@analogjs/vite-plugin-angular 3.0.0-beta.1 → 3.0.0-beta.11
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/README.md +40 -0
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.js +13 -2
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.js.map +1 -1
- package/package.json +1 -14
- package/src/lib/angular-vite-plugin.js +14 -1
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/compiler/compile.js +5 -2
- package/src/lib/compiler/compile.js.map +1 -1
- package/src/lib/compiler/dts-reader.d.ts +5 -0
- package/src/lib/compiler/dts-reader.js +9 -3
- package/src/lib/compiler/dts-reader.js.map +1 -1
- package/src/lib/compiler/hmr.d.ts +4 -0
- package/src/lib/compiler/hmr.js +7 -2
- package/src/lib/compiler/hmr.js.map +1 -1
- package/src/lib/compiler/index.d.ts +2 -2
- package/src/lib/compiler/index.js +3 -3
- package/src/lib/compiler/jit-metadata.d.ts +3 -1
- package/src/lib/compiler/jit-metadata.js +10 -8
- package/src/lib/compiler/jit-metadata.js.map +1 -1
- package/src/lib/compiler/registry.d.ts +6 -0
- package/src/lib/compiler/registry.js +21 -1
- package/src/lib/compiler/registry.js.map +1 -1
- package/src/lib/fast-compile-plugin.js +97 -15
- package/src/lib/fast-compile-plugin.js.map +1 -1
- package/src/lib/tools/src/builders/vite/vite-build.impl.js +2 -1
- package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -1
- package/migrations/migrations.json +0 -9
- package/migrations/update-3-0-0/migrate-setup-vitest.d.ts +0 -2
- package/migrations/update-3-0-0/migrate-setup-vitest.js +0 -37
- package/migrations/update-3-0-0/migrate-setup-vitest.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dts-reader.js","names":[],"sources":["../../../../src/lib/compiler/dts-reader.ts"],"sourcesContent":["import { parseSync } from 'oxc-parser';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { RegistryEntry, RegistryInput } from './registry.js';\n\n/**\n * Scan a single .d.ts file and extract Angular directive/component/pipe\n * metadata from the static ɵdir / ɵcmp / ɵpipe type declarations.\n *\n * This mirrors what ngtsc's DtsMetadataReader does: it reads the type\n * parameters of ɵɵDirectiveDeclaration / ɵɵComponentDeclaration /\n * ɵɵPipeDeclaration to discover selectors, inputs, and outputs for\n * pre-compiled Angular packages.\n */\nexport function scanDtsFile(code: string, fileName: string): RegistryEntry[] {\n // Fast pre-filter — skip files that can't contain Angular declarations\n if (\n !code.includes('DirectiveDeclaration') &&\n !code.includes('ComponentDeclaration') &&\n !code.includes('PipeDeclaration') &&\n !code.includes('NgModuleDeclaration')\n )\n return [];\n\n const { program } = parseSync(fileName, code);\n const entries: RegistryEntry[] = [];\n\n visitStatements(program.body, fileName, entries);\n return entries;\n}\n\n/**\n * Resolve a package's directory in node_modules, scan all its .d.ts files,\n * and return RegistryEntry[] for every Angular declaration found.\n *\n * @param packageName e.g. \"@angular/router\"\n * @param basePath project root (where node_modules lives)\n */\nexport function scanPackageDts(\n packageName: string,\n basePath: string,\n visited?: Set<string>,\n): RegistryEntry[] {\n // Walk up from basePath to find the nearest node_modules containing the package.\n // This handles monorepos where node_modules is at the workspace root,\n // not in the project subdirectory.\n let pkgDir = '';\n let searchBase = basePath;\n while (searchBase !== path.dirname(searchBase)) {\n const candidate = path.join(searchBase, 'node_modules', packageName);\n if (fs.existsSync(candidate)) {\n pkgDir = candidate;\n break;\n }\n searchBase = path.dirname(searchBase);\n }\n if (!pkgDir) return [];\n\n // Build a map from className → correct import path using package.json exports.\n // This handles packages with sub-entry points (e.g. @angular/material/tabs)\n // where re-exported classes must be imported from their origin entry point.\n const classToImportPath = buildClassToImportMap(packageName, pkgDir);\n\n // Check for a \"types\" directory first (Angular packages use this),\n // then fall back to the package root.\n const typesDir = path.join(pkgDir, 'types');\n const searchDir = fs.existsSync(typesDir) ? typesDir : pkgDir;\n\n const dtsFiles = collectDtsFiles(searchDir);\n const entries: RegistryEntry[] = [];\n // Packages re-exported by this package's NgModule declarations. A library\n // NgModule can re-export another package's module (e.g. BrowserModule exports\n // CommonModule), so those packages must be scanned too or their directives\n // (NgIf, NgForOf, …) never reach the registry.\n const referencedPackages = new Set<string>();\n\n for (const file of dtsFiles) {\n try {\n const code = fs.readFileSync(file, 'utf-8');\n const fileEntries = scanDtsFile(code, file);\n for (const entry of fileEntries) {\n entry.sourcePackage =\n classToImportPath.get(entry.className) ||\n subEntryFromFilePath(packageName, pkgDir, file) ||\n packageName;\n }\n entries.push(...fileEntries);\n // Only follow cross-package imports of declaration files that actually\n // contain an NgModule — those are the ones whose exports can pull in\n // another package's directives/pipes. This keeps the walk bounded.\n if (visited && fileEntries.some((e) => e.kind === 'ngmodule')) {\n for (const p of collectImportedPackages(code, file)) {\n referencedPackages.add(p);\n }\n }\n } catch {\n // Skip unreadable files\n }\n }\n\n if (visited) {\n for (const p of referencedPackages) {\n if (p === packageName || visited.has(p)) continue;\n visited.add(p);\n try {\n entries.push(...scanPackageDts(p, basePath, visited));\n } catch {\n // Package may not have .d.ts or not be Angular\n }\n }\n }\n\n return entries;\n}\n\n/**\n * Read package.json exports to build a map from class name to the correct\n * sub-entry import path (e.g. \"MatTabNav\" → \"@angular/material/tabs\").\n *\n * For each sub-entry that has a \"types\" field, the corresponding .d.ts file\n * is read to collect declared class names and re-exported names.\n */\nfunction buildClassToImportMap(\n packageName: string,\n pkgDir: string,\n): Map<string, string> {\n const map = new Map<string, string>();\n try {\n const pkgJson = JSON.parse(\n fs.readFileSync(path.join(pkgDir, 'package.json'), 'utf-8'),\n );\n if (!pkgJson.exports) return map;\n\n for (const [key, value] of Object.entries(pkgJson.exports) as [\n string,\n any,\n ][]) {\n if (key !== '.' && !key.startsWith('./')) continue;\n // Resolve types from the export entry. Some packages declare\n // `types` only at the package root (top-level package.json `types`\n // field) rather than per-export, so fall back to that for `.`.\n let typesFile: string | undefined =\n typeof value === 'object' && value !== null && value.types;\n if (!typesFile && key === '.' && typeof pkgJson.types === 'string') {\n typesFile = pkgJson.types;\n }\n if (!typesFile) continue;\n\n // Root entry (`.`) maps classes to the bare package name; sub-entries\n // (`./tabs`) map to `${packageName}/tabs`. Mapping root-exported\n // classes prevents `subEntryFromFilePath` from deriving an invalid\n // subpath like `ngx-scrollbar/lib` for files that physically live in\n // a `lib/` subdirectory but are only re-exported from the root entry.\n const importPath =\n key === '.' ? packageName : packageName + '/' + key.slice(2);\n const fullTypesPath = path.resolve(pkgDir, typesFile);\n if (!fs.existsSync(fullTypesPath)) continue;\n\n collectExportedClassesFromDts(fullTypesPath, importPath, map);\n }\n } catch {\n // No package.json or no exports — fall back to packageName\n }\n return map;\n}\n\n/**\n * Read a `.d.ts` entry file and add every class it exports to `map`,\n * following `export * from './rel'` chains so re-exported classes from\n * physically nested files (e.g. `lib/foo.d.ts`) are still mapped to the\n * exporting entry's import path.\n *\n * Without this, packages whose root `index.d.ts` is just a barrel of\n * `export * from './lib/...'` would never get their classes mapped, and the\n * `subEntryFromFilePath` fallback would derive an invalid `${pkg}/lib`\n * import for files living under `lib/`.\n */\nfunction collectExportedClassesFromDts(\n filePath: string,\n importPath: string,\n map: Map<string, string>,\n visited: Set<string> = new Set(),\n): void {\n if (visited.has(filePath)) return;\n visited.add(filePath);\n let code: string;\n try {\n code = fs.readFileSync(filePath, 'utf-8');\n } catch {\n return;\n }\n\n let program: any;\n try {\n program = parseSync(filePath, code).program;\n } catch {\n return;\n }\n\n const dir = path.dirname(filePath);\n for (const stmt of program.body || []) {\n // `declare class Foo` (top-level)\n if (stmt.type === 'ClassDeclaration' && stmt.id?.name) {\n map.set(stmt.id.name, importPath);\n continue;\n }\n\n // `export declare class Foo` / `export class Foo` /\n // `export { A, B as C } from '...'` / `export { A, B }`\n if (stmt.type === 'ExportNamedDeclaration') {\n if (\n stmt.declaration?.type === 'ClassDeclaration' &&\n stmt.declaration.id?.name\n ) {\n map.set(stmt.declaration.id.name, importPath);\n }\n for (const spec of stmt.specifiers || []) {\n // ExportSpecifier: { local, exported }\n const exportedNode = spec.exported;\n const exportedName =\n exportedNode?.type === 'Identifier'\n ? exportedNode.name\n : exportedNode?.type === 'Literal'\n ? exportedNode.value\n : undefined;\n if (typeof exportedName === 'string') {\n map.set(exportedName, importPath);\n }\n }\n continue;\n }\n\n // `export * from './rel'` and `export * as Ns from './rel'`\n if (stmt.type === 'ExportAllDeclaration') {\n const rel: string | undefined = stmt.source?.value;\n if (!rel || !rel.startsWith('.')) continue;\n // TypeScript preserves the original specifier text in emitted\n // `.d.ts` files, so NodeNext-style packages keep their `.js`\n // (or `.mjs`) extensions in re-exports — but the actual\n // declaration is at `foo.d.ts` / `foo/index.d.ts`. Strip the\n // ESM extension before probing.\n const normalizedRel = rel.replace(/\\.(?:js|mjs)$/u, '');\n const candidates = [\n path.resolve(dir, normalizedRel + '.d.ts'),\n path.resolve(dir, normalizedRel, 'index.d.ts'),\n ];\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) {\n collectExportedClassesFromDts(candidate, importPath, map, visited);\n break;\n }\n }\n continue;\n }\n }\n}\n\n/**\n * Derive a sub-entry import path from a .d.ts file's location relative to the\n * package root. This handles older Angular packages that keep .d.ts files in\n * subdirectories (e.g. `@angular/material/tabs/index.d.ts`) instead of a\n * top-level `types/` folder.\n *\n * Returns `undefined` when no sub-entry can be determined (e.g. file is at the\n * package root, inside `types/`, or in a non-entry directory).\n */\nfunction subEntryFromFilePath(\n packageName: string,\n pkgDir: string,\n filePath: string,\n): string | undefined {\n const NON_ENTRY_DIRS = new Set([\n 'types',\n 'fesm2022',\n 'fesm2020',\n 'fesm2015',\n 'esm2022',\n 'esm2020',\n 'esm2015',\n 'bundles',\n 'schematics',\n 'node_modules',\n ]);\n const rel = path.relative(pkgDir, filePath);\n const segments = rel.split(path.sep);\n // File directly in pkgDir (no subdirectory) → no sub-entry\n if (segments.length < 2) return undefined;\n const firstDir = segments[0];\n // Skip internal/build directories and chunk files\n if (NON_ENTRY_DIRS.has(firstDir) || firstDir.startsWith('_'))\n return undefined;\n return packageName + '/' + firstDir;\n}\n\n/**\n * Parse a source file with OXC and return the set of bare-specifier package\n * names it imports (e.g. \"@angular/router\", \"rxjs\"). Relative imports are\n * skipped.\n */\nexport function collectImportedPackages(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): Set<string> {\n const packages = new Set<string>();\n program ??= parseSync(fileName, code).program;\n\n for (const stmt of program.body) {\n if (stmt.type !== 'ImportDeclaration') continue;\n const specifier: string = stmt.source?.value;\n if (!specifier || specifier.startsWith('.')) continue;\n\n const parts = specifier.split('/');\n packages.add(\n specifier.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0],\n );\n }\n\n return packages;\n}\n\n/**\n * Parse a source file with OXC and return the relative-path specifiers it\n * re-exports via `export * from './x'`, `export * as Ns from './x'`, or\n * `export { … } from './x'`. Bare-specifier re-exports are skipped.\n *\n * Used by the analog Vite plugin to walk library entry barrels at startup\n * (e.g. `helm/select/src/index.ts` → `./lib/hlm-select`) so the underlying\n * directive classes land in the registry before any consumer is compiled.\n */\nexport function collectRelativeReExports(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): string[] {\n if (!program) {\n try {\n program = parseSync(fileName, code).program;\n } catch {\n return [];\n }\n }\n const result: string[] = [];\n for (const stmt of program.body || []) {\n if (\n stmt.type !== 'ExportAllDeclaration' &&\n stmt.type !== 'ExportNamedDeclaration'\n ) {\n continue;\n }\n // ExportNamedDeclaration without `source` is `export { x }` (no\n // re-export), which we don't care about here.\n const specifier: string | undefined = stmt.source?.value;\n if (!specifier || !specifier.startsWith('.')) continue;\n result.push(specifier);\n }\n return result;\n}\n\n/**\n * Parse a source file with OXC and return every module specifier it imports or\n * re-exports from (relative AND bare), including `import`, `export * from`, and\n * `export { … } from`. Used to walk the transitive import graph at startup so\n * the registry contains components/directives/pipes/modules from files not\n * directly listed in tsconfig `files`/`include` (transitively-imported app\n * sources) or behind wildcard `paths` (workspace libraries).\n */\nexport function collectAllImports(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): string[] {\n if (!program) {\n try {\n program = parseSync(fileName, code).program;\n } catch {\n return [];\n }\n }\n const result: string[] = [];\n for (const stmt of program.body || []) {\n if (\n stmt.type === 'ImportDeclaration' ||\n stmt.type === 'ExportAllDeclaration' ||\n stmt.type === 'ExportNamedDeclaration'\n ) {\n const specifier: string | undefined = stmt.source?.value;\n if (specifier) result.push(specifier);\n }\n }\n return result;\n}\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\nfunction visitStatements(\n stmts: any[],\n fileName: string,\n entries: RegistryEntry[],\n) {\n for (const stmt of stmts) {\n // Unwrap exports: `export declare class ...` / `export default class ...`\n const decl =\n stmt.type === 'ExportNamedDeclaration' ||\n stmt.type === 'ExportDefaultDeclaration'\n ? stmt.declaration\n : stmt;\n\n if (!decl) continue;\n\n // Recurse into `declare module \"...\" { ... }` blocks\n if (decl.type === 'TSModuleDeclaration' && decl.body?.body) {\n visitStatements(decl.body.body, fileName, entries);\n continue;\n }\n\n if (decl.type !== 'ClassDeclaration' || !decl.id?.name) continue;\n const className: string = decl.id.name;\n const members: any[] = decl.body?.body || [];\n\n for (const member of members) {\n if (member.type !== 'PropertyDefinition' || !member.static) continue;\n const propName: string | undefined = member.key?.name;\n\n // Read the type annotation: e.g. `i0.ɵɵDirectiveDeclaration<...>`\n const typeRef = member.typeAnnotation?.typeAnnotation;\n if (!typeRef || typeRef.type !== 'TSTypeReference') continue;\n\n const typeName = qualifiedName(typeRef.typeName);\n const typeParams: any[] | undefined = typeRef.typeArguments?.params;\n\n if (\n (propName === 'ɵdir' || propName === 'ɵcmp') &&\n (typeName.includes('DirectiveDeclaration') ||\n typeName.includes('ComponentDeclaration')) &&\n typeParams &&\n typeParams.length >= 5\n ) {\n const selector = literalString(typeParams[1]);\n if (!selector) continue;\n\n const inputs = extractInputs(typeParams[3]);\n const outputs = extractOutputs(typeParams[4]);\n\n entries.push({\n selector: selector.split(',')[0].trim(),\n kind: propName === 'ɵcmp' ? 'component' : 'directive',\n fileName,\n className,\n ...(Object.keys(inputs).length > 0 ? { inputs } : {}),\n ...(Object.keys(outputs).length > 0 ? { outputs } : {}),\n });\n } else if (\n propName === 'ɵpipe' &&\n typeName.includes('PipeDeclaration') &&\n typeParams &&\n typeParams.length >= 2\n ) {\n const pipeName = literalString(typeParams[1]);\n if (!pipeName) continue;\n\n entries.push({\n selector: pipeName,\n kind: 'pipe',\n pipeName,\n fileName,\n className,\n });\n } else if (\n propName === 'ɵmod' &&\n typeName.includes('NgModuleDeclaration') &&\n typeParams &&\n typeParams.length >= 4\n ) {\n // ɵɵNgModuleDeclaration<Module, Declarations, Imports, Exports>\n // Extract exported class names from the 4th type param (index 3).\n const exportsParam = typeParams[3];\n const exportedNames: string[] = [];\n if (exportsParam?.type === 'TSTupleType' && exportsParam.elementTypes) {\n for (const el of exportsParam.elementTypes) {\n if (\n el.type === 'TSTypeQuery' &&\n el.exprName?.type === 'Identifier'\n ) {\n exportedNames.push(el.exprName.name);\n } else if (\n el.type === 'TSTypeQuery' &&\n el.exprName?.type === 'TSQualifiedName'\n ) {\n // e.g. typeof i2.BidiModule → extract \"BidiModule\"\n const right = el.exprName.right;\n if (right?.type === 'Identifier') {\n exportedNames.push(right.name);\n }\n }\n }\n }\n entries.push({\n selector: className,\n kind: 'ngmodule',\n exports: exportedNames,\n fileName,\n className,\n });\n }\n }\n }\n}\n\n/**\n * Extract inputs from the type-argument at position [3].\n *\n * Handles two formats:\n * v16+: { \"prop\": { \"alias\": \"binding\"; \"required\": false; \"isSignal\"?: true } }\n * pre-v16: { \"prop\": \"binding\" }\n */\nfunction extractInputs(node: any): Record<string, RegistryInput> {\n const inputs: Record<string, RegistryInput> = {};\n if (node?.type !== 'TSTypeLiteral') return inputs;\n\n for (const member of node.members) {\n if (member.type !== 'TSPropertySignature') continue;\n const propName = keyName(member.key);\n const innerType = member.typeAnnotation?.typeAnnotation;\n if (!propName || !innerType) continue;\n\n if (innerType.type === 'TSTypeLiteral') {\n // v16+ object format\n let alias = propName;\n let required = false;\n let isSignal = false;\n\n for (const inner of innerType.members) {\n if (inner.type !== 'TSPropertySignature') continue;\n const key = keyName(inner.key);\n const val = inner.typeAnnotation?.typeAnnotation;\n if (!key || !val) continue;\n\n if (key === 'alias') {\n alias = literalString(val) ?? propName;\n } else if (key === 'required') {\n required = literalBoolean(val) === true;\n } else if (key === 'isSignal') {\n isSignal = literalBoolean(val) === true;\n }\n }\n\n inputs[propName] = {\n classPropertyName: propName,\n bindingPropertyName: alias,\n isSignal,\n required,\n };\n } else {\n // pre-v16 string format\n const alias = literalString(innerType);\n if (alias) {\n inputs[propName] = {\n classPropertyName: propName,\n bindingPropertyName: alias,\n isSignal: false,\n required: false,\n };\n }\n }\n }\n\n return inputs;\n}\n\n/**\n * Extract outputs from the type-argument at position [4].\n * Format: { \"propName\": \"eventName\" }\n */\nfunction extractOutputs(node: any): Record<string, string> {\n const outputs: Record<string, string> = {};\n if (node?.type !== 'TSTypeLiteral') return outputs;\n\n for (const member of node.members) {\n if (member.type !== 'TSPropertySignature') continue;\n const propName = keyName(member.key);\n const val = member.typeAnnotation?.typeAnnotation;\n if (!propName || !val) continue;\n\n const value = literalString(val);\n if (value) outputs[propName] = value;\n }\n\n return outputs;\n}\n\n/** Get the string name from a property key (Identifier or Literal). */\nfunction keyName(key: any): string | undefined {\n if (!key) return undefined;\n if (key.type === 'Identifier') return key.name;\n if (key.type === 'Literal' && typeof key.value === 'string') return key.value;\n return undefined;\n}\n\n/** Build a dotted name from an Identifier or TSQualifiedName. */\nfunction qualifiedName(node: any): string {\n if (!node) return '';\n if (node.type === 'Identifier') return node.name;\n if (node.type === 'TSQualifiedName')\n return qualifiedName(node.left) + '.' + qualifiedName(node.right);\n return '';\n}\n\n/** Extract a string value from a TSLiteralType node. */\nfunction literalString(node: any): string | undefined {\n if (\n node?.type === 'TSLiteralType' &&\n node.literal?.type === 'Literal' &&\n typeof node.literal.value === 'string'\n ) {\n return node.literal.value;\n }\n return undefined;\n}\n\n/** Extract a boolean value from a TSLiteralType node. */\nfunction literalBoolean(node: any): boolean | undefined {\n if (\n node?.type === 'TSLiteralType' &&\n node.literal?.type === 'Literal' &&\n typeof node.literal.value === 'boolean'\n ) {\n return node.literal.value;\n }\n return undefined;\n}\n\n/** Recursively collect all .d.ts files under a directory. */\nfunction collectDtsFiles(dir: string): string[] {\n const results: string[] = [];\n let entries: fs.Dirent[];\n try {\n entries = fs.readdirSync(dir, { withFileTypes: true });\n } catch {\n return results;\n }\n\n for (const entry of entries) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory() && entry.name !== 'node_modules') {\n results.push(...collectDtsFiles(full));\n } else if (entry.isFile() && entry.name.endsWith('.d.ts')) {\n results.push(full);\n }\n }\n\n return results;\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,YAAY,MAAc,UAAmC;CAE3E,IACE,CAAC,KAAK,SAAS,sBAAsB,KACrC,CAAC,KAAK,SAAS,sBAAsB,KACrC,CAAC,KAAK,SAAS,iBAAiB,KAChC,CAAC,KAAK,SAAS,qBAAqB,GAEpC,OAAO,CAAC;CAEV,MAAM,EAAE,YAAY,UAAU,UAAU,IAAI;CAC5C,MAAM,UAA2B,CAAC;CAElC,gBAAgB,QAAQ,MAAM,UAAU,OAAO;CAC/C,OAAO;AACT;;;;;;;;AASA,SAAgB,eACd,aACA,UACA,SACiB;CAIjB,IAAI,SAAS;CACb,IAAI,aAAa;CACjB,OAAO,eAAe,OAAK,QAAQ,UAAU,GAAG;EAC9C,MAAM,YAAY,OAAK,KAAK,YAAY,gBAAgB,WAAW;EACnE,IAAI,GAAG,WAAW,SAAS,GAAG;GAC5B,SAAS;GACT;EACF;EACA,aAAa,OAAK,QAAQ,UAAU;CACtC;CACA,IAAI,CAAC,QAAQ,OAAO,CAAC;CAKrB,MAAM,oBAAoB,sBAAsB,aAAa,MAAM;CAInE,M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tD,QAAQ,KAAK,IAAI;CAErB;CAEA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"dts-reader.js","names":[],"sources":["../../../../src/lib/compiler/dts-reader.ts"],"sourcesContent":["import { parseSync } from 'oxc-parser';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { RegistryEntry, RegistryInput } from './registry.js';\n\n/**\n * Scan a single .d.ts file and extract Angular directive/component/pipe\n * metadata from the static ɵdir / ɵcmp / ɵpipe type declarations.\n *\n * This mirrors what ngtsc's DtsMetadataReader does: it reads the type\n * parameters of ɵɵDirectiveDeclaration / ɵɵComponentDeclaration /\n * ɵɵPipeDeclaration to discover selectors, inputs, and outputs for\n * pre-compiled Angular packages.\n */\nexport function scanDtsFile(code: string, fileName: string): RegistryEntry[] {\n // Fast pre-filter — skip files that can't contain Angular declarations\n if (\n !code.includes('DirectiveDeclaration') &&\n !code.includes('ComponentDeclaration') &&\n !code.includes('PipeDeclaration') &&\n !code.includes('NgModuleDeclaration')\n )\n return [];\n\n const { program } = parseSync(fileName, code);\n const entries: RegistryEntry[] = [];\n\n visitStatements(program.body, fileName, entries);\n return entries;\n}\n\n/**\n * Resolve a package's directory in node_modules, scan all its .d.ts files,\n * and return RegistryEntry[] for every Angular declaration found.\n *\n * @param packageName e.g. \"@angular/router\"\n * @param basePath project root (where node_modules lives)\n */\nexport function scanPackageDts(\n packageName: string,\n basePath: string,\n visited?: Set<string>,\n): RegistryEntry[] {\n // Walk up from basePath to find the nearest node_modules containing the package.\n // This handles monorepos where node_modules is at the workspace root,\n // not in the project subdirectory.\n let pkgDir = '';\n let searchBase = basePath;\n while (searchBase !== path.dirname(searchBase)) {\n const candidate = path.join(searchBase, 'node_modules', packageName);\n if (fs.existsSync(candidate)) {\n pkgDir = candidate;\n break;\n }\n searchBase = path.dirname(searchBase);\n }\n if (!pkgDir) return [];\n\n // Build a map from className → correct import path using package.json exports.\n // This handles packages with sub-entry points (e.g. @angular/material/tabs)\n // where re-exported classes must be imported from their origin entry point.\n const classToImportPath = buildClassToImportMap(packageName, pkgDir);\n\n // Check for a \"types\" directory first (Angular packages use this),\n // then fall back to the package root.\n const typesDir = path.join(pkgDir, 'types');\n const searchDir = fs.existsSync(typesDir) ? typesDir : pkgDir;\n\n const dtsFiles = collectDtsFiles(searchDir);\n const entries: RegistryEntry[] = [];\n // Packages re-exported by this package's NgModule declarations. A library\n // NgModule can re-export another package's module (e.g. BrowserModule exports\n // CommonModule), so those packages must be scanned too or their directives\n // (NgIf, NgForOf, …) never reach the registry.\n const referencedPackages = new Set<string>();\n\n for (const file of dtsFiles) {\n try {\n const code = fs.readFileSync(file, 'utf-8');\n const fileEntries = scanDtsFile(code, file);\n for (const entry of fileEntries) {\n entry.sourcePackage =\n classToImportPath.get(entry.className) ||\n subEntryFromFilePath(packageName, pkgDir, file) ||\n packageName;\n }\n entries.push(...fileEntries);\n // Only follow cross-package imports of declaration files that actually\n // contain an NgModule — those are the ones whose exports can pull in\n // another package's directives/pipes. This keeps the walk bounded.\n if (visited && fileEntries.some((e) => e.kind === 'ngmodule')) {\n for (const p of collectImportedPackages(code, file)) {\n referencedPackages.add(p);\n }\n }\n } catch {\n // Skip unreadable files\n }\n }\n\n if (visited) {\n for (const p of referencedPackages) {\n if (p === packageName || visited.has(p)) continue;\n visited.add(p);\n try {\n entries.push(...scanPackageDts(p, basePath, visited));\n } catch {\n // Package may not have .d.ts or not be Angular\n }\n }\n }\n\n return entries;\n}\n\n/**\n * Read package.json exports to build a map from class name to the correct\n * sub-entry import path (e.g. \"MatTabNav\" → \"@angular/material/tabs\").\n *\n * For each sub-entry that has a \"types\" field, the corresponding .d.ts file\n * is read to collect declared class names and re-exported names.\n */\nfunction buildClassToImportMap(\n packageName: string,\n pkgDir: string,\n): Map<string, string> {\n const map = new Map<string, string>();\n try {\n const pkgJson = JSON.parse(\n fs.readFileSync(path.join(pkgDir, 'package.json'), 'utf-8'),\n );\n if (!pkgJson.exports) return map;\n\n for (const [key, value] of Object.entries(pkgJson.exports) as [\n string,\n any,\n ][]) {\n if (key !== '.' && !key.startsWith('./')) continue;\n // Resolve types from the export entry. Some packages declare\n // `types` only at the package root (top-level package.json `types`\n // field) rather than per-export, so fall back to that for `.`.\n let typesFile: string | undefined =\n typeof value === 'object' && value !== null && value.types;\n if (!typesFile && key === '.' && typeof pkgJson.types === 'string') {\n typesFile = pkgJson.types;\n }\n if (!typesFile) continue;\n\n // Root entry (`.`) maps classes to the bare package name; sub-entries\n // (`./tabs`) map to `${packageName}/tabs`. Mapping root-exported\n // classes prevents `subEntryFromFilePath` from deriving an invalid\n // subpath like `ngx-scrollbar/lib` for files that physically live in\n // a `lib/` subdirectory but are only re-exported from the root entry.\n const importPath =\n key === '.' ? packageName : packageName + '/' + key.slice(2);\n const fullTypesPath = path.resolve(pkgDir, typesFile);\n if (!fs.existsSync(fullTypesPath)) continue;\n\n collectExportedClassesFromDts(fullTypesPath, importPath, map);\n }\n } catch {\n // No package.json or no exports — fall back to packageName\n }\n return map;\n}\n\n/**\n * Read a `.d.ts` entry file and add every class it exports to `map`,\n * following `export * from './rel'` chains so re-exported classes from\n * physically nested files (e.g. `lib/foo.d.ts`) are still mapped to the\n * exporting entry's import path.\n *\n * Without this, packages whose root `index.d.ts` is just a barrel of\n * `export * from './lib/...'` would never get their classes mapped, and the\n * `subEntryFromFilePath` fallback would derive an invalid `${pkg}/lib`\n * import for files living under `lib/`.\n */\nfunction collectExportedClassesFromDts(\n filePath: string,\n importPath: string,\n map: Map<string, string>,\n visited: Set<string> = new Set(),\n): void {\n if (visited.has(filePath)) return;\n visited.add(filePath);\n let code: string;\n try {\n code = fs.readFileSync(filePath, 'utf-8');\n } catch {\n return;\n }\n\n let program: any;\n try {\n program = parseSync(filePath, code).program;\n } catch {\n return;\n }\n\n const dir = path.dirname(filePath);\n for (const stmt of program.body || []) {\n // `declare class Foo` (top-level)\n if (stmt.type === 'ClassDeclaration' && stmt.id?.name) {\n map.set(stmt.id.name, importPath);\n continue;\n }\n\n // `export declare class Foo` / `export class Foo` /\n // `export { A, B as C } from '...'` / `export { A, B }`\n if (stmt.type === 'ExportNamedDeclaration') {\n if (\n stmt.declaration?.type === 'ClassDeclaration' &&\n stmt.declaration.id?.name\n ) {\n map.set(stmt.declaration.id.name, importPath);\n }\n for (const spec of stmt.specifiers || []) {\n // ExportSpecifier: { local, exported }\n const exportedNode = spec.exported;\n const exportedName =\n exportedNode?.type === 'Identifier'\n ? exportedNode.name\n : exportedNode?.type === 'Literal'\n ? exportedNode.value\n : undefined;\n if (typeof exportedName === 'string') {\n map.set(exportedName, importPath);\n }\n }\n continue;\n }\n\n // `export * from './rel'` and `export * as Ns from './rel'`\n if (stmt.type === 'ExportAllDeclaration') {\n const rel: string | undefined = stmt.source?.value;\n if (!rel || !rel.startsWith('.')) continue;\n // TypeScript preserves the original specifier text in emitted\n // `.d.ts` files, so NodeNext-style packages keep their `.js`\n // (or `.mjs`) extensions in re-exports — but the actual\n // declaration is at `foo.d.ts` / `foo/index.d.ts`. Strip the\n // ESM extension before probing.\n const normalizedRel = rel.replace(/\\.(?:js|mjs)$/u, '');\n const candidates = [\n path.resolve(dir, normalizedRel + '.d.ts'),\n path.resolve(dir, normalizedRel, 'index.d.ts'),\n ];\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) {\n collectExportedClassesFromDts(candidate, importPath, map, visited);\n break;\n }\n }\n continue;\n }\n }\n}\n\n/**\n * Derive a sub-entry import path from a .d.ts file's location relative to the\n * package root. This handles older Angular packages that keep .d.ts files in\n * subdirectories (e.g. `@angular/material/tabs/index.d.ts`) instead of a\n * top-level `types/` folder.\n *\n * Returns `undefined` when no sub-entry can be determined (e.g. file is at the\n * package root, inside `types/`, or in a non-entry directory).\n */\nfunction subEntryFromFilePath(\n packageName: string,\n pkgDir: string,\n filePath: string,\n): string | undefined {\n const NON_ENTRY_DIRS = new Set([\n 'types',\n 'fesm2022',\n 'fesm2020',\n 'fesm2015',\n 'esm2022',\n 'esm2020',\n 'esm2015',\n 'bundles',\n 'schematics',\n 'node_modules',\n ]);\n const rel = path.relative(pkgDir, filePath);\n const segments = rel.split(path.sep);\n // File directly in pkgDir (no subdirectory) → no sub-entry\n if (segments.length < 2) return undefined;\n const firstDir = segments[0];\n // Skip internal/build directories and chunk files\n if (NON_ENTRY_DIRS.has(firstDir) || firstDir.startsWith('_'))\n return undefined;\n return packageName + '/' + firstDir;\n}\n\n/**\n * Parse a source file with OXC and return the set of bare-specifier package\n * names it imports (e.g. \"@angular/router\", \"rxjs\"). Relative imports are\n * skipped.\n */\nexport function collectImportedPackages(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): Set<string> {\n const packages = new Set<string>();\n program ??= parseSync(fileName, code).program;\n\n for (const stmt of program.body) {\n if (stmt.type !== 'ImportDeclaration') continue;\n const specifier: string = stmt.source?.value;\n if (!specifier || specifier.startsWith('.')) continue;\n\n const parts = specifier.split('/');\n packages.add(\n specifier.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0],\n );\n }\n\n return packages;\n}\n\n/**\n * Parse a source file with OXC and return the relative-path specifiers it\n * re-exports via `export * from './x'`, `export * as Ns from './x'`, or\n * `export { … } from './x'`. Bare-specifier re-exports are skipped.\n *\n * Used by the analog Vite plugin to walk library entry barrels at startup\n * (e.g. `helm/select/src/index.ts` → `./lib/hlm-select`) so the underlying\n * directive classes land in the registry before any consumer is compiled.\n */\nexport function collectRelativeReExports(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): string[] {\n return collectReExports(code, fileName, program).filter((specifier) =>\n specifier.startsWith('.'),\n );\n}\n\n/**\n * Parse a source file with OXC and return every specifier it re-exports from\n * (relative AND bare) via `export * from` or `export { … } from`.\n */\nexport function collectReExports(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): string[] {\n if (!program) {\n try {\n program = parseSync(fileName, code).program;\n } catch {\n return [];\n }\n }\n const result: string[] = [];\n for (const stmt of program.body || []) {\n if (\n stmt.type !== 'ExportAllDeclaration' &&\n stmt.type !== 'ExportNamedDeclaration'\n ) {\n continue;\n }\n // ExportNamedDeclaration without `source` is `export { x }` (no\n // re-export), which we don't care about here.\n const specifier: string | undefined = stmt.source?.value;\n if (specifier) result.push(specifier);\n }\n return result;\n}\n\n/**\n * Parse a source file with OXC and return every module specifier it imports or\n * re-exports from (relative AND bare), including `import`, `export * from`, and\n * `export { … } from`. Used to walk the transitive import graph at startup so\n * the registry contains components/directives/pipes/modules from files not\n * directly listed in tsconfig `files`/`include` (transitively-imported app\n * sources) or behind wildcard `paths` (workspace libraries).\n */\nexport function collectAllImports(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): string[] {\n if (!program) {\n try {\n program = parseSync(fileName, code).program;\n } catch {\n return [];\n }\n }\n const result: string[] = [];\n for (const stmt of program.body || []) {\n if (\n stmt.type === 'ImportDeclaration' ||\n stmt.type === 'ExportAllDeclaration' ||\n stmt.type === 'ExportNamedDeclaration'\n ) {\n const specifier: string | undefined = stmt.source?.value;\n if (specifier) result.push(specifier);\n }\n }\n return result;\n}\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\nfunction visitStatements(\n stmts: any[],\n fileName: string,\n entries: RegistryEntry[],\n) {\n for (const stmt of stmts) {\n // Unwrap exports: `export declare class ...` / `export default class ...`\n const decl =\n stmt.type === 'ExportNamedDeclaration' ||\n stmt.type === 'ExportDefaultDeclaration'\n ? stmt.declaration\n : stmt;\n\n if (!decl) continue;\n\n // Recurse into `declare module \"...\" { ... }` blocks\n if (decl.type === 'TSModuleDeclaration' && decl.body?.body) {\n visitStatements(decl.body.body, fileName, entries);\n continue;\n }\n\n if (decl.type !== 'ClassDeclaration' || !decl.id?.name) continue;\n const className: string = decl.id.name;\n const members: any[] = decl.body?.body || [];\n\n for (const member of members) {\n if (member.type !== 'PropertyDefinition' || !member.static) continue;\n const propName: string | undefined = member.key?.name;\n\n // Read the type annotation: e.g. `i0.ɵɵDirectiveDeclaration<...>`\n const typeRef = member.typeAnnotation?.typeAnnotation;\n if (!typeRef || typeRef.type !== 'TSTypeReference') continue;\n\n const typeName = qualifiedName(typeRef.typeName);\n const typeParams: any[] | undefined = typeRef.typeArguments?.params;\n\n if (\n (propName === 'ɵdir' || propName === 'ɵcmp') &&\n (typeName.includes('DirectiveDeclaration') ||\n typeName.includes('ComponentDeclaration')) &&\n typeParams &&\n typeParams.length >= 5\n ) {\n const selector = literalString(typeParams[1]);\n if (!selector) continue;\n\n const inputs = extractInputs(typeParams[3]);\n const outputs = extractOutputs(typeParams[4]);\n\n entries.push({\n selector: selector.split(',')[0].trim(),\n kind: propName === 'ɵcmp' ? 'component' : 'directive',\n fileName,\n className,\n ...(Object.keys(inputs).length > 0 ? { inputs } : {}),\n ...(Object.keys(outputs).length > 0 ? { outputs } : {}),\n });\n } else if (\n propName === 'ɵpipe' &&\n typeName.includes('PipeDeclaration') &&\n typeParams &&\n typeParams.length >= 2\n ) {\n const pipeName = literalString(typeParams[1]);\n if (!pipeName) continue;\n\n entries.push({\n selector: pipeName,\n kind: 'pipe',\n pipeName,\n fileName,\n className,\n });\n } else if (\n propName === 'ɵmod' &&\n typeName.includes('NgModuleDeclaration') &&\n typeParams &&\n typeParams.length >= 4\n ) {\n // ɵɵNgModuleDeclaration<Module, Declarations, Imports, Exports>\n // Extract exported class names from the 4th type param (index 3).\n const exportsParam = typeParams[3];\n const exportedNames: string[] = [];\n if (exportsParam?.type === 'TSTupleType' && exportsParam.elementTypes) {\n for (const el of exportsParam.elementTypes) {\n if (\n el.type === 'TSTypeQuery' &&\n el.exprName?.type === 'Identifier'\n ) {\n exportedNames.push(el.exprName.name);\n } else if (\n el.type === 'TSTypeQuery' &&\n el.exprName?.type === 'TSQualifiedName'\n ) {\n // e.g. typeof i2.BidiModule → extract \"BidiModule\"\n const right = el.exprName.right;\n if (right?.type === 'Identifier') {\n exportedNames.push(right.name);\n }\n }\n }\n }\n entries.push({\n selector: className,\n kind: 'ngmodule',\n exports: exportedNames,\n fileName,\n className,\n });\n }\n }\n }\n}\n\n/**\n * Extract inputs from the type-argument at position [3].\n *\n * Handles two formats:\n * v16+: { \"prop\": { \"alias\": \"binding\"; \"required\": false; \"isSignal\"?: true } }\n * pre-v16: { \"prop\": \"binding\" }\n */\nfunction extractInputs(node: any): Record<string, RegistryInput> {\n const inputs: Record<string, RegistryInput> = {};\n if (node?.type !== 'TSTypeLiteral') return inputs;\n\n for (const member of node.members) {\n if (member.type !== 'TSPropertySignature') continue;\n const propName = keyName(member.key);\n const innerType = member.typeAnnotation?.typeAnnotation;\n if (!propName || !innerType) continue;\n\n if (innerType.type === 'TSTypeLiteral') {\n // v16+ object format\n let alias = propName;\n let required = false;\n let isSignal = false;\n\n for (const inner of innerType.members) {\n if (inner.type !== 'TSPropertySignature') continue;\n const key = keyName(inner.key);\n const val = inner.typeAnnotation?.typeAnnotation;\n if (!key || !val) continue;\n\n if (key === 'alias') {\n alias = literalString(val) ?? propName;\n } else if (key === 'required') {\n required = literalBoolean(val) === true;\n } else if (key === 'isSignal') {\n isSignal = literalBoolean(val) === true;\n }\n }\n\n inputs[propName] = {\n classPropertyName: propName,\n bindingPropertyName: alias,\n isSignal,\n required,\n };\n } else {\n // pre-v16 string format\n const alias = literalString(innerType);\n if (alias) {\n inputs[propName] = {\n classPropertyName: propName,\n bindingPropertyName: alias,\n isSignal: false,\n required: false,\n };\n }\n }\n }\n\n return inputs;\n}\n\n/**\n * Extract outputs from the type-argument at position [4].\n * Format: { \"propName\": \"eventName\" }\n */\nfunction extractOutputs(node: any): Record<string, string> {\n const outputs: Record<string, string> = {};\n if (node?.type !== 'TSTypeLiteral') return outputs;\n\n for (const member of node.members) {\n if (member.type !== 'TSPropertySignature') continue;\n const propName = keyName(member.key);\n const val = member.typeAnnotation?.typeAnnotation;\n if (!propName || !val) continue;\n\n const value = literalString(val);\n if (value) outputs[propName] = value;\n }\n\n return outputs;\n}\n\n/** Get the string name from a property key (Identifier or Literal). */\nfunction keyName(key: any): string | undefined {\n if (!key) return undefined;\n if (key.type === 'Identifier') return key.name;\n if (key.type === 'Literal' && typeof key.value === 'string') return key.value;\n return undefined;\n}\n\n/** Build a dotted name from an Identifier or TSQualifiedName. */\nfunction qualifiedName(node: any): string {\n if (!node) return '';\n if (node.type === 'Identifier') return node.name;\n if (node.type === 'TSQualifiedName')\n return qualifiedName(node.left) + '.' + qualifiedName(node.right);\n return '';\n}\n\n/** Extract a string value from a TSLiteralType node. */\nfunction literalString(node: any): string | undefined {\n if (\n node?.type === 'TSLiteralType' &&\n node.literal?.type === 'Literal' &&\n typeof node.literal.value === 'string'\n ) {\n return node.literal.value;\n }\n return undefined;\n}\n\n/** Extract a boolean value from a TSLiteralType node. */\nfunction literalBoolean(node: any): boolean | undefined {\n if (\n node?.type === 'TSLiteralType' &&\n node.literal?.type === 'Literal' &&\n typeof node.literal.value === 'boolean'\n ) {\n return node.literal.value;\n }\n return undefined;\n}\n\n/** Recursively collect all .d.ts files under a directory. */\nfunction collectDtsFiles(dir: string): string[] {\n const results: string[] = [];\n let entries: fs.Dirent[];\n try {\n entries = fs.readdirSync(dir, { withFileTypes: true });\n } catch {\n return results;\n }\n\n for (const entry of entries) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory() && entry.name !== 'node_modules') {\n results.push(...collectDtsFiles(full));\n } else if (entry.isFile() && entry.name.endsWith('.d.ts')) {\n results.push(full);\n }\n }\n\n return results;\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,YAAY,MAAc,UAAmC;CAE3E,IACE,CAAC,KAAK,SAAS,sBAAsB,KACrC,CAAC,KAAK,SAAS,sBAAsB,KACrC,CAAC,KAAK,SAAS,iBAAiB,KAChC,CAAC,KAAK,SAAS,qBAAqB,GAEpC,OAAO,CAAC;CAEV,MAAM,EAAE,YAAY,UAAU,UAAU,IAAI;CAC5C,MAAM,UAA2B,CAAC;CAElC,gBAAgB,QAAQ,MAAM,UAAU,OAAO;CAC/C,OAAO;AACT;;;;;;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QAAQ,UAAU,WAE9B,OAAO,KAAK,QAAQ;AAGxB;;AAGA,SAAS,gBAAgB,KAAuB;CAC9C,MAAM,UAAoB,CAAC;CAC3B,IAAI;CACJ,IAAI;EACF,UAAU,GAAG,YAAY,KAAK,EAAE,eAAe,KAAK,CAAC;CACvD,QAAQ;EACN,OAAO;CACT;CAEA,KAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,OAAO,OAAK,KAAK,KAAK,MAAM,IAAI;EACtC,IAAI,MAAM,YAAY,KAAK,MAAM,SAAS,gBACxC,QAAQ,KAAK,GAAG,gBAAgB,IAAI,CAAC;OAChC,IAAI,MAAM,OAAO,KAAK,MAAM,KAAK,SAAS,OAAO,GACtD,QAAQ,KAAK,IAAI;CAErB;CAEA,OAAO;AACT"}
|
|
@@ -12,5 +12,9 @@ import type { RegistryEntry } from "./registry.js";
|
|
|
12
12
|
*
|
|
13
13
|
* For directives and pipes, ɵɵreplaceMetadata does not support them, so
|
|
14
14
|
* we fall back to a full page reload via import.meta.hot.invalidate().
|
|
15
|
+
*
|
|
16
|
+
* Every update re-executes the module and defines new classes, but Angular
|
|
17
|
+
* keeps rendering the classes from the first load. Those are kept in
|
|
18
|
+
* `import.meta.hot.data` so each update patches them, not the previous copy.
|
|
15
19
|
*/
|
|
16
20
|
export declare function generateHmrCode(declarations: RegistryEntry[], localDepClassNames?: string[]): string;
|
package/src/lib/compiler/hmr.js
CHANGED
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
*
|
|
13
13
|
* For directives and pipes, ɵɵreplaceMetadata does not support them, so
|
|
14
14
|
* we fall back to a full page reload via import.meta.hot.invalidate().
|
|
15
|
+
*
|
|
16
|
+
* Every update re-executes the module and defines new classes, but Angular
|
|
17
|
+
* keeps rendering the classes from the first load. Those are kept in
|
|
18
|
+
* `import.meta.hot.data` so each update patches them, not the previous copy.
|
|
15
19
|
*/
|
|
16
20
|
function generateHmrCode(declarations, localDepClassNames = []) {
|
|
17
21
|
const components = declarations.filter((d) => d.kind === "component");
|
|
@@ -26,7 +30,7 @@ export function ɵhmr_${c.className}(type) {
|
|
|
26
30
|
const replaceBlocks = components.map((c) => `
|
|
27
31
|
try {
|
|
28
32
|
i0.ɵɵreplaceMetadata(
|
|
29
|
-
|
|
33
|
+
ɵhmrTypes.${c.className},
|
|
30
34
|
newModule.ɵhmr_${c.className},
|
|
31
35
|
{ i0 },
|
|
32
36
|
${localDepsArray},
|
|
@@ -39,7 +43,7 @@ export function ɵhmr_${c.className}(type) {
|
|
|
39
43
|
}`).join("\n");
|
|
40
44
|
const swapBlocks = nonComponents.map((c) => `
|
|
41
45
|
try {
|
|
42
|
-
newModule.ɵhmr_${c.className}(
|
|
46
|
+
newModule.ɵhmr_${c.className}(ɵhmrTypes.${c.className});
|
|
43
47
|
swapped = true;
|
|
44
48
|
} catch(e) {}`).join("\n");
|
|
45
49
|
let acceptBody = `
|
|
@@ -59,6 +63,7 @@ export function ɵhmr_${c.className}(type) {
|
|
|
59
63
|
}`;
|
|
60
64
|
return `\n${applyFns}
|
|
61
65
|
if (import.meta.hot) {
|
|
66
|
+
const ɵhmrTypes = (import.meta.hot.data.ɵhmrTypes ??= {});${declarations.map((c) => `\n ɵhmrTypes.${c.className} ??= ${c.className};`).join("")}
|
|
62
67
|
import.meta.hot.accept((newModule) => {${acceptBody}
|
|
63
68
|
});
|
|
64
69
|
}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmr.js","names":[],"sources":["../../../../src/lib/compiler/hmr.ts"],"sourcesContent":["import type { RegistryEntry } from './registry.js';\n\n/**\n * Generate HMR code using Angular's ɵɵreplaceMetadata for components,\n * and simple field-swap + invalidation for directives/pipes.\n *\n * The applyMetadata callback dynamically copies all ɵ-prefixed static\n * fields (ɵcmp, ɵfac, ɵdir, ɵpipe, etc.) from the newly compiled class\n * to the old class reference that Angular's runtime is tracking.\n *\n * For components, ɵɵreplaceMetadata then merges the old/new definitions\n * and recreates matching LViews in the component tree.\n *\n * For directives and pipes, ɵɵreplaceMetadata does not support them, so\n * we fall back to a full page reload via import.meta.hot.invalidate().\n */\nexport function generateHmrCode(\n declarations: RegistryEntry[],\n localDepClassNames: string[] = [],\n): string {\n const components = declarations.filter((d) => d.kind === 'component');\n const nonComponents = declarations.filter((d) => d.kind !== 'component');\n\n // Export applyMetadata functions so the accept callback can access them.\n // Dynamically copy all ɵ-prefixed static fields to handle ɵcmp, ɵfac,\n // ɵdir, ɵpipe, ɵmod, ɵinj, ɵprov, and any future Ivy fields.\n const applyFns = declarations\n .map(\n (c) => `\nexport function ɵhmr_${c.className}(type) {\n for (const key of Object.getOwnPropertyNames(${c.className})) {\n if (key.startsWith('ɵ')) type[key] = ${c.className}[key];\n }\n}`,\n )\n .join('\\n');\n\n // Components: use ɵɵreplaceMetadata for full LView recreation\n const localDepsArray =\n localDepClassNames.length > 0 ? `[${localDepClassNames.join(', ')}]` : '[]';\n\n const replaceBlocks = components\n .map(\n (c) => `\n try {\n i0.ɵɵreplaceMetadata(\n
|
|
1
|
+
{"version":3,"file":"hmr.js","names":[],"sources":["../../../../src/lib/compiler/hmr.ts"],"sourcesContent":["import type { RegistryEntry } from './registry.js';\n\n/**\n * Generate HMR code using Angular's ɵɵreplaceMetadata for components,\n * and simple field-swap + invalidation for directives/pipes.\n *\n * The applyMetadata callback dynamically copies all ɵ-prefixed static\n * fields (ɵcmp, ɵfac, ɵdir, ɵpipe, etc.) from the newly compiled class\n * to the old class reference that Angular's runtime is tracking.\n *\n * For components, ɵɵreplaceMetadata then merges the old/new definitions\n * and recreates matching LViews in the component tree.\n *\n * For directives and pipes, ɵɵreplaceMetadata does not support them, so\n * we fall back to a full page reload via import.meta.hot.invalidate().\n *\n * Every update re-executes the module and defines new classes, but Angular\n * keeps rendering the classes from the first load. Those are kept in\n * `import.meta.hot.data` so each update patches them, not the previous copy.\n */\nexport function generateHmrCode(\n declarations: RegistryEntry[],\n localDepClassNames: string[] = [],\n): string {\n const components = declarations.filter((d) => d.kind === 'component');\n const nonComponents = declarations.filter((d) => d.kind !== 'component');\n\n // Export applyMetadata functions so the accept callback can access them.\n // Dynamically copy all ɵ-prefixed static fields to handle ɵcmp, ɵfac,\n // ɵdir, ɵpipe, ɵmod, ɵinj, ɵprov, and any future Ivy fields.\n const applyFns = declarations\n .map(\n (c) => `\nexport function ɵhmr_${c.className}(type) {\n for (const key of Object.getOwnPropertyNames(${c.className})) {\n if (key.startsWith('ɵ')) type[key] = ${c.className}[key];\n }\n}`,\n )\n .join('\\n');\n\n // Components: use ɵɵreplaceMetadata for full LView recreation\n const localDepsArray =\n localDepClassNames.length > 0 ? `[${localDepClassNames.join(', ')}]` : '[]';\n\n const replaceBlocks = components\n .map(\n (c) => `\n try {\n i0.ɵɵreplaceMetadata(\n ɵhmrTypes.${c.className},\n newModule.ɵhmr_${c.className},\n { i0 },\n ${localDepsArray},\n import.meta,\n \"${c.className}\"\n );\n replaced = true;\n } catch(e) {\n // ɵɵreplaceMetadata failed — will fall back to page reload\n }`,\n )\n .join('\\n');\n\n // Directives/pipes: swap static fields and invalidate\n const swapBlocks = nonComponents\n .map(\n (c) => `\n try {\n newModule.ɵhmr_${c.className}(ɵhmrTypes.${c.className});\n swapped = true;\n } catch(e) {}`,\n )\n .join('\\n');\n\n let acceptBody = `\n if (!newModule) return;`;\n\n if (components.length > 0) {\n acceptBody += `\n let replaced = false;${replaceBlocks}\n if (!replaced) {\n import.meta.hot.invalidate('Component HMR failed, reloading');\n return;\n }`;\n }\n\n if (nonComponents.length > 0) {\n acceptBody += `\n let swapped = false;${swapBlocks}\n if (swapped) {\n // Directive/pipe definitions updated — full reload needed for Angular\n // to pick up the new behavior since ɵɵreplaceMetadata only supports components.\n import.meta.hot.invalidate('Directive/pipe changed, reloading');\n }`;\n }\n\n const keepTypes = declarations\n .map((c) => `\\n ɵhmrTypes.${c.className} ??= ${c.className};`)\n .join('');\n\n return `\\n${applyFns}\nif (import.meta.hot) {\n const ɵhmrTypes = (import.meta.hot.data.ɵhmrTypes ??= {});${keepTypes}\n import.meta.hot.accept((newModule) => {${acceptBody}\n });\n}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,gBACd,cACA,qBAA+B,CAAC,GACxB;CACR,MAAM,aAAa,aAAa,QAAQ,MAAM,EAAE,SAAS,WAAW;CACpE,MAAM,gBAAgB,aAAa,QAAQ,MAAM,EAAE,SAAS,WAAW;CAKvE,MAAM,WAAW,aACd,KACE,MAAM;uBACU,EAAE,UAAU;iDACc,EAAE,UAAU;2CAClB,EAAE,UAAU;;EAGnD,CAAC,CACA,KAAK,IAAI;CAGZ,MAAM,iBACJ,mBAAmB,SAAS,IAAI,IAAI,mBAAmB,KAAK,IAAI,EAAE,KAAK;CAEzE,MAAM,gBAAgB,WACnB,KACE,MAAM;;;sBAGS,EAAE,UAAU;2BACP,EAAE,UAAU;;YAE3B,eAAe;;aAEd,EAAE,UAAU;;;;;QAMrB,CAAC,CACA,KAAK,IAAI;CAGZ,MAAM,aAAa,cAChB,KACE,MAAM;;yBAEY,EAAE,UAAU,aAAa,EAAE,UAAU;;oBAG1D,CAAC,CACA,KAAK,IAAI;CAEZ,IAAI,aAAa;;CAGjB,IAAI,WAAW,SAAS,GACtB,cAAc;2BACS,cAAc;;;;;CAOvC,IAAI,cAAc,SAAS,GACzB,cAAc;0BACQ,WAAW;;;;;;CAYnC,OAAO,KAAK,SAAS;;8DAJH,aACf,KAAK,MAAM,iBAAiB,EAAE,UAAU,OAAO,EAAE,UAAU,EAAE,CAAC,CAC9D,KAAK,EAIoD,EAAU;2CAC7B,WAAW;;;AAGtD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { compile, type CompileResult, type CompileOptions } from "./compile.js";
|
|
2
2
|
export { ANGULAR_DECORATORS, ANGULAR_DECORATOR_CALL_RE } from "./constants.js";
|
|
3
|
-
export { scanFile, type RegistryEntry, type ComponentRegistry } from "./registry.js";
|
|
4
|
-
export { scanDtsFile, scanPackageDts, collectImportedPackages, collectRelativeReExports, collectAllImports } from "./dts-reader.js";
|
|
3
|
+
export { scanFile, declaresNonStandaloneComponent, type RegistryEntry, type ComponentRegistry } from "./registry.js";
|
|
4
|
+
export { scanDtsFile, scanPackageDts, collectImportedPackages, collectRelativeReExports, collectReExports, collectAllImports } from "./dts-reader.js";
|
|
5
5
|
export { jitTransform, type JitTransformResult } from "./jit-transform.js";
|
|
6
6
|
export { generateHmrCode } from "./hmr.js";
|
|
7
7
|
export { inlineResourceUrls, extractInlineStyles } from "./resource-inliner.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ANGULAR_DECORATOR_CALL_RE } from "./constants.js";
|
|
2
2
|
import { debugCompile, debugRegistry } from "./debug.js";
|
|
3
3
|
import { compile } from "./compile.js";
|
|
4
|
-
import { scanFile } from "./registry.js";
|
|
5
|
-
import { collectAllImports, collectImportedPackages, collectRelativeReExports, scanPackageDts } from "./dts-reader.js";
|
|
4
|
+
import { declaresNonStandaloneComponent, scanFile } from "./registry.js";
|
|
5
|
+
import { collectAllImports, collectImportedPackages, collectReExports, collectRelativeReExports, scanPackageDts } from "./dts-reader.js";
|
|
6
6
|
import { jitTransform } from "./jit-transform.js";
|
|
7
7
|
import { generateHmrCode } from "./hmr.js";
|
|
8
8
|
import { extractInlineStyles, inlineResourceUrls } from "./resource-inliner.js";
|
|
9
|
-
export { ANGULAR_DECORATOR_CALL_RE, collectAllImports, collectImportedPackages, collectRelativeReExports, compile, debugCompile, debugRegistry, extractInlineStyles, generateHmrCode, inlineResourceUrls, jitTransform, scanFile, scanPackageDts };
|
|
9
|
+
export { ANGULAR_DECORATOR_CALL_RE, collectAllImports, collectImportedPackages, collectReExports, collectRelativeReExports, compile, debugCompile, debugRegistry, declaresNonStandaloneComponent, extractInlineStyles, generateHmrCode, inlineResourceUrls, jitTransform, scanFile, scanPackageDts };
|
|
@@ -12,5 +12,7 @@ export declare function buildCtorParameters(classNode: any, sourceCode: string,
|
|
|
12
12
|
* Returns a JS object literal string or null if no props.
|
|
13
13
|
*
|
|
14
14
|
* Accepts an OXC ClassDeclaration node and the original source string.
|
|
15
|
+
* `coreNamespace` (e.g. `i0.`) qualifies the decorators synthesized for
|
|
16
|
+
* signal APIs, whose names the source may not import.
|
|
15
17
|
*/
|
|
16
|
-
export declare function buildPropDecorators(classNode: any, sourceCode: string): string | null;
|
|
18
|
+
export declare function buildPropDecorators(classNode: any, sourceCode: string, coreNamespace?: string): string | null;
|
|
@@ -98,8 +98,10 @@ function buildCtorParameters(classNode, sourceCode, typeOnlyImports) {
|
|
|
98
98
|
* Returns a JS object literal string or null if no props.
|
|
99
99
|
*
|
|
100
100
|
* Accepts an OXC ClassDeclaration node and the original source string.
|
|
101
|
+
* `coreNamespace` (e.g. `i0.`) qualifies the decorators synthesized for
|
|
102
|
+
* signal APIs, whose names the source may not import.
|
|
101
103
|
*/
|
|
102
|
-
function buildPropDecorators(classNode, sourceCode) {
|
|
104
|
+
function buildPropDecorators(classNode, sourceCode, coreNamespace = "") {
|
|
103
105
|
const props = {};
|
|
104
106
|
const members = classNode.body?.body || [];
|
|
105
107
|
for (const member of members) {
|
|
@@ -142,24 +144,24 @@ function buildPropDecorators(classNode, sourceCode) {
|
|
|
142
144
|
optParts.push(sourceCode.slice(p.start, p.end));
|
|
143
145
|
}
|
|
144
146
|
optParts.push(`isSignal: true`, `required: ${required}`);
|
|
145
|
-
props[memberName].push(`{type: Input, args: [{${optParts.join(", ")}}]}`);
|
|
147
|
+
props[memberName].push(`{type: ${coreNamespace}Input, args: [{${optParts.join(", ")}}]}`);
|
|
146
148
|
} else if (api === "model") {
|
|
147
149
|
if (!props[memberName]) props[memberName] = [];
|
|
148
150
|
const bindingName = extractAlias(required ? args[0] : args[1]) ?? memberName;
|
|
149
|
-
props[memberName].push(`{type: Input, args: [{isSignal: true, alias: '${escapeStringLiteral(bindingName)}', required: ${required}}]}`);
|
|
150
|
-
props[memberName].push(`{type: Output, args: ['${escapeStringLiteral(bindingName + "Change")}']}`);
|
|
151
|
+
props[memberName].push(`{type: ${coreNamespace}Input, args: [{isSignal: true, alias: '${escapeStringLiteral(bindingName)}', required: ${required}}]}`);
|
|
152
|
+
props[memberName].push(`{type: ${coreNamespace}Output, args: ['${escapeStringLiteral(bindingName + "Change")}']}`);
|
|
151
153
|
} else if (api === "output" || api === "outputFromObservable") {
|
|
152
154
|
if (!props[memberName]) props[memberName] = [];
|
|
153
155
|
const alias = extractAlias(api === "outputFromObservable" ? args[1] : args[0]);
|
|
154
|
-
if (alias !== null) props[memberName].push(`{type: Output, args: ['${escapeStringLiteral(alias)}']}`);
|
|
155
|
-
else props[memberName].push(`{type: Output}`);
|
|
156
|
+
if (alias !== null) props[memberName].push(`{type: ${coreNamespace}Output, args: ['${escapeStringLiteral(alias)}']}`);
|
|
157
|
+
else props[memberName].push(`{type: ${coreNamespace}Output}`);
|
|
156
158
|
} else if (api === "viewChild" || api === "viewChildren" || api === "contentChild" || api === "contentChildren") {
|
|
157
159
|
if (!props[memberName]) props[memberName] = [];
|
|
158
160
|
const queryType = api === "viewChildren" ? "ViewChildren" : api === "viewChild" ? "ViewChild" : api === "contentChildren" ? "ContentChildren" : "ContentChild";
|
|
159
161
|
if (args.length > 0) {
|
|
160
162
|
const opts = args.length > 1 ? `{...${sourceCode.slice(args[1].start, args[1].end)}, isSignal: true}` : `{isSignal: true}`;
|
|
161
|
-
props[memberName].push(`{type: ${queryType}, args: [${sourceCode.slice(args[0].start, args[0].end)}, ${opts}]}`);
|
|
162
|
-
} else props[memberName].push(`{type: ${queryType}, args: [undefined, {isSignal: true}]}`);
|
|
163
|
+
props[memberName].push(`{type: ${coreNamespace}${queryType}, args: [${sourceCode.slice(args[0].start, args[0].end)}, ${opts}]}`);
|
|
164
|
+
} else props[memberName].push(`{type: ${coreNamespace}${queryType}, args: [undefined, {isSignal: true}]}`);
|
|
163
165
|
}
|
|
164
166
|
}
|
|
165
167
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jit-metadata.js","names":[],"sources":["../../../../src/lib/compiler/jit-metadata.ts"],"sourcesContent":["/**\n * JIT metadata helpers — OXC AST edition.\n *\n * Builds static metadata arrays that Angular's ReflectionCapabilities reads\n * at runtime for JIT compilation (ctorParameters, propDecorators).\n *\n * Uses source-position slicing instead of AST getText() for speed.\n */\nimport { FIELD_DECORATORS } from './constants.js';\n\nfunction getCallApi(call: any): { api: string; required: boolean } | null {\n const callee = call.callee;\n if (!callee) return null;\n\n if (callee.type === 'Identifier') {\n return { api: callee.name, required: false };\n }\n\n if (\n (callee.type === 'StaticMemberExpression' ||\n callee.type === 'MemberExpression') &&\n callee.object?.type === 'Identifier' &&\n callee.property?.name === 'required'\n ) {\n return { api: callee.object.name, required: true };\n }\n\n return null;\n}\n\n/**\n * Read a string-literal `alias` value out of an OXC ObjectExpression.\n * Returns null when the arg isn't an object literal, has no alias, or\n * the alias value isn't a static string. Shorthand `{alias}` is skipped\n * because the identifier wouldn't be in scope when the propDecorators\n * static block is evaluated at class top level.\n */\nfunction extractAlias(optArg: any): string | null {\n if (!optArg || optArg.type !== 'ObjectExpression') return null;\n for (const p of optArg.properties || []) {\n if (p.type !== 'ObjectProperty' && p.type !== 'Property') continue;\n if (p.shorthand) continue;\n const pKey = p.key?.name || p.key?.value;\n if (pKey !== 'alias') continue;\n const v = p.value;\n if (v?.type === 'StringLiteral') return v.value;\n if (v?.type === 'Literal' && typeof v.value === 'string') return v.value;\n }\n return null;\n}\n\nfunction escapeStringLiteral(s: string): string {\n return s.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\");\n}\n\n/** The constructor implementation, skipping overload signatures. */\nexport function findConstructor(classNode: any): any {\n return (classNode.body?.body || []).find(\n (m: any) =>\n m.type === 'MethodDefinition' &&\n m.kind === 'constructor' &&\n m.value?.body,\n );\n}\n\n/**\n * Build ctorParameters for constructor DI in JIT format:\n * [{ type: ServiceA }, { type: ServiceB, decorators: [{type: Optional}] }]\n *\n * Accepts an OXC ClassDeclaration node and the original source string.\n */\nexport function buildCtorParameters(\n classNode: any,\n sourceCode: string,\n typeOnlyImports: Set<string>,\n): string | null {\n const ctor = findConstructor(classNode);\n if (!ctor) return null;\n\n const params: any[] = ctor.value?.params?.items || ctor.value?.params || [];\n if (params.length === 0) return null;\n\n const result: string[] = [];\n for (const param of params) {\n const parts: string[] = [];\n\n // Handle TSParameterProperty (e.g., constructor(private foo: Bar))\n const actualParam =\n param.type === 'TSParameterProperty' ? param.parameter : param;\n const typeAnn =\n actualParam?.typeAnnotation?.typeAnnotation ??\n param?.typeAnnotation?.typeAnnotation;\n\n // Extract type name from annotation\n let typeName: string | null = null;\n if (typeAnn) {\n if (typeAnn.type === 'TSTypeReference' && typeAnn.typeName) {\n typeName =\n typeAnn.typeName.name ??\n sourceCode.slice(typeAnn.typeName.start, typeAnn.typeName.end);\n } else if (typeAnn.type === 'TSUnionType') {\n for (const t of typeAnn.types || []) {\n if (t.type === 'TSTypeReference' && t.typeName) {\n typeName =\n t.typeName.name ??\n sourceCode.slice(t.typeName.start, t.typeName.end);\n break;\n }\n }\n }\n }\n\n // Extract parameter decorators (may live on TSParameterProperty or the param itself)\n const paramDecs: any[] = param.decorators || actualParam?.decorators || [];\n // @Inject supplies the token, so its annotation may be an interface\n // with no runtime value; referencing it would throw.\n const hasInject = paramDecs.some(\n (dec: any) => dec.expression?.callee?.name === 'Inject',\n );\n\n if (typeName && !hasInject && !typeOnlyImports.has(typeName)) {\n parts.push(`type: ${typeName}`);\n } else {\n parts.push(`type: undefined`);\n }\n\n if (paramDecs.length > 0) {\n const decEntries = paramDecs\n .map((dec: any) => {\n const expr = dec.expression;\n if (!expr || expr.type !== 'CallExpression') return '';\n const name = expr.callee?.name;\n if (!name) return '';\n const args: any[] = expr.arguments || [];\n if (args.length > 0) {\n return `{type: ${name}, args: [${args.map((a: any) => sourceCode.slice(a.start, a.end)).join(', ')}]}`;\n }\n return `{type: ${name}}`;\n })\n .filter(Boolean);\n if (decEntries.length > 0) {\n parts.push(`decorators: [${decEntries.join(', ')}]`);\n }\n }\n\n result.push(`{${parts.join(', ')}}`);\n }\n\n return result.join(', ');\n}\n\n/**\n * Build propDecorators for field decorators + signal API downleveling.\n * Returns a JS object literal string or null if no props.\n *\n * Accepts an OXC ClassDeclaration node and the original source string.\n */\nexport function buildPropDecorators(\n classNode: any,\n sourceCode: string,\n): string | null {\n const props: Record<string, string[]> = {};\n const members: any[] = classNode.body?.body || [];\n\n for (const member of members) {\n const memberName: string | undefined = member.key?.name;\n if (!memberName) continue;\n\n // Check for field decorators (@Input, @Output, @ViewChild, etc.)\n const explicitDecoratorNames = new Set<string>();\n const decorators: any[] = member.decorators || [];\n for (const dec of decorators) {\n const expr = dec.expression;\n if (!expr || expr.type !== 'CallExpression') continue;\n const decName: string | undefined = expr.callee?.name;\n if (!decName || !FIELD_DECORATORS.has(decName)) continue;\n\n explicitDecoratorNames.add(decName);\n if (!props[memberName]) props[memberName] = [];\n const args: any[] = expr.arguments || [];\n if (args.length > 0) {\n props[memberName].push(\n `{type: ${decName}, args: [${args.map((a: any) => sourceCode.slice(a.start, a.end)).join(', ')}]}`,\n );\n } else {\n props[memberName].push(`{type: ${decName}}`);\n }\n }\n\n // Signal API downleveling. Skip when a matching explicit decorator\n // is already on the field — Angular's transform bails in that case\n // (input_function.ts, model_function.ts, output_function.ts,\n // query_functions.ts) to avoid duplicate metadata entries.\n if (\n member.type === 'PropertyDefinition' &&\n member.value?.type === 'CallExpression'\n ) {\n const signalCall = getCallApi(member.value);\n if (!signalCall) continue;\n\n const { api, required } = signalCall;\n const args: any[] = member.value.arguments || [];\n\n const hasInput = explicitDecoratorNames.has('Input');\n const hasOutput = explicitDecoratorNames.has('Output');\n const hasQuery =\n explicitDecoratorNames.has('ViewChild') ||\n explicitDecoratorNames.has('ViewChildren') ||\n explicitDecoratorNames.has('ContentChild') ||\n explicitDecoratorNames.has('ContentChildren');\n\n if (api === 'input' && hasInput) continue;\n if (api === 'model' && (hasInput || hasOutput)) continue;\n if ((api === 'output' || api === 'outputFromObservable') && hasOutput) {\n continue;\n }\n if (\n (api === 'viewChild' ||\n api === 'viewChildren' ||\n api === 'contentChild' ||\n api === 'contentChildren') &&\n hasQuery\n ) {\n continue;\n }\n\n if (api === 'input') {\n if (!props[memberName]) props[memberName] = [];\n // Preserve original options from the input() call and overlay\n // isSignal/required. `transform` is dropped: the input signal\n // already applies it internally, so forwarding it to the\n // decorator would make Angular's runtime JIT wrap it a second\n // time via the directive metadata's transformFunction slot.\n // Shorthand props ({alias}) are skipped — the identifier\n // wouldn't be in scope when the propDecorators block runs at\n // class top level.\n const optArg = required ? args[0] : args[1];\n const optParts: string[] = [];\n if (optArg?.type === 'ObjectExpression') {\n for (const p of optArg.properties || []) {\n if (p.type !== 'ObjectProperty' && p.type !== 'Property') continue;\n if (p.shorthand) continue;\n const pKey = p.key?.name || p.key?.value;\n if (\n pKey === 'isSignal' ||\n pKey === 'required' ||\n pKey === 'transform'\n ) {\n continue;\n }\n optParts.push(sourceCode.slice(p.start, p.end));\n }\n }\n optParts.push(`isSignal: true`, `required: ${required}`);\n props[memberName].push(\n `{type: Input, args: [{${optParts.join(', ')}}]}`,\n );\n } else if (api === 'model') {\n // Both Input and Output must live on the SAME propDecorators key\n // (the class field name). Angular's JIT facade indexes outputs by\n // classPropertyName and reads `instance[classPropertyName]` for\n // the EventEmitter — for a model that's the signal itself, which\n // exposes the emitter via [SIGNAL]. Splitting Output onto a\n // synthetic `<name>Change` key would point at a field that does\n // not exist on the class, breaking two-way bindings.\n if (!props[memberName]) props[memberName] = [];\n const optArg = required ? args[0] : args[1];\n const alias = extractAlias(optArg);\n const bindingName = alias ?? memberName;\n props[memberName].push(\n `{type: Input, args: [{isSignal: true, alias: '${escapeStringLiteral(bindingName)}', required: ${required}}]}`,\n );\n props[memberName].push(\n `{type: Output, args: ['${escapeStringLiteral(bindingName + 'Change')}']}`,\n );\n } else if (api === 'output' || api === 'outputFromObservable') {\n if (!props[memberName]) props[memberName] = [];\n // outputFromObservable(observable, options) — options is args[1].\n // output(options) — options is args[0].\n const optArg = api === 'outputFromObservable' ? args[1] : args[0];\n const alias = extractAlias(optArg);\n if (alias !== null) {\n props[memberName].push(\n `{type: Output, args: ['${escapeStringLiteral(alias)}']}`,\n );\n } else {\n props[memberName].push(`{type: Output}`);\n }\n } else if (\n api === 'viewChild' ||\n api === 'viewChildren' ||\n api === 'contentChild' ||\n api === 'contentChildren'\n ) {\n if (!props[memberName]) props[memberName] = [];\n const queryType =\n api === 'viewChildren'\n ? 'ViewChildren'\n : api === 'viewChild'\n ? 'ViewChild'\n : api === 'contentChildren'\n ? 'ContentChildren'\n : 'ContentChild';\n // Signal queries need `isSignal: true` so the runtime JIT compiler\n // wires them through the signal query infrastructure rather than\n // treating them as plain @ViewChild/@ContentChild assignments.\n // Mirrors Angular's own JIT transform in\n // compiler-cli/.../initializer_api_transforms/query_functions.ts.\n if (args.length > 0) {\n const opts =\n args.length > 1\n ? `{...${sourceCode.slice(args[1].start, args[1].end)}, isSignal: true}`\n : `{isSignal: true}`;\n props[memberName].push(\n `{type: ${queryType}, args: [${sourceCode.slice(args[0].start, args[0].end)}, ${opts}]}`,\n );\n } else {\n props[memberName].push(\n `{type: ${queryType}, args: [undefined, {isSignal: true}]}`,\n );\n }\n }\n }\n }\n\n const entries = Object.entries(props);\n if (entries.length === 0) return null;\n\n const propsStr = entries\n .map(([key, decs]) => `${key}: [${decs.join(', ')}]`)\n .join(', ');\n return `{${propsStr}}`;\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAS,WAAW,MAAsD;CACxE,MAAM,SAAS,KAAK;CACpB,IAAI,CAAC,QAAQ,OAAO;CAEpB,IAAI,OAAO,SAAS,cAClB,OAAO;EAAE,KAAK,OAAO;EAAM,UAAU;CAAM;CAG7C,KACG,OAAO,SAAS,4BACf,OAAO,SAAS,uBAClB,OAAO,QAAQ,SAAS,gBACxB,OAAO,UAAU,SAAS,YAE1B,OAAO;EAAE,KAAK,OAAO,OAAO;EAAM,UAAU;CAAK;CA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,MAAM,cAAc,CAAC;IAC7C,MAAM,YACJ,QAAQ,iBACJ,iBACA,QAAQ,cACN,cACA,QAAQ,oBACN,oBACA;IAMV,IAAI,KAAK,SAAS,GAAG;KACnB,MAAM,OACJ,KAAK,SAAS,IACV,OAAO,WAAW,MAAM,KAAK,EAAE,CAAC,OAAO,KAAK,EAAE,CAAC,GAAG,EAAE,qBACpD;KACN,MAAM,WAAW,CAAC,KAChB,UAAU,UAAU,WAAW,WAAW,MAAM,KAAK,EAAE,CAAC,OAAO,KAAK,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK,GACvF;IACF,OACE,MAAM,WAAW,CAAC,KAChB,UAAU,UAAU,uCACtB;GAEJ;EACF;CACF;CAEA,MAAM,UAAU,OAAO,QAAQ,KAAK;CACpC,IAAI,QAAQ,WAAW,GAAG,OAAO;CAKjC,OAAO,IAHU,QACd,KAAK,CAAC,KAAK,UAAU,GAAG,IAAI,KAAK,KAAK,KAAK,IAAI,EAAE,EAAE,CAAC,CACpD,KAAK,IACG,EAAS;AACtB"}
|
|
1
|
+
{"version":3,"file":"jit-metadata.js","names":[],"sources":["../../../../src/lib/compiler/jit-metadata.ts"],"sourcesContent":["/**\n * JIT metadata helpers — OXC AST edition.\n *\n * Builds static metadata arrays that Angular's ReflectionCapabilities reads\n * at runtime for JIT compilation (ctorParameters, propDecorators).\n *\n * Uses source-position slicing instead of AST getText() for speed.\n */\nimport { FIELD_DECORATORS } from './constants.js';\n\nfunction getCallApi(call: any): { api: string; required: boolean } | null {\n const callee = call.callee;\n if (!callee) return null;\n\n if (callee.type === 'Identifier') {\n return { api: callee.name, required: false };\n }\n\n if (\n (callee.type === 'StaticMemberExpression' ||\n callee.type === 'MemberExpression') &&\n callee.object?.type === 'Identifier' &&\n callee.property?.name === 'required'\n ) {\n return { api: callee.object.name, required: true };\n }\n\n return null;\n}\n\n/**\n * Read a string-literal `alias` value out of an OXC ObjectExpression.\n * Returns null when the arg isn't an object literal, has no alias, or\n * the alias value isn't a static string. Shorthand `{alias}` is skipped\n * because the identifier wouldn't be in scope when the propDecorators\n * static block is evaluated at class top level.\n */\nfunction extractAlias(optArg: any): string | null {\n if (!optArg || optArg.type !== 'ObjectExpression') return null;\n for (const p of optArg.properties || []) {\n if (p.type !== 'ObjectProperty' && p.type !== 'Property') continue;\n if (p.shorthand) continue;\n const pKey = p.key?.name || p.key?.value;\n if (pKey !== 'alias') continue;\n const v = p.value;\n if (v?.type === 'StringLiteral') return v.value;\n if (v?.type === 'Literal' && typeof v.value === 'string') return v.value;\n }\n return null;\n}\n\nfunction escapeStringLiteral(s: string): string {\n return s.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\");\n}\n\n/** The constructor implementation, skipping overload signatures. */\nexport function findConstructor(classNode: any): any {\n return (classNode.body?.body || []).find(\n (m: any) =>\n m.type === 'MethodDefinition' &&\n m.kind === 'constructor' &&\n m.value?.body,\n );\n}\n\n/**\n * Build ctorParameters for constructor DI in JIT format:\n * [{ type: ServiceA }, { type: ServiceB, decorators: [{type: Optional}] }]\n *\n * Accepts an OXC ClassDeclaration node and the original source string.\n */\nexport function buildCtorParameters(\n classNode: any,\n sourceCode: string,\n typeOnlyImports: Set<string>,\n): string | null {\n const ctor = findConstructor(classNode);\n if (!ctor) return null;\n\n const params: any[] = ctor.value?.params?.items || ctor.value?.params || [];\n if (params.length === 0) return null;\n\n const result: string[] = [];\n for (const param of params) {\n const parts: string[] = [];\n\n // Handle TSParameterProperty (e.g., constructor(private foo: Bar))\n const actualParam =\n param.type === 'TSParameterProperty' ? param.parameter : param;\n const typeAnn =\n actualParam?.typeAnnotation?.typeAnnotation ??\n param?.typeAnnotation?.typeAnnotation;\n\n // Extract type name from annotation\n let typeName: string | null = null;\n if (typeAnn) {\n if (typeAnn.type === 'TSTypeReference' && typeAnn.typeName) {\n typeName =\n typeAnn.typeName.name ??\n sourceCode.slice(typeAnn.typeName.start, typeAnn.typeName.end);\n } else if (typeAnn.type === 'TSUnionType') {\n for (const t of typeAnn.types || []) {\n if (t.type === 'TSTypeReference' && t.typeName) {\n typeName =\n t.typeName.name ??\n sourceCode.slice(t.typeName.start, t.typeName.end);\n break;\n }\n }\n }\n }\n\n // Extract parameter decorators (may live on TSParameterProperty or the param itself)\n const paramDecs: any[] = param.decorators || actualParam?.decorators || [];\n // @Inject supplies the token, so its annotation may be an interface\n // with no runtime value; referencing it would throw.\n const hasInject = paramDecs.some(\n (dec: any) => dec.expression?.callee?.name === 'Inject',\n );\n\n if (typeName && !hasInject && !typeOnlyImports.has(typeName)) {\n parts.push(`type: ${typeName}`);\n } else {\n parts.push(`type: undefined`);\n }\n\n if (paramDecs.length > 0) {\n const decEntries = paramDecs\n .map((dec: any) => {\n const expr = dec.expression;\n if (!expr || expr.type !== 'CallExpression') return '';\n const name = expr.callee?.name;\n if (!name) return '';\n const args: any[] = expr.arguments || [];\n if (args.length > 0) {\n return `{type: ${name}, args: [${args.map((a: any) => sourceCode.slice(a.start, a.end)).join(', ')}]}`;\n }\n return `{type: ${name}}`;\n })\n .filter(Boolean);\n if (decEntries.length > 0) {\n parts.push(`decorators: [${decEntries.join(', ')}]`);\n }\n }\n\n result.push(`{${parts.join(', ')}}`);\n }\n\n return result.join(', ');\n}\n\n/**\n * Build propDecorators for field decorators + signal API downleveling.\n * Returns a JS object literal string or null if no props.\n *\n * Accepts an OXC ClassDeclaration node and the original source string.\n * `coreNamespace` (e.g. `i0.`) qualifies the decorators synthesized for\n * signal APIs, whose names the source may not import.\n */\nexport function buildPropDecorators(\n classNode: any,\n sourceCode: string,\n coreNamespace = '',\n): string | null {\n const props: Record<string, string[]> = {};\n const members: any[] = classNode.body?.body || [];\n\n for (const member of members) {\n const memberName: string | undefined = member.key?.name;\n if (!memberName) continue;\n\n // Check for field decorators (@Input, @Output, @ViewChild, etc.)\n const explicitDecoratorNames = new Set<string>();\n const decorators: any[] = member.decorators || [];\n for (const dec of decorators) {\n const expr = dec.expression;\n if (!expr || expr.type !== 'CallExpression') continue;\n const decName: string | undefined = expr.callee?.name;\n if (!decName || !FIELD_DECORATORS.has(decName)) continue;\n\n explicitDecoratorNames.add(decName);\n if (!props[memberName]) props[memberName] = [];\n const args: any[] = expr.arguments || [];\n if (args.length > 0) {\n props[memberName].push(\n `{type: ${decName}, args: [${args.map((a: any) => sourceCode.slice(a.start, a.end)).join(', ')}]}`,\n );\n } else {\n props[memberName].push(`{type: ${decName}}`);\n }\n }\n\n // Signal API downleveling. Skip when a matching explicit decorator\n // is already on the field — Angular's transform bails in that case\n // (input_function.ts, model_function.ts, output_function.ts,\n // query_functions.ts) to avoid duplicate metadata entries.\n if (\n member.type === 'PropertyDefinition' &&\n member.value?.type === 'CallExpression'\n ) {\n const signalCall = getCallApi(member.value);\n if (!signalCall) continue;\n\n const { api, required } = signalCall;\n const args: any[] = member.value.arguments || [];\n\n const hasInput = explicitDecoratorNames.has('Input');\n const hasOutput = explicitDecoratorNames.has('Output');\n const hasQuery =\n explicitDecoratorNames.has('ViewChild') ||\n explicitDecoratorNames.has('ViewChildren') ||\n explicitDecoratorNames.has('ContentChild') ||\n explicitDecoratorNames.has('ContentChildren');\n\n if (api === 'input' && hasInput) continue;\n if (api === 'model' && (hasInput || hasOutput)) continue;\n if ((api === 'output' || api === 'outputFromObservable') && hasOutput) {\n continue;\n }\n if (\n (api === 'viewChild' ||\n api === 'viewChildren' ||\n api === 'contentChild' ||\n api === 'contentChildren') &&\n hasQuery\n ) {\n continue;\n }\n\n if (api === 'input') {\n if (!props[memberName]) props[memberName] = [];\n // Preserve original options from the input() call and overlay\n // isSignal/required. `transform` is dropped: the input signal\n // already applies it internally, so forwarding it to the\n // decorator would make Angular's runtime JIT wrap it a second\n // time via the directive metadata's transformFunction slot.\n // Shorthand props ({alias}) are skipped — the identifier\n // wouldn't be in scope when the propDecorators block runs at\n // class top level.\n const optArg = required ? args[0] : args[1];\n const optParts: string[] = [];\n if (optArg?.type === 'ObjectExpression') {\n for (const p of optArg.properties || []) {\n if (p.type !== 'ObjectProperty' && p.type !== 'Property') continue;\n if (p.shorthand) continue;\n const pKey = p.key?.name || p.key?.value;\n if (\n pKey === 'isSignal' ||\n pKey === 'required' ||\n pKey === 'transform'\n ) {\n continue;\n }\n optParts.push(sourceCode.slice(p.start, p.end));\n }\n }\n optParts.push(`isSignal: true`, `required: ${required}`);\n props[memberName].push(\n `{type: ${coreNamespace}Input, args: [{${optParts.join(', ')}}]}`,\n );\n } else if (api === 'model') {\n // Both Input and Output must live on the SAME propDecorators key\n // (the class field name). Angular's JIT facade indexes outputs by\n // classPropertyName and reads `instance[classPropertyName]` for\n // the EventEmitter — for a model that's the signal itself, which\n // exposes the emitter via [SIGNAL]. Splitting Output onto a\n // synthetic `<name>Change` key would point at a field that does\n // not exist on the class, breaking two-way bindings.\n if (!props[memberName]) props[memberName] = [];\n const optArg = required ? args[0] : args[1];\n const alias = extractAlias(optArg);\n const bindingName = alias ?? memberName;\n props[memberName].push(\n `{type: ${coreNamespace}Input, args: [{isSignal: true, alias: '${escapeStringLiteral(bindingName)}', required: ${required}}]}`,\n );\n props[memberName].push(\n `{type: ${coreNamespace}Output, args: ['${escapeStringLiteral(bindingName + 'Change')}']}`,\n );\n } else if (api === 'output' || api === 'outputFromObservable') {\n if (!props[memberName]) props[memberName] = [];\n // outputFromObservable(observable, options) — options is args[1].\n // output(options) — options is args[0].\n const optArg = api === 'outputFromObservable' ? args[1] : args[0];\n const alias = extractAlias(optArg);\n if (alias !== null) {\n props[memberName].push(\n `{type: ${coreNamespace}Output, args: ['${escapeStringLiteral(alias)}']}`,\n );\n } else {\n props[memberName].push(`{type: ${coreNamespace}Output}`);\n }\n } else if (\n api === 'viewChild' ||\n api === 'viewChildren' ||\n api === 'contentChild' ||\n api === 'contentChildren'\n ) {\n if (!props[memberName]) props[memberName] = [];\n const queryType =\n api === 'viewChildren'\n ? 'ViewChildren'\n : api === 'viewChild'\n ? 'ViewChild'\n : api === 'contentChildren'\n ? 'ContentChildren'\n : 'ContentChild';\n // Signal queries need `isSignal: true` so the runtime JIT compiler\n // wires them through the signal query infrastructure rather than\n // treating them as plain @ViewChild/@ContentChild assignments.\n // Mirrors Angular's own JIT transform in\n // compiler-cli/.../initializer_api_transforms/query_functions.ts.\n if (args.length > 0) {\n const opts =\n args.length > 1\n ? `{...${sourceCode.slice(args[1].start, args[1].end)}, isSignal: true}`\n : `{isSignal: true}`;\n props[memberName].push(\n `{type: ${coreNamespace}${queryType}, args: [${sourceCode.slice(args[0].start, args[0].end)}, ${opts}]}`,\n );\n } else {\n props[memberName].push(\n `{type: ${coreNamespace}${queryType}, args: [undefined, {isSignal: true}]}`,\n );\n }\n }\n }\n }\n\n const entries = Object.entries(props);\n if (entries.length === 0) return null;\n\n const propsStr = entries\n .map(([key, decs]) => `${key}: [${decs.join(', ')}]`)\n .join(', ');\n return `{${propsStr}}`;\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAS,WAAW,MAAsD;CACxE,MAAM,SAAS,KAAK;CACpB,IAAI,CAAC,QAAQ,OAAO;CAEpB,IAAI,OAAO,SAAS,cAClB,OAAO;EAAE,KAAK,OAAO;EAAM,UAAU;CAAM;CAG7C,KACG,OAAO,SAAS,4BACf,OAAO,SAAS,uBAClB,OAAO,QAAQ,SAAS,gBACxB,OAAO,UAAU,SAAS,YAE1B,OAAO;EAAE,KAAK,OAAO,OAAO;EAAM,UAAU;CAAK;CAGnD,OAAO;AACT;;;;;;;;AASA,SAAS,aAAa,QAA4B;CAChD,IAAI,CAAC,UAAU,OAAO,SAAS,oBAAoB,OAAO;CAC1D,KAAK,MAAM,KAAK,OAAO,cAAc,CAAC,GAAG;EACvC,IAAI,EAAE,SAAS,oBAAoB,EAAE,SAAS,YAAY;EAC1D,IAAI,EAAE,WAAW;EAEjB,KADa,EAAE,KAAK,QAAQ,EAAE,KAAK,WACtB,SAAS;EACtB,MAAM,IAAI,EAAE;EACZ,IAAI,GAAG,SAAS,iBAAiB,OAAO,EAAE;EAC1C,IAAI,GAAG,SAAS,aAAa,OAAO,EAAE,U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,CAAC,OAAO,KAAK,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK,GACvG;IACF,OACE,MAAM,WAAW,CAAC,KAChB,UAAU,gBAAgB,UAAU,uCACtC;GAEJ;EACF;CACF;CAEA,MAAM,UAAU,OAAO,QAAQ,KAAK;CACpC,IAAI,QAAQ,WAAW,GAAG,OAAO;CAKjC,OAAO,IAHU,QACd,KAAK,CAAC,KAAK,UAAU,GAAG,IAAI,KAAK,KAAK,KAAK,IAAI,EAAE,EAAE,CAAC,CACpD,KAAK,IACG,EAAS;AACtB"}
|
|
@@ -54,3 +54,9 @@ export type ComponentRegistry = Map<string, RegistryEntry>;
|
|
|
54
54
|
* without performing full compilation. Uses OXC's native Rust parser for speed.
|
|
55
55
|
*/
|
|
56
56
|
export declare function scanFile(code: string, fileName: string, program?: ReturnType<typeof parseSync>["program"]): RegistryEntry[];
|
|
57
|
+
/**
|
|
58
|
+
* Whether the file declares a `@Component({ standalone: false })`. Such a
|
|
59
|
+
* component's template scope comes from the NgModule that declares it, which
|
|
60
|
+
* can only be found by scanning the whole project.
|
|
61
|
+
*/
|
|
62
|
+
export declare function declaresNonStandaloneComponent(program: ReturnType<typeof parseSync>["program"]): boolean;
|
|
@@ -170,7 +170,27 @@ function scanFile(code, fileName, program) {
|
|
|
170
170
|
}
|
|
171
171
|
return entries;
|
|
172
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Whether the file declares a `@Component({ standalone: false })`. Such a
|
|
175
|
+
* component's template scope comes from the NgModule that declares it, which
|
|
176
|
+
* can only be found by scanning the whole project.
|
|
177
|
+
*/
|
|
178
|
+
function declaresNonStandaloneComponent(program) {
|
|
179
|
+
for (const node of program.body) {
|
|
180
|
+
const decl = node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration" ? node.declaration : node;
|
|
181
|
+
if (decl?.type !== "ClassDeclaration") continue;
|
|
182
|
+
for (const dec of decl.decorators || []) {
|
|
183
|
+
const expr = dec.expression;
|
|
184
|
+
if (expr?.type !== "CallExpression") continue;
|
|
185
|
+
if (expr.callee?.name !== "Component") continue;
|
|
186
|
+
const arg = expr.arguments?.[0];
|
|
187
|
+
if (arg?.type !== "ObjectExpression") continue;
|
|
188
|
+
for (const prop of arg.properties) if (prop.type === "Property" && (prop.key?.name || prop.key?.value) === "standalone" && prop.value?.type === "Literal" && prop.value.value === false) return true;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
173
193
|
//#endregion
|
|
174
|
-
export { scanFile };
|
|
194
|
+
export { declaresNonStandaloneComponent, scanFile };
|
|
175
195
|
|
|
176
196
|
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","names":[],"sources":["../../../../src/lib/compiler/registry.ts"],"sourcesContent":["import { parseSync } from 'oxc-parser';\nimport { COMPILABLE_DECORATORS } from './constants.js';\n\nexport interface RegistryInput {\n classPropertyName: string;\n bindingPropertyName: string;\n isSignal: boolean;\n required: boolean;\n /**\n * `true` when the input declares a `transform` function. The actual\n * transform expression isn't usable cross-file, but downstream tools\n * (template type checking, codegen widening) need to know whether\n * one exists so they can broaden the accepted binding type.\n */\n hasTransform?: boolean;\n}\n\nexport interface RegistryEntry {\n /** CSS selector for components/directives, pipe name for pipes, class name for NgModules */\n selector: string;\n /** What kind of Angular declaration this is */\n kind: 'component' | 'directive' | 'pipe' | 'ngmodule' | 'tuple';\n /** The pipe name (only for pipes) */\n pipeName?: string;\n /** Exported class names (only for NgModules) */\n exports?: string[];\n /** Declared class names (only for NgModules) — used to wire non-standalone\n * component scope from the declaring module. */\n declarations?: string[];\n /** Imported module/class names (only for NgModules) — expanded transitively\n * to compute the directive/pipe scope of declared components. */\n imports?: string[];\n /**\n * Member class names (only for `tuple` kind) — produced by top-level\n * `export const X = [A, B, C] as const` style barrels common in\n * helm/spartan-style libraries. The compiler expands these into the\n * underlying directives when they appear in another component's\n * `imports` array, mirroring how Angular's official compiler resolves\n * static `imports` references at compile time.\n */\n members?: string[];\n /** The source file this declaration was found in */\n fileName: string;\n /** The class name */\n className: string;\n /** Input bindings (from signal APIs and @Input decorators) */\n inputs?: Record<string, RegistryInput>;\n /** Output bindings (from signal APIs and @Output decorators) */\n outputs?: Record<string, string>;\n /** The package this declaration was scanned from (e.g. \"@angular/cdk\") */\n sourcePackage?: string;\n}\n\n/** Maps class name → registry entry */\nexport type ComponentRegistry = Map<string, RegistryEntry>;\n\nconst DECORATOR_RE = new RegExp(`@(${[...COMPILABLE_DECORATORS].join('|')})`);\n\n/**\n * Lightweight scan of a TypeScript file to extract Angular decorator metadata\n * without performing full compilation. Uses OXC's native Rust parser for speed.\n */\nexport function scanFile(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): RegistryEntry[] {\n const entries: RegistryEntry[] = [];\n\n // Fast regex pre-filter — skip files with neither Angular decorators\n // nor a top-level `const X = [...]` that might be a directive tuple\n // barrel re-export.\n if (!DECORATOR_RE.test(code) && !/\\bconst\\s+\\w+\\s*=\\s*\\[/.test(code)) {\n return entries;\n }\n\n program ??= parseSync(fileName, code).program;\n\n // First pass: collect tuple barrels — top-level `const X = [A, B, C]`\n // (with or without `export`/`as const`) where every element is a bare\n // class identifier. These are how spartan-style libraries expose a\n // group of directives behind a single import (e.g. `HlmSelectImports`).\n // Without registering them, the fast-compile path treats the bare\n // identifier as an unknown directive and Angular's runtime never\n // matches the underlying classes.\n for (const node of program.body) {\n const varDecl =\n node.type === 'ExportNamedDeclaration' &&\n (node as any).declaration?.type === 'VariableDeclaration'\n ? (node as any).declaration\n : node.type === 'VariableDeclaration'\n ? node\n : null;\n if (!varDecl || varDecl.kind !== 'const') continue;\n for (const declarator of varDecl.declarations || []) {\n if (declarator.id?.type !== 'Identifier') continue;\n // Unwrap `arr as const` → ArrayExpression\n let init = declarator.init;\n if (init?.type === 'TSAsExpression') init = init.expression;\n if (init?.type !== 'ArrayExpression') continue;\n const members: string[] = [];\n let allClassRefs = true;\n for (const el of init.elements || []) {\n if (el?.type !== 'Identifier') {\n allClassRefs = false;\n break;\n }\n members.push(el.name);\n }\n if (!allClassRefs || members.length === 0) continue;\n const tupleName: string = declarator.id.name;\n entries.push({\n selector: tupleName,\n kind: 'tuple',\n members,\n fileName,\n className: tupleName,\n });\n }\n }\n\n for (const node of program.body) {\n // Handle `class Foo {}`, `export class Foo {}`, and `export default class Foo {}`\n const decl =\n node.type === 'ExportNamedDeclaration' ||\n node.type === 'ExportDefaultDeclaration'\n ? (node as any).declaration\n : node;\n if (!decl || decl.type !== 'ClassDeclaration') continue;\n // Skip anonymous default exports (no name to register)\n if (!decl.id?.name) continue;\n\n const className: string = decl.id.name;\n const decorators: any[] = decl.decorators || [];\n\n for (const dec of decorators) {\n const expr = dec.expression;\n if (!expr || expr.type !== 'CallExpression') continue;\n\n const decoratorName: string = expr.callee?.name;\n if (!COMPILABLE_DECORATORS.has(decoratorName)) continue;\n\n const arg = expr.arguments?.[0];\n if (!arg || arg.type !== 'ObjectExpression') continue;\n\n let selector: string | undefined;\n let pipeName: string | undefined;\n let moduleExports: string[] | undefined;\n let moduleDeclarations: string[] | undefined;\n let moduleImports: string[] | undefined;\n\n // Class names from an NgModule metadata array: bare `Identifier`s and the\n // module out of `Module.forRoot(...)`/`forChild(...)` ModuleWithProviders.\n const classNamesFrom = (val: any): string[] =>\n (val?.elements ?? [])\n .map((e: any) => {\n if (e?.type === 'Identifier') return e.name;\n if (\n e?.type === 'CallExpression' &&\n // OXC emits `StaticMemberExpression`; the ESTree shape some\n // versions produce uses `MemberExpression`. Accept both (matches\n // the other member-expression checks in this file).\n (e.callee?.type === 'StaticMemberExpression' ||\n e.callee?.type === 'MemberExpression') &&\n e.callee.object?.type === 'Identifier'\n ) {\n return e.callee.object.name;\n }\n return undefined;\n })\n .filter((n: unknown): n is string => typeof n === 'string');\n\n for (const prop of arg.properties) {\n if (prop.type !== 'Property') continue;\n const key: string = prop.key?.name || prop.key?.value;\n const val = prop.value;\n\n if (\n key === 'selector' &&\n val?.type === 'Literal' &&\n typeof val.value === 'string'\n ) {\n selector = val.value;\n }\n if (\n key === 'name' &&\n val?.type === 'Literal' &&\n typeof val.value === 'string' &&\n decoratorName === 'Pipe'\n ) {\n pipeName = val.value;\n }\n if (val?.type === 'ArrayExpression' && decoratorName === 'NgModule') {\n if (key === 'exports') moduleExports = classNamesFrom(val);\n else if (key === 'declarations')\n moduleDeclarations = classNamesFrom(val);\n else if (key === 'imports') moduleImports = classNamesFrom(val);\n }\n }\n\n if (decoratorName === 'NgModule') {\n entries.push({\n selector: className,\n kind: 'ngmodule',\n exports: moduleExports || [],\n declarations: moduleDeclarations || [],\n imports: moduleImports || [],\n fileName,\n className,\n });\n } else if (decoratorName === 'Pipe' && pipeName) {\n entries.push({\n selector: pipeName,\n kind: 'pipe',\n pipeName,\n fileName,\n className,\n });\n } else if (selector) {\n // Extract inputs/outputs from class members\n const inputs: Record<string, RegistryInput> = {};\n const outputs: Record<string, string> = {};\n const members: any[] = decl.body?.body || [];\n\n for (const member of members) {\n if (member.type !== 'PropertyDefinition' || !member.key?.name)\n continue;\n const name: string = member.key.name;\n const init = member.value;\n\n // Signal APIs: input(), input.required(), model(), output()\n if (init?.type === 'CallExpression') {\n const callee = init.callee;\n let calleeName = '';\n if (callee?.type === 'Identifier') {\n calleeName = callee.name;\n } else if (\n callee?.type === 'StaticMemberExpression' ||\n callee?.type === 'MemberExpression'\n ) {\n calleeName =\n (callee.object?.name || '') +\n '.' +\n (callee.property?.name || '');\n }\n\n // Extract `alias` from an options object at the given\n // argument index. Used for input/model (options at index 1,\n // or 0 for the `.required` variants) and for output (options\n // at index 0). Without this, host-directive mappings that\n // reference the public name (e.g. `inputs: ['aria-label']`,\n // `outputs: ['publicEvent']`) fail to resolve.\n const aliasFromArg = (argIndex: number): string | null => {\n const optionsArg = init.arguments?.[argIndex];\n if (optionsArg?.type !== 'ObjectExpression') return null;\n for (const prop of optionsArg.properties || []) {\n if (prop.type !== 'ObjectProperty' && prop.type !== 'Property')\n continue;\n const k = prop.key?.name ?? prop.key?.value;\n if (k !== 'alias') continue;\n const v = prop.value;\n if (\n v?.type === 'StringLiteral' ||\n (v?.type === 'Literal' && typeof v.value === 'string')\n ) {\n return v.value;\n }\n }\n return null;\n };\n // Detect a `transform: ...` entry in the input options object\n // so cross-file consumers know the binding type is widened.\n const hasTransformAtArg = (argIndex: number): boolean => {\n const optionsArg = init.arguments?.[argIndex];\n if (optionsArg?.type !== 'ObjectExpression') return false;\n for (const prop of optionsArg.properties || []) {\n if (prop.type !== 'ObjectProperty' && prop.type !== 'Property')\n continue;\n const k = prop.key?.name ?? prop.key?.value;\n if (k === 'transform') return true;\n }\n return false;\n };\n const inputAliasIndex =\n calleeName === 'input.required' || calleeName === 'model.required'\n ? 0\n : 1;\n\n if (calleeName === 'input' || calleeName === 'input.required') {\n const alias = aliasFromArg(inputAliasIndex);\n const hasTransform = hasTransformAtArg(inputAliasIndex);\n inputs[name] = {\n classPropertyName: name,\n bindingPropertyName: alias ?? name,\n isSignal: true,\n required: calleeName === 'input.required',\n ...(hasTransform ? { hasTransform: true } : {}),\n };\n } else if (\n calleeName === 'model' ||\n calleeName === 'model.required'\n ) {\n const alias = aliasFromArg(inputAliasIndex);\n inputs[name] = {\n classPropertyName: name,\n bindingPropertyName: alias ?? name,\n isSignal: true,\n required: calleeName === 'model.required',\n };\n // outputs map is `{ classPropertyName: bindingName }` —\n // for a model, the class property is `name` and the\n // binding name is `${aliasOrName}Change`.\n outputs[name] = (alias ?? name) + 'Change';\n } else if (\n calleeName === 'output' ||\n calleeName === 'outputFromObservable'\n ) {\n // output() options at arg[0]; outputFromObservable(source,\n // opts?) options at arg[1].\n const alias = aliasFromArg(\n calleeName === 'outputFromObservable' ? 1 : 0,\n );\n outputs[name] = alias ?? name;\n }\n }\n\n // Decorator-based: @Input(), @Output()\n const memberDecorators: any[] = member.decorators || [];\n for (const mdec of memberDecorators) {\n const mexpr = mdec.expression;\n if (!mexpr) continue;\n const mdecName =\n mexpr.type === 'CallExpression'\n ? mexpr.callee?.name\n : mexpr.type === 'Identifier'\n ? mexpr.name\n : undefined;\n if (mdecName === 'Input') {\n const alias =\n mexpr.arguments?.[0]?.type === 'Literal'\n ? mexpr.arguments[0].value\n : name;\n inputs[name] = {\n classPropertyName: name,\n bindingPropertyName: alias || name,\n isSignal: false,\n required: false,\n };\n } else if (mdecName === 'Output') {\n const alias =\n mexpr.arguments?.[0]?.type === 'Literal'\n ? mexpr.arguments[0].value\n : name;\n outputs[name] = alias || name;\n }\n }\n }\n\n entries.push({\n selector: selector.split(',')[0].trim(),\n kind: decoratorName === 'Component' ? 'component' : 'directive',\n fileName,\n className,\n ...(Object.keys(inputs).length > 0 ? { inputs } : {}),\n ...(Object.keys(outputs).length > 0 ? { outputs } : {}),\n });\n }\n }\n }\n\n return entries;\n}\n"],"mappings":";;;AAwDA,IAAM,eAAe,IAAI,OAAO,KAAK,CAAC,GAAG,qBAAqB,CAAC,CAAC,KAAK,GAAG,EAAE,EAAE;;;;;AAM5E,SAAgB,SACd,MACA,UACA,SACiB;CACjB,MAAM,UAA2B,CAAC;CAKlC,IAAI,CAAC,aAAa,KAAK,IAAI,KAAK,CAAC,yBAAyB,KAAK,IAAI,GACjE,OAAO;CAGT,YAAY,UAAU,UAAU,IAAI,CAAC,CAAC;CAStC,KAAK,MAAM,QAAQ,QAAQ,MAAM;EAC/B,MAAM,UACJ,KAAK,SAAS,4BACb,KAAa,aAAa,SAAS,wBAC/B,KAAa,cACd,KAAK,SAAS,wBACZ,OACA;EACR,IAAI,CAAC,WAAW,QAAQ,SAAS,SAAS;EAC1C,KAAK,MAAM,cAAc,QAAQ,gBAAgB,CAAC,GAAG;GACnD,IAAI,WAAW,IAAI,SAAS,cAAc;GAE1C,IAAI,OAAO,WAAW;GACtB,IAAI,MAAM,SAAS,kBAAkB,OAAO,KAAK;GACjD,IAAI,MAAM,SAAS,mBAAmB;GACtC,MAAM,UAAoB,CAAC;GAC3B,IAAI,eA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AA0B,OAAO,cAAc,CAAC;KACtD,KAAK,MAAM,QAAQ,kBAAkB;MACnC,MAAM,QAAQ,KAAK;MACnB,IAAI,CAAC,OAAO;MACZ,MAAM,WACJ,MAAM,SAAS,mBACX,MAAM,QAAQ,OACd,MAAM,SAAS,eACb,MAAM,OACN,KAAA;MACR,IAAI,aAAa,SAKf,OAAO,QAAQ;OACb,mBAAmB;OACnB,sBALA,MAAM,YAAY,EAAE,EAAE,SAAS,YAC3B,MAAM,UAAU,EAAE,CAAC,QACnB,SAG0B;OAC9B,UAAU;OACV,UAAU;MACZ;WACK,IAAI,aAAa,UAKtB,QAAQ,SAHN,MAAM,YAAY,EAAE,EAAE,SAAS,YAC3B,MAAM,UAAU,EAAE,CAAC,QACnB,SACmB;KAE7B;IACF;IAEA,QAAQ,KAAK;KACX,UAAU,SAAS,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;KACtC,MAAM,kBAAkB,cAAc,cAAc;KACpD;KACA;KACA,GAAI,OAAO,KAAK,MAAM,CAAC,CAAC,SAAS,IAAI,EAAE,OAAO,IAAI,CAAC;KACnD,GAAI,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,IAAI,EAAE,QAAQ,IAAI,CAAC;IACvD,CAAC;GACH;EACF;CACF;CAEA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"registry.js","names":[],"sources":["../../../../src/lib/compiler/registry.ts"],"sourcesContent":["import { parseSync } from 'oxc-parser';\nimport { COMPILABLE_DECORATORS } from './constants.js';\n\nexport interface RegistryInput {\n classPropertyName: string;\n bindingPropertyName: string;\n isSignal: boolean;\n required: boolean;\n /**\n * `true` when the input declares a `transform` function. The actual\n * transform expression isn't usable cross-file, but downstream tools\n * (template type checking, codegen widening) need to know whether\n * one exists so they can broaden the accepted binding type.\n */\n hasTransform?: boolean;\n}\n\nexport interface RegistryEntry {\n /** CSS selector for components/directives, pipe name for pipes, class name for NgModules */\n selector: string;\n /** What kind of Angular declaration this is */\n kind: 'component' | 'directive' | 'pipe' | 'ngmodule' | 'tuple';\n /** The pipe name (only for pipes) */\n pipeName?: string;\n /** Exported class names (only for NgModules) */\n exports?: string[];\n /** Declared class names (only for NgModules) — used to wire non-standalone\n * component scope from the declaring module. */\n declarations?: string[];\n /** Imported module/class names (only for NgModules) — expanded transitively\n * to compute the directive/pipe scope of declared components. */\n imports?: string[];\n /**\n * Member class names (only for `tuple` kind) — produced by top-level\n * `export const X = [A, B, C] as const` style barrels common in\n * helm/spartan-style libraries. The compiler expands these into the\n * underlying directives when they appear in another component's\n * `imports` array, mirroring how Angular's official compiler resolves\n * static `imports` references at compile time.\n */\n members?: string[];\n /** The source file this declaration was found in */\n fileName: string;\n /** The class name */\n className: string;\n /** Input bindings (from signal APIs and @Input decorators) */\n inputs?: Record<string, RegistryInput>;\n /** Output bindings (from signal APIs and @Output decorators) */\n outputs?: Record<string, string>;\n /** The package this declaration was scanned from (e.g. \"@angular/cdk\") */\n sourcePackage?: string;\n}\n\n/** Maps class name → registry entry */\nexport type ComponentRegistry = Map<string, RegistryEntry>;\n\nconst DECORATOR_RE = new RegExp(`@(${[...COMPILABLE_DECORATORS].join('|')})`);\n\n/**\n * Lightweight scan of a TypeScript file to extract Angular decorator metadata\n * without performing full compilation. Uses OXC's native Rust parser for speed.\n */\nexport function scanFile(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): RegistryEntry[] {\n const entries: RegistryEntry[] = [];\n\n // Fast regex pre-filter — skip files with neither Angular decorators\n // nor a top-level `const X = [...]` that might be a directive tuple\n // barrel re-export.\n if (!DECORATOR_RE.test(code) && !/\\bconst\\s+\\w+\\s*=\\s*\\[/.test(code)) {\n return entries;\n }\n\n program ??= parseSync(fileName, code).program;\n\n // First pass: collect tuple barrels — top-level `const X = [A, B, C]`\n // (with or without `export`/`as const`) where every element is a bare\n // class identifier. These are how spartan-style libraries expose a\n // group of directives behind a single import (e.g. `HlmSelectImports`).\n // Without registering them, the fast-compile path treats the bare\n // identifier as an unknown directive and Angular's runtime never\n // matches the underlying classes.\n for (const node of program.body) {\n const varDecl =\n node.type === 'ExportNamedDeclaration' &&\n (node as any).declaration?.type === 'VariableDeclaration'\n ? (node as any).declaration\n : node.type === 'VariableDeclaration'\n ? node\n : null;\n if (!varDecl || varDecl.kind !== 'const') continue;\n for (const declarator of varDecl.declarations || []) {\n if (declarator.id?.type !== 'Identifier') continue;\n // Unwrap `arr as const` → ArrayExpression\n let init = declarator.init;\n if (init?.type === 'TSAsExpression') init = init.expression;\n if (init?.type !== 'ArrayExpression') continue;\n const members: string[] = [];\n let allClassRefs = true;\n for (const el of init.elements || []) {\n if (el?.type !== 'Identifier') {\n allClassRefs = false;\n break;\n }\n members.push(el.name);\n }\n if (!allClassRefs || members.length === 0) continue;\n const tupleName: string = declarator.id.name;\n entries.push({\n selector: tupleName,\n kind: 'tuple',\n members,\n fileName,\n className: tupleName,\n });\n }\n }\n\n for (const node of program.body) {\n // Handle `class Foo {}`, `export class Foo {}`, and `export default class Foo {}`\n const decl =\n node.type === 'ExportNamedDeclaration' ||\n node.type === 'ExportDefaultDeclaration'\n ? (node as any).declaration\n : node;\n if (!decl || decl.type !== 'ClassDeclaration') continue;\n // Skip anonymous default exports (no name to register)\n if (!decl.id?.name) continue;\n\n const className: string = decl.id.name;\n const decorators: any[] = decl.decorators || [];\n\n for (const dec of decorators) {\n const expr = dec.expression;\n if (!expr || expr.type !== 'CallExpression') continue;\n\n const decoratorName: string = expr.callee?.name;\n if (!COMPILABLE_DECORATORS.has(decoratorName)) continue;\n\n const arg = expr.arguments?.[0];\n if (!arg || arg.type !== 'ObjectExpression') continue;\n\n let selector: string | undefined;\n let pipeName: string | undefined;\n let moduleExports: string[] | undefined;\n let moduleDeclarations: string[] | undefined;\n let moduleImports: string[] | undefined;\n\n // Class names from an NgModule metadata array: bare `Identifier`s and the\n // module out of `Module.forRoot(...)`/`forChild(...)` ModuleWithProviders.\n const classNamesFrom = (val: any): string[] =>\n (val?.elements ?? [])\n .map((e: any) => {\n if (e?.type === 'Identifier') return e.name;\n if (\n e?.type === 'CallExpression' &&\n // OXC emits `StaticMemberExpression`; the ESTree shape some\n // versions produce uses `MemberExpression`. Accept both (matches\n // the other member-expression checks in this file).\n (e.callee?.type === 'StaticMemberExpression' ||\n e.callee?.type === 'MemberExpression') &&\n e.callee.object?.type === 'Identifier'\n ) {\n return e.callee.object.name;\n }\n return undefined;\n })\n .filter((n: unknown): n is string => typeof n === 'string');\n\n for (const prop of arg.properties) {\n if (prop.type !== 'Property') continue;\n const key: string = prop.key?.name || prop.key?.value;\n const val = prop.value;\n\n if (\n key === 'selector' &&\n val?.type === 'Literal' &&\n typeof val.value === 'string'\n ) {\n selector = val.value;\n }\n if (\n key === 'name' &&\n val?.type === 'Literal' &&\n typeof val.value === 'string' &&\n decoratorName === 'Pipe'\n ) {\n pipeName = val.value;\n }\n if (val?.type === 'ArrayExpression' && decoratorName === 'NgModule') {\n if (key === 'exports') moduleExports = classNamesFrom(val);\n else if (key === 'declarations')\n moduleDeclarations = classNamesFrom(val);\n else if (key === 'imports') moduleImports = classNamesFrom(val);\n }\n }\n\n if (decoratorName === 'NgModule') {\n entries.push({\n selector: className,\n kind: 'ngmodule',\n exports: moduleExports || [],\n declarations: moduleDeclarations || [],\n imports: moduleImports || [],\n fileName,\n className,\n });\n } else if (decoratorName === 'Pipe' && pipeName) {\n entries.push({\n selector: pipeName,\n kind: 'pipe',\n pipeName,\n fileName,\n className,\n });\n } else if (selector) {\n // Extract inputs/outputs from class members\n const inputs: Record<string, RegistryInput> = {};\n const outputs: Record<string, string> = {};\n const members: any[] = decl.body?.body || [];\n\n for (const member of members) {\n if (member.type !== 'PropertyDefinition' || !member.key?.name)\n continue;\n const name: string = member.key.name;\n const init = member.value;\n\n // Signal APIs: input(), input.required(), model(), output()\n if (init?.type === 'CallExpression') {\n const callee = init.callee;\n let calleeName = '';\n if (callee?.type === 'Identifier') {\n calleeName = callee.name;\n } else if (\n callee?.type === 'StaticMemberExpression' ||\n callee?.type === 'MemberExpression'\n ) {\n calleeName =\n (callee.object?.name || '') +\n '.' +\n (callee.property?.name || '');\n }\n\n // Extract `alias` from an options object at the given\n // argument index. Used for input/model (options at index 1,\n // or 0 for the `.required` variants) and for output (options\n // at index 0). Without this, host-directive mappings that\n // reference the public name (e.g. `inputs: ['aria-label']`,\n // `outputs: ['publicEvent']`) fail to resolve.\n const aliasFromArg = (argIndex: number): string | null => {\n const optionsArg = init.arguments?.[argIndex];\n if (optionsArg?.type !== 'ObjectExpression') return null;\n for (const prop of optionsArg.properties || []) {\n if (prop.type !== 'ObjectProperty' && prop.type !== 'Property')\n continue;\n const k = prop.key?.name ?? prop.key?.value;\n if (k !== 'alias') continue;\n const v = prop.value;\n if (\n v?.type === 'StringLiteral' ||\n (v?.type === 'Literal' && typeof v.value === 'string')\n ) {\n return v.value;\n }\n }\n return null;\n };\n // Detect a `transform: ...` entry in the input options object\n // so cross-file consumers know the binding type is widened.\n const hasTransformAtArg = (argIndex: number): boolean => {\n const optionsArg = init.arguments?.[argIndex];\n if (optionsArg?.type !== 'ObjectExpression') return false;\n for (const prop of optionsArg.properties || []) {\n if (prop.type !== 'ObjectProperty' && prop.type !== 'Property')\n continue;\n const k = prop.key?.name ?? prop.key?.value;\n if (k === 'transform') return true;\n }\n return false;\n };\n const inputAliasIndex =\n calleeName === 'input.required' || calleeName === 'model.required'\n ? 0\n : 1;\n\n if (calleeName === 'input' || calleeName === 'input.required') {\n const alias = aliasFromArg(inputAliasIndex);\n const hasTransform = hasTransformAtArg(inputAliasIndex);\n inputs[name] = {\n classPropertyName: name,\n bindingPropertyName: alias ?? name,\n isSignal: true,\n required: calleeName === 'input.required',\n ...(hasTransform ? { hasTransform: true } : {}),\n };\n } else if (\n calleeName === 'model' ||\n calleeName === 'model.required'\n ) {\n const alias = aliasFromArg(inputAliasIndex);\n inputs[name] = {\n classPropertyName: name,\n bindingPropertyName: alias ?? name,\n isSignal: true,\n required: calleeName === 'model.required',\n };\n // outputs map is `{ classPropertyName: bindingName }` —\n // for a model, the class property is `name` and the\n // binding name is `${aliasOrName}Change`.\n outputs[name] = (alias ?? name) + 'Change';\n } else if (\n calleeName === 'output' ||\n calleeName === 'outputFromObservable'\n ) {\n // output() options at arg[0]; outputFromObservable(source,\n // opts?) options at arg[1].\n const alias = aliasFromArg(\n calleeName === 'outputFromObservable' ? 1 : 0,\n );\n outputs[name] = alias ?? name;\n }\n }\n\n // Decorator-based: @Input(), @Output()\n const memberDecorators: any[] = member.decorators || [];\n for (const mdec of memberDecorators) {\n const mexpr = mdec.expression;\n if (!mexpr) continue;\n const mdecName =\n mexpr.type === 'CallExpression'\n ? mexpr.callee?.name\n : mexpr.type === 'Identifier'\n ? mexpr.name\n : undefined;\n if (mdecName === 'Input') {\n const alias =\n mexpr.arguments?.[0]?.type === 'Literal'\n ? mexpr.arguments[0].value\n : name;\n inputs[name] = {\n classPropertyName: name,\n bindingPropertyName: alias || name,\n isSignal: false,\n required: false,\n };\n } else if (mdecName === 'Output') {\n const alias =\n mexpr.arguments?.[0]?.type === 'Literal'\n ? mexpr.arguments[0].value\n : name;\n outputs[name] = alias || name;\n }\n }\n }\n\n entries.push({\n selector: selector.split(',')[0].trim(),\n kind: decoratorName === 'Component' ? 'component' : 'directive',\n fileName,\n className,\n ...(Object.keys(inputs).length > 0 ? { inputs } : {}),\n ...(Object.keys(outputs).length > 0 ? { outputs } : {}),\n });\n }\n }\n }\n\n return entries;\n}\n\n/**\n * Whether the file declares a `@Component({ standalone: false })`. Such a\n * component's template scope comes from the NgModule that declares it, which\n * can only be found by scanning the whole project.\n */\nexport function declaresNonStandaloneComponent(\n program: ReturnType<typeof parseSync>['program'],\n): boolean {\n for (const node of program.body) {\n const decl =\n node.type === 'ExportNamedDeclaration' ||\n node.type === 'ExportDefaultDeclaration'\n ? (node as any).declaration\n : node;\n if (decl?.type !== 'ClassDeclaration') continue;\n for (const dec of decl.decorators || []) {\n const expr = dec.expression;\n if (expr?.type !== 'CallExpression') continue;\n if (expr.callee?.name !== 'Component') continue;\n const arg = expr.arguments?.[0];\n if (arg?.type !== 'ObjectExpression') continue;\n for (const prop of arg.properties) {\n if (\n prop.type === 'Property' &&\n (prop.key?.name || prop.key?.value) === 'standalone' &&\n prop.value?.type === 'Literal' &&\n prop.value.value === false\n ) {\n return true;\n }\n }\n }\n }\n return false;\n}\n"],"mappings":";;;AAwDA,IAAM,eAAe,IAAI,OAAO,KAAK,CAAC,GAAG,qBAAqB,CAAC,CAAC,KAAK,GAAG,EAAE,EAAE;;;;;AAM5E,SAAgB,SACd,MACA,UACA,SACiB;CACjB,MAAM,UAA2B,CAAC;CAKlC,IAAI,CAAC,aAAa,KAAK,IAAI,KAAK,CAAC,yBAAyB,KAAK,IAAI,GACjE,OAAO;CAGT,YAAY,UAAU,UAAU,IAAI,CAAC,CAAC;CAStC,KAAK,MAAM,QAAQ,QAAQ,MAAM;EAC/B,MAAM,UACJ,KAAK,SAAS,4BACb,KAAa,aAAa,SAAS,wBAC/B,KAAa,cACd,KAAK,SAAS,wBACZ,OACA;EACR,IAAI,CAAC,WAAW,QAAQ,SAAS,SAAS;EAC1C,KAAK,MAAM,cAAc,QAAQ,gBAAgB,CAAC,GAAG;GACnD,IAAI,WAAW,IAAI,SAAS,cAAc;GAE1C,IAAI,OAAO,WAAW;GACtB,IAAI,MAAM,SAAS,kBAAkB,OAAO,KAAK;GACjD,IAAI,MAAM,SAAS,mBAAmB;GACtC,MAAM,UAAoB,CAAC;GAC3B,IAAI,eAAe;GACnB,KAAK,MAAM,MAAM,KAAK,YAAY,CAAC,GAAG;IACpC,IAAI,IAAI,SAAS,cAAc;KAC7B,eAAe;KACf;IACF;IACA,QAAQ,KAAK,GAAG,IAAI;GACtB;GACA,IAAI,CAAC,gBAAgB,QAAQ,WAAW,GAAG;GAC3C,MAAM,YAAoB,WAAW,GAAG;GACxC,QAAQ,KAAK;IACX,UAAU;IACV,MAAM;IACN;IACA;IACA,WAAW;GACb,CAAC;EACH;CACF;CAEA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