xstate 5.0.0-beta.51 → 5.0.0-beta.53
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 +9 -11
- package/actions/dist/xstate-actions.cjs.mjs +0 -2
- package/actions/dist/xstate-actions.development.cjs.js +9 -11
- package/actions/dist/xstate-actions.development.cjs.mjs +0 -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 +17 -17
- package/actors/dist/xstate-actors.development.cjs.js +17 -17
- package/actors/dist/xstate-actors.development.esm.js +17 -17
- package/actors/dist/xstate-actors.esm.js +17 -17
- package/actors/dist/xstate-actors.umd.min.js +1 -1
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/declarations/src/State.d.ts +2 -2
- package/dist/declarations/src/StateMachine.d.ts +6 -6
- package/dist/declarations/src/StateNode.d.ts +4 -4
- package/dist/declarations/src/actions.d.ts +0 -2
- package/dist/declarations/src/actors/index.d.ts +1 -1
- package/dist/declarations/src/actors/transition.d.ts +1 -1
- package/dist/declarations/src/guards.d.ts +1 -1
- package/dist/declarations/src/interpreter.d.ts +7 -7
- package/dist/declarations/src/stateUtils.d.ts +9 -9
- package/dist/declarations/src/types.d.ts +23 -19
- package/dist/{pure-296f8ebd.development.esm.js → log-1fd7d00a.development.esm.js} +24 -61
- package/dist/{pure-aefddc19.esm.js → log-60ab9eaf.esm.js} +24 -58
- package/dist/{pure-c5f1b46c.cjs.js → log-717bb5a1.cjs.js} +23 -59
- package/dist/{pure-a0f16134.development.cjs.js → log-c8797128.development.cjs.js} +23 -62
- package/dist/{raise-acaa3884.development.esm.js → raise-953b1eb5.development.esm.js} +136 -136
- package/dist/{raise-d5633a02.cjs.js → raise-a8367773.cjs.js} +136 -136
- package/dist/{raise-4742bf04.esm.js → raise-be2f20bc.esm.js} +136 -136
- package/dist/{raise-528386de.development.cjs.js → raise-d9fd8932.development.cjs.js} +136 -136
- package/dist/xstate.cjs.js +28 -30
- package/dist/xstate.cjs.mjs +0 -2
- package/dist/xstate.development.cjs.js +28 -30
- package/dist/xstate.development.cjs.mjs +0 -2
- package/dist/xstate.development.esm.js +21 -21
- package/dist/xstate.esm.js +21 -21
- 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
- package/dist/declarations/src/actions/choose.d.ts +0 -9
- package/dist/declarations/src/actions/pure.d.ts +0 -10
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
|
|
6
|
+
var guards_dist_xstateGuards = require('./raise-a8367773.cjs.js');
|
|
7
|
+
var log = require('./log-717bb5a1.cjs.js');
|
|
8
8
|
require('../dev/dist/xstate-dev.cjs.js');
|
|
9
9
|
|
|
10
10
|
class SimulatedClock {
|
|
@@ -254,8 +254,8 @@ class StateNode {
|
|
|
254
254
|
src,
|
|
255
255
|
systemId
|
|
256
256
|
} = invokeConfig;
|
|
257
|
-
const resolvedId = invokeConfig.id
|
|
258
|
-
const resolvedSrc = typeof src === 'string' ? src : `xstate
|
|
257
|
+
const resolvedId = invokeConfig.id ?? guards_dist_xstateGuards.createInvokeId(this.id, i);
|
|
258
|
+
const resolvedSrc = typeof src === 'string' ? src : `xstate.invoke.${guards_dist_xstateGuards.createInvokeId(this.id, i)}`;
|
|
259
259
|
return {
|
|
260
260
|
...invokeConfig,
|
|
261
261
|
src: resolvedSrc,
|
|
@@ -297,7 +297,7 @@ class StateNode {
|
|
|
297
297
|
get initial() {
|
|
298
298
|
return memo(this, 'initial', () => guards_dist_xstateGuards.formatInitialTransition(this, this.config.initial));
|
|
299
299
|
}
|
|
300
|
-
next(
|
|
300
|
+
next(snapshot, event) {
|
|
301
301
|
const eventType = event.type;
|
|
302
302
|
const actions = [];
|
|
303
303
|
let selectedTransition;
|
|
@@ -306,10 +306,10 @@ class StateNode {
|
|
|
306
306
|
const {
|
|
307
307
|
guard
|
|
308
308
|
} = candidate;
|
|
309
|
-
const resolvedContext =
|
|
309
|
+
const resolvedContext = snapshot.context;
|
|
310
310
|
let guardPassed = false;
|
|
311
311
|
try {
|
|
312
|
-
guardPassed = !guard || guards_dist_xstateGuards.evaluateGuard(guard, resolvedContext, event,
|
|
312
|
+
guardPassed = !guard || guards_dist_xstateGuards.evaluateGuard(guard, resolvedContext, event, snapshot);
|
|
313
313
|
} catch (err) {
|
|
314
314
|
const guardType = typeof guard === 'string' ? guard : typeof guard === 'object' ? guard.type : undefined;
|
|
315
315
|
throw new Error(`Unable to evaluate guard ${guardType ? `'${guardType}' ` : ''}in transition for event '${eventType}' in state node '${this.id}':\n${err.message}`);
|
|
@@ -390,7 +390,7 @@ class StateMachine {
|
|
|
390
390
|
this.version = this.config.version;
|
|
391
391
|
this.transition = this.transition.bind(this);
|
|
392
392
|
this.getInitialState = this.getInitialState.bind(this);
|
|
393
|
-
this.
|
|
393
|
+
this.restoreSnapshot = this.restoreSnapshot.bind(this);
|
|
394
394
|
this.start = this.start.bind(this);
|
|
395
395
|
this.root = new StateNode(config, {
|
|
396
396
|
_key: this.id,
|
|
@@ -458,7 +458,7 @@ class StateMachine {
|
|
|
458
458
|
* @param event The received event
|
|
459
459
|
*/
|
|
460
460
|
transition(snapshot, event, actorScope) {
|
|
461
|
-
return guards_dist_xstateGuards.macrostep(snapshot, event, actorScope).
|
|
461
|
+
return guards_dist_xstateGuards.macrostep(snapshot, event, actorScope).snapshot;
|
|
462
462
|
}
|
|
463
463
|
|
|
464
464
|
/**
|
|
@@ -468,8 +468,8 @@ class StateMachine {
|
|
|
468
468
|
* @param state The current state
|
|
469
469
|
* @param event The received event
|
|
470
470
|
*/
|
|
471
|
-
microstep(
|
|
472
|
-
return guards_dist_xstateGuards.macrostep(
|
|
471
|
+
microstep(snapshot, event, actorScope) {
|
|
472
|
+
return guards_dist_xstateGuards.macrostep(snapshot, event, actorScope).microstates;
|
|
473
473
|
}
|
|
474
474
|
getTransitionData(snapshot, event) {
|
|
475
475
|
return guards_dist_xstateGuards.transitionNode(this.root, snapshot.value, snapshot, event) || [];
|
|
@@ -497,7 +497,7 @@ class StateMachine {
|
|
|
497
497
|
spawn,
|
|
498
498
|
input: event.input
|
|
499
499
|
});
|
|
500
|
-
return guards_dist_xstateGuards.resolveActionsAndContext(preInitial, initEvent, actorScope, [
|
|
500
|
+
return guards_dist_xstateGuards.resolveActionsAndContext(preInitial, initEvent, actorScope, [log.assign(assignment)], internalQueue);
|
|
501
501
|
}
|
|
502
502
|
return preInitial;
|
|
503
503
|
}
|
|
@@ -518,12 +518,12 @@ class StateMachine {
|
|
|
518
518
|
toJSON: null // TODO: fix
|
|
519
519
|
}], preInitialState, actorScope, initEvent, true, internalQueue);
|
|
520
520
|
const {
|
|
521
|
-
|
|
521
|
+
snapshot: macroState
|
|
522
522
|
} = guards_dist_xstateGuards.macrostep(nextState, initEvent, actorScope, internalQueue);
|
|
523
523
|
return macroState;
|
|
524
524
|
}
|
|
525
|
-
start(
|
|
526
|
-
Object.values(
|
|
525
|
+
start(snapshot) {
|
|
526
|
+
Object.values(snapshot.children).forEach(child => {
|
|
527
527
|
if (child.getSnapshot().status === 'active') {
|
|
528
528
|
child.start();
|
|
529
529
|
}
|
|
@@ -545,15 +545,15 @@ class StateMachine {
|
|
|
545
545
|
toJSON() {
|
|
546
546
|
return this.definition;
|
|
547
547
|
}
|
|
548
|
-
|
|
549
|
-
return guards_dist_xstateGuards.
|
|
548
|
+
getPersistedSnapshot(snapshot, options) {
|
|
549
|
+
return guards_dist_xstateGuards.getPersistedSnapshot(snapshot, options);
|
|
550
550
|
}
|
|
551
|
-
|
|
551
|
+
restoreSnapshot(snapshot, _actorScope) {
|
|
552
552
|
const children = {};
|
|
553
553
|
const snapshotChildren = snapshot.children;
|
|
554
554
|
Object.keys(snapshotChildren).forEach(actorId => {
|
|
555
555
|
const actorData = snapshotChildren[actorId];
|
|
556
|
-
const childState = actorData.
|
|
556
|
+
const childState = actorData.snapshot;
|
|
557
557
|
const src = actorData.src;
|
|
558
558
|
const logic = typeof src === 'string' ? guards_dist_xstateGuards.resolveReferencedActor(this, src) : src;
|
|
559
559
|
if (!logic) {
|
|
@@ -563,7 +563,7 @@ class StateMachine {
|
|
|
563
563
|
id: actorId,
|
|
564
564
|
parent: _actorScope?.self,
|
|
565
565
|
syncSnapshot: actorData.syncSnapshot,
|
|
566
|
-
|
|
566
|
+
snapshot: childState,
|
|
567
567
|
src,
|
|
568
568
|
systemId: actorData.systemId
|
|
569
569
|
});
|
|
@@ -716,16 +716,14 @@ exports.stateIn = guards_dist_xstateGuards.stateIn;
|
|
|
716
716
|
exports.stop = guards_dist_xstateGuards.stop;
|
|
717
717
|
exports.stopChild = guards_dist_xstateGuards.stopChild;
|
|
718
718
|
exports.toObserver = guards_dist_xstateGuards.toObserver;
|
|
719
|
-
exports.SpecialTargets =
|
|
720
|
-
exports.assign =
|
|
721
|
-
exports.
|
|
722
|
-
exports.
|
|
723
|
-
exports.
|
|
724
|
-
exports.
|
|
725
|
-
exports.
|
|
726
|
-
exports.
|
|
727
|
-
exports.sendParent = pure.sendParent;
|
|
728
|
-
exports.sendTo = pure.sendTo;
|
|
719
|
+
exports.SpecialTargets = log.SpecialTargets;
|
|
720
|
+
exports.assign = log.assign;
|
|
721
|
+
exports.enqueueActions = log.enqueueActions;
|
|
722
|
+
exports.escalate = log.escalate;
|
|
723
|
+
exports.forwardTo = log.forwardTo;
|
|
724
|
+
exports.log = log.log;
|
|
725
|
+
exports.sendParent = log.sendParent;
|
|
726
|
+
exports.sendTo = log.sendTo;
|
|
729
727
|
exports.SimulatedClock = SimulatedClock;
|
|
730
728
|
exports.StateMachine = StateMachine;
|
|
731
729
|
exports.StateNode = StateNode;
|
package/dist/xstate.cjs.mjs
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.development.cjs.js');
|
|
6
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
7
|
-
var
|
|
6
|
+
var guards_dist_xstateGuards = require('./raise-d9fd8932.development.cjs.js');
|
|
7
|
+
var log = require('./log-c8797128.development.cjs.js');
|
|
8
8
|
require('../dev/dist/xstate-dev.development.cjs.js');
|
|
9
9
|
|
|
10
10
|
class SimulatedClock {
|
|
@@ -254,8 +254,8 @@ class StateNode {
|
|
|
254
254
|
src,
|
|
255
255
|
systemId
|
|
256
256
|
} = invokeConfig;
|
|
257
|
-
const resolvedId = invokeConfig.id
|
|
258
|
-
const resolvedSrc = typeof src === 'string' ? src : `xstate
|
|
257
|
+
const resolvedId = invokeConfig.id ?? guards_dist_xstateGuards.createInvokeId(this.id, i);
|
|
258
|
+
const resolvedSrc = typeof src === 'string' ? src : `xstate.invoke.${guards_dist_xstateGuards.createInvokeId(this.id, i)}`;
|
|
259
259
|
return {
|
|
260
260
|
...invokeConfig,
|
|
261
261
|
src: resolvedSrc,
|
|
@@ -297,7 +297,7 @@ class StateNode {
|
|
|
297
297
|
get initial() {
|
|
298
298
|
return memo(this, 'initial', () => guards_dist_xstateGuards.formatInitialTransition(this, this.config.initial));
|
|
299
299
|
}
|
|
300
|
-
next(
|
|
300
|
+
next(snapshot, event) {
|
|
301
301
|
const eventType = event.type;
|
|
302
302
|
const actions = [];
|
|
303
303
|
let selectedTransition;
|
|
@@ -306,10 +306,10 @@ class StateNode {
|
|
|
306
306
|
const {
|
|
307
307
|
guard
|
|
308
308
|
} = candidate;
|
|
309
|
-
const resolvedContext =
|
|
309
|
+
const resolvedContext = snapshot.context;
|
|
310
310
|
let guardPassed = false;
|
|
311
311
|
try {
|
|
312
|
-
guardPassed = !guard || guards_dist_xstateGuards.evaluateGuard(guard, resolvedContext, event,
|
|
312
|
+
guardPassed = !guard || guards_dist_xstateGuards.evaluateGuard(guard, resolvedContext, event, snapshot);
|
|
313
313
|
} catch (err) {
|
|
314
314
|
const guardType = typeof guard === 'string' ? guard : typeof guard === 'object' ? guard.type : undefined;
|
|
315
315
|
throw new Error(`Unable to evaluate guard ${guardType ? `'${guardType}' ` : ''}in transition for event '${eventType}' in state node '${this.id}':\n${err.message}`);
|
|
@@ -390,7 +390,7 @@ class StateMachine {
|
|
|
390
390
|
this.version = this.config.version;
|
|
391
391
|
this.transition = this.transition.bind(this);
|
|
392
392
|
this.getInitialState = this.getInitialState.bind(this);
|
|
393
|
-
this.
|
|
393
|
+
this.restoreSnapshot = this.restoreSnapshot.bind(this);
|
|
394
394
|
this.start = this.start.bind(this);
|
|
395
395
|
this.root = new StateNode(config, {
|
|
396
396
|
_key: this.id,
|
|
@@ -461,7 +461,7 @@ class StateMachine {
|
|
|
461
461
|
* @param event The received event
|
|
462
462
|
*/
|
|
463
463
|
transition(snapshot, event, actorScope) {
|
|
464
|
-
return guards_dist_xstateGuards.macrostep(snapshot, event, actorScope).
|
|
464
|
+
return guards_dist_xstateGuards.macrostep(snapshot, event, actorScope).snapshot;
|
|
465
465
|
}
|
|
466
466
|
|
|
467
467
|
/**
|
|
@@ -471,8 +471,8 @@ class StateMachine {
|
|
|
471
471
|
* @param state The current state
|
|
472
472
|
* @param event The received event
|
|
473
473
|
*/
|
|
474
|
-
microstep(
|
|
475
|
-
return guards_dist_xstateGuards.macrostep(
|
|
474
|
+
microstep(snapshot, event, actorScope) {
|
|
475
|
+
return guards_dist_xstateGuards.macrostep(snapshot, event, actorScope).microstates;
|
|
476
476
|
}
|
|
477
477
|
getTransitionData(snapshot, event) {
|
|
478
478
|
return guards_dist_xstateGuards.transitionNode(this.root, snapshot.value, snapshot, event) || [];
|
|
@@ -500,7 +500,7 @@ class StateMachine {
|
|
|
500
500
|
spawn,
|
|
501
501
|
input: event.input
|
|
502
502
|
});
|
|
503
|
-
return guards_dist_xstateGuards.resolveActionsAndContext(preInitial, initEvent, actorScope, [
|
|
503
|
+
return guards_dist_xstateGuards.resolveActionsAndContext(preInitial, initEvent, actorScope, [log.assign(assignment)], internalQueue);
|
|
504
504
|
}
|
|
505
505
|
return preInitial;
|
|
506
506
|
}
|
|
@@ -521,12 +521,12 @@ class StateMachine {
|
|
|
521
521
|
toJSON: null // TODO: fix
|
|
522
522
|
}], preInitialState, actorScope, initEvent, true, internalQueue);
|
|
523
523
|
const {
|
|
524
|
-
|
|
524
|
+
snapshot: macroState
|
|
525
525
|
} = guards_dist_xstateGuards.macrostep(nextState, initEvent, actorScope, internalQueue);
|
|
526
526
|
return macroState;
|
|
527
527
|
}
|
|
528
|
-
start(
|
|
529
|
-
Object.values(
|
|
528
|
+
start(snapshot) {
|
|
529
|
+
Object.values(snapshot.children).forEach(child => {
|
|
530
530
|
if (child.getSnapshot().status === 'active') {
|
|
531
531
|
child.start();
|
|
532
532
|
}
|
|
@@ -548,15 +548,15 @@ class StateMachine {
|
|
|
548
548
|
toJSON() {
|
|
549
549
|
return this.definition;
|
|
550
550
|
}
|
|
551
|
-
|
|
552
|
-
return guards_dist_xstateGuards.
|
|
551
|
+
getPersistedSnapshot(snapshot, options) {
|
|
552
|
+
return guards_dist_xstateGuards.getPersistedSnapshot(snapshot, options);
|
|
553
553
|
}
|
|
554
|
-
|
|
554
|
+
restoreSnapshot(snapshot, _actorScope) {
|
|
555
555
|
const children = {};
|
|
556
556
|
const snapshotChildren = snapshot.children;
|
|
557
557
|
Object.keys(snapshotChildren).forEach(actorId => {
|
|
558
558
|
const actorData = snapshotChildren[actorId];
|
|
559
|
-
const childState = actorData.
|
|
559
|
+
const childState = actorData.snapshot;
|
|
560
560
|
const src = actorData.src;
|
|
561
561
|
const logic = typeof src === 'string' ? guards_dist_xstateGuards.resolveReferencedActor(this, src) : src;
|
|
562
562
|
if (!logic) {
|
|
@@ -566,7 +566,7 @@ class StateMachine {
|
|
|
566
566
|
id: actorId,
|
|
567
567
|
parent: _actorScope?.self,
|
|
568
568
|
syncSnapshot: actorData.syncSnapshot,
|
|
569
|
-
|
|
569
|
+
snapshot: childState,
|
|
570
570
|
src,
|
|
571
571
|
systemId: actorData.systemId
|
|
572
572
|
});
|
|
@@ -722,16 +722,14 @@ exports.stateIn = guards_dist_xstateGuards.stateIn;
|
|
|
722
722
|
exports.stop = guards_dist_xstateGuards.stop;
|
|
723
723
|
exports.stopChild = guards_dist_xstateGuards.stopChild;
|
|
724
724
|
exports.toObserver = guards_dist_xstateGuards.toObserver;
|
|
725
|
-
exports.SpecialTargets =
|
|
726
|
-
exports.assign =
|
|
727
|
-
exports.
|
|
728
|
-
exports.
|
|
729
|
-
exports.
|
|
730
|
-
exports.
|
|
731
|
-
exports.
|
|
732
|
-
exports.
|
|
733
|
-
exports.sendParent = pure.sendParent;
|
|
734
|
-
exports.sendTo = pure.sendTo;
|
|
725
|
+
exports.SpecialTargets = log.SpecialTargets;
|
|
726
|
+
exports.assign = log.assign;
|
|
727
|
+
exports.enqueueActions = log.enqueueActions;
|
|
728
|
+
exports.escalate = log.escalate;
|
|
729
|
+
exports.forwardTo = log.forwardTo;
|
|
730
|
+
exports.log = log.log;
|
|
731
|
+
exports.sendParent = log.sendParent;
|
|
732
|
+
exports.sendTo = log.sendTo;
|
|
735
733
|
exports.SimulatedClock = SimulatedClock;
|
|
736
734
|
exports.StateMachine = StateMachine;
|
|
737
735
|
exports.StateNode = StateNode;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.development.esm.js';
|
|
2
|
-
import { S as STATE_DELIMITER, m as mapValues, t as toArray, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as macrostep, o as transitionNode, p as resolveActionsAndContext, q as createInitEvent, s as microstep, u as getInitialStateNodes, v as isStateId, w as getStateNodeByPath, x as
|
|
3
|
-
export { A as Actor, G as __unsafe_getAllOwnEventDescriptors, H as and, L as cancel, z as createActor, j as getStateNodes, B as interpret, C as isMachineSnapshot, D as matchesState, I as not, J as or, E as pathToStateValue, M as raise, O as spawnChild, K as stateIn, P as stop, Q as stopChild, F as toObserver } from './raise-
|
|
4
|
-
import { a as assign } from './
|
|
5
|
-
export { S as SpecialTargets, a as assign,
|
|
2
|
+
import { S as STATE_DELIMITER, m as mapValues, t as toArray, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as macrostep, o as transitionNode, p as resolveActionsAndContext, q as createInitEvent, s as microstep, u as getInitialStateNodes, v as isStateId, w as getStateNodeByPath, x as getPersistedSnapshot, y as resolveReferencedActor, z as createActor, $ as $$ACTOR_TYPE } from './raise-953b1eb5.development.esm.js';
|
|
3
|
+
export { A as Actor, G as __unsafe_getAllOwnEventDescriptors, H as and, L as cancel, z as createActor, j as getStateNodes, B as interpret, C as isMachineSnapshot, D as matchesState, I as not, J as or, E as pathToStateValue, M as raise, O as spawnChild, K as stateIn, P as stop, Q as stopChild, F as toObserver } from './raise-953b1eb5.development.esm.js';
|
|
4
|
+
import { a as assign } from './log-1fd7d00a.development.esm.js';
|
|
5
|
+
export { S as SpecialTargets, a as assign, e as enqueueActions, b as escalate, f as forwardTo, l as log, s as sendParent, c as sendTo } from './log-1fd7d00a.development.esm.js';
|
|
6
6
|
import '../dev/dist/xstate-dev.development.esm.js';
|
|
7
7
|
|
|
8
8
|
class SimulatedClock {
|
|
@@ -252,8 +252,8 @@ class StateNode {
|
|
|
252
252
|
src,
|
|
253
253
|
systemId
|
|
254
254
|
} = invokeConfig;
|
|
255
|
-
const resolvedId = invokeConfig.id
|
|
256
|
-
const resolvedSrc = typeof src === 'string' ? src : `xstate
|
|
255
|
+
const resolvedId = invokeConfig.id ?? createInvokeId(this.id, i);
|
|
256
|
+
const resolvedSrc = typeof src === 'string' ? src : `xstate.invoke.${createInvokeId(this.id, i)}`;
|
|
257
257
|
return {
|
|
258
258
|
...invokeConfig,
|
|
259
259
|
src: resolvedSrc,
|
|
@@ -295,7 +295,7 @@ class StateNode {
|
|
|
295
295
|
get initial() {
|
|
296
296
|
return memo(this, 'initial', () => formatInitialTransition(this, this.config.initial));
|
|
297
297
|
}
|
|
298
|
-
next(
|
|
298
|
+
next(snapshot, event) {
|
|
299
299
|
const eventType = event.type;
|
|
300
300
|
const actions = [];
|
|
301
301
|
let selectedTransition;
|
|
@@ -304,10 +304,10 @@ class StateNode {
|
|
|
304
304
|
const {
|
|
305
305
|
guard
|
|
306
306
|
} = candidate;
|
|
307
|
-
const resolvedContext =
|
|
307
|
+
const resolvedContext = snapshot.context;
|
|
308
308
|
let guardPassed = false;
|
|
309
309
|
try {
|
|
310
|
-
guardPassed = !guard || evaluateGuard(guard, resolvedContext, event,
|
|
310
|
+
guardPassed = !guard || evaluateGuard(guard, resolvedContext, event, snapshot);
|
|
311
311
|
} catch (err) {
|
|
312
312
|
const guardType = typeof guard === 'string' ? guard : typeof guard === 'object' ? guard.type : undefined;
|
|
313
313
|
throw new Error(`Unable to evaluate guard ${guardType ? `'${guardType}' ` : ''}in transition for event '${eventType}' in state node '${this.id}':\n${err.message}`);
|
|
@@ -388,7 +388,7 @@ class StateMachine {
|
|
|
388
388
|
this.version = this.config.version;
|
|
389
389
|
this.transition = this.transition.bind(this);
|
|
390
390
|
this.getInitialState = this.getInitialState.bind(this);
|
|
391
|
-
this.
|
|
391
|
+
this.restoreSnapshot = this.restoreSnapshot.bind(this);
|
|
392
392
|
this.start = this.start.bind(this);
|
|
393
393
|
this.root = new StateNode(config, {
|
|
394
394
|
_key: this.id,
|
|
@@ -459,7 +459,7 @@ class StateMachine {
|
|
|
459
459
|
* @param event The received event
|
|
460
460
|
*/
|
|
461
461
|
transition(snapshot, event, actorScope) {
|
|
462
|
-
return macrostep(snapshot, event, actorScope).
|
|
462
|
+
return macrostep(snapshot, event, actorScope).snapshot;
|
|
463
463
|
}
|
|
464
464
|
|
|
465
465
|
/**
|
|
@@ -469,8 +469,8 @@ class StateMachine {
|
|
|
469
469
|
* @param state The current state
|
|
470
470
|
* @param event The received event
|
|
471
471
|
*/
|
|
472
|
-
microstep(
|
|
473
|
-
return macrostep(
|
|
472
|
+
microstep(snapshot, event, actorScope) {
|
|
473
|
+
return macrostep(snapshot, event, actorScope).microstates;
|
|
474
474
|
}
|
|
475
475
|
getTransitionData(snapshot, event) {
|
|
476
476
|
return transitionNode(this.root, snapshot.value, snapshot, event) || [];
|
|
@@ -519,12 +519,12 @@ class StateMachine {
|
|
|
519
519
|
toJSON: null // TODO: fix
|
|
520
520
|
}], preInitialState, actorScope, initEvent, true, internalQueue);
|
|
521
521
|
const {
|
|
522
|
-
|
|
522
|
+
snapshot: macroState
|
|
523
523
|
} = macrostep(nextState, initEvent, actorScope, internalQueue);
|
|
524
524
|
return macroState;
|
|
525
525
|
}
|
|
526
|
-
start(
|
|
527
|
-
Object.values(
|
|
526
|
+
start(snapshot) {
|
|
527
|
+
Object.values(snapshot.children).forEach(child => {
|
|
528
528
|
if (child.getSnapshot().status === 'active') {
|
|
529
529
|
child.start();
|
|
530
530
|
}
|
|
@@ -546,15 +546,15 @@ class StateMachine {
|
|
|
546
546
|
toJSON() {
|
|
547
547
|
return this.definition;
|
|
548
548
|
}
|
|
549
|
-
|
|
550
|
-
return
|
|
549
|
+
getPersistedSnapshot(snapshot, options) {
|
|
550
|
+
return getPersistedSnapshot(snapshot, options);
|
|
551
551
|
}
|
|
552
|
-
|
|
552
|
+
restoreSnapshot(snapshot, _actorScope) {
|
|
553
553
|
const children = {};
|
|
554
554
|
const snapshotChildren = snapshot.children;
|
|
555
555
|
Object.keys(snapshotChildren).forEach(actorId => {
|
|
556
556
|
const actorData = snapshotChildren[actorId];
|
|
557
|
-
const childState = actorData.
|
|
557
|
+
const childState = actorData.snapshot;
|
|
558
558
|
const src = actorData.src;
|
|
559
559
|
const logic = typeof src === 'string' ? resolveReferencedActor(this, src) : src;
|
|
560
560
|
if (!logic) {
|
|
@@ -564,7 +564,7 @@ class StateMachine {
|
|
|
564
564
|
id: actorId,
|
|
565
565
|
parent: _actorScope?.self,
|
|
566
566
|
syncSnapshot: actorData.syncSnapshot,
|
|
567
|
-
|
|
567
|
+
snapshot: childState,
|
|
568
568
|
src,
|
|
569
569
|
systemId: actorData.systemId
|
|
570
570
|
});
|
package/dist/xstate.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.esm.js';
|
|
2
|
-
import { S as STATE_DELIMITER, m as mapValues, t as toArray, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as macrostep, o as transitionNode, p as resolveActionsAndContext, q as createInitEvent, s as microstep, u as getInitialStateNodes, v as isStateId, w as getStateNodeByPath, x as
|
|
3
|
-
export { A as Actor, G as __unsafe_getAllOwnEventDescriptors, H as and, L as cancel, z as createActor, j as getStateNodes, B as interpret, C as isMachineSnapshot, D as matchesState, I as not, J as or, E as pathToStateValue, M as raise, O as spawnChild, K as stateIn, P as stop, Q as stopChild, F as toObserver } from './raise-
|
|
4
|
-
import { a as assign } from './
|
|
5
|
-
export { S as SpecialTargets, a as assign,
|
|
2
|
+
import { S as STATE_DELIMITER, m as mapValues, t as toArray, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as macrostep, o as transitionNode, p as resolveActionsAndContext, q as createInitEvent, s as microstep, u as getInitialStateNodes, v as isStateId, w as getStateNodeByPath, x as getPersistedSnapshot, y as resolveReferencedActor, z as createActor, $ as $$ACTOR_TYPE } from './raise-be2f20bc.esm.js';
|
|
3
|
+
export { A as Actor, G as __unsafe_getAllOwnEventDescriptors, H as and, L as cancel, z as createActor, j as getStateNodes, B as interpret, C as isMachineSnapshot, D as matchesState, I as not, J as or, E as pathToStateValue, M as raise, O as spawnChild, K as stateIn, P as stop, Q as stopChild, F as toObserver } from './raise-be2f20bc.esm.js';
|
|
4
|
+
import { a as assign } from './log-60ab9eaf.esm.js';
|
|
5
|
+
export { S as SpecialTargets, a as assign, e as enqueueActions, b as escalate, f as forwardTo, l as log, s as sendParent, c as sendTo } from './log-60ab9eaf.esm.js';
|
|
6
6
|
import '../dev/dist/xstate-dev.esm.js';
|
|
7
7
|
|
|
8
8
|
class SimulatedClock {
|
|
@@ -252,8 +252,8 @@ class StateNode {
|
|
|
252
252
|
src,
|
|
253
253
|
systemId
|
|
254
254
|
} = invokeConfig;
|
|
255
|
-
const resolvedId = invokeConfig.id
|
|
256
|
-
const resolvedSrc = typeof src === 'string' ? src : `xstate
|
|
255
|
+
const resolvedId = invokeConfig.id ?? createInvokeId(this.id, i);
|
|
256
|
+
const resolvedSrc = typeof src === 'string' ? src : `xstate.invoke.${createInvokeId(this.id, i)}`;
|
|
257
257
|
return {
|
|
258
258
|
...invokeConfig,
|
|
259
259
|
src: resolvedSrc,
|
|
@@ -295,7 +295,7 @@ class StateNode {
|
|
|
295
295
|
get initial() {
|
|
296
296
|
return memo(this, 'initial', () => formatInitialTransition(this, this.config.initial));
|
|
297
297
|
}
|
|
298
|
-
next(
|
|
298
|
+
next(snapshot, event) {
|
|
299
299
|
const eventType = event.type;
|
|
300
300
|
const actions = [];
|
|
301
301
|
let selectedTransition;
|
|
@@ -304,10 +304,10 @@ class StateNode {
|
|
|
304
304
|
const {
|
|
305
305
|
guard
|
|
306
306
|
} = candidate;
|
|
307
|
-
const resolvedContext =
|
|
307
|
+
const resolvedContext = snapshot.context;
|
|
308
308
|
let guardPassed = false;
|
|
309
309
|
try {
|
|
310
|
-
guardPassed = !guard || evaluateGuard(guard, resolvedContext, event,
|
|
310
|
+
guardPassed = !guard || evaluateGuard(guard, resolvedContext, event, snapshot);
|
|
311
311
|
} catch (err) {
|
|
312
312
|
const guardType = typeof guard === 'string' ? guard : typeof guard === 'object' ? guard.type : undefined;
|
|
313
313
|
throw new Error(`Unable to evaluate guard ${guardType ? `'${guardType}' ` : ''}in transition for event '${eventType}' in state node '${this.id}':\n${err.message}`);
|
|
@@ -388,7 +388,7 @@ class StateMachine {
|
|
|
388
388
|
this.version = this.config.version;
|
|
389
389
|
this.transition = this.transition.bind(this);
|
|
390
390
|
this.getInitialState = this.getInitialState.bind(this);
|
|
391
|
-
this.
|
|
391
|
+
this.restoreSnapshot = this.restoreSnapshot.bind(this);
|
|
392
392
|
this.start = this.start.bind(this);
|
|
393
393
|
this.root = new StateNode(config, {
|
|
394
394
|
_key: this.id,
|
|
@@ -456,7 +456,7 @@ class StateMachine {
|
|
|
456
456
|
* @param event The received event
|
|
457
457
|
*/
|
|
458
458
|
transition(snapshot, event, actorScope) {
|
|
459
|
-
return macrostep(snapshot, event, actorScope).
|
|
459
|
+
return macrostep(snapshot, event, actorScope).snapshot;
|
|
460
460
|
}
|
|
461
461
|
|
|
462
462
|
/**
|
|
@@ -466,8 +466,8 @@ class StateMachine {
|
|
|
466
466
|
* @param state The current state
|
|
467
467
|
* @param event The received event
|
|
468
468
|
*/
|
|
469
|
-
microstep(
|
|
470
|
-
return macrostep(
|
|
469
|
+
microstep(snapshot, event, actorScope) {
|
|
470
|
+
return macrostep(snapshot, event, actorScope).microstates;
|
|
471
471
|
}
|
|
472
472
|
getTransitionData(snapshot, event) {
|
|
473
473
|
return transitionNode(this.root, snapshot.value, snapshot, event) || [];
|
|
@@ -516,12 +516,12 @@ class StateMachine {
|
|
|
516
516
|
toJSON: null // TODO: fix
|
|
517
517
|
}], preInitialState, actorScope, initEvent, true, internalQueue);
|
|
518
518
|
const {
|
|
519
|
-
|
|
519
|
+
snapshot: macroState
|
|
520
520
|
} = macrostep(nextState, initEvent, actorScope, internalQueue);
|
|
521
521
|
return macroState;
|
|
522
522
|
}
|
|
523
|
-
start(
|
|
524
|
-
Object.values(
|
|
523
|
+
start(snapshot) {
|
|
524
|
+
Object.values(snapshot.children).forEach(child => {
|
|
525
525
|
if (child.getSnapshot().status === 'active') {
|
|
526
526
|
child.start();
|
|
527
527
|
}
|
|
@@ -543,15 +543,15 @@ class StateMachine {
|
|
|
543
543
|
toJSON() {
|
|
544
544
|
return this.definition;
|
|
545
545
|
}
|
|
546
|
-
|
|
547
|
-
return
|
|
546
|
+
getPersistedSnapshot(snapshot, options) {
|
|
547
|
+
return getPersistedSnapshot(snapshot, options);
|
|
548
548
|
}
|
|
549
|
-
|
|
549
|
+
restoreSnapshot(snapshot, _actorScope) {
|
|
550
550
|
const children = {};
|
|
551
551
|
const snapshotChildren = snapshot.children;
|
|
552
552
|
Object.keys(snapshotChildren).forEach(actorId => {
|
|
553
553
|
const actorData = snapshotChildren[actorId];
|
|
554
|
-
const childState = actorData.
|
|
554
|
+
const childState = actorData.snapshot;
|
|
555
555
|
const src = actorData.src;
|
|
556
556
|
const logic = typeof src === 'string' ? resolveReferencedActor(this, src) : src;
|
|
557
557
|
if (!logic) {
|
|
@@ -561,7 +561,7 @@ class StateMachine {
|
|
|
561
561
|
id: actorId,
|
|
562
562
|
parent: _actorScope?.self,
|
|
563
563
|
syncSnapshot: actorData.syncSnapshot,
|
|
564
|
-
|
|
564
|
+
snapshot: childState,
|
|
565
565
|
src,
|
|
566
566
|
systemId: actorData.systemId
|
|
567
567
|
});
|