diff --git a/Sources/Model/User Interface/Renderable/RenderableStorage.swift b/Sources/Model/User Interface/Renderable/RenderableStorage.swift index c8b880a..f152457 100644 --- a/Sources/Model/User Interface/Renderable/RenderableStorage.swift +++ b/Sources/Model/User Interface/Renderable/RenderableStorage.swift @@ -6,7 +6,7 @@ // /// Store a reference to a rendered view in a view storage. -public class RenderableStorage { +public actor RenderableStorage { /// The pointer. /// diff --git a/Sources/View/AppearObserver.swift b/Sources/View/AppearObserver.swift index ba65acb..a2f3f3b 100644 --- a/Sources/View/AppearObserver.swift +++ b/Sources/View/AppearObserver.swift @@ -18,7 +18,7 @@ struct AppearObserver: ConvenienceWidget { /// - modifiers: Modify views before being updated. /// - type: The type of the app storage. func container( - modifiers: [(any AnyView) -> any AnyView], + modifiers: [@Sendable (any AnyView) -> any AnyView], type: Storage.Type ) -> ViewStorage where Storage: AppStorage { let storage = content.storage(modifiers: modifiers, type: type) @@ -34,7 +34,7 @@ struct AppearObserver: ConvenienceWidget { /// - type: The type of the app storage. func update( _ storage: ViewStorage, - modifiers: [(any AnyView) -> any AnyView], + modifiers: [@Sendable (any AnyView) -> any AnyView], updateProperties: Bool, type: Storage.Type ) where Storage: AppStorage { diff --git a/Sources/View/ContentModifier.swift b/Sources/View/ContentModifier.swift index 42acd8d..baad4fe 100644 --- a/Sources/View/ContentModifier.swift +++ b/Sources/View/ContentModifier.swift @@ -18,7 +18,7 @@ struct ContentModifier: ConvenienceWidget where Content: AnyView { /// - modifiers: Modify views before being updated. /// - type: The type of the app storage. func container( - modifiers: [(any AnyView) -> any AnyView], + modifiers: [@Sendable (any AnyView) -> any AnyView], type: Storage.Type ) -> ViewStorage where Storage: AppStorage { content.storage(modifiers: modifiers + [modifyView], type: type) @@ -32,7 +32,7 @@ struct ContentModifier: ConvenienceWidget where Content: AnyView { /// - type: The type of the app storage. func update( _ storage: ViewStorage, - modifiers: [(any AnyView) -> any AnyView], + modifiers: [@Sendable (any AnyView) -> any AnyView], updateProperties: Bool, type: Storage.Type ) where Storage: AppStorage { @@ -42,7 +42,7 @@ struct ContentModifier: ConvenienceWidget where Content: AnyView { /// Apply the modifier to a view. /// - Parameter view: The view. - func modifyView(_ view: AnyView) -> AnyView { + @Sendable func modifyView(_ view: AnyView) -> AnyView { if let view = view as? Content { return modify(view).stopModifiers() } else { diff --git a/Sources/View/Freeze.swift b/Sources/View/Freeze.swift index 15b0ad9..927baf4 100644 --- a/Sources/View/Freeze.swift +++ b/Sources/View/Freeze.swift @@ -18,7 +18,7 @@ struct Freeze: ConvenienceWidget { /// - modifiers: Modify views before being updated. /// - type: The type of the app storage. func container( - modifiers: [(any AnyView) -> any AnyView], + modifiers: [@Sendable (any AnyView) -> any AnyView], type: Storage.Type ) -> ViewStorage where Storage: AppStorage { content.storage(modifiers: modifiers, type: type) @@ -32,7 +32,7 @@ struct Freeze: ConvenienceWidget { /// - type: The type of the app storage. func update( _ storage: ViewStorage, - modifiers: [(any AnyView) -> any AnyView], + modifiers: [@Sendable (any AnyView) -> any AnyView], updateProperties: Bool, type: Storage.Type ) where Storage: AppStorage { diff --git a/Sources/View/InspectorWrapper.swift b/Sources/View/InspectorWrapper.swift index 347d713..b09c6c7 100644 --- a/Sources/View/InspectorWrapper.swift +++ b/Sources/View/InspectorWrapper.swift @@ -18,7 +18,7 @@ struct InspectorWrapper: ConvenienceWidget { /// - modifiers: Modify views before being updated. /// - type: The type of the app storage. func container( - modifiers: [(any AnyView) -> any AnyView], + modifiers: [@Sendable (any AnyView) -> any AnyView], type: Storage.Type ) -> ViewStorage where Storage: AppStorage { let storage = content.storage(modifiers: modifiers, type: type) @@ -34,7 +34,7 @@ struct InspectorWrapper: ConvenienceWidget { /// - type: The type of the app storage. func update( _ storage: ViewStorage, - modifiers: [(any AnyView) -> any AnyView], + modifiers: [@Sendable (any AnyView) -> any AnyView], updateProperties: Bool, type: Storage.Type ) where Storage: AppStorage { diff --git a/Sources/View/ModifierStopper.swift b/Sources/View/ModifierStopper.swift index 32834fe..d5ec0bc 100644 --- a/Sources/View/ModifierStopper.swift +++ b/Sources/View/ModifierStopper.swift @@ -16,7 +16,7 @@ struct ModifierStopper: ConvenienceWidget { /// - modifiers: Modify views before being updated. /// - type: The type of the app storage. func container( - modifiers: [(any AnyView) -> any AnyView], + modifiers: [@Sendable (any AnyView) -> any AnyView], type: Storage.Type ) -> ViewStorage where Storage: AppStorage { content.storage(modifiers: [], type: type) @@ -30,7 +30,7 @@ struct ModifierStopper: ConvenienceWidget { /// - type: The type of the app storage. func update( _ storage: ViewStorage, - modifiers: [(any AnyView) -> any AnyView], + modifiers: [@Sendable (any AnyView) -> any AnyView], updateProperties: Bool, type: Storage.Type ) where Storage: AppStorage { diff --git a/Tests/SampleBackends/Backend1.swift b/Tests/SampleBackends/Backend1.swift index ab769dd..cb48573 100644 --- a/Tests/SampleBackends/Backend1.swift +++ b/Tests/SampleBackends/Backend1.swift @@ -56,7 +56,7 @@ public enum Backend1 { self.action = action } - public func container(modifiers: [(any AnyView) -> any AnyView], type: Storage.Type) -> ViewStorage where Storage: AppStorage { + public func container(modifiers: [@Sendable (any AnyView) -> any AnyView], type: Storage.Type) -> ViewStorage where Storage: AppStorage { print("Init button") let storage = ViewStorage(nil) Task { @@ -67,7 +67,7 @@ public enum Backend1 { return storage } - public func update(_ storage: ViewStorage, modifiers: [(any AnyView) -> any AnyView], updateProperties: Bool, type: Storage.Type) { + public func update(_ storage: ViewStorage, modifiers: [@Sendable (any AnyView) -> any AnyView], updateProperties: Bool, type: Storage.Type) { Task { if updateProperties { print("Update button (label = \(label))") @@ -98,7 +98,7 @@ public enum Backend1 { print("Update renderable") } - public func container(modifiers: [(any AnyView) -> any AnyView], type: Storage.Type) -> ViewStorage where Storage: AppStorage { + public func container(modifiers: [@Sendable (any AnyView) -> any AnyView], type: Storage.Type) -> ViewStorage where Storage: AppStorage { let storage = ViewStorage(nil) Task { await storage.setRenderableContent(key: .mainContent, value: (content as [Renderable]).storages(type: MenuElement.self, fields: [:])) @@ -106,7 +106,7 @@ public enum Backend1 { return storage } - public func update(_ storage: ViewStorage, modifiers: [(any AnyView) -> any AnyView], updateProperties: Bool, type: Storage.Type) { + public func update(_ storage: ViewStorage, modifiers: [@Sendable (any AnyView) -> any AnyView], updateProperties: Bool, type: Storage.Type) { Task { (content as [Renderable]).update(await storage.getRenderableContent(key: .mainContent), updateProperties: updateProperties, type: MenuElement.self, fields: [:]) } @@ -158,7 +158,7 @@ public enum Backend1 { self.content = content() } - public func container(modifiers: [(any Meta.AnyView) -> any Meta.AnyView], type: Storage.Type) -> Meta.ViewStorage where Storage : Meta.AppStorage { + public func container(modifiers: [@Sendable (any Meta.AnyView) -> any Meta.AnyView], type: Storage.Type) -> Meta.ViewStorage where Storage : Meta.AppStorage { let storage = ViewStorage(nil) Task { await storage.setContent(key: .mainContent, value: content.storages(modifiers: modifiers, type: type)) @@ -166,7 +166,7 @@ public enum Backend1 { return storage } - public func update(_ storage: Meta.ViewStorage, modifiers: [(any Meta.AnyView) -> any Meta.AnyView], updateProperties: Bool, type: Storage.Type) where Storage : Meta.AppStorage { + public func update(_ storage: Meta.ViewStorage, modifiers: [@Sendable (any Meta.AnyView) -> any Meta.AnyView], updateProperties: Bool, type: Storage.Type) where Storage : Meta.AppStorage { Task { content.update(await storage.getContent(key: .mainContent), modifiers: modifiers, updateProperties: updateProperties, type: type) } diff --git a/Tests/SampleBackends/Backend2.swift b/Tests/SampleBackends/Backend2.swift index 98f4a3a..45c0491 100644 --- a/Tests/SampleBackends/Backend2.swift +++ b/Tests/SampleBackends/Backend2.swift @@ -54,7 +54,7 @@ public enum Backend2 { self.content = content() } - public func container(modifiers: [(any Meta.AnyView) -> any Meta.AnyView], type: Storage.Type) -> Meta.ViewStorage where Storage : Meta.AppStorage { + public func container(modifiers: [@Sendable (any Meta.AnyView) -> any Meta.AnyView], type: Storage.Type) -> Meta.ViewStorage where Storage : Meta.AppStorage { let storage = ViewStorage(nil) Task { await storage.setContent(key: .mainContent, value: content.storages(modifiers: modifiers, type: type)) @@ -62,7 +62,7 @@ public enum Backend2 { return storage } - public func update(_ storage: Meta.ViewStorage, modifiers: [(any Meta.AnyView) -> any Meta.AnyView], updateProperties: Bool, type: Storage.Type) where Storage : Meta.AppStorage { + public func update(_ storage: Meta.ViewStorage, modifiers: [@Sendable (any Meta.AnyView) -> any Meta.AnyView], updateProperties: Bool, type: Storage.Type) where Storage : Meta.AppStorage { Task { content.update(await storage.getContent(key: .mainContent), modifiers: modifiers, updateProperties: updateProperties, type: type) }