xstate 5.0.0-beta.28 → 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 -139
- package/actors/dist/xstate-actors.cjs.mjs +1 -3
- package/actors/dist/xstate-actors.development.cjs.js +104 -139
- package/actors/dist/xstate-actors.development.cjs.mjs +1 -3
- package/actors/dist/xstate-actors.development.esm.js +105 -138
- package/actors/dist/xstate-actors.esm.js +105 -138
- 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/assign.d.ts +4 -4
- package/dist/declarations/src/actions/cancel.d.ts +4 -4
- package/dist/declarations/src/actions/choose.d.ts +3 -3
- package/dist/declarations/src/actions/log.d.ts +4 -4
- package/dist/declarations/src/actions/pure.d.ts +1 -1
- package/dist/declarations/src/actions/raise.d.ts +2 -2
- package/dist/declarations/src/actions/send.d.ts +7 -7
- package/dist/declarations/src/actions/stop.d.ts +4 -4
- package/dist/declarations/src/actors/callback.d.ts +8 -8
- package/dist/declarations/src/actors/index.d.ts +3 -5
- 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 +92 -70
- package/dist/{interpreter-a1432c7d.development.cjs.js → interpreter-7f1dc557.development.cjs.js} +9 -30
- package/dist/{interpreter-a77bb0ec.development.esm.js → interpreter-945c4b96.development.esm.js} +10 -28
- package/dist/{interpreter-672794ae.cjs.js → interpreter-a2c1e529.cjs.js} +9 -30
- package/dist/{interpreter-b5203bcb.esm.js → interpreter-b8f53c4b.esm.js} +10 -28
- package/dist/{raise-b9c9a234.esm.js → raise-0b7dde8b.esm.js} +13 -11
- package/dist/{raise-a60c9290.development.esm.js → raise-6e4f5cf7.development.esm.js} +13 -11
- package/dist/{raise-74b72ca5.development.cjs.js → raise-7cae872b.development.cjs.js} +13 -11
- package/dist/{raise-436a57a2.cjs.js → raise-e79b1f86.cjs.js} +13 -11
- package/dist/{send-e8b55d00.development.cjs.js → send-19a256f0.development.cjs.js} +2 -2
- package/dist/{send-e63b7b83.development.esm.js → send-a1d772da.development.esm.js} +2 -2
- package/dist/{send-35e1a689.cjs.js → send-e7063201.cjs.js} +2 -2
- package/dist/{send-4192e7bc.esm.js → send-f4fb3ba5.esm.js} +2 -2
- package/dist/xstate.cjs.js +20 -31
- package/dist/xstate.cjs.mjs +0 -2
- package/dist/xstate.development.cjs.js +20 -31
- package/dist/xstate.development.cjs.mjs +0 -2
- package/dist/xstate.development.esm.js +24 -33
- package/dist/xstate.esm.js +24 -33
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/guards/dist/xstate-guards.cjs.js +2 -2
- package/guards/dist/xstate-guards.development.cjs.js +2 -2
- package/guards/dist/xstate-guards.development.esm.js +2 -2
- package/guards/dist/xstate-guards.esm.js +2 -2
- package/guards/dist/xstate-guards.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/{interpreter-a1432c7d.development.cjs.js → interpreter-7f1dc557.development.cjs.js}
RENAMED
|
@@ -284,16 +284,6 @@ function mapContext(mapper, context, event, self) {
|
|
|
284
284
|
}
|
|
285
285
|
return mapper;
|
|
286
286
|
}
|
|
287
|
-
function isPromiseLike(value) {
|
|
288
|
-
if (value instanceof Promise) {
|
|
289
|
-
return true;
|
|
290
|
-
}
|
|
291
|
-
// Check if shape matches the Promise/A+ specification for a "thenable".
|
|
292
|
-
if (value !== null && (typeof value === 'function' || typeof value === 'object') && typeof value.then === 'function') {
|
|
293
|
-
return true;
|
|
294
|
-
}
|
|
295
|
-
return false;
|
|
296
|
-
}
|
|
297
287
|
function isArray(value) {
|
|
298
288
|
return Array.isArray(value);
|
|
299
289
|
}
|
|
@@ -347,7 +337,6 @@ let ActorStatus = /*#__PURE__*/function (ActorStatus) {
|
|
|
347
337
|
*/
|
|
348
338
|
const InterpreterStatus = ActorStatus;
|
|
349
339
|
const defaultOptions = {
|
|
350
|
-
deferEvents: true,
|
|
351
340
|
clock: {
|
|
352
341
|
setTimeout: (fn, ms) => {
|
|
353
342
|
return setTimeout(fn, ms);
|
|
@@ -463,10 +452,9 @@ class Actor {
|
|
|
463
452
|
|
|
464
453
|
// array of functions to defer
|
|
465
454
|
|
|
466
|
-
update(
|
|
455
|
+
update(snapshot) {
|
|
467
456
|
// Update state
|
|
468
|
-
this._state =
|
|
469
|
-
const snapshot = this.getSnapshot();
|
|
457
|
+
this._state = snapshot;
|
|
470
458
|
|
|
471
459
|
// Execute deferred effects
|
|
472
460
|
let deferredFn;
|
|
@@ -481,18 +469,17 @@ class Actor {
|
|
|
481
469
|
reportUnhandledError(err);
|
|
482
470
|
}
|
|
483
471
|
}
|
|
484
|
-
|
|
485
|
-
switch (status?.status) {
|
|
472
|
+
switch (this._state.status) {
|
|
486
473
|
case 'done':
|
|
487
474
|
this._stopProcedure();
|
|
488
475
|
this._complete();
|
|
489
|
-
this._doneEvent = createDoneActorEvent(this.id,
|
|
476
|
+
this._doneEvent = createDoneActorEvent(this.id, this._state.output);
|
|
490
477
|
this._parent?.send(this._doneEvent);
|
|
491
478
|
break;
|
|
492
479
|
case 'error':
|
|
493
480
|
this._stopProcedure();
|
|
494
|
-
this._error(
|
|
495
|
-
this._parent?.send(createErrorActorEvent(this.id,
|
|
481
|
+
this._error(this._state.error);
|
|
482
|
+
this._parent?.send(createErrorActorEvent(this.id, this._state.error));
|
|
496
483
|
break;
|
|
497
484
|
}
|
|
498
485
|
}
|
|
@@ -527,8 +514,8 @@ class Actor {
|
|
|
527
514
|
this.system._set(this._systemId, this);
|
|
528
515
|
}
|
|
529
516
|
this.status = ActorStatus.Running;
|
|
530
|
-
const status = this.
|
|
531
|
-
switch (status
|
|
517
|
+
const status = this._state.status;
|
|
518
|
+
switch (status) {
|
|
532
519
|
case 'done':
|
|
533
520
|
// a state machine can be "done" upon intialization (it could reach a final state using initial microsteps)
|
|
534
521
|
// we still need to complete observers, flush deferreds etc
|
|
@@ -682,11 +669,6 @@ class Actor {
|
|
|
682
669
|
}
|
|
683
670
|
return;
|
|
684
671
|
}
|
|
685
|
-
if (this.status !== ActorStatus.Running && !this.options.deferEvents) {
|
|
686
|
-
throw new Error(`Event "${event.type}" was sent to uninitialized actor "${this.id
|
|
687
|
-
// tslint:disable-next-line:max-line-length
|
|
688
|
-
}". Make sure .start() is called for this actor, or set { deferEvents: true } in the actor options.\nEvent: ${JSON.stringify(event)}`);
|
|
689
|
-
}
|
|
690
672
|
this.mailbox.enqueue(event);
|
|
691
673
|
}
|
|
692
674
|
|
|
@@ -737,7 +719,7 @@ class Actor {
|
|
|
737
719
|
return this;
|
|
738
720
|
}
|
|
739
721
|
getSnapshot() {
|
|
740
|
-
return this.
|
|
722
|
+
return this._state;
|
|
741
723
|
}
|
|
742
724
|
}
|
|
743
725
|
|
|
@@ -776,7 +758,6 @@ exports.XSTATE_INIT = XSTATE_INIT;
|
|
|
776
758
|
exports.XSTATE_STOP = XSTATE_STOP;
|
|
777
759
|
exports.createActor = createActor;
|
|
778
760
|
exports.createAfterEvent = createAfterEvent;
|
|
779
|
-
exports.createDoneActorEvent = createDoneActorEvent;
|
|
780
761
|
exports.createDoneStateEvent = createDoneStateEvent;
|
|
781
762
|
exports.createErrorActorEvent = createErrorActorEvent;
|
|
782
763
|
exports.createInitEvent = createInitEvent;
|
|
@@ -785,14 +766,12 @@ exports.flatten = flatten;
|
|
|
785
766
|
exports.interpret = interpret;
|
|
786
767
|
exports.isArray = isArray;
|
|
787
768
|
exports.isErrorActorEvent = isErrorActorEvent;
|
|
788
|
-
exports.isPromiseLike = isPromiseLike;
|
|
789
769
|
exports.mapContext = mapContext;
|
|
790
770
|
exports.mapValues = mapValues;
|
|
791
771
|
exports.matchesState = matchesState;
|
|
792
772
|
exports.normalizeTarget = normalizeTarget;
|
|
793
773
|
exports.pathToStateValue = pathToStateValue;
|
|
794
774
|
exports.resolveReferencedActor = resolveReferencedActor;
|
|
795
|
-
exports.symbolObservable = symbolObservable;
|
|
796
775
|
exports.toArray = toArray;
|
|
797
776
|
exports.toObserver = toObserver;
|
|
798
777
|
exports.toStatePath = toStatePath;
|
package/dist/{interpreter-a77bb0ec.development.esm.js → interpreter-945c4b96.development.esm.js}
RENAMED
|
@@ -282,16 +282,6 @@ function mapContext(mapper, context, event, self) {
|
|
|
282
282
|
}
|
|
283
283
|
return mapper;
|
|
284
284
|
}
|
|
285
|
-
function isPromiseLike(value) {
|
|
286
|
-
if (value instanceof Promise) {
|
|
287
|
-
return true;
|
|
288
|
-
}
|
|
289
|
-
// Check if shape matches the Promise/A+ specification for a "thenable".
|
|
290
|
-
if (value !== null && (typeof value === 'function' || typeof value === 'object') && typeof value.then === 'function') {
|
|
291
|
-
return true;
|
|
292
|
-
}
|
|
293
|
-
return false;
|
|
294
|
-
}
|
|
295
285
|
function isArray(value) {
|
|
296
286
|
return Array.isArray(value);
|
|
297
287
|
}
|
|
@@ -345,7 +335,6 @@ let ActorStatus = /*#__PURE__*/function (ActorStatus) {
|
|
|
345
335
|
*/
|
|
346
336
|
const InterpreterStatus = ActorStatus;
|
|
347
337
|
const defaultOptions = {
|
|
348
|
-
deferEvents: true,
|
|
349
338
|
clock: {
|
|
350
339
|
setTimeout: (fn, ms) => {
|
|
351
340
|
return setTimeout(fn, ms);
|
|
@@ -461,10 +450,9 @@ class Actor {
|
|
|
461
450
|
|
|
462
451
|
// array of functions to defer
|
|
463
452
|
|
|
464
|
-
update(
|
|
453
|
+
update(snapshot) {
|
|
465
454
|
// Update state
|
|
466
|
-
this._state =
|
|
467
|
-
const snapshot = this.getSnapshot();
|
|
455
|
+
this._state = snapshot;
|
|
468
456
|
|
|
469
457
|
// Execute deferred effects
|
|
470
458
|
let deferredFn;
|
|
@@ -479,18 +467,17 @@ class Actor {
|
|
|
479
467
|
reportUnhandledError(err);
|
|
480
468
|
}
|
|
481
469
|
}
|
|
482
|
-
|
|
483
|
-
switch (status?.status) {
|
|
470
|
+
switch (this._state.status) {
|
|
484
471
|
case 'done':
|
|
485
472
|
this._stopProcedure();
|
|
486
473
|
this._complete();
|
|
487
|
-
this._doneEvent = createDoneActorEvent(this.id,
|
|
474
|
+
this._doneEvent = createDoneActorEvent(this.id, this._state.output);
|
|
488
475
|
this._parent?.send(this._doneEvent);
|
|
489
476
|
break;
|
|
490
477
|
case 'error':
|
|
491
478
|
this._stopProcedure();
|
|
492
|
-
this._error(
|
|
493
|
-
this._parent?.send(createErrorActorEvent(this.id,
|
|
479
|
+
this._error(this._state.error);
|
|
480
|
+
this._parent?.send(createErrorActorEvent(this.id, this._state.error));
|
|
494
481
|
break;
|
|
495
482
|
}
|
|
496
483
|
}
|
|
@@ -525,8 +512,8 @@ class Actor {
|
|
|
525
512
|
this.system._set(this._systemId, this);
|
|
526
513
|
}
|
|
527
514
|
this.status = ActorStatus.Running;
|
|
528
|
-
const status = this.
|
|
529
|
-
switch (status
|
|
515
|
+
const status = this._state.status;
|
|
516
|
+
switch (status) {
|
|
530
517
|
case 'done':
|
|
531
518
|
// a state machine can be "done" upon intialization (it could reach a final state using initial microsteps)
|
|
532
519
|
// we still need to complete observers, flush deferreds etc
|
|
@@ -680,11 +667,6 @@ class Actor {
|
|
|
680
667
|
}
|
|
681
668
|
return;
|
|
682
669
|
}
|
|
683
|
-
if (this.status !== ActorStatus.Running && !this.options.deferEvents) {
|
|
684
|
-
throw new Error(`Event "${event.type}" was sent to uninitialized actor "${this.id
|
|
685
|
-
// tslint:disable-next-line:max-line-length
|
|
686
|
-
}". Make sure .start() is called for this actor, or set { deferEvents: true } in the actor options.\nEvent: ${JSON.stringify(event)}`);
|
|
687
|
-
}
|
|
688
670
|
this.mailbox.enqueue(event);
|
|
689
671
|
}
|
|
690
672
|
|
|
@@ -735,7 +717,7 @@ class Actor {
|
|
|
735
717
|
return this;
|
|
736
718
|
}
|
|
737
719
|
getSnapshot() {
|
|
738
|
-
return this.
|
|
720
|
+
return this._state;
|
|
739
721
|
}
|
|
740
722
|
}
|
|
741
723
|
|
|
@@ -762,4 +744,4 @@ const interpret = createActor;
|
|
|
762
744
|
* @deprecated Use `Actor` instead.
|
|
763
745
|
*/
|
|
764
746
|
|
|
765
|
-
export { Actor as A,
|
|
747
|
+
export { Actor as A, InterpreterStatus as I, NULL_EVENT as N, STATE_DELIMITER as S, WILDCARD as W, XSTATE_INIT as X, toTransitionConfigArray as a, createInitEvent as b, createInvokeId as c, createActor as d, matchesState as e, ActorStatus as f, interpret as g, toObserver as h, isErrorActorEvent as i, XSTATE_STOP as j, createErrorActorEvent as k, toStateValue as l, mapValues as m, STATE_IDENTIFIER as n, normalizeTarget as o, pathToStateValue as p, toStatePath as q, resolveReferencedActor as r, createDoneStateEvent as s, toArray as t, mapContext as u, isArray as v, createAfterEvent as w, flatten as x, XSTATE_ERROR as y };
|
|
@@ -281,16 +281,6 @@ function mapContext(mapper, context, event, self) {
|
|
|
281
281
|
}
|
|
282
282
|
return mapper;
|
|
283
283
|
}
|
|
284
|
-
function isPromiseLike(value) {
|
|
285
|
-
if (value instanceof Promise) {
|
|
286
|
-
return true;
|
|
287
|
-
}
|
|
288
|
-
// Check if shape matches the Promise/A+ specification for a "thenable".
|
|
289
|
-
if (value !== null && (typeof value === 'function' || typeof value === 'object') && typeof value.then === 'function') {
|
|
290
|
-
return true;
|
|
291
|
-
}
|
|
292
|
-
return false;
|
|
293
|
-
}
|
|
294
284
|
function isArray(value) {
|
|
295
285
|
return Array.isArray(value);
|
|
296
286
|
}
|
|
@@ -344,7 +334,6 @@ let ActorStatus = /*#__PURE__*/function (ActorStatus) {
|
|
|
344
334
|
*/
|
|
345
335
|
const InterpreterStatus = ActorStatus;
|
|
346
336
|
const defaultOptions = {
|
|
347
|
-
deferEvents: true,
|
|
348
337
|
clock: {
|
|
349
338
|
setTimeout: (fn, ms) => {
|
|
350
339
|
return setTimeout(fn, ms);
|
|
@@ -460,10 +449,9 @@ class Actor {
|
|
|
460
449
|
|
|
461
450
|
// array of functions to defer
|
|
462
451
|
|
|
463
|
-
update(
|
|
452
|
+
update(snapshot) {
|
|
464
453
|
// Update state
|
|
465
|
-
this._state =
|
|
466
|
-
const snapshot = this.getSnapshot();
|
|
454
|
+
this._state = snapshot;
|
|
467
455
|
|
|
468
456
|
// Execute deferred effects
|
|
469
457
|
let deferredFn;
|
|
@@ -478,18 +466,17 @@ class Actor {
|
|
|
478
466
|
reportUnhandledError(err);
|
|
479
467
|
}
|
|
480
468
|
}
|
|
481
|
-
|
|
482
|
-
switch (status?.status) {
|
|
469
|
+
switch (this._state.status) {
|
|
483
470
|
case 'done':
|
|
484
471
|
this._stopProcedure();
|
|
485
472
|
this._complete();
|
|
486
|
-
this._doneEvent = createDoneActorEvent(this.id,
|
|
473
|
+
this._doneEvent = createDoneActorEvent(this.id, this._state.output);
|
|
487
474
|
this._parent?.send(this._doneEvent);
|
|
488
475
|
break;
|
|
489
476
|
case 'error':
|
|
490
477
|
this._stopProcedure();
|
|
491
|
-
this._error(
|
|
492
|
-
this._parent?.send(createErrorActorEvent(this.id,
|
|
478
|
+
this._error(this._state.error);
|
|
479
|
+
this._parent?.send(createErrorActorEvent(this.id, this._state.error));
|
|
493
480
|
break;
|
|
494
481
|
}
|
|
495
482
|
}
|
|
@@ -524,8 +511,8 @@ class Actor {
|
|
|
524
511
|
this.system._set(this._systemId, this);
|
|
525
512
|
}
|
|
526
513
|
this.status = ActorStatus.Running;
|
|
527
|
-
const status = this.
|
|
528
|
-
switch (status
|
|
514
|
+
const status = this._state.status;
|
|
515
|
+
switch (status) {
|
|
529
516
|
case 'done':
|
|
530
517
|
// a state machine can be "done" upon intialization (it could reach a final state using initial microsteps)
|
|
531
518
|
// we still need to complete observers, flush deferreds etc
|
|
@@ -674,11 +661,6 @@ class Actor {
|
|
|
674
661
|
if (this.status === ActorStatus.Stopped) {
|
|
675
662
|
return;
|
|
676
663
|
}
|
|
677
|
-
if (this.status !== ActorStatus.Running && !this.options.deferEvents) {
|
|
678
|
-
throw new Error(`Event "${event.type}" was sent to uninitialized actor "${this.id
|
|
679
|
-
// tslint:disable-next-line:max-line-length
|
|
680
|
-
}". Make sure .start() is called for this actor, or set { deferEvents: true } in the actor options.\nEvent: ${JSON.stringify(event)}`);
|
|
681
|
-
}
|
|
682
664
|
this.mailbox.enqueue(event);
|
|
683
665
|
}
|
|
684
666
|
|
|
@@ -729,7 +711,7 @@ class Actor {
|
|
|
729
711
|
return this;
|
|
730
712
|
}
|
|
731
713
|
getSnapshot() {
|
|
732
|
-
return this.
|
|
714
|
+
return this._state;
|
|
733
715
|
}
|
|
734
716
|
}
|
|
735
717
|
|
|
@@ -768,7 +750,6 @@ exports.XSTATE_INIT = XSTATE_INIT;
|
|
|
768
750
|
exports.XSTATE_STOP = XSTATE_STOP;
|
|
769
751
|
exports.createActor = createActor;
|
|
770
752
|
exports.createAfterEvent = createAfterEvent;
|
|
771
|
-
exports.createDoneActorEvent = createDoneActorEvent;
|
|
772
753
|
exports.createDoneStateEvent = createDoneStateEvent;
|
|
773
754
|
exports.createErrorActorEvent = createErrorActorEvent;
|
|
774
755
|
exports.createInitEvent = createInitEvent;
|
|
@@ -777,14 +758,12 @@ exports.flatten = flatten;
|
|
|
777
758
|
exports.interpret = interpret;
|
|
778
759
|
exports.isArray = isArray;
|
|
779
760
|
exports.isErrorActorEvent = isErrorActorEvent;
|
|
780
|
-
exports.isPromiseLike = isPromiseLike;
|
|
781
761
|
exports.mapContext = mapContext;
|
|
782
762
|
exports.mapValues = mapValues;
|
|
783
763
|
exports.matchesState = matchesState;
|
|
784
764
|
exports.normalizeTarget = normalizeTarget;
|
|
785
765
|
exports.pathToStateValue = pathToStateValue;
|
|
786
766
|
exports.resolveReferencedActor = resolveReferencedActor;
|
|
787
|
-
exports.symbolObservable = symbolObservable;
|
|
788
767
|
exports.toArray = toArray;
|
|
789
768
|
exports.toObserver = toObserver;
|
|
790
769
|
exports.toStatePath = toStatePath;
|
|
@@ -279,16 +279,6 @@ function mapContext(mapper, context, event, self) {
|
|
|
279
279
|
}
|
|
280
280
|
return mapper;
|
|
281
281
|
}
|
|
282
|
-
function isPromiseLike(value) {
|
|
283
|
-
if (value instanceof Promise) {
|
|
284
|
-
return true;
|
|
285
|
-
}
|
|
286
|
-
// Check if shape matches the Promise/A+ specification for a "thenable".
|
|
287
|
-
if (value !== null && (typeof value === 'function' || typeof value === 'object') && typeof value.then === 'function') {
|
|
288
|
-
return true;
|
|
289
|
-
}
|
|
290
|
-
return false;
|
|
291
|
-
}
|
|
292
282
|
function isArray(value) {
|
|
293
283
|
return Array.isArray(value);
|
|
294
284
|
}
|
|
@@ -342,7 +332,6 @@ let ActorStatus = /*#__PURE__*/function (ActorStatus) {
|
|
|
342
332
|
*/
|
|
343
333
|
const InterpreterStatus = ActorStatus;
|
|
344
334
|
const defaultOptions = {
|
|
345
|
-
deferEvents: true,
|
|
346
335
|
clock: {
|
|
347
336
|
setTimeout: (fn, ms) => {
|
|
348
337
|
return setTimeout(fn, ms);
|
|
@@ -458,10 +447,9 @@ class Actor {
|
|
|
458
447
|
|
|
459
448
|
// array of functions to defer
|
|
460
449
|
|
|
461
|
-
update(
|
|
450
|
+
update(snapshot) {
|
|
462
451
|
// Update state
|
|
463
|
-
this._state =
|
|
464
|
-
const snapshot = this.getSnapshot();
|
|
452
|
+
this._state = snapshot;
|
|
465
453
|
|
|
466
454
|
// Execute deferred effects
|
|
467
455
|
let deferredFn;
|
|
@@ -476,18 +464,17 @@ class Actor {
|
|
|
476
464
|
reportUnhandledError(err);
|
|
477
465
|
}
|
|
478
466
|
}
|
|
479
|
-
|
|
480
|
-
switch (status?.status) {
|
|
467
|
+
switch (this._state.status) {
|
|
481
468
|
case 'done':
|
|
482
469
|
this._stopProcedure();
|
|
483
470
|
this._complete();
|
|
484
|
-
this._doneEvent = createDoneActorEvent(this.id,
|
|
471
|
+
this._doneEvent = createDoneActorEvent(this.id, this._state.output);
|
|
485
472
|
this._parent?.send(this._doneEvent);
|
|
486
473
|
break;
|
|
487
474
|
case 'error':
|
|
488
475
|
this._stopProcedure();
|
|
489
|
-
this._error(
|
|
490
|
-
this._parent?.send(createErrorActorEvent(this.id,
|
|
476
|
+
this._error(this._state.error);
|
|
477
|
+
this._parent?.send(createErrorActorEvent(this.id, this._state.error));
|
|
491
478
|
break;
|
|
492
479
|
}
|
|
493
480
|
}
|
|
@@ -522,8 +509,8 @@ class Actor {
|
|
|
522
509
|
this.system._set(this._systemId, this);
|
|
523
510
|
}
|
|
524
511
|
this.status = ActorStatus.Running;
|
|
525
|
-
const status = this.
|
|
526
|
-
switch (status
|
|
512
|
+
const status = this._state.status;
|
|
513
|
+
switch (status) {
|
|
527
514
|
case 'done':
|
|
528
515
|
// a state machine can be "done" upon intialization (it could reach a final state using initial microsteps)
|
|
529
516
|
// we still need to complete observers, flush deferreds etc
|
|
@@ -672,11 +659,6 @@ class Actor {
|
|
|
672
659
|
if (this.status === ActorStatus.Stopped) {
|
|
673
660
|
return;
|
|
674
661
|
}
|
|
675
|
-
if (this.status !== ActorStatus.Running && !this.options.deferEvents) {
|
|
676
|
-
throw new Error(`Event "${event.type}" was sent to uninitialized actor "${this.id
|
|
677
|
-
// tslint:disable-next-line:max-line-length
|
|
678
|
-
}". Make sure .start() is called for this actor, or set { deferEvents: true } in the actor options.\nEvent: ${JSON.stringify(event)}`);
|
|
679
|
-
}
|
|
680
662
|
this.mailbox.enqueue(event);
|
|
681
663
|
}
|
|
682
664
|
|
|
@@ -727,7 +709,7 @@ class Actor {
|
|
|
727
709
|
return this;
|
|
728
710
|
}
|
|
729
711
|
getSnapshot() {
|
|
730
|
-
return this.
|
|
712
|
+
return this._state;
|
|
731
713
|
}
|
|
732
714
|
}
|
|
733
715
|
|
|
@@ -754,4 +736,4 @@ const interpret = createActor;
|
|
|
754
736
|
* @deprecated Use `Actor` instead.
|
|
755
737
|
*/
|
|
756
738
|
|
|
757
|
-
export { Actor as A,
|
|
739
|
+
export { Actor as A, InterpreterStatus as I, NULL_EVENT as N, STATE_DELIMITER as S, WILDCARD as W, XSTATE_INIT as X, toTransitionConfigArray as a, createInitEvent as b, createInvokeId as c, createActor as d, matchesState as e, ActorStatus as f, interpret as g, toObserver as h, isErrorActorEvent as i, XSTATE_STOP as j, createErrorActorEvent as k, toStateValue as l, mapValues as m, STATE_IDENTIFIER as n, normalizeTarget as o, pathToStateValue as p, toStatePath as q, resolveReferencedActor as r, createDoneStateEvent as s, toArray as t, mapContext as u, isArray as v, createAfterEvent as w, flatten as x, XSTATE_ERROR as y };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as resolveReferencedActor, d as createActor, f as ActorStatus,
|
|
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, j as XSTATE_STOP, X as XSTATE_INIT, W as WILDCARD, v as isArray, w as createAfterEvent, x as flatten, e as matchesState } from './interpreter-b8f53c4b.esm.js';
|
|
2
2
|
|
|
3
3
|
const cache = new WeakMap();
|
|
4
4
|
function memo(object, key, fn) {
|
|
@@ -890,7 +890,7 @@ function microstepProcedure(transitions, currentState, mutConfiguration, event,
|
|
|
890
890
|
historyValue,
|
|
891
891
|
_internalQueue: internalQueue,
|
|
892
892
|
context: nextState.context,
|
|
893
|
-
done,
|
|
893
|
+
status: done ? 'done' : currentState.status,
|
|
894
894
|
output,
|
|
895
895
|
children: nextState.children
|
|
896
896
|
});
|
|
@@ -1119,7 +1119,7 @@ function macrostep(state, event, actorCtx) {
|
|
|
1119
1119
|
nextState = microstep(transitions, state, actorCtx, nextEvent, false);
|
|
1120
1120
|
states.push(nextState);
|
|
1121
1121
|
}
|
|
1122
|
-
while (
|
|
1122
|
+
while (nextState.status === 'active') {
|
|
1123
1123
|
let enabledTransitions = selectEventlessTransitions(nextState, nextEvent);
|
|
1124
1124
|
if (!enabledTransitions.length) {
|
|
1125
1125
|
if (!nextState._internalQueue.length) {
|
|
@@ -1136,7 +1136,7 @@ function macrostep(state, event, actorCtx) {
|
|
|
1136
1136
|
states.push(nextState);
|
|
1137
1137
|
}
|
|
1138
1138
|
}
|
|
1139
|
-
if (nextState.
|
|
1139
|
+
if (nextState.status !== 'active') {
|
|
1140
1140
|
// Perform the stop step to ensure that child actors are stopped
|
|
1141
1141
|
stopStep(nextEvent, nextState, actorCtx);
|
|
1142
1142
|
}
|
|
@@ -1229,7 +1229,8 @@ class State {
|
|
|
1229
1229
|
meta: {},
|
|
1230
1230
|
configuration: [],
|
|
1231
1231
|
// TODO: fix,
|
|
1232
|
-
children: {}
|
|
1232
|
+
children: {},
|
|
1233
|
+
status: 'active'
|
|
1233
1234
|
}, machine);
|
|
1234
1235
|
}
|
|
1235
1236
|
return stateValue;
|
|
@@ -1240,7 +1241,8 @@ class State {
|
|
|
1240
1241
|
context,
|
|
1241
1242
|
meta: undefined,
|
|
1242
1243
|
configuration: Array.from(configuration),
|
|
1243
|
-
children: {}
|
|
1244
|
+
children: {},
|
|
1245
|
+
status: 'active'
|
|
1244
1246
|
}, machine);
|
|
1245
1247
|
}
|
|
1246
1248
|
|
|
@@ -1253,8 +1255,7 @@ class State {
|
|
|
1253
1255
|
this.machine = machine;
|
|
1254
1256
|
this.tags = void 0;
|
|
1255
1257
|
this.value = void 0;
|
|
1256
|
-
this.
|
|
1257
|
-
this.output = void 0;
|
|
1258
|
+
this.status = void 0;
|
|
1258
1259
|
this.error = void 0;
|
|
1259
1260
|
this.context = void 0;
|
|
1260
1261
|
this.historyValue = {};
|
|
@@ -1270,7 +1271,7 @@ class State {
|
|
|
1270
1271
|
this.children = config.children;
|
|
1271
1272
|
this.value = getStateValue(machine.root, this.configuration);
|
|
1272
1273
|
this.tags = new Set(flatten(this.configuration.map(sn => sn.tags)));
|
|
1273
|
-
this.
|
|
1274
|
+
this.status = config.status;
|
|
1274
1275
|
this.output = config.output;
|
|
1275
1276
|
this.error = config.error;
|
|
1276
1277
|
}
|
|
@@ -1365,9 +1366,10 @@ function getPersistedState(state) {
|
|
|
1365
1366
|
} = state;
|
|
1366
1367
|
const childrenJson = {};
|
|
1367
1368
|
for (const id in children) {
|
|
1369
|
+
const child = children[id];
|
|
1368
1370
|
childrenJson[id] = {
|
|
1369
|
-
state:
|
|
1370
|
-
src:
|
|
1371
|
+
state: child.getPersistedState?.(),
|
|
1372
|
+
src: child.src
|
|
1371
1373
|
};
|
|
1372
1374
|
}
|
|
1373
1375
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as resolveReferencedActor, d as createActor, f as ActorStatus,
|
|
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 {
|