xstate 5.24.0 → 5.25.1
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 +4 -1
- package/actors/dist/xstate-actors.development.cjs.js +4 -1
- package/actors/dist/xstate-actors.development.esm.js +4 -1
- package/actors/dist/xstate-actors.esm.js +4 -1
- package/actors/dist/xstate-actors.umd.min.js +1 -1
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/{StateMachine-37bc3882.esm.js → StateMachine-6c48f805.esm.js} +4 -3
- package/dist/{StateMachine-4f3286fa.development.cjs.js → StateMachine-6d24a98f.development.cjs.js} +4 -3
- package/dist/{StateMachine-d6caf9f3.development.esm.js → StateMachine-d0e98d09.development.esm.js} +4 -3
- package/dist/{StateMachine-30081029.cjs.js → StateMachine-fee05db8.cjs.js} +4 -3
- package/dist/{assign-ab9cc19e.esm.js → assign-37a2fc1e.esm.js} +1 -1
- package/dist/{assign-445527dc.development.esm.js → assign-541a432d.development.esm.js} +1 -1
- package/dist/{assign-9e730107.development.cjs.js → assign-577bb842.development.cjs.js} +1 -1
- package/dist/{assign-dea9f7c8.cjs.js → assign-592716a8.cjs.js} +1 -1
- package/dist/declarations/src/State.d.ts +5 -5
- package/dist/declarations/src/StateMachine.d.ts +10 -10
- package/dist/declarations/src/assert.d.ts +2 -4
- package/dist/declarations/src/setup.d.ts +13 -8
- package/dist/declarations/src/types.d.ts +1 -1
- package/dist/declarations/src/utils.d.ts +13 -0
- package/dist/{log-cbac1abc.development.cjs.js → log-3827c227.development.cjs.js} +2 -2
- package/dist/{log-ec8d4df4.cjs.js → log-9c9f917d.cjs.js} +2 -2
- package/dist/{log-2aa3642a.development.esm.js → log-b8ca474e.development.esm.js} +2 -2
- package/dist/{log-7cbae384.esm.js → log-ce14fc9a.esm.js} +2 -2
- package/dist/{raise-c096f887.development.esm.js → raise-13a60c49.development.esm.js} +61 -32
- package/dist/{raise-da5b247f.cjs.js → raise-577e4163.cjs.js} +55 -25
- package/dist/{raise-f777a9e8.development.cjs.js → raise-ed7c6f3d.development.cjs.js} +61 -31
- package/dist/{raise-9ad1c5c6.esm.js → raise-f5c7cb5b.esm.js} +55 -26
- package/dist/xstate.cjs.js +10 -6
- package/dist/xstate.development.cjs.js +10 -6
- package/dist/xstate.development.esm.js +14 -10
- package/dist/xstate.esm.js +14 -10
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/graph/dist/xstate-graph.cjs.js +3 -3
- package/graph/dist/xstate-graph.development.cjs.js +3 -3
- package/graph/dist/xstate-graph.development.esm.js +3 -3
- package/graph/dist/xstate-graph.esm.js +3 -3
- package/graph/dist/xstate-graph.umd.min.js +1 -1
- package/graph/dist/xstate-graph.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
|
@@ -288,6 +288,50 @@ function getAllOwnEventDescriptors(snapshot) {
|
|
|
288
288
|
return [...new Set([...snapshot._nodes.flatMap(sn => sn.ownEvents)])];
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
+
/**
|
|
292
|
+
* Checks if an event type matches an event descriptor, supporting wildcards.
|
|
293
|
+
* Event descriptors can be:
|
|
294
|
+
*
|
|
295
|
+
* - Exact matches: "event.type"
|
|
296
|
+
* - Wildcard: "*"
|
|
297
|
+
* - Partial matches: "event.*"
|
|
298
|
+
*
|
|
299
|
+
* @param eventType - The actual event type string
|
|
300
|
+
* @param descriptor - The event descriptor to match against
|
|
301
|
+
* @returns True if the event type matches the descriptor
|
|
302
|
+
*/
|
|
303
|
+
function matchesEventDescriptor(eventType, descriptor) {
|
|
304
|
+
if (descriptor === eventType) {
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
if (descriptor === WILDCARD) {
|
|
308
|
+
return true;
|
|
309
|
+
}
|
|
310
|
+
if (!descriptor.endsWith('.*')) {
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
if (/.*\*.+/.test(descriptor)) {
|
|
314
|
+
console.warn(`Wildcards can only be the last token of an event descriptor (e.g., "event.*") or the entire event descriptor ("*"). Check the "${descriptor}" event.`);
|
|
315
|
+
}
|
|
316
|
+
const partialEventTokens = descriptor.split('.');
|
|
317
|
+
const eventTokens = eventType.split('.');
|
|
318
|
+
for (let tokenIndex = 0; tokenIndex < partialEventTokens.length; tokenIndex++) {
|
|
319
|
+
const partialEventToken = partialEventTokens[tokenIndex];
|
|
320
|
+
const eventToken = eventTokens[tokenIndex];
|
|
321
|
+
if (partialEventToken === '*') {
|
|
322
|
+
const isLastToken = tokenIndex === partialEventTokens.length - 1;
|
|
323
|
+
if (!isLastToken) {
|
|
324
|
+
console.warn(`Infix wildcards in transition events are not allowed. Check the "${descriptor}" transition.`);
|
|
325
|
+
}
|
|
326
|
+
return isLastToken;
|
|
327
|
+
}
|
|
328
|
+
if (partialEventToken !== eventToken) {
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
334
|
+
|
|
291
335
|
function createScheduledEventId(actorRef, id) {
|
|
292
336
|
return `${actorRef.sessionId}.${id}`;
|
|
293
337
|
}
|
|
@@ -926,12 +970,14 @@ class Actor {
|
|
|
926
970
|
}
|
|
927
971
|
}
|
|
928
972
|
this.observers.clear();
|
|
973
|
+
this.eventListeners.clear();
|
|
929
974
|
}
|
|
930
975
|
_reportError(err) {
|
|
931
976
|
if (!this.observers.size) {
|
|
932
977
|
if (!this._parent) {
|
|
933
978
|
reportUnhandledError(err);
|
|
934
979
|
}
|
|
980
|
+
this.eventListeners.clear();
|
|
935
981
|
return;
|
|
936
982
|
}
|
|
937
983
|
let reportError = false;
|
|
@@ -945,6 +991,7 @@ class Actor {
|
|
|
945
991
|
}
|
|
946
992
|
}
|
|
947
993
|
this.observers.clear();
|
|
994
|
+
this.eventListeners.clear();
|
|
948
995
|
if (reportError) {
|
|
949
996
|
reportUnhandledError(err);
|
|
950
997
|
}
|
|
@@ -1273,6 +1320,16 @@ function resolveStop(_, snapshot, args, actionParams, {
|
|
|
1273
1320
|
children
|
|
1274
1321
|
}), resolvedActorRef, undefined];
|
|
1275
1322
|
}
|
|
1323
|
+
function unregisterRecursively(actorScope, actorRef) {
|
|
1324
|
+
// unregister children first (depth-first)
|
|
1325
|
+
const snapshot = actorRef.getSnapshot();
|
|
1326
|
+
if (snapshot && 'children' in snapshot) {
|
|
1327
|
+
for (const child of Object.values(snapshot.children)) {
|
|
1328
|
+
unregisterRecursively(actorScope, child);
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
actorScope.system._unregister(actorRef);
|
|
1332
|
+
}
|
|
1276
1333
|
function executeStop(actorScope, actorRef) {
|
|
1277
1334
|
if (!actorRef) {
|
|
1278
1335
|
return;
|
|
@@ -1281,7 +1338,8 @@ function executeStop(actorScope, actorRef) {
|
|
|
1281
1338
|
// we need to eagerly unregister it here so a new actor with the same systemId can be registered immediately
|
|
1282
1339
|
// since we defer actual stopping of the actor but we don't defer actor creations (and we can't do that)
|
|
1283
1340
|
// this could throw on `systemId` collision, for example, when dealing with reentering transitions
|
|
1284
|
-
|
|
1341
|
+
// we also need to recursively unregister all nested children's systemIds
|
|
1342
|
+
unregisterRecursively(actorScope, actorRef);
|
|
1285
1343
|
|
|
1286
1344
|
// this allows us to prevent an actor from being started if it gets stopped within the same macrostep
|
|
1287
1345
|
// this can happen, for example, when the invoking state is being exited immediately by an always transition
|
|
@@ -1624,36 +1682,7 @@ function isInFinalState(stateNodeSet, stateNode) {
|
|
|
1624
1682
|
}
|
|
1625
1683
|
const isStateId = str => str[0] === STATE_IDENTIFIER;
|
|
1626
1684
|
function getCandidates(stateNode, receivedEventType) {
|
|
1627
|
-
const candidates = stateNode.transitions.get(receivedEventType) || [...stateNode.transitions.keys()].filter(eventDescriptor =>
|
|
1628
|
-
// check if transition is a wildcard transition,
|
|
1629
|
-
// which matches any non-transient events
|
|
1630
|
-
if (eventDescriptor === WILDCARD) {
|
|
1631
|
-
return true;
|
|
1632
|
-
}
|
|
1633
|
-
if (!eventDescriptor.endsWith('.*')) {
|
|
1634
|
-
return false;
|
|
1635
|
-
}
|
|
1636
|
-
if (/.*\*.+/.test(eventDescriptor)) {
|
|
1637
|
-
console.warn(`Wildcards can only be the last token of an event descriptor (e.g., "event.*") or the entire event descriptor ("*"). Check the "${eventDescriptor}" event.`);
|
|
1638
|
-
}
|
|
1639
|
-
const partialEventTokens = eventDescriptor.split('.');
|
|
1640
|
-
const eventTokens = receivedEventType.split('.');
|
|
1641
|
-
for (let tokenIndex = 0; tokenIndex < partialEventTokens.length; tokenIndex++) {
|
|
1642
|
-
const partialEventToken = partialEventTokens[tokenIndex];
|
|
1643
|
-
const eventToken = eventTokens[tokenIndex];
|
|
1644
|
-
if (partialEventToken === '*') {
|
|
1645
|
-
const isLastToken = tokenIndex === partialEventTokens.length - 1;
|
|
1646
|
-
if (!isLastToken) {
|
|
1647
|
-
console.warn(`Infix wildcards in transition events are not allowed. Check the "${eventDescriptor}" transition.`);
|
|
1648
|
-
}
|
|
1649
|
-
return isLastToken;
|
|
1650
|
-
}
|
|
1651
|
-
if (partialEventToken !== eventToken) {
|
|
1652
|
-
return false;
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
return true;
|
|
1656
|
-
}).sort((a, b) => b.length - a.length).flatMap(key => stateNode.transitions.get(key));
|
|
1685
|
+
const candidates = stateNode.transitions.get(receivedEventType) || [...stateNode.transitions.keys()].filter(eventDescriptor => matchesEventDescriptor(receivedEventType, eventDescriptor)).sort((a, b) => b.length - a.length).flatMap(key => stateNode.transitions.get(key));
|
|
1657
1686
|
return candidates;
|
|
1658
1687
|
}
|
|
1659
1688
|
|
|
@@ -2747,6 +2776,7 @@ exports.isMachineSnapshot = isMachineSnapshot;
|
|
|
2747
2776
|
exports.isStateId = isStateId;
|
|
2748
2777
|
exports.macrostep = macrostep;
|
|
2749
2778
|
exports.mapValues = mapValues;
|
|
2779
|
+
exports.matchesEventDescriptor = matchesEventDescriptor;
|
|
2750
2780
|
exports.matchesState = matchesState;
|
|
2751
2781
|
exports.microstep = microstep;
|
|
2752
2782
|
exports.not = not;
|
|
@@ -283,6 +283,44 @@ function getAllOwnEventDescriptors(snapshot) {
|
|
|
283
283
|
return [...new Set([...snapshot._nodes.flatMap(sn => sn.ownEvents)])];
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
+
/**
|
|
287
|
+
* Checks if an event type matches an event descriptor, supporting wildcards.
|
|
288
|
+
* Event descriptors can be:
|
|
289
|
+
*
|
|
290
|
+
* - Exact matches: "event.type"
|
|
291
|
+
* - Wildcard: "*"
|
|
292
|
+
* - Partial matches: "event.*"
|
|
293
|
+
*
|
|
294
|
+
* @param eventType - The actual event type string
|
|
295
|
+
* @param descriptor - The event descriptor to match against
|
|
296
|
+
* @returns True if the event type matches the descriptor
|
|
297
|
+
*/
|
|
298
|
+
function matchesEventDescriptor(eventType, descriptor) {
|
|
299
|
+
if (descriptor === eventType) {
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
if (descriptor === WILDCARD) {
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
if (!descriptor.endsWith('.*')) {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
const partialEventTokens = descriptor.split('.');
|
|
309
|
+
const eventTokens = eventType.split('.');
|
|
310
|
+
for (let tokenIndex = 0; tokenIndex < partialEventTokens.length; tokenIndex++) {
|
|
311
|
+
const partialEventToken = partialEventTokens[tokenIndex];
|
|
312
|
+
const eventToken = eventTokens[tokenIndex];
|
|
313
|
+
if (partialEventToken === '*') {
|
|
314
|
+
const isLastToken = tokenIndex === partialEventTokens.length - 1;
|
|
315
|
+
return isLastToken;
|
|
316
|
+
}
|
|
317
|
+
if (partialEventToken !== eventToken) {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return true;
|
|
322
|
+
}
|
|
323
|
+
|
|
286
324
|
function createScheduledEventId(actorRef, id) {
|
|
287
325
|
return `${actorRef.sessionId}.${id}`;
|
|
288
326
|
}
|
|
@@ -921,12 +959,14 @@ class Actor {
|
|
|
921
959
|
}
|
|
922
960
|
}
|
|
923
961
|
this.observers.clear();
|
|
962
|
+
this.eventListeners.clear();
|
|
924
963
|
}
|
|
925
964
|
_reportError(err) {
|
|
926
965
|
if (!this.observers.size) {
|
|
927
966
|
if (!this._parent) {
|
|
928
967
|
reportUnhandledError(err);
|
|
929
968
|
}
|
|
969
|
+
this.eventListeners.clear();
|
|
930
970
|
return;
|
|
931
971
|
}
|
|
932
972
|
let reportError = false;
|
|
@@ -940,6 +980,7 @@ class Actor {
|
|
|
940
980
|
}
|
|
941
981
|
}
|
|
942
982
|
this.observers.clear();
|
|
983
|
+
this.eventListeners.clear();
|
|
943
984
|
if (reportError) {
|
|
944
985
|
reportUnhandledError(err);
|
|
945
986
|
}
|
|
@@ -1246,6 +1287,16 @@ function resolveStop(_, snapshot, args, actionParams, {
|
|
|
1246
1287
|
children
|
|
1247
1288
|
}), resolvedActorRef, undefined];
|
|
1248
1289
|
}
|
|
1290
|
+
function unregisterRecursively(actorScope, actorRef) {
|
|
1291
|
+
// unregister children first (depth-first)
|
|
1292
|
+
const snapshot = actorRef.getSnapshot();
|
|
1293
|
+
if (snapshot && 'children' in snapshot) {
|
|
1294
|
+
for (const child of Object.values(snapshot.children)) {
|
|
1295
|
+
unregisterRecursively(actorScope, child);
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
actorScope.system._unregister(actorRef);
|
|
1299
|
+
}
|
|
1249
1300
|
function executeStop(actorScope, actorRef) {
|
|
1250
1301
|
if (!actorRef) {
|
|
1251
1302
|
return;
|
|
@@ -1254,7 +1305,8 @@ function executeStop(actorScope, actorRef) {
|
|
|
1254
1305
|
// we need to eagerly unregister it here so a new actor with the same systemId can be registered immediately
|
|
1255
1306
|
// since we defer actual stopping of the actor but we don't defer actor creations (and we can't do that)
|
|
1256
1307
|
// this could throw on `systemId` collision, for example, when dealing with reentering transitions
|
|
1257
|
-
|
|
1308
|
+
// we also need to recursively unregister all nested children's systemIds
|
|
1309
|
+
unregisterRecursively(actorScope, actorRef);
|
|
1258
1310
|
|
|
1259
1311
|
// this allows us to prevent an actor from being started if it gets stopped within the same macrostep
|
|
1260
1312
|
// this can happen, for example, when the invoking state is being exited immediately by an always transition
|
|
@@ -1586,30 +1638,7 @@ function isInFinalState(stateNodeSet, stateNode) {
|
|
|
1586
1638
|
}
|
|
1587
1639
|
const isStateId = str => str[0] === STATE_IDENTIFIER;
|
|
1588
1640
|
function getCandidates(stateNode, receivedEventType) {
|
|
1589
|
-
const candidates = stateNode.transitions.get(receivedEventType) || [...stateNode.transitions.keys()].filter(eventDescriptor =>
|
|
1590
|
-
// check if transition is a wildcard transition,
|
|
1591
|
-
// which matches any non-transient events
|
|
1592
|
-
if (eventDescriptor === WILDCARD) {
|
|
1593
|
-
return true;
|
|
1594
|
-
}
|
|
1595
|
-
if (!eventDescriptor.endsWith('.*')) {
|
|
1596
|
-
return false;
|
|
1597
|
-
}
|
|
1598
|
-
const partialEventTokens = eventDescriptor.split('.');
|
|
1599
|
-
const eventTokens = receivedEventType.split('.');
|
|
1600
|
-
for (let tokenIndex = 0; tokenIndex < partialEventTokens.length; tokenIndex++) {
|
|
1601
|
-
const partialEventToken = partialEventTokens[tokenIndex];
|
|
1602
|
-
const eventToken = eventTokens[tokenIndex];
|
|
1603
|
-
if (partialEventToken === '*') {
|
|
1604
|
-
const isLastToken = tokenIndex === partialEventTokens.length - 1;
|
|
1605
|
-
return isLastToken;
|
|
1606
|
-
}
|
|
1607
|
-
if (partialEventToken !== eventToken) {
|
|
1608
|
-
return false;
|
|
1609
|
-
}
|
|
1610
|
-
}
|
|
1611
|
-
return true;
|
|
1612
|
-
}).sort((a, b) => b.length - a.length).flatMap(key => stateNode.transitions.get(key));
|
|
1641
|
+
const candidates = stateNode.transitions.get(receivedEventType) || [...stateNode.transitions.keys()].filter(eventDescriptor => matchesEventDescriptor(receivedEventType, eventDescriptor)).sort((a, b) => b.length - a.length).flatMap(key => stateNode.transitions.get(key));
|
|
1613
1642
|
return candidates;
|
|
1614
1643
|
}
|
|
1615
1644
|
|
|
@@ -2650,4 +2679,4 @@ function raise(eventOrExpr, options) {
|
|
|
2650
2679
|
return raise;
|
|
2651
2680
|
}
|
|
2652
2681
|
|
|
2653
|
-
export { $$ACTOR_TYPE as $, Actor as A,
|
|
2682
|
+
export { $$ACTOR_TYPE as $, Actor as A, formatInitialTransition as B, getCandidates as C, resolveStateValue as D, getAllStateNodes as E, createMachineSnapshot as F, isInFinalState as G, macrostep as H, transitionNode as I, resolveActionsAndContext as J, createInitEvent as K, microstep as L, getInitialStateNodes as M, NULL_EVENT as N, toStatePath as O, isStateId as P, getStateNodeByPath as Q, getPersistedSnapshot as R, STATE_DELIMITER as S, resolveReferencedActor as T, XSTATE_ERROR as U, createErrorActorEvent as V, ProcessingStatus as W, XSTATE_STOP as X, cloneMachineSnapshot as Y, cancel as a, spawnChild as b, createActor as c, and as d, stateIn as e, isMachineSnapshot as f, getStateNodes as g, getAllOwnEventDescriptors as h, interpret as i, matchesState as j, toObserver as k, stop as l, matchesEventDescriptor as m, not as n, or as o, pathToStateValue as p, mapValues as q, raise as r, stopChild as s, toArray as t, formatTransitions as u, toTransitionConfigArray as v, formatTransition as w, evaluateGuard as x, createInvokeId as y, getDelayedTransitions as z };
|
package/dist/xstate.cjs.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
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 StateMachine = require('./StateMachine-
|
|
8
|
-
var assign = require('./assign-
|
|
9
|
-
var log = require('./log-
|
|
6
|
+
var guards_dist_xstateGuards = require('./raise-577e4163.cjs.js');
|
|
7
|
+
var StateMachine = require('./StateMachine-fee05db8.cjs.js');
|
|
8
|
+
var assign = require('./assign-592716a8.cjs.js');
|
|
9
|
+
var log = require('./log-9c9f917d.cjs.js');
|
|
10
10
|
require('../dev/dist/xstate-dev.cjs.js');
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -34,8 +34,9 @@ require('../dev/dist/xstate-dev.cjs.js');
|
|
|
34
34
|
*/
|
|
35
35
|
function assertEvent(event, type) {
|
|
36
36
|
const types = guards_dist_xstateGuards.toArray(type);
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const matches = types.some(descriptor => guards_dist_xstateGuards.matchesEventDescriptor(event.type, descriptor));
|
|
38
|
+
if (!matches) {
|
|
39
|
+
const typesText = types.length === 1 ? `type matching "${types[0]}"` : `one of types matching "${types.join('", "')}"`;
|
|
39
40
|
throw new Error(`Expected event ${JSON.stringify(event)} to have ${typesText}`);
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -151,6 +152,9 @@ function getNextSnapshot(actorLogic, snapshot, event) {
|
|
|
151
152
|
// at the moment we allow extra actors - ones that are not specified by `children`
|
|
152
153
|
// this could be reconsidered in the future
|
|
153
154
|
|
|
155
|
+
// used to keep only StateSchema relevant keys
|
|
156
|
+
// this helps with type serialization as it makes the inferred type much shorter when dealing with huge configs
|
|
157
|
+
|
|
154
158
|
function setup({
|
|
155
159
|
schemas,
|
|
156
160
|
actors,
|
|
@@ -3,10 +3,10 @@
|
|
|
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 StateMachine = require('./StateMachine-
|
|
8
|
-
var assign = require('./assign-
|
|
9
|
-
var log = require('./log-
|
|
6
|
+
var guards_dist_xstateGuards = require('./raise-ed7c6f3d.development.cjs.js');
|
|
7
|
+
var StateMachine = require('./StateMachine-6d24a98f.development.cjs.js');
|
|
8
|
+
var assign = require('./assign-577bb842.development.cjs.js');
|
|
9
|
+
var log = require('./log-3827c227.development.cjs.js');
|
|
10
10
|
require('../dev/dist/xstate-dev.development.cjs.js');
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -34,8 +34,9 @@ require('../dev/dist/xstate-dev.development.cjs.js');
|
|
|
34
34
|
*/
|
|
35
35
|
function assertEvent(event, type) {
|
|
36
36
|
const types = guards_dist_xstateGuards.toArray(type);
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const matches = types.some(descriptor => guards_dist_xstateGuards.matchesEventDescriptor(event.type, descriptor));
|
|
38
|
+
if (!matches) {
|
|
39
|
+
const typesText = types.length === 1 ? `type matching "${types[0]}"` : `one of types matching "${types.join('", "')}"`;
|
|
39
40
|
throw new Error(`Expected event ${JSON.stringify(event)} to have ${typesText}`);
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -151,6 +152,9 @@ function getNextSnapshot(actorLogic, snapshot, event) {
|
|
|
151
152
|
// at the moment we allow extra actors - ones that are not specified by `children`
|
|
152
153
|
// this could be reconsidered in the future
|
|
153
154
|
|
|
155
|
+
// used to keep only StateSchema relevant keys
|
|
156
|
+
// this helps with type serialization as it makes the inferred type much shorter when dealing with huge configs
|
|
157
|
+
|
|
154
158
|
function setup({
|
|
155
159
|
schemas,
|
|
156
160
|
actors,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.development.esm.js';
|
|
2
|
-
import { t as toArray, c as createActor, r as raise, a as cancel, s as stopChild, b as spawnChild } from './raise-
|
|
3
|
-
export { A as Actor, h as __unsafe_getAllOwnEventDescriptors, d as and, a as cancel, c as createActor, g as getStateNodes, i as interpret, f as isMachineSnapshot,
|
|
4
|
-
import { S as StateMachine } from './StateMachine-
|
|
5
|
-
export { S as StateMachine, a as StateNode } from './StateMachine-
|
|
6
|
-
import { a as assign } from './assign-
|
|
7
|
-
export { a as assign } from './assign-
|
|
8
|
-
import { s as sendTo, l as log, e as enqueueActions, a as emit } from './log-
|
|
9
|
-
export { S as SpecialTargets, a as emit, e as enqueueActions, f as forwardTo, l as log, b as sendParent, s as sendTo } from './log-
|
|
2
|
+
import { m as matchesEventDescriptor, t as toArray, c as createActor, r as raise, a as cancel, s as stopChild, b as spawnChild } from './raise-13a60c49.development.esm.js';
|
|
3
|
+
export { A as Actor, h as __unsafe_getAllOwnEventDescriptors, d as and, a as cancel, c as createActor, g as getStateNodes, i as interpret, f as isMachineSnapshot, j as matchesState, n as not, o as or, p as pathToStateValue, r as raise, b as spawnChild, e as stateIn, l as stop, s as stopChild, k as toObserver } from './raise-13a60c49.development.esm.js';
|
|
4
|
+
import { S as StateMachine } from './StateMachine-d0e98d09.development.esm.js';
|
|
5
|
+
export { S as StateMachine, a as StateNode } from './StateMachine-d0e98d09.development.esm.js';
|
|
6
|
+
import { a as assign } from './assign-541a432d.development.esm.js';
|
|
7
|
+
export { a as assign } from './assign-541a432d.development.esm.js';
|
|
8
|
+
import { s as sendTo, l as log, e as enqueueActions, a as emit } from './log-b8ca474e.development.esm.js';
|
|
9
|
+
export { S as SpecialTargets, a as emit, e as enqueueActions, f as forwardTo, l as log, b as sendParent, s as sendTo } from './log-b8ca474e.development.esm.js';
|
|
10
10
|
import '../dev/dist/xstate-dev.development.esm.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -34,8 +34,9 @@ import '../dev/dist/xstate-dev.development.esm.js';
|
|
|
34
34
|
*/
|
|
35
35
|
function assertEvent(event, type) {
|
|
36
36
|
const types = toArray(type);
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const matches = types.some(descriptor => matchesEventDescriptor(event.type, descriptor));
|
|
38
|
+
if (!matches) {
|
|
39
|
+
const typesText = types.length === 1 ? `type matching "${types[0]}"` : `one of types matching "${types.join('", "')}"`;
|
|
39
40
|
throw new Error(`Expected event ${JSON.stringify(event)} to have ${typesText}`);
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -151,6 +152,9 @@ function getNextSnapshot(actorLogic, snapshot, event) {
|
|
|
151
152
|
// at the moment we allow extra actors - ones that are not specified by `children`
|
|
152
153
|
// this could be reconsidered in the future
|
|
153
154
|
|
|
155
|
+
// used to keep only StateSchema relevant keys
|
|
156
|
+
// this helps with type serialization as it makes the inferred type much shorter when dealing with huge configs
|
|
157
|
+
|
|
154
158
|
function setup({
|
|
155
159
|
schemas,
|
|
156
160
|
actors,
|
package/dist/xstate.esm.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.esm.js';
|
|
2
|
-
import { t as toArray, c as createActor, r as raise, a as cancel, s as stopChild, b as spawnChild } from './raise-
|
|
3
|
-
export { A as Actor, h as __unsafe_getAllOwnEventDescriptors, d as and, a as cancel, c as createActor, g as getStateNodes, i as interpret, f as isMachineSnapshot,
|
|
4
|
-
import { S as StateMachine } from './StateMachine-
|
|
5
|
-
export { S as StateMachine, a as StateNode } from './StateMachine-
|
|
6
|
-
import { a as assign } from './assign-
|
|
7
|
-
export { a as assign } from './assign-
|
|
8
|
-
import { s as sendTo, l as log, e as enqueueActions, a as emit } from './log-
|
|
9
|
-
export { S as SpecialTargets, a as emit, e as enqueueActions, f as forwardTo, l as log, b as sendParent, s as sendTo } from './log-
|
|
2
|
+
import { m as matchesEventDescriptor, t as toArray, c as createActor, r as raise, a as cancel, s as stopChild, b as spawnChild } from './raise-f5c7cb5b.esm.js';
|
|
3
|
+
export { A as Actor, h as __unsafe_getAllOwnEventDescriptors, d as and, a as cancel, c as createActor, g as getStateNodes, i as interpret, f as isMachineSnapshot, j as matchesState, n as not, o as or, p as pathToStateValue, r as raise, b as spawnChild, e as stateIn, l as stop, s as stopChild, k as toObserver } from './raise-f5c7cb5b.esm.js';
|
|
4
|
+
import { S as StateMachine } from './StateMachine-6c48f805.esm.js';
|
|
5
|
+
export { S as StateMachine, a as StateNode } from './StateMachine-6c48f805.esm.js';
|
|
6
|
+
import { a as assign } from './assign-37a2fc1e.esm.js';
|
|
7
|
+
export { a as assign } from './assign-37a2fc1e.esm.js';
|
|
8
|
+
import { s as sendTo, l as log, e as enqueueActions, a as emit } from './log-ce14fc9a.esm.js';
|
|
9
|
+
export { S as SpecialTargets, a as emit, e as enqueueActions, f as forwardTo, l as log, b as sendParent, s as sendTo } from './log-ce14fc9a.esm.js';
|
|
10
10
|
import '../dev/dist/xstate-dev.esm.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -34,8 +34,9 @@ import '../dev/dist/xstate-dev.esm.js';
|
|
|
34
34
|
*/
|
|
35
35
|
function assertEvent(event, type) {
|
|
36
36
|
const types = toArray(type);
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const matches = types.some(descriptor => matchesEventDescriptor(event.type, descriptor));
|
|
38
|
+
if (!matches) {
|
|
39
|
+
const typesText = types.length === 1 ? `type matching "${types[0]}"` : `one of types matching "${types.join('", "')}"`;
|
|
39
40
|
throw new Error(`Expected event ${JSON.stringify(event)} to have ${typesText}`);
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -151,6 +152,9 @@ function getNextSnapshot(actorLogic, snapshot, event) {
|
|
|
151
152
|
// at the moment we allow extra actors - ones that are not specified by `children`
|
|
152
153
|
// this could be reconsidered in the future
|
|
153
154
|
|
|
155
|
+
// used to keep only StateSchema relevant keys
|
|
156
|
+
// this helps with type serialization as it makes the inferred type much shorter when dealing with huge configs
|
|
157
|
+
|
|
154
158
|
function setup({
|
|
155
159
|
schemas,
|
|
156
160
|
actors,
|