xstate 5.5.2 → 5.6.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/actions/dist/xstate-actions.cjs.js +2 -2
- package/actions/dist/xstate-actions.development.cjs.js +2 -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 +1 -1
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/declarations/src/StateMachine.d.ts +7 -2
- package/dist/declarations/src/createActor.d.ts +8 -2
- package/dist/declarations/src/createMachine.d.ts +5 -2
- package/dist/declarations/src/setup.d.ts +3 -2
- package/dist/declarations/src/types.d.ts +26 -3
- package/dist/{log-98537fde.development.cjs.js → log-75c83841.development.cjs.js} +2 -10
- package/dist/{log-97cf155c.esm.js → log-b6ecfc82.esm.js} +2 -10
- package/dist/{log-fd06e64a.cjs.js → log-c5c46d15.cjs.js} +2 -10
- package/dist/{log-c0102fcf.development.esm.js → log-edca19d9.development.esm.js} +2 -10
- package/dist/{raise-df36f61b.development.esm.js → raise-2fdbadc6.development.esm.js} +1 -2
- package/dist/{raise-cdf69ebb.esm.js → raise-309d511a.esm.js} +1 -2
- package/dist/{raise-ca850521.cjs.js → raise-540fdaf2.cjs.js} +1 -2
- package/dist/{raise-0743d1df.development.cjs.js → raise-d7d9caaa.development.cjs.js} +1 -2
- package/dist/xstate.cjs.js +11 -5
- package/dist/xstate.development.cjs.js +11 -5
- package/dist/xstate.development.esm.js +13 -7
- package/dist/xstate.esm.js +13 -7
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StateMachine } from "./StateMachine.js";
|
|
2
2
|
import { ResolveTypegenMeta, TypegenConstraint, TypegenDisabled } from "./typegenTypes.js";
|
|
3
|
-
import { AnyActorRef, AnyEventObject, Cast, InternalMachineImplementations, IsNever, MachineConfig, MachineContext, NonReducibleUnknown, ParameterizedObject, Prop, ProvidedActor, StateValue, ToChildren } from "./types.js";
|
|
3
|
+
import { AnyActorRef, AnyEventObject, Cast, InternalMachineImplementations, IsNever, MachineConfig, MachineContext, MachineTypes, NonReducibleUnknown, ParameterizedObject, Prop, ProvidedActor, StateValue, ToChildren } from "./types.js";
|
|
4
4
|
type TestValue = string | {
|
|
5
5
|
[k: string]: TestValue | undefined;
|
|
6
6
|
};
|
|
@@ -56,5 +56,8 @@ type ToStateValue<TTestValue extends string | TestValue> = FilterLeafValues<Grou
|
|
|
56
56
|
```
|
|
57
57
|
*/
|
|
58
58
|
export declare function createMachine<TContext extends MachineContext, TEvent extends AnyEventObject, // TODO: consider using a stricter `EventObject` here
|
|
59
|
-
TActor extends ProvidedActor, TAction extends ParameterizedObject, TGuard extends ParameterizedObject, TDelay extends string, TTag extends string, TInput, TOutput extends NonReducibleUnknown, TTypesMeta extends TypegenConstraint = TypegenDisabled>(config:
|
|
59
|
+
TActor extends ProvidedActor, TAction extends ParameterizedObject, TGuard extends ParameterizedObject, TDelay extends string, TTag extends string, TInput, TOutput extends NonReducibleUnknown, TTypesMeta extends TypegenConstraint = TypegenDisabled>(config: {
|
|
60
|
+
types?: MachineTypes<TContext, TEvent, TActor, TAction, TGuard, TDelay, TTag, TInput, TOutput, TTypesMeta>;
|
|
61
|
+
schemas?: unknown;
|
|
62
|
+
} & MachineConfig<TContext, TEvent, TActor, TAction, TGuard, TDelay, TTag, TInput, TOutput, TTypesMeta>, implementations?: InternalMachineImplementations<TContext, ResolveTypegenMeta<TTypesMeta, TEvent, TActor, TAction, TGuard, TDelay, TTag>>): StateMachine<TContext, TEvent, Cast<ToChildren<TActor>, Record<string, AnyActorRef | undefined>>, TActor, TAction, TGuard, TDelay, 'matchesStates' extends keyof TTypesMeta ? ToStateValue<Cast<TTypesMeta['matchesStates'], TestValue>> : StateValue, Prop<ResolveTypegenMeta<TTypesMeta, TEvent, TActor, TAction, TGuard, TDelay, TTag>['resolved'], 'tags'> & string, TInput, TOutput, ResolveTypegenMeta<TTypesMeta, TEvent, TActor, TAction, TGuard, TDelay, TTag>>;
|
|
60
63
|
export {};
|
|
@@ -13,7 +13,7 @@ type ToProvidedActor<TChildrenMap extends Record<string, string>, TActors extend
|
|
|
13
13
|
[K in keyof TResolvedActors & string]: {
|
|
14
14
|
src: K;
|
|
15
15
|
logic: TResolvedActors[K];
|
|
16
|
-
id: IsNever<TChildrenMap> extends true ? string | undefined : K extends keyof Invert<TChildrenMap> ? Invert<TChildrenMap>[K] : string | undefined;
|
|
16
|
+
id: IsNever<TChildrenMap> extends true ? string | undefined : K extends keyof Invert<TChildrenMap> ? Invert<TChildrenMap>[K] & string : string | undefined;
|
|
17
17
|
};
|
|
18
18
|
}>;
|
|
19
19
|
type _GroupStateKeys<T extends StateSchema, S extends keyof T['states']> = S extends any ? T['states'][S] extends {
|
|
@@ -33,7 +33,8 @@ type ToStateValue<T extends StateSchema> = T extends {
|
|
|
33
33
|
type: 'parallel';
|
|
34
34
|
} ? true : false> : never) : {};
|
|
35
35
|
export declare function setup<TContext extends MachineContext, TEvent extends AnyEventObject, // TODO: consider using a stricter `EventObject` here
|
|
36
|
-
TActors extends Record<Values<TChildrenMap>, UnknownActorLogic>, TActions extends Record<string, ParameterizedObject['params'] | undefined>, TGuards extends Record<string, ParameterizedObject['params'] | undefined>, TDelay extends string, TTag extends string, TInput, TOutput extends NonReducibleUnknown, TChildrenMap extends Record<string, string> = never>({ actors, actions, guards, delays }: {
|
|
36
|
+
TActors extends Record<Values<TChildrenMap>, UnknownActorLogic>, TActions extends Record<string, ParameterizedObject['params'] | undefined>, TGuards extends Record<string, ParameterizedObject['params'] | undefined>, TDelay extends string, TTag extends string, TInput, TOutput extends NonReducibleUnknown, TChildrenMap extends Record<string, string> = never>({ schemas, actors, actions, guards, delays }: {
|
|
37
|
+
schemas?: unknown;
|
|
37
38
|
types?: SetupTypes<TContext, TEvent, TChildrenMap, TTag, TInput, TOutput>;
|
|
38
39
|
actors?: {
|
|
39
40
|
[K in keyof TActors]: TActors[K];
|
|
@@ -3,7 +3,7 @@ import type { StateMachine } from "./StateMachine.js";
|
|
|
3
3
|
import type { StateNode } from "./StateNode.js";
|
|
4
4
|
import { AssignArgs } from "./actions/assign.js";
|
|
5
5
|
import { PromiseActorLogic } from "./actors/promise.js";
|
|
6
|
-
import { Guard, UnknownGuard } from "./guards.js";
|
|
6
|
+
import { Guard, GuardPredicate, UnknownGuard } from "./guards.js";
|
|
7
7
|
import type { Actor } from "./createActor.js";
|
|
8
8
|
import { Spawner } from "./spawn.js";
|
|
9
9
|
import { AnyActorSystem, InspectionEvent, Clock } from './system.js';
|
|
@@ -119,7 +119,7 @@ export type UnknownAction = Action<MachineContext, EventObject, EventObject, Par
|
|
|
119
119
|
export type Actions<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TActor extends ProvidedActor, TAction extends ParameterizedObject, TGuard extends ParameterizedObject, TDelay extends string> = SingleOrArray<Action<TContext, TExpressionEvent, TEvent, TParams, TActor, TAction, TGuard, TDelay>>;
|
|
120
120
|
export type StateKey = string | AnyMachineSnapshot;
|
|
121
121
|
export interface StateValueMap {
|
|
122
|
-
[key: string]: StateValue;
|
|
122
|
+
[key: string]: StateValue | undefined;
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
125
|
* The string or object representing the state value relative to the parent state node.
|
|
@@ -383,8 +383,25 @@ export type ActionFunctionMap<TContext extends MachineContext, TEvent extends Ev
|
|
|
383
383
|
type: K;
|
|
384
384
|
} ? TAction : never>, TActor, TAction, TGuard, TDelay>;
|
|
385
385
|
};
|
|
386
|
+
type GuardMap<TContext extends MachineContext, TEvent extends EventObject, TGuard extends ParameterizedObject> = {
|
|
387
|
+
[K in TGuard['type']]?: GuardPredicate<TContext, TEvent, GetParameterizedParams<TGuard extends {
|
|
388
|
+
type: K;
|
|
389
|
+
} ? TGuard : never>, TGuard>;
|
|
390
|
+
};
|
|
386
391
|
export type DelayFunctionMap<TContext extends MachineContext, TEvent extends EventObject, TAction extends ParameterizedObject> = Record<string, DelayConfig<TContext, TEvent, TAction['params'], TEvent>>;
|
|
387
392
|
export type DelayConfig<TContext extends MachineContext, TExpressionEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TEvent extends EventObject> = number | DelayExpr<TContext, TExpressionEvent, TParams, TEvent>;
|
|
393
|
+
/**
|
|
394
|
+
* @hidden
|
|
395
|
+
*/
|
|
396
|
+
export interface MachineImplementationsSimplified<TContext extends MachineContext, TEvent extends EventObject, TActor extends ProvidedActor = ProvidedActor, TAction extends ParameterizedObject = ParameterizedObject, TGuard extends ParameterizedObject = ParameterizedObject> {
|
|
397
|
+
guards: GuardMap<TContext, TEvent, TGuard>;
|
|
398
|
+
actions: ActionFunctionMap<TContext, TEvent, TActor, TAction>;
|
|
399
|
+
actors: Record<string, AnyActorLogic | {
|
|
400
|
+
src: AnyActorLogic;
|
|
401
|
+
input: Mapper<TContext, TEvent, unknown, TEvent> | NonReducibleUnknown;
|
|
402
|
+
}>;
|
|
403
|
+
delays: DelayFunctionMap<TContext, TEvent, TAction>;
|
|
404
|
+
}
|
|
388
405
|
type MaybeNarrowedEvent<TIndexedEvents, TCausingLookup, K> = Cast<Prop<TIndexedEvents, K extends keyof TCausingLookup ? TCausingLookup[K] : TIndexedEvents[keyof TIndexedEvents]>, EventObject>;
|
|
389
406
|
type MachineImplementationsActions<TContext extends MachineContext, TResolvedTypesMeta, TEventsCausingActions = Prop<Prop<TResolvedTypesMeta, 'resolved'>, 'eventsCausingActions'>, TIndexedEvents = Prop<Prop<TResolvedTypesMeta, 'resolved'>, 'indexedEvents'>, TIndexedActors = Prop<Prop<TResolvedTypesMeta, 'resolved'>, 'indexedActors'>, TIndexedActions = Prop<Prop<TResolvedTypesMeta, 'resolved'>, 'indexedActions'>, TIndexedGuards = Prop<Prop<TResolvedTypesMeta, 'resolved'>, 'indexedGuards'>, TIndexedDelays = Prop<Prop<TResolvedTypesMeta, 'resolved'>, 'indexedDelays'>> = {
|
|
390
407
|
[K in keyof TIndexedActions]?: ActionFunction<TContext, MaybeNarrowedEvent<TIndexedEvents, TEventsCausingActions, K>, Cast<Prop<TIndexedEvents, keyof TIndexedEvents>, EventObject>, GetParameterizedParams<Cast<TIndexedActions[K], ParameterizedObject>>, Cast<Prop<TIndexedActors, keyof TIndexedActors>, ProvidedActor>, Cast<Prop<TIndexedActions, keyof TIndexedActions>, ParameterizedObject>, Cast<Prop<TIndexedGuards, keyof TIndexedGuards>, ParameterizedObject>, Cast<Prop<TIndexedDelays, keyof TIndexedDelays>, ParameterizedObject>['type']>;
|
|
@@ -433,13 +450,13 @@ export type MachineConfig<TContext extends MachineContext, TEvent extends EventO
|
|
|
433
450
|
* The machine's own version.
|
|
434
451
|
*/
|
|
435
452
|
version?: string;
|
|
436
|
-
types?: MachineTypes<TContext, TEvent, TActor, TAction, TGuard, TDelay, TTag, TInput, TOutput, TTypesMeta>;
|
|
437
453
|
output?: Mapper<TContext, DoneStateEvent, TOutput, TEvent> | TOutput;
|
|
438
454
|
}) & (MachineContext extends TContext ? {
|
|
439
455
|
context?: InitialContext<LowInfer<TContext>, TActor, TInput, TEvent>;
|
|
440
456
|
} : {
|
|
441
457
|
context: InitialContext<LowInfer<TContext>, TActor, TInput, TEvent>;
|
|
442
458
|
});
|
|
459
|
+
export type UnknownMachineConfig = MachineConfig<MachineContext, EventObject>;
|
|
443
460
|
export interface ProvidedActor {
|
|
444
461
|
src: string;
|
|
445
462
|
logic: UnknownActorLogic;
|
|
@@ -705,6 +722,12 @@ export type Observer<T> = {
|
|
|
705
722
|
export interface Subscription {
|
|
706
723
|
unsubscribe(): void;
|
|
707
724
|
}
|
|
725
|
+
export interface InteropObservable<T> {
|
|
726
|
+
[Symbol.observable]: () => InteropSubscribable<T>;
|
|
727
|
+
}
|
|
728
|
+
export interface InteropSubscribable<T> {
|
|
729
|
+
subscribe(observer: Observer<T>): Subscription;
|
|
730
|
+
}
|
|
708
731
|
export interface Subscribable<T> extends InteropSubscribable<T> {
|
|
709
732
|
subscribe(observer: Observer<T>): Subscription;
|
|
710
733
|
subscribe(next: (value: T) => void, error?: (error: any) => void, complete?: () => void): Subscription;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-d7d9caaa.development.cjs.js');
|
|
4
4
|
|
|
5
5
|
// it's likely-ish that `(TActor & { src: TSrc })['logic']` would be faster
|
|
6
6
|
// but it's only possible to do it since https://github.com/microsoft/TypeScript/pull/53098 (TS 5.1)
|
|
@@ -171,7 +171,7 @@ function assign(assignment) {
|
|
|
171
171
|
|
|
172
172
|
// TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
|
|
173
173
|
/**
|
|
174
|
-
* @
|
|
174
|
+
* @hidden
|
|
175
175
|
*/
|
|
176
176
|
let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
177
177
|
SpecialTargets["Parent"] = "#_parent";
|
|
@@ -185,14 +185,6 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
185
185
|
|
|
186
186
|
// Based on RxJS types
|
|
187
187
|
|
|
188
|
-
/**
|
|
189
|
-
* @internal
|
|
190
|
-
*/
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* @internal
|
|
194
|
-
*/
|
|
195
|
-
|
|
196
188
|
/**
|
|
197
189
|
* @deprecated Use `Actor<T>` instead.
|
|
198
190
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as ProcessingStatus, z as resolveReferencedActor, A as createActor, U as cloneMachineSnapshot, V as XSTATE_ERROR, W as createErrorActorEvent, e as evaluateGuard, M as cancel, O as raise, P as spawnChild, R as stopChild } from './raise-
|
|
1
|
+
import { T as ProcessingStatus, z as resolveReferencedActor, A as createActor, U as cloneMachineSnapshot, V as XSTATE_ERROR, W as createErrorActorEvent, e as evaluateGuard, M as cancel, O as raise, P as spawnChild, R as stopChild } from './raise-309d511a.esm.js';
|
|
2
2
|
|
|
3
3
|
// it's likely-ish that `(TActor & { src: TSrc })['logic']` would be faster
|
|
4
4
|
// but it's only possible to do it since https://github.com/microsoft/TypeScript/pull/53098 (TS 5.1)
|
|
@@ -166,7 +166,7 @@ function assign(assignment) {
|
|
|
166
166
|
|
|
167
167
|
// TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
|
|
168
168
|
/**
|
|
169
|
-
* @
|
|
169
|
+
* @hidden
|
|
170
170
|
*/
|
|
171
171
|
let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
172
172
|
SpecialTargets["Parent"] = "#_parent";
|
|
@@ -180,14 +180,6 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
180
180
|
|
|
181
181
|
// Based on RxJS types
|
|
182
182
|
|
|
183
|
-
/**
|
|
184
|
-
* @internal
|
|
185
|
-
*/
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* @internal
|
|
189
|
-
*/
|
|
190
|
-
|
|
191
183
|
/**
|
|
192
184
|
* @deprecated Use `Actor<T>` instead.
|
|
193
185
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-540fdaf2.cjs.js');
|
|
4
4
|
|
|
5
5
|
// it's likely-ish that `(TActor & { src: TSrc })['logic']` would be faster
|
|
6
6
|
// but it's only possible to do it since https://github.com/microsoft/TypeScript/pull/53098 (TS 5.1)
|
|
@@ -168,7 +168,7 @@ function assign(assignment) {
|
|
|
168
168
|
|
|
169
169
|
// TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
|
|
170
170
|
/**
|
|
171
|
-
* @
|
|
171
|
+
* @hidden
|
|
172
172
|
*/
|
|
173
173
|
let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
174
174
|
SpecialTargets["Parent"] = "#_parent";
|
|
@@ -182,14 +182,6 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
182
182
|
|
|
183
183
|
// Based on RxJS types
|
|
184
184
|
|
|
185
|
-
/**
|
|
186
|
-
* @internal
|
|
187
|
-
*/
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* @internal
|
|
191
|
-
*/
|
|
192
|
-
|
|
193
185
|
/**
|
|
194
186
|
* @deprecated Use `Actor<T>` instead.
|
|
195
187
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as ProcessingStatus, z as resolveReferencedActor, A as createActor, U as cloneMachineSnapshot, V as XSTATE_ERROR, W as createErrorActorEvent, e as evaluateGuard, M as cancel, O as raise, P as spawnChild, R as stopChild } from './raise-
|
|
1
|
+
import { T as ProcessingStatus, z as resolveReferencedActor, A as createActor, U as cloneMachineSnapshot, V as XSTATE_ERROR, W as createErrorActorEvent, e as evaluateGuard, M as cancel, O as raise, P as spawnChild, R as stopChild } from './raise-2fdbadc6.development.esm.js';
|
|
2
2
|
|
|
3
3
|
// it's likely-ish that `(TActor & { src: TSrc })['logic']` would be faster
|
|
4
4
|
// but it's only possible to do it since https://github.com/microsoft/TypeScript/pull/53098 (TS 5.1)
|
|
@@ -169,7 +169,7 @@ function assign(assignment) {
|
|
|
169
169
|
|
|
170
170
|
// TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
|
|
171
171
|
/**
|
|
172
|
-
* @
|
|
172
|
+
* @hidden
|
|
173
173
|
*/
|
|
174
174
|
let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
175
175
|
SpecialTargets["Parent"] = "#_parent";
|
|
@@ -183,14 +183,6 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
183
183
|
|
|
184
184
|
// Based on RxJS types
|
|
185
185
|
|
|
186
|
-
/**
|
|
187
|
-
* @internal
|
|
188
|
-
*/
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* @internal
|
|
192
|
-
*/
|
|
193
|
-
|
|
194
186
|
/**
|
|
195
187
|
* @deprecated Use `Actor<T>` instead.
|
|
196
188
|
*/
|
|
@@ -975,7 +975,6 @@ class Actor {
|
|
|
975
975
|
return this._snapshot;
|
|
976
976
|
}
|
|
977
977
|
}
|
|
978
|
-
|
|
979
978
|
/**
|
|
980
979
|
* Creates a new actor instance for the given actor logic with the provided options, if any.
|
|
981
980
|
*
|
|
@@ -1008,7 +1007,7 @@ class Actor {
|
|
|
1008
1007
|
* @param logic - The actor logic to create an actor from. For a state machine actor logic creator, see {@link createMachine}. Other actor logic creators include {@link fromCallback}, {@link fromEventObservable}, {@link fromObservable}, {@link fromPromise}, and {@link fromTransition}.
|
|
1009
1008
|
* @param options - Actor options
|
|
1010
1009
|
*/
|
|
1011
|
-
function createActor(logic, options) {
|
|
1010
|
+
function createActor(logic, ...[options]) {
|
|
1012
1011
|
return new Actor(logic, options);
|
|
1013
1012
|
}
|
|
1014
1013
|
|
|
@@ -961,7 +961,6 @@ class Actor {
|
|
|
961
961
|
return this._snapshot;
|
|
962
962
|
}
|
|
963
963
|
}
|
|
964
|
-
|
|
965
964
|
/**
|
|
966
965
|
* Creates a new actor instance for the given actor logic with the provided options, if any.
|
|
967
966
|
*
|
|
@@ -994,7 +993,7 @@ class Actor {
|
|
|
994
993
|
* @param logic - The actor logic to create an actor from. For a state machine actor logic creator, see {@link createMachine}. Other actor logic creators include {@link fromCallback}, {@link fromEventObservable}, {@link fromObservable}, {@link fromPromise}, and {@link fromTransition}.
|
|
995
994
|
* @param options - Actor options
|
|
996
995
|
*/
|
|
997
|
-
function createActor(logic, options) {
|
|
996
|
+
function createActor(logic, ...[options]) {
|
|
998
997
|
return new Actor(logic, options);
|
|
999
998
|
}
|
|
1000
999
|
|
|
@@ -963,7 +963,6 @@ class Actor {
|
|
|
963
963
|
return this._snapshot;
|
|
964
964
|
}
|
|
965
965
|
}
|
|
966
|
-
|
|
967
966
|
/**
|
|
968
967
|
* Creates a new actor instance for the given actor logic with the provided options, if any.
|
|
969
968
|
*
|
|
@@ -996,7 +995,7 @@ class Actor {
|
|
|
996
995
|
* @param logic - The actor logic to create an actor from. For a state machine actor logic creator, see {@link createMachine}. Other actor logic creators include {@link fromCallback}, {@link fromEventObservable}, {@link fromObservable}, {@link fromPromise}, and {@link fromTransition}.
|
|
997
996
|
* @param options - Actor options
|
|
998
997
|
*/
|
|
999
|
-
function createActor(logic, options) {
|
|
998
|
+
function createActor(logic, ...[options]) {
|
|
1000
999
|
return new Actor(logic, options);
|
|
1001
1000
|
}
|
|
1002
1001
|
|
|
@@ -977,7 +977,6 @@ class Actor {
|
|
|
977
977
|
return this._snapshot;
|
|
978
978
|
}
|
|
979
979
|
}
|
|
980
|
-
|
|
981
980
|
/**
|
|
982
981
|
* Creates a new actor instance for the given actor logic with the provided options, if any.
|
|
983
982
|
*
|
|
@@ -1010,7 +1009,7 @@ class Actor {
|
|
|
1010
1009
|
* @param logic - The actor logic to create an actor from. For a state machine actor logic creator, see {@link createMachine}. Other actor logic creators include {@link fromCallback}, {@link fromEventObservable}, {@link fromObservable}, {@link fromPromise}, and {@link fromTransition}.
|
|
1011
1010
|
* @param options - Actor options
|
|
1012
1011
|
*/
|
|
1013
|
-
function createActor(logic, options) {
|
|
1012
|
+
function createActor(logic, ...[options]) {
|
|
1014
1013
|
return new Actor(logic, options);
|
|
1015
1014
|
}
|
|
1016
1015
|
|
package/dist/xstate.cjs.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var actors_dist_xstateActors = require('../actors/dist/xstate-actors.cjs.js');
|
|
6
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
7
|
-
var log = require('./log-
|
|
6
|
+
var guards_dist_xstateGuards = require('./raise-540fdaf2.cjs.js');
|
|
7
|
+
var log = require('./log-c5c46d15.cjs.js');
|
|
8
8
|
require('../dev/dist/xstate-dev.cjs.js');
|
|
9
9
|
|
|
10
10
|
class SimulatedClock {
|
|
@@ -394,6 +394,7 @@ class StateMachine {
|
|
|
394
394
|
* The machine's own version.
|
|
395
395
|
*/
|
|
396
396
|
this.version = void 0;
|
|
397
|
+
this.schemas = void 0;
|
|
397
398
|
this.implementations = void 0;
|
|
398
399
|
/** @internal */
|
|
399
400
|
this.__xstatenode = true;
|
|
@@ -415,6 +416,7 @@ class StateMachine {
|
|
|
415
416
|
guards: implementations?.guards ?? {}
|
|
416
417
|
};
|
|
417
418
|
this.version = this.config.version;
|
|
419
|
+
this.schemas = this.config.schemas;
|
|
418
420
|
this.transition = this.transition.bind(this);
|
|
419
421
|
this.getInitialSnapshot = this.getInitialSnapshot.bind(this);
|
|
420
422
|
this.getPersistedSnapshot = this.getPersistedSnapshot.bind(this);
|
|
@@ -704,10 +706,10 @@ function waitFor(actorRef, predicate, options) {
|
|
|
704
706
|
* Creates a state machine (statechart) with the given configuration.
|
|
705
707
|
*
|
|
706
708
|
* The state machine represents the pure logic of a state machine actor.
|
|
707
|
-
*
|
|
709
|
+
*
|
|
708
710
|
* @param config The state machine configuration.
|
|
709
711
|
* @param options DEPRECATED: use `setup({ ... })` or `machine.provide({ ... })` to provide machine implementations instead.
|
|
710
|
-
*
|
|
712
|
+
*
|
|
711
713
|
* @example
|
|
712
714
|
```ts
|
|
713
715
|
import { createMachine } from 'xstate';
|
|
@@ -797,13 +799,17 @@ function getNextSnapshot(actorLogic, snapshot, event) {
|
|
|
797
799
|
// at the moment we allow extra actors - ones that are not specified by `children`
|
|
798
800
|
// this could be reconsidered in the future
|
|
799
801
|
function setup({
|
|
802
|
+
schemas,
|
|
800
803
|
actors,
|
|
801
804
|
actions,
|
|
802
805
|
guards,
|
|
803
806
|
delays
|
|
804
807
|
}) {
|
|
805
808
|
return {
|
|
806
|
-
createMachine: config => createMachine(
|
|
809
|
+
createMachine: config => createMachine({
|
|
810
|
+
...config,
|
|
811
|
+
schemas
|
|
812
|
+
}, {
|
|
807
813
|
actors,
|
|
808
814
|
actions,
|
|
809
815
|
guards,
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var actors_dist_xstateActors = require('../actors/dist/xstate-actors.development.cjs.js');
|
|
6
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
7
|
-
var log = require('./log-
|
|
6
|
+
var guards_dist_xstateGuards = require('./raise-d7d9caaa.development.cjs.js');
|
|
7
|
+
var log = require('./log-75c83841.development.cjs.js');
|
|
8
8
|
require('../dev/dist/xstate-dev.development.cjs.js');
|
|
9
9
|
|
|
10
10
|
class SimulatedClock {
|
|
@@ -394,6 +394,7 @@ class StateMachine {
|
|
|
394
394
|
* The machine's own version.
|
|
395
395
|
*/
|
|
396
396
|
this.version = void 0;
|
|
397
|
+
this.schemas = void 0;
|
|
397
398
|
this.implementations = void 0;
|
|
398
399
|
/** @internal */
|
|
399
400
|
this.__xstatenode = true;
|
|
@@ -415,6 +416,7 @@ class StateMachine {
|
|
|
415
416
|
guards: implementations?.guards ?? {}
|
|
416
417
|
};
|
|
417
418
|
this.version = this.config.version;
|
|
419
|
+
this.schemas = this.config.schemas;
|
|
418
420
|
this.transition = this.transition.bind(this);
|
|
419
421
|
this.getInitialSnapshot = this.getInitialSnapshot.bind(this);
|
|
420
422
|
this.getPersistedSnapshot = this.getPersistedSnapshot.bind(this);
|
|
@@ -710,10 +712,10 @@ function waitFor(actorRef, predicate, options) {
|
|
|
710
712
|
* Creates a state machine (statechart) with the given configuration.
|
|
711
713
|
*
|
|
712
714
|
* The state machine represents the pure logic of a state machine actor.
|
|
713
|
-
*
|
|
715
|
+
*
|
|
714
716
|
* @param config The state machine configuration.
|
|
715
717
|
* @param options DEPRECATED: use `setup({ ... })` or `machine.provide({ ... })` to provide machine implementations instead.
|
|
716
|
-
*
|
|
718
|
+
*
|
|
717
719
|
* @example
|
|
718
720
|
```ts
|
|
719
721
|
import { createMachine } from 'xstate';
|
|
@@ -803,13 +805,17 @@ function getNextSnapshot(actorLogic, snapshot, event) {
|
|
|
803
805
|
// at the moment we allow extra actors - ones that are not specified by `children`
|
|
804
806
|
// this could be reconsidered in the future
|
|
805
807
|
function setup({
|
|
808
|
+
schemas,
|
|
806
809
|
actors,
|
|
807
810
|
actions,
|
|
808
811
|
guards,
|
|
809
812
|
delays
|
|
810
813
|
}) {
|
|
811
814
|
return {
|
|
812
|
-
createMachine: config => createMachine(
|
|
815
|
+
createMachine: config => createMachine({
|
|
816
|
+
...config,
|
|
817
|
+
schemas
|
|
818
|
+
}, {
|
|
813
819
|
actors,
|
|
814
820
|
actions,
|
|
815
821
|
guards,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.development.esm.js';
|
|
2
|
-
import { S as STATE_DELIMITER, m as mapValues, t as toArray, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as macrostep, o as transitionNode, p as resolveActionsAndContext, q as createInitEvent, s as microstep, u as getInitialStateNodes, v as toStatePath, w as isStateId, x as getStateNodeByPath, y as getPersistedSnapshot, z as resolveReferencedActor, A as createActor, $ as $$ACTOR_TYPE } from './raise-
|
|
3
|
-
export { B as Actor, I as __unsafe_getAllOwnEventDescriptors, E as and, M as cancel, A as createActor, j as getStateNodes, C as interpret, D as isMachineSnapshot, J as matchesState, F as not, G as or, K as pathToStateValue, O as raise, P as spawnChild, H as stateIn, Q as stop, R as stopChild, L as toObserver } from './raise-
|
|
4
|
-
import { a as assign } from './log-
|
|
5
|
-
export { S as SpecialTargets, a as assign, e as enqueueActions, f as forwardTo, l as log, s as sendParent, b as sendTo } from './log-
|
|
2
|
+
import { S as STATE_DELIMITER, m as mapValues, t as toArray, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as macrostep, o as transitionNode, p as resolveActionsAndContext, q as createInitEvent, s as microstep, u as getInitialStateNodes, v as toStatePath, w as isStateId, x as getStateNodeByPath, y as getPersistedSnapshot, z as resolveReferencedActor, A as createActor, $ as $$ACTOR_TYPE } from './raise-2fdbadc6.development.esm.js';
|
|
3
|
+
export { B as Actor, I as __unsafe_getAllOwnEventDescriptors, E as and, M as cancel, A as createActor, j as getStateNodes, C as interpret, D as isMachineSnapshot, J as matchesState, F as not, G as or, K as pathToStateValue, O as raise, P as spawnChild, H as stateIn, Q as stop, R as stopChild, L as toObserver } from './raise-2fdbadc6.development.esm.js';
|
|
4
|
+
import { a as assign } from './log-edca19d9.development.esm.js';
|
|
5
|
+
export { S as SpecialTargets, a as assign, e as enqueueActions, f as forwardTo, l as log, s as sendParent, b as sendTo } from './log-edca19d9.development.esm.js';
|
|
6
6
|
import '../dev/dist/xstate-dev.development.esm.js';
|
|
7
7
|
|
|
8
8
|
class SimulatedClock {
|
|
@@ -392,6 +392,7 @@ class StateMachine {
|
|
|
392
392
|
* The machine's own version.
|
|
393
393
|
*/
|
|
394
394
|
this.version = void 0;
|
|
395
|
+
this.schemas = void 0;
|
|
395
396
|
this.implementations = void 0;
|
|
396
397
|
/** @internal */
|
|
397
398
|
this.__xstatenode = true;
|
|
@@ -413,6 +414,7 @@ class StateMachine {
|
|
|
413
414
|
guards: implementations?.guards ?? {}
|
|
414
415
|
};
|
|
415
416
|
this.version = this.config.version;
|
|
417
|
+
this.schemas = this.config.schemas;
|
|
416
418
|
this.transition = this.transition.bind(this);
|
|
417
419
|
this.getInitialSnapshot = this.getInitialSnapshot.bind(this);
|
|
418
420
|
this.getPersistedSnapshot = this.getPersistedSnapshot.bind(this);
|
|
@@ -708,10 +710,10 @@ function waitFor(actorRef, predicate, options) {
|
|
|
708
710
|
* Creates a state machine (statechart) with the given configuration.
|
|
709
711
|
*
|
|
710
712
|
* The state machine represents the pure logic of a state machine actor.
|
|
711
|
-
*
|
|
713
|
+
*
|
|
712
714
|
* @param config The state machine configuration.
|
|
713
715
|
* @param options DEPRECATED: use `setup({ ... })` or `machine.provide({ ... })` to provide machine implementations instead.
|
|
714
|
-
*
|
|
716
|
+
*
|
|
715
717
|
* @example
|
|
716
718
|
```ts
|
|
717
719
|
import { createMachine } from 'xstate';
|
|
@@ -801,13 +803,17 @@ function getNextSnapshot(actorLogic, snapshot, event) {
|
|
|
801
803
|
// at the moment we allow extra actors - ones that are not specified by `children`
|
|
802
804
|
// this could be reconsidered in the future
|
|
803
805
|
function setup({
|
|
806
|
+
schemas,
|
|
804
807
|
actors,
|
|
805
808
|
actions,
|
|
806
809
|
guards,
|
|
807
810
|
delays
|
|
808
811
|
}) {
|
|
809
812
|
return {
|
|
810
|
-
createMachine: config => createMachine(
|
|
813
|
+
createMachine: config => createMachine({
|
|
814
|
+
...config,
|
|
815
|
+
schemas
|
|
816
|
+
}, {
|
|
811
817
|
actors,
|
|
812
818
|
actions,
|
|
813
819
|
guards,
|
package/dist/xstate.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.esm.js';
|
|
2
|
-
import { S as STATE_DELIMITER, m as mapValues, t as toArray, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as macrostep, o as transitionNode, p as resolveActionsAndContext, q as createInitEvent, s as microstep, u as getInitialStateNodes, v as toStatePath, w as isStateId, x as getStateNodeByPath, y as getPersistedSnapshot, z as resolveReferencedActor, A as createActor, $ as $$ACTOR_TYPE } from './raise-
|
|
3
|
-
export { B as Actor, I as __unsafe_getAllOwnEventDescriptors, E as and, M as cancel, A as createActor, j as getStateNodes, C as interpret, D as isMachineSnapshot, J as matchesState, F as not, G as or, K as pathToStateValue, O as raise, P as spawnChild, H as stateIn, Q as stop, R as stopChild, L as toObserver } from './raise-
|
|
4
|
-
import { a as assign } from './log-
|
|
5
|
-
export { S as SpecialTargets, a as assign, e as enqueueActions, f as forwardTo, l as log, s as sendParent, b as sendTo } from './log-
|
|
2
|
+
import { S as STATE_DELIMITER, m as mapValues, t as toArray, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as macrostep, o as transitionNode, p as resolveActionsAndContext, q as createInitEvent, s as microstep, u as getInitialStateNodes, v as toStatePath, w as isStateId, x as getStateNodeByPath, y as getPersistedSnapshot, z as resolveReferencedActor, A as createActor, $ as $$ACTOR_TYPE } from './raise-309d511a.esm.js';
|
|
3
|
+
export { B as Actor, I as __unsafe_getAllOwnEventDescriptors, E as and, M as cancel, A as createActor, j as getStateNodes, C as interpret, D as isMachineSnapshot, J as matchesState, F as not, G as or, K as pathToStateValue, O as raise, P as spawnChild, H as stateIn, Q as stop, R as stopChild, L as toObserver } from './raise-309d511a.esm.js';
|
|
4
|
+
import { a as assign } from './log-b6ecfc82.esm.js';
|
|
5
|
+
export { S as SpecialTargets, a as assign, e as enqueueActions, f as forwardTo, l as log, s as sendParent, b as sendTo } from './log-b6ecfc82.esm.js';
|
|
6
6
|
import '../dev/dist/xstate-dev.esm.js';
|
|
7
7
|
|
|
8
8
|
class SimulatedClock {
|
|
@@ -392,6 +392,7 @@ class StateMachine {
|
|
|
392
392
|
* The machine's own version.
|
|
393
393
|
*/
|
|
394
394
|
this.version = void 0;
|
|
395
|
+
this.schemas = void 0;
|
|
395
396
|
this.implementations = void 0;
|
|
396
397
|
/** @internal */
|
|
397
398
|
this.__xstatenode = true;
|
|
@@ -413,6 +414,7 @@ class StateMachine {
|
|
|
413
414
|
guards: implementations?.guards ?? {}
|
|
414
415
|
};
|
|
415
416
|
this.version = this.config.version;
|
|
417
|
+
this.schemas = this.config.schemas;
|
|
416
418
|
this.transition = this.transition.bind(this);
|
|
417
419
|
this.getInitialSnapshot = this.getInitialSnapshot.bind(this);
|
|
418
420
|
this.getPersistedSnapshot = this.getPersistedSnapshot.bind(this);
|
|
@@ -702,10 +704,10 @@ function waitFor(actorRef, predicate, options) {
|
|
|
702
704
|
* Creates a state machine (statechart) with the given configuration.
|
|
703
705
|
*
|
|
704
706
|
* The state machine represents the pure logic of a state machine actor.
|
|
705
|
-
*
|
|
707
|
+
*
|
|
706
708
|
* @param config The state machine configuration.
|
|
707
709
|
* @param options DEPRECATED: use `setup({ ... })` or `machine.provide({ ... })` to provide machine implementations instead.
|
|
708
|
-
*
|
|
710
|
+
*
|
|
709
711
|
* @example
|
|
710
712
|
```ts
|
|
711
713
|
import { createMachine } from 'xstate';
|
|
@@ -795,13 +797,17 @@ function getNextSnapshot(actorLogic, snapshot, event) {
|
|
|
795
797
|
// at the moment we allow extra actors - ones that are not specified by `children`
|
|
796
798
|
// this could be reconsidered in the future
|
|
797
799
|
function setup({
|
|
800
|
+
schemas,
|
|
798
801
|
actors,
|
|
799
802
|
actions,
|
|
800
803
|
guards,
|
|
801
804
|
delays
|
|
802
805
|
}) {
|
|
803
806
|
return {
|
|
804
|
-
createMachine: config => createMachine(
|
|
807
|
+
createMachine: config => createMachine({
|
|
808
|
+
...config,
|
|
809
|
+
schemas
|
|
810
|
+
}, {
|
|
805
811
|
actors,
|
|
806
812
|
actions,
|
|
807
813
|
guards,
|