@akylas/nativescript 9.0.25 → 9.1.5

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 (633) hide show
  1. package/abortcontroller/abortsignal.js.map +1 -1
  2. package/abortcontroller/index.js.map +1 -1
  3. package/accessibility/accessibility-common.js.map +1 -1
  4. package/accessibility/accessibility-css-helper.js.map +1 -1
  5. package/accessibility/accessibility-properties.js.map +1 -1
  6. package/accessibility/accessibility-service-common.js.map +1 -1
  7. package/accessibility/accessibility-service.android.js.map +1 -1
  8. package/accessibility/accessibility-service.ios.js.map +1 -1
  9. package/accessibility/accessibility-types.js.map +1 -1
  10. package/accessibility/font-scale-common.js.map +1 -1
  11. package/accessibility/font-scale.android.js.map +1 -1
  12. package/accessibility/font-scale.ios.js.map +1 -1
  13. package/accessibility/index.android.js.map +1 -1
  14. package/accessibility/index.ios.js.map +1 -1
  15. package/animation-frame/animation-native.android.js.map +1 -1
  16. package/animation-frame/animation-native.ios.js.map +1 -1
  17. package/animation-frame/index.js.map +1 -1
  18. package/application/application-common.d.ts +205 -3
  19. package/application/application-common.js +438 -55
  20. package/application/application-common.js.map +1 -1
  21. package/application/application-interfaces.d.ts +67 -1
  22. package/application/application-interfaces.js.map +1 -1
  23. package/application/application-shims.js.map +1 -1
  24. package/application/application.android.d.ts +39 -0
  25. package/application/application.android.js +239 -18
  26. package/application/application.android.js.map +1 -1
  27. package/application/application.d.ts +161 -54
  28. package/application/application.ios.d.ts +189 -28
  29. package/application/application.ios.js +892 -390
  30. package/application/application.ios.js.map +1 -1
  31. package/application/helpers-common.d.ts +7 -0
  32. package/application/helpers-common.js +46 -1
  33. package/application/helpers-common.js.map +1 -1
  34. package/application/helpers.android.js.map +1 -1
  35. package/application/helpers.ios.js.map +1 -1
  36. package/application/index.android.js.map +1 -1
  37. package/application/index.ios.js.map +1 -1
  38. package/application/scene-delegate-bridge.d.ts +60 -0
  39. package/application/scene-delegate-bridge.js +138 -0
  40. package/application/scene-delegate-bridge.js.map +1 -0
  41. package/application-settings/application-settings-common.js.map +1 -1
  42. package/application-settings/index.android.js.map +1 -1
  43. package/application-settings/index.ios.js.map +1 -1
  44. package/bundle-entry-points.js.map +1 -1
  45. package/cli-hooks/before-checkForChanges.mjs +0 -11
  46. package/color/color-common.js +16 -5
  47. package/color/color-common.js.map +1 -1
  48. package/color/color-types.js.map +1 -1
  49. package/color/color-utils.d.ts +4 -1
  50. package/color/color-utils.js +14 -9
  51. package/color/color-utils.js.map +1 -1
  52. package/color/index.android.js.map +1 -1
  53. package/color/index.ios.js.map +1 -1
  54. package/color/known-colors.js.map +1 -1
  55. package/config/config.interface.d.ts +45 -3
  56. package/config/config.interface.js.map +1 -1
  57. package/config/index.js.map +1 -1
  58. package/connectivity/index.android.js.map +1 -1
  59. package/connectivity/index.ios.js.map +1 -1
  60. package/console/index.js.map +1 -1
  61. package/core-types/animation-types.js.map +1 -1
  62. package/core-types/index.d.ts +25 -2
  63. package/core-types/index.js +23 -0
  64. package/core-types/index.js.map +1 -1
  65. package/core-types/validators.js.map +1 -1
  66. package/css/CSS3Parser.js +3 -2
  67. package/css/CSS3Parser.js.map +1 -1
  68. package/css/CSSNativeScript.js.map +1 -1
  69. package/css/css-tree-parser.js +5 -1
  70. package/css/css-tree-parser.js.map +1 -1
  71. package/css/lib/parse/index.js +5 -1
  72. package/css/lib/parse/index.js.map +1 -1
  73. package/css/parser.js +20 -3
  74. package/css/parser.js.map +1 -1
  75. package/css/reworkcss.js.map +1 -1
  76. package/css/system-classes.d.ts +9 -0
  77. package/css/system-classes.js +23 -0
  78. package/css/system-classes.js.map +1 -1
  79. package/css-mediaquery/index.d.ts +6 -1
  80. package/css-mediaquery/index.js +35 -6
  81. package/css-mediaquery/index.js.map +1 -1
  82. package/css-value/reworkcss-value.js.map +1 -1
  83. package/data/observable/index.d.ts +23 -0
  84. package/data/observable/index.js +50 -9
  85. package/data/observable/index.js.map +1 -1
  86. package/data/observable-array/index.js.map +1 -1
  87. package/data/virtual-array/index.js.map +1 -1
  88. package/debugger/InspectorBackendCommands.js.map +1 -1
  89. package/debugger/devtools-elements-interfaces.js.map +1 -1
  90. package/debugger/devtools-elements.common.js.map +1 -1
  91. package/debugger/devtools-elements.js.map +1 -1
  92. package/debugger/dom-types.js +31 -1
  93. package/debugger/dom-types.js.map +1 -1
  94. package/debugger/index.js.map +1 -1
  95. package/debugger/webinspector-css.js.map +1 -1
  96. package/debugger/webinspector-dom.js.map +1 -1
  97. package/debugger/webinspector-network.android.js.map +1 -1
  98. package/debugger/webinspector-network.d.ts +29 -0
  99. package/debugger/webinspector-network.ios.js.map +1 -1
  100. package/fetch/index.d.ts +79 -0
  101. package/fetch/index.js +408 -0
  102. package/fetch/index.js.map +1 -0
  103. package/file-system/file-system-access.android.d.ts +1 -0
  104. package/file-system/file-system-access.android.js +18 -21
  105. package/file-system/file-system-access.android.js.map +1 -1
  106. package/file-system/file-system-access.ios.js +21 -13
  107. package/file-system/file-system-access.ios.js.map +1 -1
  108. package/file-system/index.d.ts +3 -3
  109. package/file-system/index.js.map +1 -1
  110. package/fps-meter/fps-native.android.js.map +1 -1
  111. package/fps-meter/fps-native.ios.js.map +1 -1
  112. package/fps-meter/index.js.map +1 -1
  113. package/global-types.d.ts +40 -34
  114. package/globals/global-utils.d.ts +6 -1
  115. package/globals/global-utils.js +10 -5
  116. package/globals/global-utils.js.map +1 -1
  117. package/globals/index.js +22 -9
  118. package/globals/index.js.map +1 -1
  119. package/globals/polyfills/polyfill-xhr.js.map +1 -1
  120. package/globals/polyfills/utils.js +2 -0
  121. package/globals/polyfills/utils.js.map +1 -1
  122. package/http/http-interfaces.js.map +1 -1
  123. package/http/http-request/http-request-common.js.map +1 -1
  124. package/http/http-request/index.android.js +5 -1
  125. package/http/http-request/index.android.js.map +1 -1
  126. package/http/http-request/index.ios.js.map +1 -1
  127. package/http/http-request-internal/http-request-internal-common.d.ts +6 -1
  128. package/http/http-request-internal/http-request-internal-common.js +19 -0
  129. package/http/http-request-internal/http-request-internal-common.js.map +1 -1
  130. package/http/http-request-internal/index.android.d.ts +7 -1
  131. package/http/http-request-internal/index.android.js +8 -6
  132. package/http/http-request-internal/index.android.js.map +1 -1
  133. package/http/http-request-internal/index.ios.d.ts +7 -1
  134. package/http/http-request-internal/index.ios.js +34 -17
  135. package/http/http-request-internal/index.ios.js.map +1 -1
  136. package/http/index.js.map +1 -1
  137. package/image-asset/image-asset-common.js.map +1 -1
  138. package/image-asset/index.android.js.map +1 -1
  139. package/image-asset/index.ios.js.map +1 -1
  140. package/image-source/image-source-common.js.map +1 -1
  141. package/image-source/index.android.js.map +1 -1
  142. package/image-source/index.ios.js +7 -6
  143. package/image-source/index.ios.js.map +1 -1
  144. package/index.d.ts +3 -1
  145. package/index.js +1 -0
  146. package/index.js.map +1 -1
  147. package/inspector_modules.js +1 -1
  148. package/inspector_modules.js.map +1 -1
  149. package/js-libs/easysax/easysax.d.ts +49 -7
  150. package/js-libs/easysax/easysax.js +631 -747
  151. package/js-libs/easysax/easysax.js.map +1 -0
  152. package/matrix/index.js.map +1 -1
  153. package/media-query-list/index.js +57 -15
  154. package/media-query-list/index.js.map +1 -1
  155. package/module-name-resolver/helpers.d.ts +1 -1
  156. package/module-name-resolver/helpers.js.map +1 -1
  157. package/module-name-resolver/index.d.ts +2 -2
  158. package/module-name-resolver/index.js.map +1 -1
  159. package/module-name-resolver/non-bundle-workflow-compat.js.map +1 -1
  160. package/module-name-resolver/qualifier-matcher/index.js.map +1 -1
  161. package/native-window/index.d.ts +426 -0
  162. package/native-window/index.js +4 -0
  163. package/native-window/index.js.map +1 -0
  164. package/native-window/native-window-common.d.ts +153 -0
  165. package/native-window/native-window-common.js +340 -0
  166. package/native-window/native-window-common.js.map +1 -0
  167. package/native-window/native-window-interfaces.d.ts +186 -0
  168. package/native-window/native-window-interfaces.js +90 -0
  169. package/native-window/native-window-interfaces.js.map +1 -0
  170. package/native-window/native-window.android.d.ts +59 -0
  171. package/native-window/native-window.android.js +175 -0
  172. package/native-window/native-window.android.js.map +1 -0
  173. package/native-window/native-window.ios.d.ts +61 -0
  174. package/native-window/native-window.ios.js +218 -0
  175. package/native-window/native-window.ios.js.map +1 -0
  176. package/native-window/window-base.d.ts +111 -0
  177. package/native-window/window-base.js +91 -0
  178. package/native-window/window-base.js.map +1 -0
  179. package/package.json +3 -3
  180. package/platform/common.js.map +1 -1
  181. package/platform/device/index.android.js.map +1 -1
  182. package/platform/device/index.ios.js.map +1 -1
  183. package/platform/index.js.map +1 -1
  184. package/platform/screen/index.android.js.map +1 -1
  185. package/platform/screen/index.ios.d.ts +1 -0
  186. package/platform/screen/index.ios.js +6 -2
  187. package/platform/screen/index.ios.js.map +1 -1
  188. package/platforms/android/java/org/nativescript/widgets/BorderDrawable.java +5 -6
  189. package/platforms/android/java/org/nativescript/widgets/BoxShadowDrawable.java +0 -6
  190. package/platforms/android/java/org/nativescript/widgets/CommonLayoutParams.java +56 -0
  191. package/platforms/android/java/org/nativescript/widgets/ContentLayout.java +20 -4
  192. package/platforms/android/java/org/nativescript/widgets/CustomTransition.java +26 -9
  193. package/platforms/android/java/org/nativescript/widgets/FlexLine.java +3 -3
  194. package/platforms/android/java/org/nativescript/widgets/FlexboxLayout.java +194 -731
  195. package/platforms/android/java/org/nativescript/widgets/ImageView.java +2 -2
  196. package/platforms/android/java/org/nativescript/widgets/Utils.java +37 -9
  197. package/platforms/android/java/org/nativescript/widgets/ViewHelper.java +78 -0
  198. package/platforms/android/java/org/nativescript/widgets/image/BitmapOwner.java +1 -4
  199. package/platforms/android/java/org/nativescript/widgets/image/Worker.java +99 -76
  200. package/platforms/android/native-api-usage.json +11 -0
  201. package/platforms/ios/src/NativeScriptMainWindow.swift +72 -39
  202. package/profiling/index.js.map +1 -1
  203. package/references.d.ts +5 -2
  204. package/text/formatted-string.js.map +1 -1
  205. package/text/index.android.js.map +1 -1
  206. package/text/index.ios.js.map +1 -1
  207. package/text/span.js.map +1 -1
  208. package/text/text-common.js +1 -1
  209. package/text/text-common.js.map +1 -1
  210. package/timer/index.android.js +2 -1
  211. package/timer/index.android.js.map +1 -1
  212. package/timer/index.ios.js.map +1 -1
  213. package/trace/index.d.ts +2 -2
  214. package/trace/index.js.map +1 -1
  215. package/ui/action-bar/action-bar-common.js.map +1 -1
  216. package/ui/action-bar/index.android.js +7 -11
  217. package/ui/action-bar/index.android.js.map +1 -1
  218. package/ui/action-bar/index.d.ts +13 -1
  219. package/ui/action-bar/index.ios.js +26 -0
  220. package/ui/action-bar/index.ios.js.map +1 -1
  221. package/ui/activity-indicator/activity-indicator-common.js.map +1 -1
  222. package/ui/activity-indicator/index.android.js.map +1 -1
  223. package/ui/activity-indicator/index.ios.js.map +1 -1
  224. package/ui/animation/animation-common.js.map +1 -1
  225. package/ui/animation/animation-interfaces.js.map +1 -1
  226. package/ui/animation/animation-shared.js.map +1 -1
  227. package/ui/animation/animation-types.js.map +1 -1
  228. package/ui/animation/index.android.js.map +1 -1
  229. package/ui/animation/index.ios.js +6 -1
  230. package/ui/animation/index.ios.js.map +1 -1
  231. package/ui/animation/keyframe-animation.d.ts +3 -1
  232. package/ui/animation/keyframe-animation.js +72 -3
  233. package/ui/animation/keyframe-animation.js.map +1 -1
  234. package/ui/builder/binding-builder.d.ts +8 -0
  235. package/ui/builder/binding-builder.js +12 -0
  236. package/ui/builder/binding-builder.js.map +1 -1
  237. package/ui/builder/component-builder/index.d.ts +7 -4
  238. package/ui/builder/component-builder/index.js +13 -7
  239. package/ui/builder/component-builder/index.js.map +1 -1
  240. package/ui/builder/index.d.ts +16 -2
  241. package/ui/builder/index.js +61 -13
  242. package/ui/builder/index.js.map +1 -1
  243. package/ui/button/button-common.js.map +1 -1
  244. package/ui/button/index.android.js +4 -3
  245. package/ui/button/index.android.js.map +1 -1
  246. package/ui/button/index.ios.js.map +1 -1
  247. package/ui/content-view/index.js +2 -0
  248. package/ui/content-view/index.js.map +1 -1
  249. package/ui/core/bindable/bindable-expressions.js.map +1 -1
  250. package/ui/core/bindable/bindable-resources.js.map +1 -1
  251. package/ui/core/bindable/bindable-types.d.ts +15 -0
  252. package/ui/core/bindable/bindable-types.js.map +1 -1
  253. package/ui/core/bindable/index.d.ts +1 -1
  254. package/ui/core/bindable/index.js +14 -8
  255. package/ui/core/bindable/index.js.map +1 -1
  256. package/ui/core/control-state-change/index.android.js.map +1 -1
  257. package/ui/core/control-state-change/index.ios.js.map +1 -1
  258. package/ui/core/properties/index.d.ts +37 -2
  259. package/ui/core/properties/index.js +205 -29
  260. package/ui/core/properties/index.js.map +1 -1
  261. package/ui/core/properties/property-shared.js +11 -2
  262. package/ui/core/properties/property-shared.js.map +1 -1
  263. package/ui/core/view/index.android.d.ts +5 -0
  264. package/ui/core/view/index.android.js +89 -15
  265. package/ui/core/view/index.android.js.map +1 -1
  266. package/ui/core/view/index.d.ts +58 -1
  267. package/ui/core/view/index.ios.d.ts +1 -0
  268. package/ui/core/view/index.ios.js +48 -11
  269. package/ui/core/view/index.ios.js.map +1 -1
  270. package/ui/core/view/view-common.d.ts +37 -0
  271. package/ui/core/view/view-common.js +81 -0
  272. package/ui/core/view/view-common.js.map +1 -1
  273. package/ui/core/view/view-helper/index.android.d.ts +1 -0
  274. package/ui/core/view/view-helper/index.android.js +8 -0
  275. package/ui/core/view/view-helper/index.android.js.map +1 -1
  276. package/ui/core/view/view-helper/index.d.ts +46 -0
  277. package/ui/core/view/view-helper/index.ios.d.ts +42 -0
  278. package/ui/core/view/view-helper/index.ios.js +170 -5
  279. package/ui/core/view/view-helper/index.ios.js.map +1 -1
  280. package/ui/core/view/view-helper/view-helper-common.js +21 -3
  281. package/ui/core/view/view-helper/view-helper-common.js.map +1 -1
  282. package/ui/core/view/view-helper/view-helper-shared.js.map +1 -1
  283. package/ui/core/view/view-interfaces.js.map +1 -1
  284. package/ui/core/view-base/index.js +75 -36
  285. package/ui/core/view-base/index.js.map +1 -1
  286. package/ui/core/view-base/utils.js.map +1 -1
  287. package/ui/core/weak-event-listener/index.js.map +1 -1
  288. package/ui/date-picker/date-picker-common.js.map +1 -1
  289. package/ui/date-picker/index.android.js +1 -1
  290. package/ui/date-picker/index.android.js.map +1 -1
  291. package/ui/date-picker/index.ios.js.map +1 -1
  292. package/ui/dialogs/dialogs-common.js.map +1 -1
  293. package/ui/dialogs/index.android.js +5 -5
  294. package/ui/dialogs/index.android.js.map +1 -1
  295. package/ui/dialogs/index.ios.js.map +1 -1
  296. package/ui/editable-text-base/editable-text-base-common.js.map +1 -1
  297. package/ui/editable-text-base/index.android.d.ts +2 -0
  298. package/ui/editable-text-base/index.android.js +17 -7
  299. package/ui/editable-text-base/index.android.js.map +1 -1
  300. package/ui/editable-text-base/index.d.ts +8 -0
  301. package/ui/editable-text-base/index.ios.js.map +1 -1
  302. package/ui/embedding/index.android.js.map +1 -1
  303. package/ui/embedding/index.ios.js.map +1 -1
  304. package/ui/enums/enums.js.map +1 -1
  305. package/ui/enums/index.js.map +1 -1
  306. package/ui/frame/activity.android.js.map +1 -1
  307. package/ui/frame/fragment.android.js.map +1 -1
  308. package/ui/frame/fragment.ios.js.map +1 -1
  309. package/ui/frame/fragment.transitions.android.d.ts +12 -9
  310. package/ui/frame/fragment.transitions.android.js +105 -90
  311. package/ui/frame/fragment.transitions.android.js.map +1 -1
  312. package/ui/frame/fragment.transitions.types.js.map +1 -1
  313. package/ui/frame/frame-common.d.ts +14 -2
  314. package/ui/frame/frame-common.js +51 -24
  315. package/ui/frame/frame-common.js.map +1 -1
  316. package/ui/frame/frame-constants.d.ts +9 -0
  317. package/ui/frame/frame-constants.js +10 -0
  318. package/ui/frame/frame-constants.js.map +1 -0
  319. package/ui/frame/frame-helper-for-android.d.ts +2 -2
  320. package/ui/frame/frame-helper-for-android.js +14 -5
  321. package/ui/frame/frame-helper-for-android.js.map +1 -1
  322. package/ui/frame/frame-helpers.js.map +1 -1
  323. package/ui/frame/frame-interfaces.d.ts +1 -1
  324. package/ui/frame/frame-interfaces.js.map +1 -1
  325. package/ui/frame/frame-stack.d.ts +22 -1
  326. package/ui/frame/frame-stack.js +43 -5
  327. package/ui/frame/frame-stack.js.map +1 -1
  328. package/ui/frame/index.android.d.ts +2 -2
  329. package/ui/frame/index.android.js +161 -56
  330. package/ui/frame/index.android.js.map +1 -1
  331. package/ui/frame/index.d.ts +15 -5
  332. package/ui/frame/index.ios.d.ts +1 -1
  333. package/ui/frame/index.ios.js +86 -26
  334. package/ui/frame/index.ios.js.map +1 -1
  335. package/ui/gestures/gestures-common.js.map +1 -1
  336. package/ui/gestures/gestures-types.d.ts +2 -0
  337. package/ui/gestures/gestures-types.js.map +1 -1
  338. package/ui/gestures/index.android.d.ts +1 -1
  339. package/ui/gestures/index.android.js +177 -133
  340. package/ui/gestures/index.android.js.map +1 -1
  341. package/ui/gestures/index.ios.js +36 -7
  342. package/ui/gestures/index.ios.js.map +1 -1
  343. package/ui/gestures/touch-manager.d.ts +1 -2
  344. package/ui/gestures/touch-manager.js +79 -50
  345. package/ui/gestures/touch-manager.js.map +1 -1
  346. package/ui/html-view/html-view-common.js.map +1 -1
  347. package/ui/html-view/index.android.js.map +1 -1
  348. package/ui/html-view/index.ios.js.map +1 -1
  349. package/ui/image/image-common.js +1 -1
  350. package/ui/image/image-common.js.map +1 -1
  351. package/ui/image/index.android.js +14 -2
  352. package/ui/image/index.android.js.map +1 -1
  353. package/ui/image/index.ios.js.map +1 -1
  354. package/ui/image/symbol-effects-common.js.map +1 -1
  355. package/ui/image/symbol-effects.android.js.map +1 -1
  356. package/ui/image/symbol-effects.ios.js.map +1 -1
  357. package/ui/image-cache/image-cache-common.js.map +1 -1
  358. package/ui/image-cache/index.android.js +1 -2
  359. package/ui/image-cache/index.android.js.map +1 -1
  360. package/ui/image-cache/index.ios.js.map +1 -1
  361. package/ui/index.d.ts +2 -2
  362. package/ui/index.js.map +1 -1
  363. package/ui/label/index.android.js.map +1 -1
  364. package/ui/label/index.ios.js.map +1 -1
  365. package/ui/layouts/absolute-layout/absolute-layout-common.js.map +1 -1
  366. package/ui/layouts/absolute-layout/index.android.js.map +1 -1
  367. package/ui/layouts/absolute-layout/index.ios.js +3 -0
  368. package/ui/layouts/absolute-layout/index.ios.js.map +1 -1
  369. package/ui/layouts/dock-layout/dock-layout-common.js.map +1 -1
  370. package/ui/layouts/dock-layout/index.android.js.map +1 -1
  371. package/ui/layouts/dock-layout/index.ios.js +3 -0
  372. package/ui/layouts/dock-layout/index.ios.js.map +1 -1
  373. package/ui/layouts/flexbox-layout/flexbox-layout-common.d.ts +7 -0
  374. package/ui/layouts/flexbox-layout/flexbox-layout-common.js +18 -0
  375. package/ui/layouts/flexbox-layout/flexbox-layout-common.js.map +1 -1
  376. package/ui/layouts/flexbox-layout/index.android.d.ts +5 -0
  377. package/ui/layouts/flexbox-layout/index.android.js +15 -0
  378. package/ui/layouts/flexbox-layout/index.android.js.map +1 -1
  379. package/ui/layouts/flexbox-layout/index.d.ts +19 -1
  380. package/ui/layouts/flexbox-layout/index.ios.d.ts +2 -0
  381. package/ui/layouts/flexbox-layout/index.ios.js +246 -195
  382. package/ui/layouts/flexbox-layout/index.ios.js.map +1 -1
  383. package/ui/layouts/grid-layout/grid-layout-common.js.map +1 -1
  384. package/ui/layouts/grid-layout/index.android.js.map +1 -1
  385. package/ui/layouts/grid-layout/index.ios.js +3 -0
  386. package/ui/layouts/grid-layout/index.ios.js.map +1 -1
  387. package/ui/layouts/index.js.map +1 -1
  388. package/ui/layouts/layout-base-common.d.ts +1 -0
  389. package/ui/layouts/layout-base-common.js +23 -1
  390. package/ui/layouts/layout-base-common.js.map +1 -1
  391. package/ui/layouts/layout-base.android.js.map +1 -1
  392. package/ui/layouts/layout-base.ios.js.map +1 -1
  393. package/ui/layouts/liquid-glass/index.android.js.map +1 -1
  394. package/ui/layouts/liquid-glass/index.ios.d.ts +0 -1
  395. package/ui/layouts/liquid-glass/index.ios.js +2 -43
  396. package/ui/layouts/liquid-glass/index.ios.js.map +1 -1
  397. package/ui/layouts/liquid-glass/liquid-glass-common.js.map +1 -1
  398. package/ui/layouts/liquid-glass-container/index.android.js.map +1 -1
  399. package/ui/layouts/liquid-glass-container/index.ios.d.ts +0 -1
  400. package/ui/layouts/liquid-glass-container/index.ios.js +2 -43
  401. package/ui/layouts/liquid-glass-container/index.ios.js.map +1 -1
  402. package/ui/layouts/liquid-glass-container/liquid-glass-container-common.js.map +1 -1
  403. package/ui/layouts/root-layout/index.android.js.map +1 -1
  404. package/ui/layouts/root-layout/index.ios.js.map +1 -1
  405. package/ui/layouts/root-layout/root-layout-common.js.map +1 -1
  406. package/ui/layouts/root-layout/root-layout-stack.js.map +1 -1
  407. package/ui/layouts/stack-layout/index.android.js.map +1 -1
  408. package/ui/layouts/stack-layout/index.ios.js +3 -0
  409. package/ui/layouts/stack-layout/index.ios.js.map +1 -1
  410. package/ui/layouts/stack-layout/stack-layout-common.js.map +1 -1
  411. package/ui/layouts/wrap-layout/index.android.js.map +1 -1
  412. package/ui/layouts/wrap-layout/index.ios.js +3 -0
  413. package/ui/layouts/wrap-layout/index.ios.js.map +1 -1
  414. package/ui/layouts/wrap-layout/wrap-layout-common.js.map +1 -1
  415. package/ui/list-picker/index.android.d.ts +1 -0
  416. package/ui/list-picker/index.android.js +6 -5
  417. package/ui/list-picker/index.android.js.map +1 -1
  418. package/ui/list-picker/index.ios.js.map +1 -1
  419. package/ui/list-picker/list-picker-common.js.map +1 -1
  420. package/ui/list-view/index.android.js +19 -11
  421. package/ui/list-view/index.android.js.map +1 -1
  422. package/ui/list-view/index.d.ts +47 -3
  423. package/ui/list-view/index.ios.d.ts +13 -3
  424. package/ui/list-view/index.ios.js +132 -41
  425. package/ui/list-view/index.ios.js.map +1 -1
  426. package/ui/list-view/list-view-common.d.ts +19 -0
  427. package/ui/list-view/list-view-common.js +30 -0
  428. package/ui/list-view/list-view-common.js.map +1 -1
  429. package/ui/page/events.js.map +1 -1
  430. package/ui/page/index.android.js.map +1 -1
  431. package/ui/page/index.d.ts +1 -1
  432. package/ui/page/index.ios.d.ts +3 -1
  433. package/ui/page/index.ios.js +33 -20
  434. package/ui/page/index.ios.js.map +1 -1
  435. package/ui/page/page-common.d.ts +5 -1
  436. package/ui/page/page-common.js.map +1 -1
  437. package/ui/placeholder/index.android.js.map +1 -1
  438. package/ui/placeholder/index.js.map +1 -1
  439. package/ui/placeholder/placeholder-common.js.map +1 -1
  440. package/ui/progress/index.android.js.map +1 -1
  441. package/ui/progress/index.ios.js.map +1 -1
  442. package/ui/progress/progress-common.js.map +1 -1
  443. package/ui/proxy-view-container/index.js.map +1 -1
  444. package/ui/repeater/index.d.ts +2 -1
  445. package/ui/repeater/index.js.map +1 -1
  446. package/ui/scroll-view/index.android.d.ts +2 -1
  447. package/ui/scroll-view/index.android.js +4 -1
  448. package/ui/scroll-view/index.android.js.map +1 -1
  449. package/ui/scroll-view/index.d.ts +53 -0
  450. package/ui/scroll-view/index.ios.d.ts +13 -1
  451. package/ui/scroll-view/index.ios.js +100 -20
  452. package/ui/scroll-view/index.ios.js.map +1 -1
  453. package/ui/scroll-view/scroll-view-common.d.ts +13 -0
  454. package/ui/scroll-view/scroll-view-common.js +27 -0
  455. package/ui/scroll-view/scroll-view-common.js.map +1 -1
  456. package/ui/search-bar/index.android.js +2 -2
  457. package/ui/search-bar/index.android.js.map +1 -1
  458. package/ui/search-bar/index.ios.js.map +1 -1
  459. package/ui/search-bar/search-bar-common.js.map +1 -1
  460. package/ui/segmented-bar/index.android.js +8 -8
  461. package/ui/segmented-bar/index.android.js.map +1 -1
  462. package/ui/segmented-bar/index.ios.js.map +1 -1
  463. package/ui/segmented-bar/segmented-bar-common.d.ts +5 -1
  464. package/ui/segmented-bar/segmented-bar-common.js +6 -1
  465. package/ui/segmented-bar/segmented-bar-common.js.map +1 -1
  466. package/ui/slider/index.android.js +1 -2
  467. package/ui/slider/index.android.js.map +1 -1
  468. package/ui/slider/index.ios.js.map +1 -1
  469. package/ui/slider/slider-common.js.map +1 -1
  470. package/ui/split-view/index.android.js.map +1 -1
  471. package/ui/split-view/index.ios.js.map +1 -1
  472. package/ui/split-view/split-view-common.js.map +1 -1
  473. package/ui/styling/background-common.d.ts +2 -0
  474. package/ui/styling/background-common.js +10 -2
  475. package/ui/styling/background-common.js.map +1 -1
  476. package/ui/styling/background.android.d.ts +4 -1
  477. package/ui/styling/background.android.js +5 -2
  478. package/ui/styling/background.android.js.map +1 -1
  479. package/ui/styling/background.d.ts +2 -2
  480. package/ui/styling/background.ios.d.ts +1 -1
  481. package/ui/styling/background.ios.js +10 -3
  482. package/ui/styling/background.ios.js.map +1 -1
  483. package/ui/styling/box-shadow.js.map +1 -1
  484. package/ui/styling/clip-path-function.js.map +1 -1
  485. package/ui/styling/converters.js.map +1 -1
  486. package/ui/styling/css-animation-parser.js.map +1 -1
  487. package/ui/styling/css-selector.d.ts +60 -13
  488. package/ui/styling/css-selector.js +311 -50
  489. package/ui/styling/css-selector.js.map +1 -1
  490. package/ui/styling/css-shadow.js.map +1 -1
  491. package/ui/styling/css-stroke.js.map +1 -1
  492. package/ui/styling/css-transform.js.map +1 -1
  493. package/ui/styling/css-utils.d.ts +16 -0
  494. package/ui/styling/css-utils.js +121 -7
  495. package/ui/styling/css-utils.js.map +1 -1
  496. package/ui/styling/font-common.js.map +1 -1
  497. package/ui/styling/font-interfaces.js.map +1 -1
  498. package/ui/styling/font.android.js.map +1 -1
  499. package/ui/styling/font.ios.js.map +1 -1
  500. package/ui/styling/length-shared.d.ts +2 -0
  501. package/ui/styling/length-shared.js +29 -2
  502. package/ui/styling/length-shared.js.map +1 -1
  503. package/ui/styling/linear-gradient.js.map +1 -1
  504. package/ui/styling/style/index.d.ts +29 -2
  505. package/ui/styling/style/index.js +1 -0
  506. package/ui/styling/style/index.js.map +1 -1
  507. package/ui/styling/style-properties.d.ts +5 -0
  508. package/ui/styling/style-properties.js +172 -101
  509. package/ui/styling/style-properties.js.map +1 -1
  510. package/ui/styling/style-scope.d.ts +24 -3
  511. package/ui/styling/style-scope.js +461 -63
  512. package/ui/styling/style-scope.js.map +1 -1
  513. package/ui/styling/styling-profile.js.map +1 -1
  514. package/ui/styling/styling-shared.js.map +1 -1
  515. package/ui/switch/index.android.js +1 -1
  516. package/ui/switch/index.android.js.map +1 -1
  517. package/ui/switch/index.ios.js +5 -1
  518. package/ui/switch/index.ios.js.map +1 -1
  519. package/ui/switch/switch-common.js.map +1 -1
  520. package/ui/tab-view/index.android.js +13 -17
  521. package/ui/tab-view/index.android.js.map +1 -1
  522. package/ui/tab-view/index.d.ts +5 -3
  523. package/ui/tab-view/index.ios.d.ts +2 -1
  524. package/ui/tab-view/index.ios.js +83 -20
  525. package/ui/tab-view/index.ios.js.map +1 -1
  526. package/ui/tab-view/tab-view-common.d.ts +6 -1
  527. package/ui/tab-view/tab-view-common.js +17 -1
  528. package/ui/tab-view/tab-view-common.js.map +1 -1
  529. package/ui/text-base/formatted-string.js.map +1 -1
  530. package/ui/text-base/index.android.js +6 -9
  531. package/ui/text-base/index.android.js.map +1 -1
  532. package/ui/text-base/index.ios.d.ts +3 -0
  533. package/ui/text-base/index.ios.js +26 -4
  534. package/ui/text-base/index.ios.js.map +1 -1
  535. package/ui/text-base/span.js.map +1 -1
  536. package/ui/text-base/text-base-common.js.map +1 -1
  537. package/ui/text-field/index.android.js.map +1 -1
  538. package/ui/text-field/index.ios.js +13 -5
  539. package/ui/text-field/index.ios.js.map +1 -1
  540. package/ui/text-field/text-field-common.js.map +1 -1
  541. package/ui/text-view/index.android.js.map +1 -1
  542. package/ui/text-view/index.ios.js.map +1 -1
  543. package/ui/text-view/text-view-common.js.map +1 -1
  544. package/ui/time-picker/index.android.js +1 -1
  545. package/ui/time-picker/index.android.js.map +1 -1
  546. package/ui/time-picker/index.ios.js.map +1 -1
  547. package/ui/time-picker/time-picker-common.js.map +1 -1
  548. package/ui/transition/fade-transition.android.js.map +1 -1
  549. package/ui/transition/fade-transition.ios.js.map +1 -1
  550. package/ui/transition/flip-transition.android.js.map +1 -1
  551. package/ui/transition/index.android.js.map +1 -1
  552. package/ui/transition/index.d.ts +2 -1
  553. package/ui/transition/index.ios.js.map +1 -1
  554. package/ui/transition/modal-transition.android.js.map +1 -1
  555. package/ui/transition/modal-transition.ios.js +33 -5
  556. package/ui/transition/modal-transition.ios.js.map +1 -1
  557. package/ui/transition/page-transition.android.d.ts +4 -0
  558. package/ui/transition/page-transition.android.js +171 -86
  559. package/ui/transition/page-transition.android.js.map +1 -1
  560. package/ui/transition/page-transition.ios.d.ts +5 -0
  561. package/ui/transition/page-transition.ios.js +298 -36
  562. package/ui/transition/page-transition.ios.js.map +1 -1
  563. package/ui/transition/shared-transition-helper.android.d.ts +3 -0
  564. package/ui/transition/shared-transition-helper.android.js +9 -0
  565. package/ui/transition/shared-transition-helper.android.js.map +1 -1
  566. package/ui/transition/shared-transition-helper.d.ts +7 -0
  567. package/ui/transition/shared-transition-helper.ios.d.ts +48 -0
  568. package/ui/transition/shared-transition-helper.ios.js +977 -95
  569. package/ui/transition/shared-transition-helper.ios.js.map +1 -1
  570. package/ui/transition/shared-transition.d.ts +134 -0
  571. package/ui/transition/shared-transition.js +90 -2
  572. package/ui/transition/shared-transition.js.map +1 -1
  573. package/ui/transition/slide-transition.android.js.map +1 -1
  574. package/ui/transition/slide-transition.ios.js.map +1 -1
  575. package/ui/utils.android.js.map +1 -1
  576. package/ui/utils.d.ts +2 -0
  577. package/ui/utils.ios.js.map +1 -1
  578. package/ui/web-view/index.android.js +1 -1
  579. package/ui/web-view/index.android.js.map +1 -1
  580. package/ui/web-view/index.ios.js.map +1 -1
  581. package/ui/web-view/web-view-common.js.map +1 -1
  582. package/ui/web-view/web-view-interfaces.js.map +1 -1
  583. package/utils/android-runtime-version.d.ts +12 -0
  584. package/utils/android-runtime-version.js +36 -0
  585. package/utils/android-runtime-version.js.map +1 -0
  586. package/utils/animation-helpers.js.map +1 -1
  587. package/utils/common.js.map +1 -1
  588. package/utils/constants.android.js.map +1 -1
  589. package/utils/constants.ios.js.map +1 -1
  590. package/utils/debug-source.js.map +1 -1
  591. package/utils/debug.js.map +1 -1
  592. package/utils/index.android.js.map +1 -1
  593. package/utils/index.ios.js.map +1 -1
  594. package/utils/layout-helper/index.android.js.map +1 -1
  595. package/utils/layout-helper/index.ios.js +11 -3
  596. package/utils/layout-helper/index.ios.js.map +1 -1
  597. package/utils/layout-helper/layout-helper-common.js.map +1 -1
  598. package/utils/layout-helper/layout-helper-shared.js.map +1 -1
  599. package/utils/lazy.js.map +1 -1
  600. package/utils/macrotask-scheduler.js.map +1 -1
  601. package/utils/mainthread-helper.android.js.map +1 -1
  602. package/utils/mainthread-helper.ios.js.map +1 -1
  603. package/utils/module-merge.js.map +1 -1
  604. package/utils/native-helper-for-android.js +9 -3
  605. package/utils/native-helper-for-android.js.map +1 -1
  606. package/utils/native-helper.android.d.ts +66 -2
  607. package/utils/native-helper.android.js.map +1 -1
  608. package/utils/native-helper.d.ts +2 -2
  609. package/utils/native-helper.ios.d.ts +52 -2
  610. package/utils/native-helper.ios.js +35 -5
  611. package/utils/native-helper.ios.js.map +1 -1
  612. package/utils/native-helper.types.d.ts +2 -0
  613. package/utils/number-utils.js.map +1 -1
  614. package/utils/platform-check.d.ts +1 -1
  615. package/utils/platform-check.js.map +1 -1
  616. package/utils/shared.js.map +1 -1
  617. package/utils/types.js.map +1 -1
  618. package/utils/utils-shared.js.map +1 -1
  619. package/wgc/atob.js.map +1 -1
  620. package/wgc/btoa.js.map +1 -1
  621. package/wgc/crypto/SubtleCrypto.js.map +1 -1
  622. package/wgc/crypto/index.d.ts +1 -1
  623. package/wgc/crypto/index.js +12 -8
  624. package/wgc/crypto/index.js.map +1 -1
  625. package/wgc/index.js.map +1 -1
  626. package/xhr/index.d.ts +5 -4
  627. package/xhr/index.js +18 -18
  628. package/xhr/index.js.map +1 -1
  629. package/xml/index.d.ts +2 -2
  630. package/xml/index.js +1 -1
  631. package/xml/index.js.map +1 -1
  632. package/LICENSE +0 -19
  633. package/fetch/index.mjs +0 -535
@@ -1,14 +1,17 @@
1
1
  import { profile } from '../profiling';
2
- import { ContentView } from '../ui/content-view';
3
2
  import { isEmbedded } from '../ui/embedding';
4
3
  import { IOSHelper } from '../ui/core/view/view-helper';
5
4
  import { getWindow } from '../utils/native-helper';
6
5
  import { SDK_VERSION } from '../utils/constants';
7
- import { ios as iosUtils, dataSerialize } from '../utils/native-helper';
8
- import { ApplicationCommon, SceneEvents } from './application-common';
6
+ import { ios as iosUtils, dataSerialize, dataDeserialize } from '../utils/native-helper';
7
+ import { ApplicationCommon } from './application-common';
8
+ import { deliverShortcutItem, forwardContinueUserActivity, forwardOpenURLContexts, getLaunchUserActivities, oneShotCompletion } from './scene-delegate-bridge';
9
9
  import { Trace } from '../trace';
10
+ import { IOSNativeWindow } from '../native-window/native-window.ios';
11
+ import { NativeWindow } from '../native-window/native-window-common';
12
+ import { NativeWindowEvents } from '../native-window/native-window-interfaces';
10
13
  import { CoreTypes } from '../core-types';
11
- import { getiOSWindow, setApplicationPropertiesCallback, setAppMainEntry, setiOSWindow, setRootView, setToggleApplicationEventListenersCallback } from './helpers-common';
14
+ import { createContentView, getiOSWindow, setApplicationPropertiesCallback, setAppMainEntry, setiOSWindow, setRootView, setToggleApplicationEventListenersCallback } from './helpers-common';
12
15
  var NotificationObserver = (function (_super) {
13
16
  __extends(NotificationObserver, _super);
14
17
  function NotificationObserver() {
@@ -38,6 +41,7 @@ var CADisplayLinkTarget = (function (_super) {
38
41
  return target;
39
42
  };
40
43
  CADisplayLinkTarget.prototype.onDisplayed = function (link) {
44
+ var _a;
41
45
  link.invalidate();
42
46
  var owner = this._owner.deref();
43
47
  if (!owner) {
@@ -49,6 +53,7 @@ var CADisplayLinkTarget = (function (_super) {
49
53
  object: owner,
50
54
  ios: UIApplication.sharedApplication,
51
55
  });
56
+ (_a = owner.primaryWindow) === null || _a === void 0 ? void 0 : _a._notifyEvent(NativeWindowEvents.displayed);
52
57
  owner.displayedLinkTarget = null;
53
58
  owner.displayedLink = null;
54
59
  };
@@ -79,6 +84,15 @@ function supportsMultipleScenes() {
79
84
  }
80
85
  return UIApplication.sharedApplication?.supportsMultipleScenes;
81
86
  }
87
+ /**
88
+ * Number of times the JS runtime has been soft-rebooted in this process via
89
+ * NativeScriptRuntime.reloadApplication / restartWithConfig. 0 on first boot.
90
+ * Provided as a global by the iOS runtime (v9+); older runtimes report 0.
91
+ */
92
+ function getRuntimeReloadCount() {
93
+ const runtime = globalThis.NativeScriptRuntime;
94
+ return runtime && typeof runtime.reloadCount === 'number' ? runtime.reloadCount : 0;
95
+ }
82
96
  var Responder = (function (_super) {
83
97
  __extends(Responder, _super);
84
98
  function Responder() {
@@ -96,25 +110,171 @@ var Responder = (function (_super) {
96
110
  Responder.ObjCProtocols = [UIApplicationDelegate];
97
111
  return Responder;
98
112
  }(UIResponder));
99
- if (supportsScenes()) {
100
- /**
101
- * This method is called when a new scene session is being created.
102
- * Important: When this method is implemented, the app assumes scene-based lifecycle management.
103
- * Detected by the Info.plist existence 'UIApplicationSceneManifest'.
104
- * If this method is implemented when there is no manifest defined,
105
- * the app will boot to a white screen.
106
- */
107
- Responder.prototype.applicationConfigurationForConnectingSceneSessionOptions = function (application, connectingSceneSession, options) {
108
- const config = UISceneConfiguration.configurationWithNameSessionRole('Default Configuration', connectingSceneSession.role);
109
- config.sceneClass = UIWindowScene;
110
- config.delegateClass = SceneDelegate;
111
- return config;
112
- };
113
- // scene session destruction handling
114
- Responder.prototype.applicationDidDiscardSceneSessions = function (application, sceneSessions) {
115
- // Note: we could emit an event here if needed
116
- // console.log('Scene sessions discarded:', sceneSessions.count);
117
- };
113
+ const delegateWindowKey = Symbol('nativescript.delegateWindow');
114
+ /**
115
+ * Installs NativeScript's default `UIApplicationDelegate` members on the class that will
116
+ * be handed to `UIApplicationMain`, so scenes keep working with a custom delegate.
117
+ *
118
+ * Each member is installed only when the class does not already provide one (its own or
119
+ * inherited), so a delegate that implements a method keeps it and can forward to
120
+ * `Application.ios.defaultSceneConfiguration` / `defaultDiscardSceneSessions` itself.
121
+ *
122
+ * @internal
123
+ */
124
+ function installSceneDelegateDefaults(delegateClass) {
125
+ const proto = delegateClass?.prototype;
126
+ if (!proto) {
127
+ return;
128
+ }
129
+ // Implementing the scene methods makes the app assume scene-based lifecycle management,
130
+ // which boots to a white screen when Info.plist has no UIApplicationSceneManifest.
131
+ // Configuring the delegate here is also why UISceneConfigurations does not have to be
132
+ // declared in Info.plist — UIApplicationSceneManifest on its own is enough.
133
+ if (supportsScenes()) {
134
+ if (!proto.applicationConfigurationForConnectingSceneSessionOptions) {
135
+ proto.applicationConfigurationForConnectingSceneSessionOptions = function (application, connectingSceneSession, options) {
136
+ return Application.ios.defaultSceneConfiguration(application, connectingSceneSession, options);
137
+ };
138
+ }
139
+ if (!proto.applicationDidDiscardSceneSessions) {
140
+ proto.applicationDidDiscardSceneSessions = function (application, sceneSessions) {
141
+ Application.ios.defaultDiscardSceneSessions(application, sceneSessions);
142
+ };
143
+ }
144
+ }
145
+ if (!('window' in proto)) {
146
+ Object.defineProperty(proto, 'window', {
147
+ get() {
148
+ return this[delegateWindowKey] ?? Application.ios.window;
149
+ },
150
+ // UIKit assigns `delegate.window` on non-scene apps and a delegate may assign it
151
+ // itself, so the value has to be kept: a discarding setter would leave the
152
+ // delegate reporting a window it never set.
153
+ set(value) {
154
+ this[delegateWindowKey] = value;
155
+ },
156
+ enumerable: true,
157
+ configurable: true,
158
+ });
159
+ }
160
+ }
161
+ installSceneDelegateDefaults(Responder);
162
+ let warnedAboutDelegateProtocols = false;
163
+ let warnedAboutDelegateAfterStart = false;
164
+ function warnAboutDelegate(message) {
165
+ Trace.write(message, Trace.categories.Error, Trace.messageType.warn);
166
+ console.warn(message);
167
+ }
168
+ /**
169
+ * Reports the two custom-delegate mistakes NativeScript cannot correct on the app's behalf:
170
+ * a delegate class that never declared `UIApplicationDelegate` conformance, and a delegate
171
+ * assigned once `UIApplicationMain` has already been given a class.
172
+ */
173
+ function warnAboutDelegateClass(delegateClass, alreadyStarted) {
174
+ const protocols = delegateClass?.ObjCProtocols;
175
+ if (!warnedAboutDelegateProtocols && !(Array.isArray(protocols) && protocols.indexOf(UIApplicationDelegate) !== -1)) {
176
+ warnedAboutDelegateProtocols = true;
177
+ warnAboutDelegate('Application.ios.delegate was set to a class that does not list UIApplicationDelegate in its static ObjCProtocols. Add `static ObjCProtocols = [UIApplicationDelegate];` to the class body: the Objective-C class is built from ObjCProtocols and cached, so conformance cannot be declared from here and UIKit may never dispatch the delegate methods.');
178
+ }
179
+ if (alreadyStarted && !warnedAboutDelegateAfterStart) {
180
+ warnedAboutDelegateAfterStart = true;
181
+ warnAboutDelegate('Application.ios.delegate was set after the application started. UIApplicationMain has already been given a delegate class, so this assignment has no effect — set Application.ios.delegate before calling Application.run().');
182
+ }
183
+ }
184
+ /**
185
+ * Reads the payload `openWindow()` put on the activating NSUserActivity.
186
+ */
187
+ function getSceneConnectionData(connectionOptions) {
188
+ const activities = connectionOptions?.userActivities;
189
+ if (!activities || activities.count === 0) {
190
+ return undefined;
191
+ }
192
+ const activity = activities.allObjects.objectAtIndex(0);
193
+ return activity?.userInfo ? dataDeserialize(activity.userInfo) : undefined;
194
+ }
195
+ /**
196
+ * The activity type `openWindow()` uses to hand its data to the scene it opens.
197
+ */
198
+ function getSceneActivityType() {
199
+ return `${NSBundle.mainBundle.bundleIdentifier}.scene`;
200
+ }
201
+ function deliverOpenURLContexts(windowScene, nativeWindow, URLContexts) {
202
+ if (nativeWindow) {
203
+ nativeWindow.notify({
204
+ eventName: NativeWindowEvents.sceneOpenURLContexts,
205
+ object: nativeWindow,
206
+ window: nativeWindow,
207
+ scene: windowScene,
208
+ urlContexts: URLContexts,
209
+ });
210
+ }
211
+ Application.ios.notify({
212
+ eventName: NativeWindowEvents.sceneOpenURLContexts,
213
+ object: Application.ios,
214
+ window: nativeWindow,
215
+ scene: windowScene,
216
+ urlContexts: URLContexts,
217
+ });
218
+ forwardOpenURLContexts(Application.ios.delegate, UIApplication.sharedApplication, URLContexts);
219
+ }
220
+ function deliverUserActivity(windowScene, nativeWindow, userActivity) {
221
+ if (nativeWindow) {
222
+ nativeWindow.notify({
223
+ eventName: NativeWindowEvents.sceneContinueUserActivity,
224
+ object: nativeWindow,
225
+ window: nativeWindow,
226
+ scene: windowScene,
227
+ userActivity,
228
+ });
229
+ }
230
+ Application.ios.notify({
231
+ eventName: NativeWindowEvents.sceneContinueUserActivity,
232
+ object: Application.ios,
233
+ window: nativeWindow,
234
+ scene: windowScene,
235
+ userActivity,
236
+ });
237
+ forwardContinueUserActivity(Application.ios.delegate, UIApplication.sharedApplication, userActivity);
238
+ }
239
+ function deliverShortcutAction(windowScene, nativeWindow, shortcutItem, completionHandler) {
240
+ // Shared by the listeners and the legacy handler, so it has to tolerate several callers.
241
+ const deliver = oneShotCompletion(completionHandler);
242
+ if (nativeWindow) {
243
+ nativeWindow.notify({
244
+ eventName: NativeWindowEvents.scenePerformActionForShortcutItem,
245
+ object: nativeWindow,
246
+ window: nativeWindow,
247
+ scene: windowScene,
248
+ shortcutItem,
249
+ completionHandler: deliver,
250
+ });
251
+ }
252
+ Application.ios.notify({
253
+ eventName: NativeWindowEvents.scenePerformActionForShortcutItem,
254
+ object: Application.ios,
255
+ window: nativeWindow,
256
+ scene: windowScene,
257
+ shortcutItem,
258
+ completionHandler: deliver,
259
+ });
260
+ deliverShortcutItem(Application.ios.delegate, UIApplication.sharedApplication, shortcutItem, deliver);
261
+ }
262
+ /**
263
+ * UIKit hands the URLs, continuation activities and quick action that launched a scene only to
264
+ * `scene:willConnectToSession:options:`; the scene callbacks that carry them later never fire for
265
+ * the launch itself, so they are delivered here the same way.
266
+ */
267
+ function deliverLaunchPayloads(windowScene, nativeWindow, connectionOptions) {
268
+ if (connectionOptions?.URLContexts?.count) {
269
+ deliverOpenURLContexts(windowScene, nativeWindow, connectionOptions.URLContexts);
270
+ }
271
+ for (const userActivity of getLaunchUserActivities(connectionOptions, getSceneActivityType())) {
272
+ deliverUserActivity(windowScene, nativeWindow, userActivity);
273
+ }
274
+ if (connectionOptions?.shortcutItem) {
275
+ // A launch has no completion handler to report back to.
276
+ deliverShortcutAction(windowScene, nativeWindow, connectionOptions.shortcutItem, undefined);
277
+ }
118
278
  }
119
279
  var SceneDelegate = (function (_super) {
120
280
  __extends(SceneDelegate, _super);
@@ -138,48 +298,196 @@ var SceneDelegate = (function (_super) {
138
298
  if (!(scene instanceof UIWindowScene)) {
139
299
  return;
140
300
  }
141
- var isFirstScene = !Application.ios.getPrimaryScene() && !Application.hasLaunched();
142
- this._scene = scene;
143
- this._window = UIWindow.alloc().initWithWindowScene(scene);
144
- Application.ios._setWindowForScene(this._window, scene);
145
- Application.ios._setupWindowForScene(this._window, scene);
301
+ var windowScene = scene;
302
+ var isFirstScene = Application.ios._getWindows().length === 0;
303
+ this._scene = windowScene;
304
+ this._window = UIWindow.alloc().initWithWindowScene(windowScene);
305
+ if (!__VISIONOS__) {
306
+ this._window.backgroundColor = SDK_VERSION <= 12 || !UIColor.systemBackgroundColor ? UIColor.whiteColor : UIColor.systemBackgroundColor;
307
+ }
308
+ var nativeWindowId = IOSNativeWindow.getSceneId(windowScene);
309
+ var knownWindow = nativeWindowId ? Application.ios.getWindowById(nativeWindowId) : undefined;
310
+ var nativeWindow;
311
+ if ((knownWindow === null || knownWindow === void 0 ? void 0 : knownWindow.state) === "detached") {
312
+ nativeWindow = knownWindow;
313
+ nativeWindow._reattach(windowScene, this._window);
314
+ }
315
+ else {
316
+ var isPrimary_1 = isFirstScene || !Application.ios.primaryWindow;
317
+ nativeWindow = new IOSNativeWindow(windowScene, this._window, nativeWindowId, isPrimary_1);
318
+ Application.ios._registerWindow(nativeWindow);
319
+ }
320
+ var isPrimary = nativeWindow.isPrimary;
321
+ nativeWindow._notifyEvent(NativeWindowEvents.attached);
322
+ if (isPrimary) {
323
+ setiOSWindow(this._window);
324
+ }
325
+ nativeWindow.notify({
326
+ eventName: NativeWindowEvents.sceneWillConnect,
327
+ object: nativeWindow,
328
+ window: nativeWindow,
329
+ scene: windowScene,
330
+ uiWindow: this._window,
331
+ connectionOptions: connectionOptions,
332
+ });
146
333
  Application.ios.notify({
147
- eventName: SceneEvents.sceneWillConnect,
334
+ eventName: NativeWindowEvents.sceneWillConnect,
148
335
  object: Application.ios,
149
- scene: scene,
150
- window: this._window,
336
+ window: nativeWindow,
337
+ scene: windowScene,
338
+ uiWindow: this._window,
151
339
  connectionOptions: connectionOptions,
152
340
  });
153
- if (scene === Application.ios.getPrimaryScene()) {
341
+ if (isPrimary) {
154
342
  this._window.makeKeyAndVisible();
155
343
  }
156
- else {
157
- Application.ios.notify({
158
- eventName: SceneEvents.sceneContentSetup,
159
- object: Application.ios,
160
- scene: scene,
161
- window: this._window,
162
- connectionOptions: connectionOptions,
344
+ if (nativeWindow.role === "application") {
345
+ Application.ios._resolveWindowContent(nativeWindow, {
346
+ window: nativeWindow,
347
+ isPrimary: isPrimary,
348
+ data: getSceneConnectionData(connectionOptions),
349
+ ios: { connectionOptions: connectionOptions },
163
350
  });
164
351
  }
165
- if (isFirstScene) {
166
- Application.ios._notifySceneAppStarted();
167
- }
352
+ deliverLaunchPayloads(windowScene, nativeWindow, connectionOptions);
168
353
  };
169
354
  SceneDelegate.prototype.sceneDidBecomeActive = function (scene) {
355
+ var windowScene = scene;
356
+ var nativeWindow = Application.ios._getWindowForScene(windowScene);
357
+ if (nativeWindow) {
358
+ nativeWindow._notifyEvent(NativeWindowEvents.activate);
359
+ nativeWindow.notify({
360
+ eventName: NativeWindowEvents.sceneDidActivate,
361
+ object: nativeWindow,
362
+ window: nativeWindow,
363
+ scene: windowScene,
364
+ });
365
+ }
366
+ Application.ios.notify({
367
+ eventName: NativeWindowEvents.sceneDidActivate,
368
+ object: Application.ios,
369
+ window: nativeWindow,
370
+ scene: windowScene,
371
+ });
372
+ Application.ios._setWindowActive(nativeWindow, true, windowScene);
373
+ var rootView = nativeWindow === null || nativeWindow === void 0 ? void 0 : nativeWindow.rootView;
374
+ if (rootView && !rootView.isLoaded) {
375
+ rootView.callLoaded();
376
+ }
170
377
  };
171
378
  SceneDelegate.prototype.sceneWillResignActive = function (scene) {
379
+ var windowScene = scene;
380
+ var nativeWindow = Application.ios._getWindowForScene(windowScene);
381
+ if (nativeWindow) {
382
+ nativeWindow._notifyEvent(NativeWindowEvents.deactivate);
383
+ nativeWindow.notify({
384
+ eventName: NativeWindowEvents.sceneWillResignActive,
385
+ object: nativeWindow,
386
+ window: nativeWindow,
387
+ scene: windowScene,
388
+ });
389
+ }
172
390
  Application.ios.notify({
173
- eventName: SceneEvents.sceneWillResignActive,
391
+ eventName: NativeWindowEvents.sceneWillResignActive,
174
392
  object: Application.ios,
175
- scene: scene,
393
+ window: nativeWindow,
394
+ scene: windowScene,
176
395
  });
396
+ Application.ios._setWindowActive(nativeWindow, false, windowScene);
177
397
  };
178
398
  SceneDelegate.prototype.sceneWillEnterForeground = function (scene) {
399
+ var windowScene = scene;
400
+ var nativeWindow = Application.ios._getWindowForScene(windowScene);
401
+ if (nativeWindow) {
402
+ nativeWindow._notifyEvent(NativeWindowEvents.foreground);
403
+ nativeWindow.notify({
404
+ eventName: NativeWindowEvents.sceneWillEnterForeground,
405
+ object: nativeWindow,
406
+ window: nativeWindow,
407
+ scene: windowScene,
408
+ });
409
+ }
410
+ Application.ios.notify({
411
+ eventName: NativeWindowEvents.sceneWillEnterForeground,
412
+ object: Application.ios,
413
+ window: nativeWindow,
414
+ scene: windowScene,
415
+ });
416
+ Application.ios._setWindowInForeground(nativeWindow, true, windowScene);
179
417
  };
180
418
  SceneDelegate.prototype.sceneDidEnterBackground = function (scene) {
419
+ var windowScene = scene;
420
+ var nativeWindow = Application.ios._getWindowForScene(windowScene);
421
+ if (nativeWindow) {
422
+ nativeWindow._notifyEvent(NativeWindowEvents.background);
423
+ nativeWindow.notify({
424
+ eventName: NativeWindowEvents.sceneDidEnterBackground,
425
+ object: nativeWindow,
426
+ window: nativeWindow,
427
+ scene: windowScene,
428
+ });
429
+ }
430
+ Application.ios.notify({
431
+ eventName: NativeWindowEvents.sceneDidEnterBackground,
432
+ object: Application.ios,
433
+ window: nativeWindow,
434
+ scene: windowScene,
435
+ });
436
+ Application.ios._setWindowInForeground(nativeWindow, false, windowScene);
437
+ var rootView = nativeWindow === null || nativeWindow === void 0 ? void 0 : nativeWindow.rootView;
438
+ if (rootView && rootView.isLoaded) {
439
+ rootView.callUnloaded();
440
+ }
181
441
  };
182
442
  SceneDelegate.prototype.sceneDidDisconnect = function (scene) {
443
+ var windowScene = scene;
444
+ var nativeWindow = Application.ios._getWindowForScene(windowScene);
445
+ Application.ios._setWindowActive(nativeWindow, false, windowScene);
446
+ Application.ios._setWindowInForeground(nativeWindow, false, windowScene);
447
+ if (nativeWindow) {
448
+ nativeWindow._surfaceGone = true;
449
+ var isClosing = nativeWindow._closeRequested || !nativeWindow._hasSessionIdentity;
450
+ if (isClosing) {
451
+ nativeWindow._notifyEvent(NativeWindowEvents.close);
452
+ }
453
+ nativeWindow.notify({
454
+ eventName: NativeWindowEvents.sceneDidDisconnect,
455
+ object: nativeWindow,
456
+ window: nativeWindow,
457
+ scene: windowScene,
458
+ });
459
+ if (isClosing) {
460
+ Application.ios._unregisterWindow(nativeWindow);
461
+ }
462
+ else {
463
+ nativeWindow._detach();
464
+ }
465
+ }
466
+ Application.ios.notify({
467
+ eventName: NativeWindowEvents.sceneDidDisconnect,
468
+ object: Application.ios,
469
+ window: nativeWindow,
470
+ scene: windowScene,
471
+ });
472
+ };
473
+ SceneDelegate.prototype.sceneOpenURLContexts = function (scene, URLContexts) {
474
+ var windowScene = scene;
475
+ deliverOpenURLContexts(windowScene, Application.ios._getWindowForScene(windowScene), URLContexts);
476
+ };
477
+ SceneDelegate.prototype.sceneContinueUserActivity = function (scene, userActivity) {
478
+ var windowScene = scene;
479
+ deliverUserActivity(windowScene, Application.ios._getWindowForScene(windowScene), userActivity);
480
+ };
481
+ SceneDelegate.prototype.windowSceneDidUpdateEffectiveGeometry = function (windowScene, previousEffectiveGeometry) {
482
+ var _a;
483
+ (_a = Application.ios._getWindowForScene(windowScene)) === null || _a === void 0 ? void 0 : _a._syncOrientation();
484
+ };
485
+ SceneDelegate.prototype.windowSceneDidUpdateCoordinateSpaceInterfaceOrientationTraitCollection = function (windowScene, previousCoordinateSpace, previousInterfaceOrientation, previousTraitCollection) {
486
+ var _a;
487
+ (_a = Application.ios._getWindowForScene(windowScene)) === null || _a === void 0 ? void 0 : _a._syncOrientation();
488
+ };
489
+ SceneDelegate.prototype.windowScenePerformActionForShortcutItemCompletionHandler = function (windowScene, shortcutItem, completionHandler) {
490
+ deliverShortcutAction(windowScene, Application.ios._getWindowForScene(windowScene), shortcutItem, completionHandler);
183
491
  };
184
492
  SceneDelegate.ObjCProtocols = [UIWindowSceneDelegate];
185
493
  return SceneDelegate;
@@ -193,12 +501,31 @@ export class iOSApplication extends ApplicationCommon {
193
501
  constructor() {
194
502
  super();
195
503
  this._delegateHandlers = new Map();
196
- this.launchEventCalled = false;
197
- this._windowSceneMap = new Map();
198
- this._primaryScene = null;
199
- this._openedScenesById = new Map();
504
+ /**
505
+ * Root views that are a ContentView host created by this class. The host is the actual
506
+ * root of the window (it carries `.ns-root`, the system CSS classes and the CSS state, so
507
+ * the user's root view can read CSS variables as soon as it is created), and the root view
508
+ * the user provided (main entry / `launch` root / resetRootView) is its `content`.
509
+ * `getRootView()` returns that user view, as it did before NativeWindow existed.
510
+ */
511
+ this._contentHosts = new WeakSet();
512
+ // Application-role windows currently in the foreground / currently active. Membership,
513
+ // not a count, so a repeated or missing scene callback cannot drift the aggregate.
514
+ this._foregroundWindows = new Set();
515
+ this._activeWindows = new Set();
200
516
  this._notificationObservers = [];
517
+ this._softRebootSceneDelegates = new Map();
201
518
  this.displayedOnce = false;
519
+ /**
520
+ * Delays the 'launch' event, and with it the creation of the first window's content, until the
521
+ * app first becomes active, instead of raising it while the app finishes launching.
522
+ *
523
+ * Applies to non-scene apps only. It has no effect in a scene-based app, where each window's
524
+ * content is resolved as its scene connects.
525
+ *
526
+ * @deprecated Use the 'ready' event for application initialization, and
527
+ * Application.setWindowContentResolver() to provide window UI.
528
+ */
202
529
  this.shouldDelayLaunchEvent = false;
203
530
  this.addNotificationObserver(UIApplicationDidFinishLaunchingNotification, this.didFinishLaunchingWithOptions.bind(this));
204
531
  this.addNotificationObserver(UIApplicationDidBecomeActiveNotification, this.didBecomeActive.bind(this));
@@ -206,26 +533,59 @@ export class iOSApplication extends ApplicationCommon {
206
533
  this.addNotificationObserver(UIApplicationWillTerminateNotification, this.willTerminate.bind(this));
207
534
  this.addNotificationObserver(UIApplicationDidReceiveMemoryWarningNotification, this.didReceiveMemoryWarning.bind(this));
208
535
  this.addNotificationObserver(UIApplicationDidChangeStatusBarOrientationNotification, this.didChangeStatusBarOrientation.bind(this));
209
- // Add scene lifecycle notification observers only if scenes are supported
210
- if (this.supportsScenes()) {
211
- this.addNotificationObserver('UISceneWillConnectNotification', this.sceneWillConnect.bind(this));
212
- this.addNotificationObserver('UISceneDidActivateNotification', this.sceneDidActivate.bind(this));
213
- this.addNotificationObserver('UISceneWillEnterForegroundNotification', this.sceneWillEnterForeground.bind(this));
214
- this.addNotificationObserver('UISceneDidEnterBackgroundNotification', this.sceneDidEnterBackground.bind(this));
215
- this.addNotificationObserver('UISceneDidDisconnectNotification', this.sceneDidDisconnect.bind(this));
216
- }
217
536
  }
218
537
  getRootView() {
219
- return this._subRootView || this._rootView;
538
+ const root = this._rootView;
539
+ return root && this._contentHosts.has(root) ? root.content || root : root;
220
540
  }
221
- resetRootView(view) {
222
- super.resetRootView(view);
541
+ resetRootView(entry) {
542
+ super.resetRootView(entry);
223
543
  this.setWindowContent();
224
544
  }
225
545
  run(entry) {
226
546
  setAppMainEntry(typeof entry === 'string' ? { moduleName: entry } : entry);
227
547
  this.started = true;
228
548
  if (this.nativeApp) {
549
+ // During Vite HMR dev boot, the placeholder has already started
550
+ // the app lifecycle. A second run() with an entry should replace
551
+ // the placeholder root, NOT present a modal via runAsEmbeddedApp.
552
+ // The HTTP ESM realm creates a separate @nativescript/core instance,
553
+ // so JS-level patching of Application.run can't intercept this call.
554
+ // Detect HMR mode via the placeholder's global flag and use
555
+ // setWindowContent on the PRIMARY Application singleton (bundled realm)
556
+ // which has the actual window and root view hierarchy.
557
+ const g = globalThis;
558
+ if (g.__NS_DEV_PLACEHOLDER_ROOT_VIEW__ || g.__NS_DEV_PLACEHOLDER_ROOT_EARLY__) {
559
+ if (entry) {
560
+ // Defer to next run loop tick so resetRootView executes outside the
561
+ // HTTP ESM import context. Direct calls can fail with
562
+ // "ReferenceError: __COMMONJS__ is not defined" because the JS
563
+ // execution stack is in the HTTP realm when Builder loads modules.
564
+ const resolvedEntry = typeof entry === 'string' ? { moduleName: entry } : entry;
565
+ setTimeout(() => {
566
+ try {
567
+ const primaryApp = g.Application;
568
+ if (primaryApp && typeof primaryApp.resetRootView === 'function') {
569
+ primaryApp.resetRootView(resolvedEntry);
570
+ }
571
+ }
572
+ catch (e) {
573
+ if (__DEV__)
574
+ console.warn('[app-ios] deferred resetRootView failed:', e);
575
+ }
576
+ delete g.__NS_DEV_PLACEHOLDER_ROOT_VIEW__;
577
+ delete g.__NS_DEV_PLACEHOLDER_ROOT_EARLY__;
578
+ }, 0);
579
+ }
580
+ else {
581
+ // Framework (e.g. Angular) calls run() with no entry — it manages
582
+ // root views itself via resetRootView(). No-op to avoid presenting
583
+ // a modal via runAsEmbeddedApp or throwing "Main entry is missing".
584
+ if (__DEV__)
585
+ console.info('[app-ios] run() called with no entry during HMR placeholder; framework manages root view');
586
+ }
587
+ return;
588
+ }
229
589
  this.runAsEmbeddedApp();
230
590
  }
231
591
  else {
@@ -236,6 +596,8 @@ export class iOSApplication extends ApplicationCommon {
236
596
  UIApplicationMain(0, null, null, this.delegate ? NSStringFromClass(this.delegate) : NSStringFromClass(Responder));
237
597
  }
238
598
  runAsEmbeddedApp() {
599
+ this.notifyReady();
600
+ this._reattachNativeDelegatesAfterSoftReboot();
239
601
  // TODO: this rootView should be held alive until rootController dismissViewController is called.
240
602
  const rootView = this.createRootView(this._rootView, true);
241
603
  if (!rootView) {
@@ -244,38 +606,126 @@ export class iOSApplication extends ApplicationCommon {
244
606
  this._rootView = rootView;
245
607
  setRootView(rootView);
246
608
  // Attach to the existing iOS app
247
- const window = getWindow();
609
+ let window = getWindow();
610
+ if (!window) {
611
+ // In-process soft reboot with OTAs.
612
+ // Original UIWindow is deallocated when the old JS isolate is torn down.
613
+ // Recreate a window bound to the active UIWindowScene so the
614
+ // root has somewhere to attach.
615
+ const app = UIApplication.sharedApplication;
616
+ const all = app && app.connectedScenes ? app.connectedScenes.allObjects : null;
617
+ let targetScene;
618
+ if (all) {
619
+ for (let i = 0; i < all.count; i++) {
620
+ const s = all.objectAtIndex(i);
621
+ // Only UIWindowScene exposes `windows`; prefer a foreground-active one.
622
+ if (s && typeof s.windows !== 'undefined') {
623
+ targetScene = s;
624
+ if (s.activationState === 0 /* UISceneActivationState.ForegroundActive */) {
625
+ break;
626
+ }
627
+ }
628
+ }
629
+ }
630
+ if (targetScene) {
631
+ window = UIWindow.alloc().initWithWindowScene(targetScene);
632
+ if (!__VISIONOS__) {
633
+ window.backgroundColor = SDK_VERSION <= 12 || !UIColor.systemBackgroundColor ? UIColor.whiteColor : UIColor.systemBackgroundColor;
634
+ }
635
+ // The registry lives in JS and was lost with the previous isolate, so
636
+ // the still-connected scene needs a fresh NativeWindow to be reachable.
637
+ const isPrimary = !this.primaryWindow;
638
+ const nativeWindow = new IOSNativeWindow(targetScene, window, IOSNativeWindow.getSceneId(targetScene), isPrimary);
639
+ this._registerWindow(nativeWindow);
640
+ if (isPrimary) {
641
+ setiOSWindow(window);
642
+ }
643
+ // If the scene's delegate was recreated after a soft reboot, point it
644
+ // at the new window so `scene.delegate.window` queries resolve.
645
+ const freshSceneDelegate = this._softRebootSceneDelegates.get(targetScene);
646
+ if (freshSceneDelegate) {
647
+ freshSceneDelegate.window = window;
648
+ }
649
+ }
650
+ }
248
651
  if (!window) {
249
652
  return;
250
653
  }
654
+ // May be null on a freshly recreated window — expected; the replace-root
655
+ // path below sets it. Only the embedder path needs an existing controller.
251
656
  const rootController = window.rootViewController;
252
- if (!rootController) {
657
+ const embedderDelegate = NativeScriptEmbedder.sharedInstance().delegate;
658
+ // Embed into host app requires an existing root view controller
659
+ if (embedderDelegate && !rootController) {
253
660
  return;
254
661
  }
255
- const controller = this.getViewController(rootView);
256
- const embedderDelegate = NativeScriptEmbedder.sharedInstance().delegate;
257
- rootView._setupAsRootView({});
258
- rootView.on(IOSHelper.traitCollectionColorAppearanceChangedEvent, () => {
259
- const userInterfaceStyle = controller.traitCollection.userInterfaceStyle;
260
- const newSystemAppearance = this.getSystemAppearanceValue(userInterfaceStyle);
261
- this.setSystemAppearance(newSystemAppearance);
262
- });
263
- rootView.on(IOSHelper.traitCollectionLayoutDirectionChangedEvent, () => {
264
- const layoutDirection = controller.traitCollection.layoutDirection;
265
- const newLayoutDirection = this.getLayoutDirectionValue(layoutDirection);
266
- this.setLayoutDirection(newLayoutDirection);
267
- });
268
- if (embedderDelegate) {
269
- this.setViewControllerView(rootView);
270
- embedderDelegate.presentNativeScriptApp(controller);
662
+ let hostWindow = this.primaryWindow;
663
+ if (!hostWindow) {
664
+ // Only an embedder delegate makes this window a guest: without one NativeScript
665
+ // owns the UIApplication and the window has to attach its own content.
666
+ const role = embedderDelegate ? 'embedded' : 'application';
667
+ hostWindow = new IOSNativeWindow(window.windowScene ?? undefined, window, 'embedded-main', true, role);
668
+ this._registerWindow(hostWindow);
669
+ hostWindow._notifyEvent(NativeWindowEvents.attached);
271
670
  }
272
- else {
273
- const visibleVC = iosUtils.getVisibleViewController(rootController);
274
- visibleVC.presentViewControllerAnimatedCompletion(controller, true, null);
275
- }
276
- this.initRootView(rootView);
671
+ hostWindow.setContent(rootView);
277
672
  this.notifyAppStarted();
278
673
  }
674
+ /**
675
+ * After an in-process soft reboot (NativeScriptRuntime.reloadApplication /
676
+ * restartWithConfig), the Objective-C delegate classes created by the
677
+ * previous JS isolate still exist and UIKit keeps dispatching to their
678
+ * now-inert instances: their method callbacks bail out because the isolate
679
+ * that implemented them is gone. Notification-center observers are
680
+ * re-registered by the new isolate, but delegate-based dispatch (custom
681
+ * UIApplicationDelegate methods like push-token/openURL callbacks, and the
682
+ * UIScene delegates used by scene-lifecycle apps) stays pinned to the old
683
+ * bundle. Recreate those delegates from this bundle's classes and re-point
684
+ * UIKit at them.
685
+ */
686
+ _reattachNativeDelegatesAfterSoftReboot() {
687
+ if (getRuntimeReloadCount() <= 0) {
688
+ // First boot: UIApplicationMain (or the host app) set up delegates.
689
+ return;
690
+ }
691
+ if (isEmbedded()) {
692
+ // The host app owns the UIApplication delegate; never touch it.
693
+ return;
694
+ }
695
+ const app = UIApplication.sharedApplication;
696
+ if (!app) {
697
+ return;
698
+ }
699
+ // Fresh application delegate from the new bundle. Assigning `delegate`
700
+ // does not retain (unlike the UIApplicationMain launch path), so keep a
701
+ // strong reference ourselves.
702
+ this.delegate ?? (this.delegate = Responder);
703
+ const freshDelegate = this.delegate.new();
704
+ this._softRebootAppDelegate = freshDelegate;
705
+ app.delegate = freshDelegate;
706
+ // Re-point already-connected scenes at fresh scene delegates so scene
707
+ // lifecycle and user-implemented scene delegate methods (shortcuts,
708
+ // openURLContexts, userActivity continuation, etc.) reach this isolate.
709
+ // Newly connecting scenes are covered by the fresh application delegate's
710
+ // applicationConfigurationForConnectingSceneSessionOptions, which returns
711
+ // this bundle's SceneDelegate class.
712
+ if (this.supportsScenes()) {
713
+ this._softRebootSceneDelegates.clear();
714
+ const scenes = app.connectedScenes?.allObjects;
715
+ for (let i = 0; scenes && i < scenes.count; i++) {
716
+ const scene = scenes.objectAtIndex(i);
717
+ if (!(scene instanceof UIWindowScene)) {
718
+ continue;
719
+ }
720
+ const freshSceneDelegate = SceneDelegate.new();
721
+ scene.delegate = freshSceneDelegate;
722
+ this._softRebootSceneDelegates.set(scene, freshSceneDelegate);
723
+ }
724
+ }
725
+ if (Trace.isEnabled()) {
726
+ Trace.write(`Reattached application delegate${this._softRebootSceneDelegates.size ? ` and ${this._softRebootSceneDelegates.size} scene delegate(s)` : ''} after soft reboot (reloadCount: ${getRuntimeReloadCount()})`, Trace.categories.NativeLifecycle);
727
+ }
728
+ }
279
729
  getViewController(rootView) {
280
730
  let viewController = rootView.viewController || rootView.ios;
281
731
  if (!(viewController instanceof UIViewController)) {
@@ -357,15 +807,74 @@ export class iOSApplication extends ApplicationCommon {
357
807
  set delegate(value) {
358
808
  if (this._delegate !== value) {
359
809
  this._delegate = value;
810
+ if (value) {
811
+ warnAboutDelegateClass(value, this.started);
812
+ installSceneDelegateDefaults(value);
813
+ }
814
+ }
815
+ }
816
+ /**
817
+ * NativeScript's default implementation of the `UIApplicationDelegate`
818
+ * `applicationConfigurationForConnectingSceneSessionOptions` method.
819
+ *
820
+ * It is installed automatically on the application delegate class unless that class
821
+ * already implements the method. A delegate that does implement it can handle the
822
+ * scenes it cares about and forward the rest here:
823
+ *
824
+ * ```ts
825
+ * applicationConfigurationForConnectingSceneSessionOptions(app, session, options) {
826
+ * if (session.role === myCustomRole) {
827
+ * return myConfig;
828
+ * }
829
+ * return Application.ios.defaultSceneConfiguration(app, session, options);
830
+ * }
831
+ * ```
832
+ *
833
+ * `onSceneConfiguration` is consulted first. Scenes with the
834
+ * `UIWindowSceneSessionRoleApplication` role then get a configuration backed by
835
+ * NativeScript's SceneDelegate; every other role gets a bare configuration that
836
+ * NativeScript does not manage.
837
+ */
838
+ defaultSceneConfiguration(application, connectingSceneSession, options) {
839
+ // Let the user intercept scene configuration for any/all scenes
840
+ const userHandler = this._onSceneConfiguration;
841
+ if (userHandler) {
842
+ const userConfig = userHandler(application, connectingSceneSession, options);
843
+ if (userConfig) {
844
+ return userConfig;
845
+ }
360
846
  }
847
+ // Only handle the standard window scene role — skip CarPlay, external displays, etc.
848
+ if (connectingSceneSession.role !== UIWindowSceneSessionRoleApplication) {
849
+ // Return a bare configuration so iOS doesn't crash, but NativeScript won't manage it
850
+ return UISceneConfiguration.configurationWithNameSessionRole('Unmanaged', connectingSceneSession.role);
851
+ }
852
+ const config = UISceneConfiguration.configurationWithNameSessionRole('Default Configuration', connectingSceneSession.role);
853
+ config.sceneClass = UIWindowScene;
854
+ config.delegateClass = SceneDelegate;
855
+ return config;
856
+ }
857
+ /**
858
+ * NativeScript's default implementation of the `UIApplicationDelegate`
859
+ * `applicationDidDiscardSceneSessions` method, which retires the `NativeWindow`s
860
+ * belonging to the discarded sessions.
861
+ *
862
+ * It is installed automatically on the application delegate class unless that class
863
+ * already implements the method, in which case forward to it from there so window
864
+ * bookkeeping stays correct.
865
+ */
866
+ defaultDiscardSceneSessions(application, sceneSessions) {
867
+ this._onSceneSessionsDiscarded(sceneSessions);
361
868
  }
362
869
  addDelegateHandler(methodName, handler) {
363
870
  // safe-guard against invalid handlers
364
871
  if (typeof handler !== 'function') {
365
872
  return;
366
873
  }
367
- // ensure we have a delegate
368
- this.delegate ?? (this.delegate = Responder);
874
+ // ensure we have a delegate; Responder already carries the defaults, so it is
875
+ // stored directly rather than through the setter, whose warnings only apply to
876
+ // a delegate class the app supplied.
877
+ this._delegate ?? (this._delegate = Responder);
369
878
  const handlers = this._delegateHandlers.get(methodName) ?? [];
370
879
  if (!this._delegateHandlers.has(methodName)) {
371
880
  const originalHandler = this.delegate.prototype[methodName];
@@ -407,11 +916,12 @@ export class iOSApplication extends ApplicationCommon {
407
916
  }
408
917
  getSystemAppearance() {
409
918
  // userInterfaceStyle is available on UITraitCollection since iOS 12.
410
- if ((!__VISIONOS__ && SDK_VERSION <= 11) || !this.rootController) {
919
+ if (!__VISIONOS__ && SDK_VERSION <= 11) {
411
920
  return null;
412
921
  }
413
- const userInterfaceStyle = this.rootController.traitCollection.userInterfaceStyle;
414
- return this.getSystemAppearanceValue(userInterfaceStyle);
922
+ // the launch event fires before the window has a root view controller: the screen traits are enough then
923
+ const traits = this.rootController?.traitCollection ?? this.window?.traitCollection ?? UIScreen.mainScreen.traitCollection;
924
+ return this.getSystemAppearanceValue(traits.userInterfaceStyle);
415
925
  }
416
926
  getSystemAppearanceValue(userInterfaceStyle) {
417
927
  switch (userInterfaceStyle) {
@@ -471,7 +981,6 @@ export class iOSApplication extends ApplicationCommon {
471
981
  return [newOrientation, degrees];
472
982
  }
473
983
  notifyAppStarted(notification) {
474
- this.launchEventCalled = true;
475
984
  const root = this.notifyLaunch({
476
985
  ios: notification?.userInfo?.objectForKey('UIApplicationLaunchOptionsLocalNotificationKey') ?? null,
477
986
  });
@@ -484,10 +993,6 @@ export class iOSApplication extends ApplicationCommon {
484
993
  setiOSWindow(this.window);
485
994
  }
486
995
  }
487
- // Public method for scene-based app startup
488
- _notifySceneAppStarted() {
489
- this.notifyAppStarted();
490
- }
491
996
  _onLivesync(context) {
492
997
  // Handle application root module
493
998
  const isAppRootModuleChanged = context && context.path && context.path.includes(this.getMainEntry().moduleName) && context.type !== 'style';
@@ -502,15 +1007,64 @@ export class iOSApplication extends ApplicationCommon {
502
1007
  }
503
1008
  }
504
1009
  setWindowContent(view) {
1010
+ const userView = this.createRootView(view);
1011
+ const primaryWindow = this.primaryWindow;
1012
+ if (primaryWindow) {
1013
+ this.setHostedWindowContent(primaryWindow, userView);
1014
+ return;
1015
+ }
1016
+ this.setWindowContentFallback(userView);
1017
+ }
1018
+ /**
1019
+ * Installs `userView` as the content of `window`, hosted in a ContentView which is the
1020
+ * window's actual root view (see `_contentHosts`).
1021
+ */
1022
+ setHostedWindowContent(window, userView) {
1023
+ const host = createContentView();
1024
+ this._contentHosts.add(host);
1025
+ // Sets the host up as a root view (CSS classes, native controller) and, for the primary
1026
+ // window, raises `initRootView` for it through `contentLoaded` -> `adoptRootView`.
1027
+ window.setContent(host);
1028
+ this.attachUserRootView(host, userView);
1029
+ }
1030
+ attachUserRootView(host, userView) {
1031
+ if (!userView) {
1032
+ // no root view created
1033
+ return;
1034
+ }
1035
+ if (userView.parent) {
1036
+ userView.parent._removeView(userView);
1037
+ }
1038
+ host.content = userView;
1039
+ }
1040
+ /**
1041
+ * The primary window's content is hosted in a ContentView so `Application.getRootView()`
1042
+ * and the first CSS pass behave as before NativeWindow. Other windows get the resolved
1043
+ * view as their root directly.
1044
+ * TODO(merge): secondary windows are not hosted in a ContentView.
1045
+ */
1046
+ _resolveWindowContent(window, request, options) {
1047
+ if (!window.isPrimary || options?.install === false) {
1048
+ return super._resolveWindowContent(window, request, options);
1049
+ }
1050
+ const userView = super._resolveWindowContent(window, request, { ...options, install: false });
1051
+ if (!userView) {
1052
+ return null;
1053
+ }
1054
+ this.setHostedWindowContent(window, userView);
1055
+ return userView;
1056
+ }
1057
+ /**
1058
+ * Attaches content to the raw `UIWindow`. Every launch path registers a primary
1059
+ * NativeWindow, so this only runs when no window is left to own the content.
1060
+ */
1061
+ setWindowContentFallback(userView) {
505
1062
  if (this._rootView) {
506
- // if we already have a root view, we reset it.
507
1063
  this._rootView._onRootViewReset();
508
1064
  }
509
- // TODO: using import crashes. it creates a circular dependency which is tricky to fix right now
510
- const rootView = new ContentView();
1065
+ const rootView = createContentView();
1066
+ this._contentHosts.add(rootView);
511
1067
  const controller = this.getViewController(rootView);
512
- this._rootView = rootView;
513
- setRootView(rootView);
514
1068
  // setup view as styleScopeHost
515
1069
  rootView._setupAsRootView({});
516
1070
  this.setViewControllerView(rootView);
@@ -520,28 +1074,8 @@ export class iOSApplication extends ApplicationCommon {
520
1074
  if (!haveController) {
521
1075
  win.makeKeyAndVisible();
522
1076
  }
523
- this.initRootView(rootView);
524
- rootView.on(IOSHelper.traitCollectionColorAppearanceChangedEvent, () => {
525
- const userInterfaceStyle = controller.traitCollection.userInterfaceStyle;
526
- const newSystemAppearance = this.getSystemAppearanceValue(userInterfaceStyle);
527
- this.setSystemAppearance(newSystemAppearance);
528
- });
529
- rootView.on(IOSHelper.traitCollectionLayoutDirectionChangedEvent, () => {
530
- const layoutDirection = controller.traitCollection.layoutDirection;
531
- const newLayoutDirection = this.getLayoutDirectionValue(layoutDirection);
532
- this.setLayoutDirection(newLayoutDirection);
533
- });
534
- let subRootView = this._subRootView;
535
- subRootView = this.createRootView(view);
536
- if (!subRootView) {
537
- // no root view created
538
- return;
539
- }
540
- this._subRootView = subRootView;
541
- if (subRootView.parent) {
542
- subRootView.parent._removeView(subRootView);
543
- }
544
- rootView.content = subRootView;
1077
+ this.adoptRootView(rootView);
1078
+ this.attachUserRootView(rootView, userView);
545
1079
  }
546
1080
  // Observers
547
1081
  didFinishLaunchingWithOptions(notification) {
@@ -559,6 +1093,8 @@ export class iOSApplication extends ApplicationCommon {
559
1093
  }
560
1094
  }
561
1095
  }
1096
+ // Must precede every window registration below and every scene connect that follows.
1097
+ this.notifyReady();
562
1098
  this.setMaxRefreshRate();
563
1099
  // Only set up window if NOT using scene-based lifecycle
564
1100
  if (!this.supportsScenes()) {
@@ -572,9 +1108,25 @@ export class iOSApplication extends ApplicationCommon {
572
1108
  if (!__VISIONOS__) {
573
1109
  this.window.backgroundColor = SDK_VERSION <= 12 || !UIColor.systemBackgroundColor ? UIColor.whiteColor : UIColor.systemBackgroundColor;
574
1110
  }
575
- this.launchEventCalled = false;
576
- if (!this.shouldDelayLaunchEvent) {
577
- this.notifyAppStarted();
1111
+ if (!this.primaryWindow) {
1112
+ const nativeWindow = new IOSNativeWindow(undefined, this.window, 'main', true, 'application');
1113
+ this._registerWindow(nativeWindow);
1114
+ nativeWindow._notifyEvent(NativeWindowEvents.attached);
1115
+ }
1116
+ const primaryWindow = this.primaryWindow;
1117
+ const resolveContent = () => this._resolveWindowContent(primaryWindow, {
1118
+ window: primaryWindow,
1119
+ isPrimary: true,
1120
+ }, {
1121
+ launchData: {
1122
+ ios: notification?.userInfo?.objectForKey('UIApplicationLaunchOptionsLocalNotificationKey') ?? null,
1123
+ },
1124
+ });
1125
+ if (this.shouldDelayLaunchEvent) {
1126
+ this._pendingWindowContentResolve = resolveContent;
1127
+ }
1128
+ else {
1129
+ resolveContent();
578
1130
  }
579
1131
  }
580
1132
  else {
@@ -582,36 +1134,42 @@ export class iOSApplication extends ApplicationCommon {
582
1134
  }
583
1135
  }
584
1136
  didBecomeActive(notification) {
585
- if (!this.launchEventCalled) {
586
- this.notifyAppStarted(notification);
587
- }
588
- const additionalData = {
589
- ios: UIApplication.sharedApplication,
590
- };
591
- this.setInBackground(false, additionalData);
592
- this.setSuspended(false, additionalData);
593
- const rootView = this._rootView;
594
- if (rootView && !rootView.isLoaded) {
595
- rootView.callLoaded();
1137
+ const pendingWindowContentResolve = this._pendingWindowContentResolve;
1138
+ if (pendingWindowContentResolve) {
1139
+ this._pendingWindowContentResolve = null;
1140
+ pendingWindowContentResolve();
1141
+ }
1142
+ // A scene app derives app-level state from its windows, so this notification must not
1143
+ // drive it as well. In scene mode the root view belongs to a window too, so the scene
1144
+ // delegate loads it.
1145
+ if (!this.supportsScenes()) {
1146
+ const additionalData = {
1147
+ ios: UIApplication.sharedApplication,
1148
+ };
1149
+ this.setInBackground(false, additionalData);
1150
+ this.setSuspended(false, additionalData);
1151
+ const rootView = this._rootView;
1152
+ if (rootView && !rootView.isLoaded) {
1153
+ rootView.callLoaded();
1154
+ }
596
1155
  }
597
1156
  }
598
1157
  didEnterBackground(notification) {
599
- const additionalData = {
600
- ios: UIApplication.sharedApplication,
601
- };
602
- this.setInBackground(true, additionalData);
603
- this.setSuspended(true, additionalData);
604
- const rootView = this._rootView;
605
- if (rootView && rootView.isLoaded) {
606
- rootView.callUnloaded();
1158
+ // See didBecomeActive: in scene mode the windows drive app-level state.
1159
+ if (!this.supportsScenes()) {
1160
+ const additionalData = {
1161
+ ios: UIApplication.sharedApplication,
1162
+ };
1163
+ this.setInBackground(true, additionalData);
1164
+ this.setSuspended(true, additionalData);
1165
+ const rootView = this._rootView;
1166
+ if (rootView && rootView.isLoaded) {
1167
+ rootView.callUnloaded();
1168
+ }
607
1169
  }
608
1170
  }
609
1171
  willTerminate(notification) {
610
- this.notify({
611
- eventName: this.exitEvent,
612
- object: this,
613
- ios: this.ios,
614
- });
1172
+ this.notifyExit({ ios: this.ios });
615
1173
  // const rootView = this._rootView;
616
1174
  // if (rootView && rootView.isLoaded) {
617
1175
  // rootView.callUnloaded();
@@ -625,151 +1183,150 @@ export class iOSApplication extends ApplicationCommon {
625
1183
  });
626
1184
  }
627
1185
  didChangeStatusBarOrientation(notification) {
628
- const statusBarOrientation = UIApplication.sharedApplication.statusBarOrientation;
629
- const [newOrientation, degrees] = this.getOrientationValue(statusBarOrientation);
630
- this.setOrientation(newOrientation, degrees);
631
- }
632
- // Scene lifecycle notification handlers
633
- sceneWillConnect(notification) {
634
- const scene = notification.object;
635
- if (!scene || !(scene instanceof UIWindowScene)) {
636
- return;
637
- }
638
- // Store as primary scene if it's the first one
639
- if (!this._primaryScene) {
640
- this._primaryScene = scene;
1186
+ // The notification is app-wide, but scenes rotate independently, so every attached
1187
+ // window is refreshed from its own scene.
1188
+ for (const nativeWindow of this._windows) {
1189
+ nativeWindow._syncOrientation();
641
1190
  }
642
- this.notify({
643
- eventName: SceneEvents.sceneWillConnect,
644
- object: this,
645
- scene: scene,
646
- userInfo: notification.userInfo,
647
- });
648
1191
  }
649
- sceneDidActivate(notification) {
650
- const scene = notification.object;
651
- this.notify({
652
- eventName: SceneEvents.sceneDidActivate,
653
- object: this,
654
- scene: scene,
655
- });
656
- // If this is the primary scene, trigger traditional app lifecycle
657
- if (scene === this._primaryScene) {
658
- const additionalData = {
659
- ios: UIApplication.sharedApplication,
660
- scene: scene,
661
- };
662
- this.setInBackground(false, additionalData);
663
- this.setSuspended(false, additionalData);
664
- if (this._rootView && !this._rootView.isLoaded) {
665
- this._rootView.callLoaded();
666
- }
1192
+ // --- App-level root view mirror ---
1193
+ /**
1194
+ * Keeps the app-level root view state (`getRootView()`, the global root view and the
1195
+ * `initRootView` event) following whatever the primary window shows.
1196
+ */
1197
+ mirrorPrimaryWindow(nativeWindow) {
1198
+ if (this._mirroredWindow === nativeWindow) {
1199
+ return;
1200
+ }
1201
+ this._mirroredWindow?.off(NativeWindowEvents.contentLoaded, this.onPrimaryWindowContentLoaded, this);
1202
+ this._mirroredWindow = nativeWindow;
1203
+ nativeWindow.on(NativeWindowEvents.contentLoaded, this.onPrimaryWindowContentLoaded, this);
1204
+ if (nativeWindow.rootView && nativeWindow.rootView !== this._rootView) {
1205
+ this.adoptRootView(nativeWindow.rootView);
667
1206
  }
668
1207
  }
669
- sceneWillEnterForeground(notification) {
670
- const scene = notification.object;
671
- this.notify({
672
- eventName: SceneEvents.sceneWillEnterForeground,
673
- object: this,
674
- scene: scene,
675
- });
1208
+ onPrimaryWindowContentLoaded(data) {
1209
+ this.adoptRootView(data.window.rootView);
676
1210
  }
677
- sceneDidEnterBackground(notification) {
678
- const scene = notification.object;
679
- this.notify({
680
- eventName: SceneEvents.sceneDidEnterBackground,
681
- object: this,
682
- scene: scene,
683
- });
684
- // If this is the primary scene, trigger traditional app lifecycle
685
- if (scene === this._primaryScene) {
686
- const additionalData = {
687
- ios: UIApplication.sharedApplication,
688
- scene: scene,
689
- };
690
- this.setInBackground(true, additionalData);
691
- this.setSuspended(true, additionalData);
692
- if (this._rootView && this._rootView.isLoaded) {
693
- this._rootView.callUnloaded();
694
- }
1211
+ adoptRootView(rootView) {
1212
+ if (!rootView) {
1213
+ return;
695
1214
  }
1215
+ this._rootView = rootView;
1216
+ setRootView(rootView);
1217
+ this.initRootView(rootView, this._mirroredWindow);
696
1218
  }
697
- sceneDidDisconnect(notification) {
698
- const scene = notification.object;
699
- this._removeWindowForScene(scene);
700
- // If primary scene disconnected, clear it
701
- if (scene === this._primaryScene) {
702
- this._primaryScene = null;
1219
+ // --- NativeWindow registry ---
1220
+ /**
1221
+ * @internal - hands the discarded sessions' ids to the window registry, which decides
1222
+ * which of them name a window that is actually finished with.
1223
+ */
1224
+ _onSceneSessionsDiscarded(sessions) {
1225
+ const all = sessions?.allObjects;
1226
+ if (!all) {
1227
+ return;
703
1228
  }
704
- if (this._primaryScene) {
705
- if (SDK_VERSION >= 17) {
706
- const request = UISceneSessionActivationRequest.requestWithSession(this._primaryScene.session);
707
- UIApplication.sharedApplication.activateSceneSessionForRequestErrorHandler(request, (err) => {
708
- if (err) {
709
- console.log('Failed to activate primary scene:', err.localizedDescription);
710
- }
711
- });
712
- }
713
- else {
714
- UIApplication.sharedApplication.requestSceneSessionActivationUserActivityOptionsErrorHandler(this._primaryScene.session, null, null, (err) => {
715
- if (err) {
716
- console.log('Failed to activate primary scene (legacy):', err.localizedDescription);
717
- }
718
- });
1229
+ const ids = [];
1230
+ for (let i = 0; i < all.count; i++) {
1231
+ const persistentIdentifier = all.objectAtIndex(i)?.persistentIdentifier;
1232
+ if (persistentIdentifier) {
1233
+ ids.push(`${persistentIdentifier}`);
719
1234
  }
720
1235
  }
721
- this.notify({
722
- eventName: SceneEvents.sceneDidDisconnect,
723
- object: this,
724
- scene: scene,
725
- });
1236
+ this._retireDiscardedWindows(ids);
726
1237
  }
727
- // Scene management helper methods
728
- _setWindowForScene(window, scene) {
729
- this._windowSceneMap.set(scene, window);
1238
+ /**
1239
+ * @internal - Get a NativeWindow by its scene.
1240
+ */
1241
+ _getWindowForScene(scene) {
1242
+ return this._windows.find((nw) => nw.ios?.scene === scene);
730
1243
  }
731
- _removeWindowForScene(scene) {
732
- this._windowSceneMap.delete(scene);
733
- // also untrack opened scene id
734
- try {
735
- const s = scene;
736
- if (s && s.session) {
737
- const id = this._getSceneId(s);
738
- this._openedScenesById.delete(id);
739
- }
1244
+ /**
1245
+ * @internal - Feeds a window's foreground state into the application-level
1246
+ * 'foreground'/'background' events, which describe the app as a whole: they are raised
1247
+ * when the first application-role window enters the foreground and when the last one
1248
+ * leaves it. Windows in any other role never speak for the app.
1249
+ */
1250
+ _setWindowInForeground(nativeWindow, inForeground, scene) {
1251
+ if (this._trackWindowState(this._foregroundWindows, nativeWindow, inForeground)) {
1252
+ this.setInBackground(!inForeground, {
1253
+ ios: UIApplication.sharedApplication,
1254
+ scene,
1255
+ });
740
1256
  }
741
- catch { }
742
1257
  }
743
- _getWindowForScene(scene) {
744
- return this._windowSceneMap.get(scene);
1258
+ /**
1259
+ * @internal - Feeds a window's active state into the application-level 'resume'/'suspend'
1260
+ * events, raised when the first application-role window becomes active and when the last
1261
+ * active one resigns.
1262
+ */
1263
+ _setWindowActive(nativeWindow, active, scene) {
1264
+ if (this._trackWindowState(this._activeWindows, nativeWindow, active)) {
1265
+ this.setSuspended(!active, {
1266
+ ios: UIApplication.sharedApplication,
1267
+ scene,
1268
+ });
1269
+ }
745
1270
  }
746
- _setupWindowForScene(window, scene) {
747
- if (!window) {
748
- return;
1271
+ /**
1272
+ * @returns whether the set flipped between empty and non-empty, which is the only point
1273
+ * at which app-level state changes.
1274
+ */
1275
+ _trackWindowState(windows, nativeWindow, member) {
1276
+ if (nativeWindow?.role !== 'application') {
1277
+ return false;
749
1278
  }
750
- // track opened scene
751
- try {
752
- const id = this._getSceneId(scene);
753
- this._openedScenesById.set(id, scene);
1279
+ const wasPopulated = windows.size > 0;
1280
+ if (member) {
1281
+ windows.add(nativeWindow);
754
1282
  }
755
- catch { }
756
- // Set up window background
757
- if (!__VISIONOS__) {
758
- window.backgroundColor = SDK_VERSION <= 12 || !UIColor.systemBackgroundColor ? UIColor.whiteColor : UIColor.systemBackgroundColor;
1283
+ else {
1284
+ windows.delete(nativeWindow);
759
1285
  }
760
- // If this is the primary scene, set up the main application content
761
- if (scene === this._primaryScene || !this._primaryScene) {
762
- this._primaryScene = scene;
763
- if (!getiOSWindow()) {
764
- setiOSWindow(window);
765
- }
766
- // During initial scene startup we must wait for launch to be notified first.
767
- // Some frameworks provide root content from launch handlers.
768
- if (this.hasLaunched()) {
769
- this.setWindowContent();
770
- }
1286
+ return wasPopulated !== windows.size > 0;
1287
+ }
1288
+ _onWindowRegistered(nativeWindow) {
1289
+ if (nativeWindow.isPrimary) {
1290
+ this.mirrorPrimaryWindow(nativeWindow);
771
1291
  }
772
1292
  }
1293
+ _onPrimaryWindowPromoted(nativeWindow) {
1294
+ const promotedWindow = nativeWindow.ios?.uiWindow;
1295
+ if (promotedWindow) {
1296
+ setiOSWindow(promotedWindow);
1297
+ }
1298
+ this.mirrorPrimaryWindow(nativeWindow);
1299
+ }
1300
+ /**
1301
+ * Register a callback to intercept scene configuration.
1302
+ *
1303
+ * Called for every new scene session. Return a `UISceneConfiguration` to handle
1304
+ * the scene yourself (e.g. CarPlay, external display), or return `null`/`undefined`
1305
+ * to let NativeScript handle it with the default SceneDelegate.
1306
+ *
1307
+ * NativeScript only auto-manages `UIWindowSceneSessionRoleApplication` scenes.
1308
+ * All other scene roles are ignored unless you provide a configuration here.
1309
+ *
1310
+ * @example
1311
+ * ```ts
1312
+ * Application.ios.onSceneConfiguration = (app, session, options) => {
1313
+ * if (session.role === CPTemplateApplicationSceneSessionRoleApplication) {
1314
+ * const config = UISceneConfiguration.configurationWithNameSessionRole('CarPlay', session.role);
1315
+ * config.delegateClass = MyCarPlaySceneDelegate;
1316
+ * return config;
1317
+ * }
1318
+ * // Return null to let NativeScript handle the default window scene
1319
+ * return null;
1320
+ * };
1321
+ * ```
1322
+ */
1323
+ set onSceneConfiguration(handler) {
1324
+ this._onSceneConfiguration = handler;
1325
+ }
1326
+ get onSceneConfiguration() {
1327
+ return this._onSceneConfiguration;
1328
+ }
1329
+ // Scene management helper methods (kept for backward compat)
773
1330
  get sceneDelegate() {
774
1331
  if (!this._sceneDelegate) {
775
1332
  this._sceneDelegate = SceneDelegate.new();
@@ -783,10 +1340,12 @@ export class iOSApplication extends ApplicationCommon {
783
1340
  * Multi-window support
784
1341
  */
785
1342
  /**
786
- * Opens a new window with the specified data.
787
- * @param data The data to pass to the new window.
1343
+ * Opens a new window (scene).
1344
+ *
1345
+ * @param options Options for the new window. `options.data` is serialized into the
1346
+ * activating scene's `NSUserActivity.userInfo`.
788
1347
  */
789
- openWindow(data) {
1348
+ openWindow(options) {
790
1349
  if (!supportsMultipleScenes()) {
791
1350
  console.log('Cannot create a new scene - not supported on this device.');
792
1351
  return;
@@ -795,34 +1354,18 @@ export class iOSApplication extends ApplicationCommon {
795
1354
  const app = UIApplication.sharedApplication;
796
1355
  // iOS 17+
797
1356
  if (SDK_VERSION >= 17) {
798
- // Create a new scene activation request with proper role
799
1357
  let request;
800
1358
  try {
801
- // Use the correct factory method to create request with role
802
- // Based on the type definitions, this is the proper way
803
1359
  request = UISceneSessionActivationRequest.requestWithRole(UIWindowSceneSessionRoleApplication);
804
- // Note: may be useful to allow user defined activity type through optional string typed data in future
805
- const activity = NSUserActivity.alloc().initWithActivityType(`${NSBundle.mainBundle.bundleIdentifier}.scene`);
806
- activity.userInfo = dataSerialize(data);
1360
+ const activity = NSUserActivity.alloc().initWithActivityType(getSceneActivityType());
1361
+ activity.userInfo = dataSerialize(options?.data ?? {});
807
1362
  request.userActivity = activity;
808
- // Set proper options with requesting scene
809
- const options = UISceneActivationRequestOptions.new();
810
- // Note: explore secondary windows spawning other windows
811
- // and if this context needs to change in those cases
812
- const mainWindow = Application.ios.getPrimaryWindow();
813
- options.requestingScene = mainWindow?.windowScene;
814
- /**
815
- * Note: This does not work in testing but worth exploring further sometime
816
- * regarding the size/dimensions of opened secondary windows.
817
- * The initial size is ultimately determined by the system
818
- * based on available space and user context.
819
- */
820
- // Get the size restrictions from the window scene
821
- // const sizeRestrictions = (options.requestingScene as UIWindowScene).sizeRestrictions;
822
- // // Set your minimum and maximum dimensions
823
- // sizeRestrictions.minimumSize = CGSizeMake(320, 400);
824
- // sizeRestrictions.maximumSize = CGSizeMake(600, 800);
825
- request.options = options;
1363
+ const activationOptions = UISceneActivationRequestOptions.new();
1364
+ const primary = this.primaryWindow;
1365
+ if (primary?.ios?.scene) {
1366
+ activationOptions.requestingScene = primary.ios.scene;
1367
+ }
1368
+ request.options = activationOptions;
826
1369
  }
827
1370
  catch (roleError) {
828
1371
  console.log('Error creating request:', roleError);
@@ -831,32 +1374,25 @@ export class iOSApplication extends ApplicationCommon {
831
1374
  app.activateSceneSessionForRequestErrorHandler(request, (error) => {
832
1375
  if (error) {
833
1376
  console.log('Error creating new scene (iOS 17+):', error);
834
- // Log additional debugging info
835
1377
  if (error.userInfo) {
836
1378
  console.error(`Error userInfo: ${error.userInfo.description}`);
837
1379
  }
838
- // Handle specific error types
839
1380
  if (error.localizedDescription.includes('role') && error.localizedDescription.includes('nil')) {
840
- this.createSceneWithLegacyAPI(data);
1381
+ this.createSceneWithLegacyAPI(options?.data);
841
1382
  }
842
1383
  else if (error.domain === 'FBSWorkspaceErrorDomain' && error.code === 2) {
843
- this.createSceneWithLegacyAPI(data);
1384
+ this.createSceneWithLegacyAPI(options?.data);
844
1385
  }
845
1386
  }
846
1387
  });
847
1388
  }
848
- // iOS 13-16 - Use the legacy requestSceneSessionActivationUserActivityOptionsErrorHandler method
849
1389
  else if (SDK_VERSION >= 13 && SDK_VERSION < 17) {
850
- app.requestSceneSessionActivationUserActivityOptionsErrorHandler(null, // session
851
- null, // userActivity
852
- null, // options
853
- (error) => {
1390
+ app.requestSceneSessionActivationUserActivityOptionsErrorHandler(null, null, null, (error) => {
854
1391
  if (error) {
855
1392
  console.log('Error creating new scene (legacy):', error);
856
1393
  }
857
1394
  });
858
1395
  }
859
- // Fallback for older iOS versions or unsupported configurations
860
1396
  else {
861
1397
  console.log('Neither new nor legacy scene activation methods are available');
862
1398
  }
@@ -867,71 +1403,66 @@ export class iOSApplication extends ApplicationCommon {
867
1403
  }
868
1404
  /**
869
1405
  * Closes a secondary window/scene.
870
- * Usage examples:
871
- * - Application.ios.closeWindow() // best-effort close of a non-primary scene
872
- * - Application.ios.closeWindow(button) // from a tap handler within the scene
873
- * - Application.ios.closeWindow(window)
874
- * - Application.ios.closeWindow(scene)
875
- * - Application.ios.closeWindow('scene-id')
1406
+ * Accepts a NativeWindow, View, UIWindow, UIWindowScene, or string id.
876
1407
  */
877
1408
  closeWindow(target) {
878
1409
  if (!__APPLE__) {
879
1410
  return;
880
1411
  }
881
1412
  try {
882
- const scene = this._resolveScene(target);
883
- if (!scene) {
884
- console.log('closeWindow: No scene resolved for target');
885
- return;
1413
+ let nativeWindow;
1414
+ if (target instanceof NativeWindow) {
1415
+ nativeWindow = target;
886
1416
  }
887
- // Don't allow closing the primary scene
888
- if (scene === this._primaryScene) {
889
- console.log('closeWindow: Refusing to close the primary scene');
890
- return;
1417
+ else {
1418
+ const scene = this._resolveScene(target);
1419
+ if (scene) {
1420
+ nativeWindow = this._getWindowForScene(scene);
1421
+ }
891
1422
  }
892
- const session = scene.session;
893
- if (!session) {
894
- console.log('closeWindow: Scene has no session to destroy');
1423
+ if (!nativeWindow) {
1424
+ console.log('closeWindow: No window resolved for target');
895
1425
  return;
896
1426
  }
897
- const app = UIApplication.sharedApplication;
898
- if (app.requestSceneSessionDestructionOptionsErrorHandler) {
899
- app.requestSceneSessionDestructionOptionsErrorHandler(session, null, (error) => {
900
- if (error) {
901
- console.log('closeWindow: destruction error', error);
902
- }
903
- else {
904
- // clean up tracked id
905
- const id = this._getSceneId(scene);
906
- this._openedScenesById.delete(id);
907
- }
908
- });
909
- }
910
- else {
911
- console.info('closeWindow: Scene destruction API not available on this iOS version');
912
- }
1427
+ nativeWindow.close();
913
1428
  }
914
1429
  catch (err) {
915
1430
  console.log('closeWindow: Unexpected error', err);
916
1431
  }
917
1432
  }
1433
+ /**
1434
+ * @deprecated Use `getWindows()` instead.
1435
+ */
918
1436
  getAllWindows() {
919
- return Array.from(this._windowSceneMap.values());
1437
+ return this._windows.map((nw) => nw.ios?.uiWindow).filter(Boolean);
920
1438
  }
1439
+ /**
1440
+ * @deprecated Use `getWindows()` instead.
1441
+ */
921
1442
  getAllScenes() {
922
- return Array.from(this._windowSceneMap.keys());
1443
+ return this._windows.map((nw) => nw.ios?.scene).filter(Boolean);
923
1444
  }
1445
+ /**
1446
+ * @deprecated Use `getWindows()` instead.
1447
+ */
924
1448
  getWindowScenes() {
925
1449
  return this.getAllScenes().filter((scene) => scene instanceof UIWindowScene);
926
1450
  }
1451
+ /**
1452
+ * @deprecated Use `primaryWindow?.ios?.uiWindow` instead.
1453
+ */
927
1454
  getPrimaryWindow() {
928
- if (this._primaryScene) {
929
- return this._getWindowForScene(this._primaryScene) || getiOSWindow();
1455
+ const primary = this.primaryWindow;
1456
+ if (primary?.ios?.uiWindow) {
1457
+ return primary.ios.uiWindow;
930
1458
  }
931
1459
  return getiOSWindow();
932
1460
  }
1461
+ /**
1462
+ * @deprecated Use `primaryWindow?.ios?.scene` instead.
1463
+ */
933
1464
  getPrimaryScene() {
934
- return this._primaryScene;
1465
+ return this.primaryWindow?.ios?.scene || null;
935
1466
  }
936
1467
  // Scene lifecycle management
937
1468
  supportsScenes() {
@@ -941,7 +1472,7 @@ export class iOSApplication extends ApplicationCommon {
941
1472
  return supportsMultipleScenes();
942
1473
  }
943
1474
  isUsingSceneLifecycle() {
944
- return this.supportsScenes() && this._windowSceneMap.size > 0;
1475
+ return this.supportsScenes() && this._windows.length > 0;
945
1476
  }
946
1477
  // Call this to set up scene-based configuration
947
1478
  configureForScenes() {
@@ -949,34 +1480,6 @@ export class iOSApplication extends ApplicationCommon {
949
1480
  console.warn('Scene-based lifecycle is only supported on iOS 13+ iPad or visionOS with multi-scene enabled apps.');
950
1481
  return;
951
1482
  }
952
- // Additional scene configuration can be added here
953
- // For now, the notification observers are already set up in the constructor
954
- }
955
- // Stable scene id for lookups
956
- _getSceneId(scene) {
957
- try {
958
- if (!scene) {
959
- return 'Unknown';
960
- }
961
- // Prefer session persistentIdentifier when available (stable across lifetime)
962
- const session = scene.session;
963
- const persistentId = session && session.persistentIdentifier;
964
- if (persistentId) {
965
- return `${persistentId}`;
966
- }
967
- // Fallbacks
968
- if (scene.hash != null) {
969
- return `${scene.hash}`;
970
- }
971
- const desc = scene.description;
972
- if (desc) {
973
- return `${desc}`;
974
- }
975
- }
976
- catch (err) {
977
- // ignore
978
- }
979
- return 'Unknown';
980
1483
  }
981
1484
  // Resolve a UIWindowScene from various input types
982
1485
  _resolveScene(target) {
@@ -984,12 +1487,10 @@ export class iOSApplication extends ApplicationCommon {
984
1487
  return null;
985
1488
  }
986
1489
  if (!target) {
987
- // Try to pick a non-primary foreground active scene, else last known scene
988
- const scenes = this.getWindowScenes?.() || [];
989
- const nonPrimary = scenes.filter((s) => s !== this._primaryScene);
990
- return nonPrimary[0] || scenes[0] || null;
1490
+ // Try to pick a non-primary window's scene
1491
+ const nonPrimary = this._windows.filter((nw) => !nw.isPrimary);
1492
+ return nonPrimary[0]?.ios?.scene || this.primaryWindow?.ios?.scene || null;
991
1493
  }
992
- // If a View was passed, derive its window.scene
993
1494
  if (target && typeof target === 'object') {
994
1495
  // UIWindowScene
995
1496
  if (target.session && target.activationState !== undefined) {
@@ -1008,15 +1509,15 @@ export class iOSApplication extends ApplicationCommon {
1008
1509
  }
1009
1510
  // String id lookup
1010
1511
  if (typeof target === 'string') {
1011
- if (this._openedScenesById.has(target)) {
1012
- return this._openedScenesById.get(target);
1512
+ const found = this.getWindowById(target);
1513
+ if (found) {
1514
+ return found.ios?.scene || null;
1013
1515
  }
1014
- // Try matching by persistentIdentifier or hash among known scenes
1015
- const scenes = this.getWindowScenes?.() || [];
1016
- for (const s of scenes) {
1017
- const sid = this._getSceneId(s);
1018
- if (sid === target) {
1019
- return s;
1516
+ // Try matching among known scenes
1517
+ for (const nw of this._windows) {
1518
+ const scene = nw.ios?.scene;
1519
+ if (scene && IOSNativeWindow.getSceneId(scene) === target) {
1520
+ return scene;
1020
1521
  }
1021
1522
  }
1022
1523
  }
@@ -1028,8 +1529,8 @@ export class iOSApplication extends ApplicationCommon {
1028
1529
  return;
1029
1530
  }
1030
1531
  // Create user activity for the new scene
1031
- const userActivity = NSUserActivity.alloc().initWithActivityType(`${NSBundle.mainBundle.bundleIdentifier}.scene`);
1032
- userActivity.userInfo = dataSerialize(data);
1532
+ const userActivity = NSUserActivity.alloc().initWithActivityType(getSceneActivityType());
1533
+ userActivity.userInfo = dataSerialize(data ?? {});
1033
1534
  // Use the legacy API
1034
1535
  const options = UISceneActivationRequestOptions.new();
1035
1536
  options.requestingScene = windowScene;
@@ -1074,6 +1575,7 @@ global.__onLiveSyncCore = function (context) {
1074
1575
  iosApp._onLivesync(context);
1075
1576
  };
1076
1577
  export * from './application-common';
1578
+ export * from './application-interfaces';
1077
1579
  export const Application = iosApp;
1078
1580
  export const AndroidApplication = undefined;
1079
1581
  const applicationEvents = [Application.orientationChangedEvent, Application.systemAppearanceChangedEvent];