xstate 5.19.3 → 5.20.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 +0 -1
- package/actions/dist/xstate-actions.cjs.d.ts +1 -1
- package/actions/dist/xstate-actions.cjs.js +9 -8
- package/actions/dist/xstate-actions.development.cjs.js +9 -8
- package/actions/dist/xstate-actions.development.esm.js +3 -2
- package/actions/dist/xstate-actions.esm.js +3 -2
- package/actions/dist/xstate-actions.umd.min.js +1 -1
- package/actions/dist/xstate-actions.umd.min.js.map +1 -1
- package/actors/dist/xstate-actors.cjs.d.ts +1 -1
- package/actors/dist/xstate-actors.cjs.js +1 -1
- package/actors/dist/xstate-actors.development.cjs.js +1 -1
- package/actors/dist/xstate-actors.development.esm.js +1 -1
- package/actors/dist/xstate-actors.esm.js +1 -1
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dev/dist/xstate-dev.cjs.d.ts +1 -1
- package/dev/dist/xstate-dev.umd.min.js.map +1 -1
- package/dist/StateMachine-1cda96d3.cjs.js +560 -0
- package/dist/StateMachine-38b5bb3f.development.cjs.js +566 -0
- package/dist/StateMachine-b4e94439.development.esm.js +563 -0
- package/dist/StateMachine-c88ea5dd.esm.js +557 -0
- package/dist/assign-6313ccb3.development.esm.js +133 -0
- package/dist/assign-c3259787.esm.js +127 -0
- package/dist/assign-c84786ab.development.cjs.js +135 -0
- package/dist/assign-e9c344ea.cjs.js +129 -0
- package/dist/declarations/src/StateMachine.d.ts +3 -4
- package/dist/declarations/src/graph/TestModel.d.ts +71 -0
- package/dist/declarations/src/graph/adjacency.d.ts +8 -0
- package/dist/declarations/src/graph/graph.d.ts +14 -0
- package/dist/declarations/src/graph/index.d.ts +9 -0
- package/dist/declarations/src/graph/pathFromEvents.d.ts +3 -0
- package/dist/declarations/src/graph/pathGenerators.d.ts +4 -0
- package/dist/declarations/src/graph/shortestPaths.d.ts +3 -0
- package/dist/declarations/src/graph/simplePaths.d.ts +3 -0
- package/dist/declarations/src/graph/types.d.ts +159 -0
- package/dist/declarations/src/types.d.ts +1 -1
- package/dist/{log-12aa30c9.esm.js → log-1c257a58.esm.js} +5 -126
- package/dist/{log-179b5431.cjs.js → log-215998b6.cjs.js} +5 -127
- package/dist/{log-210b28c2.development.cjs.js → log-2c8d7f98.development.cjs.js} +5 -133
- package/dist/{log-b47a3833.development.esm.js → log-ef959da6.development.esm.js} +5 -132
- package/dist/{raise-cbaedcda.cjs.js → raise-5872b9e8.cjs.js} +4 -2
- package/dist/{raise-527db318.development.esm.js → raise-78b8dcb8.development.esm.js} +5 -3
- package/dist/{raise-32fab6fb.development.cjs.js → raise-7a84f9f0.development.cjs.js} +4 -2
- package/dist/{raise-59f80ebb.esm.js → raise-b0a4e862.esm.js} +5 -3
- package/dist/xstate.cjs.d.ts +1 -1
- package/dist/xstate.cjs.js +8 -563
- package/dist/xstate.development.cjs.js +8 -569
- package/dist/xstate.development.esm.js +7 -568
- package/dist/xstate.esm.js +7 -562
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/graph/dist/xstate-graph.cjs.d.mts +2 -0
- package/graph/dist/xstate-graph.cjs.d.ts +2 -0
- package/graph/dist/xstate-graph.cjs.js +901 -0
- package/graph/dist/xstate-graph.cjs.mjs +15 -0
- package/graph/dist/xstate-graph.development.cjs.js +901 -0
- package/graph/dist/xstate-graph.development.cjs.mjs +15 -0
- package/graph/dist/xstate-graph.development.esm.js +885 -0
- package/graph/dist/xstate-graph.esm.js +885 -0
- package/graph/dist/xstate-graph.umd.min.js +2 -0
- package/graph/dist/xstate-graph.umd.min.js.map +1 -0
- package/graph/package.json +8 -0
- package/guards/dist/xstate-guards.cjs.d.ts +1 -1
- package/guards/dist/xstate-guards.cjs.js +1 -1
- package/guards/dist/xstate-guards.development.cjs.js +1 -1
- package/guards/dist/xstate-guards.development.esm.js +1 -1
- package/guards/dist/xstate-guards.esm.js +1 -1
- package/guards/dist/xstate-guards.umd.min.js +1 -1
- package/guards/dist/xstate-guards.umd.min.js.map +1 -1
- package/package.json +22 -6
|
@@ -1,134 +1,5 @@
|
|
|
1
|
-
import { T as
|
|
2
|
-
|
|
3
|
-
function createSpawner(actorScope, {
|
|
4
|
-
machine,
|
|
5
|
-
context
|
|
6
|
-
}, event, spawnedChildren) {
|
|
7
|
-
const spawn = (src, options) => {
|
|
8
|
-
if (typeof src === 'string') {
|
|
9
|
-
const logic = resolveReferencedActor(machine, src);
|
|
10
|
-
if (!logic) {
|
|
11
|
-
throw new Error(`Actor logic '${src}' not implemented in machine '${machine.id}'`);
|
|
12
|
-
}
|
|
13
|
-
const actorRef = createActor(logic, {
|
|
14
|
-
id: options?.id,
|
|
15
|
-
parent: actorScope.self,
|
|
16
|
-
syncSnapshot: options?.syncSnapshot,
|
|
17
|
-
input: typeof options?.input === 'function' ? options.input({
|
|
18
|
-
context,
|
|
19
|
-
event,
|
|
20
|
-
self: actorScope.self
|
|
21
|
-
}) : options?.input,
|
|
22
|
-
src,
|
|
23
|
-
systemId: options?.systemId
|
|
24
|
-
});
|
|
25
|
-
spawnedChildren[actorRef.id] = actorRef;
|
|
26
|
-
return actorRef;
|
|
27
|
-
} else {
|
|
28
|
-
const actorRef = createActor(src, {
|
|
29
|
-
id: options?.id,
|
|
30
|
-
parent: actorScope.self,
|
|
31
|
-
syncSnapshot: options?.syncSnapshot,
|
|
32
|
-
input: options?.input,
|
|
33
|
-
src,
|
|
34
|
-
systemId: options?.systemId
|
|
35
|
-
});
|
|
36
|
-
return actorRef;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
return (src, options) => {
|
|
40
|
-
const actorRef = spawn(src, options); // TODO: fix types
|
|
41
|
-
spawnedChildren[actorRef.id] = actorRef;
|
|
42
|
-
actorScope.defer(() => {
|
|
43
|
-
if (actorRef._processingStatus === ProcessingStatus.Stopped) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
actorRef.start();
|
|
47
|
-
});
|
|
48
|
-
return actorRef;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
|
|
53
|
-
assignment
|
|
54
|
-
}) {
|
|
55
|
-
if (!snapshot.context) {
|
|
56
|
-
throw new Error('Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.');
|
|
57
|
-
}
|
|
58
|
-
const spawnedChildren = {};
|
|
59
|
-
const assignArgs = {
|
|
60
|
-
context: snapshot.context,
|
|
61
|
-
event: actionArgs.event,
|
|
62
|
-
spawn: createSpawner(actorScope, snapshot, actionArgs.event, spawnedChildren),
|
|
63
|
-
self: actorScope.self,
|
|
64
|
-
system: actorScope.system
|
|
65
|
-
};
|
|
66
|
-
let partialUpdate = {};
|
|
67
|
-
if (typeof assignment === 'function') {
|
|
68
|
-
partialUpdate = assignment(assignArgs, actionParams);
|
|
69
|
-
} else {
|
|
70
|
-
for (const key of Object.keys(assignment)) {
|
|
71
|
-
const propAssignment = assignment[key];
|
|
72
|
-
partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs, actionParams) : propAssignment;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const updatedContext = Object.assign({}, snapshot.context, partialUpdate);
|
|
76
|
-
return [cloneMachineSnapshot(snapshot, {
|
|
77
|
-
context: updatedContext,
|
|
78
|
-
children: Object.keys(spawnedChildren).length ? {
|
|
79
|
-
...snapshot.children,
|
|
80
|
-
...spawnedChildren
|
|
81
|
-
} : snapshot.children
|
|
82
|
-
}), undefined, undefined];
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Updates the current context of the machine.
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
*
|
|
89
|
-
* ```ts
|
|
90
|
-
* import { createMachine, assign } from 'xstate';
|
|
91
|
-
*
|
|
92
|
-
* const countMachine = createMachine({
|
|
93
|
-
* context: {
|
|
94
|
-
* count: 0,
|
|
95
|
-
* message: ''
|
|
96
|
-
* },
|
|
97
|
-
* on: {
|
|
98
|
-
* inc: {
|
|
99
|
-
* actions: assign({
|
|
100
|
-
* count: ({ context }) => context.count + 1
|
|
101
|
-
* })
|
|
102
|
-
* },
|
|
103
|
-
* updateMessage: {
|
|
104
|
-
* actions: assign(({ context, event }) => {
|
|
105
|
-
* return {
|
|
106
|
-
* message: event.message.trim()
|
|
107
|
-
* };
|
|
108
|
-
* })
|
|
109
|
-
* }
|
|
110
|
-
* }
|
|
111
|
-
* });
|
|
112
|
-
* ```
|
|
113
|
-
*
|
|
114
|
-
* @param assignment An object that represents the partial context to update, or
|
|
115
|
-
* a function that returns an object that represents the partial context to
|
|
116
|
-
* update.
|
|
117
|
-
*/
|
|
118
|
-
function assign(assignment) {
|
|
119
|
-
if (executingCustomAction) {
|
|
120
|
-
console.warn('Custom actions should not call `assign()` directly, as it is not imperative. See https://stately.ai/docs/actions#built-in-actions for more details.');
|
|
121
|
-
}
|
|
122
|
-
function assign(_args, _params) {
|
|
123
|
-
{
|
|
124
|
-
throw new Error(`This isn't supposed to be called`);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
assign.type = 'xstate.assign';
|
|
128
|
-
assign.assignment = assignment;
|
|
129
|
-
assign.resolve = resolveAssign;
|
|
130
|
-
return assign;
|
|
131
|
-
}
|
|
1
|
+
import { T as executingCustomAction, U as XSTATE_ERROR, V as createErrorActorEvent, w as evaluateGuard, f as cancel, r as raise, h as spawnChild, k as stopChild } from './raise-78b8dcb8.development.esm.js';
|
|
2
|
+
import { a as assign } from './assign-6313ccb3.development.esm.js';
|
|
132
3
|
|
|
133
4
|
function resolveEmit(_, snapshot, args, actionParams, {
|
|
134
5
|
event: eventOrExpr
|
|
@@ -196,6 +67,8 @@ eventOrExpr) {
|
|
|
196
67
|
return emit;
|
|
197
68
|
}
|
|
198
69
|
|
|
70
|
+
// this is needed to make JSDoc `@link` work properly
|
|
71
|
+
|
|
199
72
|
/**
|
|
200
73
|
* @remarks
|
|
201
74
|
* `T | unknown` reduces to `unknown` and that can be problematic when it comes
|
|
@@ -533,4 +406,4 @@ function log(value = ({
|
|
|
533
406
|
return log;
|
|
534
407
|
}
|
|
535
408
|
|
|
536
|
-
export { SpecialTargets as S,
|
|
409
|
+
export { SpecialTargets as S, enqueueActions as a, sendTo as b, emit as e, forwardTo as f, log as l, sendParent as s };
|
|
@@ -15,7 +15,7 @@ class Mailbox {
|
|
|
15
15
|
}
|
|
16
16
|
clear() {
|
|
17
17
|
// we can't set _current to null because we might be currently processing
|
|
18
|
-
// and enqueue following clear
|
|
18
|
+
// and enqueue following clear shouldn't start processing the enqueued item immediately
|
|
19
19
|
if (this._current) {
|
|
20
20
|
this._current.next = null;
|
|
21
21
|
this._last = this._current;
|
|
@@ -421,6 +421,8 @@ function createSystem(rootActor, options) {
|
|
|
421
421
|
return system;
|
|
422
422
|
}
|
|
423
423
|
|
|
424
|
+
// those are needed to make JSDoc `@link` work properly
|
|
425
|
+
|
|
424
426
|
let executingCustomAction = false;
|
|
425
427
|
const $$ACTOR_TYPE = 1;
|
|
426
428
|
|
|
@@ -2363,7 +2365,7 @@ function macrostep(snapshot, event, actorScope, internalQueue) {
|
|
|
2363
2365
|
const transitions = selectTransitions(currentEvent, nextSnapshot);
|
|
2364
2366
|
if (isErr && !transitions.length) {
|
|
2365
2367
|
// TODO: we should likely only allow transitions selected by very explicit descriptors
|
|
2366
|
-
// `*` shouldn't be matched, likely `xstate.error.*`
|
|
2368
|
+
// `*` shouldn't be matched, likely `xstate.error.*` shouldn't be either
|
|
2367
2369
|
// similarly `xstate.error.actor.*` and `xstate.error.actor.todo.*` have to be considered too
|
|
2368
2370
|
nextSnapshot = cloneMachineSnapshot(snapshot, {
|
|
2369
2371
|
status: 'error',
|
|
@@ -13,7 +13,7 @@ class Mailbox {
|
|
|
13
13
|
}
|
|
14
14
|
clear() {
|
|
15
15
|
// we can't set _current to null because we might be currently processing
|
|
16
|
-
// and enqueue following clear
|
|
16
|
+
// and enqueue following clear shouldn't start processing the enqueued item immediately
|
|
17
17
|
if (this._current) {
|
|
18
18
|
this._current.next = null;
|
|
19
19
|
this._last = this._current;
|
|
@@ -422,6 +422,8 @@ function createSystem(rootActor, options) {
|
|
|
422
422
|
return system;
|
|
423
423
|
}
|
|
424
424
|
|
|
425
|
+
// those are needed to make JSDoc `@link` work properly
|
|
426
|
+
|
|
425
427
|
let executingCustomAction = false;
|
|
426
428
|
const $$ACTOR_TYPE = 1;
|
|
427
429
|
|
|
@@ -2411,7 +2413,7 @@ function macrostep(snapshot, event, actorScope, internalQueue) {
|
|
|
2411
2413
|
const transitions = selectTransitions(currentEvent, nextSnapshot);
|
|
2412
2414
|
if (isErr && !transitions.length) {
|
|
2413
2415
|
// TODO: we should likely only allow transitions selected by very explicit descriptors
|
|
2414
|
-
// `*` shouldn't be matched, likely `xstate.error.*`
|
|
2416
|
+
// `*` shouldn't be matched, likely `xstate.error.*` shouldn't be either
|
|
2415
2417
|
// similarly `xstate.error.actor.*` and `xstate.error.actor.todo.*` have to be considered too
|
|
2416
2418
|
nextSnapshot = cloneMachineSnapshot(snapshot, {
|
|
2417
2419
|
status: 'error',
|
|
@@ -2703,4 +2705,4 @@ function raise(eventOrExpr, options) {
|
|
|
2703
2705
|
return raise;
|
|
2704
2706
|
}
|
|
2705
2707
|
|
|
2706
|
-
export { $$ACTOR_TYPE as $,
|
|
2708
|
+
export { $$ACTOR_TYPE as $, Actor as A, getCandidates as B, resolveStateValue as C, getAllStateNodes as D, createMachineSnapshot as E, isInFinalState as F, macrostep as G, transitionNode as H, resolveActionsAndContext as I, createInitEvent as J, microstep as K, getInitialStateNodes as L, toStatePath as M, NULL_EVENT as N, isStateId as O, getStateNodeByPath as P, getPersistedSnapshot as Q, resolveReferencedActor as R, STATE_DELIMITER as S, executingCustomAction as T, XSTATE_ERROR as U, createErrorActorEvent as V, ProcessingStatus as W, XSTATE_STOP as X, cloneMachineSnapshot as Y, and as a, isMachineSnapshot as b, createActor as c, getAllOwnEventDescriptors as d, toObserver as e, cancel as f, getStateNodes as g, spawnChild as h, interpret as i, stop as j, stopChild as k, mapValues as l, matchesState as m, not as n, or as o, pathToStateValue as p, formatTransitions as q, raise as r, stateIn as s, toArray as t, toTransitionConfigArray as u, formatTransition as v, evaluateGuard as w, createInvokeId as x, getDelayedTransitions as y, formatInitialTransition as z };
|
|
@@ -15,7 +15,7 @@ class Mailbox {
|
|
|
15
15
|
}
|
|
16
16
|
clear() {
|
|
17
17
|
// we can't set _current to null because we might be currently processing
|
|
18
|
-
// and enqueue following clear
|
|
18
|
+
// and enqueue following clear shouldn't start processing the enqueued item immediately
|
|
19
19
|
if (this._current) {
|
|
20
20
|
this._current.next = null;
|
|
21
21
|
this._last = this._current;
|
|
@@ -424,6 +424,8 @@ function createSystem(rootActor, options) {
|
|
|
424
424
|
return system;
|
|
425
425
|
}
|
|
426
426
|
|
|
427
|
+
// those are needed to make JSDoc `@link` work properly
|
|
428
|
+
|
|
427
429
|
exports.executingCustomAction = false;
|
|
428
430
|
const $$ACTOR_TYPE = 1;
|
|
429
431
|
|
|
@@ -2413,7 +2415,7 @@ function macrostep(snapshot, event, actorScope, internalQueue) {
|
|
|
2413
2415
|
const transitions = selectTransitions(currentEvent, nextSnapshot);
|
|
2414
2416
|
if (isErr && !transitions.length) {
|
|
2415
2417
|
// TODO: we should likely only allow transitions selected by very explicit descriptors
|
|
2416
|
-
// `*` shouldn't be matched, likely `xstate.error.*`
|
|
2418
|
+
// `*` shouldn't be matched, likely `xstate.error.*` shouldn't be either
|
|
2417
2419
|
// similarly `xstate.error.actor.*` and `xstate.error.actor.todo.*` have to be considered too
|
|
2418
2420
|
nextSnapshot = cloneMachineSnapshot(snapshot, {
|
|
2419
2421
|
status: 'error',
|
|
@@ -13,7 +13,7 @@ class Mailbox {
|
|
|
13
13
|
}
|
|
14
14
|
clear() {
|
|
15
15
|
// we can't set _current to null because we might be currently processing
|
|
16
|
-
// and enqueue following clear
|
|
16
|
+
// and enqueue following clear shouldn't start processing the enqueued item immediately
|
|
17
17
|
if (this._current) {
|
|
18
18
|
this._current.next = null;
|
|
19
19
|
this._last = this._current;
|
|
@@ -419,6 +419,8 @@ function createSystem(rootActor, options) {
|
|
|
419
419
|
return system;
|
|
420
420
|
}
|
|
421
421
|
|
|
422
|
+
// those are needed to make JSDoc `@link` work properly
|
|
423
|
+
|
|
422
424
|
let executingCustomAction = false;
|
|
423
425
|
const $$ACTOR_TYPE = 1;
|
|
424
426
|
|
|
@@ -2361,7 +2363,7 @@ function macrostep(snapshot, event, actorScope, internalQueue) {
|
|
|
2361
2363
|
const transitions = selectTransitions(currentEvent, nextSnapshot);
|
|
2362
2364
|
if (isErr && !transitions.length) {
|
|
2363
2365
|
// TODO: we should likely only allow transitions selected by very explicit descriptors
|
|
2364
|
-
// `*` shouldn't be matched, likely `xstate.error.*`
|
|
2366
|
+
// `*` shouldn't be matched, likely `xstate.error.*` shouldn't be either
|
|
2365
2367
|
// similarly `xstate.error.actor.*` and `xstate.error.actor.todo.*` have to be considered too
|
|
2366
2368
|
nextSnapshot = cloneMachineSnapshot(snapshot, {
|
|
2367
2369
|
status: 'error',
|
|
@@ -2641,4 +2643,4 @@ function raise(eventOrExpr, options) {
|
|
|
2641
2643
|
return raise;
|
|
2642
2644
|
}
|
|
2643
2645
|
|
|
2644
|
-
export { $$ACTOR_TYPE as $,
|
|
2646
|
+
export { $$ACTOR_TYPE as $, Actor as A, getCandidates as B, resolveStateValue as C, getAllStateNodes as D, createMachineSnapshot as E, isInFinalState as F, macrostep as G, transitionNode as H, resolveActionsAndContext as I, createInitEvent as J, microstep as K, getInitialStateNodes as L, toStatePath as M, NULL_EVENT as N, isStateId as O, getStateNodeByPath as P, getPersistedSnapshot as Q, resolveReferencedActor as R, STATE_DELIMITER as S, XSTATE_ERROR as T, createErrorActorEvent as U, ProcessingStatus as V, cloneMachineSnapshot as W, XSTATE_STOP as X, and as a, isMachineSnapshot as b, createActor as c, getAllOwnEventDescriptors as d, toObserver as e, cancel as f, getStateNodes as g, spawnChild as h, interpret as i, stop as j, stopChild as k, mapValues as l, matchesState as m, not as n, or as o, pathToStateValue as p, formatTransitions as q, raise as r, stateIn as s, toArray as t, toTransitionConfigArray as u, formatTransition as v, evaluateGuard as w, createInvokeId as x, getDelayedTransitions as y, formatInitialTransition as z };
|
package/dist/xstate.cjs.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./declarations/src/index";
|
|
1
|
+
export * from "./declarations/src/index.js";
|
|
2
2
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoieHN0YXRlLmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi9kZWNsYXJhdGlvbnMvc3JjL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
|