A serializable, append-only action log for replay, undo checkpoints, synchronization and
debugging. It does not interpret actions or events: the game decides how to reapply an
action, while the journal preserves the exact order and resulting event batch.
Actions and events are copied with structuredClone on the way in, so both must be plain
data. An action that carries a live object holding callbacks (an actor with a
ReactionTable, say) is refused by append with the path of the first value that cannot be
copied; carry that object's id instead.
Example
import { ActionJournal } from'@datamoc/mwg/core';
constjournal = newActionJournal<string, { type: string }>(); journal.append('open-door', [{ type:'door-opened' }]); constcheckpoint = journal.mark(); // An undo system can restore its state and replay journal.since(checkpoint).
A serializable, append-only action log for replay, undo checkpoints, synchronization and debugging. It does not interpret actions or events: the game decides how to reapply an action, while the journal preserves the exact order and resulting event batch.
Actions and events are copied with
structuredCloneon the way in, so both must be plain data. An action that carries a live object holding callbacks (an actor with aReactionTable, say) is refused byappendwith the path of the first value that cannot be copied; carry that object's id instead.Example