xstate 5.0.0-alpha.5 → 5.0.0-beta.7
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.dev.js +1 -1
- package/actions/dist/xstate-actions.cjs.prod.js +1 -1
- 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.dev.js +1 -1
- package/actors/dist/xstate-actors.cjs.prod.js +1 -1
- 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/dist/{actions-96f799fc.cjs.dev.js → actions-0fcf4fd9.cjs.dev.js} +19 -16
- package/dist/{actions-2479953d.cjs.prod.js → actions-a1a641d3.cjs.prod.js} +19 -16
- package/dist/{actions-7678b87b.esm.js → actions-b334e916.esm.js} +19 -17
- package/dist/declarations/src/StateNode.d.ts +2 -2
- package/dist/declarations/src/actions.d.ts +4 -4
- package/dist/declarations/src/stateUtils.d.ts +6 -0
- package/dist/declarations/src/typegenTypes.d.ts +3 -3
- package/dist/declarations/src/types.d.ts +11 -11
- package/dist/xstate.cjs.dev.js +11 -9
- package/dist/xstate.cjs.prod.js +11 -9
- package/dist/xstate.esm.js +12 -10
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/guards/dist/xstate-guards.cjs.dev.js +1 -1
- package/guards/dist/xstate-guards.cjs.prod.js +1 -1
- package/guards/dist/xstate-guards.esm.js +1 -1
- package/guards/dist/xstate-guards.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -2041,8 +2041,7 @@ function getOutput(configuration, context, _event) {
|
|
|
2041
2041
|
var finalChildStateNode = configuration.find(function (stateNode) {
|
|
2042
2042
|
return stateNode.type === 'final' && stateNode.parent === machine.root;
|
|
2043
2043
|
});
|
|
2044
|
-
|
|
2045
|
-
return doneData;
|
|
2044
|
+
return finalChildStateNode && finalChildStateNode.output ? mapContext(finalChildStateNode.output, context, _event) : undefined;
|
|
2046
2045
|
}
|
|
2047
2046
|
var isAtomicStateNode = function isAtomicStateNode(stateNode) {
|
|
2048
2047
|
return stateNode.type === 'atomic' || stateNode.type === 'final';
|
|
@@ -2292,9 +2291,9 @@ function getDelayedTransitions(stateNode) {
|
|
|
2292
2291
|
});
|
|
2293
2292
|
}
|
|
2294
2293
|
function formatTransition(stateNode, transitionConfig) {
|
|
2295
|
-
var _transitionConfig$
|
|
2294
|
+
var _transitionConfig$ree;
|
|
2296
2295
|
var normalizedTarget = normalizeTarget(transitionConfig.target);
|
|
2297
|
-
var
|
|
2296
|
+
var reenter = (_transitionConfig$ree = transitionConfig.reenter) !== null && _transitionConfig$ree !== void 0 ? _transitionConfig$ree : false;
|
|
2298
2297
|
var guards = stateNode.machine.options.guards;
|
|
2299
2298
|
var target = resolveTarget(stateNode, normalizedTarget);
|
|
2300
2299
|
|
|
@@ -2309,7 +2308,7 @@ function formatTransition(stateNode, transitionConfig) {
|
|
|
2309
2308
|
}) : undefined,
|
|
2310
2309
|
target: target,
|
|
2311
2310
|
source: stateNode,
|
|
2312
|
-
|
|
2311
|
+
reenter: reenter,
|
|
2313
2312
|
eventType: transitionConfig.event,
|
|
2314
2313
|
toJSON: function toJSON() {
|
|
2315
2314
|
return _objectSpread2(_objectSpread2({}, transition), {}, {
|
|
@@ -2396,7 +2395,7 @@ function formatInitialTransition(stateNode, _target) {
|
|
|
2396
2395
|
source: stateNode,
|
|
2397
2396
|
actions: [],
|
|
2398
2397
|
eventType: null,
|
|
2399
|
-
|
|
2398
|
+
reenter: false,
|
|
2400
2399
|
target: resolvedTarget,
|
|
2401
2400
|
toJSON: function toJSON() {
|
|
2402
2401
|
return _objectSpread2(_objectSpread2({}, transition), {}, {
|
|
@@ -2429,6 +2428,9 @@ function resolveTarget(stateNode, targets) {
|
|
|
2429
2428
|
if (!isString(target)) {
|
|
2430
2429
|
return target;
|
|
2431
2430
|
}
|
|
2431
|
+
if (isStateId(target)) {
|
|
2432
|
+
return stateNode.machine.getStateNodeById(target);
|
|
2433
|
+
}
|
|
2432
2434
|
var isInternalTarget = target[0] === stateNode.machine.delimiter;
|
|
2433
2435
|
// If internal target is defined on machine,
|
|
2434
2436
|
// do not include machine key on target
|
|
@@ -2444,7 +2446,7 @@ function resolveTarget(stateNode, targets) {
|
|
|
2444
2446
|
throw new Error("Invalid transition definition for state node '".concat(stateNode.id, "':\n").concat(err.message));
|
|
2445
2447
|
}
|
|
2446
2448
|
} else {
|
|
2447
|
-
|
|
2449
|
+
throw new Error("Invalid target: \"".concat(target, "\" is not a valid target from the root node. Did you mean \".").concat(target, "\"?"));
|
|
2448
2450
|
}
|
|
2449
2451
|
});
|
|
2450
2452
|
}
|
|
@@ -2816,7 +2818,7 @@ function getTransitionDomain(transition, historyValue) {
|
|
|
2816
2818
|
if (!targetStates) {
|
|
2817
2819
|
return null;
|
|
2818
2820
|
}
|
|
2819
|
-
if (!transition.
|
|
2821
|
+
if (!transition.reenter && transition.source.type !== 'parallel' && targetStates.every(function (targetStateNode) {
|
|
2820
2822
|
return isDescendant(targetStateNode, transition.source);
|
|
2821
2823
|
})) {
|
|
2822
2824
|
return transition.source;
|
|
@@ -2886,7 +2888,7 @@ function microstep(transitions, currentState, actorCtx, scxmlEvent) {
|
|
|
2886
2888
|
var microstate = microstepProcedure(currentState._initial ? [{
|
|
2887
2889
|
target: _toConsumableArray(currentState.configuration).filter(isAtomicStateNode),
|
|
2888
2890
|
source: machine.root,
|
|
2889
|
-
|
|
2891
|
+
reenter: true,
|
|
2890
2892
|
actions: [],
|
|
2891
2893
|
eventType: null,
|
|
2892
2894
|
toJSON: null // TODO: fix
|
|
@@ -3044,7 +3046,7 @@ function enterStates(filteredTransitions, mutConfiguration, actions, internalQue
|
|
|
3044
3046
|
if (!parent.parent) {
|
|
3045
3047
|
continue;
|
|
3046
3048
|
}
|
|
3047
|
-
internalQueue.push(toSCXMLEvent(done(parent.id, stateNodeToEnter.
|
|
3049
|
+
internalQueue.push(toSCXMLEvent(done(parent.id, stateNodeToEnter.output ? mapContext(stateNodeToEnter.output, currentState.context, currentState._event) : undefined)));
|
|
3048
3050
|
if (parent.parent) {
|
|
3049
3051
|
var grandparent = parent.parent;
|
|
3050
3052
|
if (grandparent.type === 'parallel') {
|
|
@@ -4198,13 +4200,13 @@ function after$1(delayRef, id) {
|
|
|
4198
4200
|
* has been reached in the parent state node.
|
|
4199
4201
|
*
|
|
4200
4202
|
* @param id The final state node's parent state node `id`
|
|
4201
|
-
* @param
|
|
4203
|
+
* @param output The data to pass into the event
|
|
4202
4204
|
*/
|
|
4203
|
-
function done(id,
|
|
4205
|
+
function done(id, output) {
|
|
4204
4206
|
var type = "".concat(exports.ActionTypes.DoneState, ".").concat(id);
|
|
4205
4207
|
var eventObject = {
|
|
4206
4208
|
type: type,
|
|
4207
|
-
|
|
4209
|
+
output: output
|
|
4208
4210
|
};
|
|
4209
4211
|
eventObject.toString = function () {
|
|
4210
4212
|
return type;
|
|
@@ -4219,13 +4221,13 @@ function done(id, data) {
|
|
|
4219
4221
|
* but not when it is canceled.
|
|
4220
4222
|
*
|
|
4221
4223
|
* @param invokeId The invoked service ID
|
|
4222
|
-
* @param
|
|
4224
|
+
* @param output The data to pass into the event
|
|
4223
4225
|
*/
|
|
4224
|
-
function doneInvoke(invokeId,
|
|
4226
|
+
function doneInvoke(invokeId, output) {
|
|
4225
4227
|
var type = "".concat(exports.ActionTypes.DoneInvoke, ".").concat(invokeId);
|
|
4226
4228
|
var eventObject = {
|
|
4227
4229
|
type: type,
|
|
4228
|
-
|
|
4230
|
+
output: output
|
|
4229
4231
|
};
|
|
4230
4232
|
eventObject.toString = function () {
|
|
4231
4233
|
return type;
|
|
@@ -4292,6 +4294,7 @@ exports.getConfiguration = getConfiguration;
|
|
|
4292
4294
|
exports.getDelayedTransitions = getDelayedTransitions;
|
|
4293
4295
|
exports.getInitialConfiguration = getInitialConfiguration;
|
|
4294
4296
|
exports.getPersistedState = getPersistedState;
|
|
4297
|
+
exports.getStateNodeByPath = getStateNodeByPath;
|
|
4295
4298
|
exports.getStateNodes = getStateNodes;
|
|
4296
4299
|
exports.initEvent = initEvent;
|
|
4297
4300
|
exports.interpret = interpret;
|
|
@@ -2020,8 +2020,7 @@ function getOutput(configuration, context, _event) {
|
|
|
2020
2020
|
var finalChildStateNode = configuration.find(function (stateNode) {
|
|
2021
2021
|
return stateNode.type === 'final' && stateNode.parent === machine.root;
|
|
2022
2022
|
});
|
|
2023
|
-
|
|
2024
|
-
return doneData;
|
|
2023
|
+
return finalChildStateNode && finalChildStateNode.output ? mapContext(finalChildStateNode.output, context, _event) : undefined;
|
|
2025
2024
|
}
|
|
2026
2025
|
var isAtomicStateNode = function isAtomicStateNode(stateNode) {
|
|
2027
2026
|
return stateNode.type === 'atomic' || stateNode.type === 'final';
|
|
@@ -2265,9 +2264,9 @@ function getDelayedTransitions(stateNode) {
|
|
|
2265
2264
|
});
|
|
2266
2265
|
}
|
|
2267
2266
|
function formatTransition(stateNode, transitionConfig) {
|
|
2268
|
-
var _transitionConfig$
|
|
2267
|
+
var _transitionConfig$ree;
|
|
2269
2268
|
var normalizedTarget = normalizeTarget(transitionConfig.target);
|
|
2270
|
-
var
|
|
2269
|
+
var reenter = (_transitionConfig$ree = transitionConfig.reenter) !== null && _transitionConfig$ree !== void 0 ? _transitionConfig$ree : false;
|
|
2271
2270
|
var guards = stateNode.machine.options.guards;
|
|
2272
2271
|
var target = resolveTarget(stateNode, normalizedTarget);
|
|
2273
2272
|
var transition = _objectSpread2(_objectSpread2({}, transitionConfig), {}, {
|
|
@@ -2277,7 +2276,7 @@ function formatTransition(stateNode, transitionConfig) {
|
|
|
2277
2276
|
}) : undefined,
|
|
2278
2277
|
target: target,
|
|
2279
2278
|
source: stateNode,
|
|
2280
|
-
|
|
2279
|
+
reenter: reenter,
|
|
2281
2280
|
eventType: transitionConfig.event,
|
|
2282
2281
|
toJSON: function toJSON() {
|
|
2283
2282
|
return _objectSpread2(_objectSpread2({}, transition), {}, {
|
|
@@ -2364,7 +2363,7 @@ function formatInitialTransition(stateNode, _target) {
|
|
|
2364
2363
|
source: stateNode,
|
|
2365
2364
|
actions: [],
|
|
2366
2365
|
eventType: null,
|
|
2367
|
-
|
|
2366
|
+
reenter: false,
|
|
2368
2367
|
target: resolvedTarget,
|
|
2369
2368
|
toJSON: function toJSON() {
|
|
2370
2369
|
return _objectSpread2(_objectSpread2({}, transition), {}, {
|
|
@@ -2397,6 +2396,9 @@ function resolveTarget(stateNode, targets) {
|
|
|
2397
2396
|
if (!isString(target)) {
|
|
2398
2397
|
return target;
|
|
2399
2398
|
}
|
|
2399
|
+
if (isStateId(target)) {
|
|
2400
|
+
return stateNode.machine.getStateNodeById(target);
|
|
2401
|
+
}
|
|
2400
2402
|
var isInternalTarget = target[0] === stateNode.machine.delimiter;
|
|
2401
2403
|
// If internal target is defined on machine,
|
|
2402
2404
|
// do not include machine key on target
|
|
@@ -2412,7 +2414,7 @@ function resolveTarget(stateNode, targets) {
|
|
|
2412
2414
|
throw new Error("Invalid transition definition for state node '".concat(stateNode.id, "':\n").concat(err.message));
|
|
2413
2415
|
}
|
|
2414
2416
|
} else {
|
|
2415
|
-
|
|
2417
|
+
throw new Error("Invalid target: \"".concat(target, "\" is not a valid target from the root node. Did you mean \".").concat(target, "\"?"));
|
|
2416
2418
|
}
|
|
2417
2419
|
});
|
|
2418
2420
|
}
|
|
@@ -2784,7 +2786,7 @@ function getTransitionDomain(transition, historyValue) {
|
|
|
2784
2786
|
if (!targetStates) {
|
|
2785
2787
|
return null;
|
|
2786
2788
|
}
|
|
2787
|
-
if (!transition.
|
|
2789
|
+
if (!transition.reenter && transition.source.type !== 'parallel' && targetStates.every(function (targetStateNode) {
|
|
2788
2790
|
return isDescendant(targetStateNode, transition.source);
|
|
2789
2791
|
})) {
|
|
2790
2792
|
return transition.source;
|
|
@@ -2854,7 +2856,7 @@ function microstep(transitions, currentState, actorCtx, scxmlEvent) {
|
|
|
2854
2856
|
var microstate = microstepProcedure(currentState._initial ? [{
|
|
2855
2857
|
target: _toConsumableArray(currentState.configuration).filter(isAtomicStateNode),
|
|
2856
2858
|
source: machine.root,
|
|
2857
|
-
|
|
2859
|
+
reenter: true,
|
|
2858
2860
|
actions: [],
|
|
2859
2861
|
eventType: null,
|
|
2860
2862
|
toJSON: null // TODO: fix
|
|
@@ -3012,7 +3014,7 @@ function enterStates(filteredTransitions, mutConfiguration, actions, internalQue
|
|
|
3012
3014
|
if (!parent.parent) {
|
|
3013
3015
|
continue;
|
|
3014
3016
|
}
|
|
3015
|
-
internalQueue.push(toSCXMLEvent(done(parent.id, stateNodeToEnter.
|
|
3017
|
+
internalQueue.push(toSCXMLEvent(done(parent.id, stateNodeToEnter.output ? mapContext(stateNodeToEnter.output, currentState.context, currentState._event) : undefined)));
|
|
3016
3018
|
if (parent.parent) {
|
|
3017
3019
|
var grandparent = parent.parent;
|
|
3018
3020
|
if (grandparent.type === 'parallel') {
|
|
@@ -4160,13 +4162,13 @@ function after$1(delayRef, id) {
|
|
|
4160
4162
|
* has been reached in the parent state node.
|
|
4161
4163
|
*
|
|
4162
4164
|
* @param id The final state node's parent state node `id`
|
|
4163
|
-
* @param
|
|
4165
|
+
* @param output The data to pass into the event
|
|
4164
4166
|
*/
|
|
4165
|
-
function done(id,
|
|
4167
|
+
function done(id, output) {
|
|
4166
4168
|
var type = "".concat(exports.ActionTypes.DoneState, ".").concat(id);
|
|
4167
4169
|
var eventObject = {
|
|
4168
4170
|
type: type,
|
|
4169
|
-
|
|
4171
|
+
output: output
|
|
4170
4172
|
};
|
|
4171
4173
|
eventObject.toString = function () {
|
|
4172
4174
|
return type;
|
|
@@ -4181,13 +4183,13 @@ function done(id, data) {
|
|
|
4181
4183
|
* but not when it is canceled.
|
|
4182
4184
|
*
|
|
4183
4185
|
* @param invokeId The invoked service ID
|
|
4184
|
-
* @param
|
|
4186
|
+
* @param output The data to pass into the event
|
|
4185
4187
|
*/
|
|
4186
|
-
function doneInvoke(invokeId,
|
|
4188
|
+
function doneInvoke(invokeId, output) {
|
|
4187
4189
|
var type = "".concat(exports.ActionTypes.DoneInvoke, ".").concat(invokeId);
|
|
4188
4190
|
var eventObject = {
|
|
4189
4191
|
type: type,
|
|
4190
|
-
|
|
4192
|
+
output: output
|
|
4191
4193
|
};
|
|
4192
4194
|
eventObject.toString = function () {
|
|
4193
4195
|
return type;
|
|
@@ -4254,6 +4256,7 @@ exports.getConfiguration = getConfiguration;
|
|
|
4254
4256
|
exports.getDelayedTransitions = getDelayedTransitions;
|
|
4255
4257
|
exports.getInitialConfiguration = getInitialConfiguration;
|
|
4256
4258
|
exports.getPersistedState = getPersistedState;
|
|
4259
|
+
exports.getStateNodeByPath = getStateNodeByPath;
|
|
4257
4260
|
exports.getStateNodes = getStateNodes;
|
|
4258
4261
|
exports.initEvent = initEvent;
|
|
4259
4262
|
exports.interpret = interpret;
|
|
@@ -2073,8 +2073,7 @@ function getOutput(configuration, context, _event) {
|
|
|
2073
2073
|
var finalChildStateNode = configuration.find(function (stateNode) {
|
|
2074
2074
|
return stateNode.type === 'final' && stateNode.parent === machine.root;
|
|
2075
2075
|
});
|
|
2076
|
-
|
|
2077
|
-
return doneData;
|
|
2076
|
+
return finalChildStateNode && finalChildStateNode.output ? mapContext(finalChildStateNode.output, context, _event) : undefined;
|
|
2078
2077
|
}
|
|
2079
2078
|
var isAtomicStateNode = function isAtomicStateNode(stateNode) {
|
|
2080
2079
|
return stateNode.type === 'atomic' || stateNode.type === 'final';
|
|
@@ -2324,9 +2323,9 @@ function getDelayedTransitions(stateNode) {
|
|
|
2324
2323
|
});
|
|
2325
2324
|
}
|
|
2326
2325
|
function formatTransition(stateNode, transitionConfig) {
|
|
2327
|
-
var _transitionConfig$
|
|
2326
|
+
var _transitionConfig$ree;
|
|
2328
2327
|
var normalizedTarget = normalizeTarget(transitionConfig.target);
|
|
2329
|
-
var
|
|
2328
|
+
var reenter = (_transitionConfig$ree = transitionConfig.reenter) !== null && _transitionConfig$ree !== void 0 ? _transitionConfig$ree : false;
|
|
2330
2329
|
var guards = stateNode.machine.options.guards;
|
|
2331
2330
|
var target = resolveTarget(stateNode, normalizedTarget);
|
|
2332
2331
|
|
|
@@ -2341,7 +2340,7 @@ function formatTransition(stateNode, transitionConfig) {
|
|
|
2341
2340
|
}) : undefined,
|
|
2342
2341
|
target: target,
|
|
2343
2342
|
source: stateNode,
|
|
2344
|
-
|
|
2343
|
+
reenter: reenter,
|
|
2345
2344
|
eventType: transitionConfig.event,
|
|
2346
2345
|
toJSON: function toJSON() {
|
|
2347
2346
|
return _objectSpread2(_objectSpread2({}, transition), {}, {
|
|
@@ -2428,7 +2427,7 @@ function formatInitialTransition(stateNode, _target) {
|
|
|
2428
2427
|
source: stateNode,
|
|
2429
2428
|
actions: [],
|
|
2430
2429
|
eventType: null,
|
|
2431
|
-
|
|
2430
|
+
reenter: false,
|
|
2432
2431
|
target: resolvedTarget,
|
|
2433
2432
|
toJSON: function toJSON() {
|
|
2434
2433
|
return _objectSpread2(_objectSpread2({}, transition), {}, {
|
|
@@ -2461,6 +2460,9 @@ function resolveTarget(stateNode, targets) {
|
|
|
2461
2460
|
if (!isString(target)) {
|
|
2462
2461
|
return target;
|
|
2463
2462
|
}
|
|
2463
|
+
if (isStateId(target)) {
|
|
2464
|
+
return stateNode.machine.getStateNodeById(target);
|
|
2465
|
+
}
|
|
2464
2466
|
var isInternalTarget = target[0] === stateNode.machine.delimiter;
|
|
2465
2467
|
// If internal target is defined on machine,
|
|
2466
2468
|
// do not include machine key on target
|
|
@@ -2476,7 +2478,7 @@ function resolveTarget(stateNode, targets) {
|
|
|
2476
2478
|
throw new Error("Invalid transition definition for state node '".concat(stateNode.id, "':\n").concat(err.message));
|
|
2477
2479
|
}
|
|
2478
2480
|
} else {
|
|
2479
|
-
|
|
2481
|
+
throw new Error("Invalid target: \"".concat(target, "\" is not a valid target from the root node. Did you mean \".").concat(target, "\"?"));
|
|
2480
2482
|
}
|
|
2481
2483
|
});
|
|
2482
2484
|
}
|
|
@@ -2848,7 +2850,7 @@ function getTransitionDomain(transition, historyValue) {
|
|
|
2848
2850
|
if (!targetStates) {
|
|
2849
2851
|
return null;
|
|
2850
2852
|
}
|
|
2851
|
-
if (!transition.
|
|
2853
|
+
if (!transition.reenter && transition.source.type !== 'parallel' && targetStates.every(function (targetStateNode) {
|
|
2852
2854
|
return isDescendant(targetStateNode, transition.source);
|
|
2853
2855
|
})) {
|
|
2854
2856
|
return transition.source;
|
|
@@ -2918,7 +2920,7 @@ function microstep(transitions, currentState, actorCtx, scxmlEvent) {
|
|
|
2918
2920
|
var microstate = microstepProcedure(currentState._initial ? [{
|
|
2919
2921
|
target: _toConsumableArray(currentState.configuration).filter(isAtomicStateNode),
|
|
2920
2922
|
source: machine.root,
|
|
2921
|
-
|
|
2923
|
+
reenter: true,
|
|
2922
2924
|
actions: [],
|
|
2923
2925
|
eventType: null,
|
|
2924
2926
|
toJSON: null // TODO: fix
|
|
@@ -3076,7 +3078,7 @@ function enterStates(filteredTransitions, mutConfiguration, actions, internalQue
|
|
|
3076
3078
|
if (!parent.parent) {
|
|
3077
3079
|
continue;
|
|
3078
3080
|
}
|
|
3079
|
-
internalQueue.push(toSCXMLEvent(done(parent.id, stateNodeToEnter.
|
|
3081
|
+
internalQueue.push(toSCXMLEvent(done(parent.id, stateNodeToEnter.output ? mapContext(stateNodeToEnter.output, currentState.context, currentState._event) : undefined)));
|
|
3080
3082
|
if (parent.parent) {
|
|
3081
3083
|
var grandparent = parent.parent;
|
|
3082
3084
|
if (grandparent.type === 'parallel') {
|
|
@@ -4230,13 +4232,13 @@ function after$1(delayRef, id) {
|
|
|
4230
4232
|
* has been reached in the parent state node.
|
|
4231
4233
|
*
|
|
4232
4234
|
* @param id The final state node's parent state node `id`
|
|
4233
|
-
* @param
|
|
4235
|
+
* @param output The data to pass into the event
|
|
4234
4236
|
*/
|
|
4235
|
-
function done(id,
|
|
4237
|
+
function done(id, output) {
|
|
4236
4238
|
var type = "".concat(ActionTypes.DoneState, ".").concat(id);
|
|
4237
4239
|
var eventObject = {
|
|
4238
4240
|
type: type,
|
|
4239
|
-
|
|
4241
|
+
output: output
|
|
4240
4242
|
};
|
|
4241
4243
|
eventObject.toString = function () {
|
|
4242
4244
|
return type;
|
|
@@ -4251,13 +4253,13 @@ function done(id, data) {
|
|
|
4251
4253
|
* but not when it is canceled.
|
|
4252
4254
|
*
|
|
4253
4255
|
* @param invokeId The invoked service ID
|
|
4254
|
-
* @param
|
|
4256
|
+
* @param output The data to pass into the event
|
|
4255
4257
|
*/
|
|
4256
|
-
function doneInvoke(invokeId,
|
|
4258
|
+
function doneInvoke(invokeId, output) {
|
|
4257
4259
|
var type = "".concat(ActionTypes.DoneInvoke, ".").concat(invokeId);
|
|
4258
4260
|
var eventObject = {
|
|
4259
4261
|
type: type,
|
|
4260
|
-
|
|
4262
|
+
output: output
|
|
4261
4263
|
};
|
|
4262
4264
|
eventObject.toString = function () {
|
|
4263
4265
|
return type;
|
|
@@ -4282,4 +4284,4 @@ function createInitEvent(input) {
|
|
|
4282
4284
|
});
|
|
4283
4285
|
}
|
|
4284
4286
|
|
|
4285
|
-
export {
|
|
4287
|
+
export { sendTo as $, getConfiguration as A, getStateNodes as B, resolveStateValue as C, isInFinalState as D, toSCXMLEvent as E, isSCXMLErrorEvent as F, macrostep as G, transitionNode as H, _slicedToArray as I, getInitialConfiguration as J, resolveActionsAndContext as K, microstep as L, error$1 as M, NULL_EVENT as N, isStateId as O, getStateNodeByPath as P, getPersistedState as Q, resolveReferencedActor as R, State as S, interpret as T, STATE_DELIMITER as U, initEvent as V, matchesState as W, raise$1 as X, send$1 as Y, sendParent as Z, _createClass as _, toActionObjects as a, log$1 as a0, cancel$1 as a1, stop$1 as a2, assign$1 as a3, after$1 as a4, done as a5, respond as a6, forwardTo as a7, escalate as a8, choose$1 as a9, toActionObject as aA, Interpreter as aa, ActorStatus as ab, doneInvoke as ac, pathToStateValue as ad, toObserver as ae, ActionTypes as af, SpecialTargets as ag, startSignalType as ah, stopSignalType as ai, startSignal as aj, stopSignal as ak, isSignal as al, isActorRef as am, toActorRef as an, fromTransition as ao, fromPromise as ap, fromObservable as aq, fromEventObservable as ar, fromCallback as as, stateIn as at, not as au, and as av, or as aw, toGuardDefinition as ax, actionTypes as ay, resolveActionObject as az, toTransitionConfigArray as b, createDynamicAction as c, formatTransition as d, memo as e, formatTransitions as f, _createForOfIteratorHelper as g, evaluateGuard as h, _toConsumableArray as i, flatten as j, _classCallCheck as k, _defineProperty as l, mapValues as m, createInvokeId as n, toInvokeConfig as o, pure as p, _objectSpread2 as q, invoke as r, _objectWithoutProperties as s, toArray as t, getDelayedTransitions as u, formatInitialTransition as v, getCandidates as w, isString as x, createSpawner as y, createInitEvent as z };
|
|
@@ -65,9 +65,9 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
|
|
|
65
65
|
*/
|
|
66
66
|
meta?: any;
|
|
67
67
|
/**
|
|
68
|
-
* The data sent with the "done.state._id_" event if this is a final state node.
|
|
68
|
+
* The output data sent with the "done.state._id_" event if this is a final state node.
|
|
69
69
|
*/
|
|
70
|
-
|
|
70
|
+
output?: Mapper<TContext, TEvent, any> | PropertyMapper<TContext, TEvent, any>;
|
|
71
71
|
/**
|
|
72
72
|
* The order this state node appears. Corresponds to the implicit SCXML document order.
|
|
73
73
|
*/
|
|
@@ -27,9 +27,9 @@ export declare function after(delayRef: number | string, id?: string): string;
|
|
|
27
27
|
* has been reached in the parent state node.
|
|
28
28
|
*
|
|
29
29
|
* @param id The final state node's parent state node `id`
|
|
30
|
-
* @param
|
|
30
|
+
* @param output The data to pass into the event
|
|
31
31
|
*/
|
|
32
|
-
export declare function done(id: string,
|
|
32
|
+
export declare function done(id: string, output?: any): DoneEventObject;
|
|
33
33
|
/**
|
|
34
34
|
* Returns an event that represents that an invoked service has terminated.
|
|
35
35
|
*
|
|
@@ -37,9 +37,9 @@ export declare function done(id: string, data?: any): DoneEventObject;
|
|
|
37
37
|
* but not when it is canceled.
|
|
38
38
|
*
|
|
39
39
|
* @param invokeId The invoked service ID
|
|
40
|
-
* @param
|
|
40
|
+
* @param output The data to pass into the event
|
|
41
41
|
*/
|
|
42
|
-
export declare function doneInvoke(invokeId: string,
|
|
42
|
+
export declare function doneInvoke(invokeId: string, output?: any): DoneEvent;
|
|
43
43
|
export declare function error(id: string, data?: any): ErrorPlatformEvent & string;
|
|
44
44
|
export declare function createInitEvent(input: any): SCXML.Event<{
|
|
45
45
|
type: ActionTypes.Init;
|
|
@@ -32,6 +32,12 @@ export declare function getInitialStateNodes(stateNode: AnyStateNode): Array<Any
|
|
|
32
32
|
* Returns the child state node from its relative `stateKey`, or throws.
|
|
33
33
|
*/
|
|
34
34
|
export declare function getStateNode(stateNode: AnyStateNode, stateKey: string): AnyStateNode;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the relative state node from the given `statePath`, or throws.
|
|
37
|
+
*
|
|
38
|
+
* @param statePath The string or string array relative path to the state node.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getStateNodeByPath(stateNode: AnyStateNode, statePath: string | string[]): AnyStateNode;
|
|
35
41
|
/**
|
|
36
42
|
* Returns the state nodes represented by the current state value.
|
|
37
43
|
*
|
|
@@ -121,11 +121,11 @@ export interface ResolveTypegenMeta<TTypesMeta extends TypegenConstraint, TEvent
|
|
|
121
121
|
disabled: TypegenDisabled & AllImplementationsProvided & AllowAllEvents & {
|
|
122
122
|
indexedActions: IndexByType<TAction>;
|
|
123
123
|
indexedEvents: Record<string, TEvent> & {
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
__XSTATE_ALLOW_ANY_INVOKE_OUTPUT_HACK__: {
|
|
125
|
+
output: any;
|
|
126
126
|
};
|
|
127
127
|
};
|
|
128
|
-
invokeSrcNameMap: Record<string, '
|
|
128
|
+
invokeSrcNameMap: Record<string, '__XSTATE_ALLOW_ANY_INVOKE_OUTPUT_HACK__'>;
|
|
129
129
|
};
|
|
130
130
|
}[IsNever<TTypesMeta> extends true ? 'disabled' : TTypesMeta extends TypegenEnabled ? 'enabled' : 'disabled'];
|
|
131
131
|
}
|
|
@@ -161,7 +161,7 @@ export type TransitionTarget = SingleOrArray<string>;
|
|
|
161
161
|
export interface TransitionConfig<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent, TAction extends ParameterizedObject = ParameterizedObject> {
|
|
162
162
|
guard?: GuardConfig<TContext, TExpressionEvent>;
|
|
163
163
|
actions?: BaseActions<TContext, TExpressionEvent, TEvent, TAction>;
|
|
164
|
-
|
|
164
|
+
reenter?: boolean;
|
|
165
165
|
target?: TransitionTarget | undefined;
|
|
166
166
|
meta?: Record<string, any>;
|
|
167
167
|
description?: string;
|
|
@@ -269,7 +269,7 @@ export interface InvokeConfig<TContext extends MachineContext, TEvent extends Ev
|
|
|
269
269
|
/**
|
|
270
270
|
* The transition to take upon the invoked child machine sending an error event.
|
|
271
271
|
*/
|
|
272
|
-
onError?: string | SingleOrArray<TransitionConfigOrTarget<TContext,
|
|
272
|
+
onError?: string | SingleOrArray<TransitionConfigOrTarget<TContext, ErrorEvent<any>, TEvent>>;
|
|
273
273
|
onSnapshot?: string | SingleOrArray<TransitionConfigOrTarget<TContext, SnapshotEvent<any>, TEvent>>;
|
|
274
274
|
/**
|
|
275
275
|
* Meta data related to this invocation
|
|
@@ -341,12 +341,12 @@ export interface StateNodeConfig<TContext extends MachineContext, TEvent extends
|
|
|
341
341
|
*/
|
|
342
342
|
meta?: any;
|
|
343
343
|
/**
|
|
344
|
-
* The data sent with the "done.state._id_" event if this is a final state node.
|
|
344
|
+
* The output data sent with the "done.state._id_" event if this is a final state node.
|
|
345
345
|
*
|
|
346
|
-
* The data will be evaluated with the current `context` and placed on the `.data` property
|
|
346
|
+
* The output data will be evaluated with the current `context` and placed on the `.data` property
|
|
347
347
|
* of the event.
|
|
348
348
|
*/
|
|
349
|
-
|
|
349
|
+
output?: Mapper<TContext, TEvent, any> | PropertyMapper<TContext, TEvent, any>;
|
|
350
350
|
/**
|
|
351
351
|
* The unique ID of the state node, which can be referenced as a transition target via the
|
|
352
352
|
* `#id` syntax.
|
|
@@ -387,7 +387,7 @@ export interface StateNodeDefinition<TContext extends MachineContext, TEvent ext
|
|
|
387
387
|
exit: BaseActionObject[];
|
|
388
388
|
meta: any;
|
|
389
389
|
order: number;
|
|
390
|
-
|
|
390
|
+
output?: FinalStateNodeConfig<TContext, TEvent>['output'];
|
|
391
391
|
invoke: Array<InvokeDefinition<TContext, TEvent>>;
|
|
392
392
|
description?: string;
|
|
393
393
|
tags: string[];
|
|
@@ -416,7 +416,7 @@ export interface FinalStateNodeConfig<TContext extends MachineContext, TEvent ex
|
|
|
416
416
|
* The data to be sent with the "done.state.<id>" event. The data can be
|
|
417
417
|
* static or dynamic (based on assigners).
|
|
418
418
|
*/
|
|
419
|
-
|
|
419
|
+
output?: Mapper<TContext, TEvent, any> | PropertyMapper<TContext, TEvent, any>;
|
|
420
420
|
}
|
|
421
421
|
export type SimpleOrStateNodeConfig<TContext extends MachineContext, TEvent extends EventObject> = AtomicStateNodeConfig<TContext, TEvent> | StateNodeConfig<TContext, TEvent>;
|
|
422
422
|
export type ActionFunctionMap<TContext extends MachineContext, TEvent extends EventObject, TAction extends ParameterizedObject = ParameterizedObject> = {
|
|
@@ -494,7 +494,7 @@ export interface MachineConfig<TContext extends MachineContext, TEvent extends E
|
|
|
494
494
|
tsTypes?: TTypesMeta;
|
|
495
495
|
}
|
|
496
496
|
export type ActorMap = Record<string, {
|
|
497
|
-
|
|
497
|
+
output: any;
|
|
498
498
|
}>;
|
|
499
499
|
export interface MachineSchema<TContext extends MachineContext, TEvent extends EventObject, TActorMap extends ActorMap = ActorMap> {
|
|
500
500
|
context?: TContext;
|
|
@@ -547,7 +547,7 @@ export interface RaiseActionObject<TContext extends MachineContext, TExpressionE
|
|
|
547
547
|
}
|
|
548
548
|
export interface DoneInvokeEvent<TData> extends EventObject {
|
|
549
549
|
type: `done.invoke.${string}`;
|
|
550
|
-
|
|
550
|
+
output: TData;
|
|
551
551
|
}
|
|
552
552
|
export interface ErrorEvent<TErrorData> {
|
|
553
553
|
type: `error.${string}`;
|
|
@@ -570,7 +570,7 @@ export interface SCXMLErrorEvent extends SCXML.Event<any> {
|
|
|
570
570
|
data: any;
|
|
571
571
|
}
|
|
572
572
|
export interface DoneEventObject extends EventObject {
|
|
573
|
-
|
|
573
|
+
output?: any;
|
|
574
574
|
toString(): string;
|
|
575
575
|
}
|
|
576
576
|
export type DoneEvent = DoneEventObject & string;
|
|
@@ -731,7 +731,7 @@ export interface TransitionDefinition<TContext extends MachineContext, TEvent ex
|
|
|
731
731
|
target: Array<StateNode<TContext, TEvent>> | undefined;
|
|
732
732
|
source: StateNode<TContext, TEvent>;
|
|
733
733
|
actions: BaseActionObject[];
|
|
734
|
-
|
|
734
|
+
reenter: boolean;
|
|
735
735
|
guard?: GuardDefinition<TContext, TEvent>;
|
|
736
736
|
eventType: TEvent['type'] | '*';
|
|
737
737
|
toJSON: () => {
|
package/dist/xstate.cjs.dev.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var actors_dist_xstateActors = require('./actions-
|
|
5
|
+
var actors_dist_xstateActors = require('./actions-0fcf4fd9.cjs.dev.js');
|
|
6
6
|
require('./index-ebaab3c9.cjs.dev.js');
|
|
7
7
|
|
|
8
8
|
function pure(getActions) {
|
|
@@ -83,7 +83,7 @@ var StateNode = /*#__PURE__*/function () {
|
|
|
83
83
|
*/
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
|
-
* The data sent with the "done.state._id_" event if this is a final state node.
|
|
86
|
+
* The output data sent with the "done.state._id_" event if this is a final state node.
|
|
87
87
|
*/
|
|
88
88
|
|
|
89
89
|
/**
|
|
@@ -109,7 +109,7 @@ var StateNode = /*#__PURE__*/function () {
|
|
|
109
109
|
actors_dist_xstateActors._defineProperty(this, "parent", void 0);
|
|
110
110
|
actors_dist_xstateActors._defineProperty(this, "machine", void 0);
|
|
111
111
|
actors_dist_xstateActors._defineProperty(this, "meta", void 0);
|
|
112
|
-
actors_dist_xstateActors._defineProperty(this, "
|
|
112
|
+
actors_dist_xstateActors._defineProperty(this, "output", void 0);
|
|
113
113
|
actors_dist_xstateActors._defineProperty(this, "order", -1);
|
|
114
114
|
actors_dist_xstateActors._defineProperty(this, "description", void 0);
|
|
115
115
|
actors_dist_xstateActors._defineProperty(this, "tags", []);
|
|
@@ -141,7 +141,7 @@ var StateNode = /*#__PURE__*/function () {
|
|
|
141
141
|
this.entry = actors_dist_xstateActors.toActionObjects(this.config.entry);
|
|
142
142
|
this.exit = actors_dist_xstateActors.toActionObjects(this.config.exit);
|
|
143
143
|
this.meta = this.config.meta;
|
|
144
|
-
this.
|
|
144
|
+
this.output = this.type === 'final' ? this.config.output : undefined;
|
|
145
145
|
this.tags = actors_dist_xstateActors.toArray(config.tags);
|
|
146
146
|
}
|
|
147
147
|
actors_dist_xstateActors._createClass(StateNode, [{
|
|
@@ -176,7 +176,7 @@ var StateNode = /*#__PURE__*/function () {
|
|
|
176
176
|
source: this,
|
|
177
177
|
actions: this.initial.actions,
|
|
178
178
|
eventType: null,
|
|
179
|
-
|
|
179
|
+
reenter: false,
|
|
180
180
|
toJSON: function toJSON() {
|
|
181
181
|
return {
|
|
182
182
|
target: _this3.initial.target.map(function (t) {
|
|
@@ -198,7 +198,7 @@ var StateNode = /*#__PURE__*/function () {
|
|
|
198
198
|
exit: this.exit,
|
|
199
199
|
meta: this.meta,
|
|
200
200
|
order: this.order || -1,
|
|
201
|
-
|
|
201
|
+
output: this.output,
|
|
202
202
|
invoke: this.invoke,
|
|
203
203
|
description: this.description,
|
|
204
204
|
tags: this.tags
|
|
@@ -400,7 +400,7 @@ var StateNode = /*#__PURE__*/function () {
|
|
|
400
400
|
key: "ownEvents",
|
|
401
401
|
get: function get() {
|
|
402
402
|
var events = new Set(this.transitions.filter(function (transition) {
|
|
403
|
-
return !(!transition.target && !transition.actions.length && !transition.
|
|
403
|
+
return !(!transition.target && !transition.actions.length && !transition.reenter);
|
|
404
404
|
}).map(function (transition) {
|
|
405
405
|
return transition.eventType;
|
|
406
406
|
}));
|
|
@@ -666,12 +666,14 @@ var StateMachine = /*#__PURE__*/function () {
|
|
|
666
666
|
}, {
|
|
667
667
|
key: "getStateNodeById",
|
|
668
668
|
value: function getStateNodeById(stateId) {
|
|
669
|
-
var
|
|
669
|
+
var fullPath = stateId.split(this.delimiter);
|
|
670
|
+
var relativePath = fullPath.slice(1);
|
|
671
|
+
var resolvedStateId = actors_dist_xstateActors.isStateId(fullPath[0]) ? fullPath[0].slice(STATE_IDENTIFIER.length) : fullPath[0];
|
|
670
672
|
var stateNode = this.idMap.get(resolvedStateId);
|
|
671
673
|
if (!stateNode) {
|
|
672
674
|
throw new Error("Child state node '#".concat(resolvedStateId, "' does not exist on machine '").concat(this.id, "'"));
|
|
673
675
|
}
|
|
674
|
-
return stateNode;
|
|
676
|
+
return actors_dist_xstateActors.getStateNodeByPath(stateNode, relativePath);
|
|
675
677
|
}
|
|
676
678
|
}, {
|
|
677
679
|
key: "definition",
|