xstate 6.0.0-alpha.8 → 6.0.0-beta.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/README.md +223 -78
- package/bin/agent.js +347 -0
- package/bin/xstate.js +52 -0
- package/dist/createActor-25900f76.cjs.js +7015 -0
- package/dist/createActor-551369be.development.esm.js +7175 -0
- package/dist/createActor-a49ae0ce.development.cjs.js +7289 -0
- package/dist/createActor-cbe3abac.esm.js +6902 -0
- package/dist/declarations/src/SimulatedClock.d.ts +2 -1
- package/dist/declarations/src/State.d.ts +66 -5
- package/dist/declarations/src/StateMachine.d.ts +107 -32
- package/dist/declarations/src/StateNode.d.ts +21 -16
- package/dist/declarations/src/actions.d.ts +11 -6
- package/dist/declarations/src/actors/callback.d.ts +11 -2
- package/dist/declarations/src/actors/index.d.ts +6 -5
- package/dist/declarations/src/actors/listener.d.ts +8 -3
- package/dist/declarations/src/actors/logic.d.ts +42 -52
- package/dist/declarations/src/actors/observable.d.ts +15 -2
- package/dist/declarations/src/actors/promise.d.ts +90 -22
- package/dist/declarations/src/actors/subscription.d.ts +9 -3
- package/dist/declarations/src/assert.d.ts +1 -0
- package/dist/declarations/src/base.types.d.ts +102 -0
- package/dist/declarations/src/createActor.d.ts +101 -27
- package/dist/declarations/src/createMachine.d.ts +38 -17
- package/dist/declarations/src/delay.d.ts +8 -0
- package/dist/declarations/src/durable/index.d.ts +231 -0
- package/dist/declarations/src/effectDescriptor.d.ts +95 -0
- package/dist/declarations/src/eventTypes.d.ts +9 -0
- package/dist/declarations/src/fsm/index.d.ts +2 -0
- package/dist/declarations/src/fsm.d.ts +169 -0
- package/dist/declarations/src/graph/adjacency.d.ts +6 -3
- package/dist/declarations/src/graph/graph.d.ts +6 -3
- package/dist/declarations/src/graph/index.d.ts +2 -3
- package/dist/declarations/src/graph/pathFromEvents.d.ts +5 -2
- package/dist/declarations/src/graph/shortestPaths.d.ts +5 -3
- package/dist/declarations/src/graph/simplePaths.d.ts +5 -3
- package/dist/declarations/src/graph/types.d.ts +113 -59
- package/dist/declarations/src/hotSwap.d.ts +18 -0
- package/dist/declarations/src/index.d.ts +28 -19
- package/dist/declarations/src/inspection.d.ts +24 -1
- package/dist/declarations/src/machineFromJSON.d.ts +171 -0
- package/dist/declarations/src/machineSchemas.d.ts +27 -0
- package/dist/declarations/src/machineVersion.types.d.ts +53 -0
- package/dist/declarations/src/machineVersions.d.ts +103 -0
- package/dist/declarations/src/mapState.d.ts +2 -0
- package/dist/declarations/src/persist/index.d.ts +36 -0
- package/dist/declarations/src/persistedSnapshotValidation.d.ts +18 -0
- package/dist/declarations/src/runtimeHelpers.d.ts +43 -0
- package/dist/declarations/src/schema.types.d.ts +31 -4
- package/dist/declarations/src/serialize.d.ts +39 -28
- package/dist/declarations/src/setup.d.ts +1086 -147
- package/dist/declarations/src/spawn.d.ts +6 -4
- package/dist/declarations/src/stateUtils.d.ts +57 -14
- package/dist/declarations/src/system.d.ts +178 -17
- package/dist/declarations/src/systemTransition.d.ts +108 -0
- package/dist/declarations/src/toPromise.d.ts +1 -0
- package/dist/declarations/src/transition.d.ts +48 -10
- package/dist/declarations/src/transitionActions.d.ts +22 -4
- package/dist/declarations/src/typeUtils.d.ts +51 -0
- package/dist/declarations/src/types.d.ts +835 -318
- package/dist/declarations/src/types.v6.d.ts +547 -104
- package/dist/declarations/src/utils.d.ts +38 -8
- package/dist/declarations/src/validation/index.d.ts +49 -0
- package/dist/declarations/src/validation.types.d.ts +29 -0
- package/dist/declarations/src/waitFor.d.ts +1 -0
- package/dist/effectDescriptor-2fa27c54.cjs.js +351 -0
- package/dist/effectDescriptor-321a8ce9.development.esm.js +343 -0
- package/dist/effectDescriptor-d8b0f749.esm.js +343 -0
- package/dist/effectDescriptor-f73da4ec.development.cjs.js +351 -0
- package/dist/machineSchemas-45c21bc2.esm.js +1292 -0
- package/dist/machineSchemas-6d96bef4.development.cjs.js +1379 -0
- package/dist/machineSchemas-88d01821.cjs.js +1300 -0
- package/dist/machineSchemas-b5736804.development.esm.js +1371 -0
- package/dist/schema.types-0ecd17b8.esm.js +71 -0
- package/dist/schema.types-15a68ddc.cjs.js +74 -0
- package/dist/schema.types-1c16f035.development.cjs.js +74 -0
- package/dist/schema.types-1cd4652e.development.esm.js +71 -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 +1068 -12
- package/dist/xstate-actors.cjs.mjs +2 -4
- package/dist/xstate-actors.development.cjs.js +1068 -12
- package/dist/xstate-actors.development.cjs.mjs +2 -4
- package/dist/xstate-actors.development.esm.js +1064 -1
- package/dist/xstate-actors.esm.js +1064 -1
- package/dist/xstate-actors.umd.min.js +1 -1
- package/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/xstate-durable.cjs.d.mts +2 -0
- package/dist/xstate-durable.cjs.d.ts +2 -0
- package/dist/xstate-durable.cjs.js +513 -0
- package/dist/xstate-durable.cjs.mjs +5 -0
- package/dist/xstate-durable.development.cjs.js +513 -0
- package/dist/xstate-durable.development.cjs.mjs +5 -0
- package/dist/xstate-durable.development.esm.js +507 -0
- package/dist/xstate-durable.esm.js +507 -0
- package/dist/xstate-durable.umd.min.js +2 -0
- package/dist/xstate-durable.umd.min.js.map +1 -0
- package/dist/xstate-fsm.cjs.d.mts +2 -0
- package/dist/xstate-fsm.cjs.d.ts +2 -0
- package/dist/xstate-fsm.cjs.js +111 -0
- package/dist/xstate-fsm.cjs.mjs +5 -0
- package/dist/xstate-fsm.development.cjs.js +111 -0
- package/dist/xstate-fsm.development.cjs.mjs +5 -0
- package/dist/xstate-fsm.development.esm.js +105 -0
- package/dist/xstate-fsm.esm.js +105 -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 +173 -457
- package/dist/xstate-graph.cjs.mjs +2 -5
- package/dist/xstate-graph.development.cjs.js +173 -457
- package/dist/xstate-graph.development.cjs.mjs +2 -5
- package/dist/xstate-graph.development.esm.js +171 -451
- package/dist/xstate-graph.esm.js +171 -451
- package/dist/xstate-graph.umd.min.js +1 -1
- package/dist/xstate-graph.umd.min.js.map +1 -1
- package/dist/xstate-persist.cjs.d.mts +2 -0
- package/dist/xstate-persist.cjs.d.ts +2 -0
- package/dist/xstate-persist.cjs.js +314 -0
- package/dist/xstate-persist.cjs.mjs +6 -0
- package/dist/xstate-persist.development.cjs.js +325 -0
- package/dist/xstate-persist.development.cjs.mjs +6 -0
- package/dist/xstate-persist.development.esm.js +319 -0
- package/dist/xstate-persist.esm.js +308 -0
- package/dist/xstate-persist.umd.min.js +2 -0
- package/dist/xstate-persist.umd.min.js.map +1 -0
- package/dist/xstate-validation.cjs.d.mts +2 -0
- package/dist/xstate-validation.cjs.d.ts +2 -0
- package/dist/xstate-validation.cjs.js +330 -0
- package/dist/xstate-validation.cjs.mjs +5 -0
- package/dist/xstate-validation.development.cjs.js +330 -0
- package/dist/xstate-validation.development.cjs.mjs +5 -0
- package/dist/xstate-validation.development.esm.js +324 -0
- package/dist/xstate-validation.esm.js +324 -0
- package/dist/xstate-validation.umd.min.js +2 -0
- package/dist/xstate-validation.umd.min.js.map +1 -0
- package/dist/xstate.cjs.js +2486 -1430
- package/dist/xstate.cjs.mjs +23 -13
- package/dist/xstate.development.cjs.js +2486 -1430
- package/dist/xstate.development.cjs.mjs +23 -13
- package/dist/xstate.development.esm.js +2445 -1398
- package/dist/xstate.esm.js +2445 -1398
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/docs/actions.md +75 -0
- package/docs/actor-logic.md +250 -0
- package/docs/actors.md +64 -0
- package/docs/agents.md +132 -0
- package/docs/api-stability.json +4287 -0
- package/docs/async-logic.md +75 -0
- package/docs/async-requests.md +157 -0
- package/docs/backend-workflows.md +124 -0
- package/docs/cancellation.md +42 -0
- package/docs/cheatsheet.md +563 -0
- package/docs/choice-states.md +109 -0
- package/docs/choose-xstate.md +47 -0
- package/docs/configuration.md +161 -0
- package/docs/context.md +67 -0
- package/docs/create-actor.md +159 -0
- package/docs/data-and-effects.md +48 -0
- package/docs/delays.md +81 -0
- package/docs/durable-execution.md +520 -0
- package/docs/emitted-events.md +146 -0
- package/docs/errors.md +812 -0
- package/docs/examples.md +75 -0
- package/docs/faq.md +60 -0
- package/docs/final-states.md +149 -0
- package/docs/forms-and-wizards.md +166 -0
- package/docs/frameworks.md +69 -0
- package/docs/fsm.md +164 -0
- package/docs/glossary.md +68 -0
- package/docs/guards.md +137 -0
- package/docs/history-states.md +161 -0
- package/docs/how-xstate-runs-machines.md +86 -0
- package/docs/index.md +74 -0
- package/docs/input-output.md +69 -0
- package/docs/inspect-actor-systems.md +118 -0
- package/docs/inspection.md +75 -0
- package/docs/internal-events.md +156 -0
- package/docs/invoke.md +371 -0
- package/docs/lifecycle-and-errors.md +48 -0
- package/docs/listen-and-subscribe.md +126 -0
- package/docs/model-based-testing.md +321 -0
- package/docs/modeling.md +40 -0
- package/docs/parallel-states.md +182 -0
- package/docs/persist-and-restore-actors.md +120 -0
- package/docs/persistence.md +312 -0
- package/docs/quick-start.md +55 -0
- package/docs/retries-and-timeouts.md +122 -0
- package/docs/route-states.md +104 -0
- package/docs/scxml.md +92 -0
- package/docs/selectors.md +99 -0
- package/docs/serialization.md +127 -0
- package/docs/setup-and-provide.md +273 -0
- package/docs/snapshots.md +134 -0
- package/docs/spawn.md +212 -0
- package/docs/state-input.md +162 -0
- package/docs/statecharts.md +54 -0
- package/docs/states-events-transitions.md +82 -0
- package/docs/states.md +168 -0
- package/docs/system-transitions.md +172 -0
- package/docs/systems.md +166 -0
- package/docs/testing.md +152 -0
- package/docs/timeouts.md +125 -0
- package/docs/transition-functions.md +89 -0
- package/docs/transitions.md +187 -0
- package/docs/troubleshooting.md +56 -0
- package/docs/tutorial.md +481 -0
- package/docs/typescript.md +213 -0
- package/docs/typestates.md +112 -0
- package/docs/utilities.md +39 -0
- package/docs/why-state-machines.md +59 -0
- package/docs/xstate-v5-to-v6.md +1923 -0
- package/docs/your-first-machine.md +79 -0
- package/durable/package.json +8 -0
- package/fsm/package.json +8 -0
- package/package.json +72 -10
- package/persist/package.json +8 -0
- package/validation/package.json +8 -0
- package/actions/package.json +0 -8
- package/dev/package.json +0 -8
- package/dist/StateMachine-0aa98f54.development.esm.js +0 -746
- package/dist/StateMachine-aef700df.cjs.js +0 -732
- package/dist/StateMachine-d4931336.esm.js +0 -729
- package/dist/StateMachine-da872dde.development.cjs.js +0 -749
- package/dist/declarations/src/createMachineFromConfig.d.ts +0 -177
- package/dist/declarations/src/getNextSnapshot.d.ts +0 -37
- package/dist/declarations/src/graph/TestModel.d.ts +0 -70
- package/dist/declarations/src/graph/pathGenerators.d.ts +0 -4
- package/dist/index-219cb621.development.cjs.js +0 -4476
- package/dist/index-2f2fbd9b.development.esm.js +0 -4421
- package/dist/index-559ceab3.cjs.js +0 -4437
- package/dist/index-8828376f.esm.js +0 -4382
- package/guards/package.json +0 -8
- package/invoke/package.json +0 -4
|
@@ -1,177 +0,0 @@
|
|
|
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
|
-
export interface LogJSON {
|
|
13
|
-
type: '@xstate.log';
|
|
14
|
-
args: any[];
|
|
15
|
-
}
|
|
16
|
-
interface EmitJSON {
|
|
17
|
-
type: '@xstate.emit';
|
|
18
|
-
event: AnyEventObject;
|
|
19
|
-
}
|
|
20
|
-
interface AssignJSON {
|
|
21
|
-
type: '@xstate.assign';
|
|
22
|
-
context: MachineContext;
|
|
23
|
-
}
|
|
24
|
-
interface ScxmlAssignJSON {
|
|
25
|
-
type: 'scxml.assign';
|
|
26
|
-
/** SCXML location attribute - the context property to assign to */
|
|
27
|
-
location: string;
|
|
28
|
-
/** SCXML expr attribute - expression to evaluate */
|
|
29
|
-
expr: string;
|
|
30
|
-
}
|
|
31
|
-
export interface ScxmlRaiseJSON {
|
|
32
|
-
type: 'scxml.raise';
|
|
33
|
-
/** Event type, or undefined if using eventexpr */
|
|
34
|
-
event?: string;
|
|
35
|
-
/** Expression to evaluate for event type */
|
|
36
|
-
eventexpr?: string;
|
|
37
|
-
/** Params with expressions to evaluate */
|
|
38
|
-
params?: Array<{
|
|
39
|
-
name: string;
|
|
40
|
-
expr: string;
|
|
41
|
-
}>;
|
|
42
|
-
id?: string;
|
|
43
|
-
delay?: number;
|
|
44
|
-
/** Expression for delay */
|
|
45
|
-
delayexpr?: string;
|
|
46
|
-
/** Static target (e.g. '#_parent') */
|
|
47
|
-
target?: string;
|
|
48
|
-
/** Expression for target */
|
|
49
|
-
targetexpr?: string;
|
|
50
|
-
}
|
|
51
|
-
interface ScxmlScriptJSON {
|
|
52
|
-
type: 'scxml.script';
|
|
53
|
-
/** The script code to execute */
|
|
54
|
-
code: string;
|
|
55
|
-
}
|
|
56
|
-
export interface ScxmlForeachJSON {
|
|
57
|
-
type: 'scxml.foreach';
|
|
58
|
-
array: string;
|
|
59
|
-
item: string;
|
|
60
|
-
index?: string;
|
|
61
|
-
actions: ActionJSON[];
|
|
62
|
-
}
|
|
63
|
-
export interface ScxmlCancelJSON {
|
|
64
|
-
type: 'scxml.cancel';
|
|
65
|
-
sendidexpr: string;
|
|
66
|
-
}
|
|
67
|
-
export interface ScxmlDonedataJSON {
|
|
68
|
-
params?: Array<{
|
|
69
|
-
name: string;
|
|
70
|
-
expr: string;
|
|
71
|
-
}>;
|
|
72
|
-
contentExpr?: string;
|
|
73
|
-
contentText?: string;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Isolated executable-content block. Errors in nested actions stop this block
|
|
77
|
-
* but do not propagate to the surrounding action list. Used to model SCXML's
|
|
78
|
-
* separate <onentry>/<onexit> blocks: each is its own block per spec.
|
|
79
|
-
*/
|
|
80
|
-
interface ScxmlBlockJSON {
|
|
81
|
-
type: 'scxml.block';
|
|
82
|
-
actions: ActionJSON[];
|
|
83
|
-
}
|
|
84
|
-
interface ScxmlIfJSON {
|
|
85
|
-
type: 'scxml.if';
|
|
86
|
-
branches: Array<{
|
|
87
|
-
cond?: string;
|
|
88
|
-
actions: ActionJSON[];
|
|
89
|
-
}>;
|
|
90
|
-
}
|
|
91
|
-
interface CustomActionJSON {
|
|
92
|
-
type: string;
|
|
93
|
-
params?: Record<string, unknown>;
|
|
94
|
-
}
|
|
95
|
-
export type ActionJSON = CustomActionJSON | RaiseJSON | CancelJSON | LogJSON | EmitJSON | AssignJSON | ScxmlAssignJSON | ScxmlRaiseJSON | ScxmlScriptJSON | ScxmlIfJSON | ScxmlForeachJSON | ScxmlCancelJSON | ScxmlBlockJSON;
|
|
96
|
-
export interface GuardJSON {
|
|
97
|
-
type: string;
|
|
98
|
-
params?: Record<string, unknown>;
|
|
99
|
-
}
|
|
100
|
-
export interface InvokeJSON {
|
|
101
|
-
id?: string;
|
|
102
|
-
registryKey?: string;
|
|
103
|
-
src: string | UnserializableMarker;
|
|
104
|
-
input?: unknown;
|
|
105
|
-
onDone?: TransitionJSON | TransitionJSON[];
|
|
106
|
-
onError?: TransitionJSON | TransitionJSON[];
|
|
107
|
-
onSnapshot?: TransitionJSON | TransitionJSON[];
|
|
108
|
-
timeout?: number | string;
|
|
109
|
-
onTimeout?: TransitionJSON | TransitionJSON[];
|
|
110
|
-
}
|
|
111
|
-
export interface TransitionJSON {
|
|
112
|
-
target?: string | string[];
|
|
113
|
-
context?: MachineContext;
|
|
114
|
-
actions?: ActionJSON[];
|
|
115
|
-
guard?: GuardJSON;
|
|
116
|
-
description?: string;
|
|
117
|
-
reenter?: boolean;
|
|
118
|
-
meta?: MetaObject;
|
|
119
|
-
input?: unknown;
|
|
120
|
-
}
|
|
121
|
-
export interface StateNodeJSON {
|
|
122
|
-
id?: string;
|
|
123
|
-
key?: string;
|
|
124
|
-
type?: 'atomic' | 'compound' | 'parallel' | 'final' | 'history' | 'choice';
|
|
125
|
-
initial?: string;
|
|
126
|
-
states?: Record<string, StateNodeJSON>;
|
|
127
|
-
on?: Record<string, TransitionJSON | TransitionJSON[]>;
|
|
128
|
-
after?: Record<string, TransitionJSON | TransitionJSON[]>;
|
|
129
|
-
always?: TransitionJSON | TransitionJSON[];
|
|
130
|
-
choice?: TransitionJSON;
|
|
131
|
-
/**
|
|
132
|
-
* JSON route config. Unlike the authoring API (a function), the JSON layer
|
|
133
|
-
* allows an object form whose `guard` may be a named guard reference (string)
|
|
134
|
-
* resolved against the machine's `guards` implementations.
|
|
135
|
-
*/
|
|
136
|
-
route?: {
|
|
137
|
-
description?: string;
|
|
138
|
-
reenter?: boolean;
|
|
139
|
-
meta?: MetaObject;
|
|
140
|
-
guard?: string;
|
|
141
|
-
input?: Record<string, unknown>;
|
|
142
|
-
};
|
|
143
|
-
invoke?: InvokeJSON | InvokeJSON[];
|
|
144
|
-
entry?: ActionJSON[];
|
|
145
|
-
exit?: ActionJSON[];
|
|
146
|
-
meta?: MetaObject;
|
|
147
|
-
description?: string;
|
|
148
|
-
tags?: string[];
|
|
149
|
-
input?: unknown;
|
|
150
|
-
timeout?: number | string;
|
|
151
|
-
onTimeout?: TransitionJSON | TransitionJSON[];
|
|
152
|
-
history?: 'shallow' | 'deep';
|
|
153
|
-
target?: string;
|
|
154
|
-
output?: unknown;
|
|
155
|
-
context?: Record<string, unknown>;
|
|
156
|
-
_scxmlDonedata?: ScxmlDonedataJSON;
|
|
157
|
-
}
|
|
158
|
-
export interface MachineJSON extends StateNodeJSON {
|
|
159
|
-
version?: string;
|
|
160
|
-
actions?: Record<string, unknown>;
|
|
161
|
-
guards?: Record<string, unknown>;
|
|
162
|
-
actorSources?: Record<string, unknown>;
|
|
163
|
-
delays?: Record<string, unknown>;
|
|
164
|
-
schemas?: Record<string, unknown>;
|
|
165
|
-
}
|
|
166
|
-
interface UnserializableMarker {
|
|
167
|
-
$unserializable: 'function' | 'actor' | 'schema' | 'value';
|
|
168
|
-
id?: string;
|
|
169
|
-
}
|
|
170
|
-
interface MachineImplementations {
|
|
171
|
-
actions?: Record<string, (...args: any[]) => unknown>;
|
|
172
|
-
guards?: Record<string, (...args: any[]) => boolean>;
|
|
173
|
-
actorSources?: Record<string, AnyActorLogic>;
|
|
174
|
-
delays?: Record<string, number | ((...args: any[]) => number)>;
|
|
175
|
-
}
|
|
176
|
-
export declare function createMachineFromConfig(json: MachineJSON, implementations?: MachineImplementations): AnyStateMachine;
|
|
177
|
-
export {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { AnyActorLogic, EventFromLogic, InputFrom, SnapshotFrom } from "./types.js";
|
|
2
|
-
/** @deprecated Use `initialTransition(…)` instead. */
|
|
3
|
-
export declare function getInitialSnapshot<T extends AnyActorLogic>(actorLogic: T, ...[input]: undefined extends InputFrom<T> ? [input?: InputFrom<T>] : [input: InputFrom<T>]): SnapshotFrom<T>;
|
|
4
|
-
/**
|
|
5
|
-
* Determines the next snapshot for the given `actorLogic` based on the given
|
|
6
|
-
* `snapshot` and `event`.
|
|
7
|
-
*
|
|
8
|
-
* If the `snapshot` is `undefined`, the initial snapshot of the `actorLogic` is
|
|
9
|
-
* used.
|
|
10
|
-
*
|
|
11
|
-
* @deprecated Use `transition(…)` instead.
|
|
12
|
-
* @example
|
|
13
|
-
*
|
|
14
|
-
* ```ts
|
|
15
|
-
* import { getNextSnapshot } from 'xstate';
|
|
16
|
-
* import { trafficLightMachine } from './trafficLightMachine.ts';
|
|
17
|
-
*
|
|
18
|
-
* const nextSnapshot = getNextSnapshot(
|
|
19
|
-
* trafficLightMachine, // actor logic
|
|
20
|
-
* undefined, // snapshot (or initial state if undefined)
|
|
21
|
-
* { type: 'TIMER' }
|
|
22
|
-
* ); // event object
|
|
23
|
-
*
|
|
24
|
-
* console.log(nextSnapshot.value);
|
|
25
|
-
* // => 'yellow'
|
|
26
|
-
*
|
|
27
|
-
* const nextSnapshot2 = getNextSnapshot(
|
|
28
|
-
* trafficLightMachine, // actor logic
|
|
29
|
-
* nextSnapshot, // snapshot
|
|
30
|
-
* { type: 'TIMER' }
|
|
31
|
-
* ); // event object
|
|
32
|
-
*
|
|
33
|
-
* console.log(nextSnapshot2.value);
|
|
34
|
-
* // =>'red'
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare function getNextSnapshot<T extends AnyActorLogic>(actorLogic: T, snapshot: SnapshotFrom<T>, event: EventFromLogic<T>): SnapshotFrom<T>;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { AdjacencyMap, StatePath, Step, TraversalOptions, PathGenerator, TestModelOptions, TestParam, TestPath, TestPathResult } from "./types.js";
|
|
2
|
-
import { EventObject, ActorLogic, Snapshot, AnyStateMachine, EventFromLogic, SnapshotFrom, InputFrom } from "../index.js";
|
|
3
|
-
type GetPathOptions<TSnapshot extends Snapshot<unknown>, TEvent extends EventObject, TInput> = Partial<TraversalOptions<TSnapshot, TEvent, TInput>> & {
|
|
4
|
-
/**
|
|
5
|
-
* Whether to allow deduplicate paths so that paths that are contained by
|
|
6
|
-
* longer paths are included.
|
|
7
|
-
*
|
|
8
|
-
* @default false
|
|
9
|
-
*/
|
|
10
|
-
allowDuplicatePaths?: boolean;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Creates a test model that represents an abstract model of a system under test
|
|
14
|
-
* (SUT).
|
|
15
|
-
*
|
|
16
|
-
* The test model is used to generate test paths, which are used to verify that
|
|
17
|
-
* states in the model are reachable in the SUT.
|
|
18
|
-
*/
|
|
19
|
-
export declare class TestModel<TSnapshot extends Snapshot<unknown>, TEvent extends EventObject, TInput> {
|
|
20
|
-
testLogic: ActorLogic<TSnapshot, TEvent, TInput>;
|
|
21
|
-
options: TestModelOptions<TSnapshot, TEvent, TInput>;
|
|
22
|
-
defaultTraversalOptions?: TraversalOptions<TSnapshot, TEvent, TInput>;
|
|
23
|
-
getDefaultOptions(): TestModelOptions<TSnapshot, TEvent, TInput>;
|
|
24
|
-
constructor(testLogic: ActorLogic<TSnapshot, TEvent, TInput>, options?: Partial<TestModelOptions<TSnapshot, TEvent, TInput>>);
|
|
25
|
-
getPaths(pathGenerator: PathGenerator<TSnapshot, TEvent, TInput>, options?: GetPathOptions<TSnapshot, TEvent, TInput>): Array<TestPath<TSnapshot, TEvent>>;
|
|
26
|
-
getShortestPaths(options?: GetPathOptions<TSnapshot, TEvent, TInput>): Array<TestPath<TSnapshot, TEvent>>;
|
|
27
|
-
getShortestPathsFrom(paths: Array<TestPath<TSnapshot, TEvent>>, options?: GetPathOptions<TSnapshot, TEvent, TInput>): Array<TestPath<TSnapshot, TEvent>>;
|
|
28
|
-
getSimplePaths(options?: GetPathOptions<TSnapshot, TEvent, TInput>): Array<TestPath<TSnapshot, TEvent>>;
|
|
29
|
-
getSimplePathsFrom(paths: Array<TestPath<TSnapshot, TEvent>>, options?: GetPathOptions<TSnapshot, TEvent, TInput>): Array<TestPath<TSnapshot, TEvent>>;
|
|
30
|
-
private _toTestPath;
|
|
31
|
-
getPathsFromEvents(events: TEvent[], options?: GetPathOptions<TSnapshot, TEvent, TInput>): Array<TestPath<TSnapshot, TEvent>>;
|
|
32
|
-
/**
|
|
33
|
-
* An array of adjacencies, which are objects that represent each `state` with
|
|
34
|
-
* the `nextState` given the `event`.
|
|
35
|
-
*/
|
|
36
|
-
getAdjacencyMap(): AdjacencyMap<TSnapshot, TEvent>;
|
|
37
|
-
testPath(path: StatePath<TSnapshot, TEvent>, params: TestParam<TSnapshot, TEvent>, options?: Partial<TestModelOptions<TSnapshot, TEvent, TInput>>): Promise<TestPathResult>;
|
|
38
|
-
testState(params: TestParam<TSnapshot, TEvent>, state: TSnapshot, options?: Partial<TestModelOptions<TSnapshot, TEvent, TInput>>): Promise<void>;
|
|
39
|
-
private _getStateTestKeys;
|
|
40
|
-
private _getEventExec;
|
|
41
|
-
testTransition(params: TestParam<TSnapshot, TEvent>, step: Step<TSnapshot, TEvent>): Promise<void>;
|
|
42
|
-
private _resolveOptions;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Creates a test model that represents an abstract model of a system under test
|
|
46
|
-
* (SUT).
|
|
47
|
-
*
|
|
48
|
-
* The test model is used to generate test paths, which are used to verify that
|
|
49
|
-
* states in the `machine` are reachable in the SUT.
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
*
|
|
53
|
-
* ```js
|
|
54
|
-
* const toggleModel = createModel(toggleMachine).withEvents({
|
|
55
|
-
* TOGGLE: {
|
|
56
|
-
* exec: async (page) => {
|
|
57
|
-
* await page.click('input');
|
|
58
|
-
* }
|
|
59
|
-
* }
|
|
60
|
-
* });
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* @param machine The state machine used to represent the abstract model.
|
|
64
|
-
* @param options Options for the created test model:
|
|
65
|
-
*
|
|
66
|
-
* - `events`: an object mapping string event types (e.g., `SUBMIT`) to an event
|
|
67
|
-
* test config (e.g., `{exec: () => {...}, cases: [...]}`)
|
|
68
|
-
*/
|
|
69
|
-
export declare function createTestModel<TMachine extends AnyStateMachine>(machine: TMachine, options?: Partial<TestModelOptions<SnapshotFrom<TMachine>, EventFromLogic<TMachine>, InputFrom<TMachine>>>): TestModel<SnapshotFrom<TMachine>, EventFromLogic<TMachine>, unknown>;
|
|
70
|
-
export {};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { EventObject, Snapshot } from "../index.js";
|
|
2
|
-
import { PathGenerator } from "./types.js";
|
|
3
|
-
export declare const createShortestPathsGen: <TSnapshot extends Snapshot<unknown>, TEvent extends EventObject, TInput>() => PathGenerator<TSnapshot, TEvent, TInput>;
|
|
4
|
-
export declare const createSimplePathsGen: <TSnapshot extends Snapshot<unknown>, TEvent extends EventObject, TInput>() => PathGenerator<TSnapshot, TEvent, TInput>;
|