Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update xstate monorepo (major) #1489

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Apr 23, 2024

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
@xstate/vue (source) ^2.0.0 -> ^4.0.0 age adoption passing confidence
xstate (source) ^4.38.3 -> ^5.19.0 age adoption passing confidence

Release Notes

statelyai/xstate (@​xstate/vue)

v4.0.0

Compare Source

Major Changes
  • #​3947 5fa3a0c74 Thanks @​davidkpiano! - Removed the ability to pass a factory function as argument to useMachine.

  • #​4006 42df9a536 Thanks @​davidkpiano! - useActorRef is introduced, which returns an ActorRef from actor logic:

    const actorRef = useActorRef(machine, { ... });
    const anotherActorRef = useActorRef(fromPromise(...));

    ~~useMachine~~ is deprecated in favor of useActor, which works with machines and any other kind of logic

    -const [state, send] = useMachine(machine);
    +const [state, send] = useActor(machine);
    const [state, send] = useActor(fromTransition(...));

    ~~useSpawn~~ is removed in favor of useActorRef

    -const actorRef = useSpawn(machine);
    +const actorRef = useActorRef(machine);
    
    The previous use of `useActor(actorRef)` is now replaced with just using the `actorRef` directly, and with `useSelector`:
    
    ```diff
    -const [state, send] = useActor(actorRef);
    +const state = useSelector(actorRef, s => s);
    // actorRef.send(...)
  • #​4050 fc88dc8e6 Thanks @​davidkpiano! - The options prop has been added (back) to the Context.Provider component returned from createActorContext:

    const SomeContext = createActorContext(someMachine);
    
    // ...
    
    <SomeContext.Provider options={{ input: 42 }}>
      {/* ... */}
    </SomeContext.Provider>;
  • #​4006 42df9a536 Thanks @​davidkpiano! - useActor has been removed from the created actor context, you should be able to replace its usage with MyCtx.useSelector and MyCtx.useActorRef.

  • #​4265 1153b3f9a Thanks @​davidkpiano! - FSM-related functions have been removed.

  • #​3947 5fa3a0c74 Thanks @​davidkpiano! - Implementations for machines on useMachine hooks should go directly on the machine via machine.provide(...), and are no longer allowed to be passed in as options.

    -const [state, send] = useMachine(machine, {
    -  actions: {
    -    // ...
    -  }
    -});
    +const [state, send] = useMachine(machine.provide({
    +  actions: {
    +    // ...
    +  }
    +}));
  • #​3148 7a68cbb61 Thanks @​davidkpiano! - Removed getSnapshot parameter from hooks. It is expected that the received actorRef has to have a getSnapshot method on it that can be used internally.

Minor Changes

v3.1.4

Compare Source

Patch Changes

v3.1.3

Compare Source

Patch Changes
  • #​5055 ad38c35c37 Thanks @​SandroMaglione! - Updated types of useActor, useMachine, and useActorRef to require input when defined inside types/input.

    Previously even when input was defined inside types, useActor, useMachine, and useActorRef would not make the input required:

    const machine = setup({
      types: {
        input: {} as { value: number }
      }
    }).createMachine({});
    
    function App() {
      // Event if `input` is not defined, `useMachine` works at compile time, but risks crashing at runtime
      const _ = useMachine(machine);
      return <></>;
    }

    With this change the above code will show a type error, since input is now required:

    const machine = setup({
      types: {
        input: {} as { value: number }
      }
    }).createMachine({});
    
    function App() {
      const _ = useMachine(machine, {
        input: { value: 1 } // Now input is required at compile time!
      });
      return <></>;
    }

    This avoids runtime errors when forgetting to pass input when defined inside types.

v3.1.2

Compare Source

Patch Changes
  • #​3804 b53856d28 Thanks @​farskid! - Interpreter options can now be specified in the second argument of createActorContext(machine, options).

v3.1.1

Compare Source

Patch Changes
  • #​3799 51d254692 Thanks @​Andarist! - Fixed an issue that caused the internally used useSyncExternalStore to warn about the computed snapshot not being cached when a not-started machine servive was passed to useActor.

v3.1.0

Compare Source

Minor Changes
  • #​3778 f12248b23 Thanks @​davidkpiano! - The createActorContext(...) helper has been introduced to make global actors easier to use with React. It outputs a React Context object with the following properties:

    • .Provider - The React Context provider
    • .useActor(...) - A hook that can be used to get the current state and send events to the actor
    • .useSelector(...) - A hook that can be used to select some derived state from the actor's state
    • .useActorRef() - A hook that can be used to get a reference to the actor that can be passed to other components

    Usage:

    import { createActorContext } from '@&#8203;xstate/react';
    import { someMachine } from './someMachine';
    
    // Create a React Context object that will interpret the machine
    const SomeContext = createActorContext(someMachine);
    
    function SomeComponent() {
      // Get the current state and `send` function
      const [state, send] = SomeContext.useActor();
    
      // Or select some derived state
      const someValue = SomeContext.useSelector((state) => state.context.someValue);
    
      // Or get a reference to the actor
      const actorRef = SomeContext.useActorRef();
    
      return (/* ... */);
    }
    
    function App() {
      return (
        <SomeContext.Provider>
          <SomeComponent />
        </SomeContext.Provider>
      );
    }

v3.0.3

Compare Source

Patch Changes

v3.0.2

Compare Source

Patch Changes
  • #​3752 4190c3fd6 Thanks @​davidkpiano! - Computing the initial state is now consistent with useMachine and useActor, avoiding stale initial state problems with nested machines

v3.0.1

Compare Source

Patch Changes
  • #​3456 131d429ab Thanks @​davidkpiano! - Add shallowEqual helper comparator function.

  • #​3500 0dfc6d92f Thanks @​Andarist! - Fixed an issue with useSelector always computing fresh snapshots internally for uninitialized services. This avoids the internal useSyncExternalStore from warning about the snapshot value not being cached properly.

v3.0.0

Compare Source

Major Changes
  • #​2939 360e85462 Thanks @​Andarist! - This package now accepts React 18 as a peer dep and the implementation has been rewritten to use use-sync-external-store package. This doesn't break compatibility with older versions of React since we are using the shim to keep compatibility with those older versions.

  • #​2939 360e85462 Thanks @​Andarist! - asEffect and asLayoutEffect action creators were removed. They were not fitting the React model that well and could lead to issues as their existence suggested that they are easy to use.

    To execute actions at those exact times you can always either just call your stuff directly from those effects or send events to the machine from those effects and execute explicit actions in response to said events.

  • #​2939 360e85462 Thanks @​Andarist! - The signatures of useMachine and useService integrating with @xstate/fsm were changed. They now only accept a single generic each (TMachine and TService respectively). This has been done to match their signatures with the related hooks that integrate with xstate itself.

Patch Changes
  • #​2939 360e85462 Thanks @​Andarist! - In v2 we have changed signatures of useMachine and useInterpret. Instead of accepting a list of generics they now only support a single generic: TMachine. This change, erroneously, was only introduced to types targeting [email protected] but the types targeting previous TS releases were still using the older signatures. This has now been fixed and users of older TS versions should now be able to leverage typegen with @xstate/react.

  • #​2939 360e85462 Thanks @​Andarist! - useMachine for xstate now correctly rerenders with the initial state when the internal service is being restarted. This might happen during Fast Refresh and now you shouldn't be able to observe this stale state that didn't match the actual state of the service.

  • #​2939 360e85462 Thanks @​Andarist! - useMachine for @xstate/fsm now starts the service in an effect. This avoids side-effects in render and improves the compatibility with StrictMode.

  • #​2939 360e85462 Thanks @​Andarist! - Implementations given to useMachine targeting @xstate/fsm are now updated in a layout effect. This avoid some stale closure problems for actions that are executed in response to events sent from layout effects.

  • Updated dependencies [360e85462, 360e85462]:


Configuration

📅 Schedule: Branch creation - "before 5am every weekday" in timezone America/New_York, Automerge - "every weekday" in timezone America/New_York.

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

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.


  • 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 added dependencies Pull requests that update a dependency file renovate-bot labels Apr 23, 2024
@renovate renovate bot requested a review from a team as a code owner April 23, 2024 06:49
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from b167e07 to 14b75f2 Compare April 24, 2024 06:19
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 14b75f2 to 0ffe366 Compare April 29, 2024 07:32
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 0ffe366 to b864357 Compare April 30, 2024 07:38
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from b864357 to b4820a8 Compare May 1, 2024 06:18
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from b4820a8 to b7e29fb Compare May 2, 2024 04:59
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from b7e29fb to 3ca0d7f Compare May 6, 2024 04:42
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 3ca0d7f to ac867a5 Compare May 6, 2024 07:09
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from ac867a5 to f2d31ed Compare May 7, 2024 05:18
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from f2d31ed to 3b126f0 Compare May 7, 2024 08:24
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 3b126f0 to 7a63253 Compare May 9, 2024 04:50
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 7a63253 to 78ccdcf Compare May 10, 2024 05:21
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 78ccdcf to 72098b9 Compare May 10, 2024 06:51
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 72098b9 to 8e6158d Compare May 16, 2024 06:02
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 79cfafa to 09ae589 Compare October 15, 2024 04:59
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 09ae589 to 424bee8 Compare October 18, 2024 04:03
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 424bee8 to a2b4685 Compare October 22, 2024 05:19
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from a2b4685 to 95d6ab6 Compare October 29, 2024 05:13
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 95d6ab6 to 3fb22b6 Compare October 31, 2024 04:05
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 3fb22b6 to dba198e Compare November 4, 2024 08:29
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from dba198e to d7e8f9c Compare November 11, 2024 06:44
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from d7e8f9c to df142eb Compare November 14, 2024 06:25
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from df142eb to 751cd03 Compare November 19, 2024 06:36
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 751cd03 to 4fec211 Compare November 21, 2024 06:47
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 4fec211 to fe199ec Compare November 25, 2024 09:56
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from fe199ec to 883679d Compare November 26, 2024 07:57
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 883679d to 4e1dd7a Compare November 27, 2024 07:29
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 4e1dd7a to 9b6d4c0 Compare November 28, 2024 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file renovate-bot
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant