xstate 5.0.0-beta.41 → 5.0.0-beta.42
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 +3 -3
- package/actions/dist/xstate-actions.development.cjs.js +3 -3
- package/actions/dist/xstate-actions.development.esm.js +3 -3
- package/actions/dist/xstate-actions.esm.js +3 -3
- 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 +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/dist/declarations/src/State.d.ts +35 -42
- package/dist/declarations/src/StateMachine.d.ts +12 -29
- package/dist/declarations/src/StateNode.d.ts +2 -2
- package/dist/declarations/src/index.d.ts +3 -4
- package/dist/declarations/src/interpreter.d.ts +12 -0
- package/dist/declarations/src/stateUtils.d.ts +7 -8
- package/dist/declarations/src/types.d.ts +112 -15
- package/dist/{interpreter-70ed981b.development.cjs.js → interpreter-23e4041c.development.cjs.js} +23 -10
- package/dist/{interpreter-480db258.esm.js → interpreter-3d0c0ff2.esm.js} +24 -10
- package/dist/{interpreter-fb2829f1.cjs.js → interpreter-b6bdd134.cjs.js} +23 -10
- package/dist/{interpreter-936da690.development.esm.js → interpreter-f2620ea7.development.esm.js} +24 -10
- package/dist/{raise-f757be00.development.esm.js → raise-51ae36e5.development.esm.js} +76 -175
- package/dist/{raise-beae3fd3.cjs.js → raise-6b64c553.cjs.js} +74 -174
- package/dist/{raise-5ab465ed.development.cjs.js → raise-8f482ce9.development.cjs.js} +77 -177
- package/dist/{raise-9d6921da.esm.js → raise-d2084327.esm.js} +73 -172
- package/dist/{send-a931d1b8.esm.js → send-4e732fa5.esm.js} +5 -3
- package/dist/{send-b26e3812.development.esm.js → send-7a350091.development.esm.js} +5 -3
- package/dist/{send-ca5f706c.cjs.js → send-85b562d8.cjs.js} +5 -3
- package/dist/{send-fb87a01a.development.cjs.js → send-cc8f864e.development.cjs.js} +5 -3
- package/dist/xstate.cjs.js +23 -49
- package/dist/xstate.cjs.mjs +0 -2
- package/dist/xstate.development.cjs.js +23 -49
- package/dist/xstate.development.cjs.mjs +0 -2
- package/dist/xstate.development.esm.js +27 -51
- package/dist/xstate.esm.js +27 -51
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/guards/dist/xstate-guards.cjs.js +2 -2
- package/guards/dist/xstate-guards.development.cjs.js +2 -2
- package/guards/dist/xstate-guards.development.esm.js +2 -2
- package/guards/dist/xstate-guards.esm.js +2 -2
- package/guards/dist/xstate-guards.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/declarations/src/mapState.d.ts +0 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
4
|
-
var interpreter = require('./interpreter-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-6b64c553.cjs.js');
|
|
4
|
+
var interpreter = require('./interpreter-b6bdd134.cjs.js');
|
|
5
5
|
|
|
6
6
|
function createSpawner(actorScope, {
|
|
7
7
|
machine,
|
|
@@ -112,7 +112,7 @@ function resolveAssign(actorScope, state, actionArgs, actionParams, {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
const updatedContext = Object.assign({}, state.context, partialUpdate);
|
|
115
|
-
return [guards_dist_xstateGuards.
|
|
115
|
+
return [guards_dist_xstateGuards.cloneMachineSnapshot(state, {
|
|
116
116
|
context: updatedContext,
|
|
117
117
|
children: Object.keys(spawnedChildren).length ? {
|
|
118
118
|
...state.children,
|
|
@@ -247,6 +247,8 @@ function pure(getActions) {
|
|
|
247
247
|
|
|
248
248
|
// TODO: remove once TS fixes this type-widening issue
|
|
249
249
|
|
|
250
|
+
// TODO: replace with AnyMachineSnapshot
|
|
251
|
+
|
|
250
252
|
// TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
|
|
251
253
|
|
|
252
254
|
let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
4
|
-
var interpreter = require('./interpreter-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-8f482ce9.development.cjs.js');
|
|
4
|
+
var interpreter = require('./interpreter-23e4041c.development.cjs.js');
|
|
5
5
|
|
|
6
6
|
function createSpawner(actorScope, {
|
|
7
7
|
machine,
|
|
@@ -112,7 +112,7 @@ function resolveAssign(actorScope, state, actionArgs, actionParams, {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
const updatedContext = Object.assign({}, state.context, partialUpdate);
|
|
115
|
-
return [guards_dist_xstateGuards.
|
|
115
|
+
return [guards_dist_xstateGuards.cloneMachineSnapshot(state, {
|
|
116
116
|
context: updatedContext,
|
|
117
117
|
children: Object.keys(spawnedChildren).length ? {
|
|
118
118
|
...state.children,
|
|
@@ -259,6 +259,8 @@ function pure(getActions) {
|
|
|
259
259
|
|
|
260
260
|
// TODO: remove once TS fixes this type-widening issue
|
|
261
261
|
|
|
262
|
+
// TODO: replace with AnyMachineSnapshot
|
|
263
|
+
|
|
262
264
|
// TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
|
|
263
265
|
|
|
264
266
|
let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
package/dist/xstate.cjs.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
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 interpreter = require('./interpreter-
|
|
7
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
8
|
-
var send = require('./send-
|
|
6
|
+
var interpreter = require('./interpreter-b6bdd134.cjs.js');
|
|
7
|
+
var guards_dist_xstateGuards = require('./raise-6b64c553.cjs.js');
|
|
8
|
+
var send = require('./send-85b562d8.cjs.js');
|
|
9
9
|
require('../dev/dist/xstate-dev.cjs.js');
|
|
10
10
|
|
|
11
11
|
class SimulatedClock {
|
|
@@ -447,27 +447,18 @@ class StateMachine {
|
|
|
447
447
|
}
|
|
448
448
|
});
|
|
449
449
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
...state,
|
|
463
|
-
value: guards_dist_xstateGuards.resolveStateValue(this.root, state.value),
|
|
464
|
-
configuration,
|
|
465
|
-
status: guards_dist_xstateGuards.isInFinalState(configurationSet, this.root) ? 'done' : state.status
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
resolveStateValue(stateValue, ...[context]) {
|
|
469
|
-
const resolvedStateValue = guards_dist_xstateGuards.resolveStateValue(this.root, stateValue);
|
|
470
|
-
return this.resolveState(guards_dist_xstateGuards.State.from(resolvedStateValue, context, this));
|
|
450
|
+
resolveState(config) {
|
|
451
|
+
const resolvedStateValue = guards_dist_xstateGuards.resolveStateValue(this.root, config.value);
|
|
452
|
+
const configurationSet = guards_dist_xstateGuards.getConfiguration(guards_dist_xstateGuards.getStateNodes(this.root, resolvedStateValue));
|
|
453
|
+
return guards_dist_xstateGuards.createMachineSnapshot({
|
|
454
|
+
configuration: [...configurationSet],
|
|
455
|
+
context: config.context || {},
|
|
456
|
+
children: {},
|
|
457
|
+
status: guards_dist_xstateGuards.isInFinalState(configurationSet, this.root) ? 'done' : config.status || 'active',
|
|
458
|
+
output: config.output,
|
|
459
|
+
error: config.error,
|
|
460
|
+
historyValue: config.historyValue
|
|
461
|
+
}, this);
|
|
471
462
|
}
|
|
472
463
|
|
|
473
464
|
/**
|
|
@@ -480,7 +471,7 @@ class StateMachine {
|
|
|
480
471
|
transition(state, event, actorScope) {
|
|
481
472
|
// TODO: handle error events in a better way
|
|
482
473
|
if (interpreter.isErrorActorEvent(event) && !state.nextEvents.some(nextEvent => nextEvent === event.type)) {
|
|
483
|
-
return guards_dist_xstateGuards.
|
|
474
|
+
return guards_dist_xstateGuards.cloneMachineSnapshot(state, {
|
|
484
475
|
status: 'error',
|
|
485
476
|
error: event.data
|
|
486
477
|
});
|
|
@@ -513,15 +504,12 @@ class StateMachine {
|
|
|
513
504
|
const {
|
|
514
505
|
context
|
|
515
506
|
} = this.config;
|
|
516
|
-
const preInitial =
|
|
517
|
-
value: {},
|
|
518
|
-
// TODO: this is computed in state constructor
|
|
507
|
+
const preInitial = guards_dist_xstateGuards.createMachineSnapshot({
|
|
519
508
|
context: typeof context !== 'function' && context ? context : {},
|
|
520
|
-
|
|
521
|
-
configuration: guards_dist_xstateGuards.getInitialConfiguration(this.root),
|
|
509
|
+
configuration: [this.root],
|
|
522
510
|
children: {},
|
|
523
511
|
status: 'active'
|
|
524
|
-
})
|
|
512
|
+
}, this);
|
|
525
513
|
if (typeof context === 'function') {
|
|
526
514
|
const assignment = ({
|
|
527
515
|
spawn,
|
|
@@ -581,9 +569,6 @@ class StateMachine {
|
|
|
581
569
|
getPersistedState(state, options) {
|
|
582
570
|
return guards_dist_xstateGuards.getPersistedState(state, options);
|
|
583
571
|
}
|
|
584
|
-
createState(stateConfig) {
|
|
585
|
-
return stateConfig instanceof guards_dist_xstateGuards.State ? stateConfig : new guards_dist_xstateGuards.State(stateConfig, this);
|
|
586
|
-
}
|
|
587
572
|
restoreState(snapshot, _actorScope) {
|
|
588
573
|
const children = {};
|
|
589
574
|
const snapshotChildren = snapshot.children;
|
|
@@ -605,10 +590,11 @@ class StateMachine {
|
|
|
605
590
|
});
|
|
606
591
|
children[actorId] = actorRef;
|
|
607
592
|
});
|
|
608
|
-
const restoredSnapshot =
|
|
593
|
+
const restoredSnapshot = guards_dist_xstateGuards.createMachineSnapshot({
|
|
609
594
|
...snapshot,
|
|
610
|
-
children
|
|
611
|
-
|
|
595
|
+
children,
|
|
596
|
+
configuration: Array.from(guards_dist_xstateGuards.getConfiguration(guards_dist_xstateGuards.getStateNodes(this.root, snapshot.value)))
|
|
597
|
+
}, this);
|
|
612
598
|
let seen = new Set();
|
|
613
599
|
function reviveContext(contextPart, children) {
|
|
614
600
|
if (seen.has(contextPart)) {
|
|
@@ -708,16 +694,6 @@ function createMachine(config, implementations) {
|
|
|
708
694
|
return new StateMachine(config, implementations);
|
|
709
695
|
}
|
|
710
696
|
|
|
711
|
-
function mapState(stateMap, stateId) {
|
|
712
|
-
let foundStateId;
|
|
713
|
-
for (const mappedStateId of Object.keys(stateMap)) {
|
|
714
|
-
if (interpreter.matchesState(mappedStateId, stateId) && (!foundStateId || stateId.length > foundStateId.length)) {
|
|
715
|
-
foundStateId = mappedStateId;
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
return stateMap[foundStateId];
|
|
719
|
-
}
|
|
720
|
-
|
|
721
697
|
exports.createEmptyActor = actors_dist_xstateActors.createEmptyActor;
|
|
722
698
|
exports.fromCallback = actors_dist_xstateActors.fromCallback;
|
|
723
699
|
exports.fromEventObservable = actors_dist_xstateActors.fromEventObservable;
|
|
@@ -730,7 +706,6 @@ exports.interpret = interpreter.interpret;
|
|
|
730
706
|
exports.matchesState = interpreter.matchesState;
|
|
731
707
|
exports.pathToStateValue = interpreter.pathToStateValue;
|
|
732
708
|
exports.toObserver = interpreter.toObserver;
|
|
733
|
-
exports.State = guards_dist_xstateGuards.State;
|
|
734
709
|
exports.and = guards_dist_xstateGuards.and;
|
|
735
710
|
exports.cancel = guards_dist_xstateGuards.cancel;
|
|
736
711
|
exports.getStateNodes = guards_dist_xstateGuards.getStateNodes;
|
|
@@ -753,5 +728,4 @@ exports.SimulatedClock = SimulatedClock;
|
|
|
753
728
|
exports.StateMachine = StateMachine;
|
|
754
729
|
exports.StateNode = StateNode;
|
|
755
730
|
exports.createMachine = createMachine;
|
|
756
|
-
exports.mapState = mapState;
|
|
757
731
|
exports.waitFor = waitFor;
|
package/dist/xstate.cjs.mjs
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
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 interpreter = require('./interpreter-
|
|
7
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
8
|
-
var send = require('./send-
|
|
6
|
+
var interpreter = require('./interpreter-23e4041c.development.cjs.js');
|
|
7
|
+
var guards_dist_xstateGuards = require('./raise-8f482ce9.development.cjs.js');
|
|
8
|
+
var send = require('./send-cc8f864e.development.cjs.js');
|
|
9
9
|
require('../dev/dist/xstate-dev.development.cjs.js');
|
|
10
10
|
|
|
11
11
|
class SimulatedClock {
|
|
@@ -450,27 +450,18 @@ class StateMachine {
|
|
|
450
450
|
}
|
|
451
451
|
});
|
|
452
452
|
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
...state,
|
|
466
|
-
value: guards_dist_xstateGuards.resolveStateValue(this.root, state.value),
|
|
467
|
-
configuration,
|
|
468
|
-
status: guards_dist_xstateGuards.isInFinalState(configurationSet, this.root) ? 'done' : state.status
|
|
469
|
-
});
|
|
470
|
-
}
|
|
471
|
-
resolveStateValue(stateValue, ...[context]) {
|
|
472
|
-
const resolvedStateValue = guards_dist_xstateGuards.resolveStateValue(this.root, stateValue);
|
|
473
|
-
return this.resolveState(guards_dist_xstateGuards.State.from(resolvedStateValue, context, this));
|
|
453
|
+
resolveState(config) {
|
|
454
|
+
const resolvedStateValue = guards_dist_xstateGuards.resolveStateValue(this.root, config.value);
|
|
455
|
+
const configurationSet = guards_dist_xstateGuards.getConfiguration(guards_dist_xstateGuards.getStateNodes(this.root, resolvedStateValue));
|
|
456
|
+
return guards_dist_xstateGuards.createMachineSnapshot({
|
|
457
|
+
configuration: [...configurationSet],
|
|
458
|
+
context: config.context || {},
|
|
459
|
+
children: {},
|
|
460
|
+
status: guards_dist_xstateGuards.isInFinalState(configurationSet, this.root) ? 'done' : config.status || 'active',
|
|
461
|
+
output: config.output,
|
|
462
|
+
error: config.error,
|
|
463
|
+
historyValue: config.historyValue
|
|
464
|
+
}, this);
|
|
474
465
|
}
|
|
475
466
|
|
|
476
467
|
/**
|
|
@@ -483,7 +474,7 @@ class StateMachine {
|
|
|
483
474
|
transition(state, event, actorScope) {
|
|
484
475
|
// TODO: handle error events in a better way
|
|
485
476
|
if (interpreter.isErrorActorEvent(event) && !state.nextEvents.some(nextEvent => nextEvent === event.type)) {
|
|
486
|
-
return guards_dist_xstateGuards.
|
|
477
|
+
return guards_dist_xstateGuards.cloneMachineSnapshot(state, {
|
|
487
478
|
status: 'error',
|
|
488
479
|
error: event.data
|
|
489
480
|
});
|
|
@@ -516,15 +507,12 @@ class StateMachine {
|
|
|
516
507
|
const {
|
|
517
508
|
context
|
|
518
509
|
} = this.config;
|
|
519
|
-
const preInitial =
|
|
520
|
-
value: {},
|
|
521
|
-
// TODO: this is computed in state constructor
|
|
510
|
+
const preInitial = guards_dist_xstateGuards.createMachineSnapshot({
|
|
522
511
|
context: typeof context !== 'function' && context ? context : {},
|
|
523
|
-
|
|
524
|
-
configuration: guards_dist_xstateGuards.getInitialConfiguration(this.root),
|
|
512
|
+
configuration: [this.root],
|
|
525
513
|
children: {},
|
|
526
514
|
status: 'active'
|
|
527
|
-
})
|
|
515
|
+
}, this);
|
|
528
516
|
if (typeof context === 'function') {
|
|
529
517
|
const assignment = ({
|
|
530
518
|
spawn,
|
|
@@ -584,9 +572,6 @@ class StateMachine {
|
|
|
584
572
|
getPersistedState(state, options) {
|
|
585
573
|
return guards_dist_xstateGuards.getPersistedState(state, options);
|
|
586
574
|
}
|
|
587
|
-
createState(stateConfig) {
|
|
588
|
-
return stateConfig instanceof guards_dist_xstateGuards.State ? stateConfig : new guards_dist_xstateGuards.State(stateConfig, this);
|
|
589
|
-
}
|
|
590
575
|
restoreState(snapshot, _actorScope) {
|
|
591
576
|
const children = {};
|
|
592
577
|
const snapshotChildren = snapshot.children;
|
|
@@ -608,10 +593,11 @@ class StateMachine {
|
|
|
608
593
|
});
|
|
609
594
|
children[actorId] = actorRef;
|
|
610
595
|
});
|
|
611
|
-
const restoredSnapshot =
|
|
596
|
+
const restoredSnapshot = guards_dist_xstateGuards.createMachineSnapshot({
|
|
612
597
|
...snapshot,
|
|
613
|
-
children
|
|
614
|
-
|
|
598
|
+
children,
|
|
599
|
+
configuration: Array.from(guards_dist_xstateGuards.getConfiguration(guards_dist_xstateGuards.getStateNodes(this.root, snapshot.value)))
|
|
600
|
+
}, this);
|
|
615
601
|
let seen = new Set();
|
|
616
602
|
function reviveContext(contextPart, children) {
|
|
617
603
|
if (seen.has(contextPart)) {
|
|
@@ -714,16 +700,6 @@ function createMachine(config, implementations) {
|
|
|
714
700
|
return new StateMachine(config, implementations);
|
|
715
701
|
}
|
|
716
702
|
|
|
717
|
-
function mapState(stateMap, stateId) {
|
|
718
|
-
let foundStateId;
|
|
719
|
-
for (const mappedStateId of Object.keys(stateMap)) {
|
|
720
|
-
if (interpreter.matchesState(mappedStateId, stateId) && (!foundStateId || stateId.length > foundStateId.length)) {
|
|
721
|
-
foundStateId = mappedStateId;
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
return stateMap[foundStateId];
|
|
725
|
-
}
|
|
726
|
-
|
|
727
703
|
exports.createEmptyActor = actors_dist_xstateActors.createEmptyActor;
|
|
728
704
|
exports.fromCallback = actors_dist_xstateActors.fromCallback;
|
|
729
705
|
exports.fromEventObservable = actors_dist_xstateActors.fromEventObservable;
|
|
@@ -736,7 +712,6 @@ exports.interpret = interpreter.interpret;
|
|
|
736
712
|
exports.matchesState = interpreter.matchesState;
|
|
737
713
|
exports.pathToStateValue = interpreter.pathToStateValue;
|
|
738
714
|
exports.toObserver = interpreter.toObserver;
|
|
739
|
-
exports.State = guards_dist_xstateGuards.State;
|
|
740
715
|
exports.and = guards_dist_xstateGuards.and;
|
|
741
716
|
exports.cancel = guards_dist_xstateGuards.cancel;
|
|
742
717
|
exports.getStateNodes = guards_dist_xstateGuards.getStateNodes;
|
|
@@ -759,5 +734,4 @@ exports.SimulatedClock = SimulatedClock;
|
|
|
759
734
|
exports.StateMachine = StateMachine;
|
|
760
735
|
exports.StateNode = StateNode;
|
|
761
736
|
exports.createMachine = createMachine;
|
|
762
|
-
exports.mapState = mapState;
|
|
763
737
|
exports.waitFor = waitFor;
|
|
@@ -1,10 +1,10 @@
|
|
|
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, a as toTransitionConfigArray, N as NULL_EVENT, c as createInvokeId, i as isErrorActorEvent, b as createInitEvent, r as resolveReferencedActor, d as createActor, $ as $$ACTOR_TYPE
|
|
3
|
-
export { A as Actor, d as createActor,
|
|
4
|
-
import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates,
|
|
5
|
-
export {
|
|
6
|
-
import { a as assign } from './send-
|
|
7
|
-
export { S as SpecialTargets, a as assign, c as choose, e as escalate, f as forwardTo, l as log, p as pure, s as sendParent, b as sendTo } from './send-
|
|
2
|
+
import { S as STATE_DELIMITER, m as mapValues, t as toArray, a as toTransitionConfigArray, N as NULL_EVENT, c as createInvokeId, i as isErrorActorEvent, b as createInitEvent, r as resolveReferencedActor, d as createActor, $ as $$ACTOR_TYPE } from './interpreter-f2620ea7.development.esm.js';
|
|
3
|
+
export { A as Actor, d as createActor, e as interpret, f as matchesState, p as pathToStateValue, g as toObserver } from './interpreter-f2620ea7.development.esm.js';
|
|
4
|
+
import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates, r as resolveStateValue, d as getConfiguration, h as getStateNodes, i as createMachineSnapshot, j as isInFinalState, k as cloneMachineSnapshot, l as macrostep, t as transitionNode, n as resolveActionsAndContext, o as microstep, p as getInitialStateNodes, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-51ae36e5.development.esm.js';
|
|
5
|
+
export { v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, C as spawn, y as stateIn, B as stop } from './raise-51ae36e5.development.esm.js';
|
|
6
|
+
import { a as assign } from './send-7a350091.development.esm.js';
|
|
7
|
+
export { S as SpecialTargets, a as assign, c as choose, e as escalate, f as forwardTo, l as log, p as pure, s as sendParent, b as sendTo } from './send-7a350091.development.esm.js';
|
|
8
8
|
import '../dev/dist/xstate-dev.development.esm.js';
|
|
9
9
|
|
|
10
10
|
class SimulatedClock {
|
|
@@ -449,27 +449,18 @@ class StateMachine {
|
|
|
449
449
|
}
|
|
450
450
|
});
|
|
451
451
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
...state,
|
|
465
|
-
value: resolveStateValue(this.root, state.value),
|
|
466
|
-
configuration,
|
|
467
|
-
status: isInFinalState(configurationSet, this.root) ? 'done' : state.status
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
resolveStateValue(stateValue, ...[context]) {
|
|
471
|
-
const resolvedStateValue = resolveStateValue(this.root, stateValue);
|
|
472
|
-
return this.resolveState(State.from(resolvedStateValue, context, this));
|
|
452
|
+
resolveState(config) {
|
|
453
|
+
const resolvedStateValue = resolveStateValue(this.root, config.value);
|
|
454
|
+
const configurationSet = getConfiguration(getStateNodes(this.root, resolvedStateValue));
|
|
455
|
+
return createMachineSnapshot({
|
|
456
|
+
configuration: [...configurationSet],
|
|
457
|
+
context: config.context || {},
|
|
458
|
+
children: {},
|
|
459
|
+
status: isInFinalState(configurationSet, this.root) ? 'done' : config.status || 'active',
|
|
460
|
+
output: config.output,
|
|
461
|
+
error: config.error,
|
|
462
|
+
historyValue: config.historyValue
|
|
463
|
+
}, this);
|
|
473
464
|
}
|
|
474
465
|
|
|
475
466
|
/**
|
|
@@ -482,7 +473,7 @@ class StateMachine {
|
|
|
482
473
|
transition(state, event, actorScope) {
|
|
483
474
|
// TODO: handle error events in a better way
|
|
484
475
|
if (isErrorActorEvent(event) && !state.nextEvents.some(nextEvent => nextEvent === event.type)) {
|
|
485
|
-
return
|
|
476
|
+
return cloneMachineSnapshot(state, {
|
|
486
477
|
status: 'error',
|
|
487
478
|
error: event.data
|
|
488
479
|
});
|
|
@@ -515,15 +506,12 @@ class StateMachine {
|
|
|
515
506
|
const {
|
|
516
507
|
context
|
|
517
508
|
} = this.config;
|
|
518
|
-
const preInitial =
|
|
519
|
-
value: {},
|
|
520
|
-
// TODO: this is computed in state constructor
|
|
509
|
+
const preInitial = createMachineSnapshot({
|
|
521
510
|
context: typeof context !== 'function' && context ? context : {},
|
|
522
|
-
|
|
523
|
-
configuration: getInitialConfiguration(this.root),
|
|
511
|
+
configuration: [this.root],
|
|
524
512
|
children: {},
|
|
525
513
|
status: 'active'
|
|
526
|
-
})
|
|
514
|
+
}, this);
|
|
527
515
|
if (typeof context === 'function') {
|
|
528
516
|
const assignment = ({
|
|
529
517
|
spawn,
|
|
@@ -583,9 +571,6 @@ class StateMachine {
|
|
|
583
571
|
getPersistedState(state, options) {
|
|
584
572
|
return getPersistedState(state, options);
|
|
585
573
|
}
|
|
586
|
-
createState(stateConfig) {
|
|
587
|
-
return stateConfig instanceof State ? stateConfig : new State(stateConfig, this);
|
|
588
|
-
}
|
|
589
574
|
restoreState(snapshot, _actorScope) {
|
|
590
575
|
const children = {};
|
|
591
576
|
const snapshotChildren = snapshot.children;
|
|
@@ -607,10 +592,11 @@ class StateMachine {
|
|
|
607
592
|
});
|
|
608
593
|
children[actorId] = actorRef;
|
|
609
594
|
});
|
|
610
|
-
const restoredSnapshot =
|
|
595
|
+
const restoredSnapshot = createMachineSnapshot({
|
|
611
596
|
...snapshot,
|
|
612
|
-
children
|
|
613
|
-
|
|
597
|
+
children,
|
|
598
|
+
configuration: Array.from(getConfiguration(getStateNodes(this.root, snapshot.value)))
|
|
599
|
+
}, this);
|
|
614
600
|
let seen = new Set();
|
|
615
601
|
function reviveContext(contextPart, children) {
|
|
616
602
|
if (seen.has(contextPart)) {
|
|
@@ -713,14 +699,4 @@ function createMachine(config, implementations) {
|
|
|
713
699
|
return new StateMachine(config, implementations);
|
|
714
700
|
}
|
|
715
701
|
|
|
716
|
-
|
|
717
|
-
let foundStateId;
|
|
718
|
-
for (const mappedStateId of Object.keys(stateMap)) {
|
|
719
|
-
if (matchesState(mappedStateId, stateId) && (!foundStateId || stateId.length > foundStateId.length)) {
|
|
720
|
-
foundStateId = mappedStateId;
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
return stateMap[foundStateId];
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
export { SimulatedClock, StateMachine, StateNode, createMachine, mapState, waitFor };
|
|
702
|
+
export { SimulatedClock, StateMachine, StateNode, createMachine, waitFor };
|
package/dist/xstate.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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, a as toTransitionConfigArray, N as NULL_EVENT, c as createInvokeId, i as isErrorActorEvent, b as createInitEvent, r as resolveReferencedActor, d as createActor, $ as $$ACTOR_TYPE
|
|
3
|
-
export { A as Actor, d as createActor,
|
|
4
|
-
import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates,
|
|
5
|
-
export {
|
|
6
|
-
import { a as assign } from './send-
|
|
7
|
-
export { S as SpecialTargets, a as assign, c as choose, e as escalate, f as forwardTo, l as log, p as pure, s as sendParent, b as sendTo } from './send-
|
|
2
|
+
import { S as STATE_DELIMITER, m as mapValues, t as toArray, a as toTransitionConfigArray, N as NULL_EVENT, c as createInvokeId, i as isErrorActorEvent, b as createInitEvent, r as resolveReferencedActor, d as createActor, $ as $$ACTOR_TYPE } from './interpreter-3d0c0ff2.esm.js';
|
|
3
|
+
export { A as Actor, d as createActor, e as interpret, f as matchesState, p as pathToStateValue, g as toObserver } from './interpreter-3d0c0ff2.esm.js';
|
|
4
|
+
import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates, r as resolveStateValue, d as getConfiguration, h as getStateNodes, i as createMachineSnapshot, j as isInFinalState, k as cloneMachineSnapshot, l as macrostep, t as transitionNode, n as resolveActionsAndContext, o as microstep, p as getInitialStateNodes, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-d2084327.esm.js';
|
|
5
|
+
export { v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, C as spawn, y as stateIn, B as stop } from './raise-d2084327.esm.js';
|
|
6
|
+
import { a as assign } from './send-4e732fa5.esm.js';
|
|
7
|
+
export { S as SpecialTargets, a as assign, c as choose, e as escalate, f as forwardTo, l as log, p as pure, s as sendParent, b as sendTo } from './send-4e732fa5.esm.js';
|
|
8
8
|
import '../dev/dist/xstate-dev.esm.js';
|
|
9
9
|
|
|
10
10
|
class SimulatedClock {
|
|
@@ -446,27 +446,18 @@ class StateMachine {
|
|
|
446
446
|
}
|
|
447
447
|
});
|
|
448
448
|
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
...state,
|
|
462
|
-
value: resolveStateValue(this.root, state.value),
|
|
463
|
-
configuration,
|
|
464
|
-
status: isInFinalState(configurationSet, this.root) ? 'done' : state.status
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
resolveStateValue(stateValue, ...[context]) {
|
|
468
|
-
const resolvedStateValue = resolveStateValue(this.root, stateValue);
|
|
469
|
-
return this.resolveState(State.from(resolvedStateValue, context, this));
|
|
449
|
+
resolveState(config) {
|
|
450
|
+
const resolvedStateValue = resolveStateValue(this.root, config.value);
|
|
451
|
+
const configurationSet = getConfiguration(getStateNodes(this.root, resolvedStateValue));
|
|
452
|
+
return createMachineSnapshot({
|
|
453
|
+
configuration: [...configurationSet],
|
|
454
|
+
context: config.context || {},
|
|
455
|
+
children: {},
|
|
456
|
+
status: isInFinalState(configurationSet, this.root) ? 'done' : config.status || 'active',
|
|
457
|
+
output: config.output,
|
|
458
|
+
error: config.error,
|
|
459
|
+
historyValue: config.historyValue
|
|
460
|
+
}, this);
|
|
470
461
|
}
|
|
471
462
|
|
|
472
463
|
/**
|
|
@@ -479,7 +470,7 @@ class StateMachine {
|
|
|
479
470
|
transition(state, event, actorScope) {
|
|
480
471
|
// TODO: handle error events in a better way
|
|
481
472
|
if (isErrorActorEvent(event) && !state.nextEvents.some(nextEvent => nextEvent === event.type)) {
|
|
482
|
-
return
|
|
473
|
+
return cloneMachineSnapshot(state, {
|
|
483
474
|
status: 'error',
|
|
484
475
|
error: event.data
|
|
485
476
|
});
|
|
@@ -512,15 +503,12 @@ class StateMachine {
|
|
|
512
503
|
const {
|
|
513
504
|
context
|
|
514
505
|
} = this.config;
|
|
515
|
-
const preInitial =
|
|
516
|
-
value: {},
|
|
517
|
-
// TODO: this is computed in state constructor
|
|
506
|
+
const preInitial = createMachineSnapshot({
|
|
518
507
|
context: typeof context !== 'function' && context ? context : {},
|
|
519
|
-
|
|
520
|
-
configuration: getInitialConfiguration(this.root),
|
|
508
|
+
configuration: [this.root],
|
|
521
509
|
children: {},
|
|
522
510
|
status: 'active'
|
|
523
|
-
})
|
|
511
|
+
}, this);
|
|
524
512
|
if (typeof context === 'function') {
|
|
525
513
|
const assignment = ({
|
|
526
514
|
spawn,
|
|
@@ -580,9 +568,6 @@ class StateMachine {
|
|
|
580
568
|
getPersistedState(state, options) {
|
|
581
569
|
return getPersistedState(state, options);
|
|
582
570
|
}
|
|
583
|
-
createState(stateConfig) {
|
|
584
|
-
return stateConfig instanceof State ? stateConfig : new State(stateConfig, this);
|
|
585
|
-
}
|
|
586
571
|
restoreState(snapshot, _actorScope) {
|
|
587
572
|
const children = {};
|
|
588
573
|
const snapshotChildren = snapshot.children;
|
|
@@ -604,10 +589,11 @@ class StateMachine {
|
|
|
604
589
|
});
|
|
605
590
|
children[actorId] = actorRef;
|
|
606
591
|
});
|
|
607
|
-
const restoredSnapshot =
|
|
592
|
+
const restoredSnapshot = createMachineSnapshot({
|
|
608
593
|
...snapshot,
|
|
609
|
-
children
|
|
610
|
-
|
|
594
|
+
children,
|
|
595
|
+
configuration: Array.from(getConfiguration(getStateNodes(this.root, snapshot.value)))
|
|
596
|
+
}, this);
|
|
611
597
|
let seen = new Set();
|
|
612
598
|
function reviveContext(contextPart, children) {
|
|
613
599
|
if (seen.has(contextPart)) {
|
|
@@ -707,14 +693,4 @@ function createMachine(config, implementations) {
|
|
|
707
693
|
return new StateMachine(config, implementations);
|
|
708
694
|
}
|
|
709
695
|
|
|
710
|
-
|
|
711
|
-
let foundStateId;
|
|
712
|
-
for (const mappedStateId of Object.keys(stateMap)) {
|
|
713
|
-
if (matchesState(mappedStateId, stateId) && (!foundStateId || stateId.length > foundStateId.length)) {
|
|
714
|
-
foundStateId = mappedStateId;
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
return stateMap[foundStateId];
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
export { SimulatedClock, StateMachine, StateNode, createMachine, mapState, waitFor };
|
|
696
|
+
export { SimulatedClock, StateMachine, StateNode, createMachine, waitFor };
|