jssm 5.65.1 → 5.65.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es6/jssm.d.ts +189 -0
- package/dist/es6/jssm.js +213 -0
- package/dist/es6/version.js +1 -1
- package/dist/jssm.es5.cjs.js +1 -1
- package/dist/jssm.es5.iife.js +1 -1
- package/jssm.d.ts +189 -0
- package/package.json +2 -1
package/jssm.d.ts
CHANGED
|
@@ -4,12 +4,168 @@ JssmMachineInternalState, JssmParseTree, JssmStateDeclaration, JssmArrow, JssmAr
|
|
|
4
4
|
import { seq, weighted_rand_select, weighted_sample_select, histograph, weighted_histo_key } from './jssm_util';
|
|
5
5
|
import { shapes, gviz_shapes, named_colors } from './jssm_constants';
|
|
6
6
|
import { version } from './version';
|
|
7
|
+
/*********
|
|
8
|
+
*
|
|
9
|
+
* Return the direction of an arrow - `right`, `left`, or `both`.
|
|
10
|
+
*
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { arrow_direction } from './jssm';
|
|
13
|
+
*
|
|
14
|
+
* arrow_direction('->'); // 'right'
|
|
15
|
+
* arrow_direction('<~=>'); // 'both'
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
7
19
|
declare function arrow_direction(arrow: JssmArrow): JssmArrowDirection;
|
|
20
|
+
/*********
|
|
21
|
+
*
|
|
22
|
+
* Return the direction of an arrow - `right`, `left`, or `both`.
|
|
23
|
+
*
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { arrow_left_kind } from './jssm';
|
|
26
|
+
*
|
|
27
|
+
* arrow_left_kind('<-'); // 'legal'
|
|
28
|
+
* arrow_left_kind('<='); // 'main'
|
|
29
|
+
* arrow_left_kind('<~'); // 'forced'
|
|
30
|
+
* arrow_left_kind('<->'); // 'legal'
|
|
31
|
+
* arrow_left_kind('->'); // 'none'
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
8
35
|
declare function arrow_left_kind(arrow: JssmArrow): JssmArrowKind;
|
|
36
|
+
/*********
|
|
37
|
+
*
|
|
38
|
+
* Return the direction of an arrow - `right`, `left`, or `both`.
|
|
39
|
+
*
|
|
40
|
+
* ```typescript
|
|
41
|
+
* import { arrow_left_kind } from './jssm';
|
|
42
|
+
*
|
|
43
|
+
* arrow_left_kind('->'); // 'legal'
|
|
44
|
+
* arrow_left_kind('=>'); // 'main'
|
|
45
|
+
* arrow_left_kind('~>'); // 'forced'
|
|
46
|
+
* arrow_left_kind('<->'); // 'legal'
|
|
47
|
+
* arrow_left_kind('<-'); // 'none'
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
9
51
|
declare function arrow_right_kind(arrow: JssmArrow): JssmArrowKind;
|
|
52
|
+
/*********
|
|
53
|
+
*
|
|
54
|
+
* This method wraps the parser call that comes from the peg grammar,
|
|
55
|
+
* {@link parse}. Generally neither this nor that should be used directly
|
|
56
|
+
* unless you mean to develop plugins or extensions for the machine.
|
|
57
|
+
*
|
|
58
|
+
* Parses the intermediate representation of a compiled string down to a
|
|
59
|
+
* machine configuration object. If you're using this (probably don't,) you're
|
|
60
|
+
* probably also using {@link compile} and {@link Machine.constructor}.
|
|
61
|
+
*
|
|
62
|
+
* ```typescript
|
|
63
|
+
* import { parse, compile, Machine } from './jssm';
|
|
64
|
+
*
|
|
65
|
+
* const intermediate = wrap_parse('a -> b;', {});
|
|
66
|
+
* // [ {key:'transition', from:'a', se:{kind:'->',to:'b'}} ]
|
|
67
|
+
*
|
|
68
|
+
* const cfg = compile(intermediate);
|
|
69
|
+
* // { start_states:['a'], transitions: [{ from:'a', to:'b', kind:'legal', forced_only:false, main_path:false }] }
|
|
70
|
+
*
|
|
71
|
+
* const machine = new Machine(cfg);
|
|
72
|
+
* // Machine { _instance_name: undefined, _state: 'a', ...
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* This method is mostly for plugin and intermediate tool authors, or people
|
|
76
|
+
* who need to work with the machine's intermediate representation.
|
|
77
|
+
*
|
|
78
|
+
* # Hey!
|
|
79
|
+
*
|
|
80
|
+
* Most people looking at this want either the `sm` operator or method `from`,
|
|
81
|
+
* which perform all the steps in the chain. The library's author mostly uses
|
|
82
|
+
* operator `sm`, and mostly falls back to `.from` when needing to parse
|
|
83
|
+
* strings dynamically instead of from template literals.
|
|
84
|
+
*
|
|
85
|
+
* Operator {@link sm}:
|
|
86
|
+
*
|
|
87
|
+
* ```typescript
|
|
88
|
+
* import { sm } from './jssm';
|
|
89
|
+
*
|
|
90
|
+
* const switch = sm`on <=> off;`;
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* Method {@link from}:
|
|
94
|
+
*
|
|
95
|
+
* ```typescript
|
|
96
|
+
* import * as jssm from './jssm';
|
|
97
|
+
*
|
|
98
|
+
* const toggle = jssm.from('up <=> down;');
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* `wrap_parse` itself is an internal convenience method for alting out an
|
|
102
|
+
* object as the options call. Not generally meant for external use.
|
|
103
|
+
*
|
|
104
|
+
*/
|
|
10
105
|
declare function wrap_parse(input: string, options?: Object): any;
|
|
106
|
+
/*********
|
|
107
|
+
*
|
|
108
|
+
* Compile a machine's JSON intermediate representation to a config object. If
|
|
109
|
+
* you're using this (probably don't,) you're probably also using
|
|
110
|
+
* {@link parse} to get the IR, and the object constructor
|
|
111
|
+
* {@link Machine.construct} to turn the config object into a workable machine.
|
|
112
|
+
*
|
|
113
|
+
* ```typescript
|
|
114
|
+
* import { parse, compile, Machine } from './jssm';
|
|
115
|
+
*
|
|
116
|
+
* const intermediate = parse('a -> b;');
|
|
117
|
+
* // [ {key:'transition', from:'a', se:{kind:'->',to:'b'}} ]
|
|
118
|
+
*
|
|
119
|
+
* const cfg = compile(intermediate);
|
|
120
|
+
* // { start_states:['a'], transitions: [{ from:'a', to:'b', kind:'legal', forced_only:false, main_path:false }] }
|
|
121
|
+
*
|
|
122
|
+
* const machine = new Machine(cfg);
|
|
123
|
+
* // Machine { _instance_name: undefined, _state: 'a', ...
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* This method is mostly for plugin and intermediate tool authors, or people
|
|
127
|
+
* who need to work with the machine's intermediate representation.
|
|
128
|
+
*
|
|
129
|
+
* # Hey!
|
|
130
|
+
*
|
|
131
|
+
* Most people looking at this want either the `sm` operator or method `from`,
|
|
132
|
+
* which perform all the steps in the chain. The library's author mostly uses
|
|
133
|
+
* operator `sm`, and mostly falls back to `.from` when needing to parse
|
|
134
|
+
* strings dynamically instead of from template literals.
|
|
135
|
+
*
|
|
136
|
+
* Operator {@link sm}:
|
|
137
|
+
*
|
|
138
|
+
* ```typescript
|
|
139
|
+
* import { sm } from './jssm';
|
|
140
|
+
*
|
|
141
|
+
* const switch = sm`on <=> off;`;
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* Method {@link from}:
|
|
145
|
+
*
|
|
146
|
+
* ```typescript
|
|
147
|
+
* import * as jssm from './jssm';
|
|
148
|
+
*
|
|
149
|
+
* const toggle = jssm.from('up <=> down;');
|
|
150
|
+
* ```
|
|
151
|
+
*
|
|
152
|
+
*/
|
|
11
153
|
declare function compile<mDT>(tree: JssmParseTree): JssmGenericConfig<mDT>;
|
|
154
|
+
/*********
|
|
155
|
+
*
|
|
156
|
+
* An internal convenience wrapper for parsing then compiling a machine string.
|
|
157
|
+
* Not generally meant for external use. Please see {@link compile} or
|
|
158
|
+
* {@link sm}.
|
|
159
|
+
*
|
|
160
|
+
*/
|
|
12
161
|
declare function make<mDT>(plan: string): JssmGenericConfig<mDT>;
|
|
162
|
+
/*********
|
|
163
|
+
*
|
|
164
|
+
* An internal method meant to take a series of declarations and fold them into
|
|
165
|
+
* a single multi-faceted declaration, in the process of building a state. Not
|
|
166
|
+
* generally meant for external use.
|
|
167
|
+
*
|
|
168
|
+
*/
|
|
13
169
|
declare function transfer_state_properties(state_decl: JssmStateDeclaration): JssmStateDeclaration;
|
|
14
170
|
declare class Machine<mDT> {
|
|
15
171
|
_state: StateType;
|
|
@@ -129,6 +285,39 @@ declare class Machine<mDT> {
|
|
|
129
285
|
instance_name(): string | undefined;
|
|
130
286
|
sm(template_strings: TemplateStringsArray, ...remainder: any[]): Machine<mDT>;
|
|
131
287
|
}
|
|
288
|
+
/*********
|
|
289
|
+
*
|
|
290
|
+
* Create a state machine from a template string. This is one of the two main
|
|
291
|
+
* paths for working with JSSM, alongside {@link from}.
|
|
292
|
+
*
|
|
293
|
+
* Use this method when you want to work directly and conveniently with a
|
|
294
|
+
* constant template expression. Use `.from` when you want to pull from
|
|
295
|
+
* dynamic strings.
|
|
296
|
+
*
|
|
297
|
+
*
|
|
298
|
+
* ```typescript
|
|
299
|
+
* import * as jssm from './jssm';
|
|
300
|
+
*
|
|
301
|
+
* const switch = jssm.from('on <=> off;');
|
|
302
|
+
* ```
|
|
303
|
+
*
|
|
304
|
+
*/
|
|
132
305
|
declare function sm<mDT>(template_strings: TemplateStringsArray, ...remainder: any[]): Machine<mDT>;
|
|
306
|
+
/*********
|
|
307
|
+
*
|
|
308
|
+
* Create a state machine from an implementation string. This is one of the
|
|
309
|
+
* two main paths for working with JSSM, alongside {@link sm}.
|
|
310
|
+
*
|
|
311
|
+
* Use this method when you want to conveniently pull a state machine from a
|
|
312
|
+
* string dynamically. Use operator `sm` when you just want to work with a
|
|
313
|
+
* template expression.
|
|
314
|
+
*
|
|
315
|
+
* ```typescript
|
|
316
|
+
* import * as jssm from './jssm';
|
|
317
|
+
*
|
|
318
|
+
* const switch = jssm.from('on <=> off;');
|
|
319
|
+
* ```
|
|
320
|
+
*
|
|
321
|
+
*/
|
|
133
322
|
declare function from<mDT>(MachineAsString: string, ExtraConstructorFields?: Partial<JssmGenericConfig<mDT>> | undefined): Machine<mDT>;
|
|
134
323
|
export { version, transfer_state_properties, Machine, make, wrap_parse as parse, compile, sm, from, arrow_direction, arrow_left_kind, arrow_right_kind, seq, weighted_rand_select, histograph, weighted_sample_select, weighted_histo_key, shapes, gviz_shapes, named_colors };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jssm",
|
|
3
|
-
"version": "5.65.
|
|
3
|
+
"version": "5.65.4",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=10.0.0"
|
|
6
6
|
},
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"vet": "npm run eslint && npm run audit",
|
|
46
46
|
"benny": "node ./src/buildjs/benchmark.js",
|
|
47
47
|
"build": "npm run vet && npm run test && npm run site && npm run docs && npm run benny",
|
|
48
|
+
"buildnb": "npm run vet && npm run test && npm run site && npm run docs",
|
|
48
49
|
"qbuild": "npm run test",
|
|
49
50
|
"ci_build": "npm run vet && npm run test",
|
|
50
51
|
"minify": "mv dist/es6/jssm-dot.js dist/es6/jssm-dot.nonmin.js && terser dist/es6/jssm-dot.nonmin.js > dist/es6/jssm-dot.js",
|