Add .shoegaze document type and rig/board sharing

Introduce a single shareable document type for rigs and boards:

- ShoeGazeDocument: versioned JSON envelope wrapping either a RigArchive
  (one or many rigs) or a BoardVersion, with a tolerant decoder that also
  reads the legacy bare-RigArchive and bare-ShoeGazeState shapes.
- Register the .shoegaze UTType (net.realizedsound.shoegaze, conforms to
  public.json) in all four demo app Info.plists.
- Migrate library export/import onto the envelope: exportDocumentData() and
  a decoder-tolerant importArchive(); RigFileDocument and the Builder
  exporter/importer now use .shoegaze. Internal per-rig and board-version
  files stay app-private JSON.
- Add OS share-sheet entries via SwiftUI ShareLink: Share per rig in the
  library sidebar, Share per version in the board editor, backed by the
  Transferable wrappers RigShareItem / BoardShareItem.

Tests: ShoeGazeDocument round-trip and legacy decode, library .shoegaze
export/import round-trip, and a board-document-imports-no-rigs case.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-28 17:49:20 -07:00
parent 657ecaf4f4
commit 9e09eb284a
16 changed files with 737 additions and 33 deletions
+48
View File
@@ -0,0 +1,48 @@
# 1.3 — Rig sharing & the `.shoegaze` document type
Goal: a single registered file type for sharing rigs and boards, migrate export/import onto it, and
add an OS share sheet to the rig library and board-version menu. Local only — no backend, no accounts.
## File type
- **Extension:** `.shoegaze`. **UTType:** `net.realizedsound.shoegaze`, conforms to `public.json`
(stays text-readable). `UTType.shoeGaze` lives in `LyrebirdShoeGazeUI`.
- Declared by all four demo apps and both CLI scaffolder templates
(`CFBundleDocumentTypes` Editor/Owner + `UTExportedTypeDeclarations`) so the system associates the
type with the app for Open and Share.
## Document model — `LyrebirdShoeGaze`
`ShoeGazeDocument` — versioned envelope (`shoeGazeDocumentFormatVersion = 1`) around one payload:
- `.rigs(RigArchive)` — one or many rigs (a single shared rig is a one-rig archive).
- `.board(BoardVersion)` — a single board snapshot.
`data()` encodes pretty-printed JSON (`secondsSince1970` dates). `decoded(from:legacyRigName:)` is
tolerant: tries the envelope, then a bare `RigArchive`, then a bare `ShoeGazeState` (normalised to a
one-rig document). On-disk JSON carries an explicit `kind` discriminator.
## Migration
- `RigLibraryStore.exportDocumentData()` writes the library as a `.shoegaze` document; the prior
`exportArchiveData()` (bare `RigArchive`) is retained for callers/tests.
- `importArchive(from:)` now decodes via `ShoeGazeDocument.decoded` — accepts `.shoegaze`, bare
archive, and legacy single-rig files. A board document contributes no rigs.
- `RigFileDocument` writes `.shoeGaze`, reads `[.shoeGaze, .json]`. The Builder's `fileExporter`
uses `.shoeGaze`; the `fileImporter` accepts `[.shoeGaze, .json]`.
- **Internal** per-rig library files and board-version files stay plain `.json` (app-private; no
churn). `.shoegaze` is the share/export surface only.
## Share UI — `LyrebirdShoeGazeUI`
- `RigShareItem` / `BoardShareItem` — `Transferable` wrappers holding pre-encoded `.shoegaze` bytes
(value-type payload keeps them `Sendable`). Suggested filename `<name>.shoegaze`.
- Rig library sidebar: `Share…` per rig (context menu). Board editor Versions menu: `Share…` per
version. Both via SwiftUI `ShareLink` → AirDrop / Mail / Messages / Files.
## Tests
- `ShoeGazeDocumentTests` — rig/board round-trip, legacy archive + bare-state decode, garbage
rejection, `kind` discriminator on disk.
- `RigLibraryStoreTests` — `.shoegaze` export→import round-trip; board document imports zero rigs.
- Lyrebird `ProjectScaffolderTests` — generated macOS/iOS `Info.plist` registers the document type.