From b4968f3210d67ae458053a2ee30044b59477424a Mon Sep 17 00:00:00 2001 From: Filippos Sakellariou Date: Thu, 4 Mar 2021 18:16:51 +0200 Subject: [PATCH 01/11] Add '_spi(TokamakCore)' to ideally internal public members. --- Sources/TokamakCore/App/Scenes/WindowGroup.swift | 3 ++- .../TokamakCore/App/Scenes/_SceneModifier.swift | 2 ++ Sources/TokamakCore/App/_AnyApp.swift | 16 +++++++++++----- Sources/TokamakCore/App/_AnyScene.swift | 3 ++- Sources/TokamakCore/App/_TupleScene.swift | 3 ++- Sources/TokamakCore/Shapes/Path.swift | 1 + Sources/TokamakCore/Shapes/Shape.swift | 3 ++- Sources/TokamakCore/Styles/ButtonStyle.swift | 3 +++ Sources/TokamakCore/Tokens/Color.swift | 1 + Sources/TokamakCore/Tokens/Font.swift | 1 + Sources/TokamakCore/Views/AnyView.swift | 4 +++- Sources/TokamakCore/Views/Buttons/Button.swift | 5 ++++- Sources/TokamakCore/Views/Buttons/Link.swift | 4 +++- .../Views/Containers/DisclosureGroup.swift | 4 +++- .../TokamakCore/Views/Containers/ForEach.swift | 5 ++++- Sources/TokamakCore/Views/Containers/Group.swift | 2 ++ Sources/TokamakCore/Views/Containers/List.swift | 2 ++ .../TokamakCore/Views/Containers/TupleView.swift | 1 + Sources/TokamakCore/Views/Image.swift | 4 +++- .../Views/Layout/GeometryReader.swift | 1 + Sources/TokamakCore/Views/Layout/HStack.swift | 4 +++- Sources/TokamakCore/Views/Layout/LazyHGrid.swift | 3 ++- Sources/TokamakCore/Views/Layout/LazyVGrid.swift | 4 +++- .../TokamakCore/Views/Layout/ScrollView.swift | 4 +++- Sources/TokamakCore/Views/Layout/VStack.swift | 4 +++- Sources/TokamakCore/Views/Layout/ZStack.swift | 4 +++- .../Views/Navigation/NavigationLink.swift | 4 +++- .../Views/Navigation/NavigationView.swift | 4 +++- Sources/TokamakCore/Views/Selectors/Picker.swift | 11 +++++++++-- Sources/TokamakCore/Views/Selectors/Slider.swift | 6 +++++- Sources/TokamakCore/Views/Selectors/Toggle.swift | 1 + Sources/TokamakCore/Views/Spacers/Divider.swift | 3 +++ Sources/TokamakCore/Views/Spacers/Spacer.swift | 3 ++- Sources/TokamakCore/Views/Text/SecureField.swift | 5 ++++- Sources/TokamakCore/Views/Text/Text.swift | 4 +++- Sources/TokamakCore/Views/Text/TextEditor.swift | 3 ++- Sources/TokamakCore/Views/Text/TextField.swift | 5 ++++- Sources/TokamakCore/Views/ViewBuilder.swift | 7 +++++-- Sources/TokamakDOM/Styles/ButtonStyle.swift | 1 + Sources/TokamakDOM/Views/Buttons/Button.swift | 1 + .../Views/Containers/DisclosureGroup.swift | 1 + Sources/TokamakDOM/Views/DynamicHTML.swift | 6 ++++-- .../TokamakDOM/Views/Layout/GeometryReader.swift | 1 + .../Views/Navigation/NavigationLink.swift | 1 + Sources/TokamakDOM/Views/Selectors/Picker.swift | 2 ++ Sources/TokamakDOM/Views/Selectors/Slider.swift | 1 + Sources/TokamakDOM/Views/Text/SecureField.swift | 1 + Sources/TokamakDOM/Views/Text/TextEditor.swift | 1 + Sources/TokamakDOM/Views/Text/TextField.swift | 3 ++- .../TokamakGTK/Modifiers/WidgetModifier.swift | 1 + Sources/TokamakGTK/Shapes/Shape.swift | 1 + Sources/TokamakGTK/Views/List.swift | 1 + Sources/TokamakGTK/Views/NavigationView.swift | 2 ++ Sources/TokamakGTK/Views/ScrollView.swift | 1 + Sources/TokamakGTK/Views/Stack.swift | 2 ++ Sources/TokamakGTK/Views/TextField.swift | 2 ++ .../Modifiers/ModifiedContent.swift | 1 + Sources/TokamakStaticHTML/Shapes/Path.swift | 1 + .../TokamakStaticHTML/Shapes/_ShapeView.swift | 1 + .../TokamakStaticHTML/Views/Buttons/Link.swift | 1 + Sources/TokamakStaticHTML/Views/HTML.swift | 6 ++++-- .../TokamakStaticHTML/Views/Images/Image.swift | 1 + .../TokamakStaticHTML/Views/Layout/HStack.swift | 1 + .../Views/Layout/LazyHGrid.swift | 1 + .../Views/Layout/LazyVGrid.swift | 1 + .../Views/Layout/ScrollView.swift | 1 + .../TokamakStaticHTML/Views/Layout/VStack.swift | 1 + .../TokamakStaticHTML/Views/Layout/ZStack.swift | 1 + .../Views/Navigation/NavigationView.swift | 1 + .../TokamakStaticHTML/Views/Spacers/Spacer.swift | 1 + 70 files changed, 157 insertions(+), 38 deletions(-) diff --git a/Sources/TokamakCore/App/Scenes/WindowGroup.swift b/Sources/TokamakCore/App/Scenes/WindowGroup.swift index f3e4192bd..f84afb76e 100644 --- a/Sources/TokamakCore/App/Scenes/WindowGroup.swift +++ b/Sources/TokamakCore/App/Scenes/WindowGroup.swift @@ -62,7 +62,8 @@ public struct WindowGroup: Scene, TitledScene where Content: View { self.title = Text(title) 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..4ea669c1f 100644 --- a/Sources/TokamakCore/App/Scenes/_SceneModifier.swift +++ b/Sources/TokamakCore/App/Scenes/_SceneModifier.swift @@ -25,6 +25,8 @@ 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..21182d603 100644 --- a/Sources/TokamakCore/App/_AnyApp.swift +++ b/Sources/TokamakCore/App/_AnyApp.swift @@ -30,27 +30,33 @@ public struct _AnyApp: App { bodyClosure = { _AnyScene(($0 as! A).body) } 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..1482faf9d 100644 --- a/Sources/TokamakCore/App/_AnyScene.swift +++ b/Sources/TokamakCore/App/_AnyScene.swift @@ -65,7 +65,8 @@ public struct _AnyScene: Scene { typeConstructorName = TokamakCore.typeConstructorName(type) } } - + + @_spi(TokamakCore) public var body: Never { neverScene("_AnyScene") } diff --git a/Sources/TokamakCore/App/_TupleScene.swift b/Sources/TokamakCore/App/_TupleScene.swift index 2c2543b5c..84c3f85bc 100644 --- a/Sources/TokamakCore/App/_TupleScene.swift +++ b/Sources/TokamakCore/App/_TupleScene.swift @@ -23,7 +23,8 @@ struct _TupleScene: Scene, GroupScene { self.value = value self.children = children } - + + @_spi(TokamakCore) var body: Never { neverScene("_TupleScene") } diff --git a/Sources/TokamakCore/Shapes/Path.swift b/Sources/TokamakCore/Shapes/Path.swift index 20010b6e6..3dbb769dd 100644 --- a/Sources/TokamakCore/Shapes/Path.swift +++ b/Sources/TokamakCore/Shapes/Path.swift @@ -25,6 +25,7 @@ import WASILibc /// The outline of a 2D shape. public struct Path: Equatable, LosslessStringConvertible { + @_spi(TokamakCore) public class _PathBox: Equatable { var elements: [Element] = [] public static func == (lhs: Path._PathBox, rhs: Path._PathBox) -> Bool { diff --git a/Sources/TokamakCore/Shapes/Shape.swift b/Sources/TokamakCore/Shapes/Shape.swift index 3f72340d0..cc8fcd756 100644 --- a/Sources/TokamakCore/Shapes/Shape.swift +++ b/Sources/TokamakCore/Shapes/Shape.swift @@ -58,7 +58,8 @@ public struct _ShapeView: View where Content: Shape, Style: Shap self.style = style self.fillStyle = fillStyle } - + + @_spi(TokamakCore) public var body: Never { neverBody("_ShapeView") } diff --git a/Sources/TokamakCore/Styles/ButtonStyle.swift b/Sources/TokamakCore/Styles/ButtonStyle.swift index feab28f70..957b4bc89 100644 --- a/Sources/TokamakCore/Styles/ButtonStyle.swift +++ b/Sources/TokamakCore/Styles/ButtonStyle.swift @@ -17,6 +17,8 @@ public struct ButtonStyleConfiguration { public struct Label: View { let content: AnyView + + @_spi(TokamakCore) public var body: Never { neverBody("ButtonStyleConfiguration.Label") } @@ -34,6 +36,7 @@ public struct DefaultButtonStyle: ButtonStyle { } /// This is a helper type that works around absence of "package private" access control in Swift +@_spi(TokamakCore) public struct _ButtonStyleConfigurationProxy { public struct Label { public typealias Subject = ButtonStyleConfiguration.Label diff --git a/Sources/TokamakCore/Tokens/Color.swift b/Sources/TokamakCore/Tokens/Color.swift index f0e942c02..9646227e0 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) diff --git a/Sources/TokamakCore/Tokens/Font.swift b/Sources/TokamakCore/Tokens/Font.swift index 3ea487f20..73204535b 100644 --- a/Sources/TokamakCore/Tokens/Font.swift +++ b/Sources/TokamakCore/Tokens/Font.swift @@ -33,6 +33,7 @@ public protocol AnyFontBoxDeferredToRenderer: AnyFontBox { } public class AnyFontBox: AnyTokenBox, Hashable, Equatable { + @_spi(TokamakCore) public struct _Font: Hashable, Equatable { public var _name: String public var _size: CGFloat diff --git a/Sources/TokamakCore/Views/AnyView.swift b/Sources/TokamakCore/Views/AnyView.swift index 13e5a9606..d620b0d6b 100644 --- a/Sources/TokamakCore/Views/AnyView.swift +++ b/Sources/TokamakCore/Views/AnyView.swift @@ -67,7 +67,8 @@ public struct AnyView: View { } } } - + + @_spi(TokamakCore) public var body: Never { neverBody("AnyView") } @@ -80,6 +81,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..7d523954d 100644 --- a/Sources/TokamakCore/Views/Buttons/Button.swift +++ b/Sources/TokamakCore/Views/Buttons/Button.swift @@ -47,6 +47,7 @@ public struct Button