@akylas/nativescript 9.0.25 → 9.1.4

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