@my/tic-tac-toe-game package from tutorial 1.
Reference code: examples/replays/tic-tac-toe-replay-viewer.
1. Capture a replay from a local match
@openturn/replay turns any local session’s action log into a serializable envelope.
From the React app
In the React component from tutorial 1, add a “download replay” button:replayData is exposed on the local match.state. It carries the initial bootstrap, the seed, the initial time, and the action log. createSavedReplayFromSession wraps it into a versioned envelope.
From the CLI
If you also ran the CLI variant, pass--save-replay <path>:
2. Build a viewer app
A replay viewer is just another local-runtime openturn app that, instead of letting the player click, replays a loaded action log.app/app/openturn.ts
app/app/page.tsx
Same shape as before — it renders a React component.
app/src/components/TicTacToeReplayViewer.tsx
snapshot on each step is byte-identical to the original match.
3. Browse frames with inspector
For an interactive timeline, drop in theReplayInspector returned by @openturn/inspector-ui’s createInspector. It gives you a timeline, state diff viewer, and graph highlight:
materializeSavedReplay, then renders the timeline, frame diffs, and graph highlights.
What you learned
@openturn/replayserializes matches into a versioned JSON envelope.- Replaying is just re-dispatching the recorded actions against a fresh session.
@openturn/inspector-uiturns a timeline into an interactive inspector with no extra code.
What to do next
- Tutorial: tic-tac-toe with core rewrites the same game using
@openturn/coredirectly. - How-to: debug with inspector is the full inspector walkthrough.
- How-to: capture replays is the condensed recipe.