UNPKG

20.1 kBSource Map (JSON)View Raw
1{"version":3,"file":"index.js","sources":["../src/util.js","../src/index.js"],"sourcesContent":["import { 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)) return true;\n maybeWrapped = p;\n });\n return maybeWrapped;\n}\n","import { declare } from \"@babel/helper-plugin-utils\";\nimport {\n isTransparentExprWrapper,\n skipTransparentExprWrappers,\n} from \"@babel/helper-skip-transparent-expression-wrappers\";\nimport syntaxOptionalChaining from \"@babel/plugin-syntax-optional-chaining\";\nimport { types as t, template } from \"@babel/core\";\nimport { willPathCastToBoolean, findOutermostTransparentParent } from \"./util\";\n\nconst { ast } = template.expression;\n\nexport default declare((api, options) => {\n api.assertVersion(7);\n\n const { loose = false } = options;\n\n function isSimpleMemberExpression(expression) {\n expression = skipTransparentExprWrappers(expression);\n return (\n t.isIdentifier(expression) ||\n t.isSuper(expression) ||\n (t.isMemberExpression(expression) &&\n !expression.computed &&\n isSimpleMemberExpression(expression.object))\n );\n }\n\n /**\n * Test if a given optional chain `path` needs to be memoized\n * @param {NodePath} path\n * @returns {boolean}\n */\n function needsMemoize(path) {\n let optionalPath = path;\n const { scope } = path;\n while (\n optionalPath.isOptionalMemberExpression() ||\n optionalPath.isOptionalCallExpression()\n ) {\n const { node } = optionalPath;\n const childKey = optionalPath.isOptionalMemberExpression()\n ? \"object\"\n : \"callee\";\n const childPath = skipTransparentExprWrappers(optionalPath.get(childKey));\n if (node.optional) {\n return !scope.isStatic(childPath.node);\n }\n\n optionalPath = childPath;\n }\n }\n\n return {\n name: \"proposal-optional-chaining\",\n inherits: syntaxOptionalChaining,\n\n visitor: {\n \"OptionalCallExpression|OptionalMemberExpression\"(path) {\n const { scope } = path;\n // maybeWrapped points to the outermost transparent expression wrapper\n // or the path itself\n const maybeWrapped = findOutermostTransparentParent(path);\n const { parentPath } = maybeWrapped;\n const willReplacementCastToBoolean = willPathCastToBoolean(\n maybeWrapped,\n );\n let isDeleteOperation = false;\n const parentIsCall =\n parentPath.isCallExpression({ callee: maybeWrapped.node }) &&\n // note that the first condition must implies that `path.optional` is `true`,\n // otherwise the parentPath should be an OptionalCallExpressioin\n path.isOptionalMemberExpression();\n\n const optionals = [];\n\n let optionalPath = path;\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 if (scope.path.isPattern() && needsMemoize(optionalPath)) {\n path.replaceWith(template.ast`(() => ${path.node})()`);\n // The injected optional chain will be queued and eventually transformed when visited\n return;\n }\n while (\n optionalPath.isOptionalMemberExpression() ||\n optionalPath.isOptionalCallExpression()\n ) {\n const { node } = optionalPath;\n if (node.optional) {\n optionals.push(node);\n }\n\n if (optionalPath.isOptionalMemberExpression()) {\n optionalPath.node.type = \"MemberExpression\";\n optionalPath = skipTransparentExprWrappers(\n optionalPath.get(\"object\"),\n );\n } else if (optionalPath.isOptionalCallExpression()) {\n optionalPath.node.type = \"CallExpression\";\n optionalPath = skipTransparentExprWrappers(\n optionalPath.get(\"callee\"),\n );\n }\n }\n\n let replacementPath = path;\n if (parentPath.isUnaryExpression({ operator: \"delete\" })) {\n replacementPath = parentPath;\n isDeleteOperation = true;\n }\n for (let i = optionals.length - 1; i >= 0; i--) {\n const node = optionals[i];\n\n const isCall = t.isCallExpression(node);\n const replaceKey = isCall ? \"callee\" : \"object\";\n\n const chainWithTypes = node[replaceKey];\n let chain = chainWithTypes;\n\n while (isTransparentExprWrapper(chain)) {\n chain = chain.expression;\n }\n\n let ref;\n let check;\n if (isCall && t.isIdentifier(chain, { name: \"eval\" })) {\n check = ref = chain;\n // `eval?.()` is an indirect eval call transformed to `(0,eval)()`\n node[replaceKey] = t.sequenceExpression([t.numericLiteral(0), ref]);\n } else if (loose && isCall && isSimpleMemberExpression(chain)) {\n // If we are using a loose transform (avoiding a Function#call) and we are at the call,\n // we can avoid a needless memoize. We only do this if the callee is a simple member\n // expression, to avoid multiple calls to nested call expressions.\n check = ref = chainWithTypes;\n } else {\n ref = scope.maybeGenerateMemoised(chain);\n if (ref) {\n check = t.assignmentExpression(\n \"=\",\n t.cloneNode(ref),\n // Here `chainWithTypes` MUST NOT be cloned because it could be\n // updated when generating the memoised context of a call\n // expression\n chainWithTypes,\n );\n\n node[replaceKey] = ref;\n } else {\n check = ref = chainWithTypes;\n }\n }\n\n // Ensure call expressions have the proper `this`\n // `foo.bar()` has context `foo`.\n if (isCall && t.isMemberExpression(chain)) {\n if (loose && isSimpleMemberExpression(chain)) {\n // To avoid a Function#call, we can instead re-grab the property from the context object.\n // `a.?b.?()` translates roughly to `_a.b != null && _a.b()`\n node.callee = chainWithTypes;\n } else {\n // Otherwise, we need to memoize the context object, and change the call into a Function#call.\n // `a.?b.?()` translates roughly to `(_b = _a.b) != null && _b.call(_a)`\n const { object } = chain;\n let context = scope.maybeGenerateMemoised(object);\n if (context) {\n chain.object = t.assignmentExpression(\"=\", context, object);\n } else if (t.isSuper(object)) {\n context = t.thisExpression();\n } else {\n context = object;\n }\n\n node.arguments.unshift(t.cloneNode(context));\n node.callee = t.memberExpression(\n node.callee,\n t.identifier(\"call\"),\n );\n }\n }\n let replacement = replacementPath.node;\n // Ensure (a?.b)() has proper `this`\n // The `parentIsCall` is constant within loop, we should check i === 0\n // to ensure that it is only applied to the first optional chain element\n // i.e. `?.b` in `(a?.b.c)()`\n if (i === 0 && parentIsCall) {\n // `(a?.b)()` to `(a == null ? undefined : a.b.bind(a))()`\n const object = skipTransparentExprWrappers(\n replacementPath.get(\"object\"),\n ).node;\n let baseRef;\n if (!loose || !isSimpleMemberExpression(object)) {\n // memoize the context object in non-loose mode\n // `(a?.b.c)()` to `(a == null ? undefined : (_a$b = a.b).c.bind(_a$b))()`\n baseRef = scope.maybeGenerateMemoised(object);\n if (baseRef) {\n replacement.object = t.assignmentExpression(\n \"=\",\n baseRef,\n object,\n );\n }\n }\n replacement = t.callExpression(\n t.memberExpression(replacement, t.identifier(\"bind\")),\n [t.cloneNode(baseRef ?? object)],\n );\n }\n\n if (willReplacementCastToBoolean) {\n // `if (a?.b) {}` transformed to `if (a != null && a.b) {}`\n // we don't need to return `void 0` because the returned value will\n // eveutally cast to boolean.\n const nonNullishCheck = loose\n ? ast`${t.cloneNode(check)} != null`\n : ast`\n ${t.cloneNode(check)} !== null && ${t.cloneNode(ref)} !== void 0`;\n replacementPath.replaceWith(\n t.logicalExpression(\"&&\", nonNullishCheck, replacement),\n );\n replacementPath = skipTransparentExprWrappers(\n replacementPath.get(\"right\"),\n );\n } else {\n const nullishCheck = loose\n ? ast`${t.cloneNode(check)} == null`\n : ast`\n ${t.cloneNode(check)} === null || ${t.cloneNode(ref)} === void 0`;\n\n const returnValue = isDeleteOperation ? ast`true` : ast`void 0`;\n replacementPath.replaceWith(\n t.conditionalExpression(nullishCheck, returnValue, replacement),\n );\n replacementPath = skipTransparentExprWrappers(\n replacementPath.get(\"alternate\"),\n );\n }\n }\n },\n },\n };\n});\n"],"names":["willPathCastToBoolean","path","maybeWrapped","findOutermostTransparentParent","node","parentPath","isLogicalExpression","operator","right","isSequenceExpression","expressions","length","isConditional","test","isUnaryExpression","isLoop","findParent","p","isTransparentExprWrapper","ast","template","expression","declare","api","options","assertVersion","loose","isSimpleMemberExpression","skipTransparentExprWrappers","t","isIdentifier","isSuper","isMemberExpression","computed","object","needsMemoize","optionalPath","scope","isOptionalMemberExpression","isOptionalCallExpression","childKey","childPath","get","optional","isStatic","name","inherits","syntaxOptionalChaining","visitor","willReplacementCastToBoolean","isDeleteOperation","parentIsCall","isCallExpression","callee","optionals","isPattern","replaceWith","push","type","replacementPath","i","isCall","replaceKey","chainWithTypes","chain","ref","check","sequenceExpression","numericLiteral","maybeGenerateMemoised","assignmentExpression","cloneNode","context","thisExpression","arguments","unshift","memberExpression","identifier","replacement","baseRef","callExpression","nonNullishCheck","logicalExpression","nullishCheck","returnValue","conditionalExpression"],"mappings":";;;;;;;;;;;;;AAgBO,SAASA,qBAAT,CAA+BC,IAA/B,EAAwD;AAC7D,QAAMC,YAAY,GAAGC,8BAA8B,CAACF,IAAD,CAAnD;AACA,QAAM;AAAEG,IAAAA,IAAF;AAAQC,IAAAA;AAAR,MAAuBH,YAA7B;;AACA,MAAIG,UAAU,CAACC,mBAAX,EAAJ,EAAsC;AACpC,UAAM;AAAEC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ,QAAsBH,UAAU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