Commit 0ae470fd authored by Rosanny Sihombing's avatar Rosanny Sihombing
Browse files

Merge branch 'MLAB-670' into 'testing'

Update required modules

See merge request !162
parents cad730bf d27c335f
Pipeline #6650 passed with stage
in 4 seconds
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.
# @babel/helper-optimise-call-expression
> Helper function to optimise call expression
See our website [@babel/helper-optimise-call-expression](https://babeljs.io/docs/en/babel-helper-optimise-call-expression) for more information.
## Install
Using npm:
```sh
npm install --save @babel/helper-optimise-call-expression
```
or using yarn:
```sh
yarn add @babel/helper-optimise-call-expression
```
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = optimiseCallExpression;
var _t = require("@babel/types");
const {
callExpression,
identifier,
isIdentifier,
isSpreadElement,
memberExpression,
optionalCallExpression,
optionalMemberExpression
} = _t;
function optimiseCallExpression(callee, thisNode, args, optional) {
if (args.length === 1 && isSpreadElement(args[0]) && isIdentifier(args[0].argument, {
name: "arguments"
})) {
if (optional) {
return optionalCallExpression(optionalMemberExpression(callee, identifier("apply"), false, true), [thisNode, args[0].argument], false);
}
return callExpression(memberExpression(callee, identifier("apply")), [thisNode, args[0].argument]);
} else {
if (optional) {
return optionalCallExpression(optionalMemberExpression(callee, identifier("call"), false, true), [thisNode, ...args], false);
}
return callExpression(memberExpression(callee, identifier("call")), [thisNode, ...args]);
}
}
\ No newline at end of file
{
"name": "@babel/helper-optimise-call-expression",
"version": "7.18.6",
"description": "Helper function to optimise call expression",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel.git",
"directory": "packages/babel-helper-optimise-call-expression"
},
"homepage": "https://babel.dev/docs/en/next/babel-helper-optimise-call-expression",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"main": "./lib/index.js",
"dependencies": {
"@babel/types": "^7.18.6"
},
"devDependencies": {
"@babel/generator": "^7.18.6",
"@babel/parser": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
},
"author": "The Babel Team (https://babel.dev/team)",
"type": "commonjs"
}
\ No newline at end of file
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.
# @babel/helper-plugin-utils
> General utilities for plugins to use
See our website [@babel/helper-plugin-utils](https://babeljs.io/docs/en/babel-helper-plugin-utils) for more information.
## Install
Using npm:
```sh
npm install --save @babel/helper-plugin-utils
```
or using yarn:
```sh
yarn add @babel/helper-plugin-utils
```
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.declare = declare;
exports.declarePreset = void 0;
function declare(builder) {
return (api, options, dirname) => {
var _clonedApi2;
let clonedApi;
for (const name of Object.keys(apiPolyfills)) {
var _clonedApi;
if (api[name]) continue;
clonedApi = (_clonedApi = clonedApi) != null ? _clonedApi : copyApiObject(api);
clonedApi[name] = apiPolyfills[name](clonedApi);
}
return builder((_clonedApi2 = clonedApi) != null ? _clonedApi2 : api, options || {}, dirname);
};
}
const declarePreset = declare;
exports.declarePreset = declarePreset;
const apiPolyfills = {
assertVersion: api => range => {
throwVersionError(range, api.version);
},
targets: () => () => {
return {};
},
assumption: () => () => {
return undefined;
}
};
function copyApiObject(api) {
let proto = null;
if (typeof api.version === "string" && /^7\./.test(api.version)) {
proto = Object.getPrototypeOf(api);
if (proto && (!has(proto, "version") || !has(proto, "transform") || !has(proto, "template") || !has(proto, "types"))) {
proto = null;
}
}
return Object.assign({}, proto, api);
}
function has(obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key);
}
function throwVersionError(range, version) {
if (typeof range === "number") {
if (!Number.isInteger(range)) {
throw new Error("Expected string or integer value.");
}
range = `^${range}.0.0-0`;
}
if (typeof range !== "string") {
throw new Error("Expected string or integer value.");
}
const limit = Error.stackTraceLimit;
if (typeof limit === "number" && limit < 25) {
Error.stackTraceLimit = 25;
}
let err;
if (version.slice(0, 2) === "7.") {
err = new Error(`Requires Babel "^7.0.0-beta.41", but was loaded with "${version}". ` + `You'll need to update your @babel/core version.`);
} else {
err = new Error(`Requires Babel "${range}", but was loaded with "${version}". ` + `If you are sure you have a compatible version of @babel/core, ` + `it is likely that something in your build process is loading the ` + `wrong version. Inspect the stack trace of this error to look for ` + `the first entry that doesn't mention "@babel/core" or "babel-core" ` + `to see what is calling Babel.`);
}
if (typeof limit === "number") {
Error.stackTraceLimit = limit;
}
throw Object.assign(err, {
code: "BABEL_VERSION_UNSUPPORTED",
version,
range
});
}
\ No newline at end of file
{
"name": "@babel/helper-plugin-utils",
"version": "7.18.6",
"description": "General utilities for plugins to use",
"author": "The Babel Team (https://babel.dev/team)",
"homepage": "https://babel.dev/docs/en/next/babel-helper-plugin-utils",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/babel/babel.git",
"directory": "packages/babel-helper-plugin-utils"
},
"main": "./lib/index.js",
"engines": {
"node": ">=6.9.0"
},
"type": "commonjs"
}
\ No newline at end of file
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.
# @babel/helper-remap-async-to-generator
> Helper function to remap async functions to generators
See our website [@babel/helper-remap-async-to-generator](https://babeljs.io/docs/en/babel-helper-remap-async-to-generator) for more information.
## Install
Using npm:
```sh
npm install --save @babel/helper-remap-async-to-generator
```
or using yarn:
```sh
yarn add @babel/helper-remap-async-to-generator
```
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _helperWrapFunction = require("@babel/helper-wrap-function");
var _helperAnnotateAsPure = require("@babel/helper-annotate-as-pure");
var _helperEnvironmentVisitor = require("@babel/helper-environment-visitor");
var _core = require("@babel/core");
var _t = require("@babel/types");
const {
callExpression,
cloneNode,
isIdentifier,
isThisExpression,
yieldExpression
} = _t;
const awaitVisitor = _core.traverse.visitors.merge([{
ArrowFunctionExpression(path) {
path.skip();
},
AwaitExpression(path, {
wrapAwait
}) {
const argument = path.get("argument");
path.replaceWith(yieldExpression(wrapAwait ? callExpression(cloneNode(wrapAwait), [argument.node]) : argument.node));
}
}, _helperEnvironmentVisitor.default]);
function _default(path, helpers, noNewArrows, ignoreFunctionLength) {
path.traverse(awaitVisitor, {
wrapAwait: helpers.wrapAwait
});
const isIIFE = checkIsIIFE(path);
path.node.async = false;
path.node.generator = true;
(0, _helperWrapFunction.default)(path, cloneNode(helpers.wrapAsync), noNewArrows, ignoreFunctionLength);
const isProperty = path.isObjectMethod() || path.isClassMethod() || path.parentPath.isObjectProperty() || path.parentPath.isClassProperty();
if (!isProperty && !isIIFE && path.isExpression()) {
(0, _helperAnnotateAsPure.default)(path);
}
function checkIsIIFE(path) {
if (path.parentPath.isCallExpression({
callee: path.node
})) {
return true;
}
const {
parentPath
} = path;
if (parentPath.isMemberExpression() && isIdentifier(parentPath.node.property, {
name: "bind"
})) {
const {
parentPath: bindCall
} = parentPath;
return bindCall.isCallExpression() && bindCall.node.arguments.length === 1 && isThisExpression(bindCall.node.arguments[0]) && bindCall.parentPath.isCallExpression({
callee: bindCall.node
});
}
return false;
}
}
\ No newline at end of file
{
"name": "@babel/helper-remap-async-to-generator",
"version": "7.18.6",
"description": "Helper function to remap async functions to generators",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel.git",
"directory": "packages/babel-helper-remap-async-to-generator"
},
"homepage": "https://babel.dev/docs/en/next/babel-helper-remap-async-to-generator",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"main": "./lib/index.js",
"dependencies": {
"@babel/helper-annotate-as-pure": "^7.18.6",
"@babel/helper-environment-visitor": "^7.18.6",
"@babel/helper-wrap-function": "^7.18.6",
"@babel/types": "^7.18.6"
},
"devDependencies": {
"@babel/traverse": "^7.18.6"
},
"peerDependencies": {
"@babel/core": "^7.0.0"
},
"engines": {
"node": ">=6.9.0"
},
"author": "The Babel Team (https://babel.dev/team)",
"type": "commonjs"
}
\ No newline at end of file
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.
# @babel/helper-replace-supers
> Helper function to replace supers
See our website [@babel/helper-replace-supers](https://babeljs.io/docs/en/babel-helper-replace-supers) for more information.
## Install
Using npm:
```sh
npm install --save @babel/helper-replace-supers
```
or using yarn:
```sh
yarn add @babel/helper-replace-supers
```
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
Object.defineProperty(exports, "environmentVisitor", {
enumerable: true,
get: function () {
return _helperEnvironmentVisitor.default;
}
});
Object.defineProperty(exports, "skipAllButComputedKey", {
enumerable: true,
get: function () {
return _helperEnvironmentVisitor.skipAllButComputedKey;
}
});
var _traverse = require("@babel/traverse");
var _helperMemberExpressionToFunctions = require("@babel/helper-member-expression-to-functions");
var _helperOptimiseCallExpression = require("@babel/helper-optimise-call-expression");
var _helperEnvironmentVisitor = require("@babel/helper-environment-visitor");
var _t = require("@babel/types");
const {
assignmentExpression,
booleanLiteral,
callExpression,
cloneNode,
identifier,
memberExpression,
sequenceExpression,
stringLiteral,
thisExpression
} = _t;
function getPrototypeOfExpression(objectRef, isStatic, file, isPrivateMethod) {
objectRef = cloneNode(objectRef);
const targetRef = isStatic || isPrivateMethod ? objectRef : memberExpression(objectRef, identifier("prototype"));
return callExpression(file.addHelper("getPrototypeOf"), [targetRef]);
}
const visitor = _traverse.default.visitors.merge([_helperEnvironmentVisitor.default, {
Super(path, state) {
const {
node,
parentPath
} = path;
if (!parentPath.isMemberExpression({
object: node
})) return;
state.handle(parentPath);
}
}]);
const unshadowSuperBindingVisitor = _traverse.default.visitors.merge([_helperEnvironmentVisitor.default, {
Scopable(path, {
refName
}) {
const binding = path.scope.getOwnBinding(refName);
if (binding && binding.identifier.name === refName) {
path.scope.rename(refName);
}
}
}]);
const specHandlers = {
memoise(superMember, count) {
const {
scope,
node
} = superMember;
const {
computed,
property
} = node;
if (!computed) {
return;
}
const memo = scope.maybeGenerateMemoised(property);
if (!memo) {
return;
}
this.memoiser.set(property, memo, count);
},
prop(superMember) {
const {
computed,
property
} = superMember.node;
if (this.memoiser.has(property)) {
return cloneNode(this.memoiser.get(property));
}
if (computed) {
return cloneNode(property);
}
return stringLiteral(property.name);
},
get(superMember) {
return this._get(superMember, this._getThisRefs());
},
_get(superMember, thisRefs) {
const proto = getPrototypeOfExpression(this.getObjectRef(), this.isStatic, this.file, this.isPrivateMethod);
return callExpression(this.file.addHelper("get"), [thisRefs.memo ? sequenceExpression([thisRefs.memo, proto]) : proto, this.prop(superMember), thisRefs.this]);
},
_getThisRefs() {
if (!this.isDerivedConstructor) {
return {
this: thisExpression()
};
}
const thisRef = this.scope.generateDeclaredUidIdentifier("thisSuper");
return {
memo: assignmentExpression("=", thisRef, thisExpression()),
this: cloneNode(thisRef)
};
},
set(superMember, value) {
const thisRefs = this._getThisRefs();
const proto = getPrototypeOfExpression(this.getObjectRef(), this.isStatic, this.file, this.isPrivateMethod);
return callExpression(this.file.addHelper("set"), [thisRefs.memo ? sequenceExpression([thisRefs.memo, proto]) : proto, this.prop(superMember), value, thisRefs.this, booleanLiteral(superMember.isInStrictMode())]);
},
destructureSet(superMember) {
throw superMember.buildCodeFrameError(`Destructuring to a super field is not supported yet.`);
},
call(superMember, args) {
const thisRefs = this._getThisRefs();
return (0, _helperOptimiseCallExpression.default)(this._get(superMember, thisRefs), cloneNode(thisRefs.this), args, false);
},
optionalCall(superMember, args) {
const thisRefs = this._getThisRefs();
return (0, _helperOptimiseCallExpression.default)(this._get(superMember, thisRefs), cloneNode(thisRefs.this), args, true);
}
};
const looseHandlers = Object.assign({}, specHandlers, {
prop(superMember) {
const {
property
} = superMember.node;
if (this.memoiser.has(property)) {
return cloneNode(this.memoiser.get(property));
}
return cloneNode(property);
},
get(superMember) {
const {
isStatic,
getSuperRef
} = this;
const {
computed
} = superMember.node;
const prop = this.prop(superMember);
let object;
if (isStatic) {
var _getSuperRef;
object = (_getSuperRef = getSuperRef()) != null ? _getSuperRef : memberExpression(identifier("Function"), identifier("prototype"));
} else {
var _getSuperRef2;
object = memberExpression((_getSuperRef2 = getSuperRef()) != null ? _getSuperRef2 : identifier("Object"), identifier("prototype"));
}
return memberExpression(object, prop, computed);
},
set(superMember, value) {
const {
computed
} = superMember.node;
const prop = this.prop(superMember);
return assignmentExpression("=", memberExpression(thisExpression(), prop, computed), value);
},
destructureSet(superMember) {
const {
computed
} = superMember.node;
const prop = this.prop(superMember);
return memberExpression(thisExpression(), prop, computed);
},
call(superMember, args) {
return (0, _helperOptimiseCallExpression.default)(this.get(superMember), thisExpression(), args, false);
},
optionalCall(superMember, args) {
return (0, _helperOptimiseCallExpression.default)(this.get(superMember), thisExpression(), args, true);
}
});
class ReplaceSupers {
constructor(opts) {
var _opts$constantSuper;
const path = opts.methodPath;
this.methodPath = path;
this.isDerivedConstructor = path.isClassMethod({
kind: "constructor"
}) && !!opts.superRef;
this.isStatic = path.isObjectMethod() || path.node.static || (path.isStaticBlock == null ? void 0 : path.isStaticBlock());
this.isPrivateMethod = path.isPrivate() && path.isMethod();
this.file = opts.file;
this.constantSuper = (_opts$constantSuper = opts.constantSuper) != null ? _opts$constantSuper : opts.isLoose;
this.opts = opts;
}
getObjectRef() {
return cloneNode(this.opts.objectRef || this.opts.getObjectRef());
}
getSuperRef() {
if (this.opts.superRef) return cloneNode(this.opts.superRef);
if (this.opts.getSuperRef) {
return cloneNode(this.opts.getSuperRef());
}
}
replace() {
if (this.opts.refToPreserve) {
this.methodPath.traverse(unshadowSuperBindingVisitor, {
refName: this.opts.refToPreserve.name
});
}
const handler = this.constantSuper ? looseHandlers : specHandlers;
(0, _helperMemberExpressionToFunctions.default)(this.methodPath, visitor, Object.assign({
file: this.file,
scope: this.methodPath.scope,
isDerivedConstructor: this.isDerivedConstructor,
isStatic: this.isStatic,
isPrivateMethod: this.isPrivateMethod,
getObjectRef: this.getObjectRef.bind(this),
getSuperRef: this.getSuperRef.bind(this),
boundGet: handler.get
}, handler));
}
}
exports.default = ReplaceSupers;
\ No newline at end of file
{
"name": "@babel/helper-replace-supers",
"version": "7.18.6",
"description": "Helper function to replace supers",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel.git",
"directory": "packages/babel-helper-replace-supers"
},
"homepage": "https://babel.dev/docs/en/next/babel-helper-replace-supers",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"main": "./lib/index.js",
"dependencies": {
"@babel/helper-environment-visitor": "^7.18.6",
"@babel/helper-member-expression-to-functions": "^7.18.6",
"@babel/helper-optimise-call-expression": "^7.18.6",
"@babel/traverse": "^7.18.6",
"@babel/types": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
},
"author": "The Babel Team (https://babel.dev/team)",
"type": "commonjs"
}
\ No newline at end of file
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.
# @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
```
"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;
function simplifyAccess(path, bindingNames, includeUpdateExpression = true) {
path.traverse(simpleAssignmentVisitor, {
scope: path.scope,
bindingNames,
seen: new WeakSet(),
includeUpdateExpression
});
}
const simpleAssignmentVisitor = {
UpdateExpression: {
exit(path) {
const {
scope,
bindingNames,
includeUpdateExpression
} = this;
if (!includeUpdateExpression) {
return;
}
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)]));
}
}
},
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 = "=";
}
}
}
};
\ No newline at end of file
{
"name": "@babel/helper-simple-access",
"version": "7.18.6",
"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.18.6"
},
"devDependencies": {
"@babel/traverse": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
},
"type": "commonjs"
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment