@syncular/client 0.60.0 → 0.60.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/dist/http.js CHANGED
@@ -182,7 +182,15 @@ async function readBody(response, onProgress, maxBytes) {
182
182
  }
183
183
  if (received !== reported)
184
184
  onProgress?.(received);
185
- return new Uint8Array(await new Blob(chunks).arrayBuffer());
185
+ // One allocation of the body's size. A Blob of the chunks and its
186
+ // arrayBuffer() kept one more full copy resident until garbage collection.
187
+ const bytes = new Uint8Array(received);
188
+ let offset = 0;
189
+ for (const chunk of chunks) {
190
+ bytes.set(chunk, offset);
191
+ offset += chunk.byteLength;
192
+ }
193
+ return bytes;
186
194
  }
187
195
  export function httpSegmentDownloader(segmentsBaseUrl, options) {
188
196
  const doFetch = options?.fetch ?? fetch;
@@ -597,9 +597,18 @@ async function startWorkerCore(options) {
597
597
  config: initConfig,
598
598
  });
599
599
  });
600
- // A config callback is a consumer from the first round.
601
- if (config.onDiagnostics !== undefined)
602
- await invoke('diagnosticsSnapshot', []);
600
+ // A config callback is a consumer from the first round. Under security
601
+ // preflight the core refuses the snapshot after the pull registered the
602
+ // worker as a push source, and activateSecurity() emits the first one.
603
+ if (config.onDiagnostics !== undefined) {
604
+ await invoke('diagnosticsSnapshot', []).catch((error) => {
605
+ if (config.securityPreflight !== true ||
606
+ !(error instanceof ClientSyncError) ||
607
+ error.code !== 'client.security_preflight_required') {
608
+ throw error;
609
+ }
610
+ });
611
+ }
603
612
  return {
604
613
  clientId: initResult.clientId,
605
614
  invoke,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncular/client",
3
- "version": "0.60.0",
3
+ "version": "0.60.1",
4
4
  "description": "Syncular TypeScript client core — offline-first sync over SQLite (WASM/OPFS, Bun, Node)",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Benjamin Kniffler",
@@ -113,11 +113,11 @@
113
113
  },
114
114
  "dependencies": {
115
115
  "@sqlite.org/sqlite-wasm": "^3.53.0-build1",
116
- "@syncular/core": "0.60.0"
116
+ "@syncular/core": "0.60.1"
117
117
  },
118
118
  "devDependencies": {
119
119
  "@electric-sql/pglite": "^0.5.4",
120
- "@syncular/server": "0.60.0",
120
+ "@syncular/server": "0.60.1",
121
121
  "playwright": "1.63.0",
122
122
  "vite": "8.3.4"
123
123
  }
package/src/http.ts CHANGED
@@ -273,7 +273,15 @@ async function readBody(
273
273
  }
274
274
  }
275
275
  if (received !== reported) onProgress?.(received);
276
- return new Uint8Array(await new Blob(chunks).arrayBuffer());
276
+ // One allocation of the body's size. A Blob of the chunks and its
277
+ // arrayBuffer() kept one more full copy resident until garbage collection.
278
+ const bytes = new Uint8Array(received);
279
+ let offset = 0;
280
+ for (const chunk of chunks) {
281
+ bytes.set(chunk, offset);
282
+ offset += chunk.byteLength;
283
+ }
284
+ return bytes;
277
285
  }
278
286
 
279
287
  export function httpSegmentDownloader(
@@ -998,9 +998,20 @@ async function startWorkerCore(options: {
998
998
  } as MainToWorkerMessage);
999
999
  },
1000
1000
  );
1001
- // A config callback is a consumer from the first round.
1002
- if (config.onDiagnostics !== undefined)
1003
- await invoke('diagnosticsSnapshot', []);
1001
+ // A config callback is a consumer from the first round. Under security
1002
+ // preflight the core refuses the snapshot after the pull registered the
1003
+ // worker as a push source, and activateSecurity() emits the first one.
1004
+ if (config.onDiagnostics !== undefined) {
1005
+ await invoke('diagnosticsSnapshot', []).catch((error: unknown) => {
1006
+ if (
1007
+ config.securityPreflight !== true ||
1008
+ !(error instanceof ClientSyncError) ||
1009
+ error.code !== 'client.security_preflight_required'
1010
+ ) {
1011
+ throw error;
1012
+ }
1013
+ });
1014
+ }
1004
1015
  return {
1005
1016
  clientId: initResult.clientId,
1006
1017
  invoke,