@nativescript/vite 8.0.0-beta.0 → 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 (577) hide show
  1. package/README.md +73 -14
  2. package/bin/cli.cjs +8 -14
  3. package/configuration/angular.d.ts +35 -2
  4. package/configuration/angular.js +541 -216
  5. package/configuration/angular.js.map +1 -1
  6. package/configuration/base.js +227 -77
  7. package/configuration/base.js.map +1 -1
  8. package/configuration/javascript.js +17 -96
  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 +58 -6
  13. package/configuration/solid.js.map +1 -1
  14. package/configuration/typescript.js +15 -96
  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/commonjs-plugins.d.ts +5 -2
  31. package/helpers/commonjs-plugins.js +126 -0
  32. package/helpers/commonjs-plugins.js.map +1 -1
  33. package/helpers/config-as-json.js +10 -0
  34. package/helpers/config-as-json.js.map +1 -1
  35. package/helpers/css-platform-plugin.d.ts +14 -0
  36. package/helpers/css-platform-plugin.js +43 -25
  37. package/helpers/css-platform-plugin.js.map +1 -1
  38. package/helpers/dev-host.d.ts +360 -0
  39. package/helpers/dev-host.js +694 -0
  40. package/helpers/dev-host.js.map +1 -0
  41. package/helpers/dynamic-import-plugin.d.ts +2 -1
  42. package/helpers/dynamic-import-plugin.js +59 -53
  43. package/helpers/dynamic-import-plugin.js.map +1 -1
  44. package/helpers/esbuild-platform-resolver.js +9 -6
  45. package/helpers/esbuild-platform-resolver.js.map +1 -1
  46. package/helpers/external-configs.d.ts +10 -4
  47. package/helpers/external-configs.js +63 -15
  48. package/helpers/external-configs.js.map +1 -1
  49. package/helpers/flavor.d.ts +13 -0
  50. package/helpers/flavor.js +18 -1
  51. package/helpers/flavor.js.map +1 -1
  52. package/helpers/global-defines.d.ts +117 -0
  53. package/helpers/global-defines.js +209 -11
  54. package/helpers/global-defines.js.map +1 -1
  55. package/helpers/hmr-scope.d.ts +26 -0
  56. package/helpers/hmr-scope.js +67 -0
  57. package/helpers/hmr-scope.js.map +1 -0
  58. package/helpers/import-meta-path.d.ts +4 -0
  59. package/helpers/import-meta-path.js +5 -0
  60. package/helpers/import-meta-path.js.map +1 -0
  61. package/helpers/import-specifier.d.ts +1 -0
  62. package/helpers/import-specifier.js +18 -0
  63. package/helpers/import-specifier.js.map +1 -0
  64. package/helpers/init.js +6 -20
  65. package/helpers/init.js.map +1 -1
  66. package/helpers/logging.d.ts +1 -0
  67. package/helpers/logging.js +65 -4
  68. package/helpers/logging.js.map +1 -1
  69. package/helpers/main-entry.d.ts +8 -2
  70. package/helpers/main-entry.js +622 -120
  71. package/helpers/main-entry.js.map +1 -1
  72. package/helpers/nativeclass-esbuild-plugin.d.ts +2 -1
  73. package/helpers/nativeclass-esbuild-plugin.js +6 -1
  74. package/helpers/nativeclass-esbuild-plugin.js.map +1 -1
  75. package/helpers/nativeclass-transform.d.ts +13 -0
  76. package/helpers/nativeclass-transform.js +42 -131
  77. package/helpers/nativeclass-transform.js.map +1 -1
  78. package/helpers/nativeclass-transformer-plugin.d.ts +19 -1
  79. package/helpers/nativeclass-transformer-plugin.js +324 -37
  80. package/helpers/nativeclass-transformer-plugin.js.map +1 -1
  81. package/helpers/nativescript-package-resolver.js +10 -62
  82. package/helpers/nativescript-package-resolver.js.map +1 -1
  83. package/helpers/normalize-id.d.ts +42 -0
  84. package/helpers/normalize-id.js +60 -0
  85. package/helpers/normalize-id.js.map +1 -0
  86. package/helpers/ns-core-external-urls.d.ts +32 -0
  87. package/helpers/ns-core-external-urls.js +107 -0
  88. package/helpers/ns-core-external-urls.js.map +1 -0
  89. package/helpers/ns-core-url.d.ts +106 -0
  90. package/helpers/ns-core-url.js +225 -0
  91. package/helpers/ns-core-url.js.map +1 -0
  92. package/helpers/optimize-deps.d.ts +16 -0
  93. package/helpers/optimize-deps.js +17 -0
  94. package/helpers/optimize-deps.js.map +1 -0
  95. package/helpers/package-platform-aliases.js +34 -49
  96. package/helpers/package-platform-aliases.js.map +1 -1
  97. package/helpers/platform-types.d.ts +2 -0
  98. package/helpers/platform-types.js +2 -0
  99. package/helpers/platform-types.js.map +1 -0
  100. package/helpers/postcss-platform-config.d.ts +17 -1
  101. package/helpers/postcss-platform-config.js +20 -37
  102. package/helpers/postcss-platform-config.js.map +1 -1
  103. package/helpers/project.d.ts +35 -0
  104. package/helpers/project.js +120 -2
  105. package/helpers/project.js.map +1 -1
  106. package/helpers/resolve-main-field-platform.d.ts +20 -0
  107. package/helpers/resolve-main-field-platform.js +49 -0
  108. package/helpers/resolve-main-field-platform.js.map +1 -0
  109. package/helpers/resolver.js +17 -2
  110. package/helpers/resolver.js.map +1 -1
  111. package/helpers/theme-core-plugins.js +1 -1
  112. package/helpers/theme-core-plugins.js.map +1 -1
  113. package/helpers/ts-config-paths.d.ts +32 -0
  114. package/helpers/ts-config-paths.js +156 -27
  115. package/helpers/ts-config-paths.js.map +1 -1
  116. package/helpers/typescript-check.d.ts +2 -1
  117. package/helpers/typescript-check.js +4 -4
  118. package/helpers/typescript-check.js.map +1 -1
  119. package/helpers/ui-registration.d.ts +21 -0
  120. package/helpers/ui-registration.js +156 -0
  121. package/helpers/ui-registration.js.map +1 -0
  122. package/helpers/utils.d.ts +9 -0
  123. package/helpers/utils.js +22 -2
  124. package/helpers/utils.js.map +1 -1
  125. package/helpers/vite-package-version.d.ts +7 -0
  126. package/helpers/vite-package-version.js +44 -0
  127. package/helpers/vite-package-version.js.map +1 -0
  128. package/helpers/workers.d.ts +40 -19
  129. package/helpers/workers.js +312 -13
  130. package/helpers/workers.js.map +1 -1
  131. package/hmr/client/css-handler.d.ts +2 -1
  132. package/hmr/client/css-handler.js +95 -23
  133. package/hmr/client/css-handler.js.map +1 -1
  134. package/hmr/client/css-update-overlay.d.ts +18 -0
  135. package/hmr/client/css-update-overlay.js +27 -0
  136. package/hmr/client/css-update-overlay.js.map +1 -0
  137. package/hmr/client/framework-client-strategy.d.ts +87 -0
  138. package/hmr/client/framework-client-strategy.js +18 -0
  139. package/hmr/client/framework-client-strategy.js.map +1 -0
  140. package/hmr/client/hmr-pending-overlay.d.ts +13 -0
  141. package/hmr/client/hmr-pending-overlay.js +41 -0
  142. package/hmr/client/hmr-pending-overlay.js.map +1 -0
  143. package/hmr/client/hot-context.d.ts +67 -0
  144. package/hmr/client/hot-context.js +307 -0
  145. package/hmr/client/hot-context.js.map +1 -0
  146. package/hmr/client/index.d.ts +9 -1
  147. package/hmr/client/index.js +91 -1418
  148. package/hmr/client/index.js.map +1 -1
  149. package/hmr/client/overlay-driver.d.ts +10 -0
  150. package/hmr/client/overlay-driver.js +33 -0
  151. package/hmr/client/overlay-driver.js.map +1 -0
  152. package/hmr/client/protocol-dispatch.d.ts +8 -0
  153. package/hmr/client/protocol-dispatch.js +308 -0
  154. package/hmr/client/protocol-dispatch.js.map +1 -0
  155. package/hmr/client/root-reset.d.ts +15 -0
  156. package/hmr/client/root-reset.js +358 -0
  157. package/hmr/client/root-reset.js.map +1 -0
  158. package/hmr/client/strategy-loader.d.ts +24 -0
  159. package/hmr/client/strategy-loader.js +100 -0
  160. package/hmr/client/strategy-loader.js.map +1 -0
  161. package/hmr/client/update-pipeline.d.ts +27 -0
  162. package/hmr/client/update-pipeline.js +464 -0
  163. package/hmr/client/update-pipeline.js.map +1 -0
  164. package/hmr/client/utils.d.ts +14 -1
  165. package/hmr/client/utils.js +265 -54
  166. package/hmr/client/utils.js.map +1 -1
  167. package/hmr/client/ws-transport.d.ts +21 -0
  168. package/hmr/client/ws-transport.js +323 -0
  169. package/hmr/client/ws-transport.js.map +1 -0
  170. package/hmr/entry-runtime.d.ts +11 -0
  171. package/hmr/entry-runtime.js +566 -43
  172. package/hmr/entry-runtime.js.map +1 -1
  173. package/hmr/frameworks/angular/build/angular-linker.d.ts +12 -0
  174. package/hmr/frameworks/angular/build/angular-linker.js +113 -0
  175. package/hmr/frameworks/angular/build/angular-linker.js.map +1 -0
  176. package/hmr/frameworks/angular/build/inject-component-hmr-registration.d.ts +112 -0
  177. package/hmr/frameworks/angular/build/inject-component-hmr-registration.js +291 -0
  178. package/hmr/frameworks/angular/build/inject-component-hmr-registration.js.map +1 -0
  179. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.d.ts +75 -0
  180. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js +221 -0
  181. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js.map +1 -0
  182. package/hmr/frameworks/angular/build/inline-decorator-component-templates.d.ts +3 -0
  183. package/hmr/frameworks/angular/build/inline-decorator-component-templates.js +231 -0
  184. package/hmr/frameworks/angular/build/inline-decorator-component-templates.js.map +1 -0
  185. package/hmr/frameworks/angular/build/js-lexer.d.ts +4 -0
  186. package/hmr/frameworks/angular/build/js-lexer.js +182 -0
  187. package/hmr/frameworks/angular/build/js-lexer.js.map +1 -0
  188. package/hmr/frameworks/angular/build/linker-stats.d.ts +18 -0
  189. package/hmr/frameworks/angular/build/linker-stats.js +29 -0
  190. package/hmr/frameworks/angular/build/linker-stats.js.map +1 -0
  191. package/hmr/frameworks/angular/build/shared-linker.d.ts +39 -0
  192. package/hmr/frameworks/angular/build/shared-linker.js +128 -0
  193. package/hmr/frameworks/angular/build/shared-linker.js.map +1 -0
  194. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.d.ts +1 -0
  195. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js +88 -0
  196. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js.map +1 -0
  197. package/hmr/frameworks/angular/build/synthesize-injectable-factories.d.ts +3 -0
  198. package/hmr/frameworks/angular/build/synthesize-injectable-factories.js +241 -0
  199. package/hmr/frameworks/angular/build/synthesize-injectable-factories.js.map +1 -0
  200. package/hmr/frameworks/angular/build/ts-fallback-transform.d.ts +5 -0
  201. package/hmr/frameworks/angular/build/ts-fallback-transform.js +138 -0
  202. package/hmr/frameworks/angular/build/ts-fallback-transform.js.map +1 -0
  203. package/{helpers/angular → hmr/frameworks/angular/build}/util.d.ts +1 -0
  204. package/hmr/frameworks/angular/build/util.js +155 -0
  205. package/hmr/frameworks/angular/build/util.js.map +1 -0
  206. package/hmr/frameworks/angular/build/worker-url-preserve.d.ts +5 -0
  207. package/hmr/frameworks/angular/build/worker-url-preserve.js +140 -0
  208. package/hmr/frameworks/angular/build/worker-url-preserve.js.map +1 -0
  209. package/hmr/frameworks/angular/client/index.d.ts +2 -1
  210. package/hmr/frameworks/angular/client/index.js +637 -23
  211. package/hmr/frameworks/angular/client/index.js.map +1 -1
  212. package/hmr/frameworks/angular/client/strategy.d.ts +9 -0
  213. package/hmr/frameworks/angular/client/strategy.js +19 -0
  214. package/hmr/frameworks/angular/client/strategy.js.map +1 -0
  215. package/hmr/frameworks/angular/server/angular-root-component.d.ts +79 -0
  216. package/hmr/frameworks/angular/server/angular-root-component.js +149 -0
  217. package/hmr/frameworks/angular/server/angular-root-component.js.map +1 -0
  218. package/hmr/frameworks/angular/server/linker.js +37 -6
  219. package/hmr/frameworks/angular/server/linker.js.map +1 -1
  220. package/hmr/frameworks/angular/server/ng-component-route.d.ts +43 -0
  221. package/hmr/frameworks/angular/server/ng-component-route.js +113 -0
  222. package/hmr/frameworks/angular/server/ng-component-route.js.map +1 -0
  223. package/hmr/frameworks/angular/server/strategy.js +697 -18
  224. package/hmr/frameworks/angular/server/strategy.js.map +1 -1
  225. package/hmr/frameworks/angular/server/websocket-angular-entry.d.ts +2 -0
  226. package/hmr/frameworks/angular/server/websocket-angular-entry.js +68 -0
  227. package/hmr/frameworks/angular/server/websocket-angular-entry.js.map +1 -0
  228. package/hmr/frameworks/angular/server/websocket-angular-hot-update.d.ts +94 -0
  229. package/hmr/frameworks/angular/server/websocket-angular-hot-update.js +485 -0
  230. package/hmr/frameworks/angular/server/websocket-angular-hot-update.js.map +1 -0
  231. package/hmr/frameworks/react/client/strategy.d.ts +12 -0
  232. package/hmr/frameworks/react/client/strategy.js +27 -0
  233. package/hmr/frameworks/react/client/strategy.js.map +1 -0
  234. package/hmr/frameworks/react/server/strategy.d.ts +2 -0
  235. package/hmr/frameworks/react/server/strategy.js +230 -0
  236. package/hmr/frameworks/react/server/strategy.js.map +1 -0
  237. package/hmr/frameworks/solid/build/solid-jsx-deps.d.ts +15 -0
  238. package/hmr/frameworks/solid/build/solid-jsx-deps.js +178 -0
  239. package/hmr/frameworks/solid/build/solid-jsx-deps.js.map +1 -0
  240. package/hmr/frameworks/solid/client/app-runtime.d.ts +68 -0
  241. package/hmr/frameworks/solid/client/app-runtime.js +252 -0
  242. package/hmr/frameworks/solid/client/app-runtime.js.map +1 -0
  243. package/hmr/frameworks/solid/client/strategy.d.ts +7 -0
  244. package/hmr/frameworks/solid/client/strategy.js +391 -0
  245. package/hmr/frameworks/solid/client/strategy.js.map +1 -0
  246. package/hmr/frameworks/solid/server/strategy.js +293 -16
  247. package/hmr/frameworks/solid/server/strategy.js.map +1 -1
  248. package/hmr/frameworks/typescript/client/strategy.d.ts +7 -0
  249. package/hmr/frameworks/typescript/client/strategy.js +418 -0
  250. package/hmr/frameworks/typescript/client/strategy.js.map +1 -0
  251. package/hmr/frameworks/typescript/server/strategy.js +48 -16
  252. package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
  253. package/hmr/frameworks/vue/client/dep-propagation.d.ts +44 -0
  254. package/hmr/frameworks/vue/client/dep-propagation.js +148 -0
  255. package/hmr/frameworks/vue/client/dep-propagation.js.map +1 -0
  256. package/hmr/frameworks/vue/client/index.d.ts +10 -1
  257. package/hmr/frameworks/vue/client/index.js +287 -562
  258. package/hmr/frameworks/vue/client/index.js.map +1 -1
  259. package/hmr/frameworks/vue/client/navigate-app.d.ts +3 -0
  260. package/hmr/frameworks/vue/client/navigate-app.js +178 -0
  261. package/hmr/frameworks/vue/client/navigate-app.js.map +1 -0
  262. package/hmr/frameworks/vue/client/strategy.d.ts +33 -0
  263. package/hmr/frameworks/vue/client/strategy.js +152 -0
  264. package/hmr/frameworks/vue/client/strategy.js.map +1 -0
  265. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.d.ts +49 -0
  266. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js +124 -0
  267. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js.map +1 -0
  268. package/hmr/frameworks/vue/server/compiler.d.ts +3 -1
  269. package/hmr/frameworks/vue/server/compiler.js +3 -1
  270. package/hmr/frameworks/vue/server/compiler.js.map +1 -1
  271. package/hmr/frameworks/vue/server/sfc-route-assemble.d.ts +7 -0
  272. package/hmr/frameworks/vue/server/sfc-route-assemble.js +823 -0
  273. package/hmr/frameworks/vue/server/sfc-route-assemble.js.map +1 -0
  274. package/hmr/frameworks/vue/server/sfc-route-meta.d.ts +7 -0
  275. package/hmr/frameworks/vue/server/sfc-route-meta.js +80 -0
  276. package/hmr/frameworks/vue/server/sfc-route-meta.js.map +1 -0
  277. package/hmr/frameworks/vue/server/sfc-route-serve.d.ts +8 -0
  278. package/hmr/frameworks/vue/server/sfc-route-serve.js +462 -0
  279. package/hmr/frameworks/vue/server/sfc-route-serve.js.map +1 -0
  280. package/hmr/frameworks/vue/server/sfc-route-shared.d.ts +45 -0
  281. package/hmr/frameworks/vue/server/sfc-route-shared.js +105 -0
  282. package/hmr/frameworks/vue/server/sfc-route-shared.js.map +1 -0
  283. package/hmr/frameworks/vue/server/strategy.d.ts +35 -0
  284. package/hmr/frameworks/vue/server/strategy.js +291 -7
  285. package/hmr/frameworks/vue/server/strategy.js.map +1 -1
  286. package/hmr/frameworks/vue/server/websocket-sfc.d.ts +15 -0
  287. package/hmr/frameworks/vue/server/websocket-sfc.js +20 -0
  288. package/hmr/frameworks/vue/server/websocket-sfc.js.map +1 -0
  289. package/hmr/helpers/ast-normalizer.d.ts +3 -1
  290. package/hmr/helpers/ast-normalizer.js +131 -24
  291. package/hmr/helpers/ast-normalizer.js.map +1 -1
  292. package/hmr/helpers/cjs-named-exports.d.ts +23 -0
  293. package/hmr/helpers/cjs-named-exports.js +152 -0
  294. package/hmr/helpers/cjs-named-exports.js.map +1 -0
  295. package/hmr/helpers/package-exports.d.ts +16 -0
  296. package/hmr/helpers/package-exports.js +396 -0
  297. package/hmr/helpers/package-exports.js.map +1 -0
  298. package/hmr/helpers/vendor-rewrite.d.ts +1 -1
  299. package/hmr/helpers/vendor-rewrite.js +5 -3
  300. package/hmr/helpers/vendor-rewrite.js.map +1 -1
  301. package/hmr/server/boot-recording.d.ts +51 -0
  302. package/hmr/server/boot-recording.js +214 -0
  303. package/hmr/server/boot-recording.js.map +1 -0
  304. package/hmr/server/constants.d.ts +1 -0
  305. package/hmr/server/constants.js +21 -4
  306. package/hmr/server/constants.js.map +1 -1
  307. package/hmr/server/content-css-update.d.ts +54 -0
  308. package/hmr/server/content-css-update.js +78 -0
  309. package/hmr/server/content-css-update.js.map +1 -0
  310. package/hmr/server/core-bundle.d.ts +140 -0
  311. package/hmr/server/core-bundle.js +614 -0
  312. package/hmr/server/core-bundle.js.map +1 -0
  313. package/hmr/server/core-sanitize.d.ts +130 -4
  314. package/hmr/server/core-sanitize.js +393 -32
  315. package/hmr/server/core-sanitize.js.map +1 -1
  316. package/hmr/server/css-connect-sync.d.ts +28 -0
  317. package/hmr/server/css-connect-sync.js +59 -0
  318. package/hmr/server/css-connect-sync.js.map +1 -0
  319. package/hmr/server/css-device-module.d.ts +28 -0
  320. package/hmr/server/css-device-module.js +44 -0
  321. package/hmr/server/css-device-module.js.map +1 -0
  322. package/hmr/server/css-update-message.d.ts +23 -0
  323. package/hmr/server/css-update-message.js +41 -0
  324. package/hmr/server/css-update-message.js.map +1 -0
  325. package/hmr/server/deps-bundle.d.ts +233 -0
  326. package/hmr/server/deps-bundle.js +1022 -0
  327. package/hmr/server/deps-bundle.js.map +1 -0
  328. package/hmr/server/device-transform-helpers.d.ts +24 -0
  329. package/hmr/server/device-transform-helpers.js +408 -0
  330. package/hmr/server/device-transform-helpers.js.map +1 -0
  331. package/hmr/server/framework-strategy.d.ts +182 -11
  332. package/hmr/server/hmr-module-graph.d.ts +37 -0
  333. package/hmr/server/hmr-module-graph.js +215 -0
  334. package/hmr/server/hmr-module-graph.js.map +1 -0
  335. package/hmr/server/import-map.d.ts +99 -0
  336. package/hmr/server/import-map.js +294 -0
  337. package/hmr/server/import-map.js.map +1 -0
  338. package/hmr/server/index.d.ts +2 -1
  339. package/hmr/server/index.js +7 -16
  340. package/hmr/server/index.js.map +1 -1
  341. package/hmr/server/node-builtins-route.d.ts +12 -0
  342. package/hmr/server/node-builtins-route.js +86 -0
  343. package/hmr/server/node-builtins-route.js.map +1 -0
  344. package/hmr/server/ns-core-cjs-shape.d.ts +204 -0
  345. package/hmr/server/ns-core-cjs-shape.js +271 -0
  346. package/hmr/server/ns-core-cjs-shape.js.map +1 -0
  347. package/hmr/server/ns-m-response-memo.d.ts +10 -0
  348. package/hmr/server/ns-m-response-memo.js +33 -0
  349. package/hmr/server/ns-m-response-memo.js.map +1 -0
  350. package/hmr/server/ns-rt-bridge.d.ts +51 -0
  351. package/hmr/server/ns-rt-bridge.js +131 -0
  352. package/hmr/server/ns-rt-bridge.js.map +1 -0
  353. package/hmr/server/ns-rt-route.d.ts +5 -0
  354. package/hmr/server/ns-rt-route.js +39 -0
  355. package/hmr/server/ns-rt-route.js.map +1 -0
  356. package/hmr/server/perf-instrumentation.d.ts +114 -0
  357. package/hmr/server/perf-instrumentation.js +197 -0
  358. package/hmr/server/perf-instrumentation.js.map +1 -0
  359. package/hmr/server/process-code-for-device.d.ts +44 -0
  360. package/hmr/server/process-code-for-device.js +834 -0
  361. package/hmr/server/process-code-for-device.js.map +1 -0
  362. package/hmr/server/require-guard.d.ts +1 -0
  363. package/hmr/server/require-guard.js +12 -0
  364. package/hmr/server/require-guard.js.map +1 -0
  365. package/hmr/server/rewrite-imports.d.ts +2 -0
  366. package/hmr/server/rewrite-imports.js +631 -0
  367. package/hmr/server/rewrite-imports.js.map +1 -0
  368. package/hmr/server/route-helpers.d.ts +7 -0
  369. package/hmr/server/route-helpers.js +13 -0
  370. package/hmr/server/route-helpers.js.map +1 -0
  371. package/hmr/server/runtime-graph-filter.d.ts +5 -0
  372. package/hmr/server/runtime-graph-filter.js +28 -0
  373. package/hmr/server/runtime-graph-filter.js.map +1 -0
  374. package/hmr/server/server-origin.d.ts +2 -0
  375. package/hmr/server/server-origin.js +88 -0
  376. package/hmr/server/server-origin.js.map +1 -0
  377. package/hmr/server/shared-transform-request.d.ts +12 -0
  378. package/hmr/server/shared-transform-request.js +143 -0
  379. package/hmr/server/shared-transform-request.js.map +1 -0
  380. package/hmr/server/socket-utils.d.ts +10 -0
  381. package/hmr/server/socket-utils.js +14 -0
  382. package/hmr/server/socket-utils.js.map +1 -0
  383. package/hmr/server/transform-cache-invalidation.d.ts +37 -0
  384. package/hmr/server/transform-cache-invalidation.js +156 -0
  385. package/hmr/server/transform-cache-invalidation.js.map +1 -0
  386. package/hmr/server/vendor-bare-module-shims.d.ts +4 -0
  387. package/hmr/server/vendor-bare-module-shims.js +80 -0
  388. package/hmr/server/vendor-bare-module-shims.js.map +1 -0
  389. package/hmr/server/vite-plugin.d.ts +22 -1
  390. package/hmr/server/vite-plugin.js +655 -58
  391. package/hmr/server/vite-plugin.js.map +1 -1
  392. package/hmr/server/websocket-core-bridge.d.ts +68 -0
  393. package/hmr/server/websocket-core-bridge.js +370 -0
  394. package/hmr/server/websocket-core-bridge.js.map +1 -0
  395. package/hmr/server/websocket-device-transform.d.ts +3 -0
  396. package/hmr/server/websocket-device-transform.js +7 -0
  397. package/hmr/server/websocket-device-transform.js.map +1 -0
  398. package/hmr/server/websocket-graph-upsert.d.ts +21 -0
  399. package/hmr/server/websocket-graph-upsert.js +33 -0
  400. package/hmr/server/websocket-graph-upsert.js.map +1 -0
  401. package/hmr/server/websocket-hmr-pending.d.ts +29 -0
  402. package/hmr/server/websocket-hmr-pending.js +33 -0
  403. package/hmr/server/websocket-hmr-pending.js.map +1 -0
  404. package/hmr/server/websocket-hot-update.d.ts +80 -0
  405. package/hmr/server/websocket-hot-update.js +295 -0
  406. package/hmr/server/websocket-hot-update.js.map +1 -0
  407. package/hmr/server/websocket-import-map-route.d.ts +15 -0
  408. package/hmr/server/websocket-import-map-route.js +51 -0
  409. package/hmr/server/websocket-import-map-route.js.map +1 -0
  410. package/hmr/server/websocket-module-bindings.d.ts +21 -0
  411. package/hmr/server/websocket-module-bindings.js +504 -0
  412. package/hmr/server/websocket-module-bindings.js.map +1 -0
  413. package/hmr/server/websocket-module-specifiers.d.ts +96 -0
  414. package/hmr/server/websocket-module-specifiers.js +819 -0
  415. package/hmr/server/websocket-module-specifiers.js.map +1 -0
  416. package/hmr/server/websocket-ns-core.d.ts +34 -0
  417. package/hmr/server/websocket-ns-core.js +414 -0
  418. package/hmr/server/websocket-ns-core.js.map +1 -0
  419. package/hmr/server/websocket-ns-entry.d.ts +21 -0
  420. package/hmr/server/websocket-ns-entry.js +163 -0
  421. package/hmr/server/websocket-ns-entry.js.map +1 -0
  422. package/hmr/server/websocket-ns-m-paths.d.ts +19 -0
  423. package/hmr/server/websocket-ns-m-paths.js +115 -0
  424. package/hmr/server/websocket-ns-m-paths.js.map +1 -0
  425. package/hmr/server/websocket-ns-m-request.d.ts +46 -0
  426. package/hmr/server/websocket-ns-m-request.js +197 -0
  427. package/hmr/server/websocket-ns-m-request.js.map +1 -0
  428. package/hmr/server/websocket-ns-m.d.ts +52 -0
  429. package/hmr/server/websocket-ns-m.js +590 -0
  430. package/hmr/server/websocket-ns-m.js.map +1 -0
  431. package/hmr/server/websocket-served-module-helpers.d.ts +89 -0
  432. package/hmr/server/websocket-served-module-helpers.js +935 -0
  433. package/hmr/server/websocket-served-module-helpers.js.map +1 -0
  434. package/hmr/server/websocket-txn.d.ts +6 -0
  435. package/hmr/server/websocket-txn.js +42 -0
  436. package/hmr/server/websocket-txn.js.map +1 -0
  437. package/hmr/server/websocket-vendor-unifier.d.ts +9 -0
  438. package/hmr/server/websocket-vendor-unifier.js +46 -0
  439. package/hmr/server/websocket-vendor-unifier.js.map +1 -0
  440. package/hmr/server/websocket.d.ts +7 -17
  441. package/hmr/server/websocket.js +723 -5376
  442. package/hmr/server/websocket.js.map +1 -1
  443. package/hmr/shared/ns-globals.d.ts +107 -0
  444. package/hmr/shared/ns-globals.js +29 -0
  445. package/hmr/shared/ns-globals.js.map +1 -0
  446. package/hmr/shared/package-classifier.d.ts +9 -0
  447. package/hmr/shared/package-classifier.js +58 -0
  448. package/hmr/shared/package-classifier.js.map +1 -0
  449. package/hmr/shared/protocol.d.ts +157 -0
  450. package/hmr/shared/protocol.js +28 -0
  451. package/hmr/shared/protocol.js.map +1 -0
  452. package/hmr/shared/runtime/boot-complete.d.ts +14 -0
  453. package/hmr/shared/runtime/boot-complete.js +32 -0
  454. package/hmr/shared/runtime/boot-complete.js.map +1 -0
  455. package/hmr/shared/runtime/boot-placeholder-ui.d.ts +69 -0
  456. package/hmr/shared/runtime/boot-placeholder-ui.js +101 -0
  457. package/hmr/shared/runtime/boot-placeholder-ui.js.map +1 -0
  458. package/hmr/shared/runtime/boot-progress.d.ts +44 -0
  459. package/hmr/shared/runtime/boot-progress.js +134 -0
  460. package/hmr/shared/runtime/boot-progress.js.map +1 -0
  461. package/hmr/shared/runtime/boot-timeline.d.ts +17 -0
  462. package/hmr/shared/runtime/boot-timeline.js +40 -0
  463. package/hmr/shared/runtime/boot-timeline.js.map +1 -0
  464. package/hmr/shared/runtime/browser-runtime-contract.d.ts +97 -0
  465. package/hmr/shared/runtime/browser-runtime-contract.js +66 -0
  466. package/hmr/shared/runtime/browser-runtime-contract.js.map +1 -0
  467. package/hmr/shared/runtime/dev-overlay-ios.d.ts +87 -0
  468. package/hmr/shared/runtime/dev-overlay-ios.js +521 -0
  469. package/hmr/shared/runtime/dev-overlay-ios.js.map +1 -0
  470. package/hmr/shared/runtime/dev-overlay-shared.d.ts +58 -0
  471. package/hmr/shared/runtime/dev-overlay-shared.js +116 -0
  472. package/hmr/shared/runtime/dev-overlay-shared.js.map +1 -0
  473. package/hmr/shared/runtime/dev-overlay-snapshots.d.ts +31 -0
  474. package/hmr/shared/runtime/dev-overlay-snapshots.js +324 -0
  475. package/hmr/shared/runtime/dev-overlay-snapshots.js.map +1 -0
  476. package/hmr/shared/runtime/dev-overlay-tree.d.ts +59 -0
  477. package/hmr/shared/runtime/dev-overlay-tree.js +712 -0
  478. package/hmr/shared/runtime/dev-overlay-tree.js.map +1 -0
  479. package/hmr/shared/runtime/dev-overlay.d.ts +39 -0
  480. package/hmr/shared/runtime/dev-overlay.js +292 -0
  481. package/hmr/shared/runtime/dev-overlay.js.map +1 -0
  482. package/hmr/shared/runtime/global-scope.d.ts +18 -0
  483. package/hmr/shared/runtime/global-scope.js +21 -0
  484. package/hmr/shared/runtime/global-scope.js.map +1 -0
  485. package/hmr/shared/runtime/hooks.js +2 -1
  486. package/hmr/shared/runtime/hooks.js.map +1 -1
  487. package/hmr/shared/runtime/launch-bridge.d.ts +9 -0
  488. package/hmr/shared/runtime/launch-bridge.js +98 -0
  489. package/hmr/shared/runtime/launch-bridge.js.map +1 -0
  490. package/hmr/shared/runtime/module-provenance.d.ts +1 -0
  491. package/hmr/shared/runtime/module-provenance.js +64 -0
  492. package/hmr/shared/runtime/module-provenance.js.map +1 -0
  493. package/hmr/shared/runtime/ns-runtime-test-double.d.ts +21 -0
  494. package/hmr/shared/runtime/ns-runtime-test-double.js +20 -0
  495. package/hmr/shared/runtime/ns-runtime-test-double.js.map +1 -0
  496. package/hmr/shared/runtime/overlay-flag.d.ts +9 -0
  497. package/hmr/shared/runtime/overlay-flag.js +34 -0
  498. package/hmr/shared/runtime/overlay-flag.js.map +1 -0
  499. package/hmr/shared/runtime/platform-polyfills.d.ts +26 -0
  500. package/hmr/shared/runtime/platform-polyfills.js +122 -0
  501. package/hmr/shared/runtime/platform-polyfills.js.map +1 -0
  502. package/hmr/shared/runtime/root-placeholder-view.d.ts +19 -0
  503. package/hmr/shared/runtime/root-placeholder-view.js +311 -0
  504. package/hmr/shared/runtime/root-placeholder-view.js.map +1 -0
  505. package/hmr/shared/runtime/root-placeholder.d.ts +1 -0
  506. package/hmr/shared/runtime/root-placeholder.js +778 -83
  507. package/hmr/shared/runtime/root-placeholder.js.map +1 -1
  508. package/hmr/shared/runtime/session-bootstrap.d.ts +1 -0
  509. package/hmr/shared/runtime/session-bootstrap.js +350 -0
  510. package/hmr/shared/runtime/session-bootstrap.js.map +1 -0
  511. package/hmr/shared/runtime/vendor-bootstrap.js +54 -16
  512. package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
  513. package/hmr/shared/runtime/vendor-resolve.d.ts +22 -0
  514. package/hmr/shared/runtime/vendor-resolve.js +45 -0
  515. package/hmr/shared/runtime/vendor-resolve.js.map +1 -0
  516. package/hmr/shared/runtime/worker-tracking.d.ts +28 -0
  517. package/hmr/shared/runtime/worker-tracking.js +114 -0
  518. package/hmr/shared/runtime/worker-tracking.js.map +1 -0
  519. package/hmr/shared/vendor/manifest-collect.d.ts +4 -0
  520. package/hmr/shared/vendor/manifest-collect.js +909 -0
  521. package/hmr/shared/vendor/manifest-collect.js.map +1 -0
  522. package/hmr/shared/vendor/manifest-loader.d.ts +2 -1
  523. package/hmr/shared/vendor/manifest-loader.js +5 -3
  524. package/hmr/shared/vendor/manifest-loader.js.map +1 -1
  525. package/hmr/shared/vendor/manifest.d.ts +12 -0
  526. package/hmr/shared/vendor/manifest.js +341 -545
  527. package/hmr/shared/vendor/manifest.js.map +1 -1
  528. package/hmr/shared/vendor/registry.d.ts +2 -0
  529. package/hmr/shared/vendor/registry.js +118 -7
  530. package/hmr/shared/vendor/registry.js.map +1 -1
  531. package/hmr/shared/vendor/vendor-device-shim.d.ts +1 -0
  532. package/hmr/shared/vendor/vendor-device-shim.js +208 -0
  533. package/hmr/shared/vendor/vendor-device-shim.js.map +1 -0
  534. package/hmr/shared/vendor/vendor-esbuild-plugins.d.ts +107 -0
  535. package/hmr/shared/vendor/vendor-esbuild-plugins.js +540 -0
  536. package/hmr/shared/vendor/vendor-esbuild-plugins.js.map +1 -0
  537. package/index.d.ts +1 -0
  538. package/index.js +5 -0
  539. package/index.js.map +1 -1
  540. package/package.json +76 -14
  541. package/runtime/core-aliases-early.js +103 -81
  542. package/runtime/core-aliases-early.js.map +1 -1
  543. package/shims/react-jsx-runtime.d.ts +4 -0
  544. package/shims/react-jsx-runtime.js +61 -0
  545. package/shims/react-jsx-runtime.js.map +1 -0
  546. package/shims/solid-jsx-runtime.d.ts +7 -0
  547. package/shims/solid-jsx-runtime.js +17 -0
  548. package/shims/solid-jsx-runtime.js.map +1 -0
  549. package/helpers/angular/angular-linker.d.ts +0 -13
  550. package/helpers/angular/angular-linker.js +0 -189
  551. package/helpers/angular/angular-linker.js.map +0 -1
  552. package/helpers/angular/shared-linker.d.ts +0 -4
  553. package/helpers/angular/shared-linker.js +0 -39
  554. package/helpers/angular/shared-linker.js.map +0 -1
  555. package/helpers/angular/util.js +0 -67
  556. package/helpers/angular/util.js.map +0 -1
  557. package/helpers/module-runner-patch.d.ts +0 -3
  558. package/helpers/module-runner-patch.js +0 -63
  559. package/helpers/module-runner-patch.js.map +0 -1
  560. package/helpers/prelink-angular.d.ts +0 -2
  561. package/helpers/prelink-angular.js +0 -117
  562. package/helpers/prelink-angular.js.map +0 -1
  563. package/hmr/shared/runtime/http-only-boot.d.ts +0 -1
  564. package/hmr/shared/runtime/http-only-boot.js +0 -124
  565. package/hmr/shared/runtime/http-only-boot.js.map +0 -1
  566. package/hmr/vendor-bootstrap.d.ts +0 -3
  567. package/hmr/vendor-bootstrap.js +0 -32
  568. package/hmr/vendor-bootstrap.js.map +0 -1
  569. package/shims/react-reconciler-constants.d.ts +0 -14
  570. package/shims/react-reconciler-constants.js +0 -21
  571. package/shims/react-reconciler-constants.js.map +0 -1
  572. package/shims/react-reconciler.d.ts +0 -8
  573. package/shims/react-reconciler.js +0 -15
  574. package/shims/react-reconciler.js.map +0 -1
  575. package/transformers/NativeClass/index.d.ts +0 -2
  576. package/transformers/NativeClass/index.js +0 -222
  577. package/transformers/NativeClass/index.js.map +0 -1
@@ -0,0 +1,819 @@
1
+ import { existsSync, readFileSync, realpathSync } from 'fs';
2
+ import * as path from 'path';
3
+ import * as PAT from './constants.js';
4
+ import { getVendorManifest, resolveVendorSpecifier } from '../shared/vendor/registry.js';
5
+ import { getProjectRootPath } from '../../helpers/project.js';
6
+ import { extractRootPackageName, getPackageRuntimeInfo } from '../shared/package-classifier.js';
7
+ const ESM_FRAMEWORK_PACKAGE_ROOTS = new Set(['@nativescript/angular', 'nativescript-angular']);
8
+ const BUILD_TIME_ONLY_PACKAGE_ROOTS = new Set(['@nativescript/vite', '@nativescript/webpack', '@nativescript/android', '@nativescript/ios', '@nativescript/visionos', 'vite', 'webpack', 'esbuild', 'typescript', 'ts-node', 'prettier']);
9
+ const BUILD_TIME_ONLY_PACKAGE_PREFIXES = ['@vitejs/', '@rollup/', '@babel/', '@angular-devkit/', '@angular/build', '@analogjs/', 'vite-plugin-'];
10
+ const EXPLICIT_RUNTIME_PLUGIN_SCRIPT_EXT_RE = /(?:\.(?:ios|android|visionos))?\.(?:ts|tsx|js|jsx|mjs|mts|cts)$/i;
11
+ function hasExplicitRuntimePluginScriptExtension(segment) {
12
+ return EXPLICIT_RUNTIME_PLUGIN_SCRIPT_EXT_RE.test(segment);
13
+ }
14
+ export function extractVitePrebundleId(spec) {
15
+ const m = spec.match(/\.vite\/deps\/([^?]+?)\.[mc]?js/);
16
+ if (m)
17
+ return m[1];
18
+ const m2 = spec.match(/__x00__([^?]+?)\.[mc]?js/);
19
+ if (m2)
20
+ return m2[1];
21
+ return null;
22
+ }
23
+ export function getFlattenedManifestMap(manifest) {
24
+ const map = new Map();
25
+ const mods = Object.keys(manifest.modules || {});
26
+ for (const canonical of mods) {
27
+ const flat = canonical.replace(/\./g, '__').replace(/\//g, '_');
28
+ map.set(flat, canonical);
29
+ const alias = manifest.aliases?.[canonical];
30
+ if (alias) {
31
+ const aliasFlat = String(alias).replace(/\./g, '__').replace(/\//g, '_');
32
+ map.set(aliasFlat, canonical);
33
+ }
34
+ }
35
+ return map;
36
+ }
37
+ export function normalizeNativeScriptCoreSpecifier(spec) {
38
+ let normalized = spec.replace(/@nativescript[_-]core/gi, '@nativescript/core').replace(/@nativescript\/core\/index\.js$/i, '@nativescript/core/index.js');
39
+ if (normalized.startsWith('/node_modules/')) {
40
+ const idx = normalized.toLowerCase().indexOf('@nativescript/core');
41
+ if (idx !== -1) {
42
+ normalized = normalized.slice(idx);
43
+ }
44
+ }
45
+ if (normalized.toLowerCase().startsWith('@nativescript/core')) {
46
+ normalized = normalized.replace(/\?[^"'`]*$/, '');
47
+ }
48
+ return normalized;
49
+ }
50
+ export function normalizeNodeModulesSpecifier(spec) {
51
+ if (!spec) {
52
+ return null;
53
+ }
54
+ const normalized = spec.replace(/\\/g, '/');
55
+ const idx = normalized.lastIndexOf('/node_modules/');
56
+ if (idx === -1) {
57
+ return null;
58
+ }
59
+ let subPath = normalized.slice(idx + '/node_modules/'.length);
60
+ if (!subPath) {
61
+ return null;
62
+ }
63
+ subPath = subPath.replace(PAT.QUERY_PATTERN, '');
64
+ if (!subPath) {
65
+ return null;
66
+ }
67
+ if (subPath.startsWith('.vite/')) {
68
+ return null;
69
+ }
70
+ return subPath.startsWith('/') ? subPath.slice(1) : subPath;
71
+ }
72
+ export function isEsmFrameworkPackageSpecifier(spec) {
73
+ if (!spec)
74
+ return false;
75
+ const cleaned = spec.replace(PAT.QUERY_PATTERN, '');
76
+ const normalized = normalizeNodeModulesSpecifier(cleaned) || cleaned.replace(/^\/+/, '');
77
+ const root = extractRootPackageName(normalized);
78
+ return ESM_FRAMEWORK_PACKAGE_ROOTS.has(root);
79
+ }
80
+ export function isCoreGlobalsReference(spec) {
81
+ return /@nativescript(?:[\/_-])core(?:[\/_-])globals/.test(spec || '');
82
+ }
83
+ export function isNativeScriptCoreModule(spec) {
84
+ return /^(?:@nativescript[\/_-]core|@nativescript\/core)(?:\b|\/)/i.test(spec || '');
85
+ }
86
+ export function isNativeScriptPluginModule(spec) {
87
+ return /^@nativescript\//i.test(spec || '') && !isNativeScriptCoreModule(spec || '');
88
+ }
89
+ function isBuildTimeOnlyPackageRoot(root) {
90
+ if (!root)
91
+ return false;
92
+ if (BUILD_TIME_ONLY_PACKAGE_ROOTS.has(root))
93
+ return true;
94
+ return BUILD_TIME_ONLY_PACKAGE_PREFIXES.some((prefix) => root.startsWith(prefix));
95
+ }
96
+ function isAllowedNativeScriptViteDeviceSubpath(spec) {
97
+ const cleaned = spec.replace(PAT.QUERY_PATTERN, '');
98
+ const normalized = normalizeNodeModulesSpecifier(cleaned) || cleaned.replace(/^\/+/, '');
99
+ const pkgName = extractRootPackageName(normalized) || normalized;
100
+ if (pkgName !== '@nativescript/vite') {
101
+ return true;
102
+ }
103
+ const subpath = normalized.slice(pkgName.length).replace(/^\/+/, '');
104
+ if (!subpath) {
105
+ return false;
106
+ }
107
+ return subpath === 'hmr/entry-runtime.js' || subpath.startsWith('hmr/client/') || /^hmr\/frameworks\/[^/]+\/client\//.test(subpath) || subpath.startsWith('hmr/shared/runtime/') || subpath.startsWith('shims/') || subpath === 'runtime/core-aliases-early.js' || subpath === 'polyfills/module.js';
108
+ }
109
+ export function getBlockedDeviceNodeModulesReason(spec) {
110
+ if (!spec)
111
+ return null;
112
+ const cleaned = spec.replace(PAT.QUERY_PATTERN, '');
113
+ const normalized = normalizeNodeModulesSpecifier(cleaned) || cleaned.replace(/^\/+/, '');
114
+ const pkgName = extractRootPackageName(normalized) || normalized;
115
+ if (!pkgName) {
116
+ return null;
117
+ }
118
+ if (pkgName === '@nativescript/vite') {
119
+ if (isAllowedNativeScriptViteDeviceSubpath(normalized)) {
120
+ return null;
121
+ }
122
+ const subpath = normalized.slice(pkgName.length).replace(/^\/+/, '');
123
+ return subpath ? `build-time NativeScript Vite module is not device-loadable: ${pkgName}/${subpath}` : 'build-time NativeScript Vite package root is not device-loadable';
124
+ }
125
+ if (isBuildTimeOnlyPackageRoot(pkgName)) {
126
+ return `build-time package is not device-loadable: ${pkgName}`;
127
+ }
128
+ return null;
129
+ }
130
+ export function isLikelyNativeScriptRuntimePluginSpecifier(spec, projectRoot = getProjectRootPath()) {
131
+ if (!spec)
132
+ return false;
133
+ const s = spec.replace(PAT.QUERY_PATTERN, '');
134
+ if (/^(?:\.|\/|https?:\/\/)/i.test(s))
135
+ return false;
136
+ if (s.startsWith('@@/'))
137
+ return false;
138
+ if (s.startsWith('~/'))
139
+ return false;
140
+ if (s.startsWith('@/'))
141
+ return false;
142
+ if (/\.vue(?:\?|$)/i.test(s))
143
+ return false;
144
+ const root = extractRootPackageName(s) || s;
145
+ if (!root)
146
+ return false;
147
+ if (isNativeScriptCoreModule(root))
148
+ return false;
149
+ if (ESM_FRAMEWORK_PACKAGE_ROOTS.has(root))
150
+ return false;
151
+ if (/^(?:vue|nativescript-vue)(?:\b|\/)/i.test(root))
152
+ return false;
153
+ if (isBuildTimeOnlyPackageRoot(root))
154
+ return false;
155
+ if (getPackageRuntimeInfo(root, projectRoot).hasNativeScriptMetadata)
156
+ return true;
157
+ if (/^@nativescript\//i.test(root))
158
+ return true;
159
+ if (/^(?:@nativescript-community|@nstudio|@mleleux)\//i.test(root))
160
+ return true;
161
+ return /(?:^|\/)nativescript(?:$|[-_])/i.test(root);
162
+ }
163
+ export function isLikelyNativeScriptPluginSpecifier(spec, projectRoot = getProjectRootPath()) {
164
+ if (!spec)
165
+ return false;
166
+ const s = spec.replace(PAT.QUERY_PATTERN, '');
167
+ if (/^(?:\.|\/|https?:\/\/)/i.test(s))
168
+ return false;
169
+ if (s.startsWith('@@/'))
170
+ return false;
171
+ if (s.startsWith('~/'))
172
+ return false;
173
+ if (s.startsWith('@/'))
174
+ return false;
175
+ if (/\.vue(?:\?|$)/i.test(s))
176
+ return false;
177
+ if (/^@nativescript\/core(\b|\/)/i.test(s))
178
+ return false;
179
+ if (isEsmFrameworkPackageSpecifier(s))
180
+ return false;
181
+ if (/^(?:vue|nativescript-vue)(?:\b|\/)/i.test(s))
182
+ return false;
183
+ const root = extractRootPackageName(s) || s;
184
+ if (isBuildTimeOnlyPackageRoot(root))
185
+ return false;
186
+ if (getPackageRuntimeInfo(root, projectRoot).hasNativeScriptMetadata)
187
+ return true;
188
+ return true;
189
+ }
190
+ export function tryReadRawExplicitJavaScriptModule(spec, projectRoot) {
191
+ if (!spec || !spec.startsWith('/'))
192
+ return null;
193
+ if (spec.startsWith('/@id/') || spec.startsWith('/@fs/'))
194
+ return null;
195
+ if (!/\.js$/i.test(spec) || /\.(?:mjs|cjs)$/i.test(spec))
196
+ return null;
197
+ try {
198
+ const nodeModulesSpecifier = normalizeNodeModulesSpecifier(spec);
199
+ if (nodeModulesSpecifier) {
200
+ const pkgName = extractRootPackageName(nodeModulesSpecifier);
201
+ if (isLikelyNativeScriptRuntimePluginSpecifier(pkgName, projectRoot)) {
202
+ return null;
203
+ }
204
+ }
205
+ }
206
+ catch { }
207
+ // source-map-js ships as CJS with relative require() calls that need
208
+ // ESM conversion via sourceMapJsCompatPlugin. Force Vite transforms.
209
+ if (/\/node_modules\/source-map-js\//.test(spec))
210
+ return null;
211
+ const root = path.resolve(projectRoot);
212
+ const absPath = path.resolve(root, `.${spec}`);
213
+ if (!absPath.startsWith(root + path.sep) && absPath !== root)
214
+ return null;
215
+ try {
216
+ const code = existsSync(absPath) ? readFileSync(absPath, 'utf-8') : null;
217
+ if (code != null) {
218
+ const usesNodeModuleInterop = /(?:from\s*['"](?:node:)?module['"]|import\s*\{[^}]*\bcreateRequire\b[^}]*\}\s*from\s*['"](?:node:)?module['"]|\bcreateRequire\s*\()/m.test(code);
219
+ if (usesNodeModuleInterop) {
220
+ return null;
221
+ }
222
+ // For node_modules files that use CJS require() with relative
223
+ // specifiers, defer to Vite transforms so the ESM conversion
224
+ // plugins (e.g. sourceMapJsCompatPlugin) can run. Raw reads
225
+ // leave `require('./x')` intact, which then hits NS's native
226
+ // file-based require and fails on HTTP URLs.
227
+ if (/\/node_modules\//.test(spec) && /\brequire\s*\(\s*['"]\.{1,2}\//.test(code)) {
228
+ return null;
229
+ }
230
+ return { code, resolvedId: spec };
231
+ }
232
+ }
233
+ catch { }
234
+ return null;
235
+ }
236
+ export function resolveVendorFromCandidate(specifier) {
237
+ if (!specifier) {
238
+ return null;
239
+ }
240
+ const manifest = getVendorManifest();
241
+ if (!manifest) {
242
+ return null;
243
+ }
244
+ const cleaned = specifier.replace(PAT.QUERY_PATTERN, '');
245
+ const direct = resolveVendorSpecifier(cleaned);
246
+ if (direct) {
247
+ return direct;
248
+ }
249
+ const flattenedId = extractVitePrebundleId(cleaned);
250
+ if (flattenedId) {
251
+ const flattenedMap = getFlattenedManifestMap(manifest);
252
+ const flatMatch = flattenedMap.get(flattenedId);
253
+ if (flatMatch) {
254
+ return flatMatch;
255
+ }
256
+ for (const [flatKey, canonical] of flattenedMap.entries()) {
257
+ if (flattenedId === flatKey) {
258
+ return canonical;
259
+ }
260
+ if (flattenedId.startsWith(`${flatKey}_`)) {
261
+ const flatSuffix = flattenedId.slice(flatKey.length + 1);
262
+ const subpath = flatSuffix.replace(/_/g, '/');
263
+ if (isFileDistSubpath(subpath)) {
264
+ return canonical;
265
+ }
266
+ const aliasKey = `${canonical}/${subpath.split('/')[0]}`;
267
+ if (manifest.aliases?.[aliasKey] && manifest.modules[manifest.aliases[aliasKey]]) {
268
+ return manifest.aliases[aliasKey];
269
+ }
270
+ }
271
+ }
272
+ const guessedId = flattenedId.replace(/__/g, '.').replace(/_/g, '/');
273
+ if (guessedId && guessedId !== flattenedId) {
274
+ const guessedCanonical = resolveVendorSpecifier(guessedId);
275
+ if (guessedCanonical) {
276
+ return guessedCanonical;
277
+ }
278
+ const prefix = findVendorPrefix(guessedId, manifest);
279
+ if (prefix) {
280
+ return prefix;
281
+ }
282
+ }
283
+ }
284
+ const normalizedCore = normalizeNativeScriptCoreSpecifier(cleaned);
285
+ if (normalizedCore !== cleaned) {
286
+ const nsCanonical = resolveVendorSpecifier(normalizedCore);
287
+ if (nsCanonical) {
288
+ return nsCanonical;
289
+ }
290
+ }
291
+ const nodeModulesSpecifier = normalizeNodeModulesSpecifier(cleaned);
292
+ if (nodeModulesSpecifier) {
293
+ const canonical = resolveVendorSpecifier(nodeModulesSpecifier);
294
+ if (canonical) {
295
+ return canonical;
296
+ }
297
+ const prefix = findVendorPrefix(nodeModulesSpecifier, manifest);
298
+ if (prefix) {
299
+ return prefix;
300
+ }
301
+ }
302
+ const prefix = findVendorPrefix(cleaned, manifest);
303
+ if (prefix) {
304
+ return prefix;
305
+ }
306
+ return null;
307
+ }
308
+ /**
309
+ * Resolve a candidate URL ('/node_modules/...', '/@fs/...', or an
310
+ * absolute fs path) to a real file on disk under one of the allowed
311
+ * roots, returning the absolute fs path or `null`.
312
+ *
313
+ * `workspaceRoot` is consulted ONLY when the candidate cannot be
314
+ * resolved under `projectRoot` — this keeps the existing app-local
315
+ * behaviour identical and adds a fallback for monorepos where
316
+ * `node_modules/` is hoisted above the app dir (Nx, Rush, Turborepo,
317
+ * etc.). Without this fallback, every `/ns/m/node_modules/<hoisted-pkg>`
318
+ * request to the dev server's bridge fails with a "transform miss"
319
+ * 404 even though the file is right there at the workspace root.
320
+ */
321
+ export function resolveCandidateFilePath(candidate, projectRoot, workspaceRoot) {
322
+ const cleaned = candidate.replace(PAT.QUERY_PATTERN, '');
323
+ if (!cleaned)
324
+ return null;
325
+ const tryUnderRoot = (root) => {
326
+ const resolvedRoot = path.resolve(root);
327
+ let absPath = null;
328
+ if (cleaned.startsWith('/@fs/')) {
329
+ absPath = cleaned.slice('/@fs'.length);
330
+ }
331
+ else if (cleaned.includes('/node_modules/')) {
332
+ absPath = path.resolve(resolvedRoot, `.${cleaned}`);
333
+ }
334
+ else if (/^(?:[A-Za-z]:)?\//.test(cleaned)) {
335
+ absPath = path.resolve(cleaned);
336
+ }
337
+ if (!absPath) {
338
+ return null;
339
+ }
340
+ const rel = path.relative(resolvedRoot, absPath);
341
+ if (!rel || rel.startsWith('..') || path.isAbsolute(rel)) {
342
+ return null;
343
+ }
344
+ return existsSync(absPath) ? absPath : null;
345
+ };
346
+ const fromProjectRoot = tryUnderRoot(projectRoot);
347
+ if (fromProjectRoot)
348
+ return fromProjectRoot;
349
+ if (workspaceRoot) {
350
+ const resolvedProject = path.resolve(projectRoot);
351
+ const resolvedWorkspace = path.resolve(workspaceRoot);
352
+ if (resolvedWorkspace !== resolvedProject) {
353
+ return tryUnderRoot(resolvedWorkspace);
354
+ }
355
+ }
356
+ return null;
357
+ }
358
+ /**
359
+ * Rewrite a `/@fs/<abs-path>` URL into a `/ns/m/<rel>` URL so the chain
360
+ * stays inside our HMR pipeline.
361
+ *
362
+ * Vite's transform output emits `/@fs/<abs-path>` for any module whose
363
+ * resolved id lives outside the configured `root` — including hoisted
364
+ * `node_modules/<pkg>/...` entries and workspace libraries in monorepos
365
+ * (Nx, Rush, Turborepo, pnpm/yarn/npm workspaces, etc.). If we leave
366
+ * those URLs untouched, the device fetches them through Vite's standard
367
+ * middleware which does NOT apply our CJS/UMD-wrapping pipeline; UMD
368
+ * modules like papaparse then crash because top-level `this` is
369
+ * `undefined` in ESM context (the `(function(root, factory) { ... })(this,
370
+ * function moduleFactory() { ... })` IIFE passes `undefined` as `root`
371
+ * and the third branch tries to do `undefined.Papa = factory()`).
372
+ *
373
+ * The conversion preserves any `?...` / `#...` suffix and tries roots in
374
+ * this order:
375
+ * 1. `projectRoot` — app-local files; mirrors the URL shape we already
376
+ * emit for relative imports under the app's own dir.
377
+ * 2. `workspaceRoot` — hoisted `node_modules` and monorepo workspace
378
+ * libs. The `/ns/m/` handler resolves these via its
379
+ * `buildFsCandidate` fallback that probes both roots.
380
+ *
381
+ * Returns `null` when the absolute path is outside both roots; the
382
+ * caller should then leave the original `/@fs/` URL alone (defensive).
383
+ */
384
+ export function rewriteFsAbsoluteToNsM(spec, projectRoot, workspaceRoot) {
385
+ if (!spec || !spec.startsWith('/@fs/'))
386
+ return null;
387
+ const queryStart = spec.search(/[?#]/);
388
+ const cleanSpec = queryStart !== -1 ? spec.slice(0, queryStart) : spec;
389
+ const querySuffix = queryStart !== -1 ? spec.slice(queryStart) : '';
390
+ // /@fs/<abs-path> — strip the prefix to recover the absolute path.
391
+ // On posix this is "/Users/...". On Windows Vite emits "/@fs/C:/..."
392
+ // where the path retains its drive letter.
393
+ const absPath = cleanSpec.slice('/@fs'.length);
394
+ if (!absPath.startsWith('/'))
395
+ return null;
396
+ const toPosix = (value) => value.replace(/\\/g, '/');
397
+ const stripTrailing = (value) => value.replace(/\/+$/, '');
398
+ const projectRootPosix = stripTrailing(toPosix(path.resolve(projectRoot)));
399
+ const workspaceRootPosix = workspaceRoot ? stripTrailing(toPosix(path.resolve(workspaceRoot))) : null;
400
+ const tryRoot = (root) => {
401
+ if (!root)
402
+ return null;
403
+ if (absPath === root)
404
+ return '';
405
+ if (absPath.startsWith(`${root}/`)) {
406
+ return absPath.slice(root.length + 1);
407
+ }
408
+ return null;
409
+ };
410
+ // App-local first so URLs match the existing `/ns/m/<projectRel>` shape.
411
+ let rel = tryRoot(projectRootPosix);
412
+ if (rel === null && workspaceRootPosix && workspaceRootPosix !== projectRootPosix) {
413
+ rel = tryRoot(workspaceRootPosix);
414
+ }
415
+ if (rel === null)
416
+ return null;
417
+ return rel === '' ? `/ns/m${querySuffix}` : `/ns/m/${rel}${querySuffix}`;
418
+ }
419
+ /**
420
+ * Filter `candidates` (variations of `spec` with different extensions /
421
+ * `index.*`) down to those that exist on disk under `projectRoot` or
422
+ * `workspaceRoot`. Workspace-root-only matches are rewritten to their
423
+ * `/@fs/<abs-path>` form so the downstream `transformRequest` call can
424
+ * load them directly without having to go through Vite's bare-specifier
425
+ * resolver — which is gated by the package's `package.json#exports`
426
+ * field and refuses internal sub-paths even when the file is on disk
427
+ * (e.g. `css-tree/lib/syntax/index.js`).
428
+ *
429
+ * Candidates whose real path (after symlink resolution) lives OUTSIDE
430
+ * any `node_modules` directory are also rewritten to `/@fs/<real-path>`.
431
+ * Vite's built-in esbuild transform plugin excludes `node_modules` paths
432
+ * from TS->JS conversion, so a workspace TypeScript package re-exposed
433
+ * via `node_modules/<scope>/<pkg>` (a common monorepo pattern: e.g.
434
+ * `node_modules/@blackout/plugins -> ../../plugins/src`) would otherwise
435
+ * be served as raw TypeScript and fail at the device with `Missing
436
+ * initializer in const declaration` on type annotations like
437
+ * `export const X: string = '...'`. Routing through the realpath makes
438
+ * Vite see a non-`node_modules` path and the TS transform applies.
439
+ *
440
+ * App-local candidates whose real path is also app-local are returned
441
+ * unchanged so existing behaviour is preserved bit-for-bit.
442
+ */
443
+ export function filterExistingNodeModulesTransformCandidates(spec, candidates, projectRoot, workspaceRoot) {
444
+ const cleanedSpec = spec.replace(PAT.QUERY_PATTERN, '');
445
+ if (!cleanedSpec.includes('/node_modules/')) {
446
+ return candidates;
447
+ }
448
+ const resolvedProjectRoot = path.resolve(projectRoot);
449
+ const resolvedWorkspaceRoot = workspaceRoot ? path.resolve(workspaceRoot) : null;
450
+ const hasDistinctWorkspaceRoot = !!resolvedWorkspaceRoot && resolvedWorkspaceRoot !== resolvedProjectRoot;
451
+ // The bridge's caller composes `candidates` from both the explicit
452
+ // spec and a fan-out of extension/index variants, which routinely
453
+ // produces the same URL twice (e.g. `/foo/index.js` is both the
454
+ // explicit spec and a `${baseNoExt}.js` variant). Dedup so we don't
455
+ // invoke `transformRequest()` twice for the same path.
456
+ const seen = new Set();
457
+ const result = [];
458
+ for (const candidate of candidates) {
459
+ const resolved = resolveCandidateFilePath(candidate, resolvedProjectRoot, hasDistinctWorkspaceRoot ? resolvedWorkspaceRoot : null);
460
+ if (!resolved)
461
+ continue;
462
+ const cleanedCandidate = candidate.replace(PAT.QUERY_PATTERN, '');
463
+ const querySuffix = candidate.length > cleanedCandidate.length ? candidate.slice(cleanedCandidate.length) : '';
464
+ // Detect "node_modules entry that symlinks to non-node_modules
465
+ // source". This is the canonical NativeScript monorepo pattern for
466
+ // workspace packages re-exposed under `node_modules/<scope>/<pkg>`
467
+ // so the runtime resolver finds them via standard Node resolution.
468
+ // Without this rewrite Vite serves the raw `.ts` source and the
469
+ // device chokes on type annotations.
470
+ let mapped = null;
471
+ try {
472
+ const realResolved = realpathSync(resolved);
473
+ if (realResolved !== resolved) {
474
+ const realIsInsideNodeModules = realResolved.split(path.sep).includes('node_modules');
475
+ if (!realIsInsideNodeModules) {
476
+ mapped = `/@fs${realResolved.replace(/\\/g, '/')}${querySuffix}`;
477
+ }
478
+ }
479
+ }
480
+ catch {
481
+ // realpath may fail on broken or circular symlinks. Fall
482
+ // through to the existing project/workspace logic.
483
+ }
484
+ if (mapped === null) {
485
+ if (!hasDistinctWorkspaceRoot) {
486
+ mapped = candidate;
487
+ }
488
+ else {
489
+ const relFromProject = path.relative(resolvedProjectRoot, resolved);
490
+ const insideProjectRoot = relFromProject !== '' && !relFromProject.startsWith('..') && !path.isAbsolute(relFromProject);
491
+ if (insideProjectRoot) {
492
+ mapped = candidate;
493
+ }
494
+ else {
495
+ // Hoisted `node_modules/<pkg>/...` file lives above projectRoot.
496
+ // Rewrite the URL to its fs-anchored form so Vite reads it directly
497
+ // instead of bouncing through bare-specifier resolution that the
498
+ // hoisted package's `exports` field may refuse.
499
+ mapped = `/@fs${resolved.replace(/\\/g, '/')}${querySuffix}`;
500
+ }
501
+ }
502
+ }
503
+ if (seen.has(mapped))
504
+ continue;
505
+ seen.add(mapped);
506
+ result.push(mapped);
507
+ }
508
+ return result;
509
+ }
510
+ function findVendorPrefix(specifier, manifest) {
511
+ const { modules, aliases } = manifest;
512
+ const keys = Object.keys(modules || {});
513
+ for (const key of keys) {
514
+ if (specifier === key) {
515
+ return key;
516
+ }
517
+ if (specifier.startsWith(`${key}/`)) {
518
+ const subpath = specifier.slice(key.length + 1);
519
+ if (isFileDistSubpath(subpath)) {
520
+ return key;
521
+ }
522
+ const aliasKey = `${key}/${subpath.split('/')[0]}`;
523
+ if (aliases?.[aliasKey] && modules[aliases[aliasKey]]) {
524
+ return aliases[aliasKey];
525
+ }
526
+ continue;
527
+ }
528
+ }
529
+ return null;
530
+ }
531
+ export function viteDepsPathToBareSpecifier(depPath) {
532
+ const manifest = getVendorManifest();
533
+ if (!manifest)
534
+ return null;
535
+ const flatId = extractVitePrebundleId(`.vite/deps/${depPath}`);
536
+ if (!flatId)
537
+ return null;
538
+ const flatMap = getFlattenedManifestMap(manifest);
539
+ if (flatMap.has(flatId)) {
540
+ return flatMap.get(flatId);
541
+ }
542
+ let bestKey = '';
543
+ let bestCanonical = '';
544
+ for (const [flatKey, canonical] of flatMap.entries()) {
545
+ if (flatId.startsWith(`${flatKey}_`) && flatKey.length > bestKey.length) {
546
+ bestKey = flatKey;
547
+ bestCanonical = canonical;
548
+ }
549
+ }
550
+ if (bestKey && bestCanonical) {
551
+ const flatSuffix = flatId.slice(bestKey.length + 1);
552
+ const subpath = flatSuffix.replace(/_/g, '/');
553
+ return `${bestCanonical}/${subpath}`;
554
+ }
555
+ return null;
556
+ }
557
+ function isFileDistSubpath(subpath) {
558
+ const firstSegment = subpath.split('/')[0];
559
+ const FILE_DIST_DIRS = new Set(['dist', 'src', 'lib', 'build', 'esm', 'cjs', 'es', 'umd', 'module', 'bundle', 'output', '_esm', '_cjs']);
560
+ if (FILE_DIST_DIRS.has(firstSegment)) {
561
+ return true;
562
+ }
563
+ if (!subpath.includes('/') && /\.[a-zA-Z0-9]+$/.test(subpath)) {
564
+ return true;
565
+ }
566
+ return false;
567
+ }
568
+ const nodeModulesPackageBoundaryCache = new Map();
569
+ export function resolveNodeModulesPackageBoundary(nodeModulesSpec, projectRoot) {
570
+ const normalized = String(nodeModulesSpec || '')
571
+ .replace(PAT.QUERY_PATTERN, '')
572
+ .replace(/^\/+/, '');
573
+ const resolvedProjectRoot = path.resolve(projectRoot || getProjectRootPath());
574
+ const cacheKey = `${resolvedProjectRoot}::${normalized}`;
575
+ const cached = nodeModulesPackageBoundaryCache.get(cacheKey);
576
+ if (cached) {
577
+ return cached;
578
+ }
579
+ const rootPackageName = extractRootPackageName(normalized) || normalized;
580
+ let packageName = rootPackageName;
581
+ if (packageName && normalized.startsWith(`${packageName}/`)) {
582
+ const segments = normalized.split('/');
583
+ const rootSegmentCount = rootPackageName.startsWith('@') ? 2 : 1;
584
+ for (let end = segments.length; end > rootSegmentCount; end--) {
585
+ const candidate = segments.slice(0, end).join('/');
586
+ if (!candidate || candidate === rootPackageName) {
587
+ continue;
588
+ }
589
+ const candidatePackageJson = path.join(resolvedProjectRoot, 'node_modules', ...candidate.split('/'), 'package.json');
590
+ if (existsSync(candidatePackageJson)) {
591
+ packageName = candidate;
592
+ break;
593
+ }
594
+ }
595
+ }
596
+ const subpath = normalized === packageName ? '' : normalized.slice(packageName.length).replace(/^\/+/, '');
597
+ const resolved = { packageName, subpath };
598
+ nodeModulesPackageBoundaryCache.set(cacheKey, resolved);
599
+ return resolved;
600
+ }
601
+ const exportsReverseMapCache = new Map();
602
+ function resolveExportConditionValue(conditions) {
603
+ if (typeof conditions === 'string')
604
+ return conditions;
605
+ if (typeof conditions !== 'object' || conditions === null)
606
+ return null;
607
+ const obj = conditions;
608
+ for (const key of ['esm2022', 'esm', 'esm2015', 'import', 'module', 'default']) {
609
+ if (key in obj) {
610
+ const result = resolveExportConditionValue(obj[key]);
611
+ if (result)
612
+ return result;
613
+ }
614
+ }
615
+ for (const val of Object.values(obj)) {
616
+ if (typeof val === 'string')
617
+ return val;
618
+ }
619
+ return null;
620
+ }
621
+ function getExportsReverseMap(pkgName, projectRoot) {
622
+ const cached = exportsReverseMapCache.get(pkgName);
623
+ if (cached)
624
+ return cached;
625
+ const map = new Map();
626
+ try {
627
+ const pkgJsonPath = path.join(projectRoot, 'node_modules', pkgName, 'package.json');
628
+ const pkgJson = JSON.parse(readFileSync(pkgJsonPath, 'utf-8'));
629
+ if (pkgJson.exports && typeof pkgJson.exports === 'object') {
630
+ for (const [entryPoint, conditions] of Object.entries(pkgJson.exports)) {
631
+ if (entryPoint.includes('*') || entryPoint.endsWith('.json'))
632
+ continue;
633
+ const resolvedPath = resolveExportConditionValue(conditions);
634
+ if (resolvedPath && typeof resolvedPath === 'string') {
635
+ const normalized = resolvedPath.replace(/^\.\//, '');
636
+ const bareSpec = entryPoint === '.' ? pkgName : `${pkgName}/${entryPoint.replace(/^\.\//, '')}`;
637
+ map.set(normalized, bareSpec);
638
+ }
639
+ }
640
+ }
641
+ if (map.size === 0) {
642
+ for (const field of ['module', 'main']) {
643
+ const value = pkgJson[field];
644
+ if (value && typeof value === 'string') {
645
+ const normalized = value.replace(/^\.\//, '');
646
+ map.set(normalized, pkgName);
647
+ const withoutExt = normalized.replace(/\.[^.]+$/, '');
648
+ if (withoutExt !== normalized) {
649
+ map.set(withoutExt, pkgName);
650
+ }
651
+ break;
652
+ }
653
+ }
654
+ }
655
+ }
656
+ catch { }
657
+ exportsReverseMapCache.set(pkgName, map);
658
+ return map;
659
+ }
660
+ function getPackageMainFieldInfo(pkgName, projectRoot) {
661
+ const info = getPackageRuntimeInfo(pkgName, projectRoot);
662
+ return {
663
+ hasExports: info.hasExports,
664
+ mainEntries: info.mainEntries,
665
+ };
666
+ }
667
+ export function resolveInternalRuntimePluginBareSpecifier(spec, projectRoot) {
668
+ if (!spec) {
669
+ return null;
670
+ }
671
+ const cleaned = spec.replace(PAT.QUERY_PATTERN, '');
672
+ const normalized = normalizeNodeModulesSpecifier(cleaned) || cleaned.replace(/^\/+/, '');
673
+ if (!normalized) {
674
+ return null;
675
+ }
676
+ const rootPackageName = extractRootPackageName(normalized);
677
+ if (!rootPackageName || !isLikelyNativeScriptRuntimePluginSpecifier(rootPackageName, projectRoot)) {
678
+ return null;
679
+ }
680
+ const { packageName, subpath } = resolveNodeModulesPackageBoundary(normalized, projectRoot);
681
+ if (!subpath || packageName !== rootPackageName) {
682
+ return null;
683
+ }
684
+ if (!subpath.includes('/')) {
685
+ return null;
686
+ }
687
+ const reverseMap = getExportsReverseMap(packageName, projectRoot);
688
+ const originalSpec = reverseMap.get(subpath);
689
+ if (originalSpec && originalSpec !== packageName) {
690
+ return null;
691
+ }
692
+ const packageMainInfo = getPackageMainFieldInfo(packageName, projectRoot);
693
+ if (!packageMainInfo.hasExports && subpathMatchesMainEntry(subpath, packageMainInfo.mainEntries)) {
694
+ return packageName;
695
+ }
696
+ return normalized;
697
+ }
698
+ /**
699
+ * True when a resolved subpath IS the package's main entry, accounting for
700
+ * NativeScript plugin conventions: `main` is commonly extensionless
701
+ * (`"main": "dist/index"`) while Vite's platform-aware resolver lands on the
702
+ * concrete file (`dist/index.ios.js`). An exact-string check misses that, the
703
+ * subpath is then kept as the vendor specifier, and the device's vendor
704
+ * registry (keyed on bare package ids) can't serve it — the import falls to
705
+ * the runtime's base require and comes back as an empty placeholder module
706
+ * (observed as `MediaServer is not a constructor` for
707
+ * `@blackout-lighting-console/media-server`).
708
+ */
709
+ function subpathMatchesMainEntry(subpath, mainEntries) {
710
+ if (mainEntries.has(subpath)) {
711
+ return true;
712
+ }
713
+ const normalize = (value) => value.replace(/\.(m|c)?(js|ts)$/, '').replace(/\.(ios|android|visionos)$/, '');
714
+ const strippedSubpath = normalize(subpath);
715
+ if (mainEntries.has(strippedSubpath)) {
716
+ return true;
717
+ }
718
+ for (const entry of mainEntries) {
719
+ if (normalize(entry) === strippedSubpath) {
720
+ return true;
721
+ }
722
+ }
723
+ return false;
724
+ }
725
+ export function shouldPreserveBareRuntimePluginSubpathImport(spec, projectRoot) {
726
+ if (!spec) {
727
+ return false;
728
+ }
729
+ const cleaned = spec.replace(PAT.QUERY_PATTERN, '');
730
+ if (!cleaned || /^(?:\.|\/|https?:\/\/)/i.test(cleaned)) {
731
+ return false;
732
+ }
733
+ if (normalizeNodeModulesSpecifier(cleaned)) {
734
+ return false;
735
+ }
736
+ const normalized = cleaned.replace(/^\/+/, '');
737
+ const rootPackageName = extractRootPackageName(normalized);
738
+ if (!rootPackageName || !isLikelyNativeScriptRuntimePluginSpecifier(rootPackageName, projectRoot)) {
739
+ return false;
740
+ }
741
+ const { packageName, subpath } = resolveNodeModulesPackageBoundary(normalized, projectRoot);
742
+ if (!subpath || packageName !== rootPackageName) {
743
+ return false;
744
+ }
745
+ const lastSegment = subpath.split('/').pop() || '';
746
+ if (hasExplicitRuntimePluginScriptExtension(lastSegment)) {
747
+ return false;
748
+ }
749
+ if (!subpath.includes('/')) {
750
+ const packageBaseName = packageName.split('/').pop() || '';
751
+ const withoutPlatform = lastSegment.replace(/\.(ios|android|visionos)$/i, '');
752
+ if (withoutPlatform === 'index' || withoutPlatform === packageBaseName || withoutPlatform.startsWith(`${packageBaseName}.`)) {
753
+ return false;
754
+ }
755
+ }
756
+ const reverseMap = getExportsReverseMap(packageName, projectRoot);
757
+ const originalSpec = reverseMap.get(subpath);
758
+ if (originalSpec && originalSpec !== packageName) {
759
+ return false;
760
+ }
761
+ return true;
762
+ }
763
+ export function resolveVendorRouting(nodeModulesSpec, projectRoot) {
764
+ const rootPackageName = extractRootPackageName(nodeModulesSpec);
765
+ const { packageName: pkgName, subpath } = resolveNodeModulesPackageBoundary(nodeModulesSpec, projectRoot);
766
+ const pkgBaseName = pkgName.split('/').pop() || '';
767
+ const isRootLevelMainEntry = (() => {
768
+ if (!subpath || subpath.includes('/')) {
769
+ return false;
770
+ }
771
+ const withoutExt = subpath.replace(/\.[^.]+$/, '');
772
+ const withoutPlatform = withoutExt.replace(/\.(ios|android|visionos)$/i, '');
773
+ return withoutPlatform === 'index' || withoutPlatform === pkgBaseName;
774
+ })();
775
+ if (rootPackageName && pkgName !== rootPackageName) {
776
+ return { route: 'http' };
777
+ }
778
+ if (isLikelyNativeScriptRuntimePluginSpecifier(pkgName, projectRoot) && (!subpath || isRootLevelMainEntry)) {
779
+ return { route: 'vendor', bareSpec: pkgName };
780
+ }
781
+ if (isLikelyNativeScriptRuntimePluginSpecifier(pkgName, projectRoot) && subpath.includes('/')) {
782
+ const exactBareSpecifier = resolveInternalRuntimePluginBareSpecifier(nodeModulesSpec, projectRoot);
783
+ if (exactBareSpecifier) {
784
+ return { route: 'vendor', bareSpec: exactBareSpecifier };
785
+ }
786
+ }
787
+ const manifest = getVendorManifest();
788
+ if (!manifest?.modules?.[pkgName]) {
789
+ return null;
790
+ }
791
+ if (/\.(ios|android|visionos)\.(js|ts|mjs|mts)$/i.test(nodeModulesSpec) && isLikelyNativeScriptRuntimePluginSpecifier(pkgName, projectRoot) && isRootLevelMainEntry) {
792
+ return { route: 'vendor', bareSpec: pkgName };
793
+ }
794
+ if (/\.(ios|android|visionos)\.(js|ts|mjs|mts)$/.test(nodeModulesSpec)) {
795
+ return { route: 'http' };
796
+ }
797
+ if (!subpath) {
798
+ return { route: 'vendor', bareSpec: pkgName };
799
+ }
800
+ const reverseMap = getExportsReverseMap(pkgName, projectRoot);
801
+ const originalSpec = reverseMap.get(subpath);
802
+ if (originalSpec && originalSpec !== pkgName) {
803
+ return { route: 'http' };
804
+ }
805
+ if (subpath) {
806
+ const packageMainInfo = getPackageMainFieldInfo(pkgName, projectRoot);
807
+ if (!packageMainInfo.hasExports && packageMainInfo.mainEntries.has(subpath)) {
808
+ return { route: 'vendor', bareSpec: pkgName };
809
+ }
810
+ }
811
+ if (!subpath.includes('/')) {
812
+ const lastSegment = subpath.replace(/\.[^.]+$/, '');
813
+ if (lastSegment === 'index' || lastSegment === pkgBaseName || lastSegment.startsWith(pkgBaseName + '.')) {
814
+ return { route: 'vendor', bareSpec: pkgName };
815
+ }
816
+ }
817
+ return { route: 'http' };
818
+ }
819
+ //# sourceMappingURL=websocket-module-specifiers.js.map