@xstate/react 5.0.5 → 6.1.0
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,2 +1,2 @@
|
|
|
1
|
-
export * from "./declarations/src/index";
|
|
1
|
+
export * from "./declarations/src/index.js";
|
|
2
2
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoieHN0YXRlLXJlYWN0LmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi9kZWNsYXJhdGlvbnMvc3JjL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
|
package/dist/xstate-react.cjs.js
CHANGED
|
@@ -115,10 +115,19 @@ function useSelector(actor, selector, compare = defaultCompare) {
|
|
|
115
115
|
}
|
|
116
116
|
const {
|
|
117
117
|
unsubscribe
|
|
118
|
-
} = actor.subscribe(
|
|
118
|
+
} = actor.subscribe({
|
|
119
|
+
next: handleStoreChange,
|
|
120
|
+
error: handleStoreChange
|
|
121
|
+
});
|
|
119
122
|
return unsubscribe;
|
|
120
123
|
}, [actor]);
|
|
121
|
-
const boundGetSnapshot = React.useCallback(() =>
|
|
124
|
+
const boundGetSnapshot = React.useCallback(() => {
|
|
125
|
+
const snapshot = actor?.getSnapshot();
|
|
126
|
+
if (snapshot && 'status' in snapshot && snapshot.status === 'error') {
|
|
127
|
+
throw snapshot.error;
|
|
128
|
+
}
|
|
129
|
+
return snapshot;
|
|
130
|
+
}, [actor]);
|
|
122
131
|
const selectedSnapshot = withSelector.useSyncExternalStoreWithSelector(subscribe, boundGetSnapshot, boundGetSnapshot, selector, compare);
|
|
123
132
|
return selectedSnapshot;
|
|
124
133
|
}
|
|
@@ -197,10 +206,17 @@ function useActor(logic, ...[options]) {
|
|
|
197
206
|
const subscribe = React.useCallback(handleStoreChange => {
|
|
198
207
|
const {
|
|
199
208
|
unsubscribe
|
|
200
|
-
} = actorRef.subscribe(
|
|
209
|
+
} = actorRef.subscribe({
|
|
210
|
+
next: handleStoreChange,
|
|
211
|
+
error: handleStoreChange
|
|
212
|
+
});
|
|
201
213
|
return unsubscribe;
|
|
202
214
|
}, [actorRef]);
|
|
203
215
|
const actorSnapshot = shim.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
216
|
+
const snapshotWithStatus = 'status' in actorSnapshot ? actorSnapshot : undefined;
|
|
217
|
+
if (snapshotWithStatus?.status === 'error') {
|
|
218
|
+
throw snapshotWithStatus.error;
|
|
219
|
+
}
|
|
204
220
|
React.useEffect(() => {
|
|
205
221
|
actorRef.start();
|
|
206
222
|
return () => {
|
|
@@ -115,10 +115,19 @@ function useSelector(actor, selector, compare = defaultCompare) {
|
|
|
115
115
|
}
|
|
116
116
|
const {
|
|
117
117
|
unsubscribe
|
|
118
|
-
} = actor.subscribe(
|
|
118
|
+
} = actor.subscribe({
|
|
119
|
+
next: handleStoreChange,
|
|
120
|
+
error: handleStoreChange
|
|
121
|
+
});
|
|
119
122
|
return unsubscribe;
|
|
120
123
|
}, [actor]);
|
|
121
|
-
const boundGetSnapshot = React.useCallback(() =>
|
|
124
|
+
const boundGetSnapshot = React.useCallback(() => {
|
|
125
|
+
const snapshot = actor?.getSnapshot();
|
|
126
|
+
if (snapshot && 'status' in snapshot && snapshot.status === 'error') {
|
|
127
|
+
throw snapshot.error;
|
|
128
|
+
}
|
|
129
|
+
return snapshot;
|
|
130
|
+
}, [actor]);
|
|
122
131
|
const selectedSnapshot = withSelector.useSyncExternalStoreWithSelector(subscribe, boundGetSnapshot, boundGetSnapshot, selector, compare);
|
|
123
132
|
return selectedSnapshot;
|
|
124
133
|
}
|
|
@@ -200,10 +209,17 @@ function useActor(logic, ...[options]) {
|
|
|
200
209
|
const subscribe = React.useCallback(handleStoreChange => {
|
|
201
210
|
const {
|
|
202
211
|
unsubscribe
|
|
203
|
-
} = actorRef.subscribe(
|
|
212
|
+
} = actorRef.subscribe({
|
|
213
|
+
next: handleStoreChange,
|
|
214
|
+
error: handleStoreChange
|
|
215
|
+
});
|
|
204
216
|
return unsubscribe;
|
|
205
217
|
}, [actorRef]);
|
|
206
218
|
const actorSnapshot = shim.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
219
|
+
const snapshotWithStatus = 'status' in actorSnapshot ? actorSnapshot : undefined;
|
|
220
|
+
if (snapshotWithStatus?.status === 'error') {
|
|
221
|
+
throw snapshotWithStatus.error;
|
|
222
|
+
}
|
|
207
223
|
React.useEffect(() => {
|
|
208
224
|
actorRef.start();
|
|
209
225
|
return () => {
|
|
@@ -89,10 +89,19 @@ function useSelector(actor, selector, compare = defaultCompare) {
|
|
|
89
89
|
}
|
|
90
90
|
const {
|
|
91
91
|
unsubscribe
|
|
92
|
-
} = actor.subscribe(
|
|
92
|
+
} = actor.subscribe({
|
|
93
|
+
next: handleStoreChange,
|
|
94
|
+
error: handleStoreChange
|
|
95
|
+
});
|
|
93
96
|
return unsubscribe;
|
|
94
97
|
}, [actor]);
|
|
95
|
-
const boundGetSnapshot = useCallback(() =>
|
|
98
|
+
const boundGetSnapshot = useCallback(() => {
|
|
99
|
+
const snapshot = actor?.getSnapshot();
|
|
100
|
+
if (snapshot && 'status' in snapshot && snapshot.status === 'error') {
|
|
101
|
+
throw snapshot.error;
|
|
102
|
+
}
|
|
103
|
+
return snapshot;
|
|
104
|
+
}, [actor]);
|
|
96
105
|
const selectedSnapshot = useSyncExternalStoreWithSelector(subscribe, boundGetSnapshot, boundGetSnapshot, selector, compare);
|
|
97
106
|
return selectedSnapshot;
|
|
98
107
|
}
|
|
@@ -174,10 +183,17 @@ function useActor(logic, ...[options]) {
|
|
|
174
183
|
const subscribe = useCallback(handleStoreChange => {
|
|
175
184
|
const {
|
|
176
185
|
unsubscribe
|
|
177
|
-
} = actorRef.subscribe(
|
|
186
|
+
} = actorRef.subscribe({
|
|
187
|
+
next: handleStoreChange,
|
|
188
|
+
error: handleStoreChange
|
|
189
|
+
});
|
|
178
190
|
return unsubscribe;
|
|
179
191
|
}, [actorRef]);
|
|
180
192
|
const actorSnapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
193
|
+
const snapshotWithStatus = 'status' in actorSnapshot ? actorSnapshot : undefined;
|
|
194
|
+
if (snapshotWithStatus?.status === 'error') {
|
|
195
|
+
throw snapshotWithStatus.error;
|
|
196
|
+
}
|
|
181
197
|
useEffect(() => {
|
|
182
198
|
actorRef.start();
|
|
183
199
|
return () => {
|
package/dist/xstate-react.esm.js
CHANGED
|
@@ -89,10 +89,19 @@ function useSelector(actor, selector, compare = defaultCompare) {
|
|
|
89
89
|
}
|
|
90
90
|
const {
|
|
91
91
|
unsubscribe
|
|
92
|
-
} = actor.subscribe(
|
|
92
|
+
} = actor.subscribe({
|
|
93
|
+
next: handleStoreChange,
|
|
94
|
+
error: handleStoreChange
|
|
95
|
+
});
|
|
93
96
|
return unsubscribe;
|
|
94
97
|
}, [actor]);
|
|
95
|
-
const boundGetSnapshot = useCallback(() =>
|
|
98
|
+
const boundGetSnapshot = useCallback(() => {
|
|
99
|
+
const snapshot = actor?.getSnapshot();
|
|
100
|
+
if (snapshot && 'status' in snapshot && snapshot.status === 'error') {
|
|
101
|
+
throw snapshot.error;
|
|
102
|
+
}
|
|
103
|
+
return snapshot;
|
|
104
|
+
}, [actor]);
|
|
96
105
|
const selectedSnapshot = useSyncExternalStoreWithSelector(subscribe, boundGetSnapshot, boundGetSnapshot, selector, compare);
|
|
97
106
|
return selectedSnapshot;
|
|
98
107
|
}
|
|
@@ -171,10 +180,17 @@ function useActor(logic, ...[options]) {
|
|
|
171
180
|
const subscribe = useCallback(handleStoreChange => {
|
|
172
181
|
const {
|
|
173
182
|
unsubscribe
|
|
174
|
-
} = actorRef.subscribe(
|
|
183
|
+
} = actorRef.subscribe({
|
|
184
|
+
next: handleStoreChange,
|
|
185
|
+
error: handleStoreChange
|
|
186
|
+
});
|
|
175
187
|
return unsubscribe;
|
|
176
188
|
}, [actorRef]);
|
|
177
189
|
const actorSnapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
190
|
+
const snapshotWithStatus = 'status' in actorSnapshot ? actorSnapshot : undefined;
|
|
191
|
+
if (snapshotWithStatus?.status === 'error') {
|
|
192
|
+
throw snapshotWithStatus.error;
|
|
193
|
+
}
|
|
178
194
|
useEffect(() => {
|
|
179
195
|
actorRef.start();
|
|
180
196
|
return () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xstate/react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "XState tools for React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"state",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
57
|
-
"xstate": "^5.
|
|
57
|
+
"xstate": "^5.28.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependenciesMeta": {
|
|
60
60
|
"xstate": {
|
|
@@ -73,8 +73,7 @@
|
|
|
73
73
|
"react": "^19.0.0",
|
|
74
74
|
"react-dom": "^19.0.0",
|
|
75
75
|
"rxjs": "^7.8.1",
|
|
76
|
-
"
|
|
77
|
-
"xstate": "^5.19.4"
|
|
76
|
+
"xstate": "^5.28.0"
|
|
78
77
|
},
|
|
79
78
|
"scripts": {}
|
|
80
79
|
}
|