@nativescript/core 8.7.0-beta.1 → 8.7.0-beta.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript/core",
3
- "version": "8.7.0-beta.1",
3
+ "version": "8.7.0-beta.2",
4
4
  "description": "A JavaScript library providing an easy to use api for interacting with iOS and Android platform APIs.",
5
5
  "main": "index",
6
6
  "types": "index.d.ts",
@@ -26,15 +26,27 @@ struct NativeScriptMainWindow: Scene {
26
26
  }
27
27
  }.onReceive(NotificationCenter.default
28
28
  .publisher(for: NSNotification.Name("NativeScriptWindowOpen")), perform: { obj in
29
- Task {
30
- await handleWindowEvent(obj: obj)
31
- }
29
+ let info = parseWindowInfo(obj: obj)
30
+ let id = info.keys.first
31
+ Task {
32
+ if (info[id!]!) {
33
+ await openImmersiveSpace(id: id!)
34
+ } else {
35
+ openWindow(id: id!)
36
+ }
37
+ }
32
38
  }).onReceive(NotificationCenter.default
33
39
  .publisher(for: NSNotification.Name("NativeScriptWindowClose")), perform: { obj in
34
- Task {
35
- await handleWindowEvent(obj: obj, close: true)
36
- }
37
- })
40
+ let info = parseWindowInfo(obj: obj)
41
+ let id = info.keys.first
42
+ Task {
43
+ if (info[id!]!) {
44
+ await dismissImmersiveSpace()
45
+ } else {
46
+ dismissWindow(id: id!)
47
+ }
48
+ }
49
+ })
38
50
  .onOpenURL { (url) in
39
51
  NotificationCenter.default.post(name: Notification.Name("NativeScriptOpenURL"), object: nil, userInfo: ["url": url.absoluteString ])
40
52
  }
@@ -61,33 +73,22 @@ struct NativeScriptMainWindow: Scene {
61
73
  }
62
74
 
63
75
  #if os(visionOS)
64
- func handleWindowEvent(obj: Notification, close: Bool = false) async {
76
+ func parseWindowInfo(obj: Notification, close: Bool = false) -> [String:Bool] {
65
77
  if let userInfo = obj.userInfo {
66
- var sceneType: String = ""
78
+ var id: String = ""
67
79
  var isImmersive = false
68
80
  for (key, value) in userInfo {
69
81
  let k = key as! String
70
82
  if (k == "type") {
71
- sceneType = value as! String
83
+ id = value as! String
72
84
  } else if (k == "isImmersive") {
73
85
  isImmersive = value as! Bool
74
86
  }
75
87
  }
76
-
77
- if (close) {
78
- if (isImmersive) {
79
- await dismissImmersiveSpace()
80
- } else {
81
- dismissWindow(id: sceneType)
82
- }
83
- } else {
84
- if (isImmersive) {
85
- await openImmersiveSpace(id: sceneType)
86
- } else {
87
- openWindow(id: sceneType)
88
- }
89
- }
88
+ return [id: isImmersive]
89
+
90
90
  }
91
+ return ["_": false]
91
92
  }
92
93
  #endif
93
94
  }
@@ -124,7 +125,7 @@ struct NativeScriptAppView: UIViewRepresentable {
124
125
  @available(iOS 13.0, *)
125
126
  @objc public class NativeScriptViewFactory: NSObject, NativeScriptEmbedderDelegate {
126
127
  @objc static var shared: NativeScriptViewFactory?
127
- @objc static var app: UIKitContainerCtrl?
128
+ @objc static var app: NativeScriptContainerCtrl?
128
129
 
129
130
  // holds key/value map of views for lifecycle handling
130
131
  @objc public var views: NSMutableDictionary?
@@ -154,7 +155,7 @@ struct NativeScriptAppView: UIViewRepresentable {
154
155
 
155
156
  @objc public static func initShared() {
156
157
  if (NativeScriptViewFactory.shared == nil) {
157
- NativeScriptViewFactory.app = UIKitContainerCtrl()
158
+ NativeScriptViewFactory.app = NativeScriptContainerCtrl()
158
159
  NativeScriptViewFactory.shared = NativeScriptViewFactory()
159
160
  NativeScriptViewFactory.shared!.views = NSMutableDictionary()
160
161
  }
@@ -171,7 +172,7 @@ struct NativeScriptAppView: UIViewRepresentable {
171
172
  }
172
173
 
173
174
  // UIViewController
174
- @objc public class UIKitContainerCtrl: UIViewController {
175
+ @objc public class NativeScriptContainerCtrl: UIViewController {
175
176
  // allow NativeScript to override updateData for custom handling
176
177
  @objc public var updateData: ((_ data: NSMutableDictionary) -> Void)? = nil
177
178
  }