@analogjs/vite-plugin-angular 2.5.0-beta.8 → 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 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/vite-plugin-angular/src/lib/compiler/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2C,MAAM,cAAc,CAAC;AAChF,OAAO,EACL,QAAQ,GAGT,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,WAAW,EACX,cAAc,EACd,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAA2B,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EACL,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,SAAS,GACV,MAAM,YAAY,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Build ctorParameters for constructor DI in JIT format:
3
+ * [{ type: ServiceA }, { type: ServiceB, decorators: [{type: Optional}] }]
4
+ *
5
+ * Accepts an OXC ClassDeclaration node and the original source string.
6
+ */
7
+ export declare function buildCtorParameters(classNode: any, sourceCode: string, typeOnlyImports: Set<string>): string | null;
8
+ /**
9
+ * Build propDecorators for field decorators + signal API downleveling.
10
+ * Returns a JS object literal string or null if no props.
11
+ *
12
+ * Accepts an OXC ClassDeclaration node and the original source string.
13
+ */
14
+ export declare function buildPropDecorators(classNode: any, sourceCode: string): string | null;
@@ -0,0 +1,224 @@
1
+ /**
2
+ * JIT metadata helpers — OXC AST edition.
3
+ *
4
+ * Builds static metadata arrays that Angular's ReflectionCapabilities reads
5
+ * at runtime for JIT compilation (ctorParameters, propDecorators).
6
+ *
7
+ * Uses source-position slicing instead of AST getText() for speed.
8
+ */
9
+ import { FIELD_DECORATORS } from './constants.js';
10
+ function getCallApi(call) {
11
+ const callee = call.callee;
12
+ if (!callee)
13
+ return null;
14
+ if (callee.type === 'Identifier') {
15
+ return { api: callee.name, required: false };
16
+ }
17
+ if ((callee.type === 'StaticMemberExpression' ||
18
+ callee.type === 'MemberExpression') &&
19
+ callee.object?.type === 'Identifier' &&
20
+ callee.property?.name === 'required') {
21
+ return { api: callee.object.name, required: true };
22
+ }
23
+ return null;
24
+ }
25
+ /**
26
+ * Build ctorParameters for constructor DI in JIT format:
27
+ * [{ type: ServiceA }, { type: ServiceB, decorators: [{type: Optional}] }]
28
+ *
29
+ * Accepts an OXC ClassDeclaration node and the original source string.
30
+ */
31
+ export function buildCtorParameters(classNode, sourceCode, typeOnlyImports) {
32
+ const members = classNode.body?.body || [];
33
+ const ctor = members.find((m) => m.type === 'MethodDefinition' && m.kind === 'constructor');
34
+ if (!ctor)
35
+ return null;
36
+ const params = ctor.value?.params?.items || ctor.value?.params || [];
37
+ if (params.length === 0)
38
+ return null;
39
+ const result = [];
40
+ for (const param of params) {
41
+ const parts = [];
42
+ // Handle TSParameterProperty (e.g., constructor(private foo: Bar))
43
+ const actualParam = param.type === 'TSParameterProperty' ? param.parameter : param;
44
+ const typeAnn = actualParam?.typeAnnotation?.typeAnnotation ??
45
+ param?.typeAnnotation?.typeAnnotation;
46
+ // Extract type name from annotation
47
+ let typeName = null;
48
+ if (typeAnn) {
49
+ if (typeAnn.type === 'TSTypeReference' && typeAnn.typeName) {
50
+ typeName =
51
+ typeAnn.typeName.name ??
52
+ sourceCode.slice(typeAnn.typeName.start, typeAnn.typeName.end);
53
+ }
54
+ else if (typeAnn.type === 'TSUnionType') {
55
+ for (const t of typeAnn.types || []) {
56
+ if (t.type === 'TSTypeReference' && t.typeName) {
57
+ typeName =
58
+ t.typeName.name ??
59
+ sourceCode.slice(t.typeName.start, t.typeName.end);
60
+ break;
61
+ }
62
+ }
63
+ }
64
+ }
65
+ if (typeName && !typeOnlyImports.has(typeName)) {
66
+ parts.push(`type: ${typeName}`);
67
+ }
68
+ else {
69
+ parts.push(`type: undefined`);
70
+ }
71
+ // Extract parameter decorators (may live on TSParameterProperty or the param itself)
72
+ const paramDecs = param.decorators || actualParam?.decorators || [];
73
+ if (paramDecs.length > 0) {
74
+ const decEntries = paramDecs
75
+ .map((dec) => {
76
+ const expr = dec.expression;
77
+ if (!expr || expr.type !== 'CallExpression')
78
+ return '';
79
+ const name = expr.callee?.name;
80
+ if (!name)
81
+ return '';
82
+ const args = expr.arguments || [];
83
+ if (args.length > 0) {
84
+ return `{type: ${name}, args: [${args.map((a) => sourceCode.slice(a.start, a.end)).join(', ')}]}`;
85
+ }
86
+ return `{type: ${name}}`;
87
+ })
88
+ .filter(Boolean);
89
+ if (decEntries.length > 0) {
90
+ parts.push(`decorators: [${decEntries.join(', ')}]`);
91
+ }
92
+ }
93
+ result.push(`{${parts.join(', ')}}`);
94
+ }
95
+ return result.join(', ');
96
+ }
97
+ /**
98
+ * Build propDecorators for field decorators + signal API downleveling.
99
+ * Returns a JS object literal string or null if no props.
100
+ *
101
+ * Accepts an OXC ClassDeclaration node and the original source string.
102
+ */
103
+ export function buildPropDecorators(classNode, sourceCode) {
104
+ const props = {};
105
+ const members = classNode.body?.body || [];
106
+ for (const member of members) {
107
+ const memberName = member.key?.name;
108
+ if (!memberName)
109
+ continue;
110
+ // Check for field decorators (@Input, @Output, @ViewChild, etc.)
111
+ const decorators = member.decorators || [];
112
+ for (const dec of decorators) {
113
+ const expr = dec.expression;
114
+ if (!expr || expr.type !== 'CallExpression')
115
+ continue;
116
+ const decName = expr.callee?.name;
117
+ if (!decName || !FIELD_DECORATORS.has(decName))
118
+ continue;
119
+ if (!props[memberName])
120
+ props[memberName] = [];
121
+ const args = expr.arguments || [];
122
+ if (args.length > 0) {
123
+ props[memberName].push(`{type: ${decName}, args: [${args.map((a) => sourceCode.slice(a.start, a.end)).join(', ')}]}`);
124
+ }
125
+ else {
126
+ props[memberName].push(`{type: ${decName}}`);
127
+ }
128
+ }
129
+ // Signal API downleveling
130
+ if (member.type === 'PropertyDefinition' &&
131
+ member.value?.type === 'CallExpression') {
132
+ const signalCall = getCallApi(member.value);
133
+ if (!signalCall)
134
+ continue;
135
+ const { api, required } = signalCall;
136
+ const args = member.value.arguments || [];
137
+ if (api === 'input') {
138
+ if (!props[memberName])
139
+ props[memberName] = [];
140
+ // Preserve all original options from the input() call and overlay isSignal/required
141
+ const optArg = required ? args[0] : args[1];
142
+ const optParts = [];
143
+ if (optArg?.type === 'ObjectExpression') {
144
+ for (const p of optArg.properties || []) {
145
+ if (p.type !== 'ObjectProperty' && p.type !== 'Property')
146
+ continue;
147
+ const pKey = p.key?.name || p.key?.value;
148
+ // Skip isSignal/required — we override them below
149
+ if (pKey === 'isSignal' || pKey === 'required')
150
+ continue;
151
+ optParts.push(sourceCode.slice(p.start, p.end));
152
+ }
153
+ }
154
+ optParts.push(`isSignal: true`, `required: ${required}`);
155
+ props[memberName].push(`{type: Input, args: [{${optParts.join(', ')}}]}`);
156
+ }
157
+ else if (api === 'model') {
158
+ if (!props[memberName])
159
+ props[memberName] = [];
160
+ props[memberName].push(`{type: Input, args: [{isSignal: true}]}`);
161
+ // Model also generates a Change output
162
+ const changeName = memberName + 'Change';
163
+ if (!props[changeName])
164
+ props[changeName] = [];
165
+ props[changeName].push(`{type: Output, args: ['${changeName}']}`);
166
+ }
167
+ else if (api === 'output' || api === 'outputFromObservable') {
168
+ if (!props[memberName])
169
+ props[memberName] = [];
170
+ // Extract alias
171
+ let alias = null;
172
+ const optArg = args[0];
173
+ if (optArg?.type === 'ObjectExpression') {
174
+ for (const p of optArg.properties || []) {
175
+ if ((p.type === 'ObjectProperty' || p.type === 'Property') &&
176
+ (p.key?.name || p.key?.value) === 'alias') {
177
+ if (p.value?.type === 'StringLiteral' ||
178
+ (p.value?.type === 'Literal' &&
179
+ typeof p.value.value === 'string')) {
180
+ alias = p.value.value;
181
+ }
182
+ }
183
+ }
184
+ }
185
+ if (alias) {
186
+ props[memberName].push(`{type: Output, args: ['${alias}']}`);
187
+ }
188
+ else {
189
+ props[memberName].push(`{type: Output}`);
190
+ }
191
+ }
192
+ else if (api === 'viewChild' || api === 'viewChildren') {
193
+ if (!props[memberName])
194
+ props[memberName] = [];
195
+ const queryType = api === 'viewChildren' ? 'ViewChildren' : 'ViewChild';
196
+ if (args.length > 0) {
197
+ props[memberName].push(`{type: ${queryType}, args: [${sourceCode.slice(args[0].start, args[0].end)}]}`);
198
+ }
199
+ else {
200
+ props[memberName].push(`{type: ${queryType}}`);
201
+ }
202
+ }
203
+ else if (api === 'contentChild' || api === 'contentChildren') {
204
+ if (!props[memberName])
205
+ props[memberName] = [];
206
+ const queryType = api === 'contentChildren' ? 'ContentChildren' : 'ContentChild';
207
+ if (args.length > 0) {
208
+ props[memberName].push(`{type: ${queryType}, args: [${sourceCode.slice(args[0].start, args[0].end)}]}`);
209
+ }
210
+ else {
211
+ props[memberName].push(`{type: ${queryType}}`);
212
+ }
213
+ }
214
+ }
215
+ }
216
+ const entries = Object.entries(props);
217
+ if (entries.length === 0)
218
+ return null;
219
+ const propsStr = entries
220
+ .map(([key, decs]) => `${key}: [${decs.join(', ')}]`)
221
+ .join(', ');
222
+ return `{${propsStr}}`;
223
+ }
224
+ //# sourceMappingURL=jit-metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jit-metadata.js","sourceRoot":"","sources":["../../../../../../packages/vite-plugin-angular/src/lib/compiler/jit-metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,g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itTransformResult {
2
+ code: string;
3
+ map: any;
4
+ }
5
+ /**
6
+ * JIT transform for Angular files.
7
+ *
8
+ * Converts Angular decorators to static metadata arrays that Angular's
9
+ * runtime JIT compiler reads via ReflectionCapabilities:
10
+ *
11
+ * - Class.decorators = [{ type: Component, args: [{...}] }]
12
+ * - Class.ctorParameters = () => [{ type: ServiceA, decorators: [{type: Optional}] }]
13
+ * - Class.propDecorators = { name: [{ type: Input }], ... }
14
+ *
15
+ * Also emits ɵfac (factory function) with constructor DI and downlevels
16
+ * signal APIs (input, model, output, viewChild, etc.) to propDecorators.
17
+ *
18
+ * No template compilation — Angular's JIT compiler handles that at runtime.
19
+ * Requires `import '@angular/compiler'` in main.ts for the browser JIT.
20
+ *
21
+ * Uses OXC's native Rust parser instead of TypeScript's parser for ~1.5x
22
+ * faster parsing and source-position slicing instead of getText() calls.
23
+ */
24
+ export declare function jitTransform(sourceCode: string, fileName: string): JitTransformResult;
@@ -0,0 +1,269 @@
1
+ import { parseSync } from 'oxc-parser';
2
+ import MagicString from 'magic-string';
3
+ import { detectTypeOnlyImportNames } from './type-elision.js';
4
+ import { buildCtorParameters, buildPropDecorators } from './jit-metadata.js';
5
+ import { ANGULAR_DECORATORS, FIELD_DECORATORS } from './constants.js';
6
+ /**
7
+ * Recursively find all ClassDeclaration nodes in an OXC AST.
8
+ * Handles top-level, exported, and nested classes (e.g. inside function scopes).
9
+ */
10
+ function findAllClasses(node) {
11
+ const result = [];
12
+ if (!node || typeof node !== 'object')
13
+ return result;
14
+ if (Array.isArray(node)) {
15
+ for (const item of node) {
16
+ result.push(...findAllClasses(item));
17
+ }
18
+ return result;
19
+ }
20
+ if (node.type === 'ClassDeclaration' || node.type === 'ClassExpression') {
21
+ result.push(node);
22
+ }
23
+ for (const key of Object.keys(node)) {
24
+ if (key === 'type' ||
25
+ key === 'start' ||
26
+ key === 'end' ||
27
+ key === 'range' ||
28
+ key === 'loc')
29
+ continue;
30
+ result.push(...findAllClasses(node[key]));
31
+ }
32
+ return result;
33
+ }
34
+ /**
35
+ * JIT transform for Angular files.
36
+ *
37
+ * Converts Angular decorators to static metadata arrays that Angular's
38
+ * runtime JIT compiler reads via ReflectionCapabilities:
39
+ *
40
+ * - Class.decorators = [{ type: Component, args: [{...}] }]
41
+ * - Class.ctorParameters = () => [{ type: ServiceA, decorators: [{type: Optional}] }]
42
+ * - Class.propDecorators = { name: [{ type: Input }], ... }
43
+ *
44
+ * Also emits ɵfac (factory function) with constructor DI and downlevels
45
+ * signal APIs (input, model, output, viewChild, etc.) to propDecorators.
46
+ *
47
+ * No template compilation — Angular's JIT compiler handles that at runtime.
48
+ * Requires `import '@angular/compiler'` in main.ts for the browser JIT.
49
+ *
50
+ * Uses OXC's native Rust parser instead of TypeScript's parser for ~1.5x
51
+ * faster parsing and source-position slicing instead of getText() calls.
52
+ */
53
+ export function jitTransform(sourceCode, fileName) {
54
+ const { program } = parseSync(fileName, sourceCode);
55
+ const ms = new MagicString(sourceCode, { filename: fileName });
56
+ const typeOnlyImports = detectTypeOnlyImportNames(sourceCode);
57
+ let hasAngularClass = false;
58
+ const allClasses = findAllClasses(program.body);
59
+ const postClassStatements = [];
60
+ let importCounter = 0;
61
+ const resourceImports = [];
62
+ let needsJitImport = false;
63
+ for (const node of allClasses) {
64
+ const decorators = node.decorators || [];
65
+ const angularDecs = decorators.filter((dec) => {
66
+ const expr = dec.expression;
67
+ if (!expr || expr.type !== 'CallExpression')
68
+ return false;
69
+ const name = expr.callee?.name;
70
+ // Keep @Injectable on the class — Angular's decorator function
71
+ // self-registers ɵprov (providedIn) at class definition time and
72
+ // there is no ɵcompileInjectable JIT entry point to call instead.
73
+ if (name === 'Injectable')
74
+ return false;
75
+ return name !== undefined && ANGULAR_DECORATORS.has(name);
76
+ });
77
+ if (angularDecs.length === 0)
78
+ continue;
79
+ const className = node.id?.name;
80
+ if (!className)
81
+ continue;
82
+ hasAngularClass = true;
83
+ // 1. Remove Angular decorators from source
84
+ for (const dec of angularDecs) {
85
+ const start = dec.start;
86
+ let trimEnd = dec.end;
87
+ while (trimEnd < sourceCode.length && /\s/.test(sourceCode[trimEnd]))
88
+ trimEnd++;
89
+ ms.remove(start, trimEnd);
90
+ }
91
+ // 2. Emit Class.decorators = [{ type: DecName, args: [...] }]
92
+ // For @Component: convert templateUrl/styleUrl/styleUrls to ESM imports
93
+ const decoratorMeta = [];
94
+ const decoratorEntries = angularDecs.map((dec) => {
95
+ const call = dec.expression;
96
+ const decName = call.callee.name;
97
+ const args = call.arguments || [];
98
+ if (args.length > 0 &&
99
+ decName === 'Component' &&
100
+ args[0].type === 'ObjectExpression') {
101
+ // Rewrite component metadata: convert external resources to imports
102
+ const obj = args[0];
103
+ const rewrittenProps = [];
104
+ for (const prop of obj.properties) {
105
+ if (prop.type !== 'ObjectProperty' && prop.type !== 'Property') {
106
+ rewrittenProps.push(sourceCode.slice(prop.start, prop.end));
107
+ continue;
108
+ }
109
+ const key = prop.key?.name || prop.key?.value;
110
+ const val = prop.value;
111
+ if (key === 'templateUrl' &&
112
+ (val?.type === 'StringLiteral' ||
113
+ (val?.type === 'Literal' && typeof val.value === 'string'))) {
114
+ // templateUrl: './foo.html' → template: _tpl0 (with import)
115
+ const varName = `_jit_tpl_${importCounter++}`;
116
+ resourceImports.push(`import ${varName} from '${val.value}?raw';`);
117
+ rewrittenProps.push(`template: ${varName}`);
118
+ }
119
+ else if (key === 'styleUrl' &&
120
+ (val?.type === 'StringLiteral' ||
121
+ (val?.type === 'Literal' && typeof val.value === 'string'))) {
122
+ // styleUrl: './foo.scss' → styles: [_style0]
123
+ const varName = `_jit_style_${importCounter++}`;
124
+ resourceImports.push(`import ${varName} from '${val.value}?inline';`);
125
+ rewrittenProps.push(`styles: [${varName}]`);
126
+ }
127
+ else if (key === 'styleUrls' && val?.type === 'ArrayExpression') {
128
+ // styleUrls: ['./a.scss', './b.css'] → styles: [_style0, _style1]
129
+ const vars = [];
130
+ for (const el of val.elements) {
131
+ if (el?.type === 'StringLiteral' ||
132
+ (el?.type === 'Literal' && typeof el.value === 'string')) {
133
+ const varName = `_jit_style_${importCounter++}`;
134
+ resourceImports.push(`import ${varName} from '${el.value}?inline';`);
135
+ vars.push(varName);
136
+ }
137
+ }
138
+ rewrittenProps.push(`styles: [${vars.join(', ')}]`);
139
+ }
140
+ else {
141
+ rewrittenProps.push(sourceCode.slice(prop.start, prop.end));
142
+ }
143
+ }
144
+ const rewrittenArgsText = `{${rewrittenProps.join(', ')}}`;
145
+ decoratorMeta.push({ name: decName, argsText: rewrittenArgsText });
146
+ return `{ type: ${decName}, args: [${rewrittenArgsText}] }`;
147
+ }
148
+ if (args.length > 0) {
149
+ const argsText = args
150
+ .map((a) => sourceCode.slice(a.start, a.end))
151
+ .join(', ');
152
+ decoratorMeta.push({ name: decName, argsText });
153
+ return `{ type: ${decName}, args: [${argsText}] }`;
154
+ }
155
+ decoratorMeta.push({ name: decName, argsText: '{}' });
156
+ return `{ type: ${decName} }`;
157
+ });
158
+ postClassStatements.push(`${className}.decorators = [${decoratorEntries.join(', ')}];`);
159
+ // 2b. Trigger JIT compilation with the rewritten decorator metadata
160
+ for (const dm of decoratorMeta) {
161
+ needsJitImport = true;
162
+ switch (dm.name) {
163
+ case 'Component':
164
+ postClassStatements.push(`_jitCompileComponent(${className}, ${dm.argsText});`);
165
+ break;
166
+ case 'Directive':
167
+ postClassStatements.push(`_jitCompileDirective(${className}, ${dm.argsText});`);
168
+ break;
169
+ case 'Pipe':
170
+ postClassStatements.push(`_jitCompilePipe(${className}, ${dm.argsText});`);
171
+ break;
172
+ case 'NgModule':
173
+ postClassStatements.push(`_jitCompileNgModule(${className}, ${dm.argsText});`);
174
+ break;
175
+ }
176
+ }
177
+ // 3. Emit Class.ctorParameters for constructor DI
178
+ const ctorParams = buildCtorParameters(node, sourceCode, typeOnlyImports);
179
+ if (ctorParams) {
180
+ postClassStatements.push(`${className}.ctorParameters = () => [${ctorParams}];`);
181
+ }
182
+ // 4. Emit Class.propDecorators for field decorators + signal APIs
183
+ const propDecorators = buildPropDecorators(node, sourceCode);
184
+ if (propDecorators) {
185
+ postClassStatements.push(`${className}.propDecorators = ${propDecorators};`);
186
+ }
187
+ // 5. Remove member and parameter decorators from source now that
188
+ // they have been extracted into static metadata above.
189
+ const members = node.body?.body || [];
190
+ for (const member of members) {
191
+ const memberDecs = member.decorators || [];
192
+ for (const dec of memberDecs) {
193
+ const start = dec.start;
194
+ let trimEnd = dec.end;
195
+ while (trimEnd < sourceCode.length && /\s/.test(sourceCode[trimEnd]))
196
+ trimEnd++;
197
+ ms.remove(start, trimEnd);
198
+ }
199
+ // Constructor parameter decorators
200
+ if (member.type === 'MethodDefinition' && member.kind === 'constructor') {
201
+ const params = member.value?.params?.items || member.value?.params || [];
202
+ for (const param of params) {
203
+ // Decorators may live on the TSParameterProperty wrapper or the inner param
204
+ const allParamDecs = [
205
+ ...(param.decorators || []),
206
+ ...(param.type === 'TSParameterProperty' &&
207
+ param.parameter?.decorators
208
+ ? param.parameter.decorators
209
+ : []),
210
+ ];
211
+ for (const dec of allParamDecs) {
212
+ const start = dec.start;
213
+ let trimEnd = dec.end;
214
+ while (trimEnd < sourceCode.length &&
215
+ /\s/.test(sourceCode[trimEnd]))
216
+ trimEnd++;
217
+ ms.remove(start, trimEnd);
218
+ }
219
+ }
220
+ }
221
+ }
222
+ }
223
+ if (!hasAngularClass) {
224
+ return { code: sourceCode, map: null };
225
+ }
226
+ // Prepend ESM imports for external templates/styles
227
+ if (resourceImports.length > 0) {
228
+ ms.prepend(resourceImports.join('\n') + '\n');
229
+ }
230
+ // Prepend imports for decorator classes referenced by signal API downleveling
231
+ // (e.g. input() → {type: Input}, model() → {type: Input} + {type: Output})
232
+ const existingImports = new Set();
233
+ for (const stmt of program.body) {
234
+ if (stmt.type === 'ImportDeclaration' &&
235
+ stmt.source?.value === '@angular/core') {
236
+ for (const spec of stmt.specifiers || []) {
237
+ if (spec.type === 'ImportSpecifier') {
238
+ existingImports.add(spec.local?.name || spec.imported?.name);
239
+ }
240
+ }
241
+ }
242
+ }
243
+ const allPostCode = postClassStatements.join('\n');
244
+ const missingDecorators = [];
245
+ for (const dec of FIELD_DECORATORS) {
246
+ if (allPostCode.includes(`type: ${dec}`) && !existingImports.has(dec)) {
247
+ missingDecorators.push(dec);
248
+ }
249
+ }
250
+ if (missingDecorators.length > 0) {
251
+ ms.prepend(`import { ${missingDecorators.join(', ')} } from '@angular/core';\n`);
252
+ }
253
+ // Prepend JIT compiler imports
254
+ if (needsJitImport) {
255
+ ms.prepend(`import { ɵcompileComponent as _jitCompileComponent, ɵcompileDirective as _jitCompileDirective, ɵcompilePipe as _jitCompilePipe, ɵcompileNgModule as _jitCompileNgModule } from '@angular/core';\n`);
256
+ }
257
+ // Append all post-class statements at the end
258
+ if (postClassStatements.length > 0) {
259
+ ms.append('\n' + postClassStatements.join('\n') + '\n');
260
+ }
261
+ const map = ms.generateMap({
262
+ source: fileName,
263
+ file: fileName + '.js',
264
+ includeContent: true,
265
+ hires: 'boundary',
266
+ });
267
+ return { code: ms.toString(), map };
268
+ }
269
+ //# sourceMappingURL=jit-transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jit-transform.js","sourceRoot":"","sources":["../../../../../../packages/vite-plugin-angular/src/lib/compiler/jit-transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOtE;;;GAGG;AACH,SAAS,cAAc,CAAC,IAAS;IAC/B,MAAM,MAAM,GAAU,EAAE,CAAC;IACzB,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC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,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,4BAA4B,CACrE,CAAC;IACJ,CAAC;IAED,+BAA+B;IAC/B,IAAI,cAAc,EAAE,CAAC;QACnB,EAAE,CAAC,OAAO,CACR,mMAAmM,CACpM,CAAC;IACJ,CAAC;IAED,8CAA8C;IAC9C,IAAI,mBAAmB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnC,EAAE,CAAC,MAAM,CAAC,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,GAAG,GAAG,EAAE,CAAC,WAAW,CAAC;QACzB,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,QAAQ,GAAG,KAAK;QACtB,cAAc,EAAE,IAAI;QACpB,KAAK,EAAE,UAAU;KAClB,CAAC,CAAC;IAEH,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,CAAC;AACtC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import * as ts from 'typescript';
2
+ import * as o from '@angular/compiler';
3
+ /** Emit Angular output AST expression directly to a JavaScript string. */
4
+ export declare function emitAngularExpr(expr: o.Expression): string;
5
+ /** Emit Angular output AST statement directly to a JavaScript string. */
6
+ export declare function emitAngularStmt(stmt: o.Statement): string;
7
+ /** Set the current source file for WrappedNodeExpr fallback printing. */
8
+ export declare function setEmitterSourceFile(sf: ts.SourceFile | undefined): void;
9
+ /** Set the current source code for OXC-based WrappedNodeExpr slice fallback. */
10
+ export declare function setEmitterSourceCode(code: string | undefined): void;