xstate 5.0.0-beta.45 → 5.0.0-beta.46
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 +2 -2
- package/actions/dist/xstate-actions.development.cjs.js +2 -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/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-2b5a4e4c.esm.js → raise-1682abb7.esm.js} +23 -36
- package/dist/{raise-fabffc3d.cjs.js → raise-a1d3d7e9.cjs.js} +23 -35
- package/dist/{raise-b3fb3c65.development.cjs.js → raise-a9e7e31c.development.cjs.js} +23 -35
- package/dist/{raise-90139fbc.development.esm.js → raise-fa23c2b9.development.esm.js} +23 -36
- package/dist/{send-c124176f.cjs.js → send-2fa3a204.cjs.js} +22 -1
- package/dist/{send-d0bc7eed.development.cjs.js → send-5b256a89.development.cjs.js} +22 -1
- package/dist/{send-24cc8018.development.esm.js → send-9acdf858.development.esm.js} +22 -1
- package/dist/{send-8e7e41e7.esm.js → send-a237e4e8.esm.js} +22 -1
- package/dist/xstate.cjs.js +59 -81
- package/dist/xstate.cjs.mjs +1 -0
- package/dist/xstate.development.cjs.js +59 -81
- package/dist/xstate.development.cjs.mjs +1 -0
- 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
|
@@ -321,6 +321,9 @@ function resolveReferencedActor(machine, src) {
|
|
|
321
321
|
}
|
|
322
322
|
return machine.implementations.actors[src];
|
|
323
323
|
}
|
|
324
|
+
function getAllOwnEventDescriptors(snapshot) {
|
|
325
|
+
return [...new Set(flatten([...snapshot._nodes.map(sn => sn.ownEvents)]))];
|
|
326
|
+
}
|
|
324
327
|
|
|
325
328
|
const $$ACTOR_TYPE = 1;
|
|
326
329
|
// those values are currently used by @xstate/react directly so it's important to keep the assigned values in sync
|
|
@@ -347,32 +350,6 @@ const defaultOptions = {
|
|
|
347
350
|
* 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.
|
|
348
351
|
*/
|
|
349
352
|
class Actor {
|
|
350
|
-
/**
|
|
351
|
-
* The current internal state of the actor.
|
|
352
|
-
*/
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* The clock that is responsible for setting and clearing timeouts, such as delayed events and transitions.
|
|
356
|
-
*/
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* The unique identifier for this actor relative to its parent.
|
|
360
|
-
*/
|
|
361
|
-
|
|
362
|
-
/** @internal */
|
|
363
|
-
|
|
364
|
-
// Actor Ref
|
|
365
|
-
|
|
366
|
-
// TODO: add typings for system
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* The globally unique process ID for this invocation.
|
|
370
|
-
*/
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* The system to which this actor belongs.
|
|
374
|
-
*/
|
|
375
|
-
|
|
376
353
|
/**
|
|
377
354
|
* Creates a new actor instance for the given logic with the provided options, if any.
|
|
378
355
|
*
|
|
@@ -381,24 +358,43 @@ class Actor {
|
|
|
381
358
|
*/
|
|
382
359
|
constructor(logic, options) {
|
|
383
360
|
this.logic = logic;
|
|
361
|
+
/**
|
|
362
|
+
* The current internal state of the actor.
|
|
363
|
+
*/
|
|
384
364
|
this._state = void 0;
|
|
365
|
+
/**
|
|
366
|
+
* The clock that is responsible for setting and clearing timeouts, such as delayed events and transitions.
|
|
367
|
+
*/
|
|
385
368
|
this.clock = void 0;
|
|
386
369
|
this.options = void 0;
|
|
370
|
+
/**
|
|
371
|
+
* The unique identifier for this actor relative to its parent.
|
|
372
|
+
*/
|
|
387
373
|
this.id = void 0;
|
|
388
374
|
this.mailbox = new Mailbox(this._process.bind(this));
|
|
389
375
|
this.delayedEventsMap = {};
|
|
390
376
|
this.observers = new Set();
|
|
391
377
|
this.logger = void 0;
|
|
378
|
+
/** @internal */
|
|
392
379
|
this._processingStatus = ProcessingStatus.NotStarted;
|
|
380
|
+
// Actor Ref
|
|
393
381
|
this._parent = void 0;
|
|
394
382
|
this._syncSnapshot = void 0;
|
|
395
383
|
this.ref = void 0;
|
|
384
|
+
// TODO: add typings for system
|
|
396
385
|
this._actorScope = void 0;
|
|
397
386
|
this._systemId = void 0;
|
|
387
|
+
/**
|
|
388
|
+
* The globally unique process ID for this invocation.
|
|
389
|
+
*/
|
|
398
390
|
this.sessionId = void 0;
|
|
391
|
+
/**
|
|
392
|
+
* The system to which this actor belongs.
|
|
393
|
+
*/
|
|
399
394
|
this.system = void 0;
|
|
400
395
|
this._doneEvent = void 0;
|
|
401
396
|
this.src = void 0;
|
|
397
|
+
// array of functions to defer
|
|
402
398
|
this._deferred = [];
|
|
403
399
|
const resolvedOptions = {
|
|
404
400
|
...defaultOptions,
|
|
@@ -463,9 +459,6 @@ class Actor {
|
|
|
463
459
|
_initState(persistedState) {
|
|
464
460
|
this._state = persistedState ? this.logic.restoreState ? this.logic.restoreState(persistedState, this._actorScope) : persistedState : this.logic.getInitialState(this._actorScope, this.options?.input);
|
|
465
461
|
}
|
|
466
|
-
|
|
467
|
-
// array of functions to defer
|
|
468
|
-
|
|
469
462
|
update(snapshot, event) {
|
|
470
463
|
// Update state
|
|
471
464
|
this._state = snapshot;
|
|
@@ -2126,7 +2119,6 @@ const machineSnapshotToJSON = function toJSON() {
|
|
|
2126
2119
|
_nodes: nodes,
|
|
2127
2120
|
tags,
|
|
2128
2121
|
machine,
|
|
2129
|
-
getNextEvents,
|
|
2130
2122
|
getMeta,
|
|
2131
2123
|
toJSON,
|
|
2132
2124
|
can,
|
|
@@ -2139,9 +2131,6 @@ const machineSnapshotToJSON = function toJSON() {
|
|
|
2139
2131
|
tags: Array.from(tags)
|
|
2140
2132
|
};
|
|
2141
2133
|
};
|
|
2142
|
-
const machineSnapshotGetNextEvents = function getNextEvents() {
|
|
2143
|
-
return [...new Set(flatten([...this._nodes.map(sn => sn.ownEvents)]))];
|
|
2144
|
-
};
|
|
2145
2134
|
const machineSnapshotGetMeta = function getMeta() {
|
|
2146
2135
|
return this._nodes.reduce((acc, stateNode) => {
|
|
2147
2136
|
if (stateNode.meta !== undefined) {
|
|
@@ -2166,7 +2155,6 @@ function createMachineSnapshot(config, machine) {
|
|
|
2166
2155
|
matches: machineSnapshotMatches,
|
|
2167
2156
|
hasTag: machineSnapshotHasTag,
|
|
2168
2157
|
can: machineSnapshotCan,
|
|
2169
|
-
getNextEvents: machineSnapshotGetNextEvents,
|
|
2170
2158
|
getMeta: machineSnapshotGetMeta,
|
|
2171
2159
|
toJSON: machineSnapshotToJSON
|
|
2172
2160
|
};
|
|
@@ -2187,7 +2175,6 @@ function getPersistedState(state, options) {
|
|
|
2187
2175
|
can,
|
|
2188
2176
|
hasTag,
|
|
2189
2177
|
matches,
|
|
2190
|
-
getNextEvents,
|
|
2191
2178
|
getMeta,
|
|
2192
2179
|
toJSON,
|
|
2193
2180
|
...jsonValues
|
|
@@ -2313,6 +2300,7 @@ exports.evaluateGuard = evaluateGuard;
|
|
|
2313
2300
|
exports.formatInitialTransition = formatInitialTransition;
|
|
2314
2301
|
exports.formatTransition = formatTransition;
|
|
2315
2302
|
exports.formatTransitions = formatTransitions;
|
|
2303
|
+
exports.getAllOwnEventDescriptors = getAllOwnEventDescriptors;
|
|
2316
2304
|
exports.getAllStateNodes = getAllStateNodes;
|
|
2317
2305
|
exports.getCandidates = getCandidates;
|
|
2318
2306
|
exports.getDelayedTransitions = getDelayedTransitions;
|
|
@@ -319,6 +319,9 @@ function resolveReferencedActor(machine, src) {
|
|
|
319
319
|
}
|
|
320
320
|
return machine.implementations.actors[src];
|
|
321
321
|
}
|
|
322
|
+
function getAllOwnEventDescriptors(snapshot) {
|
|
323
|
+
return [...new Set(flatten([...snapshot._nodes.map(sn => sn.ownEvents)]))];
|
|
324
|
+
}
|
|
322
325
|
|
|
323
326
|
const $$ACTOR_TYPE = 1;
|
|
324
327
|
// those values are currently used by @xstate/react directly so it's important to keep the assigned values in sync
|
|
@@ -345,32 +348,6 @@ const defaultOptions = {
|
|
|
345
348
|
* 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.
|
|
346
349
|
*/
|
|
347
350
|
class Actor {
|
|
348
|
-
/**
|
|
349
|
-
* The current internal state of the actor.
|
|
350
|
-
*/
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* The clock that is responsible for setting and clearing timeouts, such as delayed events and transitions.
|
|
354
|
-
*/
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* The unique identifier for this actor relative to its parent.
|
|
358
|
-
*/
|
|
359
|
-
|
|
360
|
-
/** @internal */
|
|
361
|
-
|
|
362
|
-
// Actor Ref
|
|
363
|
-
|
|
364
|
-
// TODO: add typings for system
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* The globally unique process ID for this invocation.
|
|
368
|
-
*/
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* The system to which this actor belongs.
|
|
372
|
-
*/
|
|
373
|
-
|
|
374
351
|
/**
|
|
375
352
|
* Creates a new actor instance for the given logic with the provided options, if any.
|
|
376
353
|
*
|
|
@@ -379,24 +356,43 @@ class Actor {
|
|
|
379
356
|
*/
|
|
380
357
|
constructor(logic, options) {
|
|
381
358
|
this.logic = logic;
|
|
359
|
+
/**
|
|
360
|
+
* The current internal state of the actor.
|
|
361
|
+
*/
|
|
382
362
|
this._state = void 0;
|
|
363
|
+
/**
|
|
364
|
+
* The clock that is responsible for setting and clearing timeouts, such as delayed events and transitions.
|
|
365
|
+
*/
|
|
383
366
|
this.clock = void 0;
|
|
384
367
|
this.options = void 0;
|
|
368
|
+
/**
|
|
369
|
+
* The unique identifier for this actor relative to its parent.
|
|
370
|
+
*/
|
|
385
371
|
this.id = void 0;
|
|
386
372
|
this.mailbox = new Mailbox(this._process.bind(this));
|
|
387
373
|
this.delayedEventsMap = {};
|
|
388
374
|
this.observers = new Set();
|
|
389
375
|
this.logger = void 0;
|
|
376
|
+
/** @internal */
|
|
390
377
|
this._processingStatus = ProcessingStatus.NotStarted;
|
|
378
|
+
// Actor Ref
|
|
391
379
|
this._parent = void 0;
|
|
392
380
|
this._syncSnapshot = void 0;
|
|
393
381
|
this.ref = void 0;
|
|
382
|
+
// TODO: add typings for system
|
|
394
383
|
this._actorScope = void 0;
|
|
395
384
|
this._systemId = void 0;
|
|
385
|
+
/**
|
|
386
|
+
* The globally unique process ID for this invocation.
|
|
387
|
+
*/
|
|
396
388
|
this.sessionId = void 0;
|
|
389
|
+
/**
|
|
390
|
+
* The system to which this actor belongs.
|
|
391
|
+
*/
|
|
397
392
|
this.system = void 0;
|
|
398
393
|
this._doneEvent = void 0;
|
|
399
394
|
this.src = void 0;
|
|
395
|
+
// array of functions to defer
|
|
400
396
|
this._deferred = [];
|
|
401
397
|
const resolvedOptions = {
|
|
402
398
|
...defaultOptions,
|
|
@@ -461,9 +457,6 @@ class Actor {
|
|
|
461
457
|
_initState(persistedState) {
|
|
462
458
|
this._state = persistedState ? this.logic.restoreState ? this.logic.restoreState(persistedState, this._actorScope) : persistedState : this.logic.getInitialState(this._actorScope, this.options?.input);
|
|
463
459
|
}
|
|
464
|
-
|
|
465
|
-
// array of functions to defer
|
|
466
|
-
|
|
467
460
|
update(snapshot, event) {
|
|
468
461
|
// Update state
|
|
469
462
|
this._state = snapshot;
|
|
@@ -2124,7 +2117,6 @@ const machineSnapshotToJSON = function toJSON() {
|
|
|
2124
2117
|
_nodes: nodes,
|
|
2125
2118
|
tags,
|
|
2126
2119
|
machine,
|
|
2127
|
-
getNextEvents,
|
|
2128
2120
|
getMeta,
|
|
2129
2121
|
toJSON,
|
|
2130
2122
|
can,
|
|
@@ -2137,9 +2129,6 @@ const machineSnapshotToJSON = function toJSON() {
|
|
|
2137
2129
|
tags: Array.from(tags)
|
|
2138
2130
|
};
|
|
2139
2131
|
};
|
|
2140
|
-
const machineSnapshotGetNextEvents = function getNextEvents() {
|
|
2141
|
-
return [...new Set(flatten([...this._nodes.map(sn => sn.ownEvents)]))];
|
|
2142
|
-
};
|
|
2143
2132
|
const machineSnapshotGetMeta = function getMeta() {
|
|
2144
2133
|
return this._nodes.reduce((acc, stateNode) => {
|
|
2145
2134
|
if (stateNode.meta !== undefined) {
|
|
@@ -2164,7 +2153,6 @@ function createMachineSnapshot(config, machine) {
|
|
|
2164
2153
|
matches: machineSnapshotMatches,
|
|
2165
2154
|
hasTag: machineSnapshotHasTag,
|
|
2166
2155
|
can: machineSnapshotCan,
|
|
2167
|
-
getNextEvents: machineSnapshotGetNextEvents,
|
|
2168
2156
|
getMeta: machineSnapshotGetMeta,
|
|
2169
2157
|
toJSON: machineSnapshotToJSON
|
|
2170
2158
|
};
|
|
@@ -2185,7 +2173,6 @@ function getPersistedState(state, options) {
|
|
|
2185
2173
|
can,
|
|
2186
2174
|
hasTag,
|
|
2187
2175
|
matches,
|
|
2188
|
-
getNextEvents,
|
|
2189
2176
|
getMeta,
|
|
2190
2177
|
toJSON,
|
|
2191
2178
|
...jsonValues
|
|
@@ -2292,4 +2279,4 @@ function raise(eventOrExpr, options) {
|
|
|
2292
2279
|
return raise;
|
|
2293
2280
|
}
|
|
2294
2281
|
|
|
2295
|
-
export { $$ACTOR_TYPE as $,
|
|
2282
|
+
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, spawn as R, STATE_DELIMITER as S, ProcessingStatus as T, createErrorActorEvent as U, XSTATE_ERROR as V, 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-a1d3d7e9.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,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-a9e7e31c.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 { T as ProcessingStatus, U as createErrorActorEvent, B as resolveReferencedActor, C as createActor, p as cloneMachineSnapshot, e as evaluateGuard, t as toArray, V as XSTATE_ERROR } from './raise-fa23c2b9.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,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { T as ProcessingStatus, U as createErrorActorEvent, B as resolveReferencedActor, C as createActor, p as cloneMachineSnapshot, e as evaluateGuard, t as toArray, V as XSTATE_ERROR } from './raise-1682abb7.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-a1d3d7e9.cjs.js');
|
|
7
|
+
var send = require('./send-2fa3a204.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;
|