From ce89626437fccf8eb96dea0000bc3ea3f6f979dc Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Mon, 9 Sep 2024 19:40:33 -0400 Subject: [PATCH] fixing organization --- Package.swift | 36 +++++++-- .../AppKit/NewFilePanel.swift | 0 .../AppKit/OpenAnyFilePanel.swift | 2 +- .../AppKit/OpenFilePanel.swift | 0 .../CodablePackage.swift | 3 +- .../RadiantDocs/CodablePackageDocument.swift | 79 +++++++++++++++++++ .../DocumentFile.swift | 0 .../FileTypeSpecification.swift | 1 + .../InitializableFileTypeSpecification.swift | 0 .../InitializablePackage.swift | 2 +- .../OpenFileURLAction.swift | 49 ++++++------ .../OpenWindowWithAction.swift | 23 +++--- .../OpenWindowWithValueAction.swift | 35 ++++---- .../Documents => RadiantDocs}/UTType.swift | 5 +- .../AppKit/NSWindowAdaptorModifier.swift | 3 +- .../AppKit/View+NSWindowDelegate.swift | 2 - .../AppStorage+ExpressibleByNilLiteral.swift | 6 +- .../FileType.swift | 44 +++++------ .../BushelViewsCore/PreferredLayoutView.swift | 3 - .../BushelViewsCore/SingleWindowView.swift | 18 +++-- .../RadiantKit/BushelViewsCore/Video.swift | 1 - .../Documents/CodablePackageDocument.swift | 54 ------------- .../CancelPageAction.swift | 0 .../ContainerView.swift | 0 .../DismissParameters.swift | 1 + .../NextPageAction.swift | 0 .../PageNavigationAvailability.swift | 0 .../Paging => RadiantPaging}/PageView.swift | 1 + .../PreviousPageAction.swift | 0 .../CopyOperation.swift | 0 .../CopyPaths.swift | 0 .../DownloadOperation.swift | 0 .../FileOperationProgress.swift | 2 +- .../ObservableDownloader.swift | 3 +- .../PreviewOperation.swift | 0 .../ProgressOperation.swift | 0 .../ProgressOperationProperties.swift | 0 .../ProgressOperationView.swift | 0 .../SetupPublishers.swift | 0 39 files changed, 210 insertions(+), 163 deletions(-) rename Sources/{RadiantKit/BushelViewsCore => RadiantDocs}/AppKit/NewFilePanel.swift (100%) rename Sources/{RadiantKit/BushelViewsCore => RadiantDocs}/AppKit/OpenAnyFilePanel.swift (98%) rename Sources/{RadiantKit/BushelViewsCore => RadiantDocs}/AppKit/OpenFilePanel.swift (100%) rename Sources/{RadiantKit/Documents => RadiantDocs}/CodablePackage.swift (97%) create mode 100644 Sources/RadiantDocs/CodablePackageDocument.swift rename Sources/{RadiantKit/Documents => RadiantDocs}/DocumentFile.swift (100%) rename Sources/{RadiantKit/Documents => RadiantDocs}/FileTypeSpecification.swift (98%) rename Sources/{RadiantKit/Documents => RadiantDocs}/InitializableFileTypeSpecification.swift (100%) rename Sources/{RadiantKit/Documents => RadiantDocs}/InitializablePackage.swift (99%) rename Sources/{RadiantKit/BushelViewsCore => RadiantDocs}/OpenFileURLAction.swift (53%) rename Sources/{RadiantKit/BushelViewsCore => RadiantDocs}/OpenWindowWithAction.swift (72%) rename Sources/{RadiantKit/BushelViewsCore => RadiantDocs}/OpenWindowWithValueAction.swift (62%) rename Sources/{RadiantKit/Documents => RadiantDocs}/UTType.swift (97%) rename Sources/RadiantKit/{Documents => BushelViewsCore}/FileType.swift (72%) delete mode 100644 Sources/RadiantKit/Documents/CodablePackageDocument.swift rename Sources/{RadiantKit/Paging => RadiantPaging}/CancelPageAction.swift (100%) rename Sources/{RadiantKit/Paging => RadiantPaging}/ContainerView.swift (100%) rename Sources/{RadiantKit/Paging => RadiantPaging}/DismissParameters.swift (98%) rename Sources/{RadiantKit/Paging => RadiantPaging}/NextPageAction.swift (100%) rename Sources/{RadiantKit/Paging => RadiantPaging}/PageNavigationAvailability.swift (100%) rename Sources/{RadiantKit/Paging => RadiantPaging}/PageView.swift (99%) rename Sources/{RadiantKit/Paging => RadiantPaging}/PreviousPageAction.swift (100%) rename Sources/{RadiantKit/BushelProgressUI => RadiantProgress}/CopyOperation.swift (100%) rename Sources/{RadiantKit/BushelProgressUI => RadiantProgress}/CopyPaths.swift (100%) rename Sources/{RadiantKit/BushelProgressUI => RadiantProgress}/DownloadOperation.swift (100%) rename Sources/{RadiantKit/BushelProgressUI => RadiantProgress}/FileOperationProgress.swift (97%) rename Sources/{RadiantKit/BushelProgressUI => RadiantProgress}/ObservableDownloader.swift (98%) rename Sources/{RadiantKit/BushelProgressUI => RadiantProgress}/PreviewOperation.swift (100%) rename Sources/{RadiantKit/BushelProgressUI => RadiantProgress}/ProgressOperation.swift (100%) rename Sources/{RadiantKit/BushelProgressUI => RadiantProgress}/ProgressOperationProperties.swift (100%) rename Sources/{RadiantKit/BushelProgressUI => RadiantProgress}/ProgressOperationView.swift (100%) rename Sources/{RadiantKit/BushelProgressUI => RadiantProgress}/SetupPublishers.swift (100%) diff --git a/Package.swift b/Package.swift index 1758fdc..40714fb 100644 --- a/Package.swift +++ b/Package.swift @@ -14,10 +14,10 @@ let swiftSettings: [SwiftSetting] = [ SwiftSetting.enableExperimentalFeature("RegionBasedIsolation"), SwiftSetting.enableExperimentalFeature("TransferringArgsAndResults"), SwiftSetting.enableExperimentalFeature("VariadicGenerics"), - + SwiftSetting.enableUpcomingFeature("FullTypedThrows"), SwiftSetting.enableUpcomingFeature("InternalImportsByDefault"), - + SwiftSetting.unsafeFlags([ "-Xfrontend", "-warn-long-function-bodies=100" @@ -35,21 +35,47 @@ let package = Package( .library( name: "RadiantKit", targets: ["RadiantKit"] + ), + .library( + name: "RadiantDocs", + targets: ["RadiantDocs"] + ), + .library( + name: "RadiantPaging", + targets: ["RadiantPaging"] + ), + .library( + name: "RadiantProgress", + targets: ["RadiantProgress"] ) ], dependencies: [ - .package(url: "https://github.com/swiftlang/swift-testing.git", from: "0.12.0"), + .package(url: "https://github.com/swiftlang/swift-testing.git", from: "0.12.0"), ], targets: [ .target( name: "RadiantKit", swiftSettings: swiftSettings ), + .target( + name: "RadiantDocs", + dependencies: ["RadiantKit"], + swiftSettings: swiftSettings + ), + .target( + name: "RadiantPaging", + dependencies: ["RadiantKit"], + swiftSettings: swiftSettings + ), + .target( + name: "RadiantProgress", + swiftSettings: swiftSettings + ), .testTarget( name: "RadiantKitTests", dependencies: [ - "RadiantKit", - .product(name: "Testing", package: "swift-testing") + "RadiantKit", + .product(name: "Testing", package: "swift-testing") ] ) ] diff --git a/Sources/RadiantKit/BushelViewsCore/AppKit/NewFilePanel.swift b/Sources/RadiantDocs/AppKit/NewFilePanel.swift similarity index 100% rename from Sources/RadiantKit/BushelViewsCore/AppKit/NewFilePanel.swift rename to Sources/RadiantDocs/AppKit/NewFilePanel.swift diff --git a/Sources/RadiantKit/BushelViewsCore/AppKit/OpenAnyFilePanel.swift b/Sources/RadiantDocs/AppKit/OpenAnyFilePanel.swift similarity index 98% rename from Sources/RadiantKit/BushelViewsCore/AppKit/OpenAnyFilePanel.swift rename to Sources/RadiantDocs/AppKit/OpenAnyFilePanel.swift index 3c4ebcd..d650f64 100644 --- a/Sources/RadiantKit/BushelViewsCore/AppKit/OpenAnyFilePanel.swift +++ b/Sources/RadiantDocs/AppKit/OpenAnyFilePanel.swift @@ -35,7 +35,7 @@ public import SwiftUI import UniformTypeIdentifiers - + public import RadiantKit public struct OpenAnyFilePanel { let fileTypes: [FileType] diff --git a/Sources/RadiantKit/BushelViewsCore/AppKit/OpenFilePanel.swift b/Sources/RadiantDocs/AppKit/OpenFilePanel.swift similarity index 100% rename from Sources/RadiantKit/BushelViewsCore/AppKit/OpenFilePanel.swift rename to Sources/RadiantDocs/AppKit/OpenFilePanel.swift diff --git a/Sources/RadiantKit/Documents/CodablePackage.swift b/Sources/RadiantDocs/CodablePackage.swift similarity index 97% rename from Sources/RadiantKit/Documents/CodablePackage.swift rename to Sources/RadiantDocs/CodablePackage.swift index 31940db..1dc90e5 100644 --- a/Sources/RadiantKit/Documents/CodablePackage.swift +++ b/Sources/RadiantDocs/CodablePackage.swift @@ -1,6 +1,6 @@ // // CodablePackage.swift -// BushelKit +// RadiantKit // // Created by Leo Dion. // Copyright © 2024 BrightDigit. @@ -28,6 +28,7 @@ // public import Foundation +public import RadiantKit public protocol CodablePackage: Sendable, Codable { static var decoder: JSONDecoder { get } diff --git a/Sources/RadiantDocs/CodablePackageDocument.swift b/Sources/RadiantDocs/CodablePackageDocument.swift new file mode 100644 index 0000000..5337c04 --- /dev/null +++ b/Sources/RadiantDocs/CodablePackageDocument.swift @@ -0,0 +1,79 @@ +// +// CodablePackageDocument.swift +// RadiantKit +// +// Created by Leo Dion. +// Copyright © 2024 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#if canImport(SwiftUI) + #if os(macOS) || os(iOS) || os(visionOS) + public import Foundation + + public import SwiftUI + + public import UniformTypeIdentifiers + + public struct CodablePackageDocument: FileDocument { + internal enum ReadError: Error { case missingConfigurationAtKey(String) } + + public static var readableContentTypes: [UTType] { T.readableContentTypes.map(UTType.init) } + + let configuration: T + + public init(configuration: T) { self.configuration = configuration } + + public init(configuration: ReadConfiguration) throws { + let regularFileContents = configuration.file.fileWrappers?[T.configurationFileWrapperKey]? + .regularFileContents + guard let configJSONWrapperData = regularFileContents else { + throw ReadError.missingConfigurationAtKey(T.configurationFileWrapperKey) + } + + let configuration = try T.decoder.decode(T.self, from: configJSONWrapperData) + self.init(configuration: configuration) + } + + public func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper { + let rootFileWrapper = + configuration.existingFile ?? FileWrapper(directoryWithFileWrappers: [:]) + + if let oldConfigJSONWrapper = rootFileWrapper.fileWrappers?[T.configurationFileWrapperKey] { + rootFileWrapper.removeFileWrapper(oldConfigJSONWrapper) + } + + let newConfigJSONData = try T.encoder.encode(self.configuration) + let newConfigJSONWrapper = FileWrapper(regularFileWithContents: newConfigJSONData) + newConfigJSONWrapper.preferredFilename = T.configurationFileWrapperKey + rootFileWrapper.addFileWrapper(newConfigJSONWrapper) + + return rootFileWrapper + } + } + + extension CodablePackageDocument where T: InitializablePackage { + public init() { self.init(configuration: .init()) } + } + #endif +#endif diff --git a/Sources/RadiantKit/Documents/DocumentFile.swift b/Sources/RadiantDocs/DocumentFile.swift similarity index 100% rename from Sources/RadiantKit/Documents/DocumentFile.swift rename to Sources/RadiantDocs/DocumentFile.swift diff --git a/Sources/RadiantKit/Documents/FileTypeSpecification.swift b/Sources/RadiantDocs/FileTypeSpecification.swift similarity index 98% rename from Sources/RadiantKit/Documents/FileTypeSpecification.swift rename to Sources/RadiantDocs/FileTypeSpecification.swift index da08d6a..a461e65 100644 --- a/Sources/RadiantKit/Documents/FileTypeSpecification.swift +++ b/Sources/RadiantDocs/FileTypeSpecification.swift @@ -28,5 +28,6 @@ // import Foundation +public import RadiantKit public protocol FileTypeSpecification: Sendable { static var fileType: FileType { get } } diff --git a/Sources/RadiantKit/Documents/InitializableFileTypeSpecification.swift b/Sources/RadiantDocs/InitializableFileTypeSpecification.swift similarity index 100% rename from Sources/RadiantKit/Documents/InitializableFileTypeSpecification.swift rename to Sources/RadiantDocs/InitializableFileTypeSpecification.swift diff --git a/Sources/RadiantKit/Documents/InitializablePackage.swift b/Sources/RadiantDocs/InitializablePackage.swift similarity index 99% rename from Sources/RadiantKit/Documents/InitializablePackage.swift rename to Sources/RadiantDocs/InitializablePackage.swift index e3982cc..75da2d9 100644 --- a/Sources/RadiantKit/Documents/InitializablePackage.swift +++ b/Sources/RadiantDocs/InitializablePackage.swift @@ -1,6 +1,6 @@ // // InitializablePackage.swift -// BushelKit +// RadiantKit // // Created by Leo Dion. // Copyright © 2024 BrightDigit. diff --git a/Sources/RadiantKit/BushelViewsCore/OpenFileURLAction.swift b/Sources/RadiantDocs/OpenFileURLAction.swift similarity index 53% rename from Sources/RadiantKit/BushelViewsCore/OpenFileURLAction.swift rename to Sources/RadiantDocs/OpenFileURLAction.swift index 05debb8..0f90f25 100644 --- a/Sources/RadiantKit/BushelViewsCore/OpenFileURLAction.swift +++ b/Sources/RadiantDocs/OpenFileURLAction.swift @@ -28,37 +28,38 @@ // #if canImport(SwiftUI) + #if os(macOS) || os(iOS) || os(visionOS) + public import Foundation - public import Foundation + public import SwiftUI - public import SwiftUI + fileprivate struct OpenFileURLKey: EnvironmentKey, Sendable { + typealias Value = OpenFileURLAction - fileprivate struct OpenFileURLKey: EnvironmentKey, Sendable { - typealias Value = OpenFileURLAction - - static let defaultValue: OpenFileURLAction = .default - } + static let defaultValue: OpenFileURLAction = .default + } - public typealias OpenWindowURLAction = OpenWindowWithValueAction + public typealias OpenWindowURLAction = OpenWindowWithValueAction - public typealias OpenFileURLAction = OpenWindowURLAction + public typealias OpenFileURLAction = OpenWindowURLAction - extension EnvironmentValues { - public var openFileURL: OpenFileURLAction { - get { self[OpenFileURLKey.self] } - set { self[OpenFileURLKey.self] = newValue } + extension EnvironmentValues { + public var openFileURL: OpenFileURLAction { + get { self[OpenFileURLKey.self] } + set { self[OpenFileURLKey.self] = newValue } + } } - } - extension Scene { - public func openFileURL( - _ closure: @escaping @Sendable @MainActor (URL, OpenWindowAction) -> Void - ) -> some Scene { self.environment(\.openFileURL, .init(closure: closure)) } - } + extension Scene { + public func openFileURL( + _ closure: @escaping @Sendable @MainActor (URL, OpenWindowAction) -> Void + ) -> some Scene { self.environment(\.openFileURL, .init(closure: closure)) } + } - @available(*, deprecated, message: "Use on Scene only.") extension View { - public func openFileURL( - _ closure: @Sendable @escaping @MainActor (URL, OpenWindowAction) -> Void - ) -> some View { self.environment(\.openFileURL, .init(closure: closure)) } - } + @available(*, deprecated, message: "Use on Scene only.") extension View { + public func openFileURL( + _ closure: @Sendable @escaping @MainActor (URL, OpenWindowAction) -> Void + ) -> some View { self.environment(\.openFileURL, .init(closure: closure)) } + } + #endif #endif diff --git a/Sources/RadiantKit/BushelViewsCore/OpenWindowWithAction.swift b/Sources/RadiantDocs/OpenWindowWithAction.swift similarity index 72% rename from Sources/RadiantKit/BushelViewsCore/OpenWindowWithAction.swift rename to Sources/RadiantDocs/OpenWindowWithAction.swift index c1f7b00..331e3c5 100644 --- a/Sources/RadiantKit/BushelViewsCore/OpenWindowWithAction.swift +++ b/Sources/RadiantDocs/OpenWindowWithAction.swift @@ -28,20 +28,21 @@ // #if canImport(SwiftUI) + #if os(macOS) || os(iOS) || os(visionOS) + import Foundation - import Foundation + public import SwiftUI - public import SwiftUI + public typealias OpenWindowWithAction = OpenWindowWithValueAction - public typealias OpenWindowWithAction = OpenWindowWithValueAction + @MainActor extension OpenWindowWithAction { + public init(closure: @escaping @Sendable @MainActor (OpenWindowAction) -> Void) { + self.init { _, action in closure(action) } + } - @MainActor extension OpenWindowWithAction { - public init(closure: @escaping @Sendable @MainActor (OpenWindowAction) -> Void) { - self.init { _, action in closure(action) } + @MainActor public func callAsFunction(with openWidow: OpenWindowAction) { + closure((), openWidow) + } } - - @MainActor public func callAsFunction(with openWidow: OpenWindowAction) { - closure((), openWidow) - } - } + #endif #endif diff --git a/Sources/RadiantKit/BushelViewsCore/OpenWindowWithValueAction.swift b/Sources/RadiantDocs/OpenWindowWithValueAction.swift similarity index 62% rename from Sources/RadiantKit/BushelViewsCore/OpenWindowWithValueAction.swift rename to Sources/RadiantDocs/OpenWindowWithValueAction.swift index 45e7ca5..32f3f6d 100644 --- a/Sources/RadiantKit/BushelViewsCore/OpenWindowWithValueAction.swift +++ b/Sources/RadiantDocs/OpenWindowWithValueAction.swift @@ -28,27 +28,28 @@ // #if canImport(SwiftUI) + #if os(macOS) || os(iOS) || os(visionOS) + import Foundation - import Foundation + public import SwiftUI - public import SwiftUI + public struct OpenWindowWithValueAction: Sendable { + public static var `default`: Self { + .init { value, action in defaultClosure(value, with: action) } + } - public struct OpenWindowWithValueAction: Sendable { - public static var `default`: Self { - .init { value, action in defaultClosure(value, with: action) } - } - - let closure: @Sendable @MainActor (ValueType, OpenWindowAction) -> Void - public init(closure: @escaping @MainActor @Sendable (ValueType, OpenWindowAction) -> Void) { - self.closure = closure - } + let closure: @Sendable @MainActor (ValueType, OpenWindowAction) -> Void + public init(closure: @escaping @MainActor @Sendable (ValueType, OpenWindowAction) -> Void) { + self.closure = closure + } - private static func defaultClosure(_: ValueType, with _: OpenWindowAction) { - assertionFailure() - } + private static func defaultClosure(_: ValueType, with _: OpenWindowAction) { + assertionFailure() + } - @MainActor public func callAsFunction(_ value: ValueType, with openWidow: OpenWindowAction) { - closure(value, openWidow) + @MainActor public func callAsFunction(_ value: ValueType, with openWidow: OpenWindowAction) { + closure(value, openWidow) + } } - } + #endif #endif diff --git a/Sources/RadiantKit/Documents/UTType.swift b/Sources/RadiantDocs/UTType.swift similarity index 97% rename from Sources/RadiantKit/Documents/UTType.swift rename to Sources/RadiantDocs/UTType.swift index a9dc988..aca3032 100644 --- a/Sources/RadiantKit/Documents/UTType.swift +++ b/Sources/RadiantDocs/UTType.swift @@ -1,6 +1,6 @@ // // UTType.swift -// BushelKit +// RadiantKit // // Created by Leo Dion. // Copyright © 2024 BrightDigit. @@ -29,14 +29,13 @@ #if canImport(UniformTypeIdentifiers) public import UniformTypeIdentifiers - + public import RadiantKit extension UTType { public init(fileType: FileType) { if fileType.isOwned { self.init(exportedAs: fileType.utIdentifier) } else { - // swiftlint:disable:next force_unwrapping self.init(fileType.utIdentifier)! } } diff --git a/Sources/RadiantKit/BushelViewsCore/AppKit/NSWindowAdaptorModifier.swift b/Sources/RadiantKit/BushelViewsCore/AppKit/NSWindowAdaptorModifier.swift index 1f13044..7a40d2b 100644 --- a/Sources/RadiantKit/BushelViewsCore/AppKit/NSWindowAdaptorModifier.swift +++ b/Sources/RadiantKit/BushelViewsCore/AppKit/NSWindowAdaptorModifier.swift @@ -35,7 +35,6 @@ import Foundation #if canImport(AppKit) import AppKit - // swiftlint:disable strict_fileprivate fileprivate struct NSWindowAdaptorHostingView: NSViewRepresentable { #warning( """ @@ -79,5 +78,5 @@ import Foundation public func nsWindowAdaptor(_: @escaping (Any?) -> Void) -> some View { self } } #endif -// swiftlint:enable strict_fileprivate + #endif diff --git a/Sources/RadiantKit/BushelViewsCore/AppKit/View+NSWindowDelegate.swift b/Sources/RadiantKit/BushelViewsCore/AppKit/View+NSWindowDelegate.swift index a81b905..9cd7b3a 100644 --- a/Sources/RadiantKit/BushelViewsCore/AppKit/View+NSWindowDelegate.swift +++ b/Sources/RadiantKit/BushelViewsCore/AppKit/View+NSWindowDelegate.swift @@ -34,7 +34,6 @@ fileprivate struct NSWindowDelegateAdaptorModifier: ViewModifier { @Binding var binding: (any NSWindowDelegate)? - // swiftlint:disable:next weak_delegate let delegate: any NSWindowDelegate init( @@ -44,7 +43,6 @@ self._binding = binding self.delegate = binding.wrappedValue ?? delegate() - // swiftlint:disable:next line_length #warning( "Issue 100 - We can't set binding here - Modifying state during view update, this will cause undefined behavior." ) diff --git a/Sources/RadiantKit/BushelViewsCore/AppStorage+ExpressibleByNilLiteral.swift b/Sources/RadiantKit/BushelViewsCore/AppStorage+ExpressibleByNilLiteral.swift index 3de8185..0c42266 100644 --- a/Sources/RadiantKit/BushelViewsCore/AppStorage+ExpressibleByNilLiteral.swift +++ b/Sources/RadiantKit/BushelViewsCore/AppStorage+ExpressibleByNilLiteral.swift @@ -35,11 +35,7 @@ extension AppStorage where Value: ExpressibleByNilLiteral { public init(for type: AppStoredType.Type, store: UserDefaults? = nil) - where - AppStoredType.Value == Value, - // swiftlint:disable:next discouraged_optional_boolean - Value == Bool? - { self.init(type.key, store: store) } + where AppStoredType.Value == Value, Value == Bool? { self.init(type.key, store: store) } public init(for type: AppStoredType.Type, store: UserDefaults? = nil) where AppStoredType.Value == Value, Value == Int? { self.init(type.key, store: store) } diff --git a/Sources/RadiantKit/Documents/FileType.swift b/Sources/RadiantKit/BushelViewsCore/FileType.swift similarity index 72% rename from Sources/RadiantKit/Documents/FileType.swift rename to Sources/RadiantKit/BushelViewsCore/FileType.swift index b55c152..491c746 100644 --- a/Sources/RadiantKit/Documents/FileType.swift +++ b/Sources/RadiantKit/BushelViewsCore/FileType.swift @@ -1,6 +1,6 @@ // // FileType.swift -// BushelKit +// RadiantKit // // Created by Leo Dion. // Copyright © 2024 BrightDigit. @@ -50,24 +50,24 @@ public struct FileType: Hashable, ExpressibleByStringLiteral, Sendable { .init(utIdentifier: utIdentifier, isOwned: true, fileExtension: fileExtension) } } - -extension FileType { - public static let ipswFileExtension = "ipsw" - public static let iTunesIPSW: FileType = "com.apple.itunes.ipsw" - public static let iPhoneIPSW: FileType = "com.apple.iphone.ipsw" - - public static let virtualMachineFileExtension = "bshvm" - public static let restoreImageLibraryFileExtension = "bshrilib" - - public static let virtualMachine: FileType = .exportedAs( - "com.brightdigit.bushel-vm", - virtualMachineFileExtension - ) - - public static let restoreImageLibrary: FileType = .exportedAs( - "com.brightdigit.bushel-rilib", - restoreImageLibraryFileExtension - ) - - public static let ipswTypes = [iTunesIPSW, iPhoneIPSW] -} +// +//extension FileType { +// public static let ipswFileExtension = "ipsw" +// public static let iTunesIPSW: FileType = "com.apple.itunes.ipsw" +// public static let iPhoneIPSW: FileType = "com.apple.iphone.ipsw" +// +// public static let virtualMachineFileExtension = "bshvm" +// public static let restoreImageLibraryFileExtension = "bshrilib" +// +// public static let virtualMachine: FileType = .exportedAs( +// "com.brightdigit.bushel-vm", +// virtualMachineFileExtension +// ) +// +// public static let restoreImageLibrary: FileType = .exportedAs( +// "com.brightdigit.bushel-rilib", +// restoreImageLibraryFileExtension +// ) +// +// public static let ipswTypes = [iTunesIPSW, iPhoneIPSW] +//} diff --git a/Sources/RadiantKit/BushelViewsCore/PreferredLayoutView.swift b/Sources/RadiantKit/BushelViewsCore/PreferredLayoutView.swift index 86ac7a8..81dd12b 100644 --- a/Sources/RadiantKit/BushelViewsCore/PreferredLayoutView.swift +++ b/Sources/RadiantKit/BushelViewsCore/PreferredLayoutView.swift @@ -35,7 +35,6 @@ public struct Value { private let value: Value? - // swiftlint:disable strict_fileprivate fileprivate let update: (Value) -> Void fileprivate init(value: Value?, update: @escaping (Value) -> Void) { @@ -43,8 +42,6 @@ self.update = update } - // swiftlint:enable strict_fileprivate - public func get() -> Value? { value } } diff --git a/Sources/RadiantKit/BushelViewsCore/SingleWindowView.swift b/Sources/RadiantKit/BushelViewsCore/SingleWindowView.swift index 2f8126f..cade4b0 100644 --- a/Sources/RadiantKit/BushelViewsCore/SingleWindowView.swift +++ b/Sources/RadiantKit/BushelViewsCore/SingleWindowView.swift @@ -46,14 +46,16 @@ extension SingleWindowView { public init(_: Binding) { self.init() } } - extension WindowGroup { - @MainActor public init(singleOf _: V.Type) - where Content == PresentedWindowContent { - self.init { value in - V(value) - } defaultValue: { - V.Value.default + #if os(macOS) || os(iOS) || os(visionOS) + extension WindowGroup { + @MainActor public init(singleOf _: V.Type) + where Content == PresentedWindowContent { + self.init { value in + V(value) + } defaultValue: { + V.Value.default + } } } - } + #endif #endif diff --git a/Sources/RadiantKit/BushelViewsCore/Video.swift b/Sources/RadiantKit/BushelViewsCore/Video.swift index adc9d5c..a2d3d3d 100644 --- a/Sources/RadiantKit/BushelViewsCore/Video.swift +++ b/Sources/RadiantKit/BushelViewsCore/Video.swift @@ -35,7 +35,6 @@ public struct Video: NSViewRepresentable { let player: AVPlayer? - // swiftlint:disable:next implicitly_unwrapped_optional public init(using player: AVPlayer!) { assert(player != nil) self.player = player diff --git a/Sources/RadiantKit/Documents/CodablePackageDocument.swift b/Sources/RadiantKit/Documents/CodablePackageDocument.swift deleted file mode 100644 index 99381a6..0000000 --- a/Sources/RadiantKit/Documents/CodablePackageDocument.swift +++ /dev/null @@ -1,54 +0,0 @@ -// -// CodablePackageDocument.swift -// Copyright (c) 2024 BrightDigit. -// - -#if canImport(SwiftUI) - - public import Foundation - - public import SwiftUI - - public import UniformTypeIdentifiers - - public struct CodablePackageDocument: FileDocument { - internal enum ReadError: Error { case missingConfigurationAtKey(String) } - - public static var readableContentTypes: [UTType] { T.readableContentTypes.map(UTType.init) } - - let configuration: T - - public init(configuration: T) { self.configuration = configuration } - - public init(configuration: ReadConfiguration) throws { - let regularFileContents = configuration.file.fileWrappers?[T.configurationFileWrapperKey]? - .regularFileContents - guard let configJSONWrapperData = regularFileContents else { - throw ReadError.missingConfigurationAtKey(T.configurationFileWrapperKey) - } - - let configuration = try T.decoder.decode(T.self, from: configJSONWrapperData) - self.init(configuration: configuration) - } - - public func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper { - let rootFileWrapper = - configuration.existingFile ?? FileWrapper(directoryWithFileWrappers: [:]) - - if let oldConfigJSONWrapper = rootFileWrapper.fileWrappers?[T.configurationFileWrapperKey] { - rootFileWrapper.removeFileWrapper(oldConfigJSONWrapper) - } - - let newConfigJSONData = try T.encoder.encode(self.configuration) - let newConfigJSONWrapper = FileWrapper(regularFileWithContents: newConfigJSONData) - newConfigJSONWrapper.preferredFilename = T.configurationFileWrapperKey - rootFileWrapper.addFileWrapper(newConfigJSONWrapper) - - return rootFileWrapper - } - } - - extension CodablePackageDocument where T: InitializablePackage { - public init() { self.init(configuration: .init()) } - } -#endif diff --git a/Sources/RadiantKit/Paging/CancelPageAction.swift b/Sources/RadiantPaging/CancelPageAction.swift similarity index 100% rename from Sources/RadiantKit/Paging/CancelPageAction.swift rename to Sources/RadiantPaging/CancelPageAction.swift diff --git a/Sources/RadiantKit/Paging/ContainerView.swift b/Sources/RadiantPaging/ContainerView.swift similarity index 100% rename from Sources/RadiantKit/Paging/ContainerView.swift rename to Sources/RadiantPaging/ContainerView.swift diff --git a/Sources/RadiantKit/Paging/DismissParameters.swift b/Sources/RadiantPaging/DismissParameters.swift similarity index 98% rename from Sources/RadiantKit/Paging/DismissParameters.swift rename to Sources/RadiantPaging/DismissParameters.swift index 6ff1f86..df9ffcc 100644 --- a/Sources/RadiantKit/Paging/DismissParameters.swift +++ b/Sources/RadiantPaging/DismissParameters.swift @@ -28,6 +28,7 @@ // import Foundation +public import RadiantKit public struct DismissParameters { #if canImport(SwiftUI) diff --git a/Sources/RadiantKit/Paging/NextPageAction.swift b/Sources/RadiantPaging/NextPageAction.swift similarity index 100% rename from Sources/RadiantKit/Paging/NextPageAction.swift rename to Sources/RadiantPaging/NextPageAction.swift diff --git a/Sources/RadiantKit/Paging/PageNavigationAvailability.swift b/Sources/RadiantPaging/PageNavigationAvailability.swift similarity index 100% rename from Sources/RadiantKit/Paging/PageNavigationAvailability.swift rename to Sources/RadiantPaging/PageNavigationAvailability.swift diff --git a/Sources/RadiantKit/Paging/PageView.swift b/Sources/RadiantPaging/PageView.swift similarity index 99% rename from Sources/RadiantKit/Paging/PageView.swift rename to Sources/RadiantPaging/PageView.swift index 28956d1..1d986be 100644 --- a/Sources/RadiantKit/Paging/PageView.swift +++ b/Sources/RadiantPaging/PageView.swift @@ -29,6 +29,7 @@ #if canImport(SwiftUI) public import SwiftUI + public import RadiantKit @MainActor public struct PageView: View, Sendable { @Environment(\.dismiss) private var dismiss diff --git a/Sources/RadiantKit/Paging/PreviousPageAction.swift b/Sources/RadiantPaging/PreviousPageAction.swift similarity index 100% rename from Sources/RadiantKit/Paging/PreviousPageAction.swift rename to Sources/RadiantPaging/PreviousPageAction.swift diff --git a/Sources/RadiantKit/BushelProgressUI/CopyOperation.swift b/Sources/RadiantProgress/CopyOperation.swift similarity index 100% rename from Sources/RadiantKit/BushelProgressUI/CopyOperation.swift rename to Sources/RadiantProgress/CopyOperation.swift diff --git a/Sources/RadiantKit/BushelProgressUI/CopyPaths.swift b/Sources/RadiantProgress/CopyPaths.swift similarity index 100% rename from Sources/RadiantKit/BushelProgressUI/CopyPaths.swift rename to Sources/RadiantProgress/CopyPaths.swift diff --git a/Sources/RadiantKit/BushelProgressUI/DownloadOperation.swift b/Sources/RadiantProgress/DownloadOperation.swift similarity index 100% rename from Sources/RadiantKit/BushelProgressUI/DownloadOperation.swift rename to Sources/RadiantProgress/DownloadOperation.swift diff --git a/Sources/RadiantKit/BushelProgressUI/FileOperationProgress.swift b/Sources/RadiantProgress/FileOperationProgress.swift similarity index 97% rename from Sources/RadiantKit/BushelProgressUI/FileOperationProgress.swift rename to Sources/RadiantProgress/FileOperationProgress.swift index 3303c95..bdb1728 100644 --- a/Sources/RadiantKit/BushelProgressUI/FileOperationProgress.swift +++ b/Sources/RadiantProgress/FileOperationProgress.swift @@ -27,7 +27,7 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#if canImport(Observation) && (os(macOS) || os(iOS)) +#if canImport(Observation) public import Foundation import Observation diff --git a/Sources/RadiantKit/BushelProgressUI/ObservableDownloader.swift b/Sources/RadiantProgress/ObservableDownloader.swift similarity index 98% rename from Sources/RadiantKit/BushelProgressUI/ObservableDownloader.swift rename to Sources/RadiantProgress/ObservableDownloader.swift index 51548cf..771d355 100644 --- a/Sources/RadiantKit/BushelProgressUI/ObservableDownloader.swift +++ b/Sources/RadiantProgress/ObservableDownloader.swift @@ -27,7 +27,7 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#if canImport(Combine) && canImport(Observation) && (os(macOS) || os(iOS)) +#if canImport(Combine) && canImport(Observation) public import Combine public import Foundation @@ -115,7 +115,6 @@ public internal(set) var totalBytesWritten: Int64 = 0 public internal(set) var totalBytesExpectedToWrite: Int64? - // swiftlint:disable:next implicitly_unwrapped_optional internal private(set) var session: URLSession! internal let resumeDataSubject = PassthroughSubject() diff --git a/Sources/RadiantKit/BushelProgressUI/PreviewOperation.swift b/Sources/RadiantProgress/PreviewOperation.swift similarity index 100% rename from Sources/RadiantKit/BushelProgressUI/PreviewOperation.swift rename to Sources/RadiantProgress/PreviewOperation.swift diff --git a/Sources/RadiantKit/BushelProgressUI/ProgressOperation.swift b/Sources/RadiantProgress/ProgressOperation.swift similarity index 100% rename from Sources/RadiantKit/BushelProgressUI/ProgressOperation.swift rename to Sources/RadiantProgress/ProgressOperation.swift diff --git a/Sources/RadiantKit/BushelProgressUI/ProgressOperationProperties.swift b/Sources/RadiantProgress/ProgressOperationProperties.swift similarity index 100% rename from Sources/RadiantKit/BushelProgressUI/ProgressOperationProperties.swift rename to Sources/RadiantProgress/ProgressOperationProperties.swift diff --git a/Sources/RadiantKit/BushelProgressUI/ProgressOperationView.swift b/Sources/RadiantProgress/ProgressOperationView.swift similarity index 100% rename from Sources/RadiantKit/BushelProgressUI/ProgressOperationView.swift rename to Sources/RadiantProgress/ProgressOperationView.swift diff --git a/Sources/RadiantKit/BushelProgressUI/SetupPublishers.swift b/Sources/RadiantProgress/SetupPublishers.swift similarity index 100% rename from Sources/RadiantKit/BushelProgressUI/SetupPublishers.swift rename to Sources/RadiantProgress/SetupPublishers.swift