repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
liangchunn/typescript-node-scripts
template/src/App.ts
<reponame>liangchunn/typescript-node-scripts export default () => { // eslint-disable-next-line console.log('App is running'); };
liangchunn/typescript-node-scripts
src/types/TNS.ts
export interface TNSOptions { noCollapse: boolean noAutoStart: boolean useMonorepo: boolean bypassCiWarnings: boolean }
liangchunn/typescript-node-scripts
src/scripts/util/createJestConfig.ts
import chalk from 'chalk' import * as fs from 'fs' import * as path from 'path' import { paths } from '../../lib/paths' // eslint-disable-next-line @typescript-eslint/no-var-requires const appTsConfig = require(paths.appTsConfig) /** * Transform paths from tsconfig.json to Jest compatible path mappings * Transforms ...
liangchunn/typescript-node-scripts
src/lib/webpackCompiler.ts
<gh_stars>10-100 import chalk from 'chalk' import * as path from 'path' import webpack from 'webpack' import { TNSOptions } from '../types/TNS' import { clearConsole } from './clearConsole' import { formatWebpackMessages } from './formatWebpackMessages' import { AppController } from './processHandler' import { IS_INTER...
liangchunn/typescript-node-scripts
src/lib/processHandler.ts
<filename>src/lib/processHandler.ts import chalk from 'chalk' import { ChildProcess, exec, spawn } from 'child_process' import psTree, { hasPS } from 'pstree.remy' import { isWindows } from '../util/platform' type AppControllerState = | { appRunning: true proc: ChildProcess pid: string } | { ...
liangchunn/typescript-node-scripts
src/scripts/migration/tslint-to-eslint/filesystem.ts
import * as fs from 'fs-extra' export function loadJson(path: string): Promise<any> { return new Promise((resolve, reject) => { fs.readFile(path, { encoding: 'utf-8' }, (err, data) => { if (err) { return reject(err) } try { return resolve(JSON.parse(data as any)) } catch (...
liangchunn/typescript-node-scripts
src/lib/jest/typescriptPreprocessor.ts
<reponame>liangchunn/typescript-node-scripts // eslint-disable-next-line @typescript-eslint/no-var-requires const tsJestPreprocessor = require('ts-jest') module.exports = tsJestPreprocessor
liangchunn/typescript-node-scripts
src/scripts/migration/tslint-to-eslint/index.ts
import chalk from 'chalk' import { paths, resolveOwn, resolveApp } from '../../../lib/paths' import { getFileHash } from './hash' import { loadJson, saveJson } from './filesystem' import * as fs from 'fs-extra' import { spawnSync } from 'child_process' import { createMigrationLogger, MIGRATION_OP_TYPE, } from '../....
liangchunn/typescript-node-scripts
tests/sink/ts-js-integration/__tests__/ts-import-js.ts
<filename>tests/sink/ts-js-integration/__tests__/ts-import-js.ts<gh_stars>10-100 import * as cjs from "../cjs"; import cjsDefault, { readFileSync as CJS_READ_FILE_SYNC, TEST as CJS_TEST, } from "../cjs"; import * as esm from "../esm"; import esmDefault, { readFileSync as ESM_READ_FILE_SYNC, TEST as ESM_...
liangchunn/typescript-node-scripts
tests/sink/typescript-3.7/__tests__/index.test.ts
import { f, OptChainType } from '../index' describe('optional chaining and nullish coalesing', () => { it('returns Infinity if any of the paths of OptChainType is undefined', () => { const optChainObject: OptChainType = { a: {} } expect(f(optChainObject)).toEqual(Infinity) }) it('returns a.b.c ...
liangchunn/typescript-node-scripts
src/lib/createWebpackConfig.ts
import * as webpack from 'webpack' import CaseSensitivePathsWebpackPlugin from 'case-sensitive-paths-webpack-plugin' import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin' import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin' import nodeExternals from 'webpack-node-externals' import { CleanWe...
liangchunn/typescript-node-scripts
src/scripts/util/migrationLogger.ts
<reponame>liangchunn/typescript-node-scripts import chalk from 'chalk' export enum MIGRATION_OP_TYPE { WRITE = 'write', MODIFY = 'modify', DELETE = 'delete', SKIP = 'skip', INFO = 'info', INSTALL = 'install', DONE = 'done', ERROR = 'error', } export function createMigrationLogger() { function log(me...
liangchunn/typescript-node-scripts
src/scripts/util/fileSizeReporter.ts
<reponame>liangchunn/typescript-node-scripts<gh_stars>10-100 import chalk from 'chalk' import filesize from 'filesize' import * as fs from 'fs' interface FileSizeObjectOutput { value: number symbol: string } export const getBundleSize = (fileName: string) => { try { const read = fs.statSync(fileName) re...
liangchunn/typescript-node-scripts
src/scripts/create.ts
process.on('unhandledRejection', (err) => { throw err }) import chalk from 'chalk' import { execSync, spawnSync } from 'child_process' import * as fs from 'fs-extra' import * as os from 'os' import * as path from 'path' import { yarnAvailable } from './util/yarnAvailable' const argv = process.argv.slice(2) const c...
liangchunn/typescript-node-scripts
src/injectors/dev.ts
process.env.NODE_ENV = 'development' process.on('unhandledRejection', (err) => { throw err })
liangchunn/typescript-node-scripts
tests/sink/ts-js-integration/index.ts
<filename>tests/sink/ts-js-integration/index.ts import * as assert from "assert"; import * as cjs from "./cjs"; import esmDefault, { readFileSync as ESM_READ_FILE_SYNC, TEST as ESM_TEST } from "./cjs"; import cjsDefault, { readFileSync as CJS_READ_FILE_SYNC, TEST as CJS_TEST } from "./cjs"; import * as esm from...
liangchunn/typescript-node-scripts
tests/sink/ts-js-integration/__tests__/ts.ts
<filename>tests/sink/ts-js-integration/__tests__/ts.ts<gh_stars>10-100 import * as tsRelative from "../ts"; import * as tsAbsolute from "~/ts"; describe("ts: absolute imports", () => { it("exports variables", () => { expect(typeof tsRelative.TEST === "number").toBe(true); }); it("exports default", () => { ...
liangchunn/typescript-node-scripts
src/lib/paths.ts
import * as fs from 'fs' import * as path from 'path' const appDirectory = fs.realpathSync(process.cwd()) const useTemplate = appDirectory === fs.realpathSync(path.join(__dirname, '../..')) export function resolveApp(relativePath: string): string { return path.resolve(appDirectory, relativePath) } export functio...
liangchunn/typescript-node-scripts
tests/sink/ts-js-integration/ts.ts
<reponame>liangchunn/typescript-node-scripts<filename>tests/sink/ts-js-integration/ts.ts export const TEST = 2; export default () => { // eslint-disable-next-line console.log('App is running'); };
liangchunn/typescript-node-scripts
src/scripts/test.ts
import * as jest from 'jest' import * as path from 'path' import '../injectors/test' import { paths } from '../lib/paths' import { createJestConfig } from './util/createJestConfig' const argv = process.argv.slice(2) if ( !process.env.CI && argv.indexOf('--coverage') === -1 && argv.indexOf('--watchAll') === -1 ) ...
liangchunn/typescript-node-scripts
template/setupTests.ts
/** * This file is used to set up the testing framework * before each test is executed. * * For more information, please consult: * https://facebook.github.io/jest/docs/en/configuration.html#setuptestframeworkscriptfile-string */
liangchunn/typescript-node-scripts
tests/sink/typescript-3.7/index.ts
export type OptChainType = { a?: { b?: { c: number; }; }; } export function f(arg: OptChainType) { return arg.a?.b?.c ?? Infinity }
liangchunn/typescript-node-scripts
src/util/env.ts
<reponame>liangchunn/typescript-node-scripts import { TNSOptions } from '../types/TNS' const { argv } = process export const TNS_ARGUMENTS = { MONOREPO: '--monorepo', NO_COLLAPSE: '--no-collapse', NO_AUTO_STATRT: '--no-auto-start', BYPASS_CI_WARNINGS: '--bypass-ci-warnings', } export const RuntimeOptions: TN...
liangchunn/typescript-node-scripts
src/scripts/util/fileExists.ts
import * as fs from 'fs-extra' export function fileExists(path: string): Promise<boolean> { return new Promise((resolve) => { fs.access(path, fs.constants.F_OK, (err) => { if (err) { return resolve(false) } else { return resolve(true) } }) }) }
liangchunn/typescript-node-scripts
src/injectors/test.ts
<reponame>liangchunn/typescript-node-scripts process.env.NODE_ENV = 'test' process.on('unhandledRejection', (err) => { throw err })
acro5piano/send-audio-data-via-fetch-example
frontend/index.ts
<reponame>acro5piano/send-audio-data-via-fetch-example const mimeType = 'audio/webm' function createRecorder(stream: MediaStream): MediaRecorder { if (MediaRecorder.isTypeSupported('audio/webm')) { return new MediaRecorder(stream, { mimeType }) } else { // Safari is not support audio/webm natively, so we s...
acro5piano/send-audio-data-via-fetch-example
server/file.ts
<filename>server/file.ts import delay from 'delay' import fs from 'fs/promises' import MQEmitterRedis from 'mqemitter-redis' const ee = MQEmitterRedis({ port: 46379, }) ee.on('message', ({ fileName, data }, cb) => { console.log(fileName) fs.appendFile(fileName, data).then(cb) }) export async function publish(f...
acro5piano/send-audio-data-via-fetch-example
server/worker.ts
import { EventEmitter } from 'events' import { execa } from 'execa' import delay from 'delay' export const ee = new EventEmitter() let ffmpegStarted = false ee.on('start-ffmpeg', async (pathName: string) => { if (ffmpegStarted) { return } ffmpegStarted = true await delay(3000) await Promise.all([ ...
acro5piano/send-audio-data-via-fetch-example
server/http.ts
import Fastify from 'fastify' import FastifyStatic from 'fastify-static' import path from 'path' import FastifyMultipart from 'fastify-multipart' import cors from 'fastify-cors' import { ee } from './worker' import { publish } from './file' export const app = Fastify({ logger: true }) app.register(cors) app.registe...
acro5piano/send-audio-data-via-fetch-example
server/index.ts
<reponame>acro5piano/send-audio-data-via-fetch-example import { app } from './http' app.listen(9999)
SahanaSreeH/Spectagram-stage---1
node_modules/@react-navigation/bottom-tabs/lib/typescript/src/index.d.ts
/** * Navigators */ export { default as createBottomTabNavigator } from './navigators/createBottomTabNavigator'; /** * Views */ export { default as BottomTabBar } from './views/BottomTabBar'; export { default as BottomTabView } from './views/BottomTabView'; /** * Utilities */ export { default as BottomTabBarHeigh...
surfypro/surfy-api-nodejs
src/helper.ts
import { JupWhereOperator, PropertyTypeJupValues, IJupWhereNode } from "./jup.models"; export function createFilter(operator: JupWhereOperator, column: string, value: PropertyTypeJupValues): IJupWhereNode { return { operator, column, value }; }
surfypro/surfy-api-nodejs
src/schema/queryNodes.generated.ts
<reponame>surfypro/surfy-api-nodejs import { JupQueryNode } from "../jup.models"; export namespace QueryNodes { export type JupObjectTypeScalarProperties = 'id' | 'name' | 'createdAt' | 'updatedAt' | 'externalId'; export type JupObjectTypeHasManyProperties = JupUiViews | JupRoleToJupObjectTypes export typ...
surfypro/surfy-api-nodejs
src/jup.models.ts
<reponame>surfypro/surfy-api-nodejs import { Surfy } from "./schema/surfy.models.generated"; export interface IJupQueryNodePagination { limit: number; offset?: number; } export interface JupQueryNode { name: string; _: JupQueryTree; filters?: JupQueryNodeFilter[]; pagination?: IJupQueryNodePag...
surfypro/surfy-api-nodejs
src/models.ts
import { JupQueryNode } from "./jup.models"; export interface IApiAuthorizeBody { clientId: string; clientSecret: string; } export interface IApiAuthorizeResult { token: string; } export interface IListEntitiesBody { queryNode: JupQueryNode; }
surfypro/surfy-api-nodejs
src/index.ts
import * as dotenv from "dotenv"; import axios, { AxiosResponse } from 'axios'; import { IApiAuthorizeBody, IApiAuthorizeResult, IListEntitiesBody } from "./models"; import https from 'https'; import { QueryNodes } from "./schema/queryNodes.generated"; import { createFilter } from "./helper"; dotenv.config(); async f...
mwilliamson/Stopify
stopify/src/browserLine.ts
<filename>stopify/src/browserLine.ts import * as path from 'path'; export function localBenchmarkUrl(args: string[]) { args[0] = 'file://' + path.resolve(args[0]); const ret = 'file://' + path.resolve(__dirname, '../../dist/benchmark.html') + '#' + encodeURIComponent(JSON.stringify(args)); return ret; } exp...
mwilliamson/Stopify
stopify-continuations/src/runtime/abstractRuntime.ts
import * as assert from 'assert'; import { Result, Runtime, Stack, Mode, KFrameTop, KFrameRest } from '../types'; import * as types from '../types'; export type RunResult = { type: 'normal', value: any } | { type: 'exception', value: any } | { type: 'capture', stack: Stack, f: (value: any) => any } | { type:...
mwilliamson/Stopify
stopify-continuations-compiler/src/callcc/declVars.ts
/** * Assumes that singleVarDecls has run before this and handled all the `let` * and `const` declarations. * * Moves var statements to the top of functions. * * When a var is moved, it is initialized to undefined. The * transformation introduces assignment statements where the var statement * originally occurr...
mwilliamson/Stopify
stopify-continuations-compiler/src/exposeImplicitApps.ts
import { NodePath, Visitor } from 'babel-traverse'; import * as t from 'babel-types'; import * as imm from 'immutable'; import { runtimePath } from './helpers'; export const implicitsIdentifier = t.identifier('$i'); const binopTable = imm.Map<string,string>([ ['+', 'add'], ['-', 'sub'], ['/', 'div'], ['*', 'm...
mwilliamson/Stopify
normalize-js/ts/desugarSwitch.ts
/** * Desugars switch statements to if statements. * * switch(e1) { * case c1: * s1 ... * break; * case c2: * s2 ... * default: * s3 ... * } * * is transformed into: * * _sw { * let fallthrough = false; * let test = e1; * if (test === c1 || fallthroug) { * s1 ... * ...
mwilliamson/Stopify
stopify/test/browser-integration.test.ts
import * as f from './testFixtures.js'; import * as glob from 'glob'; describe('In-browser tests', function () { glob.sync('test/browser/*.js').forEach(file => { f.browserTest(file, 'lazy'); }); });
mwilliamson/Stopify
stopify-higher-order-functions/ts/mozillaHofPolyfill.ts
// Do not directly use this file. We stopify and webpack this file for each // type of transformation. function array_map(obj: any, callback: any, thisArg?: any) { var T, A, k; if (obj === null) { throw new TypeError('this is null or not defined'); } // 1. Let O be the result of calling ToObject passing the...
mwilliamson/Stopify
stopify-continuations-compiler/test/callcc.test.ts
<gh_stars>100-1000 import * as assert from 'assert'; const glob = require('glob'); import * as t from 'babel-types'; import * as fs from 'fs'; import * as tmp from 'tmp'; import { spawnSync } from 'child_process'; import * as continuationRTS from '@stopify/continuations-runtime/dist/src/runtime/runtime'; import { compi...
mwilliamson/Stopify
normalize-js/ts/desugarLoop.ts
/** * Module to desugar all loops to while loops. This requires * the following transformations to be done: * * This plugin must enforce the following assumption about loops: * * Loop bodies are BlockStatements: * Loops can have an ExpressionStatement for their body. This messes * up the anf pass since it tries...
mwilliamson/Stopify
util/ts/index.ts
export * from './babelHelpers'; export * from './helpers'; export * from './result';
mwilliamson/Stopify
stopify-continuations/src/runtime/fudgeRuntime.ts
<filename>stopify-continuations/src/runtime/fudgeRuntime.ts import * as common from './abstractRuntime'; export * from './abstractRuntime'; import { Result, Stack } from '../types'; import * as types from '../types'; class FudgedContinuationError { constructor(public v: any) {} toString() { return `FudgedCont...
mwilliamson/Stopify
normalize-js/ts/desugarFunctionDecl.ts
<reponame>mwilliamson/Stopify import { NodePath, Visitor } from 'babel-traverse'; import * as t from 'babel-types'; import { letExpression } from '@stopify/util'; const functionDecl: Visitor = { FunctionDeclaration: function (path: NodePath<t.FunctionDeclaration>) { const { id, params, body } = path.node; pa...
mwilliamson/Stopify
normalize-js/ts/setExt.ts
/** Set difference */ export function diff<T>(setA: Set<T>, setB: Set<T>): Set<T> { var difference = new Set<T>(setA); for (const elem of setB) { difference.delete(elem); } return difference; } export function union<T>(setA: Set<T>, setB: Set<T>): Set<T> { let union = new Set<T>(setA); for (const elem ...
mwilliamson/Stopify
normalize-js/ts/freeIds.ts
<reponame>mwilliamson/Stopify /** * This module annotates the AST with the following information: * * 1. All scopeable nodes are annotated with a set of free identifiers. * 2. All function and program nodes are annotated with the set of * free identifiers in their enclosing functions. */ import * as t from 'ba...
mwilliamson/Stopify
stopify-continuations-compiler/src/compiler/flatness.ts
<reponame>mwilliamson/Stopify import * as t from 'babel-types'; import { NodePath, Visitor } from 'babel-traverse'; import { markFlatFunctions } from './markFlatFunctions'; import { markAnnotated } from './markAnnotated'; import { markFlatApplications } from './markFlatApplications'; import { transformFromAst } from '@...
mwilliamson/Stopify
normalize-js/ts/desugarLogical.ts
<reponame>mwilliamson/Stopify /** * Preconditions: * * 1. The program only contains while loops * * Postconditions: * * 1. Function calls do not occur within &&-expressions, ||-expressions, * ternary expressions, and expression sequences (the comma operator). * 2. Function applications do not occur i...
mwilliamson/Stopify
stopify-continuations-compiler/src/callcc/index.ts
import * as jumper from './jumper'; export * from '../runtime/sentinels'; export { knownBuiltIns } from '../common/cannotCapture'; export * from '../types';
mwilliamson/Stopify
stopify-continuations-compiler/src/compiler/markFlatApplications.ts
/** * This visitor should be ran after markFlatFunctions. It assumes that * function nodes have a `.mark` field that says whether or not they * are flat. */ import { NodePath, VisitNode, Visitor } from 'babel-traverse'; import * as t from 'babel-types'; import { FlatTag, FlatnessMark } from '../helpers'; /** * 0 ...
mwilliamson/Stopify
stopify/test/integration.test.ts
<reponame>mwilliamson/Stopify /** * Each integration test is a web page in the test-data/integration/ directory. * We use Selenium (with Chrome) to visit the page and wait for the title to be * "okay" or "error". */ import * as selenium from 'selenium-webdriver'; import * as chrome from 'selenium-webdriver/chrome'...
mwilliamson/Stopify
stopify-continuations-compiler/src/runtime/gettersSetters.ts
// Do not directly use this file. We stopify and webpack this file for each // type of transformation. export function get_prop(obj: any, prop: any) { const v = obj[prop]; if (typeof v === 'function') { const func = v.bind(obj); func.prototype = v.prototype; return func; } else { return v; } ...
mwilliamson/Stopify
stopify/src/compiler/compiler.ts
<reponame>mwilliamson/Stopify<filename>stopify/src/compiler/compiler.ts import * as babel from 'babel-core'; import * as types from '../types'; import * as stopifyCallCC from '../stopify/stopifyCallCC'; import * as babylon from 'babylon'; /** * Compiles (i.e., "stopifies") a program. This function should not be used...
mwilliamson/Stopify
stopify-continuations-compiler/src/runtime/sentinels.ts
/** * This file has private sentinal values that are necessary to implement * certain transformations. */ export const RV_SENTINAL = Symbol('rv_sentinal'); export const EXN_SENTINAL = Symbol('exn_sentinal');
mwilliamson/Stopify
stopify-continuations-compiler/src/exposeGettersSetters.ts
/** * This transformation allows for getters and setters support in stopify. * Getters and setters are implicity called on object accesses. This * transform makes it such accesses explicit: * * Getters: a.b => $gs.get_prop(a, "b") * Setters: a.b = v => $gs.get_prop(a, "b", v) * Delete: delete a.b => $...
mwilliamson/Stopify
util/ts/result.ts
class Ok<T> { public kind: 'ok' = 'ok'; constructor(public value: T) { } then<S>(f: (x: T) => Result<S>): Result<S> { return f(this.value); } map<S>(f: (x: T) => S): Result<S> { return asResult(() => f(this.value)); } unwrap(): T { return this.value; } } c...
mwilliamson/Stopify
stopify-continuations-compiler/src/callcc/label.ts
import {NodePath, Visitor} from 'babel-traverse'; import * as t from 'babel-types'; import { cannotCapture } from '../common/cannotCapture'; import * as h from '@stopify/util'; import * as imm from 'immutable'; export enum AppType { None = 0, Tail = 1, Mixed = 2 } export type Labeled<T> = T & { labels?: numbe...
mwilliamson/Stopify
normalize-js/ts/desugarLabel.ts
/** * Module to add labels to breaks and continues according to tagged AST nodes * generated by desugarLoop. * */ import { NodePath, Visitor } from 'babel-traverse'; import * as t from 'babel-types'; import { While, Break } from '@stopify/util'; const labelVisitor : Visitor = { ContinueStatement: function (path...
mwilliamson/Stopify
stopify/src/runtime/makeEstimator.ts
<filename>stopify/src/runtime/makeEstimator.ts import { RuntimeOpts } from '../types'; import { unreachable } from '../generic'; import { ElapsedTimeEstimator, ExactTimeEstimator, CountdownTimeEstimator, SampleAverageTimeEstimator, VelocityEstimator, } from '@stopify/estimators'; /** * Checks the current ti...
mwilliamson/Stopify
hygiene/ts/hygiene.ts
<gh_stars>100-1000 import { NodePath, Visitor } from 'babel-traverse'; import * as t from 'babel-types'; import * as fastFreshId from './fastFreshId'; import { State } from './types'; const visitor: Visitor = { Scope({ scope }: NodePath<t.Scopable>, { opts: { reserved } }: State) { const shadows = Object...
mwilliamson/Stopify
stopify/src/bin/stopifyPath.ts
/** * This program returns the local URLs to Stopify's bundles. These URLs * can be used as the source of locally hosted <script>s. */ const validPaths = [ 'stopify.bundle.js', 'stopify-full.bundle.js' ]; function main() { if (process.argv.length !== 3) { console.log('expected one argument'); process.exit...
mwilliamson/Stopify
stopify-higher-order-functions/test/unitTests.test.ts
import * as stopify from '@stopify/stopify'; import * as babylon from 'babylon'; import * as assert from 'assert'; import { polyfillHofFromAst } from '../ts/index'; // The compiler produces code that expects Stopify and its runtime compiler to // be a global variable. (global as any).stopify = stopify; const runtimeOpt...
mwilliamson/Stopify
normalize-js/ts/index.ts
import * as babel from 'babel-core'; import * as callcc from './callcc'; import * as freeIds from './freeIds'; import * as generic from './generic'; import * as babylon from 'babylon'; export { default as plugin } from './callcc'; export { freeIds, generic }; export { unreachable } from './generic'; import * as hygiene...
mwilliamson/Stopify
normalize-js/ts/main.ts
#!/usr/bin/env node import * as fs from 'fs'; import * as normalize from '.'; let args = process.argv; if (args.length !== 3) { console.error('Expected one argument: filename.js'); process.exit(1); } let code = fs.readFileSync(args[2], { encoding: 'utf-8' }); console.log(normalize.normalize(code));
mwilliamson/Stopify
stopify-continuations-compiler/src/types.ts
import * as t from 'babel-types'; import { Result } from '@stopify/continuations-runtime'; export interface LineMapping { getLine: (line: number, column: number) => number | null } export type CaptureMethod = 'eager' | 'retval' | 'lazy' | 'catch' | 'original' | 'fudge'; export type HandleNew = 'direct' | 'wrapper';...
mwilliamson/Stopify
hygiene/ts/fastFreshId.ts
<gh_stars>100-1000 /** * This module generates fresh identifiers much faster than Babel's * own functions to do so. */ import { NodePath } from 'babel-traverse'; import { transformFromAst } from '@stopify/util'; import * as t from 'babel-types'; import * as assert from 'assert'; const trie = require('trie'); // NOTE...
mwilliamson/Stopify
stopify-continuations-compiler/src/compiler/markFlatFunctions.ts
<filename>stopify-continuations-compiler/src/compiler/markFlatFunctions.ts /** * Mark functions are not provably flat as 'Untransformed' and others as * 'Transformed'. This only marks the approproiate AST nodes. It is the job of * the transformation to use the information. */ import * as t from 'babel-types'; impo...
mwilliamson/Stopify
normalize-js/ts/singleVarDecls.ts
import * as babel from 'babel-core'; import { NodePath } from 'babel-traverse'; import * as t from 'babel-types'; import * as bh from "@stopify/util"; import { fresh } from '@stopify/hygiene'; function getFunctionArgs(path: NodePath<t.Node>): string[] { const node = path.node; if (node.type === 'FunctionDeclaratio...
mwilliamson/Stopify
util/ts/helpers.ts
<filename>util/ts/helpers.ts import * as babel from 'babel-core'; import * as t from 'babel-types'; import { NodePath } from 'babel-traverse'; export { letExpression } from './babelHelpers'; export type FunctionNode = t.FunctionDeclaration | t.FunctionExpression | t.ObjectMethod; // Helper to generate tagging funct...
mwilliamson/Stopify
stopify-continuations-compiler/test/flatness.test.ts
import * as h from '../src/helpers'; import { markFlatFunctions } from '../src/compiler/markFlatFunctions' import { markFlatApplications } from '../src/compiler/markFlatApplications' import * as babel from 'babel-core'; import { NodePath } from 'babel-traverse'; import * as t from 'babel-types'; /** * The tests only ...
mwilliamson/Stopify
stopify-continuations-compiler/src/callcc/jumper.ts
<reponame>mwilliamson/Stopify<filename>stopify-continuations-compiler/src/callcc/jumper.ts import * as t from 'babel-types'; import * as assert from 'assert'; import * as bh from '@stopify/util'; import { generic } from '@stopify/normalize-js'; import { fresh } from '@stopify/hygiene'; import * as imm from 'immutable';...
mwilliamson/Stopify
continuations-playground/ts/index.tsx
import * as React from 'react'; import * as ReactDOM from 'react-dom'; import MonacoEditor from 'react-monaco-editor'; import { Hook, Console, Decode } from 'console-feed'; import { compile } from 'stopify-continuations-compiler'; function appendLog(method: 'log' | 'error', msg: any) { return function(prevState: {...
mwilliamson/Stopify
normalize-js/test/unit-tests.test.ts
import { normalize } from '../ts'; import * as vm from 'vm'; function normalizeEquiv(original: string) { let compiled = normalize(original); expect(compiled.trim()).not.toEqual(original.trim()); let originalResult = vm.runInNewContext(original); let normalizedResult = vm.runInNewContext(compiled); ...
mwilliamson/Stopify
stopify/src/stopify/suspendStop.ts
import { NodePath, Visitor } from 'babel-traverse'; import * as t from 'babel-types'; function handleBlock(body: t.BlockStatement) { body.body.unshift(t.expressionStatement( t.callExpression( t.memberExpression(t.identifier("$S"), t.identifier("suspend")), []))); } type BlockBody = { node: { body: t.Blo...
mwilliamson/Stopify
stopify/src/entrypoints/runtimeOnly.ts
/** * This is the entrypont for stopify.bundle.js. A page that includes this * entrypoint can only run stopified code that is compiled on the server. * To run the compiler in the browser, see compiler.ts. */ import { RuntimeOpts, AsyncRun, Result } from '../types'; import { Runtime } from '@stopify/continuations-ru...
mwilliamson/Stopify
stopify/src/index.ts
<gh_stars>100-1000 import * as types from './types'; import { compile } from './compiler/compiler'; import { checkAndFillCompilerOpts } from '@stopify/continuations/dist/src/compiler/check-compiler-opts'; import { getSourceMap } from '@stopify/continuations'; export * from './entrypoints/compiler'; export function st...
mwilliamson/Stopify
stopify-continuations-compiler/src/compiler/tool.ts
/** * Command-line to compile continuations. */ import * as babel from 'babel-core'; import * as t from 'babel-types'; import * as cli from './parse-compiler-opts'; import * as fs from 'fs'; import { NodePath, Visitor } from 'babel-traverse'; import callcc from '../callcc/callcc'; import { flatness } from './flatness...
mwilliamson/Stopify
stopify-continuations/src/index.ts
export * from './types'; export * from './runtime/runtime';
mwilliamson/Stopify
stopify-continuations-compiler/src/callcc/captureLogics.ts
<reponame>mwilliamson/Stopify import { NodePath } from 'babel-traverse'; import * as t from 'babel-types'; import { fresh } from '@stopify/hygiene'; import * as bh from '@stopify/util'; import * as h from '../helpers'; import { getLabels } from './label'; import { CompilerOpts } from '../types'; export { isNormalMod...
mwilliamson/Stopify
normalize-js/ts/liftVar.ts
/** * Moves var statements to the top of functions. * * When a var is moved, it is initialized to undefined. The * transformation introduces assignment statements where the var statement * originally occurred. */ import { NodePath, Visitor } from 'babel-traverse'; import * as t from 'babel-types'; import { tag } ...
mwilliamson/Stopify
stopify/src/runtime/node.ts
/** * Runtime system for Node */ import { RuntimeOpts } from '../types'; import { Runtime, Result } from '@stopify/continuations-runtime'; import { RuntimeWithSuspend } from './suspend'; import { makeEstimator } from './makeEstimator'; import { parseRuntimeOpts } from '../parse-runtime-opts'; let continuationsRTS: R...
mwilliamson/Stopify
hygiene/ts/index.ts
<gh_stars>100-1000 /* * This plugin can help another plugin be hygienic (in the Scheme macro sense) * when introducing new names. It requires as an option an array of identifiers * that the program should not use and renames all binding and bound occurences * of those identifiers. */ import { Visitor } from 'babel...
mwilliamson/Stopify
stopify-continuations-compiler/src/compiler/parse-compiler-opts.ts
/** * Command-line to compile continuations. */ import * as commander from 'commander'; import { CompilerOpts } from '../types'; import { checkAndFillCompilerOpts } from './check-compiler-opts'; commander.option( '-t, --transform <transformation>', 'either eager, lazy, catch, retval, original, or fudge'); comma...
mwilliamson/Stopify
stopify-continuations/src/runtime/runtime.ts
<filename>stopify-continuations/src/runtime/runtime.ts /** * Entrypoint of the stopify-continuations bundle */ import { RuntimeImpl } from './abstractRuntime'; import { LazyRuntime } from './lazyRuntime'; import { EagerRuntime } from './eagerRuntime'; import { RetvalRuntime } from './retvalRuntime'; import { FudgeRu...
mwilliamson/Stopify
stopify-continuations-compiler/src/callcc/callcc.ts
<filename>stopify-continuations-compiler/src/callcc/callcc.ts /** * Adds support for callCC. * * This module is a Node plugin. In addition, it can be applied from the * command line: * * node built/src/callcc/callcc <filename.js> */ import * as normalizeJs from '@stopify/normalize-js'; import * as boxAssignables...
mwilliamson/Stopify
stopify-continuations/src/runtime/eagerRuntime.ts
<reponame>mwilliamson/Stopify import * as common from './abstractRuntime'; export * from './abstractRuntime'; import { Result, Stack } from '../types'; import * as types from '../types'; export class EagerRuntime extends common.RuntimeImpl { kind: types.CaptureMethod = 'eager'; eagerStack: Stack; constructor(s...
mwilliamson/Stopify
normalize-js/ts/makeBlockStmt.ts
/** * Transforms loop bodies and conditional branches to block statements. */ import {NodePath, VisitNode, Visitor} from 'babel-traverse'; import * as t from 'babel-types'; // Consequents and alternatives in if statements must always be blocked, // otherwise variable declaration get pulled outside the branch. const ...
mwilliamson/Stopify
stopify/test/getter-setter.test.ts
<filename>stopify/test/getter-setter.test.ts import * as tmp from 'tmp'; import * as fs from 'fs'; import { execSync } from 'child_process'; const glob = require('glob'); describe('getter and setter support', () => { const files = glob.sync('test/getter-setter/*.js'); for (const src of files) { test(src, () =...
mwilliamson/Stopify
stopify-continuations-compiler/src/callcc/boxAssignables.ts
/** * This transformation boxes certain assignable variables to preserve * reference equality when the stack is reconstructed. * * Preconditions: * 1. The freeIds pass has been applied. */ import * as t from 'babel-types'; import * as babel from 'babel-core'; import * as assert from 'assert'; import { Binding, No...
mwilliamson/Stopify
hygiene/ts/types.ts
import * as t from 'babel-types'; import * as h from '@stopify/util'; export type State = { opts: { reserved: string[], global: t.Expression | undefined } };
mwilliamson/Stopify
stopify-continuations-compiler/src/compiler/check-compiler-opts.ts
/** * This module contains functions to check and normalize compiler options. */ import { CompilerOpts } from '../types'; import * as sourceMaps from './sourceMaps'; import * as t from 'babel-types'; import { RawSourceMap } from 'source-map'; const validFlags = [ 'compileFunction', 'getters', 'debug', 'capt...
mwilliamson/Stopify
stopify/src/testing/loader.ts
import { sum } from '../generic'; import { sprintf } from 'sprintf'; declare var stopify: any; const data = <HTMLTextAreaElement>document.getElementById('data')!; const startTime = Date.now(); let lastYieldTime: number | undefined; let yieldIntervals: number[] = []; let yields = 0; console.log = function (str: any) ...
mwilliamson/Stopify
stopify/src/compile.ts
<filename>stopify/src/compile.ts import 'source-map-support/register'; import * as fs from 'fs'; import { stopify } from './index'; import * as parseCli from '@stopify/continuations/dist/src/compiler/parse-compiler-opts'; function main() { const src = fs.readFileSync(parseCli.srcPath, 'utf8'); const dstCode = stop...
mwilliamson/Stopify
stopify-continuations-compiler/src/common/cannotCapture.ts
import * as t from 'babel-types'; const knowns = ['Object', 'Function', 'Boolean', 'Symbol', 'Error', 'EvalError', //'InternalError', 'RangeError', 'ReferenceError', 'SyntaxError', 'TypeError', 'URIError', 'Number', 'Math', 'Date', 'String', 'RegExp', 'Array', 'Int8Array', 'Uint8A...
mwilliamson/Stopify
stopify/src/runtime/setImmediate.ts
/** * A browser-dependent implementation of setImmediate. We have performed * simple experiments to determine which implementation of setImmediate is * fastest on each browser. We use postMessage for any browser that we haven't * tested. */ import * as browser from 'detect-browser'; function makeSetImmediateMC():...
mwilliamson/Stopify
stopify-continuations-compiler/src/compiler/sourceMaps.ts
<filename>stopify-continuations-compiler/src/compiler/sourceMaps.ts import { SourceMapConsumer, RawSourceMap } from 'source-map'; import { LineMapping } from '../types'; import * as convertSourceMap from 'convert-source-map'; class LineMappingImpl implements LineMapping { constructor(public getLine: (line: number, c...