jssm 5.89.6 → 5.90.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/CHANGELOG.md +34 -37
- package/README.md +3 -3
- package/dist/es6/jssm.d.ts +7 -3
- package/dist/es6/jssm.js +16 -3
- package/dist/es6/jssm_types.d.ts +3 -1
- package/dist/es6/jssm_util.js +1 -1
- package/dist/es6/version.js +1 -1
- package/dist/jssm.es5.cjs.js +1 -1
- package/dist/jssm.es5.iife.js +1 -1
- package/jssm.d.ts +7 -3
- package/jssm_types.d.ts +3 -1
- package/package.json +1 -1
- package/tutorial_learn_testing.md +168 -0
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
|
-
|
|
5
|
+
1102 merges; 187 releases; Changlogging the last 10 commits; Full changelog at [CHANGELOG.long.md](CHANGELOG.long.md)
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
@@ -18,6 +18,38 @@ Published tags:
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [Untagged] - 10/25/2023 11:31:11 AM
|
|
26
|
+
|
|
27
|
+
Commit [966c142a44db8c5f890b2cc4edadca9faee2d625](https://github.com/StoneCypher/jssm/commit/966c142a44db8c5f890b2cc4edadca9faee2d625)
|
|
28
|
+
|
|
29
|
+
Author: `John Haugeland <stonecypher@gmail.com>`
|
|
30
|
+
|
|
31
|
+
Merges [9944585, bba1f0a]
|
|
32
|
+
|
|
33
|
+
* Merge branch 'main' into NewGraphicAssets
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## [Untagged] - 10/25/2023 11:29:11 AM
|
|
43
|
+
|
|
44
|
+
Commit [bba1f0a273ca73ffe105eed27619fc6b31247568](https://github.com/StoneCypher/jssm/commit/bba1f0a273ca73ffe105eed27619fc6b31247568)
|
|
45
|
+
|
|
46
|
+
Author: `John Haugeland <stonecypher@gmail.com>`
|
|
47
|
+
|
|
48
|
+
* update github action to cover more modern node versions to cover 20 and 21
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
21
53
|
|
|
22
54
|
|
|
23
55
|
|
|
@@ -149,39 +181,4 @@ Author: `John Haugeland <stonecypher@gmail.com>`
|
|
|
149
181
|
Merges [d04a575, 6337159]
|
|
150
182
|
|
|
151
183
|
* Merge pull request #556 from StoneCypher/FinalizeDenoSupport
|
|
152
|
-
* Standard deno support
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
## [Untagged] - 5/13/2023 11:35:56 PM
|
|
162
|
-
|
|
163
|
-
Commit [6337159890e2a5f96af18a926096d82876660903](https://github.com/StoneCypher/jssm/commit/6337159890e2a5f96af18a926096d82876660903)
|
|
164
|
-
|
|
165
|
-
Author: `John Haugeland <stonecypher@gmail.com>`
|
|
166
|
-
|
|
167
|
-
* Standard deno support
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
<a name="5__89__0" />
|
|
177
|
-
|
|
178
|
-
## [5.89.0] - 5/7/2023 12:34:42 PM
|
|
179
|
-
|
|
180
|
-
Commit [d04a57542edb377085437d38e31d13a65fccdce8](https://github.com/StoneCypher/jssm/commit/d04a57542edb377085437d38e31d13a65fccdce8)
|
|
181
|
-
|
|
182
|
-
Author: `John Haugeland <stonecypher@gmail.com>`
|
|
183
|
-
|
|
184
|
-
Merges [ef4285a, 2a87cf1]
|
|
185
|
-
|
|
186
|
-
* Merge pull request #555 from StoneCypher/ReattemptDenoSupport
|
|
187
|
-
* draft support for deno
|
|
184
|
+
* Standard deno support
|
package/README.md
CHANGED
|
@@ -18,10 +18,10 @@ Please edit the file it's derived from, instead: `./src/md/readme_base.md`
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
* Generated for version 5.
|
|
21
|
+
* Generated for version 5.90.0 at 10/25/2023, 12:32:59 PM
|
|
22
22
|
|
|
23
23
|
-->
|
|
24
|
-
# jssm 5.
|
|
24
|
+
# jssm 5.90.0
|
|
25
25
|
|
|
26
26
|
Easy. Small. Fast. TS, es6, es5. Node, Browser. 100% coverage. Property
|
|
27
27
|
tests. Fuzz tests. Language tests for a dozen languages and emoji. Easy to
|
|
@@ -29,7 +29,7 @@ share online. Easy to embed.
|
|
|
29
29
|
|
|
30
30
|
Readable, useful state machines as one-liner strings.
|
|
31
31
|
|
|
32
|
-
***4,
|
|
32
|
+
***4,937 tests*** run 5,828 times. 4,928 specs with 100.0% coverage, 9 fuzz tests with 13.0% coverage. With 2,855 lines, that's about 1.7 tests per line, or {{line_run_ratio}} generated tests per line.
|
|
33
33
|
|
|
34
34
|
***Meet your new state machine library.***
|
|
35
35
|
|
package/dist/es6/jssm.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare type StateType = string;
|
|
2
2
|
import { JssmGenericState, JssmGenericConfig, JssmStateConfig, JssmTransition, JssmTransitionList, // JssmTransitionRule,
|
|
3
|
-
JssmMachineInternalState, JssmAllowsOverride, JssmStateDeclaration, JssmStateStyleKeyList, JssmLayout, JssmHistory, JssmSerialization, FslDirection, FslDirections, FslTheme, HookDescription, HookHandler, HookContext, HookResult, HookComplexResult } from './jssm_types';
|
|
3
|
+
JssmMachineInternalState, JssmAllowsOverride, JssmStateDeclaration, JssmStateStyleKeyList, JssmLayout, JssmHistory, JssmSerialization, FslDirection, FslDirections, FslTheme, HookDescription, HookHandler, HookContext, HookResult, HookComplexResult, JssmRng } from './jssm_types';
|
|
4
4
|
import { arrow_direction, arrow_left_kind, arrow_right_kind } from './jssm_arrow';
|
|
5
5
|
import { compile, make, wrap_parse } from './jssm_compiler';
|
|
6
6
|
import { seq, unique, find_repeated, weighted_rand_select, weighted_sample_select, histograph, weighted_histo_key } from './jssm_util';
|
|
@@ -40,8 +40,10 @@ declare class Machine<mDT> {
|
|
|
40
40
|
_fsl_version?: string;
|
|
41
41
|
_raw_state_declaration?: Array<Object>;
|
|
42
42
|
_state_declarations: Map<StateType, JssmStateDeclaration>;
|
|
43
|
-
_instance_name: string;
|
|
44
43
|
_data?: mDT;
|
|
44
|
+
_instance_name: string;
|
|
45
|
+
_rng_seed: number;
|
|
46
|
+
_rng: JssmRng;
|
|
45
47
|
_graph_layout: JssmLayout;
|
|
46
48
|
_dot_preamble: string;
|
|
47
49
|
_arrange_declaration: Array<Array<StateType>>;
|
|
@@ -99,7 +101,7 @@ declare class Machine<mDT> {
|
|
|
99
101
|
_start_state_style: JssmStateConfig;
|
|
100
102
|
_end_state_style: JssmStateConfig;
|
|
101
103
|
_state_labels: Map<string, string>;
|
|
102
|
-
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, arrange_declaration, arrange_start_declaration, arrange_end_declaration, theme, flow, graph_layout, 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, allows_override, config_allows_override }: JssmGenericConfig<StateType, mDT>);
|
|
104
|
+
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, arrange_declaration, arrange_start_declaration, arrange_end_declaration, theme, flow, graph_layout, 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, allows_override, config_allows_override, rng_seed }: JssmGenericConfig<StateType, mDT>);
|
|
103
105
|
/********
|
|
104
106
|
*
|
|
105
107
|
* Internal method for fabricating states. Not meant for external use.
|
|
@@ -668,6 +670,8 @@ declare class Machine<mDT> {
|
|
|
668
670
|
post_hook_any_transition(handler: HookHandler<mDT>): Machine<mDT>;
|
|
669
671
|
post_hook_entry(to: string, handler: HookHandler<mDT>): Machine<mDT>;
|
|
670
672
|
post_hook_exit(from: string, handler: HookHandler<mDT>): Machine<mDT>;
|
|
673
|
+
get rng_seed(): number;
|
|
674
|
+
set rng_seed(to: number | undefined);
|
|
671
675
|
edges_between(from: string, to: string): JssmTransition<StateType, mDT>[];
|
|
672
676
|
/*********
|
|
673
677
|
*
|
package/dist/es6/jssm.js
CHANGED
|
@@ -4,7 +4,7 @@ import { FslDirections } from './jssm_types';
|
|
|
4
4
|
import { arrow_direction, arrow_left_kind, arrow_right_kind } from './jssm_arrow';
|
|
5
5
|
import { compile, make, wrap_parse } from './jssm_compiler';
|
|
6
6
|
import { theme_mapping, base_theme } from './jssm_theme';
|
|
7
|
-
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';
|
|
7
|
+
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, gen_splitmix32 } from './jssm_util';
|
|
8
8
|
import * as constants from './jssm_constants';
|
|
9
9
|
const { shapes, gviz_shapes, named_colors } = constants;
|
|
10
10
|
import { version, build_time } from './version'; // replaced from package.js in build
|
|
@@ -126,7 +126,7 @@ function state_style_condense(jssk) {
|
|
|
126
126
|
// TODO add a lotta docblock here
|
|
127
127
|
class Machine {
|
|
128
128
|
// whargarbl this badly needs to be broken up, monolith master
|
|
129
|
-
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, allows_override, config_allows_override }) {
|
|
129
|
+
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, allows_override, config_allows_override, rng_seed }) {
|
|
130
130
|
this._instance_name = instance_name;
|
|
131
131
|
this._state = start_states[0];
|
|
132
132
|
this._states = new Map();
|
|
@@ -212,6 +212,8 @@ class Machine {
|
|
|
212
212
|
this._history_length = history || 0;
|
|
213
213
|
this._history = new circular_buffer(this._history_length);
|
|
214
214
|
this._state_labels = new Map();
|
|
215
|
+
this._rng_seed = rng_seed !== null && rng_seed !== void 0 ? rng_seed : new Date().getTime();
|
|
216
|
+
this._rng = gen_splitmix32(this._rng_seed);
|
|
215
217
|
// consolidate the state declarations
|
|
216
218
|
if (state_declaration) {
|
|
217
219
|
state_declaration.map((state_decl) => {
|
|
@@ -1076,7 +1078,7 @@ class Machine {
|
|
|
1076
1078
|
return wtf;
|
|
1077
1079
|
}
|
|
1078
1080
|
probabilistic_transition() {
|
|
1079
|
-
const selected = weighted_rand_select(this.probable_exits_for(this.state()));
|
|
1081
|
+
const selected = weighted_rand_select(this.probable_exits_for(this.state()), undefined, this._rng);
|
|
1080
1082
|
return this.transition(selected.to);
|
|
1081
1083
|
}
|
|
1082
1084
|
probabilistic_walk(n) {
|
|
@@ -1419,6 +1421,17 @@ class Machine {
|
|
|
1419
1421
|
this.set_hook({ kind: 'post exit', from, handler });
|
|
1420
1422
|
return this;
|
|
1421
1423
|
}
|
|
1424
|
+
get rng_seed() {
|
|
1425
|
+
return this._rng_seed;
|
|
1426
|
+
}
|
|
1427
|
+
set rng_seed(to) {
|
|
1428
|
+
if (typeof to === 'undefined') {
|
|
1429
|
+
this._rng_seed = new Date().getTime();
|
|
1430
|
+
}
|
|
1431
|
+
else {
|
|
1432
|
+
this._rng_seed = to;
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1422
1435
|
// remove_hook(HookDesc: HookDescription) {
|
|
1423
1436
|
// throw new JssmError(this, 'TODO: Should remove hook here');
|
|
1424
1437
|
// }
|
package/dist/es6/jssm_types.d.ts
CHANGED
|
@@ -219,6 +219,7 @@ declare type JssmGenericConfig<StateType, DataType> = {
|
|
|
219
219
|
default_hooked_state_config?: JssmStateStyleKeyList;
|
|
220
220
|
default_terminal_state_config?: JssmStateStyleKeyList;
|
|
221
221
|
default_active_state_config?: JssmStateStyleKeyList;
|
|
222
|
+
rng_seed?: number | undefined;
|
|
222
223
|
};
|
|
223
224
|
declare type JssmCompileRule<StateType> = {
|
|
224
225
|
agg_as: string;
|
|
@@ -359,4 +360,5 @@ declare type JssmErrorExtendedInfo = {
|
|
|
359
360
|
requested_state?: StateType | undefined;
|
|
360
361
|
};
|
|
361
362
|
declare type JssmHistory<mDT> = circular_buffer<[StateType, mDT]>;
|
|
362
|
-
|
|
363
|
+
declare type JssmRng = () => number;
|
|
364
|
+
export { JssmColor, JssmShape, JssmTransition, JssmTransitions, JssmTransitionList, JssmTransitionRule, JssmArrow, JssmArrowKind, JssmArrowDirection, JssmGenericConfig, JssmGenericState, JssmGenericMachine, JssmParseTree, JssmCompileSe, JssmCompileSeStart, JssmCompileRule, JssmPermitted, JssmPermittedOpt, JssmResult, JssmStateDeclaration, JssmStateDeclarationRule, JssmStateConfig, JssmStateStyleKey, JssmStateStyleKeyList, JssmBaseTheme, JssmTheme, JssmLayout, JssmHistory, JssmSerialization, JssmPropertyDefinition, JssmAllowsOverride, JssmParseFunctionType, JssmMachineInternalState, JssmErrorExtendedInfo, FslDirections, FslDirection, FslThemes, FslTheme, HookDescription, HookHandler, HookContext, HookResult, HookComplexResult, JssmRng };
|
package/dist/es6/jssm_util.js
CHANGED
|
@@ -11,7 +11,7 @@ function arr_uniq_p(el, i, source) {
|
|
|
11
11
|
const array_box_if_string = n => typeof n === 'string' ? [n] : n;
|
|
12
12
|
// this is explicitly about other peoples' data, so it has to be weakly typed
|
|
13
13
|
/* eslint-disable flowtype/no-weak-types */
|
|
14
|
-
const weighted_rand_select = (options, probability_property = 'probability') => {
|
|
14
|
+
const weighted_rand_select = (options, probability_property = 'probability', rng) => {
|
|
15
15
|
if (!Array.isArray(options)) {
|
|
16
16
|
throw new TypeError('options must be a non-empty array of objects');
|
|
17
17
|
}
|
package/dist/es6/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const version = "5.
|
|
1
|
+
const version = "5.90.0", build_time = 1698262297064;
|
|
2
2
|
export { version, build_time };
|