xstate 5.0.0-alpha.0 → 5.0.0-alpha.1
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 +23 -13
- package/actions/dist/xstate-actions.cjs.dev.js +22 -24
- package/actions/dist/xstate-actions.cjs.prod.js +22 -24
- package/actions/dist/xstate-actions.esm.js +1 -1
- package/actions/dist/xstate-actions.umd.min.js +2 -0
- package/actions/dist/xstate-actions.umd.min.js.map +1 -0
- package/actions/dynamicAction.ts +4 -4
- package/actions/package.json +5 -1
- package/actors/dist/xstate-actors.cjs.dev.js +12 -13
- package/actors/dist/xstate-actors.cjs.prod.js +12 -13
- package/actors/dist/xstate-actors.esm.js +1 -1
- package/actors/dist/xstate-actors.umd.min.js +2 -0
- package/actors/dist/xstate-actors.umd.min.js.map +1 -0
- package/actors/package.json +5 -1
- package/dev/dist/xstate-dev.umd.min.js +2 -0
- package/dev/dist/xstate-dev.umd.min.js.map +1 -0
- package/dev/package.json +5 -1
- package/dist/{actions-70094c93.cjs.prod.js → actions-7ea9280f.cjs.prod.js} +3118 -3209
- package/dist/{actions-6b86876d.cjs.dev.js → actions-b08d0da8.cjs.dev.js} +3105 -3202
- package/dist/{actions-ff512f16.esm.js → actions-b673cb13.esm.js} +3092 -3189
- package/dist/declarations/actions/dynamicAction.d.ts +5 -3
- package/dist/declarations/src/Machine.d.ts +4 -4
- package/dist/declarations/src/Mailbox.d.ts +12 -12
- package/dist/declarations/src/SimulatedClock.d.ts +16 -16
- package/dist/declarations/src/State.d.ts +97 -104
- package/dist/declarations/src/StateMachine.d.ts +120 -112
- package/dist/declarations/src/StateNode.d.ts +127 -127
- package/dist/declarations/src/actionTypes.d.ts +16 -17
- package/dist/declarations/src/actions/assign.d.ts +7 -7
- package/dist/declarations/src/actions/cancel.d.ts +10 -10
- package/dist/declarations/src/actions/choose.d.ts +3 -3
- package/dist/declarations/src/actions/invoke.d.ts +3 -3
- package/dist/declarations/src/actions/log.d.ts +11 -11
- package/dist/declarations/src/actions/pure.d.ts +3 -3
- package/dist/declarations/src/actions/raise.d.ts +9 -9
- package/dist/declarations/src/actions/send.d.ts +51 -55
- package/dist/declarations/src/actions/stop.d.ts +7 -8
- package/dist/declarations/src/actions.d.ts +43 -44
- package/dist/declarations/src/actors.d.ts +37 -38
- package/dist/declarations/src/constants.d.ts +5 -5
- package/dist/declarations/src/dev/index.d.ts +14 -14
- package/dist/declarations/src/environment.d.ts +1 -1
- package/dist/declarations/src/guards.d.ts +8 -9
- package/dist/declarations/src/index.d.ts +44 -47
- package/dist/declarations/src/interpreter.d.ts +108 -147
- package/dist/declarations/src/mapState.d.ts +3 -3
- package/dist/declarations/src/memo.d.ts +2 -1
- package/dist/declarations/src/registry.d.ts +8 -8
- package/dist/declarations/src/schema.d.ts +2 -2
- package/dist/declarations/src/spawn.d.ts +2 -2
- package/dist/declarations/src/stateUtils.d.ts +70 -85
- package/dist/declarations/src/symbolObservable.d.ts +1 -0
- package/dist/declarations/src/typegenTypes.d.ts +132 -132
- package/dist/declarations/src/types.d.ts +1001 -1026
- package/dist/declarations/src/utils.d.ts +54 -56
- package/dist/xstate.cjs.dev.js +856 -80
- package/dist/xstate.cjs.prod.js +856 -80
- package/dist/xstate.esm.js +815 -35
- package/dist/xstate.umd.min.js +2 -0
- package/dist/xstate.umd.min.js.map +1 -0
- package/guards/dist/xstate-guards.cjs.dev.js +7 -7
- package/guards/dist/xstate-guards.cjs.prod.js +7 -7
- package/guards/dist/xstate-guards.esm.js +1 -1
- package/guards/dist/xstate-guards.umd.min.js +2 -0
- package/guards/dist/xstate-guards.umd.min.js.map +1 -0
- package/guards/package.json +5 -1
- package/package.json +25 -2
- package/CHANGELOG.md +0 -1986
- package/actions/ExecutableAction.ts +0 -58
- package/dist/Machine-9ce74c11.cjs.dev.js +0 -755
- package/dist/Machine-dca041dc.cjs.prod.js +0 -749
- package/dist/Machine-fb2f47f5.esm.js +0 -751
- package/dist/declarations/actions/ExecutableAction.d.ts +0 -23
- package/dist/declarations/src/ObservableActorRef.d.ts +0 -25
- package/dist/declarations/src/match.d.ts +0 -5
- package/dist/declarations/src/model.d.ts +0 -5
- package/dist/declarations/src/model.types.d.ts +0 -53
- package/model/dist/xstate-model.cjs.d.ts +0 -1
- package/model/dist/xstate-model.cjs.dev.js +0 -41
- package/model/dist/xstate-model.cjs.js +0 -7
- package/model/dist/xstate-model.cjs.prod.js +0 -41
- package/model/dist/xstate-model.esm.js +0 -37
- package/model/package.json +0 -4
|
@@ -1,38 +1,37 @@
|
|
|
1
|
-
import type { InvokeCallback, Subscribable,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @param
|
|
7
|
-
* @
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export declare type
|
|
22
|
-
export declare function fromCallback<TEvent extends EventObject>(invokeCallback: InvokeCallback): Behavior<TEvent, undefined>;
|
|
23
|
-
export declare function fromPromise<T>(lazyPromise: Lazy<PromiseLike<T>>): Behavior<{
|
|
24
|
-
type: string;
|
|
25
|
-
}, T | undefined>;
|
|
26
|
-
export declare function fromObservable<T, TEvent extends EventObject>(lazyObservable: Lazy<Subscribable<T>>): Behavior<TEvent, T | undefined>;
|
|
27
|
-
/**
|
|
28
|
-
* Creates an event observable behavior that listens to an observable
|
|
29
|
-
* that delivers event objects.
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @param lazyObservable A function that creates an observable
|
|
33
|
-
* @returns An event observable behavior
|
|
34
|
-
*/
|
|
35
|
-
export declare function fromEventObservable<T extends EventObject>(lazyObservable: Lazy<Subscribable<T>>): Behavior<EventObject, T | undefined>;
|
|
36
|
-
export declare function
|
|
37
|
-
export declare function
|
|
38
|
-
export declare function toActorRef<TEvent extends EventObject, TSnapshot = any, TActorRefLike extends BaseActorRef<TEvent> = BaseActorRef<TEvent>>(actorRefLike: TActorRefLike): ActorRef<TEvent, TSnapshot> & Omit<TActorRefLike, keyof ActorRef<any, any>>;
|
|
1
|
+
import type { InvokeCallback, Subscribable, Lazy, Behavior, ActorContext, EventObject, ActorRef, BaseActorRef } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns an actor behavior from a reducer and its initial state.
|
|
4
|
+
*
|
|
5
|
+
* @param transition The pure reducer that returns the next state given the current state and event.
|
|
6
|
+
* @param initialState The initial state of the reducer.
|
|
7
|
+
* @returns An actor behavior
|
|
8
|
+
*/
|
|
9
|
+
export declare function fromReducer<TState, TEvent extends EventObject>(transition: (state: TState, event: TEvent, actorContext: ActorContext<TEvent, TState>) => TState, initialState: TState): Behavior<TEvent, TState>;
|
|
10
|
+
export declare const startSignalType = "xstate.init";
|
|
11
|
+
export declare const stopSignalType = "xstate.stop";
|
|
12
|
+
export declare const startSignal: StartSignal;
|
|
13
|
+
export declare const stopSignal: StopSignal;
|
|
14
|
+
export interface StartSignal {
|
|
15
|
+
type: 'xstate.init';
|
|
16
|
+
}
|
|
17
|
+
export interface StopSignal {
|
|
18
|
+
type: 'xstate.stop';
|
|
19
|
+
}
|
|
20
|
+
export declare type LifecycleSignal = StartSignal | StopSignal;
|
|
21
|
+
export declare type LifecycleSignalType = typeof startSignalType | typeof stopSignalType;
|
|
22
|
+
export declare function fromCallback<TEvent extends EventObject>(invokeCallback: InvokeCallback): Behavior<TEvent, undefined>;
|
|
23
|
+
export declare function fromPromise<T>(lazyPromise: Lazy<PromiseLike<T>>): Behavior<{
|
|
24
|
+
type: string;
|
|
25
|
+
}, T | undefined>;
|
|
26
|
+
export declare function fromObservable<T, TEvent extends EventObject>(lazyObservable: Lazy<Subscribable<T>>): Behavior<TEvent, T | undefined>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates an event observable behavior that listens to an observable
|
|
29
|
+
* that delivers event objects.
|
|
30
|
+
*
|
|
31
|
+
*
|
|
32
|
+
* @param lazyObservable A function that creates an observable
|
|
33
|
+
* @returns An event observable behavior
|
|
34
|
+
*/
|
|
35
|
+
export declare function fromEventObservable<T extends EventObject>(lazyObservable: Lazy<Subscribable<T>>): Behavior<EventObject, T | undefined>;
|
|
36
|
+
export declare function isActorRef(item: any): item is ActorRef<any>;
|
|
37
|
+
export declare function toActorRef<TEvent extends EventObject, TSnapshot = any, TActorRefLike extends BaseActorRef<TEvent> = BaseActorRef<TEvent>>(actorRefLike: TActorRefLike): ActorRef<TEvent, TSnapshot> & Omit<TActorRefLike, keyof ActorRef<any, any>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare const STATE_DELIMITER = ".";
|
|
2
|
-
export declare const TARGETLESS_KEY = "";
|
|
3
|
-
export declare const NULL_EVENT = "";
|
|
4
|
-
export declare const STATE_IDENTIFIER = "#";
|
|
5
|
-
export declare const WILDCARD = "*";
|
|
1
|
+
export declare const STATE_DELIMITER = ".";
|
|
2
|
+
export declare const TARGETLESS_KEY = "";
|
|
3
|
+
export declare const NULL_EVENT = "";
|
|
4
|
+
export declare const STATE_IDENTIFIER = "#";
|
|
5
|
+
export declare const WILDCARD = "*";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { AnyInterpreter, DevToolsAdapter } from '../types';
|
|
2
|
-
declare type ServiceListener = (service: AnyInterpreter) => void;
|
|
3
|
-
export interface XStateDevInterface {
|
|
4
|
-
register: (service: AnyInterpreter) => void;
|
|
5
|
-
unregister: (service: AnyInterpreter) => void;
|
|
6
|
-
onRegister: (listener: ServiceListener) => {
|
|
7
|
-
unsubscribe: () => void;
|
|
8
|
-
};
|
|
9
|
-
services: Set<AnyInterpreter>;
|
|
10
|
-
}
|
|
11
|
-
export declare function getGlobal(): typeof globalThis | undefined;
|
|
12
|
-
export declare function registerService(service: AnyInterpreter): void;
|
|
13
|
-
export declare const devToolsAdapter: DevToolsAdapter;
|
|
14
|
-
export {};
|
|
1
|
+
import { AnyInterpreter, DevToolsAdapter } from '../types';
|
|
2
|
+
declare type ServiceListener = (service: AnyInterpreter) => void;
|
|
3
|
+
export interface XStateDevInterface {
|
|
4
|
+
register: (service: AnyInterpreter) => void;
|
|
5
|
+
unregister: (service: AnyInterpreter) => void;
|
|
6
|
+
onRegister: (listener: ServiceListener) => {
|
|
7
|
+
unsubscribe: () => void;
|
|
8
|
+
};
|
|
9
|
+
services: Set<AnyInterpreter>;
|
|
10
|
+
}
|
|
11
|
+
export declare function getGlobal(): typeof globalThis | undefined;
|
|
12
|
+
export declare function registerService(service: AnyInterpreter): void;
|
|
13
|
+
export declare const devToolsAdapter: DevToolsAdapter;
|
|
14
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const IS_PRODUCTION: boolean;
|
|
1
|
+
export declare const IS_PRODUCTION: boolean;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { EventObject, StateValue, BooleanGuardDefinition, GuardConfig, GuardDefinition, SCXML, GuardPredicate, MachineContext } from './types';
|
|
2
|
-
import type { State } from './State';
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function toGuardDefinition<TContext extends MachineContext, TEvent extends EventObject>(guardConfig: GuardConfig<TContext, TEvent>, getPredicate?: (guardType: string) => GuardPredicate<TContext, TEvent>): GuardDefinition<TContext, TEvent>;
|
|
1
|
+
import type { EventObject, StateValue, BooleanGuardDefinition, GuardConfig, GuardDefinition, SCXML, GuardPredicate, MachineContext } from './types';
|
|
2
|
+
import type { State } from './State';
|
|
3
|
+
export declare function stateIn<TContext extends MachineContext, TEvent extends EventObject>(stateValue: StateValue): GuardDefinition<TContext, TEvent>;
|
|
4
|
+
export declare function not<TContext extends MachineContext, TEvent extends EventObject>(guard: GuardConfig<TContext, TEvent>): BooleanGuardDefinition<TContext, TEvent>;
|
|
5
|
+
export declare function and<TContext extends MachineContext, TEvent extends EventObject>(guards: Array<GuardConfig<TContext, TEvent>>): BooleanGuardDefinition<TContext, TEvent>;
|
|
6
|
+
export declare function or<TContext extends MachineContext, TEvent extends EventObject>(guards: Array<GuardConfig<TContext, TEvent>>): BooleanGuardDefinition<TContext, TEvent>;
|
|
7
|
+
export declare function evaluateGuard<TContext extends MachineContext, TEvent extends EventObject>(guard: GuardDefinition<TContext, TEvent>, context: TContext, _event: SCXML.Event<TEvent>, state: State<TContext, TEvent>): boolean;
|
|
8
|
+
export declare function toGuardDefinition<TContext extends MachineContext, TEvent extends EventObject>(guardConfig: GuardConfig<TContext, TEvent>, getPredicate?: (guardType: string) => GuardPredicate<TContext, TEvent>): GuardDefinition<TContext, TEvent>;
|
|
@@ -1,47 +1,44 @@
|
|
|
1
|
-
import { after, done, doneInvoke, escalate, forwardTo, respond, sendParent, sendTo
|
|
2
|
-
import { assign } from './actions/assign';
|
|
3
|
-
import { cancel } from './actions/cancel';
|
|
4
|
-
import { choose } from './actions/choose';
|
|
5
|
-
import { log } from './actions/log';
|
|
6
|
-
import { pure } from './actions/pure';
|
|
7
|
-
import { raise } from './actions/raise';
|
|
8
|
-
import { send } from './actions/send';
|
|
9
|
-
import { stop } from './actions/stop';
|
|
10
|
-
import { interpret, Interpreter,
|
|
11
|
-
import { createMachine } from './Machine';
|
|
12
|
-
import { mapState } from './mapState';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
readonly observable: symbol;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
import { after, done, doneInvoke, escalate, forwardTo, respond, sendParent, sendTo } from './actions';
|
|
2
|
+
import { assign } from './actions/assign';
|
|
3
|
+
import { cancel } from './actions/cancel';
|
|
4
|
+
import { choose } from './actions/choose';
|
|
5
|
+
import { log } from './actions/log';
|
|
6
|
+
import { pure } from './actions/pure';
|
|
7
|
+
import { raise } from './actions/raise';
|
|
8
|
+
import { send } from './actions/send';
|
|
9
|
+
import { stop } from './actions/stop';
|
|
10
|
+
import { interpret, Interpreter, ActorStatus } from './interpreter';
|
|
11
|
+
import { createMachine } from './Machine';
|
|
12
|
+
import { mapState } from './mapState';
|
|
13
|
+
import { State } from './State';
|
|
14
|
+
import { StateNode } from './StateNode';
|
|
15
|
+
export { createSchema, t } from './schema';
|
|
16
|
+
export { SimulatedClock } from './SimulatedClock';
|
|
17
|
+
export { StateMachine } from './StateMachine';
|
|
18
|
+
export { getStateNodes } from './stateUtils';
|
|
19
|
+
export * from './typegenTypes';
|
|
20
|
+
export * from './types';
|
|
21
|
+
export { matchesState, pathToStateValue, toObserver, toSCXMLEvent } from './utils';
|
|
22
|
+
export { StateNode, State, mapState, actions, assign, send, sendParent, forwardTo, interpret, Interpreter, ActorStatus as InterpreterStatus, doneInvoke, createMachine };
|
|
23
|
+
declare const actions: {
|
|
24
|
+
raise: typeof raise;
|
|
25
|
+
send: typeof send;
|
|
26
|
+
sendParent: typeof sendParent;
|
|
27
|
+
sendTo: typeof sendTo;
|
|
28
|
+
log: typeof log;
|
|
29
|
+
cancel: typeof cancel;
|
|
30
|
+
stop: typeof stop;
|
|
31
|
+
assign: typeof assign;
|
|
32
|
+
after: typeof after;
|
|
33
|
+
done: typeof done;
|
|
34
|
+
respond: typeof respond;
|
|
35
|
+
forwardTo: typeof forwardTo;
|
|
36
|
+
escalate: typeof escalate;
|
|
37
|
+
choose: typeof choose;
|
|
38
|
+
pure: typeof pure;
|
|
39
|
+
};
|
|
40
|
+
declare global {
|
|
41
|
+
interface SymbolConstructor {
|
|
42
|
+
readonly observable: symbol;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -1,147 +1,108 @@
|
|
|
1
|
-
import { AnyStateMachine, InterpreterFrom } from '
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export declare type
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
id: string;
|
|
34
|
-
private mailbox;
|
|
35
|
-
private delayedEventsMap;
|
|
36
|
-
private
|
|
37
|
-
private
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
*
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Sends an event to the running interpreter to trigger a transition.
|
|
111
|
-
*
|
|
112
|
-
* An array of events (batched) can be sent as well, which will send all
|
|
113
|
-
* batched events to the running interpreter. The listeners will be
|
|
114
|
-
* notified only **once** when all events are processed.
|
|
115
|
-
*
|
|
116
|
-
* @param event The event(s) to send
|
|
117
|
-
*/
|
|
118
|
-
send: PayloadSender<TEvent>;
|
|
119
|
-
private sendTo;
|
|
120
|
-
/**
|
|
121
|
-
* Returns the next state given the interpreter's current state and the event.
|
|
122
|
-
*
|
|
123
|
-
* This is a pure method that does _not_ update the interpreter's state.
|
|
124
|
-
*
|
|
125
|
-
* @param event The event to determine the next state
|
|
126
|
-
*/
|
|
127
|
-
nextState(event: Event<TEvent> | SCXML.Event<TEvent>): State<TContext, TEvent, TResolvedTypesMeta>;
|
|
128
|
-
private forward;
|
|
129
|
-
private defer;
|
|
130
|
-
private cancel;
|
|
131
|
-
private getActionFunction;
|
|
132
|
-
private exec;
|
|
133
|
-
private stopChild;
|
|
134
|
-
private attachDevTools;
|
|
135
|
-
toJSON(): {
|
|
136
|
-
id: string;
|
|
137
|
-
};
|
|
138
|
-
[Symbol.observable](): InteropSubscribable<State<TContext, TEvent, TResolvedTypesMeta>>;
|
|
139
|
-
getSnapshot(): State<TContext, TEvent, TResolvedTypesMeta>;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Creates a new Interpreter instance for the given machine with the provided options, if any.
|
|
143
|
-
*
|
|
144
|
-
* @param machine The machine to interpret
|
|
145
|
-
* @param options Interpreter options
|
|
146
|
-
*/
|
|
147
|
-
export declare function interpret<TMachine extends AnyStateMachine>(machine: AreAllImplementationsAssumedToBeProvided<TMachine['__TResolvedTypesMeta']> extends true ? TMachine : 'Some implementations missing', options?: InterpreterOptions): InterpreterFrom<TMachine>;
|
|
1
|
+
import type { AnyActorRef, AnyStateMachine, Behavior, EventFromBehavior, InterpreterFrom, SnapshotFrom } from './types';
|
|
2
|
+
import { AreAllImplementationsAssumedToBeProvided } from './typegenTypes';
|
|
3
|
+
import { ActorRef, DoneEvent, EventObject, InteropSubscribable, InterpreterOptions, Observer, SCXML, SendActionObject, StateValue, Subscription } from './types';
|
|
4
|
+
import { symbolObservable } from './symbolObservable';
|
|
5
|
+
export declare type SnapshotListener<TBehavior extends Behavior<any, any>> = (state: SnapshotFrom<TBehavior>) => void;
|
|
6
|
+
export declare type EventListener<TEvent extends EventObject = EventObject> = (event: TEvent) => void;
|
|
7
|
+
export declare type Listener = () => void;
|
|
8
|
+
export declare type ErrorListener = (error: any) => void;
|
|
9
|
+
export interface Clock {
|
|
10
|
+
setTimeout(fn: (...args: any[]) => void, timeout: number): any;
|
|
11
|
+
clearTimeout(id: any): void;
|
|
12
|
+
}
|
|
13
|
+
export declare enum ActorStatus {
|
|
14
|
+
NotStarted = 0,
|
|
15
|
+
Running = 1,
|
|
16
|
+
Stopped = 2
|
|
17
|
+
}
|
|
18
|
+
declare type InternalStateFrom<TBehavior extends Behavior<any, any, any>> = TBehavior extends Behavior<infer _, infer __, infer TInternalState> ? TInternalState : never;
|
|
19
|
+
export declare class Interpreter<TBehavior extends Behavior<any, any>, TEvent extends EventObject = EventFromBehavior<TBehavior>> implements ActorRef<TEvent, SnapshotFrom<TBehavior>> {
|
|
20
|
+
behavior: TBehavior;
|
|
21
|
+
/**
|
|
22
|
+
* The current state of the interpreted behavior.
|
|
23
|
+
*/
|
|
24
|
+
private _state?;
|
|
25
|
+
/**
|
|
26
|
+
* The clock that is responsible for setting and clearing timeouts, such as delayed events and transitions.
|
|
27
|
+
*/
|
|
28
|
+
clock: Clock;
|
|
29
|
+
options: Readonly<InterpreterOptions>;
|
|
30
|
+
/**
|
|
31
|
+
* The unique identifier for this actor relative to its parent.
|
|
32
|
+
*/
|
|
33
|
+
id: string;
|
|
34
|
+
private mailbox;
|
|
35
|
+
private delayedEventsMap;
|
|
36
|
+
private observers;
|
|
37
|
+
private logger;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the service is started.
|
|
40
|
+
*/
|
|
41
|
+
status: ActorStatus;
|
|
42
|
+
_parent?: ActorRef<any>;
|
|
43
|
+
ref: ActorRef<TEvent>;
|
|
44
|
+
private _actorContext;
|
|
45
|
+
/**
|
|
46
|
+
* The globally unique process ID for this invocation.
|
|
47
|
+
*/
|
|
48
|
+
sessionId: string;
|
|
49
|
+
_forwardTo: Set<AnyActorRef>;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a new Interpreter instance (i.e., service) for the given behavior with the provided options, if any.
|
|
52
|
+
*
|
|
53
|
+
* @param behavior The behavior to be interpreted
|
|
54
|
+
* @param options Interpreter options
|
|
55
|
+
*/
|
|
56
|
+
constructor(behavior: TBehavior, options?: InterpreterOptions);
|
|
57
|
+
private _deferred;
|
|
58
|
+
private _getInitialState;
|
|
59
|
+
private update;
|
|
60
|
+
onTransition(listener: SnapshotListener<TBehavior>): this;
|
|
61
|
+
subscribe(observer: Observer<SnapshotFrom<TBehavior>>): Subscription;
|
|
62
|
+
subscribe(nextListener?: (state: SnapshotFrom<TBehavior>) => void, errorListener?: (error: any) => void, completeListener?: () => void): Subscription;
|
|
63
|
+
/**
|
|
64
|
+
* Adds a state listener that is notified when the statechart has reached its final state.
|
|
65
|
+
* @param listener The state listener
|
|
66
|
+
*/
|
|
67
|
+
onDone(listener: EventListener<DoneEvent>): this;
|
|
68
|
+
/**
|
|
69
|
+
* Starts the interpreter from the given state, or the initial state.
|
|
70
|
+
* @param initialState The state to start the statechart from
|
|
71
|
+
*/
|
|
72
|
+
start(initialState?: InternalStateFrom<TBehavior> | StateValue): this;
|
|
73
|
+
private _process;
|
|
74
|
+
/**
|
|
75
|
+
* Stops the interpreter and unsubscribe all listeners.
|
|
76
|
+
*/
|
|
77
|
+
stop(): this;
|
|
78
|
+
private _complete;
|
|
79
|
+
private _stop;
|
|
80
|
+
/**
|
|
81
|
+
* Sends an event to the running interpreter to trigger a transition.
|
|
82
|
+
*
|
|
83
|
+
* An array of events (batched) can be sent as well, which will send all
|
|
84
|
+
* batched events to the running interpreter. The listeners will be
|
|
85
|
+
* notified only **once** when all events are processed.
|
|
86
|
+
*
|
|
87
|
+
* @param event The event(s) to send
|
|
88
|
+
*/
|
|
89
|
+
send(event: TEvent | SCXML.Event<TEvent>): void;
|
|
90
|
+
private forward;
|
|
91
|
+
delaySend(sendAction: SendActionObject): void;
|
|
92
|
+
cancel(sendId: string | number): void;
|
|
93
|
+
private attachDevTools;
|
|
94
|
+
toJSON(): {
|
|
95
|
+
id: string;
|
|
96
|
+
};
|
|
97
|
+
[Symbol.observable](): InteropSubscribable<SnapshotFrom<TBehavior>>;
|
|
98
|
+
getSnapshot(): SnapshotFrom<TBehavior>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Creates a new Interpreter instance for the given machine with the provided options, if any.
|
|
102
|
+
*
|
|
103
|
+
* @param machine The machine to interpret
|
|
104
|
+
* @param options Interpreter options
|
|
105
|
+
*/
|
|
106
|
+
export declare function interpret<TMachine extends AnyStateMachine>(machine: AreAllImplementationsAssumedToBeProvided<TMachine['__TResolvedTypesMeta']> extends true ? TMachine : 'Some implementations missing', options?: InterpreterOptions): InterpreterFrom<TMachine>;
|
|
107
|
+
export declare function interpret<TBehavior extends Behavior<any, any>>(behavior: TBehavior, options?: InterpreterOptions): Interpreter<TBehavior>;
|
|
108
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function mapState(stateMap: {
|
|
2
|
-
[stateId: string]: any;
|
|
3
|
-
}, stateId: string): any;
|
|
1
|
+
export declare function mapState(stateMap: {
|
|
2
|
+
[stateId: string]: any;
|
|
3
|
+
}, stateId: string): any;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export declare function memo<T>(object: any, key: string, fn: () => T): T;
|
|
1
|
+
export declare function memo<T>(object: any, key: string, fn: () => T): T;
|
|
2
|
+
export declare function evict(object: any, key?: string): void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ActorRef } from './types';
|
|
2
|
-
export interface Registry {
|
|
3
|
-
bookId(): string;
|
|
4
|
-
register(id: string, actor: ActorRef<any>): string;
|
|
5
|
-
get(id: string): ActorRef<any> | undefined;
|
|
6
|
-
free(id: string): void;
|
|
7
|
-
}
|
|
8
|
-
export declare const registry: Registry;
|
|
1
|
+
import { ActorRef } from './types';
|
|
2
|
+
export interface Registry {
|
|
3
|
+
bookId(): string;
|
|
4
|
+
register(id: string, actor: ActorRef<any>): string;
|
|
5
|
+
get(id: string): ActorRef<any> | undefined;
|
|
6
|
+
free(id: string): void;
|
|
7
|
+
}
|
|
8
|
+
export declare const registry: Registry;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function createSchema<T>(schema?: any): T;
|
|
2
|
-
export declare const t: typeof createSchema;
|
|
1
|
+
export declare function createSchema<T>(schema?: any): T;
|
|
2
|
+
export declare const t: typeof createSchema;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { MachineContext, EventObject, SCXML, InvokeActionObject, AnyStateMachine, Spawner } from '.';
|
|
2
|
-
export declare function createSpawner<TContext extends MachineContext, TEvent extends EventObject>(machine: AnyStateMachine, context: TContext, _event: SCXML.Event<TEvent>, mutCapturedActions: InvokeActionObject[]): Spawner;
|
|
1
|
+
import { MachineContext, EventObject, SCXML, InvokeActionObject, AnyStateMachine, Spawner } from '.';
|
|
2
|
+
export declare function createSpawner<TContext extends MachineContext, TEvent extends EventObject>(machine: AnyStateMachine, context: TContext, _event: SCXML.Event<TEvent>, mutCapturedActions: InvokeActionObject[]): Spawner;
|