jssm 5.65.2 → 5.65.3
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 +106 -2
- package/dist/es6/jssm.js +124 -2
- 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 +106 -2
- package/package.json +1 -1
package/jssm.d.ts
CHANGED
|
@@ -51,13 +51,117 @@ declare function arrow_left_kind(arrow: JssmArrow): JssmArrowKind;
|
|
|
51
51
|
declare function arrow_right_kind(arrow: JssmArrow): JssmArrowKind;
|
|
52
52
|
/*********
|
|
53
53
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
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
|
+
* ```typescript
|
|
86
|
+
* import { sm } from './jssm';
|
|
87
|
+
*
|
|
88
|
+
* const switch = sm`on <=> off;`;
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* … or …
|
|
92
|
+
*
|
|
93
|
+
* ```typescript
|
|
94
|
+
* import * as jssm from './jssm';
|
|
95
|
+
*
|
|
96
|
+
* const toggle = jssm.from('up <=> down;');
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* `wrap_parse` itself is an internal convenience method for alting out an
|
|
100
|
+
* object as the options call. Not generally meant for external use.
|
|
56
101
|
*
|
|
57
102
|
*/
|
|
58
103
|
declare function wrap_parse(input: string, options?: Object): any;
|
|
104
|
+
/*********
|
|
105
|
+
*
|
|
106
|
+
* Compile a machine's JSON intermediate representation to a config object. If
|
|
107
|
+
* you're using this (probably don't,) you're probably also using
|
|
108
|
+
* {@link parse} to get the IR, and the object constructor
|
|
109
|
+
* {@link Machine.construct} to turn the config object into a workable machine.
|
|
110
|
+
*
|
|
111
|
+
* ```typescript
|
|
112
|
+
* import { parse, compile, Machine } from './jssm';
|
|
113
|
+
*
|
|
114
|
+
* const intermediate = parse('a -> b;');
|
|
115
|
+
* // [ {key:'transition', from:'a', se:{kind:'->',to:'b'}} ]
|
|
116
|
+
*
|
|
117
|
+
* const cfg = compile(intermediate);
|
|
118
|
+
* // { start_states:['a'], transitions: [{ from:'a', to:'b', kind:'legal', forced_only:false, main_path:false }] }
|
|
119
|
+
*
|
|
120
|
+
* const machine = new Machine(cfg);
|
|
121
|
+
* // Machine { _instance_name: undefined, _state: 'a', ...
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* This method is mostly for plugin and intermediate tool authors, or people
|
|
125
|
+
* who need to work with the machine's intermediate representation.
|
|
126
|
+
*
|
|
127
|
+
* # Hey!
|
|
128
|
+
*
|
|
129
|
+
* Most people looking at this want either the `sm` operator or method `from`,
|
|
130
|
+
* which perform all the steps in the chain. The library's author mostly uses
|
|
131
|
+
* operator `sm`, and mostly falls back to `.from` when needing to parse
|
|
132
|
+
* strings dynamically instead of from template literals.
|
|
133
|
+
*
|
|
134
|
+
* ```typescript
|
|
135
|
+
* import { sm } from './jssm';
|
|
136
|
+
*
|
|
137
|
+
* const switch = sm`on <=> off;`;
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
140
|
+
* … or …
|
|
141
|
+
*
|
|
142
|
+
* ```typescript
|
|
143
|
+
* import * as jssm from './jssm';
|
|
144
|
+
*
|
|
145
|
+
* const toggle = jssm.from('up <=> down;');
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
*/
|
|
59
149
|
declare function compile<mDT>(tree: JssmParseTree): JssmGenericConfig<mDT>;
|
|
150
|
+
/*********
|
|
151
|
+
*
|
|
152
|
+
* An internal convenience wrapper for parsing then compiling a machine string.
|
|
153
|
+
* Not generally meant for external use. Please see {@link compile} or
|
|
154
|
+
* {@link sm}.
|
|
155
|
+
*
|
|
156
|
+
*/
|
|
60
157
|
declare function make<mDT>(plan: string): JssmGenericConfig<mDT>;
|
|
158
|
+
/*********
|
|
159
|
+
*
|
|
160
|
+
* An internal method meant to take a series of declarations and fold them into
|
|
161
|
+
* a single multi-faceted declaration, in the process of building a state. Not
|
|
162
|
+
* generally meant for external use.
|
|
163
|
+
*
|
|
164
|
+
*/
|
|
61
165
|
declare function transfer_state_properties(state_decl: JssmStateDeclaration): JssmStateDeclaration;
|
|
62
166
|
declare class Machine<mDT> {
|
|
63
167
|
_state: StateType;
|