diff --git a/Sources/TokamakCore/App/AppStorage.swift b/Sources/TokamakCore/App/AppStorage.swift index eb3b0dfa4..04ded2519 100644 --- a/Sources/TokamakCore/App/AppStorage.swift +++ b/Sources/TokamakCore/App/AppStorage.swift @@ -173,6 +173,7 @@ struct DefaultAppStorageEnvironmentKey: EnvironmentKey { } public extension EnvironmentValues { + @_spi(TokamakCore) var _defaultAppStorage: _StorageProvider? { get { self[DefaultAppStorageEnvironmentKey.self] diff --git a/Sources/TokamakCore/App/Scenes/WindowGroup.swift b/Sources/TokamakCore/App/Scenes/WindowGroup.swift index f3e4192bd..cd2d5c12a 100644 --- a/Sources/TokamakCore/App/Scenes/WindowGroup.swift +++ b/Sources/TokamakCore/App/Scenes/WindowGroup.swift @@ -63,6 +63,7 @@ public struct WindowGroup: Scene, TitledScene where Content: View { self.content = content() } + @_spi(TokamakCore) public var body: Never { neverScene("WindowGroup") } diff --git a/Sources/TokamakCore/App/Scenes/_SceneModifier.swift b/Sources/TokamakCore/App/Scenes/_SceneModifier.swift index b9030669e..555c3598a 100644 --- a/Sources/TokamakCore/App/Scenes/_SceneModifier.swift +++ b/Sources/TokamakCore/App/Scenes/_SceneModifier.swift @@ -25,6 +25,7 @@ public struct _SceneModifier_Content: Scene where Modifier: _SceneModi public let modifier: Modifier public let scene: _AnyScene + @_spi(TokamakCore) public var body: Never { neverScene("_SceneModifier_Content") } diff --git a/Sources/TokamakCore/App/_AnyApp.swift b/Sources/TokamakCore/App/_AnyApp.swift index 488cf2f2a..94fef4112 100644 --- a/Sources/TokamakCore/App/_AnyApp.swift +++ b/Sources/TokamakCore/App/_AnyApp.swift @@ -31,26 +31,32 @@ public struct _AnyApp: App { bodyType = A.Body.self } + @_spi(TokamakCore) public var body: Never { neverScene("_AnyApp") } + @_spi(TokamakCore) public init() { fatalError("`_AnyApp` cannot be initialized without an underlying `App` type.") } + @_spi(TokamakCore) public static func _launch(_ app: Self, _ rootEnvironment: EnvironmentValues) { fatalError("`_AnyApp` cannot be launched. Access underlying `app` value.") } + @_spi(TokamakCore) public static func _setTitle(_ title: String) { fatalError("`title` cannot be set for `AnyApp`. Access underlying `app` value.") } + @_spi(TokamakCore) public var _phasePublisher: AnyPublisher { fatalError("`_AnyApp` cannot monitor scenePhase. Access underlying `app` value.") } + @_spi(TokamakCore) public var _colorSchemePublisher: AnyPublisher { fatalError("`_AnyApp` cannot monitor colorScheme. Access underlying `app` value.") } diff --git a/Sources/TokamakCore/App/_AnyScene.swift b/Sources/TokamakCore/App/_AnyScene.swift index 59156bdbb..0a48557ff 100644 --- a/Sources/TokamakCore/App/_AnyScene.swift +++ b/Sources/TokamakCore/App/_AnyScene.swift @@ -66,6 +66,7 @@ public struct _AnyScene: Scene { } } + @_spi(TokamakCore) public var body: Never { neverScene("_AnyScene") } diff --git a/Sources/TokamakCore/Modifiers/LifecycleModifier.swift b/Sources/TokamakCore/Modifiers/LifecycleModifier.swift index aeda09b2b..5653a550a 100644 --- a/Sources/TokamakCore/Modifiers/LifecycleModifier.swift +++ b/Sources/TokamakCore/Modifiers/LifecycleModifier.swift @@ -14,10 +14,12 @@ // FIXME: these should have standalone implementations public extension View { + @_spi(TokamakCore) func _onMount(perform action: (() -> ())? = nil) -> some View { modifier(_AppearanceActionModifier(appear: action)) } + @_spi(TokamakCore) func _onUnmount(perform action: (() -> ())? = nil) -> some View { modifier(_AppearanceActionModifier(disappear: action)) } diff --git a/Sources/TokamakCore/Preferences/PreferenceKey.swift b/Sources/TokamakCore/Preferences/PreferenceKey.swift index 55962a2fb..d67845218 100644 --- a/Sources/TokamakCore/Preferences/PreferenceKey.swift +++ b/Sources/TokamakCore/Preferences/PreferenceKey.swift @@ -96,12 +96,6 @@ public protocol _PreferenceWritingModifierProtocol: ViewModifier func body(_ content: Self.Content, with preferenceStore: inout _PreferenceStore) -> AnyView } -public extension _PreferenceWritingViewProtocol where Self: View { - var body: Never { - neverBody(String(describing: Self.self)) - } -} - public extension _PreferenceWritingModifierProtocol { func body(content: Content) -> AnyView { content.view diff --git a/Sources/TokamakCore/Shapes/Shape.swift b/Sources/TokamakCore/Shapes/Shape.swift index 3f72340d0..214efdf51 100644 --- a/Sources/TokamakCore/Shapes/Shape.swift +++ b/Sources/TokamakCore/Shapes/Shape.swift @@ -46,7 +46,7 @@ public struct FillStyle: Equatable, ShapeStyle { } } -public struct _ShapeView: View where Content: Shape, Style: ShapeStyle { +public struct _ShapeView: PrimitiveView where Content: Shape, Style: ShapeStyle { @Environment(\.self) public var environment @Environment(\.foregroundColor) public var foregroundColor public var shape: Content @@ -58,10 +58,6 @@ public struct _ShapeView: View where Content: Shape, Style: Shap self.style = style self.fillStyle = fillStyle } - - public var body: Never { - neverBody("_ShapeView") - } } public extension Shape { diff --git a/Sources/TokamakCore/State/TargetRef.swift b/Sources/TokamakCore/State/TargetRef.swift index 9b124a867..f333b1139 100644 --- a/Sources/TokamakCore/State/TargetRef.swift +++ b/Sources/TokamakCore/State/TargetRef.swift @@ -33,6 +33,7 @@ public struct _TargetRef: View, TargetRefType { public extension View { /** Allows capturing target instance of aclosest descendant host view. The resulting instance is written to a given `binding`. */ + @_spi(TokamakCore) func _targetRef(_ binding: Binding) -> _TargetRef { .init(binding: binding, view: self) } diff --git a/Sources/TokamakCore/Styles/ButtonStyle.swift b/Sources/TokamakCore/Styles/ButtonStyle.swift index feab28f70..d3826e9d8 100644 --- a/Sources/TokamakCore/Styles/ButtonStyle.swift +++ b/Sources/TokamakCore/Styles/ButtonStyle.swift @@ -15,11 +15,8 @@ // Created by Gene Z. Ragan on 07/22/2020. public struct ButtonStyleConfiguration { - public struct Label: View { + public struct Label: PrimitiveView { let content: AnyView - public var body: Never { - neverBody("ButtonStyleConfiguration.Label") - } } public let label: Label diff --git a/Sources/TokamakCore/Styles/NavigationLinkStyle.swift b/Sources/TokamakCore/Styles/NavigationLinkStyle.swift index aef322fdb..f26bac3b0 100644 --- a/Sources/TokamakCore/Styles/NavigationLinkStyle.swift +++ b/Sources/TokamakCore/Styles/NavigationLinkStyle.swift @@ -68,6 +68,7 @@ extension EnvironmentValues { } public extension View { + @_spi(TokamakCore) func _navigationLinkStyle(_ style: S) -> some View { environment(\._navigationLinkStyle, _AnyNavigationLinkStyle(style)) } diff --git a/Sources/TokamakCore/Tokens/Color.swift b/Sources/TokamakCore/Tokens/Color.swift index f0e942c02..f36dd689c 100644 --- a/Sources/TokamakCore/Tokens/Color.swift +++ b/Sources/TokamakCore/Tokens/Color.swift @@ -241,6 +241,7 @@ public struct Color: Hashable, Equatable { } /// Create a `Color` dependent on the current `ColorScheme`. + @_spi(TokamakCore) public static func _withScheme(_ resolver: @escaping (ColorScheme) -> Self) -> Self { .init(_EnvironmentDependentColorBox { resolver($0.colorScheme) @@ -344,6 +345,7 @@ public extension Color { extension Color: ShapeStyle {} extension Color: View { + @_spi(TokamakCore) public var body: some View { _ShapeView(shape: Rectangle(), style: self) } diff --git a/Sources/TokamakCore/Views/AnyView.swift b/Sources/TokamakCore/Views/AnyView.swift index 13e5a9606..3d0cb6db3 100644 --- a/Sources/TokamakCore/Views/AnyView.swift +++ b/Sources/TokamakCore/Views/AnyView.swift @@ -16,7 +16,7 @@ // /// A type-erased view. -public struct AnyView: View { +public struct AnyView: PrimitiveView { /// The type of the underlying `view`. let type: Any.Type @@ -67,10 +67,6 @@ public struct AnyView: View { } } } - - public var body: Never { - neverBody("AnyView") - } } public func mapAnyView(_ anyView: AnyView, transform: (V) -> T) -> T? { @@ -80,6 +76,7 @@ public func mapAnyView(_ anyView: AnyView, transform: (V) -> T) -> T? { } extension AnyView: ParentView { + @_spi(TokamakCore) public var children: [AnyView] { (view as? ParentView)?.children ?? [] } diff --git a/Sources/TokamakCore/Views/Buttons/Button.swift b/Sources/TokamakCore/Views/Buttons/Button.swift index eaf5136e8..f5800731a 100644 --- a/Sources/TokamakCore/Views/Buttons/Button.swift +++ b/Sources/TokamakCore/Views/Buttons/Button.swift @@ -42,12 +42,13 @@ public struct Button