jssm 5.72.4 → 5.73.1
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 +47 -41
- package/README.md +24 -1
- package/dist/es6/jssm.d.ts +86 -1
- package/dist/es6/jssm.js +103 -1
- package/dist/es6/jssm_types.d.ts +1 -0
- package/dist/es6/version.js +1 -1
- package/dist/jssm.es5.cjs.js +1 -1
- package/dist/jssm.es5.iife.js +1 -1
- package/jest-spec.config.js +7 -1
- package/jssm.d.ts +86 -1
- package/jssm_types.d.ts +1 -0
- package/package.json +5 -2
package/jest-spec.config.js
CHANGED
|
@@ -22,6 +22,12 @@ module.exports = {
|
|
|
22
22
|
},
|
|
23
23
|
},
|
|
24
24
|
|
|
25
|
-
collectCoverageFrom: ["src/ts/**/{!(jssm-dot),}.{js,ts}"]
|
|
25
|
+
collectCoverageFrom: ["src/ts/**/{!(jssm-dot),}.{js,ts}"],
|
|
26
|
+
|
|
27
|
+
reporters: [
|
|
28
|
+
['default', {}],
|
|
29
|
+
['jest-json-reporter2', { outputDir: './coverage/spec', outputFile: 'metrics.json', fullOutput: false }],
|
|
30
|
+
// ['jest-json-reporter2', { outputDir: './coverage/spec', outputFile: 'extended-metrics.json', fullOutput: true }],
|
|
31
|
+
]
|
|
26
32
|
|
|
27
33
|
};
|
package/jssm.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
declare type StateType = string;
|
|
2
|
+
import { circular_buffer } from 'circular_buffer_js';
|
|
2
3
|
import { JssmGenericState, JssmGenericConfig, JssmTransition, JssmTransitionList, // JssmTransitionRule,
|
|
3
4
|
JssmMachineInternalState, JssmParseTree, JssmStateDeclaration, JssmArrow, JssmArrowDirection, JssmArrowKind, JssmLayout, FslDirection, FslTheme, HookDescription, HookHandler, HookContext, HookResult, HookComplexResult } from './jssm_types';
|
|
4
5
|
import { seq, weighted_rand_select, weighted_sample_select, histograph, weighted_histo_key } from './jssm_util';
|
|
@@ -233,7 +234,9 @@ declare class Machine<mDT> {
|
|
|
233
234
|
_main_transition_hook: HookHandler<mDT> | undefined;
|
|
234
235
|
_forced_transition_hook: HookHandler<mDT> | undefined;
|
|
235
236
|
_any_transition_hook: HookHandler<mDT> | undefined;
|
|
236
|
-
|
|
237
|
+
_history: circular_buffer<[StateType, mDT]>;
|
|
238
|
+
_history_length: number;
|
|
239
|
+
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, history, data }: JssmGenericConfig<mDT>);
|
|
237
240
|
/********
|
|
238
241
|
*
|
|
239
242
|
* Internal method for fabricating states. Not meant for external use.
|
|
@@ -551,6 +554,88 @@ declare class Machine<mDT> {
|
|
|
551
554
|
hook_exit(from: string, handler: HookHandler<mDT>): Machine<mDT>;
|
|
552
555
|
edges_between(from: string, to: string): JssmTransition<mDT>[];
|
|
553
556
|
transition_impl(newStateOrAction: StateType, newData: mDT | undefined, wasForced: boolean, wasAction: boolean): boolean;
|
|
557
|
+
/*********
|
|
558
|
+
*
|
|
559
|
+
* Get a truncated history of the recent states and data of the machine.
|
|
560
|
+
* Turned off by default; configure with `.from('...', {data: 5})` by length,
|
|
561
|
+
* or set `.history_length` at runtime.
|
|
562
|
+
*
|
|
563
|
+
* History *does not contain the current state*. If you want that, call
|
|
564
|
+
* `.history_inclusive` instead.
|
|
565
|
+
*
|
|
566
|
+
* ```typescript
|
|
567
|
+
* const foo = jssm.from(
|
|
568
|
+
* "a 'next' -> b 'next' -> c 'next' -> d 'next' -> e;",
|
|
569
|
+
* { history: 3 }
|
|
570
|
+
* );
|
|
571
|
+
*
|
|
572
|
+
* foo.action('next');
|
|
573
|
+
* foo.action('next');
|
|
574
|
+
* foo.action('next');
|
|
575
|
+
* foo.action('next');
|
|
576
|
+
*
|
|
577
|
+
* foo.history; // [ ['b',undefined], ['c',undefined], ['d',undefined] ]
|
|
578
|
+
* ```
|
|
579
|
+
*
|
|
580
|
+
* Notice that the machine's current state, `e`, is not in the returned list.
|
|
581
|
+
*
|
|
582
|
+
* @typeparam mDT The type of the machine data member; usually omitted
|
|
583
|
+
*
|
|
584
|
+
*/
|
|
585
|
+
get history(): [string, mDT][];
|
|
586
|
+
/*********
|
|
587
|
+
*
|
|
588
|
+
* Get a truncated history of the recent states and data of the machine,
|
|
589
|
+
* including the current state. Turned off by default; configure with
|
|
590
|
+
* `.from('...', {data: 5})` by length, or set `.history_length` at runtime.
|
|
591
|
+
*
|
|
592
|
+
* History inclusive contains the current state. If you only want past
|
|
593
|
+
* states, call `.history` instead.
|
|
594
|
+
*
|
|
595
|
+
* The list returned will be one longer than the history buffer kept, as the
|
|
596
|
+
* history buffer kept gets the current state added to it to produce this
|
|
597
|
+
* list.
|
|
598
|
+
*
|
|
599
|
+
* ```typescript
|
|
600
|
+
* const foo = jssm.from(
|
|
601
|
+
* "a 'next' -> b 'next' -> c 'next' -> d 'next' -> e;",
|
|
602
|
+
* { history: 3 }
|
|
603
|
+
* );
|
|
604
|
+
*
|
|
605
|
+
* foo.action('next');
|
|
606
|
+
* foo.action('next');
|
|
607
|
+
* foo.action('next');
|
|
608
|
+
* foo.action('next');
|
|
609
|
+
*
|
|
610
|
+
* foo.history_inclusive; // [ ['b',undefined], ['c',undefined], ['d',undefined], ['e',undefined] ]
|
|
611
|
+
* ```
|
|
612
|
+
*
|
|
613
|
+
* Notice that the machine's current state, `e`, is in the returned list.
|
|
614
|
+
*
|
|
615
|
+
* @typeparam mDT The type of the machine data member; usually omitted
|
|
616
|
+
*
|
|
617
|
+
*/
|
|
618
|
+
get history_inclusive(): [string, mDT][];
|
|
619
|
+
/*********
|
|
620
|
+
*
|
|
621
|
+
* Find out how long a history this machine is keeping. Defaults to zero.
|
|
622
|
+
* Settable directly.
|
|
623
|
+
*
|
|
624
|
+
* ```typescript
|
|
625
|
+
* const foo = jssm.from("a -> b;");
|
|
626
|
+
* foo.history_length; // 0
|
|
627
|
+
*
|
|
628
|
+
* const bar = jssm.from("a -> b;", { history: 3 });
|
|
629
|
+
* foo.history_length; // 3
|
|
630
|
+
* foo.history_length = 5;
|
|
631
|
+
* foo.history_length; // 5
|
|
632
|
+
* ```
|
|
633
|
+
*
|
|
634
|
+
* @typeparam mDT The type of the machine data member; usually omitted
|
|
635
|
+
*
|
|
636
|
+
*/
|
|
637
|
+
get history_length(): number;
|
|
638
|
+
set history_length(to: number);
|
|
554
639
|
/********
|
|
555
640
|
*
|
|
556
641
|
* Instruct the machine to complete an action.
|
package/jssm_types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jssm",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.73.1",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=10.0.0"
|
|
6
6
|
},
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"audit": "text_audit -r -t major MAJOR wasteful WASTEFUL any mixed fixme FIXME checkme CHECKME testme TESTME stochable STOCHABLE todo TODO comeback COMEBACK whargarbl WHARGARBL -g ./src/ts/**/*.{js,ts}",
|
|
48
48
|
"vet": "npm run eslint && npm run audit",
|
|
49
49
|
"benny": "node ./src/buildjs/benchmark.js",
|
|
50
|
-
"build": "npm run vet && npm run test && npm run site && npm run changelog && npm run docs",
|
|
50
|
+
"build": "npm run vet && npm run test && npm run site && npm run changelog && npm run docs && npm run readme",
|
|
51
51
|
"clean_bench": "npm run test && npm run benny",
|
|
52
52
|
"qbuild": "npm run test",
|
|
53
53
|
"ci_build": "npm run vet && npm run test",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"min_cjs": "mv dist/jssm.es5.cjs.js dist/jssm.es5.cjs.nonmin.js && terser dist/jssm.es5.cjs.nonmin.js > dist/jssm.es5.cjs.js",
|
|
57
57
|
"site": "cp src/site/* docs/ && cp -r src/assets docs/assets/",
|
|
58
58
|
"docs": "typedoc src/ts/jssm.ts --options typedoc-options.js",
|
|
59
|
+
"readme": "rm ./README.md && node ./src/buildjs/make_readme.js",
|
|
59
60
|
"changelog": "rm -f CHANGELOG.md && rm -f ./src/doc_md/CHANGELOG.md && better_git_changelog -b && cp CHANGELOG.* ./src/doc_md/"
|
|
60
61
|
},
|
|
61
62
|
"repository": {
|
|
@@ -119,6 +120,7 @@
|
|
|
119
120
|
"fast-check": "^2.12.0",
|
|
120
121
|
"glob": "^7.1.6",
|
|
121
122
|
"jest": "^27.3.1",
|
|
123
|
+
"jest-json-reporter2": "^1.1.0",
|
|
122
124
|
"pegjs": "^0.10.0",
|
|
123
125
|
"rollup": "^2.72.1",
|
|
124
126
|
"semver": "^5.7.1",
|
|
@@ -129,6 +131,7 @@
|
|
|
129
131
|
"typescript": "^4.6.4"
|
|
130
132
|
},
|
|
131
133
|
"dependencies": {
|
|
134
|
+
"circular_buffer_js": "^1.10.0",
|
|
132
135
|
"better_git_changelog": "^1.6.1",
|
|
133
136
|
"reduce-to-639-1": "^1.0.4"
|
|
134
137
|
}
|