dc42db0c59
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>
45 lines
1.6 KiB
Swift
45 lines
1.6 KiB
Swift
// RigArchive.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import Foundation
|
|
|
|
/// Format version written into every exported ``RigArchive``.
|
|
///
|
|
/// Increment when the archive schema changes in a way that requires migration on load.
|
|
public let rigArchiveFormatVersion: Int = 1
|
|
|
|
/// A portable bundle of one or more ``RigEntry`` rigs in a single JSON document.
|
|
///
|
|
/// `RigArchive` is the hand-editable, shareable file format used by the library's
|
|
/// **Export Archive** / **Import Archive** actions — the way to back up or move an entire
|
|
/// collection of rigs as one file. It is the multi-rig successor to the old single-rig file
|
|
/// save/load: a legacy single-rig file (a bare ``ShoeGazeState``) is still importable and is
|
|
/// treated as a one-rig archive (see `RigLibraryStore.importArchive`).
|
|
///
|
|
/// The document is written pretty-printed with sorted keys, so it stays readable and editable by
|
|
/// hand. `Date` values inside each ``RigEntry`` are encoded as `secondsSince1970`.
|
|
public struct RigArchive: Codable, Equatable {
|
|
|
|
/// Archive format version. Written as `rigArchiveFormatVersion` at export time.
|
|
public let version: Int
|
|
|
|
/// The rigs contained in this archive, in listing order.
|
|
public let rigs: [RigEntry]
|
|
|
|
/// Creates a rig archive.
|
|
///
|
|
/// - Parameters:
|
|
/// - version: Archive format version. Defaults to `rigArchiveFormatVersion`.
|
|
/// - rigs: The rigs to bundle.
|
|
public init(
|
|
version: Int = rigArchiveFormatVersion,
|
|
rigs: [RigEntry]
|
|
) {
|
|
self.version = version
|
|
self.rigs = rigs
|
|
}
|
|
}
|