@babel/plugin-proposal-decorators 7.19.3 → 7.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/transformer-2022-03.js +1 -1
- package/lib/transformer-2022-03.js.map +1 -1
- package/package.json +3 -3
- package/CONTRIB.md +0 -396
|
@@ -461,7 +461,7 @@ function transformClass(path, state, constantSuper, version) {
|
|
|
461
461
|
element.node.decorators = null;
|
|
462
462
|
}
|
|
463
463
|
|
|
464
|
-
if (!firstFieldPath && (kind === FIELD || kind === ACCESSOR)) {
|
|
464
|
+
if (!firstFieldPath && !isStatic && (kind === FIELD || kind === ACCESSOR)) {
|
|
465
465
|
firstFieldPath = element;
|
|
466
466
|
}
|
|
467
467
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["incrementId","id","idx","length","unshift","current","createPrivateUidGeneratorForClass","classPath","currentPrivateId","privateNames","Set","traverse","PrivateName","path","add","node","name","reifiedId","String","fromCharCode","has","t","privateName","identifier","createLazyPrivateUidGeneratorForClass","generator","replaceClassWithVar","type","varId","scope","generateUidIdentifierBasedOnNode","classId","rename","insertBefore","variableDeclaration","variableDeclarator","get","replaceWith","cloneNode","className","parent","generateDeclaredUidIdentifier","parentPath","newClassExpr","classExpression","superClass","body","newPath","sequenceExpression","generateClassProperty","key","value","isStatic","classPrivateProperty","undefined","classProperty","addProxyAccessorsFor","element","originalKey","targetKey","isComputed","static","getterBody","blockStatement","returnStatement","memberExpression","thisExpression","setterBody","expressionStatement","assignmentExpression","getter","setter","classPrivateMethod","classMethod","insertAfter","extractProxyAccessorsFor","functionExpression","FIELD","ACCESSOR","METHOD","GETTER","SETTER","STATIC","getElementKind","kind","isDecoratorInfo","info","filteredOrderedDecoratorInfo","filtered","filter","el","generateDecorationExprs","arrayExpression","map","decs","decorators","decInfo","numericLiteral","privateMethods","Array","isArray","push","extractElementLocalAssignments","decorationInfo","localIds","locals","addCallAccessorsFor","getId","setId","callExpression","isNotTsParameter","movePrivateAccessor","methodLocalVar","params","block","isClassDecoratableElementPath","staticBlockToIIFE","arrowFunctionExpression","maybeSequenceExpression","exprs","unaryExpression","transformClass","state","constantSuper","version","classDecorators","hasElementDecorators","generateClassPrivateUid","computed","newId","valueNode","newField","elementDecoratorInfo","firstFieldPath","constructorPath","requiresProtoInit","requiresStaticInit","decoratedPrivateMethods","protoInitLocal","staticInitLocal","classInitLocal","classLocal","assignments","scopeParent","memoiseExpression","expression","hint","localEvaluatedId","localId","classDecorator","generateUidIdentifier","hasDecorators","decoratorPath","isPrivate","isClassMethod","newFieldInitId","newValue","initId","valuePath","v","replaceSupers","ReplaceSupers","methodPath","objectRef","superRef","file","refToPreserve","replace","async","isAsync","remove","nameExpr","stringLiteral","d","elementDecorations","classDecorations","protoInitCall","CallExpression","exit","isSuper","skip","super","spreadElement","restElement","size","parentParentPath","left","buildCodeFrameError","classInitInjected","classInitCall","originalClass","statics","staticBlocks","forEach","isStaticBlock","isProperty","isClassProperty","isClassPrivateProperty","isClassPrivateMethod","allValues","staticsClass","template","ast","addHelper","staticBlock","toStatement","constructorBody","newExpr","newExpression","arguments","arrayPattern","Boolean","expr","crawl","assertVersion","assumption","loose","VISITED","WeakSet","inherits","syntaxDecorators","visitor","declaration","splitExportDeclaration","Class"],"sources":["../src/transformer-2022-03.ts"],"sourcesContent":["import type { NodePath, Scope } from \"@babel/traverse\";\nimport { types as t, template } from \"@babel/core\";\nimport syntaxDecorators from \"@babel/plugin-syntax-decorators\";\nimport ReplaceSupers from \"@babel/helper-replace-supers\";\nimport splitExportDeclaration from \"@babel/helper-split-export-declaration\";\nimport * as charCodes from \"charcodes\";\nimport type { PluginAPI, PluginObject, PluginPass } from \"@babel/core\";\nimport type { Options } from \"./index\";\n\ntype ClassDecoratableElement =\n | t.ClassMethod\n | t.ClassPrivateMethod\n | t.ClassProperty\n | t.ClassPrivateProperty\n | t.ClassAccessorProperty;\n\ntype ClassElement =\n | ClassDecoratableElement\n | t.TSDeclareMethod\n | t.TSIndexSignature\n | t.StaticBlock;\n\nfunction incrementId(id: number[], idx = id.length - 1): void {\n // If index is -1, id needs an additional character, unshift A\n if (idx === -1) {\n id.unshift(charCodes.uppercaseA);\n return;\n }\n\n const current = id[idx];\n\n if (current === charCodes.uppercaseZ) {\n // if current is Z, skip to a\n id[idx] = charCodes.lowercaseA;\n } else if (current === charCodes.lowercaseZ) {\n // if current is z, reset to A and carry the 1\n id[idx] = charCodes.uppercaseA;\n incrementId(id, idx - 1);\n } else {\n // else, increment by one\n id[idx] = current + 1;\n }\n}\n\n/**\n * Generates a new private name that is unique to the given class. This can be\n * used to create extra class fields and methods for the implementation, while\n * keeping the length of those names as small as possible. This is important for\n * minification purposes (though private names can generally be minified,\n * transpilations and polyfills cannot yet).\n */\nfunction createPrivateUidGeneratorForClass(\n classPath: NodePath<t.ClassDeclaration | t.ClassExpression>,\n): () => t.PrivateName {\n const currentPrivateId: number[] = [];\n const privateNames = new Set<string>();\n\n classPath.traverse({\n PrivateName(path) {\n privateNames.add(path.node.id.name);\n },\n });\n\n return (): t.PrivateName => {\n let reifiedId;\n do {\n incrementId(currentPrivateId);\n reifiedId = String.fromCharCode(...currentPrivateId);\n } while (privateNames.has(reifiedId));\n\n return t.privateName(t.identifier(reifiedId));\n };\n}\n\n/**\n * Wraps the above generator function so that it's run lazily the first time\n * it's actually required. Several types of decoration do not require this, so it\n * saves iterating the class elements an additional time and allocating the space\n * for the Sets of element names.\n */\nfunction createLazyPrivateUidGeneratorForClass(\n classPath: NodePath<t.ClassDeclaration | t.ClassExpression>,\n): () => t.PrivateName {\n let generator: () => t.PrivateName;\n\n return (): t.PrivateName => {\n if (!generator) {\n generator = createPrivateUidGeneratorForClass(classPath);\n }\n\n return generator();\n };\n}\n\n/**\n * Takes a class definition and replaces it with an equivalent class declaration\n * which is then assigned to a local variable. This allows us to reassign the\n * local variable with the decorated version of the class. The class definition\n * retains its original name so that `toString` is not affected, other\n * references to the class are renamed instead.\n */\nfunction replaceClassWithVar(\n path: NodePath<t.ClassDeclaration | t.ClassExpression>,\n): [t.Identifier, NodePath<t.ClassDeclaration | t.ClassExpression>] {\n if (path.type === \"ClassDeclaration\") {\n const varId = path.scope.generateUidIdentifierBasedOnNode(path.node.id);\n const classId = t.identifier(path.node.id.name);\n\n path.scope.rename(classId.name, varId.name);\n\n path.insertBefore(\n t.variableDeclaration(\"let\", [t.variableDeclarator(varId)]),\n );\n path.get(\"id\").replaceWith(classId);\n\n return [t.cloneNode(varId), path];\n } else {\n let className: string;\n let varId: t.Identifier;\n\n if (path.node.id) {\n className = path.node.id.name;\n varId = path.scope.parent.generateDeclaredUidIdentifier(className);\n path.scope.rename(className, varId.name);\n } else if (\n path.parentPath.node.type === \"VariableDeclarator\" &&\n path.parentPath.node.id.type === \"Identifier\"\n ) {\n className = path.parentPath.node.id.name;\n varId = path.scope.parent.generateDeclaredUidIdentifier(className);\n } else {\n varId =\n path.scope.parent.generateDeclaredUidIdentifier(\"decorated_class\");\n }\n\n const newClassExpr = t.classExpression(\n className && t.identifier(className),\n path.node.superClass,\n path.node.body,\n );\n\n const [newPath] = path.replaceWith(\n t.sequenceExpression([newClassExpr, varId]),\n );\n\n return [\n t.cloneNode(varId),\n newPath.get(\"expressions.0\") as NodePath<t.ClassExpression>,\n ];\n }\n}\n\nfunction generateClassProperty(\n key: t.PrivateName | t.Identifier,\n value: t.Expression | undefined,\n isStatic: boolean,\n): t.ClassPrivateProperty | t.ClassProperty {\n if (key.type === \"PrivateName\") {\n return t.classPrivateProperty(key, value, undefined, isStatic);\n } else {\n return t.classProperty(key, value, undefined, undefined, isStatic);\n }\n}\n\nfunction addProxyAccessorsFor(\n element: NodePath<ClassDecoratableElement>,\n originalKey: t.PrivateName | t.Expression,\n targetKey: t.PrivateName,\n isComputed = false,\n): void {\n const { static: isStatic } = element.node;\n\n const getterBody = t.blockStatement([\n t.returnStatement(\n t.memberExpression(t.thisExpression(), t.cloneNode(targetKey)),\n ),\n ]);\n\n const setterBody = t.blockStatement([\n t.expressionStatement(\n t.assignmentExpression(\n \"=\",\n t.memberExpression(t.thisExpression(), t.cloneNode(targetKey)),\n t.identifier(\"v\"),\n ),\n ),\n ]);\n\n let getter: t.ClassMethod | t.ClassPrivateMethod,\n setter: t.ClassMethod | t.ClassPrivateMethod;\n\n if (originalKey.type === \"PrivateName\") {\n getter = t.classPrivateMethod(\n \"get\",\n t.cloneNode(originalKey),\n [],\n getterBody,\n isStatic,\n );\n setter = t.classPrivateMethod(\n \"set\",\n t.cloneNode(originalKey),\n [t.identifier(\"v\")],\n setterBody,\n isStatic,\n );\n } else {\n getter = t.classMethod(\n \"get\",\n t.cloneNode(originalKey),\n [],\n getterBody,\n isComputed,\n isStatic,\n );\n setter = t.classMethod(\n \"set\",\n t.cloneNode(originalKey),\n [t.identifier(\"v\")],\n setterBody,\n isComputed,\n isStatic,\n );\n }\n\n element.insertAfter(setter);\n element.insertAfter(getter);\n}\n\nfunction extractProxyAccessorsFor(\n targetKey: t.PrivateName,\n): t.FunctionExpression[] {\n return [\n t.functionExpression(\n undefined,\n [],\n t.blockStatement([\n t.returnStatement(\n t.memberExpression(t.thisExpression(), t.cloneNode(targetKey)),\n ),\n ]),\n ),\n t.functionExpression(\n undefined,\n [t.identifier(\"value\")],\n t.blockStatement([\n t.expressionStatement(\n t.assignmentExpression(\n \"=\",\n t.memberExpression(t.thisExpression(), t.cloneNode(targetKey)),\n t.identifier(\"value\"),\n ),\n ),\n ]),\n ),\n ];\n}\n\nconst FIELD = 0;\nconst ACCESSOR = 1;\nconst METHOD = 2;\nconst GETTER = 3;\nconst SETTER = 4;\n\nconst STATIC = 5;\n\nfunction getElementKind(element: NodePath<ClassDecoratableElement>): number {\n switch (element.node.type) {\n case \"ClassProperty\":\n case \"ClassPrivateProperty\":\n return FIELD;\n case \"ClassAccessorProperty\":\n return ACCESSOR;\n case \"ClassMethod\":\n case \"ClassPrivateMethod\":\n if (element.node.kind === \"get\") {\n return GETTER;\n } else if (element.node.kind === \"set\") {\n return SETTER;\n } else {\n return METHOD;\n }\n }\n}\n\n// Information about the decorators applied to an element\ninterface DecoratorInfo {\n // The expressions of the decorators themselves\n decorators: t.Expression[];\n\n // The kind of the decorated value, matches the kind value passed to applyDecs\n kind: number;\n\n // whether or not the field is static\n isStatic: boolean;\n\n // The name of the decorator\n name: t.StringLiteral | t.Expression;\n\n privateMethods: t.FunctionExpression | t.FunctionExpression[] | undefined;\n\n // The names of local variables that will be used/returned from the decoration\n locals: t.Identifier | t.Identifier[] | undefined;\n}\n\n// Information about a computed property key. These must be evaluated\n// interspersed with decorator expressions, which is why they get added to the\n// array of DecoratorInfos later on.\ninterface ComputedPropInfo {\n localComputedNameId: t.Identifier;\n keyNode: t.Expression;\n}\n\nfunction isDecoratorInfo(\n info: DecoratorInfo | ComputedPropInfo,\n): info is DecoratorInfo {\n return \"decorators\" in info;\n}\n\nfunction filteredOrderedDecoratorInfo(\n info: (DecoratorInfo | ComputedPropInfo)[],\n): DecoratorInfo[] {\n const filtered = info.filter(isDecoratorInfo);\n\n return [\n ...filtered.filter(\n el => el.isStatic && el.kind >= ACCESSOR && el.kind <= SETTER,\n ),\n ...filtered.filter(\n el => !el.isStatic && el.kind >= ACCESSOR && el.kind <= SETTER,\n ),\n ...filtered.filter(el => el.isStatic && el.kind === FIELD),\n ...filtered.filter(el => !el.isStatic && el.kind === FIELD),\n ];\n}\n\nfunction generateDecorationExprs(\n info: (DecoratorInfo | ComputedPropInfo)[],\n): t.ArrayExpression {\n return t.arrayExpression(\n filteredOrderedDecoratorInfo(info).map(el => {\n const decs =\n el.decorators.length > 1\n ? t.arrayExpression(el.decorators)\n : el.decorators[0];\n\n const kind = el.isStatic ? el.kind + STATIC : el.kind;\n\n const decInfo = [decs, t.numericLiteral(kind), el.name];\n\n const { privateMethods } = el;\n\n if (Array.isArray(privateMethods)) {\n decInfo.push(...privateMethods);\n } else if (privateMethods) {\n decInfo.push(privateMethods);\n }\n\n return t.arrayExpression(decInfo);\n }),\n );\n}\n\nfunction extractElementLocalAssignments(\n decorationInfo: (DecoratorInfo | ComputedPropInfo)[],\n) {\n const localIds: t.Identifier[] = [];\n\n for (const el of filteredOrderedDecoratorInfo(decorationInfo)) {\n const { locals } = el;\n\n if (Array.isArray(locals)) {\n localIds.push(...locals);\n } else if (locals !== undefined) {\n localIds.push(locals);\n }\n }\n\n return localIds;\n}\n\nfunction addCallAccessorsFor(\n element: NodePath,\n key: t.PrivateName,\n getId: t.Identifier,\n setId: t.Identifier,\n) {\n element.insertAfter(\n t.classPrivateMethod(\n \"get\",\n t.cloneNode(key),\n [],\n t.blockStatement([\n t.returnStatement(\n t.callExpression(t.cloneNode(getId), [t.thisExpression()]),\n ),\n ]),\n ),\n );\n\n element.insertAfter(\n t.classPrivateMethod(\n \"set\",\n t.cloneNode(key),\n [t.identifier(\"v\")],\n t.blockStatement([\n t.expressionStatement(\n t.callExpression(t.cloneNode(setId), [\n t.thisExpression(),\n t.identifier(\"v\"),\n ]),\n ),\n ]),\n ),\n );\n}\n\nfunction isNotTsParameter(\n node: t.Identifier | t.Pattern | t.RestElement | t.TSParameterProperty,\n): node is t.Identifier | t.Pattern | t.RestElement {\n return node.type !== \"TSParameterProperty\";\n}\n\nfunction movePrivateAccessor(\n element: NodePath<t.ClassPrivateMethod>,\n key: t.PrivateName,\n methodLocalVar: t.Identifier,\n isStatic: boolean,\n) {\n let params: (t.Identifier | t.RestElement)[];\n let block: t.Statement[];\n\n if (element.node.kind === \"set\") {\n params = [t.identifier(\"v\")];\n block = [\n t.expressionStatement(\n t.callExpression(methodLocalVar, [\n t.thisExpression(),\n t.identifier(\"v\"),\n ]),\n ),\n ];\n } else {\n params = [];\n block = [\n t.returnStatement(t.callExpression(methodLocalVar, [t.thisExpression()])),\n ];\n }\n\n element.replaceWith(\n t.classPrivateMethod(\n element.node.kind,\n t.cloneNode(key),\n params,\n t.blockStatement(block),\n isStatic,\n ),\n );\n}\n\nfunction isClassDecoratableElementPath(\n path: NodePath<ClassElement>,\n): path is NodePath<ClassDecoratableElement> {\n const { type } = path;\n\n return (\n type !== \"TSDeclareMethod\" &&\n type !== \"TSIndexSignature\" &&\n type !== \"StaticBlock\"\n );\n}\n\nfunction staticBlockToIIFE(block: t.StaticBlock) {\n return t.callExpression(\n t.arrowFunctionExpression([], t.blockStatement(block.body)),\n [],\n );\n}\n\nfunction maybeSequenceExpression(exprs: t.Expression[]) {\n if (exprs.length === 0) return t.unaryExpression(\"void\", t.numericLiteral(0));\n if (exprs.length === 1) return exprs[0];\n return t.sequenceExpression(exprs);\n}\n\nfunction transformClass(\n path: NodePath<t.ClassExpression | t.ClassDeclaration>,\n state: PluginPass,\n constantSuper: boolean,\n version: \"2022-03\" | \"2021-12\",\n): NodePath {\n const body = path.get(\"body.body\");\n\n const classDecorators = path.node.decorators;\n let hasElementDecorators = false;\n\n const generateClassPrivateUid = createLazyPrivateUidGeneratorForClass(path);\n\n // Iterate over the class to see if we need to decorate it, and also to\n // transform simple auto accessors which are not decorated\n for (const element of body) {\n if (!isClassDecoratableElementPath(element)) {\n continue;\n }\n\n if (element.node.decorators && element.node.decorators.length > 0) {\n hasElementDecorators = true;\n } else if (element.node.type === \"ClassAccessorProperty\") {\n const { key, value, static: isStatic, computed } = element.node;\n\n const newId = generateClassPrivateUid();\n\n const valueNode = value ? t.cloneNode(value) : undefined;\n\n const newField = generateClassProperty(newId, valueNode, isStatic);\n\n const [newPath] = element.replaceWith(newField);\n addProxyAccessorsFor(newPath, key, newId, computed);\n }\n }\n\n // If nothing is decorated, return\n if (!classDecorators && !hasElementDecorators) return;\n\n const elementDecoratorInfo: (DecoratorInfo | ComputedPropInfo)[] = [];\n\n let firstFieldPath:\n | NodePath<t.ClassProperty | t.ClassPrivateProperty>\n | undefined;\n let constructorPath: NodePath<t.ClassMethod> | undefined;\n let requiresProtoInit = false;\n let requiresStaticInit = false;\n const decoratedPrivateMethods = new Set<string>();\n\n let protoInitLocal: t.Identifier,\n staticInitLocal: t.Identifier,\n classInitLocal: t.Identifier,\n classLocal: t.Identifier;\n const assignments: t.AssignmentExpression[] = [];\n const scopeParent: Scope = path.scope.parent;\n\n const memoiseExpression = (expression: t.Expression, hint: string) => {\n const localEvaluatedId = scopeParent.generateDeclaredUidIdentifier(hint);\n assignments.push(t.assignmentExpression(\"=\", localEvaluatedId, expression));\n return t.cloneNode(localEvaluatedId);\n };\n\n if (classDecorators) {\n classInitLocal = scopeParent.generateDeclaredUidIdentifier(\"initClass\");\n\n const [localId, classPath] = replaceClassWithVar(path);\n path = classPath;\n classLocal = localId;\n\n path.node.decorators = null;\n\n for (const classDecorator of classDecorators) {\n if (!scopeParent.isStatic(classDecorator.expression)) {\n classDecorator.expression = memoiseExpression(\n classDecorator.expression,\n \"dec\",\n );\n }\n }\n } else {\n if (!path.node.id) {\n path.node.id = path.scope.generateUidIdentifier(\"Class\");\n }\n classLocal = t.cloneNode(path.node.id);\n }\n\n if (hasElementDecorators) {\n for (const element of body) {\n if (!isClassDecoratableElementPath(element)) {\n continue;\n }\n\n const { node } = element;\n const decorators = element.get(\"decorators\");\n\n const hasDecorators = Array.isArray(decorators) && decorators.length > 0;\n\n if (hasDecorators) {\n for (const decoratorPath of decorators) {\n if (!scopeParent.isStatic(decoratorPath.node.expression)) {\n decoratorPath.node.expression = memoiseExpression(\n decoratorPath.node.expression,\n \"dec\",\n );\n }\n }\n }\n\n const isComputed =\n \"computed\" in element.node && element.node.computed === true;\n if (isComputed) {\n if (!scopeParent.isStatic(node.key)) {\n node.key = memoiseExpression(node.key as t.Expression, \"computedKey\");\n }\n }\n\n const kind = getElementKind(element);\n const { key } = node;\n\n const isPrivate = key.type === \"PrivateName\";\n\n const isStatic = !!element.node.static;\n\n let name = \"computedKey\";\n\n if (isPrivate) {\n name = (key as t.PrivateName).id.name;\n } else if (!isComputed && key.type === \"Identifier\") {\n name = key.name;\n }\n\n if (element.isClassMethod({ kind: \"constructor\" })) {\n constructorPath = element;\n }\n\n if (hasDecorators) {\n let locals: t.Identifier | t.Identifier[];\n let privateMethods: t.FunctionExpression | t.FunctionExpression[];\n\n if (kind === ACCESSOR) {\n const { value } = element.node as t.ClassAccessorProperty;\n\n const params: t.Expression[] = [t.thisExpression()];\n\n if (value) {\n params.push(t.cloneNode(value));\n }\n\n const newId = generateClassPrivateUid();\n const newFieldInitId =\n element.scope.parent.generateDeclaredUidIdentifier(`init_${name}`);\n const newValue = t.callExpression(\n t.cloneNode(newFieldInitId),\n params,\n );\n\n const newField = generateClassProperty(newId, newValue, isStatic);\n const [newPath] = element.replaceWith(newField);\n\n if (isPrivate) {\n privateMethods = extractProxyAccessorsFor(newId);\n\n const getId = newPath.scope.parent.generateDeclaredUidIdentifier(\n `get_${name}`,\n );\n const setId = newPath.scope.parent.generateDeclaredUidIdentifier(\n `set_${name}`,\n );\n\n addCallAccessorsFor(newPath, key as t.PrivateName, getId, setId);\n\n locals = [newFieldInitId, getId, setId];\n } else {\n addProxyAccessorsFor(newPath, key, newId, isComputed);\n locals = newFieldInitId;\n }\n } else if (kind === FIELD) {\n const initId = element.scope.parent.generateDeclaredUidIdentifier(\n `init_${name}`,\n );\n const valuePath = (\n element as NodePath<t.ClassProperty | t.ClassPrivateProperty>\n ).get(\"value\");\n\n valuePath.replaceWith(\n t.callExpression(\n t.cloneNode(initId),\n [t.thisExpression(), valuePath.node].filter(v => v),\n ),\n );\n\n locals = initId;\n\n if (isPrivate) {\n privateMethods = extractProxyAccessorsFor(key as t.PrivateName);\n }\n } else if (isPrivate) {\n locals = element.scope.parent.generateDeclaredUidIdentifier(\n `call_${name}`,\n ) as t.Identifier;\n\n const replaceSupers = new ReplaceSupers({\n constantSuper,\n methodPath: element as NodePath<t.ClassPrivateMethod>,\n objectRef: classLocal,\n superRef: path.node.superClass,\n file: state.file,\n refToPreserve: classLocal,\n });\n\n replaceSupers.replace();\n\n const {\n params,\n body,\n async: isAsync,\n } = element.node as t.ClassPrivateMethod;\n\n privateMethods = t.functionExpression(\n undefined,\n params.filter(isNotTsParameter),\n body,\n isAsync,\n );\n\n if (kind === GETTER || kind === SETTER) {\n movePrivateAccessor(\n element as NodePath<t.ClassPrivateMethod>,\n t.cloneNode(key as t.PrivateName),\n t.cloneNode(locals),\n isStatic,\n );\n } else {\n const node = element.node as t.ClassPrivateMethod;\n\n // Unshift\n path.node.body.body.unshift(\n t.classPrivateProperty(\n key as t.PrivateName,\n t.cloneNode(locals),\n [],\n node.static,\n ),\n );\n\n decoratedPrivateMethods.add((key as t.PrivateName).id.name);\n\n element.remove();\n }\n }\n\n let nameExpr: t.Expression;\n\n if (isComputed) {\n nameExpr = t.cloneNode(key as t.Expression);\n } else if (key.type === \"PrivateName\") {\n nameExpr = t.stringLiteral(key.id.name);\n } else if (key.type === \"Identifier\") {\n nameExpr = t.stringLiteral(key.name);\n } else {\n nameExpr = t.cloneNode(key as t.Expression);\n }\n\n elementDecoratorInfo.push({\n kind,\n decorators: decorators.map(d => d.node.expression),\n name: nameExpr,\n isStatic,\n privateMethods,\n locals,\n });\n\n if (kind !== FIELD) {\n if (isStatic) {\n requiresStaticInit = true;\n } else {\n requiresProtoInit = true;\n }\n }\n\n if (element.node) {\n element.node.decorators = null;\n }\n\n if (!firstFieldPath && (kind === FIELD || kind === ACCESSOR)) {\n firstFieldPath = element as NodePath<\n t.ClassProperty | t.ClassPrivateProperty\n >;\n }\n }\n }\n }\n\n const elementDecorations = generateDecorationExprs(elementDecoratorInfo);\n const classDecorations = t.arrayExpression(\n (classDecorators || []).map(d => d.expression),\n );\n\n const locals: t.Identifier[] =\n extractElementLocalAssignments(elementDecoratorInfo);\n\n if (requiresProtoInit) {\n protoInitLocal = scopeParent.generateDeclaredUidIdentifier(\"initProto\");\n locals.push(protoInitLocal);\n\n const protoInitCall = t.callExpression(t.cloneNode(protoInitLocal), [\n t.thisExpression(),\n ]);\n\n if (firstFieldPath) {\n const value = firstFieldPath.get(\"value\");\n const body: t.Expression[] = [protoInitCall];\n\n if (value.node) {\n body.push(value.node);\n }\n\n value.replaceWith(t.sequenceExpression(body));\n } else if (constructorPath) {\n if (path.node.superClass) {\n path.traverse({\n CallExpression: {\n exit(path) {\n if (!path.get(\"callee\").isSuper()) return;\n\n path.replaceWith(\n t.callExpression(t.cloneNode(protoInitLocal), [path.node]),\n );\n\n path.skip();\n },\n },\n });\n } else {\n constructorPath.node.body.body.unshift(\n t.expressionStatement(protoInitCall),\n );\n }\n } else {\n const body: t.Statement[] = [t.expressionStatement(protoInitCall)];\n\n if (path.node.superClass) {\n body.unshift(\n t.expressionStatement(\n t.callExpression(t.super(), [\n t.spreadElement(t.identifier(\"args\")),\n ]),\n ),\n );\n }\n\n path.node.body.body.unshift(\n t.classMethod(\n \"constructor\",\n t.identifier(\"constructor\"),\n [t.restElement(t.identifier(\"args\"))],\n t.blockStatement(body),\n ),\n );\n }\n }\n\n if (requiresStaticInit) {\n staticInitLocal = scopeParent.generateDeclaredUidIdentifier(\"initStatic\");\n locals.push(staticInitLocal);\n }\n\n if (decoratedPrivateMethods.size > 0) {\n path.traverse({\n PrivateName(path) {\n if (!decoratedPrivateMethods.has(path.node.id.name)) return;\n\n const parentPath = path.parentPath;\n const parentParentPath = parentPath.parentPath;\n\n if (\n // this.bar().#x = 123;\n (parentParentPath.node.type === \"AssignmentExpression\" &&\n parentParentPath.node.left === parentPath.node) ||\n // this.#x++;\n parentParentPath.node.type === \"UpdateExpression\" ||\n // ([...this.#x] = foo);\n parentParentPath.node.type === \"RestElement\" ||\n // ([this.#x] = foo);\n parentParentPath.node.type === \"ArrayPattern\" ||\n // ({ a: this.#x } = bar);\n (parentParentPath.node.type === \"ObjectProperty\" &&\n parentParentPath.node.value === parentPath.node &&\n parentParentPath.parentPath.type === \"ObjectPattern\") ||\n // for (this.#x of []);\n (parentParentPath.node.type === \"ForOfStatement\" &&\n parentParentPath.node.left === parentPath.node)\n ) {\n throw path.buildCodeFrameError(\n `Decorated private methods are not updatable, but \"#${path.node.id.name}\" is updated via this expression.`,\n );\n }\n },\n });\n }\n\n let classInitInjected = false;\n const classInitCall =\n classInitLocal && t.callExpression(t.cloneNode(classInitLocal), []);\n\n const originalClass = path.node;\n\n if (classDecorators) {\n locals.push(classLocal, classInitLocal);\n const statics: (\n | t.ClassProperty\n | t.ClassPrivateProperty\n | t.ClassPrivateMethod\n )[] = [];\n let staticBlocks: t.StaticBlock[] = [];\n path.get(\"body.body\").forEach(element => {\n // Static blocks cannot be compiled to \"instance blocks\", but we can inline\n // them as IIFEs in the next property.\n if (element.isStaticBlock()) {\n staticBlocks.push(element.node);\n element.remove();\n return;\n }\n\n const isProperty =\n element.isClassProperty() || element.isClassPrivateProperty();\n\n if (\n (isProperty || element.isClassPrivateMethod()) &&\n element.node.static\n ) {\n if (isProperty && staticBlocks.length > 0) {\n const allValues: t.Expression[] = staticBlocks.map(staticBlockToIIFE);\n if (element.node.value) allValues.push(element.node.value);\n element.node.value = maybeSequenceExpression(allValues);\n staticBlocks = [];\n }\n\n element.node.static = false;\n statics.push(element.node);\n element.remove();\n }\n });\n\n if (statics.length > 0 || staticBlocks.length > 0) {\n const staticsClass = template.expression.ast`\n class extends ${state.addHelper(\"identity\")} {}\n ` as t.ClassExpression;\n staticsClass.body.body = [\n t.staticBlock([t.toStatement(path.node, false)]),\n ...statics,\n ];\n\n const constructorBody: t.Expression[] = [];\n\n const newExpr = t.newExpression(staticsClass, []);\n\n if (staticBlocks.length > 0) {\n constructorBody.push(...staticBlocks.map(staticBlockToIIFE));\n }\n if (classInitCall) {\n classInitInjected = true;\n constructorBody.push(classInitCall);\n }\n if (constructorBody.length > 0) {\n constructorBody.unshift(\n t.callExpression(t.super(), [t.cloneNode(classLocal)]),\n );\n\n staticsClass.body.body.push(\n t.classMethod(\n \"constructor\",\n t.identifier(\"constructor\"),\n [],\n t.blockStatement([\n t.expressionStatement(t.sequenceExpression(constructorBody)),\n ]),\n ),\n );\n } else {\n newExpr.arguments.push(t.cloneNode(classLocal));\n }\n\n path.replaceWith(newExpr);\n }\n }\n if (!classInitInjected && classInitCall) {\n path.node.body.body.push(\n t.staticBlock([t.expressionStatement(classInitCall)]),\n );\n }\n\n originalClass.body.body.unshift(\n t.staticBlock(\n [\n t.expressionStatement(\n t.assignmentExpression(\n \"=\",\n t.arrayPattern(locals),\n t.callExpression(\n state.addHelper(\n version === \"2021-12\" ? \"applyDecs\" : \"applyDecs2203\",\n ),\n [t.thisExpression(), elementDecorations, classDecorations],\n ),\n ),\n ),\n requiresStaticInit &&\n t.expressionStatement(\n t.callExpression(t.cloneNode(staticInitLocal), [\n t.thisExpression(),\n ]),\n ),\n ].filter(Boolean),\n ),\n );\n\n // When path is a ClassExpression, path.insertBefore will convert `path`\n // into a SequenceExpression\n path.insertBefore(assignments.map(expr => t.expressionStatement(expr)));\n\n // Recrawl the scope to make sure new identifiers are properly synced\n path.scope.crawl();\n\n return path;\n}\n\nexport default function (\n { assertVersion, assumption }: PluginAPI,\n { loose }: Options,\n version: \"2022-03\" | \"2021-12\",\n): PluginObject {\n assertVersion(version === \"2021-12\" ? \"^7.16.0\" : \"^7.19.0\");\n\n const VISITED = new WeakSet<NodePath>();\n const constantSuper = assumption(\"constantSuper\") ?? loose;\n\n return {\n name: \"proposal-decorators\",\n inherits: syntaxDecorators,\n\n visitor: {\n \"ExportNamedDeclaration|ExportDefaultDeclaration\"(\n path: NodePath<t.ExportNamedDeclaration | t.ExportDefaultDeclaration>,\n ) {\n const { declaration } = path.node;\n if (\n declaration?.type === \"ClassDeclaration\" &&\n // When compiling class decorators we need to replace the class\n // binding, so we must split it in two separate declarations.\n declaration.decorators?.length > 0\n ) {\n splitExportDeclaration(path);\n }\n },\n\n Class(path, state) {\n if (VISITED.has(path)) return;\n\n const newPath = transformClass(path, state, constantSuper, version);\n if (newPath) VISITED.add(newPath);\n },\n },\n };\n}\n"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AAkBA,SAASA,WAAT,CAAqBC,EAArB,EAAmCC,GAAG,GAAGD,EAAE,CAACE,MAAH,GAAY,CAArD,EAA8D;EAE5D,IAAID,GAAG,KAA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currentPrivateId","privateNames","Set","traverse","PrivateName","path","add","node","name","reifiedId","String","fromCharCode","has","t","privateName","identifier","createLazyPrivateUidGeneratorForClass","generator","replaceClassWithVar","type","varId","scope","generateUidIdentifierBasedOnNode","classId","rename","insertBefore","variableDeclaration","variableDeclarator","get","replaceWith","cloneNode","className","parent","generateDeclaredUidIdentifier","parentPath","newClassExpr","classExpression","superClass","body","newPath","sequenceExpression","generateClassProperty","key","value","isStatic","classPrivateProperty","undefined","classProperty","addProxyAccessorsFor","element","originalKey","targetKey","isComputed","static","getterBody","blockStatement","returnStatement","memberExpression","thisExpression","setterBody","expressionStatement","assignmentExpression","getter","setter","classPrivateMethod","classMethod","insertAfter","extractProxyAccessorsFor","functionExpression","FIELD","ACCESSOR","METHOD","GETTER","SETTER","STATIC","getElementKind","kind","isDecoratorInfo","info","filteredOrderedDecoratorInfo","filtered","filter","el","generateDecorationExprs","arrayExpression","map","decs","decorators","decInfo","numericLiteral","privateMethods","Array","isArray","push","extractElementLocalAssignments","decorationInfo","localIds","locals","addCallAccessorsFor","getId","setId","callExpression","isNotTsParameter","movePrivateAccessor","methodLocalVar","params","block","isClassDecoratableElementPath","staticBlockToIIFE","arrowFunctionExpression","maybeSequenceExpression","exprs","unaryExpression","transformClass","state","constantSuper","version","classDecorators","hasElementDecorators","generateClassPrivateUid","computed","newId","valueNode","newField","elementDecoratorInfo","firstFieldPath","constructorPath","requiresProtoInit","requiresStaticInit","decoratedPrivateMethods","protoInitLocal","staticInitLocal","classInitLocal","classLocal","assignments","scopeParent","memoiseExpression","expression","hint","localEvaluatedId","localId","classDecorator","generateUidIdentifier","hasDecorators","decoratorPath","isPrivate","isClassMethod","newFieldInitId","newValue","initId","valuePath","v","replaceSupers","ReplaceSupers","methodPath","objectRef","superRef","file","refToPreserve","replace","async","isAsync","remove","nameExpr","stringLiteral","d","elementDecorations","classDecorations","protoInitCall","CallExpression","exit","isSuper","skip","super","spreadElement","restElement","size","parentParentPath","left","buildCodeFrameError","classInitInjected","classInitCall","originalClass","statics","staticBlocks","forEach","isStaticBlock","isProperty","isClassProperty","isClassPrivateProperty","isClassPrivateMethod","allValues","staticsClass","template","ast","addHelper","staticBlock","toStatement","constructorBody","newExpr","newExpression","arguments","arrayPattern","Boolean","expr","crawl","assertVersion","assumption","loose","VISITED","WeakSet","inherits","syntaxDecorators","visitor","declaration","splitExportDeclaration","Class"],"sources":["../src/transformer-2022-03.ts"],"sourcesContent":["import type { NodePath, Scope } from \"@babel/traverse\";\nimport { types as t, template } from \"@babel/core\";\nimport syntaxDecorators from \"@babel/plugin-syntax-decorators\";\nimport ReplaceSupers from \"@babel/helper-replace-supers\";\nimport splitExportDeclaration from \"@babel/helper-split-export-declaration\";\nimport * as charCodes from \"charcodes\";\nimport type { PluginAPI, PluginObject, PluginPass } from \"@babel/core\";\nimport type { Options } from \"./index\";\n\ntype ClassDecoratableElement =\n | t.ClassMethod\n | t.ClassPrivateMethod\n | t.ClassProperty\n | t.ClassPrivateProperty\n | t.ClassAccessorProperty;\n\ntype ClassElement =\n | ClassDecoratableElement\n | t.TSDeclareMethod\n | t.TSIndexSignature\n | t.StaticBlock;\n\nfunction incrementId(id: number[], idx = id.length - 1): void {\n // If index is -1, id needs an additional character, unshift A\n if (idx === -1) {\n id.unshift(charCodes.uppercaseA);\n return;\n }\n\n const current = id[idx];\n\n if (current === charCodes.uppercaseZ) {\n // if current is Z, skip to a\n id[idx] = charCodes.lowercaseA;\n } else if (current === charCodes.lowercaseZ) {\n // if current is z, reset to A and carry the 1\n id[idx] = charCodes.uppercaseA;\n incrementId(id, idx - 1);\n } else {\n // else, increment by one\n id[idx] = current + 1;\n }\n}\n\n/**\n * Generates a new private name that is unique to the given class. This can be\n * used to create extra class fields and methods for the implementation, while\n * keeping the length of those names as small as possible. This is important for\n * minification purposes (though private names can generally be minified,\n * transpilations and polyfills cannot yet).\n */\nfunction createPrivateUidGeneratorForClass(\n classPath: NodePath<t.ClassDeclaration | t.ClassExpression>,\n): () => t.PrivateName {\n const currentPrivateId: number[] = [];\n const privateNames = new Set<string>();\n\n classPath.traverse({\n PrivateName(path) {\n privateNames.add(path.node.id.name);\n },\n });\n\n return (): t.PrivateName => {\n let reifiedId;\n do {\n incrementId(currentPrivateId);\n reifiedId = String.fromCharCode(...currentPrivateId);\n } while (privateNames.has(reifiedId));\n\n return t.privateName(t.identifier(reifiedId));\n };\n}\n\n/**\n * Wraps the above generator function so that it's run lazily the first time\n * it's actually required. Several types of decoration do not require this, so it\n * saves iterating the class elements an additional time and allocating the space\n * for the Sets of element names.\n */\nfunction createLazyPrivateUidGeneratorForClass(\n classPath: NodePath<t.ClassDeclaration | t.ClassExpression>,\n): () => t.PrivateName {\n let generator: () => t.PrivateName;\n\n return (): t.PrivateName => {\n if (!generator) {\n generator = createPrivateUidGeneratorForClass(classPath);\n }\n\n return generator();\n };\n}\n\n/**\n * Takes a class definition and replaces it with an equivalent class declaration\n * which is then assigned to a local variable. This allows us to reassign the\n * local variable with the decorated version of the class. The class definition\n * retains its original name so that `toString` is not affected, other\n * references to the class are renamed instead.\n */\nfunction replaceClassWithVar(\n path: NodePath<t.ClassDeclaration | t.ClassExpression>,\n): [t.Identifier, NodePath<t.ClassDeclaration | t.ClassExpression>] {\n if (path.type === \"ClassDeclaration\") {\n const varId = path.scope.generateUidIdentifierBasedOnNode(path.node.id);\n const classId = t.identifier(path.node.id.name);\n\n path.scope.rename(classId.name, varId.name);\n\n path.insertBefore(\n t.variableDeclaration(\"let\", [t.variableDeclarator(varId)]),\n );\n path.get(\"id\").replaceWith(classId);\n\n return [t.cloneNode(varId), path];\n } else {\n let className: string;\n let varId: t.Identifier;\n\n if (path.node.id) {\n className = path.node.id.name;\n varId = path.scope.parent.generateDeclaredUidIdentifier(className);\n path.scope.rename(className, varId.name);\n } else if (\n path.parentPath.node.type === \"VariableDeclarator\" &&\n path.parentPath.node.id.type === \"Identifier\"\n ) {\n className = path.parentPath.node.id.name;\n varId = path.scope.parent.generateDeclaredUidIdentifier(className);\n } else {\n varId =\n path.scope.parent.generateDeclaredUidIdentifier(\"decorated_class\");\n }\n\n const newClassExpr = t.classExpression(\n className && t.identifier(className),\n path.node.superClass,\n path.node.body,\n );\n\n const [newPath] = path.replaceWith(\n t.sequenceExpression([newClassExpr, varId]),\n );\n\n return [\n t.cloneNode(varId),\n newPath.get(\"expressions.0\") as NodePath<t.ClassExpression>,\n ];\n }\n}\n\nfunction generateClassProperty(\n key: t.PrivateName | t.Identifier,\n value: t.Expression | undefined,\n isStatic: boolean,\n): t.ClassPrivateProperty | t.ClassProperty {\n if (key.type === \"PrivateName\") {\n return t.classPrivateProperty(key, value, undefined, isStatic);\n } else {\n return t.classProperty(key, value, undefined, undefined, isStatic);\n }\n}\n\nfunction addProxyAccessorsFor(\n element: NodePath<ClassDecoratableElement>,\n originalKey: t.PrivateName | t.Expression,\n targetKey: t.PrivateName,\n isComputed = false,\n): void {\n const { static: isStatic } = element.node;\n\n const getterBody = t.blockStatement([\n t.returnStatement(\n t.memberExpression(t.thisExpression(), t.cloneNode(targetKey)),\n ),\n ]);\n\n const setterBody = t.blockStatement([\n t.expressionStatement(\n t.assignmentExpression(\n \"=\",\n t.memberExpression(t.thisExpression(), t.cloneNode(targetKey)),\n t.identifier(\"v\"),\n ),\n ),\n ]);\n\n let getter: t.ClassMethod | t.ClassPrivateMethod,\n setter: t.ClassMethod | t.ClassPrivateMethod;\n\n if (originalKey.type === \"PrivateName\") {\n getter = t.classPrivateMethod(\n \"get\",\n t.cloneNode(originalKey),\n [],\n getterBody,\n isStatic,\n );\n setter = t.classPrivateMethod(\n \"set\",\n t.cloneNode(originalKey),\n [t.identifier(\"v\")],\n setterBody,\n isStatic,\n );\n } else {\n getter = t.classMethod(\n \"get\",\n t.cloneNode(originalKey),\n [],\n getterBody,\n isComputed,\n isStatic,\n );\n setter = t.classMethod(\n \"set\",\n t.cloneNode(originalKey),\n [t.identifier(\"v\")],\n setterBody,\n isComputed,\n isStatic,\n );\n }\n\n element.insertAfter(setter);\n element.insertAfter(getter);\n}\n\nfunction extractProxyAccessorsFor(\n targetKey: t.PrivateName,\n): t.FunctionExpression[] {\n return [\n t.functionExpression(\n undefined,\n [],\n t.blockStatement([\n t.returnStatement(\n t.memberExpression(t.thisExpression(), t.cloneNode(targetKey)),\n ),\n ]),\n ),\n t.functionExpression(\n undefined,\n [t.identifier(\"value\")],\n t.blockStatement([\n t.expressionStatement(\n t.assignmentExpression(\n \"=\",\n t.memberExpression(t.thisExpression(), t.cloneNode(targetKey)),\n t.identifier(\"value\"),\n ),\n ),\n ]),\n ),\n ];\n}\n\nconst FIELD = 0;\nconst ACCESSOR = 1;\nconst METHOD = 2;\nconst GETTER = 3;\nconst SETTER = 4;\n\nconst STATIC = 5;\n\nfunction getElementKind(element: NodePath<ClassDecoratableElement>): number {\n switch (element.node.type) {\n case \"ClassProperty\":\n case \"ClassPrivateProperty\":\n return FIELD;\n case \"ClassAccessorProperty\":\n return ACCESSOR;\n case \"ClassMethod\":\n case \"ClassPrivateMethod\":\n if (element.node.kind === \"get\") {\n return GETTER;\n } else if (element.node.kind === \"set\") {\n return SETTER;\n } else {\n return METHOD;\n }\n }\n}\n\n// Information about the decorators applied to an element\ninterface DecoratorInfo {\n // The expressions of the decorators themselves\n decorators: t.Expression[];\n\n // The kind of the decorated value, matches the kind value passed to applyDecs\n kind: number;\n\n // whether or not the field is static\n isStatic: boolean;\n\n // The name of the decorator\n name: t.StringLiteral | t.Expression;\n\n privateMethods: t.FunctionExpression | t.FunctionExpression[] | undefined;\n\n // The names of local variables that will be used/returned from the decoration\n locals: t.Identifier | t.Identifier[] | undefined;\n}\n\n// Information about a computed property key. These must be evaluated\n// interspersed with decorator expressions, which is why they get added to the\n// array of DecoratorInfos later on.\ninterface ComputedPropInfo {\n localComputedNameId: t.Identifier;\n keyNode: t.Expression;\n}\n\nfunction isDecoratorInfo(\n info: DecoratorInfo | ComputedPropInfo,\n): info is DecoratorInfo {\n return \"decorators\" in info;\n}\n\nfunction filteredOrderedDecoratorInfo(\n info: (DecoratorInfo | ComputedPropInfo)[],\n): DecoratorInfo[] {\n const filtered = info.filter(isDecoratorInfo);\n\n return [\n ...filtered.filter(\n el => el.isStatic && el.kind >= ACCESSOR && el.kind <= SETTER,\n ),\n ...filtered.filter(\n el => !el.isStatic && el.kind >= ACCESSOR && el.kind <= SETTER,\n ),\n ...filtered.filter(el => el.isStatic && el.kind === FIELD),\n ...filtered.filter(el => !el.isStatic && el.kind === FIELD),\n ];\n}\n\nfunction generateDecorationExprs(\n info: (DecoratorInfo | ComputedPropInfo)[],\n): t.ArrayExpression {\n return t.arrayExpression(\n filteredOrderedDecoratorInfo(info).map(el => {\n const decs =\n el.decorators.length > 1\n ? t.arrayExpression(el.decorators)\n : el.decorators[0];\n\n const kind = el.isStatic ? el.kind + STATIC : el.kind;\n\n const decInfo = [decs, t.numericLiteral(kind), el.name];\n\n const { privateMethods } = el;\n\n if (Array.isArray(privateMethods)) {\n decInfo.push(...privateMethods);\n } else if (privateMethods) {\n decInfo.push(privateMethods);\n }\n\n return t.arrayExpression(decInfo);\n }),\n );\n}\n\nfunction extractElementLocalAssignments(\n decorationInfo: (DecoratorInfo | ComputedPropInfo)[],\n) {\n const localIds: t.Identifier[] = [];\n\n for (const el of filteredOrderedDecoratorInfo(decorationInfo)) {\n const { locals } = el;\n\n if (Array.isArray(locals)) {\n localIds.push(...locals);\n } else if (locals !== undefined) {\n localIds.push(locals);\n }\n }\n\n return localIds;\n}\n\nfunction addCallAccessorsFor(\n element: NodePath,\n key: t.PrivateName,\n getId: t.Identifier,\n setId: t.Identifier,\n) {\n element.insertAfter(\n t.classPrivateMethod(\n \"get\",\n t.cloneNode(key),\n [],\n t.blockStatement([\n t.returnStatement(\n t.callExpression(t.cloneNode(getId), [t.thisExpression()]),\n ),\n ]),\n ),\n );\n\n element.insertAfter(\n t.classPrivateMethod(\n \"set\",\n t.cloneNode(key),\n [t.identifier(\"v\")],\n t.blockStatement([\n t.expressionStatement(\n t.callExpression(t.cloneNode(setId), [\n t.thisExpression(),\n t.identifier(\"v\"),\n ]),\n ),\n ]),\n ),\n );\n}\n\nfunction isNotTsParameter(\n node: t.Identifier | t.Pattern | t.RestElement | t.TSParameterProperty,\n): node is t.Identifier | t.Pattern | t.RestElement {\n return node.type !== \"TSParameterProperty\";\n}\n\nfunction movePrivateAccessor(\n element: NodePath<t.ClassPrivateMethod>,\n key: t.PrivateName,\n methodLocalVar: t.Identifier,\n isStatic: boolean,\n) {\n let params: (t.Identifier | t.RestElement)[];\n let block: t.Statement[];\n\n if (element.node.kind === \"set\") {\n params = [t.identifier(\"v\")];\n block = [\n t.expressionStatement(\n t.callExpression(methodLocalVar, [\n t.thisExpression(),\n t.identifier(\"v\"),\n ]),\n ),\n ];\n } else {\n params = [];\n block = [\n t.returnStatement(t.callExpression(methodLocalVar, [t.thisExpression()])),\n ];\n }\n\n element.replaceWith(\n t.classPrivateMethod(\n element.node.kind,\n t.cloneNode(key),\n params,\n t.blockStatement(block),\n isStatic,\n ),\n );\n}\n\nfunction isClassDecoratableElementPath(\n path: NodePath<ClassElement>,\n): path is NodePath<ClassDecoratableElement> {\n const { type } = path;\n\n return (\n type !== \"TSDeclareMethod\" &&\n type !== \"TSIndexSignature\" &&\n type !== \"StaticBlock\"\n );\n}\n\nfunction staticBlockToIIFE(block: t.StaticBlock) {\n return t.callExpression(\n t.arrowFunctionExpression([], t.blockStatement(block.body)),\n [],\n );\n}\n\nfunction maybeSequenceExpression(exprs: t.Expression[]) {\n if (exprs.length === 0) return t.unaryExpression(\"void\", t.numericLiteral(0));\n if (exprs.length === 1) return exprs[0];\n return t.sequenceExpression(exprs);\n}\n\nfunction transformClass(\n path: NodePath<t.ClassExpression | t.ClassDeclaration>,\n state: PluginPass,\n constantSuper: boolean,\n version: \"2022-03\" | \"2021-12\",\n): NodePath {\n const body = path.get(\"body.body\");\n\n const classDecorators = path.node.decorators;\n let hasElementDecorators = false;\n\n const generateClassPrivateUid = createLazyPrivateUidGeneratorForClass(path);\n\n // Iterate over the class to see if we need to decorate it, and also to\n // transform simple auto accessors which are not decorated\n for (const element of body) {\n if (!isClassDecoratableElementPath(element)) {\n continue;\n }\n\n if (element.node.decorators && element.node.decorators.length > 0) {\n hasElementDecorators = true;\n } else if (element.node.type === \"ClassAccessorProperty\") {\n const { key, value, static: isStatic, computed } = element.node;\n\n const newId = generateClassPrivateUid();\n\n const valueNode = value ? t.cloneNode(value) : undefined;\n\n const newField = generateClassProperty(newId, valueNode, isStatic);\n\n const [newPath] = element.replaceWith(newField);\n addProxyAccessorsFor(newPath, key, newId, computed);\n }\n }\n\n // If nothing is decorated, return\n if (!classDecorators && !hasElementDecorators) return;\n\n const elementDecoratorInfo: (DecoratorInfo | ComputedPropInfo)[] = [];\n\n // The initializer of the first non-static field will be injected with the protoInit call\n let firstFieldPath:\n | NodePath<t.ClassProperty | t.ClassPrivateProperty>\n | undefined;\n let constructorPath: NodePath<t.ClassMethod> | undefined;\n let requiresProtoInit = false;\n let requiresStaticInit = false;\n const decoratedPrivateMethods = new Set<string>();\n\n let protoInitLocal: t.Identifier,\n staticInitLocal: t.Identifier,\n classInitLocal: t.Identifier,\n classLocal: t.Identifier;\n const assignments: t.AssignmentExpression[] = [];\n const scopeParent: Scope = path.scope.parent;\n\n const memoiseExpression = (expression: t.Expression, hint: string) => {\n const localEvaluatedId = scopeParent.generateDeclaredUidIdentifier(hint);\n assignments.push(t.assignmentExpression(\"=\", localEvaluatedId, expression));\n return t.cloneNode(localEvaluatedId);\n };\n\n if (classDecorators) {\n classInitLocal = scopeParent.generateDeclaredUidIdentifier(\"initClass\");\n\n const [localId, classPath] = replaceClassWithVar(path);\n path = classPath;\n classLocal = localId;\n\n path.node.decorators = null;\n\n for (const classDecorator of classDecorators) {\n if (!scopeParent.isStatic(classDecorator.expression)) {\n classDecorator.expression = memoiseExpression(\n classDecorator.expression,\n \"dec\",\n );\n }\n }\n } else {\n if (!path.node.id) {\n path.node.id = path.scope.generateUidIdentifier(\"Class\");\n }\n classLocal = t.cloneNode(path.node.id);\n }\n\n if (hasElementDecorators) {\n for (const element of body) {\n if (!isClassDecoratableElementPath(element)) {\n continue;\n }\n\n const { node } = element;\n const decorators = element.get(\"decorators\");\n\n const hasDecorators = Array.isArray(decorators) && decorators.length > 0;\n\n if (hasDecorators) {\n for (const decoratorPath of decorators) {\n if (!scopeParent.isStatic(decoratorPath.node.expression)) {\n decoratorPath.node.expression = memoiseExpression(\n decoratorPath.node.expression,\n \"dec\",\n );\n }\n }\n }\n\n const isComputed =\n \"computed\" in element.node && element.node.computed === true;\n if (isComputed) {\n if (!scopeParent.isStatic(node.key)) {\n node.key = memoiseExpression(node.key as t.Expression, \"computedKey\");\n }\n }\n\n const kind = getElementKind(element);\n const { key } = node;\n\n const isPrivate = key.type === \"PrivateName\";\n\n const isStatic = !!element.node.static;\n\n let name = \"computedKey\";\n\n if (isPrivate) {\n name = (key as t.PrivateName).id.name;\n } else if (!isComputed && key.type === \"Identifier\") {\n name = key.name;\n }\n\n if (element.isClassMethod({ kind: \"constructor\" })) {\n constructorPath = element;\n }\n\n if (hasDecorators) {\n let locals: t.Identifier | t.Identifier[];\n let privateMethods: t.FunctionExpression | t.FunctionExpression[];\n\n if (kind === ACCESSOR) {\n const { value } = element.node as t.ClassAccessorProperty;\n\n const params: t.Expression[] = [t.thisExpression()];\n\n if (value) {\n params.push(t.cloneNode(value));\n }\n\n const newId = generateClassPrivateUid();\n const newFieldInitId =\n element.scope.parent.generateDeclaredUidIdentifier(`init_${name}`);\n const newValue = t.callExpression(\n t.cloneNode(newFieldInitId),\n params,\n );\n\n const newField = generateClassProperty(newId, newValue, isStatic);\n const [newPath] = element.replaceWith(newField);\n\n if (isPrivate) {\n privateMethods = extractProxyAccessorsFor(newId);\n\n const getId = newPath.scope.parent.generateDeclaredUidIdentifier(\n `get_${name}`,\n );\n const setId = newPath.scope.parent.generateDeclaredUidIdentifier(\n `set_${name}`,\n );\n\n addCallAccessorsFor(newPath, key as t.PrivateName, getId, setId);\n\n locals = [newFieldInitId, getId, setId];\n } else {\n addProxyAccessorsFor(newPath, key, newId, isComputed);\n locals = newFieldInitId;\n }\n } else if (kind === FIELD) {\n const initId = element.scope.parent.generateDeclaredUidIdentifier(\n `init_${name}`,\n );\n const valuePath = (\n element as NodePath<t.ClassProperty | t.ClassPrivateProperty>\n ).get(\"value\");\n\n valuePath.replaceWith(\n t.callExpression(\n t.cloneNode(initId),\n [t.thisExpression(), valuePath.node].filter(v => v),\n ),\n );\n\n locals = initId;\n\n if (isPrivate) {\n privateMethods = extractProxyAccessorsFor(key as t.PrivateName);\n }\n } else if (isPrivate) {\n locals = element.scope.parent.generateDeclaredUidIdentifier(\n `call_${name}`,\n ) as t.Identifier;\n\n const replaceSupers = new ReplaceSupers({\n constantSuper,\n methodPath: element as NodePath<t.ClassPrivateMethod>,\n objectRef: classLocal,\n superRef: path.node.superClass,\n file: state.file,\n refToPreserve: classLocal,\n });\n\n replaceSupers.replace();\n\n const {\n params,\n body,\n async: isAsync,\n } = element.node as t.ClassPrivateMethod;\n\n privateMethods = t.functionExpression(\n undefined,\n params.filter(isNotTsParameter),\n body,\n isAsync,\n );\n\n if (kind === GETTER || kind === SETTER) {\n movePrivateAccessor(\n element as NodePath<t.ClassPrivateMethod>,\n t.cloneNode(key as t.PrivateName),\n t.cloneNode(locals),\n isStatic,\n );\n } else {\n const node = element.node as t.ClassPrivateMethod;\n\n // Unshift\n path.node.body.body.unshift(\n t.classPrivateProperty(\n key as t.PrivateName,\n t.cloneNode(locals),\n [],\n node.static,\n ),\n );\n\n decoratedPrivateMethods.add((key as t.PrivateName).id.name);\n\n element.remove();\n }\n }\n\n let nameExpr: t.Expression;\n\n if (isComputed) {\n nameExpr = t.cloneNode(key as t.Expression);\n } else if (key.type === \"PrivateName\") {\n nameExpr = t.stringLiteral(key.id.name);\n } else if (key.type === \"Identifier\") {\n nameExpr = t.stringLiteral(key.name);\n } else {\n nameExpr = t.cloneNode(key as t.Expression);\n }\n\n elementDecoratorInfo.push({\n kind,\n decorators: decorators.map(d => d.node.expression),\n name: nameExpr,\n isStatic,\n privateMethods,\n locals,\n });\n\n if (kind !== FIELD) {\n if (isStatic) {\n requiresStaticInit = true;\n } else {\n requiresProtoInit = true;\n }\n }\n\n if (element.node) {\n element.node.decorators = null;\n }\n\n if (\n !firstFieldPath &&\n !isStatic &&\n (kind === FIELD || kind === ACCESSOR)\n ) {\n firstFieldPath = element as NodePath<\n t.ClassProperty | t.ClassPrivateProperty\n >;\n }\n }\n }\n }\n\n const elementDecorations = generateDecorationExprs(elementDecoratorInfo);\n const classDecorations = t.arrayExpression(\n (classDecorators || []).map(d => d.expression),\n );\n\n const locals: t.Identifier[] =\n extractElementLocalAssignments(elementDecoratorInfo);\n\n if (requiresProtoInit) {\n protoInitLocal = scopeParent.generateDeclaredUidIdentifier(\"initProto\");\n locals.push(protoInitLocal);\n\n const protoInitCall = t.callExpression(t.cloneNode(protoInitLocal), [\n t.thisExpression(),\n ]);\n\n if (firstFieldPath) {\n const value = firstFieldPath.get(\"value\");\n const body: t.Expression[] = [protoInitCall];\n\n if (value.node) {\n body.push(value.node);\n }\n\n value.replaceWith(t.sequenceExpression(body));\n } else if (constructorPath) {\n if (path.node.superClass) {\n path.traverse({\n CallExpression: {\n exit(path) {\n if (!path.get(\"callee\").isSuper()) return;\n\n path.replaceWith(\n t.callExpression(t.cloneNode(protoInitLocal), [path.node]),\n );\n\n path.skip();\n },\n },\n });\n } else {\n constructorPath.node.body.body.unshift(\n t.expressionStatement(protoInitCall),\n );\n }\n } else {\n const body: t.Statement[] = [t.expressionStatement(protoInitCall)];\n\n if (path.node.superClass) {\n body.unshift(\n t.expressionStatement(\n t.callExpression(t.super(), [\n t.spreadElement(t.identifier(\"args\")),\n ]),\n ),\n );\n }\n\n path.node.body.body.unshift(\n t.classMethod(\n \"constructor\",\n t.identifier(\"constructor\"),\n [t.restElement(t.identifier(\"args\"))],\n t.blockStatement(body),\n ),\n );\n }\n }\n\n if (requiresStaticInit) {\n staticInitLocal = scopeParent.generateDeclaredUidIdentifier(\"initStatic\");\n locals.push(staticInitLocal);\n }\n\n if (decoratedPrivateMethods.size > 0) {\n path.traverse({\n PrivateName(path) {\n if (!decoratedPrivateMethods.has(path.node.id.name)) return;\n\n const parentPath = path.parentPath;\n const parentParentPath = parentPath.parentPath;\n\n if (\n // this.bar().#x = 123;\n (parentParentPath.node.type === \"AssignmentExpression\" &&\n parentParentPath.node.left === parentPath.node) ||\n // this.#x++;\n parentParentPath.node.type === \"UpdateExpression\" ||\n // ([...this.#x] = foo);\n parentParentPath.node.type === \"RestElement\" ||\n // ([this.#x] = foo);\n parentParentPath.node.type === \"ArrayPattern\" ||\n // ({ a: this.#x } = bar);\n (parentParentPath.node.type === \"ObjectProperty\" &&\n parentParentPath.node.value === parentPath.node &&\n parentParentPath.parentPath.type === \"ObjectPattern\") ||\n // for (this.#x of []);\n (parentParentPath.node.type === \"ForOfStatement\" &&\n parentParentPath.node.left === parentPath.node)\n ) {\n throw path.buildCodeFrameError(\n `Decorated private methods are not updatable, but \"#${path.node.id.name}\" is updated via this expression.`,\n );\n }\n },\n });\n }\n\n let classInitInjected = false;\n const classInitCall =\n classInitLocal && t.callExpression(t.cloneNode(classInitLocal), []);\n\n const originalClass = path.node;\n\n if (classDecorators) {\n locals.push(classLocal, classInitLocal);\n const statics: (\n | t.ClassProperty\n | t.ClassPrivateProperty\n | t.ClassPrivateMethod\n )[] = [];\n let staticBlocks: t.StaticBlock[] = [];\n path.get(\"body.body\").forEach(element => {\n // Static blocks cannot be compiled to \"instance blocks\", but we can inline\n // them as IIFEs in the next property.\n if (element.isStaticBlock()) {\n staticBlocks.push(element.node);\n element.remove();\n return;\n }\n\n const isProperty =\n element.isClassProperty() || element.isClassPrivateProperty();\n\n if (\n (isProperty || element.isClassPrivateMethod()) &&\n element.node.static\n ) {\n if (isProperty && staticBlocks.length > 0) {\n const allValues: t.Expression[] = staticBlocks.map(staticBlockToIIFE);\n if (element.node.value) allValues.push(element.node.value);\n element.node.value = maybeSequenceExpression(allValues);\n staticBlocks = [];\n }\n\n element.node.static = false;\n statics.push(element.node);\n element.remove();\n }\n });\n\n if (statics.length > 0 || staticBlocks.length > 0) {\n const staticsClass = template.expression.ast`\n class extends ${state.addHelper(\"identity\")} {}\n ` as t.ClassExpression;\n staticsClass.body.body = [\n t.staticBlock([t.toStatement(path.node, false)]),\n ...statics,\n ];\n\n const constructorBody: t.Expression[] = [];\n\n const newExpr = t.newExpression(staticsClass, []);\n\n if (staticBlocks.length > 0) {\n constructorBody.push(...staticBlocks.map(staticBlockToIIFE));\n }\n if (classInitCall) {\n classInitInjected = true;\n constructorBody.push(classInitCall);\n }\n if (constructorBody.length > 0) {\n constructorBody.unshift(\n t.callExpression(t.super(), [t.cloneNode(classLocal)]),\n );\n\n staticsClass.body.body.push(\n t.classMethod(\n \"constructor\",\n t.identifier(\"constructor\"),\n [],\n t.blockStatement([\n t.expressionStatement(t.sequenceExpression(constructorBody)),\n ]),\n ),\n );\n } else {\n newExpr.arguments.push(t.cloneNode(classLocal));\n }\n\n path.replaceWith(newExpr);\n }\n }\n if (!classInitInjected && classInitCall) {\n path.node.body.body.push(\n t.staticBlock([t.expressionStatement(classInitCall)]),\n );\n }\n\n originalClass.body.body.unshift(\n t.staticBlock(\n [\n t.expressionStatement(\n t.assignmentExpression(\n \"=\",\n t.arrayPattern(locals),\n t.callExpression(\n state.addHelper(\n version === \"2021-12\" ? \"applyDecs\" : \"applyDecs2203\",\n ),\n [t.thisExpression(), elementDecorations, classDecorations],\n ),\n ),\n ),\n requiresStaticInit &&\n t.expressionStatement(\n t.callExpression(t.cloneNode(staticInitLocal), [\n t.thisExpression(),\n ]),\n ),\n ].filter(Boolean),\n ),\n );\n\n // When path is a ClassExpression, path.insertBefore will convert `path`\n // into a SequenceExpression\n path.insertBefore(assignments.map(expr => t.expressionStatement(expr)));\n\n // Recrawl the scope to make sure new identifiers are properly synced\n path.scope.crawl();\n\n return path;\n}\n\nexport default function (\n { assertVersion, assumption }: PluginAPI,\n { loose }: Options,\n version: \"2022-03\" | \"2021-12\",\n): PluginObject {\n assertVersion(version === \"2021-12\" ? \"^7.16.0\" : \"^7.19.0\");\n\n const VISITED = new WeakSet<NodePath>();\n const constantSuper = assumption(\"constantSuper\") ?? loose;\n\n return {\n name: \"proposal-decorators\",\n inherits: syntaxDecorators,\n\n visitor: {\n \"ExportNamedDeclaration|ExportDefaultDeclaration\"(\n path: NodePath<t.ExportNamedDeclaration | t.ExportDefaultDeclaration>,\n ) {\n const { declaration } = path.node;\n if (\n declaration?.type === \"ClassDeclaration\" &&\n // When compiling class decorators we need to replace the class\n // binding, so we must split it in two separate declarations.\n declaration.decorators?.length > 0\n ) {\n splitExportDeclaration(path);\n }\n },\n\n Class(path, state) {\n if (VISITED.has(path)) return;\n\n const newPath = transformClass(path, state, constantSuper, version);\n if (newPath) VISITED.add(newPath);\n },\n },\n };\n}\n"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AAkBA,SAASA,WAAT,CAAqBC,EAArB,EAAmCC,GAAG,GAAGD,EAAE,CAACE,MAAH,GAAY,CAArD,EAA8D;EAE5D,IAAID,GAAG,KAAK,CAAC,CAAb,EAAgB;IACdD,EAAE,CAACG,OAAH;IACA;EACD;;EAED,MAAMC,OAAO,GAAGJ,EAAE,CAACC,GAAD,CAAlB;;EAEA,IAAIG,OAAO,OAAX,EAAsC;IAEpCJ,EAAE,CAACC,GAAD,CAAF;EACD,CAHD,MAGO,IAAIG,OAAO,QAAX,EAAsC;IAE3CJ,EAAE,CAACC,GAAD,CAAF;IACAF,WAAW,CAACC,EAAD,EAAKC,GAAG,GAAG,CAAX,CAAX;EACD,CAJM,MAIA;IAELD,EAAE,CAACC,GAAD,CAAF,GAAUG,OAAO,GAAG,CAApB;EACD;AACF;;AASD,SAASC,iCAAT,CACEC,SADF,EAEuB;EACrB,MAAMC,gBAA0B,GAAG,EAAnC;EACA,MAAMC,YAAY,GAAG,IAAIC,GAAJ,EAArB;EAEAH,SAA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ADD;IAEL2M,QAAQ,EAAEC,+BAFL;IAILC,OAAO,EAAE;MACP,kDACEhN,IADF,EAEE;QAAA;;QACA,MAAM;UAAEiN;QAAF,IAAkBjN,IAAI,CAACE,IAA7B;;QACA,IACE,CAAA+M,WAAW,QAAX,YAAAA,WAAW,CAAEnM,IAAb,MAAsB,kBAAtB,IAGA,0BAAAmM,WAAW,CAAC/H,UAAZ,2CAAwB5F,MAAxB,IAAiC,CAJnC,EAKE;UACA,IAAA4N,qCAAA,EAAuBlN,IAAvB;QACD;MACF,CAbM;;MAePmN,KAAK,CAACnN,IAAD,EAAO6G,KAAP,EAAc;QACjB,IAAI+F,OAAO,CAACrM,GAAR,CAAYP,IAAZ,CAAJ,EAAuB;QAEvB,MAAMkC,OAAO,GAAG0E,cAAc,CAAC5G,IAAD,EAAO6G,KAAP,EAAcC,aAAd,EAA6BC,OAA7B,CAA9B;QACA,IAAI7E,OAAJ,EAAa0K,OAAO,CAAC3M,GAAR,CAAYiC,OAAZ;MACd;;IApBM;EAJJ,CAAP;AA2BD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@babel/plugin-proposal-decorators",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.20.0",
|
|
4
4
|
"author": "The Babel Team (https://babel.dev/team)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"@babel/core": "^7.0.0-0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@babel/core": "^7.19.
|
|
33
|
+
"@babel/core": "^7.19.6",
|
|
34
34
|
"@babel/helper-plugin-test-runner": "^7.18.6",
|
|
35
|
-
"@babel/traverse": "^7.
|
|
35
|
+
"@babel/traverse": "^7.20.0",
|
|
36
36
|
"@types/charcodes": "^0.2.0",
|
|
37
37
|
"array.prototype.concat": "^1.0.2",
|
|
38
38
|
"babel-plugin-polyfill-es-shims": "^0.7.1",
|
package/CONTRIB.md
DELETED
|
@@ -1,396 +0,0 @@
|
|
|
1
|
-
These are notes about the implementation of the 2021-12 decorators transform.
|
|
2
|
-
The implementation's goals are (in descending order):
|
|
3
|
-
|
|
4
|
-
1. Being accurate to the actual proposal (e.g. not defining additional
|
|
5
|
-
properties unless required, matching semantics exactly, etc.). This includes
|
|
6
|
-
being able to work properly with private fields and methods.
|
|
7
|
-
2. Transpiling to a very minimal and minifiable output. This transform will
|
|
8
|
-
affect each and every decorated class, so ensuring that the output is not 10x
|
|
9
|
-
the size of the original is important.
|
|
10
|
-
3. Having good runtime performance. Decoration output has the potential to
|
|
11
|
-
drastically impact startup performance, since it runs whenever a decorated
|
|
12
|
-
class is defined. In addition, every instance of a decorated class may be
|
|
13
|
-
impacted for certain types of decorators.
|
|
14
|
-
|
|
15
|
-
All of these goals come somewhat at the expense of readability and can make the
|
|
16
|
-
implementation difficult to understand, so these notes are meant to document the
|
|
17
|
-
motivations behind the design.
|
|
18
|
-
|
|
19
|
-
## Overview
|
|
20
|
-
|
|
21
|
-
Given a simple decorated class like this one:
|
|
22
|
-
|
|
23
|
-
```js
|
|
24
|
-
@dec
|
|
25
|
-
class Class {
|
|
26
|
-
@dec a = 123;
|
|
27
|
-
|
|
28
|
-
@dec static #b() {
|
|
29
|
-
console.log('foo');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
[someVal]() {}
|
|
33
|
-
|
|
34
|
-
@dec
|
|
35
|
-
@dec2
|
|
36
|
-
accessor #c = 456;
|
|
37
|
-
}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
It's output would be something like the following:
|
|
41
|
-
|
|
42
|
-
```js
|
|
43
|
-
import { applyDecs } from '@babel/helpers';
|
|
44
|
-
|
|
45
|
-
let _initInstance, _initClass, _initStatic, _init_a, _call_b, _computedKey, _init_c, _get_c, _set_c;
|
|
46
|
-
|
|
47
|
-
let _dec = dec,
|
|
48
|
-
_dec2 = dec,
|
|
49
|
-
_computedKey = someVal,
|
|
50
|
-
_dec3 = dec,
|
|
51
|
-
_dec4 = dec2;
|
|
52
|
-
|
|
53
|
-
let _Class;
|
|
54
|
-
class Class {
|
|
55
|
-
static {
|
|
56
|
-
[
|
|
57
|
-
_init_a,
|
|
58
|
-
_call_b,
|
|
59
|
-
_init_c,
|
|
60
|
-
_get_c,
|
|
61
|
-
_set_c,
|
|
62
|
-
_Class,
|
|
63
|
-
_initClass,
|
|
64
|
-
_initProto,
|
|
65
|
-
_initStatic,
|
|
66
|
-
] = _applyDecs(Class,
|
|
67
|
-
[
|
|
68
|
-
[_dec, 0, "a"],
|
|
69
|
-
[
|
|
70
|
-
_dec2,
|
|
71
|
-
7,
|
|
72
|
-
"b",
|
|
73
|
-
function () {
|
|
74
|
-
console.log('foo');
|
|
75
|
-
}
|
|
76
|
-
],
|
|
77
|
-
[
|
|
78
|
-
[_dec4, _dec5],
|
|
79
|
-
1,
|
|
80
|
-
"c",
|
|
81
|
-
function () {
|
|
82
|
-
return this.#a;
|
|
83
|
-
},
|
|
84
|
-
function (value) {
|
|
85
|
-
this.#a = value;
|
|
86
|
-
}
|
|
87
|
-
]
|
|
88
|
-
],
|
|
89
|
-
[dec]
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
_initStatic(Class);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
a = (initInstance(this), _init_a(this, 123));
|
|
96
|
-
|
|
97
|
-
static #b(...args) {
|
|
98
|
-
_call_b(this, args);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
[_computedKey]() {}
|
|
102
|
-
|
|
103
|
-
#a = _init_c(this, 123);
|
|
104
|
-
get #c() {
|
|
105
|
-
return _get_c(this);
|
|
106
|
-
}
|
|
107
|
-
set #c(v) {
|
|
108
|
-
_set_c(this, v);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
static {
|
|
112
|
-
initClass(C);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
Let's break this output down a bit:
|
|
118
|
-
|
|
119
|
-
```js
|
|
120
|
-
let initInstance, initClass, _init_a, _call_b, _init_c, _get_c, _set_c;
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
First, we need to setup some local variables outside of the class. These are
|
|
124
|
-
for:
|
|
125
|
-
|
|
126
|
-
- Decorated class field/accessor initializers
|
|
127
|
-
- Extra initializer functions added by `addInitializers`
|
|
128
|
-
- Private class methods
|
|
129
|
-
|
|
130
|
-
These are essentially all values that cannot be defined on the class itself via
|
|
131
|
-
`Object.defineProperty`, so we have to insert them into the class manually,
|
|
132
|
-
ahead of time and populate them when we run our decorators.
|
|
133
|
-
|
|
134
|
-
```js
|
|
135
|
-
let _dec = dec,
|
|
136
|
-
_dec2 = dec,
|
|
137
|
-
_computedKey = someVal,
|
|
138
|
-
_dec3 = dec,
|
|
139
|
-
_dec4 = dec2;
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
Next up, we define and evaluate the decorator expressions. The reason we
|
|
143
|
-
do this _before_ defining the class is because we must interleave decorator
|
|
144
|
-
expressions with computed property key expressions, since computed properties
|
|
145
|
-
and decorators can run arbitrary code which can modify the runtime of subsequent
|
|
146
|
-
decorators or computed property keys.
|
|
147
|
-
|
|
148
|
-
```js
|
|
149
|
-
let _Class;
|
|
150
|
-
class Class {
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
This class is being decorated directly, which means that the decorator may
|
|
154
|
-
replace the class itself. Class bindings are not mutable, so we need to create a
|
|
155
|
-
new `let` variable for the decorated class.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
```js
|
|
159
|
-
static {
|
|
160
|
-
[
|
|
161
|
-
_init_a,
|
|
162
|
-
_call_b,
|
|
163
|
-
_init_c,
|
|
164
|
-
_get_c,
|
|
165
|
-
_set_c,
|
|
166
|
-
_Class,
|
|
167
|
-
_initClass,
|
|
168
|
-
_initProto,
|
|
169
|
-
_initStatic,
|
|
170
|
-
] = _applyDecs(Class,
|
|
171
|
-
[
|
|
172
|
-
[_dec, 0, "a"],
|
|
173
|
-
[
|
|
174
|
-
_dec2,
|
|
175
|
-
7,
|
|
176
|
-
"b",
|
|
177
|
-
function () {
|
|
178
|
-
console.log('foo');
|
|
179
|
-
}
|
|
180
|
-
],
|
|
181
|
-
[
|
|
182
|
-
[_dec4, _dec5],
|
|
183
|
-
1,
|
|
184
|
-
"c",
|
|
185
|
-
function () {
|
|
186
|
-
return this.#a;
|
|
187
|
-
},
|
|
188
|
-
function (value) {
|
|
189
|
-
this.#a = value;
|
|
190
|
-
}
|
|
191
|
-
]
|
|
192
|
-
],
|
|
193
|
-
[dec]
|
|
194
|
-
);
|
|
195
|
-
|
|
196
|
-
_initStatic(Class);
|
|
197
|
-
}
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
Next, we immediately define a `static` block which actually applies the
|
|
201
|
-
decorators. This is important because we must apply the decorators _after_ the
|
|
202
|
-
class prototype has been fully setup, but _before_ static fields are run, since
|
|
203
|
-
static fields should only see the decorated version of the class.
|
|
204
|
-
|
|
205
|
-
We apply the decorators to class elements and the class itself, and the
|
|
206
|
-
application returns an array of values that are used to populate all of the
|
|
207
|
-
local variables we defined earlier. The array's order is fully deterministic, so
|
|
208
|
-
we can assign the values based on an index we can calculate ahead of time.
|
|
209
|
-
|
|
210
|
-
Another important thing to note here is that we're passing some functions here.
|
|
211
|
-
These are for private methods and accessors, which cannot be replaced directly
|
|
212
|
-
so we have to extract their code so it can be decorated. Because we define these
|
|
213
|
-
within the static block, they can access any private identifiers which were
|
|
214
|
-
defined within the class, so it's not an issue that we're extracting the method
|
|
215
|
-
logic here.
|
|
216
|
-
|
|
217
|
-
We'll come back to `applyDecs` in a bit to dig into what its format is exactly,
|
|
218
|
-
but now let's dig into the new definitions of our class elements.
|
|
219
|
-
|
|
220
|
-
```js
|
|
221
|
-
a = (_initInstance(this), _init_a(this, 123));
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
Alright, so previously this was a simple class field. Since it's the first field
|
|
225
|
-
on the class, we've updated it to immediately call `initInstance` in its
|
|
226
|
-
initializer. This calls any initializers added with `addInitializer` for all of
|
|
227
|
-
the per-class values (methods and accessors), which should all be setup on the
|
|
228
|
-
instance before class fields are assigned. Then, it calls `_init_a` to get the
|
|
229
|
-
initial value of the field, which allows initializers returned from the
|
|
230
|
-
decorator to intercept and decorate it. It's important that the initial value
|
|
231
|
-
is used/defined _within_ the class body, because initializers can now refer to
|
|
232
|
-
private class fields, e.g. `a = this.#b` is a valid field initializer and would
|
|
233
|
-
become `a = _init_a(this, this.#b)`, which would also be valid. We cannot
|
|
234
|
-
extract initializer code, or any other code, from the class body because of
|
|
235
|
-
this.
|
|
236
|
-
|
|
237
|
-
Overall, this decoration is pretty straightforward other than the fact that we
|
|
238
|
-
have to reference `_init_a` externally.
|
|
239
|
-
|
|
240
|
-
```js
|
|
241
|
-
static #b(...args) {
|
|
242
|
-
_call_b(this, args);
|
|
243
|
-
}
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
Next up, we have a private static class method `#b`. This one is a bit more
|
|
247
|
-
complex, as our definition has been broken out into 2 parts:
|
|
248
|
-
|
|
249
|
-
1. `static #b`: This is the method itself, which being a private method we
|
|
250
|
-
cannot overwrite with `defineProperty`. We also can't convert it into a
|
|
251
|
-
private field because that would change its semantics (would make it
|
|
252
|
-
writable). So, we instead have it proxy to the locally scoped `_call_b`
|
|
253
|
-
variable, which will be populated with the fully decorated method.
|
|
254
|
-
2. The definition of the method, kept in `_call_b`. As we mentioned above, the
|
|
255
|
-
original method's code is moved during the decoration process, and the wrapped
|
|
256
|
-
version is populated in `_call_b` and called whenever the private method is
|
|
257
|
-
called.
|
|
258
|
-
|
|
259
|
-
```js
|
|
260
|
-
[_computedKey]() {}
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
Next is the undecorated method with a computed key. This uses the previously
|
|
264
|
-
calculated and stored computed key.
|
|
265
|
-
|
|
266
|
-
```js
|
|
267
|
-
#a = _init_c(this, 123);
|
|
268
|
-
get #c() {
|
|
269
|
-
return _get_c(this);
|
|
270
|
-
}
|
|
271
|
-
set #c(v) {
|
|
272
|
-
_set_c(this, v);
|
|
273
|
-
}
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
Next up, we have the output for `accessor #c`. This is the most complicated
|
|
277
|
-
case, since we have to transpile the decorators, the `accessor` keyword, and
|
|
278
|
-
target a private field. Breaking it down piece by piece:
|
|
279
|
-
|
|
280
|
-
```js
|
|
281
|
-
#a = _init_c(this, 123);
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
`accessor #c` desugars to a getter and setter which are backed by a new private
|
|
285
|
-
field, `#a`. Like before, the name of this field doesn't really matter, we'll
|
|
286
|
-
just generate a short, unique name. We call the decorated initializer for `#c`
|
|
287
|
-
and return that value to assign to the field.
|
|
288
|
-
|
|
289
|
-
```js
|
|
290
|
-
get #c() {
|
|
291
|
-
return _get_c(this);
|
|
292
|
-
}
|
|
293
|
-
set #c(v) {
|
|
294
|
-
_set_c(this, v);
|
|
295
|
-
}
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
Next, we have the getter and setter for `#c` itself. These methods defer to
|
|
299
|
-
the `_get_c` and `_set_c` local variables, which will be the decorated versions
|
|
300
|
-
of the two getter functions that we passed for decoration in the static block
|
|
301
|
-
above. Those two functions are essentially just accessors for the private `#a`
|
|
302
|
-
field, but the decorator may add additional logic to them.
|
|
303
|
-
|
|
304
|
-
```js
|
|
305
|
-
static {
|
|
306
|
-
_initClass(_Class);
|
|
307
|
-
}
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
Finally, we call `_initClass` in another static block, running any class and
|
|
311
|
-
static method initializers on the final class. This is done in a static block
|
|
312
|
-
for convenience with class expressions, but it could run immediately after the
|
|
313
|
-
class is defined.
|
|
314
|
-
|
|
315
|
-
Ok, so now that we understand the general output, let's go back to `applyDecs`:
|
|
316
|
-
|
|
317
|
-
```js
|
|
318
|
-
[
|
|
319
|
-
_init_a,
|
|
320
|
-
_call_b,
|
|
321
|
-
_init_c,
|
|
322
|
-
_get_c,
|
|
323
|
-
_set_c,
|
|
324
|
-
_Class,
|
|
325
|
-
_initClass,
|
|
326
|
-
_initProto,
|
|
327
|
-
_initStatic,
|
|
328
|
-
] = _applyDecs(Class,
|
|
329
|
-
[
|
|
330
|
-
[_dec, 0, "a"],
|
|
331
|
-
[
|
|
332
|
-
_dec2,
|
|
333
|
-
7,
|
|
334
|
-
"b",
|
|
335
|
-
function () {
|
|
336
|
-
console.log('foo');
|
|
337
|
-
}
|
|
338
|
-
],
|
|
339
|
-
[
|
|
340
|
-
[_dec4, _dec5],
|
|
341
|
-
1,
|
|
342
|
-
"c",
|
|
343
|
-
function () {
|
|
344
|
-
return this.#a;
|
|
345
|
-
},
|
|
346
|
-
function (value) {
|
|
347
|
-
this.#a = value;
|
|
348
|
-
}
|
|
349
|
-
]
|
|
350
|
-
],
|
|
351
|
-
[dec]
|
|
352
|
-
);
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
`applyDecs` takes all of the decorators for the class and applies them. It
|
|
356
|
-
receives the following arguments:
|
|
357
|
-
|
|
358
|
-
1. The class itself
|
|
359
|
-
2. Decorators to apply to class elements
|
|
360
|
-
3. Decorators to apply to the class itself
|
|
361
|
-
|
|
362
|
-
The format of the data is designed to be as minimal as possible. Here's an
|
|
363
|
-
annotated version of the member descriptors:
|
|
364
|
-
|
|
365
|
-
```js
|
|
366
|
-
[
|
|
367
|
-
// List of decorators to apply to the field. Array if multiple decorators,
|
|
368
|
-
// otherwise just the single decorator itself.
|
|
369
|
-
dec,
|
|
370
|
-
|
|
371
|
-
// The type of the decorator, represented as an enum. Static-ness is also
|
|
372
|
-
// encoded by adding 5 to the values
|
|
373
|
-
// 0 === FIELD
|
|
374
|
-
// 1 === ACCESSOR
|
|
375
|
-
// 2 === METHOD
|
|
376
|
-
// 3 === GETTER
|
|
377
|
-
// 4 === SETTER
|
|
378
|
-
// 5 === FIELD + STATIC
|
|
379
|
-
// 6 === ACCESSOR + STATIC
|
|
380
|
-
// 7 === METHOD + STATIC
|
|
381
|
-
// 8 === GETTER + STATIC
|
|
382
|
-
// 9 === SETTER + STATIC
|
|
383
|
-
1,
|
|
384
|
-
|
|
385
|
-
// The name of the member
|
|
386
|
-
'y',
|
|
387
|
-
|
|
388
|
-
// Optional fourth and fifth values, these are functions passed for private
|
|
389
|
-
// decorators
|
|
390
|
-
function() {}
|
|
391
|
-
],
|
|
392
|
-
```
|
|
393
|
-
|
|
394
|
-
Static and prototype decorators are all described like this. For class
|
|
395
|
-
decorators, it's just the list of decorators since no other context
|
|
396
|
-
is necessary.
|