xstate 5.0.0-beta.29 → 5.0.0-beta.30
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 +104 -104
- package/actors/dist/xstate-actors.development.cjs.js +104 -104
- package/actors/dist/xstate-actors.development.esm.js +104 -104
- package/actors/dist/xstate-actors.esm.js +104 -104
- 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 +4 -6
- package/dist/declarations/src/StateMachine.d.ts +28 -21
- package/dist/declarations/src/StateNode.d.ts +1 -1
- package/dist/declarations/src/actions/stop.d.ts +1 -1
- package/dist/declarations/src/actors/callback.d.ts +7 -7
- package/dist/declarations/src/actors/index.d.ts +3 -3
- package/dist/declarations/src/actors/observable.d.ts +12 -13
- package/dist/declarations/src/actors/promise.d.ts +11 -14
- package/dist/declarations/src/actors/transition.d.ts +10 -7
- package/dist/declarations/src/index.d.ts +1 -1
- package/dist/declarations/src/interpreter.d.ts +4 -4
- package/dist/declarations/src/stateUtils.d.ts +5 -6
- package/dist/declarations/src/types.d.ts +69 -39
- package/dist/{interpreter-e2c6a579.development.cjs.js → interpreter-7f1dc557.development.cjs.js} +9 -11
- package/dist/{interpreter-6e7909c8.development.esm.js → interpreter-945c4b96.development.esm.js} +9 -11
- package/dist/{interpreter-c357bc50.cjs.js → interpreter-a2c1e529.cjs.js} +9 -11
- package/dist/{interpreter-498891b2.esm.js → interpreter-b8f53c4b.esm.js} +9 -11
- package/dist/{raise-59f2c242.esm.js → raise-0b7dde8b.esm.js} +13 -11
- package/dist/{raise-e778a828.development.esm.js → raise-6e4f5cf7.development.esm.js} +13 -11
- package/dist/{raise-f751dfac.development.cjs.js → raise-7cae872b.development.cjs.js} +13 -11
- package/dist/{raise-03e57569.cjs.js → raise-e79b1f86.cjs.js} +13 -11
- package/dist/{send-f53778f6.development.cjs.js → send-19a256f0.development.cjs.js} +2 -2
- package/dist/{send-42c83fb2.development.esm.js → send-a1d772da.development.esm.js} +2 -2
- package/dist/{send-51717e53.cjs.js → send-e7063201.cjs.js} +2 -2
- package/dist/{send-fff224db.esm.js → send-f4fb3ba5.esm.js} +2 -2
- package/dist/xstate.cjs.js +14 -23
- package/dist/xstate.development.cjs.js +14 -23
- package/dist/xstate.development.esm.js +17 -26
- package/dist/xstate.esm.js +17 -26
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as resolveReferencedActor, d as createActor, f as ActorStatus, k as createErrorActorEvent, l as toStateValue, n as STATE_IDENTIFIER, o as normalizeTarget, t as toArray, N as NULL_EVENT, a as toTransitionConfigArray, S as STATE_DELIMITER, q as toStatePath, s as createDoneStateEvent, u as mapContext, W as WILDCARD, j as XSTATE_STOP, X as XSTATE_INIT, v as isArray, w as createAfterEvent, x as flatten, e as matchesState } from './interpreter-
|
|
1
|
+
import { r as resolveReferencedActor, d as createActor, f as ActorStatus, k as createErrorActorEvent, l as toStateValue, n as STATE_IDENTIFIER, o as normalizeTarget, t as toArray, N as NULL_EVENT, a as toTransitionConfigArray, S as STATE_DELIMITER, q as toStatePath, s as createDoneStateEvent, u as mapContext, W as WILDCARD, j as XSTATE_STOP, X as XSTATE_INIT, v as isArray, w as createAfterEvent, x as flatten, e as matchesState } from './interpreter-945c4b96.development.esm.js';
|
|
2
2
|
|
|
3
3
|
const cache = new WeakMap();
|
|
4
4
|
function memo(object, key, fn) {
|
|
@@ -921,7 +921,7 @@ function microstepProcedure(transitions, currentState, mutConfiguration, event,
|
|
|
921
921
|
historyValue,
|
|
922
922
|
_internalQueue: internalQueue,
|
|
923
923
|
context: nextState.context,
|
|
924
|
-
done,
|
|
924
|
+
status: done ? 'done' : currentState.status,
|
|
925
925
|
output,
|
|
926
926
|
children: nextState.children
|
|
927
927
|
});
|
|
@@ -1153,7 +1153,7 @@ function macrostep(state, event, actorCtx) {
|
|
|
1153
1153
|
nextState = microstep(transitions, state, actorCtx, nextEvent, false);
|
|
1154
1154
|
states.push(nextState);
|
|
1155
1155
|
}
|
|
1156
|
-
while (
|
|
1156
|
+
while (nextState.status === 'active') {
|
|
1157
1157
|
let enabledTransitions = selectEventlessTransitions(nextState, nextEvent);
|
|
1158
1158
|
if (!enabledTransitions.length) {
|
|
1159
1159
|
if (!nextState._internalQueue.length) {
|
|
@@ -1170,7 +1170,7 @@ function macrostep(state, event, actorCtx) {
|
|
|
1170
1170
|
states.push(nextState);
|
|
1171
1171
|
}
|
|
1172
1172
|
}
|
|
1173
|
-
if (nextState.
|
|
1173
|
+
if (nextState.status !== 'active') {
|
|
1174
1174
|
// Perform the stop step to ensure that child actors are stopped
|
|
1175
1175
|
stopStep(nextEvent, nextState, actorCtx);
|
|
1176
1176
|
}
|
|
@@ -1263,7 +1263,8 @@ class State {
|
|
|
1263
1263
|
meta: {},
|
|
1264
1264
|
configuration: [],
|
|
1265
1265
|
// TODO: fix,
|
|
1266
|
-
children: {}
|
|
1266
|
+
children: {},
|
|
1267
|
+
status: 'active'
|
|
1267
1268
|
}, machine);
|
|
1268
1269
|
}
|
|
1269
1270
|
return stateValue;
|
|
@@ -1274,7 +1275,8 @@ class State {
|
|
|
1274
1275
|
context,
|
|
1275
1276
|
meta: undefined,
|
|
1276
1277
|
configuration: Array.from(configuration),
|
|
1277
|
-
children: {}
|
|
1278
|
+
children: {},
|
|
1279
|
+
status: 'active'
|
|
1278
1280
|
}, machine);
|
|
1279
1281
|
}
|
|
1280
1282
|
|
|
@@ -1287,8 +1289,7 @@ class State {
|
|
|
1287
1289
|
this.machine = machine;
|
|
1288
1290
|
this.tags = void 0;
|
|
1289
1291
|
this.value = void 0;
|
|
1290
|
-
this.
|
|
1291
|
-
this.output = void 0;
|
|
1292
|
+
this.status = void 0;
|
|
1292
1293
|
this.error = void 0;
|
|
1293
1294
|
this.context = void 0;
|
|
1294
1295
|
this.historyValue = {};
|
|
@@ -1304,7 +1305,7 @@ class State {
|
|
|
1304
1305
|
this.children = config.children;
|
|
1305
1306
|
this.value = getStateValue(machine.root, this.configuration);
|
|
1306
1307
|
this.tags = new Set(flatten(this.configuration.map(sn => sn.tags)));
|
|
1307
|
-
this.
|
|
1308
|
+
this.status = config.status;
|
|
1308
1309
|
this.output = config.output;
|
|
1309
1310
|
this.error = config.error;
|
|
1310
1311
|
}
|
|
@@ -1402,9 +1403,10 @@ function getPersistedState(state) {
|
|
|
1402
1403
|
} = state;
|
|
1403
1404
|
const childrenJson = {};
|
|
1404
1405
|
for (const id in children) {
|
|
1406
|
+
const child = children[id];
|
|
1405
1407
|
childrenJson[id] = {
|
|
1406
|
-
state:
|
|
1407
|
-
src:
|
|
1408
|
+
state: child.getPersistedState?.(),
|
|
1409
|
+
src: child.src
|
|
1408
1410
|
};
|
|
1409
1411
|
}
|
|
1410
1412
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var interpreter = require('./interpreter-
|
|
3
|
+
var interpreter = require('./interpreter-7f1dc557.development.cjs.js');
|
|
4
4
|
|
|
5
5
|
const cache = new WeakMap();
|
|
6
6
|
function memo(object, key, fn) {
|
|
@@ -923,7 +923,7 @@ function microstepProcedure(transitions, currentState, mutConfiguration, event,
|
|
|
923
923
|
historyValue,
|
|
924
924
|
_internalQueue: internalQueue,
|
|
925
925
|
context: nextState.context,
|
|
926
|
-
done,
|
|
926
|
+
status: done ? 'done' : currentState.status,
|
|
927
927
|
output,
|
|
928
928
|
children: nextState.children
|
|
929
929
|
});
|
|
@@ -1155,7 +1155,7 @@ function macrostep(state, event, actorCtx) {
|
|
|
1155
1155
|
nextState = microstep(transitions, state, actorCtx, nextEvent, false);
|
|
1156
1156
|
states.push(nextState);
|
|
1157
1157
|
}
|
|
1158
|
-
while (
|
|
1158
|
+
while (nextState.status === 'active') {
|
|
1159
1159
|
let enabledTransitions = selectEventlessTransitions(nextState, nextEvent);
|
|
1160
1160
|
if (!enabledTransitions.length) {
|
|
1161
1161
|
if (!nextState._internalQueue.length) {
|
|
@@ -1172,7 +1172,7 @@ function macrostep(state, event, actorCtx) {
|
|
|
1172
1172
|
states.push(nextState);
|
|
1173
1173
|
}
|
|
1174
1174
|
}
|
|
1175
|
-
if (nextState.
|
|
1175
|
+
if (nextState.status !== 'active') {
|
|
1176
1176
|
// Perform the stop step to ensure that child actors are stopped
|
|
1177
1177
|
stopStep(nextEvent, nextState, actorCtx);
|
|
1178
1178
|
}
|
|
@@ -1265,7 +1265,8 @@ class State {
|
|
|
1265
1265
|
meta: {},
|
|
1266
1266
|
configuration: [],
|
|
1267
1267
|
// TODO: fix,
|
|
1268
|
-
children: {}
|
|
1268
|
+
children: {},
|
|
1269
|
+
status: 'active'
|
|
1269
1270
|
}, machine);
|
|
1270
1271
|
}
|
|
1271
1272
|
return stateValue;
|
|
@@ -1276,7 +1277,8 @@ class State {
|
|
|
1276
1277
|
context,
|
|
1277
1278
|
meta: undefined,
|
|
1278
1279
|
configuration: Array.from(configuration),
|
|
1279
|
-
children: {}
|
|
1280
|
+
children: {},
|
|
1281
|
+
status: 'active'
|
|
1280
1282
|
}, machine);
|
|
1281
1283
|
}
|
|
1282
1284
|
|
|
@@ -1289,8 +1291,7 @@ class State {
|
|
|
1289
1291
|
this.machine = machine;
|
|
1290
1292
|
this.tags = void 0;
|
|
1291
1293
|
this.value = void 0;
|
|
1292
|
-
this.
|
|
1293
|
-
this.output = void 0;
|
|
1294
|
+
this.status = void 0;
|
|
1294
1295
|
this.error = void 0;
|
|
1295
1296
|
this.context = void 0;
|
|
1296
1297
|
this.historyValue = {};
|
|
@@ -1306,7 +1307,7 @@ class State {
|
|
|
1306
1307
|
this.children = config.children;
|
|
1307
1308
|
this.value = getStateValue(machine.root, this.configuration);
|
|
1308
1309
|
this.tags = new Set(interpreter.flatten(this.configuration.map(sn => sn.tags)));
|
|
1309
|
-
this.
|
|
1310
|
+
this.status = config.status;
|
|
1310
1311
|
this.output = config.output;
|
|
1311
1312
|
this.error = config.error;
|
|
1312
1313
|
}
|
|
@@ -1404,9 +1405,10 @@ function getPersistedState(state) {
|
|
|
1404
1405
|
} = state;
|
|
1405
1406
|
const childrenJson = {};
|
|
1406
1407
|
for (const id in children) {
|
|
1408
|
+
const child = children[id];
|
|
1407
1409
|
childrenJson[id] = {
|
|
1408
|
-
state:
|
|
1409
|
-
src:
|
|
1410
|
+
state: child.getPersistedState?.(),
|
|
1411
|
+
src: child.src
|
|
1410
1412
|
};
|
|
1411
1413
|
}
|
|
1412
1414
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var interpreter = require('./interpreter-
|
|
3
|
+
var interpreter = require('./interpreter-a2c1e529.cjs.js');
|
|
4
4
|
|
|
5
5
|
const cache = new WeakMap();
|
|
6
6
|
function memo(object, key, fn) {
|
|
@@ -892,7 +892,7 @@ function microstepProcedure(transitions, currentState, mutConfiguration, event,
|
|
|
892
892
|
historyValue,
|
|
893
893
|
_internalQueue: internalQueue,
|
|
894
894
|
context: nextState.context,
|
|
895
|
-
done,
|
|
895
|
+
status: done ? 'done' : currentState.status,
|
|
896
896
|
output,
|
|
897
897
|
children: nextState.children
|
|
898
898
|
});
|
|
@@ -1121,7 +1121,7 @@ function macrostep(state, event, actorCtx) {
|
|
|
1121
1121
|
nextState = microstep(transitions, state, actorCtx, nextEvent, false);
|
|
1122
1122
|
states.push(nextState);
|
|
1123
1123
|
}
|
|
1124
|
-
while (
|
|
1124
|
+
while (nextState.status === 'active') {
|
|
1125
1125
|
let enabledTransitions = selectEventlessTransitions(nextState, nextEvent);
|
|
1126
1126
|
if (!enabledTransitions.length) {
|
|
1127
1127
|
if (!nextState._internalQueue.length) {
|
|
@@ -1138,7 +1138,7 @@ function macrostep(state, event, actorCtx) {
|
|
|
1138
1138
|
states.push(nextState);
|
|
1139
1139
|
}
|
|
1140
1140
|
}
|
|
1141
|
-
if (nextState.
|
|
1141
|
+
if (nextState.status !== 'active') {
|
|
1142
1142
|
// Perform the stop step to ensure that child actors are stopped
|
|
1143
1143
|
stopStep(nextEvent, nextState, actorCtx);
|
|
1144
1144
|
}
|
|
@@ -1231,7 +1231,8 @@ class State {
|
|
|
1231
1231
|
meta: {},
|
|
1232
1232
|
configuration: [],
|
|
1233
1233
|
// TODO: fix,
|
|
1234
|
-
children: {}
|
|
1234
|
+
children: {},
|
|
1235
|
+
status: 'active'
|
|
1235
1236
|
}, machine);
|
|
1236
1237
|
}
|
|
1237
1238
|
return stateValue;
|
|
@@ -1242,7 +1243,8 @@ class State {
|
|
|
1242
1243
|
context,
|
|
1243
1244
|
meta: undefined,
|
|
1244
1245
|
configuration: Array.from(configuration),
|
|
1245
|
-
children: {}
|
|
1246
|
+
children: {},
|
|
1247
|
+
status: 'active'
|
|
1246
1248
|
}, machine);
|
|
1247
1249
|
}
|
|
1248
1250
|
|
|
@@ -1255,8 +1257,7 @@ class State {
|
|
|
1255
1257
|
this.machine = machine;
|
|
1256
1258
|
this.tags = void 0;
|
|
1257
1259
|
this.value = void 0;
|
|
1258
|
-
this.
|
|
1259
|
-
this.output = void 0;
|
|
1260
|
+
this.status = void 0;
|
|
1260
1261
|
this.error = void 0;
|
|
1261
1262
|
this.context = void 0;
|
|
1262
1263
|
this.historyValue = {};
|
|
@@ -1272,7 +1273,7 @@ class State {
|
|
|
1272
1273
|
this.children = config.children;
|
|
1273
1274
|
this.value = getStateValue(machine.root, this.configuration);
|
|
1274
1275
|
this.tags = new Set(interpreter.flatten(this.configuration.map(sn => sn.tags)));
|
|
1275
|
-
this.
|
|
1276
|
+
this.status = config.status;
|
|
1276
1277
|
this.output = config.output;
|
|
1277
1278
|
this.error = config.error;
|
|
1278
1279
|
}
|
|
@@ -1367,9 +1368,10 @@ function getPersistedState(state) {
|
|
|
1367
1368
|
} = state;
|
|
1368
1369
|
const childrenJson = {};
|
|
1369
1370
|
for (const id in children) {
|
|
1371
|
+
const child = children[id];
|
|
1370
1372
|
childrenJson[id] = {
|
|
1371
|
-
state:
|
|
1372
|
-
src:
|
|
1373
|
+
state: child.getPersistedState?.(),
|
|
1374
|
+
src: child.src
|
|
1373
1375
|
};
|
|
1374
1376
|
}
|
|
1375
1377
|
return {
|
|
@@ -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-7cae872b.development.cjs.js');
|
|
4
|
+
var interpreter = require('./interpreter-7f1dc557.development.cjs.js');
|
|
5
5
|
|
|
6
6
|
function createSpawner(actorContext, {
|
|
7
7
|
machine,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { j as cloneState, e as evaluateGuard } from './raise-
|
|
2
|
-
import { f as ActorStatus, k as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, y as XSTATE_ERROR } from './interpreter-
|
|
1
|
+
import { j as cloneState, e as evaluateGuard } from './raise-6e4f5cf7.development.esm.js';
|
|
2
|
+
import { f as ActorStatus, k as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, y as XSTATE_ERROR } from './interpreter-945c4b96.development.esm.js';
|
|
3
3
|
|
|
4
4
|
function createSpawner(actorContext, {
|
|
5
5
|
machine,
|
|
@@ -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-e79b1f86.cjs.js');
|
|
4
|
+
var interpreter = require('./interpreter-a2c1e529.cjs.js');
|
|
5
5
|
|
|
6
6
|
function createSpawner(actorContext, {
|
|
7
7
|
machine,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { j as cloneState, e as evaluateGuard } from './raise-
|
|
2
|
-
import { f as ActorStatus, k as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, y as XSTATE_ERROR } from './interpreter-
|
|
1
|
+
import { j as cloneState, e as evaluateGuard } from './raise-0b7dde8b.esm.js';
|
|
2
|
+
import { f as ActorStatus, k as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, y as XSTATE_ERROR } from './interpreter-b8f53c4b.esm.js';
|
|
3
3
|
|
|
4
4
|
function createSpawner(actorContext, {
|
|
5
5
|
machine,
|
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-a2c1e529.cjs.js');
|
|
7
|
+
var guards_dist_xstateGuards = require('./raise-e79b1f86.cjs.js');
|
|
8
|
+
var send = require('./send-e7063201.cjs.js');
|
|
9
9
|
require('../dev/dist/xstate-dev.cjs.js');
|
|
10
10
|
|
|
11
11
|
class SimulatedClock {
|
|
@@ -467,7 +467,7 @@ class StateMachine {
|
|
|
467
467
|
...state,
|
|
468
468
|
value: guards_dist_xstateGuards.resolveStateValue(this.root, state.value),
|
|
469
469
|
configuration,
|
|
470
|
-
|
|
470
|
+
status: guards_dist_xstateGuards.isInFinalState(configuration) ? 'done' : state.status
|
|
471
471
|
});
|
|
472
472
|
}
|
|
473
473
|
resolveStateValue(stateValue, ...[context]) {
|
|
@@ -486,6 +486,7 @@ class StateMachine {
|
|
|
486
486
|
// TODO: handle error events in a better way
|
|
487
487
|
if (interpreter.isErrorActorEvent(event) && !state.nextEvents.some(nextEvent => nextEvent === event.type)) {
|
|
488
488
|
return guards_dist_xstateGuards.cloneState(state, {
|
|
489
|
+
status: 'error',
|
|
489
490
|
error: event.data
|
|
490
491
|
});
|
|
491
492
|
}
|
|
@@ -523,7 +524,8 @@ class StateMachine {
|
|
|
523
524
|
context: typeof context !== 'function' && context ? context : {},
|
|
524
525
|
meta: undefined,
|
|
525
526
|
configuration: guards_dist_xstateGuards.getInitialConfiguration(this.root),
|
|
526
|
-
children: {}
|
|
527
|
+
children: {},
|
|
528
|
+
status: 'active'
|
|
527
529
|
}));
|
|
528
530
|
if (typeof context === 'function') {
|
|
529
531
|
const assignment = ({
|
|
@@ -587,21 +589,10 @@ class StateMachine {
|
|
|
587
589
|
createState(stateConfig) {
|
|
588
590
|
return stateConfig instanceof guards_dist_xstateGuards.State ? stateConfig : new guards_dist_xstateGuards.State(stateConfig, this);
|
|
589
591
|
}
|
|
590
|
-
|
|
591
|
-
return state.error ? {
|
|
592
|
-
status: 'error',
|
|
593
|
-
data: state.error
|
|
594
|
-
} : state.done ? {
|
|
595
|
-
status: 'done',
|
|
596
|
-
data: state.output
|
|
597
|
-
} : {
|
|
598
|
-
status: 'active'
|
|
599
|
-
};
|
|
600
|
-
}
|
|
601
|
-
restoreState(state, _actorCtx) {
|
|
592
|
+
restoreState(snapshot, _actorCtx) {
|
|
602
593
|
const children = {};
|
|
603
|
-
Object.keys(
|
|
604
|
-
const actorData =
|
|
594
|
+
Object.keys(snapshot.children).forEach(actorId => {
|
|
595
|
+
const actorData = snapshot.children[actorId];
|
|
605
596
|
const childState = actorData.state;
|
|
606
597
|
const src = actorData.src;
|
|
607
598
|
const logic = src ? interpreter.resolveReferencedActor(this.implementations.actors[src])?.src : undefined;
|
|
@@ -615,13 +606,13 @@ class StateMachine {
|
|
|
615
606
|
});
|
|
616
607
|
children[actorId] = actorRef;
|
|
617
608
|
});
|
|
618
|
-
const
|
|
619
|
-
...
|
|
609
|
+
const restoredSnapshot = this.createState(new guards_dist_xstateGuards.State({
|
|
610
|
+
...snapshot,
|
|
620
611
|
children
|
|
621
612
|
}, this));
|
|
622
613
|
|
|
623
614
|
// TODO: DRY this up
|
|
624
|
-
|
|
615
|
+
restoredSnapshot.configuration.forEach(stateNode => {
|
|
625
616
|
if (stateNode.invoke) {
|
|
626
617
|
stateNode.invoke.forEach(invokeConfig => {
|
|
627
618
|
const {
|
|
@@ -643,7 +634,7 @@ class StateMachine {
|
|
|
643
634
|
});
|
|
644
635
|
}
|
|
645
636
|
});
|
|
646
|
-
return
|
|
637
|
+
return restoredSnapshot;
|
|
647
638
|
}
|
|
648
639
|
|
|
649
640
|
/**@deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
@@ -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-7f1dc557.development.cjs.js');
|
|
7
|
+
var guards_dist_xstateGuards = require('./raise-7cae872b.development.cjs.js');
|
|
8
|
+
var send = require('./send-19a256f0.development.cjs.js');
|
|
9
9
|
require('../dev/dist/xstate-dev.development.cjs.js');
|
|
10
10
|
|
|
11
11
|
class SimulatedClock {
|
|
@@ -467,7 +467,7 @@ class StateMachine {
|
|
|
467
467
|
...state,
|
|
468
468
|
value: guards_dist_xstateGuards.resolveStateValue(this.root, state.value),
|
|
469
469
|
configuration,
|
|
470
|
-
|
|
470
|
+
status: guards_dist_xstateGuards.isInFinalState(configuration) ? 'done' : state.status
|
|
471
471
|
});
|
|
472
472
|
}
|
|
473
473
|
resolveStateValue(stateValue, ...[context]) {
|
|
@@ -486,6 +486,7 @@ class StateMachine {
|
|
|
486
486
|
// TODO: handle error events in a better way
|
|
487
487
|
if (interpreter.isErrorActorEvent(event) && !state.nextEvents.some(nextEvent => nextEvent === event.type)) {
|
|
488
488
|
return guards_dist_xstateGuards.cloneState(state, {
|
|
489
|
+
status: 'error',
|
|
489
490
|
error: event.data
|
|
490
491
|
});
|
|
491
492
|
}
|
|
@@ -523,7 +524,8 @@ class StateMachine {
|
|
|
523
524
|
context: typeof context !== 'function' && context ? context : {},
|
|
524
525
|
meta: undefined,
|
|
525
526
|
configuration: guards_dist_xstateGuards.getInitialConfiguration(this.root),
|
|
526
|
-
children: {}
|
|
527
|
+
children: {},
|
|
528
|
+
status: 'active'
|
|
527
529
|
}));
|
|
528
530
|
if (typeof context === 'function') {
|
|
529
531
|
const assignment = ({
|
|
@@ -587,21 +589,10 @@ class StateMachine {
|
|
|
587
589
|
createState(stateConfig) {
|
|
588
590
|
return stateConfig instanceof guards_dist_xstateGuards.State ? stateConfig : new guards_dist_xstateGuards.State(stateConfig, this);
|
|
589
591
|
}
|
|
590
|
-
|
|
591
|
-
return state.error ? {
|
|
592
|
-
status: 'error',
|
|
593
|
-
data: state.error
|
|
594
|
-
} : state.done ? {
|
|
595
|
-
status: 'done',
|
|
596
|
-
data: state.output
|
|
597
|
-
} : {
|
|
598
|
-
status: 'active'
|
|
599
|
-
};
|
|
600
|
-
}
|
|
601
|
-
restoreState(state, _actorCtx) {
|
|
592
|
+
restoreState(snapshot, _actorCtx) {
|
|
602
593
|
const children = {};
|
|
603
|
-
Object.keys(
|
|
604
|
-
const actorData =
|
|
594
|
+
Object.keys(snapshot.children).forEach(actorId => {
|
|
595
|
+
const actorData = snapshot.children[actorId];
|
|
605
596
|
const childState = actorData.state;
|
|
606
597
|
const src = actorData.src;
|
|
607
598
|
const logic = src ? interpreter.resolveReferencedActor(this.implementations.actors[src])?.src : undefined;
|
|
@@ -615,13 +606,13 @@ class StateMachine {
|
|
|
615
606
|
});
|
|
616
607
|
children[actorId] = actorRef;
|
|
617
608
|
});
|
|
618
|
-
const
|
|
619
|
-
...
|
|
609
|
+
const restoredSnapshot = this.createState(new guards_dist_xstateGuards.State({
|
|
610
|
+
...snapshot,
|
|
620
611
|
children
|
|
621
612
|
}, this));
|
|
622
613
|
|
|
623
614
|
// TODO: DRY this up
|
|
624
|
-
|
|
615
|
+
restoredSnapshot.configuration.forEach(stateNode => {
|
|
625
616
|
if (stateNode.invoke) {
|
|
626
617
|
stateNode.invoke.forEach(invokeConfig => {
|
|
627
618
|
const {
|
|
@@ -643,7 +634,7 @@ class StateMachine {
|
|
|
643
634
|
});
|
|
644
635
|
}
|
|
645
636
|
});
|
|
646
|
-
return
|
|
637
|
+
return restoredSnapshot;
|
|
647
638
|
}
|
|
648
639
|
|
|
649
640
|
/**@deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
@@ -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, e as matchesState } from './interpreter-
|
|
3
|
-
export { A as Actor, f as ActorStatus, I as InterpreterStatus, d as createActor, g as interpret, e as matchesState, p as pathToStateValue, h as toObserver } from './interpreter-
|
|
4
|
-
import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates, d as getConfiguration, h as getStateNodes, r as resolveStateValue, i as isInFinalState, S as State, j as cloneState, k as macrostep, t as transitionNode, l as getInitialConfiguration, n as resolveActionsAndContext, o as microstep, p as isAtomicStateNode, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-
|
|
5
|
-
export { S as State, v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, y as stateIn, B as stop } from './raise-
|
|
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, e as matchesState } from './interpreter-945c4b96.development.esm.js';
|
|
3
|
+
export { A as Actor, f as ActorStatus, I as InterpreterStatus, d as createActor, g as interpret, e as matchesState, p as pathToStateValue, h as toObserver } from './interpreter-945c4b96.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, d as getConfiguration, h as getStateNodes, r as resolveStateValue, i as isInFinalState, S as State, j as cloneState, k as macrostep, t as transitionNode, l as getInitialConfiguration, n as resolveActionsAndContext, o as microstep, p as isAtomicStateNode, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-6e4f5cf7.development.esm.js';
|
|
5
|
+
export { S as State, v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, y as stateIn, B as stop } from './raise-6e4f5cf7.development.esm.js';
|
|
6
|
+
import { a as assign } from './send-a1d772da.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-a1d772da.development.esm.js';
|
|
8
8
|
import '../dev/dist/xstate-dev.development.esm.js';
|
|
9
9
|
|
|
10
10
|
class SimulatedClock {
|
|
@@ -466,7 +466,7 @@ class StateMachine {
|
|
|
466
466
|
...state,
|
|
467
467
|
value: resolveStateValue(this.root, state.value),
|
|
468
468
|
configuration,
|
|
469
|
-
|
|
469
|
+
status: isInFinalState(configuration) ? 'done' : state.status
|
|
470
470
|
});
|
|
471
471
|
}
|
|
472
472
|
resolveStateValue(stateValue, ...[context]) {
|
|
@@ -485,6 +485,7 @@ class StateMachine {
|
|
|
485
485
|
// TODO: handle error events in a better way
|
|
486
486
|
if (isErrorActorEvent(event) && !state.nextEvents.some(nextEvent => nextEvent === event.type)) {
|
|
487
487
|
return cloneState(state, {
|
|
488
|
+
status: 'error',
|
|
488
489
|
error: event.data
|
|
489
490
|
});
|
|
490
491
|
}
|
|
@@ -522,7 +523,8 @@ class StateMachine {
|
|
|
522
523
|
context: typeof context !== 'function' && context ? context : {},
|
|
523
524
|
meta: undefined,
|
|
524
525
|
configuration: getInitialConfiguration(this.root),
|
|
525
|
-
children: {}
|
|
526
|
+
children: {},
|
|
527
|
+
status: 'active'
|
|
526
528
|
}));
|
|
527
529
|
if (typeof context === 'function') {
|
|
528
530
|
const assignment = ({
|
|
@@ -586,21 +588,10 @@ class StateMachine {
|
|
|
586
588
|
createState(stateConfig) {
|
|
587
589
|
return stateConfig instanceof State ? stateConfig : new State(stateConfig, this);
|
|
588
590
|
}
|
|
589
|
-
|
|
590
|
-
return state.error ? {
|
|
591
|
-
status: 'error',
|
|
592
|
-
data: state.error
|
|
593
|
-
} : state.done ? {
|
|
594
|
-
status: 'done',
|
|
595
|
-
data: state.output
|
|
596
|
-
} : {
|
|
597
|
-
status: 'active'
|
|
598
|
-
};
|
|
599
|
-
}
|
|
600
|
-
restoreState(state, _actorCtx) {
|
|
591
|
+
restoreState(snapshot, _actorCtx) {
|
|
601
592
|
const children = {};
|
|
602
|
-
Object.keys(
|
|
603
|
-
const actorData =
|
|
593
|
+
Object.keys(snapshot.children).forEach(actorId => {
|
|
594
|
+
const actorData = snapshot.children[actorId];
|
|
604
595
|
const childState = actorData.state;
|
|
605
596
|
const src = actorData.src;
|
|
606
597
|
const logic = src ? resolveReferencedActor(this.implementations.actors[src])?.src : undefined;
|
|
@@ -614,13 +605,13 @@ class StateMachine {
|
|
|
614
605
|
});
|
|
615
606
|
children[actorId] = actorRef;
|
|
616
607
|
});
|
|
617
|
-
const
|
|
618
|
-
...
|
|
608
|
+
const restoredSnapshot = this.createState(new State({
|
|
609
|
+
...snapshot,
|
|
619
610
|
children
|
|
620
611
|
}, this));
|
|
621
612
|
|
|
622
613
|
// TODO: DRY this up
|
|
623
|
-
|
|
614
|
+
restoredSnapshot.configuration.forEach(stateNode => {
|
|
624
615
|
if (stateNode.invoke) {
|
|
625
616
|
stateNode.invoke.forEach(invokeConfig => {
|
|
626
617
|
const {
|
|
@@ -642,7 +633,7 @@ class StateMachine {
|
|
|
642
633
|
});
|
|
643
634
|
}
|
|
644
635
|
});
|
|
645
|
-
return
|
|
636
|
+
return restoredSnapshot;
|
|
646
637
|
}
|
|
647
638
|
|
|
648
639
|
/**@deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
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, e as matchesState } from './interpreter-
|
|
3
|
-
export { A as Actor, f as ActorStatus, I as InterpreterStatus, d as createActor, g as interpret, e as matchesState, p as pathToStateValue, h as toObserver } from './interpreter-
|
|
4
|
-
import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates, d as getConfiguration, h as getStateNodes, r as resolveStateValue, i as isInFinalState, S as State, j as cloneState, k as macrostep, t as transitionNode, l as getInitialConfiguration, n as resolveActionsAndContext, o as microstep, p as isAtomicStateNode, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-
|
|
5
|
-
export { S as State, v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, y as stateIn, B as stop } from './raise-
|
|
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, e as matchesState } from './interpreter-b8f53c4b.esm.js';
|
|
3
|
+
export { A as Actor, f as ActorStatus, I as InterpreterStatus, d as createActor, g as interpret, e as matchesState, p as pathToStateValue, h as toObserver } from './interpreter-b8f53c4b.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, d as getConfiguration, h as getStateNodes, r as resolveStateValue, i as isInFinalState, S as State, j as cloneState, k as macrostep, t as transitionNode, l as getInitialConfiguration, n as resolveActionsAndContext, o as microstep, p as isAtomicStateNode, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-0b7dde8b.esm.js';
|
|
5
|
+
export { S as State, v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, y as stateIn, B as stop } from './raise-0b7dde8b.esm.js';
|
|
6
|
+
import { a as assign } from './send-f4fb3ba5.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-f4fb3ba5.esm.js';
|
|
8
8
|
import '../dev/dist/xstate-dev.esm.js';
|
|
9
9
|
|
|
10
10
|
class SimulatedClock {
|
|
@@ -466,7 +466,7 @@ class StateMachine {
|
|
|
466
466
|
...state,
|
|
467
467
|
value: resolveStateValue(this.root, state.value),
|
|
468
468
|
configuration,
|
|
469
|
-
|
|
469
|
+
status: isInFinalState(configuration) ? 'done' : state.status
|
|
470
470
|
});
|
|
471
471
|
}
|
|
472
472
|
resolveStateValue(stateValue, ...[context]) {
|
|
@@ -485,6 +485,7 @@ class StateMachine {
|
|
|
485
485
|
// TODO: handle error events in a better way
|
|
486
486
|
if (isErrorActorEvent(event) && !state.nextEvents.some(nextEvent => nextEvent === event.type)) {
|
|
487
487
|
return cloneState(state, {
|
|
488
|
+
status: 'error',
|
|
488
489
|
error: event.data
|
|
489
490
|
});
|
|
490
491
|
}
|
|
@@ -522,7 +523,8 @@ class StateMachine {
|
|
|
522
523
|
context: typeof context !== 'function' && context ? context : {},
|
|
523
524
|
meta: undefined,
|
|
524
525
|
configuration: getInitialConfiguration(this.root),
|
|
525
|
-
children: {}
|
|
526
|
+
children: {},
|
|
527
|
+
status: 'active'
|
|
526
528
|
}));
|
|
527
529
|
if (typeof context === 'function') {
|
|
528
530
|
const assignment = ({
|
|
@@ -586,21 +588,10 @@ class StateMachine {
|
|
|
586
588
|
createState(stateConfig) {
|
|
587
589
|
return stateConfig instanceof State ? stateConfig : new State(stateConfig, this);
|
|
588
590
|
}
|
|
589
|
-
|
|
590
|
-
return state.error ? {
|
|
591
|
-
status: 'error',
|
|
592
|
-
data: state.error
|
|
593
|
-
} : state.done ? {
|
|
594
|
-
status: 'done',
|
|
595
|
-
data: state.output
|
|
596
|
-
} : {
|
|
597
|
-
status: 'active'
|
|
598
|
-
};
|
|
599
|
-
}
|
|
600
|
-
restoreState(state, _actorCtx) {
|
|
591
|
+
restoreState(snapshot, _actorCtx) {
|
|
601
592
|
const children = {};
|
|
602
|
-
Object.keys(
|
|
603
|
-
const actorData =
|
|
593
|
+
Object.keys(snapshot.children).forEach(actorId => {
|
|
594
|
+
const actorData = snapshot.children[actorId];
|
|
604
595
|
const childState = actorData.state;
|
|
605
596
|
const src = actorData.src;
|
|
606
597
|
const logic = src ? resolveReferencedActor(this.implementations.actors[src])?.src : undefined;
|
|
@@ -614,13 +605,13 @@ class StateMachine {
|
|
|
614
605
|
});
|
|
615
606
|
children[actorId] = actorRef;
|
|
616
607
|
});
|
|
617
|
-
const
|
|
618
|
-
...
|
|
608
|
+
const restoredSnapshot = this.createState(new State({
|
|
609
|
+
...snapshot,
|
|
619
610
|
children
|
|
620
611
|
}, this));
|
|
621
612
|
|
|
622
613
|
// TODO: DRY this up
|
|
623
|
-
|
|
614
|
+
restoredSnapshot.configuration.forEach(stateNode => {
|
|
624
615
|
if (stateNode.invoke) {
|
|
625
616
|
stateNode.invoke.forEach(invokeConfig => {
|
|
626
617
|
const {
|
|
@@ -642,7 +633,7 @@ class StateMachine {
|
|
|
642
633
|
});
|
|
643
634
|
}
|
|
644
635
|
});
|
|
645
|
-
return
|
|
636
|
+
return restoredSnapshot;
|
|
646
637
|
}
|
|
647
638
|
|
|
648
639
|
/**@deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|