xstate 6.0.0-alpha.3 → 6.0.0-alpha.4
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-e1048cd6.cjs.js → StateMachine-445a8480.cjs.js} +15 -6
- package/dist/{StateMachine-e6ad61d0.development.esm.js → StateMachine-4deb4090.development.esm.js} +15 -6
- package/dist/{StateMachine-8249d511.esm.js → StateMachine-f310bc72.esm.js} +15 -6
- package/dist/{StateMachine-0770ac71.development.cjs.js → StateMachine-f83f01f9.development.cjs.js} +15 -6
- package/dist/declarations/src/StateMachine.d.ts +5 -4
- package/dist/declarations/src/actions.d.ts +1 -1
- package/dist/declarations/src/createActor.d.ts +3 -0
- package/dist/declarations/src/createMachine.d.ts +10 -7
- package/dist/declarations/src/graph/graph.d.ts +3 -3
- package/dist/declarations/src/graph/shortestPaths.d.ts +2 -2
- package/dist/declarations/src/graph/simplePaths.d.ts +2 -2
- package/dist/declarations/src/index.d.ts +1 -0
- package/dist/declarations/src/setup.d.ts +79 -33
- package/dist/declarations/src/transition.d.ts +8 -5
- package/dist/declarations/src/transitionActions.d.ts +4 -0
- package/dist/declarations/src/types.d.ts +69 -17
- package/dist/declarations/src/types.v6.d.ts +39 -21
- package/dist/{index-dda021d5.cjs.js → index-918ab496.cjs.js} +235 -127
- package/dist/{index-a7e3d8b3.esm.js → index-9cce3480.esm.js} +234 -127
- package/dist/{index-66ff64a6.development.esm.js → index-ccbe7c0b.development.esm.js} +234 -127
- package/dist/{index-269d256d.development.cjs.js → index-ebaf6fd8.development.cjs.js} +235 -127
- 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 +67 -23
- package/dist/xstate.cjs.mjs +1 -0
- package/dist/xstate.development.cjs.js +67 -23
- package/dist/xstate.development.cjs.mjs +1 -0
- package/dist/xstate.development.esm.js +68 -25
- package/dist/xstate.esm.js +68 -25
- 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-918ab496.cjs.js');
|
|
4
4
|
|
|
5
5
|
function createSpawner(actorScope, {
|
|
6
6
|
machine,
|
|
@@ -438,6 +438,7 @@ class StateMachine {
|
|
|
438
438
|
...this.config.options
|
|
439
439
|
};
|
|
440
440
|
this.transition = this.transition.bind(this);
|
|
441
|
+
this.initialTransition = this.initialTransition.bind(this);
|
|
441
442
|
this.getInitialSnapshot = this.getInitialSnapshot.bind(this);
|
|
442
443
|
this.getPersistedSnapshot = this.getPersistedSnapshot.bind(this);
|
|
443
444
|
this.restoreSnapshot = this.restoreSnapshot.bind(this);
|
|
@@ -513,7 +514,11 @@ class StateMachine {
|
|
|
513
514
|
* @param event The received event
|
|
514
515
|
*/
|
|
515
516
|
transition(snapshot, event, actorScope) {
|
|
516
|
-
|
|
517
|
+
const {
|
|
518
|
+
snapshot: nextSnapshot,
|
|
519
|
+
microsteps
|
|
520
|
+
} = dist_xstateActors.macrostep(snapshot, event, actorScope, []);
|
|
521
|
+
return [nextSnapshot, microsteps.flatMap(([, actions]) => actions)];
|
|
517
522
|
}
|
|
518
523
|
|
|
519
524
|
/**
|
|
@@ -570,7 +575,7 @@ class StateMachine {
|
|
|
570
575
|
self: actorScope.self,
|
|
571
576
|
actors: this.implementations.actors
|
|
572
577
|
});
|
|
573
|
-
const nextState = dist_xstateActors.
|
|
578
|
+
const [nextState] = dist_xstateActors.resolveActionsWithContext(preInitial, initEvent, actorScope, []);
|
|
574
579
|
if (resolvedContext) {
|
|
575
580
|
nextState.context = resolvedContext;
|
|
576
581
|
}
|
|
@@ -590,14 +595,18 @@ class StateMachine {
|
|
|
590
595
|
* `ActorRef`.
|
|
591
596
|
*/
|
|
592
597
|
getInitialSnapshot(actorScope, input) {
|
|
598
|
+
return this.initialTransition(input, actorScope)[0];
|
|
599
|
+
}
|
|
600
|
+
initialTransition(input, actorScope) {
|
|
593
601
|
const initEvent = dist_xstateActors.createInitEvent(input); // TODO: fix;
|
|
594
602
|
const internalQueue = [];
|
|
595
603
|
const preInitialState = this._getPreInitialState(actorScope, initEvent);
|
|
596
|
-
const [nextState] = dist_xstateActors.initialMicrostep(this.root, preInitialState, actorScope, initEvent, internalQueue);
|
|
604
|
+
const [nextState, initialActions] = dist_xstateActors.initialMicrostep(this.root, preInitialState, actorScope, initEvent, internalQueue);
|
|
597
605
|
const {
|
|
598
|
-
snapshot: macroState
|
|
606
|
+
snapshot: macroState,
|
|
607
|
+
microsteps
|
|
599
608
|
} = dist_xstateActors.macrostep(nextState, initEvent, actorScope, internalQueue);
|
|
600
|
-
return macroState;
|
|
609
|
+
return [macroState, [...initialActions, ...microsteps.flatMap(([, actions]) => actions)]];
|
|
601
610
|
}
|
|
602
611
|
start(snapshot) {
|
|
603
612
|
// Start rehydrated children that were active when persisted. Freshly
|
package/dist/{StateMachine-e6ad61d0.development.esm.js → StateMachine-4deb4090.development.esm.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as ProcessingStatus,
|
|
1
|
+
import { P as ProcessingStatus, C as resolveReferencedActor, c as createActor, S as STATE_DELIMITER, D as mapValues, t as toArray, E as createInvokeId, F as getDelayedTransitions, G as evaluateCandidate, H as formatTransition, N as NULL_EVENT, I as toTransitionConfigArray, J as createInvokeTimeoutEvent, K as getCandidates, L as formatRouteTransitions, M as resolveStateValue, O as getAllStateNodes, f as getStateNodes, Q as createMachineSnapshot, R as isInFinalState, a as macrostep, U as transitionNode, m as matchesEventDescriptor, V as resolveActionsWithContext, b as createInitEvent, d as initialMicrostep, W as toStatePath, X as isStateId, Y as getStateNodeByPath, Z as getPersistedSnapshot, $ as $$ACTOR_TYPE } from './index-ccbe7c0b.development.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, {
|
|
4
4
|
machine,
|
|
@@ -447,6 +447,7 @@ class StateMachine {
|
|
|
447
447
|
...this.config.options
|
|
448
448
|
};
|
|
449
449
|
this.transition = this.transition.bind(this);
|
|
450
|
+
this.initialTransition = this.initialTransition.bind(this);
|
|
450
451
|
this.getInitialSnapshot = this.getInitialSnapshot.bind(this);
|
|
451
452
|
this.getPersistedSnapshot = this.getPersistedSnapshot.bind(this);
|
|
452
453
|
this.restoreSnapshot = this.restoreSnapshot.bind(this);
|
|
@@ -525,7 +526,11 @@ class StateMachine {
|
|
|
525
526
|
* @param event The received event
|
|
526
527
|
*/
|
|
527
528
|
transition(snapshot, event, actorScope) {
|
|
528
|
-
|
|
529
|
+
const {
|
|
530
|
+
snapshot: nextSnapshot,
|
|
531
|
+
microsteps
|
|
532
|
+
} = macrostep(snapshot, event, actorScope, []);
|
|
533
|
+
return [nextSnapshot, microsteps.flatMap(([, actions]) => actions)];
|
|
529
534
|
}
|
|
530
535
|
|
|
531
536
|
/**
|
|
@@ -582,7 +587,7 @@ class StateMachine {
|
|
|
582
587
|
self: actorScope.self,
|
|
583
588
|
actors: this.implementations.actors
|
|
584
589
|
});
|
|
585
|
-
const nextState =
|
|
590
|
+
const [nextState] = resolveActionsWithContext(preInitial, initEvent, actorScope, []);
|
|
586
591
|
if (resolvedContext) {
|
|
587
592
|
nextState.context = resolvedContext;
|
|
588
593
|
}
|
|
@@ -602,14 +607,18 @@ class StateMachine {
|
|
|
602
607
|
* `ActorRef`.
|
|
603
608
|
*/
|
|
604
609
|
getInitialSnapshot(actorScope, input) {
|
|
610
|
+
return this.initialTransition(input, actorScope)[0];
|
|
611
|
+
}
|
|
612
|
+
initialTransition(input, actorScope) {
|
|
605
613
|
const initEvent = createInitEvent(input); // TODO: fix;
|
|
606
614
|
const internalQueue = [];
|
|
607
615
|
const preInitialState = this._getPreInitialState(actorScope, initEvent);
|
|
608
|
-
const [nextState] = initialMicrostep(this.root, preInitialState, actorScope, initEvent, internalQueue);
|
|
616
|
+
const [nextState, initialActions] = initialMicrostep(this.root, preInitialState, actorScope, initEvent, internalQueue);
|
|
609
617
|
const {
|
|
610
|
-
snapshot: macroState
|
|
618
|
+
snapshot: macroState,
|
|
619
|
+
microsteps
|
|
611
620
|
} = macrostep(nextState, initEvent, actorScope, internalQueue);
|
|
612
|
-
return macroState;
|
|
621
|
+
return [macroState, [...initialActions, ...microsteps.flatMap(([, actions]) => actions)]];
|
|
613
622
|
}
|
|
614
623
|
start(snapshot) {
|
|
615
624
|
// Start rehydrated children that were active when persisted. Freshly
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as ProcessingStatus,
|
|
1
|
+
import { P as ProcessingStatus, C as resolveReferencedActor, c as createActor, S as STATE_DELIMITER, D as mapValues, t as toArray, E as createInvokeId, F as getDelayedTransitions, G as evaluateCandidate, H as formatTransition, N as NULL_EVENT, I as toTransitionConfigArray, J as createInvokeTimeoutEvent, K as getCandidates, L as formatRouteTransitions, M as resolveStateValue, O as getAllStateNodes, f as getStateNodes, Q as createMachineSnapshot, R as isInFinalState, a as macrostep, U as transitionNode, m as matchesEventDescriptor, V as resolveActionsWithContext, b as createInitEvent, d as initialMicrostep, W as toStatePath, X as isStateId, Y as getStateNodeByPath, Z as getPersistedSnapshot, $ as $$ACTOR_TYPE } from './index-9cce3480.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, {
|
|
4
4
|
machine,
|
|
@@ -436,6 +436,7 @@ class StateMachine {
|
|
|
436
436
|
...this.config.options
|
|
437
437
|
};
|
|
438
438
|
this.transition = this.transition.bind(this);
|
|
439
|
+
this.initialTransition = this.initialTransition.bind(this);
|
|
439
440
|
this.getInitialSnapshot = this.getInitialSnapshot.bind(this);
|
|
440
441
|
this.getPersistedSnapshot = this.getPersistedSnapshot.bind(this);
|
|
441
442
|
this.restoreSnapshot = this.restoreSnapshot.bind(this);
|
|
@@ -511,7 +512,11 @@ class StateMachine {
|
|
|
511
512
|
* @param event The received event
|
|
512
513
|
*/
|
|
513
514
|
transition(snapshot, event, actorScope) {
|
|
514
|
-
|
|
515
|
+
const {
|
|
516
|
+
snapshot: nextSnapshot,
|
|
517
|
+
microsteps
|
|
518
|
+
} = macrostep(snapshot, event, actorScope, []);
|
|
519
|
+
return [nextSnapshot, microsteps.flatMap(([, actions]) => actions)];
|
|
515
520
|
}
|
|
516
521
|
|
|
517
522
|
/**
|
|
@@ -568,7 +573,7 @@ class StateMachine {
|
|
|
568
573
|
self: actorScope.self,
|
|
569
574
|
actors: this.implementations.actors
|
|
570
575
|
});
|
|
571
|
-
const nextState =
|
|
576
|
+
const [nextState] = resolveActionsWithContext(preInitial, initEvent, actorScope, []);
|
|
572
577
|
if (resolvedContext) {
|
|
573
578
|
nextState.context = resolvedContext;
|
|
574
579
|
}
|
|
@@ -588,14 +593,18 @@ class StateMachine {
|
|
|
588
593
|
* `ActorRef`.
|
|
589
594
|
*/
|
|
590
595
|
getInitialSnapshot(actorScope, input) {
|
|
596
|
+
return this.initialTransition(input, actorScope)[0];
|
|
597
|
+
}
|
|
598
|
+
initialTransition(input, actorScope) {
|
|
591
599
|
const initEvent = createInitEvent(input); // TODO: fix;
|
|
592
600
|
const internalQueue = [];
|
|
593
601
|
const preInitialState = this._getPreInitialState(actorScope, initEvent);
|
|
594
|
-
const [nextState] = initialMicrostep(this.root, preInitialState, actorScope, initEvent, internalQueue);
|
|
602
|
+
const [nextState, initialActions] = initialMicrostep(this.root, preInitialState, actorScope, initEvent, internalQueue);
|
|
595
603
|
const {
|
|
596
|
-
snapshot: macroState
|
|
604
|
+
snapshot: macroState,
|
|
605
|
+
microsteps
|
|
597
606
|
} = macrostep(nextState, initEvent, actorScope, internalQueue);
|
|
598
|
-
return macroState;
|
|
607
|
+
return [macroState, [...initialActions, ...microsteps.flatMap(([, actions]) => actions)]];
|
|
599
608
|
}
|
|
600
609
|
start(snapshot) {
|
|
601
610
|
// Start rehydrated children that were active when persisted. Freshly
|
package/dist/{StateMachine-0770ac71.development.cjs.js → StateMachine-f83f01f9.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-ebaf6fd8.development.cjs.js');
|
|
4
4
|
|
|
5
5
|
function createSpawner(actorScope, {
|
|
6
6
|
machine,
|
|
@@ -449,6 +449,7 @@ class StateMachine {
|
|
|
449
449
|
...this.config.options
|
|
450
450
|
};
|
|
451
451
|
this.transition = this.transition.bind(this);
|
|
452
|
+
this.initialTransition = this.initialTransition.bind(this);
|
|
452
453
|
this.getInitialSnapshot = this.getInitialSnapshot.bind(this);
|
|
453
454
|
this.getPersistedSnapshot = this.getPersistedSnapshot.bind(this);
|
|
454
455
|
this.restoreSnapshot = this.restoreSnapshot.bind(this);
|
|
@@ -527,7 +528,11 @@ class StateMachine {
|
|
|
527
528
|
* @param event The received event
|
|
528
529
|
*/
|
|
529
530
|
transition(snapshot, event, actorScope) {
|
|
530
|
-
|
|
531
|
+
const {
|
|
532
|
+
snapshot: nextSnapshot,
|
|
533
|
+
microsteps
|
|
534
|
+
} = dist_xstateActors.macrostep(snapshot, event, actorScope, []);
|
|
535
|
+
return [nextSnapshot, microsteps.flatMap(([, actions]) => actions)];
|
|
531
536
|
}
|
|
532
537
|
|
|
533
538
|
/**
|
|
@@ -584,7 +589,7 @@ class StateMachine {
|
|
|
584
589
|
self: actorScope.self,
|
|
585
590
|
actors: this.implementations.actors
|
|
586
591
|
});
|
|
587
|
-
const nextState = dist_xstateActors.
|
|
592
|
+
const [nextState] = dist_xstateActors.resolveActionsWithContext(preInitial, initEvent, actorScope, []);
|
|
588
593
|
if (resolvedContext) {
|
|
589
594
|
nextState.context = resolvedContext;
|
|
590
595
|
}
|
|
@@ -604,14 +609,18 @@ class StateMachine {
|
|
|
604
609
|
* `ActorRef`.
|
|
605
610
|
*/
|
|
606
611
|
getInitialSnapshot(actorScope, input) {
|
|
612
|
+
return this.initialTransition(input, actorScope)[0];
|
|
613
|
+
}
|
|
614
|
+
initialTransition(input, actorScope) {
|
|
607
615
|
const initEvent = dist_xstateActors.createInitEvent(input); // TODO: fix;
|
|
608
616
|
const internalQueue = [];
|
|
609
617
|
const preInitialState = this._getPreInitialState(actorScope, initEvent);
|
|
610
|
-
const [nextState] = dist_xstateActors.initialMicrostep(this.root, preInitialState, actorScope, initEvent, internalQueue);
|
|
618
|
+
const [nextState, initialActions] = dist_xstateActors.initialMicrostep(this.root, preInitialState, actorScope, initEvent, internalQueue);
|
|
611
619
|
const {
|
|
612
|
-
snapshot: macroState
|
|
620
|
+
snapshot: macroState,
|
|
621
|
+
microsteps
|
|
613
622
|
} = dist_xstateActors.macrostep(nextState, initEvent, actorScope, internalQueue);
|
|
614
|
-
return macroState;
|
|
623
|
+
return [macroState, [...initialActions, ...microsteps.flatMap(([, actions]) => actions)]];
|
|
615
624
|
}
|
|
616
625
|
start(snapshot) {
|
|
617
626
|
// Start rehydrated children that were active when persisted. Freshly
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { MachineSnapshot } from "./State.js";
|
|
2
2
|
import { StateNode } from "./StateNode.js";
|
|
3
3
|
import { AnyActorSystem } from "./system.js";
|
|
4
|
-
import type { ActorLogic, ActorScope, AnyActor, AnyActorRef, AnyActorScope, AnyTransitionDefinition, Equals, EventDescriptor, EventObject, HistoryValue, MachineContext, MetaObject, Snapshot, StateValue, StateSchema, SnapshotStatus } from "./types.js";
|
|
4
|
+
import type { ActorLogic, ActorLogicTransitionResult, ActorScope, AnyActor, AnyActorRef, AnyActorScope, AnyTransitionDefinition, Equals, EventDescriptor, EventObject, ExecutableActionObjectFromLogic, HistoryValue, MachineContext, MetaObject, Snapshot, StateValue, StateSchema, SnapshotStatus } from "./types.js";
|
|
5
5
|
import { AnyMachineSchemas, Implementations, Next_MachineConfig, MachineOptions } from "./types.v6.js";
|
|
6
6
|
export declare class StateMachine<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TInput, TOutput, TEmitted extends EventObject, TMeta extends MetaObject, TConfig extends StateSchema, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays']> implements ActorLogic<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, TEvent, TInput, AnyActorSystem, TEmitted> {
|
|
7
7
|
/** The raw config used to create the machine. */
|
|
8
|
-
config: Next_MachineConfig<any, any, any, any, any, any, any, any, any, any> & {
|
|
8
|
+
config: Next_MachineConfig<any, any, any, any, any, any, any, any, any, any, any> & {
|
|
9
9
|
schemas?: AnyMachineSchemas;
|
|
10
10
|
internalEvents?: readonly string[];
|
|
11
11
|
};
|
|
@@ -22,7 +22,7 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
22
22
|
internalEventDescriptors: ReadonlyArray<string>;
|
|
23
23
|
constructor(
|
|
24
24
|
/** The raw config used to create the machine. */
|
|
25
|
-
config: Next_MachineConfig<any, any, any, any, any, any, any, any, any, any> & {
|
|
25
|
+
config: Next_MachineConfig<any, any, any, any, any, any, any, any, any, any, any> & {
|
|
26
26
|
schemas?: AnyMachineSchemas;
|
|
27
27
|
internalEvents?: readonly string[];
|
|
28
28
|
}, implementations?: Implementations);
|
|
@@ -56,7 +56,7 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
56
56
|
* @param snapshot The current snapshot
|
|
57
57
|
* @param event The received event
|
|
58
58
|
*/
|
|
59
|
-
transition(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, event: TEvent, actorScope: ActorScope<typeof snapshot, TEvent, AnyActorSystem, TEmitted>): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig
|
|
59
|
+
transition(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, event: TEvent, actorScope: ActorScope<typeof snapshot, TEvent, AnyActorSystem, TEmitted>): ActorLogicTransitionResult<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, ExecutableActionObjectFromLogic<this>>;
|
|
60
60
|
/**
|
|
61
61
|
* Determines the next state given the current `state` and `event`. Calculates
|
|
62
62
|
* a microstep.
|
|
@@ -72,6 +72,7 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
72
72
|
* `ActorRef`.
|
|
73
73
|
*/
|
|
74
74
|
getInitialSnapshot(actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, TEvent, AnyActorSystem, TEmitted>, input?: TInput): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>;
|
|
75
|
+
initialTransition(input: TInput | undefined, actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, TEvent, AnyActorSystem, TEmitted>): ActorLogicTransitionResult<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, ExecutableActionObjectFromLogic<this>>;
|
|
75
76
|
start(snapshot?: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>): void;
|
|
76
77
|
getStateNodeById(stateId: string): StateNode<TContext, TEvent>;
|
|
77
78
|
getPersistedSnapshot(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, options?: unknown): Snapshot<unknown>;
|
|
@@ -10,5 +10,5 @@ export declare const builtInActions: {
|
|
|
10
10
|
delay?: number;
|
|
11
11
|
}) => void;
|
|
12
12
|
"@xstate.cancel": (actorScope: AnyActorScope, sendId: string) => void;
|
|
13
|
-
"@xstate.
|
|
13
|
+
"@xstate.stop": (actorScope: AnyActorScope, actor: AnyActor) => void;
|
|
14
14
|
};
|
|
@@ -35,9 +35,11 @@ export declare class Actor<TLogic extends AnyActorLogic> implements ActorInstanc
|
|
|
35
35
|
private observers;
|
|
36
36
|
private eventListeners;
|
|
37
37
|
private logger;
|
|
38
|
+
private _forceDeferredActions;
|
|
38
39
|
_parent?: AnyActor;
|
|
39
40
|
ref: ActorRef<SnapshotFrom<TLogic>, EventFromLogic<TLogic>, EmittedFrom<TLogic>, SendableEventFromLogic<TLogic>>;
|
|
40
41
|
private _actorScope;
|
|
42
|
+
private _initialEffects;
|
|
41
43
|
systemId: string | undefined;
|
|
42
44
|
/** The globally unique process ID for this invocation. */
|
|
43
45
|
sessionId: string;
|
|
@@ -64,6 +66,7 @@ export declare class Actor<TLogic extends AnyActorLogic> implements ActorInstanc
|
|
|
64
66
|
private _setErrorSnapshot;
|
|
65
67
|
private _next;
|
|
66
68
|
private update;
|
|
69
|
+
private _flushInitialEffects;
|
|
67
70
|
/**
|
|
68
71
|
* Subscribe an observer to an actor’s snapshot values.
|
|
69
72
|
*
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from "./schema.types.js";
|
|
2
2
|
import { StateMachine } from "./StateMachine.js";
|
|
3
|
-
import { AnyActorRef, EventObject, AnyEventObject, Cast, MachineContext, ProvidedActor, StateValue, ToChildren, MetaObject, StateSchema, DoNotInfer, RoutableStateId } from "./types.js";
|
|
4
|
-
import { Implementations, DelayMapFromNames, InferOutput, InferEvents, Next_MachineConfig, Next_StateNodeConfig, ValidateDelayReferences, WidenLiterals, WithDefault } from "./types.v6.js";
|
|
3
|
+
import { AnyActorRef, EventObject, AnyEventObject, Cast, MachineContext, ProvidedActor, StateValue, ToChildren, MetaObject, StateSchema, DoNotInfer, RoutableStateId, Compute } from "./types.js";
|
|
4
|
+
import { Implementations, DelayMapFromNames, InferChildren, InferOutput, InferEvents, Next_MachineConfig, Next_StateNodeConfig, ValidateDelayReferences, WidenLiterals, WithDefault } from "./types.v6.js";
|
|
5
|
+
type MergeChildren<TChildren extends Record<string, AnyActorRef | undefined>, TActor extends ProvidedActor> = [keyof TChildren] extends [never] ? Compute<ToChildren<TActor>> : Compute<TChildren>;
|
|
5
6
|
/**
|
|
6
7
|
* Creates a state machine (statechart) with the given configuration.
|
|
7
8
|
*
|
|
@@ -44,19 +45,20 @@ import { Implementations, DelayMapFromNames, InferOutput, InferEvents, Next_Mach
|
|
|
44
45
|
* @param options DEPRECATED: use `setup({ ... })` or `machine.provide({ ... })`
|
|
45
46
|
* to provide machine implementations instead.
|
|
46
47
|
*/
|
|
47
|
-
export declare function createMachine<TContextSchema extends StandardSchemaV1, const TEventSchemaMap extends Record<string, StandardSchemaV1>, TEmittedSchemaMap extends Record<string, StandardSchemaV1>, TInputSchema extends StandardSchemaV1, TOutputSchema extends StandardSchemaV1, TMetaSchema extends StandardSchemaV1, TTagSchema extends StandardSchemaV1, _TEvent extends EventObject, TActor extends ProvidedActor, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TDelays extends string, TTag extends StandardSchemaV1.InferOutput<TTagSchema> & string, TInput, const TSS extends StateSchema>(config: TSS & ValidateDelayReferences<TSS> & Next_MachineConfig<TContextSchema, TEventSchemaMap, TEmittedSchemaMap, TInputSchema, TOutputSchema, TMetaSchema, TTagSchema, InferOutput<TContextSchema, MachineContext>, InferEvents<TEventSchemaMap>, TDelays, TTag, TActionMap, TActorMap, TGuardMap, TDelayMap> & {
|
|
48
|
+
export declare function createMachine<TContextSchema extends StandardSchemaV1, const TEventSchemaMap extends Record<string, StandardSchemaV1>, TEmittedSchemaMap extends Record<string, StandardSchemaV1>, TInputSchema extends StandardSchemaV1, TOutputSchema extends StandardSchemaV1, TMetaSchema extends StandardSchemaV1, TTagSchema extends StandardSchemaV1, const TChildrenSchemaMap extends Record<string, StandardSchemaV1>, _TEvent extends EventObject, TActor extends ProvidedActor, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TDelays extends string, TTag extends StandardSchemaV1.InferOutput<TTagSchema> & string, TInput, const TSS extends StateSchema>(config: TSS & ValidateDelayReferences<TSS> & Next_MachineConfig<TContextSchema, TEventSchemaMap, TEmittedSchemaMap, TInputSchema, TOutputSchema, TMetaSchema, TTagSchema, TChildrenSchemaMap, InferOutput<TContextSchema, MachineContext>, InferEvents<TEventSchemaMap>, Cast<MergeChildren<InferChildren<TChildrenSchemaMap>, TActor>, Record<string, AnyActorRef | undefined>>, TDelays, TTag, TActionMap, TActorMap, TGuardMap, TDelayMap> & {
|
|
48
49
|
schemas: {
|
|
49
50
|
context: TContextSchema;
|
|
51
|
+
children?: TChildrenSchemaMap;
|
|
50
52
|
};
|
|
51
53
|
}): StateMachine<InferOutput<TContextSchema, MachineContext>, InferEvents<TEventSchemaMap> | ([RoutableStateId<TSS>] extends [never] ? never : {
|
|
52
54
|
type: 'xstate.route';
|
|
53
55
|
to: RoutableStateId<TSS>;
|
|
54
|
-
}), Cast<
|
|
56
|
+
}), Cast<MergeChildren<InferChildren<TChildrenSchemaMap>, TActor>, Record<string, AnyActorRef | undefined>>, StateValue, TTag & string, TInput, InferOutput<TOutputSchema, unknown>, WithDefault<InferEvents<TEmittedSchemaMap>, AnyEventObject>, InferOutput<TMetaSchema, MetaObject>, // TMeta
|
|
55
57
|
TSS, // TStateSchema
|
|
56
58
|
TActionMap, TActorMap, TGuardMap, DelayMapFromNames<TDelays, TDelayMap>> & {
|
|
57
59
|
states: TSS;
|
|
58
60
|
};
|
|
59
|
-
export declare function createMachine<TContext extends MachineContext = never, const TEventSchemaMap extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, TEmittedSchemaMap extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, TInputSchema extends StandardSchemaV1 = StandardSchemaV1, TOutputSchema extends StandardSchemaV1 = StandardSchemaV1, TMetaSchema extends StandardSchemaV1 = StandardSchemaV1, TTagSchema extends StandardSchemaV1 = StandardSchemaV1, _TEvent extends EventObject = EventObject, TActor extends ProvidedActor = ProvidedActor, TActionMap extends Implementations['actions'] = Implementations['actions'], TActorMap extends Implementations['actors'] = Implementations['actors'], TGuardMap extends Implementations['guards'] = Implementations['guards'], TDelayMap extends Implementations['delays'] = Implementations['delays'], TDelays extends string = string, TTag extends StandardSchemaV1.InferOutput<TTagSchema> & string = StandardSchemaV1.InferOutput<TTagSchema> & string, TInput = unknown, const TSS extends StateSchema = StateSchema>(config: TSS & ValidateDelayReferences<TSS> & Next_MachineConfig<StandardSchemaV1, TEventSchemaMap, TEmittedSchemaMap, TInputSchema, TOutputSchema, TMetaSchema, TTagSchema, WidenLiterals<TContext>, InferEvents<TEventSchemaMap>, TDelays, TTag, TActionMap, TActorMap, TGuardMap, TDelayMap, false> & {
|
|
61
|
+
export declare function createMachine<TContext extends MachineContext = never, const TEventSchemaMap extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, TEmittedSchemaMap extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, TInputSchema extends StandardSchemaV1 = StandardSchemaV1, TOutputSchema extends StandardSchemaV1 = StandardSchemaV1, TMetaSchema extends StandardSchemaV1 = StandardSchemaV1, TTagSchema extends StandardSchemaV1 = StandardSchemaV1, const TChildrenSchemaMap extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, _TEvent extends EventObject = EventObject, TActor extends ProvidedActor = ProvidedActor, TActionMap extends Implementations['actions'] = Implementations['actions'], TActorMap extends Implementations['actors'] = Implementations['actors'], TGuardMap extends Implementations['guards'] = Implementations['guards'], TDelayMap extends Implementations['delays'] = Implementations['delays'], TDelays extends string = string, TTag extends StandardSchemaV1.InferOutput<TTagSchema> & string = StandardSchemaV1.InferOutput<TTagSchema> & string, TInput = unknown, const TSS extends StateSchema = StateSchema>(config: TSS & ValidateDelayReferences<TSS> & Next_MachineConfig<StandardSchemaV1, TEventSchemaMap, TEmittedSchemaMap, TInputSchema, TOutputSchema, TMetaSchema, TTagSchema, TChildrenSchemaMap, WidenLiterals<TContext>, InferEvents<TEventSchemaMap>, Cast<MergeChildren<InferChildren<TChildrenSchemaMap>, TActor>, Record<string, AnyActorRef | undefined>>, TDelays, TTag, TActionMap, TActorMap, TGuardMap, TDelayMap, false> & {
|
|
60
62
|
schemas?: {
|
|
61
63
|
context?: never;
|
|
62
64
|
};
|
|
@@ -69,10 +71,11 @@ export declare function createMachine<TContext extends MachineContext = never, c
|
|
|
69
71
|
}): StateMachine<WidenLiterals<TContext>, InferEvents<TEventSchemaMap> | ([RoutableStateId<TSS>] extends [never] ? never : {
|
|
70
72
|
type: 'xstate.route';
|
|
71
73
|
to: RoutableStateId<TSS>;
|
|
72
|
-
}), Cast<
|
|
74
|
+
}), Cast<MergeChildren<InferChildren<TChildrenSchemaMap>, TActor>, Record<string, AnyActorRef | undefined>>, StateValue, TTag & string, TInput, InferOutput<TOutputSchema, unknown>, WithDefault<InferEvents<TEmittedSchemaMap>, AnyEventObject>, InferOutput<TMetaSchema, MetaObject>, // TMeta
|
|
73
75
|
TSS, // TStateSchema
|
|
74
76
|
TActionMap, TActorMap, TGuardMap, DelayMapFromNames<TDelays, TDelayMap>> & {
|
|
75
77
|
states: TSS;
|
|
76
78
|
};
|
|
77
79
|
export declare function createStateConfig<TContextSchema extends StandardSchemaV1, TEventSchema extends StandardSchemaV1, TEmittedSchema extends StandardSchemaV1, _TInputSchema extends StandardSchemaV1, TOutputSchema extends StandardSchemaV1, TMetaSchema extends StandardSchemaV1, TTagSchema extends StandardSchemaV1, _TEvent extends StandardSchemaV1.InferOutput<TEventSchema> & EventObject, // TODO: consider using a stricter `EventObject` here
|
|
78
|
-
_TActor extends ProvidedActor, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TDelays extends string, _TTag extends StandardSchemaV1.InferOutput<TTagSchema> & string, _TInput, const TSS extends StateSchema>(config: TSS & Next_StateNodeConfig<InferOutput<TContextSchema, MachineContext>, DoNotInfer<StandardSchemaV1.InferOutput<TEventSchema> & EventObject>, DoNotInfer<TDelays>, DoNotInfer<StandardSchemaV1.InferOutput<TTagSchema> & string>, DoNotInfer<StandardSchemaV1.InferOutput<TOutputSchema>>, DoNotInfer<StandardSchemaV1.InferOutput<TEmittedSchema> & EventObject>, DoNotInfer<InferOutput<TMetaSchema, MetaObject>>, DoNotInfer<TActionMap>, DoNotInfer<TActorMap>, DoNotInfer<TGuardMap>, DoNotInfer<TDelayMap>>): typeof config;
|
|
80
|
+
_TActor extends ProvidedActor, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TDelays extends string, _TTag extends StandardSchemaV1.InferOutput<TTagSchema> & string, _TInput, const TSS extends StateSchema>(config: TSS & Next_StateNodeConfig<InferOutput<TContextSchema, MachineContext>, DoNotInfer<StandardSchemaV1.InferOutput<TEventSchema> & EventObject>, DoNotInfer<TDelays>, DoNotInfer<StandardSchemaV1.InferOutput<TTagSchema> & string>, DoNotInfer<StandardSchemaV1.InferOutput<TOutputSchema>>, DoNotInfer<StandardSchemaV1.InferOutput<TEmittedSchema> & EventObject>, DoNotInfer<InferOutput<TMetaSchema, MetaObject>>, DoNotInfer<Record<string, AnyActorRef | undefined>>, DoNotInfer<TActionMap>, DoNotInfer<TActorMap>, DoNotInfer<TGuardMap>, DoNotInfer<TDelayMap>>): typeof config;
|
|
81
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventObject, AnyStateMachine, StateNode, AnyActorLogic, EventFromLogic, Snapshot, InputFrom } from "../index.js";
|
|
1
|
+
import { EventObject, AnyStateMachine, StateNode, AnyActorLogic, EventFromLogic, Snapshot, InputFrom, SnapshotFrom } from "../index.js";
|
|
2
2
|
import type { SerializedSnapshot, StatePath, DirectedGraphNode, TraversalOptions, AnyStateNode, TraversalConfig } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Returns all state nodes of the given `node`.
|
|
@@ -9,8 +9,8 @@ export declare function getStateNodes(stateNode: {
|
|
|
9
9
|
states: Record<string, AnyStateNode | StateNode<never, EventObject>>;
|
|
10
10
|
}): AnyStateNode[];
|
|
11
11
|
export declare function serializeSnapshot(snapshot: Snapshot<any>): SerializedSnapshot;
|
|
12
|
-
export declare function createDefaultMachineOptions<TMachine extends AnyStateMachine>(machine: TMachine, options?: TraversalOptions<
|
|
12
|
+
export declare function createDefaultMachineOptions<TMachine extends AnyStateMachine>(machine: TMachine, options?: TraversalOptions<SnapshotFrom<TMachine>, EventFromLogic<TMachine>, InputFrom<TMachine>>): TraversalOptions<SnapshotFrom<TMachine>, EventFromLogic<TMachine>, InputFrom<TMachine>>;
|
|
13
13
|
export declare function createDefaultLogicOptions(): TraversalOptions<any, any, any>;
|
|
14
14
|
export declare function toDirectedGraph(stateMachine: AnyStateNode | AnyStateMachine): DirectedGraphNode;
|
|
15
|
-
export declare function resolveTraversalOptions<TLogic extends AnyActorLogic>(logic: TLogic, traversalOptions?: TraversalOptions<
|
|
15
|
+
export declare function resolveTraversalOptions<TLogic extends AnyActorLogic>(logic: TLogic, traversalOptions?: TraversalOptions<SnapshotFrom<TLogic>, EventFromLogic<TLogic>, InputFrom<TLogic>>, defaultOptions?: TraversalOptions<SnapshotFrom<TLogic>, EventFromLogic<TLogic>, InputFrom<TLogic>>): TraversalConfig<SnapshotFrom<TLogic>, EventFromLogic<TLogic>>;
|
|
16
16
|
export declare function joinPaths<TSnapshot extends Snapshot<unknown>, TEvent extends EventObject>(headPath: StatePath<TSnapshot, TEvent>, tailPath: StatePath<TSnapshot, TEvent>): StatePath<TSnapshot, TEvent>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { AnyActorLogic, EventFromLogic, InputFrom } from "../index.js";
|
|
1
|
+
import { AnyActorLogic, EventFromLogic, InputFrom, SnapshotFrom } from "../index.js";
|
|
2
2
|
import { StatePath, TraversalOptions } from "./types.js";
|
|
3
|
-
export declare function getShortestPaths<TLogic extends AnyActorLogic>(logic: TLogic, options?: TraversalOptions<
|
|
3
|
+
export declare function getShortestPaths<TLogic extends AnyActorLogic>(logic: TLogic, options?: TraversalOptions<SnapshotFrom<TLogic>, EventFromLogic<TLogic>, InputFrom<TLogic>>): Array<StatePath<SnapshotFrom<TLogic>, EventFromLogic<TLogic>>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { AnyActorLogic, EventFromLogic, InputFrom } from "../index.js";
|
|
1
|
+
import { AnyActorLogic, EventFromLogic, InputFrom, SnapshotFrom } from "../index.js";
|
|
2
2
|
import { StatePath, TraversalOptions } from "./types.js";
|
|
3
|
-
export declare function getSimplePaths<TLogic extends AnyActorLogic>(logic: TLogic, options?: TraversalOptions<
|
|
3
|
+
export declare function getSimplePaths<TLogic extends AnyActorLogic>(logic: TLogic, options?: TraversalOptions<SnapshotFrom<TLogic>, EventFromLogic<TLogic>, InputFrom<TLogic>>): Array<StatePath<SnapshotFrom<TLogic>, EventFromLogic<TLogic>>>;
|
|
@@ -22,6 +22,7 @@ export * from "./types.js";
|
|
|
22
22
|
export type { Next_MachineConfig as MachineConfig, Next_StateNodeConfig as StateNodeConfig, Next_InvokeConfig as InvokeConfig, Next_TransitionConfigOrTarget as TransitionConfigOrTarget, Implementations, InferEvents, WidenLiterals } from "./types.v6.js";
|
|
23
23
|
export { getAllOwnEventDescriptors as __unsafe_getAllOwnEventDescriptors, matchesState, checkStateIn, pathToStateValue, toObserver } from "./utils.js";
|
|
24
24
|
export { transition, initialTransition, getMicrosteps, getInitialMicrosteps, getNextTransitions } from "./transition.js";
|
|
25
|
+
export { isBuiltInExecutableAction } from "./transitionActions.js";
|
|
25
26
|
export { waitFor } from "./waitFor.js";
|
|
26
27
|
declare global {
|
|
27
28
|
interface SymbolConstructor {
|