diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2023-10-14 15:31:11 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2023-10-14 15:31:11 +0800 |
| commit | aa773172311dcada759dfbaac485f4bc6e00bc21 (patch) | |
| tree | ca6d9a5eff3ab8f689f9acb4f0df791d9486813d /node_modules/@babel/plugin-transform-nullish-coalescing-operator | |
| parent | c5a5384e846f242e901e859fe600d695d8990a9a (diff) | |
added babel
Diffstat (limited to 'node_modules/@babel/plugin-transform-nullish-coalescing-operator')
5 files changed, 126 insertions, 0 deletions
diff --git a/node_modules/@babel/plugin-transform-nullish-coalescing-operator/LICENSE b/node_modules/@babel/plugin-transform-nullish-coalescing-operator/LICENSE new file mode 100644 index 00000000..f31575ec --- /dev/null +++ b/node_modules/@babel/plugin-transform-nullish-coalescing-operator/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-nullish-coalescing-operator/README.md b/node_modules/@babel/plugin-transform-nullish-coalescing-operator/README.md new file mode 100644 index 00000000..0d98d92c --- /dev/null +++ b/node_modules/@babel/plugin-transform-nullish-coalescing-operator/README.md @@ -0,0 +1,19 @@ +# @babel/plugin-transform-nullish-coalescing-operator + +> Remove nullish coalescing operator + +See our website [@babel/plugin-transform-nullish-coalescing-operator](https://babeljs.io/docs/babel-plugin-transform-nullish-coalescing-operator) for more information. + +## Install + +Using npm: + +```sh +npm install --save-dev @babel/plugin-transform-nullish-coalescing-operator +``` + +or using yarn: + +```sh +yarn add @babel/plugin-transform-nullish-coalescing-operator --dev +``` diff --git a/node_modules/@babel/plugin-transform-nullish-coalescing-operator/lib/index.js b/node_modules/@babel/plugin-transform-nullish-coalescing-operator/lib/index.js new file mode 100644 index 00000000..e80d70af --- /dev/null +++ b/node_modules/@babel/plugin-transform-nullish-coalescing-operator/lib/index.js @@ -0,0 +1,49 @@ +"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, { + loose = false +}) => { + var _api$assumption; + api.assertVersion(7); + const noDocumentAll = (_api$assumption = api.assumption("noDocumentAll")) != null ? _api$assumption : loose; + return { + name: "transform-nullish-coalescing-operator", + inherits: require("@babel/plugin-syntax-nullish-coalescing-operator").default, + visitor: { + LogicalExpression(path) { + const { + node, + scope + } = path; + if (node.operator !== "??") { + return; + } + let ref; + let assignment; + if (scope.isStatic(node.left)) { + ref = node.left; + assignment = _core.types.cloneNode(node.left); + } else if (scope.path.isPattern()) { + path.replaceWith(_core.template.statement.ast`(() => ${path.node})()`); + return; + } else { + ref = scope.generateUidIdentifierBasedOnNode(node.left); + scope.push({ + id: _core.types.cloneNode(ref) + }); + assignment = _core.types.assignmentExpression("=", ref, node.left); + } + path.replaceWith(_core.types.conditionalExpression(noDocumentAll ? _core.types.binaryExpression("!=", assignment, _core.types.nullLiteral()) : _core.types.logicalExpression("&&", _core.types.binaryExpression("!==", assignment, _core.types.nullLiteral()), _core.types.binaryExpression("!==", _core.types.cloneNode(ref), scope.buildUndefinedNode())), _core.types.cloneNode(ref), node.right)); + } + } + }; +}); +exports.default = _default; + +//# sourceMappingURL=index.js.map diff --git a/node_modules/@babel/plugin-transform-nullish-coalescing-operator/lib/index.js.map b/node_modules/@babel/plugin-transform-nullish-coalescing-operator/lib/index.js.map new file mode 100644 index 00000000..d828f03b --- /dev/null +++ b/node_modules/@babel/plugin-transform-nullish-coalescing-operator/lib/index.js.map @@ -0,0 +1 @@ +{"version":3,"names":["_helperPluginUtils","require","_core","_default","declare","api","loose","_api$assumption","assertVersion","noDocumentAll","assumption","name","inherits","default","visitor","LogicalExpression","path","node","scope","operator","ref","assignment","isStatic","left","t","cloneNode","isPattern","replaceWith","template","statement","ast","generateUidIdentifierBasedOnNode","push","id","assignmentExpression","conditionalExpression","binaryExpression","nullLiteral","logicalExpression","buildUndefinedNode","right","exports"],"sources":["../src/index.ts"],"sourcesContent":["import { declare } from \"@babel/helper-plugin-utils\";\nimport { types as t, template } from \"@babel/core\";\n\nexport interface Options {\n loose?: boolean;\n}\n\nexport default declare((api, { loose = false }: Options) => {\n api.assertVersion(7);\n const noDocumentAll = api.assumption(\"noDocumentAll\") ?? loose;\n\n return {\n name: \"transform-nullish-coalescing-operator\",\n inherits: USE_ESM\n ? undefined\n : IS_STANDALONE\n ? undefined\n : // eslint-disable-next-line no-restricted-globals\n require(\"@babel/plugin-syntax-nullish-coalescing-operator\").default,\n\n visitor: {\n LogicalExpression(path) {\n const { node, scope } = path;\n if (node.operator !== \"??\") {\n return;\n }\n\n let ref;\n let assignment;\n // skip creating extra reference when `left` is static\n if (scope.isStatic(node.left)) {\n ref = node.left;\n assignment = t.cloneNode(node.left);\n } else if (scope.path.isPattern()) {\n // Replace `function (a, x = a.b ?? c) {}` to `function (a, x = (() => a.b ?? c)() ){}`\n // so the temporary variable can be injected in correct scope\n path.replaceWith(template.statement.ast`(() => ${path.node})()`);\n // The injected nullish expression will be queued and eventually transformed when visited\n return;\n } else {\n ref = scope.generateUidIdentifierBasedOnNode(node.left);\n scope.push({ id: t.cloneNode(ref) });\n assignment = t.assignmentExpression(\"=\", ref, node.left);\n }\n\n path.replaceWith(\n t.conditionalExpression(\n // We cannot use `!= null` in spec mode because\n // `document.all == null` and `document.all` is not \"nullish\".\n noDocumentAll\n ? t.binaryExpression(\"!=\", assignment, t.nullLiteral())\n : t.logicalExpression(\n \"&&\",\n t.binaryExpression(\"!==\", assignment, t.nullLiteral()),\n t.binaryExpression(\n \"!==\",\n t.cloneNode(ref),\n scope.buildUndefinedNode(),\n ),\n ),\n t.cloneNode(ref),\n node.right,\n ),\n );\n },\n },\n };\n});\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAAmD,IAAAE,QAAA,GAMpC,IAAAC,0BAAO,EAAC,CAACC,GAAG,EAAE;EAAEC,KAAK,GAAG;AAAe,CAAC,KAAK;EAAA,IAAAC,eAAA;EAC1DF,GAAG,CAACG,aAAa,CAAC,CAAC,CAAC;EACpB,MAAMC,aAAa,IAAAF,eAAA,GAAGF,GAAG,CAACK,UAAU,CAAC,eAAe,CAAC,YAAAH,eAAA,GAAID,KAAK;EAE9D,OAAO;IACLK,IAAI,EAAE,uCAAuC;IAC7CC,QAAQ,EAKJX,OAAO,CAAC,kDAAkD,CAAC,CAACY,OAAO;IAEvEC,OAAO,EAAE;MACPC,iBAAiBA,CAACC,IAAI,EAAE;QACtB,MAAM;UAAEC,IAAI;UAAEC;QAAM,CAAC,GAAGF,IAAI;QAC5B,IAAIC,IAAI,CAACE,QAAQ,KAAK,IAAI,EAAE;UAC1B;QACF;QAEA,IAAIC,GAAG;QACP,IAAIC,UAAU;QAEd,IAAIH,KAAK,CAACI,QAAQ,CAACL,IAAI,CAACM,IAAI,CAAC,EAAE;UAC7BH,GAAG,GAAGH,IAAI,CAACM,IAAI;UACfF,UAAU,GAAGG,WAAC,CAACC,SAAS,CAACR,IAAI,CAACM,IAAI,CAAC;QACrC,CAAC,MAAM,IAAIL,KAAK,CAACF,IAAI,CAACU,SAAS,CAAC,CAAC,EAAE;UAGjCV,IAAI,CAACW,WAAW,CAACC,cAAQ,CAACC,SAAS,CAACC,GAAI,UAASd,IAAI,CAACC,IAAK,KAAI,CAAC;UAEhE;QACF,CAAC,MAAM;UACLG,GAAG,GAAGF,KAAK,CAACa,gCAAgC,CAACd,IAAI,CAACM,IAAI,CAAC;UACvDL,KAAK,CAACc,IAAI,CAAC;YAAEC,EAAE,EAAET,WAAC,CAACC,SAAS,CAACL,GAAG;UAAE,CAAC,CAAC;UACpCC,UAAU,GAAGG,WAAC,CAACU,oBAAoB,CAAC,GAAG,EAAEd,GAAG,EAAEH,IAAI,CAACM,IAAI,CAAC;QAC1D;QAEAP,IAAI,CAACW,WAAW,CACdH,WAAC,CAACW,qBAAqB,CAGrB1B,aAAa,GACTe,WAAC,CAACY,gBAAgB,CAAC,IAAI,EAAEf,UAAU,EAAEG,WAAC,CAACa,WAAW,CAAC,CAAC,CAAC,GACrDb,WAAC,CAACc,iBAAiB,CACjB,IAAI,EACJd,WAAC,CAACY,gBAAgB,CAAC,KAAK,EAAEf,UAAU,EAAEG,WAAC,CAACa,WAAW,CAAC,CAAC,CAAC,EACtDb,WAAC,CAACY,gBAAgB,CAChB,KAAK,EACLZ,WAAC,CAACC,SAAS,CAACL,GAAG,CAAC,EAChBF,KAAK,CAACqB,kBAAkB,CAAC,CAC3B,CACF,CAAC,EACLf,WAAC,CAACC,SAAS,CAACL,GAAG,CAAC,EAChBH,IAAI,CAACuB,KACP,CACF,CAAC;MACH;IACF;EACF,CAAC;AACH,CAAC,CAAC;AAAAC,OAAA,CAAA5B,OAAA,GAAAV,QAAA"}
\ No newline at end of file diff --git a/node_modules/@babel/plugin-transform-nullish-coalescing-operator/package.json b/node_modules/@babel/plugin-transform-nullish-coalescing-operator/package.json new file mode 100644 index 00000000..dd3a8539 --- /dev/null +++ b/node_modules/@babel/plugin-transform-nullish-coalescing-operator/package.json @@ -0,0 +1,35 @@ +{ + "name": "@babel/plugin-transform-nullish-coalescing-operator", + "version": "7.22.11", + "description": "Remove nullish coalescing operator", + "repository": { + "type": "git", + "url": "https://github.com/babel/babel.git", + "directory": "packages/babel-plugin-transform-nullish-coalescing-operator" + }, + "homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-nullish-coalescing-operator", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "main": "./lib/index.js", + "keywords": [ + "babel-plugin" + ], + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + }, + "devDependencies": { + "@babel/core": "^7.22.11", + "@babel/helper-plugin-test-runner": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "author": "The Babel Team (https://babel.dev/team)", + "type": "commonjs" +}
\ No newline at end of file |
