Replace stringly-typed pedal API with PedalType tokens

appendPedal(type: String, to:) is replaced by appendPedal(_ kind: PedalType, to:),
where PedalType is an extensible RawRepresentable struct with static members for
the built-in pedals:

    try shoeGaze.appendPedal(.overdrive, to: board)

Discoverable/autocompleting call sites, still open for custom pedals
(PedalType("My Pedal")). rawValue == the pedal's displayName, so PedalRegistry
and the rig JSON format are unchanged — saved rigs load exactly as before.

Named PedalType (not PedalKind) to avoid colliding with Lyrebird's score-notation
PedalKind enum, which is visible when both modules are imported. The UI palette
wraps its registry-key strings as PedalType(key); demos/tests use the static
members. PedalRegistry.makePedal(type:) stays string-keyed as the serialization
boundary used by loadRig.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-24 20:34:45 -07:00
parent 24ce4564e8
commit 21b9123a87
11 changed files with 109 additions and 34 deletions
@@ -443,7 +443,7 @@ public struct BoardFlowView: View {
private func append(type: String, lane: PedalLane) {
guard let board: PedalBoard = board else { return }
do { _ = try shoeGaze.appendPedal(type: type, to: board, lane: lane) }
do { _ = try shoeGaze.appendPedal(PedalType(type), to: board, lane: lane) }
catch { print("[BoardFlowView] appendPedal failed: \(error)") }
}
@@ -11,7 +11,7 @@ import LyrebirdShoeGaze
/// options, sized to sit in a narrow left sidebar.
///
/// The pedal rows are tappable: selecting one invokes `onAdd(type)` with the pedal's
/// `displayName`, which the host wires to `ShoeGaze.appendPedal(type:to:)`. The routing cards
/// `displayName`, which the host wraps in a `PedalType` for `ShoeGaze.appendPedal(_:to:)`. The routing cards
/// (Parallel split, Stereo split, Chain router, Merge to mono) are informational only — they
/// describe the topologies the engine supports, which are built programmatically rather than via
/// linear add (see ``BoardBuilderView`` for the read-only display of existing branches).
@@ -20,7 +20,7 @@ import LyrebirdShoeGaze
///
/// ```swift
/// PedalPaletteView { type in
/// try? shoeGaze.appendPedal(type: type, to: board)
/// try? shoeGaze.appendPedal(PedalType(type), to: board)
/// }
/// ```
public struct PedalPaletteView: View {
@@ -373,7 +373,7 @@ public struct ShoeGazeBuilderView: View {
guard !shoeGaze.boards.isEmpty else { return }
let board: PedalBoard = shoeGaze.boards[clampedBoardIndex]
do {
_ = try shoeGaze.appendPedal(type: type, to: board)
_ = try shoeGaze.appendPedal(PedalType(type), to: board)
} catch {
print("[ShoeGazeBuilderView] appendPedal failed: \(error)")
}