$
This commit is contained in:
22
node_modules/@babel/plugin-transform-block-scoping/LICENSE
generated
vendored
Normal file
22
node_modules/@babel/plugin-transform-block-scoping/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
||||
|
||||
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.
|
||||
19
node_modules/@babel/plugin-transform-block-scoping/README.md
generated
vendored
Normal file
19
node_modules/@babel/plugin-transform-block-scoping/README.md
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# @babel/plugin-transform-block-scoping
|
||||
|
||||
> Compile ES2015 block scoping (const and let) to ES5
|
||||
|
||||
See our website [@babel/plugin-transform-block-scoping](https://babeljs.io/docs/en/babel-plugin-transform-block-scoping) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/plugin-transform-block-scoping
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/plugin-transform-block-scoping --dev
|
||||
```
|
||||
763
node_modules/@babel/plugin-transform-block-scoping/lib/index.js
generated
vendored
Normal file
763
node_modules/@babel/plugin-transform-block-scoping/lib/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
97
node_modules/@babel/plugin-transform-block-scoping/lib/tdz.js
generated
vendored
Normal file
97
node_modules/@babel/plugin-transform-block-scoping/lib/tdz.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.visitor = void 0;
|
||||
|
||||
var _core = require("@babel/core");
|
||||
|
||||
function getTDZStatus(refPath, bindingPath) {
|
||||
const executionStatus = bindingPath._guessExecutionStatusRelativeTo(refPath);
|
||||
|
||||
if (executionStatus === "before") {
|
||||
return "outside";
|
||||
} else if (executionStatus === "after") {
|
||||
return "inside";
|
||||
} else {
|
||||
return "maybe";
|
||||
}
|
||||
}
|
||||
|
||||
function buildTDZAssert(node, state) {
|
||||
return _core.types.callExpression(state.addHelper("temporalRef"), [node, _core.types.stringLiteral(node.name)]);
|
||||
}
|
||||
|
||||
function isReference(node, scope, state) {
|
||||
const declared = state.letReferences.get(node.name);
|
||||
if (!declared) return false;
|
||||
return scope.getBindingIdentifier(node.name) === declared;
|
||||
}
|
||||
|
||||
const visitedMaybeTDZNodes = new WeakSet();
|
||||
const visitor = {
|
||||
ReferencedIdentifier(path, state) {
|
||||
if (!state.tdzEnabled) return;
|
||||
const {
|
||||
node,
|
||||
parent,
|
||||
scope
|
||||
} = path;
|
||||
if (path.parentPath.isFor({
|
||||
left: node
|
||||
})) return;
|
||||
if (!isReference(node, scope, state)) return;
|
||||
const bindingPath = scope.getBinding(node.name).path;
|
||||
if (bindingPath.isFunctionDeclaration()) return;
|
||||
const status = getTDZStatus(path, bindingPath);
|
||||
if (status === "outside") return;
|
||||
|
||||
if (status === "maybe") {
|
||||
if (visitedMaybeTDZNodes.has(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
visitedMaybeTDZNodes.add(node);
|
||||
const assert = buildTDZAssert(node, state);
|
||||
bindingPath.parent._tdzThis = true;
|
||||
|
||||
if (path.parentPath.isUpdateExpression()) {
|
||||
if (parent._ignoreBlockScopingTDZ) return;
|
||||
path.parentPath.replaceWith(_core.types.sequenceExpression([assert, parent]));
|
||||
} else {
|
||||
path.replaceWith(assert);
|
||||
}
|
||||
} else if (status === "inside") {
|
||||
path.replaceWith(_core.template.ast`${state.addHelper("tdz")}("${node.name}")`);
|
||||
}
|
||||
},
|
||||
|
||||
AssignmentExpression: {
|
||||
exit(path, state) {
|
||||
if (!state.tdzEnabled) return;
|
||||
const {
|
||||
node
|
||||
} = path;
|
||||
if (node._ignoreBlockScopingTDZ) return;
|
||||
const nodes = [];
|
||||
const ids = path.getBindingIdentifiers();
|
||||
|
||||
for (const name of Object.keys(ids)) {
|
||||
const id = ids[name];
|
||||
|
||||
if (isReference(id, path.scope, state)) {
|
||||
nodes.push(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (nodes.length) {
|
||||
node._ignoreBlockScopingTDZ = true;
|
||||
nodes.push(node);
|
||||
path.replaceWithMultiple(nodes.map(n => _core.types.expressionStatement(n)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
exports.visitor = visitor;
|
||||
35
node_modules/@babel/plugin-transform-block-scoping/package.json
generated
vendored
Normal file
35
node_modules/@babel/plugin-transform-block-scoping/package.json
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "@babel/plugin-transform-block-scoping",
|
||||
"version": "7.18.9",
|
||||
"description": "Compile ES2015 block scoping (const and let) to ES5",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-plugin-transform-block-scoping"
|
||||
},
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-block-scoping",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/helper-plugin-utils": "^7.18.9"
|
||||
},
|
||||
"keywords": [
|
||||
"babel-plugin"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.18.9",
|
||||
"@babel/helper-plugin-test-runner": "^7.18.6",
|
||||
"@babel/traverse": "^7.18.9"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"type": "commonjs"
|
||||
}
|
||||
Reference in New Issue
Block a user