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:
@@ -360,27 +360,28 @@ public struct ShoeGazeBuilderView: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// Hosts the archive-export (`.json`) exporter on its own node. Writes the whole library as one
|
||||
/// ``RigArchive`` file for backup or transfer.
|
||||
/// Hosts the library-export (`.shoegaze`) exporter on its own node. Writes the whole library as
|
||||
/// one ``ShoeGazeDocument`` file for backup or transfer.
|
||||
private var rigExportAnchor: some View {
|
||||
Color.clear
|
||||
.fileExporter(
|
||||
isPresented: $showExporter,
|
||||
document: exportDocument,
|
||||
contentType: .json,
|
||||
contentType: .shoeGaze,
|
||||
defaultFilename: ShoeGazeBuilderView.defaultArchiveFileName
|
||||
) { result in
|
||||
if case .failure(let error) = result {
|
||||
print("[ShoeGazeBuilderView] archive export failed: \(error)")
|
||||
print("[ShoeGazeBuilderView] library export failed: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Hosts the archive-import (`.json`) importer on its own node (cross-platform). Accepts a
|
||||
/// ``RigArchive`` or a legacy single-rig file; imported rigs are added to the library.
|
||||
/// Hosts the library-import (`.shoegaze`) importer on its own node (cross-platform). Accepts a
|
||||
/// ``ShoeGazeDocument`` or a legacy archive / single-rig file; imported rigs are added to the
|
||||
/// library.
|
||||
private var rigImportAnchor: some View {
|
||||
Color.clear
|
||||
.fileImporter(isPresented: $showImporter, allowedContentTypes: [.json]) { result in
|
||||
.fileImporter(isPresented: $showImporter, allowedContentTypes: [.shoeGaze, .json]) { result in
|
||||
handleArchiveImport(result)
|
||||
}
|
||||
}
|
||||
@@ -917,13 +918,13 @@ public struct ShoeGazeBuilderView: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// Captures the current session into the whole-library archive exporter.
|
||||
/// Captures the whole library into the `.shoegaze` document exporter.
|
||||
private func exportArchiveAction() {
|
||||
do {
|
||||
exportDocument = RigFileDocument(data: try library.exportArchiveData())
|
||||
exportDocument = RigFileDocument(data: try library.exportDocumentData())
|
||||
showExporter = true
|
||||
} catch {
|
||||
print("[ShoeGazeBuilderView] exportArchiveData failed: \(error)")
|
||||
print("[ShoeGazeBuilderView] exportDocumentData failed: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user