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
|
@@ -3,6 +3,38 @@
|
|
|
3
3
|
var dev_dist_xstateDev = require('./index-ebaab3c9.cjs.dev.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('./index-ebaab3c9.cjs.dev.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) {
|
|
@@ -504,9 +537,9 @@ function isDynamicAction(action) {
|
|
|
504
537
|
* - `delay` - The number of milliseconds to delay the sending of the event.
|
|
505
538
|
* - `to` - The target of this event (by default, the machine the event was sent from).
|
|
506
539
|
*/
|
|
507
|
-
function send
|
|
540
|
+
function send(eventOrExpr, options) {
|
|
508
541
|
return createDynamicAction({
|
|
509
|
-
type: send,
|
|
542
|
+
type: send$1,
|
|
510
543
|
params: {
|
|
511
544
|
to: options ? options.to : undefined,
|
|
512
545
|
delay: options ? options.delay : undefined,
|
|
@@ -567,7 +600,7 @@ function send$1(eventOrExpr, options) {
|
|
|
567
600
|
targetActorRef = resolvedTarget || (actorContext === null || actorContext === void 0 ? void 0 : actorContext.self);
|
|
568
601
|
}
|
|
569
602
|
var resolvedAction = {
|
|
570
|
-
type: send,
|
|
603
|
+
type: send$1,
|
|
571
604
|
params: _objectSpread2(_objectSpread2({}, params), {}, {
|
|
572
605
|
to: targetActorRef,
|
|
573
606
|
_event: resolvedEvent,
|
|
@@ -586,7 +619,7 @@ function send$1(eventOrExpr, options) {
|
|
|
586
619
|
actorCtx.defer(function () {
|
|
587
620
|
var origin = actorCtx.self;
|
|
588
621
|
var resolvedEvent = _objectSpread2(_objectSpread2({}, _event2), {}, {
|
|
589
|
-
name: _event2.name === error ? "".concat(error
|
|
622
|
+
name: _event2.name === error$1 ? "".concat(error(origin.id)) : _event2.name,
|
|
590
623
|
origin: origin
|
|
591
624
|
});
|
|
592
625
|
target.send(resolvedEvent);
|
|
@@ -605,7 +638,7 @@ function send$1(eventOrExpr, options) {
|
|
|
605
638
|
* @param options Options to pass into the send event.
|
|
606
639
|
*/
|
|
607
640
|
function sendParent(event, options) {
|
|
608
|
-
return send
|
|
641
|
+
return send(event, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
609
642
|
to: exports.SpecialTargets.Parent
|
|
610
643
|
}));
|
|
611
644
|
}
|
|
@@ -617,7 +650,7 @@ function sendParent(event, options) {
|
|
|
617
650
|
* @param options Options to pass into the send event
|
|
618
651
|
*/
|
|
619
652
|
function respond(event, options) {
|
|
620
|
-
return send
|
|
653
|
+
return send(event, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
621
654
|
to: function to(_ref2) {
|
|
622
655
|
var _event = _ref2._event;
|
|
623
656
|
return _event.origin; // TODO: handle when _event.origin is undefined
|
|
@@ -642,7 +675,7 @@ function forwardTo(target, options) {
|
|
|
642
675
|
return resolvedTarget;
|
|
643
676
|
};
|
|
644
677
|
}
|
|
645
|
-
return send
|
|
678
|
+
return send(function (_ref3) {
|
|
646
679
|
var event = _ref3.event;
|
|
647
680
|
return event;
|
|
648
681
|
}, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
@@ -660,7 +693,7 @@ function forwardTo(target, options) {
|
|
|
660
693
|
function escalate(errorData, options) {
|
|
661
694
|
return sendParent(function (arg) {
|
|
662
695
|
return {
|
|
663
|
-
type: error,
|
|
696
|
+
type: error$1,
|
|
664
697
|
data: isFunction(errorData) ? errorData(arg) : errorData
|
|
665
698
|
};
|
|
666
699
|
}, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
@@ -677,7 +710,7 @@ function escalate(errorData, options) {
|
|
|
677
710
|
* @returns An XState send action object
|
|
678
711
|
*/
|
|
679
712
|
function sendTo(actor, event, options) {
|
|
680
|
-
return send
|
|
713
|
+
return send(event, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
681
714
|
to: actor
|
|
682
715
|
}));
|
|
683
716
|
}
|
|
@@ -872,11 +905,19 @@ promiseCreator) {
|
|
|
872
905
|
input: state.input
|
|
873
906
|
}));
|
|
874
907
|
resolvedPromise.then(function (response) {
|
|
908
|
+
// TODO: remove this condition once dead letter queue lands
|
|
909
|
+
if (self._state.status !== 'active') {
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
875
912
|
self.send({
|
|
876
913
|
type: resolveEventType,
|
|
877
914
|
data: response
|
|
878
915
|
});
|
|
879
916
|
}, function (errorData) {
|
|
917
|
+
// TODO: remove this condition once dead letter queue lands
|
|
918
|
+
if (self._state.status !== 'active') {
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
880
921
|
self.send({
|
|
881
922
|
type: rejectEventType,
|
|
882
923
|
data: errorData
|
|
@@ -1165,7 +1206,7 @@ function fromCallback(invokeCallback) {
|
|
|
1165
1206
|
state.canceled = true;
|
|
1166
1207
|
}, function (errorData) {
|
|
1167
1208
|
var _self$_parent3;
|
|
1168
|
-
var errorEvent = error
|
|
1209
|
+
var errorEvent = error(id, errorData);
|
|
1169
1210
|
(_self$_parent3 = self._parent) === null || _self$_parent3 === void 0 ? void 0 : _self$_parent3.send(toSCXMLEvent(errorEvent, {
|
|
1170
1211
|
origin: self
|
|
1171
1212
|
}));
|
|
@@ -1302,6 +1343,7 @@ function createSystem() {
|
|
|
1302
1343
|
return system;
|
|
1303
1344
|
}
|
|
1304
1345
|
|
|
1346
|
+
exports.ActorStatus = void 0;
|
|
1305
1347
|
(function (ActorStatus) {
|
|
1306
1348
|
ActorStatus[ActorStatus["NotStarted"] = 0] = "NotStarted";
|
|
1307
1349
|
ActorStatus[ActorStatus["Running"] = 1] = "Running";
|
|
@@ -1457,9 +1499,9 @@ var Interpreter = /*#__PURE__*/function () {
|
|
|
1457
1499
|
_step;
|
|
1458
1500
|
try {
|
|
1459
1501
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1460
|
-
var
|
|
1461
|
-
var
|
|
1462
|
-
(
|
|
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);
|
|
1463
1505
|
}
|
|
1464
1506
|
} catch (err) {
|
|
1465
1507
|
_iterator.e(err);
|
|
@@ -1469,30 +1511,20 @@ var Interpreter = /*#__PURE__*/function () {
|
|
|
1469
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);
|
|
1470
1512
|
switch (status === null || status === void 0 ? void 0 : status.status) {
|
|
1471
1513
|
case 'done':
|
|
1514
|
+
this._stopProcedure();
|
|
1472
1515
|
this._doneEvent = doneInvoke(this.id, status.data);
|
|
1473
1516
|
(_this$_parent = this._parent) === null || _this$_parent === void 0 ? void 0 : _this$_parent.send(toSCXMLEvent(this._doneEvent, {
|
|
1474
1517
|
origin: this,
|
|
1475
1518
|
invokeid: this.id
|
|
1476
1519
|
}));
|
|
1477
|
-
this.
|
|
1520
|
+
this._complete();
|
|
1478
1521
|
break;
|
|
1479
1522
|
case 'error':
|
|
1480
|
-
|
|
1523
|
+
this._stopProcedure();
|
|
1524
|
+
(_this$_parent2 = this._parent) === null || _this$_parent2 === void 0 ? void 0 : _this$_parent2.send(toSCXMLEvent(error(this.id, status.data), {
|
|
1481
1525
|
origin: this
|
|
1482
1526
|
}));
|
|
1483
|
-
|
|
1484
|
-
_step2;
|
|
1485
|
-
try {
|
|
1486
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1487
|
-
var _observer$error;
|
|
1488
|
-
var _observer = _step2.value;
|
|
1489
|
-
(_observer$error = _observer.error) === null || _observer$error === void 0 ? void 0 : _observer$error.call(_observer, status.data);
|
|
1490
|
-
}
|
|
1491
|
-
} catch (err) {
|
|
1492
|
-
_iterator2.e(err);
|
|
1493
|
-
} finally {
|
|
1494
|
-
_iterator2.f();
|
|
1495
|
-
}
|
|
1527
|
+
this._error(status.data);
|
|
1496
1528
|
break;
|
|
1497
1529
|
}
|
|
1498
1530
|
}
|
|
@@ -1573,13 +1605,14 @@ var Interpreter = /*#__PURE__*/function () {
|
|
|
1573
1605
|
this.update(nextState);
|
|
1574
1606
|
if (event.name === stopSignalType) {
|
|
1575
1607
|
this._stopProcedure();
|
|
1608
|
+
this._complete();
|
|
1576
1609
|
}
|
|
1577
1610
|
} catch (err) {
|
|
1578
1611
|
// TODO: properly handle errors
|
|
1579
1612
|
if (this.observers.size > 0) {
|
|
1580
1613
|
this.observers.forEach(function (observer) {
|
|
1581
|
-
var _observer$
|
|
1582
|
-
(_observer$
|
|
1614
|
+
var _observer$error;
|
|
1615
|
+
(_observer$error = observer.error) === null || _observer$error === void 0 ? void 0 : _observer$error.call(observer, err);
|
|
1583
1616
|
});
|
|
1584
1617
|
this.stop();
|
|
1585
1618
|
} else {
|
|
@@ -1618,13 +1651,31 @@ var Interpreter = /*#__PURE__*/function () {
|
|
|
1618
1651
|
}, {
|
|
1619
1652
|
key: "_complete",
|
|
1620
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) {
|
|
1621
1672
|
var _iterator3 = _createForOfIteratorHelper(this.observers),
|
|
1622
1673
|
_step3;
|
|
1623
1674
|
try {
|
|
1624
1675
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
1625
|
-
var _observer3$
|
|
1676
|
+
var _observer3$error;
|
|
1626
1677
|
var _observer3 = _step3.value;
|
|
1627
|
-
(_observer3$
|
|
1678
|
+
(_observer3$error = _observer3.error) === null || _observer3$error === void 0 ? void 0 : _observer3$error.call(_observer3, data);
|
|
1628
1679
|
}
|
|
1629
1680
|
} catch (err) {
|
|
1630
1681
|
_iterator3.e(err);
|
|
@@ -1636,7 +1687,6 @@ var Interpreter = /*#__PURE__*/function () {
|
|
|
1636
1687
|
}, {
|
|
1637
1688
|
key: "_stopProcedure",
|
|
1638
1689
|
value: function _stopProcedure() {
|
|
1639
|
-
this._complete();
|
|
1640
1690
|
if (this.status !== exports.ActorStatus.Running) {
|
|
1641
1691
|
// Interpreter already stopped; do nothing
|
|
1642
1692
|
return this;
|
|
@@ -1763,10 +1813,10 @@ function interpret(behavior, options) {
|
|
|
1763
1813
|
* @param actorRef The actor to stop.
|
|
1764
1814
|
*/
|
|
1765
1815
|
|
|
1766
|
-
function stop
|
|
1816
|
+
function stop(actorRef) {
|
|
1767
1817
|
var actor = actorRef;
|
|
1768
1818
|
return createDynamicAction({
|
|
1769
|
-
type: stop,
|
|
1819
|
+
type: stop$1,
|
|
1770
1820
|
params: {
|
|
1771
1821
|
actor: actor
|
|
1772
1822
|
}
|
|
@@ -1816,11 +1866,11 @@ var defaultLogExpr = function defaultLogExpr(_ref) {
|
|
|
1816
1866
|
* @param label The label to give to the logged expression.
|
|
1817
1867
|
*/
|
|
1818
1868
|
|
|
1819
|
-
function log
|
|
1869
|
+
function log() {
|
|
1820
1870
|
var expr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultLogExpr;
|
|
1821
1871
|
var label = arguments.length > 1 ? arguments[1] : undefined;
|
|
1822
1872
|
return createDynamicAction({
|
|
1823
|
-
type: log,
|
|
1873
|
+
type: log$1,
|
|
1824
1874
|
params: {
|
|
1825
1875
|
label: label,
|
|
1826
1876
|
expr: expr
|
|
@@ -1863,9 +1913,9 @@ function log$1() {
|
|
|
1863
1913
|
* @param sendId The `id` of the `send(...)` action to cancel.
|
|
1864
1914
|
*/
|
|
1865
1915
|
|
|
1866
|
-
function cancel
|
|
1916
|
+
function cancel(sendId) {
|
|
1867
1917
|
return createDynamicAction({
|
|
1868
|
-
type: cancel,
|
|
1918
|
+
type: cancel$1,
|
|
1869
1919
|
params: {
|
|
1870
1920
|
sendId: sendId
|
|
1871
1921
|
}
|
|
@@ -2276,13 +2326,13 @@ function getDelayedTransitions(stateNode) {
|
|
|
2276
2326
|
}
|
|
2277
2327
|
var mutateEntryExit = function mutateEntryExit(delay, i) {
|
|
2278
2328
|
var delayRef = isFunction(delay) ? "".concat(stateNode.id, ":delay[").concat(i, "]") : delay;
|
|
2279
|
-
var eventType = after
|
|
2280
|
-
stateNode.entry.push(raise
|
|
2329
|
+
var eventType = after(delayRef, stateNode.id);
|
|
2330
|
+
stateNode.entry.push(raise({
|
|
2281
2331
|
type: eventType
|
|
2282
2332
|
}, {
|
|
2283
2333
|
delay: delay
|
|
2284
2334
|
}));
|
|
2285
|
-
stateNode.exit.push(cancel
|
|
2335
|
+
stateNode.exit.push(cancel(eventType));
|
|
2286
2336
|
return eventType;
|
|
2287
2337
|
};
|
|
2288
2338
|
var delayedTransitions = isArray(afterConfig) ? afterConfig.map(function (transition, i) {
|
|
@@ -2933,12 +2983,12 @@ function setChildren(currentState, nonRaisedActions) {
|
|
|
2933
2983
|
try {
|
|
2934
2984
|
for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
|
|
2935
2985
|
var action = _step21.value;
|
|
2936
|
-
if (action.type === invoke && action.params.ref) {
|
|
2986
|
+
if (action.type === invoke$1 && action.params.ref) {
|
|
2937
2987
|
var ref = action.params.ref;
|
|
2938
2988
|
if (ref) {
|
|
2939
2989
|
children[ref.id] = ref;
|
|
2940
2990
|
}
|
|
2941
|
-
} else if (action.type === stop) {
|
|
2991
|
+
} else if (action.type === stop$1) {
|
|
2942
2992
|
var _ref = action.params.actor;
|
|
2943
2993
|
if (_ref) {
|
|
2944
2994
|
delete children[_ref.id];
|
|
@@ -3037,7 +3087,7 @@ function enterStates(filteredTransitions, mutConfiguration, actions, internalQue
|
|
|
3037
3087
|
try {
|
|
3038
3088
|
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
3039
3089
|
var invokeDef = _step23.value;
|
|
3040
|
-
actions.push(invoke
|
|
3090
|
+
actions.push(invoke(invokeDef));
|
|
3041
3091
|
}
|
|
3042
3092
|
|
|
3043
3093
|
// Add entry actions
|
|
@@ -3347,7 +3397,7 @@ function exitStates(transitions, mutConfiguration, historyValue, actions) {
|
|
|
3347
3397
|
for (_iterator40.s(); !(_step40 = _iterator40.n()).done;) {
|
|
3348
3398
|
var s = _step40.value;
|
|
3349
3399
|
actions.push.apply(actions, _toConsumableArray(s.exit.flat()).concat(_toConsumableArray(s.invoke.map(function (def) {
|
|
3350
|
-
return stop
|
|
3400
|
+
return stop(def.id);
|
|
3351
3401
|
}))));
|
|
3352
3402
|
mutConfiguration["delete"](s);
|
|
3353
3403
|
}
|
|
@@ -3385,12 +3435,12 @@ function resolveActionsAndContext(actions, scxmlEvent, currentState, actorCtx) {
|
|
|
3385
3435
|
resolvedAction = _executableActionObje2[1];
|
|
3386
3436
|
var matchedActions = (_resolvedAction$param = resolvedAction.params) === null || _resolvedAction$param === void 0 ? void 0 : _resolvedAction$param.actions;
|
|
3387
3437
|
intermediateState = nextState;
|
|
3388
|
-
if ((resolvedAction.type === raise || resolvedAction.type === send && resolvedAction.params.internal) && typeof resolvedAction.params.delay !== 'number') {
|
|
3438
|
+
if ((resolvedAction.type === raise$1 || resolvedAction.type === send$1 && resolvedAction.params.internal) && typeof resolvedAction.params.delay !== 'number') {
|
|
3389
3439
|
raiseActions.push(resolvedAction);
|
|
3390
3440
|
}
|
|
3391
3441
|
|
|
3392
3442
|
// TODO: remove the check; just handleAction
|
|
3393
|
-
if (resolvedAction.type !== pure) {
|
|
3443
|
+
if (resolvedAction.type !== pure$1) {
|
|
3394
3444
|
handleAction(resolvedAction);
|
|
3395
3445
|
}
|
|
3396
3446
|
toActionObjects(matchedActions).forEach(resolveAction);
|
|
@@ -3504,7 +3554,7 @@ function stopStep(scxmlEvent, nextState, actorCtx) {
|
|
|
3504
3554
|
}
|
|
3505
3555
|
for (var _i4 = 0, _Object$values = Object.values(nextState.children); _i4 < _Object$values.length; _i4++) {
|
|
3506
3556
|
var child = _Object$values[_i4];
|
|
3507
|
-
actions.push(stop
|
|
3557
|
+
actions.push(stop(child));
|
|
3508
3558
|
}
|
|
3509
3559
|
var _resolveActionsAndCon2 = resolveActionsAndContext(actions, scxmlEvent, nextState, actorCtx),
|
|
3510
3560
|
stoppedState = _resolveActionsAndCon2.nextState;
|
|
@@ -3677,11 +3727,11 @@ var State = /*#__PURE__*/function () {
|
|
|
3677
3727
|
}, {
|
|
3678
3728
|
key: "toJSON",
|
|
3679
3729
|
value: function toJSON() {
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
tags = this.tags
|
|
3683
|
-
|
|
3684
|
-
jsonValues = _objectWithoutProperties(this, _excluded);
|
|
3730
|
+
this.configuration;
|
|
3731
|
+
this.transitions;
|
|
3732
|
+
var tags = this.tags;
|
|
3733
|
+
this.machine;
|
|
3734
|
+
var jsonValues = _objectWithoutProperties(this, _excluded);
|
|
3685
3735
|
return _objectSpread2(_objectSpread2({}, jsonValues), {}, {
|
|
3686
3736
|
tags: Array.from(tags),
|
|
3687
3737
|
meta: this.meta
|
|
@@ -3832,11 +3882,11 @@ function cloneState(state) {
|
|
|
3832
3882
|
return new State(_objectSpread2(_objectSpread2({}, state), config), state.machine);
|
|
3833
3883
|
}
|
|
3834
3884
|
function getPersistedState(state) {
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
children = state.children,
|
|
3885
|
+
state.configuration;
|
|
3886
|
+
state.transitions;
|
|
3887
|
+
state.tags;
|
|
3888
|
+
state.machine;
|
|
3889
|
+
var children = state.children,
|
|
3840
3890
|
jsonValues = _objectWithoutProperties(state, _excluded2);
|
|
3841
3891
|
var childrenJson = {};
|
|
3842
3892
|
for (var id in children) {
|
|
@@ -3851,14 +3901,14 @@ function getPersistedState(state) {
|
|
|
3851
3901
|
});
|
|
3852
3902
|
}
|
|
3853
3903
|
|
|
3854
|
-
function invoke
|
|
3904
|
+
function invoke(invokeDef) {
|
|
3855
3905
|
return createDynamicAction({
|
|
3856
|
-
type: invoke,
|
|
3906
|
+
type: invoke$1,
|
|
3857
3907
|
params: invokeDef
|
|
3858
3908
|
}, function (_event, _ref) {
|
|
3859
3909
|
var state = _ref.state,
|
|
3860
3910
|
actorContext = _ref.actorContext;
|
|
3861
|
-
var type = invoke;
|
|
3911
|
+
var type = invoke$1;
|
|
3862
3912
|
var id = invokeDef.id,
|
|
3863
3913
|
src = invokeDef.src;
|
|
3864
3914
|
var resolvedInvokeAction;
|
|
@@ -3920,7 +3970,7 @@ function invoke$1(invokeDef) {
|
|
|
3920
3970
|
var _actorRef$start;
|
|
3921
3971
|
(_actorRef$start = actorRef.start) === null || _actorRef$start === void 0 ? void 0 : _actorRef$start.call(actorRef);
|
|
3922
3972
|
} catch (err) {
|
|
3923
|
-
parent.send(error
|
|
3973
|
+
parent.send(error(id, err));
|
|
3924
3974
|
return;
|
|
3925
3975
|
}
|
|
3926
3976
|
});
|
|
@@ -3949,7 +3999,7 @@ function createSpawner(self, machine, context, _event, mutCapturedActions) {
|
|
|
3949
3999
|
self: self
|
|
3950
4000
|
}) : input
|
|
3951
4001
|
});
|
|
3952
|
-
mutCapturedActions.push(invoke
|
|
4002
|
+
mutCapturedActions.push(invoke({
|
|
3953
4003
|
id: actorRef.id,
|
|
3954
4004
|
// @ts-ignore TODO: fix types
|
|
3955
4005
|
src: actorRef,
|
|
@@ -3970,7 +4020,7 @@ function createSpawner(self, machine, context, _event, mutCapturedActions) {
|
|
|
3970
4020
|
parent: self,
|
|
3971
4021
|
input: options.input
|
|
3972
4022
|
});
|
|
3973
|
-
mutCapturedActions.push(invoke
|
|
4023
|
+
mutCapturedActions.push(invoke({
|
|
3974
4024
|
// @ts-ignore TODO: fix types
|
|
3975
4025
|
src: _actorRef,
|
|
3976
4026
|
ref: _actorRef,
|
|
@@ -3988,9 +4038,9 @@ function createSpawner(self, machine, context, _event, mutCapturedActions) {
|
|
|
3988
4038
|
*
|
|
3989
4039
|
* @param assignment An object that represents the partial context to update.
|
|
3990
4040
|
*/
|
|
3991
|
-
function assign
|
|
4041
|
+
function assign(assignment) {
|
|
3992
4042
|
return createDynamicAction({
|
|
3993
|
-
type: assign,
|
|
4043
|
+
type: assign$1,
|
|
3994
4044
|
params: {
|
|
3995
4045
|
assignment: assignment
|
|
3996
4046
|
}
|
|
@@ -4026,7 +4076,7 @@ function assign$1(assignment) {
|
|
|
4026
4076
|
return [cloneState(state, {
|
|
4027
4077
|
context: updatedContext
|
|
4028
4078
|
}), {
|
|
4029
|
-
type: assign,
|
|
4079
|
+
type: assign$1,
|
|
4030
4080
|
params: {
|
|
4031
4081
|
context: updatedContext,
|
|
4032
4082
|
actions: capturedActions
|
|
@@ -4042,9 +4092,9 @@ function assign$1(assignment) {
|
|
|
4042
4092
|
* @param eventType The event to raise.
|
|
4043
4093
|
*/
|
|
4044
4094
|
|
|
4045
|
-
function raise
|
|
4095
|
+
function raise(eventOrExpr, options) {
|
|
4046
4096
|
return createDynamicAction({
|
|
4047
|
-
type: raise,
|
|
4097
|
+
type: raise$1,
|
|
4048
4098
|
params: {
|
|
4049
4099
|
delay: options ? options.delay : undefined,
|
|
4050
4100
|
event: eventOrExpr,
|
|
@@ -4081,7 +4131,7 @@ function raise$1(eventOrExpr, options) {
|
|
|
4081
4131
|
resolvedDelay = typeof params.delay === 'function' ? params.delay(args) : params.delay;
|
|
4082
4132
|
}
|
|
4083
4133
|
var resolvedAction = {
|
|
4084
|
-
type: raise,
|
|
4134
|
+
type: raise$1,
|
|
4085
4135
|
params: _objectSpread2(_objectSpread2({}, params), {}, {
|
|
4086
4136
|
_event: resolvedEvent,
|
|
4087
4137
|
event: resolvedEvent.data,
|
|
@@ -4098,9 +4148,9 @@ function raise$1(eventOrExpr, options) {
|
|
|
4098
4148
|
});
|
|
4099
4149
|
}
|
|
4100
4150
|
|
|
4101
|
-
function choose
|
|
4151
|
+
function choose(guards) {
|
|
4102
4152
|
return createDynamicAction({
|
|
4103
|
-
type: choose,
|
|
4153
|
+
type: choose$1,
|
|
4104
4154
|
params: {
|
|
4105
4155
|
guards: guards
|
|
4106
4156
|
}
|
|
@@ -4114,7 +4164,7 @@ function choose$1(guards) {
|
|
|
4114
4164
|
return !guard || evaluateGuard(guard, state.context, _event, state);
|
|
4115
4165
|
})) === null || _guards$find === void 0 ? void 0 : _guards$find.actions;
|
|
4116
4166
|
return [state, {
|
|
4117
|
-
type: choose,
|
|
4167
|
+
type: choose$1,
|
|
4118
4168
|
params: {
|
|
4119
4169
|
actions: toActionObjects(matchedActions)
|
|
4120
4170
|
}
|
|
@@ -4122,9 +4172,9 @@ function choose$1(guards) {
|
|
|
4122
4172
|
});
|
|
4123
4173
|
}
|
|
4124
4174
|
|
|
4125
|
-
function pure
|
|
4175
|
+
function pure(getActions) {
|
|
4126
4176
|
return createDynamicAction({
|
|
4127
|
-
type: pure,
|
|
4177
|
+
type: pure$1,
|
|
4128
4178
|
params: {
|
|
4129
4179
|
get: getActions
|
|
4130
4180
|
}
|
|
@@ -4132,7 +4182,7 @@ function pure$1(getActions) {
|
|
|
4132
4182
|
var _toArray;
|
|
4133
4183
|
var state = _ref.state;
|
|
4134
4184
|
return [state, {
|
|
4135
|
-
type: pure,
|
|
4185
|
+
type: pure$1,
|
|
4136
4186
|
params: {
|
|
4137
4187
|
actions: (_toArray = toArray(toActionObjects(getActions({
|
|
4138
4188
|
context: state.context,
|
|
@@ -4164,9 +4214,9 @@ function resolveActionObject(actionObject, actionFunctionMap) {
|
|
|
4164
4214
|
execute: function execute(actorCtx) {
|
|
4165
4215
|
return dereferencedAction({
|
|
4166
4216
|
context: state.context,
|
|
4167
|
-
event:
|
|
4217
|
+
event: _event.data,
|
|
4168
4218
|
action: a,
|
|
4169
|
-
_event:
|
|
4219
|
+
_event: _event,
|
|
4170
4220
|
system: actorCtx.system,
|
|
4171
4221
|
self: actorCtx.self
|
|
4172
4222
|
});
|
|
@@ -4235,7 +4285,7 @@ var toActionObjects = function toActionObjects(action) {
|
|
|
4235
4285
|
* @param delayRef The delay in milliseconds
|
|
4236
4286
|
* @param id The state node ID where this event is handled
|
|
4237
4287
|
*/
|
|
4238
|
-
function after
|
|
4288
|
+
function after(delayRef, id) {
|
|
4239
4289
|
var idSuffix = id ? "#".concat(id) : '';
|
|
4240
4290
|
return "".concat(exports.ActionTypes.After, "(").concat(delayRef, ")").concat(idSuffix);
|
|
4241
4291
|
}
|
|
@@ -4279,7 +4329,7 @@ function doneInvoke(invokeId, output) {
|
|
|
4279
4329
|
};
|
|
4280
4330
|
return eventObject;
|
|
4281
4331
|
}
|
|
4282
|
-
function error
|
|
4332
|
+
function error(id, data) {
|
|
4283
4333
|
var type = "".concat(exports.ActionTypes.ErrorPlatform, ".").concat(id);
|
|
4284
4334
|
var eventObject = {
|
|
4285
4335
|
type: type,
|
|
@@ -4310,18 +4360,18 @@ exports._objectWithoutProperties = _objectWithoutProperties;
|
|
|
4310
4360
|
exports._slicedToArray = _slicedToArray;
|
|
4311
4361
|
exports._toConsumableArray = _toConsumableArray;
|
|
4312
4362
|
exports.actionTypes = actionTypes;
|
|
4313
|
-
exports.after = after
|
|
4363
|
+
exports.after = after;
|
|
4314
4364
|
exports.and = and;
|
|
4315
|
-
exports.assign = assign
|
|
4316
|
-
exports.cancel = cancel
|
|
4317
|
-
exports.choose = choose
|
|
4365
|
+
exports.assign = assign;
|
|
4366
|
+
exports.cancel = cancel;
|
|
4367
|
+
exports.choose = choose;
|
|
4318
4368
|
exports.createEmptyActor = createEmptyActor;
|
|
4319
4369
|
exports.createInitEvent = createInitEvent;
|
|
4320
4370
|
exports.createInvokeId = createInvokeId;
|
|
4321
4371
|
exports.createSpawner = createSpawner;
|
|
4322
4372
|
exports.done = done;
|
|
4323
4373
|
exports.doneInvoke = doneInvoke;
|
|
4324
|
-
exports.error = error
|
|
4374
|
+
exports.error = error;
|
|
4325
4375
|
exports.escalate = escalate;
|
|
4326
4376
|
exports.evaluateGuard = evaluateGuard;
|
|
4327
4377
|
exports.flatten = flatten;
|
|
@@ -4343,14 +4393,14 @@ exports.getStateNodeByPath = getStateNodeByPath;
|
|
|
4343
4393
|
exports.getStateNodes = getStateNodes;
|
|
4344
4394
|
exports.initEvent = initEvent;
|
|
4345
4395
|
exports.interpret = interpret;
|
|
4346
|
-
exports.invoke = invoke;
|
|
4396
|
+
exports.invoke = invoke$1;
|
|
4347
4397
|
exports.isActorRef = isActorRef;
|
|
4348
4398
|
exports.isInFinalState = isInFinalState;
|
|
4349
4399
|
exports.isSCXMLErrorEvent = isSCXMLErrorEvent;
|
|
4350
4400
|
exports.isSignal = isSignal;
|
|
4351
4401
|
exports.isStateId = isStateId;
|
|
4352
4402
|
exports.isString = isString;
|
|
4353
|
-
exports.log = log
|
|
4403
|
+
exports.log = log;
|
|
4354
4404
|
exports.macrostep = macrostep;
|
|
4355
4405
|
exports.mapValues = mapValues;
|
|
4356
4406
|
exports.matchesState = matchesState;
|
|
@@ -4359,20 +4409,20 @@ exports.microstep = microstep;
|
|
|
4359
4409
|
exports.not = not;
|
|
4360
4410
|
exports.or = or;
|
|
4361
4411
|
exports.pathToStateValue = pathToStateValue;
|
|
4362
|
-
exports.pure = pure
|
|
4363
|
-
exports.raise = raise
|
|
4412
|
+
exports.pure = pure;
|
|
4413
|
+
exports.raise = raise;
|
|
4364
4414
|
exports.resolveActionObject = resolveActionObject;
|
|
4365
4415
|
exports.resolveActionsAndContext = resolveActionsAndContext;
|
|
4366
4416
|
exports.resolveReferencedActor = resolveReferencedActor;
|
|
4367
4417
|
exports.resolveStateValue = resolveStateValue;
|
|
4368
4418
|
exports.respond = respond;
|
|
4369
|
-
exports.send = send
|
|
4419
|
+
exports.send = send;
|
|
4370
4420
|
exports.sendParent = sendParent;
|
|
4371
4421
|
exports.sendTo = sendTo;
|
|
4372
4422
|
exports.startSignal = startSignal;
|
|
4373
4423
|
exports.startSignalType = startSignalType;
|
|
4374
4424
|
exports.stateIn = stateIn;
|
|
4375
|
-
exports.stop = stop
|
|
4425
|
+
exports.stop = stop;
|
|
4376
4426
|
exports.stopSignal = stopSignal;
|
|
4377
4427
|
exports.stopSignalType = stopSignalType;
|
|
4378
4428
|
exports.toActionObject = toActionObject;
|