import { Clock, Interpreter } from './interpreter'; import { Model } from './model.types'; import { State } from './State'; import { StateNode } from './StateNode'; import { MarkAllImplementationsAsProvided, TypegenDisabled, ResolveTypegenMeta, TypegenConstraint, AreAllImplementationsAssumedToBeProvided, TypegenEnabled } from './typegenTypes'; export declare type AnyFunction = (...args: any[]) => any; declare type ReturnTypeOrValue = T extends AnyFunction ? ReturnType : T; export declare type IsNever = [T] extends [never] ? true : false; export declare type Compute = { [K in keyof A]: A[K]; } & unknown; export declare type Prop = K extends keyof T ? T[K] : never; export declare type Values = T[keyof T]; export declare type Merge = Omit & N; export declare type IndexByType = { [K in T['type']]: T extends any ? (K extends T['type'] ? T : never) : never; }; export declare type Equals = (() => A extends A2 ? true : false) extends () => A extends A1 ? true : false ? true : false; export declare type IsAny = Equals; export declare type Cast = A extends B ? A : B; export declare type NoInfer = [T][T extends any ? 0 : any]; export declare type LowInfer = T & {}; export declare type EventType = string; export declare type ActionType = string; export declare type MetaObject = Record; /** * The full definition of an event, with a string `type`. */ export interface EventObject { /** * The type of event that is sent. */ type: string; } export interface AnyEventObject extends EventObject { [key: string]: any; } export interface BaseActionObject { /** * The type of action that is executed. */ type: string; [other: string]: any; [notAnArrayLike: number]: never; } /** * The full definition of an action, with a string `type` and an * `exec` implementation function. */ export interface ActionObject { type: string; /** * The implementation for executing the action. */ exec?: ActionFunction | undefined; /** @deprecated an internal signature that doesn't exist at runtime. Its existence helps TS to choose a better code path in the inference algorithm */ (arg: TContext, ev: TExpressionEvent, meta: ActionMeta): void; } export declare type DefaultContext = Record | undefined; export declare type EventData = Record & { type?: never; }; /** * The specified string event types or the specified event objects. */ export declare type Event = TEvent['type'] | TEvent; export interface ActionMeta extends StateMeta { action: TAction; _event: SCXML.Event; } export interface AssignMeta { state?: State; action: AssignAction; _event: SCXML.Event; } export declare type ActionFunction = { bivarianceHack(context: TContext, event: TExpressionEvent, meta: ActionMeta): void; }['bivarianceHack']; export interface ChooseCondition { cond?: Condition; actions: Actions; } export declare type Action = ActionType | BaseActionObject | ActionObject | ActionFunction; /** * Extracts action objects that have no extra properties. */ declare type SimpleActionsOf = ActionObject extends T ? T : ExtractWithSimpleSupport; /** * Events that do not require payload */ export declare type SimpleEventsOf = ExtractWithSimpleSupport; export declare type BaseAction = SimpleActionsOf['type'] | TAction | RaiseAction | SendAction | AssignAction | LogAction | CancelAction | StopAction | ChooseAction | PureAction | ActionFunction; export declare type BaseActions = SingleOrArray>; export declare type Actions = SingleOrArray>; export declare type StateKey = string | AnyState; export interface StateValueMap { [key: string]: StateValue; } /** * The string or object representing the state value relative to the parent state node. * * - For a child atomic state node, this is a string, e.g., `"pending"`. * - For complex state nodes, this is an object, e.g., `{ success: "someChildState" }`. */ export declare type StateValue = string | StateValueMap; export interface HistoryValue { states: Record; current: StateValue | undefined; } export declare type ConditionPredicate = (context: TContext, event: TEvent, meta: GuardMeta) => boolean; export declare type DefaultGuardType = 'xstate.guard'; export interface GuardPredicate { type: DefaultGuardType; name: string | undefined; predicate: ConditionPredicate; } export declare type Guard = GuardPredicate | (Record & { type: string; }); export interface GuardMeta extends StateMeta { cond: Guard; } export declare type Condition = string | ConditionPredicate | Guard; export declare type TransitionTarget = SingleOrArray>; export declare type TransitionTargets = Array>; export interface TransitionConfig { cond?: Condition; actions?: BaseActions; in?: StateValue; internal?: boolean; target?: TransitionTarget | undefined; meta?: Record; description?: string; } export interface TargetTransitionConfig extends TransitionConfig { target: TransitionTarget; } export declare type ConditionalTransitionConfig = Array>; export declare type Transition = string | TransitionConfig | ConditionalTransitionConfig; export declare type DisposeActivityFunction = () => void; export declare type ActivityConfig = (ctx: TContext, activity: ActivityDefinition) => DisposeActivityFunction | void; export declare type Activity = string | ActivityDefinition; export interface ActivityDefinition extends ActionObject { id: string; type: string; } export declare type Sender = (event: Event) => void; declare type ExcludeType = { [K in Exclude]: A[K]; }; declare type ExtractExtraParameters = A extends { type: T; } ? ExcludeType : never; declare type ExtractWithSimpleSupport = T extends any ? { type: T['type']; } extends T ? T : never : never; declare type NeverIfEmpty = {} extends T ? never : T; export interface PayloadSender { /** * Send an event object or just the event type, if the event has no other payload */ (event: TEvent | ExtractWithSimpleSupport['type']): void; /** * Send an event type and its payload */ (eventType: K, payload: NeverIfEmpty>): void; } export declare type Receiver = (listener: { bivarianceHack(event: TEvent): void; }['bivarianceHack']) => void; export declare type InvokeCallback = (callback: Sender, onReceive: Receiver) => (() => void) | Promise | void; export interface InvokeMeta { data: any; src: InvokeSourceDefinition; meta?: MetaObject; } /** * Returns either a Promises or a callback handler (for streams of events) given the * machine's current `context` and `event` that invoked the service. * * For Promises, the only events emitted to the parent will be: * - `done.invoke.` with the `data` containing the resolved payload when the promise resolves, or: * - `error.platform.` with the `data` containing the caught error, and `src` containing the service `id`. * * For callback handlers, the `callback` will be provided, which will send events to the parent service. * * @param context The current machine `context` * @param event The event that invoked the service */ export declare type InvokeCreator = (context: TContext, event: TSourceEvent, meta: InvokeMeta) => PromiseLike | StateMachine | Subscribable | InvokeCallback | Behavior; export interface InvokeDefinition extends ActivityDefinition { /** * The source of the machine to be invoked, or the machine itself. */ src: string | InvokeSourceDefinition; /** * If `true`, events sent to the parent service will be forwarded to the invoked service. * * Default: `false` */ autoForward?: boolean; /** * @deprecated * * Use `autoForward` property instead of `forward`. Support for `forward` will get removed in the future. */ forward?: boolean; /** * Data from the parent machine's context to set as the (partial or full) context * for the invoked child machine. * * Data should be mapped to match the child machine's context shape. */ data?: Mapper | PropertyMapper; meta?: MetaObject; } export interface Delay { id: string; /** * The time to delay the event, in milliseconds. */ delay: number; } export declare type DelayedTransitions = Record>> | Array & { delay: number | string | Expr; }>; export declare type StateTypes = 'atomic' | 'compound' | 'parallel' | 'final' | 'history' | string; export declare type SingleOrArray = T[] | T; export declare type StateNodesConfig = { [K in keyof TStateSchema['states']]: StateNode; }; export declare type StatesConfig = { [K in keyof TStateSchema['states']]: StateNodeConfig; }; export declare type StatesDefinition = { [K in keyof TStateSchema['states']]: StateNodeDefinition; }; export declare type TransitionConfigTarget = string | undefined | StateNode; export declare type TransitionConfigOrTarget = SingleOrArray | TransitionConfig>; export declare type TransitionsConfigMap = { [K in TEvent['type'] | '' | '*']?: K extends '' | '*' ? TransitionConfigOrTarget : TransitionConfigOrTarget, TEvent>; }; declare type TransitionsConfigArray = Array<(TEvent extends EventObject ? TransitionConfig & { event: TEvent['type']; } : never) | (TransitionConfig & { event: ''; }) | (TransitionConfig & { event: '*'; })>; export declare type TransitionsConfig = TransitionsConfigMap | TransitionsConfigArray; export interface InvokeSourceDefinition { [key: string]: any; type: string; } export interface InvokeConfig { /** * The unique identifier for the invoked machine. If not specified, this * will be the machine's own `id`, or the URL (from `src`). */ id?: string; /** * The source of the machine to be invoked, or the machine itself. */ src: string | InvokeSourceDefinition | AnyStateMachine | InvokeCreator; /** * If `true`, events sent to the parent service will be forwarded to the invoked service. * * Default: `false` */ autoForward?: boolean; /** * @deprecated * * Use `autoForward` property instead of `forward`. Support for `forward` will get removed in the future. */ forward?: boolean; /** * Data from the parent machine's context to set as the (partial or full) context * for the invoked child machine. * * Data should be mapped to match the child machine's context shape. */ data?: Mapper | PropertyMapper; /** * The transition to take upon the invoked child machine reaching its final top-level state. */ onDone?: string | SingleOrArray>>; /** * The transition to take upon the invoked child machine sending an error event. */ onError?: string | SingleOrArray>>; /** * Meta data related to this invocation */ meta?: MetaObject; } export interface StateNodeConfig { /** * The relative key of the state node, which represents its location in the overall state value. * This is automatically determined by the configuration shape via the key where it was defined. */ key?: string; /** * The initial state node key. */ initial?: keyof TStateSchema['states'] | undefined; /** * @deprecated */ parallel?: boolean | undefined; /** * The type of this state node: * * - `'atomic'` - no child state nodes * - `'compound'` - nested child state nodes (XOR) * - `'parallel'` - orthogonal nested child state nodes (AND) * - `'history'` - history state node * - `'final'` - final state node */ type?: 'atomic' | 'compound' | 'parallel' | 'final' | 'history'; /** * Indicates whether the state node is a history state node, and what * type of history: * shallow, deep, true (shallow), false (none), undefined (none) */ history?: 'shallow' | 'deep' | boolean | undefined; /** * The mapping of state node keys to their state node configurations (recursive). */ states?: StatesConfig | undefined; /** * The services to invoke upon entering this state node. These services will be stopped upon exiting this state node. */ invoke?: SingleOrArray | AnyStateMachine>; /** * The mapping of event types to their potential transition(s). */ on?: TransitionsConfig; /** * The action(s) to be executed upon entering the state node. * * @deprecated Use `entry` instead. */ onEntry?: Actions; /** * The action(s) to be executed upon entering the state node. */ entry?: BaseActions; /** * The action(s) to be executed upon exiting the state node. * * @deprecated Use `exit` instead. */ onExit?: Actions; /** * The action(s) to be executed upon exiting the state node. */ exit?: BaseActions; /** * The potential transition(s) to be taken upon reaching a final child state node. * * This is equivalent to defining a `[done(id)]` transition on this state node's `on` property. */ onDone?: string | SingleOrArray> | undefined; /** * The mapping (or array) of delays (in milliseconds) to their potential transition(s). * The delayed transitions are taken after the specified delay in an interpreter. */ after?: DelayedTransitions; /** * An eventless transition that is always taken when this state node is active. * Equivalent to a transition specified as an empty `''`' string in the `on` property. */ always?: TransitionConfigOrTarget; /** * The activities to be started upon entering the state node, * and stopped upon exiting the state node. * * @deprecated Use `invoke` instead. */ activities?: SingleOrArray>; /** * @private */ parent?: StateNode; strict?: boolean | undefined; /** * The meta data associated with this state node, which will be returned in State instances. */ meta?: TStateSchema extends { meta: infer D; } ? D : any; /** * The data sent with the "done.state._id_" event if this is a final state node. * * The data will be evaluated with the current `context` and placed on the `.data` property * of the event. */ data?: Mapper | PropertyMapper; /** * The unique ID of the state node, which can be referenced as a transition target via the * `#id` syntax. */ id?: string | undefined; /** * The string delimiter for serializing the path to a string. The default is "." */ delimiter?: string; /** * The order this state node appears. Corresponds to the implicit SCXML document order. */ order?: number; /** * The tags for this state node, which are accumulated into the `state.tags` property. */ tags?: SingleOrArray; /** * Whether actions should be called in order. * When `false` (default), `assign(...)` actions are prioritized before other actions. * * @default false */ preserveActionOrder?: boolean; /** * Whether XState calls actions with the event directly responsible for the related transition. * * @default false */ predictableActionArguments?: boolean; /** * A text description of the state node */ description?: string; } export interface StateNodeDefinition { id: string; version: string | undefined; key: string; context: TContext; type: 'atomic' | 'compound' | 'parallel' | 'final' | 'history'; initial: StateNodeConfig['initial']; history: boolean | 'shallow' | 'deep' | undefined; states: StatesDefinition; on: TransitionDefinitionMap; transitions: Array>; entry: Array>; exit: Array>; /** * @deprecated */ activities: Array>; meta: any; order: number; data?: FinalStateNodeConfig['data']; invoke: Array>; description?: string; tags: string[]; } export declare type AnyStateNodeDefinition = StateNodeDefinition; export declare type AnyState = State; export declare type AnyStateMachine = StateMachine; export interface AtomicStateNodeConfig extends StateNodeConfig { initial?: undefined; parallel?: false | undefined; states?: undefined; onDone?: undefined; } export interface HistoryStateNodeConfig extends AtomicStateNodeConfig { history: 'shallow' | 'deep' | true; target: StateValue | undefined; } export interface FinalStateNodeConfig extends AtomicStateNodeConfig { type: 'final'; /** * The data to be sent with the "done.state." event. The data can be * static or dynamic (based on assigners). */ data?: Mapper | PropertyMapper; } export declare type SimpleOrStateNodeConfig = AtomicStateNodeConfig | StateNodeConfig; export declare type ActionFunctionMap = { [K in TAction['type']]?: ActionObject | ActionFunction; }; export declare type DelayFunctionMap = Record>; export declare type ServiceConfig = string | AnyStateMachine | InvokeCreator; export declare type DelayConfig = number | DelayExpr; declare type MachineOptionsActions, 'eventsCausingActions'>, TIndexedEvents = Prop, 'indexedEvents'>, TIndexedActions = Prop, 'indexedActions'>> = { [K in keyof TEventsCausingActions]?: ActionObject, EventObject>, Cast, EventObject>, Cast, BaseActionObject>> | ActionFunction, EventObject>, Cast, BaseActionObject>, Cast, EventObject>>; }; declare type MachineOptionsDelays, 'eventsCausingDelays'>, TIndexedEvents = Prop, 'indexedEvents'>> = { [K in keyof TEventsCausingDelays]?: DelayConfig, EventObject>>; }; declare type MachineOptionsGuards, 'eventsCausingGuards'>, TIndexedEvents = Prop, 'indexedEvents'>> = { [K in keyof TEventsCausingGuards]?: ConditionPredicate, EventObject>>; }; declare type MachineOptionsServices, 'eventsCausingServices'>, TIndexedEvents = Prop, 'indexedEvents'>, TInvokeSrcNameMap = Prop, 'invokeSrcNameMap'>> = { [K in keyof TEventsCausingServices]?: AnyStateMachine | InvokeCreator, EventObject>, Prop>, 'data'>, EventObject, Cast>; }; declare type MakeKeysRequired = { [K in T]: unknown; }; declare type MaybeMakeMissingImplementationsRequired = TRequireMissingImplementations extends true ? IsNever extends true ? {} : { [K in Cast]: MakeKeysRequired>; } : {}; declare type GenerateActionsConfigPart = MaybeMakeMissingImplementationsRequired<'actions', Prop, TRequireMissingImplementations> & { actions?: MachineOptionsActions; }; declare type GenerateDelaysConfigPart = MaybeMakeMissingImplementationsRequired<'delays', Prop, TRequireMissingImplementations> & { delays?: MachineOptionsDelays; }; declare type GenerateGuardsConfigPart = MaybeMakeMissingImplementationsRequired<'guards', Prop, TRequireMissingImplementations> & { guards?: MachineOptionsGuards; }; declare type GenerateServicesConfigPart = MaybeMakeMissingImplementationsRequired<'services', Prop, TRequireMissingImplementations> & { services?: MachineOptionsServices; }; export declare type InternalMachineOptions, 'missingImplementations'>> = GenerateActionsConfigPart & GenerateDelaysConfigPart & GenerateGuardsConfigPart & GenerateServicesConfigPart & { /** * @deprecated Use `services` instead. */ activities?: Record>; }; export declare type MachineOptions = InternalMachineOptions>; export interface MachineConfig extends StateNodeConfig, TStateSchema, NoInfer, TAction> { /** * The initial context (extended state) */ context?: LowInfer TContext)>; /** * The machine's own version. */ version?: string; schema?: MachineSchema; tsTypes?: TTypesMeta; } export declare type ServiceMap = Record; export interface MachineSchema { context?: TContext; events?: TEvent; actions?: { type: string; [key: string]: any; }; guards?: { type: string; [key: string]: any; }; services?: TServiceMap; } export interface StandardMachineConfig extends StateNodeConfig { } export interface ParallelMachineConfig extends StateNodeConfig { initial?: undefined; type?: 'parallel'; } export interface EntryExitEffectMap { entry: Array>; exit: Array>; } export interface HistoryStateNode extends StateNode { history: 'shallow' | 'deep'; target: StateValue | undefined; } /** @ts-ignore TS complains about withConfig & withContext not being compatible here when extending StateNode */ export interface StateMachine = { value: any; context: TContext; }, TAction extends BaseActionObject = BaseActionObject, TServiceMap extends ServiceMap = ServiceMap, TResolvedTypesMeta = ResolveTypegenMeta, TAction, TServiceMap>> extends StateNode { id: string; states: StateNode['states']; withConfig(options: InternalMachineOptions, context?: TContext | (() => TContext)): StateMachine extends false ? MarkAllImplementationsAsProvided : TResolvedTypesMeta>; withContext(context: TContext | (() => TContext)): StateMachine; /** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */ __TContext: TContext; /** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */ __TStateSchema: TStateSchema; /** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */ __TEvent: TEvent; /** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */ __TTypestate: TTypestate; /** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */ __TAction: TAction; /** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */ __TServiceMap: TServiceMap; /** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */ __TResolvedTypesMeta: TResolvedTypesMeta; } export declare type StateFrom AnyStateMachine)> = T extends AnyStateMachine ? ReturnType : T extends (...args: any[]) => AnyStateMachine ? ReturnType['transition']> : never; export interface ActionMap { onEntry: Array>; actions: Array>; onExit: Array>; } export interface EntryExitStates { entry: Set>; exit: Set>; } export interface EntryExitStateArrays { entry: Array>; exit: Array>; } export interface ActivityMap { [activityKey: string]: ActivityDefinition | false; } export interface StateTransition { transitions: Array>; configuration: Array>; exitSet: Array>; /** * The source state that preceded the transition. */ source: State | undefined; actions: Array>; } export interface TransitionData { value: StateValue | undefined; actions: ActionMap; activities?: ActivityMap; } export declare enum ActionTypes { Start = "xstate.start", Stop = "xstate.stop", Raise = "xstate.raise", Send = "xstate.send", Cancel = "xstate.cancel", NullEvent = "", Assign = "xstate.assign", After = "xstate.after", DoneState = "done.state", DoneInvoke = "done.invoke", Log = "xstate.log", Init = "xstate.init", Invoke = "xstate.invoke", ErrorExecution = "error.execution", ErrorCommunication = "error.communication", ErrorPlatform = "error.platform", ErrorCustom = "xstate.error", Update = "xstate.update", Pure = "xstate.pure", Choose = "xstate.choose" } export interface RaiseAction extends ActionObject { type: ActionTypes.Raise; event: TEvent | SendExpr; delay: number | string | undefined | DelayExpr; id: string | number | undefined; } export interface RaiseActionObject extends RaiseAction { type: ActionTypes.Raise; _event: SCXML.Event; delay: number | undefined; id: string | number | undefined; } export interface DoneInvokeEvent extends EventObject { data: TData; } export interface ErrorExecutionEvent extends EventObject { src: string; type: ActionTypes.ErrorExecution; data: any; } export interface ErrorPlatformEvent extends EventObject { data: any; } export interface DoneEventObject extends EventObject { data?: any; toString(): string; } export interface UpdateObject extends EventObject { id: string | number; state: AnyState; } export declare type DoneEvent = DoneEventObject & string; export interface NullEvent { type: ActionTypes.NullEvent; } export interface ActivityActionObject extends ActionObject { type: ActionTypes.Start | ActionTypes.Stop; activity: ActivityDefinition | undefined; exec: ActionFunction | undefined; } export interface InvokeActionObject extends ActivityActionObject { activity: InvokeDefinition; } export declare type DelayExpr = ExprWithMeta; export declare type LogExpr = ExprWithMeta; export interface LogAction extends ActionObject { type: ActionTypes.Log; label: string | undefined; expr: string | LogExpr; } export interface LogActionObject extends LogAction { value: any; } export interface SendAction extends ActionObject { type: ActionTypes.Send; to: string | number | ActorRef | ExprWithMeta> | undefined; event: TSentEvent | SendExpr; delay?: number | string | DelayExpr; id: string | number; } export interface SendActionObject extends SendAction { to: string | number | ActorRef | undefined; _event: SCXML.Event; event: TSentEvent; delay?: number; id: string | number; } export interface StopAction extends ActionObject { type: ActionTypes.Stop; activity: string | { id: string; } | Expr; } export interface StopActionObject { type: ActionTypes.Stop; activity: { id: string; }; } export declare type Expr = (context: TContext, event: TEvent) => T; export declare type ExprWithMeta = (context: TContext, event: TEvent, meta: SCXMLEventMeta) => T; export declare type SendExpr = ExprWithMeta; export declare enum SpecialTargets { Parent = "#_parent", Internal = "#_internal" } export interface SendActionOptions extends RaiseActionOptions { to?: string | ActorRef | ExprWithMeta>; } export interface RaiseActionOptions { id?: string | number; delay?: number | string | DelayExpr; } export interface CancelAction extends ActionObject { type: ActionTypes.Cancel; sendId: string | number; } export declare type Assigner = (context: TContext, event: TEvent, meta: AssignMeta) => Partial; export declare type PartialAssigner = (context: TContext, event: TEvent, meta: AssignMeta) => TContext[TKey]; export declare type PropertyAssigner = { [K in keyof TContext]?: PartialAssigner | TContext[K]; }; export declare type Mapper = (context: TContext, event: TEvent) => TParams; export declare type PropertyMapper = { [K in keyof TParams]?: ((context: TContext, event: TEvent) => TParams[K]) | TParams[K]; }; export interface AnyAssignAction extends ActionObject { type: ActionTypes.Assign; assignment: any; } export interface AssignAction extends ActionObject { type: ActionTypes.Assign; assignment: Assigner | PropertyAssigner; } export interface PureAction extends ActionObject { type: ActionTypes.Pure; get: (context: TContext, event: TEvent) => SingleOrArray | ActionObject['type']> | undefined; } export interface ChooseAction extends ActionObject { type: ActionTypes.Choose; conds: Array>; } export interface TransitionDefinition extends Omit, 'actions'> { target: Array> | undefined; source: StateNode; actions: Array>; cond?: Guard; eventType: TEvent['type'] | NullEvent['type'] | '*'; toJSON: () => { target: string[] | undefined; source: string; actions: Array>; cond?: Guard; eventType: TEvent['type'] | NullEvent['type'] | '*'; meta?: Record; }; } export declare type TransitionDefinitionMap = { [K in TEvent['type'] | NullEvent['type'] | '*']: Array : EventObject>>; }; export interface DelayedTransitionDefinition extends TransitionDefinition { delay: number | string | DelayExpr; } export interface Edge { event: TEventType; source: StateNode; target: StateNode; cond?: Condition; actions: Array>; meta?: MetaObject; transition: TransitionDefinition; } export interface NodesAndEdges { nodes: StateNode[]; edges: Array>; } export interface Segment { /** * From state. */ state: State; /** * Event from state. */ event: TEvent; } export interface PathItem { state: State; path: Array>; weight?: number; } export interface PathMap { [key: string]: PathItem; } export interface PathsItem { state: State; paths: Array>>; } export interface PathsMap { [key: string]: PathsItem; } export interface TransitionMap { state: StateValue | undefined; } export interface AdjacencyMap { [stateId: string]: Record; } export interface ValueAdjacencyMap { [stateId: string]: Record>; } export interface SCXMLEventMeta { _event: SCXML.Event; } export interface StateMeta { state: State; _event: SCXML.Event; } export interface Typestate { value: StateValue; context: TContext; } export interface StateLike { value: StateValue; context: TContext; event: EventObject; _event: SCXML.Event; } export interface StateConfig { value: StateValue; context: TContext; _event: SCXML.Event; _sessionid: string | null; historyValue?: HistoryValue | undefined; history?: State; actions?: Array>; /** * @deprecated */ activities?: ActivityMap; meta?: any; /** * @deprecated */ events?: TEvent[]; configuration: Array>; transitions: Array>; children: Record>; done?: boolean; tags?: Set; machine?: StateMachine; } export declare type AnyStateConfig = StateConfig; export interface StateSchema { meta?: any; context?: Partial; states?: { [key: string]: StateSchema; }; } export interface InterpreterOptions { /** * Whether state actions should be executed immediately upon transition. Defaults to `true`. */ execute?: boolean; clock?: Clock; logger?: (...args: any[]) => void; parent?: AnyInterpreter; /** * If `true`, defers processing of sent events until the service * is initialized (`.start()`). Otherwise, an error will be thrown * for events sent to an uninitialized service. * * Default: `true` */ deferEvents?: boolean; /** * The custom `id` for referencing this service. */ id?: string; /** * If `true`, states and events will be logged to Redux DevTools. * * Default: `false` */ devTools?: boolean | object; } export declare namespace SCXML { interface Event { /** * This is a character string giving the name of the event. * The SCXML Processor must set the name field to the name of this event. * It is what is matched against the 'event' attribute of . * Note that transitions can do additional tests by using the value of this field * inside boolean expressions in the 'cond' attribute. */ name: string; /** * This field describes the event type. * The SCXML Processor must set it to: "platform" (for events raised by the platform itself, such as error events), * "internal" (for events raised by and with target '_internal') * or "external" (for all other events). */ type: 'platform' | 'internal' | 'external'; /** * If the sending entity has specified a value for this, the Processor must set this field to that value * (see C Event I/O Processors for details). * Otherwise, in the case of error events triggered by a failed attempt to send an event, * the Processor must set this field to the send id of the triggering element. * Otherwise it must leave it blank. */ sendid?: string; /** * This is a URI, equivalent to the 'target' attribute on the element. * For external events, the SCXML Processor should set this field to a value which, * when used as the value of 'target', will allow the receiver of the event to * a response back to the originating entity via the Event I/O Processor specified in 'origintype'. * For internal and platform events, the Processor must leave this field blank. */ origin?: string; /** * This is equivalent to the 'type' field on the element. * For external events, the SCXML Processor should set this field to a value which, * when used as the value of 'type', will allow the receiver of the event to * a response back to the originating entity at the URI specified by 'origin'. * For internal and platform events, the Processor must leave this field blank. */ origintype?: string; /** * If this event is generated from an invoked child process, the SCXML Processor * must set this field to the invoke id of the invocation that triggered the child process. * Otherwise it must leave it blank. */ invokeid?: string; /** * This field contains whatever data the sending entity chose to include in this event. * The receiving SCXML Processor should reformat this data to match its data model, * but must not otherwise modify it. * * If the conversion is not possible, the Processor must leave the field blank * and must place an error 'error.execution' in the internal event queue. */ data: TEvent; /** * @private */ $$type: 'scxml'; } } export interface Observer { next: (value: T) => void; error: (err: any) => void; complete: () => void; } export interface Subscription { unsubscribe(): void; } export interface InteropObservable { [Symbol.observable]: () => InteropSubscribable; } export interface InteropSubscribable { subscribe(observer: Observer): Subscription; } export interface Subscribable extends InteropSubscribable { subscribe(observer: Observer): Subscription; subscribe(next: (value: T) => void, error?: (error: any) => void, complete?: () => void): Subscription; } export declare type Spawnable = AnyStateMachine | PromiseLike | InvokeCallback | InteropObservable | Subscribable | Behavior; export declare type ExtractEvent = TEvent extends any ? TEventType extends TEvent['type'] ? TEvent : never : never; export interface BaseActorRef { send: (event: TEvent) => void; } export interface ActorRef extends Subscribable, InteropObservable { send: Sender; id: string; getSnapshot: () => TEmitted | undefined; stop?: () => void; toJSON?: () => any; } export declare type AnyActorRef = ActorRef; /** * @deprecated Use `ActorRef` instead. */ export declare type SpawnedActorRef = ActorRef; export declare type ActorRefWithDeprecatedState, TResolvedTypesMeta = TypegenDisabled> = ActorRef> & { /** * @deprecated Use `.getSnapshot()` instead. */ state: State; }; export declare type ActorRefFrom = ReturnTypeOrValue extends infer R ? R extends StateMachine ? ActorRefWithDeprecatedState extends false ? MarkAllImplementationsAsProvided : TResolvedTypesMeta> : R extends Promise ? ActorRef : R extends Behavior ? ActorRef : never : never; export declare type AnyInterpreter = Interpreter; export declare type InterpreterFrom AnyStateMachine)> = ReturnTypeOrValue extends StateMachine ? Interpreter extends false ? MarkAllImplementationsAsProvided : TResolvedTypesMeta> : never; export declare type MachineOptionsFrom AnyStateMachine), TRequireMissingImplementations extends boolean = false> = ReturnTypeOrValue extends StateMachine ? InternalMachineOptions : never; export declare type __ResolvedTypesMetaFrom = T extends StateMachine ? TResolvedTypesMeta : never; export interface ActorContext { parent?: ActorRef; self: ActorRef; id: string; observers: Set>; } export interface Behavior { transition: (state: TEmitted, event: TEvent, actorCtx: ActorContext) => TEmitted; initialState: TEmitted; start?: (actorCtx: ActorContext) => TEmitted; } export declare type EmittedFrom = ReturnTypeOrValue extends infer R ? R extends StateMachine ? R['initialState'] : R extends Interpreter ? R['initialState'] : R extends ActorRef ? TEmitted : R extends Behavior ? TEmitted : R extends ActorContext ? TEmitted : never : never; declare type ResolveEventType = ReturnTypeOrValue extends infer R ? R extends StateMachine ? TEvent : R extends Model ? TEvent : R extends State ? TEvent : R extends Interpreter ? TEvent : R extends ActorRef ? TEvent : never : never; export declare type EventFrom = never, TEvent extends EventObject = ResolveEventType> = IsNever extends true ? TEvent : ExtractEvent; export declare type ContextFrom = ReturnTypeOrValue extends infer R ? R extends StateMachine ? TContext : R extends Model ? TContext : R extends State ? TContext : R extends Interpreter ? TContext : never : never; declare type Matches = { (stateValue: TypegenEnabledArg): any; (stateValue: TypegenDisabledArg): any; }; export declare type StateValueFrom = StateFrom['matches'] extends Matches ? TMachine['__TResolvedTypesMeta'] extends TypegenEnabled ? TypegenEnabledArg : TypegenDisabledArg : never; export declare type PredictableActionArgumentsExec = (action: ActionObject, context: unknown, _event: SCXML.Event) => void; export declare type TagsFrom = Parameters['hasTag']>[0]; export {}; //# sourceMappingURL=types.d.ts.map