@nativescript/vite 8.0.0-alpha.4 → 8.0.0-alpha.41

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 (410) hide show
  1. package/README.md +51 -11
  2. package/bin/cli.cjs +8 -14
  3. package/configuration/angular.d.ts +34 -1
  4. package/configuration/angular.js +376 -165
  5. package/configuration/angular.js.map +1 -1
  6. package/configuration/base.js +256 -30
  7. package/configuration/base.js.map +1 -1
  8. package/configuration/javascript.js +12 -90
  9. package/configuration/javascript.js.map +1 -1
  10. package/configuration/solid.js +33 -4
  11. package/configuration/solid.js.map +1 -1
  12. package/configuration/typescript.js +10 -90
  13. package/configuration/typescript.js.map +1 -1
  14. package/helpers/app-components.d.ts +2 -1
  15. package/helpers/app-components.js.map +1 -1
  16. package/helpers/app-css-state.d.ts +8 -0
  17. package/helpers/app-css-state.js +8 -0
  18. package/helpers/app-css-state.js.map +1 -0
  19. package/helpers/bundler-context.d.ts +11 -0
  20. package/helpers/bundler-context.js +71 -0
  21. package/helpers/bundler-context.js.map +1 -0
  22. package/helpers/config-as-json.js +10 -0
  23. package/helpers/config-as-json.js.map +1 -1
  24. package/helpers/css-platform-plugin.d.ts +14 -0
  25. package/helpers/css-platform-plugin.js +43 -25
  26. package/helpers/css-platform-plugin.js.map +1 -1
  27. package/helpers/dev-host.d.ts +360 -0
  28. package/helpers/dev-host.js +692 -0
  29. package/helpers/dev-host.js.map +1 -0
  30. package/helpers/dynamic-import-plugin.js +1 -1
  31. package/helpers/dynamic-import-plugin.js.map +1 -1
  32. package/helpers/esbuild-platform-resolver.js +4 -1
  33. package/helpers/esbuild-platform-resolver.js.map +1 -1
  34. package/helpers/external-configs.d.ts +10 -12
  35. package/helpers/external-configs.js +54 -35
  36. package/helpers/external-configs.js.map +1 -1
  37. package/helpers/global-defines.d.ts +128 -0
  38. package/helpers/global-defines.js +174 -11
  39. package/helpers/global-defines.js.map +1 -1
  40. package/helpers/hmr-scope.d.ts +26 -0
  41. package/helpers/hmr-scope.js +67 -0
  42. package/helpers/hmr-scope.js.map +1 -0
  43. package/helpers/init.js +0 -18
  44. package/helpers/init.js.map +1 -1
  45. package/helpers/logging.d.ts +1 -0
  46. package/helpers/logging.js +65 -4
  47. package/helpers/logging.js.map +1 -1
  48. package/helpers/main-entry.d.ts +3 -1
  49. package/helpers/main-entry.js +444 -50
  50. package/helpers/main-entry.js.map +1 -1
  51. package/helpers/nativeclass-esbuild-plugin.d.ts +2 -1
  52. package/helpers/nativeclass-esbuild-plugin.js.map +1 -1
  53. package/helpers/nativeclass-transform.js +5 -6
  54. package/helpers/nativeclass-transform.js.map +1 -1
  55. package/helpers/nativeclass-transformer-plugin.d.ts +9 -2
  56. package/helpers/nativeclass-transformer-plugin.js +157 -14
  57. package/helpers/nativeclass-transformer-plugin.js.map +1 -1
  58. package/helpers/nativescript-package-resolver.js +10 -62
  59. package/helpers/nativescript-package-resolver.js.map +1 -1
  60. package/helpers/normalize-id.d.ts +42 -0
  61. package/helpers/normalize-id.js +60 -0
  62. package/helpers/normalize-id.js.map +1 -0
  63. package/helpers/ns-core-url.d.ts +106 -0
  64. package/helpers/ns-core-url.js +225 -0
  65. package/helpers/ns-core-url.js.map +1 -0
  66. package/helpers/optimize-deps.d.ts +16 -0
  67. package/helpers/optimize-deps.js +17 -0
  68. package/helpers/optimize-deps.js.map +1 -0
  69. package/helpers/package-platform-aliases.js +34 -49
  70. package/helpers/package-platform-aliases.js.map +1 -1
  71. package/helpers/platform-types.d.ts +2 -0
  72. package/helpers/platform-types.js +2 -0
  73. package/helpers/platform-types.js.map +1 -0
  74. package/helpers/postcss-platform-config.d.ts +17 -1
  75. package/helpers/postcss-platform-config.js +20 -37
  76. package/helpers/postcss-platform-config.js.map +1 -1
  77. package/helpers/project.d.ts +35 -0
  78. package/helpers/project.js +120 -2
  79. package/helpers/project.js.map +1 -1
  80. package/helpers/resolve-main-field-platform.d.ts +20 -0
  81. package/helpers/resolve-main-field-platform.js +49 -0
  82. package/helpers/resolve-main-field-platform.js.map +1 -0
  83. package/helpers/resolver.js +17 -2
  84. package/helpers/resolver.js.map +1 -1
  85. package/helpers/theme-core-plugins.js +1 -1
  86. package/helpers/theme-core-plugins.js.map +1 -1
  87. package/helpers/ts-config-paths.d.ts +14 -0
  88. package/helpers/ts-config-paths.js +90 -9
  89. package/helpers/ts-config-paths.js.map +1 -1
  90. package/helpers/typescript-check.d.ts +2 -1
  91. package/helpers/typescript-check.js.map +1 -1
  92. package/helpers/ui-registration.d.ts +21 -0
  93. package/helpers/ui-registration.js +156 -0
  94. package/helpers/ui-registration.js.map +1 -0
  95. package/helpers/utils.js +1 -2
  96. package/helpers/utils.js.map +1 -1
  97. package/helpers/workers.d.ts +20 -19
  98. package/helpers/workers.js +624 -4
  99. package/helpers/workers.js.map +1 -1
  100. package/hmr/client/css-handler.d.ts +2 -1
  101. package/hmr/client/css-handler.js +50 -26
  102. package/hmr/client/css-handler.js.map +1 -1
  103. package/hmr/client/css-update-overlay.d.ts +18 -0
  104. package/hmr/client/css-update-overlay.js +27 -0
  105. package/hmr/client/css-update-overlay.js.map +1 -0
  106. package/hmr/client/framework-client-strategy.d.ts +79 -0
  107. package/hmr/client/framework-client-strategy.js +19 -0
  108. package/hmr/client/framework-client-strategy.js.map +1 -0
  109. package/hmr/client/hmr-pending-overlay.d.ts +13 -0
  110. package/hmr/client/hmr-pending-overlay.js +60 -0
  111. package/hmr/client/hmr-pending-overlay.js.map +1 -0
  112. package/hmr/client/index.js +820 -212
  113. package/hmr/client/index.js.map +1 -1
  114. package/hmr/client/utils.d.ts +7 -1
  115. package/hmr/client/utils.js +207 -29
  116. package/hmr/client/utils.js.map +1 -1
  117. package/hmr/entry-runtime.d.ts +2 -1
  118. package/hmr/entry-runtime.js +256 -69
  119. package/hmr/entry-runtime.js.map +1 -1
  120. package/hmr/frameworks/angular/build/angular-linker.d.ts +12 -0
  121. package/hmr/frameworks/angular/build/angular-linker.js +109 -0
  122. package/hmr/frameworks/angular/build/angular-linker.js.map +1 -0
  123. package/hmr/frameworks/angular/build/inject-component-hmr-registration.d.ts +112 -0
  124. package/hmr/frameworks/angular/build/inject-component-hmr-registration.js +291 -0
  125. package/hmr/frameworks/angular/build/inject-component-hmr-registration.js.map +1 -0
  126. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.d.ts +75 -0
  127. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js +221 -0
  128. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js.map +1 -0
  129. package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.js +1 -170
  130. package/hmr/frameworks/angular/build/inline-decorator-component-templates.js.map +1 -0
  131. package/hmr/frameworks/angular/build/js-lexer.d.ts +4 -0
  132. package/{helpers/angular/synthesize-decorator-ctor-parameters.js → hmr/frameworks/angular/build/js-lexer.js} +22 -96
  133. package/hmr/frameworks/angular/build/js-lexer.js.map +1 -0
  134. package/hmr/frameworks/angular/build/shared-linker.d.ts +39 -0
  135. package/hmr/frameworks/angular/build/shared-linker.js +128 -0
  136. package/hmr/frameworks/angular/build/shared-linker.js.map +1 -0
  137. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js +88 -0
  138. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js.map +1 -0
  139. package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.js +1 -174
  140. package/hmr/frameworks/angular/build/synthesize-injectable-factories.js.map +1 -0
  141. package/{helpers/angular → hmr/frameworks/angular/build}/util.d.ts +1 -0
  142. package/hmr/frameworks/angular/build/util.js +155 -0
  143. package/hmr/frameworks/angular/build/util.js.map +1 -0
  144. package/hmr/frameworks/angular/client/index.d.ts +1 -0
  145. package/hmr/frameworks/angular/client/index.js +803 -21
  146. package/hmr/frameworks/angular/client/index.js.map +1 -1
  147. package/hmr/frameworks/angular/client/strategy.d.ts +9 -0
  148. package/hmr/frameworks/angular/client/strategy.js +19 -0
  149. package/hmr/frameworks/angular/client/strategy.js.map +1 -0
  150. package/hmr/frameworks/angular/server/angular-root-component.d.ts +79 -0
  151. package/hmr/frameworks/angular/server/angular-root-component.js +149 -0
  152. package/hmr/frameworks/angular/server/angular-root-component.js.map +1 -0
  153. package/hmr/frameworks/angular/server/linker.js +1 -4
  154. package/hmr/frameworks/angular/server/linker.js.map +1 -1
  155. package/hmr/frameworks/angular/server/strategy.js +460 -12
  156. package/hmr/frameworks/angular/server/strategy.js.map +1 -1
  157. package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.js +2 -2
  158. package/hmr/frameworks/angular/server/websocket-angular-entry.js.map +1 -0
  159. package/hmr/{server → frameworks/angular/server}/websocket-angular-hot-update.d.ts +17 -11
  160. package/hmr/frameworks/angular/server/websocket-angular-hot-update.js +336 -0
  161. package/hmr/frameworks/angular/server/websocket-angular-hot-update.js.map +1 -0
  162. package/hmr/frameworks/solid/build/solid-jsx-deps.d.ts +15 -0
  163. package/hmr/frameworks/solid/build/solid-jsx-deps.js +178 -0
  164. package/hmr/frameworks/solid/build/solid-jsx-deps.js.map +1 -0
  165. package/hmr/frameworks/solid/server/strategy.js +291 -16
  166. package/hmr/frameworks/solid/server/strategy.js.map +1 -1
  167. package/hmr/frameworks/typescript/server/strategy.js +38 -14
  168. package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
  169. package/hmr/frameworks/vue/client/dep-propagation.d.ts +36 -0
  170. package/hmr/frameworks/vue/client/dep-propagation.js +101 -0
  171. package/hmr/frameworks/vue/client/dep-propagation.js.map +1 -0
  172. package/hmr/frameworks/vue/client/index.d.ts +8 -0
  173. package/hmr/frameworks/vue/client/index.js +56 -243
  174. package/hmr/frameworks/vue/client/index.js.map +1 -1
  175. package/hmr/frameworks/vue/client/strategy.d.ts +33 -0
  176. package/hmr/frameworks/vue/client/strategy.js +157 -0
  177. package/hmr/frameworks/vue/client/strategy.js.map +1 -0
  178. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.d.ts +49 -0
  179. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js +142 -0
  180. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js.map +1 -0
  181. package/hmr/frameworks/vue/server/sfc-route-assemble.d.ts +7 -0
  182. package/hmr/frameworks/vue/server/sfc-route-assemble.js +747 -0
  183. package/hmr/frameworks/vue/server/sfc-route-assemble.js.map +1 -0
  184. package/hmr/frameworks/vue/server/sfc-route-meta.d.ts +7 -0
  185. package/hmr/frameworks/vue/server/sfc-route-meta.js +80 -0
  186. package/hmr/frameworks/vue/server/sfc-route-meta.js.map +1 -0
  187. package/hmr/frameworks/vue/server/sfc-route-serve.d.ts +8 -0
  188. package/hmr/frameworks/vue/server/sfc-route-serve.js +459 -0
  189. package/hmr/frameworks/vue/server/sfc-route-serve.js.map +1 -0
  190. package/hmr/frameworks/vue/server/sfc-route-shared.d.ts +38 -0
  191. package/hmr/frameworks/vue/server/sfc-route-shared.js +48 -0
  192. package/hmr/frameworks/vue/server/sfc-route-shared.js.map +1 -0
  193. package/hmr/frameworks/vue/server/strategy.d.ts +35 -0
  194. package/hmr/frameworks/vue/server/strategy.js +278 -1
  195. package/hmr/frameworks/vue/server/strategy.js.map +1 -1
  196. package/hmr/frameworks/vue/server/websocket-sfc.d.ts +15 -0
  197. package/hmr/frameworks/vue/server/websocket-sfc.js +20 -0
  198. package/hmr/frameworks/vue/server/websocket-sfc.js.map +1 -0
  199. package/hmr/helpers/ast-normalizer.d.ts +3 -1
  200. package/hmr/helpers/ast-normalizer.js +77 -10
  201. package/hmr/helpers/ast-normalizer.js.map +1 -1
  202. package/hmr/helpers/cjs-named-exports.d.ts +23 -0
  203. package/hmr/helpers/cjs-named-exports.js +152 -0
  204. package/hmr/helpers/cjs-named-exports.js.map +1 -0
  205. package/hmr/helpers/package-exports.d.ts +16 -0
  206. package/hmr/helpers/package-exports.js +396 -0
  207. package/hmr/helpers/package-exports.js.map +1 -0
  208. package/hmr/server/constants.js +20 -5
  209. package/hmr/server/constants.js.map +1 -1
  210. package/hmr/server/core-sanitize.d.ts +90 -7
  211. package/hmr/server/core-sanitize.js +211 -56
  212. package/hmr/server/core-sanitize.js.map +1 -1
  213. package/hmr/server/device-transform-helpers.d.ts +24 -0
  214. package/hmr/server/device-transform-helpers.js +369 -0
  215. package/hmr/server/device-transform-helpers.js.map +1 -0
  216. package/hmr/server/framework-strategy.d.ts +108 -11
  217. package/hmr/server/hmr-module-graph.d.ts +37 -0
  218. package/hmr/server/hmr-module-graph.js +214 -0
  219. package/hmr/server/hmr-module-graph.js.map +1 -0
  220. package/hmr/server/import-map.d.ts +11 -2
  221. package/hmr/server/import-map.js +95 -44
  222. package/hmr/server/import-map.js.map +1 -1
  223. package/hmr/server/index.js +7 -16
  224. package/hmr/server/index.js.map +1 -1
  225. package/hmr/server/ns-core-cjs-shape.d.ts +204 -0
  226. package/hmr/server/ns-core-cjs-shape.js +271 -0
  227. package/hmr/server/ns-core-cjs-shape.js.map +1 -0
  228. package/hmr/server/ns-rt-bridge.d.ts +51 -0
  229. package/hmr/server/ns-rt-bridge.js +131 -0
  230. package/hmr/server/ns-rt-bridge.js.map +1 -0
  231. package/hmr/server/ns-rt-route.d.ts +5 -0
  232. package/hmr/server/ns-rt-route.js +38 -0
  233. package/hmr/server/ns-rt-route.js.map +1 -0
  234. package/hmr/server/perf-instrumentation.d.ts +114 -0
  235. package/hmr/server/perf-instrumentation.js +197 -0
  236. package/hmr/server/perf-instrumentation.js.map +1 -0
  237. package/hmr/server/process-code-for-device.d.ts +14 -0
  238. package/hmr/server/process-code-for-device.js +702 -0
  239. package/hmr/server/process-code-for-device.js.map +1 -0
  240. package/hmr/server/require-guard.d.ts +1 -0
  241. package/hmr/server/require-guard.js +12 -0
  242. package/hmr/server/require-guard.js.map +1 -0
  243. package/hmr/server/rewrite-imports.d.ts +2 -0
  244. package/hmr/server/rewrite-imports.js +600 -0
  245. package/hmr/server/rewrite-imports.js.map +1 -0
  246. package/hmr/server/route-helpers.d.ts +7 -0
  247. package/hmr/server/route-helpers.js +13 -0
  248. package/hmr/server/route-helpers.js.map +1 -0
  249. package/hmr/server/server-origin.d.ts +2 -0
  250. package/hmr/server/server-origin.js +83 -0
  251. package/hmr/server/server-origin.js.map +1 -0
  252. package/hmr/server/shared-transform-request.js +13 -7
  253. package/hmr/server/shared-transform-request.js.map +1 -1
  254. package/hmr/server/transform-cache-invalidation.d.ts +37 -0
  255. package/hmr/server/transform-cache-invalidation.js +156 -0
  256. package/hmr/server/transform-cache-invalidation.js.map +1 -0
  257. package/hmr/server/vendor-bare-module-shims.d.ts +4 -0
  258. package/hmr/server/vendor-bare-module-shims.js +80 -0
  259. package/hmr/server/vendor-bare-module-shims.js.map +1 -0
  260. package/hmr/server/vite-plugin.js +72 -42
  261. package/hmr/server/vite-plugin.js.map +1 -1
  262. package/hmr/server/websocket-core-bridge.d.ts +45 -6
  263. package/hmr/server/websocket-core-bridge.js +81 -77
  264. package/hmr/server/websocket-core-bridge.js.map +1 -1
  265. package/hmr/server/websocket-css-hot-update.d.ts +33 -0
  266. package/hmr/server/websocket-css-hot-update.js +65 -0
  267. package/hmr/server/websocket-css-hot-update.js.map +1 -0
  268. package/hmr/server/websocket-device-transform.d.ts +3 -0
  269. package/hmr/server/websocket-device-transform.js +7 -0
  270. package/hmr/server/websocket-device-transform.js.map +1 -0
  271. package/hmr/server/websocket-graph-upsert.d.ts +15 -0
  272. package/hmr/server/websocket-graph-upsert.js +20 -0
  273. package/hmr/server/websocket-graph-upsert.js.map +1 -1
  274. package/hmr/server/websocket-hmr-pending.d.ts +37 -0
  275. package/hmr/server/websocket-hmr-pending.js +55 -0
  276. package/hmr/server/websocket-hmr-pending.js.map +1 -0
  277. package/hmr/server/websocket-hot-update.d.ts +77 -0
  278. package/hmr/server/websocket-hot-update.js +360 -0
  279. package/hmr/server/websocket-hot-update.js.map +1 -0
  280. package/hmr/server/websocket-import-map-route.d.ts +15 -0
  281. package/hmr/server/websocket-import-map-route.js +50 -0
  282. package/hmr/server/websocket-import-map-route.js.map +1 -0
  283. package/hmr/server/websocket-module-bindings.js +3 -3
  284. package/hmr/server/websocket-module-bindings.js.map +1 -1
  285. package/hmr/server/websocket-module-specifiers.d.ts +66 -2
  286. package/hmr/server/websocket-module-specifiers.js +203 -20
  287. package/hmr/server/websocket-module-specifiers.js.map +1 -1
  288. package/hmr/server/websocket-ns-core.d.ts +21 -0
  289. package/hmr/server/websocket-ns-core.js +311 -0
  290. package/hmr/server/websocket-ns-core.js.map +1 -0
  291. package/hmr/server/websocket-ns-entry.d.ts +21 -0
  292. package/hmr/server/websocket-ns-entry.js +164 -0
  293. package/hmr/server/websocket-ns-entry.js.map +1 -0
  294. package/hmr/server/websocket-ns-m-paths.d.ts +1 -1
  295. package/hmr/server/websocket-ns-m-paths.js +58 -13
  296. package/hmr/server/websocket-ns-m-paths.js.map +1 -1
  297. package/hmr/server/websocket-ns-m-request.d.ts +11 -1
  298. package/hmr/server/websocket-ns-m-request.js +18 -25
  299. package/hmr/server/websocket-ns-m-request.js.map +1 -1
  300. package/hmr/server/websocket-ns-m.d.ts +33 -0
  301. package/hmr/server/websocket-ns-m.js +752 -0
  302. package/hmr/server/websocket-ns-m.js.map +1 -0
  303. package/hmr/server/websocket-served-module-helpers.d.ts +82 -0
  304. package/hmr/server/websocket-served-module-helpers.js +879 -0
  305. package/hmr/server/websocket-served-module-helpers.js.map +1 -0
  306. package/hmr/server/websocket-txn.js +2 -8
  307. package/hmr/server/websocket-txn.js.map +1 -1
  308. package/hmr/server/websocket-vendor-unifier.d.ts +0 -1
  309. package/hmr/server/websocket-vendor-unifier.js +4 -9
  310. package/hmr/server/websocket-vendor-unifier.js.map +1 -1
  311. package/hmr/server/websocket.d.ts +8 -39
  312. package/hmr/server/websocket.js +514 -4030
  313. package/hmr/server/websocket.js.map +1 -1
  314. package/hmr/shared/ns-globals.d.ts +118 -0
  315. package/hmr/shared/ns-globals.js +29 -0
  316. package/hmr/shared/ns-globals.js.map +1 -0
  317. package/hmr/shared/protocol.d.ts +145 -0
  318. package/hmr/shared/protocol.js +28 -0
  319. package/hmr/shared/protocol.js.map +1 -0
  320. package/hmr/shared/runtime/boot-placeholder-ui.d.ts +69 -0
  321. package/hmr/shared/runtime/boot-placeholder-ui.js +101 -0
  322. package/hmr/shared/runtime/boot-placeholder-ui.js.map +1 -0
  323. package/hmr/shared/runtime/boot-progress.d.ts +44 -0
  324. package/hmr/shared/runtime/boot-progress.js +133 -0
  325. package/hmr/shared/runtime/boot-progress.js.map +1 -0
  326. package/hmr/shared/runtime/boot-timeline.d.ts +18 -0
  327. package/hmr/shared/runtime/boot-timeline.js +42 -0
  328. package/hmr/shared/runtime/boot-timeline.js.map +1 -0
  329. package/hmr/shared/runtime/browser-runtime-contract.js.map +1 -1
  330. package/hmr/shared/runtime/dev-overlay-snapshots.d.ts +31 -0
  331. package/hmr/shared/runtime/dev-overlay-snapshots.js +324 -0
  332. package/hmr/shared/runtime/dev-overlay-snapshots.js.map +1 -0
  333. package/hmr/shared/runtime/dev-overlay.d.ts +119 -26
  334. package/hmr/shared/runtime/dev-overlay.js +1153 -261
  335. package/hmr/shared/runtime/dev-overlay.js.map +1 -1
  336. package/hmr/shared/runtime/global-scope.d.ts +18 -0
  337. package/hmr/shared/runtime/global-scope.js +21 -0
  338. package/hmr/shared/runtime/global-scope.js.map +1 -0
  339. package/hmr/shared/runtime/hooks.js +2 -1
  340. package/hmr/shared/runtime/hooks.js.map +1 -1
  341. package/hmr/shared/runtime/http-only-boot.js +7 -6
  342. package/hmr/shared/runtime/http-only-boot.js.map +1 -1
  343. package/hmr/shared/runtime/module-provenance.js +4 -6
  344. package/hmr/shared/runtime/module-provenance.js.map +1 -1
  345. package/hmr/shared/runtime/root-placeholder-view.d.ts +19 -0
  346. package/hmr/shared/runtime/root-placeholder-view.js +311 -0
  347. package/hmr/shared/runtime/root-placeholder-view.js.map +1 -0
  348. package/hmr/shared/runtime/root-placeholder.js +371 -197
  349. package/hmr/shared/runtime/root-placeholder.js.map +1 -1
  350. package/hmr/shared/runtime/session-bootstrap.js +168 -4
  351. package/hmr/shared/runtime/session-bootstrap.js.map +1 -1
  352. package/hmr/shared/runtime/vendor-bootstrap.js +3 -10
  353. package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
  354. package/hmr/shared/vendor/manifest-collect.d.ts +4 -0
  355. package/hmr/shared/vendor/manifest-collect.js +512 -0
  356. package/hmr/shared/vendor/manifest-collect.js.map +1 -0
  357. package/hmr/shared/vendor/manifest-loader.d.ts +2 -1
  358. package/hmr/shared/vendor/manifest-loader.js +5 -3
  359. package/hmr/shared/vendor/manifest-loader.js.map +1 -1
  360. package/hmr/shared/vendor/manifest.d.ts +1 -7
  361. package/hmr/shared/vendor/manifest.js +102 -741
  362. package/hmr/shared/vendor/manifest.js.map +1 -1
  363. package/hmr/shared/vendor/vendor-device-shim.d.ts +1 -0
  364. package/hmr/shared/vendor/vendor-device-shim.js +208 -0
  365. package/hmr/shared/vendor/vendor-device-shim.js.map +1 -0
  366. package/hmr/shared/vendor/vendor-esbuild-plugins.d.ts +16 -0
  367. package/hmr/shared/vendor/vendor-esbuild-plugins.js +203 -0
  368. package/hmr/shared/vendor/vendor-esbuild-plugins.js.map +1 -0
  369. package/hmr/vendor-bootstrap.d.ts +1 -3
  370. package/hmr/vendor-bootstrap.js +4 -6
  371. package/hmr/vendor-bootstrap.js.map +1 -1
  372. package/index.d.ts +1 -0
  373. package/index.js +5 -0
  374. package/index.js.map +1 -1
  375. package/package.json +55 -11
  376. package/runtime/core-aliases-early.js +25 -55
  377. package/runtime/core-aliases-early.js.map +1 -1
  378. package/helpers/angular/angular-linker.d.ts +0 -13
  379. package/helpers/angular/angular-linker.js +0 -194
  380. package/helpers/angular/angular-linker.js.map +0 -1
  381. package/helpers/angular/inline-decorator-component-templates.js.map +0 -1
  382. package/helpers/angular/shared-linker.d.ts +0 -11
  383. package/helpers/angular/shared-linker.js +0 -75
  384. package/helpers/angular/shared-linker.js.map +0 -1
  385. package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +0 -1
  386. package/helpers/angular/synthesize-injectable-factories.js.map +0 -1
  387. package/helpers/angular/util.js +0 -67
  388. package/helpers/angular/util.js.map +0 -1
  389. package/helpers/prelink-angular.d.ts +0 -2
  390. package/helpers/prelink-angular.js +0 -117
  391. package/helpers/prelink-angular.js.map +0 -1
  392. package/hmr/server/websocket-angular-entry.js.map +0 -1
  393. package/hmr/server/websocket-angular-hot-update.js +0 -239
  394. package/hmr/server/websocket-angular-hot-update.js.map +0 -1
  395. package/hmr/server/websocket-ns-m-finalize.d.ts +0 -32
  396. package/hmr/server/websocket-ns-m-finalize.js +0 -73
  397. package/hmr/server/websocket-ns-m-finalize.js.map +0 -1
  398. package/hmr/server/websocket-runtime-compat.d.ts +0 -19
  399. package/hmr/server/websocket-runtime-compat.js +0 -286
  400. package/hmr/server/websocket-runtime-compat.js.map +0 -1
  401. package/hmr/server/websocket-vue-sfc.d.ts +0 -35
  402. package/hmr/server/websocket-vue-sfc.js +0 -1116
  403. package/hmr/server/websocket-vue-sfc.js.map +0 -1
  404. package/transformers/NativeClass/index.d.ts +0 -2
  405. package/transformers/NativeClass/index.js +0 -222
  406. package/transformers/NativeClass/index.js.map +0 -1
  407. /package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.d.ts +0 -0
  408. /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-decorator-ctor-parameters.d.ts +0 -0
  409. /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.d.ts +0 -0
  410. /package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.d.ts +0 -0
@@ -2,10 +2,16 @@ 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';
13
+ import { rewritePlatformCssImports } from './css-platform-plugin.js';
14
+ import { buildGlobalSeedStatements, getRuntimeSeedValues } from './global-defines.js';
9
15
  // Switched to runtime modules to avoid fragile string injection and enable TS checks
10
16
  const projectRoot = getProjectRootPath();
11
17
  const appRootDir = getProjectAppPath();
@@ -51,13 +57,139 @@ const APP_CSS_RESOLVED = '\0' + APP_CSS_VIRTUAL_ID;
51
57
  // polyfill is installed during module evaluation (before zone.js patches run).
52
58
  const XHR_POLYFILL_VIRTUAL_ID = 'virtual:ns-xhr-polyfill';
53
59
  const XHR_POLYFILL_RESOLVED = '\0' + XHR_POLYFILL_VIRTUAL_ID;
60
+ // Virtual module that seeds compile-time defines (`__APPLE__`, `__IOS__`,
61
+ // `__DEV__`, etc.) on `globalThis` BEFORE any other module evaluates.
62
+ //
63
+ // Why this exists. The per-module shim that `processCodeForDevice` injects
64
+ // at the top of every served module reads these values from `globalThis`:
65
+ // const __APPLE__ = globalThis.__APPLE__ !== undefined
66
+ // ? globalThis.__APPLE__
67
+ // : (__IOS__ || __VISIONOS__);
68
+ // `const` evaluates ONCE at module instantiation. So every module needs
69
+ // `globalThis.__APPLE__` to already be set when it instantiates — otherwise
70
+ // it locks in `false` for the lifetime of the module.
71
+ //
72
+ // In ESM, all `import` statements hoist to the top of the module's
73
+ // evaluation phase: imports run in DFS post-order BEFORE the importing
74
+ // module's body. If we put the seed assignments inline in the entry's
75
+ // body (e.g. `globalThis.__APPLE__ = true`), they run AFTER every module
76
+ // transitively imported via `bundle-entry-points` (which reaches the
77
+ // user's `main.ts` → `app.module.ts` → services → util files). Those
78
+ // utility modules then snapshot `globalThis.__APPLE__ = undefined` and
79
+ // fall through to the `false` branch — landing iOS code in the
80
+ // `else { /* Android */ }` branch and crashing on `Utils.android.*`.
81
+ //
82
+ // The fix is to import this virtual module FIRST in the entry. As a leaf
83
+ // in the dependency graph it evaluates before every sibling import, so
84
+ // its body assignments happen before any user module instantiates and
85
+ // reads `globalThis.__*`. This is the architecturally-correct way to
86
+ // make values available to other modules across the import graph in ESM.
87
+ const DEFINES_SEED_VIRTUAL_ID = 'virtual:ns-defines-seed';
88
+ const DEFINES_SEED_RESOLVED = '\0' + DEFINES_SEED_VIRTUAL_ID;
54
89
  export function mainEntryPlugin(opts) {
55
90
  let resolvedConfig;
91
+ // Prefer the flavor the active config DECLARES (threaded from baseConfig)
92
+ // over deps-based detection: in workspaces whose app package.json doesn't
93
+ // list the framework package (hoisted to the root), detection falls through
94
+ // to 'typescript' — which previously emitted the ts-only
95
+ // `virtual:ns-ui-registration` import into an Angular entry with no
96
+ // resolver registered, and seeded the wrong `__NS_TARGET_FLAVOR__`.
97
+ const effectiveFlavor = opts.flavor || flavor;
56
98
  return {
57
99
  name: 'main-entry',
58
100
  configResolved(config) {
59
101
  resolvedConfig = config;
60
102
  },
103
+ // Warm chokidar with `app.css`'s @import dependency tree at
104
+ // server startup. Without this, the FIRST save to a workspace
105
+ // `@import` dep (e.g. `<repo>/libs/.../index.css`) is silently
106
+ // dropped: nothing in the cold-boot path causes the dev server
107
+ // to transform `app.css`, so `vite:css` never registers
108
+ // `@import`-resolved deps with the watcher. Eagerly resolving
109
+ // them here breaks the chicken-and-egg.
110
+ //
111
+ // We ALSO stash the resolved dep set on the server itself so
112
+ // the HMR websocket handler can recognize when a non-CSS edit
113
+ // (e.g. a `.html` template or `.ts` file scanned by Tailwind's
114
+ // content config) should trigger a fresh `app.css` fetch. The
115
+ // `preprocessCSS` deps include every file PostCSS reported as
116
+ // a `dependency` message — for Tailwind 3 with content globs,
117
+ // Vite's `compileCSS` expands the `dir-dependency` glob into
118
+ // the individual file paths, so we get the full content set.
119
+ //
120
+ // `app.css` is NEVER a real Vite module in NS HMR (the virtual
121
+ // `:ns-app-css` module re-runs `preprocessCSS` in its load
122
+ // hook), so the standard moduleGraph `addWatchFile` →
123
+ // `_addedImports` → file-only-entry-importer chain doesn't
124
+ // populate, and `ctx.modules` for a content-file edit never
125
+ // links back to a CSS module. The dep set fills that gap.
126
+ configureServer(server) {
127
+ if (server.config.command !== 'serve')
128
+ return;
129
+ const appCssPath = path.resolve(projectRoot, getProjectAppRelativePath('app.css'));
130
+ if (!fs.existsSync(appCssPath))
131
+ return;
132
+ const normalizeFsPath = (p) => path.resolve(p).replace(/\\/g, '/');
133
+ const normalizedAppCssPath = normalizeFsPath(appCssPath);
134
+ const watchedDeps = new Set([normalizedAppCssPath]);
135
+ const refreshDeps = async () => {
136
+ try {
137
+ const rawCode = fs.readFileSync(appCssPath, 'utf-8');
138
+ // Same platform @import rewrite as the virtual:ns-app-css load hook —
139
+ // this raw read also bypasses the ns-css-platform transform.
140
+ const code = rewritePlatformCssImports(rawCode, path.dirname(appCssPath), opts.platform) ?? rawCode;
141
+ const result = await preprocessCSS(code, appCssPath, server.config);
142
+ server.watcher.add(appCssPath);
143
+ const next = new Set([normalizedAppCssPath]);
144
+ for (const dep of result?.deps ?? []) {
145
+ if (typeof dep === 'string' && dep) {
146
+ server.watcher.add(dep);
147
+ next.add(normalizeFsPath(dep));
148
+ }
149
+ }
150
+ // Atomic-ish replace: clear + repopulate the existing
151
+ // Set so any concurrent reader sees a consistent view
152
+ // when iterating with `.has()`.
153
+ watchedDeps.clear();
154
+ for (const f of next)
155
+ watchedDeps.add(f);
156
+ }
157
+ catch { }
158
+ };
159
+ setAppCssState(server, { path: normalizedAppCssPath, deps: watchedDeps });
160
+ refreshDeps();
161
+ // Re-scan when `app.css` itself or a Tailwind config file
162
+ // changes — Tailwind's content list and utility definitions
163
+ // can both shift, so the dep set has to follow. Debounced
164
+ // because watcher events for the same edit can fire in
165
+ // quick succession (chokidar's atomic save handling).
166
+ let pendingRefresh = null;
167
+ const scheduleRefresh = () => {
168
+ if (pendingRefresh)
169
+ clearTimeout(pendingRefresh);
170
+ pendingRefresh = setTimeout(() => {
171
+ pendingRefresh = null;
172
+ refreshDeps();
173
+ }, 50);
174
+ };
175
+ const isAppCssOrTailwindConfig = (file) => {
176
+ const normalized = normalizeFsPath(file);
177
+ if (normalized === normalizedAppCssPath)
178
+ return true;
179
+ return /\/tailwind\.config\.[mc]?[jt]s$/.test(normalized);
180
+ };
181
+ server.watcher.on('change', (file) => {
182
+ if (isAppCssOrTailwindConfig(file))
183
+ scheduleRefresh();
184
+ });
185
+ // `add`/`unlink` cover Tailwind's content set growing or
186
+ // shrinking — new template files, deleted partials, etc.
187
+ // Re-running `preprocessCSS` is the safest way to keep the
188
+ // glob expansion accurate without re-implementing the
189
+ // match.
190
+ server.watcher.on('add', scheduleRefresh);
191
+ server.watcher.on('unlink', scheduleRefresh);
192
+ },
61
193
  resolveId(id) {
62
194
  if (id === VIRTUAL_ID)
63
195
  return RESOLVED;
@@ -65,19 +197,117 @@ export function mainEntryPlugin(opts) {
65
197
  return APP_CSS_RESOLVED;
66
198
  if (id === XHR_POLYFILL_VIRTUAL_ID)
67
199
  return XHR_POLYFILL_RESOLVED;
200
+ if (id === DEFINES_SEED_VIRTUAL_ID)
201
+ return DEFINES_SEED_RESOLVED;
68
202
  return null;
69
203
  },
70
204
  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.
205
+ // Compute the dev server origin for HMR mode. Under HMR we emit
206
+ // `@nativescript/core*` imports as FULL HTTP URLs so iOS's ESM loader
207
+ // can fetch them directly during bundle.mjs module instantiation
208
+ // the import map isn't installed yet at that phase. For non-HMR
209
+ // builds, we keep bare specifiers so production bundlers inline core
210
+ // the normal way.
211
+ //
212
+ // Routes through `resolveDeviceReachableOrigin` so the URL baked
213
+ // into the bundle is something the DEVICE can reach: wildcard
214
+ // binds (`0.0.0.0`) and Android loopback get remapped to a real
215
+ // LAN IP (preferred) or the platform's reachable fallback
216
+ // (`10.0.2.2` for the Android emulator). Without this, Android
217
+ // crashes at boot trying to fetch `http://0.0.0.0:5173/ns/core/xhr`.
218
+ const getBootOrigin = () => {
219
+ if (!opts.hmrActive)
220
+ return null;
221
+ try {
222
+ const { origin } = resolveDeviceReachableOrigin({
223
+ host: resolvedConfig.server.host,
224
+ platform: opts.platform,
225
+ protocol: resolvedConfig.server.https || opts.useHttps ? 'https' : 'http',
226
+ port: Number(resolvedConfig.server.port || 5173),
227
+ });
228
+ return origin;
229
+ }
230
+ catch {
231
+ return null;
232
+ }
233
+ };
234
+ // Return a spec string for @nativescript/core or a subpath that is
235
+ // guaranteed to resolve at iOS module-instantiation time. Under HMR
236
+ // this is always a full HTTP URL into the /ns/core bridge (no
237
+ // import-map dependency). Under non-HMR it's the bare specifier for
238
+ // the bundler to handle.
239
+ //
240
+ // Under HMR, delegates to buildCoreUrl() — the ONE canonical URL
241
+ // generator. Every URL emitter in the build/runtime pipeline (this
242
+ // function, ns-core-external-urls, rewriteSpec, runtime import map)
243
+ // uses the same function so iOS's HTTP ESM cache sees byte-identical
244
+ // URLs.
245
+ const coreSpec = (subpath) => {
246
+ const origin = getBootOrigin();
247
+ if (origin) {
248
+ return buildCoreUrl(origin, subpath);
249
+ }
250
+ const sub = subpath ? String(subpath).replace(/^\/+/, '') : '';
251
+ return sub ? `@nativescript/core/${sub}` : '@nativescript/core';
252
+ };
253
+ // Virtual module that processes app.css through PostCSS/Tailwind and emits a
254
+ // JS module that BOTH applies the CSS as a side-effect AND exports the raw
255
+ // CSS string as default.
256
+ //
257
+ // Background: Vite's default `?inline` CSS handling collides with
258
+ // @analogjs/vite-plugin-angular's load hook in Vite 8 (it converts ?inline
259
+ // CSS to JS without setting moduleType:'js', so vite:css still tries to run
260
+ // PostCSS on the JS output). This virtual module sidesteps that.
261
+ //
262
+ // We still export the raw CSS string as default so the entry can seed
263
+ // `globalThis.__NS_HMR_APP_CSS__` for HMR's HTTP-core-realm replay path.
264
+ //
265
+ // We always pre-parse with rework `css` and either:
266
+ // - non-HMR: call `addTaggedAdditionalCSS(astJson, 'app.css')` directly
267
+ // so the bundled `style-scope` realm gets the styles before any view
268
+ // is created.
269
+ // - HMR: stash the AST on `globalThis.__NS_HMR_APP_CSS_AST__` so
270
+ // `installHttpCoreCssSupport` can apply it via the SAME AST path
271
+ // in the HTTP-core realm. Without this, the HTTP path would fall
272
+ // back to applying the raw text via `cssTreeParse` at runtime,
273
+ // which has produced subtle behavioral mismatches with the rework
274
+ // AST (e.g. `.text-sm { line-height: 20 }` rendering with extra
275
+ // line spacing under HMR but not under the no-HMR rolldown
276
+ // bundle, even though both bundles serialize the identical
277
+ // declaration). Pre-parsing once at build time and shipping the
278
+ // AST to BOTH paths keeps cold-boot rendering identical between
279
+ // the two modes. Live HMR edits still arrive as raw text via the
280
+ // dev-server WebSocket, so `installHttpCoreCssSupport` keeps the
281
+ // raw-text fallback for that case.
75
282
  if (id === APP_CSS_RESOLVED) {
76
283
  const appCssPath = path.resolve(projectRoot, getProjectAppRelativePath('app.css'));
77
- const code = fs.readFileSync(appCssPath, 'utf-8');
284
+ const rawCode = fs.readFileSync(appCssPath, 'utf-8');
285
+ // Rewrite platform-suffixed @imports (foo.css -> foo.ios.css) BEFORE
286
+ // preprocessCSS: this raw read bypasses the plugin transform chain, so
287
+ // the ns-css-platform plugin never sees this content, and Vite's
288
+ // internal postcss-import (which runs ahead of any user postcss
289
+ // plugins) can't resolve the generic specifier on its own.
290
+ const code = rewritePlatformCssImports(rawCode, path.dirname(appCssPath), opts.platform) ?? rawCode;
78
291
  const result = await preprocessCSS(code, appCssPath, resolvedConfig);
292
+ const ast = parseCssToAst(result.code, { silent: true });
293
+ // `css` emits `position` metadata on every AST node. NS doesn't
294
+ // use it, and stripping it ~halves the inlined JSON size — same
295
+ // thing webpack's css2json-loader does.
296
+ const astJson = JSON.stringify(ast, (key, value) => (key === 'position' ? undefined : value));
297
+ const lines = [];
298
+ if (opts.hmrActive) {
299
+ // Stash AST on globalThis BEFORE the entry seeds
300
+ // `__NS_HMR_APP_CSS__` from this module's default export, so
301
+ // `installHttpCoreCssSupport` can prefer the AST and match
302
+ // the no-HMR application path exactly.
303
+ lines.push(`try { (globalThis).__NS_HMR_APP_CSS_AST__ = ${astJson}; } catch {}`);
304
+ }
305
+ else {
306
+ lines.push(`import { addTaggedAdditionalCSS } from ${JSON.stringify(coreSpec('ui/styling/style-scope'))};`, `addTaggedAdditionalCSS(${astJson}, 'app.css');`);
307
+ }
308
+ lines.push(`export default ${JSON.stringify(result.code)};`);
79
309
  return {
80
- code: `export default ${JSON.stringify(result.code)};`,
310
+ code: lines.join('\n'),
81
311
  moduleType: 'js',
82
312
  };
83
313
  }
@@ -85,42 +315,174 @@ export function mainEntryPlugin(opts) {
85
315
  // guaranteeing XMLHttpRequest is on globalThis before zone.js or any other code accesses it.
86
316
  if (id === XHR_POLYFILL_RESOLVED) {
87
317
  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'),
318
+ 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'),
319
+ moduleType: 'js',
320
+ };
321
+ }
322
+ // Virtual module that seeds compile-time defines on globalThis.
323
+ // Imported FIRST in the entry so it evaluates as a leaf before
324
+ // any other module — including the `bundle-entry-points` chain
325
+ // that transitively reaches the user's app code. See the
326
+ // DEFINES_SEED_VIRTUAL_ID comment at the top of this file.
327
+ if (id === DEFINES_SEED_RESOLVED) {
328
+ // The FULL seed map: canonical platform defines (shared with Vite's
329
+ // `define` config and the dev server's per-module shims) PLUS every
330
+ // `__NS_*__` value raw-served client files consume (runtime flavor,
331
+ // app-root paths, overlay/kickstart knobs). Vite's define substitution
332
+ // never reaches those raw-served files, so anything they read must be
333
+ // planted on globalThis here — see getRuntimeSeedValues for the rule.
334
+ const seedLines = buildGlobalSeedStatements(getRuntimeSeedValues({ platform: opts.platform, isDevMode: opts.isDevMode, verbose: opts.verbose, flavor: effectiveFlavor, isCI: !!process.env.CI }));
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`;
@@ -144,7 +508,7 @@ export function mainEntryPlugin(opts) {
144
508
  // With experimentalDecorators:true, TypeScript emits __decorate patterns.
145
509
  // On watch-mode rebuilds the Angular compiler may not re-emit ɵfac for
146
510
  // cached files, so the JIT compiler must be available as a fallback.
147
- if (opts.isDevMode && flavor === 'angular') {
511
+ if (opts.isDevMode && effectiveFlavor === 'angular') {
148
512
  imports += "import { publishFacade as __nsPublishAngularCompilerFacade } from '@angular/compiler';\n";
149
513
  imports += '__nsPublishAngularCompilerFacade(globalThis);\n';
150
514
  if (opts.verbose) {
@@ -171,11 +535,22 @@ 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
  }
178
- if (flavor === 'typescript') {
542
+ // XML-driven flavors: register @nativescript/core/ui + element nicknames
543
+ // with the bundler module registry, import the bundler context, and apply
544
+ // View prototype guards. Provided as a virtual module by
545
+ // createUiRegistrationPlugin (wired in typescript.ts / javascript.ts) —
546
+ // imported HERE, right after bundle-entry-points, instead of being
547
+ // string-injected into this generated entry by a marker-matching
548
+ // transform (the marker drifted once and silently broke all XML builds
549
+ // with "Module 'Frame' not found").
550
+ if (effectiveFlavor === 'typescript' || effectiveFlavor === 'javascript') {
551
+ imports += "import 'virtual:ns-ui-registration';\n";
552
+ }
553
+ if (effectiveFlavor === 'typescript') {
179
554
  // Statically import bundler context synchronously before app code
180
555
  imports += "import 'virtual:ns-bundler-context';\n";
181
556
  if (opts.hmrActive) {
@@ -238,19 +613,30 @@ export function mainEntryPlugin(opts) {
238
613
  // Import Application statically if needed for CSS or Android activity defer
239
614
  if (hasAppCss || needsAndroidActivityDefer) {
240
615
  if (hasAppCss) {
241
- imports += `// Import and apply global CSS before app bootstrap\n`;
616
+ // The virtual module's body either:
617
+ // - non-HMR: calls `addTaggedAdditionalCSS(ast, 'app.css')`
618
+ // as an import-time side-effect, landing CSS in NS's
619
+ // selector tables before any view is created.
620
+ // - HMR: stashes the rework AST on
621
+ // `globalThis.__NS_HMR_APP_CSS_AST__` so
622
+ // `installHttpCoreCssSupport` can apply it via the SAME
623
+ // AST path in the HTTP-core realm. The default export
624
+ // is the raw CSS string, also seeded onto
625
+ // `globalThis.__NS_HMR_APP_CSS__` here as a
626
+ // raw-text fallback (used for live HMR edits via the
627
+ // dev-server WebSocket).
628
+ imports += `// Apply global CSS before app bootstrap (AST under non-HMR; AST stashed for HMR cold boot)\n`;
242
629
  imports += `import appCssContent from '${APP_CSS_VIRTUAL_ID}';\n`;
243
630
  if (opts.hmrActive) {
244
631
  imports += `try { globalThis.__NS_HMR_APP_CSS__ = appCssContent; } catch {}\n`;
245
632
  }
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
633
  if (opts.verbose) {
251
- imports += `console.info('[ns-entry] app.css applied');\n`;
634
+ imports += `console.info('[ns-entry] app.css applied as AST');\n`;
252
635
  }
253
636
  }
637
+ if (needsAndroidActivityDefer) {
638
+ imports += `import { Application } from ${JSON.stringify(coreSpec())};\n`;
639
+ }
254
640
  }
255
641
  // ---- Deferred Android activity import (non-HMR only) ----
256
642
  // Uses the statically imported Application to avoid mixing dynamic and static imports
@@ -278,15 +664,23 @@ export function mainEntryPlugin(opts) {
278
664
  if (opts.verbose) {
279
665
  imports += `console.info('[ns-entry] including deterministic dev session bootstrap', { platform: ${JSON.stringify(opts.platform)}, mainRel: ${JSON.stringify(mainEntryRelPosix)} });\n`;
280
666
  }
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';
667
+ // Same device-reachable origin as `getBootOrigin()` so the
668
+ // session-descriptor URL and every `/ns/core/*` URL baked
669
+ // into bundle.mjs come from one canonical source. Without
670
+ // this, Android's `bundle.mjs` would hit `0.0.0.0:5173` for
671
+ // both endpoints (server.host's wildcard bind) and fail at
672
+ // boot before any user code runs.
673
+ const { origin: bootOrigin } = resolveDeviceReachableOrigin({
674
+ host: resolvedConfig.server.host,
675
+ platform: opts.platform,
676
+ protocol: resolvedConfig.server.https || opts.useHttps ? 'https' : 'http',
677
+ port: Number(resolvedConfig.server.port || 5173),
678
+ });
679
+ const sessionUrl = bootOrigin + '/__ns_dev__/session';
286
680
  imports += "import { startBrowserRuntimeSession } from '@nativescript/vite/hmr/shared/runtime/session-bootstrap.js';\n";
287
681
  imports += `startBrowserRuntimeSession(${JSON.stringify(sessionUrl)}, __nsVerboseLog).catch((error) => {\n`;
288
682
  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`;
683
+ imports += ` console.error('[ns-entry] deterministic dev session bootstrap failed', error && error.stack ? error.stack : error);\n`;
290
684
  imports += `});\n`;
291
685
  if (opts.verbose) {
292
686
  imports += `console.info('[ns-entry] deterministic dev session bootstrap appended');\n`;
@@ -300,7 +694,7 @@ export function mainEntryPlugin(opts) {
300
694
  }
301
695
  if (opts.isDevMode) {
302
696
  // debug tools support
303
- imports += "import '@nativescript/core/inspector_modules';\n";
697
+ imports += `import ${JSON.stringify(coreSpec('inspector_modules'))};\n`;
304
698
  if (opts.verbose) {
305
699
  imports += "console.info('[ns-entry] inspector modules imported');\n";
306
700
  }