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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (410) hide show
  1. package/README.md +51 -11
  2. package/bin/cli.cjs +8 -14
  3. package/configuration/angular.d.ts +34 -1
  4. package/configuration/angular.js +376 -165
  5. package/configuration/angular.js.map +1 -1
  6. package/configuration/base.js +256 -30
  7. package/configuration/base.js.map +1 -1
  8. package/configuration/javascript.js +12 -90
  9. package/configuration/javascript.js.map +1 -1
  10. package/configuration/solid.js +33 -4
  11. package/configuration/solid.js.map +1 -1
  12. package/configuration/typescript.js +10 -90
  13. package/configuration/typescript.js.map +1 -1
  14. package/helpers/app-components.d.ts +2 -1
  15. package/helpers/app-components.js.map +1 -1
  16. package/helpers/app-css-state.d.ts +8 -0
  17. package/helpers/app-css-state.js +8 -0
  18. package/helpers/app-css-state.js.map +1 -0
  19. package/helpers/bundler-context.d.ts +11 -0
  20. package/helpers/bundler-context.js +71 -0
  21. package/helpers/bundler-context.js.map +1 -0
  22. package/helpers/config-as-json.js +10 -0
  23. package/helpers/config-as-json.js.map +1 -1
  24. package/helpers/css-platform-plugin.d.ts +14 -0
  25. package/helpers/css-platform-plugin.js +43 -25
  26. package/helpers/css-platform-plugin.js.map +1 -1
  27. package/helpers/dev-host.d.ts +360 -0
  28. package/helpers/dev-host.js +692 -0
  29. package/helpers/dev-host.js.map +1 -0
  30. package/helpers/dynamic-import-plugin.js +1 -1
  31. package/helpers/dynamic-import-plugin.js.map +1 -1
  32. package/helpers/esbuild-platform-resolver.js +4 -1
  33. package/helpers/esbuild-platform-resolver.js.map +1 -1
  34. package/helpers/external-configs.d.ts +10 -12
  35. package/helpers/external-configs.js +54 -35
  36. package/helpers/external-configs.js.map +1 -1
  37. package/helpers/global-defines.d.ts +128 -0
  38. package/helpers/global-defines.js +174 -11
  39. package/helpers/global-defines.js.map +1 -1
  40. package/helpers/hmr-scope.d.ts +26 -0
  41. package/helpers/hmr-scope.js +67 -0
  42. package/helpers/hmr-scope.js.map +1 -0
  43. package/helpers/init.js +0 -18
  44. package/helpers/init.js.map +1 -1
  45. package/helpers/logging.d.ts +1 -0
  46. package/helpers/logging.js +65 -4
  47. package/helpers/logging.js.map +1 -1
  48. package/helpers/main-entry.d.ts +3 -1
  49. package/helpers/main-entry.js +444 -50
  50. package/helpers/main-entry.js.map +1 -1
  51. package/helpers/nativeclass-esbuild-plugin.d.ts +2 -1
  52. package/helpers/nativeclass-esbuild-plugin.js.map +1 -1
  53. package/helpers/nativeclass-transform.js +5 -6
  54. package/helpers/nativeclass-transform.js.map +1 -1
  55. package/helpers/nativeclass-transformer-plugin.d.ts +9 -2
  56. package/helpers/nativeclass-transformer-plugin.js +157 -14
  57. package/helpers/nativeclass-transformer-plugin.js.map +1 -1
  58. package/helpers/nativescript-package-resolver.js +10 -62
  59. package/helpers/nativescript-package-resolver.js.map +1 -1
  60. package/helpers/normalize-id.d.ts +42 -0
  61. package/helpers/normalize-id.js +60 -0
  62. package/helpers/normalize-id.js.map +1 -0
  63. package/helpers/ns-core-url.d.ts +106 -0
  64. package/helpers/ns-core-url.js +225 -0
  65. package/helpers/ns-core-url.js.map +1 -0
  66. package/helpers/optimize-deps.d.ts +16 -0
  67. package/helpers/optimize-deps.js +17 -0
  68. package/helpers/optimize-deps.js.map +1 -0
  69. package/helpers/package-platform-aliases.js +34 -49
  70. package/helpers/package-platform-aliases.js.map +1 -1
  71. package/helpers/platform-types.d.ts +2 -0
  72. package/helpers/platform-types.js +2 -0
  73. package/helpers/platform-types.js.map +1 -0
  74. package/helpers/postcss-platform-config.d.ts +17 -1
  75. package/helpers/postcss-platform-config.js +20 -37
  76. package/helpers/postcss-platform-config.js.map +1 -1
  77. package/helpers/project.d.ts +35 -0
  78. package/helpers/project.js +120 -2
  79. package/helpers/project.js.map +1 -1
  80. package/helpers/resolve-main-field-platform.d.ts +20 -0
  81. package/helpers/resolve-main-field-platform.js +49 -0
  82. package/helpers/resolve-main-field-platform.js.map +1 -0
  83. package/helpers/resolver.js +17 -2
  84. package/helpers/resolver.js.map +1 -1
  85. package/helpers/theme-core-plugins.js +1 -1
  86. package/helpers/theme-core-plugins.js.map +1 -1
  87. package/helpers/ts-config-paths.d.ts +14 -0
  88. package/helpers/ts-config-paths.js +90 -9
  89. package/helpers/ts-config-paths.js.map +1 -1
  90. package/helpers/typescript-check.d.ts +2 -1
  91. package/helpers/typescript-check.js.map +1 -1
  92. package/helpers/ui-registration.d.ts +21 -0
  93. package/helpers/ui-registration.js +156 -0
  94. package/helpers/ui-registration.js.map +1 -0
  95. package/helpers/utils.js +1 -2
  96. package/helpers/utils.js.map +1 -1
  97. package/helpers/workers.d.ts +20 -19
  98. package/helpers/workers.js +624 -4
  99. package/helpers/workers.js.map +1 -1
  100. package/hmr/client/css-handler.d.ts +2 -1
  101. package/hmr/client/css-handler.js +50 -26
  102. package/hmr/client/css-handler.js.map +1 -1
  103. package/hmr/client/css-update-overlay.d.ts +18 -0
  104. package/hmr/client/css-update-overlay.js +27 -0
  105. package/hmr/client/css-update-overlay.js.map +1 -0
  106. package/hmr/client/framework-client-strategy.d.ts +79 -0
  107. package/hmr/client/framework-client-strategy.js +19 -0
  108. package/hmr/client/framework-client-strategy.js.map +1 -0
  109. package/hmr/client/hmr-pending-overlay.d.ts +13 -0
  110. package/hmr/client/hmr-pending-overlay.js +60 -0
  111. package/hmr/client/hmr-pending-overlay.js.map +1 -0
  112. package/hmr/client/index.js +787 -211
  113. package/hmr/client/index.js.map +1 -1
  114. package/hmr/client/utils.d.ts +7 -1
  115. package/hmr/client/utils.js +207 -29
  116. package/hmr/client/utils.js.map +1 -1
  117. package/hmr/entry-runtime.d.ts +2 -1
  118. package/hmr/entry-runtime.js +256 -69
  119. package/hmr/entry-runtime.js.map +1 -1
  120. package/hmr/frameworks/angular/build/angular-linker.d.ts +12 -0
  121. package/hmr/frameworks/angular/build/angular-linker.js +109 -0
  122. package/hmr/frameworks/angular/build/angular-linker.js.map +1 -0
  123. package/hmr/frameworks/angular/build/inject-component-hmr-registration.d.ts +112 -0
  124. package/hmr/frameworks/angular/build/inject-component-hmr-registration.js +291 -0
  125. package/hmr/frameworks/angular/build/inject-component-hmr-registration.js.map +1 -0
  126. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.d.ts +75 -0
  127. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js +221 -0
  128. package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js.map +1 -0
  129. package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.js +1 -170
  130. package/hmr/frameworks/angular/build/inline-decorator-component-templates.js.map +1 -0
  131. package/hmr/frameworks/angular/build/js-lexer.d.ts +4 -0
  132. package/{helpers/angular/synthesize-decorator-ctor-parameters.js → hmr/frameworks/angular/build/js-lexer.js} +22 -96
  133. package/hmr/frameworks/angular/build/js-lexer.js.map +1 -0
  134. package/hmr/frameworks/angular/build/shared-linker.d.ts +39 -0
  135. package/hmr/frameworks/angular/build/shared-linker.js +128 -0
  136. package/hmr/frameworks/angular/build/shared-linker.js.map +1 -0
  137. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js +88 -0
  138. package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js.map +1 -0
  139. package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.js +1 -174
  140. package/hmr/frameworks/angular/build/synthesize-injectable-factories.js.map +1 -0
  141. package/{helpers/angular → hmr/frameworks/angular/build}/util.d.ts +1 -0
  142. package/hmr/frameworks/angular/build/util.js +155 -0
  143. package/hmr/frameworks/angular/build/util.js.map +1 -0
  144. package/hmr/frameworks/angular/client/index.d.ts +1 -0
  145. package/hmr/frameworks/angular/client/index.js +803 -21
  146. package/hmr/frameworks/angular/client/index.js.map +1 -1
  147. package/hmr/frameworks/angular/client/strategy.d.ts +9 -0
  148. package/hmr/frameworks/angular/client/strategy.js +19 -0
  149. package/hmr/frameworks/angular/client/strategy.js.map +1 -0
  150. package/hmr/frameworks/angular/server/angular-root-component.d.ts +79 -0
  151. package/hmr/frameworks/angular/server/angular-root-component.js +149 -0
  152. package/hmr/frameworks/angular/server/angular-root-component.js.map +1 -0
  153. package/hmr/frameworks/angular/server/linker.js +1 -4
  154. package/hmr/frameworks/angular/server/linker.js.map +1 -1
  155. package/hmr/frameworks/angular/server/strategy.js +460 -12
  156. package/hmr/frameworks/angular/server/strategy.js.map +1 -1
  157. package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.js +2 -2
  158. package/hmr/frameworks/angular/server/websocket-angular-entry.js.map +1 -0
  159. package/hmr/{server → frameworks/angular/server}/websocket-angular-hot-update.d.ts +17 -11
  160. package/hmr/frameworks/angular/server/websocket-angular-hot-update.js +336 -0
  161. package/hmr/frameworks/angular/server/websocket-angular-hot-update.js.map +1 -0
  162. package/hmr/frameworks/solid/build/solid-jsx-deps.d.ts +15 -0
  163. package/hmr/frameworks/solid/build/solid-jsx-deps.js +178 -0
  164. package/hmr/frameworks/solid/build/solid-jsx-deps.js.map +1 -0
  165. package/hmr/frameworks/solid/server/strategy.js +291 -16
  166. package/hmr/frameworks/solid/server/strategy.js.map +1 -1
  167. package/hmr/frameworks/typescript/server/strategy.js +38 -14
  168. package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
  169. package/hmr/frameworks/vue/client/dep-propagation.d.ts +36 -0
  170. package/hmr/frameworks/vue/client/dep-propagation.js +101 -0
  171. package/hmr/frameworks/vue/client/dep-propagation.js.map +1 -0
  172. package/hmr/frameworks/vue/client/index.d.ts +8 -0
  173. package/hmr/frameworks/vue/client/index.js +56 -243
  174. package/hmr/frameworks/vue/client/index.js.map +1 -1
  175. package/hmr/frameworks/vue/client/strategy.d.ts +33 -0
  176. package/hmr/frameworks/vue/client/strategy.js +157 -0
  177. package/hmr/frameworks/vue/client/strategy.js.map +1 -0
  178. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.d.ts +49 -0
  179. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js +142 -0
  180. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js.map +1 -0
  181. package/hmr/frameworks/vue/server/sfc-route-assemble.d.ts +7 -0
  182. package/hmr/frameworks/vue/server/sfc-route-assemble.js +747 -0
  183. package/hmr/frameworks/vue/server/sfc-route-assemble.js.map +1 -0
  184. package/hmr/frameworks/vue/server/sfc-route-meta.d.ts +7 -0
  185. package/hmr/frameworks/vue/server/sfc-route-meta.js +80 -0
  186. package/hmr/frameworks/vue/server/sfc-route-meta.js.map +1 -0
  187. package/hmr/frameworks/vue/server/sfc-route-serve.d.ts +8 -0
  188. package/hmr/frameworks/vue/server/sfc-route-serve.js +459 -0
  189. package/hmr/frameworks/vue/server/sfc-route-serve.js.map +1 -0
  190. package/hmr/frameworks/vue/server/sfc-route-shared.d.ts +38 -0
  191. package/hmr/frameworks/vue/server/sfc-route-shared.js +48 -0
  192. package/hmr/frameworks/vue/server/sfc-route-shared.js.map +1 -0
  193. package/hmr/frameworks/vue/server/strategy.d.ts +35 -0
  194. package/hmr/frameworks/vue/server/strategy.js +278 -1
  195. package/hmr/frameworks/vue/server/strategy.js.map +1 -1
  196. package/hmr/frameworks/vue/server/websocket-sfc.d.ts +15 -0
  197. package/hmr/frameworks/vue/server/websocket-sfc.js +20 -0
  198. package/hmr/frameworks/vue/server/websocket-sfc.js.map +1 -0
  199. package/hmr/helpers/ast-normalizer.d.ts +3 -1
  200. package/hmr/helpers/ast-normalizer.js +77 -10
  201. package/hmr/helpers/ast-normalizer.js.map +1 -1
  202. package/hmr/helpers/cjs-named-exports.d.ts +23 -0
  203. package/hmr/helpers/cjs-named-exports.js +152 -0
  204. package/hmr/helpers/cjs-named-exports.js.map +1 -0
  205. package/hmr/helpers/package-exports.d.ts +16 -0
  206. package/hmr/helpers/package-exports.js +396 -0
  207. package/hmr/helpers/package-exports.js.map +1 -0
  208. package/hmr/server/constants.js +20 -5
  209. package/hmr/server/constants.js.map +1 -1
  210. package/hmr/server/core-sanitize.d.ts +90 -7
  211. package/hmr/server/core-sanitize.js +211 -56
  212. package/hmr/server/core-sanitize.js.map +1 -1
  213. package/hmr/server/device-transform-helpers.d.ts +24 -0
  214. package/hmr/server/device-transform-helpers.js +369 -0
  215. package/hmr/server/device-transform-helpers.js.map +1 -0
  216. package/hmr/server/framework-strategy.d.ts +108 -11
  217. package/hmr/server/hmr-module-graph.d.ts +37 -0
  218. package/hmr/server/hmr-module-graph.js +214 -0
  219. package/hmr/server/hmr-module-graph.js.map +1 -0
  220. package/hmr/server/import-map.d.ts +11 -2
  221. package/hmr/server/import-map.js +95 -44
  222. package/hmr/server/import-map.js.map +1 -1
  223. package/hmr/server/index.js +7 -16
  224. package/hmr/server/index.js.map +1 -1
  225. package/hmr/server/ns-core-cjs-shape.d.ts +204 -0
  226. package/hmr/server/ns-core-cjs-shape.js +271 -0
  227. package/hmr/server/ns-core-cjs-shape.js.map +1 -0
  228. package/hmr/server/ns-rt-bridge.d.ts +51 -0
  229. package/hmr/server/ns-rt-bridge.js +131 -0
  230. package/hmr/server/ns-rt-bridge.js.map +1 -0
  231. package/hmr/server/ns-rt-route.d.ts +5 -0
  232. package/hmr/server/ns-rt-route.js +38 -0
  233. package/hmr/server/ns-rt-route.js.map +1 -0
  234. package/hmr/server/perf-instrumentation.d.ts +114 -0
  235. package/hmr/server/perf-instrumentation.js +197 -0
  236. package/hmr/server/perf-instrumentation.js.map +1 -0
  237. package/hmr/server/process-code-for-device.d.ts +14 -0
  238. package/hmr/server/process-code-for-device.js +702 -0
  239. package/hmr/server/process-code-for-device.js.map +1 -0
  240. package/hmr/server/require-guard.d.ts +1 -0
  241. package/hmr/server/require-guard.js +12 -0
  242. package/hmr/server/require-guard.js.map +1 -0
  243. package/hmr/server/rewrite-imports.d.ts +2 -0
  244. package/hmr/server/rewrite-imports.js +600 -0
  245. package/hmr/server/rewrite-imports.js.map +1 -0
  246. package/hmr/server/route-helpers.d.ts +7 -0
  247. package/hmr/server/route-helpers.js +13 -0
  248. package/hmr/server/route-helpers.js.map +1 -0
  249. package/hmr/server/server-origin.d.ts +2 -0
  250. package/hmr/server/server-origin.js +83 -0
  251. package/hmr/server/server-origin.js.map +1 -0
  252. package/hmr/server/shared-transform-request.js +13 -7
  253. package/hmr/server/shared-transform-request.js.map +1 -1
  254. package/hmr/server/transform-cache-invalidation.d.ts +37 -0
  255. package/hmr/server/transform-cache-invalidation.js +156 -0
  256. package/hmr/server/transform-cache-invalidation.js.map +1 -0
  257. package/hmr/server/vendor-bare-module-shims.d.ts +4 -0
  258. package/hmr/server/vendor-bare-module-shims.js +80 -0
  259. package/hmr/server/vendor-bare-module-shims.js.map +1 -0
  260. package/hmr/server/vite-plugin.js +72 -42
  261. package/hmr/server/vite-plugin.js.map +1 -1
  262. package/hmr/server/websocket-core-bridge.d.ts +45 -6
  263. package/hmr/server/websocket-core-bridge.js +81 -77
  264. package/hmr/server/websocket-core-bridge.js.map +1 -1
  265. package/hmr/server/websocket-css-hot-update.d.ts +33 -0
  266. package/hmr/server/websocket-css-hot-update.js +65 -0
  267. package/hmr/server/websocket-css-hot-update.js.map +1 -0
  268. package/hmr/server/websocket-device-transform.d.ts +3 -0
  269. package/hmr/server/websocket-device-transform.js +7 -0
  270. package/hmr/server/websocket-device-transform.js.map +1 -0
  271. package/hmr/server/websocket-graph-upsert.d.ts +15 -0
  272. package/hmr/server/websocket-graph-upsert.js +20 -0
  273. package/hmr/server/websocket-graph-upsert.js.map +1 -1
  274. package/hmr/server/websocket-hmr-pending.d.ts +37 -0
  275. package/hmr/server/websocket-hmr-pending.js +55 -0
  276. package/hmr/server/websocket-hmr-pending.js.map +1 -0
  277. package/hmr/server/websocket-hot-update.d.ts +77 -0
  278. package/hmr/server/websocket-hot-update.js +360 -0
  279. package/hmr/server/websocket-hot-update.js.map +1 -0
  280. package/hmr/server/websocket-import-map-route.d.ts +15 -0
  281. package/hmr/server/websocket-import-map-route.js +50 -0
  282. package/hmr/server/websocket-import-map-route.js.map +1 -0
  283. package/hmr/server/websocket-module-bindings.js +3 -3
  284. package/hmr/server/websocket-module-bindings.js.map +1 -1
  285. package/hmr/server/websocket-module-specifiers.d.ts +66 -2
  286. package/hmr/server/websocket-module-specifiers.js +203 -20
  287. package/hmr/server/websocket-module-specifiers.js.map +1 -1
  288. package/hmr/server/websocket-ns-core.d.ts +21 -0
  289. package/hmr/server/websocket-ns-core.js +311 -0
  290. package/hmr/server/websocket-ns-core.js.map +1 -0
  291. package/hmr/server/websocket-ns-entry.d.ts +21 -0
  292. package/hmr/server/websocket-ns-entry.js +164 -0
  293. package/hmr/server/websocket-ns-entry.js.map +1 -0
  294. package/hmr/server/websocket-ns-m-paths.d.ts +1 -1
  295. package/hmr/server/websocket-ns-m-paths.js +58 -13
  296. package/hmr/server/websocket-ns-m-paths.js.map +1 -1
  297. package/hmr/server/websocket-ns-m-request.d.ts +11 -1
  298. package/hmr/server/websocket-ns-m-request.js +18 -25
  299. package/hmr/server/websocket-ns-m-request.js.map +1 -1
  300. package/hmr/server/websocket-ns-m.d.ts +33 -0
  301. package/hmr/server/websocket-ns-m.js +752 -0
  302. package/hmr/server/websocket-ns-m.js.map +1 -0
  303. package/hmr/server/websocket-served-module-helpers.d.ts +82 -0
  304. package/hmr/server/websocket-served-module-helpers.js +879 -0
  305. package/hmr/server/websocket-served-module-helpers.js.map +1 -0
  306. package/hmr/server/websocket-txn.js +2 -8
  307. package/hmr/server/websocket-txn.js.map +1 -1
  308. package/hmr/server/websocket-vendor-unifier.d.ts +0 -1
  309. package/hmr/server/websocket-vendor-unifier.js +4 -9
  310. package/hmr/server/websocket-vendor-unifier.js.map +1 -1
  311. package/hmr/server/websocket.d.ts +8 -39
  312. package/hmr/server/websocket.js +514 -4030
  313. package/hmr/server/websocket.js.map +1 -1
  314. package/hmr/shared/ns-globals.d.ts +118 -0
  315. package/hmr/shared/ns-globals.js +29 -0
  316. package/hmr/shared/ns-globals.js.map +1 -0
  317. package/hmr/shared/protocol.d.ts +145 -0
  318. package/hmr/shared/protocol.js +28 -0
  319. package/hmr/shared/protocol.js.map +1 -0
  320. package/hmr/shared/runtime/boot-placeholder-ui.d.ts +69 -0
  321. package/hmr/shared/runtime/boot-placeholder-ui.js +101 -0
  322. package/hmr/shared/runtime/boot-placeholder-ui.js.map +1 -0
  323. package/hmr/shared/runtime/boot-progress.d.ts +44 -0
  324. package/hmr/shared/runtime/boot-progress.js +133 -0
  325. package/hmr/shared/runtime/boot-progress.js.map +1 -0
  326. package/hmr/shared/runtime/boot-timeline.d.ts +18 -0
  327. package/hmr/shared/runtime/boot-timeline.js +42 -0
  328. package/hmr/shared/runtime/boot-timeline.js.map +1 -0
  329. package/hmr/shared/runtime/browser-runtime-contract.js.map +1 -1
  330. package/hmr/shared/runtime/dev-overlay-snapshots.d.ts +31 -0
  331. package/hmr/shared/runtime/dev-overlay-snapshots.js +324 -0
  332. package/hmr/shared/runtime/dev-overlay-snapshots.js.map +1 -0
  333. package/hmr/shared/runtime/dev-overlay.d.ts +75 -26
  334. package/hmr/shared/runtime/dev-overlay.js +992 -261
  335. package/hmr/shared/runtime/dev-overlay.js.map +1 -1
  336. package/hmr/shared/runtime/global-scope.d.ts +18 -0
  337. package/hmr/shared/runtime/global-scope.js +21 -0
  338. package/hmr/shared/runtime/global-scope.js.map +1 -0
  339. package/hmr/shared/runtime/hooks.js +2 -1
  340. package/hmr/shared/runtime/hooks.js.map +1 -1
  341. package/hmr/shared/runtime/http-only-boot.js +7 -6
  342. package/hmr/shared/runtime/http-only-boot.js.map +1 -1
  343. package/hmr/shared/runtime/module-provenance.js +4 -6
  344. package/hmr/shared/runtime/module-provenance.js.map +1 -1
  345. package/hmr/shared/runtime/root-placeholder-view.d.ts +19 -0
  346. package/hmr/shared/runtime/root-placeholder-view.js +311 -0
  347. package/hmr/shared/runtime/root-placeholder-view.js.map +1 -0
  348. package/hmr/shared/runtime/root-placeholder.js +371 -197
  349. package/hmr/shared/runtime/root-placeholder.js.map +1 -1
  350. package/hmr/shared/runtime/session-bootstrap.js +168 -4
  351. package/hmr/shared/runtime/session-bootstrap.js.map +1 -1
  352. package/hmr/shared/runtime/vendor-bootstrap.js +3 -10
  353. package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
  354. package/hmr/shared/vendor/manifest-collect.d.ts +4 -0
  355. package/hmr/shared/vendor/manifest-collect.js +512 -0
  356. package/hmr/shared/vendor/manifest-collect.js.map +1 -0
  357. package/hmr/shared/vendor/manifest-loader.d.ts +2 -1
  358. package/hmr/shared/vendor/manifest-loader.js +5 -3
  359. package/hmr/shared/vendor/manifest-loader.js.map +1 -1
  360. package/hmr/shared/vendor/manifest.d.ts +1 -7
  361. package/hmr/shared/vendor/manifest.js +102 -741
  362. package/hmr/shared/vendor/manifest.js.map +1 -1
  363. package/hmr/shared/vendor/vendor-device-shim.d.ts +1 -0
  364. package/hmr/shared/vendor/vendor-device-shim.js +208 -0
  365. package/hmr/shared/vendor/vendor-device-shim.js.map +1 -0
  366. package/hmr/shared/vendor/vendor-esbuild-plugins.d.ts +16 -0
  367. package/hmr/shared/vendor/vendor-esbuild-plugins.js +203 -0
  368. package/hmr/shared/vendor/vendor-esbuild-plugins.js.map +1 -0
  369. package/hmr/vendor-bootstrap.d.ts +1 -3
  370. package/hmr/vendor-bootstrap.js +4 -6
  371. package/hmr/vendor-bootstrap.js.map +1 -1
  372. package/index.d.ts +1 -0
  373. package/index.js +5 -0
  374. package/index.js.map +1 -1
  375. package/package.json +55 -11
  376. package/runtime/core-aliases-early.js +25 -55
  377. package/runtime/core-aliases-early.js.map +1 -1
  378. package/helpers/angular/angular-linker.d.ts +0 -13
  379. package/helpers/angular/angular-linker.js +0 -194
  380. package/helpers/angular/angular-linker.js.map +0 -1
  381. package/helpers/angular/inline-decorator-component-templates.js.map +0 -1
  382. package/helpers/angular/shared-linker.d.ts +0 -11
  383. package/helpers/angular/shared-linker.js +0 -75
  384. package/helpers/angular/shared-linker.js.map +0 -1
  385. package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +0 -1
  386. package/helpers/angular/synthesize-injectable-factories.js.map +0 -1
  387. package/helpers/angular/util.js +0 -67
  388. package/helpers/angular/util.js.map +0 -1
  389. package/helpers/prelink-angular.d.ts +0 -2
  390. package/helpers/prelink-angular.js +0 -117
  391. package/helpers/prelink-angular.js.map +0 -1
  392. package/hmr/server/websocket-angular-entry.js.map +0 -1
  393. package/hmr/server/websocket-angular-hot-update.js +0 -239
  394. package/hmr/server/websocket-angular-hot-update.js.map +0 -1
  395. package/hmr/server/websocket-ns-m-finalize.d.ts +0 -32
  396. package/hmr/server/websocket-ns-m-finalize.js +0 -73
  397. package/hmr/server/websocket-ns-m-finalize.js.map +0 -1
  398. package/hmr/server/websocket-runtime-compat.d.ts +0 -19
  399. package/hmr/server/websocket-runtime-compat.js +0 -286
  400. package/hmr/server/websocket-runtime-compat.js.map +0 -1
  401. package/hmr/server/websocket-vue-sfc.d.ts +0 -35
  402. package/hmr/server/websocket-vue-sfc.js +0 -1116
  403. package/hmr/server/websocket-vue-sfc.js.map +0 -1
  404. package/transformers/NativeClass/index.d.ts +0 -2
  405. package/transformers/NativeClass/index.js +0 -222
  406. package/transformers/NativeClass/index.js.map +0 -1
  407. /package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.d.ts +0 -0
  408. /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-decorator-ctor-parameters.d.ts +0 -0
  409. /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.d.ts +0 -0
  410. /package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.d.ts +0 -0
@@ -1,18 +1,42 @@
1
- const BOOT_TITLE = 'NativeScript Vite preparing dev session...';
2
- const DEFAULT_SNAPSHOT = {
3
- visible: false,
4
- mode: 'hidden',
5
- badge: 'HMR',
6
- title: BOOT_TITLE,
7
- phase: '',
8
- detail: '',
9
- progress: null,
10
- busy: false,
11
- blocking: false,
12
- tone: 'info',
13
- };
1
+ import { BOOT_PLACEHOLDER_MOTION, computeBootProgressFillScale, formatBootDetailLine, formatBootPrimaryLine } from './boot-placeholder-ui.js';
2
+ import { BOOT_TITLE, DEFAULT_SNAPSHOT, createBootOverlaySnapshot, createConnectionOverlaySnapshot, createUpdateOverlaySnapshot } from './dev-overlay-snapshots.js';
3
+ import { getGlobalScope } from './global-scope.js';
4
+ // Re-export the snapshot model so existing `./dev-overlay.js` importers keep working.
5
+ export { createBootOverlaySnapshot, createConnectionOverlaySnapshot, createUpdateOverlaySnapshot } from './dev-overlay-snapshots.js';
6
+ const DEFAULT_OVERLAY_POSITION = 'top';
14
7
  function getOverlayGlobal() {
15
- return globalThis;
8
+ return getGlobalScope();
9
+ }
10
+ /**
11
+ * Resolve the configured live-overlay position.
12
+ *
13
+ * Reads `globalThis.__NS_HMR_OVERLAY_POSITION__` so a project can
14
+ * override the default at boot time (e.g. inside `app.ts` before the
15
+ * Vite session bootstraps). Falls back to 'top' which gives the
16
+ * toast-style chip with a slide-in animation and safe-area padding.
17
+ */
18
+ export function getHmrDevOverlayPosition() {
19
+ const g = getOverlayGlobal();
20
+ const stored = g.__NS_HMR_OVERLAY_POSITION__;
21
+ if (stored === 'top' || stored === 'bottom' || stored === 'center') {
22
+ return stored;
23
+ }
24
+ return DEFAULT_OVERLAY_POSITION;
25
+ }
26
+ /**
27
+ * Imperative setter for the live-overlay position. Re-applies the
28
+ * current snapshot so the change is visible without waiting for the
29
+ * next HMR cycle. Useful during dev to A/B between top/bottom/center
30
+ * without restarting the app.
31
+ */
32
+ export function setHmrDevOverlayPosition(position) {
33
+ if (position !== 'top' && position !== 'bottom' && position !== 'center') {
34
+ return;
35
+ }
36
+ const g = getOverlayGlobal();
37
+ g.__NS_HMR_OVERLAY_POSITION__ = position;
38
+ const state = getRuntimeState();
39
+ applyRuntimeSnapshot(state.snapshot);
16
40
  }
17
41
  function getRuntimeState() {
18
42
  const g = getOverlayGlobal();
@@ -21,240 +45,25 @@ function getRuntimeState() {
21
45
  snapshot: { ...DEFAULT_SNAPSHOT },
22
46
  bootRefs: null,
23
47
  liveRefs: null,
48
+ iosRefs: null,
49
+ iosBuildFailed: false,
24
50
  verbose: false,
51
+ updateAutoHideTimer: null,
52
+ updateCycleStartedAt: 0,
25
53
  };
26
54
  }
27
- return g.__NS_HMR_DEV_OVERLAY_STATE__;
28
- }
29
- function describeAttempt(info) {
30
- const attempt = Number(info?.attempt || 0);
31
- const attempts = Number(info?.attempts || 0);
32
- if (!attempt || !attempts) {
33
- return '';
34
- }
35
- return `Attempt ${attempt}/${attempts}`;
36
- }
37
- export function createBootOverlaySnapshot(stage, info) {
38
- const attemptText = describeAttempt(info);
39
- const phaseInfo = {
40
- placeholder: {
41
- visible: true,
42
- mode: 'boot',
43
- badge: 'BOOT',
44
- title: BOOT_TITLE,
45
- phase: 'Preparing the HTTP HMR bootstrap',
46
- progress: 4,
47
- busy: true,
48
- blocking: true,
49
- tone: 'info',
50
- },
51
- 'probing-origin': {
52
- visible: true,
53
- mode: 'boot',
54
- badge: 'BOOT',
55
- title: BOOT_TITLE,
56
- phase: 'Contacting the Vite dev server',
57
- progress: 8,
58
- busy: true,
59
- blocking: true,
60
- tone: 'info',
61
- },
62
- 'loading-entry-runtime': {
63
- visible: true,
64
- mode: 'boot',
65
- badge: 'BOOT',
66
- title: BOOT_TITLE,
67
- phase: 'Loading the entry runtime bridge',
68
- progress: 16,
69
- busy: true,
70
- blocking: true,
71
- tone: 'info',
72
- },
73
- 'configuring-import-map': {
74
- visible: true,
75
- mode: 'boot',
76
- badge: 'BOOT',
77
- title: BOOT_TITLE,
78
- phase: 'Configuring the import map',
79
- progress: 26,
80
- busy: true,
81
- blocking: true,
82
- tone: 'info',
83
- },
84
- 'loading-runtime-bridge': {
85
- visible: true,
86
- mode: 'boot',
87
- badge: 'BOOT',
88
- title: BOOT_TITLE,
89
- phase: 'Loading the NativeScript runtime bridge',
90
- progress: 40,
91
- busy: true,
92
- blocking: true,
93
- tone: 'info',
94
- },
95
- 'loading-core-bridge': {
96
- visible: true,
97
- mode: 'boot',
98
- badge: 'BOOT',
99
- title: BOOT_TITLE,
100
- phase: 'Loading the unified core bridge',
101
- progress: 54,
102
- busy: true,
103
- blocking: true,
104
- tone: 'info',
105
- },
106
- 'preloading-style-scope': {
107
- visible: true,
108
- mode: 'boot',
109
- badge: 'BOOT',
110
- title: BOOT_TITLE,
111
- phase: 'Preparing the shared style scope',
112
- progress: 62,
113
- busy: true,
114
- blocking: true,
115
- tone: 'info',
116
- },
117
- 'installing-css': {
118
- visible: true,
119
- mode: 'boot',
120
- badge: 'BOOT',
121
- title: BOOT_TITLE,
122
- phase: 'Applying the app stylesheet',
123
- progress: 70,
124
- busy: true,
125
- blocking: true,
126
- tone: 'info',
127
- },
128
- 'importing-main': {
129
- visible: true,
130
- mode: 'boot',
131
- badge: 'BOOT',
132
- title: BOOT_TITLE,
133
- phase: 'Importing the app entry',
134
- progress: 82,
135
- busy: true,
136
- blocking: true,
137
- tone: 'info',
138
- },
139
- 'waiting-for-app': {
140
- visible: true,
141
- mode: 'boot',
142
- badge: 'BOOT',
143
- title: BOOT_TITLE,
144
- phase: 'Waiting for the app root view',
145
- progress: 94,
146
- busy: true,
147
- blocking: true,
148
- tone: 'info',
149
- },
150
- 'app-root-committed': {
151
- visible: true,
152
- mode: 'boot',
153
- badge: 'READY',
154
- title: BOOT_TITLE,
155
- phase: 'Real app root committed',
156
- progress: 100,
157
- busy: false,
158
- blocking: true,
159
- tone: 'info',
160
- },
161
- ready: {
162
- visible: true,
163
- mode: 'boot',
164
- badge: 'READY',
165
- title: BOOT_TITLE,
166
- phase: 'Boot complete',
167
- progress: 100,
168
- busy: false,
169
- blocking: true,
170
- tone: 'info',
171
- },
172
- error: {
173
- visible: true,
174
- mode: 'boot',
175
- badge: 'RETRY',
176
- title: BOOT_TITLE,
177
- phase: 'Retrying after a boot failure',
178
- progress: null,
179
- busy: true,
180
- blocking: true,
181
- tone: 'error',
182
- },
183
- };
184
- const base = phaseInfo[stage];
185
- let detail = info?.detail || '';
186
- if (!detail && stage === 'probing-origin' && info?.origin) {
187
- detail = `Trying ${info.origin}`;
188
- }
189
- if (attemptText) {
190
- detail = detail ? `${detail} ${attemptText}` : attemptText;
191
- }
192
- return {
193
- ...base,
194
- detail,
195
- progress: typeof info?.progress === 'number' || info?.progress === null ? info.progress : base.progress,
196
- };
197
- }
198
- export function createConnectionOverlaySnapshot(stage, info) {
199
- if (stage === 'healthy') {
200
- return { ...DEFAULT_SNAPSHOT };
201
- }
202
- const phaseInfo = {
203
- connecting: {
204
- visible: true,
205
- mode: 'connection',
206
- badge: 'SOCKET',
207
- title: 'Waiting for Vite dev server',
208
- phase: 'Opening websocket connection',
209
- detail: 'Live updates are paused until the connection is healthy.',
210
- progress: null,
211
- busy: true,
212
- blocking: false,
213
- tone: 'warn',
214
- },
215
- reconnecting: {
216
- visible: true,
217
- mode: 'connection',
218
- badge: 'SOCKET',
219
- title: 'HMR connection lost',
220
- phase: 'Reconnecting Vite websocket',
221
- detail: 'The app may be stale until the dev server reconnects.',
222
- progress: null,
223
- busy: true,
224
- blocking: false,
225
- tone: 'warn',
226
- },
227
- synchronizing: {
228
- visible: true,
229
- mode: 'connection',
230
- badge: 'SYNC',
231
- title: 'HMR connection restored',
232
- phase: 'Synchronizing live-update state',
233
- detail: 'Finalizing the module graph before dismissing the overlay.',
234
- progress: 95,
235
- busy: true,
236
- blocking: false,
237
- tone: 'info',
238
- },
239
- offline: {
240
- visible: true,
241
- mode: 'connection',
242
- badge: 'OFFLINE',
243
- title: 'Vite dev server offline',
244
- phase: 'Idle...',
245
- detail: 'The websocket and HTTP HMR path are both unavailable right now.',
246
- progress: null,
247
- busy: true,
248
- blocking: false,
249
- tone: 'error',
250
- },
251
- };
252
- const base = phaseInfo[stage];
253
- return {
254
- ...base,
255
- detail: info?.detail || base.detail,
256
- progress: typeof info?.progress === 'number' || info?.progress === null ? info.progress : base.progress,
257
- };
55
+ const state = g.__NS_HMR_DEV_OVERLAY_STATE__;
56
+ // Backfill newer fields for legacy state objects (e.g. after hot reload)
57
+ // so we never observe an undefined iosRefs/iosBuildFailed at runtime.
58
+ if (typeof state.iosRefs === 'undefined')
59
+ state.iosRefs = null;
60
+ if (typeof state.iosBuildFailed === 'undefined')
61
+ state.iosBuildFailed = false;
62
+ if (typeof state.updateAutoHideTimer === 'undefined')
63
+ state.updateAutoHideTimer = null;
64
+ if (typeof state.updateCycleStartedAt !== 'number')
65
+ state.updateCycleStartedAt = 0;
66
+ return state;
258
67
  }
259
68
  function resolveCoreExport(name) {
260
69
  const g = getOverlayGlobal();
@@ -435,10 +244,28 @@ function findBootStatusLabel() {
435
244
  catch { }
436
245
  return null;
437
246
  }
247
+ function findBootDetailLabel() {
248
+ const g = getOverlayGlobal();
249
+ return g.__NS_DEV_BOOT_DETAIL_LABEL__ || null;
250
+ }
251
+ function findBootProgressFill() {
252
+ const g = getOverlayGlobal();
253
+ return g.__NS_DEV_BOOT_PROGRESS_FILL__ || null;
254
+ }
438
255
  function updateBootStatusLabel(snapshot) {
439
- const newText = formatStatusText(snapshot) || 'Preparing the HTTP HMR bootstrap (4%)';
440
256
  const statusLabel = findBootStatusLabel();
257
+ const detailLabel = findBootDetailLabel();
258
+ const progressFill = findBootProgressFill();
441
259
  const activityIndicator = findBootActivityIndicator();
260
+ // New (card) layout: phase line + detail line live in separate
261
+ // labels so the typography can differ. Legacy (single-label)
262
+ // layout: keep the original combined "phase (X%)\ndetail" text so
263
+ // nothing visually regresses for runtimes still attached to the
264
+ // older placeholder shape.
265
+ const hasSplitLabels = !!detailLabel;
266
+ const phaseLine = formatBootPrimaryLine(snapshot);
267
+ const detailLine = formatBootDetailLine(snapshot);
268
+ const combinedText = formatStatusText(snapshot) || 'Preparing the HTTP HMR bootstrap (4%)';
442
269
  if (!statusLabel) {
443
270
  if (activityIndicator) {
444
271
  try {
@@ -447,11 +274,16 @@ function updateBootStatusLabel(snapshot) {
447
274
  }
448
275
  catch { }
449
276
  }
277
+ applyBootProgressFill(progressFill, snapshot);
450
278
  return;
451
279
  }
452
280
  try {
453
- statusLabel.text = newText;
454
- statusLabel.color = asColor(snapshot.tone === 'error' ? '#b41810e6' : '#563e3fb1');
281
+ statusLabel.text = hasSplitLabels ? phaseLine || 'Preparing the HTTP HMR bootstrap' : combinedText;
282
+ // Card layout uses the calibrated phase-text colour from the
283
+ // palette; legacy single-label layout keeps the original muted
284
+ // brown so we don't visually regress mid-session.
285
+ const phaseColorHex = snapshot.tone === 'error' ? '#B91C1C' : hasSplitLabels ? '#475569' : '#563e3fb1';
286
+ statusLabel.color = asColor(phaseColorHex);
455
287
  if (typeof statusLabel.requestLayout === 'function') {
456
288
  statusLabel.requestLayout();
457
289
  }
@@ -461,6 +293,15 @@ function updateBootStatusLabel(snapshot) {
461
293
  }
462
294
  }
463
295
  catch { }
296
+ if (detailLabel) {
297
+ try {
298
+ detailLabel.text = detailLine;
299
+ detailLabel.color = asColor(snapshot.tone === 'error' ? '#DC2626' : '#94A3B8');
300
+ detailLabel.visibility = detailLine ? 'visible' : 'collapse';
301
+ }
302
+ catch { }
303
+ }
304
+ applyBootProgressFill(progressFill, snapshot);
464
305
  if (activityIndicator) {
465
306
  try {
466
307
  activityIndicator.busy = !!snapshot.busy;
@@ -469,6 +310,50 @@ function updateBootStatusLabel(snapshot) {
469
310
  catch { }
470
311
  }
471
312
  }
313
+ // Drive the progress fill scaleX from the snapshot. Uses NS's view
314
+ // animate API for a smooth 220 ms easeOut between heartbeat ticks; a
315
+ // monotonic ratchet on `globalThis.__NS_DEV_BOOT_PROGRESS_LAST_SCALE__`
316
+ // guards against the fill snapping backwards if a less-progressed
317
+ // snapshot ever lands between ticks (mirrors the JS-side
318
+ // `applyMonotonicBootProgress` contract).
319
+ function applyBootProgressFill(progressFill, snapshot) {
320
+ if (!progressFill)
321
+ return;
322
+ const g = getOverlayGlobal();
323
+ const isError = snapshot.tone === 'error';
324
+ progressFill.backgroundColor = asColor(isError ? '#B41810' : '#3B6FE5');
325
+ const targetScale = computeBootProgressFillScale(snapshot.progress ?? null);
326
+ const previousRaw = Number(g.__NS_DEV_BOOT_PROGRESS_LAST_SCALE__);
327
+ const previous = Number.isFinite(previousRaw) ? previousRaw : 0;
328
+ const next = Math.max(previous, targetScale);
329
+ g.__NS_DEV_BOOT_PROGRESS_LAST_SCALE__ = next;
330
+ try {
331
+ // NS view.animate scales around `originX`/`originY`; the
332
+ // placeholder builder pins `originX = 0` so the fill grows
333
+ // rightward. animate() may be unavailable in some headless
334
+ // test environments — fall through to a direct property set.
335
+ if (typeof progressFill.animate === 'function') {
336
+ progressFill
337
+ .animate({
338
+ scale: { x: next, y: 1 },
339
+ duration: BOOT_PLACEHOLDER_MOTION.progressDurationMs,
340
+ curve: 'easeOut',
341
+ })
342
+ .catch(() => {
343
+ try {
344
+ progressFill.scaleX = next;
345
+ }
346
+ catch { }
347
+ });
348
+ }
349
+ else {
350
+ progressFill.scaleX = next;
351
+ }
352
+ }
353
+ catch {
354
+ progressFill.scaleX = next;
355
+ }
356
+ }
472
357
  function resolveActivePage() {
473
358
  try {
474
359
  const Frame = resolveCoreExport('Frame');
@@ -505,8 +390,18 @@ function buildLiveOverlayView(snapshot) {
505
390
  overlay.height = '100%';
506
391
  overlay.horizontalAlignment = 'stretch';
507
392
  overlay.verticalAlignment = 'stretch';
393
+ // Toast mode lets touches reach the underlying app. We flip
394
+ // isUserInteractionEnabled in applySnapshotToLiveRefs based on
395
+ // the resolved position, but keep it false here as a safe default
396
+ // (the panel itself is purely informational).
397
+ try {
398
+ overlay.isUserInteractionEnabled = false;
399
+ }
400
+ catch { }
508
401
  const panel = new StackLayout();
509
402
  panel.horizontalAlignment = 'center';
403
+ // Vertical alignment is overridden in applySnapshotToLiveRefs
404
+ // based on getHmrDevOverlayPosition(); 'middle' is the default
510
405
  panel.verticalAlignment = 'middle';
511
406
  panel.width = 320;
512
407
  panel.margin = 24;
@@ -528,6 +423,8 @@ function buildLiveOverlayView(snapshot) {
528
423
  overlay,
529
424
  titleLabel,
530
425
  statusLabel,
426
+ wasVisible: false,
427
+ currentPosition: getHmrDevOverlayPosition(),
531
428
  };
532
429
  applySnapshotToLiveRefs(refs, snapshot);
533
430
  return refs;
@@ -584,27 +481,698 @@ function applySnapshotToLiveRefs(refs, snapshot) {
584
481
  if (!refs) {
585
482
  return;
586
483
  }
587
- const visible = snapshot.visible && snapshot.mode === 'connection';
588
- refs.overlay.visibility = visible ? 'visible' : 'collapse';
589
- refs.overlay.backgroundColor = asColor(snapshot.tone === 'error' ? '#b4181068' : '#a1771683');
484
+ // 'update' mode shares the live (in-tree) overlay chrome with
485
+ // 'connection'. Both render a small panel inside the page; only
486
+ // the colours, text, and (now) panel position change with the
487
+ // snapshot's tone and the configured overlay position.
488
+ const visible = snapshot.visible && (snapshot.mode === 'connection' || snapshot.mode === 'update');
489
+ const wasVisible = !!refs.wasVisible;
490
+ const position = getHmrDevOverlayPosition();
491
+ const previousPosition = refs.currentPosition || position;
492
+ const isToast = position !== 'center';
590
493
  refs.titleLabel.text = snapshot.title;
591
- refs.titleLabel.color = asColor(snapshot.tone === 'error' ? '#b41810e6' : '#563e3fb1');
592
494
  refs.statusLabel.text = formatStatusText(snapshot);
593
- refs.statusLabel.color = asColor(snapshot.tone === 'error' ? '#b41810e6' : '#563e3fb1');
495
+ const textColor = snapshot.tone === 'error' ? '#b41810e6' : snapshot.tone === 'success' ? '#0e6e2fff' : '#563e3fb1';
496
+ refs.titleLabel.color = asColor(textColor);
497
+ refs.statusLabel.color = asColor(textColor);
498
+ // Backdrop tints (centered modal only). Toast modes use a fully
499
+ // transparent backdrop so the rest of the app stays visible AND
500
+ // reachable; the panel itself carries enough colour to stand out.
501
+ if (isToast) {
502
+ refs.overlay.backgroundColor = asColor('transparent');
503
+ }
504
+ else {
505
+ // Original wash-by-tone for centered:
506
+ // error → red wash (matches existing UX)
507
+ // success → richer green wash so the apply event is visible
508
+ // on bright app backgrounds
509
+ // default → warm orange (existing connection-overlay look)
510
+ const overlayBg = snapshot.tone === 'error' ? '#b4181068' : snapshot.tone === 'success' ? '#1f883d80' : '#a1771683';
511
+ refs.overlay.backgroundColor = asColor(overlayBg);
512
+ }
513
+ // Panel chrome — toast and centered share the same chip look,
514
+ // just position differs. We keep the slightly richer green tint
515
+ // for the HMR success state so it pops without needing the
516
+ // backdrop wash.
517
+ let panel = null;
594
518
  try {
595
- const panel = refs.titleLabel.parent;
519
+ panel = refs.titleLabel.parent;
596
520
  if (panel) {
597
- panel.backgroundColor = asColor('#FFFFFFFF');
521
+ const panelBg = snapshot.tone === 'success' ? '#E6F8E9FF' : '#FFFFFFFF';
522
+ panel.backgroundColor = asColor(panelBg);
598
523
  panel.opacity = 1;
599
524
  panel.padding = 16;
600
525
  try {
601
526
  panel.borderRadius = 12;
602
527
  }
603
528
  catch { }
529
+ // Position-aware alignment. The wrapper GridLayout fills
530
+ // the page content area, which on iOS is already inside
531
+ // the safe area; we add a small extra margin so the chip
532
+ // doesn't kiss the notch / home indicator.
533
+ try {
534
+ if (position === 'top') {
535
+ panel.verticalAlignment = 'top';
536
+ panel.margin = '12 16 0 16';
537
+ }
538
+ else if (position === 'bottom') {
539
+ panel.verticalAlignment = 'bottom';
540
+ panel.margin = '0 16 12 16';
541
+ }
542
+ else {
543
+ panel.verticalAlignment = 'middle';
544
+ panel.margin = 24;
545
+ }
546
+ }
547
+ catch { }
548
+ }
549
+ }
550
+ catch { }
551
+ // Touch passthrough for toast; centered mode keeps the
552
+ // blocking modal so the dim backdrop is meaningful.
553
+ try {
554
+ refs.overlay.isUserInteractionEnabled = !isToast;
555
+ }
556
+ catch { }
557
+ const positionChanged = previousPosition !== position;
558
+ const justAppeared = visible && (!wasVisible || positionChanged);
559
+ const justDismissed = !visible && wasVisible;
560
+ if (justAppeared) {
561
+ refs.overlay.visibility = 'visible';
562
+ if (isToast && panel && typeof panel.animate === 'function') {
563
+ animateLivePanelIn(panel, position);
564
+ }
565
+ else if (panel) {
566
+ try {
567
+ panel.translateY = 0;
568
+ panel.opacity = 1;
569
+ }
570
+ catch { }
571
+ }
572
+ }
573
+ else if (justDismissed) {
574
+ if (isToast && panel && typeof panel.animate === 'function') {
575
+ animateLivePanelOut(panel, previousPosition, () => {
576
+ try {
577
+ refs.overlay.visibility = 'collapse';
578
+ }
579
+ catch { }
580
+ });
581
+ }
582
+ else {
583
+ refs.overlay.visibility = 'collapse';
584
+ }
585
+ }
586
+ else {
587
+ refs.overlay.visibility = visible ? 'visible' : 'collapse';
588
+ }
589
+ if (typeof refs.wasVisible !== 'undefined')
590
+ refs.wasVisible = visible;
591
+ if (typeof refs.currentPosition !== 'undefined')
592
+ refs.currentPosition = position;
593
+ }
594
+ /**
595
+ * Slide-in animation for the in-tree toast panel.
596
+ *
597
+ * NativeScript's `View.animate({ translate, opacity, duration, curve })`
598
+ * is widely available across Core versions, so we don't depend on any
599
+ * specific curve enum being importable here. We use a moderate-to-snappy
600
+ * 320ms ease-out which feels close to a UIView spring without needing
601
+ * platform-specific APIs.
602
+ */
603
+ function animateLivePanelIn(panel, position) {
604
+ if (!panel || typeof panel.animate !== 'function')
605
+ return;
606
+ try {
607
+ const startY = position === 'bottom' ? 80 : -80;
608
+ panel.translateY = startY;
609
+ panel.opacity = 0;
610
+ const result = panel.animate({
611
+ translate: { x: 0, y: 0 },
612
+ opacity: 1,
613
+ duration: 320,
614
+ curve: 'easeOut',
615
+ });
616
+ if (result && typeof result.catch === 'function') {
617
+ result.catch(() => {
618
+ try {
619
+ panel.translateY = 0;
620
+ panel.opacity = 1;
621
+ }
622
+ catch { }
623
+ });
624
+ }
625
+ }
626
+ catch {
627
+ try {
628
+ panel.translateY = 0;
629
+ panel.opacity = 1;
630
+ }
631
+ catch { }
632
+ }
633
+ }
634
+ function animateLivePanelOut(panel, position, onComplete) {
635
+ if (!panel || typeof panel.animate !== 'function') {
636
+ onComplete();
637
+ return;
638
+ }
639
+ try {
640
+ const targetY = position === 'bottom' ? 80 : -80;
641
+ const result = panel.animate({
642
+ translate: { x: 0, y: targetY },
643
+ opacity: 0,
644
+ duration: 220,
645
+ curve: 'easeIn',
646
+ });
647
+ const finish = () => {
648
+ try {
649
+ panel.translateY = 0;
650
+ panel.opacity = 1;
651
+ }
652
+ catch { }
653
+ onComplete();
654
+ };
655
+ if (result && typeof result.then === 'function') {
656
+ result.then(finish, finish);
657
+ }
658
+ else {
659
+ finish();
660
+ }
661
+ }
662
+ catch {
663
+ onComplete();
664
+ }
665
+ }
666
+ // pure helpers for iOS window promotion. Factored out so the layout
667
+ // math and window-level selection stay unit-testable without booting a
668
+ // simulator. See `dev-overlay.spec.ts`.
669
+ /**
670
+ * Returns the UIWindow level we use for the live/connection overlay. We lift
671
+ * above `UIWindowLevelAlert` so system alerts (and any app-presented modal)
672
+ * stack underneath. When the platform does not expose `UIWindowLevelAlert`
673
+ * we fall back to the documented constant value (2000).
674
+ */
675
+ export function computeIosOverlayWindowLevel(baseAlert) {
676
+ if (typeof baseAlert === 'number' && Number.isFinite(baseAlert)) {
677
+ return baseAlert + 1;
678
+ }
679
+ return 2000 + 1;
680
+ }
681
+ /**
682
+ * Layout math for the live overlay when it runs inside its own UIWindow.
683
+ * Pure, deterministic and independent of UIKit so we can verify the rules
684
+ * (max panel width, position-aware placement, safe-area clamping, sane
685
+ * defaults) from tests.
686
+ *
687
+ * `position` controls where the panel sits vertically:
688
+ * - 'top': hugs `safeInsets.top + toastVerticalInset` so the chip
689
+ * sits just below the notch / Dynamic Island.
690
+ * - 'bottom': hugs `viewHeight - safeInsets.bottom - panelHeight -
691
+ * toastVerticalInset` so the chip sits just above the
692
+ * home indicator / nav bar.
693
+ * - 'center': original modal placement (vertically centered, clamped
694
+ * so it never crosses the top safe-area inset).
695
+ */
696
+ export function computeIosOverlayLayout(input) {
697
+ const viewWidth = Math.max(0, Number(input.viewWidth) || 0);
698
+ const viewHeight = Math.max(0, Number(input.viewHeight) || 0);
699
+ const safeInsets = {
700
+ top: Math.max(0, Number(input.safeInsets?.top ?? 0) || 0),
701
+ bottom: Math.max(0, Number(input.safeInsets?.bottom ?? 0) || 0),
702
+ left: Math.max(0, Number(input.safeInsets?.left ?? 0) || 0),
703
+ right: Math.max(0, Number(input.safeInsets?.right ?? 0) || 0),
704
+ };
705
+ const titleHeight = Math.max(0, Number(input.titleHeight) || 0);
706
+ const statusHeight = Math.max(0, Number(input.statusHeight) || 0);
707
+ const horizontalMargin = Math.max(0, Number(input.horizontalMargin ?? 24));
708
+ const maxPanelWidth = Math.max(0, Number(input.maxPanelWidth ?? 340));
709
+ const panelPadding = Math.max(0, Number(input.panelPadding ?? 16));
710
+ const interLabelSpacing = Math.max(0, Number(input.interLabelSpacing ?? 10));
711
+ const minTopInset = Math.max(0, Number(input.minTopInset ?? 20));
712
+ // Default to 'center' on the pure function so the existing
713
+ // snapshot/layout tests remain stable; the runtime call site
714
+ // (layoutIosOverlayRefs) reads the configured position from
715
+ // `getHmrDevOverlayPosition()` and forwards it explicitly.
716
+ const position = input.position ?? 'center';
717
+ // Distance between the panel and the safe-area edge in toast
718
+ // modes. 8pt mirrors the typical iOS notification chip inset and
719
+ // keeps the chip from hugging the notch / home indicator.
720
+ const toastVerticalInset = Math.max(0, Number(input.toastVerticalInset ?? 8));
721
+ const available = Math.max(0, viewWidth - 2 * horizontalMargin - safeInsets.left - safeInsets.right);
722
+ const panelWidth = Math.min(maxPanelWidth, available);
723
+ const innerWidth = Math.max(0, panelWidth - 2 * panelPadding);
724
+ const spacing = titleHeight > 0 && statusHeight > 0 ? interLabelSpacing : 0;
725
+ const panelHeight = panelPadding * 2 + titleHeight + spacing + statusHeight;
726
+ const panelX = Math.max(0, (viewWidth - panelWidth) / 2);
727
+ let panelY;
728
+ if (position === 'top') {
729
+ // Pin to the top safe-area inset (just below notch / Dynamic
730
+ // Island). Clamp non-negative for fully-NaN input.
731
+ panelY = Math.max(0, safeInsets.top + toastVerticalInset);
732
+ }
733
+ else if (position === 'bottom') {
734
+ // Pin to the bottom safe-area inset (just above home indicator
735
+ // / nav bar). If the panel can't fit between the safe-area
736
+ // insets we fall back to the top safe-area edge so the chip is
737
+ // always visible (rather than getting clipped off-screen).
738
+ const desired = viewHeight - safeInsets.bottom - panelHeight - toastVerticalInset;
739
+ panelY = Math.max(safeInsets.top + minTopInset, desired);
740
+ }
741
+ else {
742
+ // Center vertically, but never cross the top safe-area inset
743
+ // (notch/Dynamic Island). Original modal placement.
744
+ const centered = (viewHeight - panelHeight) / 2;
745
+ panelY = Math.max(safeInsets.top + minTopInset, centered);
746
+ }
747
+ return {
748
+ backdrop: { x: 0, y: 0, width: viewWidth, height: viewHeight },
749
+ panel: { x: panelX, y: panelY, width: panelWidth, height: panelHeight },
750
+ title: { x: panelPadding, y: panelPadding, width: innerWidth, height: titleHeight },
751
+ status: {
752
+ x: panelPadding,
753
+ y: panelPadding + titleHeight + spacing,
754
+ width: innerWidth,
755
+ height: statusHeight,
756
+ },
757
+ };
758
+ }
759
+ /**
760
+ * Returns the iOS UIKit symbols we rely on if we're running on an iOS runtime
761
+ * with the metadata bridge available. Returns null on Android, web, or in
762
+ * tests so callers can gracefully fall back to the in-tree overlay.
763
+ */
764
+ function getIosOverlayHost() {
765
+ const g = getOverlayGlobal();
766
+ if (typeof g.UIWindow === 'undefined' || typeof g.UIApplication === 'undefined' || typeof g.UIViewController === 'undefined' || typeof g.UIView === 'undefined' || typeof g.UILabel === 'undefined' || typeof g.UIColor === 'undefined' || typeof g.UIFont === 'undefined' || typeof g.UIScreen === 'undefined') {
767
+ return null;
768
+ }
769
+ return {
770
+ UIWindow: g.UIWindow,
771
+ UIViewController: g.UIViewController,
772
+ UIView: g.UIView,
773
+ UILabel: g.UILabel,
774
+ UIColor: g.UIColor,
775
+ UIFont: g.UIFont,
776
+ UIApplication: g.UIApplication,
777
+ UIScreen: g.UIScreen,
778
+ UIWindowLevelAlert: typeof g.UIWindowLevelAlert === 'number' ? g.UIWindowLevelAlert : undefined,
779
+ };
780
+ }
781
+ /**
782
+ * Walks UIApplication.sharedApplication windows and returns the first active
783
+ * UIWindowScene we can locate. On iOS 13+ every UIWindow is attached to a
784
+ * scene, and we must initialise our overlay window the same way or the OS
785
+ * will silently refuse to render it. Returns null when no scene is found
786
+ * (older iOS versions or non-UI environments).
787
+ */
788
+ function findActiveWindowScene(host) {
789
+ try {
790
+ const app = host.UIApplication.sharedApplication;
791
+ const windows = app?.windows;
792
+ if (!windows || typeof windows.count !== 'number')
793
+ return null;
794
+ for (let i = 0; i < windows.count; i++) {
795
+ const w = windows.objectAtIndex(i);
796
+ const scene = w && w.windowScene;
797
+ if (scene)
798
+ return scene;
799
+ }
800
+ }
801
+ catch { }
802
+ return null;
803
+ }
804
+ function buildIosOverlayRefs(state) {
805
+ const host = getIosOverlayHost();
806
+ if (!host)
807
+ return null;
808
+ // Without a scene we can't build a modern UIWindow that actually renders.
809
+ // Fall back to the in-tree overlay rather than show nothing.
810
+ const scene = findActiveWindowScene(host);
811
+ if (!scene) {
812
+ if (state.verbose) {
813
+ console.info('[ns-hmr-overlay] no active UIWindowScene; skipping iOS overlay promotion');
814
+ }
815
+ return null;
816
+ }
817
+ try {
818
+ const { UIWindow, UIViewController, UIView, UILabel, UIColor, UIFont } = host;
819
+ const window = UIWindow.alloc().initWithWindowScene(scene);
820
+ window.windowLevel = computeIosOverlayWindowLevel(host.UIWindowLevelAlert ?? null);
821
+ window.backgroundColor = UIColor.clearColor;
822
+ window.hidden = true;
823
+ const controller = UIViewController.new();
824
+ controller.view.backgroundColor = UIColor.clearColor;
825
+ window.rootViewController = controller;
826
+ // UIViewAutoresizing bit masks. We mirror the UIKit constants here to
827
+ // avoid depending on symbols the metadata bridge does not always
828
+ // expose as top-level globals.
829
+ const FLEXIBLE_LEFT_MARGIN = 1 << 0;
830
+ const FLEXIBLE_WIDTH = 1 << 1;
831
+ const FLEXIBLE_RIGHT_MARGIN = 1 << 2;
832
+ const FLEXIBLE_TOP_MARGIN = 1 << 3;
833
+ const FLEXIBLE_HEIGHT = 1 << 4;
834
+ const FLEXIBLE_BOTTOM_MARGIN = 1 << 5;
835
+ const backdrop = UIView.new();
836
+ backdrop.backgroundColor = UIColor.colorWithRedGreenBlueAlpha(0, 0, 0, 0.35);
837
+ backdrop.autoresizingMask = FLEXIBLE_WIDTH | FLEXIBLE_HEIGHT;
838
+ controller.view.addSubview(backdrop);
839
+ const panel = UIView.new();
840
+ panel.backgroundColor = UIColor.whiteColor;
841
+ panel.autoresizingMask = FLEXIBLE_LEFT_MARGIN | FLEXIBLE_RIGHT_MARGIN | FLEXIBLE_TOP_MARGIN | FLEXIBLE_BOTTOM_MARGIN;
842
+ try {
843
+ panel.layer.cornerRadius = 14;
844
+ panel.layer.masksToBounds = true;
845
+ }
846
+ catch { }
847
+ controller.view.addSubview(panel);
848
+ const titleLabel = UILabel.new();
849
+ titleLabel.numberOfLines = 0;
850
+ titleLabel.textAlignment = 1; // NSTextAlignmentCenter
851
+ titleLabel.font = UIFont.boldSystemFontOfSize(16);
852
+ titleLabel.textColor = UIColor.blackColor;
853
+ panel.addSubview(titleLabel);
854
+ const statusLabel = UILabel.new();
855
+ statusLabel.numberOfLines = 0;
856
+ statusLabel.textAlignment = 1;
857
+ statusLabel.font = UIFont.systemFontOfSize(13);
858
+ statusLabel.textColor = UIColor.darkGrayColor;
859
+ panel.addSubview(statusLabel);
860
+ // Subtle drop-shadow so the toast chip reads against light app
861
+ // content (white-on-white is invisible). The error / centered
862
+ // branches still get the dim backdrop, so the shadow is mostly
863
+ // a no-op for them — but it's a one-time setup.
864
+ try {
865
+ panel.layer.shadowColor = UIColor.blackColor.CGColor;
866
+ panel.layer.shadowOpacity = 0.18;
867
+ panel.layer.shadowRadius = 8;
868
+ panel.layer.shadowOffset = { width: 0, height: 2 };
869
+ panel.layer.masksToBounds = false;
870
+ }
871
+ catch { }
872
+ // `wasVisible` / `currentPosition` are mutated by
873
+ // applySnapshotToIosRefs when the snapshot triggers a slide-in
874
+ // or slide-out. They start in the "hidden" state so the very
875
+ // first visible snapshot animates in cleanly.
876
+ return {
877
+ window,
878
+ controller,
879
+ backdrop,
880
+ panel,
881
+ titleLabel,
882
+ statusLabel,
883
+ wasVisible: false,
884
+ currentPosition: getHmrDevOverlayPosition(),
885
+ };
886
+ }
887
+ catch (err) {
888
+ console.warn('[ns-hmr-overlay] iOS overlay construction failed:', err?.message || err);
889
+ return null;
890
+ }
891
+ }
892
+ function ensureIosOverlayRefs(state) {
893
+ if (state.iosRefs)
894
+ return state.iosRefs;
895
+ if (state.iosBuildFailed)
896
+ return null;
897
+ const built = buildIosOverlayRefs(state);
898
+ if (built) {
899
+ state.iosRefs = built;
900
+ }
901
+ else {
902
+ // Remember failure so we don't hammer construction on every snapshot
903
+ // update — the in-tree path will take over for this session.
904
+ state.iosBuildFailed = true;
905
+ }
906
+ return state.iosRefs;
907
+ }
908
+ function layoutIosOverlayRefs(refs, position) {
909
+ try {
910
+ const bounds = refs.controller.view.bounds;
911
+ const viewWidth = Number(bounds?.size?.width) || 0;
912
+ const viewHeight = Number(bounds?.size?.height) || 0;
913
+ const raw = refs.controller.view.safeAreaInsets;
914
+ const safeInsets = raw
915
+ ? {
916
+ top: Number(raw.top) || 0,
917
+ bottom: Number(raw.bottom) || 0,
918
+ left: Number(raw.left) || 0,
919
+ right: Number(raw.right) || 0,
920
+ }
921
+ : { top: 0, bottom: 0, left: 0, right: 0 };
922
+ // Ask UIKit what the labels want given the panel inner width. We use a
923
+ // generous height bound so nothing clips on long reconnect strings.
924
+ const panelPadding = 16;
925
+ const horizontalMargin = 24;
926
+ const maxPanelWidth = 340;
927
+ const innerWidth = Math.max(0, Math.min(maxPanelWidth, viewWidth - 2 * horizontalMargin - safeInsets.left - safeInsets.right) - 2 * panelPadding);
928
+ const titleFit = refs.titleLabel.sizeThatFits({ width: innerWidth, height: 10000 }) || { height: 0 };
929
+ const statusFit = refs.statusLabel.sizeThatFits({ width: innerWidth, height: 10000 }) || { height: 0 };
930
+ const layout = computeIosOverlayLayout({
931
+ viewWidth,
932
+ viewHeight,
933
+ safeInsets,
934
+ titleHeight: Number(titleFit.height) || 0,
935
+ statusHeight: Number(statusFit.height) || 0,
936
+ maxPanelWidth,
937
+ horizontalMargin,
938
+ panelPadding,
939
+ position,
940
+ });
941
+ const toCgRect = (rect) => ({
942
+ origin: { x: rect.x, y: rect.y },
943
+ size: { width: rect.width, height: rect.height },
944
+ });
945
+ refs.backdrop.frame = toCgRect(layout.backdrop);
946
+ refs.panel.frame = toCgRect(layout.panel);
947
+ refs.titleLabel.frame = toCgRect(layout.title);
948
+ refs.statusLabel.frame = toCgRect(layout.status);
949
+ return layout;
950
+ }
951
+ catch (err) {
952
+ console.warn('[ns-hmr-overlay] iOS overlay layout failed:', err?.message || err);
953
+ return null;
954
+ }
955
+ }
956
+ /**
957
+ * Slide-in animation for the iOS toast panel. Off-screen start frame
958
+ * lives just above (top) or below (bottom) the visible area; the panel
959
+ * snaps to its target frame with a spring so the motion feels physical
960
+ * without the heavy "settle" overshoot of a hard spring (damping 0.85
961
+ * lands quickly with a small overshoot).
962
+ */
963
+ function animateIosPanelIn(refs, position, layout) {
964
+ const g = getOverlayGlobal();
965
+ const UIView = g?.UIView;
966
+ if (!UIView)
967
+ return;
968
+ try {
969
+ const targetFrame = {
970
+ origin: { x: layout.panel.x, y: layout.panel.y },
971
+ size: { width: layout.panel.width, height: layout.panel.height },
972
+ };
973
+ // Off-screen start: distance includes a small fudge so the
974
+ // shadow blur tail isn't visible at t=0.
975
+ const startY = position === 'bottom' ? layout.backdrop.height + 24 : -(layout.panel.height + 24);
976
+ refs.panel.frame = {
977
+ origin: { x: layout.panel.x, y: startY },
978
+ size: { width: layout.panel.width, height: layout.panel.height },
979
+ };
980
+ refs.panel.alpha = 0;
981
+ try {
982
+ if (typeof UIView.animateWithDurationDelayUsingSpringWithDampingInitialSpringVelocityOptionsAnimationsCompletion === 'function') {
983
+ UIView.animateWithDurationDelayUsingSpringWithDampingInitialSpringVelocityOptionsAnimationsCompletion(0.42, 0, 0.85, 0.7, 0, () => {
984
+ refs.panel.frame = targetFrame;
985
+ refs.panel.alpha = 1;
986
+ }, null);
987
+ }
988
+ else if (typeof UIView.animateWithDurationAnimations === 'function') {
989
+ UIView.animateWithDurationAnimations(0.32, () => {
990
+ refs.panel.frame = targetFrame;
991
+ refs.panel.alpha = 1;
992
+ });
993
+ }
994
+ else {
995
+ refs.panel.frame = targetFrame;
996
+ refs.panel.alpha = 1;
997
+ }
998
+ }
999
+ catch {
1000
+ refs.panel.frame = targetFrame;
1001
+ refs.panel.alpha = 1;
604
1002
  }
605
1003
  }
606
1004
  catch { }
607
1005
  }
1006
+ /**
1007
+ * Slide-out animation for the iOS toast panel. Mirrors animateIosPanelIn:
1008
+ * the panel travels to the nearest off-screen edge while fading out so
1009
+ * the dismissal still feels intentional even on fast HMR cycles.
1010
+ */
1011
+ function animateIosPanelOut(refs, position, onComplete) {
1012
+ const g = getOverlayGlobal();
1013
+ const UIView = g?.UIView;
1014
+ const currentFrame = refs.panel?.frame;
1015
+ if (!UIView || !currentFrame) {
1016
+ onComplete();
1017
+ return;
1018
+ }
1019
+ try {
1020
+ const bounds = refs.controller?.view?.bounds;
1021
+ const viewHeight = Number(bounds?.size?.height) || 0;
1022
+ const targetY = position === 'bottom' ? viewHeight + 24 : -(Number(currentFrame.size?.height) + 24);
1023
+ const startFrame = currentFrame;
1024
+ const targetFrame = {
1025
+ origin: { x: Number(startFrame.origin?.x) || 0, y: targetY },
1026
+ size: startFrame.size,
1027
+ };
1028
+ try {
1029
+ if (typeof UIView.animateWithDurationDelayOptionsAnimationsCompletion === 'function') {
1030
+ // UIViewAnimationOptionCurveEaseIn = 1 << 16 — accelerate
1031
+ // out so the dismissal doesn't drag on screen.
1032
+ UIView.animateWithDurationDelayOptionsAnimationsCompletion(0.22, 0, 1 << 16, () => {
1033
+ refs.panel.frame = targetFrame;
1034
+ refs.panel.alpha = 0;
1035
+ }, () => onComplete());
1036
+ }
1037
+ else if (typeof UIView.animateWithDurationAnimationsCompletion === 'function') {
1038
+ UIView.animateWithDurationAnimationsCompletion(0.22, () => {
1039
+ refs.panel.frame = targetFrame;
1040
+ refs.panel.alpha = 0;
1041
+ }, () => onComplete());
1042
+ }
1043
+ else {
1044
+ refs.panel.alpha = 0;
1045
+ onComplete();
1046
+ }
1047
+ }
1048
+ catch {
1049
+ refs.panel.alpha = 0;
1050
+ onComplete();
1051
+ }
1052
+ }
1053
+ catch {
1054
+ onComplete();
1055
+ }
1056
+ }
1057
+ function applySnapshotToIosRefs(refs, snapshot) {
1058
+ if (!refs)
1059
+ return false;
1060
+ try {
1061
+ // 'update' mode rides the same dedicated UIWindow as
1062
+ // 'connection' so the HMR apply overlay always stacks above
1063
+ // modals/sheets/system alerts. The window is constructed
1064
+ // lazily (ensureIosOverlayRefs) and reused for the lifetime of
1065
+ // the dev session.
1066
+ const visible = snapshot.visible && (snapshot.mode === 'connection' || snapshot.mode === 'update');
1067
+ const wasVisible = !!refs.wasVisible;
1068
+ const position = getHmrDevOverlayPosition();
1069
+ const previousPosition = refs.currentPosition;
1070
+ const isToast = position !== 'center';
1071
+ // Touches pass through the overlay window in toast mode so
1072
+ // the user can keep tapping the app while the HMR chip is
1073
+ // shown. In centered mode we keep the blocking
1074
+ // behaviour (the dim backdrop is itself a hint to wait).
1075
+ try {
1076
+ refs.window.userInteractionEnabled = !isToast;
1077
+ }
1078
+ catch { }
1079
+ if (!visible) {
1080
+ // Animate out before hiding the window so the dismissal
1081
+ // has a discoverable motion. Only animate when previously
1082
+ // visible and in toast mode — centered modal hides instantly.
1083
+ if (wasVisible && isToast) {
1084
+ animateIosPanelOut(refs, previousPosition, () => {
1085
+ try {
1086
+ refs.window.hidden = true;
1087
+ }
1088
+ catch { }
1089
+ });
1090
+ }
1091
+ else {
1092
+ refs.window.hidden = true;
1093
+ }
1094
+ refs.wasVisible = false;
1095
+ refs.currentPosition = position;
1096
+ return true;
1097
+ }
1098
+ refs.window.hidden = false;
1099
+ refs.titleLabel.text = snapshot.title || '';
1100
+ refs.statusLabel.text = formatStatusText(snapshot);
1101
+ const host = getIosOverlayHost();
1102
+ if (host) {
1103
+ const { UIColor } = host;
1104
+ const isError = snapshot.tone === 'error';
1105
+ const isSuccess = snapshot.tone === 'success';
1106
+ try {
1107
+ if (isError) {
1108
+ // Red panel + dark red text (existing UX).
1109
+ refs.panel.backgroundColor = UIColor.colorWithRedGreenBlueAlpha(1, 0.96, 0.96, 1);
1110
+ refs.titleLabel.textColor = UIColor.colorWithRedGreenBlueAlpha(0.7, 0.1, 0.06, 1);
1111
+ refs.statusLabel.textColor = UIColor.colorWithRedGreenBlueAlpha(0.7, 0.1, 0.06, 0.9);
1112
+ }
1113
+ else if (isSuccess) {
1114
+ // Slightly more saturated green panel + dark-green
1115
+ // text. The previous 0.94/0.99/0.95 background was
1116
+ // nearly indistinguishable from white on most
1117
+ // devices; this bump keeps long detail strings
1118
+ // readable while making the apply event obviously
1119
+ // "happening right now".
1120
+ refs.panel.backgroundColor = UIColor.colorWithRedGreenBlueAlpha(0.9, 0.97, 0.91, 1);
1121
+ refs.titleLabel.textColor = UIColor.colorWithRedGreenBlueAlpha(0.05, 0.43, 0.18, 1);
1122
+ refs.statusLabel.textColor = UIColor.colorWithRedGreenBlueAlpha(0.05, 0.43, 0.18, 1);
1123
+ }
1124
+ else {
1125
+ // Default (info / warn) — existing connection look.
1126
+ refs.panel.backgroundColor = UIColor.whiteColor;
1127
+ refs.titleLabel.textColor = UIColor.blackColor;
1128
+ refs.statusLabel.textColor = UIColor.darkGrayColor;
1129
+ }
1130
+ // Backdrop dims only in centered mode; toast mode keeps
1131
+ // the rest of the app fully visible/usable. Errors get
1132
+ // a slightly stronger dim in centered mode because the
1133
+ // user MUST notice them.
1134
+ if (isToast) {
1135
+ refs.backdrop.backgroundColor = UIColor.clearColor;
1136
+ }
1137
+ else if (isError) {
1138
+ refs.backdrop.backgroundColor = UIColor.colorWithRedGreenBlueAlpha(0, 0, 0, 0.35);
1139
+ }
1140
+ else if (isSuccess) {
1141
+ refs.backdrop.backgroundColor = UIColor.colorWithRedGreenBlueAlpha(0, 0.15, 0.05, 0.28);
1142
+ }
1143
+ else {
1144
+ refs.backdrop.backgroundColor = UIColor.colorWithRedGreenBlueAlpha(0, 0, 0, 0.35);
1145
+ }
1146
+ }
1147
+ catch { }
1148
+ }
1149
+ const layout = layoutIosOverlayRefs(refs, position);
1150
+ // Slide-in animation only fires on the actual hidden→visible
1151
+ // transition (or on a position swap — e.g. dev toggling top
1152
+ // to bottom mid-cycle). Subsequent updates within the same
1153
+ // visible cycle just refresh text/colours without re-animating.
1154
+ const positionChanged = previousPosition !== position;
1155
+ const justAppeared = !wasVisible || positionChanged;
1156
+ if (justAppeared && isToast && layout) {
1157
+ animateIosPanelIn(refs, position, layout);
1158
+ }
1159
+ else if (justAppeared && !isToast) {
1160
+ // Centered modal: ensure alpha is reset to 1 in case a
1161
+ // previous toast-mode dismissal left it at 0.
1162
+ try {
1163
+ refs.panel.alpha = 1;
1164
+ }
1165
+ catch { }
1166
+ }
1167
+ refs.wasVisible = true;
1168
+ refs.currentPosition = position;
1169
+ return true;
1170
+ }
1171
+ catch (err) {
1172
+ console.warn('[ns-hmr-overlay] iOS overlay apply failed:', err?.message || err);
1173
+ return false;
1174
+ }
1175
+ }
608
1176
  function applyRuntimeSnapshot(snapshot) {
609
1177
  const state = getRuntimeState();
610
1178
  state.snapshot = snapshot;
@@ -613,15 +1181,108 @@ function applyRuntimeSnapshot(snapshot) {
613
1181
  updateBootStatusLabel(snapshot);
614
1182
  }
615
1183
  applySnapshotToBootRefs(state.bootRefs, snapshot);
616
- if (snapshot.visible && snapshot.mode === 'connection') {
617
- const liveRefs = ensureLiveOverlayRefs(snapshot);
618
- applySnapshotToLiveRefs(liveRefs, snapshot);
1184
+ // prefer the dedicated UIWindow
1185
+ // path so the live/update overlays always stack on top of modals,
1186
+ // sheets, and other windows. Fall back to the in-tree overlay when
1187
+ // iOS APIs aren't available (Android, tests, or when scene
1188
+ // construction fails).
1189
+ let handledByIos = false;
1190
+ // Both 'connection' and 'update' use the small-panel surface
1191
+ // (UIWindow on iOS, in-tree overlay everywhere else). 'boot' uses
1192
+ // the placeholder root via applySnapshotToBootRefs above; 'hidden'
1193
+ // hides everything.
1194
+ const wantsOverlay = snapshot.visible && (snapshot.mode === 'connection' || snapshot.mode === 'update');
1195
+ if (getIosOverlayHost()) {
1196
+ if (wantsOverlay) {
1197
+ const iosRefs = ensureIosOverlayRefs(state);
1198
+ handledByIos = applySnapshotToIosRefs(iosRefs, snapshot);
1199
+ }
1200
+ else if (state.iosRefs) {
1201
+ handledByIos = applySnapshotToIosRefs(state.iosRefs, snapshot);
1202
+ }
619
1203
  }
620
- else {
621
- applySnapshotToLiveRefs(state.liveRefs, snapshot);
1204
+ if (!handledByIos) {
1205
+ if (wantsOverlay) {
1206
+ const liveRefs = ensureLiveOverlayRefs(snapshot);
1207
+ applySnapshotToLiveRefs(liveRefs, snapshot);
1208
+ }
1209
+ else {
1210
+ applySnapshotToLiveRefs(state.liveRefs, snapshot);
1211
+ }
622
1212
  }
623
1213
  return state.snapshot;
624
1214
  }
1215
+ // How long the 'complete' frame stays on screen before we auto-hide.
1216
+ // The original 350ms was too tight: many HMR cycles complete in
1217
+ // 50–250ms, so the *total* overlay lifetime (received → complete +
1218
+ // 350ms) was often under 500ms, which is faster than the human eye
1219
+ // can comfortably register. 600ms gives the user time to read the
1220
+ // "Total Xms" line and confirm visually that something happened.
1221
+ const UPDATE_AUTO_HIDE_MS = 600;
1222
+ // Minimum perceptible duration for an entire update overlay cycle
1223
+ // (from 'received' to hide). If the cycle finished in 50ms (e.g., a
1224
+ // tiny HTML edit on a warm cache), we still hold for ~MIN_VISIBLE_MS
1225
+ // total before hiding so the overlay is actually seen. Combined with
1226
+ // UPDATE_AUTO_HIDE_MS, the *effective* hold-after-complete =
1227
+ // max(UPDATE_AUTO_HIDE_MS, MIN_VISIBLE_MS - elapsed-since-received).
1228
+ const UPDATE_MIN_VISIBLE_MS = 800;
1229
+ function clearUpdateAutoHideTimer(state) {
1230
+ if (state.updateAutoHideTimer) {
1231
+ try {
1232
+ clearTimeout(state.updateAutoHideTimer);
1233
+ }
1234
+ catch { }
1235
+ state.updateAutoHideTimer = null;
1236
+ }
1237
+ }
1238
+ function scheduleUpdateAutoHide(state) {
1239
+ clearUpdateAutoHideTimer(state);
1240
+ // Compute how much longer we need to hold the overlay so that the
1241
+ // total cycle visibility is at least UPDATE_MIN_VISIBLE_MS. For
1242
+ // fast cycles (50ms reboot) this stretches the hide; for slow
1243
+ // cycles (>UPDATE_MIN_VISIBLE_MS) it falls back to the standard
1244
+ // UPDATE_AUTO_HIDE_MS so we don't truncate the celebratory hold.
1245
+ const startedAt = state.updateCycleStartedAt || 0;
1246
+ const elapsed = startedAt > 0 ? Math.max(0, Date.now() - startedAt) : 0;
1247
+ const minRemainder = elapsed > 0 ? Math.max(0, UPDATE_MIN_VISIBLE_MS - elapsed) : UPDATE_MIN_VISIBLE_MS;
1248
+ const holdMs = Math.max(UPDATE_AUTO_HIDE_MS, minRemainder);
1249
+ try {
1250
+ state.updateAutoHideTimer = setTimeout(() => {
1251
+ state.updateAutoHideTimer = null;
1252
+ // Critical: only auto-hide if we're still on the 'complete'
1253
+ // frame. If a new HMR cycle has rotated the snapshot back
1254
+ // to 'update' / 'received' (e.g., user saved twice in
1255
+ // quick succession), the new cycle owns the overlay and
1256
+ // our timer must not steal it.
1257
+ const current = state.snapshot;
1258
+ if (current.mode === 'update' && current.tone === 'success' && current.progress === 100) {
1259
+ state.updateCycleStartedAt = 0;
1260
+ applyRuntimeSnapshot({ ...DEFAULT_SNAPSHOT });
1261
+ }
1262
+ }, holdMs);
1263
+ }
1264
+ catch {
1265
+ // setTimeout missing (extremely rare; some test envs). Fall
1266
+ // back to immediate hide so we never leave the overlay visible
1267
+ // forever after a 'complete'.
1268
+ state.updateCycleStartedAt = 0;
1269
+ applyRuntimeSnapshot({ ...DEFAULT_SNAPSHOT });
1270
+ }
1271
+ }
1272
+ function logUpdateStageTransition(state, stage, info) {
1273
+ if (!state.verbose)
1274
+ return;
1275
+ try {
1276
+ const detail = info?.detail || '';
1277
+ const progress = typeof info?.progress === 'number' ? info.progress : null;
1278
+ const progressTag = progress !== null ? ` (${Math.round(progress)}%)` : '';
1279
+ // Single-line breadcrumb so a developer can correlate
1280
+ // overlay frames with the [ns-hmr][angular] timing log when
1281
+ // debugging "I don't see the overlay" reports.
1282
+ console.info(`[ns-hmr-overlay] update stage=${stage}${progressTag}${detail ? ` detail=${detail}` : ''}`);
1283
+ }
1284
+ catch { }
1285
+ }
625
1286
  function createOverlayApi() {
626
1287
  return {
627
1288
  ensureBootPage(verbose) {
@@ -637,12 +1298,74 @@ function createOverlayApi() {
637
1298
  return state.bootRefs?.page || null;
638
1299
  },
639
1300
  setBootStage(stage, info) {
640
- return applyRuntimeSnapshot(createBootOverlaySnapshot(stage, info));
1301
+ // A boot transition cancels any pending HMR auto-hide so
1302
+ // the boot phase always wins.
1303
+ const state = getRuntimeState();
1304
+ clearUpdateAutoHideTimer(state);
1305
+ state.updateCycleStartedAt = 0;
1306
+ const next = createBootOverlaySnapshot(stage, info);
1307
+ // Monotonic boot-progress ratchet: boot stages can fire out of
1308
+ // order across boot paths (native `__nsStartDevSession` vs the
1309
+ // http-bootloader fallback) and individual bases were tuned
1310
+ // independently, so clamp boot→boot transitions to never go
1311
+ // backwards. Non-boot snapshots (error/ready) bypass — they
1312
+ // genuinely want to reset the visual.
1313
+ if (next.mode === 'boot' && state.snapshot.mode === 'boot' && typeof next.progress === 'number' && typeof state.snapshot.progress === 'number' && next.progress < state.snapshot.progress) {
1314
+ next.progress = state.snapshot.progress;
1315
+ }
1316
+ return applyRuntimeSnapshot(next);
641
1317
  },
642
1318
  setConnectionStage(stage, info) {
1319
+ const state = getRuntimeState();
1320
+ clearUpdateAutoHideTimer(state);
1321
+ state.updateCycleStartedAt = 0;
643
1322
  return applyRuntimeSnapshot(createConnectionOverlaySnapshot(stage, info));
644
1323
  },
1324
+ setUpdateStage(stage, info) {
1325
+ const state = getRuntimeState();
1326
+ // Each new in-progress stage cancels any pending auto-hide
1327
+ // from a previous cycle. Without this, two saves in quick
1328
+ // succession could see cycle-2's progress overlay yanked
1329
+ // off by cycle-1's already-scheduled hide.
1330
+ clearUpdateAutoHideTimer(state);
1331
+ // Stamp the cycle start on 'received', but distinguish
1332
+ // between two cases:
1333
+ //
1334
+ // (a) Re-assertion of the SAME cycle (e.g., the server
1335
+ // emits both `ns:hmr-pending` AND `ns:angular-update`,
1336
+ // both of which call `setUpdateStage('received')`).
1337
+ // We must PRESERVE the original timestamp so the
1338
+ // minimum-visible-window math measures the FIRST
1339
+ // 'received' the user actually saw.
1340
+ //
1341
+ // (b) Genuinely-new cycle starting either from a hidden
1342
+ // overlay OR while the previous cycle is still on
1343
+ // its 'complete' frame (pre auto-hide). In both
1344
+ // sub-cases we MUST stamp a fresh start so the
1345
+ // new cycle's auto-hide math is sane.
1346
+ //
1347
+ // We treat the previous snapshot as "in-progress for the
1348
+ // same cycle" iff mode==='update' AND progress!==100.
1349
+ // 'complete' frames are a sign that the cycle finished;
1350
+ // any subsequent 'received' is a NEW cycle.
1351
+ if (stage === 'received') {
1352
+ const prev = state.snapshot;
1353
+ const isMidCycleReassertion = prev.mode === 'update' && prev.progress !== 100;
1354
+ if (!isMidCycleReassertion) {
1355
+ state.updateCycleStartedAt = Date.now();
1356
+ }
1357
+ }
1358
+ logUpdateStageTransition(state, stage, info);
1359
+ const snapshot = applyRuntimeSnapshot(createUpdateOverlaySnapshot(stage, info));
1360
+ if (stage === 'complete') {
1361
+ scheduleUpdateAutoHide(state);
1362
+ }
1363
+ return snapshot;
1364
+ },
645
1365
  hide() {
1366
+ const state = getRuntimeState();
1367
+ clearUpdateAutoHideTimer(state);
1368
+ state.updateCycleStartedAt = 0;
646
1369
  applyRuntimeSnapshot({ ...DEFAULT_SNAPSHOT });
647
1370
  },
648
1371
  getSnapshot() {
@@ -668,6 +1391,14 @@ export function setHmrBootStage(stage, info) {
668
1391
  export function setHmrConnectionStage(stage, info) {
669
1392
  return ensureHmrDevOverlayRuntimeInstalled().setConnectionStage(stage, info);
670
1393
  }
1394
+ // Public entry point for driving the HMR-applying overlay. Callers
1395
+ // walk through stages (received → evicting → reimporting → rebooting
1396
+ // → complete); 'complete' auto-hides after a short interval.
1397
+ // Soft-fails (no-op) if the runtime overlay was never installed
1398
+ // (e.g., production builds, test environments).
1399
+ export function setHmrUpdateStage(stage, info) {
1400
+ return ensureHmrDevOverlayRuntimeInstalled().setUpdateStage(stage, info);
1401
+ }
671
1402
  export function hideHmrDevOverlay(reason) {
672
1403
  void reason;
673
1404
  ensureHmrDevOverlayRuntimeInstalled().hide(reason);