Befor generating
This commit is contained in:
1 parent
3383f4bf4a
commit
1aa1b5f625
6756 files changed
+649946
-1
No files matched your search
Generated
Vendored
+22
@@ -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.
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
# @babel/plugin-transform-exponentiation-operator
|
||||
|
||||
> Compile exponentiation operator to ES5
|
||||
|
||||
See our website [@babel/plugin-transform-exponentiation-operator](https://babeljs.io/docs/babel-plugin-transform-exponentiation-operator) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/plugin-transform-exponentiation-operator
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/plugin-transform-exponentiation-operator --dev
|
||||
```
|
||||
Generated
Vendored
+82
@@ -0,0 +1,82 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils");
|
||||
var _default = exports.default = (0, _helperPluginUtils.declare)(api => {
|
||||
api.assertVersion("^7.0.0-0 || ^8.0.0-0 || >8.0.0-alpha <8.0.0-beta");
|
||||
const {
|
||||
types: t,
|
||||
template
|
||||
} = api;
|
||||
function build(left, right) {
|
||||
return t.callExpression(t.memberExpression(t.identifier("Math"), t.identifier("pow")), [left, right]);
|
||||
}
|
||||
function maybeMemoize(node, scope) {
|
||||
if (scope.isStatic(node)) {
|
||||
return {
|
||||
assign: node,
|
||||
ref: t.cloneNode(node)
|
||||
};
|
||||
}
|
||||
if (scope.path.isPattern()) {
|
||||
return null;
|
||||
}
|
||||
const id = scope.generateUidIdentifierBasedOnNode(node);
|
||||
scope.push({
|
||||
id
|
||||
});
|
||||
return {
|
||||
assign: t.assignmentExpression("=", t.cloneNode(id), node),
|
||||
ref: t.cloneNode(id)
|
||||
};
|
||||
}
|
||||
return {
|
||||
name: "transform-exponentiation-operator",
|
||||
visitor: {
|
||||
AssignmentExpression(path) {
|
||||
const {
|
||||
node,
|
||||
scope
|
||||
} = path;
|
||||
if (node.operator !== "**=") return;
|
||||
if (t.isMemberExpression(node.left)) {
|
||||
let member1;
|
||||
let member2;
|
||||
const object = maybeMemoize(node.left.object, scope);
|
||||
if (!object) {
|
||||
path.replaceWith(template.expression.ast`(() => ${path.node})()`);
|
||||
return;
|
||||
}
|
||||
const {
|
||||
property,
|
||||
computed
|
||||
} = node.left;
|
||||
if (computed) {
|
||||
const prop = maybeMemoize(property, scope);
|
||||
member1 = t.memberExpression(object.assign, prop.assign, true);
|
||||
member2 = t.memberExpression(object.ref, prop.ref, true);
|
||||
} else {
|
||||
member1 = t.memberExpression(object.assign, property, false);
|
||||
member2 = t.memberExpression(object.ref, t.cloneNode(property), false);
|
||||
}
|
||||
path.replaceWith(t.assignmentExpression("=", member1, build(member2, node.right)));
|
||||
} else {
|
||||
path.replaceWith(t.assignmentExpression("=", node.left, build(t.cloneNode(node.left), node.right)));
|
||||
}
|
||||
},
|
||||
BinaryExpression(path) {
|
||||
const {
|
||||
node
|
||||
} = path;
|
||||
if (node.operator === "**") {
|
||||
path.replaceWith(build(node.left, node.right));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_helperPluginUtils","require","_default","exports","default","declare","api","assertVersion","types","t","template","build","left","right","callExpression","memberExpression","identifier","maybeMemoize","node","scope","isStatic","assign","ref","cloneNode","path","isPattern","id","generateUidIdentifierBasedOnNode","push","assignmentExpression","name","visitor","AssignmentExpression","operator","isMemberExpression","member1","member2","object","replaceWith","expression","ast","property","computed","prop","BinaryExpression"],"sources":["../src/index.ts"],"sourcesContent":["import { declare } from \"@babel/helper-plugin-utils\";\nimport type { types as t, Scope } from \"@babel/core\";\n\nexport default declare(api => {\n api.assertVersion(REQUIRED_VERSION(\"^7.0.0-0 || ^8.0.0-0\"));\n\n const { types: t, template } = api;\n\n function build(left: t.Expression, right: t.Expression) {\n return t.callExpression(\n t.memberExpression(t.identifier(\"Math\"), t.identifier(\"pow\")),\n [left, right],\n );\n }\n\n function maybeMemoize<T extends t.Expression | t.Super>(\n node: T,\n scope: Scope,\n ) {\n if (scope.isStatic(node)) {\n return { assign: node, ref: t.cloneNode(node) };\n }\n\n if (scope.path.isPattern()) {\n // We cannot inject a temp var in function arguments.\n return null;\n }\n\n const id = scope.generateUidIdentifierBasedOnNode(node);\n scope.push({ id });\n return {\n assign: t.assignmentExpression(\n \"=\",\n t.cloneNode(id),\n // This is not t.Super, because otherwise the .isStatic check above\n // would have returned true.\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n node as t.Expression,\n ),\n ref: t.cloneNode(id),\n };\n }\n\n return {\n name: \"transform-exponentiation-operator\",\n\n visitor: {\n AssignmentExpression(path) {\n const { node, scope } = path;\n if (node.operator !== \"**=\") return;\n\n if (t.isMemberExpression(node.left)) {\n let member1: t.Expression;\n let member2: t.Expression;\n\n const object = maybeMemoize(node.left.object, scope);\n if (!object) {\n // We need to inject a temp var, but we are in function parameters\n // and thus cannot. Wrap the expression in an IIFE. It will be\n // eventually requeued and transformed.\n path.replaceWith(template.expression.ast`(() => ${path.node})()`);\n return;\n }\n\n const { property, computed } = node.left;\n\n if (computed) {\n // @ts-ignore(Babel 7 vs Babel 8) Babel 8 has better type definitions\n const prop = maybeMemoize(property, scope);\n member1 = t.memberExpression(object.assign, prop.assign, true);\n member2 = t.memberExpression(object.ref, prop.ref, true);\n } else {\n member1 = t.memberExpression(object.assign, property, false);\n member2 = t.memberExpression(\n object.ref,\n t.cloneNode(property),\n false,\n );\n }\n\n path.replaceWith(\n t.assignmentExpression(\"=\", member1, build(member2, node.right)),\n );\n } else {\n path.replaceWith(\n t.assignmentExpression(\n \"=\",\n node.left,\n build(\n // todo: it could be a t.AsExpression\n t.cloneNode(node.left) as t.Identifier,\n node.right,\n ),\n ),\n );\n }\n },\n\n BinaryExpression(path) {\n const { node } = path;\n if (node.operator === \"**\") {\n path.replaceWith(\n build(\n // left can be PrivateName only if operator is `\"in\"`\n node.left as t.Expression,\n node.right,\n ),\n );\n }\n },\n },\n };\n});\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AAAqD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGtC,IAAAC,0BAAO,EAACC,GAAG,IAAI;EAC5BA,GAAG,CAACC,aAAa,mDAAyC,CAAC;EAE3D,MAAM;IAAEC,KAAK,EAAEC,CAAC;IAAEC;EAAS,CAAC,GAAGJ,GAAG;EAElC,SAASK,KAAKA,CAACC,IAAkB,EAAEC,KAAmB,EAAE;IACtD,OAAOJ,CAAC,CAACK,cAAc,CACrBL,CAAC,CAACM,gBAAgB,CAACN,CAAC,CAACO,UAAU,CAAC,MAAM,CAAC,EAAEP,CAAC,CAACO,UAAU,CAAC,KAAK,CAAC,CAAC,EAC7D,CAACJ,IAAI,EAAEC,KAAK,CACd,CAAC;EACH;EAEA,SAASI,YAAYA,CACnBC,IAAO,EACPC,KAAY,EACZ;IACA,IAAIA,KAAK,CAACC,QAAQ,CAACF,IAAI,CAAC,EAAE;MACxB,OAAO;QAAEG,MAAM,EAAEH,IAAI;QAAEI,GAAG,EAAEb,CAAC,CAACc,SAAS,CAACL,IAAI;MAAE,CAAC;IACjD;IAEA,IAAIC,KAAK,CAACK,IAAI,CAACC,SAAS,CAAC,CAAC,EAAE;MAE1B,OAAO,IAAI;IACb;IAEA,MAAMC,EAAE,GAAGP,KAAK,CAACQ,gCAAgC,CAACT,IAAI,CAAC;IACvDC,KAAK,CAACS,IAAI,CAAC;MAAEF;IAAG,CAAC,CAAC;IAClB,OAAO;MACLL,MAAM,EAAEZ,CAAC,CAACoB,oBAAoB,CAC5B,GAAG,EACHpB,CAAC,CAACc,SAAS,CAACG,EAAE,CAAC,EAIfR,IACF,CAAC;MACDLine truncated
|
||||
Generated
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "@babel/plugin-transform-exponentiation-operator",
|
||||
"version": "7.29.7",
|
||||
"description": "Compile exponentiation operator to ES5",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-plugin-transform-exponentiation-operator"
|
||||
},
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-exponentiation-operator",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"keywords": [
|
||||
"babel-plugin"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/helper-plugin-utils": "^7.29.7"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.29.7",
|
||||
"@babel/helper-plugin-test-runner": "^7.29.7"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"type": "commonjs"
|
||||
}
|
||||
Reference in new issue
Block a user