diff options
Diffstat (limited to 'node_modules/@babel/helper-simple-access')
5 files changed, 161 insertions, 0 deletions
diff --git a/node_modules/@babel/helper-simple-access/LICENSE b/node_modules/@babel/helper-simple-access/LICENSE new file mode 100644 index 00000000..f31575ec --- /dev/null +++ b/node_modules/@babel/helper-simple-access/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/helper-simple-access/README.md b/node_modules/@babel/helper-simple-access/README.md new file mode 100644 index 00000000..01aa70a6 --- /dev/null +++ b/node_modules/@babel/helper-simple-access/README.md @@ -0,0 +1,19 @@ +# @babel/helper-simple-access + +> Babel helper for ensuring that access to a given value is performed through simple accesses + +See our website [@babel/helper-simple-access](https://babeljs.io/docs/en/babel-helper-simple-access) for more information. + +## Install + +Using npm: + +```sh +npm install --save @babel/helper-simple-access +``` + +or using yarn: + +```sh +yarn add @babel/helper-simple-access +``` diff --git a/node_modules/@babel/helper-simple-access/lib/index.js b/node_modules/@babel/helper-simple-access/lib/index.js new file mode 100644 index 00000000..90680f58 --- /dev/null +++ b/node_modules/@babel/helper-simple-access/lib/index.js @@ -0,0 +1,91 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = simplifyAccess; +var _t = require("@babel/types"); +const { + LOGICAL_OPERATORS, + assignmentExpression, + binaryExpression, + cloneNode, + identifier, + logicalExpression, + numericLiteral, + sequenceExpression, + unaryExpression +} = _t; +const simpleAssignmentVisitor = { + AssignmentExpression: { + exit(path) { + const { + scope, + seen, + bindingNames + } = this; + if (path.node.operator === "=") return; + if (seen.has(path.node)) return; + seen.add(path.node); + const left = path.get("left"); + if (!left.isIdentifier()) return; + const localName = left.node.name; + if (!bindingNames.has(localName)) return; + if (scope.getBinding(localName) !== path.scope.getBinding(localName)) { + return; + } + const operator = path.node.operator.slice(0, -1); + if (LOGICAL_OPERATORS.includes(operator)) { + path.replaceWith(logicalExpression(operator, path.node.left, assignmentExpression("=", cloneNode(path.node.left), path.node.right))); + } else { + path.node.right = binaryExpression(operator, cloneNode(path.node.left), path.node.right); + path.node.operator = "="; + } + } + } +}; +{ + simpleAssignmentVisitor.UpdateExpression = { + exit(path) { + if (!this.includeUpdateExpression) return; + const { + scope, + bindingNames + } = this; + const arg = path.get("argument"); + if (!arg.isIdentifier()) return; + const localName = arg.node.name; + if (!bindingNames.has(localName)) return; + if (scope.getBinding(localName) !== path.scope.getBinding(localName)) { + return; + } + if (path.parentPath.isExpressionStatement() && !path.isCompletionRecord()) { + const operator = path.node.operator == "++" ? "+=" : "-="; + path.replaceWith(assignmentExpression(operator, arg.node, numericLiteral(1))); + } else if (path.node.prefix) { + path.replaceWith(assignmentExpression("=", identifier(localName), binaryExpression(path.node.operator[0], unaryExpression("+", arg.node), numericLiteral(1)))); + } else { + const old = path.scope.generateUidIdentifierBasedOnNode(arg.node, "old"); + const varName = old.name; + path.scope.push({ + id: old + }); + const binary = binaryExpression(path.node.operator[0], identifier(varName), numericLiteral(1)); + path.replaceWith(sequenceExpression([assignmentExpression("=", identifier(varName), unaryExpression("+", arg.node)), assignmentExpression("=", cloneNode(arg.node), binary), identifier(varName)])); + } + } + }; +} +function simplifyAccess(path, bindingNames) { + { + var _arguments$; + path.traverse(simpleAssignmentVisitor, { + scope: path.scope, + bindingNames, + seen: new WeakSet(), + includeUpdateExpression: (_arguments$ = arguments[2]) != null ? _arguments$ : true + }); + } +} + +//# sourceMappingURL=index.js.map diff --git a/node_modules/@babel/helper-simple-access/lib/index.js.map b/node_modules/@babel/helper-simple-access/lib/index.js.map new file mode 100644 index 00000000..91b2e4f3 --- /dev/null +++ b/node_modules/@babel/helper-simple-access/lib/index.js.map @@ -0,0 +1 @@ +{"version":3,"names":["_t","require","LOGICAL_OPERATORS","assignmentExpression","binaryExpression","cloneNode","identifier","logicalExpression","numericLiteral","sequenceExpression","unaryExpression","simpleAssignmentVisitor","AssignmentExpression","exit","path","scope","seen","bindingNames","node","operator","has","add","left","get","isIdentifier","localName","name","getBinding","slice","includes","replaceWith","right","UpdateExpression","includeUpdateExpression","arg","parentPath","isExpressionStatement","isCompletionRecord","prefix","old","generateUidIdentifierBasedOnNode","varName","push","id","binary","simplifyAccess","_arguments$","traverse","WeakSet","arguments"],"sources":["../src/index.ts"],"sourcesContent":["import {\n LOGICAL_OPERATORS,\n assignmentExpression,\n binaryExpression,\n cloneNode,\n identifier,\n logicalExpression,\n numericLiteral,\n sequenceExpression,\n unaryExpression,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport type { NodePath, Scope, Visitor } from \"@babel/traverse\";\n\ntype State = {\n scope: Scope;\n bindingNames: Set<string>;\n seen: WeakSet<t.Node>;\n};\n\nconst simpleAssignmentVisitor: Visitor<State> = {\n AssignmentExpression: {\n exit(path) {\n const { scope, seen, bindingNames } = this;\n\n if (path.node.operator === \"=\") return;\n\n if (seen.has(path.node)) return;\n seen.add(path.node);\n\n const left = path.get(\"left\");\n if (!left.isIdentifier()) return;\n\n // Simple update-assign foo += 1;\n // => exports.foo = (foo += 1);\n const localName = left.node.name;\n\n if (!bindingNames.has(localName)) return;\n\n // redeclared in this scope\n if (scope.getBinding(localName) !== path.scope.getBinding(localName)) {\n return;\n }\n\n const operator = path.node.operator.slice(0, -1);\n if (LOGICAL_OPERATORS.includes(operator)) {\n // &&, ||, ??\n // (foo &&= bar) => (foo && foo = bar)\n path.replaceWith(\n logicalExpression(\n // @ts-expect-error Guarded by LOGICAL_OPERATORS.includes\n operator,\n path.node.left,\n assignmentExpression(\n \"=\",\n cloneNode(path.node.left),\n path.node.right,\n ),\n ),\n );\n } else {\n // (foo += bar) => (foo = foo + bar)\n path.node.right = binaryExpression(\n // @ts-expect-error An assignment expression operator removing \"=\" must\n // be a valid binary operator\n operator,\n cloneNode(path.node.left),\n path.node.right,\n );\n path.node.operator = \"=\";\n }\n },\n },\n};\n\nif (!process.env.BABEL_8_BREAKING) {\n simpleAssignmentVisitor.UpdateExpression = {\n exit(path) {\n // @ts-expect-error This is Babel7-only\n if (!this.includeUpdateExpression) return;\n\n const { scope, bindingNames } = this;\n\n const arg = path.get(\"argument\");\n if (!arg.isIdentifier()) return;\n const localName = arg.node.name;\n\n if (!bindingNames.has(localName)) return;\n\n // redeclared in this scope\n if (scope.getBinding(localName) !== path.scope.getBinding(localName)) {\n return;\n }\n\n if (\n path.parentPath.isExpressionStatement() &&\n !path.isCompletionRecord()\n ) {\n // ++i => (i += 1);\n const operator = path.node.operator == \"++\" ? \"+=\" : \"-=\";\n path.replaceWith(\n assignmentExpression(operator, arg.node, numericLiteral(1)),\n );\n } else if (path.node.prefix) {\n // ++i => (i = (+i) + 1);\n path.replaceWith(\n assignmentExpression(\n \"=\",\n identifier(localName),\n binaryExpression(\n path.node.operator[0] as \"+\" | \"-\",\n unaryExpression(\"+\", arg.node),\n numericLiteral(1),\n ),\n ),\n );\n } else {\n const old = path.scope.generateUidIdentifierBasedOnNode(\n arg.node,\n \"old\",\n );\n const varName = old.name;\n path.scope.push({ id: old });\n\n const binary = binaryExpression(\n path.node.operator[0] as \"+\" | \"-\",\n identifier(varName),\n // todo: support bigint\n numericLiteral(1),\n );\n\n // i++ => (_old = (+i), i = _old + 1, _old)\n path.replaceWith(\n sequenceExpression([\n assignmentExpression(\n \"=\",\n identifier(varName),\n unaryExpression(\"+\", arg.node),\n ),\n assignmentExpression(\"=\", cloneNode(arg.node), binary),\n identifier(varName),\n ]),\n );\n }\n },\n };\n}\n\nexport default function simplifyAccess(\n path: NodePath,\n bindingNames: Set<string>,\n) {\n if (process.env.BABEL_8_BREAKING) {\n path.traverse(simpleAssignmentVisitor, {\n scope: path.scope,\n bindingNames,\n seen: new WeakSet(),\n });\n } else {\n path.traverse(simpleAssignmentVisitor, {\n scope: path.scope,\n bindingNames,\n seen: new WeakSet(),\n // @ts-expect-error This is Babel7-only\n includeUpdateExpression: arguments[2] ?? true,\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,EAAA,GAAAC,OAAA;AAUsB;EATpBC,iBAAiB;EACjBC,oBAAoB;EACpBC,gBAAgB;EAChBC,SAAS;EACTC,UAAU;EACVC,iBAAiB;EACjBC,cAAc;EACdC,kBAAkB;EAClBC;AAAe,IAAAV,EAAA;AAWjB,MAAMW,uBAAuC,GAAG;EAC9CC,oBAAoB,EAAE;IACpBC,IAAIA,CAACC,IAAI,EAAE;MACT,MAAM;QAAEC,KAAK;QAAEC,IAAI;QAAEC;MAAa,CAAC,GAAG,IAAI;MAE1C,IAAIH,IAAI,CAACI,IAAI,CAACC,QAAQ,KAAK,GAAG,EAAE;MAEhC,IAAIH,IAAI,CAACI,GAAG,CAACN,IAAI,CAACI,IAAI,CAAC,EAAE;MACzBF,IAAI,CAACK,GAAG,CAACP,IAAI,CAACI,IAAI,CAAC;MAEnB,MAAMI,IAAI,GAAGR,IAAI,CAACS,GAAG,CAAC,MAAM,CAAC;MAC7B,IAAI,CAACD,IAAI,CAACE,YAAY,CAAC,CAAC,EAAE;MAI1B,MAAMC,SAAS,GAAGH,IAAI,CAACJ,IAAI,CA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,CAAC,CAClB,CAAC;QAGDM,IAAI,CAACgB,WAAW,CACdrB,kBAAkB,CAAC,CACjBN,oBAAoB,CAClB,GAAG,EACHG,UAAU,CAACmC,OAAO,CAAC,EACnB/B,eAAe,CAAC,GAAG,EAAEwB,GAAG,CAAChB,IAAI,CAC/B,CAAC,EACDf,oBAAoB,CAAC,GAAG,EAAEE,SAAS,CAAC6B,GAAG,CAAChB,IAAI,CAAC,EAAE0B,MAAM,CAAC,EACtDtC,UAAU,CAACmC,OAAO,CAAC,CACpB,CACH,CAAC;MACH;IACF;EACF,CAAC;AACH;AAEe,SAASI,cAAcA,CACpC/B,IAAc,EACdG,YAAyB,EACzB;EAOO;IAAA,IAAA6B,WAAA;IACLhC,IAAI,CAACiC,QAAQ,CAACpC,uBAAuB,EAAE;MACrCI,KAAK,EAAED,IAAI,CAACC,KAAK;MACjBE,YAAY;MACZD,IAAI,EAAE,IAAIgC,OAAO,CAAC,CAAC;MAEnBf,uBAAuB,GAAAa,WAAA,GAAEG,SAAS,CAAC,CAAC,CAAC,YAAAH,WAAA,GAAI;IAC3C,CAAC,CAAC;EACJ;AACF"}
\ No newline at end of file diff --git a/node_modules/@babel/helper-simple-access/package.json b/node_modules/@babel/helper-simple-access/package.json new file mode 100644 index 00000000..d71efa40 --- /dev/null +++ b/node_modules/@babel/helper-simple-access/package.json @@ -0,0 +1,28 @@ +{ + "name": "@babel/helper-simple-access", + "version": "7.22.5", + "description": "Babel helper for ensuring that access to a given value is performed through simple accesses", + "author": "The Babel Team (https://babel.dev/team)", + "homepage": "https://babel.dev/docs/en/next/babel-helper-simple-access", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/babel/babel.git", + "directory": "packages/babel-helper-simple-access" + }, + "main": "./lib/index.js", + "dependencies": { + "@babel/types": "^7.22.5" + }, + "devDependencies": { + "@babel/core": "^7.22.5", + "@babel/traverse": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "type": "commonjs" +}
\ No newline at end of file |
