xstate 5.0.0-beta.50 → 5.0.0-beta.52
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/actions/dist/xstate-actions.cjs.js +9 -10
- package/actions/dist/xstate-actions.cjs.mjs +1 -2
- package/actions/dist/xstate-actions.development.cjs.js +9 -10
- package/actions/dist/xstate-actions.development.cjs.mjs +1 -2
- package/actions/dist/xstate-actions.development.esm.js +2 -2
- package/actions/dist/xstate-actions.esm.js +2 -2
- package/actions/dist/xstate-actions.umd.min.js +1 -1
- package/actions/dist/xstate-actions.umd.min.js.map +1 -1
- package/actors/dist/xstate-actors.cjs.js +1 -1
- package/actors/dist/xstate-actors.development.cjs.js +1 -1
- package/actors/dist/xstate-actors.development.esm.js +1 -1
- package/actors/dist/xstate-actors.esm.js +1 -1
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/declarations/src/StateMachine.d.ts +2 -2
- package/dist/declarations/src/StateNode.d.ts +3 -3
- package/dist/declarations/src/actions/enqueueActions.d.ts +32 -0
- package/dist/declarations/src/actions.d.ts +2 -3
- package/dist/declarations/src/actors/index.d.ts +1 -1
- package/dist/declarations/src/interpreter.d.ts +2 -2
- package/dist/declarations/src/types.d.ts +9 -9
- package/dist/declarations/src/utils.d.ts +1 -20
- package/dist/{send-7f3db830.cjs.js → log-3d815f5e.cjs.js} +90 -83
- package/dist/{send-88351a33.esm.js → log-6bc0e1e7.esm.js} +90 -82
- package/dist/{send-2b001f05.development.esm.js → log-826c9895.development.esm.js} +96 -91
- package/dist/{send-df1c8ef2.development.cjs.js → log-d160285c.development.cjs.js} +96 -92
- package/dist/{raise-6c05c91b.development.esm.js → raise-1caefe80.development.esm.js} +16 -21
- package/dist/{raise-8176cd35.cjs.js → raise-367eeb6f.cjs.js} +15 -20
- package/dist/{raise-dc9c2c58.development.cjs.js → raise-9dd3e757.development.cjs.js} +15 -20
- package/dist/{raise-32ec7226.esm.js → raise-f71460d6.esm.js} +16 -21
- package/dist/xstate.cjs.js +13 -14
- package/dist/xstate.cjs.mjs +1 -2
- package/dist/xstate.development.cjs.js +13 -14
- package/dist/xstate.development.cjs.mjs +1 -2
- package/dist/xstate.development.esm.js +6 -6
- package/dist/xstate.esm.js +6 -6
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/guards/dist/xstate-guards.cjs.js +1 -1
- package/guards/dist/xstate-guards.development.cjs.js +1 -1
- package/guards/dist/xstate-guards.development.esm.js +1 -1
- package/guards/dist/xstate-guards.esm.js +1 -1
- package/guards/dist/xstate-guards.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/declarations/src/actions/choose.d.ts +0 -9
- package/dist/declarations/src/actions/pure.d.ts +0 -13
|
@@ -80,8 +80,8 @@ export interface ParameterizedObject {
|
|
|
80
80
|
export interface UnifiedArg<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject> {
|
|
81
81
|
context: TContext;
|
|
82
82
|
event: TExpressionEvent;
|
|
83
|
-
self: ActorRef<
|
|
84
|
-
StateValue, string, unknown
|
|
83
|
+
self: ActorRef<MachineSnapshot<TContext, TEvent, Record<string, AnyActorRef | undefined>, // TODO: this should be replaced with `TChildren`
|
|
84
|
+
StateValue, string, unknown>, TEvent>;
|
|
85
85
|
system: ActorSystem<any>;
|
|
86
86
|
}
|
|
87
87
|
export type MachineContext = Record<string, any>;
|
|
@@ -521,8 +521,8 @@ export type PropertyAssigner<TContext extends MachineContext, TExpressionEvent e
|
|
|
521
521
|
export type Mapper<TContext extends MachineContext, TExpressionEvent extends EventObject, TResult, TEvent extends EventObject> = (args: {
|
|
522
522
|
context: TContext;
|
|
523
523
|
event: TExpressionEvent;
|
|
524
|
-
self: ActorRef<
|
|
525
|
-
StateValue, string, unknown
|
|
524
|
+
self: ActorRef<MachineSnapshot<TContext, TEvent, Record<string, AnyActorRef>, // TODO: this should be replaced with `TChildren`
|
|
525
|
+
StateValue, string, unknown>, TEvent>;
|
|
526
526
|
}) => TResult;
|
|
527
527
|
export interface TransitionDefinition<TContext extends MachineContext, TEvent extends EventObject> extends Omit<TransitionConfig<TContext, TEvent, TEvent, TODO, TODO, TODO, TODO>, 'target' | 'guard'> {
|
|
528
528
|
target: ReadonlyArray<StateNode<TContext, TEvent>> | undefined;
|
|
@@ -729,7 +729,7 @@ export interface BaseActorRef<TEvent extends EventObject> {
|
|
|
729
729
|
export interface ActorLike<TCurrent, TEvent extends EventObject> extends Subscribable<TCurrent> {
|
|
730
730
|
send: (event: TEvent) => void;
|
|
731
731
|
}
|
|
732
|
-
export interface ActorRef<
|
|
732
|
+
export interface ActorRef<TSnapshot extends Snapshot<unknown>, TEvent extends EventObject> extends Subscribable<TSnapshot>, InteropObservable<TSnapshot> {
|
|
733
733
|
/**
|
|
734
734
|
* The unique identifier for this actor relative to its parent.
|
|
735
735
|
*/
|
|
@@ -747,7 +747,7 @@ export interface ActorRef<TEvent extends EventObject, TSnapshot extends Snapshot
|
|
|
747
747
|
}
|
|
748
748
|
export type AnyActorRef = ActorRef<any, any>;
|
|
749
749
|
export type ActorLogicFrom<T> = ReturnTypeOrValue<T> extends infer R ? R extends StateMachine<any, any, any, any, any, any, any, any, any, any, any> ? R : R extends Promise<infer U> ? PromiseActorLogic<U> : never : never;
|
|
750
|
-
export type ActorRefFrom<T> = ReturnTypeOrValue<T> extends infer R ? R extends StateMachine<infer TContext, infer TEvent, infer TChildren, infer _TActor, infer _TAction, infer _TGuard, infer _TDelay, infer TStateValue, infer TTag, infer _TInput, infer TOutput, infer TResolvedTypesMeta> ? ActorRef<
|
|
750
|
+
export type ActorRefFrom<T> = ReturnTypeOrValue<T> extends infer R ? R extends StateMachine<infer TContext, infer TEvent, infer TChildren, infer _TActor, infer _TAction, infer _TGuard, infer _TDelay, infer TStateValue, infer TTag, infer _TInput, infer TOutput, infer TResolvedTypesMeta> ? ActorRef<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, AreAllImplementationsAssumedToBeProvided<TResolvedTypesMeta> extends false ? MarkAllImplementationsAsProvided<TResolvedTypesMeta> : TResolvedTypesMeta>, TEvent> : R extends Promise<infer U> ? ActorRefFrom<PromiseActorLogic<U>> : R extends ActorLogic<infer TSnapshot, infer TEvent, infer _TInput, infer _TSystem> ? ActorRef<TSnapshot, TEvent> : never : never;
|
|
751
751
|
export type DevToolsAdapter = (service: AnyActor) => void;
|
|
752
752
|
/**
|
|
753
753
|
* @deprecated Use `Actor<T>` instead.
|
|
@@ -766,7 +766,7 @@ any, // input
|
|
|
766
766
|
any, // output
|
|
767
767
|
infer TResolvedTypesMeta> ? TResolvedTypesMeta : never;
|
|
768
768
|
export interface ActorScope<TSnapshot extends Snapshot<unknown>, TEvent extends EventObject, TSystem extends ActorSystem<any> = ActorSystem<any>> {
|
|
769
|
-
self: ActorRef<
|
|
769
|
+
self: ActorRef<TSnapshot, TEvent>;
|
|
770
770
|
id: string;
|
|
771
771
|
sessionId: string;
|
|
772
772
|
logger: (...args: any[]) => void;
|
|
@@ -847,9 +847,9 @@ any, // input
|
|
|
847
847
|
any>;
|
|
848
848
|
export type UnknownActorLogic = ActorLogic<any, // this is invariant and it's hard to figure out a better default than `any`
|
|
849
849
|
EventObject, NonReducibleUnknown, ActorSystem<any>>;
|
|
850
|
-
export type SnapshotFrom<T> = ReturnTypeOrValue<T> extends infer R ? R extends ActorRef<infer
|
|
850
|
+
export type SnapshotFrom<T> = ReturnTypeOrValue<T> extends infer R ? R extends ActorRef<infer TSnapshot, infer _> ? TSnapshot : R extends Actor<infer TLogic> ? SnapshotFrom<TLogic> : R extends ActorLogic<infer _, infer __, infer ___, infer ____> ? ReturnType<R['transition']> : R extends ActorScope<infer TSnapshot, infer _, infer __> ? TSnapshot : never : never;
|
|
851
851
|
export type EventFromLogic<TLogic extends ActorLogic<any, any, any, any>> = TLogic extends ActorLogic<infer _, infer TEvent, infer __, infer _____> ? TEvent : never;
|
|
852
|
-
type ResolveEventType<T> = ReturnTypeOrValue<T> extends infer R ? R extends StateMachine<infer _TContext, infer TEvent, infer _TChildren, infer _TActor, infer _TAction, infer _TGuard, infer _TDelay, infer _TStateValue, infer _TTag, infer _TInput, infer _TOutput, infer _TResolvedTypesMeta> ? TEvent : R extends MachineSnapshot<infer _TContext, infer TEvent, infer _TChildren, infer _TTag, infer _TOutput, infer _TResolvedTypesMeta> ? TEvent : R extends ActorRef<infer
|
|
852
|
+
type ResolveEventType<T> = ReturnTypeOrValue<T> extends infer R ? R extends StateMachine<infer _TContext, infer TEvent, infer _TChildren, infer _TActor, infer _TAction, infer _TGuard, infer _TDelay, infer _TStateValue, infer _TTag, infer _TInput, infer _TOutput, infer _TResolvedTypesMeta> ? TEvent : R extends MachineSnapshot<infer _TContext, infer TEvent, infer _TChildren, infer _TTag, infer _TOutput, infer _TResolvedTypesMeta> ? TEvent : R extends ActorRef<infer _, infer TEvent> ? TEvent : never : never;
|
|
853
853
|
export type EventFrom<T, K extends Prop<TEvent, 'type'> = never, TEvent extends EventObject = ResolveEventType<T>> = IsNever<K> extends true ? TEvent : ExtractEvent<TEvent, K>;
|
|
854
854
|
export type ContextFrom<T> = ReturnTypeOrValue<T> extends infer R ? R extends StateMachine<infer TContext, infer _TEvent, infer _TChildren, infer _TActor, infer _TAction, infer _TGuard, infer _TDelay, infer _TStateValue, infer _TTag, infer _TInput, infer _TOutput, infer _TTypesMeta> ? TContext : R extends MachineSnapshot<infer TContext, infer _TEvent, infer _TChildren, infer _TTag, infer _TOutput, infer _TResolvedTypesMeta> ? TContext : R extends Actor<infer TActorLogic> ? TActorLogic extends StateMachine<infer TContext, infer _TEvent, infer _TChildren, infer _TActor, infer _TAction, infer _TGuard, infer _TDelay, infer _TTag, infer _TInput, infer _TOutput, infer _TTypesMeta> ? TContext : never : never : never;
|
|
855
855
|
export type InferEvent<E extends EventObject> = {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { StateNode } from "./StateNode.js";
|
|
2
|
-
import type { ActorLogic,
|
|
3
|
-
export declare function keys<T extends object>(value: T): Array<keyof T & string>;
|
|
2
|
+
import type { ActorLogic, AnyActorRef, AnyEventObject, AnyMachineSnapshot, AnyStateMachine, AnyTransitionConfig, ErrorActorEvent, EventObject, MachineContext, Mapper, NonReducibleUnknown, Observer, SingleOrArray, StateLike, StateValue, TransitionConfigTarget } from "./types.js";
|
|
4
3
|
export declare function matchesState(parentStateId: StateValue, childStateId: StateValue): boolean;
|
|
5
4
|
export declare function toStatePath(stateId: string | string[]): string[];
|
|
6
5
|
export declare function toStateValue(stateValue: StateLike<any> | StateValue): StateValue;
|
|
@@ -8,32 +7,14 @@ export declare function pathToStateValue(statePath: string[]): StateValue;
|
|
|
8
7
|
export declare function mapValues<P, O extends Record<string, unknown>>(collection: O, iteratee: (item: O[keyof O], key: keyof O, collection: O, i: number) => P): {
|
|
9
8
|
[key in keyof O]: P;
|
|
10
9
|
};
|
|
11
|
-
export declare function mapFilterValues<T, P>(collection: {
|
|
12
|
-
[key: string]: T;
|
|
13
|
-
}, iteratee: (item: T, key: string, collection: {
|
|
14
|
-
[key: string]: T;
|
|
15
|
-
}) => P, predicate: (item: T) => boolean): {
|
|
16
|
-
[key: string]: P;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Retrieves a value at the given path.
|
|
20
|
-
* @param props The deep path to the prop of the desired value
|
|
21
|
-
*/
|
|
22
|
-
export declare function path<T extends Record<string, any>>(props: string[]): any;
|
|
23
|
-
export declare function toStatePaths(stateValue: StateValue | undefined): string[][];
|
|
24
10
|
export declare function toArrayStrict<T>(value: readonly T[] | T): readonly T[];
|
|
25
11
|
export declare function toArray<T>(value: readonly T[] | T | undefined): readonly T[];
|
|
26
12
|
export declare function resolveOutput<TContext extends MachineContext, TExpressionEvent extends EventObject>(mapper: Mapper<TContext, TExpressionEvent, unknown, EventObject> | NonReducibleUnknown, context: TContext, event: TExpressionEvent, self: AnyActorRef): unknown;
|
|
27
|
-
export declare function isBuiltInEvent(eventType: string): boolean;
|
|
28
|
-
export declare function isPromiseLike(value: any): value is PromiseLike<any>;
|
|
29
13
|
export declare function isActorLogic(value: any): value is ActorLogic<any, any>;
|
|
30
|
-
export declare function partition<T, A extends T, B extends T>(items: T[], predicate: (item: T) => item is A): [A[], B[]];
|
|
31
14
|
export declare function isArray(value: any): value is readonly any[];
|
|
32
|
-
export declare function isObservable<T>(value: any): value is Subscribable<T>;
|
|
33
15
|
export declare function isErrorActorEvent(event: AnyEventObject): event is ErrorActorEvent;
|
|
34
16
|
export declare function toTransitionConfigArray<TContext extends MachineContext, TEvent extends EventObject>(configLike: SingleOrArray<AnyTransitionConfig | TransitionConfigTarget>): Array<AnyTransitionConfig>;
|
|
35
17
|
export declare function normalizeTarget<TContext extends MachineContext, TEvent extends EventObject>(target: SingleOrArray<string | StateNode<TContext, TEvent>> | undefined): ReadonlyArray<string | StateNode<TContext, TEvent>> | undefined;
|
|
36
|
-
export declare function reportUnhandledExceptionOnInvocation(originalError: any, currentError: any, id: string): void;
|
|
37
18
|
export declare function toObserver<T>(nextHandler?: Observer<T> | ((value: T) => void), errorHandler?: (error: any) => void, completionHandler?: () => void): Observer<T>;
|
|
38
19
|
export declare function createInvokeId(stateNodeId: string, index: number): string;
|
|
39
20
|
export declare function resolveReferencedActor(machine: AnyStateMachine, src: string): any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-367eeb6f.cjs.js');
|
|
4
4
|
|
|
5
5
|
function createSpawner(actorScope, {
|
|
6
6
|
machine,
|
|
@@ -101,86 +101,6 @@ function assign(assignment) {
|
|
|
101
101
|
return assign;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
function resolveChoose(_, state, actionArgs, _actionParams, {
|
|
105
|
-
branches
|
|
106
|
-
}) {
|
|
107
|
-
const matchedActions = branches.find(condition => {
|
|
108
|
-
return !condition.guard || guards_dist_xstateGuards.evaluateGuard(condition.guard, state.context, actionArgs.event, state);
|
|
109
|
-
})?.actions;
|
|
110
|
-
return [state, undefined, guards_dist_xstateGuards.toArray(matchedActions)];
|
|
111
|
-
}
|
|
112
|
-
function choose(branches) {
|
|
113
|
-
function choose(args, params) {
|
|
114
|
-
}
|
|
115
|
-
choose.type = 'xstate.choose';
|
|
116
|
-
choose.branches = branches;
|
|
117
|
-
choose.resolve = resolveChoose;
|
|
118
|
-
return choose;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function resolveLog(_, state, actionArgs, actionParams, {
|
|
122
|
-
value,
|
|
123
|
-
label
|
|
124
|
-
}) {
|
|
125
|
-
return [state, {
|
|
126
|
-
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
127
|
-
label
|
|
128
|
-
}];
|
|
129
|
-
}
|
|
130
|
-
function executeLog({
|
|
131
|
-
logger
|
|
132
|
-
}, {
|
|
133
|
-
value,
|
|
134
|
-
label
|
|
135
|
-
}) {
|
|
136
|
-
if (label) {
|
|
137
|
-
logger(label, value);
|
|
138
|
-
} else {
|
|
139
|
-
logger(value);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
*
|
|
144
|
-
* @param expr The expression function to evaluate which will be logged.
|
|
145
|
-
* Takes in 2 arguments:
|
|
146
|
-
* - `ctx` - the current state context
|
|
147
|
-
* - `event` - the event that caused this action to be executed.
|
|
148
|
-
* @param label The label to give to the logged expression.
|
|
149
|
-
*/
|
|
150
|
-
function log(value = ({
|
|
151
|
-
context,
|
|
152
|
-
event
|
|
153
|
-
}) => ({
|
|
154
|
-
context,
|
|
155
|
-
event
|
|
156
|
-
}), label) {
|
|
157
|
-
function log(args, params) {
|
|
158
|
-
}
|
|
159
|
-
log.type = 'xstate.log';
|
|
160
|
-
log.value = value;
|
|
161
|
-
log.label = label;
|
|
162
|
-
log.resolve = resolveLog;
|
|
163
|
-
log.execute = executeLog;
|
|
164
|
-
return log;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function resolvePure(_, state, args, _actionParams, {
|
|
168
|
-
get
|
|
169
|
-
}) {
|
|
170
|
-
return [state, undefined, guards_dist_xstateGuards.toArray(get({
|
|
171
|
-
context: args.context,
|
|
172
|
-
event: args.event
|
|
173
|
-
}))];
|
|
174
|
-
}
|
|
175
|
-
function pure(getActions) {
|
|
176
|
-
function pure(args, params) {
|
|
177
|
-
}
|
|
178
|
-
pure.type = 'xstate.pure';
|
|
179
|
-
pure.get = getActions;
|
|
180
|
-
pure.resolve = resolvePure;
|
|
181
|
-
return pure;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
104
|
/**
|
|
185
105
|
*
|
|
186
106
|
* @remarks
|
|
@@ -371,12 +291,99 @@ function escalate(errorData, options) {
|
|
|
371
291
|
}, options);
|
|
372
292
|
}
|
|
373
293
|
|
|
294
|
+
function resolveEnqueueActions(_, state, args, _actionParams, {
|
|
295
|
+
collect
|
|
296
|
+
}) {
|
|
297
|
+
const actions = [];
|
|
298
|
+
const enqueue = function enqueue(action) {
|
|
299
|
+
actions.push(action);
|
|
300
|
+
};
|
|
301
|
+
enqueue.assign = (...args) => {
|
|
302
|
+
actions.push(assign(...args));
|
|
303
|
+
};
|
|
304
|
+
enqueue.cancel = (...args) => {
|
|
305
|
+
actions.push(guards_dist_xstateGuards.cancel(...args));
|
|
306
|
+
};
|
|
307
|
+
enqueue.raise = (...args) => {
|
|
308
|
+
actions.push(guards_dist_xstateGuards.raise(...args));
|
|
309
|
+
};
|
|
310
|
+
enqueue.sendTo = (...args) => {
|
|
311
|
+
actions.push(sendTo(...args));
|
|
312
|
+
};
|
|
313
|
+
enqueue.spawnChild = (...args) => {
|
|
314
|
+
actions.push(guards_dist_xstateGuards.spawnChild(...args));
|
|
315
|
+
};
|
|
316
|
+
enqueue.stopChild = (...args) => {
|
|
317
|
+
actions.push(guards_dist_xstateGuards.stopChild(...args));
|
|
318
|
+
};
|
|
319
|
+
collect({
|
|
320
|
+
context: args.context,
|
|
321
|
+
event: args.event,
|
|
322
|
+
enqueue,
|
|
323
|
+
check: guard => guards_dist_xstateGuards.evaluateGuard(guard, state.context, args.event, state)
|
|
324
|
+
});
|
|
325
|
+
return [state, undefined, actions];
|
|
326
|
+
}
|
|
327
|
+
function enqueueActions(collect) {
|
|
328
|
+
function enqueueActions(args, params) {
|
|
329
|
+
}
|
|
330
|
+
enqueueActions.type = 'xstate.enqueueActions';
|
|
331
|
+
enqueueActions.collect = collect;
|
|
332
|
+
enqueueActions.resolve = resolveEnqueueActions;
|
|
333
|
+
return enqueueActions;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function resolveLog(_, state, actionArgs, actionParams, {
|
|
337
|
+
value,
|
|
338
|
+
label
|
|
339
|
+
}) {
|
|
340
|
+
return [state, {
|
|
341
|
+
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
342
|
+
label
|
|
343
|
+
}];
|
|
344
|
+
}
|
|
345
|
+
function executeLog({
|
|
346
|
+
logger
|
|
347
|
+
}, {
|
|
348
|
+
value,
|
|
349
|
+
label
|
|
350
|
+
}) {
|
|
351
|
+
if (label) {
|
|
352
|
+
logger(label, value);
|
|
353
|
+
} else {
|
|
354
|
+
logger(value);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
*
|
|
359
|
+
* @param expr The expression function to evaluate which will be logged.
|
|
360
|
+
* Takes in 2 arguments:
|
|
361
|
+
* - `ctx` - the current state context
|
|
362
|
+
* - `event` - the event that caused this action to be executed.
|
|
363
|
+
* @param label The label to give to the logged expression.
|
|
364
|
+
*/
|
|
365
|
+
function log(value = ({
|
|
366
|
+
context,
|
|
367
|
+
event
|
|
368
|
+
}) => ({
|
|
369
|
+
context,
|
|
370
|
+
event
|
|
371
|
+
}), label) {
|
|
372
|
+
function log(args, params) {
|
|
373
|
+
}
|
|
374
|
+
log.type = 'xstate.log';
|
|
375
|
+
log.value = value;
|
|
376
|
+
log.label = label;
|
|
377
|
+
log.resolve = resolveLog;
|
|
378
|
+
log.execute = executeLog;
|
|
379
|
+
return log;
|
|
380
|
+
}
|
|
381
|
+
|
|
374
382
|
exports.SpecialTargets = SpecialTargets;
|
|
375
383
|
exports.assign = assign;
|
|
376
|
-
exports.
|
|
384
|
+
exports.enqueueActions = enqueueActions;
|
|
377
385
|
exports.escalate = escalate;
|
|
378
386
|
exports.forwardTo = forwardTo;
|
|
379
387
|
exports.log = log;
|
|
380
|
-
exports.pure = pure;
|
|
381
388
|
exports.sendParent = sendParent;
|
|
382
389
|
exports.sendTo = sendTo;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, e as evaluateGuard,
|
|
1
|
+
import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, U as XSTATE_ERROR, V as createErrorActorEvent, e as evaluateGuard, L as cancel, M as raise, O as spawnChild, Q as stopChild } from './raise-f71460d6.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, {
|
|
4
4
|
machine,
|
|
@@ -99,86 +99,6 @@ function assign(assignment) {
|
|
|
99
99
|
return assign;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
function resolveChoose(_, state, actionArgs, _actionParams, {
|
|
103
|
-
branches
|
|
104
|
-
}) {
|
|
105
|
-
const matchedActions = branches.find(condition => {
|
|
106
|
-
return !condition.guard || evaluateGuard(condition.guard, state.context, actionArgs.event, state);
|
|
107
|
-
})?.actions;
|
|
108
|
-
return [state, undefined, toArray(matchedActions)];
|
|
109
|
-
}
|
|
110
|
-
function choose(branches) {
|
|
111
|
-
function choose(args, params) {
|
|
112
|
-
}
|
|
113
|
-
choose.type = 'xstate.choose';
|
|
114
|
-
choose.branches = branches;
|
|
115
|
-
choose.resolve = resolveChoose;
|
|
116
|
-
return choose;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function resolveLog(_, state, actionArgs, actionParams, {
|
|
120
|
-
value,
|
|
121
|
-
label
|
|
122
|
-
}) {
|
|
123
|
-
return [state, {
|
|
124
|
-
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
125
|
-
label
|
|
126
|
-
}];
|
|
127
|
-
}
|
|
128
|
-
function executeLog({
|
|
129
|
-
logger
|
|
130
|
-
}, {
|
|
131
|
-
value,
|
|
132
|
-
label
|
|
133
|
-
}) {
|
|
134
|
-
if (label) {
|
|
135
|
-
logger(label, value);
|
|
136
|
-
} else {
|
|
137
|
-
logger(value);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
*
|
|
142
|
-
* @param expr The expression function to evaluate which will be logged.
|
|
143
|
-
* Takes in 2 arguments:
|
|
144
|
-
* - `ctx` - the current state context
|
|
145
|
-
* - `event` - the event that caused this action to be executed.
|
|
146
|
-
* @param label The label to give to the logged expression.
|
|
147
|
-
*/
|
|
148
|
-
function log(value = ({
|
|
149
|
-
context,
|
|
150
|
-
event
|
|
151
|
-
}) => ({
|
|
152
|
-
context,
|
|
153
|
-
event
|
|
154
|
-
}), label) {
|
|
155
|
-
function log(args, params) {
|
|
156
|
-
}
|
|
157
|
-
log.type = 'xstate.log';
|
|
158
|
-
log.value = value;
|
|
159
|
-
log.label = label;
|
|
160
|
-
log.resolve = resolveLog;
|
|
161
|
-
log.execute = executeLog;
|
|
162
|
-
return log;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function resolvePure(_, state, args, _actionParams, {
|
|
166
|
-
get
|
|
167
|
-
}) {
|
|
168
|
-
return [state, undefined, toArray(get({
|
|
169
|
-
context: args.context,
|
|
170
|
-
event: args.event
|
|
171
|
-
}))];
|
|
172
|
-
}
|
|
173
|
-
function pure(getActions) {
|
|
174
|
-
function pure(args, params) {
|
|
175
|
-
}
|
|
176
|
-
pure.type = 'xstate.pure';
|
|
177
|
-
pure.get = getActions;
|
|
178
|
-
pure.resolve = resolvePure;
|
|
179
|
-
return pure;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
102
|
/**
|
|
183
103
|
*
|
|
184
104
|
* @remarks
|
|
@@ -369,4 +289,92 @@ function escalate(errorData, options) {
|
|
|
369
289
|
}, options);
|
|
370
290
|
}
|
|
371
291
|
|
|
372
|
-
|
|
292
|
+
function resolveEnqueueActions(_, state, args, _actionParams, {
|
|
293
|
+
collect
|
|
294
|
+
}) {
|
|
295
|
+
const actions = [];
|
|
296
|
+
const enqueue = function enqueue(action) {
|
|
297
|
+
actions.push(action);
|
|
298
|
+
};
|
|
299
|
+
enqueue.assign = (...args) => {
|
|
300
|
+
actions.push(assign(...args));
|
|
301
|
+
};
|
|
302
|
+
enqueue.cancel = (...args) => {
|
|
303
|
+
actions.push(cancel(...args));
|
|
304
|
+
};
|
|
305
|
+
enqueue.raise = (...args) => {
|
|
306
|
+
actions.push(raise(...args));
|
|
307
|
+
};
|
|
308
|
+
enqueue.sendTo = (...args) => {
|
|
309
|
+
actions.push(sendTo(...args));
|
|
310
|
+
};
|
|
311
|
+
enqueue.spawnChild = (...args) => {
|
|
312
|
+
actions.push(spawnChild(...args));
|
|
313
|
+
};
|
|
314
|
+
enqueue.stopChild = (...args) => {
|
|
315
|
+
actions.push(stopChild(...args));
|
|
316
|
+
};
|
|
317
|
+
collect({
|
|
318
|
+
context: args.context,
|
|
319
|
+
event: args.event,
|
|
320
|
+
enqueue,
|
|
321
|
+
check: guard => evaluateGuard(guard, state.context, args.event, state)
|
|
322
|
+
});
|
|
323
|
+
return [state, undefined, actions];
|
|
324
|
+
}
|
|
325
|
+
function enqueueActions(collect) {
|
|
326
|
+
function enqueueActions(args, params) {
|
|
327
|
+
}
|
|
328
|
+
enqueueActions.type = 'xstate.enqueueActions';
|
|
329
|
+
enqueueActions.collect = collect;
|
|
330
|
+
enqueueActions.resolve = resolveEnqueueActions;
|
|
331
|
+
return enqueueActions;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function resolveLog(_, state, actionArgs, actionParams, {
|
|
335
|
+
value,
|
|
336
|
+
label
|
|
337
|
+
}) {
|
|
338
|
+
return [state, {
|
|
339
|
+
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
340
|
+
label
|
|
341
|
+
}];
|
|
342
|
+
}
|
|
343
|
+
function executeLog({
|
|
344
|
+
logger
|
|
345
|
+
}, {
|
|
346
|
+
value,
|
|
347
|
+
label
|
|
348
|
+
}) {
|
|
349
|
+
if (label) {
|
|
350
|
+
logger(label, value);
|
|
351
|
+
} else {
|
|
352
|
+
logger(value);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
*
|
|
357
|
+
* @param expr The expression function to evaluate which will be logged.
|
|
358
|
+
* Takes in 2 arguments:
|
|
359
|
+
* - `ctx` - the current state context
|
|
360
|
+
* - `event` - the event that caused this action to be executed.
|
|
361
|
+
* @param label The label to give to the logged expression.
|
|
362
|
+
*/
|
|
363
|
+
function log(value = ({
|
|
364
|
+
context,
|
|
365
|
+
event
|
|
366
|
+
}) => ({
|
|
367
|
+
context,
|
|
368
|
+
event
|
|
369
|
+
}), label) {
|
|
370
|
+
function log(args, params) {
|
|
371
|
+
}
|
|
372
|
+
log.type = 'xstate.log';
|
|
373
|
+
log.value = value;
|
|
374
|
+
log.label = label;
|
|
375
|
+
log.resolve = resolveLog;
|
|
376
|
+
log.execute = executeLog;
|
|
377
|
+
return log;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export { SpecialTargets as S, assign as a, escalate as b, sendTo as c, enqueueActions as e, forwardTo as f, log as l, sendParent as s };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, e as evaluateGuard,
|
|
1
|
+
import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, U as XSTATE_ERROR, V as createErrorActorEvent, e as evaluateGuard, L as cancel, M as raise, O as spawnChild, Q as stopChild } from './raise-1caefe80.development.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, {
|
|
4
4
|
machine,
|
|
@@ -102,95 +102,6 @@ function assign(assignment) {
|
|
|
102
102
|
return assign;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
function resolveChoose(_, state, actionArgs, _actionParams, {
|
|
106
|
-
branches
|
|
107
|
-
}) {
|
|
108
|
-
const matchedActions = branches.find(condition => {
|
|
109
|
-
return !condition.guard || evaluateGuard(condition.guard, state.context, actionArgs.event, state);
|
|
110
|
-
})?.actions;
|
|
111
|
-
return [state, undefined, toArray(matchedActions)];
|
|
112
|
-
}
|
|
113
|
-
function choose(branches) {
|
|
114
|
-
function choose(args, params) {
|
|
115
|
-
{
|
|
116
|
-
throw new Error(`This isn't supposed to be called`);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
choose.type = 'xstate.choose';
|
|
120
|
-
choose.branches = branches;
|
|
121
|
-
choose.resolve = resolveChoose;
|
|
122
|
-
return choose;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function resolveLog(_, state, actionArgs, actionParams, {
|
|
126
|
-
value,
|
|
127
|
-
label
|
|
128
|
-
}) {
|
|
129
|
-
return [state, {
|
|
130
|
-
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
131
|
-
label
|
|
132
|
-
}];
|
|
133
|
-
}
|
|
134
|
-
function executeLog({
|
|
135
|
-
logger
|
|
136
|
-
}, {
|
|
137
|
-
value,
|
|
138
|
-
label
|
|
139
|
-
}) {
|
|
140
|
-
if (label) {
|
|
141
|
-
logger(label, value);
|
|
142
|
-
} else {
|
|
143
|
-
logger(value);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
*
|
|
148
|
-
* @param expr The expression function to evaluate which will be logged.
|
|
149
|
-
* Takes in 2 arguments:
|
|
150
|
-
* - `ctx` - the current state context
|
|
151
|
-
* - `event` - the event that caused this action to be executed.
|
|
152
|
-
* @param label The label to give to the logged expression.
|
|
153
|
-
*/
|
|
154
|
-
function log(value = ({
|
|
155
|
-
context,
|
|
156
|
-
event
|
|
157
|
-
}) => ({
|
|
158
|
-
context,
|
|
159
|
-
event
|
|
160
|
-
}), label) {
|
|
161
|
-
function log(args, params) {
|
|
162
|
-
{
|
|
163
|
-
throw new Error(`This isn't supposed to be called`);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
log.type = 'xstate.log';
|
|
167
|
-
log.value = value;
|
|
168
|
-
log.label = label;
|
|
169
|
-
log.resolve = resolveLog;
|
|
170
|
-
log.execute = executeLog;
|
|
171
|
-
return log;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
function resolvePure(_, state, args, _actionParams, {
|
|
175
|
-
get
|
|
176
|
-
}) {
|
|
177
|
-
return [state, undefined, toArray(get({
|
|
178
|
-
context: args.context,
|
|
179
|
-
event: args.event
|
|
180
|
-
}))];
|
|
181
|
-
}
|
|
182
|
-
function pure(getActions) {
|
|
183
|
-
function pure(args, params) {
|
|
184
|
-
{
|
|
185
|
-
throw new Error(`This isn't supposed to be called`);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
pure.type = 'xstate.pure';
|
|
189
|
-
pure.get = getActions;
|
|
190
|
-
pure.resolve = resolvePure;
|
|
191
|
-
return pure;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
105
|
/**
|
|
195
106
|
*
|
|
196
107
|
* @remarks
|
|
@@ -394,4 +305,98 @@ function escalate(errorData, options) {
|
|
|
394
305
|
}, options);
|
|
395
306
|
}
|
|
396
307
|
|
|
397
|
-
|
|
308
|
+
function resolveEnqueueActions(_, state, args, _actionParams, {
|
|
309
|
+
collect
|
|
310
|
+
}) {
|
|
311
|
+
const actions = [];
|
|
312
|
+
const enqueue = function enqueue(action) {
|
|
313
|
+
actions.push(action);
|
|
314
|
+
};
|
|
315
|
+
enqueue.assign = (...args) => {
|
|
316
|
+
actions.push(assign(...args));
|
|
317
|
+
};
|
|
318
|
+
enqueue.cancel = (...args) => {
|
|
319
|
+
actions.push(cancel(...args));
|
|
320
|
+
};
|
|
321
|
+
enqueue.raise = (...args) => {
|
|
322
|
+
actions.push(raise(...args));
|
|
323
|
+
};
|
|
324
|
+
enqueue.sendTo = (...args) => {
|
|
325
|
+
actions.push(sendTo(...args));
|
|
326
|
+
};
|
|
327
|
+
enqueue.spawnChild = (...args) => {
|
|
328
|
+
actions.push(spawnChild(...args));
|
|
329
|
+
};
|
|
330
|
+
enqueue.stopChild = (...args) => {
|
|
331
|
+
actions.push(stopChild(...args));
|
|
332
|
+
};
|
|
333
|
+
collect({
|
|
334
|
+
context: args.context,
|
|
335
|
+
event: args.event,
|
|
336
|
+
enqueue,
|
|
337
|
+
check: guard => evaluateGuard(guard, state.context, args.event, state)
|
|
338
|
+
});
|
|
339
|
+
return [state, undefined, actions];
|
|
340
|
+
}
|
|
341
|
+
function enqueueActions(collect) {
|
|
342
|
+
function enqueueActions(args, params) {
|
|
343
|
+
{
|
|
344
|
+
throw new Error(`This isn't supposed to be called`);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
enqueueActions.type = 'xstate.enqueueActions';
|
|
348
|
+
enqueueActions.collect = collect;
|
|
349
|
+
enqueueActions.resolve = resolveEnqueueActions;
|
|
350
|
+
return enqueueActions;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function resolveLog(_, state, actionArgs, actionParams, {
|
|
354
|
+
value,
|
|
355
|
+
label
|
|
356
|
+
}) {
|
|
357
|
+
return [state, {
|
|
358
|
+
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
359
|
+
label
|
|
360
|
+
}];
|
|
361
|
+
}
|
|
362
|
+
function executeLog({
|
|
363
|
+
logger
|
|
364
|
+
}, {
|
|
365
|
+
value,
|
|
366
|
+
label
|
|
367
|
+
}) {
|
|
368
|
+
if (label) {
|
|
369
|
+
logger(label, value);
|
|
370
|
+
} else {
|
|
371
|
+
logger(value);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
*
|
|
376
|
+
* @param expr The expression function to evaluate which will be logged.
|
|
377
|
+
* Takes in 2 arguments:
|
|
378
|
+
* - `ctx` - the current state context
|
|
379
|
+
* - `event` - the event that caused this action to be executed.
|
|
380
|
+
* @param label The label to give to the logged expression.
|
|
381
|
+
*/
|
|
382
|
+
function log(value = ({
|
|
383
|
+
context,
|
|
384
|
+
event
|
|
385
|
+
}) => ({
|
|
386
|
+
context,
|
|
387
|
+
event
|
|
388
|
+
}), label) {
|
|
389
|
+
function log(args, params) {
|
|
390
|
+
{
|
|
391
|
+
throw new Error(`This isn't supposed to be called`);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
log.type = 'xstate.log';
|
|
395
|
+
log.value = value;
|
|
396
|
+
log.label = label;
|
|
397
|
+
log.resolve = resolveLog;
|
|
398
|
+
log.execute = executeLog;
|
|
399
|
+
return log;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
export { SpecialTargets as S, assign as a, escalate as b, sendTo as c, enqueueActions as e, forwardTo as f, log as l, sendParent as s };
|