updates plug with all sorts of awesome improvements

This commit is contained in:
2026-11-09 13:09:09 +01:00
parent a92d6f8871
commit 3afdb6d67f
553 changed files with 22780 additions and 13155 deletions
+6 -4
View File
@@ -20,7 +20,7 @@ public final class PageStore {
.appendingPathComponent("page.md")
}
/// The page file as read at launch; an empty page when there was no file.
/// The page file as read at launch; the first page when there was no file.
public let loaded: PageFile
/// Makes the page file text when a save runs, so a keystroke costs no conversion; nil writes nothing.
@@ -35,12 +35,13 @@ public final class PageStore {
@ObservationIgnored private var pending: Task<Void, Never>?
@ObservationIgnored private var isDirty = false
/// Reads the page file; a missing file gives an empty page.
/// Reads the page file; a missing file gives `firstPage`, which the next flush writes unless it is empty.
/// - Throws: `PageStoreError.unreadable` when the file exists but cannot be read.
public init(
url: URL = PageStore.defaultURL,
debounce: Duration = .milliseconds(500),
write: @escaping @Sendable (Data, URL) throws -> Void = PageStore.writeAtomically
write: @escaping @Sendable (Data, URL) throws -> Void = PageStore.writeAtomically,
firstPage: @autoclosure () -> PageFile = WelcomeText.page(createdAt: Date())
) throws {
self.url = url
self.debounce = debounce
@@ -51,7 +52,8 @@ public final class PageStore {
}
loaded = PageFile(text: text)
} else {
loaded = PageFile()
loaded = firstPage()
isDirty = !loaded.lines.isEmpty
}
}