summaryrefslogtreecommitdiff
path: root/node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining
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-bugfix-v8-spread-parameters-in-optional-chaining
parentc5a5384e846f242e901e859fe600d695d8990a9a (diff)
added babel
Diffstat (limited to 'node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining')
-rw-r--r--node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/LICENSE22
-rw-r--r--node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/README.md19
-rw-r--r--node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/lib/index.js66
-rw-r--r--node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/lib/index.js.map1
-rw-r--r--node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/package.json42
5 files changed, 150 insertions, 0 deletions
diff --git a/node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/LICENSE b/node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/LICENSE
new file mode 100644
index 00000000..f31575ec
--- /dev/null
+++ b/node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/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-bugfix-v8-spread-parameters-in-optional-chaining/README.md b/node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/README.md
new file mode 100644
index 00000000..e1a86552
--- /dev/null
+++ b/node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/README.md
@@ -0,0 +1,19 @@
+# @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining
+
+> Transform optional chaining operators to workaround https://crbug.com/v8/11558
+
+See our website [@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining](https://babeljs.io/docs/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining) for more information.
+
+## Install
+
+Using npm:
+
+```sh
+npm install --save-dev @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining
+```
+
+or using yarn:
+
+```sh
+yarn add @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining --dev
+```
diff --git a/node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/lib/index.js b/node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/lib/index.js
new file mode 100644
index 00000000..071d9edf
--- /dev/null
+++ b/node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/lib/index.js
@@ -0,0 +1,66 @@
+'use strict';
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+var helperPluginUtils = require('@babel/helper-plugin-utils');
+var pluginTransformOptionalChaining = require('@babel/plugin-transform-optional-chaining');
+var helperSkipTransparentExpressionWrappers = require('@babel/helper-skip-transparent-expression-wrappers');
+var core = require('@babel/core');
+
+function matchAffectedArguments(argumentNodes) {
+ const spreadIndex = argumentNodes.findIndex(node => core.types.isSpreadElement(node));
+ return spreadIndex >= 0 && spreadIndex !== argumentNodes.length - 1;
+}
+function shouldTransform(path) {
+ let optionalPath = path;
+ const chains = [];
+ for (;;) {
+ if (optionalPath.isOptionalMemberExpression()) {
+ chains.push(optionalPath.node);
+ optionalPath = helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers(optionalPath.get("object"));
+ } else if (optionalPath.isOptionalCallExpression()) {
+ chains.push(optionalPath.node);
+ optionalPath = helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers(optionalPath.get("callee"));
+ } else {
+ break;
+ }
+ }
+ for (let i = 0; i < chains.length; i++) {
+ const node = chains[i];
+ if (core.types.isOptionalCallExpression(node) && matchAffectedArguments(node.arguments)) {
+ if (node.optional) {
+ return true;
+ }
+ const callee = chains[i + 1];
+ if (core.types.isOptionalMemberExpression(callee, {
+ optional: true
+ })) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+var index = helperPluginUtils.declare(api => {
+ var _api$assumption, _api$assumption2;
+ api.assertVersion(7);
+ const noDocumentAll = (_api$assumption = api.assumption("noDocumentAll")) != null ? _api$assumption : false;
+ const pureGetters = (_api$assumption2 = api.assumption("pureGetters")) != null ? _api$assumption2 : false;
+ return {
+ name: "bugfix-v8-spread-parameters-in-optional-chaining",
+ visitor: {
+ "OptionalCallExpression|OptionalMemberExpression"(path) {
+ if (shouldTransform(path)) {
+ pluginTransformOptionalChaining.transform(path, {
+ noDocumentAll,
+ pureGetters
+ });
+ }
+ }
+ }
+ };
+});
+
+exports.default = index;
+//# sourceMappingURL=index.js.map
diff --git a/node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/lib/index.js.map b/node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/lib/index.js.map
new file mode 100644
index 00000000..417de8d6
--- /dev/null
+++ b/node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/lib/index.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.js","sources":["../src/util.ts","../src/index.ts"],"sourcesContent":["import { skipTransparentExprWrappers } from \"@babel/helper-skip-transparent-expression-wrappers\";\nimport type { NodePath } from \"@babel/traverse\";\nimport { types as t } from \"@babel/core\";\n// https://crbug.com/v8/11558\n\n// check if there is a spread element followed by another argument.\n// (...[], 0) or (...[], ...[])\n\nfunction matchAffectedArguments(argumentNodes: t.CallExpression[\"arguments\"]) {\n const spreadIndex = argumentNodes.findIndex(node => t.isSpreadElement(node));\n return spreadIndex >= 0 && spreadIndex !== argumentNodes.length - 1;\n}\n\n/**\n * Check whether the optional chain is affected by https://crbug.com/v8/11558.\n * This routine MUST not manipulate NodePath\n *\n * @export\n * @param {(NodePath<t.OptionalMemberExpression | t.OptionalCallExpression>)} path\n * @returns {boolean}\n */\nexport function shouldTransform(\n path: NodePath<t.OptionalMemberExpression | t.OptionalCallExpression>,\n): boolean {\n let optionalPath: NodePath<t.Expression> = path;\n const chains: (t.OptionalCallExpression | t.OptionalMemberExpression)[] = [];\n for (;;) {\n if (optionalPath.isOptionalMemberExpression()) {\n chains.push(optionalPath.node);\n optionalPath = skipTransparentExprWrappers(optionalPath.get(\"object\"));\n } else if (optionalPath.isOptionalCallExpression()) {\n chains.push(optionalPath.node);\n optionalPath = skipTransparentExprWrappers(optionalPath.get(\"callee\"));\n } else {\n break;\n }\n }\n for (let i = 0; i < chains.length; i++) {\n const node = chains[i];\n if (\n t.isOptionalCallExpression(node) &&\n matchAffectedArguments(node.arguments)\n ) {\n // f?.(...[], 0)\n if (node.optional) {\n return true;\n }\n // o?.m(...[], 0)\n // when node.optional is false, chains[i + 1] is always well defined\n const callee = chains[i + 1];\n if (t.isOptionalMemberExpression(callee, { optional: true })) {\n return true;\n }\n }\n }\n return false;\n}\n","import { declare } from \"@babel/helper-plugin-utils\";\nimport { transform } from \"@babel/plugin-transform-optional-chaining\";\nimport { shouldTransform } from \"./util.ts\";\nimport type { NodePath } from \"@babel/traverse\";\nimport type * as t from \"@babel/types\";\n\nexport default declare(api => {\n api.assertVersion(7);\n\n const noDocumentAll = api.assumption(\"noDocumentAll\") ?? false;\n const pureGetters = api.assumption(\"pureGetters\") ?? false;\n\n return {\n name: \"bugfix-v8-spread-parameters-in-optional-chaining\",\n\n visitor: {\n \"OptionalCallExpression|OptionalMemberExpression\"(\n path: NodePath<t.OptionalCallExpression | t.OptionalMemberExpression>,\n ) {\n if (shouldTransform(path)) {\n transform(path, { noDocumentAll, pureGetters });\n }\n },\n },\n };\n});\n"],"names":["matchAffectedArguments","argumentNodes","spreadIndex","findIndex","node","t","isSpreadElement","length","shouldTransform","path","optionalPath","chains","isOptionalMemberExpression","push","skipTransparentExprWrappers","get","isOptionalCallExpression","i","arguments","optional","callee","declare","api","_api$assumption","_api$assumption2","assertVersion","noDocumentAll","assumption","pureGetters","name","visitor","OptionalCallExpression|OptionalMemberExpression","transform"],"mappings":";;;;;;;;;AAQA,SAASA,sBAAsBA,CAACC,aAA4C,EAAE;AAC5E,EAAA,MAAMC,WAAW,GAAGD,aAAa,CAACE,SAAS,CAACC,IAAI,IAAIC,UAAC,CAACC,eAAe,CAACF,IAAI,CAAC,CAAC,CAAA;EAC5E,OAAOF,WAAW,IAAI,CAAC,IAAIA,WAAW,KAAKD,aAAa,CAACM,MAAM,GAAG,CAAC,CAAA;AACrE,CAAA;AAUO,SAASC,eAAeA,CAC7BC,IAAqE,EAC5D;EACT,IAAIC,YAAoC,GAAGD,IAAI,CAAA;EAC/C,MAAME,MAAiE,GAAG,EAAE,CAAA;EAC5E,SAAS;AACP,IAAA,IAAID,YAAY,CAACE,0BAA0B,EAAE,EAAE;AAC7CD,MAAAA,MAAM,CAACE,IAAI,CAACH,YAAY,CAACN,IAAI,CAAC,CAAA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,KAAAJ,IAAAA,GAAAA,eAAA,GAAI,KAAK,CAAA;AAC9D,EAAA,MAAMK,WAAW,GAAA,CAAAJ,gBAAA,GAAGF,GAAG,CAACK,UAAU,CAAC,aAAa,CAAC,KAAAH,IAAAA,GAAAA,gBAAA,GAAI,KAAK,CAAA;EAE1D,OAAO;AACLK,IAAAA,IAAI,EAAE,kDAAkD;AAExDC,IAAAA,OAAO,EAAE;MACP,iDAAiDC,CAC/CtB,IAAqE,EACrE;AACA,QAAA,IAAID,eAAe,CAACC,IAAI,CAAC,EAAE;UACzBuB,yCAAS,CAACvB,IAAI,EAAE;YAAEiB,aAAa;AAAEE,YAAAA,WAAAA;AAAY,WAAC,CAAC,CAAA;AACjD,SAAA;AACF,OAAA;AACF,KAAA;GACD,CAAA;AACH,CAAC,CAAC;;;;"} \ No newline at end of file
diff --git a/node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/package.json b/node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/package.json
new file mode 100644
index 00000000..7f54c604
--- /dev/null
+++ b/node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/package.json
@@ -0,0 +1,42 @@
+{
+ "name": "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining",
+ "version": "7.22.15",
+ "description": "Transform optional chaining operators to workaround https://crbug.com/v8/11558",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/babel/babel.git",
+ "directory": "packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining"
+ },
+ "homepage": "https://babel.dev/docs/en/next/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining",
+ "license": "MIT",
+ "publishConfig": {
+ "access": "public"
+ },
+ "main": "./lib/index.js",
+ "exports": {
+ ".": "./lib/index.js",
+ "./package.json": "./package.json"
+ },
+ "keywords": [
+ "babel-plugin",
+ "bugfix"
+ ],
+ "dependencies": {
+ "@babel/helper-plugin-utils": "^7.22.5",
+ "@babel/helper-skip-transparent-expression-wrappers": "^7.22.5",
+ "@babel/plugin-transform-optional-chaining": "^7.22.15"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.13.0"
+ },
+ "devDependencies": {
+ "@babel/core": "^7.22.15",
+ "@babel/helper-plugin-test-runner": "^7.22.5",
+ "@babel/traverse": "^7.22.15"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ },
+ "author": "The Babel Team (https://babel.dev/team)",
+ "type": "commonjs"
+} \ No newline at end of file