@catalyst-cloud/sdk 0.8.18 → 0.8.20
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 +10 -27
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -129,10 +129,7 @@ Requires a platform `WebSocket` (browser, Bun, or Node ≥22). On older Node, in
|
|
|
129
129
|
|
|
130
130
|
### Browser — managed OPFS replica (`/browser`)
|
|
131
131
|
|
|
132
|
-
`BrowserReplica` is the browser twin of `/node`'s `CatalystReplica`: an OPFS-persisted SQLite replica
|
|
133
|
-
in a dedicated Web Worker, seeded from `/snapshot` in bounded streamed batches, kept live off the same
|
|
134
|
-
change feed, and read through the same `@catalyst-cloud/read-model` views — no hand-written worker,
|
|
135
|
-
apply, or seeding code in your app.
|
|
132
|
+
`BrowserReplica` is the browser twin of `/node`'s `CatalystReplica`: an OPFS-persisted SQLite replica in a dedicated Web Worker, seeded from `/snapshot` in bounded streamed batches, kept live off the same change feed, and read through the same `@catalyst-cloud/read-model` views — no hand-written worker, apply, or seeding code in your app.
|
|
136
133
|
|
|
137
134
|
```ts
|
|
138
135
|
import {
|
|
@@ -175,32 +172,20 @@ if (isBrowserReplicaSupported()) {
|
|
|
175
172
|
}
|
|
176
173
|
```
|
|
177
174
|
|
|
178
|
-
`status` above is whatever your `onStatus` handler last recorded. `start()` REJECTS if the boot fails
|
|
179
|
-
(bad origin, missing worker chunk, OPFS unavailable) — it does not resolve into a broken state, so a
|
|
180
|
-
`try`/`catch` around it is where you surface the error to the user.
|
|
175
|
+
`status` above is whatever your `onStatus` handler last recorded. `start()` REJECTS if the boot fails (bad origin, missing worker chunk, OPFS unavailable) — it does not resolve into a broken state, so a `try`/`catch` around it is where you surface the error to the user.
|
|
181
176
|
|
|
182
177
|
Built in, because browsers need them:
|
|
183
178
|
|
|
184
|
-
- **Single-owner election** (Web Locks): OPFS SAHPool is single-connection-per-origin, so exactly one
|
|
185
|
-
|
|
186
|
-
should read via its normal fetch path.
|
|
187
|
-
- **Backpressure**: live deltas are coalesced into batched, single-flight applies with a bounded
|
|
188
|
-
buffer; a backlog too deep to replay escalates to a fresh snapshot instead of growing.
|
|
179
|
+
- **Single-owner election** (Web Locks): OPFS SAHPool is single-connection-per-origin, so exactly one tab boots the replica; every other tab gets status `"secondary"` (a clean state, not an error) and should read via its normal fetch path.
|
|
180
|
+
- **Backpressure**: live deltas are coalesced into batched, single-flight applies with a bounded buffer; a backlog too deep to replay escalates to a fresh snapshot instead of growing.
|
|
189
181
|
|
|
190
|
-
**Peer dependency**: install [`@sqlite.org/sqlite-wasm`](https://www.npmjs.com/package/@sqlite.org/sqlite-wasm)
|
|
191
|
-
yourself — the SDK never bundles the wasm.
|
|
182
|
+
**Peer dependency**: install [`@sqlite.org/sqlite-wasm`](https://www.npmjs.com/package/@sqlite.org/sqlite-wasm) yourself — the SDK never bundles the wasm.
|
|
192
183
|
|
|
193
|
-
**Bundlers**: the worker is created with `new Worker(new URL("./db.worker.js", import.meta.url),
|
|
194
|
-
{ type: "module" })`, which Vite, webpack 5, and Rollup detect statically and split into its own chunk
|
|
195
|
-
(nothing wasm-related touches your main bundle; `/node` consumers never see it at all). Notes:
|
|
184
|
+
**Bundlers**: the worker is created with `new Worker(new URL("./db.worker.js", import.meta.url), { type: "module" })`, which Vite, webpack 5, and Rollup detect statically and split into its own chunk (nothing wasm-related touches your main bundle; `/node` consumers never see it at all). Notes:
|
|
196
185
|
|
|
197
|
-
- **Vite**: works out of the box in `build`. In dev, if pre-bundling interferes with the worker URL,
|
|
198
|
-
|
|
199
|
-
- **
|
|
200
|
-
worker support in your config, e.g. `@surma/rollup-plugin-off-main-thread` or equivalent).
|
|
201
|
-
- **Exotic bundlers**: pass `createWorker` in `BrowserReplicaOptions` and construct the worker
|
|
202
|
-
however your toolchain requires. The worker module is published at the dedicated subpath
|
|
203
|
-
**`@catalyst-cloud/sdk/browser/db-worker`** — that specifier is the supported entry point:
|
|
186
|
+
- **Vite**: works out of the box in `build`. In dev, if pre-bundling interferes with the worker URL, add `optimizeDeps: { exclude: ["@catalyst-cloud/sdk"] }`.
|
|
187
|
+
- **webpack 5 / Rollup**: the `new Worker(new URL(...))` syntax is supported natively (Rollup needs worker support in your config, e.g. `@surma/rollup-plugin-off-main-thread` or equivalent).
|
|
188
|
+
- **Exotic bundlers**: pass `createWorker` in `BrowserReplicaOptions` and construct the worker however your toolchain requires. The worker module is published at the dedicated subpath **`@catalyst-cloud/sdk/browser/db-worker`** — that specifier is the supported entry point:
|
|
204
189
|
|
|
205
190
|
```ts
|
|
206
191
|
// Vite
|
|
@@ -215,9 +200,7 @@ yourself — the SDK never bundles the wasm.
|
|
|
215
200
|
);
|
|
216
201
|
```
|
|
217
202
|
|
|
218
|
-
The worker is a **side-effect module** (it registers a message handler and exports nothing), so it
|
|
219
|
-
is listed in the package's `sideEffects` array — do not configure your bundler to tree-shake it, or
|
|
220
|
-
it will load and register nothing and every replica call will hang.
|
|
203
|
+
The worker is a **side-effect module** (it registers a message handler and exports nothing), so it is listed in the package's `sideEffects` array — do not configure your bundler to tree-shake it, or it will load and register nothing and every replica call will hang.
|
|
221
204
|
|
|
222
205
|
## API
|
|
223
206
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@catalyst-cloud/sdk",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.20",
|
|
4
4
|
"description": "Keep a live local copy of your Linear and GitHub project data \u2014 pushed in real time, without polling rate limits or webhook tunnels.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Coalesce Labs",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@catalyst-cloud/read-model": "^0.1.0",
|
|
82
|
-
"@catalyst-cloud/replicate": "0.1.
|
|
83
|
-
"@catalyst-cloud/schema": "0.1.
|
|
82
|
+
"@catalyst-cloud/replicate": "0.1.17",
|
|
83
|
+
"@catalyst-cloud/schema": "0.1.23"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"@opentelemetry/api": ">=1.3.0 <2",
|