Skip to content

Commit

Permalink
the conversion continues
Browse files Browse the repository at this point in the history
  • Loading branch information
StoneCypher committed Jun 25, 2022
1 parent b0cbe1c commit adfa906
Show file tree
Hide file tree
Showing 23 changed files with 420 additions and 223 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.long.md
Expand Up @@ -2,7 +2,7 @@

All notable changes to this project will be documented in this file.

920 merges; 114 releases
921 merges; 114 releases



Expand All @@ -18,6 +18,21 @@ Published tags:



 

 

## [Untagged] - 6/24/2022 5:49:06 PM

Commit [b0cbe1c1ae0199c8d78a82f624e8ee94b344cf71](https://github.com/StoneCypher/jssm/commit/b0cbe1c1ae0199c8d78a82f624e8ee94b344cf71)

Author: `John Haugeland <stonecypher@gmail.com>`

* Normalize hook return pattern, fixes StoneCypher/fsl#930




&nbsp;

&nbsp;
Expand Down
36 changes: 17 additions & 19 deletions CHANGELOG.md
Expand Up @@ -2,7 +2,7 @@

All notable changes to this project will be documented in this file.

920 merges; 114 releases; Changlogging the last 10 commits; Full changelog at [CHANGELOG.long.md](CHANGELOG.long.md)
921 merges; 114 releases; Changlogging the last 10 commits; Full changelog at [CHANGELOG.long.md](CHANGELOG.long.md)



Expand All @@ -18,6 +18,21 @@ Published tags:



&nbsp;

&nbsp;

## [Untagged] - 6/24/2022 5:49:06 PM

Commit [b0cbe1c1ae0199c8d78a82f624e8ee94b344cf71](https://github.com/StoneCypher/jssm/commit/b0cbe1c1ae0199c8d78a82f624e8ee94b344cf71)

Author: `John Haugeland <stonecypher@gmail.com>`

* Normalize hook return pattern, fixes StoneCypher/fsl#930




&nbsp;

&nbsp;
Expand Down Expand Up @@ -156,21 +171,4 @@ Commit [ca254f455f2c19f21e77834e993c310e05272822](https://github.com/StoneCypher

Author: `John Haugeland <stonecypher@gmail.com>`

* holy another facile build for triggering, batman




&nbsp;

&nbsp;

<a name="5__70__32" />

## [5.70.32] - 6/18/2022 8:48:07 PM

Commit [8115e8b62d8ac1cff3c7eb07afabced097f1be42](https://github.com/StoneCypher/jssm/commit/8115e8b62d8ac1cff3c7eb07afabced097f1be42)

Author: `John Haugeland <stonecypher@gmail.com>`

* yet another small commit as a trigger, this time to get the extended diff
* holy another facile build for triggering, batman
9 changes: 5 additions & 4 deletions dist/es6/jssm.d.ts
@@ -1,6 +1,6 @@
declare type StateType = string;
import { JssmGenericState, JssmGenericConfig, JssmTransition, JssmTransitionList, // JssmTransitionRule,
JssmMachineInternalState, JssmParseTree, JssmStateDeclaration, JssmArrow, JssmArrowDirection, JssmArrowKind, JssmLayout, FslDirection, FslTheme, HookDescription, HookHandler } from './jssm_types';
JssmMachineInternalState, JssmParseTree, JssmStateDeclaration, JssmArrow, JssmArrowDirection, JssmArrowKind, JssmLayout, FslDirection, FslTheme, HookDescription, HookHandler, HookResult } from './jssm_types';
import { seq, weighted_rand_select, weighted_sample_select, histograph, weighted_histo_key } from './jssm_util';
import { shapes, gviz_shapes, named_colors } from './jssm_constants';
import { version } from './version';
Expand Down Expand Up @@ -223,9 +223,9 @@ declare class Machine<mDT> {
_has_exit_hooks: boolean;
_has_global_action_hooks: boolean;
_has_transition_hooks: boolean;
_hooks: Map<string, Function>;
_hooks: Map<string, HookHandler<mDT>>;
_named_hooks: Map<string, Function>;
_entry_hooks: Map<string, Function>;
_entry_hooks: Map<string, HookHandler<mDT>>;
_exit_hooks: Map<string, Function>;
_global_action_hooks: Map<string, Function>;
_any_action_hook: HookHandler<mDT> | undefined;
Expand Down Expand Up @@ -669,4 +669,5 @@ declare function sm<mDT>(template_strings: TemplateStringsArray, ...remainder: a
*
*/
declare function from<mDT>(MachineAsString: string, ExtraConstructorFields?: Partial<JssmGenericConfig<mDT>> | undefined): Machine<mDT>;
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 };
declare function is_hook_rejection(hr: HookResult): boolean;
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 };
92 changes: 61 additions & 31 deletions dist/es6/jssm.js
Expand Up @@ -1328,8 +1328,6 @@ class Machine {
newState = newStateOrAction;
}
}
// todo whargarbl implement data stuff
// todo major incomplete whargarbl comeback
if (valid) {
if (this._has_hooks) {
const hook_args = { data: this._data, action: fromAction, from: this._state, to: newState, forced: wasForced };
Expand Down Expand Up @@ -1376,51 +1374,38 @@ class Machine {
}
// 6. regular hook
if (this._has_basic_hooks) {
const hn = hook_name(this._state, newState), maybe_hook = this._hooks.get(hn);
if (maybe_hook !== undefined) {
if (maybe_hook(hook_args) === false) {
return false;
}
const hn = hook_name(this._state, newState), outcome = AbstractHookStep(this._hooks.get(hn), hook_args);
if (outcome.pass === false) {
return false;
}
}
// 7. edge type hook
// 7a. standard transition hook
if (trans_type === 'legal') {
if (this._standard_transition_hook !== undefined) {
// todo handle actions
// todo handle forced
if (this._standard_transition_hook(hook_args) === false) {
return false;
}
const outcome = AbstractHookStep(this._standard_transition_hook, hook_args);
if (outcome.pass === false) {
return false;
}
}
// 7b. main type hook
if (trans_type === 'main') {
if (this._main_transition_hook !== undefined) {
// todo handle actions
// todo handle forced
if (this._main_transition_hook(hook_args) === false) {
return false;
}
const outcome = AbstractHookStep(this._main_transition_hook, hook_args);
if (outcome.pass === false) {
return false;
}
}
// 7c. forced transition hook
if (trans_type === 'forced') {
if (this._forced_transition_hook !== undefined) {
// todo handle actions
// todo handle forced
if (this._forced_transition_hook(hook_args) === false) {
return false;
}
const outcome = AbstractHookStep(this._forced_transition_hook, hook_args);
if (outcome.pass === false) {
return false;
}
}
// 8. entry hook
if (this._has_entry_hooks) {
const maybe_en_hook = this._entry_hooks.get(newState);
if (maybe_en_hook !== undefined) {
if (maybe_en_hook(hook_args) === false) {
return false;
}
const outcome = AbstractHookStep(this._entry_hooks.get(newState), hook_args);
if (outcome.pass === false) {
return false;
}
}
this._state = newState;
Expand Down Expand Up @@ -1615,6 +1600,51 @@ function from(MachineAsString, ExtraConstructorFields) {
}
return new Machine(to_decorate);
}
function is_hook_complex_result(hr) {
if (typeof hr === 'object') {
if (typeof hr.pass === 'boolean') {
return true;
}
}
return false;
}
function is_hook_rejection(hr) {
if (hr === true) {
return false;
}
if (hr === undefined) {
return false;
}
if (hr === false) {
return true;
}
if (is_hook_complex_result(hr)) {
return (!(hr.pass));
}
throw new TypeError('unknown hook rejection type result');
}
// TODO hook_args: unknown
function AbstractHookStep(maybe_hook, hook_args) {
if (maybe_hook !== undefined) {
const result = maybe_hook(hook_args);
if (result === undefined) {
return { pass: true };
}
if (result === true) {
return { pass: true };
}
if (result === false) {
return { pass: false };
}
// if (is_hook_complex_result(result)) {
// return result;
// }
throw new TypeError(`Unknown hook result type ${result}`);
}
else {
return { pass: true };
}
}
export { version, transfer_state_properties, Machine, make, wrap_parse as parse, compile, sm, from, arrow_direction, arrow_left_kind, arrow_right_kind,
// WHARGARBL TODO these should be exported to a utility library
seq, weighted_rand_select, histograph, weighted_sample_select, weighted_histo_key, shapes, gviz_shapes, named_colors };
seq, weighted_rand_select, histograph, weighted_sample_select, weighted_histo_key, shapes, gviz_shapes, named_colors, is_hook_rejection };
7 changes: 6 additions & 1 deletion dist/es6/jssm_types.d.ts
Expand Up @@ -198,6 +198,11 @@ declare type ExitHook<mDT> = {
handler: HookHandler<mDT>;
};
declare type HookDescription<mDT> = BasicHookDescription<mDT> | HookDescriptionWithAction<mDT> | GlobalActionHook<mDT> | AnyActionHook<mDT> | StandardTransitionHook<mDT> | MainTransitionHook<mDT> | ForcedTransitionHook<mDT> | AnyTransitionHook<mDT> | EntryHook<mDT> | ExitHook<mDT>;
declare type HookComplexResult<mDT> = {
pass: boolean;
state?: StateType;
data?: mDT;
};
declare type HookResult = true | false | undefined | void;
declare type HookContext<mDT> = {
data: mDT;
Expand All @@ -206,4 +211,4 @@ declare type HookHandler<mDT> = (hook_context: HookContext<mDT>) => HookResult;
declare type JssmErrorExtendedInfo = {
requested_state?: StateType | undefined;
};
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 };
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 };
2 changes: 1 addition & 1 deletion dist/es6/version.js
@@ -1,2 +1,2 @@
const version = "5.72.2";
const version = "5.72.3";
export { version };
2 changes: 1 addition & 1 deletion dist/jssm.es5.cjs.js

Large diffs are not rendered by default.

0 comments on commit adfa906

Please sign in to comment.