first
This commit is contained in:
22
node_modules/@babel/plugin-transform-optional-chaining/LICENSE
generated
vendored
Normal file
22
node_modules/@babel/plugin-transform-optional-chaining/LICENSE
generated
vendored
Normal file
@ -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.
|
19
node_modules/@babel/plugin-transform-optional-chaining/README.md
generated
vendored
Normal file
19
node_modules/@babel/plugin-transform-optional-chaining/README.md
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
# @babel/plugin-transform-optional-chaining
|
||||
|
||||
> Transform optional chaining operators into a series of nil checks
|
||||
|
||||
See our website [@babel/plugin-transform-optional-chaining](https://babeljs.io/docs/babel-plugin-transform-optional-chaining) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/plugin-transform-optional-chaining
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/plugin-transform-optional-chaining --dev
|
||||
```
|
235
node_modules/@babel/plugin-transform-optional-chaining/lib/index.js
generated
vendored
Normal file
235
node_modules/@babel/plugin-transform-optional-chaining/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,235 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var helperPluginUtils = require('@babel/helper-plugin-utils');
|
||||
var syntaxOptionalChaining = require('@babel/plugin-syntax-optional-chaining');
|
||||
var core = require('@babel/core');
|
||||
var helperSkipTransparentExpressionWrappers = require('@babel/helper-skip-transparent-expression-wrappers');
|
||||
|
||||
function willPathCastToBoolean(path) {
|
||||
const maybeWrapped = findOutermostTransparentParent(path);
|
||||
const {
|
||||
node,
|
||||
parentPath
|
||||
} = maybeWrapped;
|
||||
if (parentPath.isLogicalExpression()) {
|
||||
const {
|
||||
operator,
|
||||
right
|
||||
} = parentPath.node;
|
||||
if (operator === "&&" || operator === "||" || operator === "??" && node === right) {
|
||||
return willPathCastToBoolean(parentPath);
|
||||
}
|
||||
}
|
||||
if (parentPath.isSequenceExpression()) {
|
||||
const {
|
||||
expressions
|
||||
} = parentPath.node;
|
||||
if (expressions[expressions.length - 1] === node) {
|
||||
return willPathCastToBoolean(parentPath);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return parentPath.isConditional({
|
||||
test: node
|
||||
}) || parentPath.isUnaryExpression({
|
||||
operator: "!"
|
||||
}) || parentPath.isLoop({
|
||||
test: node
|
||||
});
|
||||
}
|
||||
function findOutermostTransparentParent(path) {
|
||||
let maybeWrapped = path;
|
||||
path.findParent(p => {
|
||||
if (!helperSkipTransparentExpressionWrappers.isTransparentExprWrapper(p.node)) return true;
|
||||
maybeWrapped = p;
|
||||
});
|
||||
return maybeWrapped;
|
||||
}
|
||||
|
||||
function isSimpleMemberExpression(expression) {
|
||||
expression = helperSkipTransparentExpressionWrappers.skipTransparentExprWrapperNodes(expression);
|
||||
return core.types.isIdentifier(expression) || core.types.isSuper(expression) || core.types.isMemberExpression(expression) && !expression.computed && isSimpleMemberExpression(expression.object);
|
||||
}
|
||||
function needsMemoize(path) {
|
||||
let optionalPath = path;
|
||||
const {
|
||||
scope
|
||||
} = path;
|
||||
while (optionalPath.isOptionalMemberExpression() || optionalPath.isOptionalCallExpression()) {
|
||||
const {
|
||||
node
|
||||
} = optionalPath;
|
||||
const childPath = helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers(optionalPath.isOptionalMemberExpression() ? optionalPath.get("object") : optionalPath.get("callee"));
|
||||
if (node.optional) {
|
||||
return !scope.isStatic(childPath.node);
|
||||
}
|
||||
optionalPath = childPath;
|
||||
}
|
||||
}
|
||||
const NULLISH_CHECK = core.template.expression(`%%check%% === null || %%ref%% === void 0`);
|
||||
const NULLISH_CHECK_NO_DDA = core.template.expression(`%%check%% == null`);
|
||||
const NULLISH_CHECK_NEG = core.template.expression(`%%check%% !== null && %%ref%% !== void 0`);
|
||||
const NULLISH_CHECK_NO_DDA_NEG = core.template.expression(`%%check%% != null`);
|
||||
function transformOptionalChain(path, {
|
||||
pureGetters,
|
||||
noDocumentAll
|
||||
}, replacementPath, ifNullish, wrapLast) {
|
||||
const {
|
||||
scope
|
||||
} = path;
|
||||
if (scope.path.isPattern() && needsMemoize(path)) {
|
||||
replacementPath.replaceWith(core.template.expression.ast`(() => ${replacementPath.node})()`);
|
||||
return;
|
||||
}
|
||||
const optionals = [];
|
||||
let optionalPath = path;
|
||||
while (optionalPath.isOptionalMemberExpression() || optionalPath.isOptionalCallExpression()) {
|
||||
const {
|
||||
node
|
||||
} = optionalPath;
|
||||
if (node.optional) {
|
||||
optionals.push(node);
|
||||
}
|
||||
if (optionalPath.isOptionalMemberExpression()) {
|
||||
optionalPath.node.type = "MemberExpression";
|
||||
optionalPath = helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers(optionalPath.get("object"));
|
||||
} else if (optionalPath.isOptionalCallExpression()) {
|
||||
optionalPath.node.type = "CallExpression";
|
||||
optionalPath = helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers(optionalPath.get("callee"));
|
||||
}
|
||||
}
|
||||
if (optionals.length === 0) {
|
||||
return;
|
||||
}
|
||||
const checks = [];
|
||||
let tmpVar;
|
||||
for (let i = optionals.length - 1; i >= 0; i--) {
|
||||
const node = optionals[i];
|
||||
const isCall = core.types.isCallExpression(node);
|
||||
const chainWithTypes = isCall ? node.callee : node.object;
|
||||
const chain = helperSkipTransparentExpressionWrappers.skipTransparentExprWrapperNodes(chainWithTypes);
|
||||
let ref;
|
||||
let check;
|
||||
if (isCall && core.types.isIdentifier(chain, {
|
||||
name: "eval"
|
||||
})) {
|
||||
check = ref = chain;
|
||||
node.callee = core.types.sequenceExpression([core.types.numericLiteral(0), ref]);
|
||||
} else if (pureGetters && isCall && isSimpleMemberExpression(chain)) {
|
||||
check = ref = node.callee;
|
||||
} else if (scope.isStatic(chain)) {
|
||||
check = ref = chainWithTypes;
|
||||
} else {
|
||||
if (!tmpVar || isCall) {
|
||||
tmpVar = scope.generateUidIdentifierBasedOnNode(chain);
|
||||
scope.push({
|
||||
id: core.types.cloneNode(tmpVar)
|
||||
});
|
||||
}
|
||||
ref = tmpVar;
|
||||
check = core.types.assignmentExpression("=", core.types.cloneNode(tmpVar), chainWithTypes);
|
||||
isCall ? node.callee = ref : node.object = ref;
|
||||
}
|
||||
if (isCall && core.types.isMemberExpression(chain)) {
|
||||
if (pureGetters && isSimpleMemberExpression(chain)) {
|
||||
node.callee = chainWithTypes;
|
||||
} else {
|
||||
const {
|
||||
object
|
||||
} = chain;
|
||||
let context;
|
||||
if (core.types.isSuper(object)) {
|
||||
context = core.types.thisExpression();
|
||||
} else {
|
||||
const memoized = scope.maybeGenerateMemoised(object);
|
||||
if (memoized) {
|
||||
context = memoized;
|
||||
chain.object = core.types.assignmentExpression("=", memoized, object);
|
||||
} else {
|
||||
context = object;
|
||||
}
|
||||
}
|
||||
node.arguments.unshift(core.types.cloneNode(context));
|
||||
node.callee = core.types.memberExpression(node.callee, core.types.identifier("call"));
|
||||
}
|
||||
}
|
||||
const data = {
|
||||
check: core.types.cloneNode(check),
|
||||
ref: core.types.cloneNode(ref)
|
||||
};
|
||||
Object.defineProperty(data, "ref", {
|
||||
enumerable: false
|
||||
});
|
||||
checks.push(data);
|
||||
}
|
||||
let result = replacementPath.node;
|
||||
if (wrapLast) result = wrapLast(result);
|
||||
const ifNullishBoolean = core.types.isBooleanLiteral(ifNullish);
|
||||
const ifNullishFalse = ifNullishBoolean && ifNullish.value === false;
|
||||
const tpl = ifNullishFalse ? noDocumentAll ? NULLISH_CHECK_NO_DDA_NEG : NULLISH_CHECK_NEG : noDocumentAll ? NULLISH_CHECK_NO_DDA : NULLISH_CHECK;
|
||||
const logicalOp = ifNullishFalse ? "&&" : "||";
|
||||
const check = checks.map(tpl).reduce((expr, check) => core.types.logicalExpression(logicalOp, expr, check));
|
||||
replacementPath.replaceWith(ifNullishBoolean ? core.types.logicalExpression(logicalOp, check, result) : core.types.conditionalExpression(check, ifNullish, result));
|
||||
}
|
||||
function transform(path, assumptions) {
|
||||
const {
|
||||
scope
|
||||
} = path;
|
||||
const maybeWrapped = findOutermostTransparentParent(path);
|
||||
const {
|
||||
parentPath
|
||||
} = maybeWrapped;
|
||||
if (parentPath.isUnaryExpression({
|
||||
operator: "delete"
|
||||
})) {
|
||||
transformOptionalChain(path, assumptions, parentPath, core.types.booleanLiteral(true));
|
||||
} else {
|
||||
let wrapLast;
|
||||
if (parentPath.isCallExpression({
|
||||
callee: maybeWrapped.node
|
||||
}) && path.isOptionalMemberExpression()) {
|
||||
wrapLast = replacement => {
|
||||
var _baseRef;
|
||||
const object = helperSkipTransparentExpressionWrappers.skipTransparentExprWrapperNodes(replacement.object);
|
||||
let baseRef;
|
||||
if (!assumptions.pureGetters || !isSimpleMemberExpression(object)) {
|
||||
baseRef = scope.maybeGenerateMemoised(object);
|
||||
if (baseRef) {
|
||||
replacement.object = core.types.assignmentExpression("=", baseRef, object);
|
||||
}
|
||||
}
|
||||
return core.types.callExpression(core.types.memberExpression(replacement, core.types.identifier("bind")), [core.types.cloneNode((_baseRef = baseRef) != null ? _baseRef : object)]);
|
||||
};
|
||||
}
|
||||
transformOptionalChain(path, assumptions, path, willPathCastToBoolean(maybeWrapped) ? core.types.booleanLiteral(false) : scope.buildUndefinedNode(), wrapLast);
|
||||
}
|
||||
}
|
||||
|
||||
var index = helperPluginUtils.declare((api, options) => {
|
||||
var _api$assumption, _api$assumption2;
|
||||
api.assertVersion(7);
|
||||
const {
|
||||
loose = false
|
||||
} = options;
|
||||
const noDocumentAll = (_api$assumption = api.assumption("noDocumentAll")) != null ? _api$assumption : loose;
|
||||
const pureGetters = (_api$assumption2 = api.assumption("pureGetters")) != null ? _api$assumption2 : loose;
|
||||
return {
|
||||
name: "transform-optional-chaining",
|
||||
inherits: syntaxOptionalChaining.default,
|
||||
visitor: {
|
||||
"OptionalCallExpression|OptionalMemberExpression"(path) {
|
||||
transform(path, {
|
||||
noDocumentAll,
|
||||
pureGetters
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
exports["default"] = index;
|
||||
exports.transform = transform;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@babel/plugin-transform-optional-chaining/lib/index.js.map
generated
vendored
Normal file
1
node_modules/@babel/plugin-transform-optional-chaining/lib/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
170
node_modules/@babel/plugin-transform-optional-chaining/lib/transform.js
generated
vendored
Normal file
170
node_modules/@babel/plugin-transform-optional-chaining/lib/transform.js
generated
vendored
Normal file
@ -0,0 +1,170 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.transform = transform;
|
||||
exports.transformOptionalChain = transformOptionalChain;
|
||||
var _core = require("@babel/core");
|
||||
var _helperSkipTransparentExpressionWrappers = require("@babel/helper-skip-transparent-expression-wrappers");
|
||||
var _util = require("./util");
|
||||
function isSimpleMemberExpression(expression) {
|
||||
expression = (0, _helperSkipTransparentExpressionWrappers.skipTransparentExprWrapperNodes)(expression);
|
||||
return _core.types.isIdentifier(expression) || _core.types.isSuper(expression) || _core.types.isMemberExpression(expression) && !expression.computed && isSimpleMemberExpression(expression.object);
|
||||
}
|
||||
function needsMemoize(path) {
|
||||
let optionalPath = path;
|
||||
const {
|
||||
scope
|
||||
} = path;
|
||||
while (optionalPath.isOptionalMemberExpression() || optionalPath.isOptionalCallExpression()) {
|
||||
const {
|
||||
node
|
||||
} = optionalPath;
|
||||
const childPath = (0, _helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers)(optionalPath.isOptionalMemberExpression() ? optionalPath.get("object") : optionalPath.get("callee"));
|
||||
if (node.optional) {
|
||||
return !scope.isStatic(childPath.node);
|
||||
}
|
||||
optionalPath = childPath;
|
||||
}
|
||||
}
|
||||
const NULLISH_CHECK = _core.template.expression(`%%check%% === null || %%ref%% === void 0`);
|
||||
const NULLISH_CHECK_NO_DDA = _core.template.expression(`%%check%% == null`);
|
||||
const NULLISH_CHECK_NEG = _core.template.expression(`%%check%% !== null && %%ref%% !== void 0`);
|
||||
const NULLISH_CHECK_NO_DDA_NEG = _core.template.expression(`%%check%% != null`);
|
||||
function transformOptionalChain(path, {
|
||||
pureGetters,
|
||||
noDocumentAll
|
||||
}, replacementPath, ifNullish, wrapLast) {
|
||||
const {
|
||||
scope
|
||||
} = path;
|
||||
if (scope.path.isPattern() && needsMemoize(path)) {
|
||||
replacementPath.replaceWith(_core.template.expression.ast`(() => ${replacementPath.node})()`);
|
||||
return;
|
||||
}
|
||||
const optionals = [];
|
||||
let optionalPath = path;
|
||||
while (optionalPath.isOptionalMemberExpression() || optionalPath.isOptionalCallExpression()) {
|
||||
const {
|
||||
node
|
||||
} = optionalPath;
|
||||
if (node.optional) {
|
||||
optionals.push(node);
|
||||
}
|
||||
if (optionalPath.isOptionalMemberExpression()) {
|
||||
optionalPath.node.type = "MemberExpression";
|
||||
optionalPath = (0, _helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers)(optionalPath.get("object"));
|
||||
} else if (optionalPath.isOptionalCallExpression()) {
|
||||
optionalPath.node.type = "CallExpression";
|
||||
optionalPath = (0, _helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers)(optionalPath.get("callee"));
|
||||
}
|
||||
}
|
||||
if (optionals.length === 0) {
|
||||
return;
|
||||
}
|
||||
const checks = [];
|
||||
let tmpVar;
|
||||
for (let i = optionals.length - 1; i >= 0; i--) {
|
||||
const node = optionals[i];
|
||||
const isCall = _core.types.isCallExpression(node);
|
||||
const chainWithTypes = isCall ? node.callee : node.object;
|
||||
const chain = (0, _helperSkipTransparentExpressionWrappers.skipTransparentExprWrapperNodes)(chainWithTypes);
|
||||
let ref;
|
||||
let check;
|
||||
if (isCall && _core.types.isIdentifier(chain, {
|
||||
name: "eval"
|
||||
})) {
|
||||
check = ref = chain;
|
||||
node.callee = _core.types.sequenceExpression([_core.types.numericLiteral(0), ref]);
|
||||
} else if (pureGetters && isCall && isSimpleMemberExpression(chain)) {
|
||||
check = ref = node.callee;
|
||||
} else if (scope.isStatic(chain)) {
|
||||
check = ref = chainWithTypes;
|
||||
} else {
|
||||
if (!tmpVar || isCall) {
|
||||
tmpVar = scope.generateUidIdentifierBasedOnNode(chain);
|
||||
scope.push({
|
||||
id: _core.types.cloneNode(tmpVar)
|
||||
});
|
||||
}
|
||||
ref = tmpVar;
|
||||
check = _core.types.assignmentExpression("=", _core.types.cloneNode(tmpVar), chainWithTypes);
|
||||
isCall ? node.callee = ref : node.object = ref;
|
||||
}
|
||||
if (isCall && _core.types.isMemberExpression(chain)) {
|
||||
if (pureGetters && isSimpleMemberExpression(chain)) {
|
||||
node.callee = chainWithTypes;
|
||||
} else {
|
||||
const {
|
||||
object
|
||||
} = chain;
|
||||
let context;
|
||||
if (_core.types.isSuper(object)) {
|
||||
context = _core.types.thisExpression();
|
||||
} else {
|
||||
const memoized = scope.maybeGenerateMemoised(object);
|
||||
if (memoized) {
|
||||
context = memoized;
|
||||
chain.object = _core.types.assignmentExpression("=", memoized, object);
|
||||
} else {
|
||||
context = object;
|
||||
}
|
||||
}
|
||||
node.arguments.unshift(_core.types.cloneNode(context));
|
||||
node.callee = _core.types.memberExpression(node.callee, _core.types.identifier("call"));
|
||||
}
|
||||
}
|
||||
const data = {
|
||||
check: _core.types.cloneNode(check),
|
||||
ref: _core.types.cloneNode(ref)
|
||||
};
|
||||
Object.defineProperty(data, "ref", {
|
||||
enumerable: false
|
||||
});
|
||||
checks.push(data);
|
||||
}
|
||||
let result = replacementPath.node;
|
||||
if (wrapLast) result = wrapLast(result);
|
||||
const ifNullishBoolean = _core.types.isBooleanLiteral(ifNullish);
|
||||
const ifNullishFalse = ifNullishBoolean && ifNullish.value === false;
|
||||
const tpl = ifNullishFalse ? noDocumentAll ? NULLISH_CHECK_NO_DDA_NEG : NULLISH_CHECK_NEG : noDocumentAll ? NULLISH_CHECK_NO_DDA : NULLISH_CHECK;
|
||||
const logicalOp = ifNullishFalse ? "&&" : "||";
|
||||
const check = checks.map(tpl).reduce((expr, check) => _core.types.logicalExpression(logicalOp, expr, check));
|
||||
replacementPath.replaceWith(ifNullishBoolean ? _core.types.logicalExpression(logicalOp, check, result) : _core.types.conditionalExpression(check, ifNullish, result));
|
||||
}
|
||||
function transform(path, assumptions) {
|
||||
const {
|
||||
scope
|
||||
} = path;
|
||||
const maybeWrapped = (0, _util.findOutermostTransparentParent)(path);
|
||||
const {
|
||||
parentPath
|
||||
} = maybeWrapped;
|
||||
if (parentPath.isUnaryExpression({
|
||||
operator: "delete"
|
||||
})) {
|
||||
transformOptionalChain(path, assumptions, parentPath, _core.types.booleanLiteral(true));
|
||||
} else {
|
||||
let wrapLast;
|
||||
if (parentPath.isCallExpression({
|
||||
callee: maybeWrapped.node
|
||||
}) && path.isOptionalMemberExpression()) {
|
||||
wrapLast = replacement => {
|
||||
var _baseRef;
|
||||
const object = (0, _helperSkipTransparentExpressionWrappers.skipTransparentExprWrapperNodes)(replacement.object);
|
||||
let baseRef;
|
||||
if (!assumptions.pureGetters || !isSimpleMemberExpression(object)) {
|
||||
baseRef = scope.maybeGenerateMemoised(object);
|
||||
if (baseRef) {
|
||||
replacement.object = _core.types.assignmentExpression("=", baseRef, object);
|
||||
}
|
||||
}
|
||||
return _core.types.callExpression(_core.types.memberExpression(replacement, _core.types.identifier("bind")), [_core.types.cloneNode((_baseRef = baseRef) != null ? _baseRef : object)]);
|
||||
};
|
||||
}
|
||||
transformOptionalChain(path, assumptions, path, (0, _util.willPathCastToBoolean)(maybeWrapped) ? _core.types.booleanLiteral(false) : scope.buildUndefinedNode(), wrapLast);
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=transform.js.map
|
1
node_modules/@babel/plugin-transform-optional-chaining/lib/transform.js.map
generated
vendored
Normal file
1
node_modules/@babel/plugin-transform-optional-chaining/lib/transform.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
51
node_modules/@babel/plugin-transform-optional-chaining/lib/util.js
generated
vendored
Normal file
51
node_modules/@babel/plugin-transform-optional-chaining/lib/util.js
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.findOutermostTransparentParent = findOutermostTransparentParent;
|
||||
exports.willPathCastToBoolean = willPathCastToBoolean;
|
||||
var _helperSkipTransparentExpressionWrappers = require("@babel/helper-skip-transparent-expression-wrappers");
|
||||
function willPathCastToBoolean(path) {
|
||||
const maybeWrapped = findOutermostTransparentParent(path);
|
||||
const {
|
||||
node,
|
||||
parentPath
|
||||
} = maybeWrapped;
|
||||
if (parentPath.isLogicalExpression()) {
|
||||
const {
|
||||
operator,
|
||||
right
|
||||
} = parentPath.node;
|
||||
if (operator === "&&" || operator === "||" || operator === "??" && node === right) {
|
||||
return willPathCastToBoolean(parentPath);
|
||||
}
|
||||
}
|
||||
if (parentPath.isSequenceExpression()) {
|
||||
const {
|
||||
expressions
|
||||
} = parentPath.node;
|
||||
if (expressions[expressions.length - 1] === node) {
|
||||
return willPathCastToBoolean(parentPath);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return parentPath.isConditional({
|
||||
test: node
|
||||
}) || parentPath.isUnaryExpression({
|
||||
operator: "!"
|
||||
}) || parentPath.isLoop({
|
||||
test: node
|
||||
});
|
||||
}
|
||||
function findOutermostTransparentParent(path) {
|
||||
let maybeWrapped = path;
|
||||
path.findParent(p => {
|
||||
if (!(0, _helperSkipTransparentExpressionWrappers.isTransparentExprWrapper)(p.node)) return true;
|
||||
maybeWrapped = p;
|
||||
});
|
||||
return maybeWrapped;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=util.js.map
|
1
node_modules/@babel/plugin-transform-optional-chaining/lib/util.js.map
generated
vendored
Normal file
1
node_modules/@babel/plugin-transform-optional-chaining/lib/util.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"names":["_helperSkipTransparentExpressionWrappers","require","willPathCastToBoolean","path","maybeWrapped","findOutermostTransparentParent","node","parentPath","isLogicalExpression","operator","right","isSequenceExpression","expressions","length","isConditional","test","isUnaryExpression","isLoop","findParent","p","isTransparentExprWrapper"],"sources":["../src/util.ts"],"sourcesContent":["import type { NodePath } from \"@babel/traverse\";\nimport { isTransparentExprWrapper } from \"@babel/helper-skip-transparent-expression-wrappers\";\n/**\n * Test if a NodePath will be cast to boolean when evaluated.\n * It respects transparent expression wrappers defined in\n * \"@babel/helper-skip-transparent-expression-wrappers\"\n *\n * @example\n * // returns true\n * const nodePathADotB = NodePath(\"if (a.b) {}\").get(\"test\"); // a.b\n * willPathCastToBoolean(nodePathADotB)\n * @example\n * // returns false\n * willPathCastToBoolean(NodePath(\"a.b\"))\n * @param {NodePath} path\n * @returns {boolean}\n */\nexport function willPathCastToBoolean(path: NodePath): boolean {\n const maybeWrapped = findOutermostTransparentParent(path);\n const { node, parentPath } = maybeWrapped;\n if (parentPath.isLogicalExpression()) {\n const { operator, right } = parentPath.node;\n if (\n operator === \"&&\" ||\n operator === \"||\" ||\n (operator === \"??\" && node === right)\n ) {\n return willPathCastToBoolean(parentPath);\n }\n }\n if (parentPath.isSequenceExpression()) {\n const { expressions } = parentPath.node;\n if (expressions[expressions.length - 1] === node) {\n return willPathCastToBoolean(parentPath);\n } else {\n // if it is in the middle of a sequence expression, we don't\n // care the return value so just cast to boolean for smaller\n // output\n return true;\n }\n }\n return (\n parentPath.isConditional({ test: node }) ||\n parentPath.isUnaryExpression({ operator: \"!\" }) ||\n parentPath.isLoop({ test: node })\n );\n}\n\n/**\n * Return the outermost transparent expression wrapper of a given path,\n * otherwise returns path itself.\n * @example\n * const nodePathADotB = NodePath(\"(a.b as any)\").get(\"expression\"); // a.b\n * // returns NodePath(\"(a.b as any)\")\n * findOutermostTransparentParent(nodePathADotB);\n * @param {NodePath} path\n * @returns {NodePath}\n */\nexport function findOutermostTransparentParent(path: NodePath): NodePath {\n let maybeWrapped = path;\n path.findParent(p => {\n if (!isTransparentExprWrapper(p.node)) return true;\n maybeWrapped = p;\n });\n return maybeWrapped;\n}\n"],"mappings":";;;;;;;AACA,IAAAA,wCAAA,GAAAC,OAAA;AAgBO,SAASC,qBAAqBA,CAACC,IAAc,EAAW;EAC7D,MAAMC,YAAY,GAAGC,8BAA8B,CAACF,IAAI,CAAC;EACzD,MAAM;IAAEG,IAAI;IAAEC;EAAW,CAAC,GAAGH,YAAY;EACzC,IAAIG,UAAU,CAACC,mBAAmB,CAAC,CAAC,EAAE;IACpC,MAAM;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAGH,UAAU,CAACD,IAAI;IAC3C,IACEG,QAAQ,KAAK,IAAI,IACjBA,QAAQ,KAAK,IAAI,IAChBA,QAAQ,KAAK,IAAI,IAAIH,IAAI,KAAKI,KAAM,EACrC;MACA,OAAOR,qBAAqB,CAACK,UAAU,CAAC;IAC1C;EACF;EACA,IAAIA,UAAU,CAACI,oBAAoB,CAAC,CAAC,EAAE;IACrC,MAAM;MAAEC;IAAY,CAAC,GAAGL,UAAU,CAACD,IAAI;IACvC,IAAIM,WAAW,CAACA,WAAW,CAACC,MAAM,GAAG,CAAC,CAAC,KAAKP,IAAI,EAAE;MAChD,OAAOJ,qBAAqB,CAACK,UAAU,CAAC;IAC1C,CAAC,MAAM;MAIL,OAAO,IAAI;IACb;EACF;EACA,OACEA,UAAU,CAACO,aAAa,CAAC;IAAEC,IAAI,EAAET;EAAK,CAAC,CAAC,IACxCC,UAAU,CAACS,iBAAiB,CAAC;IAAEP,QAAQ,EAAE;EAAI,CAAC,CAAC,IAC/CF,UAAU,CAACU,MAAM,CAAC;IAAEF,IAAI,EAAET;EAAK,CAAC,CAAC;AAErC;AAYO,SAASD,8BAA8BA,CAACF,IAAc,EAAY;EACvE,IAAIC,YAAY,GAAGD,IAAI;EACvBA,IAAI,CAACe,UAAU,CAACC,CAAC,IAAI;IACnB,IAAI,CAAC,IAAAC,iEAAwB,EAACD,CAAC,CAACb,IAAI,CAAC,EAAE,OAAO,IAAI;IAClDF,YAAY,GAAGe,CAAC;EAClB,CAAC,CAAC;EACF,OAAOf,YAAY;AACrB"}
|
71
node_modules/@babel/plugin-transform-optional-chaining/package.json
generated
vendored
Normal file
71
node_modules/@babel/plugin-transform-optional-chaining/package.json
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
{
|
||||
"_from": "@babel/plugin-transform-optional-chaining@^7.22.10",
|
||||
"_id": "@babel/plugin-transform-optional-chaining@7.22.10",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-MMkQqZAZ+MGj+jGTG3OTuhKeBpNcO+0oCEbrGNEaOmiEn+1MzRyQlYsruGiU8RTK3zV6XwrVJTmwiDOyYK6J9g==",
|
||||
"_location": "/@babel/plugin-transform-optional-chaining",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@babel/plugin-transform-optional-chaining@^7.22.10",
|
||||
"name": "@babel/plugin-transform-optional-chaining",
|
||||
"escapedName": "@babel%2fplugin-transform-optional-chaining",
|
||||
"scope": "@babel",
|
||||
"rawSpec": "^7.22.10",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^7.22.10"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining",
|
||||
"/@babel/preset-env"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.22.10.tgz",
|
||||
"_shasum": "076d28a7e074392e840d4ae587d83445bac0372a",
|
||||
"_spec": "@babel/plugin-transform-optional-chaining@^7.22.10",
|
||||
"_where": "C:\\Users\\zhouxueli\\Desktop\\scheduling-app\\node_modules\\@babel\\preset-env",
|
||||
"author": {
|
||||
"name": "The Babel Team",
|
||||
"url": "https://babel.dev/team"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/babel/babel/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"@babel/helper-plugin-utils": "^7.22.5",
|
||||
"@babel/helper-skip-transparent-expression-wrappers": "^7.22.5",
|
||||
"@babel/plugin-syntax-optional-chaining": "^7.8.3"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Transform optional chaining operators into a series of nil checks",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.22.10",
|
||||
"@babel/helper-plugin-test-runner": "^7.22.5",
|
||||
"@babel/plugin-transform-block-scoping": "^7.22.10",
|
||||
"@babel/traverse": "^7.22.10"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-optional-chaining",
|
||||
"keywords": [
|
||||
"babel-plugin"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./lib/index.js",
|
||||
"name": "@babel/plugin-transform-optional-chaining",
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-plugin-transform-optional-chaining"
|
||||
},
|
||||
"type": "commonjs",
|
||||
"version": "7.22.10"
|
||||
}
|
Reference in New Issue
Block a user