@octanejs/tanstack-store 0.0.46 → 0.0.48
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.
- package/package.json +4 -4
- package/src/useSelector.ts +10 -2
- package/src/useStore.ts +4 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octanejs/tanstack-store",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.48",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@testing-library/jest-dom": "^6.9.1",
|
|
49
49
|
"@testing-library/react": "16.3.1",
|
|
50
50
|
"@testing-library/user-event": "^14.6.1",
|
|
51
|
-
"@tsrx/react": "^0.2.
|
|
51
|
+
"@tsrx/react": "^0.2.67",
|
|
52
52
|
"@types/react": "19.2.7",
|
|
53
53
|
"@types/react-dom": "19.2.3",
|
|
54
54
|
"@types/use-sync-external-store": "^1.5.0",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"react-dom": "19.2.3",
|
|
58
58
|
"use-sync-external-store": "1.6.0",
|
|
59
59
|
"vitest": "^4.1.10",
|
|
60
|
-
"@octanejs/testing-library": "0.1.
|
|
61
|
-
"octane": "0.2.
|
|
60
|
+
"@octanejs/testing-library": "0.1.50",
|
|
61
|
+
"octane": "0.2.4"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"test": "vitest run",
|
package/src/useSelector.ts
CHANGED
|
@@ -3,7 +3,12 @@ import { splitSlot, subSlot } from './internal';
|
|
|
3
3
|
import { useSyncExternalStoreWithSelector } from './useSyncExternalStoreWithSelector';
|
|
4
4
|
|
|
5
5
|
export interface UseSelectorOptions<TSelected> {
|
|
6
|
-
|
|
6
|
+
// Written as an optional property that also admits `undefined`, because this
|
|
7
|
+
// package publishes source and the consumer's compiler options apply to it.
|
|
8
|
+
// Under `exactOptionalPropertyTypes` a bare `compare?:` would reject both an
|
|
9
|
+
// options object forwarded from another optional value and this package's own
|
|
10
|
+
// `useStore` bridge, which always passes the key through.
|
|
11
|
+
compare?: ((a: TSelected, b: TSelected) => boolean) | undefined;
|
|
7
12
|
}
|
|
8
13
|
|
|
9
14
|
type SyncExternalStoreSubscribe = Parameters<typeof useSyncExternalStoreWithSelector>[0];
|
|
@@ -52,7 +57,10 @@ export function useSelector<TSource, TSelected = NoInfer<TSource>>(
|
|
|
52
57
|
slot?: symbol,
|
|
53
58
|
]
|
|
54
59
|
): TSelected {
|
|
55
|
-
const [user,
|
|
60
|
+
const [user, callerSlot] = splitSlot(rest);
|
|
61
|
+
// The authored fourth argument precedes any slot appended by the compiler adapter.
|
|
62
|
+
const explicitSlot = user[2];
|
|
63
|
+
const slot = typeof explicitSlot === 'symbol' ? explicitSlot : callerSlot;
|
|
56
64
|
const selector =
|
|
57
65
|
(user[0] as ((snapshot: TSource) => TSelected) | undefined) ??
|
|
58
66
|
((snapshot: TSource) => snapshot as unknown as TSelected);
|
package/src/useStore.ts
CHANGED
|
@@ -32,7 +32,10 @@ export function useStore<TSource, TSelected = NoInfer<TSource>>(
|
|
|
32
32
|
slot?: symbol,
|
|
33
33
|
]
|
|
34
34
|
): TSelected {
|
|
35
|
-
const [user,
|
|
35
|
+
const [user, callerSlot] = splitSlot(rest);
|
|
36
|
+
// The authored fourth argument precedes any slot appended by the compiler adapter.
|
|
37
|
+
const explicitSlot = user[2];
|
|
38
|
+
const slot = typeof explicitSlot === 'symbol' ? explicitSlot : callerSlot;
|
|
36
39
|
const selector = user[0] as ((snapshot: TSource) => TSelected) | undefined;
|
|
37
40
|
const compare = user[1] as ((a: TSelected, b: TSelected) => boolean) | undefined;
|
|
38
41
|
|