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

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 (463) 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 +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 +4 -2
  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 +149 -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.map +1 -1
  55. package/helpers/nativeclass-transform.js +5 -6
  56. package/helpers/nativeclass-transform.js.map +1 -1
  57. package/helpers/nativeclass-transformer-plugin.d.ts +9 -2
  58. package/helpers/nativeclass-transformer-plugin.js +157 -14
  59. package/helpers/nativeclass-transformer-plugin.js.map +1 -1
  60. package/helpers/nativescript-package-resolver.js +10 -62
  61. package/helpers/nativescript-package-resolver.js.map +1 -1
  62. package/helpers/normalize-id.d.ts +42 -0
  63. package/helpers/normalize-id.js +60 -0
  64. package/helpers/normalize-id.js.map +1 -0
  65. package/helpers/ns-core-url.d.ts +29 -7
  66. package/helpers/ns-core-url.js +69 -12
  67. package/helpers/ns-core-url.js.map +1 -1
  68. package/helpers/optimize-deps.d.ts +16 -0
  69. package/helpers/optimize-deps.js +17 -0
  70. package/helpers/optimize-deps.js.map +1 -0
  71. package/helpers/package-platform-aliases.js +34 -49
  72. package/helpers/package-platform-aliases.js.map +1 -1
  73. package/helpers/platform-types.d.ts +2 -0
  74. package/helpers/platform-types.js +2 -0
  75. package/helpers/platform-types.js.map +1 -0
  76. package/helpers/postcss-platform-config.d.ts +17 -1
  77. package/helpers/postcss-platform-config.js +20 -37
  78. package/helpers/postcss-platform-config.js.map +1 -1
  79. package/helpers/project.d.ts +35 -0
  80. package/helpers/project.js +120 -2
  81. package/helpers/project.js.map +1 -1
  82. package/helpers/resolve-main-field-platform.d.ts +20 -0
  83. package/helpers/resolve-main-field-platform.js +49 -0
  84. package/helpers/resolve-main-field-platform.js.map +1 -0
  85. package/helpers/resolver.js +17 -2
  86. package/helpers/resolver.js.map +1 -1
  87. package/helpers/theme-core-plugins.js +1 -1
  88. package/helpers/theme-core-plugins.js.map +1 -1
  89. package/helpers/ts-config-paths.d.ts +32 -0
  90. package/helpers/ts-config-paths.js +156 -27
  91. package/helpers/ts-config-paths.js.map +1 -1
  92. package/helpers/typescript-check.d.ts +2 -1
  93. package/helpers/typescript-check.js +2 -2
  94. package/helpers/typescript-check.js.map +1 -1
  95. package/helpers/ui-registration.d.ts +21 -0
  96. package/helpers/ui-registration.js +156 -0
  97. package/helpers/ui-registration.js.map +1 -0
  98. package/helpers/utils.d.ts +9 -0
  99. package/helpers/utils.js +22 -2
  100. package/helpers/utils.js.map +1 -1
  101. package/helpers/vite-package-version.d.ts +7 -0
  102. package/helpers/vite-package-version.js +44 -0
  103. package/helpers/vite-package-version.js.map +1 -0
  104. package/helpers/workers.d.ts +20 -19
  105. package/helpers/workers.js +624 -4
  106. package/helpers/workers.js.map +1 -1
  107. package/hmr/client/css-handler.d.ts +2 -1
  108. package/hmr/client/css-handler.js +50 -26
  109. package/hmr/client/css-handler.js.map +1 -1
  110. package/hmr/client/css-update-overlay.d.ts +18 -0
  111. package/hmr/client/css-update-overlay.js +27 -0
  112. package/hmr/client/css-update-overlay.js.map +1 -0
  113. package/hmr/client/framework-client-strategy.d.ts +79 -0
  114. package/hmr/client/framework-client-strategy.js +19 -0
  115. package/hmr/client/framework-client-strategy.js.map +1 -0
  116. package/hmr/client/hmr-pending-overlay.d.ts +0 -14
  117. package/hmr/client/hmr-pending-overlay.js +14 -4
  118. package/hmr/client/hmr-pending-overlay.js.map +1 -1
  119. package/hmr/client/hot-context.d.ts +67 -0
  120. package/hmr/client/hot-context.js +284 -0
  121. package/hmr/client/hot-context.js.map +1 -0
  122. package/hmr/client/index.js +922 -273
  123. package/hmr/client/index.js.map +1 -1
  124. package/hmr/client/utils.d.ts +2 -1
  125. package/hmr/client/utils.js +111 -99
  126. package/hmr/client/utils.js.map +1 -1
  127. package/hmr/entry-runtime.d.ts +2 -1
  128. package/hmr/entry-runtime.js +271 -69
  129. package/hmr/entry-runtime.js.map +1 -1
  130. package/hmr/frameworks/angular/build/angular-linker.d.ts +12 -0
  131. package/hmr/frameworks/angular/build/angular-linker.js +109 -0
  132. package/hmr/frameworks/angular/build/angular-linker.js.map +1 -0
  133. package/hmr/frameworks/angular/build/inject-component-hmr-registration.d.ts +112 -0
  134. package/hmr/frameworks/angular/build/inject-component-hmr-registration.js +291 -0
  135. package/hmr/frameworks/angular/build/inject-component-hmr-registration.js.map +1 -0
  136. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.d.ts +75 -0
  137. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js +221 -0
  138. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js.map +1 -0
  139. package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.js +1 -170
  140. package/hmr/frameworks/angular/build/inline-decorator-component-templates.js.map +1 -0
  141. package/hmr/frameworks/angular/build/js-lexer.d.ts +4 -0
  142. package/{helpers/angular/synthesize-decorator-ctor-parameters.js → hmr/frameworks/angular/build/js-lexer.js} +22 -96
  143. package/hmr/frameworks/angular/build/js-lexer.js.map +1 -0
  144. package/hmr/frameworks/angular/build/shared-linker.d.ts +39 -0
  145. package/hmr/frameworks/angular/build/shared-linker.js +128 -0
  146. package/hmr/frameworks/angular/build/shared-linker.js.map +1 -0
  147. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js +88 -0
  148. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js.map +1 -0
  149. package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.js +1 -174
  150. package/hmr/frameworks/angular/build/synthesize-injectable-factories.js.map +1 -0
  151. package/{helpers/angular → hmr/frameworks/angular/build}/util.d.ts +1 -0
  152. package/hmr/frameworks/angular/build/util.js +155 -0
  153. package/hmr/frameworks/angular/build/util.js.map +1 -0
  154. package/hmr/frameworks/angular/client/index.js +542 -175
  155. package/hmr/frameworks/angular/client/index.js.map +1 -1
  156. package/hmr/frameworks/angular/client/strategy.d.ts +9 -0
  157. package/hmr/frameworks/angular/client/strategy.js +19 -0
  158. package/hmr/frameworks/angular/client/strategy.js.map +1 -0
  159. package/hmr/frameworks/angular/server/angular-root-component.d.ts +79 -0
  160. package/hmr/frameworks/angular/server/angular-root-component.js +149 -0
  161. package/hmr/frameworks/angular/server/angular-root-component.js.map +1 -0
  162. package/hmr/frameworks/angular/server/linker.js +1 -4
  163. package/hmr/frameworks/angular/server/linker.js.map +1 -1
  164. package/hmr/frameworks/angular/server/strategy.js +458 -12
  165. package/hmr/frameworks/angular/server/strategy.js.map +1 -1
  166. package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.js +2 -2
  167. package/hmr/frameworks/angular/server/websocket-angular-entry.js.map +1 -0
  168. package/hmr/{server → frameworks/angular/server}/websocket-angular-hot-update.d.ts +14 -11
  169. package/hmr/{server → frameworks/angular/server}/websocket-angular-hot-update.js +108 -111
  170. package/hmr/frameworks/angular/server/websocket-angular-hot-update.js.map +1 -0
  171. package/hmr/frameworks/react/server/strategy.d.ts +2 -0
  172. package/hmr/frameworks/react/server/strategy.js +230 -0
  173. package/hmr/frameworks/react/server/strategy.js.map +1 -0
  174. package/hmr/frameworks/solid/build/solid-jsx-deps.d.ts +15 -0
  175. package/hmr/frameworks/solid/build/solid-jsx-deps.js +178 -0
  176. package/hmr/frameworks/solid/build/solid-jsx-deps.js.map +1 -0
  177. package/hmr/frameworks/solid/client/app-runtime.d.ts +68 -0
  178. package/hmr/frameworks/solid/client/app-runtime.js +246 -0
  179. package/hmr/frameworks/solid/client/app-runtime.js.map +1 -0
  180. package/hmr/frameworks/solid/server/strategy.js +291 -16
  181. package/hmr/frameworks/solid/server/strategy.js.map +1 -1
  182. package/hmr/frameworks/typescript/server/strategy.js +38 -14
  183. package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
  184. package/hmr/frameworks/vue/client/dep-propagation.d.ts +44 -0
  185. package/hmr/frameworks/vue/client/dep-propagation.js +148 -0
  186. package/hmr/frameworks/vue/client/dep-propagation.js.map +1 -0
  187. package/hmr/frameworks/vue/client/index.d.ts +9 -0
  188. package/hmr/frameworks/vue/client/index.js +251 -247
  189. package/hmr/frameworks/vue/client/index.js.map +1 -1
  190. package/hmr/frameworks/vue/client/strategy.d.ts +33 -0
  191. package/hmr/frameworks/vue/client/strategy.js +157 -0
  192. package/hmr/frameworks/vue/client/strategy.js.map +1 -0
  193. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.d.ts +49 -0
  194. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js +142 -0
  195. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js.map +1 -0
  196. package/hmr/frameworks/vue/server/compiler.d.ts +3 -1
  197. package/hmr/frameworks/vue/server/compiler.js +3 -1
  198. package/hmr/frameworks/vue/server/compiler.js.map +1 -1
  199. package/hmr/frameworks/vue/server/sfc-route-assemble.d.ts +7 -0
  200. package/hmr/frameworks/vue/server/sfc-route-assemble.js +823 -0
  201. package/hmr/frameworks/vue/server/sfc-route-assemble.js.map +1 -0
  202. package/hmr/frameworks/vue/server/sfc-route-meta.d.ts +7 -0
  203. package/hmr/frameworks/vue/server/sfc-route-meta.js +80 -0
  204. package/hmr/frameworks/vue/server/sfc-route-meta.js.map +1 -0
  205. package/hmr/frameworks/vue/server/sfc-route-serve.d.ts +8 -0
  206. package/hmr/frameworks/vue/server/sfc-route-serve.js +462 -0
  207. package/hmr/frameworks/vue/server/sfc-route-serve.js.map +1 -0
  208. package/hmr/frameworks/vue/server/sfc-route-shared.d.ts +45 -0
  209. package/hmr/frameworks/vue/server/sfc-route-shared.js +105 -0
  210. package/hmr/frameworks/vue/server/sfc-route-shared.js.map +1 -0
  211. package/hmr/frameworks/vue/server/strategy.d.ts +35 -0
  212. package/hmr/frameworks/vue/server/strategy.js +286 -7
  213. package/hmr/frameworks/vue/server/strategy.js.map +1 -1
  214. package/hmr/frameworks/vue/server/websocket-sfc.d.ts +15 -0
  215. package/hmr/frameworks/vue/server/websocket-sfc.js +20 -0
  216. package/hmr/frameworks/vue/server/websocket-sfc.js.map +1 -0
  217. package/hmr/helpers/ast-normalizer.d.ts +3 -1
  218. package/hmr/helpers/ast-normalizer.js +77 -10
  219. package/hmr/helpers/ast-normalizer.js.map +1 -1
  220. package/hmr/helpers/cjs-named-exports.d.ts +23 -0
  221. package/hmr/helpers/cjs-named-exports.js +152 -0
  222. package/hmr/helpers/cjs-named-exports.js.map +1 -0
  223. package/hmr/helpers/package-exports.d.ts +16 -0
  224. package/hmr/helpers/package-exports.js +396 -0
  225. package/hmr/helpers/package-exports.js.map +1 -0
  226. package/hmr/helpers/vendor-rewrite.d.ts +1 -1
  227. package/hmr/helpers/vendor-rewrite.js +5 -3
  228. package/hmr/helpers/vendor-rewrite.js.map +1 -1
  229. package/hmr/server/boot-archive-route.d.ts +40 -0
  230. package/hmr/server/boot-archive-route.js +154 -0
  231. package/hmr/server/boot-archive-route.js.map +1 -0
  232. package/hmr/server/boot-closure-route.d.ts +49 -0
  233. package/hmr/server/boot-closure-route.js +144 -0
  234. package/hmr/server/boot-closure-route.js.map +1 -0
  235. package/hmr/server/boot-recording.d.ts +58 -0
  236. package/hmr/server/boot-recording.js +228 -0
  237. package/hmr/server/boot-recording.js.map +1 -0
  238. package/hmr/server/constants.js +20 -5
  239. package/hmr/server/constants.js.map +1 -1
  240. package/hmr/server/core-bundle.d.ts +140 -0
  241. package/hmr/server/core-bundle.js +614 -0
  242. package/hmr/server/core-bundle.js.map +1 -0
  243. package/hmr/server/core-sanitize.d.ts +86 -7
  244. package/hmr/server/core-sanitize.js +170 -45
  245. package/hmr/server/core-sanitize.js.map +1 -1
  246. package/hmr/server/css-device-module.d.ts +28 -0
  247. package/hmr/server/css-device-module.js +44 -0
  248. package/hmr/server/css-device-module.js.map +1 -0
  249. package/hmr/server/deps-bundle.d.ts +218 -0
  250. package/hmr/server/deps-bundle.js +984 -0
  251. package/hmr/server/deps-bundle.js.map +1 -0
  252. package/hmr/server/device-transform-helpers.d.ts +24 -0
  253. package/hmr/server/device-transform-helpers.js +408 -0
  254. package/hmr/server/device-transform-helpers.js.map +1 -0
  255. package/hmr/server/framework-strategy.d.ts +113 -11
  256. package/hmr/server/hmr-module-graph.d.ts +37 -0
  257. package/hmr/server/hmr-module-graph.js +215 -0
  258. package/hmr/server/hmr-module-graph.js.map +1 -0
  259. package/hmr/server/import-map.d.ts +13 -4
  260. package/hmr/server/import-map.js +94 -47
  261. package/hmr/server/import-map.js.map +1 -1
  262. package/hmr/server/index.js +7 -16
  263. package/hmr/server/index.js.map +1 -1
  264. package/hmr/server/ns-core-cjs-shape.d.ts +2 -4
  265. package/hmr/server/ns-core-cjs-shape.js +4 -6
  266. package/hmr/server/ns-core-cjs-shape.js.map +1 -1
  267. package/hmr/server/ns-m-response-memo.d.ts +10 -0
  268. package/hmr/server/ns-m-response-memo.js +33 -0
  269. package/hmr/server/ns-m-response-memo.js.map +1 -0
  270. package/hmr/server/ns-rt-bridge.d.ts +51 -0
  271. package/hmr/server/ns-rt-bridge.js +131 -0
  272. package/hmr/server/ns-rt-bridge.js.map +1 -0
  273. package/hmr/server/ns-rt-route.d.ts +5 -0
  274. package/hmr/server/ns-rt-route.js +39 -0
  275. package/hmr/server/ns-rt-route.js.map +1 -0
  276. package/hmr/server/perf-instrumentation.d.ts +6 -10
  277. package/hmr/server/perf-instrumentation.js +5 -6
  278. package/hmr/server/perf-instrumentation.js.map +1 -1
  279. package/hmr/server/process-code-for-device.d.ts +30 -0
  280. package/hmr/server/process-code-for-device.js +791 -0
  281. package/hmr/server/process-code-for-device.js.map +1 -0
  282. package/hmr/server/require-guard.d.ts +1 -0
  283. package/hmr/server/require-guard.js +12 -0
  284. package/hmr/server/require-guard.js.map +1 -0
  285. package/hmr/server/rewrite-imports.d.ts +2 -0
  286. package/hmr/server/rewrite-imports.js +630 -0
  287. package/hmr/server/rewrite-imports.js.map +1 -0
  288. package/hmr/server/route-helpers.d.ts +7 -0
  289. package/hmr/server/route-helpers.js +13 -0
  290. package/hmr/server/route-helpers.js.map +1 -0
  291. package/hmr/server/server-origin.d.ts +2 -0
  292. package/hmr/server/server-origin.js +83 -0
  293. package/hmr/server/server-origin.js.map +1 -0
  294. package/hmr/server/shared-transform-request.js +1 -2
  295. package/hmr/server/shared-transform-request.js.map +1 -1
  296. package/hmr/server/transform-cache-invalidation.d.ts +37 -0
  297. package/hmr/server/transform-cache-invalidation.js +156 -0
  298. package/hmr/server/transform-cache-invalidation.js.map +1 -0
  299. package/hmr/server/vendor-bare-module-shims.d.ts +4 -0
  300. package/hmr/server/vendor-bare-module-shims.js +80 -0
  301. package/hmr/server/vendor-bare-module-shims.js.map +1 -0
  302. package/hmr/server/vite-plugin.d.ts +1 -0
  303. package/hmr/server/vite-plugin.js +180 -54
  304. package/hmr/server/vite-plugin.js.map +1 -1
  305. package/hmr/server/websocket-core-bridge.d.ts +51 -4
  306. package/hmr/server/websocket-core-bridge.js +62 -54
  307. package/hmr/server/websocket-core-bridge.js.map +1 -1
  308. package/hmr/server/websocket-css-hot-update.d.ts +33 -0
  309. package/hmr/server/websocket-css-hot-update.js +65 -0
  310. package/hmr/server/websocket-css-hot-update.js.map +1 -0
  311. package/hmr/server/websocket-device-transform.d.ts +3 -0
  312. package/hmr/server/websocket-device-transform.js +7 -0
  313. package/hmr/server/websocket-device-transform.js.map +1 -0
  314. package/hmr/server/websocket-hmr-pending.d.ts +3 -9
  315. package/hmr/server/websocket-hmr-pending.js +1 -1
  316. package/hmr/server/websocket-hmr-pending.js.map +1 -1
  317. package/hmr/server/websocket-hot-update.d.ts +77 -0
  318. package/hmr/server/websocket-hot-update.js +360 -0
  319. package/hmr/server/websocket-hot-update.js.map +1 -0
  320. package/hmr/server/websocket-import-map-route.d.ts +15 -0
  321. package/hmr/server/websocket-import-map-route.js +50 -0
  322. package/hmr/server/websocket-import-map-route.js.map +1 -0
  323. package/hmr/server/websocket-module-bindings.js +3 -3
  324. package/hmr/server/websocket-module-bindings.js.map +1 -1
  325. package/hmr/server/websocket-module-specifiers.d.ts +66 -2
  326. package/hmr/server/websocket-module-specifiers.js +191 -20
  327. package/hmr/server/websocket-module-specifiers.js.map +1 -1
  328. package/hmr/server/websocket-ns-core.d.ts +34 -0
  329. package/hmr/server/websocket-ns-core.js +414 -0
  330. package/hmr/server/websocket-ns-core.js.map +1 -0
  331. package/hmr/server/websocket-ns-entry.d.ts +21 -0
  332. package/hmr/server/websocket-ns-entry.js +164 -0
  333. package/hmr/server/websocket-ns-entry.js.map +1 -0
  334. package/hmr/server/websocket-ns-m-paths.d.ts +1 -3
  335. package/hmr/server/websocket-ns-m-paths.js +25 -82
  336. package/hmr/server/websocket-ns-m-paths.js.map +1 -1
  337. package/hmr/server/websocket-ns-m-request.d.ts +11 -1
  338. package/hmr/server/websocket-ns-m-request.js +17 -9
  339. package/hmr/server/websocket-ns-m-request.js.map +1 -1
  340. package/hmr/server/websocket-ns-m.d.ts +52 -0
  341. package/hmr/server/websocket-ns-m.js +824 -0
  342. package/hmr/server/websocket-ns-m.js.map +1 -0
  343. package/hmr/server/websocket-served-module-helpers.d.ts +50 -4
  344. package/hmr/server/websocket-served-module-helpers.js +384 -86
  345. package/hmr/server/websocket-served-module-helpers.js.map +1 -1
  346. package/hmr/server/websocket-txn.js +6 -9
  347. package/hmr/server/websocket-txn.js.map +1 -1
  348. package/hmr/server/websocket-vendor-unifier.d.ts +0 -1
  349. package/hmr/server/websocket-vendor-unifier.js +4 -9
  350. package/hmr/server/websocket-vendor-unifier.js.map +1 -1
  351. package/hmr/server/websocket.d.ts +7 -39
  352. package/hmr/server/websocket.js +643 -6716
  353. package/hmr/server/websocket.js.map +1 -1
  354. package/hmr/shared/ns-globals.d.ts +108 -0
  355. package/hmr/shared/ns-globals.js +28 -0
  356. package/hmr/shared/ns-globals.js.map +1 -0
  357. package/hmr/shared/protocol.d.ts +145 -0
  358. package/hmr/shared/protocol.js +28 -0
  359. package/hmr/shared/protocol.js.map +1 -0
  360. package/hmr/shared/runtime/boot-archive-format.d.ts +16 -0
  361. package/hmr/shared/runtime/boot-archive-format.js +31 -0
  362. package/hmr/shared/runtime/boot-archive-format.js.map +1 -0
  363. package/hmr/shared/runtime/boot-complete.d.ts +14 -0
  364. package/hmr/shared/runtime/boot-complete.js +32 -0
  365. package/hmr/shared/runtime/boot-complete.js.map +1 -0
  366. package/hmr/shared/runtime/boot-placeholder-ui.d.ts +69 -0
  367. package/hmr/shared/runtime/boot-placeholder-ui.js +101 -0
  368. package/hmr/shared/runtime/boot-placeholder-ui.js.map +1 -0
  369. package/hmr/shared/runtime/boot-progress.d.ts +44 -0
  370. package/hmr/shared/runtime/boot-progress.js +134 -0
  371. package/hmr/shared/runtime/boot-progress.js.map +1 -0
  372. package/hmr/shared/runtime/boot-timeline.d.ts +2 -1
  373. package/hmr/shared/runtime/boot-timeline.js +9 -22
  374. package/hmr/shared/runtime/boot-timeline.js.map +1 -1
  375. package/hmr/shared/runtime/browser-runtime-contract.d.ts +53 -22
  376. package/hmr/shared/runtime/browser-runtime-contract.js +6 -9
  377. package/hmr/shared/runtime/browser-runtime-contract.js.map +1 -1
  378. package/hmr/shared/runtime/dev-overlay-snapshots.d.ts +31 -0
  379. package/hmr/shared/runtime/dev-overlay-snapshots.js +324 -0
  380. package/hmr/shared/runtime/dev-overlay-snapshots.js.map +1 -0
  381. package/hmr/shared/runtime/dev-overlay.d.ts +76 -30
  382. package/hmr/shared/runtime/dev-overlay.js +767 -408
  383. package/hmr/shared/runtime/dev-overlay.js.map +1 -1
  384. package/hmr/shared/runtime/global-scope.d.ts +18 -0
  385. package/hmr/shared/runtime/global-scope.js +21 -0
  386. package/hmr/shared/runtime/global-scope.js.map +1 -0
  387. package/hmr/shared/runtime/hooks.js +2 -1
  388. package/hmr/shared/runtime/hooks.js.map +1 -1
  389. package/hmr/shared/runtime/http-only-boot.js +7 -6
  390. package/hmr/shared/runtime/http-only-boot.js.map +1 -1
  391. package/hmr/shared/runtime/module-provenance.js +4 -6
  392. package/hmr/shared/runtime/module-provenance.js.map +1 -1
  393. package/hmr/shared/runtime/root-placeholder-view.d.ts +19 -0
  394. package/hmr/shared/runtime/root-placeholder-view.js +311 -0
  395. package/hmr/shared/runtime/root-placeholder-view.js.map +1 -0
  396. package/hmr/shared/runtime/root-placeholder.js +398 -204
  397. package/hmr/shared/runtime/root-placeholder.js.map +1 -1
  398. package/hmr/shared/runtime/session-bootstrap.js +255 -50
  399. package/hmr/shared/runtime/session-bootstrap.js.map +1 -1
  400. package/hmr/shared/runtime/vendor-bootstrap.js +3 -10
  401. package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
  402. package/hmr/shared/vendor/manifest-collect.d.ts +4 -0
  403. package/hmr/shared/vendor/manifest-collect.js +549 -0
  404. package/hmr/shared/vendor/manifest-collect.js.map +1 -0
  405. package/hmr/shared/vendor/manifest-loader.d.ts +2 -1
  406. package/hmr/shared/vendor/manifest-loader.js +5 -3
  407. package/hmr/shared/vendor/manifest-loader.js.map +1 -1
  408. package/hmr/shared/vendor/manifest.d.ts +1 -7
  409. package/hmr/shared/vendor/manifest.js +125 -825
  410. package/hmr/shared/vendor/manifest.js.map +1 -1
  411. package/hmr/shared/vendor/registry.d.ts +2 -0
  412. package/hmr/shared/vendor/registry.js +14 -0
  413. package/hmr/shared/vendor/registry.js.map +1 -1
  414. package/hmr/shared/vendor/vendor-device-shim.d.ts +1 -0
  415. package/hmr/shared/vendor/vendor-device-shim.js +208 -0
  416. package/hmr/shared/vendor/vendor-device-shim.js.map +1 -0
  417. package/hmr/shared/vendor/vendor-esbuild-plugins.d.ts +38 -0
  418. package/hmr/shared/vendor/vendor-esbuild-plugins.js +296 -0
  419. package/hmr/shared/vendor/vendor-esbuild-plugins.js.map +1 -0
  420. package/hmr/vendor-bootstrap.d.ts +1 -3
  421. package/hmr/vendor-bootstrap.js +4 -6
  422. package/hmr/vendor-bootstrap.js.map +1 -1
  423. package/index.d.ts +1 -0
  424. package/index.js +5 -0
  425. package/index.js.map +1 -1
  426. package/package.json +65 -11
  427. package/runtime/core-aliases-early.js +25 -55
  428. package/runtime/core-aliases-early.js.map +1 -1
  429. package/shims/react-jsx-runtime.d.ts +4 -0
  430. package/shims/react-jsx-runtime.js +61 -0
  431. package/shims/react-jsx-runtime.js.map +1 -0
  432. package/helpers/angular/angular-linker.d.ts +0 -13
  433. package/helpers/angular/angular-linker.js +0 -194
  434. package/helpers/angular/angular-linker.js.map +0 -1
  435. package/helpers/angular/inline-decorator-component-templates.js.map +0 -1
  436. package/helpers/angular/shared-linker.d.ts +0 -11
  437. package/helpers/angular/shared-linker.js +0 -75
  438. package/helpers/angular/shared-linker.js.map +0 -1
  439. package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +0 -1
  440. package/helpers/angular/synthesize-injectable-factories.js.map +0 -1
  441. package/helpers/angular/util.js +0 -67
  442. package/helpers/angular/util.js.map +0 -1
  443. package/helpers/prelink-angular.d.ts +0 -2
  444. package/helpers/prelink-angular.js +0 -117
  445. package/helpers/prelink-angular.js.map +0 -1
  446. package/hmr/server/websocket-angular-entry.js.map +0 -1
  447. package/hmr/server/websocket-angular-hot-update.js.map +0 -1
  448. package/hmr/server/websocket-ns-m-finalize.d.ts +0 -22
  449. package/hmr/server/websocket-ns-m-finalize.js +0 -88
  450. package/hmr/server/websocket-ns-m-finalize.js.map +0 -1
  451. package/hmr/server/websocket-runtime-compat.d.ts +0 -19
  452. package/hmr/server/websocket-runtime-compat.js +0 -286
  453. package/hmr/server/websocket-runtime-compat.js.map +0 -1
  454. package/hmr/server/websocket-vue-sfc.d.ts +0 -27
  455. package/hmr/server/websocket-vue-sfc.js +0 -1114
  456. package/hmr/server/websocket-vue-sfc.js.map +0 -1
  457. package/transformers/NativeClass/index.d.ts +0 -2
  458. package/transformers/NativeClass/index.js +0 -222
  459. package/transformers/NativeClass/index.js.map +0 -1
  460. /package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.d.ts +0 -0
  461. /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-decorator-ctor-parameters.d.ts +0 -0
  462. /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.d.ts +0 -0
  463. /package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.d.ts +0 -0
@@ -1,9 +1,99 @@
1
1
  import { parse as babelParse } from '@babel/parser';
2
2
  import * as t from '@babel/types';
3
+ import { existsSync, readFileSync } from 'fs';
4
+ import * as path from 'path';
3
5
  import * as PAT from './constants.js';
4
6
  import { isDeepCoreSubpath } from './core-sanitize.js';
5
- import { extractDirectExportedNames } from './websocket-core-bridge.js';
6
- const MODULE_IMPORT_ANALYSIS_PLUGINS = ['typescript', 'jsx', 'importMeta', 'topLevelAwait', 'classProperties', 'classPrivateProperties', 'classPrivateMethods', 'decorators-legacy'];
7
+ import { getCjsNamedExports } from '../helpers/cjs-named-exports.js';
8
+ import { getMonorepoWorkspaceRoot } from '../../helpers/project.js';
9
+ import { extractDirectExportedNames, parseExportSpecList } from './websocket-core-bridge.js';
10
+ import { resolveCandidateFilePath } from './websocket-module-specifiers.js';
11
+ let cachedWorkspaceCoreRoot;
12
+ /**
13
+ * Absolute root of @nativescript/core when it is consumed from monorepo
14
+ * source (`<workspace>/packages/core` in the NativeScript repo) rather than
15
+ * node_modules. Returns null for standalone apps.
16
+ */
17
+ export function getWorkspaceCoreSourceRoot() {
18
+ if (cachedWorkspaceCoreRoot !== undefined)
19
+ return cachedWorkspaceCoreRoot;
20
+ cachedWorkspaceCoreRoot = null;
21
+ try {
22
+ const wsRoot = getMonorepoWorkspaceRoot();
23
+ if (wsRoot) {
24
+ const pkgPath = path.join(wsRoot, 'packages/core/package.json');
25
+ if (existsSync(pkgPath)) {
26
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
27
+ if (pkg?.name === '@nativescript/core') {
28
+ cachedWorkspaceCoreRoot = path.resolve(wsRoot, 'packages/core').replace(/\\/g, '/');
29
+ }
30
+ }
31
+ }
32
+ }
33
+ catch { }
34
+ return cachedWorkspaceCoreRoot;
35
+ }
36
+ /**
37
+ * True when a served module path points into @nativescript/core consumed from
38
+ * monorepo source. These modules are library code: the app-source HMR passes
39
+ * (AST normalization, /ns/rt underscore-helper alias injection) must NOT run
40
+ * on them — they exist for compiled app/SFC output, and on core sources they
41
+ * misread internals (e.g. `ClassInfo._getBase`) as Vue template helpers and
42
+ * inject destructures that shadow real bindings or TDZ-crash on the circular
43
+ * /ns/rt dependency. In standalone apps core lives under node_modules and is
44
+ * already excluded by the node_modules check.
45
+ */
46
+ export function isWorkspaceCoreModulePath(p) {
47
+ if (!p)
48
+ return false;
49
+ const coreRoot = getWorkspaceCoreSourceRoot();
50
+ if (!coreRoot)
51
+ return false;
52
+ const normalized = String(p).split('?')[0].replace(/\\/g, '/');
53
+ return normalized.includes(coreRoot + '/') || /(^|\/)packages\/core\//.test(normalized);
54
+ }
55
+ /**
56
+ * True when a served module path points into the @nativescript/vite package
57
+ * routed via its monorepo build output (`dist/packages/vite/...`). Apps that
58
+ * consume the package via `file:../../dist/packages/vite` get a node_modules
59
+ * SYMLINK, and require.resolve follows it to the real dist path — so the
60
+ * served URL carries no `node_modules/` segment and escapes the node_modules
61
+ * library check. Like core source, this is library code: the app-source HMR
62
+ * passes (AST normalization, /ns/rt alias injection) must not run on it —
63
+ * e.g. the HMR client bundle already carries its own `__ns_rt_ns_re` import,
64
+ * and a second injected one is a duplicate-declaration SyntaxError on device.
65
+ */
66
+ export function isWorkspaceVitePackageModulePath(p) {
67
+ if (!p)
68
+ return false;
69
+ const normalized = String(p).split('?')[0].replace(/\\/g, '/');
70
+ return /(^|\/)dist\/packages\/vite\//.test(normalized);
71
+ }
72
+ /**
73
+ * Single classification point for the /ns/m served-module pipeline. The
74
+ * app-source passes inside processCodeForDevice (AST normalization, /ns/rt
75
+ * underscore-helper alias injection) must run ONLY on 'app' modules; 'library'
76
+ * code is served as-is plus import rewriting. Three things count as library:
77
+ * - anything under node_modules
78
+ * - @nativescript/core consumed from monorepo source (packages/core)
79
+ * - the @nativescript/vite package served from its dist build output
80
+ * (file:../../dist/packages/vite symlinks resolve to the real dist path,
81
+ * so no node_modules segment appears in the URL)
82
+ * Add the next workspace-library case HERE, not at a call site.
83
+ */
84
+ export function classifyServedModule(p) {
85
+ if (!p)
86
+ return 'app';
87
+ const normalized = String(p).split('?')[0].replace(/\\/g, '/');
88
+ if (/(?:^|\/)node_modules\//.test(normalized))
89
+ return 'library';
90
+ if (isWorkspaceCoreModulePath(normalized))
91
+ return 'library';
92
+ if (isWorkspaceVitePackageModulePath(normalized))
93
+ return 'library';
94
+ return 'app';
95
+ }
96
+ export const MODULE_IMPORT_ANALYSIS_PLUGINS = ['typescript', 'jsx', 'importMeta', 'topLevelAwait', 'classProperties', 'classPrivateProperties', 'classPrivateMethods', 'decorators-legacy'];
7
97
  export function collectTopLevelImportRecords(code) {
8
98
  if (!code || typeof code !== 'string' || !/\bimport\b/.test(code)) {
9
99
  return [];
@@ -63,14 +153,27 @@ export function hoistTopLevelStaticImports(code) {
63
153
  }
64
154
  return `${hoisted.join('\n')}\n${stripped.replace(/^\s*\n+/, '')}`;
65
155
  }
156
+ // Boot-progress instrumentation snippet (server-side string-only).
157
+ //
158
+ // Injected at the top of every `__ns_boot__/b1`-tagged module the dev
159
+ // server serves during cold boot. The snippet is FULLY SYNCHRONOUS —
160
+ // even one conditional top-level `await` would mark the module async
161
+ // in V8, propagating an async-promise chain through the entire boot
162
+ // graph and tripping the iOS 10 s top-level-await deadline (see
163
+ // `ModuleInternal.mm::pumpAsyncProgress`). It just bumps the
164
+ // `__NS_HMR_BOOT_MODULE_COUNT__` / `__NS_HMR_BOOT_LAST_MODULE__`
165
+ // globals; the 250 ms heartbeat in `session-bootstrap.ts` owns
166
+ // `setBootStage` and runs `boot-progress.ts::computeBootImportProgress`
167
+ // against those counters plus elapsed wall-clock to drive the bar.
168
+ // The iOS runtime's `MaybePumpJSThreadDuringBoot` keeps the JS-thread
169
+ // CFRunLoop ticking between sync fetches so the heartbeat can fire
170
+ // during the otherwise-blocking cold-boot module walk.
171
+ //
172
+ // Regression-tested by `websocket-integrity.spec.ts` (snippet stays
173
+ // fully synchronous + propagates exactly via the boot-tag prefix).
66
174
  export function buildBootProgressSnippet(bootModuleLabel) {
67
175
  const normalizedLabel = JSON.stringify(String(bootModuleLabel || '').replace(/\\/g, '/'));
68
- return [
69
- `const __nsBootGlobal=globalThis;`,
70
- `try{if(!__nsBootGlobal.__NS_HMR_BOOT_COMPLETE__){const __nsBootApi=__nsBootGlobal.__NS_HMR_DEV_OVERLAY__;if(__nsBootApi&&typeof __nsBootApi.setBootStage==='function'){const __nsBootCount=(__nsBootGlobal.__NS_HMR_BOOT_MODULE_COUNT__=Number(__nsBootGlobal.__NS_HMR_BOOT_MODULE_COUNT__||0)+1);__nsBootGlobal.__NS_HMR_BOOT_LAST_MODULE__=${normalizedLabel};const __nsBootNow=Date.now();const __nsBootLast=Number(__nsBootGlobal.__NS_HMR_BOOT_LAST_PROGRESS_AT__||0);if(__nsBootCount<=8||__nsBootCount%6===0||__nsBootNow-__nsBootLast>90){__nsBootGlobal.__NS_HMR_BOOT_LAST_PROGRESS_AT__=__nsBootNow;const __nsBootProgress=Math.min(94,82+Math.min(10,Math.round((Math.log(__nsBootCount+1)/Math.LN2)*2)));__nsBootApi.setBootStage('importing-main',{detail:'Evaluated '+__nsBootCount+' modules\\n'+__nsBootGlobal.__NS_HMR_BOOT_LAST_MODULE__,attempt:Number(__nsBootGlobal.__NS_HMR_BOOT_MAIN_ATTEMPT__||1),attempts:Number(__nsBootGlobal.__NS_HMR_BOOT_MAIN_ATTEMPTS__||6),progress:__nsBootProgress});}}}}catch(__nsBootErr){}`,
71
- `if(!__nsBootGlobal.__NS_HMR_BOOT_COMPLETE__){const __nsBootCount=Number(__nsBootGlobal.__NS_HMR_BOOT_MODULE_COUNT__||0);if(__nsBootCount<=24||__nsBootCount%8===0){await new Promise((resolve)=>setTimeout(resolve,0));}}`,
72
- '',
73
- ].join('\n');
176
+ return [`const __nsBootGlobal=globalThis;`, `try{if(!__nsBootGlobal.__NS_HMR_BOOT_COMPLETE__){__nsBootGlobal.__NS_HMR_BOOT_MODULE_COUNT__=Number(__nsBootGlobal.__NS_HMR_BOOT_MODULE_COUNT__||0)+1;__nsBootGlobal.__NS_HMR_BOOT_LAST_MODULE__=${normalizedLabel};}}catch(__nsBootErr){}`, ''].join('\n');
74
177
  }
75
178
  export function stripCoreGlobalsImports(code) {
76
179
  const pattern = /^\s*(?:import\s+(?:[^'"\n]*from\s+)?|export\s+\*\s+from\s+)["'][^"']*(?:@nativescript(?:[/_-])core(?:[\/_-])globals|@nativescript_core_globals)[^"']*["'];?\s*$/gm;
@@ -99,7 +202,7 @@ export function ensureVariableDynamicImportHelper(code) {
99
202
  `};\n`;
100
203
  return `${helper}${code}`;
101
204
  }
102
- export function ensureGuardPlainDynamicImports(code, _origin) {
205
+ export function ensureGuardPlainDynamicImports(code) {
103
206
  try {
104
207
  if (!code || !/\bimport\s*\(/.test(code))
105
208
  return code;
@@ -114,20 +217,21 @@ export function ensureGuardPlainDynamicImports(code, _origin) {
114
217
  return code;
115
218
  }
116
219
  }
117
- // alpha.59 — Stable URL helper for dynamic imports.
220
+ // Stable URL helper for dynamic imports.
118
221
  //
119
- // Pre-alpha.59 the helper synthesized `/ns/m/__ns_hmr__/<tag>/<rest>` URLs
120
- // from `globalThis.__NS_HMR_GRAPH_VERSION__` and an importer-derived tag.
121
- // That tag flowed straight into V8's `g_moduleRegistry` cache key — so a
122
- // `graphVersion` bump on every save effectively flushed the whole module
123
- // graph (HMR latency was dominated by Vite re-transforming the unchanged
124
- // closure on every save, ~3s per cycle).
222
+ // Older versions of the helper synthesized
223
+ // `/ns/m/__ns_hmr__/<tag>/<rest>` URLs from
224
+ // `globalThis.__NS_HMR_GRAPH_VERSION__` and an importer-derived tag.
225
+ // That tag flowed straight into V8's `g_moduleRegistry` cache key — so
226
+ // a `graphVersion` bump on every save effectively flushed the whole
227
+ // module graph (HMR latency was dominated by Vite re-transforming the
228
+ // unchanged closure on every save).
125
229
  //
126
- // alpha.59 inverts that contract:
230
+ // The current contract inverts that:
127
231
  // * The runtime canonicalizes any URL shape (boot prefix, hmr prefix,
128
232
  // stable) to a single key via `CanonicalizeHttpUrlKey`.
129
233
  // * The Angular client receives an explicit eviction set in
130
- // `ns:angular-update` and calls `__nsInvalidateModules` before
234
+ // `ns:angular-update` and calls `__NS_DEV__.invalidateModules` before
131
235
  // re-importing the entry, so V8 only refetches modules that
132
236
  // actually changed.
133
237
  // * The dynamic-import helper no longer needs to busy-construct
@@ -143,10 +247,10 @@ export function ensureGuardPlainDynamicImports(code, _origin) {
143
247
  // 2. `/ns/m/...` specs that don't yet have a boot prefix get one
144
248
  // added when the caller is itself a boot-tagged module. This
145
249
  // keeps the boot-progress instrumentation flowing through the
146
- // transitive cold-boot graph on alpha.59 + alpha.59 boot
147
- // sequences. Once HMR takes over (`__NS_HMR_BOOT_COMPLETE__` is
148
- // set on the global), no prefix is added — the runtime
149
- // canonicalizer collapses any historical prefix to the same key.
250
+ // transitive cold-boot graph during cold-boot sequences. Once HMR
251
+ // takes over (`__NS_HMR_BOOT_COMPLETE__` is set on the global), no
252
+ // prefix is added — the runtime canonicalizer collapses any
253
+ // historical prefix to the same key.
150
254
  // 3. Everything else is a pass-through `import(spec)`.
151
255
  export function ensureDynamicHmrImportHelper(code) {
152
256
  try {
@@ -175,40 +279,198 @@ export function ensureDynamicHmrImportHelper(code) {
175
279
  return code;
176
280
  }
177
281
  }
178
- function extractExportedNames(code) {
179
- return extractDirectExportedNames(code);
282
+ /**
283
+ * Star-export expansion must be TRANSITIVE.
284
+ *
285
+ * The expansion below replaces `export * from "url"` with an explicit named
286
+ * list, so any name missing from that list is silently dropped from the
287
+ * importer's export surface — the device then fails at link time with
288
+ * "does not provide an export named '<name>'". Real packages routinely chain
289
+ * star re-exports (`index.ios.js → export * from './canvas'` →
290
+ * `canvas.ios.js → export * from './canvas.common'`), so the name set for a
291
+ * star target is the union of its direct exports, its named re-exports, and
292
+ * — recursively — every nested `export * from` chain, cycles included.
293
+ *
294
+ * This mirrors `collectStaticExportOriginsFromFile` in
295
+ * `websocket-core-bridge.ts`, which solved the identical problem for the
296
+ * /ns/core bridge (see its `Application` comment). That walker reads files
297
+ * from disk; this one works on Vite-transformed code via the shared
298
+ * transformer, because star targets here are served URLs (aliases, /@fs
299
+ * paths, platform-extension resolution already applied by Vite's resolver).
300
+ * If you change export-name semantics in one walker, check the other.
301
+ */
302
+ const STAR_EXPANSION_MAX_DEPTH = 64;
303
+ /**
304
+ * Normalize a star-export target (served URL or nested transformed
305
+ * specifier) into a root-relative path feedable to Vite's transform
306
+ * pipeline. Returns null for specifiers that cannot be walked (bare ids,
307
+ * relative specs with no parent context).
308
+ */
309
+ function normalizeStarExportTargetPath(spec, parentVitePath) {
310
+ let p = String(spec || '').trim();
311
+ if (!p)
312
+ return null;
313
+ p = p.replace(/^https?:\/\/[^/]+/, '');
314
+ p = p.replace(/[?#].*$/, '');
315
+ p = p.replace(/^\/ns\/m\//, '/');
316
+ p = p.replace(/^\/__ns_boot__\/[^/]+/, '');
317
+ p = p.replace(/\/__ns_hmr__\/[^/]+/, '');
318
+ if (p.startsWith('.')) {
319
+ // Vite's import analysis normally rewrites nested specifiers to
320
+ // root-relative URLs; resolve any relative stragglers against the
321
+ // parent module's directory.
322
+ const parent = String(parentVitePath || '')
323
+ .replace(/\\/g, '/')
324
+ .replace(/[?#].*$/, '');
325
+ if (!parent.startsWith('/'))
326
+ return null;
327
+ p = path.posix.normalize(path.posix.join(path.posix.dirname(parent), p));
328
+ }
329
+ return p.startsWith('/') ? p : null;
330
+ }
331
+ function scanModuleExportSurface(code) {
332
+ const ownNames = new Set(extractDirectExportedNames(code));
333
+ for (const m of code.matchAll(/\bexport\s+\*\s+as\s+([A-Za-z_$][\w$]*)\s+from\s*["'][^"']+["']/g)) {
334
+ ownNames.add(m[1]);
335
+ }
336
+ for (const m of code.matchAll(/\bexport\s*\{([^}]+)\}\s*from\s*["'][^"']+["']/g)) {
337
+ for (const { exportedName } of parseExportSpecList(m[1])) {
338
+ ownNames.add(exportedName);
339
+ }
340
+ }
341
+ const starSources = [];
342
+ // Tolerate trailing comments/code on the line (see the identical fix in
343
+ // websocket-core-bridge.ts: a strict `$` anchor silently skipped
344
+ // `export * from './layouts'; // barrel export` lines).
345
+ for (const m of code.matchAll(/^[ \t]*export\s+\*\s+from\s+["']([^"']+)["'][^\n]*$/gm)) {
346
+ starSources.push(m[1]);
347
+ }
348
+ return { ownNames, starSources };
349
+ }
350
+ /**
351
+ * Recursively collect the full export-name set of a star-export target,
352
+ * following nested `export * from` chains. Cycle-safe via the DFS `stack`
353
+ * set (a revisited module contributes nothing new at that point — its names
354
+ * are already being collected by the outer visit, matching spec
355
+ * GetExportedNames semantics). Returns null when the target itself cannot
356
+ * be transformed; partial failures deeper in the chain are reported through
357
+ * `diagnostics` while still returning every name that could be collected.
358
+ */
359
+ async function collectStarTargetExportNames(vitePath, transformer, stack, depth, diagnostics) {
360
+ if (stack.has(vitePath))
361
+ return new Set();
362
+ if (depth > STAR_EXPANSION_MAX_DEPTH) {
363
+ diagnostics.push(`star-export chain deeper than ${STAR_EXPANSION_MAX_DEPTH} at ${vitePath}`);
364
+ return null;
365
+ }
366
+ let targetCode;
367
+ try {
368
+ targetCode = (await transformer(vitePath))?.code ?? undefined;
369
+ }
370
+ catch { }
371
+ if (!targetCode) {
372
+ diagnostics.push(`unresolvable star-export target ${vitePath}`);
373
+ return null;
374
+ }
375
+ const surface = scanModuleExportSurface(targetCode);
376
+ const names = new Set(surface.ownNames);
377
+ stack.add(vitePath);
378
+ try {
379
+ for (const spec of surface.starSources) {
380
+ const childPath = normalizeStarExportTargetPath(spec, vitePath);
381
+ if (!childPath) {
382
+ diagnostics.push(`unwalkable nested star-export specifier ${JSON.stringify(spec)} in ${vitePath}`);
383
+ continue;
384
+ }
385
+ const childNames = await collectStarTargetExportNames(childPath, transformer, stack, depth + 1, diagnostics);
386
+ if (!childNames)
387
+ continue;
388
+ for (const n of childNames)
389
+ names.add(n);
390
+ }
391
+ }
392
+ finally {
393
+ stack.delete(vitePath);
394
+ }
395
+ // `export *` never re-exports default.
396
+ names.delete('default');
397
+ return names;
180
398
  }
181
- export async function expandStarExports(code, server, _projectRoot, verbose) {
182
- const STAR_RE = /^[ \t]*(export\s+\*\s+from\s+["'])([^"']+)(["'];?)[ \t]*$/gm;
399
+ export async function expandStarExports(code, server, projectRoot, verbose, sharedTransformer, importerId) {
400
+ const STAR_RE = /^[ \t]*export\s+\*\s+from\s+["']([^"']+)["'];?(?=[ \t]*(?:\/\/[^\n]*)?$)/gm;
183
401
  let match;
184
402
  const replacements = [];
185
403
  while ((match = STAR_RE.exec(code)) !== null) {
186
- const url = match[2];
404
+ const url = match[1];
187
405
  if (!url.includes('/node_modules/'))
188
406
  continue;
189
- replacements.push({ full: match[0], url, prefix: match[1], suffix: match[3] });
407
+ replacements.push({ full: match[0], url });
190
408
  }
191
409
  if (!replacements.length)
192
410
  return code;
193
- for (const rep of replacements) {
194
- try {
195
- let vitePath = rep.url.replace(/^https?:\/\/[^/]+/, '');
196
- vitePath = vitePath.replace(/^\/ns\/m\//, '/');
197
- vitePath = vitePath.replace(/^\/__ns_boot__\/[^/]+/, '');
198
- vitePath = vitePath.replace(/\/__ns_hmr__\/[^/]+/, '');
199
- const result = await server.transformRequest(vitePath);
200
- if (!result?.code)
201
- continue;
202
- const names = extractExportedNames(result.code);
203
- if (!names.length)
204
- continue;
205
- const explicit = `export { ${names.join(', ')} } from ${JSON.stringify(rep.url)};`;
206
- code = code.replace(rep.full, explicit);
207
- if (verbose) {
208
- console.log(`[ns/m] expanded export* -> ${names.length} names from ${vitePath}`);
411
+ // Names already exported lexically by the importing module. Per spec,
412
+ // lexical exports shadow star-exported names — re-emitting them in an
413
+ // explicit list would be a duplicate-export SyntaxError on device.
414
+ const claimed = new Set(scanModuleExportSurface(code).ownNames);
415
+ // Resolve each star-export target in parallel through the shared runner
416
+ // (when provided) so they share the /ns/m TTL cache and concurrency gate.
417
+ const baseTransformer = sharedTransformer ?? ((url) => server.transformRequest(url));
418
+ // A bare `/node_modules/<pkg>/...` URL is NOT transformable on its own:
419
+ // Vite's bare-specifier resolver is gated by the package's
420
+ // `package.json#exports` and refuses internal sub-paths even when the file
421
+ // is on disk (e.g. `css-tree/lib/version.js`, `css-what/dist/esm/types.js`),
422
+ // and in a monorepo the package is hoisted ABOVE the app's `root` so the
423
+ // path doesn't exist relative to it at all. Either way the transform
424
+ // returns nothing and the star target is mis-reported as "unresolvable",
425
+ // silently dropping its names from the importer's export surface. Mirror the
426
+ // main /ns/m route (`filterExistingNodeModulesTransformCandidates`): resolve
427
+ // the path to a concrete file under the project or workspace root and feed
428
+ // the `/@fs/<abs>` form to Vite, which bypasses the `exports` gate. Falls
429
+ // back to the raw URL for anything that doesn't resolve to a real file.
430
+ const workspaceRoot = projectRoot ? getMonorepoWorkspaceRoot(projectRoot) : null;
431
+ const transformer = (url) => {
432
+ if (projectRoot && url.includes('/node_modules/')) {
433
+ const abs = resolveCandidateFilePath(url, projectRoot, workspaceRoot);
434
+ if (abs) {
435
+ // Posix-normalize and guarantee a leading slash so Windows drive
436
+ // letters produce the `/@fs/C:/...` form Vite expects.
437
+ const absPosix = abs.replace(/\\/g, '/');
438
+ return baseTransformer(`/@fs${absPosix.startsWith('/') ? '' : '/'}${absPosix}`);
209
439
  }
210
440
  }
211
- catch { }
441
+ return baseTransformer(url);
442
+ };
443
+ const resolved = await Promise.all(replacements.map(async (rep) => {
444
+ const diagnostics = [];
445
+ const vitePath = normalizeStarExportTargetPath(rep.url, null);
446
+ if (!vitePath) {
447
+ diagnostics.push(`unwalkable star-export URL ${rep.url}`);
448
+ return { rep, names: null, diagnostics };
449
+ }
450
+ const names = await collectStarTargetExportNames(vitePath, transformer, new Set(), 0, diagnostics);
451
+ if (verbose && names) {
452
+ console.log(`[ns/m] expanded export* -> ${names.size} names from ${vitePath}${diagnostics.length ? ' (partial)' : ''}`);
453
+ }
454
+ return { rep, names, diagnostics };
455
+ }));
456
+ for (const entry of resolved) {
457
+ if (entry.diagnostics.length) {
458
+ // Always-on: an incomplete expansion silently narrows the importer's
459
+ // export surface, which surfaces on device as a link-time
460
+ // "does not provide an export named ..." with no server-side trace.
461
+ console.warn(`[ns/m][export*] incomplete star-export expansion${importerId ? ` in ${importerId}` : ''} for ${entry.rep.url}: ${entry.diagnostics.join('; ')}`);
462
+ }
463
+ if (!entry.names)
464
+ continue;
465
+ // First star wins for names provided by multiple siblings; duplicates
466
+ // would be a SyntaxError, and spec-ambiguous names have no good answer.
467
+ const emit = Array.from(entry.names).filter((n) => !claimed.has(n));
468
+ for (const n of emit)
469
+ claimed.add(n);
470
+ // An empty list still keeps the dependency edge (side effects,
471
+ // evaluation order) via a side-effect import.
472
+ const explicit = emit.length ? `export { ${emit.join(', ')} } from ${JSON.stringify(entry.rep.url)};` : `import ${JSON.stringify(entry.rep.url)};`;
473
+ code = code.replace(entry.rep.full, explicit);
212
474
  }
213
475
  return code;
214
476
  }
@@ -231,11 +493,17 @@ export function repairImportEqualsAssignments(code) {
231
493
  catch { }
232
494
  return code;
233
495
  }
234
- export function ensureVersionedRtImports(code, origin, ver) {
235
- if (!code || !origin || !Number.isFinite(ver))
496
+ // Canonicalize `/ns/rt` imports: collapse any versioned form
497
+ // (`/ns/rt/<n>`, `/@ns/rt/<n>`) to the single unversioned `/ns/rt` URL.
498
+ // One canonical URL per bridge module — the runtime treats the literal
499
+ // URL as module identity, so emitting `/ns/rt/<ver>` would mint a new
500
+ // module realm per graph version. (The GET route still ACCEPTS the
501
+ // versioned form for stale in-flight code; see ns-rt-route.ts.)
502
+ export function canonicalizeRtImports(code, origin) {
503
+ if (!code || !origin)
236
504
  return code;
237
- code = code.replace(/(from\s+["'])(?:https?:\/\/[^"']+)?\/(?:\@ns|ns)\/rt(?:\/[\d]+)?(["'])/g, (_m, p1, p3) => `${p1}/ns/rt/${ver}${p3}`);
238
- code = code.replace(/(import\(\s*["'])(?:https?:\/\/[^"']+)?\/(?:\@ns|ns)\/rt(?:\/[\d]+)?(["']\s*\))/g, (_m, p1, p3) => `${p1}/ns/rt/${ver}${p3}`);
505
+ code = code.replace(/(from\s+["'])(?:https?:\/\/[^"']+)?\/(?:\@ns|ns)\/rt(?:\/[\d]+)?(["'])/g, (_m, p1, p3) => `${p1}/ns/rt${p3}`);
506
+ code = code.replace(/(import\(\s*["'])(?:https?:\/\/[^"']+)?\/(?:\@ns|ns)\/rt(?:\/[\d]+)?(["']\s*\))/g, (_m, p1, p3) => `${p1}/ns/rt${p3}`);
239
507
  return code;
240
508
  }
241
509
  export function stripViteDynamicImportVirtual(code) {
@@ -243,7 +511,13 @@ export function stripViteDynamicImportVirtual(code) {
243
511
  return code;
244
512
  }
245
513
  const original = code;
246
- code = code.replace(/^[\t ]*import[^\n]*\/@id\/__x00__vite\/dynamic-import-helper[^\n]*$/gm, '');
514
+ // Statement-scoped, NOT line-anchored: Vite 8 emits its injected imports
515
+ // concatenated on ONE line with the module's original first line, e.g.
516
+ // import …"/@vite/client";import …"/@id/__x00__vite/dynamic-import-helper.js";/**
517
+ // A `^…$`-anchored replace would delete the whole line — including the
518
+ // module's leading `/**`, leaving an orphaned JSDoc body that is a
519
+ // SyntaxError ("Unexpected token '*'") on device.
520
+ code = code.replace(/import\s+[^;'"\n]*['"][^'"\n]*\/@id\/__x00__vite\/dynamic-import-helper[^'"\n]*['"]\s*;?/g, '');
247
521
  if (/\/@id\/__x00__vite\/dynamic-import-helper/.test(code)) {
248
522
  code = code.replace(/\/@id\/__x00__vite\/dynamic-import-helper[^"'`)]*/g, '/__NS_UNUSED_DYNAMIC_IMPORT_HELPER__');
249
523
  }
@@ -288,44 +562,52 @@ export function extractExportMetadata(code) {
288
562
  return { hasDefault, named: Array.from(named) };
289
563
  }
290
564
  function shouldAllowLocalCoreSanitizerPaths(contextLabel) {
291
- return /\bnode_modules\/@nativescript\/vite\/hmr\/(?:client|frameworks)\//.test(contextLabel);
565
+ // The @nativescript/vite HMR runtime (client + framework strategies)
566
+ // legitimately references local core paths in strings — allow it whether it
567
+ // is served from node_modules or from the monorepo dist output
568
+ // (`file:../../dist/packages/vite` symlinks resolve to the real dist path,
569
+ // so no node_modules segment appears in the served URL).
570
+ return /\b(?:node_modules\/@nativescript\/vite|dist\/packages\/vite)\/hmr\/(?:client|frameworks)\//.test(contextLabel);
292
571
  }
293
572
  export function assertNoOptimizedArtifacts(code, contextLabel) {
294
- try {
295
- const offenders = [];
296
- const lines = code.split('\n');
297
- const tests = [/\b__VITE_PLUGIN__\b/, /\b__VITE_PRELOAD__\b/];
298
- const localCore = /(^|[^\w@])(?:\.\.?\/|\/)??@nativescript[\/_-]core\//i;
299
- for (let i = 0; i < lines.length; i++) {
300
- const line = lines[i];
301
- for (const re of tests) {
302
- if (re.test(line)) {
303
- offenders.push(`${i + 1}: ${line.substring(0, 200)}`);
304
- break;
305
- }
306
- }
307
- if (localCore.test(line)) {
308
- const trimmed = line.trimStart();
309
- if (trimmed.startsWith('//') || trimmed.startsWith('/*') || trimmed.startsWith('*')) {
310
- continue;
311
- }
312
- if (shouldAllowLocalCoreSanitizerPaths(contextLabel)) {
313
- continue;
314
- }
315
- offenders.push(`${i + 1}: ${line.substring(0, 200)} [local-core-path]`);
316
- }
317
- if (offenders.length >= 10)
573
+ const offenders = [];
574
+ const lines = code.split('\n');
575
+ const tests = [/\b__VITE_PLUGIN__\b/, /\b__VITE_PRELOAD__\b/];
576
+ const localCore = /(^|[^\w@])(?:\.\.?\/|\/)??@nativescript[\/_-]core\//i;
577
+ for (let i = 0; i < lines.length; i++) {
578
+ const line = lines[i];
579
+ for (const re of tests) {
580
+ if (re.test(line)) {
581
+ offenders.push(`${i + 1}: ${line.substring(0, 200)}`);
318
582
  break;
583
+ }
319
584
  }
320
- if (offenders.length) {
321
- const msg = `[sanitize-fail] Optimized deps/virtual id artifacts detected in ${contextLabel}. These cannot be evaluated by the device HTTP ESM loader. Offending lines (first ${Math.min(5, offenders.length)} shown):\n` + offenders.slice(0, 5).join('\n');
322
- const error = new Error(msg);
323
- error.code = 'NS_SANITIZE_FAIL';
324
- error.offenders = offenders;
325
- throw error;
585
+ if (localCore.test(line)) {
586
+ const trimmed = line.trimStart();
587
+ if (trimmed.startsWith('//') || trimmed.startsWith('/*') || trimmed.startsWith('*')) {
588
+ continue;
589
+ }
590
+ if (shouldAllowLocalCoreSanitizerPaths(contextLabel)) {
591
+ continue;
592
+ }
593
+ // Only module-resolution contexts (import/export/require) leak to the
594
+ // device ESM loader. A core path appearing as plain runtime string data
595
+ // — e.g. component-builder's `const CORE_UI_BARREL = '@nativescript/core/ui'`
596
+ // passed to `global.loadModule()`, which reads the bundler module
597
+ // registry, not the ESM loader — is legitimate and must not fail serving.
598
+ if (!/(?:\bimport\b|\bexport\b|\bfrom\s*["']|\brequire\s*\()/.test(line)) {
599
+ continue;
600
+ }
601
+ offenders.push(`${i + 1}: ${line.substring(0, 200)} [local-core-path]`);
326
602
  }
327
- }
328
- catch (error) {
603
+ if (offenders.length >= 10)
604
+ break;
605
+ }
606
+ if (offenders.length) {
607
+ const msg = `[sanitize-fail] Optimized deps/virtual id artifacts detected in ${contextLabel}. These cannot be evaluated by the device HTTP ESM loader. Offending lines (first ${Math.min(5, offenders.length)} shown):\n` + offenders.slice(0, 5).join('\n');
608
+ const error = new Error(msg);
609
+ error.code = 'NS_SANITIZE_FAIL';
610
+ error.offenders = offenders;
329
611
  throw error;
330
612
  }
331
613
  }
@@ -342,7 +624,7 @@ export function ensureDestructureCoreImports(code) {
342
624
  return match.length === 2 ? `${match[0].trim()}: ${match[1].trim()}` : seg;
343
625
  })
344
626
  .join(', ');
345
- const reNamed = /(^|\n)\s*import\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/core(?:\/[\d]+)?(?:\?p=[^"']+)?)['"];?\s*/gm;
627
+ const reNamed = /(^|\n)\s*import\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/core(?:\/[^"']+)?)['"];?\s*/gm;
346
628
  result = result.replace(reNamed, (_full, prefix, specList, src) => {
347
629
  if (isDeepCoreSubpath(src))
348
630
  return _full;
@@ -351,7 +633,7 @@ export function ensureDestructureCoreImports(code) {
351
633
  const decl = `const { ${toDestructure(specList)} } = ${tempName};`;
352
634
  return `${prefix}import ${tempName} from ${JSON.stringify(src)};\n${decl}\n`;
353
635
  });
354
- const reMixed = /(^|\n)\s*import\s+([A-Za-z_$][\w$]*)\s*,\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/core(?:\/[\d]+)?(?:\?p=[^"']+)?)['"];?\s*/gm;
636
+ const reMixed = /(^|\n)\s*import\s+([A-Za-z_$][\w$]*)\s*,\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/core(?:\/[^"']+)?)['"];?\s*/gm;
355
637
  result = result.replace(reMixed, (_full, prefix, defName, specList, src) => {
356
638
  if (isDeepCoreSubpath(src))
357
639
  return _full;
@@ -536,7 +818,7 @@ export function deduplicateLinkerImports(code) {
536
818
  return code;
537
819
  }
538
820
  }
539
- export function wrapCommonJsModuleForDevice(code) {
821
+ export function wrapCommonJsModuleForDevice(code, absolutePath) {
540
822
  if (!code)
541
823
  return code;
542
824
  try {
@@ -562,6 +844,22 @@ export function wrapCommonJsModuleForDevice(code) {
562
844
  namedExports.add(name);
563
845
  }
564
846
  }
847
+ // Static enumeration only sees `exports.foo = ...` and `Object.defineProperty(exports, 'foo', ...)`.
848
+ // Real-world packages like lodash attach their entire surface to a function inside an IIFE and
849
+ // then `module.exports = thatFunction`. Static analysis returns zero in that case. To handle
850
+ // these modules we ALSO load the package in the dev-server's Node context (only when we have a
851
+ // node_modules path) and merge the runtime keys. See `helpers/cjs-named-exports.ts` for the
852
+ // reasoning and safety boundaries.
853
+ if (absolutePath) {
854
+ try {
855
+ for (const n of getCjsNamedExports(absolutePath)) {
856
+ namedExports.add(n);
857
+ }
858
+ }
859
+ catch {
860
+ /* fall through to whatever we caught statically */
861
+ }
862
+ }
565
863
  let suffix = `\nvar __cjs_mod = module.exports;\nexport default __cjs_mod;\n`;
566
864
  if (namedExports.size) {
567
865
  const entries = Array.from(namedExports);