diff --git a/Sources/COpenSwiftUI/empty.c b/Sources/COpenSwiftUI/empty.c new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/Sources/COpenSwiftUI/empty.c @@ -0,0 +1 @@ + diff --git a/Sources/COpenSwiftUI/include/empty.h b/Sources/COpenSwiftUI/include/empty.h new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/Sources/COpenSwiftUI/include/empty.h @@ -0,0 +1 @@ + diff --git a/Sources/COpenSwiftUI/ProtocolDescriptor.m b/Sources/COpenSwiftUICore/Other/ProtocolDescriptor.c similarity index 59% rename from Sources/COpenSwiftUI/ProtocolDescriptor.m rename to Sources/COpenSwiftUICore/Other/ProtocolDescriptor.c index e9e35170..e52d0964 100644 --- a/Sources/COpenSwiftUI/ProtocolDescriptor.m +++ b/Sources/COpenSwiftUICore/Other/ProtocolDescriptor.c @@ -1,9 +1,6 @@ // // ProtocolDescriptor.c -// FIXME: Use ProtocolDescriptor.m due to COpenSwiftUICore module contains ObjC symbol. -// Solution: Move down to COpenSwiftUICore module. -// COpenSwiftUI - +// COpenSwiftUICore #include "ProtocolDescriptor.h" @@ -13,15 +10,15 @@ void _OpenSwiftUI_callVisitViewType(void *visitor_value, const void *view_pwt); OPENSWIFTUI_EXPORT -const void *$s11OpenSwiftUI4ViewMp; +const void *$s15OpenSwiftUICore4ViewMp; const void *_OpenSwiftUI_viewProtocolDescriptor(void) { - return &$s11OpenSwiftUI4ViewMp; + return &$s15OpenSwiftUICore4ViewMp; } OPENSWIFTUI_EXPORT -const void *$s11OpenSwiftUI12ViewModifierMp; +const void *$s15OpenSwiftUICore12ViewModifierMp; const void *_OpenSwiftUI_viewModifierProtocolDescriptor(void) { - return &$s11OpenSwiftUI12ViewModifierMp; + return &$s15OpenSwiftUICore12ViewModifierMp; } diff --git a/Sources/COpenSwiftUI/include/ProtocolDescriptor.h b/Sources/COpenSwiftUICore/include/ProtocolDescriptor.h similarity index 100% rename from Sources/COpenSwiftUI/include/ProtocolDescriptor.h rename to Sources/COpenSwiftUICore/include/ProtocolDescriptor.h diff --git a/Sources/OpenSwiftUI/App/AppGraph.swift b/Sources/OpenSwiftUI/App/AppGraph.swift index 11218127..0041f667 100644 --- a/Sources/OpenSwiftUI/App/AppGraph.swift +++ b/Sources/OpenSwiftUI/App/AppGraph.swift @@ -14,7 +14,7 @@ import Glibc import WASILibc #endif internal import OpenGraphShims -@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore +@_spi(ForOpenSwiftUIOnly) package import OpenSwiftUICore package final class AppGraph: GraphHost { static var shared: AppGraph? = nil diff --git a/Sources/OpenSwiftUI/App/OpenSwiftUIApplication.swift b/Sources/OpenSwiftUI/App/OpenSwiftUIApplication.swift index 6f2f0c1b..8eed05a4 100644 --- a/Sources/OpenSwiftUI/App/OpenSwiftUIApplication.swift +++ b/Sources/OpenSwiftUI/App/OpenSwiftUIApplication.swift @@ -6,7 +6,7 @@ // Status: WIP // ID: ACC2C5639A7D76F611E170E831FCA491 -@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore +@_spi(ForOpenSwiftUIOnly) internal import OpenSwiftUICore #if os(iOS) || os(tvOS) import UIKit diff --git a/Sources/OpenSwiftUI/Core/Render/DisplayLink.swift b/Sources/OpenSwiftUI/Core/Render/DisplayLink.swift index 953d12cd..b4024d64 100644 --- a/Sources/OpenSwiftUI/Core/Render/DisplayLink.swift +++ b/Sources/OpenSwiftUI/Core/Render/DisplayLink.swift @@ -14,7 +14,7 @@ import UIKit import AppKit #endif -@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore +@_spi(ForOpenSwiftUIOnly) internal import OpenSwiftUICore final class DisplayLink: NSObject { private weak var host: AnyUIHostingView? diff --git a/Sources/OpenSwiftUI/Core/Util/Comparable+Extension.swift b/Sources/OpenSwiftUI/Core/Util/Comparable+Extension.swift deleted file mode 100644 index d9d8db11..00000000 --- a/Sources/OpenSwiftUI/Core/Util/Comparable+Extension.swift +++ /dev/null @@ -1,21 +0,0 @@ -extension Comparable { - func clamped(to range: ClosedRange) -> Self { - var value = self - value.clamp(to: range) - return value - } - - mutating func clamp(to range: ClosedRange) { - self = OpenSwiftUI.clamp(self, min: range.lowerBound, max: range.upperBound) - } -} - -func clamp(_ value: Value, min minValue: Value, max maxValue: Value) -> Value { - if value < minValue { - minValue - } else if value > maxValue { - maxValue - } else { - value - } -} diff --git a/Sources/OpenSwiftUI/Core/View/View/ViewInputs.swift b/Sources/OpenSwiftUI/Core/View/View/ViewInputs.swift deleted file mode 100644 index 9571cad1..00000000 --- a/Sources/OpenSwiftUI/Core/View/View/ViewInputs.swift +++ /dev/null @@ -1,144 +0,0 @@ -// -// ViewInputs.swift -// OpenSwiftUI -// -// Audited for RELEASE_2021 -// Status: WIP - -internal import OpenGraphShims - -/// The input (aka inherited) attributes supplied to each view. Most -/// view types will only actually wire a small number of these into -/// their node. Doesn't include the view itself, which is passed -/// separately. -public struct _ViewInputs { - private var base: _GraphInputs - var preferences: PreferencesInputs - var transform: Attribute - var position: Attribute - var containerPosition: Attribute - var size: Attribute - var safeAreaInsets: OptionalAttribute - - init( - base: _GraphInputs, - preferences: PreferencesInputs, - transform: Attribute, - position: Attribute, - containerPosition: Attribute, - size: Attribute, - safeAreaInsets: OptionalAttribute - ) { - self.base = base - self.preferences = preferences - self.transform = transform - self.position = position - self.containerPosition = containerPosition - self.size = size - self.safeAreaInsets = safeAreaInsets - } - - mutating func append(_ value: Value, to type: Input.Type) where Input.Value == [Value] { - var values = base[type] - values.append(value) - base[type] = values - } - - mutating func popLast(_ type: Input.Type) -> Value? where Input.Value == [Value] { - var values = base[type] - guard let value = values.popLast() else { - return nil - } - base[type] = values - return value - } - - func makeIndirectOutputs() -> _ViewOutputs { - #if canImport(Darwin) - struct AddPreferenceVisitor: PreferenceKeyVisitor { - var outputs = _ViewOutputs() - mutating func visit(key: Key.Type) { -// let source = ViewGraph.current.intern(Key.defaultValue, id: 0) -// let indirect = IndirectAttribute(source: source) -// outputs.appendPreference(key: Key.self, value: Attribute(identifier: indirect.identifier)) - fatalError() - } - } - var visitor = AddPreferenceVisitor() - preferences.keys.forEach { key in - key.visitKey(&visitor) - } - var outputs = visitor.outputs - outputs.setLayoutComputer(self) { - let indirect = IndirectAttribute(source: ViewGraph.current.$defaultLayoutComputer) - return Attribute(identifier: indirect.identifier) - } - return outputs - #else - fatalError("See #39") - #endif - } - - // MARK: - base - - @inline(__always) - mutating func withMutateGraphInputs(_ body: (inout _GraphInputs) -> R) -> R { - body(&base) - } - - // MARK: - base.customInputs - - @inline(__always) - func withCustomInputs(_ body: (PropertyList) -> R) -> R { - body(base.customInputs) - } - - @inline(__always) - mutating func withMutableCustomInputs(_ body: (inout PropertyList) -> R) -> R { - body(&base.customInputs) - } - - // MARK: - base.cachedEnvironment - - @inline(__always) - func withCachedEnviroment(_ body: (CachedEnvironment) -> R) -> R { - body(base.cachedEnvironment.wrappedValue) - } - - @inline(__always) - func withMutableCachedEnviroment(_ body: (inout CachedEnvironment) -> R) -> R { - body(&base.cachedEnvironment.wrappedValue) - } - - @inline(__always) - func detechedEnvironmentInputs() -> Self { - var newInputs = self - newInputs.base = self.base.detechedEnvironmentInputs() - return newInputs - } - - // MARK: - base.phase - @inline(__always) - var phase: Attribute<_GraphInputs.Phase> { - base.phase - } - - // MARK: - base.changedDebugProperties - - @inline(__always) - func withEmptyChangedDebugPropertiesInputs(_ body: (_ViewInputs) -> R) -> R { - var newInputs = self - return base.withEmptyChangedDebugPropertiesInputs { - newInputs.base = $0 - return body(newInputs) - } - } - - // MARK: Options - - @inline(__always) - var enableLayout: Bool { - get { base.enableLayout } - // TODO: setter - } -} diff --git a/Sources/OpenSwiftUI/EventHandling/Focus/FocusState.swift b/Sources/OpenSwiftUI/EventHandling/Focus/FocusState.swift index 4941ac19..6a197357 100644 --- a/Sources/OpenSwiftUI/EventHandling/Focus/FocusState.swift +++ b/Sources/OpenSwiftUI/EventHandling/Focus/FocusState.swift @@ -6,7 +6,7 @@ // Status: WIP // ID: 274D264A38B51DC68ACC48A91353B7D0 -@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore +@_spi(ForOpenSwiftUIOnly) public import OpenSwiftUICore @frozen @propertyWrapper diff --git a/Sources/OpenSwiftUI/EventHandling/Focus/FocusStoreLocation.swift b/Sources/OpenSwiftUI/EventHandling/Focus/FocusStoreLocation.swift index 4a0463b5..c64365e5 100644 --- a/Sources/OpenSwiftUI/EventHandling/Focus/FocusStoreLocation.swift +++ b/Sources/OpenSwiftUI/EventHandling/Focus/FocusStoreLocation.swift @@ -1,4 +1,4 @@ -@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore +@_spi(ForOpenSwiftUIOnly) internal import OpenSwiftUICore class FocusStoreLocation: AnyLocation, @unchecked Sendable { override var wasRead: Bool { diff --git a/Sources/OpenSwiftUI/Export.swift b/Sources/OpenSwiftUI/Export.swift index bee153f1..d26496d4 100644 --- a/Sources/OpenSwiftUI/Export.swift +++ b/Sources/OpenSwiftUI/Export.swift @@ -9,4 +9,4 @@ @_spi(DisplayList_ViewSystem) @_spi(SystemUI) @_spi(DoNotImport) -import OpenSwiftUICore +public import OpenSwiftUICore diff --git a/Sources/OpenSwiftUI/Integration/Representable/Platform/PlatformViewRepresentable.swift b/Sources/OpenSwiftUI/Integration/Representable/Platform/PlatformViewRepresentable.swift index e8ceb3cd..8c7f4120 100644 --- a/Sources/OpenSwiftUI/Integration/Representable/Platform/PlatformViewRepresentable.swift +++ b/Sources/OpenSwiftUI/Integration/Representable/Platform/PlatformViewRepresentable.swift @@ -16,6 +16,8 @@ import Foundation typealias PlatformView = Void #endif +internal import OpenSwiftUICore + protocol PlatformViewRepresentable: View { associatedtype PlatformViewProvider associatedtype Coordinator diff --git a/Sources/OpenSwiftUI/Integration/UIKit/AnyUIHostingView.swift b/Sources/OpenSwiftUI/Integration/UIKit/AnyUIHostingView.swift index d7556d58..81489960 100644 --- a/Sources/OpenSwiftUI/Integration/UIKit/AnyUIHostingView.swift +++ b/Sources/OpenSwiftUI/Integration/UIKit/AnyUIHostingView.swift @@ -7,7 +7,7 @@ #if os(iOS) -@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore +@_spi(ForOpenSwiftUIOnly) internal import OpenSwiftUICore protocol AnyUIHostingView: AnyObject { func displayLinkTimer(timestamp: Time, isAsyncThread: Bool) diff --git a/Sources/OpenSwiftUI/Integration/UIKit/UIHostingView.swift b/Sources/OpenSwiftUI/Integration/UIKit/UIHostingView.swift index e7c70486..9cc18ace 100644 --- a/Sources/OpenSwiftUI/Integration/UIKit/UIHostingView.swift +++ b/Sources/OpenSwiftUI/Integration/UIKit/UIHostingView.swift @@ -7,17 +7,17 @@ // ID: FAF0B683EB49BE9BABC9009857940A1E #if os(iOS) -@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore +@_spi(ForOpenSwiftUIOnly) public import OpenSwiftUICore import UIKit @available(macOS, unavailable) @available(watchOS, unavailable) open class _UIHostingView: UIView where Content: View { private var _rootView: Content - var viewGraph: ViewGraph - var currentTimestamp: Time = .zero - var propertiesNeedingUpdate: ViewRendererHostProperties = [.rootView] // FIXME - var isRendering: Bool = false + package var viewGraph: ViewGraph + package var currentTimestamp: Time = .zero + package var propertiesNeedingUpdate: ViewRendererHostProperties = [.rootView] // FIXME + package var isRendering: Bool = false var inheritedEnvironment: EnvironmentValues? var environmentOverride: EnvironmentValues? weak var viewController: UIHostingController? @@ -154,30 +154,30 @@ open class _UIHostingView: UIView where Content: View { } extension _UIHostingView: ViewRendererHost { - func addImplicitPropertiesNeedingUpdate(to _: inout ViewRendererHostProperties) {} + package func addImplicitPropertiesNeedingUpdate(to _: inout ViewRendererHostProperties) {} - func updateRootView() { + package func updateRootView() { let rootView = makeRootView() viewGraph.setRootView(rootView) } - func requestUpdate(after: Double) { + package func requestUpdate(after: Double) { // TODO } - func modifyViewInputs(_ inputs: inout _ViewInputs) { + package func modifyViewInputs(_ inputs: inout _ViewInputs) { // TODO } - func outputsDidChange(outputs: ViewGraph.Outputs) { + package func outputsDidChange(outputs: ViewGraph.Outputs) { // TODO } - func focusDidChange() { + package func focusDidChange() { // TODO } - func rootTransform() -> ViewTransform { + package func rootTransform() -> ViewTransform { fatalError("TODO") } diff --git a/Sources/OpenSwiftUI/Test/TestIDView.swift b/Sources/OpenSwiftUI/Test/TestIDView.swift index d5d2e409..7957fa92 100644 --- a/Sources/OpenSwiftUI/Test/TestIDView.swift +++ b/Sources/OpenSwiftUI/Test/TestIDView.swift @@ -6,6 +6,7 @@ // Status: WIP internal import OpenGraphShims +internal import OpenSwiftUICore struct TestIDView: PrimitiveView, UnaryView { var content: Content diff --git a/Sources/OpenSwiftUI/View/Control/Button/ButtonStyle/ButtonStyleConfiguration.swift b/Sources/OpenSwiftUI/View/Control/Button/ButtonStyle/ButtonStyleConfiguration.swift index 35e058fb..e66aa4c5 100644 --- a/Sources/OpenSwiftUI/View/Control/Button/ButtonStyle/ButtonStyleConfiguration.swift +++ b/Sources/OpenSwiftUI/View/Control/Button/ButtonStyle/ButtonStyleConfiguration.swift @@ -8,6 +8,8 @@ public struct ButtonStyleConfiguration { public struct Label: ViewAlias { public typealias Body = Never + + package init() {} } // 0x0 - 2 Byte diff --git a/Sources/OpenSwiftUI/View/Control/Button/ButtonStyle/PrimitiveButtonStyleConfiguration.swift b/Sources/OpenSwiftUI/View/Control/Button/ButtonStyle/PrimitiveButtonStyleConfiguration.swift index 5fe137c0..28cd2b28 100644 --- a/Sources/OpenSwiftUI/View/Control/Button/ButtonStyle/PrimitiveButtonStyleConfiguration.swift +++ b/Sources/OpenSwiftUI/View/Control/Button/ButtonStyle/PrimitiveButtonStyleConfiguration.swift @@ -8,6 +8,8 @@ public struct PrimitiveButtonStyleConfiguration { public struct Label: ViewAlias { public typealias Body = Never + + package init() {} } // 0x0 - 2 Byte diff --git a/Sources/OpenSwiftUI/View/Control/Slider/Slider.swift b/Sources/OpenSwiftUI/View/Control/Slider/Slider.swift index 8b6d96ca..f6219650 100644 --- a/Sources/OpenSwiftUI/View/Control/Slider/Slider.swift +++ b/Sources/OpenSwiftUI/View/Control/Slider/Slider.swift @@ -6,7 +6,7 @@ // Status: Blocked by Accessibility // ID: F045F16106E380A820CC0B639278A953 -@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore +@_spi(ForOpenSwiftUIOnly) public import OpenSwiftUICore /// A control for selecting a value from a bounded linear range of values. /// diff --git a/Sources/OpenSwiftUI/View/Animation/AnimatablePair.swift b/Sources/OpenSwiftUICore/Animation/AnimatablePair.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Animation/AnimatablePair.swift rename to Sources/OpenSwiftUICore/Animation/AnimatablePair.swift diff --git a/Sources/OpenSwiftUI/View/Animation/EmptyAnimatableData.swift b/Sources/OpenSwiftUICore/Animation/EmptyAnimatableData.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Animation/EmptyAnimatableData.swift rename to Sources/OpenSwiftUICore/Animation/EmptyAnimatableData.swift diff --git a/Sources/OpenSwiftUI/View/Animation/TODO/Animatable.swift b/Sources/OpenSwiftUICore/Animation/TODO/Animatable.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Animation/TODO/Animatable.swift rename to Sources/OpenSwiftUICore/Animation/TODO/Animatable.swift diff --git a/Sources/OpenSwiftUI/View/Animation/TODO/AnimatableModifier.swift b/Sources/OpenSwiftUICore/Animation/TODO/AnimatableModifier.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Animation/TODO/AnimatableModifier.swift rename to Sources/OpenSwiftUICore/Animation/TODO/AnimatableModifier.swift diff --git a/Sources/OpenSwiftUI/View/Animation/TODO/_AnimatableView.swift b/Sources/OpenSwiftUICore/Animation/TODO/_AnimatableView.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Animation/TODO/_AnimatableView.swift rename to Sources/OpenSwiftUICore/Animation/TODO/_AnimatableView.swift diff --git a/Sources/OpenSwiftUI/View/Animation/VectorArithmetic.swift b/Sources/OpenSwiftUICore/Animation/VectorArithmetic.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Animation/VectorArithmetic.swift rename to Sources/OpenSwiftUICore/Animation/VectorArithmetic.swift diff --git a/Sources/OpenSwiftUI/View/Animation/_VectorMath.swift b/Sources/OpenSwiftUICore/Animation/_VectorMath.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Animation/_VectorMath.swift rename to Sources/OpenSwiftUICore/Animation/_VectorMath.swift diff --git a/Sources/OpenSwiftUI/Core/Codable/CodableProxy.swift b/Sources/OpenSwiftUICore/Data/Codable/CodableProxy.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/Codable/CodableProxy.swift rename to Sources/OpenSwiftUICore/Data/Codable/CodableProxy.swift diff --git a/Sources/OpenSwiftUI/Data/Environment/Environment.swift b/Sources/OpenSwiftUICore/Data/Environment/Environment.swift similarity index 100% rename from Sources/OpenSwiftUI/Data/Environment/Environment.swift rename to Sources/OpenSwiftUICore/Data/Environment/Environment.swift diff --git a/Sources/OpenSwiftUI/Data/Environment/EnvironmentKeyTransformModifier.swift b/Sources/OpenSwiftUICore/Data/Environment/EnvironmentKeyTransformModifier.swift similarity index 100% rename from Sources/OpenSwiftUI/Data/Environment/EnvironmentKeyTransformModifier.swift rename to Sources/OpenSwiftUICore/Data/Environment/EnvironmentKeyTransformModifier.swift diff --git a/Sources/OpenSwiftUI/Data/Preference/PreferenceBridge.swift b/Sources/OpenSwiftUICore/Data/Preference/PreferenceBridge.swift similarity index 98% rename from Sources/OpenSwiftUI/Data/Preference/PreferenceBridge.swift rename to Sources/OpenSwiftUICore/Data/Preference/PreferenceBridge.swift index 775f6219..d833dd7d 100644 --- a/Sources/OpenSwiftUI/Data/Preference/PreferenceBridge.swift +++ b/Sources/OpenSwiftUICore/Data/Preference/PreferenceBridge.swift @@ -7,9 +7,8 @@ // ID: A9FAE381E99529D5274BA37A9BC9B074 internal import OpenGraphShims -@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore -final class PreferenceBridge { +package final class PreferenceBridge { unowned let viewGraph: ViewGraph private(set) var children: [Unmanaged] = [] var requestedPreferences = PreferenceKeys() diff --git a/Sources/OpenSwiftUI/Data/Preference/PreferencesCombiner.swift b/Sources/OpenSwiftUICore/Data/Preference/PreferencesCombiner.swift similarity index 100% rename from Sources/OpenSwiftUI/Data/Preference/PreferencesCombiner.swift rename to Sources/OpenSwiftUICore/Data/Preference/PreferencesCombiner.swift diff --git a/Sources/OpenSwiftUI/Data/Preference/PreferencesInputs.swift b/Sources/OpenSwiftUICore/Data/Preference/PreferencesInputs.swift similarity index 100% rename from Sources/OpenSwiftUI/Data/Preference/PreferencesInputs.swift rename to Sources/OpenSwiftUICore/Data/Preference/PreferencesInputs.swift diff --git a/Sources/OpenSwiftUI/Data/Preference/PreferencesOutputs.swift b/Sources/OpenSwiftUICore/Data/Preference/PreferencesOutputs.swift similarity index 100% rename from Sources/OpenSwiftUI/Data/Preference/PreferencesOutputs.swift rename to Sources/OpenSwiftUICore/Data/Preference/PreferencesOutputs.swift diff --git a/Sources/OpenSwiftUI/Data/Preference/TODO/_PreferenceTransformModifier.swift b/Sources/OpenSwiftUICore/Data/Preference/TODO/_PreferenceTransformModifier.swift similarity index 100% rename from Sources/OpenSwiftUI/Data/Preference/TODO/_PreferenceTransformModifier.swift rename to Sources/OpenSwiftUICore/Data/Preference/TODO/_PreferenceTransformModifier.swift diff --git a/Sources/OpenSwiftUI/Data/Preference/TODO/_PreferenceWritingModifier.swift b/Sources/OpenSwiftUICore/Data/Preference/TODO/_PreferenceWritingModifier.swift similarity index 100% rename from Sources/OpenSwiftUI/Data/Preference/TODO/_PreferenceWritingModifier.swift rename to Sources/OpenSwiftUICore/Data/Preference/TODO/_PreferenceWritingModifier.swift diff --git a/Sources/OpenSwiftUI/Data/Preference/View_Preference.swift b/Sources/OpenSwiftUICore/Data/Preference/View_Preference.swift similarity index 92% rename from Sources/OpenSwiftUI/Data/Preference/View_Preference.swift rename to Sources/OpenSwiftUICore/Data/Preference/View_Preference.swift index 2ad7b3b2..edb88b73 100644 --- a/Sources/OpenSwiftUI/Data/Preference/View_Preference.swift +++ b/Sources/OpenSwiftUICore/Data/Preference/View_Preference.swift @@ -6,9 +6,6 @@ // Status: Complete // ID: 6C396F98EFDD04A6B58F2F9112448013 -@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore -@_spi(Private) import OpenSwiftUICore - extension View { /// Sets a value for the given preference. @inlinable diff --git a/Sources/OpenSwiftUI/EventHandling/InputEvent/HitTesting/ContentResponder.swift b/Sources/OpenSwiftUICore/EventHandling/InputEvent/HitTesting/ContentResponder.swift similarity index 93% rename from Sources/OpenSwiftUI/EventHandling/InputEvent/HitTesting/ContentResponder.swift rename to Sources/OpenSwiftUICore/EventHandling/InputEvent/HitTesting/ContentResponder.swift index aa5258d7..c3e03ab6 100644 --- a/Sources/OpenSwiftUI/EventHandling/InputEvent/HitTesting/ContentResponder.swift +++ b/Sources/OpenSwiftUICore/EventHandling/InputEvent/HitTesting/ContentResponder.swift @@ -6,8 +6,7 @@ // Status: WIP import Foundation -internal import COpenSwiftUI -@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore +internal import COpenSwiftUICore protocol ContentResponder { func contains(points: [CGPoint], size: CGSize) -> BitVector64 diff --git a/Sources/OpenSwiftUI/EventHandling/InputEvent/HitTesting/ContentShapeKinds.swift b/Sources/OpenSwiftUICore/EventHandling/InputEvent/HitTesting/ContentShapeKinds.swift similarity index 100% rename from Sources/OpenSwiftUI/EventHandling/InputEvent/HitTesting/ContentShapeKinds.swift rename to Sources/OpenSwiftUICore/EventHandling/InputEvent/HitTesting/ContentShapeKinds.swift diff --git a/Sources/OpenSwiftUI/View/Graphic/Color/Color.swift b/Sources/OpenSwiftUICore/Graphic/Color/Color.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Graphic/Color/Color.swift rename to Sources/OpenSwiftUICore/Graphic/Color/Color.swift diff --git a/Sources/OpenSwiftUI/View/Graphic/Color/ColorResolved.swift b/Sources/OpenSwiftUICore/Graphic/Color/ColorResolved.swift similarity index 99% rename from Sources/OpenSwiftUI/View/Graphic/Color/ColorResolved.swift rename to Sources/OpenSwiftUICore/Graphic/Color/ColorResolved.swift index f043bae6..e50e622d 100644 --- a/Sources/OpenSwiftUI/View/Graphic/Color/ColorResolved.swift +++ b/Sources/OpenSwiftUICore/Graphic/Color/ColorResolved.swift @@ -6,8 +6,7 @@ // Status: WIP import Foundation -import OpenSwiftUICore -internal import COpenSwiftUI +internal import COpenSwiftUICore // MARK: - Color.Resolved diff --git a/Sources/OpenSwiftUI/View/Graphic/Color/ColorSchema.swift b/Sources/OpenSwiftUICore/Graphic/Color/ColorSchema.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Graphic/Color/ColorSchema.swift rename to Sources/OpenSwiftUICore/Graphic/Color/ColorSchema.swift diff --git a/Sources/OpenSwiftUI/View/Graphic/Color/CoreColor+Extension.swift b/Sources/OpenSwiftUICore/Graphic/Color/CoreColor+Extension.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Graphic/Color/CoreColor+Extension.swift rename to Sources/OpenSwiftUICore/Graphic/Color/CoreColor+Extension.swift diff --git a/Sources/OpenSwiftUI/View/Graphic/Data/Angle.swift b/Sources/OpenSwiftUICore/Graphic/Data/Angle.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Graphic/Data/Angle.swift rename to Sources/OpenSwiftUICore/Graphic/Data/Angle.swift diff --git a/Sources/OpenSwiftUI/View/Graphic/Data/Axis.swift b/Sources/OpenSwiftUICore/Graphic/Data/Axis.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Graphic/Data/Axis.swift rename to Sources/OpenSwiftUICore/Graphic/Data/Axis.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutAdjustments/Alignment/AlignmentID.swift b/Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Alignment/AlignmentID.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutAdjustments/Alignment/AlignmentID.swift rename to Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Alignment/AlignmentID.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutAdjustments/Alignment/AlignmentKey.swift b/Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Alignment/AlignmentKey.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutAdjustments/Alignment/AlignmentKey.swift rename to Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Alignment/AlignmentKey.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutAdjustments/Alignment/HorizontalAlignment.swift b/Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Alignment/HorizontalAlignment.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutAdjustments/Alignment/HorizontalAlignment.swift rename to Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Alignment/HorizontalAlignment.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutAdjustments/Alignment/VerticalAlignment.swift b/Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Alignment/VerticalAlignment.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutAdjustments/Alignment/VerticalAlignment.swift rename to Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Alignment/VerticalAlignment.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutAdjustments/Alignment/ViewDimensions.swift b/Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Alignment/ViewDimensions.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutAdjustments/Alignment/ViewDimensions.swift rename to Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Alignment/ViewDimensions.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutAdjustments/Direction/LayoutDirection.swift b/Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Direction/LayoutDirection.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutAdjustments/Direction/LayoutDirection.swift rename to Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Direction/LayoutDirection.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutAdjustments/Edge/Edge.swift b/Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Edge/Edge.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutAdjustments/Edge/Edge.swift rename to Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Edge/Edge.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutAdjustments/Edge/EdgeInsets.swift b/Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Edge/EdgeInsets.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutAdjustments/Edge/EdgeInsets.swift rename to Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Edge/EdgeInsets.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutAdjustments/Edge/SafeAreaInsets.swift b/Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Edge/SafeAreaInsets.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutAdjustments/Edge/SafeAreaInsets.swift rename to Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Edge/SafeAreaInsets.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutAdjustments/Edge/SafeAreaRegions.swift b/Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Edge/SafeAreaRegions.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutAdjustments/Edge/SafeAreaRegions.swift rename to Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Edge/SafeAreaRegions.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutAdjustments/Padding/PaddingLayout.swift b/Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Padding/PaddingLayout.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutAdjustments/Padding/PaddingLayout.swift rename to Sources/OpenSwiftUICore/Layout/LayoutAdjustments/Padding/PaddingLayout.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutFundamentals/Separators/Divider.swift b/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/Separators/Divider.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutFundamentals/Separators/Divider.swift rename to Sources/OpenSwiftUICore/Layout/LayoutFundamentals/Separators/Divider.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutFundamentals/Separators/Spacer.swift b/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/Separators/Spacer.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutFundamentals/Separators/Spacer.swift rename to Sources/OpenSwiftUICore/Layout/LayoutFundamentals/Separators/Spacer.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutFundamentals/Stack/HVStack.swift b/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/Stack/HVStack.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutFundamentals/Stack/HVStack.swift rename to Sources/OpenSwiftUICore/Layout/LayoutFundamentals/Stack/HVStack.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutFundamentals/Stack/HVStackLayout.swift b/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/Stack/HVStackLayout.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutFundamentals/Stack/HVStackLayout.swift rename to Sources/OpenSwiftUICore/Layout/LayoutFundamentals/Stack/HVStackLayout.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/LayoutComputer.swift b/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/LayoutComputer.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/LayoutComputer.swift rename to Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/LayoutComputer.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/ProjectionTransform.swift b/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/ProjectionTransform.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/ProjectionTransform.swift rename to Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/ProjectionTransform.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/ProposedSize.swift b/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/ProposedSize.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/ProposedSize.swift rename to Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/ProposedSize.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/SizeThatFitsObserver.swift b/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/SizeThatFitsObserver.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/SizeThatFitsObserver.swift rename to Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/SizeThatFitsObserver.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/Spacing.swift b/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/Spacing.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/Spacing.swift rename to Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/Spacing.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/ViewFrame.swift b/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/ViewFrame.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/ViewFrame.swift rename to Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/ViewFrame.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/ViewGeometry.swift b/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/ViewGeometry.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/ViewGeometry.swift rename to Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/ViewGeometry.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/ViewOrigin.swift b/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/ViewOrigin.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/ViewOrigin.swift rename to Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/ViewOrigin.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/ViewSize.swift b/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/ViewSize.swift similarity index 100% rename from Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/ViewSize.swift rename to Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/ViewSize.swift diff --git a/Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/ViewTransform.swift b/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/ViewTransform.swift similarity index 96% rename from Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/ViewTransform.swift rename to Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/ViewTransform.swift index 790389d3..2d8e9715 100644 --- a/Sources/OpenSwiftUI/Layout/LayoutFundamentals/internal/ViewTransform.swift +++ b/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/ViewTransform.swift @@ -2,11 +2,11 @@ import Foundation -struct ViewTransform { +package struct ViewTransform { private var chunks: ContiguousArray var positionAdjustment: CGSize - init() { + package init() { self.chunks = [] self.positionAdjustment = .zero } diff --git a/Sources/OpenSwiftUI/View/Modifier/AppearanceActionModifier.swift b/Sources/OpenSwiftUICore/Modifier/AppearanceActionModifier.swift similarity index 99% rename from Sources/OpenSwiftUI/View/Modifier/AppearanceActionModifier.swift rename to Sources/OpenSwiftUICore/Modifier/AppearanceActionModifier.swift index 94e4ca59..e0412443 100644 --- a/Sources/OpenSwiftUI/View/Modifier/AppearanceActionModifier.swift +++ b/Sources/OpenSwiftUICore/Modifier/AppearanceActionModifier.swift @@ -9,7 +9,6 @@ // MARK: - AppearanceActionModifier internal import OpenGraphShims -@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore /// A modifier that triggers actions when its view appears and disappears. @frozen diff --git a/Sources/OpenSwiftUI/View/Modifier/ClipEffect.swift b/Sources/OpenSwiftUICore/Modifier/ClipEffect.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Modifier/ClipEffect.swift rename to Sources/OpenSwiftUICore/Modifier/ClipEffect.swift diff --git a/Sources/OpenSwiftUI/Core/Modifier/EmptyModifier.swift b/Sources/OpenSwiftUICore/Modifier/EmptyModifier.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/Modifier/EmptyModifier.swift rename to Sources/OpenSwiftUICore/Modifier/EmptyModifier.swift diff --git a/Sources/OpenSwiftUI/Core/Modifier/ModifiedContent.swift b/Sources/OpenSwiftUICore/Modifier/ModifiedContent.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/Modifier/ModifiedContent.swift rename to Sources/OpenSwiftUICore/Modifier/ModifiedContent.swift diff --git a/Sources/OpenSwiftUI/Core/Modifier/StaticIf.swift b/Sources/OpenSwiftUICore/Modifier/StaticIf.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/Modifier/StaticIf.swift rename to Sources/OpenSwiftUICore/Modifier/StaticIf.swift diff --git a/Sources/OpenSwiftUI/Core/Modifier/ViewModifier/CustomViewModifier.swift b/Sources/OpenSwiftUICore/Modifier/ViewModifier/CustomViewModifier.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/Modifier/ViewModifier/CustomViewModifier.swift rename to Sources/OpenSwiftUICore/Modifier/ViewModifier/CustomViewModifier.swift diff --git a/Sources/OpenSwiftUI/Core/Modifier/ViewModifier/PrimitiveViewModifier.swift b/Sources/OpenSwiftUICore/Modifier/ViewModifier/PrimitiveViewModifier.swift similarity index 58% rename from Sources/OpenSwiftUI/Core/Modifier/ViewModifier/PrimitiveViewModifier.swift rename to Sources/OpenSwiftUICore/Modifier/ViewModifier/PrimitiveViewModifier.swift index a29c2726..977bdd86 100644 --- a/Sources/OpenSwiftUI/Core/Modifier/ViewModifier/PrimitiveViewModifier.swift +++ b/Sources/OpenSwiftUICore/Modifier/ViewModifier/PrimitiveViewModifier.swift @@ -5,4 +5,4 @@ // Audited for RELEASE_2021 // Status: Complete -protocol PrimitiveViewModifier: ViewModifier where Body == Never {} +package protocol PrimitiveViewModifier: ViewModifier where Body == Never {} diff --git a/Sources/OpenSwiftUI/Core/Modifier/ViewModifier/SafeAreaInsetsModifier.swift b/Sources/OpenSwiftUICore/Modifier/ViewModifier/SafeAreaInsetsModifier.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/Modifier/ViewModifier/SafeAreaInsetsModifier.swift rename to Sources/OpenSwiftUICore/Modifier/ViewModifier/SafeAreaInsetsModifier.swift diff --git a/Sources/OpenSwiftUI/Core/Modifier/ViewModifier/TODO/_EnvironmentKeyWritingModifier.swift b/Sources/OpenSwiftUICore/Modifier/ViewModifier/TODO/_EnvironmentKeyWritingModifier.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/Modifier/ViewModifier/TODO/_EnvironmentKeyWritingModifier.swift rename to Sources/OpenSwiftUICore/Modifier/ViewModifier/TODO/_EnvironmentKeyWritingModifier.swift diff --git a/Sources/OpenSwiftUI/Core/Modifier/ViewModifier/ViewModifier.swift b/Sources/OpenSwiftUICore/Modifier/ViewModifier/ViewModifier.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/Modifier/ViewModifier/ViewModifier.swift rename to Sources/OpenSwiftUICore/Modifier/ViewModifier/ViewModifier.swift diff --git a/Sources/OpenSwiftUI/Core/Render/DisplayList.swift b/Sources/OpenSwiftUICore/Render/DisplayList.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/Render/DisplayList.swift rename to Sources/OpenSwiftUICore/Render/DisplayList.swift diff --git a/Sources/OpenSwiftUI/Core/Runtime/ProtocolDescriptor.swift b/Sources/OpenSwiftUICore/Runtime/ProtocolDescriptor.swift similarity index 97% rename from Sources/OpenSwiftUI/Core/Runtime/ProtocolDescriptor.swift rename to Sources/OpenSwiftUICore/Runtime/ProtocolDescriptor.swift index 865dc5e6..db647d9a 100644 --- a/Sources/OpenSwiftUI/Core/Runtime/ProtocolDescriptor.swift +++ b/Sources/OpenSwiftUICore/Runtime/ProtocolDescriptor.swift @@ -5,7 +5,7 @@ // Audited for RELEASE_2021 // Status: WIP -internal import COpenSwiftUI +internal import COpenSwiftUICore internal import OpenGraphShims // MARK: - ProtocolDescriptor diff --git a/Sources/OpenSwiftUI/Core/Runtime/TypeConformance.swift b/Sources/OpenSwiftUICore/Runtime/TypeConformance.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/Runtime/TypeConformance.swift rename to Sources/OpenSwiftUICore/Runtime/TypeConformance.swift diff --git a/Sources/OpenSwiftUI/View/Shape/FillStyle.swift b/Sources/OpenSwiftUICore/Shape/FillStyle.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Shape/FillStyle.swift rename to Sources/OpenSwiftUICore/Shape/FillStyle.swift diff --git a/Sources/OpenSwiftUI/View/Shape/ForegroundStyle.swift b/Sources/OpenSwiftUICore/Shape/ForegroundStyle.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Shape/ForegroundStyle.swift rename to Sources/OpenSwiftUICore/Shape/ForegroundStyle.swift diff --git a/Sources/OpenSwiftUI/View/Shape/Path/FixedRoundedRect.swift b/Sources/OpenSwiftUICore/Shape/Path/FixedRoundedRect.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Shape/Path/FixedRoundedRect.swift rename to Sources/OpenSwiftUICore/Shape/Path/FixedRoundedRect.swift diff --git a/Sources/OpenSwiftUI/View/Shape/Path/Path.swift b/Sources/OpenSwiftUICore/Shape/Path/Path.swift similarity index 99% rename from Sources/OpenSwiftUI/View/Shape/Path/Path.swift rename to Sources/OpenSwiftUICore/Shape/Path/Path.swift index 1680907e..63414bb7 100644 --- a/Sources/OpenSwiftUI/View/Shape/Path/Path.swift +++ b/Sources/OpenSwiftUICore/Shape/Path/Path.swift @@ -10,7 +10,7 @@ import Foundation #if canImport(CoreGraphics) -internal import COpenSwiftUI +internal import COpenSwiftUICore import CoreGraphics @_silgen_name("__CGPathParseString") diff --git a/Sources/OpenSwiftUI/View/Shape/Rectangle.swift b/Sources/OpenSwiftUICore/Shape/Rectangle.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Shape/Rectangle.swift rename to Sources/OpenSwiftUICore/Shape/Rectangle.swift diff --git a/Sources/OpenSwiftUI/View/Shape/RoundedCornerStyle.swift b/Sources/OpenSwiftUICore/Shape/RoundedCornerStyle.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Shape/RoundedCornerStyle.swift rename to Sources/OpenSwiftUICore/Shape/RoundedCornerStyle.swift diff --git a/Sources/OpenSwiftUI/View/Shape/RoundedRectangle.swift b/Sources/OpenSwiftUICore/Shape/RoundedRectangle.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Shape/RoundedRectangle.swift rename to Sources/OpenSwiftUICore/Shape/RoundedRectangle.swift diff --git a/Sources/OpenSwiftUI/View/Shape/Shape.swift b/Sources/OpenSwiftUICore/Shape/Shape.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Shape/Shape.swift rename to Sources/OpenSwiftUICore/Shape/Shape.swift diff --git a/Sources/OpenSwiftUI/View/Shape/ShapeRole.swift b/Sources/OpenSwiftUICore/Shape/ShapeRole.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Shape/ShapeRole.swift rename to Sources/OpenSwiftUICore/Shape/ShapeRole.swift diff --git a/Sources/OpenSwiftUI/View/Shape/ShapeStyle/AnyShapeStyle.swift b/Sources/OpenSwiftUICore/Shape/ShapeStyle/AnyShapeStyle.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Shape/ShapeStyle/AnyShapeStyle.swift rename to Sources/OpenSwiftUICore/Shape/ShapeStyle/AnyShapeStyle.swift diff --git a/Sources/OpenSwiftUI/View/Shape/ShapeStyle/ShapeStyle.swift b/Sources/OpenSwiftUICore/Shape/ShapeStyle/ShapeStyle.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Shape/ShapeStyle/ShapeStyle.swift rename to Sources/OpenSwiftUICore/Shape/ShapeStyle/ShapeStyle.swift diff --git a/Sources/OpenSwiftUI/View/Shape/ShapeStyle/ShapeStyledLeadView.swift b/Sources/OpenSwiftUICore/Shape/ShapeStyle/ShapeStyledLeadView.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Shape/ShapeStyle/ShapeStyledLeadView.swift rename to Sources/OpenSwiftUICore/Shape/ShapeStyle/ShapeStyledLeadView.swift diff --git a/Sources/OpenSwiftUI/View/Shape/ShapeView.swift b/Sources/OpenSwiftUICore/Shape/ShapeView.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Shape/ShapeView.swift rename to Sources/OpenSwiftUICore/Shape/ShapeView.swift diff --git a/Sources/OpenSwiftUI/View/Shape/StrokeStyle.swift b/Sources/OpenSwiftUICore/Shape/StrokeStyle.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Shape/StrokeStyle.swift rename to Sources/OpenSwiftUICore/Shape/StrokeStyle.swift diff --git a/Sources/OpenSwiftUI/View/Text/Font/TODO/Font.swift b/Sources/OpenSwiftUICore/Text/Font/TODO/Font.swift similarity index 80% rename from Sources/OpenSwiftUI/View/Text/Font/TODO/Font.swift rename to Sources/OpenSwiftUICore/Text/Font/TODO/Font.swift index 8c035992..3a9d51db 100644 --- a/Sources/OpenSwiftUI/View/Text/Font/TODO/Font.swift +++ b/Sources/OpenSwiftUICore/Text/Font/TODO/Font.swift @@ -6,12 +6,12 @@ public struct Font: Hashable { var provider: AnyFontBox @inline(__always) - init(storage: AnyFontBox) { + package init(storage: AnyFontBox) { provider = storage } @inline(__always) - init(provider: some FontProvider) { + package init(provider: some FontProvider) { self.init(storage: FontBox(provider: provider)) } @@ -25,14 +25,14 @@ public struct Font: Hashable { } @usableFromInline -class AnyFontBox: Hashable { +package class AnyFontBox: Hashable { @usableFromInline - func hash(into _: inout Hasher) { + package func hash(into _: inout Hasher) { fatalError() } @usableFromInline - static func == (_: AnyFontBox, _: AnyFontBox) -> Bool { + package static func == (_: AnyFontBox, _: AnyFontBox) -> Bool { fatalError() } } @@ -47,7 +47,7 @@ private class FontBox: AnyFontBox, FontProvider { } } -protocol FontProvider: Hashable {} +package protocol FontProvider: Hashable {} extension Font { public enum Design: Hashable { @@ -62,13 +62,13 @@ extension Font { public static let semibold: Weight = .init(value: 0.3) } - struct TextStyleProvider: FontProvider { + package struct TextStyleProvider: FontProvider { private let textStyle: TextStyle private let design: Design private let weight: Weight? @inline(__always) - init(textStyle: TextStyle, design: Design, weight: Weight? = nil) { + package init(textStyle: TextStyle, design: Design, weight: Weight? = nil) { self.textStyle = textStyle self.design = design self.weight = weight diff --git a/Sources/OpenSwiftUI/View/Text/Text/TODO/AnyTextStorage.swift b/Sources/OpenSwiftUICore/Text/Text/TODO/AnyTextStorage.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Text/Text/TODO/AnyTextStorage.swift rename to Sources/OpenSwiftUICore/Text/Text/TODO/AnyTextStorage.swift diff --git a/Sources/OpenSwiftUI/View/Text/Text/TODO/Text.swift b/Sources/OpenSwiftUICore/Text/Text/TODO/Text.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Text/Text/TODO/Text.swift rename to Sources/OpenSwiftUICore/Text/Text/TODO/Text.swift diff --git a/Sources/OpenSwiftUICore/Util/Comparable+Extension.swift b/Sources/OpenSwiftUICore/Util/Comparable+Extension.swift new file mode 100644 index 00000000..d49352bf --- /dev/null +++ b/Sources/OpenSwiftUICore/Util/Comparable+Extension.swift @@ -0,0 +1,21 @@ +extension Comparable { + package func clamped(to range: ClosedRange) -> Self { + var value = self + value.clamp(to: range) + return value + } + + package mutating func clamp(to range: ClosedRange) { + self = OpenSwiftUICore.clamp(self, min: range.lowerBound, max: range.upperBound) + } +} + +package func clamp(_ value: Value, min minValue: Value, max maxValue: Value) -> Value { + if value < minValue { + minValue + } else if value > maxValue { + maxValue + } else { + value + } +} diff --git a/Sources/OpenSwiftUI/Core/Util/Defaultable.swift b/Sources/OpenSwiftUICore/Util/Defaultable.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/Util/Defaultable.swift rename to Sources/OpenSwiftUICore/Util/Defaultable.swift diff --git a/Sources/OpenSwiftUI/Core/Util/DescriptiveDynamicProperty.swift b/Sources/OpenSwiftUICore/Util/DescriptiveDynamicProperty.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/Util/DescriptiveDynamicProperty.swift rename to Sources/OpenSwiftUICore/Util/DescriptiveDynamicProperty.swift diff --git a/Sources/OpenSwiftUI/View/View/AnyView.swift b/Sources/OpenSwiftUICore/View/AnyView.swift similarity index 99% rename from Sources/OpenSwiftUI/View/View/AnyView.swift rename to Sources/OpenSwiftUICore/View/AnyView.swift index bf2be53f..18a661f5 100644 --- a/Sources/OpenSwiftUI/View/View/AnyView.swift +++ b/Sources/OpenSwiftUICore/View/AnyView.swift @@ -7,8 +7,7 @@ // ID: A96961F3546506F21D8995C6092F15B5 internal import OpenGraphShims -internal import COpenSwiftUI -@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore +internal import COpenSwiftUICore @frozen public struct AnyView: PrimitiveView { diff --git a/Sources/OpenSwiftUI/Core/View/ConditionalContent.swift b/Sources/OpenSwiftUICore/View/ConditionalContent.swift similarity index 97% rename from Sources/OpenSwiftUI/Core/View/ConditionalContent.swift rename to Sources/OpenSwiftUICore/View/ConditionalContent.swift index 1ae961b9..15944c1a 100644 --- a/Sources/OpenSwiftUI/Core/View/ConditionalContent.swift +++ b/Sources/OpenSwiftUICore/View/ConditionalContent.swift @@ -7,7 +7,6 @@ // ID: 1A625ACC143FD8524C590782FD8F4F8C internal import OpenGraphShims -@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore /// View content that shows one of two possible children. @frozen diff --git a/Sources/OpenSwiftUI/Core/View/CustomView.swift b/Sources/OpenSwiftUICore/View/CustomView.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/View/CustomView.swift rename to Sources/OpenSwiftUICore/View/CustomView.swift diff --git a/Sources/OpenSwiftUICore/View/ChangedBodyProperty.swift b/Sources/OpenSwiftUICore/View/Debug/ChangedBodyProperty.swift similarity index 100% rename from Sources/OpenSwiftUICore/View/ChangedBodyProperty.swift rename to Sources/OpenSwiftUICore/View/Debug/ChangedBodyProperty.swift diff --git a/Sources/OpenSwiftUI/View/Debug/TODO/ViewDebug.swift b/Sources/OpenSwiftUICore/View/Debug/ViewDebug.swift similarity index 82% rename from Sources/OpenSwiftUI/View/Debug/TODO/ViewDebug.swift rename to Sources/OpenSwiftUICore/View/Debug/ViewDebug.swift index c338aa98..b6585bc4 100644 --- a/Sources/OpenSwiftUI/View/Debug/TODO/ViewDebug.swift +++ b/Sources/OpenSwiftUICore/View/Debug/ViewDebug.swift @@ -1,15 +1,78 @@ // // ViewDebug.swift -// OpenSwiftUI +// OpenSwiftUICore // -// Audited for RELEASE_2021 +// Audited for RELEASE_2024 // Status: WIP -// ID: 5A14269649C60F846422EA0FA4C5E535 import Foundation -internal import COpenSwiftUI internal import OpenGraphShims +internal import COpenSwiftUICore +public enum _ViewDebug { + public enum Property: UInt32, Hashable { + case type + case value + case transform + case position + case size + case environment + case phase + case layoutComputer + case displayList + } + + public struct Properties: OptionSet { + public let rawValue: UInt32 + public init(rawValue: UInt32) { + self.rawValue = rawValue + } + + @inlinable + package init(_ property: Property) { + self.init(rawValue: 1 << property.rawValue) + } + + public static let type = Properties(.type) + public static let value = Properties(.value) + public static let transform = Properties(.transform) + public static let position = Properties(.position) + public static let size = Properties(.size) + public static let environment = Properties(.environment) + public static let phase = Properties(.phase) + public static let layoutComputer = Properties(.layoutComputer) + public static let displayList = Properties(.displayList) + public static let all = Properties(rawValue: 0xFFFF_FFFF) + } + + package static var properties = Properties() + + public struct Data { + package var data: [Property: Any] + package var childData: [_ViewDebug.Data] + + package init() { + data = [:] + childData = [] + } + } + + package static var isInitialized = false +} + +@available(*, unavailable) +extension _ViewDebug.Properties: Sendable {} + +@available(*, unavailable) +extension _ViewDebug.Property: Sendable {} + +@available(*, unavailable) +extension _ViewDebug.Data: Sendable {} + +@available(*, unavailable) +extension _ViewDebug: Sendable {} + +// TODO // MARK: View and ViewModifier extension View { diff --git a/Sources/OpenSwiftUI/View/View/EmptyView.swift b/Sources/OpenSwiftUICore/View/EmptyView.swift similarity index 100% rename from Sources/OpenSwiftUI/View/View/EmptyView.swift rename to Sources/OpenSwiftUICore/View/EmptyView.swift diff --git a/Sources/OpenSwiftUI/View/Extension/View_Font.swift b/Sources/OpenSwiftUICore/View/Extension/View_Font.swift similarity index 89% rename from Sources/OpenSwiftUI/View/Extension/View_Font.swift rename to Sources/OpenSwiftUICore/View/Extension/View_Font.swift index 969f973d..b4c32064 100644 --- a/Sources/OpenSwiftUI/View/Extension/View_Font.swift +++ b/Sources/OpenSwiftUICore/View/Extension/View_Font.swift @@ -32,13 +32,13 @@ extension EnvironmentValues { } @inline(__always) - var defaultFont: Font? { + package var defaultFont: Font? { get { self[DefaultFontKey.self] } set { self[DefaultFontKey.self] = newValue } } @inline(__always) - var effectiveFont: Font { + package var effectiveFont: Font { EffectiveFontKey.value(in: self) } } @@ -54,7 +54,7 @@ extension View { extension View { @inline(__always) - func defaultFont(_ font: Font?) -> some View { + package func defaultFont(_ font: Font?) -> some View { environment(\.defaultFont, font) } } diff --git a/Sources/OpenSwiftUI/View/Extension/View_Opacity.swift b/Sources/OpenSwiftUICore/View/Extension/View_Opacity.swift similarity index 100% rename from Sources/OpenSwiftUI/View/Extension/View_Opacity.swift rename to Sources/OpenSwiftUICore/View/Extension/View_Opacity.swift diff --git a/Sources/OpenSwiftUI/Core/View/IdentifiedViewProxy.swift b/Sources/OpenSwiftUICore/View/IdentifiedViewProxy.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/View/IdentifiedViewProxy.swift rename to Sources/OpenSwiftUICore/View/IdentifiedViewProxy.swift diff --git a/Sources/OpenSwiftUI/Core/View/InterfaceIdiom.swift b/Sources/OpenSwiftUICore/View/InterfaceIdiom.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/View/InterfaceIdiom.swift rename to Sources/OpenSwiftUICore/View/InterfaceIdiom.swift diff --git a/Sources/OpenSwiftUI/Core/View/PrimitiveView.swift b/Sources/OpenSwiftUICore/View/PrimitiveView.swift similarity index 75% rename from Sources/OpenSwiftUI/Core/View/PrimitiveView.swift rename to Sources/OpenSwiftUICore/View/PrimitiveView.swift index c2656052..60c876fd 100644 --- a/Sources/OpenSwiftUI/Core/View/PrimitiveView.swift +++ b/Sources/OpenSwiftUICore/View/PrimitiveView.swift @@ -5,7 +5,7 @@ // Audited for RELEASE_2021 // Status: Complete -protocol PrimitiveView: View where Body == Never {} +package protocol PrimitiveView: View where Body == Never {} extension PrimitiveView { public var body: Never { diff --git a/Sources/OpenSwiftUI/Core/View/ViewTrait/ViewTraitCollection.swift b/Sources/OpenSwiftUICore/View/Trait/ViewTraitCollection.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/View/ViewTrait/ViewTraitCollection.swift rename to Sources/OpenSwiftUICore/View/Trait/ViewTraitCollection.swift diff --git a/Sources/OpenSwiftUI/Core/View/ViewTrait/ViewTraitKey.swift b/Sources/OpenSwiftUICore/View/Trait/ViewTraitKey.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/View/ViewTrait/ViewTraitKey.swift rename to Sources/OpenSwiftUICore/View/Trait/ViewTraitKey.swift diff --git a/Sources/OpenSwiftUI/Core/View/ViewTrait/ViewTraitKeys.swift b/Sources/OpenSwiftUICore/View/Trait/ViewTraitKeys.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/View/ViewTrait/ViewTraitKeys.swift rename to Sources/OpenSwiftUICore/View/Trait/ViewTraitKeys.swift diff --git a/Sources/OpenSwiftUI/View/View/TupleView.swift b/Sources/OpenSwiftUICore/View/TupleView.swift similarity index 100% rename from Sources/OpenSwiftUI/View/View/TupleView.swift rename to Sources/OpenSwiftUICore/View/TupleView.swift diff --git a/Sources/OpenSwiftUI/View/View/UnaryView.swift b/Sources/OpenSwiftUICore/View/UnaryView.swift similarity index 71% rename from Sources/OpenSwiftUI/View/View/UnaryView.swift rename to Sources/OpenSwiftUICore/View/UnaryView.swift index c615117e..ea4f8881 100644 --- a/Sources/OpenSwiftUI/View/View/UnaryView.swift +++ b/Sources/OpenSwiftUICore/View/UnaryView.swift @@ -5,4 +5,4 @@ // Audited for RELEASE_2021 // Status: Empty -protocol UnaryView: View {} +package protocol UnaryView: View {} diff --git a/Sources/OpenSwiftUI/Core/View/VariadicView/ForEach.swift b/Sources/OpenSwiftUICore/View/Variadic/ForEach.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/View/VariadicView/ForEach.swift rename to Sources/OpenSwiftUICore/View/Variadic/ForEach.swift diff --git a/Sources/OpenSwiftUI/Core/View/VariadicView/VariadicView.swift b/Sources/OpenSwiftUICore/View/Variadic/VariadicView.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/View/VariadicView/VariadicView.swift rename to Sources/OpenSwiftUICore/View/Variadic/VariadicView.swift diff --git a/Sources/OpenSwiftUI/Core/View/VariadicView/VariadicView_Children.swift b/Sources/OpenSwiftUICore/View/Variadic/VariadicView_Children.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/View/VariadicView/VariadicView_Children.swift rename to Sources/OpenSwiftUICore/View/Variadic/VariadicView_Children.swift diff --git a/Sources/OpenSwiftUI/Core/View/VariadicView/VariadicView_ImplicitRoot.swift b/Sources/OpenSwiftUICore/View/Variadic/VariadicView_ImplicitRoot.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/View/VariadicView/VariadicView_ImplicitRoot.swift rename to Sources/OpenSwiftUICore/View/Variadic/VariadicView_ImplicitRoot.swift diff --git a/Sources/OpenSwiftUI/Core/View/VariadicView/VariadicView_Root.swift b/Sources/OpenSwiftUICore/View/Variadic/VariadicView_Root.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/View/VariadicView/VariadicView_Root.swift rename to Sources/OpenSwiftUICore/View/Variadic/VariadicView_Root.swift diff --git a/Sources/OpenSwiftUI/Core/View/VariadicView/VariadicView_ViewRoot.swift b/Sources/OpenSwiftUICore/View/Variadic/VariadicView_ViewRoot.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/View/VariadicView/VariadicView_ViewRoot.swift rename to Sources/OpenSwiftUICore/View/Variadic/VariadicView_ViewRoot.swift diff --git a/Sources/OpenSwiftUI/Core/View/View.swift b/Sources/OpenSwiftUICore/View/View.swift similarity index 98% rename from Sources/OpenSwiftUI/Core/View/View.swift rename to Sources/OpenSwiftUICore/View/View.swift index 7c3af242..5f2ee2e2 100644 --- a/Sources/OpenSwiftUI/Core/View/View.swift +++ b/Sources/OpenSwiftUICore/View/View.swift @@ -102,7 +102,7 @@ extension Never: View { } extension View { - func bodyError() -> Never { + package func bodyError() -> Never { fatalError("body() should not be called on \(Self.self)") } } diff --git a/Sources/OpenSwiftUI/Core/View/ViewAlias.swift b/Sources/OpenSwiftUICore/View/ViewAlias.swift similarity index 86% rename from Sources/OpenSwiftUI/Core/View/ViewAlias.swift rename to Sources/OpenSwiftUICore/View/ViewAlias.swift index 660dd41b..0cfcbfe6 100644 --- a/Sources/OpenSwiftUI/Core/View/ViewAlias.swift +++ b/Sources/OpenSwiftUICore/View/ViewAlias.swift @@ -6,19 +6,19 @@ // Status: TODO // ID: D9F7AF928092578A4B8FA861B49E2161 -protocol ViewAlias: PrimitiveView { +package protocol ViewAlias: PrimitiveView { init() } extension View { - func viewAlias( + package func viewAlias( _ alias: Alias.Type, _ source: () -> Source ) -> some View { modifier(StaticSourceWriter(source: source())) } - func viewAlias( + package func viewAlias( _ alias: Alias.Type, _ source: () -> Source? ) -> some View { diff --git a/Sources/OpenSwiftUI/Core/BodyAccessor/ViewBodyAccessor.swift b/Sources/OpenSwiftUICore/View/ViewBodyAccessor.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/BodyAccessor/ViewBodyAccessor.swift rename to Sources/OpenSwiftUICore/View/ViewBodyAccessor.swift diff --git a/Sources/OpenSwiftUI/Core/View/ViewBuilder.swift b/Sources/OpenSwiftUICore/View/ViewBuilder.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/View/ViewBuilder.swift rename to Sources/OpenSwiftUICore/View/ViewBuilder.swift diff --git a/Sources/OpenSwiftUICore/View/ViewDebug.swift b/Sources/OpenSwiftUICore/View/ViewDebug.swift deleted file mode 100644 index 62e96ff8..00000000 --- a/Sources/OpenSwiftUICore/View/ViewDebug.swift +++ /dev/null @@ -1,69 +0,0 @@ -// -// ViewDebug.swift -// OpenSwiftUICore -// -// Audited for RELEASE_2024 -// Status: WIP - -public enum _ViewDebug { - public enum Property: UInt32, Hashable { - case type - case value - case transform - case position - case size - case environment - case phase - case layoutComputer - case displayList - } - - public struct Properties: OptionSet { - public let rawValue: UInt32 - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - - @inlinable - package init(_ property: Property) { - self.init(rawValue: 1 << property.rawValue) - } - - public static let type = Properties(.type) - public static let value = Properties(.value) - public static let transform = Properties(.transform) - public static let position = Properties(.position) - public static let size = Properties(.size) - public static let environment = Properties(.environment) - public static let phase = Properties(.phase) - public static let layoutComputer = Properties(.layoutComputer) - public static let displayList = Properties(.displayList) - public static let all = Properties(rawValue: 0xFFFF_FFFF) - } - - package static var properties = Properties() - - public struct Data { - package var data: [Property: Any] - package var childData: [_ViewDebug.Data] - - package init() { - data = [:] - childData = [] - } - } - - package static var isInitialized = false -} - -@available(*, unavailable) -extension _ViewDebug.Properties: Sendable {} - -@available(*, unavailable) -extension _ViewDebug.Property: Sendable {} - -@available(*, unavailable) -extension _ViewDebug.Data: Sendable {} - -@available(*, unavailable) -extension _ViewDebug: Sendable {} diff --git a/Sources/OpenSwiftUI/Core/View/ViewGraph.swift b/Sources/OpenSwiftUICore/View/ViewGraph.swift similarity index 97% rename from Sources/OpenSwiftUI/Core/View/ViewGraph.swift rename to Sources/OpenSwiftUICore/View/ViewGraph.swift index fcf7617e..b20f68f6 100644 --- a/Sources/OpenSwiftUI/Core/View/ViewGraph.swift +++ b/Sources/OpenSwiftUICore/View/ViewGraph.swift @@ -8,7 +8,6 @@ internal import OpenGraphShims import Foundation -@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore package final class ViewGraph: GraphHost { @inline(__always) @@ -48,7 +47,7 @@ package final class ViewGraph: GraphHost { var needsFocusUpdate: Bool = false var nextUpdate: (views: NextUpdate, gestures: NextUpdate) = (NextUpdate(time: .infinity), NextUpdate(time: .infinity)) private weak var _preferenceBridge: PreferenceBridge? - var preferenceBridge: PreferenceBridge? { + package var preferenceBridge: PreferenceBridge? { get { _preferenceBridge } set { setPreferenceBridge(to: newValue, isInvalidating: false) } } @@ -57,7 +56,7 @@ package final class ViewGraph: GraphHost { #endif // TODO - init(rootViewType: Body.Type, requestedOutputs: Outputs) { + package init(rootViewType: Body.Type, requestedOutputs: Outputs) { #if canImport(Darwin) self.rootViewType = rootViewType self.requestedOutputs = requestedOutputs @@ -180,7 +179,7 @@ package final class ViewGraph: GraphHost { // TODO } - func setRootView(_ view: V) { + package func setRootView(_ view: V) { #if canImport(Darwin) @Attribute(identifier: rootView) var rootView: V @@ -317,8 +316,12 @@ extension ViewGraph { } extension ViewGraph { - struct Outputs: OptionSet { - let rawValue: UInt8 + package struct Outputs: OptionSet { + package let rawValue: UInt8 + + package init(rawValue: UInt8) { + self.rawValue = rawValue + } static var _0: Outputs { .init(rawValue: 1 << 0) } static var _1: Outputs { .init(rawValue: 1 << 1) } diff --git a/Sources/OpenSwiftUI/Core/View/ViewGraphDelegate.swift b/Sources/OpenSwiftUICore/View/ViewGraphDelegate.swift similarity index 86% rename from Sources/OpenSwiftUI/Core/View/ViewGraphDelegate.swift rename to Sources/OpenSwiftUICore/View/ViewGraphDelegate.swift index bde183e7..7a50732c 100644 --- a/Sources/OpenSwiftUI/Core/View/ViewGraphDelegate.swift +++ b/Sources/OpenSwiftUICore/View/ViewGraphDelegate.swift @@ -5,9 +5,7 @@ // Audited for RELEASE_2021 // Status: Complete -@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore - -protocol ViewGraphDelegate: GraphDelegate { +package protocol ViewGraphDelegate: GraphDelegate { func modifyViewInputs(_ inputs: inout _ViewInputs) func updateViewGraph(body: (ViewGraph) -> Value) -> Value func outputsDidChange(outputs: ViewGraph.Outputs) -> () diff --git a/Sources/OpenSwiftUI/Core/View/View/ViewInput.swift b/Sources/OpenSwiftUICore/View/ViewInput.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/View/View/ViewInput.swift rename to Sources/OpenSwiftUICore/View/ViewInput.swift diff --git a/Sources/OpenSwiftUI/Core/View/View/ViewInputFlag.swift b/Sources/OpenSwiftUICore/View/ViewInputFlag.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/View/View/ViewInputFlag.swift rename to Sources/OpenSwiftUICore/View/ViewInputFlag.swift diff --git a/Sources/OpenSwiftUI/Core/View/View/ViewInputPredicate.swift b/Sources/OpenSwiftUICore/View/ViewInputPredicate.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/View/View/ViewInputPredicate.swift rename to Sources/OpenSwiftUICore/View/ViewInputPredicate.swift diff --git a/Sources/OpenSwiftUICore/View/ViewInputs.swift b/Sources/OpenSwiftUICore/View/ViewInputs.swift index 8221cf3f..d58d6ebf 100644 --- a/Sources/OpenSwiftUICore/View/ViewInputs.swift +++ b/Sources/OpenSwiftUICore/View/ViewInputs.swift @@ -1 +1,146 @@ +// +// ViewInputs.swift +// OpenSwiftUI +// +// Audited for RELEASE_2021 +// Status: WIP + +internal import OpenGraphShims + package typealias ViewPhase = _GraphInputs.Phase + +/// The input (aka inherited) attributes supplied to each view. Most +/// view types will only actually wire a small number of these into +/// their node. Doesn't include the view itself, which is passed +/// separately. +public struct _ViewInputs { + private var base: _GraphInputs + var preferences: PreferencesInputs + var transform: Attribute + var position: Attribute + var containerPosition: Attribute + var size: Attribute + var safeAreaInsets: OptionalAttribute + + init( + base: _GraphInputs, + preferences: PreferencesInputs, + transform: Attribute, + position: Attribute, + containerPosition: Attribute, + size: Attribute, + safeAreaInsets: OptionalAttribute + ) { + self.base = base + self.preferences = preferences + self.transform = transform + self.position = position + self.containerPosition = containerPosition + self.size = size + self.safeAreaInsets = safeAreaInsets + } + + mutating func append(_ value: Value, to type: Input.Type) where Input.Value == [Value] { + var values = base[type] + values.append(value) + base[type] = values + } + + mutating func popLast(_ type: Input.Type) -> Value? where Input.Value == [Value] { + var values = base[type] + guard let value = values.popLast() else { + return nil + } + base[type] = values + return value + } + + func makeIndirectOutputs() -> _ViewOutputs { + #if canImport(Darwin) + struct AddPreferenceVisitor: PreferenceKeyVisitor { + var outputs = _ViewOutputs() + mutating func visit(key: Key.Type) { +// let source = ViewGraph.current.intern(Key.defaultValue, id: 0) +// let indirect = IndirectAttribute(source: source) +// outputs.appendPreference(key: Key.self, value: Attribute(identifier: indirect.identifier)) + fatalError() + } + } + var visitor = AddPreferenceVisitor() + preferences.keys.forEach { key in + key.visitKey(&visitor) + } + var outputs = visitor.outputs + outputs.setLayoutComputer(self) { + let indirect = IndirectAttribute(source: ViewGraph.current.$defaultLayoutComputer) + return Attribute(identifier: indirect.identifier) + } + return outputs + #else + fatalError("See #39") + #endif + } + + // MARK: - base + + @inline(__always) + mutating func withMutateGraphInputs(_ body: (inout _GraphInputs) -> R) -> R { + body(&base) + } + + // MARK: - base.customInputs + + @inline(__always) + func withCustomInputs(_ body: (PropertyList) -> R) -> R { + body(base.customInputs) + } + + @inline(__always) + mutating func withMutableCustomInputs(_ body: (inout PropertyList) -> R) -> R { + body(&base.customInputs) + } + + // MARK: - base.cachedEnvironment + + @inline(__always) + func withCachedEnviroment(_ body: (CachedEnvironment) -> R) -> R { + body(base.cachedEnvironment.wrappedValue) + } + + @inline(__always) + func withMutableCachedEnviroment(_ body: (inout CachedEnvironment) -> R) -> R { + body(&base.cachedEnvironment.wrappedValue) + } + + @inline(__always) + func detechedEnvironmentInputs() -> Self { + var newInputs = self + newInputs.base = self.base.detechedEnvironmentInputs() + return newInputs + } + + // MARK: - base.phase + @inline(__always) + var phase: Attribute<_GraphInputs.Phase> { + base.phase + } + + // MARK: - base.changedDebugProperties + + @inline(__always) + func withEmptyChangedDebugPropertiesInputs(_ body: (_ViewInputs) -> R) -> R { + var newInputs = self + return base.withEmptyChangedDebugPropertiesInputs { + newInputs.base = $0 + return body(newInputs) + } + } + + // MARK: Options + + @inline(__always) + var enableLayout: Bool { + get { base.enableLayout } + // TODO: setter + } +} diff --git a/Sources/OpenSwiftUI/Core/View/View/ViewList.swift b/Sources/OpenSwiftUICore/View/ViewList.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/View/View/ViewList.swift rename to Sources/OpenSwiftUICore/View/ViewList.swift diff --git a/Sources/OpenSwiftUI/Core/View/View/ViewOutputs.swift b/Sources/OpenSwiftUICore/View/ViewOutputs.swift similarity index 98% rename from Sources/OpenSwiftUI/Core/View/View/ViewOutputs.swift rename to Sources/OpenSwiftUICore/View/ViewOutputs.swift index d965df83..cc73ee50 100644 --- a/Sources/OpenSwiftUI/Core/View/View/ViewOutputs.swift +++ b/Sources/OpenSwiftUICore/View/ViewOutputs.swift @@ -1,5 +1,4 @@ internal import OpenGraphShims -@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore /// The output (aka synthesized) attributes returned by each view. public struct _ViewOutputs { diff --git a/Sources/OpenSwiftUI/Core/View/ViewRendererHost.swift b/Sources/OpenSwiftUICore/View/ViewRendererHost.swift similarity index 75% rename from Sources/OpenSwiftUI/Core/View/ViewRendererHost.swift rename to Sources/OpenSwiftUICore/View/ViewRendererHost.swift index 5d75ba5a..ef91bee2 100644 --- a/Sources/OpenSwiftUI/Core/View/ViewRendererHost.swift +++ b/Sources/OpenSwiftUICore/View/ViewRendererHost.swift @@ -6,9 +6,8 @@ // Status: WIP internal import OpenGraphShims -@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore -protocol ViewRendererHost: ViewGraphDelegate { +package protocol ViewRendererHost: ViewGraphDelegate { var viewGraph: ViewGraph { get } var currentTimestamp: Time { get set } var propertiesNeedingUpdate: ViewRendererHostProperties { get set } @@ -21,7 +20,7 @@ protocol ViewRendererHost: ViewGraphDelegate { // MARK: - ViewRendererHost's default implementation for ViewGraphDelegate extension ViewRendererHost { - func updateViewGraph(body: (ViewGraph) -> Value) -> Value { + package func updateViewGraph(body: (ViewGraph) -> Value) -> Value { Update.dispatchImmediately { OGGraph.withoutUpdate { updateGraph() @@ -32,12 +31,12 @@ extension ViewRendererHost { } extension ViewRendererHost { - func initializeViewGraph() { + package func initializeViewGraph() { viewGraph.delegate = self // TODO: Signpost related } - func invalidateProperties(_ properties: ViewRendererHostProperties, mayDeferUpdate: Bool) { + package func invalidateProperties(_ properties: ViewRendererHostProperties, mayDeferUpdate: Bool) { Update.locked { guard !propertiesNeedingUpdate.contains(properties) else { return @@ -48,15 +47,15 @@ extension ViewRendererHost { } } - func startProfiling() { + package func startProfiling() { OGGraph.startProfiling(viewGraph.graph) } - func stopProfiling() { + package func stopProfiling() { OGGraph.stopProfiling(viewGraph.graph) } - func render(interval: Double, updateDisplayList: Bool = true) { + package func render(interval: Double, updateDisplayList: Bool = true) { Update.dispatchImmediately { guard !isRendering else { return @@ -78,11 +77,11 @@ extension ViewRendererHost { } } - static func makeRootView(_ view: V) -> some View { + package static func makeRootView(_ view: V) -> some View { view/*.modifier(HitTestBindingModifier())*/ } - func updateGraph() { + package func updateGraph() { var properties = propertiesNeedingUpdate addImplicitPropertiesNeedingUpdate(to: &properties) guard !properties.isEmpty else { return } @@ -98,14 +97,18 @@ extension ViewRendererHost { } } - func invalidate() { + package func invalidate() { viewGraph.delegate = nil // TODO: Signpost.viewHost } } -struct ViewRendererHostProperties: OptionSet { - let rawValue: UInt16 +package struct ViewRendererHostProperties: OptionSet { + package let rawValue: UInt16 - static var rootView: ViewRendererHostProperties { ViewRendererHostProperties(rawValue: 1 << 0) } + package init(rawValue: UInt16) { + self.rawValue = rawValue + } + + package static var rootView: ViewRendererHostProperties { ViewRendererHostProperties(rawValue: 1 << 0) } } diff --git a/Sources/OpenSwiftUI/Core/View/ViewRoot.swift b/Sources/OpenSwiftUICore/View/ViewRoot.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/View/ViewRoot.swift rename to Sources/OpenSwiftUICore/View/ViewRoot.swift diff --git a/Sources/OpenSwiftUI/Core/View/ViewVisitor.swift b/Sources/OpenSwiftUICore/View/ViewVisitor.swift similarity index 100% rename from Sources/OpenSwiftUI/Core/View/ViewVisitor.swift rename to Sources/OpenSwiftUICore/View/ViewVisitor.swift diff --git a/Tests/OpenSwiftUITests/COpenSwiftUI/MovableLockTests.swift b/Tests/OpenSwiftUICoreTests/COpenSwiftUICore/MovableLockTests.swift similarity index 96% rename from Tests/OpenSwiftUITests/COpenSwiftUI/MovableLockTests.swift rename to Tests/OpenSwiftUICoreTests/COpenSwiftUICore/MovableLockTests.swift index 2cf6e467..0f348d6a 100644 --- a/Tests/OpenSwiftUITests/COpenSwiftUI/MovableLockTests.swift +++ b/Tests/OpenSwiftUICoreTests/COpenSwiftUICore/MovableLockTests.swift @@ -5,7 +5,7 @@ // Created by Kyle on 2024/3/16. // -import COpenSwiftUI +import COpenSwiftUICore import Testing #if canImport(Darwin) diff --git a/Tests/OpenSwiftUITests/Data/Preference/HostPreferencesKeyTests.swift b/Tests/OpenSwiftUICoreTests/Data/Preference/HostPreferencesKeyTests.swift similarity index 99% rename from Tests/OpenSwiftUITests/Data/Preference/HostPreferencesKeyTests.swift rename to Tests/OpenSwiftUICoreTests/Data/Preference/HostPreferencesKeyTests.swift index 442ec3af..8ded5b42 100644 --- a/Tests/OpenSwiftUITests/Data/Preference/HostPreferencesKeyTests.swift +++ b/Tests/OpenSwiftUICoreTests/Data/Preference/HostPreferencesKeyTests.swift @@ -5,7 +5,7 @@ // Created by Kyle on 2024/2/4. // -@testable import OpenSwiftUI +@testable import OpenSwiftUICore import Testing struct HostPreferencesKeyTests { diff --git a/Tests/OpenSwiftUICoreTests/Data/Preference/PreferenceKeyTests.swift b/Tests/OpenSwiftUICoreTests/Data/Preference/PreferenceKeyTests.swift index eb0c555c..58a43ec8 100644 --- a/Tests/OpenSwiftUICoreTests/Data/Preference/PreferenceKeyTests.swift +++ b/Tests/OpenSwiftUICoreTests/Data/Preference/PreferenceKeyTests.swift @@ -30,4 +30,25 @@ struct PreferenceKeyTests { #expect(CPreferenceKey.readableName == "C") #expect(PreferenceKey.readableName == "PreferenceKeyTests.PreferenceKey") } + + struct DemoKey: OpenSwiftUICore.PreferenceKey { + struct Value: ExpressibleByNilLiteral { + var value = 0 + init(nilLiteral _: ()) {} + init(value: Int) { self.value = value } + } + + static func reduce(value: inout Value, nextValue: () -> Value) { + value.value = nextValue().value + } + } + + @Test + func preferenceKeyReduce() throws { + var value = DemoKey.defaultValue + DemoKey.reduce(value: &value) { + DemoKey.Value(value: 3) + } + #expect(value.value == 3) + } } diff --git a/Tests/OpenSwiftUICoreTests/Data/Preference/PreferenceListTests.swift b/Tests/OpenSwiftUICoreTests/Data/Preference/PreferenceListTests.swift index 10742901..d3966fc9 100644 --- a/Tests/OpenSwiftUICoreTests/Data/Preference/PreferenceListTests.swift +++ b/Tests/OpenSwiftUICoreTests/Data/Preference/PreferenceListTests.swift @@ -41,4 +41,62 @@ struct PreferenceListTests { list[B.self] = .init(value: 2, seed: .empty) #expect(list.description == "invalid: [B = 2, AKey = 2]") } + + struct IntKey: PreferenceKey { + static var defaultValue: Int { 0 } + + static func reduce(value: inout Int, nextValue: () -> Int) { + value += nextValue() + } + } + + struct DoubleKey: PreferenceKey { + static var defaultValue: Double { 0.0 } + + static func reduce(value: inout Double, nextValue: () -> Double) { + value += nextValue() + } + } + + struct EnumKey: PreferenceKey { + static func reduce(value: inout Value, nextValue: () -> Value) { + value = nextValue() + } + + enum Value { case a, b } + static var defaultValue: Value { .a } + } + + + @Test("Test description and subscript with zero seed") + func subscriptAndDescriptionWithZeroSeed() { + var list = PreferenceList() + #expect(list.description == "empty: []") + list[IntKey.self] = PreferenceList.Value(value: 1, seed: .empty) + #expect(list.description == "empty: [IntKey = 1]") + list[DoubleKey.self] = PreferenceList.Value(value: 1.0, seed: .empty) + #expect(list.description == "empty: [DoubleKey = 1.0, IntKey = 1]") + list[IntKey.self] = PreferenceList.Value(value: 2, seed: .empty) + #expect(list.description == "empty: [IntKey = 2, DoubleKey = 1.0]") + list[DoubleKey.self] = PreferenceList.Value(value: 1.0, seed: .empty) + #expect(list.description == "empty: [DoubleKey = 1.0, IntKey = 2]") + list[EnumKey.self] = PreferenceList.Value(value: .a, seed: .empty) + #expect(list.description == "empty: [EnumKey = a, DoubleKey = 1.0, IntKey = 2]") + } + + @Test("Test description and subscript with seed") + func subscriptAndDescriptionWithSeed() { + var list = PreferenceList() + #expect(list.description == "empty: []") + list[IntKey.self] = PreferenceList.Value(value: 1, seed: .init(value: 1)) + #expect(list.description == "1: [IntKey = 1]") + list[DoubleKey.self] = PreferenceList.Value(value: 1.0, seed: .init(value: 2)) + #expect(list.description == "547159728: [DoubleKey = 1.0, IntKey = 1]") + list[IntKey.self] = PreferenceList.Value(value: 2, seed: .init(value: 3)) + #expect(list.description == "3634229150: [IntKey = 2, DoubleKey = 1.0]") + list[DoubleKey.self] = PreferenceList.Value(value: 1.0, seed: .init(value: 4)) + #expect(list.description == "1218402493: [DoubleKey = 1.0, IntKey = 2]") + list[EnumKey.self] = PreferenceList.Value(value: .a, seed: .init(value: 5)) + #expect(list.description == "1817264013: [EnumKey = a, DoubleKey = 1.0, IntKey = 2]") + } } diff --git a/Tests/OpenSwiftUITests/View/Graphics/Color/ColorResolvedTests.swift b/Tests/OpenSwiftUICoreTests/Graphics/Color/ColorResolvedTests.swift similarity index 94% rename from Tests/OpenSwiftUITests/View/Graphics/Color/ColorResolvedTests.swift rename to Tests/OpenSwiftUICoreTests/Graphics/Color/ColorResolvedTests.swift index 67410bd8..3fe910f8 100644 --- a/Tests/OpenSwiftUITests/View/Graphics/Color/ColorResolvedTests.swift +++ b/Tests/OpenSwiftUICoreTests/Graphics/Color/ColorResolvedTests.swift @@ -4,7 +4,7 @@ #if canImport(Darwin) -@testable import OpenSwiftUI +@testable import OpenSwiftUICore import Testing struct ColorResolvedTests { diff --git a/Tests/OpenSwiftUITests/Layout/LayoutAdjustments/Alignment/AlignmentIDTests.swift b/Tests/OpenSwiftUICoreTests/Layout/LayoutAdjustments/Alignment/AlignmentIDTests.swift similarity index 97% rename from Tests/OpenSwiftUITests/Layout/LayoutAdjustments/Alignment/AlignmentIDTests.swift rename to Tests/OpenSwiftUICoreTests/Layout/LayoutAdjustments/Alignment/AlignmentIDTests.swift index cda1f5dd..518d491f 100644 --- a/Tests/OpenSwiftUITests/Layout/LayoutAdjustments/Alignment/AlignmentIDTests.swift +++ b/Tests/OpenSwiftUICoreTests/Layout/LayoutAdjustments/Alignment/AlignmentIDTests.swift @@ -5,7 +5,7 @@ // Created by Kyle on 2023/12/16. // -@testable import OpenSwiftUI +@testable import OpenSwiftUICore import Testing import Foundation diff --git a/Tests/OpenSwiftUITests/Layout/LayoutFundamentals/ProposedSizeTests.swift b/Tests/OpenSwiftUICoreTests/Layout/LayoutFundamentals/ProposedSizeTests.swift similarity index 94% rename from Tests/OpenSwiftUITests/Layout/LayoutFundamentals/ProposedSizeTests.swift rename to Tests/OpenSwiftUICoreTests/Layout/LayoutFundamentals/ProposedSizeTests.swift index 5867e14d..f329044f 100644 --- a/Tests/OpenSwiftUITests/Layout/LayoutFundamentals/ProposedSizeTests.swift +++ b/Tests/OpenSwiftUICoreTests/Layout/LayoutFundamentals/ProposedSizeTests.swift @@ -6,7 +6,7 @@ // Status: Complete import OpenGraphShims -@testable import OpenSwiftUI +@testable import OpenSwiftUICore import Testing @Suite diff --git a/Tests/OpenSwiftUITests/View/Shape/Path/FixedRoundedRectTests.swift b/Tests/OpenSwiftUICoreTests/Shape/Path/FixedRoundedRectTests.swift similarity index 82% rename from Tests/OpenSwiftUITests/View/Shape/Path/FixedRoundedRectTests.swift rename to Tests/OpenSwiftUICoreTests/Shape/Path/FixedRoundedRectTests.swift index ce2ebd34..52edd8e8 100644 --- a/Tests/OpenSwiftUITests/View/Shape/Path/FixedRoundedRectTests.swift +++ b/Tests/OpenSwiftUICoreTests/Shape/Path/FixedRoundedRectTests.swift @@ -2,7 +2,7 @@ // FixedRoundedRectTests.swift // OpenSwiftUITests -@testable import OpenSwiftUI +@testable import OpenSwiftUICore import Testing struct FixedRoundedRectTests { diff --git a/Tests/OpenSwiftUITests/View/View/AnyViewTests.swift b/Tests/OpenSwiftUICoreTests/View/AnyViewTests.swift similarity index 93% rename from Tests/OpenSwiftUITests/View/View/AnyViewTests.swift rename to Tests/OpenSwiftUICoreTests/View/AnyViewTests.swift index 81e3cba1..907f0b7a 100644 --- a/Tests/OpenSwiftUITests/View/View/AnyViewTests.swift +++ b/Tests/OpenSwiftUICoreTests/View/AnyViewTests.swift @@ -2,7 +2,7 @@ // AnyViewTests.swift // OpenSwiftUITests -@testable import OpenSwiftUI +@testable import OpenSwiftUICore import Testing struct AnyViewTests { diff --git a/Tests/OpenSwiftUITests/View/Core/Debug/ViewDebugTests.swift b/Tests/OpenSwiftUICoreTests/View/Debug/ViewDebugTests.swift similarity index 96% rename from Tests/OpenSwiftUITests/View/Core/Debug/ViewDebugTests.swift rename to Tests/OpenSwiftUICoreTests/View/Debug/ViewDebugTests.swift index c70d8d21..b466689a 100644 --- a/Tests/OpenSwiftUITests/View/Core/Debug/ViewDebugTests.swift +++ b/Tests/OpenSwiftUICoreTests/View/Debug/ViewDebugTests.swift @@ -5,7 +5,7 @@ // Created by Kyle on 2023/10/6. // -@testable import OpenSwiftUI +@testable import OpenSwiftUICore import Testing import Foundation diff --git a/Tests/OpenSwiftUITests/View/Core/InterfaceIdiomTests.swift b/Tests/OpenSwiftUICoreTests/View/InterfaceIdiomTests.swift similarity index 97% rename from Tests/OpenSwiftUITests/View/Core/InterfaceIdiomTests.swift rename to Tests/OpenSwiftUICoreTests/View/InterfaceIdiomTests.swift index de5a3c75..e8a7f2ca 100644 --- a/Tests/OpenSwiftUITests/View/Core/InterfaceIdiomTests.swift +++ b/Tests/OpenSwiftUICoreTests/View/InterfaceIdiomTests.swift @@ -2,7 +2,7 @@ // InterfaceIdiomTests.swift // OpenSwiftUITests -@testable import OpenSwiftUI +@testable import OpenSwiftUICore import Testing #if canImport(UIKit) import UIKit diff --git a/Tests/OpenSwiftUITests/Data/Preference/PreferenceKeyTests.swift b/Tests/OpenSwiftUITests/Data/Preference/PreferenceKeyTests.swift deleted file mode 100644 index 74531d4f..00000000 --- a/Tests/OpenSwiftUITests/Data/Preference/PreferenceKeyTests.swift +++ /dev/null @@ -1,32 +0,0 @@ -// -// PreferenceKeyTests.swift -// -// -// Created by Kyle on 2023/10/11. -// - -@testable import OpenSwiftUI -import Testing - -struct PreferenceKeyTests { - struct DemoKey: PreferenceKey { - struct Value: ExpressibleByNilLiteral { - var value = 0 - init(nilLiteral _: ()) {} - init(value: Int) { self.value = value } - } - - static func reduce(value: inout Value, nextValue: () -> Value) { - value.value = nextValue().value - } - } - - @Test - func preferenceKeyReduce() throws { - var value = DemoKey.defaultValue - DemoKey.reduce(value: &value) { - DemoKey.Value(value: 3) - } - #expect(value.value == 3) - } -} diff --git a/Tests/OpenSwiftUITests/Data/Preference/PreferenceListTests.swift b/Tests/OpenSwiftUITests/Data/Preference/PreferenceListTests.swift deleted file mode 100644 index 17270484..00000000 --- a/Tests/OpenSwiftUITests/Data/Preference/PreferenceListTests.swift +++ /dev/null @@ -1,69 +0,0 @@ -// -// PreferenceListTests.swift -// -// -// Created by Kyle on 2024/2/4. -// - -@testable import OpenSwiftUI -import Testing - -struct PreferenceListTests { - struct IntKey: PreferenceKey { - static var defaultValue: Int { 0 } - - static func reduce(value: inout Int, nextValue: () -> Int) { - value += nextValue() - } - } - - struct DoubleKey: PreferenceKey { - static var defaultValue: Double { 0.0 } - - static func reduce(value: inout Double, nextValue: () -> Double) { - value += nextValue() - } - } - - struct EnumKey: PreferenceKey { - static func reduce(value: inout Value, nextValue: () -> Value) { - value = nextValue() - } - - enum Value { case a, b } - static var defaultValue: Value { .a } - } - - - @Test("Test description and subscript with zero seed") - func subscriptAndDescriptionWithZeroSeed() { - var list = PreferenceList() - #expect(list.description == "empty: []") - list[IntKey.self] = PreferenceList.Value(value: 1, seed: .empty) - #expect(list.description == "empty: [IntKey = 1]") - list[DoubleKey.self] = PreferenceList.Value(value: 1.0, seed: .empty) - #expect(list.description == "empty: [DoubleKey = 1.0, IntKey = 1]") - list[IntKey.self] = PreferenceList.Value(value: 2, seed: .empty) - #expect(list.description == "empty: [IntKey = 2, DoubleKey = 1.0]") - list[DoubleKey.self] = PreferenceList.Value(value: 1.0, seed: .empty) - #expect(list.description == "empty: [DoubleKey = 1.0, IntKey = 2]") - list[EnumKey.self] = PreferenceList.Value(value: .a, seed: .empty) - #expect(list.description == "empty: [EnumKey = a, DoubleKey = 1.0, IntKey = 2]") - } - - @Test("Test description and subscript with seed") - func subscriptAndDescriptionWithSeed() { - var list = PreferenceList() - #expect(list.description == "empty: []") - list[IntKey.self] = PreferenceList.Value(value: 1, seed: .init(value: 1)) - #expect(list.description == "1: [IntKey = 1]") - list[DoubleKey.self] = PreferenceList.Value(value: 1.0, seed: .init(value: 2)) - #expect(list.description == "547159728: [DoubleKey = 1.0, IntKey = 1]") - list[IntKey.self] = PreferenceList.Value(value: 2, seed: .init(value: 3)) - #expect(list.description == "3634229150: [IntKey = 2, DoubleKey = 1.0]") - list[DoubleKey.self] = PreferenceList.Value(value: 1.0, seed: .init(value: 4)) - #expect(list.description == "1218402493: [DoubleKey = 1.0, IntKey = 2]") - list[EnumKey.self] = PreferenceList.Value(value: .a, seed: .init(value: 5)) - #expect(list.description == "1817264013: [EnumKey = a, DoubleKey = 1.0, IntKey = 2]") - } -}