9a8e5461c0
Move the remaining synchronous main-thread I/O off the main actor: - RigLibraryStore now constructs instantly with a local placeholder and exposes an awaitable async start(): it resolves the iCloud-or-local location off-main (the blocking ubiquity lookup), loads entries off-main via the shared ioQueue (so a reload can't drop a just-saved rig), then sets isLoaded. reload() is async; iCloud metadata updates re-read via it. - Seeding moves into RigLibraryBootstrap.start(_:seedFrom:), which seeds a "Default" rig only AFTER the (possibly iCloud) library has loaded and is still empty — preventing a duplicate "Default" on every synced device on first launch. - Sidebar shows a Loading state until isLoaded; the builder restores the persisted current-rig highlight when isLoaded flips true (initialRigID param dropped). - Shells construct the store synchronously and start it asynchronously (macOS via Task in didFinishLaunching; iOS via .task). Codec + file helpers are nonisolated static so background work needs no actor hop. - Tests await store.start(). Full suite: 206 passing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
45 lines
1.6 KiB
Swift
45 lines
1.6 KiB
Swift
// ShoeGazeBuilderiOSApp.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import SwiftUI
|
|
import LyrebirdShoeGazeUI
|
|
|
|
/// iOS entry point for the ShoeGaze Builder.
|
|
///
|
|
/// Holds the `ShoeGazeBuilderiOSAppModel` as `@State` so it is created once and owned for the
|
|
/// lifetime of the app. The audio engine is **not** started automatically — the user presses
|
|
/// Start in ``ShoeGazeBuilderView``. The engine is stopped when the view disappears.
|
|
///
|
|
/// ``ShoeGazeBuilderView`` manages its own scroll regions (palette + builder), so it is hosted
|
|
/// directly rather than wrapped in an outer `ScrollView`.
|
|
@main
|
|
struct ShoeGazeBuilderiOSApp: App {
|
|
|
|
@State private var model: ShoeGazeBuilderiOSAppModel = ShoeGazeBuilderiOSAppModel()
|
|
@Environment(\.scenePhase) private var scenePhase
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
NavigationStack {
|
|
ShoeGazeBuilderView(
|
|
shoeGaze: model.shoeGaze,
|
|
library: model.library,
|
|
hardwareSampleRate: { model.hardwareSampleRate },
|
|
onEnableLiveInput: { model.enableLiveInput() }
|
|
)
|
|
.navigationTitle("ShoeGaze Builder")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.task { await model.startLibrary() }
|
|
}
|
|
.onDisappear { model.stop() }
|
|
}
|
|
.onChange(of: scenePhase) { _, phase in
|
|
// Persist the rig whenever the app leaves the foreground.
|
|
if phase != .active { model.save() }
|
|
}
|
|
}
|
|
}
|