Skip to content

Update dependency xstate to v5 - #47

Open
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/major-xstate-monorepo
Open

Update dependency xstate to v5#47
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/major-xstate-monorepo

Conversation

@renovate

@renovate renovate Bot commented Apr 15, 2024

Copy link
Copy Markdown
Contributor

ℹ️ Note

This PR body was truncated due to platform limits.

This PR contains the following updates:

Package Change Age Confidence
xstate (source) ^4.32.0^5.0.0 age confidence
xstate (source) ^4.32.0^5.0.0 age confidence

Release Notes

statelyai/xstate (xstate)

v5.32.5

Compare Source

Patch Changes
  • #​5603 345e04c Thanks @​xianjianlf2! - Sending an event to a stopped actor no longer throws when the event contains unserializable data (e.g. circular references). Previously, the development-only warning that an event was sent to a stopped actor used JSON.stringify on the event, which could throw and mask the intended warning. The warning is now emitted safely regardless of the event's contents.

v5.32.4

Compare Source

Patch Changes
  • #​5589 e913eeb Thanks @​spokodev! - Fixed a bug where targeting a history state that is a direct child of a parallel state would silently do nothing when that parallel state had not been visited yet and the history state had no default target. The machine now enters the parallel state's initial configuration, matching the behavior of history states inside compound states.

    const machine = createMachine({
      initial: 'off',
      states: {
        off: { on: { GO: 'on.hist' } },
        on: {
          type: 'parallel',
          states: {
            regA: { initial: 'a1', states: { a1: {}, a2: {} } },
            regB: { initial: 'b1', states: { b1: {}, b2: {} } },
            hist: { type: 'history', history: 'deep' }
          }
        }
      }
    });
    
    const actor = createActor(machine).start();
    actor.send({ type: 'GO' });
    actor.getSnapshot().value; // { on: { regA: 'a1', regB: 'b1' } }

v5.32.3

Compare Source

Patch Changes
  • #​5575 830db8b Thanks @​JSap0914! - Fixed initialTransition (and transition) throwing "Actor with system ID '...' already exists" when the machine contains an invoke with a systemId.

    Root cause: createInertActorScope used createActor(logic) internally, which eagerly ran getInitialSnapshot during construction and registered any systemId-carrying child actors in the system. When the caller then ran getInitialSnapshot (or transition) via the returned scope, the same system was reused, causing the duplicate-registration error.

    Fix: After creating the internal actor, createInertActorScope now replaces the actor's system reference with a freshly-created system. Child actors spawned by the subsequent caller-driven getInitialSnapshot / transition invocation therefore register into a clean system with no pre-existing entries.

    const machine = createMachine({
      initial: 'idle',
      states: {
        idle: {
          invoke: {
            src: fromPromise(async () => 42),
            systemId: 'myActor' // previously caused: "Actor with system ID 'myActor' already exists"
          }
        }
      }
    });
    
    // Now works correctly — returns [snapshot, actions] without throwing
    const [snapshot, actions] = initialTransition(machine);
  • #​5585 a551a2b Thanks @​RubenFricke! - Add missing https:// protocol to the Stately Studio link in the README

v5.32.2

Compare Source

Patch Changes
  • #​5548 8a53531 Thanks @​JSap0914! - fix(core): fall back to wildcard event descriptors when an exact descriptor's guard fails

    When a state has both an exact event descriptor (e.g. "foo.bar") and a matching wildcard descriptor (e.g. "foo.*"), transitions from the exact descriptor are now tried first; if all their guards fail, matching wildcard descriptor transitions are tried as fallback. Previously, the presence of an exact match would prevent any wildcard fallback from being considered, leaving the machine in its current state when the exact descriptor's guard failed.

v5.32.1

Compare Source

Patch Changes

v5.32.0

Compare Source

Minor Changes

v5.31.1

Compare Source

Patch Changes
  • #​5525 f79ea13 Thanks @​davidkpiano! - Fixed route transition guards so named guards registered with setup({ guards }) are resolved for route.guard.

    const machine = setup({
      guards: {
        isReady: ({ context }) => context.ready
      }
    }).createMachine({
      states: {
        review: {
          id: 'review',
          route: {
            guard: 'isReady'
          }
        }
      }
    });

v5.31.0

Compare Source

Minor Changes
  • #​5429 9d9c1fe Thanks @​davidkpiano! - Add mapState(snapshot, mapper) to map a snapshot to values based on active state(s).

    import { mapState } from 'xstate';
    
    const results = mapState(snapshot, {
      states: {
        loading: { map: () => 'Loading...' },
        success: { map: (snap) => snap.context.data },
        error: { map: (snap) => snap.context.error.message }
      }
    });
    
    console.log(results);
    // E.g. if snapshot.value === 'loading', then:
    // [
    //   { stateNode: { key: 'loading' }, result: 'Loading...' }
    // ]
  • #​5430 e543599 Thanks @​davidkpiano! - Add maxIterations option to configure the maximum number of microsteps allowed before throwing an infinite loop error. The default is Infinity (no limit) to avoid breaking existing machines.

    You can configure it when creating a machine:

    const machine = createMachine({
      // ... machine config
      options: {
        maxIterations: 1000 // set a limit to enable infinite loop detection
      }
    });

v5.30.0

Compare Source

Minor Changes
  • #​5493 871857d Thanks @​davidkpiano! - Add a filterEvents option to xstate/graph traversal helpers and
    createTestModel(...) to control which events should be explored from each
    state.

    This makes it possible to opt into enabled-only traversal for machine snapshots,
    such as when you only want to explore events that currently pass guards:

    import { createTestModel } from 'xstate/graph';
    
    const model = createTestModel(machine);
    
    const paths = model.getSimplePaths({
      filterEvents: (state, event) => state.can(event)
    });

v5.29.0

Compare Source

Minor Changes
  • #​5299 ca8306f Thanks @​Uniqen! - Add actor.select(selector, equalityFn?) method to derive a Readable<TSelected> from an actor's snapshot. The returned object has .subscribe() (only emits when the selected value changes, using Object.is by default) and .get() for synchronous access.

    const actor = createActor(machine);
    actor.start();
    
    const count = actor.select((snap) => snap.context.count);
    
    count.get(); // current value
    
    count.subscribe((value) => {
      console.log(value); // only fires when count changes
    });

v5.28.0

Compare Source

Minor Changes
  • #​4184 a741fe7 Thanks @​davidkpiano! - Added routable states. States with route: {} and an explicit id can be navigated to from anywhere via a single { type: 'xstate.route', to: '#id' } event.

    const machine = setup({}).createMachine({
      id: 'app',
      initial: 'home',
      states: {
        home: { id: 'home', route: {} },
        dashboard: {
          initial: 'overview',
          states: {
            overview: { id: 'overview', route: {} },
            settings: { id: 'settings', route: {} }
          }
        }
      }
    });
    
    const actor = createActor(machine).start();
    
    // Route directly to deeply nested state from anywhere
    actor.send({ type: 'xstate.route', to: '#settings' });

    Routes support guards for conditional navigation:

    settings: {
      id: 'settings',
      route: {
        guard: ({ context }) => context.role === 'admin'
      }
    }
Patch Changes

v5.27.0

Compare Source

Minor Changes
  • #​5457 287b51e Thanks @​davidkpiano! - Add getInitialMicrosteps(…) and getMicrosteps(…) functions that return an array of [snapshot, actions] tuples for each microstep in a transition.

    import { createMachine, getInitialMicrosteps, getMicrosteps } from 'xstate';
    
    const machine = createMachine({
      initial: 'a',
      states: {
        a: {
          entry: () => console.log('enter a'),
          on: {
            NEXT: 'b'
          }
        },
        b: {
          entry: () => console.log('enter b'),
          always: 'c'
        },
        c: {}
      }
    });
    
    // Get microsteps from initial transition
    const initialMicrosteps = getInitialMicrosteps(machine);
    // Returns: [
    //  [snapshotA, [entryActionA]]
    // ]
    
    // Get microsteps from a transition
    const microsteps = getMicrosteps(machine, initialMicrosteps[0][0], {
      type: 'NEXT'
    });
    // Returns: [
    //  [snapshotB, [entryActionB]],
    //  [snapshotC, []]
    // ]
    
    // Each microstep is a tuple of [snapshot, actions]
    for (const [snapshot, actions] of microsteps) {
      console.log('State:', snapshot.value);
      console.log('Actions:', actions.length);
    }

v5.26.0

Compare Source

Minor Changes
  • #​5406 703c3a1 Thanks @​davidkpiano! - Add getNextTransitions(state) utility to get all transitions available from current state.

    import { getNextTransitions } from 'xstate';
    
    // ...
    
    const state = actor.getSnapshot();
    const transitions = getNextTransitions(state);
    
    transitions.forEach((t) => {
      console.log(`Event: ${t.eventType}, Source: ${t.source.key}`);
    });

v5.25.1

Compare Source

Patch Changes

v5.25.0

Compare Source

Minor Changes
  • #​5422 329297b Thanks @​davidkpiano! - Add partial descriptor support to assertEvent(…)

    // Matches any event with a type that starts with `FEEDBACK.`
    assertEvent(event, 'FEEDBACK.*');
Patch Changes

v5.24.0

Compare Source

Minor Changes
  • #​5371 b8ec3b1 Thanks @​davidkpiano! - Add setup.extend() method to incrementally extend machine setup configurations with additional actions, guards, and delays. This enables composable and reusable machine setups where extended actions, guards, and delays can reference base actions, guards, and delays and support chaining multiple extensions:

    import { setup, not, and } from 'xstate';
    
    const baseSetup = setup({
      guards: {
        isAuthenticated: () => true,
        hasPermission: () => false
      }
    });
    
    const extendedSetup = baseSetup.extend({
      guards: {
        // Type-safe guard references
        isUnauthenticated: not('isAuthenticated'),
        canAccess: and(['isAuthenticated', 'hasPermission'])
      }
    });
    
    // Both base and extended guards are available
    extendedSetup.createMachine({
      on: {
        LOGIN: {
          guard: 'isAuthenticated',
          target: 'authenticated'
        },
        LOGOUT: {
          guard: 'isUnauthenticated',
          target: 'unauthenticated'
        }
      }
    });

v5.23.0

Compare Source

Minor Changes
  • #​5387 53dd7f1 Thanks @​farskid! - Adds system.getAll that returns a record of running actors within the system by their system id

    const childMachine = createMachine({});
    const machine = createMachine({
      // ...
      invoke: [
        {
          src: childMachine,
          systemId: 'test'
        }
      ]
    });
    const system = createActor(machine);
    
    system.getAll(); // { test: ActorRefFrom<typeof childMachine> }

v5.22.1

Compare Source

Patch Changes

v5.22.0

Compare Source

Minor Changes
  • #​5367 76c857e Thanks @​davidkpiano! - Add type-bound action helpers to setup():

    • createAction(fn) – create type-safe custom actions
    • setup().assign(...), setup().sendTo(...), setup().raise(...), setup().log(...), setup().cancel(...), setup().stopChild(...), setup().enqueueActions(...), setup().emit(...), setup().spawnChild(...) – setup-scoped helpers that are fully typed to the setup's context/events/actors/guards/delays/emitted.

    These helpers return actions that are bound to the specific setup() they were created from and can be used directly in the machine produced by that setup.

    const machineSetup = setup({
      types: {} as {
        context: {
          count: number;
        };
        events: { type: 'inc'; value: number } | { type: 'TEST' };
        emitted: { type: 'PING' };
      }
    });
    
    // Custom action
    const action = machineSetup.createAction(({ context, event }) => {
      console.log(context.count, event.value);
    });
    
    // Type-bound built-ins (no wrapper needed)
    const increment = machineSetup.assign({
      count: ({ context }) => context.count + 1
    });
    const raiseTest = machineSetup.raise({ type: 'TEST' });
    const ping = machineSetup.emit({ type: 'PING' });
    const batch = machineSetup.enqueueActions(({ enqueue, check }) => {
      if (check(() => true)) {
        enqueue(increment);
      }
    });
    
    const machine = machineSetup.createMachine({
      context: { count: 0 },
      entry: [action, increment, raiseTest, ping, batch]
    });

v5.21.0

Compare Source

Minor Changes
  • #​5364 15e15b5 Thanks @​davidkpiano! - Added .createStateConfig(…) to the setup API. This makes it possible to create state configs that are strongly typed and modular.

    const lightMachineSetup = setup({
      // ...
    });
    
    const green = lightMachineSetup.createStateConfig({
      //...
    });
    
    const yellow = lightMachineSetup.createStateConfig({
      //...
    });
    
    const red = lightMachineSetup.createStateConfig({
      //...
    });
    
    const machine = lightMachineSetup.createMachine({
      initial: 'green',
      states: {
        green,
        yellow,
        red
      }
    });

v5.20.2

Compare Source

Patch Changes
  • #​5351 71387ff Thanks @​davidkpiano! - Fix: Emit callback errors no longer crash the actor

    actor.on('event', () => {
      // Will no longer crash the actor
      throw new Error('oops');
    });

v5.20.1

Compare Source

Patch Changes

v5.20.0

Compare Source

Minor Changes

v5.19.4

Compare Source

Patch Changes

v5.19.3

Compare Source

Patch Changes

v5.19.2

Compare Source

Patch Changes

v5.19.1

Compare Source

Patch Changes
  • #​5139 bf6119a7310a878afbf4f5b01f5e24288f9a0f16 Thanks @​SandroMaglione! - Make spawn input required when defined inside referenced actor:

    const childMachine = createMachine({
      types: { input: {} as { value: number } }
    });
    
    const machine = createMachine({
      types: {} as { context: { ref: ActorRefFrom<typeof childMachine> } },
      context: ({ spawn }) => ({
        ref: spawn(
          childMachine,
          // Input is now required!
          { input: { value: 42 } }
        )
      })
    });

v5.19.0

Compare Source

Minor Changes
  • #​4954 8c4b70652acaef2702f32435362e4755679a516d Thanks @​davidkpiano! - Added a new transition function that takes an actor logic, a snapshot, and an event, and returns a tuple containing the next snapshot and the actions to execute. This function is a pure function and does not execute the actions itself. It can be used like this:

    import { transition } from 'xstate';
    
    const [nextState, actions] = transition(actorLogic, currentState, event);
    // Execute actions as needed

    Added a new initialTransition function that takes an actor logic and an optional input, and returns a tuple containing the initial snapshot and the actions to execute from the initial transition. This function is also a pure function and does not execute the actions itself. It can be used like this:

    import { initialTransition } from 'xstate';
    
    const [initialState, actions] = initialTransition(actorLogic, input);
    // Execute actions as needed

    These new functions provide a way to separate the calculation of the next snapshot and actions from the execution of those actions, allowing for more control and flexibility in the transition process.

v5.18.2

Compare Source

Patch Changes

v5.18.1

Compare Source

Patch Changes

v5.18.0

Compare Source

Minor Changes
  • #​5042 54c9d9e6a4 Thanks @​boneskull! - waitFor() now accepts a {signal: AbortSignal} in WaitForOptions

  • #​5006 1ab974547f Thanks @​davidkpiano! - The state value typings for setup state machine actors (setup({}).createMachine({ ... })) have been improved to represent the actual expected state values.

    const machine = setup({}).createMachine({
      initial: 'green',
      states: {
        green: {},
        yellow: {},
        red: {
          initial: 'walk',
          states: {
            walk: {},
            wait: {},
            stop: {}
          }
        },
        emergency: {
          type: 'parallel',
          states: {
            main: {
              initial: 'blinking',
              states: {
                blinking: {}
              }
            },
            cross: {
              initial: 'blinking',
              states: {
                blinking: {}
              }
            }
          }
        }
      }
    });
    
    const actor = createActor(machine).start();
    
    const stateValue = actor.getSnapshot().value;
    
    if (stateValue === 'green') {
      // ...
    } else if (stateValue === 'yellow') {
      // ...
    } else if ('red' in stateValue) {
      stateValue;
      // {
      //   red: "walk" | "wait" | "stop";
      // }
    } else {
      stateValue;
      // {
      //   emergency: {
      //     main: "blinking";
      //     cross: "blinking";
      //   };
      // }
    }
Patch Changes
  • #​5054 853f6daa0b Thanks @​davidkpiano! - The CallbackLogicFunction type (previously InvokeCallback) is now exported. This is the callback function that you pass into fromCallback(callbackLogicFn) to create an actor from a callback function.

    import { type CallbackLogicFunction } from 'xstate';
    
    // ...

v5.17.4

Compare Source

Patch Changes
  • #​5039 d6df8fb470 Thanks @​Andarist! - Fixed an inference issue that prevented emit used directly in setup (or bare createMachine) to benefit from types.emitted types.

v5.17.3

Compare Source

Patch Changes

v5.17.2

Compare Source

Patch Changes

v5.17.1

Compare Source

Patch Changes
  • #​5009 51d4c4fc5 Thanks @​davidkpiano! - The internal types for StateMachine<...> have been improved so that all type params are required, to prevent errors when using the types. This fixes weird issues like #​5008.

v5.17.0

Compare Source

Minor Changes
  • #​4979 a0e9ebcef Thanks @​davidkpiano! - State IDs are now strongly typed as keys of snapshot.getMeta() for state machine actor snapshots.

    const machine = setup({
      // ...
    }).createMachine({
      id: 'root',
      initial: 'parentState',
      states: {
        parentState: {
          meta: {},
          initial: 'childState',
          states: {
            childState: {
              meta: {}
            },
            stateWithId: {
              id: 'state with id',
              meta: {}
            }
          }
        }
      }
    });
    
    const actor = createActor(machine);
    
    const metaValues = actor.getSnapshot().getMeta();
    
    // Auto-completed keys:
    metaValues.root;
    metaValues['root.parentState'];
    metaValues['root.parentState.childState'];
    metaValues['state with id'];
    
    // @&#8203;ts-expect-error
    metaValues['root.parentState.stateWithId'];
    
    // @&#8203;ts-expect-error
    metaValues['unknown state'];
Patch Changes

v5.16.0

Compare Source

Minor Changes
  • #​4996 5be796cd2 Thanks @​ronvoluted! - The actor snapshot status type ('active' | 'done' | 'error' | 'stopped') is now exposed as SnapshotStatus

  • #​4981 c4ae156b2 Thanks @​davidkpiano! - Added sendParent to the enqueueActions feature. This allows users to enqueue actions that send events to the parent actor within the enqueueActions block.

    import { createMachine, enqueueActions } from 'xstate';
    
    const childMachine = createMachine({
      entry: enqueueActions(({ enqueue }) => {
        enqueue.sendParent({ type: 'CHILD_READY' });
      })
    });

v5.15.0

Compare Source

Minor Changes
  • #​4976 452bce71e Thanks @​with-heart! - Added exports for actor logic-specific ActorRef types: CallbackActorRef, ObservableActorRef, PromiseActorRef, and TransitionActorRef.

    Each type represents ActorRef narrowed to the corresponding type of logic (the type of self within the actor's logic):

    • CallbackActorRef: actor created by fromCallback

      import { fromCallback, createActor } from 'xstate';
      
      /** The events the actor receives. */
      type Event = { type: 'someEvent' };
      /** The actor's input. */
      type Input = { name: string };
      
      /** Actor logic that logs whenever it receives an event of type `someEvent`. */
      const logic = fromCallback<Event, Input>(({ self, input, receive }) => {
        self;
        // ^? CallbackActorRef<Event, Input>
      
        receive((event) => {
          if (event.type === 'someEvent') {
            console.log(`${input.name}: received "someEvent" event`);
            // logs 'myActor: received "someEvent" event'
          }
        });
      });
      
      const actor = createActor(logic, { input: { name: 'myActor' } });
      //    ^? CallbackActorRef<Event, Input>
    • ObservableActorRef: actor created by fromObservable and fromEventObservable

      import { fromObservable, createActor } from 'xstate';
      import { interval } from 'rxjs';
      
      /** The type of the value observed by the actor's logic. */
      type Context = number;
      /** The actor's input. */
      type Input = { period?: number };
      
      /**
       * Actor logic that observes a number incremented every `input.period`
       * milliseconds (default: 1_000).
       */
      const logic = fromObservable<Context, Input>(({ input, self }) => {
        self;
        // ^? ObservableActorRef<Event, Input>
      
        return interval(input.period ?? 1_000);
      });
      
      const actor = createActor(logic, { input: { period: 2_000 } });
      //    ^? ObservableActorRef<Event, Input>
    • PromiseActorRef: actor created by fromPromise

      import { fromPromise, createActor } from 'xstate';
      
      /** The actor's resolved output. */
      type Output = string;
      /** The actor's input. */
      type Input = { message: string };
      
      /** Actor logic that fetches the url of an image of a cat saying `input.message`. */
      const logic = fromPromise<Output, Input>(async ({ input, self }) => {
        self;
        // ^? PromiseActorRef<Output, Input>
      
        const data = await fetch(`https://cataas.com/cat/says/${input.message}`);
        const url = await data.json();
        return url;
      });
      
      const actor = createActor(logic, { input: { message: 'hello world' } });
      //    ^? PromiseActorRef<Output, Input>
    • TransitionActorRef: actor created by fromTransition

      import { fromTransition, createActor, type AnyActorSystem } from 'xstate';
      
      /** The actor's stored context. */
      type Context = {
        /** The current count. */
        count: number;
        /** The amount to increase `count` by. */
        step: number;
      };
      /** The events the actor receives. */
      type Event = { type: 'increment' };
      /** The actor's input. */
      type Input = { step?: number };
      
      /**
       * Actor logic that increments `count` by `step` when it receives an event of
       * type `increment`.
       */
      const logic = fromTransition<Context, Event, AnyActorSystem, Input>(
        (state, event, actorScope) => {
          actorScope.self;
          //         ^? TransitionActorRef<Context, Event>
      
          if (event.type === 'increment') {
            return {
              ...state,
              count: state.count + state.step
            };
          }
          return state;
        },
        ({ input, self }) => {
          self;
          // ^? TransitionActorRef<Context, Event>
      
          return {
            count: 0,
            step: input.step ?? 1
          };
        }
      );
      
      const actor = createActor(logic, { input: { step: 10 } });
      //    ^? TransitionActorRef<Context, Event>
  • #​4949 8aa4c2b90 Thanks @​davidkpiano! - The TypeGen-related types have been removed from XState, simplifying the internal types without affecting normal XState usage.

v5.14.0

Compare Source

Minor Changes
  • #​4936 c58b36dc3 Thanks @​davidkpiano! - Inspecting an actor system via actor.system.inspect(ev => …) now accepts a function or observer, and returns a subscription:

    const actor = createActor(someMachine);
    
    const sub = actor.system.inspect((inspectionEvent) => {
      console.log(inspectionEvent);
    });
    
    // Inspection events will be logged
    actor.start();
    actor.send({ type: 'anEvent' });
    
    // ...
    
    sub.unsubscribe();
    
    // Will no longer log inspection events
    actor.send({ type: 'someEvent' });
  • #​4942 9caaa1f70 Thanks @​boneskull! - DoneActorEvent and ErrorActorEvent now contain property actorId, which refers to the ID of the actor the event refers to.

  • #​4935 2ac08b700 Thanks @​davidkpiano! - All actor logic creators now support emitting events:

    Promise actors

    const logic = fromPromise(async ({ emit }) => {
      // ...
      emit({
        type: 'emitted',
        msg: 'hello'
      });
      // ...
    });

    Transition actors

    const logic = fromTransition((state, event, { emit }) => {
      // ...
      emit({
        type: 'emitted',
        msg: 'hello'
      });
      // ...
      return state;
    }, {});

    Observable actors

    const logic = fromObservable(({ emit }) => {
      // ...
    
      emit({
        type: 'emitted',
        msg: 'hello'
      });
    
      // ...
    });

    Callback actors

    const logic = fromCallback(({ emit }) => {
      // ...
      emit({
        type: 'emitted',
        msg: 'hello'
      });
      // ...
    });
Patch Changes

v5.13.2

Compare Source

Patch Changes

v5.13.1

Compare Source

Patch Changes
  • #​4905 dbeafeb25 Thanks @​davidkpiano! - You can now use a wildcard to listen for any emitted event from an actor:

    actor.on('*', (emitted) => {
      console.log(emitted); // Any emitted event
    });

v5.13.0

Compare Source

Minor Changes
  • #​4832 148d8fcef Thanks @​cevr! - fromPromise now passes a signal into its creator function.

    const logic = fromPromise(({ signal }) =>
      fetch('https://api.example.com', { signal })
    );

    This will be called whenever the state transitions before the promise is resolved. This is useful for cancelling the promise if the state changes.

Patch Changes
  • #​4876 3f6a73b56 Thanks @​davidkpiano! - XState will now warn when calling built-in actions like assign, sendTo, raise, emit, etc. directly inside of a custom action. See https://stately.ai/docs/actions#built-in-actions for more details.

    const machine = createMachine({
      entry: () => {
        // Will warn:
        // "Custom actions should not call \`assign()\` directly, as it is not imperative. See https://stately.ai/docs/actions#built-in-actions for more details."
        assign({
          // ...
        });
      }
    });

v5.12.0

Compare Source

Minor Changes
  • #​4863 0696adc21 Thanks @​davidkpiano! - Meta objects for state nodes and transitions can now be specified in setup({ types: … }):

    const machine = setup({
      types: {
        meta: {} as {
          layout: string;
        }
      }
    }).createMachine({
      initial: 'home',
      states: {
        home: {
          meta: {
            layout: 'full'
          }
        }
      }
    });
    
    const actor = createActor(machine).start();
    
    actor.getSnapshot().getMeta().home;
    // => { layout: 'full' }
    // if in "home" state

v5.11.0

Compare Source

Minor Changes
  • #​4806 f4e0ec48c Thanks @​davidkpiano! - Inline actor logic is now permitted when named actors are present. Defining inline actors will no longer cause a TypeScript error:

    const machine = setup({
      actors: {
        existingActor: fromPromise(async () => {
          // ...
        })
      }
    }).createMachine({
      invoke: {
        src: fromPromise(async () => {
          // Inline actor
        })
        // ...
      }
    });

v5.10.0

Compare Source

Minor Changes
  • #​4822 f7f1fbbf3 Thanks @​davidkpiano! - The clock and logger specified in the options object of createActor(logic, options) will now propagate to all actors created within the same actor system.

    import { setup, log, createActor } from 'xstate';
    
    const childMachine = setup({
      // ...
    }).createMachine({
      // ...
      // Uses custom logger from root actor
      entry: log('something')
    });
    
    const parentMachine = setup({
      // ...
    }).createMachine({
      // ...
      invoke: {
        src: childMachine
      }
    });
    
    const actor = createActor(parentMachine, {
      logger: (...args) => {
        // custom logger for args
      }
    });
    
    actor.start();

v5.9.1

Compare Source

Patch Changes

v5.9.0

Compare Source

Minor Changes
  • #​4746 b570ba20d Thanks @​davidkpiano! - The new emit(…) action creator emits events that can be received by listeners. Actors are now event emitters.

    import { emit } from 'xstate';
    
    const machine = createMachine({
      // ...
      on: {
        something: {
          actions: emit({
            type: 'emitted',
            some: 'data'
          })
        }
      }
      // ...
    });
    
    const actor = createActor(machine).start();
    
    actor.on('emitted', (event) => {
      console.log(event);
    });
    
    actor.send({ type: 'something' });
    // logs:
    // {
    //   type: 'emitted',
    //   some: 'data'
    // }
  • #​4777 4abeed9df Thanks @​Andarist! - Added support for params to enqueueActions

v5.8.2

Compare Source

Patch Changes
  • #​4772 9a0120901 Thanks @​Andarist! - Fixed a type issue that prevent sendParent to be accepted by setup when delays stayed not configured.

v5.8.1

Compare Source

Patch Changes

v5.8.0

Compare Source

Minor Changes

v5.7.1

Compare Source

Patch Changes

Note

PR body was truncated to here.


Configuration

📅 Schedule: (UTC)

  • Branch creation
    • Between 12:00 AM and 03:59 AM, only on Monday (* 0-3 * * 1)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about these updates again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate

renovate Bot commented Apr 15, 2024

Copy link
Copy Markdown
Contributor Author

⚠ Artifact update problem

Renovate failed to update an artifact related to this branch. You probably do not want to merge this PR as-is.

♻ Renovate will retry this branch, including artifacts, only when one of the following happens:

  • any of the package files in this branch needs updating, or
  • the branch becomes conflicted, or
  • you click the rebase/retry checkbox if found above, or
  • you rename this PR's title to start with "rebase!" to trigger it manually

The artifact failure details are included below:

File name: pnpm-lock.yaml
 WARN  The "store" setting has been renamed to "store-dir". Please use the new name.
 WARN  GET https://registry.npmjs.org/xstate error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@babel/core/-/core-7.17.10.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.17.10.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.16.7.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@changesets/cli/-/cli-2.22.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@types/jest/-/jest-27.5.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@types/node/-/node-17.0.31.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.22.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.22.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/babel-plugin-dev-expression/-/babel-plugin-dev-expression-0.2.3.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/babel-plugin-transform-define/-/babel-plugin-transform-define-2.0.1.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/eslint/-/eslint-8.15.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-26.1.5.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/xstate error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/@babel/core/-/core-7.17.10.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.17.10.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.16.7.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/@changesets/cli/-/cli-2.22.0.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/@types/jest/-/jest-27.5.0.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/@types/node/-/node-17.0.31.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.22.0.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.22.0.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/babel-plugin-dev-expression/-/babel-plugin-dev-expression-0.2.3.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/babel-plugin-transform-define/-/babel-plugin-transform-define-2.0.1.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/eslint/-/eslint-8.15.0.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-26.1.5.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.2.16.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
undefined
 ERR_INVALID_THIS  Value of "this" must be of type URLSearchParams
 WARN  GET https://registry.npmjs.org/husky/-/husky-7.0.4.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/jest/-/jest-28.1.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/jest-mock-console/-/jest-mock-console-1.2.3.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/jest-watch-typeahead/-/jest-watch-typeahead-1.1.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/lint-staged/-/lint-staged-12.4.1.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/microbundle/-/microbundle-0.15.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/prettier/-/prettier-2.6.2.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/shx/-/shx-0.3.4.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/typedoc/-/typedoc-0.22.15.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.12.1.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/mitt/-/mitt-3.0.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-6.0.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.

@renovate renovate Bot changed the title chore(deps): update dependency xstate to v5 fix(deps): update dependency xstate to v5 Dec 10, 2024
@renovate

renovate Bot commented Aug 6, 2025

Copy link
Copy Markdown
Contributor Author

⚠️ Artifact update problem

Renovate failed to update an artifact related to this branch. You probably do not want to merge this PR as-is.

♻ Renovate will retry this branch, including artifacts, only when one of the following happens:

  • any of the package files in this branch needs updating, or
  • the branch becomes conflicted, or
  • you click the rebase/retry checkbox if found above, or
  • you rename this PR's title to start with "rebase!" to trigger it manually

The artifact failure details are included below:

File name: pnpm-lock.yaml
 WARN  GET https://registry.npmjs.org/xstate error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@babel/core/-/core-7.17.10.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.17.10.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.16.7.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@changesets/cli/-/cli-2.22.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@types/jest/-/jest-27.5.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@types/node/-/node-17.0.31.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.22.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.22.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/babel-plugin-dev-expression/-/babel-plugin-dev-expression-0.2.3.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/babel-plugin-transform-define/-/babel-plugin-transform-define-2.0.1.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/eslint/-/eslint-8.15.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-26.1.5.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/xstate error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/@babel/core/-/core-7.17.10.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.17.10.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.16.7.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/@changesets/cli/-/cli-2.22.0.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/@types/jest/-/jest-27.5.0.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/@types/node/-/node-17.0.31.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.22.0.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.22.0.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/babel-plugin-dev-expression/-/babel-plugin-dev-expression-0.2.3.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/babel-plugin-transform-define/-/babel-plugin-transform-define-2.0.1.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/eslint/-/eslint-8.15.0.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-26.1.5.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz error (ERR_INVALID_THIS). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.2.16.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 ERR_INVALID_THIS  Value of "this" must be of type URLSearchParams
 WARN  GET https://registry.npmjs.org/husky/-/husky-7.0.4.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/jest/-/jest-28.1.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/jest-mock-console/-/jest-mock-console-1.2.3.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/jest-watch-typeahead/-/jest-watch-typeahead-1.1.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/lint-staged/-/lint-staged-12.4.1.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/microbundle/-/microbundle-0.15.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/prettier/-/prettier-2.6.2.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/shx/-/shx-0.3.4.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/typedoc/-/typedoc-0.22.15.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.12.1.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/mitt/-/mitt-3.0.0.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.

@renovate renovate Bot changed the title fix(deps): update dependency xstate to v5 Update dependency xstate to v5 Apr 8, 2026
@renovate renovate Bot changed the title Update dependency xstate to v5 Update xstate monorepo to v5 Jun 2, 2026
@renovate renovate Bot changed the title Update xstate monorepo to v5 Update xstate monorepo (major) Jun 22, 2026
@renovate renovate Bot changed the title Update xstate monorepo (major) Update dependency xstate to v5 Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants