@syncular/tauri 0.15.48 → 0.16.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 CHANGED
@@ -8,6 +8,22 @@ Install the bridge together with its required Tauri JavaScript API peer:
8
8
  bun add @syncular/tauri @tauri-apps/api
9
9
  ```
10
10
 
11
+ The bridge works with any frontend framework. Generate the schema module using
12
+ the [existing-project setup](https://syncular.dev/guide-schema/#add-syncular-to-an-existing-project),
13
+ then create one shared client in the webview:
14
+
15
+ ```ts
16
+ // src/sync.ts
17
+ import { createTauriSyncClient } from '@syncular/tauri';
18
+ import { schema } from './syncular.generated';
19
+
20
+ export const client = await createTauriSyncClient({ schema });
21
+ ```
22
+
23
+ Register the native plugin as described in the
24
+ [Tauri guide](https://syncular.dev/platform-tauri/). React apps can separately
25
+ install `@syncular/react` for hooks over the same client.
26
+
11
27
  Reactive snapshots use the plugin's independent read-only SQLite path, so
12
28
  local Tauri views remain responsive while the native client is syncing over
13
29
  HTTP/WebSocket. Mutations, sync, and all durable writes remain serialized on
@@ -148,3 +164,9 @@ See the [Syncular repository](https://github.com/syncular/syncular) for docs.
148
164
  ## License
149
165
 
150
166
  Apache-2.0
167
+
168
+ The snapshot API revision removes the individual `schemaFloor`, `leaseState`,
169
+ `upgrading`, and `syncNeeded` methods. Read those fields from
170
+ `await client.statusSnapshot()`. Collection and outcome reads remain methods.
171
+ React accepts the bridge directly. See the
172
+ [client migration](https://syncular.dev/platform-web/#snapshot-api-migration).
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { ClientSnapshotMethods, PromiseMethods } from '@syncular/client';
1
2
  /**
2
3
  * @syncular/tauri — the JS bridge to the native syncular instance running
3
4
  * inside the Tauri process (see `tauri-plugin-syncular`).
@@ -26,7 +27,7 @@
26
27
  * `invoke`/`listen` either from its ESM entry points, from the ambient
27
28
  * `window.__TAURI__`, or via injected doubles (tests).
28
29
  */
29
- import type { ClientChangeListener, ClientDiagnosticsListener, ClientDiagnosticsRequest, ClientDiagnosticsSnapshot, CommitOutcome, CommitOutcomeQuery, ConflictRecord, EncryptionKeyringConfig, InvalidationListener, LeaseState, LocalDataPurgeInput, LocalDataPurgeResult, LocalDataRebootstrapInput, LocalDataRebootstrapResult, MutationInput, PresencePeer, QueryReadSpec, QuerySnapshot, RejectionRecord, ResolveCommitOutcomeInput, SchemaFloor, SecurityLifecycle, SqlRow, SqlValue, SyncStatusSnapshot, WindowBase, WindowState } from '@syncular/client';
30
+ import type { ClientChangeListener, ClientDiagnosticsListener, ClientDiagnosticsRequest, ClientDiagnosticsSnapshot, CommitOutcome, CommitOutcomeQuery, ConflictRecord, EncryptionKeyringConfig, InvalidationListener, LocalDataPurgeInput, LocalDataPurgeResult, LocalDataRebootstrapInput, LocalDataRebootstrapResult, MutationInput, PresencePeer, QueryReadSpec, QuerySnapshot, RejectionRecord, ResolveCommitOutcomeInput, SecurityLifecycle, SqlRow, SqlValue, SyncStatusSnapshot, WindowBase, WindowState } from '@syncular/client';
30
31
  /** One event pushed on `syncular://event` (the derived client-observable set). */
31
32
  interface SyncularEvent {
32
33
  readonly type: string;
@@ -73,10 +74,10 @@ export type BytesEnvelope = {
73
74
  };
74
75
  /**
75
76
  * The webview-side proxy implementing `SyncClientLike` over the plugin. Every
76
- * method is a promise (an IPC round trip); the React `normalizeClient` already
77
- * wraps sync and async members uniformly, so the hooks accept it directly.
77
+ * snapshot method returns a promise from an IPC round trip. React hooks accept
78
+ * the canonical snapshot interface directly.
78
79
  */
79
- export declare class TauriSyncClient {
80
+ export declare class TauriSyncClient implements PromiseMethods<ClientSnapshotMethods> {
80
81
  #private;
81
82
  /** @internal — use {@link createTauriSyncClient}. */
82
83
  constructor(tauri: TauriApi, unlisten: () => void, securityLifecycle?: SecurityLifecycle);
@@ -144,10 +145,6 @@ export declare class TauriSyncClient {
144
145
  commitOutcome(clientCommitId: string): Promise<CommitOutcome | undefined>;
145
146
  commitOutcomes(query?: CommitOutcomeQuery): Promise<readonly CommitOutcome[]>;
146
147
  resolveCommitOutcome(input: ResolveCommitOutcomeInput): Promise<CommitOutcome>;
147
- schemaFloor(): Promise<SchemaFloor | undefined>;
148
- leaseState(): Promise<LeaseState | undefined>;
149
- upgrading(): Promise<boolean>;
150
- syncNeeded(): Promise<boolean>;
151
148
  pendingCommits(): Promise<unknown[]>;
152
149
  presence(scopeKey: string): Promise<readonly PresencePeer[]>;
153
150
  setPresence(scopeKey: string, doc: Record<string, unknown> | null): Promise<void>;
package/dist/index.js CHANGED
@@ -1,31 +1,3 @@
1
- /**
2
- * @syncular/tauri — the JS bridge to the native syncular instance running
3
- * inside the Tauri process (see `tauri-plugin-syncular`).
4
- *
5
- * The Tauri host runs a REAL Rust syncular client (file DB + native HTTP+WS
6
- * transport). This module is a thin webview-side proxy that implements the SAME
7
- * `SyncClientLike` interface the React package normalizes — so the hooks
8
- * (`useRawSql`, `useMutation`, `usePresence`, …) work UNCHANGED against a
9
- * Tauri app. It is the fourth host of one interface, after the direct
10
- * `SyncClient`, the worker-leader `SyncClientHandle`, and the multi-tab
11
- * follower.
12
- *
13
- * Every method forwards to the plugin's `syncular_command` command (the whole
14
- * command surface in one JSON envelope — `{method, params}`), mirroring the FFI
15
- * and the conformance shim. `query` uses the dedicated `syncular_query` fast
16
- * path; atomic reactive reads use `syncular_query_snapshot`, backed by an
17
- * independent read-only SQLite connection so network sync cannot stall local
18
- * UI reads. Client-observable
19
- * events (`change` / `presence`) arrive on
20
- * the `syncular://event` Tauri event and fan out to the registered listeners.
21
- *
22
- * Bytes cross the command JSON as the established `{$bytes: hex}` envelope, the
23
- * same convention the Rust command router and the driver protocol use.
24
- *
25
- * `@tauri-apps/api` is a required peer dependency: the bridge takes
26
- * `invoke`/`listen` either from its ESM entry points, from the ambient
27
- * `window.__TAURI__`, or via injected doubles (tests).
28
- */
29
1
  // -- Types the bridge speaks (structurally the web-client's) -----------------
30
2
  // Most imports stay type-only; the stable preflight error code is shared at
31
3
  // runtime so every host surfaces byte-identical policy evidence.
@@ -145,8 +117,8 @@ async function resolveTauri(injected) {
145
117
  }
146
118
  /**
147
119
  * The webview-side proxy implementing `SyncClientLike` over the plugin. Every
148
- * method is a promise (an IPC round trip); the React `normalizeClient` already
149
- * wraps sync and async members uniformly, so the hooks accept it directly.
120
+ * snapshot method returns a promise from an IPC round trip. React hooks accept
121
+ * the canonical snapshot interface directly.
150
122
  */
151
123
  export class TauriSyncClient {
152
124
  #tauri;
@@ -522,22 +494,6 @@ export class TauriSyncClient {
522
494
  }));
523
495
  return result.outcome;
524
496
  }
525
- async schemaFloor() {
526
- const result = (await this.#command('schemaFloor', {}));
527
- return result.floor ?? undefined;
528
- }
529
- async leaseState() {
530
- const result = (await this.#command('leaseState', {}));
531
- return result.lease ?? undefined;
532
- }
533
- async upgrading() {
534
- const result = (await this.#command('upgrading', {}));
535
- return result.value;
536
- }
537
- async syncNeeded() {
538
- const result = (await this.#command('syncNeeded', {}));
539
- return result.value;
540
- }
541
497
  async pendingCommits() {
542
498
  const result = (await this.#command('pendingCommitIds', {}));
543
499
  return result.ids;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncular/tauri",
3
- "version": "0.15.48",
3
+ "version": "0.16.1",
4
4
  "description": "Tauri integration for the Syncular client",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Benjamin Kniffler",
@@ -48,12 +48,12 @@
48
48
  "test": "bun test"
49
49
  },
50
50
  "dependencies": {
51
- "@syncular/client": "0.15.48"
51
+ "@syncular/client": "0.16.1"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@tauri-apps/api": ">=2.0.0"
55
55
  },
56
56
  "devDependencies": {
57
- "@syncular/react": "0.15.48"
57
+ "@syncular/react": "0.16.1"
58
58
  }
59
59
  }
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { ClientSnapshotMethods, PromiseMethods } from '@syncular/client';
1
2
  /**
2
3
  * @syncular/tauri — the JS bridge to the native syncular instance running
3
4
  * inside the Tauri process (see `tauri-plugin-syncular`).
@@ -39,7 +40,6 @@ import type {
39
40
  EncryptionKeyringConfig,
40
41
  InvalidationEvent,
41
42
  InvalidationListener,
42
- LeaseState,
43
43
  LocalDataPurgeInput,
44
44
  LocalDataPurgeResult,
45
45
  LocalDataRebootstrapInput,
@@ -50,7 +50,6 @@ import type {
50
50
  QuerySnapshot,
51
51
  RejectionRecord,
52
52
  ResolveCommitOutcomeInput,
53
- SchemaFloor,
54
53
  SecurityLifecycle,
55
54
  SqlRow,
56
55
  SqlValue,
@@ -252,10 +251,10 @@ async function resolveTauri(injected: TauriApi | undefined): Promise<TauriApi> {
252
251
 
253
252
  /**
254
253
  * The webview-side proxy implementing `SyncClientLike` over the plugin. Every
255
- * method is a promise (an IPC round trip); the React `normalizeClient` already
256
- * wraps sync and async members uniformly, so the hooks accept it directly.
254
+ * snapshot method returns a promise from an IPC round trip. React hooks accept
255
+ * the canonical snapshot interface directly.
257
256
  */
258
- export class TauriSyncClient {
257
+ export class TauriSyncClient implements PromiseMethods<ClientSnapshotMethods> {
259
258
  readonly #tauri: TauriApi;
260
259
  readonly #invalidationListeners = new Set<InvalidationListener>();
261
260
  readonly #changeListeners = new Set<ClientChangeListener>();
@@ -763,32 +762,6 @@ export class TauriSyncClient {
763
762
  return result.outcome;
764
763
  }
765
764
 
766
- async schemaFloor(): Promise<SchemaFloor | undefined> {
767
- const result = (await this.#command('schemaFloor', {})) as {
768
- floor?: SchemaFloor;
769
- };
770
- return result.floor ?? undefined;
771
- }
772
-
773
- async leaseState(): Promise<LeaseState | undefined> {
774
- const result = (await this.#command('leaseState', {})) as {
775
- lease?: LeaseState;
776
- };
777
- return result.lease ?? undefined;
778
- }
779
-
780
- async upgrading(): Promise<boolean> {
781
- const result = (await this.#command('upgrading', {})) as { value: boolean };
782
- return result.value;
783
- }
784
-
785
- async syncNeeded(): Promise<boolean> {
786
- const result = (await this.#command('syncNeeded', {})) as {
787
- value: boolean;
788
- };
789
- return result.value;
790
- }
791
-
792
765
  async pendingCommits(): Promise<unknown[]> {
793
766
  const result = (await this.#command('pendingCommitIds', {})) as {
794
767
  ids: string[];