xstate 6.0.0-alpha.14 → 6.0.0-alpha.16
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/dist/{StateMachine-e3b1aa2d.cjs.js → StateMachine-18299be7.cjs.js} +29 -24
- package/dist/{StateMachine-8dbd20ad.esm.js → StateMachine-4a0a8848.esm.js} +29 -24
- package/dist/{StateMachine-98411dc5.development.cjs.js → StateMachine-7572fbeb.development.cjs.js} +39 -16
- package/dist/{StateMachine-0fa9c094.development.esm.js → StateMachine-dfe616b4.development.esm.js} +39 -16
- package/dist/declarations/src/createActor.d.ts +1 -0
- package/dist/declarations/src/createMachineFromConfig.d.ts +1 -0
- package/dist/declarations/src/setup.d.ts +17 -4
- package/dist/declarations/src/transitionActions.d.ts +3 -1
- package/dist/declarations/src/types.d.ts +40 -20
- package/dist/declarations/src/types.v6.d.ts +8 -2
- package/dist/declarations/src/utils.d.ts +2 -2
- package/dist/{index-07b19ed0.development.cjs.js → index-4a0afbfa.development.cjs.js} +308 -272
- package/dist/{index-362125ce.development.esm.js → index-5d18ec0c.development.esm.js} +308 -273
- package/dist/{index-0d940f2c.cjs.js → index-64839116.cjs.js} +307 -271
- package/dist/{index-2635a437.esm.js → index-9fc97b9e.esm.js} +307 -272
- package/dist/xstate-actors.cjs.js +1 -1
- package/dist/xstate-actors.development.cjs.js +1 -1
- package/dist/xstate-actors.development.esm.js +1 -1
- package/dist/xstate-actors.esm.js +1 -1
- package/dist/xstate-actors.umd.min.js +1 -1
- package/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/xstate-graph.cjs.js +2 -2
- package/dist/xstate-graph.development.cjs.js +2 -2
- package/dist/xstate-graph.development.esm.js +2 -2
- package/dist/xstate-graph.esm.js +2 -2
- package/dist/xstate-graph.umd.min.js +1 -1
- package/dist/xstate-graph.umd.min.js.map +1 -1
- package/dist/xstate.cjs.js +65 -20
- package/dist/xstate.development.cjs.js +65 -20
- package/dist/xstate.development.esm.js +67 -22
- package/dist/xstate.esm.js +67 -22
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var dist_xstateActors = require('./index-
|
|
3
|
+
var dist_xstateActors = require('./index-64839116.cjs.js');
|
|
4
4
|
|
|
5
5
|
function createSpawner(actorScope, {
|
|
6
6
|
machine,
|
|
@@ -66,7 +66,6 @@ function memo(object, key, fn) {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
const EMPTY_OBJECT = {};
|
|
69
|
-
const CHOICE_CONFIG_KEYS = ['invoke', 'after', 'on', 'entry', 'exit', 'always', 'states', 'initial', 'onDone', 'timeout', 'onTimeout', 'history', 'target', 'output'];
|
|
70
69
|
class StateNode {
|
|
71
70
|
constructor(/** The raw config used to create the machine. */
|
|
72
71
|
config, options) {
|
|
@@ -246,30 +245,17 @@ class StateNode {
|
|
|
246
245
|
function validateStateNodeConfig(stateNode) {
|
|
247
246
|
const config = stateNode.config;
|
|
248
247
|
if (stateNode.type !== 'choice') {
|
|
249
|
-
if (config.choice !== undefined) {
|
|
250
|
-
throw new Error(`State "${stateNode.id}" has \`choice\`, but \`choice\` can only be used with \`type: 'choice'\`.`);
|
|
251
|
-
}
|
|
252
248
|
return;
|
|
253
249
|
}
|
|
254
250
|
if (typeof config.choice !== 'function') {
|
|
255
|
-
throw new Error(`
|
|
256
|
-
}
|
|
257
|
-
for (const key of CHOICE_CONFIG_KEYS) {
|
|
258
|
-
if (config[key] !== undefined) {
|
|
259
|
-
throw new Error(`Choice state "${stateNode.id}" cannot declare \`${key}\`.`);
|
|
260
|
-
}
|
|
251
|
+
throw new Error(`Missing \`choice\` function on "${stateNode.id}"`);
|
|
261
252
|
}
|
|
262
253
|
}
|
|
263
254
|
function formatChoiceTransitions(stateNode) {
|
|
264
255
|
const choice = stateNode.config.choice;
|
|
265
256
|
const validateChoiceResult = result => {
|
|
266
257
|
if (!result || result.target === undefined) {
|
|
267
|
-
throw new Error(`Choice
|
|
268
|
-
}
|
|
269
|
-
for (const key of ['actions', 'to']) {
|
|
270
|
-
if (result[key] !== undefined) {
|
|
271
|
-
throw new Error(`Choice state "${stateNode.id}" cannot declare \`${key}\` on a choice.`);
|
|
272
|
-
}
|
|
258
|
+
throw new Error(`Choice "${stateNode.id}" has no target`);
|
|
273
259
|
}
|
|
274
260
|
return result;
|
|
275
261
|
};
|
|
@@ -290,7 +276,7 @@ function formatTransitions(stateNode) {
|
|
|
290
276
|
if (stateNode.config.on) {
|
|
291
277
|
for (const descriptor of Object.keys(stateNode.config.on)) {
|
|
292
278
|
if (descriptor === dist_xstateActors.NULL_EVENT) {
|
|
293
|
-
throw new Error('Null
|
|
279
|
+
throw new Error('Null event transition key');
|
|
294
280
|
}
|
|
295
281
|
const transitionsConfig = stateNode.config.on[descriptor];
|
|
296
282
|
transitions.set(descriptor, mapTransitionConfigs(transitionsConfig, transition => dist_xstateActors.formatTransition(stateNode, descriptor, transition)));
|
|
@@ -300,6 +286,10 @@ function formatTransitions(stateNode) {
|
|
|
300
286
|
const descriptor = `xstate.done.state.${stateNode.id}`;
|
|
301
287
|
transitions.set(descriptor, mapTransitionConfigs(stateNode.config.onDone, transition => dist_xstateActors.formatTransition(stateNode, descriptor, transition)));
|
|
302
288
|
}
|
|
289
|
+
if (stateNode.config.onError) {
|
|
290
|
+
const descriptor = 'xstate.error.*';
|
|
291
|
+
transitions.set(descriptor, mapTransitionConfigs(stateNode.config.onError, transition => dist_xstateActors.formatTransition(stateNode, descriptor, transition)));
|
|
292
|
+
}
|
|
303
293
|
const createCancelInvokeTimeoutTransition = (descriptor, timeoutEventType) => dist_xstateActors.formatTransition(stateNode, descriptor, {
|
|
304
294
|
to: (_args, enq) => {
|
|
305
295
|
enq.cancel(timeoutEventType);
|
|
@@ -386,7 +376,7 @@ function formatInitialTransition(stateNode, _target) {
|
|
|
386
376
|
const input = typeof _target === 'object' && _target !== null ? _target.input : undefined;
|
|
387
377
|
const resolvedTarget = typeof targetString === 'string' ? stateNode.states[targetString] : undefined;
|
|
388
378
|
if (!resolvedTarget && targetString) {
|
|
389
|
-
throw new Error(`Initial state
|
|
379
|
+
throw new Error(`Initial state "${targetString}" not found on "#${stateNode.id}"`);
|
|
390
380
|
}
|
|
391
381
|
const transition = {
|
|
392
382
|
source: stateNode,
|
|
@@ -642,11 +632,26 @@ class StateMachine {
|
|
|
642
632
|
const initEvent = dist_xstateActors.createInitEvent(input); // TODO: fix;
|
|
643
633
|
const internalQueue = [];
|
|
644
634
|
const preInitialState = this._getPreInitialState(actorScope, initEvent);
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
635
|
+
let nextState;
|
|
636
|
+
let initialActions = [];
|
|
637
|
+
let microsteps = [];
|
|
638
|
+
let macroState;
|
|
639
|
+
try {
|
|
640
|
+
[nextState, initialActions] = dist_xstateActors.initialMicrostep(this.root, preInitialState, actorScope, initEvent, internalQueue);
|
|
641
|
+
({
|
|
642
|
+
snapshot: macroState,
|
|
643
|
+
microsteps
|
|
644
|
+
} = dist_xstateActors.macrostep(nextState, initEvent, actorScope, internalQueue));
|
|
645
|
+
} catch (err) {
|
|
646
|
+
if (!this.root.config.onError) {
|
|
647
|
+
throw err;
|
|
648
|
+
}
|
|
649
|
+
const errorEvent = dist_xstateActors.createErrorPlatformEvent('execution', err);
|
|
650
|
+
const errorMacrostep = dist_xstateActors.macrostep(preInitialState, errorEvent, actorScope, []);
|
|
651
|
+
macroState = errorMacrostep.snapshot;
|
|
652
|
+
microsteps = errorMacrostep.microsteps;
|
|
653
|
+
initialActions = [];
|
|
654
|
+
}
|
|
650
655
|
return [macroState, [...initialActions, ...microsteps.flatMap(([, actions]) => actions)]];
|
|
651
656
|
}
|
|
652
657
|
start(snapshot) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as ProcessingStatus, G as resolveReferencedActor, d as createActor, S as STATE_DELIMITER, H as mapValues, t as toArray, I as createInvokeId, J as getDelayedTransitions, K as evaluateCandidate, L as formatTransition, N as NULL_EVENT, M as toTransitionConfigArray, O as createInvokeTimeoutEvent, Q as getCandidates, R as formatRouteTransitions, U as resolveStateValue, V as getAllStateNodes, k as getStateNodes, W as createMachineSnapshot, Y as isInFinalState, e as macrostep, Z as cloneMachineSnapshot, _ as transitionNode, m as matchesEventDescriptor, r as resolveActionsWithContext, f as createInitEvent, g as initialMicrostep, $ as toStatePath, a0 as isStateId, a1 as getStateNodeByPath, a2 as getPersistedSnapshot, a3 as $$ACTOR_TYPE } from './index-
|
|
1
|
+
import { P as ProcessingStatus, G as resolveReferencedActor, d as createActor, S as STATE_DELIMITER, H as mapValues, t as toArray, I as createInvokeId, J as getDelayedTransitions, K as evaluateCandidate, L as formatTransition, N as NULL_EVENT, M as toTransitionConfigArray, O as createInvokeTimeoutEvent, Q as getCandidates, R as formatRouteTransitions, U as resolveStateValue, V as getAllStateNodes, k as getStateNodes, W as createMachineSnapshot, Y as isInFinalState, e as macrostep, Z as cloneMachineSnapshot, _ as transitionNode, m as matchesEventDescriptor, r as resolveActionsWithContext, f as createInitEvent, g as initialMicrostep, $ as toStatePath, a0 as isStateId, a1 as getStateNodeByPath, a2 as getPersistedSnapshot, a3 as $$ACTOR_TYPE, a4 as createErrorPlatformEvent } from './index-9fc97b9e.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, {
|
|
4
4
|
machine,
|
|
@@ -64,7 +64,6 @@ function memo(object, key, fn) {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
const EMPTY_OBJECT = {};
|
|
67
|
-
const CHOICE_CONFIG_KEYS = ['invoke', 'after', 'on', 'entry', 'exit', 'always', 'states', 'initial', 'onDone', 'timeout', 'onTimeout', 'history', 'target', 'output'];
|
|
68
67
|
class StateNode {
|
|
69
68
|
constructor(/** The raw config used to create the machine. */
|
|
70
69
|
config, options) {
|
|
@@ -244,30 +243,17 @@ class StateNode {
|
|
|
244
243
|
function validateStateNodeConfig(stateNode) {
|
|
245
244
|
const config = stateNode.config;
|
|
246
245
|
if (stateNode.type !== 'choice') {
|
|
247
|
-
if (config.choice !== undefined) {
|
|
248
|
-
throw new Error(`State "${stateNode.id}" has \`choice\`, but \`choice\` can only be used with \`type: 'choice'\`.`);
|
|
249
|
-
}
|
|
250
246
|
return;
|
|
251
247
|
}
|
|
252
248
|
if (typeof config.choice !== 'function') {
|
|
253
|
-
throw new Error(`
|
|
254
|
-
}
|
|
255
|
-
for (const key of CHOICE_CONFIG_KEYS) {
|
|
256
|
-
if (config[key] !== undefined) {
|
|
257
|
-
throw new Error(`Choice state "${stateNode.id}" cannot declare \`${key}\`.`);
|
|
258
|
-
}
|
|
249
|
+
throw new Error(`Missing \`choice\` function on "${stateNode.id}"`);
|
|
259
250
|
}
|
|
260
251
|
}
|
|
261
252
|
function formatChoiceTransitions(stateNode) {
|
|
262
253
|
const choice = stateNode.config.choice;
|
|
263
254
|
const validateChoiceResult = result => {
|
|
264
255
|
if (!result || result.target === undefined) {
|
|
265
|
-
throw new Error(`Choice
|
|
266
|
-
}
|
|
267
|
-
for (const key of ['actions', 'to']) {
|
|
268
|
-
if (result[key] !== undefined) {
|
|
269
|
-
throw new Error(`Choice state "${stateNode.id}" cannot declare \`${key}\` on a choice.`);
|
|
270
|
-
}
|
|
256
|
+
throw new Error(`Choice "${stateNode.id}" has no target`);
|
|
271
257
|
}
|
|
272
258
|
return result;
|
|
273
259
|
};
|
|
@@ -288,7 +274,7 @@ function formatTransitions(stateNode) {
|
|
|
288
274
|
if (stateNode.config.on) {
|
|
289
275
|
for (const descriptor of Object.keys(stateNode.config.on)) {
|
|
290
276
|
if (descriptor === NULL_EVENT) {
|
|
291
|
-
throw new Error('Null
|
|
277
|
+
throw new Error('Null event transition key');
|
|
292
278
|
}
|
|
293
279
|
const transitionsConfig = stateNode.config.on[descriptor];
|
|
294
280
|
transitions.set(descriptor, mapTransitionConfigs(transitionsConfig, transition => formatTransition(stateNode, descriptor, transition)));
|
|
@@ -298,6 +284,10 @@ function formatTransitions(stateNode) {
|
|
|
298
284
|
const descriptor = `xstate.done.state.${stateNode.id}`;
|
|
299
285
|
transitions.set(descriptor, mapTransitionConfigs(stateNode.config.onDone, transition => formatTransition(stateNode, descriptor, transition)));
|
|
300
286
|
}
|
|
287
|
+
if (stateNode.config.onError) {
|
|
288
|
+
const descriptor = 'xstate.error.*';
|
|
289
|
+
transitions.set(descriptor, mapTransitionConfigs(stateNode.config.onError, transition => formatTransition(stateNode, descriptor, transition)));
|
|
290
|
+
}
|
|
301
291
|
const createCancelInvokeTimeoutTransition = (descriptor, timeoutEventType) => formatTransition(stateNode, descriptor, {
|
|
302
292
|
to: (_args, enq) => {
|
|
303
293
|
enq.cancel(timeoutEventType);
|
|
@@ -384,7 +374,7 @@ function formatInitialTransition(stateNode, _target) {
|
|
|
384
374
|
const input = typeof _target === 'object' && _target !== null ? _target.input : undefined;
|
|
385
375
|
const resolvedTarget = typeof targetString === 'string' ? stateNode.states[targetString] : undefined;
|
|
386
376
|
if (!resolvedTarget && targetString) {
|
|
387
|
-
throw new Error(`Initial state
|
|
377
|
+
throw new Error(`Initial state "${targetString}" not found on "#${stateNode.id}"`);
|
|
388
378
|
}
|
|
389
379
|
const transition = {
|
|
390
380
|
source: stateNode,
|
|
@@ -640,11 +630,26 @@ class StateMachine {
|
|
|
640
630
|
const initEvent = createInitEvent(input); // TODO: fix;
|
|
641
631
|
const internalQueue = [];
|
|
642
632
|
const preInitialState = this._getPreInitialState(actorScope, initEvent);
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
633
|
+
let nextState;
|
|
634
|
+
let initialActions = [];
|
|
635
|
+
let microsteps = [];
|
|
636
|
+
let macroState;
|
|
637
|
+
try {
|
|
638
|
+
[nextState, initialActions] = initialMicrostep(this.root, preInitialState, actorScope, initEvent, internalQueue);
|
|
639
|
+
({
|
|
640
|
+
snapshot: macroState,
|
|
641
|
+
microsteps
|
|
642
|
+
} = macrostep(nextState, initEvent, actorScope, internalQueue));
|
|
643
|
+
} catch (err) {
|
|
644
|
+
if (!this.root.config.onError) {
|
|
645
|
+
throw err;
|
|
646
|
+
}
|
|
647
|
+
const errorEvent = createErrorPlatformEvent('execution', err);
|
|
648
|
+
const errorMacrostep = macrostep(preInitialState, errorEvent, actorScope, []);
|
|
649
|
+
macroState = errorMacrostep.snapshot;
|
|
650
|
+
microsteps = errorMacrostep.microsteps;
|
|
651
|
+
initialActions = [];
|
|
652
|
+
}
|
|
648
653
|
return [macroState, [...initialActions, ...microsteps.flatMap(([, actions]) => actions)]];
|
|
649
654
|
}
|
|
650
655
|
start(snapshot) {
|
package/dist/{StateMachine-98411dc5.development.cjs.js → StateMachine-7572fbeb.development.cjs.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var dist_xstateActors = require('./index-
|
|
3
|
+
var dist_xstateActors = require('./index-4a0afbfa.development.cjs.js');
|
|
4
4
|
|
|
5
5
|
function createSpawner(actorScope, {
|
|
6
6
|
machine,
|
|
@@ -252,11 +252,13 @@ function validateStateNodeConfig(stateNode) {
|
|
|
252
252
|
return;
|
|
253
253
|
}
|
|
254
254
|
if (typeof config.choice !== 'function') {
|
|
255
|
-
throw new Error(`Choice state "${stateNode.id}" must declare a \`choice\` function.`);
|
|
255
|
+
throw new Error(`Choice state "${stateNode.id}" must declare a \`choice\` function.` );
|
|
256
256
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
{
|
|
258
|
+
for (const key of CHOICE_CONFIG_KEYS) {
|
|
259
|
+
if (config[key] !== undefined) {
|
|
260
|
+
throw new Error(`Choice state "${stateNode.id}" cannot declare \`${key}\`.`);
|
|
261
|
+
}
|
|
260
262
|
}
|
|
261
263
|
}
|
|
262
264
|
}
|
|
@@ -264,11 +266,13 @@ function formatChoiceTransitions(stateNode) {
|
|
|
264
266
|
const choice = stateNode.config.choice;
|
|
265
267
|
const validateChoiceResult = result => {
|
|
266
268
|
if (!result || result.target === undefined) {
|
|
267
|
-
throw new Error(`Choice state "${stateNode.id}" must resolve to a target.`);
|
|
269
|
+
throw new Error(`Choice state "${stateNode.id}" must resolve to a target.` );
|
|
268
270
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
271
|
+
{
|
|
272
|
+
for (const key of ['actions', 'to']) {
|
|
273
|
+
if (result[key] !== undefined) {
|
|
274
|
+
throw new Error(`Choice state "${stateNode.id}" cannot declare \`${key}\` on a choice.`);
|
|
275
|
+
}
|
|
272
276
|
}
|
|
273
277
|
}
|
|
274
278
|
return result;
|
|
@@ -290,7 +294,7 @@ function formatTransitions(stateNode) {
|
|
|
290
294
|
if (stateNode.config.on) {
|
|
291
295
|
for (const descriptor of Object.keys(stateNode.config.on)) {
|
|
292
296
|
if (descriptor === dist_xstateActors.NULL_EVENT) {
|
|
293
|
-
throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');
|
|
297
|
+
throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.' );
|
|
294
298
|
}
|
|
295
299
|
const transitionsConfig = stateNode.config.on[descriptor];
|
|
296
300
|
transitions.set(descriptor, mapTransitionConfigs(transitionsConfig, transition => dist_xstateActors.formatTransition(stateNode, descriptor, transition)));
|
|
@@ -300,6 +304,10 @@ function formatTransitions(stateNode) {
|
|
|
300
304
|
const descriptor = `xstate.done.state.${stateNode.id}`;
|
|
301
305
|
transitions.set(descriptor, mapTransitionConfigs(stateNode.config.onDone, transition => dist_xstateActors.formatTransition(stateNode, descriptor, transition)));
|
|
302
306
|
}
|
|
307
|
+
if (stateNode.config.onError) {
|
|
308
|
+
const descriptor = 'xstate.error.*';
|
|
309
|
+
transitions.set(descriptor, mapTransitionConfigs(stateNode.config.onError, transition => dist_xstateActors.formatTransition(stateNode, descriptor, transition)));
|
|
310
|
+
}
|
|
303
311
|
const createCancelInvokeTimeoutTransition = (descriptor, timeoutEventType) => dist_xstateActors.formatTransition(stateNode, descriptor, {
|
|
304
312
|
to: (_args, enq) => {
|
|
305
313
|
enq.cancel(timeoutEventType);
|
|
@@ -386,7 +394,7 @@ function formatInitialTransition(stateNode, _target) {
|
|
|
386
394
|
const input = typeof _target === 'object' && _target !== null ? _target.input : undefined;
|
|
387
395
|
const resolvedTarget = typeof targetString === 'string' ? stateNode.states[targetString] : undefined;
|
|
388
396
|
if (!resolvedTarget && targetString) {
|
|
389
|
-
throw new Error(`Initial state node "${targetString}" not found on parent state node #${stateNode.id}`);
|
|
397
|
+
throw new Error(`Initial state node "${targetString}" not found on parent state node #${stateNode.id}` );
|
|
390
398
|
}
|
|
391
399
|
const transition = {
|
|
392
400
|
source: stateNode,
|
|
@@ -656,11 +664,26 @@ class StateMachine {
|
|
|
656
664
|
const initEvent = dist_xstateActors.createInitEvent(input); // TODO: fix;
|
|
657
665
|
const internalQueue = [];
|
|
658
666
|
const preInitialState = this._getPreInitialState(actorScope, initEvent);
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
667
|
+
let nextState;
|
|
668
|
+
let initialActions = [];
|
|
669
|
+
let microsteps = [];
|
|
670
|
+
let macroState;
|
|
671
|
+
try {
|
|
672
|
+
[nextState, initialActions] = dist_xstateActors.initialMicrostep(this.root, preInitialState, actorScope, initEvent, internalQueue);
|
|
673
|
+
({
|
|
674
|
+
snapshot: macroState,
|
|
675
|
+
microsteps
|
|
676
|
+
} = dist_xstateActors.macrostep(nextState, initEvent, actorScope, internalQueue));
|
|
677
|
+
} catch (err) {
|
|
678
|
+
if (!this.root.config.onError) {
|
|
679
|
+
throw err;
|
|
680
|
+
}
|
|
681
|
+
const errorEvent = dist_xstateActors.createErrorPlatformEvent('execution', err);
|
|
682
|
+
const errorMacrostep = dist_xstateActors.macrostep(preInitialState, errorEvent, actorScope, []);
|
|
683
|
+
macroState = errorMacrostep.snapshot;
|
|
684
|
+
microsteps = errorMacrostep.microsteps;
|
|
685
|
+
initialActions = [];
|
|
686
|
+
}
|
|
664
687
|
return [macroState, [...initialActions, ...microsteps.flatMap(([, actions]) => actions)]];
|
|
665
688
|
}
|
|
666
689
|
start(snapshot) {
|
package/dist/{StateMachine-0fa9c094.development.esm.js → StateMachine-dfe616b4.development.esm.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as ProcessingStatus, G as resolveReferencedActor, d as createActor, S as STATE_DELIMITER, H as mapValues, t as toArray, I as createInvokeId, J as getDelayedTransitions, K as evaluateCandidate, L as formatTransition, N as NULL_EVENT, M as toTransitionConfigArray, O as createInvokeTimeoutEvent, Q as getCandidates, R as formatRouteTransitions, U as resolveStateValue, V as getAllStateNodes, k as getStateNodes, W as createMachineSnapshot, Y as isInFinalState, e as macrostep, Z as cloneMachineSnapshot, _ as transitionNode, m as matchesEventDescriptor, r as resolveActionsWithContext, f as createInitEvent, g as initialMicrostep, $ as toStatePath, a0 as isStateId, a1 as getStateNodeByPath, a2 as getPersistedSnapshot, a3 as $$ACTOR_TYPE } from './index-
|
|
1
|
+
import { P as ProcessingStatus, G as resolveReferencedActor, d as createActor, S as STATE_DELIMITER, H as mapValues, t as toArray, I as createInvokeId, J as getDelayedTransitions, K as evaluateCandidate, L as formatTransition, N as NULL_EVENT, M as toTransitionConfigArray, O as createInvokeTimeoutEvent, Q as getCandidates, R as formatRouteTransitions, U as resolveStateValue, V as getAllStateNodes, k as getStateNodes, W as createMachineSnapshot, Y as isInFinalState, e as macrostep, Z as cloneMachineSnapshot, _ as transitionNode, m as matchesEventDescriptor, r as resolveActionsWithContext, f as createInitEvent, g as initialMicrostep, $ as toStatePath, a0 as isStateId, a1 as getStateNodeByPath, a2 as getPersistedSnapshot, a3 as $$ACTOR_TYPE, a4 as createErrorPlatformEvent } from './index-5d18ec0c.development.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, {
|
|
4
4
|
machine,
|
|
@@ -250,11 +250,13 @@ function validateStateNodeConfig(stateNode) {
|
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
252
|
if (typeof config.choice !== 'function') {
|
|
253
|
-
throw new Error(`Choice state "${stateNode.id}" must declare a \`choice\` function.`);
|
|
253
|
+
throw new Error(`Choice state "${stateNode.id}" must declare a \`choice\` function.` );
|
|
254
254
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
255
|
+
{
|
|
256
|
+
for (const key of CHOICE_CONFIG_KEYS) {
|
|
257
|
+
if (config[key] !== undefined) {
|
|
258
|
+
throw new Error(`Choice state "${stateNode.id}" cannot declare \`${key}\`.`);
|
|
259
|
+
}
|
|
258
260
|
}
|
|
259
261
|
}
|
|
260
262
|
}
|
|
@@ -262,11 +264,13 @@ function formatChoiceTransitions(stateNode) {
|
|
|
262
264
|
const choice = stateNode.config.choice;
|
|
263
265
|
const validateChoiceResult = result => {
|
|
264
266
|
if (!result || result.target === undefined) {
|
|
265
|
-
throw new Error(`Choice state "${stateNode.id}" must resolve to a target.`);
|
|
267
|
+
throw new Error(`Choice state "${stateNode.id}" must resolve to a target.` );
|
|
266
268
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
269
|
+
{
|
|
270
|
+
for (const key of ['actions', 'to']) {
|
|
271
|
+
if (result[key] !== undefined) {
|
|
272
|
+
throw new Error(`Choice state "${stateNode.id}" cannot declare \`${key}\` on a choice.`);
|
|
273
|
+
}
|
|
270
274
|
}
|
|
271
275
|
}
|
|
272
276
|
return result;
|
|
@@ -288,7 +292,7 @@ function formatTransitions(stateNode) {
|
|
|
288
292
|
if (stateNode.config.on) {
|
|
289
293
|
for (const descriptor of Object.keys(stateNode.config.on)) {
|
|
290
294
|
if (descriptor === NULL_EVENT) {
|
|
291
|
-
throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');
|
|
295
|
+
throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.' );
|
|
292
296
|
}
|
|
293
297
|
const transitionsConfig = stateNode.config.on[descriptor];
|
|
294
298
|
transitions.set(descriptor, mapTransitionConfigs(transitionsConfig, transition => formatTransition(stateNode, descriptor, transition)));
|
|
@@ -298,6 +302,10 @@ function formatTransitions(stateNode) {
|
|
|
298
302
|
const descriptor = `xstate.done.state.${stateNode.id}`;
|
|
299
303
|
transitions.set(descriptor, mapTransitionConfigs(stateNode.config.onDone, transition => formatTransition(stateNode, descriptor, transition)));
|
|
300
304
|
}
|
|
305
|
+
if (stateNode.config.onError) {
|
|
306
|
+
const descriptor = 'xstate.error.*';
|
|
307
|
+
transitions.set(descriptor, mapTransitionConfigs(stateNode.config.onError, transition => formatTransition(stateNode, descriptor, transition)));
|
|
308
|
+
}
|
|
301
309
|
const createCancelInvokeTimeoutTransition = (descriptor, timeoutEventType) => formatTransition(stateNode, descriptor, {
|
|
302
310
|
to: (_args, enq) => {
|
|
303
311
|
enq.cancel(timeoutEventType);
|
|
@@ -384,7 +392,7 @@ function formatInitialTransition(stateNode, _target) {
|
|
|
384
392
|
const input = typeof _target === 'object' && _target !== null ? _target.input : undefined;
|
|
385
393
|
const resolvedTarget = typeof targetString === 'string' ? stateNode.states[targetString] : undefined;
|
|
386
394
|
if (!resolvedTarget && targetString) {
|
|
387
|
-
throw new Error(`Initial state node "${targetString}" not found on parent state node #${stateNode.id}`);
|
|
395
|
+
throw new Error(`Initial state node "${targetString}" not found on parent state node #${stateNode.id}` );
|
|
388
396
|
}
|
|
389
397
|
const transition = {
|
|
390
398
|
source: stateNode,
|
|
@@ -654,11 +662,26 @@ class StateMachine {
|
|
|
654
662
|
const initEvent = createInitEvent(input); // TODO: fix;
|
|
655
663
|
const internalQueue = [];
|
|
656
664
|
const preInitialState = this._getPreInitialState(actorScope, initEvent);
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
665
|
+
let nextState;
|
|
666
|
+
let initialActions = [];
|
|
667
|
+
let microsteps = [];
|
|
668
|
+
let macroState;
|
|
669
|
+
try {
|
|
670
|
+
[nextState, initialActions] = initialMicrostep(this.root, preInitialState, actorScope, initEvent, internalQueue);
|
|
671
|
+
({
|
|
672
|
+
snapshot: macroState,
|
|
673
|
+
microsteps
|
|
674
|
+
} = macrostep(nextState, initEvent, actorScope, internalQueue));
|
|
675
|
+
} catch (err) {
|
|
676
|
+
if (!this.root.config.onError) {
|
|
677
|
+
throw err;
|
|
678
|
+
}
|
|
679
|
+
const errorEvent = createErrorPlatformEvent('execution', err);
|
|
680
|
+
const errorMacrostep = macrostep(preInitialState, errorEvent, actorScope, []);
|
|
681
|
+
macroState = errorMacrostep.snapshot;
|
|
682
|
+
microsteps = errorMacrostep.microsteps;
|
|
683
|
+
initialActions = [];
|
|
684
|
+
}
|
|
662
685
|
return [macroState, [...initialActions, ...microsteps.flatMap(([, actions]) => actions)]];
|
|
663
686
|
}
|
|
664
687
|
start(snapshot) {
|
|
@@ -58,6 +58,7 @@ export declare class Actor<TLogic extends AnyActorLogic> implements ActorInstanc
|
|
|
58
58
|
private _deferred;
|
|
59
59
|
private _pendingEffects?;
|
|
60
60
|
private _setErrorSnapshot;
|
|
61
|
+
private _tryHandleExecutionError;
|
|
61
62
|
private _next;
|
|
62
63
|
private update;
|
|
63
64
|
private _flushInitialEffects;
|
|
@@ -145,6 +145,7 @@ export interface StateNodeJSON {
|
|
|
145
145
|
initial?: string;
|
|
146
146
|
states?: Record<string, StateNodeJSON>;
|
|
147
147
|
on?: Record<string, TransitionConfigJSON | TransitionConfigJSON[]>;
|
|
148
|
+
onError?: TransitionConfigJSON | TransitionConfigJSON[];
|
|
148
149
|
after?: Record<string, TransitionConfigJSON | TransitionConfigJSON[]>;
|
|
149
150
|
always?: TransitionConfigJSON | TransitionConfigJSON[];
|
|
150
151
|
choice?: ChoiceBranchJSON[] | ResolvableJSON;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from "./schema.types.js";
|
|
2
2
|
import { StateMachine } from "./StateMachine.js";
|
|
3
3
|
import { type Actor, type RequiredActorOptionsKeys } from "./createActor.js";
|
|
4
|
-
import { AnyActorRef, AnyActorLogic, ActorRefFromLogic, AnyStateNode, EventObject, AnyEventObject, EventDescriptor, ExtractEvent, MachineContext, ProvidedActor, RoutableStateId, StateSchema, StateValue, ToChildren, MetaObject, Cast, Compute, EnqueueObject, SystemRegistry, RegistryKeyForLogic, ActorOptions, Observer, Subscription, OutputArg } from "./types.js";
|
|
4
|
+
import { AnyActorRef, AnyActorLogic, ActorRefFromLogic, AnyStateNode, EventObject, AnyEventObject, EventDescriptor, ExtractEvent, MachineContext, ProvidedActor, RoutableStateId, StateSchema, StateValue, ToChildren, MetaObject, Cast, Compute, EnqueueObject, DoneActorEvent, DoneStateEvent, ErrorActorEvent, SystemRegistry, RegistryKeyForLogic, ActorOptions, Observer, Subscription, OutputArg, SnapshotEvent, SingleOrArray } from "./types.js";
|
|
5
5
|
import { AnyActorSystem } from "./system.js";
|
|
6
6
|
import { InspectionEvent } from "./inspection.js";
|
|
7
|
-
import { ActionSchemas, DelayMapFromNames, GuardSchemas, InferChildren, InferActions, InferGuards, Implementations, InferOutput, InferEvents, Next_MachineConfig, Next_StateNodeConfig, WithDefault } from "./types.v6.js";
|
|
7
|
+
import { ActionSchemas, DelayMapFromNames, GuardSchemas, InferChildren, InferActions, InferGuards, Implementations, InferOutput, InferEvents, Next_MachineConfig, Next_InvokeConfig, Next_StateNodeConfig, Next_TransitionConfigOrTarget, WithDefault } from "./types.v6.js";
|
|
8
8
|
export type SetupConfig<TSchemas extends SetupSchemas, TStates extends Record<string, SetupStateSchema>, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays']> = {
|
|
9
9
|
schemas?: TSchemas & SetupSchemas;
|
|
10
10
|
states?: TStates;
|
|
@@ -185,6 +185,7 @@ type WithNestedStates<TConfig, TNestedStates> = TConfig extends {
|
|
|
185
185
|
} ? TConfig : Omit<TConfig, 'states'> & {
|
|
186
186
|
states?: TNestedStates;
|
|
187
187
|
};
|
|
188
|
+
type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
|
|
188
189
|
/**
|
|
189
190
|
* Converts SetupStateSchema to StateSchema with input types included. This
|
|
190
191
|
* allows getInputs() to be strongly typed.
|
|
@@ -231,7 +232,7 @@ type MergeStateSchema<TConfig extends StateSchema, TSetup extends StateSchema> =
|
|
|
231
232
|
} : undefined : undefined;
|
|
232
233
|
};
|
|
233
234
|
/** Machine config with typed state input */
|
|
234
|
-
type SetupMachineConfig<TStateSchemas extends Record<string, SetupStateSchema>, TSchemas extends SetupSchemas, TContextSchema extends StandardSchemaV1, TEventSchemaMap extends Record<string, StandardSchemaV1>, TEmittedSchemaMap extends Record<string, StandardSchemaV1>, TInputSchema extends StandardSchemaV1, TOutputSchema extends StandardSchemaV1, TMetaSchema extends StandardSchemaV1, TTagSchema extends StandardSchemaV1, TChildrenSchemaMap extends Record<string, StandardSchemaV1>, TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TDelays extends string, TTag extends string, TEmitted extends EventObject, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry, TContextRequired extends boolean, TRootDelays extends string = TDelays, TRootActionMap extends Implementations['actions'] = TActionMap, TRootActorMap extends Implementations['actorSources'] = TActorMap, TRootGuardMap extends Implementations['guards'] = TGuardMap> = Omit<Next_MachineConfig<SetupOrConfigSchema<TSchemas, 'context', TContextSchema>, SetupOrConfigSchemaMap<TSchemas, 'events', TEventSchemaMap>, SetupOrConfigSchemaMap<TSchemas, 'emitted', TEmittedSchemaMap>, SetupOrConfigSchema<TSchemas, 'input', TInputSchema>, SetupOrConfigSchema<TSchemas, 'output', TOutputSchema>, SetupOrConfigSchema<TSchemas, 'meta', TMetaSchema>, SetupOrConfigSchema<TSchemas, 'tags', TTagSchema>, SetupOrConfigSchemaMap<TSchemas, 'children', TChildrenSchemaMap>, TContext, TEvent, TChildren, TDelays, TTag, TActionMap, TActorMap, TGuardMap, TDelayMap, TContextRequired, TSystemRegistry>, 'states' | 'initial' | 'on' | 'always' | 'actions' | 'actorSources' | 'guards' | 'delays'> & {
|
|
235
|
+
type SetupMachineConfig<TStateSchemas extends Record<string, SetupStateSchema>, TSchemas extends SetupSchemas, TContextSchema extends StandardSchemaV1, TEventSchemaMap extends Record<string, StandardSchemaV1>, TEmittedSchemaMap extends Record<string, StandardSchemaV1>, TInputSchema extends StandardSchemaV1, TOutputSchema extends StandardSchemaV1, TMetaSchema extends StandardSchemaV1, TTagSchema extends StandardSchemaV1, TChildrenSchemaMap extends Record<string, StandardSchemaV1>, TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TDelays extends string, TTag extends string, TEmitted extends EventObject, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry, TContextRequired extends boolean, TRootDelays extends string = TDelays, TRootActionMap extends Implementations['actions'] = TActionMap, TRootActorMap extends Implementations['actorSources'] = TActorMap, TRootGuardMap extends Implementations['guards'] = TGuardMap> = Omit<Next_MachineConfig<SetupOrConfigSchema<TSchemas, 'context', TContextSchema>, SetupOrConfigSchemaMap<TSchemas, 'events', TEventSchemaMap>, SetupOrConfigSchemaMap<TSchemas, 'emitted', TEmittedSchemaMap>, SetupOrConfigSchema<TSchemas, 'input', TInputSchema>, SetupOrConfigSchema<TSchemas, 'output', TOutputSchema>, SetupOrConfigSchema<TSchemas, 'meta', TMetaSchema>, SetupOrConfigSchema<TSchemas, 'tags', TTagSchema>, SetupOrConfigSchemaMap<TSchemas, 'children', TChildrenSchemaMap>, TContext, TEvent, TChildren, TDelays, TTag, TActionMap, TActorMap, TGuardMap, TDelayMap, TContextRequired, TSystemRegistry>, 'states' | 'initial' | 'on' | 'always' | 'invoke' | 'actions' | 'actorSources' | 'guards' | 'delays'> & {
|
|
235
236
|
actions?: TRootActionMap;
|
|
236
237
|
actorSources?: TRootActorMap;
|
|
237
238
|
guards?: TRootGuardMap;
|
|
@@ -245,6 +246,7 @@ type SetupMachineConfig<TStateSchemas extends Record<string, SetupStateSchema>,
|
|
|
245
246
|
initial?: SetupStateKey<TStateSchemas> | InitialTransitionWithInput<TStateSchemas, TContext, TEvent> | undefined;
|
|
246
247
|
on?: StateTransitions<TStateSchemas, TContext, SetupContextShape<TSchemas, TContextSchema, TContext>, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
247
248
|
always?: StateTransitionConfigOrTarget<TStateSchemas, TContext, SetupContextShape<TSchemas, TContextSchema, TContext>, TEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
249
|
+
invoke?: SingleOrArray<SetupInvokeConfig<TStateSchemas, TContext, SetupContextShape<TSchemas, TContextSchema, TContext>, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>>;
|
|
248
250
|
states?: StatesWithInput<TStateSchemas, TStateSchemas, TContext, SetupContextShape<TSchemas, TContextSchema, TContext>, TEvent, TChildren, TDelays, TTag, SetupOutput<TSchemas, TOutputSchema>, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
249
251
|
};
|
|
250
252
|
/** States config type that provides typed input for known states */
|
|
@@ -252,19 +254,30 @@ type StatesWithInput<TRootStateSchemas extends Record<string, SetupStateSchema>,
|
|
|
252
254
|
[K in keyof TStateSchemas & string]?: StateNodeConfigWithNestedInput<TRootStateSchemas, TStateSchemas[K], TContext, TContextShape, TEvent, TChildren, TDelays, TTag, TOutput, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
253
255
|
};
|
|
254
256
|
/** State node config that recursively applies typed input for nested states */
|
|
255
|
-
type StateNodeConfigWithNestedInput<TSiblingStateSchemas extends Record<string, SetupStateSchema>, TStateSchema extends SetupStateSchema, TContext extends MachineContext, TContextShape, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TDelays extends string, TTag extends string, TOutput, TEmitted extends EventObject, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry> = WithNestedStates<Omit<Next_StateNodeConfig<StateContext<TStateSchema, TContext>, TEvent, TDelays, TTag, TOutput, TEmitted, TMeta, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, StateInput<TStateSchema>, Record<string, unknown>, TSystemRegistry>, 'on' | 'always' | 'initial'> & {
|
|
257
|
+
type StateNodeConfigWithNestedInput<TSiblingStateSchemas extends Record<string, SetupStateSchema>, TStateSchema extends SetupStateSchema, TContext extends MachineContext, TContextShape, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TDelays extends string, TTag extends string, TOutput, TEmitted extends EventObject, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry> = WithNestedStates<Omit<Next_StateNodeConfig<StateContext<TStateSchema, TContext>, TEvent, TDelays, TTag, TOutput, TEmitted, TMeta, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, StateInput<TStateSchema>, Record<string, unknown>, TSystemRegistry>, 'on' | 'always' | 'initial' | 'invoke' | 'onDone'> & {
|
|
256
258
|
initial?: TStateSchema['states'] extends Record<string, SetupStateSchema> ? SetupStateKey<TStateSchema['states']> | InitialTransitionWithInput<TStateSchema['states'], StateContext<TStateSchema, TContext>, TEvent> : string | {
|
|
257
259
|
target: string;
|
|
258
260
|
input?: Record<string, unknown>;
|
|
259
261
|
} | undefined;
|
|
260
262
|
on?: StateTransitions<TSiblingStateSchemas, StateContext<TStateSchema, TContext>, StateContextShape<TStateSchema, TContextShape>, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
261
263
|
always?: StateTransitionConfigOrTarget<TSiblingStateSchemas, StateContext<TStateSchema, TContext>, StateContextShape<TStateSchema, TContextShape>, TEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
264
|
+
invoke?: SingleOrArray<SetupInvokeConfig<TSiblingStateSchemas, StateContext<TStateSchema, TContext>, StateContextShape<TStateSchema, TContextShape>, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>>;
|
|
265
|
+
onDone?: StateTransitionConfigOrTarget<TSiblingStateSchemas, StateContext<TStateSchema, TContext>, StateContextShape<TStateSchema, TContextShape>, DoneStateEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
262
266
|
}, TStateSchema['states'] extends Record<string, SetupStateSchema> ? StatesWithInput<TStateSchema['states'], TStateSchema['states'], TContext, StateContextShape<TStateSchema, TContextShape>, TEvent, TChildren, TDelays, TTag, TOutput, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry> : {
|
|
263
267
|
[K in string]?: Next_StateNodeConfig<TContext, TEvent, TDelays, TTag, TOutput, TEmitted, TMeta, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, undefined, Record<string, unknown>, TSystemRegistry>;
|
|
264
268
|
}>;
|
|
265
269
|
type StateTransitions<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TContextShape, TEvent extends EventObject, TEmitted extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry> = {
|
|
266
270
|
[K in EventDescriptor<TEvent>]?: StateTransitionConfigOrTarget<TStateSchemas, TContext, TContextShape, ExtractEvent<TEvent, K>, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
267
271
|
};
|
|
272
|
+
type InvokeDoneEvent<TInvoke> = TInvoke extends {
|
|
273
|
+
onDone?: Next_TransitionConfigOrTarget<infer _TContext, infer TDoneEvent, infer _TEvent, infer _TEmitted, infer _TActionMap, infer _TActorMap, infer _TGuardMap, infer _TDelayMap, infer _TMeta>;
|
|
274
|
+
} ? Cast<TDoneEvent, EventObject> : DoneActorEvent;
|
|
275
|
+
type SetupInvokeConfig<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TContextShape, TEvent extends EventObject, TEmitted extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry> = Next_InvokeConfig<TContext, TEvent, TEmitted, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta, TSystemRegistry> extends infer TInvoke ? TInvoke extends any ? DistributiveOmit<TInvoke, 'onDone' | 'onError' | 'onSnapshot' | 'onTimeout'> & {
|
|
276
|
+
onDone?: StateTransitionConfigOrTarget<TStateSchemas, TContext, TContextShape, InvokeDoneEvent<TInvoke>, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
277
|
+
onError?: StateTransitionConfigOrTarget<TStateSchemas, TContext, TContextShape, ErrorActorEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
278
|
+
onSnapshot?: StateTransitionConfigOrTarget<TStateSchemas, TContext, TContextShape, SnapshotEvent<any>, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
279
|
+
onTimeout?: StateTransitionConfigOrTarget<TStateSchemas, TContext, TContextShape, TEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
280
|
+
} : never : never;
|
|
268
281
|
type StateTransitionConfigOrTarget<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TContextShape, TExpressionEvent extends EventObject, TEvent extends EventObject, TEmitted extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry> = undefined | StateTransitionObjectConfig<TStateSchemas, TContext, TContextShape, TExpressionEvent, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry> | StateTransitionFunction<TStateSchemas, TContext, TContextShape, TExpressionEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
269
282
|
type StateTransitionObjectConfig<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TContextShape, TExpressionEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry> = (StateTransitionResult<TStateSchemas, TContext, TContextShape, TMeta, TExpressionEvent, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry, true> & {
|
|
270
283
|
description?: string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { AnyAction, AnyActorScope, AnyEventObject, AnyMachineSnapshot, EnqueueObject, EventObject, ExecutableActionObject, SpecialExecutableAction } from "./types.js";
|
|
1
|
+
import type { AnyAction, AnyActorScope, AnyEventObject, AnyMachineSnapshot, EnqueueObject, EventObject, ExecutableActionObject, MachineContext, SpecialExecutableAction } from "./types.js";
|
|
2
|
+
export declare function mergeContextPatch(context: MachineContext, patch: MachineContext): MachineContext;
|
|
2
3
|
export declare function createTransitionEnqueue(actorScope: AnyActorScope, actions: any[], internalEvents: EventObject[], actorSubscriptions?: boolean, createActors?: boolean): EnqueueObject<any, any>;
|
|
3
4
|
export declare function isBuiltInExecutableAction(action: ExecutableActionObject): action is SpecialExecutableAction;
|
|
4
5
|
export declare function resolveActionsWithContext(currentSnapshot: AnyMachineSnapshot, event: AnyEventObject, actorScope: AnyActorScope, actions: AnyAction[]): [AnyMachineSnapshot, ExecutableActionObject[]];
|
|
6
|
+
export declare function createEnqueueObject(props: Partial<EnqueueObject<any, any>>, action: <T extends (...args: any[]) => any>(fn: T, ...args: Parameters<T>) => void): EnqueueObject<any, any>;
|