Initial commit
This commit is contained in:
5
node_modules/with/lib/globals.d.ts
generated
vendored
Normal file
5
node_modules/with/lib/globals.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import * as t from '@babel/types';
|
||||
export default function findGlobals(ast: t.Node): {
|
||||
name: string;
|
||||
nodes: (t.Identifier | t.ThisExpression)[];
|
||||
}[];
|
190
node_modules/with/lib/globals.js
generated
vendored
Normal file
190
node_modules/with/lib/globals.js
generated
vendored
Normal file
@ -0,0 +1,190 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const assert_never_1 = __importDefault(require("assert-never"));
|
||||
const babel_walk_1 = require("babel-walk");
|
||||
const t = __importStar(require("@babel/types"));
|
||||
const reference_1 = __importDefault(require("./reference"));
|
||||
const isScope = (node) => t.isFunctionParent(node) || t.isProgram(node);
|
||||
const isBlockScope = (node) => t.isBlockStatement(node) || isScope(node);
|
||||
const declaresArguments = (node) => t.isFunction(node) && !t.isArrowFunctionExpression(node);
|
||||
const declaresThis = declaresArguments;
|
||||
const LOCALS_SYMBOL = Symbol('locals');
|
||||
const getLocals = (node) => node[LOCALS_SYMBOL];
|
||||
const declareLocals = (node) => (node[LOCALS_SYMBOL] = node[LOCALS_SYMBOL] || new Set());
|
||||
const setLocal = (node, name) => declareLocals(node).add(name);
|
||||
// First pass
|
||||
function declareFunction(node) {
|
||||
for (const param of node.params) {
|
||||
declarePattern(param, node);
|
||||
}
|
||||
const id = node.id;
|
||||
if (id) {
|
||||
setLocal(node, id.name);
|
||||
}
|
||||
}
|
||||
function declarePattern(node, parent) {
|
||||
switch (node.type) {
|
||||
case 'Identifier':
|
||||
setLocal(parent, node.name);
|
||||
break;
|
||||
case 'ObjectPattern':
|
||||
for (const prop of node.properties) {
|
||||
switch (prop.type) {
|
||||
case 'RestElement':
|
||||
declarePattern(prop.argument, parent);
|
||||
break;
|
||||
case 'ObjectProperty':
|
||||
declarePattern(prop.value, parent);
|
||||
break;
|
||||
default:
|
||||
assert_never_1.default(prop);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'ArrayPattern':
|
||||
for (const element of node.elements) {
|
||||
if (element)
|
||||
declarePattern(element, parent);
|
||||
}
|
||||
break;
|
||||
case 'RestElement':
|
||||
declarePattern(node.argument, parent);
|
||||
break;
|
||||
case 'AssignmentPattern':
|
||||
declarePattern(node.left, parent);
|
||||
break;
|
||||
// istanbul ignore next
|
||||
default:
|
||||
throw new Error('Unrecognized pattern type: ' + node.type);
|
||||
}
|
||||
}
|
||||
function declareModuleSpecifier(node, _state, parents) {
|
||||
for (let i = parents.length - 2; i >= 0; i--) {
|
||||
if (isScope(parents[i])) {
|
||||
setLocal(parents[i], node.local.name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
const firstPass = babel_walk_1.ancestor({
|
||||
VariableDeclaration(node, _state, parents) {
|
||||
for (let i = parents.length - 2; i >= 0; i--) {
|
||||
if (node.kind === 'var'
|
||||
? t.isFunctionParent(parents[i])
|
||||
: isBlockScope(parents[i])) {
|
||||
for (const declaration of node.declarations) {
|
||||
declarePattern(declaration.id, parents[i]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
FunctionDeclaration(node, _state, parents) {
|
||||
if (node.id) {
|
||||
for (let i = parents.length - 2; i >= 0; i--) {
|
||||
if (isScope(parents[i])) {
|
||||
setLocal(parents[i], node.id.name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
Function: declareFunction,
|
||||
ClassDeclaration(node, _state, parents) {
|
||||
for (let i = parents.length - 2; i >= 0; i--) {
|
||||
if (isScope(parents[i])) {
|
||||
setLocal(parents[i], node.id.name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
TryStatement(node) {
|
||||
if (node.handler === null)
|
||||
return;
|
||||
if (node.handler.param === null)
|
||||
return;
|
||||
declarePattern(node.handler.param, node.handler);
|
||||
},
|
||||
ImportDefaultSpecifier: declareModuleSpecifier,
|
||||
ImportSpecifier: declareModuleSpecifier,
|
||||
ImportNamespaceSpecifier: declareModuleSpecifier,
|
||||
});
|
||||
// Second pass
|
||||
const secondPass = babel_walk_1.ancestor({
|
||||
Identifier(node, state, parents) {
|
||||
var _a;
|
||||
const name = node.name;
|
||||
if (name === 'undefined')
|
||||
return;
|
||||
const lastParent = parents[parents.length - 2];
|
||||
if (lastParent) {
|
||||
if (!reference_1.default(node, lastParent))
|
||||
return;
|
||||
for (const parent of parents) {
|
||||
if (name === 'arguments' && declaresArguments(parent)) {
|
||||
return;
|
||||
}
|
||||
if ((_a = getLocals(parent)) === null || _a === void 0 ? void 0 : _a.has(name)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
state.globals.push(node);
|
||||
},
|
||||
ThisExpression(node, state, parents) {
|
||||
for (const parent of parents) {
|
||||
if (declaresThis(parent)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
state.globals.push(node);
|
||||
},
|
||||
});
|
||||
function findGlobals(ast) {
|
||||
const globals = [];
|
||||
// istanbul ignore if
|
||||
if (!t.isNode(ast)) {
|
||||
throw new TypeError('Source must be a Babylon AST');
|
||||
}
|
||||
firstPass(ast, undefined);
|
||||
secondPass(ast, { globals });
|
||||
const groupedGlobals = new Map();
|
||||
for (const node of globals) {
|
||||
const name = node.type === 'ThisExpression' ? 'this' : node.name;
|
||||
const existing = groupedGlobals.get(name);
|
||||
if (existing) {
|
||||
existing.push(node);
|
||||
}
|
||||
else {
|
||||
groupedGlobals.set(name, [node]);
|
||||
}
|
||||
}
|
||||
return [...groupedGlobals]
|
||||
.map(([name, nodes]) => ({ name, nodes }))
|
||||
.sort((a, b) => (a.name < b.name ? -1 : 1));
|
||||
}
|
||||
exports.default = findGlobals;
|
||||
//# sourceMappingURL=globals.js.map
|
1
node_modules/with/lib/globals.js.map
generated
vendored
Normal file
1
node_modules/with/lib/globals.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
8
node_modules/with/lib/index.d.ts
generated
vendored
Normal file
8
node_modules/with/lib/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Mimic `with` as far as possible but at compile time
|
||||
*
|
||||
* @param obj The object part of a with expression
|
||||
* @param src The body of the with expression
|
||||
* @param exclude A list of variable names to explicitly exclude
|
||||
*/
|
||||
export default function addWith(obj: string, src: string, exclude?: string[]): string;
|
148
node_modules/with/lib/index.js
generated
vendored
Normal file
148
node_modules/with/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,148 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const parser_1 = require("@babel/parser");
|
||||
const babel_walk_1 = require("babel-walk");
|
||||
const t = __importStar(require("@babel/types"));
|
||||
const globals_1 = __importDefault(require("./globals"));
|
||||
const parseOptions = {
|
||||
allowReturnOutsideFunction: true,
|
||||
allowImportExportEverywhere: true,
|
||||
};
|
||||
/**
|
||||
* Mimic `with` as far as possible but at compile time
|
||||
*
|
||||
* @param obj The object part of a with expression
|
||||
* @param src The body of the with expression
|
||||
* @param exclude A list of variable names to explicitly exclude
|
||||
*/
|
||||
function addWith(obj, src, exclude = []) {
|
||||
// tslint:disable-next-line: no-parameter-reassignment
|
||||
obj = obj + '';
|
||||
// tslint:disable-next-line: no-parameter-reassignment
|
||||
src = src + '';
|
||||
let ast;
|
||||
try {
|
||||
ast = parser_1.parse(src, parseOptions);
|
||||
}
|
||||
catch (e) {
|
||||
throw Object.assign(new Error('Error parsing body of the with expression'), {
|
||||
component: 'src',
|
||||
babylonError: e,
|
||||
});
|
||||
}
|
||||
let objAst;
|
||||
try {
|
||||
objAst = parser_1.parse(obj, parseOptions);
|
||||
}
|
||||
catch (e) {
|
||||
throw Object.assign(new Error('Error parsing object part of the with expression'), {
|
||||
component: 'obj',
|
||||
babylonError: e,
|
||||
});
|
||||
}
|
||||
const excludeSet = new Set([
|
||||
'undefined',
|
||||
'this',
|
||||
...exclude,
|
||||
...globals_1.default(objAst).map((g) => g.name),
|
||||
]);
|
||||
const vars = new Set(globals_1.default(ast)
|
||||
.map((global) => global.name)
|
||||
.filter((v) => !excludeSet.has(v)));
|
||||
if (vars.size === 0)
|
||||
return src;
|
||||
let declareLocal = '';
|
||||
let local = 'locals_for_with';
|
||||
let result = 'result_of_with';
|
||||
if (t.isValidIdentifier(obj)) {
|
||||
local = obj;
|
||||
}
|
||||
else {
|
||||
while (vars.has(local) || excludeSet.has(local)) {
|
||||
local += '_';
|
||||
}
|
||||
declareLocal = `var ${local} = (${obj});`;
|
||||
}
|
||||
while (vars.has(result) || excludeSet.has(result)) {
|
||||
result += '_';
|
||||
}
|
||||
const args = [
|
||||
'this',
|
||||
...Array.from(vars).map((v) => `${JSON.stringify(v)} in ${local} ?
|
||||
${local}.${v} :
|
||||
typeof ${v} !== 'undefined' ? ${v} : undefined`),
|
||||
];
|
||||
const unwrapped = unwrapReturns(ast, src, result);
|
||||
return `;
|
||||
${declareLocal}
|
||||
${unwrapped.before}
|
||||
(function (${Array.from(vars).join(', ')}) {
|
||||
${unwrapped.body}
|
||||
}.call(${args.join(', ')}));
|
||||
${unwrapped.after};`;
|
||||
}
|
||||
exports.default = addWith;
|
||||
const unwrapReturnsVisitors = babel_walk_1.recursive({
|
||||
Function(_node, _state, _c) {
|
||||
// returns in these functions are not applicable
|
||||
},
|
||||
ReturnStatement(node, state) {
|
||||
state.hasReturn = true;
|
||||
let value = '';
|
||||
if (node.argument) {
|
||||
value = `value: (${state.source(node.argument)})`;
|
||||
}
|
||||
state.replace(node, `return {${value}};`);
|
||||
},
|
||||
});
|
||||
/**
|
||||
* Take a self calling function, and unwrap it such that return inside the function
|
||||
* results in return outside the function
|
||||
*
|
||||
* @param src Some JavaScript code representing a self-calling function
|
||||
* @param result A temporary variable to store the result in
|
||||
*/
|
||||
function unwrapReturns(ast, src, result) {
|
||||
const charArray = src.split('');
|
||||
const state = {
|
||||
hasReturn: false,
|
||||
source(node) {
|
||||
return src.slice(node.start, node.end);
|
||||
},
|
||||
replace(node, str) {
|
||||
charArray.fill('', node.start, node.end);
|
||||
charArray[node.start] = str;
|
||||
},
|
||||
};
|
||||
unwrapReturnsVisitors(ast, state);
|
||||
return {
|
||||
before: state.hasReturn ? `var ${result} = ` : '',
|
||||
body: charArray.join(''),
|
||||
after: state.hasReturn ? `;if (${result}) return ${result}.value` : '',
|
||||
};
|
||||
}
|
||||
module.exports = addWith;
|
||||
module.exports.default = addWith;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/with/lib/index.js.map
generated
vendored
Normal file
1
node_modules/with/lib/index.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAoC;AACpC,2CAA6C;AAC7C,gDAAkC;AAClC,wDAA+B;AAE/B,MAAM,YAAY,GAAG;IACnB,0BAA0B,EAAE,IAAI;IAChC,2BAA2B,EAAE,IAAI;CAClC,CAAC;AAEF;;;;;;GAMG;AACH,SAAwB,OAAO,CAC7B,GAAW,EACX,GAAW,EACX,UAAoB,EAAE;IAEtB,sDAAsD;IACtD,GAAG,GAAG,GAAG,GAAG,EAAE,CAAC;IACf,sDAAsD;IACtD,GAAG,GAAG,GAAG,GAAG,EAAE,CAAC;IAEf,IAAI,GAAG,CAAC;IACR,IAAI;QACF,GAAG,GAAG,cAAK,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;KAChC;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,MAAM,CAAC,MAAM,CACjB,IAAI,KAAK,CAAC,2CAA2C,CAAC,EACtD;YACE,SAAS,EAAE,KAAK;YAChB,YAAY,EAAE,CAAC;SAChB,CACF,CAAC;KACH;IACD,IAAI,MAAM,CAAC;IACX,IAAI;QACF,MAAM,GAAG,cAAK,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;KACnC;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,MAAM,C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K,CAAC,IAAI,CAAC,KAAM,EAAE,IAAI,CAAC,GAAI,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,CAAC,IAAI,EAAE,GAAG;YACf,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,KAAM,EAAE,IAAI,CAAC,GAAI,CAAC,CAAC;YAC3C,SAAS,CAAC,IAAI,CAAC,KAAM,CAAC,GAAG,GAAG,CAAC;QAC/B,CAAC;KACF,CAAC;IAEF,qBAAqB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAElC,OAAO;QACL,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,MAAM,KAAK,CAAC,CAAC,CAAC,EAAE;QACjD,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,MAAM,YAAY,MAAM,QAAQ,CAAC,CAAC,CAAC,EAAE;KACvE,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;AACzB,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC"}
|
2
node_modules/with/lib/reference.d.ts
generated
vendored
Normal file
2
node_modules/with/lib/reference.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import * as t from '@babel/types';
|
||||
export default function isReferenced(node: t.Node, parent: t.Node): boolean;
|
43
node_modules/with/lib/reference.js
generated
vendored
Normal file
43
node_modules/with/lib/reference.js
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const t = __importStar(require("@babel/types"));
|
||||
function isReferenced(node, parent) {
|
||||
switch (parent.type) {
|
||||
// yes: { [NODE]: '' }
|
||||
// yes: { NODE }
|
||||
// no: { NODE: '' }
|
||||
case 'ObjectProperty':
|
||||
return parent.value === node || parent.computed;
|
||||
// no: break NODE;
|
||||
// no: continue NODE;
|
||||
case 'BreakStatement':
|
||||
case 'ContinueStatement':
|
||||
return false;
|
||||
// yes: left = NODE;
|
||||
// yes: NODE = right;
|
||||
case 'AssignmentExpression':
|
||||
return true;
|
||||
}
|
||||
return t.isReferenced(node, parent);
|
||||
}
|
||||
exports.default = isReferenced;
|
||||
//# sourceMappingURL=reference.js.map
|
1
node_modules/with/lib/reference.js.map
generated
vendored
Normal file
1
node_modules/with/lib/reference.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"reference.js","sourceRoot":"","sources":["../src/reference.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAElC,SAAwB,YAAY,CAAC,IAAY,EAAE,MAAc;IAC/D,QAAQ,MAAM,CAAC,IAAI,EAAE;QACnB,sBAAsB;QACtB,gBAAgB;QAChB,mBAAmB;QACnB,KAAK,gBAAgB;YACnB,OAAO,MAAM,CAAC,KAAK,KAAK,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC;QAElD,kBAAkB;QAClB,qBAAqB;QACrB,KAAK,gBAAgB,CAAC;QACtB,KAAK,mBAAmB;YACtB,OAAO,KAAK,CAAC;QAEf,oBAAoB;QACpB,qBAAqB;QACrB,KAAK,sBAAsB;YACzB,OAAO,IAAI,CAAC;KACf;IAED,OAAO,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACtC,CAAC;AArBD,+BAqBC"}
|
Reference in New Issue
Block a user