import { circular_buffer } from 'circular_buffer_js'; declare type StateType = string; declare type JssmSuccess = { success: true; }; /** Composite type indicating success as part of a result */ declare type JssmFailure = { success: false; error: any; }; /** Composite type indicating an error, and why, as part of a result */ declare type JssmIncomplete = { success: 'incomplete'; }; /** Composite type indicating that a result isn't finished */ declare type JssmResult = JssmSuccess | JssmFailure | JssmIncomplete; /** Composite type composing whether or not a result was successful */ declare type JssmColor = string; declare type JssmPermitted = 'required' | 'disallowed'; declare type JssmPermittedOpt = 'required' | 'disallowed' | 'optional'; declare type JssmArrow = '->' | '<-' | '<->' | '<=->' | '<~->' | '=>' | '<=' | '<=>' | '<-=>' | '<~=>' | '~>' | '<~' | '<~>' | '<-~>' | '<=~>'; /** * A type teaching Typescript the various supported shapes for nodes, mostly inherited from GraphViz */ declare type 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"; declare type JssmArrowDirection = 'left' | 'right' | 'both'; declare type JssmArrowKind = 'none' | 'legal' | 'main' | 'forced'; declare type JssmLayout = 'dot' | 'circo' | 'twopi' | 'fdp' | 'neato'; declare type JssmCorner = 'regular' | 'rounded' | 'lined'; declare type JssmLineStyle = 'solid' | 'dashed' | 'dotted'; declare type JssmAllowsOverride = true | false | undefined; declare const FslDirections: readonly ["up", "right", "down", "left"]; declare type FslDirection = typeof FslDirections[number]; declare const FslThemes: readonly ["default", "ocean", "modern", "plain", "bold"]; declare type FslTheme = typeof FslThemes[number]; declare type JssmSerialization = { jssm_version: string; timestamp: number; comment?: string | undefined; state: StateType; history: [string, DataType][]; history_capacity: number; data: DataType; }; declare type JssmPropertyDefinition = { name: string; default_value?: any; required?: boolean; }; declare type JssmTransitionPermitter = (OldState: StateType, NewState: StateType, OldData: DataType, NewData: DataType) => boolean; declare type JssmTransitionPermitterMaybeArray = JssmTransitionPermitter | Array>; declare type JssmTransition = { from: StateType; to: StateType; after_time?: number; se?: JssmCompileSe; name?: StateType; action?: StateType; check?: JssmTransitionPermitterMaybeArray; probability?: number; kind: JssmArrowKind; forced_only: boolean; main_path: boolean; }; declare type JssmTransitions = JssmTransition[]; declare type JssmTransitionList = { entrances: Array; exits: Array; }; declare type JssmTransitionCycle = { key: 'cycle'; value: StateType; }; declare type JssmTransitionRule = StateType | JssmTransitionCycle; declare type JssmGenericState = { from: Array; name: StateType; to: Array; complete: boolean; }; declare type JssmMachineInternalState = { internal_state_impl_version: 1; state: StateType; states: Map; named_transitions: Map; edge_map: Map>; actions: Map>; reverse_actions: Map>; edges: Array>; }; declare type JssmStatePermitter = (OldState: StateType, NewState: StateType, OldData: DataType, NewData: DataType) => boolean; declare type JssmStatePermitterMaybeArray = JssmStatePermitter | Array>; declare type JssmGenericMachine = { name?: string; state: StateType; data?: DataType; nodes?: Array; transitions: JssmTransitions; check?: JssmStatePermitterMaybeArray; min_transitions?: number; max_transitions?: number; allow_empty?: boolean; allow_islands?: boolean; allow_force?: boolean; keep_history?: boolean | number; }; declare type JssmStateDeclarationRule = { key: string; value: any; name?: string; }; declare type JssmStateDeclaration = { declarations: Array; shape?: JssmShape; color?: JssmColor; corners?: JssmCorner; lineStyle?: JssmLineStyle; stateLabel?: string; textColor?: JssmColor; backgroundColor?: JssmColor; borderColor?: JssmColor; state: StateType; property?: { name: string; value: unknown; }; }; declare type JssmStateConfig = Partial; declare type JssmStateStyleShape = { key: 'shape'; value: JssmShape; }; declare type JssmStateStyleColor = { key: 'color'; value: JssmColor; }; declare type JssmStateStyleTextColor = { key: 'text-color'; value: JssmColor; }; declare type JssmStateStyleCorners = { key: 'corners'; value: JssmCorner; }; declare type JssmStateStyleLineStyle = { key: 'line-style'; value: JssmLineStyle; }; declare type JssmStateStyleStateLabel = { key: 'state-label'; value: string; }; declare type JssmStateStyleBackgroundColor = { key: 'background-color'; value: JssmColor; }; declare type JssmStateStyleBorderColor = { key: 'border-color'; value: JssmColor; }; declare type JssmStateStyleKey = JssmStateStyleShape | JssmStateStyleColor | JssmStateStyleTextColor | JssmStateStyleCorners | JssmStateStyleLineStyle | JssmStateStyleBackgroundColor | JssmStateStyleStateLabel | JssmStateStyleBorderColor; declare type JssmStateStyleKeyList = JssmStateStyleKey[]; declare type JssmBaseTheme = { name: string; state: JssmStateConfig; hooked: JssmStateConfig; start: JssmStateConfig; end: JssmStateConfig; terminal: JssmStateConfig; active: JssmStateConfig; active_hooked: JssmStateConfig; active_start: JssmStateConfig; active_end: JssmStateConfig; active_terminal: JssmStateConfig; graph: undefined; legal: undefined; main: undefined; forced: undefined; action: undefined; title: undefined; }; declare type JssmTheme = Partial; declare type JssmGenericConfig = { graph_layout?: JssmLayout; complete?: Array; transitions: JssmTransitions; theme?: FslTheme[]; flow?: FslDirection; name?: string; data?: DataType; nodes?: Array; check?: JssmStatePermitterMaybeArray; history?: number; min_exits?: number; max_exits?: number; allow_islands?: false; allow_force?: false; actions?: JssmPermittedOpt; simplify_bidi?: boolean; allows_override?: JssmAllowsOverride; config_allows_override?: JssmAllowsOverride; dot_preamble?: string; start_states: Array; end_states?: Array; initial_state?: StateType; start_states_no_enforce?: boolean; state_declaration?: Object[]; property_definition?: JssmPropertyDefinition[]; state_property?: JssmPropertyDefinition[]; arrange_declaration?: Array>; arrange_start_declaration?: Array>; arrange_end_declaration?: Array>; machine_author?: string | Array; machine_comment?: string; machine_contributor?: string | Array; machine_definition?: string; machine_language?: string; machine_license?: string; machine_name?: string; machine_version?: string; fsl_version?: string; auto_api?: boolean | string; instance_name?: string | undefined; default_state_config?: JssmStateStyleKeyList; default_start_state_config?: JssmStateStyleKeyList; default_end_state_config?: JssmStateStyleKeyList; default_hooked_state_config?: JssmStateStyleKeyList; default_terminal_state_config?: JssmStateStyleKeyList; default_active_state_config?: JssmStateStyleKeyList; rng_seed?: number | undefined; time_source?: () => number; timeout_source?: (Function: any, number: any) => number; clear_timeout_source?: (number: any) => void; }; declare type JssmCompileRule = { agg_as: string; val: any; }; declare type JssmCompileSe = { to: StateType; se?: JssmCompileSe; kind: JssmArrow; l_action?: StateType; r_action?: StateType; l_probability: number; r_probability: number; l_after?: number; r_after?: number; }; declare type JssmCompileSeStart = { from: StateType; se: JssmCompileSe; key: string; value?: string | number; name?: string; state?: string; default_value?: any; required?: boolean; }; declare type JssmParseTree = Array>; declare type JssmParseFunctionType = (string: any) => JssmParseTree; declare type BasicHookDescription = { kind: 'hook'; from: string; to: string; handler: HookHandler; }; declare type HookDescriptionWithAction = { kind: 'named'; from: string; to: string; action: string; handler: HookHandler; }; declare type StandardTransitionHook = { kind: 'standard transition'; handler: HookHandler; }; declare type MainTransitionHook = { kind: 'main transition'; handler: HookHandler; }; declare type ForcedTransitionHook = { kind: 'forced transition'; handler: HookHandler; }; declare type AnyTransitionHook = { kind: 'any transition'; handler: HookHandler; }; declare type GlobalActionHook = { kind: 'global action'; action: string; handler: HookHandler; }; declare type AnyActionHook = { kind: 'any action'; handler: HookHandler; }; declare type EntryHook = { kind: 'entry'; to: string; handler: HookHandler; }; declare type ExitHook = { kind: 'exit'; from: string; handler: HookHandler; }; declare type AfterHook = { kind: 'after'; from: string; handler: HookHandler; }; declare type PostBasicHookDescription = { kind: 'post hook'; from: string; to: string; handler: PostHookHandler; }; declare type PostHookDescriptionWithAction = { kind: 'post named'; from: string; to: string; action: string; handler: PostHookHandler; }; declare type PostStandardTransitionHook = { kind: 'post standard transition'; handler: PostHookHandler; }; declare type PostMainTransitionHook = { kind: 'post main transition'; handler: PostHookHandler; }; declare type PostForcedTransitionHook = { kind: 'post forced transition'; handler: PostHookHandler; }; declare type PostAnyTransitionHook = { kind: 'post any transition'; handler: PostHookHandler; }; declare type PostGlobalActionHook = { kind: 'post global action'; action: string; handler: PostHookHandler; }; declare type PostAnyActionHook = { kind: 'post any action'; handler: PostHookHandler; }; declare type PostEntryHook = { kind: 'post entry'; to: string; handler: PostHookHandler; }; declare type PostExitHook = { kind: 'post exit'; from: string; handler: PostHookHandler; }; declare type HookDescription = BasicHookDescription | HookDescriptionWithAction | GlobalActionHook | AnyActionHook | StandardTransitionHook | MainTransitionHook | ForcedTransitionHook | AnyTransitionHook | EntryHook | ExitHook | AfterHook | PostBasicHookDescription | PostHookDescriptionWithAction | PostGlobalActionHook | PostAnyActionHook | PostStandardTransitionHook | PostMainTransitionHook | PostForcedTransitionHook | PostAnyTransitionHook | PostEntryHook | PostExitHook; declare type HookComplexResult = { pass: boolean; state?: StateType; data?: mDT; next_data?: mDT; }; declare type HookResult = true | false | undefined | void | HookComplexResult; /** Documents whether a hook succeeded, either with a primitive or a reference to the hook complex object */ declare type HookContext = { data: mDT; next_data: mDT; }; declare type HookHandler = (hook_context: HookContext) => HookResult; declare type PostHookHandler = (hook_context: HookContext) => void; declare type JssmErrorExtendedInfo = { requested_state?: StateType | undefined; }; declare type JssmHistory = circular_buffer<[StateType, mDT]>; declare type JssmRng = () => number; export { JssmColor, JssmShape, JssmTransition, JssmTransitions, JssmTransitionList, JssmTransitionRule, JssmArrow, JssmArrowKind, JssmArrowDirection, JssmGenericConfig, JssmGenericState, JssmGenericMachine, JssmParseTree, JssmCompileSe, JssmCompileSeStart, JssmCompileRule, JssmPermitted, JssmPermittedOpt, JssmResult, JssmStateDeclaration, JssmStateDeclarationRule, JssmStateConfig, JssmStateStyleKey, JssmStateStyleKeyList, JssmBaseTheme, JssmTheme, JssmLayout, JssmHistory, JssmSerialization, JssmPropertyDefinition, JssmAllowsOverride, JssmParseFunctionType, JssmMachineInternalState, JssmErrorExtendedInfo, FslDirections, FslDirection, FslThemes, FslTheme, HookDescription, HookHandler, HookContext, HookResult, HookComplexResult, JssmRng };