Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type Aliases

EverythingHookContext<mDT>: HookContext<mDT> & { hook_name: string }

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.

Type Parameters

  • mDT

EverythingHookHandler<mDT>: ((hook_context: EverythingHookContext<mDT>) => HookResult<mDT>)

Type Parameters

  • mDT

Type declaration

FslDirection: typeof FslDirections[number]

String literal type of the four supported FSL flow directions. This is the type of the flow config key on a machine.

FslSourceLocation: { end: FslSourcePoint; start: FslSourcePoint }

Type declaration

FslSourcePoint: { column: number; line: number; offset: number }

A source span produced by the FSL parser when parse(input, { locations: true }) is used. Mirrors PEG.js's native location() shape: byte offsets (0-based, half-open) plus 1-based line/column for display.

const [t] = parse('a -> b;', { locations: true });
// t.loc === { start: { offset: 0, line: 1, column: 1 },
// end: { offset: 7, line: 1, column: 8 } }

Type declaration

  • column: number
  • line: number
  • offset: number
FslTheme: typeof FslThemes[number]

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).

HookBoundaryKind: "group enter" | "group exit" | "state enter" | "state exit"

Kinds for FSL boundary hooks (on enter/exit &group do 'X' and the plain- state analogue). These fire post-commit when a transition crosses the subject's boundary and are not part of HookDescription (that union covers only the programmatically-registered observational hooks), so the registry widens its kind field with them.

HookComplexResult<mDT>: { data?: mDT; next_data?: mDT; pass: boolean; state?: StateType }

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.

Type Parameters

  • mDT

Type declaration

  • Optional data?: mDT
  • Optional next_data?: mDT
  • pass: boolean
  • Optional state?: StateType
HookContext<mDT>: { data: mDT; next_data: mDT }

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.

Type Parameters

  • mDT

Type declaration

  • data: mDT
  • next_data: mDT

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.

Type Parameters

  • mDT

HookHandler<mDT>: ((hook_context: HookContext<mDT>) => HookResult<mDT>)

Type Parameters

  • mDT

Type declaration

HookPhase: "pre" | "post"

Whether an observational hook runs in the pre-transition phase (where it may veto/mutate the transition) or the post-transition phase (a pure observer that runs only after a successful transition commits).

HookQuery: StateType | { action?: string; from: StateType; to: StateType } | { action: string } | { group: string }

Query for Machine.has_hook / Machine.hooks_on. A bare string is read as a state name; an { from, to, action? } object is read as an edge (optionally a named edge); an { action } object is read as a named action; a { group } object is read as a named state group. This mirrors the spec's hooks_on(state) / hooks_on(from→to) / hooks_on(action) / hooks_on(&group) set with one parameter shape.

HookRegistryEntry: { kind: HookDescription<unknown>["kind"] | HookBoundaryKind; phase: HookPhase; target: HookTarget }

One row of the generated uniform observational-hook registry. kind is either an original HookDescription discriminator (e.g. 'entry', 'post named') or a HookBoundaryKind for an FSL boundary hook, phase is the HookPhase the hook runs in, and target is the normalized HookTarget it is bound to. The triple (kind, target, phase) is the registry key the spec calls for.

Type declaration

HookResult<mDT>: boolean | undefined | void | HookComplexResult<mDT>

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.

Type Parameters

  • mDT

HookTarget: { action?: string; from: StateType; scope: "edge"; to: StateType } | { scope: "state"; state: StateType } | { action: string; scope: "action" } | { scope: "global" } | { group: string; scope: "group" }

Normalized description of the target a registry entry is bound to. Exactly one scope variant applies; the present fields depend on the scope:

  • 'edge' carries from + to (+ optional action for named hooks),
  • 'state' carries state,
  • 'action' carries action,
  • 'global' carries no further keys (it matches everything),
  • 'group' carries group (a named state group with a boundary hook).
HookTargetScope: "edge" | "state" | "action" | "global" | "group"

Coarse classification of what a hook observes, used to bucket every hook kind into the uniform registry. 'edge' hooks watch a from→to transition (optionally narrowed to a named action); 'state' hooks watch a single state (entry/exit/after, or a state boundary hook); 'action' hooks watch a named action regardless of edge; 'global' hooks watch every transition or every action (the any-*, transition-class, and everything observers); 'group' hooks watch a named state group's enter/exit boundary.

JssmActionEventDetail<mDT>: { action: StateType; data: mDT; from: StateType; next_data?: mDT; to?: StateType }

Detail payload fired with an action event. Fires when an action is attempted, before transition validation runs.

Type Parameters

  • mDT

Type declaration

JssmAllowIslands: boolean | "with_start"

Controls whether the state graph may contain disconnected components (islands). true permits islands (default), false requires a single connected component, and 'with_start' permits islands only when every component contains at least one start state.

JssmAllowsOverride: boolean | undefined

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.

JssmArrow: "->" | "<-" | "<->" | "<=->" | "<~->" | "=>" | "<=" | "<=>" | "<-=>" | "<~=>" | "~>" | "<~" | "<~>" | "<-~>" | "<=~>"

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.

JssmArrowDirection: "left" | "right" | "both"

Direction polarity of an arrow: pointing only 'left', only 'right', or 'both' (a bidirectional arrow).

JssmArrowKind: "none" | "legal" | "main" | "forced"

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.

JssmBaseTheme: { action: undefined; active: JssmStateConfig; active_end: JssmStateConfig; active_hooked: JssmStateConfig; active_start: JssmStateConfig; active_terminal: JssmStateConfig; end: JssmStateConfig; forced: undefined; graph: undefined; hooked: JssmStateConfig; legal: undefined; main: undefined; name: string; start: JssmStateConfig; state: JssmStateConfig; terminal: JssmStateConfig; title: undefined }

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.

Type declaration

JssmBoundaryHooks: { onEnter?: string; onExit?: string }

The compiled boundary-hook surface for a single subject (a group or a state): the action to run on entry (onEnter) and/or on exit (onExit). Each is optional so a subject may declare only one direction; the compiler merges an enter and an exit declaration for the same subject into one of these.

see

JssmHookDeclaration

Type declaration

  • Optional onEnter?: string
  • Optional onExit?: string
JssmColor: string

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.

JssmCompileRule<StateType>: { agg_as: string; val: any }

Internal compiler intermediate: a single aggregated rule produced while folding a parse tree into a machine configuration. Not intended for end-user code.

internal

Type Parameters

  • StateType

Type declaration

  • agg_as: string
  • val: any
JssmCompileSe<StateType, mDT>: { kind: JssmArrow; l_action?: StateType; l_action_loc?: FslSourceLocation; l_after?: number; l_probability: number; loc?: FslSourceLocation; r_action?: StateType; r_action_loc?: FslSourceLocation; r_after?: number; r_probability: number; se?: JssmCompileSe<StateType, mDT>; to: StateType; to_loc?: FslSourceLocation }

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

Type Parameters

  • StateType

  • mDT

Type declaration

JssmCompileSeStart<StateType, DataType>: { default_value?: any; from: StateType; from_loc?: FslSourceLocation; key: string; loc?: FslSourceLocation; name?: string; name_loc?: FslSourceLocation; required?: boolean; se: JssmCompileSe<StateType, DataType>; state?: string; value?: string | number | JssmStateDeclarationRule[]; value_loc?: FslSourceLocation }

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.

internal

Type Parameters

  • StateType

  • DataType

Type declaration

JssmCompleteEventDetail<mDT>: { data: mDT; state: StateType }

Detail payload fired with a complete event. Indicates that the machine has reached a FSL complete state.

Type Parameters

  • mDT

Type declaration

JssmDataChangeEventDetail<mDT>: { action?: StateType; cause: "transition" | "override"; from?: StateType; new_data: mDT; old_data: mDT; to?: StateType }

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.

Type Parameters

  • mDT

Type declaration

JssmDefaultSize: { height?: number; width?: number }

Structured render-size hint for a machine visualization, set by the FSL default_size directive. All three forms are optional in the sense that only one or two fields will be present depending on the form used:

  • { width } — single-number form (default_size: 800;)
  • { width, height } — bounding-box form (default_size: 800 600;)
  • { height } — height-only form (default_size: height 600;)

This is a hint, not a hard constraint. Renderers may ignore it.

see

Machine.default_size

Type declaration

  • Optional height?: number
  • Optional width?: number
JssmEntryEventDetail<mDT>: { action?: StateType; data: mDT; from?: StateType; state: StateType }

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.

Type Parameters

  • mDT

Type declaration

JssmErrorEventDetail: { error: unknown; handler: Function; source_detail: unknown; source_event: JssmEventName }

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.

Type declaration

  • error: unknown
  • handler: Function
  • source_detail: unknown
  • source_event: JssmEventName
JssmErrorExtendedInfo: { requested_state?: StateType; source_location?: FslSourceLocation }

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.

Type declaration

JssmEventDetailMap<mDT>: { action: JssmActionEventDetail<mDT>; complete: JssmCompleteEventDetail<mDT>; data-change: JssmDataChangeEventDetail<mDT>; entry: JssmEntryEventDetail<mDT>; error: JssmErrorEventDetail; exit: JssmExitEventDetail<mDT>; hook-registration: JssmHookLifecycleEventDetail<mDT>; hook-removal: JssmHookLifecycleEventDetail<mDT>; override: JssmOverrideEventDetail<mDT>; rejection: JssmRejectionEventDetail<mDT>; terminal: JssmTerminalEventDetail<mDT>; timeout: JssmTimeoutEventDetail; transition: JssmTransitionEventDetail<mDT> }

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.

Type Parameters

  • mDT

Type declaration

JssmEventFilter<mDT, Ev>: JssmEventFilterMap<mDT>[Ev]

Per-event filter object (as passed to Machine.on). Use JssmEventDetailMap<mDT>[Ev] to find the matching detail type.

Type Parameters

  • mDT

    The type of the machine data member.

  • Ev extends JssmEventName

    The event name.

JssmEventFilterMap<mDT>: { action: Record<string, never>; complete: Record<string, never>; data-change: Record<string, never>; entry: { state?: StateType }; error: Record<string, never>; exit: { state?: StateType }; hook-registration: Record<string, never>; hook-removal: Record<string, never>; override: Record<string, never>; rejection: Record<string, never>; terminal: Record<string, never>; timeout: Record<string, never>; transition: { from?: StateType; to?: StateType } }

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.

Type Parameters

  • mDT

Type declaration

JssmEventHandler<mDT, Ev>: ((detail: JssmEventDetailMap<mDT>[Ev]) => void)

Type Parameters

  • mDT

    The type of the machine data member.

  • Ev extends JssmEventName

    The event name.

Type declaration

    • Per-event handler signature. Receives a detail object typed by event name, so e.action (etc.) only exist where they're meaningful.

      Parameters

      Returns void

JssmEventName: "transition" | "rejection" | "action" | "entry" | "exit" | "terminal" | "complete" | "error" | "data-change" | "override" | "timeout" | "hook-registration" | "hook-removal"

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.

see

Machine.on

JssmExitEventDetail<mDT>: { action?: StateType; data: mDT; state: StateType; to?: StateType }

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.

Type Parameters

  • mDT

Type declaration

JssmGenericConfig<StateType, DataType>: { actions?: JssmPermittedOpt; allow_force?: false; allow_islands?: JssmAllowIslands; allows_override?: JssmAllowsOverride; arrange_declaration?: StateType[][]; arrange_end_declaration?: StateType[][]; arrange_start_declaration?: StateType[][]; auto_api?: boolean | string; boundary_depth_limit?: number; check?: JssmStatePermitterMaybeArray<DataType>; complete?: StateType[]; config_allows_override?: JssmAllowsOverride; data?: DataType; default_active_state_config?: JssmStateStyleKeyList; default_end_state_config?: JssmStateStyleKeyList; default_graph_config?: JssmGraphConfig; default_hooked_state_config?: JssmStateStyleKeyList; default_size?: JssmDefaultSize; default_start_state_config?: JssmStateStyleKeyList; default_state_config?: JssmStateStyleKeyList; default_terminal_state_config?: JssmStateStyleKeyList; default_transition_config?: JssmTransitionConfig; dot_preamble?: string; end_states?: StateType[]; failed_outputs?: StateType[]; flow?: FslDirection; fsl_version?: string; graph_layout?: JssmLayout; group_hooks?: JssmGroupHooks; group_metadata?: Map<string, JssmStateConfig>; group_registry?: JssmGroupRegistry; history?: number; initial_state?: StateType; instance_name?: string; machine_author?: string | string[]; machine_comment?: string; machine_contributor?: string | string[]; machine_definition?: string; machine_language?: string; machine_license?: string; machine_name?: string; machine_version?: string; max_exits?: number; min_exits?: number; name?: string; nodes?: StateType[]; npm_name?: string; property_definition?: JssmPropertyDefinition[]; rng_seed?: number; simplify_bidi?: boolean; start_states: StateType[]; start_states_no_enforce?: boolean; state_declaration?: <internal>.Object[]; state_hooks?: JssmStateHooks; state_property?: JssmPropertyDefinition[]; theme?: FslTheme[]; transitions: JssmTransitions<StateType, DataType>; clear_timeout_source?: any; time_source?: any; timeout_source?: 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.

Type Parameters

  • StateType

    The state-name type (usually string).

  • DataType

    The user-supplied data payload type (mDT).

Type declaration

  • Optional actions?: JssmPermittedOpt
  • Optional allow_force?: false
  • Optional allow_islands?: JssmAllowIslands
  • Optional allows_override?: JssmAllowsOverride
  • Optional arrange_declaration?: StateType[][]
  • Optional arrange_end_declaration?: StateType[][]
  • Optional arrange_start_declaration?: StateType[][]
  • Optional auto_api?: boolean | string
  • Optional boundary_depth_limit?: number

    Maximum depth of the boundary-hook action cascade before the machine throws a JssmError rather than risking a stack overflow or hang.

    Each time a boundary action fires a transition that itself crosses a boundary, the depth counter increments. A cascade exceeding this limit is treated as a probable infinite loop and rejected.

    Defaults to 100. Raise it for legitimate pipelines that genuinely nest more than 100 transitions via boundary hooks.

    see

    Machine._boundary_depth_limit

    see

    Machine._fire_boundary_actions

  • Optional check?: JssmStatePermitterMaybeArray<DataType>
  • Optional complete?: StateType[]
  • Optional config_allows_override?: JssmAllowsOverride
  • Optional data?: DataType
  • Optional default_active_state_config?: JssmStateStyleKeyList
  • Optional default_end_state_config?: JssmStateStyleKeyList
  • Optional default_graph_config?: JssmGraphConfig
  • Optional default_hooked_state_config?: JssmStateStyleKeyList
  • Optional default_size?: JssmDefaultSize
  • Optional default_start_state_config?: JssmStateStyleKeyList
  • Optional default_state_config?: JssmStateStyleKeyList
  • Optional default_terminal_state_config?: JssmStateStyleKeyList
  • Optional default_transition_config?: JssmTransitionConfig
  • Optional dot_preamble?: string
  • Optional end_states?: StateType[]
  • Optional failed_outputs?: StateType[]
  • Optional flow?: FslDirection
  • Optional fsl_version?: string
  • Optional graph_layout?: JssmLayout
  • Optional group_hooks?: JssmGroupHooks
  • Optional group_metadata?: Map<string, JssmStateConfig>
  • Optional group_registry?: JssmGroupRegistry

    Overlapping-state-group tables produced by the compile pass and consumed by the Task-3 runtime cascade.

    group_registry maps each group name to its ordered list of direct members (states and sub-group references) as declared in the FSL source.

    group_metadata maps each group name to its RAW style object { declarations: [...] } — parsed style items from a state &g : { … }; declaration, not condensed JssmStateConfig style fields. Condensation is intentionally deferred to the Task-3 runtime cascade so that depth-specificity resolution can weight each group's contribution before merging into per-state config.

    group_hooks and state_hooks hold boundary-hook payloads keyed by group name and state name respectively; firing is also a Task-3 concern.

    All four fields are absent (undefined) on machines that declare no groups or hooks.

  • Optional history?: number
  • Optional initial_state?: StateType
  • Optional instance_name?: string
  • Optional machine_author?: string | string[]
  • Optional machine_comment?: string
  • Optional machine_contributor?: string | string[]
  • Optional machine_definition?: string
  • Optional machine_language?: string
  • Optional machine_license?: string
  • Optional machine_name?: string
  • Optional machine_version?: string
  • Optional max_exits?: number
  • Optional min_exits?: number
  • Optional name?: string
  • Optional nodes?: StateType[]
  • Optional npm_name?: string
  • Optional property_definition?: JssmPropertyDefinition[]
  • Optional rng_seed?: number
  • Optional simplify_bidi?: boolean
  • start_states: StateType[]
  • Optional start_states_no_enforce?: boolean
  • Optional state_declaration?: <internal>.Object[]
  • Optional state_hooks?: JssmStateHooks
  • Optional state_property?: JssmPropertyDefinition[]
  • Optional theme?: FslTheme[]
  • transitions: JssmTransitions<StateType, DataType>
  • clear_timeout_source?:function
    • clear_timeout_source(number: any): void
  • time_source?:function
    • time_source(): number
  • timeout_source?:function
    • timeout_source(Function: any, number: any): number
JssmGenericMachine<DataType>: { allow_empty?: boolean; allow_force?: boolean; allow_islands?: boolean; check?: JssmStatePermitterMaybeArray<DataType>; data?: DataType; keep_history?: boolean | number; max_transitions?: number; min_transitions?: number; name?: string; nodes?: StateType[]; state: StateType; transitions: JssmTransitions<StateType, DataType> }

Minimal machine description used internally and accepted by some lower-level constructors. Most callers should use the richer JssmGenericConfig instead.

Type Parameters

  • DataType

Type declaration

  • Optional allow_empty?: boolean
  • Optional allow_force?: boolean
  • Optional allow_islands?: boolean
  • Optional check?: JssmStatePermitterMaybeArray<DataType>
  • Optional data?: DataType
  • Optional keep_history?: boolean | number
  • Optional max_transitions?: number
  • Optional min_transitions?: number
  • Optional name?: string
  • Optional nodes?: StateType[]
  • state: StateType
  • transitions: JssmTransitions<StateType, DataType>
JssmGenericState: { complete: boolean; from: StateType[]; name: StateType; to: StateType[] }

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.

Type declaration

JssmGraphAliasKey: { key: "graph_layout"; value: JssmLayout } | { key: "graph_bg_color"; value: JssmColor } | { key: "dot_preamble"; value: string } | { key: "theme"; value: FslTheme | FslTheme[] } | { key: "flow"; value: FslDirection } | JssmGraphDefaultEdgeColor

Graph-scope default-config style items folded from the deprecated top-level graph keywords (graph_layout, graph_bg_color, dot_preamble, theme, flow, and the edge-color/edge_color default) into the consolidated graph: {} config. Each carries the legacy parse key so downstream consumers can disambiguate.

JssmGraphConfig: JssmGraphStyleKey[]

The compiled value of a graph: {} config block: an ordered list of graph-default style items. The compiler folds the deprecated top-level graph keywords into this list first, then lets an explicit graph: {} block override on key conflict.

import { compile, parse } from 'jssm';
const cfg = compile(parse('a -> b; graph_bg_color: #ffffff;'));
// the compiler canonicalizes the folded `graph_bg_color` alias to a
// `background-color` item, so:
// cfg.default_graph_config includes { key: 'background-color', value: '#ffffffff' }
see

JssmTransitionConfig

JssmGraphDefaultEdgeColor: { key: "graph_default_edge_color"; value: JssmColor }

The graph-wide default edge colour style item, produced by the edge-color/edge_color line inside a transition: {} (or graph: {}) config block. Kept distinct from JssmStateStyleColor because it applies to edges rather than nodes, and because it carries the legacy graph_default_edge_color key the grammar emits.

Type declaration

  • key: "graph_default_edge_color"
  • value: JssmColor

A single item inside a graph: {} default-config block. For v1 this reuses the per-state style items plus the graph-scope alias items (JssmGraphAliasKey) folded in from the deprecated top-level graph keywords.

see

JssmGraphConfig

JssmGroupHooks: Map<string, JssmBoundaryHooks>

Maps each group name that has at least one boundary hook to its merged JssmBoundaryHooks. Carried on JssmGenericConfig for the runtime to consume; depth-aware firing is a later task.

see

JssmHookDeclaration

JssmGroupMemberRef: { kind: "state"; name: string } | { kind: "group"; mode: "nest" | "spread"; name: string }

One ordered member of a named group's membership list. A 'state' member is an ordinary state (a inside &g : [a]). A 'group' member references another group: mode: 'nest' is the &child form, which preserves the child group's identity for later precedence/viz, while mode: 'spread' is the ...&child form, which inlines the child's members and erases that identity. Both modes resolve to the same flat set of states via JssmGroupRegistry resolution; only their structural bookkeeping differs.

// `&outer : [&inner x];` direct members:
// [ { kind: 'group', name: 'inner', mode: 'nest' },
// { kind: 'state', name: 'x' } ]
see

JssmGroupRef

see

JssmGroupRegistry

JssmGroupRef: { key: "group_ref"; name: string }

A bare reference to a named group as it appears in the parse tree — written &Name in FSL. Stands in for a state wherever a group may be used (a transition source/target, a state declaration subject, or a hook subject). Distinct from the &Name : [...] declaration form, which defines the group's members.

import { parse } from 'jssm';
parse('&busy : [a b]; &busy -> idle;')[1].from;
// { key: 'group_ref', name: 'busy' }
see

JssmGroupMemberRef

see

JssmGroupRegistry

Type declaration

  • key: "group_ref"
  • name: string
JssmGroupRegistry: Map<string, JssmGroupMemberRef[]>

The compiled group table: maps each declared group name to its ordered, direct members (a JssmGroupMemberRef list). Order is meaningful — it carries declaration/iteration/precedence order — so this is always an array-valued Map, never a Set. Only direct members are stored; transitive (flattened) membership is resolved lazily so the group→group graph survives for viz and precedence.

// for `&inner : [a b]; &outer : [&inner c];`
// registry.get('inner') === [ { kind:'state', name:'a' },
// { kind:'state', name:'b' } ]
// registry.get('outer') === [ { kind:'group', name:'inner', mode:'nest' },
// { kind:'state', name:'c' } ]
see

JssmGroupMemberRef

JssmHistory<mDT>: circular_buffer<[StateType, mDT]>

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.

Type Parameters

  • mDT

JssmHookDeclaration: { action: string; event: "enter" | "exit"; key: "hook_decl"; subject: JssmGroupRef | string }

A parsed FSL boundary-hook declaration — the on <enter|exit> <subject> do '<action>'; form. event is the boundary crossing the hook listens for, subject is either a JssmGroupRef (a &Group) or a plain state label string, and action is the (unquoted) action name to run. The compiler routes a group subject into group_hooks and a state subject into state_hooks on JssmGenericConfig; runtime firing is a later task.

import { parse } from 'jssm';
parse("on enter &busy do 'log';")[0];
// { key:'hook_decl', event:'enter',
// subject:{ key:'group_ref', name:'busy' }, action:'log' }
see

JssmGroupRef

see

JssmGroupHooks

Type declaration

  • action: string
  • event: "enter" | "exit"
  • key: "hook_decl"
  • subject: JssmGroupRef | string
JssmHookLifecycleEventDetail<mDT>: { description: HookDescription<mDT> }

Detail payload fired with hook-registration and hook-removal events. Mirrors the HookDescription so inspector tools can mirror the current hook set.

Type Parameters

  • mDT

Type declaration

JssmLayout: "dot" | "circo" | "twopi" | "fdp" | "neato"

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.

JssmMachineInternalState<DataType>: { actions: Map<StateType, Map<StateType, number>>; edge_map: Map<StateType, Map<StateType, number>>; edges: JssmTransition<StateType, DataType>[]; internal_state_impl_version: 1; named_transitions: Map<StateType, number>; reverse_actions: Map<StateType, Map<StateType, number>>; state: StateType; states: Map<StateType, JssmGenericState> }

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.

Type Parameters

  • DataType

Type declaration

JssmOverrideEventDetail<mDT>: { from: StateType; new_data?: mDT; old_data: mDT; to: StateType }

Detail payload fired with an override event. Distinguishes a forced state replacement from a normal transition.

Type Parameters

  • mDT

Type declaration

JssmParseFunctionType<StateType, mDT>: ((string: any) => JssmParseTree<StateType, mDT>)

Type Parameters

  • StateType

  • mDT

Type declaration

    • 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.

      Parameters

      • string: any

      Returns JssmParseTree<StateType, mDT>

JssmParseTree<StateType, mDT>: JssmCompileSeStart<StateType, mDT>[]

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.

internal

Type Parameters

  • StateType

  • mDT

JssmPermitted: "required" | "disallowed"

Two-state policy flag: a feature is either 'required' or 'disallowed'. Used by machine configuration where the option must take a definite stance.

JssmPermittedOpt: "required" | "disallowed" | "optional"

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).

JssmPropertyDefinition: { default_value?: any; name: string; property?: string; required?: boolean; state?: string }

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.

For state-property bindings (the state_property config list), the compiler also writes property and state — the unserialized pair behind the serialized name — so the Machine constructor can validate bindings without parsing name back apart. Both are optional: hand-built configs may carry only the serialized name, and global property definitions never set them.

Type declaration

  • Optional default_value?: any
  • name: string
  • Optional property?: string
  • Optional required?: boolean
  • Optional state?: string
JssmRejectionEventDetail<mDT>: { action?: StateType; data: mDT; forced: boolean; from: StateType; hook_name?: string; next_data?: mDT; reason: "invalid" | "hook"; to: StateType }

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'.

Type Parameters

  • mDT

Type declaration

  • Optional action?: StateType
  • data: mDT
  • forced: boolean
  • from: StateType
  • Optional hook_name?: string
  • Optional next_data?: mDT
  • reason: "invalid" | "hook"
  • to: StateType

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.

JssmRng: (() => number)

Type declaration

    • (): number
    • 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.

      Returns number

JssmSerialization<DataType>: { comment?: string; data: DataType; history: [string, DataType][]; history_capacity: number; jssm_version: string; state: StateType; timestamp: number }

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.

Type Parameters

  • DataType

    The type of the user-supplied data payload (mDT).

Type declaration

  • Optional comment?: string
  • data: DataType
  • history: [string, DataType][]
  • history_capacity: number
  • jssm_version: string
  • state: StateType
  • timestamp: number
JssmShape: "box" | "polygon" | "ellipse" | "oval" | "circle" | "point" | "egg" | "triangle" | "plaintext" | "plain" | "diamond" | "trapezium" | "parallelogram" | "house" | "pentagon" | "hexagon" | "septagon" | "octagon" | "doublecircle" | "doubleoctagon" | "tripleoctagon" | "invtriangle" | "invtrapezium" | "invhouse" | "Mdiamond" | "Msquare" | "Mcircle" | "rect" | "rectangle" | "square" | "star" | "none" | "underline" | "cylinder" | "note" | "tab" | "folder" | "box3d" | "component" | "promoter" | "cds" | "terminator" | "utr" | "primersite" | "restrictionsite" | "fivepoverhang" | "threepoverhang" | "noverhang" | "assembly" | "signature" | "insulator" | "ribosite" | "rnastab" | "proteasesite" | "proteinstab" | "rpromoter" | "rarrow" | "larrow" | "lpromoter" | "record"

A type teaching Typescript the various supported shapes for nodes, mostly inherited from GraphViz

JssmStateConfig: Partial<JssmStateDeclaration>

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.

JssmStateDeclaration: { backgroundColor?: JssmColor; borderColor?: JssmColor; color?: JssmColor; corners?: JssmCorner; declarations: JssmStateDeclarationRule[]; image?: string; lineStyle?: JssmLineStyle; property?: { name: string; value: unknown }; shape?: JssmShape; state: StateType; stateLabel?: string; textColor?: JssmColor; url?: string }

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.

Type declaration

JssmStateDeclarationRule: { key: string; loc?: FslSourceLocation; name?: string; value: any; value_loc?: FslSourceLocation }

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.

Type declaration

JssmStateHooks: Map<string, JssmBoundaryHooks>

Maps each plain state name that has at least one boundary hook to its merged JssmBoundaryHooks. The state-subject analogue of JssmGroupHooks.

see

JssmHookDeclaration

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.

JssmStateStyleKeyList: JssmStateStyleKey[]

An ordered list of JssmStateStyleKey entries. Used by the default_*_state_config machine config options to provide a fallback style stack.

JssmTerminalEventDetail<mDT>: { data: mDT; state: StateType }

Detail payload fired with a terminal event. Indicates that the machine has reached a state with no outgoing edges.

Type Parameters

  • mDT

Type declaration

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.

JssmTimeoutEventDetail: { after_time: number; from: StateType; to: StateType }

Detail payload fired with a timeout event. Fires when a configured after clause causes an automatic transition.

Type declaration

JssmTransition<StateType, DataType>: { action?: StateType; after_time?: number; check?: JssmTransitionPermitterMaybeArray<DataType>; forced_only: boolean; from: StateType; kind: JssmArrowKind; main_path: boolean; name?: StateType; probability?: number; se?: JssmCompileSe<StateType, DataType>; to: StateType }

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.

Type Parameters

  • StateType

    The state-name type (usually string).

  • DataType

    The machine's data payload type (mDT).

Type declaration

  • Optional action?: StateType
  • Optional after_time?: number
  • Optional check?: JssmTransitionPermitterMaybeArray<DataType>
  • forced_only: boolean
  • from: StateType
  • kind: JssmArrowKind
  • main_path: boolean
  • Optional name?: StateType
  • Optional probability?: number
  • Optional se?: JssmCompileSe<StateType, DataType>
  • to: StateType
JssmTransitionConfig: JssmTransitionStyleKey[]

The compiled value of a transition: {} config block: an ordered list of edge-default style items. V1 mirrors the state-style shape used by default_state_config; group machinery that consumes it lands in a later task.

import { compile, parse } from 'jssm';
const cfg = compile(parse('a -> b; transition: { color: red; };'));
// cfg.default_transition_config === [ { key: 'color', value: '#ff0000ff' } ]
see

JssmGraphConfig

JssmTransitionEventDetail<mDT>: { action?: StateType; data: mDT; forced: boolean; from: StateType; next_data?: mDT; to: StateType; trans_type: string | undefined }

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.

Type Parameters

  • mDT

Type declaration

JssmTransitionList: { entrances: StateType[]; exits: StateType[] }

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.

Type declaration

JssmTransitionRule: StateType | JssmTransitionCycle

An entry produced while parsing a transition rule: either a literal state name (StateType) or a JssmTransitionCycle marker.

A single item inside a transition: {} default-config block. For v1 this reuses the per-state style items (so color: red; works inside a transition: block exactly as inside a state: block) plus the edge-scoped JssmGraphDefaultEdgeColor default.

see

JssmTransitionConfig

JssmTransitions<StateType, DataType>: JssmTransition<StateType, DataType>[]

A list of JssmTransitions — the edge set of a machine.

Type Parameters

  • StateType

  • DataType

JssmUnsubscribe: (() => void)

Type declaration

    • (): void
    • Function returned by Machine.on and Machine.once that removes the subscription. Calling it more than once is a no-op.

      Returns void

PostEverythingHookHandler<mDT>: ((hook_context: EverythingHookContext<mDT>) => void)

Type Parameters

  • mDT

Type declaration

Variables

FslDirections: readonly ["up", "right", "down", "left"] = ...

Runtime-iterable list of valid flow directions for FSL diagrams. Use this when you need to enumerate directions; for the type itself see FslDirection.

FslThemes: readonly ["default", "ocean", "modern", "plain", "bold"] = ...

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