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

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 (356) hide show
  1. package/README.md +51 -11
  2. package/configuration/angular.d.ts +34 -1
  3. package/configuration/angular.js +373 -163
  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/app-components.d.ts +2 -1
  14. package/helpers/app-components.js.map +1 -1
  15. package/helpers/app-css-state.d.ts +8 -0
  16. package/helpers/app-css-state.js +8 -0
  17. package/helpers/app-css-state.js.map +1 -0
  18. package/helpers/bundler-context.d.ts +11 -0
  19. package/helpers/bundler-context.js +71 -0
  20. package/helpers/bundler-context.js.map +1 -0
  21. package/helpers/config-as-json.js +10 -0
  22. package/helpers/config-as-json.js.map +1 -1
  23. package/helpers/dev-host.d.ts +341 -0
  24. package/helpers/dev-host.js +617 -0
  25. package/helpers/dev-host.js.map +1 -0
  26. package/helpers/esbuild-platform-resolver.js +4 -1
  27. package/helpers/esbuild-platform-resolver.js.map +1 -1
  28. package/helpers/global-defines.d.ts +51 -0
  29. package/helpers/global-defines.js +77 -0
  30. package/helpers/global-defines.js.map +1 -1
  31. package/helpers/hmr-scope.d.ts +26 -0
  32. package/helpers/hmr-scope.js +67 -0
  33. package/helpers/hmr-scope.js.map +1 -0
  34. package/helpers/init.js +0 -18
  35. package/helpers/init.js.map +1 -1
  36. package/helpers/logging.d.ts +1 -0
  37. package/helpers/logging.js +63 -3
  38. package/helpers/logging.js.map +1 -1
  39. package/helpers/main-entry.d.ts +2 -1
  40. package/helpers/main-entry.js +430 -47
  41. package/helpers/main-entry.js.map +1 -1
  42. package/helpers/nativeclass-esbuild-plugin.d.ts +2 -1
  43. package/helpers/nativeclass-esbuild-plugin.js.map +1 -1
  44. package/helpers/nativeclass-transform.js.map +1 -1
  45. package/helpers/nativeclass-transformer-plugin.d.ts +9 -2
  46. package/helpers/nativeclass-transformer-plugin.js +157 -14
  47. package/helpers/nativeclass-transformer-plugin.js.map +1 -1
  48. package/helpers/nativescript-package-resolver.js +8 -3
  49. package/helpers/nativescript-package-resolver.js.map +1 -1
  50. package/helpers/normalize-id.d.ts +42 -0
  51. package/helpers/normalize-id.js +60 -0
  52. package/helpers/normalize-id.js.map +1 -0
  53. package/helpers/ns-core-url.d.ts +88 -0
  54. package/helpers/ns-core-url.js +191 -0
  55. package/helpers/ns-core-url.js.map +1 -0
  56. package/helpers/package-platform-aliases.js +4 -3
  57. package/helpers/package-platform-aliases.js.map +1 -1
  58. package/helpers/platform-types.d.ts +2 -0
  59. package/helpers/platform-types.js +2 -0
  60. package/helpers/platform-types.js.map +1 -0
  61. package/helpers/project.d.ts +35 -0
  62. package/helpers/project.js +120 -2
  63. package/helpers/project.js.map +1 -1
  64. package/helpers/resolver.js +17 -2
  65. package/helpers/resolver.js.map +1 -1
  66. package/helpers/ts-config-paths.d.ts +14 -0
  67. package/helpers/ts-config-paths.js +89 -8
  68. package/helpers/ts-config-paths.js.map +1 -1
  69. package/helpers/typescript-check.d.ts +2 -1
  70. package/helpers/typescript-check.js.map +1 -1
  71. package/helpers/workers.d.ts +20 -19
  72. package/helpers/workers.js +624 -4
  73. package/helpers/workers.js.map +1 -1
  74. package/hmr/client/css-handler.d.ts +1 -0
  75. package/hmr/client/css-handler.js +33 -20
  76. package/hmr/client/css-handler.js.map +1 -1
  77. package/hmr/client/css-update-overlay.d.ts +18 -0
  78. package/hmr/client/css-update-overlay.js +27 -0
  79. package/hmr/client/css-update-overlay.js.map +1 -0
  80. package/hmr/client/framework-client-strategy.d.ts +73 -0
  81. package/hmr/client/framework-client-strategy.js +19 -0
  82. package/hmr/client/framework-client-strategy.js.map +1 -0
  83. package/hmr/client/hmr-pending-overlay.d.ts +27 -0
  84. package/hmr/client/hmr-pending-overlay.js +50 -0
  85. package/hmr/client/hmr-pending-overlay.js.map +1 -0
  86. package/hmr/client/index.js +459 -164
  87. package/hmr/client/index.js.map +1 -1
  88. package/hmr/client/utils.d.ts +6 -1
  89. package/hmr/client/utils.js +184 -8
  90. package/hmr/client/utils.js.map +1 -1
  91. package/hmr/entry-runtime.d.ts +2 -1
  92. package/hmr/entry-runtime.js +252 -65
  93. package/hmr/entry-runtime.js.map +1 -1
  94. package/hmr/frameworks/angular/build/angular-linker.d.ts +12 -0
  95. package/hmr/frameworks/angular/build/angular-linker.js +109 -0
  96. package/hmr/frameworks/angular/build/angular-linker.js.map +1 -0
  97. package/hmr/frameworks/angular/build/inject-component-hmr-registration.d.ts +112 -0
  98. package/hmr/frameworks/angular/build/inject-component-hmr-registration.js +291 -0
  99. package/hmr/frameworks/angular/build/inject-component-hmr-registration.js.map +1 -0
  100. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.d.ts +75 -0
  101. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js +221 -0
  102. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js.map +1 -0
  103. package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.js +1 -170
  104. package/hmr/frameworks/angular/build/inline-decorator-component-templates.js.map +1 -0
  105. package/hmr/frameworks/angular/build/js-lexer.d.ts +4 -0
  106. package/{helpers/angular/synthesize-decorator-ctor-parameters.js → hmr/frameworks/angular/build/js-lexer.js} +22 -96
  107. package/hmr/frameworks/angular/build/js-lexer.js.map +1 -0
  108. package/hmr/frameworks/angular/build/shared-linker.d.ts +39 -0
  109. package/hmr/frameworks/angular/build/shared-linker.js +128 -0
  110. package/hmr/frameworks/angular/build/shared-linker.js.map +1 -0
  111. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js +88 -0
  112. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js.map +1 -0
  113. package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.js +1 -174
  114. package/hmr/frameworks/angular/build/synthesize-injectable-factories.js.map +1 -0
  115. package/{helpers/angular → hmr/frameworks/angular/build}/util.d.ts +1 -0
  116. package/hmr/frameworks/angular/build/util.js +155 -0
  117. package/hmr/frameworks/angular/build/util.js.map +1 -0
  118. package/hmr/frameworks/angular/client/index.d.ts +1 -0
  119. package/hmr/frameworks/angular/client/index.js +778 -20
  120. package/hmr/frameworks/angular/client/index.js.map +1 -1
  121. package/hmr/frameworks/angular/client/strategy.d.ts +9 -0
  122. package/hmr/frameworks/angular/client/strategy.js +19 -0
  123. package/hmr/frameworks/angular/client/strategy.js.map +1 -0
  124. package/hmr/frameworks/angular/server/angular-root-component.d.ts +79 -0
  125. package/hmr/frameworks/angular/server/angular-root-component.js +149 -0
  126. package/hmr/frameworks/angular/server/angular-root-component.js.map +1 -0
  127. package/hmr/frameworks/angular/server/linker.js +1 -4
  128. package/hmr/frameworks/angular/server/linker.js.map +1 -1
  129. package/hmr/frameworks/angular/server/strategy.js +448 -12
  130. package/hmr/frameworks/angular/server/strategy.js.map +1 -1
  131. package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.js +2 -2
  132. package/hmr/frameworks/angular/server/websocket-angular-entry.js.map +1 -0
  133. package/hmr/{server → frameworks/angular/server}/websocket-angular-hot-update.d.ts +17 -11
  134. package/hmr/frameworks/angular/server/websocket-angular-hot-update.js +336 -0
  135. package/hmr/frameworks/angular/server/websocket-angular-hot-update.js.map +1 -0
  136. package/hmr/frameworks/solid/build/solid-jsx-deps.d.ts +15 -0
  137. package/hmr/frameworks/solid/build/solid-jsx-deps.js +178 -0
  138. package/hmr/frameworks/solid/build/solid-jsx-deps.js.map +1 -0
  139. package/hmr/frameworks/solid/server/strategy.js +360 -16
  140. package/hmr/frameworks/solid/server/strategy.js.map +1 -1
  141. package/hmr/frameworks/typescript/server/strategy.js +28 -14
  142. package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
  143. package/hmr/frameworks/vue/client/index.js +30 -199
  144. package/hmr/frameworks/vue/client/index.js.map +1 -1
  145. package/hmr/frameworks/vue/client/strategy.d.ts +7 -0
  146. package/hmr/frameworks/vue/client/strategy.js +83 -0
  147. package/hmr/frameworks/vue/client/strategy.js.map +1 -0
  148. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.d.ts +82 -0
  149. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js +133 -0
  150. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js.map +1 -0
  151. package/hmr/frameworks/vue/server/sfc-route-assemble.d.ts +7 -0
  152. package/hmr/frameworks/vue/server/sfc-route-assemble.js +706 -0
  153. package/hmr/frameworks/vue/server/sfc-route-assemble.js.map +1 -0
  154. package/hmr/frameworks/vue/server/sfc-route-meta.d.ts +7 -0
  155. package/hmr/frameworks/vue/server/sfc-route-meta.js +80 -0
  156. package/hmr/frameworks/vue/server/sfc-route-meta.js.map +1 -0
  157. package/hmr/frameworks/vue/server/sfc-route-serve.d.ts +8 -0
  158. package/hmr/frameworks/vue/server/sfc-route-serve.js +457 -0
  159. package/hmr/frameworks/vue/server/sfc-route-serve.js.map +1 -0
  160. package/hmr/frameworks/vue/server/sfc-route-shared.d.ts +19 -0
  161. package/hmr/frameworks/vue/server/sfc-route-shared.js +14 -0
  162. package/hmr/frameworks/vue/server/sfc-route-shared.js.map +1 -0
  163. package/hmr/frameworks/vue/server/strategy.js +244 -0
  164. package/hmr/frameworks/vue/server/strategy.js.map +1 -1
  165. package/hmr/frameworks/vue/server/websocket-sfc.d.ts +15 -0
  166. package/hmr/frameworks/vue/server/websocket-sfc.js +20 -0
  167. package/hmr/frameworks/vue/server/websocket-sfc.js.map +1 -0
  168. package/hmr/helpers/ast-normalizer.js +52 -5
  169. package/hmr/helpers/ast-normalizer.js.map +1 -1
  170. package/hmr/helpers/cjs-named-exports.d.ts +23 -0
  171. package/hmr/helpers/cjs-named-exports.js +152 -0
  172. package/hmr/helpers/cjs-named-exports.js.map +1 -0
  173. package/hmr/helpers/package-exports.d.ts +16 -0
  174. package/hmr/helpers/package-exports.js +396 -0
  175. package/hmr/helpers/package-exports.js.map +1 -0
  176. package/hmr/server/constants.js +13 -4
  177. package/hmr/server/constants.js.map +1 -1
  178. package/hmr/server/core-sanitize.d.ts +90 -7
  179. package/hmr/server/core-sanitize.js +211 -56
  180. package/hmr/server/core-sanitize.js.map +1 -1
  181. package/hmr/server/device-transform-helpers.d.ts +24 -0
  182. package/hmr/server/device-transform-helpers.js +327 -0
  183. package/hmr/server/device-transform-helpers.js.map +1 -0
  184. package/hmr/server/framework-strategy.d.ts +95 -11
  185. package/hmr/server/hmr-module-graph.d.ts +37 -0
  186. package/hmr/server/hmr-module-graph.js +214 -0
  187. package/hmr/server/hmr-module-graph.js.map +1 -0
  188. package/hmr/server/import-map.d.ts +11 -2
  189. package/hmr/server/import-map.js +59 -40
  190. package/hmr/server/import-map.js.map +1 -1
  191. package/hmr/server/index.js +7 -16
  192. package/hmr/server/index.js.map +1 -1
  193. package/hmr/server/ns-core-cjs-shape.d.ts +204 -0
  194. package/hmr/server/ns-core-cjs-shape.js +271 -0
  195. package/hmr/server/ns-core-cjs-shape.js.map +1 -0
  196. package/hmr/server/ns-rt-bridge.d.ts +51 -0
  197. package/hmr/server/ns-rt-bridge.js +131 -0
  198. package/hmr/server/ns-rt-bridge.js.map +1 -0
  199. package/hmr/server/ns-rt-route.d.ts +5 -0
  200. package/hmr/server/ns-rt-route.js +35 -0
  201. package/hmr/server/ns-rt-route.js.map +1 -0
  202. package/hmr/server/perf-instrumentation.d.ts +114 -0
  203. package/hmr/server/perf-instrumentation.js +195 -0
  204. package/hmr/server/perf-instrumentation.js.map +1 -0
  205. package/hmr/server/process-code-for-device.d.ts +15 -0
  206. package/hmr/server/process-code-for-device.js +654 -0
  207. package/hmr/server/process-code-for-device.js.map +1 -0
  208. package/hmr/server/require-guard.d.ts +1 -0
  209. package/hmr/server/require-guard.js +12 -0
  210. package/hmr/server/require-guard.js.map +1 -0
  211. package/hmr/server/rewrite-imports.d.ts +2 -0
  212. package/hmr/server/rewrite-imports.js +604 -0
  213. package/hmr/server/rewrite-imports.js.map +1 -0
  214. package/hmr/server/route-helpers.d.ts +7 -0
  215. package/hmr/server/route-helpers.js +13 -0
  216. package/hmr/server/route-helpers.js.map +1 -0
  217. package/hmr/server/server-origin.d.ts +12 -0
  218. package/hmr/server/server-origin.js +66 -0
  219. package/hmr/server/server-origin.js.map +1 -0
  220. package/hmr/server/shared-transform-request.js +12 -5
  221. package/hmr/server/shared-transform-request.js.map +1 -1
  222. package/hmr/server/transform-cache-invalidation.d.ts +11 -0
  223. package/hmr/server/transform-cache-invalidation.js +84 -0
  224. package/hmr/server/transform-cache-invalidation.js.map +1 -0
  225. package/hmr/server/vendor-bare-module-shims.d.ts +4 -0
  226. package/hmr/server/vendor-bare-module-shims.js +80 -0
  227. package/hmr/server/vendor-bare-module-shims.js.map +1 -0
  228. package/hmr/server/vite-plugin.js +60 -42
  229. package/hmr/server/vite-plugin.js.map +1 -1
  230. package/hmr/server/websocket-core-bridge.d.ts +41 -6
  231. package/hmr/server/websocket-core-bridge.js +72 -75
  232. package/hmr/server/websocket-core-bridge.js.map +1 -1
  233. package/hmr/server/websocket-css-hot-update.d.ts +33 -0
  234. package/hmr/server/websocket-css-hot-update.js +65 -0
  235. package/hmr/server/websocket-css-hot-update.js.map +1 -0
  236. package/hmr/server/websocket-device-transform.d.ts +3 -0
  237. package/hmr/server/websocket-device-transform.js +7 -0
  238. package/hmr/server/websocket-device-transform.js.map +1 -0
  239. package/hmr/server/websocket-graph-upsert.d.ts +15 -0
  240. package/hmr/server/websocket-graph-upsert.js +20 -0
  241. package/hmr/server/websocket-graph-upsert.js.map +1 -1
  242. package/hmr/server/websocket-hmr-pending.d.ts +37 -0
  243. package/hmr/server/websocket-hmr-pending.js +55 -0
  244. package/hmr/server/websocket-hmr-pending.js.map +1 -0
  245. package/hmr/server/websocket-hot-update.d.ts +77 -0
  246. package/hmr/server/websocket-hot-update.js +330 -0
  247. package/hmr/server/websocket-hot-update.js.map +1 -0
  248. package/hmr/server/websocket-import-map-route.d.ts +15 -0
  249. package/hmr/server/websocket-import-map-route.js +46 -0
  250. package/hmr/server/websocket-import-map-route.js.map +1 -0
  251. package/hmr/server/websocket-module-bindings.js +3 -3
  252. package/hmr/server/websocket-module-bindings.js.map +1 -1
  253. package/hmr/server/websocket-module-specifiers.d.ts +66 -2
  254. package/hmr/server/websocket-module-specifiers.js +202 -19
  255. package/hmr/server/websocket-module-specifiers.js.map +1 -1
  256. package/hmr/server/websocket-ns-core.d.ts +21 -0
  257. package/hmr/server/websocket-ns-core.js +306 -0
  258. package/hmr/server/websocket-ns-core.js.map +1 -0
  259. package/hmr/server/websocket-ns-entry.d.ts +21 -0
  260. package/hmr/server/websocket-ns-entry.js +150 -0
  261. package/hmr/server/websocket-ns-entry.js.map +1 -0
  262. package/hmr/server/websocket-ns-m-paths.d.ts +3 -0
  263. package/hmr/server/websocket-ns-m-paths.js +92 -0
  264. package/hmr/server/websocket-ns-m-paths.js.map +1 -0
  265. package/hmr/server/websocket-ns-m-request.d.ts +45 -0
  266. package/hmr/server/websocket-ns-m-request.js +196 -0
  267. package/hmr/server/websocket-ns-m-request.js.map +1 -0
  268. package/hmr/server/websocket-ns-m.d.ts +33 -0
  269. package/hmr/server/websocket-ns-m.js +748 -0
  270. package/hmr/server/websocket-ns-m.js.map +1 -0
  271. package/hmr/server/websocket-served-module-helpers.d.ts +39 -0
  272. package/hmr/server/websocket-served-module-helpers.js +654 -0
  273. package/hmr/server/websocket-served-module-helpers.js.map +1 -0
  274. package/hmr/server/websocket-txn.d.ts +6 -0
  275. package/hmr/server/websocket-txn.js +39 -0
  276. package/hmr/server/websocket-txn.js.map +1 -0
  277. package/hmr/server/websocket-vendor-unifier.d.ts +9 -0
  278. package/hmr/server/websocket-vendor-unifier.js +46 -0
  279. package/hmr/server/websocket-vendor-unifier.js.map +1 -0
  280. package/hmr/server/websocket.d.ts +8 -39
  281. package/hmr/server/websocket.js +602 -6049
  282. package/hmr/server/websocket.js.map +1 -1
  283. package/hmr/shared/ns-globals.d.ts +118 -0
  284. package/hmr/shared/ns-globals.js +27 -0
  285. package/hmr/shared/ns-globals.js.map +1 -0
  286. package/hmr/shared/protocol.d.ts +136 -0
  287. package/hmr/shared/protocol.js +28 -0
  288. package/hmr/shared/protocol.js.map +1 -0
  289. package/hmr/shared/runtime/boot-placeholder-ui.d.ts +69 -0
  290. package/hmr/shared/runtime/boot-placeholder-ui.js +101 -0
  291. package/hmr/shared/runtime/boot-placeholder-ui.js.map +1 -0
  292. package/hmr/shared/runtime/boot-progress.d.ts +40 -0
  293. package/hmr/shared/runtime/boot-progress.js +128 -0
  294. package/hmr/shared/runtime/boot-progress.js.map +1 -0
  295. package/hmr/shared/runtime/boot-timeline.d.ts +18 -0
  296. package/hmr/shared/runtime/boot-timeline.js +52 -0
  297. package/hmr/shared/runtime/boot-timeline.js.map +1 -0
  298. package/hmr/shared/runtime/dev-overlay-snapshots.d.ts +31 -0
  299. package/hmr/shared/runtime/dev-overlay-snapshots.js +324 -0
  300. package/hmr/shared/runtime/dev-overlay-snapshots.js.map +1 -0
  301. package/hmr/shared/runtime/dev-overlay.d.ts +75 -26
  302. package/hmr/shared/runtime/dev-overlay.js +990 -260
  303. package/hmr/shared/runtime/dev-overlay.js.map +1 -1
  304. package/hmr/shared/runtime/module-provenance.js +1 -4
  305. package/hmr/shared/runtime/module-provenance.js.map +1 -1
  306. package/hmr/shared/runtime/root-placeholder-view.d.ts +19 -0
  307. package/hmr/shared/runtime/root-placeholder-view.js +310 -0
  308. package/hmr/shared/runtime/root-placeholder-view.js.map +1 -0
  309. package/hmr/shared/runtime/root-placeholder.js +352 -194
  310. package/hmr/shared/runtime/root-placeholder.js.map +1 -1
  311. package/hmr/shared/runtime/session-bootstrap.js +164 -1
  312. package/hmr/shared/runtime/session-bootstrap.js.map +1 -1
  313. package/hmr/shared/runtime/vendor-bootstrap.js +1 -9
  314. package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
  315. package/hmr/shared/vendor/manifest-collect.d.ts +4 -0
  316. package/hmr/shared/vendor/manifest-collect.js +512 -0
  317. package/hmr/shared/vendor/manifest-collect.js.map +1 -0
  318. package/hmr/shared/vendor/manifest-loader.d.ts +2 -1
  319. package/hmr/shared/vendor/manifest-loader.js +3 -2
  320. package/hmr/shared/vendor/manifest-loader.js.map +1 -1
  321. package/hmr/shared/vendor/manifest.d.ts +1 -7
  322. package/hmr/shared/vendor/manifest.js +102 -741
  323. package/hmr/shared/vendor/manifest.js.map +1 -1
  324. package/hmr/shared/vendor/vendor-device-shim.d.ts +1 -0
  325. package/hmr/shared/vendor/vendor-device-shim.js +208 -0
  326. package/hmr/shared/vendor/vendor-device-shim.js.map +1 -0
  327. package/hmr/shared/vendor/vendor-esbuild-plugins.d.ts +16 -0
  328. package/hmr/shared/vendor/vendor-esbuild-plugins.js +203 -0
  329. package/hmr/shared/vendor/vendor-esbuild-plugins.js.map +1 -0
  330. package/index.d.ts +1 -0
  331. package/index.js +5 -0
  332. package/index.js.map +1 -1
  333. package/package.json +55 -11
  334. package/runtime/core-aliases-early.js +17 -41
  335. package/runtime/core-aliases-early.js.map +1 -1
  336. package/helpers/angular/angular-linker.d.ts +0 -13
  337. package/helpers/angular/angular-linker.js +0 -194
  338. package/helpers/angular/angular-linker.js.map +0 -1
  339. package/helpers/angular/inline-decorator-component-templates.js.map +0 -1
  340. package/helpers/angular/shared-linker.d.ts +0 -11
  341. package/helpers/angular/shared-linker.js +0 -75
  342. package/helpers/angular/shared-linker.js.map +0 -1
  343. package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +0 -1
  344. package/helpers/angular/synthesize-injectable-factories.js.map +0 -1
  345. package/helpers/angular/util.js +0 -67
  346. package/helpers/angular/util.js.map +0 -1
  347. package/helpers/prelink-angular.d.ts +0 -2
  348. package/helpers/prelink-angular.js +0 -117
  349. package/helpers/prelink-angular.js.map +0 -1
  350. package/hmr/server/websocket-angular-entry.js.map +0 -1
  351. package/hmr/server/websocket-angular-hot-update.js +0 -239
  352. package/hmr/server/websocket-angular-hot-update.js.map +0 -1
  353. /package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.d.ts +0 -0
  354. /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-decorator-ctor-parameters.d.ts +0 -0
  355. /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.d.ts +0 -0
  356. /package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.d.ts +0 -0
@@ -2,10 +2,14 @@ import { getPackageJson, getProjectFilePath, getProjectRootPath } from './projec
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
4
  import { preprocessCSS } from 'vite';
5
+ import { parse as parseCssToAst } from 'css';
5
6
  import { getProjectFlavor } from './flavor.js';
6
7
  import { getProjectAppPath, getProjectAppRelativePath, getProjectAppVirtualPath } from './utils.js';
7
8
  import { getResolvedAppComponents } from './app-components.js';
8
9
  import { toStaticImportSpecifier } from './import-specifier.js';
10
+ import { buildCoreUrl } from './ns-core-url.js';
11
+ import { resolveDeviceReachableOrigin } from './dev-host.js';
12
+ import { setAppCssState } from './app-css-state.js';
9
13
  // Switched to runtime modules to avoid fragile string injection and enable TS checks
10
14
  const projectRoot = getProjectRootPath();
11
15
  const appRootDir = getProjectAppPath();
@@ -51,6 +55,35 @@ const APP_CSS_RESOLVED = '\0' + APP_CSS_VIRTUAL_ID;
51
55
  // polyfill is installed during module evaluation (before zone.js patches run).
52
56
  const XHR_POLYFILL_VIRTUAL_ID = 'virtual:ns-xhr-polyfill';
53
57
  const XHR_POLYFILL_RESOLVED = '\0' + XHR_POLYFILL_VIRTUAL_ID;
58
+ // Virtual module that seeds compile-time defines (`__APPLE__`, `__IOS__`,
59
+ // `__DEV__`, etc.) on `globalThis` BEFORE any other module evaluates.
60
+ //
61
+ // Why this exists. The per-module shim that `processCodeForDevice` injects
62
+ // at the top of every served module reads these values from `globalThis`:
63
+ // const __APPLE__ = globalThis.__APPLE__ !== undefined
64
+ // ? globalThis.__APPLE__
65
+ // : (__IOS__ || __VISIONOS__);
66
+ // `const` evaluates ONCE at module instantiation. So every module needs
67
+ // `globalThis.__APPLE__` to already be set when it instantiates — otherwise
68
+ // it locks in `false` for the lifetime of the module.
69
+ //
70
+ // In ESM, all `import` statements hoist to the top of the module's
71
+ // evaluation phase: imports run in DFS post-order BEFORE the importing
72
+ // module's body. If we put the seed assignments inline in the entry's
73
+ // body (e.g. `globalThis.__APPLE__ = true`), they run AFTER every module
74
+ // transitively imported via `bundle-entry-points` (which reaches the
75
+ // user's `main.ts` → `app.module.ts` → services → util files). Those
76
+ // utility modules then snapshot `globalThis.__APPLE__ = undefined` and
77
+ // fall through to the `false` branch — landing iOS code in the
78
+ // `else { /* Android */ }` branch and crashing on `Utils.android.*`.
79
+ //
80
+ // The fix is to import this virtual module FIRST in the entry. As a leaf
81
+ // in the dependency graph it evaluates before every sibling import, so
82
+ // its body assignments happen before any user module instantiates and
83
+ // reads `globalThis.__*`. This is the architecturally-correct way to
84
+ // make values available to other modules across the import graph in ESM.
85
+ const DEFINES_SEED_VIRTUAL_ID = 'virtual:ns-defines-seed';
86
+ const DEFINES_SEED_RESOLVED = '\0' + DEFINES_SEED_VIRTUAL_ID;
54
87
  export function mainEntryPlugin(opts) {
55
88
  let resolvedConfig;
56
89
  return {
@@ -58,6 +91,93 @@ export function mainEntryPlugin(opts) {
58
91
  configResolved(config) {
59
92
  resolvedConfig = config;
60
93
  },
94
+ // Warm chokidar with `app.css`'s @import dependency tree at
95
+ // server startup. Without this, the FIRST save to a workspace
96
+ // `@import` dep (e.g. `<repo>/libs/.../index.css`) is silently
97
+ // dropped: nothing in the cold-boot path causes the dev server
98
+ // to transform `app.css`, so `vite:css` never registers
99
+ // `@import`-resolved deps with the watcher. Eagerly resolving
100
+ // them here breaks the chicken-and-egg.
101
+ //
102
+ // We ALSO stash the resolved dep set on the server itself so
103
+ // the HMR websocket handler can recognize when a non-CSS edit
104
+ // (e.g. a `.html` template or `.ts` file scanned by Tailwind's
105
+ // content config) should trigger a fresh `app.css` fetch. The
106
+ // `preprocessCSS` deps include every file PostCSS reported as
107
+ // a `dependency` message — for Tailwind 3 with content globs,
108
+ // Vite's `compileCSS` expands the `dir-dependency` glob into
109
+ // the individual file paths, so we get the full content set.
110
+ //
111
+ // `app.css` is NEVER a real Vite module in NS HMR (the virtual
112
+ // `:ns-app-css` module re-runs `preprocessCSS` in its load
113
+ // hook), so the standard moduleGraph `addWatchFile` →
114
+ // `_addedImports` → file-only-entry-importer chain doesn't
115
+ // populate, and `ctx.modules` for a content-file edit never
116
+ // links back to a CSS module. The dep set fills that gap.
117
+ configureServer(server) {
118
+ if (server.config.command !== 'serve')
119
+ return;
120
+ const appCssPath = path.resolve(projectRoot, getProjectAppRelativePath('app.css'));
121
+ if (!fs.existsSync(appCssPath))
122
+ return;
123
+ const normalizeFsPath = (p) => path.resolve(p).replace(/\\/g, '/');
124
+ const normalizedAppCssPath = normalizeFsPath(appCssPath);
125
+ const watchedDeps = new Set([normalizedAppCssPath]);
126
+ const refreshDeps = async () => {
127
+ try {
128
+ const code = fs.readFileSync(appCssPath, 'utf-8');
129
+ const result = await preprocessCSS(code, appCssPath, server.config);
130
+ server.watcher.add(appCssPath);
131
+ const next = new Set([normalizedAppCssPath]);
132
+ for (const dep of result?.deps ?? []) {
133
+ if (typeof dep === 'string' && dep) {
134
+ server.watcher.add(dep);
135
+ next.add(normalizeFsPath(dep));
136
+ }
137
+ }
138
+ // Atomic-ish replace: clear + repopulate the existing
139
+ // Set so any concurrent reader sees a consistent view
140
+ // when iterating with `.has()`.
141
+ watchedDeps.clear();
142
+ for (const f of next)
143
+ watchedDeps.add(f);
144
+ }
145
+ catch { }
146
+ };
147
+ setAppCssState(server, { path: normalizedAppCssPath, deps: watchedDeps });
148
+ refreshDeps();
149
+ // Re-scan when `app.css` itself or a Tailwind config file
150
+ // changes — Tailwind's content list and utility definitions
151
+ // can both shift, so the dep set has to follow. Debounced
152
+ // because watcher events for the same edit can fire in
153
+ // quick succession (chokidar's atomic save handling).
154
+ let pendingRefresh = null;
155
+ const scheduleRefresh = () => {
156
+ if (pendingRefresh)
157
+ clearTimeout(pendingRefresh);
158
+ pendingRefresh = setTimeout(() => {
159
+ pendingRefresh = null;
160
+ refreshDeps();
161
+ }, 50);
162
+ };
163
+ const isAppCssOrTailwindConfig = (file) => {
164
+ const normalized = normalizeFsPath(file);
165
+ if (normalized === normalizedAppCssPath)
166
+ return true;
167
+ return /\/tailwind\.config\.[mc]?[jt]s$/.test(normalized);
168
+ };
169
+ server.watcher.on('change', (file) => {
170
+ if (isAppCssOrTailwindConfig(file))
171
+ scheduleRefresh();
172
+ });
173
+ // `add`/`unlink` cover Tailwind's content set growing or
174
+ // shrinking — new template files, deleted partials, etc.
175
+ // Re-running `preprocessCSS` is the safest way to keep the
176
+ // glob expansion accurate without re-implementing the
177
+ // match.
178
+ server.watcher.on('add', scheduleRefresh);
179
+ server.watcher.on('unlink', scheduleRefresh);
180
+ },
61
181
  resolveId(id) {
62
182
  if (id === VIRTUAL_ID)
63
183
  return RESOLVED;
@@ -65,19 +185,111 @@ export function mainEntryPlugin(opts) {
65
185
  return APP_CSS_RESOLVED;
66
186
  if (id === XHR_POLYFILL_VIRTUAL_ID)
67
187
  return XHR_POLYFILL_RESOLVED;
188
+ if (id === DEFINES_SEED_VIRTUAL_ID)
189
+ return DEFINES_SEED_RESOLVED;
68
190
  return null;
69
191
  },
70
192
  async load(id) {
71
- // Virtual module that processes app.css through PostCSS/Tailwind and returns as a JS string.
72
- // This avoids using ?inline which conflicts with @analogjs/vite-plugin-angular's CSS
73
- // interception in Vite 8 the Angular plugin converts ?inline CSS to JS via its load hook
74
- // but doesn't set moduleType:'js', so vite:css still tries to run PostCSS on the JS output.
193
+ // Compute the dev server origin for HMR mode. Under HMR we emit
194
+ // `@nativescript/core*` imports as FULL HTTP URLs so iOS's ESM loader
195
+ // can fetch them directly during bundle.mjs module instantiation
196
+ // the import map isn't installed yet at that phase. For non-HMR
197
+ // builds, we keep bare specifiers so production bundlers inline core
198
+ // the normal way.
199
+ //
200
+ // Routes through `resolveDeviceReachableOrigin` so the URL baked
201
+ // into the bundle is something the DEVICE can reach: wildcard
202
+ // binds (`0.0.0.0`) and Android loopback get remapped to a real
203
+ // LAN IP (preferred) or the platform's reachable fallback
204
+ // (`10.0.2.2` for the Android emulator). Without this, Android
205
+ // crashes at boot trying to fetch `http://0.0.0.0:5173/ns/core/xhr`.
206
+ const getBootOrigin = () => {
207
+ if (!opts.hmrActive)
208
+ return null;
209
+ try {
210
+ const { origin } = resolveDeviceReachableOrigin({
211
+ host: resolvedConfig.server.host,
212
+ platform: opts.platform,
213
+ protocol: resolvedConfig.server.https || opts.useHttps ? 'https' : 'http',
214
+ port: Number(resolvedConfig.server.port || 5173),
215
+ });
216
+ return origin;
217
+ }
218
+ catch {
219
+ return null;
220
+ }
221
+ };
222
+ // Return a spec string for @nativescript/core or a subpath that is
223
+ // guaranteed to resolve at iOS module-instantiation time. Under HMR
224
+ // this is always a full HTTP URL into the /ns/core bridge (no
225
+ // import-map dependency). Under non-HMR it's the bare specifier for
226
+ // the bundler to handle.
227
+ //
228
+ // Under HMR, delegates to buildCoreUrl() — the ONE canonical URL
229
+ // generator. Every URL emitter in the build/runtime pipeline (this
230
+ // function, ns-core-external-urls, rewriteSpec, runtime import map)
231
+ // uses the same function so iOS's HTTP ESM cache sees byte-identical
232
+ // URLs.
233
+ const coreSpec = (subpath) => {
234
+ const origin = getBootOrigin();
235
+ if (origin) {
236
+ return buildCoreUrl(origin, subpath);
237
+ }
238
+ const sub = subpath ? String(subpath).replace(/^\/+/, '') : '';
239
+ return sub ? `@nativescript/core/${sub}` : '@nativescript/core';
240
+ };
241
+ // Virtual module that processes app.css through PostCSS/Tailwind and emits a
242
+ // JS module that BOTH applies the CSS as a side-effect AND exports the raw
243
+ // CSS string as default.
244
+ //
245
+ // Background: Vite's default `?inline` CSS handling collides with
246
+ // @analogjs/vite-plugin-angular's load hook in Vite 8 (it converts ?inline
247
+ // CSS to JS without setting moduleType:'js', so vite:css still tries to run
248
+ // PostCSS on the JS output). This virtual module sidesteps that.
249
+ //
250
+ // We still export the raw CSS string as default so the entry can seed
251
+ // `globalThis.__NS_HMR_APP_CSS__` for HMR's HTTP-core-realm replay path.
252
+ //
253
+ // We always pre-parse with rework `css` and either:
254
+ // - non-HMR: call `addTaggedAdditionalCSS(astJson, 'app.css')` directly
255
+ // so the bundled `style-scope` realm gets the styles before any view
256
+ // is created.
257
+ // - HMR: stash the AST on `globalThis.__NS_HMR_APP_CSS_AST__` so
258
+ // `installHttpCoreCssSupport` can apply it via the SAME AST path
259
+ // in the HTTP-core realm. Without this, the HTTP path would fall
260
+ // back to applying the raw text via `cssTreeParse` at runtime,
261
+ // which has produced subtle behavioral mismatches with the rework
262
+ // AST (e.g. `.text-sm { line-height: 20 }` rendering with extra
263
+ // line spacing under HMR but not under the no-HMR rolldown
264
+ // bundle, even though both bundles serialize the identical
265
+ // declaration). Pre-parsing once at build time and shipping the
266
+ // AST to BOTH paths keeps cold-boot rendering identical between
267
+ // the two modes. Live HMR edits still arrive as raw text via the
268
+ // dev-server WebSocket, so `installHttpCoreCssSupport` keeps the
269
+ // raw-text fallback for that case.
75
270
  if (id === APP_CSS_RESOLVED) {
76
271
  const appCssPath = path.resolve(projectRoot, getProjectAppRelativePath('app.css'));
77
272
  const code = fs.readFileSync(appCssPath, 'utf-8');
78
273
  const result = await preprocessCSS(code, appCssPath, resolvedConfig);
274
+ const ast = parseCssToAst(result.code, { silent: true });
275
+ // `css` emits `position` metadata on every AST node. NS doesn't
276
+ // use it, and stripping it ~halves the inlined JSON size — same
277
+ // thing webpack's css2json-loader does.
278
+ const astJson = JSON.stringify(ast, (key, value) => (key === 'position' ? undefined : value));
279
+ const lines = [];
280
+ if (opts.hmrActive) {
281
+ // Stash AST on globalThis BEFORE the entry seeds
282
+ // `__NS_HMR_APP_CSS__` from this module's default export, so
283
+ // `installHttpCoreCssSupport` can prefer the AST and match
284
+ // the no-HMR application path exactly.
285
+ lines.push(`try { (globalThis).__NS_HMR_APP_CSS_AST__ = ${astJson}; } catch {}`);
286
+ }
287
+ else {
288
+ lines.push(`import { addTaggedAdditionalCSS } from ${JSON.stringify(coreSpec('ui/styling/style-scope'))};`, `addTaggedAdditionalCSS(${astJson}, 'app.css');`);
289
+ }
290
+ lines.push(`export default ${JSON.stringify(result.code)};`);
79
291
  return {
80
- code: `export default ${JSON.stringify(result.code)};`,
292
+ code: lines.join('\n'),
81
293
  moduleType: 'js',
82
294
  };
83
295
  }
@@ -85,42 +297,192 @@ export function mainEntryPlugin(opts) {
85
297
  // guaranteeing XMLHttpRequest is on globalThis before zone.js or any other code accesses it.
86
298
  if (id === XHR_POLYFILL_RESOLVED) {
87
299
  return {
88
- code: ["import * as xhrImpl from '@nativescript/core/xhr';", "var polyfills = ['XMLHttpRequest','FormData','Blob','File','FileReader'];", 'for (var i = 0; i < polyfills.length; i++) {', ' var n = polyfills[i];', ' if (!(n in globalThis) && xhrImpl[n]) globalThis[n] = xhrImpl[n];', '}'].join('\n'),
300
+ code: [`import * as xhrImpl from ${JSON.stringify(coreSpec('xhr'))};`, "var polyfills = ['XMLHttpRequest','FormData','Blob','File','FileReader'];", 'for (var i = 0; i < polyfills.length; i++) {', ' var n = polyfills[i];', ' if (!(n in globalThis) && xhrImpl[n]) globalThis[n] = xhrImpl[n];', '}'].join('\n'),
301
+ moduleType: 'js',
302
+ };
303
+ }
304
+ // Virtual module that seeds compile-time defines on globalThis.
305
+ // Imported FIRST in the entry so it evaluates as a leaf before
306
+ // any other module — including the `bundle-entry-points` chain
307
+ // that transitively reaches the user's app code. See the
308
+ // DEFINES_SEED_VIRTUAL_ID comment at the top of this file.
309
+ if (id === DEFINES_SEED_RESOLVED) {
310
+ const isApple = opts.platform === 'ios' || opts.platform === 'visionos';
311
+ const seedLines = [
312
+ `globalThis.__DEV__ = ${opts.isDevMode ? 'true' : 'false'};`,
313
+ `globalThis.__ANDROID__ = ${opts.platform === 'android' ? 'true' : 'false'};`,
314
+ `globalThis.__IOS__ = ${opts.platform === 'ios' ? 'true' : 'false'};`,
315
+ `globalThis.__VISIONOS__ = ${opts.platform === 'visionos' ? 'true' : 'false'};`,
316
+ `globalThis.__APPLE__ = ${isApple ? 'true' : 'false'};`,
317
+ 'globalThis.__COMMONJS__ = false;',
318
+ 'globalThis.__NS_WEBPACK__ = false;',
319
+ `globalThis.__NS_ENV_VERBOSE__ = ${opts.verbose ? 'true' : 'false'};`,
320
+ // Seed the runtime flavor so the HMR client (which is loaded from
321
+ // node_modules and therefore NOT processed by Vite's `define`
322
+ // substitution) can resolve `TARGET_FLAVOR` reliably. Without
323
+ // this, `resolveTargetFlavor()` in `hmr/client/index.ts` only
324
+ // detects 'angular' (via __reboot_ng_modules__) and 'vue' (via
325
+ // __VUE_HMR_RUNTIME__), and 'solid' / 'typescript' fall through
326
+ // to undefined — so any flavor-specific switch case in
327
+ // `processQueue` (Solid component boundary discovery, route-loader
328
+ // patching, overlay stage transitions) silently never fires.
329
+ `globalThis.__NS_TARGET_FLAVOR__ = ${JSON.stringify(flavor)};`,
330
+ 'globalThis.__UI_USE_XML_PARSER__ = true;',
331
+ 'globalThis.__UI_USE_EXTERNAL_RENDERER__ = false;',
332
+ "globalThis.__CSS_PARSER__ = 'css-tree';",
333
+ 'globalThis.__TEST__ = false;',
334
+ ];
335
+ return {
336
+ code: seedLines.join('\n') + '\n',
89
337
  moduleType: 'js',
90
338
  };
91
339
  }
92
340
  if (id !== RESOLVED)
93
341
  return null;
342
+ let imports = '';
343
+ // Under HMR: import the defines-seed virtual module FIRST so its
344
+ // body — which sets `globalThis.__APPLE__`, `__IOS__`, `__DEV__`,
345
+ // etc. — evaluates as a leaf in the dependency graph BEFORE any
346
+ // other module instantiates. Per-module shims injected by
347
+ // `processCodeForDevice` read these from globalThis and snapshot
348
+ // them at instantiation time, so they MUST be set first.
349
+ //
350
+ // Under non-HMR: Vite's `define` config handles substitution
351
+ // statically at build time — no runtime seeding needed.
352
+ if (opts.hmrActive) {
353
+ imports += `import '${DEFINES_SEED_VIRTUAL_ID}';\n`;
354
+ }
94
355
  // consistent verbose flag to easily reference below
95
- let imports = "const __nsVerboseLog = typeof __NS_ENV_VERBOSE__ !== 'undefined' && __NS_ENV_VERBOSE__;\n";
96
- // Ensure any CommonJS-style tooling requires (e.g. from Babel or other
97
- // build-time libraries that may be accidentally bundled) do not attempt
98
- // to resolve Node built-ins like 'fs' or 'path' on device. These modules
99
- // are not used at runtime for NativeScript apps, so we safely return an
100
- // empty object from a global require shim when present.
101
- imports += "try { if (typeof globalThis !== 'undefined') { var _nsReq = function () { return {}; }; _nsReq.context = function() { var _c = { keys: function() { return []; } }; _c.__esModule = true; return _c; }; globalThis.require = _nsReq; } } catch {}\n";
356
+ imports += "const __nsVerboseLog = typeof __NS_ENV_VERBOSE__ !== 'undefined' && __NS_ENV_VERBOSE__;\n";
357
+ // Ensure any CommonJS-style tooling requires (e.g. from Babel or
358
+ // other build-time libraries that may be accidentally bundled) do
359
+ // not attempt to resolve Node built-ins like 'fs' or 'path' on
360
+ // device. These modules are not used at runtime for NativeScript
361
+ // apps, so we safely return an empty object from a shim.
362
+ //
363
+ // IMPORTANT: Under HMR, vendor packages call the real NativeScript
364
+ // CommonJS require() with `@nativescript/core/<sub>` specifiers
365
+ // (e.g. `require('@nativescript/core/ui/core/view').View` in
366
+ // `@nativescript-community/gesturehandler`). If we overwrite
367
+ // globalThis.require with a blanket stub, every such call returns
368
+ // `{}` and any property access on the result (e.g. `.View`) is
369
+ // `undefined`, cascading into `TypeError: Cannot read properties
370
+ // of undefined (reading 'prototype')` inside `applyMixins` when
371
+ // vendor install() hooks run.
372
+ //
373
+ // Instead, install a DELEGATING shim:
374
+ // - If the specifier is a Node built-in (fs, path, os, …) or
375
+ // a webpack-only runtime hook (require.context), return a
376
+ // safe empty stub.
377
+ // - Otherwise, delegate to the preserved original
378
+ // `globalThis.require` (NativeScript's native CJS loader),
379
+ // which routes `@nativescript/core*` through the HTTP bridge
380
+ // or, for already-HTTP-loaded modules, through the
381
+ // `globalThis.__NS_CORE_MODULES__` registry populated by the
382
+ // `/ns/core` bridge preamble.
383
+ imports += "try { if (typeof globalThis !== 'undefined') {\n";
384
+ imports += " var __nsOrigRequire = typeof globalThis.require === 'function' ? globalThis.require : null;\n";
385
+ 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';
386
+ // Mirror helpers/ns-core-url.ts normalizeCoreSub() inline so the
387
+ // lookup against __NS_CORE_MODULES__ uses the same keys the
388
+ // /ns/core handler registers under.
389
+ imports += ' var __nsNormSub = function (s) {\n';
390
+ imports += " if (!s) return '';\n";
391
+ imports += " var t = String(s).split('?')[0].split('#')[0].trim();\n";
392
+ imports += " t = t.replace(/^\\/+/, '').replace(/\\/+$/, '');\n";
393
+ imports += " t = t.replace(/\\.(?:mjs|cjs|js)$/, '');\n";
394
+ imports += " if (t.length >= 6 && t.substring(t.length - 6) === '/index') t = t.substring(0, t.length - 6);\n";
395
+ imports += " if (!t || t === 'index') return '';\n";
396
+ imports += ' return t;\n';
397
+ imports += ' };\n';
398
+ // Invariant D: CJS/ESM interop shape helper.
399
+ //
400
+ // Install a global, idempotent shape function that converts
401
+ // ESM Module Namespace Objects (which have [[Prototype]] = null
402
+ // per spec §9.4.6) into plain Objects that inherit from
403
+ // Object.prototype. CJS consumers — especially zone.js's
404
+ // patchMethod() — call `hasOwnProperty`, `toString`, etc. on
405
+ // their require() result; a null-proto namespace throws
406
+ // "X is not a function" on the first such call.
407
+ //
408
+ // Properties:
409
+ // - Recursive: @nativescript/core re-exports Utils/Http/Trace
410
+ // as nested namespaces (`export * as Utils from './utils'`),
411
+ // each also null-proto. Shallow wrapping leaves those.
412
+ // - Identity-preserving via a WeakMap cache keyed on the
413
+ // underlying namespace. zone.js MUTATES its target (stashes
414
+ // delegate symbols, overwrites methods); a fresh copy per
415
+ // require() would lose those mutations on the next lookup.
416
+ // - Installed ONCE on globalThis so the /ns/core handler's
417
+ // registration footer, the vendor shim's createRequire, and
418
+ // any other consumer share the same cache and see
419
+ // mutation-consistent shapes.
420
+ imports += ' var __nsShapeCache = globalThis.__NS_CJS_SHAPE_CACHE__ || (globalThis.__NS_CJS_SHAPE_CACHE__ = new WeakMap());\n';
421
+ imports += ' var __nsShapeCjs = globalThis.__NS_CJS_SHAPE__ || (globalThis.__NS_CJS_SHAPE__ = function __nsShape(obj) {\n';
422
+ imports += " if (!obj || typeof obj !== 'object') return obj;\n";
423
+ imports += ' var proto = Object.getPrototypeOf(obj);\n';
424
+ imports += ' var isNsModule = false;\n';
425
+ imports += " try { isNsModule = obj[Symbol.toStringTag] === 'Module'; } catch (e) {}\n";
426
+ imports += ' if (proto !== null && !isNsModule) return obj;\n';
427
+ imports += ' if (__nsShapeCache.has(obj)) return __nsShapeCache.get(obj);\n';
428
+ imports += ' var out = {};\n';
429
+ imports += ' __nsShapeCache.set(obj, out);\n';
430
+ imports += ' try {\n';
431
+ imports += ' var keys = Object.keys(obj);\n';
432
+ imports += ' for (var i = 0; i < keys.length; i++) {\n';
433
+ imports += ' var k = keys[i];\n';
434
+ imports += ' try { out[k] = __nsShape(obj[k]); } catch (e) {}\n';
435
+ imports += ' }\n';
436
+ imports += ' } catch (e) {}\n';
437
+ imports += ' return out;\n';
438
+ imports += ' });\n';
439
+ imports += ' var _nsReq = function (id) {\n';
440
+ imports += ' try {\n';
441
+ imports += " var n = String(id || '');\n";
442
+ imports += " var stripped = n.indexOf('node:') === 0 ? n.slice(5) : n;\n";
443
+ imports += ' if (__nsNodeBuiltins[stripped]) return {};\n';
444
+ imports += " if (n === '@nativescript/core' || n.indexOf('@nativescript/core/') === 0) {\n";
445
+ imports += ' var table = globalThis.__NS_CORE_MODULES__;\n';
446
+ imports += ' if (table) {\n';
447
+ // Table entries are ALREADY shaped (the /ns/core footer stores
448
+ // the shape, not the raw namespace). But we pass through
449
+ // __nsShapeCjs anyway — it's a no-op on already-shaped values
450
+ // (fast path: `proto !== null && !isNsModule` returns obj as-is)
451
+ // and guards against future changes to how the registry is
452
+ // populated (e.g., by direct assignment from test code).
453
+ imports += ' if (table[n]) return __nsShapeCjs(table[n]);\n';
454
+ imports += " var rawSub = n === '@nativescript/core' ? '' : n.slice('@nativescript/core/'.length);\n";
455
+ imports += ' var normSub = __nsNormSub(rawSub);\n';
456
+ imports += " var bareKey = normSub ? '@nativescript/core/' + normSub : '@nativescript/core';\n";
457
+ imports += ' if (table[bareKey]) return __nsShapeCjs(table[bareKey]);\n';
458
+ imports += ' if (table[normSub]) return __nsShapeCjs(table[normSub]);\n';
459
+ imports += ' }\n';
460
+ imports += ' }\n';
461
+ // Fallback to native require (NativeScript CJS loader via HTTP
462
+ // bridge). Shape the result too — the native loader may return
463
+ // a raw ESM namespace for core subpaths served before the /ns/core
464
+ // footer runs.
465
+ imports += ' if (__nsOrigRequire) return __nsShapeCjs(__nsOrigRequire(id));\n';
466
+ imports += ' } catch (e) {}\n';
467
+ imports += ' return {};\n';
468
+ imports += ' };\n';
469
+ imports += ' _nsReq.context = function () { var _c = { keys: function () { return []; } }; _c.__esModule = true; return _c; };\n';
470
+ imports += ' if (__nsOrigRequire) { try { _nsReq.resolve = __nsOrigRequire.resolve ? __nsOrigRequire.resolve.bind(__nsOrigRequire) : function (id) { return id; }; } catch (e) {} }\n';
471
+ imports += ' globalThis.require = _nsReq;\n';
472
+ imports += ' globalThis.__nsOrigRequire = __nsOrigRequire;\n';
473
+ imports += '} } catch {}\n';
102
474
  // Banner diagnostics for visibility at runtime
103
475
  if (opts.verbose) {
104
476
  imports += `console.info('[ns-entry] begin', { platform: ${JSON.stringify(opts.platform)}, dev: ${JSON.stringify(opts.isDevMode)}, hmr: ${JSON.stringify(opts.hmrActive)}, verbose: ${JSON.stringify(opts.verbose)}, mainEntry: ${JSON.stringify(mainEntry)}, mainRel: ${JSON.stringify(mainEntryRelPosix)}, time: new Date().toISOString() });\n`;
105
477
  }
106
478
  if (opts.hmrActive) {
107
- // Seed ALL compile-time defines on globalThis so that every execution
108
- // context the primary bundle, HTTP ESM modules, and cross-realm
109
- // calls can reliably access them. The per-module injection in
110
- // processCodeForDevice() reads from globalThis as the source of truth;
111
- // these seeds ensure the values are always available.
112
- imports += `globalThis.__DEV__ = ${opts.isDevMode ? 'true' : 'false'};\n`;
113
- imports += `globalThis.__ANDROID__ = ${opts.platform === 'android' ? 'true' : 'false'};\n`;
114
- imports += `globalThis.__IOS__ = ${opts.platform === 'ios' ? 'true' : 'false'};\n`;
115
- imports += `globalThis.__VISIONOS__ = ${opts.platform === 'visionos' ? 'true' : 'false'};\n`;
116
- imports += `globalThis.__APPLE__ = ${opts.platform === 'ios' || opts.platform === 'visionos' ? 'true' : 'false'};\n`;
117
- imports += `globalThis.__COMMONJS__ = false;\n`;
118
- imports += `globalThis.__NS_WEBPACK__ = false;\n`;
119
- imports += `globalThis.__NS_ENV_VERBOSE__ = ${opts.verbose ? 'true' : 'false'};\n`;
120
- imports += `globalThis.__UI_USE_XML_PARSER__ = true;\n`;
121
- imports += `globalThis.__UI_USE_EXTERNAL_RENDERER__ = false;\n`;
122
- imports += `globalThis.__CSS_PARSER__ = 'css-tree';\n`;
123
- imports += `globalThis.__TEST__ = false;\n`;
479
+ // NOTE: globalThis defines (`__APPLE__`, `__IOS__`, `__DEV__`,
480
+ // etc.) are seeded by the `virtual:ns-defines-seed` import at
481
+ // the very top of this entry see the import on line ~192.
482
+ // They MUST run as a leaf module ahead of any other graph
483
+ // node, so we can't seed them inline here (ESM imports hoist
484
+ // past inline body code, so any module reachable through
485
+ // `bundle-entry-points` would otherwise see undefined).
124
486
  imports += "import { installModuleProvenanceRecorder } from '@nativescript/vite/hmr/shared/runtime/module-provenance.js';\n";
125
487
  imports += 'installModuleProvenanceRecorder(__nsVerboseLog);\n';
126
488
  }
@@ -128,14 +490,16 @@ export function mainEntryPlugin(opts) {
128
490
  // Install XHR polyfill FIRST — its virtual module body runs during import evaluation,
129
491
  // before any subsequent import (like zone.js) can reference XMLHttpRequest.
130
492
  imports += `import '${XHR_POLYFILL_VIRTUAL_ID}';\n`;
131
- // Load globals early
132
- imports += "import '@nativescript/core/globals/index';\n";
493
+ // Load globals early. Under HMR we use a full HTTP URL so iOS's
494
+ // ESM loader can fetch it directly at module-instantiation time —
495
+ // the import map isn't installed yet at that phase.
496
+ imports += `import ${JSON.stringify(coreSpec('globals/index'))};\n`;
133
497
  if (opts.verbose) {
134
498
  imports += `console.info('[ns-entry] core globals loaded');\n`;
135
499
  }
136
500
  // Seed the real NativeScript Application singleton before any early HMR/placeholder
137
501
  // code runs. Dynamic discovery is too late for iOS placeholder startup.
138
- imports += "import { Application as __nsEarlyApplication } from '@nativescript/core/application';\n";
502
+ imports += `import { Application as __nsEarlyApplication } from ${JSON.stringify(coreSpec('application'))};\n`;
139
503
  imports += `try { if (__nsEarlyApplication && (typeof __nsEarlyApplication.run === 'function' || typeof __nsEarlyApplication.on === 'function' || typeof __nsEarlyApplication.resetRootView === 'function')) { globalThis.Application = __nsEarlyApplication; } } catch {}\n`;
140
504
  if (opts.verbose) {
141
505
  imports += `console.info('[ns-entry] early Application seeded', { hasRun: typeof globalThis.Application?.run === 'function', hasOn: typeof globalThis.Application?.on === 'function', hasResetRootView: typeof globalThis.Application?.resetRootView === 'function' });\n`;
@@ -171,7 +535,7 @@ export function mainEntryPlugin(opts) {
171
535
  }
172
536
  }
173
537
  // Load NS bundle entry points after early hook
174
- imports += "import '@nativescript/core/bundle-entry-points';\n";
538
+ imports += `import ${JSON.stringify(coreSpec('bundle-entry-points'))};\n`;
175
539
  if (opts.verbose) {
176
540
  imports += `console.info('[ns-entry] bundle-entry-points loaded');\n`;
177
541
  }
@@ -238,19 +602,30 @@ export function mainEntryPlugin(opts) {
238
602
  // Import Application statically if needed for CSS or Android activity defer
239
603
  if (hasAppCss || needsAndroidActivityDefer) {
240
604
  if (hasAppCss) {
241
- imports += `// Import and apply global CSS before app bootstrap\n`;
605
+ // The virtual module's body either:
606
+ // - non-HMR: calls `addTaggedAdditionalCSS(ast, 'app.css')`
607
+ // as an import-time side-effect, landing CSS in NS's
608
+ // selector tables before any view is created.
609
+ // - HMR: stashes the rework AST on
610
+ // `globalThis.__NS_HMR_APP_CSS_AST__` so
611
+ // `installHttpCoreCssSupport` can apply it via the SAME
612
+ // AST path in the HTTP-core realm. The default export
613
+ // is the raw CSS string, also seeded onto
614
+ // `globalThis.__NS_HMR_APP_CSS__` here as a
615
+ // raw-text fallback (used for live HMR edits via the
616
+ // dev-server WebSocket).
617
+ imports += `// Apply global CSS before app bootstrap (AST under non-HMR; AST stashed for HMR cold boot)\n`;
242
618
  imports += `import appCssContent from '${APP_CSS_VIRTUAL_ID}';\n`;
243
619
  if (opts.hmrActive) {
244
620
  imports += `try { globalThis.__NS_HMR_APP_CSS__ = appCssContent; } catch {}\n`;
245
621
  }
246
- }
247
- imports += `import { Application } from '@nativescript/core';\n`;
248
- if (hasAppCss) {
249
- imports += `if (appCssContent) { try { Application.addCss(appCssContent); } catch (error) { console.error('Error applying CSS:', error); } }\n`;
250
622
  if (opts.verbose) {
251
- imports += `console.info('[ns-entry] app.css applied');\n`;
623
+ imports += `console.info('[ns-entry] app.css applied as AST');\n`;
252
624
  }
253
625
  }
626
+ if (needsAndroidActivityDefer) {
627
+ imports += `import { Application } from ${JSON.stringify(coreSpec())};\n`;
628
+ }
254
629
  }
255
630
  // ---- Deferred Android activity import (non-HMR only) ----
256
631
  // Uses the statically imported Application to avoid mixing dynamic and static imports
@@ -278,15 +653,23 @@ export function mainEntryPlugin(opts) {
278
653
  if (opts.verbose) {
279
654
  imports += `console.info('[ns-entry] including deterministic dev session bootstrap', { platform: ${JSON.stringify(opts.platform)}, mainRel: ${JSON.stringify(mainEntryRelPosix)} });\n`;
280
655
  }
281
- const configuredHost = typeof resolvedConfig.server.host === 'string' && resolvedConfig.server.host ? resolvedConfig.server.host : 'localhost';
282
- const bootHost = (process.env.NS_HMR_HOST || '') || configuredHost;
283
- const bootProtocol = resolvedConfig.server.https || opts.useHttps ? 'https' : 'http';
284
- const bootPort = Number(resolvedConfig.server.port || 5173);
285
- const sessionUrl = bootProtocol + '://' + bootHost + ':' + String(bootPort) + '/__ns_dev__/session';
656
+ // Same device-reachable origin as `getBootOrigin()` so the
657
+ // session-descriptor URL and every `/ns/core/*` URL baked
658
+ // into bundle.mjs come from one canonical source. Without
659
+ // this, Android's `bundle.mjs` would hit `0.0.0.0:5173` for
660
+ // both endpoints (server.host's wildcard bind) and fail at
661
+ // boot before any user code runs.
662
+ const { origin: bootOrigin } = resolveDeviceReachableOrigin({
663
+ host: resolvedConfig.server.host,
664
+ platform: opts.platform,
665
+ protocol: resolvedConfig.server.https || opts.useHttps ? 'https' : 'http',
666
+ port: Number(resolvedConfig.server.port || 5173),
667
+ });
668
+ const sessionUrl = bootOrigin + '/__ns_dev__/session';
286
669
  imports += "import { startBrowserRuntimeSession } from '@nativescript/vite/hmr/shared/runtime/session-bootstrap.js';\n";
287
670
  imports += `startBrowserRuntimeSession(${JSON.stringify(sessionUrl)}, __nsVerboseLog).catch((error) => {\n`;
288
671
  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`;
289
- imports += ` try { console.error('[ns-entry] deterministic dev session bootstrap failed', error && error.stack ? error.stack : error); } catch {}\n`;
672
+ imports += ` console.error('[ns-entry] deterministic dev session bootstrap failed', error && error.stack ? error.stack : error);\n`;
290
673
  imports += `});\n`;
291
674
  if (opts.verbose) {
292
675
  imports += `console.info('[ns-entry] deterministic dev session bootstrap appended');\n`;
@@ -300,7 +683,7 @@ export function mainEntryPlugin(opts) {
300
683
  }
301
684
  if (opts.isDevMode) {
302
685
  // debug tools support
303
- imports += "import '@nativescript/core/inspector_modules';\n";
686
+ imports += `import ${JSON.stringify(coreSpec('inspector_modules'))};\n`;
304
687
  if (opts.verbose) {
305
688
  imports += "console.info('[ns-entry] inspector modules imported');\n";
306
689
  }