-
Notifications
You must be signed in to change notification settings - Fork 21
/
jssm.d.ts
105 lines (105 loc) · 5.63 KB
/
jssm.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
declare type StateType = string;
import { JssmGenericState, JssmGenericConfig, JssmTransition, JssmTransitionList, // JssmTransitionRule,
JssmMachineInternalState, JssmParseTree, JssmStateDeclaration, JssmArrow, JssmArrowDirection, JssmArrowKind, JssmLayout, FslDirection, FslTheme, HookDescription } from './jssm_types';
import { seq, weighted_rand_select, weighted_sample_select, histograph, weighted_histo_key } from './jssm_util';
import { version } from './version';
declare function arrow_direction(arrow: JssmArrow): JssmArrowDirection;
declare function arrow_left_kind(arrow: JssmArrow): JssmArrowKind;
declare function arrow_right_kind(arrow: JssmArrow): JssmArrowKind;
declare function wrap_parse(input: string, options?: Object): any;
declare function compile<mDT>(tree: JssmParseTree): JssmGenericConfig<mDT>;
declare function make<mDT>(plan: string): JssmGenericConfig<mDT>;
declare function transfer_state_properties(state_decl: JssmStateDeclaration): JssmStateDeclaration;
declare class Machine<mDT> {
_state: StateType;
_states: Map<StateType, JssmGenericState>;
_edges: Array<JssmTransition<mDT>>;
_edge_map: Map<StateType, Map<StateType, number>>;
_named_transitions: Map<StateType, number>;
_actions: Map<StateType, Map<StateType, number>>;
_reverse_actions: Map<StateType, Map<StateType, number>>;
_reverse_action_targets: Map<StateType, Map<StateType, number>>;
_machine_author?: Array<string>;
_machine_comment?: string;
_machine_contributor?: Array<string>;
_machine_definition?: string;
_machine_language?: string;
_machine_license?: string;
_machine_name?: string;
_machine_version?: string;
_fsl_version?: string;
_raw_state_declaration?: Array<Object>;
_state_declarations: Map<StateType, JssmStateDeclaration>;
_graph_layout: JssmLayout;
_dot_preamble: string;
_arrange_declaration: Array<Array<StateType>>;
_arrange_start_declaration: Array<Array<StateType>>;
_arrange_end_declaration: Array<Array<StateType>>;
_theme: FslTheme;
_flow: FslDirection;
_has_hooks: boolean;
_hooks: Map<string, Function>;
_named_hooks: Map<string, Function>;
constructor({ start_states, complete, transitions, machine_author, machine_comment, machine_contributor, machine_definition, machine_language, machine_license, machine_name, machine_version, state_declaration, fsl_version, dot_preamble, arrange_declaration, arrange_start_declaration, arrange_end_declaration, theme, flow, graph_layout }: JssmGenericConfig<mDT>);
_new_state(state_config: JssmGenericState): StateType;
state(): StateType;
state_is_final(whichState: StateType): boolean;
is_final(): boolean;
graph_layout(): string;
dot_preamble(): string;
machine_author(): Array<string>;
machine_comment(): string;
machine_contributor(): Array<string>;
machine_definition(): string;
machine_language(): string;
machine_license(): string;
machine_name(): string;
machine_version(): string;
raw_state_declarations(): Array<Object>;
state_declaration(which: StateType): JssmStateDeclaration;
state_declarations(): Map<StateType, JssmStateDeclaration>;
fsl_version(): string;
machine_state(): JssmMachineInternalState<mDT>;
states(): Array<StateType>;
state_for(whichState: StateType): JssmGenericState;
has_state(whichState: StateType): boolean;
list_edges(): Array<JssmTransition<mDT>>;
list_named_transitions(): Map<StateType, number>;
list_actions(): Array<StateType>;
theme(): FslTheme;
flow(): FslDirection;
get_transition_by_state_names(from: StateType, to: StateType): number;
lookup_transition_for(from: StateType, to: StateType): JssmTransition<mDT>;
list_transitions(whichState?: StateType): JssmTransitionList;
list_entrances(whichState?: StateType): Array<StateType>;
list_exits(whichState?: StateType): Array<StateType>;
probable_exits_for(whichState: StateType): Array<JssmTransition<mDT>>;
probabilistic_transition(): boolean;
probabilistic_walk(n: number): Array<StateType>;
probabilistic_histo_walk(n: number): Map<StateType, number>;
actions(whichState?: StateType): Array<StateType>;
list_states_having_action(whichState: StateType): Array<StateType>;
list_exit_actions(whichState?: StateType): Array<StateType>;
probable_action_exits(whichState?: StateType): Array<any>;
is_unenterable(whichState: StateType): boolean;
has_unenterables(): boolean;
is_terminal(): boolean;
state_is_terminal(whichState: StateType): boolean;
has_terminals(): boolean;
is_complete(): boolean;
state_is_complete(whichState: StateType): boolean;
has_completes(): boolean;
set_hook(HookDesc: HookDescription): void;
remove_hook(HookDesc: HookDescription): void;
action(name: StateType, newData?: mDT): boolean;
transition(newState: StateType, newData?: mDT): boolean;
force_transition(newState: StateType, newData?: mDT): boolean;
current_action_for(action: StateType): number;
current_action_edge_for(action: StateType): JssmTransition<mDT>;
valid_action(action: StateType, _newData?: mDT): boolean;
valid_transition(newState: StateType, _newData?: mDT): boolean;
valid_force_transition(newState: StateType, _newData?: mDT): boolean;
sm(template_strings: TemplateStringsArray, ...remainder: any[]): Machine<mDT>;
}
declare function sm<mDT>(template_strings: TemplateStringsArray, ...remainder: any[]): Machine<mDT>;
export { version, transfer_state_properties, Machine, make, wrap_parse as parse, compile, sm, arrow_direction, arrow_left_kind, arrow_right_kind, seq, weighted_rand_select, histograph, weighted_sample_select, weighted_histo_key };