@octanejs/zustand 0.1.42 → 0.1.44

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/traditional.ts +2 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octanejs/zustand",
3
- "version": "0.1.42",
3
+ "version": "0.1.44",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "engines": {
@@ -45,7 +45,7 @@
45
45
  "zustand": "^5.0.14"
46
46
  },
47
47
  "peerDependencies": {
48
- "octane": "0.1.43"
48
+ "octane": "0.1.45"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@tsrx/react": "^0.2.58",
@@ -53,7 +53,7 @@
53
53
  "react": "^19.2.7",
54
54
  "react-dom": "^19.2.7",
55
55
  "vitest": "^4.1.10",
56
- "octane": "0.1.43"
56
+ "octane": "0.1.45"
57
57
  },
58
58
  "scripts": {
59
59
  "test": "vitest run"
@@ -15,7 +15,7 @@
15
15
  //
16
16
  // Note: v5 recommends `useShallow` over this equality-fn pattern for object
17
17
  // slices; `traditional` exists for code that still uses it.
18
- import { useSyncExternalStore, useRef } from 'octane';
18
+ import { createSubSlot, useSyncExternalStore, useRef } from 'octane';
19
19
  import { createStore } from 'zustand/vanilla';
20
20
  import type { StateCreator, StoreApi } from 'zustand/vanilla';
21
21
 
@@ -24,21 +24,7 @@ type ReadonlyStoreApi<T> = Pick<StoreApi<T>, 'getState' | 'getInitialState' | 's
24
24
 
25
25
  const identity = <T>(arg: T): T => arg;
26
26
 
27
- // Derive a stable, distinct sub-slot from the wrapper's slot. `Symbol.for` interns
28
- // by description, so the same call site always yields the same sub-slot; the
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>>();
33
- function subSlot(slot: symbol | undefined, tag: string): symbol | undefined {
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;
41
- }
27
+ const subSlot = createSubSlot({ tagPrefix: ':wsel:' });
42
28
 
43
29
  interface SelectionCell<U> {
44
30
  hasValue: boolean;