summaryrefslogtreecommitdiff
path: root/node_modules/@babel/plugin-transform-new-target
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-10-14 15:31:11 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-10-14 15:31:11 +0800
commitaa773172311dcada759dfbaac485f4bc6e00bc21 (patch)
treeca6d9a5eff3ab8f689f9acb4f0df791d9486813d /node_modules/@babel/plugin-transform-new-target
parentc5a5384e846f242e901e859fe600d695d8990a9a (diff)
added babel
Diffstat (limited to 'node_modules/@babel/plugin-transform-new-target')
-rw-r--r--node_modules/@babel/plugin-transform-new-target/LICENSE22
-rw-r--r--node_modules/@babel/plugin-transform-new-target/README.md19
-rw-r--r--node_modules/@babel/plugin-transform-new-target/lib/index.js72
-rw-r--r--node_modules/@babel/plugin-transform-new-target/lib/index.js.map1
-rw-r--r--node_modules/@babel/plugin-transform-new-target/package.json36
5 files changed, 150 insertions, 0 deletions
diff --git a/node_modules/@babel/plugin-transform-new-target/LICENSE b/node_modules/@babel/plugin-transform-new-target/LICENSE
new file mode 100644
index 00000000..f31575ec
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-new-target/LICENSE
@@ -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.
diff --git a/node_modules/@babel/plugin-transform-new-target/README.md b/node_modules/@babel/plugin-transform-new-target/README.md
new file mode 100644
index 00000000..affc541d
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-new-target/README.md
@@ -0,0 +1,19 @@
+# @babel/plugin-transform-new-target
+
+> Transforms new.target meta property
+
+See our website [@babel/plugin-transform-new-target](https://babeljs.io/docs/en/babel-plugin-transform-new-target) for more information.
+
+## Install
+
+Using npm:
+
+```sh
+npm install --save-dev @babel/plugin-transform-new-target
+```
+
+or using yarn:
+
+```sh
+yarn add @babel/plugin-transform-new-target --dev
+```
diff --git a/node_modules/@babel/plugin-transform-new-target/lib/index.js b/node_modules/@babel/plugin-transform-new-target/lib/index.js
new file mode 100644
index 00000000..340ad9ab
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-new-target/lib/index.js
@@ -0,0 +1,72 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = void 0;
+var _helperPluginUtils = require("@babel/helper-plugin-utils");
+var _core = require("@babel/core");
+var _default = (0, _helperPluginUtils.declare)(api => {
+ api.assertVersion(7);
+ return {
+ name: "transform-new-target",
+ visitor: {
+ MetaProperty(path) {
+ const meta = path.get("meta");
+ const property = path.get("property");
+ const {
+ scope
+ } = path;
+ if (meta.isIdentifier({
+ name: "new"
+ }) && property.isIdentifier({
+ name: "target"
+ })) {
+ const func = path.findParent(path => {
+ if (path.isClass()) return true;
+ if (path.isFunction() && !path.isArrowFunctionExpression()) {
+ if (path.isClassMethod({
+ kind: "constructor"
+ })) {
+ return false;
+ }
+ return true;
+ }
+ return false;
+ });
+ if (!func) {
+ throw path.buildCodeFrameError("new.target must be under a (non-arrow) function or a class.");
+ }
+ const {
+ node
+ } = func;
+ if (_core.types.isMethod(node)) {
+ path.replaceWith(scope.buildUndefinedNode());
+ return;
+ }
+ const constructor = _core.types.memberExpression(_core.types.thisExpression(), _core.types.identifier("constructor"));
+ if (func.isClass()) {
+ path.replaceWith(constructor);
+ return;
+ }
+ if (!node.id) {
+ node.id = scope.generateUidIdentifier("target");
+ } else {
+ let scope = path.scope;
+ const name = node.id.name;
+ while (scope !== func.parentPath.scope) {
+ if (scope.hasOwnBinding(name) && !scope.bindingIdentifierEquals(name, node.id)) {
+ scope.rename(name);
+ }
+ scope = scope.parent;
+ }
+ }
+ path.replaceWith(_core.types.conditionalExpression(_core.types.binaryExpression("instanceof", _core.types.thisExpression(), _core.types.cloneNode(node.id)), constructor, scope.buildUndefinedNode()));
+ }
+ }
+ }
+ };
+});
+exports.default = _default;
+
+//# sourceMappingURL=index.js.map
diff --git a/node_modules/@babel/plugin-transform-new-target/lib/index.js.map b/node_modules/@babel/plugin-transform-new-target/lib/index.js.map
new file mode 100644
index 00000000..02426b2f
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-new-target/lib/index.js.map
@@ -0,0 +1 @@
+{"version":3,"names":["_helperPluginUtils","require","_core","_default","declare","api","assertVersion","name","visitor","MetaProperty","path","meta","get","property","scope","isIdentifier","func","findParent","isClass","isFunction","isArrowFunctionExpression","isClassMethod","kind","buildCodeFrameError","node","t","isMethod","replaceWith","buildUndefinedNode","constructor","memberExpression","thisExpression","identifier","id","generateUidIdentifier","parentPath","hasOwnBinding","bindingIdentifierEquals","rename","parent","conditionalExpression","binaryExpression","cloneNode","exports","default"],"sources":["../src/index.ts"],"sourcesContent":["import { declare } from \"@babel/helper-plugin-utils\";\nimport { types as t } from \"@babel/core\";\nimport type { NodePath } from \"@babel/traverse\";\n\nexport default declare(api => {\n api.assertVersion(7);\n\n return {\n name: \"transform-new-target\",\n\n visitor: {\n MetaProperty(path) {\n const meta = path.get(\"meta\");\n const property = path.get(\"property\");\n const { scope } = path;\n\n if (\n meta.isIdentifier({ name: \"new\" }) &&\n property.isIdentifier({ name: \"target\" })\n ) {\n const func = path.findParent(path => {\n if (path.isClass()) return true;\n if (path.isFunction() && !path.isArrowFunctionExpression()) {\n if (path.isClassMethod({ kind: \"constructor\" })) {\n return false;\n }\n\n return true;\n }\n return false;\n }) as NodePath<\n | t.FunctionDeclaration\n | t.FunctionExpression\n | t.Class\n | t.ClassMethod\n | t.ClassPrivateMethod\n >;\n\n if (!func) {\n throw path.buildCodeFrameError(\n \"new.target must be under a (non-arrow) function or a class.\",\n );\n }\n\n const { node } = func;\n if (t.isMethod(node)) {\n path.replaceWith(scope.buildUndefinedNode());\n return;\n }\n\n const constructor = t.memberExpression(\n t.thisExpression(),\n t.identifier(\"constructor\"),\n );\n\n if (func.isClass()) {\n path.replaceWith(constructor);\n return;\n }\n\n if (!node.id) {\n node.id = scope.generateUidIdentifier(\"target\");\n } else {\n // packages/babel-helper-create-class-features-plugin/src/fields.ts#L192 unshadow\n let scope = path.scope;\n const name = node.id.name;\n while (scope !== func.parentPath.scope) {\n if (\n scope.hasOwnBinding(name) &&\n !scope.bindingIdentifierEquals(name, node.id)\n ) {\n scope.rename(name);\n }\n scope = scope.parent;\n }\n }\n\n path.replaceWith(\n t.conditionalExpression(\n t.binaryExpression(\n \"instanceof\",\n t.thisExpression(),\n t.cloneNode(node.id),\n ),\n constructor,\n scope.buildUndefinedNode(),\n ),\n );\n }\n },\n },\n };\n});\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAAyC,IAAAE,QAAA,GAG1B,IAAAC,0BAAO,EAACC,GAAG,IAAI;EAC5BA,GAAG,CAACC,aAAa,CAAC,CAAC,CAAC;EAEpB,OAAO;IACLC,IAAI,EAAE,sBAAsB;IAE5BC,OAAO,EAAE;MACPC,YAAYA,CAACC,IAAI,EAAE;QACjB,MAAMC,IAAI,GAAGD,IAAI,CAACE,GAAG,CAAC,MAAM,CAAC;QAC7B,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B,qBAAqB,CAAC,QAAQ,CAAC;UACjD,CAAC,MAAM;YAEL,IAAIpB,KAAK,GAAGJ,IAAI,CAACI,KAAK;YACtB,MAAMP,IAAI,GAAGiB,IAAI,CAACS,EAAE,CAAC1B,IAAI;YACzB,OAAOO,KAAK,KAAKE,IAAI,CAACmB,UAAU,CAACrB,KAAK,EAAE;cACtC,IACEA,KAAK,CAACsB,aAAa,CAAC7B,IAAI,CAAC,IACzB,CAACO,KAAK,CAACuB,uBAAuB,CAAC9B,IAAI,EAAEiB,IAAI,CAACS,EAAE,CAAC,EAC7C;gBACAnB,KAAK,CAACwB,MAAM,CAAC/B,IAAI,CAAC;cACpB;cACAO,KAAK,GAAGA,KAAK,CAACyB,MAAM;YACtB;UACF;UAEA7B,IAAI,CAACiB,WAAW,CACdF,WAAC,CAACe,qBAAqB,CACrBf,WAAC,CAACgB,gBAAgB,CAChB,YAAY,EACZhB,WAAC,CAACM,cAAc,CAAC,CAAC,EAClBN,WAAC,CAACiB,SAAS,CAAClB,IAAI,CAACS,EAAE,CACrB,CAAC,EACDJ,WAAW,EACXf,KAAK,CAACc,kBAAkB,CAAC,CAC3B,CACF,CAAC;QACH;MACF;IACF;EACF,CAAC;AACH,CAAC,CAAC;AAAAe,OAAA,CAAAC,OAAA,GAAAzC,QAAA"} \ No newline at end of file
diff --git a/node_modules/@babel/plugin-transform-new-target/package.json b/node_modules/@babel/plugin-transform-new-target/package.json
new file mode 100644
index 00000000..4c68ac37
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-new-target/package.json
@@ -0,0 +1,36 @@
+{
+ "name": "@babel/plugin-transform-new-target",
+ "version": "7.22.5",
+ "description": "Transforms new.target meta property",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/babel/babel.git",
+ "directory": "packages/babel-plugin-transform-new-target"
+ },
+ "homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-new-target",
+ "license": "MIT",
+ "publishConfig": {
+ "access": "public"
+ },
+ "main": "./lib/index.js",
+ "keywords": [
+ "babel-plugin"
+ ],
+ "dependencies": {
+ "@babel/helper-plugin-utils": "^7.22.5"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
+ },
+ "devDependencies": {
+ "@babel/core": "^7.22.5",
+ "@babel/helper-plugin-test-runner": "^7.22.5",
+ "@babel/plugin-transform-arrow-functions": "^7.22.5",
+ "@babel/plugin-transform-class-properties": "^7.22.5"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ },
+ "author": "The Babel Team (https://babel.dev/team)",
+ "type": "commonjs"
+} \ No newline at end of file