@nativescript/vite 8.0.0-alpha.0 → 8.0.0-alpha.10

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 (222) hide show
  1. package/configuration/angular.d.ts +1 -1
  2. package/configuration/angular.js +486 -140
  3. package/configuration/angular.js.map +1 -1
  4. package/configuration/base.js +159 -41
  5. package/configuration/base.js.map +1 -1
  6. package/configuration/javascript.js +3 -3
  7. package/configuration/javascript.js.map +1 -1
  8. package/configuration/solid.js +7 -0
  9. package/configuration/solid.js.map +1 -1
  10. package/configuration/typescript.js +4 -4
  11. package/configuration/typescript.js.map +1 -1
  12. package/helpers/angular/angular-linker.js +38 -42
  13. package/helpers/angular/angular-linker.js.map +1 -1
  14. package/helpers/angular/inject-component-hmr-registration.d.ts +112 -0
  15. package/helpers/angular/inject-component-hmr-registration.js +359 -0
  16. package/helpers/angular/inject-component-hmr-registration.js.map +1 -0
  17. package/helpers/angular/inline-decorator-component-templates.d.ts +3 -0
  18. package/helpers/angular/inline-decorator-component-templates.js +400 -0
  19. package/helpers/angular/inline-decorator-component-templates.js.map +1 -0
  20. package/helpers/angular/shared-linker.d.ts +7 -0
  21. package/helpers/angular/shared-linker.js +37 -1
  22. package/helpers/angular/shared-linker.js.map +1 -1
  23. package/helpers/angular/synthesize-decorator-ctor-parameters.d.ts +1 -0
  24. package/helpers/angular/synthesize-decorator-ctor-parameters.js +256 -0
  25. package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +1 -0
  26. package/helpers/angular/synthesize-injectable-factories.d.ts +3 -0
  27. package/helpers/angular/synthesize-injectable-factories.js +414 -0
  28. package/helpers/angular/synthesize-injectable-factories.js.map +1 -0
  29. package/helpers/angular/util.d.ts +1 -0
  30. package/helpers/angular/util.js +88 -0
  31. package/helpers/angular/util.js.map +1 -1
  32. package/helpers/commonjs-plugins.d.ts +5 -2
  33. package/helpers/commonjs-plugins.js +126 -0
  34. package/helpers/commonjs-plugins.js.map +1 -1
  35. package/helpers/config-as-json.js +10 -0
  36. package/helpers/config-as-json.js.map +1 -1
  37. package/helpers/esbuild-platform-resolver.js +5 -5
  38. package/helpers/esbuild-platform-resolver.js.map +1 -1
  39. package/helpers/external-configs.d.ts +9 -1
  40. package/helpers/external-configs.js +31 -6
  41. package/helpers/external-configs.js.map +1 -1
  42. package/helpers/global-defines.d.ts +51 -0
  43. package/helpers/global-defines.js +77 -0
  44. package/helpers/global-defines.js.map +1 -1
  45. package/helpers/import-meta-path.d.ts +4 -0
  46. package/helpers/import-meta-path.js +5 -0
  47. package/helpers/import-meta-path.js.map +1 -0
  48. package/helpers/import-specifier.d.ts +1 -0
  49. package/helpers/import-specifier.js +18 -0
  50. package/helpers/import-specifier.js.map +1 -0
  51. package/helpers/logging.d.ts +1 -0
  52. package/helpers/logging.js +63 -3
  53. package/helpers/logging.js.map +1 -1
  54. package/helpers/main-entry.d.ts +5 -2
  55. package/helpers/main-entry.js +365 -116
  56. package/helpers/main-entry.js.map +1 -1
  57. package/helpers/nativeclass-transform.js +8 -127
  58. package/helpers/nativeclass-transform.js.map +1 -1
  59. package/helpers/nativeclass-transformer-plugin.d.ts +19 -1
  60. package/helpers/nativeclass-transformer-plugin.js +318 -31
  61. package/helpers/nativeclass-transformer-plugin.js.map +1 -1
  62. package/helpers/ns-core-url.d.ts +83 -0
  63. package/helpers/ns-core-url.js +167 -0
  64. package/helpers/ns-core-url.js.map +1 -0
  65. package/helpers/prelink-angular.js +1 -4
  66. package/helpers/prelink-angular.js.map +1 -1
  67. package/helpers/preserve-imports.js +2 -17
  68. package/helpers/preserve-imports.js.map +1 -1
  69. package/helpers/project.d.ts +35 -0
  70. package/helpers/project.js +120 -2
  71. package/helpers/project.js.map +1 -1
  72. package/helpers/ts-config-paths.js +50 -2
  73. package/helpers/ts-config-paths.js.map +1 -1
  74. package/helpers/workers.d.ts +20 -19
  75. package/helpers/workers.js +620 -3
  76. package/helpers/workers.js.map +1 -1
  77. package/hmr/client/css-handler.js +60 -19
  78. package/hmr/client/css-handler.js.map +1 -1
  79. package/hmr/client/hmr-pending-overlay.d.ts +27 -0
  80. package/hmr/client/hmr-pending-overlay.js +50 -0
  81. package/hmr/client/hmr-pending-overlay.js.map +1 -0
  82. package/hmr/client/index.js +597 -24
  83. package/hmr/client/index.js.map +1 -1
  84. package/hmr/client/utils.d.ts +5 -0
  85. package/hmr/client/utils.js +212 -21
  86. package/hmr/client/utils.js.map +1 -1
  87. package/hmr/entry-runtime.d.ts +10 -0
  88. package/hmr/entry-runtime.js +330 -42
  89. package/hmr/entry-runtime.js.map +1 -1
  90. package/hmr/frameworks/angular/client/index.d.ts +3 -1
  91. package/hmr/frameworks/angular/client/index.js +821 -25
  92. package/hmr/frameworks/angular/client/index.js.map +1 -1
  93. package/hmr/frameworks/angular/server/linker.js +37 -6
  94. package/hmr/frameworks/angular/server/linker.js.map +1 -1
  95. package/hmr/frameworks/angular/server/strategy.js +30 -6
  96. package/hmr/frameworks/angular/server/strategy.js.map +1 -1
  97. package/hmr/frameworks/typescript/server/strategy.js +8 -2
  98. package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
  99. package/hmr/frameworks/vue/client/index.js +18 -42
  100. package/hmr/frameworks/vue/client/index.js.map +1 -1
  101. package/hmr/helpers/ast-normalizer.js +22 -10
  102. package/hmr/helpers/ast-normalizer.js.map +1 -1
  103. package/hmr/helpers/cjs-named-exports.d.ts +23 -0
  104. package/hmr/helpers/cjs-named-exports.js +152 -0
  105. package/hmr/helpers/cjs-named-exports.js.map +1 -0
  106. package/hmr/server/constants.d.ts +1 -0
  107. package/hmr/server/constants.js +14 -3
  108. package/hmr/server/constants.js.map +1 -1
  109. package/hmr/server/core-sanitize.d.ts +49 -2
  110. package/hmr/server/core-sanitize.js +267 -24
  111. package/hmr/server/core-sanitize.js.map +1 -1
  112. package/hmr/server/import-map.d.ts +65 -0
  113. package/hmr/server/import-map.js +222 -0
  114. package/hmr/server/import-map.js.map +1 -0
  115. package/hmr/server/index.d.ts +2 -1
  116. package/hmr/server/index.js.map +1 -1
  117. package/hmr/server/ns-core-cjs-shape.d.ts +204 -0
  118. package/hmr/server/ns-core-cjs-shape.js +271 -0
  119. package/hmr/server/ns-core-cjs-shape.js.map +1 -0
  120. package/hmr/server/perf-instrumentation.d.ts +114 -0
  121. package/hmr/server/perf-instrumentation.js +195 -0
  122. package/hmr/server/perf-instrumentation.js.map +1 -0
  123. package/hmr/server/runtime-graph-filter.d.ts +5 -0
  124. package/hmr/server/runtime-graph-filter.js +21 -0
  125. package/hmr/server/runtime-graph-filter.js.map +1 -0
  126. package/hmr/server/shared-transform-request.d.ts +12 -0
  127. package/hmr/server/shared-transform-request.js +144 -0
  128. package/hmr/server/shared-transform-request.js.map +1 -0
  129. package/hmr/server/vite-plugin.d.ts +21 -1
  130. package/hmr/server/vite-plugin.js +461 -22
  131. package/hmr/server/vite-plugin.js.map +1 -1
  132. package/hmr/server/websocket-angular-entry.d.ts +2 -0
  133. package/hmr/server/websocket-angular-entry.js +68 -0
  134. package/hmr/server/websocket-angular-entry.js.map +1 -0
  135. package/hmr/server/websocket-angular-hot-update.d.ts +78 -0
  136. package/hmr/server/websocket-angular-hot-update.js +413 -0
  137. package/hmr/server/websocket-angular-hot-update.js.map +1 -0
  138. package/hmr/server/websocket-core-bridge.d.ts +21 -0
  139. package/hmr/server/websocket-core-bridge.js +357 -0
  140. package/hmr/server/websocket-core-bridge.js.map +1 -0
  141. package/hmr/server/websocket-graph-upsert.d.ts +21 -0
  142. package/hmr/server/websocket-graph-upsert.js +33 -0
  143. package/hmr/server/websocket-graph-upsert.js.map +1 -0
  144. package/hmr/server/websocket-hmr-pending.d.ts +43 -0
  145. package/hmr/server/websocket-hmr-pending.js +55 -0
  146. package/hmr/server/websocket-hmr-pending.js.map +1 -0
  147. package/hmr/server/websocket-module-bindings.d.ts +6 -0
  148. package/hmr/server/websocket-module-bindings.js +471 -0
  149. package/hmr/server/websocket-module-bindings.js.map +1 -0
  150. package/hmr/server/websocket-module-specifiers.d.ts +101 -0
  151. package/hmr/server/websocket-module-specifiers.js +820 -0
  152. package/hmr/server/websocket-module-specifiers.js.map +1 -0
  153. package/hmr/server/websocket-ns-m-finalize.d.ts +22 -0
  154. package/hmr/server/websocket-ns-m-finalize.js +88 -0
  155. package/hmr/server/websocket-ns-m-finalize.js.map +1 -0
  156. package/hmr/server/websocket-ns-m-paths.d.ts +3 -0
  157. package/hmr/server/websocket-ns-m-paths.js +92 -0
  158. package/hmr/server/websocket-ns-m-paths.js.map +1 -0
  159. package/hmr/server/websocket-ns-m-request.d.ts +45 -0
  160. package/hmr/server/websocket-ns-m-request.js +196 -0
  161. package/hmr/server/websocket-ns-m-request.js.map +1 -0
  162. package/hmr/server/websocket-runtime-compat.d.ts +19 -0
  163. package/hmr/server/websocket-runtime-compat.js +287 -0
  164. package/hmr/server/websocket-runtime-compat.js.map +1 -0
  165. package/hmr/server/websocket-served-module-helpers.d.ts +36 -0
  166. package/hmr/server/websocket-served-module-helpers.js +631 -0
  167. package/hmr/server/websocket-served-module-helpers.js.map +1 -0
  168. package/hmr/server/websocket-txn.d.ts +6 -0
  169. package/hmr/server/websocket-txn.js +45 -0
  170. package/hmr/server/websocket-txn.js.map +1 -0
  171. package/hmr/server/websocket-vendor-unifier.d.ts +10 -0
  172. package/hmr/server/websocket-vendor-unifier.js +51 -0
  173. package/hmr/server/websocket-vendor-unifier.js.map +1 -0
  174. package/hmr/server/websocket-vue-sfc.d.ts +27 -0
  175. package/hmr/server/websocket-vue-sfc.js +1069 -0
  176. package/hmr/server/websocket-vue-sfc.js.map +1 -0
  177. package/hmr/server/websocket.d.ts +26 -3
  178. package/hmr/server/websocket.js +2233 -796
  179. package/hmr/server/websocket.js.map +1 -1
  180. package/hmr/shared/package-classifier.d.ts +9 -0
  181. package/hmr/shared/package-classifier.js +58 -0
  182. package/hmr/shared/package-classifier.js.map +1 -0
  183. package/hmr/shared/runtime/boot-timeline.d.ts +17 -0
  184. package/hmr/shared/runtime/boot-timeline.js +51 -0
  185. package/hmr/shared/runtime/boot-timeline.js.map +1 -0
  186. package/hmr/shared/runtime/browser-runtime-contract.d.ts +64 -0
  187. package/hmr/shared/runtime/browser-runtime-contract.js +54 -0
  188. package/hmr/shared/runtime/browser-runtime-contract.js.map +1 -0
  189. package/hmr/shared/runtime/dev-overlay.d.ts +85 -0
  190. package/hmr/shared/runtime/dev-overlay.js +1236 -0
  191. package/hmr/shared/runtime/dev-overlay.js.map +1 -0
  192. package/hmr/shared/runtime/http-only-boot.d.ts +1 -0
  193. package/hmr/shared/runtime/http-only-boot.js +53 -6
  194. package/hmr/shared/runtime/http-only-boot.js.map +1 -1
  195. package/hmr/shared/runtime/module-provenance.d.ts +1 -0
  196. package/hmr/shared/runtime/module-provenance.js +63 -0
  197. package/hmr/shared/runtime/module-provenance.js.map +1 -0
  198. package/hmr/shared/runtime/platform-polyfills.d.ts +26 -0
  199. package/hmr/shared/runtime/platform-polyfills.js +122 -0
  200. package/hmr/shared/runtime/platform-polyfills.js.map +1 -0
  201. package/hmr/shared/runtime/root-placeholder.d.ts +1 -0
  202. package/hmr/shared/runtime/root-placeholder.js +552 -82
  203. package/hmr/shared/runtime/root-placeholder.js.map +1 -1
  204. package/hmr/shared/runtime/session-bootstrap.d.ts +1 -0
  205. package/hmr/shared/runtime/session-bootstrap.js +195 -0
  206. package/hmr/shared/runtime/session-bootstrap.js.map +1 -0
  207. package/hmr/shared/runtime/vendor-bootstrap.js +52 -15
  208. package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
  209. package/hmr/shared/vendor/manifest.d.ts +37 -0
  210. package/hmr/shared/vendor/manifest.js +677 -57
  211. package/hmr/shared/vendor/manifest.js.map +1 -1
  212. package/hmr/shared/vendor/registry.js +104 -7
  213. package/hmr/shared/vendor/registry.js.map +1 -1
  214. package/index.d.ts +1 -0
  215. package/index.js +5 -0
  216. package/index.js.map +1 -1
  217. package/package.json +14 -2
  218. package/runtime/core-aliases-early.js +94 -67
  219. package/runtime/core-aliases-early.js.map +1 -1
  220. package/shims/solid-jsx-runtime.d.ts +7 -0
  221. package/shims/solid-jsx-runtime.js +17 -0
  222. package/shims/solid-jsx-runtime.js.map +1 -0
@@ -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.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AAE,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"}
@@ -0,0 +1,3 @@
1
+ export declare function inlineDecoratorComponentTemplates(code: string, options: {
2
+ projectRoot: string;
3
+ }): string;