From 4fd16aadc9dbfb1248ab11413787aa5981b41f51 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Mon, 17 Nov 2025 21:20:48 -0800 Subject: [PATCH] Convert from default MainActor isolation to unspecified default isolation. --- Modules/Account/Package.swift | 1 - Modules/Account/Sources/Account/Account.swift | 2 +- .../Sources/Account/AccountDelegate.swift | 46 ++-- .../Sources/Account/AccountManager.swift | 2 +- .../Sources/Account/ArticleFetcher.swift | 14 +- .../CloudKit/CloudKitAccountDelegate.swift | 2 +- .../CloudKitRemoteNotificationOperation.swift | 6 +- .../Sources/Account/ContainerIdentifier.swift | 4 +- Modules/Account/Sources/Account/Feed.swift | 2 +- .../Sources/Account/FeedMetadata.swift | 17 +- .../Sources/Account/Feedbin/FeedbinDate.swift | 4 +- .../Account/Feedly/FeedlyAPICaller.swift | 4 +- Modules/Account/Sources/Account/Folder.swift | 6 +- .../Account/Sources/Account/OPMLFile.swift | 11 +- .../Account/ReaderAPI/ReaderAPICaller.swift | 3 +- .../Sources/Account/UnreadCountProvider.swift | 10 +- Modules/Articles/Package.swift | 1 - .../Articles/Sources/Articles/Article.swift | 8 +- .../Sources/Articles/ArticleStatus.swift | 4 +- .../Articles/Sources/Articles/Author.swift | 3 +- .../Sources/Articles/DatabaseID.swift | 28 +-- Modules/ArticlesDatabase/Package.swift | 1 - .../ArticlesDatabase/ArticlesDatabase.swift | 10 +- .../ArticlesDatabase/ArticlesTable.swift | 4 +- .../ArticlesDatabase/AuthorsTable.swift | 3 +- .../Sources/ArticlesDatabase/Constants.swift | 9 +- .../Extensions/Article+Database.swift | 6 +- .../Extensions/ArticleStatus+Database.swift | 4 +- .../Extensions/Author+Database.swift | 4 +- .../Extensions/DatabaseObject+Database.swift | 2 +- .../Extensions/ParsedArticle+Database.swift | 2 +- .../RelatedObjectsMap+Database.swift | 2 +- .../FetchAllUnreadCountsOperation.swift | 6 +- .../ArticlesDatabase/SearchTable.swift | 7 +- .../ArticlesDatabase/StatusesTable.swift | 9 +- Modules/FeedFinder/Package.swift | 1 - .../Sources/FeedFinder/FeedFinder.swift | 5 +- .../Sources/FeedFinder/FeedSpecifier.swift | 5 +- .../Sources/FeedFinder/HTMLFeedFinder.swift | 6 +- Modules/RSCore/Package.swift | 2 - .../Sources/RSCore/AppKit/FourCharCode.swift | 2 - .../Sources/RSCore/AppKit/Keyboard.swift | 15 +- .../AppKit/KeyboardDelegateProtocol.swift | 6 +- .../RSCore/AppKit/NSAppearance+RSCore.swift | 2 +- .../NSAppleEventDescriptor+RSCore.swift | 1 - .../RSCore/AppKit/NSImage+RSCore.swift | 2 +- .../RSCore/AppKit/NSMenu+Extensions.swift | 2 +- .../RSCore/AppKit/NSOutlineView+RSCore.swift | 2 +- .../RSCore/AppKit/NSPasteboard+RSCore.swift | 4 - .../AppKit/NSResponder-Extensions.swift | 2 +- .../RSCore/AppKit/NSTableView+RSCore.swift | 8 +- .../RSCore/AppKit/NSToolbar+RSCore.swift | 1 + .../Sources/RSCore/AppKit/NSView+RSCore.swift | 2 +- .../RSCore/AppKit/NSWindow-Extensions.swift | 7 +- .../AppKit/NSWindowController+RSCore.swift | 4 +- .../RSCore/AppKit/PasteboardWriterOwner.swift | 2 +- .../RSCore/AppKit/RSAppMovementMonitor.swift | 3 +- .../Sources/RSCore/AppKit/RSToolbarItem.swift | 4 +- .../RSCore/AppKit/URLPasteboardWriter.swift | 1 - .../Sources/RSCore/AppKit/UserApp.swift | 8 +- .../Sources/RSCore/Shared/AppConfig.swift | 2 +- .../Sources/RSCore/Shared/Array+RSCore.swift | 2 +- .../Sources/RSCore/Shared/BatchUpdate.swift | 4 +- .../RSCore/Sources/RSCore/Shared/Cache.swift | 7 +- .../RSCore/Shared/Calendar+RSCore.swift | 1 - .../RSCore/Shared/CoalescingQueue.swift | 7 +- .../Sources/RSCore/Shared/Data+RSCore.swift | 4 +- .../RSCore/Shared/Date+Extensions.swift | 3 +- .../RSCore/Shared/DisplayNameProvider.swift | 5 +- .../RSCore/Shared/FileManager+RSCore.swift | 3 +- .../Sources/RSCore/Shared/Geometry.swift | 3 +- .../RSCore/Shared/MacroProcessor.swift | 5 +- .../Shared/MainThreadBlockOperation.swift | 4 +- .../RSCore/Shared/MainThreadOperation.swift | 45 ++-- .../Shared/MainThreadOperationQueue.swift | 4 +- .../Shared/NotificationCenter+RSCore.swift | 4 +- .../RSCore/Shared/OPMLRepresentable.swift | 6 +- .../Sources/RSCore/Shared/RSImage.swift | 6 +- .../Sources/RSCore/Shared/RSScreen.swift | 2 +- .../Sources/RSCore/Shared/Renamable.swift | 6 +- .../RSCore/Shared/SendToBlogEditorApp.swift | 15 +- .../Sources/RSCore/Shared/SendToCommand.swift | 3 +- .../Sources/RSCore/Shared/String+RSCore.swift | 5 +- .../RSCore/Shared/UndoableCommand.swift | 27 +-- .../UIKit/UIViewController+RSCore.swift | 5 +- .../RSCore/UIKit/UIWindow+RSCore.swift | 4 +- ...ndeterminateProgressWindowController.swift | 17 +- .../AppKit/WebViewWindowController.swift | 3 - Modules/RSDatabase/Package.swift | 1 - .../Sources/RSDatabase/Database.swift | 4 +- .../Sources/RSDatabase/DatabaseObject.swift | 6 +- .../RSDatabase/DatabaseObjectCache.swift | 2 +- .../Sources/RSDatabase/DatabaseQueue.swift | 4 +- .../Sources/RSDatabase/DatabaseTable.swift | 4 +- .../RSDatabase/FMDatabase+Extras.swift | 2 +- .../RSDatabase/FMResultSet+Extras.swift | 2 +- .../Related Objects/DatabaseLookupTable.swift | 4 +- .../DatabaseRelatedObjectsTable.swift | 4 +- .../Related Objects/RelatedObjectIDsMap.swift | 5 +- .../Related Objects/RelatedObjectsMap.swift | 2 +- .../Sources/RSDatabaseObjC/RSDatabaseQueue.h | 63 ----- .../Sources/RSDatabaseObjC/RSDatabaseQueue.m | 227 ------------------ .../RSDatabaseObjC/include/RSDatabaseObjC.h | 4 - Modules/RSMarkdown/Package.swift | 1 - .../Sources/RSMarkdown/RSMarkdown.swift | 3 +- Modules/RSParser/Package.swift | 8 +- .../Sources/Swift/Feeds/FeedParser.swift | 2 +- .../Sources/Swift/Feeds/FeedType.swift | 6 +- .../Swift/Feeds/JSON/JSONFeedParser.swift | 4 +- .../Swift/Feeds/JSON/RSSInJSONParser.swift | 4 +- .../Swift/Feeds/ParsedAttachment.swift | 2 +- .../Sources/Swift/Feeds/ParsedAuthor.swift | 2 +- .../Sources/Swift/Feeds/ParsedFeed.swift | 2 +- .../Sources/Swift/Feeds/ParsedHub.swift | 2 +- .../Sources/Swift/Feeds/ParsedItem.swift | 4 +- .../Sources/Swift/Feeds/XML/AtomParser.swift | 2 +- .../Feeds/XML/RSParsedFeedTransformer.swift | 4 +- .../Sources/Swift/Feeds/XML/RSSParser.swift | 2 +- .../Sources/Swift/JSON/JSONUtilities.swift | 5 +- .../Swift/Utilities/String+RSParser.swift | 2 +- Modules/RSTree/Package.swift | 1 - Modules/RSTree/Sources/RSTree/Node.swift | 20 +- Modules/RSTree/Sources/RSTree/NodePath.swift | 3 +- .../Sources/RSTree/TreeController.swift | 12 +- Modules/RSWeb/Package.swift | 1 - .../RSWeb/Sources/RSWeb/DownloadSession.swift | 4 +- Modules/RSWeb/Sources/RSWeb/Downloader.swift | 3 +- .../RSWeb/Sources/RSWeb/MacWebBrowser.swift | 2 +- .../Sources/RSWeb/WebServices/Transport.swift | 2 +- Modules/Secrets/Package.swift | 1 - .../Sources/Secrets/CredentialsManager.swift | 2 +- .../Sources/Secrets/SecretKey.swift.gyb | 2 +- Modules/SyncDatabase/Package.swift | 1 - .../Sources/SyncDatabase/Constants.swift | 2 +- .../Sources/SyncDatabase/SyncStatus.swift | 2 +- .../SyncDatabase/SyncStatusTable.swift | 4 +- 136 files changed, 261 insertions(+), 736 deletions(-) delete mode 100755 Modules/RSDatabase/Sources/RSDatabaseObjC/RSDatabaseQueue.h delete mode 100755 Modules/RSDatabase/Sources/RSDatabaseObjC/RSDatabaseQueue.m diff --git a/Modules/Account/Package.swift b/Modules/Account/Package.swift index 7ca220931..358cf7942 100644 --- a/Modules/Account/Package.swift +++ b/Modules/Account/Package.swift @@ -40,7 +40,6 @@ let package = Package( swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), .enableUpcomingFeature("InferIsolatedConformances"), - .defaultIsolation(MainActor.self) ] ), .testTarget( diff --git a/Modules/Account/Sources/Account/Account.swift b/Modules/Account/Sources/Account/Account.swift index 3226c6b5d..9fdd81366 100644 --- a/Modules/Account/Sources/Account/Account.swift +++ b/Modules/Account/Sources/Account/Account.swift @@ -60,7 +60,7 @@ public enum FetchType { case searchWithArticleIDs(String, Set) } -public final class Account: DisplayNameProvider, UnreadCountProvider, Container, Hashable { +@MainActor public final class Account: DisplayNameProvider, UnreadCountProvider, Container, Hashable { public struct UserInfoKey { public static let account = "account" // UserDidAddAccount, UserDidDeleteAccount public static let newArticles = "newArticles" // AccountDidDownloadArticles diff --git a/Modules/Account/Sources/Account/AccountDelegate.swift b/Modules/Account/Sources/Account/AccountDelegate.swift index b1de207d9..e362d81c7 100644 --- a/Modules/Account/Sources/Account/AccountDelegate.swift +++ b/Modules/Account/Sources/Account/AccountDelegate.swift @@ -23,43 +23,43 @@ import Secrets var refreshProgress: DownloadProgress { get } - @MainActor func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable : Any]) async + func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable : Any]) async - @MainActor func refreshAll(for account: Account) async throws - @MainActor func syncArticleStatus(for account: Account) async throws - @MainActor func sendArticleStatus(for account: Account) async throws - @MainActor func refreshArticleStatus(for account: Account) async throws + func refreshAll(for account: Account) async throws + func syncArticleStatus(for account: Account) async throws + func sendArticleStatus(for account: Account) async throws + func refreshArticleStatus(for account: Account) async throws - @MainActor func importOPML(for account: Account, opmlFile: URL) async throws + func importOPML(for account: Account, opmlFile: URL) async throws - @MainActor func createFolder(for account: Account, name: String) async throws -> Folder - @MainActor func renameFolder(for account: Account, with folder: Folder, to name: String) async throws - @MainActor func removeFolder(for account: Account, with folder: Folder) async throws + func createFolder(for account: Account, name: String) async throws -> Folder + func renameFolder(for account: Account, with folder: Folder, to name: String) async throws + func removeFolder(for account: Account, with folder: Folder) async throws - @MainActor func createFeed(for account: Account, url: String, name: String?, container: Container, validateFeed: Bool) async throws -> Feed - @MainActor func renameFeed(for account: Account, with feed: Feed, to name: String) async throws - @MainActor func addFeed(account: Account, feed: Feed, container: Container) async throws - @MainActor func removeFeed(account: Account, feed: Feed, container: Container) async throws - @MainActor func moveFeed(account: Account, feed: Feed, sourceContainer: Container, destinationContainer: Container) async throws + func createFeed(for account: Account, url: String, name: String?, container: Container, validateFeed: Bool) async throws -> Feed + func renameFeed(for account: Account, with feed: Feed, to name: String) async throws + func addFeed(account: Account, feed: Feed, container: Container) async throws + func removeFeed(account: Account, feed: Feed, container: Container) async throws + func moveFeed(account: Account, feed: Feed, sourceContainer: Container, destinationContainer: Container) async throws - @MainActor func restoreFeed(for account: Account, feed: Feed, container: Container) async throws - @MainActor func restoreFolder(for account: Account, folder: Folder) async throws + func restoreFeed(for account: Account, feed: Feed, container: Container) async throws + func restoreFolder(for account: Account, folder: Folder) async throws - @MainActor func markArticles(for account: Account, articles: Set
, statusKey: ArticleStatus.Key, flag: Bool) async throws + func markArticles(for account: Account, articles: Set
, statusKey: ArticleStatus.Key, flag: Bool) async throws // Called at the end of account’s init method. - @MainActor func accountDidInitialize(_ account: Account) + func accountDidInitialize(_ account: Account) - @MainActor func accountWillBeDeleted(_ account: Account) + func accountWillBeDeleted(_ account: Account) - @MainActor static func validateCredentials(transport: Transport, credentials: Credentials, endpoint: URL?) async throws -> Credentials? + static func validateCredentials(transport: Transport, credentials: Credentials, endpoint: URL?) async throws -> Credentials? /// Suspend all network activity - @MainActor func suspendNetwork() + func suspendNetwork() /// Suspend the SQLite databases - @MainActor func suspendDatabase() + func suspendDatabase() /// Make sure no SQLite databases are open and we are ready to issue network requests. - @MainActor func resume() + func resume() } diff --git a/Modules/Account/Sources/Account/AccountManager.swift b/Modules/Account/Sources/Account/AccountManager.swift index e54210982..d3b962333 100644 --- a/Modules/Account/Sources/Account/AccountManager.swift +++ b/Modules/Account/Sources/Account/AccountManager.swift @@ -17,7 +17,7 @@ import RSDatabase // Main thread only. @MainActor public final class AccountManager: UnreadCountProvider { - @MainActor public static var shared = AccountManager() + public static var shared = AccountManager() public static let netNewsWireNewsURL = "https://netnewswire.blog/feed.xml" private static let jsonNetNewsWireNewsURL = "https://netnewswire.blog/feed.json" diff --git a/Modules/Account/Sources/Account/ArticleFetcher.swift b/Modules/Account/Sources/Account/ArticleFetcher.swift index 0511dbd9e..cc5274cfa 100644 --- a/Modules/Account/Sources/Account/ArticleFetcher.swift +++ b/Modules/Account/Sources/Account/ArticleFetcher.swift @@ -10,14 +10,14 @@ import Foundation import Articles import ArticlesDatabase -public protocol ArticleFetcher { - @MainActor func fetchArticles() throws -> Set
- @MainActor func fetchArticlesAsync() async throws -> Set
- @MainActor func fetchUnreadArticles() throws -> Set
- @MainActor func fetchUnreadArticlesAsync() async throws -> Set
+@MainActor public protocol ArticleFetcher { + func fetchArticles() throws -> Set
+ func fetchArticlesAsync() async throws -> Set
+ func fetchUnreadArticles() throws -> Set
+ func fetchUnreadArticlesAsync() async throws -> Set
} -@MainActor extension Feed: ArticleFetcher { +extension Feed: ArticleFetcher { public func fetchArticles() throws -> Set
{ return try account?.fetchArticles(.feed(self)) ?? Set
() @@ -46,7 +46,7 @@ public protocol ArticleFetcher { } } -@MainActor extension Folder: ArticleFetcher { +extension Folder: ArticleFetcher { public func fetchArticles() throws -> Set
{ guard let account else { diff --git a/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift b/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift index 45e5dd705..55f57c994 100644 --- a/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift +++ b/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift @@ -20,7 +20,7 @@ import Secrets import CloudKitSync import FeedFinder -enum CloudKitAccountDelegateError: LocalizedError { +enum CloudKitAccountDelegateError: LocalizedError, Sendable { case invalidParameter case unknown diff --git a/Modules/Account/Sources/Account/CloudKit/CloudKitRemoteNotificationOperation.swift b/Modules/Account/Sources/Account/CloudKit/CloudKitRemoteNotificationOperation.swift index 49102ccc0..0c753fb50 100644 --- a/Modules/Account/Sources/Account/CloudKit/CloudKitRemoteNotificationOperation.swift +++ b/Modules/Account/Sources/Account/CloudKit/CloudKitRemoteNotificationOperation.swift @@ -11,10 +11,10 @@ import os.log import RSCore import CloudKitSync -final class CloudKitRemoteNotificationOperation: MainThreadOperation, @unchecked Sendable { +@MainActor final class CloudKitRemoteNotificationOperation: MainThreadOperation, @unchecked Sendable { private weak var accountZone: CloudKitAccountZone? private weak var articlesZone: CloudKitArticlesZone? - private var userInfo: [AnyHashable : Any] + nonisolated(unsafe) private var userInfo: [AnyHashable : Any] private static let logger = cloudKitLogger init(accountZone: CloudKitAccountZone, articlesZone: CloudKitArticlesZone, userInfo: [AnyHashable : Any]) { @@ -24,7 +24,7 @@ final class CloudKitRemoteNotificationOperation: MainThreadOperation, @unchecked super.init(name: "CloudKitRemoteNotificationOperation") } - @MainActor override func run() { + override func run() { guard let accountZone, let articlesZone else { didComplete() return diff --git a/Modules/Account/Sources/Account/ContainerIdentifier.swift b/Modules/Account/Sources/Account/ContainerIdentifier.swift index 9a73fb16f..1c5abab36 100644 --- a/Modules/Account/Sources/Account/ContainerIdentifier.swift +++ b/Modules/Account/Sources/Account/ContainerIdentifier.swift @@ -8,11 +8,11 @@ import Foundation -public protocol ContainerIdentifiable { +@MainActor public protocol ContainerIdentifiable { var containerID: ContainerIdentifier? { get } } -public enum ContainerIdentifier: Hashable, Equatable { +public enum ContainerIdentifier: Hashable, Equatable, Sendable { case smartFeedController case account(String) // accountID case folder(String, String) // accountID, folderName diff --git a/Modules/Account/Sources/Account/Feed.swift b/Modules/Account/Sources/Account/Feed.swift index 5f07bba16..62422eb07 100644 --- a/Modules/Account/Sources/Account/Feed.swift +++ b/Modules/Account/Sources/Account/Feed.swift @@ -11,7 +11,7 @@ import RSCore import RSWeb import Articles -public final class Feed: SidebarItem, Renamable, Hashable { +@MainActor public final class Feed: SidebarItem, Renamable, Hashable { public let feedID: String public let accountID: String public let url: String diff --git a/Modules/Account/Sources/Account/FeedMetadata.swift b/Modules/Account/Sources/Account/FeedMetadata.swift index 76c3bd383..ed9e6d3e2 100644 --- a/Modules/Account/Sources/Account/FeedMetadata.swift +++ b/Modules/Account/Sources/Account/FeedMetadata.swift @@ -10,12 +10,11 @@ import Foundation import RSWeb import Articles -protocol FeedMetadataDelegate: AnyObject { - @MainActor func valueDidChange(_ feedMetadata: FeedMetadata, key: FeedMetadata.CodingKeys) +@MainActor protocol FeedMetadataDelegate: AnyObject { + func valueDidChange(_ feedMetadata: FeedMetadata, key: FeedMetadata.CodingKeys) } -final class FeedMetadata: Codable { - +@MainActor final class FeedMetadata: Codable { enum CodingKeys: String, CodingKey { case feedID case homePageURL @@ -169,14 +168,6 @@ final class FeedMetadata: Codable { } func valueDidChange(_ key: CodingKeys) { - if Thread.isMainThread { - MainActor.assumeIsolated { - delegate?.valueDidChange(self, key: key) - } - } else { - Task { @MainActor in - delegate?.valueDidChange(self, key: key) - } - } + delegate?.valueDidChange(self, key: key) } } diff --git a/Modules/Account/Sources/Account/Feedbin/FeedbinDate.swift b/Modules/Account/Sources/Account/Feedbin/FeedbinDate.swift index 08051fa2d..9f2221b02 100644 --- a/Modules/Account/Sources/Account/Feedbin/FeedbinDate.swift +++ b/Modules/Account/Sources/Account/Feedbin/FeedbinDate.swift @@ -9,13 +9,11 @@ import Foundation struct FeedbinDate { - - public static var formatter: DateFormatter = { + public static let formatter: DateFormatter = { let formatter = DateFormatter() formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'" formatter.locale = Locale(identifier: "en_US") formatter.timeZone = TimeZone(abbreviation: "GMT") return formatter }() - } diff --git a/Modules/Account/Sources/Account/Feedly/FeedlyAPICaller.swift b/Modules/Account/Sources/Account/Feedly/FeedlyAPICaller.swift index 21f58a6f5..beb11b21e 100644 --- a/Modules/Account/Sources/Account/Feedly/FeedlyAPICaller.swift +++ b/Modules/Account/Sources/Account/Feedly/FeedlyAPICaller.swift @@ -17,9 +17,9 @@ protocol FeedlyAPICallerDelegate: AnyObject { @MainActor func reauthorizeFeedlyAPICaller(_ caller: FeedlyAPICaller, completionHandler: @escaping (Bool) -> ()) } -nonisolated final class FeedlyAPICaller: @unchecked Sendable { +@MainActor final class FeedlyAPICaller { - nonisolated enum API: Sendable { + enum API: Sendable { case sandbox case cloud diff --git a/Modules/Account/Sources/Account/Folder.swift b/Modules/Account/Sources/Account/Folder.swift index a38fd3f9d..3d6a4a181 100644 --- a/Modules/Account/Sources/Account/Folder.swift +++ b/Modules/Account/Sources/Account/Folder.swift @@ -18,18 +18,18 @@ public final class Folder: SidebarItem, Renamable, Container, Hashable { return .read } - @MainActor public var containerID: ContainerIdentifier? { + public var containerID: ContainerIdentifier? { ContainerIdentifier.folder(accountID, nameForDisplay) } - @MainActor public var sidebarItemID: SidebarItemIdentifier? { + public var sidebarItemID: SidebarItemIdentifier? { SidebarItemIdentifier.folder(accountID, nameForDisplay) } public var topLevelFeeds: Set = Set() public var folders: Set? = nil // subfolders are not supported, so this is always nil - @MainActor public var name: String? { + public var name: String? { didSet { postDisplayNameDidChangeNotification() } diff --git a/Modules/Account/Sources/Account/OPMLFile.swift b/Modules/Account/Sources/Account/OPMLFile.swift index 20e967a83..7a3b5cacf 100644 --- a/Modules/Account/Sources/Account/OPMLFile.swift +++ b/Modules/Account/Sources/Account/OPMLFile.swift @@ -11,7 +11,7 @@ import os.log import RSCore import RSParser -final class OPMLFile { +@MainActor final class OPMLFile { private let fileURL: URL private let account: Account @@ -32,7 +32,7 @@ final class OPMLFile { isDirty = true } - @MainActor func load() { + func load() { guard let fileData = opmlFileData(), let opmlItems = parsedOPMLItems(fileData: fileData) else { return } @@ -42,7 +42,7 @@ final class OPMLFile { } } - @MainActor func save() { + func save() { guard !account.isDeleted else { return } let opmlDocumentString = opmlDocument() @@ -52,7 +52,6 @@ final class OPMLFile { Self.logger.error("OPML save to disk failed: \(error.localizedDescription)") } } - } private extension OPMLFile { @@ -69,7 +68,7 @@ private extension OPMLFile { } } - @MainActor @objc func saveToDiskIfNeeded() { + @objc func saveToDiskIfNeeded() { if isDirty { isDirty = false save() @@ -102,7 +101,7 @@ private extension OPMLFile { return opmlDocument?.children } - @MainActor func opmlDocument() -> String { + func opmlDocument() -> String { let escapedTitle = account.nameForDisplay.escapingSpecialXMLCharacters let openingText = """ diff --git a/Modules/Account/Sources/Account/ReaderAPI/ReaderAPICaller.swift b/Modules/Account/Sources/Account/ReaderAPI/ReaderAPICaller.swift index 7274c2bcd..443770d8a 100644 --- a/Modules/Account/Sources/Account/ReaderAPI/ReaderAPICaller.swift +++ b/Modules/Account/Sources/Account/ReaderAPI/ReaderAPICaller.swift @@ -15,8 +15,7 @@ enum CreateReaderAPISubscriptionResult { case notFound } -final class ReaderAPICaller { - +@MainActor final class ReaderAPICaller { enum ItemIDType { case unread case starred diff --git a/Modules/Account/Sources/Account/UnreadCountProvider.swift b/Modules/Account/Sources/Account/UnreadCountProvider.swift index e549f9ef5..f3e9ab4fb 100644 --- a/Modules/Account/Sources/Account/UnreadCountProvider.swift +++ b/Modules/Account/Sources/Account/UnreadCountProvider.swift @@ -13,15 +13,15 @@ public extension Notification.Name { static let UnreadCountDidChange = Notification.Name(rawValue: "UnreadCountDidChange") } -public protocol UnreadCountProvider { - @MainActor var unreadCount: Int { get } +@MainActor public protocol UnreadCountProvider { + var unreadCount: Int { get } - @MainActor func postUnreadCountDidChangeNotification() - @MainActor func calculateUnreadCount(_ children: T) -> Int + func postUnreadCountDidChangeNotification() + func calculateUnreadCount(_ children: T) -> Int } -@MainActor public extension UnreadCountProvider { +public extension UnreadCountProvider { func postUnreadCountDidInitializeNotification() { NotificationCenter.default.post(name: .UnreadCountDidInitialize, object: self, userInfo: nil) diff --git a/Modules/Articles/Package.swift b/Modules/Articles/Package.swift index a4c2c170d..1f271b649 100644 --- a/Modules/Articles/Package.swift +++ b/Modules/Articles/Package.swift @@ -22,7 +22,6 @@ let package = Package( swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), .enableUpcomingFeature("InferIsolatedConformances"), - .defaultIsolation(MainActor.self) ]), ] ) diff --git a/Modules/Articles/Sources/Articles/Article.swift b/Modules/Articles/Sources/Articles/Article.swift index db09dbba5..7dd9ae3ae 100644 --- a/Modules/Articles/Sources/Articles/Article.swift +++ b/Modules/Articles/Sources/Articles/Article.swift @@ -10,7 +10,7 @@ import Foundation public typealias ArticleSetBlock = (Set
) -> Void -nonisolated public final class Article: Hashable, Sendable { +public final class Article: Hashable, Sendable { public let articleID: String // Unique database ID (possibly sync service ID) public let accountID: String public let feedID: String // Likely a URL, but not necessarily @@ -70,7 +70,7 @@ nonisolated public final class Article: Hashable, Sendable { } } -nonisolated public extension Set where Element == Article { +public extension Set where Element == Article { func articleIDs() -> Set { return Set(map { $0.articleID }) @@ -86,14 +86,14 @@ nonisolated public extension Set where Element == Article { } } -nonisolated public extension Array where Element == Article { +public extension Array where Element == Article { func articleIDs() -> [String] { return map { $0.articleID } } } -nonisolated public extension Article { +public extension Article { private static let allowedTags: Set = ["b", "bdi", "bdo", "cite", "code", "del", "dfn", "em", "i", "ins", "kbd", "mark", "q", "s", "samp", "small", "strong", "sub", "sup", "time", "u", "var"] func sanitizedTitle(forHTML: Bool = true) -> String? { diff --git a/Modules/Articles/Sources/Articles/ArticleStatus.swift b/Modules/Articles/Sources/Articles/ArticleStatus.swift index 0db537368..2b420c417 100644 --- a/Modules/Articles/Sources/Articles/ArticleStatus.swift +++ b/Modules/Articles/Sources/Articles/ArticleStatus.swift @@ -9,8 +9,8 @@ import Foundation import Synchronization -nonisolated public final class ArticleStatus: Hashable, Sendable { - nonisolated public enum Key: String, Sendable { +public final class ArticleStatus: Hashable, Sendable { + public enum Key: String, Sendable { case read case starred } diff --git a/Modules/Articles/Sources/Articles/Author.swift b/Modules/Articles/Sources/Articles/Author.swift index 5aa5deb96..7736f3f56 100644 --- a/Modules/Articles/Sources/Articles/Author.swift +++ b/Modules/Articles/Sources/Articles/Author.swift @@ -8,8 +8,7 @@ import Foundation -nonisolated public struct Author: Codable, Hashable, Sendable { - +public struct Author: Codable, Hashable, Sendable { public let authorID: String // calculated public let name: String? public let url: String? diff --git a/Modules/Articles/Sources/Articles/DatabaseID.swift b/Modules/Articles/Sources/Articles/DatabaseID.swift index fb3eb3e09..a0ba58d82 100644 --- a/Modules/Articles/Sources/Articles/DatabaseID.swift +++ b/Modules/Articles/Sources/Articles/DatabaseID.swift @@ -8,25 +8,21 @@ import Foundation import RSCore +import Synchronization -// MD5 works because: -// * It’s fast -// * Collisions aren’t going to happen with feed data +private let databaseIDCache = Mutex([String: String]()) -nonisolated(unsafe) private var databaseIDCache = [String: String]() -nonisolated private let databaseIDCacheLock = NSLock() +public func databaseIDWithString(_ s: String) -> String { + databaseIDCache.withLock { cache in + if let identifier = cache[s] { + return identifier + } -nonisolated public func databaseIDWithString(_ s: String) -> String { - databaseIDCacheLock.lock() - defer { - databaseIDCacheLock.unlock() - } - - if let identifier = databaseIDCache[s] { + // MD5 works because: + // * It’s fast + // * Collisions aren’t going to happen with feed data + let identifier = s.md5String + cache[s] = identifier return identifier } - - let identifier = s.md5String - databaseIDCache[s] = identifier - return identifier } diff --git a/Modules/ArticlesDatabase/Package.swift b/Modules/ArticlesDatabase/Package.swift index fde57677d..c7f451c39 100644 --- a/Modules/ArticlesDatabase/Package.swift +++ b/Modules/ArticlesDatabase/Package.swift @@ -28,7 +28,6 @@ let package = Package( swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), .enableUpcomingFeature("InferIsolatedConformances"), - .defaultIsolation(MainActor.self) ] ), ] diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift index 1d6c4a6a4..388058ca4 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift @@ -18,7 +18,7 @@ import Articles public typealias UnreadCountDictionary = [String: Int] // feedID: unreadCount -nonisolated public struct ArticleChanges: Sendable { +public struct ArticleChanges: Sendable { public let new: Set
? public let updated: Set
? public let deleted: Set
? @@ -36,7 +36,7 @@ nonisolated public struct ArticleChanges: Sendable { } } -nonisolated public final class ArticlesDatabase: Sendable { +@MainActor public final class ArticlesDatabase: Sendable { public enum RetentionStyle: Sendable { case feedBased // Local and iCloud: article retention is defined by contents of feed case syncSystem // Feedbin, Feedly, etc.: article retention is defined by external system @@ -48,7 +48,7 @@ nonisolated public final class ArticlesDatabase: Sendable { private let retentionStyle: RetentionStyle private let accountID: String - private static let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "ArticlesDatabase") + nonisolated private static let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "ArticlesDatabase") public init(databaseFilePath: String, accountID: String, retentionStyle: RetentionStyle) { Self.logger.debug("Articles Database init \(accountID, privacy: .public)") @@ -394,7 +394,7 @@ nonisolated public final class ArticlesDatabase: Sendable { // MARK: - Private -nonisolated private extension ArticlesDatabase { +private extension ArticlesDatabase { static let tableCreationStatements = """ CREATE TABLE if not EXISTS articles (articleID TEXT NOT NULL PRIMARY KEY, feedID TEXT NOT NULL, uniqueID TEXT NOT NULL, title TEXT, contentHTML TEXT, contentText TEXT, markdown TEXT, url TEXT, externalURL TEXT, summary TEXT, imageURL TEXT, bannerImageURL TEXT, datePublished DATE, dateModified DATE, searchRowID INTEGER); @@ -448,7 +448,7 @@ typealias ArticleIDsCompletionBlock = @Sendable (ArticleIDsResult) -> Void typealias ArticleStatusesResult = Result, DatabaseError> typealias ArticleStatusesResultBlock = @Sendable (ArticleStatusesResult) -> Void -nonisolated private extension ArticlesDatabase { +private extension ArticlesDatabase { func _fetchAllUnreadCounts(_ completion: @escaping UnreadCountDictionaryCompletionBlock) { Self.logger.debug("ArticlesDatabase: \(#function, privacy: .public) \(self.accountID, privacy: .public)") diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesTable.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesTable.swift index 18814c705..04fc5386a 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesTable.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesTable.swift @@ -14,7 +14,7 @@ import RSDatabaseObjC import RSParser import Articles -nonisolated final class ArticlesTable: DatabaseTable, Sendable { +final class ArticlesTable: DatabaseTable, Sendable { let name: String private let accountID: String @@ -1116,7 +1116,7 @@ nonisolated private extension ArticlesTable { } } -nonisolated private extension Set where Element == ParsedItem { +private extension Set where Element == ParsedItem { func articleIDs() -> Set { return Set(map { $0.articleID }) } diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/AuthorsTable.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/AuthorsTable.swift index 6866f7e05..125de1ded 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/AuthorsTable.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/AuthorsTable.swift @@ -18,8 +18,7 @@ import Articles // CREATE TABLE if not EXISTS authorLookup (authorID TEXT NOT NULL, articleID TEXT NOT NULL, PRIMARY KEY(authorID, articleID)); -nonisolated final class AuthorsTable: DatabaseRelatedObjectsTable, Sendable { - +final class AuthorsTable: DatabaseRelatedObjectsTable, Sendable { let name: String let databaseIDKey = DatabaseKey.authorID let cache = DatabaseObjectCache() diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Constants.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Constants.swift index 935a5b2b3..025d17ca1 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Constants.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Constants.swift @@ -10,16 +10,14 @@ import Foundation // MARK: - Database structure -nonisolated struct DatabaseTableName { - +struct DatabaseTableName { static let articles = "articles" static let authors = "authors" static let authorsLookup = "authorsLookup" static let statuses = "statuses" } -nonisolated struct DatabaseKey { - +struct DatabaseKey { // Shared static let articleID = "articleID" static let url = "url" @@ -59,7 +57,6 @@ nonisolated struct DatabaseKey { static let rowID = "rowid" } -nonisolated struct RelationshipName { - +struct RelationshipName { static let authors = "authors" } diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/Article+Database.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/Article+Database.swift index c740b6920..ff045c7a6 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/Article+Database.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/Article+Database.swift @@ -12,7 +12,7 @@ import RSDatabaseObjC import Articles import RSParser -nonisolated extension Article { +extension Article { convenience init?(accountID: String, row: FMResultSet, status: ArticleStatus) { guard let articleID = row.string(forColumn: DatabaseKey.articleID) else { @@ -137,7 +137,7 @@ nonisolated extension Article { } } -nonisolated extension Article: @retroactive DatabaseObject { +extension Article: @retroactive DatabaseObject { public func databaseDictionary() -> DatabaseDictionary? { var d = DatabaseDictionary() @@ -200,7 +200,7 @@ nonisolated extension Article: @retroactive DatabaseObject { } } -nonisolated extension Set where Element == Article { +extension Set where Element == Article { func statuses() -> Set { return Set(map { $0.status }) diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/ArticleStatus+Database.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/ArticleStatus+Database.swift index 93b70727b..60a500c73 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/ArticleStatus+Database.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/ArticleStatus+Database.swift @@ -11,7 +11,7 @@ import RSDatabase import RSDatabaseObjC import Articles -nonisolated extension ArticleStatus { +extension ArticleStatus { convenience init(articleID: String, dateArrived: Date, row: FMResultSet) { let read = row.bool(forColumn: DatabaseKey.read) @@ -22,7 +22,7 @@ nonisolated extension ArticleStatus { } -nonisolated extension ArticleStatus: @retroactive DatabaseObject { +extension ArticleStatus: @retroactive DatabaseObject { public var databaseID: String { return articleID diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/Author+Database.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/Author+Database.swift index 62db72fb3..71f6a0b6b 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/Author+Database.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/Author+Database.swift @@ -14,7 +14,7 @@ import RSParser // MARK: - DatabaseObject -nonisolated extension Author { +extension Author { init?(row: FMResultSet) { let authorID = row.string(forColumn: DatabaseKey.authorID) @@ -40,7 +40,7 @@ nonisolated extension Author { } } -nonisolated extension Author: @retroactive DatabaseObject { +extension Author: @retroactive DatabaseObject { public var databaseID: String { return authorID diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/DatabaseObject+Database.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/DatabaseObject+Database.swift index 9c40bcdad..e31344780 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/DatabaseObject+Database.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/DatabaseObject+Database.swift @@ -10,7 +10,7 @@ import Foundation import RSDatabase import Articles -nonisolated extension Array where Element == DatabaseObject { +extension Array where Element == DatabaseObject { func asAuthors() -> Set? { let authors = Set(self.map { $0 as! Author }) diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/ParsedArticle+Database.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/ParsedArticle+Database.swift index c5f43c81d..ded5cc246 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/ParsedArticle+Database.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/ParsedArticle+Database.swift @@ -10,7 +10,7 @@ import Foundation import RSParser import Articles -nonisolated extension ParsedItem { +extension ParsedItem { var articleID: String { if let s = syncServiceID { diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/RelatedObjectsMap+Database.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/RelatedObjectsMap+Database.swift index b11a296d0..49325b62a 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/RelatedObjectsMap+Database.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/RelatedObjectsMap+Database.swift @@ -10,7 +10,7 @@ import Foundation import RSDatabase import Articles -nonisolated extension RelatedObjectsMap { +extension RelatedObjectsMap { func authors(for articleID: String) -> Set? { if let objects = self[articleID] { diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Operations/FetchAllUnreadCountsOperation.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Operations/FetchAllUnreadCountsOperation.swift index 74bd05a84..bab731b8a 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Operations/FetchAllUnreadCountsOperation.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Operations/FetchAllUnreadCountsOperation.swift @@ -11,8 +11,8 @@ import RSCore import RSDatabase import RSDatabaseObjC -public final class FetchAllUnreadCountsOperation: MainThreadOperation, @unchecked Sendable { - var result: UnreadCountDictionaryCompletionResult? +@MainActor public final class FetchAllUnreadCountsOperation: MainThreadOperation, @unchecked Sendable { + nonisolated(unsafe) var result: UnreadCountDictionaryCompletionResult? private let queue: DatabaseQueue init(databaseQueue: DatabaseQueue) { @@ -20,7 +20,7 @@ public final class FetchAllUnreadCountsOperation: MainThreadOperation, @unchecke super.init(name: "FetchAllUnreadCountsOperation") } - @MainActor public override func run() { + public override func run() { queue.runInDatabase { databaseResult in if self.isCanceled { self.didComplete() diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/SearchTable.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/SearchTable.swift index f79c3e3e9..0a3b8d4c5 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/SearchTable.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/SearchTable.swift @@ -14,8 +14,7 @@ import RSDatabaseObjC import Articles import RSParser -nonisolated final class ArticleSearchInfo: Hashable, Sendable { - +final class ArticleSearchInfo: Hashable, Sendable { let articleID: String let title: String? let contentHTML: String? @@ -79,7 +78,7 @@ nonisolated final class ArticleSearchInfo: Hashable, Sendable { } } -nonisolated final class SearchTable: DatabaseTable, @unchecked Sendable { +final class SearchTable: DatabaseTable, @unchecked Sendable { let name = "search" private let queue: DatabaseQueue weak var articlesTable: ArticlesTable? @@ -129,7 +128,7 @@ nonisolated final class SearchTable: DatabaseTable, @unchecked Sendable { // MARK: - Private -nonisolated private extension SearchTable { +private extension SearchTable { func performInitialIndexForArticles(_ articles: Set, _ database: FMDatabase) { articles.forEach { performInitialIndex($0, database) } diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/StatusesTable.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/StatusesTable.swift index c018fa1eb..42e4013fe 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/StatusesTable.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/StatusesTable.swift @@ -17,8 +17,7 @@ import Articles // // CREATE TABLE if not EXISTS statuses (articleID TEXT NOT NULL PRIMARY KEY, read BOOL NOT NULL DEFAULT 0, starred BOOL NOT NULL DEFAULT 0, dateArrived DATE NOT NULL DEFAULT 0); -nonisolated final class StatusesTable: DatabaseTable, Sendable { - +final class StatusesTable: DatabaseTable, Sendable { let name = DatabaseTableName.statuses private let cache = StatusCache() private let queue: DatabaseQueue @@ -227,7 +226,7 @@ nonisolated final class StatusesTable: DatabaseTable, Sendable { // MARK: - Private -nonisolated private extension StatusesTable { +private extension StatusesTable { // MARK: - Cache @@ -268,7 +267,7 @@ nonisolated private extension StatusesTable { // MARK: - StatusCache -nonisolated private final class StatusCache: Sendable { +private final class StatusCache: Sendable { private struct State { var dictionary = [String: ArticleStatus]() } @@ -313,5 +312,3 @@ nonisolated private final class StatusCache: Sendable { } } } - - diff --git a/Modules/FeedFinder/Package.swift b/Modules/FeedFinder/Package.swift index a55b9d372..423d3c599 100644 --- a/Modules/FeedFinder/Package.swift +++ b/Modules/FeedFinder/Package.swift @@ -26,7 +26,6 @@ let package = Package( swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), .enableUpcomingFeature("InferIsolatedConformances"), - .defaultIsolation(MainActor.self), .unsafeFlags(["-warnings-as-errors"]) ] ), diff --git a/Modules/FeedFinder/Sources/FeedFinder/FeedFinder.swift b/Modules/FeedFinder/Sources/FeedFinder/FeedFinder.swift index d692efab6..a6d5a3723 100644 --- a/Modules/FeedFinder/Sources/FeedFinder/FeedFinder.swift +++ b/Modules/FeedFinder/Sources/FeedFinder/FeedFinder.swift @@ -23,8 +23,7 @@ public enum FeedFinderError: LocalizedError { } } -nonisolated public final class FeedFinder { - +public final class FeedFinder { private static let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "FeedFinder") @concurrent public static func find(url: URL) async throws -> Set { @@ -68,7 +67,7 @@ nonisolated public final class FeedFinder { } } -nonisolated private extension FeedFinder { +private extension FeedFinder { static func addFeedSpecifier(_ feedSpecifier: FeedSpecifier, feedSpecifiers: inout [String: FeedSpecifier]) { // If there's an existing feed specifier, merge the two so that we have the best data. If one has a title and one doesn't, use that non-nil title. Use the better source. diff --git a/Modules/FeedFinder/Sources/FeedFinder/FeedSpecifier.swift b/Modules/FeedFinder/Sources/FeedFinder/FeedSpecifier.swift index 6ed5b33de..bbceb6a63 100644 --- a/Modules/FeedFinder/Sources/FeedFinder/FeedSpecifier.swift +++ b/Modules/FeedFinder/Sources/FeedFinder/FeedSpecifier.swift @@ -9,8 +9,7 @@ import Foundation import RSWeb -nonisolated public struct FeedSpecifier: Hashable, Sendable { - +public struct FeedSpecifier: Hashable, Sendable { public enum Source: Int, Sendable { case UserEntered = 0, HTMLHead, HTMLLink @@ -77,7 +76,7 @@ nonisolated public struct FeedSpecifier: Hashable, Sendable { } } -nonisolated private extension FeedSpecifier { +private extension FeedSpecifier { func calculatedScore() -> Int { var score = 0 diff --git a/Modules/FeedFinder/Sources/FeedFinder/HTMLFeedFinder.swift b/Modules/FeedFinder/Sources/FeedFinder/HTMLFeedFinder.swift index 83f7438be..815d53f9f 100644 --- a/Modules/FeedFinder/Sources/FeedFinder/HTMLFeedFinder.swift +++ b/Modules/FeedFinder/Sources/FeedFinder/HTMLFeedFinder.swift @@ -9,9 +9,9 @@ import Foundation import RSParser -nonisolated private let feedURLWordsToMatch = ["feed", "xml", "rss", "atom", "json"] +private let feedURLWordsToMatch = ["feed", "xml", "rss", "atom", "json"] -nonisolated final class HTMLFeedFinder { +final class HTMLFeedFinder { var feedSpecifiers: Set { return Set(feedSpecifiersDictionary.values) @@ -42,7 +42,7 @@ nonisolated final class HTMLFeedFinder { } } -nonisolated private extension HTMLFeedFinder { +private extension HTMLFeedFinder { func addFeedSpecifier(_ feedSpecifier: FeedSpecifier) { // If there’s an existing feed specifier, merge the two so that we have the best data. If one has a title and one doesn’t, use that non-nil title. Use the better source. diff --git a/Modules/RSCore/Package.swift b/Modules/RSCore/Package.swift index 3827f6867..9a2d3927f 100644 --- a/Modules/RSCore/Package.swift +++ b/Modules/RSCore/Package.swift @@ -16,7 +16,6 @@ let package = Package( swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), .enableUpcomingFeature("InferIsolatedConformances"), - .defaultIsolation(MainActor.self) ] ), .target( @@ -35,7 +34,6 @@ let package = Package( swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), .enableUpcomingFeature("InferIsolatedConformances"), - .defaultIsolation(MainActor.self) ] ), .testTarget( diff --git a/Modules/RSCore/Sources/RSCore/AppKit/FourCharCode.swift b/Modules/RSCore/Sources/RSCore/AppKit/FourCharCode.swift index 9f3c0ebf4..878626b4b 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/FourCharCode.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/FourCharCode.swift @@ -29,9 +29,7 @@ public extension String { } public extension Int { - var fourCharCode: FourCharCode { return UInt32(self) } } - diff --git a/Modules/RSCore/Sources/RSCore/AppKit/Keyboard.swift b/Modules/RSCore/Sources/RSCore/AppKit/Keyboard.swift index 65fa3834f..6cdb03b18 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/Keyboard.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/Keyboard.swift @@ -11,15 +11,13 @@ import AppKit // To get, for instance, the keyboard integer value for "\r": "\r".keyboardIntegerValue (returns 13) public struct KeyboardConstant { - public static let lineFeedKey = "\n".keyboardIntegerValue public static let returnKey = "\r".keyboardIntegerValue public static let spaceKey = " ".keyboardIntegerValue } public extension String { - - nonisolated var keyboardIntegerValue: Int? { + var keyboardIntegerValue: Int? { if isEmpty { return nil } @@ -32,13 +30,11 @@ public extension String { } } -nonisolated public struct KeyboardShortcut: Hashable, Sendable { - +public struct KeyboardShortcut: Hashable, Sendable { public let key: KeyboardKey public let actionString: String public init?(dictionary: [String: Any]) { - guard let key = KeyboardKey(dictionary: dictionary) else { return nil } @@ -56,7 +52,6 @@ nonisolated public struct KeyboardShortcut: Hashable, Sendable { } public static func findMatchingShortcut(in shortcuts: Set, key: KeyboardKey) -> KeyboardShortcut? { - for shortcut in shortcuts { if shortcut.key == key { return shortcut @@ -66,8 +61,7 @@ nonisolated public struct KeyboardShortcut: Hashable, Sendable { } } -nonisolated public struct KeyboardKey: Hashable, Sendable { - +public struct KeyboardKey: Hashable, Sendable { public let shiftKeyDown: Bool public let optionKeyDown: Bool public let commandKeyDown: Bool @@ -79,7 +73,6 @@ nonisolated public struct KeyboardKey: Hashable, Sendable { } init(integerValue: Int, shiftKeyDown: Bool, optionKeyDown: Bool, commandKeyDown: Bool, controlKeyDown: Bool) { - self.integerValue = integerValue self.shiftKeyDown = shiftKeyDown @@ -91,7 +84,6 @@ nonisolated public struct KeyboardKey: Hashable, Sendable { static let deleteKeyCode = 127 public init(with event: NSEvent) { - let flags = event.modifierFlags let shiftKeyDown = flags.contains(.shift) let optionKeyDown = flags.contains(.option) @@ -104,7 +96,6 @@ nonisolated public struct KeyboardKey: Hashable, Sendable { } public init?(dictionary: [String: Any]) { - guard let s = dictionary["key"] as? String else { return nil } diff --git a/Modules/RSCore/Sources/RSCore/AppKit/KeyboardDelegateProtocol.swift b/Modules/RSCore/Sources/RSCore/AppKit/KeyboardDelegateProtocol.swift index 1dc626038..c97676f8f 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/KeyboardDelegateProtocol.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/KeyboardDelegateProtocol.swift @@ -5,14 +5,12 @@ // Created by Brent Simmons on 10/11/16. // Copyright © 2016 Ranchero Software, LLC. All rights reserved. // + #if os(macOS) import AppKit -//let keypadEnter: unichar = 3 - @objc public protocol KeyboardDelegate: AnyObject { - // Return true if handled. - func keydown(_: NSEvent, in view: NSView) -> Bool + @MainActor func keydown(_: NSEvent, in view: NSView) -> Bool } #endif diff --git a/Modules/RSCore/Sources/RSCore/AppKit/NSAppearance+RSCore.swift b/Modules/RSCore/Sources/RSCore/AppKit/NSAppearance+RSCore.swift index 207cc4885..832d7da98 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/NSAppearance+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/NSAppearance+RSCore.swift @@ -12,7 +12,7 @@ import AppKit extension NSAppearance { @objc(rsIsDarkMode) - public var isDarkMode: Bool { + @MainActor public var isDarkMode: Bool { if #available(macOS 10.14, *) { return self.bestMatch(from: [.darkAqua, .aqua]) == .darkAqua } diff --git a/Modules/RSCore/Sources/RSCore/AppKit/NSAppleEventDescriptor+RSCore.swift b/Modules/RSCore/Sources/RSCore/AppKit/NSAppleEventDescriptor+RSCore.swift index fcfcbcf94..7b63826d1 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/NSAppleEventDescriptor+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/NSAppleEventDescriptor+RSCore.swift @@ -17,7 +17,6 @@ public extension NSAppleEventDescriptor { /// - Returns: An instance of `NSAppleEventDescriptor` that refers to the running application, /// or `nil` if the running application has no process ID. convenience init?(runningApplication: NSRunningApplication) { - let pid = runningApplication.processIdentifier if pid == -1 { return nil diff --git a/Modules/RSCore/Sources/RSCore/AppKit/NSImage+RSCore.swift b/Modules/RSCore/Sources/RSCore/AppKit/NSImage+RSCore.swift index 739829ab4..04f87edfc 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/NSImage+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/NSImage+RSCore.swift @@ -5,13 +5,13 @@ // Created by Brent Simmons on 12/16/17. // Copyright © 2017 Ranchero Software, LLC. All rights reserved. // + #if os(macOS) import AppKit public extension NSImage { func tinted(with color: NSColor) -> NSImage { - let image = self.copy() as! NSImage image.lockFocus() diff --git a/Modules/RSCore/Sources/RSCore/AppKit/NSMenu+Extensions.swift b/Modules/RSCore/Sources/RSCore/AppKit/NSMenu+Extensions.swift index 115e71b63..6423cc04b 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/NSMenu+Extensions.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/NSMenu+Extensions.swift @@ -5,13 +5,13 @@ // Created by Brent Simmons on 2/9/18. // Copyright © 2018 Ranchero Software, LLC. All rights reserved. // + #if os(macOS) import AppKit public extension NSMenu { func takeItems(from menu: NSMenu) { - // The passed-in menu gets all its items removed. let items = menu.items diff --git a/Modules/RSCore/Sources/RSCore/AppKit/NSOutlineView+RSCore.swift b/Modules/RSCore/Sources/RSCore/AppKit/NSOutlineView+RSCore.swift index a16152fba..067427f6e 100755 --- a/Modules/RSCore/Sources/RSCore/AppKit/NSOutlineView+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/NSOutlineView+RSCore.swift @@ -5,11 +5,11 @@ // Created by Brent Simmons on 9/6/16. // Copyright © 2016 Ranchero Software, LLC. All rights reserved. // + #if os(macOS) import AppKit public extension NSOutlineView { - var selectedItems: [AnyObject] { if selectionIsEmpty { return [AnyObject]() diff --git a/Modules/RSCore/Sources/RSCore/AppKit/NSPasteboard+RSCore.swift b/Modules/RSCore/Sources/RSCore/AppKit/NSPasteboard+RSCore.swift index b22696b29..941957f23 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/NSPasteboard+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/NSPasteboard+RSCore.swift @@ -11,7 +11,6 @@ import AppKit public extension NSPasteboard { func copyObjects(_ objects: [Any]) { - guard let writers = writersFor(objects) else { return } @@ -21,7 +20,6 @@ public extension NSPasteboard { } func canCopyAtLeastOneObject(_ objects: [Any]) -> Bool { - for object in objects { if object is PasteboardWriterOwner { return true @@ -29,7 +27,6 @@ public extension NSPasteboard { } return false } - } public extension NSPasteboard { @@ -55,7 +52,6 @@ public extension NSPasteboard { private extension NSPasteboard { func writersFor(_ objects: [Any]) -> [NSPasteboardWriting]? { - let writers = objects.compactMap { ($0 as? PasteboardWriterOwner)?.pasteboardWriter } return writers.isEmpty ? nil : writers } diff --git a/Modules/RSCore/Sources/RSCore/AppKit/NSResponder-Extensions.swift b/Modules/RSCore/Sources/RSCore/AppKit/NSResponder-Extensions.swift index 73c6889d1..dbf7f4f84 100755 --- a/Modules/RSCore/Sources/RSCore/AppKit/NSResponder-Extensions.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/NSResponder-Extensions.swift @@ -5,13 +5,13 @@ // Created by Brent Simmons on 10/10/16. // Copyright © 2016 Ranchero Software, LLC. All rights reserved. // + #if os(macOS) import AppKit public extension NSResponder { func hasAncestor(_ ancestor: NSResponder) -> Bool { - var nomad: NSResponder = self while(true) { if nomad === ancestor { diff --git a/Modules/RSCore/Sources/RSCore/AppKit/NSTableView+RSCore.swift b/Modules/RSCore/Sources/RSCore/AppKit/NSTableView+RSCore.swift index d6a8485ab..704ce3919 100755 --- a/Modules/RSCore/Sources/RSCore/AppKit/NSTableView+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/NSTableView+RSCore.swift @@ -5,17 +5,16 @@ // Created by Brent Simmons on 9/6/16. // Copyright © 2016 Ranchero Software, LLC. All rights reserved. // + #if os(macOS) import AppKit public extension NSTableView { - var selectionIsEmpty: Bool { return selectedRowIndexes.startIndex == selectedRowIndexes.endIndex } func indexesOfAvailableRowsPassingTest(_ test: (Int) -> Bool) -> IndexSet? { - // Checks visible and in-flight rows. var indexes = IndexSet() @@ -29,14 +28,12 @@ public extension NSTableView { } func indexesOfAvailableRows() -> IndexSet? { - var indexes = IndexSet() enumerateAvailableRowViews { indexes.insert($1) } return indexes.isEmpty ? nil : indexes } func scrollTo(row: Int, extraHeight: Int = 150) { - guard let scrollView = self.enclosingScrollView else { return } @@ -73,7 +70,6 @@ public extension NSTableView { } func visibleRowViews() -> [NSTableRowView]? { - guard let scrollView = self.enclosingScrollView, numberOfRows > 0 else { return nil } @@ -95,12 +91,10 @@ public extension NSTableView { } func selectRow(_ row: Int) { - self.selectRowIndexes(IndexSet(integer: row), byExtendingSelection: false) } func selectRowAndScrollToVisible(_ row: Int) { - self.selectRow(row) self.scrollRowToVisible(row) } diff --git a/Modules/RSCore/Sources/RSCore/AppKit/NSToolbar+RSCore.swift b/Modules/RSCore/Sources/RSCore/AppKit/NSToolbar+RSCore.swift index 1396e59cb..c286e6b89 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/NSToolbar+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/NSToolbar+RSCore.swift @@ -5,6 +5,7 @@ // Created by Brent Simmons on 2/17/18. // Copyright © 2018 Ranchero Software, LLC. All rights reserved. // + #if os(macOS) import AppKit diff --git a/Modules/RSCore/Sources/RSCore/AppKit/NSView+RSCore.swift b/Modules/RSCore/Sources/RSCore/AppKit/NSView+RSCore.swift index af2f3df23..831a0f784 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/NSView+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/NSView+RSCore.swift @@ -5,6 +5,7 @@ // Created by Maurice Parker on 11/12/19. // Copyright © 2019 Ranchero Software, LLC. All rights reserved. // + #if os(macOS) import AppKit @@ -18,7 +19,6 @@ extension NSView { img.addRepresentation(rep) return img } - } public extension NSView { diff --git a/Modules/RSCore/Sources/RSCore/AppKit/NSWindow-Extensions.swift b/Modules/RSCore/Sources/RSCore/AppKit/NSWindow-Extensions.swift index a55745c5b..204e0c938 100755 --- a/Modules/RSCore/Sources/RSCore/AppKit/NSWindow-Extensions.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/NSWindow-Extensions.swift @@ -5,18 +5,16 @@ // Created by Brent Simmons on 10/10/16. // Copyright © 2016 Ranchero Software, LLC. All rights reserved. // + #if os(macOS) import AppKit public extension NSWindow { - var isDisplayingSheet: Bool { - return attachedSheet != nil } func makeFirstResponderUnlessDescendantIsFirstResponder(_ responder: NSResponder) { - if let fr = firstResponder, fr.hasAncestor(responder) { return } @@ -24,7 +22,6 @@ public extension NSWindow { } func setPointAndSizeAdjustingForScreen(point: NSPoint, size: NSSize, minimumSize: NSSize) { - // point.y specifies from the *top* of the screen, even though screen coordinates work from the bottom up. This is for convenience. // The eventual size may be smaller than requested, since the screen may be small, but not smaller than minimumSize. @@ -52,7 +49,6 @@ public extension NSWindow { } var flippedOrigin: NSPoint? { - // Screen coordinates start at lower-left. // With this we can use upper-left, like sane people. @@ -75,7 +71,6 @@ public extension NSWindow { } func setFlippedOriginAdjustingForScreen(_ point: NSPoint) { - guard let screenFrame = screen?.frame else { return } diff --git a/Modules/RSCore/Sources/RSCore/AppKit/NSWindowController+RSCore.swift b/Modules/RSCore/Sources/RSCore/AppKit/NSWindowController+RSCore.swift index 901054254..453e0afc9 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/NSWindowController+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/NSWindowController+RSCore.swift @@ -5,18 +5,16 @@ // Created by Brent Simmons on 2/17/18. // Copyright © 2018 Ranchero Software, LLC. All rights reserved. // + #if os(macOS) import AppKit public extension NSWindowController { - var isDisplayingSheet: Bool { - return window?.isDisplayingSheet ?? false } var isOpen: Bool { - return isWindowLoaded && window!.isVisible } } diff --git a/Modules/RSCore/Sources/RSCore/AppKit/PasteboardWriterOwner.swift b/Modules/RSCore/Sources/RSCore/AppKit/PasteboardWriterOwner.swift index de4f2c3f9..5f698f1bf 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/PasteboardWriterOwner.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/PasteboardWriterOwner.swift @@ -5,11 +5,11 @@ // Created by Brent Simmons on 2/11/18. // Copyright © 2018 Ranchero Software, LLC. All rights reserved. // + #if os(macOS) import AppKit public protocol PasteboardWriterOwner { - var pasteboardWriter: NSPasteboardWriting { get } } #endif diff --git a/Modules/RSCore/Sources/RSCore/AppKit/RSAppMovementMonitor.swift b/Modules/RSCore/Sources/RSCore/AppKit/RSAppMovementMonitor.swift index 248a6dd0e..13ee53740 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/RSAppMovementMonitor.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/RSAppMovementMonitor.swift @@ -6,10 +6,11 @@ // Created by Daniel Jalkut on 8/28/19. // Copyright © 2019 Red Sweater Software. All rights reserved. // + #if os(macOS) import Cocoa -public final class RSAppMovementMonitor: NSObject { +@MainActor public final class RSAppMovementMonitor: NSObject { // If provided, the handler will be consulted when the app is moved. // Return true to indicate that the default handler should be invoked. diff --git a/Modules/RSCore/Sources/RSCore/AppKit/RSToolbarItem.swift b/Modules/RSCore/Sources/RSCore/AppKit/RSToolbarItem.swift index 0a05bcd0e..1da6e5253 100755 --- a/Modules/RSCore/Sources/RSCore/AppKit/RSToolbarItem.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/RSToolbarItem.swift @@ -5,13 +5,13 @@ // Created by Brent Simmons on 10/16/16. // Copyright © 2016 Ranchero Software, LLC. All rights reserved. // + #if os(macOS) import AppKit public class RSToolbarItem: NSToolbarItem { override public func validate() { - guard let view = view, let _ = view.window else { isEnabled = false return @@ -23,7 +23,6 @@ public class RSToolbarItem: NSToolbarItem { private extension RSToolbarItem { func isValidAsUserInterfaceItem() -> Bool { - // Use NSValidatedUserInterfaceItem protocol rather than calling validateToolbarItem:. if let target = target as? NSResponder { @@ -55,7 +54,6 @@ private extension RSToolbarItem { } func validateWithResponder(_ responder: NSObjectProtocol) -> Bool? { - guard responder.responds(to: action), let target = responder as? NSUserInterfaceValidations else { return nil } diff --git a/Modules/RSCore/Sources/RSCore/AppKit/URLPasteboardWriter.swift b/Modules/RSCore/Sources/RSCore/AppKit/URLPasteboardWriter.swift index 606d09d83..150100ab5 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/URLPasteboardWriter.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/URLPasteboardWriter.swift @@ -12,7 +12,6 @@ import AppKit /// Takes a string, not a URL, but writes it as a URL (when possible) and as a String. @objc public final class URLPasteboardWriter: NSObject, NSPasteboardWriting { - let urlString: String public init(urlString: String) { diff --git a/Modules/RSCore/Sources/RSCore/AppKit/UserApp.swift b/Modules/RSCore/Sources/RSCore/AppKit/UserApp.swift index 87ea16ddd..503770b33 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/UserApp.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/UserApp.swift @@ -5,6 +5,7 @@ // Created by Brent Simmons on 1/14/18. // Copyright © 2018 Ranchero Software, LLC. All rights reserved. // + #if os(macOS) import AppKit @@ -13,7 +14,6 @@ import AppKit /// The app may or may not be running. It may or may not exist. public final class UserApp { - public let bundleID: String public var icon: NSImage? = nil public var existsOnDisk = false @@ -21,7 +21,6 @@ public final class UserApp { public var runningApplication: NSRunningApplication? = nil public var isRunning: Bool { - updateStatus() if let runningApplication = runningApplication { return !runningApplication.isTerminated @@ -30,13 +29,11 @@ public final class UserApp { } public init(bundleID: String) { - self.bundleID = bundleID updateStatus() } public func updateStatus() { - if let runningApplication = runningApplication, runningApplication.isTerminated { self.runningApplication = nil } @@ -85,7 +82,6 @@ public final class UserApp { } public func launchIfNeeded() async -> Bool { - // Return true if already running. // Return true if not running and successfully gets launched. @@ -125,7 +121,6 @@ public final class UserApp { } public func bringToFront() -> Bool { - // Activates the app, ignoring other apps. // Does not automatically launch the app first. @@ -134,7 +129,6 @@ public final class UserApp { } public func targetDescriptor() -> NSAppleEventDescriptor? { - // Requires that the app has previously been launched. updateStatus() diff --git a/Modules/RSCore/Sources/RSCore/Shared/AppConfig.swift b/Modules/RSCore/Sources/RSCore/Shared/AppConfig.swift index efdfc95f4..5828051b4 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/AppConfig.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/AppConfig.swift @@ -8,7 +8,7 @@ import Foundation -public final class AppConfig { +@MainActor public final class AppConfig { public static let appName: String = (Bundle.main.infoDictionary!["CFBundleExecutable"]! as! String) diff --git a/Modules/RSCore/Sources/RSCore/Shared/Array+RSCore.swift b/Modules/RSCore/Sources/RSCore/Shared/Array+RSCore.swift index 6d2e71e92..fc184e2d4 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/Array+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/Array+RSCore.swift @@ -8,7 +8,7 @@ import Foundation -nonisolated public extension Array { +public extension Array { func chunked(into size: Int) -> [[Element]] { return stride(from: 0, to: count, by: size).map { diff --git a/Modules/RSCore/Sources/RSCore/Shared/BatchUpdate.swift b/Modules/RSCore/Sources/RSCore/Shared/BatchUpdate.swift index fdfdabae7..ebb631786 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/BatchUpdate.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/BatchUpdate.swift @@ -13,13 +13,12 @@ import Foundation public typealias BatchUpdateBlock = () -> Void public extension Notification.Name { - /// A notification posted when a batch update completes. static let BatchUpdateDidPerform = Notification.Name(rawValue: "BatchUpdateDidPerform") } /// A class for batch updating. -public final class BatchUpdate { +@MainActor public final class BatchUpdate { /// The shared batch update object. public static let shared = BatchUpdate() @@ -77,5 +76,4 @@ private extension BatchUpdate { NotificationCenter.default.post(name: .BatchUpdateDidPerform, object: nil, userInfo: nil) } } - } diff --git a/Modules/RSCore/Sources/RSCore/Shared/Cache.swift b/Modules/RSCore/Sources/RSCore/Shared/Cache.swift index e54272d56..72836f883 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/Cache.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/Cache.swift @@ -8,11 +8,11 @@ import Foundation import Synchronization -nonisolated public protocol CacheRecord: Sendable { +public protocol CacheRecord: Sendable { var dateCreated: Date { get } } -nonisolated public final class Cache: Sendable { +public final class Cache: Sendable { public let timeToLive: TimeInterval public let timeBetweenCleanups: TimeInterval @@ -59,10 +59,9 @@ nonisolated public final class Cache: Sendable { } } -nonisolated extension Cache { +extension Cache { private func cleanupIfNeeded(_ state: inout State) { - let currentDate = Date() guard state.lastCleanupDate.timeIntervalSince(currentDate) < -timeBetweenCleanups else { return diff --git a/Modules/RSCore/Sources/RSCore/Shared/Calendar+RSCore.swift b/Modules/RSCore/Sources/RSCore/Shared/Calendar+RSCore.swift index c59d1263e..d4cb3a4b3 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/Calendar+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/Calendar+RSCore.swift @@ -9,7 +9,6 @@ import Foundation public extension Calendar { - /// A cached `.autoupdatingCurrent` for performance. static let cached: Calendar = .autoupdatingCurrent diff --git a/Modules/RSCore/Sources/RSCore/Shared/CoalescingQueue.swift b/Modules/RSCore/Sources/RSCore/Shared/CoalescingQueue.swift index f9bf028ae..1945efd0f 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/CoalescingQueue.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/CoalescingQueue.swift @@ -15,22 +15,19 @@ import Foundation // Calls are FIFO. struct QueueCall: Equatable { - weak var target: AnyObject? let selector: Selector func perform() { - _ = target?.perform(selector) } static func ==(lhs: QueueCall, rhs: QueueCall) -> Bool { - - return lhs.target === rhs.target && lhs.selector == rhs.selector + lhs.target === rhs.target && lhs.selector == rhs.selector } } -@objc public final class CoalescingQueue: NSObject { +@MainActor @objc public final class CoalescingQueue: NSObject { public static let standard = CoalescingQueue(name: "Standard", interval: 0.05, maxInterval: 0.1) public let name: String diff --git a/Modules/RSCore/Sources/RSCore/Shared/Data+RSCore.swift b/Modules/RSCore/Sources/RSCore/Shared/Data+RSCore.swift index d84ae1a6d..dea25d07f 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/Data+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/Data+RSCore.swift @@ -9,8 +9,7 @@ import Foundation import CryptoKit -nonisolated public extension Data { - +public extension Data { /// The MD5 hash of the data. var md5Hash: Data { let digest = Insecure.MD5.hash(data: self) @@ -85,7 +84,6 @@ nonisolated public extension Data { /// Constants for `isProbablyHTML`. private enum RSSearch { - static let lessThan = "<".utf8.first! static let greaterThan = ">".utf8.first! diff --git a/Modules/RSCore/Sources/RSCore/Shared/Date+Extensions.swift b/Modules/RSCore/Sources/RSCore/Shared/Date+Extensions.swift index 070e2865e..00358acf3 100755 --- a/Modules/RSCore/Sources/RSCore/Shared/Date+Extensions.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/Date+Extensions.swift @@ -8,8 +8,7 @@ import Foundation -nonisolated public extension Date { - +public extension Date { // Below are for rough use only — they don't use the calendar. func bySubtracting(days: Int) -> Date { diff --git a/Modules/RSCore/Sources/RSCore/Shared/DisplayNameProvider.swift b/Modules/RSCore/Sources/RSCore/Shared/DisplayNameProvider.swift index 7d470c694..bd84d23c9 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/DisplayNameProvider.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/DisplayNameProvider.swift @@ -9,19 +9,18 @@ import Foundation extension Notification.Name { - public static let DisplayNameDidChange = Notification.Name("DisplayNameDidChange") } /// A type that provides a name for display to the user. @MainActor public protocol DisplayNameProvider { - @MainActor var nameForDisplay: String { get } + var nameForDisplay: String { get } } public extension DisplayNameProvider { - @MainActor func postDisplayNameDidChangeNotification() { + func postDisplayNameDidChangeNotification() { NotificationCenter.default.post(name: .DisplayNameDidChange, object: self, userInfo: nil) } } diff --git a/Modules/RSCore/Sources/RSCore/Shared/FileManager+RSCore.swift b/Modules/RSCore/Sources/RSCore/Shared/FileManager+RSCore.swift index ceabd51b3..33ae0300a 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/FileManager+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/FileManager+RSCore.swift @@ -8,8 +8,7 @@ import Foundation -nonisolated public extension FileManager { - +public extension FileManager { /// Returns whether a path refers to a folder. /// /// - Parameter path: The file path to check. diff --git a/Modules/RSCore/Sources/RSCore/Shared/Geometry.swift b/Modules/RSCore/Sources/RSCore/Shared/Geometry.swift index 41d3db8b7..346b67814 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/Geometry.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/Geometry.swift @@ -7,8 +7,9 @@ // import Foundation + #if os(macOS) -nonisolated public extension CGRect { +public extension CGRect { /// Centers a rectangle vertically in another rectangle. /// diff --git a/Modules/RSCore/Sources/RSCore/Shared/MacroProcessor.swift b/Modules/RSCore/Sources/RSCore/Shared/MacroProcessor.swift index dffe26260..dfa516292 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/MacroProcessor.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/MacroProcessor.swift @@ -12,8 +12,7 @@ enum MacroProcessorError: Error, Sendable { case emptyMacroDelimiter } -nonisolated public final class MacroProcessor: Sendable { - +public final class MacroProcessor: Sendable { let template: String let substitutions: [String: String] let macroStart: String @@ -51,7 +50,6 @@ nonisolated public final class MacroProcessor: Sendable { self.macroStart = macroStart self.macroEnd = macroEnd } - } nonisolated private extension MacroProcessor { @@ -85,5 +83,4 @@ nonisolated private extension MacroProcessor { return result } - } diff --git a/Modules/RSCore/Sources/RSCore/Shared/MainThreadBlockOperation.swift b/Modules/RSCore/Sources/RSCore/Shared/MainThreadBlockOperation.swift index 07a3967f3..f3bed85b2 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/MainThreadBlockOperation.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/MainThreadBlockOperation.swift @@ -9,7 +9,7 @@ import Foundation /// Run a block of code as an operation. -public final class MainThreadBlockOperation: MainThreadOperation, @unchecked Sendable { +@MainActor public final class MainThreadBlockOperation: MainThreadOperation, @unchecked Sendable { private let block: VoidBlock public init(name: String? = nil, block: @escaping VoidBlock) { @@ -17,7 +17,7 @@ public final class MainThreadBlockOperation: MainThreadOperation, @unchecked Sen super.init(name: name, completionBlock: nil) } - @MainActor override public func run() { + override public func run() { assert(Thread.isMainThread) block() didComplete() diff --git a/Modules/RSCore/Sources/RSCore/Shared/MainThreadOperation.swift b/Modules/RSCore/Sources/RSCore/Shared/MainThreadOperation.swift index d2ce11c44..3b07e3f98 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/MainThreadOperation.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/MainThreadOperation.swift @@ -24,9 +24,9 @@ import Synchronization /// regardless of cancellation status. The completion block /// takes the operation as a parameter so that it can check /// cancellation status if it needs to. -nonisolated open class MainThreadOperation: Hashable, @unchecked Sendable { +@MainActor open class MainThreadOperation: Hashable, @unchecked Sendable { public let id: Int - private static let nextID = Mutex(0) + private static var incrementingID = 0 private struct State: Sendable { var isCanceled = false @@ -34,19 +34,19 @@ nonisolated open class MainThreadOperation: Hashable, @unchecked Sendable { private let state = Mutex(State()) // Check this at appropriate times in case the operation has been canceled. - public var isCanceled: Bool { + nonisolated public var isCanceled: Bool { get { state.withLock { $0.isCanceled } } set { state.withLock { $0.isCanceled = newValue } } } public let name: String? - public typealias MainThreadOperationCompletionBlock = @MainActor @Sendable (MainThreadOperation) -> Void + public typealias MainThreadOperationCompletionBlock = @MainActor (MainThreadOperation) -> Void public var completionBlock: MainThreadOperationCompletionBlock? - @MainActor public weak var operationQueue: MainThreadOperationQueue? + public weak var operationQueue: MainThreadOperationQueue? - @MainActor var dependencies = Set() + var dependencies = Set() /// Create a new MainThreadOperation. /// @@ -58,7 +58,8 @@ nonisolated open class MainThreadOperation: Hashable, @unchecked Sendable { /// - completionBlock: Called on the main thread once the operation has completed. /// Called even if canceled, even if `run` was never called. public init(name: String? = nil, completionBlock: MainThreadOperationCompletionBlock? = nil) { - self.id = Self.autoincrementingID() + self.id = Self.incrementingID + Self.incrementingID += 1 self.name = name self.completionBlock = completionBlock } @@ -67,7 +68,7 @@ nonisolated open class MainThreadOperation: Hashable, @unchecked Sendable { /// /// This code runs on the main thread. You can run code off the main /// thread via the standard ways. - @MainActor open func run() { + open func run() { preconditionFailure("MainThreadOperation.run must be overridden.") } @@ -75,7 +76,7 @@ nonisolated open class MainThreadOperation: Hashable, @unchecked Sendable { /// /// Any operations dependent on this operation /// will also be canceled automatically. - @MainActor public func cancel() { + public func cancel() { isCanceled = true dependencies.removeAll() Task { @MainActor in @@ -92,15 +93,15 @@ nonisolated open class MainThreadOperation: Hashable, @unchecked Sendable { /// this operation gets run. If the other operation is canceled, /// this operation will automatically be canceled. /// Note: an operation can have multiple dependencies. - @MainActor public func addDependency(_ parentOperation: MainThreadOperation) { + public func addDependency(_ parentOperation: MainThreadOperation) { dependencies.insert(parentOperation) } - @MainActor func removeDependency(_ parentOperation: MainThreadOperation) { + func removeDependency(_ parentOperation: MainThreadOperation) { dependencies.remove(parentOperation) } - @MainActor func hasDependency(_ parentOperation: MainThreadOperation) -> Bool { + func hasDependency(_ parentOperation: MainThreadOperation) -> Bool { dependencies.contains(parentOperation) } @@ -118,35 +119,23 @@ nonisolated open class MainThreadOperation: Hashable, @unchecked Sendable { } /// Override to be notified when the operation is complete. - @MainActor open func noteDidComplete() { + open func noteDidComplete() { } - @MainActor func callCompletionBlock() { + func callCompletionBlock() { completionBlock?(self) completionBlock = nil } // MARK: - Hashable - public func hash(into hasher: inout Hasher) { + nonisolated public func hash(into hasher: inout Hasher) { hasher.combine(id) } // MARK: - Equatable - static public func ==(lhs: MainThreadOperation, rhs: MainThreadOperation) -> Bool { + nonisolated static public func ==(lhs: MainThreadOperation, rhs: MainThreadOperation) -> Bool { lhs.id == rhs.id } } - -nonisolated private extension MainThreadOperation { - - static func autoincrementingID() -> Int { - nextID.withLock { id in - defer { - id += 1 - } - return id - } - } -} diff --git a/Modules/RSCore/Sources/RSCore/Shared/MainThreadOperationQueue.swift b/Modules/RSCore/Sources/RSCore/Shared/MainThreadOperationQueue.swift index b697651df..0e909fce8 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/MainThreadOperationQueue.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/MainThreadOperationQueue.swift @@ -30,7 +30,7 @@ import Foundation return pendingNonCanceledOperations.count } - nonisolated public init() {} + public init() {} /// Add an operation to the queue. public func add(_ operation: MainThreadOperation) { @@ -156,7 +156,7 @@ private extension MainThreadOperationQueue { } hasPendingRunScheduled = true - Task { @MainActor in + Task { hasPendingRunScheduled = false guard !isSuspended && currentOperation == nil else { return diff --git a/Modules/RSCore/Sources/RSCore/Shared/NotificationCenter+RSCore.swift b/Modules/RSCore/Sources/RSCore/Shared/NotificationCenter+RSCore.swift index 570b67f41..d15706b60 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/NotificationCenter+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/NotificationCenter+RSCore.swift @@ -7,9 +7,9 @@ import Foundation -nonisolated public extension NotificationCenter { +public extension NotificationCenter { - func postOnMainThread(name: Notification.Name, object: Any?, userInfo: [AnyHashable : Any]? = nil) { + nonisolated func postOnMainThread(name: Notification.Name, object: Any?, userInfo: [AnyHashable : Any]? = nil) { nonisolated(unsafe) let capturedObject = object nonisolated(unsafe) let capturedUserInfo = userInfo Task { @MainActor in diff --git a/Modules/RSCore/Sources/RSCore/Shared/OPMLRepresentable.swift b/Modules/RSCore/Sources/RSCore/Shared/OPMLRepresentable.swift index c63fd9a84..f5b11c56d 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/OPMLRepresentable.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/OPMLRepresentable.swift @@ -8,14 +8,14 @@ import Foundation -public protocol OPMLRepresentable { +@MainActor public protocol OPMLRepresentable { func OPMLString(indentLevel: Int, allowCustomAttributes: Bool) -> String } public extension OPMLRepresentable { - @MainActor func OPMLString(indentLevel: Int) -> String { - return OPMLString(indentLevel: indentLevel, allowCustomAttributes: false) + func OPMLString(indentLevel: Int) -> String { + OPMLString(indentLevel: indentLevel, allowCustomAttributes: false) } } diff --git a/Modules/RSCore/Sources/RSCore/Shared/RSImage.swift b/Modules/RSCore/Sources/RSCore/Shared/RSImage.swift index 41988fb66..e85404135 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/RSImage.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/RSImage.swift @@ -19,10 +19,10 @@ import UIKit public typealias RSImage = UIImage #endif -nonisolated private let RSImageLogger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "RSImage") -nonisolated private let debugLoggingEnabled = false +private let RSImageLogger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "RSImage") +private let debugLoggingEnabled = false -nonisolated public extension RSImage { +public extension RSImage { /// Create a colored image from the source image using a specified color. /// diff --git a/Modules/RSCore/Sources/RSCore/Shared/RSScreen.swift b/Modules/RSCore/Sources/RSCore/Shared/RSScreen.swift index 772baa96f..920464438 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/RSScreen.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/RSScreen.swift @@ -11,7 +11,7 @@ import AppKit public final class RSScreen { - nonisolated public static var maxScreenScale: CGFloat { + public static var maxScreenScale: CGFloat { NSScreen.screens.map(\.backingScaleFactor).max() ?? 2.0 } } diff --git a/Modules/RSCore/Sources/RSCore/Shared/Renamable.swift b/Modules/RSCore/Sources/RSCore/Shared/Renamable.swift index 283331153..a6b8b6ec1 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/Renamable.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/Renamable.swift @@ -9,14 +9,12 @@ import Foundation /// For anything that can be renamed by the user. - -public protocol Renamable { +@MainActor public protocol Renamable { /// Renames an object. /// - Parameters: /// - to: The new name for the object. /// - completion: A block called when the renaming completes or fails. /// - result: The result of the renaming. - @MainActor func rename(to: String, completion: @escaping (_ result: Result) -> Void) + func rename(to: String, completion: @escaping (_ result: Result) -> Void) } - diff --git a/Modules/RSCore/Sources/RSCore/Shared/SendToBlogEditorApp.swift b/Modules/RSCore/Sources/RSCore/Shared/SendToBlogEditorApp.swift index 2e534b070..85b1cdedf 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/SendToBlogEditorApp.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/SendToBlogEditorApp.swift @@ -11,8 +11,7 @@ import Foundation /// This is for sending articles to MarsEdit and other apps that implement the /// [send-to-blog-editor Apple Events API](http://ranchero.com/netnewswire/developers/externalinterface)\. -public struct SendToBlogEditorApp { - +@MainActor public struct SendToBlogEditorApp { ///The target descriptor of the application. /// /// The easiest way to get this is probably `UserApp.targetDescriptor` or `NSAppleEventDescriptor(runningApplication:)`. @@ -49,10 +48,8 @@ public struct SendToBlogEditorApp { self.sourceFeedURL = sourceFeedURL } - /// Sends the receiver's data to the blog editor application described by `targetDescriptor`. public func send() { - let appleEvent = NSAppleEventDescriptor(eventClass: .editDataItemAppleEventClass, eventID: .editDataItemAppleEventID, targetDescriptor: targetDescriptor, returnID: .autoGenerate, transactionID: .any) appleEvent.setParam(paramDescriptor, forKeyword: keyDirectObject) @@ -60,11 +57,9 @@ public struct SendToBlogEditorApp { let _ = try? appleEvent.sendEvent(options: [.noReply, .canSwitchLayer, .alwaysInteract], timeout: .AEDefaultTimeout) } - } private extension SendToBlogEditorApp { - var paramDescriptor: NSAppleEventDescriptor { let descriptor = NSAppleEventDescriptor.record() @@ -94,19 +89,15 @@ private extension SendToBlogEditorApp { } private extension AEEventClass { - static let editDataItemAppleEventClass = "EBlg".fourCharCode } private extension AEEventID { - static let editDataItemAppleEventID = "oitm".fourCharCode - } private extension AEKeyword { - static let dataItemTitle = "titl".fourCharCode static let dataItemDescription = "desc".fourCharCode static let dataItemSummary = "summ".fourCharCode @@ -119,22 +110,18 @@ private extension AEKeyword { static let dataItemSourceName = "snam".fourCharCode static let dataItemSourceHomeURL = "hurl".fourCharCode static let dataItemSourceFeedURL = "furl".fourCharCode - } private extension AEReturnID { - static let autoGenerate = AEReturnID(kAutoGenerateReturnID) } private extension AETransactionID { - static let any = AETransactionID(kAnyTransactionID) } private extension TimeInterval { - static let AEDefaultTimeout = TimeInterval(kAEDefaultTimeout) } diff --git a/Modules/RSCore/Sources/RSCore/Shared/SendToCommand.swift b/Modules/RSCore/Sources/RSCore/Shared/SendToCommand.swift index ff83c5f4a..15e8b2623 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/SendToCommand.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/SendToCommand.swift @@ -20,8 +20,7 @@ import UIKit /// /// See NetNewsWire. -public protocol SendToCommand { - +@MainActor public protocol SendToCommand { /// The title of the command. /// /// Often the name of the target application. diff --git a/Modules/RSCore/Sources/RSCore/Shared/String+RSCore.swift b/Modules/RSCore/Sources/RSCore/Shared/String+RSCore.swift index 58c7ebb6f..07b6ebb4f 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/String+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/String+RSCore.swift @@ -10,7 +10,7 @@ import Foundation import CommonCrypto import RSCoreObjC -nonisolated public extension String { +public extension String { func htmlByAddingLink(_ link: String, className: String? = nil) -> String { if let className = className { @@ -29,10 +29,9 @@ nonisolated public extension String { let data = Data(digest) return data.map { String(format: "%02hhx", $0) }.joined() } - } -nonisolated public extension String { +public extension String { /// An MD5 hash of the string's UTF-8 representation. var md5Hash: Data { diff --git a/Modules/RSCore/Sources/RSCore/Shared/UndoableCommand.swift b/Modules/RSCore/Sources/RSCore/Shared/UndoableCommand.swift index 6d4cb3292..737453625 100644 --- a/Modules/RSCore/Sources/RSCore/Shared/UndoableCommand.swift +++ b/Modules/RSCore/Sources/RSCore/Shared/UndoableCommand.swift @@ -8,8 +8,7 @@ import Foundation -public protocol UndoableCommand: AnyObject { - +@MainActor public protocol UndoableCommand: AnyObject { var undoActionName: String { get } var redoActionName: String { get } var undoManager: UndoManager { get } @@ -21,7 +20,6 @@ public protocol UndoableCommand: AnyObject { extension UndoableCommand { public func registerUndo() { - undoManager.setActionName(undoActionName) undoManager.registerUndo(withTarget: self) { (target) in self.undo() @@ -29,7 +27,6 @@ extension UndoableCommand { } public func registerRedo() { - undoManager.setActionName(redoActionName) undoManager.registerUndo(withTarget: self) { (target) in self.perform() @@ -39,30 +36,26 @@ extension UndoableCommand { // Useful for view controllers. -public protocol UndoableCommandRunner: AnyObject { +@MainActor public protocol UndoableCommandRunner: AnyObject { + var undoableCommands: [UndoableCommand] { get set } + var undoManager: UndoManager? { get } - @MainActor var undoableCommands: [UndoableCommand] { get set } - @MainActor var undoManager: UndoManager? { get } - - @MainActor func runCommand(_ undoableCommand: UndoableCommand) - @MainActor func clearUndoableCommands() + func runCommand(_ undoableCommand: UndoableCommand) + func clearUndoableCommands() } -public extension UndoableCommandRunner { - - @MainActor func runCommand(_ undoableCommand: UndoableCommand) { +@MainActor public extension UndoableCommandRunner { + func runCommand(_ undoableCommand: UndoableCommand) { pushUndoableCommand(undoableCommand) undoableCommand.perform() } - @MainActor func pushUndoableCommand(_ undoableCommand: UndoableCommand) { - + func pushUndoableCommand(_ undoableCommand: UndoableCommand) { undoableCommands += [undoableCommand] } - @MainActor func clearUndoableCommands() { - + func clearUndoableCommands() { // Useful, for example, when timeline is reloaded and the list of articles changes. // Otherwise things like Redo Mark Read are ambiguous. // (Do they apply to the previous articles or to the current articles?) diff --git a/Modules/RSCore/Sources/RSCore/UIKit/UIViewController+RSCore.swift b/Modules/RSCore/Sources/RSCore/UIKit/UIViewController+RSCore.swift index 23c8185b7..cf12b463f 100644 --- a/Modules/RSCore/Sources/RSCore/UIKit/UIViewController+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/UIKit/UIViewController+RSCore.swift @@ -10,8 +10,7 @@ import UIKit import SwiftUI extension UIViewController { - - // MARK: Error Handling + // MARK: - Error Handling public func presentError(title: String, message: String, dismiss: (() -> Void)? = nil) { let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) @@ -25,7 +24,7 @@ extension UIViewController { } -// MARK: SwiftUI +// MARK: - SwiftUI public struct ViewControllerHolder { public weak var value: UIViewController? diff --git a/Modules/RSCore/Sources/RSCore/UIKit/UIWindow+RSCore.swift b/Modules/RSCore/Sources/RSCore/UIKit/UIWindow+RSCore.swift index a5df7ac6b..28a52164c 100644 --- a/Modules/RSCore/Sources/RSCore/UIKit/UIWindow+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/UIKit/UIWindow+RSCore.swift @@ -5,13 +5,12 @@ // Created by Maurice Parker on 4/15/19. // Copyright © 2019 Ranchero Software. All rights reserved. // + #if os(iOS) import UIKit extension UIWindow { - public var topViewController: UIViewController? { - var top = self.rootViewController while true { if let presented = top?.presentedViewController { @@ -37,6 +36,5 @@ extension UIWindow { return top } - } #endif diff --git a/Modules/RSCore/Sources/RSCoreResources/AppKit/IndeterminateProgressWindowController.swift b/Modules/RSCore/Sources/RSCoreResources/AppKit/IndeterminateProgressWindowController.swift index 2efe1d5eb..2bc183c73 100644 --- a/Modules/RSCore/Sources/RSCoreResources/AppKit/IndeterminateProgressWindowController.swift +++ b/Modules/RSCore/Sources/RSCoreResources/AppKit/IndeterminateProgressWindowController.swift @@ -9,23 +9,11 @@ #if os(macOS) import AppKit -public func runIndeterminateProgressWithMessage(_ message: String) { - - IndeterminateProgressController.beginProgressWithMessage(message) -} - -public func stopIndeterminateProgress() { - - IndeterminateProgressController.endProgress() -} - -private final class IndeterminateProgressController { - +@MainActor private final class IndeterminateProgressController { static var windowController: IndeterminateProgressWindowController? static var runningProgressWindow = false static func beginProgressWithMessage(_ message: String) { - if runningProgressWindow { assertionFailure("Expected !runningProgressWindow.") endProgress() @@ -37,7 +25,6 @@ private final class IndeterminateProgressController { } static func endProgress() { - if !runningProgressWindow { assertionFailure("Expected runningProgressWindow.") return @@ -51,7 +38,6 @@ private final class IndeterminateProgressController { } private final class IndeterminateProgressWindowController: NSWindowController { - @IBOutlet var messageLabel: NSTextField! @IBOutlet var progressIndicator: NSProgressIndicator! @objc dynamic var message = "" @@ -63,7 +49,6 @@ private final class IndeterminateProgressWindowController: NSWindowController { } override func windowDidLoad() { - progressIndicator.startAnimation(self) } } diff --git a/Modules/RSCore/Sources/RSCoreResources/AppKit/WebViewWindowController.swift b/Modules/RSCore/Sources/RSCoreResources/AppKit/WebViewWindowController.swift index 67eb4a2a1..576ce7d18 100644 --- a/Modules/RSCore/Sources/RSCoreResources/AppKit/WebViewWindowController.swift +++ b/Modules/RSCore/Sources/RSCoreResources/AppKit/WebViewWindowController.swift @@ -11,7 +11,6 @@ import AppKit import WebKit public final class WebViewWindowController: NSWindowController { - @IBOutlet private var webview: WKWebView! private var title: String! @@ -22,12 +21,10 @@ public final class WebViewWindowController: NSWindowController { } public override func windowDidLoad() { - window!.title = title } public func displayContents(of path: String) { - // We assume there might be images, style sheets, etc. contained by the folder that the file appears in, so we get read access to the parent folder. let _ = self.window diff --git a/Modules/RSDatabase/Package.swift b/Modules/RSDatabase/Package.swift index e71cf5953..ceb5b9fc8 100644 --- a/Modules/RSDatabase/Package.swift +++ b/Modules/RSDatabase/Package.swift @@ -23,7 +23,6 @@ let package = Package( swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), .enableUpcomingFeature("InferIsolatedConformances"), - .defaultIsolation(MainActor.self) ] ), .target( diff --git a/Modules/RSDatabase/Sources/RSDatabase/Database.swift b/Modules/RSDatabase/Sources/RSDatabase/Database.swift index c73733905..53b1a5557 100644 --- a/Modules/RSDatabase/Sources/RSDatabase/Database.swift +++ b/Modules/RSDatabase/Sources/RSDatabase/Database.swift @@ -9,7 +9,7 @@ import Foundation import RSDatabaseObjC -nonisolated public enum DatabaseError: Error, LocalizedError, Sendable { +public enum DatabaseError: Error, LocalizedError, Sendable { case isSuspended // On iOS, to support background refreshing, a database may be suspended. public var errorDescription: String? { @@ -37,7 +37,7 @@ public typealias DatabaseIntCompletionBlock = (DatabaseIntResult) -> Void // MARK: - Extensions -nonisolated public extension DatabaseResult { +public extension DatabaseResult { /// Convenience for getting the database from a DatabaseResult. var database: FMDatabase? { switch self { diff --git a/Modules/RSDatabase/Sources/RSDatabase/DatabaseObject.swift b/Modules/RSDatabase/Sources/RSDatabase/DatabaseObject.swift index 89ef5f97b..aa5f166db 100644 --- a/Modules/RSDatabase/Sources/RSDatabase/DatabaseObject.swift +++ b/Modules/RSDatabase/Sources/RSDatabase/DatabaseObject.swift @@ -10,7 +10,7 @@ import Foundation public typealias DatabaseDictionary = [String: Any] -nonisolated public protocol DatabaseObject: Sendable { +public protocol DatabaseObject: Sendable { var databaseID: String { get } @@ -19,7 +19,7 @@ nonisolated public protocol DatabaseObject: Sendable { func relatedObjectsWithName(_ name: String) -> [DatabaseObject]? } -nonisolated public extension DatabaseObject { +public extension DatabaseObject { func relatedObjectsWithName(_ name: String) -> [DatabaseObject]? { @@ -27,7 +27,7 @@ nonisolated public extension DatabaseObject { } } -nonisolated extension Array where Element == DatabaseObject { +extension Array where Element == DatabaseObject { func dictionary() -> [String: DatabaseObject] { diff --git a/Modules/RSDatabase/Sources/RSDatabase/DatabaseObjectCache.swift b/Modules/RSDatabase/Sources/RSDatabase/DatabaseObjectCache.swift index a12a08985..52834d8d2 100644 --- a/Modules/RSDatabase/Sources/RSDatabase/DatabaseObjectCache.swift +++ b/Modules/RSDatabase/Sources/RSDatabase/DatabaseObjectCache.swift @@ -9,7 +9,7 @@ import Foundation import Synchronization -nonisolated public final class DatabaseObjectCache: Sendable { +public final class DatabaseObjectCache: Sendable { private let state = Mutex([String: DatabaseObject]()) public init() { diff --git a/Modules/RSDatabase/Sources/RSDatabase/DatabaseQueue.swift b/Modules/RSDatabase/Sources/RSDatabase/DatabaseQueue.swift index c162f55d7..3b9d1636d 100644 --- a/Modules/RSDatabase/Sources/RSDatabase/DatabaseQueue.swift +++ b/Modules/RSDatabase/Sources/RSDatabase/DatabaseQueue.swift @@ -16,7 +16,7 @@ import RSDatabaseObjC /// /// On iOS, the queue can be suspended /// in order to support background refreshing. -nonisolated public final class DatabaseQueue: Sendable { +public final class DatabaseQueue: Sendable { private struct State { var isCallingDatabase = false var isSuspended = false @@ -201,7 +201,7 @@ nonisolated public final class DatabaseQueue: Sendable { } } -nonisolated private extension DatabaseQueue { +private extension DatabaseQueue { private func _runInDatabase(_ state: inout State, _ databaseBlock: DatabaseBlock, _ useTransaction: Bool) { precondition(!state.isCallingDatabase) diff --git a/Modules/RSDatabase/Sources/RSDatabase/DatabaseTable.swift b/Modules/RSDatabase/Sources/RSDatabase/DatabaseTable.swift index ff209e6b1..b4e634580 100644 --- a/Modules/RSDatabase/Sources/RSDatabase/DatabaseTable.swift +++ b/Modules/RSDatabase/Sources/RSDatabase/DatabaseTable.swift @@ -9,12 +9,12 @@ import Foundation import RSDatabaseObjC -nonisolated public protocol DatabaseTable { +public protocol DatabaseTable { var name: String { get } } -nonisolated public extension DatabaseTable { +public extension DatabaseTable { // MARK: Fetching diff --git a/Modules/RSDatabase/Sources/RSDatabase/FMDatabase+Extras.swift b/Modules/RSDatabase/Sources/RSDatabase/FMDatabase+Extras.swift index 3f9df4793..ea523ff63 100644 --- a/Modules/RSDatabase/Sources/RSDatabase/FMDatabase+Extras.swift +++ b/Modules/RSDatabase/Sources/RSDatabase/FMDatabase+Extras.swift @@ -8,7 +8,7 @@ import Foundation import RSDatabaseObjC -nonisolated public extension FMDatabase { +public extension FMDatabase { static func openAndSetUpDatabase(path: String) -> FMDatabase { let database = FMDatabase(path: path)! diff --git a/Modules/RSDatabase/Sources/RSDatabase/FMResultSet+Extras.swift b/Modules/RSDatabase/Sources/RSDatabase/FMResultSet+Extras.swift index 4b22fddb3..1dfb24d19 100644 --- a/Modules/RSDatabase/Sources/RSDatabase/FMResultSet+Extras.swift +++ b/Modules/RSDatabase/Sources/RSDatabase/FMResultSet+Extras.swift @@ -8,7 +8,7 @@ import Foundation import RSDatabaseObjC -nonisolated public extension FMResultSet { +public extension FMResultSet { func intWithCountResult() -> Int? { guard next() else { diff --git a/Modules/RSDatabase/Sources/RSDatabase/Related Objects/DatabaseLookupTable.swift b/Modules/RSDatabase/Sources/RSDatabase/Related Objects/DatabaseLookupTable.swift index 3b756bd69..ea4918ffb 100644 --- a/Modules/RSDatabase/Sources/RSDatabase/Related Objects/DatabaseLookupTable.swift +++ b/Modules/RSDatabase/Sources/RSDatabase/Related Objects/DatabaseLookupTable.swift @@ -14,7 +14,7 @@ import RSDatabaseObjC // Example: CREATE TABLE if not EXISTS authorLookup (authorID TEXT NOT NULL, articleID TEXT NOT NULL, PRIMARY KEY(authorID, articleID)); // articleID is objectID; authorID is relatedObjectID. -nonisolated public final class DatabaseLookupTable: Sendable { +public final class DatabaseLookupTable: Sendable { private let name: String private let objectIDKey: String private let relatedObjectIDKey: String @@ -86,7 +86,7 @@ nonisolated public final class DatabaseLookupTable: Sendable { // MARK: - Private -nonisolated private extension DatabaseLookupTable { +private extension DatabaseLookupTable { // MARK: Removing diff --git a/Modules/RSDatabase/Sources/RSDatabase/Related Objects/DatabaseRelatedObjectsTable.swift b/Modules/RSDatabase/Sources/RSDatabase/Related Objects/DatabaseRelatedObjectsTable.swift index 32b059474..dfcd40daf 100644 --- a/Modules/RSDatabase/Sources/RSDatabase/Related Objects/DatabaseRelatedObjectsTable.swift +++ b/Modules/RSDatabase/Sources/RSDatabase/Related Objects/DatabaseRelatedObjectsTable.swift @@ -11,7 +11,7 @@ import RSDatabaseObjC // Protocol for a database table for related objects — authors and attachments in NetNewsWire, for instance. -nonisolated public protocol DatabaseRelatedObjectsTable: DatabaseTable, Sendable { +public protocol DatabaseRelatedObjectsTable: DatabaseTable, Sendable { var databaseIDKey: String { get} var cache: DatabaseObjectCache { get } @@ -23,7 +23,7 @@ nonisolated public protocol DatabaseRelatedObjectsTable: DatabaseTable, Sendable func save(_ objects: [DatabaseObject], in database: FMDatabase) } -nonisolated public extension DatabaseRelatedObjectsTable { +public extension DatabaseRelatedObjectsTable { // MARK: Default implementations diff --git a/Modules/RSDatabase/Sources/RSDatabase/Related Objects/RelatedObjectIDsMap.swift b/Modules/RSDatabase/Sources/RSDatabase/Related Objects/RelatedObjectIDsMap.swift index 69e20e52d..318f8f339 100644 --- a/Modules/RSDatabase/Sources/RSDatabase/Related Objects/RelatedObjectIDsMap.swift +++ b/Modules/RSDatabase/Sources/RSDatabase/Related Objects/RelatedObjectIDsMap.swift @@ -10,8 +10,7 @@ import Foundation // Maps objectIDs to Set where the Strings are relatedObjectIDs. -nonisolated struct RelatedObjectIDsMap: Sendable { - +struct RelatedObjectIDsMap: Sendable { private let dictionary: [String: Set] // objectID: Set init(dictionary: [String: Set]) { @@ -56,7 +55,7 @@ nonisolated struct RelatedObjectIDsMap: Sendable { } } -nonisolated struct LookupValue: Hashable, Sendable { +struct LookupValue: Hashable, Sendable { let objectID: String let relatedObjectID: String } diff --git a/Modules/RSDatabase/Sources/RSDatabase/Related Objects/RelatedObjectsMap.swift b/Modules/RSDatabase/Sources/RSDatabase/Related Objects/RelatedObjectsMap.swift index 25e292c17..1c7abbb8c 100644 --- a/Modules/RSDatabase/Sources/RSDatabase/Related Objects/RelatedObjectsMap.swift +++ b/Modules/RSDatabase/Sources/RSDatabase/Related Objects/RelatedObjectsMap.swift @@ -11,7 +11,7 @@ import Foundation // Map objectID to [DatabaseObject] (related objects). // It’s used as the return value for DatabaseLookupTable.fetchRelatedObjects. -nonisolated public struct RelatedObjectsMap: Sendable { +public struct RelatedObjectsMap: Sendable { private let dictionary: [String: [DatabaseObject]] // objectID: relatedObjects init(relatedObjects: [DatabaseObject], relatedObjectIDsMap: RelatedObjectIDsMap) { diff --git a/Modules/RSDatabase/Sources/RSDatabaseObjC/RSDatabaseQueue.h b/Modules/RSDatabase/Sources/RSDatabaseObjC/RSDatabaseQueue.h deleted file mode 100755 index a9bbb75e2..000000000 --- a/Modules/RSDatabase/Sources/RSDatabaseObjC/RSDatabaseQueue.h +++ /dev/null @@ -1,63 +0,0 @@ -// -// RSDatabaseQueue.h -// RSDatabase -// -// Created by Brent Simmons on 10/19/13. -// Copyright (c) 2013 Ranchero Software, LLC. All rights reserved. -// - -@import Foundation; -#import "FMDatabase.h" - -// This has been deprecated — use DatabaseQueue instead. - -@class RSDatabaseQueue; - -NS_ASSUME_NONNULL_BEGIN - -@protocol RSDatabaseQueueDelegate - -@optional - -- (void)makeFunctionsForDatabase:(FMDatabase *)database queue:(RSDatabaseQueue *)queue; - -@end - - -// Everything runs on a serial queue. - -typedef void (^RSDatabaseBlock)(FMDatabase * __nonnull database); - - -@interface RSDatabaseQueue : NSObject - -@property (nonatomic, strong, readonly) NSString *databasePath; // For debugging use, so you can open the database in sqlite3. - -- (instancetype)initWithFilepath:(NSString *)filepath excludeFromBackup:(BOOL)excludeFromBackup; - -@property (nonatomic, weak) id delegate; - -// You can feed it the contents of a file that includes comments, etc. -// Lines that start with case-insensitive "create " are executed. -- (void)createTablesUsingStatements:(NSString *)createStatements; -- (void)createTablesUsingStatementsSync:(NSString *)createStatements; - -- (void)update:(RSDatabaseBlock)updateBlock; -- (void)updateSync:(RSDatabaseBlock)updateBlock; - -- (void)runInDatabase:(RSDatabaseBlock)databaseBlock; // Same as update, but no transaction. - -- (void)fetch:(RSDatabaseBlock)fetchBlock; -- (void)fetchSync:(RSDatabaseBlock)fetchBlock; - -- (void)vacuum; -- (void)vacuumIfNeeded; // defaultsKey = @"lastVacuumDate"; interval is 6 days. -- (void)vacuumIfNeeded:(NSString *)defaultsKey intervalBetweenVacuums:(NSTimeInterval)intervalBetweenVacuums; - -- (NSArray *)arrayWithSingleColumnResultSet:(FMResultSet *)rs; - -- (void)close; - -@end - -NS_ASSUME_NONNULL_END diff --git a/Modules/RSDatabase/Sources/RSDatabaseObjC/RSDatabaseQueue.m b/Modules/RSDatabase/Sources/RSDatabaseObjC/RSDatabaseQueue.m deleted file mode 100755 index e7b192e0e..000000000 --- a/Modules/RSDatabase/Sources/RSDatabaseObjC/RSDatabaseQueue.m +++ /dev/null @@ -1,227 +0,0 @@ -// -// RSDatabaseQueue.m -// RSDatabase -// -// Created by Brent Simmons on 10/19/13. -// Copyright (c) 2013 Ranchero Software, LLC. All rights reserved. -// - -#import "RSDatabaseQueue.h" -#import - -// This has been deprecated — use DatabaseQueue instead. - -@interface RSDatabaseQueue () - -@property (nonatomic, strong, readwrite) NSString *databasePath; -@property (nonatomic, assign) BOOL excludeFromBackup; -@property (nonatomic, strong, readonly) dispatch_queue_t serialDispatchQueue; -@property (nonatomic) BOOL closing; -@property (nonatomic) BOOL closed; - -@end - - -@implementation RSDatabaseQueue - - -#pragma mark - Init - -- (instancetype)initWithFilepath:(NSString *)filepath excludeFromBackup:(BOOL)excludeFromBackup { - - self = [super init]; - if (self == nil) - return self; - - _databasePath = filepath; - - _serialDispatchQueue = dispatch_queue_create([[NSString stringWithFormat:@"RSDatabaseQueue serial queue - %@", filepath.lastPathComponent] UTF8String], DISPATCH_QUEUE_SERIAL); - - _excludeFromBackup = excludeFromBackup; - - return self; -} - - -#pragma mark - Database - -- (FMDatabase *)database { - - /*I've always done it this way -- kept a per-thread database in the threadDictionary -- and I know it's solid. Maybe it's not necessary with a serial queue, but my understanding was that SQLite wanted a different database per thread (and a serial queue may run on different threads).*/ - - if (self.closed) { - return nil; - } - - NSMutableDictionary *threadDictionary = [[NSThread currentThread] threadDictionary]; - FMDatabase *database = threadDictionary[self.databasePath]; - - if (!database || !database.open) { - - database = [FMDatabase databaseWithPath:self.databasePath]; - [database open]; - [database executeUpdate:@"PRAGMA synchronous = 1;"]; - [database setShouldCacheStatements:YES]; - - if ([self.delegate respondsToSelector:@selector(makeFunctionsForDatabase:queue:)]) { - [self.delegate makeFunctionsForDatabase:database queue:self]; - } - - threadDictionary[self.databasePath] = database; - - if (self.excludeFromBackup) { - - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - NSURL *URL = [NSURL fileURLWithPath:self.databasePath isDirectory:NO]; - NSError *error = nil; - [URL setResourceValue:@YES forKey:NSURLIsExcludedFromBackupKey error:&error]; - }); - } - } - - return database; -} - -#pragma mark - API - -- (void)createTablesUsingStatements:(NSString *)createStatements { - - [self runInDatabase:^(FMDatabase *database) { - [self runCreateStatements:createStatements database:database]; - }]; -} - - -- (void)createTablesUsingStatementsSync:(NSString *)createStatements { - - [self runInDatabaseSync:^(FMDatabase *database) { - [self runCreateStatements:createStatements database:database]; - }]; -} - -- (void)runCreateStatements:(NSString *)createStatements database:(FMDatabase *)database { - - [createStatements enumerateLinesUsingBlock:^(NSString *line, BOOL *stop) { - if ([line.lowercaseString hasPrefix:@"create "]) { - [database executeUpdate:line]; - } - *stop = NO; - }]; -} - -- (void)update:(RSDatabaseBlock)updateBlock { - - dispatch_async(self.serialDispatchQueue, ^{ - [self runInTransaction:updateBlock]; - }); -} - - -- (void)updateSync:(RSDatabaseBlock)updateBlock { - - dispatch_sync(self.serialDispatchQueue, ^{ - [self runInTransaction:updateBlock]; - }); -} - -- (void)runInTransaction:(RSDatabaseBlock)databaseBlock { - - @autoreleasepool { - FMDatabase *database = [self database]; - [database beginTransaction]; - databaseBlock(database); - [database commit]; - } -} - -- (void)runInDatabase:(RSDatabaseBlock)databaseBlock { - - dispatch_async(self.serialDispatchQueue, ^{ - @autoreleasepool { - databaseBlock([self database]); - } - }); -} - - -- (void)runInDatabaseSync:(RSDatabaseBlock)databaseBlock { - - dispatch_sync(self.serialDispatchQueue, ^{ - @autoreleasepool { - databaseBlock([self database]); - } - }); -} - -- (void)fetch:(RSDatabaseBlock)fetchBlock { - - [self runInDatabase:fetchBlock]; -} - - -- (void)fetchSync:(RSDatabaseBlock)fetchBlock { - - dispatch_sync(self.serialDispatchQueue, ^{ - @autoreleasepool { - fetchBlock([self database]); - } - }); -} - - -- (void)vacuum { - - dispatch_async(self.serialDispatchQueue, ^{ - @autoreleasepool { - [[self database] executeUpdate:@"vacuum;"]; - } - }); -} - -- (void)vacuumIfNeeded { - - NSTimeInterval interval = (24 * 60 * 60) * 6; // 6 days - [self vacuumIfNeeded:@"lastVacuumDate" intervalBetweenVacuums:interval]; -} - - -- (void)vacuumIfNeeded:(NSString *)defaultsKey intervalBetweenVacuums:(NSTimeInterval)intervalBetweenVacuums { - - NSDate *lastVacuumDate = [[NSUserDefaults standardUserDefaults] objectForKey:defaultsKey]; - if (!lastVacuumDate || ![lastVacuumDate isKindOfClass:[NSDate class]]) { - [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:defaultsKey]; - return; - } - - NSDate *cutoffDate = [[NSDate date] dateByAddingTimeInterval: -(intervalBetweenVacuums)]; - if ([cutoffDate earlierDate:lastVacuumDate] == lastVacuumDate) { - [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:defaultsKey]; - [self vacuum]; - } -} - - -- (NSArray *)arrayWithSingleColumnResultSet:(FMResultSet *)rs { - - NSMutableArray *results = [NSMutableArray new]; - while ([rs next]) { - id oneObject = [rs objectForColumnIndex:0]; - if (oneObject) { - [results addObject:oneObject]; - } - } - - return [results copy]; -} - -- (void)close { - self.closing = YES; - [self runInDatabaseSync:^(FMDatabase *database) { - self.closed = YES; - [database close]; - }]; -} - -@end - diff --git a/Modules/RSDatabase/Sources/RSDatabaseObjC/include/RSDatabaseObjC.h b/Modules/RSDatabase/Sources/RSDatabaseObjC/include/RSDatabaseObjC.h index 9203707bc..8b158e412 100644 --- a/Modules/RSDatabase/Sources/RSDatabaseObjC/include/RSDatabaseObjC.h +++ b/Modules/RSDatabase/Sources/RSDatabaseObjC/include/RSDatabaseObjC.h @@ -11,7 +11,3 @@ #import "../FMDatabase+RSExtras.h" #import "../FMResultSet+RSExtras.h" #import "../NSString+RSDatabase.h" - -// RSDatabase - -#import "../RSDatabaseQueue.h" diff --git a/Modules/RSMarkdown/Package.swift b/Modules/RSMarkdown/Package.swift index c6a00a65b..edd9cfd08 100644 --- a/Modules/RSMarkdown/Package.swift +++ b/Modules/RSMarkdown/Package.swift @@ -21,7 +21,6 @@ let package = Package( swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), .enableUpcomingFeature("InferIsolatedConformances"), - .defaultIsolation(MainActor.self), .unsafeFlags(["-warnings-as-errors"]) ] ), diff --git a/Modules/RSMarkdown/Sources/RSMarkdown/RSMarkdown.swift b/Modules/RSMarkdown/Sources/RSMarkdown/RSMarkdown.swift index 4a3a113e5..8709605fd 100644 --- a/Modules/RSMarkdown/Sources/RSMarkdown/RSMarkdown.swift +++ b/Modules/RSMarkdown/Sources/RSMarkdown/RSMarkdown.swift @@ -8,8 +8,7 @@ import Foundation import Markdown -nonisolated public struct RSMarkdown { - +public struct RSMarkdown { /// Converts Markdown text to HTML string /// - Parameter markdown: The Markdown text to convert /// - Returns: HTML string representation of the Markdown diff --git a/Modules/RSParser/Package.swift b/Modules/RSParser/Package.swift index 4b59b856f..d3c384d0c 100644 --- a/Modules/RSParser/Package.swift +++ b/Modules/RSParser/Package.swift @@ -25,7 +25,6 @@ let package = Package( swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), .enableUpcomingFeature("InferIsolatedConformances"), - .defaultIsolation(MainActor.self) ]), .target( name: "RSParserObjC", @@ -39,6 +38,11 @@ let package = Package( name: "RSParserTests", dependencies: ["RSParser"], exclude: ["Info.plist"], - resources: [.copy("Resources")]), + resources: [.copy("Resources")], + swiftSettings: [ + .enableUpcomingFeature("NonisolatedNonsendingByDefault"), + .enableUpcomingFeature("InferIsolatedConformances"), + ] + ), ] ) diff --git a/Modules/RSParser/Sources/Swift/Feeds/FeedParser.swift b/Modules/RSParser/Sources/Swift/Feeds/FeedParser.swift index 71551e2a0..f6eda8bec 100644 --- a/Modules/RSParser/Sources/Swift/Feeds/FeedParser.swift +++ b/Modules/RSParser/Sources/Swift/Feeds/FeedParser.swift @@ -14,7 +14,7 @@ import RSParserObjC public typealias FeedParserCallback = @Sendable (_ parsedFeed: ParsedFeed?, _ error: Error?) -> Void -nonisolated public struct FeedParser { +public struct FeedParser { private static let parseQueue = DispatchQueue(label: "FeedParser parse queue") diff --git a/Modules/RSParser/Sources/Swift/Feeds/FeedType.swift b/Modules/RSParser/Sources/Swift/Feeds/FeedType.swift index c7857398f..cbd16b1ab 100644 --- a/Modules/RSParser/Sources/Swift/Feeds/FeedType.swift +++ b/Modules/RSParser/Sources/Swift/Feeds/FeedType.swift @@ -11,7 +11,7 @@ import Foundation import RSParserObjC #endif -nonisolated public enum FeedType: Sendable { +public enum FeedType: Sendable { case rss case atom case jsonFeed @@ -21,9 +21,9 @@ nonisolated public enum FeedType: Sendable { } -nonisolated private let minNumberOfBytesRequired = 128 +private let minNumberOfBytesRequired = 128 -nonisolated public func feedType(_ parserData: ParserData, isPartialData: Bool = false) -> FeedType { +public func feedType(_ parserData: ParserData, isPartialData: Bool = false) -> FeedType { // Can call with partial data — while still downloading, for instance. // If there’s not enough data, return .unknown. Ask again when there’s more data. diff --git a/Modules/RSParser/Sources/Swift/Feeds/JSON/JSONFeedParser.swift b/Modules/RSParser/Sources/Swift/Feeds/JSON/JSONFeedParser.swift index 8aaa7bff2..6c76b030b 100644 --- a/Modules/RSParser/Sources/Swift/Feeds/JSON/JSONFeedParser.swift +++ b/Modules/RSParser/Sources/Swift/Feeds/JSON/JSONFeedParser.swift @@ -13,7 +13,7 @@ import RSParserObjC // See https://jsonfeed.org/version/1.1 -nonisolated public struct JSONFeedParser { +public struct JSONFeedParser { struct Key { static let version = "version" @@ -85,7 +85,7 @@ nonisolated public struct JSONFeedParser { } } -nonisolated private extension JSONFeedParser { +private extension JSONFeedParser { static func parseAuthors(_ dictionary: JSONDictionary) -> Set? { diff --git a/Modules/RSParser/Sources/Swift/Feeds/JSON/RSSInJSONParser.swift b/Modules/RSParser/Sources/Swift/Feeds/JSON/RSSInJSONParser.swift index 612a5ece3..ec02a9e2d 100644 --- a/Modules/RSParser/Sources/Swift/Feeds/JSON/RSSInJSONParser.swift +++ b/Modules/RSParser/Sources/Swift/Feeds/JSON/RSSInJSONParser.swift @@ -14,7 +14,7 @@ import RSParserObjC // See https://github.com/scripting/Scripting-News/blob/master/rss-in-json/README.md // Also: http://cyber.harvard.edu/rss/rss.html -nonisolated public struct RSSInJSONParser { +public struct RSSInJSONParser { public static func parse(_ parserData: ParserData) throws -> ParsedFeed? { do { @@ -59,7 +59,7 @@ nonisolated public struct RSSInJSONParser { } } -nonisolated private extension RSSInJSONParser { +private extension RSSInJSONParser { static func parseItems(_ itemsObject: JSONArray, _ feedURL: String) -> Set { diff --git a/Modules/RSParser/Sources/Swift/Feeds/ParsedAttachment.swift b/Modules/RSParser/Sources/Swift/Feeds/ParsedAttachment.swift index aa782c634..f1f0eda33 100644 --- a/Modules/RSParser/Sources/Swift/Feeds/ParsedAttachment.swift +++ b/Modules/RSParser/Sources/Swift/Feeds/ParsedAttachment.swift @@ -8,7 +8,7 @@ import Foundation -nonisolated public struct ParsedAttachment: Hashable, Sendable { +public struct ParsedAttachment: Hashable, Sendable { public let url: String public let mimeType: String? public let title: String? diff --git a/Modules/RSParser/Sources/Swift/Feeds/ParsedAuthor.swift b/Modules/RSParser/Sources/Swift/Feeds/ParsedAuthor.swift index 8d85d6899..d28f02fdb 100644 --- a/Modules/RSParser/Sources/Swift/Feeds/ParsedAuthor.swift +++ b/Modules/RSParser/Sources/Swift/Feeds/ParsedAuthor.swift @@ -8,7 +8,7 @@ import Foundation -nonisolated public struct ParsedAuthor: Hashable, Codable, Sendable { +public struct ParsedAuthor: Hashable, Codable, Sendable { public let name: String? public let url: String? diff --git a/Modules/RSParser/Sources/Swift/Feeds/ParsedFeed.swift b/Modules/RSParser/Sources/Swift/Feeds/ParsedFeed.swift index 8a8442301..105b3d885 100644 --- a/Modules/RSParser/Sources/Swift/Feeds/ParsedFeed.swift +++ b/Modules/RSParser/Sources/Swift/Feeds/ParsedFeed.swift @@ -8,7 +8,7 @@ import Foundation -nonisolated public struct ParsedFeed: Sendable { +public struct ParsedFeed: Sendable { public let type: FeedType public let title: String? public let homePageURL: String? diff --git a/Modules/RSParser/Sources/Swift/Feeds/ParsedHub.swift b/Modules/RSParser/Sources/Swift/Feeds/ParsedHub.swift index d4c8317a1..a2d17dc71 100644 --- a/Modules/RSParser/Sources/Swift/Feeds/ParsedHub.swift +++ b/Modules/RSParser/Sources/Swift/Feeds/ParsedHub.swift @@ -8,7 +8,7 @@ import Foundation -nonisolated public struct ParsedHub: Hashable, Sendable { +public struct ParsedHub: Hashable, Sendable { public let type: String public let url: String } diff --git a/Modules/RSParser/Sources/Swift/Feeds/ParsedItem.swift b/Modules/RSParser/Sources/Swift/Feeds/ParsedItem.swift index 75c37cf63..035d3e17d 100644 --- a/Modules/RSParser/Sources/Swift/Feeds/ParsedItem.swift +++ b/Modules/RSParser/Sources/Swift/Feeds/ParsedItem.swift @@ -9,8 +9,7 @@ import Foundation import RSMarkdown -nonisolated public struct ParsedItem: Hashable, Sendable { - +public struct ParsedItem: Hashable, Sendable { public let syncServiceID: String? //Nil when not syncing public let uniqueID: String //RSS guid, for instance; may be calculated public let feedURL: String @@ -73,4 +72,3 @@ nonisolated public struct ParsedItem: Hashable, Sendable { } } } - diff --git a/Modules/RSParser/Sources/Swift/Feeds/XML/AtomParser.swift b/Modules/RSParser/Sources/Swift/Feeds/XML/AtomParser.swift index 9a060f5ca..ad6b6648f 100644 --- a/Modules/RSParser/Sources/Swift/Feeds/XML/AtomParser.swift +++ b/Modules/RSParser/Sources/Swift/Feeds/XML/AtomParser.swift @@ -20,7 +20,7 @@ import RSParserObjC // // In general, you should see FeedParser.swift for all your feed-parsing needs. -nonisolated public struct AtomParser { +public struct AtomParser { public static func parse(_ parserData: ParserData) -> ParsedFeed? { diff --git a/Modules/RSParser/Sources/Swift/Feeds/XML/RSParsedFeedTransformer.swift b/Modules/RSParser/Sources/Swift/Feeds/XML/RSParsedFeedTransformer.swift index 1f73bb195..e03537449 100644 --- a/Modules/RSParser/Sources/Swift/Feeds/XML/RSParsedFeedTransformer.swift +++ b/Modules/RSParser/Sources/Swift/Feeds/XML/RSParsedFeedTransformer.swift @@ -16,7 +16,7 @@ import RSParserObjC // These functions take an RSParsedFeed and return a Swift-y ParsedFeed, // which is part of providing a single API for feed parsing. -nonisolated struct RSParsedFeedTransformer { +struct RSParsedFeedTransformer { static func parsedFeed(_ rsParsedFeed: RSParsedFeed) -> ParsedFeed { @@ -25,7 +25,7 @@ nonisolated struct RSParsedFeedTransformer { } } -nonisolated private extension RSParsedFeedTransformer { +private extension RSParsedFeedTransformer { static func parsedItems(_ parsedArticles: Set) -> Set { diff --git a/Modules/RSParser/Sources/Swift/Feeds/XML/RSSParser.swift b/Modules/RSParser/Sources/Swift/Feeds/XML/RSSParser.swift index c99447fdb..f14d9c75d 100644 --- a/Modules/RSParser/Sources/Swift/Feeds/XML/RSSParser.swift +++ b/Modules/RSParser/Sources/Swift/Feeds/XML/RSSParser.swift @@ -17,7 +17,7 @@ import RSParserObjC // // In general, you should see FeedParser.swift for all your feed-parsing needs. -nonisolated public struct RSSParser { +public struct RSSParser { public static func parse(_ parserData: ParserData) -> ParsedFeed? { diff --git a/Modules/RSParser/Sources/Swift/JSON/JSONUtilities.swift b/Modules/RSParser/Sources/Swift/JSON/JSONUtilities.swift index c2bc621a5..cb4b131d1 100644 --- a/Modules/RSParser/Sources/Swift/JSON/JSONUtilities.swift +++ b/Modules/RSParser/Sources/Swift/JSON/JSONUtilities.swift @@ -8,20 +8,17 @@ import Foundation -nonisolated public struct JSONUtilities { +public struct JSONUtilities { public static func object(with data: Data) -> Any? { - return try? JSONSerialization.jsonObject(with: data) } public static func dictionary(with data: Data) -> JSONDictionary? { - return object(with: data) as? JSONDictionary } public static func array(with data: Data) -> JSONArray? { - return object(with: data) as? JSONArray } } diff --git a/Modules/RSParser/Sources/Swift/Utilities/String+RSParser.swift b/Modules/RSParser/Sources/Swift/Utilities/String+RSParser.swift index b9b1d045a..cf86bcee0 100644 --- a/Modules/RSParser/Sources/Swift/Utilities/String+RSParser.swift +++ b/Modules/RSParser/Sources/Swift/Utilities/String+RSParser.swift @@ -8,7 +8,7 @@ import Foundation -nonisolated extension String { +extension String { var nilIfEmptyOrWhitespace: String? { return self.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty ? nil : self diff --git a/Modules/RSTree/Package.swift b/Modules/RSTree/Package.swift index ce7b8e5d4..b570f1cec 100644 --- a/Modules/RSTree/Package.swift +++ b/Modules/RSTree/Package.swift @@ -17,7 +17,6 @@ let package = Package( swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), .enableUpcomingFeature("InferIsolatedConformances"), - .defaultIsolation(MainActor.self) ]), ] ) diff --git a/Modules/RSTree/Sources/RSTree/Node.swift b/Modules/RSTree/Sources/RSTree/Node.swift index 7fa899673..4cf18a2d0 100644 --- a/Modules/RSTree/Sources/RSTree/Node.swift +++ b/Modules/RSTree/Sources/RSTree/Node.swift @@ -8,10 +8,7 @@ import Foundation -// Main thread only. - -public final class Node: Hashable { - +@MainActor public final class Node: Hashable { public weak var parent: Node? public let representedObject: AnyObject public var canHaveChildNodes = false @@ -54,7 +51,6 @@ public final class Node: Hashable { } public init(representedObject: AnyObject, parent: Node?) { - precondition(Thread.isMainThread) self.representedObject = representedObject @@ -65,14 +61,12 @@ public final class Node: Hashable { } public class func genericRootNode() -> Node { - let node = Node(representedObject: TopLevelRepresentedObject(), parent: nil) node.canHaveChildNodes = true return node } public func existingOrNewChildNode(with representedObject: AnyObject) -> Node { - if let node = childNodeRepresentingObject(representedObject) { return node } @@ -80,13 +74,11 @@ public final class Node: Hashable { } public func createChildNode(_ representedObject: AnyObject) -> Node { - // Just creates — doesn’t add it. return Node(representedObject: representedObject, parent: self) } public func childAtIndex(_ index: Int) -> Node? { - if index >= childNodes.count || index < 0 { return nil } @@ -94,7 +86,6 @@ public final class Node: Hashable { } public func indexOfChild(_ node: Node) -> Int? { - return childNodes.firstIndex{ (oneChildNode) -> Bool in oneChildNode === node } @@ -113,7 +104,6 @@ public final class Node: Hashable { } public func hasAncestor(in nodes: [Node]) -> Bool { - for node in nodes { if node.isAncestor(of: self) { return true @@ -123,7 +113,6 @@ public final class Node: Hashable { } public func isAncestor(of node: Node) -> Bool { - if node == self { return false } @@ -141,13 +130,11 @@ public final class Node: Hashable { } public class func nodesOrganizedByParent(_ nodes: [Node]) -> [Node: [Node]] { - let nodesWithParents = nodes.filter { $0.parent != nil } return Dictionary(grouping: nodesWithParents, by: { $0.parent! }) } public class func indexSetsGroupedByParent(_ nodes: [Node]) -> [Node: IndexSet] { - let d = nodesOrganizedByParent(nodes) let indexSetDictionary = d.mapValues { (nodes) -> IndexSet in @@ -183,7 +170,7 @@ public final class Node: Hashable { } -public extension Array where Element == Node { +@MainActor public extension Array where Element == Node { func representedObjects() -> [AnyObject] { return self.map{ $0.representedObject } @@ -193,7 +180,6 @@ public extension Array where Element == Node { private extension Node { func findNodeRepresentingObject(_ obj: AnyObject, recursively: Bool = false) -> Node? { - for childNode in childNodes { if childNode.representedObject === obj { return childNode @@ -207,7 +193,6 @@ private extension Node { } func findNode(where test: (Node) -> Bool, recursively: Bool = false) -> Node? { - for childNode in childNodes { if test(childNode) { return childNode @@ -219,5 +204,4 @@ private extension Node { return nil } - } diff --git a/Modules/RSTree/Sources/RSTree/NodePath.swift b/Modules/RSTree/Sources/RSTree/NodePath.swift index 020d358e5..68d57702b 100644 --- a/Modules/RSTree/Sources/RSTree/NodePath.swift +++ b/Modules/RSTree/Sources/RSTree/NodePath.swift @@ -8,7 +8,7 @@ import Foundation -public struct NodePath { +@MainActor public struct NodePath { let components: [Node] public init(node: Node) { @@ -30,7 +30,6 @@ public struct NodePath { } public init?(representedObject: AnyObject, treeController: TreeController) { - if let node = treeController.nodeInTreeRepresentingObject(representedObject) { self.init(node: node) } diff --git a/Modules/RSTree/Sources/RSTree/TreeController.swift b/Modules/RSTree/Sources/RSTree/TreeController.swift index 856498990..458d06bb2 100644 --- a/Modules/RSTree/Sources/RSTree/TreeController.swift +++ b/Modules/RSTree/Sources/RSTree/TreeController.swift @@ -14,38 +14,33 @@ public protocol TreeControllerDelegate: AnyObject { public typealias NodeVisitBlock = (_ : Node) -> Void -public final class TreeController { +@MainActor public final class TreeController { private weak var delegate: TreeControllerDelegate? public let rootNode: Node public init(delegate: TreeControllerDelegate, rootNode: Node) { - self.delegate = delegate self.rootNode = rootNode rebuild() } public convenience init(delegate: TreeControllerDelegate) { - self.init(delegate: delegate, rootNode: Node.genericRootNode()) } @discardableResult public func rebuild() -> Bool { - // Rebuild and re-sort. Return true if any changes in the entire tree. return rebuildChildNodes(node: rootNode) } public func visitNodes(_ visitBlock: NodeVisitBlock) { - visitNode(rootNode, visitBlock) } public func nodeInArrayRepresentingObject(nodes: [Node], representedObject: AnyObject, recurse: Bool = false) -> Node? { - for oneNode in nodes { if oneNode.representedObject === representedObject { @@ -63,12 +58,10 @@ public final class TreeController { } public func nodeInTreeRepresentingObject(_ representedObject: AnyObject) -> Node? { - return nodeInArrayRepresentingObject(nodes: [rootNode], representedObject: representedObject, recurse: true) } public func normalizedSelectedNodes(_ nodes: [Node]) -> [Node] { - // An array of nodes might include a leaf node and its parent. Remove the leaf node. var normalizedNodes = [Node]() @@ -86,7 +79,6 @@ public final class TreeController { private extension TreeController { func visitNode(_ node: Node, _ visitBlock: NodeVisitBlock) { - visitBlock(node) node.childNodes.forEach{ (oneChildNode) in visitNode(oneChildNode, visitBlock) @@ -94,7 +86,6 @@ private extension TreeController { } func nodeArraysAreEqual(_ nodeArray1: [Node]?, _ nodeArray2: [Node]?) -> Bool { - if nodeArray1 == nil && nodeArray2 == nil { return true } @@ -109,7 +100,6 @@ private extension TreeController { } func rebuildChildNodes(node: Node) -> Bool { - if !node.canHaveChildNodes { return false } diff --git a/Modules/RSWeb/Package.swift b/Modules/RSWeb/Package.swift index 812283cb0..db1db76db 100644 --- a/Modules/RSWeb/Package.swift +++ b/Modules/RSWeb/Package.swift @@ -25,7 +25,6 @@ let package = Package( .unsafeFlags(["-warnings-as-errors"]), .enableUpcomingFeature("NonisolatedNonsendingByDefault"), .enableUpcomingFeature("InferIsolatedConformances"), - .defaultIsolation(MainActor.self) ] ), .testTarget( diff --git a/Modules/RSWeb/Sources/RSWeb/DownloadSession.swift b/Modules/RSWeb/Sources/RSWeb/DownloadSession.swift index 5dd621e2d..c895aae85 100755 --- a/Modules/RSWeb/Sources/RSWeb/DownloadSession.swift +++ b/Modules/RSWeb/Sources/RSWeb/DownloadSession.swift @@ -31,10 +31,8 @@ struct HTTP4xxResponse { } } -@objc public final class DownloadSession: NSObject { - +@MainActor @objc public final class DownloadSession: NSObject { public let downloadProgress = DownloadProgress(numberOfTasks: 0) - private var urlSession: URLSession! private var tasksInProgress = Set() private var tasksPending = Set() diff --git a/Modules/RSWeb/Sources/RSWeb/Downloader.swift b/Modules/RSWeb/Sources/RSWeb/Downloader.swift index e20f0eb46..689e99101 100755 --- a/Modules/RSWeb/Sources/RSWeb/Downloader.swift +++ b/Modules/RSWeb/Sources/RSWeb/Downloader.swift @@ -15,8 +15,7 @@ public typealias DownloadCallback = @MainActor (Data?, URLResponse?, Error?) -> /// Simple downloader, for a one-shot download like an image /// or a web page. For a download-feeds session, see DownloadSession. /// Caches response for a short time for GET requests. May return cached response. -public final class Downloader { - +@MainActor public final class Downloader { public static let shared = Downloader() private let urlSession: URLSession private var callbacks = [URL: [DownloadCallback]]() diff --git a/Modules/RSWeb/Sources/RSWeb/MacWebBrowser.swift b/Modules/RSWeb/Sources/RSWeb/MacWebBrowser.swift index d6ac8a8f0..c187f842f 100755 --- a/Modules/RSWeb/Sources/RSWeb/MacWebBrowser.swift +++ b/Modules/RSWeb/Sources/RSWeb/MacWebBrowser.swift @@ -10,7 +10,7 @@ import AppKit import UniformTypeIdentifiers -public class MacWebBrowser { +@MainActor public class MacWebBrowser { /// Opens a URL in the default browser. @discardableResult public class func openURL(_ url: URL, inBackground: Bool = false) -> Bool { diff --git a/Modules/RSWeb/Sources/RSWeb/WebServices/Transport.swift b/Modules/RSWeb/Sources/RSWeb/WebServices/Transport.swift index 5ba2b9633..a338245e1 100644 --- a/Modules/RSWeb/Sources/RSWeb/WebServices/Transport.swift +++ b/Modules/RSWeb/Sources/RSWeb/WebServices/Transport.swift @@ -9,7 +9,7 @@ import Foundation -nonisolated public enum TransportError: LocalizedError, Sendable { +public enum TransportError: LocalizedError, Sendable { case noData case noURL case suspended diff --git a/Modules/Secrets/Package.swift b/Modules/Secrets/Package.swift index 3bea204c0..f28edf3b8 100644 --- a/Modules/Secrets/Package.swift +++ b/Modules/Secrets/Package.swift @@ -20,7 +20,6 @@ let package = Package( swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), .enableUpcomingFeature("InferIsolatedConformances"), - .defaultIsolation(MainActor.self), .unsafeFlags(["-warnings-as-errors"]) ] ) diff --git a/Modules/Secrets/Sources/Secrets/CredentialsManager.swift b/Modules/Secrets/Sources/Secrets/CredentialsManager.swift index 7622ebb09..caa13f0d8 100644 --- a/Modules/Secrets/Sources/Secrets/CredentialsManager.swift +++ b/Modules/Secrets/Sources/Secrets/CredentialsManager.swift @@ -8,7 +8,7 @@ import Foundation -nonisolated public struct CredentialsManager { +public struct CredentialsManager { private static let keychainGroup: String? = { guard let appGroup = Bundle.main.object(forInfoDictionaryKey: "AppGroup") as? String else { diff --git a/Modules/Secrets/Sources/Secrets/SecretKey.swift.gyb b/Modules/Secrets/Sources/Secrets/SecretKey.swift.gyb index e02cda54b..46d116fb1 100644 --- a/Modules/Secrets/Sources/Secrets/SecretKey.swift.gyb +++ b/Modules/Secrets/Sources/Secrets/SecretKey.swift.gyb @@ -22,7 +22,7 @@ salt = [byte for byte in os.urandom(64)] import Foundation -nonisolated public struct SecretKey { +public struct SecretKey { % for secret in secrets: public static var ${snake_to_camel(secret)}: String { diff --git a/Modules/SyncDatabase/Package.swift b/Modules/SyncDatabase/Package.swift index fb3241cd2..95fd7e7ce 100644 --- a/Modules/SyncDatabase/Package.swift +++ b/Modules/SyncDatabase/Package.swift @@ -26,7 +26,6 @@ let package = Package( swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), .enableUpcomingFeature("InferIsolatedConformances"), - .defaultIsolation(MainActor.self), .unsafeFlags(["-warnings-as-errors"]) ] ), diff --git a/Modules/SyncDatabase/Sources/SyncDatabase/Constants.swift b/Modules/SyncDatabase/Sources/SyncDatabase/Constants.swift index 0b3961b7a..d193e67e8 100644 --- a/Modules/SyncDatabase/Sources/SyncDatabase/Constants.swift +++ b/Modules/SyncDatabase/Sources/SyncDatabase/Constants.swift @@ -6,7 +6,7 @@ // Copyright © 2019 Ranchero Software. All rights reserved. // -nonisolated struct DatabaseKey { +struct DatabaseKey { // Sync Status static let articleID = "articleID" static let key = "key" diff --git a/Modules/SyncDatabase/Sources/SyncDatabase/SyncStatus.swift b/Modules/SyncDatabase/Sources/SyncDatabase/SyncStatus.swift index bc0e732de..683cdefdf 100644 --- a/Modules/SyncDatabase/Sources/SyncDatabase/SyncStatus.swift +++ b/Modules/SyncDatabase/Sources/SyncDatabase/SyncStatus.swift @@ -10,7 +10,7 @@ import Foundation import Articles import RSDatabase -nonisolated public struct SyncStatus: Hashable, Equatable, Sendable { +public struct SyncStatus: Hashable, Equatable, Sendable { public enum Key: String, Sendable { case read case starred diff --git a/Modules/SyncDatabase/Sources/SyncDatabase/SyncStatusTable.swift b/Modules/SyncDatabase/Sources/SyncDatabase/SyncStatusTable.swift index 168367fd2..a1e131205 100644 --- a/Modules/SyncDatabase/Sources/SyncDatabase/SyncStatusTable.swift +++ b/Modules/SyncDatabase/Sources/SyncDatabase/SyncStatusTable.swift @@ -11,7 +11,7 @@ import Articles import RSDatabase import RSDatabaseObjC -nonisolated struct SyncStatusTable { +struct SyncStatusTable { static let name = "syncStatus" static func selectForProcessing(limit: Int?, database: FMDatabase) -> Set? { @@ -98,7 +98,7 @@ nonisolated struct SyncStatusTable { } } -nonisolated private extension SyncStatusTable { +private extension SyncStatusTable { static func statusWithRow(_ row: FMResultSet) -> SyncStatus? { guard let articleID = row.string(forColumn: DatabaseKey.articleID),