@atolljs/react 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.
Files changed (2) hide show
  1. package/README.md +51 -5
  2. package/package.json +8 -3
package/README.md CHANGED
@@ -1,9 +1,55 @@
1
1
  # @atolljs/react
2
2
 
3
- React bindings for `@atolljs/core` — framework adapter only, no domain code.
3
+ React bindings for `@atolljs/core` — hooks that bind shared-memory fields and
4
+ worker tasks to component state over `useSyncExternalStore`. SSR-safe: field
5
+ reads return `undefined` until the contract binds on the client.
4
6
 
5
- - `useObservable(source)` — subscribe to any `ObservableValue` via `useSyncExternalStore`.
6
- - `useSharedValue(memory, key)` — a shared-memory field as React state.
7
- - `useTask(task)` — an `AsyncTask` snapshot (`data`/`pending`/`settled`/`elapsedMs`/`error`) plus `run`/`runOnce`.
7
+ **[Atoll — package documentation](https://jwhenry3.github.io/atolljs/consumer/quickstart/)**
8
8
 
9
- The consuming app composes these with its own contracts and tasks.
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @atolljs/core @atolljs/react
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```tsx
18
+ import { useSharedValue, useTask } from '@atolljs/react';
19
+ import { counterMemory } from './counter.memory';
20
+ import { counter } from './counter';
21
+
22
+ export function App() {
23
+ const count = useSharedValue(counterMemory, 'count');
24
+ const increment = useTask(counter.increment); // client method → latest-wins task
25
+
26
+ return (
27
+ <button onClick={() => increment.run(1)}>
28
+ count: {count ?? '…'}
29
+ </button>
30
+ );
31
+ }
32
+ ```
33
+
34
+ ## API
35
+
36
+ - `useObservable(source)` — subscribe to any `ObservableValue` snapshot (task or field).
37
+ - `useSharedValue(memory, key, select?, options?)` — bind one shared-memory
38
+ field to React state; optional selector + `equals` slice updates so a
39
+ component re-renders only when its slice changes.
40
+ - `useTask(task | asyncFn)` — bind an `AsyncTask` (or any async fn, e.g. a
41
+ `connectWorker` client method) to `{ data, pending, settled, elapsedMs,
42
+ error }` plus `run`/`runOnce` triggers.
43
+
44
+ ## Notes
45
+
46
+ - `counter.increment` is typed from the worker's `defineWorker` methods — no
47
+ task contract to declare.
48
+ - Worker-hosted React trees (islands) live in the companion package
49
+ [`@atolljs/react-island`](../react-island).
50
+
51
+ ## Documentation
52
+
53
+ - [Atoll — package documentation](https://jwhenry3.github.io/atolljs/consumer/quickstart/)
54
+ - [React guide](https://jwhenry3.github.io/atolljs/consumer/fw-react/)
55
+ - [Worker islands for React](https://jwhenry3.github.io/atolljs/consumer/fw-react/worker-islands/)
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@atolljs/react",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "React bindings — useObservable, useSharedValue, useTask",
5
+ "homepage": "https://jwhenry3.github.io/atolljs/consumer/quickstart/",
5
6
  "type": "module",
6
7
  "exports": {
7
8
  ".": "./src/index.ts"
@@ -10,15 +11,19 @@
10
11
  "src"
11
12
  ],
12
13
  "publishConfig": {
13
- "access": "public"
14
+ "access": "public",
15
+ "registry": "https://registry.npmjs.org"
14
16
  },
15
17
  "peerDependencies": {
16
- "@atolljs/core": "0.1.0",
18
+ "@atolljs/core": "0.1.2",
17
19
  "react": "^19.3.0"
18
20
  },
19
21
  "repository": {
20
22
  "type": "git",
21
23
  "url": "https://github.com/jwhenry3/atolljs",
22
24
  "directory": "packages/react"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/jwhenry3/atolljs/issues"
23
28
  }
24
29
  }