@nativescript/vite 8.0.0-alpha.5 → 8.0.0-alpha.51

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 (424) 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 +241 -51
  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 +1 -1
  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 +142 -0
  41. package/helpers/global-defines.js +213 -11
  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.d.ts +1 -0
  49. package/helpers/logging.js +65 -4
  50. package/helpers/logging.js.map +1 -1
  51. package/helpers/main-entry.d.ts +3 -1
  52. package/helpers/main-entry.js +301 -53
  53. package/helpers/main-entry.js.map +1 -1
  54. package/helpers/nativeclass-esbuild-plugin.d.ts +2 -1
  55. package/helpers/nativeclass-esbuild-plugin.js.map +1 -1
  56. package/helpers/nativeclass-transform.js +5 -6
  57. package/helpers/nativeclass-transform.js.map +1 -1
  58. package/helpers/nativeclass-transformer-plugin.d.ts +9 -2
  59. package/helpers/nativeclass-transformer-plugin.js +157 -14
  60. package/helpers/nativeclass-transformer-plugin.js.map +1 -1
  61. package/helpers/nativescript-package-resolver.js +10 -62
  62. package/helpers/nativescript-package-resolver.js.map +1 -1
  63. package/helpers/normalize-id.d.ts +42 -0
  64. package/helpers/normalize-id.js +60 -0
  65. package/helpers/normalize-id.js.map +1 -0
  66. package/helpers/ns-core-url.d.ts +29 -7
  67. package/helpers/ns-core-url.js +69 -12
  68. package/helpers/ns-core-url.js.map +1 -1
  69. package/helpers/optimize-deps.d.ts +16 -0
  70. package/helpers/optimize-deps.js +17 -0
  71. package/helpers/optimize-deps.js.map +1 -0
  72. package/helpers/package-platform-aliases.js +34 -49
  73. package/helpers/package-platform-aliases.js.map +1 -1
  74. package/helpers/platform-types.d.ts +2 -0
  75. package/helpers/platform-types.js +2 -0
  76. package/helpers/platform-types.js.map +1 -0
  77. package/helpers/postcss-platform-config.d.ts +17 -1
  78. package/helpers/postcss-platform-config.js +20 -37
  79. package/helpers/postcss-platform-config.js.map +1 -1
  80. package/helpers/project.d.ts +35 -0
  81. package/helpers/project.js +120 -2
  82. package/helpers/project.js.map +1 -1
  83. package/helpers/resolve-main-field-platform.d.ts +20 -0
  84. package/helpers/resolve-main-field-platform.js +49 -0
  85. package/helpers/resolve-main-field-platform.js.map +1 -0
  86. package/helpers/resolver.js +17 -2
  87. package/helpers/resolver.js.map +1 -1
  88. package/helpers/theme-core-plugins.js +1 -1
  89. package/helpers/theme-core-plugins.js.map +1 -1
  90. package/helpers/ts-config-paths.d.ts +14 -0
  91. package/helpers/ts-config-paths.js +90 -9
  92. package/helpers/ts-config-paths.js.map +1 -1
  93. package/helpers/typescript-check.d.ts +2 -1
  94. package/helpers/typescript-check.js +2 -2
  95. package/helpers/typescript-check.js.map +1 -1
  96. package/helpers/ui-registration.d.ts +21 -0
  97. package/helpers/ui-registration.js +156 -0
  98. package/helpers/ui-registration.js.map +1 -0
  99. package/helpers/utils.d.ts +9 -0
  100. package/helpers/utils.js +22 -2
  101. package/helpers/utils.js.map +1 -1
  102. package/helpers/workers.d.ts +20 -19
  103. package/helpers/workers.js +624 -4
  104. package/helpers/workers.js.map +1 -1
  105. package/hmr/client/css-handler.d.ts +2 -1
  106. package/hmr/client/css-handler.js +50 -26
  107. package/hmr/client/css-handler.js.map +1 -1
  108. package/hmr/client/css-update-overlay.d.ts +18 -0
  109. package/hmr/client/css-update-overlay.js +27 -0
  110. package/hmr/client/css-update-overlay.js.map +1 -0
  111. package/hmr/client/framework-client-strategy.d.ts +79 -0
  112. package/hmr/client/framework-client-strategy.js +19 -0
  113. package/hmr/client/framework-client-strategy.js.map +1 -0
  114. package/hmr/client/hmr-pending-overlay.d.ts +13 -0
  115. package/hmr/client/hmr-pending-overlay.js +60 -0
  116. package/hmr/client/hmr-pending-overlay.js.map +1 -0
  117. package/hmr/client/index.js +891 -220
  118. package/hmr/client/index.js.map +1 -1
  119. package/hmr/client/utils.d.ts +7 -1
  120. package/hmr/client/utils.js +207 -29
  121. package/hmr/client/utils.js.map +1 -1
  122. package/hmr/entry-runtime.d.ts +2 -1
  123. package/hmr/entry-runtime.js +256 -69
  124. package/hmr/entry-runtime.js.map +1 -1
  125. package/hmr/frameworks/angular/build/angular-linker.d.ts +12 -0
  126. package/hmr/frameworks/angular/build/angular-linker.js +109 -0
  127. package/hmr/frameworks/angular/build/angular-linker.js.map +1 -0
  128. package/hmr/frameworks/angular/build/inject-component-hmr-registration.d.ts +112 -0
  129. package/hmr/frameworks/angular/build/inject-component-hmr-registration.js +291 -0
  130. package/hmr/frameworks/angular/build/inject-component-hmr-registration.js.map +1 -0
  131. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.d.ts +75 -0
  132. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js +221 -0
  133. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js.map +1 -0
  134. package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.js +1 -170
  135. package/hmr/frameworks/angular/build/inline-decorator-component-templates.js.map +1 -0
  136. package/hmr/frameworks/angular/build/js-lexer.d.ts +4 -0
  137. package/{helpers/angular/synthesize-decorator-ctor-parameters.js → hmr/frameworks/angular/build/js-lexer.js} +22 -96
  138. package/hmr/frameworks/angular/build/js-lexer.js.map +1 -0
  139. package/hmr/frameworks/angular/build/shared-linker.d.ts +39 -0
  140. package/hmr/frameworks/angular/build/shared-linker.js +128 -0
  141. package/hmr/frameworks/angular/build/shared-linker.js.map +1 -0
  142. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js +88 -0
  143. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js.map +1 -0
  144. package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.js +1 -174
  145. package/hmr/frameworks/angular/build/synthesize-injectable-factories.js.map +1 -0
  146. package/{helpers/angular → hmr/frameworks/angular/build}/util.d.ts +1 -0
  147. package/hmr/frameworks/angular/build/util.js +155 -0
  148. package/hmr/frameworks/angular/build/util.js.map +1 -0
  149. package/hmr/frameworks/angular/client/index.d.ts +1 -0
  150. package/hmr/frameworks/angular/client/index.js +859 -21
  151. package/hmr/frameworks/angular/client/index.js.map +1 -1
  152. package/hmr/frameworks/angular/client/strategy.d.ts +9 -0
  153. package/hmr/frameworks/angular/client/strategy.js +19 -0
  154. package/hmr/frameworks/angular/client/strategy.js.map +1 -0
  155. package/hmr/frameworks/angular/server/angular-root-component.d.ts +79 -0
  156. package/hmr/frameworks/angular/server/angular-root-component.js +149 -0
  157. package/hmr/frameworks/angular/server/angular-root-component.js.map +1 -0
  158. package/hmr/frameworks/angular/server/linker.js +1 -4
  159. package/hmr/frameworks/angular/server/linker.js.map +1 -1
  160. package/hmr/frameworks/angular/server/strategy.js +460 -12
  161. package/hmr/frameworks/angular/server/strategy.js.map +1 -1
  162. package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.js +2 -2
  163. package/hmr/frameworks/angular/server/websocket-angular-entry.js.map +1 -0
  164. package/hmr/{server → frameworks/angular/server}/websocket-angular-hot-update.d.ts +17 -11
  165. package/hmr/frameworks/angular/server/websocket-angular-hot-update.js +336 -0
  166. package/hmr/frameworks/angular/server/websocket-angular-hot-update.js.map +1 -0
  167. package/hmr/frameworks/react/server/strategy.d.ts +2 -0
  168. package/hmr/frameworks/react/server/strategy.js +150 -0
  169. package/hmr/frameworks/react/server/strategy.js.map +1 -0
  170. package/hmr/frameworks/solid/build/solid-jsx-deps.d.ts +15 -0
  171. package/hmr/frameworks/solid/build/solid-jsx-deps.js +178 -0
  172. package/hmr/frameworks/solid/build/solid-jsx-deps.js.map +1 -0
  173. package/hmr/frameworks/solid/client/app-runtime.d.ts +54 -0
  174. package/hmr/frameworks/solid/client/app-runtime.js +184 -0
  175. package/hmr/frameworks/solid/client/app-runtime.js.map +1 -0
  176. package/hmr/frameworks/solid/server/strategy.js +291 -16
  177. package/hmr/frameworks/solid/server/strategy.js.map +1 -1
  178. package/hmr/frameworks/typescript/server/strategy.js +38 -14
  179. package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
  180. package/hmr/frameworks/vue/client/dep-propagation.d.ts +36 -0
  181. package/hmr/frameworks/vue/client/dep-propagation.js +101 -0
  182. package/hmr/frameworks/vue/client/dep-propagation.js.map +1 -0
  183. package/hmr/frameworks/vue/client/index.d.ts +8 -0
  184. package/hmr/frameworks/vue/client/index.js +56 -243
  185. package/hmr/frameworks/vue/client/index.js.map +1 -1
  186. package/hmr/frameworks/vue/client/strategy.d.ts +33 -0
  187. package/hmr/frameworks/vue/client/strategy.js +157 -0
  188. package/hmr/frameworks/vue/client/strategy.js.map +1 -0
  189. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.d.ts +49 -0
  190. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js +142 -0
  191. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js.map +1 -0
  192. package/hmr/frameworks/vue/server/sfc-route-assemble.d.ts +7 -0
  193. package/hmr/frameworks/vue/server/sfc-route-assemble.js +747 -0
  194. package/hmr/frameworks/vue/server/sfc-route-assemble.js.map +1 -0
  195. package/hmr/frameworks/vue/server/sfc-route-meta.d.ts +7 -0
  196. package/hmr/frameworks/vue/server/sfc-route-meta.js +80 -0
  197. package/hmr/frameworks/vue/server/sfc-route-meta.js.map +1 -0
  198. package/hmr/frameworks/vue/server/sfc-route-serve.d.ts +8 -0
  199. package/hmr/frameworks/vue/server/sfc-route-serve.js +459 -0
  200. package/hmr/frameworks/vue/server/sfc-route-serve.js.map +1 -0
  201. package/hmr/frameworks/vue/server/sfc-route-shared.d.ts +38 -0
  202. package/hmr/frameworks/vue/server/sfc-route-shared.js +48 -0
  203. package/hmr/frameworks/vue/server/sfc-route-shared.js.map +1 -0
  204. package/hmr/frameworks/vue/server/strategy.d.ts +35 -0
  205. package/hmr/frameworks/vue/server/strategy.js +278 -1
  206. package/hmr/frameworks/vue/server/strategy.js.map +1 -1
  207. package/hmr/frameworks/vue/server/websocket-sfc.d.ts +15 -0
  208. package/hmr/frameworks/vue/server/websocket-sfc.js +20 -0
  209. package/hmr/frameworks/vue/server/websocket-sfc.js.map +1 -0
  210. package/hmr/helpers/ast-normalizer.d.ts +3 -1
  211. package/hmr/helpers/ast-normalizer.js +77 -10
  212. package/hmr/helpers/ast-normalizer.js.map +1 -1
  213. package/hmr/helpers/cjs-named-exports.d.ts +23 -0
  214. package/hmr/helpers/cjs-named-exports.js +152 -0
  215. package/hmr/helpers/cjs-named-exports.js.map +1 -0
  216. package/hmr/helpers/package-exports.d.ts +16 -0
  217. package/hmr/helpers/package-exports.js +396 -0
  218. package/hmr/helpers/package-exports.js.map +1 -0
  219. package/hmr/server/constants.js +20 -5
  220. package/hmr/server/constants.js.map +1 -1
  221. package/hmr/server/core-sanitize.d.ts +86 -7
  222. package/hmr/server/core-sanitize.js +170 -45
  223. package/hmr/server/core-sanitize.js.map +1 -1
  224. package/hmr/server/device-transform-helpers.d.ts +24 -0
  225. package/hmr/server/device-transform-helpers.js +408 -0
  226. package/hmr/server/device-transform-helpers.js.map +1 -0
  227. package/hmr/server/framework-strategy.d.ts +108 -11
  228. package/hmr/server/hmr-module-graph.d.ts +37 -0
  229. package/hmr/server/hmr-module-graph.js +214 -0
  230. package/hmr/server/hmr-module-graph.js.map +1 -0
  231. package/hmr/server/import-map.d.ts +11 -2
  232. package/hmr/server/import-map.js +92 -45
  233. package/hmr/server/import-map.js.map +1 -1
  234. package/hmr/server/index.js +7 -16
  235. package/hmr/server/index.js.map +1 -1
  236. package/hmr/server/ns-core-cjs-shape.d.ts +2 -4
  237. package/hmr/server/ns-core-cjs-shape.js +4 -6
  238. package/hmr/server/ns-core-cjs-shape.js.map +1 -1
  239. package/hmr/server/ns-rt-bridge.d.ts +51 -0
  240. package/hmr/server/ns-rt-bridge.js +131 -0
  241. package/hmr/server/ns-rt-bridge.js.map +1 -0
  242. package/hmr/server/ns-rt-route.d.ts +5 -0
  243. package/hmr/server/ns-rt-route.js +38 -0
  244. package/hmr/server/ns-rt-route.js.map +1 -0
  245. package/hmr/server/perf-instrumentation.d.ts +114 -0
  246. package/hmr/server/perf-instrumentation.js +197 -0
  247. package/hmr/server/perf-instrumentation.js.map +1 -0
  248. package/hmr/server/process-code-for-device.d.ts +14 -0
  249. package/hmr/server/process-code-for-device.js +699 -0
  250. package/hmr/server/process-code-for-device.js.map +1 -0
  251. package/hmr/server/require-guard.d.ts +1 -0
  252. package/hmr/server/require-guard.js +12 -0
  253. package/hmr/server/require-guard.js.map +1 -0
  254. package/hmr/server/rewrite-imports.d.ts +2 -0
  255. package/hmr/server/rewrite-imports.js +630 -0
  256. package/hmr/server/rewrite-imports.js.map +1 -0
  257. package/hmr/server/route-helpers.d.ts +7 -0
  258. package/hmr/server/route-helpers.js +13 -0
  259. package/hmr/server/route-helpers.js.map +1 -0
  260. package/hmr/server/server-origin.d.ts +2 -0
  261. package/hmr/server/server-origin.js +83 -0
  262. package/hmr/server/server-origin.js.map +1 -0
  263. package/hmr/server/shared-transform-request.js +13 -7
  264. package/hmr/server/shared-transform-request.js.map +1 -1
  265. package/hmr/server/transform-cache-invalidation.d.ts +37 -0
  266. package/hmr/server/transform-cache-invalidation.js +156 -0
  267. package/hmr/server/transform-cache-invalidation.js.map +1 -0
  268. package/hmr/server/vendor-bare-module-shims.d.ts +4 -0
  269. package/hmr/server/vendor-bare-module-shims.js +80 -0
  270. package/hmr/server/vendor-bare-module-shims.js.map +1 -0
  271. package/hmr/server/vite-plugin.js +78 -42
  272. package/hmr/server/vite-plugin.js.map +1 -1
  273. package/hmr/server/websocket-core-bridge.d.ts +45 -4
  274. package/hmr/server/websocket-core-bridge.js +50 -48
  275. package/hmr/server/websocket-core-bridge.js.map +1 -1
  276. package/hmr/server/websocket-css-hot-update.d.ts +33 -0
  277. package/hmr/server/websocket-css-hot-update.js +65 -0
  278. package/hmr/server/websocket-css-hot-update.js.map +1 -0
  279. package/hmr/server/websocket-device-transform.d.ts +3 -0
  280. package/hmr/server/websocket-device-transform.js +7 -0
  281. package/hmr/server/websocket-device-transform.js.map +1 -0
  282. package/hmr/server/websocket-graph-upsert.d.ts +15 -0
  283. package/hmr/server/websocket-graph-upsert.js +20 -0
  284. package/hmr/server/websocket-graph-upsert.js.map +1 -1
  285. package/hmr/server/websocket-hmr-pending.d.ts +37 -0
  286. package/hmr/server/websocket-hmr-pending.js +55 -0
  287. package/hmr/server/websocket-hmr-pending.js.map +1 -0
  288. package/hmr/server/websocket-hot-update.d.ts +77 -0
  289. package/hmr/server/websocket-hot-update.js +360 -0
  290. package/hmr/server/websocket-hot-update.js.map +1 -0
  291. package/hmr/server/websocket-import-map-route.d.ts +15 -0
  292. package/hmr/server/websocket-import-map-route.js +50 -0
  293. package/hmr/server/websocket-import-map-route.js.map +1 -0
  294. package/hmr/server/websocket-module-bindings.js +3 -3
  295. package/hmr/server/websocket-module-bindings.js.map +1 -1
  296. package/hmr/server/websocket-module-specifiers.d.ts +66 -2
  297. package/hmr/server/websocket-module-specifiers.js +191 -20
  298. package/hmr/server/websocket-module-specifiers.js.map +1 -1
  299. package/hmr/server/websocket-ns-core.d.ts +21 -0
  300. package/hmr/server/websocket-ns-core.js +311 -0
  301. package/hmr/server/websocket-ns-core.js.map +1 -0
  302. package/hmr/server/websocket-ns-entry.d.ts +21 -0
  303. package/hmr/server/websocket-ns-entry.js +164 -0
  304. package/hmr/server/websocket-ns-entry.js.map +1 -0
  305. package/hmr/server/websocket-ns-m-paths.d.ts +1 -1
  306. package/hmr/server/websocket-ns-m-paths.js +58 -13
  307. package/hmr/server/websocket-ns-m-paths.js.map +1 -1
  308. package/hmr/server/websocket-ns-m-request.d.ts +11 -1
  309. package/hmr/server/websocket-ns-m-request.js +18 -25
  310. package/hmr/server/websocket-ns-m-request.js.map +1 -1
  311. package/hmr/server/websocket-ns-m.d.ts +33 -0
  312. package/hmr/server/websocket-ns-m.js +752 -0
  313. package/hmr/server/websocket-ns-m.js.map +1 -0
  314. package/hmr/server/websocket-served-module-helpers.d.ts +49 -3
  315. package/hmr/server/websocket-served-module-helpers.js +403 -87
  316. package/hmr/server/websocket-served-module-helpers.js.map +1 -1
  317. package/hmr/server/websocket-txn.js +2 -8
  318. package/hmr/server/websocket-txn.js.map +1 -1
  319. package/hmr/server/websocket-vendor-unifier.d.ts +0 -1
  320. package/hmr/server/websocket-vendor-unifier.js +4 -9
  321. package/hmr/server/websocket-vendor-unifier.js.map +1 -1
  322. package/hmr/server/websocket.d.ts +8 -39
  323. package/hmr/server/websocket.js +608 -6300
  324. package/hmr/server/websocket.js.map +1 -1
  325. package/hmr/shared/ns-globals.d.ts +118 -0
  326. package/hmr/shared/ns-globals.js +29 -0
  327. package/hmr/shared/ns-globals.js.map +1 -0
  328. package/hmr/shared/protocol.d.ts +145 -0
  329. package/hmr/shared/protocol.js +28 -0
  330. package/hmr/shared/protocol.js.map +1 -0
  331. package/hmr/shared/runtime/boot-placeholder-ui.d.ts +69 -0
  332. package/hmr/shared/runtime/boot-placeholder-ui.js +101 -0
  333. package/hmr/shared/runtime/boot-placeholder-ui.js.map +1 -0
  334. package/hmr/shared/runtime/boot-progress.d.ts +44 -0
  335. package/hmr/shared/runtime/boot-progress.js +133 -0
  336. package/hmr/shared/runtime/boot-progress.js.map +1 -0
  337. package/hmr/shared/runtime/boot-timeline.d.ts +18 -0
  338. package/hmr/shared/runtime/boot-timeline.js +42 -0
  339. package/hmr/shared/runtime/boot-timeline.js.map +1 -0
  340. package/hmr/shared/runtime/browser-runtime-contract.js.map +1 -1
  341. package/hmr/shared/runtime/dev-overlay-snapshots.d.ts +31 -0
  342. package/hmr/shared/runtime/dev-overlay-snapshots.js +324 -0
  343. package/hmr/shared/runtime/dev-overlay-snapshots.js.map +1 -0
  344. package/hmr/shared/runtime/dev-overlay.d.ts +119 -26
  345. package/hmr/shared/runtime/dev-overlay.js +1196 -262
  346. package/hmr/shared/runtime/dev-overlay.js.map +1 -1
  347. package/hmr/shared/runtime/global-scope.d.ts +18 -0
  348. package/hmr/shared/runtime/global-scope.js +21 -0
  349. package/hmr/shared/runtime/global-scope.js.map +1 -0
  350. package/hmr/shared/runtime/hooks.js +2 -1
  351. package/hmr/shared/runtime/hooks.js.map +1 -1
  352. package/hmr/shared/runtime/http-only-boot.js +7 -6
  353. package/hmr/shared/runtime/http-only-boot.js.map +1 -1
  354. package/hmr/shared/runtime/module-provenance.js +4 -6
  355. package/hmr/shared/runtime/module-provenance.js.map +1 -1
  356. package/hmr/shared/runtime/root-placeholder-view.d.ts +19 -0
  357. package/hmr/shared/runtime/root-placeholder-view.js +311 -0
  358. package/hmr/shared/runtime/root-placeholder-view.js.map +1 -0
  359. package/hmr/shared/runtime/root-placeholder.js +393 -200
  360. package/hmr/shared/runtime/root-placeholder.js.map +1 -1
  361. package/hmr/shared/runtime/session-bootstrap.js +168 -4
  362. package/hmr/shared/runtime/session-bootstrap.js.map +1 -1
  363. package/hmr/shared/runtime/vendor-bootstrap.js +3 -10
  364. package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
  365. package/hmr/shared/vendor/manifest-collect.d.ts +4 -0
  366. package/hmr/shared/vendor/manifest-collect.js +549 -0
  367. package/hmr/shared/vendor/manifest-collect.js.map +1 -0
  368. package/hmr/shared/vendor/manifest-loader.d.ts +2 -1
  369. package/hmr/shared/vendor/manifest-loader.js +5 -3
  370. package/hmr/shared/vendor/manifest-loader.js.map +1 -1
  371. package/hmr/shared/vendor/manifest.d.ts +1 -7
  372. package/hmr/shared/vendor/manifest.js +84 -819
  373. package/hmr/shared/vendor/manifest.js.map +1 -1
  374. package/hmr/shared/vendor/vendor-device-shim.d.ts +1 -0
  375. package/hmr/shared/vendor/vendor-device-shim.js +208 -0
  376. package/hmr/shared/vendor/vendor-device-shim.js.map +1 -0
  377. package/hmr/shared/vendor/vendor-esbuild-plugins.d.ts +38 -0
  378. package/hmr/shared/vendor/vendor-esbuild-plugins.js +296 -0
  379. package/hmr/shared/vendor/vendor-esbuild-plugins.js.map +1 -0
  380. package/hmr/vendor-bootstrap.d.ts +1 -3
  381. package/hmr/vendor-bootstrap.js +4 -6
  382. package/hmr/vendor-bootstrap.js.map +1 -1
  383. package/index.d.ts +1 -0
  384. package/index.js +5 -0
  385. package/index.js.map +1 -1
  386. package/package.json +61 -11
  387. package/runtime/core-aliases-early.js +25 -55
  388. package/runtime/core-aliases-early.js.map +1 -1
  389. package/shims/react-jsx-runtime.d.ts +4 -0
  390. package/shims/react-jsx-runtime.js +61 -0
  391. package/shims/react-jsx-runtime.js.map +1 -0
  392. package/helpers/angular/angular-linker.d.ts +0 -13
  393. package/helpers/angular/angular-linker.js +0 -194
  394. package/helpers/angular/angular-linker.js.map +0 -1
  395. package/helpers/angular/inline-decorator-component-templates.js.map +0 -1
  396. package/helpers/angular/shared-linker.d.ts +0 -11
  397. package/helpers/angular/shared-linker.js +0 -75
  398. package/helpers/angular/shared-linker.js.map +0 -1
  399. package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +0 -1
  400. package/helpers/angular/synthesize-injectable-factories.js.map +0 -1
  401. package/helpers/angular/util.js +0 -67
  402. package/helpers/angular/util.js.map +0 -1
  403. package/helpers/prelink-angular.d.ts +0 -2
  404. package/helpers/prelink-angular.js +0 -117
  405. package/helpers/prelink-angular.js.map +0 -1
  406. package/hmr/server/websocket-angular-entry.js.map +0 -1
  407. package/hmr/server/websocket-angular-hot-update.js +0 -239
  408. package/hmr/server/websocket-angular-hot-update.js.map +0 -1
  409. package/hmr/server/websocket-ns-m-finalize.d.ts +0 -22
  410. package/hmr/server/websocket-ns-m-finalize.js +0 -88
  411. package/hmr/server/websocket-ns-m-finalize.js.map +0 -1
  412. package/hmr/server/websocket-runtime-compat.d.ts +0 -19
  413. package/hmr/server/websocket-runtime-compat.js +0 -286
  414. package/hmr/server/websocket-runtime-compat.js.map +0 -1
  415. package/hmr/server/websocket-vue-sfc.d.ts +0 -27
  416. package/hmr/server/websocket-vue-sfc.js +0 -1117
  417. package/hmr/server/websocket-vue-sfc.js.map +0 -1
  418. package/transformers/NativeClass/index.d.ts +0 -2
  419. package/transformers/NativeClass/index.js +0 -222
  420. package/transformers/NativeClass/index.js.map +0 -1
  421. /package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.d.ts +0 -0
  422. /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-decorator-ctor-parameters.d.ts +0 -0
  423. /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.d.ts +0 -0
  424. /package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.d.ts +0 -0
@@ -1,12 +1,12 @@
1
1
  import * as esbuild from 'esbuild';
2
- import { readFile } from 'fs/promises';
3
2
  import path from 'path';
4
- import { readFileSync } from 'fs';
5
3
  import { createHash } from 'crypto';
6
- import { createRequire } from 'node:module';
7
4
  import { registerVendorManifest, clearVendorManifest, getVendorManifest } from './registry.js';
5
+ import { collectVendorModules } from './manifest-collect.js';
8
6
  import { generatePlatformPolyfills } from '../runtime/platform-polyfills.js';
9
7
  import { createNativeClassEsbuildPlugin } from '../../../helpers/nativeclass-esbuild-plugin.js';
8
+ import { getGlobalDefines } from '../../../helpers/global-defines.js';
9
+ import { createVendorEsbuildPlugin, createSolidJsxEsbuildPlugin, angularLinkerEsbuildPlugin, createUnicodeRegexEsbuildPlugin } from './vendor-esbuild-plugins.js';
10
10
  export const VENDOR_MANIFEST_ID = '@nativescript/vendor-manifest';
11
11
  export const VENDOR_MANIFEST_VIRTUAL_ID = '\0' + VENDOR_MANIFEST_ID;
12
12
  export const VENDOR_BUNDLE_ID = '@nativescript/vendor';
@@ -15,105 +15,6 @@ export const SERVER_VENDOR_PATH = '/@nativescript/vendor.mjs';
15
15
  export const SERVER_MANIFEST_PATH = '/@nativescript/vendor-manifest.json';
16
16
  export const DEFAULT_VENDOR_FILENAME = 'ns-vendor.mjs';
17
17
  export const DEFAULT_MANIFEST_FILENAME = 'ns-vendor-manifest.json';
18
- // Do not force-include @nativescript/core in the dev vendor bundle.
19
- // Keeping core out of vendor avoids duplicate side-effect registrations (e.g.,
20
- // com.tns.FragmentClass, com.tns.NativeScriptActivity) across bundle.mjs and vendor.
21
- // Force runtime-sensitive packages onto the vendor path so they do not drift
22
- // between startup bundle, HTTP-wrapped CommonJS, and base-require semantics
23
- // during HMR sessions.
24
- const ALWAYS_INCLUDE = new Set(['stacktrace-js']);
25
- const ALWAYS_EXCLUDE = new Set([
26
- '@nativescript/android',
27
- '@nativescript/ios',
28
- '@nativescript/types',
29
- '@nativescript/webpack',
30
- // Angular browser animations are not used in NativeScript; excluding reduces
31
- // memory pressure and avoids bringing partial declarations into vendor.
32
- '@angular/animations',
33
- '@angular/platform-browser/animations',
34
- // Not needed at runtime with linked partials; reduce vendor size/memory.
35
- '@angular/platform-browser-dynamic',
36
- // Native add-on helpers pulled by ws or others; exclude in NS dev vendor
37
- 'bufferutil',
38
- 'utf-8-validate',
39
- 'node-gyp-build',
40
- 'bufferutil',
41
- 'utf-8-validate',
42
- 'node-gyp-build',
43
- // All @babel/* and babel-* packages are build-time tools, never runtime deps.
44
- // They get pulled in as peer deps of packages like @nativescript-community/solid-js
45
- // but should never be in the vendor bundle (they require 'fs', 'path', etc.).
46
- '@babel/core',
47
- '@babel/helper-plugin-utils',
48
- '@babel/generator',
49
- '@babel/helper-string-parser',
50
- '@babel/helper-validator-identifier',
51
- '@babel/parser',
52
- '@babel/plugin-syntax-typescript',
53
- '@babel/plugin-transform-typescript',
54
- '@babel/preset-typescript',
55
- '@babel/preset-env',
56
- '@babel/types',
57
- 'babel-preset-solid',
58
- 'babel-plugin-jsx-dom-expressions',
59
- // Heavy dependency not needed in vendor dev bundle; fetch via HTTP loader instead
60
- 'rxjs',
61
- 'nativescript',
62
- 'typescript',
63
- 'ts-node',
64
- 'vue-tsc',
65
- 'ws',
66
- '@types/node',
67
- 'nativescript-theme-core',
68
- // Build-time tools that get pulled in as transitive dependencies but should
69
- // never be in the device vendor bundle (they require Node built-ins like fs,
70
- // path, child_process, etc.). Now that we collect transitive runtime deps,
71
- // these need explicit exclusion.
72
- 'esbuild',
73
- 'prettier',
74
- 'acorn',
75
- 'recast',
76
- 'source-map',
77
- 'source-map-js',
78
- 'tsx',
79
- 'diff',
80
- 'esprima',
81
- // TanStack build-time router tooling (code generation, file-based routing)
82
- '@tanstack/router-plugin',
83
- '@tanstack/router-generator',
84
- '@tanstack/router-utils',
85
- '@tanstack/virtual-file-routes',
86
- // File system / glob utilities — build-time only, require Node fs
87
- 'fdir',
88
- 'picomatch',
89
- 'tinyglobby',
90
- // SSR-only library (bot detection) — not needed on device
91
- 'isbot',
92
- // Type-only packages with no runtime JavaScript
93
- 'csstype',
94
- // NativeScript CLI hook system — build-time only, requires Node os/path
95
- '@nativescript/hook',
96
- // Test runner uses webpack's require.context API which doesn't exist in Vite.
97
- // Including it in the vendor bundle causes __require.context crashes at runtime.
98
- '@nativescript/unit-test-runner',
99
- 'nativescript-unit-test-runner',
100
- // CSS build tools — postcss, tailwindcss, and related tooling are exclusively
101
- // build-time processors. They require Node APIs (process, fs, path) and must
102
- // never run on device. esbuild bundles their transitive deps (picocolors,
103
- // nanoid, etc.) which reference `process` and crash at runtime.
104
- 'tailwindcss',
105
- '@nativescript/tailwind',
106
- 'postcss',
107
- 'autoprefixer',
108
- 'postcss-import',
109
- 'postcss-url',
110
- 'postcss-nested',
111
- 'picocolors',
112
- 'nanoid',
113
- // Server-side SDKs that require Node networking APIs (net, tls, dns, crypto).
114
- // These are backend tools, not device-side.
115
- 'mongodb',
116
- ]);
117
18
  const INDEX_ALIAS_SUFFIXES = ['/index', '/index.js', '/index.android.js', '/index.ios.js', '/index.visionos.js'];
118
19
  export function vendorManifestPlugin(options) {
119
20
  let cachedResult = null;
@@ -289,10 +190,41 @@ async function generateVendorBundle(options) {
289
190
  }));
290
191
  },
291
192
  };
193
+ // Externalize the `solid-js` root specifier for the Solid flavor so
194
+ // vendor-bundled packages (e.g. `@nativescript-community/solid-js`,
195
+ // `solid-navigation`, transitively `solid-js/universal` and
196
+ // `solid-js/store`) don't bake their own copy of solid-js into
197
+ // vendor.mjs. The dev server's import map (see `import-map.ts`)
198
+ // redirects bare `solid-js` to the same `/ns/m/node_modules/solid-js/...`
199
+ // URL that Vite's alias produces for user code and `@solid-refresh`,
200
+ // so V8 dedupes the three import paths down to a single module
201
+ // instance — one `Owner` module-local, one reactive graph, one
202
+ // `$DEVCOMP`/`$PROXY` symbol identity across the whole app.
203
+ //
204
+ // Important: scope this to the EXACT bare `solid-js` specifier. Subpaths
205
+ // like `solid-js/store`, `solid-js/universal`, `solid-js/web` stay
206
+ // bundleable so vendor packages that import them keep working out of
207
+ // the box; those subpaths still go through the unified solid-js
208
+ // runtime via their own `import 'solid-js'` statements (which we just
209
+ // externalized).
210
+ const nsSolidJsExternalPlugin = {
211
+ name: 'ns-solid-js-external',
212
+ setup(build) {
213
+ build.onResolve({ filter: /^solid-js$/ }, (args) => ({
214
+ path: args.path,
215
+ external: true,
216
+ }));
217
+ },
218
+ };
292
219
  const plugins = [
293
220
  // Mark @nativescript/core external BEFORE other plugins so esbuild never
294
221
  // tries to read/transform core's source files. See comment above.
295
222
  nsCoreExternalPlugin,
223
+ // For the Solid flavor, externalize `solid-js` so vendor.mjs and the
224
+ // HTTP-served `@solid-refresh` / user code converge on one runtime
225
+ // realm. See `nsSolidJsExternalPlugin`'s definition for the full
226
+ // duplicate-instance rationale.
227
+ ...(flavor === 'solid' ? [nsSolidJsExternalPlugin] : []),
296
228
  // Apply NativeClass transformer to convert @NativeClass decorated classes to ES5 IIFE pattern.
297
229
  // This MUST run before other plugins to ensure proper transformation.
298
230
  createNativeClassEsbuildPlugin(platform),
@@ -314,6 +246,12 @@ async function generateVendorBundle(options) {
314
246
  if (flavor === 'solid') {
315
247
  plugins.push(createSolidJsxEsbuildPlugin(projectRoot));
316
248
  }
249
+ // Registered last so the framework-specific passes above own their files
250
+ // first (esbuild stops at the first onLoad that returns a result). Applies
251
+ // to every flavor: any vendored dependency (e.g. highlight.js) may ship
252
+ // `\p{…}` regexes that NativeScript's non-ICU V8 cannot compile, which would
253
+ // otherwise abort the entire vendor.mjs compile. See the plugin for details.
254
+ plugins.push(createUnicodeRegexEsbuildPlugin(projectRoot));
317
255
  const buildResult = await esbuild.build({
318
256
  stdin: {
319
257
  contents: entryCode,
@@ -353,9 +291,31 @@ async function generateVendorBundle(options) {
353
291
  '.css': 'text',
354
292
  '.json': 'json',
355
293
  },
356
- define: {
357
- 'process.env.NODE_ENV': JSON.stringify(mode),
358
- },
294
+ // Mirror Vite's main-bundle DefinePlugin in the vendor esbuild build.
295
+ //
296
+ // esbuild's `define` requires every value to be a JS expression
297
+ // expressed as a string (the same constraint Vite normalises away).
298
+ // `getGlobalDefines()` returns a few raw `boolean` values for
299
+ // historical reasons (e.g. `__COMMONJS__: false`,
300
+ // `__UI_USE_XML_PARSER__: true`), so coerce any non-string entries
301
+ // through `JSON.stringify` before handing the table to esbuild.
302
+ define: (() => {
303
+ const raw = getGlobalDefines({
304
+ platform,
305
+ targetMode: mode,
306
+ verbose: !!options.verbose,
307
+ flavor: flavor ?? '',
308
+ isCI: !!process.env.CI,
309
+ });
310
+ const out = {};
311
+ for (const [key, value] of Object.entries(raw)) {
312
+ out[key] = typeof value === 'string' ? value : JSON.stringify(value);
313
+ }
314
+ // Belt-and-suspenders: keep the original NODE_ENV define explicit so
315
+ // future changes to `getGlobalDefines()` can't silently drop it.
316
+ out['process.env.NODE_ENV'] = JSON.stringify(mode);
317
+ return out;
318
+ })(),
359
319
  plugins,
360
320
  // Externalize ALL Node built-in modules. The vendor bundle runs on the
361
321
  // NativeScript device runtime, not Node, so any Node API reference must
@@ -477,238 +437,32 @@ async function generateVendorBundle(options) {
477
437
  entries: collected.entries,
478
438
  };
479
439
  }
480
- function collectVendorModules(projectRoot, platform, flavor) {
481
- const packageJsonPath = path.resolve(projectRoot, 'package.json');
482
- const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
483
- const projectRequire = createRequire(packageJsonPath);
484
- const vendor = new Set();
485
- const visited = new Set();
486
- const queue = [];
487
- const isPackageRootSpecifier = (name) => {
488
- if (!name)
489
- return false;
490
- if (name.startsWith('@')) {
491
- // Scoped: @scope/name is root; anything deeper is subpath
492
- const parts = name.split('/');
493
- return parts.length === 2;
494
- }
495
- // Unscoped: no slash means root; any slash means subpath
496
- return !name.includes('/');
497
- };
498
- const isAngularFlavor = flavor === 'angular';
499
- const addCandidate = (name) => {
500
- if (!name || shouldSkipDependency(name)) {
501
- return;
502
- }
503
- // Avoid pulling Angular compiler/runtime into the dev vendor bundle when
504
- // the current project flavor is not Angular (for example, solid). This
505
- // prevents esbuild from trying to bundle @angular/compiler and its Babel
506
- // toolchain, which requires Node built-ins like fs/path/url.
507
- if (!isAngularFlavor && (name === '@angular/compiler' || name.startsWith('@angular/'))) {
508
- return;
509
- }
510
- // Skip already-visited packages to avoid redundant queue processing
511
- if (visited.has(name)) {
512
- return;
513
- }
514
- visited.add(name);
515
- vendor.add(name);
516
- const isRoot = isPackageRootSpecifier(name);
517
- // Only traverse deps for package roots; subpaths should not attempt package.json resolution
518
- if (isRoot) {
519
- queue.push(name);
520
- }
521
- };
522
- const addDeps = (deps) => {
523
- if (!deps) {
524
- return;
525
- }
526
- for (const name of Object.keys(deps)) {
527
- addCandidate(name);
528
- }
529
- };
530
- addDeps(pkg.dependencies);
531
- addDeps(pkg.optionalDependencies);
532
- for (const name of ALWAYS_INCLUDE) {
533
- // Some force-included packages are only present transitively in apps that
534
- // actually use them. Skip missing packages quietly so unrelated projects do
535
- // not fail vendor collection just because the policy list names them.
536
- if (canResolveDependencyPackageJson(name, projectRequire)) {
537
- addCandidate(name);
538
- }
539
- }
540
- // Ensure Android Activity proxy is present for SBG scanning in dev/HMR
541
- // and non-HMR builds alike: explicitly include the side-effect module
542
- // that registers `com.tns.NativeScriptActivity`.
543
- if (platform === 'android') {
544
- addCandidate('@nativescript/core/ui/frame/activity.android');
545
- }
546
- if (pkg.dependencies?.['nativescript-vue'] && pkg.devDependencies?.vue) {
547
- addCandidate('vue');
548
- }
549
- // Angular framework packages are intentionally NOT added to vendor. They are
550
- // served via HTTP only so every importer resolves to a single module realm.
551
- // See shouldSkipDependency() for the full rationale. RxJS is also left out of
552
- // vendor (large, and not required in the vendor bundle for dev HMR).
553
- if (pkg.dependencies?.['react-nativescript']) {
554
- if (pkg.dependencies?.react) {
555
- addCandidate('react');
556
- }
557
- if (pkg.dependencies?.['react-dom']) {
558
- addCandidate('react-dom');
559
- }
560
- }
561
- // SolidJS / TanStack Router: when @nativescript/tanstack-router is a dependency,
562
- // its runtime deps (@tanstack/solid-router, @tanstack/router-core, @tanstack/history)
563
- // MUST be in the vendor bundle. These packages:
564
- // 1. Use browser APIs (window.dispatchEvent) that don't exist in NativeScript — they
565
- // must be bundled where the NativeScript wrapper intercepts those calls
566
- // 2. Contain JSX source that needs Solid compilation (dist/source/*.jsx) — the HTTP
567
- // fallback can't compile node_modules JSX since vite-plugin-solid skips it
568
- // 3. Import solid-js internally — loading via HTTP creates a separate solid-js instance
569
- // esbuild uses the 'import' condition (not 'solid'), resolving to pre-compiled
570
- // dist/esm/*.js which avoids all three issues.
571
- if (pkg.dependencies?.['@nativescript/tanstack-router']) {
572
- addCandidate('@tanstack/solid-router');
573
- addCandidate('@tanstack/router-core');
574
- addCandidate('@tanstack/history');
575
- }
576
- parseEnvList(process.env.NS_VENDOR_INCLUDE).forEach(addCandidate);
577
- const projectDeps = {
578
- dependencies: new Set(Object.keys(pkg.dependencies ?? {})),
579
- optional: new Set(Object.keys(pkg.optionalDependencies ?? {})),
580
- dev: new Set(Object.keys(pkg.devDependencies ?? {})),
581
- };
582
- while (queue.length) {
583
- const specifier = queue.shift();
584
- const dependencyPkg = readDependencyPackageJson(specifier, projectRequire);
585
- if (!dependencyPkg) {
586
- continue;
587
- }
588
- const peerDependencies = Object.keys(dependencyPkg.peerDependencies ?? {});
589
- for (const peer of peerDependencies) {
590
- if (shouldSkipDependency(peer)) {
591
- continue;
592
- }
593
- if (projectDeps.dependencies.has(peer) || projectDeps.optional.has(peer) || projectDeps.dev.has(peer)) {
594
- addCandidate(peer);
595
- }
596
- }
597
- // NOTE: We intentionally do NOT collect transitive runtime dependencies
598
- // here. The import map + runtime specifier normalization handles non-vendor
599
- // packages by routing them through HTTP to the Vite dev server. This avoids
600
- // the fragility of trying to esbuild-bundle every transitive dep (which can
601
- // fail due to Node built-ins, type-only packages, duplicate module instances,
602
- // etc.). Only direct project dependencies go into the vendor bundle.
603
- }
604
- parseEnvList(process.env.NS_VENDOR_EXCLUDE).forEach((name) => {
605
- vendor.delete(name);
606
- });
607
- return {
608
- entries: Array.from(vendor).sort(),
609
- };
610
- }
611
- function shouldSkipDependency(name) {
612
- if (!name) {
613
- return true;
614
- }
615
- if (ALWAYS_EXCLUDE.has(name)) {
616
- return true;
617
- }
618
- // Angular framework packages must only be served via the HTTP path so every
619
- // importer resolves to a single module realm. When these packages are present
620
- // in the vendor bundle AND imported by app modules via HTTP subpath, every
621
- // @Component/@Injectable gets defined twice (once per realm), producing NG0912
622
- // selector collisions, cross-realm `instanceof` failures, and dual class
623
- // identities throughout Angular's DI container. HTTP-only is the single-realm
624
- // invariant for user-level framework code.
625
- if (name === '@nativescript/angular' || name === 'nativescript-angular' || name.startsWith('@angular/')) {
626
- return true;
627
- }
628
- // All Babel packages are build tools — never bundle into device runtime.
629
- // They require Node built-ins (fs, path, url) that don't exist on device.
630
- if (name.startsWith('@babel/') || name.startsWith('babel-')) {
631
- return true;
632
- }
633
- // Dev tools and type-only packages — not needed on device
634
- if (name.startsWith('@solid-devtools/')) {
635
- return true;
636
- }
637
- if (name.startsWith('@types/')) {
638
- return true;
639
- }
640
- // PostCSS ecosystem — all build-time CSS processing
641
- if (name === 'postcss' || name.startsWith('postcss-')) {
642
- return true;
643
- }
644
- // Tailwind ecosystem — build-time only CSS framework
645
- if (name.includes('tailwind')) {
646
- return true;
647
- }
648
- // Test runners and frameworks — never needed on device
649
- if (name.includes('test-runner') || name.includes('unit-test')) {
650
- return true;
651
- }
652
- // Linters and formatters — build-time tools
653
- if (name.includes('eslint') || name.includes('stylelint')) {
654
- return true;
655
- }
656
- if (name.startsWith('.')) {
657
- return true;
658
- }
659
- if (name.startsWith('file:')) {
660
- return true;
661
- }
662
- if (name.startsWith('workspace:')) {
663
- return true;
664
- }
665
- if (name.startsWith('link:')) {
666
- return true;
667
- }
668
- return false;
669
- }
670
- export const __test_collectVendorModules = collectVendorModules;
671
- export const __test_createVendorBundleRuntimeModule = createVendorBundleRuntimeModule;
672
- function canResolveDependencyPackageJson(specifier, projectRequire) {
673
- try {
674
- projectRequire.resolve(`${specifier}/package.json`);
675
- return true;
676
- }
677
- catch {
678
- return false;
679
- }
680
- }
681
- function readDependencyPackageJson(specifier, projectRequire) {
682
- try {
683
- const packageJsonPath = projectRequire.resolve(`${specifier}/package.json`);
684
- return JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
685
- }
686
- catch (error) {
687
- if (process.env.VITE_DEBUG_LOGS) {
688
- console.warn(`[vendor] unable to resolve ${specifier} package.json`, error);
689
- }
690
- return null;
691
- }
692
- }
693
- function parseEnvList(value) {
694
- if (!value) {
695
- return [];
696
- }
697
- return value
698
- .split(',')
699
- .map((token) => token.trim())
700
- .filter(Boolean);
701
- }
702
440
  function createVendorEntry(entries) {
703
441
  if (!entries.length) {
704
442
  return `export const __nsVendorModuleMap = {};
705
443
  `;
706
444
  }
707
- const imports = entries.map((specifier, index) => `import * as __nsVendor_${index} from ${JSON.stringify(specifier)};`).join('\n');
445
+ // Emit a side-effect-only import FIRST for each entry, then the namespace
446
+ // import we actually expose through `__nsVendorModuleMap`. Per the ESM
447
+ // spec, `import "pkg";` (no clause) guarantees module body evaluation, and
448
+ // esbuild treats these as DCE-immune even when the package declares
449
+ // `"sideEffects": false`. Without this, packages whose top-level
450
+ // statements install runtime patches (e.g. `@nativescript-community/text`
451
+ // monkey-patching `TextBase.prototype.setTextDecorationAndTransform` via
452
+ // `overrideSpanAndFormattedString()` invoked from
453
+ // `@nativescript-community/ui-label/index-common.js` line 12) can have
454
+ // their bodies elided by esbuild — exports stay resolvable via the
455
+ // namespace, but the runtime patches never fire, producing line-height /
456
+ // letter-spacing / formatted-text rendering divergence between HMR
457
+ // (vendor.mjs via HTTP) and no-HMR (single Rolldown bundle that inlines
458
+ // everything anyway). This affects any NS plugin that relies on top-level
459
+ // side-effects to wire up renderer behavior.
460
+ const sideEffectImports = entries.map((specifier) => `import ${JSON.stringify(specifier)};`).join('\n');
461
+ const namespaceImports = entries.map((specifier, index) => `import * as __nsVendor_${index} from ${JSON.stringify(specifier)};`).join('\n');
708
462
  const modules = entries.map((specifier, index) => `${JSON.stringify(specifier)}: __nsVendor_${index}`).join(',\n ');
709
- return `${imports}\n\nexport const __nsVendorModuleMap = {\n ${modules}\n};\n`;
463
+ return `${sideEffectImports}\n\n${namespaceImports}\n\nexport const __nsVendorModuleMap = {\n ${modules}\n};\n`;
710
464
  }
711
- function createVendorBundleRuntimeModule(result) {
465
+ export function createVendorBundleRuntimeModule(result) {
712
466
  return `${result.code}
713
467
  export const vendorManifest = ${JSON.stringify(result.manifest)};
714
468
  export default vendorManifest;
@@ -771,495 +525,6 @@ function createSbgVendorAssetCode(platform) {
771
525
  lines.push('export const __nsVendorModuleMap = {};\nexport default {};\n');
772
526
  return lines.join('\n');
773
527
  }
774
- function createVendorEsbuildPlugin(projectRoot) {
775
- return {
776
- name: 'ns-vendor-resolver',
777
- setup(build) {
778
- const debug = process.env.VITE_DEBUG_LOGS === 'true' || process.env.VITE_DEBUG_LOGS === '1';
779
- build.onResolve({ filter: /^~\/package\.json$/ }, () => ({
780
- path: path.resolve(projectRoot, 'package.json'),
781
- }));
782
- build.onResolve({ filter: /^module$/ }, () => ({
783
- path: 'ns-vendor-module-shim',
784
- namespace: 'ns-vendor',
785
- }));
786
- build.onLoad({ filter: /^ns-vendor-module-shim$/, namespace: 'ns-vendor' }, () => ({
787
- contents: vendorModuleShim,
788
- loader: 'js',
789
- }));
790
- // Stub Angular animations in vendor to avoid bundling browser-only code.
791
- // Provide named exports expected by @nativescript/angular to satisfy esbuild.
792
- const PB_ANIMATIONS_ID = 'ns-animations-pb-shim';
793
- const ANIMATIONS_BROWSER_ID = 'ns-animations-browser-shim';
794
- const ANIMATIONS_ID = 'ns-animations-noop';
795
- // @angular/platform-browser/animations -> provide concrete named stubs
796
- build.onResolve({ filter: /^@angular\/platform-browser\/animations(?:\/.*)?$/ }, (args) => {
797
- if (debug) {
798
- try {
799
- console.log('[vendor] map', args.path, '->', PB_ANIMATIONS_ID);
800
- }
801
- catch { }
802
- }
803
- return { path: PB_ANIMATIONS_ID, namespace: 'ns-vendor' };
804
- });
805
- build.onLoad({ filter: new RegExp(`^${PB_ANIMATIONS_ID}$`), namespace: 'ns-vendor' }, () => ({
806
- contents: [
807
- 'export default {};',
808
- // Commonly imported symbols by @nativescript/angular
809
- 'export class AnimationBuilder {};',
810
- 'export const \u0275BrowserAnimationBuilder = class {};',
811
- 'export const \u0275AnimationEngine = class {};',
812
- 'export const \u0275AnimationRendererFactory = class {};',
813
- 'export const \u0275WebAnimationsStyleNormalizer = class {};',
814
- // Typical platform-browser/animations APIs exported; safe no-ops
815
- 'export class BrowserAnimationsModule {};',
816
- 'export class NoopAnimationsModule {};',
817
- 'export const provideAnimations = (..._args) => [];',
818
- 'export const provideNoopAnimations = (..._args) => [];',
819
- // Marker used by some Angular internals
820
- 'export const ANIMATION_MODULE_TYPE = void 0;',
821
- ].join('\n'),
822
- loader: 'js',
823
- }));
824
- // @angular/animations/browser -> provide ɵ* engine/renderer/style normalizer stubs
825
- build.onResolve({ filter: /^@angular\/animations\/browser(?:\/.*)?$/ }, (args) => {
826
- if (debug) {
827
- try {
828
- console.log('[vendor] map', args.path, '->', ANIMATIONS_BROWSER_ID);
829
- }
830
- catch { }
831
- }
832
- return { path: ANIMATIONS_BROWSER_ID, namespace: 'ns-vendor' };
833
- });
834
- build.onLoad({ filter: new RegExp(`^${ANIMATIONS_BROWSER_ID}$`), namespace: 'ns-vendor' }, () => ({
835
- contents: [
836
- 'export default {};',
837
- 'export class AnimationDriver {};',
838
- 'export const \u0275AnimationRendererFactory = class {};',
839
- 'export const \u0275AnimationStyleNormalizer = class {};',
840
- 'export const \u0275WebAnimationsStyleNormalizer = class {};',
841
- 'export const \u0275AnimationEngine = class {};',
842
- // Convenience alias if any consumers import non-ɵ name
843
- 'export const AnimationStyleNormalizer = \u0275AnimationStyleNormalizer;',
844
- ].join('\n'),
845
- loader: 'js',
846
- }));
847
- // @angular/animations -> broad no-op surface
848
- build.onResolve(
849
- // Keep generic mapping for @angular/animations base; /browser is handled above
850
- { filter: /^@angular\/animations(?:$|\/)$/ }, (args) => {
851
- if (debug) {
852
- try {
853
- console.log('[vendor] map', args.path, '->', ANIMATIONS_ID);
854
- }
855
- catch { }
856
- }
857
- return { path: ANIMATIONS_ID, namespace: 'ns-vendor' };
858
- });
859
- build.onLoad({ filter: new RegExp(`^${ANIMATIONS_ID}$`), namespace: 'ns-vendor' }, () => ({
860
- contents: [
861
- 'export default {};',
862
- // Provide names sometimes (incorrectly) imported from @angular/animations by wrappers
863
- 'export class AnimationBuilder {};',
864
- 'export const \u0275BrowserAnimationBuilder = class {};',
865
- 'export const \u0275AnimationEngine = class {};',
866
- 'export const \u0275AnimationRendererFactory = class {};',
867
- 'export const \u0275WebAnimationsStyleNormalizer = class {};',
868
- 'export const ANIMATION_MODULE_TYPE = void 0;',
869
- // Export a few common tokens as harmless stubs
870
- 'export const animate = (..._a) => ({});',
871
- 'export const state = (..._a) => ({});',
872
- 'export const style = (..._a) => ({});',
873
- 'export const transition = (..._a) => ({});',
874
- 'export const trigger = (..._a) => ({});',
875
- 'export const sequence = (..._a) => ({});',
876
- 'export const group = (..._a) => ({});',
877
- 'export const query = (..._a) => ({});',
878
- 'export const stagger = (..._a) => ({});',
879
- 'export const keyframes = (..._a) => ({});',
880
- ].join('\n'),
881
- loader: 'js',
882
- }));
883
- },
884
- };
885
- }
886
- /**
887
- * esbuild plugin to compile .jsx/.tsx files from Solid packages through
888
- * babel-preset-solid. Without this, esbuild uses its default React JSX
889
- * transform, producing React.createElement calls that crash at runtime.
890
- *
891
- * Only applied to files inside node_modules that have .jsx or .tsx extension.
892
- */
893
- function createSolidJsxEsbuildPlugin(projectRoot) {
894
- // Lazy-load Babel and the Solid preset so they're only required when
895
- // the Solid flavor is active.
896
- let babel;
897
- let solidPreset;
898
- return {
899
- name: 'ns-vendor-solid-jsx',
900
- setup(build) {
901
- // Intercept .jsx and .tsx files from node_modules
902
- build.onLoad({ filter: /node_modules\/.*\.[jt]sx$/ }, async (args) => {
903
- try {
904
- if (!babel) {
905
- babel = await import('@babel/core');
906
- // babel-preset-solid is the standard Solid JSX transform
907
- solidPreset = (await import('babel-preset-solid')).default;
908
- }
909
- const source = await readFile(args.path, 'utf-8');
910
- const result = await babel.transformAsync(source, {
911
- filename: args.path,
912
- presets: [
913
- [
914
- solidPreset,
915
- {
916
- generate: 'universal',
917
- hydratable: false,
918
- moduleName: '@nativescript-community/solid-js',
919
- },
920
- ],
921
- ],
922
- parserOpts: {
923
- plugins: ['jsx', ...(args.path.endsWith('.tsx') ? ['typescript'] : [])],
924
- },
925
- ast: false,
926
- sourceMaps: false,
927
- configFile: false,
928
- babelrc: false,
929
- });
930
- if (result?.code) {
931
- return { contents: result.code, loader: 'js' };
932
- }
933
- }
934
- catch (e) {
935
- console.warn(`[ns-vendor-solid-jsx] failed to transform ${args.path}:`, e?.message || e);
936
- }
937
- // Fall through to esbuild's default handling
938
- return undefined;
939
- });
940
- },
941
- };
942
- }
943
- /**
944
- * Minimal esbuild plugin to run Angular linker (Babel) over partial-compiled
945
- * Angular packages in node_modules. This converts ɵɵngDeclare* calls into
946
- * ɵɵdefine* so runtime doesn't require the JIT compiler.
947
- */
948
- function angularLinkerEsbuildPlugin(projectRoot) {
949
- // Lazily resolve Babel and Angular linker from the project to avoid hard deps
950
- let babel = null;
951
- let createLinker = null;
952
- let angularFileSystem = null;
953
- async function ensureDeps() {
954
- if (babel && createLinker)
955
- return;
956
- try {
957
- const req = createRequire(projectRoot + '/package.json');
958
- // Resolve from the application project first
959
- const babelPath = req.resolve('@babel/core');
960
- const linkerPath = req.resolve('@angular/compiler-cli/linker/babel');
961
- babel = (await import(babelPath));
962
- const linkerMod = await import(linkerPath);
963
- createLinker = linkerMod.createLinkerPlugin || linkerMod.createEs2015LinkerPlugin || null;
964
- }
965
- catch {
966
- // As a fallback, try local resolution (hoisted installs)
967
- try {
968
- babel = (await import('@babel/core'));
969
- }
970
- catch { }
971
- try {
972
- const linkerMod = await import('@angular/compiler-cli/linker/babel');
973
- createLinker = linkerMod.createLinkerPlugin || linkerMod.createEs2015LinkerPlugin || null;
974
- }
975
- catch { }
976
- }
977
- // Angular 21+ requires a fileSystem for the linker plugin
978
- if (!angularFileSystem) {
979
- try {
980
- const req = createRequire(projectRoot + '/package.json');
981
- const cliPath = req.resolve('@angular/compiler-cli');
982
- const cliMod = await import(cliPath);
983
- if (cliMod.NodeJSFileSystem) {
984
- angularFileSystem = new cliMod.NodeJSFileSystem();
985
- }
986
- }
987
- catch { }
988
- if (!angularFileSystem) {
989
- try {
990
- const cliMod = await import('@angular/compiler-cli');
991
- if (cliMod.NodeJSFileSystem) {
992
- angularFileSystem = new cliMod.NodeJSFileSystem();
993
- }
994
- }
995
- catch { }
996
- }
997
- if (!angularFileSystem) {
998
- // Minimal fallback
999
- const nodePath = await import('node:path');
1000
- const nodeFs = await import('node:fs');
1001
- angularFileSystem = {
1002
- resolve: (...paths) => nodePath.resolve(...paths),
1003
- dirname: (p) => nodePath.dirname(p),
1004
- join: (...paths) => nodePath.join(...paths),
1005
- isRooted: (p) => nodePath.isAbsolute(p),
1006
- exists: (p) => nodeFs.existsSync(p),
1007
- readFile: (p) => nodeFs.readFileSync(p, 'utf8'),
1008
- };
1009
- }
1010
- }
1011
- }
1012
- // Restrict to Angular framework packages to minimize esbuild memory usage.
1013
- const FILTER = /node_modules\/(?:@angular|@nativescript\/angular)\/.*\.[mc]?js$/;
1014
- return {
1015
- name: 'ns-angular-linker',
1016
- async setup(build) {
1017
- const debug = process.env.VITE_DEBUG_LOGS === 'true' || process.env.VITE_DEBUG_LOGS === '1';
1018
- await ensureDeps();
1019
- if (!babel || !createLinker) {
1020
- // Nothing to do if deps unavailable
1021
- return;
1022
- }
1023
- build.onLoad({ filter: FILTER }, async (args) => {
1024
- try {
1025
- const source = await readFile(args.path, 'utf8');
1026
- // Fast-path: only run linker when partial declarations are present
1027
- if (!(source.includes('\u0275\u0275ngDeclare') || source.includes('ɵɵngDeclare'))) {
1028
- return { contents: source, loader: 'js' };
1029
- }
1030
- const plugin = createLinker({
1031
- sourceMapping: false,
1032
- fileSystem: angularFileSystem,
1033
- });
1034
- if (debug) {
1035
- try {
1036
- console.log('[ns-angular-linker][vendor] linking', args.path);
1037
- }
1038
- catch { }
1039
- }
1040
- const result = await babel.transformAsync(source, {
1041
- filename: args.path,
1042
- configFile: false,
1043
- babelrc: false,
1044
- sourceMaps: false,
1045
- compact: false,
1046
- plugins: [plugin],
1047
- });
1048
- return {
1049
- contents: (result && result.code) || source,
1050
- loader: 'js',
1051
- };
1052
- }
1053
- catch (e) {
1054
- // On any failure, return original source to avoid breaking the build
1055
- return { contents: await readFile(args.path, 'utf8'), loader: 'js' };
1056
- }
1057
- });
1058
- },
1059
- };
1060
- }
1061
- const vendorModuleShim = `
1062
- const g = globalThis;
1063
- const BACKSLASH = String.fromCharCode(92);
1064
-
1065
- function toForwardSlashes(input) {
1066
- return String(input ?? '').split(BACKSLASH).join('/');
1067
- }
1068
-
1069
- function getNativeScriptRequire() {
1070
- const nsRequire = typeof g.require === "function" ? g.require : null;
1071
- if (nsRequire) {
1072
- return nsRequire;
1073
- }
1074
- const legacy = g.__nsRequire;
1075
- if (typeof legacy === "function") {
1076
- return legacy;
1077
- }
1078
- return null;
1079
- }
1080
-
1081
- function getDocumentsPath() {
1082
- const cached = g.__NS_DOCUMENTS_PATH__;
1083
- if (typeof cached === "string" && cached.length) {
1084
- return toForwardSlashes(cached);
1085
- }
1086
- try {
1087
- const core = g.require ? g.require("@nativescript/core") : null;
1088
- const docsFolder = core?.knownFolders?.documents?.();
1089
- const docPath = docsFolder?.path;
1090
- if (docPath) {
1091
- const normalized = toForwardSlashes(docPath);
1092
- g.__NS_DOCUMENTS_PATH__ = normalized;
1093
- return normalized;
1094
- }
1095
- } catch (_err) {
1096
- // ignore - fallback to raw specifier
1097
- }
1098
- return null;
1099
- }
1100
-
1101
- function collapseSegments(input) {
1102
- const segments = [];
1103
- const parts = input.split('/');
1104
- for (const part of parts) {
1105
- if (!part || part === ".") {
1106
- continue;
1107
- }
1108
- if (part === "..") {
1109
- if (segments.length && segments[segments.length - 1] !== "..") {
1110
- segments.pop();
1111
- continue;
1112
- }
1113
- }
1114
- segments.push(part);
1115
- }
1116
- const leadingSlash = input.startsWith('/');
1117
- return (leadingSlash ? '/' : '') + segments.join('/');
1118
- }
1119
-
1120
- function normalizeSpecifier(spec) {
1121
- let value = String(spec ?? "");
1122
- value = toForwardSlashes(value);
1123
- const docsPath = getDocumentsPath();
1124
- if (value.startsWith("__NSDOC__/")) {
1125
- if (docsPath) {
1126
- value = docsPath + '/' + value.slice("__NSDOC__/".length);
1127
- } else {
1128
- value = value.slice("__NSDOC__/".length);
1129
- }
1130
- }
1131
- if (value.startsWith("~/") && docsPath) {
1132
- value = docsPath + '/' + value.slice(2);
1133
- }
1134
- if (value.startsWith("file://")) {
1135
- const stripped = value.slice("file://".length);
1136
- value = stripped.startsWith('/') ? stripped : '/' + stripped;
1137
- }
1138
- if (value.includes("/../") || value.includes("/./")) {
1139
- value = collapseSegments(value);
1140
- }
1141
- return value;
1142
- }
1143
-
1144
- function normalizeCoreSubLocal(s) {
1145
- if (!s) return "";
1146
- let t = String(s).split("?")[0].split("#")[0].trim();
1147
- t = t.replace(/^\\/+/, "").replace(/\\/+$/, "");
1148
- t = t.replace(/\\.(?:mjs|cjs|js)$/, "");
1149
- if (t.length >= 6 && t.substring(t.length - 6) === "/index") {
1150
- t = t.substring(0, t.length - 6);
1151
- }
1152
- if (!t || t === "index") return "";
1153
- return t;
1154
- }
1155
-
1156
- // Invariant D: shape ESM namespaces before returning to CJS callers.
1157
- //
1158
- // The /ns/core handler's registration footer (see websocket.ts) and the
1159
- // main-entry require shim (see helpers/main-entry.ts) both install the
1160
- // shape function on globalThis. In practice, entries stored in
1161
- // __NS_CORE_MODULES__ are ALREADY shaped, so this pass-through is a
1162
- // fast no-op (the shape function's fast path returns obj as-is when it
1163
- // already has Object.prototype). We call it anyway as defense-in-depth
1164
- // against future callers that might populate the registry without
1165
- // shaping.
1166
- function shapeForCjs(value) {
1167
- if (!value || typeof value !== "object") return value;
1168
- const shape = g.__NS_CJS_SHAPE__;
1169
- if (typeof shape === "function") {
1170
- try { return shape(value); } catch (e) {}
1171
- }
1172
- return value;
1173
- }
1174
-
1175
- function resolveCoreFromRegistry(normalizedId) {
1176
- if (
1177
- normalizedId !== "@nativescript/core" &&
1178
- normalizedId.indexOf("@nativescript/core/") !== 0
1179
- ) {
1180
- return null;
1181
- }
1182
- const table = g.__NS_CORE_MODULES__;
1183
- if (!table) return null;
1184
- if (table[normalizedId]) return shapeForCjs(table[normalizedId]);
1185
- const rawSub =
1186
- normalizedId === "@nativescript/core"
1187
- ? ""
1188
- : normalizedId.slice("@nativescript/core/".length);
1189
- const normSub = normalizeCoreSubLocal(rawSub);
1190
- const bareKey = normSub ? "@nativescript/core/" + normSub : "@nativescript/core";
1191
- if (table[bareKey]) return shapeForCjs(table[bareKey]);
1192
- if (normSub && table[normSub]) return shapeForCjs(table[normSub]);
1193
- if (!normSub && table[""]) return shapeForCjs(table[""]);
1194
- return null;
1195
- }
1196
-
1197
- export function createRequire(_url) {
1198
- const nsRequire = getNativeScriptRequire();
1199
- if (!nsRequire) {
1200
- return function (id) {
1201
- // Even without nsRequire, the @nativescript/core registry populated by
1202
- // the /ns/core bridge may already have the module — return it so
1203
- // vendor install() hooks that run against the HMR-served core don't
1204
- // crash at module-instantiation time.
1205
- const fromRegistry = resolveCoreFromRegistry(normalizeSpecifier(id));
1206
- if (fromRegistry) return fromRegistry;
1207
- throw new Error("NativeScript require() is not available in this context");
1208
- };
1209
- }
1210
- const req = function (id) {
1211
- const normalizedId = normalizeSpecifier(id);
1212
- // Invariant C: @nativescript/core and its subpaths are served ONCE via
1213
- // the /ns/core HTTP bridge, which self-registers each module's ESM
1214
- // namespace on globalThis.__NS_CORE_MODULES__. CommonJS require() from
1215
- // vendor packages (e.g. \`require('@nativescript/core/ui/core/view').View\`
1216
- // in @nativescript-community/gesturehandler, or \`require('@nativescript/core').View\`
1217
- // in @nativescript-community/ui-material-core) MUST resolve to that
1218
- // same namespace; otherwise we re-trigger class identity splits and
1219
- // applyMixins() crashes with "Cannot read properties of undefined".
1220
- const fromRegistry = resolveCoreFromRegistry(normalizedId);
1221
- if (fromRegistry) return fromRegistry;
1222
- if (
1223
- normalizedId.includes("../data/patch.json") ||
1224
- normalizedId.includes("css-tree/lib/data/patch.json")
1225
- ) {
1226
- return {
1227
- atrules: {},
1228
- properties: {},
1229
- types: {},
1230
- };
1231
- }
1232
- if (normalizedId.includes("mdn-data/")) {
1233
- return {};
1234
- }
1235
- if (
1236
- normalizedId.endsWith("/package.json") ||
1237
- normalizedId.includes("../package.json")
1238
- ) {
1239
- return { version: "0.0.0" };
1240
- }
1241
- if (normalizedId.endsWith(".json")) {
1242
- return {};
1243
- }
1244
- // Shape the native require result too. The NativeScript CJS loader
1245
- // may serve an @nativescript/core subpath over HTTP before the
1246
- // /ns/core footer has run (e.g., during initial boot). In that
1247
- // window, the result is a raw ESM namespace with null [[Prototype]]
1248
- // and zone.js/vendor install() hooks crash on hasOwnProperty.
1249
- return shapeForCjs(nsRequire(normalizedId));
1250
- };
1251
- req.resolve = nsRequire.resolve
1252
- ? function (id) {
1253
- return nsRequire.resolve(id);
1254
- }
1255
- : function (id) {
1256
- return id;
1257
- };
1258
- return req;
1259
- }
1260
-
1261
- export default { createRequire };
1262
- `;
1263
528
  function stripIndexSuffix(specifier) {
1264
529
  return specifier.replace(/\/(?:(?:index)(?:\.[^.\/]+)?)$/, '');
1265
530
  }