@graphty/graphty-element / session / SessionHistory
Interface: SessionHistory ​
Defined in: graphty-element/src/session/types.ts:1514
The session's undo history. steps, pending and nextUndo are frozen values, the identical objects between changes; version moves on every history:changed, so a React host can subscribe with useSyncExternalStore(subscribe, () => session.history.version).
Properties ​
bytes ​
readonlybytes:number
Defined in: graphty-element/src/session/types.ts:1529
What every step retains, in bytes.
limitBytes ​
limitBytes:
number
Defined in: graphty-element/src/session/types.ts:1536
The byte budget. Default 256 MiB. When a record goes past it, or past limitSteps, the oldest steps (then the farthest redo steps) are dropped until the history is within 90% of both budgets, so the work of dropping is spread over many records. Lowering a budget below what the history holds trims it the same way at once.
limitSteps ​
limitSteps:
number
Defined in: graphty-element/src/session/types.ts:1541
The step budget. Default 1000. Going past it trims the history to 90% of it, rounded down, as limitBytes describes: with a budget of 10, the eleventh step leaves 9.
nextUndo ​
readonlynextUndo: {kind:"cancel";pending: readonlyPendingStep[]; } | {kind:"undo";step:HistoryStep; } |null
Defined in: graphty-element/src/session/types.ts:1524
What the next undo() will do: cancel pending work, undo a step, or nothing (null).
pending ​
readonlypending: readonlyPendingStep[]
Defined in: graphty-element/src/session/types.ts:1522
Undoable work dispatched and not yet recorded, oldest first.
position ​
readonlyposition:number
Defined in: graphty-element/src/session/types.ts:1520
How many steps are applied.
steps ​
readonlysteps: readonlyHistoryStep[]
Defined in: graphty-element/src/session/types.ts:1518
Oldest first; steps[position..] have been undone and can be redone.
version ​
readonlyversion:number
Defined in: graphty-element/src/session/types.ts:1516
Bumped on every history:changed.
Methods ​
cancel() ​
cancel(
pending): readonlyPendingStep[]
Defined in: graphty-element/src/session/types.ts:1554
Cancel a pending item, and every later-dispatched item that depends on what it writes.
Parameters ​
pending ​
The item.
Returns ​
readonly PendingStep[]
Every item cancelled; empty when the id is not pending.
clear() ​
clear():
void
Defined in: graphty-element/src/session/types.ts:1556
Drop every step, cancelling pending work: the current state becomes the baseline.
Returns ​
void
restoreTo() ​
restoreTo(
step):Promise<HistoryOutcome>
Defined in: graphty-element/src/session/types.ts:1548
Move to the state just after a step, or to the baseline with null, as the equivalent run of undos or redos. Resolves once the picture matches the state.
Parameters ​
step ​
HistoryStepId | null
The step, or null for the state before every step.
Returns ​
Promise<HistoryOutcome>
What was done.