xstate 6.0.0-alpha.20 → 6.0.0-alpha.21
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-f2b70732.cjs.js → StateMachine-1b155670.cjs.js} +1 -1
- package/dist/{StateMachine-42f1d26c.esm.js → StateMachine-3c17fe3e.esm.js} +1 -1
- package/dist/{StateMachine-6661eb0d.development.cjs.js → StateMachine-550ff7f2.development.cjs.js} +1 -1
- package/dist/{StateMachine-ba3ccedf.development.esm.js → StateMachine-e25dd61f.development.esm.js} +1 -1
- package/dist/declarations/src/setup.d.ts +19 -27
- package/dist/declarations/src/types.v6.d.ts +5 -2
- package/dist/declarations/src/utils.d.ts +1 -1
- package/dist/{index-d88b0c55.esm.js → index-3f87408c.esm.js} +20 -27
- package/dist/{index-dc3443b6.development.esm.js → index-d39fb138.development.esm.js} +20 -27
- package/dist/{index-42956779.cjs.js → index-e694228c.cjs.js} +20 -27
- package/dist/{index-49293864.development.cjs.js → index-ec7c7a2d.development.cjs.js} +20 -27
- 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.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 +2 -2
- package/dist/xstate.development.cjs.js +2 -2
- package/dist/xstate.development.esm.js +4 -4
- package/dist/xstate.esm.js +4 -4
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -351,6 +351,13 @@ function createSubscriptionLogic() {
|
|
|
351
351
|
// Singleton logic instance
|
|
352
352
|
const subscriptionLogic = /* #__PURE__ */createSubscriptionLogic();
|
|
353
353
|
|
|
354
|
+
const builtInExecutableAction = Symbol('xstate.builtInExecutableAction');
|
|
355
|
+
function brandBuiltInExecutableAction(action) {
|
|
356
|
+
Object.defineProperty(action, builtInExecutableAction, {
|
|
357
|
+
value: true
|
|
358
|
+
});
|
|
359
|
+
return action;
|
|
360
|
+
}
|
|
354
361
|
function mergeContextPatch(context, patch) {
|
|
355
362
|
return {
|
|
356
363
|
...context,
|
|
@@ -537,7 +544,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
537
544
|
function createStartEffect(actor) {
|
|
538
545
|
const action = builtInActions['@xstate.start'];
|
|
539
546
|
const args = [actor];
|
|
540
|
-
return {
|
|
547
|
+
return brandBuiltInExecutableAction({
|
|
541
548
|
type: XSTATE_START,
|
|
542
549
|
params: {
|
|
543
550
|
action,
|
|
@@ -547,7 +554,7 @@ function createStartEffect(actor) {
|
|
|
547
554
|
exec: action.bind(null, actor),
|
|
548
555
|
actor,
|
|
549
556
|
id: actor.id
|
|
550
|
-
};
|
|
557
|
+
});
|
|
551
558
|
}
|
|
552
559
|
|
|
553
560
|
/**
|
|
@@ -576,23 +583,7 @@ function deriveDeferredStarts(effects) {
|
|
|
576
583
|
return [...attachedStarts, ...childStarts];
|
|
577
584
|
}
|
|
578
585
|
function isBuiltInExecutableAction(action) {
|
|
579
|
-
|
|
580
|
-
return false;
|
|
581
|
-
}
|
|
582
|
-
switch (action.type) {
|
|
583
|
-
case '@xstate.spawn':
|
|
584
|
-
return 'actor' in action && 'logic' in action && 'src' in action && 'input' in action;
|
|
585
|
-
case '@xstate.start':
|
|
586
|
-
case '@xstate.stop':
|
|
587
|
-
return 'actor' in action;
|
|
588
|
-
case '@xstate.raise':
|
|
589
|
-
case '@xstate.sendTo':
|
|
590
|
-
return 'event' in action;
|
|
591
|
-
case '@xstate.cancel':
|
|
592
|
-
return 'id' in action;
|
|
593
|
-
default:
|
|
594
|
-
return false;
|
|
595
|
-
}
|
|
586
|
+
return action[builtInExecutableAction] === true;
|
|
596
587
|
}
|
|
597
588
|
function resolveActionsWithContext(currentSnapshot, event, actorScope, actions) {
|
|
598
589
|
let intermediateSnapshot = currentSnapshot;
|
|
@@ -646,13 +637,14 @@ function resolveActionsWithContext(currentSnapshot, event, actorScope, actions)
|
|
|
646
637
|
}
|
|
647
638
|
if (!resolvedAction || !('resolve' in resolvedAction)) {
|
|
648
639
|
const builtInFields = typeof action === 'object' && action !== null && 'action' in action && typeof action.action === 'function' ? getBuiltInActionFields(action.action, action.args) : undefined;
|
|
649
|
-
|
|
640
|
+
const executableAction = {
|
|
650
641
|
type: typeof action === 'object' ? 'action' in action && typeof action.action === 'function' ? action.action.name ?? '(anonymous)' : action.type : action.name || '(anonymous)',
|
|
651
642
|
params: actionParams,
|
|
652
643
|
args: typeof action === 'object' && 'action' in action ? action.args : [],
|
|
653
644
|
exec: resolvedAction || (typeof action === 'object' && action !== null ? () => actorScope.defer(() => actorScope.emit(action)) : undefined),
|
|
654
645
|
...builtInFields
|
|
655
|
-
}
|
|
646
|
+
};
|
|
647
|
+
executableActions.push(builtInFields ? brandBuiltInExecutableAction(executableAction) : executableAction);
|
|
656
648
|
continue;
|
|
657
649
|
}
|
|
658
650
|
}
|
|
@@ -1518,7 +1510,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
1518
1510
|
let completionOutput;
|
|
1519
1511
|
if (rootCompletionNode.output !== undefined && rootCompletionNode.parent) {
|
|
1520
1512
|
const rootDoneEvent = internalQueue.find(e => e.type === `xstate.done.state.${rootNode.id}`);
|
|
1521
|
-
completionOutput = rootDoneEvent && rootCompletionNode.parent === rootNode ? rootDoneEvent.output : resolveOutput(rootCompletionNode.output, nextState.context, event, actorScope.self);
|
|
1513
|
+
completionOutput = rootDoneEvent && rootCompletionNode.parent === rootNode ? rootDoneEvent.output : resolveOutput(rootCompletionNode.output, nextState.context, event, actorScope.self, stateInputMap[rootCompletionNode.id]);
|
|
1522
1514
|
} else if (rootCompletionNode.type === 'parallel') {
|
|
1523
1515
|
const parallelDoneType = `xstate.done.state.${rootCompletionNode.id}`;
|
|
1524
1516
|
const parallelDoneEvent = internalQueue.find(e => e.type === parallelDoneType);
|
|
@@ -1740,14 +1732,14 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
1740
1732
|
let ancestorMarker = parent?.type === 'parallel' ? parent : parent?.parent;
|
|
1741
1733
|
let rootCompletionNode = ancestorMarker || stateNodeToEnter;
|
|
1742
1734
|
if (parent?.type === 'compound') {
|
|
1743
|
-
internalQueue.push(createDoneStateEvent(parent.id, stateNodeToEnter.output !== undefined ? resolveOutput(stateNodeToEnter.output, nextState.context, event, actorScope.self) : undefined));
|
|
1735
|
+
internalQueue.push(createDoneStateEvent(parent.id, stateNodeToEnter.output !== undefined ? resolveOutput(stateNodeToEnter.output, nextState.context, event, actorScope.self, stateInput) : undefined));
|
|
1744
1736
|
}
|
|
1745
1737
|
while (ancestorMarker?.type === 'parallel' && !completedNodes.has(ancestorMarker) && isInFinalState(mutStateNodeSet, ancestorMarker)) {
|
|
1746
1738
|
completedNodes.add(ancestorMarker);
|
|
1747
1739
|
const regionOutput = {};
|
|
1748
1740
|
for (const region of getChildren(ancestorMarker)) {
|
|
1749
1741
|
if (region.type === 'final') {
|
|
1750
|
-
regionOutput[region.key] = region.output !== undefined ? resolveOutput(region.output, nextState.context, event, actorScope.self) : undefined;
|
|
1742
|
+
regionOutput[region.key] = region.output !== undefined ? resolveOutput(region.output, nextState.context, event, actorScope.self, stateInputMap[region.id]) : undefined;
|
|
1751
1743
|
continue;
|
|
1752
1744
|
}
|
|
1753
1745
|
if (region.type === 'parallel') {
|
|
@@ -1757,7 +1749,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
1757
1749
|
continue;
|
|
1758
1750
|
}
|
|
1759
1751
|
const finalChild = getChildren(region).find(s => s.type === 'final' && mutStateNodeSet.has(s));
|
|
1760
|
-
regionOutput[region.key] = finalChild?.output !== undefined ? resolveOutput(finalChild.output, nextState.context, event, actorScope.self) : undefined;
|
|
1752
|
+
regionOutput[region.key] = finalChild?.output !== undefined ? resolveOutput(finalChild.output, nextState.context, event, actorScope.self, stateInputMap[finalChild.id]) : undefined;
|
|
1761
1753
|
}
|
|
1762
1754
|
internalQueue.push(createDoneStateEvent(ancestorMarker.id, regionOutput));
|
|
1763
1755
|
rootCompletionNode = ancestorMarker;
|
|
@@ -2377,14 +2369,15 @@ function toArray(value) {
|
|
|
2377
2369
|
}
|
|
2378
2370
|
return toArrayStrict(value);
|
|
2379
2371
|
}
|
|
2380
|
-
function resolveOutput(mapper, context, event, self) {
|
|
2372
|
+
function resolveOutput(mapper, context, event, self, input) {
|
|
2381
2373
|
if (typeof mapper === 'function') {
|
|
2382
2374
|
const outputMapper = mapper;
|
|
2383
2375
|
const args = {
|
|
2384
2376
|
context,
|
|
2385
2377
|
event,
|
|
2386
2378
|
output: getEventOutput(event),
|
|
2387
|
-
self
|
|
2379
|
+
self,
|
|
2380
|
+
input
|
|
2388
2381
|
};
|
|
2389
2382
|
return outputMapper(args);
|
|
2390
2383
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { T as TimeoutError, C as createAsyncLogic, x as createCallbackLogic, w as createEmptyActor, z as createEventObservableLogic, D as createListenerLogic, B as createLogic, y as createObservableLogic, F as createSubscriptionLogic, E as listenerLogic, G as subscriptionLogic } from './index-
|
|
1
|
+
export { T as TimeoutError, C as createAsyncLogic, x as createCallbackLogic, w as createEmptyActor, z as createEventObservableLogic, D as createListenerLogic, B as createLogic, y as createObservableLogic, F as createSubscriptionLogic, E as listenerLogic, G as subscriptionLogic } from './index-d39fb138.development.esm.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { T as TimeoutError, C as createAsyncLogic, x as createCallbackLogic, w as createEmptyActor, z as createEventObservableLogic, D as createListenerLogic, B as createLogic, y as createObservableLogic, F as createSubscriptionLogic, E as listenerLogic, G as subscriptionLogic } from './index-
|
|
1
|
+
export { T as TimeoutError, C as createAsyncLogic, x as createCallbackLogic, w as createEmptyActor, z as createEventObservableLogic, D as createListenerLogic, B as createLogic, y as createObservableLogic, F as createSubscriptionLogic, E as listenerLogic, G as subscriptionLogic } from './index-3f87408c.esm.js';
|