@octanejs/zustand 0.1.0 → 0.1.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.
- package/package.json +3 -3
- package/src/traditional.ts +10 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octanejs/zustand",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "zustand bindings for the octane renderer — reuses zustand's framework-agnostic vanilla store and swaps the React binding for octane's useSyncExternalStore.",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"zustand": "^5.0.0",
|
|
35
|
-
"octane": "0.1.
|
|
35
|
+
"octane": "0.1.3"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@tsrx/react": "^0.2.
|
|
38
|
+
"@tsrx/react": "^0.2.33",
|
|
39
39
|
"esbuild": "^0.28.1",
|
|
40
40
|
"react": "^19.2.0",
|
|
41
41
|
"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> {
|