@analogjs/vite-plugin-angular 2.5.0-beta.9 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +24 -0
  2. package/package.json +23 -5
  3. package/src/lib/angular-vite-plugin.d.ts +12 -1
  4. package/src/lib/angular-vite-plugin.js +102 -300
  5. package/src/lib/angular-vite-plugin.js.map +1 -1
  6. package/src/lib/angular-vitest-plugin.js +2 -2
  7. package/src/lib/angular-vitest-plugin.js.map +1 -1
  8. package/src/lib/compiler/angular-version.d.ts +19 -0
  9. package/src/lib/compiler/angular-version.js +42 -0
  10. package/src/lib/compiler/angular-version.js.map +1 -0
  11. package/src/lib/compiler/class-field-lowering.d.ts +23 -0
  12. package/src/lib/compiler/class-field-lowering.js +213 -0
  13. package/src/lib/compiler/class-field-lowering.js.map +1 -0
  14. package/src/lib/compiler/compile.d.ts +44 -0
  15. package/src/lib/compiler/compile.js +1160 -0
  16. package/src/lib/compiler/compile.js.map +1 -0
  17. package/src/lib/compiler/constants.d.ts +18 -0
  18. package/src/lib/compiler/constants.js +48 -0
  19. package/src/lib/compiler/constants.js.map +1 -0
  20. package/src/lib/compiler/debug.d.ts +22 -0
  21. package/src/lib/compiler/debug.js +35 -0
  22. package/src/lib/compiler/debug.js.map +1 -0
  23. package/src/lib/compiler/defer.d.ts +47 -0
  24. package/src/lib/compiler/defer.js +203 -0
  25. package/src/lib/compiler/defer.js.map +1 -0
  26. package/src/lib/compiler/dts-reader.d.ts +35 -0
  27. package/src/lib/compiler/dts-reader.js +526 -0
  28. package/src/lib/compiler/dts-reader.js.map +1 -0
  29. package/src/lib/compiler/hmr.d.ts +16 -0
  30. package/src/lib/compiler/hmr.js +80 -0
  31. package/src/lib/compiler/hmr.js.map +1 -0
  32. package/src/lib/compiler/index.d.ts +7 -0
  33. package/src/lib/compiler/index.js +8 -0
  34. package/src/lib/compiler/index.js.map +1 -0
  35. package/src/lib/compiler/jit-metadata.d.ts +14 -0
  36. package/src/lib/compiler/jit-metadata.js +224 -0
  37. package/src/lib/compiler/jit-metadata.js.map +1 -0
  38. package/src/lib/compiler/jit-transform.d.ts +24 -0
  39. package/src/lib/compiler/jit-transform.js +269 -0
  40. package/src/lib/compiler/jit-transform.js.map +1 -0
  41. package/src/lib/compiler/js-emitter.d.ts +10 -0
  42. package/src/lib/compiler/js-emitter.js +502 -0
  43. package/src/lib/compiler/js-emitter.js.map +1 -0
  44. package/src/lib/compiler/metadata.d.ts +57 -0
  45. package/src/lib/compiler/metadata.js +894 -0
  46. package/src/lib/compiler/metadata.js.map +1 -0
  47. package/src/lib/compiler/registry.d.ts +49 -0
  48. package/src/lib/compiler/registry.js +273 -0
  49. package/src/lib/compiler/registry.js.map +1 -0
  50. package/src/lib/compiler/resource-inliner.d.ts +21 -0
  51. package/src/lib/compiler/resource-inliner.js +200 -0
  52. package/src/lib/compiler/resource-inliner.js.map +1 -0
  53. package/src/lib/compiler/style-ast.d.ts +8 -0
  54. package/src/lib/compiler/style-ast.js +110 -0
  55. package/src/lib/compiler/style-ast.js.map +1 -0
  56. package/src/lib/compiler/styles.d.ts +13 -0
  57. package/src/lib/compiler/styles.js +60 -0
  58. package/src/lib/compiler/styles.js.map +1 -0
  59. package/src/lib/compiler/test-helpers.d.ts +7 -0
  60. package/src/lib/compiler/test-helpers.js +28 -0
  61. package/src/lib/compiler/test-helpers.js.map +1 -0
  62. package/src/lib/compiler/type-elision.d.ts +26 -0
  63. package/src/lib/compiler/type-elision.js +313 -0
  64. package/src/lib/compiler/type-elision.js.map +1 -0
  65. package/src/lib/compiler/utils.d.ts +10 -0
  66. package/src/lib/compiler/utils.js +95 -0
  67. package/src/lib/compiler/utils.js.map +1 -0
  68. package/src/lib/fast-compile-plugin.d.ts +28 -0
  69. package/src/lib/fast-compile-plugin.js +404 -0
  70. package/src/lib/fast-compile-plugin.js.map +1 -0
  71. package/src/lib/utils/plugin-config.d.ts +45 -0
  72. package/src/lib/utils/plugin-config.js +89 -0
  73. package/src/lib/utils/plugin-config.js.map +1 -0
  74. package/src/lib/utils/safe-module-paths.d.ts +16 -0
  75. package/src/lib/utils/safe-module-paths.js +26 -0
  76. package/src/lib/utils/safe-module-paths.js.map +1 -0
  77. package/src/lib/utils/virtual-ids.d.ts +4 -0
  78. package/src/lib/utils/virtual-ids.js +30 -0
  79. package/src/lib/utils/virtual-ids.js.map +1 -0
  80. package/src/lib/utils/virtual-resources.d.ts +19 -0
  81. package/src/lib/utils/virtual-resources.js +47 -0
  82. package/src/lib/utils/virtual-resources.js.map +1 -0
@@ -0,0 +1,526 @@
1
+ import { parseSync } from 'oxc-parser';
2
+ import * as fs from 'node:fs';
3
+ import * as path from 'node:path';
4
+ /**
5
+ * Scan a single .d.ts file and extract Angular directive/component/pipe
6
+ * metadata from the static ɵdir / ɵcmp / ɵpipe type declarations.
7
+ *
8
+ * This mirrors what ngtsc's DtsMetadataReader does: it reads the type
9
+ * parameters of ɵɵDirectiveDeclaration / ɵɵComponentDeclaration /
10
+ * ɵɵPipeDeclaration to discover selectors, inputs, and outputs for
11
+ * pre-compiled Angular packages.
12
+ */
13
+ export function scanDtsFile(code, fileName) {
14
+ // Fast pre-filter — skip files that can't contain Angular declarations
15
+ if (!code.includes('DirectiveDeclaration') &&
16
+ !code.includes('ComponentDeclaration') &&
17
+ !code.includes('PipeDeclaration') &&
18
+ !code.includes('NgModuleDeclaration'))
19
+ return [];
20
+ const { program } = parseSync(fileName, code);
21
+ const entries = [];
22
+ visitStatements(program.body, fileName, entries);
23
+ return entries;
24
+ }
25
+ /**
26
+ * Resolve a package's directory in node_modules, scan all its .d.ts files,
27
+ * and return RegistryEntry[] for every Angular declaration found.
28
+ *
29
+ * @param packageName e.g. "@angular/router"
30
+ * @param basePath project root (where node_modules lives)
31
+ */
32
+ export function scanPackageDts(packageName, basePath) {
33
+ // Walk up from basePath to find the nearest node_modules containing the package.
34
+ // This handles monorepos where node_modules is at the workspace root,
35
+ // not in the project subdirectory.
36
+ let pkgDir = '';
37
+ let searchBase = basePath;
38
+ while (searchBase !== path.dirname(searchBase)) {
39
+ const candidate = path.join(searchBase, 'node_modules', packageName);
40
+ if (fs.existsSync(candidate)) {
41
+ pkgDir = candidate;
42
+ break;
43
+ }
44
+ searchBase = path.dirname(searchBase);
45
+ }
46
+ if (!pkgDir)
47
+ return [];
48
+ // Build a map from className → correct import path using package.json exports.
49
+ // This handles packages with sub-entry points (e.g. @angular/material/tabs)
50
+ // where re-exported classes must be imported from their origin entry point.
51
+ const classToImportPath = buildClassToImportMap(packageName, pkgDir);
52
+ // Check for a "types" directory first (Angular packages use this),
53
+ // then fall back to the package root.
54
+ const typesDir = path.join(pkgDir, 'types');
55
+ const searchDir = fs.existsSync(typesDir) ? typesDir : pkgDir;
56
+ const dtsFiles = collectDtsFiles(searchDir);
57
+ const entries = [];
58
+ for (const file of dtsFiles) {
59
+ try {
60
+ const code = fs.readFileSync(file, 'utf-8');
61
+ const fileEntries = scanDtsFile(code, file);
62
+ for (const entry of fileEntries) {
63
+ entry.sourcePackage =
64
+ classToImportPath.get(entry.className) ||
65
+ subEntryFromFilePath(packageName, pkgDir, file) ||
66
+ packageName;
67
+ }
68
+ entries.push(...fileEntries);
69
+ }
70
+ catch {
71
+ // Skip unreadable files
72
+ }
73
+ }
74
+ return entries;
75
+ }
76
+ /**
77
+ * Read package.json exports to build a map from class name to the correct
78
+ * sub-entry import path (e.g. "MatTabNav" → "@angular/material/tabs").
79
+ *
80
+ * For each sub-entry that has a "types" field, the corresponding .d.ts file
81
+ * is read to collect declared class names and re-exported names.
82
+ */
83
+ function buildClassToImportMap(packageName, pkgDir) {
84
+ const map = new Map();
85
+ try {
86
+ const pkgJson = JSON.parse(fs.readFileSync(path.join(pkgDir, 'package.json'), 'utf-8'));
87
+ if (!pkgJson.exports)
88
+ return map;
89
+ for (const [key, value] of Object.entries(pkgJson.exports)) {
90
+ if (key !== '.' && !key.startsWith('./'))
91
+ continue;
92
+ // Resolve types from the export entry. Some packages declare
93
+ // `types` only at the package root (top-level package.json `types`
94
+ // field) rather than per-export, so fall back to that for `.`.
95
+ let typesFile = typeof value === 'object' && value !== null && value.types;
96
+ if (!typesFile && key === '.' && typeof pkgJson.types === 'string') {
97
+ typesFile = pkgJson.types;
98
+ }
99
+ if (!typesFile)
100
+ continue;
101
+ // Root entry (`.`) maps classes to the bare package name; sub-entries
102
+ // (`./tabs`) map to `${packageName}/tabs`. Mapping root-exported
103
+ // classes prevents `subEntryFromFilePath` from deriving an invalid
104
+ // subpath like `ngx-scrollbar/lib` for files that physically live in
105
+ // a `lib/` subdirectory but are only re-exported from the root entry.
106
+ const importPath = key === '.' ? packageName : packageName + '/' + key.slice(2);
107
+ const fullTypesPath = path.resolve(pkgDir, typesFile);
108
+ if (!fs.existsSync(fullTypesPath))
109
+ continue;
110
+ collectExportedClassesFromDts(fullTypesPath, importPath, map);
111
+ }
112
+ }
113
+ catch {
114
+ // No package.json or no exports — fall back to packageName
115
+ }
116
+ return map;
117
+ }
118
+ /**
119
+ * Read a `.d.ts` entry file and add every class it exports to `map`,
120
+ * following `export * from './rel'` chains so re-exported classes from
121
+ * physically nested files (e.g. `lib/foo.d.ts`) are still mapped to the
122
+ * exporting entry's import path.
123
+ *
124
+ * Without this, packages whose root `index.d.ts` is just a barrel of
125
+ * `export * from './lib/...'` would never get their classes mapped, and the
126
+ * `subEntryFromFilePath` fallback would derive an invalid `${pkg}/lib`
127
+ * import for files living under `lib/`.
128
+ */
129
+ function collectExportedClassesFromDts(filePath, importPath, map, visited = new Set()) {
130
+ if (visited.has(filePath))
131
+ return;
132
+ visited.add(filePath);
133
+ let code;
134
+ try {
135
+ code = fs.readFileSync(filePath, 'utf-8');
136
+ }
137
+ catch {
138
+ return;
139
+ }
140
+ let program;
141
+ try {
142
+ program = parseSync(filePath, code).program;
143
+ }
144
+ catch {
145
+ return;
146
+ }
147
+ const dir = path.dirname(filePath);
148
+ for (const stmt of program.body || []) {
149
+ // `declare class Foo` (top-level)
150
+ if (stmt.type === 'ClassDeclaration' && stmt.id?.name) {
151
+ map.set(stmt.id.name, importPath);
152
+ continue;
153
+ }
154
+ // `export declare class Foo` / `export class Foo` /
155
+ // `export { A, B as C } from '...'` / `export { A, B }`
156
+ if (stmt.type === 'ExportNamedDeclaration') {
157
+ if (stmt.declaration?.type === 'ClassDeclaration' &&
158
+ stmt.declaration.id?.name) {
159
+ map.set(stmt.declaration.id.name, importPath);
160
+ }
161
+ for (const spec of stmt.specifiers || []) {
162
+ // ExportSpecifier: { local, exported }
163
+ const exportedNode = spec.exported;
164
+ const exportedName = exportedNode?.type === 'Identifier'
165
+ ? exportedNode.name
166
+ : exportedNode?.type === 'Literal'
167
+ ? exportedNode.value
168
+ : undefined;
169
+ if (typeof exportedName === 'string') {
170
+ map.set(exportedName, importPath);
171
+ }
172
+ }
173
+ continue;
174
+ }
175
+ // `export * from './rel'` and `export * as Ns from './rel'`
176
+ if (stmt.type === 'ExportAllDeclaration') {
177
+ const rel = stmt.source?.value;
178
+ if (!rel || !rel.startsWith('.'))
179
+ continue;
180
+ // TypeScript preserves the original specifier text in emitted
181
+ // `.d.ts` files, so NodeNext-style packages keep their `.js`
182
+ // (or `.mjs`) extensions in re-exports — but the actual
183
+ // declaration is at `foo.d.ts` / `foo/index.d.ts`. Strip the
184
+ // ESM extension before probing.
185
+ const normalizedRel = rel.replace(/\.(?:js|mjs)$/u, '');
186
+ const candidates = [
187
+ path.resolve(dir, normalizedRel + '.d.ts'),
188
+ path.resolve(dir, normalizedRel, 'index.d.ts'),
189
+ ];
190
+ for (const candidate of candidates) {
191
+ if (fs.existsSync(candidate)) {
192
+ collectExportedClassesFromDts(candidate, importPath, map, visited);
193
+ break;
194
+ }
195
+ }
196
+ continue;
197
+ }
198
+ }
199
+ }
200
+ /**
201
+ * Derive a sub-entry import path from a .d.ts file's location relative to the
202
+ * package root. This handles older Angular packages that keep .d.ts files in
203
+ * subdirectories (e.g. `@angular/material/tabs/index.d.ts`) instead of a
204
+ * top-level `types/` folder.
205
+ *
206
+ * Returns `undefined` when no sub-entry can be determined (e.g. file is at the
207
+ * package root, inside `types/`, or in a non-entry directory).
208
+ */
209
+ function subEntryFromFilePath(packageName, pkgDir, filePath) {
210
+ const NON_ENTRY_DIRS = new Set([
211
+ 'types',
212
+ 'fesm2022',
213
+ 'fesm2020',
214
+ 'fesm2015',
215
+ 'esm2022',
216
+ 'esm2020',
217
+ 'esm2015',
218
+ 'bundles',
219
+ 'schematics',
220
+ 'node_modules',
221
+ ]);
222
+ const rel = path.relative(pkgDir, filePath);
223
+ const segments = rel.split(path.sep);
224
+ // File directly in pkgDir (no subdirectory) → no sub-entry
225
+ if (segments.length < 2)
226
+ return undefined;
227
+ const firstDir = segments[0];
228
+ // Skip internal/build directories and chunk files
229
+ if (NON_ENTRY_DIRS.has(firstDir) || firstDir.startsWith('_'))
230
+ return undefined;
231
+ return packageName + '/' + firstDir;
232
+ }
233
+ /**
234
+ * Parse a source file with OXC and return the set of bare-specifier package
235
+ * names it imports (e.g. "@angular/router", "rxjs"). Relative imports are
236
+ * skipped.
237
+ */
238
+ export function collectImportedPackages(code, fileName) {
239
+ const packages = new Set();
240
+ const { program } = parseSync(fileName, code);
241
+ for (const stmt of program.body) {
242
+ if (stmt.type !== 'ImportDeclaration')
243
+ continue;
244
+ const specifier = stmt.source?.value;
245
+ if (!specifier || specifier.startsWith('.'))
246
+ continue;
247
+ const parts = specifier.split('/');
248
+ packages.add(specifier.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0]);
249
+ }
250
+ return packages;
251
+ }
252
+ /**
253
+ * Parse a source file with OXC and return the relative-path specifiers it
254
+ * re-exports via `export * from './x'`, `export * as Ns from './x'`, or
255
+ * `export { … } from './x'`. Bare-specifier re-exports are skipped.
256
+ *
257
+ * Used by the analog Vite plugin to walk library entry barrels at startup
258
+ * (e.g. `helm/select/src/index.ts` → `./lib/hlm-select`) so the underlying
259
+ * directive classes land in the registry before any consumer is compiled.
260
+ */
261
+ export function collectRelativeReExports(code, fileName) {
262
+ let program;
263
+ try {
264
+ program = parseSync(fileName, code).program;
265
+ }
266
+ catch {
267
+ return [];
268
+ }
269
+ const result = [];
270
+ for (const stmt of program.body || []) {
271
+ if (stmt.type !== 'ExportAllDeclaration' &&
272
+ stmt.type !== 'ExportNamedDeclaration') {
273
+ continue;
274
+ }
275
+ // ExportNamedDeclaration without `source` is `export { x }` (no
276
+ // re-export), which we don't care about here.
277
+ const specifier = stmt.source?.value;
278
+ if (!specifier || !specifier.startsWith('.'))
279
+ continue;
280
+ result.push(specifier);
281
+ }
282
+ return result;
283
+ }
284
+ // ---------------------------------------------------------------------------
285
+ // Internal helpers
286
+ // ---------------------------------------------------------------------------
287
+ function visitStatements(stmts, fileName, entries) {
288
+ for (const stmt of stmts) {
289
+ // Unwrap exports: `export declare class ...` / `export default class ...`
290
+ const decl = stmt.type === 'ExportNamedDeclaration' ||
291
+ stmt.type === 'ExportDefaultDeclaration'
292
+ ? stmt.declaration
293
+ : stmt;
294
+ if (!decl)
295
+ continue;
296
+ // Recurse into `declare module "..." { ... }` blocks
297
+ if (decl.type === 'TSModuleDeclaration' && decl.body?.body) {
298
+ visitStatements(decl.body.body, fileName, entries);
299
+ continue;
300
+ }
301
+ if (decl.type !== 'ClassDeclaration' || !decl.id?.name)
302
+ continue;
303
+ const className = decl.id.name;
304
+ const members = decl.body?.body || [];
305
+ for (const member of members) {
306
+ if (member.type !== 'PropertyDefinition' || !member.static)
307
+ continue;
308
+ const propName = member.key?.name;
309
+ // Read the type annotation: e.g. `i0.ɵɵDirectiveDeclaration<...>`
310
+ const typeRef = member.typeAnnotation?.typeAnnotation;
311
+ if (!typeRef || typeRef.type !== 'TSTypeReference')
312
+ continue;
313
+ const typeName = qualifiedName(typeRef.typeName);
314
+ const typeParams = typeRef.typeArguments?.params;
315
+ if ((propName === 'ɵdir' || propName === 'ɵcmp') &&
316
+ (typeName.includes('DirectiveDeclaration') ||
317
+ typeName.includes('ComponentDeclaration')) &&
318
+ typeParams &&
319
+ typeParams.length >= 5) {
320
+ const selector = literalString(typeParams[1]);
321
+ if (!selector)
322
+ continue;
323
+ const inputs = extractInputs(typeParams[3]);
324
+ const outputs = extractOutputs(typeParams[4]);
325
+ entries.push({
326
+ selector: selector.split(',')[0].trim(),
327
+ kind: propName === 'ɵcmp' ? 'component' : 'directive',
328
+ fileName,
329
+ className,
330
+ ...(Object.keys(inputs).length > 0 ? { inputs } : {}),
331
+ ...(Object.keys(outputs).length > 0 ? { outputs } : {}),
332
+ });
333
+ }
334
+ else if (propName === 'ɵpipe' &&
335
+ typeName.includes('PipeDeclaration') &&
336
+ typeParams &&
337
+ typeParams.length >= 2) {
338
+ const pipeName = literalString(typeParams[1]);
339
+ if (!pipeName)
340
+ continue;
341
+ entries.push({
342
+ selector: pipeName,
343
+ kind: 'pipe',
344
+ pipeName,
345
+ fileName,
346
+ className,
347
+ });
348
+ }
349
+ else if (propName === 'ɵmod' &&
350
+ typeName.includes('NgModuleDeclaration') &&
351
+ typeParams &&
352
+ typeParams.length >= 4) {
353
+ // ɵɵNgModuleDeclaration<Module, Declarations, Imports, Exports>
354
+ // Extract exported class names from the 4th type param (index 3).
355
+ const exportsParam = typeParams[3];
356
+ const exportedNames = [];
357
+ if (exportsParam?.type === 'TSTupleType' && exportsParam.elementTypes) {
358
+ for (const el of exportsParam.elementTypes) {
359
+ if (el.type === 'TSTypeQuery' &&
360
+ el.exprName?.type === 'Identifier') {
361
+ exportedNames.push(el.exprName.name);
362
+ }
363
+ else if (el.type === 'TSTypeQuery' &&
364
+ el.exprName?.type === 'TSQualifiedName') {
365
+ // e.g. typeof i2.BidiModule → extract "BidiModule"
366
+ const right = el.exprName.right;
367
+ if (right?.type === 'Identifier') {
368
+ exportedNames.push(right.name);
369
+ }
370
+ }
371
+ }
372
+ }
373
+ entries.push({
374
+ selector: className,
375
+ kind: 'ngmodule',
376
+ exports: exportedNames,
377
+ fileName,
378
+ className,
379
+ });
380
+ }
381
+ }
382
+ }
383
+ }
384
+ /**
385
+ * Extract inputs from the type-argument at position [3].
386
+ *
387
+ * Handles two formats:
388
+ * v16+: { "prop": { "alias": "binding"; "required": false; "isSignal"?: true } }
389
+ * pre-v16: { "prop": "binding" }
390
+ */
391
+ function extractInputs(node) {
392
+ const inputs = {};
393
+ if (node?.type !== 'TSTypeLiteral')
394
+ return inputs;
395
+ for (const member of node.members) {
396
+ if (member.type !== 'TSPropertySignature')
397
+ continue;
398
+ const propName = keyName(member.key);
399
+ const innerType = member.typeAnnotation?.typeAnnotation;
400
+ if (!propName || !innerType)
401
+ continue;
402
+ if (innerType.type === 'TSTypeLiteral') {
403
+ // v16+ object format
404
+ let alias = propName;
405
+ let required = false;
406
+ let isSignal = false;
407
+ for (const inner of innerType.members) {
408
+ if (inner.type !== 'TSPropertySignature')
409
+ continue;
410
+ const key = keyName(inner.key);
411
+ const val = inner.typeAnnotation?.typeAnnotation;
412
+ if (!key || !val)
413
+ continue;
414
+ if (key === 'alias') {
415
+ alias = literalString(val) ?? propName;
416
+ }
417
+ else if (key === 'required') {
418
+ required = literalBoolean(val) === true;
419
+ }
420
+ else if (key === 'isSignal') {
421
+ isSignal = literalBoolean(val) === true;
422
+ }
423
+ }
424
+ inputs[propName] = {
425
+ classPropertyName: propName,
426
+ bindingPropertyName: alias,
427
+ isSignal,
428
+ required,
429
+ };
430
+ }
431
+ else {
432
+ // pre-v16 string format
433
+ const alias = literalString(innerType);
434
+ if (alias) {
435
+ inputs[propName] = {
436
+ classPropertyName: propName,
437
+ bindingPropertyName: alias,
438
+ isSignal: false,
439
+ required: false,
440
+ };
441
+ }
442
+ }
443
+ }
444
+ return inputs;
445
+ }
446
+ /**
447
+ * Extract outputs from the type-argument at position [4].
448
+ * Format: { "propName": "eventName" }
449
+ */
450
+ function extractOutputs(node) {
451
+ const outputs = {};
452
+ if (node?.type !== 'TSTypeLiteral')
453
+ return outputs;
454
+ for (const member of node.members) {
455
+ if (member.type !== 'TSPropertySignature')
456
+ continue;
457
+ const propName = keyName(member.key);
458
+ const val = member.typeAnnotation?.typeAnnotation;
459
+ if (!propName || !val)
460
+ continue;
461
+ const value = literalString(val);
462
+ if (value)
463
+ outputs[propName] = value;
464
+ }
465
+ return outputs;
466
+ }
467
+ /** Get the string name from a property key (Identifier or Literal). */
468
+ function keyName(key) {
469
+ if (!key)
470
+ return undefined;
471
+ if (key.type === 'Identifier')
472
+ return key.name;
473
+ if (key.type === 'Literal' && typeof key.value === 'string')
474
+ return key.value;
475
+ return undefined;
476
+ }
477
+ /** Build a dotted name from an Identifier or TSQualifiedName. */
478
+ function qualifiedName(node) {
479
+ if (!node)
480
+ return '';
481
+ if (node.type === 'Identifier')
482
+ return node.name;
483
+ if (node.type === 'TSQualifiedName')
484
+ return qualifiedName(node.left) + '.' + qualifiedName(node.right);
485
+ return '';
486
+ }
487
+ /** Extract a string value from a TSLiteralType node. */
488
+ function literalString(node) {
489
+ if (node?.type === 'TSLiteralType' &&
490
+ node.literal?.type === 'Literal' &&
491
+ typeof node.literal.value === 'string') {
492
+ return node.literal.value;
493
+ }
494
+ return undefined;
495
+ }
496
+ /** Extract a boolean value from a TSLiteralType node. */
497
+ function literalBoolean(node) {
498
+ if (node?.type === 'TSLiteralType' &&
499
+ node.literal?.type === 'Literal' &&
500
+ typeof node.literal.value === 'boolean') {
501
+ return node.literal.value;
502
+ }
503
+ return undefined;
504
+ }
505
+ /** Recursively collect all .d.ts files under a directory. */
506
+ function collectDtsFiles(dir) {
507
+ const results = [];
508
+ let entries;
509
+ try {
510
+ entries = fs.readdirSync(dir, { withFileTypes: true });
511
+ }
512
+ catch {
513
+ return results;
514
+ }
515
+ for (const entry of entries) {
516
+ const full = path.join(dir, entry.name);
517
+ if (entry.isDirectory() && entry.name !== 'node_modules') {
518
+ results.push(...collectDtsFiles(full));
519
+ }
520
+ else if (entry.isFile() && entry.name.endsWith('.d.ts')) {
521
+ results.push(full);
522
+ }
523
+ }
524
+ return results;
525
+ }
526
+ //# sourceMappingURL=dts-reader.js.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ACE,IAAI,EAAE,IAAI,KAAK,eAAe;QAC9B,IAAI,CAAC,OAAO,EAAE,IAAI,KAAK,SAAS;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,EACvC,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IAC5B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,6DAA6D;AAC7D,SAAS,eAAe,CAAC,GAAW;IAClC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,OAAoB,CAAC;IACzB,IAAI,CAAC;QACH,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,KAAK,CAAC,WAAW,EAAE,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;YACzD,OAAO,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;QACzC,CAAC;aAAM,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1D,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { RegistryEntry } from './registry.js';
2
+ /**
3
+ * Generate HMR code using Angular's ɵɵreplaceMetadata for components,
4
+ * and simple field-swap + invalidation for directives/pipes.
5
+ *
6
+ * The applyMetadata callback dynamically copies all ɵ-prefixed static
7
+ * fields (ɵcmp, ɵfac, ɵdir, ɵpipe, etc.) from the newly compiled class
8
+ * to the old class reference that Angular's runtime is tracking.
9
+ *
10
+ * For components, ɵɵreplaceMetadata then merges the old/new definitions
11
+ * and recreates matching LViews in the component tree.
12
+ *
13
+ * For directives and pipes, ɵɵreplaceMetadata does not support them, so
14
+ * we fall back to a full page reload via import.meta.hot.invalidate().
15
+ */
16
+ export declare function generateHmrCode(declarations: RegistryEntry[], localDepClassNames?: string[]): string;
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Generate HMR code using Angular's ɵɵreplaceMetadata for components,
3
+ * and simple field-swap + invalidation for directives/pipes.
4
+ *
5
+ * The applyMetadata callback dynamically copies all ɵ-prefixed static
6
+ * fields (ɵcmp, ɵfac, ɵdir, ɵpipe, etc.) from the newly compiled class
7
+ * to the old class reference that Angular's runtime is tracking.
8
+ *
9
+ * For components, ɵɵreplaceMetadata then merges the old/new definitions
10
+ * and recreates matching LViews in the component tree.
11
+ *
12
+ * For directives and pipes, ɵɵreplaceMetadata does not support them, so
13
+ * we fall back to a full page reload via import.meta.hot.invalidate().
14
+ */
15
+ export function generateHmrCode(declarations, localDepClassNames = []) {
16
+ const components = declarations.filter((d) => d.kind === 'component');
17
+ const nonComponents = declarations.filter((d) => d.kind !== 'component');
18
+ // Export applyMetadata functions so the accept callback can access them.
19
+ // Dynamically copy all ɵ-prefixed static fields to handle ɵcmp, ɵfac,
20
+ // ɵdir, ɵpipe, ɵmod, ɵinj, ɵprov, and any future Ivy fields.
21
+ const applyFns = declarations
22
+ .map((c) => `
23
+ export function ɵhmr_${c.className}(type) {
24
+ for (const key of Object.getOwnPropertyNames(${c.className})) {
25
+ if (key.startsWith('ɵ')) type[key] = ${c.className}[key];
26
+ }
27
+ }`)
28
+ .join('\n');
29
+ // Components: use ɵɵreplaceMetadata for full LView recreation
30
+ const localDepsArray = localDepClassNames.length > 0 ? `[${localDepClassNames.join(', ')}]` : '[]';
31
+ const replaceBlocks = components
32
+ .map((c) => `
33
+ try {
34
+ i0.ɵɵreplaceMetadata(
35
+ ${c.className},
36
+ newModule.ɵhmr_${c.className},
37
+ { i0 },
38
+ ${localDepsArray},
39
+ import.meta,
40
+ "${c.className}"
41
+ );
42
+ replaced = true;
43
+ } catch(e) {
44
+ // ɵɵreplaceMetadata failed — will fall back to page reload
45
+ }`)
46
+ .join('\n');
47
+ // Directives/pipes: swap static fields and invalidate
48
+ const swapBlocks = nonComponents
49
+ .map((c) => `
50
+ try {
51
+ newModule.ɵhmr_${c.className}(${c.className});
52
+ swapped = true;
53
+ } catch(e) {}`)
54
+ .join('\n');
55
+ let acceptBody = `
56
+ if (!newModule) return;`;
57
+ if (components.length > 0) {
58
+ acceptBody += `
59
+ let replaced = false;${replaceBlocks}
60
+ if (!replaced) {
61
+ import.meta.hot.invalidate('Component HMR failed, reloading');
62
+ return;
63
+ }`;
64
+ }
65
+ if (nonComponents.length > 0) {
66
+ acceptBody += `
67
+ let swapped = false;${swapBlocks}
68
+ if (swapped) {
69
+ // Directive/pipe definitions updated — full reload needed for Angular
70
+ // to pick up the new behavior since ɵɵreplaceMetadata only supports components.
71
+ import.meta.hot.invalidate('Directive/pipe changed, reloading');
72
+ }`;
73
+ }
74
+ return `\n${applyFns}
75
+ if (import.meta.hot) {
76
+ import.meta.hot.accept((newModule) => {${acceptBody}
77
+ });
78
+ }`;
79
+ }
80
+ //# sourceMappingURL=hmr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmr.js","sourceRoot":"","sources":["../../../../../../packages/vite-plugin-angular/src/lib/compiler/hmr.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,eAAe,CAC7B,YAA6B,EAC7B,qBAA+B,EAAE;IAEjC,MAAM,UAAU,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC;IACtE,MAAM,aAAa,GAAG,YAAY,CAAC,MAAM,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,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { compile, type CompileResult, type CompileOptions } from './compile.js';
2
+ export { scanFile, type RegistryEntry, type ComponentRegistry, } from './registry.js';
3
+ export { scanDtsFile, scanPackageDts, collectImportedPackages, collectRelativeReExports, } from './dts-reader.js';
4
+ export { jitTransform, type JitTransformResult } from './jit-transform.js';
5
+ export { generateHmrCode } from './hmr.js';
6
+ export { inlineResourceUrls, extractInlineStyles } from './resource-inliner.js';
7
+ export { debugCompile, debugRegistry, debugResolve, debugEmit, } from './debug.js';
@@ -0,0 +1,8 @@
1
+ export { compile } from './compile.js';
2
+ export { scanFile, } from './registry.js';
3
+ export { scanDtsFile, scanPackageDts, collectImportedPackages, collectRelativeReExports, } from './dts-reader.js';
4
+ export { jitTransform } from './jit-transform.js';
5
+ export { generateHmrCode } from './hmr.js';
6
+ export { inlineResourceUrls, extractInlineStyles } from './resource-inliner.js';
7
+ export { debugCompile, debugRegistry, debugResolve, debugEmit, } from './debug.js';
8
+ //# sourceMappingURL=index.js.map