UNPKG

7.17 kBTypeScriptView Raw
1declare type StateType = string;
2declare type JssmSuccess = {
3 success: true;
4};
5declare type JssmFailure = {
6 success: false;
7 error: any;
8};
9declare type JssmIncomplete = {
10 success: 'incomplete';
11};
12declare type JssmResult = JssmSuccess | JssmFailure | JssmIncomplete;
13declare type JssmColor = string;
14declare type JssmPermitted = 'required' | 'disallowed';
15declare type JssmPermittedOpt = 'required' | 'disallowed' | 'optional';
16declare type JssmArrow = '->' | '<-' | '<->' | '<=->' | '<~->' | '=>' | '<=' | '<=>' | '<-=>' | '<~=>' | '~>' | '<~' | '<~>' | '<-~>' | '<=~>';
17declare 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";
18declare type JssmArrowDirection = 'left' | 'right' | 'both';
19declare type JssmArrowKind = 'none' | 'legal' | 'main' | 'forced';
20declare type JssmLayout = 'dot' | 'circo' | 'twopi' | 'fdp';
21declare type JssmCorner = 'regular' | 'rounded' | 'lined';
22declare type JssmLineStyle = 'solid' | 'dashed' | 'dotted';
23declare type FslDirection = 'up' | 'right' | 'down' | 'left';
24declare type FslTheme = 'default' | 'ocean' | 'modern' | 'none';
25declare type JssmTransitionPermitter<DataType> = (OldState: StateType, NewState: StateType, OldData: DataType, NewData: DataType) => boolean;
26declare type JssmTransitionPermitterMaybeArray<DataType> = JssmTransitionPermitter<DataType> | Array<JssmTransitionPermitter<DataType>>;
27declare type JssmTransition<DataType> = {
28 from: StateType;
29 to: StateType;
30 name?: string;
31 action?: StateType;
32 check?: JssmTransitionPermitterMaybeArray<DataType>;
33 probability?: number;
34 kind: JssmArrowKind;
35 forced_only: boolean;
36 main_path: boolean;
37};
38declare type JssmTransitions<DataType> = Array<JssmTransition<DataType>>;
39declare type JssmTransitionList = {
40 entrances: Array<StateType>;
41 exits: Array<StateType>;
42};
43declare type JssmTransitionCycle = {
44 key: 'cycle';
45 value: StateType;
46};
47declare type JssmTransitionRule = StateType | JssmTransitionCycle;
48declare type JssmGenericState = {
49 from: Array<StateType>;
50 name: StateType;
51 to: Array<StateType>;
52 complete: boolean;
53};
54declare type JssmMachineInternalState<DataType> = {
55 internal_state_impl_version: 1;
56 state: StateType;
57 states: Map<StateType, JssmGenericState>;
58 named_transitions: Map<StateType, number>;
59 edge_map: Map<StateType, Map<StateType, number>>;
60 actions: Map<StateType, Map<StateType, number>>;
61 reverse_actions: Map<StateType, Map<StateType, number>>;
62 edges: Array<JssmTransition<DataType>>;
63};
64declare type JssmStatePermitter<DataType> = (OldState: StateType, NewState: StateType, OldData: DataType, NewData: DataType) => boolean;
65declare type JssmStatePermitterMaybeArray<DataType> = JssmStatePermitter<DataType> | Array<JssmStatePermitter<DataType>>;
66declare type JssmGenericMachine<DataType> = {
67 name?: string;
68 state: StateType;
69 data?: DataType;
70 nodes?: Array<StateType>;
71 transitions: JssmTransitions<DataType>;
72 check?: JssmStatePermitterMaybeArray<DataType>;
73 min_transitions?: number;
74 max_transitions?: number;
75 allow_empty?: boolean;
76 allow_islands?: boolean;
77 allow_force?: boolean;
78 keep_history?: boolean | number;
79};
80declare type JssmStateDeclarationRule = {
81 key: string;
82 value: any;
83};
84declare type JssmStateDeclaration = {
85 declarations: Array<JssmStateDeclarationRule>;
86 shape?: JssmShape;
87 color?: JssmColor;
88 corners?: JssmCorner;
89 linestyle?: JssmLineStyle;
90 textColor?: JssmColor;
91 backgroundColor?: JssmColor;
92 borderColor?: JssmColor;
93 state: StateType;
94};
95declare type JssmGenericConfig<DataType> = {
96 graph_layout?: JssmLayout;
97 complete?: Array<StateType>;
98 transitions: JssmTransitions<DataType>;
99 theme?: FslTheme;
100 flow?: FslDirection;
101 name?: string;
102 data?: DataType;
103 nodes?: Array<StateType>;
104 check?: JssmStatePermitterMaybeArray<DataType>;
105 min_exits?: number;
106 max_exits?: number;
107 allow_islands?: false;
108 allow_force?: false;
109 actions?: JssmPermittedOpt;
110 simplify_bidi?: boolean;
111 dot_preamble?: string;
112 start_states: Array<StateType>;
113 end_states?: Array<StateType>;
114 state_declaration?: Array<Object>;
115 arrange_declaration?: Array<Array<StateType>>;
116 arrange_start_declaration?: Array<Array<StateType>>;
117 arrange_end_declaration?: Array<Array<StateType>>;
118 machine_author?: string | Array<string>;
119 machine_comment?: string;
120 machine_contributor?: string | Array<string>;
121 machine_definition?: string;
122 machine_language?: string;
123 machine_license?: string;
124 machine_name?: string;
125 machine_version?: string;
126 fsl_version?: string;
127 auto_api?: boolean | string;
128};
129declare type JssmCompileRule = {
130 agg_as: string;
131 val: any;
132};
133declare type JssmCompileSe = {
134 to: StateType;
135 se: JssmCompileSe;
136 kind: JssmArrow;
137 l_action?: StateType;
138 r_action?: StateType;
139 l_probability: number;
140 r_probability: number;
141};
142declare type JssmCompileSeStart<DataType> = {
143 from: DataType;
144 se: JssmCompileSe;
145 key: string;
146 value?: string | number;
147 name?: string;
148};
149declare type JssmParseTree = Array<JssmCompileSeStart<StateType>>;
150declare type JssmParseFunctionType = (string: any) => JssmParseTree;
151declare type HookHandler = Function;
152declare type BasicHookDescription = {
153 kind: 'hook';
154 from: string;
155 to: string;
156 handler: HookHandler;
157};
158declare type HookDescriptionWithAction = {
159 kind: 'named';
160 from: string;
161 to: string;
162 action: string;
163 handler: HookHandler;
164};
165declare type AnyTransitionHook = {
166 kind: 'any transition';
167 handler: HookHandler;
168};
169declare type EntryHook = {
170 kind: 'entry';
171 to: string;
172 handler: HookHandler;
173};
174declare type ExitHook = {
175 kind: 'exit';
176 from: string;
177 handler: HookHandler;
178};
179declare type HookDescription = BasicHookDescription | HookDescriptionWithAction | AnyTransitionHook | EntryHook | ExitHook;
180export { JssmColor, JssmTransition, JssmTransitions, JssmTransitionList, JssmTransitionRule, JssmArrow, JssmArrowKind, JssmArrowDirection, JssmGenericConfig, JssmGenericState, JssmGenericMachine, JssmParseTree, JssmCompileSe, JssmCompileSeStart, JssmCompileRule, JssmPermitted, JssmPermittedOpt, JssmResult, JssmStateDeclaration, JssmStateDeclarationRule, JssmLayout, JssmParseFunctionType, JssmMachineInternalState, FslDirection, FslTheme, HookDescription, HookHandler };