9e09eb284a
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>
43 lines
1.4 KiB
Swift
43 lines
1.4 KiB
Swift
// BoardShareItem.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import Foundation
|
|
import CoreTransferable
|
|
import UniformTypeIdentifiers
|
|
import LyrebirdShoeGaze
|
|
|
|
/// A `Transferable` wrapper that lets a `ShareLink` send a single board as a `.shoegaze` document.
|
|
///
|
|
/// Mirrors ``RigShareItem`` for a board snapshot: it holds the already-encoded document bytes and
|
|
/// the system serialises them to a temporary `<board>.shoegaze` file for AirDrop, Mail, Messages,
|
|
/// and Files.
|
|
struct BoardShareItem: Transferable, Sendable {
|
|
|
|
/// Filesystem-safe base name for the shared file (no extension).
|
|
let filenameBase: String
|
|
|
|
/// Encoded `.shoegaze` document bytes.
|
|
let data: Data
|
|
|
|
/// Encodes `version` as a single-board `.shoegaze` document.
|
|
///
|
|
/// - Parameter version: The board snapshot to share.
|
|
/// - Throws: Any `JSONEncoder` error from ``ShoeGazeDocument/data()``.
|
|
init(board version: BoardVersion) throws {
|
|
self.filenameBase = shareFilenameBase(version.name)
|
|
self.data = try ShoeGazeDocument(board: version).data()
|
|
}
|
|
|
|
static var transferRepresentation: some TransferRepresentation {
|
|
DataRepresentation(exportedContentType: .shoeGaze) { item in
|
|
item.data
|
|
}
|
|
.suggestedFileName { item in
|
|
"\(item.filenameBase).\(ShoeGazeDocument.fileExtension)"
|
|
}
|
|
}
|
|
}
|