Add iCloud-synced rig library
Replace the single hand-saved rig file with a managed library of named rigs persisted in app storage and synced across devices and both builder apps via a shared iCloud container (iCloud.net.realizedsound.ShoeGazeData), falling back to local storage when iCloud is unavailable. Core (LyrebirdShoeGaze/Presets): - RigEntry: named, timestamped ShoeGazeState (a whole multi-board rig). - RigArchive: portable multi-rig JSON bundle for backup/transfer; legacy single-rig files import as a one-rig archive. - RigLibraryStore (@MainActor @Observable): one JSON file per rig, with NSFileCoordinator writes and NSMetadataQuery live remote-change watching. - RigLibraryLocation: iCloud-or-local directory resolver (skips the slow ubiquity lookup when no iCloud account is signed in). - ShoeGaze.loadRig(from: ShoeGazeState) + captureEntry; shared filename sanitizer factored out of BoardVersionStore. UI (LyrebirdShoeGazeUI): - RigLibrarySidebarView: persistent left listing with new/save/save-as/ duplicate/rename/delete/erase-all and archive import/export. - RigNamePrompt; RigLibraryBootstrap one-call shell setup. - ShoeGazeBuilderView: sidebar wired in; selecting a rig replaces the session; File menu / sidebar do whole-library archive import/export. Shells/entitlements: both builder targets own+start the store and carry the iCloud Documents entitlement; NSUbiquitousContainers exposes the rigs in the Files app. (macOS pbxproj also carries a pre-existing 1.0->1.1.1 version bump.) Tests: RigEntry/RigArchive round-trip + RigLibraryStore CRUD/import/export (15 new; full suite 206 passing). Provisioning (manual, not done here): enable the iCloud container on both App IDs and select it in Signing & Capabilities for both targets. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,23 @@ extension ShoeGaze {
|
||||
return ShoeGazeState(boards: boardStates)
|
||||
}
|
||||
|
||||
/// Captures the current rig as a named ``RigEntry`` suitable for the rig library.
|
||||
///
|
||||
/// Wraps ``captureState()`` with a name, a fresh `id`, and a `savedAt` timestamp. The engine
|
||||
/// graph is not modified; this is a read-only operation.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - name: Human-readable name for the entry (e.g. `"Ambient Wash"`).
|
||||
/// - id: Stable identifier. Defaults to a newly generated `UUID()`; pass an existing entry's
|
||||
/// `id` to overwrite that entry in place.
|
||||
/// - Returns: A ``RigEntry`` reflecting the current rig.
|
||||
public func captureEntry(
|
||||
name: String,
|
||||
id: UUID = UUID()
|
||||
) -> RigEntry {
|
||||
RigEntry(id: id, name: name, state: captureState())
|
||||
}
|
||||
|
||||
// MARK: - Save / Load
|
||||
|
||||
/// Saves the current rig to a JSON file at `url`.
|
||||
@@ -58,6 +75,20 @@ extension ShoeGaze {
|
||||
public func loadRig(from data: Data) throws {
|
||||
let decoder: JSONDecoder = JSONDecoder()
|
||||
let state: ShoeGazeState = try decoder.decode(ShoeGazeState.self, from: data)
|
||||
try loadRig(from: state)
|
||||
}
|
||||
|
||||
/// Rebuilds the engine graph from an already-decoded ``ShoeGazeState``.
|
||||
///
|
||||
/// Shared core of the `Data` / `URL` loaders, and the entry point the rig library uses to
|
||||
/// recall a stored ``RigEntry`` (`loadRig(from: entry.state)`) without re-encoding. Rejects a
|
||||
/// snapshot whose `version` exceeds `presetFormatVersion`, tears down the current rig, then
|
||||
/// rebuilds every board with the all-or-nothing semantics of ``rebuildAllBoards(from:)``.
|
||||
///
|
||||
/// - Important: Call with the engine **stopped**, as with ``loadRig(from:)``.
|
||||
/// - Parameter state: The rig snapshot to restore.
|
||||
/// - Throws: `PresetError.unsupportedVersion` for a too-new snapshot, or any board-build error.
|
||||
public func loadRig(from state: ShoeGazeState) throws {
|
||||
guard state.version <= presetFormatVersion else {
|
||||
throw PresetError.unsupportedVersion(state.version)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user