Skip to content

Commit

Permalink
First steps towards being a Moore machine - initial data in constructor
Browse files Browse the repository at this point in the history
fixes StoneCypher/fsl#923 , can read in hooks fixes StoneCypher/fsl#924
  • Loading branch information
StoneCypher committed Jun 24, 2022
1 parent 1dc7c24 commit a1c43e9
Show file tree
Hide file tree
Showing 21 changed files with 278 additions and 130 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.

917 merges; 114 releases
918 merges; 114 releases



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



 

 

## [Untagged] - 6/23/2022 6:34:38 PM

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

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

* Small documentation tweaks. First attempt to lodge on deno.land




&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.

917 merges; 114 releases; Changlogging the last 10 commits; Full changelog at [CHANGELOG.long.md](CHANGELOG.long.md)
918 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/23/2022 6:34:38 PM

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

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

* Small documentation tweaks. First attempt to lodge on deno.land




&nbsp;

&nbsp;
Expand Down Expand Up @@ -162,21 +177,4 @@ Commit [3211f94bb943a63ae07f202eb168916d73f94f90](https://github.com/StoneCypher

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

* missing closing div tag was breaking examples page




&nbsp;

&nbsp;

<a name="5__70__29" />

## [5.70.29] - 6/18/2022 8:40:30 AM

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

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

* One more build to trigger remote.
* missing closing div tag was breaking examples page
3 changes: 2 additions & 1 deletion dist/es6/jssm.d.ts
Expand Up @@ -208,6 +208,7 @@ declare class Machine<mDT> {
_raw_state_declaration?: Array<Object>;
_state_declarations: Map<StateType, JssmStateDeclaration>;
_instance_name: string;
_data?: mDT;
_graph_layout: JssmLayout;
_dot_preamble: string;
_arrange_declaration: Array<Array<StateType>>;
Expand All @@ -232,7 +233,7 @@ declare class Machine<mDT> {
_main_transition_hook: HookHandler | undefined;
_forced_transition_hook: HookHandler | undefined;
_any_transition_hook: HookHandler | undefined;
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, arrange_declaration, arrange_start_declaration, arrange_end_declaration, theme, flow, graph_layout, instance_name }: JssmGenericConfig<mDT>);
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, arrange_declaration, arrange_start_declaration, arrange_end_declaration, theme, flow, graph_layout, instance_name, data }: JssmGenericConfig<mDT>);
/********
*
* Internal method for fabricating states. Not meant for external use.
Expand Down
15 changes: 3 additions & 12 deletions dist/es6/jssm.js
Expand Up @@ -534,7 +534,7 @@ function transfer_state_properties(state_decl) {
// TODO add a lotta docblock here
class Machine {
// whargarbl this badly needs to be broken up, monolith master
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 }) {
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, data }) {
this._instance_name = instance_name;
this._state = start_states[0];
this._states = new Map();
Expand Down Expand Up @@ -581,6 +581,7 @@ class Machine {
this._forced_transition_hook = undefined;
this._any_transition_hook = undefined;
this._standard_transition_hook = undefined;
this._data = data;
if (state_declaration) {
state_declaration.map((state_decl) => {
if (this._state_declarations.has(state_decl.state)) { // no repeats
Expand Down Expand Up @@ -1229,52 +1230,42 @@ class Machine {
}
}
hook(from, to, handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'hook', from, to, handler });
return this;
}
hook_action(from, to, action, handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'named', from, to, action, handler });
return this;
}
hook_global_action(action, handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'global action', action, handler });
return this;
}
hook_any_action(handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'any action', handler });
return this;
}
hook_standard_transition(handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'standard transition', handler });
return this;
}
hook_main_transition(handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'main transition', handler });
return this;
}
hook_forced_transition(handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'forced transition', handler });
return this;
}
hook_any_transition(handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'any transition', handler });
return this;
}
hook_entry(to, handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'entry', to, handler });
return this;
}
hook_exit(from, handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'exit', from, handler });
return this;
}
Expand Down Expand Up @@ -1317,7 +1308,7 @@ class Machine {
// todo major incomplete whargarbl comeback
if (valid) {
if (this._has_hooks) {
const hook_args = { action: fromAction, from: this._state, to: newState, forced: wasForced };
const hook_args = { data: this._data, action: fromAction, from: this._state, to: newState, forced: wasForced };
if (wasAction) {
// 1. any action hook
if (this._any_action_hook !== undefined) {
Expand Down
2 changes: 1 addition & 1 deletion dist/es6/version.js
@@ -1,2 +1,2 @@
const version = "5.71.1";
const version = "5.72.0";
export { version };
2 changes: 1 addition & 1 deletion dist/jssm.es5.cjs.js

Large diffs are not rendered by default.

17 changes: 4 additions & 13 deletions dist/jssm.es5.cjs.nonmin.js
Expand Up @@ -16783,7 +16783,7 @@ function peg$parse(input, options) {
}
}

const version = "5.71.1";
const version = "5.72.0";

class JssmError extends Error {
constructor(machine, message, JEEI) {
Expand Down Expand Up @@ -17342,7 +17342,7 @@ function transfer_state_properties(state_decl) {
// TODO add a lotta docblock here
class Machine {
// whargarbl this badly needs to be broken up, monolith master
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 }) {
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, data }) {
this._instance_name = instance_name;
this._state = start_states[0];
this._states = new Map();
Expand Down Expand Up @@ -17389,6 +17389,7 @@ class Machine {
this._forced_transition_hook = undefined;
this._any_transition_hook = undefined;
this._standard_transition_hook = undefined;
this._data = data;
if (state_declaration) {
state_declaration.map((state_decl) => {
if (this._state_declarations.has(state_decl.state)) { // no repeats
Expand Down Expand Up @@ -18037,52 +18038,42 @@ class Machine {
}
}
hook(from, to, handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'hook', from, to, handler });
return this;
}
hook_action(from, to, action, handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'named', from, to, action, handler });
return this;
}
hook_global_action(action, handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'global action', action, handler });
return this;
}
hook_any_action(handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'any action', handler });
return this;
}
hook_standard_transition(handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'standard transition', handler });
return this;
}
hook_main_transition(handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'main transition', handler });
return this;
}
hook_forced_transition(handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'forced transition', handler });
return this;
}
hook_any_transition(handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'any transition', handler });
return this;
}
hook_entry(to, handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'entry', to, handler });
return this;
}
hook_exit(from, handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'exit', from, handler });
return this;
}
Expand Down Expand Up @@ -18125,7 +18116,7 @@ class Machine {
// todo major incomplete whargarbl comeback
if (valid) {
if (this._has_hooks) {
const hook_args = { action: fromAction, from: this._state, to: newState, forced: wasForced };
const hook_args = { data: this._data, action: fromAction, from: this._state, to: newState, forced: wasForced };
if (wasAction) {
// 1. any action hook
if (this._any_action_hook !== undefined) {
Expand Down
2 changes: 1 addition & 1 deletion dist/jssm.es5.iife.js

Large diffs are not rendered by default.

17 changes: 4 additions & 13 deletions dist/jssm.es5.iife.nonmin.js
Expand Up @@ -16782,7 +16782,7 @@ var jssm = (function (exports) {
}
}

const version = "5.71.1";
const version = "5.72.0";

class JssmError extends Error {
constructor(machine, message, JEEI) {
Expand Down Expand Up @@ -17341,7 +17341,7 @@ var jssm = (function (exports) {
// TODO add a lotta docblock here
class Machine {
// whargarbl this badly needs to be broken up, monolith master
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 }) {
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, data }) {
this._instance_name = instance_name;
this._state = start_states[0];
this._states = new Map();
Expand Down Expand Up @@ -17388,6 +17388,7 @@ var jssm = (function (exports) {
this._forced_transition_hook = undefined;
this._any_transition_hook = undefined;
this._standard_transition_hook = undefined;
this._data = data;
if (state_declaration) {
state_declaration.map((state_decl) => {
if (this._state_declarations.has(state_decl.state)) { // no repeats
Expand Down Expand Up @@ -18036,52 +18037,42 @@ var jssm = (function (exports) {
}
}
hook(from, to, handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'hook', from, to, handler });
return this;
}
hook_action(from, to, action, handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'named', from, to, action, handler });
return this;
}
hook_global_action(action, handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'global action', action, handler });
return this;
}
hook_any_action(handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'any action', handler });
return this;
}
hook_standard_transition(handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'standard transition', handler });
return this;
}
hook_main_transition(handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'main transition', handler });
return this;
}
hook_forced_transition(handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'forced transition', handler });
return this;
}
hook_any_transition(handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'any transition', handler });
return this;
}
hook_entry(to, handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'entry', to, handler });
return this;
}
hook_exit(from, handler) {
// TODO: should this throw if setting the hook fails, or ignore it and continue?
this.set_hook({ kind: 'exit', from, handler });
return this;
}
Expand Down Expand Up @@ -18124,7 +18115,7 @@ var jssm = (function (exports) {
// todo major incomplete whargarbl comeback
if (valid) {
if (this._has_hooks) {
const hook_args = { action: fromAction, from: this._state, to: newState, forced: wasForced };
const hook_args = { data: this._data, action: fromAction, from: this._state, to: newState, forced: wasForced };
if (wasAction) {
// 1. any action hook
if (this._any_action_hook !== undefined) {
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/assets/search.js

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions docs/docs/classes/Machine.html

Large diffs are not rendered by default.

0 comments on commit a1c43e9

Please sign in to comment.