zocket 0.0.1

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 ADDED
@@ -0,0 +1,29 @@
1
+ # zhub
2
+
3
+ Synchronize `orbz` instances between Anchors in different environments via Websockets.
4
+
5
+ This package exports adapters for `bun` and `web` (more later) to simplify synchronizing shared state between multiple sources.
6
+
7
+ ## Bun hub persistence
8
+
9
+ `createHub()` accepts Orbz Anchor persistence options and passes them through when it creates the hub anchor. For a one-file JSON store:
10
+
11
+ ```js
12
+ import { createHub, createJsonFilePersistence } from "zhub/bun"
13
+
14
+ const persist = createJsonFilePersistence(new URL("./hub-state.json", import.meta.url))
15
+ const hub = await createHub({ routes, shapes, persist })
16
+ ```
17
+
18
+ The JSON file stores route UUIDs and serialized Orb records in the same format the Anchor adapter reads back during hydration. For databases or split files, pass your own Anchor adapter instead:
19
+
20
+ ```js
21
+ const hub = await createHub({
22
+ routes,
23
+ shapes,
24
+ persist: {
25
+ adapter,
26
+ autosave: { intervalMs: 100 },
27
+ },
28
+ })
29
+ ```