@helipod/client 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/README.md +42 -0
- package/package.json +9 -9
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# @helipod/client
|
|
2
|
+
|
|
3
|
+
The framework-agnostic Helipod client SDK: `HelipodClient` over a reactive WebSocket connection, with React bindings (`useQuery`/`useMutation`/`useAction`) at the `@helipod/client/react` subpath.
|
|
4
|
+
|
|
5
|
+
Most users should install the umbrella package [`helipod`](https://www.npmjs.com/package/helipod) instead — it re-exports this package, and the React hooks are available there as `helipod/react`.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
bun add helipod # or: npm install helipod
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { HelipodClient, webSocketTransport } from "@helipod/client";
|
|
15
|
+
import { HelipodProvider, useQuery, useMutation } from "@helipod/client/react";
|
|
16
|
+
import { api } from "../helipod/_generated/api";
|
|
17
|
+
|
|
18
|
+
const client = new HelipodClient(webSocketTransport("ws://localhost:3210/api/sync"));
|
|
19
|
+
|
|
20
|
+
function Chat() {
|
|
21
|
+
const messages = useQuery(api.messages.list, { conversationId });
|
|
22
|
+
const send = useMutation(api.messages.send);
|
|
23
|
+
// `messages` re-renders automatically whenever a mutation changes the data it reads.
|
|
24
|
+
return <button onClick={() => send({ conversationId, body: "hi" })}>Send</button>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// <HelipodProvider client={client}><Chat /></HelipodProvider>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
|
|
32
|
+
- Live queries: subscribe once, get pushed updates whenever a committed write intersects the query's read set — no polling.
|
|
33
|
+
- Typed end-to-end: function references from your app's generated `api` carry argument and return types into `useQuery`/`useMutation`/`useAction`.
|
|
34
|
+
- Optimistic updates: `useMutation(ref).withOptimisticUpdate((store, args) => ...)` for instant local UI with exact rollback and flicker-free reconciliation.
|
|
35
|
+
- Durable offline outbox (opt-in): `indexedDBOutbox()` in the browser, `fsOutbox()` (via `@helipod/client/outbox-fs`) for Node/Electron/Tauri, `memoryOutbox()` for tests — queued mutations survive reloads and drain exactly once on reconnect, with `usePendingMutations()` for status UI and `drainOutboxOnce()` for Service Worker Background Sync.
|
|
36
|
+
- Client-minted ids: `mintId` from your app's `_generated/ids` lets offline code create a document and reference it in a later queued mutation without waiting for the server.
|
|
37
|
+
- Auth session management: `createAuthClient` handles token rotation, refresh scheduling, and cross-tab session broadcast over a `HelipodClient`.
|
|
38
|
+
- Automatic reconnection with resubscribe, auth replay, and bandwidth-saving resume for unchanged query results.
|
|
39
|
+
|
|
40
|
+
Part of [Helipod](https://github.com/helipod-sh/helipod) — docs at https://helipod-six.vercel.app/docs
|
|
41
|
+
|
|
42
|
+
License: FSL-1.1-Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helipod/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "FSL-1.1-Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -39,16 +39,16 @@
|
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@helipod/id-codec": "0.1.
|
|
43
|
-
"@helipod/index-key-codec": "0.1.
|
|
44
|
-
"@helipod/sync": "0.1.
|
|
45
|
-
"@helipod/values": "0.1.
|
|
42
|
+
"@helipod/id-codec": "0.1.2",
|
|
43
|
+
"@helipod/index-key-codec": "0.1.2",
|
|
44
|
+
"@helipod/sync": "0.1.2",
|
|
45
|
+
"@helipod/values": "0.1.2"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@helipod/docstore-sqlite": "0.1.
|
|
49
|
-
"@helipod/executor": "0.1.
|
|
50
|
-
"@helipod/query-engine": "0.1.
|
|
51
|
-
"@helipod/runtime-embedded": "0.1.
|
|
48
|
+
"@helipod/docstore-sqlite": "0.1.2",
|
|
49
|
+
"@helipod/executor": "0.1.2",
|
|
50
|
+
"@helipod/query-engine": "0.1.2",
|
|
51
|
+
"@helipod/runtime-embedded": "0.1.2",
|
|
52
52
|
"@testing-library/react": "^16.1.0",
|
|
53
53
|
"@types/node": "^22.10.5",
|
|
54
54
|
"@types/react": "^18.3.18",
|