8889841cREADME.md000066600000000716150443051770006041 0ustar00# @babel/helper-member-expression-to-functions > Helper function to replace certain member expressions with function calls See our website [@babel/helper-member-expression-to-functions](https://babeljs.io/docs/en/babel-helper-member-expression-to-functions) for more information. ## Install Using npm: ```sh npm install --save @babel/helper-member-expression-to-functions ``` or using yarn: ```sh yarn add @babel/helper-member-expression-to-functions ``` lib/index.js000066600000030454150443051770006777 0ustar00'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var _t = require('@babel/types'); function _interopNamespace(e) { if (e && e.__esModule) return e; var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { if (k !== 'default') { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: function () { return e[k]; } }); } }); } n["default"] = e; return Object.freeze(n); } var _t__namespace = /*#__PURE__*/_interopNamespace(_t); function willPathCastToBoolean(path) { const maybeWrapped = 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 }); } const { LOGICAL_OPERATORS, arrowFunctionExpression, assignmentExpression, binaryExpression, booleanLiteral, callExpression, cloneNode, conditionalExpression, identifier, isMemberExpression, isOptionalCallExpression, isOptionalMemberExpression, isUpdateExpression, logicalExpression, memberExpression, nullLiteral, optionalCallExpression, optionalMemberExpression, sequenceExpression, updateExpression } = _t__namespace; class AssignmentMemoiser { constructor() { this._map = void 0; this._map = new WeakMap(); } has(key) { return this._map.has(key); } get(key) { if (!this.has(key)) return; const record = this._map.get(key); const { value } = record; record.count--; if (record.count === 0) { return assignmentExpression("=", value, key); } return value; } set(key, value, count) { return this._map.set(key, { count, value }); } } function toNonOptional(path, base) { const { node } = path; if (isOptionalMemberExpression(node)) { return memberExpression(base, node.property, node.computed); } if (path.isOptionalCallExpression()) { const callee = path.get("callee"); if (path.node.optional && callee.isOptionalMemberExpression()) { const object = callee.node.object; const context = path.scope.maybeGenerateMemoised(object); callee.get("object").replaceWith(assignmentExpression("=", context, object)); return callExpression(memberExpression(base, identifier("call")), [context, ...path.node.arguments]); } return callExpression(base, path.node.arguments); } return path.node; } function isInDetachedTree(path) { while (path) { if (path.isProgram()) break; const { parentPath, container, listKey } = path; const parentNode = parentPath.node; if (listKey) { if (container !== parentNode[listKey]) { return true; } } else { if (container !== parentNode) return true; } path = parentPath; } return false; } const handle = { memoise() {}, handle(member, noDocumentAll) { const { node, parent, parentPath, scope } = member; if (member.isOptionalMemberExpression()) { if (isInDetachedTree(member)) return; const endPath = member.find(({ node, parent }) => { if (isOptionalMemberExpression(parent)) { return parent.optional || parent.object !== node; } if (isOptionalCallExpression(parent)) { return node !== member.node && parent.optional || parent.callee !== node; } return true; }); if (scope.path.isPattern()) { endPath.replaceWith(callExpression(arrowFunctionExpression([], endPath.node), [])); return; } const willEndPathCastToBoolean = willPathCastToBoolean(endPath); const rootParentPath = endPath.parentPath; if (rootParentPath.isUpdateExpression({ argument: node }) || rootParentPath.isAssignmentExpression({ left: node })) { throw member.buildCodeFrameError(`can't handle assignment`); } const isDeleteOperation = rootParentPath.isUnaryExpression({ operator: "delete" }); if (isDeleteOperation && endPath.isOptionalMemberExpression() && endPath.get("property").isPrivateName()) { throw member.buildCodeFrameError(`can't delete a private class element`); } let startingOptional = member; for (;;) { if (startingOptional.isOptionalMemberExpression()) { if (startingOptional.node.optional) break; startingOptional = startingOptional.get("object"); continue; } else if (startingOptional.isOptionalCallExpression()) { if (startingOptional.node.optional) break; startingOptional = startingOptional.get("callee"); continue; } throw new Error(`Internal error: unexpected ${startingOptional.node.type}`); } const startingNode = startingOptional.isOptionalMemberExpression() ? startingOptional.node.object : startingOptional.node.callee; const baseNeedsMemoised = scope.maybeGenerateMemoised(startingNode); const baseRef = baseNeedsMemoised != null ? baseNeedsMemoised : startingNode; const parentIsOptionalCall = parentPath.isOptionalCallExpression({ callee: node }); const isOptionalCall = parent => parentIsOptionalCall; const parentIsCall = parentPath.isCallExpression({ callee: node }); startingOptional.replaceWith(toNonOptional(startingOptional, baseRef)); if (isOptionalCall()) { if (parent.optional) { parentPath.replaceWith(this.optionalCall(member, parent.arguments)); } else { parentPath.replaceWith(this.call(member, parent.arguments)); } } else if (parentIsCall) { member.replaceWith(this.boundGet(member)); } else if (this.delete && parentPath.isUnaryExpression({ operator: "delete" })) { parentPath.replaceWith(this.delete(member)); } else { member.replaceWith(this.get(member)); } let regular = member.node; for (let current = member; current !== endPath;) { const parentPath = current.parentPath; if (parentPath === endPath && isOptionalCall() && parent.optional) { regular = parentPath.node; break; } regular = toNonOptional(parentPath, regular); current = parentPath; } let context; const endParentPath = endPath.parentPath; if (isMemberExpression(regular) && endParentPath.isOptionalCallExpression({ callee: endPath.node, optional: true })) { const { object } = regular; context = member.scope.maybeGenerateMemoised(object); if (context) { regular.object = assignmentExpression("=", context, object); } } let replacementPath = endPath; if (isDeleteOperation) { replacementPath = endParentPath; regular = endParentPath.node; } const baseMemoised = baseNeedsMemoised ? assignmentExpression("=", cloneNode(baseRef), cloneNode(startingNode)) : cloneNode(baseRef); if (willEndPathCastToBoolean) { let nonNullishCheck; if (noDocumentAll) { nonNullishCheck = binaryExpression("!=", baseMemoised, nullLiteral()); } else { nonNullishCheck = logicalExpression("&&", binaryExpression("!==", baseMemoised, nullLiteral()), binaryExpression("!==", cloneNode(baseRef), scope.buildUndefinedNode())); } replacementPath.replaceWith(logicalExpression("&&", nonNullishCheck, regular)); } else { let nullishCheck; if (noDocumentAll) { nullishCheck = binaryExpression("==", baseMemoised, nullLiteral()); } else { nullishCheck = logicalExpression("||", binaryExpression("===", baseMemoised, nullLiteral()), binaryExpression("===", cloneNode(baseRef), scope.buildUndefinedNode())); } replacementPath.replaceWith(conditionalExpression(nullishCheck, isDeleteOperation ? booleanLiteral(true) : scope.buildUndefinedNode(), regular)); } if (context) { const endParent = endParentPath.node; endParentPath.replaceWith(optionalCallExpression(optionalMemberExpression(endParent.callee, identifier("call"), false, true), [cloneNode(context), ...endParent.arguments], false)); } return; } if (isUpdateExpression(parent, { argument: node })) { if (this.simpleSet) { member.replaceWith(this.simpleSet(member)); return; } const { operator, prefix } = parent; this.memoise(member, 2); const ref = scope.generateUidIdentifierBasedOnNode(node); scope.push({ id: ref }); const seq = [assignmentExpression("=", cloneNode(ref), this.get(member))]; if (prefix) { seq.push(updateExpression(operator, cloneNode(ref), prefix)); const value = sequenceExpression(seq); parentPath.replaceWith(this.set(member, value)); return; } else { const ref2 = scope.generateUidIdentifierBasedOnNode(node); scope.push({ id: ref2 }); seq.push(assignmentExpression("=", cloneNode(ref2), updateExpression(operator, cloneNode(ref), prefix)), cloneNode(ref)); const value = sequenceExpression(seq); parentPath.replaceWith(sequenceExpression([this.set(member, value), cloneNode(ref2)])); return; } } if (parentPath.isAssignmentExpression({ left: node })) { if (this.simpleSet) { member.replaceWith(this.simpleSet(member)); return; } const { operator, right: value } = parentPath.node; if (operator === "=") { parentPath.replaceWith(this.set(member, value)); } else { const operatorTrunc = operator.slice(0, -1); if (LOGICAL_OPERATORS.includes(operatorTrunc)) { this.memoise(member, 1); parentPath.replaceWith(logicalExpression(operatorTrunc, this.get(member), this.set(member, value))); } else { this.memoise(member, 2); parentPath.replaceWith(this.set(member, binaryExpression(operatorTrunc, this.get(member), value))); } } return; } if (parentPath.isCallExpression({ callee: node })) { parentPath.replaceWith(this.call(member, parentPath.node.arguments)); return; } if (parentPath.isOptionalCallExpression({ callee: node })) { if (scope.path.isPattern()) { parentPath.replaceWith(callExpression(arrowFunctionExpression([], parentPath.node), [])); return; } parentPath.replaceWith(this.optionalCall(member, parentPath.node.arguments)); return; } if (this.delete && parentPath.isUnaryExpression({ operator: "delete" })) { parentPath.replaceWith(this.delete(member)); return; } if (parentPath.isForXStatement({ left: node }) || parentPath.isObjectProperty({ value: node }) && parentPath.parentPath.isObjectPattern() || parentPath.isAssignmentPattern({ left: node }) && parentPath.parentPath.isObjectProperty({ value: parent }) && parentPath.parentPath.parentPath.isObjectPattern() || parentPath.isArrayPattern() || parentPath.isAssignmentPattern({ left: node }) && parentPath.parentPath.isArrayPattern() || parentPath.isRestElement()) { member.replaceWith(this.destructureSet(member)); return; } if (parentPath.isTaggedTemplateExpression()) { member.replaceWith(this.boundGet(member)); } else { member.replaceWith(this.get(member)); } } }; function memberExpressionToFunctions(path, visitor, state) { path.traverse(visitor, Object.assign({}, handle, state, { memoiser: new AssignmentMemoiser() })); } exports["default"] = memberExpressionToFunctions; //# sourceMappingURL=index.js.map lib/index.js.map000066600000114426150443051770007555 0ustar00{"version":3,"file":"index.js","sources":["../src/util.ts","../src/index.ts"],"sourcesContent":["import type { NodePath } from \"@babel/traverse\";\n\n/**\n * Test if a NodePath will be cast to boolean when evaluated.\n *\n * @example\n * // returns true\n * const nodePathAQDotB = NodePath(\"if (a?.#b) {}\").get(\"test\"); // a?.#b\n * willPathCastToBoolean(nodePathAQDotB)\n * @example\n * // returns false\n * willPathCastToBoolean(NodePath(\"a?.#b\"))\n * @todo Respect transparent expression wrappers\n * @see {@link packages/babel-plugin-proposal-optional-chaining/src/util.js}\n * @param {NodePath} path\n * @returns {boolean}\n */\nexport function willPathCastToBoolean(path: NodePath): boolean {\n const maybeWrapped = 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","import type { NodePath, Visitor } from \"@babel/traverse\";\nimport {\n LOGICAL_OPERATORS,\n arrowFunctionExpression,\n assignmentExpression,\n binaryExpression,\n booleanLiteral,\n callExpression,\n cloneNode,\n conditionalExpression,\n identifier,\n isMemberExpression,\n isOptionalCallExpression,\n isOptionalMemberExpression,\n isUpdateExpression,\n logicalExpression,\n memberExpression,\n nullLiteral,\n optionalCallExpression,\n optionalMemberExpression,\n sequenceExpression,\n updateExpression,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport { willPathCastToBoolean } from \"./util\";\n\nclass AssignmentMemoiser {\n private _map: WeakMap;\n constructor() {\n this._map = new WeakMap();\n }\n\n has(key: t.Expression) {\n return this._map.has(key);\n }\n\n get(key: t.Expression) {\n if (!this.has(key)) return;\n\n const record = this._map.get(key);\n const { value } = record;\n\n record.count--;\n if (record.count === 0) {\n // The `count` access is the outermost function call (hopefully), so it\n // does the assignment.\n return assignmentExpression(\"=\", value, key);\n }\n return value;\n }\n\n set(key: t.Expression, value: t.Identifier, count: number) {\n return this._map.set(key, { count, value });\n }\n}\n\nfunction toNonOptional(\n path: NodePath,\n base: t.Expression,\n): t.Expression {\n const { node } = path;\n if (isOptionalMemberExpression(node)) {\n return memberExpression(base, node.property, node.computed);\n }\n\n if (path.isOptionalCallExpression()) {\n const callee = path.get(\"callee\");\n if (path.node.optional && callee.isOptionalMemberExpression()) {\n // object must be a conditional expression because the optional private access in object has been transformed\n const object = callee.node.object as t.ConditionalExpression;\n const context = path.scope.maybeGenerateMemoised(object);\n callee\n .get(\"object\")\n .replaceWith(assignmentExpression(\"=\", context, object));\n\n return callExpression(memberExpression(base, identifier(\"call\")), [\n context,\n ...path.node.arguments,\n ]);\n }\n\n return callExpression(base, path.node.arguments);\n }\n\n return path.node;\n}\n\n// Determines if the current path is in a detached tree. This can happen when\n// we are iterating on a path, and replace an ancestor with a new node. Babel\n// doesn't always stop traversing the old node tree, and that can cause\n// inconsistencies.\nfunction isInDetachedTree(path: NodePath) {\n while (path) {\n if (path.isProgram()) break;\n\n const { parentPath, container, listKey } = path;\n const parentNode = parentPath.node;\n if (listKey) {\n if (\n container !==\n // @ts-expect-error listKey must be a valid parent node key\n parentNode[listKey]\n ) {\n return true;\n }\n } else {\n if (container !== parentNode) return true;\n }\n\n path = parentPath;\n }\n\n return false;\n}\n\ntype Member = NodePath;\n\nconst handle = {\n memoise() {\n // noop.\n },\n\n handle(this: HandlerState, member: Member, noDocumentAll: boolean) {\n const { node, parent, parentPath, scope } = member;\n\n if (member.isOptionalMemberExpression()) {\n // Transforming optional chaining requires we replace ancestors.\n if (isInDetachedTree(member)) return;\n\n // We're looking for the end of _this_ optional chain, which is actually\n // the \"rightmost\" property access of the chain. This is because\n // everything up to that property access is \"optional\".\n //\n // Let's take the case of `FOO?.BAR.baz?.qux`, with `FOO?.BAR` being our\n // member. The \"end\" to most users would be `qux` property access.\n // Everything up to it could be skipped if it `FOO` were nullish. But\n // actually, we can consider the `baz` access to be the end. So we're\n // looking for the nearest optional chain that is `optional: true`.\n const endPath = member.find(({ node, parent }) => {\n if (isOptionalMemberExpression(parent)) {\n // We need to check `parent.object` since we could be inside the\n // computed expression of a `bad?.[FOO?.BAR]`. In this case, the\n // endPath is the `FOO?.BAR` member itself.\n return parent.optional || parent.object !== node;\n }\n if (isOptionalCallExpression(parent)) {\n // Checking `parent.callee` since we could be in the arguments, eg\n // `bad?.(FOO?.BAR)`.\n // Also skip `FOO?.BAR` in `FOO?.BAR?.()` since we need to transform the optional call to ensure proper this\n return (\n // In FOO?.#BAR?.(), endPath points the optional call expression so we skip FOO?.#BAR\n (node !== member.node && parent.optional) || parent.callee !== node\n );\n }\n return true;\n }) as NodePath;\n\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 // This can be further optimized to avoid unnecessary IIFE\n if (scope.path.isPattern()) {\n endPath.replaceWith(\n // The injected member will be queued and eventually transformed when visited\n callExpression(arrowFunctionExpression([], endPath.node), []),\n );\n return;\n }\n\n const willEndPathCastToBoolean = willPathCastToBoolean(endPath);\n\n const rootParentPath = endPath.parentPath;\n if (\n rootParentPath.isUpdateExpression({ argument: node }) ||\n rootParentPath.isAssignmentExpression({ left: node })\n ) {\n throw member.buildCodeFrameError(`can't handle assignment`);\n }\n const isDeleteOperation = rootParentPath.isUnaryExpression({\n operator: \"delete\",\n });\n if (\n isDeleteOperation &&\n endPath.isOptionalMemberExpression() &&\n endPath.get(\"property\").isPrivateName()\n ) {\n // @babel/parser will throw error on `delete obj?.#x`.\n // This error serves as fallback when `delete obj?.#x` is constructed from babel types\n throw member.buildCodeFrameError(\n `can't delete a private class element`,\n );\n }\n\n // Now, we're looking for the start of this optional chain, which is\n // optional to the left of this member.\n //\n // Let's take the case of `foo?.bar?.baz.QUX?.BAM`, with `QUX?.BAM` being\n // our member. The \"start\" to most users would be `foo` object access.\n // But actually, we can consider the `bar` access to be the start. So\n // we're looking for the nearest optional chain that is `optional: true`,\n // which is guaranteed to be somewhere in the object/callee tree.\n let startingOptional: NodePath = member;\n for (;;) {\n if (startingOptional.isOptionalMemberExpression()) {\n if (startingOptional.node.optional) break;\n startingOptional = startingOptional.get(\"object\");\n continue;\n } else if (startingOptional.isOptionalCallExpression()) {\n if (startingOptional.node.optional) break;\n startingOptional = startingOptional.get(\"callee\");\n continue;\n }\n // prevent infinite loop: unreachable if the AST is well-formed\n throw new Error(\n `Internal error: unexpected ${startingOptional.node.type}`,\n );\n }\n\n // @ts-expect-error isOptionalMemberExpression does not work with NodePath union\n const startingNode = startingOptional.isOptionalMemberExpression()\n ? // @ts-expect-error isOptionalMemberExpression does not work with NodePath union\n startingOptional.node.object\n : // @ts-expect-error isOptionalMemberExpression does not work with NodePath union\n startingOptional.node.callee;\n const baseNeedsMemoised = scope.maybeGenerateMemoised(startingNode);\n const baseRef = baseNeedsMemoised ?? startingNode;\n\n // Compute parentIsOptionalCall before `startingOptional` is replaced\n // as `node` may refer to `startingOptional.node` before replaced.\n const parentIsOptionalCall = parentPath.isOptionalCallExpression({\n callee: node,\n });\n // here we use a function to wrap `parentIsOptionalCall` to get type\n // for parent, do not use it anywhere else\n // See https://github.com/microsoft/TypeScript/issues/10421\n const isOptionalCall = (\n parent: t.Node,\n ): parent is t.OptionalCallExpression => parentIsOptionalCall;\n // if parentIsCall is true, it implies that node.extra.parenthesized is always true\n const parentIsCall = parentPath.isCallExpression({ callee: node });\n startingOptional.replaceWith(toNonOptional(startingOptional, baseRef));\n if (isOptionalCall(parent)) {\n if (parent.optional) {\n parentPath.replaceWith(this.optionalCall(member, parent.arguments));\n } else {\n parentPath.replaceWith(this.call(member, parent.arguments));\n }\n } else if (parentIsCall) {\n // `(a?.#b)()` to `(a == null ? void 0 : a.#b.bind(a))()`\n member.replaceWith(this.boundGet(member));\n } else if (\n this.delete &&\n parentPath.isUnaryExpression({ operator: \"delete\" })\n ) {\n parentPath.replaceWith(this.delete(member));\n } else {\n member.replaceWith(this.get(member));\n }\n\n let regular: t.Expression = member.node;\n for (let current: NodePath = member; current !== endPath; ) {\n const parentPath = current.parentPath as NodePath;\n // skip transforming `Foo.#BAR?.call(FOO)`\n if (\n parentPath === endPath &&\n isOptionalCall(parent) &&\n parent.optional\n ) {\n regular = parentPath.node;\n break;\n }\n regular = toNonOptional(parentPath, regular);\n current = parentPath;\n }\n\n let context: t.Identifier;\n const endParentPath = endPath.parentPath as NodePath;\n if (\n isMemberExpression(regular) &&\n endParentPath.isOptionalCallExpression({\n callee: endPath.node,\n optional: true,\n })\n ) {\n const { object } = regular;\n context = member.scope.maybeGenerateMemoised(object);\n if (context) {\n regular.object = assignmentExpression(\n \"=\",\n context,\n // object must not be Super when `context` is an identifier\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n object as t.Expression,\n );\n }\n }\n\n let replacementPath: NodePath = endPath;\n if (isDeleteOperation) {\n replacementPath = endParentPath;\n regular = endParentPath.node;\n }\n\n const baseMemoised = baseNeedsMemoised\n ? assignmentExpression(\n \"=\",\n // When base needs memoised, the baseRef must be an identifier\n cloneNode(baseRef as t.Identifier),\n cloneNode(startingNode),\n )\n : cloneNode(baseRef);\n\n if (willEndPathCastToBoolean) {\n let nonNullishCheck;\n if (noDocumentAll) {\n nonNullishCheck = binaryExpression(\"!=\", baseMemoised, nullLiteral());\n } else {\n nonNullishCheck = logicalExpression(\n \"&&\",\n binaryExpression(\"!==\", baseMemoised, nullLiteral()),\n binaryExpression(\n \"!==\",\n cloneNode(baseRef),\n scope.buildUndefinedNode(),\n ),\n );\n }\n replacementPath.replaceWith(\n logicalExpression(\"&&\", nonNullishCheck, regular),\n );\n } else {\n let nullishCheck;\n if (noDocumentAll) {\n nullishCheck = binaryExpression(\"==\", baseMemoised, nullLiteral());\n } else {\n nullishCheck = logicalExpression(\n \"||\",\n binaryExpression(\"===\", baseMemoised, nullLiteral()),\n binaryExpression(\n \"===\",\n cloneNode(baseRef),\n scope.buildUndefinedNode(),\n ),\n );\n }\n\n replacementPath.replaceWith(\n conditionalExpression(\n nullishCheck,\n isDeleteOperation\n ? booleanLiteral(true)\n : scope.buildUndefinedNode(),\n regular,\n ),\n );\n }\n\n // context and isDeleteOperation can not be both truthy\n if (context) {\n const endParent = endParentPath.node as t.OptionalCallExpression;\n endParentPath.replaceWith(\n optionalCallExpression(\n optionalMemberExpression(\n endParent.callee,\n identifier(\"call\"),\n false,\n true,\n ),\n [cloneNode(context), ...endParent.arguments],\n false,\n ),\n );\n }\n\n return;\n }\n\n // MEMBER++ -> _set(MEMBER, (ref = _get(MEMBER), ref2 = ref++, ref)), ref2\n // ++MEMBER -> _set(MEMBER, (ref = _get(MEMBER), ++ref))\n if (isUpdateExpression(parent, { argument: node })) {\n if (this.simpleSet) {\n member.replaceWith(this.simpleSet(member));\n return;\n }\n\n const { operator, prefix } = parent;\n\n // Give the state handler a chance to memoise the member, since we'll\n // reference it twice. The second access (the set) should do the memo\n // assignment.\n this.memoise(member, 2);\n\n const ref = scope.generateUidIdentifierBasedOnNode(node);\n scope.push({ id: ref });\n\n const seq: t.Expression[] = [\n // ref = _get(MEMBER)\n assignmentExpression(\"=\", cloneNode(ref), this.get(member)),\n ];\n\n if (prefix) {\n seq.push(updateExpression(operator, cloneNode(ref), prefix));\n\n // (ref = _get(MEMBER), ++ref)\n const value = sequenceExpression(seq);\n parentPath.replaceWith(this.set(member, value));\n\n return;\n } else {\n const ref2 = scope.generateUidIdentifierBasedOnNode(node);\n scope.push({ id: ref2 });\n\n seq.push(\n assignmentExpression(\n \"=\",\n cloneNode(ref2),\n updateExpression(operator, cloneNode(ref), prefix),\n ),\n cloneNode(ref),\n );\n\n // (ref = _get(MEMBER), ref2 = ref++, ref)\n const value = sequenceExpression(seq);\n parentPath.replaceWith(\n sequenceExpression([this.set(member, value), cloneNode(ref2)]),\n );\n\n return;\n }\n }\n\n // MEMBER = VALUE -> _set(MEMBER, VALUE)\n // MEMBER += VALUE -> _set(MEMBER, _get(MEMBER) + VALUE)\n // MEMBER ??= VALUE -> _get(MEMBER) ?? _set(MEMBER, VALUE)\n if (parentPath.isAssignmentExpression({ left: node })) {\n if (this.simpleSet) {\n member.replaceWith(this.simpleSet(member));\n return;\n }\n\n const { operator, right: value } = parentPath.node;\n\n if (operator === \"=\") {\n parentPath.replaceWith(this.set(member, value));\n } else {\n const operatorTrunc = operator.slice(0, -1);\n if (LOGICAL_OPERATORS.includes(operatorTrunc)) {\n // Give the state handler a chance to memoise the member, since we'll\n // reference it twice. The first access (the get) should do the memo\n // assignment.\n this.memoise(member, 1);\n parentPath.replaceWith(\n logicalExpression(\n operatorTrunc as t.LogicalExpression[\"operator\"],\n this.get(member),\n this.set(member, value),\n ),\n );\n } else {\n // Here, the second access (the set) is evaluated first.\n this.memoise(member, 2);\n parentPath.replaceWith(\n this.set(\n member,\n binaryExpression(\n operatorTrunc as t.BinaryExpression[\"operator\"],\n this.get(member),\n value,\n ),\n ),\n );\n }\n }\n return;\n }\n\n // MEMBER(ARGS) -> _call(MEMBER, ARGS)\n if (parentPath.isCallExpression({ callee: node })) {\n parentPath.replaceWith(this.call(member, parentPath.node.arguments));\n return;\n }\n\n // MEMBER?.(ARGS) -> _optionalCall(MEMBER, ARGS)\n if (parentPath.isOptionalCallExpression({ callee: node })) {\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 // This can be further optimized to avoid unnecessary IIFE\n if (scope.path.isPattern()) {\n parentPath.replaceWith(\n // The injected member will be queued and eventually transformed when visited\n callExpression(arrowFunctionExpression([], parentPath.node), []),\n );\n return;\n }\n parentPath.replaceWith(\n this.optionalCall(member, parentPath.node.arguments),\n );\n return;\n }\n\n // delete MEMBER -> _delete(MEMBER)\n if (this.delete && parentPath.isUnaryExpression({ operator: \"delete\" })) {\n parentPath.replaceWith(this.delete(member));\n return;\n }\n\n // for (MEMBER of ARR)\n // for (MEMBER in ARR)\n // { KEY: MEMBER } = OBJ -> { KEY: _destructureSet(MEMBER) } = OBJ\n // { KEY: MEMBER = _VALUE } = OBJ -> { KEY: _destructureSet(MEMBER) = _VALUE } = OBJ\n // {...MEMBER} -> {..._destructureSet(MEMBER)}\n //\n // [MEMBER] = ARR -> [_destructureSet(MEMBER)] = ARR\n // [MEMBER = _VALUE] = ARR -> [_destructureSet(MEMBER) = _VALUE] = ARR\n // [...MEMBER] -> [..._destructureSet(MEMBER)]\n if (\n // for (MEMBER of ARR)\n // for (MEMBER in ARR)\n parentPath.isForXStatement({ left: node }) ||\n // { KEY: MEMBER } = OBJ\n (parentPath.isObjectProperty({ value: node }) &&\n parentPath.parentPath.isObjectPattern()) ||\n // { KEY: MEMBER = _VALUE } = OBJ\n (parentPath.isAssignmentPattern({ left: node }) &&\n parentPath.parentPath.isObjectProperty({ value: parent }) &&\n parentPath.parentPath.parentPath.isObjectPattern()) ||\n // [MEMBER] = ARR\n parentPath.isArrayPattern() ||\n // [MEMBER = _VALUE] = ARR\n (parentPath.isAssignmentPattern({ left: node }) &&\n parentPath.parentPath.isArrayPattern()) ||\n // {...MEMBER}\n // [...MEMBER]\n parentPath.isRestElement()\n ) {\n member.replaceWith(this.destructureSet(member));\n return;\n }\n\n if (parentPath.isTaggedTemplateExpression()) {\n // MEMBER -> _get(MEMBER).bind(this)\n member.replaceWith(this.boundGet(member));\n } else {\n // MEMBER -> _get(MEMBER)\n member.replaceWith(this.get(member));\n }\n },\n};\n\nexport interface Handler {\n memoise?(\n this: HandlerState & State,\n member: Member,\n count: number,\n ): void;\n destructureSet(\n this: HandlerState & State,\n member: Member,\n ): t.Expression;\n boundGet(this: HandlerState & State, member: Member): t.Expression;\n simpleSet?(this: HandlerState & State, member: Member): t.Expression;\n get(this: HandlerState & State, member: Member): t.Expression;\n set(\n this: HandlerState & State,\n member: Member,\n value: t.Expression,\n ): t.Expression;\n call(\n this: HandlerState & State,\n member: Member,\n args: t.CallExpression[\"arguments\"],\n ): t.Expression;\n optionalCall(\n this: HandlerState & State,\n member: Member,\n args: t.OptionalCallExpression[\"arguments\"],\n ): t.Expression;\n // TODO(Babel 8): Consider making this required, since `.get` doesn't\n // really work as a fallback for `.delete`\n delete?(this: HandlerState & State, member: Member): t.Expression;\n}\n\nexport interface HandlerState extends Handler {\n handle(\n this: HandlerState & State,\n member: Member,\n noDocumentAll?: boolean,\n ): void;\n memoiser: AssignmentMemoiser;\n}\n\n// We do not provide a default traversal visitor\n// Instead, caller passes one, and must call `state.handle` on the members\n// it wishes to be transformed.\n// Additionally, the caller must pass in a state object with at least\n// get, set, and call methods.\n// Optionally, a memoise method may be defined on the state, which will be\n// called when the member is a self-referential update.\nexport default function memberExpressionToFunctions(\n path: NodePath,\n visitor: Visitor>,\n state: Handler & CustomState,\n) {\n path.traverse(visitor, {\n ...handle,\n ...state,\n memoiser: new AssignmentMemoiser(),\n });\n}\n"],"names":["willPathCastToBoolean","path","maybeWrapped","node","parentPath","isLogicalExpression","operator","right","isSequenceExpression","expressions","length","isConditional","test","isUnaryExpression","isLoop","LOGICAL_OPERATORS","arrowFunctionExpression","assignmentExpression","binaryExpression","booleanLiteral","callExpression","cloneNode","conditionalExpression","identifier","isMemberExpression","isOptionalCallExpression","isOptionalMemberExpression","isUpdateExpression","logicalExpression","memberExpression","nullLiteral","optionalCallExpression","optionalMemberExpression","sequenceExpression","updateExpression","_t","AssignmentMemoiser","constructor","_map","WeakMap","has","key","get","record","value","count","set","toNonOptional","base","property","computed","callee","optional","object","context","scope","maybeGenerateMemoised","replaceWith","arguments","isInDetachedTree","isProgram","container","listKey","parentNode","handle","memoise","member","noDocumentAll","parent","endPath","find","isPattern","willEndPathCastToBoolean","rootParentPath","argument","isAssignmentExpression","left","buildCodeFrameError","isDeleteOperation","isPrivateName","startingOptional","Error","type","startingNode","baseNeedsMemoised","baseRef","parentIsOptionalCall","isOptionalCall","parentIsCall","isCallExpression","optionalCall","call","boundGet","delete","regular","current","endParentPath","replacementPath","baseMemoised","nonNullishCheck","buildUndefinedNode","nullishCheck","endParent","simpleSet","prefix","ref","generateUidIdentifierBasedOnNode","push","id","seq","ref2","operatorTrunc","slice","includes","isForXStatement","isObjectProperty","isObjectPattern","isAssignmentPattern","isArrayPattern","isRestElement","destructureSet","isTaggedTemplateExpression","memberExpressionToFunctions","visitor","state","traverse","memoiser"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiBO,SAASA,qBAAqB,CAACC,IAAc,EAAW;EAC7D,MAAMC,YAAY,GAAGD,IAAI,CAAA;EACzB,MAAM;IAAEE,IAAI;AAAEC,IAAAA,UAAAA;AAAW,GAAC,GAAGF,YAAY,CAAA;AACzC,EAAA,IAAIE,UAAU,CAACC,mBAAmB,EAAE,EAAE;IACpC,MAAM;MAAEC,QAAQ;AAAEC,MAAAA,KAAAA;KAAO,GAAGH,UAAU,CAACD,IAAI,CAAA;AAC3C,IAAA,IACEG,QAAQ,KAAK,I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AAO,EAChB3D,MAAAA,CAAAA,MAAAA,CAAAA,EAAAA,EAAAA,MAAM,EACN4D,KAAK,EAAA;IACRE,QAAQ,EAAE,IAAI1F,kBAAkB,EAAA;GAChC,CAAA,CAAA,CAAA;AACJ;;;;"}LICENSE000066600000002122150443051770005560 0ustar00MIT 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. package.json000066600000001374150443051770007051 0ustar00{ "name": "@babel/helper-member-expression-to-functions", "version": "7.21.0", "description": "Helper function to replace certain member expressions with function calls", "repository": { "type": "git", "url": "https://github.com/babel/babel.git", "directory": "packages/babel-helper-member-expression-to-functions" }, "homepage": "https://babel.dev/docs/en/next/babel-helper-member-expression-to-functions", "license": "MIT", "publishConfig": { "access": "public" }, "main": "./lib/index.js", "author": "The Babel Team (https://babel.dev/team)", "dependencies": { "@babel/types": "^7.21.0" }, "devDependencies": { "@babel/traverse": "^7.21.0" }, "engines": { "node": ">=6.9.0" }, "type": "commonjs" }