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

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 (465) 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 +390 -165
  5. package/configuration/angular.js.map +1 -1
  6. package/configuration/base.js +244 -53
  7. package/configuration/base.js.map +1 -1
  8. package/configuration/javascript.js +14 -93
  9. package/configuration/javascript.js.map +1 -1
  10. package/configuration/react.js +41 -73
  11. package/configuration/react.js.map +1 -1
  12. package/configuration/solid.js +51 -6
  13. package/configuration/solid.js.map +1 -1
  14. package/configuration/typescript.js +12 -93
  15. package/configuration/typescript.js.map +1 -1
  16. package/helpers/app-components.d.ts +2 -1
  17. package/helpers/app-components.js.map +1 -1
  18. package/helpers/app-css-state.d.ts +8 -0
  19. package/helpers/app-css-state.js +8 -0
  20. package/helpers/app-css-state.js.map +1 -0
  21. package/helpers/bundler-context.d.ts +11 -0
  22. package/helpers/bundler-context.js +71 -0
  23. package/helpers/bundler-context.js.map +1 -0
  24. package/helpers/cli-flags.d.ts +12 -0
  25. package/helpers/cli-flags.js +34 -0
  26. package/helpers/cli-flags.js.map +1 -1
  27. package/helpers/css-platform-plugin.d.ts +14 -0
  28. package/helpers/css-platform-plugin.js +43 -25
  29. package/helpers/css-platform-plugin.js.map +1 -1
  30. package/helpers/dev-host.d.ts +360 -0
  31. package/helpers/dev-host.js +694 -0
  32. package/helpers/dev-host.js.map +1 -0
  33. package/helpers/dynamic-import-plugin.js +9 -4
  34. package/helpers/dynamic-import-plugin.js.map +1 -1
  35. package/helpers/esbuild-platform-resolver.js +4 -1
  36. package/helpers/esbuild-platform-resolver.js.map +1 -1
  37. package/helpers/external-configs.d.ts +10 -12
  38. package/helpers/external-configs.js +58 -35
  39. package/helpers/external-configs.js.map +1 -1
  40. package/helpers/global-defines.d.ts +100 -13
  41. package/helpers/global-defines.js +165 -28
  42. package/helpers/global-defines.js.map +1 -1
  43. package/helpers/hmr-scope.d.ts +26 -0
  44. package/helpers/hmr-scope.js +67 -0
  45. package/helpers/hmr-scope.js.map +1 -0
  46. package/helpers/init.js +0 -18
  47. package/helpers/init.js.map +1 -1
  48. package/helpers/logging.js +29 -1
  49. package/helpers/logging.js.map +1 -1
  50. package/helpers/main-entry.d.ts +4 -1
  51. package/helpers/main-entry.js +368 -53
  52. package/helpers/main-entry.js.map +1 -1
  53. package/helpers/nativeclass-esbuild-plugin.d.ts +2 -1
  54. package/helpers/nativeclass-esbuild-plugin.js +6 -1
  55. package/helpers/nativeclass-esbuild-plugin.js.map +1 -1
  56. package/helpers/nativeclass-transform.d.ts +13 -0
  57. package/helpers/nativeclass-transform.js +37 -7
  58. package/helpers/nativeclass-transform.js.map +1 -1
  59. package/helpers/nativeclass-transformer-plugin.d.ts +9 -2
  60. package/helpers/nativeclass-transformer-plugin.js +163 -15
  61. package/helpers/nativeclass-transformer-plugin.js.map +1 -1
  62. package/helpers/nativescript-package-resolver.js +10 -62
  63. package/helpers/nativescript-package-resolver.js.map +1 -1
  64. package/helpers/normalize-id.d.ts +42 -0
  65. package/helpers/normalize-id.js +60 -0
  66. package/helpers/normalize-id.js.map +1 -0
  67. package/helpers/ns-core-url.d.ts +29 -7
  68. package/helpers/ns-core-url.js +69 -12
  69. package/helpers/ns-core-url.js.map +1 -1
  70. package/helpers/optimize-deps.d.ts +16 -0
  71. package/helpers/optimize-deps.js +17 -0
  72. package/helpers/optimize-deps.js.map +1 -0
  73. package/helpers/package-platform-aliases.js +34 -49
  74. package/helpers/package-platform-aliases.js.map +1 -1
  75. package/helpers/platform-types.d.ts +2 -0
  76. package/helpers/platform-types.js +2 -0
  77. package/helpers/platform-types.js.map +1 -0
  78. package/helpers/postcss-platform-config.d.ts +17 -1
  79. package/helpers/postcss-platform-config.js +20 -37
  80. package/helpers/postcss-platform-config.js.map +1 -1
  81. package/helpers/project.d.ts +35 -0
  82. package/helpers/project.js +120 -2
  83. package/helpers/project.js.map +1 -1
  84. package/helpers/resolve-main-field-platform.d.ts +20 -0
  85. package/helpers/resolve-main-field-platform.js +49 -0
  86. package/helpers/resolve-main-field-platform.js.map +1 -0
  87. package/helpers/resolver.js +17 -2
  88. package/helpers/resolver.js.map +1 -1
  89. package/helpers/theme-core-plugins.js +1 -1
  90. package/helpers/theme-core-plugins.js.map +1 -1
  91. package/helpers/ts-config-paths.d.ts +32 -0
  92. package/helpers/ts-config-paths.js +156 -27
  93. package/helpers/ts-config-paths.js.map +1 -1
  94. package/helpers/typescript-check.d.ts +2 -1
  95. package/helpers/typescript-check.js +2 -2
  96. package/helpers/typescript-check.js.map +1 -1
  97. package/helpers/ui-registration.d.ts +21 -0
  98. package/helpers/ui-registration.js +156 -0
  99. package/helpers/ui-registration.js.map +1 -0
  100. package/helpers/utils.d.ts +9 -0
  101. package/helpers/utils.js +22 -2
  102. package/helpers/utils.js.map +1 -1
  103. package/helpers/vite-package-version.d.ts +7 -0
  104. package/helpers/vite-package-version.js +44 -0
  105. package/helpers/vite-package-version.js.map +1 -0
  106. package/helpers/workers.d.ts +48 -19
  107. package/helpers/workers.js +662 -13
  108. package/helpers/workers.js.map +1 -1
  109. package/hmr/client/css-handler.d.ts +2 -1
  110. package/hmr/client/css-handler.js +50 -26
  111. package/hmr/client/css-handler.js.map +1 -1
  112. package/hmr/client/css-update-overlay.d.ts +18 -0
  113. package/hmr/client/css-update-overlay.js +27 -0
  114. package/hmr/client/css-update-overlay.js.map +1 -0
  115. package/hmr/client/framework-client-strategy.d.ts +79 -0
  116. package/hmr/client/framework-client-strategy.js +19 -0
  117. package/hmr/client/framework-client-strategy.js.map +1 -0
  118. package/hmr/client/hmr-pending-overlay.d.ts +0 -14
  119. package/hmr/client/hmr-pending-overlay.js +14 -4
  120. package/hmr/client/hmr-pending-overlay.js.map +1 -1
  121. package/hmr/client/hot-context.d.ts +67 -0
  122. package/hmr/client/hot-context.js +284 -0
  123. package/hmr/client/hot-context.js.map +1 -0
  124. package/hmr/client/index.js +922 -273
  125. package/hmr/client/index.js.map +1 -1
  126. package/hmr/client/utils.d.ts +2 -1
  127. package/hmr/client/utils.js +111 -99
  128. package/hmr/client/utils.js.map +1 -1
  129. package/hmr/entry-runtime.d.ts +2 -1
  130. package/hmr/entry-runtime.js +279 -71
  131. package/hmr/entry-runtime.js.map +1 -1
  132. package/hmr/frameworks/angular/build/angular-linker.d.ts +12 -0
  133. package/hmr/frameworks/angular/build/angular-linker.js +109 -0
  134. package/hmr/frameworks/angular/build/angular-linker.js.map +1 -0
  135. package/hmr/frameworks/angular/build/inject-component-hmr-registration.d.ts +112 -0
  136. package/hmr/frameworks/angular/build/inject-component-hmr-registration.js +291 -0
  137. package/hmr/frameworks/angular/build/inject-component-hmr-registration.js.map +1 -0
  138. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.d.ts +75 -0
  139. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js +221 -0
  140. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js.map +1 -0
  141. package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.js +1 -170
  142. package/hmr/frameworks/angular/build/inline-decorator-component-templates.js.map +1 -0
  143. package/hmr/frameworks/angular/build/js-lexer.d.ts +4 -0
  144. package/{helpers/angular/synthesize-decorator-ctor-parameters.js → hmr/frameworks/angular/build/js-lexer.js} +22 -96
  145. package/hmr/frameworks/angular/build/js-lexer.js.map +1 -0
  146. package/hmr/frameworks/angular/build/shared-linker.d.ts +39 -0
  147. package/hmr/frameworks/angular/build/shared-linker.js +128 -0
  148. package/hmr/frameworks/angular/build/shared-linker.js.map +1 -0
  149. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js +88 -0
  150. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js.map +1 -0
  151. package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.js +1 -174
  152. package/hmr/frameworks/angular/build/synthesize-injectable-factories.js.map +1 -0
  153. package/{helpers/angular → hmr/frameworks/angular/build}/util.d.ts +1 -0
  154. package/hmr/frameworks/angular/build/util.js +155 -0
  155. package/hmr/frameworks/angular/build/util.js.map +1 -0
  156. package/hmr/frameworks/angular/client/index.js +542 -175
  157. package/hmr/frameworks/angular/client/index.js.map +1 -1
  158. package/hmr/frameworks/angular/client/strategy.d.ts +9 -0
  159. package/hmr/frameworks/angular/client/strategy.js +19 -0
  160. package/hmr/frameworks/angular/client/strategy.js.map +1 -0
  161. package/hmr/frameworks/angular/server/angular-root-component.d.ts +79 -0
  162. package/hmr/frameworks/angular/server/angular-root-component.js +149 -0
  163. package/hmr/frameworks/angular/server/angular-root-component.js.map +1 -0
  164. package/hmr/frameworks/angular/server/linker.js +1 -4
  165. package/hmr/frameworks/angular/server/linker.js.map +1 -1
  166. package/hmr/frameworks/angular/server/strategy.js +458 -12
  167. package/hmr/frameworks/angular/server/strategy.js.map +1 -1
  168. package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.js +2 -2
  169. package/hmr/frameworks/angular/server/websocket-angular-entry.js.map +1 -0
  170. package/hmr/{server → frameworks/angular/server}/websocket-angular-hot-update.d.ts +14 -11
  171. package/hmr/{server → frameworks/angular/server}/websocket-angular-hot-update.js +108 -111
  172. package/hmr/frameworks/angular/server/websocket-angular-hot-update.js.map +1 -0
  173. package/hmr/frameworks/react/server/strategy.d.ts +2 -0
  174. package/hmr/frameworks/react/server/strategy.js +230 -0
  175. package/hmr/frameworks/react/server/strategy.js.map +1 -0
  176. package/hmr/frameworks/solid/build/solid-jsx-deps.d.ts +15 -0
  177. package/hmr/frameworks/solid/build/solid-jsx-deps.js +178 -0
  178. package/hmr/frameworks/solid/build/solid-jsx-deps.js.map +1 -0
  179. package/hmr/frameworks/solid/client/app-runtime.d.ts +68 -0
  180. package/hmr/frameworks/solid/client/app-runtime.js +246 -0
  181. package/hmr/frameworks/solid/client/app-runtime.js.map +1 -0
  182. package/hmr/frameworks/solid/server/strategy.js +291 -16
  183. package/hmr/frameworks/solid/server/strategy.js.map +1 -1
  184. package/hmr/frameworks/typescript/server/strategy.js +38 -14
  185. package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
  186. package/hmr/frameworks/vue/client/dep-propagation.d.ts +44 -0
  187. package/hmr/frameworks/vue/client/dep-propagation.js +148 -0
  188. package/hmr/frameworks/vue/client/dep-propagation.js.map +1 -0
  189. package/hmr/frameworks/vue/client/index.d.ts +9 -0
  190. package/hmr/frameworks/vue/client/index.js +251 -247
  191. package/hmr/frameworks/vue/client/index.js.map +1 -1
  192. package/hmr/frameworks/vue/client/strategy.d.ts +33 -0
  193. package/hmr/frameworks/vue/client/strategy.js +157 -0
  194. package/hmr/frameworks/vue/client/strategy.js.map +1 -0
  195. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.d.ts +49 -0
  196. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js +142 -0
  197. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js.map +1 -0
  198. package/hmr/frameworks/vue/server/compiler.d.ts +3 -1
  199. package/hmr/frameworks/vue/server/compiler.js +3 -1
  200. package/hmr/frameworks/vue/server/compiler.js.map +1 -1
  201. package/hmr/frameworks/vue/server/sfc-route-assemble.d.ts +7 -0
  202. package/hmr/frameworks/vue/server/sfc-route-assemble.js +823 -0
  203. package/hmr/frameworks/vue/server/sfc-route-assemble.js.map +1 -0
  204. package/hmr/frameworks/vue/server/sfc-route-meta.d.ts +7 -0
  205. package/hmr/frameworks/vue/server/sfc-route-meta.js +80 -0
  206. package/hmr/frameworks/vue/server/sfc-route-meta.js.map +1 -0
  207. package/hmr/frameworks/vue/server/sfc-route-serve.d.ts +8 -0
  208. package/hmr/frameworks/vue/server/sfc-route-serve.js +462 -0
  209. package/hmr/frameworks/vue/server/sfc-route-serve.js.map +1 -0
  210. package/hmr/frameworks/vue/server/sfc-route-shared.d.ts +45 -0
  211. package/hmr/frameworks/vue/server/sfc-route-shared.js +105 -0
  212. package/hmr/frameworks/vue/server/sfc-route-shared.js.map +1 -0
  213. package/hmr/frameworks/vue/server/strategy.d.ts +35 -0
  214. package/hmr/frameworks/vue/server/strategy.js +286 -7
  215. package/hmr/frameworks/vue/server/strategy.js.map +1 -1
  216. package/hmr/frameworks/vue/server/websocket-sfc.d.ts +15 -0
  217. package/hmr/frameworks/vue/server/websocket-sfc.js +20 -0
  218. package/hmr/frameworks/vue/server/websocket-sfc.js.map +1 -0
  219. package/hmr/helpers/ast-normalizer.d.ts +3 -1
  220. package/hmr/helpers/ast-normalizer.js +77 -10
  221. package/hmr/helpers/ast-normalizer.js.map +1 -1
  222. package/hmr/helpers/cjs-named-exports.d.ts +23 -0
  223. package/hmr/helpers/cjs-named-exports.js +152 -0
  224. package/hmr/helpers/cjs-named-exports.js.map +1 -0
  225. package/hmr/helpers/package-exports.d.ts +16 -0
  226. package/hmr/helpers/package-exports.js +396 -0
  227. package/hmr/helpers/package-exports.js.map +1 -0
  228. package/hmr/helpers/vendor-rewrite.d.ts +1 -1
  229. package/hmr/helpers/vendor-rewrite.js +5 -3
  230. package/hmr/helpers/vendor-rewrite.js.map +1 -1
  231. package/hmr/server/boot-archive-route.d.ts +40 -0
  232. package/hmr/server/boot-archive-route.js +154 -0
  233. package/hmr/server/boot-archive-route.js.map +1 -0
  234. package/hmr/server/boot-closure-route.d.ts +49 -0
  235. package/hmr/server/boot-closure-route.js +144 -0
  236. package/hmr/server/boot-closure-route.js.map +1 -0
  237. package/hmr/server/boot-recording.d.ts +58 -0
  238. package/hmr/server/boot-recording.js +228 -0
  239. package/hmr/server/boot-recording.js.map +1 -0
  240. package/hmr/server/constants.js +20 -5
  241. package/hmr/server/constants.js.map +1 -1
  242. package/hmr/server/core-bundle.d.ts +140 -0
  243. package/hmr/server/core-bundle.js +614 -0
  244. package/hmr/server/core-bundle.js.map +1 -0
  245. package/hmr/server/core-sanitize.d.ts +86 -7
  246. package/hmr/server/core-sanitize.js +170 -45
  247. package/hmr/server/core-sanitize.js.map +1 -1
  248. package/hmr/server/css-device-module.d.ts +28 -0
  249. package/hmr/server/css-device-module.js +44 -0
  250. package/hmr/server/css-device-module.js.map +1 -0
  251. package/hmr/server/deps-bundle.d.ts +218 -0
  252. package/hmr/server/deps-bundle.js +998 -0
  253. package/hmr/server/deps-bundle.js.map +1 -0
  254. package/hmr/server/device-transform-helpers.d.ts +24 -0
  255. package/hmr/server/device-transform-helpers.js +408 -0
  256. package/hmr/server/device-transform-helpers.js.map +1 -0
  257. package/hmr/server/framework-strategy.d.ts +113 -11
  258. package/hmr/server/hmr-module-graph.d.ts +37 -0
  259. package/hmr/server/hmr-module-graph.js +215 -0
  260. package/hmr/server/hmr-module-graph.js.map +1 -0
  261. package/hmr/server/import-map.d.ts +13 -4
  262. package/hmr/server/import-map.js +94 -47
  263. package/hmr/server/import-map.js.map +1 -1
  264. package/hmr/server/index.js +7 -16
  265. package/hmr/server/index.js.map +1 -1
  266. package/hmr/server/ns-core-cjs-shape.d.ts +2 -4
  267. package/hmr/server/ns-core-cjs-shape.js +4 -6
  268. package/hmr/server/ns-core-cjs-shape.js.map +1 -1
  269. package/hmr/server/ns-m-response-memo.d.ts +10 -0
  270. package/hmr/server/ns-m-response-memo.js +33 -0
  271. package/hmr/server/ns-m-response-memo.js.map +1 -0
  272. package/hmr/server/ns-rt-bridge.d.ts +51 -0
  273. package/hmr/server/ns-rt-bridge.js +131 -0
  274. package/hmr/server/ns-rt-bridge.js.map +1 -0
  275. package/hmr/server/ns-rt-route.d.ts +5 -0
  276. package/hmr/server/ns-rt-route.js +39 -0
  277. package/hmr/server/ns-rt-route.js.map +1 -0
  278. package/hmr/server/perf-instrumentation.d.ts +6 -10
  279. package/hmr/server/perf-instrumentation.js +5 -6
  280. package/hmr/server/perf-instrumentation.js.map +1 -1
  281. package/hmr/server/process-code-for-device.d.ts +30 -0
  282. package/hmr/server/process-code-for-device.js +791 -0
  283. package/hmr/server/process-code-for-device.js.map +1 -0
  284. package/hmr/server/require-guard.d.ts +1 -0
  285. package/hmr/server/require-guard.js +12 -0
  286. package/hmr/server/require-guard.js.map +1 -0
  287. package/hmr/server/rewrite-imports.d.ts +2 -0
  288. package/hmr/server/rewrite-imports.js +638 -0
  289. package/hmr/server/rewrite-imports.js.map +1 -0
  290. package/hmr/server/route-helpers.d.ts +7 -0
  291. package/hmr/server/route-helpers.js +13 -0
  292. package/hmr/server/route-helpers.js.map +1 -0
  293. package/hmr/server/server-origin.d.ts +2 -0
  294. package/hmr/server/server-origin.js +83 -0
  295. package/hmr/server/server-origin.js.map +1 -0
  296. package/hmr/server/shared-transform-request.js +1 -2
  297. package/hmr/server/shared-transform-request.js.map +1 -1
  298. package/hmr/server/transform-cache-invalidation.d.ts +37 -0
  299. package/hmr/server/transform-cache-invalidation.js +156 -0
  300. package/hmr/server/transform-cache-invalidation.js.map +1 -0
  301. package/hmr/server/vendor-bare-module-shims.d.ts +4 -0
  302. package/hmr/server/vendor-bare-module-shims.js +80 -0
  303. package/hmr/server/vendor-bare-module-shims.js.map +1 -0
  304. package/hmr/server/vite-plugin.d.ts +1 -0
  305. package/hmr/server/vite-plugin.js +180 -54
  306. package/hmr/server/vite-plugin.js.map +1 -1
  307. package/hmr/server/websocket-core-bridge.d.ts +51 -4
  308. package/hmr/server/websocket-core-bridge.js +62 -54
  309. package/hmr/server/websocket-core-bridge.js.map +1 -1
  310. package/hmr/server/websocket-css-hot-update.d.ts +33 -0
  311. package/hmr/server/websocket-css-hot-update.js +65 -0
  312. package/hmr/server/websocket-css-hot-update.js.map +1 -0
  313. package/hmr/server/websocket-device-transform.d.ts +3 -0
  314. package/hmr/server/websocket-device-transform.js +7 -0
  315. package/hmr/server/websocket-device-transform.js.map +1 -0
  316. package/hmr/server/websocket-hmr-pending.d.ts +3 -9
  317. package/hmr/server/websocket-hmr-pending.js +1 -1
  318. package/hmr/server/websocket-hmr-pending.js.map +1 -1
  319. package/hmr/server/websocket-hot-update.d.ts +77 -0
  320. package/hmr/server/websocket-hot-update.js +360 -0
  321. package/hmr/server/websocket-hot-update.js.map +1 -0
  322. package/hmr/server/websocket-import-map-route.d.ts +15 -0
  323. package/hmr/server/websocket-import-map-route.js +50 -0
  324. package/hmr/server/websocket-import-map-route.js.map +1 -0
  325. package/hmr/server/websocket-module-bindings.js +3 -3
  326. package/hmr/server/websocket-module-bindings.js.map +1 -1
  327. package/hmr/server/websocket-module-specifiers.d.ts +66 -2
  328. package/hmr/server/websocket-module-specifiers.js +191 -20
  329. package/hmr/server/websocket-module-specifiers.js.map +1 -1
  330. package/hmr/server/websocket-ns-core.d.ts +34 -0
  331. package/hmr/server/websocket-ns-core.js +414 -0
  332. package/hmr/server/websocket-ns-core.js.map +1 -0
  333. package/hmr/server/websocket-ns-entry.d.ts +21 -0
  334. package/hmr/server/websocket-ns-entry.js +164 -0
  335. package/hmr/server/websocket-ns-entry.js.map +1 -0
  336. package/hmr/server/websocket-ns-m-paths.d.ts +1 -3
  337. package/hmr/server/websocket-ns-m-paths.js +25 -82
  338. package/hmr/server/websocket-ns-m-paths.js.map +1 -1
  339. package/hmr/server/websocket-ns-m-request.d.ts +11 -1
  340. package/hmr/server/websocket-ns-m-request.js +17 -9
  341. package/hmr/server/websocket-ns-m-request.js.map +1 -1
  342. package/hmr/server/websocket-ns-m.d.ts +52 -0
  343. package/hmr/server/websocket-ns-m.js +835 -0
  344. package/hmr/server/websocket-ns-m.js.map +1 -0
  345. package/hmr/server/websocket-served-module-helpers.d.ts +50 -4
  346. package/hmr/server/websocket-served-module-helpers.js +384 -86
  347. package/hmr/server/websocket-served-module-helpers.js.map +1 -1
  348. package/hmr/server/websocket-txn.js +6 -9
  349. package/hmr/server/websocket-txn.js.map +1 -1
  350. package/hmr/server/websocket-vendor-unifier.d.ts +0 -1
  351. package/hmr/server/websocket-vendor-unifier.js +4 -9
  352. package/hmr/server/websocket-vendor-unifier.js.map +1 -1
  353. package/hmr/server/websocket.d.ts +7 -39
  354. package/hmr/server/websocket.js +643 -6716
  355. package/hmr/server/websocket.js.map +1 -1
  356. package/hmr/shared/ns-globals.d.ts +108 -0
  357. package/hmr/shared/ns-globals.js +28 -0
  358. package/hmr/shared/ns-globals.js.map +1 -0
  359. package/hmr/shared/protocol.d.ts +145 -0
  360. package/hmr/shared/protocol.js +28 -0
  361. package/hmr/shared/protocol.js.map +1 -0
  362. package/hmr/shared/runtime/boot-archive-format.d.ts +16 -0
  363. package/hmr/shared/runtime/boot-archive-format.js +31 -0
  364. package/hmr/shared/runtime/boot-archive-format.js.map +1 -0
  365. package/hmr/shared/runtime/boot-complete.d.ts +14 -0
  366. package/hmr/shared/runtime/boot-complete.js +32 -0
  367. package/hmr/shared/runtime/boot-complete.js.map +1 -0
  368. package/hmr/shared/runtime/boot-placeholder-ui.d.ts +69 -0
  369. package/hmr/shared/runtime/boot-placeholder-ui.js +101 -0
  370. package/hmr/shared/runtime/boot-placeholder-ui.js.map +1 -0
  371. package/hmr/shared/runtime/boot-progress.d.ts +44 -0
  372. package/hmr/shared/runtime/boot-progress.js +134 -0
  373. package/hmr/shared/runtime/boot-progress.js.map +1 -0
  374. package/hmr/shared/runtime/boot-timeline.d.ts +2 -1
  375. package/hmr/shared/runtime/boot-timeline.js +9 -22
  376. package/hmr/shared/runtime/boot-timeline.js.map +1 -1
  377. package/hmr/shared/runtime/browser-runtime-contract.d.ts +53 -22
  378. package/hmr/shared/runtime/browser-runtime-contract.js +6 -9
  379. package/hmr/shared/runtime/browser-runtime-contract.js.map +1 -1
  380. package/hmr/shared/runtime/dev-overlay-snapshots.d.ts +31 -0
  381. package/hmr/shared/runtime/dev-overlay-snapshots.js +324 -0
  382. package/hmr/shared/runtime/dev-overlay-snapshots.js.map +1 -0
  383. package/hmr/shared/runtime/dev-overlay.d.ts +76 -30
  384. package/hmr/shared/runtime/dev-overlay.js +767 -408
  385. package/hmr/shared/runtime/dev-overlay.js.map +1 -1
  386. package/hmr/shared/runtime/global-scope.d.ts +18 -0
  387. package/hmr/shared/runtime/global-scope.js +21 -0
  388. package/hmr/shared/runtime/global-scope.js.map +1 -0
  389. package/hmr/shared/runtime/hooks.js +2 -1
  390. package/hmr/shared/runtime/hooks.js.map +1 -1
  391. package/hmr/shared/runtime/http-only-boot.js +7 -6
  392. package/hmr/shared/runtime/http-only-boot.js.map +1 -1
  393. package/hmr/shared/runtime/module-provenance.js +4 -6
  394. package/hmr/shared/runtime/module-provenance.js.map +1 -1
  395. package/hmr/shared/runtime/root-placeholder-view.d.ts +19 -0
  396. package/hmr/shared/runtime/root-placeholder-view.js +311 -0
  397. package/hmr/shared/runtime/root-placeholder-view.js.map +1 -0
  398. package/hmr/shared/runtime/root-placeholder.js +398 -204
  399. package/hmr/shared/runtime/root-placeholder.js.map +1 -1
  400. package/hmr/shared/runtime/session-bootstrap.js +274 -55
  401. package/hmr/shared/runtime/session-bootstrap.js.map +1 -1
  402. package/hmr/shared/runtime/vendor-bootstrap.js +3 -10
  403. package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
  404. package/hmr/shared/vendor/manifest-collect.d.ts +4 -0
  405. package/hmr/shared/vendor/manifest-collect.js +549 -0
  406. package/hmr/shared/vendor/manifest-collect.js.map +1 -0
  407. package/hmr/shared/vendor/manifest-loader.d.ts +2 -1
  408. package/hmr/shared/vendor/manifest-loader.js +5 -3
  409. package/hmr/shared/vendor/manifest-loader.js.map +1 -1
  410. package/hmr/shared/vendor/manifest.d.ts +1 -7
  411. package/hmr/shared/vendor/manifest.js +136 -825
  412. package/hmr/shared/vendor/manifest.js.map +1 -1
  413. package/hmr/shared/vendor/registry.d.ts +2 -0
  414. package/hmr/shared/vendor/registry.js +14 -0
  415. package/hmr/shared/vendor/registry.js.map +1 -1
  416. package/hmr/shared/vendor/vendor-device-shim.d.ts +1 -0
  417. package/hmr/shared/vendor/vendor-device-shim.js +208 -0
  418. package/hmr/shared/vendor/vendor-device-shim.js.map +1 -0
  419. package/hmr/shared/vendor/vendor-esbuild-plugins.d.ts +76 -0
  420. package/hmr/shared/vendor/vendor-esbuild-plugins.js +401 -0
  421. package/hmr/shared/vendor/vendor-esbuild-plugins.js.map +1 -0
  422. package/hmr/vendor-bootstrap.d.ts +1 -3
  423. package/hmr/vendor-bootstrap.js +4 -6
  424. package/hmr/vendor-bootstrap.js.map +1 -1
  425. package/index.d.ts +1 -0
  426. package/index.js +5 -0
  427. package/index.js.map +1 -1
  428. package/package.json +65 -11
  429. package/runtime/core-aliases-early.js +25 -55
  430. package/runtime/core-aliases-early.js.map +1 -1
  431. package/shims/react-jsx-runtime.d.ts +4 -0
  432. package/shims/react-jsx-runtime.js +61 -0
  433. package/shims/react-jsx-runtime.js.map +1 -0
  434. package/helpers/angular/angular-linker.d.ts +0 -13
  435. package/helpers/angular/angular-linker.js +0 -194
  436. package/helpers/angular/angular-linker.js.map +0 -1
  437. package/helpers/angular/inline-decorator-component-templates.js.map +0 -1
  438. package/helpers/angular/shared-linker.d.ts +0 -11
  439. package/helpers/angular/shared-linker.js +0 -75
  440. package/helpers/angular/shared-linker.js.map +0 -1
  441. package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +0 -1
  442. package/helpers/angular/synthesize-injectable-factories.js.map +0 -1
  443. package/helpers/angular/util.js +0 -67
  444. package/helpers/angular/util.js.map +0 -1
  445. package/helpers/prelink-angular.d.ts +0 -2
  446. package/helpers/prelink-angular.js +0 -117
  447. package/helpers/prelink-angular.js.map +0 -1
  448. package/hmr/server/websocket-angular-entry.js.map +0 -1
  449. package/hmr/server/websocket-angular-hot-update.js.map +0 -1
  450. package/hmr/server/websocket-ns-m-finalize.d.ts +0 -22
  451. package/hmr/server/websocket-ns-m-finalize.js +0 -88
  452. package/hmr/server/websocket-ns-m-finalize.js.map +0 -1
  453. package/hmr/server/websocket-runtime-compat.d.ts +0 -19
  454. package/hmr/server/websocket-runtime-compat.js +0 -286
  455. package/hmr/server/websocket-runtime-compat.js.map +0 -1
  456. package/hmr/server/websocket-vue-sfc.d.ts +0 -27
  457. package/hmr/server/websocket-vue-sfc.js +0 -1114
  458. package/hmr/server/websocket-vue-sfc.js.map +0 -1
  459. package/transformers/NativeClass/index.d.ts +0 -2
  460. package/transformers/NativeClass/index.js +0 -222
  461. package/transformers/NativeClass/index.js.map +0 -1
  462. /package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.d.ts +0 -0
  463. /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-decorator-ctor-parameters.d.ts +0 -0
  464. /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.d.ts +0 -0
  465. /package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.d.ts +0 -0
@@ -2,11 +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
- import { getProjectAppPath, getProjectAppRelativePath, getProjectAppVirtualPath } from './utils.js';
7
+ import { getProjectAppPath, getProjectAppRelativePath, getProjectAppVirtualPath, resolveProjectGlobalCssPath } from './utils.js';
7
8
  import { getResolvedAppComponents } from './app-components.js';
8
9
  import { toStaticImportSpecifier } from './import-specifier.js';
9
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';
10
15
  // Switched to runtime modules to avoid fragile string injection and enable TS checks
11
16
  const projectRoot = getProjectRootPath();
12
17
  const appRootDir = getProjectAppPath();
@@ -46,26 +51,205 @@ const VIRTUAL_ID = 'virtual:entry-with-polyfills';
46
51
  const RESOLVED = '\0' + VIRTUAL_ID;
47
52
  const APP_CSS_VIRTUAL_ID = 'virtual:ns-app-css';
48
53
  const APP_CSS_RESOLVED = '\0' + APP_CSS_VIRTUAL_ID;
54
+ // Build-only applier for SFC `<style>` + JS/TS-imported `.css`/`.scss` that Vite
55
+ // extracts into a CSS asset. NativeScript has no DOM to `<link>` it, so the
56
+ // `--no-hmr` build would otherwise drop those styles (HMR applies them at
57
+ // runtime). `load` emits the apply with a sentinel; `generateBundle` rewrites it
58
+ // to the collected rework-CSS AST (the form `app.css` uses). Replaces the per-app
59
+ // `nsSfcStylesPlugin` workaround — apps no longer need their own.
60
+ const BUNDLE_CSS_VIRTUAL_ID = 'virtual:ns-bundle-css';
61
+ const BUNDLE_CSS_RESOLVED = '\0' + BUNDLE_CSS_VIRTUAL_ID;
62
+ const BUNDLE_CSS_AST_SENTINEL = '__NS_BUNDLE_CSS_AST__';
49
63
  // Virtual module that installs the XHR polyfill from @nativescript/core/xhr.
50
64
  // Rolldown tree-shakes the polyfill-xhr.ts side-effect import from @nativescript/core/globals,
51
65
  // so XMLHttpRequest never gets registered as a global. This dedicated module ensures the XHR
52
66
  // polyfill is installed during module evaluation (before zone.js patches run).
53
67
  const XHR_POLYFILL_VIRTUAL_ID = 'virtual:ns-xhr-polyfill';
54
68
  const XHR_POLYFILL_RESOLVED = '\0' + XHR_POLYFILL_VIRTUAL_ID;
69
+ // Virtual module that seeds compile-time defines (`__APPLE__`, `__IOS__`,
70
+ // `__DEV__`, etc.) on `globalThis` BEFORE any other module evaluates.
71
+ //
72
+ // Why this exists. The per-module shim that `processCodeForDevice` injects
73
+ // at the top of every served module reads these values from `globalThis`:
74
+ // const __APPLE__ = globalThis.__APPLE__ !== undefined
75
+ // ? globalThis.__APPLE__
76
+ // : (__IOS__ || __VISIONOS__);
77
+ // `const` evaluates ONCE at module instantiation. So every module needs
78
+ // `globalThis.__APPLE__` to already be set when it instantiates — otherwise
79
+ // it locks in `false` for the lifetime of the module.
80
+ //
81
+ // In ESM, all `import` statements hoist to the top of the module's
82
+ // evaluation phase: imports run in DFS post-order BEFORE the importing
83
+ // module's body. If we put the seed assignments inline in the entry's
84
+ // body (e.g. `globalThis.__APPLE__ = true`), they run AFTER every module
85
+ // transitively imported via `bundle-entry-points` (which reaches the
86
+ // user's `main.ts` → `app.module.ts` → services → util files). Those
87
+ // utility modules then snapshot `globalThis.__APPLE__ = undefined` and
88
+ // fall through to the `false` branch — landing iOS code in the
89
+ // `else { /* Android */ }` branch and crashing on `Utils.android.*`.
90
+ //
91
+ // The fix is to import this virtual module FIRST in the entry. As a leaf
92
+ // in the dependency graph it evaluates before every sibling import, so
93
+ // its body assignments happen before any user module instantiates and
94
+ // reads `globalThis.__*`. This is the architecturally-correct way to
95
+ // make values available to other modules across the import graph in ESM.
96
+ const DEFINES_SEED_VIRTUAL_ID = 'virtual:ns-defines-seed';
97
+ const DEFINES_SEED_RESOLVED = '\0' + DEFINES_SEED_VIRTUAL_ID;
55
98
  export function mainEntryPlugin(opts) {
56
99
  let resolvedConfig;
100
+ // Prefer the flavor the active config DECLARES (threaded from baseConfig)
101
+ // over deps-based detection: in workspaces whose app package.json doesn't
102
+ // list the framework package (hoisted to the root), detection falls through
103
+ // to 'typescript' — which previously emitted the ts-only
104
+ // `virtual:ns-ui-registration` import into an Angular entry with no
105
+ // resolver registered, and seeded the wrong `__NS_TARGET_FLAVOR__`.
106
+ const effectiveFlavor = opts.flavor || flavor;
57
107
  return {
58
108
  name: 'main-entry',
59
109
  configResolved(config) {
60
110
  resolvedConfig = config;
61
111
  },
112
+ // Fill the `virtual:ns-bundle-css` sentinel with the extracted CSS and drop
113
+ // the orphan asset (non-HMR builds only; HMR delivers this CSS at runtime).
114
+ generateBundle(_outputOptions, bundle) {
115
+ if (opts.hmrActive)
116
+ return;
117
+ try {
118
+ const cssAssets = Object.values(bundle).filter((f) => f && f.type === 'asset' && typeof f.fileName === 'string' && f.fileName.endsWith('.css'));
119
+ let cssText = '';
120
+ for (const a of cssAssets) {
121
+ const src = a.source;
122
+ cssText += (typeof src === 'string' ? src : new TextDecoder().decode(src)) + '\n';
123
+ }
124
+ // Rework AST, position-stripped (the form app.css uses; ~halves size).
125
+ const ast = parseCssToAst(cssText, { silent: true });
126
+ const astJson = JSON.stringify(ast, (key, value) => (key === 'position' ? undefined : value));
127
+ // Rewrite the sentinel in whichever chunk carries the applier.
128
+ const sentinelRe = new RegExp(`(['"])${BUNDLE_CSS_AST_SENTINEL}\\1`);
129
+ let replaced = false;
130
+ for (const file of Object.values(bundle)) {
131
+ if (file && file.type === 'chunk' && typeof file.code === 'string' && sentinelRe.test(file.code)) {
132
+ file.code = file.code.replace(sentinelRe, () => astJson);
133
+ replaced = true;
134
+ break;
135
+ }
136
+ }
137
+ // Drop the orphan asset only after its rules are applied above.
138
+ if (replaced) {
139
+ for (const a of cssAssets)
140
+ delete bundle[a.fileName];
141
+ }
142
+ if (opts.verbose) {
143
+ console.info(`[ns-entry] bundle CSS: ${cssAssets.length} asset(s), ${cssText.length} bytes, applied=${replaced}`);
144
+ }
145
+ }
146
+ catch (e) {
147
+ if (opts.verbose)
148
+ console.warn('[ns-entry] bundle CSS injection failed:', e?.message || e);
149
+ }
150
+ },
151
+ // Warm chokidar with `app.css`'s @import dependency tree at
152
+ // server startup. Without this, the FIRST save to a workspace
153
+ // `@import` dep (e.g. `<repo>/libs/.../index.css`) is silently
154
+ // dropped: nothing in the cold-boot path causes the dev server
155
+ // to transform `app.css`, so `vite:css` never registers
156
+ // `@import`-resolved deps with the watcher. Eagerly resolving
157
+ // them here breaks the chicken-and-egg.
158
+ //
159
+ // We ALSO stash the resolved dep set on the server itself so
160
+ // the HMR websocket handler can recognize when a non-CSS edit
161
+ // (e.g. a `.html` template or `.ts` file scanned by Tailwind's
162
+ // content config) should trigger a fresh `app.css` fetch. The
163
+ // `preprocessCSS` deps include every file PostCSS reported as
164
+ // a `dependency` message — for Tailwind 3 with content globs,
165
+ // Vite's `compileCSS` expands the `dir-dependency` glob into
166
+ // the individual file paths, so we get the full content set.
167
+ //
168
+ // `app.css` is NEVER a real Vite module in NS HMR (the virtual
169
+ // `:ns-app-css` module re-runs `preprocessCSS` in its load
170
+ // hook), so the standard moduleGraph `addWatchFile` →
171
+ // `_addedImports` → file-only-entry-importer chain doesn't
172
+ // populate, and `ctx.modules` for a content-file edit never
173
+ // links back to a CSS module. The dep set fills that gap.
174
+ configureServer(server) {
175
+ if (server.config.command !== 'serve')
176
+ return;
177
+ // Prefer `app.css`, fall back to `styles.css` (common in web projects).
178
+ const appCssPath = resolveProjectGlobalCssPath(projectRoot);
179
+ if (!appCssPath)
180
+ return;
181
+ const normalizeFsPath = (p) => path.resolve(p).replace(/\\/g, '/');
182
+ const normalizedAppCssPath = normalizeFsPath(appCssPath);
183
+ const watchedDeps = new Set([normalizedAppCssPath]);
184
+ const refreshDeps = async () => {
185
+ try {
186
+ const rawCode = fs.readFileSync(appCssPath, 'utf-8');
187
+ // Same platform @import rewrite as the virtual:ns-app-css load hook —
188
+ // this raw read also bypasses the ns-css-platform transform.
189
+ const code = rewritePlatformCssImports(rawCode, path.dirname(appCssPath), opts.platform) ?? rawCode;
190
+ const result = await preprocessCSS(code, appCssPath, server.config);
191
+ server.watcher.add(appCssPath);
192
+ const next = new Set([normalizedAppCssPath]);
193
+ for (const dep of result?.deps ?? []) {
194
+ if (typeof dep === 'string' && dep) {
195
+ server.watcher.add(dep);
196
+ next.add(normalizeFsPath(dep));
197
+ }
198
+ }
199
+ // Atomic-ish replace: clear + repopulate the existing
200
+ // Set so any concurrent reader sees a consistent view
201
+ // when iterating with `.has()`.
202
+ watchedDeps.clear();
203
+ for (const f of next)
204
+ watchedDeps.add(f);
205
+ }
206
+ catch { }
207
+ };
208
+ setAppCssState(server, { path: normalizedAppCssPath, deps: watchedDeps });
209
+ refreshDeps();
210
+ // Re-scan when `app.css` itself or a Tailwind config file
211
+ // changes — Tailwind's content list and utility definitions
212
+ // can both shift, so the dep set has to follow. Debounced
213
+ // because watcher events for the same edit can fire in
214
+ // quick succession (chokidar's atomic save handling).
215
+ let pendingRefresh = null;
216
+ const scheduleRefresh = () => {
217
+ if (pendingRefresh)
218
+ clearTimeout(pendingRefresh);
219
+ pendingRefresh = setTimeout(() => {
220
+ pendingRefresh = null;
221
+ refreshDeps();
222
+ }, 50);
223
+ };
224
+ const isAppCssOrTailwindConfig = (file) => {
225
+ const normalized = normalizeFsPath(file);
226
+ if (normalized === normalizedAppCssPath)
227
+ return true;
228
+ return /\/tailwind\.config\.[mc]?[jt]s$/.test(normalized);
229
+ };
230
+ server.watcher.on('change', (file) => {
231
+ if (isAppCssOrTailwindConfig(file))
232
+ scheduleRefresh();
233
+ });
234
+ // `add`/`unlink` cover Tailwind's content set growing or
235
+ // shrinking — new template files, deleted partials, etc.
236
+ // Re-running `preprocessCSS` is the safest way to keep the
237
+ // glob expansion accurate without re-implementing the
238
+ // match.
239
+ server.watcher.on('add', scheduleRefresh);
240
+ server.watcher.on('unlink', scheduleRefresh);
241
+ },
62
242
  resolveId(id) {
63
243
  if (id === VIRTUAL_ID)
64
244
  return RESOLVED;
65
245
  if (id === APP_CSS_VIRTUAL_ID)
66
246
  return APP_CSS_RESOLVED;
247
+ if (id === BUNDLE_CSS_VIRTUAL_ID)
248
+ return BUNDLE_CSS_RESOLVED;
67
249
  if (id === XHR_POLYFILL_VIRTUAL_ID)
68
250
  return XHR_POLYFILL_RESOLVED;
251
+ if (id === DEFINES_SEED_VIRTUAL_ID)
252
+ return DEFINES_SEED_RESOLVED;
69
253
  return null;
70
254
  },
71
255
  async load(id) {
@@ -75,15 +259,24 @@ export function mainEntryPlugin(opts) {
75
259
  // the import map isn't installed yet at that phase. For non-HMR
76
260
  // builds, we keep bare specifiers so production bundlers inline core
77
261
  // the normal way.
262
+ //
263
+ // Routes through `resolveDeviceReachableOrigin` so the URL baked
264
+ // into the bundle is something the DEVICE can reach: wildcard
265
+ // binds (`0.0.0.0`) and Android loopback get remapped to a real
266
+ // LAN IP (preferred) or the platform's reachable fallback
267
+ // (`10.0.2.2` for the Android emulator). Without this, Android
268
+ // crashes at boot trying to fetch `http://0.0.0.0:5173/ns/core/xhr`.
78
269
  const getBootOrigin = () => {
79
270
  if (!opts.hmrActive)
80
271
  return null;
81
272
  try {
82
- const configuredHost = typeof resolvedConfig.server.host === 'string' && resolvedConfig.server.host ? resolvedConfig.server.host : 'localhost';
83
- const bootHost = (process.env.NS_HMR_HOST || '') || configuredHost;
84
- const bootProtocol = resolvedConfig.server.https || opts.useHttps ? 'https' : 'http';
85
- const bootPort = Number(resolvedConfig.server.port || 5173);
86
- return `${bootProtocol}://${bootHost}:${bootPort}`;
273
+ const { origin } = resolveDeviceReachableOrigin({
274
+ host: resolvedConfig.server.host,
275
+ platform: opts.platform,
276
+ protocol: resolvedConfig.server.https || opts.useHttps ? 'https' : 'http',
277
+ port: Number(resolvedConfig.server.port || 5173),
278
+ });
279
+ return origin;
87
280
  }
88
281
  catch {
89
282
  return null;
@@ -96,10 +289,10 @@ export function mainEntryPlugin(opts) {
96
289
  // the bundler to handle.
97
290
  //
98
291
  // Under HMR, delegates to buildCoreUrl() — the ONE canonical URL
99
- // generator (see Invariant A, HMR_CORE_REALM_DETERMINISTIC_PLAN.md).
100
- // Every URL emitter in the build/runtime pipeline (this function,
101
- // ns-core-external-urls, rewriteSpec, runtime import map) uses the
102
- // same function so iOS's HTTP ESM cache sees byte-identical URLs.
292
+ // generator. Every URL emitter in the build/runtime pipeline (this
293
+ // function, ns-core-external-urls, rewriteSpec, runtime import map)
294
+ // uses the same function so iOS's HTTP ESM cache sees byte-identical
295
+ // URLs.
103
296
  const coreSpec = (subpath) => {
104
297
  const origin = getBootOrigin();
105
298
  if (origin) {
@@ -108,16 +301,82 @@ export function mainEntryPlugin(opts) {
108
301
  const sub = subpath ? String(subpath).replace(/^\/+/, '') : '';
109
302
  return sub ? `@nativescript/core/${sub}` : '@nativescript/core';
110
303
  };
111
- // Virtual module that processes app.css through PostCSS/Tailwind and returns as a JS string.
112
- // This avoids using ?inline which conflicts with @analogjs/vite-plugin-angular's CSS
113
- // interception in Vite 8 — the Angular plugin converts ?inline CSS to JS via its load hook
114
- // but doesn't set moduleType:'js', so vite:css still tries to run PostCSS on the JS output.
304
+ // Virtual module that processes app.css through PostCSS/Tailwind and emits a
305
+ // JS module that BOTH applies the CSS as a side-effect AND exports the raw
306
+ // CSS string as default.
307
+ //
308
+ // Background: Vite's default `?inline` CSS handling collides with
309
+ // @analogjs/vite-plugin-angular's load hook in Vite 8 (it converts ?inline
310
+ // CSS to JS without setting moduleType:'js', so vite:css still tries to run
311
+ // PostCSS on the JS output). This virtual module sidesteps that.
312
+ //
313
+ // We still export the raw CSS string as default so the entry can seed
314
+ // `globalThis.__NS_HMR_APP_CSS__` for HMR's HTTP-core-realm replay path.
315
+ //
316
+ // We always pre-parse with rework `css` and either:
317
+ // - non-HMR: call `addTaggedAdditionalCSS(astJson, 'app.css')` directly
318
+ // so the bundled `style-scope` realm gets the styles before any view
319
+ // is created.
320
+ // - HMR: stash the AST on `globalThis.__NS_HMR_APP_CSS_AST__` so
321
+ // `installHttpCoreCssSupport` can apply it via the SAME AST path
322
+ // in the HTTP-core realm. Without this, the HTTP path would fall
323
+ // back to applying the raw text via `cssTreeParse` at runtime,
324
+ // which has produced subtle behavioral mismatches with the rework
325
+ // AST (e.g. `.text-sm { line-height: 20 }` rendering with extra
326
+ // line spacing under HMR but not under the no-HMR rolldown
327
+ // bundle, even though both bundles serialize the identical
328
+ // declaration). Pre-parsing once at build time and shipping the
329
+ // AST to BOTH paths keeps cold-boot rendering identical between
330
+ // the two modes. Live HMR edits still arrive as raw text via the
331
+ // dev-server WebSocket, so `installHttpCoreCssSupport` keeps the
332
+ // raw-text fallback for that case.
115
333
  if (id === APP_CSS_RESOLVED) {
116
- const appCssPath = path.resolve(projectRoot, getProjectAppRelativePath('app.css'));
117
- const code = fs.readFileSync(appCssPath, 'utf-8');
334
+ // Same resolver as the entry generator (app.css → styles.css fallback)
335
+ // so both always pick the same file. Only reached when a global
336
+ // stylesheet exists, but guard defensively against a mid-session delete.
337
+ const appCssPath = resolveProjectGlobalCssPath(projectRoot);
338
+ if (!appCssPath) {
339
+ return { code: 'export default "";', moduleType: 'js' };
340
+ }
341
+ const rawCode = fs.readFileSync(appCssPath, 'utf-8');
342
+ // Rewrite platform-suffixed @imports (foo.css -> foo.ios.css) BEFORE
343
+ // preprocessCSS: this raw read bypasses the plugin transform chain, so
344
+ // the ns-css-platform plugin never sees this content, and Vite's
345
+ // internal postcss-import (which runs ahead of any user postcss
346
+ // plugins) can't resolve the generic specifier on its own.
347
+ const code = rewritePlatformCssImports(rawCode, path.dirname(appCssPath), opts.platform) ?? rawCode;
118
348
  const result = await preprocessCSS(code, appCssPath, resolvedConfig);
349
+ const ast = parseCssToAst(result.code, { silent: true });
350
+ // `css` emits `position` metadata on every AST node. NS doesn't
351
+ // use it, and stripping it ~halves the inlined JSON size — same
352
+ // thing webpack's css2json-loader does.
353
+ const astJson = JSON.stringify(ast, (key, value) => (key === 'position' ? undefined : value));
354
+ const lines = [];
355
+ if (opts.hmrActive) {
356
+ // Stash AST on globalThis BEFORE the entry seeds
357
+ // `__NS_HMR_APP_CSS__` from this module's default export, so
358
+ // `installHttpCoreCssSupport` can prefer the AST and match
359
+ // the no-HMR application path exactly.
360
+ lines.push(`try { (globalThis).__NS_HMR_APP_CSS_AST__ = ${astJson}; } catch {}`);
361
+ }
362
+ else {
363
+ lines.push(`import { addTaggedAdditionalCSS } from ${JSON.stringify(coreSpec('ui/styling/style-scope'))};`, `addTaggedAdditionalCSS(${astJson}, 'app.css');`);
364
+ }
365
+ lines.push(`export default ${JSON.stringify(result.code)};`);
119
366
  return {
120
- code: `export default ${JSON.stringify(result.code)};`,
367
+ code: lines.join('\n'),
368
+ moduleType: 'js',
369
+ };
370
+ }
371
+ // Emit the bundle-CSS apply with a sentinel that generateBundle fills in
372
+ // (the CSS isn't known until then). No-op under HMR (dev server applies
373
+ // it at runtime, and the entry skips this import in HMR mode).
374
+ if (id === BUNDLE_CSS_RESOLVED) {
375
+ if (opts.hmrActive) {
376
+ return { code: 'export default "";', moduleType: 'js' };
377
+ }
378
+ return {
379
+ code: [`import { addTaggedAdditionalCSS } from ${JSON.stringify(coreSpec('ui/styling/style-scope'))};`, `try { addTaggedAdditionalCSS(${JSON.stringify(BUNDLE_CSS_AST_SENTINEL)}, 'ns-bundle-css'); } catch (e) {}`, `export default "";`].join('\n'),
121
380
  moduleType: 'js',
122
381
  };
123
382
  }
@@ -129,10 +388,41 @@ export function mainEntryPlugin(opts) {
129
388
  moduleType: 'js',
130
389
  };
131
390
  }
391
+ // Virtual module that seeds compile-time defines on globalThis.
392
+ // Imported FIRST in the entry so it evaluates as a leaf before
393
+ // any other module — including the `bundle-entry-points` chain
394
+ // that transitively reaches the user's app code. See the
395
+ // DEFINES_SEED_VIRTUAL_ID comment at the top of this file.
396
+ if (id === DEFINES_SEED_RESOLVED) {
397
+ // The FULL seed map: canonical platform defines (shared with Vite's
398
+ // `define` config and the dev server's per-module shims) PLUS every
399
+ // `__NS_*__` value raw-served client files consume (runtime flavor,
400
+ // app-root paths, overlay/kickstart knobs). Vite's define substitution
401
+ // never reaches those raw-served files, so anything they read must be
402
+ // planted on globalThis here — see getRuntimeSeedValues for the rule.
403
+ const seedLines = buildGlobalSeedStatements(getRuntimeSeedValues({ platform: opts.platform, isDevMode: opts.isDevMode, verbose: opts.verbose, flavor: effectiveFlavor, isCI: !!process.env.CI }));
404
+ return {
405
+ code: seedLines.join('\n') + '\n',
406
+ moduleType: 'js',
407
+ };
408
+ }
132
409
  if (id !== RESOLVED)
133
410
  return null;
411
+ let imports = '';
412
+ // Under HMR: import the defines-seed virtual module FIRST so its
413
+ // body — which sets `globalThis.__APPLE__`, `__IOS__`, `__DEV__`,
414
+ // etc. — evaluates as a leaf in the dependency graph BEFORE any
415
+ // other module instantiates. Per-module shims injected by
416
+ // `processCodeForDevice` read these from globalThis and snapshot
417
+ // them at instantiation time, so they MUST be set first.
418
+ //
419
+ // Under non-HMR: Vite's `define` config handles substitution
420
+ // statically at build time — no runtime seeding needed.
421
+ if (opts.hmrActive) {
422
+ imports += `import '${DEFINES_SEED_VIRTUAL_ID}';\n`;
423
+ }
134
424
  // consistent verbose flag to easily reference below
135
- let imports = "const __nsVerboseLog = typeof __NS_ENV_VERBOSE__ !== 'undefined' && __NS_ENV_VERBOSE__;\n";
425
+ imports += "const __nsVerboseLog = typeof __NS_ENV_VERBOSE__ !== 'undefined' && __NS_ENV_VERBOSE__;\n";
136
426
  // Ensure any CommonJS-style tooling requires (e.g. from Babel or
137
427
  // other build-time libraries that may be accidentally bundled) do
138
428
  // not attempt to resolve Node built-ins like 'fs' or 'path' on
@@ -158,8 +448,7 @@ export function mainEntryPlugin(opts) {
158
448
  // which routes `@nativescript/core*` through the HTTP bridge
159
449
  // or, for already-HTTP-loaded modules, through the
160
450
  // `globalThis.__NS_CORE_MODULES__` registry populated by the
161
- // `/ns/core` bridge preamble (see Invariant C in
162
- // HMR_CORE_REALM_DETERMINISTIC_PLAN.md).
451
+ // `/ns/core` bridge preamble.
163
452
  imports += "try { if (typeof globalThis !== 'undefined') {\n";
164
453
  imports += " var __nsOrigRequire = typeof globalThis.require === 'function' ? globalThis.require : null;\n";
165
454
  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';
@@ -256,23 +545,13 @@ export function mainEntryPlugin(opts) {
256
545
  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`;
257
546
  }
258
547
  if (opts.hmrActive) {
259
- // Seed ALL compile-time defines on globalThis so that every execution
260
- // context — the primary bundle, HTTP ESM modules, and cross-realm
261
- // calls — can reliably access them. The per-module injection in
262
- // processCodeForDevice() reads from globalThis as the source of truth;
263
- // these seeds ensure the values are always available.
264
- imports += `globalThis.__DEV__ = ${opts.isDevMode ? 'true' : 'false'};\n`;
265
- imports += `globalThis.__ANDROID__ = ${opts.platform === 'android' ? 'true' : 'false'};\n`;
266
- imports += `globalThis.__IOS__ = ${opts.platform === 'ios' ? 'true' : 'false'};\n`;
267
- imports += `globalThis.__VISIONOS__ = ${opts.platform === 'visionos' ? 'true' : 'false'};\n`;
268
- imports += `globalThis.__APPLE__ = ${opts.platform === 'ios' || opts.platform === 'visionos' ? 'true' : 'false'};\n`;
269
- imports += `globalThis.__COMMONJS__ = false;\n`;
270
- imports += `globalThis.__NS_WEBPACK__ = false;\n`;
271
- imports += `globalThis.__NS_ENV_VERBOSE__ = ${opts.verbose ? 'true' : 'false'};\n`;
272
- imports += `globalThis.__UI_USE_XML_PARSER__ = true;\n`;
273
- imports += `globalThis.__UI_USE_EXTERNAL_RENDERER__ = false;\n`;
274
- imports += `globalThis.__CSS_PARSER__ = 'css-tree';\n`;
275
- imports += `globalThis.__TEST__ = false;\n`;
548
+ // NOTE: globalThis defines (`__APPLE__`, `__IOS__`, `__DEV__`,
549
+ // etc.) are seeded by the `virtual:ns-defines-seed` import at
550
+ // the very top of this entry — see the import on line ~192.
551
+ // They MUST run as a leaf module ahead of any other graph
552
+ // node, so we can't seed them inline here (ESM imports hoist
553
+ // past inline body code, so any module reachable through
554
+ // `bundle-entry-points` would otherwise see undefined).
276
555
  imports += "import { installModuleProvenanceRecorder } from '@nativescript/vite/hmr/shared/runtime/module-provenance.js';\n";
277
556
  imports += 'installModuleProvenanceRecorder(__nsVerboseLog);\n';
278
557
  }
@@ -298,7 +577,7 @@ export function mainEntryPlugin(opts) {
298
577
  // With experimentalDecorators:true, TypeScript emits __decorate patterns.
299
578
  // On watch-mode rebuilds the Angular compiler may not re-emit ɵfac for
300
579
  // cached files, so the JIT compiler must be available as a fallback.
301
- if (opts.isDevMode && flavor === 'angular') {
580
+ if (opts.isDevMode && effectiveFlavor === 'angular') {
302
581
  imports += "import { publishFacade as __nsPublishAngularCompilerFacade } from '@angular/compiler';\n";
303
582
  imports += '__nsPublishAngularCompilerFacade(globalThis);\n';
304
583
  if (opts.verbose) {
@@ -329,7 +608,18 @@ export function mainEntryPlugin(opts) {
329
608
  if (opts.verbose) {
330
609
  imports += `console.info('[ns-entry] bundle-entry-points loaded');\n`;
331
610
  }
332
- if (flavor === 'typescript') {
611
+ // XML-driven flavors: register @nativescript/core/ui + element nicknames
612
+ // with the bundler module registry, import the bundler context, and apply
613
+ // View prototype guards. Provided as a virtual module by
614
+ // createUiRegistrationPlugin (wired in typescript.ts / javascript.ts) —
615
+ // imported HERE, right after bundle-entry-points, instead of being
616
+ // string-injected into this generated entry by a marker-matching
617
+ // transform (the marker drifted once and silently broke all XML builds
618
+ // with "Module 'Frame' not found").
619
+ if (effectiveFlavor === 'typescript' || effectiveFlavor === 'javascript') {
620
+ imports += "import 'virtual:ns-ui-registration';\n";
621
+ }
622
+ if (effectiveFlavor === 'typescript') {
333
623
  // Statically import bundler context synchronously before app code
334
624
  imports += "import 'virtual:ns-bundler-context';\n";
335
625
  if (opts.hmrActive) {
@@ -387,24 +677,41 @@ export function mainEntryPlugin(opts) {
387
677
  }
388
678
  }
389
679
  // ---- Global CSS injection (always-needed if file exists) ----
390
- const appCssPath = path.resolve(projectRoot, getProjectAppRelativePath('app.css'));
391
- const hasAppCss = fs.existsSync(appCssPath);
680
+ // Prefer `app.css`, fall back to `styles.css` (common in web projects).
681
+ const appCssPath = resolveProjectGlobalCssPath(projectRoot);
682
+ const hasAppCss = !!appCssPath;
392
683
  // Import Application statically if needed for CSS or Android activity defer
393
684
  if (hasAppCss || needsAndroidActivityDefer) {
394
685
  if (hasAppCss) {
395
- imports += `// Import and apply global CSS before app bootstrap\n`;
686
+ // The virtual module's body either:
687
+ // - non-HMR: calls `addTaggedAdditionalCSS(ast, 'app.css')`
688
+ // as an import-time side-effect, landing CSS in NS's
689
+ // selector tables before any view is created.
690
+ // - HMR: stashes the rework AST on
691
+ // `globalThis.__NS_HMR_APP_CSS_AST__` so
692
+ // `installHttpCoreCssSupport` can apply it via the SAME
693
+ // AST path in the HTTP-core realm. The default export
694
+ // is the raw CSS string, also seeded onto
695
+ // `globalThis.__NS_HMR_APP_CSS__` here as a
696
+ // raw-text fallback (used for live HMR edits via the
697
+ // dev-server WebSocket).
698
+ imports += `// Apply global CSS before app bootstrap (AST under non-HMR; AST stashed for HMR cold boot)\n`;
396
699
  imports += `import appCssContent from '${APP_CSS_VIRTUAL_ID}';\n`;
397
700
  if (opts.hmrActive) {
398
701
  imports += `try { globalThis.__NS_HMR_APP_CSS__ = appCssContent; } catch {}\n`;
399
702
  }
400
- }
401
- imports += `import { Application } from ${JSON.stringify(coreSpec())};\n`;
402
- if (hasAppCss) {
403
- imports += `if (appCssContent) { try { Application.addCss(appCssContent); } catch (error) { console.error('Error applying CSS:', error); } }\n`;
404
703
  if (opts.verbose) {
405
- imports += `console.info('[ns-entry] app.css applied');\n`;
704
+ imports += `console.info('[ns-entry] app.css applied as AST');\n`;
406
705
  }
407
706
  }
707
+ if (needsAndroidActivityDefer) {
708
+ imports += `import { Application } from ${JSON.stringify(coreSpec())};\n`;
709
+ }
710
+ }
711
+ // SFC/imported CSS (non-HMR build). After app.css so component rules win
712
+ // specificity ties. generateBundle fills it in; HMR applies at runtime.
713
+ if (!opts.hmrActive) {
714
+ imports += `import '${BUNDLE_CSS_VIRTUAL_ID}';\n`;
408
715
  }
409
716
  // ---- Deferred Android activity import (non-HMR only) ----
410
717
  // Uses the statically imported Application to avoid mixing dynamic and static imports
@@ -432,15 +739,23 @@ export function mainEntryPlugin(opts) {
432
739
  if (opts.verbose) {
433
740
  imports += `console.info('[ns-entry] including deterministic dev session bootstrap', { platform: ${JSON.stringify(opts.platform)}, mainRel: ${JSON.stringify(mainEntryRelPosix)} });\n`;
434
741
  }
435
- const configuredHost = typeof resolvedConfig.server.host === 'string' && resolvedConfig.server.host ? resolvedConfig.server.host : 'localhost';
436
- const bootHost = (process.env.NS_HMR_HOST || '') || configuredHost;
437
- const bootProtocol = resolvedConfig.server.https || opts.useHttps ? 'https' : 'http';
438
- const bootPort = Number(resolvedConfig.server.port || 5173);
439
- const sessionUrl = bootProtocol + '://' + bootHost + ':' + String(bootPort) + '/__ns_dev__/session';
742
+ // Same device-reachable origin as `getBootOrigin()` so the
743
+ // session-descriptor URL and every `/ns/core/*` URL baked
744
+ // into bundle.mjs come from one canonical source. Without
745
+ // this, Android's `bundle.mjs` would hit `0.0.0.0:5173` for
746
+ // both endpoints (server.host's wildcard bind) and fail at
747
+ // boot before any user code runs.
748
+ const { origin: bootOrigin } = resolveDeviceReachableOrigin({
749
+ host: resolvedConfig.server.host,
750
+ platform: opts.platform,
751
+ protocol: resolvedConfig.server.https || opts.useHttps ? 'https' : 'http',
752
+ port: Number(resolvedConfig.server.port || 5173),
753
+ });
754
+ const sessionUrl = bootOrigin + '/__ns_dev__/session';
440
755
  imports += "import { startBrowserRuntimeSession } from '@nativescript/vite/hmr/shared/runtime/session-bootstrap.js';\n";
441
756
  imports += `startBrowserRuntimeSession(${JSON.stringify(sessionUrl)}, __nsVerboseLog).catch((error) => {\n`;
442
757
  imports += ` try { globalThis.__NS_ENTRY_ERROR__ = { phase: 'deterministic-dev-session', message: String(error && (error.message || error)), stack: error && error.stack ? String(error.stack) : '' }; } catch {}\n`;
443
- imports += ` try { console.error('[ns-entry] deterministic dev session bootstrap failed', error && error.stack ? error.stack : error); } catch {}\n`;
758
+ imports += ` console.error('[ns-entry] deterministic dev session bootstrap failed', error && error.stack ? error.stack : error);\n`;
444
759
  imports += `});\n`;
445
760
  if (opts.verbose) {
446
761
  imports += `console.info('[ns-entry] deterministic dev session bootstrap appended');\n`;