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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (410) hide show
  1. package/README.md +51 -11
  2. package/bin/cli.cjs +8 -14
  3. package/configuration/angular.d.ts +34 -1
  4. package/configuration/angular.js +376 -165
  5. package/configuration/angular.js.map +1 -1
  6. package/configuration/base.js +256 -30
  7. package/configuration/base.js.map +1 -1
  8. package/configuration/javascript.js +12 -90
  9. package/configuration/javascript.js.map +1 -1
  10. package/configuration/solid.js +33 -4
  11. package/configuration/solid.js.map +1 -1
  12. package/configuration/typescript.js +10 -90
  13. package/configuration/typescript.js.map +1 -1
  14. package/helpers/app-components.d.ts +2 -1
  15. package/helpers/app-components.js.map +1 -1
  16. package/helpers/app-css-state.d.ts +8 -0
  17. package/helpers/app-css-state.js +8 -0
  18. package/helpers/app-css-state.js.map +1 -0
  19. package/helpers/bundler-context.d.ts +11 -0
  20. package/helpers/bundler-context.js +71 -0
  21. package/helpers/bundler-context.js.map +1 -0
  22. package/helpers/config-as-json.js +10 -0
  23. package/helpers/config-as-json.js.map +1 -1
  24. package/helpers/css-platform-plugin.d.ts +14 -0
  25. package/helpers/css-platform-plugin.js +43 -25
  26. package/helpers/css-platform-plugin.js.map +1 -1
  27. package/helpers/dev-host.d.ts +360 -0
  28. package/helpers/dev-host.js +692 -0
  29. package/helpers/dev-host.js.map +1 -0
  30. package/helpers/dynamic-import-plugin.js +1 -1
  31. package/helpers/dynamic-import-plugin.js.map +1 -1
  32. package/helpers/esbuild-platform-resolver.js +4 -1
  33. package/helpers/esbuild-platform-resolver.js.map +1 -1
  34. package/helpers/external-configs.d.ts +10 -12
  35. package/helpers/external-configs.js +54 -35
  36. package/helpers/external-configs.js.map +1 -1
  37. package/helpers/global-defines.d.ts +128 -0
  38. package/helpers/global-defines.js +174 -11
  39. package/helpers/global-defines.js.map +1 -1
  40. package/helpers/hmr-scope.d.ts +26 -0
  41. package/helpers/hmr-scope.js +67 -0
  42. package/helpers/hmr-scope.js.map +1 -0
  43. package/helpers/init.js +0 -18
  44. package/helpers/init.js.map +1 -1
  45. package/helpers/logging.d.ts +1 -0
  46. package/helpers/logging.js +65 -4
  47. package/helpers/logging.js.map +1 -1
  48. package/helpers/main-entry.d.ts +3 -1
  49. package/helpers/main-entry.js +444 -50
  50. package/helpers/main-entry.js.map +1 -1
  51. package/helpers/nativeclass-esbuild-plugin.d.ts +2 -1
  52. package/helpers/nativeclass-esbuild-plugin.js.map +1 -1
  53. package/helpers/nativeclass-transform.js +5 -6
  54. package/helpers/nativeclass-transform.js.map +1 -1
  55. package/helpers/nativeclass-transformer-plugin.d.ts +9 -2
  56. package/helpers/nativeclass-transformer-plugin.js +157 -14
  57. package/helpers/nativeclass-transformer-plugin.js.map +1 -1
  58. package/helpers/nativescript-package-resolver.js +10 -62
  59. package/helpers/nativescript-package-resolver.js.map +1 -1
  60. package/helpers/normalize-id.d.ts +42 -0
  61. package/helpers/normalize-id.js +60 -0
  62. package/helpers/normalize-id.js.map +1 -0
  63. package/helpers/ns-core-url.d.ts +106 -0
  64. package/helpers/ns-core-url.js +225 -0
  65. package/helpers/ns-core-url.js.map +1 -0
  66. package/helpers/optimize-deps.d.ts +16 -0
  67. package/helpers/optimize-deps.js +17 -0
  68. package/helpers/optimize-deps.js.map +1 -0
  69. package/helpers/package-platform-aliases.js +34 -49
  70. package/helpers/package-platform-aliases.js.map +1 -1
  71. package/helpers/platform-types.d.ts +2 -0
  72. package/helpers/platform-types.js +2 -0
  73. package/helpers/platform-types.js.map +1 -0
  74. package/helpers/postcss-platform-config.d.ts +17 -1
  75. package/helpers/postcss-platform-config.js +20 -37
  76. package/helpers/postcss-platform-config.js.map +1 -1
  77. package/helpers/project.d.ts +35 -0
  78. package/helpers/project.js +120 -2
  79. package/helpers/project.js.map +1 -1
  80. package/helpers/resolve-main-field-platform.d.ts +20 -0
  81. package/helpers/resolve-main-field-platform.js +49 -0
  82. package/helpers/resolve-main-field-platform.js.map +1 -0
  83. package/helpers/resolver.js +17 -2
  84. package/helpers/resolver.js.map +1 -1
  85. package/helpers/theme-core-plugins.js +1 -1
  86. package/helpers/theme-core-plugins.js.map +1 -1
  87. package/helpers/ts-config-paths.d.ts +14 -0
  88. package/helpers/ts-config-paths.js +90 -9
  89. package/helpers/ts-config-paths.js.map +1 -1
  90. package/helpers/typescript-check.d.ts +2 -1
  91. package/helpers/typescript-check.js.map +1 -1
  92. package/helpers/ui-registration.d.ts +21 -0
  93. package/helpers/ui-registration.js +156 -0
  94. package/helpers/ui-registration.js.map +1 -0
  95. package/helpers/utils.js +1 -2
  96. package/helpers/utils.js.map +1 -1
  97. package/helpers/workers.d.ts +20 -19
  98. package/helpers/workers.js +624 -4
  99. package/helpers/workers.js.map +1 -1
  100. package/hmr/client/css-handler.d.ts +2 -1
  101. package/hmr/client/css-handler.js +50 -26
  102. package/hmr/client/css-handler.js.map +1 -1
  103. package/hmr/client/css-update-overlay.d.ts +18 -0
  104. package/hmr/client/css-update-overlay.js +27 -0
  105. package/hmr/client/css-update-overlay.js.map +1 -0
  106. package/hmr/client/framework-client-strategy.d.ts +79 -0
  107. package/hmr/client/framework-client-strategy.js +19 -0
  108. package/hmr/client/framework-client-strategy.js.map +1 -0
  109. package/hmr/client/hmr-pending-overlay.d.ts +13 -0
  110. package/hmr/client/hmr-pending-overlay.js +60 -0
  111. package/hmr/client/hmr-pending-overlay.js.map +1 -0
  112. package/hmr/client/index.js +787 -211
  113. package/hmr/client/index.js.map +1 -1
  114. package/hmr/client/utils.d.ts +7 -1
  115. package/hmr/client/utils.js +207 -29
  116. package/hmr/client/utils.js.map +1 -1
  117. package/hmr/entry-runtime.d.ts +2 -1
  118. package/hmr/entry-runtime.js +256 -69
  119. package/hmr/entry-runtime.js.map +1 -1
  120. package/hmr/frameworks/angular/build/angular-linker.d.ts +12 -0
  121. package/hmr/frameworks/angular/build/angular-linker.js +109 -0
  122. package/hmr/frameworks/angular/build/angular-linker.js.map +1 -0
  123. package/hmr/frameworks/angular/build/inject-component-hmr-registration.d.ts +112 -0
  124. package/hmr/frameworks/angular/build/inject-component-hmr-registration.js +291 -0
  125. package/hmr/frameworks/angular/build/inject-component-hmr-registration.js.map +1 -0
  126. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.d.ts +75 -0
  127. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js +221 -0
  128. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js.map +1 -0
  129. package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.js +1 -170
  130. package/hmr/frameworks/angular/build/inline-decorator-component-templates.js.map +1 -0
  131. package/hmr/frameworks/angular/build/js-lexer.d.ts +4 -0
  132. package/{helpers/angular/synthesize-decorator-ctor-parameters.js → hmr/frameworks/angular/build/js-lexer.js} +22 -96
  133. package/hmr/frameworks/angular/build/js-lexer.js.map +1 -0
  134. package/hmr/frameworks/angular/build/shared-linker.d.ts +39 -0
  135. package/hmr/frameworks/angular/build/shared-linker.js +128 -0
  136. package/hmr/frameworks/angular/build/shared-linker.js.map +1 -0
  137. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js +88 -0
  138. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js.map +1 -0
  139. package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.js +1 -174
  140. package/hmr/frameworks/angular/build/synthesize-injectable-factories.js.map +1 -0
  141. package/{helpers/angular → hmr/frameworks/angular/build}/util.d.ts +1 -0
  142. package/hmr/frameworks/angular/build/util.js +155 -0
  143. package/hmr/frameworks/angular/build/util.js.map +1 -0
  144. package/hmr/frameworks/angular/client/index.d.ts +1 -0
  145. package/hmr/frameworks/angular/client/index.js +803 -21
  146. package/hmr/frameworks/angular/client/index.js.map +1 -1
  147. package/hmr/frameworks/angular/client/strategy.d.ts +9 -0
  148. package/hmr/frameworks/angular/client/strategy.js +19 -0
  149. package/hmr/frameworks/angular/client/strategy.js.map +1 -0
  150. package/hmr/frameworks/angular/server/angular-root-component.d.ts +79 -0
  151. package/hmr/frameworks/angular/server/angular-root-component.js +149 -0
  152. package/hmr/frameworks/angular/server/angular-root-component.js.map +1 -0
  153. package/hmr/frameworks/angular/server/linker.js +1 -4
  154. package/hmr/frameworks/angular/server/linker.js.map +1 -1
  155. package/hmr/frameworks/angular/server/strategy.js +460 -12
  156. package/hmr/frameworks/angular/server/strategy.js.map +1 -1
  157. package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.js +2 -2
  158. package/hmr/frameworks/angular/server/websocket-angular-entry.js.map +1 -0
  159. package/hmr/{server → frameworks/angular/server}/websocket-angular-hot-update.d.ts +17 -11
  160. package/hmr/frameworks/angular/server/websocket-angular-hot-update.js +336 -0
  161. package/hmr/frameworks/angular/server/websocket-angular-hot-update.js.map +1 -0
  162. package/hmr/frameworks/solid/build/solid-jsx-deps.d.ts +15 -0
  163. package/hmr/frameworks/solid/build/solid-jsx-deps.js +178 -0
  164. package/hmr/frameworks/solid/build/solid-jsx-deps.js.map +1 -0
  165. package/hmr/frameworks/solid/server/strategy.js +291 -16
  166. package/hmr/frameworks/solid/server/strategy.js.map +1 -1
  167. package/hmr/frameworks/typescript/server/strategy.js +38 -14
  168. package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
  169. package/hmr/frameworks/vue/client/dep-propagation.d.ts +36 -0
  170. package/hmr/frameworks/vue/client/dep-propagation.js +101 -0
  171. package/hmr/frameworks/vue/client/dep-propagation.js.map +1 -0
  172. package/hmr/frameworks/vue/client/index.d.ts +8 -0
  173. package/hmr/frameworks/vue/client/index.js +56 -243
  174. package/hmr/frameworks/vue/client/index.js.map +1 -1
  175. package/hmr/frameworks/vue/client/strategy.d.ts +33 -0
  176. package/hmr/frameworks/vue/client/strategy.js +157 -0
  177. package/hmr/frameworks/vue/client/strategy.js.map +1 -0
  178. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.d.ts +49 -0
  179. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js +142 -0
  180. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js.map +1 -0
  181. package/hmr/frameworks/vue/server/sfc-route-assemble.d.ts +7 -0
  182. package/hmr/frameworks/vue/server/sfc-route-assemble.js +747 -0
  183. package/hmr/frameworks/vue/server/sfc-route-assemble.js.map +1 -0
  184. package/hmr/frameworks/vue/server/sfc-route-meta.d.ts +7 -0
  185. package/hmr/frameworks/vue/server/sfc-route-meta.js +80 -0
  186. package/hmr/frameworks/vue/server/sfc-route-meta.js.map +1 -0
  187. package/hmr/frameworks/vue/server/sfc-route-serve.d.ts +8 -0
  188. package/hmr/frameworks/vue/server/sfc-route-serve.js +459 -0
  189. package/hmr/frameworks/vue/server/sfc-route-serve.js.map +1 -0
  190. package/hmr/frameworks/vue/server/sfc-route-shared.d.ts +38 -0
  191. package/hmr/frameworks/vue/server/sfc-route-shared.js +48 -0
  192. package/hmr/frameworks/vue/server/sfc-route-shared.js.map +1 -0
  193. package/hmr/frameworks/vue/server/strategy.d.ts +35 -0
  194. package/hmr/frameworks/vue/server/strategy.js +278 -1
  195. package/hmr/frameworks/vue/server/strategy.js.map +1 -1
  196. package/hmr/frameworks/vue/server/websocket-sfc.d.ts +15 -0
  197. package/hmr/frameworks/vue/server/websocket-sfc.js +20 -0
  198. package/hmr/frameworks/vue/server/websocket-sfc.js.map +1 -0
  199. package/hmr/helpers/ast-normalizer.d.ts +3 -1
  200. package/hmr/helpers/ast-normalizer.js +77 -10
  201. package/hmr/helpers/ast-normalizer.js.map +1 -1
  202. package/hmr/helpers/cjs-named-exports.d.ts +23 -0
  203. package/hmr/helpers/cjs-named-exports.js +152 -0
  204. package/hmr/helpers/cjs-named-exports.js.map +1 -0
  205. package/hmr/helpers/package-exports.d.ts +16 -0
  206. package/hmr/helpers/package-exports.js +396 -0
  207. package/hmr/helpers/package-exports.js.map +1 -0
  208. package/hmr/server/constants.js +20 -5
  209. package/hmr/server/constants.js.map +1 -1
  210. package/hmr/server/core-sanitize.d.ts +90 -7
  211. package/hmr/server/core-sanitize.js +211 -56
  212. package/hmr/server/core-sanitize.js.map +1 -1
  213. package/hmr/server/device-transform-helpers.d.ts +24 -0
  214. package/hmr/server/device-transform-helpers.js +369 -0
  215. package/hmr/server/device-transform-helpers.js.map +1 -0
  216. package/hmr/server/framework-strategy.d.ts +108 -11
  217. package/hmr/server/hmr-module-graph.d.ts +37 -0
  218. package/hmr/server/hmr-module-graph.js +214 -0
  219. package/hmr/server/hmr-module-graph.js.map +1 -0
  220. package/hmr/server/import-map.d.ts +11 -2
  221. package/hmr/server/import-map.js +95 -44
  222. package/hmr/server/import-map.js.map +1 -1
  223. package/hmr/server/index.js +7 -16
  224. package/hmr/server/index.js.map +1 -1
  225. package/hmr/server/ns-core-cjs-shape.d.ts +204 -0
  226. package/hmr/server/ns-core-cjs-shape.js +271 -0
  227. package/hmr/server/ns-core-cjs-shape.js.map +1 -0
  228. package/hmr/server/ns-rt-bridge.d.ts +51 -0
  229. package/hmr/server/ns-rt-bridge.js +131 -0
  230. package/hmr/server/ns-rt-bridge.js.map +1 -0
  231. package/hmr/server/ns-rt-route.d.ts +5 -0
  232. package/hmr/server/ns-rt-route.js +38 -0
  233. package/hmr/server/ns-rt-route.js.map +1 -0
  234. package/hmr/server/perf-instrumentation.d.ts +114 -0
  235. package/hmr/server/perf-instrumentation.js +197 -0
  236. package/hmr/server/perf-instrumentation.js.map +1 -0
  237. package/hmr/server/process-code-for-device.d.ts +14 -0
  238. package/hmr/server/process-code-for-device.js +702 -0
  239. package/hmr/server/process-code-for-device.js.map +1 -0
  240. package/hmr/server/require-guard.d.ts +1 -0
  241. package/hmr/server/require-guard.js +12 -0
  242. package/hmr/server/require-guard.js.map +1 -0
  243. package/hmr/server/rewrite-imports.d.ts +2 -0
  244. package/hmr/server/rewrite-imports.js +600 -0
  245. package/hmr/server/rewrite-imports.js.map +1 -0
  246. package/hmr/server/route-helpers.d.ts +7 -0
  247. package/hmr/server/route-helpers.js +13 -0
  248. package/hmr/server/route-helpers.js.map +1 -0
  249. package/hmr/server/server-origin.d.ts +2 -0
  250. package/hmr/server/server-origin.js +83 -0
  251. package/hmr/server/server-origin.js.map +1 -0
  252. package/hmr/server/shared-transform-request.js +13 -7
  253. package/hmr/server/shared-transform-request.js.map +1 -1
  254. package/hmr/server/transform-cache-invalidation.d.ts +37 -0
  255. package/hmr/server/transform-cache-invalidation.js +156 -0
  256. package/hmr/server/transform-cache-invalidation.js.map +1 -0
  257. package/hmr/server/vendor-bare-module-shims.d.ts +4 -0
  258. package/hmr/server/vendor-bare-module-shims.js +80 -0
  259. package/hmr/server/vendor-bare-module-shims.js.map +1 -0
  260. package/hmr/server/vite-plugin.js +72 -42
  261. package/hmr/server/vite-plugin.js.map +1 -1
  262. package/hmr/server/websocket-core-bridge.d.ts +45 -6
  263. package/hmr/server/websocket-core-bridge.js +81 -77
  264. package/hmr/server/websocket-core-bridge.js.map +1 -1
  265. package/hmr/server/websocket-css-hot-update.d.ts +33 -0
  266. package/hmr/server/websocket-css-hot-update.js +65 -0
  267. package/hmr/server/websocket-css-hot-update.js.map +1 -0
  268. package/hmr/server/websocket-device-transform.d.ts +3 -0
  269. package/hmr/server/websocket-device-transform.js +7 -0
  270. package/hmr/server/websocket-device-transform.js.map +1 -0
  271. package/hmr/server/websocket-graph-upsert.d.ts +15 -0
  272. package/hmr/server/websocket-graph-upsert.js +20 -0
  273. package/hmr/server/websocket-graph-upsert.js.map +1 -1
  274. package/hmr/server/websocket-hmr-pending.d.ts +37 -0
  275. package/hmr/server/websocket-hmr-pending.js +55 -0
  276. package/hmr/server/websocket-hmr-pending.js.map +1 -0
  277. package/hmr/server/websocket-hot-update.d.ts +77 -0
  278. package/hmr/server/websocket-hot-update.js +360 -0
  279. package/hmr/server/websocket-hot-update.js.map +1 -0
  280. package/hmr/server/websocket-import-map-route.d.ts +15 -0
  281. package/hmr/server/websocket-import-map-route.js +50 -0
  282. package/hmr/server/websocket-import-map-route.js.map +1 -0
  283. package/hmr/server/websocket-module-bindings.js +3 -3
  284. package/hmr/server/websocket-module-bindings.js.map +1 -1
  285. package/hmr/server/websocket-module-specifiers.d.ts +66 -2
  286. package/hmr/server/websocket-module-specifiers.js +203 -20
  287. package/hmr/server/websocket-module-specifiers.js.map +1 -1
  288. package/hmr/server/websocket-ns-core.d.ts +21 -0
  289. package/hmr/server/websocket-ns-core.js +311 -0
  290. package/hmr/server/websocket-ns-core.js.map +1 -0
  291. package/hmr/server/websocket-ns-entry.d.ts +21 -0
  292. package/hmr/server/websocket-ns-entry.js +164 -0
  293. package/hmr/server/websocket-ns-entry.js.map +1 -0
  294. package/hmr/server/websocket-ns-m-paths.d.ts +1 -1
  295. package/hmr/server/websocket-ns-m-paths.js +58 -13
  296. package/hmr/server/websocket-ns-m-paths.js.map +1 -1
  297. package/hmr/server/websocket-ns-m-request.d.ts +11 -1
  298. package/hmr/server/websocket-ns-m-request.js +18 -25
  299. package/hmr/server/websocket-ns-m-request.js.map +1 -1
  300. package/hmr/server/websocket-ns-m.d.ts +33 -0
  301. package/hmr/server/websocket-ns-m.js +752 -0
  302. package/hmr/server/websocket-ns-m.js.map +1 -0
  303. package/hmr/server/websocket-served-module-helpers.d.ts +82 -0
  304. package/hmr/server/websocket-served-module-helpers.js +879 -0
  305. package/hmr/server/websocket-served-module-helpers.js.map +1 -0
  306. package/hmr/server/websocket-txn.js +2 -8
  307. package/hmr/server/websocket-txn.js.map +1 -1
  308. package/hmr/server/websocket-vendor-unifier.d.ts +0 -1
  309. package/hmr/server/websocket-vendor-unifier.js +4 -9
  310. package/hmr/server/websocket-vendor-unifier.js.map +1 -1
  311. package/hmr/server/websocket.d.ts +8 -39
  312. package/hmr/server/websocket.js +514 -4030
  313. package/hmr/server/websocket.js.map +1 -1
  314. package/hmr/shared/ns-globals.d.ts +118 -0
  315. package/hmr/shared/ns-globals.js +29 -0
  316. package/hmr/shared/ns-globals.js.map +1 -0
  317. package/hmr/shared/protocol.d.ts +145 -0
  318. package/hmr/shared/protocol.js +28 -0
  319. package/hmr/shared/protocol.js.map +1 -0
  320. package/hmr/shared/runtime/boot-placeholder-ui.d.ts +69 -0
  321. package/hmr/shared/runtime/boot-placeholder-ui.js +101 -0
  322. package/hmr/shared/runtime/boot-placeholder-ui.js.map +1 -0
  323. package/hmr/shared/runtime/boot-progress.d.ts +44 -0
  324. package/hmr/shared/runtime/boot-progress.js +133 -0
  325. package/hmr/shared/runtime/boot-progress.js.map +1 -0
  326. package/hmr/shared/runtime/boot-timeline.d.ts +18 -0
  327. package/hmr/shared/runtime/boot-timeline.js +42 -0
  328. package/hmr/shared/runtime/boot-timeline.js.map +1 -0
  329. package/hmr/shared/runtime/browser-runtime-contract.js.map +1 -1
  330. package/hmr/shared/runtime/dev-overlay-snapshots.d.ts +31 -0
  331. package/hmr/shared/runtime/dev-overlay-snapshots.js +324 -0
  332. package/hmr/shared/runtime/dev-overlay-snapshots.js.map +1 -0
  333. package/hmr/shared/runtime/dev-overlay.d.ts +75 -26
  334. package/hmr/shared/runtime/dev-overlay.js +992 -261
  335. package/hmr/shared/runtime/dev-overlay.js.map +1 -1
  336. package/hmr/shared/runtime/global-scope.d.ts +18 -0
  337. package/hmr/shared/runtime/global-scope.js +21 -0
  338. package/hmr/shared/runtime/global-scope.js.map +1 -0
  339. package/hmr/shared/runtime/hooks.js +2 -1
  340. package/hmr/shared/runtime/hooks.js.map +1 -1
  341. package/hmr/shared/runtime/http-only-boot.js +7 -6
  342. package/hmr/shared/runtime/http-only-boot.js.map +1 -1
  343. package/hmr/shared/runtime/module-provenance.js +4 -6
  344. package/hmr/shared/runtime/module-provenance.js.map +1 -1
  345. package/hmr/shared/runtime/root-placeholder-view.d.ts +19 -0
  346. package/hmr/shared/runtime/root-placeholder-view.js +311 -0
  347. package/hmr/shared/runtime/root-placeholder-view.js.map +1 -0
  348. package/hmr/shared/runtime/root-placeholder.js +371 -197
  349. package/hmr/shared/runtime/root-placeholder.js.map +1 -1
  350. package/hmr/shared/runtime/session-bootstrap.js +168 -4
  351. package/hmr/shared/runtime/session-bootstrap.js.map +1 -1
  352. package/hmr/shared/runtime/vendor-bootstrap.js +3 -10
  353. package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
  354. package/hmr/shared/vendor/manifest-collect.d.ts +4 -0
  355. package/hmr/shared/vendor/manifest-collect.js +512 -0
  356. package/hmr/shared/vendor/manifest-collect.js.map +1 -0
  357. package/hmr/shared/vendor/manifest-loader.d.ts +2 -1
  358. package/hmr/shared/vendor/manifest-loader.js +5 -3
  359. package/hmr/shared/vendor/manifest-loader.js.map +1 -1
  360. package/hmr/shared/vendor/manifest.d.ts +1 -7
  361. package/hmr/shared/vendor/manifest.js +102 -741
  362. package/hmr/shared/vendor/manifest.js.map +1 -1
  363. package/hmr/shared/vendor/vendor-device-shim.d.ts +1 -0
  364. package/hmr/shared/vendor/vendor-device-shim.js +208 -0
  365. package/hmr/shared/vendor/vendor-device-shim.js.map +1 -0
  366. package/hmr/shared/vendor/vendor-esbuild-plugins.d.ts +16 -0
  367. package/hmr/shared/vendor/vendor-esbuild-plugins.js +203 -0
  368. package/hmr/shared/vendor/vendor-esbuild-plugins.js.map +1 -0
  369. package/hmr/vendor-bootstrap.d.ts +1 -3
  370. package/hmr/vendor-bootstrap.js +4 -6
  371. package/hmr/vendor-bootstrap.js.map +1 -1
  372. package/index.d.ts +1 -0
  373. package/index.js +5 -0
  374. package/index.js.map +1 -1
  375. package/package.json +55 -11
  376. package/runtime/core-aliases-early.js +25 -55
  377. package/runtime/core-aliases-early.js.map +1 -1
  378. package/helpers/angular/angular-linker.d.ts +0 -13
  379. package/helpers/angular/angular-linker.js +0 -194
  380. package/helpers/angular/angular-linker.js.map +0 -1
  381. package/helpers/angular/inline-decorator-component-templates.js.map +0 -1
  382. package/helpers/angular/shared-linker.d.ts +0 -11
  383. package/helpers/angular/shared-linker.js +0 -75
  384. package/helpers/angular/shared-linker.js.map +0 -1
  385. package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +0 -1
  386. package/helpers/angular/synthesize-injectable-factories.js.map +0 -1
  387. package/helpers/angular/util.js +0 -67
  388. package/helpers/angular/util.js.map +0 -1
  389. package/helpers/prelink-angular.d.ts +0 -2
  390. package/helpers/prelink-angular.js +0 -117
  391. package/helpers/prelink-angular.js.map +0 -1
  392. package/hmr/server/websocket-angular-entry.js.map +0 -1
  393. package/hmr/server/websocket-angular-hot-update.js +0 -239
  394. package/hmr/server/websocket-angular-hot-update.js.map +0 -1
  395. package/hmr/server/websocket-ns-m-finalize.d.ts +0 -32
  396. package/hmr/server/websocket-ns-m-finalize.js +0 -73
  397. package/hmr/server/websocket-ns-m-finalize.js.map +0 -1
  398. package/hmr/server/websocket-runtime-compat.d.ts +0 -19
  399. package/hmr/server/websocket-runtime-compat.js +0 -286
  400. package/hmr/server/websocket-runtime-compat.js.map +0 -1
  401. package/hmr/server/websocket-vue-sfc.d.ts +0 -35
  402. package/hmr/server/websocket-vue-sfc.js +0 -1116
  403. package/hmr/server/websocket-vue-sfc.js.map +0 -1
  404. package/transformers/NativeClass/index.d.ts +0 -2
  405. package/transformers/NativeClass/index.js +0 -222
  406. package/transformers/NativeClass/index.js.map +0 -1
  407. /package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.d.ts +0 -0
  408. /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-decorator-ctor-parameters.d.ts +0 -0
  409. /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.d.ts +0 -0
  410. /package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.d.ts +0 -0
@@ -0,0 +1,879 @@
1
+ import { parse as babelParse } from '@babel/parser';
2
+ import * as t from '@babel/types';
3
+ import { existsSync, readFileSync } from 'fs';
4
+ import * as path from 'path';
5
+ import * as PAT from './constants.js';
6
+ import { isDeepCoreSubpath } from './core-sanitize.js';
7
+ import { getCjsNamedExports } from '../helpers/cjs-named-exports.js';
8
+ import { getMonorepoWorkspaceRoot } from '../../helpers/project.js';
9
+ import { extractDirectExportedNames, parseExportSpecList } from './websocket-core-bridge.js';
10
+ let cachedWorkspaceCoreRoot;
11
+ /**
12
+ * Absolute root of @nativescript/core when it is consumed from monorepo
13
+ * source (`<workspace>/packages/core` in the NativeScript repo) rather than
14
+ * node_modules. Returns null for standalone apps.
15
+ */
16
+ export function getWorkspaceCoreSourceRoot() {
17
+ if (cachedWorkspaceCoreRoot !== undefined)
18
+ return cachedWorkspaceCoreRoot;
19
+ cachedWorkspaceCoreRoot = null;
20
+ try {
21
+ const wsRoot = getMonorepoWorkspaceRoot();
22
+ if (wsRoot) {
23
+ const pkgPath = path.join(wsRoot, 'packages/core/package.json');
24
+ if (existsSync(pkgPath)) {
25
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
26
+ if (pkg?.name === '@nativescript/core') {
27
+ cachedWorkspaceCoreRoot = path.resolve(wsRoot, 'packages/core').replace(/\\/g, '/');
28
+ }
29
+ }
30
+ }
31
+ }
32
+ catch { }
33
+ return cachedWorkspaceCoreRoot;
34
+ }
35
+ /**
36
+ * True when a served module path points into @nativescript/core consumed from
37
+ * monorepo source. These modules are library code: the app-source HMR passes
38
+ * (AST normalization, /ns/rt underscore-helper alias injection) must NOT run
39
+ * on them — they exist for compiled app/SFC output, and on core sources they
40
+ * misread internals (e.g. `ClassInfo._getBase`) as Vue template helpers and
41
+ * inject destructures that shadow real bindings or TDZ-crash on the circular
42
+ * /ns/rt dependency. In standalone apps core lives under node_modules and is
43
+ * already excluded by the node_modules check.
44
+ */
45
+ export function isWorkspaceCoreModulePath(p) {
46
+ if (!p)
47
+ return false;
48
+ const coreRoot = getWorkspaceCoreSourceRoot();
49
+ if (!coreRoot)
50
+ return false;
51
+ const normalized = String(p).split('?')[0].replace(/\\/g, '/');
52
+ return normalized.includes(coreRoot + '/') || /(^|\/)packages\/core\//.test(normalized);
53
+ }
54
+ /**
55
+ * True when a served module path points into the @nativescript/vite package
56
+ * routed via its monorepo build output (`dist/packages/vite/...`). Apps that
57
+ * consume the package via `file:../../dist/packages/vite` get a node_modules
58
+ * SYMLINK, and require.resolve follows it to the real dist path — so the
59
+ * served URL carries no `node_modules/` segment and escapes the node_modules
60
+ * library check. Like core source, this is library code: the app-source HMR
61
+ * passes (AST normalization, /ns/rt alias injection) must not run on it —
62
+ * e.g. the HMR client bundle already carries its own `__ns_rt_ns_re` import,
63
+ * and a second injected one is a duplicate-declaration SyntaxError on device.
64
+ */
65
+ export function isWorkspaceVitePackageModulePath(p) {
66
+ if (!p)
67
+ return false;
68
+ const normalized = String(p).split('?')[0].replace(/\\/g, '/');
69
+ return /(^|\/)dist\/packages\/vite\//.test(normalized);
70
+ }
71
+ /**
72
+ * Single classification point for the /ns/m served-module pipeline. The
73
+ * app-source passes inside processCodeForDevice (AST normalization, /ns/rt
74
+ * underscore-helper alias injection) must run ONLY on 'app' modules; 'library'
75
+ * code is served as-is plus import rewriting. Three things count as library:
76
+ * - anything under node_modules
77
+ * - @nativescript/core consumed from monorepo source (packages/core)
78
+ * - the @nativescript/vite package served from its dist build output
79
+ * (file:../../dist/packages/vite symlinks resolve to the real dist path,
80
+ * so no node_modules segment appears in the URL)
81
+ * Add the next workspace-library case HERE, not at a call site.
82
+ */
83
+ export function classifyServedModule(p) {
84
+ if (!p)
85
+ return 'app';
86
+ const normalized = String(p).split('?')[0].replace(/\\/g, '/');
87
+ if (/(?:^|\/)node_modules\//.test(normalized))
88
+ return 'library';
89
+ if (isWorkspaceCoreModulePath(normalized))
90
+ return 'library';
91
+ if (isWorkspaceVitePackageModulePath(normalized))
92
+ return 'library';
93
+ return 'app';
94
+ }
95
+ export const MODULE_IMPORT_ANALYSIS_PLUGINS = ['typescript', 'jsx', 'importMeta', 'topLevelAwait', 'classProperties', 'classPrivateProperties', 'classPrivateMethods', 'decorators-legacy'];
96
+ export function collectTopLevelImportRecords(code) {
97
+ if (!code || typeof code !== 'string' || !/\bimport\b/.test(code)) {
98
+ return [];
99
+ }
100
+ try {
101
+ const ast = babelParse(code, {
102
+ sourceType: 'module',
103
+ plugins: MODULE_IMPORT_ANALYSIS_PLUGINS,
104
+ });
105
+ const body = ast?.program?.body;
106
+ if (!Array.isArray(body)) {
107
+ return [];
108
+ }
109
+ return body
110
+ .filter((node) => t.isImportDeclaration(node) && typeof node.start === 'number' && typeof node.end === 'number' && typeof node.source?.value === 'string')
111
+ .map((node) => ({
112
+ start: node.start,
113
+ end: node.end,
114
+ text: code.slice(node.start, node.end),
115
+ source: node.source.value,
116
+ hasOnlyNamedSpecifiers: Array.isArray(node.specifiers) && node.specifiers.length > 0 && node.specifiers.every((spec) => t.isImportSpecifier(spec)),
117
+ namedBindings: Array.isArray(node.specifiers)
118
+ ? node.specifiers
119
+ .filter((spec) => t.isImportSpecifier(spec) && typeof spec.start === 'number' && typeof spec.end === 'number')
120
+ .map((spec) => ({
121
+ importedName: t.isIdentifier(spec.imported) ? spec.imported.name : String(spec.imported?.value || ''),
122
+ text: code.slice(spec.start, spec.end),
123
+ }))
124
+ : [],
125
+ }));
126
+ }
127
+ catch {
128
+ return [];
129
+ }
130
+ }
131
+ export function hoistTopLevelStaticImports(code) {
132
+ const imports = collectTopLevelImportRecords(code);
133
+ if (!imports.length) {
134
+ return code;
135
+ }
136
+ let stripped = code;
137
+ for (const imp of [...imports].sort((left, right) => right.start - left.start)) {
138
+ stripped = stripped.slice(0, imp.start) + stripped.slice(imp.end);
139
+ }
140
+ const hoisted = [];
141
+ const seen = new Set();
142
+ for (const imp of imports) {
143
+ const text = imp.text.trim();
144
+ if (!text || seen.has(text)) {
145
+ continue;
146
+ }
147
+ seen.add(text);
148
+ hoisted.push(text);
149
+ }
150
+ if (!hoisted.length) {
151
+ return stripped;
152
+ }
153
+ return `${hoisted.join('\n')}\n${stripped.replace(/^\s*\n+/, '')}`;
154
+ }
155
+ // Boot-progress instrumentation snippet (server-side string-only).
156
+ //
157
+ // Injected at the top of every `__ns_boot__/b1`-tagged module the dev
158
+ // server serves during cold boot. The snippet is FULLY SYNCHRONOUS —
159
+ // even one conditional top-level `await` would mark the module async
160
+ // in V8, propagating an async-promise chain through the entire boot
161
+ // graph and tripping the iOS 10 s top-level-await deadline (see
162
+ // `ModuleInternal.mm::pumpAsyncProgress`). It just bumps the
163
+ // `__NS_HMR_BOOT_MODULE_COUNT__` / `__NS_HMR_BOOT_LAST_MODULE__`
164
+ // globals; the 250 ms heartbeat in `session-bootstrap.ts` owns
165
+ // `setBootStage` and runs `boot-progress.ts::computeBootImportProgress`
166
+ // against those counters plus elapsed wall-clock to drive the bar.
167
+ // The iOS runtime's `MaybePumpJSThreadDuringBoot` keeps the JS-thread
168
+ // CFRunLoop ticking between sync fetches so the heartbeat can fire
169
+ // during the otherwise-blocking cold-boot module walk.
170
+ //
171
+ // Regression-tested by `websocket-integrity.spec.ts` (snippet stays
172
+ // fully synchronous + propagates exactly via the boot-tag prefix).
173
+ export function buildBootProgressSnippet(bootModuleLabel) {
174
+ const normalizedLabel = JSON.stringify(String(bootModuleLabel || '').replace(/\\/g, '/'));
175
+ return [`const __nsBootGlobal=globalThis;`, `try{if(!__nsBootGlobal.__NS_HMR_BOOT_COMPLETE__){__nsBootGlobal.__NS_HMR_BOOT_MODULE_COUNT__=Number(__nsBootGlobal.__NS_HMR_BOOT_MODULE_COUNT__||0)+1;__nsBootGlobal.__NS_HMR_BOOT_LAST_MODULE__=${normalizedLabel};}}catch(__nsBootErr){}`, ''].join('\n');
176
+ }
177
+ export function stripCoreGlobalsImports(code) {
178
+ const pattern = /^\s*(?:import\s+(?:[^'"\n]*from\s+)?|export\s+\*\s+from\s+)["'][^"']*(?:@nativescript(?:[/_-])core(?:[\/_-])globals|@nativescript_core_globals)[^"']*["'];?\s*$/gm;
179
+ return code.replace(pattern, '');
180
+ }
181
+ export function ensureVariableDynamicImportHelper(code) {
182
+ if (!code.includes('__variableDynamicImportRuntimeHelper')) {
183
+ return code;
184
+ }
185
+ if (PAT.VARIABLE_DYNAMIC_IMPORT_HELPER_PATTERN.test(code)) {
186
+ return code;
187
+ }
188
+ const helper = `const __variableDynamicImportRuntimeHelper = (map, request, importMode) => {\n` +
189
+ ` try { if (request === '@') { return import(new URL('/ns/m/__invalid_at__.mjs', import.meta.url).href); } } catch {}\n` +
190
+ ` const loader = map && (map[request] || map[request?.replace(/\\\\/g, "/")]);\n` +
191
+ ` if (!loader) {\n` +
192
+ ` const error = new Error("Cannot dynamically import: " + request);\n` +
193
+ ` error.code = 'ERR_MODULE_NOT_FOUND';\n` +
194
+ ` return Promise.reject(error);\n` +
195
+ ` }\n` +
196
+ ` try {\n` +
197
+ ` return loader(importMode);\n` +
198
+ ` } catch (err) {\n` +
199
+ ` return Promise.reject(err);\n` +
200
+ ` }\n` +
201
+ `};\n`;
202
+ return `${helper}${code}`;
203
+ }
204
+ export function ensureGuardPlainDynamicImports(code) {
205
+ try {
206
+ if (!code || !/\bimport\s*\(/.test(code))
207
+ return code;
208
+ const wrapper = `const __ns_import = (s) => { try { if (s === '@') { return import(new URL('/ns/m/__invalid_at__.mjs', import.meta.url).href); } } catch {} return import(s); }\n`;
209
+ const replaced = code.replace(/(^|[^\.\w$])import\s*\(/g, (_m, p1) => `${p1}__ns_import(`);
210
+ if (replaced !== code) {
211
+ return wrapper + replaced;
212
+ }
213
+ return code;
214
+ }
215
+ catch {
216
+ return code;
217
+ }
218
+ }
219
+ // Stable URL helper for dynamic imports.
220
+ //
221
+ // Older versions of the helper synthesized
222
+ // `/ns/m/__ns_hmr__/<tag>/<rest>` URLs from
223
+ // `globalThis.__NS_HMR_GRAPH_VERSION__` and an importer-derived tag.
224
+ // That tag flowed straight into V8's `g_moduleRegistry` cache key — so
225
+ // a `graphVersion` bump on every save effectively flushed the whole
226
+ // module graph (HMR latency was dominated by Vite re-transforming the
227
+ // unchanged closure on every save).
228
+ //
229
+ // The current contract inverts that:
230
+ // * The runtime canonicalizes any URL shape (boot prefix, hmr prefix,
231
+ // stable) to a single key via `CanonicalizeHttpUrlKey`.
232
+ // * The Angular client receives an explicit eviction set in
233
+ // `ns:angular-update` and calls `__nsInvalidateModules` before
234
+ // re-importing the entry, so V8 only refetches modules that
235
+ // actually changed.
236
+ // * The dynamic-import helper no longer needs to busy-construct
237
+ // versioned URLs. Boot prefix preservation still matters at COLD
238
+ // boot because the server-side handler routes `/__ns_boot__/b1/`
239
+ // paths to the boot-progress instrumentation snippet — but the
240
+ // prefix is read from `import.meta.url`, never synthesized from
241
+ // `__NS_HMR_GRAPH_VERSION__`.
242
+ //
243
+ // The helper is intentionally tiny:
244
+ // 1. `@` and falsy specs route to `/ns/m/__invalid_at__.mjs` (existing
245
+ // defensive sentinel for misencoded imports).
246
+ // 2. `/ns/m/...` specs that don't yet have a boot prefix get one
247
+ // added when the caller is itself a boot-tagged module. This
248
+ // keeps the boot-progress instrumentation flowing through the
249
+ // transitive cold-boot graph during cold-boot sequences. Once HMR
250
+ // takes over (`__NS_HMR_BOOT_COMPLETE__` is set on the global), no
251
+ // prefix is added — the runtime canonicalizer collapses any
252
+ // historical prefix to the same key.
253
+ // 3. Everything else is a pass-through `import(spec)`.
254
+ export function ensureDynamicHmrImportHelper(code) {
255
+ try {
256
+ if (!code.includes('__nsDynamicHmrImport('))
257
+ return code;
258
+ if (code.includes('const __nsDynamicHmrImport ='))
259
+ return code;
260
+ const helper = 'const __nsDynamicHmrImport = (spec) => {\n' +
261
+ " const __nsm = '/ns' + '/m';\n" +
262
+ " try { if (!spec || spec === '@') { return import(new URL(__nsm + '/__invalid_at__.mjs', import.meta.url).href); } } catch {}\n" +
263
+ ' try {\n' +
264
+ " if (typeof spec !== 'string' || !spec.startsWith(__nsm + '/')) return import(spec);\n" +
265
+ ' const g = globalThis;\n' +
266
+ " const inBoot = !g.__NS_HMR_BOOT_COMPLETE__ && typeof import.meta !== 'undefined' && import.meta && typeof import.meta.url === 'string' && import.meta.url.includes('/__ns_boot__/b1/');\n" +
267
+ " const noBootPrefixYet = !spec.startsWith(__nsm + '/__ns_boot__/');\n" +
268
+ " const isAppModule = !spec.startsWith(__nsm + '/node_modules/');\n" +
269
+ " const finalSpec = inBoot && noBootPrefixYet && isAppModule ? __nsm + '/__ns_boot__/b1' + spec.slice(__nsm.length) : spec;\n" +
270
+ " const origin = typeof g.__NS_HTTP_ORIGIN__ === 'string' && /^https?:\\/\\//.test(g.__NS_HTTP_ORIGIN__) ? g.__NS_HTTP_ORIGIN__ : '';\n" +
271
+ ' return import(origin ? origin + finalSpec : new URL(finalSpec, import.meta.url).href);\n' +
272
+ ' } catch {}\n' +
273
+ ' return import(spec);\n' +
274
+ '};\n';
275
+ return helper + code;
276
+ }
277
+ catch {
278
+ return code;
279
+ }
280
+ }
281
+ /**
282
+ * Star-export expansion must be TRANSITIVE.
283
+ *
284
+ * The expansion below replaces `export * from "url"` with an explicit named
285
+ * list, so any name missing from that list is silently dropped from the
286
+ * importer's export surface — the device then fails at link time with
287
+ * "does not provide an export named '<name>'". Real packages routinely chain
288
+ * star re-exports (`index.ios.js → export * from './canvas'` →
289
+ * `canvas.ios.js → export * from './canvas.common'`), so the name set for a
290
+ * star target is the union of its direct exports, its named re-exports, and
291
+ * — recursively — every nested `export * from` chain, cycles included.
292
+ *
293
+ * This mirrors `collectStaticExportOriginsFromFile` in
294
+ * `websocket-core-bridge.ts`, which solved the identical problem for the
295
+ * /ns/core bridge (see its `Application` comment). That walker reads files
296
+ * from disk; this one works on Vite-transformed code via the shared
297
+ * transformer, because star targets here are served URLs (aliases, /@fs
298
+ * paths, platform-extension resolution already applied by Vite's resolver).
299
+ * If you change export-name semantics in one walker, check the other.
300
+ */
301
+ const STAR_EXPANSION_MAX_DEPTH = 64;
302
+ /**
303
+ * Normalize a star-export target (served URL or nested transformed
304
+ * specifier) into a root-relative path feedable to Vite's transform
305
+ * pipeline. Returns null for specifiers that cannot be walked (bare ids,
306
+ * relative specs with no parent context).
307
+ */
308
+ function normalizeStarExportTargetPath(spec, parentVitePath) {
309
+ let p = String(spec || '').trim();
310
+ if (!p)
311
+ return null;
312
+ p = p.replace(/^https?:\/\/[^/]+/, '');
313
+ p = p.replace(/[?#].*$/, '');
314
+ p = p.replace(/^\/ns\/m\//, '/');
315
+ p = p.replace(/^\/__ns_boot__\/[^/]+/, '');
316
+ p = p.replace(/\/__ns_hmr__\/[^/]+/, '');
317
+ if (p.startsWith('.')) {
318
+ // Vite's import analysis normally rewrites nested specifiers to
319
+ // root-relative URLs; resolve any relative stragglers against the
320
+ // parent module's directory.
321
+ const parent = String(parentVitePath || '')
322
+ .replace(/\\/g, '/')
323
+ .replace(/[?#].*$/, '');
324
+ if (!parent.startsWith('/'))
325
+ return null;
326
+ p = path.posix.normalize(path.posix.join(path.posix.dirname(parent), p));
327
+ }
328
+ return p.startsWith('/') ? p : null;
329
+ }
330
+ function scanModuleExportSurface(code) {
331
+ const ownNames = new Set(extractDirectExportedNames(code));
332
+ for (const m of code.matchAll(/\bexport\s+\*\s+as\s+([A-Za-z_$][\w$]*)\s+from\s*["'][^"']+["']/g)) {
333
+ ownNames.add(m[1]);
334
+ }
335
+ for (const m of code.matchAll(/\bexport\s*\{([^}]+)\}\s*from\s*["'][^"']+["']/g)) {
336
+ for (const { exportedName } of parseExportSpecList(m[1])) {
337
+ ownNames.add(exportedName);
338
+ }
339
+ }
340
+ const starSources = [];
341
+ // Tolerate trailing comments/code on the line (see the identical fix in
342
+ // websocket-core-bridge.ts: a strict `$` anchor silently skipped
343
+ // `export * from './layouts'; // barrel export` lines).
344
+ for (const m of code.matchAll(/^[ \t]*export\s+\*\s+from\s+["']([^"']+)["'][^\n]*$/gm)) {
345
+ starSources.push(m[1]);
346
+ }
347
+ return { ownNames, starSources };
348
+ }
349
+ /**
350
+ * Recursively collect the full export-name set of a star-export target,
351
+ * following nested `export * from` chains. Cycle-safe via the DFS `stack`
352
+ * set (a revisited module contributes nothing new at that point — its names
353
+ * are already being collected by the outer visit, matching spec
354
+ * GetExportedNames semantics). Returns null when the target itself cannot
355
+ * be transformed; partial failures deeper in the chain are reported through
356
+ * `diagnostics` while still returning every name that could be collected.
357
+ */
358
+ async function collectStarTargetExportNames(vitePath, transformer, stack, depth, diagnostics) {
359
+ if (stack.has(vitePath))
360
+ return new Set();
361
+ if (depth > STAR_EXPANSION_MAX_DEPTH) {
362
+ diagnostics.push(`star-export chain deeper than ${STAR_EXPANSION_MAX_DEPTH} at ${vitePath}`);
363
+ return null;
364
+ }
365
+ let targetCode;
366
+ try {
367
+ targetCode = (await transformer(vitePath))?.code ?? undefined;
368
+ }
369
+ catch { }
370
+ if (!targetCode) {
371
+ diagnostics.push(`unresolvable star-export target ${vitePath}`);
372
+ return null;
373
+ }
374
+ const surface = scanModuleExportSurface(targetCode);
375
+ const names = new Set(surface.ownNames);
376
+ stack.add(vitePath);
377
+ try {
378
+ for (const spec of surface.starSources) {
379
+ const childPath = normalizeStarExportTargetPath(spec, vitePath);
380
+ if (!childPath) {
381
+ diagnostics.push(`unwalkable nested star-export specifier ${JSON.stringify(spec)} in ${vitePath}`);
382
+ continue;
383
+ }
384
+ const childNames = await collectStarTargetExportNames(childPath, transformer, stack, depth + 1, diagnostics);
385
+ if (!childNames)
386
+ continue;
387
+ for (const n of childNames)
388
+ names.add(n);
389
+ }
390
+ }
391
+ finally {
392
+ stack.delete(vitePath);
393
+ }
394
+ // `export *` never re-exports default.
395
+ names.delete('default');
396
+ return names;
397
+ }
398
+ export async function expandStarExports(code, server, _projectRoot, verbose, sharedTransformer, importerId) {
399
+ const STAR_RE = /^[ \t]*export\s+\*\s+from\s+["']([^"']+)["'];?(?=[ \t]*(?:\/\/[^\n]*)?$)/gm;
400
+ let match;
401
+ const replacements = [];
402
+ while ((match = STAR_RE.exec(code)) !== null) {
403
+ const url = match[1];
404
+ if (!url.includes('/node_modules/'))
405
+ continue;
406
+ replacements.push({ full: match[0], url });
407
+ }
408
+ if (!replacements.length)
409
+ return code;
410
+ // Names already exported lexically by the importing module. Per spec,
411
+ // lexical exports shadow star-exported names — re-emitting them in an
412
+ // explicit list would be a duplicate-export SyntaxError on device.
413
+ const claimed = new Set(scanModuleExportSurface(code).ownNames);
414
+ // Resolve each star-export target in parallel through the shared runner
415
+ // (when provided) so they share the /ns/m TTL cache and concurrency gate.
416
+ const transformer = sharedTransformer ?? ((url) => server.transformRequest(url));
417
+ const resolved = await Promise.all(replacements.map(async (rep) => {
418
+ const diagnostics = [];
419
+ const vitePath = normalizeStarExportTargetPath(rep.url, null);
420
+ if (!vitePath) {
421
+ diagnostics.push(`unwalkable star-export URL ${rep.url}`);
422
+ return { rep, names: null, diagnostics };
423
+ }
424
+ const names = await collectStarTargetExportNames(vitePath, transformer, new Set(), 0, diagnostics);
425
+ if (verbose && names) {
426
+ console.log(`[ns/m] expanded export* -> ${names.size} names from ${vitePath}${diagnostics.length ? ' (partial)' : ''}`);
427
+ }
428
+ return { rep, names, diagnostics };
429
+ }));
430
+ for (const entry of resolved) {
431
+ if (entry.diagnostics.length) {
432
+ // Always-on: an incomplete expansion silently narrows the importer's
433
+ // export surface, which surfaces on device as a link-time
434
+ // "does not provide an export named ..." with no server-side trace.
435
+ console.warn(`[ns/m][export*] incomplete star-export expansion${importerId ? ` in ${importerId}` : ''} for ${entry.rep.url}: ${entry.diagnostics.join('; ')}`);
436
+ }
437
+ if (!entry.names)
438
+ continue;
439
+ // First star wins for names provided by multiple siblings; duplicates
440
+ // would be a SyntaxError, and spec-ambiguous names have no good answer.
441
+ const emit = Array.from(entry.names).filter((n) => !claimed.has(n));
442
+ for (const n of emit)
443
+ claimed.add(n);
444
+ // An empty list still keeps the dependency edge (side effects,
445
+ // evaluation order) via a side-effect import.
446
+ const explicit = emit.length ? `export { ${emit.join(', ')} } from ${JSON.stringify(entry.rep.url)};` : `import ${JSON.stringify(entry.rep.url)};`;
447
+ code = code.replace(entry.rep.full, explicit);
448
+ }
449
+ return code;
450
+ }
451
+ export function repairImportEqualsAssignments(code) {
452
+ try {
453
+ if (!code || typeof code !== 'string')
454
+ return code;
455
+ code = code.replace(/(^|\n)\s*import\s*\{([^}]+)\}\s*=\s*([^;]+);?/g, (_m, p1, specList, rhs) => {
456
+ const cleaned = String(specList)
457
+ .split(',')
458
+ .map((s) => s.trim())
459
+ .filter(Boolean)
460
+ .map((seg) => seg.replace(/\s+as\s+/i, ': '))
461
+ .join(', ');
462
+ return `${p1}const { ${cleaned} } = ${rhs};`;
463
+ });
464
+ code = code.replace(/(^|\n)\s*import\s*\*\s*as\s*([A-Za-z_$][\w$]*)\s*=\s*([^;]+);?/g, (_m, p1, ns, rhs) => `${p1}const ${ns} = (${rhs});`);
465
+ code = code.replace(/(^|\n)\s*import\s+([A-Za-z_$][\w$]*)\s*=\s*([^;]+);?/g, (_m, p1, id, rhs) => `${p1}const ${id} = ${rhs};`);
466
+ }
467
+ catch { }
468
+ return code;
469
+ }
470
+ export function ensureVersionedRtImports(code, origin, ver) {
471
+ if (!code || !origin || !Number.isFinite(ver))
472
+ return code;
473
+ code = code.replace(/(from\s+["'])(?:https?:\/\/[^"']+)?\/(?:\@ns|ns)\/rt(?:\/[\d]+)?(["'])/g, (_m, p1, p3) => `${p1}/ns/rt/${ver}${p3}`);
474
+ code = code.replace(/(import\(\s*["'])(?:https?:\/\/[^"']+)?\/(?:\@ns|ns)\/rt(?:\/[\d]+)?(["']\s*\))/g, (_m, p1, p3) => `${p1}/ns/rt/${ver}${p3}`);
475
+ return code;
476
+ }
477
+ export function stripViteDynamicImportVirtual(code) {
478
+ if (!/\/@id\/__x00__vite\/dynamic-import-helper/.test(code)) {
479
+ return code;
480
+ }
481
+ const original = code;
482
+ // Statement-scoped, NOT line-anchored: Vite 8 emits its injected imports
483
+ // concatenated on ONE line with the module's original first line, e.g.
484
+ // import …"/@vite/client";import …"/@id/__x00__vite/dynamic-import-helper.js";/**
485
+ // A `^…$`-anchored replace would delete the whole line — including the
486
+ // module's leading `/**`, leaving an orphaned JSDoc body that is a
487
+ // SyntaxError ("Unexpected token '*'") on device.
488
+ code = code.replace(/import\s+[^;'"\n]*['"][^'"\n]*\/@id\/__x00__vite\/dynamic-import-helper[^'"\n]*['"]\s*;?/g, '');
489
+ if (/\/@id\/__x00__vite\/dynamic-import-helper/.test(code)) {
490
+ code = code.replace(/\/@id\/__x00__vite\/dynamic-import-helper[^"'`)]*/g, '/__NS_UNUSED_DYNAMIC_IMPORT_HELPER__');
491
+ }
492
+ if (!/__variableDynamicImportRuntimeHelper/.test(code)) {
493
+ const inline = `const __variableDynamicImportRuntimeHelper = (map, request, importMode) => {\n try { if (request === '@') { return import('/ns/m/__invalid_at__.mjs'); } } catch {}\n const loader = map && (map[request] || map[request?.replace(/\\\\/g, '/')]);\n if (!loader) { const e = new Error('Cannot dynamically import: ' + request); /*@ts-ignore*/ e.code = 'ERR_MODULE_NOT_FOUND'; return Promise.reject(e); }\n try { return loader(importMode); } catch (e) { return Promise.reject(e); }\n};\n`;
494
+ code = inline + code;
495
+ }
496
+ if (code !== original) {
497
+ code = `// [hmr-sanitize] removed virtual dynamic-import-helper\n${code}`;
498
+ }
499
+ return code;
500
+ }
501
+ export function extractExportMetadata(code) {
502
+ const named = new Set();
503
+ let hasDefault = /\bexport\s+default\b/.test(code);
504
+ try {
505
+ for (const match of code.matchAll(/\bexport\s+(?:const|let|var|function|class)\s+([A-Za-z_$][A-Za-z0-9_$]*)/g)) {
506
+ if (match[1])
507
+ named.add(match[1]);
508
+ }
509
+ for (const match of code.matchAll(/\bexport\s*\{([^}]+)\}/g)) {
510
+ const inner = (match[1] || '')
511
+ .split(',')
512
+ .map((s) => s.trim())
513
+ .filter(Boolean);
514
+ for (const seg of inner) {
515
+ const direct = seg.match(/^([A-Za-z_$][A-Za-z0-9_$]*)(?:\s+as\s+([A-Za-z_$][A-Za-z0-9_$]*))?$/);
516
+ if (!direct)
517
+ continue;
518
+ const base = direct[1];
519
+ const alias = direct[2];
520
+ if (base === 'default') {
521
+ hasDefault = true;
522
+ continue;
523
+ }
524
+ named.add(alias || base);
525
+ }
526
+ }
527
+ }
528
+ catch { }
529
+ named.delete('default');
530
+ return { hasDefault, named: Array.from(named) };
531
+ }
532
+ function shouldAllowLocalCoreSanitizerPaths(contextLabel) {
533
+ // The @nativescript/vite HMR runtime (client + framework strategies)
534
+ // legitimately references local core paths in strings — allow it whether it
535
+ // is served from node_modules or from the monorepo dist output
536
+ // (`file:../../dist/packages/vite` symlinks resolve to the real dist path,
537
+ // so no node_modules segment appears in the served URL).
538
+ return /\b(?:node_modules\/@nativescript\/vite|dist\/packages\/vite)\/hmr\/(?:client|frameworks)\//.test(contextLabel);
539
+ }
540
+ export function assertNoOptimizedArtifacts(code, contextLabel) {
541
+ const offenders = [];
542
+ const lines = code.split('\n');
543
+ const tests = [/\b__VITE_PLUGIN__\b/, /\b__VITE_PRELOAD__\b/];
544
+ const localCore = /(^|[^\w@])(?:\.\.?\/|\/)??@nativescript[\/_-]core\//i;
545
+ for (let i = 0; i < lines.length; i++) {
546
+ const line = lines[i];
547
+ for (const re of tests) {
548
+ if (re.test(line)) {
549
+ offenders.push(`${i + 1}: ${line.substring(0, 200)}`);
550
+ break;
551
+ }
552
+ }
553
+ if (localCore.test(line)) {
554
+ const trimmed = line.trimStart();
555
+ if (trimmed.startsWith('//') || trimmed.startsWith('/*') || trimmed.startsWith('*')) {
556
+ continue;
557
+ }
558
+ if (shouldAllowLocalCoreSanitizerPaths(contextLabel)) {
559
+ continue;
560
+ }
561
+ // Only module-resolution contexts (import/export/require) leak to the
562
+ // device ESM loader. A core path appearing as plain runtime string data
563
+ // — e.g. component-builder's `const CORE_UI_BARREL = '@nativescript/core/ui'`
564
+ // passed to `global.loadModule()`, which reads the bundler module
565
+ // registry, not the ESM loader — is legitimate and must not fail serving.
566
+ if (!/(?:\bimport\b|\bexport\b|\bfrom\s*["']|\brequire\s*\()/.test(line)) {
567
+ continue;
568
+ }
569
+ offenders.push(`${i + 1}: ${line.substring(0, 200)} [local-core-path]`);
570
+ }
571
+ if (offenders.length >= 10)
572
+ break;
573
+ }
574
+ if (offenders.length) {
575
+ const msg = `[sanitize-fail] Optimized deps/virtual id artifacts detected in ${contextLabel}. These cannot be evaluated by the device HTTP ESM loader. Offending lines (first ${Math.min(5, offenders.length)} shown):\n` + offenders.slice(0, 5).join('\n');
576
+ const error = new Error(msg);
577
+ error.code = 'NS_SANITIZE_FAIL';
578
+ error.offenders = offenders;
579
+ throw error;
580
+ }
581
+ }
582
+ export function ensureDestructureCoreImports(code) {
583
+ try {
584
+ let result = code;
585
+ let coreImportCounter = 0;
586
+ const toDestructure = (specList) => specList
587
+ .split(',')
588
+ .map((s) => s.trim())
589
+ .filter(Boolean)
590
+ .map((seg) => {
591
+ const match = seg.split(/\s+as\s+/i);
592
+ return match.length === 2 ? `${match[0].trim()}: ${match[1].trim()}` : seg;
593
+ })
594
+ .join(', ');
595
+ const reNamed = /(^|\n)\s*import\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/core(?:\/[^"']+)?)['"];?\s*/gm;
596
+ result = result.replace(reNamed, (_full, prefix, specList, src) => {
597
+ if (isDeepCoreSubpath(src))
598
+ return _full;
599
+ const tempName = `__ns_core_ns_re${coreImportCounter > 0 ? `_${coreImportCounter}` : ''}`;
600
+ coreImportCounter++;
601
+ const decl = `const { ${toDestructure(specList)} } = ${tempName};`;
602
+ return `${prefix}import ${tempName} from ${JSON.stringify(src)};\n${decl}\n`;
603
+ });
604
+ const reMixed = /(^|\n)\s*import\s+([A-Za-z_$][\w$]*)\s*,\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/core(?:\/[^"']+)?)['"];?\s*/gm;
605
+ result = result.replace(reMixed, (_full, prefix, defName, specList, src) => {
606
+ if (isDeepCoreSubpath(src))
607
+ return _full;
608
+ const decl = `const { ${toDestructure(specList)} } = ${defName};`;
609
+ return `${prefix}import ${defName} from ${JSON.stringify(src)};\n${decl}\n`;
610
+ });
611
+ return result;
612
+ }
613
+ catch {
614
+ return code;
615
+ }
616
+ }
617
+ export function ensureDestructureRtImports(code) {
618
+ try {
619
+ let result = code;
620
+ const toDestructure = (specList) => specList
621
+ .split(',')
622
+ .map((s) => s.trim())
623
+ .filter(Boolean)
624
+ .map((seg) => {
625
+ const match = seg.split(/\s+as\s+/i);
626
+ return match.length === 2 ? `${match[0].trim()}: ${match[1].trim()}` : seg;
627
+ })
628
+ .join(', ');
629
+ const reNamed = /(^|\n)\s*import\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/rt(?:\/[\d]+)?)['"];?\s*/gm;
630
+ result = result.replace(reNamed, (_full, prefix, specList, src) => {
631
+ const tempName = `__ns_rt_ns_re`;
632
+ const decl = `const { ${toDestructure(specList)} } = ${tempName};`;
633
+ return `${prefix}import ${tempName} from ${JSON.stringify(src)};\n${decl}\n`;
634
+ });
635
+ const reMixed = /(^|\n)\s*import\s+([A-Za-z_$][\w$]*)\s*,\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/rt(?:\/[\d]+)?)['"];?\s*/gm;
636
+ result = result.replace(reMixed, (_full, prefix, defName, specList, src) => {
637
+ const decl = `const { ${toDestructure(specList)} } = ${defName};`;
638
+ return `${prefix}import ${defName} from ${JSON.stringify(src)};\n${decl}\n`;
639
+ });
640
+ return result;
641
+ }
642
+ catch {
643
+ return code;
644
+ }
645
+ }
646
+ export function dedupeRtNamedImportsAgainstDestructures(code) {
647
+ try {
648
+ let result = code;
649
+ const rtDestructureRE = /(^|\n)\s*const\s*\{([^}]+)\}\s*=\s*(__ns_rt_ns(?:\d+|_re))\s*;?/gm;
650
+ const rtBound = new Set();
651
+ let match;
652
+ while ((match = rtDestructureRE.exec(result)) !== null) {
653
+ const specList = String(match[2] || '');
654
+ specList
655
+ .split(',')
656
+ .map((s) => s.trim())
657
+ .filter(Boolean)
658
+ .forEach((seg) => {
659
+ const bind = seg.includes(':') ? seg.split(':')[1].trim() : seg;
660
+ if (bind)
661
+ rtBound.add(bind);
662
+ });
663
+ }
664
+ if (!rtBound.size)
665
+ return result;
666
+ const rtNamedImportRE = /(^|\n)\s*import\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/rt(?:\/[\d]+)?)['"];?\s*/gm;
667
+ const edits = [];
668
+ while ((match = rtNamedImportRE.exec(result)) !== null) {
669
+ const full = match[0];
670
+ const prefix = match[1] || '';
671
+ const specList = String(match[2] || '');
672
+ const src = match[3];
673
+ const kept = [];
674
+ specList
675
+ .split(',')
676
+ .map((s) => s.trim())
677
+ .filter(Boolean)
678
+ .forEach((seg) => {
679
+ const importedName = seg.split(/\s+as\s+/i)[0].trim();
680
+ if (!rtBound.has(importedName))
681
+ kept.push(seg);
682
+ });
683
+ let replacement = '';
684
+ if (kept.length) {
685
+ replacement = `${prefix}import { ${kept.join(', ')} } from ${JSON.stringify(src)};`;
686
+ }
687
+ else {
688
+ replacement = prefix || '';
689
+ }
690
+ edits.push({
691
+ start: rtNamedImportRE.lastIndex - full.length,
692
+ end: rtNamedImportRE.lastIndex,
693
+ text: replacement,
694
+ });
695
+ }
696
+ if (edits.length) {
697
+ edits
698
+ .sort((a, b) => b.start - a.start)
699
+ .forEach((edit) => {
700
+ result = result.slice(0, edit.start) + edit.text + result.slice(edit.end);
701
+ });
702
+ }
703
+ return result;
704
+ }
705
+ catch {
706
+ return code;
707
+ }
708
+ }
709
+ export function deduplicateLinkerImports(code) {
710
+ if (!code)
711
+ return code;
712
+ try {
713
+ const imports = collectTopLevelImportRecords(code);
714
+ if (!imports.length) {
715
+ return code;
716
+ }
717
+ const pkgUrlMap = new Map();
718
+ const pkgBindings = new Map();
719
+ for (const imp of imports) {
720
+ const url = imp.source;
721
+ if (!/^https?:\/\//.test(url) && !url.startsWith('/')) {
722
+ continue;
723
+ }
724
+ const nmIdx = url.lastIndexOf('/node_modules/');
725
+ if (nmIdx === -1)
726
+ continue;
727
+ const afterNm = url.substring(nmIdx + '/node_modules/'.length);
728
+ const parts = afterNm.split('/');
729
+ const pkg = parts[0].startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];
730
+ if (!pkgUrlMap.has(pkg))
731
+ pkgUrlMap.set(pkg, url);
732
+ if (imp.namedBindings.length) {
733
+ if (!pkgBindings.has(pkg))
734
+ pkgBindings.set(pkg, new Set());
735
+ for (const binding of imp.namedBindings) {
736
+ if (binding.importedName)
737
+ pkgBindings.get(pkg).add(binding.importedName);
738
+ }
739
+ }
740
+ }
741
+ if (pkgUrlMap.size === 0)
742
+ return code;
743
+ const edits = [];
744
+ for (const imp of imports) {
745
+ if (!imp.hasOnlyNamedSpecifiers) {
746
+ continue;
747
+ }
748
+ const specifier = imp.source;
749
+ if (specifier.startsWith('/') || specifier.startsWith('.') || specifier.startsWith('http')) {
750
+ continue;
751
+ }
752
+ const parts = specifier.split('/');
753
+ const pkg = specifier.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];
754
+ const url = pkgUrlMap.get(pkg);
755
+ if (!url) {
756
+ continue;
757
+ }
758
+ const existing = pkgBindings.get(pkg) || new Set();
759
+ const newBindings = imp.namedBindings.filter((binding) => !existing.has(binding.importedName));
760
+ if (newBindings.length === 0) {
761
+ edits.push({ start: imp.start, end: imp.end, text: '' });
762
+ continue;
763
+ }
764
+ if (newBindings.length === imp.namedBindings.length) {
765
+ continue;
766
+ }
767
+ for (const binding of newBindings) {
768
+ existing.add(binding.importedName);
769
+ }
770
+ edits.push({
771
+ start: imp.start,
772
+ end: imp.end,
773
+ text: `import { ${newBindings.map((binding) => binding.text).join(', ')} } from ${JSON.stringify(url)};`,
774
+ });
775
+ }
776
+ if (!edits.length) {
777
+ return code;
778
+ }
779
+ let next = code;
780
+ for (const edit of edits.sort((left, right) => right.start - left.start)) {
781
+ next = next.slice(0, edit.start) + edit.text + next.slice(edit.end);
782
+ }
783
+ return next;
784
+ }
785
+ catch {
786
+ return code;
787
+ }
788
+ }
789
+ export function wrapCommonJsModuleForDevice(code, absolutePath) {
790
+ if (!code)
791
+ return code;
792
+ try {
793
+ const hasExportDefault = /\bexport\s+default\b/.test(code) || /export\s*\{\s*default\s*(?:as\s*default)?\s*\}/.test(code);
794
+ const hasNamedExports = /\bexport\s+(?:const|let|var|function|class|async)\b/.test(code) || /\bexport\s*\{/.test(code);
795
+ const hasCjsExports = /\bmodule\s*\.\s*exports\b/.test(code) || /\bexports\s*\.\s*\w/.test(code);
796
+ if (hasExportDefault || hasNamedExports || !hasCjsExports) {
797
+ return code;
798
+ }
799
+ const namedExports = new Set();
800
+ const exportsRe = /\bexports\s*\.\s*([A-Za-z_$][\w$]*)\s*=/g;
801
+ let match;
802
+ while ((match = exportsRe.exec(code)) !== null) {
803
+ const name = match[1];
804
+ if (name !== '__esModule' && name !== 'default') {
805
+ namedExports.add(name);
806
+ }
807
+ }
808
+ const defPropRe = /Object\s*\.\s*defineProperty\s*\(\s*exports\s*,\s*['"]([^'"]+)['"]/g;
809
+ while ((match = defPropRe.exec(code)) !== null) {
810
+ const name = match[1];
811
+ if (name !== '__esModule' && name !== 'default') {
812
+ namedExports.add(name);
813
+ }
814
+ }
815
+ // Static enumeration only sees `exports.foo = ...` and `Object.defineProperty(exports, 'foo', ...)`.
816
+ // Real-world packages like lodash attach their entire surface to a function inside an IIFE and
817
+ // then `module.exports = thatFunction`. Static analysis returns zero in that case. To handle
818
+ // these modules we ALSO load the package in the dev-server's Node context (only when we have a
819
+ // node_modules path) and merge the runtime keys. See `helpers/cjs-named-exports.ts` for the
820
+ // reasoning and safety boundaries.
821
+ if (absolutePath) {
822
+ try {
823
+ for (const n of getCjsNamedExports(absolutePath)) {
824
+ namedExports.add(n);
825
+ }
826
+ }
827
+ catch {
828
+ /* fall through to whatever we caught statically */
829
+ }
830
+ }
831
+ let suffix = `\nvar __cjs_mod = module.exports;\nexport default __cjs_mod;\n`;
832
+ if (namedExports.size) {
833
+ const entries = Array.from(namedExports);
834
+ const temps = entries.map((name, i) => `var __cjs_e${i} = __cjs_mod[${JSON.stringify(name)}];`);
835
+ const reExports = entries.map((name, i) => `__cjs_e${i} as ${name}`);
836
+ suffix += `${temps.join(' ')}\nexport { ${reExports.join(', ')} };\n`;
837
+ }
838
+ const prelude = `var module = { exports: {} }; var exports = module.exports;\n` +
839
+ `var __ns_cjs_require_base = (typeof globalThis.__nsBaseRequire === 'function' ? globalThis.__nsBaseRequire : (typeof globalThis.__nsRequire === 'function' ? globalThis.__nsRequire : (typeof globalThis.require === 'function' ? globalThis.require : undefined)));\n` +
840
+ `var __ns_cjs_require_kind = (typeof globalThis.__nsBaseRequire === 'function' ? 'base-require' : (typeof globalThis.__nsRequire === 'function' ? 'vendor-require' : 'global-require'));\n` +
841
+ `var require = function(spec) {\n` +
842
+ ` if (!__ns_cjs_require_base) { throw new Error('require is not defined'); }\n` +
843
+ // Resolve relative specifiers against the HTTP-served module's URL
844
+ // before delegating to NS's runtime require. Keeps ./sibling and
845
+ // ../parent requires routable through the HTTP ESM loader rather
846
+ // than NS's filesystem-based require.
847
+ ` var __nsResolvedSpec = spec;\n` +
848
+ ` try {\n` +
849
+ ` if (typeof spec === 'string' && (spec.indexOf('./') === 0 || spec.indexOf('../') === 0)) {\n` +
850
+ ` var __nsParentUrl = (typeof import.meta !== 'undefined' && import.meta && typeof import.meta.url === 'string') ? import.meta.url : null;\n` +
851
+ ` if (__nsParentUrl) {\n` +
852
+ ` var __nsResolvedUrl = new URL(spec, __nsParentUrl);\n` +
853
+ ` if (!/\\.[A-Za-z0-9]+$/.test(__nsResolvedUrl.pathname.split('/').pop() || '')) {\n` +
854
+ ` __nsResolvedUrl.pathname = __nsResolvedUrl.pathname.replace(/\\/+$/, '') + '.js';\n` +
855
+ ` }\n` +
856
+ ` __nsResolvedSpec = __nsResolvedUrl.href;\n` +
857
+ ` }\n` +
858
+ ` }\n` +
859
+ ` } catch (e) {}\n` +
860
+ ` try { var __nsRecord = globalThis.__NS_RECORD_MODULE_PROVENANCE__; if (typeof __nsRecord === 'function') { __nsRecord(String(__nsResolvedSpec), { kind: __ns_cjs_require_kind, specifier: String(spec), url: __nsResolvedSpec !== spec ? __nsResolvedSpec : undefined, via: 'cjs-wrapper', parent: (typeof import.meta !== 'undefined' && import.meta && import.meta.url) ? import.meta.url : undefined }); } } catch (e) {}\n` +
861
+ ` var mod = __ns_cjs_require_base(__nsResolvedSpec);\n` +
862
+ ` try {\n` +
863
+ ` if (mod && (typeof mod === 'object' || typeof mod === 'function') && mod.default !== undefined) {\n` +
864
+ ` var keys = [];\n` +
865
+ ` try { keys = Object.keys(mod); } catch (e) {}\n` +
866
+ ` var defaultOnly = keys.length === 1 && keys[0] === 'default';\n` +
867
+ ` var esModuleOnly = keys.length === 2 && keys.indexOf('default') !== -1 && keys.indexOf('__esModule') !== -1;\n` +
868
+ ` if (mod.__esModule || defaultOnly || esModuleOnly) { return mod.default; }\n` +
869
+ ` }\n` +
870
+ ` } catch (e) {}\n` +
871
+ ` return mod;\n` +
872
+ `};\n`;
873
+ return `${prelude}${code}${suffix}`;
874
+ }
875
+ catch {
876
+ return code;
877
+ }
878
+ }
879
+ //# sourceMappingURL=websocket-served-module-helpers.js.map