@nativescript/vite 8.0.0-alpha.9 → 8.0.0-rc.0

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 (544) hide show
  1. package/README.md +73 -14
  2. package/bin/cli.cjs +8 -14
  3. package/configuration/angular.d.ts +34 -1
  4. package/configuration/angular.js +196 -217
  5. package/configuration/angular.js.map +1 -1
  6. package/configuration/base.js +151 -103
  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 +11 -92
  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-refresh.d.ts +31 -0
  19. package/helpers/app-css-refresh.js +43 -0
  20. package/helpers/app-css-refresh.js.map +1 -0
  21. package/helpers/app-css-state.d.ts +17 -0
  22. package/helpers/app-css-state.js +51 -0
  23. package/helpers/app-css-state.js.map +1 -0
  24. package/helpers/bundler-context.d.ts +11 -0
  25. package/helpers/bundler-context.js +71 -0
  26. package/helpers/bundler-context.js.map +1 -0
  27. package/helpers/cli-flags.d.ts +12 -0
  28. package/helpers/cli-flags.js +34 -0
  29. package/helpers/cli-flags.js.map +1 -1
  30. package/helpers/css-platform-plugin.d.ts +14 -0
  31. package/helpers/css-platform-plugin.js +43 -25
  32. package/helpers/css-platform-plugin.js.map +1 -1
  33. package/helpers/dev-host.d.ts +360 -0
  34. package/helpers/dev-host.js +694 -0
  35. package/helpers/dev-host.js.map +1 -0
  36. package/helpers/dynamic-import-plugin.d.ts +2 -1
  37. package/helpers/dynamic-import-plugin.js +59 -53
  38. package/helpers/dynamic-import-plugin.js.map +1 -1
  39. package/helpers/esbuild-platform-resolver.js +4 -1
  40. package/helpers/esbuild-platform-resolver.js.map +1 -1
  41. package/helpers/external-configs.d.ts +10 -12
  42. package/helpers/external-configs.js +58 -35
  43. package/helpers/external-configs.js.map +1 -1
  44. package/helpers/flavor.d.ts +13 -0
  45. package/helpers/flavor.js +18 -1
  46. package/helpers/flavor.js.map +1 -1
  47. package/helpers/global-defines.d.ts +99 -33
  48. package/helpers/global-defines.js +187 -66
  49. package/helpers/global-defines.js.map +1 -1
  50. package/helpers/hmr-scope.d.ts +26 -0
  51. package/helpers/hmr-scope.js +67 -0
  52. package/helpers/hmr-scope.js.map +1 -0
  53. package/helpers/init.js +6 -20
  54. package/helpers/init.js.map +1 -1
  55. package/helpers/logging.js +29 -1
  56. package/helpers/logging.js.map +1 -1
  57. package/helpers/main-entry.d.ts +4 -1
  58. package/helpers/main-entry.js +293 -40
  59. package/helpers/main-entry.js.map +1 -1
  60. package/helpers/nativeclass-esbuild-plugin.d.ts +2 -1
  61. package/helpers/nativeclass-esbuild-plugin.js +6 -1
  62. package/helpers/nativeclass-esbuild-plugin.js.map +1 -1
  63. package/helpers/nativeclass-transform.d.ts +13 -0
  64. package/helpers/nativeclass-transform.js +37 -7
  65. package/helpers/nativeclass-transform.js.map +1 -1
  66. package/helpers/nativeclass-transformer-plugin.js +8 -3
  67. package/helpers/nativeclass-transformer-plugin.js.map +1 -1
  68. package/helpers/nativescript-package-resolver.js +10 -62
  69. package/helpers/nativescript-package-resolver.js.map +1 -1
  70. package/helpers/normalize-id.d.ts +42 -0
  71. package/helpers/normalize-id.js +60 -0
  72. package/helpers/normalize-id.js.map +1 -0
  73. package/helpers/ns-core-external-urls.d.ts +32 -0
  74. package/helpers/ns-core-external-urls.js +107 -0
  75. package/helpers/ns-core-external-urls.js.map +1 -0
  76. package/helpers/ns-core-url.d.ts +26 -3
  77. package/helpers/ns-core-url.js +66 -8
  78. package/helpers/ns-core-url.js.map +1 -1
  79. package/helpers/optimize-deps.d.ts +16 -0
  80. package/helpers/optimize-deps.js +17 -0
  81. package/helpers/optimize-deps.js.map +1 -0
  82. package/helpers/package-platform-aliases.js +34 -49
  83. package/helpers/package-platform-aliases.js.map +1 -1
  84. package/helpers/platform-types.d.ts +2 -0
  85. package/helpers/platform-types.js +2 -0
  86. package/helpers/platform-types.js.map +1 -0
  87. package/helpers/postcss-platform-config.d.ts +17 -1
  88. package/helpers/postcss-platform-config.js +20 -37
  89. package/helpers/postcss-platform-config.js.map +1 -1
  90. package/helpers/resolve-main-field-platform.d.ts +20 -0
  91. package/helpers/resolve-main-field-platform.js +49 -0
  92. package/helpers/resolve-main-field-platform.js.map +1 -0
  93. package/helpers/resolver.js +17 -2
  94. package/helpers/resolver.js.map +1 -1
  95. package/helpers/theme-core-plugins.js +1 -1
  96. package/helpers/theme-core-plugins.js.map +1 -1
  97. package/helpers/ts-config-paths.d.ts +32 -0
  98. package/helpers/ts-config-paths.js +143 -62
  99. package/helpers/ts-config-paths.js.map +1 -1
  100. package/helpers/typescript-check.d.ts +2 -1
  101. package/helpers/typescript-check.js +4 -4
  102. package/helpers/typescript-check.js.map +1 -1
  103. package/helpers/ui-registration.d.ts +21 -0
  104. package/helpers/ui-registration.js +156 -0
  105. package/helpers/ui-registration.js.map +1 -0
  106. package/helpers/utils.d.ts +9 -0
  107. package/helpers/utils.js +22 -2
  108. package/helpers/utils.js.map +1 -1
  109. package/helpers/vite-package-version.d.ts +7 -0
  110. package/helpers/vite-package-version.js +44 -0
  111. package/helpers/vite-package-version.js.map +1 -0
  112. package/helpers/workers.d.ts +33 -0
  113. package/helpers/workers.js +237 -10
  114. package/helpers/workers.js.map +1 -1
  115. package/hmr/client/css-handler.d.ts +2 -1
  116. package/hmr/client/css-handler.js +63 -32
  117. package/hmr/client/css-handler.js.map +1 -1
  118. package/hmr/client/css-update-overlay.d.ts +18 -0
  119. package/hmr/client/css-update-overlay.js +27 -0
  120. package/hmr/client/css-update-overlay.js.map +1 -0
  121. package/hmr/client/framework-client-strategy.d.ts +87 -0
  122. package/hmr/client/framework-client-strategy.js +18 -0
  123. package/hmr/client/framework-client-strategy.js.map +1 -0
  124. package/hmr/client/hmr-pending-overlay.d.ts +0 -14
  125. package/hmr/client/hmr-pending-overlay.js +2 -11
  126. package/hmr/client/hmr-pending-overlay.js.map +1 -1
  127. package/hmr/client/hot-context.d.ts +67 -0
  128. package/hmr/client/hot-context.js +307 -0
  129. package/hmr/client/hot-context.js.map +1 -0
  130. package/hmr/client/index.d.ts +9 -1
  131. package/hmr/client/index.js +70 -1970
  132. package/hmr/client/index.js.map +1 -1
  133. package/hmr/client/overlay-driver.d.ts +10 -0
  134. package/hmr/client/overlay-driver.js +33 -0
  135. package/hmr/client/overlay-driver.js.map +1 -0
  136. package/hmr/client/protocol-dispatch.d.ts +8 -0
  137. package/hmr/client/protocol-dispatch.js +308 -0
  138. package/hmr/client/protocol-dispatch.js.map +1 -0
  139. package/hmr/client/root-reset.d.ts +15 -0
  140. package/hmr/client/root-reset.js +358 -0
  141. package/hmr/client/root-reset.js.map +1 -0
  142. package/hmr/client/strategy-loader.d.ts +24 -0
  143. package/hmr/client/strategy-loader.js +100 -0
  144. package/hmr/client/strategy-loader.js.map +1 -0
  145. package/hmr/client/update-pipeline.d.ts +27 -0
  146. package/hmr/client/update-pipeline.js +464 -0
  147. package/hmr/client/update-pipeline.js.map +1 -0
  148. package/hmr/client/utils.d.ts +9 -1
  149. package/hmr/client/utils.js +117 -97
  150. package/hmr/client/utils.js.map +1 -1
  151. package/hmr/client/ws-transport.d.ts +21 -0
  152. package/hmr/client/ws-transport.js +323 -0
  153. package/hmr/client/ws-transport.js.map +1 -0
  154. package/hmr/entry-runtime.d.ts +2 -1
  155. package/hmr/entry-runtime.js +279 -44
  156. package/hmr/entry-runtime.js.map +1 -1
  157. package/hmr/frameworks/angular/build/angular-linker.d.ts +12 -0
  158. package/hmr/frameworks/angular/build/angular-linker.js +113 -0
  159. package/hmr/frameworks/angular/build/angular-linker.js.map +1 -0
  160. package/{helpers/angular → hmr/frameworks/angular/build}/inject-component-hmr-registration.js +2 -70
  161. package/hmr/frameworks/angular/build/inject-component-hmr-registration.js.map +1 -0
  162. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.d.ts +75 -0
  163. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js +221 -0
  164. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js.map +1 -0
  165. package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.js +1 -170
  166. package/hmr/frameworks/angular/build/inline-decorator-component-templates.js.map +1 -0
  167. package/hmr/frameworks/angular/build/js-lexer.d.ts +4 -0
  168. package/{helpers/angular/synthesize-decorator-ctor-parameters.js → hmr/frameworks/angular/build/js-lexer.js} +22 -96
  169. package/hmr/frameworks/angular/build/js-lexer.js.map +1 -0
  170. package/hmr/frameworks/angular/build/linker-stats.d.ts +18 -0
  171. package/hmr/frameworks/angular/build/linker-stats.js +29 -0
  172. package/hmr/frameworks/angular/build/linker-stats.js.map +1 -0
  173. package/hmr/frameworks/angular/build/shared-linker.d.ts +39 -0
  174. package/hmr/frameworks/angular/build/shared-linker.js +128 -0
  175. package/hmr/frameworks/angular/build/shared-linker.js.map +1 -0
  176. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js +88 -0
  177. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js.map +1 -0
  178. package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.js +1 -174
  179. package/hmr/frameworks/angular/build/synthesize-injectable-factories.js.map +1 -0
  180. package/hmr/frameworks/angular/build/ts-fallback-transform.d.ts +5 -0
  181. package/hmr/frameworks/angular/build/ts-fallback-transform.js +138 -0
  182. package/hmr/frameworks/angular/build/ts-fallback-transform.js.map +1 -0
  183. package/hmr/frameworks/angular/build/util.js.map +1 -0
  184. package/hmr/frameworks/angular/build/worker-url-preserve.d.ts +5 -0
  185. package/hmr/frameworks/angular/build/worker-url-preserve.js +140 -0
  186. package/hmr/frameworks/angular/build/worker-url-preserve.js.map +1 -0
  187. package/hmr/frameworks/angular/client/index.d.ts +0 -1
  188. package/hmr/frameworks/angular/client/index.js +360 -194
  189. package/hmr/frameworks/angular/client/index.js.map +1 -1
  190. package/hmr/frameworks/angular/client/strategy.d.ts +9 -0
  191. package/hmr/frameworks/angular/client/strategy.js +19 -0
  192. package/hmr/frameworks/angular/client/strategy.js.map +1 -0
  193. package/hmr/frameworks/angular/server/angular-root-component.d.ts +79 -0
  194. package/hmr/frameworks/angular/server/angular-root-component.js +149 -0
  195. package/hmr/frameworks/angular/server/angular-root-component.js.map +1 -0
  196. package/hmr/frameworks/angular/server/ng-component-route.d.ts +43 -0
  197. package/hmr/frameworks/angular/server/ng-component-route.js +113 -0
  198. package/hmr/frameworks/angular/server/ng-component-route.js.map +1 -0
  199. package/hmr/frameworks/angular/server/strategy.js +668 -13
  200. package/hmr/frameworks/angular/server/strategy.js.map +1 -1
  201. package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.js +2 -2
  202. package/hmr/frameworks/angular/server/websocket-angular-entry.js.map +1 -0
  203. package/hmr/{server → frameworks/angular/server}/websocket-angular-hot-update.d.ts +27 -11
  204. package/hmr/{server → frameworks/angular/server}/websocket-angular-hot-update.js +179 -107
  205. package/hmr/frameworks/angular/server/websocket-angular-hot-update.js.map +1 -0
  206. package/hmr/frameworks/react/client/strategy.d.ts +12 -0
  207. package/hmr/frameworks/react/client/strategy.js +27 -0
  208. package/hmr/frameworks/react/client/strategy.js.map +1 -0
  209. package/hmr/frameworks/react/server/strategy.d.ts +2 -0
  210. package/hmr/frameworks/react/server/strategy.js +230 -0
  211. package/hmr/frameworks/react/server/strategy.js.map +1 -0
  212. package/hmr/frameworks/solid/build/solid-jsx-deps.d.ts +15 -0
  213. package/hmr/frameworks/solid/build/solid-jsx-deps.js +178 -0
  214. package/hmr/frameworks/solid/build/solid-jsx-deps.js.map +1 -0
  215. package/hmr/frameworks/solid/client/app-runtime.d.ts +68 -0
  216. package/hmr/frameworks/solid/client/app-runtime.js +252 -0
  217. package/hmr/frameworks/solid/client/app-runtime.js.map +1 -0
  218. package/hmr/frameworks/solid/client/strategy.d.ts +7 -0
  219. package/hmr/frameworks/solid/client/strategy.js +391 -0
  220. package/hmr/frameworks/solid/client/strategy.js.map +1 -0
  221. package/hmr/frameworks/solid/server/strategy.js +293 -16
  222. package/hmr/frameworks/solid/server/strategy.js.map +1 -1
  223. package/hmr/frameworks/typescript/client/strategy.d.ts +7 -0
  224. package/hmr/frameworks/typescript/client/strategy.js +418 -0
  225. package/hmr/frameworks/typescript/client/strategy.js.map +1 -0
  226. package/hmr/frameworks/typescript/server/strategy.js +40 -14
  227. package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
  228. package/hmr/frameworks/vue/client/dep-propagation.d.ts +44 -0
  229. package/hmr/frameworks/vue/client/dep-propagation.js +148 -0
  230. package/hmr/frameworks/vue/client/dep-propagation.js.map +1 -0
  231. package/hmr/frameworks/vue/client/index.d.ts +10 -1
  232. package/hmr/frameworks/vue/client/index.js +270 -521
  233. package/hmr/frameworks/vue/client/index.js.map +1 -1
  234. package/hmr/frameworks/vue/client/navigate-app.d.ts +3 -0
  235. package/hmr/frameworks/vue/client/navigate-app.js +178 -0
  236. package/hmr/frameworks/vue/client/navigate-app.js.map +1 -0
  237. package/hmr/frameworks/vue/client/strategy.d.ts +33 -0
  238. package/hmr/frameworks/vue/client/strategy.js +152 -0
  239. package/hmr/frameworks/vue/client/strategy.js.map +1 -0
  240. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.d.ts +49 -0
  241. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js +124 -0
  242. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js.map +1 -0
  243. package/hmr/frameworks/vue/server/compiler.d.ts +3 -1
  244. package/hmr/frameworks/vue/server/compiler.js +3 -1
  245. package/hmr/frameworks/vue/server/compiler.js.map +1 -1
  246. package/hmr/frameworks/vue/server/sfc-route-assemble.d.ts +7 -0
  247. package/hmr/frameworks/vue/server/sfc-route-assemble.js +823 -0
  248. package/hmr/frameworks/vue/server/sfc-route-assemble.js.map +1 -0
  249. package/hmr/frameworks/vue/server/sfc-route-meta.d.ts +7 -0
  250. package/hmr/frameworks/vue/server/sfc-route-meta.js +80 -0
  251. package/hmr/frameworks/vue/server/sfc-route-meta.js.map +1 -0
  252. package/hmr/frameworks/vue/server/sfc-route-serve.d.ts +8 -0
  253. package/hmr/frameworks/vue/server/sfc-route-serve.js +462 -0
  254. package/hmr/frameworks/vue/server/sfc-route-serve.js.map +1 -0
  255. package/hmr/frameworks/vue/server/sfc-route-shared.d.ts +45 -0
  256. package/hmr/frameworks/vue/server/sfc-route-shared.js +105 -0
  257. package/hmr/frameworks/vue/server/sfc-route-shared.js.map +1 -0
  258. package/hmr/frameworks/vue/server/strategy.d.ts +35 -0
  259. package/hmr/frameworks/vue/server/strategy.js +291 -7
  260. package/hmr/frameworks/vue/server/strategy.js.map +1 -1
  261. package/hmr/frameworks/vue/server/websocket-sfc.d.ts +15 -0
  262. package/hmr/frameworks/vue/server/websocket-sfc.js +20 -0
  263. package/hmr/frameworks/vue/server/websocket-sfc.js.map +1 -0
  264. package/hmr/helpers/ast-normalizer.d.ts +3 -1
  265. package/hmr/helpers/ast-normalizer.js +109 -14
  266. package/hmr/helpers/ast-normalizer.js.map +1 -1
  267. package/hmr/helpers/package-exports.d.ts +16 -0
  268. package/hmr/helpers/package-exports.js +396 -0
  269. package/hmr/helpers/package-exports.js.map +1 -0
  270. package/hmr/helpers/vendor-rewrite.d.ts +1 -1
  271. package/hmr/helpers/vendor-rewrite.js +5 -3
  272. package/hmr/helpers/vendor-rewrite.js.map +1 -1
  273. package/hmr/server/boot-recording.d.ts +51 -0
  274. package/hmr/server/boot-recording.js +214 -0
  275. package/hmr/server/boot-recording.js.map +1 -0
  276. package/hmr/server/constants.js +7 -1
  277. package/hmr/server/constants.js.map +1 -1
  278. package/hmr/server/content-css-update.d.ts +54 -0
  279. package/hmr/server/content-css-update.js +78 -0
  280. package/hmr/server/content-css-update.js.map +1 -0
  281. package/hmr/server/core-bundle.d.ts +140 -0
  282. package/hmr/server/core-bundle.js +614 -0
  283. package/hmr/server/core-bundle.js.map +1 -0
  284. package/hmr/server/core-sanitize.d.ts +86 -7
  285. package/hmr/server/core-sanitize.js +155 -37
  286. package/hmr/server/core-sanitize.js.map +1 -1
  287. package/hmr/server/css-connect-sync.d.ts +28 -0
  288. package/hmr/server/css-connect-sync.js +59 -0
  289. package/hmr/server/css-connect-sync.js.map +1 -0
  290. package/hmr/server/css-device-module.d.ts +28 -0
  291. package/hmr/server/css-device-module.js +44 -0
  292. package/hmr/server/css-device-module.js.map +1 -0
  293. package/hmr/server/css-update-message.d.ts +23 -0
  294. package/hmr/server/css-update-message.js +41 -0
  295. package/hmr/server/css-update-message.js.map +1 -0
  296. package/hmr/server/deps-bundle.d.ts +233 -0
  297. package/hmr/server/deps-bundle.js +1022 -0
  298. package/hmr/server/deps-bundle.js.map +1 -0
  299. package/hmr/server/device-transform-helpers.d.ts +24 -0
  300. package/hmr/server/device-transform-helpers.js +408 -0
  301. package/hmr/server/device-transform-helpers.js.map +1 -0
  302. package/hmr/server/framework-strategy.d.ts +182 -11
  303. package/hmr/server/hmr-module-graph.d.ts +37 -0
  304. package/hmr/server/hmr-module-graph.js +215 -0
  305. package/hmr/server/hmr-module-graph.js.map +1 -0
  306. package/hmr/server/import-map.d.ts +57 -23
  307. package/hmr/server/import-map.js +142 -70
  308. package/hmr/server/import-map.js.map +1 -1
  309. package/hmr/server/index.js +7 -16
  310. package/hmr/server/index.js.map +1 -1
  311. package/hmr/server/node-builtins-route.d.ts +12 -0
  312. package/hmr/server/node-builtins-route.js +86 -0
  313. package/hmr/server/node-builtins-route.js.map +1 -0
  314. package/hmr/server/ns-m-response-memo.d.ts +10 -0
  315. package/hmr/server/ns-m-response-memo.js +33 -0
  316. package/hmr/server/ns-m-response-memo.js.map +1 -0
  317. package/hmr/server/ns-rt-bridge.d.ts +51 -0
  318. package/hmr/server/ns-rt-bridge.js +131 -0
  319. package/hmr/server/ns-rt-bridge.js.map +1 -0
  320. package/hmr/server/ns-rt-route.d.ts +5 -0
  321. package/hmr/server/ns-rt-route.js +39 -0
  322. package/hmr/server/ns-rt-route.js.map +1 -0
  323. package/hmr/server/perf-instrumentation.d.ts +1 -1
  324. package/hmr/server/perf-instrumentation.js +3 -1
  325. package/hmr/server/perf-instrumentation.js.map +1 -1
  326. package/hmr/server/process-code-for-device.d.ts +44 -0
  327. package/hmr/server/process-code-for-device.js +834 -0
  328. package/hmr/server/process-code-for-device.js.map +1 -0
  329. package/hmr/server/require-guard.d.ts +1 -0
  330. package/hmr/server/require-guard.js +12 -0
  331. package/hmr/server/require-guard.js.map +1 -0
  332. package/hmr/server/rewrite-imports.d.ts +2 -0
  333. package/hmr/server/rewrite-imports.js +631 -0
  334. package/hmr/server/rewrite-imports.js.map +1 -0
  335. package/hmr/server/route-helpers.d.ts +7 -0
  336. package/hmr/server/route-helpers.js +13 -0
  337. package/hmr/server/route-helpers.js.map +1 -0
  338. package/hmr/server/runtime-graph-filter.js +8 -1
  339. package/hmr/server/runtime-graph-filter.js.map +1 -1
  340. package/hmr/server/server-origin.d.ts +2 -0
  341. package/hmr/server/server-origin.js +88 -0
  342. package/hmr/server/server-origin.js.map +1 -0
  343. package/hmr/server/shared-transform-request.js +1 -2
  344. package/hmr/server/shared-transform-request.js.map +1 -1
  345. package/hmr/server/socket-utils.d.ts +10 -0
  346. package/hmr/server/socket-utils.js +14 -0
  347. package/hmr/server/socket-utils.js.map +1 -0
  348. package/hmr/server/transform-cache-invalidation.d.ts +37 -0
  349. package/hmr/server/transform-cache-invalidation.js +156 -0
  350. package/hmr/server/transform-cache-invalidation.js.map +1 -0
  351. package/hmr/server/vendor-bare-module-shims.d.ts +4 -0
  352. package/hmr/server/vendor-bare-module-shims.js +80 -0
  353. package/hmr/server/vendor-bare-module-shims.js.map +1 -0
  354. package/hmr/server/vite-plugin.d.ts +1 -0
  355. package/hmr/server/vite-plugin.js +211 -53
  356. package/hmr/server/vite-plugin.js.map +1 -1
  357. package/hmr/server/websocket-core-bridge.d.ts +51 -4
  358. package/hmr/server/websocket-core-bridge.js +62 -49
  359. package/hmr/server/websocket-core-bridge.js.map +1 -1
  360. package/hmr/server/websocket-device-transform.d.ts +3 -0
  361. package/hmr/server/websocket-device-transform.js +7 -0
  362. package/hmr/server/websocket-device-transform.js.map +1 -0
  363. package/hmr/server/websocket-hmr-pending.d.ts +2 -16
  364. package/hmr/server/websocket-hmr-pending.js +0 -22
  365. package/hmr/server/websocket-hmr-pending.js.map +1 -1
  366. package/hmr/server/websocket-hot-update.d.ts +80 -0
  367. package/hmr/server/websocket-hot-update.js +295 -0
  368. package/hmr/server/websocket-hot-update.js.map +1 -0
  369. package/hmr/server/websocket-import-map-route.d.ts +15 -0
  370. package/hmr/server/websocket-import-map-route.js +51 -0
  371. package/hmr/server/websocket-import-map-route.js.map +1 -0
  372. package/hmr/server/websocket-module-bindings.d.ts +15 -0
  373. package/hmr/server/websocket-module-bindings.js +36 -3
  374. package/hmr/server/websocket-module-bindings.js.map +1 -1
  375. package/hmr/server/websocket-module-specifiers.d.ts +0 -5
  376. package/hmr/server/websocket-module-specifiers.js +29 -30
  377. package/hmr/server/websocket-module-specifiers.js.map +1 -1
  378. package/hmr/server/websocket-ns-core.d.ts +34 -0
  379. package/hmr/server/websocket-ns-core.js +414 -0
  380. package/hmr/server/websocket-ns-core.js.map +1 -0
  381. package/hmr/server/websocket-ns-entry.d.ts +21 -0
  382. package/hmr/server/websocket-ns-entry.js +163 -0
  383. package/hmr/server/websocket-ns-entry.js.map +1 -0
  384. package/hmr/server/websocket-ns-m-paths.d.ts +19 -3
  385. package/hmr/server/websocket-ns-m-paths.js +98 -75
  386. package/hmr/server/websocket-ns-m-paths.js.map +1 -1
  387. package/hmr/server/websocket-ns-m-request.d.ts +2 -1
  388. package/hmr/server/websocket-ns-m-request.js +3 -2
  389. package/hmr/server/websocket-ns-m-request.js.map +1 -1
  390. package/hmr/server/websocket-ns-m.d.ts +52 -0
  391. package/hmr/server/websocket-ns-m.js +590 -0
  392. package/hmr/server/websocket-ns-m.js.map +1 -0
  393. package/hmr/server/websocket-served-module-helpers.d.ts +56 -3
  394. package/hmr/server/websocket-served-module-helpers.js +444 -140
  395. package/hmr/server/websocket-served-module-helpers.js.map +1 -1
  396. package/hmr/server/websocket-txn.js +6 -9
  397. package/hmr/server/websocket-txn.js.map +1 -1
  398. package/hmr/server/websocket-vendor-unifier.d.ts +0 -1
  399. package/hmr/server/websocket-vendor-unifier.js +4 -9
  400. package/hmr/server/websocket-vendor-unifier.js.map +1 -1
  401. package/hmr/server/websocket.d.ts +7 -40
  402. package/hmr/server/websocket.js +661 -6751
  403. package/hmr/server/websocket.js.map +1 -1
  404. package/hmr/shared/ns-globals.d.ts +107 -0
  405. package/hmr/shared/ns-globals.js +29 -0
  406. package/hmr/shared/ns-globals.js.map +1 -0
  407. package/hmr/shared/protocol.d.ts +157 -0
  408. package/hmr/shared/protocol.js +28 -0
  409. package/hmr/shared/protocol.js.map +1 -0
  410. package/hmr/shared/runtime/boot-complete.d.ts +14 -0
  411. package/hmr/shared/runtime/boot-complete.js +32 -0
  412. package/hmr/shared/runtime/boot-complete.js.map +1 -0
  413. package/hmr/shared/runtime/boot-placeholder-ui.d.ts +69 -0
  414. package/hmr/shared/runtime/boot-placeholder-ui.js +101 -0
  415. package/hmr/shared/runtime/boot-placeholder-ui.js.map +1 -0
  416. package/hmr/shared/runtime/boot-progress.d.ts +44 -0
  417. package/hmr/shared/runtime/boot-progress.js +134 -0
  418. package/hmr/shared/runtime/boot-progress.js.map +1 -0
  419. package/hmr/shared/runtime/boot-timeline.d.ts +1 -1
  420. package/hmr/shared/runtime/boot-timeline.js +8 -19
  421. package/hmr/shared/runtime/boot-timeline.js.map +1 -1
  422. package/hmr/shared/runtime/browser-runtime-contract.d.ts +58 -25
  423. package/hmr/shared/runtime/browser-runtime-contract.js +21 -9
  424. package/hmr/shared/runtime/browser-runtime-contract.js.map +1 -1
  425. package/hmr/shared/runtime/dev-overlay-ios.d.ts +87 -0
  426. package/hmr/shared/runtime/dev-overlay-ios.js +521 -0
  427. package/hmr/shared/runtime/dev-overlay-ios.js.map +1 -0
  428. package/hmr/shared/runtime/dev-overlay-shared.d.ts +58 -0
  429. package/hmr/shared/runtime/dev-overlay-shared.js +116 -0
  430. package/hmr/shared/runtime/dev-overlay-shared.js.map +1 -0
  431. package/hmr/shared/runtime/dev-overlay-snapshots.d.ts +31 -0
  432. package/hmr/shared/runtime/dev-overlay-snapshots.js +324 -0
  433. package/hmr/shared/runtime/dev-overlay-snapshots.js.map +1 -0
  434. package/hmr/shared/runtime/dev-overlay-tree.d.ts +59 -0
  435. package/hmr/shared/runtime/dev-overlay-tree.js +712 -0
  436. package/hmr/shared/runtime/dev-overlay-tree.js.map +1 -0
  437. package/hmr/shared/runtime/dev-overlay.d.ts +23 -69
  438. package/hmr/shared/runtime/dev-overlay.js +67 -1011
  439. package/hmr/shared/runtime/dev-overlay.js.map +1 -1
  440. package/hmr/shared/runtime/global-scope.d.ts +18 -0
  441. package/hmr/shared/runtime/global-scope.js +21 -0
  442. package/hmr/shared/runtime/global-scope.js.map +1 -0
  443. package/hmr/shared/runtime/hooks.js +2 -1
  444. package/hmr/shared/runtime/hooks.js.map +1 -1
  445. package/hmr/shared/runtime/launch-bridge.d.ts +9 -0
  446. package/hmr/shared/runtime/launch-bridge.js +98 -0
  447. package/hmr/shared/runtime/launch-bridge.js.map +1 -0
  448. package/hmr/shared/runtime/module-provenance.js +3 -2
  449. package/hmr/shared/runtime/module-provenance.js.map +1 -1
  450. package/hmr/shared/runtime/ns-runtime-test-double.d.ts +21 -0
  451. package/hmr/shared/runtime/ns-runtime-test-double.js +20 -0
  452. package/hmr/shared/runtime/ns-runtime-test-double.js.map +1 -0
  453. package/hmr/shared/runtime/overlay-flag.d.ts +9 -0
  454. package/hmr/shared/runtime/overlay-flag.js +34 -0
  455. package/hmr/shared/runtime/overlay-flag.js.map +1 -0
  456. package/hmr/shared/runtime/root-placeholder-view.d.ts +19 -0
  457. package/hmr/shared/runtime/root-placeholder-view.js +311 -0
  458. package/hmr/shared/runtime/root-placeholder-view.js.map +1 -0
  459. package/hmr/shared/runtime/root-placeholder.js +382 -157
  460. package/hmr/shared/runtime/root-placeholder.js.map +1 -1
  461. package/hmr/shared/runtime/session-bootstrap.js +209 -54
  462. package/hmr/shared/runtime/session-bootstrap.js.map +1 -1
  463. package/hmr/shared/runtime/vendor-bootstrap.js +2 -1
  464. package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
  465. package/hmr/shared/runtime/vendor-resolve.d.ts +22 -0
  466. package/hmr/shared/runtime/vendor-resolve.js +45 -0
  467. package/hmr/shared/runtime/vendor-resolve.js.map +1 -0
  468. package/hmr/shared/runtime/worker-tracking.d.ts +28 -0
  469. package/hmr/shared/runtime/worker-tracking.js +114 -0
  470. package/hmr/shared/runtime/worker-tracking.js.map +1 -0
  471. package/hmr/shared/vendor/manifest-collect.d.ts +4 -0
  472. package/hmr/shared/vendor/manifest-collect.js +909 -0
  473. package/hmr/shared/vendor/manifest-collect.js.map +1 -0
  474. package/hmr/shared/vendor/manifest-loader.d.ts +2 -1
  475. package/hmr/shared/vendor/manifest-loader.js +5 -3
  476. package/hmr/shared/vendor/manifest-loader.js.map +1 -1
  477. package/hmr/shared/vendor/manifest.d.ts +10 -35
  478. package/hmr/shared/vendor/manifest.js +154 -978
  479. package/hmr/shared/vendor/manifest.js.map +1 -1
  480. package/hmr/shared/vendor/registry.d.ts +2 -0
  481. package/hmr/shared/vendor/registry.js +14 -0
  482. package/hmr/shared/vendor/registry.js.map +1 -1
  483. package/hmr/shared/vendor/vendor-device-shim.d.ts +1 -0
  484. package/hmr/shared/vendor/vendor-device-shim.js +208 -0
  485. package/hmr/shared/vendor/vendor-device-shim.js.map +1 -0
  486. package/hmr/shared/vendor/vendor-esbuild-plugins.d.ts +107 -0
  487. package/hmr/shared/vendor/vendor-esbuild-plugins.js +540 -0
  488. package/hmr/shared/vendor/vendor-esbuild-plugins.js.map +1 -0
  489. package/package.json +63 -13
  490. package/runtime/core-aliases-early.js +11 -16
  491. package/runtime/core-aliases-early.js.map +1 -1
  492. package/shims/react-jsx-runtime.d.ts +4 -0
  493. package/shims/react-jsx-runtime.js +61 -0
  494. package/shims/react-jsx-runtime.js.map +1 -0
  495. package/helpers/angular/angular-linker.d.ts +0 -13
  496. package/helpers/angular/angular-linker.js +0 -185
  497. package/helpers/angular/angular-linker.js.map +0 -1
  498. package/helpers/angular/inject-component-hmr-registration.js.map +0 -1
  499. package/helpers/angular/inline-decorator-component-templates.js.map +0 -1
  500. package/helpers/angular/shared-linker.d.ts +0 -11
  501. package/helpers/angular/shared-linker.js +0 -75
  502. package/helpers/angular/shared-linker.js.map +0 -1
  503. package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +0 -1
  504. package/helpers/angular/synthesize-injectable-factories.js.map +0 -1
  505. package/helpers/angular/util.js.map +0 -1
  506. package/helpers/module-runner-patch.d.ts +0 -3
  507. package/helpers/module-runner-patch.js +0 -63
  508. package/helpers/module-runner-patch.js.map +0 -1
  509. package/helpers/prelink-angular.d.ts +0 -2
  510. package/helpers/prelink-angular.js +0 -114
  511. package/helpers/prelink-angular.js.map +0 -1
  512. package/hmr/server/websocket-angular-entry.js.map +0 -1
  513. package/hmr/server/websocket-angular-hot-update.js.map +0 -1
  514. package/hmr/server/websocket-ns-m-finalize.d.ts +0 -22
  515. package/hmr/server/websocket-ns-m-finalize.js +0 -88
  516. package/hmr/server/websocket-ns-m-finalize.js.map +0 -1
  517. package/hmr/server/websocket-runtime-compat.d.ts +0 -19
  518. package/hmr/server/websocket-runtime-compat.js +0 -287
  519. package/hmr/server/websocket-runtime-compat.js.map +0 -1
  520. package/hmr/server/websocket-vue-sfc.d.ts +0 -27
  521. package/hmr/server/websocket-vue-sfc.js +0 -1069
  522. package/hmr/server/websocket-vue-sfc.js.map +0 -1
  523. package/hmr/shared/runtime/http-only-boot.d.ts +0 -2
  524. package/hmr/shared/runtime/http-only-boot.js +0 -171
  525. package/hmr/shared/runtime/http-only-boot.js.map +0 -1
  526. package/hmr/vendor-bootstrap.d.ts +0 -3
  527. package/hmr/vendor-bootstrap.js +0 -32
  528. package/hmr/vendor-bootstrap.js.map +0 -1
  529. package/shims/react-reconciler-constants.d.ts +0 -14
  530. package/shims/react-reconciler-constants.js +0 -21
  531. package/shims/react-reconciler-constants.js.map +0 -1
  532. package/shims/react-reconciler.d.ts +0 -8
  533. package/shims/react-reconciler.js +0 -15
  534. package/shims/react-reconciler.js.map +0 -1
  535. package/transformers/NativeClass/index.d.ts +0 -2
  536. package/transformers/NativeClass/index.js +0 -222
  537. package/transformers/NativeClass/index.js.map +0 -1
  538. /package/{helpers/angular → hmr/frameworks/angular/build}/inject-component-hmr-registration.d.ts +0 -0
  539. /package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.d.ts +0 -0
  540. /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-decorator-ctor-parameters.d.ts +0 -0
  541. /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.d.ts +0 -0
  542. /package/{helpers/angular → hmr/frameworks/angular/build}/util.d.ts +0 -0
  543. /package/{helpers/angular → hmr/frameworks/angular/build}/util.js +0 -0
  544. /package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.d.ts +0 -0
@@ -0,0 +1,631 @@
1
+ // THE SINGLE import-rewrite function — used everywhere for consistency. Maps a
2
+ // served module's specifiers to device-reachable forms: the unified /ns/core
3
+ // bridge, /ns/m node_modules + app modules, /ns/sfc for Vue, vendor bare specs,
4
+ // inlined JSON, and import.meta.url-relative dynamic imports.
5
+ import { existsSync, readFileSync } from 'fs';
6
+ import * as path from 'path';
7
+ import * as PAT from './constants.js';
8
+ import { getMonorepoWorkspaceRoot } from '../../helpers/project.js';
9
+ import { getProjectAppPath } from '../../helpers/utils.js';
10
+ import { buildCoreUrl, buildCoreUrlPath } from '../../helpers/ns-core-url.js';
11
+ import { resolveAngularCoreHmrImportSource, rewriteAngularEntryRegisterOnly } from '../frameworks/angular/server/websocket-angular-entry.js';
12
+ import { isNativeScriptCoreModule, isNativeScriptPluginModule, normalizeNativeScriptCoreSpecifier, normalizeNodeModulesSpecifier, resolveNodeModulesPackageBoundary, resolveVendorRouting, rewriteFsAbsoluteToNsM, shouldPreserveBareRuntimePluginSubpathImport } from './websocket-module-specifiers.js';
13
+ import { ensureDynamicHmrImportHelper } from './websocket-served-module-helpers.js';
14
+ import { collectMixedRuntimePluginHttpRootPackages, findDependencyFileName, getProjectRelativeImportPath, isApplicationImport, normalizeImportPath, stripToProjectRelative, toAppModuleBaseId, toNodeModulesHttpModuleId } from './device-transform-helpers.js';
15
+ const APP_ROOT_DIR = getProjectAppPath();
16
+ export function prepareAngularEntryForDevice(code, importerPath, sfcFileMap, depFileMap, projectRoot, verbose = false, outputDirOverrideRel, httpOrigin, resolveVendorAsHttp = false) {
17
+ const rewrittenCode = rewriteImports(code, importerPath, sfcFileMap, depFileMap, projectRoot, verbose, outputDirOverrideRel, httpOrigin, resolveVendorAsHttp);
18
+ return rewriteAngularEntryRegisterOnly(rewrittenCode, resolveAngularCoreHmrImportSource(rewrittenCode, httpOrigin));
19
+ }
20
+ export function rewriteImports(code, importerPath, sfcFileMap, depFileMap, projectRoot, verbose = false, outputDirOverrideRel, httpOrigin, resolveVendorAsHttp = false) {
21
+ let result = code;
22
+ // Pre-normalize concatenated imports onto their own lines.
23
+ //
24
+ // Babel's `genCode(ast, { retainLines: true })` in
25
+ // `astNormalizeModuleImportsAndHelpers` (which runs before us in the SFC
26
+ // asm pipeline, and in several other hot paths) can emit multiple
27
+ // statements on a single line, e.g.:
28
+ // `} = __ns_rt_ns_1;import { $goTo } from "../utils";import PageWrapper from ...;`
29
+ //
30
+ // IMPORT_PATTERN_1/_2/_3/SIDE_EFFECT all anchor on `(?:^|\n)\s*import`,
31
+ // so any import past the first one on a single line is silently dropped
32
+ // by the rewriter. Downstream that leaves bare relative specifiers like
33
+ // `../utils` to be resolved by the iOS HTTP ESM loader, which interprets
34
+ // them relative to the `/ns/asm/0?path=...` URL and 404s on the
35
+ // resulting `/ns/utils`. Splitting `;import` onto its own line makes the
36
+ // existing patterns match every import, restoring the rewrite contract.
37
+ //
38
+ // Mirrors the same normalization already performed in
39
+ // `core-sanitize.ts::normalizeStrayCoreStringLiterals` (`;\s*import` →
40
+ // `;\nimport`) but applied universally at the rewriter entry point so
41
+ // every caller benefits without having to opt in.
42
+ result = result.replace(/;\s*import\s+/g, ';\nimport ');
43
+ // Same hazard for re-exports: retainLines can glue `;export * from "x"` /
44
+ // `;export { a } from "x"` onto the previous statement, where the
45
+ // `(?:^|\n)`-anchored EXPORT_PATTERN can't see it. A missed re-export keeps
46
+ // Vite's raw `/@fs/<abs>` specifier while sibling imports of the same file
47
+ // get the canonical `/ns/m/...` URL — two URLs for one module splits its
48
+ // identity on device (observed as "conflicting star exports for name ..."
49
+ // from V8 when both instances reach one importer's star exports).
50
+ result = result.replace(/;[ \t]*export(\s+[*{])/g, ';\nexport$1');
51
+ const httpOriginSafe = httpOrigin;
52
+ const mixedRuntimePluginHttpRootPackages = collectMixedRuntimePluginHttpRootPackages(result, projectRoot);
53
+ const isDynamicImportPrefix = (prefix) => /import\(\s*["']?$/.test(prefix.trimStart());
54
+ const importerDir = path.posix.dirname(importerPath);
55
+ // Resolved once per `rewriteImports` call so the per-import `/@fs/` rewriter
56
+ // can convert workspace-lib paths back into our `/ns/m/` pipeline. Memoized
57
+ // upstream — calling here is cheap and we reuse the value below.
58
+ const monorepoWorkspaceRootForRewrite = getMonorepoWorkspaceRoot(projectRoot);
59
+ // Determine importer output relative path (project-relative .mjs) to compute relative imports consistently
60
+ const importerOutRel = outputDirOverrideRel || getProjectRelativeImportPath(importerPath, projectRoot) || stripToProjectRelative(importerPath, projectRoot).replace(/\.(ts|js|tsx|jsx|mjs|mts|cts)$/i, '.mjs');
61
+ const importerOutDir = importerOutRel ? path.posix.dirname(importerOutRel) : '';
62
+ const ensureRel = (p) => (p.startsWith('.') ? p : `./${p}`);
63
+ const isNsSfcSpecifier = (spec) => /^(?:https?:\/\/[^/]+)?\/ns\/sfc(?:\/\d+)?(?:\/|$)/.test(spec.replace(PAT.QUERY_PATTERN, ''));
64
+ // Normalize all @nativescript/core imports to the unified HTTP ESM core bridge to guarantee a single realm on device
65
+ try {
66
+ let coreAliasIdx = 0;
67
+ const mkAlias = () => `__NSC${coreAliasIdx++}`;
68
+ // Use the canonical PATH form `/ns/core/<sub>`. The iOS HTTP ESM
69
+ // loader caches module records by URL string — every emitter
70
+ // (`buildCoreUrl()` / `buildCoreUrlPath()`, the runtime import map,
71
+ // vendor `require()` shims, app-side rewrites, the cold-boot
72
+ // preload in `entry-runtime.ts`) MUST produce the same byte
73
+ // string for the same logical core subpath. A divergence creates
74
+ // two distinct V8 module records for the same source. Each gets
75
+ // its own class
76
+ // identities (TextBase, View, etc.), and side-effect patches
77
+ // applied to one (e.g. @nativescript-community/text's
78
+ // `TextBase.prototype.setTextDecorationAndTransform` override
79
+ // installed when vendor.mjs evaluates `overrideSpanAndFormattedString()`
80
+ // from `@nativescript-community/ui-label/index-common.js`) are
81
+ // invisible to the other — manifesting as inconsistent line-height /
82
+ // letter-spacing rendering between HMR and no-HMR.
83
+ //
84
+ // Mirrors `normalizeCoreSub()` (helpers/ns-core-url.ts) so the URL
85
+ // produced here is byte-identical to what `buildCoreUrl()` produces
86
+ // for the bundle entry, import map, and external-urls plugin.
87
+ // Delegate to the ONE canonical URL builder so every emitter (this
88
+ // rewriter, core-sanitize, the runtime import map, the ns-core-external-urls
89
+ // build plugin, and main-entry) produces byte-identical URLs for
90
+ // the same logical core module. Any drift here would re-introduce
91
+ // the realm-split bug.
92
+ const coreUrl = (sub) => (httpOriginSafe ? buildCoreUrl(httpOriginSafe, sub) : buildCoreUrlPath(sub));
93
+ // Case 1: import { A, B } from '@nativescript/core[/sub]'
94
+ result = result.replace(/(^|\n)\s*import\s*\{\s*([^}]+?)\s*\}\s*from\s+["']@nativescript\/core([^"'\n]*)["'];?/g, (_m, pfx, names, sub) => {
95
+ const alias = mkAlias();
96
+ const url = coreUrl(sub || '');
97
+ const cleaned = names
98
+ .split(',')
99
+ .map((s) => s.trim())
100
+ .filter(Boolean)
101
+ .join(', ');
102
+ return `${pfx}import * as ${alias} from ${JSON.stringify(url)};\nconst { ${cleaned} } = ${alias};`;
103
+ });
104
+ // Case 2: import Default, { A, B } from '@nativescript/core[/sub]'
105
+ result = result.replace(/(^|\n)\s*import\s+([A-Za-z_$][\w$]*)\s*,\s*\{([^}]+?)\s*\}\s*from\s*["']@nativescript\/core([^"'\n]*)["'];?/g, (_m, pfx, defName, names, sub) => {
106
+ const alias = mkAlias();
107
+ const url = coreUrl(sub || '');
108
+ const cleaned = names
109
+ .split(',')
110
+ .map((s) => s.trim())
111
+ .filter(Boolean)
112
+ .join(', ');
113
+ return `${pfx}import * as ${alias} from ${JSON.stringify(url)};\nconst ${defName} = (${alias}.default || ${alias});\nconst { ${cleaned} } = ${alias};`;
114
+ });
115
+ // Case 3: import Default from '@nativescript/core[/sub]'
116
+ result = result.replace(/(^|\n)\s*import\s+([A-Za-z_$][\w$]*)\s+from\s*["']@nativescript\/core([^"'\n]*)["'];?/g, (_m, pfx, defName, sub) => {
117
+ const alias = mkAlias();
118
+ const url = coreUrl(sub || '');
119
+ return `${pfx}import * as ${alias} from ${JSON.stringify(url)};\nconst ${defName} = (${alias}.default || ${alias});`;
120
+ });
121
+ // Case 4: import * as NS from '@nativescript/core[/sub]'
122
+ result = result.replace(/(^|\n)\s*import\s+\*\s+as\s+([A-Za-z_$][\w$]*)\s+from\s*["']@nativescript\/core([^"'\n]*)["'];?/g, (_m, pfx, nsName, sub) => {
123
+ const url = coreUrl(sub || '');
124
+ return `${pfx}import * as ${nsName} from ${JSON.stringify(url)};`;
125
+ });
126
+ // Case 5: side-effect import '@nativescript/core[/sub]'
127
+ result = result.replace(/(^|\n)\s*import\s*["']@nativescript\/core([^"'\n]*)["'];?/g, (_m, pfx, sub) => {
128
+ const url = coreUrl(sub || '');
129
+ return `${pfx}import ${JSON.stringify(url)};`;
130
+ });
131
+ // Case 6: dynamic import('@nativescript/core[/sub]')
132
+ result = result.replace(/import\(\s*["']@nativescript\/core([^"'\n]*)["']\s*\)/g, (_m, sub) => {
133
+ const url = coreUrl(sub || '');
134
+ return `import(${JSON.stringify(url)})`;
135
+ });
136
+ }
137
+ catch { }
138
+ // Inline JSON imports (package.json, config.json, etc.)
139
+ // This must happen BEFORE other rewrites because JSON imports get a ?import query added by Vite
140
+ result = result.replace(/import\s+(\w+)\s+from\s+["']([^"']+\.json(?:\?[^"']*)?)["'];?/g, (match, varName, jsonPath) => {
141
+ try {
142
+ // Remove query params like ?import
143
+ const cleanPath = jsonPath.split('?')[0];
144
+ // Resolve the JSON file path relative to the importer
145
+ let fullPath;
146
+ if (cleanPath.startsWith('/@fs/')) {
147
+ // Vite filesystem URL: `/@fs/<abs-path>`. Strip the `/@fs` prefix
148
+ // (4 chars, leaving the leading `/`) to recover the absolute
149
+ // path. This matches `rewriteFsAbsoluteToNsM`'s convention and
150
+ // covers both bare specifiers Vite pre-resolved out of the
151
+ // project root (e.g. `emojibase-data/en/compact.json` →
152
+ // `/@fs/.../node_modules/.../compact.json`) and tsconfig
153
+ // path-alias targets that resolve outside the project root
154
+ // (e.g. `~shared/...metadata.json` → `/@fs/.../tools/...json`).
155
+ // Without this branch the next `else if` would `path.join` the
156
+ // `/@fs/...` URL onto `projectRoot`, collapsing the leading `/`
157
+ // and producing a malformed nested path that always misses on
158
+ // `existsSync` and triggers a `ReferenceError` at runtime when
159
+ // the JSON-import-failed comment leaves the binding undefined.
160
+ fullPath = cleanPath.slice('/@fs'.length);
161
+ }
162
+ else if (cleanPath.startsWith('/')) {
163
+ // Absolute from project root
164
+ fullPath = path.join(projectRoot, cleanPath);
165
+ }
166
+ else if (cleanPath.startsWith('./') || cleanPath.startsWith('../')) {
167
+ // Relative to importer - resolve from importer's location in project
168
+ const importerFullPath = path.join(projectRoot, importerDir);
169
+ fullPath = path.resolve(importerFullPath, cleanPath);
170
+ }
171
+ else {
172
+ // Skip node_modules JSON imports
173
+ return match;
174
+ }
175
+ if (existsSync(fullPath)) {
176
+ const jsonContent = readFileSync(fullPath, 'utf-8');
177
+ if (verbose) {
178
+ console.log(`[rewrite] JSON inline: ${jsonPath} → const ${varName} = {...}`);
179
+ }
180
+ // Inline the JSON as a const declaration
181
+ return `const ${varName} = ${jsonContent};`;
182
+ }
183
+ else {
184
+ console.warn(`[rewrite] JSON file not found: ${fullPath} (specifier=${jsonPath})`);
185
+ }
186
+ }
187
+ catch (error) {
188
+ console.warn(`[rewrite] Could not inline JSON import: ${jsonPath}`, error);
189
+ }
190
+ // If we can't inline it, remove the import to prevent runtime errors
191
+ // The code will fail with "varName is not defined" which is more debuggable
192
+ return `/* JSON import failed: ${match} */`;
193
+ });
194
+ // Helper to resolve .vue file imports to absolute project paths
195
+ const resolveVueKey = (spec) => {
196
+ if (!spec || typeof spec !== 'string') {
197
+ return null;
198
+ }
199
+ // Only process .vue files
200
+ if (!PAT.VUE_FILE_PATTERN.test(spec)) {
201
+ return null;
202
+ }
203
+ let key;
204
+ if (spec.startsWith('/')) {
205
+ key = spec;
206
+ }
207
+ else if (spec.startsWith('./') || spec.startsWith('../')) {
208
+ key = path.posix.normalize(path.posix.join(importerDir, spec));
209
+ if (!key.startsWith('/'))
210
+ key = '/' + key;
211
+ }
212
+ else {
213
+ return null;
214
+ }
215
+ // Strip query params
216
+ key = key.replace(PAT.QUERY_PATTERN, '');
217
+ return key;
218
+ };
219
+ // Replacement function for all imports
220
+ const replaceVueImport = (_match, prefix, spec, suffix) => {
221
+ // Safety check
222
+ if (!spec || typeof spec !== 'string') {
223
+ return `${prefix}${spec}${suffix}`;
224
+ }
225
+ // Guard 0: leave fully-qualified HTTP(S) URLs alone
226
+ if (/^https?:\/\//.test(spec)) {
227
+ return `${prefix}${spec}${suffix}`;
228
+ }
229
+ // Guard: anomalous bare '@' spec should be rewritten to a safe stub module.
230
+ // This can surface from upstream alias mishaps; mapping it here avoids device-side
231
+ // "instantiate failed @" errors.
232
+ if (spec === '@') {
233
+ const stub = `/ns/m/__invalid_at__.mjs`;
234
+ if (verbose) {
235
+ console.warn(`[rewrite] mapped bare '@' spec to stub: ${stub}`);
236
+ }
237
+ return `${prefix}${stub}${suffix}`;
238
+ }
239
+ spec = normalizeNativeScriptCoreSpecifier(spec);
240
+ // Pull `/@fs/<abs-path>` URLs back into the `/ns/m/` pipeline so they
241
+ // hit our CJS/UMD-wrapping handler. Vite emits `/@fs/...` for any
242
+ // resolved id outside the configured `root` — including hoisted
243
+ // `node_modules/<pkg>` entries and workspace libs in monorepos. Left
244
+ // untouched, the device fetches them through Vite's standard
245
+ // middleware which never invokes `wrapCommonJsModuleForDevice`, so a
246
+ // UMD module like papaparse crashes on `(this).Papa = factory()`
247
+ // because top-level `this` is `undefined` in ESM context.
248
+ if (spec.startsWith('/@fs/')) {
249
+ const rewritten = rewriteFsAbsoluteToNsM(spec, projectRoot, monorepoWorkspaceRootForRewrite);
250
+ if (rewritten) {
251
+ if (httpOriginSafe) {
252
+ return `${prefix}${httpOriginSafe}${rewritten}${suffix}`;
253
+ }
254
+ return `${prefix}${rewritten}${suffix}`;
255
+ }
256
+ // Path resolves outside both roots — leave Vite's URL alone as a
257
+ // last resort. The original behaviour was to fall through here
258
+ // and let downstream branches (e.g. `normalizeNodeModulesSpecifier`)
259
+ // handle paths whose abs form happens to contain `/node_modules/`,
260
+ // so preserve that for the unrewritable case below.
261
+ }
262
+ // Vite 8 oxc runtime helpers (decorators etc.) — emitted as
263
+ // `/@id/__x00__@oxc-project+runtime@<ver>/helpers/<name>.js`. These are
264
+ // real dev-server URLs serving self-contained ESM, so just origin-prefix
265
+ // them for the device; no /ns/m wrapping needed (processCodeForDevice
266
+ // exempts them from the generic /@id/ strip for the same reason).
267
+ if (spec.startsWith('/@id/__x00__@oxc-project+runtime')) {
268
+ if (httpOriginSafe) {
269
+ return `${prefix}${httpOriginSafe}${spec}${suffix}`;
270
+ }
271
+ return `${prefix}${spec}${suffix}`;
272
+ }
273
+ // Route Vite virtual modules (/@solid-refresh, etc.) through /ns/m/ so their
274
+ // internal imports (e.g. solid-js) get vendor-rewritten by our pipeline.
275
+ // Skip known Vite internals (/@vite/, /@id/) which are handled elsewhere.
276
+ // `/@fs/` is intentionally excluded above; if we ever reach here with a
277
+ // `/@fs/` spec it means the rewrite-to-`/ns/m/` pass couldn't anchor it
278
+ // under projectRoot or workspaceRoot, so we fall through and rely on the
279
+ // `normalizeNodeModulesSpecifier` branch below for paths that still
280
+ // contain a `/node_modules/<pkg>/` segment.
281
+ if (spec.startsWith('/@') && !/^\/@(?:vite|id|fs)\//.test(spec)) {
282
+ const out = `/ns/m${spec}`;
283
+ if (httpOriginSafe) {
284
+ return `${prefix}${httpOriginSafe}${out}${suffix}`;
285
+ }
286
+ return `${prefix}${out}${suffix}`;
287
+ }
288
+ // Route internal NS endpoints to absolute HTTP origin for device
289
+ if (spec.startsWith('/ns/')) {
290
+ if (httpOriginSafe) {
291
+ return `${prefix}${httpOriginSafe}${spec}${suffix}`;
292
+ }
293
+ return `${prefix}${spec}${suffix}`;
294
+ }
295
+ if (isNativeScriptCoreModule(spec)) {
296
+ return `${prefix}${spec}${suffix}`;
297
+ }
298
+ const nodeModulesSpecifier = normalizeNodeModulesSpecifier(spec);
299
+ const normalizedRuntimePluginSpec = nodeModulesSpecifier || spec.replace(PAT.QUERY_PATTERN, '').replace(/^\/+/, '');
300
+ if (normalizedRuntimePluginSpec && mixedRuntimePluginHttpRootPackages.size > 0) {
301
+ const { packageName } = resolveNodeModulesPackageBoundary(normalizedRuntimePluginSpec, projectRoot);
302
+ if (packageName && mixedRuntimePluginHttpRootPackages.has(packageName)) {
303
+ const httpNodeModulesSpecifier = nodeModulesSpecifier || normalizedRuntimePluginSpec;
304
+ const httpSpec = `/ns/m/node_modules/${httpNodeModulesSpecifier}`;
305
+ if (httpOriginSafe) {
306
+ return `${prefix}${httpOriginSafe}${httpSpec}${suffix}`;
307
+ }
308
+ return `${prefix}${httpSpec}${suffix}`;
309
+ }
310
+ }
311
+ if (shouldPreserveBareRuntimePluginSubpathImport(spec, projectRoot)) {
312
+ const httpSpec = `/ns/m/node_modules/${spec.replace(PAT.QUERY_PATTERN, '').replace(/^\/+/, '')}`;
313
+ if (httpOriginSafe) {
314
+ return `${prefix}${httpOriginSafe}${httpSpec}${suffix}`;
315
+ }
316
+ return `${prefix}${httpSpec}${suffix}`;
317
+ }
318
+ // ── Node modules routing ──────────────────────────────────────
319
+ // Uses the package's own package.json exports field to determine
320
+ // whether an import is the main entry (→ vendor bridge) or a
321
+ // subpath entry (→ HTTP). This replaces the old heuristic-based
322
+ // approach that tried to guess from file paths.
323
+ if (nodeModulesSpecifier) {
324
+ const vendorRouting = resolveVendorRouting(nodeModulesSpecifier, projectRoot);
325
+ if (vendorRouting) {
326
+ if (vendorRouting.route === 'vendor') {
327
+ return `${prefix}${vendorRouting.bareSpec}${suffix}`;
328
+ }
329
+ // Vendor package but subpath/platform-specific → HTTP
330
+ const httpSpec = `/ns/m/node_modules/${nodeModulesSpecifier}`;
331
+ if (httpOriginSafe) {
332
+ return `${prefix}${httpOriginSafe}${httpSpec}${suffix}`;
333
+ }
334
+ return `${prefix}${httpSpec}${suffix}`;
335
+ }
336
+ // Not a vendor package → serve via HTTP from Vite dev server
337
+ const httpSpec = `/ns/m/node_modules/${nodeModulesSpecifier}`;
338
+ if (httpOriginSafe) {
339
+ return `${prefix}${httpOriginSafe}${httpSpec}${suffix}`;
340
+ }
341
+ return `${prefix}${httpSpec}${suffix}`;
342
+ }
343
+ // Handle .vue imports
344
+ if (PAT.VUE_FILE_PATTERN.test(spec)) {
345
+ // Case A: SFC submodule variant (template/script) must keep its query to avoid self-import cycles.
346
+ const isVueVariant = /\bvue&type=/.test(spec);
347
+ if (isVueVariant) {
348
+ // Preserve the full ?vue&type=... query and route via /ns/sfc so sanitation applies
349
+ const qIdx = spec.indexOf('?');
350
+ const base = qIdx !== -1 ? spec.slice(0, qIdx) : spec;
351
+ const query = qIdx !== -1 ? spec.slice(qIdx) : '';
352
+ // Resolve to absolute project path if relative
353
+ let abs = base;
354
+ if (!abs.startsWith('/')) {
355
+ const joined = path.posix.normalize(path.posix.join(importerDir, abs));
356
+ abs = joined.startsWith('/') ? joined : `/${joined}`;
357
+ }
358
+ const out = `/ns/sfc${abs}${query}`;
359
+ if (verbose) {
360
+ console.log(`[rewrite] .vue variant routed (http): ${spec} → ${out}`);
361
+ }
362
+ return `${prefix}${out}${suffix}`;
363
+ }
364
+ // Case B: plain .vue module → rewrite to SFC endpoint or local artifact
365
+ const vueKey = resolveVueKey(spec.replace(PAT.QUERY_PATTERN, '')) || '';
366
+ if (vueKey) {
367
+ // `.vue` modules are always rewritten to the `/ns/sfc` HTTP endpoint.
368
+ const absVue = vueKey.startsWith('/') ? vueKey : '/' + vueKey;
369
+ const out = `/ns/sfc${absVue}`;
370
+ if (verbose) {
371
+ console.log(`[rewrite] .vue rewrite (http): ${spec} → ${out}`);
372
+ }
373
+ return `${prefix}${out}${suffix}`;
374
+ }
375
+ return `${prefix}${spec}${suffix}`;
376
+ }
377
+ // Rewrite relative application imports to HTTP for served modules
378
+ if (spec.startsWith('./') || spec.startsWith('../')) {
379
+ const absMaybe = normalizeImportPath(spec, importerDir);
380
+ const nodeModulesHttpSpec = absMaybe ? toNodeModulesHttpModuleId(absMaybe) : null;
381
+ if (nodeModulesHttpSpec) {
382
+ if (isDynamicImportPrefix(prefix)) {
383
+ if (verbose)
384
+ console.log(`[rewrite][http] dynamic relative node_modules import → ${nodeModulesHttpSpec} (from ${spec})`);
385
+ return `__nsDynamicHmrImport(${JSON.stringify(nodeModulesHttpSpec)})`;
386
+ }
387
+ if (verbose)
388
+ console.log(`[rewrite][http] relative node_modules import → ${nodeModulesHttpSpec} (from ${spec})`);
389
+ return `${prefix}${nodeModulesHttpSpec}${suffix}`;
390
+ }
391
+ const baseId = absMaybe ? toAppModuleBaseId(absMaybe, projectRoot) : null; // e.g. /src/foo.mjs
392
+ if (baseId) {
393
+ const httpSpec = `/ns/m${baseId}`;
394
+ if (isDynamicImportPrefix(prefix)) {
395
+ if (verbose)
396
+ console.log(`[rewrite][http] dynamic relative app import → ${httpSpec} (from ${spec})`);
397
+ return `__nsDynamicHmrImport(${JSON.stringify(httpSpec)})`;
398
+ }
399
+ if (verbose)
400
+ console.log(`[rewrite][http] relative app import → ${httpSpec} (from ${spec})`);
401
+ return `${prefix}${httpSpec}${suffix}`;
402
+ }
403
+ return `${prefix}${spec}${suffix}`;
404
+ }
405
+ // Note: Do NOT rewrite bare application specifiers (e.g. "core/foo").
406
+ // These will be inlined during bundleDependenciesInline() to avoid static HTTP imports on device.
407
+ if (isApplicationImport(spec)) {
408
+ const baseId = toAppModuleBaseId(spec, projectRoot);
409
+ if (baseId) {
410
+ const httpSpec = `/ns/m${baseId}`;
411
+ if (isDynamicImportPrefix(prefix)) {
412
+ if (verbose)
413
+ console.log(`[rewrite][http] dynamic app import → ${httpSpec} (from ${spec})`);
414
+ return `__nsDynamicHmrImport(${JSON.stringify(httpSpec)})`;
415
+ }
416
+ if (verbose)
417
+ console.log(`[rewrite][http] absolute app import → ${httpSpec} (from ${spec})`);
418
+ return `${prefix}${httpSpec}${suffix}`;
419
+ }
420
+ return `${prefix}${spec}${suffix}`;
421
+ }
422
+ // In HTTP mode, avoid rewriting to dep-*.mjs; let imports resolve via server endpoints
423
+ const depKey = normalizeImportPath(spec, importerDir);
424
+ if (depKey && !httpOriginSafe) {
425
+ if (isNativeScriptCoreModule(depKey)) {
426
+ return `${prefix}${spec}${suffix}`;
427
+ }
428
+ if (isNativeScriptPluginModule(depKey)) {
429
+ return `${prefix}${spec}${suffix}`;
430
+ }
431
+ const depFile = findDependencyFileName(depFileMap, depKey);
432
+ if (depFile) {
433
+ if (verbose) {
434
+ console.log(`[rewrite] dep import: ${spec} → ./${depFile}`);
435
+ }
436
+ return `${prefix}./${depFile}${suffix}`;
437
+ }
438
+ }
439
+ // ── Bare specifier vendor routing ────────────────────────────
440
+ // Bare specifiers like `pinia`, `dayjs`, `lodash` never reach
441
+ // the `nodeModulesSpecifier` branch above because
442
+ // `normalizeNodeModulesSpecifier` keys on a literal
443
+ // `/node_modules/` segment in the path. Preserving the bare
444
+ // spec routes them through the device import map's exact
445
+ // `<pkg>` entry — the canonical `/ns/m/node_modules/<pkg>` URL
446
+ // whose served body is the deps-bundle shim, i.e. the single
447
+ // package instance. Rewriting here would mint a second URL
448
+ // form for the same package. Subpath imports
449
+ // (`pinia/plugins/foo`) intentionally fall through to the
450
+ // HTTP fallback — `resolveVendorRouting` returns
451
+ // `{ route: 'http' }` for non-main-entry subpaths even when the
452
+ // root package is in the manifest, mirroring the
453
+ // `nodeModulesSpecifier` branch.
454
+ if (spec && !spec.startsWith('/') && !spec.startsWith('./') && !spec.startsWith('../') && !/^https?:\/\//i.test(spec) && !spec.startsWith('@nativescript/core')) {
455
+ const bareNpmRe = /^(?:@[A-Za-z0-9][\w.-]*\/)?[A-Za-z0-9][\w.-]*(?:\/[\w.\-/]+)?$/;
456
+ if (bareNpmRe.test(spec)) {
457
+ const bareVendorRouting = resolveVendorRouting(spec, projectRoot);
458
+ if (bareVendorRouting?.route === 'vendor') {
459
+ if (verbose) {
460
+ console.log(`[rewrite] bare vendor import: ${spec} → ${bareVendorRouting.bareSpec}`);
461
+ }
462
+ return `${prefix}${bareVendorRouting.bareSpec}${suffix}`;
463
+ }
464
+ }
465
+ }
466
+ // Bare npm package specifier fallback — route to /ns/m/node_modules/.
467
+ // This catches specifiers like `source-map-js/lib/source-map-generator.js`
468
+ // emitted by helpers such as the CommonJS compat transform, which Vite
469
+ // would normally resolve to an absolute path but which pass through the
470
+ // rewriter as bare strings here. Under HMR (core external) bundle.mjs
471
+ // depends on these resolving over HTTP rather than via a filesystem
472
+ // bare-specifier lookup, which iOS can't satisfy and which crashes with
473
+ // "Module not found".
474
+ if (spec && !spec.startsWith('/') && !spec.startsWith('./') && !spec.startsWith('../') && !/^https?:\/\//i.test(spec) && !spec.startsWith('@nativescript/core')) {
475
+ // Only treat as a package spec if it looks like one — disallow
476
+ // plain identifiers like `moment` unresolved (those are left alone
477
+ // for existing vendor-routing paths to handle).
478
+ const bareNpmRe = /^(?:@[A-Za-z0-9][\w.-]*\/)?[A-Za-z0-9][\w.-]*(?:\/[\w.\-/]+)?$/;
479
+ if (bareNpmRe.test(spec)) {
480
+ // `solid-js` is a hard singleton for the Solid flavor: it is kept
481
+ // OUT of the vendor bundle (manifest-collect.ts) and pinned by the
482
+ // framework strategy's import map to the canonical DEV build URL
483
+ // `/ns/m/node_modules/solid-js/dist/dev.js` (see
484
+ // frameworks/solid/server/strategy.ts → importMapEntries). App code
485
+ // (resolve.alias in configuration/solid.ts) and vendor code
486
+ // (externalized `import 'solid-js'` → import map) both converge on
487
+ // that one URL, so V8 keeps a SINGLE reactive graph.
488
+ //
489
+ // Pre-built packages reached through the Solid JSX-runtime shim
490
+ // (e.g. @tanstack/solid-router's `dist/source/*.jsx`,
491
+ // @nativescript/tanstack-router/solid, and shims/solid-jsx-runtime
492
+ // itself) import the bare root `solid-js`. Without this guard that
493
+ // falls through to the generic `/ns/m/node_modules/solid-js`
494
+ // package-ROOT URL, which is wrong twice over:
495
+ // 1. It is a DIFFERENT URL string than the canonical
496
+ // `…/solid-js/dist/dev.js` every other importer uses. V8 keys
497
+ // ESM module records by URL, so the reactive core evaluates a
498
+ // SECOND time → "You appear to have multiple instances of
499
+ // Solid" + a dead second reactive graph.
500
+ // 2. The package root resolves via solid-js's `module`/`node`
501
+ // export condition to `dist/server.js` (the SSR build), whose
502
+ // `createComponent` is an inert server stub. JSX created
503
+ // through the shim then never mounts → white screen.
504
+ // Pin the exact root to the canonical dev URL so every importer
505
+ // shares one module record. Subpaths (solid-js/web, /store,
506
+ // /universal, /jsx-runtime) keep their own URLs and import the bare
507
+ // root internally, which also lands here. Reached only after the
508
+ // bare-vendor-routing block above, so a non-Solid project that
509
+ // genuinely vendors solid-js is already handled and never gets here.
510
+ const httpSpec = spec === 'solid-js' ? `/ns/m/node_modules/solid-js/dist/dev.js` : `/ns/m/node_modules/${spec}`;
511
+ if (httpOriginSafe) {
512
+ return `${prefix}${httpOriginSafe}${httpSpec}${suffix}`;
513
+ }
514
+ return `${prefix}${httpSpec}${suffix}`;
515
+ }
516
+ }
517
+ // Leave everything else unchanged (vendor imports, etc.)
518
+ return `${prefix}${spec}${suffix}`;
519
+ };
520
+ // Apply to all import/export patterns (but only .vue files will be rewritten)
521
+ result = result.replace(PAT.IMPORT_PATTERN_1, replaceVueImport);
522
+ result = result.replace(PAT.IMPORT_PATTERN_2, replaceVueImport);
523
+ result = result.replace(PAT.EXPORT_PATTERN, replaceVueImport);
524
+ result = result.replace(PAT.IMPORT_PATTERN_3, replaceVueImport);
525
+ // Side-effect imports (import "spec") — must run AFTER named-import patterns
526
+ // since IMPORT_PATTERN_1 already handles `import ... from "spec"`.
527
+ result = result.replace(PAT.IMPORT_PATTERN_SIDE_EFFECT, replaceVueImport);
528
+ result = ensureDynamicHmrImportHelper(result);
529
+ // Extra guard: map any lingering dynamic import('@') to a safe stub module path
530
+ // to prevent device runtime normalization errors.
531
+ // Example matched: import('@') or import("@") with optional whitespace before closing paren
532
+ result = result.replace(/(import\(\s*['"])@(['"]\s*\))/g, (_m) => {
533
+ const stubExpr = `import(new URL('/ns/m/__invalid_at__.mjs', import.meta.url).href)`;
534
+ if (verbose) {
535
+ console.warn(`[rewrite] mapped dynamic import('@') to /ns/m/__invalid_at__.mjs via import.meta.url`);
536
+ }
537
+ return stubExpr;
538
+ });
539
+ // Also guard static spec forms that could erroneously be '@'
540
+ // 1) ESM: import { x } from '@'
541
+ result = result.replace(/(from\s*['"])@(['"])/g, (_m, p1, p2) => {
542
+ const stub = `/ns/m/__invalid_at__.mjs`;
543
+ if (verbose) {
544
+ console.warn(`[rewrite] mapped static from '@' to ${stub}`);
545
+ }
546
+ return `${p1}${stub}${p2}`;
547
+ });
548
+ // 2) ESM side-effect: import '@'
549
+ result = result.replace(/(import\s*(?!\()\s*['"])@(['"])/g, (_m, p1, p2) => {
550
+ const stub = `/ns/m/__invalid_at__.mjs`;
551
+ if (verbose) {
552
+ console.warn(`[rewrite] mapped side-effect import '@' to ${stub}`);
553
+ }
554
+ return `${p1}${stub}${p2}`;
555
+ });
556
+ // Handle .vue imports with queries
557
+ // In HTTP mode, skip legacy local-path rewrite to avoid mixing module origins
558
+ result = result.replace(PAT.VUE_FILE_IMPORT, (_m, p1, spec, p3) => {
559
+ if (httpOrigin) {
560
+ if (isNsSfcSpecifier(spec)) {
561
+ if (verbose)
562
+ console.log(`[rewrite] .vue already routed (VUE_FILE_IMPORT http): ${spec}`);
563
+ return `${p1}${spec}${p3}`;
564
+ }
565
+ // Route via /ns/sfc with full query preserved
566
+ try {
567
+ let base = spec;
568
+ const qIdx = base.indexOf('?');
569
+ const query = qIdx !== -1 ? base.slice(qIdx) : '';
570
+ base = qIdx !== -1 ? base.slice(0, qIdx) : base;
571
+ // Resolve relative to importerDir
572
+ let abs = base;
573
+ if (!abs.startsWith('/')) {
574
+ const joined = path.posix.normalize(path.posix.join(importerDir, abs));
575
+ abs = joined.startsWith('/') ? joined : '/' + joined;
576
+ }
577
+ const out = `/ns/sfc${abs}${query}`;
578
+ if (verbose)
579
+ console.log(`[rewrite] .vue variant routed (VUE_FILE_IMPORT http): ${spec} → ${out}`);
580
+ return `${p1}${out}${p3}`;
581
+ }
582
+ catch { }
583
+ return `${p1}${spec}${p3}`;
584
+ }
585
+ const vueKey = resolveVueKey(spec);
586
+ if (vueKey) {
587
+ const vueFile = sfcFileMap.get(vueKey);
588
+ if (vueFile) {
589
+ const target = `_ns_hmr/${APP_ROOT_DIR}/sfc/${vueFile}`;
590
+ const relPath = importerOutDir ? ensureRel(path.posix.relative(importerOutDir, target)) : ensureRel(target);
591
+ if (verbose) {
592
+ console.log(`[rewrite] .vue rewrite (VUE_FILE_IMPORT): ${spec} → ${relPath}`);
593
+ }
594
+ return `${p1}${relPath}${p3}`;
595
+ }
596
+ else if (verbose) {
597
+ console.log(`[rewrite] .vue NOT in sfcFileMap (VUE_FILE_IMPORT): ${vueKey}`);
598
+ }
599
+ }
600
+ return `${p1}${spec}${p3}`;
601
+ });
602
+ // Final safeguard: normalize any remaining absolute filesystem dynamic imports to HTTP origin spec
603
+ const absoluteDynamicPattern = /(import\(\s*["'])([^"']+)(["']\s*\))/g;
604
+ result = result.replace(absoluteDynamicPattern, (match, _prefix, spec, _suffix) => {
605
+ if (!spec || !spec.startsWith('/'))
606
+ return match;
607
+ // Handle internal NS endpoints
608
+ if (spec.startsWith('/ns/')) {
609
+ const expr = `import(new URL('${spec}', import.meta.url).href)`;
610
+ if (verbose)
611
+ console.log(`[rewrite][http] internal ns import (dynamic) → ${spec} via import.meta.url`);
612
+ return expr;
613
+ }
614
+ const nodeModulesHttpSpec = toNodeModulesHttpModuleId(spec);
615
+ if (nodeModulesHttpSpec) {
616
+ const expr = `import(new URL('${nodeModulesHttpSpec}', import.meta.url).href)`;
617
+ if (verbose)
618
+ console.log(`[rewrite][http] absolute dynamic node_modules import → ${nodeModulesHttpSpec} via import.meta.url (from ${spec})`);
619
+ return expr;
620
+ }
621
+ const baseId = toAppModuleBaseId(spec, projectRoot);
622
+ if (!baseId)
623
+ return match;
624
+ const expr = `import(new URL('/ns/m${baseId}', import.meta.url).href)`;
625
+ if (verbose)
626
+ console.log(`[rewrite][http] absolute dynamic import → /ns/m${baseId} via import.meta.url (from ${spec})`);
627
+ return expr;
628
+ });
629
+ return result;
630
+ }
631
+ //# sourceMappingURL=rewrite-imports.js.map