jssm 5.81.2 → 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.
@@ -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
- _theme: FslTheme;
221
+ _themes: FslTheme[];
222
222
  _flow: FslDirection;
223
223
  _has_hooks: boolean;
224
224
  _has_basic_hooks: boolean;
@@ -625,7 +625,7 @@ declare class Machine<mDT> {
625
625
  list_edges(): Array<JssmTransition<mDT>>;
626
626
  list_named_transitions(): Map<StateType, number>;
627
627
  list_actions(): Array<StateType>;
628
- theme(): FslTheme;
628
+ themes(): FslTheme[];
629
629
  flow(): FslDirection;
630
630
  get_transition_by_state_names(from: StateType, to: StateType): number;
631
631
  lookup_transition_for(from: StateType, to: StateType): JssmTransition<mDT>;
@@ -1070,7 +1070,7 @@ declare class Machine<mDT> {
1070
1070
  * ```
1071
1071
  *
1072
1072
  * @typeparam mDT The type of the machine data member; usually omitted
1073
- b *
1073
+ *
1074
1074
  * @param actionName The action to engage
1075
1075
  *
1076
1076
  * @param newData The data change to insert during the action
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 { base_state_style, base_start_state_style, base_end_state_style, base_terminal_state_style, base_active_state_style } from './jssm_base_stylesheet';
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;
@@ -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
- 'theme', 'flow', 'dot_preamble'
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',
@@ -661,7 +668,7 @@ function state_style_condense(jssk) {
661
668
  // TODO add a lotta docblock here
662
669
  class Machine {
663
670
  // whargarbl this badly needs to be broken up, monolith master
664
- 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 }) {
665
672
  this._instance_name = instance_name;
666
673
  this._state = start_states[0];
667
674
  this._states = new Map();
@@ -688,7 +695,7 @@ class Machine {
688
695
  this._arrange_start_declaration = arrange_start_declaration;
689
696
  this._arrange_end_declaration = arrange_end_declaration;
690
697
  this._dot_preamble = dot_preamble;
691
- this._theme = theme;
698
+ this._themes = theme;
692
699
  this._flow = flow;
693
700
  this._graph_layout = graph_layout;
694
701
  this._has_hooks = false;
@@ -1380,8 +1387,8 @@ class Machine {
1380
1387
  list_actions() {
1381
1388
  return Array.from(this._actions.keys());
1382
1389
  }
1383
- theme() {
1384
- return this._theme; // constructor sets this to "default" otherwise
1390
+ themes() {
1391
+ return this._themes; // constructor sets this to "default" otherwise
1385
1392
  }
1386
1393
  flow() {
1387
1394
  return this._flow;
@@ -2317,6 +2324,12 @@ class Machine {
2317
2324
  get active_state_style() {
2318
2325
  return this._active_state_style;
2319
2326
  }
2327
+ /*
2328
+ */
2329
+ // TODO COMEBACK IMPLEMENTME FIXME
2330
+ // has_hooks(state: StateType): false {
2331
+ // return false;
2332
+ // }
2320
2333
  /********
2321
2334
  *
2322
2335
  * Gets the composite style for a specific node by individually imposing the
@@ -2337,48 +2350,76 @@ class Machine {
2337
2350
  *
2338
2351
  */
2339
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
+ });
2340
2361
  // basic state style
2341
- const layers = [base_state_style];
2342
- // if (theme.state_style) { layers.push(theme.state_style); }
2362
+ const layers = [base_theme.state];
2363
+ themes.reverse().map(theme => {
2364
+ if (theme.state) {
2365
+ layers.push(theme.state);
2366
+ }
2367
+ });
2343
2368
  if (this._state_style) {
2344
2369
  layers.push(this._state_style);
2345
2370
  }
2346
- /*
2347
- // hooked state style
2348
- if (this.has_hooks(state)) {
2349
- layers.push(base_hooked_state_style);
2350
- // if (theme.hooked_state_style) { layers.push(theme.hooked_state_style); }
2351
- if (this._hooked_state_style) { layers.push(this._hooked_state_style); }
2352
- }
2353
- */
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
+ // }
2354
2379
  // terminal state style
2355
2380
  if (this.state_is_terminal(state)) {
2356
- layers.push(base_terminal_state_style);
2357
- // if (theme.terminal_state_style) { layers.push(theme.terminal_state_style); }
2381
+ layers.push(base_theme.terminal);
2382
+ themes.map(theme => {
2383
+ if (theme.terminal) {
2384
+ layers.push(theme.terminal);
2385
+ }
2386
+ });
2358
2387
  if (this._terminal_state_style) {
2359
2388
  layers.push(this._terminal_state_style);
2360
2389
  }
2361
2390
  }
2362
2391
  // start state style
2363
2392
  if (this.is_start_state(state)) {
2364
- layers.push(base_start_state_style);
2365
- // if (theme.start_state_style) { layers.push(theme.start_state_style); }
2393
+ layers.push(base_theme.start);
2394
+ themes.map(theme => {
2395
+ if (theme.start) {
2396
+ layers.push(theme.start);
2397
+ }
2398
+ });
2366
2399
  if (this._start_state_style) {
2367
2400
  layers.push(this._start_state_style);
2368
2401
  }
2369
2402
  }
2370
2403
  // end state style
2371
2404
  if (this.is_end_state(state)) {
2372
- layers.push(base_end_state_style);
2373
- // if (theme.end_state_style) { layers.push(theme.end_state_style); }
2405
+ layers.push(base_theme.end);
2406
+ themes.map(theme => {
2407
+ if (theme.end) {
2408
+ layers.push(theme.end);
2409
+ }
2410
+ });
2374
2411
  if (this._end_state_style) {
2375
2412
  layers.push(this._end_state_style);
2376
2413
  }
2377
2414
  }
2378
2415
  // active state style
2379
2416
  if (this.state() === state) {
2380
- layers.push(base_active_state_style);
2381
- // if (theme.active_state_style) { layers.push(theme.active_state_style); }
2417
+ layers.push(base_theme.active);
2418
+ themes.map(theme => {
2419
+ if (theme.active) {
2420
+ layers.push(theme.active);
2421
+ }
2422
+ });
2382
2423
  if (this._active_state_style) {
2383
2424
  layers.push(this._active_state_style);
2384
2425
  }
@@ -2423,7 +2464,7 @@ class Machine {
2423
2464
  * ```
2424
2465
  *
2425
2466
  * @typeparam mDT The type of the machine data member; usually omitted
2426
- b *
2467
+ *
2427
2468
  * @param actionName The action to engage
2428
2469
  *
2429
2470
  * @param newData The data change to insert during the action
@@ -174,7 +174,7 @@ declare type JssmGenericConfig<DataType> = {
174
174
  graph_layout?: JssmLayout;
175
175
  complete?: Array<StateType>;
176
176
  transitions: JssmTransitions<DataType>;
177
- theme?: FslTheme;
177
+ theme?: FslTheme[];
178
178
  flow?: FslDirection;
179
179
  name?: string;
180
180
  data?: DataType;
@@ -1,4 +1,4 @@
1
- import { JssmStateConfig, JssmBaseTheme } from './jssm_types';
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;
@@ -8,4 +8,4 @@ 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 };
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 };
@@ -54,4 +54,4 @@ const base_theme = {
54
54
  graph: undefined,
55
55
  title: undefined // TODO FIXME
56
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 };
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 };
@@ -0,0 +1,57 @@
1
+ const base_state_style = {
2
+ shape: 'rectangle',
3
+ backgroundColor: 'khaki',
4
+ textColor: 'black',
5
+ borderColor: 'black'
6
+ };
7
+ const base_active_state_style = {
8
+ textColor: 'white',
9
+ backgroundColor: 'dodgerblue4'
10
+ };
11
+ const base_hooked_state_style = {
12
+ shape: 'component'
13
+ };
14
+ const base_terminal_state_style = {
15
+ textColor: 'white',
16
+ backgroundColor: 'crimson'
17
+ };
18
+ const base_active_terminal_state_style = {
19
+ textColor: 'white',
20
+ backgroundColor: 'indigo'
21
+ };
22
+ const base_start_state_style = {
23
+ backgroundColor: 'yellow'
24
+ };
25
+ const base_active_start_state_style = {
26
+ backgroundColor: 'yellowgreen'
27
+ };
28
+ const base_active_hooked_state_style = {
29
+ backgroundColor: 'yellowgreen'
30
+ };
31
+ const base_end_state_style = {
32
+ textColor: 'white',
33
+ backgroundColor: 'darkolivegreen'
34
+ };
35
+ const base_active_end_state_style = {
36
+ textColor: 'white',
37
+ backgroundColor: 'darkgreen'
38
+ };
39
+ const default_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, default_theme, default_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 modern_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, modern_theme, modern_theme as theme };
@@ -0,0 +1,57 @@
1
+ const base_state_style = {
2
+ shape: 'rectangle',
3
+ backgroundColor: 'khaki',
4
+ textColor: 'black',
5
+ borderColor: 'black'
6
+ };
7
+ const base_active_state_style = {
8
+ textColor: 'white',
9
+ backgroundColor: 'dodgerblue4'
10
+ };
11
+ const base_hooked_state_style = {
12
+ shape: 'component'
13
+ };
14
+ const base_terminal_state_style = {
15
+ textColor: 'white',
16
+ backgroundColor: 'crimson'
17
+ };
18
+ const base_active_terminal_state_style = {
19
+ textColor: 'white',
20
+ backgroundColor: 'indigo'
21
+ };
22
+ const base_start_state_style = {
23
+ backgroundColor: 'yellow'
24
+ };
25
+ const base_active_start_state_style = {
26
+ backgroundColor: 'yellowgreen'
27
+ };
28
+ const base_active_hooked_state_style = {
29
+ backgroundColor: 'yellowgreen'
30
+ };
31
+ const base_end_state_style = {
32
+ textColor: 'white',
33
+ backgroundColor: 'darkolivegreen'
34
+ };
35
+ const base_active_end_state_style = {
36
+ textColor: 'white',
37
+ backgroundColor: 'darkgreen'
38
+ };
39
+ const modern_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, modern_theme, modern_theme as theme };
@@ -1,4 +1,4 @@
1
- import { JssmStateConfig, JssmBaseTheme } from './jssm_types';
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,5 +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
- 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 };
10
+ declare const ocean_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, ocean_theme, ocean_theme as theme };
@@ -0,0 +1,55 @@
1
+ const base_state_style = {
2
+ backgroundColor: 'cadetblue1',
3
+ };
4
+ const base_active_state_style = {
5
+ textColor: 'white',
6
+ backgroundColor: 'deepskyblue'
7
+ };
8
+ const base_hooked_state_style = {
9
+ shape: 'component',
10
+ backgroundColor: 'mediumaquamarine'
11
+ };
12
+ const base_terminal_state_style = {
13
+ textColor: 'white',
14
+ backgroundColor: 'darkviolet'
15
+ };
16
+ const base_active_terminal_state_style = {
17
+ textColor: 'white',
18
+ backgroundColor: 'deeppink'
19
+ };
20
+ const base_start_state_style = {
21
+ backgroundColor: 'darkseagreen1'
22
+ };
23
+ const base_active_start_state_style = {
24
+ backgroundColor: 'aquamarine'
25
+ };
26
+ const base_active_hooked_state_style = {
27
+ backgroundColor: 'aquamarine'
28
+ };
29
+ const base_end_state_style = {
30
+ textColor: 'white',
31
+ backgroundColor: 'chartreuse1'
32
+ };
33
+ const base_active_end_state_style = {
34
+ textColor: 'white',
35
+ backgroundColor: 'darkgreen'
36
+ };
37
+ const ocean_theme = {
38
+ state: base_state_style,
39
+ start: base_start_state_style,
40
+ end: base_end_state_style,
41
+ terminal: base_terminal_state_style,
42
+ hooked: base_hooked_state_style,
43
+ active: base_active_state_style,
44
+ active_start: base_active_start_state_style,
45
+ active_end: base_active_end_state_style,
46
+ active_terminal: base_active_terminal_state_style,
47
+ active_hooked: base_active_hooked_state_style,
48
+ legal: undefined,
49
+ main: undefined,
50
+ forced: undefined,
51
+ action: undefined,
52
+ graph: undefined,
53
+ title: undefined // TODO FIXME
54
+ };
55
+ 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, ocean_theme, ocean_theme as theme };
@@ -1,2 +1,2 @@
1
- const version = "5.81.2";
1
+ const version = "5.82.0";
2
2
  export { version };