xstate 5.0.0-beta.45 → 5.0.0-beta.47
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/actions/dist/xstate-actions.cjs.js +4 -3
- package/actions/dist/xstate-actions.cjs.mjs +3 -2
- package/actions/dist/xstate-actions.development.cjs.js +4 -3
- package/actions/dist/xstate-actions.development.cjs.mjs +3 -2
- package/actions/dist/xstate-actions.development.esm.js +2 -2
- package/actions/dist/xstate-actions.esm.js +2 -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.js +42 -5
- package/actors/dist/xstate-actors.development.cjs.js +42 -5
- package/actors/dist/xstate-actors.development.esm.js +42 -5
- package/actors/dist/xstate-actors.esm.js +42 -5
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/declarations/src/State.d.ts +16 -26
- package/dist/declarations/src/StateMachine.d.ts +11 -29
- package/dist/declarations/src/StateNode.d.ts +8 -6
- package/dist/declarations/src/actions/{spawn.d.ts → spawnChild.d.ts} +1 -1
- package/dist/declarations/src/actions/{stop.d.ts → stopChild.d.ts} +8 -2
- package/dist/declarations/src/actions.d.ts +2 -2
- package/dist/declarations/src/actors/observable.d.ts +41 -4
- package/dist/declarations/src/createMachine.d.ts +3 -3
- package/dist/declarations/src/index.d.ts +1 -1
- package/dist/declarations/src/setup.d.ts +11 -8
- package/dist/declarations/src/types.d.ts +41 -15
- package/dist/declarations/src/utils.d.ts +2 -1
- package/dist/{raise-90139fbc.development.esm.js → raise-156f5f68.development.esm.js} +47 -53
- package/dist/{raise-fabffc3d.cjs.js → raise-7af24c22.cjs.js} +49 -53
- package/dist/{raise-b3fb3c65.development.cjs.js → raise-7dc97582.development.cjs.js} +49 -53
- package/dist/{raise-2b5a4e4c.esm.js → raise-91ec8b4f.esm.js} +47 -53
- package/dist/{send-c124176f.cjs.js → send-401f5c30.cjs.js} +22 -1
- package/dist/{send-24cc8018.development.esm.js → send-7489590c.development.esm.js} +22 -1
- package/dist/{send-d0bc7eed.development.cjs.js → send-bc0d3e22.development.cjs.js} +22 -1
- package/dist/{send-8e7e41e7.esm.js → send-ed326064.esm.js} +22 -1
- package/dist/xstate.cjs.js +61 -82
- package/dist/xstate.cjs.mjs +3 -1
- package/dist/xstate.development.cjs.js +61 -82
- package/dist/xstate.development.cjs.mjs +3 -1
- package/dist/xstate.development.esm.js +60 -83
- package/dist/xstate.esm.js +60 -83
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +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.map +1 -1
- package/package.json +1 -1
|
@@ -316,6 +316,9 @@ function resolveReferencedActor(machine, src) {
|
|
|
316
316
|
}
|
|
317
317
|
return machine.implementations.actors[src];
|
|
318
318
|
}
|
|
319
|
+
function getAllOwnEventDescriptors(snapshot) {
|
|
320
|
+
return [...new Set(flatten([...snapshot._nodes.map(sn => sn.ownEvents)]))];
|
|
321
|
+
}
|
|
319
322
|
|
|
320
323
|
const $$ACTOR_TYPE = 1;
|
|
321
324
|
// those values are currently used by @xstate/react directly so it's important to keep the assigned values in sync
|
|
@@ -342,32 +345,6 @@ const defaultOptions = {
|
|
|
342
345
|
* An Actor is a running process that can receive events, send events and change its behavior based on the events it receives, which can cause effects outside of the actor. When you run a state machine, it becomes an actor.
|
|
343
346
|
*/
|
|
344
347
|
class Actor {
|
|
345
|
-
/**
|
|
346
|
-
* The current internal state of the actor.
|
|
347
|
-
*/
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* The clock that is responsible for setting and clearing timeouts, such as delayed events and transitions.
|
|
351
|
-
*/
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* The unique identifier for this actor relative to its parent.
|
|
355
|
-
*/
|
|
356
|
-
|
|
357
|
-
/** @internal */
|
|
358
|
-
|
|
359
|
-
// Actor Ref
|
|
360
|
-
|
|
361
|
-
// TODO: add typings for system
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* The globally unique process ID for this invocation.
|
|
365
|
-
*/
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* The system to which this actor belongs.
|
|
369
|
-
*/
|
|
370
|
-
|
|
371
348
|
/**
|
|
372
349
|
* Creates a new actor instance for the given logic with the provided options, if any.
|
|
373
350
|
*
|
|
@@ -376,24 +353,43 @@ class Actor {
|
|
|
376
353
|
*/
|
|
377
354
|
constructor(logic, options) {
|
|
378
355
|
this.logic = logic;
|
|
356
|
+
/**
|
|
357
|
+
* The current internal state of the actor.
|
|
358
|
+
*/
|
|
379
359
|
this._state = void 0;
|
|
360
|
+
/**
|
|
361
|
+
* The clock that is responsible for setting and clearing timeouts, such as delayed events and transitions.
|
|
362
|
+
*/
|
|
380
363
|
this.clock = void 0;
|
|
381
364
|
this.options = void 0;
|
|
365
|
+
/**
|
|
366
|
+
* The unique identifier for this actor relative to its parent.
|
|
367
|
+
*/
|
|
382
368
|
this.id = void 0;
|
|
383
369
|
this.mailbox = new Mailbox(this._process.bind(this));
|
|
384
370
|
this.delayedEventsMap = {};
|
|
385
371
|
this.observers = new Set();
|
|
386
372
|
this.logger = void 0;
|
|
373
|
+
/** @internal */
|
|
387
374
|
this._processingStatus = ProcessingStatus.NotStarted;
|
|
375
|
+
// Actor Ref
|
|
388
376
|
this._parent = void 0;
|
|
389
377
|
this._syncSnapshot = void 0;
|
|
390
378
|
this.ref = void 0;
|
|
379
|
+
// TODO: add typings for system
|
|
391
380
|
this._actorScope = void 0;
|
|
392
381
|
this._systemId = void 0;
|
|
382
|
+
/**
|
|
383
|
+
* The globally unique process ID for this invocation.
|
|
384
|
+
*/
|
|
393
385
|
this.sessionId = void 0;
|
|
386
|
+
/**
|
|
387
|
+
* The system to which this actor belongs.
|
|
388
|
+
*/
|
|
394
389
|
this.system = void 0;
|
|
395
390
|
this._doneEvent = void 0;
|
|
396
391
|
this.src = void 0;
|
|
392
|
+
// array of functions to defer
|
|
397
393
|
this._deferred = [];
|
|
398
394
|
const resolvedOptions = {
|
|
399
395
|
...defaultOptions,
|
|
@@ -458,9 +454,6 @@ class Actor {
|
|
|
458
454
|
_initState(persistedState) {
|
|
459
455
|
this._state = persistedState ? this.logic.restoreState ? this.logic.restoreState(persistedState, this._actorScope) : persistedState : this.logic.getInitialState(this._actorScope, this.options?.input);
|
|
460
456
|
}
|
|
461
|
-
|
|
462
|
-
// array of functions to defer
|
|
463
|
-
|
|
464
457
|
update(snapshot, event) {
|
|
465
458
|
// Update state
|
|
466
459
|
this._state = snapshot;
|
|
@@ -946,23 +939,23 @@ function executeSpawn(actorScope, {
|
|
|
946
939
|
}
|
|
947
940
|
});
|
|
948
941
|
}
|
|
949
|
-
function
|
|
942
|
+
function spawnChild(...[src, {
|
|
950
943
|
id,
|
|
951
944
|
systemId,
|
|
952
945
|
input,
|
|
953
946
|
syncSnapshot = false
|
|
954
947
|
} = {}]) {
|
|
955
|
-
function
|
|
948
|
+
function spawnChild(args, params) {
|
|
956
949
|
}
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
return
|
|
950
|
+
spawnChild.type = 'xstate.spawnChild';
|
|
951
|
+
spawnChild.id = id;
|
|
952
|
+
spawnChild.systemId = systemId;
|
|
953
|
+
spawnChild.src = src;
|
|
954
|
+
spawnChild.input = input;
|
|
955
|
+
spawnChild.syncSnapshot = syncSnapshot;
|
|
956
|
+
spawnChild.resolve = resolveSpawn;
|
|
957
|
+
spawnChild.execute = executeSpawn;
|
|
958
|
+
return spawnChild;
|
|
966
959
|
}
|
|
967
960
|
|
|
968
961
|
function resolveStop(_, state, args, actionParams, {
|
|
@@ -1006,20 +999,27 @@ function executeStop(actorScope, actorRef) {
|
|
|
1006
999
|
});
|
|
1007
1000
|
}
|
|
1008
1001
|
/**
|
|
1009
|
-
* Stops
|
|
1002
|
+
* Stops a child actor.
|
|
1010
1003
|
*
|
|
1011
1004
|
* @param actorRef The actor to stop.
|
|
1012
1005
|
*/
|
|
1013
|
-
function
|
|
1006
|
+
function stopChild(actorRef) {
|
|
1014
1007
|
function stop(args, params) {
|
|
1015
1008
|
}
|
|
1016
|
-
stop.type = 'xstate.
|
|
1009
|
+
stop.type = 'xstate.stopChild';
|
|
1017
1010
|
stop.actorRef = actorRef;
|
|
1018
1011
|
stop.resolve = resolveStop;
|
|
1019
1012
|
stop.execute = executeStop;
|
|
1020
1013
|
return stop;
|
|
1021
1014
|
}
|
|
1022
1015
|
|
|
1016
|
+
/**
|
|
1017
|
+
* Stops a child actor.
|
|
1018
|
+
*
|
|
1019
|
+
* @deprecated Use `stopChild(...)` instead
|
|
1020
|
+
*/
|
|
1021
|
+
const stop = stopChild;
|
|
1022
|
+
|
|
1023
1023
|
function checkStateIn(state, _, {
|
|
1024
1024
|
stateValue
|
|
1025
1025
|
}) {
|
|
@@ -1748,7 +1748,7 @@ function enterStates(currentState, event, actorScope, filteredTransitions, mutSt
|
|
|
1748
1748
|
// Add entry actions
|
|
1749
1749
|
actions.push(...stateNodeToEnter.entry);
|
|
1750
1750
|
for (const invokeDef of stateNodeToEnter.invoke) {
|
|
1751
|
-
actions.push(
|
|
1751
|
+
actions.push(spawnChild(invokeDef.src, {
|
|
1752
1752
|
...invokeDef,
|
|
1753
1753
|
syncSnapshot: !!invokeDef.onSnapshot
|
|
1754
1754
|
}));
|
|
@@ -1899,7 +1899,7 @@ function exitStates(currentState, event, actorScope, transitions, mutStateNodeSe
|
|
|
1899
1899
|
}
|
|
1900
1900
|
}
|
|
1901
1901
|
for (const s of statesToExit) {
|
|
1902
|
-
nextState = resolveActionsAndContext(nextState, event, actorScope, [...s.exit, ...s.invoke.map(def =>
|
|
1902
|
+
nextState = resolveActionsAndContext(nextState, event, actorScope, [...s.exit, ...s.invoke.map(def => stopChild(def.id))], internalQueue);
|
|
1903
1903
|
mutStateNodeSet.delete(s);
|
|
1904
1904
|
}
|
|
1905
1905
|
return [nextState, changedHistory || historyValue];
|
|
@@ -2022,7 +2022,7 @@ function macrostep(state, event, actorScope, internalQueue = []) {
|
|
|
2022
2022
|
};
|
|
2023
2023
|
}
|
|
2024
2024
|
function stopChildren(nextState, event, actorScope) {
|
|
2025
|
-
return resolveActionsAndContext(nextState, event, actorScope, Object.values(nextState.children).map(child =>
|
|
2025
|
+
return resolveActionsAndContext(nextState, event, actorScope, Object.values(nextState.children).map(child => stopChild(child)), []);
|
|
2026
2026
|
}
|
|
2027
2027
|
function selectTransitions(event, nextState) {
|
|
2028
2028
|
return nextState.machine.getTransitionData(nextState, event);
|
|
@@ -2076,7 +2076,6 @@ const machineSnapshotToJSON = function toJSON() {
|
|
|
2076
2076
|
_nodes: nodes,
|
|
2077
2077
|
tags,
|
|
2078
2078
|
machine,
|
|
2079
|
-
getNextEvents,
|
|
2080
2079
|
getMeta,
|
|
2081
2080
|
toJSON,
|
|
2082
2081
|
can,
|
|
@@ -2089,9 +2088,6 @@ const machineSnapshotToJSON = function toJSON() {
|
|
|
2089
2088
|
tags: Array.from(tags)
|
|
2090
2089
|
};
|
|
2091
2090
|
};
|
|
2092
|
-
const machineSnapshotGetNextEvents = function getNextEvents() {
|
|
2093
|
-
return [...new Set(flatten([...this._nodes.map(sn => sn.ownEvents)]))];
|
|
2094
|
-
};
|
|
2095
2091
|
const machineSnapshotGetMeta = function getMeta() {
|
|
2096
2092
|
return this._nodes.reduce((acc, stateNode) => {
|
|
2097
2093
|
if (stateNode.meta !== undefined) {
|
|
@@ -2116,7 +2112,6 @@ function createMachineSnapshot(config, machine) {
|
|
|
2116
2112
|
matches: machineSnapshotMatches,
|
|
2117
2113
|
hasTag: machineSnapshotHasTag,
|
|
2118
2114
|
can: machineSnapshotCan,
|
|
2119
|
-
getNextEvents: machineSnapshotGetNextEvents,
|
|
2120
2115
|
getMeta: machineSnapshotGetMeta,
|
|
2121
2116
|
toJSON: machineSnapshotToJSON
|
|
2122
2117
|
};
|
|
@@ -2137,7 +2132,6 @@ function getPersistedState(state, options) {
|
|
|
2137
2132
|
can,
|
|
2138
2133
|
hasTag,
|
|
2139
2134
|
matches,
|
|
2140
|
-
getNextEvents,
|
|
2141
2135
|
getMeta,
|
|
2142
2136
|
toJSON,
|
|
2143
2137
|
...jsonValues
|
|
@@ -2238,4 +2232,4 @@ function raise(eventOrExpr, options) {
|
|
|
2238
2232
|
return raise;
|
|
2239
2233
|
}
|
|
2240
2234
|
|
|
2241
|
-
export { $$ACTOR_TYPE as $,
|
|
2235
|
+
export { $$ACTOR_TYPE as $, getPersistedState as A, resolveReferencedActor as B, createActor as C, Actor as D, interpret as E, isMachineSnapshot as F, matchesState as G, pathToStateValue as H, toObserver as I, and as J, not as K, or as L, stateIn as M, NULL_EVENT as N, cancel as O, raise as P, stop as Q, stopChild as R, STATE_DELIMITER as S, spawnChild as T, ProcessingStatus as U, createErrorActorEvent as V, XSTATE_ERROR as W, XSTATE_STOP as X, toTransitionConfigArray as a, formatTransition as b, createInvokeId as c, formatInitialTransition as d, evaluateGuard as e, formatTransitions as f, getDelayedTransitions as g, getCandidates as h, getAllStateNodes as i, getStateNodes as j, createMachineSnapshot as k, isInFinalState as l, mapValues as m, isErrorActorEvent as n, getAllOwnEventDescriptors as o, cloneMachineSnapshot as p, macrostep as q, resolveStateValue as r, transitionNode as s, toArray as t, resolveActionsAndContext as u, createInitEvent as v, microstep as w, getInitialStateNodes as x, isStateId as y, getStateNodeByPath as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-7af24c22.cjs.js');
|
|
4
4
|
|
|
5
5
|
function createSpawner(actorScope, {
|
|
6
6
|
machine,
|
|
@@ -229,6 +229,27 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
229
229
|
return SpecialTargets;
|
|
230
230
|
}({});
|
|
231
231
|
|
|
232
|
+
/**
|
|
233
|
+
* @deprecated Use `AnyActor` instead.
|
|
234
|
+
*/
|
|
235
|
+
|
|
236
|
+
// Based on RxJS types
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* @deprecated Use `Actor<T>` instead.
|
|
240
|
+
*/
|
|
241
|
+
|
|
242
|
+
// only meant to be used internally for debugging purposes
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Represents logic which can be used by an actor.
|
|
246
|
+
*
|
|
247
|
+
* @template TSnapshot - The type of the snapshot.
|
|
248
|
+
* @template TEvent - The type of the event object.
|
|
249
|
+
* @template TInput - The type of the input.
|
|
250
|
+
* @template TSystem - The type of the actor system.
|
|
251
|
+
*/
|
|
252
|
+
|
|
232
253
|
function resolveSendTo(actorScope, state, args, actionParams, {
|
|
233
254
|
to,
|
|
234
255
|
event: eventOrExpr,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { U as ProcessingStatus, V as createErrorActorEvent, B as resolveReferencedActor, C as createActor, p as cloneMachineSnapshot, e as evaluateGuard, t as toArray, W as XSTATE_ERROR } from './raise-156f5f68.development.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, {
|
|
4
4
|
machine,
|
|
@@ -239,6 +239,27 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
239
239
|
return SpecialTargets;
|
|
240
240
|
}({});
|
|
241
241
|
|
|
242
|
+
/**
|
|
243
|
+
* @deprecated Use `AnyActor` instead.
|
|
244
|
+
*/
|
|
245
|
+
|
|
246
|
+
// Based on RxJS types
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* @deprecated Use `Actor<T>` instead.
|
|
250
|
+
*/
|
|
251
|
+
|
|
252
|
+
// only meant to be used internally for debugging purposes
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Represents logic which can be used by an actor.
|
|
256
|
+
*
|
|
257
|
+
* @template TSnapshot - The type of the snapshot.
|
|
258
|
+
* @template TEvent - The type of the event object.
|
|
259
|
+
* @template TInput - The type of the input.
|
|
260
|
+
* @template TSystem - The type of the actor system.
|
|
261
|
+
*/
|
|
262
|
+
|
|
242
263
|
function resolveSendTo(actorScope, state, args, actionParams, {
|
|
243
264
|
to,
|
|
244
265
|
event: eventOrExpr,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-7dc97582.development.cjs.js');
|
|
4
4
|
|
|
5
5
|
function createSpawner(actorScope, {
|
|
6
6
|
machine,
|
|
@@ -241,6 +241,27 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
241
241
|
return SpecialTargets;
|
|
242
242
|
}({});
|
|
243
243
|
|
|
244
|
+
/**
|
|
245
|
+
* @deprecated Use `AnyActor` instead.
|
|
246
|
+
*/
|
|
247
|
+
|
|
248
|
+
// Based on RxJS types
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* @deprecated Use `Actor<T>` instead.
|
|
252
|
+
*/
|
|
253
|
+
|
|
254
|
+
// only meant to be used internally for debugging purposes
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Represents logic which can be used by an actor.
|
|
258
|
+
*
|
|
259
|
+
* @template TSnapshot - The type of the snapshot.
|
|
260
|
+
* @template TEvent - The type of the event object.
|
|
261
|
+
* @template TInput - The type of the input.
|
|
262
|
+
* @template TSystem - The type of the actor system.
|
|
263
|
+
*/
|
|
264
|
+
|
|
244
265
|
function resolveSendTo(actorScope, state, args, actionParams, {
|
|
245
266
|
to,
|
|
246
267
|
event: eventOrExpr,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { U as ProcessingStatus, V as createErrorActorEvent, B as resolveReferencedActor, C as createActor, p as cloneMachineSnapshot, e as evaluateGuard, t as toArray, W as XSTATE_ERROR } from './raise-91ec8b4f.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, {
|
|
4
4
|
machine,
|
|
@@ -227,6 +227,27 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
227
227
|
return SpecialTargets;
|
|
228
228
|
}({});
|
|
229
229
|
|
|
230
|
+
/**
|
|
231
|
+
* @deprecated Use `AnyActor` instead.
|
|
232
|
+
*/
|
|
233
|
+
|
|
234
|
+
// Based on RxJS types
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* @deprecated Use `Actor<T>` instead.
|
|
238
|
+
*/
|
|
239
|
+
|
|
240
|
+
// only meant to be used internally for debugging purposes
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Represents logic which can be used by an actor.
|
|
244
|
+
*
|
|
245
|
+
* @template TSnapshot - The type of the snapshot.
|
|
246
|
+
* @template TEvent - The type of the event object.
|
|
247
|
+
* @template TInput - The type of the input.
|
|
248
|
+
* @template TSystem - The type of the actor system.
|
|
249
|
+
*/
|
|
250
|
+
|
|
230
251
|
function resolveSendTo(actorScope, state, args, actionParams, {
|
|
231
252
|
to,
|
|
232
253
|
event: eventOrExpr,
|
package/dist/xstate.cjs.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var actors_dist_xstateActors = require('../actors/dist/xstate-actors.cjs.js');
|
|
6
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
7
|
-
var send = require('./send-
|
|
6
|
+
var guards_dist_xstateGuards = require('./raise-7af24c22.cjs.js');
|
|
7
|
+
var send = require('./send-401f5c30.cjs.js');
|
|
8
8
|
require('../dev/dist/xstate-dev.cjs.js');
|
|
9
9
|
|
|
10
10
|
class SimulatedClock {
|
|
@@ -90,85 +90,72 @@ const toSerializableAction = action => {
|
|
|
90
90
|
return action;
|
|
91
91
|
};
|
|
92
92
|
class StateNode {
|
|
93
|
-
/**
|
|
94
|
-
* The relative key of the state node, which represents its location in the overall state value.
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* The unique ID of the state node.
|
|
99
|
-
*/
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* The type of this state node:
|
|
103
|
-
*
|
|
104
|
-
* - `'atomic'` - no child state nodes
|
|
105
|
-
* - `'compound'` - nested child state nodes (XOR)
|
|
106
|
-
* - `'parallel'` - orthogonal nested child state nodes (AND)
|
|
107
|
-
* - `'history'` - history state node
|
|
108
|
-
* - `'final'` - final state node
|
|
109
|
-
*/
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* The string path from the root machine node to this node.
|
|
113
|
-
*/
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* The child state nodes.
|
|
117
|
-
*/
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* The type of history on this state node. Can be:
|
|
121
|
-
*
|
|
122
|
-
* - `'shallow'` - recalls only top-level historical state value
|
|
123
|
-
* - `'deep'` - recalls historical state value at all levels
|
|
124
|
-
*/
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* The action(s) to be executed upon entering the state node.
|
|
128
|
-
*/
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* The action(s) to be executed upon exiting the state node.
|
|
132
|
-
*/
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* The parent state node.
|
|
136
|
-
*/
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* The root machine node.
|
|
140
|
-
*/
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* The meta data associated with this state node, which will be returned in State instances.
|
|
144
|
-
*/
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* The output data sent with the "xstate.done.state._id_" event if this is a final state node.
|
|
148
|
-
*/
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* The order this state node appears. Corresponds to the implicit document order.
|
|
152
|
-
*/
|
|
153
|
-
|
|
154
93
|
constructor(
|
|
155
94
|
/**
|
|
156
95
|
* The raw config used to create the machine.
|
|
157
96
|
*/
|
|
158
97
|
config, options) {
|
|
159
98
|
this.config = config;
|
|
99
|
+
/**
|
|
100
|
+
* The relative key of the state node, which represents its location in the overall state value.
|
|
101
|
+
*/
|
|
160
102
|
this.key = void 0;
|
|
103
|
+
/**
|
|
104
|
+
* The unique ID of the state node.
|
|
105
|
+
*/
|
|
161
106
|
this.id = void 0;
|
|
107
|
+
/**
|
|
108
|
+
* The type of this state node:
|
|
109
|
+
*
|
|
110
|
+
* - `'atomic'` - no child state nodes
|
|
111
|
+
* - `'compound'` - nested child state nodes (XOR)
|
|
112
|
+
* - `'parallel'` - orthogonal nested child state nodes (AND)
|
|
113
|
+
* - `'history'` - history state node
|
|
114
|
+
* - `'final'` - final state node
|
|
115
|
+
*/
|
|
162
116
|
this.type = void 0;
|
|
117
|
+
/**
|
|
118
|
+
* The string path from the root machine node to this node.
|
|
119
|
+
*/
|
|
163
120
|
this.path = void 0;
|
|
121
|
+
/**
|
|
122
|
+
* The child state nodes.
|
|
123
|
+
*/
|
|
164
124
|
this.states = void 0;
|
|
125
|
+
/**
|
|
126
|
+
* The type of history on this state node. Can be:
|
|
127
|
+
*
|
|
128
|
+
* - `'shallow'` - recalls only top-level historical state value
|
|
129
|
+
* - `'deep'` - recalls historical state value at all levels
|
|
130
|
+
*/
|
|
165
131
|
this.history = void 0;
|
|
132
|
+
/**
|
|
133
|
+
* The action(s) to be executed upon entering the state node.
|
|
134
|
+
*/
|
|
166
135
|
this.entry = void 0;
|
|
136
|
+
/**
|
|
137
|
+
* The action(s) to be executed upon exiting the state node.
|
|
138
|
+
*/
|
|
167
139
|
this.exit = void 0;
|
|
140
|
+
/**
|
|
141
|
+
* The parent state node.
|
|
142
|
+
*/
|
|
168
143
|
this.parent = void 0;
|
|
144
|
+
/**
|
|
145
|
+
* The root machine node.
|
|
146
|
+
*/
|
|
169
147
|
this.machine = void 0;
|
|
148
|
+
/**
|
|
149
|
+
* The meta data associated with this state node, which will be returned in State instances.
|
|
150
|
+
*/
|
|
170
151
|
this.meta = void 0;
|
|
152
|
+
/**
|
|
153
|
+
* The output data sent with the "xstate.done.state._id_" event if this is a final state node.
|
|
154
|
+
*/
|
|
171
155
|
this.output = void 0;
|
|
156
|
+
/**
|
|
157
|
+
* The order this state node appears. Corresponds to the implicit document order.
|
|
158
|
+
*/
|
|
172
159
|
this.order = -1;
|
|
173
160
|
this.description = void 0;
|
|
174
161
|
this.tags = [];
|
|
@@ -374,16 +361,15 @@ class StateNode {
|
|
|
374
361
|
|
|
375
362
|
const STATE_IDENTIFIER = '#';
|
|
376
363
|
class StateMachine {
|
|
377
|
-
/**
|
|
378
|
-
* The machine's own version.
|
|
379
|
-
*/
|
|
380
|
-
|
|
381
364
|
constructor(
|
|
382
365
|
/**
|
|
383
366
|
* The raw config used to create the machine.
|
|
384
367
|
*/
|
|
385
368
|
config, implementations) {
|
|
386
369
|
this.config = config;
|
|
370
|
+
/**
|
|
371
|
+
* The machine's own version.
|
|
372
|
+
*/
|
|
387
373
|
this.version = void 0;
|
|
388
374
|
this.implementations = void 0;
|
|
389
375
|
this.types = void 0;
|
|
@@ -393,15 +379,7 @@ class StateMachine {
|
|
|
393
379
|
this.id = void 0;
|
|
394
380
|
this.states = void 0;
|
|
395
381
|
this.events = void 0;
|
|
396
|
-
|
|
397
|
-
this.__TEvent = void 0;
|
|
398
|
-
this.__TActor = void 0;
|
|
399
|
-
this.__TAction = void 0;
|
|
400
|
-
this.__TGuard = void 0;
|
|
401
|
-
this.__TDelay = void 0;
|
|
402
|
-
this.__TTag = void 0;
|
|
403
|
-
this.__TInput = void 0;
|
|
404
|
-
this.__TOutput = void 0;
|
|
382
|
+
/** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
405
383
|
this.__TResolvedTypesMeta = void 0;
|
|
406
384
|
this.id = config.id || '(machine)';
|
|
407
385
|
this.implementations = {
|
|
@@ -483,7 +461,7 @@ class StateMachine {
|
|
|
483
461
|
*/
|
|
484
462
|
transition(state, event, actorScope) {
|
|
485
463
|
// TODO: handle error events in a better way
|
|
486
|
-
if (guards_dist_xstateGuards.isErrorActorEvent(event) && !
|
|
464
|
+
if (guards_dist_xstateGuards.isErrorActorEvent(event) && !guards_dist_xstateGuards.getAllOwnEventDescriptors(state).some(nextEvent => nextEvent === event.type)) {
|
|
487
465
|
return guards_dist_xstateGuards.cloneMachineSnapshot(state, {
|
|
488
466
|
status: 'error',
|
|
489
467
|
error: event.data
|
|
@@ -593,12 +571,11 @@ class StateMachine {
|
|
|
593
571
|
if (!logic) {
|
|
594
572
|
return;
|
|
595
573
|
}
|
|
596
|
-
const actorState = logic.restoreState?.(childState, _actorScope);
|
|
597
574
|
const actorRef = guards_dist_xstateGuards.createActor(logic, {
|
|
598
575
|
id: actorId,
|
|
599
576
|
parent: _actorScope?.self,
|
|
600
577
|
syncSnapshot: actorData.syncSnapshot,
|
|
601
|
-
state:
|
|
578
|
+
state: childState,
|
|
602
579
|
src,
|
|
603
580
|
systemId: actorData.systemId
|
|
604
581
|
});
|
|
@@ -629,8 +606,6 @@ class StateMachine {
|
|
|
629
606
|
reviveContext(restoredSnapshot.context, children);
|
|
630
607
|
return restoredSnapshot;
|
|
631
608
|
}
|
|
632
|
-
|
|
633
|
-
/**@deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
634
609
|
}
|
|
635
610
|
|
|
636
611
|
const defaultWaitForOptions = {
|
|
@@ -708,6 +683,8 @@ function createMachine(config, implementations) {
|
|
|
708
683
|
return new StateMachine(config, implementations);
|
|
709
684
|
}
|
|
710
685
|
|
|
686
|
+
// at the moment we allow extra actors - ones that are not specified by `children`
|
|
687
|
+
// this could be reconsidered in the future
|
|
711
688
|
function setup({
|
|
712
689
|
actors,
|
|
713
690
|
actions,
|
|
@@ -731,6 +708,7 @@ exports.fromObservable = actors_dist_xstateActors.fromObservable;
|
|
|
731
708
|
exports.fromPromise = actors_dist_xstateActors.fromPromise;
|
|
732
709
|
exports.fromTransition = actors_dist_xstateActors.fromTransition;
|
|
733
710
|
exports.Actor = guards_dist_xstateGuards.Actor;
|
|
711
|
+
exports.__unsafe_getAllOwnEventDescriptors = guards_dist_xstateGuards.getAllOwnEventDescriptors;
|
|
734
712
|
exports.and = guards_dist_xstateGuards.and;
|
|
735
713
|
exports.cancel = guards_dist_xstateGuards.cancel;
|
|
736
714
|
exports.createActor = guards_dist_xstateGuards.createActor;
|
|
@@ -742,9 +720,10 @@ exports.not = guards_dist_xstateGuards.not;
|
|
|
742
720
|
exports.or = guards_dist_xstateGuards.or;
|
|
743
721
|
exports.pathToStateValue = guards_dist_xstateGuards.pathToStateValue;
|
|
744
722
|
exports.raise = guards_dist_xstateGuards.raise;
|
|
745
|
-
exports.
|
|
723
|
+
exports.spawnChild = guards_dist_xstateGuards.spawnChild;
|
|
746
724
|
exports.stateIn = guards_dist_xstateGuards.stateIn;
|
|
747
725
|
exports.stop = guards_dist_xstateGuards.stop;
|
|
726
|
+
exports.stopChild = guards_dist_xstateGuards.stopChild;
|
|
748
727
|
exports.toObserver = guards_dist_xstateGuards.toObserver;
|
|
749
728
|
exports.SpecialTargets = send.SpecialTargets;
|
|
750
729
|
exports.assign = send.assign;
|
package/dist/xstate.cjs.mjs
CHANGED
|
@@ -4,6 +4,7 @@ export {
|
|
|
4
4
|
SpecialTargets,
|
|
5
5
|
StateMachine,
|
|
6
6
|
StateNode,
|
|
7
|
+
__unsafe_getAllOwnEventDescriptors,
|
|
7
8
|
and,
|
|
8
9
|
assign,
|
|
9
10
|
cancel,
|
|
@@ -31,9 +32,10 @@ export {
|
|
|
31
32
|
sendParent,
|
|
32
33
|
sendTo,
|
|
33
34
|
setup,
|
|
34
|
-
|
|
35
|
+
spawnChild,
|
|
35
36
|
stateIn,
|
|
36
37
|
stop,
|
|
38
|
+
stopChild,
|
|
37
39
|
toObserver,
|
|
38
40
|
waitFor
|
|
39
41
|
} from "./xstate.cjs.js";
|