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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (465) hide show
  1. package/README.md +51 -11
  2. package/bin/cli.cjs +8 -14
  3. package/configuration/angular.d.ts +34 -1
  4. package/configuration/angular.js +390 -165
  5. package/configuration/angular.js.map +1 -1
  6. package/configuration/base.js +244 -53
  7. package/configuration/base.js.map +1 -1
  8. package/configuration/javascript.js +14 -93
  9. package/configuration/javascript.js.map +1 -1
  10. package/configuration/react.js +41 -73
  11. package/configuration/react.js.map +1 -1
  12. package/configuration/solid.js +51 -6
  13. package/configuration/solid.js.map +1 -1
  14. package/configuration/typescript.js +12 -93
  15. package/configuration/typescript.js.map +1 -1
  16. package/helpers/app-components.d.ts +2 -1
  17. package/helpers/app-components.js.map +1 -1
  18. package/helpers/app-css-state.d.ts +8 -0
  19. package/helpers/app-css-state.js +8 -0
  20. package/helpers/app-css-state.js.map +1 -0
  21. package/helpers/bundler-context.d.ts +11 -0
  22. package/helpers/bundler-context.js +71 -0
  23. package/helpers/bundler-context.js.map +1 -0
  24. package/helpers/cli-flags.d.ts +12 -0
  25. package/helpers/cli-flags.js +34 -0
  26. package/helpers/cli-flags.js.map +1 -1
  27. package/helpers/css-platform-plugin.d.ts +14 -0
  28. package/helpers/css-platform-plugin.js +43 -25
  29. package/helpers/css-platform-plugin.js.map +1 -1
  30. package/helpers/dev-host.d.ts +360 -0
  31. package/helpers/dev-host.js +694 -0
  32. package/helpers/dev-host.js.map +1 -0
  33. package/helpers/dynamic-import-plugin.js +9 -4
  34. package/helpers/dynamic-import-plugin.js.map +1 -1
  35. package/helpers/esbuild-platform-resolver.js +4 -1
  36. package/helpers/esbuild-platform-resolver.js.map +1 -1
  37. package/helpers/external-configs.d.ts +10 -12
  38. package/helpers/external-configs.js +58 -35
  39. package/helpers/external-configs.js.map +1 -1
  40. package/helpers/global-defines.d.ts +100 -13
  41. package/helpers/global-defines.js +165 -28
  42. package/helpers/global-defines.js.map +1 -1
  43. package/helpers/hmr-scope.d.ts +26 -0
  44. package/helpers/hmr-scope.js +67 -0
  45. package/helpers/hmr-scope.js.map +1 -0
  46. package/helpers/init.js +0 -18
  47. package/helpers/init.js.map +1 -1
  48. package/helpers/logging.js +29 -1
  49. package/helpers/logging.js.map +1 -1
  50. package/helpers/main-entry.d.ts +4 -1
  51. package/helpers/main-entry.js +368 -53
  52. package/helpers/main-entry.js.map +1 -1
  53. package/helpers/nativeclass-esbuild-plugin.d.ts +2 -1
  54. package/helpers/nativeclass-esbuild-plugin.js +6 -1
  55. package/helpers/nativeclass-esbuild-plugin.js.map +1 -1
  56. package/helpers/nativeclass-transform.d.ts +13 -0
  57. package/helpers/nativeclass-transform.js +37 -7
  58. package/helpers/nativeclass-transform.js.map +1 -1
  59. package/helpers/nativeclass-transformer-plugin.d.ts +9 -2
  60. package/helpers/nativeclass-transformer-plugin.js +163 -15
  61. package/helpers/nativeclass-transformer-plugin.js.map +1 -1
  62. package/helpers/nativescript-package-resolver.js +10 -62
  63. package/helpers/nativescript-package-resolver.js.map +1 -1
  64. package/helpers/normalize-id.d.ts +42 -0
  65. package/helpers/normalize-id.js +60 -0
  66. package/helpers/normalize-id.js.map +1 -0
  67. package/helpers/ns-core-url.d.ts +29 -7
  68. package/helpers/ns-core-url.js +69 -12
  69. package/helpers/ns-core-url.js.map +1 -1
  70. package/helpers/optimize-deps.d.ts +16 -0
  71. package/helpers/optimize-deps.js +17 -0
  72. package/helpers/optimize-deps.js.map +1 -0
  73. package/helpers/package-platform-aliases.js +34 -49
  74. package/helpers/package-platform-aliases.js.map +1 -1
  75. package/helpers/platform-types.d.ts +2 -0
  76. package/helpers/platform-types.js +2 -0
  77. package/helpers/platform-types.js.map +1 -0
  78. package/helpers/postcss-platform-config.d.ts +17 -1
  79. package/helpers/postcss-platform-config.js +20 -37
  80. package/helpers/postcss-platform-config.js.map +1 -1
  81. package/helpers/project.d.ts +35 -0
  82. package/helpers/project.js +120 -2
  83. package/helpers/project.js.map +1 -1
  84. package/helpers/resolve-main-field-platform.d.ts +20 -0
  85. package/helpers/resolve-main-field-platform.js +49 -0
  86. package/helpers/resolve-main-field-platform.js.map +1 -0
  87. package/helpers/resolver.js +17 -2
  88. package/helpers/resolver.js.map +1 -1
  89. package/helpers/theme-core-plugins.js +1 -1
  90. package/helpers/theme-core-plugins.js.map +1 -1
  91. package/helpers/ts-config-paths.d.ts +32 -0
  92. package/helpers/ts-config-paths.js +156 -27
  93. package/helpers/ts-config-paths.js.map +1 -1
  94. package/helpers/typescript-check.d.ts +2 -1
  95. package/helpers/typescript-check.js +2 -2
  96. package/helpers/typescript-check.js.map +1 -1
  97. package/helpers/ui-registration.d.ts +21 -0
  98. package/helpers/ui-registration.js +156 -0
  99. package/helpers/ui-registration.js.map +1 -0
  100. package/helpers/utils.d.ts +9 -0
  101. package/helpers/utils.js +22 -2
  102. package/helpers/utils.js.map +1 -1
  103. package/helpers/vite-package-version.d.ts +7 -0
  104. package/helpers/vite-package-version.js +44 -0
  105. package/helpers/vite-package-version.js.map +1 -0
  106. package/helpers/workers.d.ts +48 -19
  107. package/helpers/workers.js +662 -13
  108. package/helpers/workers.js.map +1 -1
  109. package/hmr/client/css-handler.d.ts +2 -1
  110. package/hmr/client/css-handler.js +50 -26
  111. package/hmr/client/css-handler.js.map +1 -1
  112. package/hmr/client/css-update-overlay.d.ts +18 -0
  113. package/hmr/client/css-update-overlay.js +27 -0
  114. package/hmr/client/css-update-overlay.js.map +1 -0
  115. package/hmr/client/framework-client-strategy.d.ts +79 -0
  116. package/hmr/client/framework-client-strategy.js +19 -0
  117. package/hmr/client/framework-client-strategy.js.map +1 -0
  118. package/hmr/client/hmr-pending-overlay.d.ts +0 -14
  119. package/hmr/client/hmr-pending-overlay.js +14 -4
  120. package/hmr/client/hmr-pending-overlay.js.map +1 -1
  121. package/hmr/client/hot-context.d.ts +67 -0
  122. package/hmr/client/hot-context.js +284 -0
  123. package/hmr/client/hot-context.js.map +1 -0
  124. package/hmr/client/index.js +922 -273
  125. package/hmr/client/index.js.map +1 -1
  126. package/hmr/client/utils.d.ts +2 -1
  127. package/hmr/client/utils.js +111 -99
  128. package/hmr/client/utils.js.map +1 -1
  129. package/hmr/entry-runtime.d.ts +2 -1
  130. package/hmr/entry-runtime.js +279 -71
  131. package/hmr/entry-runtime.js.map +1 -1
  132. package/hmr/frameworks/angular/build/angular-linker.d.ts +12 -0
  133. package/hmr/frameworks/angular/build/angular-linker.js +109 -0
  134. package/hmr/frameworks/angular/build/angular-linker.js.map +1 -0
  135. package/hmr/frameworks/angular/build/inject-component-hmr-registration.d.ts +112 -0
  136. package/hmr/frameworks/angular/build/inject-component-hmr-registration.js +291 -0
  137. package/hmr/frameworks/angular/build/inject-component-hmr-registration.js.map +1 -0
  138. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.d.ts +75 -0
  139. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js +221 -0
  140. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js.map +1 -0
  141. package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.js +1 -170
  142. package/hmr/frameworks/angular/build/inline-decorator-component-templates.js.map +1 -0
  143. package/hmr/frameworks/angular/build/js-lexer.d.ts +4 -0
  144. package/{helpers/angular/synthesize-decorator-ctor-parameters.js → hmr/frameworks/angular/build/js-lexer.js} +22 -96
  145. package/hmr/frameworks/angular/build/js-lexer.js.map +1 -0
  146. package/hmr/frameworks/angular/build/shared-linker.d.ts +39 -0
  147. package/hmr/frameworks/angular/build/shared-linker.js +128 -0
  148. package/hmr/frameworks/angular/build/shared-linker.js.map +1 -0
  149. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js +88 -0
  150. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js.map +1 -0
  151. package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.js +1 -174
  152. package/hmr/frameworks/angular/build/synthesize-injectable-factories.js.map +1 -0
  153. package/{helpers/angular → hmr/frameworks/angular/build}/util.d.ts +1 -0
  154. package/hmr/frameworks/angular/build/util.js +155 -0
  155. package/hmr/frameworks/angular/build/util.js.map +1 -0
  156. package/hmr/frameworks/angular/client/index.js +542 -175
  157. package/hmr/frameworks/angular/client/index.js.map +1 -1
  158. package/hmr/frameworks/angular/client/strategy.d.ts +9 -0
  159. package/hmr/frameworks/angular/client/strategy.js +19 -0
  160. package/hmr/frameworks/angular/client/strategy.js.map +1 -0
  161. package/hmr/frameworks/angular/server/angular-root-component.d.ts +79 -0
  162. package/hmr/frameworks/angular/server/angular-root-component.js +149 -0
  163. package/hmr/frameworks/angular/server/angular-root-component.js.map +1 -0
  164. package/hmr/frameworks/angular/server/linker.js +1 -4
  165. package/hmr/frameworks/angular/server/linker.js.map +1 -1
  166. package/hmr/frameworks/angular/server/strategy.js +458 -12
  167. package/hmr/frameworks/angular/server/strategy.js.map +1 -1
  168. package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.js +2 -2
  169. package/hmr/frameworks/angular/server/websocket-angular-entry.js.map +1 -0
  170. package/hmr/{server → frameworks/angular/server}/websocket-angular-hot-update.d.ts +14 -11
  171. package/hmr/{server → frameworks/angular/server}/websocket-angular-hot-update.js +108 -111
  172. package/hmr/frameworks/angular/server/websocket-angular-hot-update.js.map +1 -0
  173. package/hmr/frameworks/react/server/strategy.d.ts +2 -0
  174. package/hmr/frameworks/react/server/strategy.js +230 -0
  175. package/hmr/frameworks/react/server/strategy.js.map +1 -0
  176. package/hmr/frameworks/solid/build/solid-jsx-deps.d.ts +15 -0
  177. package/hmr/frameworks/solid/build/solid-jsx-deps.js +178 -0
  178. package/hmr/frameworks/solid/build/solid-jsx-deps.js.map +1 -0
  179. package/hmr/frameworks/solid/client/app-runtime.d.ts +68 -0
  180. package/hmr/frameworks/solid/client/app-runtime.js +246 -0
  181. package/hmr/frameworks/solid/client/app-runtime.js.map +1 -0
  182. package/hmr/frameworks/solid/server/strategy.js +291 -16
  183. package/hmr/frameworks/solid/server/strategy.js.map +1 -1
  184. package/hmr/frameworks/typescript/server/strategy.js +38 -14
  185. package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
  186. package/hmr/frameworks/vue/client/dep-propagation.d.ts +44 -0
  187. package/hmr/frameworks/vue/client/dep-propagation.js +148 -0
  188. package/hmr/frameworks/vue/client/dep-propagation.js.map +1 -0
  189. package/hmr/frameworks/vue/client/index.d.ts +9 -0
  190. package/hmr/frameworks/vue/client/index.js +251 -247
  191. package/hmr/frameworks/vue/client/index.js.map +1 -1
  192. package/hmr/frameworks/vue/client/strategy.d.ts +33 -0
  193. package/hmr/frameworks/vue/client/strategy.js +157 -0
  194. package/hmr/frameworks/vue/client/strategy.js.map +1 -0
  195. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.d.ts +49 -0
  196. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js +142 -0
  197. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js.map +1 -0
  198. package/hmr/frameworks/vue/server/compiler.d.ts +3 -1
  199. package/hmr/frameworks/vue/server/compiler.js +3 -1
  200. package/hmr/frameworks/vue/server/compiler.js.map +1 -1
  201. package/hmr/frameworks/vue/server/sfc-route-assemble.d.ts +7 -0
  202. package/hmr/frameworks/vue/server/sfc-route-assemble.js +823 -0
  203. package/hmr/frameworks/vue/server/sfc-route-assemble.js.map +1 -0
  204. package/hmr/frameworks/vue/server/sfc-route-meta.d.ts +7 -0
  205. package/hmr/frameworks/vue/server/sfc-route-meta.js +80 -0
  206. package/hmr/frameworks/vue/server/sfc-route-meta.js.map +1 -0
  207. package/hmr/frameworks/vue/server/sfc-route-serve.d.ts +8 -0
  208. package/hmr/frameworks/vue/server/sfc-route-serve.js +462 -0
  209. package/hmr/frameworks/vue/server/sfc-route-serve.js.map +1 -0
  210. package/hmr/frameworks/vue/server/sfc-route-shared.d.ts +45 -0
  211. package/hmr/frameworks/vue/server/sfc-route-shared.js +105 -0
  212. package/hmr/frameworks/vue/server/sfc-route-shared.js.map +1 -0
  213. package/hmr/frameworks/vue/server/strategy.d.ts +35 -0
  214. package/hmr/frameworks/vue/server/strategy.js +286 -7
  215. package/hmr/frameworks/vue/server/strategy.js.map +1 -1
  216. package/hmr/frameworks/vue/server/websocket-sfc.d.ts +15 -0
  217. package/hmr/frameworks/vue/server/websocket-sfc.js +20 -0
  218. package/hmr/frameworks/vue/server/websocket-sfc.js.map +1 -0
  219. package/hmr/helpers/ast-normalizer.d.ts +3 -1
  220. package/hmr/helpers/ast-normalizer.js +77 -10
  221. package/hmr/helpers/ast-normalizer.js.map +1 -1
  222. package/hmr/helpers/cjs-named-exports.d.ts +23 -0
  223. package/hmr/helpers/cjs-named-exports.js +152 -0
  224. package/hmr/helpers/cjs-named-exports.js.map +1 -0
  225. package/hmr/helpers/package-exports.d.ts +16 -0
  226. package/hmr/helpers/package-exports.js +396 -0
  227. package/hmr/helpers/package-exports.js.map +1 -0
  228. package/hmr/helpers/vendor-rewrite.d.ts +1 -1
  229. package/hmr/helpers/vendor-rewrite.js +5 -3
  230. package/hmr/helpers/vendor-rewrite.js.map +1 -1
  231. package/hmr/server/boot-archive-route.d.ts +40 -0
  232. package/hmr/server/boot-archive-route.js +154 -0
  233. package/hmr/server/boot-archive-route.js.map +1 -0
  234. package/hmr/server/boot-closure-route.d.ts +49 -0
  235. package/hmr/server/boot-closure-route.js +144 -0
  236. package/hmr/server/boot-closure-route.js.map +1 -0
  237. package/hmr/server/boot-recording.d.ts +58 -0
  238. package/hmr/server/boot-recording.js +228 -0
  239. package/hmr/server/boot-recording.js.map +1 -0
  240. package/hmr/server/constants.js +20 -5
  241. package/hmr/server/constants.js.map +1 -1
  242. package/hmr/server/core-bundle.d.ts +140 -0
  243. package/hmr/server/core-bundle.js +614 -0
  244. package/hmr/server/core-bundle.js.map +1 -0
  245. package/hmr/server/core-sanitize.d.ts +86 -7
  246. package/hmr/server/core-sanitize.js +170 -45
  247. package/hmr/server/core-sanitize.js.map +1 -1
  248. package/hmr/server/css-device-module.d.ts +28 -0
  249. package/hmr/server/css-device-module.js +44 -0
  250. package/hmr/server/css-device-module.js.map +1 -0
  251. package/hmr/server/deps-bundle.d.ts +218 -0
  252. package/hmr/server/deps-bundle.js +998 -0
  253. package/hmr/server/deps-bundle.js.map +1 -0
  254. package/hmr/server/device-transform-helpers.d.ts +24 -0
  255. package/hmr/server/device-transform-helpers.js +408 -0
  256. package/hmr/server/device-transform-helpers.js.map +1 -0
  257. package/hmr/server/framework-strategy.d.ts +113 -11
  258. package/hmr/server/hmr-module-graph.d.ts +37 -0
  259. package/hmr/server/hmr-module-graph.js +215 -0
  260. package/hmr/server/hmr-module-graph.js.map +1 -0
  261. package/hmr/server/import-map.d.ts +13 -4
  262. package/hmr/server/import-map.js +94 -47
  263. package/hmr/server/import-map.js.map +1 -1
  264. package/hmr/server/index.js +7 -16
  265. package/hmr/server/index.js.map +1 -1
  266. package/hmr/server/ns-core-cjs-shape.d.ts +2 -4
  267. package/hmr/server/ns-core-cjs-shape.js +4 -6
  268. package/hmr/server/ns-core-cjs-shape.js.map +1 -1
  269. package/hmr/server/ns-m-response-memo.d.ts +10 -0
  270. package/hmr/server/ns-m-response-memo.js +33 -0
  271. package/hmr/server/ns-m-response-memo.js.map +1 -0
  272. package/hmr/server/ns-rt-bridge.d.ts +51 -0
  273. package/hmr/server/ns-rt-bridge.js +131 -0
  274. package/hmr/server/ns-rt-bridge.js.map +1 -0
  275. package/hmr/server/ns-rt-route.d.ts +5 -0
  276. package/hmr/server/ns-rt-route.js +39 -0
  277. package/hmr/server/ns-rt-route.js.map +1 -0
  278. package/hmr/server/perf-instrumentation.d.ts +6 -10
  279. package/hmr/server/perf-instrumentation.js +5 -6
  280. package/hmr/server/perf-instrumentation.js.map +1 -1
  281. package/hmr/server/process-code-for-device.d.ts +30 -0
  282. package/hmr/server/process-code-for-device.js +791 -0
  283. package/hmr/server/process-code-for-device.js.map +1 -0
  284. package/hmr/server/require-guard.d.ts +1 -0
  285. package/hmr/server/require-guard.js +12 -0
  286. package/hmr/server/require-guard.js.map +1 -0
  287. package/hmr/server/rewrite-imports.d.ts +2 -0
  288. package/hmr/server/rewrite-imports.js +638 -0
  289. package/hmr/server/rewrite-imports.js.map +1 -0
  290. package/hmr/server/route-helpers.d.ts +7 -0
  291. package/hmr/server/route-helpers.js +13 -0
  292. package/hmr/server/route-helpers.js.map +1 -0
  293. package/hmr/server/server-origin.d.ts +2 -0
  294. package/hmr/server/server-origin.js +83 -0
  295. package/hmr/server/server-origin.js.map +1 -0
  296. package/hmr/server/shared-transform-request.js +1 -2
  297. package/hmr/server/shared-transform-request.js.map +1 -1
  298. package/hmr/server/transform-cache-invalidation.d.ts +37 -0
  299. package/hmr/server/transform-cache-invalidation.js +156 -0
  300. package/hmr/server/transform-cache-invalidation.js.map +1 -0
  301. package/hmr/server/vendor-bare-module-shims.d.ts +4 -0
  302. package/hmr/server/vendor-bare-module-shims.js +80 -0
  303. package/hmr/server/vendor-bare-module-shims.js.map +1 -0
  304. package/hmr/server/vite-plugin.d.ts +1 -0
  305. package/hmr/server/vite-plugin.js +180 -54
  306. package/hmr/server/vite-plugin.js.map +1 -1
  307. package/hmr/server/websocket-core-bridge.d.ts +51 -4
  308. package/hmr/server/websocket-core-bridge.js +62 -54
  309. package/hmr/server/websocket-core-bridge.js.map +1 -1
  310. package/hmr/server/websocket-css-hot-update.d.ts +33 -0
  311. package/hmr/server/websocket-css-hot-update.js +65 -0
  312. package/hmr/server/websocket-css-hot-update.js.map +1 -0
  313. package/hmr/server/websocket-device-transform.d.ts +3 -0
  314. package/hmr/server/websocket-device-transform.js +7 -0
  315. package/hmr/server/websocket-device-transform.js.map +1 -0
  316. package/hmr/server/websocket-hmr-pending.d.ts +3 -9
  317. package/hmr/server/websocket-hmr-pending.js +1 -1
  318. package/hmr/server/websocket-hmr-pending.js.map +1 -1
  319. package/hmr/server/websocket-hot-update.d.ts +77 -0
  320. package/hmr/server/websocket-hot-update.js +360 -0
  321. package/hmr/server/websocket-hot-update.js.map +1 -0
  322. package/hmr/server/websocket-import-map-route.d.ts +15 -0
  323. package/hmr/server/websocket-import-map-route.js +50 -0
  324. package/hmr/server/websocket-import-map-route.js.map +1 -0
  325. package/hmr/server/websocket-module-bindings.js +3 -3
  326. package/hmr/server/websocket-module-bindings.js.map +1 -1
  327. package/hmr/server/websocket-module-specifiers.d.ts +66 -2
  328. package/hmr/server/websocket-module-specifiers.js +191 -20
  329. package/hmr/server/websocket-module-specifiers.js.map +1 -1
  330. package/hmr/server/websocket-ns-core.d.ts +34 -0
  331. package/hmr/server/websocket-ns-core.js +414 -0
  332. package/hmr/server/websocket-ns-core.js.map +1 -0
  333. package/hmr/server/websocket-ns-entry.d.ts +21 -0
  334. package/hmr/server/websocket-ns-entry.js +164 -0
  335. package/hmr/server/websocket-ns-entry.js.map +1 -0
  336. package/hmr/server/websocket-ns-m-paths.d.ts +1 -3
  337. package/hmr/server/websocket-ns-m-paths.js +25 -82
  338. package/hmr/server/websocket-ns-m-paths.js.map +1 -1
  339. package/hmr/server/websocket-ns-m-request.d.ts +11 -1
  340. package/hmr/server/websocket-ns-m-request.js +17 -9
  341. package/hmr/server/websocket-ns-m-request.js.map +1 -1
  342. package/hmr/server/websocket-ns-m.d.ts +52 -0
  343. package/hmr/server/websocket-ns-m.js +835 -0
  344. package/hmr/server/websocket-ns-m.js.map +1 -0
  345. package/hmr/server/websocket-served-module-helpers.d.ts +50 -4
  346. package/hmr/server/websocket-served-module-helpers.js +384 -86
  347. package/hmr/server/websocket-served-module-helpers.js.map +1 -1
  348. package/hmr/server/websocket-txn.js +6 -9
  349. package/hmr/server/websocket-txn.js.map +1 -1
  350. package/hmr/server/websocket-vendor-unifier.d.ts +0 -1
  351. package/hmr/server/websocket-vendor-unifier.js +4 -9
  352. package/hmr/server/websocket-vendor-unifier.js.map +1 -1
  353. package/hmr/server/websocket.d.ts +7 -39
  354. package/hmr/server/websocket.js +643 -6716
  355. package/hmr/server/websocket.js.map +1 -1
  356. package/hmr/shared/ns-globals.d.ts +108 -0
  357. package/hmr/shared/ns-globals.js +28 -0
  358. package/hmr/shared/ns-globals.js.map +1 -0
  359. package/hmr/shared/protocol.d.ts +145 -0
  360. package/hmr/shared/protocol.js +28 -0
  361. package/hmr/shared/protocol.js.map +1 -0
  362. package/hmr/shared/runtime/boot-archive-format.d.ts +16 -0
  363. package/hmr/shared/runtime/boot-archive-format.js +31 -0
  364. package/hmr/shared/runtime/boot-archive-format.js.map +1 -0
  365. package/hmr/shared/runtime/boot-complete.d.ts +14 -0
  366. package/hmr/shared/runtime/boot-complete.js +32 -0
  367. package/hmr/shared/runtime/boot-complete.js.map +1 -0
  368. package/hmr/shared/runtime/boot-placeholder-ui.d.ts +69 -0
  369. package/hmr/shared/runtime/boot-placeholder-ui.js +101 -0
  370. package/hmr/shared/runtime/boot-placeholder-ui.js.map +1 -0
  371. package/hmr/shared/runtime/boot-progress.d.ts +44 -0
  372. package/hmr/shared/runtime/boot-progress.js +134 -0
  373. package/hmr/shared/runtime/boot-progress.js.map +1 -0
  374. package/hmr/shared/runtime/boot-timeline.d.ts +2 -1
  375. package/hmr/shared/runtime/boot-timeline.js +9 -22
  376. package/hmr/shared/runtime/boot-timeline.js.map +1 -1
  377. package/hmr/shared/runtime/browser-runtime-contract.d.ts +53 -22
  378. package/hmr/shared/runtime/browser-runtime-contract.js +6 -9
  379. package/hmr/shared/runtime/browser-runtime-contract.js.map +1 -1
  380. package/hmr/shared/runtime/dev-overlay-snapshots.d.ts +31 -0
  381. package/hmr/shared/runtime/dev-overlay-snapshots.js +324 -0
  382. package/hmr/shared/runtime/dev-overlay-snapshots.js.map +1 -0
  383. package/hmr/shared/runtime/dev-overlay.d.ts +76 -30
  384. package/hmr/shared/runtime/dev-overlay.js +767 -408
  385. package/hmr/shared/runtime/dev-overlay.js.map +1 -1
  386. package/hmr/shared/runtime/global-scope.d.ts +18 -0
  387. package/hmr/shared/runtime/global-scope.js +21 -0
  388. package/hmr/shared/runtime/global-scope.js.map +1 -0
  389. package/hmr/shared/runtime/hooks.js +2 -1
  390. package/hmr/shared/runtime/hooks.js.map +1 -1
  391. package/hmr/shared/runtime/http-only-boot.js +7 -6
  392. package/hmr/shared/runtime/http-only-boot.js.map +1 -1
  393. package/hmr/shared/runtime/module-provenance.js +4 -6
  394. package/hmr/shared/runtime/module-provenance.js.map +1 -1
  395. package/hmr/shared/runtime/root-placeholder-view.d.ts +19 -0
  396. package/hmr/shared/runtime/root-placeholder-view.js +311 -0
  397. package/hmr/shared/runtime/root-placeholder-view.js.map +1 -0
  398. package/hmr/shared/runtime/root-placeholder.js +398 -204
  399. package/hmr/shared/runtime/root-placeholder.js.map +1 -1
  400. package/hmr/shared/runtime/session-bootstrap.js +274 -55
  401. package/hmr/shared/runtime/session-bootstrap.js.map +1 -1
  402. package/hmr/shared/runtime/vendor-bootstrap.js +3 -10
  403. package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
  404. package/hmr/shared/vendor/manifest-collect.d.ts +4 -0
  405. package/hmr/shared/vendor/manifest-collect.js +549 -0
  406. package/hmr/shared/vendor/manifest-collect.js.map +1 -0
  407. package/hmr/shared/vendor/manifest-loader.d.ts +2 -1
  408. package/hmr/shared/vendor/manifest-loader.js +5 -3
  409. package/hmr/shared/vendor/manifest-loader.js.map +1 -1
  410. package/hmr/shared/vendor/manifest.d.ts +1 -7
  411. package/hmr/shared/vendor/manifest.js +136 -825
  412. package/hmr/shared/vendor/manifest.js.map +1 -1
  413. package/hmr/shared/vendor/registry.d.ts +2 -0
  414. package/hmr/shared/vendor/registry.js +14 -0
  415. package/hmr/shared/vendor/registry.js.map +1 -1
  416. package/hmr/shared/vendor/vendor-device-shim.d.ts +1 -0
  417. package/hmr/shared/vendor/vendor-device-shim.js +208 -0
  418. package/hmr/shared/vendor/vendor-device-shim.js.map +1 -0
  419. package/hmr/shared/vendor/vendor-esbuild-plugins.d.ts +76 -0
  420. package/hmr/shared/vendor/vendor-esbuild-plugins.js +401 -0
  421. package/hmr/shared/vendor/vendor-esbuild-plugins.js.map +1 -0
  422. package/hmr/vendor-bootstrap.d.ts +1 -3
  423. package/hmr/vendor-bootstrap.js +4 -6
  424. package/hmr/vendor-bootstrap.js.map +1 -1
  425. package/index.d.ts +1 -0
  426. package/index.js +5 -0
  427. package/index.js.map +1 -1
  428. package/package.json +65 -11
  429. package/runtime/core-aliases-early.js +25 -55
  430. package/runtime/core-aliases-early.js.map +1 -1
  431. package/shims/react-jsx-runtime.d.ts +4 -0
  432. package/shims/react-jsx-runtime.js +61 -0
  433. package/shims/react-jsx-runtime.js.map +1 -0
  434. package/helpers/angular/angular-linker.d.ts +0 -13
  435. package/helpers/angular/angular-linker.js +0 -194
  436. package/helpers/angular/angular-linker.js.map +0 -1
  437. package/helpers/angular/inline-decorator-component-templates.js.map +0 -1
  438. package/helpers/angular/shared-linker.d.ts +0 -11
  439. package/helpers/angular/shared-linker.js +0 -75
  440. package/helpers/angular/shared-linker.js.map +0 -1
  441. package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +0 -1
  442. package/helpers/angular/synthesize-injectable-factories.js.map +0 -1
  443. package/helpers/angular/util.js +0 -67
  444. package/helpers/angular/util.js.map +0 -1
  445. package/helpers/prelink-angular.d.ts +0 -2
  446. package/helpers/prelink-angular.js +0 -117
  447. package/helpers/prelink-angular.js.map +0 -1
  448. package/hmr/server/websocket-angular-entry.js.map +0 -1
  449. package/hmr/server/websocket-angular-hot-update.js.map +0 -1
  450. package/hmr/server/websocket-ns-m-finalize.d.ts +0 -22
  451. package/hmr/server/websocket-ns-m-finalize.js +0 -88
  452. package/hmr/server/websocket-ns-m-finalize.js.map +0 -1
  453. package/hmr/server/websocket-runtime-compat.d.ts +0 -19
  454. package/hmr/server/websocket-runtime-compat.js +0 -286
  455. package/hmr/server/websocket-runtime-compat.js.map +0 -1
  456. package/hmr/server/websocket-vue-sfc.d.ts +0 -27
  457. package/hmr/server/websocket-vue-sfc.js +0 -1114
  458. package/hmr/server/websocket-vue-sfc.js.map +0 -1
  459. package/transformers/NativeClass/index.d.ts +0 -2
  460. package/transformers/NativeClass/index.js +0 -222
  461. package/transformers/NativeClass/index.js.map +0 -1
  462. /package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.d.ts +0 -0
  463. /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-decorator-ctor-parameters.d.ts +0 -0
  464. /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.d.ts +0 -0
  465. /package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.d.ts +0 -0
@@ -1,7 +1,98 @@
1
1
  import path from 'path';
2
+ import { createRequire } from 'node:module';
2
3
  import { nsConfigToJson, resolveNativeScriptPlatformFile } from './utils.js';
3
- export function getWorkerPlugins(platform) {
4
- return [
4
+ import { createTsConfigPathsResolver, getTsConfigData } from './ts-config-paths.js';
5
+ import { packagePlatformResolverPlugin } from './package-platform-aliases.js';
6
+ import { nativescriptPackageResolver } from './nativescript-package-resolver.js';
7
+ import { findMonorepoWorkspaceRoot, getProjectRootPath } from './project.js';
8
+ import { normalizeModuleId } from './normalize-id.js';
9
+ const nodeRequire = createRequire(import.meta.url);
10
+ // Stub out webpack-style `nativescript-worker-loader!./worker.js` imports.
11
+ // Some packages (e.g. `nativescript-sqlite-commercial`) still ship a webpack 4
12
+ // branch like:
13
+ // if (global.TNS_WEBPACK >= 5) { worker = new Worker("./worker.js"); }
14
+ // else { require("nativescript-worker-loader!./worker.js"); }
15
+ // At runtime under @nativescript/vite, `global.TNS_WEBPACK` is undefined so the
16
+ // loader-prefix branch is never executed — but Rolldown still statically scans
17
+ // it and fails to resolve the webpack-only specifier. Returning a virtual stub
18
+ // module satisfies the static graph without touching runtime semantics.
19
+ const NS_WORKER_LOADER_STUB_ID = '\0ns-worker-loader-stub';
20
+ export function nativescriptWorkerLoaderStubPlugin() {
21
+ return {
22
+ name: 'nativescript-worker-loader-stub',
23
+ enforce: 'pre',
24
+ resolveId(id) {
25
+ if (typeof id === 'string' && id.startsWith('nativescript-worker-loader!')) {
26
+ return NS_WORKER_LOADER_STUB_ID;
27
+ }
28
+ return null;
29
+ },
30
+ load(id) {
31
+ if (id === NS_WORKER_LOADER_STUB_ID) {
32
+ // The default export is a constructor — emulate `new SqliteWorker()`
33
+ // so the legacy code path doesn't crash if it ever runs accidentally.
34
+ return ['const message = "nativescript-worker-loader! is a webpack-only loader prefix and is not supported under Vite. Update the calling package to use `new Worker(new URL(...))` for worker entry points.";', 'function NSWorkerLoaderStub() { throw new Error(message); }', 'export default NSWorkerLoaderStub;'].join('\n');
35
+ }
36
+ return null;
37
+ },
38
+ };
39
+ }
40
+ /**
41
+ * Rewrite every code-level `import.meta` usage in a worker module so the
42
+ * emitted classic script can compile.
43
+ *
44
+ * Workers are emitted as classic scripts (the NS worker bootstrap `require()`s
45
+ * them), where ANY code-level `import.meta` token is a compile-time
46
+ * SyntaxError — the runtime reports "Cannot compile script" the moment the
47
+ * worker starts, so the failure looks arbitrary per-worker. Beyond the
48
+ * `.url`/`.dirname` static substitutions, HMR helpers pulled into worker
49
+ * graphs (e.g. @nativescript/angular's hmr view-cache) read `import.meta.hot`
50
+ * / `import.meta["hot"]` / `import.meta["webpackHot"]` defensively behind
51
+ * try/catch — every remaining member access is rewritten to `(undefined)`;
52
+ * workers never have HMR.
53
+ *
54
+ * Bare `import.meta` tokens (no member access) are left alone on purpose:
55
+ * every observed occurrence lives inside string literals (e.g. acorn's parser
56
+ * error messages when a JS parser is bundled into a worker), where they are
57
+ * harmless and rewriting would corrupt library data.
58
+ *
59
+ * Returns `null` when the module contains no `import.meta` at all. None of
60
+ * the replacements add or remove lines, so existing line-level mappings stay
61
+ * valid — the explicit `map: null` also keeps Rolldown from flagging
62
+ * SOURCEMAP_BROKEN on every worker chunk.
63
+ */
64
+ export function neutralizeWorkerImportMeta(code) {
65
+ if (!code.includes('import.meta')) {
66
+ return null;
67
+ }
68
+ const rewritten = code
69
+ .replace(/import\.meta\.dirname/g, '""')
70
+ .replace(/import\.meta\.url/g, '"file:///app/"')
71
+ // import.meta["hot"], import.meta['webpackHot'], ...
72
+ .replace(/import\.meta\s*\[\s*(['"])[^'"\]]*\1\s*\]/g, '(undefined)')
73
+ // import.meta.hot, import.meta.env, ...
74
+ .replace(/import\.meta\.\w+/g, '(undefined)');
75
+ return { code: rewritten, map: null };
76
+ }
77
+ // Worker bundles run as separate Rolldown builds and do NOT inherit `config.plugins`
78
+ // at build time (see https://vite.dev/config/worker-options#worker-plugins). To match
79
+ // the main bundle's module resolution behavior, mirror the bare-specifier resolvers
80
+ // that the main config registers — most importantly the tsconfig `paths` resolver,
81
+ // without which workspace path aliases (e.g. `@scope/lib/util`) fail to resolve in
82
+ // any code reachable from a `new Worker(new URL(...))` entry point.
83
+ export function getWorkerPlugins(platformOrOpts) {
84
+ const opts = typeof platformOrOpts === 'string' ? { platform: platformOrOpts } : platformOrOpts;
85
+ const { platform, verbose } = opts;
86
+ // Reuse the same tsconfig data the main config does. `getTsConfigData` is internally
87
+ // memoized by config path, so this is essentially free on subsequent calls.
88
+ const tsConfig = getTsConfigData({ platform, verbose });
89
+ const tsConfigResolver = createTsConfigPathsResolver({
90
+ paths: tsConfig.paths,
91
+ baseUrl: tsConfig.baseUrl,
92
+ platform,
93
+ verbose,
94
+ });
95
+ const plugins = [
5
96
  // Handle ~/package.json virtual module for workers
6
97
  {
7
98
  name: 'worker-virtual-package-json',
@@ -37,7 +128,9 @@ export function getWorkerPlugins(platform) {
37
128
  // Use the existing NativeScript platform file resolver
38
129
  const platformResolvedFile = resolveNativeScriptPlatformFile(testPath, platform);
39
130
  if (platformResolvedFile) {
40
- return platformResolvedFile;
131
+ // Canonicalize so the worker bundle dedupes core the same way
132
+ // the main bundle does (forward slash + uppercase Windows drive).
133
+ return normalizeModuleId(platformResolvedFile);
41
134
  }
42
135
  }
43
136
  return null;
@@ -49,18 +142,562 @@ export function getWorkerPlugins(platform) {
49
142
  {
50
143
  name: 'worker-import-meta-handler',
51
144
  transform(code, id) {
52
- // Replace import.meta.dirname with a static value for workers
53
- if (code.includes('import.meta.dirname')) {
54
- code = code.replace(/import\.meta\.dirname/g, '""');
55
- }
56
- // Replace import.meta.url with a static value for workers
57
- if (code.includes('import.meta.url')) {
58
- code = code.replace(/import\.meta\.url/g, '"file:///app/"');
59
- }
60
- return code;
145
+ return neutralizeWorkerImportMeta(code);
61
146
  },
62
147
  },
63
148
  ];
149
+ // Mirror the main-config bare-specifier resolvers for workers. Without these,
150
+ // workspace tsconfig paths and platform-specific package mains fail to resolve
151
+ // when code is pulled into a worker bundle.
152
+ if (tsConfigResolver) {
153
+ plugins.push(tsConfigResolver);
154
+ }
155
+ plugins.push(packagePlatformResolverPlugin({ tsConfig, platform, verbose }));
156
+ plugins.push(nativescriptPackageResolver(platform));
157
+ plugins.push(nativescriptWorkerLoaderStubPlugin());
158
+ return plugins;
159
+ }
160
+ // In Vite dev/HMR mode, Vite's built-in `workerImportMetaUrlPlugin` rewrites
161
+ // `new Worker(new URL('./foo.worker', import.meta.url))` into
162
+ // `new Worker(new URL(/* @vite-ignore */"/src/.../foo.worker.ts?worker_file&type=classic", '' + import.meta.url))`.
163
+ // That output breaks under NativeScript for two independent reasons:
164
+ //
165
+ // 1. TypeError on `new URL(spec, '' + import.meta.url)`. The iOS V8 runtime's
166
+ // `InitializeImportMetaObject` callback (in NativeScript/runtime/Runtime.mm)
167
+ // blindly prefixes the module's registry key with `file://`. For HTTP-served
168
+ // HMR modules the key is already `http://localhost:5173/ns/m/...`, so the
169
+ // callback emits `import.meta.url = "file://http://localhost:5173/ns/m/..."`
170
+ // — a malformed URL that fails the WHATWG URL parser's base check. Other
171
+ // `new URL(spec, import.meta.url)` sites in the served pipeline are wrapped
172
+ // in `try/catch` and silently fall through; the worker creation site is not.
173
+ //
174
+ // 2. Pipeline routing mismatch.
175
+ // Even with a valid `import.meta.url`, the resolved URL points at Vite's
176
+ // `?worker_file&type=classic` middleware, which serves a self-contained
177
+ // worker bundle whose internal imports use `/src/...` and `/@fs/...` URLs
178
+ // that bypass our `/ns/m/` wrapping pipeline. The worker would crash on
179
+ // its first transitive import.
180
+ //
181
+ // We use `__NS_HTTP_ORIGIN__` (set by the entry runtime in
182
+ // `hmr/entry-runtime.ts`) so the URL stays correct when the device connects
183
+ // via a non-localhost origin (e.g. `http://192.168.x.x:5173`).
184
+ //
185
+ // Counterpart for production builds: `workerUrlPlugin()` below, which runs in
186
+ // `generateBundle` and rewrites a similar pattern to `new Worker('~/' + ...)`.
187
+ // Matches Vite-emitted dev shape:
188
+ // new Worker(new URL(/* @vite-ignore */ "/src/.../foo.worker.ts?worker_file&type=classic", '' + import.meta.url))
189
+ // The `/* @vite-ignore */` and `'' +` coercion are constants Vite always emits
190
+ // (see `workerImportMetaUrlPlugin` in vite/dist/node/chunks/node.js), so we
191
+ // match them as fixed structure rather than as optional fragments. The asset
192
+ // path can use single, double, or template-literal quotes.
193
+ const WORKER_VITE_DEV_RE = /new\s+Worker\s*\(\s*new\s+URL\s*\(\s*\/\*\s*@vite-ignore\s*\*\/\s*(['"`])([^'"`]+)\1\s*,\s*(?:'\s*'|"\s*"|`\s*`)\s*\+\s*import\.meta\.url\s*\)\s*(,\s*\{[^}]*\})?\s*\)/g;
194
+ const SKIP_TRANSFORM_ID_RE = /(?:^|\/)(?:node_modules|\.vite)\//;
195
+ // Strip Vite's `?worker_file&type=classic` query suffix (and any extension) so
196
+ // the resulting URL matches the canonical `/ns/m/<rel-without-ext>` shape that
197
+ // the NS HMR pipeline serves. Exported for unit testing.
198
+ export function viteWorkerAssetPathToNsMUrl(assetPath, projectRoot, workspaceRoot) {
199
+ if (typeof assetPath !== 'string' || !assetPath) {
200
+ return null;
201
+ }
202
+ // Vite emits asset paths in two shapes during dev/HMR:
203
+ // 1. Project-relative: "/src/.../foo.worker.ts?worker_file&type=classic"
204
+ // 2. Absolute fs: "/@fs/Users/.../src/.../foo.worker.ts?worker_file&type=classic"
205
+ // We only need to match #1 here — the project-relative form Vite uses for
206
+ // project-local files. Absolute-fs paths come from outside the project root
207
+ // (e.g. workspace libs in a monorepo), and we hand those off to Vite's
208
+ // default behavior rather than try to map them into `/ns/m/`.
209
+ const queryIdx = assetPath.indexOf('?');
210
+ const cleanPath = queryIdx === -1 ? assetPath : assetPath.slice(0, queryIdx);
211
+ const query = queryIdx === -1 ? '' : assetPath.slice(queryIdx);
212
+ // Confirm this is the worker_file query Vite emits — leaves non-worker URLs
213
+ // (e.g. asset URLs from `assetImportMetaUrlPlugin`) alone.
214
+ if (!/[?&]worker_file(?:&|=|$)/.test(query)) {
215
+ return null;
216
+ }
217
+ // Project-relative: "/src/..." → "/ns/m/src/..."
218
+ if (cleanPath.startsWith('/') && !cleanPath.startsWith('/@fs/')) {
219
+ // Strip the rewritable extension so the URL matches the canonical
220
+ // `/ns/m/<rel-without-ext>` shape served by the HMR middleware.
221
+ const noExt = cleanPath.replace(/\.(?:ts|tsx|mjs|cjs|js|jsx)$/, '');
222
+ return `/ns/m${noExt}`;
223
+ }
224
+ // Absolute-fs: "/@fs/abs/path/..." — try to map into project or workspace roots.
225
+ if (cleanPath.startsWith('/@fs/')) {
226
+ const absPath = cleanPath.slice('/@fs'.length); // keep leading '/'
227
+ const toPosix = (value) => value.replace(/\\/g, '/');
228
+ const stripTrailing = (value) => value.replace(/\/+$/, '');
229
+ const target = toPosix(absPath);
230
+ const projectPosix = stripTrailing(toPosix(path.resolve(projectRoot)));
231
+ const workspacePosix = workspaceRoot ? stripTrailing(toPosix(path.resolve(workspaceRoot))) : null;
232
+ const tryRoot = (root) => {
233
+ if (!root)
234
+ return null;
235
+ if (target === root)
236
+ return '/ns/m';
237
+ if (target.startsWith(`${root}/`)) {
238
+ const rel = target.slice(root.length); // includes leading '/'
239
+ const noExt = rel.replace(/\.(?:ts|tsx|mjs|cjs|js|jsx)$/, '');
240
+ return `/ns/m${noExt}`;
241
+ }
242
+ return null;
243
+ };
244
+ return tryRoot(projectPosix) ?? tryRoot(workspacePosix);
245
+ }
246
+ return null;
247
+ }
248
+ // Runtime helper injected at the top of every HMR-transformed module that
249
+ // instantiates a Worker. Wraps each `new Worker(...)` call in
250
+ // `__nsHmrTrackWorker(...)`, which registers the worker for cleanup via
251
+ // TWO complementary mechanisms:
252
+ //
253
+ // 1. STANDARDS-COMPLIANT — `import.meta.hot.dispose(cb)` per Vite spec.
254
+ // The JS hot registry (`hmr/client/hot-context.ts`) records the
255
+ // callback per-module; the Angular HMR client drains the registry
256
+ // before reboot. This is the same primitive every Vite plugin
257
+ // author already knows; users can register their own dispose
258
+ // callbacks the same way.
259
+ //
260
+ // 2. RUNTIME-AUTHORITATIVE — `globalThis.__NS_HMR_WORKERS__` Set
261
+ // drained by the HMR client (or by the runtime's
262
+ // `__NS_DEV__.terminateAllWorkers()`). This catches workers spawned in
263
+ // modules that aren't being individually re-evaluated (e.g. the
264
+ // `app.component.ts` constructor that re-runs on every Angular
265
+ // reboot, even though `app.component.ts` itself isn't being
266
+ // replaced — its `dispose` callbacks don't fire per Vite spec).
267
+ //
268
+ // ## Why both?
269
+ //
270
+ // `import.meta.hot.dispose()` is correct for modules being replaced.
271
+ // But Angular HMR's `__reboot_ng_modules__` re-creates the component
272
+ // tree without re-evaluating modules — `app.component.ts`'s top-level
273
+ // dispose callback wouldn't fire on a `login.component.html` save,
274
+ // even though Angular re-runs `AppComponent`'s constructor and spawns
275
+ // a fresh worker. The runtime-authoritative path catches this:
276
+ // `__NS_DEV__.terminateAllWorkers()` walks `Caches::Workers` (the iOS
277
+ // runtime's authoritative worker registry) and kills every live
278
+ // worker regardless of which module spawned it.
279
+ //
280
+ // ## Design notes
281
+ //
282
+ // * Helper injected ONLY in modules that have at least one
283
+ // `new Worker(new URL(...))` call we rewrote. Modules without
284
+ // workers pay no prelude cost.
285
+ // * `terminate()` is the only cleanup primitive. Apps needing
286
+ // graceful shutdown should send a custom message before HMR via
287
+ // their own pre-update hook (e.g.
288
+ // `import.meta.hot.on('vite:beforeUpdate', ...)`).
289
+ // * `try/catch` around `terminate()` so an already-dead worker
290
+ // doesn't break the HMR cycle (e.g. user code already terminated
291
+ // it).
292
+ // * Both mechanisms are best-effort and idempotent: terminating an
293
+ // already-dead worker is a no-op, and clearing an already-empty
294
+ // Set is a no-op. Belt-and-suspenders is the right policy here.
295
+ // * `addEventListener('terminated', ...)` would be nicer than a Set
296
+ // of references, but iOS Worker doesn't fire that event reliably,
297
+ // so we use the Set + opportunistic cleanup approach.
298
+ const HMR_WORKER_DISPOSE_HELPER = [
299
+ '/* Injected by @nativescript/vite workerHmrUrlPlugin (HMR worker auto-dispose) */',
300
+ 'const __nsHmrTrackWorker = /* @__PURE__ */ (function () {',
301
+ // Per-module Set so `import.meta.hot.dispose` only terminates
302
+ // workers SPAWNED BY THIS MODULE — matches Vite spec semantics.
303
+ // The shared `globalThis.__NS_HMR_WORKERS__` Set below is the
304
+ // belt-and-suspenders fallback the runtime can also drain
305
+ // universally on Angular reboot.
306
+ '\tconst __nsModuleWorkers = new Set();',
307
+ '\tlet __nsDisposeRegistered = false;',
308
+ '\treturn function __nsHmrTrackWorker(w) {',
309
+ '\t\tif (!w) return w;',
310
+ // Path 1: register in the legacy global Set. Kept for backward
311
+ // compatibility with older NS runtimes that don't yet ship
312
+ // `__NS_DEV__.terminateAllWorkers()`. Once that runtime API is universally
313
+ // adopted this can be removed — everything else here is
314
+ // standards-compliant.
315
+ '\t\ttry {',
316
+ '\t\t\tconst __nsG = typeof globalThis !== "undefined" ? globalThis : (typeof self !== "undefined" ? self : {});',
317
+ '\t\t\tif (!__nsG.__NS_HMR_WORKERS__) __nsG.__NS_HMR_WORKERS__ = new Set();',
318
+ '\t\t\t__nsG.__NS_HMR_WORKERS__.add(w);',
319
+ '\t\t} catch (_e) {}',
320
+ // Path 2: standards-compliant `import.meta.hot.dispose` registration.
321
+ // We re-register the disposer on EVERY worker spawn rather than
322
+ // just the first, because per Vite spec dispose callbacks are
323
+ // consumed when they fire — the runtime drains them out of its
324
+ // registry on each HMR cycle. The closure-level
325
+ // `__nsDisposeRegistered` flag is reset by the disposer itself
326
+ // after firing, so we register exactly once per HMR cycle (not
327
+ // once per worker spawn within a cycle): the second `add()` in
328
+ // the same cycle sees `__nsDisposeRegistered === true` and skips
329
+ // re-registration. After the cycle completes the flag flips back
330
+ // to false and the next worker spawn registers a fresh disposer.
331
+ // Modules that never instantiate a worker never register a
332
+ // disposer at all.
333
+ '\t\t__nsModuleWorkers.add(w);',
334
+ '\t\tif (!__nsDisposeRegistered && typeof import.meta !== "undefined" && import.meta && import.meta.hot && typeof import.meta.hot.dispose === "function") {',
335
+ '\t\t\t__nsDisposeRegistered = true;',
336
+ '\t\t\timport.meta.hot.dispose(function () {',
337
+ '\t\t\t\tfor (const __nsW of __nsModuleWorkers) {',
338
+ '\t\t\t\t\ttry { typeof __nsW.terminate === "function" && __nsW.terminate(); } catch (_e) {}',
339
+ '\t\t\t\t}',
340
+ '\t\t\t\t__nsModuleWorkers.clear();',
341
+ // Re-arm so the next worker spawn (in the new module instance
342
+ // after the HMR reboot) registers a fresh disposer for the next
343
+ // cycle. Without this re-arm, only cycle #1 uses the dispose
344
+ // path and cycles #2+ fall through to the worker terminator
345
+ // fallback — observable but suboptimal (uses two log lines
346
+ // instead of one and pays the worker terminator's iteration
347
+ // cost unnecessarily).
348
+ '\t\t\t\t__nsDisposeRegistered = false;',
349
+ '\t\t\t});',
350
+ '\t\t}',
351
+ '\t\treturn w;',
352
+ '\t};',
353
+ '})();',
354
+ '',
355
+ ].join('\n');
356
+ export function workerHmrUrlPlugin(opts) {
357
+ const { verbose } = opts || {};
358
+ let projectRoot = '';
359
+ let workspaceRoot = null;
360
+ return {
361
+ name: 'nativescript-worker-hmr-url-transform',
362
+ // Run AFTER Vite's built-in `workerImportMetaUrlPlugin` (and AFTER
363
+ // the Angular plugin, which discards upstream `code` by re-compiling
364
+ // from disk). At this point Vite has already rewritten the user's
365
+ // `new Worker(new URL('./foo', import.meta.url))` into its dev shape
366
+ // `new Worker(new URL(/* @vite-ignore */"/src/.../foo.worker.ts?worker_file&type=classic", '' + import.meta.url))`.
367
+ // We match that shape and replace it with a plain string URL that
368
+ // routes through `/ns/m/` so the worker's internal imports get the
369
+ // same HMR treatment as the main thread.
370
+ enforce: 'post',
371
+ // Dev/HMR only — `workerUrlPlugin()` below handles the production build.
372
+ apply: 'serve',
373
+ configResolved(config) {
374
+ projectRoot = path.resolve(config.root || getProjectRootPath());
375
+ workspaceRoot = findMonorepoWorkspaceRoot(projectRoot);
376
+ },
377
+ transform(code, id) {
378
+ if (!code || code.indexOf('new Worker') === -1 || code.indexOf('import.meta.url') === -1) {
379
+ return null;
380
+ }
381
+ // `id` may carry a Vite query suffix (`?vue&type=script`, `?used`, …);
382
+ // strip it so path matching works against real fs paths.
383
+ const cleanId = id.split('?', 1)[0];
384
+ if (!cleanId || SKIP_TRANSFORM_ID_RE.test(cleanId)) {
385
+ return null;
386
+ }
387
+ let modified = false;
388
+ let workerWraps = 0;
389
+ let newCode = code.replace(WORKER_VITE_DEV_RE, (match, _quote, assetPath, options) => {
390
+ const nsmUrl = viteWorkerAssetPathToNsMUrl(assetPath, projectRoot, workspaceRoot);
391
+ if (!nsmUrl) {
392
+ if (verbose) {
393
+ // eslint-disable-next-line no-console
394
+ console.warn(`[ns-worker-hmr] worker asset path ${JSON.stringify(assetPath)} in ${cleanId} can't be mapped to /ns/m/; leaving Vite's default behavior in place`);
395
+ }
396
+ return match;
397
+ }
398
+ modified = true;
399
+ workerWraps++;
400
+ const optionsTail = options ? options : '';
401
+ // Wrap each `new Worker(...)` in `__nsHmrTrackWorker(...)`
402
+ // so it auto-registers for cleanup on the next HMR
403
+ // dispose. The wrap is transparent — `__nsHmrTrackWorker`
404
+ // returns the worker instance unchanged so callers that
405
+ // assign the result to a variable still get a real
406
+ // Worker.
407
+ return `__nsHmrTrackWorker(new Worker((typeof globalThis !== "undefined" && typeof globalThis.__NS_HTTP_ORIGIN__ === "string" ? globalThis.__NS_HTTP_ORIGIN__ : "") + ${JSON.stringify(nsmUrl)}${optionsTail}))`;
408
+ });
409
+ if (!modified) {
410
+ return null;
411
+ }
412
+ // Inject the helper prelude exactly once at the top of the
413
+ // module. The helper closure self-tracks workers and lazily
414
+ // registers the `import.meta.hot.dispose()` callback on the
415
+ // first wrap, so injecting it unconditionally (whether or not
416
+ // HMR is wired up at module-eval time) is safe.
417
+ newCode = HMR_WORKER_DISPOSE_HELPER + newCode;
418
+ if (verbose) {
419
+ // eslint-disable-next-line no-console
420
+ console.log(`[ns-worker-hmr] rewrote ${workerWraps} Vite worker URL${workerWraps === 1 ? '' : 's'} → /ns/m/ in ${cleanId} (with HMR auto-terminate via globalThis.__NS_HMR_WORKERS__)`);
421
+ }
422
+ // Returning null for the source map keeps Vite's downstream sourcemap
423
+ // composition simple; the per-Worker line shift is small and the
424
+ // frame is rarely the one a developer is debugging.
425
+ return { code: newCode, map: null };
426
+ },
427
+ };
428
+ }
429
+ // Safety-net TypeScript fallback transform.
430
+ //
431
+ // Problem: In HMR mode (where `useAngularCompilationAPI = false`), the
432
+ // `@analogjs/vite-plugin-angular` `config` hook forcibly sets `oxc: false` on
433
+ // the Vite config (see `angular-vite-plugin.js`:
434
+ // `const oxc = pluginOptions.useAngularCompilationAPI ? undefined : (config.oxc ?? false);`).
435
+ // That disables Vite's built-in oxc TypeScript transformer for the whole dev
436
+ // session. The Analog plugin then expects its own `fileEmitter` to strip types
437
+ // from every `.ts` file in the project — but `fileEmitter` only knows about
438
+ // files that are part of the Angular TypeScript program (anything imported
439
+ // directly, or referenced via `templateUrl` / `styleUrls` from a decorated
440
+ // class).
441
+ //
442
+ // Worker entry files fall outside the program. They are only loaded via
443
+ // `new Worker(new URL('./foo.worker', import.meta.url))`, which is NOT an
444
+ // import — it's a URL constructor expression the device resolves at runtime.
445
+ // `fileEmitter(id)` returns nothing for those files, the Analog plugin's
446
+ // transform returns `undefined`, oxc doesn't run (because Analog disabled it),
447
+ // and the raw `.ts` source reaches the device with type annotations intact.
448
+ // V8's parser then chokes on the first `(x: Type)` parameter annotation with
449
+ // `SyntaxError: Unexpected token ':'`.
450
+ //
451
+ // The fix is a small post-enforce transform that re-runs Vite's own
452
+ // `transformWithOxc` on any `.ts`/`.tsx` file that still looks like raw
453
+ // TypeScript after the rest of the pipeline is done. For already-compiled
454
+ // Angular output (pure JS), the detection heuristic short-circuits and we
455
+ // never invoke oxc, so the fast path stays fast.
456
+ //
457
+ // Scope intentionally narrow:
458
+ // * `enforce: 'post'` — only sees final code after every other plugin had a
459
+ // chance to transform.
460
+ // * `apply: 'serve'` — dev/HMR only. Production builds use Rolldown which
461
+ // handles TS natively without needing this net.
462
+ // * Skips `node_modules` / `.vite` — third-party code has its own pipeline,
463
+ // and hitting every transitive dep would be wasteful.
464
+ // * Skips files containing Angular decorators (`@Component`, `@Injectable`,
465
+ // `@NgModule`, `@Directive`, `@Pipe`). Those files belong to the Angular
466
+ // program; if they fell through the Angular plugin we surface Angular's
467
+ // own `"contains Angular decorators but is not in the TypeScript program"`
468
+ // warning rather than silently transforming them with oxc (which would
469
+ // emit a `@oxc-project/runtime/helpers/decorate` import that the app does
470
+ // not depend on, breaking Vite's import-analysis pass).
471
+ // * Regex-based detection — catches the tokens V8 would actually reject.
472
+ // False positives (running oxc on valid JS) are harmless because oxc with
473
+ // `lang: 'ts'` is a no-op on JS; false negatives would only surface as the
474
+ // same error the fix is designed to prevent, so the detector errs toward
475
+ // running the transform when in doubt.
476
+ const TS_ONLY_SYNTAX_RE = new RegExp([
477
+ // `import type { … } from '…'` / `export type { … } from '…'`
478
+ String.raw `\b(?:import|export)\s+type\s`,
479
+ // `interface Foo { … }`
480
+ String.raw `\binterface\s+[A-Z_$][\w$]*\s*[<{]`,
481
+ // `type Foo = …`
482
+ String.raw `\btype\s+[A-Z_$][\w$]*\s*[<=]`,
483
+ // `as Type` assertions — restrict right-hand side to common primitives
484
+ // or PascalCase identifiers to avoid catching unrelated tokens.
485
+ String.raw `\bas\s+(?:string|number|boolean|any|unknown|never|void|[A-Z][\w$]*)\b`,
486
+ // Parameter / destructured type annotations: `(msg: any)`, `(x: T, y: U)`.
487
+ // Anchored to `(` or `,` so we don't match object literal keys like `{ a: 1 }`.
488
+ String.raw `[(,]\s*[\w$]+\s*\??\s*:\s*(?:string|number|boolean|any|unknown|never|void|null|undefined|object|[A-Z][\w$]*(?:<[^>]*>)?(?:\[\])?)\b`,
489
+ // Variable type annotations: `let x: T = …` / `const y: T`
490
+ String.raw `\b(?:const|let|var)\s+[\w$]+\s*:\s*[\w$<>[\]|&., ]+\s*[;=]`,
491
+ // Return type annotations on arrow functions: `): T =>`
492
+ String.raw `\)\s*:\s*(?:string|number|boolean|any|unknown|never|void|[A-Z][\w$]*(?:<[^>]*>)?)\s*(?:=>|\{)`,
493
+ ].join('|'));
494
+ // Decorator shapes that mean "the Angular plugin owns this file, stay out of
495
+ // its way." We do NOT try to compile these ourselves even if the Angular
496
+ // plugin's `fileEmitter` didn't produce output for them — oxc would rewrite
497
+ // the decorators into `import _decorate from "@oxc-project/runtime/helpers/decorate"`
498
+ // calls, Vite's import-analysis would fail to resolve that helper package,
499
+ // and we'd turn a harmless "not in TypeScript program" warning into a fatal
500
+ // import error. Better to let Angular's own warning surface and leave the
501
+ // code untouched.
502
+ const ANGULAR_DECORATOR_RE = /@(?:Component|Directive|Injectable|NgModule|Pipe)\s*\(/;
503
+ const TS_FALLBACK_SKIP_ID_RE = /(?:^|\/)(?:node_modules|\.vite)\//;
504
+ export function tsFallbackTransformPlugin(opts) {
505
+ const { verbose } = opts || {};
506
+ // Cached after the first successful import so repeated transforms don't
507
+ // pay the dynamic-import cost. `null` = not loaded yet; `false` = load
508
+ // attempted and failed (older Vite with no oxc export — we'll skip).
509
+ let cachedTransformWithOxc = null;
510
+ return {
511
+ name: 'nativescript-ts-fallback-transform',
512
+ enforce: 'post',
513
+ apply: 'serve',
514
+ async transform(code, id) {
515
+ if (cachedTransformWithOxc === false)
516
+ return null;
517
+ const cleanId = id.split('?', 1)[0];
518
+ if (!cleanId || !/\.(m?ts|[jt]sx)$/.test(cleanId))
519
+ return null;
520
+ if (TS_FALLBACK_SKIP_ID_RE.test(cleanId))
521
+ return null;
522
+ if (ANGULAR_DECORATOR_RE.test(code))
523
+ return null;
524
+ if (!TS_ONLY_SYNTAX_RE.test(code))
525
+ return null;
526
+ if (cachedTransformWithOxc === null) {
527
+ try {
528
+ // Dynamic import keeps this plugin cross-version-safe: older
529
+ // Vite installs without `transformWithOxc` (pre-Rolldown
530
+ // builds) cleanly disable this fallback instead of crashing.
531
+ const vite = await import('vite');
532
+ if (typeof vite.transformWithOxc === 'function') {
533
+ cachedTransformWithOxc = vite.transformWithOxc;
534
+ }
535
+ else {
536
+ cachedTransformWithOxc = false;
537
+ return null;
538
+ }
539
+ }
540
+ catch {
541
+ cachedTransformWithOxc = false;
542
+ return null;
543
+ }
544
+ }
545
+ try {
546
+ const lang = cleanId.endsWith('tsx') ? 'tsx' : cleanId.endsWith('jsx') ? 'jsx' : 'ts';
547
+ const result = await cachedTransformWithOxc(code, cleanId, { lang });
548
+ if (!result || typeof result.code !== 'string')
549
+ return null;
550
+ if (verbose) {
551
+ // eslint-disable-next-line no-console
552
+ console.log(`[ns-ts-fallback] type-stripped ${cleanId}`);
553
+ }
554
+ return { code: result.code, map: result.map ?? null };
555
+ }
556
+ catch (err) {
557
+ if (verbose) {
558
+ // eslint-disable-next-line no-console
559
+ console.warn(`[ns-ts-fallback] transformWithOxc failed for ${cleanId}:`, err);
560
+ }
561
+ return null;
562
+ }
563
+ },
564
+ };
565
+ }
566
+ export function angularWorkerUrlPreservePlugin(opts) {
567
+ const { verbose } = opts || {};
568
+ let patched = false;
569
+ const applyPatch = () => {
570
+ if (patched)
571
+ return;
572
+ patched = true;
573
+ patchAngularCompilationInitializers({ verbose });
574
+ };
575
+ return {
576
+ name: 'nativescript-angular-worker-url-preserve',
577
+ // `enforce: 'pre'` + eager `config` hook ensures the patch lands
578
+ // before any `buildStart`/`transform` hook runs (i.e. before Angular
579
+ // ever instantiates a compilation class and calls `initialize`).
580
+ enforce: 'pre',
581
+ config() {
582
+ applyPatch();
583
+ return null;
584
+ },
585
+ // Belt-and-suspenders: Vite sometimes skips `config` for inner
586
+ // environments (e.g. `build --environment=<name>`). `configResolved`
587
+ // always runs once per environment, so re-applying here is safe
588
+ // (idempotent) and guarantees the patch lands before compilation.
589
+ configResolved() {
590
+ applyPatch();
591
+ },
592
+ };
593
+ }
594
+ // The three concrete `AngularCompilation` subclasses in `@angular/build`.
595
+ // All three expose an `initialize(tsconfig, hostOptions, compilerOptionsTransformer)`
596
+ // method that forwards `hostOptions.processWebWorker` into either the TS
597
+ // transformer (Aot/Jit) or a worker-thread MessageChannel (Parallel). We
598
+ // wrap `initialize` on each so `hostOptions.processWebWorker` is coerced to
599
+ // identity before any of that happens.
600
+ const ANGULAR_COMPILATION_TARGETS = [
601
+ {
602
+ specifier: 'src/tools/angular/compilation/aot-compilation.js',
603
+ className: 'AotCompilation',
604
+ },
605
+ {
606
+ specifier: 'src/tools/angular/compilation/jit-compilation.js',
607
+ className: 'JitCompilation',
608
+ },
609
+ {
610
+ specifier: 'src/tools/angular/compilation/parallel-compilation.js',
611
+ className: 'ParallelCompilation',
612
+ },
613
+ ];
614
+ function patchAngularCompilationInitializers(opts) {
615
+ const { verbose } = opts;
616
+ // `@angular/build` locks its public `exports` map to `.`, `./private`,
617
+ // and `./package.json`. Deep subpath requires like
618
+ // `@angular/build/src/tools/angular/compilation/aot-compilation.js`
619
+ // fail with `ERR_PACKAGE_PATH_NOT_EXPORTED`. Resolve the package root
620
+ // via the always-allowed `./package.json` export and require the
621
+ // absolute on-disk paths instead — `exports` doesn't gate absolute fs
622
+ // paths.
623
+ let pkgRoot;
624
+ try {
625
+ const pkgJsonPath = nodeRequire.resolve('@angular/build/package.json');
626
+ pkgRoot = path.dirname(pkgJsonPath);
627
+ }
628
+ catch {
629
+ if (verbose) {
630
+ // eslint-disable-next-line no-console
631
+ console.log('[ns-angular-worker-preserve] @angular/build not installed; skipping patch (non-Angular project)');
632
+ }
633
+ return;
634
+ }
635
+ let patchedCount = 0;
636
+ let attemptedCount = 0;
637
+ for (const target of ANGULAR_COMPILATION_TARGETS) {
638
+ attemptedCount++;
639
+ const filePath = path.join(pkgRoot, target.specifier);
640
+ let mod;
641
+ try {
642
+ mod = nodeRequire(filePath);
643
+ }
644
+ catch (err) {
645
+ if (verbose) {
646
+ // eslint-disable-next-line no-console
647
+ console.log(`[ns-angular-worker-preserve] ${target.className} not loadable at ${filePath} (older @angular/build or reorganized layout); skipping:`, err.message);
648
+ }
649
+ continue;
650
+ }
651
+ const klass = mod ? mod[target.className] : null;
652
+ if (typeof klass !== 'function') {
653
+ if (verbose) {
654
+ // eslint-disable-next-line no-console
655
+ console.log(`[ns-angular-worker-preserve] ${target.className} export missing from ${filePath}; skipping`);
656
+ }
657
+ continue;
658
+ }
659
+ if (klass.__nativescriptPatchedProcessWebWorker) {
660
+ patchedCount++;
661
+ continue;
662
+ }
663
+ const originalInitialize = klass.prototype && klass.prototype.initialize;
664
+ if (typeof originalInitialize !== 'function') {
665
+ if (verbose) {
666
+ // eslint-disable-next-line no-console
667
+ console.log(`[ns-angular-worker-preserve] ${target.className}.prototype.initialize missing; skipping`);
668
+ }
669
+ continue;
670
+ }
671
+ klass.prototype.initialize = function nativescriptPatchedInitialize(tsconfig, hostOptions, ...rest) {
672
+ // Wrap `processWebWorker` in place so Angular sees an identity
673
+ // function. When Angular's transformer sees `replacementPath ===
674
+ // filePath` it leaves `new Worker(new URL(...))` nodes unchanged,
675
+ // and Vite's own `workerImportMetaUrlPlugin` handles bundling
676
+ // downstream. Mutating the incoming object is safe: Analog
677
+ // constructs a fresh `hostOptions` on every `performAngularCompilation`
678
+ // call, and the only consumer (this `initialize` call) runs
679
+ // synchronously after our override.
680
+ if (hostOptions && typeof hostOptions.processWebWorker === 'function' && !hostOptions.__nativescriptPatchedProcessWebWorker) {
681
+ hostOptions.processWebWorker = function identityProcessWebWorker(workerFile, _containingFile) {
682
+ return workerFile;
683
+ };
684
+ hostOptions.__nativescriptPatchedProcessWebWorker = true;
685
+ }
686
+ return originalInitialize.call(this, tsconfig, hostOptions, ...rest);
687
+ };
688
+ klass.__nativescriptPatchedProcessWebWorker = true;
689
+ patchedCount++;
690
+ }
691
+ if (verbose) {
692
+ if (patchedCount === 0) {
693
+ // eslint-disable-next-line no-console
694
+ console.warn(`[ns-angular-worker-preserve] no AngularCompilation subclasses patched (tried ${attemptedCount}); worker URLs may be blanked out in the build`);
695
+ }
696
+ else {
697
+ // eslint-disable-next-line no-console
698
+ console.log(`[ns-angular-worker-preserve] patched ${patchedCount}/${attemptedCount} AngularCompilation subclass initializers (${ANGULAR_COMPILATION_TARGETS.map((t) => t.className).join(', ')})`);
699
+ }
700
+ }
64
701
  }
65
702
  export function workerUrlPlugin() {
66
703
  return {
@@ -72,7 +709,19 @@ export function workerUrlPlugin() {
72
709
  // Transform Vite's worker URL pattern to NativeScript's expected format
73
710
  // From: new Worker(new URL(/* @vite-ignore */ "/assets/sample.worker-C6wW8q2-.js", import.meta.url))
74
711
  // To: new Worker('~/' + 'assets/sample.worker-C6wW8q2-.js')
75
- const workerUrlRegex = /new\s+Worker\s*\(\s*new\s+URL\s*\(\s*(?:\/\*[^*]*\*\/\s*)?["']([^"']+)["']\s*,\s*import\.meta\.url\s*\)\s*\)/g;
712
+ //
713
+ // Rolldown (Vite's underlying bundler) emits the asset path as a
714
+ // template-literal (backticks) and prefixes the second URL arg
715
+ // with `\`\` +` to coerce it to a string, e.g.:
716
+ // new Worker(new URL(`/assets/foo.js`, `` + import.meta.url))
717
+ // The regex below accepts either single quotes, double quotes,
718
+ // or backticks for the asset path, and an optional
719
+ // `<emptyString> +` coercion prefix before `import.meta.url`. At
720
+ // NS runtime there's no `import.meta.url` in the main bundle and
721
+ // `new URL("/assets/...", ...)` would resolve to a `file:///...`
722
+ // URL that NS Worker can't load, so this rewrite is the last
723
+ // step that makes worker chunks actually loadable.
724
+ const workerUrlRegex = /new\s+Worker\s*\(\s*new\s+URL\s*\(\s*(?:\/\*[^*]*\*\/\s*)?[`"']([^`"']+)[`"']\s*,\s*(?:[`"'][^`"']*[`"']\s*\+\s*)?import\.meta\.url\s*\)\s*\)/g;
76
725
  if (workerUrlRegex.test(chunk.code)) {
77
726
  chunk.code = chunk.code.replace(workerUrlRegex, (match, assetPath) => {
78
727
  // Use the full asset path including assets/ folder