// 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 `.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)" } } }