Open .shoegaze files: wire document handlers, scope type to builders
Registering the document type made the apps claim .shoegaze, but without an open handler macOS reported "cannot open files in the ShoeGaze Document format." Wire actual opening: - macOS Builder: implement application(_:open:) — decode the document and import its rigs into the library (board files get an explanatory note), with a confirmation alert. Also migrate the File-menu Export/Import panels to .shoegaze (still importing legacy JSON). - iOS Builder: add .onOpenURL and an importDocument(at:) on the app model. - Drop the document-type declaration from the two minimal player demos (ShoeGazeDemo, ShoeGazeiOSDemo); they have no open/share UI, so only the two Builder apps should claim the type. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -93,6 +93,25 @@ final class ShoeGazeBuilderiOSAppModel {
|
||||
library.flushPendingWrites()
|
||||
}
|
||||
|
||||
// MARK: - Document open
|
||||
|
||||
/// Imports a `.shoegaze` file opened from Files, AirDrop, or another app into the rig library.
|
||||
/// Rig documents add their rigs (they appear in the sidebar, ready to load); board documents are
|
||||
/// ignored here. Returns the number of rigs added.
|
||||
@discardableResult
|
||||
func importDocument(at url: URL) -> Int {
|
||||
// A document opened from outside the sandbox is security-scoped; start access to read it.
|
||||
let scoped: Bool = url.startAccessingSecurityScopedResource()
|
||||
defer { if scoped { url.stopAccessingSecurityScopedResource() } }
|
||||
do {
|
||||
let data: Data = try Data(contentsOf: url)
|
||||
return try library.importArchive(from: data)
|
||||
} catch {
|
||||
print("[ShoeGazeBuilderiOS] open document failed: \(error)")
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Audio session / engine construction
|
||||
|
||||
/// Activates the play-and-record audio session once. Idempotent; safe to call before each
|
||||
|
||||
Reference in New Issue
Block a user