@@ -741,10 +741,10 @@ var StaticInterpreter = class {
741741 visitEnumDeclaration(node, context) {
742742 const enumRef = this.getReference(node, context);
743743 const map = /* @__PURE__ */ new Map();
744- node.members.forEach((member) => {
744+ node.members.forEach((member, index ) => {
745745 const name = this.stringNameFromPropertyName(member.name, context);
746746 if (name !== void 0) {
747- const resolved = member.initializer && this.visit(member.initializer, context);
747+ const resolved = member.initializer ? this.visit(member.initializer, context) : index ;
748748 map.set(name, new EnumValue(enumRef, name, resolved));
749749 }
750750 });
@@ -13667,7 +13667,7 @@ import { outputAst as o3 } from "@angular/compiler";
1366713667// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/hmr/src/extract_dependencies.mjs
1366813668import { outputAst as o2 } from "@angular/compiler";
1366913669import ts45 from "typescript";
13670- function extractHmrDependencies(node, definition, factory, deferBlockMetadata, classMetadata, debugInfo) {
13670+ function extractHmrDependencies(node, definition, factory, deferBlockMetadata, classMetadata, debugInfo, reflection, evaluator ) {
1367113671 var _a, _b;
1367213672 const name = ts45.isClassDeclaration(node) && node.name ? node.name.text : null;
1367313673 const visitor = new PotentialTopLevelReadsVisitor();
@@ -13684,19 +13684,55 @@ function extractHmrDependencies(node, definition, factory, deferBlockMetadata, c
1368413684 (_b = deferBlockMetadata.dependenciesFn) == null ? void 0 : _b.visitExpression(visitor, null);
1368513685 }
1368613686 const availableTopLevel = getTopLevelDeclarationNames(sourceFile);
13687+ const local = [];
13688+ const seenLocals = /* @__PURE__ */ new Set();
13689+ for (const readNode of visitor.allReads) {
13690+ const readName = readNode instanceof o2.ReadVarExpr ? readNode.name : readNode.text;
13691+ if (readName !== name && !seenLocals.has(readName) && availableTopLevel.has(readName)) {
13692+ const runtimeRepresentation = getRuntimeRepresentation(readNode, reflection, evaluator);
13693+ if (runtimeRepresentation === null) {
13694+ return null;
13695+ }
13696+ local.push({ name: readName, runtimeRepresentation });
13697+ seenLocals.add(readName);
13698+ }
13699+ }
1368713700 return {
13688- local: Array.from(visitor.allReads).filter((r) => r !== name && availableTopLevel.has(r)) ,
13701+ local,
1368913702 external: Array.from(visitor.namespaceReads, (name2, index) => ({
1369013703 moduleName: name2,
1369113704 assignedName: `\u0275hmr${index}`
1369213705 }))
1369313706 };
1369413707}
13708+ function getRuntimeRepresentation(node, reflection, evaluator) {
13709+ if (node instanceof o2.ReadVarExpr) {
13710+ return o2.variable(node.name);
13711+ }
13712+ if (isConstEnumReference(node, reflection)) {
13713+ const evaluated = evaluator.evaluate(node);
13714+ if (evaluated instanceof Map) {
13715+ const members = [];
13716+ for (const [name, value] of evaluated.entries()) {
13717+ if (value instanceof EnumValue && (value.resolved == null || typeof value.resolved === "string" || typeof value.resolved === "boolean" || typeof value.resolved === "number")) {
13718+ members.push({
13719+ key: name,
13720+ quoted: false,
13721+ value: o2.literal(value.resolved)
13722+ });
13723+ } else {
13724+ return null;
13725+ }
13726+ }
13727+ return o2.literalMap(members);
13728+ }
13729+ }
13730+ return o2.variable(node.text);
13731+ }
1369513732function getTopLevelDeclarationNames(sourceFile) {
13696- var _a;
1369713733 const results = /* @__PURE__ */ new Set();
1369813734 for (const node of sourceFile.statements) {
13699- if (ts45.isClassDeclaration(node) || ts45.isFunctionDeclaration(node) || ts45.isEnumDeclaration(node) && !((_a = node.modifiers) == null ? void 0 : _a.some((m) => m.kind === ts45.SyntaxKind.ConstKeyword)) ) {
13735+ if (ts45.isClassDeclaration(node) || ts45.isFunctionDeclaration(node) || ts45.isEnumDeclaration(node)) {
1370013736 if (node.name) {
1370113737 results.add(node.name.text);
1370213738 }
@@ -13754,7 +13790,7 @@ var PotentialTopLevelReadsVisitor = class extends o2.RecursiveAstVisitor {
1375413790 super.visitExternalExpr(ast, context);
1375513791 }
1375613792 visitReadVarExpr(ast, context) {
13757- this.allReads.add(ast.name );
13793+ this.allReads.add(ast);
1375813794 super.visitReadVarExpr(ast, context);
1375913795 }
1376013796 visitWrappedNodeExpr(ast, context) {
@@ -13765,7 +13801,7 @@ var PotentialTopLevelReadsVisitor = class extends o2.RecursiveAstVisitor {
1376513801 }
1376613802 addAllTopLevelIdentifiers = (node) => {
1376713803 if (ts45.isIdentifier(node) && this.isTopLevelIdentifierReference(node)) {
13768- this.allReads.add(node.text );
13804+ this.allReads.add(node);
1376913805 } else {
1377013806 ts45.forEachChild(node, this.addAllTopLevelIdentifiers);
1377113807 }
@@ -13830,15 +13866,27 @@ var PotentialTopLevelReadsVisitor = class extends o2.RecursiveAstVisitor {
1383013866 return !!value && typeof value.kind === "number";
1383113867 }
1383213868};
13869+ function isConstEnumReference(node, reflection) {
13870+ var _a;
13871+ const parent = node.parent;
13872+ if (!parent || !ts45.isPropertyAccessExpression(parent) || parent.expression !== node || !ts45.isIdentifier(parent.name)) {
13873+ return false;
13874+ }
13875+ const declaration = reflection.getDeclarationOfIdentifier(node);
13876+ return declaration !== null && ts45.isEnumDeclaration(declaration.node) && !!((_a = declaration.node.modifiers) == null ? void 0 : _a.some((m) => m.kind === ts45.SyntaxKind.ConstKeyword));
13877+ }
1383313878
1383413879// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/hmr/src/metadata.mjs
13835- function extractHmrMetatadata(clazz, reflection, compilerHost, rootDirs, definition, factory, deferBlockMetadata, classMetadata, debugInfo) {
13880+ function extractHmrMetatadata(clazz, reflection, evaluator, compilerHost, rootDirs, definition, factory, deferBlockMetadata, classMetadata, debugInfo) {
1383613881 if (!reflection.isClass(clazz)) {
1383713882 return null;
1383813883 }
1383913884 const sourceFile = clazz.getSourceFile();
1384013885 const filePath = getProjectRelativePath(sourceFile.fileName, rootDirs, compilerHost) || compilerHost.getCanonicalFileName(sourceFile.fileName);
13841- const dependencies = extractHmrDependencies(clazz, definition, factory, deferBlockMetadata, classMetadata, debugInfo);
13886+ const dependencies = extractHmrDependencies(clazz, definition, factory, deferBlockMetadata, classMetadata, debugInfo, reflection, evaluator);
13887+ if (dependencies === null) {
13888+ return null;
13889+ }
1384213890 const meta = {
1384313891 type: new o3.WrappedNodeExpr(clazz.name),
1384413892 className: clazz.name.text,
@@ -14750,7 +14798,7 @@ var ComponentDecoratorHandler = class {
1475014798 const inputTransformFields = compileInputTransformFields(analysis.inputs);
1475114799 const classMetadata = analysis.classMetadata !== null ? compileComponentClassMetadata(analysis.classMetadata, perComponentDeferredDeps).toStmt() : null;
1475214800 const debugInfo = analysis.classDebugInfo !== null ? compileClassDebugInfo(analysis.classDebugInfo).toStmt() : null;
14753- const hmrMeta = this.enableHmr ? extractHmrMetatadata(node, this.reflector, this.compilerHost, this.rootDirs, def, fac, defer, classMetadata, debugInfo) : null;
14801+ const hmrMeta = this.enableHmr ? extractHmrMetatadata(node, this.reflector, this.evaluator, this. compilerHost, this.rootDirs, def, fac, defer, classMetadata, debugInfo) : null;
1475414802 const hmrInitializer = hmrMeta ? compileHmrInitializer(hmrMeta).toStmt() : null;
1475514803 const deferrableImports = this.canDeferDeps ? this.deferredSymbolTracker.getDeferrableImportDecls() : null;
1475614804 return compileResults(fac, def, classMetadata, "\u0275cmp", inputTransformFields, deferrableImports, debugInfo, hmrInitializer);
@@ -14776,7 +14824,7 @@ var ComponentDecoratorHandler = class {
1477614824 const inputTransformFields = compileInputTransformFields(analysis.inputs);
1477714825 const def = compileDeclareComponentFromMetadata(meta, analysis.template, templateInfo);
1477814826 const classMetadata = analysis.classMetadata !== null ? compileComponentDeclareClassMetadata(analysis.classMetadata, perComponentDeferredDeps).toStmt() : null;
14779- const hmrMeta = this.enableHmr ? extractHmrMetatadata(node, this.reflector, this.compilerHost, this.rootDirs, def, fac, defer, classMetadata, null) : null;
14827+ const hmrMeta = this.enableHmr ? extractHmrMetatadata(node, this.reflector, this.evaluator, this. compilerHost, this.rootDirs, def, fac, defer, classMetadata, null) : null;
1478014828 const hmrInitializer = hmrMeta ? compileHmrInitializer(hmrMeta).toStmt() : null;
1478114829 const deferrableImports = this.canDeferDeps ? this.deferredSymbolTracker.getDeferrableImportDecls() : null;
1478214830 return compileResults(fac, def, classMetadata, "\u0275cmp", inputTransformFields, deferrableImports, null, hmrInitializer);
@@ -14797,7 +14845,7 @@ var ComponentDecoratorHandler = class {
1479714845 const inputTransformFields = compileInputTransformFields(analysis.inputs);
1479814846 const classMetadata = analysis.classMetadata !== null ? compileComponentClassMetadata(analysis.classMetadata, deferrableTypes).toStmt() : null;
1479914847 const debugInfo = analysis.classDebugInfo !== null ? compileClassDebugInfo(analysis.classDebugInfo).toStmt() : null;
14800- const hmrMeta = this.enableHmr ? extractHmrMetatadata(node, this.reflector, this.compilerHost, this.rootDirs, def, fac, defer, classMetadata, debugInfo) : null;
14848+ const hmrMeta = this.enableHmr ? extractHmrMetatadata(node, this.reflector, this.evaluator, this. compilerHost, this.rootDirs, def, fac, defer, classMetadata, debugInfo) : null;
1480114849 const hmrInitializer = hmrMeta ? compileHmrInitializer(hmrMeta).toStmt() : null;
1480214850 const deferrableImports = this.canDeferDeps ? this.deferredSymbolTracker.getDeferrableImportDecls() : null;
1480314851 return compileResults(fac, def, classMetadata, "\u0275cmp", inputTransformFields, deferrableImports, debugInfo, hmrInitializer);
@@ -14817,7 +14865,7 @@ var ComponentDecoratorHandler = class {
1481714865 const def = compileComponentFromMetadata(meta, pool, makeBindingParser2());
1481814866 const classMetadata = analysis.classMetadata !== null ? compileComponentClassMetadata(analysis.classMetadata, null).toStmt() : null;
1481914867 const debugInfo = analysis.classDebugInfo !== null ? compileClassDebugInfo(analysis.classDebugInfo).toStmt() : null;
14820- const hmrMeta = this.enableHmr ? extractHmrMetatadata(node, this.reflector, this.compilerHost, this.rootDirs, def, fac, defer, classMetadata, debugInfo) : null;
14868+ const hmrMeta = this.enableHmr ? extractHmrMetatadata(node, this.reflector, this.evaluator, this. compilerHost, this.rootDirs, def, fac, defer, classMetadata, debugInfo) : null;
1482114869 const res = compileResults(fac, def, classMetadata, "\u0275cmp", null, null, debugInfo, null);
1482214870 return hmrMeta === null || res.length === 0 ? null : getHmrUpdateDeclaration(res, pool.statements, hmrMeta, node.getSourceFile());
1482314871 }
@@ -15547,4 +15595,4 @@ export {
1554715595 * Use of this source code is governed by an MIT-style license that can be
1554815596 * found in the LICENSE file at https://angular.dev/license
1554915597 */
15550- //# sourceMappingURL=chunk-L6PLONOG .js.map
15598+ //# sourceMappingURL=chunk-PKCWD3IK .js.map
0 commit comments