feat: initial commit
This commit is contained in:
22
node_modules/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/LICENSE
generated
vendored
Normal file
22
node_modules/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/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-bugfix-v8-static-class-fields-redefine-readonly/README.md
generated
vendored
Normal file
19
node_modules/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/README.md
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
# @babel/plugin-bugfix-v8-static-class-fields-redefine-readonly
|
||||
|
||||
> Transform static class fields assignments that are affected by https://crbug.com/v8/12421
|
||||
|
||||
See our website [@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly](https://babeljs.io/docs/babel-plugin-bugfix-v8-static-class-fields-redefine-readonly) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/plugin-bugfix-v8-static-class-fields-redefine-readonly
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/plugin-bugfix-v8-static-class-fields-redefine-readonly --dev
|
||||
```
|
175
node_modules/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/lib/index.js
generated
vendored
Normal file
175
node_modules/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,175 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var core = require('@babel/core');
|
||||
var helperPluginUtils = require('@babel/helper-plugin-utils');
|
||||
|
||||
function isNameOrLength(key) {
|
||||
if (core.types.isIdentifier(key)) {
|
||||
return key.name === "name" || key.name === "length";
|
||||
}
|
||||
if (core.types.isStringLiteral(key)) {
|
||||
return key.value === "name" || key.value === "length";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isStaticFieldWithValue(node) {
|
||||
return (core.types.isClassProperty(node) || core.types.isClassPrivateProperty(node)) && node.static && !!node.value;
|
||||
}
|
||||
const hasReferenceVisitor = {
|
||||
ReferencedIdentifier(path, state) {
|
||||
if (path.node.name === state.name) {
|
||||
state.ref();
|
||||
path.stop();
|
||||
}
|
||||
},
|
||||
Scope(path, {
|
||||
name
|
||||
}) {
|
||||
if (path.scope.hasOwnBinding(name)) {
|
||||
path.skip();
|
||||
}
|
||||
}
|
||||
};
|
||||
function isReferenceOrThis(node, name) {
|
||||
return core.types.isThisExpression(node) || name && core.types.isIdentifier(node, {
|
||||
name
|
||||
});
|
||||
}
|
||||
const hasReferenceOrThisVisitor = {
|
||||
"ThisExpression|ReferencedIdentifier"(path, state) {
|
||||
if (isReferenceOrThis(path.node, state.name)) {
|
||||
state.ref();
|
||||
path.stop();
|
||||
}
|
||||
},
|
||||
FunctionParent(path, state) {
|
||||
if (path.isArrowFunctionExpression()) return;
|
||||
if (state.name && !path.scope.hasOwnBinding(state.name)) {
|
||||
path.traverse(hasReferenceVisitor, state);
|
||||
}
|
||||
path.skip();
|
||||
if (path.isMethod()) {
|
||||
if (path.requeueComputedKeyAndDecorators) {
|
||||
path.requeueComputedKeyAndDecorators();
|
||||
} else {
|
||||
require("@babel/traverse").NodePath.prototype.requeueComputedKeyAndDecorators.call(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
function getPotentiallyBuggyFieldsIndexes(path) {
|
||||
var _path$node$id;
|
||||
const buggyPublicStaticFieldsIndexes = [];
|
||||
let classReferenced = false;
|
||||
const className = (_path$node$id = path.node.id) == null ? void 0 : _path$node$id.name;
|
||||
const hasReferenceState = {
|
||||
name: className,
|
||||
ref: () => classReferenced = true
|
||||
};
|
||||
if (className) {
|
||||
for (const el of path.get("body.body")) {
|
||||
if (el.node.computed) {
|
||||
el.get("key").traverse(hasReferenceVisitor, hasReferenceState);
|
||||
if (classReferenced) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
let nextPotentiallyBuggy = false;
|
||||
const {
|
||||
body
|
||||
} = path.node.body;
|
||||
for (let i = 0; i < body.length; i++) {
|
||||
const node = body[i];
|
||||
if (!nextPotentiallyBuggy) {
|
||||
if (core.types.isStaticBlock(node)) {
|
||||
classReferenced = true;
|
||||
nextPotentiallyBuggy = true;
|
||||
} else if (isStaticFieldWithValue(node)) {
|
||||
if (!classReferenced) {
|
||||
if (isReferenceOrThis(node.value, className)) {
|
||||
classReferenced = true;
|
||||
} else {
|
||||
path.get(`body.body.${i}.value`).traverse(hasReferenceOrThisVisitor, hasReferenceState);
|
||||
}
|
||||
}
|
||||
if (classReferenced) {
|
||||
nextPotentiallyBuggy = !path.scope.isPure(node.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (core.types.isClassProperty(node, {
|
||||
static: true
|
||||
}) && (nextPotentiallyBuggy || node.computed || isNameOrLength(node.key))) {
|
||||
buggyPublicStaticFieldsIndexes.push(i);
|
||||
}
|
||||
}
|
||||
return buggyPublicStaticFieldsIndexes;
|
||||
}
|
||||
function getNameOrLengthStaticFieldsIndexes(path) {
|
||||
const indexes = [];
|
||||
const {
|
||||
body
|
||||
} = path.node.body;
|
||||
for (let i = 0; i < body.length; i++) {
|
||||
const node = body[i];
|
||||
if (core.types.isClassProperty(node, {
|
||||
static: true,
|
||||
computed: false
|
||||
}) && isNameOrLength(node.key)) {
|
||||
indexes.push(i);
|
||||
}
|
||||
}
|
||||
return indexes;
|
||||
}
|
||||
function toRanges(nums) {
|
||||
const ranges = [];
|
||||
if (nums.length === 0) return ranges;
|
||||
let start = nums[0];
|
||||
let end = start + 1;
|
||||
for (let i = 1; i < nums.length; i++) {
|
||||
if (nums[i] <= nums[i - 1]) {
|
||||
throw new Error("Internal Babel error: nums must be in ascending order");
|
||||
}
|
||||
if (nums[i] === end) {
|
||||
end++;
|
||||
} else {
|
||||
ranges.push([start, end]);
|
||||
start = nums[i];
|
||||
end = start + 1;
|
||||
}
|
||||
}
|
||||
ranges.push([start, end]);
|
||||
return ranges;
|
||||
}
|
||||
|
||||
function buildFieldsReplacement(fields, scope, file) {
|
||||
return core.types.staticBlock(fields.map(field => {
|
||||
const key = field.computed || !core.types.isIdentifier(field.key) ? field.key : core.types.stringLiteral(field.key.name);
|
||||
return core.types.expressionStatement(core.types.callExpression(file.addHelper("defineProperty"), [core.types.thisExpression(), key, field.value || scope.buildUndefinedNode()]));
|
||||
}));
|
||||
}
|
||||
var index = helperPluginUtils.declare(api => {
|
||||
api.assertVersion("^7.0.0-0 || >8.0.0-alpha <8.0.0-beta");
|
||||
const setPublicClassFields = api.assumption("setPublicClassFields");
|
||||
return {
|
||||
name: "bugfix-v8-static-class-fields-redefine-readonly",
|
||||
visitor: {
|
||||
Class(path) {
|
||||
const ranges = toRanges(setPublicClassFields ? getNameOrLengthStaticFieldsIndexes(path) : getPotentiallyBuggyFieldsIndexes(path));
|
||||
for (let i = ranges.length - 1; i >= 0; i--) {
|
||||
const [start, end] = ranges[i];
|
||||
const startPath = path.get("body.body")[start];
|
||||
startPath.replaceWith(buildFieldsReplacement(path.node.body.body.slice(start, end), path.scope, this.file));
|
||||
for (let j = end - 1; j > start; j--) {
|
||||
path.get("body.body")[j].remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
exports.default = index;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/lib/index.js.map
generated
vendored
Normal file
1
node_modules/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/lib/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
44
node_modules/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/package.json
generated
vendored
Normal file
44
node_modules/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/package.json
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly",
|
||||
"version": "7.25.0",
|
||||
"description": "Transform static class fields assignments that are affected by https://crbug.com/v8/12421",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-plugin-bugfix-v8-static-class-fields-redefine-readonly"
|
||||
},
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-bugfix-v8-static-class-fields-redefine-readonly",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./lib/index.d.ts",
|
||||
"default": "./lib/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"keywords": [
|
||||
"babel-plugin",
|
||||
"bugfix"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/helper-plugin-utils": "^7.24.8",
|
||||
"@babel/traverse": "^7.25.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.24.9",
|
||||
"@babel/helper-plugin-test-runner": "^7.24.7",
|
||||
"@babel/traverse": "^7.25.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"type": "commonjs"
|
||||
}
|
17
node_modules/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/tsconfig.json
generated
vendored
Normal file
17
node_modules/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/tsconfig.json
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
/* This file is automatically generated by scripts/generators/tsconfig.js */
|
||||
{
|
||||
"extends": [
|
||||
"../../tsconfig.base.json",
|
||||
"../../tsconfig.paths.json"
|
||||
],
|
||||
"include": [
|
||||
"../../packages/babel-plugin-bugfix-v8-static-class-fields-redefine-readonly/src/**/*.ts",
|
||||
"../../lib/globals.d.ts",
|
||||
"../../scripts/repo-utils/*.d.ts"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../packages/babel-helper-plugin-utils"
|
||||
}
|
||||
]
|
||||
}
|
1
node_modules/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/tsconfig.tsbuildinfo
generated
vendored
Normal file
1
node_modules/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/tsconfig.tsbuildinfo
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user