@nativescript/vite 8.0.0-alpha.6 → 8.0.0-alpha.8

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 (85) hide show
  1. package/configuration/angular.js +155 -22
  2. package/configuration/angular.js.map +1 -1
  3. package/configuration/base.js +9 -12
  4. package/configuration/base.js.map +1 -1
  5. package/configuration/typescript.js +1 -1
  6. package/configuration/typescript.js.map +1 -1
  7. package/helpers/angular/angular-linker.js +3 -12
  8. package/helpers/angular/angular-linker.js.map +1 -1
  9. package/helpers/angular/inject-component-hmr-registration.d.ts +112 -0
  10. package/helpers/angular/inject-component-hmr-registration.js +359 -0
  11. package/helpers/angular/inject-component-hmr-registration.js.map +1 -0
  12. package/helpers/global-defines.d.ts +7 -13
  13. package/helpers/global-defines.js +10 -16
  14. package/helpers/global-defines.js.map +1 -1
  15. package/helpers/main-entry.js +6 -7
  16. package/helpers/main-entry.js.map +1 -1
  17. package/helpers/ns-core-url.d.ts +5 -6
  18. package/helpers/ns-core-url.js +5 -6
  19. package/helpers/ns-core-url.js.map +1 -1
  20. package/helpers/prelink-angular.js +1 -4
  21. package/helpers/prelink-angular.js.map +1 -1
  22. package/hmr/client/css-handler.js +2 -1
  23. package/hmr/client/css-handler.js.map +1 -1
  24. package/hmr/client/hmr-pending-overlay.d.ts +1 -1
  25. package/hmr/client/hmr-pending-overlay.js +1 -1
  26. package/hmr/client/index.js +27 -26
  27. package/hmr/client/index.js.map +1 -1
  28. package/hmr/client/utils.js +27 -25
  29. package/hmr/client/utils.js.map +1 -1
  30. package/hmr/entry-runtime.js +11 -29
  31. package/hmr/entry-runtime.js.map +1 -1
  32. package/hmr/frameworks/angular/client/index.js +118 -136
  33. package/hmr/frameworks/angular/client/index.js.map +1 -1
  34. package/hmr/frameworks/angular/server/linker.js +1 -4
  35. package/hmr/frameworks/angular/server/linker.js.map +1 -1
  36. package/hmr/frameworks/vue/client/index.js +18 -42
  37. package/hmr/frameworks/vue/client/index.js.map +1 -1
  38. package/hmr/server/core-sanitize.js +8 -8
  39. package/hmr/server/core-sanitize.js.map +1 -1
  40. package/hmr/server/import-map.js +3 -4
  41. package/hmr/server/import-map.js.map +1 -1
  42. package/hmr/server/ns-core-cjs-shape.d.ts +2 -4
  43. package/hmr/server/ns-core-cjs-shape.js +4 -6
  44. package/hmr/server/ns-core-cjs-shape.js.map +1 -1
  45. package/hmr/server/perf-instrumentation.d.ts +5 -9
  46. package/hmr/server/perf-instrumentation.js +2 -5
  47. package/hmr/server/perf-instrumentation.js.map +1 -1
  48. package/hmr/server/vite-plugin.js +3 -1
  49. package/hmr/server/vite-plugin.js.map +1 -1
  50. package/hmr/server/websocket-angular-hot-update.d.ts +1 -0
  51. package/hmr/server/websocket-angular-hot-update.js +42 -30
  52. package/hmr/server/websocket-angular-hot-update.js.map +1 -1
  53. package/hmr/server/websocket-core-bridge.js +12 -17
  54. package/hmr/server/websocket-core-bridge.js.map +1 -1
  55. package/hmr/server/websocket-hmr-pending.d.ts +1 -1
  56. package/hmr/server/websocket-hmr-pending.js +1 -1
  57. package/hmr/server/websocket-module-bindings.js +2 -2
  58. package/hmr/server/websocket-module-bindings.js.map +1 -1
  59. package/hmr/server/websocket-ns-m-paths.js +14 -15
  60. package/hmr/server/websocket-ns-m-paths.js.map +1 -1
  61. package/hmr/server/websocket-runtime-compat.js +4 -3
  62. package/hmr/server/websocket-runtime-compat.js.map +1 -1
  63. package/hmr/server/websocket-served-module-helpers.js +13 -12
  64. package/hmr/server/websocket-served-module-helpers.js.map +1 -1
  65. package/hmr/server/websocket-vue-sfc.js +15 -60
  66. package/hmr/server/websocket-vue-sfc.js.map +1 -1
  67. package/hmr/server/websocket.js +286 -338
  68. package/hmr/server/websocket.js.map +1 -1
  69. package/hmr/shared/runtime/boot-timeline.js +0 -3
  70. package/hmr/shared/runtime/boot-timeline.js.map +1 -1
  71. package/hmr/shared/runtime/dev-overlay.js +36 -50
  72. package/hmr/shared/runtime/dev-overlay.js.map +1 -1
  73. package/hmr/shared/runtime/module-provenance.js +1 -4
  74. package/hmr/shared/runtime/module-provenance.js.map +1 -1
  75. package/hmr/shared/runtime/root-placeholder.js +38 -68
  76. package/hmr/shared/runtime/root-placeholder.js.map +1 -1
  77. package/hmr/shared/runtime/session-bootstrap.js +8 -8
  78. package/hmr/shared/runtime/session-bootstrap.js.map +1 -1
  79. package/hmr/shared/runtime/vendor-bootstrap.js +1 -9
  80. package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
  81. package/hmr/shared/vendor/manifest.js +4 -16
  82. package/hmr/shared/vendor/manifest.js.map +1 -1
  83. package/package.json +1 -1
  84. package/runtime/core-aliases-early.js +17 -41
  85. package/runtime/core-aliases-early.js.map +1 -1
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Vite-side helper that injects HMR self-registration calls into the
3
+ * compiled output of user `.ts` files that declare `@Component`-
4
+ * decorated classes.
5
+ *
6
+ * After an HMR reboot, the global `__NS_HMR_REGISTER_COMPONENT__` hook
7
+ * (installed by `@nativescript/angular`) records each fresh class
8
+ * keyed by source name. HMR helpers (modal restore, route replay) read
9
+ * the registry to re-attach to the live class. See
10
+ * `hmr-class-registry.ts` for the runtime side of the contract.
11
+ *
12
+ * The helper exposes two phases used by complementary Vite plugins:
13
+ * 1. `findComponentClassNames(rawTs)` — scans the user's raw TS
14
+ * source for `@Component`-decorated classes. Used by an
15
+ * `enforce: 'pre'` plugin to discover names BEFORE the Analog
16
+ * Angular plugin compiles the file. The discovery has to happen
17
+ * on raw TS because the Angular plugin rewrites the `@Component`
18
+ * decorator into static metadata calls (`ɵsetClassMetadata`,
19
+ * `ɵɵdefineComponent`) and removes the textual `@Component(...)`
20
+ * pattern.
21
+ * 2. `appendComponentHmrRegistration(compiledCode, names)` — appends
22
+ * the registration snippet to the END of compiled JS produced by
23
+ * the Analog Angular plugin. Used by an `enforce: 'post'` plugin.
24
+ * Appending here is the only reliable insertion point because:
25
+ * - Class declarations are evaluated and bound by then.
26
+ * - Angular's static metadata (`ɵcmp`/`ɵfac`) has finished
27
+ * attaching, so the registered class identity already
28
+ * carries the up-to-date component definition.
29
+ * - The Analog Angular plugin's `transform` discards anything
30
+ * appended before its compilation step (it returns code
31
+ * regenerated from its own `outputFiles` cache, not the
32
+ * input passed in). Verified directly in the plugin chain.
33
+ * - Source-map line offsets for the original module body are
34
+ * preserved (we only append).
35
+ *
36
+ * The legacy `injectComponentHmrRegistration(rawTs)` helper is kept
37
+ * for backward compatibility — it appends to raw TS in a single call —
38
+ * but is no longer the path used by the live HMR pipeline (its output
39
+ * is silently dropped by the Angular plugin for `@Component` files).
40
+ *
41
+ * The helpers are dev-only: production builds skip the Vite plugins
42
+ * (`apply: 'serve'`), and the runtime hook short-circuits when
43
+ * `isAngularHmrEnabled()` is false.
44
+ */
45
+ /**
46
+ * Marker comment placed immediately before the appended registration
47
+ * block. Plugins can scan for this string to make their work
48
+ * idempotent across re-transforms (the Vite cache may replay the
49
+ * transform pipeline on cached modules).
50
+ */
51
+ export declare const INJECTION_MARKER = "/* @nativescript/vite ns-hmr-register */";
52
+ export interface InjectComponentHmrRegistrationOptions {
53
+ /**
54
+ * Optional override of the global hook name. Defaults to
55
+ * `__NS_HMR_REGISTER_COMPONENT__`. Exposed for tests; production
56
+ * callers should keep the default.
57
+ */
58
+ hookName?: string;
59
+ }
60
+ export interface InjectComponentHmrRegistrationResult {
61
+ /** New code, or `null` if no transformation is needed. */
62
+ code: string | null;
63
+ /** Names of `@Component` classes detected in the file. */
64
+ componentNames: string[];
65
+ }
66
+ /**
67
+ * Build the trailing snippet that registers each component class with
68
+ * the global HMR hook. Pure string construction — exposed so the post-
69
+ * Angular plugin can append it to compiled output without re-scanning
70
+ * for class names (the pre plugin already scanned the raw TS source).
71
+ *
72
+ * Returns an empty string when `componentNames` is empty so callers
73
+ * can concatenate unconditionally.
74
+ */
75
+ export declare function buildComponentHmrRegistrationSuffix(componentNames: string[], options?: InjectComponentHmrRegistrationOptions): string;
76
+ /**
77
+ * Append the registration snippet to a piece of code (typically the
78
+ * compiled output from `@analogjs/vite-plugin-angular`) using a list
79
+ * of component names previously discovered in the raw TS source.
80
+ *
81
+ * Returns `{ code: null, componentNames: [] }` if `componentNames`
82
+ * is empty or if the code already contains the injection marker
83
+ * (idempotent re-transform case).
84
+ */
85
+ export declare function appendComponentHmrRegistration(code: string, componentNames: string[], options?: InjectComponentHmrRegistrationOptions): InjectComponentHmrRegistrationResult;
86
+ /**
87
+ * Legacy helper: scan raw TypeScript source for `@Component` classes
88
+ * and append registration calls. Retained for tests and for any
89
+ * caller running outside the post-Angular plugin chain.
90
+ *
91
+ * NOTE: For files compiled by `@analogjs/vite-plugin-angular`, this
92
+ * helper's output is discarded — the Angular plugin replaces the
93
+ * input code with the regenerated compiled output from its internal
94
+ * `outputFiles` cache. Use `findComponentClassNames(rawTs)` +
95
+ * `appendComponentHmrRegistration(compiledCode, names)` from a
96
+ * `enforce: 'post'` plugin to survive that compilation step.
97
+ */
98
+ export declare function injectComponentHmrRegistration(code: string, options?: InjectComponentHmrRegistrationOptions): InjectComponentHmrRegistrationResult;
99
+ /**
100
+ * Walk a TS source string and collect class names declared after a
101
+ * `@Component(...)` decorator. Supports:
102
+ * - `export class Foo` and bare `class Foo`
103
+ * - `abstract class Foo` (rare for @Component but allowed)
104
+ * - Any number of additional decorators stacked between `@Component`
105
+ * and the class keyword (e.g. `@Component({}) @SomethingElse() ...`)
106
+ *
107
+ * Skips matches that fall inside string literals or comments. Uses a
108
+ * paren-matching scanner instead of regex `[\s\S]*?` so multi-line
109
+ * decorator arguments (templates, styles arrays) don't trip up the
110
+ * scanner.
111
+ */
112
+ export declare function findComponentClassNames(code: string): string[];
@@ -0,0 +1,359 @@
1
+ /**
2
+ * Vite-side helper that injects HMR self-registration calls into the
3
+ * compiled output of user `.ts` files that declare `@Component`-
4
+ * decorated classes.
5
+ *
6
+ * After an HMR reboot, the global `__NS_HMR_REGISTER_COMPONENT__` hook
7
+ * (installed by `@nativescript/angular`) records each fresh class
8
+ * keyed by source name. HMR helpers (modal restore, route replay) read
9
+ * the registry to re-attach to the live class. See
10
+ * `hmr-class-registry.ts` for the runtime side of the contract.
11
+ *
12
+ * The helper exposes two phases used by complementary Vite plugins:
13
+ * 1. `findComponentClassNames(rawTs)` — scans the user's raw TS
14
+ * source for `@Component`-decorated classes. Used by an
15
+ * `enforce: 'pre'` plugin to discover names BEFORE the Analog
16
+ * Angular plugin compiles the file. The discovery has to happen
17
+ * on raw TS because the Angular plugin rewrites the `@Component`
18
+ * decorator into static metadata calls (`ɵsetClassMetadata`,
19
+ * `ɵɵdefineComponent`) and removes the textual `@Component(...)`
20
+ * pattern.
21
+ * 2. `appendComponentHmrRegistration(compiledCode, names)` — appends
22
+ * the registration snippet to the END of compiled JS produced by
23
+ * the Analog Angular plugin. Used by an `enforce: 'post'` plugin.
24
+ * Appending here is the only reliable insertion point because:
25
+ * - Class declarations are evaluated and bound by then.
26
+ * - Angular's static metadata (`ɵcmp`/`ɵfac`) has finished
27
+ * attaching, so the registered class identity already
28
+ * carries the up-to-date component definition.
29
+ * - The Analog Angular plugin's `transform` discards anything
30
+ * appended before its compilation step (it returns code
31
+ * regenerated from its own `outputFiles` cache, not the
32
+ * input passed in). Verified directly in the plugin chain.
33
+ * - Source-map line offsets for the original module body are
34
+ * preserved (we only append).
35
+ *
36
+ * The legacy `injectComponentHmrRegistration(rawTs)` helper is kept
37
+ * for backward compatibility — it appends to raw TS in a single call —
38
+ * but is no longer the path used by the live HMR pipeline (its output
39
+ * is silently dropped by the Angular plugin for `@Component` files).
40
+ *
41
+ * The helpers are dev-only: production builds skip the Vite plugins
42
+ * (`apply: 'serve'`), and the runtime hook short-circuits when
43
+ * `isAngularHmrEnabled()` is false.
44
+ */
45
+ const COMPONENT_DECORATOR_RE = /@Component\s*\(/g;
46
+ /**
47
+ * Marker comment placed immediately before the appended registration
48
+ * block. Plugins can scan for this string to make their work
49
+ * idempotent across re-transforms (the Vite cache may replay the
50
+ * transform pipeline on cached modules).
51
+ */
52
+ export const INJECTION_MARKER = '/* @nativescript/vite ns-hmr-register */';
53
+ /**
54
+ * Build the trailing snippet that registers each component class with
55
+ * the global HMR hook. Pure string construction — exposed so the post-
56
+ * Angular plugin can append it to compiled output without re-scanning
57
+ * for class names (the pre plugin already scanned the raw TS source).
58
+ *
59
+ * Returns an empty string when `componentNames` is empty so callers
60
+ * can concatenate unconditionally.
61
+ */
62
+ export function buildComponentHmrRegistrationSuffix(componentNames, options = {}) {
63
+ if (!componentNames || componentNames.length === 0) {
64
+ return '';
65
+ }
66
+ const hookName = options.hookName ?? '__NS_HMR_REGISTER_COMPONENT__';
67
+ const registrationLines = componentNames.map((name) => buildRegistrationLine(hookName, name));
68
+ // Pad with two newlines so the appended block is visually separated
69
+ // from the original module body in source maps and stack traces.
70
+ return `\n\n${INJECTION_MARKER}\n${registrationLines.join('\n')}\n`;
71
+ }
72
+ /**
73
+ * Append the registration snippet to a piece of code (typically the
74
+ * compiled output from `@analogjs/vite-plugin-angular`) using a list
75
+ * of component names previously discovered in the raw TS source.
76
+ *
77
+ * Returns `{ code: null, componentNames: [] }` if `componentNames`
78
+ * is empty or if the code already contains the injection marker
79
+ * (idempotent re-transform case).
80
+ */
81
+ export function appendComponentHmrRegistration(code, componentNames, options = {}) {
82
+ if (!code) {
83
+ return { code: null, componentNames: [] };
84
+ }
85
+ if (!componentNames || componentNames.length === 0) {
86
+ return { code: null, componentNames: [] };
87
+ }
88
+ if (code.includes(INJECTION_MARKER)) {
89
+ return { code: null, componentNames: [] };
90
+ }
91
+ const suffix = buildComponentHmrRegistrationSuffix(componentNames, options);
92
+ if (!suffix) {
93
+ return { code: null, componentNames: [] };
94
+ }
95
+ return {
96
+ code: code + suffix,
97
+ componentNames: [...componentNames],
98
+ };
99
+ }
100
+ /**
101
+ * Legacy helper: scan raw TypeScript source for `@Component` classes
102
+ * and append registration calls. Retained for tests and for any
103
+ * caller running outside the post-Angular plugin chain.
104
+ *
105
+ * NOTE: For files compiled by `@analogjs/vite-plugin-angular`, this
106
+ * helper's output is discarded — the Angular plugin replaces the
107
+ * input code with the regenerated compiled output from its internal
108
+ * `outputFiles` cache. Use `findComponentClassNames(rawTs)` +
109
+ * `appendComponentHmrRegistration(compiledCode, names)` from a
110
+ * `enforce: 'post'` plugin to survive that compilation step.
111
+ */
112
+ export function injectComponentHmrRegistration(code, options = {}) {
113
+ if (!code) {
114
+ return { code: null, componentNames: [] };
115
+ }
116
+ if (code.includes(INJECTION_MARKER)) {
117
+ // Already injected (re-transform case) — return original to avoid
118
+ // duplicating registration calls.
119
+ return { code: null, componentNames: [] };
120
+ }
121
+ if (!COMPONENT_DECORATOR_RE.test(code)) {
122
+ return { code: null, componentNames: [] };
123
+ }
124
+ // RegExp.prototype.test with `g` flag advances lastIndex; reset for the
125
+ // next walk in `findComponentClassNames`.
126
+ COMPONENT_DECORATOR_RE.lastIndex = 0;
127
+ const componentNames = findComponentClassNames(code);
128
+ if (componentNames.length === 0) {
129
+ return { code: null, componentNames: [] };
130
+ }
131
+ const suffix = buildComponentHmrRegistrationSuffix(componentNames, options);
132
+ return {
133
+ code: code + suffix,
134
+ componentNames,
135
+ };
136
+ }
137
+ function buildRegistrationLine(hookName, className) {
138
+ // Wrap each call in its own try so a failure (e.g. the class binding
139
+ // not in scope at module end because the user re-exported it from
140
+ // somewhere else) doesn't break sibling registrations.
141
+ // The typeof guard prevents a ReferenceError if the global hook isn't
142
+ // installed (production builds, non-Angular contexts, isolated unit
143
+ // tests). The "globalThis" reference is universal across modern JS
144
+ // runtimes including the NativeScript iOS/Android runtimes.
145
+ return `try { if (typeof globalThis !== 'undefined' && typeof globalThis.${hookName} === 'function' && typeof ${className} !== 'undefined') { globalThis.${hookName}(${JSON.stringify(className)}, ${className}, typeof import.meta !== 'undefined' && import.meta && import.meta.url ? import.meta.url : ''); } } catch (e) {}`;
146
+ }
147
+ /**
148
+ * Walk a TS source string and collect class names declared after a
149
+ * `@Component(...)` decorator. Supports:
150
+ * - `export class Foo` and bare `class Foo`
151
+ * - `abstract class Foo` (rare for @Component but allowed)
152
+ * - Any number of additional decorators stacked between `@Component`
153
+ * and the class keyword (e.g. `@Component({}) @SomethingElse() ...`)
154
+ *
155
+ * Skips matches that fall inside string literals or comments. Uses a
156
+ * paren-matching scanner instead of regex `[\s\S]*?` so multi-line
157
+ * decorator arguments (templates, styles arrays) don't trip up the
158
+ * scanner.
159
+ */
160
+ export function findComponentClassNames(code) {
161
+ const names = [];
162
+ const componentRe = /@Component\s*\(/g;
163
+ let match;
164
+ while ((match = componentRe.exec(code)) !== null) {
165
+ const matchStart = match.index;
166
+ if (isInsideStringOrComment(code, matchStart)) {
167
+ continue;
168
+ }
169
+ const openParenIdx = matchStart + match[0].length - 1;
170
+ const closeParenIdx = findMatchingDelimiter(code, openParenIdx, '(', ')');
171
+ if (closeParenIdx === -1) {
172
+ continue;
173
+ }
174
+ const className = findClassNameAfter(code, closeParenIdx + 1);
175
+ if (className && !names.includes(className)) {
176
+ names.push(className);
177
+ }
178
+ }
179
+ return names;
180
+ }
181
+ /**
182
+ * Starting at `position`, skip whitespace and any further decorators
183
+ * (`@Foo(...)`) and return the next class name encountered, or
184
+ * `null` if no class declaration follows.
185
+ */
186
+ function findClassNameAfter(code, position) {
187
+ let i = position;
188
+ while (i < code.length) {
189
+ while (i < code.length && /\s/.test(code[i])) {
190
+ i++;
191
+ }
192
+ if (i >= code.length) {
193
+ return null;
194
+ }
195
+ if (code[i] === '@') {
196
+ // Another decorator stacked between @Component and class.
197
+ i++;
198
+ // Decorator name (identifier).
199
+ while (i < code.length && /[\w$.]/.test(code[i])) {
200
+ i++;
201
+ }
202
+ while (i < code.length && /\s/.test(code[i])) {
203
+ i++;
204
+ }
205
+ if (code[i] === '(') {
206
+ const decoClose = findMatchingDelimiter(code, i, '(', ')');
207
+ if (decoClose === -1) {
208
+ return null;
209
+ }
210
+ i = decoClose + 1;
211
+ }
212
+ continue;
213
+ }
214
+ const remainder = code.slice(i);
215
+ const classMatch = /^(?:export\s+(?:default\s+)?)?(?:abstract\s+)?class\s+([A-Za-z_$][\w$]*)/.exec(remainder);
216
+ if (classMatch) {
217
+ return classMatch[1];
218
+ }
219
+ return null;
220
+ }
221
+ return null;
222
+ }
223
+ /**
224
+ * True if `index` falls inside a // line comment, /* block comment, or
225
+ * a string/template literal. Used to filter out false positives from
226
+ * `@Component(` matches inside docs or stringified examples.
227
+ */
228
+ function isInsideStringOrComment(code, index) {
229
+ let i = 0;
230
+ let quote = null;
231
+ let escape = false;
232
+ let inLineComment = false;
233
+ let inBlockComment = false;
234
+ while (i < index) {
235
+ const char = code[i];
236
+ const next = code[i + 1];
237
+ if (inLineComment) {
238
+ if (char === '\n') {
239
+ inLineComment = false;
240
+ }
241
+ i++;
242
+ continue;
243
+ }
244
+ if (inBlockComment) {
245
+ if (char === '*' && next === '/') {
246
+ inBlockComment = false;
247
+ i += 2;
248
+ continue;
249
+ }
250
+ i++;
251
+ continue;
252
+ }
253
+ if (quote) {
254
+ if (escape) {
255
+ escape = false;
256
+ i++;
257
+ continue;
258
+ }
259
+ if (char === '\\') {
260
+ escape = true;
261
+ i++;
262
+ continue;
263
+ }
264
+ if (char === quote) {
265
+ quote = null;
266
+ }
267
+ i++;
268
+ continue;
269
+ }
270
+ if (char === '/' && next === '/') {
271
+ inLineComment = true;
272
+ i += 2;
273
+ continue;
274
+ }
275
+ if (char === '/' && next === '*') {
276
+ inBlockComment = true;
277
+ i += 2;
278
+ continue;
279
+ }
280
+ if (char === '"' || char === "'" || char === '`') {
281
+ quote = char;
282
+ i++;
283
+ continue;
284
+ }
285
+ i++;
286
+ }
287
+ return inLineComment || inBlockComment || quote !== null;
288
+ }
289
+ /**
290
+ * Find the index of the matching close delimiter for the opener at
291
+ * `openIndex`. Comment- and string-aware so multi-line decorator
292
+ * arguments (template strings, styles arrays) are scanned correctly.
293
+ */
294
+ function findMatchingDelimiter(source, openIndex, openChar, closeChar) {
295
+ if (openIndex < 0 || source[openIndex] !== openChar) {
296
+ return -1;
297
+ }
298
+ let depth = 0;
299
+ let quote = null;
300
+ let escape = false;
301
+ let inLineComment = false;
302
+ let inBlockComment = false;
303
+ for (let index = openIndex; index < source.length; index++) {
304
+ const char = source[index];
305
+ const next = source[index + 1];
306
+ if (inLineComment) {
307
+ if (char === '\n') {
308
+ inLineComment = false;
309
+ }
310
+ continue;
311
+ }
312
+ if (inBlockComment) {
313
+ if (char === '*' && next === '/') {
314
+ inBlockComment = false;
315
+ index++;
316
+ }
317
+ continue;
318
+ }
319
+ if (quote) {
320
+ if (escape) {
321
+ escape = false;
322
+ continue;
323
+ }
324
+ if (char === '\\') {
325
+ escape = true;
326
+ continue;
327
+ }
328
+ if (char === quote) {
329
+ quote = null;
330
+ }
331
+ continue;
332
+ }
333
+ if (char === '/' && next === '/') {
334
+ inLineComment = true;
335
+ index++;
336
+ continue;
337
+ }
338
+ if (char === '/' && next === '*') {
339
+ inBlockComment = true;
340
+ index++;
341
+ continue;
342
+ }
343
+ if (char === '"' || char === "'" || char === '`') {
344
+ quote = char;
345
+ continue;
346
+ }
347
+ if (char === openChar) {
348
+ depth++;
349
+ }
350
+ else if (char === closeChar) {
351
+ depth--;
352
+ if (depth === 0) {
353
+ return index;
354
+ }
355
+ }
356
+ }
357
+ return -1;
358
+ }
359
+ //# sourceMappingURL=inject-component-hmr-registration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inject-component-hmr-registration.js","sourceRoot":"","sources":["../../../../../packages/vite/helpers/angular/inject-component-hmr-registration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,0CAA0C,CAAC;AAkB3E;;;;;;;;GAQG;AACH,MAAM,UAAU,mCAAmC,CAAC,cAAwB,EAAE,UAAiD,EAAE;IAChI,IAAI,CAAC,cAAc,IAAI,c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AC;gBACvB,KAAK,EAAE,CAAC;YACT,CAAC;YACD,SAAS;QACV,CAAC;QACD,IAAI,KAAK,EAAE,CAAC;YACX,IAAI,MAAM,EAAE,CAAC;gBACZ,MAAM,GAAG,KAAK,CAAC;gBACf,SAAS;YACV,CAAC;YACD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;gBACnB,MAAM,GAAG,IAAI,CAAC;gBACd,SAAS;YACV,CAAC;YACD,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;gBACpB,KAAK,GAAG,IAAI,CAAC;YACd,CAAC;YACD,SAAS;QACV,CAAC;QAED,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YAClC,aAAa,GAAG,IAAI,CAAC;YACrB,KAAK,EAAE,CAAC;YACR,SAAS;QACV,CAAC;QACD,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YAClC,cAAc,GAAG,IAAI,CAAC;YACtB,KAAK,EAAE,CAAC;YACR,SAAS;QACV,CAAC;QACD,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YAClD,KAAK,GAAG,IAAI,CAAC;YACb,SAAS;QACV,CAAC;QAED,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YACvB,KAAK,EAAE,CAAC;QACT,CAAC;aAAM,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YAC/B,KAAK,EAAE,CAAC;YACR,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;gBACjB,OAAO,KAAK,CAAC;YACd,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,CAAC,CAAC,CAAC;AACX,CAAC"}
@@ -1,6 +1,5 @@
1
1
  /**
2
- * alpha.62 follow-up — opt-out flag for the HMR-applying progress
3
- * overlay introduced in Round-eleven.3.
2
+ * Opt-out flag for the HMR-applying progress overlay.
4
3
  *
5
4
  * Default: enabled. Set `NS_VITE_PROGRESS_OVERLAY=0` (or `false`) in
6
5
  * the environment to suppress the overlay if a developer finds it
@@ -11,8 +10,8 @@
11
10
  */
12
11
  export declare function isHmrProgressOverlayEnabled(env?: NodeJS.ProcessEnv): boolean;
13
12
  /**
14
- * alpha.64 — Kickstart-eligibility threshold for the parallel HMR
15
- * prefetch (alpha.63's `__nsKickstartHmrPrefetch`).
13
+ * Kickstart-eligibility threshold for the parallel HMR prefetch
14
+ * (`__nsKickstartHmrPrefetch`).
16
15
  *
17
16
  * Why a threshold exists. The kickstart fetches the SERVER-computed
18
17
  * inverse-dep closure (`evictPaths`) in parallel before V8 starts
@@ -31,23 +30,18 @@ export declare function isHmrProgressOverlayEnabled(env?: NodeJS.ProcessEnv): bo
31
30
  * route's path. The kickstart's parallel wave then over-fetches the
32
31
  * other ~70–270 importers — and Vite's single-threaded transform
33
32
  * pipeline cannot keep up with 16-way concurrent demand, so each
34
- * fetch's tail latency balloons (avg `[http-loader][fetch-sync]`
35
- * went from 17 ms to 74 ms in the user's repro). Net result: a
36
- * "should-be-200ms" HMR cycle becomes 6+ seconds.
33
+ * fetch's tail latency balloons. Net result: a "should-be-200ms"
34
+ * HMR cycle becomes 6+ seconds.
37
35
  *
38
36
  * The threshold short-circuits the kickstart when `evictPaths.length`
39
37
  * exceeds the configured cap. The HMR cycle still completes
40
- * correctly — V8 falls back to per-module synchronous fetches, which
41
- * is what the runtime did before alpha.63 — and the cycle reverts
42
- * to roughly the alpha.62 floor (~400–800 ms for a wide-fan-in
43
- * constants edit).
38
+ * correctly — V8 falls back to per-module synchronous fetches.
44
39
  *
45
40
  * Default: 32. Empirically chosen so component-shaped closures
46
41
  * (typically 5–30) keep the kickstart speed-up while wide-fan-in
47
42
  * leaf edits (typically 100+) skip it. Override with
48
43
  * `NS_VITE_KICKSTART_MAX_URLS=N` (any non-negative integer) — `0`
49
- * disables the kickstart entirely; `Infinity` disables the
50
- * threshold and restores alpha.63 behavior unconditionally.
44
+ * disables the kickstart entirely; `Infinity` removes the cap.
51
45
  */
52
46
  export declare const HMR_KICKSTART_DEFAULT_MAX_URLS = 32;
53
47
  export declare function resolveHmrKickstartMaxUrls(env?: NodeJS.ProcessEnv): number;
@@ -2,8 +2,7 @@ import { getProjectAppPath, getProjectAppVirtualPath } from './utils.js';
2
2
  const APP_ROOT_DIR = getProjectAppPath();
3
3
  const APP_ROOT_VIRTUAL = getProjectAppVirtualPath();
4
4
  /**
5
- * alpha.62 follow-up — opt-out flag for the HMR-applying progress
6
- * overlay introduced in Round-eleven.3.
5
+ * Opt-out flag for the HMR-applying progress overlay.
7
6
  *
8
7
  * Default: enabled. Set `NS_VITE_PROGRESS_OVERLAY=0` (or `false`) in
9
8
  * the environment to suppress the overlay if a developer finds it
@@ -19,8 +18,8 @@ export function isHmrProgressOverlayEnabled(env = process.env) {
19
18
  return !['0', 'false', 'off', 'no'].includes(raw);
20
19
  }
21
20
  /**
22
- * alpha.64 — Kickstart-eligibility threshold for the parallel HMR
23
- * prefetch (alpha.63's `__nsKickstartHmrPrefetch`).
21
+ * Kickstart-eligibility threshold for the parallel HMR prefetch
22
+ * (`__nsKickstartHmrPrefetch`).
24
23
  *
25
24
  * Why a threshold exists. The kickstart fetches the SERVER-computed
26
25
  * inverse-dep closure (`evictPaths`) in parallel before V8 starts
@@ -39,23 +38,18 @@ export function isHmrProgressOverlayEnabled(env = process.env) {
39
38
  * route's path. The kickstart's parallel wave then over-fetches the
40
39
  * other ~70–270 importers — and Vite's single-threaded transform
41
40
  * pipeline cannot keep up with 16-way concurrent demand, so each
42
- * fetch's tail latency balloons (avg `[http-loader][fetch-sync]`
43
- * went from 17 ms to 74 ms in the user's repro). Net result: a
44
- * "should-be-200ms" HMR cycle becomes 6+ seconds.
41
+ * fetch's tail latency balloons. Net result: a "should-be-200ms"
42
+ * HMR cycle becomes 6+ seconds.
45
43
  *
46
44
  * The threshold short-circuits the kickstart when `evictPaths.length`
47
45
  * exceeds the configured cap. The HMR cycle still completes
48
- * correctly — V8 falls back to per-module synchronous fetches, which
49
- * is what the runtime did before alpha.63 — and the cycle reverts
50
- * to roughly the alpha.62 floor (~400–800 ms for a wide-fan-in
51
- * constants edit).
46
+ * correctly — V8 falls back to per-module synchronous fetches.
52
47
  *
53
48
  * Default: 32. Empirically chosen so component-shaped closures
54
49
  * (typically 5–30) keep the kickstart speed-up while wide-fan-in
55
50
  * leaf edits (typically 100+) skip it. Override with
56
51
  * `NS_VITE_KICKSTART_MAX_URLS=N` (any non-negative integer) — `0`
57
- * disables the kickstart entirely; `Infinity` disables the
58
- * threshold and restores alpha.63 behavior unconditionally.
52
+ * disables the kickstart entirely; `Infinity` removes the cap.
59
53
  */
60
54
  export const HMR_KICKSTART_DEFAULT_MAX_URLS = 32;
61
55
  export function resolveHmrKickstartMaxUrls(env = process.env) {
@@ -86,9 +80,9 @@ export function getGlobalDefines(opts) {
86
80
  __NS_TARGET_FLAVOR__: JSON.stringify(opts.flavor),
87
81
  // whether to show the HMR in-progress overlay.
88
82
  __NS_HMR_PROGRESS_OVERLAY_ENABLED__: JSON.stringify(isHmrProgressOverlayEnabled()),
89
- // alpha.64 — eviction-set size cap for the parallel HMR
90
- // kickstart. JSON.stringify(Number.POSITIVE_INFINITY) is the
91
- // string "null", so we serialize Infinity ourselves to keep the
83
+ // Eviction-set size cap for the parallel HMR kickstart.
84
+ // `JSON.stringify(Number.POSITIVE_INFINITY)` is the string
85
+ // "null", so we serialize Infinity ourselves to keep the
92
86
  // build-time literal readable in source maps.
93
87
  __NS_HMR_KICKSTART_MAX_URLS__: (() => {
94
88
  const n = resolveHmrKickstartMaxUrls();
@@ -1 +1 @@
1
- {"version":3,"file":"global-defines.js","sourceRoot":"","sources":["../../../../packages/vite/helpers/global-defines.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAEzE,MAAM,YAAY,GAAG,iBAAiB,EAAE,CAAC;AACzC,MAAM,gBAAgB,GAAG,wBA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,2DAA2D;QAC3D,yDAAyD;QACzD,8CAA8C;QAC9C,6BAA6B,EAAE,CAAC,GAAW,EAAE;YAC5C,MAAM,CAAC,GAAG,0BAA0B,EAAE,CAAC;YACvC,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;QACpD,CAAC,CAAC,EAAE;QACJ,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;QAC1C,qBAAqB,EAAE,IAAI;QAC3B,4BAA4B,EAAE,KAAK;QACnC,yDAAyD;QACzD,QAAQ,EAAE,KAAK;QACf,yCAAyC;QACzC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QACnC,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;QACjD,uBAAuB,EAAE,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC;QACzD,2FAA2F;QAC3F,sBAAsB,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,KAAK,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC;KACxG,CAAC;AACH,CAAC"}
@@ -96,10 +96,10 @@ export function mainEntryPlugin(opts) {
96
96
  // the bundler to handle.
97
97
  //
98
98
  // Under HMR, delegates to buildCoreUrl() — the ONE canonical URL
99
- // generator (see Invariant A, HMR_CORE_REALM_DETERMINISTIC_PLAN.md).
100
- // Every URL emitter in the build/runtime pipeline (this function,
101
- // ns-core-external-urls, rewriteSpec, runtime import map) uses the
102
- // same function so iOS's HTTP ESM cache sees byte-identical URLs.
99
+ // generator. Every URL emitter in the build/runtime pipeline (this
100
+ // function, ns-core-external-urls, rewriteSpec, runtime import map)
101
+ // uses the same function so iOS's HTTP ESM cache sees byte-identical
102
+ // URLs.
103
103
  const coreSpec = (subpath) => {
104
104
  const origin = getBootOrigin();
105
105
  if (origin) {
@@ -158,8 +158,7 @@ export function mainEntryPlugin(opts) {
158
158
  // which routes `@nativescript/core*` through the HTTP bridge
159
159
  // or, for already-HTTP-loaded modules, through the
160
160
  // `globalThis.__NS_CORE_MODULES__` registry populated by the
161
- // `/ns/core` bridge preamble (see Invariant C in
162
- // HMR_CORE_REALM_DETERMINISTIC_PLAN.md).
161
+ // `/ns/core` bridge preamble.
163
162
  imports += "try { if (typeof globalThis !== 'undefined') {\n";
164
163
  imports += " var __nsOrigRequire = typeof globalThis.require === 'function' ? globalThis.require : null;\n";
165
164
  imports += ' var __nsNodeBuiltins = { fs: 1, path: 1, os: 1, url: 1, crypto: 1, util: 1, stream: 1, events: 1, buffer: 1, http: 1, https: 1, net: 1, tls: 1, dns: 1, child_process: 1, module: 1, zlib: 1, querystring: 1, assert: 1, constants: 1, vm: 1 };\n';
@@ -440,7 +439,7 @@ export function mainEntryPlugin(opts) {
440
439
  imports += "import { startBrowserRuntimeSession } from '@nativescript/vite/hmr/shared/runtime/session-bootstrap.js';\n";
441
440
  imports += `startBrowserRuntimeSession(${JSON.stringify(sessionUrl)}, __nsVerboseLog).catch((error) => {\n`;
442
441
  imports += ` try { globalThis.__NS_ENTRY_ERROR__ = { phase: 'deterministic-dev-session', message: String(error && (error.message || error)), stack: error && error.stack ? String(error.stack) : '' }; } catch {}\n`;
443
- imports += ` try { console.error('[ns-entry] deterministic dev session bootstrap failed', error && error.stack ? error.stack : error); } catch {}\n`;
442
+ imports += ` console.error('[ns-entry] deterministic dev session bootstrap failed', error && error.stack ? error.stack : error);\n`;
444
443
  imports += `});\n`;
445
444
  if (opts.verbose) {
446
445
  imports += `console.info('[ns-entry] deterministic dev session bootstrap appended');\n`;