restores Helder in all its glory

This commit is contained in:
2026-09-28 11:34:49 +02:00
parent c2b38b853c
commit 1d29d0952d
280 changed files with 29205 additions and 7 deletions
@@ -0,0 +1,33 @@
import Foundation
import HelderCore
import HelderServices
/// The project note in memory; records every write.
final class FakeNotes: NotesServicing, @unchecked Sendable {
private let state: Locked<(stored: String, writes: [String], failWrites: Bool)>
init(_ stored: String = "") {
state = Locked((stored, [], false))
}
var writes: [String] { state.current.writes }
var onDisk: String { state.current.stored }
var failWrites: Bool {
get { state.current.failWrites }
set { state.mutate { $0.failWrites = newValue } }
}
/// Another program rewrote the note file.
func setOnDisk(_ text: String) { state.mutate { $0.stored = text } }
func read() async -> String { state.current.stored }
func write(_ text: String) async throws {
try state.mutate { state in
if state.failWrites { throw CocoaError(.fileWriteNoPermission) }
state.writes.append(text)
state.stored = text
}
}
}