@nativescript/vite 8.0.0-alpha.3 → 8.0.0-alpha.30

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 (295) hide show
  1. package/README.md +51 -11
  2. package/configuration/angular.d.ts +34 -1
  3. package/configuration/angular.js +369 -159
  4. package/configuration/angular.js.map +1 -1
  5. package/configuration/base.js +184 -14
  6. package/configuration/base.js.map +1 -1
  7. package/configuration/javascript.js +5 -72
  8. package/configuration/javascript.js.map +1 -1
  9. package/configuration/solid.js +27 -1
  10. package/configuration/solid.js.map +1 -1
  11. package/configuration/typescript.js +5 -75
  12. package/configuration/typescript.js.map +1 -1
  13. package/helpers/angular/angular-linker.d.ts +5 -6
  14. package/helpers/angular/angular-linker.js +36 -121
  15. package/helpers/angular/angular-linker.js.map +1 -1
  16. package/helpers/angular/inject-component-hmr-registration.d.ts +112 -0
  17. package/helpers/angular/inject-component-hmr-registration.js +291 -0
  18. package/helpers/angular/inject-component-hmr-registration.js.map +1 -0
  19. package/helpers/angular/inject-hmr-vite-ignore.d.ts +75 -0
  20. package/helpers/angular/inject-hmr-vite-ignore.js +221 -0
  21. package/helpers/angular/inject-hmr-vite-ignore.js.map +1 -0
  22. package/helpers/angular/inline-decorator-component-templates.js +1 -170
  23. package/helpers/angular/inline-decorator-component-templates.js.map +1 -1
  24. package/helpers/angular/js-lexer.d.ts +4 -0
  25. package/helpers/angular/js-lexer.js +182 -0
  26. package/helpers/angular/js-lexer.js.map +1 -0
  27. package/helpers/angular/shared-linker.d.ts +31 -3
  28. package/helpers/angular/shared-linker.js +67 -14
  29. package/helpers/angular/shared-linker.js.map +1 -1
  30. package/helpers/angular/synthesize-decorator-ctor-parameters.js +2 -170
  31. package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +1 -1
  32. package/helpers/angular/synthesize-injectable-factories.js +1 -174
  33. package/helpers/angular/synthesize-injectable-factories.js.map +1 -1
  34. package/helpers/angular/util.d.ts +1 -0
  35. package/helpers/angular/util.js +88 -0
  36. package/helpers/angular/util.js.map +1 -1
  37. package/helpers/app-components.d.ts +2 -1
  38. package/helpers/app-components.js.map +1 -1
  39. package/helpers/app-css-state.d.ts +8 -0
  40. package/helpers/app-css-state.js +8 -0
  41. package/helpers/app-css-state.js.map +1 -0
  42. package/helpers/bundler-context.d.ts +11 -0
  43. package/helpers/bundler-context.js +71 -0
  44. package/helpers/bundler-context.js.map +1 -0
  45. package/helpers/config-as-json.js +10 -0
  46. package/helpers/config-as-json.js.map +1 -1
  47. package/helpers/dev-host.d.ts +341 -0
  48. package/helpers/dev-host.js +617 -0
  49. package/helpers/dev-host.js.map +1 -0
  50. package/helpers/esbuild-platform-resolver.js +4 -1
  51. package/helpers/esbuild-platform-resolver.js.map +1 -1
  52. package/helpers/global-defines.d.ts +51 -0
  53. package/helpers/global-defines.js +77 -0
  54. package/helpers/global-defines.js.map +1 -1
  55. package/helpers/hmr-scope.d.ts +26 -0
  56. package/helpers/hmr-scope.js +67 -0
  57. package/helpers/hmr-scope.js.map +1 -0
  58. package/helpers/init.js +0 -18
  59. package/helpers/init.js.map +1 -1
  60. package/helpers/logging.d.ts +1 -0
  61. package/helpers/logging.js +63 -3
  62. package/helpers/logging.js.map +1 -1
  63. package/helpers/main-entry.d.ts +2 -1
  64. package/helpers/main-entry.js +430 -47
  65. package/helpers/main-entry.js.map +1 -1
  66. package/helpers/nativeclass-esbuild-plugin.d.ts +2 -1
  67. package/helpers/nativeclass-esbuild-plugin.js.map +1 -1
  68. package/helpers/nativeclass-transform.js.map +1 -1
  69. package/helpers/nativeclass-transformer-plugin.d.ts +9 -2
  70. package/helpers/nativeclass-transformer-plugin.js +157 -14
  71. package/helpers/nativeclass-transformer-plugin.js.map +1 -1
  72. package/helpers/nativescript-package-resolver.js +8 -3
  73. package/helpers/nativescript-package-resolver.js.map +1 -1
  74. package/helpers/normalize-id.d.ts +42 -0
  75. package/helpers/normalize-id.js +60 -0
  76. package/helpers/normalize-id.js.map +1 -0
  77. package/helpers/ns-core-url.d.ts +88 -0
  78. package/helpers/ns-core-url.js +191 -0
  79. package/helpers/ns-core-url.js.map +1 -0
  80. package/helpers/package-platform-aliases.js +4 -3
  81. package/helpers/package-platform-aliases.js.map +1 -1
  82. package/helpers/platform-types.d.ts +2 -0
  83. package/helpers/platform-types.js +2 -0
  84. package/helpers/platform-types.js.map +1 -0
  85. package/helpers/prelink-angular.js +12 -33
  86. package/helpers/prelink-angular.js.map +1 -1
  87. package/helpers/project.d.ts +35 -0
  88. package/helpers/project.js +120 -2
  89. package/helpers/project.js.map +1 -1
  90. package/helpers/resolver.js +17 -2
  91. package/helpers/resolver.js.map +1 -1
  92. package/helpers/solid-jsx-deps.d.ts +15 -0
  93. package/helpers/solid-jsx-deps.js +178 -0
  94. package/helpers/solid-jsx-deps.js.map +1 -0
  95. package/helpers/ts-config-paths.d.ts +14 -0
  96. package/helpers/ts-config-paths.js +89 -8
  97. package/helpers/ts-config-paths.js.map +1 -1
  98. package/helpers/typescript-check.d.ts +2 -1
  99. package/helpers/typescript-check.js.map +1 -1
  100. package/helpers/workers.d.ts +20 -19
  101. package/helpers/workers.js +624 -4
  102. package/helpers/workers.js.map +1 -1
  103. package/hmr/client/css-handler.d.ts +1 -0
  104. package/hmr/client/css-handler.js +33 -20
  105. package/hmr/client/css-handler.js.map +1 -1
  106. package/hmr/client/css-update-overlay.d.ts +18 -0
  107. package/hmr/client/css-update-overlay.js +27 -0
  108. package/hmr/client/css-update-overlay.js.map +1 -0
  109. package/hmr/client/hmr-pending-overlay.d.ts +27 -0
  110. package/hmr/client/hmr-pending-overlay.js +50 -0
  111. package/hmr/client/hmr-pending-overlay.js.map +1 -0
  112. package/hmr/client/index.js +419 -15
  113. package/hmr/client/index.js.map +1 -1
  114. package/hmr/client/utils.d.ts +6 -1
  115. package/hmr/client/utils.js +184 -8
  116. package/hmr/client/utils.js.map +1 -1
  117. package/hmr/client/vue-sfc-update-overlay.d.ts +82 -0
  118. package/hmr/client/vue-sfc-update-overlay.js +133 -0
  119. package/hmr/client/vue-sfc-update-overlay.js.map +1 -0
  120. package/hmr/entry-runtime.d.ts +2 -1
  121. package/hmr/entry-runtime.js +252 -65
  122. package/hmr/entry-runtime.js.map +1 -1
  123. package/hmr/frameworks/angular/client/index.d.ts +1 -0
  124. package/hmr/frameworks/angular/client/index.js +778 -20
  125. package/hmr/frameworks/angular/client/index.js.map +1 -1
  126. package/hmr/frameworks/angular/server/linker.js +1 -4
  127. package/hmr/frameworks/angular/server/linker.js.map +1 -1
  128. package/hmr/frameworks/angular/server/strategy.js +13 -15
  129. package/hmr/frameworks/angular/server/strategy.js.map +1 -1
  130. package/hmr/frameworks/solid/server/strategy.js +3 -18
  131. package/hmr/frameworks/solid/server/strategy.js.map +1 -1
  132. package/hmr/frameworks/typescript/server/strategy.js +2 -15
  133. package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
  134. package/hmr/frameworks/vue/client/index.js +30 -199
  135. package/hmr/frameworks/vue/client/index.js.map +1 -1
  136. package/hmr/helpers/ast-normalizer.js +52 -5
  137. package/hmr/helpers/ast-normalizer.js.map +1 -1
  138. package/hmr/helpers/cjs-named-exports.d.ts +23 -0
  139. package/hmr/helpers/cjs-named-exports.js +152 -0
  140. package/hmr/helpers/cjs-named-exports.js.map +1 -0
  141. package/hmr/helpers/package-exports.d.ts +16 -0
  142. package/hmr/helpers/package-exports.js +396 -0
  143. package/hmr/helpers/package-exports.js.map +1 -0
  144. package/hmr/server/angular-root-component.d.ts +79 -0
  145. package/hmr/server/angular-root-component.js +149 -0
  146. package/hmr/server/angular-root-component.js.map +1 -0
  147. package/hmr/server/constants.js +13 -4
  148. package/hmr/server/constants.js.map +1 -1
  149. package/hmr/server/core-sanitize.d.ts +90 -7
  150. package/hmr/server/core-sanitize.js +211 -56
  151. package/hmr/server/core-sanitize.js.map +1 -1
  152. package/hmr/server/framework-strategy.d.ts +9 -19
  153. package/hmr/server/hmr-module-graph.d.ts +37 -0
  154. package/hmr/server/hmr-module-graph.js +214 -0
  155. package/hmr/server/hmr-module-graph.js.map +1 -0
  156. package/hmr/server/import-map.js +60 -8
  157. package/hmr/server/import-map.js.map +1 -1
  158. package/hmr/server/index.js +1 -0
  159. package/hmr/server/index.js.map +1 -1
  160. package/hmr/server/ns-core-cjs-shape.d.ts +204 -0
  161. package/hmr/server/ns-core-cjs-shape.js +271 -0
  162. package/hmr/server/ns-core-cjs-shape.js.map +1 -0
  163. package/hmr/server/ns-rt-bridge.d.ts +51 -0
  164. package/hmr/server/ns-rt-bridge.js +131 -0
  165. package/hmr/server/ns-rt-bridge.js.map +1 -0
  166. package/hmr/server/ns-rt-route.d.ts +5 -0
  167. package/hmr/server/ns-rt-route.js +35 -0
  168. package/hmr/server/ns-rt-route.js.map +1 -0
  169. package/hmr/server/perf-instrumentation.d.ts +114 -0
  170. package/hmr/server/perf-instrumentation.js +195 -0
  171. package/hmr/server/perf-instrumentation.js.map +1 -0
  172. package/hmr/server/require-guard.d.ts +1 -0
  173. package/hmr/server/require-guard.js +12 -0
  174. package/hmr/server/require-guard.js.map +1 -0
  175. package/hmr/server/route-helpers.d.ts +7 -0
  176. package/hmr/server/route-helpers.js +13 -0
  177. package/hmr/server/route-helpers.js.map +1 -0
  178. package/hmr/server/server-origin.d.ts +12 -0
  179. package/hmr/server/server-origin.js +66 -0
  180. package/hmr/server/server-origin.js.map +1 -0
  181. package/hmr/server/shared-transform-request.js +12 -5
  182. package/hmr/server/shared-transform-request.js.map +1 -1
  183. package/hmr/server/vendor-bare-module-shims.d.ts +4 -0
  184. package/hmr/server/vendor-bare-module-shims.js +80 -0
  185. package/hmr/server/vendor-bare-module-shims.js.map +1 -0
  186. package/hmr/server/vite-plugin.js +60 -42
  187. package/hmr/server/vite-plugin.js.map +1 -1
  188. package/hmr/server/websocket-angular-entry.js +1 -1
  189. package/hmr/server/websocket-angular-entry.js.map +1 -1
  190. package/hmr/server/websocket-angular-hot-update.d.ts +17 -0
  191. package/hmr/server/websocket-angular-hot-update.js +176 -2
  192. package/hmr/server/websocket-angular-hot-update.js.map +1 -1
  193. package/hmr/server/websocket-core-bridge.d.ts +41 -6
  194. package/hmr/server/websocket-core-bridge.js +72 -75
  195. package/hmr/server/websocket-core-bridge.js.map +1 -1
  196. package/hmr/server/websocket-css-hot-update.d.ts +33 -0
  197. package/hmr/server/websocket-css-hot-update.js +65 -0
  198. package/hmr/server/websocket-css-hot-update.js.map +1 -0
  199. package/hmr/server/websocket-device-transform.d.ts +21 -0
  200. package/hmr/server/websocket-device-transform.js +1570 -0
  201. package/hmr/server/websocket-device-transform.js.map +1 -0
  202. package/hmr/server/websocket-graph-upsert.d.ts +15 -0
  203. package/hmr/server/websocket-graph-upsert.js +20 -0
  204. package/hmr/server/websocket-graph-upsert.js.map +1 -1
  205. package/hmr/server/websocket-hmr-pending.d.ts +43 -0
  206. package/hmr/server/websocket-hmr-pending.js +55 -0
  207. package/hmr/server/websocket-hmr-pending.js.map +1 -0
  208. package/hmr/server/websocket-hot-update.d.ts +51 -0
  209. package/hmr/server/websocket-hot-update.js +1160 -0
  210. package/hmr/server/websocket-hot-update.js.map +1 -0
  211. package/hmr/server/websocket-import-map-route.d.ts +15 -0
  212. package/hmr/server/websocket-import-map-route.js +44 -0
  213. package/hmr/server/websocket-import-map-route.js.map +1 -0
  214. package/hmr/server/websocket-module-bindings.js +3 -3
  215. package/hmr/server/websocket-module-bindings.js.map +1 -1
  216. package/hmr/server/websocket-module-specifiers.d.ts +66 -2
  217. package/hmr/server/websocket-module-specifiers.js +202 -19
  218. package/hmr/server/websocket-module-specifiers.js.map +1 -1
  219. package/hmr/server/websocket-ns-core.d.ts +21 -0
  220. package/hmr/server/websocket-ns-core.js +305 -0
  221. package/hmr/server/websocket-ns-core.js.map +1 -0
  222. package/hmr/server/websocket-ns-entry.d.ts +22 -0
  223. package/hmr/server/websocket-ns-entry.js +150 -0
  224. package/hmr/server/websocket-ns-entry.js.map +1 -0
  225. package/hmr/server/websocket-ns-m-paths.d.ts +3 -0
  226. package/hmr/server/websocket-ns-m-paths.js +92 -0
  227. package/hmr/server/websocket-ns-m-paths.js.map +1 -0
  228. package/hmr/server/websocket-ns-m-request.d.ts +45 -0
  229. package/hmr/server/websocket-ns-m-request.js +196 -0
  230. package/hmr/server/websocket-ns-m-request.js.map +1 -0
  231. package/hmr/server/websocket-ns-m.d.ts +34 -0
  232. package/hmr/server/websocket-ns-m.js +853 -0
  233. package/hmr/server/websocket-ns-m.js.map +1 -0
  234. package/hmr/server/websocket-served-module-helpers.d.ts +39 -0
  235. package/hmr/server/websocket-served-module-helpers.js +654 -0
  236. package/hmr/server/websocket-served-module-helpers.js.map +1 -0
  237. package/hmr/server/websocket-sfc.d.ts +24 -0
  238. package/hmr/server/websocket-sfc.js +1223 -0
  239. package/hmr/server/websocket-sfc.js.map +1 -0
  240. package/hmr/server/websocket-txn.d.ts +6 -0
  241. package/hmr/server/websocket-txn.js +39 -0
  242. package/hmr/server/websocket-txn.js.map +1 -0
  243. package/hmr/server/websocket-vendor-unifier.d.ts +10 -0
  244. package/hmr/server/websocket-vendor-unifier.js +45 -0
  245. package/hmr/server/websocket-vendor-unifier.js.map +1 -0
  246. package/hmr/server/websocket.d.ts +0 -30
  247. package/hmr/server/websocket.js +599 -6038
  248. package/hmr/server/websocket.js.map +1 -1
  249. package/hmr/shared/runtime/boot-placeholder-ui.d.ts +69 -0
  250. package/hmr/shared/runtime/boot-placeholder-ui.js +101 -0
  251. package/hmr/shared/runtime/boot-placeholder-ui.js.map +1 -0
  252. package/hmr/shared/runtime/boot-progress.d.ts +40 -0
  253. package/hmr/shared/runtime/boot-progress.js +128 -0
  254. package/hmr/shared/runtime/boot-progress.js.map +1 -0
  255. package/hmr/shared/runtime/boot-timeline.d.ts +18 -0
  256. package/hmr/shared/runtime/boot-timeline.js +52 -0
  257. package/hmr/shared/runtime/boot-timeline.js.map +1 -0
  258. package/hmr/shared/runtime/dev-overlay-snapshots.d.ts +31 -0
  259. package/hmr/shared/runtime/dev-overlay-snapshots.js +324 -0
  260. package/hmr/shared/runtime/dev-overlay-snapshots.js.map +1 -0
  261. package/hmr/shared/runtime/dev-overlay.d.ts +75 -26
  262. package/hmr/shared/runtime/dev-overlay.js +990 -260
  263. package/hmr/shared/runtime/dev-overlay.js.map +1 -1
  264. package/hmr/shared/runtime/module-provenance.js +1 -4
  265. package/hmr/shared/runtime/module-provenance.js.map +1 -1
  266. package/hmr/shared/runtime/root-placeholder-view.d.ts +19 -0
  267. package/hmr/shared/runtime/root-placeholder-view.js +310 -0
  268. package/hmr/shared/runtime/root-placeholder-view.js.map +1 -0
  269. package/hmr/shared/runtime/root-placeholder.js +352 -194
  270. package/hmr/shared/runtime/root-placeholder.js.map +1 -1
  271. package/hmr/shared/runtime/session-bootstrap.js +164 -1
  272. package/hmr/shared/runtime/session-bootstrap.js.map +1 -1
  273. package/hmr/shared/runtime/vendor-bootstrap.js +1 -9
  274. package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
  275. package/hmr/shared/vendor/manifest-collect.d.ts +32 -0
  276. package/hmr/shared/vendor/manifest-collect.js +512 -0
  277. package/hmr/shared/vendor/manifest-collect.js.map +1 -0
  278. package/hmr/shared/vendor/manifest-loader.d.ts +2 -1
  279. package/hmr/shared/vendor/manifest-loader.js +3 -2
  280. package/hmr/shared/vendor/manifest-loader.js.map +1 -1
  281. package/hmr/shared/vendor/manifest.d.ts +1 -5
  282. package/hmr/shared/vendor/manifest.js +102 -739
  283. package/hmr/shared/vendor/manifest.js.map +1 -1
  284. package/hmr/shared/vendor/vendor-device-shim.d.ts +1 -0
  285. package/hmr/shared/vendor/vendor-device-shim.js +208 -0
  286. package/hmr/shared/vendor/vendor-device-shim.js.map +1 -0
  287. package/hmr/shared/vendor/vendor-esbuild-plugins.d.ts +16 -0
  288. package/hmr/shared/vendor/vendor-esbuild-plugins.js +203 -0
  289. package/hmr/shared/vendor/vendor-esbuild-plugins.js.map +1 -0
  290. package/index.d.ts +1 -0
  291. package/index.js +5 -0
  292. package/index.js.map +1 -1
  293. package/package.json +55 -11
  294. package/runtime/core-aliases-early.js +17 -41
  295. package/runtime/core-aliases-early.js.map +1 -1
@@ -0,0 +1,152 @@
1
+ // Runtime-enumerated CommonJS named exports for the HMR `/ns/m` pipeline.
2
+ //
3
+ // Why this exists:
4
+ // V8's HTTP-imported ES module loader (the device's `http-esm` mode) requires
5
+ // named exports to be declared statically at parse time. Many real-world npm
6
+ // packages do not declare their public surface statically — the canonical
7
+ // example is lodash:
8
+ //
9
+ // (freeModule.exports = _)._ = _;
10
+ //
11
+ // At parse time there are zero `exports.foo = ...` or
12
+ // `Object.defineProperty(exports, 'foo', ...)` patterns. Lodash builds its
13
+ // public surface dynamically inside an IIFE and attaches every method to a
14
+ // function object that is then assigned to `module.exports`. Neither a
15
+ // regex nor an AST can statically determine that lodash exposes
16
+ // `capitalize`, `chunk`, `debounce`, etc.
17
+ //
18
+ // The only correct way to enumerate this kind of CJS module's public
19
+ // surface is to actually load it in the dev server's Node context and ask
20
+ // `Object.keys(...)`. This is exactly what esbuild and Vite do at build
21
+ // time when they pre-bundle CJS deps for an ESM consumer; this helper
22
+ // brings the same strategy to the HMR served-module pipeline so that
23
+ // `import { capitalize } from 'lodash'` succeeds even when lodash is not
24
+ // pre-bundled by Vite.
25
+ //
26
+ // Safety:
27
+ // - Only call this for modules under `node_modules` (we never execute user
28
+ // source code via this path).
29
+ // - Wrap in try/catch — some npm packages throw at load time (missing peer
30
+ // deps, browser-only globals, side effects). On any failure we return an
31
+ // empty list and the caller falls back to whatever it could detect
32
+ // statically.
33
+ // - Cache by absolute path so a second HMR request for the same module is
34
+ // free.
35
+ import { createRequire } from 'node:module';
36
+ import * as path from 'node:path';
37
+ import * as fs from 'node:fs';
38
+ const cache = new Map();
39
+ const RESERVED = new Set(['default', '__esModule']);
40
+ // `Object.getOwnPropertyNames` on a function exposes these implementation
41
+ // details — they are not real exports.
42
+ const FUNCTION_INTERNAL = new Set(['length', 'name', 'prototype', 'arguments', 'caller']);
43
+ const VALID_IDENT = /^[A-Za-z_$][\w$]*$/;
44
+ export function clearCjsNamedExportsCache(filePath) {
45
+ if (!filePath) {
46
+ cache.clear();
47
+ }
48
+ else {
49
+ cache.delete(filePath);
50
+ }
51
+ }
52
+ export function getCjsNamedExportsCacheSize() {
53
+ return cache.size;
54
+ }
55
+ /**
56
+ * Normalize a path that may have come from a Vite-resolved id (e.g.
57
+ * `/@fs/Users/.../node_modules/foo/index.js?import`) into a plain
58
+ * absolute filesystem path that `createRequire` can load.
59
+ *
60
+ * Returns null if the path does not look like an absolute filesystem
61
+ * path that exists on disk.
62
+ */
63
+ export function normalizeAbsolutePathForRequire(input) {
64
+ if (!input)
65
+ return null;
66
+ let s = String(input).replace(/[?#].*$/, '');
67
+ // Vite serves absolute paths as `/@fs/<absolute>`; strip the prefix.
68
+ if (s.startsWith('/@fs/')) {
69
+ s = s.slice('/@fs'.length);
70
+ }
71
+ if (!path.isAbsolute(s))
72
+ return null;
73
+ try {
74
+ if (!fs.statSync(s).isFile())
75
+ return null;
76
+ }
77
+ catch {
78
+ return null;
79
+ }
80
+ return s;
81
+ }
82
+ /**
83
+ * Enumerate the named exports of a CommonJS module by loading it in the
84
+ * dev server's Node context.
85
+ *
86
+ * Returns an empty array if the module can't be loaded, isn't in
87
+ * node_modules, or doesn't expose any enumerable string-keyed properties
88
+ * that look like JS identifiers.
89
+ *
90
+ * Results are cached by absolute path. Pass `clearCjsNamedExportsCache()`
91
+ * if you need to invalidate (e.g. between tests).
92
+ */
93
+ export function getCjsNamedExports(absolutePath) {
94
+ const normalized = normalizeAbsolutePathForRequire(absolutePath);
95
+ if (!normalized)
96
+ return [];
97
+ // Only enumerate node_modules paths — never execute user source via this code path.
98
+ if (!/(?:^|\/)node_modules\//.test(normalized))
99
+ return [];
100
+ const cached = cache.get(normalized);
101
+ if (cached !== undefined)
102
+ return cached || [];
103
+ let names = null;
104
+ try {
105
+ // `createRequire` needs a path that itself exists; the file we are
106
+ // enumerating is a fine anchor. The cwd of the require base is its
107
+ // parent directory, which matters for nested workspace resolution.
108
+ const req = createRequire(normalized);
109
+ const mod = req(normalized);
110
+ const collected = new Set();
111
+ const isFn = typeof mod === 'function';
112
+ if (mod && (typeof mod === 'object' || isFn)) {
113
+ // `Object.keys` returns enumerable own props — covers most CJS modules
114
+ // where named exports are real properties on the exports object.
115
+ try {
116
+ for (const k of Object.keys(mod)) {
117
+ if (!RESERVED.has(k) && VALID_IDENT.test(k))
118
+ collected.add(k);
119
+ }
120
+ }
121
+ catch {
122
+ /* exotic proxy etc. */
123
+ }
124
+ // `Object.getOwnPropertyNames` covers non-enumerable own props too.
125
+ // Lodash attaches a few methods that aren't enumerable; more importantly
126
+ // some packages mark exports non-enumerable on purpose.
127
+ try {
128
+ for (const k of Object.getOwnPropertyNames(mod)) {
129
+ if (RESERVED.has(k) || !VALID_IDENT.test(k))
130
+ continue;
131
+ if (isFn && FUNCTION_INTERNAL.has(k))
132
+ continue;
133
+ collected.add(k);
134
+ }
135
+ }
136
+ catch {
137
+ /* exotic */
138
+ }
139
+ names = Array.from(collected);
140
+ }
141
+ else {
142
+ // Primitive default export (e.g. `module.exports = 'hello'`). No named exports possible.
143
+ names = [];
144
+ }
145
+ }
146
+ catch {
147
+ names = null;
148
+ }
149
+ cache.set(normalized, names);
150
+ return names || [];
151
+ }
152
+ //# sourceMappingURL=cjs-named-exports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cjs-named-exports.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/helpers/cjs-named-exports.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,EAAE;AACF,mBAAmB;AACnB,8EAA8E;AAC9E,6EAA6E;AAC7E,0EAA0E;AAC1E,qBAAqB;AACrB,EAAE;AACF,oCAAoC;AACpC,EAAE;AACF,sDAAsD;AACtD,2EAA2E;AAC3E,2EAA2E;AAC3E,uEAAuE;AACvE,gEAAgE;AAChE,0CAA0C;AAC1C,EAAE;AACF,qEAAqE;AACrE,0EAA0E;A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,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;oBAClC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;wBAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;gBAC/D,CAAC;YACF,CAAC;YAAC,MAAM,CAAC;gBACR,uBAAuB;YACxB,CAAC;YACD,oEAAoE;YACpE,yEAAyE;YACzE,wDAAwD;YACxD,IAAI,CAAC;gBACJ,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAC,EAAE,CAAC;oBACjD,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;wBAAE,SAAS;oBACtD,IAAI,IAAI,IAAI,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC;wBAAE,SAAS;oBAC/C,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;gBAClB,CAAC;YACF,CAAC;YAAC,MAAM,CAAC;gBACR,YAAY;YACb,CAAC;YACD,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC/B,CAAC;aAAM,CAAC;YACP,yFAAyF;YACzF,KAAK,GAAG,EAAE,CAAC;QACZ,CAAC;IACF,CAAC;IAAC,MAAM,CAAC;QACR,KAAK,GAAG,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAC7B,OAAO,KAAK,IAAI,EAAE,CAAC;AACpB,CAAC"}
@@ -0,0 +1,16 @@
1
+ export interface PackageExportShape {
2
+ /** Union of every named export reachable from the package entry, minus `default`. */
3
+ names: Set<string>;
4
+ /** True if any visited file emits a `default` export. */
5
+ hasDefault: boolean;
6
+ /** Absolute path to the resolved entry file (empty string when the package could not be resolved). */
7
+ entry: string;
8
+ /** Files visited during the walk — useful for diagnostics and cache invalidation. */
9
+ visitedFiles: string[];
10
+ }
11
+ /**
12
+ * Clear the cache. Tests use this to assert determinism; production code
13
+ * never needs it (the cache is intentionally process-lifetime).
14
+ */
15
+ export declare function __clearPackageExportsCache(): void;
16
+ export declare function enumeratePackageExports(packageId: string, projectRoot: string): PackageExportShape;
@@ -0,0 +1,396 @@
1
+ // Static export-surface enumerator for the single-realm HTTP-ESM bridge.
2
+ //
3
+ // The HMR runtime serves canonical bridge specifiers (e.g. `/ns/rt` for
4
+ // `nativescript-vue`) that fan out to the device's vendor registry so that
5
+ // app code, plugins, and the vendor bundle itself share one module record
6
+ // per package. The bridge module must therefore re-export every public
7
+ // symbol the underlying package offers — otherwise consumers fall back to
8
+ // `undefined` for any export the bridge author forgot to enumerate, and the
9
+ // failure only surfaces at the call site (often deep inside a UI event
10
+ // handler) as `TypeError: <name> is not a function`.
11
+ //
12
+ // Hand-curated re-export lists are the source of that bug class. This
13
+ // helper replaces them with a deterministic walk of the package's static
14
+ // ESM export graph:
15
+ //
16
+ // 1. Resolve the package's `main` entry from the project's `node_modules`.
17
+ // 2. Parse with Babel and collect every named export — both inline
18
+ // (`export const x = …`, `export function y() {}`, `export { z }`) and
19
+ // re-exported (`export { a, b as c } from './foo'`).
20
+ // 3. Recurse into `export * from <spec>`, following both relative paths
21
+ // and bare package specifiers (so `export * from '@vue/runtime-core'`
22
+ // contributes the full Vue runtime API too).
23
+ // 4. Cache the result by `${projectRoot}::${packageId}` — the walk
24
+ // touches dozens of files for `nativescript-vue` and we want one walk
25
+ // per dev session, not per request.
26
+ //
27
+ // The walker is intentionally permissive: parse errors and unresolvable
28
+ // specifiers are swallowed (continue with what we have). The caller decides
29
+ // what to do if the surface comes back empty (typically: fall back to a
30
+ // known-good baseline list rather than emit a stub bridge).
31
+ import { parse as babelParse } from '@babel/parser';
32
+ import { readFileSync, existsSync, realpathSync } from 'fs';
33
+ import path from 'path';
34
+ import { createRequire } from 'node:module';
35
+ const cache = new Map();
36
+ /**
37
+ * Clear the cache. Tests use this to assert determinism; production code
38
+ * never needs it (the cache is intentionally process-lifetime).
39
+ */
40
+ export function __clearPackageExportsCache() {
41
+ cache.clear();
42
+ }
43
+ export function enumeratePackageExports(packageId, projectRoot) {
44
+ const root = path.resolve(projectRoot || process.cwd());
45
+ const cacheKey = `${root}::${packageId}`;
46
+ const cached = cache.get(cacheKey);
47
+ if (cached)
48
+ return cached;
49
+ const result = {
50
+ names: new Set(),
51
+ hasDefault: false,
52
+ entry: '',
53
+ visitedFiles: [],
54
+ };
55
+ const rootRequire = createRequireFromDir(root);
56
+ const entry = resolvePackageEsmEntry(packageId, rootRequire);
57
+ if (!entry) {
58
+ cache.set(cacheKey, result);
59
+ return result;
60
+ }
61
+ result.entry = entry;
62
+ const visited = new Set();
63
+ const queue = [entry];
64
+ while (queue.length) {
65
+ const file = queue.shift();
66
+ const real = safeRealpath(file);
67
+ if (visited.has(real))
68
+ continue;
69
+ visited.add(real);
70
+ result.visitedFiles.push(real);
71
+ const source = readFileSafe(real);
72
+ if (source === null)
73
+ continue;
74
+ const program = parseModule(source);
75
+ if (!program)
76
+ continue;
77
+ const dir = path.dirname(real);
78
+ const localRequire = createRequireFromFile(real);
79
+ for (const node of program.body) {
80
+ collectExportsFromNode(node, result, (spec) => {
81
+ const next = resolveSpec(spec, dir, localRequire);
82
+ if (next)
83
+ queue.push(next);
84
+ });
85
+ }
86
+ }
87
+ cache.set(cacheKey, result);
88
+ return result;
89
+ }
90
+ function collectExportsFromNode(node, out, queueReExportSource) {
91
+ if (node.type === 'ExportNamedDeclaration') {
92
+ // `export const x = …`, `export function y() {}`, `export class Z {}`
93
+ const decl = node.declaration;
94
+ if (decl) {
95
+ if (decl.declarations) {
96
+ for (const d of decl.declarations) {
97
+ addId(out.names, d?.id);
98
+ }
99
+ }
100
+ else if (decl.id?.name) {
101
+ out.names.add(decl.id.name);
102
+ }
103
+ }
104
+ // `export { a, b as c }` and `export { a } from './foo'`
105
+ for (const spec of (node.specifiers || [])) {
106
+ const exportedName = spec?.exported?.name ?? spec?.exported?.value;
107
+ if (exportedName === 'default') {
108
+ out.hasDefault = true;
109
+ }
110
+ else if (exportedName) {
111
+ out.names.add(String(exportedName));
112
+ }
113
+ }
114
+ // `export … from <source>` — we already captured the explicit names above,
115
+ // but we still need to recurse if there's a `*` re-export hiding inside
116
+ // (Babel models that as `ExportAllDeclaration`, handled below). Nothing to do here.
117
+ }
118
+ else if (node.type === 'ExportAllDeclaration') {
119
+ // `export * from <source>` — recurse.
120
+ // `export * as ns from <source>` adds a named binding `ns` instead of fanning out.
121
+ const src = node.source?.value;
122
+ const asName = node.exported?.name;
123
+ if (asName) {
124
+ if (asName !== 'default')
125
+ out.names.add(String(asName));
126
+ }
127
+ else if (src) {
128
+ queueReExportSource(src);
129
+ }
130
+ }
131
+ else if (node.type === 'ExportDefaultDeclaration') {
132
+ out.hasDefault = true;
133
+ }
134
+ }
135
+ function addId(names, idNode) {
136
+ if (!idNode)
137
+ return;
138
+ if (idNode.type === 'Identifier' && idNode.name) {
139
+ names.add(idNode.name);
140
+ return;
141
+ }
142
+ if (idNode.type === 'ObjectPattern') {
143
+ for (const prop of idNode.properties || []) {
144
+ if (prop.type === 'ObjectProperty')
145
+ addId(names, prop.value);
146
+ else if (prop.type === 'RestElement')
147
+ addId(names, prop.argument);
148
+ }
149
+ return;
150
+ }
151
+ if (idNode.type === 'ArrayPattern') {
152
+ for (const el of idNode.elements || [])
153
+ addId(names, el);
154
+ return;
155
+ }
156
+ if (idNode.type === 'AssignmentPattern') {
157
+ addId(names, idNode.left);
158
+ }
159
+ }
160
+ function parseModule(source) {
161
+ try {
162
+ const ast = babelParse(source, {
163
+ sourceType: 'module',
164
+ plugins: ['typescript', 'jsx', 'importMeta', 'topLevelAwait', 'decorators-legacy', 'classProperties', 'classPrivateProperties', 'classPrivateMethods'],
165
+ errorRecovery: true,
166
+ allowReturnOutsideFunction: true,
167
+ allowUndeclaredExports: true,
168
+ });
169
+ return ast.program;
170
+ }
171
+ catch {
172
+ return null;
173
+ }
174
+ }
175
+ function resolveSpec(spec, dir, localRequire) {
176
+ if (!spec)
177
+ return null;
178
+ if (spec.startsWith('.')) {
179
+ return resolveRelative(dir, spec);
180
+ }
181
+ if (spec.startsWith('/')) {
182
+ return existsSync(spec) ? spec : null;
183
+ }
184
+ // Bare specifier (e.g. `@vue/runtime-core` from inside `nativescript-vue`).
185
+ // `createRequire.resolve()` is CJS-first and follows the package's `main`
186
+ // field, which for dual-format packages like `@vue/runtime-core` points at
187
+ // a CommonJS shim (`module.exports = require('./dist/…cjs.js')`) — parsing
188
+ // that as ESM yields zero exports and we silently drop the entire
189
+ // re-export chain. Use the ESM-aware resolver instead so we land on the
190
+ // actual `dist/…esm-bundler.js` advertised by `exports[".module"]` /
191
+ // `module`, where `export { ref, computed, … }` lives.
192
+ if (localRequire) {
193
+ return resolvePackageEsmEntry(spec, localRequire);
194
+ }
195
+ return null;
196
+ }
197
+ /**
198
+ * Resolve a bare specifier to its ESM entry file by consulting the package's
199
+ * own `package.json` ESM hints — in priority order:
200
+ *
201
+ * 1. `exports[<sub>].module` (Vue, modern dual-format packages)
202
+ * 2. `exports[<sub>].import`
203
+ * 3. `exports[<sub>]` shorthand (string form)
204
+ * 4. top-level `module` field (older dual-format convention)
205
+ * 5. top-level `main` (last resort; may be CJS — we'll parse what we get)
206
+ *
207
+ * `<sub>` is either `"."` (root entry) or `"./relative/subpath"`. Anything not
208
+ * declared in `exports` falls back to plain CJS resolution.
209
+ *
210
+ * Returns the absolute file path, or `null` if the package can't be located.
211
+ */
212
+ function resolvePackageEsmEntry(spec, localRequire) {
213
+ const { packageName, subpath } = splitBareSpec(spec);
214
+ if (!packageName)
215
+ return null;
216
+ // Locate the package's `package.json` from the calling file's vantage point.
217
+ // Node ≥ 18.6 has `require.resolve('<pkg>/package.json')` working for almost
218
+ // every layout (including pnpm hoisted/nested), provided the package
219
+ // declares `package.json` reachable (it is, by default). If the package
220
+ // opts out of exposing it via `exports`, fall back to walking up from any
221
+ // resolvable entry.
222
+ let pkgJsonPath = safeResolve(localRequire, `${packageName}/package.json`);
223
+ if (!pkgJsonPath) {
224
+ const someEntry = safeResolve(localRequire, spec);
225
+ if (someEntry)
226
+ pkgJsonPath = findPackageJsonUpward(someEntry, packageName);
227
+ }
228
+ if (!pkgJsonPath)
229
+ return null;
230
+ const pkgDir = path.dirname(pkgJsonPath);
231
+ const pkg = readJsonSafe(pkgJsonPath);
232
+ if (!pkg)
233
+ return null;
234
+ const subKey = subpath ? `./${subpath}` : '.';
235
+ const esmRelative = pickEsmEntryFromManifest(pkg, subKey);
236
+ if (esmRelative) {
237
+ const resolved = resolveRelativeInsidePackage(pkgDir, esmRelative);
238
+ if (resolved)
239
+ return resolved;
240
+ }
241
+ // Last-resort fallback: ordinary CJS resolution. Parsing may yield zero
242
+ // exports (the file is genuinely CJS) — that's acceptable; the caller
243
+ // treats an empty contribution as "this package adds nothing" rather than
244
+ // erroring out.
245
+ return safeResolve(localRequire, spec);
246
+ }
247
+ function splitBareSpec(spec) {
248
+ if (spec.startsWith('@')) {
249
+ const parts = spec.split('/');
250
+ if (parts.length < 2)
251
+ return { packageName: '', subpath: '' };
252
+ return { packageName: `${parts[0]}/${parts[1]}`, subpath: parts.slice(2).join('/') };
253
+ }
254
+ const slash = spec.indexOf('/');
255
+ if (slash === -1)
256
+ return { packageName: spec, subpath: '' };
257
+ return { packageName: spec.slice(0, slash), subpath: spec.slice(slash + 1) };
258
+ }
259
+ function readJsonSafe(file) {
260
+ try {
261
+ return JSON.parse(readFileSync(file, 'utf-8'));
262
+ }
263
+ catch {
264
+ return null;
265
+ }
266
+ }
267
+ function pickEsmEntryFromManifest(pkg, subKey) {
268
+ const exportsField = pkg?.exports;
269
+ if (exportsField && typeof exportsField === 'object') {
270
+ const entry = exportsField[subKey];
271
+ const fromConditional = pickEsmFromConditionalExports(entry);
272
+ if (fromConditional)
273
+ return fromConditional;
274
+ }
275
+ // `exports` as a bare string only applies to the `.` subpath.
276
+ if (typeof exportsField === 'string' && subKey === '.')
277
+ return exportsField;
278
+ if (subKey === '.') {
279
+ if (typeof pkg?.module === 'string')
280
+ return pkg.module;
281
+ if (typeof pkg?.main === 'string')
282
+ return pkg.main;
283
+ // CommonJS-only packages frequently omit `main`; Node defaults to `index.js`.
284
+ return 'index.js';
285
+ }
286
+ // Subpath without an `exports` mapping: caller falls through to CJS resolution.
287
+ return null;
288
+ }
289
+ function pickEsmFromConditionalExports(entry) {
290
+ if (!entry)
291
+ return null;
292
+ if (typeof entry === 'string')
293
+ return entry;
294
+ if (typeof entry !== 'object')
295
+ return null;
296
+ // Prefer `module` (the de-facto "ESM bundler" condition that Vue, lit,
297
+ // preact etc. ship), then `import`, then `default`. Skip `node`/`require`
298
+ // because those usually point at the CJS shim we're explicitly avoiding.
299
+ for (const key of ['module', 'import', 'default']) {
300
+ const value = entry[key];
301
+ if (typeof value === 'string')
302
+ return value;
303
+ if (value && typeof value === 'object') {
304
+ const nested = pickEsmFromConditionalExports(value);
305
+ if (nested)
306
+ return nested;
307
+ }
308
+ }
309
+ return null;
310
+ }
311
+ function resolveRelativeInsidePackage(pkgDir, rel) {
312
+ const trimmed = rel.replace(/^\.\//, '');
313
+ const candidates = [trimmed, `${trimmed}.js`, `${trimmed}.mjs`, `${trimmed}.cjs`, `${trimmed}/index.js`, `${trimmed}/index.mjs`];
314
+ for (const c of candidates) {
315
+ const p = path.join(pkgDir, c);
316
+ if (existsSync(p))
317
+ return safeRealpath(p);
318
+ }
319
+ return null;
320
+ }
321
+ function findPackageJsonUpward(startFile, expectedName) {
322
+ let dir = path.dirname(startFile);
323
+ const root = path.parse(dir).root;
324
+ while (dir && dir !== root) {
325
+ const candidate = path.join(dir, 'package.json');
326
+ if (existsSync(candidate)) {
327
+ const pkg = readJsonSafe(candidate);
328
+ if (pkg?.name === expectedName)
329
+ return candidate;
330
+ }
331
+ const next = path.dirname(dir);
332
+ if (next === dir)
333
+ break;
334
+ dir = next;
335
+ }
336
+ return null;
337
+ }
338
+ function resolveRelative(dir, spec) {
339
+ const base = path.resolve(dir, spec);
340
+ const candidates = ['', '.js', '.mjs', '.cjs', '/index.js', '/index.mjs', '/index.cjs'];
341
+ for (const ext of candidates) {
342
+ const p = base + ext;
343
+ try {
344
+ if (existsSync(p)) {
345
+ const real = safeRealpath(p);
346
+ // Skip directories returned by `existsSync` without an index file fallback.
347
+ try {
348
+ const stat = readFileSafe(real);
349
+ if (stat !== null)
350
+ return real;
351
+ }
352
+ catch { }
353
+ }
354
+ }
355
+ catch { }
356
+ }
357
+ return null;
358
+ }
359
+ function safeResolve(req, spec) {
360
+ try {
361
+ return req.resolve(spec);
362
+ }
363
+ catch {
364
+ return null;
365
+ }
366
+ }
367
+ function createRequireFromDir(dir) {
368
+ // `createRequire` wants a file path; we pass a synthetic file under the
369
+ // dir so resolution starts there.
370
+ return createRequire(path.join(dir, 'package.json'));
371
+ }
372
+ function createRequireFromFile(file) {
373
+ try {
374
+ return createRequire(file);
375
+ }
376
+ catch {
377
+ return null;
378
+ }
379
+ }
380
+ function safeRealpath(file) {
381
+ try {
382
+ return realpathSync(file);
383
+ }
384
+ catch {
385
+ return file;
386
+ }
387
+ }
388
+ function readFileSafe(file) {
389
+ try {
390
+ return readFileSync(file, 'utf-8');
391
+ }
392
+ catch {
393
+ return null;
394
+ }
395
+ }
396
+ //# sourceMappingURL=package-exports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-exports.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/helpers/package-exports.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,EAAE;AACF,wEAAwE;AACxE,2EAA2E;AAC3E,0EAA0E;AAC1E,uEAAuE;AACvE,0EAA0E;AAC1E,4EAA4E;AAC5E,uEAAuE;AACvE,qDAAqD;AACrD,EAAE;AACF,sEAAsE;AACtE,yEAAyE;AACzE,oBAAoB;AACpB,EAAE;AACF,6EAA6E;AAC7E,qEAA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,SAAS,YAAY,CAAC,IAAY;IACjC,IAAI,CAAC;QACJ,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,IAAI,CAAC;IACb,CAAC;AACF,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IACjC,IAAI,CAAC;QACJ,OAAO,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,IAAI,CAAC;IACb,CAAC;AACF,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Identifies the Angular **bootstrap (root) component** of a project from
3
+ * its dev-server entry module, and provides helpers to match Analog's
4
+ * `angular:component-update` events against it.
5
+ *
6
+ * Why this exists
7
+ * ---------------
8
+ * NativeScript's root Angular component hosts the navigation `Frame` (via
9
+ * `<page-router-outlet>`). Analog's in-place template HMR
10
+ * (`ɵɵreplaceMetadata`) recreates the matching `LView`s for the edited
11
+ * component WITHOUT re-running router navigation. For a normal child
12
+ * component that's exactly right — its view re-renders inside an intact
13
+ * page. For the ROOT component it's fatal: replacing the root metadata
14
+ * tears down the `PageRouterOutlet`'s `Frame` and nothing re-navigates,
15
+ * leaving a permanent blank/white screen that no further in-place update
16
+ * can recover.
17
+ *
18
+ * The reboot path (`ns:angular-update` → `__reboot_ng_modules__`) DOES
19
+ * recover the root view (it re-bootstraps and replays route state). So the
20
+ * fix is to route every root-component edit through the reboot path and
21
+ * suppress the destructive in-place update for it. Both halves need to know
22
+ * which file is the root component — that's what this module resolves.
23
+ *
24
+ * Resolution is intentionally dependency-free string/path math so it can be
25
+ * unit-tested without a Vite server or filesystem. It targets the modern
26
+ * standalone bootstrap shape (`bootstrapApplication(AppComponent, …)`),
27
+ * which is what `main.ts` uses; it degrades gracefully to `null` for shapes
28
+ * it can't statically resolve (e.g. NgModule `bootstrap: [...]`), in which
29
+ * case callers keep their existing behavior.
30
+ */
31
+ export interface BootstrapRootComponent {
32
+ /**
33
+ * Extensionless, project-relative POSIX path with a leading slash —
34
+ * e.g. `/src/app/app.component`. Comparisons are always extensionless so
35
+ * a `.html` template edit and its `.ts` component resolve to the same key.
36
+ */
37
+ moduleRel: string;
38
+ /**
39
+ * The class name passed to `bootstrapApplication(...)` (best-effort,
40
+ * resolved back to the imported binding name when aliased). Used as a
41
+ * secondary match signal for Analog ids whose path base differs from the
42
+ * project root.
43
+ */
44
+ className: string;
45
+ }
46
+ /**
47
+ * Normalizes any project-relative path to a leading-slash, extensionless
48
+ * POSIX key suitable for equality comparison between a `.html`/`.ts` edit
49
+ * and the resolved root component.
50
+ */
51
+ export declare function toExtensionlessModuleRel(rel: string): string;
52
+ /** True when two project-relative paths refer to the same module (ignoring extension). */
53
+ export declare function isSameAngularModuleRel(a: string | null | undefined, b: string | null | undefined): boolean;
54
+ /**
55
+ * Resolves the bootstrap root component from a dev-server entry module's
56
+ * source. Returns `null` when the bootstrap shape can't be statically
57
+ * resolved (callers should then keep their default behavior).
58
+ */
59
+ export declare function resolveBootstrapRootComponent(options: {
60
+ entrySource: string;
61
+ entryRel: string;
62
+ appRootRel?: string;
63
+ }): BootstrapRootComponent | null;
64
+ /**
65
+ * Decodes Analog's `angular:component-update` payload `id`
66
+ * (`encodeURIComponent(relativePath + '@' + className)`) into a normalized,
67
+ * extensionless module rel plus the class name, so the bridge can compare it
68
+ * against the resolved root component. Returns `null` for empty/invalid ids.
69
+ */
70
+ export declare function decodeAngularComponentUpdateId(id: unknown): {
71
+ moduleRel: string;
72
+ className: string;
73
+ } | null;
74
+ /**
75
+ * True when an Analog `angular:component-update` `id` targets the resolved
76
+ * root component — matched by module path first (robust to class-name
77
+ * collisions), then by class name as a fallback.
78
+ */
79
+ export declare function isAngularRootComponentUpdate(root: BootstrapRootComponent | null | undefined, id: unknown): boolean;