jssm 5.61.4 → 5.64.0
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/README.md +2 -2
- package/dist/es6/jssm.d.ts +6 -2
- package/dist/es6/jssm.js +49 -37
- package/dist/es6/jssm_constants.d.ts +3 -0
- package/dist/es6/jssm_constants.js +64 -0
- package/dist/es6/jssm_error.d.ts +8 -0
- package/dist/es6/jssm_error.js +28 -0
- package/dist/es6/jssm_types.d.ts +5 -1
- 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 +6 -2
- package/jssm_constants.d.ts +3 -0
- package/jssm_error.d.ts +8 -0
- package/jssm_types.d.ts +5 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -62,8 +62,8 @@ What if integration with the outside was straightforward?
|
|
|
62
62
|
|
|
63
63
|
```javascript
|
|
64
64
|
const MTL = sm`Red 'next' -> Green 'next' -> Yellow 'next' -> Red;` // MTL = More Traffic Lights
|
|
65
|
-
.hook('Red', 'Green', () =>
|
|
66
|
-
.hook_entry('Red', () =>
|
|
65
|
+
.hook('Red', 'Green', () => log('GO GO GO') ) // node will jump the gun when you hit return, though
|
|
66
|
+
.hook_entry('Red', () => log('STOP') ); // so put it on one line in node
|
|
67
67
|
|
|
68
68
|
log( MTL.state() ); // 'Red'
|
|
69
69
|
|
package/dist/es6/jssm.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ declare type StateType = string;
|
|
|
2
2
|
import { JssmGenericState, JssmGenericConfig, JssmTransition, JssmTransitionList, // JssmTransitionRule,
|
|
3
3
|
JssmMachineInternalState, JssmParseTree, JssmStateDeclaration, JssmArrow, JssmArrowDirection, JssmArrowKind, JssmLayout, FslDirection, FslTheme, HookDescription, HookHandler } from './jssm_types';
|
|
4
4
|
import { seq, weighted_rand_select, weighted_sample_select, histograph, weighted_histo_key } from './jssm_util';
|
|
5
|
+
import { shapes, gviz_shapes } from './jssm_constants';
|
|
5
6
|
import { version } from './version';
|
|
6
7
|
declare function arrow_direction(arrow: JssmArrow): JssmArrowDirection;
|
|
7
8
|
declare function arrow_left_kind(arrow: JssmArrow): JssmArrowKind;
|
|
@@ -30,6 +31,7 @@ declare class Machine<mDT> {
|
|
|
30
31
|
_fsl_version?: string;
|
|
31
32
|
_raw_state_declaration?: Array<Object>;
|
|
32
33
|
_state_declarations: Map<StateType, JssmStateDeclaration>;
|
|
34
|
+
_instance_name: string;
|
|
33
35
|
_graph_layout: JssmLayout;
|
|
34
36
|
_dot_preamble: string;
|
|
35
37
|
_arrange_declaration: Array<Array<StateType>>;
|
|
@@ -54,7 +56,7 @@ declare class Machine<mDT> {
|
|
|
54
56
|
_main_transition_hook: HookHandler | undefined;
|
|
55
57
|
_forced_transition_hook: HookHandler | undefined;
|
|
56
58
|
_any_transition_hook: HookHandler | undefined;
|
|
57
|
-
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>);
|
|
59
|
+
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, instance_name }: JssmGenericConfig<mDT>);
|
|
58
60
|
_new_state(state_config: JssmGenericState): StateType;
|
|
59
61
|
state(): StateType;
|
|
60
62
|
state_is_final(whichState: StateType): boolean;
|
|
@@ -124,7 +126,9 @@ declare class Machine<mDT> {
|
|
|
124
126
|
valid_action(action: StateType, _newData?: mDT): boolean;
|
|
125
127
|
valid_transition(newState: StateType, _newData?: mDT): boolean;
|
|
126
128
|
valid_force_transition(newState: StateType, _newData?: mDT): boolean;
|
|
129
|
+
instance_name(): string | undefined;
|
|
127
130
|
sm(template_strings: TemplateStringsArray, ...remainder: any[]): Machine<mDT>;
|
|
128
131
|
}
|
|
129
132
|
declare function sm<mDT>(template_strings: TemplateStringsArray, ...remainder: any[]): Machine<mDT>;
|
|
130
|
-
|
|
133
|
+
declare function from<mDT>(MachineAsString: string, ExtraConstructorFields?: Partial<JssmGenericConfig<mDT>> | undefined): Machine<mDT>;
|
|
134
|
+
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 };
|
package/dist/es6/jssm.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// whargarbl lots of these return arrays could/should be sets
|
|
2
2
|
import { reduce as reduce_to_639 } from 'reduce-to-639-1';
|
|
3
3
|
import { seq, weighted_rand_select, weighted_sample_select, histograph, weighted_histo_key, array_box_if_string, hook_name, named_hook_name } from './jssm_util';
|
|
4
|
-
import {
|
|
4
|
+
import { shapes, gviz_shapes } from './jssm_constants';
|
|
5
|
+
import { parse } from './jssm-dot';
|
|
5
6
|
import { version } from './version'; // replaced from package.js in build
|
|
7
|
+
import { JssmError } from './jssm_error';
|
|
6
8
|
/* eslint-disable complexity */
|
|
7
9
|
function arrow_direction(arrow) {
|
|
8
10
|
switch (String(arrow)) {
|
|
@@ -52,7 +54,7 @@ function arrow_direction(arrow) {
|
|
|
52
54
|
case '<~⇒':
|
|
53
55
|
return 'both';
|
|
54
56
|
default:
|
|
55
|
-
throw new
|
|
57
|
+
throw new JssmError(undefined, `arrow_direction: unknown arrow type ${arrow}`);
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
/* eslint-enable complexity */
|
|
@@ -94,7 +96,7 @@ function arrow_left_kind(arrow) {
|
|
|
94
96
|
case '↚⇒':
|
|
95
97
|
return 'forced';
|
|
96
98
|
default:
|
|
97
|
-
throw new
|
|
99
|
+
throw new JssmError(undefined, `arrow_direction: unknown arrow type ${arrow}`);
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
/* eslint-enable complexity */
|
|
@@ -136,7 +138,7 @@ function arrow_right_kind(arrow) {
|
|
|
136
138
|
case '⇐↛':
|
|
137
139
|
return 'forced';
|
|
138
140
|
default:
|
|
139
|
-
throw new
|
|
141
|
+
throw new JssmError(undefined, `arrow_direction: unknown arrow type ${arrow}`);
|
|
140
142
|
}
|
|
141
143
|
}
|
|
142
144
|
/* eslint-enable complexity */
|
|
@@ -148,13 +150,13 @@ function makeTransition(this_se, from, to, isRight, _wasList, _wasIndex) {
|
|
|
148
150
|
forced_only: kind === 'forced',
|
|
149
151
|
main_path: kind === 'main'
|
|
150
152
|
};
|
|
151
|
-
// if ((wasList !== undefined) && (wasIndex === undefined)) { throw new
|
|
152
|
-
// if ((wasIndex !== undefined) && (wasList === undefined)) { throw new
|
|
153
|
+
// if ((wasList !== undefined) && (wasIndex === undefined)) { throw new JssmError(undefined, `Must have an index if transition was in a list"); }
|
|
154
|
+
// if ((wasIndex !== undefined) && (wasList === undefined)) { throw new JssmError(undefined, `Must be in a list if transition has an index"); }
|
|
153
155
|
/*
|
|
154
156
|
if (typeof edge.to === 'object') {
|
|
155
157
|
|
|
156
158
|
if (edge.to.key === 'cycle') {
|
|
157
|
-
if (wasList === undefined) { throw "Must have a waslist if a to is type cycle"; }
|
|
159
|
+
if (wasList === undefined) { throw new JssmError(undefined, "Must have a waslist if a to is type cycle"); }
|
|
158
160
|
const nextIndex = wrapBy(wasIndex, edge.to.value, wasList.length);
|
|
159
161
|
edge.to = wasList[nextIndex];
|
|
160
162
|
}
|
|
@@ -208,7 +210,7 @@ function compile_rule_handler(rule) {
|
|
|
208
210
|
}
|
|
209
211
|
if (rule.key === 'state_declaration') {
|
|
210
212
|
if (!rule.name) {
|
|
211
|
-
throw new
|
|
213
|
+
throw new JssmError(undefined, 'State declarations must have a name');
|
|
212
214
|
}
|
|
213
215
|
return { agg_as: 'state_declaration', val: { state: rule.name, declarations: rule.value } };
|
|
214
216
|
}
|
|
@@ -225,7 +227,7 @@ function compile_rule_handler(rule) {
|
|
|
225
227
|
if (tautologies.includes(rule.key)) {
|
|
226
228
|
return { agg_as: rule.key, val: rule.value };
|
|
227
229
|
}
|
|
228
|
-
throw new
|
|
230
|
+
throw new JssmError(undefined, `compile_rule_handler: Unknown rule: ${JSON.stringify(rule)}`);
|
|
229
231
|
}
|
|
230
232
|
function compile(tree) {
|
|
231
233
|
const results = {
|
|
@@ -268,7 +270,7 @@ function compile(tree) {
|
|
|
268
270
|
];
|
|
269
271
|
oneOnlyKeys.map((oneOnlyKey) => {
|
|
270
272
|
if (results[oneOnlyKey].length > 1) {
|
|
271
|
-
throw new
|
|
273
|
+
throw new JssmError(undefined, `May only have one ${oneOnlyKey} statement maximum: ${JSON.stringify(results[oneOnlyKey])}`);
|
|
272
274
|
}
|
|
273
275
|
else {
|
|
274
276
|
if (results[oneOnlyKey].length) {
|
|
@@ -311,14 +313,15 @@ function transfer_state_properties(state_decl) {
|
|
|
311
313
|
case 'border-color':
|
|
312
314
|
state_decl.borderColor = d.value;
|
|
313
315
|
break;
|
|
314
|
-
default: throw new
|
|
316
|
+
default: throw new JssmError(undefined, `Unknown state property: '${JSON.stringify(d)}'`);
|
|
315
317
|
}
|
|
316
318
|
});
|
|
317
319
|
return state_decl;
|
|
318
320
|
}
|
|
319
321
|
class Machine {
|
|
320
322
|
// whargarbl this badly needs to be broken up, monolith master
|
|
321
|
-
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 = undefined, arrange_declaration = [], arrange_start_declaration = [], arrange_end_declaration = [], theme = 'default', flow = 'down', graph_layout = 'dot' }) {
|
|
323
|
+
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 = undefined, arrange_declaration = [], arrange_start_declaration = [], arrange_end_declaration = [], theme = 'default', flow = 'down', graph_layout = 'dot', instance_name }) {
|
|
324
|
+
this._instance_name = instance_name;
|
|
322
325
|
this._state = start_states[0];
|
|
323
326
|
this._states = new Map();
|
|
324
327
|
this._state_declarations = new Map();
|
|
@@ -367,17 +370,17 @@ class Machine {
|
|
|
367
370
|
if (state_declaration) {
|
|
368
371
|
state_declaration.map((state_decl) => {
|
|
369
372
|
if (this._state_declarations.has(state_decl.state)) { // no repeats
|
|
370
|
-
throw new
|
|
373
|
+
throw new JssmError(this, `Added the same state declaration twice: ${JSON.stringify(state_decl.state)}`);
|
|
371
374
|
}
|
|
372
375
|
this._state_declarations.set(state_decl.state, transfer_state_properties(state_decl));
|
|
373
376
|
});
|
|
374
377
|
}
|
|
375
378
|
transitions.map((tr) => {
|
|
376
379
|
if (tr.from === undefined) {
|
|
377
|
-
throw new
|
|
380
|
+
throw new JssmError(this, `transition must define 'from': ${JSON.stringify(tr)}`);
|
|
378
381
|
}
|
|
379
382
|
if (tr.to === undefined) {
|
|
380
|
-
throw new
|
|
383
|
+
throw new JssmError(this, `transition must define 'to': ${JSON.stringify(tr)}`);
|
|
381
384
|
}
|
|
382
385
|
// get the cursors. what a mess
|
|
383
386
|
const cursor_from = this._states.get(tr.from)
|
|
@@ -392,7 +395,7 @@ class Machine {
|
|
|
392
395
|
}
|
|
393
396
|
// guard against existing connections being re-added
|
|
394
397
|
if (cursor_from.to.includes(tr.to)) {
|
|
395
|
-
throw new
|
|
398
|
+
throw new JssmError(this, `already has ${JSON.stringify(tr.from)} to ${JSON.stringify(tr.to)}`);
|
|
396
399
|
}
|
|
397
400
|
else {
|
|
398
401
|
cursor_from.to.push(tr.to);
|
|
@@ -404,7 +407,7 @@ class Machine {
|
|
|
404
407
|
// guard against repeating a transition name
|
|
405
408
|
if (tr.name) {
|
|
406
409
|
if (this._named_transitions.has(tr.name)) {
|
|
407
|
-
throw new
|
|
410
|
+
throw new JssmError(this, `named transition "${JSON.stringify(tr.name)}" already created`);
|
|
408
411
|
}
|
|
409
412
|
else {
|
|
410
413
|
this._named_transitions.set(tr.name, thisEdgeId);
|
|
@@ -426,7 +429,7 @@ class Machine {
|
|
|
426
429
|
this._actions.set(tr.action, actionMap);
|
|
427
430
|
}
|
|
428
431
|
if (actionMap.has(tr.from)) {
|
|
429
|
-
throw new
|
|
432
|
+
throw new JssmError(this, `action ${JSON.stringify(tr.action)} already attached to origin ${JSON.stringify(tr.from)}`);
|
|
430
433
|
}
|
|
431
434
|
else {
|
|
432
435
|
actionMap.set(tr.from, thisEdgeId);
|
|
@@ -449,12 +452,12 @@ class Machine {
|
|
|
449
452
|
const roActionMap = this._reverse_action_targets.get(tr.to); // wasteful - already did has - refactor
|
|
450
453
|
if (roActionMap) {
|
|
451
454
|
if (roActionMap.has(tr.action)) {
|
|
452
|
-
throw new
|
|
455
|
+
throw new JssmError(this, `ro-action ${tr.to} already attached to action ${tr.action}`);
|
|
453
456
|
} else {
|
|
454
457
|
roActionMap.set(tr.action, thisEdgeId);
|
|
455
458
|
}
|
|
456
459
|
} else {
|
|
457
|
-
throw new
|
|
460
|
+
throw new JssmError(this, `should be impossible - flow doesn\'t know .set precedes .get yet again. severe error?');
|
|
458
461
|
}
|
|
459
462
|
*/
|
|
460
463
|
}
|
|
@@ -462,7 +465,7 @@ class Machine {
|
|
|
462
465
|
}
|
|
463
466
|
_new_state(state_config) {
|
|
464
467
|
if (this._states.has(state_config.name)) {
|
|
465
|
-
throw new
|
|
468
|
+
throw new JssmError(this, `state ${JSON.stringify(state_config.name)} already exists`);
|
|
466
469
|
}
|
|
467
470
|
this._states.set(state_config.name, state_config);
|
|
468
471
|
return state_config.name;
|
|
@@ -534,7 +537,7 @@ class Machine {
|
|
|
534
537
|
edges: this._edges,
|
|
535
538
|
named_transitions: this._named_transitions,
|
|
536
539
|
reverse_actions: this._reverse_actions,
|
|
537
|
-
//
|
|
540
|
+
// reverse_action_targets : this._reverse_action_targets,
|
|
538
541
|
state: this._state,
|
|
539
542
|
states: this._states
|
|
540
543
|
};
|
|
@@ -553,7 +556,7 @@ class Machine {
|
|
|
553
556
|
return state;
|
|
554
557
|
}
|
|
555
558
|
else {
|
|
556
|
-
throw new
|
|
559
|
+
throw new JssmError(this, 'No such state', { requested_state: whichState });
|
|
557
560
|
}
|
|
558
561
|
}
|
|
559
562
|
has_state(whichState) {
|
|
@@ -603,7 +606,7 @@ class Machine {
|
|
|
603
606
|
probable_exits_for(whichState) {
|
|
604
607
|
const wstate = this._states.get(whichState);
|
|
605
608
|
if (!(wstate)) {
|
|
606
|
-
throw new
|
|
609
|
+
throw new JssmError(this, `No such state ${JSON.stringify(whichState)} in probable_exits_for`);
|
|
607
610
|
}
|
|
608
611
|
const wstate_to = wstate.to, wtf = wstate_to
|
|
609
612
|
.map((ws) => this.lookup_transition_for(this.state(), ws))
|
|
@@ -632,7 +635,7 @@ class Machine {
|
|
|
632
635
|
return Array.from(wstate.keys());
|
|
633
636
|
}
|
|
634
637
|
else {
|
|
635
|
-
throw new
|
|
638
|
+
throw new JssmError(this, `No such state ${JSON.stringify(whichState)}`);
|
|
636
639
|
}
|
|
637
640
|
}
|
|
638
641
|
list_states_having_action(whichState) {
|
|
@@ -641,7 +644,7 @@ class Machine {
|
|
|
641
644
|
return Array.from(wstate.keys());
|
|
642
645
|
}
|
|
643
646
|
else {
|
|
644
|
-
throw new
|
|
647
|
+
throw new JssmError(this, `No such state ${JSON.stringify(whichState)}`);
|
|
645
648
|
}
|
|
646
649
|
}
|
|
647
650
|
// comeback
|
|
@@ -656,7 +659,7 @@ class Machine {
|
|
|
656
659
|
list_exit_actions(whichState = this.state()) {
|
|
657
660
|
const ra_base = this._reverse_actions.get(whichState);
|
|
658
661
|
if (!(ra_base)) {
|
|
659
|
-
throw new
|
|
662
|
+
throw new JssmError(this, `No such state ${JSON.stringify(whichState)}`);
|
|
660
663
|
}
|
|
661
664
|
return Array.from(ra_base.values())
|
|
662
665
|
.map((edgeId) => this._edges[edgeId])
|
|
@@ -666,7 +669,7 @@ class Machine {
|
|
|
666
669
|
probable_action_exits(whichState = this.state()) {
|
|
667
670
|
const ra_base = this._reverse_actions.get(whichState);
|
|
668
671
|
if (!(ra_base)) {
|
|
669
|
-
throw new
|
|
672
|
+
throw new JssmError(this, `No such state ${JSON.stringify(whichState)}`);
|
|
670
673
|
}
|
|
671
674
|
return Array.from(ra_base.values())
|
|
672
675
|
.map((edgeId) => this._edges[edgeId])
|
|
@@ -679,7 +682,7 @@ class Machine {
|
|
|
679
682
|
// TODO FIXME test that is_unenterable on non-state throws
|
|
680
683
|
is_unenterable(whichState) {
|
|
681
684
|
if (!(this.has_state(whichState))) {
|
|
682
|
-
throw new
|
|
685
|
+
throw new JssmError(this, `No such state ${whichState}`);
|
|
683
686
|
}
|
|
684
687
|
return this.list_entrances(whichState).length === 0;
|
|
685
688
|
}
|
|
@@ -692,7 +695,7 @@ class Machine {
|
|
|
692
695
|
// TODO FIXME test that state_is_terminal on non-state throws
|
|
693
696
|
state_is_terminal(whichState) {
|
|
694
697
|
if (!(this.has_state(whichState))) {
|
|
695
|
-
throw new
|
|
698
|
+
throw new JssmError(this, `No such state ${whichState}`);
|
|
696
699
|
}
|
|
697
700
|
return this.list_exits(whichState).length === 0;
|
|
698
701
|
}
|
|
@@ -708,7 +711,7 @@ class Machine {
|
|
|
708
711
|
return wstate.complete;
|
|
709
712
|
}
|
|
710
713
|
else {
|
|
711
|
-
throw new
|
|
714
|
+
throw new JssmError(this, `No such state ${JSON.stringify(whichState)}`);
|
|
712
715
|
}
|
|
713
716
|
}
|
|
714
717
|
has_completes() {
|
|
@@ -767,8 +770,7 @@ class Machine {
|
|
|
767
770
|
this._has_exit_hooks = true;
|
|
768
771
|
break;
|
|
769
772
|
default:
|
|
770
|
-
|
|
771
|
-
throw new RangeError(`Unknown hook type ${HookDesc.kind}, should be impossible`);
|
|
773
|
+
throw new JssmError(this, `Unknown hook type ${HookDesc.kind}, should be impossible`);
|
|
772
774
|
}
|
|
773
775
|
}
|
|
774
776
|
hook(from, to, handler) {
|
|
@@ -822,7 +824,7 @@ class Machine {
|
|
|
822
824
|
return this;
|
|
823
825
|
}
|
|
824
826
|
// remove_hook(HookDesc: HookDescription) {
|
|
825
|
-
// throw 'TODO: Should remove hook here';
|
|
827
|
+
// throw new JssmError(this, 'TODO: Should remove hook here');
|
|
826
828
|
// }
|
|
827
829
|
edges_between(from, to) {
|
|
828
830
|
return this._edges.filter(edge => ((edge.from === from) && (edge.to === to)));
|
|
@@ -982,7 +984,7 @@ class Machine {
|
|
|
982
984
|
current_action_edge_for(action) {
|
|
983
985
|
const idx = this.current_action_for(action);
|
|
984
986
|
if ((idx === undefined) || (idx === null)) {
|
|
985
|
-
throw new
|
|
987
|
+
throw new JssmError(this, `No such action ${JSON.stringify(action)}`);
|
|
986
988
|
}
|
|
987
989
|
return this._edges[idx];
|
|
988
990
|
}
|
|
@@ -1008,6 +1010,9 @@ class Machine {
|
|
|
1008
1010
|
// todo major incomplete whargarbl comeback
|
|
1009
1011
|
return (this.lookup_transition_for(this.state(), newState) !== undefined);
|
|
1010
1012
|
}
|
|
1013
|
+
instance_name() {
|
|
1014
|
+
return this._instance_name;
|
|
1015
|
+
}
|
|
1011
1016
|
/* eslint-disable no-use-before-define */
|
|
1012
1017
|
/* eslint-disable class-methods-use-this */
|
|
1013
1018
|
sm(template_strings, ...remainder /* , arguments */) {
|
|
@@ -1027,6 +1032,13 @@ function sm(template_strings, ...remainder /* , arguments */) {
|
|
|
1027
1032
|
/* eslint-enable prefer-rest-params */
|
|
1028
1033
|
)));
|
|
1029
1034
|
}
|
|
1030
|
-
|
|
1035
|
+
function from(MachineAsString, ExtraConstructorFields) {
|
|
1036
|
+
const to_decorate = make(MachineAsString);
|
|
1037
|
+
if (ExtraConstructorFields !== undefined) {
|
|
1038
|
+
Object.keys(ExtraConstructorFields).map(key => to_decorate[key] = ExtraConstructorFields[key]);
|
|
1039
|
+
}
|
|
1040
|
+
return new Machine(to_decorate);
|
|
1041
|
+
}
|
|
1042
|
+
export { version, transfer_state_properties, Machine, make, wrap_parse as parse, compile, sm, from, arrow_direction, arrow_left_kind, arrow_right_kind,
|
|
1031
1043
|
// WHARGARBL TODO these should be exported to a utility library
|
|
1032
|
-
seq, weighted_rand_select, histograph, weighted_sample_select, weighted_histo_key };
|
|
1044
|
+
seq, weighted_rand_select, histograph, weighted_sample_select, weighted_histo_key, shapes, gviz_shapes };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const gviz_shapes = [
|
|
2
|
+
"box3d",
|
|
3
|
+
"polygon",
|
|
4
|
+
"ellipse",
|
|
5
|
+
"oval",
|
|
6
|
+
"circle",
|
|
7
|
+
"point",
|
|
8
|
+
"egg",
|
|
9
|
+
"triangle",
|
|
10
|
+
"plaintext",
|
|
11
|
+
"plain",
|
|
12
|
+
"diamond",
|
|
13
|
+
"trapezium",
|
|
14
|
+
"parallelogram",
|
|
15
|
+
"house",
|
|
16
|
+
"pentagon",
|
|
17
|
+
"hexagon",
|
|
18
|
+
"septagon",
|
|
19
|
+
"octagon",
|
|
20
|
+
"doublecircle",
|
|
21
|
+
"doubleoctagon",
|
|
22
|
+
"tripleoctagon",
|
|
23
|
+
"invtriangle",
|
|
24
|
+
"invtrapezium",
|
|
25
|
+
"invhouse",
|
|
26
|
+
"Mdiamond",
|
|
27
|
+
"Msquare",
|
|
28
|
+
"Mcircle",
|
|
29
|
+
"rectangle",
|
|
30
|
+
"rect",
|
|
31
|
+
"square",
|
|
32
|
+
"star",
|
|
33
|
+
"none",
|
|
34
|
+
"underline",
|
|
35
|
+
"cylinder",
|
|
36
|
+
"note",
|
|
37
|
+
"tab",
|
|
38
|
+
"folder",
|
|
39
|
+
"box",
|
|
40
|
+
"component",
|
|
41
|
+
"promoter",
|
|
42
|
+
"cds",
|
|
43
|
+
"terminator",
|
|
44
|
+
"utr",
|
|
45
|
+
"primersite",
|
|
46
|
+
"restrictionsite",
|
|
47
|
+
"fivepoverhang",
|
|
48
|
+
"threepoverhang",
|
|
49
|
+
"noverhang",
|
|
50
|
+
"assembly",
|
|
51
|
+
"signature",
|
|
52
|
+
"insulator",
|
|
53
|
+
"ribosite",
|
|
54
|
+
"rnastab",
|
|
55
|
+
"proteasesite",
|
|
56
|
+
"proteinstab",
|
|
57
|
+
"rpromoter",
|
|
58
|
+
"rarrow",
|
|
59
|
+
"larrow",
|
|
60
|
+
"lpromoter",
|
|
61
|
+
"record"
|
|
62
|
+
];
|
|
63
|
+
const shapes = gviz_shapes;
|
|
64
|
+
export { gviz_shapes, shapes };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { JssmErrorExtendedInfo } from './jssm_types';
|
|
2
|
+
declare class JssmError extends Error {
|
|
3
|
+
message: string;
|
|
4
|
+
base_message: string;
|
|
5
|
+
requested_state: string | undefined;
|
|
6
|
+
constructor(machine: any, message: string, JEEI?: JssmErrorExtendedInfo);
|
|
7
|
+
}
|
|
8
|
+
export { JssmError };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
class JssmError extends Error {
|
|
2
|
+
constructor(machine, message, JEEI) {
|
|
3
|
+
const { requested_state } = (JEEI === undefined)
|
|
4
|
+
? { requested_state: undefined }
|
|
5
|
+
: JEEI;
|
|
6
|
+
const follow_ups = [];
|
|
7
|
+
if (machine) {
|
|
8
|
+
if (machine.state() !== undefined) {
|
|
9
|
+
follow_ups.push(`at "${machine.state()}"`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
if (requested_state !== undefined) {
|
|
13
|
+
follow_ups.push(`requested "${requested_state}"`);
|
|
14
|
+
}
|
|
15
|
+
const complex_msg = `${((machine === null || machine === void 0 ? void 0 : machine.instance_name()) !== undefined)
|
|
16
|
+
? `[[${machine.instance_name()}]]: `
|
|
17
|
+
: ''}${message}${follow_ups.length
|
|
18
|
+
? ` (${follow_ups.join(', ')})`
|
|
19
|
+
: ''}`;
|
|
20
|
+
super(complex_msg);
|
|
21
|
+
this.name = 'JssmError';
|
|
22
|
+
this.message = complex_msg;
|
|
23
|
+
this.base_message = message;
|
|
24
|
+
this.requested_state = requested_state;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
;
|
|
28
|
+
export { JssmError };
|
package/dist/es6/jssm_types.d.ts
CHANGED
|
@@ -125,6 +125,7 @@ declare type JssmGenericConfig<DataType> = {
|
|
|
125
125
|
machine_version?: string;
|
|
126
126
|
fsl_version?: string;
|
|
127
127
|
auto_api?: boolean | string;
|
|
128
|
+
instance_name?: string | undefined;
|
|
128
129
|
};
|
|
129
130
|
declare type JssmCompileRule = {
|
|
130
131
|
agg_as: string;
|
|
@@ -198,4 +199,7 @@ declare type ExitHook = {
|
|
|
198
199
|
handler: HookHandler;
|
|
199
200
|
};
|
|
200
201
|
declare type HookDescription = BasicHookDescription | HookDescriptionWithAction | GlobalActionHook | AnyActionHook | StandardTransitionHook | MainTransitionHook | ForcedTransitionHook | AnyTransitionHook | EntryHook | ExitHook;
|
|
201
|
-
|
|
202
|
+
declare type JssmErrorExtendedInfo = {
|
|
203
|
+
requested_state?: StateType | undefined;
|
|
204
|
+
};
|
|
205
|
+
export { JssmColor, JssmTransition, JssmTransitions, JssmTransitionList, JssmTransitionRule, JssmArrow, JssmArrowKind, JssmArrowDirection, JssmGenericConfig, JssmGenericState, JssmGenericMachine, JssmParseTree, JssmCompileSe, JssmCompileSeStart, JssmCompileRule, JssmPermitted, JssmPermittedOpt, JssmResult, JssmStateDeclaration, JssmStateDeclarationRule, JssmLayout, JssmParseFunctionType, JssmMachineInternalState, JssmErrorExtendedInfo, FslDirection, FslTheme, HookDescription, HookHandler };
|
package/dist/es6/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const version = "5.
|
|
1
|
+
const version = "5.64.0";
|
|
2
2
|
export { version };
|