xstate 5.0.0-beta.8 → 5.0.0-beta.9
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.d.mts +2 -0
- package/actions/dist/xstate-actions.cjs.d.mts.map +1 -0
- package/actions/dist/xstate-actions.cjs.d.ts +1 -0
- package/actions/dist/xstate-actions.cjs.d.ts.map +1 -0
- package/actions/dist/xstate-actions.cjs.dev.js +1 -1
- package/actions/dist/xstate-actions.cjs.mjs +25 -0
- package/actions/dist/xstate-actions.cjs.prod.js +2 -2
- package/actions/dist/xstate-actions.esm.js +1 -1
- 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.d.mts +2 -0
- package/actors/dist/xstate-actors.cjs.d.mts.map +1 -0
- package/actors/dist/xstate-actors.cjs.d.ts +1 -0
- package/actors/dist/xstate-actors.cjs.d.ts.map +1 -0
- package/actors/dist/xstate-actors.cjs.dev.js +1 -1
- package/actors/dist/xstate-actors.cjs.mjs +15 -0
- package/actors/dist/xstate-actors.cjs.prod.js +2 -2
- package/actors/dist/xstate-actors.esm.js +1 -1
- package/actors/dist/xstate-actors.umd.min.js +1 -1
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dev/dist/xstate-dev.cjs.d.mts +2 -0
- package/dev/dist/xstate-dev.cjs.d.mts.map +1 -0
- package/dev/dist/xstate-dev.cjs.d.ts +1 -0
- package/dev/dist/xstate-dev.cjs.d.ts.map +1 -0
- package/dev/dist/xstate-dev.cjs.mjs +5 -0
- package/dev/dist/xstate-dev.cjs.prod.js +6 -43
- package/dev/dist/xstate-dev.umd.min.js.map +1 -1
- package/dist/{actions-d06ca158.cjs.dev.js → actions-b6357569.cjs.dev.js} +164 -114
- package/dist/{actions-900f9761.cjs.prod.js → actions-bd4a184d.cjs.prod.js} +191 -117
- package/dist/{actions-c8d7df32.esm.js → actions-de434a04.esm.js} +120 -104
- package/dist/declarations/src/interpreter.d.ts +3 -2
- package/dist/declarations/src/typegenTypes.d.ts +7 -1
- package/dist/declarations/src/types.d.ts +2 -1
- package/dist/index-0f3fdf0c.cjs.prod.js +52 -0
- package/dist/xstate.cjs.d.mts +2 -0
- package/dist/xstate.cjs.d.mts.map +1 -0
- package/dist/xstate.cjs.d.ts +1 -0
- package/dist/xstate.cjs.d.ts.map +1 -0
- package/dist/xstate.cjs.dev.js +13 -19
- package/dist/xstate.cjs.mjs +39 -0
- package/dist/xstate.cjs.prod.js +14 -20
- package/dist/xstate.esm.js +11 -11
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/guards/dist/xstate-guards.cjs.d.mts +2 -0
- package/guards/dist/xstate-guards.cjs.d.mts.map +1 -0
- package/guards/dist/xstate-guards.cjs.d.ts +1 -0
- package/guards/dist/xstate-guards.cjs.d.ts.map +1 -0
- package/guards/dist/xstate-guards.cjs.dev.js +1 -1
- package/guards/dist/xstate-guards.cjs.mjs +8 -0
- package/guards/dist/xstate-guards.cjs.prod.js +2 -2
- package/guards/dist/xstate-guards.esm.js +1 -1
- package/guards/dist/xstate-guards.umd.min.js.map +1 -1
- package/package.json +7 -1
|
@@ -1,8 +1,40 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var dev_dist_xstateDev = require('
|
|
3
|
+
var dev_dist_xstateDev = require('./index-0f3fdf0c.cjs.prod.js');
|
|
4
4
|
|
|
5
5
|
// https://github.com/microsoft/TypeScript/issues/23182#issuecomment-379091887
|
|
6
|
+
|
|
7
|
+
// TODO: replace in v5 with:
|
|
8
|
+
// export type IndexByType<T extends { type: string }> = { [E in T as E['type']]: E; };
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The full definition of an event, with a string `type`.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// TODO: do not accept machines without all implementations
|
|
15
|
+
// we should also accept a raw machine as a behavior here
|
|
16
|
+
// or just make machine a behavior
|
|
17
|
+
|
|
18
|
+
// TODO: narrow this to behaviors from machine
|
|
19
|
+
|
|
20
|
+
// TODO: fix last param
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Extracts action objects that have no extra properties.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The string or object representing the state value relative to the parent state node.
|
|
28
|
+
*
|
|
29
|
+
* - For a child atomic state node, this is a string, e.g., `"pending"`.
|
|
30
|
+
* - For complex state nodes, this is an object, e.g., `{ success: "someChildState" }`.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
// TODO: remove once TS fixes this type-widening issue
|
|
34
|
+
|
|
35
|
+
// TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
|
|
36
|
+
|
|
37
|
+
exports.ActionTypes = void 0;
|
|
6
38
|
(function (ActionTypes) {
|
|
7
39
|
ActionTypes["Stop"] = "xstate.stop";
|
|
8
40
|
ActionTypes["Raise"] = "xstate.raise";
|
|
@@ -22,45 +54,46 @@ var dev_dist_xstateDev = require('../dev/dist/xstate-dev.cjs.prod.js');
|
|
|
22
54
|
ActionTypes["Pure"] = "xstate.pure";
|
|
23
55
|
ActionTypes["Choose"] = "xstate.choose";
|
|
24
56
|
})(exports.ActionTypes || (exports.ActionTypes = {}));
|
|
57
|
+
exports.SpecialTargets = void 0;
|
|
25
58
|
(function (SpecialTargets) {
|
|
26
59
|
SpecialTargets["Parent"] = "#_parent";
|
|
27
60
|
SpecialTargets["Internal"] = "#_internal";
|
|
28
61
|
})(exports.SpecialTargets || (exports.SpecialTargets = {}));
|
|
29
62
|
|
|
30
63
|
// xstate-specific action types
|
|
31
|
-
var stop = exports.ActionTypes.Stop;
|
|
32
|
-
var raise = exports.ActionTypes.Raise;
|
|
33
|
-
var send = exports.ActionTypes.Send;
|
|
34
|
-
var cancel = exports.ActionTypes.Cancel;
|
|
35
|
-
var assign = exports.ActionTypes.Assign;
|
|
36
|
-
var after = exports.ActionTypes.After;
|
|
64
|
+
var stop$1 = exports.ActionTypes.Stop;
|
|
65
|
+
var raise$1 = exports.ActionTypes.Raise;
|
|
66
|
+
var send$1 = exports.ActionTypes.Send;
|
|
67
|
+
var cancel$1 = exports.ActionTypes.Cancel;
|
|
68
|
+
var assign$1 = exports.ActionTypes.Assign;
|
|
69
|
+
var after$1 = exports.ActionTypes.After;
|
|
37
70
|
var doneState = exports.ActionTypes.DoneState;
|
|
38
|
-
var log = exports.ActionTypes.Log;
|
|
71
|
+
var log$1 = exports.ActionTypes.Log;
|
|
39
72
|
var init = exports.ActionTypes.Init;
|
|
40
|
-
var invoke = exports.ActionTypes.Invoke;
|
|
73
|
+
var invoke$1 = exports.ActionTypes.Invoke;
|
|
41
74
|
var errorExecution = exports.ActionTypes.ErrorExecution;
|
|
42
75
|
var errorPlatform = exports.ActionTypes.ErrorPlatform;
|
|
43
|
-
var error = exports.ActionTypes.ErrorCustom;
|
|
44
|
-
var choose = exports.ActionTypes.Choose;
|
|
45
|
-
var pure = exports.ActionTypes.Pure;
|
|
76
|
+
var error$1 = exports.ActionTypes.ErrorCustom;
|
|
77
|
+
var choose$1 = exports.ActionTypes.Choose;
|
|
78
|
+
var pure$1 = exports.ActionTypes.Pure;
|
|
46
79
|
|
|
47
80
|
var actionTypes = /*#__PURE__*/Object.freeze({
|
|
48
81
|
__proto__: null,
|
|
49
|
-
stop: stop,
|
|
50
|
-
raise: raise,
|
|
51
|
-
send: send,
|
|
52
|
-
cancel: cancel,
|
|
53
|
-
assign: assign,
|
|
54
|
-
after: after,
|
|
82
|
+
stop: stop$1,
|
|
83
|
+
raise: raise$1,
|
|
84
|
+
send: send$1,
|
|
85
|
+
cancel: cancel$1,
|
|
86
|
+
assign: assign$1,
|
|
87
|
+
after: after$1,
|
|
55
88
|
doneState: doneState,
|
|
56
|
-
log: log,
|
|
89
|
+
log: log$1,
|
|
57
90
|
init: init,
|
|
58
|
-
invoke: invoke,
|
|
91
|
+
invoke: invoke$1,
|
|
59
92
|
errorExecution: errorExecution,
|
|
60
93
|
errorPlatform: errorPlatform,
|
|
61
|
-
error: error,
|
|
62
|
-
choose: choose,
|
|
63
|
-
pure: pure
|
|
94
|
+
error: error$1,
|
|
95
|
+
choose: choose$1,
|
|
96
|
+
pure: pure$1
|
|
64
97
|
});
|
|
65
98
|
|
|
66
99
|
function _toPrimitive(input, hint) {
|
|
@@ -380,6 +413,22 @@ function isPromiseLike(value) {
|
|
|
380
413
|
|
|
381
414
|
// tslint:disable-next-line:no-empty
|
|
382
415
|
var warn = function warn() {};
|
|
416
|
+
if (!dev_dist_xstateDev.IS_PRODUCTION) {
|
|
417
|
+
warn = function warn(condition, message) {
|
|
418
|
+
var error = condition instanceof Error ? condition : undefined;
|
|
419
|
+
if (!error && condition) {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
if (console !== undefined) {
|
|
423
|
+
var args = ["Warning: ".concat(message)];
|
|
424
|
+
if (error) {
|
|
425
|
+
args.push(error);
|
|
426
|
+
}
|
|
427
|
+
// tslint:disable-next-line:no-console
|
|
428
|
+
console.warn.apply(console, args);
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
}
|
|
383
432
|
function isArray(value) {
|
|
384
433
|
return Array.isArray(value);
|
|
385
434
|
}
|
|
@@ -488,9 +537,9 @@ function isDynamicAction(action) {
|
|
|
488
537
|
* - `delay` - The number of milliseconds to delay the sending of the event.
|
|
489
538
|
* - `to` - The target of this event (by default, the machine the event was sent from).
|
|
490
539
|
*/
|
|
491
|
-
function send
|
|
540
|
+
function send(eventOrExpr, options) {
|
|
492
541
|
return createDynamicAction({
|
|
493
|
-
type: send,
|
|
542
|
+
type: send$1,
|
|
494
543
|
params: {
|
|
495
544
|
to: options ? options.to : undefined,
|
|
496
545
|
delay: options ? options.delay : undefined,
|
|
@@ -551,7 +600,7 @@ function send$1(eventOrExpr, options) {
|
|
|
551
600
|
targetActorRef = resolvedTarget || (actorContext === null || actorContext === void 0 ? void 0 : actorContext.self);
|
|
552
601
|
}
|
|
553
602
|
var resolvedAction = {
|
|
554
|
-
type: send,
|
|
603
|
+
type: send$1,
|
|
555
604
|
params: _objectSpread2(_objectSpread2({}, params), {}, {
|
|
556
605
|
to: targetActorRef,
|
|
557
606
|
_event: resolvedEvent,
|
|
@@ -570,7 +619,7 @@ function send$1(eventOrExpr, options) {
|
|
|
570
619
|
actorCtx.defer(function () {
|
|
571
620
|
var origin = actorCtx.self;
|
|
572
621
|
var resolvedEvent = _objectSpread2(_objectSpread2({}, _event2), {}, {
|
|
573
|
-
name: _event2.name === error ? "".concat(error
|
|
622
|
+
name: _event2.name === error$1 ? "".concat(error(origin.id)) : _event2.name,
|
|
574
623
|
origin: origin
|
|
575
624
|
});
|
|
576
625
|
target.send(resolvedEvent);
|
|
@@ -589,7 +638,7 @@ function send$1(eventOrExpr, options) {
|
|
|
589
638
|
* @param options Options to pass into the send event.
|
|
590
639
|
*/
|
|
591
640
|
function sendParent(event, options) {
|
|
592
|
-
return send
|
|
641
|
+
return send(event, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
593
642
|
to: exports.SpecialTargets.Parent
|
|
594
643
|
}));
|
|
595
644
|
}
|
|
@@ -601,7 +650,7 @@ function sendParent(event, options) {
|
|
|
601
650
|
* @param options Options to pass into the send event
|
|
602
651
|
*/
|
|
603
652
|
function respond(event, options) {
|
|
604
|
-
return send
|
|
653
|
+
return send(event, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
605
654
|
to: function to(_ref2) {
|
|
606
655
|
var _event = _ref2._event;
|
|
607
656
|
return _event.origin; // TODO: handle when _event.origin is undefined
|
|
@@ -626,7 +675,7 @@ function forwardTo(target, options) {
|
|
|
626
675
|
return resolvedTarget;
|
|
627
676
|
};
|
|
628
677
|
}
|
|
629
|
-
return send
|
|
678
|
+
return send(function (_ref3) {
|
|
630
679
|
var event = _ref3.event;
|
|
631
680
|
return event;
|
|
632
681
|
}, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
@@ -644,7 +693,7 @@ function forwardTo(target, options) {
|
|
|
644
693
|
function escalate(errorData, options) {
|
|
645
694
|
return sendParent(function (arg) {
|
|
646
695
|
return {
|
|
647
|
-
type: error,
|
|
696
|
+
type: error$1,
|
|
648
697
|
data: isFunction(errorData) ? errorData(arg) : errorData
|
|
649
698
|
};
|
|
650
699
|
}, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
@@ -661,7 +710,7 @@ function escalate(errorData, options) {
|
|
|
661
710
|
* @returns An XState send action object
|
|
662
711
|
*/
|
|
663
712
|
function sendTo(actor, event, options) {
|
|
664
|
-
return send
|
|
713
|
+
return send(event, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
665
714
|
to: actor
|
|
666
715
|
}));
|
|
667
716
|
}
|
|
@@ -856,11 +905,19 @@ promiseCreator) {
|
|
|
856
905
|
input: state.input
|
|
857
906
|
}));
|
|
858
907
|
resolvedPromise.then(function (response) {
|
|
908
|
+
// TODO: remove this condition once dead letter queue lands
|
|
909
|
+
if (self._state.status !== 'active') {
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
859
912
|
self.send({
|
|
860
913
|
type: resolveEventType,
|
|
861
914
|
data: response
|
|
862
915
|
});
|
|
863
916
|
}, function (errorData) {
|
|
917
|
+
// TODO: remove this condition once dead letter queue lands
|
|
918
|
+
if (self._state.status !== 'active') {
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
864
921
|
self.send({
|
|
865
922
|
type: rejectEventType,
|
|
866
923
|
data: errorData
|
|
@@ -1149,7 +1206,7 @@ function fromCallback(invokeCallback) {
|
|
|
1149
1206
|
state.canceled = true;
|
|
1150
1207
|
}, function (errorData) {
|
|
1151
1208
|
var _self$_parent3;
|
|
1152
|
-
var errorEvent = error
|
|
1209
|
+
var errorEvent = error(id, errorData);
|
|
1153
1210
|
(_self$_parent3 = self._parent) === null || _self$_parent3 === void 0 ? void 0 : _self$_parent3.send(toSCXMLEvent(errorEvent, {
|
|
1154
1211
|
origin: self
|
|
1155
1212
|
}));
|
|
@@ -1286,6 +1343,7 @@ function createSystem() {
|
|
|
1286
1343
|
return system;
|
|
1287
1344
|
}
|
|
1288
1345
|
|
|
1346
|
+
exports.ActorStatus = void 0;
|
|
1289
1347
|
(function (ActorStatus) {
|
|
1290
1348
|
ActorStatus[ActorStatus["NotStarted"] = 0] = "NotStarted";
|
|
1291
1349
|
ActorStatus[ActorStatus["Running"] = 1] = "Running";
|
|
@@ -1441,9 +1499,9 @@ var Interpreter = /*#__PURE__*/function () {
|
|
|
1441
1499
|
_step;
|
|
1442
1500
|
try {
|
|
1443
1501
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1444
|
-
var
|
|
1445
|
-
var
|
|
1446
|
-
(
|
|
1502
|
+
var _observer$next;
|
|
1503
|
+
var _observer = _step.value;
|
|
1504
|
+
(_observer$next = _observer.next) === null || _observer$next === void 0 ? void 0 : _observer$next.call(_observer, snapshot);
|
|
1447
1505
|
}
|
|
1448
1506
|
} catch (err) {
|
|
1449
1507
|
_iterator.e(err);
|
|
@@ -1453,30 +1511,20 @@ var Interpreter = /*#__PURE__*/function () {
|
|
|
1453
1511
|
var status = (_this$behavior$getSta = (_this$behavior = this.behavior).getStatus) === null || _this$behavior$getSta === void 0 ? void 0 : _this$behavior$getSta.call(_this$behavior, state);
|
|
1454
1512
|
switch (status === null || status === void 0 ? void 0 : status.status) {
|
|
1455
1513
|
case 'done':
|
|
1514
|
+
this._stopProcedure();
|
|
1456
1515
|
this._doneEvent = doneInvoke(this.id, status.data);
|
|
1457
1516
|
(_this$_parent = this._parent) === null || _this$_parent === void 0 ? void 0 : _this$_parent.send(toSCXMLEvent(this._doneEvent, {
|
|
1458
1517
|
origin: this,
|
|
1459
1518
|
invokeid: this.id
|
|
1460
1519
|
}));
|
|
1461
|
-
this.
|
|
1520
|
+
this._complete();
|
|
1462
1521
|
break;
|
|
1463
1522
|
case 'error':
|
|
1464
|
-
|
|
1523
|
+
this._stopProcedure();
|
|
1524
|
+
(_this$_parent2 = this._parent) === null || _this$_parent2 === void 0 ? void 0 : _this$_parent2.send(toSCXMLEvent(error(this.id, status.data), {
|
|
1465
1525
|
origin: this
|
|
1466
1526
|
}));
|
|
1467
|
-
|
|
1468
|
-
_step2;
|
|
1469
|
-
try {
|
|
1470
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1471
|
-
var _observer$error;
|
|
1472
|
-
var _observer = _step2.value;
|
|
1473
|
-
(_observer$error = _observer.error) === null || _observer$error === void 0 ? void 0 : _observer$error.call(_observer, status.data);
|
|
1474
|
-
}
|
|
1475
|
-
} catch (err) {
|
|
1476
|
-
_iterator2.e(err);
|
|
1477
|
-
} finally {
|
|
1478
|
-
_iterator2.f();
|
|
1479
|
-
}
|
|
1527
|
+
this._error(status.data);
|
|
1480
1528
|
break;
|
|
1481
1529
|
}
|
|
1482
1530
|
}
|
|
@@ -1557,13 +1605,14 @@ var Interpreter = /*#__PURE__*/function () {
|
|
|
1557
1605
|
this.update(nextState);
|
|
1558
1606
|
if (event.name === stopSignalType) {
|
|
1559
1607
|
this._stopProcedure();
|
|
1608
|
+
this._complete();
|
|
1560
1609
|
}
|
|
1561
1610
|
} catch (err) {
|
|
1562
1611
|
// TODO: properly handle errors
|
|
1563
1612
|
if (this.observers.size > 0) {
|
|
1564
1613
|
this.observers.forEach(function (observer) {
|
|
1565
|
-
var _observer$
|
|
1566
|
-
(_observer$
|
|
1614
|
+
var _observer$error;
|
|
1615
|
+
(_observer$error = observer.error) === null || _observer$error === void 0 ? void 0 : _observer$error.call(observer, err);
|
|
1567
1616
|
});
|
|
1568
1617
|
this.stop();
|
|
1569
1618
|
} else {
|
|
@@ -1602,13 +1651,31 @@ var Interpreter = /*#__PURE__*/function () {
|
|
|
1602
1651
|
}, {
|
|
1603
1652
|
key: "_complete",
|
|
1604
1653
|
value: function _complete() {
|
|
1654
|
+
var _iterator2 = _createForOfIteratorHelper(this.observers),
|
|
1655
|
+
_step2;
|
|
1656
|
+
try {
|
|
1657
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1658
|
+
var _observer2$complete;
|
|
1659
|
+
var _observer2 = _step2.value;
|
|
1660
|
+
(_observer2$complete = _observer2.complete) === null || _observer2$complete === void 0 ? void 0 : _observer2$complete.call(_observer2);
|
|
1661
|
+
}
|
|
1662
|
+
} catch (err) {
|
|
1663
|
+
_iterator2.e(err);
|
|
1664
|
+
} finally {
|
|
1665
|
+
_iterator2.f();
|
|
1666
|
+
}
|
|
1667
|
+
this.observers.clear();
|
|
1668
|
+
}
|
|
1669
|
+
}, {
|
|
1670
|
+
key: "_error",
|
|
1671
|
+
value: function _error(data) {
|
|
1605
1672
|
var _iterator3 = _createForOfIteratorHelper(this.observers),
|
|
1606
1673
|
_step3;
|
|
1607
1674
|
try {
|
|
1608
1675
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
1609
|
-
var _observer3$
|
|
1676
|
+
var _observer3$error;
|
|
1610
1677
|
var _observer3 = _step3.value;
|
|
1611
|
-
(_observer3$
|
|
1678
|
+
(_observer3$error = _observer3.error) === null || _observer3$error === void 0 ? void 0 : _observer3$error.call(_observer3, data);
|
|
1612
1679
|
}
|
|
1613
1680
|
} catch (err) {
|
|
1614
1681
|
_iterator3.e(err);
|
|
@@ -1620,7 +1687,6 @@ var Interpreter = /*#__PURE__*/function () {
|
|
|
1620
1687
|
}, {
|
|
1621
1688
|
key: "_stopProcedure",
|
|
1622
1689
|
value: function _stopProcedure() {
|
|
1623
|
-
this._complete();
|
|
1624
1690
|
if (this.status !== exports.ActorStatus.Running) {
|
|
1625
1691
|
// Interpreter already stopped; do nothing
|
|
1626
1692
|
return this;
|
|
@@ -1657,6 +1723,11 @@ var Interpreter = /*#__PURE__*/function () {
|
|
|
1657
1723
|
}
|
|
1658
1724
|
var _event = toSCXMLEvent(event);
|
|
1659
1725
|
if (this.status === exports.ActorStatus.Stopped) {
|
|
1726
|
+
// do nothing
|
|
1727
|
+
if (!dev_dist_xstateDev.IS_PRODUCTION) {
|
|
1728
|
+
var eventString = JSON.stringify(_event.data);
|
|
1729
|
+
warn(false, "Event \"".concat(_event.name.toString(), "\" was sent to stopped actor \"").concat(this.id, " (").concat(this.sessionId, ")\". This actor has already reached its final state, and will not transition.\nEvent: ").concat(eventString));
|
|
1730
|
+
}
|
|
1660
1731
|
return;
|
|
1661
1732
|
}
|
|
1662
1733
|
if (this.status !== exports.ActorStatus.Running && !this.options.deferEvents) {
|
|
@@ -1742,10 +1813,10 @@ function interpret(behavior, options) {
|
|
|
1742
1813
|
* @param actorRef The actor to stop.
|
|
1743
1814
|
*/
|
|
1744
1815
|
|
|
1745
|
-
function stop
|
|
1816
|
+
function stop(actorRef) {
|
|
1746
1817
|
var actor = actorRef;
|
|
1747
1818
|
return createDynamicAction({
|
|
1748
|
-
type: stop,
|
|
1819
|
+
type: stop$1,
|
|
1749
1820
|
params: {
|
|
1750
1821
|
actor: actor
|
|
1751
1822
|
}
|
|
@@ -1795,11 +1866,11 @@ var defaultLogExpr = function defaultLogExpr(_ref) {
|
|
|
1795
1866
|
* @param label The label to give to the logged expression.
|
|
1796
1867
|
*/
|
|
1797
1868
|
|
|
1798
|
-
function log
|
|
1869
|
+
function log() {
|
|
1799
1870
|
var expr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultLogExpr;
|
|
1800
1871
|
var label = arguments.length > 1 ? arguments[1] : undefined;
|
|
1801
1872
|
return createDynamicAction({
|
|
1802
|
-
type: log,
|
|
1873
|
+
type: log$1,
|
|
1803
1874
|
params: {
|
|
1804
1875
|
label: label,
|
|
1805
1876
|
expr: expr
|
|
@@ -1842,9 +1913,9 @@ function log$1() {
|
|
|
1842
1913
|
* @param sendId The `id` of the `send(...)` action to cancel.
|
|
1843
1914
|
*/
|
|
1844
1915
|
|
|
1845
|
-
function cancel
|
|
1916
|
+
function cancel(sendId) {
|
|
1846
1917
|
return createDynamicAction({
|
|
1847
|
-
type: cancel,
|
|
1918
|
+
type: cancel$1,
|
|
1848
1919
|
params: {
|
|
1849
1920
|
sendId: sendId
|
|
1850
1921
|
}
|
|
@@ -2249,13 +2320,13 @@ function getDelayedTransitions(stateNode) {
|
|
|
2249
2320
|
}
|
|
2250
2321
|
var mutateEntryExit = function mutateEntryExit(delay, i) {
|
|
2251
2322
|
var delayRef = isFunction(delay) ? "".concat(stateNode.id, ":delay[").concat(i, "]") : delay;
|
|
2252
|
-
var eventType = after
|
|
2253
|
-
stateNode.entry.push(raise
|
|
2323
|
+
var eventType = after(delayRef, stateNode.id);
|
|
2324
|
+
stateNode.entry.push(raise({
|
|
2254
2325
|
type: eventType
|
|
2255
2326
|
}, {
|
|
2256
2327
|
delay: delay
|
|
2257
2328
|
}));
|
|
2258
|
-
stateNode.exit.push(cancel
|
|
2329
|
+
stateNode.exit.push(cancel(eventType));
|
|
2259
2330
|
return eventType;
|
|
2260
2331
|
};
|
|
2261
2332
|
var delayedTransitions = isArray(afterConfig) ? afterConfig.map(function (transition, i) {
|
|
@@ -2901,12 +2972,12 @@ function setChildren(currentState, nonRaisedActions) {
|
|
|
2901
2972
|
try {
|
|
2902
2973
|
for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
|
|
2903
2974
|
var action = _step21.value;
|
|
2904
|
-
if (action.type === invoke && action.params.ref) {
|
|
2975
|
+
if (action.type === invoke$1 && action.params.ref) {
|
|
2905
2976
|
var ref = action.params.ref;
|
|
2906
2977
|
if (ref) {
|
|
2907
2978
|
children[ref.id] = ref;
|
|
2908
2979
|
}
|
|
2909
|
-
} else if (action.type === stop) {
|
|
2980
|
+
} else if (action.type === stop$1) {
|
|
2910
2981
|
var _ref = action.params.actor;
|
|
2911
2982
|
if (_ref) {
|
|
2912
2983
|
delete children[_ref.id];
|
|
@@ -3005,7 +3076,7 @@ function enterStates(filteredTransitions, mutConfiguration, actions, internalQue
|
|
|
3005
3076
|
try {
|
|
3006
3077
|
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
3007
3078
|
var invokeDef = _step23.value;
|
|
3008
|
-
actions.push(invoke
|
|
3079
|
+
actions.push(invoke(invokeDef));
|
|
3009
3080
|
}
|
|
3010
3081
|
|
|
3011
3082
|
// Add entry actions
|
|
@@ -3315,7 +3386,7 @@ function exitStates(transitions, mutConfiguration, historyValue, actions) {
|
|
|
3315
3386
|
for (_iterator40.s(); !(_step40 = _iterator40.n()).done;) {
|
|
3316
3387
|
var s = _step40.value;
|
|
3317
3388
|
actions.push.apply(actions, _toConsumableArray(s.exit.flat()).concat(_toConsumableArray(s.invoke.map(function (def) {
|
|
3318
|
-
return stop
|
|
3389
|
+
return stop(def.id);
|
|
3319
3390
|
}))));
|
|
3320
3391
|
mutConfiguration["delete"](s);
|
|
3321
3392
|
}
|
|
@@ -3353,12 +3424,12 @@ function resolveActionsAndContext(actions, scxmlEvent, currentState, actorCtx) {
|
|
|
3353
3424
|
resolvedAction = _executableActionObje2[1];
|
|
3354
3425
|
var matchedActions = (_resolvedAction$param = resolvedAction.params) === null || _resolvedAction$param === void 0 ? void 0 : _resolvedAction$param.actions;
|
|
3355
3426
|
intermediateState = nextState;
|
|
3356
|
-
if ((resolvedAction.type === raise || resolvedAction.type === send && resolvedAction.params.internal) && typeof resolvedAction.params.delay !== 'number') {
|
|
3427
|
+
if ((resolvedAction.type === raise$1 || resolvedAction.type === send$1 && resolvedAction.params.internal) && typeof resolvedAction.params.delay !== 'number') {
|
|
3357
3428
|
raiseActions.push(resolvedAction);
|
|
3358
3429
|
}
|
|
3359
3430
|
|
|
3360
3431
|
// TODO: remove the check; just handleAction
|
|
3361
|
-
if (resolvedAction.type !== pure) {
|
|
3432
|
+
if (resolvedAction.type !== pure$1) {
|
|
3362
3433
|
handleAction(resolvedAction);
|
|
3363
3434
|
}
|
|
3364
3435
|
toActionObjects(matchedActions).forEach(resolveAction);
|
|
@@ -3388,6 +3459,9 @@ function resolveActionsAndContext(actions, scxmlEvent, currentState, actorCtx) {
|
|
|
3388
3459
|
};
|
|
3389
3460
|
}
|
|
3390
3461
|
function macrostep(state, scxmlEvent, actorCtx) {
|
|
3462
|
+
if (!dev_dist_xstateDev.IS_PRODUCTION && scxmlEvent.name === WILDCARD) {
|
|
3463
|
+
throw new Error("An event cannot have the wildcard type ('".concat(WILDCARD, "')"));
|
|
3464
|
+
}
|
|
3391
3465
|
var nextState = state;
|
|
3392
3466
|
var states = [];
|
|
3393
3467
|
|
|
@@ -3469,7 +3543,7 @@ function stopStep(scxmlEvent, nextState, actorCtx) {
|
|
|
3469
3543
|
}
|
|
3470
3544
|
for (var _i4 = 0, _Object$values = Object.values(nextState.children); _i4 < _Object$values.length; _i4++) {
|
|
3471
3545
|
var child = _Object$values[_i4];
|
|
3472
|
-
actions.push(stop
|
|
3546
|
+
actions.push(stop(child));
|
|
3473
3547
|
}
|
|
3474
3548
|
var _resolveActionsAndCon2 = resolveActionsAndContext(actions, scxmlEvent, nextState, actorCtx),
|
|
3475
3549
|
stoppedState = _resolveActionsAndCon2.nextState;
|
|
@@ -3642,11 +3716,11 @@ var State = /*#__PURE__*/function () {
|
|
|
3642
3716
|
}, {
|
|
3643
3717
|
key: "toJSON",
|
|
3644
3718
|
value: function toJSON() {
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
tags = this.tags
|
|
3648
|
-
|
|
3649
|
-
jsonValues = _objectWithoutProperties(this, _excluded);
|
|
3719
|
+
this.configuration;
|
|
3720
|
+
this.transitions;
|
|
3721
|
+
var tags = this.tags;
|
|
3722
|
+
this.machine;
|
|
3723
|
+
var jsonValues = _objectWithoutProperties(this, _excluded);
|
|
3650
3724
|
return _objectSpread2(_objectSpread2({}, jsonValues), {}, {
|
|
3651
3725
|
tags: Array.from(tags),
|
|
3652
3726
|
meta: this.meta
|
|
@@ -3684,8 +3758,8 @@ var State = /*#__PURE__*/function () {
|
|
|
3684
3758
|
}, {
|
|
3685
3759
|
key: "can",
|
|
3686
3760
|
value: function can(event) {
|
|
3687
|
-
{
|
|
3688
|
-
warn(!!this.machine);
|
|
3761
|
+
if (dev_dist_xstateDev.IS_PRODUCTION) {
|
|
3762
|
+
warn(!!this.machine, "state.can(...) used outside of a machine-created State object; this will always return false.");
|
|
3689
3763
|
}
|
|
3690
3764
|
var transitionData = this.machine.getTransitionData(this, toSCXMLEvent(event));
|
|
3691
3765
|
return !!(transitionData !== null && transitionData !== void 0 && transitionData.length) &&
|
|
@@ -3797,11 +3871,11 @@ function cloneState(state) {
|
|
|
3797
3871
|
return new State(_objectSpread2(_objectSpread2({}, state), config), state.machine);
|
|
3798
3872
|
}
|
|
3799
3873
|
function getPersistedState(state) {
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
children = state.children,
|
|
3874
|
+
state.configuration;
|
|
3875
|
+
state.transitions;
|
|
3876
|
+
state.tags;
|
|
3877
|
+
state.machine;
|
|
3878
|
+
var children = state.children,
|
|
3805
3879
|
jsonValues = _objectWithoutProperties(state, _excluded2);
|
|
3806
3880
|
var childrenJson = {};
|
|
3807
3881
|
for (var id in children) {
|
|
@@ -3816,14 +3890,14 @@ function getPersistedState(state) {
|
|
|
3816
3890
|
});
|
|
3817
3891
|
}
|
|
3818
3892
|
|
|
3819
|
-
function invoke
|
|
3893
|
+
function invoke(invokeDef) {
|
|
3820
3894
|
return createDynamicAction({
|
|
3821
|
-
type: invoke,
|
|
3895
|
+
type: invoke$1,
|
|
3822
3896
|
params: invokeDef
|
|
3823
3897
|
}, function (_event, _ref) {
|
|
3824
3898
|
var state = _ref.state,
|
|
3825
3899
|
actorContext = _ref.actorContext;
|
|
3826
|
-
var type = invoke;
|
|
3900
|
+
var type = invoke$1;
|
|
3827
3901
|
var id = invokeDef.id,
|
|
3828
3902
|
src = invokeDef.src;
|
|
3829
3903
|
var resolvedInvokeAction;
|
|
@@ -3882,7 +3956,7 @@ function invoke$1(invokeDef) {
|
|
|
3882
3956
|
var _actorRef$start;
|
|
3883
3957
|
(_actorRef$start = actorRef.start) === null || _actorRef$start === void 0 ? void 0 : _actorRef$start.call(actorRef);
|
|
3884
3958
|
} catch (err) {
|
|
3885
|
-
parent.send(error
|
|
3959
|
+
parent.send(error(id, err));
|
|
3886
3960
|
return;
|
|
3887
3961
|
}
|
|
3888
3962
|
});
|
|
@@ -3911,7 +3985,7 @@ function createSpawner(self, machine, context, _event, mutCapturedActions) {
|
|
|
3911
3985
|
self: self
|
|
3912
3986
|
}) : input
|
|
3913
3987
|
});
|
|
3914
|
-
mutCapturedActions.push(invoke
|
|
3988
|
+
mutCapturedActions.push(invoke({
|
|
3915
3989
|
id: actorRef.id,
|
|
3916
3990
|
// @ts-ignore TODO: fix types
|
|
3917
3991
|
src: actorRef,
|
|
@@ -3932,7 +4006,7 @@ function createSpawner(self, machine, context, _event, mutCapturedActions) {
|
|
|
3932
4006
|
parent: self,
|
|
3933
4007
|
input: options.input
|
|
3934
4008
|
});
|
|
3935
|
-
mutCapturedActions.push(invoke
|
|
4009
|
+
mutCapturedActions.push(invoke({
|
|
3936
4010
|
// @ts-ignore TODO: fix types
|
|
3937
4011
|
src: _actorRef,
|
|
3938
4012
|
ref: _actorRef,
|
|
@@ -3950,9 +4024,9 @@ function createSpawner(self, machine, context, _event, mutCapturedActions) {
|
|
|
3950
4024
|
*
|
|
3951
4025
|
* @param assignment An object that represents the partial context to update.
|
|
3952
4026
|
*/
|
|
3953
|
-
function assign
|
|
4027
|
+
function assign(assignment) {
|
|
3954
4028
|
return createDynamicAction({
|
|
3955
|
-
type: assign,
|
|
4029
|
+
type: assign$1,
|
|
3956
4030
|
params: {
|
|
3957
4031
|
assignment: assignment
|
|
3958
4032
|
}
|
|
@@ -3988,7 +4062,7 @@ function assign$1(assignment) {
|
|
|
3988
4062
|
return [cloneState(state, {
|
|
3989
4063
|
context: updatedContext
|
|
3990
4064
|
}), {
|
|
3991
|
-
type: assign,
|
|
4065
|
+
type: assign$1,
|
|
3992
4066
|
params: {
|
|
3993
4067
|
context: updatedContext,
|
|
3994
4068
|
actions: capturedActions
|
|
@@ -4004,9 +4078,9 @@ function assign$1(assignment) {
|
|
|
4004
4078
|
* @param eventType The event to raise.
|
|
4005
4079
|
*/
|
|
4006
4080
|
|
|
4007
|
-
function raise
|
|
4081
|
+
function raise(eventOrExpr, options) {
|
|
4008
4082
|
return createDynamicAction({
|
|
4009
|
-
type: raise,
|
|
4083
|
+
type: raise$1,
|
|
4010
4084
|
params: {
|
|
4011
4085
|
delay: options ? options.delay : undefined,
|
|
4012
4086
|
event: eventOrExpr,
|
|
@@ -4043,7 +4117,7 @@ function raise$1(eventOrExpr, options) {
|
|
|
4043
4117
|
resolvedDelay = typeof params.delay === 'function' ? params.delay(args) : params.delay;
|
|
4044
4118
|
}
|
|
4045
4119
|
var resolvedAction = {
|
|
4046
|
-
type: raise,
|
|
4120
|
+
type: raise$1,
|
|
4047
4121
|
params: _objectSpread2(_objectSpread2({}, params), {}, {
|
|
4048
4122
|
_event: resolvedEvent,
|
|
4049
4123
|
event: resolvedEvent.data,
|
|
@@ -4060,9 +4134,9 @@ function raise$1(eventOrExpr, options) {
|
|
|
4060
4134
|
});
|
|
4061
4135
|
}
|
|
4062
4136
|
|
|
4063
|
-
function choose
|
|
4137
|
+
function choose(guards) {
|
|
4064
4138
|
return createDynamicAction({
|
|
4065
|
-
type: choose,
|
|
4139
|
+
type: choose$1,
|
|
4066
4140
|
params: {
|
|
4067
4141
|
guards: guards
|
|
4068
4142
|
}
|
|
@@ -4076,7 +4150,7 @@ function choose$1(guards) {
|
|
|
4076
4150
|
return !guard || evaluateGuard(guard, state.context, _event, state);
|
|
4077
4151
|
})) === null || _guards$find === void 0 ? void 0 : _guards$find.actions;
|
|
4078
4152
|
return [state, {
|
|
4079
|
-
type: choose,
|
|
4153
|
+
type: choose$1,
|
|
4080
4154
|
params: {
|
|
4081
4155
|
actions: toActionObjects(matchedActions)
|
|
4082
4156
|
}
|
|
@@ -4084,9 +4158,9 @@ function choose$1(guards) {
|
|
|
4084
4158
|
});
|
|
4085
4159
|
}
|
|
4086
4160
|
|
|
4087
|
-
function pure
|
|
4161
|
+
function pure(getActions) {
|
|
4088
4162
|
return createDynamicAction({
|
|
4089
|
-
type: pure,
|
|
4163
|
+
type: pure$1,
|
|
4090
4164
|
params: {
|
|
4091
4165
|
get: getActions
|
|
4092
4166
|
}
|
|
@@ -4094,7 +4168,7 @@ function pure$1(getActions) {
|
|
|
4094
4168
|
var _toArray;
|
|
4095
4169
|
var state = _ref.state;
|
|
4096
4170
|
return [state, {
|
|
4097
|
-
type: pure,
|
|
4171
|
+
type: pure$1,
|
|
4098
4172
|
params: {
|
|
4099
4173
|
actions: (_toArray = toArray(toActionObjects(getActions({
|
|
4100
4174
|
context: state.context,
|
|
@@ -4126,9 +4200,9 @@ function resolveActionObject(actionObject, actionFunctionMap) {
|
|
|
4126
4200
|
execute: function execute(actorCtx) {
|
|
4127
4201
|
return dereferencedAction({
|
|
4128
4202
|
context: state.context,
|
|
4129
|
-
event:
|
|
4203
|
+
event: _event.data,
|
|
4130
4204
|
action: a,
|
|
4131
|
-
_event:
|
|
4205
|
+
_event: _event,
|
|
4132
4206
|
system: actorCtx.system,
|
|
4133
4207
|
self: actorCtx.self
|
|
4134
4208
|
});
|
|
@@ -4197,7 +4271,7 @@ var toActionObjects = function toActionObjects(action) {
|
|
|
4197
4271
|
* @param delayRef The delay in milliseconds
|
|
4198
4272
|
* @param id The state node ID where this event is handled
|
|
4199
4273
|
*/
|
|
4200
|
-
function after
|
|
4274
|
+
function after(delayRef, id) {
|
|
4201
4275
|
var idSuffix = id ? "#".concat(id) : '';
|
|
4202
4276
|
return "".concat(exports.ActionTypes.After, "(").concat(delayRef, ")").concat(idSuffix);
|
|
4203
4277
|
}
|
|
@@ -4241,7 +4315,7 @@ function doneInvoke(invokeId, output) {
|
|
|
4241
4315
|
};
|
|
4242
4316
|
return eventObject;
|
|
4243
4317
|
}
|
|
4244
|
-
function error
|
|
4318
|
+
function error(id, data) {
|
|
4245
4319
|
var type = "".concat(exports.ActionTypes.ErrorPlatform, ".").concat(id);
|
|
4246
4320
|
var eventObject = {
|
|
4247
4321
|
type: type,
|
|
@@ -4272,18 +4346,18 @@ exports._objectWithoutProperties = _objectWithoutProperties;
|
|
|
4272
4346
|
exports._slicedToArray = _slicedToArray;
|
|
4273
4347
|
exports._toConsumableArray = _toConsumableArray;
|
|
4274
4348
|
exports.actionTypes = actionTypes;
|
|
4275
|
-
exports.after = after
|
|
4349
|
+
exports.after = after;
|
|
4276
4350
|
exports.and = and;
|
|
4277
|
-
exports.assign = assign
|
|
4278
|
-
exports.cancel = cancel
|
|
4279
|
-
exports.choose = choose
|
|
4351
|
+
exports.assign = assign;
|
|
4352
|
+
exports.cancel = cancel;
|
|
4353
|
+
exports.choose = choose;
|
|
4280
4354
|
exports.createEmptyActor = createEmptyActor;
|
|
4281
4355
|
exports.createInitEvent = createInitEvent;
|
|
4282
4356
|
exports.createInvokeId = createInvokeId;
|
|
4283
4357
|
exports.createSpawner = createSpawner;
|
|
4284
4358
|
exports.done = done;
|
|
4285
4359
|
exports.doneInvoke = doneInvoke;
|
|
4286
|
-
exports.error = error
|
|
4360
|
+
exports.error = error;
|
|
4287
4361
|
exports.escalate = escalate;
|
|
4288
4362
|
exports.evaluateGuard = evaluateGuard;
|
|
4289
4363
|
exports.flatten = flatten;
|
|
@@ -4305,14 +4379,14 @@ exports.getStateNodeByPath = getStateNodeByPath;
|
|
|
4305
4379
|
exports.getStateNodes = getStateNodes;
|
|
4306
4380
|
exports.initEvent = initEvent;
|
|
4307
4381
|
exports.interpret = interpret;
|
|
4308
|
-
exports.invoke = invoke;
|
|
4382
|
+
exports.invoke = invoke$1;
|
|
4309
4383
|
exports.isActorRef = isActorRef;
|
|
4310
4384
|
exports.isInFinalState = isInFinalState;
|
|
4311
4385
|
exports.isSCXMLErrorEvent = isSCXMLErrorEvent;
|
|
4312
4386
|
exports.isSignal = isSignal;
|
|
4313
4387
|
exports.isStateId = isStateId;
|
|
4314
4388
|
exports.isString = isString;
|
|
4315
|
-
exports.log = log
|
|
4389
|
+
exports.log = log;
|
|
4316
4390
|
exports.macrostep = macrostep;
|
|
4317
4391
|
exports.mapValues = mapValues;
|
|
4318
4392
|
exports.matchesState = matchesState;
|
|
@@ -4321,20 +4395,20 @@ exports.microstep = microstep;
|
|
|
4321
4395
|
exports.not = not;
|
|
4322
4396
|
exports.or = or;
|
|
4323
4397
|
exports.pathToStateValue = pathToStateValue;
|
|
4324
|
-
exports.pure = pure
|
|
4325
|
-
exports.raise = raise
|
|
4398
|
+
exports.pure = pure;
|
|
4399
|
+
exports.raise = raise;
|
|
4326
4400
|
exports.resolveActionObject = resolveActionObject;
|
|
4327
4401
|
exports.resolveActionsAndContext = resolveActionsAndContext;
|
|
4328
4402
|
exports.resolveReferencedActor = resolveReferencedActor;
|
|
4329
4403
|
exports.resolveStateValue = resolveStateValue;
|
|
4330
4404
|
exports.respond = respond;
|
|
4331
|
-
exports.send = send
|
|
4405
|
+
exports.send = send;
|
|
4332
4406
|
exports.sendParent = sendParent;
|
|
4333
4407
|
exports.sendTo = sendTo;
|
|
4334
4408
|
exports.startSignal = startSignal;
|
|
4335
4409
|
exports.startSignalType = startSignalType;
|
|
4336
4410
|
exports.stateIn = stateIn;
|
|
4337
|
-
exports.stop = stop
|
|
4411
|
+
exports.stop = stop;
|
|
4338
4412
|
exports.stopSignal = stopSignal;
|
|
4339
4413
|
exports.stopSignalType = stopSignalType;
|
|
4340
4414
|
exports.toActionObject = toActionObject;
|