From aa806eabf1738a1cd0933ab5f55992e900baed0a Mon Sep 17 00:00:00 2001 From: Miranda Wilson Date: Tue, 12 Dec 2023 18:02:20 +0000 Subject: [PATCH] Add new VisionOS classes --- Examples | 2 +- .../VisionOS/Entities/ComponentEntity.swift | 54 ++++++++ .../Entities/ImmersiveSpaceEntity.swift | 115 +++++++++++++++++ .../VisionOS/Entities/RealityKitEntity.swift | 59 +++++++++ .../Entities/TrackableAnchorEntity.swift | 119 ++++++++++++++++++ .../VisionOS/Entities/WindowEntity.swift | 53 ++++++++ .../VisionOS/Entities/WindowGroupEntity.swift | 59 +++++++++ .../VisionOS/Events/DismissSpaceEvent.swift | 27 ++++ .../VisionOS/Events/DismissWindowEvent.swift | 27 ++++ .../VisionOS/Events/OpenSpaceEvent.swift | 27 ++++ .../VisionOS/Events/OpenWindowEvent.swift | 27 ++++ .../Snowplow/VisionOS/VisionOsSchemata.swift | 30 +++++ Sources/Snowplow/VisionOS/WindowStyle.swift | 46 +++++++ 13 files changed, 644 insertions(+), 1 deletion(-) create mode 100644 Sources/Snowplow/VisionOS/Entities/ComponentEntity.swift create mode 100644 Sources/Snowplow/VisionOS/Entities/ImmersiveSpaceEntity.swift create mode 100644 Sources/Snowplow/VisionOS/Entities/RealityKitEntity.swift create mode 100644 Sources/Snowplow/VisionOS/Entities/TrackableAnchorEntity.swift create mode 100644 Sources/Snowplow/VisionOS/Entities/WindowEntity.swift create mode 100644 Sources/Snowplow/VisionOS/Entities/WindowGroupEntity.swift create mode 100644 Sources/Snowplow/VisionOS/Events/DismissSpaceEvent.swift create mode 100644 Sources/Snowplow/VisionOS/Events/DismissWindowEvent.swift create mode 100644 Sources/Snowplow/VisionOS/Events/OpenSpaceEvent.swift create mode 100644 Sources/Snowplow/VisionOS/Events/OpenWindowEvent.swift create mode 100644 Sources/Snowplow/VisionOS/VisionOsSchemata.swift create mode 100644 Sources/Snowplow/VisionOS/WindowStyle.swift diff --git a/Examples b/Examples index 9d851e13f..3d383f24e 160000 --- a/Examples +++ b/Examples @@ -1 +1 @@ -Subproject commit 9d851e13f8ca357a394c60695777c3970f8ed9bc +Subproject commit 3d383f24e908727f709ae45cf408db0929c3c156 diff --git a/Sources/Snowplow/VisionOS/Entities/ComponentEntity.swift b/Sources/Snowplow/VisionOS/Entities/ComponentEntity.swift new file mode 100644 index 000000000..4ea7537f8 --- /dev/null +++ b/Sources/Snowplow/VisionOS/Entities/ComponentEntity.swift @@ -0,0 +1,54 @@ +// Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved. +// +// This program is licensed to you under the Apache License Version 2.0, +// and you may not use this file except in compliance with the Apache License +// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at +// http://www.apache.org/licenses/LICENSE-2.0. +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the Apache License Version 2.0 is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the Apache License Version 2.0 for the specific +// language governing permissions and limitations there under. + +import Foundation +import RealityFoundation + +/** + Properties for the RealityKit component entity. + Entity schema: `iglu:com.apple.arkit/component/jsonschema/1-0-0` + */ +@objc(SPComponentEntity) +public class ComponentEntity: NSObject { + + /// A globally unique ID for a component. + public var id: String + /// Type of the component, e.g. "PointLightComponent". + public var type: String + /// Textual description of the component. + public var componentDescription: String? + + internal var entity: SelfDescribingJson { + var data: [String : Any] = [ + "id": id, + "type": type + ] + if let componentDescription = componentDescription { data["description"] = componentDescription } + + return SelfDescribingJson(schema: VisionOsSchemata.component, andData: data) + } + + /// - Parameter id: A globally unique ID for a component. + /// - Parameter type: Type of the component, e.g. "PointLightComponent". + /// - Parameter componentDescription: Textual description of the component. + @objc + init( + id: String, + type: String, + componentDescription: String? = nil + ) { + self.id = id + self.type = type + self.componentDescription = componentDescription + } +} diff --git a/Sources/Snowplow/VisionOS/Entities/ImmersiveSpaceEntity.swift b/Sources/Snowplow/VisionOS/Entities/ImmersiveSpaceEntity.swift new file mode 100644 index 000000000..5301669a7 --- /dev/null +++ b/Sources/Snowplow/VisionOS/Entities/ImmersiveSpaceEntity.swift @@ -0,0 +1,115 @@ +// Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved. +// +// This program is licensed to you under the Apache License Version 2.0, +// and you may not use this file except in compliance with the Apache License +// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at +// http://www.apache.org/licenses/LICENSE-2.0. +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the Apache License Version 2.0 is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the Apache License Version 2.0 for the specific +// language governing permissions and limitations there under. + +import Foundation + +/** + Properties for the VisionOS immersive space entity. + Entity schema: `iglu:com.apple.swiftui/immersive_space/jsonschema/1-0-0` + */ +@objc(SPImmersiveSpaceEntity) +public class ImmersiveSpaceEntity: NSObject { + + /// Randomly generated ID for the view of the immersive space by the tracker. + public var id: String + /// The identifier of the immersive space to present. + public var immersiveSpaceId: String? + /// The style of an immersive space. + public var immersionStyle: ImmersionStyle + /// Preferred visibility of the user's upper limbs, while an immersive space scene is presented. + public var upperLimbVisibility: UpperLimbVisibility + + internal var entity: SelfDescribingJson { + var data: [String : Any] = [ + "id": id + ] + if let immersiveSpaceId = immersiveSpaceId { data["immersive_space_id"] = immersiveSpaceId } + data["immersion_style"] = immersionStyle.value + data["upper_limb_visibility"] = upperLimbVisibility.value + + return SelfDescribingJson(schema: VisionOsSchemata.immersiveSpace, andData: data) + } + + /// - Parameter id: Randomly generated ID for the view of the immersive space by the tracker. + /// - Parameter immersiveSpaceId: A localized string key to use for the window's title in system menus and in the window's title bar. + /// - Parameter immersionStyle: A specification for the appearance and interaction of a window. + /// - Parameter upperLimbVisibility: A specification for the appearance and interaction of a window. + @objc + public init( + id: String, + immersiveSpaceId: String? = nil, + immersionStyle: ImmersionStyle, + upperLimbVisibility: UpperLimbVisibility + ) { + self.id = id + self.immersiveSpaceId = immersiveSpaceId + self.immersionStyle = immersionStyle + self.upperLimbVisibility = upperLimbVisibility + } +} + +// MARK: - ImmersionStyle + +/// The style of a VisionOS immersive space. +@objc(SPImmersionStyle) +public enum ImmersionStyle: Int { + /// Default immersion style. + case automatic + /// Displays unbounded content that obscures pass-through video. + case full + /// Displays unbounded content intermixed with other app content. + case mixed + /// Content displays with no clipping boundaries applied. + case progressive +} + +extension ImmersionStyle { + var value: String { + switch self { + case .automatic: + return "automatic" + case .full: + return "full" + case .mixed: + return "mixed" + case .progressive: + return "progressive" + } + } +} + +// MARK: - UpperLimbVisibility + +/// The visibility of the user's upper limbs in a VisionOS immersive space. +@objc(SPUpperLimbVisibility) +public enum UpperLimbVisibility: Int { + /// Limbs may be visible or hidden depending on the policies of the component accepting the visibility configuration. + case automatic + /// Limbs may be visible. + case visible + /// Limbs may be hidden. + case hidden +} + +extension UpperLimbVisibility { + var value: String { + switch self { + case .automatic: + return "automatic" + case .visible: + return "visible" + case .hidden: + return "hidden" + } + } +} diff --git a/Sources/Snowplow/VisionOS/Entities/RealityKitEntity.swift b/Sources/Snowplow/VisionOS/Entities/RealityKitEntity.swift new file mode 100644 index 000000000..880af98b6 --- /dev/null +++ b/Sources/Snowplow/VisionOS/Entities/RealityKitEntity.swift @@ -0,0 +1,59 @@ +// Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved. +// +// This program is licensed to you under the Apache License Version 2.0, +// and you may not use this file except in compliance with the Apache License +// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at +// http://www.apache.org/licenses/LICENSE-2.0. +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the Apache License Version 2.0 is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the Apache License Version 2.0 for the specific +// language governing permissions and limitations there under. + +import Foundation + +/** + Properties for the Snowplow entity that represents a RealityKit Entity. + Entity schema: `iglu:com.apple.realitykit/entity/jsonschema/1-0-0` + */ +@objc(SPRealityKitEntity) +public class RealityKitEntity: NSObject { + +// /// Randomly generated ID for the view of the immersive space by the tracker. +// public var id: String +// /// The identifier of the immersive space to present. +// public var immersiveSpaceId: String? +// /// The style of an immersive space. +// public var immersionStyle: ImmersionStyle +// /// Preferred visibility of the user's upper limbs, while an immersive space scene is presented. +// public var upperLimbVisibility: UpperLimbVisibility +// +// internal var entity: SelfDescribingJson { +// var data: [String : Any] = [ +// "id": id +// ] +// if let immersiveSpaceId = immersiveSpaceId { data["immersive_space_id"] = immersiveSpaceId } +// data["immersion_style"] = immersionStyle.value +// data["upper_limb_visibility"] = upperLimbVisibility.value +// +// return SelfDescribingJson(schema: VisionOsSchemata.immersiveSpace, andData: data) +// } +// +// /// - Parameter id: Randomly generated ID for the view of the immersive space by the tracker. +// /// - Parameter immersiveSpaceId: A localized string key to use for the window's title in system menus and in the window's title bar. +// /// - Parameter immersionStyle: A specification for the appearance and interaction of a window. +// /// - Parameter upperLimbVisibility: A specification for the appearance and interaction of a window. +// @objc +// public init( +// id: String, +// immersiveSpaceId: String? = nil, +// immersionStyle: ImmersionStyle, +// upperLimbVisibility: UpperLimbVisibility +// ) { +// self.id = id +// self.immersiveSpaceId = immersiveSpaceId +// self.immersionStyle = immersionStyle +// self.upperLimbVisibility = upperLimbVisibility +// } +} diff --git a/Sources/Snowplow/VisionOS/Entities/TrackableAnchorEntity.swift b/Sources/Snowplow/VisionOS/Entities/TrackableAnchorEntity.swift new file mode 100644 index 000000000..8567487a7 --- /dev/null +++ b/Sources/Snowplow/VisionOS/Entities/TrackableAnchorEntity.swift @@ -0,0 +1,119 @@ +// Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved. +// +// This program is licensed to you under the Apache License Version 2.0, +// and you may not use this file except in compliance with the Apache License +// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at +// http://www.apache.org/licenses/LICENSE-2.0. +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the Apache License Version 2.0 is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the Apache License Version 2.0 for the specific +// language governing permissions and limitations there under. + +import Foundation +import ARKit + +/** + Properties for the ARKit trackable anchor entity. + Entity schema: `iglu:com.apple.arkit/trackable_anchor/jsonschema/1-0-0` + */ +@objc(SPTrackableAnchorEntity) +public class TrackableAnchorEntity: NSObject { + + /// A globally unique ID for a device anchor. + public var id: String + /// Type of the anchor. + public var type: TrackableAnchorType? + /// Textual description of the anchor. + public var anchorDescription: String? + /// Whether ARKit is tracking the anchor. + public var isTracked: Bool + /// The reference image that this image anchor tracks. + public var referenceImage: ARReferenceImage? + + internal var entity: SelfDescribingJson { + var data: [String : Any] = [ + "id": id + ] + if let type = type { data["type"] = type } + if let anchorDescription = anchorDescription { data["description"] = anchorDescription } + data["is_tracked"] = isTracked + if let referenceImage = referenceImage { + var imageData: [String : Any] = [ + "physical_size": "\(referenceImage.physicalSize.width)x\(referenceImage.physicalSize.height)", + "description": referenceImage.description + ] + if let name = referenceImage.name { data["name"] = name } + data["reference_image"] = imageData + } + + return SelfDescribingJson(schema: VisionOsSchemata.trackableAnchor, andData: data) + } + + /// - Parameter id: A globally unique ID for a device anchor. + /// - Parameter type: Type of the anchor. + /// - Parameter anchorDescription: Textual description of the anchor. + /// - Parameter isTracked: Whether ARKit is tracking the anchor. + /// - Parameter referenceImage: The reference image that this image anchor tracks. + public init( + id: String, + type: TrackableAnchorType? = nil, + anchorDescription: String? = nil, + isTracked: Bool, + referenceImage: ARReferenceImage? = nil + ) { + self.id = id + self.type = type + self.anchorDescription = anchorDescription + self.isTracked = isTracked + self.referenceImage = referenceImage + } + + /// - Parameter id: A globally unique ID for a device anchor. + /// - Parameter anchorDescription: Textual description of the anchor. + /// - Parameter isTracked: Whether ARKit is tracking the anchor. + /// - Parameter referenceImage: The reference image that this image anchor tracks. + @objc + public init( + id: String, + anchorDescription: String? = nil, + isTracked: Bool, + referenceImage: ARReferenceImage? = nil + ) { + self.id = id + self.anchorDescription = anchorDescription + self.isTracked = isTracked + self.referenceImage = referenceImage + } +} + +// MARK: - TrackableAnchorType + +/// The visibility of the user's upper limbs in a VisionOS immersive space. +@objc(SPTrackableAnchorType) +public enum TrackableAnchorType: Int { + /// TODO. + case device + /// TODO. + case world + /// TODO. + case hand + /// TODO. + case image +} + +extension TrackableAnchorType { + var value: String { + switch self { + case .device: + return "device" + case .world: + return "world" + case .hand: + return "hand" + case .image: + return "image" + } + } +} diff --git a/Sources/Snowplow/VisionOS/Entities/WindowEntity.swift b/Sources/Snowplow/VisionOS/Entities/WindowEntity.swift new file mode 100644 index 000000000..1d8794649 --- /dev/null +++ b/Sources/Snowplow/VisionOS/Entities/WindowEntity.swift @@ -0,0 +1,53 @@ +// Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved. +// +// This program is licensed to you under the Apache License Version 2.0, +// and you may not use this file except in compliance with the Apache License +// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at +// http://www.apache.org/licenses/LICENSE-2.0. +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the Apache License Version 2.0 is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the Apache License Version 2.0 for the specific +// language governing permissions and limitations there under. + +import Foundation + +/** + Properties for the VisionOS window scene entity. + Entity schema: `iglu:com.apple.swiftui/window/jsonschema/1-0-0` + */ +@objc(SPWindowEntity) +public class WindowEntity: NSObject { + + /// A unique string identifier that you can use to open the window. + public var id: String? + /// A localized string key to use for the window's title in system menus and in the window's title bar. Provide a title that describes the purpose of the window. + public var titleKey: String? + /// A specification for the appearance and interaction of a window. + public var windowStyle: WindowStyle + + internal var entity: SelfDescribingJson { + var data: [String : Any] = [ + "window_style": windowStyle.value + ] + if let id = id { data["id"] = id } + if let titleKey = titleKey { data["title_key"] = titleKey } + + return SelfDescribingJson(schema: VisionOsSchemata.window, andData: data) + } + + /// - Parameter windowStyle: A specification for the appearance and interaction of a window. + /// - Parameter id: A unique string identifier that you can use to open the window. + /// - Parameter titleKey: A localized string key to use for the window's title in system menus and in the window's title bar. + @objc + public init( + windowStyle: WindowStyle, + id: String? = nil, + titleKey: String? = nil + ) { + self.id = id + self.titleKey = titleKey + self.windowStyle = windowStyle + } +} diff --git a/Sources/Snowplow/VisionOS/Entities/WindowGroupEntity.swift b/Sources/Snowplow/VisionOS/Entities/WindowGroupEntity.swift new file mode 100644 index 000000000..4896653fa --- /dev/null +++ b/Sources/Snowplow/VisionOS/Entities/WindowGroupEntity.swift @@ -0,0 +1,59 @@ +// Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved. +// +// This program is licensed to you under the Apache License Version 2.0, +// and you may not use this file except in compliance with the Apache License +// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at +// http://www.apache.org/licenses/LICENSE-2.0. +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the Apache License Version 2.0 is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the Apache License Version 2.0 for the specific +// language governing permissions and limitations there under. + +import Foundation + +/** + Properties for the VisionOS window group entity. + Entity schema: `iglu:com.apple.swiftui/window_group/jsonschema/1-0-0` + */ +@objc(SPWindowGroupEntity) +public class WindowGroupEntity: NSObject { + + /// Randomly generated ID for the current window within the group. + public var id: String + /// A localized string key to use for the window's title in system menus and in the window's title bar. Provide a title that describes the purpose of the window. + public var titleKey: String? + /// A string that uniquely identifies the window group. Identifiers must be unique among the window groups in your app. + public var windowGroupID: String? + /// A specification for the appearance and interaction of a window. + public var windowStyle: WindowStyle + + internal var entity: SelfDescribingJson { + var data: [String : Any] = [ + "id": id + ] + if let titleKey = titleKey { data["title_key"] = titleKey } + if let windowGroupID = windowGroupID { data["window_group_id"] = windowGroupID } + data["window_style"] = windowStyle.value + + return SelfDescribingJson(schema: VisionOsSchemata.windowGroup, andData: data) + } + + /// - Parameter id: Randomly generated ID for the current window within the group. + /// - Parameter titleKey: A localized string key to use for the window's title in system menus and in the window's title bar. + /// - Parameter windowGroupID: A string that uniquely identifies the window group. + /// - Parameter windowStyle: A specification for the appearance and interaction of a window. + @objc + public init( + id: String = UUID().uuidString, + titleKey: String? = nil, + windowGroupID: String? = nil, + windowStyle: WindowStyle + ) { + self.id = id + self.titleKey = titleKey + self.windowGroupID = windowGroupID + self.windowStyle = windowStyle + } +} diff --git a/Sources/Snowplow/VisionOS/Events/DismissSpaceEvent.swift b/Sources/Snowplow/VisionOS/Events/DismissSpaceEvent.swift new file mode 100644 index 000000000..b076e3d02 --- /dev/null +++ b/Sources/Snowplow/VisionOS/Events/DismissSpaceEvent.swift @@ -0,0 +1,27 @@ +// Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved. +// +// This program is licensed to you under the Apache License Version 2.0, +// and you may not use this file except in compliance with the Apache License +// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at +// http://www.apache.org/licenses/LICENSE-2.0. +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the Apache License Version 2.0 is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the Apache License Version 2.0 for the specific +// language governing permissions and limitations there under. + +import Foundation + +/** VisionOS event for an immersive space being dismissed. */ +@objc(SPDismissSpaceEvent) +public class DismissSpaceEvent: SelfDescribingAbstract { + + override var schema: String { + return VisionOsSchemata.dismissSpace + } + + override var payload: [String : Any] { + return [:] + } +} diff --git a/Sources/Snowplow/VisionOS/Events/DismissWindowEvent.swift b/Sources/Snowplow/VisionOS/Events/DismissWindowEvent.swift new file mode 100644 index 000000000..2818612ea --- /dev/null +++ b/Sources/Snowplow/VisionOS/Events/DismissWindowEvent.swift @@ -0,0 +1,27 @@ +// Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved. +// +// This program is licensed to you under the Apache License Version 2.0, +// and you may not use this file except in compliance with the Apache License +// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at +// http://www.apache.org/licenses/LICENSE-2.0. +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the Apache License Version 2.0 is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the Apache License Version 2.0 for the specific +// language governing permissions and limitations there under. + +import Foundation + +/** VisionOS event for a window being dismissed. */ +@objc(SPDismissWindowEvent) +public class DismissWindowEvent: SelfDescribingAbstract { + + override var schema: String { + return VisionOsSchemata.dismissWindow + } + + override var payload: [String : Any] { + return [:] + } +} diff --git a/Sources/Snowplow/VisionOS/Events/OpenSpaceEvent.swift b/Sources/Snowplow/VisionOS/Events/OpenSpaceEvent.swift new file mode 100644 index 000000000..71befcafe --- /dev/null +++ b/Sources/Snowplow/VisionOS/Events/OpenSpaceEvent.swift @@ -0,0 +1,27 @@ +// Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved. +// +// This program is licensed to you under the Apache License Version 2.0, +// and you may not use this file except in compliance with the Apache License +// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at +// http://www.apache.org/licenses/LICENSE-2.0. +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the Apache License Version 2.0 is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the Apache License Version 2.0 for the specific +// language governing permissions and limitations there under. + +import Foundation + +/** VisionOS event for an immersive space being opened. */ +@objc(SPOpenSpaceEvent) +public class OpenSpaceEvent: SelfDescribingAbstract { + + override var schema: String { + return VisionOsSchemata.openSpace + } + + override var payload: [String : Any] { + return [:] + } +} diff --git a/Sources/Snowplow/VisionOS/Events/OpenWindowEvent.swift b/Sources/Snowplow/VisionOS/Events/OpenWindowEvent.swift new file mode 100644 index 000000000..ba5c36e73 --- /dev/null +++ b/Sources/Snowplow/VisionOS/Events/OpenWindowEvent.swift @@ -0,0 +1,27 @@ +// Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved. +// +// This program is licensed to you under the Apache License Version 2.0, +// and you may not use this file except in compliance with the Apache License +// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at +// http://www.apache.org/licenses/LICENSE-2.0. +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the Apache License Version 2.0 is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the Apache License Version 2.0 for the specific +// language governing permissions and limitations there under. + +import Foundation + +/** VisionOS event for a window being opened. */ +@objc(SPOpenWindowEvent) +public class OpenWindowEvent: SelfDescribingAbstract { + + override var schema: String { + return VisionOsSchemata.openWindow + } + + override var payload: [String : Any] { + return [:] + } +} diff --git a/Sources/Snowplow/VisionOS/VisionOsSchemata.swift b/Sources/Snowplow/VisionOS/VisionOsSchemata.swift new file mode 100644 index 000000000..22f869ae1 --- /dev/null +++ b/Sources/Snowplow/VisionOS/VisionOsSchemata.swift @@ -0,0 +1,30 @@ +// Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved. +// +// This program is licensed to you under the Apache License Version 2.0, +// and you may not use this file except in compliance with the Apache License +// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at +// http://www.apache.org/licenses/LICENSE-2.0. +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the Apache License Version 2.0 is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the Apache License Version 2.0 for the specific +// language governing permissions and limitations there under. + +import Foundation + +class VisionOsSchemata { + static let openWindow = "iglu:com.apple.swiftui/open_window/jsonschema/1-0-0" + static let dismissWindow = "iglu:com.apple.swiftui/dismiss_window/jsonschema/1-0-0" + static let openSpace = "iglu:com.apple.swiftui/open_immersive_space/jsonschema/1-0-0" + static let dismissSpace = "iglu:com.apple.swiftui/dismiss_immersive_space/jsonschema/1-0-0" + + static let windowGroup = "iglu:com.apple.swiftui/window_group/jsonschema/1-0-0" + static let window = "iglu:com.apple.swiftui/window/jsonschema/1-0-0" + static let immersiveSpace = "iglu:com.apple.swiftui/immersive_space/jsonschema/1-0-0" + + static let realityKit = "iglu:com.apple.realitykit/entity/jsonschema/1-0-0" + static let component = "iglu:com.apple.realitykit/component/jsonschema/1-0-0" + + static let trackableAnchor = "iglu:com.apple.arkit/trackable_anchor/jsonschema/1-0-0" +} diff --git a/Sources/Snowplow/VisionOS/WindowStyle.swift b/Sources/Snowplow/VisionOS/WindowStyle.swift new file mode 100644 index 000000000..1564f4434 --- /dev/null +++ b/Sources/Snowplow/VisionOS/WindowStyle.swift @@ -0,0 +1,46 @@ +// Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved. +// +// This program is licensed to you under the Apache License Version 2.0, +// and you may not use this file except in compliance with the Apache License +// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at +// http://www.apache.org/licenses/LICENSE-2.0. +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the Apache License Version 2.0 is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the Apache License Version 2.0 for the specific +// language governing permissions and limitations there under. + +import Foundation + +/// A specification for the appearance and interaction of a window. +@objc(SPWindowStyle) +public enum WindowStyle: Int { + /// Default window style. + case automatic + /// Hides both the window’s title and the backing of the titlebar area. + case hiddenTitleBar + /// Plain window style. + case plain + /// Displays the title bar section of the window. + case titleBar + /// Creates a 3D volumetric window. + case volumetric +} + +extension WindowStyle { + var value: String { + switch self { + case .automatic: + return "automatic" + case .hiddenTitleBar: + return "hiddenTitleBar" + case .plain: + return "plain" + case .titleBar: + return "titleBar" + case .volumetric: + return "volumetric" + } + } +}