Skip to content

Refactor: add a typed machine runtime and convert remaining viewer state - #67

Merged
marcelduin merged 20 commits into
fixes/implicit-state-machinesfrom
refactor/more-machines
Nov 9, 2026
Merged

marcelduin merged 20 commits into
fixes/implicit-state-machinesfrom
refactor/more-machines

Conversation

@marcelduin

Copy link
Copy Markdown
Member

This branch adds an internal reducer/machine runtime and uses it to replace the remaining multi-field state across the viewer.

Runtime

  • New machine.ts: queued transitions, phase and transition effects, AbortSignal cancellation, bounded history, disposal.
  • No dependency, no public export change.

Converted state

  • Media playback and the video-tour clock/segment.
  • Serial tour steps and the book goto cascade.
  • Camera Ani, page-flip slots and tile phases.
  • Marker popup, marker session, print lifecycle and grid transitions.
  • Grid visibility/serial mode and audio unlock.
  • Gallery drag phase, shared by the swipe strip and scrubber.
  • Embed presentation (html | gl | gl+overlay).

The old boolean/latch fields behind these behaviours are removed in the migrated components.

Also included

  • 55f1a69 restores Kinetic.start()’s contract for a no-motion click.
  • The load/switch machine was attempted and reverted (d5e9752); its _switching timing is part of the waypoint arrival contract and is not changed here.

Verification

  • pnpm test — 139 files / 1995 tests passed
  • pnpm typecheck and pnpm lint clean
  • New core reducer tests for every added state module
  • dev.html is not included

Queued transitions, phase entry signals, transition signals, bounded history and disposal; covered by core unit tests.
One phase per playback state; public events and end reporting derive from phase edges for native, HLS and iframe backends.
Phase, runId and step own the story; the opening phase signal cancels superseded image loads and transport events derive from phase edges.
Replace the running/view/zoom booleans with one phase and channel; pause and resume stay explicit.
One phase and run id for the cascade; waiters resolve by run and the frame loop owns settling.
Named tile phases and a pure reducer replace the 0..3 load-state numbers; failed stays terminal until eviction.
Slot phase replaces direction plus dragging booleans; a programmatic flip now leaves the drag state instead of stalling.
Restore start()'s contract: only the under-zoom guard may refuse it; a no-motion click is stopped by the frame loop.
One phase, segment and clock replace the paused/playing/wasPaused/timestamp fields; replay and paused seeks stay deterministic.
One phase covers live/destroying, minimized, advance latch and tour-control placement.
Transition phase, set id and z tiers are one state; cancel preserves the generation and destroy invalidates it.
One print phase and generation replace the printed flag and generation counter.
Switch phase and shown edge own _switching; loading remains the engine's tile progress.
A shared drag phase replaces the strip active flag; the reducer can express pending, dragging and cancellation.
Grid mode tracks overview/hidden/focus/non-clickable and the serial transport as one reducer state.
One locked/probing/blocked/unlocked phase replaces the interacted store; controllers subscribe to the phase.
html, gl and gl+overlay are one discriminated presentation instead of four booleans.
Selection phase and popup/popover flags live in State.Main; marker events drive its transitions.
The public switching store's exact notification timing is part of the waypoint contract; the machine changed it.
The scrubber's drag flag is now the same explicit phase as the swipe strip.
@marcelduin
marcelduin added this pull request to stack #68 November 9, 2026 03:00
@marcelduin
marcelduin merged commit 6fe4969 into main Nov 9, 2026
2 of 8 checks passed
@marcelduin
marcelduin deleted the refactor/more-machines branch November 9, 2026 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant