xstate 5.0.0-beta.49 → 5.0.0-beta.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/dist/xstate-actions.cjs.js +2 -2
- package/actions/dist/xstate-actions.development.cjs.js +2 -2
- package/actions/dist/xstate-actions.development.esm.js +2 -2
- package/actions/dist/xstate-actions.esm.js +2 -2
- package/actions/dist/xstate-actions.umd.min.js +1 -1
- package/actions/dist/xstate-actions.umd.min.js.map +1 -1
- package/actors/dist/xstate-actors.cjs.js +2 -4
- package/actors/dist/xstate-actors.development.cjs.js +2 -4
- package/actors/dist/xstate-actors.development.esm.js +2 -4
- package/actors/dist/xstate-actors.esm.js +2 -4
- 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/actors/callback.d.ts +5 -5
- package/dist/declarations/src/actors/observable.d.ts +5 -5
- package/dist/declarations/src/actors/promise.d.ts +2 -2
- package/dist/declarations/src/actors/transition.d.ts +3 -3
- package/dist/declarations/src/interpreter.d.ts +1 -0
- package/dist/declarations/src/setup.d.ts +2 -2
- package/dist/declarations/src/types.d.ts +5 -3
- package/dist/{raise-e4cc6d4f.esm.js → raise-32ec7226.esm.js} +92 -27
- package/dist/{raise-1873c645.development.esm.js → raise-6c05c91b.development.esm.js} +92 -27
- package/dist/{raise-8f9c4a5a.cjs.js → raise-8176cd35.cjs.js} +91 -27
- package/dist/{raise-495f4b9f.development.cjs.js → raise-dc9c2c58.development.cjs.js} +91 -27
- package/dist/{send-0a381ca2.development.esm.js → send-2b001f05.development.esm.js} +2 -7
- package/dist/{send-8ed5c8b2.cjs.js → send-7f3db830.cjs.js} +2 -7
- package/dist/{send-22880315.esm.js → send-88351a33.esm.js} +2 -7
- package/dist/{send-8d30b415.development.cjs.js → send-df1c8ef2.development.cjs.js} +2 -7
- package/dist/xstate.cjs.js +3 -13
- package/dist/xstate.development.cjs.js +3 -13
- package/dist/xstate.development.esm.js +5 -15
- package/dist/xstate.esm.js +5 -15
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/guards/dist/xstate-guards.cjs.js +1 -1
- package/guards/dist/xstate-guards.development.cjs.js +1 -1
- package/guards/dist/xstate-guards.development.esm.js +1 -1
- package/guards/dist/xstate-guards.esm.js +1 -1
- package/guards/dist/xstate-guards.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -451,7 +451,18 @@ class Actor {
|
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
453
|
_initState(persistedState) {
|
|
454
|
-
|
|
454
|
+
try {
|
|
455
|
+
this._state = persistedState ? this.logic.restoreState ? this.logic.restoreState(persistedState, this._actorScope) : persistedState : this.logic.getInitialState(this._actorScope, this.options?.input);
|
|
456
|
+
} catch (err) {
|
|
457
|
+
// if we get here then it means that we assign a value to this._state that is not of the correct type
|
|
458
|
+
// we can't get the true `TSnapshot & { status: 'error'; }`, it's impossible
|
|
459
|
+
// so right now this is a lie of sorts
|
|
460
|
+
this._state = {
|
|
461
|
+
status: 'error',
|
|
462
|
+
output: undefined,
|
|
463
|
+
error: err
|
|
464
|
+
};
|
|
465
|
+
}
|
|
455
466
|
}
|
|
456
467
|
update(snapshot, event) {
|
|
457
468
|
// Update state
|
|
@@ -460,17 +471,46 @@ class Actor {
|
|
|
460
471
|
// Execute deferred effects
|
|
461
472
|
let deferredFn;
|
|
462
473
|
while (deferredFn = this._deferred.shift()) {
|
|
463
|
-
deferredFn();
|
|
464
|
-
}
|
|
465
|
-
for (const observer of this.observers) {
|
|
466
474
|
try {
|
|
467
|
-
|
|
475
|
+
deferredFn();
|
|
468
476
|
} catch (err) {
|
|
469
|
-
|
|
477
|
+
// this error can only be caught when executing *initial* actions
|
|
478
|
+
// it's the only time when we call actions provided by the user through those deferreds
|
|
479
|
+
// when the actor is already running we always execute them synchronously while transitioning
|
|
480
|
+
// no "builtin deferred" should actually throw an error since they are either safe
|
|
481
|
+
// or the control flow is passed through the mailbox and errors should be caught by the `_process` used by the mailbox
|
|
482
|
+
this._deferred.length = 0;
|
|
483
|
+
this._state = {
|
|
484
|
+
...snapshot,
|
|
485
|
+
status: 'error',
|
|
486
|
+
error: err
|
|
487
|
+
};
|
|
470
488
|
}
|
|
471
489
|
}
|
|
472
490
|
switch (this._state.status) {
|
|
491
|
+
case 'active':
|
|
492
|
+
for (const observer of this.observers) {
|
|
493
|
+
try {
|
|
494
|
+
observer.next?.(snapshot);
|
|
495
|
+
} catch (err) {
|
|
496
|
+
reportUnhandledError(err);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
break;
|
|
473
500
|
case 'done':
|
|
501
|
+
// next observers are meant to be notified about done snapshots
|
|
502
|
+
// this can be seen as something that is different from how observable work
|
|
503
|
+
// but with observables `complete` callback is called without any arguments
|
|
504
|
+
// it's more ergonomic for XState to treat a done snapshot as a "next" value
|
|
505
|
+
// and the completion event as something that is separate,
|
|
506
|
+
// something that merely follows emitting that done snapshot
|
|
507
|
+
for (const observer of this.observers) {
|
|
508
|
+
try {
|
|
509
|
+
observer.next?.(snapshot);
|
|
510
|
+
} catch (err) {
|
|
511
|
+
reportUnhandledError(err);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
474
514
|
this._stopProcedure();
|
|
475
515
|
this._complete();
|
|
476
516
|
this._doneEvent = createDoneActorEvent(this.id, this._state.output);
|
|
@@ -479,11 +519,7 @@ class Actor {
|
|
|
479
519
|
}
|
|
480
520
|
break;
|
|
481
521
|
case 'error':
|
|
482
|
-
this._stopProcedure();
|
|
483
522
|
this._error(this._state.error);
|
|
484
|
-
if (this._parent) {
|
|
485
|
-
this.system._relay(this, this._parent, createErrorActorEvent(this.id, this._state.error));
|
|
486
|
-
}
|
|
487
523
|
break;
|
|
488
524
|
}
|
|
489
525
|
this.system._sendInspectionEvent({
|
|
@@ -573,7 +609,7 @@ class Actor {
|
|
|
573
609
|
this.subscribe({
|
|
574
610
|
next: snapshot => {
|
|
575
611
|
if (snapshot.status === 'active') {
|
|
576
|
-
this.
|
|
612
|
+
this.system._relay(this, this._parent, {
|
|
577
613
|
type: `xstate.snapshot.${this.id}`,
|
|
578
614
|
snapshot
|
|
579
615
|
});
|
|
@@ -602,18 +638,22 @@ class Actor {
|
|
|
602
638
|
// a state machine can be "done" upon initialization (it could reach a final state using initial microsteps)
|
|
603
639
|
// we still need to complete observers, flush deferreds etc
|
|
604
640
|
this.update(this._state, initEvent);
|
|
605
|
-
// fallthrough
|
|
606
|
-
case 'error':
|
|
607
641
|
// TODO: rethink cleanup of observers, mailbox, etc
|
|
608
642
|
return this;
|
|
643
|
+
case 'error':
|
|
644
|
+
this._error(this._state.error);
|
|
645
|
+
return this;
|
|
609
646
|
}
|
|
610
647
|
if (this.logic.start) {
|
|
611
648
|
try {
|
|
612
649
|
this.logic.start(this._state, this._actorScope);
|
|
613
650
|
} catch (err) {
|
|
614
|
-
this.
|
|
651
|
+
this._state = {
|
|
652
|
+
...this._state,
|
|
653
|
+
status: 'error',
|
|
654
|
+
error: err
|
|
655
|
+
};
|
|
615
656
|
this._error(err);
|
|
616
|
-
this._parent?.send(createErrorActorEvent(this.id, err));
|
|
617
657
|
return this;
|
|
618
658
|
}
|
|
619
659
|
}
|
|
@@ -629,7 +669,6 @@ class Actor {
|
|
|
629
669
|
return this;
|
|
630
670
|
}
|
|
631
671
|
_process(event) {
|
|
632
|
-
// TODO: reexamine what happens when an action (or a guard or smth) throws
|
|
633
672
|
let nextState;
|
|
634
673
|
let caughtError;
|
|
635
674
|
try {
|
|
@@ -644,9 +683,12 @@ class Actor {
|
|
|
644
683
|
const {
|
|
645
684
|
err
|
|
646
685
|
} = caughtError;
|
|
647
|
-
this.
|
|
686
|
+
this._state = {
|
|
687
|
+
...this._state,
|
|
688
|
+
status: 'error',
|
|
689
|
+
error: err
|
|
690
|
+
};
|
|
648
691
|
this._error(err);
|
|
649
|
-
this._parent?.send(createErrorActorEvent(this.id, err));
|
|
650
692
|
return;
|
|
651
693
|
}
|
|
652
694
|
this.update(nextState, event);
|
|
@@ -689,7 +731,7 @@ class Actor {
|
|
|
689
731
|
}
|
|
690
732
|
this.observers.clear();
|
|
691
733
|
}
|
|
692
|
-
|
|
734
|
+
_reportError(err) {
|
|
693
735
|
if (!this.observers.size) {
|
|
694
736
|
if (!this._parent) {
|
|
695
737
|
reportUnhandledError(err);
|
|
@@ -711,6 +753,18 @@ class Actor {
|
|
|
711
753
|
reportUnhandledError(err);
|
|
712
754
|
}
|
|
713
755
|
}
|
|
756
|
+
_error(err) {
|
|
757
|
+
this._stopProcedure();
|
|
758
|
+
this._reportError(err);
|
|
759
|
+
if (this._parent) {
|
|
760
|
+
this.system._relay(this, this._parent, createErrorActorEvent(this.id, err));
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
// TODO: atm children don't belong entirely to the actor so
|
|
764
|
+
// in a way - it's not even super aware of them
|
|
765
|
+
// so we can't stop them from here but we really should!
|
|
766
|
+
// right now, they are being stopped within the machine's transition
|
|
767
|
+
// but that could throw and leave us with "orphaned" active actors
|
|
714
768
|
_stopProcedure() {
|
|
715
769
|
if (this._processingStatus !== ProcessingStatus.Running) {
|
|
716
770
|
// Actor already stopped; do nothing
|
|
@@ -956,12 +1010,7 @@ function executeSpawn(actorScope, {
|
|
|
956
1010
|
if (actorRef._processingStatus === ProcessingStatus.Stopped) {
|
|
957
1011
|
return;
|
|
958
1012
|
}
|
|
959
|
-
|
|
960
|
-
actorRef.start?.();
|
|
961
|
-
} catch (err) {
|
|
962
|
-
actorScope.self.send(createErrorActorEvent(id, err));
|
|
963
|
-
return;
|
|
964
|
-
}
|
|
1013
|
+
actorRef.start();
|
|
965
1014
|
});
|
|
966
1015
|
}
|
|
967
1016
|
function spawnChild(...[src, {
|
|
@@ -2016,7 +2065,23 @@ function macrostep(state, event, actorScope, internalQueue = []) {
|
|
|
2016
2065
|
// Assume the state is at rest (no raised events)
|
|
2017
2066
|
// Determine the next state based on the next microstep
|
|
2018
2067
|
if (nextEvent.type !== XSTATE_INIT) {
|
|
2019
|
-
const
|
|
2068
|
+
const currentEvent = nextEvent;
|
|
2069
|
+
const isErr = isErrorActorEvent(currentEvent);
|
|
2070
|
+
const transitions = selectTransitions(currentEvent, nextState);
|
|
2071
|
+
if (isErr && !transitions.length) {
|
|
2072
|
+
// TODO: we should likely only allow transitions selected by very explicit descriptors
|
|
2073
|
+
// `*` shouldn't be matched, likely `xstate.error.*` shouldnt be either
|
|
2074
|
+
// similarly `xstate.error.actor.*` and `xstate.error.actor.todo.*` have to be considered too
|
|
2075
|
+
nextState = cloneMachineSnapshot(state, {
|
|
2076
|
+
status: 'error',
|
|
2077
|
+
error: currentEvent.data
|
|
2078
|
+
});
|
|
2079
|
+
states.push(nextState);
|
|
2080
|
+
return {
|
|
2081
|
+
state: nextState,
|
|
2082
|
+
microstates: states
|
|
2083
|
+
};
|
|
2084
|
+
}
|
|
2020
2085
|
nextState = microstep(transitions, state, actorScope, nextEvent, false, internalQueue);
|
|
2021
2086
|
states.push(nextState);
|
|
2022
2087
|
}
|
|
@@ -2284,7 +2349,6 @@ exports.getPersistedState = getPersistedState;
|
|
|
2284
2349
|
exports.getStateNodeByPath = getStateNodeByPath;
|
|
2285
2350
|
exports.getStateNodes = getStateNodes;
|
|
2286
2351
|
exports.interpret = interpret;
|
|
2287
|
-
exports.isErrorActorEvent = isErrorActorEvent;
|
|
2288
2352
|
exports.isInFinalState = isInFinalState;
|
|
2289
2353
|
exports.isMachineSnapshot = isMachineSnapshot;
|
|
2290
2354
|
exports.isStateId = isStateId;
|
|
@@ -454,7 +454,18 @@ class Actor {
|
|
|
454
454
|
}
|
|
455
455
|
}
|
|
456
456
|
_initState(persistedState) {
|
|
457
|
-
|
|
457
|
+
try {
|
|
458
|
+
this._state = persistedState ? this.logic.restoreState ? this.logic.restoreState(persistedState, this._actorScope) : persistedState : this.logic.getInitialState(this._actorScope, this.options?.input);
|
|
459
|
+
} catch (err) {
|
|
460
|
+
// if we get here then it means that we assign a value to this._state that is not of the correct type
|
|
461
|
+
// we can't get the true `TSnapshot & { status: 'error'; }`, it's impossible
|
|
462
|
+
// so right now this is a lie of sorts
|
|
463
|
+
this._state = {
|
|
464
|
+
status: 'error',
|
|
465
|
+
output: undefined,
|
|
466
|
+
error: err
|
|
467
|
+
};
|
|
468
|
+
}
|
|
458
469
|
}
|
|
459
470
|
update(snapshot, event) {
|
|
460
471
|
// Update state
|
|
@@ -463,17 +474,46 @@ class Actor {
|
|
|
463
474
|
// Execute deferred effects
|
|
464
475
|
let deferredFn;
|
|
465
476
|
while (deferredFn = this._deferred.shift()) {
|
|
466
|
-
deferredFn();
|
|
467
|
-
}
|
|
468
|
-
for (const observer of this.observers) {
|
|
469
477
|
try {
|
|
470
|
-
|
|
478
|
+
deferredFn();
|
|
471
479
|
} catch (err) {
|
|
472
|
-
|
|
480
|
+
// this error can only be caught when executing *initial* actions
|
|
481
|
+
// it's the only time when we call actions provided by the user through those deferreds
|
|
482
|
+
// when the actor is already running we always execute them synchronously while transitioning
|
|
483
|
+
// no "builtin deferred" should actually throw an error since they are either safe
|
|
484
|
+
// or the control flow is passed through the mailbox and errors should be caught by the `_process` used by the mailbox
|
|
485
|
+
this._deferred.length = 0;
|
|
486
|
+
this._state = {
|
|
487
|
+
...snapshot,
|
|
488
|
+
status: 'error',
|
|
489
|
+
error: err
|
|
490
|
+
};
|
|
473
491
|
}
|
|
474
492
|
}
|
|
475
493
|
switch (this._state.status) {
|
|
494
|
+
case 'active':
|
|
495
|
+
for (const observer of this.observers) {
|
|
496
|
+
try {
|
|
497
|
+
observer.next?.(snapshot);
|
|
498
|
+
} catch (err) {
|
|
499
|
+
reportUnhandledError(err);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
break;
|
|
476
503
|
case 'done':
|
|
504
|
+
// next observers are meant to be notified about done snapshots
|
|
505
|
+
// this can be seen as something that is different from how observable work
|
|
506
|
+
// but with observables `complete` callback is called without any arguments
|
|
507
|
+
// it's more ergonomic for XState to treat a done snapshot as a "next" value
|
|
508
|
+
// and the completion event as something that is separate,
|
|
509
|
+
// something that merely follows emitting that done snapshot
|
|
510
|
+
for (const observer of this.observers) {
|
|
511
|
+
try {
|
|
512
|
+
observer.next?.(snapshot);
|
|
513
|
+
} catch (err) {
|
|
514
|
+
reportUnhandledError(err);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
477
517
|
this._stopProcedure();
|
|
478
518
|
this._complete();
|
|
479
519
|
this._doneEvent = createDoneActorEvent(this.id, this._state.output);
|
|
@@ -482,11 +522,7 @@ class Actor {
|
|
|
482
522
|
}
|
|
483
523
|
break;
|
|
484
524
|
case 'error':
|
|
485
|
-
this._stopProcedure();
|
|
486
525
|
this._error(this._state.error);
|
|
487
|
-
if (this._parent) {
|
|
488
|
-
this.system._relay(this, this._parent, createErrorActorEvent(this.id, this._state.error));
|
|
489
|
-
}
|
|
490
526
|
break;
|
|
491
527
|
}
|
|
492
528
|
this.system._sendInspectionEvent({
|
|
@@ -576,7 +612,7 @@ class Actor {
|
|
|
576
612
|
this.subscribe({
|
|
577
613
|
next: snapshot => {
|
|
578
614
|
if (snapshot.status === 'active') {
|
|
579
|
-
this.
|
|
615
|
+
this.system._relay(this, this._parent, {
|
|
580
616
|
type: `xstate.snapshot.${this.id}`,
|
|
581
617
|
snapshot
|
|
582
618
|
});
|
|
@@ -605,18 +641,22 @@ class Actor {
|
|
|
605
641
|
// a state machine can be "done" upon initialization (it could reach a final state using initial microsteps)
|
|
606
642
|
// we still need to complete observers, flush deferreds etc
|
|
607
643
|
this.update(this._state, initEvent);
|
|
608
|
-
// fallthrough
|
|
609
|
-
case 'error':
|
|
610
644
|
// TODO: rethink cleanup of observers, mailbox, etc
|
|
611
645
|
return this;
|
|
646
|
+
case 'error':
|
|
647
|
+
this._error(this._state.error);
|
|
648
|
+
return this;
|
|
612
649
|
}
|
|
613
650
|
if (this.logic.start) {
|
|
614
651
|
try {
|
|
615
652
|
this.logic.start(this._state, this._actorScope);
|
|
616
653
|
} catch (err) {
|
|
617
|
-
this.
|
|
654
|
+
this._state = {
|
|
655
|
+
...this._state,
|
|
656
|
+
status: 'error',
|
|
657
|
+
error: err
|
|
658
|
+
};
|
|
618
659
|
this._error(err);
|
|
619
|
-
this._parent?.send(createErrorActorEvent(this.id, err));
|
|
620
660
|
return this;
|
|
621
661
|
}
|
|
622
662
|
}
|
|
@@ -632,7 +672,6 @@ class Actor {
|
|
|
632
672
|
return this;
|
|
633
673
|
}
|
|
634
674
|
_process(event) {
|
|
635
|
-
// TODO: reexamine what happens when an action (or a guard or smth) throws
|
|
636
675
|
let nextState;
|
|
637
676
|
let caughtError;
|
|
638
677
|
try {
|
|
@@ -647,9 +686,12 @@ class Actor {
|
|
|
647
686
|
const {
|
|
648
687
|
err
|
|
649
688
|
} = caughtError;
|
|
650
|
-
this.
|
|
689
|
+
this._state = {
|
|
690
|
+
...this._state,
|
|
691
|
+
status: 'error',
|
|
692
|
+
error: err
|
|
693
|
+
};
|
|
651
694
|
this._error(err);
|
|
652
|
-
this._parent?.send(createErrorActorEvent(this.id, err));
|
|
653
695
|
return;
|
|
654
696
|
}
|
|
655
697
|
this.update(nextState, event);
|
|
@@ -692,7 +734,7 @@ class Actor {
|
|
|
692
734
|
}
|
|
693
735
|
this.observers.clear();
|
|
694
736
|
}
|
|
695
|
-
|
|
737
|
+
_reportError(err) {
|
|
696
738
|
if (!this.observers.size) {
|
|
697
739
|
if (!this._parent) {
|
|
698
740
|
reportUnhandledError(err);
|
|
@@ -714,6 +756,18 @@ class Actor {
|
|
|
714
756
|
reportUnhandledError(err);
|
|
715
757
|
}
|
|
716
758
|
}
|
|
759
|
+
_error(err) {
|
|
760
|
+
this._stopProcedure();
|
|
761
|
+
this._reportError(err);
|
|
762
|
+
if (this._parent) {
|
|
763
|
+
this.system._relay(this, this._parent, createErrorActorEvent(this.id, err));
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
// TODO: atm children don't belong entirely to the actor so
|
|
767
|
+
// in a way - it's not even super aware of them
|
|
768
|
+
// so we can't stop them from here but we really should!
|
|
769
|
+
// right now, they are being stopped within the machine's transition
|
|
770
|
+
// but that could throw and leave us with "orphaned" active actors
|
|
717
771
|
_stopProcedure() {
|
|
718
772
|
if (this._processingStatus !== ProcessingStatus.Running) {
|
|
719
773
|
// Actor already stopped; do nothing
|
|
@@ -973,12 +1027,7 @@ function executeSpawn(actorScope, {
|
|
|
973
1027
|
if (actorRef._processingStatus === ProcessingStatus.Stopped) {
|
|
974
1028
|
return;
|
|
975
1029
|
}
|
|
976
|
-
|
|
977
|
-
actorRef.start?.();
|
|
978
|
-
} catch (err) {
|
|
979
|
-
actorScope.self.send(createErrorActorEvent(id, err));
|
|
980
|
-
return;
|
|
981
|
-
}
|
|
1030
|
+
actorRef.start();
|
|
982
1031
|
});
|
|
983
1032
|
}
|
|
984
1033
|
function spawnChild(...[src, {
|
|
@@ -2061,7 +2110,23 @@ function macrostep(state, event, actorScope, internalQueue = []) {
|
|
|
2061
2110
|
// Assume the state is at rest (no raised events)
|
|
2062
2111
|
// Determine the next state based on the next microstep
|
|
2063
2112
|
if (nextEvent.type !== XSTATE_INIT) {
|
|
2064
|
-
const
|
|
2113
|
+
const currentEvent = nextEvent;
|
|
2114
|
+
const isErr = isErrorActorEvent(currentEvent);
|
|
2115
|
+
const transitions = selectTransitions(currentEvent, nextState);
|
|
2116
|
+
if (isErr && !transitions.length) {
|
|
2117
|
+
// TODO: we should likely only allow transitions selected by very explicit descriptors
|
|
2118
|
+
// `*` shouldn't be matched, likely `xstate.error.*` shouldnt be either
|
|
2119
|
+
// similarly `xstate.error.actor.*` and `xstate.error.actor.todo.*` have to be considered too
|
|
2120
|
+
nextState = cloneMachineSnapshot(state, {
|
|
2121
|
+
status: 'error',
|
|
2122
|
+
error: currentEvent.data
|
|
2123
|
+
});
|
|
2124
|
+
states.push(nextState);
|
|
2125
|
+
return {
|
|
2126
|
+
state: nextState,
|
|
2127
|
+
microstates: states
|
|
2128
|
+
};
|
|
2129
|
+
}
|
|
2065
2130
|
nextState = microstep(transitions, state, actorScope, nextEvent, false, internalQueue);
|
|
2066
2131
|
states.push(nextState);
|
|
2067
2132
|
}
|
|
@@ -2338,7 +2403,6 @@ exports.getPersistedState = getPersistedState;
|
|
|
2338
2403
|
exports.getStateNodeByPath = getStateNodeByPath;
|
|
2339
2404
|
exports.getStateNodes = getStateNodes;
|
|
2340
2405
|
exports.interpret = interpret;
|
|
2341
|
-
exports.isErrorActorEvent = isErrorActorEvent;
|
|
2342
2406
|
exports.isInFinalState = isInFinalState;
|
|
2343
2407
|
exports.isMachineSnapshot = isMachineSnapshot;
|
|
2344
2408
|
exports.isStateId = isStateId;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, e as evaluateGuard, t as toArray, U as XSTATE_ERROR, V as createErrorActorEvent } from './raise-6c05c91b.development.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, {
|
|
4
4
|
machine,
|
|
@@ -47,12 +47,7 @@ function createSpawner(actorScope, {
|
|
|
47
47
|
if (actorRef._processingStatus === ProcessingStatus.Stopped) {
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
actorRef.start?.();
|
|
52
|
-
} catch (err) {
|
|
53
|
-
actorScope.self.send(createErrorActorEvent(actorRef.id, err));
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
50
|
+
actorRef.start();
|
|
56
51
|
});
|
|
57
52
|
return actorRef;
|
|
58
53
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-8176cd35.cjs.js');
|
|
4
4
|
|
|
5
5
|
function createSpawner(actorScope, {
|
|
6
6
|
machine,
|
|
@@ -49,12 +49,7 @@ function createSpawner(actorScope, {
|
|
|
49
49
|
if (actorRef._processingStatus === guards_dist_xstateGuards.ProcessingStatus.Stopped) {
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
actorRef.start?.();
|
|
54
|
-
} catch (err) {
|
|
55
|
-
actorScope.self.send(guards_dist_xstateGuards.createErrorActorEvent(actorRef.id, err));
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
52
|
+
actorRef.start();
|
|
58
53
|
});
|
|
59
54
|
return actorRef;
|
|
60
55
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, e as evaluateGuard, t as toArray, U as XSTATE_ERROR, V as createErrorActorEvent } from './raise-32ec7226.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, {
|
|
4
4
|
machine,
|
|
@@ -47,12 +47,7 @@ function createSpawner(actorScope, {
|
|
|
47
47
|
if (actorRef._processingStatus === ProcessingStatus.Stopped) {
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
actorRef.start?.();
|
|
52
|
-
} catch (err) {
|
|
53
|
-
actorScope.self.send(createErrorActorEvent(actorRef.id, err));
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
50
|
+
actorRef.start();
|
|
56
51
|
});
|
|
57
52
|
return actorRef;
|
|
58
53
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-dc9c2c58.development.cjs.js');
|
|
4
4
|
|
|
5
5
|
function createSpawner(actorScope, {
|
|
6
6
|
machine,
|
|
@@ -49,12 +49,7 @@ function createSpawner(actorScope, {
|
|
|
49
49
|
if (actorRef._processingStatus === guards_dist_xstateGuards.ProcessingStatus.Stopped) {
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
actorRef.start?.();
|
|
54
|
-
} catch (err) {
|
|
55
|
-
actorScope.self.send(guards_dist_xstateGuards.createErrorActorEvent(actorRef.id, err));
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
52
|
+
actorRef.start();
|
|
58
53
|
});
|
|
59
54
|
return actorRef;
|
|
60
55
|
};
|
package/dist/xstate.cjs.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var actors_dist_xstateActors = require('../actors/dist/xstate-actors.cjs.js');
|
|
6
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
7
|
-
var send = require('./send-
|
|
6
|
+
var guards_dist_xstateGuards = require('./raise-8176cd35.cjs.js');
|
|
7
|
+
var send = require('./send-7f3db830.cjs.js');
|
|
8
8
|
require('../dev/dist/xstate-dev.cjs.js');
|
|
9
9
|
|
|
10
10
|
class SimulatedClock {
|
|
@@ -458,17 +458,7 @@ class StateMachine {
|
|
|
458
458
|
* @param event The received event
|
|
459
459
|
*/
|
|
460
460
|
transition(snapshot, event, actorScope) {
|
|
461
|
-
|
|
462
|
-
if (guards_dist_xstateGuards.isErrorActorEvent(event) && !guards_dist_xstateGuards.getAllOwnEventDescriptors(snapshot).some(nextEvent => nextEvent === event.type)) {
|
|
463
|
-
return guards_dist_xstateGuards.cloneMachineSnapshot(snapshot, {
|
|
464
|
-
status: 'error',
|
|
465
|
-
error: event.data
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
const {
|
|
469
|
-
state: nextState
|
|
470
|
-
} = guards_dist_xstateGuards.macrostep(snapshot, event, actorScope);
|
|
471
|
-
return nextState;
|
|
461
|
+
return guards_dist_xstateGuards.macrostep(snapshot, event, actorScope).state;
|
|
472
462
|
}
|
|
473
463
|
|
|
474
464
|
/**
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var actors_dist_xstateActors = require('../actors/dist/xstate-actors.development.cjs.js');
|
|
6
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
7
|
-
var send = require('./send-
|
|
6
|
+
var guards_dist_xstateGuards = require('./raise-dc9c2c58.development.cjs.js');
|
|
7
|
+
var send = require('./send-df1c8ef2.development.cjs.js');
|
|
8
8
|
require('../dev/dist/xstate-dev.development.cjs.js');
|
|
9
9
|
|
|
10
10
|
class SimulatedClock {
|
|
@@ -461,17 +461,7 @@ class StateMachine {
|
|
|
461
461
|
* @param event The received event
|
|
462
462
|
*/
|
|
463
463
|
transition(snapshot, event, actorScope) {
|
|
464
|
-
|
|
465
|
-
if (guards_dist_xstateGuards.isErrorActorEvent(event) && !guards_dist_xstateGuards.getAllOwnEventDescriptors(snapshot).some(nextEvent => nextEvent === event.type)) {
|
|
466
|
-
return guards_dist_xstateGuards.cloneMachineSnapshot(snapshot, {
|
|
467
|
-
status: 'error',
|
|
468
|
-
error: event.data
|
|
469
|
-
});
|
|
470
|
-
}
|
|
471
|
-
const {
|
|
472
|
-
state: nextState
|
|
473
|
-
} = guards_dist_xstateGuards.macrostep(snapshot, event, actorScope);
|
|
474
|
-
return nextState;
|
|
464
|
+
return guards_dist_xstateGuards.macrostep(snapshot, event, actorScope).state;
|
|
475
465
|
}
|
|
476
466
|
|
|
477
467
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.development.esm.js';
|
|
2
|
-
import { S as STATE_DELIMITER, m as mapValues, t as toArray, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as
|
|
3
|
-
export {
|
|
4
|
-
import { a as assign } from './send-
|
|
5
|
-
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, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as macrostep, o as transitionNode, p as resolveActionsAndContext, q as createInitEvent, s as microstep, u as getInitialStateNodes, v as isStateId, w as getStateNodeByPath, x as getPersistedState, y as resolveReferencedActor, z as createActor, $ as $$ACTOR_TYPE } from './raise-6c05c91b.development.esm.js';
|
|
3
|
+
export { A as Actor, G as __unsafe_getAllOwnEventDescriptors, H as and, L as cancel, z as createActor, j as getStateNodes, B as interpret, C as isMachineSnapshot, D as matchesState, I as not, J as or, E as pathToStateValue, M as raise, Q as spawnChild, K as stateIn, O as stop, P as stopChild, F as toObserver } from './raise-6c05c91b.development.esm.js';
|
|
4
|
+
import { a as assign } from './send-2b001f05.development.esm.js';
|
|
5
|
+
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-2b001f05.development.esm.js';
|
|
6
6
|
import '../dev/dist/xstate-dev.development.esm.js';
|
|
7
7
|
|
|
8
8
|
class SimulatedClock {
|
|
@@ -459,17 +459,7 @@ class StateMachine {
|
|
|
459
459
|
* @param event The received event
|
|
460
460
|
*/
|
|
461
461
|
transition(snapshot, event, actorScope) {
|
|
462
|
-
|
|
463
|
-
if (isErrorActorEvent(event) && !getAllOwnEventDescriptors(snapshot).some(nextEvent => nextEvent === event.type)) {
|
|
464
|
-
return cloneMachineSnapshot(snapshot, {
|
|
465
|
-
status: 'error',
|
|
466
|
-
error: event.data
|
|
467
|
-
});
|
|
468
|
-
}
|
|
469
|
-
const {
|
|
470
|
-
state: nextState
|
|
471
|
-
} = macrostep(snapshot, event, actorScope);
|
|
472
|
-
return nextState;
|
|
462
|
+
return macrostep(snapshot, event, actorScope).state;
|
|
473
463
|
}
|
|
474
464
|
|
|
475
465
|
/**
|
package/dist/xstate.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.esm.js';
|
|
2
|
-
import { S as STATE_DELIMITER, m as mapValues, t as toArray, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as
|
|
3
|
-
export {
|
|
4
|
-
import { a as assign } from './send-
|
|
5
|
-
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, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as macrostep, o as transitionNode, p as resolveActionsAndContext, q as createInitEvent, s as microstep, u as getInitialStateNodes, v as isStateId, w as getStateNodeByPath, x as getPersistedState, y as resolveReferencedActor, z as createActor, $ as $$ACTOR_TYPE } from './raise-32ec7226.esm.js';
|
|
3
|
+
export { A as Actor, G as __unsafe_getAllOwnEventDescriptors, H as and, L as cancel, z as createActor, j as getStateNodes, B as interpret, C as isMachineSnapshot, D as matchesState, I as not, J as or, E as pathToStateValue, M as raise, Q as spawnChild, K as stateIn, O as stop, P as stopChild, F as toObserver } from './raise-32ec7226.esm.js';
|
|
4
|
+
import { a as assign } from './send-88351a33.esm.js';
|
|
5
|
+
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-88351a33.esm.js';
|
|
6
6
|
import '../dev/dist/xstate-dev.esm.js';
|
|
7
7
|
|
|
8
8
|
class SimulatedClock {
|
|
@@ -456,17 +456,7 @@ class StateMachine {
|
|
|
456
456
|
* @param event The received event
|
|
457
457
|
*/
|
|
458
458
|
transition(snapshot, event, actorScope) {
|
|
459
|
-
|
|
460
|
-
if (isErrorActorEvent(event) && !getAllOwnEventDescriptors(snapshot).some(nextEvent => nextEvent === event.type)) {
|
|
461
|
-
return cloneMachineSnapshot(snapshot, {
|
|
462
|
-
status: 'error',
|
|
463
|
-
error: event.data
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
|
-
const {
|
|
467
|
-
state: nextState
|
|
468
|
-
} = macrostep(snapshot, event, actorScope);
|
|
469
|
-
return nextState;
|
|
459
|
+
return macrostep(snapshot, event, actorScope).state;
|
|
470
460
|
}
|
|
471
461
|
|
|
472
462
|
/**
|