@analogjs/vite-plugin-angular 3.0.0-beta.56 → 3.0.0-beta.58

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@analogjs/vite-plugin-angular",
3
- "version": "3.0.0-beta.56",
3
+ "version": "3.0.0-beta.58",
4
4
  "description": "Vite Plugin for Angular",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -8,7 +8,7 @@ import { collectStringConstants, detectFieldDecorators, detectSignals, extractCo
8
8
  import { buildDeferDependencyMap, buildImportMap } from "./defer.js";
9
9
  import { buildCtorParameters, buildPropDecorators } from "./jit-metadata.js";
10
10
  import { debugCompile } from "./debug.js";
11
- import { inlineStyleRanges } from "./style-ast.js";
11
+ import { getPropertyKey, inlineStyleRanges } from "./style-ast.js";
12
12
  import * as fs from "node:fs";
13
13
  import * as path$1 from "node:path";
14
14
  import * as o from "@angular/compiler";
@@ -32,6 +32,34 @@ function decoratorCallName(dec, sourceCode) {
32
32
  return sourceCode.slice(callee.callee.start, callee.callee.end);
33
33
  }
34
34
  /**
35
+ * Pair each inline style of a component with its processed CSS, skipping the
36
+ * ones whose processing failed.
37
+ */
38
+ function resolveInlineStyles(range, resolvedInlineStyles) {
39
+ if (!range || !resolvedInlineStyles) return [];
40
+ return range.styles.flatMap((style, k) => {
41
+ const css = resolvedInlineStyles.get(range.start + k);
42
+ return css === void 0 ? [] : [{
43
+ ...style,
44
+ css
45
+ }];
46
+ });
47
+ }
48
+ /**
49
+ * Source text of a `styles` value with each resolved inline style replaced by
50
+ * its processed CSS, so the class metadata a TestBed override recompiles from
51
+ * carries the same styles as ɵcmp.
52
+ */
53
+ function withResolvedInlineStyles(stylesNode, styles, sourceCode) {
54
+ let text = "";
55
+ let pos = stylesNode.start;
56
+ for (const { node, css } of styles) {
57
+ text += sourceCode.slice(pos, node.start) + JSON.stringify(css);
58
+ pos = node.end;
59
+ }
60
+ return text + sourceCode.slice(pos, stylesNode.end);
61
+ }
62
+ /**
35
63
  * Normalize a `providers` / `viewProviders` metadata value into the single
36
64
  * `o.Expression` Angular's injector/host emitters expect.
37
65
  *
@@ -376,14 +404,10 @@ function compile(sourceCode, fileName, optionsOrRegistry) {
376
404
  } catch {
377
405
  console.warn(`[fast-compile] Could not read style file "${url}" for ${className}`);
378
406
  }
379
- const styleRange = styleRanges?.get(dec);
380
- if (resolvedInlineStyles && styleRange) for (let k = 0; k < styleRange.count; k++) {
381
- const css = resolvedInlineStyles.get(styleRange.start + k);
382
- if (css !== void 0) meta.styles[k] = css;
383
- }
407
+ for (const { index, css } of resolveInlineStyles(styleRanges?.get(dec), resolvedInlineStyles)) meta.styles[index] = css;
384
408
  resolvedResources.set(dec, {
385
409
  template: templateContent || void 0,
386
- styles: meta.styles?.length > 0 ? [...meta.styles] : void 0
410
+ styles: meta.styleUrls.length > 0 && meta.styles?.length > 0 ? [...meta.styles] : void 0
387
411
  });
388
412
  const parsedTemplate = parseTemplate(templateContent, fileName, {
389
413
  preserveWhitespaces: meta.preserveWhitespaces,
@@ -694,17 +718,25 @@ function compile(sourceCode, fileName, optionsOrRegistry) {
694
718
  if (resources && decArgsNode.type === "ObjectExpression") {
695
719
  const rewrittenProps = [];
696
720
  let needsTransform = false;
721
+ const inlineStyles = resolveInlineStyles(styleRanges?.get(dec), resolvedInlineStyles);
722
+ let resourceStylesWritten = false;
697
723
  for (const prop of decArgsNode.properties) {
698
724
  if (prop.type !== "Property" || prop.shorthand || prop.method || prop.kind !== "init") {
699
725
  rewrittenProps.push(textOf(prop));
700
726
  continue;
701
727
  }
702
- const propName = textOf(prop.key);
728
+ const propName = getPropertyKey(prop);
703
729
  if (propName === "templateUrl" && resources.template) {
704
730
  rewrittenProps.push(`template: ${JSON.stringify(resources.template)}`);
705
731
  needsTransform = true;
706
- } else if ((propName === "styleUrl" || propName === "styleUrls") && resources.styles?.length) {
707
- rewrittenProps.push(`styles: [${resources.styles.map((s) => JSON.stringify(s)).join(", ")}]`);
732
+ } else if ((propName === "styleUrl" || propName === "styleUrls" || propName === "styles") && resources.styles) {
733
+ if (!resourceStylesWritten) {
734
+ rewrittenProps.push(`styles: [${resources.styles.map((s) => JSON.stringify(s)).join(", ")}]`);
735
+ resourceStylesWritten = true;
736
+ }
737
+ needsTransform = true;
738
+ } else if (propName === "styles" && inlineStyles.length > 0) {
739
+ rewrittenProps.push(`styles: ${withResolvedInlineStyles(prop.value, inlineStyles, sourceCode)}`);
708
740
  needsTransform = true;
709
741
  } else rewrittenProps.push(textOf(prop));
710
742
  }
@@ -1 +1 @@
1
- {"version":3,"file":"compile.js","names":[],"sources":["../../../../src/lib/compiler/compile.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as o from '@angular/compiler';\nimport MagicString from 'magic-string';\nimport type { parseSync } from 'oxc-parser';\nimport { parseOxc } from './utils.js';\nimport {\n ConstantPool,\n compileComponentFromMetadata,\n compileDirectiveFromMetadata,\n compilePipeFromMetadata,\n compileNgModule,\n compileInjector,\n R3NgModuleMetadataKind,\n R3SelectorScopeMode,\n FactoryTarget,\n compileFactoryFunction,\n parseTemplate,\n makeBindingParser,\n parseHostBindings,\n ParseSourceFile,\n ParseLocation,\n ParseSourceSpan,\n compileClassMetadata,\n compileComponentClassMetadata,\n compileDeclareComponentFromMetadata,\n compileDeclareDirectiveFromMetadata,\n compileDeclarePipeFromMetadata,\n compileDeclareNgModuleFromMetadata,\n compileDeclareInjectorFromMetadata,\n compileDeclareInjectableFromMetadata,\n compileDeclareFactoryFunction,\n compileDeclareClassMetadata,\n} from '@angular/compiler';\nimport { ComponentRegistry } from './registry.js';\nimport {\n findAllClasses,\n resolveSyntheticImportSpecifier,\n walkOxc,\n} from './utils.js';\nimport { ANGULAR_DECORATORS, FIELD_DECORATORS } from './constants.js';\nimport { angularVersionAtLeast } from './angular-version.js';\nimport {\n detectTypeOnlyImportNames,\n elideTypeOnlyImportsMagicString,\n} from './type-elision.js';\n\nimport {\n emitAngularExpr,\n emitAngularStmt,\n setEmitterSourceCode,\n} from './js-emitter.js';\nimport { lowerClassFields } from './class-field-lowering.js';\nimport {\n extractMetadata,\n collectStringConstants,\n detectSignals,\n detectFieldDecorators,\n extractConstructorDeps,\n} from './metadata.js';\nimport { buildDeferDependencyMap, buildImportMap } from './defer.js';\nimport { buildCtorParameters, buildPropDecorators } from './jit-metadata.js';\nimport { debugCompile, debugEmit } from './debug.js';\nimport { inlineStyleRanges } from './style-ast.js';\n\n/**\n * COMPLETE EXHAUSTIVE ANGULAR LITE COMPILER\n * Translates Angular Decorators + Signals to Ivy Static Definitions.\n *\n * @param registry - Optional external registry from the global analysis plugin.\n * When provided, used to resolve component/directive selectors for template compilation.\n */\nexport interface CompileResult {\n code: string;\n /** Source map for the transformation */\n map: ReturnType<MagicString['generateMap']>;\n /** Absolute paths of external resources (templateUrl, styleUrl) read during compilation */\n resourceDependencies: string[];\n}\n\nexport interface CompileOptions {\n registry?: ComponentRegistry;\n /** Pre-resolved style contents keyed by absolute file path (e.g. SCSS already compiled to CSS). */\n resolvedStyles?: Map<string, string>;\n /** Pre-processed inline styles (index in styles array → compiled CSS). */\n resolvedInlineStyles?: Map<number, string>;\n /**\n * When `false` (default), instance class field initializers are lowered to\n * constructor assignments (matching TypeScript's `useDefineForClassFields: false`\n * behavior). This is required for Angular's `inject()` and constructor DI to\n * work correctly with the standard Angular tsconfig.\n */\n useDefineForClassFields?: boolean;\n /** Enable legacy i18n message ID format (default: true). */\n enableI18nLegacyMessageIdFormat?: boolean;\n /** Normalize line endings in ICU expressions (default: true). */\n i18nNormalizeLineEndingsInICUs?: boolean;\n /** Use external IDs in `$localize` calls (for Closure Compiler compatibility). */\n i18nUseExternalIds?: boolean;\n /**\n * Compilation output mode.\n * - `'full'` (default): Emit final Ivy definitions (`ɵɵdefineComponent`) for application builds.\n * - `'partial'`: Emit partial declarations (`ɵɵngDeclareComponent`) for library publishing.\n * Partial output is version-stable and linked at application build time.\n */\n compilationMode?: 'full' | 'partial';\n /**\n * Pre-parsed OXC program of `sourceCode`, so callers that already parsed\n * the identical string can avoid a re-parse. Treated as read-only.\n */\n oxcProgram?: ReturnType<typeof parseSync>['program'];\n}\n\ntype CompileMetadata = ReturnType<typeof extractMetadata>;\n\ntype CompileDeclaration = {\n type: o.Expression;\n selector: string | null;\n className?: string;\n kind: number;\n name?: string;\n inputs?: string[];\n outputs?: string[];\n exportAs?: string[];\n isComponent?: boolean;\n};\n\n/** A top-level statement with any `export` wrapper unwrapped. */\ninterface TopLevelStatement {\n /** The declaration (or the statement itself when not exported). */\n decl: any;\n exported: boolean;\n /** Start of the whole statement, including leading class decorators. */\n start: number;\n end: number;\n}\n\nfunction toTopLevelStatement(stmt: any): TopLevelStatement {\n const isExport =\n (stmt.type === 'ExportNamedDeclaration' ||\n stmt.type === 'ExportDefaultDeclaration') &&\n stmt.declaration;\n const decl = isExport ? stmt.declaration : stmt;\n return {\n decl,\n exported: !!isExport,\n start: Math.min(stmt.start, decl.decorators?.[0]?.start ?? stmt.start),\n end: stmt.end,\n };\n}\n\n/** Get the callee name of a decorator call, e.g. `Component` for `@Component(...)`. */\nfunction decoratorCallName(dec: any, sourceCode: string): string | undefined {\n const callee = dec.expression;\n if (callee?.type !== 'CallExpression') return undefined;\n return sourceCode.slice(callee.callee.start, callee.callee.end);\n}\n\n/**\n * Normalize a `providers` / `viewProviders` metadata value into the single\n * `o.Expression` Angular's injector/host emitters expect.\n *\n * `extractMetadata` stores these as an array of `WrappedNodeExpr` when the\n * source used an inline array literal (`providers: [A, B]`) — those get\n * wrapped in a `LiteralArrayExpr`. When the source referenced a const,\n * spread, or call instead (`providers: safeProviders`), it stores the raw\n * expression, which is emitted by value. Returns `null` when there is\n * nothing to emit so callers skip the feature entirely.\n */\nfunction providersToExpr(\n value: o.Expression[] | o.Expression | undefined | null,\n): o.Expression | null {\n if (!value) return null;\n if (Array.isArray(value)) {\n return value.length ? new o.LiteralArrayExpr(value) : null;\n }\n return value;\n}\n\nconst LAZY_SCOPE_TYPES = new Set([\n 'FunctionDeclaration',\n 'FunctionExpression',\n 'ArrowFunctionExpression',\n 'ClassDeclaration',\n 'ClassExpression',\n 'TSFunctionType',\n 'TSConstructorType',\n 'TSMethodSignature',\n 'TSCallSignatureDeclaration',\n 'TSConstructSignatureDeclaration',\n]);\n\n/**\n * Collect identifier names referenced in eagerly-evaluated code only.\n * Skips function/arrow/class bodies so that lazy references\n * (e.g. `const TOKEN = () => LaterClass`) are not treated as dependencies.\n * The root node's own children are always walked.\n */\nfunction collectIdentifiers(root: any): Set<string> {\n const ids = new Set<string>();\n walkOxc(root, (n) => {\n if (n.type === 'Identifier') ids.add(n.name);\n return n === root || !LAZY_SCOPE_TYPES.has(n.type);\n });\n return ids;\n}\n\n/** Extract the names defined by a top-level declaration. */\nfunction getDefinedNames(decl: any): string[] {\n if (decl.type === 'VariableDeclaration') {\n const names: string[] = [];\n for (const d of decl.declarations) {\n collectBindingNames(d.id, names);\n }\n return names;\n }\n if (\n (decl.type === 'FunctionDeclaration' || decl.type === 'ClassDeclaration') &&\n decl.id\n ) {\n return [decl.id.name];\n }\n return [];\n}\n\n/** Recursively collect all bound identifiers from a binding pattern. */\nfunction collectBindingNames(pattern: any, out: string[]): void {\n if (!pattern) return;\n switch (pattern.type) {\n case 'Identifier':\n out.push(pattern.name);\n break;\n case 'ObjectPattern':\n for (const prop of pattern.properties) {\n collectBindingNames(\n prop.type === 'RestElement' ? prop.argument : prop.value,\n out,\n );\n }\n break;\n case 'ArrayPattern':\n for (const el of pattern.elements) collectBindingNames(el, out);\n break;\n case 'RestElement':\n collectBindingNames(pattern.argument, out);\n break;\n case 'AssignmentPattern':\n collectBindingNames(pattern.left, out);\n break;\n }\n}\n\nexport function compile(\n sourceCode: string,\n fileName: string,\n optionsOrRegistry?: CompileOptions | ComponentRegistry,\n): CompileResult {\n // Backward compat: accept ComponentRegistry directly\n const opts: CompileOptions =\n optionsOrRegistry instanceof Map\n ? { registry: optionsOrRegistry }\n : optionsOrRegistry || {};\n const registry = opts.registry;\n const resolvedStyles = opts.resolvedStyles;\n const resolvedInlineStyles = opts.resolvedInlineStyles;\n const useDefineForClassFields = opts.useDefineForClassFields ?? false;\n const isPartial = opts.compilationMode === 'partial';\n const startTimeMs = debugCompile.enabled ? performance.now() : 0;\n debugCompile(\n 'compile %s (mode=%s, registry=%d entries)',\n fileName,\n isPartial ? 'partial' : 'full',\n registry?.size ?? 0,\n );\n const oxcProgram = opts.oxcProgram ?? parseOxc(fileName, sourceCode).program;\n const styleRanges = resolvedInlineStyles && inlineStyleRanges(oxcProgram);\n const oxcClassMap = new Map<string, any>();\n for (const stmt of oxcProgram.body) {\n const decl =\n stmt.type === 'ExportNamedDeclaration' ||\n stmt.type === 'ExportDefaultDeclaration'\n ? (stmt as any).declaration\n : stmt;\n if (\n decl &&\n (decl.type === 'ClassDeclaration' || decl.type === 'ClassExpression') &&\n decl.id?.name\n ) {\n oxcClassMap.set(decl.id.name, decl);\n }\n }\n\n // Collect module-level string constants so decorator metadata can resolve\n // template-literal interpolations like `template: \\`<div class=\"${tw}\">x</div>\\``.\n const stringConsts = collectStringConstants(oxcProgram);\n\n const constantPool = new ConstantPool();\n const resourceDependencies: string[] = [];\n const parseFile = new ParseSourceFile(sourceCode, fileName);\n const parseLoc = new ParseLocation(parseFile, 0, 0, 0);\n const typeSourceSpan = new ParseSourceSpan(parseLoc, parseLoc);\n const typeOnlyImports = detectTypeOnlyImportNames(sourceCode, oxcProgram);\n const importSpecifierByName = new Map<string, string>();\n const importedNames = new Set<string>();\n const typeOnlyImportedNames = new Set<string>();\n\n for (const stmt of oxcProgram.body as any[]) {\n if (stmt.type !== 'ImportDeclaration') continue;\n\n const moduleSpecifier: string = stmt.source.value;\n // Explicit `import type { X }` — declaration-level type-only import\n const isDeclarationTypeOnly = stmt.importKind === 'type';\n for (const element of stmt.specifiers) {\n if (element.type !== 'ImportSpecifier') continue;\n const localName: string = element.local.name;\n importSpecifierByName.set(localName, moduleSpecifier);\n // Explicit `import { type X }` — specifier-level type-only import.\n // Both forms erase the symbol at runtime, so they cannot be used as\n // DI tokens. Add them to typeOnlyImports so extractConstructorDeps\n // surfaces ɵɵinvalidFactory() instead of emitting a broken\n // ɵɵdirectiveInject(X) referring to a non-existent value.\n if (isDeclarationTypeOnly || element.importKind === 'type') {\n typeOnlyImports.add(localName);\n typeOnlyImportedNames.add(localName);\n } else {\n importedNames.add(localName);\n }\n }\n }\n\n // Build a file-local selector map as fallback when no external registry is provided.\n // Skip the expensive extractMetadata scan when a registry covers all classes.\n const localSelectors = new Map<string, string>();\n /**\n * Per component class: the dependencies only its @defer blocks use, which\n * its class metadata must load lazily (`ɵsetClassMetadataAsync`).\n */\n const deferredMetadataDeps = new Map<\n string,\n { symbolName: string; importPath: string; isDefaultImport: boolean }[]\n >();\n if (!registry) {\n for (const [clsName, oxcNode] of oxcClassMap) {\n const decs: any[] = oxcNode.decorators || [];\n if (decs.length > 0) {\n const meta = extractMetadata(decs[0], sourceCode, stringConsts);\n if (meta?.selector) {\n localSelectors.set(clsName, meta.selector.split(',')[0].trim());\n }\n }\n }\n }\n\n const bindingParser = isPartial ? undefined : makeBindingParser();\n setEmitterSourceCode(sourceCode);\n\n // --- Direct walk: compile each Angular-decorated class and collect string outputs ---\n interface ClassCompileResult {\n ivyCode: string[]; // \"static ɵfac = ...\", \"static ɵcmp = ...\", etc.\n decorators: any[]; // Angular decorators to remove (OXC nodes)\n classEnd: number; // Position of closing } in original source\n // setClassMetadata calls for classes nested in a function scope, which\n // must be emitted next to the class rather than at module scope.\n scopedMetadata: o.Statement[];\n }\n const classResults: ClassCompileResult[] = [];\n const topLevelClasses = new Set(\n (oxcProgram.body as any[]).map((stmt) => toTopLevelStatement(stmt).decl),\n );\n // Track synthetic imports needed for NgModule export expansion.\n // Maps exported class name → import specifier.\n const syntheticImports = new Map<string, string>();\n // A type-only import is erased at runtime, so its synthetic value import\n // needs an alias to avoid redeclaring the type-only binding.\n const dependencyLocalName = (name: string) =>\n typeOnlyImportedNames.has(name) ? `ɵngDep_${name}` : name;\n\n // ANGULAR_DECORATORS imported from utils\n\n for (const node of findAllClasses(oxcProgram)) {\n const decorators: any[] = node.decorators;\n if (!decorators || decorators.length === 0) continue;\n\n const className: string | undefined = node.id?.name;\n if (!className) continue;\n\n const angularDecorators = decorators.filter((dec) =>\n ANGULAR_DECORATORS.has(decoratorCallName(dec, sourceCode) ?? ''),\n );\n if (angularDecorators.length === 0) continue;\n\n const ivyCode: string[] = [];\n let targetType: FactoryTarget = FactoryTarget.Injectable;\n // Store resolved resources per decorator for metadata inlining\n const resolvedResources = new Map<\n any,\n { template?: string; styles?: string[] }\n >();\n\n const classRef: o.R3Reference = {\n value: new o.WrappedNodeExpr(className),\n type: new o.WrappedNodeExpr(className),\n };\n\n // Detect `class Foo extends Bar` so the directive/component def\n // gets `usesInheritance: true`. Angular's compiler turns that into\n // `features: [InheritDefinitionFeature]`, which is what causes the\n // runtime to merge inputs/outputs/queries/host bindings from the\n // base class. Without it, derived directives like\n // `BrnPopover extends BrnDialog` lose every input declared on the\n // base, and any host directive that references those inputs by\n // public name fails at runtime with NG0311.\n const usesInheritance = !!node.superClass;\n\n let classCompileError: Error | null = null;\n\n angularDecorators.forEach((dec) => {\n const decoratorName = decoratorCallName(dec, sourceCode)!;\n const meta = extractMetadata(dec, sourceCode, stringConsts);\n const sigs = detectSignals(node, sourceCode);\n const fields = detectFieldDecorators(node, sourceCode);\n const hostBindings = parseHostBindings(meta.hostRaw || {});\n\n const hostMetadata: o.R3HostMetadata = {\n attributes: hostBindings.attributes,\n listeners: { ...hostBindings.listeners, ...fields.hostListeners },\n properties: { ...hostBindings.properties, ...fields.hostProperties },\n specialAttributes: hostBindings.specialAttributes,\n };\n\n switch (decoratorName) {\n case 'Component': {\n targetType = FactoryTarget.Component;\n if (!meta.selector) {\n meta.selector = `ng-component-${className.toLowerCase()}`;\n }\n\n const declarations: CompileDeclaration[] = [];\n // Dedupe by class name across direct imports, tuple-barrel\n // expansion, and NgModule export expansion so the final\n // `dependencies: () => [...]` list never contains the same\n // class twice. Otherwise Angular's runtime throws NG0300\n // (\"Multiple components match …\") when a file lists both\n // `NgIcon` and a barrel like `HlmIconImports = [HlmIcon, NgIcon]`\n // that re-exports it, or when two NgModules re-export the same\n // directive (e.g. FormsModule + ReactiveFormsModule →\n // DefaultValueAccessor).\n const seenDeclarationNames = new Set<string>();\n\n // Expand `imports` entries that are not directives themselves\n // (e.g. NgModules and tuple barrels like `HlmSelectImports =\n // [HlmSelect, HlmSelectContent, ...] as const`) into the\n // underlying directive class names. Returns the original entry\n // when it doesn't match either expansion case.\n const collectExpandedImports = (\n depClassName: string,\n visited: Set<string>,\n ): string[] => {\n if (visited.has(depClassName)) return [];\n visited.add(depClassName);\n const entry = registry?.get(depClassName);\n if (!entry) return [depClassName];\n if (entry.kind === 'ngmodule' && entry.exports) {\n const out: string[] = [];\n for (const name of entry.exports) {\n out.push(...collectExpandedImports(name, visited));\n }\n return out;\n }\n if (entry.kind === 'tuple' && entry.members) {\n const out: string[] = [];\n for (const name of entry.members) {\n out.push(...collectExpandedImports(name, visited));\n }\n return out;\n }\n return [depClassName];\n };\n\n for (const dep of Array.isArray(meta.imports) ? meta.imports : []) {\n const depNode = dep.node;\n const depClassName: string =\n typeof depNode === 'string'\n ? depNode\n : (depNode?.name ?? depNode?.type === 'Identifier')\n ? depNode.name\n : sourceCode.slice(depNode?.start ?? 0, depNode?.end ?? 0);\n const registryEntry = registry?.get(depClassName);\n\n // Tuple barrel: `imports: [HlmSelectImports]` where the\n // const is `[HlmSelect, HlmSelectContent, ...] as const`.\n // Expand into the underlying directive declarations and\n // track synthetic imports for any classes not already\n // referenced in this file.\n if (registryEntry?.kind === 'tuple' && registryEntry.members) {\n const expanded = collectExpandedImports(depClassName, new Set());\n const tupleSpecifier = importSpecifierByName.get(depClassName);\n for (const memberName of expanded) {\n const memberEntry = registry?.get(memberName);\n if (!memberEntry || memberEntry.kind === 'tuple') continue;\n const memberRef = new o.WrappedNodeExpr(\n dependencyLocalName(memberName),\n );\n if (!importedNames.has(memberName)) {\n const memberSpecifier = resolveSyntheticImportSpecifier(\n fileName,\n memberEntry,\n tupleSpecifier,\n );\n if (memberSpecifier) {\n syntheticImports.set(memberName, memberSpecifier);\n }\n }\n const kind = memberEntry.kind === 'pipe' ? 1 : 0;\n const memberDecl: CompileDeclaration = {\n type: memberRef,\n selector: memberEntry.selector,\n kind,\n ...(kind === 1 ? { name: memberEntry.pipeName } : {}),\n };\n if (memberEntry.inputs) {\n memberDecl.inputs = Object.values(memberEntry.inputs).map(\n (i) => i.bindingPropertyName,\n );\n }\n if (memberEntry.outputs) {\n memberDecl.outputs = Object.values(\n memberEntry.outputs,\n ) as string[];\n }\n if (!seenDeclarationNames.has(memberName)) {\n seenDeclarationNames.add(memberName);\n declarations.push(memberDecl);\n }\n }\n continue;\n }\n\n if (registryEntry?.kind === 'ngmodule' && registryEntry.exports) {\n const moduleSpecifier = importSpecifierByName.get(depClassName);\n\n // Recursively collect all non-module exports (handles nested NgModules\n // like ReactiveFormsModule → ɵInternalFormsSharedModule → DefaultValueAccessor)\n const allExports: string[] = [];\n const expandModule = (\n moduleName: string,\n visited = new Set<string>(),\n ) => {\n if (visited.has(moduleName)) return;\n visited.add(moduleName);\n const mod = registry?.get(moduleName);\n if (!mod?.exports) return;\n for (const name of mod.exports) {\n const entry = registry?.get(name);\n if (!entry) continue;\n if (entry.kind === 'ngmodule') {\n expandModule(name, visited);\n } else {\n allExports.push(name);\n }\n }\n };\n expandModule(depClassName);\n\n for (const exportedName of allExports) {\n const exportedEntry = registry?.get(exportedName);\n if (exportedEntry) {\n const kind = exportedEntry.kind === 'pipe' ? 1 : 0;\n // Create a reference to the exported class. If it's not\n // already imported, track it for synthetic import injection.\n const exportedRef = new o.WrappedNodeExpr(\n dependencyLocalName(exportedName),\n );\n const exportedSpecifier = resolveSyntheticImportSpecifier(\n fileName,\n exportedEntry,\n moduleSpecifier,\n );\n if (exportedSpecifier) {\n syntheticImports.set(exportedName, exportedSpecifier);\n }\n const decl: CompileDeclaration = {\n type: exportedRef,\n selector: exportedEntry.selector,\n kind,\n ...(kind === 1 ? { name: exportedEntry.pipeName } : {}),\n };\n if (exportedEntry.inputs) {\n decl.inputs = Object.values(exportedEntry.inputs).map(\n (i) => i.bindingPropertyName,\n );\n }\n if (exportedEntry.outputs) {\n decl.outputs = Object.values(\n exportedEntry.outputs,\n ) as string[];\n }\n if (!seenDeclarationNames.has(exportedName)) {\n seenDeclarationNames.add(exportedName);\n declarations.push(decl);\n }\n }\n }\n continue;\n }\n\n const selector =\n registryEntry?.selector ?? localSelectors.get(depClassName);\n const kind = registryEntry?.kind === 'pipe' ? 1 : 0;\n const decl: CompileDeclaration = {\n type: dep,\n selector: selector || `_unresolved-${depClassName}`,\n kind,\n ...(kind === 1 ? { name: registryEntry?.pipeName } : {}),\n };\n // Pass inputs/outputs from registry so template bindings resolve.\n // R3DirectiveDependencyMetadata expects inputs/outputs as string[]\n // of binding property names.\n if (registryEntry?.inputs) {\n decl.inputs = Object.values(registryEntry.inputs).map(\n (i) => i.bindingPropertyName,\n );\n }\n if (registryEntry?.outputs) {\n decl.outputs = Object.values(registryEntry.outputs) as string[];\n }\n if (!seenDeclarationNames.has(depClassName)) {\n seenDeclarationNames.add(depClassName);\n declarations.push(decl);\n }\n }\n\n // Add self-reference so recursive components (e.g. tree views)\n // can use their own selector in their template.\n // Skip in partial mode — the linker handles self-resolution.\n if (!isPartial && !seenDeclarationNames.has(className)) {\n const selfInputs = Object.entries(sigs.inputs).map(\n ([, v]: [string, any]) => v.bindingPropertyName,\n );\n const selfOutputs = Object.values({\n ...meta.outputs,\n ...fields.outputs,\n ...sigs.outputs,\n }) as string[];\n seenDeclarationNames.add(className);\n declarations.push({\n type: classRef.value,\n selector: meta.selector,\n kind: 0,\n ...(selfInputs.length > 0 ? { inputs: selfInputs } : {}),\n ...(selfOutputs.length > 0 ? { outputs: selfOutputs } : {}),\n });\n }\n\n // Non-standalone components get their directive/pipe scope from the\n // @NgModule that declares them. Whole-program ngtsc resolves this; a\n // per-file engine can't read the module from the component file, but the\n // project-wide registry (populated at buildStart) records every module's\n // declarations + imports. We resolve the owning module's transitive scope\n // here and inline it into the component's own `dependencies` — matching\n // ngtsc, and surviving tree-shaking (unlike a separate, droppable\n // `ɵɵsetComponentScope` call).\n //\n // A component declared in an @NgModule must set\n // `standalone: false`, so only those need the owning-module lookup.\n if (!isPartial && meta.standalone === false && registry) {\n let owningModule:\n | { declarations?: string[]; imports?: string[] }\n | undefined;\n for (const entry of registry.values()) {\n if (\n entry.kind === 'ngmodule' &&\n entry.declarations?.includes(className)\n ) {\n owningModule = entry;\n break;\n }\n }\n if (owningModule) {\n // Transitive scope = the module's own declarations + the exported\n // declarations of every imported module (recursively) + tuple members.\n const scopeNames = new Set<string>();\n const addExportsOf = (modName: string, visited: Set<string>) => {\n if (visited.has(modName)) return;\n visited.add(modName);\n const e = registry.get(modName);\n if (!e) return;\n if (e.kind === 'ngmodule') {\n for (const exp of e.exports ?? []) addExportsOf(exp, visited);\n } else if (e.kind === 'tuple') {\n for (const m of e.members ?? []) scopeNames.add(m);\n } else {\n scopeNames.add(modName);\n }\n };\n for (const d of owningModule.declarations ?? [])\n scopeNames.add(d);\n for (const imp of owningModule.imports ?? [])\n addExportsOf(imp, new Set());\n\n for (const name of scopeNames) {\n if (seenDeclarationNames.has(name)) continue;\n const entry = registry.get(name);\n if (\n !entry ||\n entry.kind === 'ngmodule' ||\n entry.kind === 'tuple'\n )\n continue;\n if (!importedNames.has(name)) {\n const spec = resolveSyntheticImportSpecifier(\n fileName,\n entry,\n importSpecifierByName.get(name),\n );\n if (spec) syntheticImports.set(name, spec);\n }\n const kind = entry.kind === 'pipe' ? 1 : 0;\n const decl: CompileDeclaration = {\n type: new o.WrappedNodeExpr(dependencyLocalName(name)),\n selector: entry.selector || `_unresolved-${name}`,\n kind,\n ...(kind === 1 ? { name: entry.pipeName } : {}),\n };\n if (entry.inputs) {\n decl.inputs = Object.values(entry.inputs).map(\n (i) => i.bindingPropertyName,\n );\n }\n if (entry.outputs) {\n decl.outputs = Object.values(entry.outputs) as string[];\n }\n seenDeclarationNames.add(name);\n declarations.push(decl);\n }\n }\n }\n\n let templateContent = meta.template || '';\n if (!templateContent && meta.templateUrl) {\n try {\n const templatePath = path.resolve(\n path.dirname(fileName),\n meta.templateUrl,\n );\n templateContent = fs.readFileSync(templatePath, 'utf-8');\n resourceDependencies.push(templatePath);\n } catch {\n console.warn(\n `[fast-compile] Could not read template file \"${meta.templateUrl}\" for ${className}`,\n );\n }\n }\n\n if (Array.isArray(meta.styleUrls)) {\n for (const url of meta.styleUrls) {\n try {\n const stylePath = path.resolve(path.dirname(fileName), url);\n const styleContent =\n resolvedStyles?.get(stylePath) ??\n fs.readFileSync(stylePath, 'utf-8');\n meta.styles.push(styleContent);\n resourceDependencies.push(stylePath);\n } catch {\n console.warn(\n `[fast-compile] Could not read style file \"${url}\" for ${className}`,\n );\n }\n }\n }\n\n const styleRange = styleRanges?.get(dec);\n if (resolvedInlineStyles && styleRange) {\n for (let k = 0; k < styleRange.count; k++) {\n const css = resolvedInlineStyles.get(styleRange.start + k);\n if (css !== undefined) meta.styles[k] = css;\n }\n }\n\n // Store resolved resources for metadata inlining\n resolvedResources.set(dec, {\n template: templateContent || undefined,\n styles: meta.styles?.length > 0 ? [...meta.styles] : undefined,\n });\n\n const parsedTemplate = parseTemplate(templateContent, fileName, {\n preserveWhitespaces: meta.preserveWhitespaces,\n enableI18nLegacyMessageIdFormat:\n opts.enableI18nLegacyMessageIdFormat ?? true,\n i18nNormalizeLineEndingsInICUs:\n opts.i18nNormalizeLineEndingsInICUs ?? true,\n });\n\n const ivyInputs: Record<string, unknown> = {};\n if (Array.isArray(meta.inputs)) {\n meta.inputs.forEach((i: string) => (ivyInputs[i] = i));\n } else if (meta.inputs) {\n Object.assign(ivyInputs, meta.inputs);\n }\n Object.assign(ivyInputs, fields.inputs);\n for (const [key, val] of Object.entries(sigs.inputs)) {\n const sigDesc = val as {\n bindingPropertyName?: string;\n required?: boolean;\n transform?: o.Expression | null;\n };\n ivyInputs[key] = {\n classPropertyName: key,\n // Honor the binding name (alias) extracted by detectSignals\n // so `input(null, { alias: 'aria-label' })` registers with\n // the public name `aria-label`, not the class property name.\n bindingPropertyName: sigDesc.bindingPropertyName ?? key,\n isSignal: true,\n required: sigDesc.required || false,\n transformFunction: sigDesc.transform || null,\n };\n }\n const templateErrors = parsedTemplate.errors ?? [];\n if (templateErrors.length > 0) {\n const firstError = templateErrors[0];\n classCompileError = new Error(\n `[fast-compile] Template parse error in ${fileName} (${className}): ${firstError.msg}`,\n );\n return;\n }\n\n // Classes used only inside @defer blocks load through the blocks'\n // dynamic import()s, so they must not also be eager dependencies:\n // that would keep their module in this chunk. Once nothing else\n // references them, the TypeScript strip pass drops their imports.\n const deferDependencies = buildDeferDependencyMap(\n parsedTemplate,\n oxcProgram,\n registry,\n localSelectors,\n );\n if (!isPartial && deferDependencies.deferredImports.size > 0) {\n const importMap = buildImportMap(oxcProgram);\n const metadataDeps: {\n symbolName: string;\n importPath: string;\n isDefaultImport: boolean;\n }[] = [];\n for (let i = declarations.length - 1; i >= 0; i--) {\n const name = declarationName(declarations[i]);\n const info = name !== null ? importMap.get(name) : undefined;\n if (\n name === null ||\n info === undefined ||\n !deferDependencies.deferredImports.has(name)\n ) {\n continue;\n }\n declarations.splice(i, 1);\n metadataDeps.unshift({\n symbolName: name,\n importPath: info.path,\n isDefaultImport: info.isDefault,\n });\n }\n if (metadataDeps.length > 0) {\n deferredMetadataDeps.set(className, metadataDeps);\n }\n }\n\n const componentMeta: CompileMetadata & {\n name: string;\n type: o.R3Reference;\n typeSourceSpan: ParseSourceSpan;\n declarations: CompileDeclaration[];\n template: {\n nodes: o.Node[];\n ngContentSelectors: string[];\n preserveWhitespaces: boolean;\n };\n } = {\n ...meta,\n name: className,\n type: classRef,\n typeSourceSpan,\n declarations,\n template: {\n nodes: parsedTemplate.nodes,\n ngContentSelectors: parsedTemplate.ngContentSelectors,\n preserveWhitespaces: parsedTemplate.preserveWhitespaces,\n },\n styles: [...(meta.styles || []), ...(parsedTemplate.styles || [])],\n inputs: ivyInputs,\n outputs: { ...meta.outputs, ...fields.outputs, ...sigs.outputs },\n viewQueries: [...fields.viewQueries, ...sigs.viewQueries],\n queries: [...fields.contentQueries, ...sigs.contentQueries],\n host: hostMetadata,\n changeDetection: meta.changeDetection ?? (isPartial ? null : 1),\n encapsulation: meta.encapsulation ?? 0,\n exportAs: meta.exportAs,\n providers: providersToExpr(meta.providers),\n viewProviders: providersToExpr(meta.viewProviders),\n animations: meta.animations?.length\n ? new o.LiteralArrayExpr(meta.animations)\n : null,\n isStandalone: meta.standalone,\n imports: meta.imports,\n lifecycle: { usesOnChanges: false },\n // Angular v19/v20's `createComponentDefinitionMap` reads\n // `meta.interpolation.start` and `meta.interpolation.end`\n // unconditionally (the `!== DEFAULT_INTERPOLATION_CONFIG` check\n // is reference-equality, so a missing field enters the block\n // and crashes with `Cannot read properties of undefined`). v21\n // dropped the field from `createComponentDefinitionMap`\n // entirely. Use the v19/v20 singleton when the Angular package\n // exports it (matches the reference-equality check, skipping\n // the partial-mode emission block) and fall back to a plain\n // shape on v21+ where the field is ignored anyway.\n interpolation: (\n o as {\n DEFAULT_INTERPOLATION_CONFIG?: { start: string; end: string };\n }\n ).DEFAULT_INTERPOLATION_CONFIG ?? { start: '{{', end: '}}' },\n usesInheritance,\n defer: {\n mode: 0,\n blocks: deferDependencies.blocks,\n },\n declarationListEmitMode: 1,\n i18nUseExternalIds: opts.i18nUseExternalIds ?? false,\n relativeContextFilePath: fileName,\n controlCreate: null,\n hasDirectiveDependencies:\n declarations.length > 0 ||\n (Array.isArray(meta.imports) && meta.imports.length > 0),\n };\n\n if (isPartial) {\n // Partial compilation accesses .inputs, .outputs, .exportAs on\n // each declaration — ensure they are arrays (not undefined).\n componentMeta.declarations = declarations.map((d) => ({\n ...d,\n inputs: d.inputs ?? null,\n outputs: d.outputs ?? null,\n exportAs: d.exportAs ?? null,\n isComponent: d.isComponent ?? false,\n }));\n const cmp = compileDeclareComponentFromMetadata(\n componentMeta,\n parsedTemplate,\n {\n content: templateContent,\n sourceUrl: fileName,\n isInline: !meta.templateUrl,\n inlineTemplateLiteralExpression: null,\n },\n );\n ivyCode.push(\n `static ɵcmp = /*@__PURE__*/ ${emitAngularExpr(cmp.expression)}`,\n );\n } else {\n const cmp = compileComponentFromMetadata(\n componentMeta,\n constantPool,\n bindingParser!,\n );\n ivyCode.push(\n `static ɵcmp = /*@__PURE__*/ ${emitAngularExpr(cmp.expression)}`,\n );\n }\n break;\n }\n\n case 'Directive': {\n targetType = FactoryTarget.Directive;\n // Build proper input descriptors (same as Component path)\n const dirInputs: Record<string, unknown> = {};\n if (Array.isArray(meta.inputs)) {\n meta.inputs.forEach((i: string) => (dirInputs[i] = i));\n } else if (meta.inputs) {\n Object.assign(dirInputs, meta.inputs);\n }\n Object.assign(dirInputs, fields.inputs);\n for (const [key, val] of Object.entries(sigs.inputs)) {\n const sigDesc = val as {\n bindingPropertyName?: string;\n required?: boolean;\n transform?: o.Expression | null;\n };\n dirInputs[key] = {\n classPropertyName: key,\n // Honor the binding name (alias) extracted by detectSignals.\n bindingPropertyName: sigDesc.bindingPropertyName ?? key,\n isSignal: true,\n required: sigDesc.required || false,\n transformFunction: sigDesc.transform || null,\n };\n }\n const directiveMeta = {\n ...meta,\n // Abstract base directives are declared as `@Directive()` with\n // no metadata. Angular's R3DirectiveMetadata accepts\n // `selector: string | null`, but the downstream selector parser\n // calls `.replace()` on the value and crashes on `undefined`.\n // Coerce missing selectors to `null` so abstract base classes\n // compile correctly.\n selector: meta.selector ?? null,\n name: className,\n type: classRef,\n typeSourceSpan,\n host: hostMetadata,\n inputs: dirInputs,\n outputs: { ...meta.outputs, ...fields.outputs, ...sigs.outputs },\n viewQueries: [...fields.viewQueries, ...sigs.viewQueries],\n queries: [...fields.contentQueries, ...sigs.contentQueries],\n // Angular's compiler treats `providers` as an Expression and\n // emits `ɵɵProvidersFeature(<expr>)` whenever it is truthy.\n // `providersToExpr` lowers an inline array literal to a\n // LiteralArrayExpr (matching the Component branch) and passes a\n // const/spread reference through by value — returning `null`\n // when there are no providers so Angular skips the feature\n // entirely. Passing the bare JS array would otherwise be lowered\n // to `null` and crash Angular at runtime in `resolveProvider`.\n providers: providersToExpr(meta.providers),\n exportAs: meta.exportAs,\n isStandalone: meta.standalone,\n lifecycle: { usesOnChanges: false },\n usesInheritance,\n controlCreate: null,\n };\n if (isPartial) {\n const dir = compileDeclareDirectiveFromMetadata(directiveMeta);\n ivyCode.push(\n `static ɵdir = /*@__PURE__*/ ${emitAngularExpr(dir.expression)}`,\n );\n } else {\n const dir = compileDirectiveFromMetadata(\n directiveMeta,\n constantPool,\n bindingParser!,\n );\n ivyCode.push(\n `static ɵdir = /*@__PURE__*/ ${emitAngularExpr(dir.expression)}`,\n );\n }\n break;\n }\n\n case 'Pipe': {\n targetType = FactoryTarget.Pipe;\n const pipeMeta = {\n ...meta,\n name: className,\n pipeName: meta.name,\n type: classRef,\n isStandalone: meta.standalone,\n pure: meta.pure ?? true,\n };\n if (isPartial) {\n const pipe = compileDeclarePipeFromMetadata(pipeMeta);\n ivyCode.push(\n `static ɵpipe = /*@__PURE__*/ ${emitAngularExpr(pipe.expression)}`,\n );\n } else {\n const pipe = compilePipeFromMetadata(pipeMeta);\n ivyCode.push(\n `static ɵpipe = /*@__PURE__*/ ${emitAngularExpr(pipe.expression)}`,\n );\n }\n break;\n }\n\n case 'Injectable': {\n targetType = FactoryTarget.Injectable;\n const injectableMeta: any = {\n name: className,\n type: classRef,\n typeArgumentCount: 0,\n providedIn: {\n expression: new o.LiteralExpr(meta.providedIn ?? null),\n forwardRef: 0,\n },\n };\n // Forward provider configuration so `ɵprov` honors useFactory/\n // useClass/useExisting/useValue. Without this, an\n // `@Injectable({ useFactory: () => ... })` quietly falls back\n // to constructor instantiation.\n if (meta.useClass) injectableMeta.useClass = meta.useClass;\n if (meta.useFactory) injectableMeta.useFactory = meta.useFactory;\n if (meta.useExisting) injectableMeta.useExisting = meta.useExisting;\n if (meta.useValue) injectableMeta.useValue = meta.useValue;\n // Dependency list for `useFactory` / `useClass`; without it the\n // emitted factory is invoked with no arguments.\n if (meta.deps) injectableMeta.deps = meta.deps;\n if (isPartial) {\n const inj = compileDeclareInjectableFromMetadata(injectableMeta);\n ivyCode.push(\n `static ɵprov = /*@__PURE__*/ ${emitAngularExpr(inj.expression)}`,\n );\n } else {\n const inj = o.compileInjectable(injectableMeta, true);\n ivyCode.push(\n `static ɵprov = /*@__PURE__*/ ${emitAngularExpr(inj.expression)}`,\n );\n }\n break;\n }\n\n case 'Service': {\n // `@Service` (and the `compileService` compiler API) landed in\n // Angular 22. On older peers the decorator does not exist; fail\n // loudly rather than falling through and emitting a default\n // `Injectable`-target factory with no `ɵprov`.\n if (!angularVersionAtLeast(22)) {\n classCompileError = new Error(\n `[fast-compile] @Service on ${className} requires Angular 22 or later`,\n );\n break;\n }\n targetType = (FactoryTarget as any).Service;\n const serviceMeta: any = {\n name: className,\n type: classRef,\n typeArgumentCount: 0,\n };\n if (meta.autoProvided === false) serviceMeta.autoProvided = false;\n if (meta.factory) serviceMeta.factory = meta.factory;\n if (isPartial) {\n const svc = (o as any).compileDeclareServiceFromMetadata(\n serviceMeta,\n );\n ivyCode.push(\n `static ɵprov = /*@__PURE__*/ ${emitAngularExpr(svc.expression)}`,\n );\n } else {\n const svc = (o as any).compileService(serviceMeta, false);\n ivyCode.push(\n `static ɵprov = /*@__PURE__*/ ${emitAngularExpr(svc.expression)}`,\n );\n }\n break;\n }\n\n case 'NgModule': {\n targetType = FactoryTarget.NgModule;\n const ngModuleImports = Array.isArray(meta.imports)\n ? meta.imports\n : [];\n const ngModuleDeclarations = Array.isArray(meta.declarations)\n ? meta.declarations\n : [];\n const ngModuleExports = Array.isArray(meta.exports)\n ? meta.exports\n : [];\n const ngModuleBootstrap = Array.isArray(meta.bootstrap)\n ? meta.bootstrap\n : [];\n\n const ngModuleMeta = {\n kind: R3NgModuleMetadataKind.Global as const,\n type: classRef,\n bootstrap: ngModuleBootstrap.map((e: o.WrappedNodeExpr<any>) => ({\n value: e,\n type: e,\n })),\n declarations: ngModuleDeclarations.map(\n (e: o.WrappedNodeExpr<any>) => ({ value: e, type: e }),\n ),\n publicDeclarationTypes: null,\n imports: ngModuleImports.map((e: o.WrappedNodeExpr<any>) => ({\n value: e,\n type: e,\n })),\n includeImportTypes: true,\n exports: ngModuleExports.map((e: o.WrappedNodeExpr<any>) => ({\n value: e,\n type: e,\n })),\n selectorScopeMode: R3SelectorScopeMode.Inline,\n containsForwardDecls: false,\n schemas: [],\n id: null,\n };\n const injectorMeta = {\n name: className,\n type: classRef,\n providers: providersToExpr(meta.providers),\n imports: ngModuleImports.map((e: o.WrappedNodeExpr<any>) => e),\n };\n if (isPartial) {\n const ngMod = compileDeclareNgModuleFromMetadata(ngModuleMeta);\n ivyCode.push(\n `static ɵmod = /*@__PURE__*/ ${emitAngularExpr(ngMod.expression)}`,\n );\n const injector = compileDeclareInjectorFromMetadata(injectorMeta);\n ivyCode.push(\n `static ɵinj = /*@__PURE__*/ ${emitAngularExpr(injector.expression)}`,\n );\n } else {\n const ngMod = compileNgModule(ngModuleMeta);\n ivyCode.push(\n `static ɵmod = /*@__PURE__*/ ${emitAngularExpr(ngMod.expression)}`,\n );\n const injector = compileInjector(injectorMeta);\n ivyCode.push(\n `static ɵinj = /*@__PURE__*/ ${emitAngularExpr(injector.expression)}`,\n );\n }\n break;\n }\n }\n });\n\n if (classCompileError) {\n throw classCompileError;\n }\n\n // Generate factory\n const deps = extractConstructorDeps(node, sourceCode, typeOnlyImports);\n if (deps === null) {\n const baseVar = `ɵ${className}_BaseFactory`;\n ivyCode.unshift(\n `static ɵfac = /*@__PURE__*/ (() => { let ${baseVar}; return function ${className}_Factory(__ngFactoryType__) { return (${baseVar} || (${baseVar} = i0.ɵɵgetInheritedFactory(${className})))(__ngFactoryType__ || ${className}); }; })()`,\n );\n } else if (deps === 'invalid') {\n ivyCode.unshift(\n `static ɵfac = function ${className}_Factory(__ngFactoryType__) { i0.ɵɵinvalidFactory(); }`,\n );\n } else {\n const factoryMeta = {\n name: className,\n type: classRef,\n typeArgumentCount: 0,\n deps,\n target: targetType,\n };\n if (isPartial) {\n const fac = compileDeclareFactoryFunction(factoryMeta);\n ivyCode.unshift(\n `static ɵfac = /*@__PURE__*/ ${emitAngularExpr(fac.expression)}`,\n );\n } else {\n const fac = compileFactoryFunction(factoryMeta);\n ivyCode.unshift(\n `static ɵfac = /*@__PURE__*/ ${emitAngularExpr(fac.expression)}`,\n );\n }\n }\n\n // Emit setClassMetadata for runtime decorator reflection (devMode only)\n const ctorParameters = buildCtorParameters(\n node,\n sourceCode,\n typeOnlyImports,\n );\n const propDecorators = buildPropDecorators(node, sourceCode, 'i0.');\n const scopedMetadata: o.Statement[] = [];\n angularDecorators.forEach((dec) => {\n const decName = decoratorCallName(dec, sourceCode)!;\n const decArgsNode = dec.expression.arguments[0];\n const textOf = (n: any) => sourceCode.slice(n.start, n.end);\n\n // Build the decorator args for setClassMetadata, inlining resources if needed.\n const resources = resolvedResources.get(dec);\n let metadataArgsExpr: string | null = null;\n if (decArgsNode) {\n if (resources && decArgsNode.type === 'ObjectExpression') {\n // Inline external templateUrl/styleUrl(s) into the metadata so Angular's\n // runtime doesn't try to fetch relative URLs (which fails during SSR).\n const rewrittenProps: string[] = [];\n let needsTransform = false;\n for (const prop of decArgsNode.properties) {\n if (\n prop.type !== 'Property' ||\n prop.shorthand ||\n prop.method ||\n prop.kind !== 'init'\n ) {\n rewrittenProps.push(textOf(prop));\n continue;\n }\n const propName = textOf(prop.key);\n\n if (propName === 'templateUrl' && resources.template) {\n rewrittenProps.push(\n `template: ${JSON.stringify(resources.template)}`,\n );\n needsTransform = true;\n } else if (\n (propName === 'styleUrl' || propName === 'styleUrls') &&\n resources.styles?.length\n ) {\n rewrittenProps.push(\n `styles: [${resources.styles.map((s) => JSON.stringify(s)).join(', ')}]`,\n );\n needsTransform = true;\n } else {\n rewrittenProps.push(textOf(prop));\n }\n }\n metadataArgsExpr = needsTransform\n ? `{${rewrittenProps.join(', ')}}`\n : textOf(decArgsNode);\n } else {\n metadataArgsExpr = textOf(decArgsNode);\n }\n }\n\n try {\n // `LiteralMapPropertyAssignment` was a class with a constructor in\n // Angular up through ~v19, removed-then-restored in later v20/v21\n // patches. The only stable shape across versions is the plain\n // `{ key, value, quoted }` object literal — Angular's own emitter\n // and Analog's `JSEmitter` both consume entries via duck typing\n // (`.key` / `.value` / `.quoted`), and `compileClassMetadata` does\n // not `instanceof`-check entries. The js-emitter has a matching\n // comment at the consumption site. Using `new o.LiteralMapProperty\n // Assignment(...)` would throw \"is not a constructor\" on Angular\n // versions where the class export is missing (e.g. 20.3.x), and\n // the surrounding try/catch would silently disable class metadata\n // emission for every class in the project.\n const classMetaInput = {\n type: new o.WrappedNodeExpr(className),\n decorators: new o.LiteralArrayExpr([\n new o.LiteralMapExpr([\n {\n key: 'type',\n value: new o.WrappedNodeExpr(decName),\n quoted: false,\n },\n ...(metadataArgsExpr\n ? [\n {\n key: 'args',\n value: new o.LiteralArrayExpr([\n new o.WrappedNodeExpr(metadataArgsExpr),\n ]),\n quoted: false,\n },\n ]\n : []),\n ] as unknown as o.LiteralMapPropertyAssignment[]),\n ]),\n ctorParameters: ctorParameters\n ? new o.WrappedNodeExpr(`() => [${ctorParameters}]`)\n : null,\n propDecorators: propDecorators\n ? new o.WrappedNodeExpr(propDecorators)\n : null,\n };\n // A component whose @defer blocks load some dependencies lazily must\n // not reference them eagerly in its metadata either.\n const deferredDeps =\n decName === 'Component'\n ? deferredMetadataDeps.get(className)\n : undefined;\n const classMetadataExpr = isPartial\n ? compileDeclareClassMetadata(classMetaInput)\n : deferredDeps\n ? compileComponentClassMetadata(classMetaInput, deferredDeps)\n : compileClassMetadata(classMetaInput);\n const metadataStmt = new o.ExpressionStatement(classMetadataExpr);\n if (topLevelClasses.has(node)) {\n constantPool.statements.push(metadataStmt);\n } else {\n scopedMetadata.push(metadataStmt);\n }\n } catch (e) {\n // Skip if compileClassMetadata fails — surfaced via DEBUG=analog-fast-compile\n if (debugCompile.enabled) {\n debugCompile(\n 'compileClassMetadata failed for %s in %s: %s',\n className,\n fileName,\n (e as Error)?.message,\n );\n }\n }\n });\n\n // Collect member decorators (@HostListener, @HostBinding, @Input, @Output,\n // @ViewChild, @ContentChild, etc.) so they are removed from the source.\n // The metadata has already been extracted by detectFieldDecorators().\n const memberDecorators: any[] = [];\n for (const member of node.body.body) {\n for (const dec of member.decorators ?? []) {\n if (FIELD_DECORATORS.has(decoratorCallName(dec, sourceCode) ?? '')) {\n memberDecorators.push(dec);\n }\n }\n }\n\n classResults.push({\n ivyCode,\n decorators: [...angularDecorators, ...memberDecorators],\n classEnd: node.end,\n scopedMetadata,\n });\n }\n\n // Apply edits via MagicString\n const ms = new MagicString(sourceCode, { filename: fileName });\n\n // 1. Prepend i0 import (skip if already present)\n if (!sourceCode.includes('import * as i0 from')) {\n ms.prepend('import * as i0 from \"@angular/core\";\\n');\n }\n\n // 1b. Inject synthetic imports for NgModule-exported classes\n for (const [name, specifier] of syntheticImports) {\n const localName = dependencyLocalName(name);\n if (!importedNames.has(localName)) {\n const binding = localName === name ? name : `${name} as ${localName}`;\n ms.prepend(`import { ${binding} } from \"${specifier}\";\\n`);\n importedNames.add(localName);\n }\n }\n\n // 2a. Hoist non-exported variable/function declarations that appear after\n // a class to just before the first class. This avoids TDZ errors when\n // static ɵcmp references file-level constants declared after the class.\n //\n // We must NOT hoist a statement whose initializer references a name\n // (class, exported const/let) that is defined between firstClassPos and\n // the statement itself — doing so would move the reference before the\n // definition and cause a TDZ error at runtime.\n if (classResults.length > 0) {\n // Find the position right before the first class (any class, not just Angular-decorated)\n const statements = (oxcProgram.body as any[]).map(toTopLevelStatement);\n let firstClassPos = Infinity;\n const nonHoistableNames = new Set<string>();\n for (const { decl, start } of statements) {\n if (decl.type === 'ClassDeclaration') {\n firstClassPos = start;\n // The first class itself is non-hoistable — statements hoisted\n // before it must not reference it.\n if (decl.id) {\n nonHoistableNames.add(decl.id.name);\n }\n break;\n }\n }\n\n // Pass 1: collect names defined by statements that will NOT be hoisted\n // (classes, enums, exported vars/functions) and therefore remain after\n // firstClassPos.\n for (const { decl, exported, start } of statements) {\n if (start <= firstClassPos) continue;\n\n if (\n decl.type === 'ClassDeclaration' ||\n decl.type === 'TSEnumDeclaration'\n ) {\n if (decl.id) nonHoistableNames.add(decl.id.name);\n } else if (\n exported &&\n (decl.type === 'VariableDeclaration' ||\n decl.type === 'FunctionDeclaration')\n ) {\n for (const n of getDefinedNames(decl)) {\n nonHoistableNames.add(n);\n }\n }\n }\n\n // Pass 2: for each hoist candidate, check if it references any\n // non-hoistable name. If it does, skip it and add its own names to the\n // non-hoistable set (transitivity).\n for (const { decl, exported, start, end } of statements) {\n if (start <= firstClassPos) continue;\n\n const isCandidate =\n !exported &&\n (decl.type === 'VariableDeclaration' ||\n decl.type === 'FunctionDeclaration');\n if (!isCandidate) continue;\n\n const referencedIds = collectIdentifiers(decl);\n let referencesNonHoistable = false;\n for (const id of referencedIds) {\n if (nonHoistableNames.has(id)) {\n referencesNonHoistable = true;\n break;\n }\n }\n\n if (referencesNonHoistable) {\n // Don't hoist — mark this statement's names as non-hoistable too\n for (const name of getDefinedNames(decl)) {\n nonHoistableNames.add(name);\n }\n } else {\n // Move rather than re-insert so the statement keeps its source map.\n // The separating newline is attached to the moved chunk.\n ms.appendLeft(end, '\\n');\n ms.move(start, end, firstClassPos);\n }\n }\n }\n\n // 2. For each compiled class: remove decorators + insert Ivy definitions\n for (const cr of classResults) {\n // Remove Angular decorators from source\n for (const dec of cr.decorators) {\n const start = dec.start;\n const end = dec.end;\n let trimEnd = end;\n while (\n trimEnd < sourceCode.length &&\n (sourceCode[trimEnd] === ' ' ||\n sourceCode[trimEnd] === '\\n' ||\n sourceCode[trimEnd] === '\\r')\n ) {\n trimEnd++;\n }\n ms.remove(start, trimEnd);\n }\n\n // Insert static members before closing }\n if (cr.ivyCode.length > 0) {\n const memberCode = cr.ivyCode.map((c) => ' ' + c + ';').join('\\n');\n ms.appendLeft(cr.classEnd - 1, '\\n' + memberCode + '\\n');\n }\n\n for (const stmt of cr.scopedMetadata) {\n ms.appendLeft(cr.classEnd, `\\n/*@__PURE__*/ ${emitAngularStmt(stmt)}`);\n }\n }\n\n // 3. Emit constant pool statements.\n // Split into: helper declarations (const/function) that must appear before\n // the class (since static property initializers reference them), and\n // side-effect statements (setClassMetadata IIFEs) that go after.\n const helpers: string[] = [];\n const sideEffects: string[] = [];\n for (const s of constantPool.statements) {\n const code = emitAngularStmt(s);\n if (\n s instanceof o.ExpressionStatement &&\n s.expr instanceof o.InvokeFunctionExpr\n ) {\n // setClassMetadata is wrapped in `(() => { ... })()` — annotate\n // the IIFE call so bundlers can drop it when ngDevMode is folded\n // to false at production build time.\n sideEffects.push(`/*@__PURE__*/ ${code}`);\n } else {\n helpers.push(code);\n }\n }\n\n if (sideEffects.length > 0) {\n ms.append('\\n\\n' + sideEffects.join('\\n'));\n }\n\n // 4. Lower class field initializers to constructor assignments when\n // useDefineForClassFields is false (standard Angular tsconfig).\n // Uses the original OXC AST positions which are still valid for MagicString\n // since MagicString tracks edits relative to the original source.\n // Ivy static definitions (ɵcmp, ɵfac) are not in the original AST so they\n // are unaffected, and shouldLowerField skips static fields regardless.\n if (!useDefineForClassFields) {\n lowerClassFields(ms, sourceCode, oxcProgram);\n }\n\n // 5. Elide imports that are only used in type positions (type annotations,\n // implements, generics, etc.). Without this pass, single-file transpilers\n // like OXC / esbuild cannot tell that `import { SomeType }` is type-only\n // and will leave the import in the output, causing runtime errors.\n // Detection runs once on the final output; helpers are appended for\n // analysis only, since their position does not affect references.\n const helperCode = helpers.join('\\n');\n const willElide = detectTypeOnlyImportNames(\n ms.toString() + '\\n' + helperCode,\n );\n if (helpers.length > 0) {\n // Insert helpers after the last import / top-level non-class statement,\n // well before any class that references them. Skip imports that will be\n // fully removed by type elision (step 5): inserting inside a\n // soon-to-be-removed range would discard the helpers with the import.\n let insertPos = 0;\n for (const stmt of oxcProgram.body as any[]) {\n const { decl } = toTopLevelStatement(stmt);\n if (stmt.type === 'ImportDeclaration') {\n // Skip imports that will be entirely removed by type elision\n if (willElide.size > 0 && stmt.specifiers.length > 0) {\n const allElided = stmt.specifiers.every(\n (spec: any) =>\n spec.type === 'ImportNamespaceSpecifier' ||\n spec.importKind === 'type' ||\n willElide.has(spec.local.name),\n );\n if (allElided) continue;\n }\n insertPos = stmt.end;\n } else if (\n decl.type === 'VariableDeclaration' &&\n !sourceCode.slice(stmt.start, stmt.end).includes('class')\n ) {\n insertPos = stmt.end;\n } else if (\n stmt.type !== 'TSExportAssignment' &&\n !(\n stmt.type === 'ExportDefaultDeclaration' &&\n decl.type !== 'ClassDeclaration' &&\n decl.type !== 'FunctionDeclaration'\n )\n ) {\n // Stop at the first class or non-import/non-variable statement\n break;\n }\n }\n // Helpers must survive downstream `ms.overwrite()` / `ms.remove()` of\n // imports performed by the type-only specifier elision pass (step 5).\n //\n // Case `insertPos > 0`: a surviving import ends at `insertPos`. Use\n // `appendRight(insertPos, …)` so helpers bind to the `\\n` after the\n // import's `;` — outside any overwrite range `[node.start, node.end)`\n // of a preceding import. `appendLeft(insertPos, …)` would bind to the\n // `;` itself, which IS inside the overwrite range and would be wiped.\n //\n // Case `insertPos === 0`: no import survives — every import is going\n // to be elided, and `elideTypeOnlyImportsMagicString` will\n // `ms.remove(0, declEnd)` the first one. `appendRight(0, …)` anchors\n // to the character at position 0 (the first import's first char),\n // which is inside `[0, declEnd)` and gets wiped. Use `appendLeft(0, …)`\n // instead — it anchors to the LEFT of position 0, outside any range\n // starting at 0, so the helpers survive. Ordering is still correct\n // because the i0 import prepended in step 1 lives in MagicString's\n // `intro` (from `ms.prepend`), which always emits before any\n // `appendLeft` content at position 0.\n if (insertPos === 0) {\n ms.appendLeft(0, helperCode + '\\n');\n } else {\n ms.appendRight(insertPos, '\\n' + helperCode + '\\n');\n }\n }\n elideTypeOnlyImportsMagicString(ms, oxcProgram, willElide);\n\n const map = ms.generateMap({\n source: fileName,\n file: fileName + '.js',\n includeContent: true,\n hires: 'boundary',\n });\n\n if (debugCompile.enabled) {\n debugCompile(\n 'compile %s done (%dms, %d classes, %d resource deps)',\n fileName,\n Math.round(performance.now() - startTimeMs),\n classResults.length,\n resourceDependencies.length,\n );\n }\n return {\n code: ms.toString(),\n map,\n resourceDependencies,\n };\n}\n\n/** The local class name an `imports` entry declares, when it is a plain identifier. */\nfunction declarationName(declaration: CompileDeclaration): string | null {\n const node = (declaration.type as { node?: unknown }).node as\n | string\n | { type?: string; name?: string }\n | undefined;\n if (typeof node === 'string') {\n return node;\n }\n if (node?.type === 'Identifier' && typeof node.name === 'string') {\n return node.name;\n }\n return declaration.className ?? null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyIA,SAAS,oBAAoB,MAA8B;CACzD,MAAM,YACH,KAAK,SAAS,4BACb,KAAK,SAAS,+BAChB,KAAK;CACP,MAAM,OAAO,WAAW,KAAK,cAAc;CAC3C,OAAO;EACL;EACA,UAAU,CAAC,CAAC;EACZ,OAAO,KAAK,IAAI,KAAK,OAAO,KAAK,aAAa,EAAE,EAAE,SAAS,KAAK,KAAK;EACrE,KAAK,KAAK;CACZ;AACF;;AAGA,SAAS,kBAAkB,KAAU,YAAwC;CAC3E,MAAM,SAAS,IAAI;CACnB,IAAI,QAAQ,SAAS,kBAAkB,OAAO,KAAA;CAC9C,OAAO,WAAW,MAAM,OAAO,OAAO,OAAO,OAAO,OAAO,GAAG;AAChE;;;;;;;;;;;;AAaA,SAAS,gBACP,OACqB;CACrB,IAAI,CAAC,OAAO,OAAO;CACnB,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,SAAS,IAAI,EAAE,iBAAiB,KAAK,IAAI;CAExD,OAAO;AACT;AAEA,IAAM,mCAA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AAgB,aAAgD;CACvE,MAAM,OAAQ,YAAY,KAA4B;CAItD,IAAI,OAAO,SAAS,UAClB,OAAO;CAET,IAAI,MAAM,SAAS,gBAAgB,OAAO,KAAK,SAAS,UACtD,OAAO,KAAK;CAEd,OAAO,YAAY,aAAa;AAClC"}
1
+ {"version":3,"file":"compile.js","names":[],"sources":["../../../../src/lib/compiler/compile.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as o from '@angular/compiler';\nimport MagicString from 'magic-string';\nimport type { parseSync } from 'oxc-parser';\nimport { parseOxc } from './utils.js';\nimport {\n ConstantPool,\n compileComponentFromMetadata,\n compileDirectiveFromMetadata,\n compilePipeFromMetadata,\n compileNgModule,\n compileInjector,\n R3NgModuleMetadataKind,\n R3SelectorScopeMode,\n FactoryTarget,\n compileFactoryFunction,\n parseTemplate,\n makeBindingParser,\n parseHostBindings,\n ParseSourceFile,\n ParseLocation,\n ParseSourceSpan,\n compileClassMetadata,\n compileComponentClassMetadata,\n compileDeclareComponentFromMetadata,\n compileDeclareDirectiveFromMetadata,\n compileDeclarePipeFromMetadata,\n compileDeclareNgModuleFromMetadata,\n compileDeclareInjectorFromMetadata,\n compileDeclareInjectableFromMetadata,\n compileDeclareFactoryFunction,\n compileDeclareClassMetadata,\n} from '@angular/compiler';\nimport { ComponentRegistry } from './registry.js';\nimport {\n findAllClasses,\n resolveSyntheticImportSpecifier,\n walkOxc,\n} from './utils.js';\nimport { ANGULAR_DECORATORS, FIELD_DECORATORS } from './constants.js';\nimport { angularVersionAtLeast } from './angular-version.js';\nimport {\n detectTypeOnlyImportNames,\n elideTypeOnlyImportsMagicString,\n} from './type-elision.js';\n\nimport {\n emitAngularExpr,\n emitAngularStmt,\n setEmitterSourceCode,\n} from './js-emitter.js';\nimport { lowerClassFields } from './class-field-lowering.js';\nimport {\n extractMetadata,\n collectStringConstants,\n detectSignals,\n detectFieldDecorators,\n extractConstructorDeps,\n} from './metadata.js';\nimport { buildDeferDependencyMap, buildImportMap } from './defer.js';\nimport { buildCtorParameters, buildPropDecorators } from './jit-metadata.js';\nimport { debugCompile, debugEmit } from './debug.js';\nimport {\n getPropertyKey,\n inlineStyleRanges,\n type InlineStyle,\n type InlineStyleRange,\n} from './style-ast.js';\n\n/**\n * COMPLETE EXHAUSTIVE ANGULAR LITE COMPILER\n * Translates Angular Decorators + Signals to Ivy Static Definitions.\n *\n * @param registry - Optional external registry from the global analysis plugin.\n * When provided, used to resolve component/directive selectors for template compilation.\n */\nexport interface CompileResult {\n code: string;\n /** Source map for the transformation */\n map: ReturnType<MagicString['generateMap']>;\n /** Absolute paths of external resources (templateUrl, styleUrl) read during compilation */\n resourceDependencies: string[];\n}\n\nexport interface CompileOptions {\n registry?: ComponentRegistry;\n /** Pre-resolved style contents keyed by absolute file path (e.g. SCSS already compiled to CSS). */\n resolvedStyles?: Map<string, string>;\n /** Pre-processed inline styles (index in styles array → compiled CSS). */\n resolvedInlineStyles?: Map<number, string>;\n /**\n * When `false` (default), instance class field initializers are lowered to\n * constructor assignments (matching TypeScript's `useDefineForClassFields: false`\n * behavior). This is required for Angular's `inject()` and constructor DI to\n * work correctly with the standard Angular tsconfig.\n */\n useDefineForClassFields?: boolean;\n /** Enable legacy i18n message ID format (default: true). */\n enableI18nLegacyMessageIdFormat?: boolean;\n /** Normalize line endings in ICU expressions (default: true). */\n i18nNormalizeLineEndingsInICUs?: boolean;\n /** Use external IDs in `$localize` calls (for Closure Compiler compatibility). */\n i18nUseExternalIds?: boolean;\n /**\n * Compilation output mode.\n * - `'full'` (default): Emit final Ivy definitions (`ɵɵdefineComponent`) for application builds.\n * - `'partial'`: Emit partial declarations (`ɵɵngDeclareComponent`) for library publishing.\n * Partial output is version-stable and linked at application build time.\n */\n compilationMode?: 'full' | 'partial';\n /**\n * Pre-parsed OXC program of `sourceCode`, so callers that already parsed\n * the identical string can avoid a re-parse. Treated as read-only.\n */\n oxcProgram?: ReturnType<typeof parseSync>['program'];\n}\n\ntype CompileMetadata = ReturnType<typeof extractMetadata>;\n\ntype CompileDeclaration = {\n type: o.Expression;\n selector: string | null;\n className?: string;\n kind: number;\n name?: string;\n inputs?: string[];\n outputs?: string[];\n exportAs?: string[];\n isComponent?: boolean;\n};\n\n/** A top-level statement with any `export` wrapper unwrapped. */\ninterface TopLevelStatement {\n /** The declaration (or the statement itself when not exported). */\n decl: any;\n exported: boolean;\n /** Start of the whole statement, including leading class decorators. */\n start: number;\n end: number;\n}\n\nfunction toTopLevelStatement(stmt: any): TopLevelStatement {\n const isExport =\n (stmt.type === 'ExportNamedDeclaration' ||\n stmt.type === 'ExportDefaultDeclaration') &&\n stmt.declaration;\n const decl = isExport ? stmt.declaration : stmt;\n return {\n decl,\n exported: !!isExport,\n start: Math.min(stmt.start, decl.decorators?.[0]?.start ?? stmt.start),\n end: stmt.end,\n };\n}\n\n/** Get the callee name of a decorator call, e.g. `Component` for `@Component(...)`. */\nfunction decoratorCallName(dec: any, sourceCode: string): string | undefined {\n const callee = dec.expression;\n if (callee?.type !== 'CallExpression') return undefined;\n return sourceCode.slice(callee.callee.start, callee.callee.end);\n}\n\n/** An inline style and the CSS the style pipeline produced for it. */\ninterface ResolvedInlineStyle extends InlineStyle {\n css: string;\n}\n\n/**\n * Pair each inline style of a component with its processed CSS, skipping the\n * ones whose processing failed.\n */\nfunction resolveInlineStyles(\n range: InlineStyleRange | undefined,\n resolvedInlineStyles: Map<number, string> | undefined,\n): ResolvedInlineStyle[] {\n if (!range || !resolvedInlineStyles) return [];\n return range.styles.flatMap((style, k) => {\n const css = resolvedInlineStyles.get(range.start + k);\n return css === undefined ? [] : [{ ...style, css }];\n });\n}\n\n/**\n * Source text of a `styles` value with each resolved inline style replaced by\n * its processed CSS, so the class metadata a TestBed override recompiles from\n * carries the same styles as ɵcmp.\n */\nfunction withResolvedInlineStyles(\n stylesNode: any,\n styles: ResolvedInlineStyle[],\n sourceCode: string,\n): string {\n let text = '';\n let pos = stylesNode.start;\n for (const { node, css } of styles) {\n text += sourceCode.slice(pos, node.start) + JSON.stringify(css);\n pos = node.end;\n }\n return text + sourceCode.slice(pos, stylesNode.end);\n}\n\n/**\n * Normalize a `providers` / `viewProviders` metadata value into the single\n * `o.Expression` Angular's injector/host emitters expect.\n *\n * `extractMetadata` stores these as an array of `WrappedNodeExpr` when the\n * source used an inline array literal (`providers: [A, B]`) — those get\n * wrapped in a `LiteralArrayExpr`. When the source referenced a const,\n * spread, or call instead (`providers: safeProviders`), it stores the raw\n * expression, which is emitted by value. Returns `null` when there is\n * nothing to emit so callers skip the feature entirely.\n */\nfunction providersToExpr(\n value: o.Expression[] | o.Expression | undefined | null,\n): o.Expression | null {\n if (!value) return null;\n if (Array.isArray(value)) {\n return value.length ? new o.LiteralArrayExpr(value) : null;\n }\n return value;\n}\n\nconst LAZY_SCOPE_TYPES = new Set([\n 'FunctionDeclaration',\n 'FunctionExpression',\n 'ArrowFunctionExpression',\n 'ClassDeclaration',\n 'ClassExpression',\n 'TSFunctionType',\n 'TSConstructorType',\n 'TSMethodSignature',\n 'TSCallSignatureDeclaration',\n 'TSConstructSignatureDeclaration',\n]);\n\n/**\n * Collect identifier names referenced in eagerly-evaluated code only.\n * Skips function/arrow/class bodies so that lazy references\n * (e.g. `const TOKEN = () => LaterClass`) are not treated as dependencies.\n * The root node's own children are always walked.\n */\nfunction collectIdentifiers(root: any): Set<string> {\n const ids = new Set<string>();\n walkOxc(root, (n) => {\n if (n.type === 'Identifier') ids.add(n.name);\n return n === root || !LAZY_SCOPE_TYPES.has(n.type);\n });\n return ids;\n}\n\n/** Extract the names defined by a top-level declaration. */\nfunction getDefinedNames(decl: any): string[] {\n if (decl.type === 'VariableDeclaration') {\n const names: string[] = [];\n for (const d of decl.declarations) {\n collectBindingNames(d.id, names);\n }\n return names;\n }\n if (\n (decl.type === 'FunctionDeclaration' || decl.type === 'ClassDeclaration') &&\n decl.id\n ) {\n return [decl.id.name];\n }\n return [];\n}\n\n/** Recursively collect all bound identifiers from a binding pattern. */\nfunction collectBindingNames(pattern: any, out: string[]): void {\n if (!pattern) return;\n switch (pattern.type) {\n case 'Identifier':\n out.push(pattern.name);\n break;\n case 'ObjectPattern':\n for (const prop of pattern.properties) {\n collectBindingNames(\n prop.type === 'RestElement' ? prop.argument : prop.value,\n out,\n );\n }\n break;\n case 'ArrayPattern':\n for (const el of pattern.elements) collectBindingNames(el, out);\n break;\n case 'RestElement':\n collectBindingNames(pattern.argument, out);\n break;\n case 'AssignmentPattern':\n collectBindingNames(pattern.left, out);\n break;\n }\n}\n\nexport function compile(\n sourceCode: string,\n fileName: string,\n optionsOrRegistry?: CompileOptions | ComponentRegistry,\n): CompileResult {\n // Backward compat: accept ComponentRegistry directly\n const opts: CompileOptions =\n optionsOrRegistry instanceof Map\n ? { registry: optionsOrRegistry }\n : optionsOrRegistry || {};\n const registry = opts.registry;\n const resolvedStyles = opts.resolvedStyles;\n const resolvedInlineStyles = opts.resolvedInlineStyles;\n const useDefineForClassFields = opts.useDefineForClassFields ?? false;\n const isPartial = opts.compilationMode === 'partial';\n const startTimeMs = debugCompile.enabled ? performance.now() : 0;\n debugCompile(\n 'compile %s (mode=%s, registry=%d entries)',\n fileName,\n isPartial ? 'partial' : 'full',\n registry?.size ?? 0,\n );\n const oxcProgram = opts.oxcProgram ?? parseOxc(fileName, sourceCode).program;\n const styleRanges = resolvedInlineStyles && inlineStyleRanges(oxcProgram);\n const oxcClassMap = new Map<string, any>();\n for (const stmt of oxcProgram.body) {\n const decl =\n stmt.type === 'ExportNamedDeclaration' ||\n stmt.type === 'ExportDefaultDeclaration'\n ? (stmt as any).declaration\n : stmt;\n if (\n decl &&\n (decl.type === 'ClassDeclaration' || decl.type === 'ClassExpression') &&\n decl.id?.name\n ) {\n oxcClassMap.set(decl.id.name, decl);\n }\n }\n\n // Collect module-level string constants so decorator metadata can resolve\n // template-literal interpolations like `template: \\`<div class=\"${tw}\">x</div>\\``.\n const stringConsts = collectStringConstants(oxcProgram);\n\n const constantPool = new ConstantPool();\n const resourceDependencies: string[] = [];\n const parseFile = new ParseSourceFile(sourceCode, fileName);\n const parseLoc = new ParseLocation(parseFile, 0, 0, 0);\n const typeSourceSpan = new ParseSourceSpan(parseLoc, parseLoc);\n const typeOnlyImports = detectTypeOnlyImportNames(sourceCode, oxcProgram);\n const importSpecifierByName = new Map<string, string>();\n const importedNames = new Set<string>();\n const typeOnlyImportedNames = new Set<string>();\n\n for (const stmt of oxcProgram.body as any[]) {\n if (stmt.type !== 'ImportDeclaration') continue;\n\n const moduleSpecifier: string = stmt.source.value;\n // Explicit `import type { X }` — declaration-level type-only import\n const isDeclarationTypeOnly = stmt.importKind === 'type';\n for (const element of stmt.specifiers) {\n if (element.type !== 'ImportSpecifier') continue;\n const localName: string = element.local.name;\n importSpecifierByName.set(localName, moduleSpecifier);\n // Explicit `import { type X }` — specifier-level type-only import.\n // Both forms erase the symbol at runtime, so they cannot be used as\n // DI tokens. Add them to typeOnlyImports so extractConstructorDeps\n // surfaces ɵɵinvalidFactory() instead of emitting a broken\n // ɵɵdirectiveInject(X) referring to a non-existent value.\n if (isDeclarationTypeOnly || element.importKind === 'type') {\n typeOnlyImports.add(localName);\n typeOnlyImportedNames.add(localName);\n } else {\n importedNames.add(localName);\n }\n }\n }\n\n // Build a file-local selector map as fallback when no external registry is provided.\n // Skip the expensive extractMetadata scan when a registry covers all classes.\n const localSelectors = new Map<string, string>();\n /**\n * Per component class: the dependencies only its @defer blocks use, which\n * its class metadata must load lazily (`ɵsetClassMetadataAsync`).\n */\n const deferredMetadataDeps = new Map<\n string,\n { symbolName: string; importPath: string; isDefaultImport: boolean }[]\n >();\n if (!registry) {\n for (const [clsName, oxcNode] of oxcClassMap) {\n const decs: any[] = oxcNode.decorators || [];\n if (decs.length > 0) {\n const meta = extractMetadata(decs[0], sourceCode, stringConsts);\n if (meta?.selector) {\n localSelectors.set(clsName, meta.selector.split(',')[0].trim());\n }\n }\n }\n }\n\n const bindingParser = isPartial ? undefined : makeBindingParser();\n setEmitterSourceCode(sourceCode);\n\n // --- Direct walk: compile each Angular-decorated class and collect string outputs ---\n interface ClassCompileResult {\n ivyCode: string[]; // \"static ɵfac = ...\", \"static ɵcmp = ...\", etc.\n decorators: any[]; // Angular decorators to remove (OXC nodes)\n classEnd: number; // Position of closing } in original source\n // setClassMetadata calls for classes nested in a function scope, which\n // must be emitted next to the class rather than at module scope.\n scopedMetadata: o.Statement[];\n }\n const classResults: ClassCompileResult[] = [];\n const topLevelClasses = new Set(\n (oxcProgram.body as any[]).map((stmt) => toTopLevelStatement(stmt).decl),\n );\n // Track synthetic imports needed for NgModule export expansion.\n // Maps exported class name → import specifier.\n const syntheticImports = new Map<string, string>();\n // A type-only import is erased at runtime, so its synthetic value import\n // needs an alias to avoid redeclaring the type-only binding.\n const dependencyLocalName = (name: string) =>\n typeOnlyImportedNames.has(name) ? `ɵngDep_${name}` : name;\n\n // ANGULAR_DECORATORS imported from utils\n\n for (const node of findAllClasses(oxcProgram)) {\n const decorators: any[] = node.decorators;\n if (!decorators || decorators.length === 0) continue;\n\n const className: string | undefined = node.id?.name;\n if (!className) continue;\n\n const angularDecorators = decorators.filter((dec) =>\n ANGULAR_DECORATORS.has(decoratorCallName(dec, sourceCode) ?? ''),\n );\n if (angularDecorators.length === 0) continue;\n\n const ivyCode: string[] = [];\n let targetType: FactoryTarget = FactoryTarget.Injectable;\n // Store resolved resources per decorator for metadata inlining\n const resolvedResources = new Map<\n any,\n { template?: string; styles?: string[] }\n >();\n\n const classRef: o.R3Reference = {\n value: new o.WrappedNodeExpr(className),\n type: new o.WrappedNodeExpr(className),\n };\n\n // Detect `class Foo extends Bar` so the directive/component def\n // gets `usesInheritance: true`. Angular's compiler turns that into\n // `features: [InheritDefinitionFeature]`, which is what causes the\n // runtime to merge inputs/outputs/queries/host bindings from the\n // base class. Without it, derived directives like\n // `BrnPopover extends BrnDialog` lose every input declared on the\n // base, and any host directive that references those inputs by\n // public name fails at runtime with NG0311.\n const usesInheritance = !!node.superClass;\n\n let classCompileError: Error | null = null;\n\n angularDecorators.forEach((dec) => {\n const decoratorName = decoratorCallName(dec, sourceCode)!;\n const meta = extractMetadata(dec, sourceCode, stringConsts);\n const sigs = detectSignals(node, sourceCode);\n const fields = detectFieldDecorators(node, sourceCode);\n const hostBindings = parseHostBindings(meta.hostRaw || {});\n\n const hostMetadata: o.R3HostMetadata = {\n attributes: hostBindings.attributes,\n listeners: { ...hostBindings.listeners, ...fields.hostListeners },\n properties: { ...hostBindings.properties, ...fields.hostProperties },\n specialAttributes: hostBindings.specialAttributes,\n };\n\n switch (decoratorName) {\n case 'Component': {\n targetType = FactoryTarget.Component;\n if (!meta.selector) {\n meta.selector = `ng-component-${className.toLowerCase()}`;\n }\n\n const declarations: CompileDeclaration[] = [];\n // Dedupe by class name across direct imports, tuple-barrel\n // expansion, and NgModule export expansion so the final\n // `dependencies: () => [...]` list never contains the same\n // class twice. Otherwise Angular's runtime throws NG0300\n // (\"Multiple components match …\") when a file lists both\n // `NgIcon` and a barrel like `HlmIconImports = [HlmIcon, NgIcon]`\n // that re-exports it, or when two NgModules re-export the same\n // directive (e.g. FormsModule + ReactiveFormsModule →\n // DefaultValueAccessor).\n const seenDeclarationNames = new Set<string>();\n\n // Expand `imports` entries that are not directives themselves\n // (e.g. NgModules and tuple barrels like `HlmSelectImports =\n // [HlmSelect, HlmSelectContent, ...] as const`) into the\n // underlying directive class names. Returns the original entry\n // when it doesn't match either expansion case.\n const collectExpandedImports = (\n depClassName: string,\n visited: Set<string>,\n ): string[] => {\n if (visited.has(depClassName)) return [];\n visited.add(depClassName);\n const entry = registry?.get(depClassName);\n if (!entry) return [depClassName];\n if (entry.kind === 'ngmodule' && entry.exports) {\n const out: string[] = [];\n for (const name of entry.exports) {\n out.push(...collectExpandedImports(name, visited));\n }\n return out;\n }\n if (entry.kind === 'tuple' && entry.members) {\n const out: string[] = [];\n for (const name of entry.members) {\n out.push(...collectExpandedImports(name, visited));\n }\n return out;\n }\n return [depClassName];\n };\n\n for (const dep of Array.isArray(meta.imports) ? meta.imports : []) {\n const depNode = dep.node;\n const depClassName: string =\n typeof depNode === 'string'\n ? depNode\n : (depNode?.name ?? depNode?.type === 'Identifier')\n ? depNode.name\n : sourceCode.slice(depNode?.start ?? 0, depNode?.end ?? 0);\n const registryEntry = registry?.get(depClassName);\n\n // Tuple barrel: `imports: [HlmSelectImports]` where the\n // const is `[HlmSelect, HlmSelectContent, ...] as const`.\n // Expand into the underlying directive declarations and\n // track synthetic imports for any classes not already\n // referenced in this file.\n if (registryEntry?.kind === 'tuple' && registryEntry.members) {\n const expanded = collectExpandedImports(depClassName, new Set());\n const tupleSpecifier = importSpecifierByName.get(depClassName);\n for (const memberName of expanded) {\n const memberEntry = registry?.get(memberName);\n if (!memberEntry || memberEntry.kind === 'tuple') continue;\n const memberRef = new o.WrappedNodeExpr(\n dependencyLocalName(memberName),\n );\n if (!importedNames.has(memberName)) {\n const memberSpecifier = resolveSyntheticImportSpecifier(\n fileName,\n memberEntry,\n tupleSpecifier,\n );\n if (memberSpecifier) {\n syntheticImports.set(memberName, memberSpecifier);\n }\n }\n const kind = memberEntry.kind === 'pipe' ? 1 : 0;\n const memberDecl: CompileDeclaration = {\n type: memberRef,\n selector: memberEntry.selector,\n kind,\n ...(kind === 1 ? { name: memberEntry.pipeName } : {}),\n };\n if (memberEntry.inputs) {\n memberDecl.inputs = Object.values(memberEntry.inputs).map(\n (i) => i.bindingPropertyName,\n );\n }\n if (memberEntry.outputs) {\n memberDecl.outputs = Object.values(\n memberEntry.outputs,\n ) as string[];\n }\n if (!seenDeclarationNames.has(memberName)) {\n seenDeclarationNames.add(memberName);\n declarations.push(memberDecl);\n }\n }\n continue;\n }\n\n if (registryEntry?.kind === 'ngmodule' && registryEntry.exports) {\n const moduleSpecifier = importSpecifierByName.get(depClassName);\n\n // Recursively collect all non-module exports (handles nested NgModules\n // like ReactiveFormsModule → ɵInternalFormsSharedModule → DefaultValueAccessor)\n const allExports: string[] = [];\n const expandModule = (\n moduleName: string,\n visited = new Set<string>(),\n ) => {\n if (visited.has(moduleName)) return;\n visited.add(moduleName);\n const mod = registry?.get(moduleName);\n if (!mod?.exports) return;\n for (const name of mod.exports) {\n const entry = registry?.get(name);\n if (!entry) continue;\n if (entry.kind === 'ngmodule') {\n expandModule(name, visited);\n } else {\n allExports.push(name);\n }\n }\n };\n expandModule(depClassName);\n\n for (const exportedName of allExports) {\n const exportedEntry = registry?.get(exportedName);\n if (exportedEntry) {\n const kind = exportedEntry.kind === 'pipe' ? 1 : 0;\n // Create a reference to the exported class. If it's not\n // already imported, track it for synthetic import injection.\n const exportedRef = new o.WrappedNodeExpr(\n dependencyLocalName(exportedName),\n );\n const exportedSpecifier = resolveSyntheticImportSpecifier(\n fileName,\n exportedEntry,\n moduleSpecifier,\n );\n if (exportedSpecifier) {\n syntheticImports.set(exportedName, exportedSpecifier);\n }\n const decl: CompileDeclaration = {\n type: exportedRef,\n selector: exportedEntry.selector,\n kind,\n ...(kind === 1 ? { name: exportedEntry.pipeName } : {}),\n };\n if (exportedEntry.inputs) {\n decl.inputs = Object.values(exportedEntry.inputs).map(\n (i) => i.bindingPropertyName,\n );\n }\n if (exportedEntry.outputs) {\n decl.outputs = Object.values(\n exportedEntry.outputs,\n ) as string[];\n }\n if (!seenDeclarationNames.has(exportedName)) {\n seenDeclarationNames.add(exportedName);\n declarations.push(decl);\n }\n }\n }\n continue;\n }\n\n const selector =\n registryEntry?.selector ?? localSelectors.get(depClassName);\n const kind = registryEntry?.kind === 'pipe' ? 1 : 0;\n const decl: CompileDeclaration = {\n type: dep,\n selector: selector || `_unresolved-${depClassName}`,\n kind,\n ...(kind === 1 ? { name: registryEntry?.pipeName } : {}),\n };\n // Pass inputs/outputs from registry so template bindings resolve.\n // R3DirectiveDependencyMetadata expects inputs/outputs as string[]\n // of binding property names.\n if (registryEntry?.inputs) {\n decl.inputs = Object.values(registryEntry.inputs).map(\n (i) => i.bindingPropertyName,\n );\n }\n if (registryEntry?.outputs) {\n decl.outputs = Object.values(registryEntry.outputs) as string[];\n }\n if (!seenDeclarationNames.has(depClassName)) {\n seenDeclarationNames.add(depClassName);\n declarations.push(decl);\n }\n }\n\n // Add self-reference so recursive components (e.g. tree views)\n // can use their own selector in their template.\n // Skip in partial mode — the linker handles self-resolution.\n if (!isPartial && !seenDeclarationNames.has(className)) {\n const selfInputs = Object.entries(sigs.inputs).map(\n ([, v]: [string, any]) => v.bindingPropertyName,\n );\n const selfOutputs = Object.values({\n ...meta.outputs,\n ...fields.outputs,\n ...sigs.outputs,\n }) as string[];\n seenDeclarationNames.add(className);\n declarations.push({\n type: classRef.value,\n selector: meta.selector,\n kind: 0,\n ...(selfInputs.length > 0 ? { inputs: selfInputs } : {}),\n ...(selfOutputs.length > 0 ? { outputs: selfOutputs } : {}),\n });\n }\n\n // Non-standalone components get their directive/pipe scope from the\n // @NgModule that declares them. Whole-program ngtsc resolves this; a\n // per-file engine can't read the module from the component file, but the\n // project-wide registry (populated at buildStart) records every module's\n // declarations + imports. We resolve the owning module's transitive scope\n // here and inline it into the component's own `dependencies` — matching\n // ngtsc, and surviving tree-shaking (unlike a separate, droppable\n // `ɵɵsetComponentScope` call).\n //\n // A component declared in an @NgModule must set\n // `standalone: false`, so only those need the owning-module lookup.\n if (!isPartial && meta.standalone === false && registry) {\n let owningModule:\n | { declarations?: string[]; imports?: string[] }\n | undefined;\n for (const entry of registry.values()) {\n if (\n entry.kind === 'ngmodule' &&\n entry.declarations?.includes(className)\n ) {\n owningModule = entry;\n break;\n }\n }\n if (owningModule) {\n // Transitive scope = the module's own declarations + the exported\n // declarations of every imported module (recursively) + tuple members.\n const scopeNames = new Set<string>();\n const addExportsOf = (modName: string, visited: Set<string>) => {\n if (visited.has(modName)) return;\n visited.add(modName);\n const e = registry.get(modName);\n if (!e) return;\n if (e.kind === 'ngmodule') {\n for (const exp of e.exports ?? []) addExportsOf(exp, visited);\n } else if (e.kind === 'tuple') {\n for (const m of e.members ?? []) scopeNames.add(m);\n } else {\n scopeNames.add(modName);\n }\n };\n for (const d of owningModule.declarations ?? [])\n scopeNames.add(d);\n for (const imp of owningModule.imports ?? [])\n addExportsOf(imp, new Set());\n\n for (const name of scopeNames) {\n if (seenDeclarationNames.has(name)) continue;\n const entry = registry.get(name);\n if (\n !entry ||\n entry.kind === 'ngmodule' ||\n entry.kind === 'tuple'\n )\n continue;\n if (!importedNames.has(name)) {\n const spec = resolveSyntheticImportSpecifier(\n fileName,\n entry,\n importSpecifierByName.get(name),\n );\n if (spec) syntheticImports.set(name, spec);\n }\n const kind = entry.kind === 'pipe' ? 1 : 0;\n const decl: CompileDeclaration = {\n type: new o.WrappedNodeExpr(dependencyLocalName(name)),\n selector: entry.selector || `_unresolved-${name}`,\n kind,\n ...(kind === 1 ? { name: entry.pipeName } : {}),\n };\n if (entry.inputs) {\n decl.inputs = Object.values(entry.inputs).map(\n (i) => i.bindingPropertyName,\n );\n }\n if (entry.outputs) {\n decl.outputs = Object.values(entry.outputs) as string[];\n }\n seenDeclarationNames.add(name);\n declarations.push(decl);\n }\n }\n }\n\n let templateContent = meta.template || '';\n if (!templateContent && meta.templateUrl) {\n try {\n const templatePath = path.resolve(\n path.dirname(fileName),\n meta.templateUrl,\n );\n templateContent = fs.readFileSync(templatePath, 'utf-8');\n resourceDependencies.push(templatePath);\n } catch {\n console.warn(\n `[fast-compile] Could not read template file \"${meta.templateUrl}\" for ${className}`,\n );\n }\n }\n\n if (Array.isArray(meta.styleUrls)) {\n for (const url of meta.styleUrls) {\n try {\n const stylePath = path.resolve(path.dirname(fileName), url);\n const styleContent =\n resolvedStyles?.get(stylePath) ??\n fs.readFileSync(stylePath, 'utf-8');\n meta.styles.push(styleContent);\n resourceDependencies.push(stylePath);\n } catch {\n console.warn(\n `[fast-compile] Could not read style file \"${url}\" for ${className}`,\n );\n }\n }\n }\n\n for (const { index, css } of resolveInlineStyles(\n styleRanges?.get(dec),\n resolvedInlineStyles,\n )) {\n meta.styles[index] = css;\n }\n\n // Store resolved resources for metadata inlining. `styles` is set only\n // when a styleUrl was read here, and then holds every style ɵcmp got,\n // inline ones included.\n resolvedResources.set(dec, {\n template: templateContent || undefined,\n styles:\n meta.styleUrls.length > 0 && meta.styles?.length > 0\n ? [...meta.styles]\n : undefined,\n });\n\n const parsedTemplate = parseTemplate(templateContent, fileName, {\n preserveWhitespaces: meta.preserveWhitespaces,\n enableI18nLegacyMessageIdFormat:\n opts.enableI18nLegacyMessageIdFormat ?? true,\n i18nNormalizeLineEndingsInICUs:\n opts.i18nNormalizeLineEndingsInICUs ?? true,\n });\n\n const ivyInputs: Record<string, unknown> = {};\n if (Array.isArray(meta.inputs)) {\n meta.inputs.forEach((i: string) => (ivyInputs[i] = i));\n } else if (meta.inputs) {\n Object.assign(ivyInputs, meta.inputs);\n }\n Object.assign(ivyInputs, fields.inputs);\n for (const [key, val] of Object.entries(sigs.inputs)) {\n const sigDesc = val as {\n bindingPropertyName?: string;\n required?: boolean;\n transform?: o.Expression | null;\n };\n ivyInputs[key] = {\n classPropertyName: key,\n // Honor the binding name (alias) extracted by detectSignals\n // so `input(null, { alias: 'aria-label' })` registers with\n // the public name `aria-label`, not the class property name.\n bindingPropertyName: sigDesc.bindingPropertyName ?? key,\n isSignal: true,\n required: sigDesc.required || false,\n transformFunction: sigDesc.transform || null,\n };\n }\n const templateErrors = parsedTemplate.errors ?? [];\n if (templateErrors.length > 0) {\n const firstError = templateErrors[0];\n classCompileError = new Error(\n `[fast-compile] Template parse error in ${fileName} (${className}): ${firstError.msg}`,\n );\n return;\n }\n\n // Classes used only inside @defer blocks load through the blocks'\n // dynamic import()s, so they must not also be eager dependencies:\n // that would keep their module in this chunk. Once nothing else\n // references them, the TypeScript strip pass drops their imports.\n const deferDependencies = buildDeferDependencyMap(\n parsedTemplate,\n oxcProgram,\n registry,\n localSelectors,\n );\n if (!isPartial && deferDependencies.deferredImports.size > 0) {\n const importMap = buildImportMap(oxcProgram);\n const metadataDeps: {\n symbolName: string;\n importPath: string;\n isDefaultImport: boolean;\n }[] = [];\n for (let i = declarations.length - 1; i >= 0; i--) {\n const name = declarationName(declarations[i]);\n const info = name !== null ? importMap.get(name) : undefined;\n if (\n name === null ||\n info === undefined ||\n !deferDependencies.deferredImports.has(name)\n ) {\n continue;\n }\n declarations.splice(i, 1);\n metadataDeps.unshift({\n symbolName: name,\n importPath: info.path,\n isDefaultImport: info.isDefault,\n });\n }\n if (metadataDeps.length > 0) {\n deferredMetadataDeps.set(className, metadataDeps);\n }\n }\n\n const componentMeta: CompileMetadata & {\n name: string;\n type: o.R3Reference;\n typeSourceSpan: ParseSourceSpan;\n declarations: CompileDeclaration[];\n template: {\n nodes: o.Node[];\n ngContentSelectors: string[];\n preserveWhitespaces: boolean;\n };\n } = {\n ...meta,\n name: className,\n type: classRef,\n typeSourceSpan,\n declarations,\n template: {\n nodes: parsedTemplate.nodes,\n ngContentSelectors: parsedTemplate.ngContentSelectors,\n preserveWhitespaces: parsedTemplate.preserveWhitespaces,\n },\n styles: [...(meta.styles || []), ...(parsedTemplate.styles || [])],\n inputs: ivyInputs,\n outputs: { ...meta.outputs, ...fields.outputs, ...sigs.outputs },\n viewQueries: [...fields.viewQueries, ...sigs.viewQueries],\n queries: [...fields.contentQueries, ...sigs.contentQueries],\n host: hostMetadata,\n changeDetection: meta.changeDetection ?? (isPartial ? null : 1),\n encapsulation: meta.encapsulation ?? 0,\n exportAs: meta.exportAs,\n providers: providersToExpr(meta.providers),\n viewProviders: providersToExpr(meta.viewProviders),\n animations: meta.animations?.length\n ? new o.LiteralArrayExpr(meta.animations)\n : null,\n isStandalone: meta.standalone,\n imports: meta.imports,\n lifecycle: { usesOnChanges: false },\n // Angular v19/v20's `createComponentDefinitionMap` reads\n // `meta.interpolation.start` and `meta.interpolation.end`\n // unconditionally (the `!== DEFAULT_INTERPOLATION_CONFIG` check\n // is reference-equality, so a missing field enters the block\n // and crashes with `Cannot read properties of undefined`). v21\n // dropped the field from `createComponentDefinitionMap`\n // entirely. Use the v19/v20 singleton when the Angular package\n // exports it (matches the reference-equality check, skipping\n // the partial-mode emission block) and fall back to a plain\n // shape on v21+ where the field is ignored anyway.\n interpolation: (\n o as {\n DEFAULT_INTERPOLATION_CONFIG?: { start: string; end: string };\n }\n ).DEFAULT_INTERPOLATION_CONFIG ?? { start: '{{', end: '}}' },\n usesInheritance,\n defer: {\n mode: 0,\n blocks: deferDependencies.blocks,\n },\n declarationListEmitMode: 1,\n i18nUseExternalIds: opts.i18nUseExternalIds ?? false,\n relativeContextFilePath: fileName,\n controlCreate: null,\n hasDirectiveDependencies:\n declarations.length > 0 ||\n (Array.isArray(meta.imports) && meta.imports.length > 0),\n };\n\n if (isPartial) {\n // Partial compilation accesses .inputs, .outputs, .exportAs on\n // each declaration — ensure they are arrays (not undefined).\n componentMeta.declarations = declarations.map((d) => ({\n ...d,\n inputs: d.inputs ?? null,\n outputs: d.outputs ?? null,\n exportAs: d.exportAs ?? null,\n isComponent: d.isComponent ?? false,\n }));\n const cmp = compileDeclareComponentFromMetadata(\n componentMeta,\n parsedTemplate,\n {\n content: templateContent,\n sourceUrl: fileName,\n isInline: !meta.templateUrl,\n inlineTemplateLiteralExpression: null,\n },\n );\n ivyCode.push(\n `static ɵcmp = /*@__PURE__*/ ${emitAngularExpr(cmp.expression)}`,\n );\n } else {\n const cmp = compileComponentFromMetadata(\n componentMeta,\n constantPool,\n bindingParser!,\n );\n ivyCode.push(\n `static ɵcmp = /*@__PURE__*/ ${emitAngularExpr(cmp.expression)}`,\n );\n }\n break;\n }\n\n case 'Directive': {\n targetType = FactoryTarget.Directive;\n // Build proper input descriptors (same as Component path)\n const dirInputs: Record<string, unknown> = {};\n if (Array.isArray(meta.inputs)) {\n meta.inputs.forEach((i: string) => (dirInputs[i] = i));\n } else if (meta.inputs) {\n Object.assign(dirInputs, meta.inputs);\n }\n Object.assign(dirInputs, fields.inputs);\n for (const [key, val] of Object.entries(sigs.inputs)) {\n const sigDesc = val as {\n bindingPropertyName?: string;\n required?: boolean;\n transform?: o.Expression | null;\n };\n dirInputs[key] = {\n classPropertyName: key,\n // Honor the binding name (alias) extracted by detectSignals.\n bindingPropertyName: sigDesc.bindingPropertyName ?? key,\n isSignal: true,\n required: sigDesc.required || false,\n transformFunction: sigDesc.transform || null,\n };\n }\n const directiveMeta = {\n ...meta,\n // Abstract base directives are declared as `@Directive()` with\n // no metadata. Angular's R3DirectiveMetadata accepts\n // `selector: string | null`, but the downstream selector parser\n // calls `.replace()` on the value and crashes on `undefined`.\n // Coerce missing selectors to `null` so abstract base classes\n // compile correctly.\n selector: meta.selector ?? null,\n name: className,\n type: classRef,\n typeSourceSpan,\n host: hostMetadata,\n inputs: dirInputs,\n outputs: { ...meta.outputs, ...fields.outputs, ...sigs.outputs },\n viewQueries: [...fields.viewQueries, ...sigs.viewQueries],\n queries: [...fields.contentQueries, ...sigs.contentQueries],\n // Angular's compiler treats `providers` as an Expression and\n // emits `ɵɵProvidersFeature(<expr>)` whenever it is truthy.\n // `providersToExpr` lowers an inline array literal to a\n // LiteralArrayExpr (matching the Component branch) and passes a\n // const/spread reference through by value — returning `null`\n // when there are no providers so Angular skips the feature\n // entirely. Passing the bare JS array would otherwise be lowered\n // to `null` and crash Angular at runtime in `resolveProvider`.\n providers: providersToExpr(meta.providers),\n exportAs: meta.exportAs,\n isStandalone: meta.standalone,\n lifecycle: { usesOnChanges: false },\n usesInheritance,\n controlCreate: null,\n };\n if (isPartial) {\n const dir = compileDeclareDirectiveFromMetadata(directiveMeta);\n ivyCode.push(\n `static ɵdir = /*@__PURE__*/ ${emitAngularExpr(dir.expression)}`,\n );\n } else {\n const dir = compileDirectiveFromMetadata(\n directiveMeta,\n constantPool,\n bindingParser!,\n );\n ivyCode.push(\n `static ɵdir = /*@__PURE__*/ ${emitAngularExpr(dir.expression)}`,\n );\n }\n break;\n }\n\n case 'Pipe': {\n targetType = FactoryTarget.Pipe;\n const pipeMeta = {\n ...meta,\n name: className,\n pipeName: meta.name,\n type: classRef,\n isStandalone: meta.standalone,\n pure: meta.pure ?? true,\n };\n if (isPartial) {\n const pipe = compileDeclarePipeFromMetadata(pipeMeta);\n ivyCode.push(\n `static ɵpipe = /*@__PURE__*/ ${emitAngularExpr(pipe.expression)}`,\n );\n } else {\n const pipe = compilePipeFromMetadata(pipeMeta);\n ivyCode.push(\n `static ɵpipe = /*@__PURE__*/ ${emitAngularExpr(pipe.expression)}`,\n );\n }\n break;\n }\n\n case 'Injectable': {\n targetType = FactoryTarget.Injectable;\n const injectableMeta: any = {\n name: className,\n type: classRef,\n typeArgumentCount: 0,\n providedIn: {\n expression: new o.LiteralExpr(meta.providedIn ?? null),\n forwardRef: 0,\n },\n };\n // Forward provider configuration so `ɵprov` honors useFactory/\n // useClass/useExisting/useValue. Without this, an\n // `@Injectable({ useFactory: () => ... })` quietly falls back\n // to constructor instantiation.\n if (meta.useClass) injectableMeta.useClass = meta.useClass;\n if (meta.useFactory) injectableMeta.useFactory = meta.useFactory;\n if (meta.useExisting) injectableMeta.useExisting = meta.useExisting;\n if (meta.useValue) injectableMeta.useValue = meta.useValue;\n // Dependency list for `useFactory` / `useClass`; without it the\n // emitted factory is invoked with no arguments.\n if (meta.deps) injectableMeta.deps = meta.deps;\n if (isPartial) {\n const inj = compileDeclareInjectableFromMetadata(injectableMeta);\n ivyCode.push(\n `static ɵprov = /*@__PURE__*/ ${emitAngularExpr(inj.expression)}`,\n );\n } else {\n const inj = o.compileInjectable(injectableMeta, true);\n ivyCode.push(\n `static ɵprov = /*@__PURE__*/ ${emitAngularExpr(inj.expression)}`,\n );\n }\n break;\n }\n\n case 'Service': {\n // `@Service` (and the `compileService` compiler API) landed in\n // Angular 22. On older peers the decorator does not exist; fail\n // loudly rather than falling through and emitting a default\n // `Injectable`-target factory with no `ɵprov`.\n if (!angularVersionAtLeast(22)) {\n classCompileError = new Error(\n `[fast-compile] @Service on ${className} requires Angular 22 or later`,\n );\n break;\n }\n targetType = (FactoryTarget as any).Service;\n const serviceMeta: any = {\n name: className,\n type: classRef,\n typeArgumentCount: 0,\n };\n if (meta.autoProvided === false) serviceMeta.autoProvided = false;\n if (meta.factory) serviceMeta.factory = meta.factory;\n if (isPartial) {\n const svc = (o as any).compileDeclareServiceFromMetadata(\n serviceMeta,\n );\n ivyCode.push(\n `static ɵprov = /*@__PURE__*/ ${emitAngularExpr(svc.expression)}`,\n );\n } else {\n const svc = (o as any).compileService(serviceMeta, false);\n ivyCode.push(\n `static ɵprov = /*@__PURE__*/ ${emitAngularExpr(svc.expression)}`,\n );\n }\n break;\n }\n\n case 'NgModule': {\n targetType = FactoryTarget.NgModule;\n const ngModuleImports = Array.isArray(meta.imports)\n ? meta.imports\n : [];\n const ngModuleDeclarations = Array.isArray(meta.declarations)\n ? meta.declarations\n : [];\n const ngModuleExports = Array.isArray(meta.exports)\n ? meta.exports\n : [];\n const ngModuleBootstrap = Array.isArray(meta.bootstrap)\n ? meta.bootstrap\n : [];\n\n const ngModuleMeta = {\n kind: R3NgModuleMetadataKind.Global as const,\n type: classRef,\n bootstrap: ngModuleBootstrap.map((e: o.WrappedNodeExpr<any>) => ({\n value: e,\n type: e,\n })),\n declarations: ngModuleDeclarations.map(\n (e: o.WrappedNodeExpr<any>) => ({ value: e, type: e }),\n ),\n publicDeclarationTypes: null,\n imports: ngModuleImports.map((e: o.WrappedNodeExpr<any>) => ({\n value: e,\n type: e,\n })),\n includeImportTypes: true,\n exports: ngModuleExports.map((e: o.WrappedNodeExpr<any>) => ({\n value: e,\n type: e,\n })),\n selectorScopeMode: R3SelectorScopeMode.Inline,\n containsForwardDecls: false,\n schemas: [],\n id: null,\n };\n const injectorMeta = {\n name: className,\n type: classRef,\n providers: providersToExpr(meta.providers),\n imports: ngModuleImports.map((e: o.WrappedNodeExpr<any>) => e),\n };\n if (isPartial) {\n const ngMod = compileDeclareNgModuleFromMetadata(ngModuleMeta);\n ivyCode.push(\n `static ɵmod = /*@__PURE__*/ ${emitAngularExpr(ngMod.expression)}`,\n );\n const injector = compileDeclareInjectorFromMetadata(injectorMeta);\n ivyCode.push(\n `static ɵinj = /*@__PURE__*/ ${emitAngularExpr(injector.expression)}`,\n );\n } else {\n const ngMod = compileNgModule(ngModuleMeta);\n ivyCode.push(\n `static ɵmod = /*@__PURE__*/ ${emitAngularExpr(ngMod.expression)}`,\n );\n const injector = compileInjector(injectorMeta);\n ivyCode.push(\n `static ɵinj = /*@__PURE__*/ ${emitAngularExpr(injector.expression)}`,\n );\n }\n break;\n }\n }\n });\n\n if (classCompileError) {\n throw classCompileError;\n }\n\n // Generate factory\n const deps = extractConstructorDeps(node, sourceCode, typeOnlyImports);\n if (deps === null) {\n const baseVar = `ɵ${className}_BaseFactory`;\n ivyCode.unshift(\n `static ɵfac = /*@__PURE__*/ (() => { let ${baseVar}; return function ${className}_Factory(__ngFactoryType__) { return (${baseVar} || (${baseVar} = i0.ɵɵgetInheritedFactory(${className})))(__ngFactoryType__ || ${className}); }; })()`,\n );\n } else if (deps === 'invalid') {\n ivyCode.unshift(\n `static ɵfac = function ${className}_Factory(__ngFactoryType__) { i0.ɵɵinvalidFactory(); }`,\n );\n } else {\n const factoryMeta = {\n name: className,\n type: classRef,\n typeArgumentCount: 0,\n deps,\n target: targetType,\n };\n if (isPartial) {\n const fac = compileDeclareFactoryFunction(factoryMeta);\n ivyCode.unshift(\n `static ɵfac = /*@__PURE__*/ ${emitAngularExpr(fac.expression)}`,\n );\n } else {\n const fac = compileFactoryFunction(factoryMeta);\n ivyCode.unshift(\n `static ɵfac = /*@__PURE__*/ ${emitAngularExpr(fac.expression)}`,\n );\n }\n }\n\n // Emit setClassMetadata for runtime decorator reflection (devMode only)\n const ctorParameters = buildCtorParameters(\n node,\n sourceCode,\n typeOnlyImports,\n );\n const propDecorators = buildPropDecorators(node, sourceCode, 'i0.');\n const scopedMetadata: o.Statement[] = [];\n angularDecorators.forEach((dec) => {\n const decName = decoratorCallName(dec, sourceCode)!;\n const decArgsNode = dec.expression.arguments[0];\n const textOf = (n: any) => sourceCode.slice(n.start, n.end);\n\n // Build the decorator args for setClassMetadata, inlining resources if needed.\n const resources = resolvedResources.get(dec);\n let metadataArgsExpr: string | null = null;\n if (decArgsNode) {\n if (resources && decArgsNode.type === 'ObjectExpression') {\n // Inline external templateUrl/styleUrl(s) into the metadata so Angular's\n // runtime doesn't try to fetch relative URLs (which fails during SSR).\n const rewrittenProps: string[] = [];\n let needsTransform = false;\n const inlineStyles = resolveInlineStyles(\n styleRanges?.get(dec),\n resolvedInlineStyles,\n );\n let resourceStylesWritten = false;\n for (const prop of decArgsNode.properties) {\n if (\n prop.type !== 'Property' ||\n prop.shorthand ||\n prop.method ||\n prop.kind !== 'init'\n ) {\n rewrittenProps.push(textOf(prop));\n continue;\n }\n const propName = getPropertyKey(prop);\n\n if (propName === 'templateUrl' && resources.template) {\n rewrittenProps.push(\n `template: ${JSON.stringify(resources.template)}`,\n );\n needsTransform = true;\n } else if (\n (propName === 'styleUrl' ||\n propName === 'styleUrls' ||\n propName === 'styles') &&\n resources.styles\n ) {\n // One `styles` key for all of them: a second one would win\n // over the first and drop its styles.\n if (!resourceStylesWritten) {\n rewrittenProps.push(\n `styles: [${resources.styles.map((s) => JSON.stringify(s)).join(', ')}]`,\n );\n resourceStylesWritten = true;\n }\n needsTransform = true;\n } else if (propName === 'styles' && inlineStyles.length > 0) {\n rewrittenProps.push(\n `styles: ${withResolvedInlineStyles(prop.value, inlineStyles, sourceCode)}`,\n );\n needsTransform = true;\n } else {\n rewrittenProps.push(textOf(prop));\n }\n }\n metadataArgsExpr = needsTransform\n ? `{${rewrittenProps.join(', ')}}`\n : textOf(decArgsNode);\n } else {\n metadataArgsExpr = textOf(decArgsNode);\n }\n }\n\n try {\n // `LiteralMapPropertyAssignment` was a class with a constructor in\n // Angular up through ~v19, removed-then-restored in later v20/v21\n // patches. The only stable shape across versions is the plain\n // `{ key, value, quoted }` object literal — Angular's own emitter\n // and Analog's `JSEmitter` both consume entries via duck typing\n // (`.key` / `.value` / `.quoted`), and `compileClassMetadata` does\n // not `instanceof`-check entries. The js-emitter has a matching\n // comment at the consumption site. Using `new o.LiteralMapProperty\n // Assignment(...)` would throw \"is not a constructor\" on Angular\n // versions where the class export is missing (e.g. 20.3.x), and\n // the surrounding try/catch would silently disable class metadata\n // emission for every class in the project.\n const classMetaInput = {\n type: new o.WrappedNodeExpr(className),\n decorators: new o.LiteralArrayExpr([\n new o.LiteralMapExpr([\n {\n key: 'type',\n value: new o.WrappedNodeExpr(decName),\n quoted: false,\n },\n ...(metadataArgsExpr\n ? [\n {\n key: 'args',\n value: new o.LiteralArrayExpr([\n new o.WrappedNodeExpr(metadataArgsExpr),\n ]),\n quoted: false,\n },\n ]\n : []),\n ] as unknown as o.LiteralMapPropertyAssignment[]),\n ]),\n ctorParameters: ctorParameters\n ? new o.WrappedNodeExpr(`() => [${ctorParameters}]`)\n : null,\n propDecorators: propDecorators\n ? new o.WrappedNodeExpr(propDecorators)\n : null,\n };\n // A component whose @defer blocks load some dependencies lazily must\n // not reference them eagerly in its metadata either.\n const deferredDeps =\n decName === 'Component'\n ? deferredMetadataDeps.get(className)\n : undefined;\n const classMetadataExpr = isPartial\n ? compileDeclareClassMetadata(classMetaInput)\n : deferredDeps\n ? compileComponentClassMetadata(classMetaInput, deferredDeps)\n : compileClassMetadata(classMetaInput);\n const metadataStmt = new o.ExpressionStatement(classMetadataExpr);\n if (topLevelClasses.has(node)) {\n constantPool.statements.push(metadataStmt);\n } else {\n scopedMetadata.push(metadataStmt);\n }\n } catch (e) {\n // Skip if compileClassMetadata fails — surfaced via DEBUG=analog-fast-compile\n if (debugCompile.enabled) {\n debugCompile(\n 'compileClassMetadata failed for %s in %s: %s',\n className,\n fileName,\n (e as Error)?.message,\n );\n }\n }\n });\n\n // Collect member decorators (@HostListener, @HostBinding, @Input, @Output,\n // @ViewChild, @ContentChild, etc.) so they are removed from the source.\n // The metadata has already been extracted by detectFieldDecorators().\n const memberDecorators: any[] = [];\n for (const member of node.body.body) {\n for (const dec of member.decorators ?? []) {\n if (FIELD_DECORATORS.has(decoratorCallName(dec, sourceCode) ?? '')) {\n memberDecorators.push(dec);\n }\n }\n }\n\n classResults.push({\n ivyCode,\n decorators: [...angularDecorators, ...memberDecorators],\n classEnd: node.end,\n scopedMetadata,\n });\n }\n\n // Apply edits via MagicString\n const ms = new MagicString(sourceCode, { filename: fileName });\n\n // 1. Prepend i0 import (skip if already present)\n if (!sourceCode.includes('import * as i0 from')) {\n ms.prepend('import * as i0 from \"@angular/core\";\\n');\n }\n\n // 1b. Inject synthetic imports for NgModule-exported classes\n for (const [name, specifier] of syntheticImports) {\n const localName = dependencyLocalName(name);\n if (!importedNames.has(localName)) {\n const binding = localName === name ? name : `${name} as ${localName}`;\n ms.prepend(`import { ${binding} } from \"${specifier}\";\\n`);\n importedNames.add(localName);\n }\n }\n\n // 2a. Hoist non-exported variable/function declarations that appear after\n // a class to just before the first class. This avoids TDZ errors when\n // static ɵcmp references file-level constants declared after the class.\n //\n // We must NOT hoist a statement whose initializer references a name\n // (class, exported const/let) that is defined between firstClassPos and\n // the statement itself — doing so would move the reference before the\n // definition and cause a TDZ error at runtime.\n if (classResults.length > 0) {\n // Find the position right before the first class (any class, not just Angular-decorated)\n const statements = (oxcProgram.body as any[]).map(toTopLevelStatement);\n let firstClassPos = Infinity;\n const nonHoistableNames = new Set<string>();\n for (const { decl, start } of statements) {\n if (decl.type === 'ClassDeclaration') {\n firstClassPos = start;\n // The first class itself is non-hoistable — statements hoisted\n // before it must not reference it.\n if (decl.id) {\n nonHoistableNames.add(decl.id.name);\n }\n break;\n }\n }\n\n // Pass 1: collect names defined by statements that will NOT be hoisted\n // (classes, enums, exported vars/functions) and therefore remain after\n // firstClassPos.\n for (const { decl, exported, start } of statements) {\n if (start <= firstClassPos) continue;\n\n if (\n decl.type === 'ClassDeclaration' ||\n decl.type === 'TSEnumDeclaration'\n ) {\n if (decl.id) nonHoistableNames.add(decl.id.name);\n } else if (\n exported &&\n (decl.type === 'VariableDeclaration' ||\n decl.type === 'FunctionDeclaration')\n ) {\n for (const n of getDefinedNames(decl)) {\n nonHoistableNames.add(n);\n }\n }\n }\n\n // Pass 2: for each hoist candidate, check if it references any\n // non-hoistable name. If it does, skip it and add its own names to the\n // non-hoistable set (transitivity).\n for (const { decl, exported, start, end } of statements) {\n if (start <= firstClassPos) continue;\n\n const isCandidate =\n !exported &&\n (decl.type === 'VariableDeclaration' ||\n decl.type === 'FunctionDeclaration');\n if (!isCandidate) continue;\n\n const referencedIds = collectIdentifiers(decl);\n let referencesNonHoistable = false;\n for (const id of referencedIds) {\n if (nonHoistableNames.has(id)) {\n referencesNonHoistable = true;\n break;\n }\n }\n\n if (referencesNonHoistable) {\n // Don't hoist — mark this statement's names as non-hoistable too\n for (const name of getDefinedNames(decl)) {\n nonHoistableNames.add(name);\n }\n } else {\n // Move rather than re-insert so the statement keeps its source map.\n // The separating newline is attached to the moved chunk.\n ms.appendLeft(end, '\\n');\n ms.move(start, end, firstClassPos);\n }\n }\n }\n\n // 2. For each compiled class: remove decorators + insert Ivy definitions\n for (const cr of classResults) {\n // Remove Angular decorators from source\n for (const dec of cr.decorators) {\n const start = dec.start;\n const end = dec.end;\n let trimEnd = end;\n while (\n trimEnd < sourceCode.length &&\n (sourceCode[trimEnd] === ' ' ||\n sourceCode[trimEnd] === '\\n' ||\n sourceCode[trimEnd] === '\\r')\n ) {\n trimEnd++;\n }\n ms.remove(start, trimEnd);\n }\n\n // Insert static members before closing }\n if (cr.ivyCode.length > 0) {\n const memberCode = cr.ivyCode.map((c) => ' ' + c + ';').join('\\n');\n ms.appendLeft(cr.classEnd - 1, '\\n' + memberCode + '\\n');\n }\n\n for (const stmt of cr.scopedMetadata) {\n ms.appendLeft(cr.classEnd, `\\n/*@__PURE__*/ ${emitAngularStmt(stmt)}`);\n }\n }\n\n // 3. Emit constant pool statements.\n // Split into: helper declarations (const/function) that must appear before\n // the class (since static property initializers reference them), and\n // side-effect statements (setClassMetadata IIFEs) that go after.\n const helpers: string[] = [];\n const sideEffects: string[] = [];\n for (const s of constantPool.statements) {\n const code = emitAngularStmt(s);\n if (\n s instanceof o.ExpressionStatement &&\n s.expr instanceof o.InvokeFunctionExpr\n ) {\n // setClassMetadata is wrapped in `(() => { ... })()` — annotate\n // the IIFE call so bundlers can drop it when ngDevMode is folded\n // to false at production build time.\n sideEffects.push(`/*@__PURE__*/ ${code}`);\n } else {\n helpers.push(code);\n }\n }\n\n if (sideEffects.length > 0) {\n ms.append('\\n\\n' + sideEffects.join('\\n'));\n }\n\n // 4. Lower class field initializers to constructor assignments when\n // useDefineForClassFields is false (standard Angular tsconfig).\n // Uses the original OXC AST positions which are still valid for MagicString\n // since MagicString tracks edits relative to the original source.\n // Ivy static definitions (ɵcmp, ɵfac) are not in the original AST so they\n // are unaffected, and shouldLowerField skips static fields regardless.\n if (!useDefineForClassFields) {\n lowerClassFields(ms, sourceCode, oxcProgram);\n }\n\n // 5. Elide imports that are only used in type positions (type annotations,\n // implements, generics, etc.). Without this pass, single-file transpilers\n // like OXC / esbuild cannot tell that `import { SomeType }` is type-only\n // and will leave the import in the output, causing runtime errors.\n // Detection runs once on the final output; helpers are appended for\n // analysis only, since their position does not affect references.\n const helperCode = helpers.join('\\n');\n const willElide = detectTypeOnlyImportNames(\n ms.toString() + '\\n' + helperCode,\n );\n if (helpers.length > 0) {\n // Insert helpers after the last import / top-level non-class statement,\n // well before any class that references them. Skip imports that will be\n // fully removed by type elision (step 5): inserting inside a\n // soon-to-be-removed range would discard the helpers with the import.\n let insertPos = 0;\n for (const stmt of oxcProgram.body as any[]) {\n const { decl } = toTopLevelStatement(stmt);\n if (stmt.type === 'ImportDeclaration') {\n // Skip imports that will be entirely removed by type elision\n if (willElide.size > 0 && stmt.specifiers.length > 0) {\n const allElided = stmt.specifiers.every(\n (spec: any) =>\n spec.type === 'ImportNamespaceSpecifier' ||\n spec.importKind === 'type' ||\n willElide.has(spec.local.name),\n );\n if (allElided) continue;\n }\n insertPos = stmt.end;\n } else if (\n decl.type === 'VariableDeclaration' &&\n !sourceCode.slice(stmt.start, stmt.end).includes('class')\n ) {\n insertPos = stmt.end;\n } else if (\n stmt.type !== 'TSExportAssignment' &&\n !(\n stmt.type === 'ExportDefaultDeclaration' &&\n decl.type !== 'ClassDeclaration' &&\n decl.type !== 'FunctionDeclaration'\n )\n ) {\n // Stop at the first class or non-import/non-variable statement\n break;\n }\n }\n // Helpers must survive downstream `ms.overwrite()` / `ms.remove()` of\n // imports performed by the type-only specifier elision pass (step 5).\n //\n // Case `insertPos > 0`: a surviving import ends at `insertPos`. Use\n // `appendRight(insertPos, …)` so helpers bind to the `\\n` after the\n // import's `;` — outside any overwrite range `[node.start, node.end)`\n // of a preceding import. `appendLeft(insertPos, …)` would bind to the\n // `;` itself, which IS inside the overwrite range and would be wiped.\n //\n // Case `insertPos === 0`: no import survives — every import is going\n // to be elided, and `elideTypeOnlyImportsMagicString` will\n // `ms.remove(0, declEnd)` the first one. `appendRight(0, …)` anchors\n // to the character at position 0 (the first import's first char),\n // which is inside `[0, declEnd)` and gets wiped. Use `appendLeft(0, …)`\n // instead — it anchors to the LEFT of position 0, outside any range\n // starting at 0, so the helpers survive. Ordering is still correct\n // because the i0 import prepended in step 1 lives in MagicString's\n // `intro` (from `ms.prepend`), which always emits before any\n // `appendLeft` content at position 0.\n if (insertPos === 0) {\n ms.appendLeft(0, helperCode + '\\n');\n } else {\n ms.appendRight(insertPos, '\\n' + helperCode + '\\n');\n }\n }\n elideTypeOnlyImportsMagicString(ms, oxcProgram, willElide);\n\n const map = ms.generateMap({\n source: fileName,\n file: fileName + '.js',\n includeContent: true,\n hires: 'boundary',\n });\n\n if (debugCompile.enabled) {\n debugCompile(\n 'compile %s done (%dms, %d classes, %d resource deps)',\n fileName,\n Math.round(performance.now() - startTimeMs),\n classResults.length,\n resourceDependencies.length,\n );\n }\n return {\n code: ms.toString(),\n map,\n resourceDependencies,\n };\n}\n\n/** The local class name an `imports` entry declares, when it is a plain identifier. */\nfunction declarationName(declaration: CompileDeclaration): string | null {\n const node = (declaration.type as { node?: unknown }).node as\n | string\n | { type?: string; name?: string }\n | undefined;\n if (typeof node === 'string') {\n return node;\n }\n if (node?.type === 'Identifier' && typeof node.name === 'string') {\n return node.name;\n }\n return declaration.className ?? null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA8IA,SAAS,oBAAoB,MAA8B;CACzD,MAAM,YACH,KAAK,SAAS,4BACb,KAAK,SAAS,+BAChB,KAAK;CACP,MAAM,OAAO,WAAW,KAAK,cAAc;CAC3C,OAAO;EACL;EACA,UAAU,CAAC,CAAC;EACZ,OAAO,KAAK,IAAI,KAAK,OAAO,KAAK,aAAa,EAAE,EAAE,SAAS,KAAK,KAAK;EACrE,KAAK,KAAK;CACZ;AACF;;AAGA,SAAS,kBAAkB,KAAU,YAAwC;CAC3E,MAAM,SAAS,IAAI;CACnB,IAAI,QAAQ,SAAS,kBAAkB,OAAO,KAAA;CAC9C,OAAO,WAAW,MAAM,OAAO,OAAO,OAAO,OAAO,OAAO,GAAG;AAChE;;;;;AAWA,SAAS,oBACP,OACA,sBACuB;CACvB,IAAI,CAAC,SAAS,CAAC,sBAAsB,OAAO,CAAC;CAC7C,OAAO,MAAM,OAAO,SAAS,OAAO,MAAM;EACxC,MAAM,MAAM,qBAAqB,IAAI,MAAM,QAAQ,CAAC;EACpD,OAAO,QAAQ,KAAA,IAAY,CAAC,IAAI,CAAC;GAAE,GAAG;GAAO;EAAI,CAAC;CACpD,CAAC;AACH;;;;;;AAOA,SAAS,yBACP,YACA,QACA,YACQ;CACR,IAAI,OAAO;CACX,IAAI,MAAM,WAAW;CACrB,KAAK,MAAM,EAAE,MAAM,SAAS,QAAQ;EAClC,QAAQ,WAAW,MAAM,KAAK,KAAK,KAAK,IAAI,KAAK,UAAU,GAAG;EAC9D,MAAM,KAAK;CACb;CACA,OAAO,OAAO,WAAW,MAAM,KAAK,WAAW,GAAG;AACpD;;;;;;;;;;;;AAaA,SAAS,gBACP,OACqB;CACrB,IAAI,CAAC,OAAO,OAAO;CACnB,IAAI,MAAM,QAAQ,KAAK,GACrB,OA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AAM,WAAW;EACjB,gBAAgB;EAChB,OAAO;CACT,CAAC;CAED,IAAI,aAAa,SACf,aACE,wDACA,UACA,KAAK,MAAM,YAAY,IAAI,IAAI,WAAW,GAC1C,aAAa,QACb,qBAAqB,MACvB;CAEF,OAAO;EACL,MAAM,GAAG,SAAS;EAClB;EACA;CACF;AACF;;AAGA,SAAS,gBAAgB,aAAgD;CACvE,MAAM,OAAQ,YAAY,KAA4B;CAItD,IAAI,OAAO,SAAS,UAClB,OAAO;CAET,IAAI,MAAM,SAAS,gBAAgB,OAAO,KAAK,SAAS,UACtD,OAAO,KAAK;CAEd,OAAO,YAAY,aAAa;AAClC"}
@@ -23,20 +23,37 @@ function findAllClasses(node) {
23
23
  return result;
24
24
  }
25
25
  /**
26
- * `@Injectable` and `@Service` stay on the class — their decorator functions
27
- * self-register ɵprov/ɵfac at class definition time and there is no JIT
28
- * compile entry point to call instead.
26
+ * `@Injectable` and `@Service` have no JIT compile entry point: their
27
+ * decorator functions self-register ɵprov/ɵfac when applied to the class.
29
28
  */
30
29
  function isSelfRegisteringDecorator(dec) {
31
30
  const name = dec.expression?.callee?.name;
32
31
  return name === "Injectable" || name === "Service";
33
32
  }
33
+ /**
34
+ * Whether jitTransform removes every class decorator. A decorator left for
35
+ * the TypeScript strip would run at class definition, ahead of a
36
+ * self-registering decorator applied after the class, reversing legacy order.
37
+ */
38
+ function removesEveryClassDecorator(decorators) {
39
+ return decorators.every((dec) => ANGULAR_DECORATORS.has(dec.expression?.callee?.name));
40
+ }
34
41
  /** Remove a decorator along with its trailing whitespace. */
35
42
  function removeDecorator(ms, sourceCode, dec) {
36
43
  let trimEnd = dec.end;
37
44
  while (trimEnd < sourceCode.length && /\s/.test(sourceCode[trimEnd])) trimEnd++;
38
45
  ms.remove(dec.start, trimEnd);
39
46
  }
47
+ /**
48
+ * Remove a self-registering decorator and return the statement that applies
49
+ * it to the class, as a legacy decorator runs. The output then needs no
50
+ * decorator lowering, which the TypeScript strip only does when tsconfig
51
+ * sets `experimentalDecorators`.
52
+ */
53
+ function applySelfRegisteringDecorator(ms, sourceCode, className, dec) {
54
+ removeDecorator(ms, sourceCode, dec);
55
+ return `${sourceCode.slice(dec.expression.start, dec.expression.end)}(${className});`;
56
+ }
40
57
  var DI_PARAM_DECORATORS = /* @__PURE__ */ new Set([
41
58
  "Inject",
42
59
  "Optional",
@@ -60,10 +77,8 @@ function ctorParamDecorators(classNode) {
60
77
  * provider option replaces the constructor, or when a non-DI parameter
61
78
  * decorator must keep running as written.
62
79
  */
63
- function needsInjectableCtorParameters(node, decorators) {
64
- const dec = decorators.find(isSelfRegisteringDecorator);
65
- const options = dec?.expression.arguments?.[0];
66
- return !!dec && node.type === "ClassDeclaration" && !options?.properties?.some((p) => PROVIDER_KEYS.has(p.key?.name)) && ctorParamDecorators(node).every((d) => DI_PARAM_DECORATORS.has(d.expression?.callee?.name));
80
+ function needsInjectableCtorParameters(node, dec) {
81
+ return !(dec.expression.arguments?.[0])?.properties?.some((p) => PROVIDER_KEYS.has(p.key?.name)) && ctorParamDecorators(node).every((d) => DI_PARAM_DECORATORS.has(d.expression?.callee?.name));
67
82
  }
68
83
  /**
69
84
  * JIT transform for Angular files.
@@ -105,13 +120,20 @@ function jitTransform(sourceCode, fileName) {
105
120
  });
106
121
  const className = node.id?.name;
107
122
  if (!className) continue;
123
+ const selfRegistering = node.type === "ClassDeclaration" ? decorators.find(isSelfRegisteringDecorator) : void 0;
124
+ const appliesSelfRegistering = !!selfRegistering && removesEveryClassDecorator(decorators);
108
125
  if (angularDecs.length === 0) {
109
- const ctorParams = needsInjectableCtorParameters(node, decorators) && buildCtorParameters(node, sourceCode, typeOnlyImports);
126
+ if (!selfRegistering) continue;
127
+ const statements = [];
128
+ const ctorParams = needsInjectableCtorParameters(node, selfRegistering) && buildCtorParameters(node, sourceCode, typeOnlyImports);
110
129
  if (ctorParams) {
111
- hasAngularClass = true;
112
130
  for (const dec of ctorParamDecorators(node)) removeDecorator(ms, sourceCode, dec);
113
- ms.appendLeft(node.end, `\n${className}.ctorParameters = () => [${ctorParams}];\n`);
131
+ statements.push(`${className}.ctorParameters = () => [${ctorParams}];`);
114
132
  }
133
+ if (appliesSelfRegistering) statements.push(applySelfRegisteringDecorator(ms, sourceCode, className, selfRegistering));
134
+ if (statements.length === 0) continue;
135
+ hasAngularClass = true;
136
+ ms.appendLeft(node.end, `\n${statements.join("\n")}\n`);
115
137
  continue;
116
138
  }
117
139
  hasAngularClass = true;
@@ -194,6 +216,7 @@ function jitTransform(sourceCode, fileName) {
194
216
  const members = node.body?.body || [];
195
217
  for (const member of members) for (const dec of member.decorators || []) removeDecorator(ms, sourceCode, dec);
196
218
  for (const dec of ctorParamDecorators(node)) removeDecorator(ms, sourceCode, dec);
219
+ if (appliesSelfRegistering) classStatements.push(applySelfRegisteringDecorator(ms, sourceCode, className, selfRegistering));
197
220
  if (classStatements.length > 0) {
198
221
  allEmittedStatements.push(...classStatements);
199
222
  ms.appendLeft(node.end, "\n" + classStatements.join("\n") + "\n");
@@ -1 +1 @@
1
- {"version":3,"file":"jit-transform.js","names":[],"sources":["../../../../src/lib/compiler/jit-transform.ts"],"sourcesContent":["import { parseOxc } from './utils.js';\nimport MagicString from 'magic-string';\nimport { detectTypeOnlyImportNames } from './type-elision.js';\nimport {\n buildCtorParameters,\n buildPropDecorators,\n findConstructor,\n} from './jit-metadata.js';\nimport { ANGULAR_DECORATORS, FIELD_DECORATORS } from './constants.js';\n\nexport interface JitTransformResult {\n code: string;\n map: any;\n}\n\n/**\n * Recursively find all ClassDeclaration nodes in an OXC AST.\n * Handles top-level, exported, and nested classes (e.g. inside function scopes).\n */\nfunction findAllClasses(node: any): any[] {\n const result: any[] = [];\n if (!node || typeof node !== 'object') return result;\n if (Array.isArray(node)) {\n for (const item of node) {\n result.push(...findAllClasses(item));\n }\n return result;\n }\n if (node.type === 'ClassDeclaration' || node.type === 'ClassExpression') {\n result.push(node);\n }\n for (const key of Object.keys(node)) {\n if (\n key === 'type' ||\n key === 'start' ||\n key === 'end' ||\n key === 'range' ||\n key === 'loc'\n )\n continue;\n result.push(...findAllClasses(node[key]));\n }\n return result;\n}\n\n/**\n * `@Injectable` and `@Service` stay on the class — their decorator functions\n * self-register ɵprov/ɵfac at class definition time and there is no JIT\n * compile entry point to call instead.\n */\nfunction isSelfRegisteringDecorator(dec: any): boolean {\n const name: string | undefined = dec.expression?.callee?.name;\n return name === 'Injectable' || name === 'Service';\n}\n\n/** Remove a decorator along with its trailing whitespace. */\nfunction removeDecorator(ms: MagicString, sourceCode: string, dec: any): void {\n let trimEnd: number = dec.end;\n while (trimEnd < sourceCode.length && /\\s/.test(sourceCode[trimEnd]))\n trimEnd++;\n ms.remove(dec.start, trimEnd);\n}\n\nconst DI_PARAM_DECORATORS = new Set([\n 'Inject',\n 'Optional',\n 'Self',\n 'SkipSelf',\n 'Host',\n 'Attribute',\n]);\nconst PROVIDER_KEYS = new Set([\n 'useClass',\n 'useExisting',\n 'useFactory',\n 'useValue',\n]);\n\nfunction ctorParamDecorators(classNode: any): any[] {\n const ctor = findConstructor(classNode);\n const params: any[] = ctor?.value?.params?.items || ctor?.value?.params || [];\n // Decorators may live on the TSParameterProperty wrapper or the inner param\n return params.flatMap((param: any) => [\n ...(param.decorators || []),\n ...(param.type === 'TSParameterProperty' && param.parameter?.decorators\n ? param.parameter.decorators\n : []),\n ]);\n}\n\n/**\n * Whether an @Injectable/@Service class needs ctorParameters. Skipped when a\n * provider option replaces the constructor, or when a non-DI parameter\n * decorator must keep running as written.\n */\nfunction needsInjectableCtorParameters(node: any, decorators: any[]): boolean {\n const dec = decorators.find(isSelfRegisteringDecorator);\n const options = dec?.expression.arguments?.[0];\n return (\n !!dec &&\n node.type === 'ClassDeclaration' &&\n !options?.properties?.some((p: any) => PROVIDER_KEYS.has(p.key?.name)) &&\n ctorParamDecorators(node).every((d: any) =>\n DI_PARAM_DECORATORS.has(d.expression?.callee?.name),\n )\n );\n}\n\n/**\n * JIT transform for Angular files.\n *\n * Converts Angular decorators to static metadata arrays that Angular's\n * runtime JIT compiler reads via ReflectionCapabilities:\n *\n * - Class.decorators = [{ type: Component, args: [{...}] }]\n * - Class.ctorParameters = () => [{ type: ServiceA, decorators: [{type: Optional}] }]\n * - Class.propDecorators = { name: [{ type: Input }], ... }\n *\n * Also emits ɵfac (factory function) with constructor DI and downlevels\n * signal APIs (input, model, output, viewChild, etc.) to propDecorators.\n *\n * No template compilation — Angular's JIT compiler handles that at runtime.\n * Requires `import '@angular/compiler'` in main.ts for the browser JIT.\n *\n * Uses OXC's native Rust parser instead of TypeScript's parser for ~1.5x\n * faster parsing and source-position slicing instead of getText() calls.\n */\nexport function jitTransform(\n sourceCode: string,\n fileName: string,\n): JitTransformResult {\n const { program } = parseOxc(fileName, sourceCode);\n const ms = new MagicString(sourceCode, { filename: fileName });\n const typeOnlyImports = detectTypeOnlyImportNames(sourceCode, program);\n let hasAngularClass = false;\n\n const allClasses = findAllClasses(program.body);\n\n // Accumulates every class's emitted statements so the post-loop import\n // detection (missing field-decorator imports) can scan all of them.\n // The statements themselves are inserted in-scope after each class via\n // `ms.appendLeft(node.end, ...)` rather than dumped at the end of the\n // file — a class declared inside a function/callback scope (e.g. a host\n // `@Component` defined inside a `describe(...)`/`it(...)` block in a test)\n // is not in scope at module end, so a file-end emit would reference an\n // undefined name (#2360).\n const allEmittedStatements: string[] = [];\n let importCounter = 0;\n const resourceImports: string[] = [];\n let needsJitImport = false;\n\n for (const node of allClasses) {\n const decorators: any[] = node.decorators || [];\n\n const angularDecs = decorators.filter((dec: any) => {\n const expr = dec.expression;\n if (!expr || expr.type !== 'CallExpression') return false;\n const name: string | undefined = expr.callee?.name;\n if (isSelfRegisteringDecorator(dec)) return false;\n return name !== undefined && ANGULAR_DECORATORS.has(name);\n });\n const className: string | undefined = node.id?.name;\n if (!className) continue;\n\n if (angularDecs.length === 0) {\n // @Injectable/@Service keep their decorator, but without a type\n // checker or emitDecoratorMetadata a param typed only by annotation\n // has no runtime DI token unless captured in ctorParameters. A class\n // expression's name is not in scope after it, so only declarations.\n const ctorParams =\n needsInjectableCtorParameters(node, decorators) &&\n buildCtorParameters(node, sourceCode, typeOnlyImports);\n if (ctorParams) {\n hasAngularClass = true;\n for (const dec of ctorParamDecorators(node)) {\n removeDecorator(ms, sourceCode, dec);\n }\n ms.appendLeft(\n node.end,\n `\\n${className}.ctorParameters = () => [${ctorParams}];\\n`,\n );\n }\n continue;\n }\n hasAngularClass = true;\n\n // Statements emitted for THIS class. Inserted directly after the class\n // body (see end of loop) so they run in the class's own lexical scope.\n const classStatements: string[] = [];\n\n // 1. Remove Angular decorators from source\n for (const dec of angularDecs) {\n removeDecorator(ms, sourceCode, dec);\n }\n\n // 2. Emit Class.decorators = [{ type: DecName, args: [...] }]\n // For @Component: convert templateUrl/styleUrl/styleUrls to ESM imports\n const decoratorMeta: { name: string; argsText: string }[] = [];\n const decoratorEntries = angularDecs.map((dec: any) => {\n const call = dec.expression;\n const decName: string = call.callee.name;\n const args: any[] = call.arguments || [];\n\n if (\n args.length > 0 &&\n decName === 'Component' &&\n args[0].type === 'ObjectExpression'\n ) {\n // Rewrite component metadata: convert external resources to imports\n const obj = args[0];\n const rewrittenProps: string[] = [];\n\n for (const prop of obj.properties) {\n if (prop.type !== 'ObjectProperty' && prop.type !== 'Property') {\n rewrittenProps.push(sourceCode.slice(prop.start, prop.end));\n continue;\n }\n const key: string = prop.key?.name || prop.key?.value;\n const val = prop.value;\n\n if (\n key === 'templateUrl' &&\n (val?.type === 'StringLiteral' ||\n (val?.type === 'Literal' && typeof val.value === 'string'))\n ) {\n // templateUrl: './foo.html' → template: _tpl0 (with import)\n const varName = `_jit_tpl_${importCounter++}`;\n resourceImports.push(`import ${varName} from '${val.value}?raw';`);\n rewrittenProps.push(`template: ${varName}`);\n } else if (\n key === 'styleUrl' &&\n (val?.type === 'StringLiteral' ||\n (val?.type === 'Literal' && typeof val.value === 'string'))\n ) {\n // styleUrl: './foo.scss' → styles: [_style0]\n const varName = `_jit_style_${importCounter++}`;\n resourceImports.push(\n `import ${varName} from '${val.value}?inline';`,\n );\n rewrittenProps.push(`styles: [${varName}]`);\n } else if (key === 'styleUrls' && val?.type === 'ArrayExpression') {\n // styleUrls: ['./a.scss', './b.css'] → styles: [_style0, _style1]\n const vars: string[] = [];\n for (const el of val.elements) {\n if (\n el?.type === 'StringLiteral' ||\n (el?.type === 'Literal' && typeof el.value === 'string')\n ) {\n const varName = `_jit_style_${importCounter++}`;\n resourceImports.push(\n `import ${varName} from '${el.value}?inline';`,\n );\n vars.push(varName);\n }\n }\n rewrittenProps.push(`styles: [${vars.join(', ')}]`);\n } else {\n rewrittenProps.push(sourceCode.slice(prop.start, prop.end));\n }\n }\n const rewrittenArgsText = `{${rewrittenProps.join(', ')}}`;\n decoratorMeta.push({ name: decName, argsText: rewrittenArgsText });\n return `{ type: ${decName}, args: [${rewrittenArgsText}] }`;\n }\n\n if (args.length > 0) {\n const argsText = args\n .map((a: any) => sourceCode.slice(a.start, a.end))\n .join(', ');\n decoratorMeta.push({ name: decName, argsText });\n return `{ type: ${decName}, args: [${argsText}] }`;\n }\n decoratorMeta.push({ name: decName, argsText: '{}' });\n return `{ type: ${decName} }`;\n });\n classStatements.push(\n `${className}.decorators = [${decoratorEntries.join(', ')}];`,\n );\n\n // 2b. Trigger JIT compilation with the rewritten decorator metadata\n for (const dm of decoratorMeta) {\n needsJitImport = true;\n switch (dm.name) {\n case 'Component':\n classStatements.push(\n `_jitCompileComponent(${className}, ${dm.argsText});`,\n );\n break;\n case 'Directive':\n classStatements.push(\n `_jitCompileDirective(${className}, ${dm.argsText});`,\n );\n break;\n case 'Pipe':\n classStatements.push(\n `_jitCompilePipe(${className}, ${dm.argsText});`,\n );\n break;\n case 'NgModule':\n classStatements.push(\n `_jitCompileNgModule(${className}, ${dm.argsText});`,\n );\n break;\n }\n }\n\n // 3. Emit Class.ctorParameters for constructor DI\n const ctorParams = buildCtorParameters(node, sourceCode, typeOnlyImports);\n if (ctorParams) {\n classStatements.push(\n `${className}.ctorParameters = () => [${ctorParams}];`,\n );\n }\n\n // 4. Emit Class.propDecorators for field decorators + signal APIs\n const propDecorators = buildPropDecorators(node, sourceCode);\n if (propDecorators) {\n classStatements.push(`${className}.propDecorators = ${propDecorators};`);\n }\n\n // 5. Remove member and parameter decorators from source now that\n // they have been extracted into static metadata above.\n const members: any[] = node.body?.body || [];\n for (const member of members) {\n for (const dec of member.decorators || []) {\n removeDecorator(ms, sourceCode, dec);\n }\n }\n for (const dec of ctorParamDecorators(node)) {\n removeDecorator(ms, sourceCode, dec);\n }\n\n // Insert this class's metadata statements directly after the class body\n // so they execute in the class's own lexical scope. `node.end` is the\n // position just past the closing brace (decorators were stripped before\n // `node.start`), so for a top-level class this is module scope and for a\n // class nested in a function/callback it is that enclosing scope —\n // keeping the class identifier in scope either way (#2360).\n if (classStatements.length > 0) {\n allEmittedStatements.push(...classStatements);\n ms.appendLeft(node.end, '\\n' + classStatements.join('\\n') + '\\n');\n }\n }\n\n if (!hasAngularClass) {\n return { code: sourceCode, map: null };\n }\n\n // Prepend ESM imports for external templates/styles\n if (resourceImports.length > 0) {\n ms.prepend(resourceImports.join('\\n') + '\\n');\n }\n\n // Prepend imports for decorator classes referenced by signal API downleveling\n // (e.g. input() → {type: Input}, model() → {type: Input} + {type: Output})\n const existingImports = new Set<string>();\n for (const stmt of program.body) {\n if (\n (stmt as any).type === 'ImportDeclaration' &&\n (stmt as any).source?.value === '@angular/core'\n ) {\n for (const spec of (stmt as any).specifiers || []) {\n if (spec.type === 'ImportSpecifier') {\n existingImports.add(spec.local?.name || spec.imported?.name);\n }\n }\n }\n }\n const allPostCode = allEmittedStatements.join('\\n');\n const missingDecorators: string[] = [];\n for (const dec of FIELD_DECORATORS) {\n if (allPostCode.includes(`type: ${dec}`) && !existingImports.has(dec)) {\n missingDecorators.push(dec);\n }\n }\n if (missingDecorators.length > 0) {\n ms.prepend(\n `import { ${missingDecorators.join(', ')} } from '@angular/core';\\n`,\n );\n }\n\n // Prepend JIT compiler imports\n if (needsJitImport) {\n ms.prepend(\n `import { ɵcompileComponent as _jitCompileComponent, ɵcompileDirective as _jitCompileDirective, ɵcompilePipe as _jitCompilePipe, ɵcompileNgModule as _jitCompileNgModule } from '@angular/core';\\n`,\n );\n }\n\n const map = ms.generateMap({\n source: fileName,\n file: fileName + '.js',\n includeContent: true,\n hires: 'boundary',\n });\n\n return { code: ms.toString(), map };\n}\n"],"mappings":";;;;;;;;;;AAmBA,SAAS,eAAe,MAAkB;CACxC,MAAM,SAAgB,CAAC;CACvB,IAAI,CAAC,QAAQ,OAAO,SAAS,UAAU,OAAO;CAC9C,IAAI,MAAM,QAAQ,IAAI,GAAG;EACvB,KAAK,MAAM,QAAQ,MACjB,OAAO,KAAK,GAAG,eAAe,IAAI,CAAC;EAErC,OAAO;CACT;CACA,IAAI,KAAK,SAAS,sBAAsB,KAAK,SAAS,mBACpD,OAAO,KAAK,IAAI;CAElB,KAAK,MAAM,OAAO,OAAO,KAAK,IAAI,GAAG;EACnC,IACE,QAAQ,UACR,QAAQ,WACR,QAAQ,SACR,QAAQ,WACR,QAAQ,OAER;EACF,OAAO,KAAK,GAAG,eAAe,KAAK,IAAI,CAAC;CAC1C;CACA,OAAO;AACT;;;;;;AAOA,SAAS,2BAA2B,KAAmB;CACrD,MAAM,OAA2B,IAAI,YAAY,QAAQ;CACzD,OAAO,SAAS,gBAAgB,SAAS;AAC3C;;AAGA,SAAS,gBAAgB,IAAiB,YAAoB,KAAgB;CAC5E,IAAI,UAAkB,IAAI;CAC1B,OAAO,UAAU,WAAW,UAAU,KAAK,KAAK,WAAW,QAAQ,GACjE;CACF,GAAG,OAAO,IAAI,OAAO,OAAO;AAC9B;AAEA,IAAM,sCAAsB,IAAI,IAAI;CAClC;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,IAAM,gCAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,oBAAoB,WAAuB;CAClD,MAAM,OAAO,gB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BAA8B,CAAC;CACrC,KAAK,MAAM,OAAO,kBAChB,IAAI,YAAY,SAAS,SAAS,KAAK,KAAK,CAAC,gBAAgB,IAAI,GAAG,GAClE,kBAAkB,KAAK,GAAG;CAG9B,IAAI,kBAAkB,SAAS,GAC7B,GAAG,QACD,YAAY,kBAAkB,KAAK,IAAI,EAAE,2BAC3C;CAIF,IAAI,gBACF,GAAG,QACD,mMACF;CAGF,MAAM,MAAM,GAAG,YAAY;EACzB,QAAQ;EACR,MAAM,WAAW;EACjB,gBAAgB;EAChB,OAAO;CACT,CAAC;CAED,OAAO;EAAE,MAAM,GAAG,SAAS;EAAG;CAAI;AACpC"}
1
+ {"version":3,"file":"jit-transform.js","names":[],"sources":["../../../../src/lib/compiler/jit-transform.ts"],"sourcesContent":["import { parseOxc } from './utils.js';\nimport MagicString from 'magic-string';\nimport { detectTypeOnlyImportNames } from './type-elision.js';\nimport {\n buildCtorParameters,\n buildPropDecorators,\n findConstructor,\n} from './jit-metadata.js';\nimport { ANGULAR_DECORATORS, FIELD_DECORATORS } from './constants.js';\n\nexport interface JitTransformResult {\n code: string;\n map: any;\n}\n\n/**\n * Recursively find all ClassDeclaration nodes in an OXC AST.\n * Handles top-level, exported, and nested classes (e.g. inside function scopes).\n */\nfunction findAllClasses(node: any): any[] {\n const result: any[] = [];\n if (!node || typeof node !== 'object') return result;\n if (Array.isArray(node)) {\n for (const item of node) {\n result.push(...findAllClasses(item));\n }\n return result;\n }\n if (node.type === 'ClassDeclaration' || node.type === 'ClassExpression') {\n result.push(node);\n }\n for (const key of Object.keys(node)) {\n if (\n key === 'type' ||\n key === 'start' ||\n key === 'end' ||\n key === 'range' ||\n key === 'loc'\n )\n continue;\n result.push(...findAllClasses(node[key]));\n }\n return result;\n}\n\n/**\n * `@Injectable` and `@Service` have no JIT compile entry point: their\n * decorator functions self-register ɵprov/ɵfac when applied to the class.\n */\nfunction isSelfRegisteringDecorator(dec: any): boolean {\n const name: string | undefined = dec.expression?.callee?.name;\n return name === 'Injectable' || name === 'Service';\n}\n\n/**\n * Whether jitTransform removes every class decorator. A decorator left for\n * the TypeScript strip would run at class definition, ahead of a\n * self-registering decorator applied after the class, reversing legacy order.\n */\nfunction removesEveryClassDecorator(decorators: any[]): boolean {\n return decorators.every((dec: any) =>\n ANGULAR_DECORATORS.has(dec.expression?.callee?.name),\n );\n}\n\n/** Remove a decorator along with its trailing whitespace. */\nfunction removeDecorator(ms: MagicString, sourceCode: string, dec: any): void {\n let trimEnd: number = dec.end;\n while (trimEnd < sourceCode.length && /\\s/.test(sourceCode[trimEnd]))\n trimEnd++;\n ms.remove(dec.start, trimEnd);\n}\n\n/**\n * Remove a self-registering decorator and return the statement that applies\n * it to the class, as a legacy decorator runs. The output then needs no\n * decorator lowering, which the TypeScript strip only does when tsconfig\n * sets `experimentalDecorators`.\n */\nfunction applySelfRegisteringDecorator(\n ms: MagicString,\n sourceCode: string,\n className: string,\n dec: any,\n): string {\n removeDecorator(ms, sourceCode, dec);\n const call = sourceCode.slice(dec.expression.start, dec.expression.end);\n return `${call}(${className});`;\n}\n\nconst DI_PARAM_DECORATORS = new Set([\n 'Inject',\n 'Optional',\n 'Self',\n 'SkipSelf',\n 'Host',\n 'Attribute',\n]);\nconst PROVIDER_KEYS = new Set([\n 'useClass',\n 'useExisting',\n 'useFactory',\n 'useValue',\n]);\n\nfunction ctorParamDecorators(classNode: any): any[] {\n const ctor = findConstructor(classNode);\n const params: any[] = ctor?.value?.params?.items || ctor?.value?.params || [];\n // Decorators may live on the TSParameterProperty wrapper or the inner param\n return params.flatMap((param: any) => [\n ...(param.decorators || []),\n ...(param.type === 'TSParameterProperty' && param.parameter?.decorators\n ? param.parameter.decorators\n : []),\n ]);\n}\n\n/**\n * Whether an @Injectable/@Service class needs ctorParameters. Skipped when a\n * provider option replaces the constructor, or when a non-DI parameter\n * decorator must keep running as written.\n */\nfunction needsInjectableCtorParameters(node: any, dec: any): boolean {\n const options = dec.expression.arguments?.[0];\n return (\n !options?.properties?.some((p: any) => PROVIDER_KEYS.has(p.key?.name)) &&\n ctorParamDecorators(node).every((d: any) =>\n DI_PARAM_DECORATORS.has(d.expression?.callee?.name),\n )\n );\n}\n\n/**\n * JIT transform for Angular files.\n *\n * Converts Angular decorators to static metadata arrays that Angular's\n * runtime JIT compiler reads via ReflectionCapabilities:\n *\n * - Class.decorators = [{ type: Component, args: [{...}] }]\n * - Class.ctorParameters = () => [{ type: ServiceA, decorators: [{type: Optional}] }]\n * - Class.propDecorators = { name: [{ type: Input }], ... }\n *\n * Also emits ɵfac (factory function) with constructor DI and downlevels\n * signal APIs (input, model, output, viewChild, etc.) to propDecorators.\n *\n * No template compilation — Angular's JIT compiler handles that at runtime.\n * Requires `import '@angular/compiler'` in main.ts for the browser JIT.\n *\n * Uses OXC's native Rust parser instead of TypeScript's parser for ~1.5x\n * faster parsing and source-position slicing instead of getText() calls.\n */\nexport function jitTransform(\n sourceCode: string,\n fileName: string,\n): JitTransformResult {\n const { program } = parseOxc(fileName, sourceCode);\n const ms = new MagicString(sourceCode, { filename: fileName });\n const typeOnlyImports = detectTypeOnlyImportNames(sourceCode, program);\n let hasAngularClass = false;\n\n const allClasses = findAllClasses(program.body);\n\n // Accumulates every class's emitted statements so the post-loop import\n // detection (missing field-decorator imports) can scan all of them.\n // The statements themselves are inserted in-scope after each class via\n // `ms.appendLeft(node.end, ...)` rather than dumped at the end of the\n // file — a class declared inside a function/callback scope (e.g. a host\n // `@Component` defined inside a `describe(...)`/`it(...)` block in a test)\n // is not in scope at module end, so a file-end emit would reference an\n // undefined name (#2360).\n const allEmittedStatements: string[] = [];\n let importCounter = 0;\n const resourceImports: string[] = [];\n let needsJitImport = false;\n\n for (const node of allClasses) {\n const decorators: any[] = node.decorators || [];\n\n const angularDecs = decorators.filter((dec: any) => {\n const expr = dec.expression;\n if (!expr || expr.type !== 'CallExpression') return false;\n const name: string | undefined = expr.callee?.name;\n if (isSelfRegisteringDecorator(dec)) return false;\n return name !== undefined && ANGULAR_DECORATORS.has(name);\n });\n const className: string | undefined = node.id?.name;\n if (!className) continue;\n\n // A class expression's name is not in scope after it, so only\n // declarations get their @Injectable/@Service applied after the class.\n const selfRegistering =\n node.type === 'ClassDeclaration'\n ? decorators.find(isSelfRegisteringDecorator)\n : undefined;\n const appliesSelfRegistering =\n !!selfRegistering && removesEveryClassDecorator(decorators);\n\n if (angularDecs.length === 0) {\n if (!selfRegistering) continue;\n // Without a type checker or emitDecoratorMetadata a param typed only\n // by annotation has no runtime DI token unless captured in\n // ctorParameters.\n const statements: string[] = [];\n const ctorParams =\n needsInjectableCtorParameters(node, selfRegistering) &&\n buildCtorParameters(node, sourceCode, typeOnlyImports);\n if (ctorParams) {\n for (const dec of ctorParamDecorators(node)) {\n removeDecorator(ms, sourceCode, dec);\n }\n statements.push(`${className}.ctorParameters = () => [${ctorParams}];`);\n }\n if (appliesSelfRegistering) {\n statements.push(\n applySelfRegisteringDecorator(\n ms,\n sourceCode,\n className,\n selfRegistering,\n ),\n );\n }\n if (statements.length === 0) continue;\n hasAngularClass = true;\n ms.appendLeft(node.end, `\\n${statements.join('\\n')}\\n`);\n continue;\n }\n hasAngularClass = true;\n\n // Statements emitted for THIS class. Inserted directly after the class\n // body (see end of loop) so they run in the class's own lexical scope.\n const classStatements: string[] = [];\n\n // 1. Remove Angular decorators from source\n for (const dec of angularDecs) {\n removeDecorator(ms, sourceCode, dec);\n }\n\n // 2. Emit Class.decorators = [{ type: DecName, args: [...] }]\n // For @Component: convert templateUrl/styleUrl/styleUrls to ESM imports\n const decoratorMeta: { name: string; argsText: string }[] = [];\n const decoratorEntries = angularDecs.map((dec: any) => {\n const call = dec.expression;\n const decName: string = call.callee.name;\n const args: any[] = call.arguments || [];\n\n if (\n args.length > 0 &&\n decName === 'Component' &&\n args[0].type === 'ObjectExpression'\n ) {\n // Rewrite component metadata: convert external resources to imports\n const obj = args[0];\n const rewrittenProps: string[] = [];\n\n for (const prop of obj.properties) {\n if (prop.type !== 'ObjectProperty' && prop.type !== 'Property') {\n rewrittenProps.push(sourceCode.slice(prop.start, prop.end));\n continue;\n }\n const key: string = prop.key?.name || prop.key?.value;\n const val = prop.value;\n\n if (\n key === 'templateUrl' &&\n (val?.type === 'StringLiteral' ||\n (val?.type === 'Literal' && typeof val.value === 'string'))\n ) {\n // templateUrl: './foo.html' → template: _tpl0 (with import)\n const varName = `_jit_tpl_${importCounter++}`;\n resourceImports.push(`import ${varName} from '${val.value}?raw';`);\n rewrittenProps.push(`template: ${varName}`);\n } else if (\n key === 'styleUrl' &&\n (val?.type === 'StringLiteral' ||\n (val?.type === 'Literal' && typeof val.value === 'string'))\n ) {\n // styleUrl: './foo.scss' → styles: [_style0]\n const varName = `_jit_style_${importCounter++}`;\n resourceImports.push(\n `import ${varName} from '${val.value}?inline';`,\n );\n rewrittenProps.push(`styles: [${varName}]`);\n } else if (key === 'styleUrls' && val?.type === 'ArrayExpression') {\n // styleUrls: ['./a.scss', './b.css'] → styles: [_style0, _style1]\n const vars: string[] = [];\n for (const el of val.elements) {\n if (\n el?.type === 'StringLiteral' ||\n (el?.type === 'Literal' && typeof el.value === 'string')\n ) {\n const varName = `_jit_style_${importCounter++}`;\n resourceImports.push(\n `import ${varName} from '${el.value}?inline';`,\n );\n vars.push(varName);\n }\n }\n rewrittenProps.push(`styles: [${vars.join(', ')}]`);\n } else {\n rewrittenProps.push(sourceCode.slice(prop.start, prop.end));\n }\n }\n const rewrittenArgsText = `{${rewrittenProps.join(', ')}}`;\n decoratorMeta.push({ name: decName, argsText: rewrittenArgsText });\n return `{ type: ${decName}, args: [${rewrittenArgsText}] }`;\n }\n\n if (args.length > 0) {\n const argsText = args\n .map((a: any) => sourceCode.slice(a.start, a.end))\n .join(', ');\n decoratorMeta.push({ name: decName, argsText });\n return `{ type: ${decName}, args: [${argsText}] }`;\n }\n decoratorMeta.push({ name: decName, argsText: '{}' });\n return `{ type: ${decName} }`;\n });\n classStatements.push(\n `${className}.decorators = [${decoratorEntries.join(', ')}];`,\n );\n\n // 2b. Trigger JIT compilation with the rewritten decorator metadata\n for (const dm of decoratorMeta) {\n needsJitImport = true;\n switch (dm.name) {\n case 'Component':\n classStatements.push(\n `_jitCompileComponent(${className}, ${dm.argsText});`,\n );\n break;\n case 'Directive':\n classStatements.push(\n `_jitCompileDirective(${className}, ${dm.argsText});`,\n );\n break;\n case 'Pipe':\n classStatements.push(\n `_jitCompilePipe(${className}, ${dm.argsText});`,\n );\n break;\n case 'NgModule':\n classStatements.push(\n `_jitCompileNgModule(${className}, ${dm.argsText});`,\n );\n break;\n }\n }\n\n // 3. Emit Class.ctorParameters for constructor DI\n const ctorParams = buildCtorParameters(node, sourceCode, typeOnlyImports);\n if (ctorParams) {\n classStatements.push(\n `${className}.ctorParameters = () => [${ctorParams}];`,\n );\n }\n\n // 4. Emit Class.propDecorators for field decorators + signal APIs\n const propDecorators = buildPropDecorators(node, sourceCode);\n if (propDecorators) {\n classStatements.push(`${className}.propDecorators = ${propDecorators};`);\n }\n\n // 5. Remove member and parameter decorators from source now that\n // they have been extracted into static metadata above.\n const members: any[] = node.body?.body || [];\n for (const member of members) {\n for (const dec of member.decorators || []) {\n removeDecorator(ms, sourceCode, dec);\n }\n }\n for (const dec of ctorParamDecorators(node)) {\n removeDecorator(ms, sourceCode, dec);\n }\n\n if (appliesSelfRegistering) {\n classStatements.push(\n applySelfRegisteringDecorator(\n ms,\n sourceCode,\n className,\n selfRegistering,\n ),\n );\n }\n\n // Insert this class's metadata statements directly after the class body\n // so they execute in the class's own lexical scope. `node.end` is the\n // position just past the closing brace (decorators were stripped before\n // `node.start`), so for a top-level class this is module scope and for a\n // class nested in a function/callback it is that enclosing scope —\n // keeping the class identifier in scope either way (#2360).\n if (classStatements.length > 0) {\n allEmittedStatements.push(...classStatements);\n ms.appendLeft(node.end, '\\n' + classStatements.join('\\n') + '\\n');\n }\n }\n\n if (!hasAngularClass) {\n return { code: sourceCode, map: null };\n }\n\n // Prepend ESM imports for external templates/styles\n if (resourceImports.length > 0) {\n ms.prepend(resourceImports.join('\\n') + '\\n');\n }\n\n // Prepend imports for decorator classes referenced by signal API downleveling\n // (e.g. input() → {type: Input}, model() → {type: Input} + {type: Output})\n const existingImports = new Set<string>();\n for (const stmt of program.body) {\n if (\n (stmt as any).type === 'ImportDeclaration' &&\n (stmt as any).source?.value === '@angular/core'\n ) {\n for (const spec of (stmt as any).specifiers || []) {\n if (spec.type === 'ImportSpecifier') {\n existingImports.add(spec.local?.name || spec.imported?.name);\n }\n }\n }\n }\n const allPostCode = allEmittedStatements.join('\\n');\n const missingDecorators: string[] = [];\n for (const dec of FIELD_DECORATORS) {\n if (allPostCode.includes(`type: ${dec}`) && !existingImports.has(dec)) {\n missingDecorators.push(dec);\n }\n }\n if (missingDecorators.length > 0) {\n ms.prepend(\n `import { ${missingDecorators.join(', ')} } from '@angular/core';\\n`,\n );\n }\n\n // Prepend JIT compiler imports\n if (needsJitImport) {\n ms.prepend(\n `import { ɵcompileComponent as _jitCompileComponent, ɵcompileDirective as _jitCompileDirective, ɵcompilePipe as _jitCompilePipe, ɵcompileNgModule as _jitCompileNgModule } from '@angular/core';\\n`,\n );\n }\n\n const map = ms.generateMap({\n source: fileName,\n file: fileName + '.js',\n includeContent: true,\n hires: 'boundary',\n });\n\n return { code: ms.toString(), map };\n}\n"],"mappings":";;;;;;;;;;AAmBA,SAAS,eAAe,MAAkB;CACxC,MAAM,SAAgB,CAAC;CACvB,IAAI,CAAC,QAAQ,OAAO,SAAS,UAAU,OAAO;CAC9C,IAAI,MAAM,QAAQ,IAAI,GAAG;EACvB,KAAK,MAAM,QAAQ,MACjB,OAAO,KAAK,GAAG,eAAe,IAAI,CAAC;EAErC,OAAO;CACT;CACA,IAAI,KAAK,SAAS,sBAAsB,KAAK,SAAS,mBACpD,OAAO,KAAK,IAAI;CAElB,KAAK,MAAM,OAAO,OAAO,KAAK,IAAI,GAAG;EACnC,IACE,QAAQ,UACR,QAAQ,WACR,QAAQ,SACR,QAAQ,WACR,QAAQ,OAER;EACF,OAAO,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B,KAAK,GAAG;CAG9B,IAAI,kBAAkB,SAAS,GAC7B,GAAG,QACD,YAAY,kBAAkB,KAAK,IAAI,EAAE,2BAC3C;CAIF,IAAI,gBACF,GAAG,QACD,mMACF;CAGF,MAAM,MAAM,GAAG,YAAY;EACzB,QAAQ;EACR,MAAM,WAAW;EACjB,gBAAgB;EAChB,OAAO;CACT,CAAC;CAED,OAAO;EAAE,MAAM,GAAG,SAAS;EAAG;CAAI;AACpC"}
@@ -1,4 +1,6 @@
1
1
  import type { parseSync } from "oxc-parser";
2
+ /** An object property's key, quoted (`'styles'`) or not (`styles`). */
3
+ export declare function getPropertyKey(prop: any): string | undefined;
2
4
  /**
3
5
  * Extract styleUrl/styleUrls values from Angular @Component decorators.
4
6
  */
@@ -8,10 +10,21 @@ export declare function extractStyleUrls(code: string, fileName: string): string
8
10
  */
9
11
  export declare function extractInlineStyles(code: string, fileName: string, program?: ReturnType<typeof parseSync>["program"]): string[];
10
12
  /**
11
- * Map each @Component decorator node to the range of its styles in the flat
13
+ * An inline style string, the AST node it was read from, and its position in
14
+ * the `styles` array (0 for a single `styles` value).
15
+ */
16
+ export interface InlineStyle {
17
+ text: string;
18
+ node: any;
19
+ index: number;
20
+ }
21
+ /**
22
+ * A component's inline styles and the index of the first one in the flat
12
23
  * per-file list returned by {@link extractInlineStyles}.
13
24
  */
14
- export declare function inlineStyleRanges(program: ReturnType<typeof parseSync>["program"]): Map<any, {
25
+ export interface InlineStyleRange {
15
26
  start: number;
16
- count: number;
17
- }>;
27
+ styles: InlineStyle[];
28
+ }
29
+ /** Map each @Component decorator node to its {@link InlineStyleRange}. */
30
+ export declare function inlineStyleRanges(program: ReturnType<typeof parseSync>["program"]): Map<any, InlineStyleRange>;
@@ -3,9 +3,14 @@ import { parseOxc } from "./utils.js";
3
3
  function getClassDeclaration(node) {
4
4
  return node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration" ? node.declaration : node;
5
5
  }
6
+ /** An object property's key, quoted (`'styles'`) or not (`styles`). */
6
7
  function getPropertyKey(prop) {
7
8
  return prop.key?.name || prop.key?.value;
8
9
  }
10
+ function styleText(node) {
11
+ if (node?.type === "Literal" && typeof node.value === "string") return node.value;
12
+ return getTemplateLiteralText(node);
13
+ }
9
14
  function getTemplateLiteralText(node) {
10
15
  if (node?.type !== "TemplateLiteral" || node.quasis?.length !== 1) return;
11
16
  return node.quasis[0].value.cooked || node.quasis[0].value.raw;
@@ -15,19 +20,16 @@ function getTemplateLiteralText(node) {
15
20
  */
16
21
  function extractInlineStyles(code, fileName, program) {
17
22
  program ??= parseOxc(fileName, code).program;
18
- return [...componentInlineStyles(program).values()].flat();
23
+ return [...componentInlineStyles(program).values()].flat().map((style) => style.text);
19
24
  }
20
- /**
21
- * Map each @Component decorator node to the range of its styles in the flat
22
- * per-file list returned by {@link extractInlineStyles}.
23
- */
25
+ /** Map each @Component decorator node to its {@link InlineStyleRange}. */
24
26
  function inlineStyleRanges(program) {
25
27
  const ranges = /* @__PURE__ */ new Map();
26
28
  let start = 0;
27
29
  for (const [decorator, styles] of componentInlineStyles(program)) {
28
30
  ranges.set(decorator, {
29
31
  start,
30
- count: styles.length
32
+ styles
31
33
  });
32
34
  start += styles.length;
33
35
  }
@@ -51,25 +53,20 @@ function componentInlineStyles(program) {
51
53
  const key = getPropertyKey(prop);
52
54
  const val = prop.value;
53
55
  if (key !== "styles") continue;
54
- if (val?.type === "ArrayExpression") for (const el of val.elements) {
55
- if (el?.type === "Literal" && typeof el.value === "string") {
56
- styles.push(el.value);
57
- continue;
58
- }
59
- const templateText = getTemplateLiteralText(el);
60
- if (templateText !== void 0) styles.push(templateText);
61
- }
62
- else if (val?.type === "Literal" && typeof val.value === "string") styles.push(val.value);
63
- else {
64
- const templateText = getTemplateLiteralText(val);
65
- if (templateText !== void 0) styles.push(templateText);
66
- }
56
+ (val?.type === "ArrayExpression" ? val.elements : [val]).forEach((node, index) => {
57
+ const text = styleText(node);
58
+ if (text !== void 0) styles.push({
59
+ text,
60
+ node,
61
+ index
62
+ });
63
+ });
67
64
  }
68
65
  }
69
66
  }
70
67
  return result;
71
68
  }
72
69
  //#endregion
73
- export { extractInlineStyles, inlineStyleRanges };
70
+ export { extractInlineStyles, getPropertyKey, inlineStyleRanges };
74
71
 
75
72
  //# sourceMappingURL=style-ast.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"style-ast.js","names":[],"sources":["../../../../src/lib/compiler/style-ast.ts"],"sourcesContent":["import type { parseSync } from 'oxc-parser';\nimport { parseOxc } from './utils.js';\n\ntype ProgramNode = ReturnType<typeof parseSync>['program']['body'][number];\n\nfunction getClassDeclaration(node: ProgramNode): any {\n return node.type === 'ExportNamedDeclaration' ||\n node.type === 'ExportDefaultDeclaration'\n ? (node as any).declaration\n : node;\n}\n\nfunction getPropertyKey(prop: any): string | undefined {\n return prop.key?.name || prop.key?.value;\n}\n\nfunction getTemplateLiteralText(node: any): string | undefined {\n if (node?.type !== 'TemplateLiteral' || node.quasis?.length !== 1) {\n return undefined;\n }\n\n return node.quasis[0].value.cooked || node.quasis[0].value.raw;\n}\n\n/**\n * Extract styleUrl/styleUrls values from Angular @Component decorators.\n */\nexport function extractStyleUrls(code: string, fileName: string): string[] {\n const urls: string[] = [];\n const { program } = parseOxc(fileName, code);\n\n for (const node of program.body) {\n const decl = getClassDeclaration(node);\n if (!decl || decl.type !== 'ClassDeclaration') continue;\n\n for (const dec of decl.decorators || []) {\n const expr = dec.expression;\n if (!expr || expr.type !== 'CallExpression') continue;\n if (expr.callee?.name !== 'Component') continue;\n\n const arg = expr.arguments?.[0];\n if (!arg || arg.type !== 'ObjectExpression') continue;\n\n for (const prop of arg.properties) {\n if (prop.type !== 'Property') continue;\n const key = getPropertyKey(prop);\n const val = prop.value;\n\n if (\n key === 'styleUrl' &&\n val?.type === 'Literal' &&\n typeof val.value === 'string'\n ) {\n urls.push(val.value);\n }\n\n if (key === 'styleUrls' && val?.type === 'ArrayExpression') {\n for (const el of val.elements) {\n if (el?.type === 'Literal' && typeof el.value === 'string') {\n urls.push(el.value);\n }\n }\n }\n }\n }\n }\n\n return urls;\n}\n\n/**\n * Extract inline style strings from Angular @Component decorators.\n */\nexport function extractInlineStyles(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): string[] {\n program ??= parseOxc(fileName, code).program;\n return [...componentInlineStyles(program).values()].flat();\n}\n\n/**\n * Map each @Component decorator node to the range of its styles in the flat\n * per-file list returned by {@link extractInlineStyles}.\n */\nexport function inlineStyleRanges(\n program: ReturnType<typeof parseSync>['program'],\n): Map<any, { start: number; count: number }> {\n const ranges = new Map<any, { start: number; count: number }>();\n let start = 0;\n for (const [decorator, styles] of componentInlineStyles(program)) {\n ranges.set(decorator, { start, count: styles.length });\n start += styles.length;\n }\n return ranges;\n}\n\nfunction componentInlineStyles(\n program: ReturnType<typeof parseSync>['program'],\n): Map<any, string[]> {\n const result = new Map<any, string[]>();\n\n for (const node of program.body) {\n const decl = getClassDeclaration(node);\n if (!decl || decl.type !== 'ClassDeclaration') continue;\n\n for (const dec of decl.decorators || []) {\n const expr = dec.expression;\n if (!expr || expr.type !== 'CallExpression') continue;\n if (expr.callee?.name !== 'Component') continue;\n\n const arg = expr.arguments?.[0];\n if (!arg || arg.type !== 'ObjectExpression') continue;\n\n const styles: string[] = [];\n result.set(dec, styles);\n\n for (const prop of arg.properties) {\n if (prop.type !== 'Property') continue;\n const key = getPropertyKey(prop);\n const val = prop.value;\n\n if (key !== 'styles') continue;\n\n if (val?.type === 'ArrayExpression') {\n for (const el of val.elements) {\n if (el?.type === 'Literal' && typeof el.value === 'string') {\n styles.push(el.value);\n continue;\n }\n\n const templateText = getTemplateLiteralText(el);\n if (templateText !== undefined) {\n styles.push(templateText);\n }\n }\n } else if (val?.type === 'Literal' && typeof val.value === 'string') {\n styles.push(val.value);\n } else {\n const templateText = getTemplateLiteralText(val);\n if (templateText !== undefined) {\n styles.push(templateText);\n }\n }\n }\n }\n }\n\n return result;\n}\n"],"mappings":";;AAKA,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AAQ,IAAI,YAAY;IACjC,IAAI,KAAK,SAAS,YAAY;IAC9B,MAAM,MAAM,eAAe,IAAI;IAC/B,MAAM,MAAM,KAAK;IAEjB,IAAI,QAAQ,UAAU;IAEtB,IAAI,KAAK,SAAS,mBAChB,KAAK,MAAM,MAAM,IAAI,UAAU;KAC7B,IAAI,IAAI,SAAS,aAAa,OAAO,GAAG,UAAU,UAAU;MAC1D,OAAO,KAAK,GAAG,KAAK;MACpB;KACF;KAEA,MAAM,eAAe,uBAAuB,EAAE;KAC9C,IAAI,iBAAiB,KAAA,GACnB,OAAO,KAAK,YAAY;IAE5B;SACK,IAAI,KAAK,SAAS,aAAa,OAAO,IAAI,UAAU,UACzD,OAAO,KAAK,IAAI,KAAK;SAChB;KACL,MAAM,eAAe,uBAAuB,GAAG;KAC/C,IAAI,iBAAiB,KAAA,GACnB,OAAO,KAAK,YAAY;IAE5B;GACF;EACF;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"style-ast.js","names":[],"sources":["../../../../src/lib/compiler/style-ast.ts"],"sourcesContent":["import type { parseSync } from 'oxc-parser';\nimport { parseOxc } from './utils.js';\n\ntype ProgramNode = ReturnType<typeof parseSync>['program']['body'][number];\n\nfunction getClassDeclaration(node: ProgramNode): any {\n return node.type === 'ExportNamedDeclaration' ||\n node.type === 'ExportDefaultDeclaration'\n ? (node as any).declaration\n : node;\n}\n\n/** An object property's key, quoted (`'styles'`) or not (`styles`). */\nexport function getPropertyKey(prop: any): string | undefined {\n return prop.key?.name || prop.key?.value;\n}\n\nfunction styleText(node: any): string | undefined {\n if (node?.type === 'Literal' && typeof node.value === 'string') {\n return node.value;\n }\n return getTemplateLiteralText(node);\n}\n\nfunction getTemplateLiteralText(node: any): string | undefined {\n if (node?.type !== 'TemplateLiteral' || node.quasis?.length !== 1) {\n return undefined;\n }\n\n return node.quasis[0].value.cooked || node.quasis[0].value.raw;\n}\n\n/**\n * Extract styleUrl/styleUrls values from Angular @Component decorators.\n */\nexport function extractStyleUrls(code: string, fileName: string): string[] {\n const urls: string[] = [];\n const { program } = parseOxc(fileName, code);\n\n for (const node of program.body) {\n const decl = getClassDeclaration(node);\n if (!decl || decl.type !== 'ClassDeclaration') continue;\n\n for (const dec of decl.decorators || []) {\n const expr = dec.expression;\n if (!expr || expr.type !== 'CallExpression') continue;\n if (expr.callee?.name !== 'Component') continue;\n\n const arg = expr.arguments?.[0];\n if (!arg || arg.type !== 'ObjectExpression') continue;\n\n for (const prop of arg.properties) {\n if (prop.type !== 'Property') continue;\n const key = getPropertyKey(prop);\n const val = prop.value;\n\n if (\n key === 'styleUrl' &&\n val?.type === 'Literal' &&\n typeof val.value === 'string'\n ) {\n urls.push(val.value);\n }\n\n if (key === 'styleUrls' && val?.type === 'ArrayExpression') {\n for (const el of val.elements) {\n if (el?.type === 'Literal' && typeof el.value === 'string') {\n urls.push(el.value);\n }\n }\n }\n }\n }\n }\n\n return urls;\n}\n\n/**\n * Extract inline style strings from Angular @Component decorators.\n */\nexport function extractInlineStyles(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): string[] {\n program ??= parseOxc(fileName, code).program;\n return [...componentInlineStyles(program).values()]\n .flat()\n .map((style) => style.text);\n}\n\n/**\n * An inline style string, the AST node it was read from, and its position in\n * the `styles` array (0 for a single `styles` value).\n */\nexport interface InlineStyle {\n text: string;\n node: any;\n index: number;\n}\n\n/**\n * A component's inline styles and the index of the first one in the flat\n * per-file list returned by {@link extractInlineStyles}.\n */\nexport interface InlineStyleRange {\n start: number;\n styles: InlineStyle[];\n}\n\n/** Map each @Component decorator node to its {@link InlineStyleRange}. */\nexport function inlineStyleRanges(\n program: ReturnType<typeof parseSync>['program'],\n): Map<any, InlineStyleRange> {\n const ranges = new Map<any, InlineStyleRange>();\n let start = 0;\n for (const [decorator, styles] of componentInlineStyles(program)) {\n ranges.set(decorator, { start, styles });\n start += styles.length;\n }\n return ranges;\n}\n\nfunction componentInlineStyles(\n program: ReturnType<typeof parseSync>['program'],\n): Map<any, InlineStyle[]> {\n const result = new Map<any, InlineStyle[]>();\n\n for (const node of program.body) {\n const decl = getClassDeclaration(node);\n if (!decl || decl.type !== 'ClassDeclaration') continue;\n\n for (const dec of decl.decorators || []) {\n const expr = dec.expression;\n if (!expr || expr.type !== 'CallExpression') continue;\n if (expr.callee?.name !== 'Component') continue;\n\n const arg = expr.arguments?.[0];\n if (!arg || arg.type !== 'ObjectExpression') continue;\n\n const styles: InlineStyle[] = [];\n result.set(dec, styles);\n\n for (const prop of arg.properties) {\n if (prop.type !== 'Property') continue;\n const key = getPropertyKey(prop);\n const val = prop.value;\n\n if (key !== 'styles') continue;\n\n const nodes = val?.type === 'ArrayExpression' ? val.elements : [val];\n nodes.forEach((node: any, index: number) => {\n const text = styleText(node);\n if (text !== undefined) styles.push({ text, node, index });\n });\n }\n }\n }\n\n return result;\n}\n"],"mappings":";;AAKA,SAAS,oBAAoB,MAAwB;CACnD,OAAO,KAAK,SAAS,4BACnB,KAAK,SAAS,6BACX,KAAa,cACd;AACN;;AAGA,SAAgB,eAAe,MAA+B;CAC5D,OAAO,KAAK,KAAK,QAAQ,KAAK,KAAK;AACrC;AAEA,SAAS,UAAU,MAA+B;CAChD,IAAI,MAAM,SAAS,aAAa,OAAO,KAAK,UAAU,UACpD,OAAO,KAAK;CAEd,OAAO,uBAAuB,IAAI;AACpC;AAEA,SAAS,uBAAuB,MAA+B;CAC7D,IAAI,MAAM,SAAS,qBAAqB,KAAK,QAAQ,WAAW,GAC9D;CAGF,OAAO,KAAK,OAAO,EAAE,CAAC,MAAM,UAAU,KAAK,OAAO,EAAE,CAAC,MAAM;AAC7D;;;;AAmDA,SAAgB,oBACd,MACA,UACA,SACU;CACV,YAAY,SAAS,UAAU,IAAI,CAAC,CAAC;CACrC,OAAO,CAAC,GAAG,sBAAsB,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAChD,KAAK,CAAC,CACN,KAAK,UAAU,MAAM,IAAI;AAC9B;;AAsBA,SAAgB,kBACd,SAC4B;CAC5B,MAAM,yBAAS,IAAI,IAA2B;CAC9C,IAAI,QAAQ;CACZ,KAAK,MAAM,CAAC,WAAW,WAAW,sBAAsB,OAAO,GAAG;EAChE,OAAO,IAAI,WAAW;GAAE;GAAO;EAAO,CAAC;EACvC,SAAS,OAAO;CAClB;CACA,OAAO;AACT;AAEA,SAAS,sBACP,SACyB;CACzB,MAAM,yBAAS,IAAI,IAAwB;CAE3C,KAAK,MAAM,QAAQ,QAAQ,MAAM;EAC/B,MAAM,OAAO,oBAAoB,IAAI;EACrC,IAAI,CAAC,QAAQ,KAAK,SAAS,oBAAoB;EAE/C,KAAK,MAAM,OAAO,KAAK,cAAc,CAAC,GAAG;GACvC,MAAM,OAAO,IAAI;GACjB,IAAI,CAAC,QAAQ,KAAK,SAAS,kBAAkB;GAC7C,IAAI,KAAK,QAAQ,SAAS,aAAa;GAEvC,MAAM,MAAM,KAAK,YAAY;GAC7B,IAAI,CAAC,OAAO,IAAI,SAAS,oBAAoB;GAE7C,MAAM,SAAwB,CAAC;GAC/B,OAAO,IAAI,KAAK,MAAM;GAEtB,KAAK,MAAM,QAAQ,IAAI,YAAY;IACjC,IAAI,KAAK,SAAS,YAAY;IAC9B,MAAM,MAAM,eAAe,IAAI;IAC/B,MAAM,MAAM,KAAK;IAEjB,IAAI,QAAQ,UAAU;IAGtB,CADc,KAAK,SAAS,oBAAoB,IAAI,WAAW,CAAC,GAAG,EAAA,CAC7D,SAAS,MAAW,UAAkB;KAC1C,MAAM,OAAO,UAAU,IAAI;KAC3B,IAAI,SAAS,KAAA,GAAW,OAAO,KAAK;MAAE;MAAM;MAAM;KAAM,CAAC;IAC3D,CAAC;GACH;EACF;CACF;CAEA,OAAO;AACT"}
@@ -2,9 +2,34 @@ import { isAngularBuildContext } from "./angular-build-context.js";
2
2
  import { markStylePathSafe } from "./utils/safe-module-paths.js";
3
3
  import { toVirtualRawId } from "./utils/virtual-ids.js";
4
4
  import { loadVirtualRawModule, rewriteHtmlRawImport } from "./utils/virtual-resources.js";
5
- import { dirname, isAbsolute, resolve } from "node:path";
5
+ import { statSync } from "node:fs";
6
+ import { dirname, isAbsolute, join, resolve } from "node:path";
6
7
  import { normalizePath } from "vite";
7
8
  //#region packages/vite-plugin-angular/src/lib/virtual-modules-plugin.ts
9
+ var FS_PREFIX = "/@fs/";
10
+ function isDirectory(path) {
11
+ return statSync(path, { throwIfNoEntry: false })?.isDirectory() ?? false;
12
+ }
13
+ /**
14
+ * The file a URL that Vite wrote into a module's code points at. Vitest
15
+ * resolves the imports of a module restored from `fsModuleCache` by these
16
+ * URLs, so they must resolve to the same file as the original import.
17
+ * `/@fs/<path>` is that path. A root-relative URL (`/src/app/a.css`) is the
18
+ * file under the Vite root when there is one; otherwise the caller reads it
19
+ * as the path given, which is the order Vite tries the two in. A URL that
20
+ * already starts with the root's path is root-relative only when the root
21
+ * holds a directory at its own path (`/app/app`), as in Vite's resolver.
22
+ */
23
+ function resolveViteUrl(url, root) {
24
+ if (url.startsWith(FS_PREFIX)) {
25
+ const fsPath = url.slice(5);
26
+ return /^[A-Z]:/i.test(fsPath) ? fsPath : `/${fsPath}`;
27
+ }
28
+ if (!root || !url.startsWith("/")) return;
29
+ if (url.startsWith(`${root}/`) && !isDirectory(join(root, root))) return;
30
+ const filePath = join(root, url);
31
+ return statSync(filePath, { throwIfNoEntry: false })?.isFile() ? filePath : void 0;
32
+ }
8
33
  function resolveAngularVirtualId(id, importer, options) {
9
34
  if (id.startsWith("virtual:@analogjs/vite-plugin-angular:raw:")) return `\0${id}`;
10
35
  if (options.jit && id.startsWith("angular:jit:")) {
@@ -19,7 +44,7 @@ function resolveAngularVirtualId(id, importer, options) {
19
44
  if (rawRewrite) return rawRewrite;
20
45
  if (/\.(css|scss|sass|less)\?inline$/.test(id) && importer) {
21
46
  const filePath = id.split("?")[0];
22
- const resolved = isAbsolute(filePath) ? normalizePath(filePath) : normalizePath(resolve(dirname(importer), filePath));
47
+ const resolved = normalizePath(resolveViteUrl(filePath, options.resolvedConfig?.root) ?? (isAbsolute(filePath) ? filePath : resolve(dirname(importer), filePath)));
23
48
  markStylePathSafe(options.resolvedConfig, resolved);
24
49
  return resolved + "?inline";
25
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-modules-plugin.js","names":[],"sources":["../../../src/lib/virtual-modules-plugin.ts"],"sourcesContent":["import { dirname, isAbsolute, resolve } from 'node:path';\nimport { normalizePath, type Plugin, type ResolvedConfig } from 'vite';\nimport {\n isAngularBuildContext,\n type AngularBuildContext,\n} from './angular-build-context.js';\nimport { markStylePathSafe } from './utils/safe-module-paths.js';\nimport { VIRTUAL_RAW_PREFIX, toVirtualRawId } from './utils/virtual-ids.js';\nimport {\n loadVirtualRawModule,\n rewriteHtmlRawImport,\n} from './utils/virtual-resources.js';\n\nexport interface VirtualModulesPluginOptions {\n jit?: boolean;\n}\n\nexport function resolveAngularVirtualId(\n id: string,\n importer: string | undefined,\n options: {\n jit: boolean;\n resolvedConfig?: ResolvedConfig;\n },\n): string | undefined {\n if (id.startsWith(VIRTUAL_RAW_PREFIX)) {\n return `\\0${id}`;\n }\n\n if (options.jit && id.startsWith('angular:jit:')) {\n const filePath = normalizePath(\n resolve(dirname(importer as string), id.split(';')[1]),\n );\n if (id.includes(':style')) {\n markStylePathSafe(options.resolvedConfig, filePath);\n return filePath + '?inline';\n }\n return toVirtualRawId(filePath);\n }\n\n // Intercept .html?raw imports to bypass Vite server.fs restrictions\n const rawRewrite = rewriteHtmlRawImport(id, importer);\n if (rawRewrite) {\n return rawRewrite;\n }\n\n // User `.scss?inline` / `.css?inline` imports: resolve and mark\n // safe so Vite's native CSS pipeline handles them.\n if (/\\.(css|scss|sass|less)\\?inline$/.test(id) && importer) {\n const filePath = id.split('?')[0];\n const resolved = isAbsolute(filePath)\n ? normalizePath(filePath)\n : normalizePath(resolve(dirname(importer), filePath));\n markStylePathSafe(options.resolvedConfig, resolved);\n return resolved + '?inline';\n }\n\n return undefined;\n}\n\nexport async function loadAngularVirtualModule(\n pluginCtx: { addWatchFile(path: string): void },\n id: string,\n resolvedConfig?: ResolvedConfig,\n): Promise<string | undefined> {\n const rawModule = await loadVirtualRawModule(pluginCtx, id);\n if (rawModule !== undefined) {\n return rawModule;\n }\n\n // Vitest fallback: the module-runner can skip resolveId, so the bare\n // ?inline query reaches load. Mark safe and let Vite handle it.\n if (/\\.(css|scss|sass|less)\\?inline$/.test(id)) {\n markStylePathSafe(resolvedConfig, id.split('?')[0]);\n }\n\n return undefined;\n}\n\nexport function virtualModulesPlugin(\n ctxOrOptions?: AngularBuildContext | VirtualModulesPluginOptions,\n): Plugin {\n const sharedCtx = isAngularBuildContext(ctxOrOptions)\n ? ctxOrOptions\n : undefined;\n const standaloneJit = isAngularBuildContext(ctxOrOptions)\n ? ctxOrOptions.options.jit\n : (ctxOrOptions?.jit ?? false);\n let localConfig: ResolvedConfig | undefined;\n\n return {\n name: '@analogjs/vite-plugin-angular:virtual-modules',\n enforce: 'pre',\n configResolved(config) {\n localConfig = config;\n sharedCtx?.setResolvedConfig(config);\n },\n resolveId(id, importer) {\n return resolveAngularVirtualId(id, importer, {\n jit: sharedCtx ? sharedCtx.options.jit : standaloneJit,\n resolvedConfig: sharedCtx?.resolvedConfig ?? localConfig,\n });\n },\n async load(id) {\n return loadAngularVirtualModule(\n this,\n id,\n sharedCtx?.resolvedConfig ?? localConfig,\n );\n },\n };\n}\n"],"mappings":";;;;;;;AAiBA,SAAgB,wBACd,IACA,UACA,SAIoB;CACpB,IAAI,GAAG,WAAA,4CAA6B,GAClC,OAAO,KAAK;CAGd,IAAI,QAAQ,OAAO,GAAG,WAAW,cAAc,GAAG;EAChD,MAAM,WAAW,cACf,QAAQ,QAAQ,QAAkB,GAAG,GAAG,MAAM,GAAG,CAAC,CAAC,EAAE,CACvD;EACA,IAAI,GAAG,SAAS,QAAQ,GAAG;GACzB,kBAAkB,QAAQ,gBAAgB,QAAQ;GAClD,OAAO,WAAW;EACpB;EACA,OAAO,eAAe,QAAQ;CAChC;CAGA,MAAM,aAAa,qBAAqB,IAAI,QAAQ;CACpD,IAAI,YACF,OAAO;CAKT,IAAI,kCAAkC,KAAK,EAAE,KAAK,UAAU;EAC1D,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,CAAC;EAC/B,MAAM,WAAW,WAAW,QAAQ,IAChC,cAAc,QAAQ,IACtB,cAAc,QAAQ,QAAQ,QAAQ,GAAG,QAAQ,CAAC;EACtD,kBAAkB,QAAQ,gBAAgB,QAAQ;EAClD,OAAO,WAAW;CACpB;AAGF;AAEA,eAAsB,yBACpB,WACA,IACA,gBAC6B;CAC7B,MAAM,YAAY,MAAM,qBAAqB,WAAW,EAAE;CAC1D,IAAI,cAAc,KAAA,GAChB,OAAO;CAKT,IAAI,kCAAkC,KAAK,EAAE,GAC3C,kBAAkB,gBAAgB,GAAG,MAAM,GAAG,CAAC,CAAC,EAAE;AAItD;AAEA,SAAgB,qBACd,cACQ;CACR,MAAM,YAAY,sBAAsB,YAAY,IAChD,eACA,KAAA;CACJ,MAAM,gBAAgB,sBAAsB,YAAY,IACpD,aAAa,QAAQ,MACpB,cAAc,OAAO;CAC1B,IAAI;CAEJ,OAAO;EACL,MAAM;EACN,SAAS;EACT,eAAe,QAAQ;GACrB,cAAc;GACd,WAAW,kBAAkB,MAAM;EACrC;EACA,UAAU,IAAI,UAAU;GACtB,OAAO,wBAAwB,IAAI,UAAU;IAC3C,KAAK,YAAY,UAAU,QAAQ,MAAM;IACzC,gBAAgB,WAAW,kBAAkB;GAC/C,CAAC;EACH;EACA,MAAM,KAAK,IAAI;GACb,OAAO,yBACL,MACA,IACA,WAAW,kBAAkB,WAC/B;EACF;CACF;AACF"}
1
+ {"version":3,"file":"virtual-modules-plugin.js","names":[],"sources":["../../../src/lib/virtual-modules-plugin.ts"],"sourcesContent":["import { statSync } from 'node:fs';\nimport { dirname, isAbsolute, join, resolve } from 'node:path';\nimport { normalizePath, type Plugin, type ResolvedConfig } from 'vite';\nimport {\n isAngularBuildContext,\n type AngularBuildContext,\n} from './angular-build-context.js';\nimport { markStylePathSafe } from './utils/safe-module-paths.js';\nimport { VIRTUAL_RAW_PREFIX, toVirtualRawId } from './utils/virtual-ids.js';\nimport {\n loadVirtualRawModule,\n rewriteHtmlRawImport,\n} from './utils/virtual-resources.js';\n\nexport interface VirtualModulesPluginOptions {\n jit?: boolean;\n}\n\nconst FS_PREFIX = '/@fs/';\n\nfunction isDirectory(path: string): boolean {\n return statSync(path, { throwIfNoEntry: false })?.isDirectory() ?? false;\n}\n\n/**\n * The file a URL that Vite wrote into a module's code points at. Vitest\n * resolves the imports of a module restored from `fsModuleCache` by these\n * URLs, so they must resolve to the same file as the original import.\n * `/@fs/<path>` is that path. A root-relative URL (`/src/app/a.css`) is the\n * file under the Vite root when there is one; otherwise the caller reads it\n * as the path given, which is the order Vite tries the two in. A URL that\n * already starts with the root's path is root-relative only when the root\n * holds a directory at its own path (`/app/app`), as in Vite's resolver.\n */\nfunction resolveViteUrl(\n url: string,\n root: string | undefined,\n): string | undefined {\n if (url.startsWith(FS_PREFIX)) {\n const fsPath = url.slice(FS_PREFIX.length);\n // `/@fs/C:/a.css` on Windows, `/@fs/home/a.css` elsewhere.\n return /^[A-Z]:/i.test(fsPath) ? fsPath : `/${fsPath}`;\n }\n if (!root || !url.startsWith('/')) {\n return undefined;\n }\n if (url.startsWith(`${root}/`) && !isDirectory(join(root, root))) {\n return undefined;\n }\n const filePath = join(root, url);\n return statSync(filePath, { throwIfNoEntry: false })?.isFile()\n ? filePath\n : undefined;\n}\n\nexport function resolveAngularVirtualId(\n id: string,\n importer: string | undefined,\n options: {\n jit: boolean;\n resolvedConfig?: ResolvedConfig;\n },\n): string | undefined {\n if (id.startsWith(VIRTUAL_RAW_PREFIX)) {\n return `\\0${id}`;\n }\n\n if (options.jit && id.startsWith('angular:jit:')) {\n const filePath = normalizePath(\n resolve(dirname(importer as string), id.split(';')[1]),\n );\n if (id.includes(':style')) {\n markStylePathSafe(options.resolvedConfig, filePath);\n return filePath + '?inline';\n }\n return toVirtualRawId(filePath);\n }\n\n // Intercept .html?raw imports to bypass Vite server.fs restrictions\n const rawRewrite = rewriteHtmlRawImport(id, importer);\n if (rawRewrite) {\n return rawRewrite;\n }\n\n // User `.scss?inline` / `.css?inline` imports: resolve and mark\n // safe so Vite's native CSS pipeline handles them.\n if (/\\.(css|scss|sass|less)\\?inline$/.test(id) && importer) {\n const filePath = id.split('?')[0];\n const resolved = normalizePath(\n resolveViteUrl(filePath, options.resolvedConfig?.root) ??\n (isAbsolute(filePath)\n ? filePath\n : resolve(dirname(importer), filePath)),\n );\n markStylePathSafe(options.resolvedConfig, resolved);\n return resolved + '?inline';\n }\n\n return undefined;\n}\n\nexport async function loadAngularVirtualModule(\n pluginCtx: { addWatchFile(path: string): void },\n id: string,\n resolvedConfig?: ResolvedConfig,\n): Promise<string | undefined> {\n const rawModule = await loadVirtualRawModule(pluginCtx, id);\n if (rawModule !== undefined) {\n return rawModule;\n }\n\n // Vitest fallback: the module-runner can skip resolveId, so the bare\n // ?inline query reaches load. Mark safe and let Vite handle it.\n if (/\\.(css|scss|sass|less)\\?inline$/.test(id)) {\n markStylePathSafe(resolvedConfig, id.split('?')[0]);\n }\n\n return undefined;\n}\n\nexport function virtualModulesPlugin(\n ctxOrOptions?: AngularBuildContext | VirtualModulesPluginOptions,\n): Plugin {\n const sharedCtx = isAngularBuildContext(ctxOrOptions)\n ? ctxOrOptions\n : undefined;\n const standaloneJit = isAngularBuildContext(ctxOrOptions)\n ? ctxOrOptions.options.jit\n : (ctxOrOptions?.jit ?? false);\n let localConfig: ResolvedConfig | undefined;\n\n return {\n name: '@analogjs/vite-plugin-angular:virtual-modules',\n enforce: 'pre',\n configResolved(config) {\n localConfig = config;\n sharedCtx?.setResolvedConfig(config);\n },\n resolveId(id, importer) {\n return resolveAngularVirtualId(id, importer, {\n jit: sharedCtx ? sharedCtx.options.jit : standaloneJit,\n resolvedConfig: sharedCtx?.resolvedConfig ?? localConfig,\n });\n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