jssm 5.72.2 → 5.72.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/CHANGELOG.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
- 920 merges; 114 releases; Changlogging the last 10 commits; Full changelog at [CHANGELOG.long.md](CHANGELOG.long.md)
5
+ 922 merges; 114 releases; Changlogging the last 10 commits; Full changelog at [CHANGELOG.long.md](CHANGELOG.long.md)
6
6
 
7
7
 
8
8
 
@@ -18,6 +18,36 @@ Published tags:
18
18
 
19
19
 
20
20
 
21
+  
22
+
23
+  
24
+
25
+ ## [Untagged] - 6/24/2022 7:36:27 PM
26
+
27
+ Commit [adfa9069ba5e78d8a227896a5f7e14a8f4b80117](https://github.com/StoneCypher/jssm/commit/adfa9069ba5e78d8a227896a5f7e14a8f4b80117)
28
+
29
+ Author: `John Haugeland <stonecypher@gmail.com>`
30
+
31
+ * the conversion continues
32
+
33
+
34
+
35
+
36
+ &nbsp;
37
+
38
+ &nbsp;
39
+
40
+ ## [Untagged] - 6/24/2022 5:49:06 PM
41
+
42
+ Commit [b0cbe1c1ae0199c8d78a82f624e8ee94b344cf71](https://github.com/StoneCypher/jssm/commit/b0cbe1c1ae0199c8d78a82f624e8ee94b344cf71)
43
+
44
+ Author: `John Haugeland <stonecypher@gmail.com>`
45
+
46
+ * Normalize hook return pattern, fixes StoneCypher/fsl#930
47
+
48
+
49
+
50
+
21
51
  &nbsp;
22
52
 
23
53
  &nbsp;
@@ -139,38 +169,4 @@ Commit [a0f295f060c7f08a8b10b2208dd1c95dc7f3c97a](https://github.com/StoneCypher
139
169
 
140
170
  Author: `John Haugeland <stonecypher@gmail.com>`
141
171
 
142
- * another trigger commit with mild doc extension
143
-
144
-
145
-
146
-
147
- &nbsp;
148
-
149
- &nbsp;
150
-
151
- <a name="5__70__33" />
152
-
153
- ## [5.70.33] - 6/18/2022 8:57:42 PM
154
-
155
- Commit [ca254f455f2c19f21e77834e993c310e05272822](https://github.com/StoneCypher/jssm/commit/ca254f455f2c19f21e77834e993c310e05272822)
156
-
157
- Author: `John Haugeland <stonecypher@gmail.com>`
158
-
159
- * holy another facile build for triggering, batman
160
-
161
-
162
-
163
-
164
- &nbsp;
165
-
166
- &nbsp;
167
-
168
- <a name="5__70__32" />
169
-
170
- ## [5.70.32] - 6/18/2022 8:48:07 PM
171
-
172
- Commit [8115e8b62d8ac1cff3c7eb07afabced097f1be42](https://github.com/StoneCypher/jssm/commit/8115e8b62d8ac1cff3c7eb07afabced097f1be42)
173
-
174
- Author: `John Haugeland <stonecypher@gmail.com>`
175
-
176
- * yet another small commit as a trigger, this time to get the extended diff
172
+ * another trigger commit with mild doc extension
@@ -1,6 +1,6 @@
1
1
  declare type StateType = string;
2
2
  import { JssmGenericState, JssmGenericConfig, JssmTransition, JssmTransitionList, // JssmTransitionRule,
3
- JssmMachineInternalState, JssmParseTree, JssmStateDeclaration, JssmArrow, JssmArrowDirection, JssmArrowKind, JssmLayout, FslDirection, FslTheme, HookDescription, HookHandler } from './jssm_types';
3
+ JssmMachineInternalState, JssmParseTree, JssmStateDeclaration, JssmArrow, JssmArrowDirection, JssmArrowKind, JssmLayout, FslDirection, FslTheme, HookDescription, HookHandler, HookResult } from './jssm_types';
4
4
  import { seq, weighted_rand_select, weighted_sample_select, histograph, weighted_histo_key } from './jssm_util';
5
5
  import { shapes, gviz_shapes, named_colors } from './jssm_constants';
6
6
  import { version } from './version';
@@ -223,11 +223,11 @@ declare class Machine<mDT> {
223
223
  _has_exit_hooks: boolean;
224
224
  _has_global_action_hooks: boolean;
225
225
  _has_transition_hooks: boolean;
226
- _hooks: Map<string, Function>;
227
- _named_hooks: Map<string, Function>;
228
- _entry_hooks: Map<string, Function>;
229
- _exit_hooks: Map<string, Function>;
230
- _global_action_hooks: Map<string, Function>;
226
+ _hooks: Map<string, HookHandler<mDT>>;
227
+ _named_hooks: Map<string, HookHandler<mDT>>;
228
+ _entry_hooks: Map<string, HookHandler<mDT>>;
229
+ _exit_hooks: Map<string, HookHandler<mDT>>;
230
+ _global_action_hooks: Map<string, HookHandler<mDT>>;
231
231
  _any_action_hook: HookHandler<mDT> | undefined;
232
232
  _standard_transition_hook: HookHandler<mDT> | undefined;
233
233
  _main_transition_hook: HookHandler<mDT> | undefined;
@@ -669,4 +669,5 @@ declare function sm<mDT>(template_strings: TemplateStringsArray, ...remainder: a
669
669
  *
670
670
  */
671
671
  declare function from<mDT>(MachineAsString: string, ExtraConstructorFields?: Partial<JssmGenericConfig<mDT>> | undefined): Machine<mDT>;
672
- 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, named_colors };
672
+ declare function is_hook_rejection(hr: HookResult): boolean;
673
+ 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, named_colors, is_hook_rejection };
package/dist/es6/jssm.js CHANGED
@@ -1328,99 +1328,78 @@ class Machine {
1328
1328
  newState = newStateOrAction;
1329
1329
  }
1330
1330
  }
1331
- // todo whargarbl implement data stuff
1332
- // todo major incomplete whargarbl comeback
1333
1331
  if (valid) {
1334
1332
  if (this._has_hooks) {
1335
1333
  const hook_args = { data: this._data, action: fromAction, from: this._state, to: newState, forced: wasForced };
1336
1334
  if (wasAction) {
1337
1335
  // 1. any action hook
1338
- if (this._any_action_hook !== undefined) {
1339
- if (this._any_action_hook(hook_args) === false) {
1340
- return false;
1341
- }
1336
+ const outcome = AbstractHookStep(this._any_action_hook, hook_args);
1337
+ if (outcome.pass === false) {
1338
+ return false;
1342
1339
  }
1343
1340
  // 2. global specific action hook
1344
- const maybe_ga_hook = this._global_action_hooks.get(newStateOrAction);
1345
- if (maybe_ga_hook !== undefined) {
1346
- if (maybe_ga_hook(hook_args) === false) {
1347
- return false;
1348
- }
1341
+ const outcome2 = AbstractHookStep(this._global_action_hooks.get(newStateOrAction), hook_args);
1342
+ if (outcome2.pass === false) {
1343
+ return false;
1349
1344
  }
1350
1345
  }
1351
1346
  // 3. any transition hook
1352
1347
  if (this._any_transition_hook !== undefined) {
1353
- if (this._any_transition_hook(hook_args) === false) {
1348
+ const outcome = AbstractHookStep(this._any_transition_hook, hook_args);
1349
+ if (outcome.pass === false) {
1354
1350
  return false;
1355
1351
  }
1356
1352
  }
1357
1353
  // 4. exit hook
1358
1354
  if (this._has_exit_hooks) {
1359
- const maybe_ex_hook = this._exit_hooks.get(this._state);
1360
- if (maybe_ex_hook !== undefined) {
1361
- if (maybe_ex_hook(hook_args) === false) {
1362
- return false;
1363
- }
1355
+ const outcome = AbstractHookStep(this._exit_hooks.get(this._state), hook_args);
1356
+ if (outcome.pass === false) {
1357
+ return false;
1364
1358
  }
1365
1359
  }
1366
1360
  // 5. named transition / action hook
1367
1361
  if (this._has_named_hooks) {
1368
1362
  if (wasAction) {
1369
- const nhn = named_hook_name(this._state, newState, newStateOrAction), n_maybe_hook = this._named_hooks.get(nhn);
1370
- if (n_maybe_hook !== undefined) {
1371
- if (n_maybe_hook(hook_args) === false) {
1372
- return false;
1373
- }
1363
+ const nhn = named_hook_name(this._state, newState, newStateOrAction), outcome = AbstractHookStep(this._named_hooks.get(nhn), hook_args);
1364
+ if (outcome.pass === false) {
1365
+ return false;
1374
1366
  }
1375
1367
  }
1376
1368
  }
1377
1369
  // 6. regular hook
1378
1370
  if (this._has_basic_hooks) {
1379
- const hn = hook_name(this._state, newState), maybe_hook = this._hooks.get(hn);
1380
- if (maybe_hook !== undefined) {
1381
- if (maybe_hook(hook_args) === false) {
1382
- return false;
1383
- }
1371
+ const hn = hook_name(this._state, newState), outcome = AbstractHookStep(this._hooks.get(hn), hook_args);
1372
+ if (outcome.pass === false) {
1373
+ return false;
1384
1374
  }
1385
1375
  }
1386
1376
  // 7. edge type hook
1387
1377
  // 7a. standard transition hook
1388
1378
  if (trans_type === 'legal') {
1389
- if (this._standard_transition_hook !== undefined) {
1390
- // todo handle actions
1391
- // todo handle forced
1392
- if (this._standard_transition_hook(hook_args) === false) {
1393
- return false;
1394
- }
1379
+ const outcome = AbstractHookStep(this._standard_transition_hook, hook_args);
1380
+ if (outcome.pass === false) {
1381
+ return false;
1395
1382
  }
1396
1383
  }
1397
1384
  // 7b. main type hook
1398
1385
  if (trans_type === 'main') {
1399
- if (this._main_transition_hook !== undefined) {
1400
- // todo handle actions
1401
- // todo handle forced
1402
- if (this._main_transition_hook(hook_args) === false) {
1403
- return false;
1404
- }
1386
+ const outcome = AbstractHookStep(this._main_transition_hook, hook_args);
1387
+ if (outcome.pass === false) {
1388
+ return false;
1405
1389
  }
1406
1390
  }
1407
1391
  // 7c. forced transition hook
1408
1392
  if (trans_type === 'forced') {
1409
- if (this._forced_transition_hook !== undefined) {
1410
- // todo handle actions
1411
- // todo handle forced
1412
- if (this._forced_transition_hook(hook_args) === false) {
1413
- return false;
1414
- }
1393
+ const outcome = AbstractHookStep(this._forced_transition_hook, hook_args);
1394
+ if (outcome.pass === false) {
1395
+ return false;
1415
1396
  }
1416
1397
  }
1417
1398
  // 8. entry hook
1418
1399
  if (this._has_entry_hooks) {
1419
- const maybe_en_hook = this._entry_hooks.get(newState);
1420
- if (maybe_en_hook !== undefined) {
1421
- if (maybe_en_hook(hook_args) === false) {
1422
- return false;
1423
- }
1400
+ const outcome = AbstractHookStep(this._entry_hooks.get(newState), hook_args);
1401
+ if (outcome.pass === false) {
1402
+ return false;
1424
1403
  }
1425
1404
  }
1426
1405
  this._state = newState;
@@ -1615,6 +1594,51 @@ function from(MachineAsString, ExtraConstructorFields) {
1615
1594
  }
1616
1595
  return new Machine(to_decorate);
1617
1596
  }
1597
+ function is_hook_complex_result(hr) {
1598
+ if (typeof hr === 'object') {
1599
+ if (typeof hr.pass === 'boolean') {
1600
+ return true;
1601
+ }
1602
+ }
1603
+ return false;
1604
+ }
1605
+ function is_hook_rejection(hr) {
1606
+ if (hr === true) {
1607
+ return false;
1608
+ }
1609
+ if (hr === undefined) {
1610
+ return false;
1611
+ }
1612
+ if (hr === false) {
1613
+ return true;
1614
+ }
1615
+ if (is_hook_complex_result(hr)) {
1616
+ return (!(hr.pass));
1617
+ }
1618
+ throw new TypeError('unknown hook rejection type result');
1619
+ }
1620
+ // TODO hook_args: unknown
1621
+ function AbstractHookStep(maybe_hook, hook_args) {
1622
+ if (maybe_hook !== undefined) {
1623
+ const result = maybe_hook(hook_args);
1624
+ if (result === undefined) {
1625
+ return { pass: true };
1626
+ }
1627
+ if (result === true) {
1628
+ return { pass: true };
1629
+ }
1630
+ if (result === false) {
1631
+ return { pass: false };
1632
+ }
1633
+ // if (is_hook_complex_result(result)) {
1634
+ // return result;
1635
+ // }
1636
+ throw new TypeError(`Unknown hook result type ${result}`);
1637
+ }
1638
+ else {
1639
+ return { pass: true };
1640
+ }
1641
+ }
1618
1642
  export { version, transfer_state_properties, Machine, make, wrap_parse as parse, compile, sm, from, arrow_direction, arrow_left_kind, arrow_right_kind,
1619
1643
  // WHARGARBL TODO these should be exported to a utility library
1620
- seq, weighted_rand_select, histograph, weighted_sample_select, weighted_histo_key, shapes, gviz_shapes, named_colors };
1644
+ seq, weighted_rand_select, histograph, weighted_sample_select, weighted_histo_key, shapes, gviz_shapes, named_colors, is_hook_rejection };
@@ -198,6 +198,11 @@ declare type ExitHook<mDT> = {
198
198
  handler: HookHandler<mDT>;
199
199
  };
200
200
  declare type HookDescription<mDT> = BasicHookDescription<mDT> | HookDescriptionWithAction<mDT> | GlobalActionHook<mDT> | AnyActionHook<mDT> | StandardTransitionHook<mDT> | MainTransitionHook<mDT> | ForcedTransitionHook<mDT> | AnyTransitionHook<mDT> | EntryHook<mDT> | ExitHook<mDT>;
201
+ declare type HookComplexResult<mDT> = {
202
+ pass: boolean;
203
+ state?: StateType;
204
+ data?: mDT;
205
+ };
201
206
  declare type HookResult = true | false | undefined | void;
202
207
  declare type HookContext<mDT> = {
203
208
  data: mDT;
@@ -206,4 +211,4 @@ declare type HookHandler<mDT> = (hook_context: HookContext<mDT>) => HookResult;
206
211
  declare type JssmErrorExtendedInfo = {
207
212
  requested_state?: StateType | undefined;
208
213
  };
209
- 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, HookResult };
214
+ 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, HookContext, HookResult, HookComplexResult };
@@ -1,2 +1,2 @@
1
- const version = "5.72.2";
1
+ const version = "5.72.3";
2
2
  export { version };