@tearleads/client-sdk 0.1.98 → 0.1.99
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 +15 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,13 +24,20 @@ const tearleads = new Tearleads();
|
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
The minimal instance uses same-origin API routes, memory blob storage, default
|
|
27
|
-
logging, and an idle database.
|
|
28
|
-
or identity generation
|
|
27
|
+
logging, and an idle database. Initialize SQLite, then configure the SDK before
|
|
28
|
+
using persistence, sync, or identity generation. Here `localKeys` comes from the
|
|
29
|
+
host's [local keyring](https://github.com/a2f0/tearleads/blob/main/docs/developer/client-sdk.md#local-keyring):
|
|
29
30
|
|
|
30
31
|
```ts
|
|
31
32
|
import { createSQLiteRuntime } from "@tearleads/client-sdk/sqlite";
|
|
32
33
|
|
|
33
34
|
const sqliteRuntime = createSQLiteRuntime();
|
|
35
|
+
await sqliteRuntime.client.init({
|
|
36
|
+
dbName: "/app-identity.db",
|
|
37
|
+
cipher: "chacha20",
|
|
38
|
+
key: localKeys.sqliteKey,
|
|
39
|
+
persistence: "opfs-sahpool",
|
|
40
|
+
});
|
|
34
41
|
tearleads.database.configure({
|
|
35
42
|
client: sqliteRuntime.client,
|
|
36
43
|
id: sqliteRuntime.id,
|
|
@@ -53,8 +60,10 @@ for (const file of ["worker.js", "sqlite3.wasm", "sqlite3-licenses.md"]) {
|
|
|
53
60
|
}
|
|
54
61
|
```
|
|
55
62
|
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
SQLite defaults to `persistence: "memory"`, which loses the database on worker
|
|
64
|
+
restart or page reload. The example opts into `"opfs-sahpool"` to persist it in
|
|
65
|
+
the origin private file system (OPFS); serve the page from a secure context.
|
|
66
|
+
If OPFS is unavailable, initialization fails instead of falling back to memory.
|
|
58
67
|
|
|
59
68
|
Typecheck with `skipLibCheck: true`: the declarations of drizzle-orm and
|
|
60
69
|
loro-crdt, which the SDK's types reference, do not typecheck without it.
|
|
@@ -68,6 +77,8 @@ but cannot authorize replay of the old request.
|
|
|
68
77
|
The [developer guide](https://github.com/a2f0/tearleads/blob/main/docs/developer/client-sdk.md)
|
|
69
78
|
covers constructor options, the host contract, the local keyring, and every
|
|
70
79
|
public entry point.
|
|
80
|
+
For document editing and creation, start with the
|
|
81
|
+
[document creation guide](https://github.com/a2f0/tearleads/blob/main/docs/developer/document-creation.md).
|
|
71
82
|
|
|
72
83
|
## Publishing
|
|
73
84
|
|
package/package.json
CHANGED