Signature of an "everything" pre-transition hook handler. Like
HookHandler but receives an EverythingHookContext so the
handler can dispatch on hook_name.
String literal type of the four supported FSL flow directions. This is
the type of the flow config key on a machine.
String literal type of the built-in theme names. This is the element
type of the theme config key (which accepts an array so that themes
can be layered).
Richer hook return value used when a hook needs to do more than just
accept or veto a transition. pass is the required accept/veto flag
(kept non-optional so that returning a stray object doesn't accidentally
veto everything). The optional state overrides the destination state,
data overrides the data observed by other hooks in the same chain,
and next_data overrides the data committed after the transition.
Context object passed to every HookHandler. data is the
data payload as it stands before the transition, and next_data is
the payload that will be committed if the transition is accepted —
handlers may inspect or mutate the latter via a
HookComplexResult return value.
Discriminated union of every kind of hook registration jssm understands,
pre-transition and post-transition. The kind field selects the
variant; remaining fields describe which transitions / states / actions
the hook is bound to and supply the HookHandler or
PostHookHandler to invoke.
Pre-transition variants ('hook', 'named', 'standard transition',
'main transition', 'forced transition', 'any transition',
'global action', 'any action', 'entry', 'exit', 'after')
may return a falsy value to veto a transition. Post-transition
variants ('post *') cannot veto and are invoked only after a
successful transition.
Signature of a pre-transition hook handler. Receives the current and proposed-next data payloads via a HookContext and returns a HookResult: a falsy result vetoes the transition, a truthy result allows it, and a HookComplexResult can additionally rewrite the next state or next data.
Return value from a HookHandler. May be a plain boolean to
accept (true/undefined/void) or veto (false) the transition, or
a HookComplexResult that additionally rewrites the next state
and/or the next data payload.
Detail payload fired with an action event. Fires when an action is
attempted, before transition validation runs.
Tristate flag for whether a property may be overridden at runtime.
true permits overrides, false forbids them, and undefined defers
the decision to the surrounding configuration's default.
The set of ASCII arrow tokens recognized by the FSL grammar. Each arrow
encodes a direction (one-way left/right, or two-way) and a "kind" for
each direction (- legal, = main path, ~ forced-only). See the
Language Reference docs for the full semantic table.
Direction polarity of an arrow: pointing only 'left', only 'right',
or 'both' (a bidirectional arrow).
Semantic category of an arrow's transition. 'legal' is a normal
transition, 'main' is part of the machine's primary path, 'forced'
may only be taken via Machine.force_transition, and 'none'
means no transition exists in that direction.
Complete shape of a jssm-viz theme. A theme provides a style block for
each kind of state (state, hooked, start, end, terminal) as
well as a matching active_* variant used while that state is current.
The graph, legal, main, forced, action, and title slots are
reserved for future use and currently typed as undefined.
Most user-defined themes should be typed as JssmTheme (the
Partial of this) so that omitted fields fall back to the base theme.
A color value accepted by jssm-viz for state and arrow styling. Currently
any string, validated downstream by Graphviz / the named-colors list.
Intended to be narrowed to #RRGGBB / #RRGGBBAA and CSS named colors
in a future release.
Internal compiler intermediate: a single aggregated rule produced while folding a parse tree into a machine configuration. Not intended for end-user code.
Internal compiler intermediate: one link in a chained transition
expression (an "s-expression" segment). Carries both directions of an
arrow with optional per-direction action labels, probabilities, and
after-times. The recursive se field allows the parser to chain
arrows of the form A -> B -> C. Not intended for end-user code.
Internal compiler intermediate: the root of a chained transition
expression, anchored at a from state. Also doubles as the carrier
for non-transition rules (state declarations, property definitions,
machine metadata) via its key/value/name/state fields. Not
intended for end-user code.
Detail payload fired with a complete event. Indicates that the
machine has reached a FSL complete state.
Detail payload fired with a data-change event. Fires whenever the
machine's data payload is replaced. old_data is the value before the
change; new_data is the value after.
Detail payload fired with an entry event. state is the entered
state. from is the predecessor state, if any. action is the
action that drove the entry, if any.
Detail payload fired with an error event. Wraps an exception caught
while running an event handler; source_event and source_detail
identify the event whose handler threw, and handler is the offending
function so consumers can correlate / blame.
Extra diagnostic information attached to a JssmError when it carries machine-relative context — most often the state name a caller asked about when the error was raised.
Mapped type from JssmEventName to the corresponding detail
payload. Drives the discriminated-union typing of Machine.on,
so e.action and friends only exist where they're meaningful.
Per-event filter object (as passed to Machine.on). Use
JssmEventDetailMap<mDT>[Ev] to find the matching detail type.
The type of the machine data member.
The event name.
Filter accepted by Machine.on / Machine.once for an individual event name. Only events whose detail key matches every filter entry fire the handler. Events that don't list a filter key in v1 take no filter properties.
The type of the machine data member.
The event name.
Per-event handler signature. Receives a detail object typed by event
name, so e.action (etc.) only exist where they're meaningful.
All event names that Machine.on accepts. These are observation events fired by the machine in addition to (not in place of) the hook system. Hooks intercept; events observe.
Detail payload fired with an exit event. state is the exited
state. to is the next state, if any. action is the action that
drove the exit, if any.
Full configuration object accepted by the Machine constructor and
by {@link from}. Carries the transition list and the optional knobs
governing layout, theming, history, start/end states, property
definitions, machine metadata (author, license, version, ...) and the
runtime hook surfaces (time_source, timeout_source, ...).
Most users never construct one of these directly — the sm tagged
template literal and {@link from} produce one from FSL source.
The state-name type (usually string).
The user-supplied data payload type (mDT).
Minimal machine description used internally and accepted by some lower-level constructors. Most callers should use the richer JssmGenericConfig instead.
Topology record for one node in a compiled machine: its name, the set of states it can be reached from, the set of states it can transition to, and whether reaching it constitutes "completing" the machine.
Bounded history of recently-visited states paired with the data payload
observed in each. Backed by circular_buffer_js, so the oldest entry
is dropped silently once the configured capacity is exceeded.
Detail payload fired with hook-registration and hook-removal events.
Mirrors the HookDescription so inspector tools can mirror the
current hook set.
Graphviz layout engine selector. Controls how jssm-viz lays out the
rendered diagram; 'dot' is the default and most useful for state
machines. See the Graphviz documentation for the differences.
The full internal bookkeeping snapshot of a Machine, exposed for
advanced introspection. Contains the current state, the state map, the
edge map and reverse-action map, and the original edge list. The
internal_state_impl_version field exists so that consumers can detect
shape changes if this representation evolves.
Detail payload fired with an override event. Distinguishes a forced
state replacement from a normal transition.
Signature of an FSL parse function: takes a source string and returns a JssmParseTree. Used to type the parser export so consumers can swap in alternative parser implementations.
The output shape of the FSL parser: a flat array of JssmCompileSeStart entries, one per top-level rule in the source. Consumed by the compiler to build a machine configuration.
Two-state policy flag: a feature is either 'required' or 'disallowed'.
Used by machine configuration where the option must take a definite stance.
Three-state policy flag: 'required', 'disallowed', or 'optional'.
Used by machine configuration where a default-permissive middle ground
is meaningful (for example, the actions config key).
Declaration of a named property that a machine's states may carry.
Set required: true to force every state to define the property, or
provide default_value to fall back when the state does not specify it.
Detail payload fired with a rejection event. Carries the resolved
source and target plus an indication of who rejected the transition
and why. reason is 'invalid' when no edge existed, 'hook' when
a hook handler vetoed; hook_name is set when reason is 'hook'.
Discriminated union representing the outcome of an operation: either
success, failure (with an error), or incomplete. Used as the return
shape for operations that may need to report partial progress.
Pluggable random-number-generator function shape. Must return a value
in [0, 1) exactly as Math.random does. Supplied via the
rng_seed-aware machine configuration so that stochastic models can be
made reproducible.
Persistable snapshot of a Machine produced by Machine.serialize and consumed by deserialize. Carries the current state, the associated machine data, the recent history (subject to the configured capacity), and metadata to detect version-skew on rehydration.
The type of the user-supplied data payload (mDT).
A type teaching Typescript the various supported shapes for nodes, mostly inherited from GraphViz
A loosened version of JssmStateDeclaration where every field is optional. Used as the value type for theme entries and for default state configuration where most fields will be inherited or merged.
The fully-condensed declaration for a single state, including its raw
rule list (declarations) and the well-known styling fields jssm-viz
understands. Returned by Machine.state_declaration.
A single key/value pair from an FSL state X: { ... }; block, in the
raw form produced by the parser before being condensed into a
JssmStateDeclaration.
Tagged union of all individual style key/value pairs that may appear in
a state's style configuration. The key discriminator selects which
member, and the value is typed accordingly.
An ordered list of JssmStateStyleKey entries. Used by the
default_*_state_config machine config options to provide a fallback
style stack.
Detail payload fired with a terminal event. Indicates that the
machine has reached a state with no outgoing edges.
A user-supplied theme. Identical in shape to JssmBaseTheme, but every field is optional so themes can be layered: omitted slots fall through to the underlying base theme.
Detail payload fired with a timeout event. Fires when a configured
after clause causes an automatic transition.
A single directed transition (edge) within a state machine. Captures
both the topology (from / to), the FSL semantics (kind,
forced_only, main_path), and any optional metadata such as a
per-edge name, an action label, a guard check, a transition
probability for stochastic models, and an after_time for timed
transitions.
The state-name type (usually string).
The machine's data payload type (mDT).
Detail payload fired with a transition event. Carries the resolved
source and target, the action name (if the transition was driven by an
action), the data observed before and after the change, the edge kind,
and whether the call was a forced transition.
The set of states that can immediately precede or follow a given state. Returned by jssm helpers that report a state's connectivity in the graph.
An entry produced while parsing a transition rule: either a literal
state name (StateType) or a JssmTransitionCycle marker.
A list of JssmTransitions — the edge set of a machine.
Function returned by Machine.on and Machine.once that removes the subscription. Calling it more than once is a no-op.
Signature of an "everything" post-transition hook handler. Like PostHookHandler but receives an EverythingHookContext. The return value is ignored.
Runtime-iterable list of valid flow directions for FSL diagrams.
Use this when you need to enumerate directions; for the type itself
see FslDirection.
Runtime-iterable list of the built-in theme names that ship with jssm-viz. Use this when you need to enumerate themes; for the type itself see FslTheme.
Generated using TypeDoc
Context object passed to "everything" hooks (EverythingHookHandler and PostEverythingHookHandler). Extends the usual HookContext with
hook_name, which identifies which specific hook fired so a single handler can route on it.