jssm 5.76.2 → 5.78.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 +49 -49
- package/README.md +2 -2
- package/dist/es6/jssm.d.ts +56 -7
- package/dist/es6/jssm.js +74 -5
- package/dist/es6/jssm_types.d.ts +12 -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 +56 -7
- package/jssm_types.d.ts +12 -1
- package/package.json +1 -1
- package/rollup.config.deno.js +45 -0
- package/typedoc-options.js +1 -1
package/jssm.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
declare type StateType = string;
|
|
2
|
-
import { circular_buffer } from 'circular_buffer_js';
|
|
3
2
|
import { JssmGenericState, JssmGenericConfig, JssmTransition, JssmTransitionList, // JssmTransitionRule,
|
|
4
|
-
JssmMachineInternalState, JssmParseTree, JssmStateDeclaration, JssmArrow, JssmArrowDirection, JssmArrowKind, JssmLayout, FslDirection, FslTheme, HookDescription, HookHandler, HookContext, HookResult, HookComplexResult } from './jssm_types';
|
|
3
|
+
JssmMachineInternalState, JssmParseTree, JssmStateDeclaration, JssmArrow, JssmArrowDirection, JssmArrowKind, JssmLayout, JssmHistory, JssmSerialization, FslDirection, FslTheme, HookDescription, HookHandler, HookContext, HookResult, HookComplexResult } from './jssm_types';
|
|
5
4
|
import { seq, weighted_rand_select, weighted_sample_select, histograph, weighted_histo_key } from './jssm_util';
|
|
6
5
|
import { shapes, gviz_shapes, named_colors } from './jssm_constants';
|
|
7
6
|
import { version } from './version';
|
|
@@ -251,7 +250,7 @@ declare class Machine<mDT> {
|
|
|
251
250
|
_post_main_transition_hook: HookHandler<mDT> | undefined;
|
|
252
251
|
_post_forced_transition_hook: HookHandler<mDT> | undefined;
|
|
253
252
|
_post_any_transition_hook: HookHandler<mDT> | undefined;
|
|
254
|
-
_history:
|
|
253
|
+
_history: JssmHistory<mDT>;
|
|
255
254
|
_history_length: number;
|
|
256
255
|
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>);
|
|
257
256
|
/********
|
|
@@ -330,10 +329,19 @@ declare class Machine<mDT> {
|
|
|
330
329
|
* console.log( final_test.is_final() ); // true
|
|
331
330
|
* ```
|
|
332
331
|
*
|
|
332
|
+
*/
|
|
333
|
+
is_final(): boolean;
|
|
334
|
+
/********
|
|
335
|
+
*
|
|
336
|
+
* Serialize the current machine, including all defining state but not the
|
|
337
|
+
* machine string, to a structure. This means you will need the machine
|
|
338
|
+
* string to recreate (to not waste repeated space;) if you want the machine
|
|
339
|
+
* string embedded, call {@link serialize_with_string} instead.
|
|
340
|
+
*
|
|
333
341
|
* @typeparam mDT The type of the machine data member; usually omitted
|
|
334
342
|
*
|
|
335
343
|
*/
|
|
336
|
-
|
|
344
|
+
serialize(comment?: string | undefined): JssmSerialization<mDT>;
|
|
337
345
|
graph_layout(): string;
|
|
338
346
|
dot_preamble(): string;
|
|
339
347
|
machine_author(): Array<string>;
|
|
@@ -665,7 +673,7 @@ declare class Machine<mDT> {
|
|
|
665
673
|
set history_length(to: number);
|
|
666
674
|
/********
|
|
667
675
|
*
|
|
668
|
-
* Instruct the machine to complete an action.
|
|
676
|
+
* Instruct the machine to complete an action. Synonym for {@link do}.
|
|
669
677
|
*
|
|
670
678
|
* ```typescript
|
|
671
679
|
* const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
|
|
@@ -685,7 +693,27 @@ declare class Machine<mDT> {
|
|
|
685
693
|
action(actionName: StateType, newData?: mDT): boolean;
|
|
686
694
|
/********
|
|
687
695
|
*
|
|
688
|
-
* Instruct the machine to complete
|
|
696
|
+
* Instruct the machine to complete an action. Synonym for {@link action}.
|
|
697
|
+
*
|
|
698
|
+
* ```typescript
|
|
699
|
+
* const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
|
|
700
|
+
*
|
|
701
|
+
* light.state(); // 'red'
|
|
702
|
+
* light.do('next'); // true
|
|
703
|
+
* light.state(); // 'green'
|
|
704
|
+
* ```
|
|
705
|
+
*
|
|
706
|
+
* @typeparam mDT The type of the machine data member; usually omitted
|
|
707
|
+
*
|
|
708
|
+
* @param actionName The action to engage
|
|
709
|
+
*
|
|
710
|
+
* @param newData The data change to insert during the action
|
|
711
|
+
*
|
|
712
|
+
*/
|
|
713
|
+
do(actionName: StateType, newData?: mDT): boolean;
|
|
714
|
+
/********
|
|
715
|
+
*
|
|
716
|
+
* Instruct the machine to complete a transition. Synonym for {@link go}.
|
|
689
717
|
*
|
|
690
718
|
* ```typescript
|
|
691
719
|
* const light = sm`red -> green -> yellow -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
|
|
@@ -703,6 +731,26 @@ declare class Machine<mDT> {
|
|
|
703
731
|
*
|
|
704
732
|
*/
|
|
705
733
|
transition(newState: StateType, newData?: mDT): boolean;
|
|
734
|
+
/********
|
|
735
|
+
*
|
|
736
|
+
* Instruct the machine to complete a transition. Synonym for {@link transition}.
|
|
737
|
+
*
|
|
738
|
+
* ```typescript
|
|
739
|
+
* const light = sm`red -> green -> yellow -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
|
|
740
|
+
*
|
|
741
|
+
* light.state(); // 'red'
|
|
742
|
+
* light.go('green'); // true
|
|
743
|
+
* light.state(); // 'green'
|
|
744
|
+
* ```
|
|
745
|
+
*
|
|
746
|
+
* @typeparam mDT The type of the machine data member; usually omitted
|
|
747
|
+
*
|
|
748
|
+
* @param newState The state to switch to
|
|
749
|
+
*
|
|
750
|
+
* @param newData The data change to insert during the transition
|
|
751
|
+
*
|
|
752
|
+
*/
|
|
753
|
+
go(newState: StateType, newData?: mDT): boolean;
|
|
706
754
|
/********
|
|
707
755
|
*
|
|
708
756
|
* Instruct the machine to complete a forced transition (which will reject if
|
|
@@ -784,4 +832,5 @@ declare function from<mDT>(MachineAsString: string, ExtraConstructorFields?: Par
|
|
|
784
832
|
declare function is_hook_complex_result<mDT>(hr: unknown): hr is HookComplexResult<mDT>;
|
|
785
833
|
declare function is_hook_rejection<mDT>(hr: HookResult<mDT>): boolean;
|
|
786
834
|
declare function abstract_hook_step<mDT>(maybe_hook: HookHandler<mDT> | undefined, hook_args: HookContext<mDT>): HookComplexResult<mDT>;
|
|
787
|
-
|
|
835
|
+
declare function deserialize<mDT>(machine_string: string, ser: JssmSerialization<mDT>): Machine<mDT>;
|
|
836
|
+
export { version, transfer_state_properties, Machine, deserialize, 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, is_hook_complex_result, abstract_hook_step };
|
package/jssm_types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { circular_buffer } from 'circular_buffer_js';
|
|
1
2
|
declare type StateType = string;
|
|
2
3
|
declare type JssmSuccess = {
|
|
3
4
|
success: true;
|
|
@@ -25,6 +26,15 @@ declare type JssmCorner = 'regular' | 'rounded' | 'lined';
|
|
|
25
26
|
declare type JssmLineStyle = 'solid' | 'dashed' | 'dotted';
|
|
26
27
|
declare type FslDirection = 'up' | 'right' | 'down' | 'left';
|
|
27
28
|
declare type FslTheme = 'default' | 'ocean' | 'modern' | 'none';
|
|
29
|
+
declare type JssmSerialization<DataType> = {
|
|
30
|
+
jssm_version: string;
|
|
31
|
+
timestamp: number;
|
|
32
|
+
comment?: string | undefined;
|
|
33
|
+
state: StateType;
|
|
34
|
+
history: [string, DataType][];
|
|
35
|
+
history_capacity: number;
|
|
36
|
+
data: DataType;
|
|
37
|
+
};
|
|
28
38
|
declare type JssmTransitionPermitter<DataType> = (OldState: StateType, NewState: StateType, OldData: DataType, NewData: DataType) => boolean;
|
|
29
39
|
declare type JssmTransitionPermitterMaybeArray<DataType> = JssmTransitionPermitter<DataType> | Array<JssmTransitionPermitter<DataType>>;
|
|
30
40
|
declare type JssmTransition<DataType> = {
|
|
@@ -264,4 +274,5 @@ declare type PostHookHandler<mDT> = (hook_context: HookContext<mDT>) => void;
|
|
|
264
274
|
declare type JssmErrorExtendedInfo = {
|
|
265
275
|
requested_state?: StateType | undefined;
|
|
266
276
|
};
|
|
267
|
-
|
|
277
|
+
declare type JssmHistory<mDT> = circular_buffer<[StateType, mDT]>;
|
|
278
|
+
export { JssmColor, JssmShape, JssmTransition, JssmTransitions, JssmTransitionList, JssmTransitionRule, JssmArrow, JssmArrowKind, JssmArrowDirection, JssmGenericConfig, JssmGenericState, JssmGenericMachine, JssmParseTree, JssmCompileSe, JssmCompileSeStart, JssmCompileRule, JssmPermitted, JssmPermittedOpt, JssmResult, JssmStateDeclaration, JssmStateDeclarationRule, JssmLayout, JssmHistory, JssmSerialization, JssmParseFunctionType, JssmMachineInternalState, JssmErrorExtendedInfo, FslDirection, FslTheme, HookDescription, HookHandler, HookContext, HookResult, HookComplexResult };
|
package/package.json
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
import nodeResolve from '@rollup/plugin-node-resolve';
|
|
3
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
4
|
+
import replace from '@rollup/plugin-replace';
|
|
5
|
+
|
|
6
|
+
const pkg = require('./package.json');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const config = {
|
|
12
|
+
|
|
13
|
+
input: 'dist/es6/jssm.js',
|
|
14
|
+
|
|
15
|
+
output: {
|
|
16
|
+
file : 'dist/deno/jssm.deno-esm.js',
|
|
17
|
+
format : 'esm',
|
|
18
|
+
name : 'jssm'
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
plugins : [
|
|
22
|
+
|
|
23
|
+
nodeResolve({
|
|
24
|
+
mainFields : ['module', 'main'],
|
|
25
|
+
browser : true,
|
|
26
|
+
extensions : [ '.js', '.json', '.ts', '.tsx' ],
|
|
27
|
+
preferBuiltins : false
|
|
28
|
+
}),
|
|
29
|
+
|
|
30
|
+
commonjs(),
|
|
31
|
+
|
|
32
|
+
replace({
|
|
33
|
+
preventAssignment : true,
|
|
34
|
+
'process.env.NODE_ENV' : JSON.stringify( 'production' )
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
export default config;
|
package/typedoc-options.js
CHANGED
|
@@ -27,7 +27,7 @@ module.exports = {
|
|
|
27
27
|
{ title: 'Node', source: 'todo.md' },
|
|
28
28
|
{ title: 'Typescript', source: 'todo.md' },
|
|
29
29
|
{ title: 'The browser', source: 'todo.md' },
|
|
30
|
-
|
|
30
|
+
// { title: 'Deno', source: 'todo.md' },
|
|
31
31
|
{ title: 'AWS Lambda', source: 'todo.md' },
|
|
32
32
|
{ title: 'SQL', source: 'todo.md' },
|
|
33
33
|
] },
|