@nativescript/vite 8.0.0-alpha.0 → 8.0.0-alpha.10

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 (222) hide show
  1. package/configuration/angular.d.ts +1 -1
  2. package/configuration/angular.js +486 -140
  3. package/configuration/angular.js.map +1 -1
  4. package/configuration/base.js +159 -41
  5. package/configuration/base.js.map +1 -1
  6. package/configuration/javascript.js +3 -3
  7. package/configuration/javascript.js.map +1 -1
  8. package/configuration/solid.js +7 -0
  9. package/configuration/solid.js.map +1 -1
  10. package/configuration/typescript.js +4 -4
  11. package/configuration/typescript.js.map +1 -1
  12. package/helpers/angular/angular-linker.js +38 -42
  13. package/helpers/angular/angular-linker.js.map +1 -1
  14. package/helpers/angular/inject-component-hmr-registration.d.ts +112 -0
  15. package/helpers/angular/inject-component-hmr-registration.js +359 -0
  16. package/helpers/angular/inject-component-hmr-registration.js.map +1 -0
  17. package/helpers/angular/inline-decorator-component-templates.d.ts +3 -0
  18. package/helpers/angular/inline-decorator-component-templates.js +400 -0
  19. package/helpers/angular/inline-decorator-component-templates.js.map +1 -0
  20. package/helpers/angular/shared-linker.d.ts +7 -0
  21. package/helpers/angular/shared-linker.js +37 -1
  22. package/helpers/angular/shared-linker.js.map +1 -1
  23. package/helpers/angular/synthesize-decorator-ctor-parameters.d.ts +1 -0
  24. package/helpers/angular/synthesize-decorator-ctor-parameters.js +256 -0
  25. package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +1 -0
  26. package/helpers/angular/synthesize-injectable-factories.d.ts +3 -0
  27. package/helpers/angular/synthesize-injectable-factories.js +414 -0
  28. package/helpers/angular/synthesize-injectable-factories.js.map +1 -0
  29. package/helpers/angular/util.d.ts +1 -0
  30. package/helpers/angular/util.js +88 -0
  31. package/helpers/angular/util.js.map +1 -1
  32. package/helpers/commonjs-plugins.d.ts +5 -2
  33. package/helpers/commonjs-plugins.js +126 -0
  34. package/helpers/commonjs-plugins.js.map +1 -1
  35. package/helpers/config-as-json.js +10 -0
  36. package/helpers/config-as-json.js.map +1 -1
  37. package/helpers/esbuild-platform-resolver.js +5 -5
  38. package/helpers/esbuild-platform-resolver.js.map +1 -1
  39. package/helpers/external-configs.d.ts +9 -1
  40. package/helpers/external-configs.js +31 -6
  41. package/helpers/external-configs.js.map +1 -1
  42. package/helpers/global-defines.d.ts +51 -0
  43. package/helpers/global-defines.js +77 -0
  44. package/helpers/global-defines.js.map +1 -1
  45. package/helpers/import-meta-path.d.ts +4 -0
  46. package/helpers/import-meta-path.js +5 -0
  47. package/helpers/import-meta-path.js.map +1 -0
  48. package/helpers/import-specifier.d.ts +1 -0
  49. package/helpers/import-specifier.js +18 -0
  50. package/helpers/import-specifier.js.map +1 -0
  51. package/helpers/logging.d.ts +1 -0
  52. package/helpers/logging.js +63 -3
  53. package/helpers/logging.js.map +1 -1
  54. package/helpers/main-entry.d.ts +5 -2
  55. package/helpers/main-entry.js +365 -116
  56. package/helpers/main-entry.js.map +1 -1
  57. package/helpers/nativeclass-transform.js +8 -127
  58. package/helpers/nativeclass-transform.js.map +1 -1
  59. package/helpers/nativeclass-transformer-plugin.d.ts +19 -1
  60. package/helpers/nativeclass-transformer-plugin.js +318 -31
  61. package/helpers/nativeclass-transformer-plugin.js.map +1 -1
  62. package/helpers/ns-core-url.d.ts +83 -0
  63. package/helpers/ns-core-url.js +167 -0
  64. package/helpers/ns-core-url.js.map +1 -0
  65. package/helpers/prelink-angular.js +1 -4
  66. package/helpers/prelink-angular.js.map +1 -1
  67. package/helpers/preserve-imports.js +2 -17
  68. package/helpers/preserve-imports.js.map +1 -1
  69. package/helpers/project.d.ts +35 -0
  70. package/helpers/project.js +120 -2
  71. package/helpers/project.js.map +1 -1
  72. package/helpers/ts-config-paths.js +50 -2
  73. package/helpers/ts-config-paths.js.map +1 -1
  74. package/helpers/workers.d.ts +20 -19
  75. package/helpers/workers.js +620 -3
  76. package/helpers/workers.js.map +1 -1
  77. package/hmr/client/css-handler.js +60 -19
  78. package/hmr/client/css-handler.js.map +1 -1
  79. package/hmr/client/hmr-pending-overlay.d.ts +27 -0
  80. package/hmr/client/hmr-pending-overlay.js +50 -0
  81. package/hmr/client/hmr-pending-overlay.js.map +1 -0
  82. package/hmr/client/index.js +597 -24
  83. package/hmr/client/index.js.map +1 -1
  84. package/hmr/client/utils.d.ts +5 -0
  85. package/hmr/client/utils.js +212 -21
  86. package/hmr/client/utils.js.map +1 -1
  87. package/hmr/entry-runtime.d.ts +10 -0
  88. package/hmr/entry-runtime.js +330 -42
  89. package/hmr/entry-runtime.js.map +1 -1
  90. package/hmr/frameworks/angular/client/index.d.ts +3 -1
  91. package/hmr/frameworks/angular/client/index.js +821 -25
  92. package/hmr/frameworks/angular/client/index.js.map +1 -1
  93. package/hmr/frameworks/angular/server/linker.js +37 -6
  94. package/hmr/frameworks/angular/server/linker.js.map +1 -1
  95. package/hmr/frameworks/angular/server/strategy.js +30 -6
  96. package/hmr/frameworks/angular/server/strategy.js.map +1 -1
  97. package/hmr/frameworks/typescript/server/strategy.js +8 -2
  98. package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
  99. package/hmr/frameworks/vue/client/index.js +18 -42
  100. package/hmr/frameworks/vue/client/index.js.map +1 -1
  101. package/hmr/helpers/ast-normalizer.js +22 -10
  102. package/hmr/helpers/ast-normalizer.js.map +1 -1
  103. package/hmr/helpers/cjs-named-exports.d.ts +23 -0
  104. package/hmr/helpers/cjs-named-exports.js +152 -0
  105. package/hmr/helpers/cjs-named-exports.js.map +1 -0
  106. package/hmr/server/constants.d.ts +1 -0
  107. package/hmr/server/constants.js +14 -3
  108. package/hmr/server/constants.js.map +1 -1
  109. package/hmr/server/core-sanitize.d.ts +49 -2
  110. package/hmr/server/core-sanitize.js +267 -24
  111. package/hmr/server/core-sanitize.js.map +1 -1
  112. package/hmr/server/import-map.d.ts +65 -0
  113. package/hmr/server/import-map.js +222 -0
  114. package/hmr/server/import-map.js.map +1 -0
  115. package/hmr/server/index.d.ts +2 -1
  116. package/hmr/server/index.js.map +1 -1
  117. package/hmr/server/ns-core-cjs-shape.d.ts +204 -0
  118. package/hmr/server/ns-core-cjs-shape.js +271 -0
  119. package/hmr/server/ns-core-cjs-shape.js.map +1 -0
  120. package/hmr/server/perf-instrumentation.d.ts +114 -0
  121. package/hmr/server/perf-instrumentation.js +195 -0
  122. package/hmr/server/perf-instrumentation.js.map +1 -0
  123. package/hmr/server/runtime-graph-filter.d.ts +5 -0
  124. package/hmr/server/runtime-graph-filter.js +21 -0
  125. package/hmr/server/runtime-graph-filter.js.map +1 -0
  126. package/hmr/server/shared-transform-request.d.ts +12 -0
  127. package/hmr/server/shared-transform-request.js +144 -0
  128. package/hmr/server/shared-transform-request.js.map +1 -0
  129. package/hmr/server/vite-plugin.d.ts +21 -1
  130. package/hmr/server/vite-plugin.js +461 -22
  131. package/hmr/server/vite-plugin.js.map +1 -1
  132. package/hmr/server/websocket-angular-entry.d.ts +2 -0
  133. package/hmr/server/websocket-angular-entry.js +68 -0
  134. package/hmr/server/websocket-angular-entry.js.map +1 -0
  135. package/hmr/server/websocket-angular-hot-update.d.ts +78 -0
  136. package/hmr/server/websocket-angular-hot-update.js +413 -0
  137. package/hmr/server/websocket-angular-hot-update.js.map +1 -0
  138. package/hmr/server/websocket-core-bridge.d.ts +21 -0
  139. package/hmr/server/websocket-core-bridge.js +357 -0
  140. package/hmr/server/websocket-core-bridge.js.map +1 -0
  141. package/hmr/server/websocket-graph-upsert.d.ts +21 -0
  142. package/hmr/server/websocket-graph-upsert.js +33 -0
  143. package/hmr/server/websocket-graph-upsert.js.map +1 -0
  144. package/hmr/server/websocket-hmr-pending.d.ts +43 -0
  145. package/hmr/server/websocket-hmr-pending.js +55 -0
  146. package/hmr/server/websocket-hmr-pending.js.map +1 -0
  147. package/hmr/server/websocket-module-bindings.d.ts +6 -0
  148. package/hmr/server/websocket-module-bindings.js +471 -0
  149. package/hmr/server/websocket-module-bindings.js.map +1 -0
  150. package/hmr/server/websocket-module-specifiers.d.ts +101 -0
  151. package/hmr/server/websocket-module-specifiers.js +820 -0
  152. package/hmr/server/websocket-module-specifiers.js.map +1 -0
  153. package/hmr/server/websocket-ns-m-finalize.d.ts +22 -0
  154. package/hmr/server/websocket-ns-m-finalize.js +88 -0
  155. package/hmr/server/websocket-ns-m-finalize.js.map +1 -0
  156. package/hmr/server/websocket-ns-m-paths.d.ts +3 -0
  157. package/hmr/server/websocket-ns-m-paths.js +92 -0
  158. package/hmr/server/websocket-ns-m-paths.js.map +1 -0
  159. package/hmr/server/websocket-ns-m-request.d.ts +45 -0
  160. package/hmr/server/websocket-ns-m-request.js +196 -0
  161. package/hmr/server/websocket-ns-m-request.js.map +1 -0
  162. package/hmr/server/websocket-runtime-compat.d.ts +19 -0
  163. package/hmr/server/websocket-runtime-compat.js +287 -0
  164. package/hmr/server/websocket-runtime-compat.js.map +1 -0
  165. package/hmr/server/websocket-served-module-helpers.d.ts +36 -0
  166. package/hmr/server/websocket-served-module-helpers.js +631 -0
  167. package/hmr/server/websocket-served-module-helpers.js.map +1 -0
  168. package/hmr/server/websocket-txn.d.ts +6 -0
  169. package/hmr/server/websocket-txn.js +45 -0
  170. package/hmr/server/websocket-txn.js.map +1 -0
  171. package/hmr/server/websocket-vendor-unifier.d.ts +10 -0
  172. package/hmr/server/websocket-vendor-unifier.js +51 -0
  173. package/hmr/server/websocket-vendor-unifier.js.map +1 -0
  174. package/hmr/server/websocket-vue-sfc.d.ts +27 -0
  175. package/hmr/server/websocket-vue-sfc.js +1069 -0
  176. package/hmr/server/websocket-vue-sfc.js.map +1 -0
  177. package/hmr/server/websocket.d.ts +26 -3
  178. package/hmr/server/websocket.js +2233 -796
  179. package/hmr/server/websocket.js.map +1 -1
  180. package/hmr/shared/package-classifier.d.ts +9 -0
  181. package/hmr/shared/package-classifier.js +58 -0
  182. package/hmr/shared/package-classifier.js.map +1 -0
  183. package/hmr/shared/runtime/boot-timeline.d.ts +17 -0
  184. package/hmr/shared/runtime/boot-timeline.js +51 -0
  185. package/hmr/shared/runtime/boot-timeline.js.map +1 -0
  186. package/hmr/shared/runtime/browser-runtime-contract.d.ts +64 -0
  187. package/hmr/shared/runtime/browser-runtime-contract.js +54 -0
  188. package/hmr/shared/runtime/browser-runtime-contract.js.map +1 -0
  189. package/hmr/shared/runtime/dev-overlay.d.ts +85 -0
  190. package/hmr/shared/runtime/dev-overlay.js +1236 -0
  191. package/hmr/shared/runtime/dev-overlay.js.map +1 -0
  192. package/hmr/shared/runtime/http-only-boot.d.ts +1 -0
  193. package/hmr/shared/runtime/http-only-boot.js +53 -6
  194. package/hmr/shared/runtime/http-only-boot.js.map +1 -1
  195. package/hmr/shared/runtime/module-provenance.d.ts +1 -0
  196. package/hmr/shared/runtime/module-provenance.js +63 -0
  197. package/hmr/shared/runtime/module-provenance.js.map +1 -0
  198. package/hmr/shared/runtime/platform-polyfills.d.ts +26 -0
  199. package/hmr/shared/runtime/platform-polyfills.js +122 -0
  200. package/hmr/shared/runtime/platform-polyfills.js.map +1 -0
  201. package/hmr/shared/runtime/root-placeholder.d.ts +1 -0
  202. package/hmr/shared/runtime/root-placeholder.js +552 -82
  203. package/hmr/shared/runtime/root-placeholder.js.map +1 -1
  204. package/hmr/shared/runtime/session-bootstrap.d.ts +1 -0
  205. package/hmr/shared/runtime/session-bootstrap.js +195 -0
  206. package/hmr/shared/runtime/session-bootstrap.js.map +1 -0
  207. package/hmr/shared/runtime/vendor-bootstrap.js +52 -15
  208. package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
  209. package/hmr/shared/vendor/manifest.d.ts +37 -0
  210. package/hmr/shared/vendor/manifest.js +677 -57
  211. package/hmr/shared/vendor/manifest.js.map +1 -1
  212. package/hmr/shared/vendor/registry.js +104 -7
  213. package/hmr/shared/vendor/registry.js.map +1 -1
  214. package/index.d.ts +1 -0
  215. package/index.js +5 -0
  216. package/index.js.map +1 -1
  217. package/package.json +14 -2
  218. package/runtime/core-aliases-early.js +94 -67
  219. package/runtime/core-aliases-early.js.map +1 -1
  220. package/shims/solid-jsx-runtime.d.ts +7 -0
  221. package/shims/solid-jsx-runtime.js +17 -0
  222. package/shims/solid-jsx-runtime.js.map +1 -0
@@ -1,70 +1,410 @@
1
+ import { setHmrBootStage } from './dev-overlay.js';
2
+ function isPlaceholderView(view, placeholderRoot) {
3
+ if (!view) {
4
+ return false;
5
+ }
6
+ if (placeholderRoot && view === placeholderRoot) {
7
+ return true;
8
+ }
9
+ try {
10
+ if (view.__ns_dev_placeholder) {
11
+ return true;
12
+ }
13
+ }
14
+ catch { }
15
+ return false;
16
+ }
17
+ function getCommittedRootView(application, placeholderRoot) {
18
+ try {
19
+ const root = application?.getRootView?.() || null;
20
+ if (!root) {
21
+ return null;
22
+ }
23
+ if (!isPlaceholderView(root, placeholderRoot)) {
24
+ return root;
25
+ }
26
+ const currentPage = root.currentPage || root._currentEntry?.resolvedPage || null;
27
+ if (currentPage && !isPlaceholderView(currentPage, placeholderRoot)) {
28
+ return root;
29
+ }
30
+ }
31
+ catch { }
32
+ return null;
33
+ }
34
+ function getPlaceholderWaitDiagnosticSnapshot(g, application, placeholderRoot) {
35
+ const snapshot = {
36
+ bootComplete: !!g.__NS_HMR_BOOT_COMPLETE__,
37
+ hasPlaceholderRoot: !!placeholderRoot,
38
+ hasPlaceholderFlag: !!g.__NS_DEV_PLACEHOLDER_ROOT_EARLY__,
39
+ hasAngularAppRef: !!g.__NS_ANGULAR_APP_REF__,
40
+ hasAngularReboot: typeof g.__reboot_ng_modules__ === 'function',
41
+ };
42
+ try {
43
+ snapshot.applicationType = application?.constructor?.name;
44
+ snapshot.hasLaunched = typeof application?.hasLaunched === 'function' ? !!application.hasLaunched() : undefined;
45
+ snapshot.rootViewType = application?.getRootView?.()?.constructor?.name;
46
+ }
47
+ catch { }
48
+ try {
49
+ const Frame = g.Frame;
50
+ const topmost = Frame?.topmost?.() || null;
51
+ snapshot.topmostFrameType = topmost?.constructor?.name;
52
+ snapshot.topmostPageType = topmost?.currentPage?.constructor?.name || topmost?._currentEntry?.resolvedPage?.constructor?.name;
53
+ }
54
+ catch { }
55
+ return snapshot;
56
+ }
57
+ function restoreOriginalApplicationRun(g) {
58
+ const originalRun = g['__NS_DEV_ORIGINAL_APP_RUN__'];
59
+ if (typeof originalRun !== 'function') {
60
+ return;
61
+ }
62
+ const application = g['__NS_DEV_PLACEHOLDER_APPLICATION__'] || g.Application;
63
+ try {
64
+ if (application) {
65
+ application.run = originalRun;
66
+ }
67
+ }
68
+ catch { }
69
+ try {
70
+ if (g.Application && g.Application !== application) {
71
+ g.Application.run = originalRun;
72
+ }
73
+ }
74
+ catch { }
75
+ try {
76
+ const proto = application ? Object.getPrototypeOf(application) : null;
77
+ if (proto && typeof proto.run === 'function' && proto.run !== originalRun) {
78
+ proto.run = originalRun;
79
+ }
80
+ }
81
+ catch { }
82
+ delete g['__NS_DEV_ORIGINAL_APP_RUN__'];
83
+ }
84
+ function clearPlaceholderGlobals(g) {
85
+ delete g['__NS_DEV_PLACEHOLDER_ROOT_VIEW__'];
86
+ delete g['__NS_DEV_PLACEHOLDER_ROOT_EARLY__'];
87
+ delete g['__NS_DEV_BOOT_STATUS_LABEL__'];
88
+ delete g['__NS_DEV_BOOT_ACTIVITY_INDICATOR__'];
89
+ delete g['__NS_DEV_PLACEHOLDER_LAUNCH_HANDLER__'];
90
+ delete g['__NS_DEV_PLACEHOLDER_APPLICATION__'];
91
+ const timer = g['__NS_DEV_PLACEHOLDER_RESTORE_TIMER__'];
92
+ if (timer) {
93
+ try {
94
+ clearTimeout(timer);
95
+ }
96
+ catch { }
97
+ }
98
+ delete g['__NS_DEV_PLACEHOLDER_RESTORE_TIMER__'];
99
+ }
100
+ export function tryFinalizeBootPlaceholder(reason, verbose) {
101
+ const g = globalThis;
102
+ const placeholderRoot = g['__NS_DEV_PLACEHOLDER_ROOT_VIEW__'] || null;
103
+ const hadPlaceholder = !!placeholderRoot || !!g['__NS_DEV_PLACEHOLDER_ROOT_EARLY__'] || !!g['__NS_DEV_BOOT_STATUS_LABEL__'] || !!g['__NS_DEV_BOOT_ACTIVITY_INDICATOR__'];
104
+ const application = g['__NS_DEV_PLACEHOLDER_APPLICATION__'] || g.Application;
105
+ const committedRoot = getCommittedRootView(application, placeholderRoot);
106
+ if (!committedRoot) {
107
+ return false;
108
+ }
109
+ let detachedPlaceholder = false;
110
+ if (hadPlaceholder) {
111
+ try {
112
+ const launchHandler = g['__NS_DEV_PLACEHOLDER_LAUNCH_HANDLER__'];
113
+ if (application && typeof application.off === 'function' && launchHandler) {
114
+ application.off(application.launchEvent, launchHandler);
115
+ }
116
+ }
117
+ catch { }
118
+ restoreOriginalApplicationRun(g);
119
+ clearPlaceholderGlobals(g);
120
+ detachedPlaceholder = true;
121
+ }
122
+ try {
123
+ g.__NS_HMR_BOOT_COMPLETE__ = true;
124
+ }
125
+ catch { }
126
+ if (detachedPlaceholder) {
127
+ setHmrBootStage('app-root-committed', {
128
+ detail: 'The real app root replaced the boot placeholder.',
129
+ });
130
+ }
131
+ if (verbose) {
132
+ console.info('[ns-placeholder] real app root committed', {
133
+ reason,
134
+ rootType: committedRoot?.constructor?.name || typeof committedRoot,
135
+ detachedPlaceholder,
136
+ });
137
+ }
138
+ return true;
139
+ }
140
+ function scheduleBootPlaceholderFinalize(reason, verbose) {
141
+ const g = globalThis;
142
+ if (g['__NS_DEV_PLACEHOLDER_RESTORE_TIMER__']) {
143
+ return;
144
+ }
145
+ const startedAt = Date.now();
146
+ const maxWaitMs = 20000;
147
+ let attempts = 0;
148
+ const tick = () => {
149
+ delete g['__NS_DEV_PLACEHOLDER_RESTORE_TIMER__'];
150
+ if (tryFinalizeBootPlaceholder(reason, verbose)) {
151
+ return;
152
+ }
153
+ attempts += 1;
154
+ if (Date.now() - startedAt >= maxWaitMs) {
155
+ if (verbose) {
156
+ console.info('[ns-placeholder] waiting for real root commit timed out', {
157
+ reason,
158
+ attempts,
159
+ waitMs: Date.now() - startedAt,
160
+ state: getPlaceholderWaitDiagnosticSnapshot(g, g['__NS_DEV_PLACEHOLDER_APPLICATION__'] || g.Application, g['__NS_DEV_PLACEHOLDER_ROOT_VIEW__'] || null),
161
+ });
162
+ }
163
+ return;
164
+ }
165
+ g['__NS_DEV_PLACEHOLDER_RESTORE_TIMER__'] = setTimeout(tick, attempts === 1 ? 0 : 100);
166
+ };
167
+ tick();
168
+ }
1
169
  // Root placeholder installer used during dev HMR until HTTP ESM loads.
170
+ //
171
+ // Architecture:
172
+ // 1. Install a launchEvent handler that provides a placeholder Frame/Page
173
+ // 2. Call Application.run() to start the iOS lifecycle (required or app terminates)
174
+ // 3. Inside the handler (after root is set), patch Application.run so subsequent
175
+ // calls (from the real app module) become Application.resetRootView()
176
+ //
177
+ // This means the app's entry (e.g., index.ts) can call Application.run({ create })
178
+ // exactly as it would in production — the patch intercepts it and does a clean
179
+ // root replacement instead of fighting the already-running lifecycle.
2
180
  export function installRootPlaceholder(verbose) {
3
181
  const g = globalThis;
4
182
  if (g['__NS_DEV_PLACEHOLDER_ROOT_EARLY__'])
5
183
  return;
6
184
  g['__NS_DEV_PLACEHOLDER_ROOT_EARLY__'] = true;
185
+ g['__NS_DEV_RESTORE_PLACEHOLDER__'] = (reason) => {
186
+ if (!tryFinalizeBootPlaceholder(reason, verbose)) {
187
+ scheduleBootPlaceholderFinalize(reason, verbose);
188
+ }
189
+ };
7
190
  try {
191
+ const resolveModule = (moduleIds) => {
192
+ for (const moduleId of moduleIds) {
193
+ try {
194
+ if (typeof g.moduleExists === 'function' && g.moduleExists(moduleId) && typeof g.loadModule === 'function') {
195
+ const mod = g.loadModule(moduleId);
196
+ if (mod)
197
+ return { value: (mod.default ?? mod) || mod, via: 'loadModule', moduleId };
198
+ }
199
+ }
200
+ catch { }
201
+ try {
202
+ const reg = g.__nsVendorRegistry;
203
+ if (reg?.has?.(moduleId)) {
204
+ const mod = reg.get(moduleId);
205
+ if (mod)
206
+ return { value: (mod.default ?? mod) || mod, via: '__nsVendorRegistry', moduleId };
207
+ }
208
+ }
209
+ catch { }
210
+ try {
211
+ const req = g.__nsVendorRequire || g.__nsRequire || g.require;
212
+ if (typeof req === 'function') {
213
+ const mod = req(moduleId);
214
+ if (mod)
215
+ return { value: (mod.default ?? mod) || mod, via: 'require', moduleId };
216
+ }
217
+ }
218
+ catch { }
219
+ try {
220
+ const nr = g.__nativeRequire;
221
+ if (typeof nr === 'function') {
222
+ const mod = nr(moduleId, '/');
223
+ if (mod)
224
+ return { value: (mod.default ?? mod) || mod, via: '__nativeRequire', moduleId };
225
+ }
226
+ }
227
+ catch { }
228
+ }
229
+ return undefined;
230
+ };
8
231
  const getCore = (name) => {
9
- try {
10
- const reg = g.__nsVendorRegistry;
11
- const req = reg?.get ? g.__nsVendorRequire || g.__nsRequire || g.require : g.__nsRequire || g.require;
12
- let mod = null;
13
- if (reg && reg.has('@nativescript/core'))
14
- mod = reg.get('@nativescript/core');
15
- else if (typeof req === 'function') {
16
- try {
17
- mod = req('@nativescript/core');
232
+ if (name === 'Application' && g.Application && (typeof g.Application.run === 'function' || typeof g.Application.on === 'function' || typeof g.Application.resetRootView === 'function')) {
233
+ return { value: g.Application, source: 'globalThis.Application' };
234
+ }
235
+ const pickApplicationApi = (candidate, source) => {
236
+ if (!candidate)
237
+ return null;
238
+ const candidates = [
239
+ { value: candidate, source },
240
+ { value: candidate.Application, source: `${source}#Application` },
241
+ { value: candidate.app, source: `${source}#app` },
242
+ { value: candidate.application, source: `${source}#application` },
243
+ ];
244
+ for (const entry of candidates) {
245
+ if (entry.value && (typeof entry.value.run === 'function' || typeof entry.value.on === 'function' || typeof entry.value.resetRootView === 'function')) {
246
+ return entry;
18
247
  }
19
- catch { }
20
248
  }
21
- const ns = (mod && (mod.default ?? mod)) || mod;
22
- if (name === 'Application' && ns && (ns.Application || ns))
23
- return ns.Application || ns;
24
- if (ns && ns[name])
25
- return ns[name];
249
+ return null;
250
+ };
251
+ if (name === 'Application') {
252
+ const applicationModule = resolveModule(['@nativescript/core/application']);
253
+ const pickedFromAppModule = pickApplicationApi(applicationModule?.value, applicationModule ? `${applicationModule.via}:${applicationModule.moduleId}` : '@nativescript/core/application');
254
+ if (pickedFromAppModule)
255
+ return pickedFromAppModule;
26
256
  }
27
- catch { }
28
- try {
29
- const nr = g.__nativeRequire;
30
- if (typeof nr === 'function') {
31
- try {
32
- const mod = nr('@nativescript/core', '/');
33
- const ns = (mod && (mod.default ?? mod)) || mod;
34
- if (name === 'Application' && ns && (ns.Application || ns))
35
- return ns.Application || ns;
36
- if (ns && ns[name])
37
- return ns[name];
257
+ const primary = resolveModule(['@nativescript/core']);
258
+ if (name === 'Application' && primary?.value) {
259
+ const pickedFromPrimary = pickApplicationApi(primary.value, `${primary.via}:${primary.moduleId}`);
260
+ if (pickedFromPrimary)
261
+ return pickedFromPrimary;
262
+ }
263
+ if (primary?.value && primary.value[name])
264
+ return { value: primary.value[name], source: `${primary.via}:${primary.moduleId}` };
265
+ const ui = resolveModule(['@nativescript/core/ui']);
266
+ if (ui?.value && ui.value[name])
267
+ return { value: ui.value[name], source: `${ui.via}:${ui.moduleId}` };
268
+ return { value: undefined, source: 'unresolved' };
269
+ };
270
+ const applicationResolved = getCore('Application');
271
+ const frameResolved = getCore('Frame');
272
+ const pageResolved = getCore('Page');
273
+ const labelResolved = getCore('Label');
274
+ const activityResolved = getCore('ActivityIndicator');
275
+ const Application = applicationResolved.value;
276
+ const Frame = frameResolved.value;
277
+ const Page = pageResolved.value;
278
+ const Label = labelResolved.value;
279
+ const ActivityIndicator = activityResolved.value;
280
+ if (!Application) {
281
+ if (verbose) {
282
+ console.warn('[ns-placeholder] Application unavailable', {
283
+ resolution: {
284
+ Application: applicationResolved.source,
285
+ Frame: frameResolved.source,
286
+ Page: pageResolved.source,
287
+ Label: labelResolved.source,
288
+ },
289
+ moduleApis: {
290
+ moduleExists: typeof g.moduleExists === 'function',
291
+ loadModule: typeof g.loadModule === 'function',
292
+ uiModuleRegistered: typeof g.moduleExists === 'function' ? !!g.moduleExists('@nativescript/core/ui') : false,
293
+ },
294
+ });
295
+ }
296
+ return;
297
+ }
298
+ g['__NS_DEV_PLACEHOLDER_APPLICATION__'] = Application;
299
+ const isAndroid = !!(g.__ANDROID__ || typeof g.android !== 'undefined');
300
+ if (!isAndroid && typeof Application.resetRootView === 'function' && !g['__NS_DEV_PATCHED_RESET_ROOT_VIEW__']) {
301
+ const __ns_dev_original_reset_root_view = Application.resetRootView.bind(Application);
302
+ const __ns_dev_patched_reset_root_view = function __ns_dev_patched_reset_root_view(entry) {
303
+ const result = __ns_dev_original_reset_root_view(entry);
304
+ try {
305
+ const restore = g['__NS_DEV_RESTORE_PLACEHOLDER__'];
306
+ if (typeof restore === 'function') {
307
+ restore('Application.resetRootView');
38
308
  }
39
- catch { }
309
+ }
310
+ catch { }
311
+ return result;
312
+ };
313
+ Application.resetRootView = __ns_dev_patched_reset_root_view;
314
+ try {
315
+ if (g.Application && g.Application !== Application) {
316
+ g.Application.resetRootView = __ns_dev_patched_reset_root_view;
40
317
  }
41
318
  }
42
319
  catch { }
43
- return undefined;
44
- };
45
- const Application = getCore('Application');
46
- const Frame = getCore('Frame');
47
- const Page = getCore('Page');
48
- const Label = getCore('Label');
49
- if (!Application || !Frame || !Page || !Label) {
50
320
  try {
51
- console.warn('[ns-entry] (early) core classes unavailable for placeholder');
321
+ const proto = Object.getPrototypeOf(Application);
322
+ if (proto && typeof proto.resetRootView === 'function' && proto.resetRootView !== __ns_dev_patched_reset_root_view) {
323
+ proto.resetRootView = __ns_dev_patched_reset_root_view;
324
+ }
52
325
  }
53
326
  catch { }
327
+ g['__NS_DEV_PATCHED_RESET_ROOT_VIEW__'] = true;
328
+ }
329
+ const canCreatePlaceholderRoot = !!Frame && !!Page && !!Label;
330
+ if (!canCreatePlaceholderRoot && verbose) {
331
+ console.warn('[ns-placeholder] visual placeholder unavailable; starting lifecycle without placeholder root', {
332
+ resolution: {
333
+ Application: applicationResolved.source,
334
+ Frame: frameResolved.source,
335
+ Page: pageResolved.source,
336
+ Label: labelResolved.source,
337
+ ActivityIndicator: activityResolved.source,
338
+ },
339
+ moduleApis: {
340
+ moduleExists: typeof g.moduleExists === 'function',
341
+ loadModule: typeof g.loadModule === 'function',
342
+ uiModuleRegistered: typeof g.moduleExists === 'function' ? !!g.moduleExists('@nativescript/core/ui') : false,
343
+ },
344
+ });
54
345
  }
346
+ let handlerFired = false;
347
+ // launchEvent handler: provides a placeholder root, then patches Application.run
55
348
  const __ns_launch_handler = (args) => {
349
+ if (verbose) {
350
+ console.info('[ns-placeholder] launch handler fired', {
351
+ hasArgs: !!args,
352
+ hasExistingRoot: !!args?.root,
353
+ hasLaunched: typeof Application.hasLaunched === 'function' ? !!Application.hasLaunched() : undefined,
354
+ started: !!Application.started,
355
+ });
356
+ }
56
357
  try {
57
358
  const prev = args?.root;
58
- if (verbose)
59
- console.info('[ns-entry] (early) launchEvent fired; existing root:', !!prev);
60
- if (!prev && Frame && Page && Label) {
359
+ if (!prev && canCreatePlaceholderRoot && Frame && Page && Label) {
360
+ const StackLayout = getCore('StackLayout').value;
61
361
  const page = new Page();
62
362
  page.actionBarHidden = true;
63
- const label = new Label();
64
- label.text = 'Starting NativeScript + Vite dev server…';
65
- label.textAlignment = 'center';
66
- label.padding = 12;
67
- page.content = label;
363
+ const titleLabel = new Label();
364
+ titleLabel.text = 'NativeScript Vite preparing dev session...';
365
+ titleLabel.textAlignment = 'center';
366
+ titleLabel.textWrap = true;
367
+ titleLabel.fontSize = 20;
368
+ const statusLabel = new Label();
369
+ statusLabel.text = 'Preparing the HTTP HMR bootstrap (4%)';
370
+ statusLabel.textAlignment = 'center';
371
+ statusLabel.textWrap = true;
372
+ statusLabel.fontSize = 14;
373
+ statusLabel.marginTop = 12;
374
+ const activityIndicator = ActivityIndicator
375
+ ? (() => {
376
+ const indicator = new ActivityIndicator();
377
+ indicator.busy = true;
378
+ indicator.marginTop = 16;
379
+ indicator.width = 28;
380
+ indicator.height = 28;
381
+ indicator.horizontalAlignment = 'center';
382
+ return indicator;
383
+ })()
384
+ : null;
385
+ if (StackLayout) {
386
+ const root = new StackLayout();
387
+ root.padding = 24;
388
+ root.verticalAlignment = 'middle';
389
+ root.horizontalAlignment = 'center';
390
+ root.addChild(titleLabel);
391
+ root.addChild(statusLabel);
392
+ if (activityIndicator) {
393
+ root.addChild(activityIndicator);
394
+ }
395
+ page.content = root;
396
+ }
397
+ else {
398
+ // Fallback: just show the title label centered
399
+ titleLabel.verticalAlignment = 'middle';
400
+ titleLabel.horizontalAlignment = 'center';
401
+ titleLabel.width = 280;
402
+ titleLabel.padding = 12;
403
+ page.content = titleLabel;
404
+ }
405
+ // Store refs so the overlay API can update the status label
406
+ g['__NS_DEV_BOOT_STATUS_LABEL__'] = statusLabel;
407
+ g['__NS_DEV_BOOT_ACTIVITY_INDICATOR__'] = activityIndicator;
68
408
  const frame = new Frame();
69
409
  frame.navigate({ create: () => page, clearHistory: true, animated: false });
70
410
  try {
@@ -73,70 +413,200 @@ export function installRootPlaceholder(verbose) {
73
413
  g['__NS_DEV_PLACEHOLDER_ROOT_VIEW__'] = frame;
74
414
  }
75
415
  catch { }
416
+ if (verbose) {
417
+ console.info('[ns-placeholder] assigned placeholder root', {
418
+ frameType: frame?.constructor?.name,
419
+ pageType: page?.constructor?.name,
420
+ hasStackLayout: !!StackLayout,
421
+ hasActivityIndicator: !!activityIndicator,
422
+ });
423
+ }
76
424
  if (args)
77
425
  args.root = frame;
78
- if (verbose)
79
- console.info('[ns-entry] (early) temporary root provided via launch args');
80
426
  }
81
427
  }
82
428
  catch (e) {
429
+ console.error('[ns-placeholder] root error', e);
430
+ }
431
+ if (!handlerFired) {
432
+ handlerFired = true;
433
+ // Patch Application.run() → resetRootView() for subsequent calls.
434
+ // The app lifecycle is now running — a second run() is undefined
435
+ // behavior, but resetRootView() is the documented API for
436
+ // replacing the root of a running app.
437
+ //
438
+ // Patch on ALL possible references. The vendor-registry Application,
439
+ // globalThis.Application, and the prototype may be different objects.
83
440
  try {
84
- console.error('[ns-entry] (early) temp root error', e);
441
+ if (Application && typeof Application.run === 'function') {
442
+ const _originalRun = Application.run.bind(Application);
443
+ g['__NS_DEV_ORIGINAL_APP_RUN__'] = _originalRun;
444
+ const __ns_dev_patched_run = function __ns_dev_patched_run(entry) {
445
+ try {
446
+ // Detach the launch handler, but keep placeholder refs until the
447
+ // real app root is actually committed.
448
+ try {
449
+ if (Application && Application.off) {
450
+ Application.off(Application.launchEvent, __ns_launch_handler);
451
+ }
452
+ }
453
+ catch { }
454
+ // When entry is undefined/null, the calling framework (e.g. Angular)
455
+ // manages root views itself via launch events and resetRootView().
456
+ // Don't attempt resetRootView(undefined) which throws "Main entry is missing".
457
+ if (!entry) {
458
+ if (verbose)
459
+ console.info('[ns-placeholder] patched run() called with no entry; framework manages root view');
460
+ return;
461
+ }
462
+ const isModuleNameEntry = entry && entry.moduleName && !entry.create;
463
+ if (isModuleNameEntry) {
464
+ if (typeof Application.resetRootView === 'function') {
465
+ Application.resetRootView(entry);
466
+ }
467
+ }
468
+ else {
469
+ // Framework path: two-phase boot with dominative document
470
+ Application._rootView = null;
471
+ try {
472
+ const domModule = g.__nsVendorRegistry?.get?.('dominative') ||
473
+ (typeof require === 'function'
474
+ ? (() => {
475
+ try {
476
+ return require('dominative');
477
+ }
478
+ catch {
479
+ return null;
480
+ }
481
+ })()
482
+ : null);
483
+ const doc = domModule?.document;
484
+ if (doc && typeof Application.resetRootView === 'function') {
485
+ Application.resetRootView({ create: () => doc });
486
+ if (entry && typeof entry.create === 'function') {
487
+ entry.create();
488
+ }
489
+ }
490
+ else {
491
+ if (typeof Application.resetRootView === 'function') {
492
+ Application.resetRootView(entry);
493
+ }
494
+ }
495
+ }
496
+ catch (e2) {
497
+ if (verbose)
498
+ console.warn('[ns-placeholder] two-phase boot failed:', e2?.message || e2);
499
+ try {
500
+ if (typeof Application.resetRootView === 'function') {
501
+ Application.resetRootView(entry);
502
+ }
503
+ }
504
+ catch { }
505
+ }
506
+ }
507
+ }
508
+ catch (e) {
509
+ console.warn('[ns-placeholder] patched run() error:', e);
510
+ }
511
+ };
512
+ Application.run = __ns_dev_patched_run;
513
+ if (verbose) {
514
+ console.info('[ns-placeholder] patched Application.run');
515
+ }
516
+ if (g.Application && g.Application !== Application) {
517
+ g.Application.run = __ns_dev_patched_run;
518
+ }
519
+ try {
520
+ const proto = Object.getPrototypeOf(Application);
521
+ if (proto && typeof proto.run === 'function' && proto.run !== __ns_dev_patched_run) {
522
+ proto.run = __ns_dev_patched_run;
523
+ }
524
+ }
525
+ catch { }
526
+ }
85
527
  }
86
528
  catch { }
87
529
  }
88
530
  };
531
+ g['__NS_DEV_PLACEHOLDER_LAUNCH_HANDLER__'] = __ns_launch_handler;
89
532
  try {
90
- g['__NS_DEV_LAUNCH_HANDLER__'] = __ns_launch_handler;
91
- }
92
- catch { }
93
- try {
94
- if (!g['__NS_DEV_LAUNCH_ATTACHED__'] && Application && Application.on) {
533
+ if (Application && Application.on) {
95
534
  Application.on(Application.launchEvent, __ns_launch_handler);
96
- g['__NS_DEV_LAUNCH_ATTACHED__'] = true;
97
535
  }
98
536
  }
99
537
  catch { }
538
+ // Determine boot path
100
539
  try {
101
- g['__NS_DEV_RESTORE_PLACEHOLDER__'] = () => {
102
- try {
103
- if (g['__NS_DEV_LAUNCH_HANDLER__'] && Application && Application.off) {
104
- Application.off(Application.launchEvent, g['__NS_DEV_LAUNCH_HANDLER__']);
105
- }
106
- }
107
- catch { }
108
- // Clear flags and drop any retained placeholder Frame reference
109
- try {
110
- delete g['__NS_DEV_PLACEHOLDER_ROOT_EARLY__'];
540
+ const appAny = Application;
541
+ const methodState = {
542
+ hasRun: typeof appAny?.run === 'function',
543
+ hasOn: typeof appAny?.on === 'function',
544
+ hasOff: typeof appAny?.off === 'function',
545
+ hasHasLaunched: typeof appAny?.hasLaunched === 'function',
546
+ hasGetRootView: typeof appAny?.getRootView === 'function',
547
+ hasResetRootView: typeof appAny?.resetRootView === 'function',
548
+ hasRunAsMainApp: typeof appAny?.runAsMainApp === 'function',
549
+ type: appAny?.constructor?.name,
550
+ };
551
+ if (verbose) {
552
+ console.info('[ns-placeholder] application methods', methodState);
553
+ console.info('[ns-placeholder] application source', applicationResolved.source);
554
+ }
555
+ if (!appAny || typeof appAny.run !== 'function') {
556
+ console.warn('[ns-placeholder] Application.run unavailable', {
557
+ ...methodState,
558
+ source: applicationResolved.source,
559
+ });
560
+ return;
561
+ }
562
+ const hasLaunched = typeof appAny.hasLaunched === 'function' ? !!appAny.hasLaunched() : false;
563
+ const hasRootView = typeof appAny.getRootView === 'function' ? !!appAny.getRootView() : false;
564
+ const started = !!appAny.started;
565
+ const nativeApp = appAny.nativeApp;
566
+ const iosNativeApp = appAny.ios?.nativeApp;
567
+ const canRunAsMainApp = typeof appAny.runAsMainApp === 'function';
568
+ if (verbose) {
569
+ console.info('[ns-placeholder] boot state', {
570
+ hasLaunched,
571
+ hasRootView,
572
+ started,
573
+ nativeApp: !!nativeApp,
574
+ iosNativeApp: !!iosNativeApp,
575
+ canRunAsMainApp,
576
+ hasResetRootView: typeof appAny.resetRootView === 'function',
577
+ });
578
+ }
579
+ if (hasLaunched || hasRootView) {
580
+ // App lifecycle is already active. Skip starting it again and only install
581
+ // the placeholder root/patching behavior for the existing instance.
582
+ if (verbose) {
583
+ console.info('[ns-placeholder] boot branch: existing lifecycle');
111
584
  }
112
- catch { }
113
585
  try {
114
- delete g['__NS_DEV_LAUNCH_ATTACHED__'];
586
+ __ns_launch_handler();
115
587
  }
116
588
  catch { }
117
- try {
118
- const fr = g['__NS_DEV_PLACEHOLDER_ROOT_VIEW__'];
119
- if (fr && typeof fr._removeFromSuperview === 'function') {
120
- try {
121
- fr._removeFromSuperview();
122
- }
123
- catch { }
124
- }
589
+ }
590
+ else if (canRunAsMainApp) {
591
+ if (verbose) {
592
+ console.info('[ns-placeholder] boot branch: runAsMainApp');
125
593
  }
126
- catch { }
127
- try {
128
- delete g['__NS_DEV_PLACEHOLDER_ROOT_VIEW__'];
594
+ appAny.started = true;
595
+ appAny.runAsMainApp();
596
+ }
597
+ else {
598
+ if (verbose) {
599
+ console.info('[ns-placeholder] boot branch: Application.run');
129
600
  }
130
- catch { }
131
- };
601
+ appAny.run();
602
+ }
603
+ }
604
+ catch (e) {
605
+ console.warn('[ns-placeholder] boot error', e);
132
606
  }
133
- catch { }
134
607
  }
135
608
  catch (e) {
136
- try {
137
- console.error('[ns-entry] (early) failed to install launchEvent handler', e);
138
- }
139
- catch { }
609
+ console.error('[ns-placeholder] install failed', e);
140
610
  }
141
611
  }
142
612
  //# sourceMappingURL=root-placeholder.js.map