Initial commit

This commit is contained in:
2021-08-26 21:47:42 +02:00
commit fe941c6433
1432 changed files with 161130 additions and 0 deletions

9
node_modules/with/.babelrc generated vendored Normal file
View File

@ -0,0 +1,9 @@
{
"presets": [
[ "es2015", { "loose": true } ]
],
"plugins": [
"add-module-exports",
"transform-runtime"
]
}

View File

@ -0,0 +1,40 @@
name: Publish Canary
on:
push:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn install --frozen-lockfile
- run: yarn prettier:check
- run: yarn test
publish-canary:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
registry-url: 'https://registry.npmjs.org'
- run: yarn install --frozen-lockfile
- run: yarn build
- run: npx rollingversions publish --canary $GITHUB_RUN_NUMBER
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

View File

@ -0,0 +1,38 @@
name: Release
on:
repository_dispatch:
types: [rollingversions_publish_approved]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn install --frozen-lockfile
- run: yarn prettier:check
- run: yarn test
publish:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
registry-url: 'https://registry.npmjs.org'
- run: yarn install --frozen-lockfile
- run: yarn build
- run: npx rollingversions publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

24
node_modules/with/.github/workflows/test.yml generated vendored Normal file
View File

@ -0,0 +1,24 @@
name: Test
on:
pull_request:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn install --frozen-lockfile
- run: yarn prettier:check
- run: yarn test

19
node_modules/with/LICENSE generated vendored Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2013 Forbes Lindesay
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

87
node_modules/with/README.md generated vendored Normal file
View File

@ -0,0 +1,87 @@
# with
Compile time `with` for strict mode JavaScript
[![Build Status](https://img.shields.io/github/workflow/status/pugjs/with/Publish%20Canary/master?style=for-the-badge)](https://github.com/pugjs/with/actions?query=workflow%3A%22Publish+Canary%22)
[![Rolling Versions](https://img.shields.io/badge/Rolling%20Versions-Enabled-brightgreen?style=for-the-badge)](https://rollingversions.com/pugjs/with)
[![NPM version](https://img.shields.io/npm/v/with?style=for-the-badge)](https://www.npmjs.com/package/with)
## Installation
$ npm install with
## Usage
```js
var addWith = require('with');
addWith('obj', 'console.log(a)');
// => ';(function (console, a) {
// console.log(a)
// }("console" in obj ? obj.console :
// typeof console!=="undefined" ? console : undefined,
// "a" in obj ? obj.a :
// typeof a !== "undefined" ? a : undefined));'
addWith('obj', 'console.log(a)', ['console']);
// => ';(function (console, a) {
// console.log(a)
// }("a" in obj ? obj.a :
// typeof a !== "undefined" ? a : undefined));'
```
## API
### addWith(obj, src[, exclude])
The idea is that this is roughly equivallent to:
```js
with (obj) {
src;
}
```
There are a few differences though. For starters, assignments to variables will always remain contained within the with block.
e.g.
```js
var foo = 'foo';
with ({}) {
foo = 'bar';
}
assert(foo === 'bar'); // => This fails for compile time with but passes for native with
var obj = {foo: 'foo'};
with ({}) {
foo = 'bar';
}
assert(obj.foo === 'bar'); // => This fails for compile time with but passes for native with
```
It also makes everything be declared, so you can always do:
```js
if (foo === undefined)
```
instead of
```js
if (typeof foo === 'undefined')
```
This is not the case if foo is in `exclude`. If a variable is excluded, we ignore it entirely. This is useful if you know a variable will be global as it can lead to efficiency improvements.
It is also safe to use in strict mode (unlike `with`) and it minifies properly (`with` disables virtually all minification).
#### Parsing Errors
with internally uses babylon to parse code passed to `addWith`. If babylon throws an error, probably due to a syntax error, `addWith` returns an error wrapping the babylon error, so you can
retrieve location information. `error.component` is `"src"` if the error is in the body or `"obj"` if it's in the object part of the with expression. `error.babylonError` is
the error thrown from babylon.
## License
MIT

5
node_modules/with/lib/globals.d.ts generated vendored Normal file
View 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
View 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

File diff suppressed because one or more lines are too long

8
node_modules/with/lib/index.d.ts generated vendored Normal file
View 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
View 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
View 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,CAAC,MAAM,CACjB,IAAI,KAAK,CAAC,kDAAkD,CAAC,EAC7D;YACE,SAAS,EAAE,KAAK;YAChB,YAAY,EAAE,CAAC;SAChB,CACF,CAAC;KACH;IACD,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;QACzB,WAAW;QACX,MAAM;QACN,GAAG,OAAO;QACV,GAAG,iBAAM,CAAC,MAAM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C,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
View 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
View 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
View 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"}

40
node_modules/with/package.json generated vendored Normal file
View File

@ -0,0 +1,40 @@
{
"name": "with",
"version": "7.0.2",
"description": "Compile time `with` for strict mode JavaScript",
"main": "lib/index.js",
"scripts": {
"build": "tsc",
"postbuild": "rimraf lib/**/__tests__",
"lint": "tslint './src/**/*.{ts,tsx}' -t verbose -p .",
"prettier:write": "prettier --ignore-path .gitignore --write './**/*.{md,json,yaml,js,jsx,ts,tsx}'",
"prettier:check": "prettier --ignore-path .gitignore --list-different './**/*.{md,json,yaml,js,jsx,ts,tsx}'",
"pretest": "yarn build",
"test": "mocha test/index.js -R spec"
},
"repository": {
"type": "git",
"url": "https://github.com/pugjs/with.git"
},
"author": "ForbesLindesay",
"license": "MIT",
"dependencies": {
"@babel/parser": "^7.9.6",
"@babel/types": "^7.9.6",
"assert-never": "^1.2.1",
"babel-walk": "3.0.0-canary-5"
},
"devDependencies": {
"@forbeslindesay/tsconfig": "^2.0.0",
"@types/node": "^14.0.5",
"mocha": "*",
"prettier": "^2.0.5",
"rimraf": "^3.0.2",
"tslint": "^6.1.2",
"typescript": "^3.9.3",
"uglify-js": "^2.6.2"
},
"engines": {
"node": ">= 10.0.0"
}
}

1
node_modules/with/prettier.config.js generated vendored Normal file
View File

@ -0,0 +1 @@
module.exports = require('@forbeslindesay/tsconfig/prettier');

195
node_modules/with/src/globals.ts generated vendored Normal file
View File

@ -0,0 +1,195 @@
import assertNever from 'assert-never';
import {ancestor as walk} from 'babel-walk';
import * as t from '@babel/types';
import isReferenced from './reference';
const isScope = (node: t.Node) => t.isFunctionParent(node) || t.isProgram(node);
const isBlockScope = (node: t.Node) =>
t.isBlockStatement(node) || isScope(node);
const declaresArguments = (node: t.Node) =>
t.isFunction(node) && !t.isArrowFunctionExpression(node);
const declaresThis = declaresArguments;
const LOCALS_SYMBOL = Symbol('locals');
const getLocals = (node: t.Node): Set<string> | undefined =>
(node as any)[LOCALS_SYMBOL];
const declareLocals = (node: t.Node): Set<string> =>
((node as any)[LOCALS_SYMBOL] = (node as any)[LOCALS_SYMBOL] || new Set());
const setLocal = (node: t.Node, name: string) => declareLocals(node).add(name);
// First pass
function declareFunction(node: t.Function) {
for (const param of node.params) {
declarePattern(param, node);
}
const id = (node as t.FunctionDeclaration).id;
if (id) {
setLocal(node, id.name);
}
}
function declarePattern(node: t.LVal, parent: t.Node) {
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 as t.LVal, parent);
break;
default:
assertNever(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:
| t.ImportSpecifier
| t.ImportDefaultSpecifier
| t.ImportNamespaceSpecifier,
_state: unknown,
parents: t.Node[],
) {
for (let i = parents.length - 2; i >= 0; i--) {
if (isScope(parents[i])) {
setLocal(parents[i], node.local.name);
return;
}
}
}
const firstPass = walk({
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 = walk<{
globals: (t.Identifier | t.ThisExpression)[];
}>({
Identifier(node, state, parents) {
const name = node.name;
if (name === 'undefined') return;
const lastParent = parents[parents.length - 2];
if (lastParent) {
if (!isReferenced(node, lastParent)) return;
for (const parent of parents) {
if (name === 'arguments' && declaresArguments(parent)) {
return;
}
if (getLocals(parent)?.has(name)) {
return;
}
}
}
state.globals.push(node);
},
ThisExpression(node, state, parents) {
for (const parent of parents) {
if (declaresThis(parent)) {
return;
}
}
state.globals.push(node);
},
});
export default function findGlobals(ast: t.Node) {
const globals: (t.Identifier | t.ThisExpression)[] = [];
// 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<string, (t.Identifier | t.ThisExpression)[]>();
for (const node of globals) {
const name: string = 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));
}

154
node_modules/with/src/index.ts generated vendored Normal file
View File

@ -0,0 +1,154 @@
import {parse} from '@babel/parser';
import {recursive as walk} from 'babel-walk';
import * as t from '@babel/types';
import detect from './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
*/
export default function addWith(
obj: string,
src: string,
exclude: string[] = [],
) {
// tslint:disable-next-line: no-parameter-reassignment
obj = obj + '';
// tslint:disable-next-line: no-parameter-reassignment
src = src + '';
let ast;
try {
ast = 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 = 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,
...detect(objAst).map((g) => g.name),
]);
const vars = new Set(
detect(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};`;
}
interface UnwrapReturnsState {
hasReturn: boolean;
source(node: t.Node): string;
replace(node: t.Node, str: string): void;
}
const unwrapReturnsVisitors = walk<UnwrapReturnsState>({
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: t.Node, src: string, result: string) {
const charArray = src.split('');
const state: UnwrapReturnsState = {
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;

24
node_modules/with/src/reference.ts generated vendored Normal file
View File

@ -0,0 +1,24 @@
import * as t from '@babel/types';
export default function isReferenced(node: t.Node, parent: t.Node) {
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);
}

10
node_modules/with/tsconfig.json generated vendored Normal file
View File

@ -0,0 +1,10 @@
{
"extends": "@forbeslindesay/tsconfig",
"compilerOptions": {
"outDir": "lib",
"incremental": true,
"rootDir": "src",
"tsBuildInfoFile": "lib/.tsbuildinfo"
},
"include": ["src"]
}

7
node_modules/with/tslint.json generated vendored Normal file
View File

@ -0,0 +1,7 @@
{
"extends": ["@forbeslindesay/tsconfig/tslint"],
"linterOptions": {
"exclude": ["coverage/", "dist/", "**/node_modules/**"]
},
"rules": {}
}