@syncular/tauri 0.67.3 → 0.69.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/remote.js CHANGED
@@ -6,9 +6,15 @@ export class TauriSyncError extends NativeSyncError {
6
6
  name = 'TauriSyncError';
7
7
  }
8
8
  /** Resolve the Tauri primitives from the ambient environment when not injected. */
9
- async function resolveTauri(injected) {
9
+ /** The page's Tauri API, resolved once so it identifies the native host. */
10
+ let pageTauri;
11
+ function resolveTauri(injected) {
10
12
  if (injected !== undefined)
11
- return injected;
13
+ return Promise.resolve(injected);
14
+ pageTauri ??= resolveAmbientTauri();
15
+ return pageTauri;
16
+ }
17
+ async function resolveAmbientTauri() {
12
18
  // Prefer the ambient global (present when `withGlobalTauri` is enabled).
13
19
  // Otherwise use the ESM package (the common path). The specifier must remain
14
20
  // literal and bundler-visible: hiding a bare package import behind
@@ -116,6 +122,6 @@ export async function createTauriSyncClient(config, createClient = (...args) =>
116
122
  client = opened;
117
123
  await opened.__open(() => tauri.invoke(`${PLUGIN}syncular_command`, {
118
124
  command: { method: 'create', params: { ...params, events } },
119
- }));
125
+ }), tauri);
120
126
  return opened;
121
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncular/tauri",
3
- "version": "0.67.3",
3
+ "version": "0.69.0",
4
4
  "description": "Tauri integration for the Syncular client",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Benjamin Kniffler",
@@ -64,13 +64,13 @@
64
64
  "test": "bun test"
65
65
  },
66
66
  "dependencies": {
67
- "@syncular/client": "0.67.3"
67
+ "@syncular/client": "0.69.0"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@tauri-apps/api": ">=2.0.0"
71
71
  },
72
72
  "devDependencies": {
73
- "@syncular/react": "0.67.3",
74
- "@syncular/server": "0.67.3"
73
+ "@syncular/react": "0.69.0",
74
+ "@syncular/server": "0.69.0"
75
75
  }
76
76
  }
package/src/remote.ts CHANGED
@@ -104,8 +104,16 @@ export class TauriSyncError extends NativeSyncError {
104
104
  }
105
105
 
106
106
  /** Resolve the Tauri primitives from the ambient environment when not injected. */
107
- async function resolveTauri(injected: TauriApi | undefined): Promise<TauriApi> {
108
- if (injected !== undefined) return injected;
107
+ /** The page's Tauri API, resolved once so it identifies the native host. */
108
+ let pageTauri: Promise<TauriApi> | undefined;
109
+
110
+ function resolveTauri(injected: TauriApi | undefined): Promise<TauriApi> {
111
+ if (injected !== undefined) return Promise.resolve(injected);
112
+ pageTauri ??= resolveAmbientTauri();
113
+ return pageTauri;
114
+ }
115
+
116
+ async function resolveAmbientTauri(): Promise<TauriApi> {
109
117
  // Prefer the ambient global (present when `withGlobalTauri` is enabled).
110
118
  // Otherwise use the ESM package (the common path). The specifier must remain
111
119
  // literal and bundler-visible: hiding a bare package import behind
@@ -266,10 +274,12 @@ export async function createTauriSyncClient(
266
274
  config.securityPreflight === true ? 'preflight' : 'active',
267
275
  );
268
276
  client = opened;
269
- await opened.__open(() =>
270
- tauri.invoke<NativeReply>(`${PLUGIN}syncular_command`, {
271
- command: { method: 'create', params: { ...params, events } },
272
- }),
277
+ await opened.__open(
278
+ () =>
279
+ tauri.invoke<NativeReply>(`${PLUGIN}syncular_command`, {
280
+ command: { method: 'create', params: { ...params, events } },
281
+ }),
282
+ tauri,
273
283
  );
274
284
  return opened;
275
285
  }