@octanejs/zustand 0.1.0 → 0.1.3
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/README.md +7 -1
- package/package.json +10 -3
- package/src/traditional.ts +10 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @octanejs/zustand
|
|
2
2
|
|
|
3
|
-
[zustand](https://github.com/pmndrs/zustand) for the [octane](https://github.com/octanejs/octane)
|
|
3
|
+
[zustand](https://github.com/pmndrs/zustand) for the [octane](https://github.com/octanejs/octane) UI framework.
|
|
4
4
|
|
|
5
5
|
zustand separates a framework-agnostic **vanilla store** (`createStore`) from a tiny
|
|
6
6
|
**React binding** (`create` + `useStore`) built on `useSyncExternalStore`. This package
|
|
@@ -84,3 +84,9 @@ const { a } = useStore((s) => ({ a: s.a })); // bails out via shallow
|
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
For most object-slice selections, prefer `useShallow` — the v5-recommended approach.
|
|
87
|
+
|
|
88
|
+
## Status
|
|
89
|
+
|
|
90
|
+
Current scope, known divergences, and verification status are tracked in the
|
|
91
|
+
generated [bindings status table](../../docs/bindings-status.md), sourced from
|
|
92
|
+
this package's [`status.json`](./status.json).
|
package/package.json
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octanejs/zustand",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"octane": {
|
|
7
|
+
"hookSlots": {
|
|
8
|
+
"manual": [
|
|
9
|
+
"src"
|
|
10
|
+
]
|
|
11
|
+
}
|
|
12
|
+
},
|
|
6
13
|
"description": "zustand bindings for the octane renderer — reuses zustand's framework-agnostic vanilla store and swaps the React binding for octane's useSyncExternalStore.",
|
|
7
14
|
"author": {
|
|
8
15
|
"name": "Dominic Gannaway",
|
|
@@ -32,10 +39,10 @@
|
|
|
32
39
|
},
|
|
33
40
|
"dependencies": {
|
|
34
41
|
"zustand": "^5.0.0",
|
|
35
|
-
"octane": "0.1.
|
|
42
|
+
"octane": "0.1.4"
|
|
36
43
|
},
|
|
37
44
|
"devDependencies": {
|
|
38
|
-
"@tsrx/react": "^0.2.
|
|
45
|
+
"@tsrx/react": "^0.2.37",
|
|
39
46
|
"esbuild": "^0.28.1",
|
|
40
47
|
"react": "^19.2.0",
|
|
41
48
|
"react-dom": "^19.2.0",
|
package/src/traditional.ts
CHANGED
|
@@ -27,8 +27,17 @@ const identity = <T>(arg: T): T => arg;
|
|
|
27
27
|
// Derive a stable, distinct sub-slot from the wrapper's slot. `Symbol.for` interns
|
|
28
28
|
// by description, so the same call site always yields the same sub-slot; the
|
|
29
29
|
// `:wsel:` namespace keeps it clear of useSyncExternalStore's `:uses:` slots.
|
|
30
|
+
// Memoized — subSlot runs per hook call per render; the cache returns the
|
|
31
|
+
// identical Symbol.for-interned value without the concat + registry lookup.
|
|
32
|
+
const subSlotCache = new Map<symbol, Map<string, symbol>>();
|
|
30
33
|
function subSlot(slot: symbol | undefined, tag: string): symbol | undefined {
|
|
31
|
-
|
|
34
|
+
if (slot === undefined) return undefined;
|
|
35
|
+
let byTag = subSlotCache.get(slot);
|
|
36
|
+
if (byTag === undefined) subSlotCache.set(slot, (byTag = new Map()));
|
|
37
|
+
let sym = byTag.get(tag);
|
|
38
|
+
if (sym === undefined)
|
|
39
|
+
byTag.set(tag, (sym = Symbol.for((slot.description ?? '') + ':wsel:' + tag)));
|
|
40
|
+
return sym;
|
|
32
41
|
}
|
|
33
42
|
|
|
34
43
|
interface SelectionCell<U> {
|