xstate 4.35.2 → 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 +25 -16
- package/actions/dist/xstate-actions.cjs.d.ts +1 -0
- package/actions/dist/xstate-actions.cjs.dev.js +30 -0
- package/actions/dist/xstate-actions.cjs.js +7 -0
- package/actions/dist/xstate-actions.cjs.prod.js +30 -0
- package/actions/dist/xstate-actions.esm.js +2 -0
- 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 +34 -0
- package/actions/package.json +8 -0
- package/actors/dist/xstate-actors.cjs.d.ts +1 -0
- package/actors/dist/xstate-actors.cjs.dev.js +20 -0
- package/actors/dist/xstate-actors.cjs.js +7 -0
- package/actors/dist/xstate-actors.cjs.prod.js +20 -0
- package/actors/dist/xstate-actors.esm.js +2 -0
- 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 +8 -0
- package/dev/dist/xstate-dev.cjs.d.ts +1 -0
- package/dev/dist/xstate-dev.cjs.dev.js +11 -0
- package/dev/dist/xstate-dev.cjs.js +7 -0
- package/{lib/devTools.js → dev/dist/xstate-dev.cjs.prod.js} +17 -10
- package/dev/dist/xstate-dev.esm.js +1 -0
- 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 +8 -0
- package/dist/actions-7ea9280f.cjs.prod.js +4674 -0
- package/dist/actions-b08d0da8.cjs.dev.js +4718 -0
- package/dist/actions-b673cb13.esm.js +4660 -0
- package/dist/declarations/actions/dynamicAction.d.ts +5 -0
- package/dist/declarations/src/Machine.d.ts +4 -0
- package/dist/declarations/src/Mailbox.d.ts +12 -0
- package/{es → dist/declarations/src}/SimulatedClock.d.ts +16 -17
- package/dist/declarations/src/State.d.ts +97 -0
- package/dist/declarations/src/StateMachine.d.ts +120 -0
- package/dist/declarations/src/StateNode.d.ts +127 -0
- package/{es → dist/declarations/src}/actionTypes.d.ts +16 -20
- package/dist/declarations/src/actions/assign.d.ts +7 -0
- package/dist/declarations/src/actions/cancel.d.ts +10 -0
- package/dist/declarations/src/actions/choose.d.ts +3 -0
- package/dist/declarations/src/actions/invoke.d.ts +3 -0
- package/dist/declarations/src/actions/log.d.ts +11 -0
- package/dist/declarations/src/actions/pure.d.ts +3 -0
- package/dist/declarations/src/actions/raise.d.ts +9 -0
- package/dist/declarations/src/actions/send.d.ts +51 -0
- package/dist/declarations/src/actions/stop.d.ts +7 -0
- package/dist/declarations/src/actions.d.ts +43 -0
- package/dist/declarations/src/actors.d.ts +37 -0
- package/dist/declarations/src/constants.d.ts +5 -0
- package/{lib/devTools.d.ts → dist/declarations/src/dev/index.d.ts} +14 -14
- package/{es → dist/declarations/src}/environment.d.ts +1 -2
- package/dist/declarations/src/guards.d.ts +8 -0
- package/dist/declarations/src/index.d.ts +44 -0
- package/dist/declarations/src/interpreter.d.ts +108 -0
- package/{es → dist/declarations/src}/mapState.d.ts +3 -4
- package/dist/declarations/src/memo.d.ts +2 -0
- package/dist/declarations/src/registry.d.ts +8 -0
- package/{es → dist/declarations/src}/schema.d.ts +2 -3
- package/dist/declarations/src/spawn.d.ts +2 -0
- package/dist/declarations/src/stateUtils.d.ts +70 -0
- package/dist/declarations/src/symbolObservable.d.ts +1 -0
- package/{lib → dist/declarations/src}/typegenTypes.d.ts +132 -133
- package/dist/declarations/src/types.d.ts +1001 -0
- package/dist/declarations/src/utils.d.ts +54 -0
- package/{es/devTools.js → dist/index-20b364c4.esm.js} +18 -6
- package/dist/index-2a564d03.cjs.dev.js +64 -0
- package/dist/xstate.cjs.d.ts +1 -0
- package/dist/xstate.cjs.dev.js +993 -0
- package/dist/xstate.cjs.js +7 -0
- package/dist/xstate.cjs.prod.js +993 -0
- package/dist/xstate.esm.js +952 -0
- package/dist/xstate.umd.min.js +2 -0
- package/dist/xstate.umd.min.js.map +1 -0
- package/guards/dist/xstate-guards.cjs.d.ts +1 -0
- package/guards/dist/xstate-guards.cjs.dev.js +15 -0
- package/guards/dist/xstate-guards.cjs.js +7 -0
- package/guards/dist/xstate-guards.cjs.prod.js +15 -0
- package/guards/dist/xstate-guards.esm.js +2 -0
- 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 +8 -0
- package/invoke/package.json +4 -0
- package/package.json +44 -30
- package/dist/xstate.interpreter.js +0 -15
- package/dist/xstate.js +0 -15
- package/dist/xstate.web.js +0 -15
- package/es/Actor.d.ts +0 -25
- package/es/Actor.js +0 -99
- package/es/Machine.d.ts +0 -12
- package/es/Machine.js +0 -21
- package/es/SimulatedClock.js +0 -81
- package/es/State.d.ts +0 -123
- package/es/State.js +0 -274
- package/es/StateNode.d.ts +0 -282
- package/es/StateNode.js +0 -1587
- package/es/_virtual/_tslib.js +0 -78
- package/es/actionTypes.js +0 -22
- package/es/actions.d.ts +0 -157
- package/es/actions.js +0 -630
- package/es/behaviors.d.ts +0 -37
- package/es/behaviors.js +0 -131
- package/es/constants.d.ts +0 -6
- package/es/constants.js +0 -6
- package/es/devTools.d.ts +0 -14
- package/es/each.d.ts +0 -4
- package/es/each.js +0 -13
- package/es/environment.js +0 -3
- package/es/index.d.ts +0 -22
- package/es/index.js +0 -25
- package/es/interpreter.d.ts +0 -217
- package/es/interpreter.js +0 -1488
- package/es/invoke.d.ts +0 -11
- package/es/invokeUtils.d.ts +0 -7
- package/es/invokeUtils.js +0 -40
- package/es/json.d.ts +0 -31
- package/es/json.js +0 -86
- package/es/mapState.js +0 -32
- package/es/match.d.ts +0 -9
- package/es/match.js +0 -34
- package/es/model.d.ts +0 -8
- package/es/model.js +0 -50
- package/es/model.types.d.ts +0 -56
- package/es/patterns.d.ts +0 -14
- package/es/patterns.js +0 -48
- package/es/registry.d.ts +0 -9
- package/es/registry.js +0 -19
- package/es/scheduler.d.ts +0 -17
- package/es/scheduler.js +0 -79
- package/es/schema.js +0 -6
- package/es/scxml.d.ts +0 -6
- package/es/serviceScope.d.ts +0 -4
- package/es/serviceScope.js +0 -16
- package/es/stateUtils.d.ts +0 -18
- package/es/stateUtils.js +0 -262
- package/es/typegenTypes.d.ts +0 -133
- package/es/types.d.ts +0 -1040
- package/es/types.js +0 -33
- package/es/utils.d.ts +0 -72
- package/es/utils.js +0 -622
- package/es/waitFor.d.ts +0 -34
- package/es/waitFor.js +0 -73
- package/lib/Actor.d.ts +0 -25
- package/lib/Actor.js +0 -108
- package/lib/Machine.d.ts +0 -12
- package/lib/Machine.js +0 -26
- package/lib/SimulatedClock.d.ts +0 -17
- package/lib/SimulatedClock.js +0 -85
- package/lib/State.d.ts +0 -123
- package/lib/State.js +0 -282
- package/lib/StateNode.d.ts +0 -282
- package/lib/StateNode.js +0 -1591
- package/lib/_virtual/_tslib.js +0 -85
- package/lib/actionTypes.d.ts +0 -20
- package/lib/actionTypes.js +0 -43
- package/lib/actions.d.ts +0 -157
- package/lib/actions.js +0 -662
- package/lib/behaviors.d.ts +0 -37
- package/lib/behaviors.js +0 -137
- package/lib/constants.d.ts +0 -6
- package/lib/constants.js +0 -13
- package/lib/each.d.ts +0 -4
- package/lib/each.js +0 -17
- package/lib/environment.d.ts +0 -2
- package/lib/environment.js +0 -7
- package/lib/index.d.ts +0 -22
- package/lib/index.js +0 -64
- package/lib/interpreter.d.ts +0 -217
- package/lib/interpreter.js +0 -1494
- package/lib/invoke.d.ts +0 -11
- package/lib/invoke.js +0 -20
- package/lib/invokeUtils.d.ts +0 -7
- package/lib/invokeUtils.js +0 -45
- package/lib/json.d.ts +0 -31
- package/lib/json.js +0 -94
- package/lib/mapState.d.ts +0 -4
- package/lib/mapState.js +0 -36
- package/lib/match.d.ts +0 -9
- package/lib/match.js +0 -38
- package/lib/model.d.ts +0 -8
- package/lib/model.js +0 -54
- package/lib/model.types.d.ts +0 -56
- package/lib/model.types.js +0 -2
- package/lib/patterns.d.ts +0 -14
- package/lib/patterns.js +0 -53
- package/lib/registry.d.ts +0 -9
- package/lib/registry.js +0 -23
- package/lib/scheduler.d.ts +0 -17
- package/lib/scheduler.js +0 -83
- package/lib/schema.d.ts +0 -3
- package/lib/schema.js +0 -11
- package/lib/scxml.d.ts +0 -6
- package/lib/scxml.js +0 -350
- package/lib/serviceScope.d.ts +0 -4
- package/lib/serviceScope.js +0 -21
- package/lib/stateUtils.d.ts +0 -18
- package/lib/stateUtils.js +0 -277
- package/lib/typegenTypes.js +0 -2
- package/lib/types.d.ts +0 -1040
- package/lib/types.js +0 -35
- package/lib/utils.d.ts +0 -72
- package/lib/utils.js +0 -669
- package/lib/waitFor.d.ts +0 -34
- package/lib/waitFor.js +0 -77
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { AnyInterpreter } from '
|
|
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
|
|
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,2 +1 @@
|
|
|
1
|
-
export declare const IS_PRODUCTION: boolean;
|
|
2
|
-
//# sourceMappingURL=environment.d.ts.map
|
|
1
|
+
export declare const IS_PRODUCTION: boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
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>;
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
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,4 +1,3 @@
|
|
|
1
|
-
export declare function mapState(stateMap: {
|
|
2
|
-
[stateId: string]: any;
|
|
3
|
-
}, stateId: string): any;
|
|
4
|
-
//# sourceMappingURL=mapState.d.ts.map
|
|
1
|
+
export declare function mapState(stateMap: {
|
|
2
|
+
[stateId: string]: any;
|
|
3
|
+
}, stateId: string): any;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export declare function createSchema<T>(schema?: any): T;
|
|
2
|
-
export declare const t: typeof createSchema;
|
|
3
|
-
//# sourceMappingURL=schema.d.ts.map
|
|
1
|
+
export declare function createSchema<T>(schema?: any): T;
|
|
2
|
+
export declare const t: typeof createSchema;
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { BaseActionObject, EventObject, StateValue, TransitionConfig, TransitionDefinition, SingleOrArray, SCXML, StateValueMap, InitialTransitionConfig, MachineContext } from './types';
|
|
2
|
+
import { State } from './State';
|
|
3
|
+
import { NULL_EVENT } from './constants';
|
|
4
|
+
import type { StateNode } from './StateNode';
|
|
5
|
+
import { ActorContext, AnyHistoryValue, AnyState, AnyStateMachine, AnyStateNode, AnyTransitionDefinition, DelayedTransitionDefinition, InitialTransitionDefinition, StateFromMachine } from '.';
|
|
6
|
+
declare type Configuration<TContext extends MachineContext, TE extends EventObject> = Iterable<StateNode<TContext, TE>>;
|
|
7
|
+
declare type AnyConfiguration = Configuration<any, any>;
|
|
8
|
+
declare type AdjList = Map<AnyStateNode, Array<AnyStateNode>>;
|
|
9
|
+
export declare function getConfiguration(stateNodes: Iterable<AnyStateNode>): Set<AnyStateNode>;
|
|
10
|
+
export declare function getAdjList<TContext extends MachineContext, TE extends EventObject>(configuration: Configuration<TContext, TE>): AdjList;
|
|
11
|
+
export declare function getStateValue(rootNode: AnyStateNode, configuration: AnyConfiguration): StateValue;
|
|
12
|
+
export declare function isInFinalState(configuration: Array<AnyStateNode>, stateNode?: AnyStateNode): boolean;
|
|
13
|
+
export declare const isStateId: (str: string) => boolean;
|
|
14
|
+
export declare function getCandidates<TEvent extends EventObject>(stateNode: StateNode<any, TEvent>, receivedEventType: TEvent['type'],
|
|
15
|
+
/**
|
|
16
|
+
* If `true`, will use SCXML event partial token matching semantics
|
|
17
|
+
* without the need for the ".*" suffix
|
|
18
|
+
*/
|
|
19
|
+
partialMatch?: boolean): Array<TransitionDefinition<any, TEvent>>;
|
|
20
|
+
/**
|
|
21
|
+
* All delayed transitions from the config.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getDelayedTransitions<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode): Array<DelayedTransitionDefinition<TContext, TEvent>>;
|
|
24
|
+
export declare function formatTransition<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, transitionConfig: TransitionConfig<TContext, TEvent> & {
|
|
25
|
+
event: TEvent['type'] | typeof NULL_EVENT | '*';
|
|
26
|
+
}): AnyTransitionDefinition;
|
|
27
|
+
export declare function formatTransitions<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode): Array<AnyTransitionDefinition>;
|
|
28
|
+
export declare function formatInitialTransition<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, _target: SingleOrArray<string> | InitialTransitionConfig<TContext, TEvent>): InitialTransitionDefinition<TContext, TEvent>;
|
|
29
|
+
export declare function resolveTarget(stateNode: AnyStateNode, targets: Array<string | AnyStateNode> | undefined): Array<AnyStateNode> | undefined;
|
|
30
|
+
export declare function getInitialStateNodes(stateNode: AnyStateNode): Array<AnyStateNode>;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the child state node from its relative `stateKey`, or throws.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getStateNode(stateNode: AnyStateNode, stateKey: string): AnyStateNode;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the state nodes represented by the current state value.
|
|
37
|
+
*
|
|
38
|
+
* @param state The state value or State instance
|
|
39
|
+
*/
|
|
40
|
+
export declare function getStateNodes<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, state: StateValue | State<TContext, TEvent>): Array<AnyStateNode>;
|
|
41
|
+
export declare function transitionAtomicNode<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, stateValue: string, state: State<TContext, TEvent>, _event: SCXML.Event<TEvent>): Array<TransitionDefinition<TContext, TEvent>> | undefined;
|
|
42
|
+
export declare function transitionCompoundNode<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, stateValue: StateValueMap, state: State<TContext, TEvent>, _event: SCXML.Event<TEvent>): Array<TransitionDefinition<TContext, TEvent>> | undefined;
|
|
43
|
+
export declare function transitionParallelNode<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, stateValue: StateValueMap, state: State<TContext, TEvent>, _event: SCXML.Event<TEvent>): Array<TransitionDefinition<TContext, TEvent>> | undefined;
|
|
44
|
+
export declare function transitionNode<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, stateValue: StateValue, state: State<TContext, TEvent, any>, _event: SCXML.Event<TEvent>): Array<TransitionDefinition<TContext, TEvent>> | undefined;
|
|
45
|
+
export declare function removeConflictingTransitions(enabledTransitions: Array<AnyTransitionDefinition>, configuration: Set<AnyStateNode>, historyValue: AnyHistoryValue): Array<AnyTransitionDefinition>;
|
|
46
|
+
/**
|
|
47
|
+
* https://www.w3.org/TR/scxml/#microstepProcedure
|
|
48
|
+
*
|
|
49
|
+
* @private
|
|
50
|
+
* @param transitions
|
|
51
|
+
* @param currentState
|
|
52
|
+
* @param mutConfiguration
|
|
53
|
+
*/
|
|
54
|
+
export declare function microstep<TContext extends MachineContext, TEvent extends EventObject>(transitions: Array<TransitionDefinition<TContext, TEvent>>, currentState: State<TContext, TEvent, any>, actorCtx: ActorContext<any, any> | undefined, scxmlEvent: SCXML.Event<TEvent>): State<TContext, TEvent, any>;
|
|
55
|
+
export declare function resolveActionsAndContext<TContext extends MachineContext, TEvent extends EventObject>(actions: BaseActionObject[], scxmlEvent: SCXML.Event<TEvent>, currentState: State<TContext, TEvent, any>, actorCtx: ActorContext<any, any> | undefined): {
|
|
56
|
+
nextState: AnyState;
|
|
57
|
+
};
|
|
58
|
+
export declare function macrostep<TMachine extends AnyStateMachine>(state: StateFromMachine<TMachine>, scxmlEvent: SCXML.Event<TMachine['__TEvent']>, actorCtx: ActorContext<any, any> | undefined): {
|
|
59
|
+
state: typeof state;
|
|
60
|
+
microstates: Array<typeof state>;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Resolves a partial state value with its full representation in the state node's machine.
|
|
64
|
+
*
|
|
65
|
+
* @param stateValue The partial state value to resolve.
|
|
66
|
+
*/
|
|
67
|
+
export declare function resolveStateValue(rootNode: AnyStateNode, stateValue: StateValue): StateValue;
|
|
68
|
+
export declare function stateValuesEqual(a: StateValue | undefined, b: StateValue | undefined): boolean;
|
|
69
|
+
export declare function getInitialConfiguration(rootNode: AnyStateNode): AnyStateNode[];
|
|
70
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const symbolObservable: typeof Symbol.observable;
|
|
@@ -1,133 +1,132 @@
|
|
|
1
|
-
import { BaseActionObject, EventObject, IndexByType, IsNever, Prop, Values, IsAny,
|
|
2
|
-
export interface TypegenDisabled {
|
|
3
|
-
'@@xstate/typegen': false;
|
|
4
|
-
}
|
|
5
|
-
export interface TypegenEnabled {
|
|
6
|
-
'@@xstate/typegen': true;
|
|
7
|
-
}
|
|
8
|
-
export interface TypegenMeta extends TypegenEnabled {
|
|
9
|
-
/**
|
|
10
|
-
* Allows you to specify all the results of state.matches
|
|
11
|
-
*/
|
|
12
|
-
matchesStates: string | {};
|
|
13
|
-
/**
|
|
14
|
-
* Allows you to specify all tags used by the machine
|
|
15
|
-
*/
|
|
16
|
-
tags: string;
|
|
17
|
-
/**
|
|
18
|
-
* Allows you to specify all the missing implementations
|
|
19
|
-
* of the machine
|
|
20
|
-
*/
|
|
21
|
-
missingImplementations: {
|
|
22
|
-
actions: string;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* A map for the internal events of the machine.
|
|
29
|
-
*
|
|
30
|
-
* key: 'done.invoke.
|
|
31
|
-
* value: {
|
|
32
|
-
* type: 'done.invoke.
|
|
33
|
-
* data: unknown;
|
|
34
|
-
* __tip: 'Declare the type in event types!';
|
|
35
|
-
* }
|
|
36
|
-
*/
|
|
37
|
-
internalEvents: {};
|
|
38
|
-
/**
|
|
39
|
-
* Maps the name of the
|
|
40
|
-
* of the done.invoke action
|
|
41
|
-
*
|
|
42
|
-
* key: 'invokeSrc'
|
|
43
|
-
* value: 'done.invoke.invokeName'
|
|
44
|
-
*/
|
|
45
|
-
invokeSrcNameMap: Record<string, string>;
|
|
46
|
-
/**
|
|
47
|
-
* Keeps track of which events lead to which
|
|
48
|
-
* actions.
|
|
49
|
-
*
|
|
50
|
-
* Key: 'EVENT_NAME'
|
|
51
|
-
* Value: 'actionName' | 'otherActionName'
|
|
52
|
-
*/
|
|
53
|
-
eventsCausingActions: Record<string, string>;
|
|
54
|
-
/**
|
|
55
|
-
* Keeps track of which events lead to which
|
|
56
|
-
* delays.
|
|
57
|
-
*
|
|
58
|
-
* Key: 'EVENT_NAME'
|
|
59
|
-
* Value: 'delayName' | 'otherDelayName'
|
|
60
|
-
*/
|
|
61
|
-
eventsCausingDelays: Record<string, string>;
|
|
62
|
-
/**
|
|
63
|
-
* Keeps track of which events lead to which
|
|
64
|
-
* guards.
|
|
65
|
-
*
|
|
66
|
-
* Key: 'EVENT_NAME'
|
|
67
|
-
* Value: 'guardName' | 'otherGuardName'
|
|
68
|
-
*/
|
|
69
|
-
eventsCausingGuards: Record<string, string>;
|
|
70
|
-
/**
|
|
71
|
-
* Keeps track of which events lead to which
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* Key: 'EVENT_NAME'
|
|
75
|
-
* Value: '
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
export interface ResolvedTypegenMeta extends TypegenMeta {
|
|
80
|
-
resolved: TypegenMeta & {
|
|
81
|
-
indexedActions: Record<string, BaseActionObject>;
|
|
82
|
-
indexedEvents: Record<string, EventObject>;
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
export declare type TypegenConstraint = TypegenEnabled | TypegenDisabled;
|
|
86
|
-
export declare type AreAllImplementationsAssumedToBeProvided<TResolvedTypesMeta, TMissingImplementations = Prop<Prop<TResolvedTypesMeta, 'resolved'>, 'missingImplementations'>> = IsAny<TResolvedTypesMeta> extends true ? true : TResolvedTypesMeta extends TypegenEnabled ? IsNever<Values<{
|
|
87
|
-
[K in keyof TMissingImplementations]: TMissingImplementations[K];
|
|
88
|
-
}>> extends true ? true : false : true;
|
|
89
|
-
interface AllImplementationsProvided {
|
|
90
|
-
missingImplementations: {
|
|
91
|
-
actions: never;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
export interface MarkAllImplementationsAsProvided<TResolvedTypesMeta> {
|
|
98
|
-
'@@xstate/typegen': Prop<TResolvedTypesMeta, '@@xstate/typegen'>;
|
|
99
|
-
resolved: Prop<TResolvedTypesMeta, 'resolved'> & AllImplementationsProvided;
|
|
100
|
-
}
|
|
101
|
-
declare type
|
|
102
|
-
type: TEventType;
|
|
103
|
-
} & Prop<
|
|
104
|
-
declare type
|
|
105
|
-
[K in keyof TInvokeSrcNameMap]:
|
|
106
|
-
}[keyof TInvokeSrcNameMap], EventObject>;
|
|
107
|
-
declare type MergeWithInternalEvents<TIndexedEvents, TInternalEvents> = TIndexedEvents & Pick<TInternalEvents, Exclude<keyof TInternalEvents, keyof TIndexedEvents>>;
|
|
108
|
-
declare type AllowAllEvents = {
|
|
109
|
-
eventsCausingActions: Record<string, string>;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
};
|
|
114
|
-
export interface ResolveTypegenMeta<TTypesMeta extends TypegenConstraint, TEvent extends EventObject, TAction extends BaseActionObject,
|
|
115
|
-
'@@xstate/typegen': TTypesMeta['@@xstate/typegen'];
|
|
116
|
-
resolved: {
|
|
117
|
-
enabled: TTypesMeta & {
|
|
118
|
-
indexedActions: IndexByType<TAction>;
|
|
119
|
-
indexedEvents: MergeWithInternalEvents<IndexByType<(string extends TEvent['type'] ? never : TEvent) |
|
|
120
|
-
};
|
|
121
|
-
disabled: TypegenDisabled & AllImplementationsProvided & AllowAllEvents & {
|
|
122
|
-
indexedActions: IndexByType<TAction>;
|
|
123
|
-
indexedEvents: Record<string, TEvent> & {
|
|
124
|
-
__XSTATE_ALLOW_ANY_INVOKE_DATA_HACK__: {
|
|
125
|
-
data: any;
|
|
126
|
-
};
|
|
127
|
-
};
|
|
128
|
-
invokeSrcNameMap: Record<string, '__XSTATE_ALLOW_ANY_INVOKE_DATA_HACK__'>;
|
|
129
|
-
};
|
|
130
|
-
}[IsNever<TTypesMeta> extends true ? 'disabled' : TTypesMeta extends TypegenEnabled ? 'enabled' : 'disabled'];
|
|
131
|
-
}
|
|
132
|
-
export {};
|
|
133
|
-
//# sourceMappingURL=typegenTypes.d.ts.map
|
|
1
|
+
import { BaseActionObject, EventObject, IndexByType, IsNever, Prop, Values, IsAny, ActorMap, Cast } from './types';
|
|
2
|
+
export interface TypegenDisabled {
|
|
3
|
+
'@@xstate/typegen': false;
|
|
4
|
+
}
|
|
5
|
+
export interface TypegenEnabled {
|
|
6
|
+
'@@xstate/typegen': true;
|
|
7
|
+
}
|
|
8
|
+
export interface TypegenMeta extends TypegenEnabled {
|
|
9
|
+
/**
|
|
10
|
+
* Allows you to specify all the results of state.matches
|
|
11
|
+
*/
|
|
12
|
+
matchesStates: string | {};
|
|
13
|
+
/**
|
|
14
|
+
* Allows you to specify all tags used by the machine
|
|
15
|
+
*/
|
|
16
|
+
tags: string;
|
|
17
|
+
/**
|
|
18
|
+
* Allows you to specify all the missing implementations
|
|
19
|
+
* of the machine
|
|
20
|
+
*/
|
|
21
|
+
missingImplementations: {
|
|
22
|
+
actions: string;
|
|
23
|
+
actors: string;
|
|
24
|
+
delays: string;
|
|
25
|
+
guards: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* A map for the internal events of the machine.
|
|
29
|
+
*
|
|
30
|
+
* key: 'done.invoke.myActor'
|
|
31
|
+
* value: {
|
|
32
|
+
* type: 'done.invoke.myActor';
|
|
33
|
+
* data: unknown;
|
|
34
|
+
* __tip: 'Declare the type in event types!';
|
|
35
|
+
* }
|
|
36
|
+
*/
|
|
37
|
+
internalEvents: {};
|
|
38
|
+
/**
|
|
39
|
+
* Maps the name of the actor to the event type
|
|
40
|
+
* of the done.invoke action
|
|
41
|
+
*
|
|
42
|
+
* key: 'invokeSrc'
|
|
43
|
+
* value: 'done.invoke.invokeName'
|
|
44
|
+
*/
|
|
45
|
+
invokeSrcNameMap: Record<string, string>;
|
|
46
|
+
/**
|
|
47
|
+
* Keeps track of which events lead to which
|
|
48
|
+
* actions.
|
|
49
|
+
*
|
|
50
|
+
* Key: 'EVENT_NAME'
|
|
51
|
+
* Value: 'actionName' | 'otherActionName'
|
|
52
|
+
*/
|
|
53
|
+
eventsCausingActions: Record<string, string>;
|
|
54
|
+
/**
|
|
55
|
+
* Keeps track of which events lead to which
|
|
56
|
+
* delays.
|
|
57
|
+
*
|
|
58
|
+
* Key: 'EVENT_NAME'
|
|
59
|
+
* Value: 'delayName' | 'otherDelayName'
|
|
60
|
+
*/
|
|
61
|
+
eventsCausingDelays: Record<string, string>;
|
|
62
|
+
/**
|
|
63
|
+
* Keeps track of which events lead to which
|
|
64
|
+
* guards.
|
|
65
|
+
*
|
|
66
|
+
* Key: 'EVENT_NAME'
|
|
67
|
+
* Value: 'guardName' | 'otherGuardName'
|
|
68
|
+
*/
|
|
69
|
+
eventsCausingGuards: Record<string, string>;
|
|
70
|
+
/**
|
|
71
|
+
* Keeps track of which events lead to which
|
|
72
|
+
* actors.
|
|
73
|
+
*
|
|
74
|
+
* Key: 'EVENT_NAME'
|
|
75
|
+
* Value: 'actorName' | 'otherActorName'
|
|
76
|
+
*/
|
|
77
|
+
eventsCausingActors: Record<string, string>;
|
|
78
|
+
}
|
|
79
|
+
export interface ResolvedTypegenMeta extends TypegenMeta {
|
|
80
|
+
resolved: TypegenMeta & {
|
|
81
|
+
indexedActions: Record<string, BaseActionObject>;
|
|
82
|
+
indexedEvents: Record<string, EventObject>;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export declare type TypegenConstraint = TypegenEnabled | TypegenDisabled;
|
|
86
|
+
export declare type AreAllImplementationsAssumedToBeProvided<TResolvedTypesMeta, TMissingImplementations = Prop<Prop<TResolvedTypesMeta, 'resolved'>, 'missingImplementations'>> = IsAny<TResolvedTypesMeta> extends true ? true : TResolvedTypesMeta extends TypegenEnabled ? IsNever<Values<{
|
|
87
|
+
[K in keyof TMissingImplementations]: TMissingImplementations[K];
|
|
88
|
+
}>> extends true ? true : false : true;
|
|
89
|
+
interface AllImplementationsProvided {
|
|
90
|
+
missingImplementations: {
|
|
91
|
+
actions: never;
|
|
92
|
+
actors: never;
|
|
93
|
+
delays: never;
|
|
94
|
+
guards: never;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export interface MarkAllImplementationsAsProvided<TResolvedTypesMeta> {
|
|
98
|
+
'@@xstate/typegen': Prop<TResolvedTypesMeta, '@@xstate/typegen'>;
|
|
99
|
+
resolved: Prop<TResolvedTypesMeta, 'resolved'> & AllImplementationsProvided;
|
|
100
|
+
}
|
|
101
|
+
declare type GenerateActorEvent<TActorName, TEventType, TActorMap extends ActorMap> = TEventType extends any ? {
|
|
102
|
+
type: TEventType;
|
|
103
|
+
} & Prop<TActorMap, TActorName> : never;
|
|
104
|
+
declare type GenerateActorEvents<TActorMap extends ActorMap, TInvokeSrcNameMap> = string extends keyof TActorMap ? never : Cast<{
|
|
105
|
+
[K in keyof TInvokeSrcNameMap]: GenerateActorEvent<K, TInvokeSrcNameMap[K], TActorMap>;
|
|
106
|
+
}[keyof TInvokeSrcNameMap], EventObject>;
|
|
107
|
+
declare type MergeWithInternalEvents<TIndexedEvents, TInternalEvents> = TIndexedEvents & Pick<TInternalEvents, Exclude<keyof TInternalEvents, keyof TIndexedEvents>>;
|
|
108
|
+
declare type AllowAllEvents = {
|
|
109
|
+
eventsCausingActions: Record<string, string>;
|
|
110
|
+
eventsCausingActors: Record<string, string>;
|
|
111
|
+
eventsCausingDelays: Record<string, string>;
|
|
112
|
+
eventsCausingGuards: Record<string, string>;
|
|
113
|
+
};
|
|
114
|
+
export interface ResolveTypegenMeta<TTypesMeta extends TypegenConstraint, TEvent extends EventObject, TAction extends BaseActionObject, TActorMap extends ActorMap> {
|
|
115
|
+
'@@xstate/typegen': TTypesMeta['@@xstate/typegen'];
|
|
116
|
+
resolved: {
|
|
117
|
+
enabled: TTypesMeta & {
|
|
118
|
+
indexedActions: IndexByType<TAction>;
|
|
119
|
+
indexedEvents: MergeWithInternalEvents<IndexByType<(string extends TEvent['type'] ? never : TEvent) | GenerateActorEvents<TActorMap, Prop<TTypesMeta, 'invokeSrcNameMap'>>>, Prop<TTypesMeta, 'internalEvents'>>;
|
|
120
|
+
};
|
|
121
|
+
disabled: TypegenDisabled & AllImplementationsProvided & AllowAllEvents & {
|
|
122
|
+
indexedActions: IndexByType<TAction>;
|
|
123
|
+
indexedEvents: Record<string, TEvent> & {
|
|
124
|
+
__XSTATE_ALLOW_ANY_INVOKE_DATA_HACK__: {
|
|
125
|
+
data: any;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
invokeSrcNameMap: Record<string, '__XSTATE_ALLOW_ANY_INVOKE_DATA_HACK__'>;
|
|
129
|
+
};
|
|
130
|
+
}[IsNever<TTypesMeta> extends true ? 'disabled' : TTypesMeta extends TypegenEnabled ? 'enabled' : 'disabled'];
|
|
131
|
+
}
|
|
132
|
+
export {};
|