Captures a snapshot of the current version.
Returns an immutable snapshot containing only the data properties, excluding transition methods and observers. Useful for persistence, undo/redo, or time-travel debugging.
A deeply read-only snapshot of the current version
Restores a state from a snapshot.
Returns a new state with version data restored from the snapshot. Transition methods and observers are preserved.
Snapshot created by calling capture() on this State or a related state
A new state with restored version data
Attaches an observer.
Returns a new state with the observer attached. Observers are notified asynchronously when transitions occur. Observer errors are caught and silently ignored.
The operation is idempotent - attaching an already-attached observer returns the
same State reference. Observer identity is determined by reference equality (===).
A new state with observer attached, or same reference if already attached
Detaches an observer.
Returns a new state with the observer detached.
The operation is idempotent - detaching a non-attached observer returns the
same State reference. Observer identity is determined by reference equality (===).
A new state with observer detached, or same reference if not attached
State manager.
Provides housekeeping operations for state instances, including snapshotting, restoration, and observer management. See module documentation for detailed usage examples.