@analogjs/vite-plugin-angular 3.0.0-beta.57 → 3.0.0-beta.59
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/migrations/migrate-setup-vitest/migrate-setup-vitest.js +1 -2
- package/package.json +2 -2
- package/src/index.js +1 -2
- package/src/lib/analog-plugin-interop.js +1 -2
- package/src/lib/angular-build-context.js +3 -4
- package/src/lib/angular-build-optimizer-plugin.js +2 -3
- package/src/lib/angular-jit-plugin.js +3 -4
- package/src/lib/angular-vite-plugin.js +4 -5
- package/src/lib/angular-vitest-plugin.js +2 -3
- package/src/lib/companion-plugins.js +2 -3
- package/src/lib/compilation-api/compilation-api-plugin.js +6 -7
- package/src/lib/compilation-api/index.js +1 -2
- package/src/lib/compiler/angular-version.js +0 -1
- package/src/lib/compiler/class-field-lowering.js +1 -2
- package/src/lib/compiler/compile.js +2 -3
- package/src/lib/compiler/compile.js.map +1 -1
- package/src/lib/compiler/constants.js +1 -2
- package/src/lib/compiler/debug.js +1 -2
- package/src/lib/compiler/defer.js +1 -2
- package/src/lib/compiler/dts-reader.js +1 -2
- package/src/lib/compiler/dts-reader.js.map +1 -1
- package/src/lib/compiler/hmr.js +1 -2
- package/src/lib/compiler/index.js +3 -3
- package/src/lib/compiler/jit-metadata.js +1 -2
- package/src/lib/compiler/jit-transform.js +2 -3
- package/src/lib/compiler/js-emitter.js +1 -2
- package/src/lib/compiler/metadata.js +2 -3
- package/src/lib/compiler/registry.js +2 -3
- package/src/lib/compiler/resource-inliner.js +1 -2
- package/src/lib/compiler/resource-inliner.js.map +1 -1
- package/src/lib/compiler/style-ast.js +1 -2
- package/src/lib/compiler/type-elision.js +1 -2
- package/src/lib/compiler/utils.js +1 -2
- package/src/lib/compiler/utils.js.map +1 -1
- package/src/lib/compiler-plugin.js +1 -2
- package/src/lib/component-resolvers.js +1 -2
- package/src/lib/component-scanner.js +3 -4
- package/src/lib/component-scanner.js.map +1 -1
- package/src/lib/component-styles-plugin.js +3 -4
- package/src/lib/compose-angular-plugins.js +2 -3
- package/src/lib/dev-server-mode-plugin.js +1 -2
- package/src/lib/encapsulation-plugin.js +1 -2
- package/src/lib/fast-compile-api.js +1 -2
- package/src/lib/fast-compile-plugin.js +11 -12
- package/src/lib/fast-compile-plugin.js.map +1 -1
- package/src/lib/host.js +3 -4
- package/src/lib/hot-update-batch.js +1 -2
- package/src/lib/live-reload-plugin.js +2 -3
- package/src/lib/ngp-compile-api.js +1 -2
- package/src/lib/ngp-compile-plugin.js +7 -8
- package/src/lib/ngp-compile-plugin.js.map +1 -1
- package/src/lib/ngtsc-compile-plugin.js +10 -11
- package/src/lib/nx-folder-plugin.js +1 -2
- package/src/lib/plugins/file-replacements.plugin.js +2 -3
- package/src/lib/router-plugin.js +2 -3
- package/src/lib/style-preprocessor.js +1 -2
- package/src/lib/stylesheet-registry.js +1 -2
- package/src/lib/stylesheet-registry.js.map +1 -1
- package/src/lib/tools/src/builders/vite/vite-build.impl.js +1 -2
- package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -1
- package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js +1 -2
- package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
- package/src/lib/utils/compilation-shared.js +2 -3
- package/src/lib/utils/css-extension-resolver.js +1 -2
- package/src/lib/utils/css-preprocessor-workers.js +1 -2
- package/src/lib/utils/debug-harness.js +1 -2
- package/src/lib/utils/debug-log-file.js +1 -2
- package/src/lib/utils/debug.js +1 -2
- package/src/lib/utils/devkit.js +1 -2
- package/src/lib/utils/hmr-component-updates.js +1 -2
- package/src/lib/utils/jit-inline-styles.js +1 -2
- package/src/lib/utils/lsp-type-checker.js +1 -2
- package/src/lib/utils/ngp-host-fs.js +1 -2
- package/src/lib/utils/plugin-config.js +1 -2
- package/src/lib/utils/rolldown.js +1 -2
- package/src/lib/utils/safe-module-paths.js +1 -2
- package/src/lib/utils/stylesheet-warning.js +1 -2
- package/src/lib/utils/transform-cache.js +1 -2
- package/src/lib/utils/transform-cache.js.map +1 -1
- package/src/lib/utils/tsconfig-resolver.js +1 -2
- package/src/lib/utils/virtual-ids.js +1 -2
- package/src/lib/utils/virtual-resources.js +1 -2
- package/src/lib/utils/virtual-resources.js.map +1 -1
- package/src/lib/virtual-modules-plugin.js +28 -4
- package/src/lib/virtual-modules-plugin.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dts-reader.js","names":[],"sources":["../../../../src/lib/compiler/dts-reader.ts"],"sourcesContent":["import type { parseSync } from 'oxc-parser';\nimport { parseOxc } from './utils.js';\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 } = parseOxc(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 = parseOxc(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 ??= parseOxc(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 = parseOxc(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 && !isTypeOnly(stmt)) 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 = parseOxc(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 && !isTypeOnly(stmt)) result.push(specifier);\n }\n }\n return result;\n}\n\nfunction isTypeOnly(stmt: any): boolean {\n return stmt.importKind === 'type' || stmt.exportKind === 'type';\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}\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IAAI,UAAU,UAAU,OAAO,IAAI;AAE1E;;AAGA,SAAS,cAAc,MAAmB;CACxC,IAAI,CAAC,MAAM,OAAO;CAClB,IAAI,KAAK,SAAS,cAAc,OAAO,KAAK;CAC5C,IAAI,KAAK,SAAS,mBAChB,OAAO,cAAc,KAAK,IAAI,IAAI,MAAM,cAAc,KAAK,KAAK;CAClE,OAAO;AACT;;AAGA,SAAS,cAAc,MAA+B;CACpD,IACE,MAAM,SAAS,mBACf,KAAK,SAAS,SAAS,aACvB,OAAO,KAAK,QAAQ,UAAU,UAE9B,OAAO,KAAK,QAAQ;AAGxB;;AAGA,SAAS,eAAe,MAAgC;CACtD,IACE,MAAM,SAAS,mBACf,KAAK,SAAS,SAAS,aACvB,OAAO,KAAK,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"}
|
|
1
|
+
{"version":3,"file":"dts-reader.js","names":["path"],"sources":["../../../../src/lib/compiler/dts-reader.ts"],"sourcesContent":["import type { parseSync } from 'oxc-parser';\nimport { parseOxc } from './utils.js';\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 } = parseOxc(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 = parseOxc(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 ??= parseOxc(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 = parseOxc(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 && !isTypeOnly(stmt)) 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 = parseOxc(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 && !isTypeOnly(stmt)) result.push(specifier);\n }\n }\n return result;\n}\n\nfunction isTypeOnly(stmt: any): boolean {\n return stmt.importKind === 'type' || stmt.exportKind === 'type';\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":";;;;;;;;;;;;;AAeA,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,SAAS,UAAU,IAAI;CAC3C,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,eAAeA,OAAK,QAAQ,UAAU,GAAG;EAC9C,MAAM,YAAYA,OAAK,KAAK,YAAY,gBAAgB,WAAW;EACnE,IAAI,GAAG,WAAW,SA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S,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,OAAOA,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"}
|
package/src/lib/compiler/hmr.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/vite-plugin-angular/src/lib/compiler/hmr.ts
|
|
2
2
|
/**
|
|
3
3
|
* Generate HMR code using Angular's ɵɵreplaceMetadata for components,
|
|
4
4
|
* and simple field-swap + invalidation for directives/pipes.
|
|
@@ -68,7 +68,6 @@ if (import.meta.hot) {
|
|
|
68
68
|
});
|
|
69
69
|
}`;
|
|
70
70
|
}
|
|
71
|
-
//#endregion
|
|
72
71
|
export { generateHmrCode };
|
|
73
72
|
|
|
74
73
|
//# sourceMappingURL=hmr.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ANGULAR_DECORATOR_CALL_RE } from "./constants.js";
|
|
2
|
-
import { debugRegistry } from "./debug.js";
|
|
3
1
|
import { compile } from "./compile.js";
|
|
2
|
+
import { ANGULAR_DECORATOR_CALL_RE } from "./constants.js";
|
|
4
3
|
import { declaresNonStandaloneComponent, scanFile } from "./registry.js";
|
|
5
4
|
import { collectAllImports, collectImportedPackages, collectReExports, collectRelativeReExports, scanPackageDts } from "./dts-reader.js";
|
|
6
5
|
import { jitTransform } from "./jit-transform.js";
|
|
7
|
-
import { generateHmrCode } from "./hmr.js";
|
|
8
6
|
import { extractInlineStyles, inlineResourceUrls } from "./resource-inliner.js";
|
|
7
|
+
import { generateHmrCode } from "./hmr.js";
|
|
8
|
+
import { debugRegistry } from "./debug.js";
|
|
9
9
|
export { ANGULAR_DECORATOR_CALL_RE, collectAllImports, collectImportedPackages, collectReExports, collectRelativeReExports, compile, debugRegistry, declaresNonStandaloneComponent, extractInlineStyles, generateHmrCode, inlineResourceUrls, jitTransform, scanFile, scanPackageDts };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FIELD_DECORATORS } from "./constants.js";
|
|
2
|
-
|
|
2
|
+
// packages/vite-plugin-angular/src/lib/compiler/jit-metadata.ts
|
|
3
3
|
/**
|
|
4
4
|
* JIT metadata helpers — OXC AST edition.
|
|
5
5
|
*
|
|
@@ -169,7 +169,6 @@ function buildPropDecorators(classNode, sourceCode, coreNamespace = "") {
|
|
|
169
169
|
if (entries.length === 0) return null;
|
|
170
170
|
return `{${entries.map(([key, decs]) => `${key}: [${decs.join(", ")}]`).join(", ")}}`;
|
|
171
171
|
}
|
|
172
|
-
//#endregion
|
|
173
172
|
export { buildCtorParameters, buildPropDecorators, findConstructor };
|
|
174
173
|
|
|
175
174
|
//# sourceMappingURL=jit-metadata.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ANGULAR_DECORATORS, FIELD_DECORATORS } from "./constants.js";
|
|
2
1
|
import { parseOxc } from "./utils.js";
|
|
3
2
|
import { detectTypeOnlyImportNames } from "./type-elision.js";
|
|
4
3
|
import { buildCtorParameters, buildPropDecorators, findConstructor } from "./jit-metadata.js";
|
|
4
|
+
import { ANGULAR_DECORATORS, FIELD_DECORATORS } from "./constants.js";
|
|
5
5
|
import MagicString from "magic-string";
|
|
6
|
-
|
|
6
|
+
// packages/vite-plugin-angular/src/lib/compiler/jit-transform.ts
|
|
7
7
|
/**
|
|
8
8
|
* Recursively find all ClassDeclaration nodes in an OXC AST.
|
|
9
9
|
* Handles top-level, exported, and nested classes (e.g. inside function scopes).
|
|
@@ -247,7 +247,6 @@ function jitTransform(sourceCode, fileName) {
|
|
|
247
247
|
map
|
|
248
248
|
};
|
|
249
249
|
}
|
|
250
|
-
//#endregion
|
|
251
250
|
export { jitTransform };
|
|
252
251
|
|
|
253
252
|
//# sourceMappingURL=jit-transform.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as o from "@angular/compiler";
|
|
2
|
-
|
|
2
|
+
// packages/vite-plugin-angular/src/lib/compiler/js-emitter.ts
|
|
3
3
|
var OP_DEFINITIONS = [
|
|
4
4
|
[
|
|
5
5
|
"Assign",
|
|
@@ -434,7 +434,6 @@ function emitAngularStmt(stmt) {
|
|
|
434
434
|
function setEmitterSourceCode(code) {
|
|
435
435
|
JSEmitter._currentSourceCode = code;
|
|
436
436
|
}
|
|
437
|
-
//#endregion
|
|
438
437
|
export { emitAngularExpr, emitAngularStmt, setEmitterSourceCode };
|
|
439
438
|
|
|
440
439
|
//# sourceMappingURL=js-emitter.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FIELD_DECORATORS, SIGNAL_APIS } from "./constants.js";
|
|
2
1
|
import { unwrapForwardRefOxc } from "./utils.js";
|
|
2
|
+
import { FIELD_DECORATORS, SIGNAL_APIS } from "./constants.js";
|
|
3
3
|
import * as o from "@angular/compiler";
|
|
4
|
-
|
|
4
|
+
// packages/vite-plugin-angular/src/lib/compiler/metadata.ts
|
|
5
5
|
function getCallApi(call) {
|
|
6
6
|
const callee = call.callee;
|
|
7
7
|
if (!callee) return null;
|
|
@@ -712,7 +712,6 @@ function extractConstructorDeps(classNode, sourceCode, typeOnlyImports) {
|
|
|
712
712
|
}
|
|
713
713
|
return invalid ? "invalid" : deps;
|
|
714
714
|
}
|
|
715
|
-
//#endregion
|
|
716
715
|
export { collectStringConstants, detectFieldDecorators, detectSignals, extractConstructorDeps, extractMetadata };
|
|
717
716
|
|
|
718
717
|
//# sourceMappingURL=metadata.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { COMPILABLE_DECORATORS } from "./constants.js";
|
|
2
1
|
import { parseOxc } from "./utils.js";
|
|
3
|
-
|
|
2
|
+
import { COMPILABLE_DECORATORS } from "./constants.js";
|
|
3
|
+
// packages/vite-plugin-angular/src/lib/compiler/registry.ts
|
|
4
4
|
var DECORATOR_RE = new RegExp(`@(${[...COMPILABLE_DECORATORS].join("|")})`);
|
|
5
5
|
/**
|
|
6
6
|
* Lightweight scan of a TypeScript file to extract Angular decorator metadata
|
|
@@ -190,7 +190,6 @@ function declaresNonStandaloneComponent(program) {
|
|
|
190
190
|
}
|
|
191
191
|
return false;
|
|
192
192
|
}
|
|
193
|
-
//#endregion
|
|
194
193
|
export { declaresNonStandaloneComponent, scanFile };
|
|
195
194
|
|
|
196
195
|
//# sourceMappingURL=registry.js.map
|
|
@@ -3,7 +3,7 @@ import { extractInlineStyles as extractInlineStyles$1 } from "./style-ast.js";
|
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
4
|
import * as path$1 from "node:path";
|
|
5
5
|
import MagicString from "magic-string";
|
|
6
|
-
|
|
6
|
+
// packages/vite-plugin-angular/src/lib/compiler/resource-inliner.ts
|
|
7
7
|
/** Whether a node is an inline style value (string literal or single-quasi template). */
|
|
8
8
|
function isInlineStyleValue(node) {
|
|
9
9
|
return node?.type === "Literal" && typeof node.value === "string" || node?.type === "TemplateLiteral" && node.quasis?.length === 1;
|
|
@@ -216,7 +216,6 @@ function extractInlineStyles(code, fileName, program) {
|
|
|
216
216
|
if (!code.includes("styles")) return [];
|
|
217
217
|
return extractInlineStyles$1(code, fileName, program);
|
|
218
218
|
}
|
|
219
|
-
//#endregion
|
|
220
219
|
export { extractInlineStyles, inlineResourceUrls };
|
|
221
220
|
|
|
222
221
|
//# sourceMappingURL=resource-inliner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-inliner.js","names":[],"sources":["../../../../src/lib/compiler/resource-inliner.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport type { parseSync } from 'oxc-parser';\nimport { parseOxc } from './utils.js';\nimport MagicString from 'magic-string';\nimport { extractInlineStyles as extractStylesFromAst } from './style-ast.js';\n\nexport interface InlineResourceResult {\n /** The modified source code, or the original if no changes were needed. */\n code: string;\n /**\n * Absolute path of each inlined external style, keyed by its position in\n * the flat per-file style list produced by {@link extractInlineStyles}. Lets\n * the caller preprocess each external `styleUrl` as its own file (extension\n * and relative imports), independent of the `inlineStylesExtension` option\n * (which governs truly-inline `styles: [...]` template strings).\n */\n stylePaths: Map<number, string>;\n /**\n * Absolute paths of every external resource file successfully read and\n * inlined. Callers record these so a later edit to the resource file can\n * invalidate the owning source module — the inlined copy is otherwise\n * invisible to the module graph.\n */\n resourceDependencies: string[];\n}\n\n/** Whether a node is an inline style value (string literal or single-quasi template). */\nfunction isInlineStyleValue(node: any): boolean {\n return (\n (node?.type === 'Literal' && typeof node.value === 'string') ||\n (node?.type === 'TemplateLiteral' && node.quasis?.length === 1)\n );\n}\n\n/** Count the elements of a `styles: [...]` array that {@link extractInlineStyles} would emit. */\nfunction countInlineStyleLiterals(arrayExpr: any): number {\n let count = 0;\n for (const el of arrayExpr.elements ?? []) {\n if (el?.type === 'Literal' && typeof el.value === 'string') count++;\n else if (el?.type === 'TemplateLiteral' && el.quasis?.length === 1) count++;\n }\n return count;\n}\n\n/**\n * Inline external templateUrl and styleUrl/styleUrls into the source code\n * using OXC parser for precise AST-based rewriting.\n *\n * Replaces:\n * templateUrl: './file.html' → template: \"...file contents...\"\n * styleUrl: './file.scss' → styles: [\"...file contents...\"]\n * styleUrls: ['./a.scss'] → styles: [\"...contents...\"]\n *\n * When the decorator already has a `styles: [...]` array, inlined CSS is\n * merged into that existing array instead of emitting a second `styles`\n * property (which would be a duplicate object literal key).\n *\n * Returns the modified source code plus the per-style-index path map\n * (see {@link InlineResourceResult}).\n */\nexport async function inlineResourceUrls(\n code: string,\n fileName: string,\n): Promise<InlineResourceResult> {\n const stylePaths = new Map<number, string>();\n\n if (!code.includes('templateUrl') && !code.includes('styleUrl')) {\n return { code, stylePaths, resourceDependencies: [] };\n }\n\n const { program } = parseOxc(fileName, code);\n const ms = new MagicString(code);\n let changed = false;\n const dir = path.dirname(fileName);\n\n // Phase 1: walk the AST and collect resource descriptors per decorator,\n // in source order — no I/O during the walk. A plan is recorded for every\n // `@Component` decorator (even without url props) because the flat style\n // index bookkeeping below advances per decorator.\n type ResourceProp =\n | { kind: 'templateUrl'; prop: any; resolvedPath: string }\n | { kind: 'styleUrl'; prop: any; resolvedPath: string }\n | { kind: 'styleUrls'; prop: any; resolvedPaths: string[] };\n interface DecoratorPlan {\n existingStylesProp: any;\n existingStylesArray: any;\n existingInlineCount: number;\n resourceProps: ResourceProp[];\n }\n const plans: DecoratorPlan[] = [];\n\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 || decl.type !== 'ClassDeclaration') continue;\n\n for (const dec of decl.decorators || []) {\n const expr = dec.expression;\n if (!expr || expr.type !== 'CallExpression') continue;\n if (expr.callee?.name !== 'Component') continue;\n\n const arg = expr.arguments?.[0];\n if (!arg || arg.type !== 'ObjectExpression') continue;\n\n // First pass: locate an existing `styles` property in the same decorator.\n // Inlined CSS is merged into it — converting a singular string/template\n // value to an array when needed — to avoid emitting a duplicate `styles`\n // key.\n let existingStylesProp: any = null;\n let existingStylesArray: any = null;\n for (const prop of arg.properties) {\n if (prop.type !== 'Property') continue;\n const key: string = prop.key?.name ?? prop.key?.value;\n if (key === 'styles') {\n existingStylesProp = prop;\n if (prop.value?.type === 'ArrayExpression') {\n existingStylesArray = prop.value;\n }\n break;\n }\n }\n\n // Inline `styles` entries already present come first in the flat list;\n // appended external styles follow them.\n const existingInlineCount = existingStylesArray\n ? countInlineStyleLiterals(existingStylesArray)\n : isInlineStyleValue(existingStylesProp?.value)\n ? 1\n : 0;\n\n const resourceProps: ResourceProp[] = [];\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 === 'templateUrl' &&\n val?.type === 'Literal' &&\n typeof val.value === 'string'\n ) {\n resourceProps.push({\n kind: 'templateUrl',\n prop,\n resolvedPath: path.resolve(dir, val.value),\n });\n continue;\n }\n\n if (\n key === 'styleUrl' &&\n val?.type === 'Literal' &&\n typeof val.value === 'string'\n ) {\n resourceProps.push({\n kind: 'styleUrl',\n prop,\n resolvedPath: path.resolve(dir, val.value),\n });\n continue;\n }\n\n if (key === 'styleUrls' && val?.type === 'ArrayExpression') {\n const resolvedPaths: string[] = [];\n for (const el of val.elements) {\n if (el?.type === 'Literal' && typeof el.value === 'string') {\n resolvedPaths.push(path.resolve(dir, el.value));\n }\n }\n resourceProps.push({ kind: 'styleUrls', prop, resolvedPaths });\n }\n }\n\n plans.push({\n existingStylesProp,\n existingStylesArray,\n existingInlineCount,\n resourceProps,\n });\n }\n }\n\n // Phase 2: read every referenced resource without blocking the event\n // loop. Each read catches its own failure to `undefined` — one missing\n // file must not abort sibling reads that succeed.\n const pathsToRead = new Set<string>();\n for (const plan of plans) {\n for (const rp of plan.resourceProps) {\n if (rp.kind === 'styleUrls') {\n for (const p of rp.resolvedPaths) pathsToRead.add(p);\n } else {\n pathsToRead.add(rp.resolvedPath);\n }\n }\n }\n const fileContents = new Map<string, string | undefined>();\n await Promise.all(\n [...pathsToRead].map(async (p) => {\n fileContents.set(\n p,\n await fs.promises.readFile(p, 'utf-8').catch(() => undefined),\n );\n }),\n );\n\n // Phase 3: apply MagicString rewrites in the original AST order so the\n // flat style index bookkeeping matches `extractInlineStyles`.\n\n // Running base index into the flat per-file style list (matching the order\n // `extractInlineStyles` walks classes/decorators/properties) so external\n // styles can be mapped to the index `resolvedInlineStyles` later keys on.\n let flatStyleBase = 0;\n\n for (const plan of plans) {\n const { existingStylesProp, existingStylesArray, existingInlineCount } =\n plan;\n\n // Collect the props we want to rewrite. Contents from styleUrl /\n // styleUrls are accumulated so that multiple url-based props in one\n // decorator collapse into a single `styles` array write. `paths`\n // tracks each content's source path in the same order.\n const templateUrlRewrites: Array<{ prop: any; content: string }> = [];\n const cssProps: Array<{\n prop: any;\n contents: string[];\n paths: string[];\n }> = [];\n\n for (const rp of plan.resourceProps) {\n if (rp.kind === 'templateUrl') {\n // Keep original if file can't be read\n const content = fileContents.get(rp.resolvedPath);\n if (content !== undefined) {\n templateUrlRewrites.push({ prop: rp.prop, content });\n }\n } else if (rp.kind === 'styleUrl') {\n // Keep original if file can't be read\n const content = fileContents.get(rp.resolvedPath);\n if (content !== undefined) {\n cssProps.push({\n prop: rp.prop,\n contents: [content],\n paths: [rp.resolvedPath],\n });\n }\n } else {\n // styleUrls is all-or-nothing: keep the original property if any\n // entry failed to read.\n const contents: string[] = [];\n let allRead = true;\n for (const p of rp.resolvedPaths) {\n const content = fileContents.get(p);\n if (content === undefined) {\n allRead = false;\n break;\n }\n contents.push(content);\n }\n if (allRead && contents.length > 0) {\n cssProps.push({ prop: rp.prop, contents, paths: rp.resolvedPaths });\n }\n }\n }\n\n for (const { prop, content } of templateUrlRewrites) {\n ms.overwrite(\n prop.start,\n prop.end,\n `template: ${JSON.stringify(content)}`,\n );\n changed = true;\n }\n\n if (cssProps.length > 0) {\n const allContents = cssProps.flatMap((c) => c.contents);\n const allPaths = cssProps.flatMap((c) => c.paths);\n\n if (existingStylesArray) {\n // Filter out null holes in case the source already has a sparse array.\n const realElements = (existingStylesArray.elements as any[]).filter(\n (e) => e != null,\n );\n\n if (realElements.length > 0) {\n // Insert right after the last real element. This preserves any\n // trailing comma the source may have (e.g. Prettier output) and\n // avoids producing a sparse `[existing, , \"new\"]` element, which\n // would crash downstream decorator metadata extraction.\n const lastElement = realElements[realElements.length - 1];\n const insertion = allContents\n .map((c) => `, ${JSON.stringify(c)}`)\n .join('');\n ms.appendRight(lastElement.end, insertion);\n } else {\n // Empty array — drop the leading comma.\n const insertion = allContents\n .map((c) => JSON.stringify(c))\n .join(', ');\n ms.appendLeft(existingStylesArray.end - 1, insertion);\n }\n\n for (const { prop } of cssProps) {\n removePropertyWithSeparator(ms, code, prop.start, prop.end);\n }\n } else if (isInlineStyleValue(existingStylesProp?.value)) {\n // Singular `styles: '...'` / `styles: \\`...\\`` — wrap the original\n // value into an array merged with the inlined styles, then drop the\n // styleUrl props so only one `styles` key remains.\n const original = code.slice(\n existingStylesProp.value.start,\n existingStylesProp.value.end,\n );\n const merged = allContents\n .map((c) => `, ${JSON.stringify(c)}`)\n .join('');\n ms.overwrite(\n existingStylesProp.value.start,\n existingStylesProp.value.end,\n `[${original}${merged}]`,\n );\n for (const { prop } of cssProps) {\n removePropertyWithSeparator(ms, code, prop.start, prop.end);\n }\n } else {\n // No existing `styles` array — rewrite the first styleUrl/styleUrls\n // prop with the merged contents and drop any additional ones so we\n // don't emit multiple `styles` properties.\n const [first, ...rest] = cssProps;\n ms.overwrite(\n first.prop.start,\n first.prop.end,\n `styles: [${allContents.map((c) => JSON.stringify(c)).join(', ')}]`,\n );\n for (const { prop } of rest) {\n removePropertyWithSeparator(ms, code, prop.start, prop.end);\n }\n }\n changed = true;\n\n // The appended external styles occupy the flat indices after any\n // pre-existing inline styles for this component.\n const externalBase = flatStyleBase + existingInlineCount;\n allPaths.forEach((p, k) => stylePaths.set(externalBase + k, p));\n flatStyleBase = externalBase + allContents.length;\n } else {\n flatStyleBase += existingInlineCount;\n }\n }\n\n return {\n code: changed ? ms.toString() : code,\n stylePaths,\n resourceDependencies: [...pathsToRead].filter(\n (p) => fileContents.get(p) !== undefined,\n ),\n };\n}\n\n/**\n * Remove a property from an object literal while also eating one surrounding\n * comma so the resulting object stays syntactically valid. Prefers the\n * trailing comma; falls back to the leading comma when the property is the\n * last entry in the object.\n */\nfunction removePropertyWithSeparator(\n ms: MagicString,\n code: string,\n propStart: number,\n propEnd: number,\n): void {\n let i = propEnd;\n while (i < code.length && isWhitespace(code[i])) i++;\n if (code[i] === ',') {\n ms.remove(propStart, i + 1);\n return;\n }\n let j = propStart - 1;\n while (j >= 0 && isWhitespace(code[j])) j--;\n if (code[j] === ',') {\n ms.remove(j, propEnd);\n return;\n }\n ms.remove(propStart, propEnd);\n}\n\nfunction isWhitespace(ch: string): boolean {\n return (\n ch === ' ' ||\n ch === '\\t' ||\n ch === '\\n' ||\n ch === '\\r' ||\n ch === '\\f' ||\n ch === '\\v'\n );\n}\n\n/**\n * Extract inline style strings from Angular @Component decorator using OXC parser.\n * Returns an array of style string values for preprocessing.\n */\nexport function extractInlineStyles(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): string[] {\n if (!code.includes('styles')) return [];\n return extractStylesFromAst(code, fileName, program);\n}\n"],"mappings":";;;;;;;AA4BA,SAAS,mBAAmB,MAAoB;CAC9C,OACG,MAAM,SAAS,aAAa,OAAO,KAAK,UAAU,YAClD,MAAM,SAAS,qBAAqB,KAAK,QAAQ,WAAW;AAEjE;;AAGA,SAAS,yBAAyB,WAAwB;CACxD,IAAI,QAAQ;CACZ,KAAK,MAAM,MAAM,UAAU,YAAY,CAAC,GACtC,IAAI,IAAI,SAAS,aAAa,OAAO,GAAG,UAAU,UAAU;MACvD,IAAI,IAAI,SAAS,qBAAqB,GAAG,QAAQ,WAAW,GAAG;CAEtE,OAAO;AACT;;;;;;;;;;;;;;;;;AAkBA,eAAsB,mBACpB,MACA,UAC+B;CAC/B,MAAM,6BAAa,IAAI,IAAoB;CAE3C,IAAI,CAAC,KAAK,SAAS,aAAa,KAAK,CAAC,KAAK,SAAS,UAAU,GAC5D,OAAO;EAAE;EAAM;EAAY,sBAAsB,CAAC;CAAE;CAGtD,MAAM,EAAE,YAAY,SAAS,UAAU,IAAI;CAC3C,MAAM,KAAK,IAAI,YAAY,IAAI;CAC/B,IAAI,UAAU;CACd,MAAM,MAAM,OAAK,QAAQ,QAAQ;CAgBjC,MAAM,QAAyB,CAAC;CAEhC,KAAK,MAAM,QAAQ,QAAQ,MAAM;EAC/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O,QACP,OAAO,QACP,OAAO;AAEX;;;;;AAMA,SAAgB,oBACd,MACA,UACA,SACU;CACV,IAAI,CAAC,KAAK,SAAS,QAAQ,GAAG,OAAO,CAAC;CACtC,OAAO,sBAAqB,MAAM,UAAU,OAAO;AACrD"}
|
|
1
|
+
{"version":3,"file":"resource-inliner.js","names":["path","extractStylesFromAst"],"sources":["../../../../src/lib/compiler/resource-inliner.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport type { parseSync } from 'oxc-parser';\nimport { parseOxc } from './utils.js';\nimport MagicString from 'magic-string';\nimport { extractInlineStyles as extractStylesFromAst } from './style-ast.js';\n\nexport interface InlineResourceResult {\n /** The modified source code, or the original if no changes were needed. */\n code: string;\n /**\n * Absolute path of each inlined external style, keyed by its position in\n * the flat per-file style list produced by {@link extractInlineStyles}. Lets\n * the caller preprocess each external `styleUrl` as its own file (extension\n * and relative imports), independent of the `inlineStylesExtension` option\n * (which governs truly-inline `styles: [...]` template strings).\n */\n stylePaths: Map<number, string>;\n /**\n * Absolute paths of every external resource file successfully read and\n * inlined. Callers record these so a later edit to the resource file can\n * invalidate the owning source module — the inlined copy is otherwise\n * invisible to the module graph.\n */\n resourceDependencies: string[];\n}\n\n/** Whether a node is an inline style value (string literal or single-quasi template). */\nfunction isInlineStyleValue(node: any): boolean {\n return (\n (node?.type === 'Literal' && typeof node.value === 'string') ||\n (node?.type === 'TemplateLiteral' && node.quasis?.length === 1)\n );\n}\n\n/** Count the elements of a `styles: [...]` array that {@link extractInlineStyles} would emit. */\nfunction countInlineStyleLiterals(arrayExpr: any): number {\n let count = 0;\n for (const el of arrayExpr.elements ?? []) {\n if (el?.type === 'Literal' && typeof el.value === 'string') count++;\n else if (el?.type === 'TemplateLiteral' && el.quasis?.length === 1) count++;\n }\n return count;\n}\n\n/**\n * Inline external templateUrl and styleUrl/styleUrls into the source code\n * using OXC parser for precise AST-based rewriting.\n *\n * Replaces:\n * templateUrl: './file.html' → template: \"...file contents...\"\n * styleUrl: './file.scss' → styles: [\"...file contents...\"]\n * styleUrls: ['./a.scss'] → styles: [\"...contents...\"]\n *\n * When the decorator already has a `styles: [...]` array, inlined CSS is\n * merged into that existing array instead of emitting a second `styles`\n * property (which would be a duplicate object literal key).\n *\n * Returns the modified source code plus the per-style-index path map\n * (see {@link InlineResourceResult}).\n */\nexport async function inlineResourceUrls(\n code: string,\n fileName: string,\n): Promise<InlineResourceResult> {\n const stylePaths = new Map<number, string>();\n\n if (!code.includes('templateUrl') && !code.includes('styleUrl')) {\n return { code, stylePaths, resourceDependencies: [] };\n }\n\n const { program } = parseOxc(fileName, code);\n const ms = new MagicString(code);\n let changed = false;\n const dir = path.dirname(fileName);\n\n // Phase 1: walk the AST and collect resource descriptors per decorator,\n // in source order — no I/O during the walk. A plan is recorded for every\n // `@Component` decorator (even without url props) because the flat style\n // index bookkeeping below advances per decorator.\n type ResourceProp =\n | { kind: 'templateUrl'; prop: any; resolvedPath: string }\n | { kind: 'styleUrl'; prop: any; resolvedPath: string }\n | { kind: 'styleUrls'; prop: any; resolvedPaths: string[] };\n interface DecoratorPlan {\n existingStylesProp: any;\n existingStylesArray: any;\n existingInlineCount: number;\n resourceProps: ResourceProp[];\n }\n const plans: DecoratorPlan[] = [];\n\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 || decl.type !== 'ClassDeclaration') continue;\n\n for (const dec of decl.decorators || []) {\n const expr = dec.expression;\n if (!expr || expr.type !== 'CallExpression') continue;\n if (expr.callee?.name !== 'Component') continue;\n\n const arg = expr.arguments?.[0];\n if (!arg || arg.type !== 'ObjectExpression') continue;\n\n // First pass: locate an existing `styles` property in the same decorator.\n // Inlined CSS is merged into it — converting a singular string/template\n // value to an array when needed — to avoid emitting a duplicate `styles`\n // key.\n let existingStylesProp: any = null;\n let existingStylesArray: any = null;\n for (const prop of arg.properties) {\n if (prop.type !== 'Property') continue;\n const key: string = prop.key?.name ?? prop.key?.value;\n if (key === 'styles') {\n existingStylesProp = prop;\n if (prop.value?.type === 'ArrayExpression') {\n existingStylesArray = prop.value;\n }\n break;\n }\n }\n\n // Inline `styles` entries already present come first in the flat list;\n // appended external styles follow them.\n const existingInlineCount = existingStylesArray\n ? countInlineStyleLiterals(existingStylesArray)\n : isInlineStyleValue(existingStylesProp?.value)\n ? 1\n : 0;\n\n const resourceProps: ResourceProp[] = [];\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 === 'templateUrl' &&\n val?.type === 'Literal' &&\n typeof val.value === 'string'\n ) {\n resourceProps.push({\n kind: 'templateUrl',\n prop,\n resolvedPath: path.resolve(dir, val.value),\n });\n continue;\n }\n\n if (\n key === 'styleUrl' &&\n val?.type === 'Literal' &&\n typeof val.value === 'string'\n ) {\n resourceProps.push({\n kind: 'styleUrl',\n prop,\n resolvedPath: path.resolve(dir, val.value),\n });\n continue;\n }\n\n if (key === 'styleUrls' && val?.type === 'ArrayExpression') {\n const resolvedPaths: string[] = [];\n for (const el of val.elements) {\n if (el?.type === 'Literal' && typeof el.value === 'string') {\n resolvedPaths.push(path.resolve(dir, el.value));\n }\n }\n resourceProps.push({ kind: 'styleUrls', prop, resolvedPaths });\n }\n }\n\n plans.push({\n existingStylesProp,\n existingStylesArray,\n existingInlineCount,\n resourceProps,\n });\n }\n }\n\n // Phase 2: read every referenced resource without blocking the event\n // loop. Each read catches its own failure to `undefined` — one missing\n // file must not abort sibling reads that succeed.\n const pathsToRead = new Set<string>();\n for (const plan of plans) {\n for (const rp of plan.resourceProps) {\n if (rp.kind === 'styleUrls') {\n for (const p of rp.resolvedPaths) pathsToRead.add(p);\n } else {\n pathsToRead.add(rp.resolvedPath);\n }\n }\n }\n const fileContents = new Map<string, string | undefined>();\n await Promise.all(\n [...pathsToRead].map(async (p) => {\n fileContents.set(\n p,\n await fs.promises.readFile(p, 'utf-8').catch(() => undefined),\n );\n }),\n );\n\n // Phase 3: apply MagicString rewrites in the original AST order so the\n // flat style index bookkeeping matches `extractInlineStyles`.\n\n // Running base index into the flat per-file style list (matching the order\n // `extractInlineStyles` walks classes/decorators/properties) so external\n // styles can be mapped to the index `resolvedInlineStyles` later keys on.\n let flatStyleBase = 0;\n\n for (const plan of plans) {\n const { existingStylesProp, existingStylesArray, existingInlineCount } =\n plan;\n\n // Collect the props we want to rewrite. Contents from styleUrl /\n // styleUrls are accumulated so that multiple url-based props in one\n // decorator collapse into a single `styles` array write. `paths`\n // tracks each content's source path in the same order.\n const templateUrlRewrites: Array<{ prop: any; content: string }> = [];\n const cssProps: Array<{\n prop: any;\n contents: string[];\n paths: string[];\n }> = [];\n\n for (const rp of plan.resourceProps) {\n if (rp.kind === 'templateUrl') {\n // Keep original if file can't be read\n const content = fileContents.get(rp.resolvedPath);\n if (content !== undefined) {\n templateUrlRewrites.push({ prop: rp.prop, content });\n }\n } else if (rp.kind === 'styleUrl') {\n // Keep original if file can't be read\n const content = fileContents.get(rp.resolvedPath);\n if (content !== undefined) {\n cssProps.push({\n prop: rp.prop,\n contents: [content],\n paths: [rp.resolvedPath],\n });\n }\n } else {\n // styleUrls is all-or-nothing: keep the original property if any\n // entry failed to read.\n const contents: string[] = [];\n let allRead = true;\n for (const p of rp.resolvedPaths) {\n const content = fileContents.get(p);\n if (content === undefined) {\n allRead = false;\n break;\n }\n contents.push(content);\n }\n if (allRead && contents.length > 0) {\n cssProps.push({ prop: rp.prop, contents, paths: rp.resolvedPaths });\n }\n }\n }\n\n for (const { prop, content } of templateUrlRewrites) {\n ms.overwrite(\n prop.start,\n prop.end,\n `template: ${JSON.stringify(content)}`,\n );\n changed = true;\n }\n\n if (cssProps.length > 0) {\n const allContents = cssProps.flatMap((c) => c.contents);\n const allPaths = cssProps.flatMap((c) => c.paths);\n\n if (existingStylesArray) {\n // Filter out null holes in case the source already has a sparse array.\n const realElements = (existingStylesArray.elements as any[]).filter(\n (e) => e != null,\n );\n\n if (realElements.length > 0) {\n // Insert right after the last real element. This preserves any\n // trailing comma the source may have (e.g. Prettier output) and\n // avoids producing a sparse `[existing, , \"new\"]` element, which\n // would crash downstream decorator metadata extraction.\n const lastElement = realElements[realElements.length - 1];\n const insertion = allContents\n .map((c) => `, ${JSON.stringify(c)}`)\n .join('');\n ms.appendRight(lastElement.end, insertion);\n } else {\n // Empty array — drop the leading comma.\n const insertion = allContents\n .map((c) => JSON.stringify(c))\n .join(', ');\n ms.appendLeft(existingStylesArray.end - 1, insertion);\n }\n\n for (const { prop } of cssProps) {\n removePropertyWithSeparator(ms, code, prop.start, prop.end);\n }\n } else if (isInlineStyleValue(existingStylesProp?.value)) {\n // Singular `styles: '...'` / `styles: \\`...\\`` — wrap the original\n // value into an array merged with the inlined styles, then drop the\n // styleUrl props so only one `styles` key remains.\n const original = code.slice(\n existingStylesProp.value.start,\n existingStylesProp.value.end,\n );\n const merged = allContents\n .map((c) => `, ${JSON.stringify(c)}`)\n .join('');\n ms.overwrite(\n existingStylesProp.value.start,\n existingStylesProp.value.end,\n `[${original}${merged}]`,\n );\n for (const { prop } of cssProps) {\n removePropertyWithSeparator(ms, code, prop.start, prop.end);\n }\n } else {\n // No existing `styles` array — rewrite the first styleUrl/styleUrls\n // prop with the merged contents and drop any additional ones so we\n // don't emit multiple `styles` properties.\n const [first, ...rest] = cssProps;\n ms.overwrite(\n first.prop.start,\n first.prop.end,\n `styles: [${allContents.map((c) => JSON.stringify(c)).join(', ')}]`,\n );\n for (const { prop } of rest) {\n removePropertyWithSeparator(ms, code, prop.start, prop.end);\n }\n }\n changed = true;\n\n // The appended external styles occupy the flat indices after any\n // pre-existing inline styles for this component.\n const externalBase = flatStyleBase + existingInlineCount;\n allPaths.forEach((p, k) => stylePaths.set(externalBase + k, p));\n flatStyleBase = externalBase + allContents.length;\n } else {\n flatStyleBase += existingInlineCount;\n }\n }\n\n return {\n code: changed ? ms.toString() : code,\n stylePaths,\n resourceDependencies: [...pathsToRead].filter(\n (p) => fileContents.get(p) !== undefined,\n ),\n };\n}\n\n/**\n * Remove a property from an object literal while also eating one surrounding\n * comma so the resulting object stays syntactically valid. Prefers the\n * trailing comma; falls back to the leading comma when the property is the\n * last entry in the object.\n */\nfunction removePropertyWithSeparator(\n ms: MagicString,\n code: string,\n propStart: number,\n propEnd: number,\n): void {\n let i = propEnd;\n while (i < code.length && isWhitespace(code[i])) i++;\n if (code[i] === ',') {\n ms.remove(propStart, i + 1);\n return;\n }\n let j = propStart - 1;\n while (j >= 0 && isWhitespace(code[j])) j--;\n if (code[j] === ',') {\n ms.remove(j, propEnd);\n return;\n }\n ms.remove(propStart, propEnd);\n}\n\nfunction isWhitespace(ch: string): boolean {\n return (\n ch === ' ' ||\n ch === '\\t' ||\n ch === '\\n' ||\n ch === '\\r' ||\n ch === '\\f' ||\n ch === '\\v'\n );\n}\n\n/**\n * Extract inline style strings from Angular @Component decorator using OXC parser.\n * Returns an array of style string values for preprocessing.\n */\nexport function extractInlineStyles(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): string[] {\n if (!code.includes('styles')) return [];\n return extractStylesFromAst(code, fileName, program);\n}\n"],"mappings":";;;;;;;AA4BA,SAAS,mBAAmB,MAAoB;CAC9C,OACG,MAAM,SAAS,aAAa,OAAO,KAAK,UAAU,YAClD,MAAM,SAAS,qBAAqB,KAAK,QAAQ,WAAW;AAEjE;;AAGA,SAAS,yBAAyB,WAAwB;CACxD,IAAI,QAAQ;CACZ,KAAK,MAAM,MAAM,UAAU,YAAY,CAAC,GACtC,IAAI,IAAI,SAAS,aAAa,OAAO,GAAG,UAAU,UAAU;MACvD,IAAI,IAAI,SAAS,qBAAqB,GAAG,QAAQ,WAAW,GAAG;CAEtE,OAAO;AACT;;;;;;;;;;;;;;;;;AAkBA,eAAsB,mBACpB,MACA,UAC+B;CAC/B,MAAM,6BAAa,IAAI,IAAoB;CAE3C,IAAI,CAAC,KAAK,SAAS,aA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;EACnB,GAAG,OAAO,WAAW,IAAI,CAAC;EAC1B;CACF;CACA,IAAI,IAAI,YAAY;CACpB,OAAO,KAAK,KAAK,aAAa,KAAK,EAAE,GAAG;CACxC,IAAI,KAAK,OAAO,KAAK;EACnB,GAAG,OAAO,GAAG,OAAO;EACpB;CACF;CACA,GAAG,OAAO,WAAW,OAAO;AAC9B;AAEA,SAAS,aAAa,IAAqB;CACzC,OACE,OAAO,OACP,OAAO,OACP,OAAO,QACP,OAAO,QACP,OAAO,QACP,OAAO;AAEX;;;;;AAMA,SAAgB,oBACd,MACA,UACA,SACU;CACV,IAAI,CAAC,KAAK,SAAS,QAAQ,GAAG,OAAO,CAAC;CACtC,OAAOC,sBAAqB,MAAM,UAAU,OAAO;AACrD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseOxc } from "./utils.js";
|
|
2
|
-
|
|
2
|
+
// packages/vite-plugin-angular/src/lib/compiler/style-ast.ts
|
|
3
3
|
function getClassDeclaration(node) {
|
|
4
4
|
return node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration" ? node.declaration : node;
|
|
5
5
|
}
|
|
@@ -66,7 +66,6 @@ function componentInlineStyles(program) {
|
|
|
66
66
|
}
|
|
67
67
|
return result;
|
|
68
68
|
}
|
|
69
|
-
//#endregion
|
|
70
69
|
export { extractInlineStyles, getPropertyKey, inlineStyleRanges };
|
|
71
70
|
|
|
72
71
|
//# sourceMappingURL=style-ast.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { findAllClasses, parseOxc } from "./utils.js";
|
|
2
2
|
import "magic-string";
|
|
3
|
-
|
|
3
|
+
// packages/vite-plugin-angular/src/lib/compiler/type-elision.ts
|
|
4
4
|
/**
|
|
5
5
|
* AST property keys that represent type-only positions in TypeScript.
|
|
6
6
|
* Identifiers found only under these keys are never emitted as runtime values.
|
|
@@ -204,7 +204,6 @@ function elideTypeOnlyImportsMagicString(ms, originalProgram, typeOnlyNames = de
|
|
|
204
204
|
if (typeOnlyNames.size === 0) return;
|
|
205
205
|
applyElisionEdits(ms, originalProgram ?? parseOxc("file.ts", ms.original).program, ms.original, typeOnlyNames);
|
|
206
206
|
}
|
|
207
|
-
//#endregion
|
|
208
207
|
export { detectTypeOnlyImportNames, elideTypeOnlyImportsMagicString };
|
|
209
208
|
|
|
210
209
|
//# sourceMappingURL=type-elision.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./constants.js";
|
|
2
2
|
import * as path$1 from "node:path";
|
|
3
3
|
import { parseSync, rawTransferSupported } from "oxc-parser";
|
|
4
|
-
|
|
4
|
+
// packages/vite-plugin-angular/src/lib/compiler/utils.ts
|
|
5
5
|
var rawTransferOptions = { experimentalRawTransfer: true };
|
|
6
6
|
var useRawTransfer = rawTransferSupported();
|
|
7
7
|
/**
|
|
@@ -112,7 +112,6 @@ function deriveRelativeImportPath(fromFile, toFile) {
|
|
|
112
112
|
if (!rel.startsWith(".")) rel = "./" + rel;
|
|
113
113
|
return rel;
|
|
114
114
|
}
|
|
115
|
-
//#endregion
|
|
116
115
|
export { deriveRelativeImportPath, findAllClasses, parseOxc, resolveSyntheticImportSpecifier, unwrapForwardRefOxc, walkOxc };
|
|
117
116
|
|
|
118
117
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../../../src/lib/compiler/utils.ts"],"sourcesContent":["import * as path from 'node:path';\nimport {\n parseSync,\n rawTransferSupported,\n type ParseResult,\n type ParserOptions,\n} from 'oxc-parser';\n\n// Raw transfer reads the AST straight from Rust memory instead of going\n// through JSON (~3x faster). Not yet in oxc-parser's published types.\nconst rawTransferOptions = { experimentalRawTransfer: true } as ParserOptions;\nlet useRawTransfer = rawTransferSupported();\n\n/**\n * Parse with oxc-parser, using raw transfer when the platform supports it.\n * Falls back to the default transfer for this and later calls if raw\n * transfer throws (e.g. its large buffer cannot be allocated).\n */\nconst JS_TS_EXTENSIONS = [\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.cjs',\n];\n\nexport function parseOxc(fileName: string, code: string): ParseResult {\n // OXC picks the language from the extension. Modules of other source\n // formats reach the compiler already converted to TypeScript.\n if (!JS_TS_EXTENSIONS.some((ext) => fileName.endsWith(ext))) {\n fileName += '.ts';\n }\n if (useRawTransfer) {\n try {\n return parseSync(fileName, code, rawTransferOptions);\n } catch {\n useRawTransfer = false;\n }\n }\n return parseSync(fileName, code);\n}\n\n/** Recursively find all class declarations in an OXC AST, including nested scopes. */\nexport function findAllClasses(program: any): any[] {\n const result: any[] = [];\n walkOxc(program, (node) => {\n if (node.type === 'ClassDeclaration') result.push(node);\n return true;\n });\n return result;\n}\n\n/**\n * Depth-first walk over OXC AST nodes. `visit` returns `false` to skip a\n * node's children.\n */\nexport function walkOxc(node: any, visit: (node: any) => boolean): void {\n if (Array.isArray(node)) {\n for (const child of node) walkOxc(child, visit);\n return;\n }\n if (!node || typeof node.type !== 'string' || !visit(node)) return;\n for (const key in node) {\n const value = node[key];\n if (value && typeof value === 'object') walkOxc(value, visit);\n }\n}\n\n/** Unwrap forwardRef(() => X) to X for OXC AST nodes. Returns the original node if not a forwardRef call. */\nexport function unwrapForwardRefOxc(node: any): any {\n if (\n node?.type === 'CallExpression' &&\n node.callee?.type === 'Identifier' &&\n node.callee.name === 'forwardRef'\n ) {\n const arg = node.arguments?.[0];\n if (arg?.type === 'ArrowFunctionExpression') {\n if (\n arg.body?.type === 'FunctionBody' ||\n arg.body?.type === 'BlockStatement'\n ) {\n const stmts = arg.body.statements || arg.body.body || [];\n const stmt = stmts[0];\n if (stmt?.type === 'ReturnStatement' && stmt.argument)\n return stmt.argument;\n } else {\n // Expression body: forwardRef(() => X)\n return arg.body;\n }\n }\n if (arg?.type === 'FunctionExpression') {\n const stmts = arg.body?.statements || arg.body?.body || [];\n if (stmts.length === 1) {\n const stmt = stmts[0];\n if (stmt?.type === 'ReturnStatement' && stmt.argument)\n return stmt.argument;\n }\n }\n }\n return node;\n}\n\n/**\n * Resolve the module specifier to use for a synthetic import of a registry\n * declaration referenced from `currentFileName`.\n *\n * Order of preference:\n * 1. `entry.sourcePackage` — external packages scanned from `.d.ts` resolve\n * via their package name (proper barrel exports).\n * 2. A relative path derived from `currentFileName` to `entry.fileName` — for\n * local workspace classes scanned from real source files. This is what\n * NgModule/tuple export expansion must use: the class lives in its own\n * file, not the module/barrel file that re-exports it, so importing from\n * the module specifier fails with\n * `\"X\" is not exported by \".../the.module.ts\"`.\n * 3. `fallbackSpecifier` — the import path of the module/tuple itself, used\n * for `.d.ts` entries (whose file path is not a usable import target) and\n * when the registry has no file location for the class.\n *\n * Returns `undefined` when the class is declared in `currentFileName` itself\n * (already in scope — no synthetic import needed).\n */\nexport function resolveSyntheticImportSpecifier(\n currentFileName: string,\n entry: { sourcePackage?: string; fileName?: string },\n fallbackSpecifier: string | undefined,\n): string | undefined {\n if (entry.sourcePackage) return entry.sourcePackage;\n // `.d.ts` entries come from scanning external package type declarations;\n // their file path is not a usable relative import target, so defer to the\n // module/tuple specifier the consumer already imports from.\n if (entry.fileName && !entry.fileName.endsWith('.d.ts')) {\n if (entry.fileName === currentFileName) return undefined;\n return deriveRelativeImportPath(currentFileName, entry.fileName);\n }\n return fallbackSpecifier;\n}\n\n/**\n * Derive a relative module specifier from `fromFile` to `toFile`, suitable for\n * a synthetic `import { … } from '…'` statement: strips the file extension,\n * normalizes to POSIX separators, and ensures an explicit `./` prefix.\n */\nexport function deriveRelativeImportPath(\n fromFile: string,\n toFile: string,\n): string {\n let rel = path.relative(path.dirname(fromFile), toFile);\n rel = rel.replace(/\\.[cm]?[jt]sx?$/, '');\n rel = rel.split(path.sep).join('/');\n if (!rel.startsWith('.')) rel = './' + rel;\n return rel;\n}\n\nexport { ANGULAR_DECORATORS } from './constants.js';\n"],"mappings":";;;;AAUA,IAAM,qBAAqB,EAAE,yBAAyB,KAAK;AAC3D,IAAI,iBAAiB,q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,SAAS,sBAAsB;GACtC,MAAM,QAAQ,IAAI,MAAM,cAAc,IAAI,MAAM,QAAQ,CAAC;GACzD,IAAI,MAAM,WAAW,GAAG;IACtB,MAAM,OAAO,MAAM;IACnB,IAAI,MAAM,SAAS,qBAAqB,KAAK,UAC3C,OAAO,KAAK;GAChB;EACF;CACF;CACA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,gCACd,iBACA,OACA,mBACoB;CACpB,IAAI,MAAM,eAAe,OAAO,MAAM;CAItC,IAAI,MAAM,YAAY,CAAC,MAAM,SAAS,SAAS,OAAO,GAAG;EACvD,IAAI,MAAM,aAAa,iBAAiB,OAAO,KAAA;EAC/C,OAAO,yBAAyB,iBAAiB,MAAM,QAAQ;CACjE;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,yBACd,UACA,QACQ;CACR,IAAI,
|
|
1
|
+
{"version":3,"file":"utils.js","names":["path"],"sources":["../../../../src/lib/compiler/utils.ts"],"sourcesContent":["import * as path from 'node:path';\nimport {\n parseSync,\n rawTransferSupported,\n type ParseResult,\n type ParserOptions,\n} from 'oxc-parser';\n\n// Raw transfer reads the AST straight from Rust memory instead of going\n// through JSON (~3x faster). Not yet in oxc-parser's published types.\nconst rawTransferOptions = { experimentalRawTransfer: true } as ParserOptions;\nlet useRawTransfer = rawTransferSupported();\n\n/**\n * Parse with oxc-parser, using raw transfer when the platform supports it.\n * Falls back to the default transfer for this and later calls if raw\n * transfer throws (e.g. its large buffer cannot be allocated).\n */\nconst JS_TS_EXTENSIONS = [\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.cjs',\n];\n\nexport function parseOxc(fileName: string, code: string): ParseResult {\n // OXC picks the language from the extension. Modules of other source\n // formats reach the compiler already converted to TypeScript.\n if (!JS_TS_EXTENSIONS.some((ext) => fileName.endsWith(ext))) {\n fileName += '.ts';\n }\n if (useRawTransfer) {\n try {\n return parseSync(fileName, code, rawTransferOptions);\n } catch {\n useRawTransfer = false;\n }\n }\n return parseSync(fileName, code);\n}\n\n/** Recursively find all class declarations in an OXC AST, including nested scopes. */\nexport function findAllClasses(program: any): any[] {\n const result: any[] = [];\n walkOxc(program, (node) => {\n if (node.type === 'ClassDeclaration') result.push(node);\n return true;\n });\n return result;\n}\n\n/**\n * Depth-first walk over OXC AST nodes. `visit` returns `false` to skip a\n * node's children.\n */\nexport function walkOxc(node: any, visit: (node: any) => boolean): void {\n if (Array.isArray(node)) {\n for (const child of node) walkOxc(child, visit);\n return;\n }\n if (!node || typeof node.type !== 'string' || !visit(node)) return;\n for (const key in node) {\n const value = node[key];\n if (value && typeof value === 'object') walkOxc(value, visit);\n }\n}\n\n/** Unwrap forwardRef(() => X) to X for OXC AST nodes. Returns the original node if not a forwardRef call. */\nexport function unwrapForwardRefOxc(node: any): any {\n if (\n node?.type === 'CallExpression' &&\n node.callee?.type === 'Identifier' &&\n node.callee.name === 'forwardRef'\n ) {\n const arg = node.arguments?.[0];\n if (arg?.type === 'ArrowFunctionExpression') {\n if (\n arg.body?.type === 'FunctionBody' ||\n arg.body?.type === 'BlockStatement'\n ) {\n const stmts = arg.body.statements || arg.body.body || [];\n const stmt = stmts[0];\n if (stmt?.type === 'ReturnStatement' && stmt.argument)\n return stmt.argument;\n } else {\n // Expression body: forwardRef(() => X)\n return arg.body;\n }\n }\n if (arg?.type === 'FunctionExpression') {\n const stmts = arg.body?.statements || arg.body?.body || [];\n if (stmts.length === 1) {\n const stmt = stmts[0];\n if (stmt?.type === 'ReturnStatement' && stmt.argument)\n return stmt.argument;\n }\n }\n }\n return node;\n}\n\n/**\n * Resolve the module specifier to use for a synthetic import of a registry\n * declaration referenced from `currentFileName`.\n *\n * Order of preference:\n * 1. `entry.sourcePackage` — external packages scanned from `.d.ts` resolve\n * via their package name (proper barrel exports).\n * 2. A relative path derived from `currentFileName` to `entry.fileName` — for\n * local workspace classes scanned from real source files. This is what\n * NgModule/tuple export expansion must use: the class lives in its own\n * file, not the module/barrel file that re-exports it, so importing from\n * the module specifier fails with\n * `\"X\" is not exported by \".../the.module.ts\"`.\n * 3. `fallbackSpecifier` — the import path of the module/tuple itself, used\n * for `.d.ts` entries (whose file path is not a usable import target) and\n * when the registry has no file location for the class.\n *\n * Returns `undefined` when the class is declared in `currentFileName` itself\n * (already in scope — no synthetic import needed).\n */\nexport function resolveSyntheticImportSpecifier(\n currentFileName: string,\n entry: { sourcePackage?: string; fileName?: string },\n fallbackSpecifier: string | undefined,\n): string | undefined {\n if (entry.sourcePackage) return entry.sourcePackage;\n // `.d.ts` entries come from scanning external package type declarations;\n // their file path is not a usable relative import target, so defer to the\n // module/tuple specifier the consumer already imports from.\n if (entry.fileName && !entry.fileName.endsWith('.d.ts')) {\n if (entry.fileName === currentFileName) return undefined;\n return deriveRelativeImportPath(currentFileName, entry.fileName);\n }\n return fallbackSpecifier;\n}\n\n/**\n * Derive a relative module specifier from `fromFile` to `toFile`, suitable for\n * a synthetic `import { … } from '…'` statement: strips the file extension,\n * normalizes to POSIX separators, and ensures an explicit `./` prefix.\n */\nexport function deriveRelativeImportPath(\n fromFile: string,\n toFile: string,\n): string {\n let rel = path.relative(path.dirname(fromFile), toFile);\n rel = rel.replace(/\\.[cm]?[jt]sx?$/, '');\n rel = rel.split(path.sep).join('/');\n if (!rel.startsWith('.')) rel = './' + rel;\n return rel;\n}\n\nexport { ANGULAR_DECORATORS } from './constants.js';\n"],"mappings":";;;;AAUA,IAAM,qBAAqB,EAAE,yBAAyB,KAAK;AAC3D,IAAI,iBAAiB,qBAAqB;;;;;;AAO1C,IAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAgB,SAAS,UAAkB,MAA2B;CAGpE,IAAI,CAAC,iBAAiB,MAAM,QAAQ,SAAS,SAAS,GAAG,CAAC,GACxD,YAAY;CAEd,IAAI,gBACF,IAAI;EACF,OAAO,UAAU,UAAU,MAAM,kBAAkB;CACrD,QAAQ;EACN,iBAAiB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mBACoB;CACpB,IAAI,MAAM,eAAe,OAAO,MAAM;CAItC,IAAI,MAAM,YAAY,CAAC,MAAM,SAAS,SAAS,OAAO,GAAG;EACvD,IAAI,MAAM,aAAa,iBAAiB,OAAO,KAAA;EAC/C,OAAO,yBAAyB,iBAAiB,MAAM,QAAQ;CACjE;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,yBACd,UACA,QACQ;CACR,IAAI,MAAMA,OAAK,SAASA,OAAK,QAAQ,QAAQ,GAAG,MAAM;CACtD,MAAM,IAAI,QAAQ,mBAAmB,EAAE;CACvC,MAAM,IAAI,MAAMA,OAAK,GAAG,CAAC,CAAC,KAAK,GAAG;CAClC,IAAI,CAAC,IAAI,WAAW,GAAG,GAAG,MAAM,OAAO;CACvC,OAAO;AACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JavaScriptTransformer } from "./utils/devkit.js";
|
|
2
|
-
|
|
2
|
+
// packages/vite-plugin-angular/src/lib/compiler-plugin.ts
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
5
5
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -50,7 +50,6 @@ function createRolldownCompilerPlugin(pluginOptions, isTest, closeTransformer, c
|
|
|
50
50
|
if (closeTransformer) plugin.buildEnd = () => javascriptTransformer?.close();
|
|
51
51
|
return plugin;
|
|
52
52
|
}
|
|
53
|
-
//#endregion
|
|
54
53
|
export { createCompilerPlugin, createRolldownCompilerPlugin };
|
|
55
54
|
|
|
56
55
|
//# sourceMappingURL=compiler-plugin.js.map
|
|
@@ -2,7 +2,7 @@ import { dirname, resolve } from "node:path";
|
|
|
2
2
|
import { normalizePath } from "vite";
|
|
3
3
|
import { parseSync } from "oxc-parser";
|
|
4
4
|
import { Visitor } from "rolldown/utils";
|
|
5
|
-
|
|
5
|
+
// packages/vite-plugin-angular/src/lib/component-resolvers.ts
|
|
6
6
|
/**
|
|
7
7
|
* Extracts a string value from an ESTree AST node.
|
|
8
8
|
*
|
|
@@ -106,7 +106,6 @@ var TemplateUrlsResolver = class {
|
|
|
106
106
|
return templateUrlPaths;
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
|
-
//#endregion
|
|
110
109
|
export { StyleUrlsResolver, TemplateUrlsResolver, getStyleUrls, getTemplateUrls };
|
|
111
110
|
|
|
112
111
|
//# sourceMappingURL=component-resolvers.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./compiler/index.js";
|
|
2
2
|
import { parseOxc } from "./compiler/utils.js";
|
|
3
3
|
import { scanFile } from "./compiler/registry.js";
|
|
4
4
|
import { collectAllImports, collectImportedPackages, collectReExports, scanPackageDts } from "./compiler/dts-reader.js";
|
|
5
|
-
import "./
|
|
5
|
+
import { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX } from "./utils/plugin-config.js";
|
|
6
6
|
import { promises } from "node:fs";
|
|
7
7
|
import { normalizePath } from "vite";
|
|
8
|
-
|
|
8
|
+
// packages/vite-plugin-angular/src/lib/component-scanner.ts
|
|
9
9
|
/**
|
|
10
10
|
* Angular classes scanned from source files and package `.d.ts` declarations,
|
|
11
11
|
* so source formats can look up the selectors of the components they import
|
|
@@ -172,7 +172,6 @@ var ComponentScanner = class {
|
|
|
172
172
|
return visited;
|
|
173
173
|
}
|
|
174
174
|
};
|
|
175
|
-
//#endregion
|
|
176
175
|
export { ComponentScanner };
|
|
177
176
|
|
|
178
177
|
//# sourceMappingURL=component-scanner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-scanner.js","names":[],"sources":["../../../src/lib/component-scanner.ts"],"sourcesContent":["import { promises as fsPromises } from 'node:fs';\nimport type { parseSync } from 'oxc-parser';\nimport { normalizePath } from 'vite';\n\nimport type { ComponentRegistryEntries } from './analog-plugin-interop.js';\nimport {\n collectAllImports,\n collectImportedPackages,\n collectReExports,\n scanFile,\n scanPackageDts,\n type ComponentRegistry,\n type RegistryEntry,\n} from './compiler/index.js';\nimport { parseOxc } from './compiler/utils.js';\nimport type {\n FastCompileResolve,\n FastCompileSourceFormat,\n} from './fast-compile-api.js';\nimport { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX } from './utils/plugin-config.js';\n\ntype OxcProgram = ReturnType<typeof parseSync>['program'];\n\n/** Resolves an import to a source file to scan, or `null` to skip it. */\nexport type ResolveImport = (\n spec: string,\n importer: string,\n) => Promise<string | null>;\n\n/**\n * Angular classes scanned from source files and package `.d.ts` declarations,\n * so source formats can look up the selectors of the components they import\n * before any compiler sees their modules. Shared by the fast compile and NGP\n * plugins.\n */\nexport class ComponentScanner {\n readonly registry: ComponentRegistry = new Map();\n readonly scannedDtsPackages: Set<string> = new Set();\n /** Files scanned on demand, mapped to the barrel chain each pulled in. */\n readonly lazyScans: Map<string, Promise<Set<string>>> = new Map();\n /** Modules compiled against each scanned file. */\n readonly importersByFile: Map<string, Set<string>> = new Map();\n private readonly sourceFormats: FastCompileSourceFormat[] = [];\n private root = '';\n\n /** Where package declarations are looked up from. */\n get projectRoot(): string {\n return this.root;\n }\n\n reset(projectRoot: string): void {\n this.root = projectRoot;\n this.registry.clear();\n this.scannedDtsPackages.clear();\n this.lazyScans.clear();\n this.importersByFile.clear();\n }\n\n registerSourceFormat(format: FastCompileSourceFormat): void {\n if (!this.sourceFormats.includes(format)) {\n this.sourceFormats.push(format);\n }\n }\n\n sourceFormatOf(file: string): FastCompileSourceFormat | undefined {\n const path = file.split('?')[0];\n return this.sourceFormats.find((format) => format.test(path));\n }\n\n /** Whether `file` is TypeScript or a module of a registered source format. */\n isCompiledSource(file: string): boolean {\n return TS_EXT_REGEX.test(file) || this.sourceFormatOf(file) !== undefined;\n }\n\n /**\n * Reads a source file for scanning. Modules of a registered source format\n * are converted to TypeScript first so the scanner sees their classes.\n */\n async readScanSource(file: string): Promise<string> {\n const code = await fsPromises.readFile(file, 'utf-8');\n const format = this.sourceFormatOf(file);\n return format ? format.toScanSource(code, file) : code;\n }\n\n /**\n * Adapts a Vite-style resolver to the scanner's: only source files this\n * scanner reads, outside `node_modules` (package declarations come from the\n * `.d.ts` scanner instead).\n */\n toResolveImport(resolve: FastCompileResolve): ResolveImport {\n return async (spec, importer) => {\n const resolved = await resolve(spec, importer);\n if (!resolved || resolved.external) return null;\n const file = normalizePath(resolved.id.split('?')[0]);\n return this.isCompiledSource(file) &&\n !EXCLUDED_TS_EXT_REGEX.test(file) &&\n !file.includes('/node_modules/')\n ? file\n : null;\n };\n }\n\n /** Scans the `.d.ts` declarations of `packages` into the registry, once each. */\n ensureDtsRegistryForPackages(packages: Iterable<string>): void {\n for (const pkg of packages) {\n if (this.scannedDtsPackages.has(pkg)) continue;\n this.scannedDtsPackages.add(pkg);\n try {\n const dtsEntries = scanPackageDts(\n pkg,\n // Before a tsconfig resolves, look up packages from the working directory.\n this.root || process.cwd(),\n this.scannedDtsPackages,\n );\n for (const entry of dtsEntries) {\n this.addEntry(entry);\n }\n } catch {\n // Package may not have .d.ts files or may not be Angular\n }\n }\n }\n\n ensureDtsRegistryForSource(\n code: string,\n id: string,\n program?: OxcProgram,\n ): void {\n this.ensureDtsRegistryForPackages(\n collectImportedPackages(code, id, program),\n );\n }\n\n /**\n * Scans the modules behind `specifiers`, imported by `importer`: packages\n * from their `.d.ts` declarations, everything else from source.\n */\n scanImports(\n specifiers: string[],\n importer: string,\n resolve: FastCompileResolve,\n ): Promise<void> {\n this.ensureDtsRegistryForPackages(\n specifiers\n .filter((spec) => !spec.startsWith('.') && !spec.startsWith('/'))\n .map((spec) => {\n const parts = spec.split('/');\n return spec.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];\n }),\n );\n return this.resolveImportSpecifiers(\n specifiers,\n importer,\n this.toResolveImport(resolve),\n );\n }\n\n /**\n * Scans the files behind `specs`, imported by `id`, into the registry and\n * records `id` as their importer.\n */\n async resolveImportSpecifiers(\n specs: string[],\n id: string,\n resolveImport: ResolveImport,\n ): Promise<void> {\n await Promise.all(\n specs.map(async (spec) => {\n const file = await resolveImport(spec, id);\n if (!file) return;\n for (const scanned of await this.scanOnDemand(file, resolveImport)) {\n let importers = this.importersByFile.get(scanned);\n if (!importers) {\n importers = new Set();\n this.importersByFile.set(scanned, importers);\n }\n importers.add(id);\n }\n }),\n );\n }\n\n /**\n * The element selector of a component or directive class. `external` are\n * registries contributed through `analog.setup()`.\n */\n lookupSelector(\n className: string,\n external: readonly ComponentRegistryEntries[] = [],\n ): string | null {\n const entry =\n this.registry.get(className) ??\n external.map((r) => r.get(className)).find((e) => e !== undefined);\n if (!entry || (entry.kind !== 'component' && entry.kind !== 'directive')) {\n return null;\n }\n return entry.selector;\n }\n\n /** The files scanned for `importer`. */\n dependenciesOf(importer: string): string[] {\n return [...this.importersByFile]\n .filter(([, importers]) => importers.has(importer))\n .map(([file]) => file);\n }\n\n entriesOf(file: string): RegistryEntry[] {\n return [...this.registry.values()].filter((e) => e.fileName === file);\n }\n\n /** Drops what was scanned from `file`, so the next scan reads it again. */\n invalidate(file: string): void {\n for (const entry of this.entriesOf(file)) {\n this.registry.delete(entry.className);\n }\n this.lazyScans.clear();\n }\n\n private addEntry(entry: RegistryEntry): void {\n if (!this.registry.has(entry.className)) {\n this.registry.set(entry.className, entry);\n }\n }\n\n private scanOnDemand(\n file: string,\n resolveImport: ResolveImport,\n ): Promise<Set<string>> {\n let scan = this.lazyScans.get(file);\n if (!scan) {\n scan = this.scanWithReExports(file, resolveImport);\n this.lazyScans.set(file, scan);\n }\n return scan;\n }\n\n /**\n * Scan a file and everything it re-exports, resolving specifiers through\n * Vite so path aliases work. Tuple barrels and NgModules can list classes\n * their file imports without re-exporting, so their imports are followed\n * too. Returns every file scanned.\n */\n private async scanWithReExports(\n file: string,\n resolveImport: ResolveImport,\n ): Promise<Set<string>> {\n const visited = new Set<string>();\n const visit = async (current: string): Promise<void> => {\n if (visited.has(current)) return;\n visited.add(current);\n let code: string;\n let program: OxcProgram;\n try {\n code = await this.readScanSource(current);\n program = parseOxc(current, code).program;\n } catch {\n return;\n }\n const entries = scanFile(code, current, program);\n for (const entry of entries) {\n this.addEntry(entry);\n }\n this.ensureDtsRegistryForSource(code, current, program);\n const followsImports = entries.some(\n (e) => e.kind === 'tuple' || e.kind === 'ngmodule',\n );\n const specifiers = followsImports\n ? collectAllImports(code, current, program)\n : collectReExports(code, current, program);\n for (const spec of specifiers) {\n const dep = await resolveImport(spec, current);\n if (dep) await visit(dep);\n }\n };\n await visit(file);\n return visited;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAmCA,IAAa,mBAAb,MAA8B;CAC5B,2BAAuC,IAAI,IAAI;CAC/C,qCAA2C,IAAI,IAAI;;CAEnD,4BAAwD,IAAI,IAAI;;CAEhE,kCAAqD,IAAI,IAAI;CAC7D,gBAA4D,CAAC;CAC7D,OAAe;;CAGf,IAAI,cAAsB;EACxB,OAAO,KAAK;CACd;CAEA,MAAM,aAA2B;EAC/B,KAAK,OAAO;EACZ,KAAK,SAAS,MAAM;EACpB,KAAK,mBAAmB,MAAM;EAC9B,KAAK,UAAU,MAAM;EACrB,KAAK,gBAAgB,MAAM;CAC7B;CAEA,qBAAqB,QAAuC;EAC1D,IAAI,CAAC,KAAK,cAAc,SAAS,MAAM,GACrC,KAAK,cAAc,KAAK,MAAM;CAElC;CAEA,eAAe,MAAmD;EAChE,MAAM,OAAO,KAAK,MAAM,GAAG,CAAC,CAAC;EAC7B,OAAO,KAAK,cAAc,MAAM,WAAW,OAAO,KAAK,IAAI,CAAC;CAC9D;;CAGA,iBAAiB,MAAuB;EACtC,OAAO,aAAa,KAAK,IAAI,KAAK,KAAK,eAAe,IAAI,MAAM,KAAA;CAClE;;;;;CAMA,MAAM,eAAe,MAA+B;EAClD,MAAM,OAAO,MAAM,SAAW,SAAS,MAAM,OAAO;EACpD,MAAM,SAAS,KAAK,eAAe,IAAI;EACvC,OAAO,SAAS,OAAO,aAAa,MAAM,IAAI,IAAI;CACpD;;;;;;CAOA,gBAAgB,SAA4C;EAC1D,OAAO,OAAO,MAAM,aAAa;GAC/B,MA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OAAO,YAAmC;GACtD,IAAI,QAAQ,IAAI,OAAO,GAAG;GAC1B,QAAQ,IAAI,OAAO;GACnB,IAAI;GACJ,IAAI;GACJ,IAAI;IACF,OAAO,MAAM,KAAK,eAAe,OAAO;IACxC,UAAU,SAAS,SAAS,IAAI,CAAC,CAAC;GACpC,QAAQ;IACN;GACF;GACA,MAAM,UAAU,SAAS,MAAM,SAAS,OAAO;GAC/C,KAAK,MAAM,SAAS,SAClB,KAAK,SAAS,KAAK;GAErB,KAAK,2BAA2B,MAAM,SAAS,OAAO;GAItD,MAAM,aAHiB,QAAQ,MAC5B,MAAM,EAAE,SAAS,WAAW,EAAE,SAAS,UAEvB,IACf,kBAAkB,MAAM,SAAS,OAAO,IACxC,iBAAiB,MAAM,SAAS,OAAO;GAC3C,KAAK,MAAM,QAAQ,YAAY;IAC7B,MAAM,MAAM,MAAM,cAAc,MAAM,OAAO;IAC7C,IAAI,KAAK,MAAM,MAAM,GAAG;GAC1B;EACF;EACA,MAAM,MAAM,IAAI;EAChB,OAAO;CACT;AACF"}
|
|
1
|
+
{"version":3,"file":"component-scanner.js","names":["fsPromises"],"sources":["../../../src/lib/component-scanner.ts"],"sourcesContent":["import { promises as fsPromises } from 'node:fs';\nimport type { parseSync } from 'oxc-parser';\nimport { normalizePath } from 'vite';\n\nimport type { ComponentRegistryEntries } from './analog-plugin-interop.js';\nimport {\n collectAllImports,\n collectImportedPackages,\n collectReExports,\n scanFile,\n scanPackageDts,\n type ComponentRegistry,\n type RegistryEntry,\n} from './compiler/index.js';\nimport { parseOxc } from './compiler/utils.js';\nimport type {\n FastCompileResolve,\n FastCompileSourceFormat,\n} from './fast-compile-api.js';\nimport { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX } from './utils/plugin-config.js';\n\ntype OxcProgram = ReturnType<typeof parseSync>['program'];\n\n/** Resolves an import to a source file to scan, or `null` to skip it. */\nexport type ResolveImport = (\n spec: string,\n importer: string,\n) => Promise<string | null>;\n\n/**\n * Angular classes scanned from source files and package `.d.ts` declarations,\n * so source formats can look up the selectors of the components they import\n * before any compiler sees their modules. Shared by the fast compile and NGP\n * plugins.\n */\nexport class ComponentScanner {\n readonly registry: ComponentRegistry = new Map();\n readonly scannedDtsPackages: Set<string> = new Set();\n /** Files scanned on demand, mapped to the barrel chain each pulled in. */\n readonly lazyScans: Map<string, Promise<Set<string>>> = new Map();\n /** Modules compiled against each scanned file. */\n readonly importersByFile: Map<string, Set<string>> = new Map();\n private readonly sourceFormats: FastCompileSourceFormat[] = [];\n private root = '';\n\n /** Where package declarations are looked up from. */\n get projectRoot(): string {\n return this.root;\n }\n\n reset(projectRoot: string): void {\n this.root = projectRoot;\n this.registry.clear();\n this.scannedDtsPackages.clear();\n this.lazyScans.clear();\n this.importersByFile.clear();\n }\n\n registerSourceFormat(format: FastCompileSourceFormat): void {\n if (!this.sourceFormats.includes(format)) {\n this.sourceFormats.push(format);\n }\n }\n\n sourceFormatOf(file: string): FastCompileSourceFormat | undefined {\n const path = file.split('?')[0];\n return this.sourceFormats.find((format) => format.test(path));\n }\n\n /** Whether `file` is TypeScript or a module of a registered source format. */\n isCompiledSource(file: string): boolean {\n return TS_EXT_REGEX.test(file) || this.sourceFormatOf(file) !== undefined;\n }\n\n /**\n * Reads a source file for scanning. Modules of a registered source format\n * are converted to TypeScript first so the scanner sees their classes.\n */\n async readScanSource(file: string): Promise<string> {\n const code = await fsPromises.readFile(file, 'utf-8');\n const format = this.sourceFormatOf(file);\n return format ? format.toScanSource(code, file) : code;\n }\n\n /**\n * Adapts a Vite-style resolver to the scanner's: only source files this\n * scanner reads, outside `node_modules` (package declarations come from the\n * `.d.ts` scanner instead).\n */\n toResolveImport(resolve: FastCompileResolve): ResolveImport {\n return async (spec, importer) => {\n const resolved = await resolve(spec, importer);\n if (!resolved || resolved.external) return null;\n const file = normalizePath(resolved.id.split('?')[0]);\n return this.isCompiledSource(file) &&\n !EXCLUDED_TS_EXT_REGEX.test(file) &&\n !file.includes('/node_modules/')\n ? file\n : null;\n };\n }\n\n /** Scans the `.d.ts` declarations of `packages` into the registry, once each. */\n ensureDtsRegistryForPackages(packages: Iterable<string>): void {\n for (const pkg of packages) {\n if (this.scannedDtsPackages.has(pkg)) continue;\n this.scannedDtsPackages.add(pkg);\n try {\n const dtsEntries = scanPackageDts(\n pkg,\n // Before a tsconfig resolves, look up packages from the working directory.\n this.root || process.cwd(),\n this.scannedDtsPackages,\n );\n for (const entry of dtsEntries) {\n this.addEntry(entry);\n }\n } catch {\n // Package may not have .d.ts files or may not be Angular\n }\n }\n }\n\n ensureDtsRegistryForSource(\n code: string,\n id: string,\n program?: OxcProgram,\n ): void {\n this.ensureDtsRegistryForPackages(\n collectImportedPackages(code, id, program),\n );\n }\n\n /**\n * Scans the modules behind `specifiers`, imported by `importer`: packages\n * from their `.d.ts` declarations, everything else from source.\n */\n scanImports(\n specifiers: string[],\n importer: string,\n resolve: FastCompileResolve,\n ): Promise<void> {\n this.ensureDtsRegistryForPackages(\n specifiers\n .filter((spec) => !spec.startsWith('.') && !spec.startsWith('/'))\n .map((spec) => {\n const parts = spec.split('/');\n return spec.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];\n }),\n );\n return this.resolveImportSpecifiers(\n specifiers,\n importer,\n this.toResolveImport(resolve),\n );\n }\n\n /**\n * Scans the files behind `specs`, imported by `id`, into the registry and\n * records `id` as their importer.\n */\n async resolveImportSpecifiers(\n specs: string[],\n id: string,\n resolveImport: ResolveImport,\n ): Promise<void> {\n await Promise.all(\n specs.map(async (spec) => {\n const file = await resolveImport(spec, id);\n if (!file) return;\n for (const scanned of await this.scanOnDemand(file, resolveImport)) {\n let importers = this.importersByFile.get(scanned);\n if (!importers) {\n importers = new Set();\n this.importersByFile.set(scanned, importers);\n }\n importers.add(id);\n }\n }),\n );\n }\n\n /**\n * The element selector of a component or directive class. `external` are\n * registries contributed through `analog.setup()`.\n */\n lookupSelector(\n className: string,\n external: readonly ComponentRegistryEntries[] = [],\n ): string | null {\n const entry =\n this.registry.get(className) ??\n external.map((r) => r.get(className)).find((e) => e !== undefined);\n if (!entry || (entry.kind !== 'component' && entry.kind !== 'directive')) {\n return null;\n }\n return entry.selector;\n }\n\n /** The files scanned for `importer`. */\n dependenciesOf(importer: string): string[] {\n return [...this.importersByFile]\n .filter(([, importers]) => importers.has(importer))\n .map(([file]) => file);\n }\n\n entriesOf(file: string): RegistryEntry[] {\n return [...this.registry.values()].filter((e) => e.fileName === file);\n }\n\n /** Drops what was scanned from `file`, so the next scan reads it again. */\n invalidate(file: string): void {\n for (const entry of this.entriesOf(file)) {\n this.registry.delete(entry.className);\n }\n this.lazyScans.clear();\n }\n\n private addEntry(entry: RegistryEntry): void {\n if (!this.registry.has(entry.className)) {\n this.registry.set(entry.className, entry);\n }\n }\n\n private scanOnDemand(\n file: string,\n resolveImport: ResolveImport,\n ): Promise<Set<string>> {\n let scan = this.lazyScans.get(file);\n if (!scan) {\n scan = this.scanWithReExports(file, resolveImport);\n this.lazyScans.set(file, scan);\n }\n return scan;\n }\n\n /**\n * Scan a file and everything it re-exports, resolving specifiers through\n * Vite so path aliases work. Tuple barrels and NgModules can list classes\n * their file imports without re-exporting, so their imports are followed\n * too. Returns every file scanned.\n */\n private async scanWithReExports(\n file: string,\n resolveImport: ResolveImport,\n ): Promise<Set<string>> {\n const visited = new Set<string>();\n const visit = async (current: string): Promise<void> => {\n if (visited.has(current)) return;\n visited.add(current);\n let code: string;\n let program: OxcProgram;\n try {\n code = await this.readScanSource(current);\n program = parseOxc(current, code).program;\n } catch {\n return;\n }\n const entries = scanFile(code, current, program);\n for (const entry of entries) {\n this.addEntry(entry);\n }\n this.ensureDtsRegistryForSource(code, current, program);\n const followsImports = entries.some(\n (e) => e.kind === 'tuple' || e.kind === 'ngmodule',\n );\n const specifiers = followsImports\n ? collectAllImports(code, current, program)\n : collectReExports(code, current, program);\n for (const spec of specifiers) {\n const dep = await resolveImport(spec, current);\n if (dep) await visit(dep);\n }\n };\n await visit(file);\n return visited;\n }\n}\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