xstate 5.0.0-beta.8 → 5.0.0
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/README.md +10 -8
- package/actions/dist/xstate-actions.cjs.d.mts +2 -0
- package/actions/dist/xstate-actions.cjs.d.mts.map +1 -0
- package/actions/dist/xstate-actions.cjs.d.ts +1 -0
- package/actions/dist/xstate-actions.cjs.d.ts.map +1 -0
- package/actions/dist/xstate-actions.cjs.js +19 -5
- package/actions/dist/xstate-actions.cjs.mjs +13 -0
- package/actions/dist/xstate-actions.development.cjs.js +21 -0
- package/actions/dist/xstate-actions.development.cjs.mjs +13 -0
- package/actions/dist/xstate-actions.development.esm.js +3 -0
- package/actions/dist/xstate-actions.esm.js +3 -2
- package/actions/dist/xstate-actions.umd.min.js +1 -1
- package/actions/dist/xstate-actions.umd.min.js.map +1 -1
- package/actors/dist/xstate-actors.cjs.d.mts +2 -0
- package/actors/dist/xstate-actors.cjs.d.mts.map +1 -0
- package/actors/dist/xstate-actors.cjs.d.ts +1 -0
- package/actors/dist/xstate-actors.cjs.d.ts.map +1 -0
- package/actors/dist/xstate-actors.cjs.js +621 -4
- package/actors/dist/xstate-actors.cjs.mjs +8 -0
- package/actors/dist/xstate-actors.development.cjs.js +624 -0
- package/actors/dist/xstate-actors.development.cjs.mjs +8 -0
- package/actors/dist/xstate-actors.development.esm.js +615 -0
- package/actors/dist/xstate-actors.esm.js +615 -2
- package/actors/dist/xstate-actors.umd.min.js +1 -1
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dev/dist/xstate-dev.cjs.d.mts +2 -0
- package/dev/dist/xstate-dev.cjs.d.mts.map +1 -0
- package/dev/dist/xstate-dev.cjs.d.ts +1 -0
- package/dev/dist/xstate-dev.cjs.d.ts.map +1 -0
- package/dev/dist/xstate-dev.cjs.js +45 -4
- package/dev/dist/xstate-dev.cjs.mjs +5 -0
- package/{dist/index-ebaab3c9.cjs.dev.js → dev/dist/xstate-dev.development.cjs.js} +6 -7
- package/dev/dist/xstate-dev.development.cjs.mjs +5 -0
- package/{dist/index-50bd0aff.esm.js → dev/dist/xstate-dev.development.esm.js} +6 -8
- package/dev/dist/xstate-dev.esm.js +42 -1
- package/dev/dist/xstate-dev.umd.min.js +1 -1
- package/dev/dist/xstate-dev.umd.min.js.map +1 -1
- package/dist/declarations/src/SimulatedClock.d.ts +1 -1
- package/dist/declarations/src/State.d.ts +47 -73
- package/dist/declarations/src/StateMachine.d.ts +29 -57
- package/dist/declarations/src/StateNode.d.ts +36 -33
- package/dist/declarations/src/actions/assign.d.ts +11 -2
- package/dist/declarations/src/actions/cancel.d.ts +7 -3
- package/dist/declarations/src/actions/enqueueActions.d.ts +32 -0
- package/dist/declarations/src/actions/log.d.ts +7 -3
- package/dist/declarations/src/actions/raise.d.ts +7 -2
- package/dist/declarations/src/actions/send.d.ts +14 -36
- package/dist/declarations/src/actions/spawnChild.d.ts +29 -0
- package/dist/declarations/src/actions/stopChild.d.ts +18 -0
- package/dist/declarations/src/actions.d.ts +8 -48
- package/dist/declarations/src/actors/callback.d.ts +91 -8
- package/dist/declarations/src/actors/index.d.ts +6 -28
- package/dist/declarations/src/actors/observable.d.ts +101 -18
- package/dist/declarations/src/actors/promise.d.ts +80 -10
- package/dist/declarations/src/actors/transition.d.ts +64 -9
- package/dist/declarations/src/constants.d.ts +3 -0
- package/dist/declarations/src/createMachine.d.ts +20 -0
- package/dist/declarations/src/dev/index.d.ts +6 -6
- package/dist/declarations/src/guards.d.ts +41 -8
- package/dist/declarations/src/index.d.ts +18 -23
- package/dist/declarations/src/interpreter.d.ts +150 -41
- package/dist/declarations/src/setup.d.ts +51 -0
- package/dist/declarations/src/spawn.d.ts +23 -2
- package/dist/declarations/src/stateUtils.d.ts +30 -45
- package/dist/declarations/src/system.d.ts +26 -2
- package/dist/declarations/src/typegenTypes.d.ts +40 -22
- package/dist/declarations/src/types.d.ts +528 -669
- package/dist/declarations/src/utils.d.ts +15 -52
- package/dist/declarations/src/waitFor.d.ts +2 -2
- package/dist/log-22e678c5.esm.js +364 -0
- package/dist/log-5e226275.cjs.js +372 -0
- package/dist/log-641cd926.development.cjs.js +394 -0
- package/dist/log-f196f85f.development.esm.js +386 -0
- package/dist/raise-34e25c2c.cjs.js +2368 -0
- package/dist/raise-62704519.development.cjs.js +2422 -0
- package/dist/raise-89c581c4.development.esm.js +2371 -0
- package/dist/raise-8bc422d1.esm.js +2317 -0
- package/dist/xstate.cjs.d.mts +2 -0
- package/dist/xstate.cjs.d.mts.map +1 -0
- package/dist/xstate.cjs.d.ts +1 -0
- package/dist/xstate.cjs.d.ts.map +1 -0
- package/dist/xstate.cjs.js +728 -4
- package/dist/xstate.cjs.mjs +39 -0
- package/dist/xstate.development.cjs.js +737 -0
- package/dist/xstate.development.cjs.mjs +39 -0
- package/dist/xstate.development.esm.js +699 -0
- package/dist/xstate.esm.js +561 -770
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/guards/dist/xstate-guards.cjs.d.mts +2 -0
- package/guards/dist/xstate-guards.cjs.d.mts.map +1 -0
- package/guards/dist/xstate-guards.cjs.d.ts +1 -0
- package/guards/dist/xstate-guards.cjs.d.ts.map +1 -0
- package/guards/dist/xstate-guards.cjs.js +12 -5
- package/guards/dist/xstate-guards.cjs.mjs +7 -0
- package/guards/dist/xstate-guards.development.cjs.js +14 -0
- package/guards/dist/xstate-guards.development.cjs.mjs +7 -0
- package/guards/dist/xstate-guards.development.esm.js +2 -0
- package/guards/dist/xstate-guards.esm.js +2 -2
- package/guards/dist/xstate-guards.umd.min.js +1 -1
- package/guards/dist/xstate-guards.umd.min.js.map +1 -1
- package/package.json +59 -1
- package/actions/dist/xstate-actions.cjs.dev.js +0 -32
- package/actions/dist/xstate-actions.cjs.prod.js +0 -32
- package/actions/dynamicAction.ts +0 -42
- package/actors/dist/xstate-actors.cjs.dev.js +0 -22
- package/actors/dist/xstate-actors.cjs.prod.js +0 -22
- package/dev/dist/xstate-dev.cjs.dev.js +0 -11
- package/dev/dist/xstate-dev.cjs.prod.js +0 -48
- package/dist/actions-900f9761.cjs.prod.js +0 -4349
- package/dist/actions-c8d7df32.esm.js +0 -4332
- package/dist/actions-d06ca158.cjs.dev.js +0 -4387
- package/dist/declarations/actions/dynamicAction.d.ts +0 -5
- package/dist/declarations/src/Machine.d.ts +0 -4
- package/dist/declarations/src/Mailbox.d.ts +0 -12
- package/dist/declarations/src/actionTypes.d.ts +0 -16
- package/dist/declarations/src/actions/choose.d.ts +0 -3
- package/dist/declarations/src/actions/invoke.d.ts +0 -3
- package/dist/declarations/src/actions/pure.d.ts +0 -6
- package/dist/declarations/src/actions/stop.d.ts +0 -7
- package/dist/declarations/src/environment.d.ts +0 -1
- package/dist/declarations/src/mapState.d.ts +0 -3
- package/dist/declarations/src/memo.d.ts +0 -2
- package/dist/xstate.cjs.dev.js +0 -956
- package/dist/xstate.cjs.prod.js +0 -953
- package/guards/dist/xstate-guards.cjs.dev.js +0 -15
- package/guards/dist/xstate-guards.cjs.prod.js +0 -15
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
|
|
6
6
|
function getGlobal() {
|
|
@@ -16,12 +16,12 @@ function getGlobal() {
|
|
|
16
16
|
if (typeof global !== 'undefined') {
|
|
17
17
|
return global;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
{
|
|
20
20
|
console.warn('XState could not find a global object in this environment. Please let the maintainers know and raise an issue here: https://github.com/statelyai/xstate/issues');
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
function getDevTools() {
|
|
24
|
-
|
|
24
|
+
const w = getGlobal();
|
|
25
25
|
if (!!w.__xstate__) {
|
|
26
26
|
return w.__xstate__;
|
|
27
27
|
}
|
|
@@ -31,22 +31,21 @@ function registerService(service) {
|
|
|
31
31
|
if (typeof window === 'undefined') {
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
const devTools = getDevTools();
|
|
35
35
|
if (devTools) {
|
|
36
36
|
devTools.register(service);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
const devToolsAdapter = service => {
|
|
40
40
|
if (typeof window === 'undefined') {
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
const devTools = getDevTools();
|
|
44
44
|
if (devTools) {
|
|
45
45
|
devTools.register(service);
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
exports.IS_PRODUCTION = IS_PRODUCTION;
|
|
50
49
|
exports.devToolsAdapter = devToolsAdapter;
|
|
51
50
|
exports.getGlobal = getGlobal;
|
|
52
51
|
exports.registerService = registerService;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var IS_PRODUCTION = process.env.NODE_ENV === 'production';
|
|
2
|
-
|
|
3
1
|
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
|
|
4
2
|
function getGlobal() {
|
|
5
3
|
if (typeof globalThis !== 'undefined') {
|
|
@@ -14,12 +12,12 @@ function getGlobal() {
|
|
|
14
12
|
if (typeof global !== 'undefined') {
|
|
15
13
|
return global;
|
|
16
14
|
}
|
|
17
|
-
|
|
15
|
+
{
|
|
18
16
|
console.warn('XState could not find a global object in this environment. Please let the maintainers know and raise an issue here: https://github.com/statelyai/xstate/issues');
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
19
|
function getDevTools() {
|
|
22
|
-
|
|
20
|
+
const w = getGlobal();
|
|
23
21
|
if (!!w.__xstate__) {
|
|
24
22
|
return w.__xstate__;
|
|
25
23
|
}
|
|
@@ -29,19 +27,19 @@ function registerService(service) {
|
|
|
29
27
|
if (typeof window === 'undefined') {
|
|
30
28
|
return;
|
|
31
29
|
}
|
|
32
|
-
|
|
30
|
+
const devTools = getDevTools();
|
|
33
31
|
if (devTools) {
|
|
34
32
|
devTools.register(service);
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
|
-
|
|
35
|
+
const devToolsAdapter = service => {
|
|
38
36
|
if (typeof window === 'undefined') {
|
|
39
37
|
return;
|
|
40
38
|
}
|
|
41
|
-
|
|
39
|
+
const devTools = getDevTools();
|
|
42
40
|
if (devTools) {
|
|
43
41
|
devTools.register(service);
|
|
44
42
|
}
|
|
45
43
|
};
|
|
46
44
|
|
|
47
|
-
export {
|
|
45
|
+
export { devToolsAdapter, getGlobal, registerService };
|
|
@@ -1 +1,42 @@
|
|
|
1
|
-
|
|
1
|
+
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
|
|
2
|
+
function getGlobal() {
|
|
3
|
+
if (typeof globalThis !== 'undefined') {
|
|
4
|
+
return globalThis;
|
|
5
|
+
}
|
|
6
|
+
if (typeof self !== 'undefined') {
|
|
7
|
+
return self;
|
|
8
|
+
}
|
|
9
|
+
if (typeof window !== 'undefined') {
|
|
10
|
+
return window;
|
|
11
|
+
}
|
|
12
|
+
if (typeof global !== 'undefined') {
|
|
13
|
+
return global;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function getDevTools() {
|
|
17
|
+
const w = getGlobal();
|
|
18
|
+
if (!!w.__xstate__) {
|
|
19
|
+
return w.__xstate__;
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
function registerService(service) {
|
|
24
|
+
if (typeof window === 'undefined') {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const devTools = getDevTools();
|
|
28
|
+
if (devTools) {
|
|
29
|
+
devTools.register(service);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const devToolsAdapter = service => {
|
|
33
|
+
if (typeof window === 'undefined') {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const devTools = getDevTools();
|
|
37
|
+
if (devTools) {
|
|
38
|
+
devTools.register(service);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { devToolsAdapter, getGlobal, registerService };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).XStateDev={})}(this,(function(e){"use strict";function t(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:window}function n(){
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).XStateDev={})}(this,(function(e){"use strict";function t(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:window}function n(){const e=t();if(e.__xstate__)return e.__xstate__}e.devToolsAdapter=e=>{const t=n();t&&t.register(e)},e.getGlobal=t,e.registerService=function(e){const t=n();t&&t.register(e)},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
2
|
//# sourceMappingURL=xstate-dev.umd.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xstate-dev.umd.min.js","sources":["../../src/dev/index.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"xstate-dev.umd.min.js","sources":["../../src/dev/index.ts"],"sourcesContent":["import isDevelopment from '#is-development';\nimport { AnyActor, DevToolsAdapter } from '../types.ts';\n\ninterface DevInterface {\n services: Set<AnyActor>;\n register(service: AnyActor): void;\n onRegister(listener: ServiceListener): void;\n}\ntype ServiceListener = (service: AnyActor) => void;\n\nexport interface XStateDevInterface {\n register: (service: AnyActor) => void;\n unregister: (service: AnyActor) => void;\n onRegister: (listener: ServiceListener) => {\n unsubscribe: () => void;\n };\n services: Set<AnyActor>;\n}\n\n// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis\nexport function getGlobal(): typeof globalThis | undefined {\n if (typeof globalThis !== 'undefined') {\n return globalThis;\n }\n if (typeof self !== 'undefined') {\n return self;\n }\n if (typeof window !== 'undefined') {\n return window;\n }\n if (typeof global !== 'undefined') {\n return global;\n }\n if (isDevelopment) {\n console.warn(\n 'XState could not find a global object in this environment. Please let the maintainers know and raise an issue here: https://github.com/statelyai/xstate/issues'\n );\n }\n}\n\nfunction getDevTools(): DevInterface | undefined {\n const w = getGlobal();\n if (!!(w as any).__xstate__) {\n return (w as any).__xstate__;\n }\n\n return undefined;\n}\n\nexport function registerService(service: AnyActor) {\n if (typeof window === 'undefined') {\n return;\n }\n\n const devTools = getDevTools();\n\n if (devTools) {\n devTools.register(service);\n }\n}\n\nexport const devToolsAdapter: DevToolsAdapter = (service) => {\n if (typeof window === 'undefined') {\n return;\n }\n\n const devTools = getDevTools();\n\n if (devTools) {\n devTools.register(service);\n }\n};\n"],"names":["getGlobal","globalThis","self","window","getDevTools","w","__xstate__","service","devTools","register"],"mappings":"iPAoBO,SAASA,IACd,MAA0B,oBAAfC,WACFA,WAEW,oBAATC,KACFA,KAGAC,MAUX,CAEA,SAASC,IACP,MAAMC,EAAIL,IACV,GAAOK,EAAUC,WACf,OAAQD,EAAUC,UAItB,mBAciDC,IAK/C,MAAMC,EAAWJ,IAEbI,GACFA,EAASC,SAASF,EACpB,kCArBK,SAAyBA,GAK9B,MAAMC,EAAWJ,IAEbI,GACFA,EAASC,SAASF,EAEtB"}
|
|
@@ -1,83 +1,37 @@
|
|
|
1
|
-
import type { StateNode } from
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export declare
|
|
9
|
-
|
|
10
|
-
machine:
|
|
1
|
+
import type { StateNode } from "./StateNode.js";
|
|
2
|
+
import type { StateMachine } from "./StateMachine.js";
|
|
3
|
+
import { TypegenDisabled } from "./typegenTypes.js";
|
|
4
|
+
import type { ProvidedActor, AnyMachineSnapshot, AnyStateMachine, EventObject, HistoryValue, MachineContext, StateConfig, StateValue, AnyActorRef, Snapshot, ParameterizedObject, IsNever } from "./types.js";
|
|
5
|
+
type ToTestStateValue<TStateValue extends StateValue> = TStateValue extends string ? TStateValue : IsNever<keyof TStateValue> extends true ? never : keyof TStateValue | {
|
|
6
|
+
[K in keyof TStateValue]?: ToTestStateValue<NonNullable<TStateValue[K]>>;
|
|
7
|
+
};
|
|
8
|
+
export declare function isMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject>(value: unknown): value is AnyMachineSnapshot;
|
|
9
|
+
interface MachineSnapshotBase<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TResolvedTypesMeta = TypegenDisabled> {
|
|
10
|
+
machine: StateMachine<TContext, TEvent, TChildren, ProvidedActor, ParameterizedObject, ParameterizedObject, string, TStateValue, TTag, unknown, TOutput, TResolvedTypesMeta>;
|
|
11
11
|
tags: Set<string>;
|
|
12
|
-
value:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*/
|
|
16
|
-
done: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* The done data of the top-level finite state.
|
|
19
|
-
*/
|
|
20
|
-
output: any;
|
|
12
|
+
value: TStateValue;
|
|
13
|
+
status: 'active' | 'done' | 'error' | 'stopped';
|
|
14
|
+
error: unknown;
|
|
21
15
|
context: TContext;
|
|
22
16
|
historyValue: Readonly<HistoryValue<TContext, TEvent>>;
|
|
23
|
-
actions: BaseActionObject[];
|
|
24
|
-
event: TEvent;
|
|
25
|
-
_internalQueue: Array<SCXML.Event<TEvent>>;
|
|
26
|
-
_event: SCXML.Event<TEvent>;
|
|
27
|
-
_initial: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Indicates whether the state has changed from the previous state. A state is considered "changed" if:
|
|
30
|
-
*
|
|
31
|
-
* - Its value is not equal to its previous value, or:
|
|
32
|
-
* - It has any new actions (side-effects) to execute.
|
|
33
|
-
*
|
|
34
|
-
* An initial state (with no history) will return `undefined`.
|
|
35
|
-
*/
|
|
36
|
-
changed: boolean | undefined;
|
|
37
17
|
/**
|
|
38
18
|
* The enabled state nodes representative of the state value.
|
|
39
19
|
*/
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The transition definitions that resulted in this state.
|
|
43
|
-
*/
|
|
44
|
-
transitions: Array<TransitionDefinition<TContext, TEvent>>;
|
|
20
|
+
_nodes: Array<StateNode<TContext, TEvent>>;
|
|
45
21
|
/**
|
|
46
22
|
* An object mapping actor names to spawned/invoked actors.
|
|
47
23
|
*/
|
|
48
|
-
children:
|
|
49
|
-
/**
|
|
50
|
-
* Creates a new State instance for the given `stateValue` and `context`.
|
|
51
|
-
* @param stateValue
|
|
52
|
-
* @param context
|
|
53
|
-
*/
|
|
54
|
-
static from<TContext extends MachineContext, TEvent extends EventObject = EventObject>(stateValue: State<TContext, TEvent, any> | StateValue, context: TContext | undefined, machine: AnyStateMachine): State<TContext, TEvent, any>;
|
|
55
|
-
/**
|
|
56
|
-
* Creates a new `State` instance that represents the current state of a running machine.
|
|
57
|
-
*
|
|
58
|
-
* @param config
|
|
59
|
-
*/
|
|
60
|
-
constructor(config: StateConfig<TContext, TEvent>, machine: AnyStateMachine);
|
|
61
|
-
/**
|
|
62
|
-
* Returns an array of all the string leaf state node paths.
|
|
63
|
-
* @param stateValue
|
|
64
|
-
* @param delimiter The character(s) that separate each subpath in the string state node path.
|
|
65
|
-
*/
|
|
66
|
-
toStrings(stateValue?: StateValue, delimiter?: string): string[];
|
|
67
|
-
toJSON(): Omit<this, "meta" | "toJSON" | "configuration" | "transitions" | "tags" | "machine" | "toStrings" | "matches" | "hasTag" | "can" | "nextEvents"> & {
|
|
68
|
-
tags: string[];
|
|
69
|
-
meta: Record<string, any>;
|
|
70
|
-
};
|
|
24
|
+
children: TChildren;
|
|
71
25
|
/**
|
|
72
26
|
* Whether the current state value is a subset of the given parent state value.
|
|
73
|
-
* @param
|
|
27
|
+
* @param testValue
|
|
74
28
|
*/
|
|
75
|
-
matches<
|
|
29
|
+
matches: (this: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>, testValue: ToTestStateValue<TStateValue>) => boolean;
|
|
76
30
|
/**
|
|
77
|
-
* Whether the current state
|
|
31
|
+
* Whether the current state nodes has a state node with the specified `tag`.
|
|
78
32
|
* @param tag
|
|
79
33
|
*/
|
|
80
|
-
hasTag(
|
|
34
|
+
hasTag: (this: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>, tag: TTag) => boolean;
|
|
81
35
|
/**
|
|
82
36
|
* Determines whether sending the `event` will cause a non-forbidden transition
|
|
83
37
|
* to be selected, even if the transitions have no actions nor
|
|
@@ -86,12 +40,32 @@ export declare class State<TContext extends MachineContext, TEvent extends Event
|
|
|
86
40
|
* @param event The event to test
|
|
87
41
|
* @returns Whether the event will cause a transition
|
|
88
42
|
*/
|
|
89
|
-
can(event: TEvent)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
43
|
+
can: (this: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>, event: TEvent) => boolean;
|
|
44
|
+
getMeta: (this: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>) => Record<string, any>;
|
|
45
|
+
toJSON: (this: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>) => unknown;
|
|
46
|
+
}
|
|
47
|
+
interface ActiveMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TResolvedTypesMeta = TypegenDisabled> extends MachineSnapshotBase<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta> {
|
|
48
|
+
status: 'active';
|
|
49
|
+
output: undefined;
|
|
50
|
+
error: undefined;
|
|
51
|
+
}
|
|
52
|
+
interface DoneMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TResolvedTypesMeta = TypegenDisabled> extends MachineSnapshotBase<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta> {
|
|
53
|
+
status: 'done';
|
|
54
|
+
output: TOutput;
|
|
55
|
+
error: undefined;
|
|
56
|
+
}
|
|
57
|
+
interface ErrorMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TResolvedTypesMeta = TypegenDisabled> extends MachineSnapshotBase<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta> {
|
|
58
|
+
status: 'error';
|
|
59
|
+
output: undefined;
|
|
60
|
+
error: unknown;
|
|
61
|
+
}
|
|
62
|
+
interface StoppedMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TResolvedTypesMeta = TypegenDisabled> extends MachineSnapshotBase<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta> {
|
|
63
|
+
status: 'stopped';
|
|
64
|
+
output: undefined;
|
|
65
|
+
error: undefined;
|
|
95
66
|
}
|
|
96
|
-
export
|
|
97
|
-
export declare function
|
|
67
|
+
export type MachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TResolvedTypesMeta = TypegenDisabled> = ActiveMachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta> | DoneMachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta> | ErrorMachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta> | StoppedMachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>;
|
|
68
|
+
export declare function createMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TResolvedTypesMeta = TypegenDisabled>(config: StateConfig<TContext, TEvent>, machine: AnyStateMachine): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, undefined, TResolvedTypesMeta>;
|
|
69
|
+
export declare function cloneMachineSnapshot<TState extends AnyMachineSnapshot>(snapshot: TState, config?: Partial<StateConfig<any, any>>): TState;
|
|
70
|
+
export declare function getPersistedSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TResolvedTypesMeta = TypegenDisabled>(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>, options?: unknown): Snapshot<unknown>;
|
|
71
|
+
export {};
|
|
@@ -1,38 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { StateNode } from
|
|
3
|
-
import type { AreAllImplementationsAssumedToBeProvided, MarkAllImplementationsAsProvided, ResolveTypegenMeta, TypegenDisabled } from
|
|
4
|
-
import type {
|
|
5
|
-
export declare const NULL_EVENT = "";
|
|
1
|
+
import { MachineSnapshot } from "./State.js";
|
|
2
|
+
import { StateNode } from "./StateNode.js";
|
|
3
|
+
import type { AreAllImplementationsAssumedToBeProvided, MarkAllImplementationsAsProvided, ResolveTypegenMeta, TypegenDisabled } from "./typegenTypes.js";
|
|
4
|
+
import type { ActorScope, ActorLogic, EventObject, InternalMachineImplementations, MachineConfig, MachineContext, MachineImplementationsSimplified, NoInfer, StateMachineDefinition, StateValue, TransitionDefinition, ParameterizedObject, AnyActorScope, ProvidedActor, AnyActorRef, Equals, TODO, Snapshot, HistoryValue, EventDescriptor } from "./types.js";
|
|
6
5
|
export declare const STATE_IDENTIFIER = "#";
|
|
7
6
|
export declare const WILDCARD = "*";
|
|
8
|
-
export declare class StateMachine<TContext extends MachineContext, TEvent extends EventObject
|
|
7
|
+
export declare class StateMachine<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TActor extends ProvidedActor, TAction extends ParameterizedObject, TGuard extends ParameterizedObject, TDelay extends string, TStateValue extends StateValue, TTag extends string, TInput, TOutput, TResolvedTypesMeta = ResolveTypegenMeta<TypegenDisabled, NoInfer<TEvent>, TActor, TAction, TGuard, TDelay, TTag>> implements ActorLogic<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>, TEvent, TInput, TODO> {
|
|
9
8
|
/**
|
|
10
9
|
* The raw config used to create the machine.
|
|
11
10
|
*/
|
|
12
|
-
config: MachineConfig<TContext, TEvent, any, any, any>;
|
|
13
|
-
getContext(input?: any): TContext;
|
|
14
|
-
private getContextAndActions;
|
|
11
|
+
config: MachineConfig<TContext, TEvent, any, any, any, any, any, any, TOutput, any>;
|
|
15
12
|
/**
|
|
16
13
|
* The machine's own version.
|
|
17
14
|
*/
|
|
18
15
|
version?: string;
|
|
19
|
-
|
|
20
|
-
* The string delimiter for serializing the path to a string. The default is "."
|
|
21
|
-
*/
|
|
22
|
-
delimiter: string;
|
|
23
|
-
options: MachineImplementationsSimplified<TContext, TEvent>;
|
|
24
|
-
types: MachineTypes<TContext, TEvent>;
|
|
16
|
+
implementations: MachineImplementationsSimplified<TContext, TEvent>;
|
|
25
17
|
__xstatenode: true;
|
|
26
18
|
idMap: Map<string, StateNode<TContext, TEvent>>;
|
|
27
19
|
root: StateNode<TContext, TEvent>;
|
|
28
20
|
id: string;
|
|
29
21
|
states: StateNode<TContext, TEvent>['states'];
|
|
30
|
-
events: Array<TEvent
|
|
22
|
+
events: Array<EventDescriptor<TEvent>>;
|
|
31
23
|
constructor(
|
|
32
24
|
/**
|
|
33
25
|
* The raw config used to create the machine.
|
|
34
26
|
*/
|
|
35
|
-
config: MachineConfig<TContext, TEvent, any, any, any>,
|
|
27
|
+
config: MachineConfig<TContext, TEvent, any, any, any, any, any, any, TOutput, any>, implementations?: MachineImplementationsSimplified<TContext, TEvent>);
|
|
36
28
|
/**
|
|
37
29
|
* Clones this state machine with the provided implementations
|
|
38
30
|
* and merges the `context` (if provided).
|
|
@@ -42,24 +34,25 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
42
34
|
*
|
|
43
35
|
* @returns A new `StateMachine` instance with the provided implementations.
|
|
44
36
|
*/
|
|
45
|
-
provide(implementations: InternalMachineImplementations<TContext,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
37
|
+
provide(implementations: InternalMachineImplementations<TContext, TResolvedTypesMeta, true>): StateMachine<TContext, TEvent, TChildren, TActor, TAction, TGuard, TDelay, TStateValue, TTag, TInput, TOutput, AreAllImplementationsAssumedToBeProvided<TResolvedTypesMeta> extends false ? MarkAllImplementationsAsProvided<TResolvedTypesMeta> : TResolvedTypesMeta>;
|
|
38
|
+
resolveState(config: {
|
|
39
|
+
value: StateValue;
|
|
40
|
+
context?: TContext;
|
|
41
|
+
historyValue?: HistoryValue<TContext, TEvent>;
|
|
42
|
+
status?: 'active' | 'done' | 'error' | 'stopped';
|
|
43
|
+
output?: TOutput;
|
|
44
|
+
error?: unknown;
|
|
45
|
+
} & (Equals<TContext, MachineContext> extends false ? {
|
|
46
|
+
context: unknown;
|
|
47
|
+
} : {})): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>;
|
|
55
48
|
/**
|
|
56
|
-
* Determines the next
|
|
49
|
+
* Determines the next snapshot given the current `snapshot` and received `event`.
|
|
57
50
|
* Calculates a full macrostep from all microsteps.
|
|
58
51
|
*
|
|
59
|
-
* @param
|
|
52
|
+
* @param snapshot The current snapshot
|
|
60
53
|
* @param event The received event
|
|
61
54
|
*/
|
|
62
|
-
transition(
|
|
55
|
+
transition(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>, event: TEvent, actorScope: ActorScope<typeof snapshot, TEvent>): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>;
|
|
63
56
|
/**
|
|
64
57
|
* Determines the next state given the current `state` and `event`.
|
|
65
58
|
* Calculates a microstep.
|
|
@@ -67,44 +60,23 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
67
60
|
* @param state The current state
|
|
68
61
|
* @param event The received event
|
|
69
62
|
*/
|
|
70
|
-
microstep(
|
|
71
|
-
getTransitionData(
|
|
63
|
+
microstep(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>, event: TEvent, actorScope: AnyActorScope): Array<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>>;
|
|
64
|
+
getTransitionData(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>>;
|
|
72
65
|
/**
|
|
73
66
|
* The initial state _before_ evaluating any microsteps.
|
|
74
67
|
* This "pre-initial" state is provided to initial actions executed in the initial state.
|
|
75
68
|
*/
|
|
76
69
|
private getPreInitialState;
|
|
77
|
-
/**
|
|
78
|
-
* The initial State instance, which includes all actions to be executed from
|
|
79
|
-
* entering the initial state.
|
|
80
|
-
*/
|
|
81
|
-
get initialState(): State<TContext, TEvent, TResolvedTypesMeta>;
|
|
82
70
|
/**
|
|
83
71
|
* Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
|
|
84
72
|
*/
|
|
85
|
-
|
|
86
|
-
start(
|
|
73
|
+
getInitialSnapshot(actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>, TEvent>, input?: TInput): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>;
|
|
74
|
+
start(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>): void;
|
|
87
75
|
getStateNodeById(stateId: string): StateNode<TContext, TEvent>;
|
|
88
76
|
get definition(): StateMachineDefinition<TContext, TEvent>;
|
|
89
77
|
toJSON(): StateMachineDefinition<TContext, TEvent>;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
getStatus(state: State<TContext, TEvent, TResolvedTypesMeta>): {
|
|
93
|
-
status: string;
|
|
94
|
-
data: any;
|
|
95
|
-
} | {
|
|
96
|
-
status: string;
|
|
97
|
-
data?: undefined;
|
|
98
|
-
};
|
|
99
|
-
restoreState(state: PersistedMachineState<State<TContext, TEvent, TResolvedTypesMeta>>, _actorCtx: ActorContext<TEvent, State<TContext, TEvent, TResolvedTypesMeta>>): State<TContext, TEvent, TResolvedTypesMeta>;
|
|
100
|
-
/**@deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
101
|
-
__TContext: TContext;
|
|
102
|
-
/** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
103
|
-
__TEvent: TEvent;
|
|
104
|
-
/** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
105
|
-
__TAction: TAction;
|
|
106
|
-
/** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
107
|
-
__TActorMap: TActorMap;
|
|
78
|
+
getPersistedSnapshot(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>, options?: unknown): Snapshot<unknown>;
|
|
79
|
+
restoreSnapshot(snapshot: Snapshot<unknown>, _actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>, TEvent>): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>;
|
|
108
80
|
/** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
109
81
|
__TResolvedTypesMeta: TResolvedTypesMeta;
|
|
110
82
|
}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import { MachineSnapshot } from "./State.js";
|
|
2
|
+
import type { StateMachine } from "./StateMachine.js";
|
|
3
|
+
import type { DelayedTransitionDefinition, EventObject, InitialTransitionDefinition, InvokeDefinition, MachineContext, Mapper, StateNodeConfig, StateNodeDefinition, StateNodesConfig, TransitionDefinition, TransitionDefinitionMap, TODO, UnknownAction, ParameterizedObject, AnyStateMachine, ProvidedActor, NonReducibleUnknown, EventDescriptor } from "./types.js";
|
|
4
4
|
interface StateNodeOptions<TContext extends MachineContext, TEvent extends EventObject> {
|
|
5
5
|
_key: string;
|
|
6
6
|
_parent?: StateNode<TContext, TEvent>;
|
|
7
|
-
_machine:
|
|
7
|
+
_machine: AnyStateMachine;
|
|
8
8
|
}
|
|
9
9
|
export declare class StateNode<TContext extends MachineContext = MachineContext, TEvent extends EventObject = EventObject> {
|
|
10
10
|
/**
|
|
11
11
|
* The raw config used to create the machine.
|
|
12
12
|
*/
|
|
13
|
-
config: StateNodeConfig<TContext, TEvent
|
|
13
|
+
config: StateNodeConfig<TContext, TEvent, TODO, // actions
|
|
14
|
+
TODO, // actors
|
|
15
|
+
TODO, // output
|
|
16
|
+
TODO, // guards
|
|
17
|
+
TODO, // delays
|
|
18
|
+
TODO>;
|
|
14
19
|
/**
|
|
15
20
|
* The relative key of the state node, which represents its location in the overall state value.
|
|
16
21
|
*/
|
|
@@ -47,11 +52,11 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
|
|
|
47
52
|
/**
|
|
48
53
|
* The action(s) to be executed upon entering the state node.
|
|
49
54
|
*/
|
|
50
|
-
entry:
|
|
55
|
+
entry: UnknownAction[];
|
|
51
56
|
/**
|
|
52
57
|
* The action(s) to be executed upon exiting the state node.
|
|
53
58
|
*/
|
|
54
|
-
exit:
|
|
59
|
+
exit: UnknownAction[];
|
|
55
60
|
/**
|
|
56
61
|
* The parent state node.
|
|
57
62
|
*/
|
|
@@ -59,28 +64,41 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
|
|
|
59
64
|
/**
|
|
60
65
|
* The root machine node.
|
|
61
66
|
*/
|
|
62
|
-
machine: StateMachine<TContext, TEvent, any,
|
|
67
|
+
machine: StateMachine<TContext, TEvent, any, // children
|
|
68
|
+
any, // actor
|
|
69
|
+
any, // action
|
|
70
|
+
any, // guard
|
|
71
|
+
any, // delay
|
|
72
|
+
any, // tag
|
|
73
|
+
any, // input
|
|
74
|
+
any, // output
|
|
75
|
+
any>;
|
|
63
76
|
/**
|
|
64
77
|
* The meta data associated with this state node, which will be returned in State instances.
|
|
65
78
|
*/
|
|
66
79
|
meta?: any;
|
|
67
80
|
/**
|
|
68
|
-
* The output data sent with the "done.state._id_" event if this is a final state node.
|
|
81
|
+
* The output data sent with the "xstate.done.state._id_" event if this is a final state node.
|
|
69
82
|
*/
|
|
70
|
-
output?: Mapper<
|
|
83
|
+
output?: Mapper<MachineContext, EventObject, unknown, EventObject> | NonReducibleUnknown;
|
|
71
84
|
/**
|
|
72
|
-
* The order this state node appears. Corresponds to the implicit
|
|
85
|
+
* The order this state node appears. Corresponds to the implicit document order.
|
|
73
86
|
*/
|
|
74
87
|
order: number;
|
|
75
88
|
description?: string;
|
|
76
89
|
tags: string[];
|
|
77
|
-
transitions:
|
|
90
|
+
transitions: Map<string, TransitionDefinition<TContext, TEvent>[]>;
|
|
78
91
|
always?: Array<TransitionDefinition<TContext, TEvent>>;
|
|
79
92
|
constructor(
|
|
80
93
|
/**
|
|
81
94
|
* The raw config used to create the machine.
|
|
82
95
|
*/
|
|
83
|
-
config: StateNodeConfig<TContext, TEvent
|
|
96
|
+
config: StateNodeConfig<TContext, TEvent, TODO, // actions
|
|
97
|
+
TODO, // actors
|
|
98
|
+
TODO, // output
|
|
99
|
+
TODO, // guards
|
|
100
|
+
TODO, // delays
|
|
101
|
+
TODO>, options: StateNodeOptions<TContext, TEvent>);
|
|
84
102
|
_initialize(): void;
|
|
85
103
|
/**
|
|
86
104
|
* The well-structured state node definition.
|
|
@@ -88,40 +106,25 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
|
|
|
88
106
|
get definition(): StateNodeDefinition<TContext, TEvent>;
|
|
89
107
|
toJSON(): StateNodeDefinition<TContext, TEvent>;
|
|
90
108
|
/**
|
|
91
|
-
* The
|
|
109
|
+
* The logic invoked as actors by this state node.
|
|
92
110
|
*/
|
|
93
|
-
get invoke(): Array<InvokeDefinition<TContext, TEvent>>;
|
|
111
|
+
get invoke(): Array<InvokeDefinition<TContext, TEvent, ProvidedActor, ParameterizedObject, ParameterizedObject, string>>;
|
|
94
112
|
/**
|
|
95
113
|
* The mapping of events to transitions.
|
|
96
114
|
*/
|
|
97
115
|
get on(): TransitionDefinitionMap<TContext, TEvent>;
|
|
98
116
|
get after(): Array<DelayedTransitionDefinition<TContext, TEvent>>;
|
|
99
117
|
get initial(): InitialTransitionDefinition<TContext, TEvent>;
|
|
100
|
-
|
|
101
|
-
* Returns `true` if this state node explicitly handles the given event.
|
|
102
|
-
*
|
|
103
|
-
* @param event The event in question
|
|
104
|
-
*/
|
|
105
|
-
handles(event: TEvent): boolean;
|
|
106
|
-
next(state: State<TContext, TEvent>, _event: SCXML.Event<TEvent>): TransitionDefinition<TContext, TEvent>[] | undefined;
|
|
107
|
-
/**
|
|
108
|
-
* The target state value of the history state node, if it exists. This represents the
|
|
109
|
-
* default state value to transition to if no history value exists yet.
|
|
110
|
-
*/
|
|
111
|
-
get target(): string | undefined;
|
|
112
|
-
/**
|
|
113
|
-
* All the state node IDs of this state node and its descendant state nodes.
|
|
114
|
-
*/
|
|
115
|
-
get stateIds(): string[];
|
|
118
|
+
next(snapshot: MachineSnapshot<TContext, TEvent, any, any, any, any>, event: TEvent): TransitionDefinition<TContext, TEvent>[] | undefined;
|
|
116
119
|
/**
|
|
117
120
|
* All the event types accepted by this state node and its descendants.
|
|
118
121
|
*/
|
|
119
|
-
get events(): Array<TEvent
|
|
122
|
+
get events(): Array<EventDescriptor<TEvent>>;
|
|
120
123
|
/**
|
|
121
124
|
* All the events that have transitions directly from this state node.
|
|
122
125
|
*
|
|
123
126
|
* Excludes any inert events.
|
|
124
127
|
*/
|
|
125
|
-
get ownEvents(): Array<TEvent
|
|
128
|
+
get ownEvents(): Array<EventDescriptor<TEvent>>;
|
|
126
129
|
}
|
|
127
130
|
export {};
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Spawner } from "../spawn.js";
|
|
2
|
+
import type { ActionArgs, AnyEventObject, Assigner, EventObject, LowInfer, MachineContext, ParameterizedObject, PropertyAssigner, ProvidedActor } from "../types.js";
|
|
3
|
+
export interface AssignArgs<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject, TActor extends ProvidedActor> extends ActionArgs<TContext, TExpressionEvent, TEvent> {
|
|
4
|
+
spawn: Spawner<TActor>;
|
|
5
|
+
}
|
|
6
|
+
export interface AssignAction<TContext extends MachineContext, TExpressionEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TEvent extends EventObject, TActor extends ProvidedActor> {
|
|
7
|
+
(args: ActionArgs<TContext, TExpressionEvent, TEvent>, params: TParams): void;
|
|
8
|
+
_out_TActor?: TActor;
|
|
9
|
+
}
|
|
2
10
|
/**
|
|
3
11
|
* Updates the current context of the machine.
|
|
4
12
|
*
|
|
5
13
|
* @param assignment An object that represents the partial context to update.
|
|
6
14
|
*/
|
|
7
|
-
export declare function assign<TContext extends MachineContext, TExpressionEvent extends
|
|
15
|
+
export declare function assign<TContext extends MachineContext, TExpressionEvent extends AnyEventObject = AnyEventObject, // TODO: consider using a stricter `EventObject` here
|
|
16
|
+
TParams extends ParameterizedObject['params'] | undefined = ParameterizedObject['params'] | undefined, TEvent extends EventObject = EventObject, TActor extends ProvidedActor = ProvidedActor>(assignment: Assigner<LowInfer<TContext>, TExpressionEvent, TParams, TEvent, TActor> | PropertyAssigner<LowInfer<TContext>, TExpressionEvent, TParams, TEvent, TActor>): AssignAction<TContext, TExpressionEvent, TParams, TEvent, TActor>;
|