xstate 5.0.0-alpha.0 → 5.0.0-alpha.2
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 +26 -15
- package/actions/dist/xstate-actions.cjs.dev.js +24 -25
- package/actions/dist/xstate-actions.cjs.prod.js +23 -24
- package/actions/dist/xstate-actions.esm.js +2 -2
- 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 +15 -7
- package/actions/package.json +5 -1
- package/actors/dist/xstate-actors.cjs.d.ts +1 -1
- package/actors/dist/xstate-actors.cjs.dev.js +14 -14
- package/actors/dist/xstate-actors.cjs.prod.js +13 -13
- package/actors/dist/xstate-actors.esm.js +2 -2
- 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.cjs.dev.js +1 -1
- package/dev/dist/xstate-dev.cjs.prod.js +0 -11
- package/dev/dist/xstate-dev.esm.js +1 -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-6b86876d.cjs.dev.js → actions-1e9778c2.cjs.dev.js} +2819 -3334
- package/dist/actions-9778f6fb.esm.js +4246 -0
- package/dist/actions-acb29ffe.cjs.prod.js +4262 -0
- 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 +110 -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 +8 -9
- package/dist/declarations/src/actions/send.d.ts +53 -55
- package/dist/declarations/src/actions/stop.d.ts +7 -8
- package/dist/declarations/src/actions.d.ts +47 -44
- package/dist/declarations/src/actors/callback.d.ts +8 -0
- package/dist/declarations/src/actors/index.d.ts +27 -0
- package/dist/declarations/src/actors/observable.d.ts +23 -0
- package/dist/declarations/src/actors/promise.d.ts +12 -0
- package/dist/declarations/src/actors/transition.d.ts +13 -0
- 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 +104 -147
- package/dist/declarations/src/mapState.d.ts +3 -3
- package/dist/declarations/src/memo.d.ts +2 -1
- 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/system.d.ts +2 -0
- package/dist/declarations/src/typegenTypes.d.ts +132 -132
- package/dist/declarations/src/types.d.ts +1008 -1026
- package/dist/declarations/src/utils.d.ts +58 -56
- package/dist/{index-20b364c4.esm.js → index-50bd0aff.esm.js} +0 -12
- package/dist/{index-2a564d03.cjs.dev.js → index-ebaab3c9.cjs.dev.js} +0 -12
- package/dist/xstate.cjs.dev.js +798 -100
- package/dist/xstate.cjs.prod.js +797 -99
- package/dist/xstate.esm.js +756 -55
- 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 +8 -8
- package/guards/dist/xstate-guards.cjs.prod.js +7 -7
- package/guards/dist/xstate-guards.esm.js +2 -2
- 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 +28 -6
- 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/actions-70094c93.cjs.prod.js +0 -4765
- package/dist/actions-ff512f16.esm.js +0 -4757
- package/dist/declarations/actions/ExecutableAction.d.ts +0 -23
- package/dist/declarations/src/ObservableActorRef.d.ts +0 -25
- package/dist/declarations/src/actors.d.ts +0 -38
- 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/dist/declarations/src/registry.d.ts +0 -8
- 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,44 +1,47 @@
|
|
|
1
|
-
import { Action, EventObject, SingleOrArray,
|
|
2
|
-
import * as actionTypes from './actionTypes';
|
|
3
|
-
export { send, sendTo,
|
|
4
|
-
export { stop } from './actions/stop';
|
|
5
|
-
export { log } from './actions/log';
|
|
6
|
-
export { cancel } from './actions/cancel';
|
|
7
|
-
export { assign } from './actions/assign';
|
|
8
|
-
export { raise } from './actions/raise';
|
|
9
|
-
export { choose } from './actions/choose';
|
|
10
|
-
export { actionTypes };
|
|
11
|
-
export declare const initEvent:
|
|
12
|
-
type: ActionTypes;
|
|
13
|
-
}>;
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
16
|
-
export declare
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* @param
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* @param
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* @param
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export declare function
|
|
44
|
-
export declare function
|
|
1
|
+
import { Action, EventObject, SingleOrArray, ActionFunction, ActionFunctionMap, ActionTypes, DoneEvent, ErrorPlatformEvent, DoneEventObject, MachineContext, BaseActionObject, SCXML } from './types.js';
|
|
2
|
+
import * as actionTypes from './actionTypes.js';
|
|
3
|
+
export { send, sendTo, sendParent, respond, forwardTo, escalate } from './actions/send.js';
|
|
4
|
+
export { stop } from './actions/stop.js';
|
|
5
|
+
export { log } from './actions/log.js';
|
|
6
|
+
export { cancel } from './actions/cancel.js';
|
|
7
|
+
export { assign } from './actions/assign.js';
|
|
8
|
+
export { raise } from './actions/raise.js';
|
|
9
|
+
export { choose } from './actions/choose.js';
|
|
10
|
+
export { actionTypes };
|
|
11
|
+
export declare const initEvent: SCXML.Event<{
|
|
12
|
+
type: ActionTypes;
|
|
13
|
+
}>;
|
|
14
|
+
export declare function resolveActionObject(actionObject: BaseActionObject, actionFunctionMap: ActionFunctionMap<any, any>): BaseActionObject;
|
|
15
|
+
export declare function toActionObject<TContext extends MachineContext, TEvent extends EventObject>(action: BaseActionObject | ActionFunction<TContext, TEvent> | string): BaseActionObject;
|
|
16
|
+
export declare const toActionObjects: <TContext extends MachineContext, TEvent extends EventObject>(action?: SingleOrArray<Action<TContext, TEvent, TEvent>> | undefined) => BaseActionObject[];
|
|
17
|
+
/**
|
|
18
|
+
* Returns an event type that represents an implicit event that
|
|
19
|
+
* is sent after the specified `delay`.
|
|
20
|
+
*
|
|
21
|
+
* @param delayRef The delay in milliseconds
|
|
22
|
+
* @param id The state node ID where this event is handled
|
|
23
|
+
*/
|
|
24
|
+
export declare function after(delayRef: number | string, id?: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Returns an event that represents that a final state node
|
|
27
|
+
* has been reached in the parent state node.
|
|
28
|
+
*
|
|
29
|
+
* @param id The final state node's parent state node `id`
|
|
30
|
+
* @param data The data to pass into the event
|
|
31
|
+
*/
|
|
32
|
+
export declare function done(id: string, data?: any): DoneEventObject;
|
|
33
|
+
/**
|
|
34
|
+
* Returns an event that represents that an invoked service has terminated.
|
|
35
|
+
*
|
|
36
|
+
* An invoked service is terminated when it has reached a top-level final state node,
|
|
37
|
+
* but not when it is canceled.
|
|
38
|
+
*
|
|
39
|
+
* @param invokeId The invoked service ID
|
|
40
|
+
* @param data The data to pass into the event
|
|
41
|
+
*/
|
|
42
|
+
export declare function doneInvoke(invokeId: string, data?: any): DoneEvent;
|
|
43
|
+
export declare function error(id: string, data?: any): ErrorPlatformEvent & string;
|
|
44
|
+
export declare function createInitEvent(input: any): SCXML.Event<{
|
|
45
|
+
type: ActionTypes.Init;
|
|
46
|
+
input: any;
|
|
47
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InvokeCallback, ActorBehavior, EventObject } from '../types';
|
|
2
|
+
export interface CallbackInternalState {
|
|
3
|
+
canceled: boolean;
|
|
4
|
+
receivers: Set<(e: EventObject) => void>;
|
|
5
|
+
dispose: void | (() => void) | Promise<any>;
|
|
6
|
+
input?: any;
|
|
7
|
+
}
|
|
8
|
+
export declare function fromCallback<TEvent extends EventObject>(invokeCallback: InvokeCallback): ActorBehavior<TEvent, undefined>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { EventObject, ActorRef, BaseActorRef } from '../types.js';
|
|
2
|
+
export { fromTransition } from './transition.js';
|
|
3
|
+
export { fromPromise } from './promise.js';
|
|
4
|
+
export { fromObservable, fromEventObservable } from './observable.js';
|
|
5
|
+
export { fromCallback } from './callback.js';
|
|
6
|
+
export declare const startSignalType = "xstate.init";
|
|
7
|
+
export declare const stopSignalType = "xstate.stop";
|
|
8
|
+
export declare const startSignal: StartSignal;
|
|
9
|
+
export declare const stopSignal: StopSignal;
|
|
10
|
+
export interface StartSignal {
|
|
11
|
+
type: 'xstate.init';
|
|
12
|
+
}
|
|
13
|
+
export interface StopSignal {
|
|
14
|
+
type: 'xstate.stop';
|
|
15
|
+
}
|
|
16
|
+
export type LifecycleSignal = StartSignal | StopSignal;
|
|
17
|
+
export type LifecycleSignalType = typeof startSignalType | typeof stopSignalType;
|
|
18
|
+
/**
|
|
19
|
+
* An object that expresses the behavior of an actor in reaction to received events,
|
|
20
|
+
* as well as an optionally emitted stream of values.
|
|
21
|
+
*
|
|
22
|
+
* @template TReceived The received event
|
|
23
|
+
* @template TSnapshot The emitted value
|
|
24
|
+
*/
|
|
25
|
+
export declare function isSignal(eventType: string): eventType is LifecycleSignalType;
|
|
26
|
+
export declare function isActorRef(item: any): item is ActorRef<any>;
|
|
27
|
+
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>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Subscribable, ActorBehavior, EventObject, Subscription } from '../types';
|
|
2
|
+
export interface ObservableInternalState<T> {
|
|
3
|
+
subscription: Subscription | undefined;
|
|
4
|
+
canceled: boolean;
|
|
5
|
+
status: 'active' | 'done' | 'error';
|
|
6
|
+
data: T | undefined;
|
|
7
|
+
input?: any;
|
|
8
|
+
}
|
|
9
|
+
export type ObservablePersistedState<T> = Omit<ObservableInternalState<T>, 'subscription'>;
|
|
10
|
+
export declare function fromObservable<T, TEvent extends EventObject>(observableCreator: ({ input }: {
|
|
11
|
+
input: any;
|
|
12
|
+
}) => Subscribable<T>): ActorBehavior<TEvent, T | undefined, ObservableInternalState<T>, ObservablePersistedState<T>>;
|
|
13
|
+
/**
|
|
14
|
+
* Creates an event observable behavior that listens to an observable
|
|
15
|
+
* that delivers event objects.
|
|
16
|
+
*
|
|
17
|
+
*
|
|
18
|
+
* @param lazyObservable A function that creates an observable
|
|
19
|
+
* @returns An event observable behavior
|
|
20
|
+
*/
|
|
21
|
+
export declare function fromEventObservable<T extends EventObject>(lazyObservable: ({ input }: {
|
|
22
|
+
input: any;
|
|
23
|
+
}) => Subscribable<T>): ActorBehavior<EventObject, T | undefined>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ActorBehavior } from '../types';
|
|
2
|
+
export interface PromiseInternalState<T> {
|
|
3
|
+
status: 'active' | 'error' | 'done';
|
|
4
|
+
canceled: boolean;
|
|
5
|
+
data: T | undefined;
|
|
6
|
+
input?: any;
|
|
7
|
+
}
|
|
8
|
+
export declare function fromPromise<T>(promiseCreator: ({ input }: {
|
|
9
|
+
input: any;
|
|
10
|
+
}) => PromiseLike<T>): ActorBehavior<{
|
|
11
|
+
type: string;
|
|
12
|
+
}, T | undefined, PromiseInternalState<T>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ActorBehavior, ActorContext, ActorSystem, EventObject } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns an actor behavior from a transition function and its initial state.
|
|
4
|
+
*
|
|
5
|
+
* A transition function is a function that takes the current state and an event and returns the next state.
|
|
6
|
+
*
|
|
7
|
+
* @param transition The transition function that returns the next state given the current state and event.
|
|
8
|
+
* @param initialState The initial state of the transition function.
|
|
9
|
+
* @returns An actor behavior
|
|
10
|
+
*/
|
|
11
|
+
export declare function fromTransition<TState, TEvent extends EventObject, TSystem extends ActorSystem<any>>(transition: (state: TState, event: TEvent, actorContext: ActorContext<TEvent, TState, TSystem>) => TState, initialState: TState | (({ input }: {
|
|
12
|
+
input: any;
|
|
13
|
+
}) => TState)): ActorBehavior<TEvent, TState, TState>;
|
|
@@ -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
|
-
|
|
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.js';
|
|
2
|
+
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.js';
|
|
2
|
+
import type { State } from './State.js';
|
|
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.js';
|
|
2
|
+
import { assign } from './actions/assign.js';
|
|
3
|
+
import { cancel } from './actions/cancel.js';
|
|
4
|
+
import { choose } from './actions/choose.js';
|
|
5
|
+
import { log } from './actions/log.js';
|
|
6
|
+
import { pure } from './actions/pure.js';
|
|
7
|
+
import { raise } from './actions/raise.js';
|
|
8
|
+
import { send } from './actions/send.js';
|
|
9
|
+
import { stop } from './actions/stop.js';
|
|
10
|
+
import { interpret, Interpreter, ActorStatus } from './interpreter.js';
|
|
11
|
+
import { createMachine } from './Machine.js';
|
|
12
|
+
import { mapState } from './mapState.js';
|
|
13
|
+
import { State } from './State.js';
|
|
14
|
+
import { StateNode } from './StateNode.js';
|
|
15
|
+
export { createSchema, t } from './schema.js';
|
|
16
|
+
export { SimulatedClock } from './SimulatedClock.js';
|
|
17
|
+
export { StateMachine } from './StateMachine.js';
|
|
18
|
+
export { getStateNodes } from './stateUtils.js';
|
|
19
|
+
export * from './typegenTypes.js';
|
|
20
|
+
export * from './types.js';
|
|
21
|
+
export { matchesState, pathToStateValue, toObserver, toSCXMLEvent } from './utils.js';
|
|
22
|
+
export { StateNode, State, mapState, actions, assign, send, sendTo, 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,104 @@
|
|
|
1
|
-
import { AnyStateMachine, InterpreterFrom } from '.';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
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
|
-
|
|
34
|
-
private
|
|
35
|
-
private
|
|
36
|
-
private
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* @param
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
*
|
|
66
|
-
* @param
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
*
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* @param
|
|
85
|
-
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
*
|
|
106
|
-
* This will also notify the `onStop` listeners.
|
|
107
|
-
*/
|
|
108
|
-
stop(): this;
|
|
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 { AnyStateMachine, EventFromBehavior, InterpreterFrom, PersistedStateFrom, SnapshotFrom, ActorSystem, AnyActorBehavior, RaiseActionObject } from './types.js';
|
|
2
|
+
import { AreAllImplementationsAssumedToBeProvided } from './typegenTypes.js';
|
|
3
|
+
import { ActorRef, DoneEvent, EventObject, InteropSubscribable, InterpreterOptions, Observer, SCXML, SendActionObject, Subscription } from './types.js';
|
|
4
|
+
import { symbolObservable } from './symbolObservable.js';
|
|
5
|
+
export type SnapshotListener<TBehavior extends AnyActorBehavior> = (state: SnapshotFrom<TBehavior>) => void;
|
|
6
|
+
export type EventListener<TEvent extends EventObject = EventObject> = (event: TEvent) => void;
|
|
7
|
+
export type Listener = () => void;
|
|
8
|
+
export 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
|
+
export declare class Interpreter<TBehavior extends AnyActorBehavior, TEvent extends EventObject = EventFromBehavior<TBehavior>> implements ActorRef<TEvent, SnapshotFrom<TBehavior>> {
|
|
19
|
+
behavior: TBehavior;
|
|
20
|
+
/**
|
|
21
|
+
* The current state of the interpreted behavior.
|
|
22
|
+
*/
|
|
23
|
+
private _state;
|
|
24
|
+
/**
|
|
25
|
+
* The clock that is responsible for setting and clearing timeouts, such as delayed events and transitions.
|
|
26
|
+
*/
|
|
27
|
+
clock: Clock;
|
|
28
|
+
options: Readonly<InterpreterOptions<TBehavior>>;
|
|
29
|
+
/**
|
|
30
|
+
* The unique identifier for this actor relative to its parent.
|
|
31
|
+
*/
|
|
32
|
+
id: string;
|
|
33
|
+
private mailbox;
|
|
34
|
+
private delayedEventsMap;
|
|
35
|
+
private observers;
|
|
36
|
+
private logger;
|
|
37
|
+
/**
|
|
38
|
+
* Whether the service is started.
|
|
39
|
+
*/
|
|
40
|
+
status: ActorStatus;
|
|
41
|
+
_parent?: ActorRef<any>;
|
|
42
|
+
ref: ActorRef<TEvent>;
|
|
43
|
+
private _actorContext;
|
|
44
|
+
private _systemId;
|
|
45
|
+
/**
|
|
46
|
+
* The globally unique process ID for this invocation.
|
|
47
|
+
*/
|
|
48
|
+
sessionId: string;
|
|
49
|
+
system: ActorSystem<any>;
|
|
50
|
+
private _doneEvent?;
|
|
51
|
+
src?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a new Interpreter instance (i.e., service) for the given behavior with the provided options, if any.
|
|
54
|
+
*
|
|
55
|
+
* @param behavior The behavior to be interpreted
|
|
56
|
+
* @param options Interpreter options
|
|
57
|
+
*/
|
|
58
|
+
constructor(behavior: TBehavior, options?: InterpreterOptions<TBehavior>);
|
|
59
|
+
private _initState;
|
|
60
|
+
private _deferred;
|
|
61
|
+
private update;
|
|
62
|
+
subscribe(observer: Observer<SnapshotFrom<TBehavior>>): Subscription;
|
|
63
|
+
subscribe(nextListener?: (state: SnapshotFrom<TBehavior>) => void, errorListener?: (error: any) => void, completeListener?: () => void): Subscription;
|
|
64
|
+
/**
|
|
65
|
+
* Adds a state listener that is notified when the statechart has reached its final state.
|
|
66
|
+
* @param listener The state listener
|
|
67
|
+
*/
|
|
68
|
+
onDone(listener: EventListener<DoneEvent>): this;
|
|
69
|
+
/**
|
|
70
|
+
* Starts the interpreter from the initial state
|
|
71
|
+
*/
|
|
72
|
+
start(): this;
|
|
73
|
+
private _process;
|
|
74
|
+
private _stop;
|
|
75
|
+
/**
|
|
76
|
+
* Stops the interpreter and unsubscribe all listeners.
|
|
77
|
+
*/
|
|
78
|
+
stop(): this;
|
|
79
|
+
private _complete;
|
|
80
|
+
private _stopProcedure;
|
|
81
|
+
/**
|
|
82
|
+
* Sends an event to the running interpreter to trigger a transition.
|
|
83
|
+
*
|
|
84
|
+
* @param event The event to send
|
|
85
|
+
*/
|
|
86
|
+
send(event: TEvent | SCXML.Event<TEvent>): void;
|
|
87
|
+
delaySend(sendAction: SendActionObject | RaiseActionObject<any, any, any>): void;
|
|
88
|
+
cancel(sendId: string | number): void;
|
|
89
|
+
private attachDevTools;
|
|
90
|
+
toJSON(): {
|
|
91
|
+
id: string;
|
|
92
|
+
};
|
|
93
|
+
getPersistedState(): PersistedStateFrom<TBehavior> | undefined;
|
|
94
|
+
[Symbol.observable](): InteropSubscribable<SnapshotFrom<TBehavior>>;
|
|
95
|
+
getSnapshot(): SnapshotFrom<TBehavior>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Creates a new Interpreter instance for the given machine with the provided options, if any.
|
|
99
|
+
*
|
|
100
|
+
* @param machine The machine to interpret
|
|
101
|
+
* @param options Interpreter options
|
|
102
|
+
*/
|
|
103
|
+
export declare function interpret<TMachine extends AnyStateMachine>(machine: AreAllImplementationsAssumedToBeProvided<TMachine['__TResolvedTypesMeta']> extends true ? TMachine : 'Some implementations missing', options?: InterpreterOptions<TMachine>): InterpreterFrom<TMachine>;
|
|
104
|
+
export declare function interpret<TBehavior extends AnyActorBehavior>(behavior: TBehavior, options?: InterpreterOptions<TBehavior>): Interpreter<TBehavior>;
|
|
@@ -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,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;
|