@tinkered/react 0.20.1 → 0.21.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.
package/dist/index.d.mts CHANGED
@@ -67,6 +67,10 @@ export declare function useData<T>(view: Data.View<T>): T;
67
67
  * `useData(tasks.where({ project }))` (ADR 0136). It re-renders only when that part changes; a
68
68
  * new key leaves the old part. Read-only: write through an op. */
69
69
  export declare function useData<T>(read: Data.Read<T>): T;
70
+ /** Reactively read a derived (ADR 0150): `useData(prView({ viewer, mode }))`, or the bare unit
71
+ * when it needs no config. Every reader of the same config shares one entry; a new config leaves
72
+ * the old one. */
73
+ export declare function useData<T>(read: Data.Derived<T>): T;
70
74
  /** Reactively read a slice of a capsule's cell export. */
71
75
  export declare function useData<T, S>(view: Data.View<T>, selector: (value: T) => S, isEqual?: (a: S, b: S) => boolean): S;
72
76
  /** Reactively read a slice of a `data` cell: returns `selector(value)` and re-renders only when the
package/dist/index.mjs CHANGED
@@ -204,17 +204,16 @@ function useHeld() {
204
204
  store: void 0
205
205
  };
206
206
  }
207
- /** A capsule's cell export: a read edge (ADR 0123). */
207
+ /** A read edge: it has a `kind`, and a cell has none. */
208
208
  const isView = (target) => target.kind !== void 0;
209
209
  /** A writable pair only for a cell: a capsule's cell export answers the bare value. */
210
210
  function wantsPair(cell, options) {
211
211
  return options?.writable === true && !isView(cell);
212
212
  }
213
+ /** A cell reads through its controller; a view, a keyed read, and a derived read through the
214
+ * reader the scope resolves them to. */
213
215
  function readableOf(scope, cell) {
214
- if (!isView(cell)) return scope.controller(cell);
215
- if (cell.kind === "reader") return scope.resolve(cell);
216
- const keyed = scope.controller(cell.cell);
217
- return cell.read === "of" ? keyed.of(cell.part) : keyed.where(cell.part);
216
+ return isView(cell) ? scope.resolve(cell) : scope.controller(cell);
218
217
  }
219
218
  /** The raw store rides on its controller: a property read, not a hash lookup. */
220
219
  const RAW = Symbol("raw store");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinkered/react",
3
- "version": "0.20.1",
3
+ "version": "0.21.0",
4
4
  "description": "Tinkered React: a thin React adapter over @tinkered/core.",
5
5
  "keywords": [
6
6
  "tanstack-intent"
@@ -29,12 +29,12 @@
29
29
  "access": "public"
30
30
  },
31
31
  "dependencies": {
32
- "@tinkered/core": "^0.20.1"
32
+ "@tinkered/core": "^0.21.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@stryker-mutator/core": "^10.0.0",
36
36
  "@stryker-mutator/vitest-runner": "^10.0.0",
37
- "@tinkered/core": "^0.20.1",
37
+ "@tinkered/core": "^0.21.0",
38
38
  "@types/node": "^26.1.1",
39
39
  "@types/react": "^19",
40
40
  "@types/react-dom": "^19",
@@ -15,7 +15,7 @@ metadata:
15
15
  type: framework
16
16
  framework: react
17
17
  library: '@tinkered/react'
18
- library_version: '0.20.1'
18
+ library_version: '0.21.0'
19
19
  requires:
20
20
  - '@tinkered/core#core'
21
21
  sources:
@@ -110,6 +110,18 @@ const one = useData(
110
110
  );
111
111
  ```
112
112
 
113
+ ### A computed value with a stable reference
114
+
115
+ Use a Core `derived`, not `useMemo`. Pass its
116
+ config at each render. Every reader of the same
117
+ config gets the same value.
118
+
119
+ ```tsx no-check
120
+ const view = useData(
121
+ prView({ viewer: me.email, mode }),
122
+ );
123
+ ```
124
+
113
125
  ### State for one subtree
114
126
 
115
127
  `SessionProvider` opens a session for its