jssm 5.80.1 → 5.82.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/CHANGELOG.md +38 -45
- package/README.md +2 -2
- package/dist/es6/jssm-dot.js +1 -1
- package/dist/es6/jssm.d.ts +34 -18
- package/dist/es6/jssm.js +121 -55
- package/dist/es6/jssm_types.d.ts +27 -3
- package/dist/es6/{jssm_base_stylesheet.d.ts → themes/jssm_base_stylesheet.d.ts} +3 -2
- package/dist/es6/{jssm_base_stylesheet.js → themes/jssm_base_stylesheet.js} +25 -1
- package/dist/es6/themes/jssm_theme_default.d.ts +11 -0
- package/dist/es6/themes/jssm_theme_default.js +57 -0
- package/dist/es6/themes/jssm_theme_modern.d.ts +11 -0
- package/dist/es6/themes/jssm_theme_modern.js +57 -0
- package/{jssm_base_stylesheet.d.ts → dist/es6/themes/jssm_theme_ocean.d.ts} +3 -2
- package/dist/es6/themes/jssm_theme_ocean.js +55 -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 +34 -18
- package/jssm_types.d.ts +27 -3
- package/package.json +1 -1
package/dist/es6/jssm.d.ts
CHANGED
|
@@ -94,7 +94,7 @@ declare function arrow_right_kind(arrow: JssmArrow): JssmArrowKind;
|
|
|
94
94
|
* ```typescript
|
|
95
95
|
* import { sm } from 'jssm';
|
|
96
96
|
*
|
|
97
|
-
* const
|
|
97
|
+
* const lswitch = sm`on <=> off;`;
|
|
98
98
|
* ```
|
|
99
99
|
*
|
|
100
100
|
* Method {@link from}:
|
|
@@ -149,7 +149,7 @@ declare function wrap_parse(input: string, options?: Object): any;
|
|
|
149
149
|
* ```typescript
|
|
150
150
|
* import { sm } from 'jssm';
|
|
151
151
|
*
|
|
152
|
-
* const
|
|
152
|
+
* const lswitch = sm`on <=> off;`;
|
|
153
153
|
* ```
|
|
154
154
|
*
|
|
155
155
|
* Method {@link from}:
|
|
@@ -218,7 +218,7 @@ declare class Machine<mDT> {
|
|
|
218
218
|
_arrange_declaration: Array<Array<StateType>>;
|
|
219
219
|
_arrange_start_declaration: Array<Array<StateType>>;
|
|
220
220
|
_arrange_end_declaration: Array<Array<StateType>>;
|
|
221
|
-
|
|
221
|
+
_themes: FslTheme[];
|
|
222
222
|
_flow: FslDirection;
|
|
223
223
|
_has_hooks: boolean;
|
|
224
224
|
_has_basic_hooks: boolean;
|
|
@@ -266,6 +266,7 @@ declare class Machine<mDT> {
|
|
|
266
266
|
_terminal_state_style: JssmStateConfig;
|
|
267
267
|
_start_state_style: JssmStateConfig;
|
|
268
268
|
_end_state_style: JssmStateConfig;
|
|
269
|
+
_state_labels: Map<string, string>;
|
|
269
270
|
constructor({ start_states, end_states, complete, transitions, machine_author, machine_comment, machine_contributor, machine_definition, machine_language, machine_license, machine_name, machine_version, state_declaration, property_definition, state_property, fsl_version, dot_preamble, arrange_declaration, arrange_start_declaration, arrange_end_declaration, theme, flow, graph_layout, instance_name, history, data, default_state_config, default_active_state_config, default_hooked_state_config, default_terminal_state_config, default_start_state_config, default_end_state_config }: JssmGenericConfig<mDT>);
|
|
270
271
|
/********
|
|
271
272
|
*
|
|
@@ -282,17 +283,32 @@ declare class Machine<mDT> {
|
|
|
282
283
|
* ```typescript
|
|
283
284
|
* import * as jssm from 'jssm';
|
|
284
285
|
*
|
|
285
|
-
* const
|
|
286
|
-
* console.log(
|
|
286
|
+
* const lswitch = jssm.from('on <=> off;');
|
|
287
|
+
* console.log( lswitch.state() ); // 'on'
|
|
287
288
|
*
|
|
288
|
-
*
|
|
289
|
-
* console.log(
|
|
289
|
+
* lswitch.transition('off');
|
|
290
|
+
* console.log( lswitch.state() ); // 'off'
|
|
290
291
|
* ```
|
|
291
292
|
*
|
|
292
293
|
* @typeparam mDT The type of the machine data member; usually omitted
|
|
293
294
|
*
|
|
294
295
|
*/
|
|
295
296
|
state(): StateType;
|
|
297
|
+
/*********
|
|
298
|
+
*
|
|
299
|
+
* Get the label for a given state, if any; return `undefined` otherwise.
|
|
300
|
+
*
|
|
301
|
+
* ```typescript
|
|
302
|
+
* import * as jssm from 'jssm';
|
|
303
|
+
*
|
|
304
|
+
* const lswitch = jssm.from('a -> b; state a: { label: "Foo!"; };');
|
|
305
|
+
* console.log( lswitch.label_for('a') ); // 'Foo!'
|
|
306
|
+
* ```
|
|
307
|
+
*
|
|
308
|
+
* @typeparam mDT The type of the machine data member; usually omitted
|
|
309
|
+
*
|
|
310
|
+
*/
|
|
311
|
+
label_for(state: StateType): string;
|
|
296
312
|
/*********
|
|
297
313
|
*
|
|
298
314
|
* Get the current data of a machine.
|
|
@@ -300,8 +316,8 @@ declare class Machine<mDT> {
|
|
|
300
316
|
* ```typescript
|
|
301
317
|
* import * as jssm from 'jssm';
|
|
302
318
|
*
|
|
303
|
-
* const
|
|
304
|
-
* console.log(
|
|
319
|
+
* const lswitch = jssm.from('on <=> off;', {data: 1});
|
|
320
|
+
* console.log( lswitch.data() ); // 1
|
|
305
321
|
* ```
|
|
306
322
|
*
|
|
307
323
|
* @typeparam mDT The type of the machine data member; usually omitted
|
|
@@ -545,8 +561,8 @@ declare class Machine<mDT> {
|
|
|
545
561
|
* ```typescript
|
|
546
562
|
* import * as jssm from 'jssm';
|
|
547
563
|
*
|
|
548
|
-
* const
|
|
549
|
-
* console.log(
|
|
564
|
+
* const lswitch = jssm.from('on <=> off;');
|
|
565
|
+
* console.log( lswitch.states() ); // ['on', 'off']
|
|
550
566
|
* ```
|
|
551
567
|
*
|
|
552
568
|
* @typeparam mDT The type of the machine data member; usually omitted
|
|
@@ -561,10 +577,10 @@ declare class Machine<mDT> {
|
|
|
561
577
|
* ```typescript
|
|
562
578
|
* import * as jssm from 'jssm';
|
|
563
579
|
*
|
|
564
|
-
* const
|
|
580
|
+
* const lswitch = jssm.from('on <=> off;');
|
|
565
581
|
*
|
|
566
|
-
* console.log(
|
|
567
|
-
* console.log(
|
|
582
|
+
* console.log( lswitch.has_state('off') ); // true
|
|
583
|
+
* console.log( lswitch.has_state('dance') ); // false
|
|
568
584
|
* ```
|
|
569
585
|
*
|
|
570
586
|
* @typeparam mDT The type of the machine data member; usually omitted
|
|
@@ -609,7 +625,7 @@ declare class Machine<mDT> {
|
|
|
609
625
|
list_edges(): Array<JssmTransition<mDT>>;
|
|
610
626
|
list_named_transitions(): Map<StateType, number>;
|
|
611
627
|
list_actions(): Array<StateType>;
|
|
612
|
-
|
|
628
|
+
themes(): FslTheme[];
|
|
613
629
|
flow(): FslDirection;
|
|
614
630
|
get_transition_by_state_names(from: StateType, to: StateType): number;
|
|
615
631
|
lookup_transition_for(from: StateType, to: StateType): JssmTransition<mDT>;
|
|
@@ -1054,7 +1070,7 @@ declare class Machine<mDT> {
|
|
|
1054
1070
|
* ```
|
|
1055
1071
|
*
|
|
1056
1072
|
* @typeparam mDT The type of the machine data member; usually omitted
|
|
1057
|
-
|
|
1073
|
+
*
|
|
1058
1074
|
* @param actionName The action to engage
|
|
1059
1075
|
*
|
|
1060
1076
|
* @param newData The data change to insert during the action
|
|
@@ -1155,7 +1171,7 @@ declare class Machine<mDT> {
|
|
|
1155
1171
|
* ```typescript
|
|
1156
1172
|
* import * as jssm from 'jssm';
|
|
1157
1173
|
*
|
|
1158
|
-
* const
|
|
1174
|
+
* const lswitch = jssm.from('on <=> off;');
|
|
1159
1175
|
* ```
|
|
1160
1176
|
*
|
|
1161
1177
|
* @typeparam mDT The type of the machine data member; usually omitted
|
|
@@ -1178,7 +1194,7 @@ declare function sm<mDT>(template_strings: TemplateStringsArray, ...remainder: a
|
|
|
1178
1194
|
* ```typescript
|
|
1179
1195
|
* import * as jssm from 'jssm';
|
|
1180
1196
|
*
|
|
1181
|
-
* const
|
|
1197
|
+
* const lswitch = jssm.from('on <=> off;');
|
|
1182
1198
|
* ```
|
|
1183
1199
|
*
|
|
1184
1200
|
* @typeparam mDT The type of the machine data member; usually omitted
|
package/dist/es6/jssm.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
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 { circular_buffer } from 'circular_buffer_js';
|
|
4
|
-
import {
|
|
4
|
+
import { base_theme } from './themes/jssm_base_stylesheet';
|
|
5
|
+
import { default_theme } from './themes/jssm_theme_default';
|
|
6
|
+
import { modern_theme } from './themes/jssm_theme_modern';
|
|
7
|
+
import { ocean_theme } from './themes/jssm_theme_ocean';
|
|
8
|
+
const theme_mapping = new Map();
|
|
9
|
+
theme_mapping.set('default', default_theme);
|
|
10
|
+
theme_mapping.set('modern', modern_theme);
|
|
11
|
+
theme_mapping.set('ocean', ocean_theme);
|
|
5
12
|
import { seq, unique, find_repeated, weighted_rand_select, weighted_sample_select, histograph, weighted_histo_key, array_box_if_string, name_bind_prop_and_state, hook_name, named_hook_name } from './jssm_util';
|
|
6
13
|
import * as constants from './jssm_constants';
|
|
7
14
|
const { shapes, gviz_shapes, named_colors } = constants;
|
|
@@ -272,7 +279,7 @@ function makeTransition(this_se, from, to, isRight, _wasList, _wasIndex) {
|
|
|
272
279
|
* ```typescript
|
|
273
280
|
* import { sm } from 'jssm';
|
|
274
281
|
*
|
|
275
|
-
* const
|
|
282
|
+
* const lswitch = sm`on <=> off;`;
|
|
276
283
|
* ```
|
|
277
284
|
*
|
|
278
285
|
* Method {@link from}:
|
|
@@ -424,7 +431,7 @@ function compile_rule_handler(rule) {
|
|
|
424
431
|
* ```typescript
|
|
425
432
|
* import { sm } from 'jssm';
|
|
426
433
|
*
|
|
427
|
-
* const
|
|
434
|
+
* const lswitch = sm`on <=> off;`;
|
|
428
435
|
* ```
|
|
429
436
|
*
|
|
430
437
|
* Method {@link from}:
|
|
@@ -491,7 +498,7 @@ function compile(tree) {
|
|
|
491
498
|
const oneOnlyKeys = [
|
|
492
499
|
'graph_layout', 'machine_name', 'machine_version', 'machine_comment',
|
|
493
500
|
'fsl_version', 'machine_license', 'machine_definition', 'machine_language',
|
|
494
|
-
'
|
|
501
|
+
'flow', 'dot_preamble'
|
|
495
502
|
];
|
|
496
503
|
oneOnlyKeys.map((oneOnlyKey) => {
|
|
497
504
|
if (results[oneOnlyKey].length > 1) {
|
|
@@ -504,7 +511,7 @@ function compile(tree) {
|
|
|
504
511
|
}
|
|
505
512
|
});
|
|
506
513
|
['arrange_declaration', 'arrange_start_declaration', 'arrange_end_declaration',
|
|
507
|
-
'machine_author', 'machine_contributor', 'machine_reference',
|
|
514
|
+
'machine_author', 'machine_contributor', 'machine_reference', 'theme',
|
|
508
515
|
'state_declaration', 'property_definition', 'default_state_config',
|
|
509
516
|
'default_start_state_config', 'default_end_state_config',
|
|
510
517
|
'default_hooked_state_config', 'default_terminal_state_config',
|
|
@@ -574,6 +581,9 @@ function transfer_state_properties(state_decl) {
|
|
|
574
581
|
case 'background-color':
|
|
575
582
|
state_decl.backgroundColor = d.value;
|
|
576
583
|
break;
|
|
584
|
+
case 'state-label':
|
|
585
|
+
state_decl.stateLabel = d.value;
|
|
586
|
+
break;
|
|
577
587
|
case 'border-color':
|
|
578
588
|
state_decl.borderColor = d.value;
|
|
579
589
|
break;
|
|
@@ -629,6 +639,12 @@ function state_style_condense(jssk) {
|
|
|
629
639
|
}
|
|
630
640
|
state_style.backgroundColor = key.value;
|
|
631
641
|
break;
|
|
642
|
+
case 'state-label':
|
|
643
|
+
if (state_style.stateLabel !== undefined) {
|
|
644
|
+
throw new JssmError(this, `cannot redefine 'state-label' in state_style_condense, already defined`);
|
|
645
|
+
}
|
|
646
|
+
state_style.stateLabel = key.value;
|
|
647
|
+
break;
|
|
632
648
|
case 'border-color':
|
|
633
649
|
if (state_style.borderColor !== undefined) {
|
|
634
650
|
throw new JssmError(this, `cannot redefine 'border-color' in state_style_condense, already defined`);
|
|
@@ -652,7 +668,7 @@ function state_style_condense(jssk) {
|
|
|
652
668
|
// TODO add a lotta docblock here
|
|
653
669
|
class Machine {
|
|
654
670
|
// whargarbl this badly needs to be broken up, monolith master
|
|
655
|
-
constructor({ start_states, end_states = [], complete = [], transitions, machine_author, machine_comment, machine_contributor, machine_definition, machine_language, machine_license, machine_name, machine_version, state_declaration, property_definition, state_property, fsl_version, dot_preamble = undefined, arrange_declaration = [], arrange_start_declaration = [], arrange_end_declaration = [], theme = 'default', flow = 'down', graph_layout = 'dot', instance_name, history, data, default_state_config, default_active_state_config, default_hooked_state_config, default_terminal_state_config, default_start_state_config, default_end_state_config }) {
|
|
671
|
+
constructor({ start_states, end_states = [], complete = [], transitions, machine_author, machine_comment, machine_contributor, machine_definition, machine_language, machine_license, machine_name, machine_version, state_declaration, property_definition, state_property, fsl_version, dot_preamble = undefined, arrange_declaration = [], arrange_start_declaration = [], arrange_end_declaration = [], theme = ['default'], flow = 'down', graph_layout = 'dot', instance_name, history, data, default_state_config, default_active_state_config, default_hooked_state_config, default_terminal_state_config, default_start_state_config, default_end_state_config }) {
|
|
656
672
|
this._instance_name = instance_name;
|
|
657
673
|
this._state = start_states[0];
|
|
658
674
|
this._states = new Map();
|
|
@@ -679,7 +695,7 @@ class Machine {
|
|
|
679
695
|
this._arrange_start_declaration = arrange_start_declaration;
|
|
680
696
|
this._arrange_end_declaration = arrange_end_declaration;
|
|
681
697
|
this._dot_preamble = dot_preamble;
|
|
682
|
-
this.
|
|
698
|
+
this._themes = theme;
|
|
683
699
|
this._flow = flow;
|
|
684
700
|
this._graph_layout = graph_layout;
|
|
685
701
|
this._has_hooks = false;
|
|
@@ -731,6 +747,8 @@ class Machine {
|
|
|
731
747
|
this._end_state_style = state_style_condense(default_end_state_config);
|
|
732
748
|
this._history_length = history || 0;
|
|
733
749
|
this._history = new circular_buffer(this._history_length);
|
|
750
|
+
this._state_labels = new Map();
|
|
751
|
+
// consolidate the state declarations
|
|
734
752
|
if (state_declaration) {
|
|
735
753
|
state_declaration.map((state_decl) => {
|
|
736
754
|
if (this._state_declarations.has(state_decl.state)) { // no repeats
|
|
@@ -739,6 +757,17 @@ class Machine {
|
|
|
739
757
|
this._state_declarations.set(state_decl.state, transfer_state_properties(state_decl));
|
|
740
758
|
});
|
|
741
759
|
}
|
|
760
|
+
// walk the decls for labels; aggregate them when found
|
|
761
|
+
[...this._state_declarations].map(sd => {
|
|
762
|
+
const [key, decl] = sd, labelled = decl.declarations.filter(d => d.key === 'state-label');
|
|
763
|
+
if (labelled.length > 1) {
|
|
764
|
+
throw new JssmError(this, `state ${key} may only have one state-label; has ${labelled.length}`);
|
|
765
|
+
}
|
|
766
|
+
if (labelled.length === 1) {
|
|
767
|
+
this._state_labels.set(key, labelled[0].value);
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
// walk the transitions
|
|
742
771
|
transitions.map((tr) => {
|
|
743
772
|
if (tr.from === undefined) {
|
|
744
773
|
throw new JssmError(this, `transition must define 'from': ${JSON.stringify(tr)}`);
|
|
@@ -890,11 +919,11 @@ class Machine {
|
|
|
890
919
|
* ```typescript
|
|
891
920
|
* import * as jssm from 'jssm';
|
|
892
921
|
*
|
|
893
|
-
* const
|
|
894
|
-
* console.log(
|
|
922
|
+
* const lswitch = jssm.from('on <=> off;');
|
|
923
|
+
* console.log( lswitch.state() ); // 'on'
|
|
895
924
|
*
|
|
896
|
-
*
|
|
897
|
-
* console.log(
|
|
925
|
+
* lswitch.transition('off');
|
|
926
|
+
* console.log( lswitch.state() ); // 'off'
|
|
898
927
|
* ```
|
|
899
928
|
*
|
|
900
929
|
* @typeparam mDT The type of the machine data member; usually omitted
|
|
@@ -903,13 +932,23 @@ class Machine {
|
|
|
903
932
|
state() {
|
|
904
933
|
return this._state;
|
|
905
934
|
}
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
935
|
+
/*********
|
|
936
|
+
*
|
|
937
|
+
* Get the label for a given state, if any; return `undefined` otherwise.
|
|
938
|
+
*
|
|
939
|
+
* ```typescript
|
|
940
|
+
* import * as jssm from 'jssm';
|
|
941
|
+
*
|
|
942
|
+
* const lswitch = jssm.from('a -> b; state a: { label: "Foo!"; };');
|
|
943
|
+
* console.log( lswitch.label_for('a') ); // 'Foo!'
|
|
944
|
+
* ```
|
|
945
|
+
*
|
|
946
|
+
* @typeparam mDT The type of the machine data member; usually omitted
|
|
947
|
+
*
|
|
948
|
+
*/
|
|
949
|
+
label_for(state) {
|
|
950
|
+
return this._state_labels.get(state);
|
|
951
|
+
}
|
|
913
952
|
/*********
|
|
914
953
|
*
|
|
915
954
|
* Get the current data of a machine.
|
|
@@ -917,8 +956,8 @@ class Machine {
|
|
|
917
956
|
* ```typescript
|
|
918
957
|
* import * as jssm from 'jssm';
|
|
919
958
|
*
|
|
920
|
-
* const
|
|
921
|
-
* console.log(
|
|
959
|
+
* const lswitch = jssm.from('on <=> off;', {data: 1});
|
|
960
|
+
* console.log( lswitch.data() ); // 1
|
|
922
961
|
* ```
|
|
923
962
|
*
|
|
924
963
|
* @typeparam mDT The type of the machine data member; usually omitted
|
|
@@ -927,13 +966,6 @@ class Machine {
|
|
|
927
966
|
data() {
|
|
928
967
|
return this._data;
|
|
929
968
|
}
|
|
930
|
-
/* whargarbl todo major
|
|
931
|
-
when we reimplement this, reintroduce this change to the is_final call
|
|
932
|
-
|
|
933
|
-
is_changing(): boolean {
|
|
934
|
-
return true; // todo whargarbl
|
|
935
|
-
}
|
|
936
|
-
*/
|
|
937
969
|
// NEEDS_DOCS
|
|
938
970
|
/*********
|
|
939
971
|
*
|
|
@@ -1273,8 +1305,8 @@ class Machine {
|
|
|
1273
1305
|
* ```typescript
|
|
1274
1306
|
* import * as jssm from 'jssm';
|
|
1275
1307
|
*
|
|
1276
|
-
* const
|
|
1277
|
-
* console.log(
|
|
1308
|
+
* const lswitch = jssm.from('on <=> off;');
|
|
1309
|
+
* console.log( lswitch.states() ); // ['on', 'off']
|
|
1278
1310
|
* ```
|
|
1279
1311
|
*
|
|
1280
1312
|
* @typeparam mDT The type of the machine data member; usually omitted
|
|
@@ -1299,10 +1331,10 @@ class Machine {
|
|
|
1299
1331
|
* ```typescript
|
|
1300
1332
|
* import * as jssm from 'jssm';
|
|
1301
1333
|
*
|
|
1302
|
-
* const
|
|
1334
|
+
* const lswitch = jssm.from('on <=> off;');
|
|
1303
1335
|
*
|
|
1304
|
-
* console.log(
|
|
1305
|
-
* console.log(
|
|
1336
|
+
* console.log( lswitch.has_state('off') ); // true
|
|
1337
|
+
* console.log( lswitch.has_state('dance') ); // false
|
|
1306
1338
|
* ```
|
|
1307
1339
|
*
|
|
1308
1340
|
* @typeparam mDT The type of the machine data member; usually omitted
|
|
@@ -1355,8 +1387,8 @@ class Machine {
|
|
|
1355
1387
|
list_actions() {
|
|
1356
1388
|
return Array.from(this._actions.keys());
|
|
1357
1389
|
}
|
|
1358
|
-
|
|
1359
|
-
return this.
|
|
1390
|
+
themes() {
|
|
1391
|
+
return this._themes; // constructor sets this to "default" otherwise
|
|
1360
1392
|
}
|
|
1361
1393
|
flow() {
|
|
1362
1394
|
return this._flow;
|
|
@@ -2292,6 +2324,12 @@ class Machine {
|
|
|
2292
2324
|
get active_state_style() {
|
|
2293
2325
|
return this._active_state_style;
|
|
2294
2326
|
}
|
|
2327
|
+
/*
|
|
2328
|
+
*/
|
|
2329
|
+
// TODO COMEBACK IMPLEMENTME FIXME
|
|
2330
|
+
// has_hooks(state: StateType): false {
|
|
2331
|
+
// return false;
|
|
2332
|
+
// }
|
|
2295
2333
|
/********
|
|
2296
2334
|
*
|
|
2297
2335
|
* Gets the composite style for a specific node by individually imposing the
|
|
@@ -2312,48 +2350,76 @@ class Machine {
|
|
|
2312
2350
|
*
|
|
2313
2351
|
*/
|
|
2314
2352
|
style_for(state) {
|
|
2353
|
+
// first look up the themes
|
|
2354
|
+
const themes = [];
|
|
2355
|
+
this._themes.forEach(th => {
|
|
2356
|
+
const theme_impl = theme_mapping.get(th);
|
|
2357
|
+
if (theme_impl !== undefined) {
|
|
2358
|
+
themes.push(theme_impl);
|
|
2359
|
+
}
|
|
2360
|
+
});
|
|
2315
2361
|
// basic state style
|
|
2316
|
-
const layers = [
|
|
2317
|
-
|
|
2362
|
+
const layers = [base_theme.state];
|
|
2363
|
+
themes.reverse().map(theme => {
|
|
2364
|
+
if (theme.state) {
|
|
2365
|
+
layers.push(theme.state);
|
|
2366
|
+
}
|
|
2367
|
+
});
|
|
2318
2368
|
if (this._state_style) {
|
|
2319
2369
|
layers.push(this._state_style);
|
|
2320
2370
|
}
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
//
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2371
|
+
// hooked state style
|
|
2372
|
+
// if (this.has_hooks(state)) {
|
|
2373
|
+
// layers.push(base_theme.hooked);
|
|
2374
|
+
// themes.map(theme => {
|
|
2375
|
+
// if (theme.hooked) { layers.push(theme.hooked); }
|
|
2376
|
+
// });
|
|
2377
|
+
// if (this._hooked_state_style) { layers.push(this._hooked_state_style); }
|
|
2378
|
+
// }
|
|
2329
2379
|
// terminal state style
|
|
2330
2380
|
if (this.state_is_terminal(state)) {
|
|
2331
|
-
layers.push(
|
|
2332
|
-
|
|
2381
|
+
layers.push(base_theme.terminal);
|
|
2382
|
+
themes.map(theme => {
|
|
2383
|
+
if (theme.terminal) {
|
|
2384
|
+
layers.push(theme.terminal);
|
|
2385
|
+
}
|
|
2386
|
+
});
|
|
2333
2387
|
if (this._terminal_state_style) {
|
|
2334
2388
|
layers.push(this._terminal_state_style);
|
|
2335
2389
|
}
|
|
2336
2390
|
}
|
|
2337
2391
|
// start state style
|
|
2338
2392
|
if (this.is_start_state(state)) {
|
|
2339
|
-
layers.push(
|
|
2340
|
-
|
|
2393
|
+
layers.push(base_theme.start);
|
|
2394
|
+
themes.map(theme => {
|
|
2395
|
+
if (theme.start) {
|
|
2396
|
+
layers.push(theme.start);
|
|
2397
|
+
}
|
|
2398
|
+
});
|
|
2341
2399
|
if (this._start_state_style) {
|
|
2342
2400
|
layers.push(this._start_state_style);
|
|
2343
2401
|
}
|
|
2344
2402
|
}
|
|
2345
2403
|
// end state style
|
|
2346
2404
|
if (this.is_end_state(state)) {
|
|
2347
|
-
layers.push(
|
|
2348
|
-
|
|
2405
|
+
layers.push(base_theme.end);
|
|
2406
|
+
themes.map(theme => {
|
|
2407
|
+
if (theme.end) {
|
|
2408
|
+
layers.push(theme.end);
|
|
2409
|
+
}
|
|
2410
|
+
});
|
|
2349
2411
|
if (this._end_state_style) {
|
|
2350
2412
|
layers.push(this._end_state_style);
|
|
2351
2413
|
}
|
|
2352
2414
|
}
|
|
2353
2415
|
// active state style
|
|
2354
2416
|
if (this.state() === state) {
|
|
2355
|
-
layers.push(
|
|
2356
|
-
|
|
2417
|
+
layers.push(base_theme.active);
|
|
2418
|
+
themes.map(theme => {
|
|
2419
|
+
if (theme.active) {
|
|
2420
|
+
layers.push(theme.active);
|
|
2421
|
+
}
|
|
2422
|
+
});
|
|
2357
2423
|
if (this._active_state_style) {
|
|
2358
2424
|
layers.push(this._active_state_style);
|
|
2359
2425
|
}
|
|
@@ -2398,7 +2464,7 @@ class Machine {
|
|
|
2398
2464
|
* ```
|
|
2399
2465
|
*
|
|
2400
2466
|
* @typeparam mDT The type of the machine data member; usually omitted
|
|
2401
|
-
|
|
2467
|
+
*
|
|
2402
2468
|
* @param actionName The action to engage
|
|
2403
2469
|
*
|
|
2404
2470
|
* @param newData The data change to insert during the action
|
|
@@ -2543,7 +2609,7 @@ class Machine {
|
|
|
2543
2609
|
* ```typescript
|
|
2544
2610
|
* import * as jssm from 'jssm';
|
|
2545
2611
|
*
|
|
2546
|
-
* const
|
|
2612
|
+
* const lswitch = jssm.from('on <=> off;');
|
|
2547
2613
|
* ```
|
|
2548
2614
|
*
|
|
2549
2615
|
* @typeparam mDT The type of the machine data member; usually omitted
|
|
@@ -2578,7 +2644,7 @@ function sm(template_strings, ...remainder /* , arguments */) {
|
|
|
2578
2644
|
* ```typescript
|
|
2579
2645
|
* import * as jssm from 'jssm';
|
|
2580
2646
|
*
|
|
2581
|
-
* const
|
|
2647
|
+
* const lswitch = jssm.from('on <=> off;');
|
|
2582
2648
|
* ```
|
|
2583
2649
|
*
|
|
2584
2650
|
* @typeparam mDT The type of the machine data member; usually omitted
|
package/dist/es6/jssm_types.d.ts
CHANGED
|
@@ -106,6 +106,7 @@ declare type JssmStateDeclaration = {
|
|
|
106
106
|
color?: JssmColor;
|
|
107
107
|
corners?: JssmCorner;
|
|
108
108
|
lineStyle?: JssmLineStyle;
|
|
109
|
+
stateLabel?: string;
|
|
109
110
|
textColor?: JssmColor;
|
|
110
111
|
backgroundColor?: JssmColor;
|
|
111
112
|
borderColor?: JssmColor;
|
|
@@ -136,6 +137,10 @@ declare type JssmStateStyleLineStyle = {
|
|
|
136
137
|
key: 'line-style';
|
|
137
138
|
value: JssmLineStyle;
|
|
138
139
|
};
|
|
140
|
+
declare type JssmStateStyleStateLabel = {
|
|
141
|
+
key: 'state-label';
|
|
142
|
+
value: string;
|
|
143
|
+
};
|
|
139
144
|
declare type JssmStateStyleBackgroundColor = {
|
|
140
145
|
key: 'background-color';
|
|
141
146
|
value: JssmColor;
|
|
@@ -144,13 +149,32 @@ declare type JssmStateStyleBorderColor = {
|
|
|
144
149
|
key: 'border-color';
|
|
145
150
|
value: JssmColor;
|
|
146
151
|
};
|
|
147
|
-
declare type JssmStateStyleKey = JssmStateStyleShape | JssmStateStyleColor | JssmStateStyleTextColor | JssmStateStyleCorners | JssmStateStyleLineStyle | JssmStateStyleBackgroundColor | JssmStateStyleBorderColor;
|
|
152
|
+
declare type JssmStateStyleKey = JssmStateStyleShape | JssmStateStyleColor | JssmStateStyleTextColor | JssmStateStyleCorners | JssmStateStyleLineStyle | JssmStateStyleBackgroundColor | JssmStateStyleStateLabel | JssmStateStyleBorderColor;
|
|
148
153
|
declare type JssmStateStyleKeyList = JssmStateStyleKey[];
|
|
154
|
+
declare type JssmBaseTheme = {
|
|
155
|
+
state: JssmStateConfig;
|
|
156
|
+
hooked: JssmStateConfig;
|
|
157
|
+
start: JssmStateConfig;
|
|
158
|
+
end: JssmStateConfig;
|
|
159
|
+
terminal: JssmStateConfig;
|
|
160
|
+
active: JssmStateConfig;
|
|
161
|
+
active_hooked: JssmStateConfig;
|
|
162
|
+
active_start: JssmStateConfig;
|
|
163
|
+
active_end: JssmStateConfig;
|
|
164
|
+
active_terminal: JssmStateConfig;
|
|
165
|
+
graph: undefined;
|
|
166
|
+
legal: undefined;
|
|
167
|
+
main: undefined;
|
|
168
|
+
forced: undefined;
|
|
169
|
+
action: undefined;
|
|
170
|
+
title: undefined;
|
|
171
|
+
};
|
|
172
|
+
declare type JssmTheme = Partial<JssmBaseTheme>;
|
|
149
173
|
declare type JssmGenericConfig<DataType> = {
|
|
150
174
|
graph_layout?: JssmLayout;
|
|
151
175
|
complete?: Array<StateType>;
|
|
152
176
|
transitions: JssmTransitions<DataType>;
|
|
153
|
-
theme?: FslTheme;
|
|
177
|
+
theme?: FslTheme[];
|
|
154
178
|
flow?: FslDirection;
|
|
155
179
|
name?: string;
|
|
156
180
|
data?: DataType;
|
|
@@ -327,4 +351,4 @@ declare type JssmErrorExtendedInfo = {
|
|
|
327
351
|
requested_state?: StateType | undefined;
|
|
328
352
|
};
|
|
329
353
|
declare type JssmHistory<mDT> = circular_buffer<[StateType, mDT]>;
|
|
330
|
-
export { JssmColor, JssmShape, JssmTransition, JssmTransitions, JssmTransitionList, JssmTransitionRule, JssmArrow, JssmArrowKind, JssmArrowDirection, JssmGenericConfig, JssmGenericState, JssmGenericMachine, JssmParseTree, JssmCompileSe, JssmCompileSeStart, JssmCompileRule, JssmPermitted, JssmPermittedOpt, JssmResult, JssmStateDeclaration, JssmStateDeclarationRule, JssmStateConfig, JssmStateStyleKey, JssmStateStyleKeyList, JssmLayout, JssmHistory, JssmSerialization, JssmPropertyDefinition, JssmParseFunctionType, JssmMachineInternalState, JssmErrorExtendedInfo, FslDirection, FslTheme, HookDescription, HookHandler, HookContext, HookResult, HookComplexResult };
|
|
354
|
+
export { JssmColor, JssmShape, JssmTransition, JssmTransitions, JssmTransitionList, JssmTransitionRule, JssmArrow, JssmArrowKind, JssmArrowDirection, JssmGenericConfig, JssmGenericState, JssmGenericMachine, JssmParseTree, JssmCompileSe, JssmCompileSeStart, JssmCompileRule, JssmPermitted, JssmPermittedOpt, JssmResult, JssmStateDeclaration, JssmStateDeclarationRule, JssmStateConfig, JssmStateStyleKey, JssmStateStyleKeyList, JssmBaseTheme, JssmTheme, JssmLayout, JssmHistory, JssmSerialization, JssmPropertyDefinition, JssmParseFunctionType, JssmMachineInternalState, JssmErrorExtendedInfo, FslDirection, FslTheme, HookDescription, HookHandler, HookContext, HookResult, HookComplexResult };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JssmStateConfig } from '
|
|
1
|
+
import { JssmStateConfig, JssmBaseTheme } from '../jssm_types';
|
|
2
2
|
declare const base_state_style: JssmStateConfig;
|
|
3
3
|
declare const base_active_state_style: JssmStateConfig;
|
|
4
4
|
declare const base_terminal_state_style: JssmStateConfig;
|
|
@@ -7,4 +7,5 @@ declare const base_start_state_style: JssmStateConfig;
|
|
|
7
7
|
declare const base_active_start_state_style: JssmStateConfig;
|
|
8
8
|
declare const base_end_state_style: JssmStateConfig;
|
|
9
9
|
declare const base_active_end_state_style: JssmStateConfig;
|
|
10
|
-
|
|
10
|
+
declare const base_theme: JssmBaseTheme;
|
|
11
|
+
export { base_state_style, base_active_state_style, base_terminal_state_style, base_active_terminal_state_style, base_start_state_style, base_active_start_state_style, base_end_state_style, base_active_end_state_style, base_theme, base_theme as theme };
|
|
@@ -8,6 +8,9 @@ const base_active_state_style = {
|
|
|
8
8
|
textColor: 'white',
|
|
9
9
|
backgroundColor: 'dodgerblue4'
|
|
10
10
|
};
|
|
11
|
+
const base_hooked_state_style = {
|
|
12
|
+
shape: 'component'
|
|
13
|
+
};
|
|
11
14
|
const base_terminal_state_style = {
|
|
12
15
|
textColor: 'white',
|
|
13
16
|
backgroundColor: 'crimson'
|
|
@@ -22,6 +25,9 @@ const base_start_state_style = {
|
|
|
22
25
|
const base_active_start_state_style = {
|
|
23
26
|
backgroundColor: 'yellowgreen'
|
|
24
27
|
};
|
|
28
|
+
const base_active_hooked_state_style = {
|
|
29
|
+
backgroundColor: 'yellowgreen'
|
|
30
|
+
};
|
|
25
31
|
const base_end_state_style = {
|
|
26
32
|
textColor: 'white',
|
|
27
33
|
backgroundColor: 'darkolivegreen'
|
|
@@ -30,4 +36,22 @@ const base_active_end_state_style = {
|
|
|
30
36
|
textColor: 'white',
|
|
31
37
|
backgroundColor: 'darkgreen'
|
|
32
38
|
};
|
|
33
|
-
|
|
39
|
+
const base_theme = {
|
|
40
|
+
state: base_state_style,
|
|
41
|
+
start: base_start_state_style,
|
|
42
|
+
end: base_end_state_style,
|
|
43
|
+
terminal: base_terminal_state_style,
|
|
44
|
+
hooked: base_hooked_state_style,
|
|
45
|
+
active: base_active_state_style,
|
|
46
|
+
active_start: base_active_start_state_style,
|
|
47
|
+
active_end: base_active_end_state_style,
|
|
48
|
+
active_terminal: base_active_terminal_state_style,
|
|
49
|
+
active_hooked: base_active_hooked_state_style,
|
|
50
|
+
legal: undefined,
|
|
51
|
+
main: undefined,
|
|
52
|
+
forced: undefined,
|
|
53
|
+
action: undefined,
|
|
54
|
+
graph: undefined,
|
|
55
|
+
title: undefined // TODO FIXME
|
|
56
|
+
};
|
|
57
|
+
export { base_state_style, base_active_state_style, base_terminal_state_style, base_active_terminal_state_style, base_start_state_style, base_active_start_state_style, base_end_state_style, base_active_end_state_style, base_theme, base_theme as theme };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { JssmStateConfig, JssmBaseTheme } from '../jssm_types';
|
|
2
|
+
declare const base_state_style: JssmStateConfig;
|
|
3
|
+
declare const base_active_state_style: JssmStateConfig;
|
|
4
|
+
declare const base_terminal_state_style: JssmStateConfig;
|
|
5
|
+
declare const base_active_terminal_state_style: JssmStateConfig;
|
|
6
|
+
declare const base_start_state_style: JssmStateConfig;
|
|
7
|
+
declare const base_active_start_state_style: JssmStateConfig;
|
|
8
|
+
declare const base_end_state_style: JssmStateConfig;
|
|
9
|
+
declare const base_active_end_state_style: JssmStateConfig;
|
|
10
|
+
declare const default_theme: JssmBaseTheme;
|
|
11
|
+
export { base_state_style, base_active_state_style, base_terminal_state_style, base_active_terminal_state_style, base_start_state_style, base_active_start_state_style, base_end_state_style, base_active_end_state_style, default_theme, default_theme as theme };
|