xstate 5.6.0 → 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.
@@ -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 {
@@ -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';
@@ -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']>;
@@ -439,6 +456,7 @@ export type MachineConfig<TContext extends MachineContext, TEvent extends EventO
439
456
  } : {
440
457
  context: InitialContext<LowInfer<TContext>, TActor, TInput, TEvent>;
441
458
  });
459
+ export type UnknownMachineConfig = MachineConfig<MachineContext, EventObject>;
442
460
  export interface ProvidedActor {
443
461
  src: string;
444
462
  logic: UnknownActorLogic;
@@ -704,6 +722,12 @@ export type Observer<T> = {
704
722
  export interface Subscription {
705
723
  unsubscribe(): void;
706
724
  }
725
+ export interface InteropObservable<T> {
726
+ [Symbol.observable]: () => InteropSubscribable<T>;
727
+ }
728
+ export interface InteropSubscribable<T> {
729
+ subscribe(observer: Observer<T>): Subscription;
730
+ }
707
731
  export interface Subscribable<T> extends InteropSubscribable<T> {
708
732
  subscribe(observer: Observer<T>): Subscription;
709
733
  subscribe(next: (value: T) => void, error?: (error: any) => void, complete?: () => void): Subscription;
@@ -859,12 +883,12 @@ type ExtractLiteralString<T extends string | undefined> = T extends string ? str
859
883
  type ToConcreteChildren<TActor extends ProvidedActor> = {
860
884
  [A in TActor as ExtractLiteralString<A['id']>]?: ActorRefFrom<A['logic']>;
861
885
  };
862
- export type ToChildren<TActor extends ProvidedActor> = string extends TActor['src'] ? Record<string, AnyActorRef> : ToConcreteChildren<TActor> & {
886
+ export type ToChildren<TActor extends ProvidedActor> = string extends TActor['src'] ? Record<string, AnyActorRef> : Compute<ToConcreteChildren<TActor> & {
863
887
  include: {
864
888
  [id: string]: TActor extends any ? ActorRefFrom<TActor['logic']> | undefined : never;
865
889
  };
866
890
  exclude: {};
867
- }[undefined extends TActor['id'] ? 'include' : string extends TActor['id'] ? 'include' : 'exclude'];
891
+ }[undefined extends TActor['id'] ? 'include' : string extends TActor['id'] ? 'include' : 'exclude']>;
868
892
  export type StateSchema = {
869
893
  states?: Record<string, StateSchema>;
870
894
  };
@@ -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
- * @internal
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
  */
@@ -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
- * @internal
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
  */
@@ -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
- * @internal
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
  */
@@ -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
- * @internal
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
  */
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var actors_dist_xstateActors = require('../actors/dist/xstate-actors.cjs.js');
6
6
  var guards_dist_xstateGuards = require('./raise-540fdaf2.cjs.js');
7
- var log = require('./log-8a4f6e5c.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 {
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var actors_dist_xstateActors = require('../actors/dist/xstate-actors.development.cjs.js');
6
6
  var guards_dist_xstateGuards = require('./raise-d7d9caaa.development.cjs.js');
7
- var log = require('./log-3552abe4.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 {
@@ -1,8 +1,8 @@
1
1
  export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.development.esm.js';
2
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
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-fedd0292.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-fedd0292.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 {
@@ -1,8 +1,8 @@
1
1
  export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.esm.js';
2
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
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-a8de0b28.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-a8de0b28.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 {