jssm 5.65.11 → 5.67.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/dist/es6/jssm.js CHANGED
@@ -17,6 +17,8 @@ import { JssmError } from './jssm_error';
17
17
  * arrow_direction('<~=>'); // 'both'
18
18
  * ```
19
19
  *
20
+ * @param arrow The arrow to be evaluated
21
+ *
20
22
  */
21
23
  function arrow_direction(arrow) {
22
24
  switch (String(arrow)) {
@@ -85,6 +87,8 @@ function arrow_direction(arrow) {
85
87
  * arrow_left_kind('->'); // 'none'
86
88
  * ```
87
89
  *
90
+ * @param arrow The arrow to be evaluated
91
+ *
88
92
  */
89
93
  function arrow_left_kind(arrow) {
90
94
  switch (String(arrow)) {
@@ -142,6 +146,8 @@ function arrow_left_kind(arrow) {
142
146
  * arrow_left_kind('<-'); // 'none'
143
147
  * ```
144
148
  *
149
+ * @param arrow The arrow to be evaluated
150
+ *
145
151
  */
146
152
  function arrow_right_kind(arrow) {
147
153
  switch (String(arrow)) {
@@ -189,7 +195,12 @@ function arrow_right_kind(arrow) {
189
195
  * Internal method meant to perform factory assembly of an edge. Not meant for
190
196
  * external use.
191
197
  *
198
+ * @internal
199
+ *
200
+ * @typeparam mDT The type of the machine data member; usually omitted
201
+ *
192
202
  */
203
+ // TODO add at-param to docblock
193
204
  function makeTransition(this_se, from, to, isRight, _wasList, _wasIndex) {
194
205
  const kind = isRight ? arrow_right_kind(this_se.kind) : arrow_left_kind(this_se.kind), edge = {
195
206
  from,
@@ -272,6 +283,10 @@ function makeTransition(this_se, from, to, isRight, _wasList, _wasIndex) {
272
283
  * `wrap_parse` itself is an internal convenience method for alting out an
273
284
  * object as the options call. Not generally meant for external use.
274
285
  *
286
+ * @param input The FSL code to be evaluated
287
+ *
288
+ * @param options Things to control about the instance
289
+ *
275
290
  */
276
291
  function wrap_parse(input, options) {
277
292
  return parse(input, options || {});
@@ -281,6 +296,10 @@ function wrap_parse(input, options) {
281
296
  * Internal method performing one step in compiling rules for transitions. Not
282
297
  * generally meant for external use.
283
298
  *
299
+ * @internal
300
+ *
301
+ * @typeparam mDT The type of the machine data member; usually omitted
302
+ *
284
303
  */
285
304
  function compile_rule_transition_step(acc, from, to, this_se, next_se) {
286
305
  const edges = [];
@@ -310,6 +329,8 @@ function compile_rule_transition_step(acc, from, to, this_se, next_se) {
310
329
  * Internal method performing one step in compiling rules for transitions. Not
311
330
  * generally meant for external use.
312
331
  *
332
+ * @internal
333
+ *
313
334
  */
314
335
  function compile_rule_handle_transition(rule) {
315
336
  return compile_rule_transition_step([], rule.from, rule.se.to, rule.se, rule.se.se);
@@ -319,6 +340,8 @@ function compile_rule_handle_transition(rule) {
319
340
  * Internal method performing one step in compiling rules for transitions. Not
320
341
  * generally meant for external use.
321
342
  *
343
+ * @internal
344
+ *
322
345
  */
323
346
  function compile_rule_handler(rule) {
324
347
  if (rule.key === 'transition') {
@@ -394,6 +417,10 @@ function compile_rule_handler(rule) {
394
417
  * const toggle = jssm.from('up <=> down;');
395
418
  * ```
396
419
  *
420
+ * @typeparam mDT The type of the machine data member; usually omitted
421
+ *
422
+ * @param tree The parse tree to be boiled down into a machine config
423
+ *
397
424
  */
398
425
  function compile(tree) {
399
426
  const results = {
@@ -458,6 +485,10 @@ function compile(tree) {
458
485
  * Not generally meant for external use. Please see {@link compile} or
459
486
  * {@link sm}.
460
487
  *
488
+ * @typeparam mDT The type of the machine data member; usually omitted
489
+ *
490
+ * @param plan The FSL code to be evaluated and built into a machine config
491
+ *
461
492
  */
462
493
  function make(plan) {
463
494
  return compile(wrap_parse(plan));
@@ -468,6 +499,8 @@ function make(plan) {
468
499
  * a single multi-faceted declaration, in the process of building a state. Not
469
500
  * generally meant for external use.
470
501
  *
502
+ * @internal
503
+ *
471
504
  */
472
505
  function transfer_state_properties(state_decl) {
473
506
  state_decl.declarations.map((d) => {
@@ -498,6 +531,7 @@ function transfer_state_properties(state_decl) {
498
531
  });
499
532
  return state_decl;
500
533
  }
534
+ // TODO add a lotta docblock here
501
535
  class Machine {
502
536
  // whargarbl this badly needs to be broken up, monolith master
503
537
  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 }) {
@@ -647,6 +681,8 @@ class Machine {
647
681
  *
648
682
  * Internal method for fabricating states. Not meant for external use.
649
683
  *
684
+ * @internal
685
+ *
650
686
  */
651
687
  _new_state(state_config) {
652
688
  if (this._states.has(state_config.name)) {
@@ -669,6 +705,8 @@ class Machine {
669
705
  * console.log( switch.state() ); // 'off'
670
706
  * ```
671
707
  *
708
+ * @typeparam mDT The type of the machine data member; usually omitted
709
+ *
672
710
  */
673
711
  state() {
674
712
  return this._state;
@@ -694,6 +732,10 @@ class Machine {
694
732
  * console.log( final_test.state_is_final('second') ); // true
695
733
  * ```
696
734
  *
735
+ * @typeparam mDT The type of the machine data member; usually omitted
736
+ *
737
+ * @param whichState The name of the state to check for finality
738
+ *
697
739
  */
698
740
  state_is_final(whichState) {
699
741
  return ((this.state_is_terminal(whichState)) && (this.state_is_complete(whichState)));
@@ -713,6 +755,8 @@ class Machine {
713
755
  * console.log( final_test.is_final() ); // true
714
756
  * ```
715
757
  *
758
+ * @typeparam mDT The type of the machine data member; usually omitted
759
+ *
716
760
  */
717
761
  is_final() {
718
762
  // return ((!this.is_changing()) && this.state_is_final(this.state()));
@@ -790,6 +834,8 @@ class Machine {
790
834
  * console.log( switch.states() ); // ['on', 'off']
791
835
  * ```
792
836
  *
837
+ * @typeparam mDT The type of the machine data member; usually omitted
838
+ *
793
839
  */
794
840
  states() {
795
841
  return Array.from(this._states.keys());
@@ -816,6 +862,10 @@ class Machine {
816
862
  * console.log( switch.has_state('dance') ); // false
817
863
  * ```
818
864
  *
865
+ * @typeparam mDT The type of the machine data member; usually omitted
866
+ *
867
+ * @param whichState The state to be checked for extance
868
+ *
819
869
  */
820
870
  has_state(whichState) {
821
871
  return this._states.get(whichState) !== undefined;
@@ -825,28 +875,32 @@ class Machine {
825
875
  * Lists all edges of a machine.
826
876
  *
827
877
  * ```typescript
878
+ * import { sm } from 'jssm';
879
+ *
828
880
  * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
829
881
  *
830
- * lswitch.list_edges();
831
- * [
832
- * {
833
- * from: 'on',
834
- * to: 'off',
835
- * kind: 'main',
836
- * forced_only: false,
837
- * main_path: true,
838
- * action: 'toggle'
839
- * },
840
- * {
841
- * from: 'off',
842
- * to: 'on',
843
- * kind: 'main',
844
- * forced_only: false,
845
- * main_path: true,
846
- * action: 'toggle'
847
- * }
848
- * ]
849
- * ```
882
+ * lswitch.list_edges();
883
+ * [
884
+ * {
885
+ * from: 'on',
886
+ * to: 'off',
887
+ * kind: 'main',
888
+ * forced_only: false,
889
+ * main_path: true,
890
+ * action: 'toggle'
891
+ * },
892
+ * {
893
+ * from: 'off',
894
+ * to: 'on',
895
+ * kind: 'main',
896
+ * forced_only: false,
897
+ * main_path: true,
898
+ * action: 'toggle'
899
+ * }
900
+ * ]
901
+ * ```
902
+ *
903
+ * @typeparam mDT The type of the machine data member; usually omitted
850
904
  *
851
905
  */
852
906
  list_edges() {
@@ -883,11 +937,18 @@ class Machine {
883
937
  * exit. The order of each sublist is not defined. A node could appear in
884
938
  * both lists.
885
939
  *
886
- * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
940
+ * ```typescript
941
+ * import { sm } from 'jssm';
942
+ *
887
943
  * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
888
944
  *
889
945
  * light.state(); // 'red'
890
946
  * light.list_transitions(); // { entrances: [ 'yellow', 'off' ], exits: [ 'green', 'off' ] }
947
+ * ```
948
+ *
949
+ * @typeparam mDT The type of the machine data member; usually omitted
950
+ *
951
+ * @param whichState The state whose transitions to have listed
891
952
  *
892
953
  */
893
954
  list_transitions(whichState = this.state()) {
@@ -898,11 +959,18 @@ class Machine {
898
959
  * List all entrances attached to the current state. Please note that the
899
960
  * order of the list is not defined.
900
961
  *
901
- * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
962
+ * ```typescript
963
+ * import { sm } from 'jssm';
964
+ *
902
965
  * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
903
966
  *
904
967
  * light.state(); // 'red'
905
968
  * light.list_entrances(); // [ 'yellow', 'off' ]
969
+ * ```
970
+ *
971
+ * @typeparam mDT The type of the machine data member; usually omitted
972
+ *
973
+ * @param whichState The state whose entrances to have listed
906
974
  *
907
975
  */
908
976
  list_entrances(whichState = this.state()) {
@@ -915,11 +983,18 @@ class Machine {
915
983
  * List all exits attached to the current state. Please note that the order
916
984
  * of the list is not defined.
917
985
  *
918
- * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
986
+ * ```typescript
987
+ * import { sm } from 'jssm';
988
+ *
919
989
  * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
920
990
  *
921
991
  * light.state(); // 'red'
922
992
  * light.list_exits(); // [ 'green', 'off' ]
993
+ * ```
994
+ *
995
+ * @typeparam mDT The type of the machine data member; usually omitted
996
+ *
997
+ * @param whichState The state whose exits to have listed
923
998
  *
924
999
  */
925
1000
  list_exits(whichState = this.state()) {
@@ -982,6 +1057,10 @@ class Machine {
982
1057
  * console.log( machine.actions() ); // logs ['next', 'shutdown']
983
1058
  * ```
984
1059
  *
1060
+ * @typeparam mDT The type of the machine data member; usually omitted
1061
+ *
1062
+ * @param whichState The state whose actions to have listed
1063
+ *
985
1064
  */
986
1065
  actions(whichState = this.state()) {
987
1066
  const wstate = this._reverse_actions.get(whichState);
@@ -1009,6 +1088,10 @@ class Machine {
1009
1088
  * console.log( machine.list_states_having_action('start') ); // ['off']
1010
1089
  * ```
1011
1090
  *
1091
+ * @typeparam mDT The type of the machine data member; usually omitted
1092
+ *
1093
+ * @param whichState The action to be checked for associated states
1094
+ *
1012
1095
  */
1013
1096
  list_states_having_action(whichState) {
1014
1097
  const wstate = this._actions.get(whichState);
@@ -1337,13 +1420,72 @@ class Machine {
1337
1420
  return false;
1338
1421
  }
1339
1422
  }
1423
+ /********
1424
+ *
1425
+ * Instruct the machine to complete an action.
1426
+ *
1427
+ * ```typescript
1428
+ * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
1429
+ *
1430
+ * light.state(); // 'red'
1431
+ * light.action('next'); // true
1432
+ * light.state(); // 'green'
1433
+ * ```
1434
+ *
1435
+ * @typeparam mDT The type of the machine data member; usually omitted
1436
+ *
1437
+ * @param actionName The action to engage
1438
+ *
1439
+ * @param newData The data change to insert during the action
1440
+ *
1441
+ */
1340
1442
  action(actionName, newData) {
1341
1443
  return this.transition_impl(actionName, newData, false, true);
1342
1444
  }
1445
+ /********
1446
+ *
1447
+ * Instruct the machine to complete a transition.
1448
+ *
1449
+ * ```typescript
1450
+ * const light = sm`red -> green -> yellow -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
1451
+ *
1452
+ * light.state(); // 'red'
1453
+ * light.transition('green'); // true
1454
+ * light.state(); // 'green'
1455
+ * ```
1456
+ *
1457
+ * @typeparam mDT The type of the machine data member; usually omitted
1458
+ *
1459
+ * @param newState The state to switch to
1460
+ *
1461
+ * @param newData The data change to insert during the transition
1462
+ *
1463
+ */
1343
1464
  transition(newState, newData) {
1344
1465
  return this.transition_impl(newState, newData, false, false);
1345
1466
  }
1346
- // can leave machine in inconsistent state. generally do not use
1467
+ /********
1468
+ *
1469
+ * Instruct the machine to complete a forced transition (which will reject if
1470
+ * called with a normal {@link transition} call.)
1471
+ *
1472
+ * ```typescript
1473
+ * const light = sm`red -> green -> yellow -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
1474
+ *
1475
+ * light.state(); // 'red'
1476
+ * light.transition('off'); // false
1477
+ * light.state(); // 'red'
1478
+ * light.force_transition('off'); // true
1479
+ * light.state(); // 'off'
1480
+ * ```
1481
+ *
1482
+ * @typeparam mDT The type of the machine data member; usually omitted
1483
+ *
1484
+ * @param newState The state to switch to
1485
+ *
1486
+ * @param newData The data change to insert during the transition
1487
+ *
1488
+ */
1347
1489
  force_transition(newState, newData) {
1348
1490
  return this.transition_impl(newState, newData, true, false);
1349
1491
  }
@@ -1407,6 +1549,12 @@ class Machine {
1407
1549
  * const switch = jssm.from('on <=> off;');
1408
1550
  * ```
1409
1551
  *
1552
+ * @typeparam mDT The type of the machine data member; usually omitted
1553
+ *
1554
+ * @param template_strings The assembled code
1555
+ *
1556
+ * @param remainder The mechanic for template argument insertion
1557
+ *
1410
1558
  */
1411
1559
  function sm(template_strings, ...remainder /* , arguments */) {
1412
1560
  // foo`a${1}b${2}c` will come in as (['a','b','c'],1,2)
@@ -1436,6 +1584,12 @@ function sm(template_strings, ...remainder /* , arguments */) {
1436
1584
  * const switch = jssm.from('on <=> off;');
1437
1585
  * ```
1438
1586
  *
1587
+ * @typeparam mDT The type of the machine data member; usually omitted
1588
+ *
1589
+ * @param MachineAsString The FSL code to evaluate
1590
+ *
1591
+ * @param ExtraConstructorFields Extra non-code configuration to pass at creation time
1592
+ *
1439
1593
  */
1440
1594
  function from(MachineAsString, ExtraConstructorFields) {
1441
1595
  const to_decorate = make(MachineAsString);
@@ -1,2 +1,2 @@
1
- const version = "5.65.11";
1
+ const version = "5.67.0";
2
2
  export { version };