@nativescript/core 9.1.0-next.3 → 9.1.0-next.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 (79) hide show
  1. package/accessibility/accessibility-common.d.ts +8 -0
  2. package/accessibility/accessibility-common.js +28 -0
  3. package/accessibility/accessibility-common.js.map +1 -1
  4. package/application/application-common.d.ts +187 -3
  5. package/application/application-common.js +397 -54
  6. package/application/application-common.js.map +1 -1
  7. package/application/application-interfaces.d.ts +59 -1
  8. package/application/application.android.d.ts +21 -0
  9. package/application/application.android.js +189 -7
  10. package/application/application.android.js.map +1 -1
  11. package/application/application.d.ts +121 -66
  12. package/application/application.ios.d.ts +88 -26
  13. package/application/application.ios.js +474 -351
  14. package/application/application.ios.js.map +1 -1
  15. package/application/helpers-common.d.ts +5 -0
  16. package/application/helpers-common.js +23 -1
  17. package/application/helpers-common.js.map +1 -1
  18. package/application/scene-delegate-bridge.d.ts +55 -0
  19. package/application/scene-delegate-bridge.js +122 -0
  20. package/application/scene-delegate-bridge.js.map +1 -0
  21. package/config/config.interface.d.ts +38 -2
  22. package/css/system-classes.d.ts +9 -0
  23. package/css/system-classes.js +23 -0
  24. package/css/system-classes.js.map +1 -1
  25. package/data/observable/index.d.ts +5 -0
  26. package/data/observable/index.js +9 -0
  27. package/data/observable/index.js.map +1 -1
  28. package/global-types.d.ts +39 -33
  29. package/globals/global-utils.d.ts +6 -1
  30. package/globals/global-utils.js +10 -5
  31. package/globals/global-utils.js.map +1 -1
  32. package/index.d.ts +1 -0
  33. package/index.js +1 -0
  34. package/index.js.map +1 -1
  35. package/native-window/index.d.ts +426 -0
  36. package/native-window/index.js +4 -0
  37. package/native-window/index.js.map +1 -0
  38. package/native-window/native-window-common.d.ts +153 -0
  39. package/native-window/native-window-common.js +340 -0
  40. package/native-window/native-window-common.js.map +1 -0
  41. package/native-window/native-window-interfaces.d.ts +186 -0
  42. package/native-window/native-window-interfaces.js +90 -0
  43. package/native-window/native-window-interfaces.js.map +1 -0
  44. package/native-window/native-window.android.d.ts +59 -0
  45. package/native-window/native-window.android.js +175 -0
  46. package/native-window/native-window.android.js.map +1 -0
  47. package/native-window/native-window.ios.d.ts +57 -0
  48. package/native-window/native-window.ios.js +208 -0
  49. package/native-window/native-window.ios.js.map +1 -0
  50. package/native-window/window-base.d.ts +103 -0
  51. package/native-window/window-base.js +78 -0
  52. package/native-window/window-base.js.map +1 -0
  53. package/package.json +1 -1
  54. package/ui/core/view/index.android.js +3 -1
  55. package/ui/core/view/index.android.js.map +1 -1
  56. package/ui/core/view/index.d.ts +25 -0
  57. package/ui/core/view/view-common.d.ts +19 -0
  58. package/ui/core/view/view-common.js +34 -0
  59. package/ui/core/view/view-common.js.map +1 -1
  60. package/ui/core/view-base/index.js +6 -0
  61. package/ui/core/view-base/index.js.map +1 -1
  62. package/ui/frame/frame-common.d.ts +14 -2
  63. package/ui/frame/frame-common.js +17 -5
  64. package/ui/frame/frame-common.js.map +1 -1
  65. package/ui/frame/frame-constants.d.ts +9 -0
  66. package/ui/frame/frame-constants.js +10 -0
  67. package/ui/frame/frame-constants.js.map +1 -0
  68. package/ui/frame/frame-helper-for-android.d.ts +2 -2
  69. package/ui/frame/frame-helper-for-android.js +2 -2
  70. package/ui/frame/frame-helper-for-android.js.map +1 -1
  71. package/ui/frame/frame-interfaces.d.ts +1 -1
  72. package/ui/frame/frame-stack.d.ts +17 -1
  73. package/ui/frame/frame-stack.js +32 -5
  74. package/ui/frame/frame-stack.js.map +1 -1
  75. package/ui/frame/index.android.d.ts +1 -1
  76. package/ui/frame/index.android.js +111 -38
  77. package/ui/frame/index.android.js.map +1 -1
  78. package/ui/frame/index.d.ts +15 -5
  79. package/utils/native-helper.d.ts +2 -2
@@ -0,0 +1,59 @@
1
+ import type { View } from '../ui/core/view';
2
+ import { CoreTypes } from '../core-types';
3
+ import { NativeWindow } from './native-window-common';
4
+ import type { WindowRole } from './window-base';
5
+ /**
6
+ * Android implementation of NativeWindow.
7
+ * Wraps an AppCompatActivity.
8
+ */
9
+ export declare class AndroidNativeWindow extends NativeWindow {
10
+ private _activity;
11
+ private _componentCallbacks;
12
+ private _componentCallbacksActivity;
13
+ constructor(activity: androidx.appcompat.app.AppCompatActivity, id?: string, isPrimary?: boolean, role?: WindowRole);
14
+ /**
15
+ * @internal – bind a recreated activity to this window session after a detach.
16
+ */
17
+ _reattach(activity: androidx.appcompat.app.AppCompatActivity): void;
18
+ /**
19
+ * @internal – observe the activity's own configuration.
20
+ *
21
+ * Registered on the activity rather than the application context: in multi-window
22
+ * and multi-display setups each activity gets its own configuration, and only these
23
+ * callbacks report the one this window actually renders with.
24
+ */
25
+ _registerConfigurationCallbacks(): void;
26
+ /**
27
+ * @internal – drop the configuration callbacks, so a recreated activity does not
28
+ * leave the previous one registered.
29
+ */
30
+ _unregisterConfigurationCallbacks(): void;
31
+ _detach(): void;
32
+ /**
33
+ * The wrapped Android Activity (may be GC'd).
34
+ */
35
+ get activity(): androidx.appcompat.app.AppCompatActivity | undefined;
36
+ get android(): {
37
+ activity: androidx.appcompat.app.AppCompatActivity;
38
+ };
39
+ /**
40
+ * Platform-specific: apply the view as root content of this Activity.
41
+ */
42
+ protected _setNativeContent(view: View): void;
43
+ /**
44
+ * Close this window by finishing the activity.
45
+ */
46
+ close(): void;
47
+ protected _getOrientation(): 'portrait' | 'landscape' | 'unknown';
48
+ protected _getSystemAppearance(): 'light' | 'dark' | null;
49
+ protected _getLayoutDirection(): CoreTypes.LayoutDirectionType | null;
50
+ _getOrientationValue(configuration: android.content.res.Configuration): 'portrait' | 'landscape' | 'unknown';
51
+ _getSystemAppearanceValue(configuration: android.content.res.Configuration): 'dark' | 'light';
52
+ _getLayoutDirectionValue(configuration: android.content.res.Configuration): CoreTypes.LayoutDirectionType;
53
+ protected _onDestroy(): void;
54
+ /**
55
+ * Mints a window identity. Android has no stable activity id, so the value is kept
56
+ * in the activity saved state to survive recreation (rotation, theme change).
57
+ */
58
+ static newWindowId(): string;
59
+ }
@@ -0,0 +1,175 @@
1
+ import { CoreTypes } from '../core-types';
2
+ import { CALLBACKS } from '../ui/frame/frame-constants';
3
+ import { NativeWindow } from './native-window-common';
4
+ /**
5
+ * Android implementation of NativeWindow.
6
+ * Wraps an AppCompatActivity.
7
+ */
8
+ export class AndroidNativeWindow extends NativeWindow {
9
+ constructor(activity, id, isPrimary = false, role = 'application') {
10
+ super(id, isPrimary, role);
11
+ this._activity = new WeakRef(activity);
12
+ }
13
+ /**
14
+ * @internal – bind a recreated activity to this window session after a detach.
15
+ */
16
+ _reattach(activity) {
17
+ this._activity = new WeakRef(activity);
18
+ this._setState('attached');
19
+ }
20
+ /**
21
+ * @internal – observe the activity's own configuration.
22
+ *
23
+ * Registered on the activity rather than the application context: in multi-window
24
+ * and multi-display setups each activity gets its own configuration, and only these
25
+ * callbacks report the one this window actually renders with.
26
+ */
27
+ _registerConfigurationCallbacks() {
28
+ const activity = this.activity;
29
+ if (!activity || this._componentCallbacks) {
30
+ return;
31
+ }
32
+ const callbacks = new android.content.ComponentCallbacks2({
33
+ onLowMemory() {
34
+ // Handled application-wide.
35
+ },
36
+ onTrimMemory(level) {
37
+ // Handled application-wide.
38
+ },
39
+ onConfigurationChanged: (newConfiguration) => {
40
+ this._setOrientation(this._getOrientationValue(newConfiguration));
41
+ this._setSystemAppearance(this._getSystemAppearanceValue(newConfiguration));
42
+ this._setLayoutDirection(this._getLayoutDirectionValue(newConfiguration));
43
+ },
44
+ });
45
+ activity.registerComponentCallbacks(callbacks);
46
+ this._componentCallbacks = callbacks;
47
+ this._componentCallbacksActivity = new WeakRef(activity);
48
+ }
49
+ /**
50
+ * @internal – drop the configuration callbacks, so a recreated activity does not
51
+ * leave the previous one registered.
52
+ */
53
+ _unregisterConfigurationCallbacks() {
54
+ const callbacks = this._componentCallbacks;
55
+ if (!callbacks) {
56
+ return;
57
+ }
58
+ this._componentCallbacks = null;
59
+ this._componentCallbacksActivity?.deref()?.unregisterComponentCallbacks(callbacks);
60
+ this._componentCallbacksActivity = null;
61
+ }
62
+ _detach() {
63
+ this._unregisterConfigurationCallbacks();
64
+ super._detach();
65
+ }
66
+ /**
67
+ * The wrapped Android Activity (may be GC'd).
68
+ */
69
+ get activity() {
70
+ return this._activity?.deref();
71
+ }
72
+ get android() {
73
+ const activity = this.activity;
74
+ if (!activity) {
75
+ return undefined;
76
+ }
77
+ return { activity };
78
+ }
79
+ /**
80
+ * Platform-specific: apply the view as root content of this Activity.
81
+ */
82
+ _setNativeContent(view) {
83
+ const activity = this.activity;
84
+ if (!activity) {
85
+ throw new Error('NativeWindow: Activity is no longer available.');
86
+ }
87
+ const callbacks = activity[CALLBACKS];
88
+ if (!callbacks) {
89
+ throw new Error('NativeWindow: Cannot find activity callbacks.');
90
+ }
91
+ callbacks.resetActivityContent(activity, view);
92
+ }
93
+ /**
94
+ * Close this window by finishing the activity.
95
+ */
96
+ close() {
97
+ if (this.isPrimary) {
98
+ console.log('NativeWindow: Cannot close the primary window.');
99
+ return;
100
+ }
101
+ const activity = this.activity;
102
+ if (activity) {
103
+ activity.finish();
104
+ }
105
+ }
106
+ // --- Platform getters ---
107
+ _getOrientation() {
108
+ const activity = this.activity;
109
+ if (!activity) {
110
+ return 'unknown';
111
+ }
112
+ const configuration = activity.getResources().getConfiguration();
113
+ return this._getOrientationValue(configuration);
114
+ }
115
+ _getSystemAppearance() {
116
+ const activity = this.activity;
117
+ if (!activity) {
118
+ return null;
119
+ }
120
+ const configuration = activity.getResources().getConfiguration();
121
+ return this._getSystemAppearanceValue(configuration);
122
+ }
123
+ _getLayoutDirection() {
124
+ const activity = this.activity;
125
+ if (!activity) {
126
+ return null;
127
+ }
128
+ const configuration = activity.getResources().getConfiguration();
129
+ return this._getLayoutDirectionValue(configuration);
130
+ }
131
+ // --- Value converters ---
132
+ _getOrientationValue(configuration) {
133
+ switch (configuration.orientation) {
134
+ case android.content.res.Configuration.ORIENTATION_LANDSCAPE:
135
+ return 'landscape';
136
+ case android.content.res.Configuration.ORIENTATION_PORTRAIT:
137
+ return 'portrait';
138
+ default:
139
+ return 'unknown';
140
+ }
141
+ }
142
+ _getSystemAppearanceValue(configuration) {
143
+ const mode = configuration.uiMode & android.content.res.Configuration.UI_MODE_NIGHT_MASK;
144
+ switch (mode) {
145
+ case android.content.res.Configuration.UI_MODE_NIGHT_YES:
146
+ return 'dark';
147
+ case android.content.res.Configuration.UI_MODE_NIGHT_NO:
148
+ case android.content.res.Configuration.UI_MODE_NIGHT_UNDEFINED:
149
+ default:
150
+ return 'light';
151
+ }
152
+ }
153
+ _getLayoutDirectionValue(configuration) {
154
+ switch (configuration.getLayoutDirection()) {
155
+ case android.view.View.LAYOUT_DIRECTION_RTL:
156
+ return CoreTypes.LayoutDirection.rtl;
157
+ case android.view.View.LAYOUT_DIRECTION_LTR:
158
+ default:
159
+ return CoreTypes.LayoutDirection.ltr;
160
+ }
161
+ }
162
+ _onDestroy() {
163
+ this._unregisterConfigurationCallbacks();
164
+ super._onDestroy();
165
+ this._activity = null;
166
+ }
167
+ /**
168
+ * Mints a window identity. Android has no stable activity id, so the value is kept
169
+ * in the activity saved state to survive recreation (rotation, theme change).
170
+ */
171
+ static newWindowId() {
172
+ return `window-${java.util.UUID.randomUUID().toString()}`;
173
+ }
174
+ }
175
+ //# sourceMappingURL=native-window.android.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-window.android.js","sourceRoot":"","sources":["../../../../packages/core/native-window/native-window.android.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGtD;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,YAAY;IAKpD,YAAY,QAAkD,EAAE,EAAW,EAAE,SAAS,GAAG,KAAK,EAAE,OAAmB,aAAa;QAC/H,KAAK,CAAC,EAAE,EAAE,SAAS,EAAE,I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AyB,CAAC,aAAgD;QACzE,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,kBAAkB,CAAC;QACzF,QAAQ,IAAI,EAAE,CAAC;YACd,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,iBAAiB;gBACvD,OAAO,MAAM,CAAC;YACf,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,gBAAgB,CAAC;YACxD,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,uBAAuB,CAAC;YAC/D;gBACC,OAAO,OAAO,CAAC;QACjB,CAAC;IACF,CAAC;IAED,wBAAwB,CAAC,aAAgD;QACxE,QAAQ,aAAa,CAAC,kBAAkB,EAAE,EAAE,CAAC;YAC5C,KAAK,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB;gBAC1C,OAAO,SAAS,CAAC,eAAe,CAAC,GAAG,CAAC;YACtC,KAAK,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC;YAC5C;gBACC,OAAO,SAAS,CAAC,eAAe,CAAC,GAAG,CAAC;QACvC,CAAC;IACF,CAAC;IAES,UAAU;QACnB,IAAI,CAAC,iCAAiC,EAAE,CAAC;QACzC,KAAK,CAAC,UAAU,EAAE,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,WAAW;QACjB,OAAO,UAAU,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC3D,CAAC;CACD"}
@@ -0,0 +1,57 @@
1
+ import type { View } from '../ui/core/view';
2
+ import { CoreTypes } from '../core-types';
3
+ import { NativeWindow } from './native-window-common';
4
+ import type { WindowRole } from './window-base';
5
+ /**
6
+ * iOS implementation of NativeWindow.
7
+ * Wraps a UIWindow and, when the app is scene-based, the UIWindowScene hosting it.
8
+ */
9
+ export declare class IOSNativeWindow extends NativeWindow {
10
+ private _scene;
11
+ private _window;
12
+ /**
13
+ * @internal – set while a scene session destruction request is in flight, so the
14
+ * following scene disconnect is read as a close rather than a detach.
15
+ */
16
+ _closeRequested: boolean;
17
+ /**
18
+ * @internal – whether the id comes from a scene session identity. Without one the
19
+ * window cannot be matched to a reconnecting session or to a discarded one.
20
+ */
21
+ _hasSessionIdentity: boolean;
22
+ constructor(scene: UIWindowScene | undefined, window: UIWindow, id?: string, isPrimary?: boolean, role?: WindowRole);
23
+ /**
24
+ * @internal – bind a new scene/window pair to this window session after a detach.
25
+ */
26
+ _reattach(scene: UIWindowScene, uiWindow: UIWindow): void;
27
+ get ios(): {
28
+ scene: UIWindowScene;
29
+ uiWindow: UIWindow;
30
+ };
31
+ /**
32
+ * Platform-specific: set the view as root content of this UIWindow.
33
+ */
34
+ protected _setNativeContent(view: View): void;
35
+ /**
36
+ * Close this window/scene.
37
+ */
38
+ close(): void;
39
+ protected _getOrientation(): 'portrait' | 'landscape' | 'unknown';
40
+ protected _getSystemAppearance(): 'light' | 'dark' | null;
41
+ protected _getLayoutDirection(): CoreTypes.LayoutDirectionType | null;
42
+ private _getOrientationValue;
43
+ _getSystemAppearanceValue(userInterfaceStyle: number): 'dark' | 'light';
44
+ _getLayoutDirectionValue(layoutDirection: number): CoreTypes.LayoutDirectionType;
45
+ private _getViewController;
46
+ private _setViewControllerView;
47
+ protected _onReleaseRootView(rootView: View): void;
48
+ protected _onDestroy(): void;
49
+ /**
50
+ * The window identity of a scene: the session persistent identifier, which iOS keeps
51
+ * across a disconnect and hands back when it reconnects the same session.
52
+ *
53
+ * Returns `undefined` when the scene carries no session identity — such a window gets
54
+ * a minted id and will not be recognised on reconnect.
55
+ */
56
+ static getSceneId(scene: UIWindowScene): string | undefined;
57
+ }
@@ -0,0 +1,208 @@
1
+ import { IOSHelper } from '../ui/core/view/view-helper';
2
+ import { SDK_VERSION } from '../utils/constants';
3
+ import { CoreTypes } from '../core-types';
4
+ import { Trace } from '../trace';
5
+ import { NativeWindow } from './native-window-common';
6
+ /**
7
+ * iOS implementation of NativeWindow.
8
+ * Wraps a UIWindow and, when the app is scene-based, the UIWindowScene hosting it.
9
+ */
10
+ export class IOSNativeWindow extends NativeWindow {
11
+ constructor(scene, window, id, isPrimary = false, role = 'application') {
12
+ super(id, isPrimary, role);
13
+ /**
14
+ * @internal – set while a scene session destruction request is in flight, so the
15
+ * following scene disconnect is read as a close rather than a detach.
16
+ */
17
+ this._closeRequested = false;
18
+ this._hasSessionIdentity = !!id;
19
+ this._scene = scene;
20
+ this._window = window;
21
+ }
22
+ /**
23
+ * @internal – bind a new scene/window pair to this window session after a detach.
24
+ */
25
+ _reattach(scene, uiWindow) {
26
+ this._scene = scene;
27
+ this._window = uiWindow;
28
+ this._setState('attached');
29
+ }
30
+ get ios() {
31
+ return {
32
+ scene: this._scene,
33
+ uiWindow: this._window,
34
+ };
35
+ }
36
+ /**
37
+ * Platform-specific: set the view as root content of this UIWindow.
38
+ */
39
+ _setNativeContent(view) {
40
+ const controller = this._getViewController(view);
41
+ this._setViewControllerView(view);
42
+ if (this.role === 'embedded') {
43
+ // The host app owns this UIWindow: its rootViewController and key/visible state
44
+ // are not ours to change, so the content is handed over as a view controller.
45
+ NativeScriptEmbedder.sharedInstance().delegate?.presentNativeScriptApp(controller);
46
+ }
47
+ else {
48
+ const haveController = this._window.rootViewController !== null;
49
+ this._window.rootViewController = controller;
50
+ if (!haveController) {
51
+ this._window.makeKeyAndVisible();
52
+ }
53
+ }
54
+ // Listen for trait collection changes per-window
55
+ view.on(IOSHelper.traitCollectionColorAppearanceChangedEvent, () => {
56
+ const userInterfaceStyle = controller.traitCollection.userInterfaceStyle;
57
+ this._setSystemAppearance(this._getSystemAppearanceValue(userInterfaceStyle));
58
+ });
59
+ view.on(IOSHelper.traitCollectionLayoutDirectionChangedEvent, () => {
60
+ const layoutDirection = controller.traitCollection.layoutDirection;
61
+ this._setLayoutDirection(this._getLayoutDirectionValue(layoutDirection));
62
+ });
63
+ }
64
+ /**
65
+ * Close this window/scene.
66
+ */
67
+ close() {
68
+ if (this.isPrimary) {
69
+ console.log('NativeWindow: Cannot close the primary window.');
70
+ return;
71
+ }
72
+ const session = this._scene?.session;
73
+ if (!session) {
74
+ console.log('NativeWindow: Scene has no session to destroy.');
75
+ return;
76
+ }
77
+ const app = UIApplication.sharedApplication;
78
+ if (app.requestSceneSessionDestructionOptionsErrorHandler) {
79
+ this._closeRequested = true;
80
+ app.requestSceneSessionDestructionOptionsErrorHandler(session, null, (error) => {
81
+ if (error) {
82
+ this._closeRequested = false;
83
+ console.log('NativeWindow: Error destroying scene session:', error.localizedDescription);
84
+ }
85
+ });
86
+ }
87
+ else {
88
+ console.log('NativeWindow: Scene destruction API not available on this iOS version.');
89
+ }
90
+ }
91
+ // --- Platform getters ---
92
+ _getOrientation() {
93
+ if (__VISIONOS__) {
94
+ return this._getOrientationValue(NativeScriptEmbedder.sharedInstance().windowScene?.interfaceOrientation);
95
+ }
96
+ if (this._scene) {
97
+ return this._getOrientationValue(this._scene.interfaceOrientation);
98
+ }
99
+ return this._getOrientationValue(UIApplication.sharedApplication.statusBarOrientation);
100
+ }
101
+ _getSystemAppearance() {
102
+ if (!__VISIONOS__ && SDK_VERSION <= 11) {
103
+ return null;
104
+ }
105
+ const rootVC = this._window?.rootViewController;
106
+ if (!rootVC) {
107
+ return null;
108
+ }
109
+ return this._getSystemAppearanceValue(rootVC.traitCollection.userInterfaceStyle);
110
+ }
111
+ _getLayoutDirection() {
112
+ const rootVC = this._window?.rootViewController;
113
+ if (!rootVC) {
114
+ return null;
115
+ }
116
+ return this._getLayoutDirectionValue(rootVC.traitCollection.layoutDirection);
117
+ }
118
+ // --- Value converters ---
119
+ _getOrientationValue(orientation) {
120
+ switch (orientation) {
121
+ case 3 /* UIInterfaceOrientation.LandscapeRight */:
122
+ case 4 /* UIInterfaceOrientation.LandscapeLeft */:
123
+ return 'landscape';
124
+ case 2 /* UIInterfaceOrientation.PortraitUpsideDown */:
125
+ case 1 /* UIInterfaceOrientation.Portrait */:
126
+ return 'portrait';
127
+ case 0 /* UIInterfaceOrientation.Unknown */:
128
+ default:
129
+ return 'unknown';
130
+ }
131
+ }
132
+ _getSystemAppearanceValue(userInterfaceStyle) {
133
+ switch (userInterfaceStyle) {
134
+ case 2 /* UIUserInterfaceStyle.Dark */:
135
+ return 'dark';
136
+ case 1 /* UIUserInterfaceStyle.Light */:
137
+ case 0 /* UIUserInterfaceStyle.Unspecified */:
138
+ default:
139
+ return 'light';
140
+ }
141
+ }
142
+ _getLayoutDirectionValue(layoutDirection) {
143
+ switch (layoutDirection) {
144
+ case 1 /* UITraitEnvironmentLayoutDirection.RightToLeft */:
145
+ return CoreTypes.LayoutDirection.rtl;
146
+ case 0 /* UITraitEnvironmentLayoutDirection.LeftToRight */:
147
+ default:
148
+ return CoreTypes.LayoutDirection.ltr;
149
+ }
150
+ }
151
+ // --- ViewController helpers ---
152
+ _getViewController(rootView) {
153
+ let viewController = rootView.viewController || rootView.ios;
154
+ if (!(viewController instanceof UIViewController)) {
155
+ viewController = IOSHelper.UILayoutViewController.initWithOwner(new WeakRef(rootView));
156
+ rootView.viewController = viewController;
157
+ }
158
+ return viewController;
159
+ }
160
+ _setViewControllerView(view) {
161
+ const viewController = view.viewController || view.ios;
162
+ const nativeView = view.ios || view.nativeViewProtected;
163
+ if (!nativeView || !viewController) {
164
+ throw new Error('Root should be either UIViewController or UIView');
165
+ }
166
+ if (viewController instanceof IOSHelper.UILayoutViewController) {
167
+ viewController.view.addSubview(nativeView);
168
+ }
169
+ }
170
+ _onReleaseRootView(rootView) {
171
+ rootView.off(IOSHelper.traitCollectionColorAppearanceChangedEvent);
172
+ rootView.off(IOSHelper.traitCollectionLayoutDirectionChangedEvent);
173
+ // An embedded window belongs to the host app, so its rootViewController is not ours
174
+ // to clear — `_setNativeContent` never set it in the first place.
175
+ if (this.role !== 'embedded' && this._window?.rootViewController) {
176
+ // The controller's view is moving into another window's hierarchy; leaving it
177
+ // installed here has UIKit holding a controller it no longer hosts.
178
+ this._window.rootViewController = null;
179
+ }
180
+ }
181
+ _onDestroy() {
182
+ // The trait collection listeners live on the root view, so they have to go
183
+ // before the base drops the reference to it.
184
+ if (this._rootView) {
185
+ this._rootView.off(IOSHelper.traitCollectionColorAppearanceChangedEvent);
186
+ this._rootView.off(IOSHelper.traitCollectionLayoutDirectionChangedEvent);
187
+ }
188
+ super._onDestroy();
189
+ this._scene = null;
190
+ this._window = null;
191
+ }
192
+ /**
193
+ * The window identity of a scene: the session persistent identifier, which iOS keeps
194
+ * across a disconnect and hands back when it reconnects the same session.
195
+ *
196
+ * Returns `undefined` when the scene carries no session identity — such a window gets
197
+ * a minted id and will not be recognised on reconnect.
198
+ */
199
+ static getSceneId(scene) {
200
+ const persistentIdentifier = scene?.session?.persistentIdentifier;
201
+ if (persistentIdentifier) {
202
+ return `${persistentIdentifier}`;
203
+ }
204
+ Trace.write('NativeWindow: scene has no session persistentIdentifier; window identity will not survive a reconnect.', Trace.categories.NativeLifecycle, Trace.messageType.error);
205
+ return undefined;
206
+ }
207
+ }
208
+ //# sourceMappingURL=native-window.ios.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-window.ios.js","sourceRoot":"","sources":["../../../../packages/core/native-window/native-window.ios.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAItD;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,YAAY;IAgBhD,YAAY,KAAgC,EAAE,MAAgB,EAAE,EAAW,EAAE,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ES,kBAAkB,CAAC,QAAc;QAC1C,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,0CAA0C,CAAC,CAAC;QACnE,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,0CAA0C,CAAC,CAAC;QAEnE,oFAAoF;QACpF,kEAAkE;QAClE,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,OAAO,EAAE,kBAAkB,EAAE,CAAC;YAClE,8EAA8E;YAC9E,oEAAoE;YACpE,IAAI,CAAC,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;QACxC,CAAC;IACF,CAAC;IAES,UAAU;QACnB,2EAA2E;QAC3E,6CAA6C;QAC7C,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,0CAA0C,CAAC,CAAC;YACzE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,0CAA0C,CAAC,CAAC;QAC1E,CAAC;QACD,KAAK,CAAC,UAAU,EAAE,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACrB,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,UAAU,CAAC,KAAoB;QACrC,MAAM,oBAAoB,GAAG,KAAK,EAAE,OAAO,EAAE,oBAAoB,CAAC;QAClE,IAAI,oBAAoB,EAAE,CAAC;YAC1B,OAAO,GAAG,oBAAoB,EAAE,CAAC;QAClC,CAAC;QAED,KAAK,CAAC,KAAK,CAAC,wGAAwG,EAAE,KAAK,CAAC,UAAU,CAAC,eAAe,EAAE,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAEjL,OAAO,SAAS,CAAC;IAClB,CAAC;CACD"}
@@ -0,0 +1,103 @@
1
+ import { Observable } from '../data/observable';
2
+ import type { NativeWindowEventName, WindowBaseEventData, WindowLayoutDirectionChangedEventData, WindowOrientationChangedEventData, WindowSystemAppearanceChangedEventData } from './native-window-interfaces';
3
+ import type { AndroidActivityEventData, AndroidActivityBundleEventData, AndroidActivityResultEventData, AndroidActivityBackPressedEventData, AndroidActivityNewIntentEventData, AndroidActivityRequestPermissionsEventData, SceneEventData, SceneOpenURLContextsEventData, SceneContinueUserActivityEventData, ScenePerformActionForShortcutItemEventData } from '../application/application-interfaces';
4
+ /**
5
+ * The purpose a window surface serves.
6
+ *
7
+ * - `application` – a regular app window (iOS application scene, Android activity).
8
+ * - `embedded` – a window hosted inside another app or container.
9
+ * - `carplay` – a CarPlay template scene.
10
+ * - `externalDisplay` – an external/secondary display scene.
11
+ */
12
+ export type WindowRole = 'application' | 'embedded' | 'carplay' | 'externalDisplay';
13
+ /**
14
+ * The lifecycle state of a window surface.
15
+ *
16
+ * - `attached` – connected to a live native surface.
17
+ * - `detached` – the native surface went away but the window may be reconnected.
18
+ * - `closed` – permanently torn down.
19
+ */
20
+ export type WindowState = 'attached' | 'detached' | 'closed';
21
+ /**
22
+ * Cross-platform base for any window surface.
23
+ *
24
+ * Carries identity, role, state, lifecycle events and the native accessors.
25
+ * Surfaces that host a NativeScript view tree extend {@link NativeWindow} instead.
26
+ */
27
+ export declare abstract class WindowBase extends Observable {
28
+ private _id;
29
+ private _role;
30
+ private _state;
31
+ private _isPrimary;
32
+ constructor(id?: string, isPrimary?: boolean, role?: WindowRole);
33
+ get id(): string;
34
+ get role(): WindowRole;
35
+ get state(): WindowState;
36
+ get isPrimary(): boolean;
37
+ /**
38
+ * @internal - used by the Application to promote a window to primary.
39
+ */
40
+ _setIsPrimary(value: boolean): void;
41
+ /**
42
+ * @internal
43
+ */
44
+ _setState(value: WindowState): void;
45
+ get ios(): {
46
+ readonly scene?: UIWindowScene;
47
+ readonly uiWindow: UIWindow;
48
+ } | undefined;
49
+ get android(): {
50
+ readonly activity: androidx.appcompat.app.AppCompatActivity;
51
+ } | undefined;
52
+ /**
53
+ * Close this window.
54
+ */
55
+ abstract close(): void;
56
+ on(event: 'activate', callback: (data: WindowBaseEventData) => void, thisArg?: any): void;
57
+ on(event: 'deactivate', callback: (data: WindowBaseEventData) => void, thisArg?: any): void;
58
+ on(event: 'background', callback: (data: WindowBaseEventData) => void, thisArg?: any): void;
59
+ on(event: 'foreground', callback: (data: WindowBaseEventData) => void, thisArg?: any): void;
60
+ on(event: 'close', callback: (data: WindowBaseEventData) => void, thisArg?: any): void;
61
+ on(event: 'attached', callback: (data: WindowBaseEventData) => void, thisArg?: any): void;
62
+ on(event: 'detached', callback: (data: WindowBaseEventData) => void, thisArg?: any): void;
63
+ on(event: 'displayed', callback: (data: WindowBaseEventData) => void, thisArg?: any): void;
64
+ on(event: 'orientationChanged', callback: (data: WindowOrientationChangedEventData) => void, thisArg?: any): void;
65
+ on(event: 'systemAppearanceChanged', callback: (data: WindowSystemAppearanceChangedEventData) => void, thisArg?: any): void;
66
+ on(event: 'layoutDirectionChanged', callback: (data: WindowLayoutDirectionChangedEventData) => void, thisArg?: any): void;
67
+ on(event: 'activityCreated', callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any): void;
68
+ on(event: 'activityDestroyed', callback: (args: AndroidActivityEventData) => void, thisArg?: any): void;
69
+ on(event: 'activityStarted', callback: (args: AndroidActivityEventData) => void, thisArg?: any): void;
70
+ on(event: 'activityPaused', callback: (args: AndroidActivityEventData) => void, thisArg?: any): void;
71
+ on(event: 'activityResumed', callback: (args: AndroidActivityEventData) => void, thisArg?: any): void;
72
+ on(event: 'activityStopped', callback: (args: AndroidActivityEventData) => void, thisArg?: any): void;
73
+ on(event: 'saveActivityState', callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any): void;
74
+ on(event: 'activityResult', callback: (args: AndroidActivityResultEventData) => void, thisArg?: any): void;
75
+ on(event: 'activityBackPressed', callback: (args: AndroidActivityBackPressedEventData) => void, thisArg?: any): void;
76
+ on(event: 'activityNewIntent', callback: (args: AndroidActivityNewIntentEventData) => void, thisArg?: any): void;
77
+ on(event: 'activityRequestPermissions', callback: (args: AndroidActivityRequestPermissionsEventData) => void, thisArg?: any): void;
78
+ on(event: 'sceneWillConnect', callback: (args: SceneEventData) => void, thisArg?: any): void;
79
+ on(event: 'sceneDidActivate', callback: (args: SceneEventData) => void, thisArg?: any): void;
80
+ on(event: 'sceneWillResignActive', callback: (args: SceneEventData) => void, thisArg?: any): void;
81
+ on(event: 'sceneWillEnterForeground', callback: (args: SceneEventData) => void, thisArg?: any): void;
82
+ on(event: 'sceneDidEnterBackground', callback: (args: SceneEventData) => void, thisArg?: any): void;
83
+ on(event: 'sceneDidDisconnect', callback: (args: SceneEventData) => void, thisArg?: any): void;
84
+ on(event: 'sceneOpenURLContexts', callback: (args: SceneOpenURLContextsEventData) => void, thisArg?: any): void;
85
+ on(event: 'sceneContinueUserActivity', callback: (args: SceneContinueUserActivityEventData) => void, thisArg?: any): void;
86
+ on(event: 'scenePerformActionForShortcutItem', callback: (args: ScenePerformActionForShortcutItemEventData) => void, thisArg?: any): void;
87
+ on(eventName: string, callback: (data: WindowBaseEventData) => void, thisArg?: any): void;
88
+ /**
89
+ * @internal – emit a window lifecycle event.
90
+ */
91
+ _notifyEvent(eventName: NativeWindowEventName): void;
92
+ /**
93
+ * @internal – ends the window session for good.
94
+ *
95
+ * Listeners stay live through the whole teardown and are dropped last, so handlers
96
+ * registered on this instance can still observe `close` yet never outlive the window.
97
+ */
98
+ _destroy(): void;
99
+ /**
100
+ * Teardown hook for subclasses. Runs while the listeners are still registered.
101
+ */
102
+ protected _onDestroy(): void;
103
+ }