@xstate/react 4.0.0 → 4.0.2

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.
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
- import { ActorRefFrom, AnyStateMachine, SnapshotFrom, ActorOptions, AreAllImplementationsAssumedToBeProvided, MarkAllImplementationsAsProvided, StateMachine, AnyActorLogic } from 'xstate';
3
- type ToMachinesWithProvidedImplementations<TMachine extends AnyStateMachine> = TMachine extends StateMachine<infer TContext, infer TEvent, infer TChildren, infer TActor, infer TAction, infer TGuard, infer TDelay, infer TStateValue, infer TTag, infer TInput, infer TOutput, infer TResolvedTypesMeta> ? StateMachine<TContext, TEvent, TChildren, TActor, TAction, TGuard, TDelay, TStateValue, TTag, TInput, TOutput, AreAllImplementationsAssumedToBeProvided<TResolvedTypesMeta> extends false ? MarkAllImplementationsAsProvided<TResolvedTypesMeta> : TResolvedTypesMeta> : never;
2
+ import { ActorRefFrom, SnapshotFrom, ActorOptions, AnyActorLogic } from 'xstate';
4
3
  export declare function createActorContext<TLogic extends AnyActorLogic>(actorLogic: TLogic, interpreterOptions?: ActorOptions<TLogic>): {
5
4
  useSelector: <T>(selector: (snapshot: SnapshotFrom<TLogic>) => T, compare?: (a: T, b: T) => boolean) => T;
6
5
  useActorRef: () => ActorRefFrom<TLogic>;
@@ -11,12 +10,6 @@ export declare function createActorContext<TLogic extends AnyActorLogic>(actorLo
11
10
  * @deprecated Use `logic` instead.
12
11
  */
13
12
  machine?: never;
14
- } & (TLogic extends AnyStateMachine ? AreAllImplementationsAssumedToBeProvided<TLogic['__TResolvedTypesMeta']> extends true ? {
15
13
  logic?: TLogic;
16
- } : {
17
- logic: ToMachinesWithProvidedImplementations<TLogic>;
18
- } : {
19
- logic?: TLogic;
20
- })) => React.ReactElement<any, any>;
14
+ }) => React.ReactElement<any, any>;
21
15
  };
22
- export {};
@@ -1,8 +1,8 @@
1
- import { ActorRefFrom, AnyStateMachine, AreAllImplementationsAssumedToBeProvided, ActorOptions, MissingImplementationsError, StateFrom } from 'xstate';
1
+ import { ActorRefFrom, AnyStateMachine, ActorOptions, StateFrom } from 'xstate';
2
2
  /**
3
3
  * @alias useActor
4
4
  */
5
- export declare function useMachine<TMachine extends AnyStateMachine>(machine: AreAllImplementationsAssumedToBeProvided<TMachine['__TResolvedTypesMeta']> extends true ? TMachine : MissingImplementationsError<TMachine['__TResolvedTypesMeta']>, options?: ActorOptions<TMachine>): [
5
+ export declare function useMachine<TMachine extends AnyStateMachine>(machine: TMachine, options?: ActorOptions<TMachine>): [
6
6
  StateFrom<TMachine>,
7
7
  ActorRefFrom<TMachine>['send'],
8
8
  ActorRefFrom<TMachine>
@@ -54,7 +54,9 @@ function stopRootWithRehydration(actorRef) {
54
54
  // as each subscription should have its own cleanup logic and that should be called each such reconnect
55
55
  ref.observers = new Set();
56
56
  });
57
+ const systemSnapshot = actorRef.system.getSnapshot?.();
57
58
  actorRef.stop();
59
+ actorRef.system._snapshot = systemSnapshot;
58
60
  persistedSnapshots.forEach(([ref, snapshot]) => {
59
61
  ref._processingStatus = 0;
60
62
  ref._snapshot = snapshot;
@@ -54,7 +54,9 @@ function stopRootWithRehydration(actorRef) {
54
54
  // as each subscription should have its own cleanup logic and that should be called each such reconnect
55
55
  ref.observers = new Set();
56
56
  });
57
+ const systemSnapshot = actorRef.system.getSnapshot?.();
57
58
  actorRef.stop();
59
+ actorRef.system._snapshot = systemSnapshot;
58
60
  persistedSnapshots.forEach(([ref, snapshot]) => {
59
61
  ref._processingStatus = 0;
60
62
  ref._snapshot = snapshot;
@@ -28,7 +28,9 @@ function stopRootWithRehydration(actorRef) {
28
28
  // as each subscription should have its own cleanup logic and that should be called each such reconnect
29
29
  ref.observers = new Set();
30
30
  });
31
+ const systemSnapshot = actorRef.system.getSnapshot?.();
31
32
  actorRef.stop();
33
+ actorRef.system._snapshot = systemSnapshot;
32
34
  persistedSnapshots.forEach(([ref, snapshot]) => {
33
35
  ref._processingStatus = 0;
34
36
  ref._snapshot = snapshot;
@@ -28,7 +28,9 @@ function stopRootWithRehydration(actorRef) {
28
28
  // as each subscription should have its own cleanup logic and that should be called each such reconnect
29
29
  ref.observers = new Set();
30
30
  });
31
+ const systemSnapshot = actorRef.system.getSnapshot?.();
31
32
  actorRef.stop();
33
+ actorRef.system._snapshot = systemSnapshot;
32
34
  persistedSnapshots.forEach(([ref, snapshot]) => {
33
35
  ref._processingStatus = 0;
34
36
  ref._snapshot = snapshot;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xstate/react",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "XState tools for React",
5
5
  "keywords": [
6
6
  "state",
@@ -55,7 +55,7 @@
55
55
  },
56
56
  "peerDependencies": {
57
57
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
58
- "xstate": "^5.0.0"
58
+ "xstate": "^5.4.1"
59
59
  },
60
60
  "peerDependenciesMeta": {
61
61
  "xstate": {
@@ -76,6 +76,6 @@
76
76
  "jsdom-global": "^3.0.2",
77
77
  "react": "^18.0.0",
78
78
  "react-dom": "^18.0.0",
79
- "xstate": "5.0.0"
79
+ "xstate": "5.4.1"
80
80
  }
81
81
  }