@massalabs/gossip-sdk 0.0.2-dev.20260408121232 → 0.0.2-dev.20260409113004

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.
@@ -53,8 +53,19 @@ async function handleMessage(e) {
53
53
  case 'init': {
54
54
  const { dbPath, wasmUrl, initSql, useOPFS } = e.data;
55
55
  const moduleArg = {};
56
- if (wasmUrl)
57
- moduleArg.locateFile = () => wasmUrl;
56
+ // Pre-fetch WASM as ArrayBuffer and override instantiateWasm
57
+ // so Emscripten never calls instantiateStreaming (Safari chokes
58
+ // on chunked Transfer-Encoding).
59
+ if (wasmUrl) {
60
+ const resp = await fetch(wasmUrl);
61
+ const bytes = await resp.arrayBuffer();
62
+ moduleArg.instantiateWasm = (imports, successCallback) => {
63
+ WebAssembly.instantiate(bytes, imports).then(result => {
64
+ successCallback(result.instance, result.module);
65
+ });
66
+ return {};
67
+ };
68
+ }
58
69
  // Load the right WASM build + VFS.
59
70
  // NOTE: import() paths must be string literals — Vite can't resolve variables.
60
71
  if (useOPFS) {
@@ -7,6 +7,8 @@
7
7
  * - Node.js / Jiti: init(bytes) with WASM bytes read from the filesystem
8
8
  */
9
9
  import { init } from './bindings.js';
10
+ import gossipWasmUrl from '../assets/generated/wasm/gossip_wasm_bg.wasm?url';
11
+ const WASM_PATH = '../assets/generated/wasm/gossip_wasm_bg.wasm';
10
12
  /**
11
13
  * WASM Initialization State
12
14
  */
@@ -47,13 +49,16 @@ export async function initializeWasm() {
47
49
  const url = await import('node:url');
48
50
  const path = await import('node:path');
49
51
  const currentDir = path.dirname(url.fileURLToPath(import.meta.url));
50
- const wasmPath = path.resolve(currentDir, '../assets/generated/wasm/gossip_wasm_bg.wasm');
52
+ const wasmPath = path.resolve(currentDir, WASM_PATH);
51
53
  const wasmBytes = fs.readFileSync(wasmPath);
52
54
  await init(wasmBytes);
53
55
  }
54
56
  else {
55
- // Browser: use default loading (import.meta.url + fetch internally)
56
- await init();
57
+ // Pre-fetch as ArrayBuffer so Safari doesn't choke on
58
+ // chunked Transfer-Encoding during instantiateStreaming.
59
+ const resp = await fetch(gossipWasmUrl);
60
+ const wasmBytes = await resp.arrayBuffer();
61
+ await init(wasmBytes);
57
62
  }
58
63
  isInitialized = true;
59
64
  isInitializing = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massalabs/gossip-sdk",
3
- "version": "0.0.2-dev.20260408121232",
3
+ "version": "0.0.2-dev.20260409113004",
4
4
  "description": "Gossip SDK for automation, chatbot, and integration use cases",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",