@syncular/tauri 0.2.0 → 0.3.0
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/dist/index.d.ts +8 -1
- package/dist/index.js +18 -1
- package/package.json +4 -4
- package/src/index.ts +21 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* The Tauri host runs a REAL Rust syncular client (file DB + native HTTP+WS
|
|
6
6
|
* transport). This module is a thin webview-side proxy that implements the SAME
|
|
7
7
|
* `SyncClientLike` interface the React package normalizes — so the hooks
|
|
8
|
-
* (`
|
|
8
|
+
* (`useRawSql`, `useMutation`, `usePresence`, …) work UNCHANGED against a
|
|
9
9
|
* Tauri app. It is the fourth host of one interface, after the direct
|
|
10
10
|
* `SyncClient`, the worker-leader `SyncClientHandle`, and the multi-tab
|
|
11
11
|
* follower (ROADMAP.md block 1).
|
|
@@ -77,6 +77,13 @@ export declare class TauriSyncClient {
|
|
|
77
77
|
onPresence(listener: (scopeKey: string) => void): () => void;
|
|
78
78
|
query(sql: string, params?: readonly SqlValue[]): Promise<SqlRow[]>;
|
|
79
79
|
mutate(mutations: readonly MutationInput[]): Promise<string>;
|
|
80
|
+
/**
|
|
81
|
+
* Replace the native transport's request headers at runtime — the auth
|
|
82
|
+
* rotation path (RFC 0002 §2.3). Pass the FULL header set (it replaces,
|
|
83
|
+
* it does not merge). HTTP requests use the new set from the next call;
|
|
84
|
+
* the realtime socket applies it on its next (re)connect.
|
|
85
|
+
*/
|
|
86
|
+
setHeaders(headers: Readonly<Record<string, string>>): Promise<void>;
|
|
80
87
|
/** Materialize a `crdt` column's collaborative text — decoded from the
|
|
81
88
|
* stored (server-merged) Yjs bytes. `name` selects the shared text
|
|
82
89
|
* (default `"text"`). An absent row / NULL column is the empty document. */
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* The Tauri host runs a REAL Rust syncular client (file DB + native HTTP+WS
|
|
6
6
|
* transport). This module is a thin webview-side proxy that implements the SAME
|
|
7
7
|
* `SyncClientLike` interface the React package normalizes — so the hooks
|
|
8
|
-
* (`
|
|
8
|
+
* (`useRawSql`, `useMutation`, `usePresence`, …) work UNCHANGED against a
|
|
9
9
|
* Tauri app. It is the fourth host of one interface, after the direct
|
|
10
10
|
* `SyncClient`, the worker-leader `SyncClientHandle`, and the multi-tab
|
|
11
11
|
* follower (ROADMAP.md block 1).
|
|
@@ -72,6 +72,11 @@ function decodeCell(value) {
|
|
|
72
72
|
function decodeRow(row) {
|
|
73
73
|
const out = {};
|
|
74
74
|
for (const [key, value] of Object.entries(row)) {
|
|
75
|
+
// Reserved `_sync_*` columns stay engine-internal (parity with the
|
|
76
|
+
// web client's `query()`), so a `SELECT *` row round-trips straight
|
|
77
|
+
// into `mutate()` values. Alias (`_sync_version AS v`) to read one.
|
|
78
|
+
if (key.startsWith('_sync_'))
|
|
79
|
+
continue;
|
|
75
80
|
out[key] = decodeCell(value);
|
|
76
81
|
}
|
|
77
82
|
return out;
|
|
@@ -183,6 +188,18 @@ export class TauriSyncClient {
|
|
|
183
188
|
}));
|
|
184
189
|
return result.clientCommitId;
|
|
185
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* Replace the native transport's request headers at runtime — the auth
|
|
193
|
+
* rotation path (RFC 0002 §2.3). Pass the FULL header set (it replaces,
|
|
194
|
+
* it does not merge). HTTP requests use the new set from the next call;
|
|
195
|
+
* the realtime socket applies it on its next (re)connect.
|
|
196
|
+
*/
|
|
197
|
+
async setHeaders(headers) {
|
|
198
|
+
const reply = await this.#tauri.invoke(`${PLUGIN}syncular_set_headers`, { headers });
|
|
199
|
+
if (reply.error !== undefined) {
|
|
200
|
+
throw new TauriSyncError(reply.error.code, reply.error.message);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
186
203
|
// -- Native CRDT (SPEC.md §5.10.5; needs the plugin `crdt-yjs` feature) ------
|
|
187
204
|
/** Materialize a `crdt` column's collaborative text — decoded from the
|
|
188
205
|
* stored (server-merged) Yjs bytes. `name` selects the shared text
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncular/tauri",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Tauri integration for the Syncular client",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Benjamin Kniffler",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"exports": {
|
|
29
29
|
".": {
|
|
30
30
|
"bun": "./src/index.ts",
|
|
31
|
-
"browser": "./
|
|
31
|
+
"browser": "./dist/index.js",
|
|
32
32
|
"import": {
|
|
33
33
|
"types": "./dist/index.d.ts",
|
|
34
34
|
"default": "./dist/index.js"
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"test": "bun test"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@syncular/client": "0.2.
|
|
51
|
+
"@syncular/client": "0.2.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@tauri-apps/api": ">=2.0.0"
|
|
@@ -59,6 +59,6 @@
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@syncular/react": "0.2.
|
|
62
|
+
"@syncular/react": "0.2.1"
|
|
63
63
|
}
|
|
64
64
|
}
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* The Tauri host runs a REAL Rust syncular client (file DB + native HTTP+WS
|
|
6
6
|
* transport). This module is a thin webview-side proxy that implements the SAME
|
|
7
7
|
* `SyncClientLike` interface the React package normalizes — so the hooks
|
|
8
|
-
* (`
|
|
8
|
+
* (`useRawSql`, `useMutation`, `usePresence`, …) work UNCHANGED against a
|
|
9
9
|
* Tauri app. It is the fourth host of one interface, after the direct
|
|
10
10
|
* `SyncClient`, the worker-leader `SyncClientHandle`, and the multi-tab
|
|
11
11
|
* follower (ROADMAP.md block 1).
|
|
@@ -143,6 +143,10 @@ function decodeCell(value: unknown): SqlValue {
|
|
|
143
143
|
function decodeRow(row: Record<string, unknown>): SqlRow {
|
|
144
144
|
const out: SqlRow = {};
|
|
145
145
|
for (const [key, value] of Object.entries(row)) {
|
|
146
|
+
// Reserved `_sync_*` columns stay engine-internal (parity with the
|
|
147
|
+
// web client's `query()`), so a `SELECT *` row round-trips straight
|
|
148
|
+
// into `mutate()` values. Alias (`_sync_version AS v`) to read one.
|
|
149
|
+
if (key.startsWith('_sync_')) continue;
|
|
146
150
|
out[key] = decodeCell(value);
|
|
147
151
|
}
|
|
148
152
|
return out;
|
|
@@ -284,6 +288,22 @@ export class TauriSyncClient {
|
|
|
284
288
|
return result.clientCommitId;
|
|
285
289
|
}
|
|
286
290
|
|
|
291
|
+
/**
|
|
292
|
+
* Replace the native transport's request headers at runtime — the auth
|
|
293
|
+
* rotation path (RFC 0002 §2.3). Pass the FULL header set (it replaces,
|
|
294
|
+
* it does not merge). HTTP requests use the new set from the next call;
|
|
295
|
+
* the realtime socket applies it on its next (re)connect.
|
|
296
|
+
*/
|
|
297
|
+
async setHeaders(headers: Readonly<Record<string, string>>): Promise<void> {
|
|
298
|
+
const reply = await this.#tauri.invoke<CommandReply>(
|
|
299
|
+
`${PLUGIN}syncular_set_headers`,
|
|
300
|
+
{ headers },
|
|
301
|
+
);
|
|
302
|
+
if (reply.error !== undefined) {
|
|
303
|
+
throw new TauriSyncError(reply.error.code, reply.error.message);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
287
307
|
// -- Native CRDT (SPEC.md §5.10.5; needs the plugin `crdt-yjs` feature) ------
|
|
288
308
|
|
|
289
309
|
/** Materialize a `crdt` column's collaborative text — decoded from the
|