@webspatial/builder 0.0.10 → 0.0.12
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/README.md +63 -0
- package/dist/index.js +1 -1
- package/dist/lib/Cli.js +1 -1
- package/dist/lib/cmds/build.d.ts +1 -1
- package/dist/lib/cmds/build.js +1 -1
- package/dist/lib/cmds/check.js +1 -1
- package/dist/lib/cmds/help.js +1 -1
- package/dist/lib/cmds/version.js +1 -1
- package/dist/lib/pwa/config.d.ts +1 -1
- package/dist/lib/pwa/config.js +1 -1
- package/dist/lib/pwa/index.d.ts +2 -1
- package/dist/lib/pwa/index.js +1 -1
- package/dist/lib/pwa/validate.js +1 -1
- package/dist/lib/resource/file.js +1 -1
- package/dist/lib/resource/imageHelper.js +1 -1
- package/dist/lib/resource/index.d.ts +10 -3
- package/dist/lib/resource/index.js +1 -1
- package/dist/lib/resource/load.js +1 -1
- package/dist/lib/utils/CustomError.js +1 -1
- package/dist/lib/utils/FetchUtils-1.js +1 -1
- package/dist/lib/utils/Log.js +1 -1
- package/dist/lib/utils/fetch.js +1 -1
- package/dist/lib/utils/messages.js +1 -1
- package/dist/lib/utils/utils.js +1 -1
- package/dist/lib/xcode/index.js +1 -1
- package/dist/lib/xcode/manifestSwiftTemplate.js +1 -1
- package/dist/lib/xcode/xcodebuild.js +1 -1
- package/dist/lib/xcode/xcodeproject.js +1 -1
- package/dist/lib/xcode/xcrun.js +1 -1
- package/package.json +3 -2
- package/template/visionOSApp/Packages/RealityKitContent/.build/workspace-state.json +0 -7
- package/template/visionOSApp/Packages/RealityKitContent/.swiftpm/xcode/xcuserdata/bytedance.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/template/visionOSApp/Packages/RealityKitContent/Package.realitycomposerpro/ProjectData/main.json +0 -11
- package/template/visionOSApp/Packages/RealityKitContent/Package.realitycomposerpro/WorkspaceData/SceneMetadataList.json +0 -112
- package/template/visionOSApp/Packages/RealityKitContent/Package.realitycomposerpro/WorkspaceData/Settings.rcprojectdata +0 -17
- package/template/visionOSApp/Packages/RealityKitContent/Package.swift +0 -27
- package/template/visionOSApp/Packages/RealityKitContent/README.md +0 -3
- package/template/visionOSApp/Packages/RealityKitContent/Sources/RealityKitContent/RealityKitContent.rkassets/Immersive.usda +0 -50
- package/template/visionOSApp/Packages/RealityKitContent/Sources/RealityKitContent/RealityKitContent.rkassets/Materials/GridMaterial.usda +0 -216
- package/template/visionOSApp/Packages/RealityKitContent/Sources/RealityKitContent/RealityKitContent.rkassets/Scene.usda +0 -59
- package/template/visionOSApp/Packages/RealityKitContent/Sources/RealityKitContent/RealityKitContent.swift +0 -4
- package/template/visionOSApp/web-spatial/Assets.xcassets/AppIcon.solidimagestack/Back.solidimagestacklayer/Content.imageset/Contents.json +0 -12
- package/template/visionOSApp/web-spatial/Assets.xcassets/AppIcon.solidimagestack/Back.solidimagestacklayer/Contents.json +0 -6
- package/template/visionOSApp/web-spatial/Assets.xcassets/AppIcon.solidimagestack/Contents.json +0 -17
- package/template/visionOSApp/web-spatial/Assets.xcassets/AppIcon.solidimagestack/Front.solidimagestacklayer/Content.imageset/Contents.json +0 -12
- package/template/visionOSApp/web-spatial/Assets.xcassets/AppIcon.solidimagestack/Front.solidimagestacklayer/Contents.json +0 -6
- package/template/visionOSApp/web-spatial/Assets.xcassets/AppIcon.solidimagestack/Middle.solidimagestacklayer/Content.imageset/Contents.json +0 -12
- package/template/visionOSApp/web-spatial/Assets.xcassets/AppIcon.solidimagestack/Middle.solidimagestacklayer/Contents.json +0 -6
- package/template/visionOSApp/web-spatial/Assets.xcassets/Contents.json +0 -6
- package/template/visionOSApp/web-spatial/Info.plist +0 -33
- package/template/visionOSApp/web-spatial/Preview Content/Preview Assets.xcassets/Contents.json +0 -6
- package/template/visionOSApp/web-spatial/libs/EventEmitter.swift +0 -32
- package/template/visionOSApp/web-spatial/libs/SpatialComponent.swift +0 -31
- package/template/visionOSApp/web-spatial/libs/SpatialEntity.swift +0 -179
- package/template/visionOSApp/web-spatial/libs/SpatialInputComponent.swift +0 -26
- package/template/visionOSApp/web-spatial/libs/SpatialMeshResource.swift +0 -19
- package/template/visionOSApp/web-spatial/libs/SpatialModel3DComponent.swift +0 -51
- package/template/visionOSApp/web-spatial/libs/SpatialModelComponent.swift +0 -32
- package/template/visionOSApp/web-spatial/libs/SpatialObject.swift +0 -144
- package/template/visionOSApp/web-spatial/libs/SpatialPhysicallyBasedMaterial.swift +0 -19
- package/template/visionOSApp/web-spatial/libs/SpatialViewComponent.swift +0 -15
- package/template/visionOSApp/web-spatial/libs/SpatialWindowComponent.swift +0 -420
- package/template/visionOSApp/web-spatial/libs/SpatialWindowContainer.swift +0 -149
- package/template/visionOSApp/web-spatial/libs/Utils/CommandManager.swift +0 -800
- package/template/visionOSApp/web-spatial/libs/Utils/Logger.swift +0 -36
- package/template/visionOSApp/web-spatial/libs/Utils/SceneManager.swift +0 -108
- package/template/visionOSApp/web-spatial/libs/Utils/WindowContainerMgr.swift +0 -117
- package/template/visionOSApp/web-spatial/libs/json/JsonParser.swift +0 -52
- package/template/visionOSApp/web-spatial/libs/uiKitDelegate/Window.swift +0 -34
- package/template/visionOSApp/web-spatial/libs/webView/UpdateSystem.swift +0 -33
- package/template/visionOSApp/web-spatial/libs/webView/backend/NativeWebView.swift +0 -319
- package/template/visionOSApp/web-spatial/libs/webView/manifest.swift +0 -92
- package/template/visionOSApp/web-spatial/static-web/index.html +0 -9
- package/template/visionOSApp/web-spatial/views/HideViewModifier.swift +0 -17
- package/template/visionOSApp/web-spatial/views/ImmersiveView.swift +0 -24
- package/template/visionOSApp/web-spatial/views/LoadingView.swift +0 -29
- package/template/visionOSApp/web-spatial/views/MaterialWithBorderCornerModifier.swift +0 -82
- package/template/visionOSApp/web-spatial/views/OpenDismissHandlerUI.swift +0 -52
- package/template/visionOSApp/web-spatial/views/PlainWindowContainerView.swift +0 -84
- package/template/visionOSApp/web-spatial/views/SpatialModel3DView.swift +0 -193
- package/template/visionOSApp/web-spatial/views/SpatialViewUI.swift +0 -168
- package/template/visionOSApp/web-spatial/views/SpatialWebViewUI.swift +0 -186
- package/template/visionOSApp/web-spatial/views/VolumetricWindowContainerView.swift +0 -38
- package/template/visionOSApp/web-spatial/views/ui/NavView.swift +0 -125
- package/template/visionOSApp/web-spatial/web_spatialApp.swift +0 -158
- package/template/visionOSApp/web-spatial.xcodeproj/project.pbxproj +0 -686
- package/template/visionOSApp/web-spatial.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/template/visionOSApp/web-spatial.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/template/visionOSApp/web-spatial.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +0 -5
- package/template/visionOSApp/web-spatial.xcodeproj/project.xcworkspace/xcuserdata/bytedance.xcuserdatad/WorkspaceSettings.xcsettings +0 -14
- package/template/visionOSApp/web-spatial.xcodeproj/xcshareddata/xcschemes/web-spatial.xcscheme +0 -115
- package/template/visionOSApp/web-spatial.xcodeproj/xcuserdata/bytedance.xcuserdatad/xcschemes/xcschememanagement.plist +0 -27
- package/template/visionOSApp/web-spatialTests/web_spatialTests.swift +0 -34
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// NavView.swift
|
|
3
|
-
// web-spatial
|
|
4
|
-
//
|
|
5
|
-
// Created by ByteDance on 2025/1/8.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
import SwiftUI
|
|
9
|
-
import WebKit
|
|
10
|
-
|
|
11
|
-
struct NavView: View {
|
|
12
|
-
@State var swc: SpatialWindowComponent?
|
|
13
|
-
@State var showUrl: Bool = true
|
|
14
|
-
@State private var showCopyTip = false
|
|
15
|
-
@State private var navWidth: CGFloat = 0
|
|
16
|
-
@State private var navHeight: CGFloat = 0
|
|
17
|
-
@State private var texWidth: CGFloat = 0
|
|
18
|
-
@State private var firstGetSize: Bool = true
|
|
19
|
-
|
|
20
|
-
var body: some View {
|
|
21
|
-
ZStack(alignment: .bottomTrailing) {
|
|
22
|
-
ZStack {}.frame(width: navWidth, height: navHeight)
|
|
23
|
-
VStack(alignment: .trailing, spacing: 5) {
|
|
24
|
-
if showUrl {
|
|
25
|
-
Text(pwaManager.name).padding(10)
|
|
26
|
-
if pwaManager.display == .minimal {
|
|
27
|
-
HStack(spacing: 5) {
|
|
28
|
-
Button(action: {
|
|
29
|
-
swc?.goBack()
|
|
30
|
-
}, label: {
|
|
31
|
-
Image(systemName: "arrow.left")
|
|
32
|
-
})
|
|
33
|
-
.disabled(!(swc?.canGoBack ?? false))
|
|
34
|
-
Button(action: {
|
|
35
|
-
swc?.goForward()
|
|
36
|
-
}, label: {
|
|
37
|
-
Image(systemName: "arrow.right")
|
|
38
|
-
})
|
|
39
|
-
.disabled(!(swc?.canGoBack ?? false))
|
|
40
|
-
Button(action: {
|
|
41
|
-
swc?.reload()
|
|
42
|
-
}, label: {
|
|
43
|
-
Image(systemName: "arrow.clockwise")
|
|
44
|
-
})
|
|
45
|
-
Button(
|
|
46
|
-
action: {
|
|
47
|
-
swc?
|
|
48
|
-
.navigateToURL(
|
|
49
|
-
url: URL(string: pwaManager.start_url)!
|
|
50
|
-
)
|
|
51
|
-
},
|
|
52
|
-
label: {
|
|
53
|
-
Image(systemName: "house.fill")
|
|
54
|
-
}
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
HStack(spacing: 5) {
|
|
60
|
-
if showUrl {
|
|
61
|
-
Text(
|
|
62
|
-
swc?.getURL()?.absoluteString ?? "http://localhost:5173/"
|
|
63
|
-
)
|
|
64
|
-
.padding()
|
|
65
|
-
.lineLimit(1)
|
|
66
|
-
.overlay(GeometryReader { geo -> AnyView in
|
|
67
|
-
DispatchQueue.main.async {
|
|
68
|
-
if geo.size.width > 0 {
|
|
69
|
-
texWidth = .minimum(300, geo.size.width)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return AnyView(EmptyView())
|
|
73
|
-
})
|
|
74
|
-
.frame(width: texWidth == 0 ? .infinity : texWidth)
|
|
75
|
-
Button(action: {
|
|
76
|
-
UIPasteboard.general.string = swc?.getURL()?.absoluteString ?? ""
|
|
77
|
-
showCopyTip = true
|
|
78
|
-
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
|
|
79
|
-
showCopyTip = false
|
|
80
|
-
}
|
|
81
|
-
}, label: {
|
|
82
|
-
Text("copy")
|
|
83
|
-
})
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
Button(action: {
|
|
87
|
-
withAnimation(.easeInOut(duration: 0.5)) {
|
|
88
|
-
showUrl.toggle()
|
|
89
|
-
}
|
|
90
|
-
}, label: {
|
|
91
|
-
Image(systemName: showUrl ? "xmark" : "info")
|
|
92
|
-
})
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
.padding()
|
|
96
|
-
.glassBackgroundEffect(in: RoundedRectangle(cornerRadius: 15))
|
|
97
|
-
.popover(isPresented: $showCopyTip) {
|
|
98
|
-
Text("copied!")
|
|
99
|
-
.padding()
|
|
100
|
-
.cornerRadius(10)
|
|
101
|
-
}
|
|
102
|
-
.overlay(GeometryReader { geo -> AnyView in
|
|
103
|
-
DispatchQueue.main.async {
|
|
104
|
-
if firstGetSize {
|
|
105
|
-
navWidth = geo.size.width
|
|
106
|
-
navHeight = geo.size.height
|
|
107
|
-
firstGetSize.toggle()
|
|
108
|
-
showUrl.toggle()
|
|
109
|
-
print(navWidth)
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return AnyView(EmptyView())
|
|
113
|
-
})
|
|
114
|
-
.opacity(firstGetSize ? 0 : 1)
|
|
115
|
-
}
|
|
116
|
-
.frame(width: firstGetSize ? .infinity : navWidth, height: firstGetSize ? .infinity : navHeight)
|
|
117
|
-
.offset(z: 30)
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
struct NavView_Previews: PreviewProvider {
|
|
122
|
-
static var previews: some View {
|
|
123
|
-
NavView()
|
|
124
|
-
}
|
|
125
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// web_spatialApp.swift
|
|
3
|
-
// web-spatial
|
|
4
|
-
//
|
|
5
|
-
// Created by ByteDance on 5/8/24.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
import typealias RealityKit.Attachment
|
|
9
|
-
import typealias RealityKit.Entity
|
|
10
|
-
import typealias RealityKit.MeshResource
|
|
11
|
-
import typealias RealityKit.Model3D
|
|
12
|
-
import typealias RealityKit.ModelEntity
|
|
13
|
-
import typealias RealityKit.RealityView
|
|
14
|
-
import typealias RealityKit.SimpleMaterial
|
|
15
|
-
import SwiftUI
|
|
16
|
-
|
|
17
|
-
let logger = Logger()
|
|
18
|
-
|
|
19
|
-
// To load a local path, remove http:// eg. "static-web/"
|
|
20
|
-
let nativeAPIVersion = "0.0.1"
|
|
21
|
-
|
|
22
|
-
// detect when app properties like defaultSize change so we can avoid race condition of setting default values and then opening window container
|
|
23
|
-
var sceneStateChangedCB: ((Any) -> Void) = { _ in
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@main
|
|
27
|
-
struct web_spatialApp: App {
|
|
28
|
-
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
|
29
|
-
@State var root: SpatialWindowComponent? = nil
|
|
30
|
-
@State var rootWGD: SpatialWindowContainer
|
|
31
|
-
@State var initialLaunch = true
|
|
32
|
-
|
|
33
|
-
@ObservedObject var wgm = WindowContainerMgr.Instance
|
|
34
|
-
|
|
35
|
-
@Environment(\.scenePhase) private var scenePhase
|
|
36
|
-
|
|
37
|
-
init() {
|
|
38
|
-
logger.debug("WebSpatial App Started --------")
|
|
39
|
-
|
|
40
|
-
// init global logger
|
|
41
|
-
Logger.initLogger()
|
|
42
|
-
|
|
43
|
-
// init pwa manager
|
|
44
|
-
pwaManager._init()
|
|
45
|
-
|
|
46
|
-
// create root SpatialWindowContainer and Immersive SpatialWindowContainer
|
|
47
|
-
rootWGD = SpatialWindowContainer.createRootWindowContainer()
|
|
48
|
-
let _ = SpatialWindowContainer.createImmersiveWindowContainer()
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
func getFileUrl() -> URL {
|
|
52
|
-
return URL(string: pwaManager.start_url)!
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// 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()
|
|
56
|
-
// https://forums.developer.apple.com/forums/thread/61432
|
|
57
|
-
func initAppOnViewMount() {
|
|
58
|
-
if root == nil {
|
|
59
|
-
let fileUrl = getFileUrl()
|
|
60
|
-
|
|
61
|
-
// Create a default entity with webview resource
|
|
62
|
-
let rootEntity = SpatialEntity()
|
|
63
|
-
rootEntity.coordinateSpace = CoordinateSpaceMode.ROOT
|
|
64
|
-
let windowComponent = SpatialWindowComponent(parentWindowContainerID: rootWGD.id, url: fileUrl)
|
|
65
|
-
rootEntity.addComponent(windowComponent)
|
|
66
|
-
rootEntity.setParentWindowContainer(wg: rootWGD)
|
|
67
|
-
|
|
68
|
-
root = windowComponent
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
func getDefaultSize() -> CGSize {
|
|
73
|
-
sceneStateChangedCB("")
|
|
74
|
-
return wgm.getValue().defaultSize!
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
var body: some Scene {
|
|
78
|
-
WindowGroup(id: "Plain", for: WindowContainerData.self) { $windowData in
|
|
79
|
-
if windowData.windowContainerID == SpatialWindowContainer.getRootID() {
|
|
80
|
-
VStack {}.onAppear { initAppOnViewMount() }
|
|
81
|
-
|
|
82
|
-
PlainWindowContainerView().environment(rootWGD).background(Color.clear.opacity(0)).onOpenURL { myURL in
|
|
83
|
-
initAppOnViewMount()
|
|
84
|
-
let urlToLoad = pwaManager.checkInDeeplink(url: myURL.absoluteString)
|
|
85
|
-
|
|
86
|
-
if let url = URL(string: urlToLoad) {
|
|
87
|
-
root!.navigateToURL(url: url)
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
} else {
|
|
91
|
-
let wg = SpatialWindowContainer.getOrCreateSpatialWindowContainer(
|
|
92
|
-
windowData.windowContainerID, windowData
|
|
93
|
-
)
|
|
94
|
-
PlainWindowContainerView().environment(wg)
|
|
95
|
-
// we no longer need the initial windowGroup to live all the time
|
|
96
|
-
// https://stackoverflow.com/questions/78567737/how-to-get-initial-windowgroup-to-reopen-on-launch-visionos
|
|
97
|
-
// .handlesExternalEvents(preferring: [], allowing: [])
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
defaultValue: {
|
|
101
|
-
WindowContainerData(
|
|
102
|
-
windowStyle: "Plain",
|
|
103
|
-
windowContainerID: SpatialWindowContainer.getRootID()
|
|
104
|
-
)
|
|
105
|
-
}
|
|
106
|
-
.windowStyle(.plain).onChange(of: scenePhase) {
|
|
107
|
-
oldPhase,
|
|
108
|
-
newPhase in
|
|
109
|
-
if oldPhase == .background && newPhase == .inactive {
|
|
110
|
-
if initialLaunch {
|
|
111
|
-
// App initial open
|
|
112
|
-
initialLaunch = false
|
|
113
|
-
} else {
|
|
114
|
-
// App reopened
|
|
115
|
-
|
|
116
|
-
let fileUrl = getFileUrl()
|
|
117
|
-
if let awid = SpatialWindowContainer.firstActivePlainWindowContainerId,
|
|
118
|
-
let wc = SpatialWindowContainer.getSpatialWindowContainer(
|
|
119
|
-
awid
|
|
120
|
-
)
|
|
121
|
-
{
|
|
122
|
-
let rootEntity = wc.getEntities().filter {
|
|
123
|
-
$0.value.getComponent(SpatialWindowComponent.self) != nil && $0.value.coordinateSpace == .ROOT
|
|
124
|
-
}.first?.value
|
|
125
|
-
|
|
126
|
-
if let wv = rootEntity?.getComponent(SpatialWindowComponent.self) {
|
|
127
|
-
wv.navigateToURL(url: fileUrl)
|
|
128
|
-
}
|
|
129
|
-
// reset to mainScene size
|
|
130
|
-
wgm.setToMainSceneCfg()
|
|
131
|
-
wc.setSize.send(getDefaultSize())
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
}.defaultSize(
|
|
137
|
-
getDefaultSize()
|
|
138
|
-
).windowResizability(
|
|
139
|
-
wgm.getValue().windowResizability!
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
WindowGroup(id: "Volumetric", for: WindowContainerData.self) { $windowData in
|
|
143
|
-
let wg = SpatialWindowContainer.getOrCreateSpatialWindowContainer(windowData!.windowContainerID, windowData!)
|
|
144
|
-
VolumetricWindowContainerView().environment(wg).handlesExternalEvents(preferring: [], allowing: [])
|
|
145
|
-
|
|
146
|
-
}.windowStyle(.volumetric).defaultSize(width: 1, height: 1, depth: 1, in: .meters)
|
|
147
|
-
|
|
148
|
-
ImmersiveSpace(id: "ImmersiveSpace") {
|
|
149
|
-
if let wg = SpatialWindowContainer.getImmersiveWindowContainer() {
|
|
150
|
-
VolumetricWindowContainerView().environment(wg).handlesExternalEvents(preferring: [], allowing: [])
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
WindowGroup(id: "loading") {
|
|
155
|
-
LoadingView()
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|