@webspatial/platform-visionos 0.1.10 → 0.1.11
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
|
@@ -132,15 +132,6 @@ extension SpatialWindowContainer {
|
|
|
132
132
|
static func getRootID() -> String {
|
|
133
133
|
return RootID
|
|
134
134
|
}
|
|
135
|
-
|
|
136
|
-
static func createRootWindowContainer() -> SpatialWindowContainer {
|
|
137
|
-
if let rootWindowContainer = getSpatialWindowContainer(RootID) {
|
|
138
|
-
logger.warning("Root already created! ")
|
|
139
|
-
return rootWindowContainer
|
|
140
|
-
}
|
|
141
|
-
let wgd = WindowContainerData(windowStyle: "Plain", windowContainerID: "root")
|
|
142
|
-
return SpatialWindowContainer(RootID, wgd)
|
|
143
|
-
}
|
|
144
135
|
}
|
|
145
136
|
|
|
146
137
|
extension SpatialWindowContainer {
|
|
@@ -18,13 +18,9 @@ let startURL = pwaManager.start_url
|
|
|
18
18
|
var sceneStateChangedCB: ((Any) -> Void) = { _ in
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
// TODO: we need to get rid of rootWGD and rootWC to cleanup memory and better handle close/reopen
|
|
22
|
-
weak var rootWC: SpatialWindowComponent?
|
|
23
|
-
|
|
24
21
|
@main
|
|
25
22
|
struct web_spatialApp: App {
|
|
26
23
|
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
|
27
|
-
@State var rootWGD: SpatialWindowContainer
|
|
28
24
|
@State var initialLaunch = true
|
|
29
25
|
|
|
30
26
|
@ObservedObject var wgm = WindowContainerMgr.Instance
|
|
@@ -40,8 +36,7 @@ struct web_spatialApp: App {
|
|
|
40
36
|
// init pwa manager
|
|
41
37
|
pwaManager._init()
|
|
42
38
|
|
|
43
|
-
// create
|
|
44
|
-
rootWGD = SpatialWindowContainer.createRootWindowContainer()
|
|
39
|
+
// create Immersive SpatialWindowContainer
|
|
45
40
|
let _ = SpatialWindowContainer.createImmersiveWindowContainer()
|
|
46
41
|
}
|
|
47
42
|
|
|
@@ -49,25 +44,6 @@ struct web_spatialApp: App {
|
|
|
49
44
|
return URL(string: pwaManager.start_url)!
|
|
50
45
|
}
|
|
51
46
|
|
|
52
|
-
// There seems to be a bug in WKWebView where it needs to be initialized after the app has loaded so we do this here instead of init()
|
|
53
|
-
// https://forums.developer.apple.com/forums/thread/61432
|
|
54
|
-
func initAppOnViewMount() {
|
|
55
|
-
if rootWC == nil {
|
|
56
|
-
let fileUrl = getFileUrl()
|
|
57
|
-
|
|
58
|
-
// Create a default entity with webview resource
|
|
59
|
-
let rootEntity = SpatialEntity()
|
|
60
|
-
rootEntity.coordinateSpace = CoordinateSpaceMode.ROOT
|
|
61
|
-
let windowComponent = SpatialWindowComponent(parentWindowContainerID: rootWGD.id, url: fileUrl)
|
|
62
|
-
rootEntity.addComponent(windowComponent)
|
|
63
|
-
rootEntity.setParentWindowContainer(wg: rootWGD)
|
|
64
|
-
|
|
65
|
-
rootWGD.addChildResource(windowComponent)
|
|
66
|
-
rootWGD.addChildResource(rootEntity)
|
|
67
|
-
rootWC = windowComponent
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
47
|
func getDefaultSize() -> CGSize {
|
|
72
48
|
sceneStateChangedCB("")
|
|
73
49
|
return wgm.getValue().defaultSize!
|
|
@@ -75,34 +51,30 @@ struct web_spatialApp: App {
|
|
|
75
51
|
|
|
76
52
|
var body: some Scene {
|
|
77
53
|
WindowGroup(id: "Plain", for: WindowContainerData.self) { $windowData in
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
//
|
|
83
|
-
// .onOpenURL { myURL in
|
|
84
|
-
// initAppOnViewMount()
|
|
85
|
-
// let urlToLoad = pwaManager.checkInDeeplink(url: myURL.absoluteString)
|
|
86
|
-
//
|
|
87
|
-
// if let url = URL(string: urlToLoad) {
|
|
88
|
-
// // root!.navigateToURL(url: url)
|
|
89
|
-
// }
|
|
90
|
-
// }
|
|
91
|
-
} else {
|
|
92
|
-
let wg = SpatialWindowContainer.getOrCreateSpatialWindowContainer(
|
|
93
|
-
windowData.windowContainerID, windowData
|
|
94
|
-
)
|
|
95
|
-
PlainWindowContainerView().environment(wg)
|
|
96
|
-
// we no longer need the initial windowGroup to live all the time
|
|
97
|
-
// https://stackoverflow.com/questions/78567737/how-to-get-initial-windowgroup-to-reopen-on-launch-visionos
|
|
54
|
+
let wg = SpatialWindowContainer.getOrCreateSpatialWindowContainer(
|
|
55
|
+
windowData.windowContainerID, windowData
|
|
56
|
+
)
|
|
57
|
+
PlainWindowContainerView().environment(wg)
|
|
58
|
+
// https://stackoverflow.com/questions/78567737/how-to-get-initial-windowgroup-to-reopen-on-launch-visionos
|
|
98
59
|
// .handlesExternalEvents(preferring: [], allowing: [])
|
|
99
|
-
}
|
|
100
60
|
}
|
|
101
61
|
defaultValue: {
|
|
102
|
-
WindowContainerData(
|
|
62
|
+
let windowData = WindowContainerData(
|
|
103
63
|
windowStyle: "Plain",
|
|
104
64
|
windowContainerID: SpatialWindowContainer.getRootID()
|
|
105
65
|
)
|
|
66
|
+
|
|
67
|
+
// Initialize entity and webview for deafult value
|
|
68
|
+
let fileUrl = getFileUrl()
|
|
69
|
+
let wc = SpatialWindowContainer.getOrCreateSpatialWindowContainer(
|
|
70
|
+
windowData.windowContainerID, windowData
|
|
71
|
+
)!
|
|
72
|
+
let rootEntity = SpatialEntity()
|
|
73
|
+
rootEntity.coordinateSpace = CoordinateSpaceMode.ROOT
|
|
74
|
+
let windowComponent = SpatialWindowComponent(parentWindowContainerID: wc.id, url: fileUrl)
|
|
75
|
+
rootEntity.addComponent(windowComponent)
|
|
76
|
+
rootEntity.setParentWindowContainer(wg: wc)
|
|
77
|
+
return windowData
|
|
106
78
|
}
|
|
107
79
|
.windowStyle(.plain).onChange(of: scenePhase) {
|
|
108
80
|
oldPhase,
|