.
This commit is contained in:
22
qwen/nodejs/node_modules/@babel/plugin-transform-class-static-block/LICENSE
generated
vendored
Normal file
22
qwen/nodejs/node_modules/@babel/plugin-transform-class-static-block/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
qwen/nodejs/node_modules/@babel/plugin-transform-class-static-block/README.md
generated
vendored
Normal file
19
qwen/nodejs/node_modules/@babel/plugin-transform-class-static-block/README.md
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# @babel/plugin-transform-class-static-block
|
||||
|
||||
> Transform class static blocks
|
||||
|
||||
See our website [@babel/plugin-transform-class-static-block](https://babeljs.io/docs/babel-plugin-transform-class-static-block) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/plugin-transform-class-static-block
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/plugin-transform-class-static-block --dev
|
||||
```
|
||||
153
qwen/nodejs/node_modules/@babel/plugin-transform-class-static-block/lib/index.js
generated
vendored
Normal file
153
qwen/nodejs/node_modules/@babel/plugin-transform-class-static-block/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils");
|
||||
var _helperCreateClassFeaturesPlugin = require("@babel/helper-create-class-features-plugin");
|
||||
function generateUid(scope, denyList) {
|
||||
const name = "";
|
||||
let uid;
|
||||
let i = 1;
|
||||
do {
|
||||
uid = `_${name}`;
|
||||
if (i > 1) uid += i;
|
||||
i++;
|
||||
} while (denyList.has(uid));
|
||||
return uid;
|
||||
}
|
||||
function mapLast(arr, fn) {
|
||||
if (arr.length === 0) return arr;
|
||||
return [...arr.slice(0, -1), fn(arr[arr.length - 1])];
|
||||
}
|
||||
var _default = exports.default = (0, _helperPluginUtils.declare)(({
|
||||
types: t,
|
||||
template,
|
||||
traverse,
|
||||
assertVersion
|
||||
}) => {
|
||||
assertVersion("^7.12.0 || >8.0.0-alpha <8.0.0-beta");
|
||||
const rawNamedEvaluationVisitor = (0, _helperCreateClassFeaturesPlugin.buildNamedEvaluationVisitor)(path => {
|
||||
if (!path.isClassExpression()) return false;
|
||||
for (let i = path.node.body.body.length - 1; i >= 0; i--) {
|
||||
const el = path.node.body.body[i];
|
||||
if (t.isStaticBlock(el)) {
|
||||
return true;
|
||||
}
|
||||
if ((t.isClassProperty(el) || t.isClassPrivateProperty(el)) && el.static) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}, (classPath, state, name) => {
|
||||
const nameNode = typeof name === "string" ? t.stringLiteral(name) : name;
|
||||
classPath.get("body").unshiftContainer("body", t.staticBlock([template.statement.ast`
|
||||
${state.addHelper("setFunctionName")}(this, ${nameNode});
|
||||
`]));
|
||||
});
|
||||
if (!t.classAccessorProperty) {
|
||||
delete rawNamedEvaluationVisitor.ClassAccessorProperty;
|
||||
}
|
||||
const namedEvaluationVisitor = traverse.visitors.explode(rawNamedEvaluationVisitor);
|
||||
const maybeSequenceExpression = expressions => {
|
||||
if (expressions.length === 1) {
|
||||
return expressions[0];
|
||||
} else {
|
||||
return t.sequenceExpression(expressions);
|
||||
}
|
||||
};
|
||||
const blocksToExpressions = blocks => blocks.map(block => {
|
||||
const {
|
||||
body
|
||||
} = block;
|
||||
if (body.length === 1 && t.isExpressionStatement(body[0])) {
|
||||
return t.inheritsComments(t.inheritsComments(body[0].expression, body[0]), block);
|
||||
}
|
||||
return t.inheritsComments(template.expression.ast`(() => { ${body} })()`, block);
|
||||
});
|
||||
const prependToInitializer = (prop, expressions) => {
|
||||
prop.value = prop.value ? t.sequenceExpression([...expressions, prop.value]) : maybeSequenceExpression(mapLast(expressions, expr => t.unaryExpression("void", expr)));
|
||||
};
|
||||
return {
|
||||
name: "transform-class-static-block",
|
||||
manipulateOptions: (_, parser) => parser.plugins.push("classStaticBlock"),
|
||||
pre() {
|
||||
(0, _helperCreateClassFeaturesPlugin.enableFeature)(this.file, _helperCreateClassFeaturesPlugin.FEATURES.staticBlocks, false);
|
||||
},
|
||||
visitor: {
|
||||
ClassBody(classBody) {
|
||||
const {
|
||||
scope
|
||||
} = classBody;
|
||||
let parentPath = classBody.parentPath;
|
||||
if (parentPath.isClassExpression() && !parentPath.node.id) {
|
||||
do ({
|
||||
parentPath
|
||||
} = parentPath); while (parentPath && !namedEvaluationVisitor[parentPath.type] && !parentPath.isStatement());
|
||||
if (parentPath) {
|
||||
var _namedEvaluationVisit;
|
||||
(_namedEvaluationVisit = namedEvaluationVisitor[parentPath.type]) == null || _namedEvaluationVisit.enter.forEach(f => f.call(this, parentPath, this));
|
||||
}
|
||||
}
|
||||
const pendingStaticBlocks = [];
|
||||
let lastStaticProp = null;
|
||||
for (const path of classBody.get("body")) {
|
||||
if (path.isStaticBlock()) {
|
||||
pendingStaticBlocks.push(path.node);
|
||||
path.remove();
|
||||
} else if (path.isClassProperty({
|
||||
static: true
|
||||
}) || path.isClassPrivateProperty({
|
||||
static: true
|
||||
})) {
|
||||
lastStaticProp = path;
|
||||
if (pendingStaticBlocks.length > 0) {
|
||||
prependToInitializer(path.node, blocksToExpressions(pendingStaticBlocks));
|
||||
pendingStaticBlocks.length = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pendingStaticBlocks.length > 0) {
|
||||
const tmp = scope.generateDeclaredUidIdentifier("staticBlock");
|
||||
let arrowBody;
|
||||
const needsCompletionValue = classBody.parentPath.isExpression();
|
||||
if (pendingStaticBlocks.length > 1 || pendingStaticBlocks[0].body.length === 1 && t.isExpressionStatement(pendingStaticBlocks[0].body[0])) {
|
||||
const expressions = blocksToExpressions(pendingStaticBlocks);
|
||||
if (needsCompletionValue) {
|
||||
expressions.push(t.thisExpression());
|
||||
}
|
||||
arrowBody = maybeSequenceExpression(expressions);
|
||||
} else {
|
||||
arrowBody = t.blockStatement(pendingStaticBlocks[0].body);
|
||||
if (needsCompletionValue) {
|
||||
arrowBody.body.push(t.returnStatement(t.thisExpression()));
|
||||
}
|
||||
}
|
||||
const init = template.expression.ast`${tmp} = () => ${arrowBody}`;
|
||||
if (lastStaticProp) {
|
||||
prependToInitializer(lastStaticProp.node, [init]);
|
||||
} else {
|
||||
const privateNames = new Set();
|
||||
for (const path of classBody.get("body")) {
|
||||
if (path.isPrivate()) {
|
||||
privateNames.add(path.get("key.id").node.name);
|
||||
}
|
||||
}
|
||||
const staticBlockPrivateId = generateUid(scope, privateNames);
|
||||
const staticBlockRef = t.privateName(t.identifier(staticBlockPrivateId));
|
||||
classBody.pushContainer("body", [t.classPrivateProperty(staticBlockRef, init, [], true)]);
|
||||
}
|
||||
const staticBlockClosureCall = t.callExpression(t.cloneNode(tmp), []);
|
||||
if (classBody.parentPath.isClassExpression()) {
|
||||
classBody.parentPath.replaceWith(t.sequenceExpression([classBody.parent, staticBlockClosureCall]));
|
||||
} else {
|
||||
classBody.parentPath.insertAfter(t.expressionStatement(staticBlockClosureCall));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
qwen/nodejs/node_modules/@babel/plugin-transform-class-static-block/lib/index.js.map
generated
vendored
Normal file
1
qwen/nodejs/node_modules/@babel/plugin-transform-class-static-block/lib/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
46
qwen/nodejs/node_modules/@babel/plugin-transform-class-static-block/package.json
generated
vendored
Normal file
46
qwen/nodejs/node_modules/@babel/plugin-transform-class-static-block/package.json
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "@babel/plugin-transform-class-static-block",
|
||||
"version": "7.28.3",
|
||||
"description": "Transform class static blocks",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-plugin-transform-class-static-block"
|
||||
},
|
||||
"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"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/helper-create-class-features-plugin": "^7.28.3",
|
||||
"@babel/helper-plugin-utils": "^7.27.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.12.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.28.3",
|
||||
"@babel/helper-plugin-test-runner": "^7.27.1",
|
||||
"@babel/plugin-external-helpers": "^7.27.1",
|
||||
"@babel/plugin-transform-class-properties": "^7.27.1",
|
||||
"@babel/traverse": "^7.28.3",
|
||||
"@babel/types": "^7.28.2"
|
||||
},
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-class-static-block",
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"type": "commonjs"
|
||||
}
|
||||
Reference in New Issue
Block a user