xstate 6.0.0-alpha.47 → 6.0.0-alpha.49
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/README.md +30 -1
- package/dist/{StateMachine-7046f677.cjs.js → StateMachine-0adb3a70.cjs.js} +15 -12
- package/dist/{StateMachine-70c06bdd.development.cjs.js → StateMachine-29450e6d.development.cjs.js} +15 -12
- package/dist/{StateMachine-74929087.esm.js → StateMachine-2af31c11.esm.js} +10 -7
- package/dist/{StateMachine-ee10f67e.development.esm.js → StateMachine-faf50c5c.development.esm.js} +10 -7
- package/dist/{createActor-915ea40c.esm.js → createActor-268165d4.esm.js} +79 -23
- package/dist/{createActor-ff132afa.development.esm.js → createActor-88709f74.development.esm.js} +79 -23
- package/dist/{createActor-6736cbbe.development.cjs.js → createActor-a1e0dffb.development.cjs.js} +78 -25
- package/dist/{createActor-bfe8b6bd.cjs.js → createActor-b4dd05ae.cjs.js} +78 -25
- package/dist/declarations/src/createMachineFromConfig.d.ts +5 -77
- package/dist/declarations/src/fsm/createFSMActor.d.ts +67 -0
- package/dist/declarations/src/fsm/index.d.ts +2 -0
- package/dist/declarations/src/fsm.d.ts +5 -4
- package/dist/declarations/src/scxml/index.d.ts +1 -0
- package/dist/declarations/src/scxml/runtime.d.ts +251 -0
- package/dist/declarations/src/scxml/scxml.d.ts +19 -0
- package/dist/declarations/src/types.d.ts +1 -0
- package/dist/{effectDescriptor-8be60443.esm.js → effectDescriptor-30c9a744.esm.js} +1 -1
- package/dist/{effectDescriptor-fbe67d5a.development.esm.js → effectDescriptor-39d22100.development.esm.js} +1 -1
- package/dist/{effectDescriptor-3c699328.development.cjs.js → effectDescriptor-7ff6802f.development.cjs.js} +1 -1
- package/dist/{effectDescriptor-a7e2d4d1.cjs.js → effectDescriptor-be348e50.cjs.js} +1 -1
- package/dist/fsm-7a2e9697.cjs.js +777 -0
- package/dist/fsm-b804b3e9.esm.js +775 -0
- package/dist/fsm-c1316948.development.cjs.js +777 -0
- package/dist/fsm-e18a7cb4.development.esm.js +775 -0
- package/dist/types-3c3455f7.esm.js +185 -0
- package/dist/types-adda3842.development.esm.js +185 -0
- package/dist/types-b3fea5bd.development.cjs.js +189 -0
- package/dist/types-fbabaeee.cjs.js +189 -0
- package/dist/validation-05f1d517.esm.js +8 -0
- package/dist/validation-4561b43c.cjs.js +10 -0
- package/dist/validation-e69470ad.development.esm.js +8 -0
- package/dist/validation-f2714a35.development.cjs.js +10 -0
- package/dist/xstate-actors.cjs.js +934 -9
- package/dist/xstate-actors.development.cjs.js +934 -9
- package/dist/xstate-actors.development.esm.js +932 -2
- package/dist/xstate-actors.esm.js +932 -2
- package/dist/xstate-durable.cjs.js +2 -2
- package/dist/xstate-durable.development.cjs.js +2 -2
- package/dist/xstate-durable.development.esm.js +2 -2
- package/dist/xstate-durable.esm.js +2 -2
- package/dist/xstate-fsm.cjs.d.mts +2 -0
- package/dist/xstate-fsm.cjs.d.ts +2 -0
- package/dist/xstate-fsm.cjs.js +409 -0
- package/dist/xstate-fsm.cjs.mjs +5 -0
- package/dist/xstate-fsm.development.cjs.js +409 -0
- package/dist/xstate-fsm.development.cjs.mjs +5 -0
- package/dist/xstate-fsm.development.esm.js +403 -0
- package/dist/xstate-fsm.esm.js +403 -0
- package/dist/xstate-fsm.umd.min.js +2 -0
- package/dist/xstate-fsm.umd.min.js.map +1 -0
- package/dist/xstate-graph.cjs.js +4 -3
- package/dist/xstate-graph.development.cjs.js +4 -3
- package/dist/xstate-graph.development.esm.js +4 -3
- package/dist/xstate-graph.esm.js +4 -3
- package/dist/xstate-graph.umd.min.js +1 -1
- package/dist/xstate-graph.umd.min.js.map +1 -1
- package/dist/xstate-scxml.cjs.d.mts +2 -0
- package/dist/xstate-scxml.cjs.d.ts +2 -0
- package/dist/xstate-scxml.cjs.js +2387 -0
- package/dist/xstate-scxml.cjs.mjs +3 -0
- package/dist/xstate-scxml.development.cjs.js +2387 -0
- package/dist/xstate-scxml.development.cjs.mjs +3 -0
- package/dist/xstate-scxml.development.esm.js +2383 -0
- package/dist/xstate-scxml.esm.js +2383 -0
- package/dist/xstate-scxml.umd.min.js +26 -0
- package/dist/xstate-scxml.umd.min.js.map +1 -0
- package/dist/xstate-validation.cjs.js +1 -1
- package/dist/xstate-validation.development.cjs.js +1 -1
- package/dist/xstate-validation.development.esm.js +1 -1
- package/dist/xstate-validation.esm.js +1 -1
- package/dist/xstate.cjs.js +143 -1412
- package/dist/xstate.development.cjs.js +143 -1412
- package/dist/xstate.development.esm.js +143 -1411
- package/dist/xstate.esm.js +143 -1411
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/fsm/package.json +8 -0
- package/package.json +37 -3
- package/scxml/package.json +8 -0
- package/dist/index-0f498ef2.development.cjs.js +0 -946
- package/dist/index-70d56425.development.esm.js +0 -937
- package/dist/index-b051c924.esm.js +0 -937
- package/dist/index-b3fe59bc.cjs.js +0 -946
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ActorOptions, AnyActorLogic, EventFromLogic, InputFrom, Observer, SnapshotFrom } from "../types.js";
|
|
2
|
+
/** A compact actor runtime for logic returned by `createFSM(...)`. */
|
|
3
|
+
export declare class FSMActor<TLogic extends AnyActorLogic> {
|
|
4
|
+
readonly logic: TLogic;
|
|
5
|
+
private readonly options;
|
|
6
|
+
private _snapshot;
|
|
7
|
+
private _effects;
|
|
8
|
+
private _queue;
|
|
9
|
+
private _processing;
|
|
10
|
+
private _observers;
|
|
11
|
+
private _listeners;
|
|
12
|
+
private _trigger;
|
|
13
|
+
private _restored;
|
|
14
|
+
_processingStatus: any;
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly sessionId: string;
|
|
17
|
+
readonly address: string;
|
|
18
|
+
readonly ref: this;
|
|
19
|
+
readonly src: string | AnyActorLogic;
|
|
20
|
+
readonly system: any;
|
|
21
|
+
readonly _parent: any;
|
|
22
|
+
constructor(logic: TLogic, options?: ActorOptions<TLogic>);
|
|
23
|
+
private get self();
|
|
24
|
+
private get logger();
|
|
25
|
+
private defer;
|
|
26
|
+
private get emit();
|
|
27
|
+
private stopChild;
|
|
28
|
+
private actionExecutor;
|
|
29
|
+
start(): this;
|
|
30
|
+
send(event: EventFromLogic<TLogic>): void;
|
|
31
|
+
_send(event: EventFromLogic<TLogic>): void;
|
|
32
|
+
private flush;
|
|
33
|
+
private runEffects;
|
|
34
|
+
getSnapshot(): SnapshotFrom<TLogic>;
|
|
35
|
+
getPersistedSnapshot(options?: unknown): import("../types.js").Snapshot<unknown>;
|
|
36
|
+
toJSON(): {
|
|
37
|
+
xstate$type: string;
|
|
38
|
+
id: string;
|
|
39
|
+
address: string;
|
|
40
|
+
src: string | undefined;
|
|
41
|
+
};
|
|
42
|
+
_stop(): this;
|
|
43
|
+
stop(): this;
|
|
44
|
+
subscribe(observerOrNext?: Observer<SnapshotFrom<TLogic>> | ((snapshot: SnapshotFrom<TLogic>) => void), error?: (error: unknown) => void, complete?: () => void): {
|
|
45
|
+
unsubscribe(): void;
|
|
46
|
+
};
|
|
47
|
+
on(type: string, handler: (event: any) => void): {
|
|
48
|
+
unsubscribe: () => boolean;
|
|
49
|
+
};
|
|
50
|
+
_emit(event: any): void;
|
|
51
|
+
_terminate(termination: any): void;
|
|
52
|
+
private fail;
|
|
53
|
+
private notify;
|
|
54
|
+
_isRunning(): boolean;
|
|
55
|
+
_inspectTransition(): void;
|
|
56
|
+
get trigger(): any;
|
|
57
|
+
select<T>(selector: (snapshot: SnapshotFrom<TLogic>) => T, equal?: (a: T, b: T) => boolean): {
|
|
58
|
+
get: () => T;
|
|
59
|
+
subscribe: (observerOrNext: Observer<T> | ((value: T) => void)) => {
|
|
60
|
+
unsubscribe(): void;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
[Symbol.observable](): this;
|
|
64
|
+
}
|
|
65
|
+
export declare function createFSMActor<TLogic extends AnyActorLogic>(logic: TLogic, options?: ActorOptions<TLogic> & {
|
|
66
|
+
[K in undefined extends InputFrom<TLogic> ? never : 'input']: unknown;
|
|
67
|
+
}): FSMActor<TLogic>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { ActorLogic, EventObject, MachineContext, LogicalTimer, NonReducibleUnknown, Snapshot } from "./types.js";
|
|
1
|
+
import type { ActorLogic, EnqueueObject, EventObject, MachineContext, LogicalTimer, NonReducibleUnknown, Snapshot } from "./types.js";
|
|
3
2
|
export type FSMSnapshot<TContext extends MachineContext, TState extends string, TInput = unknown> = Snapshot<undefined> & {
|
|
4
3
|
value: TState;
|
|
5
4
|
context: TContext;
|
|
@@ -31,7 +30,7 @@ type FSMArgs<TContext extends MachineContext, TEvent extends EventObject, TState
|
|
|
31
30
|
};
|
|
32
31
|
type FSMAction<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TInput> = (args: FSMArgs<TContext, TEvent, TState, TInput> & {
|
|
33
32
|
input: Record<string, unknown> | undefined;
|
|
34
|
-
}, enq:
|
|
33
|
+
}, enq: EnqueueObject<TEvent, EventObject>) => void | {
|
|
35
34
|
context?: FSMContextPatch<TContext>;
|
|
36
35
|
};
|
|
37
36
|
type FSMGuard<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TInput> = (args: FSMArgs<TContext, TEvent, TState, TInput>) => boolean;
|
|
@@ -52,14 +51,16 @@ type FSMTarget<TContext extends MachineContext> = {
|
|
|
52
51
|
type FSMObjectTarget<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TInput> = Omit<FSMTarget<TContext>, 'context'> & {
|
|
53
52
|
context?: FSMContextPatch<TContext> | FSMContextMapper<TContext, TEvent, TState, TInput>;
|
|
54
53
|
};
|
|
55
|
-
type FSMTransitionFunction<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TInput> = (args: FSMArgs<TContext, TEvent, TState, TInput>, enq:
|
|
54
|
+
type FSMTransitionFunction<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TInput> = (args: FSMArgs<TContext, TEvent, TState, TInput>, enq: EnqueueObject<TEvent, EventObject>) => void | false | FSMTarget<TContext>;
|
|
56
55
|
type FSMTransition<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TInput> = FSMObjectTarget<TContext, TEvent, TState, TInput> | (FSMObjectTarget<TContext, TEvent, TState, TInput> & {
|
|
57
56
|
guard?: FSMGuard<TContext, TEvent, TState, TInput>;
|
|
58
57
|
actions?: FSMAction<TContext, TEvent, TState, TInput> | Array<FSMAction<TContext, TEvent, TState, TInput>>;
|
|
59
58
|
}) | FSMTransitionFunction<TContext, TEvent, TState, TInput>;
|
|
60
59
|
type FSMStateConfig<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TInput> = {
|
|
60
|
+
type?: 'final';
|
|
61
61
|
entry?: FSMAction<TContext, TEvent, TState, TInput> | Array<FSMAction<TContext, TEvent, TState, TInput>>;
|
|
62
62
|
exit?: FSMAction<TContext, TEvent, TState, TInput> | Array<FSMAction<TContext, TEvent, TState, TInput>>;
|
|
63
|
+
always?: FSMTransition<TContext, TEvent, TState, TInput> | Array<FSMTransition<TContext, TEvent, TState, TInput>>;
|
|
63
64
|
on?: Record<string, FSMTransition<TContext, TEvent, TState, TInput> | Array<FSMTransition<TContext, TEvent, TState, TInput>>>;
|
|
64
65
|
};
|
|
65
66
|
export type FSMConfig<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TInput = NonReducibleUnknown> = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createMachineFromSCXML, type SCXMLConversionOptions } from "./scxml.js";
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { AnyActorLogic, AnyEventObject, AnyStateMachine, EventObject, MachineContext, MetaObject } from "../types.js";
|
|
2
|
+
export interface RaiseJSON {
|
|
3
|
+
type: '@xstate.raise';
|
|
4
|
+
event: EventObject;
|
|
5
|
+
id?: string;
|
|
6
|
+
delay?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface CancelJSON {
|
|
9
|
+
type: '@xstate.cancel';
|
|
10
|
+
id: string;
|
|
11
|
+
}
|
|
12
|
+
interface LogJSON {
|
|
13
|
+
type: '@xstate.log';
|
|
14
|
+
args: any[];
|
|
15
|
+
}
|
|
16
|
+
export interface ScxmlLogJSON {
|
|
17
|
+
type: 'scxml.log';
|
|
18
|
+
label?: string;
|
|
19
|
+
expr?: string;
|
|
20
|
+
}
|
|
21
|
+
interface EmitJSON {
|
|
22
|
+
type: '@xstate.emit';
|
|
23
|
+
event: AnyEventObject;
|
|
24
|
+
}
|
|
25
|
+
interface AssignJSON {
|
|
26
|
+
type: '@xstate.assign';
|
|
27
|
+
context: MachineContext;
|
|
28
|
+
}
|
|
29
|
+
interface ScxmlAssignJSON {
|
|
30
|
+
type: 'scxml.assign';
|
|
31
|
+
/** SCXML location attribute - the context property to assign to */
|
|
32
|
+
location: string;
|
|
33
|
+
/** SCXML expr attribute - expression to evaluate */
|
|
34
|
+
expr: string;
|
|
35
|
+
}
|
|
36
|
+
export interface ScxmlRaiseJSON {
|
|
37
|
+
type: 'scxml.raise';
|
|
38
|
+
/** Event type, or undefined if using eventexpr */
|
|
39
|
+
event?: string;
|
|
40
|
+
/** Expression to evaluate for event type */
|
|
41
|
+
eventexpr?: string;
|
|
42
|
+
/** Params with expressions to evaluate */
|
|
43
|
+
params?: Array<{
|
|
44
|
+
name: string;
|
|
45
|
+
expr?: string;
|
|
46
|
+
location?: string;
|
|
47
|
+
}>;
|
|
48
|
+
namelist?: string[];
|
|
49
|
+
id?: string;
|
|
50
|
+
idlocation?: string;
|
|
51
|
+
delay?: number;
|
|
52
|
+
/** Expression for delay */
|
|
53
|
+
delayexpr?: string;
|
|
54
|
+
/** Static target (e.g. '#_parent') */
|
|
55
|
+
target?: string;
|
|
56
|
+
/** Expression for target */
|
|
57
|
+
targetexpr?: string;
|
|
58
|
+
processorType?: string;
|
|
59
|
+
content?: ScxmlContentJSON;
|
|
60
|
+
}
|
|
61
|
+
export interface ScxmlXmlJSON {
|
|
62
|
+
name: string;
|
|
63
|
+
attributes?: Record<string, string>;
|
|
64
|
+
children?: ScxmlXmlJSON[];
|
|
65
|
+
}
|
|
66
|
+
export interface ScxmlContentJSON {
|
|
67
|
+
expr?: string;
|
|
68
|
+
text?: string;
|
|
69
|
+
xml?: ScxmlXmlJSON;
|
|
70
|
+
}
|
|
71
|
+
interface ScxmlScriptJSON {
|
|
72
|
+
type: 'scxml.script';
|
|
73
|
+
/** The script code to execute */
|
|
74
|
+
code: string;
|
|
75
|
+
global?: boolean;
|
|
76
|
+
}
|
|
77
|
+
export interface ScxmlForeachJSON {
|
|
78
|
+
type: 'scxml.foreach';
|
|
79
|
+
array: string;
|
|
80
|
+
item: string;
|
|
81
|
+
index?: string;
|
|
82
|
+
actions: ActionJSON[];
|
|
83
|
+
}
|
|
84
|
+
export interface ScxmlCancelJSON {
|
|
85
|
+
type: 'scxml.cancel';
|
|
86
|
+
sendidexpr: string;
|
|
87
|
+
}
|
|
88
|
+
export interface ScxmlDonedataJSON {
|
|
89
|
+
params?: Array<{
|
|
90
|
+
name: string;
|
|
91
|
+
expr: string;
|
|
92
|
+
}>;
|
|
93
|
+
contentExpr?: string;
|
|
94
|
+
contentText?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface ScxmlDataJSON {
|
|
97
|
+
id: string;
|
|
98
|
+
expr?: string;
|
|
99
|
+
content?: string;
|
|
100
|
+
src?: string;
|
|
101
|
+
xml?: ScxmlXmlJSON;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Isolated executable-content block. Errors in nested actions stop this block
|
|
105
|
+
* but do not propagate to the surrounding action list. Used to model SCXML's
|
|
106
|
+
* separate <onentry>/<onexit> blocks: each is its own block per spec.
|
|
107
|
+
*/
|
|
108
|
+
interface ScxmlBlockJSON {
|
|
109
|
+
type: 'scxml.block';
|
|
110
|
+
actions: ActionJSON[];
|
|
111
|
+
}
|
|
112
|
+
interface ScxmlDatamodelJSON {
|
|
113
|
+
type: 'scxml.datamodel';
|
|
114
|
+
data: ScxmlDataJSON[];
|
|
115
|
+
}
|
|
116
|
+
interface ScxmlForwardJSON {
|
|
117
|
+
type: 'scxml.forward';
|
|
118
|
+
invokeId: string;
|
|
119
|
+
}
|
|
120
|
+
interface ScxmlFinalizeJSON {
|
|
121
|
+
type: 'scxml.finalize';
|
|
122
|
+
invokeId: string;
|
|
123
|
+
actions: ActionJSON[];
|
|
124
|
+
}
|
|
125
|
+
interface ScxmlIfJSON {
|
|
126
|
+
type: 'scxml.if';
|
|
127
|
+
branches: Array<{
|
|
128
|
+
cond?: string;
|
|
129
|
+
actions: ActionJSON[];
|
|
130
|
+
}>;
|
|
131
|
+
}
|
|
132
|
+
interface CustomActionJSON {
|
|
133
|
+
type: string;
|
|
134
|
+
params?: unknown;
|
|
135
|
+
}
|
|
136
|
+
export type ActionJSON = CustomActionJSON | RaiseJSON | CancelJSON | LogJSON | EmitJSON | AssignJSON | ScxmlAssignJSON | ScxmlRaiseJSON | ScxmlScriptJSON | ScxmlIfJSON | ScxmlForeachJSON | ScxmlCancelJSON | ScxmlLogJSON | ScxmlBlockJSON | ScxmlDatamodelJSON | ScxmlForwardJSON | ScxmlFinalizeJSON | ExpressionJSON | CodeJSON;
|
|
137
|
+
export interface GuardJSON {
|
|
138
|
+
type: string;
|
|
139
|
+
params?: unknown;
|
|
140
|
+
}
|
|
141
|
+
interface ExpressionJSON {
|
|
142
|
+
'@expr': string;
|
|
143
|
+
'@lang'?: string;
|
|
144
|
+
}
|
|
145
|
+
interface CodeJSON {
|
|
146
|
+
'@code': string;
|
|
147
|
+
'@lang'?: string;
|
|
148
|
+
}
|
|
149
|
+
type ResolvableJSON = ExpressionJSON | CodeJSON;
|
|
150
|
+
type ConditionJSON = GuardJSON | ResolvableJSON;
|
|
151
|
+
interface ChoiceBranchJSON {
|
|
152
|
+
when?: ConditionJSON;
|
|
153
|
+
target: string | string[];
|
|
154
|
+
context?: MachineContext;
|
|
155
|
+
input?: unknown;
|
|
156
|
+
description?: string;
|
|
157
|
+
reenter?: boolean;
|
|
158
|
+
meta?: MetaObject;
|
|
159
|
+
}
|
|
160
|
+
export interface InvokeJSON {
|
|
161
|
+
id?: string;
|
|
162
|
+
registryKey?: string;
|
|
163
|
+
src: string;
|
|
164
|
+
input?: unknown;
|
|
165
|
+
onDone?: TransitionConfigJSON | TransitionConfigJSON[];
|
|
166
|
+
onError?: TransitionConfigJSON | TransitionConfigJSON[];
|
|
167
|
+
onSnapshot?: TransitionConfigJSON | TransitionConfigJSON[];
|
|
168
|
+
timeout?: number | string | ResolvableJSON;
|
|
169
|
+
onTimeout?: TransitionConfigJSON | TransitionConfigJSON[];
|
|
170
|
+
}
|
|
171
|
+
export interface TransitionJSON {
|
|
172
|
+
target?: string | string[];
|
|
173
|
+
matches?: Record<string, unknown>;
|
|
174
|
+
context?: MachineContext;
|
|
175
|
+
actions?: ActionJSON[];
|
|
176
|
+
guard?: ConditionJSON;
|
|
177
|
+
description?: string;
|
|
178
|
+
reenter?: boolean;
|
|
179
|
+
meta?: MetaObject;
|
|
180
|
+
input?: unknown;
|
|
181
|
+
}
|
|
182
|
+
type TransitionConfigJSON = TransitionJSON | ResolvableJSON;
|
|
183
|
+
export interface StateNodeJSON {
|
|
184
|
+
id?: string;
|
|
185
|
+
key?: string;
|
|
186
|
+
type?: 'atomic' | 'compound' | 'parallel' | 'final' | 'history' | 'choice';
|
|
187
|
+
initial?: string;
|
|
188
|
+
states?: Record<string, StateNodeJSON>;
|
|
189
|
+
on?: Record<string, TransitionConfigJSON | TransitionConfigJSON[]>;
|
|
190
|
+
onError?: TransitionConfigJSON | TransitionConfigJSON[];
|
|
191
|
+
after?: Record<string, TransitionConfigJSON | TransitionConfigJSON[]>;
|
|
192
|
+
always?: TransitionConfigJSON | TransitionConfigJSON[];
|
|
193
|
+
choice?: ChoiceBranchJSON[] | ResolvableJSON;
|
|
194
|
+
/**
|
|
195
|
+
* JSON route config. Unlike the authoring API (a function), the JSON layer
|
|
196
|
+
* allows an object form whose `guard` may be a named guard reference (string)
|
|
197
|
+
* resolved against the machine's `guards` sources.
|
|
198
|
+
*/
|
|
199
|
+
route?: {
|
|
200
|
+
description?: string;
|
|
201
|
+
reenter?: boolean;
|
|
202
|
+
meta?: MetaObject;
|
|
203
|
+
guard?: string;
|
|
204
|
+
input?: Record<string, unknown>;
|
|
205
|
+
} | ResolvableJSON;
|
|
206
|
+
invoke?: InvokeJSON | InvokeJSON[];
|
|
207
|
+
entry?: ActionJSON | ActionJSON[];
|
|
208
|
+
exit?: ActionJSON | ActionJSON[];
|
|
209
|
+
meta?: MetaObject;
|
|
210
|
+
description?: string;
|
|
211
|
+
tags?: string[];
|
|
212
|
+
input?: unknown;
|
|
213
|
+
timeout?: number | string | ResolvableJSON;
|
|
214
|
+
onTimeout?: TransitionConfigJSON | TransitionConfigJSON[];
|
|
215
|
+
history?: 'shallow' | 'deep';
|
|
216
|
+
target?: string | [string, ...string[]];
|
|
217
|
+
output?: unknown;
|
|
218
|
+
context?: Record<string, unknown>;
|
|
219
|
+
_scxmlDonedata?: ScxmlDonedataJSON;
|
|
220
|
+
}
|
|
221
|
+
export interface ScxmlIR extends StateNodeJSON {
|
|
222
|
+
'@exprLang'?: string;
|
|
223
|
+
version?: string;
|
|
224
|
+
actions?: Record<string, ActionJSON | ActionJSON[]>;
|
|
225
|
+
guards?: Record<string, {
|
|
226
|
+
when: ConditionJSON;
|
|
227
|
+
}>;
|
|
228
|
+
actors?: Record<string, unknown>;
|
|
229
|
+
delays?: Record<string, number | string | {
|
|
230
|
+
duration: number | string | ResolvableJSON;
|
|
231
|
+
}>;
|
|
232
|
+
schemas?: Record<string, unknown>;
|
|
233
|
+
}
|
|
234
|
+
type EvaluatorSlot = 'context' | 'guard' | 'choice' | 'action' | 'actionParams' | 'transition' | 'input' | 'output' | 'delay' | 'transitionContext' | 'unknown';
|
|
235
|
+
type EvaluatorKind = 'expr' | 'code';
|
|
236
|
+
interface EvaluatorArgs {
|
|
237
|
+
source: string;
|
|
238
|
+
kind: EvaluatorKind;
|
|
239
|
+
slot: EvaluatorSlot;
|
|
240
|
+
scope: Record<string, unknown>;
|
|
241
|
+
path: string;
|
|
242
|
+
}
|
|
243
|
+
interface MachineSources {
|
|
244
|
+
actions?: Record<string, (...args: any[]) => unknown>;
|
|
245
|
+
guards?: Record<string, (...args: any[]) => boolean>;
|
|
246
|
+
actors?: Record<string, AnyActorLogic>;
|
|
247
|
+
delays?: Record<string, number | ((...args: any[]) => number)>;
|
|
248
|
+
evaluators?: Record<string, (args: EvaluatorArgs) => unknown>;
|
|
249
|
+
}
|
|
250
|
+
export declare function createMachineFromSCXMLConfig(json: ScxmlIR, sources?: MachineSources): AnyStateMachine;
|
|
251
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ScxmlIR } from "./runtime.js";
|
|
2
|
+
import { AnyStateMachine } from "../types.js";
|
|
3
|
+
export declare function sanitizeStateId(id: string): string;
|
|
4
|
+
export interface SCXMLConversionOptions {
|
|
5
|
+
resolveResource?: (src: string, kind: 'data' | 'script' | 'invoke') => string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Converts an SCXML string to a JSON representation that can be used with
|
|
9
|
+
* the SCXML runtime compiler.
|
|
10
|
+
*/
|
|
11
|
+
export declare function compileSCXML(xml: string, options?: SCXMLConversionOptions): ScxmlIR;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an XState machine from an SCXML document.
|
|
14
|
+
*
|
|
15
|
+
* Expressions and external resources are evaluated using SCXML semantics.
|
|
16
|
+
* Only create machines from trusted SCXML because ECMAScript expressions and
|
|
17
|
+
* script elements execute JavaScript in the current environment.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createMachineFromSCXML(xml: string, options?: SCXMLConversionOptions): AnyStateMachine;
|
|
@@ -495,6 +495,7 @@ export type InitialTransitionDefinition = {
|
|
|
495
495
|
context: MachineContext;
|
|
496
496
|
event: EventObject;
|
|
497
497
|
}) => Record<string, unknown>);
|
|
498
|
+
to?: ((...args: any[]) => any) | undefined;
|
|
498
499
|
};
|
|
499
500
|
export type TransitionDefinitionMap<TContext extends MachineContext, TEvent extends EventObject> = {
|
|
500
501
|
[K in EventDescriptor<TEvent>]: Array<TransitionDefinition<TContext, ExtractEvent<TEvent, K>>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a5 as createInertActorScope, a6 as setInertActorScopeSnapshot, E as finalizeTransitionResult, a8 as attachSnapshotActorRef, y as createInitEvent, aw as hasAmbientInspector, a7 as beginSpawnAllocation, a9 as macrostep, al as createSpawnEffect, am as initialMicrostep, i as isAtomicStateNode, ax as getProperAncestors, ay as isRemoteActorRef, az as getActorIdPrefix } from './createActor-268165d4.esm.js';
|
|
2
2
|
|
|
3
3
|
function attachMicrostepActorRefs(microsteps, actorScope, inputSnapshot) {
|
|
4
4
|
if (!microsteps.length) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a5 as createInertActorScope, a6 as setInertActorScopeSnapshot, E as finalizeTransitionResult, a8 as attachSnapshotActorRef, y as createInitEvent, aw as hasAmbientInspector, a7 as beginSpawnAllocation, a9 as macrostep, al as createSpawnEffect, am as initialMicrostep, i as isAtomicStateNode, ax as getProperAncestors, ay as isRemoteActorRef, az as getActorIdPrefix } from './createActor-88709f74.development.esm.js';
|
|
2
2
|
|
|
3
3
|
function attachMicrostepActorRefs(microsteps, actorScope, inputSnapshot) {
|
|
4
4
|
if (!microsteps.length) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var createActor = require('./createActor-
|
|
3
|
+
var createActor = require('./createActor-a1e0dffb.development.cjs.js');
|
|
4
4
|
|
|
5
5
|
function attachMicrostepActorRefs(microsteps, actorScope, inputSnapshot) {
|
|
6
6
|
if (!microsteps.length) {
|