@automerge/subduction 0.8.0-alpha.1 → 0.9.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.
Files changed (32) hide show
  1. package/dist/cjs/wasm-base64.cjs +1 -1
  2. package/dist/cjs/web-bindings.cjs +308 -87
  3. package/dist/cjs/web.cjs +309 -88
  4. package/dist/esm/wasm-base64.js +1 -1
  5. package/dist/iife/index.js +309 -88
  6. package/dist/index.d.ts +87 -24
  7. package/dist/subduction.wasm +0 -0
  8. package/dist/wasm_bindgen/bundler/snippets/subduction_wasm-0ed7fd66cebca59f/inline0.js +9 -0
  9. package/dist/wasm_bindgen/bundler/subduction_wasm.d.ts +87 -24
  10. package/dist/wasm_bindgen/bundler/subduction_wasm_bg.js +294 -96
  11. package/dist/wasm_bindgen/bundler/subduction_wasm_bg.wasm +0 -0
  12. package/dist/wasm_bindgen/bundler/subduction_wasm_bg.wasm.d.ts +28 -20
  13. package/dist/wasm_bindgen/nodejs/snippets/subduction_wasm-0ed7fd66cebca59f/inline0.js +9 -0
  14. package/dist/wasm_bindgen/nodejs/subduction_wasm.cjs +296 -96
  15. package/dist/wasm_bindgen/nodejs/subduction_wasm.d.ts +87 -24
  16. package/dist/wasm_bindgen/nodejs/subduction_wasm_bg.wasm +0 -0
  17. package/dist/wasm_bindgen/nodejs/subduction_wasm_bg.wasm.d.ts +28 -20
  18. package/dist/wasm_bindgen/web/snippets/subduction_wasm-0ed7fd66cebca59f/inline0.js +9 -0
  19. package/dist/wasm_bindgen/web/subduction_wasm.d.ts +115 -44
  20. package/dist/wasm_bindgen/web/subduction_wasm.js +296 -96
  21. package/dist/wasm_bindgen/web/subduction_wasm_bg.wasm +0 -0
  22. package/dist/wasm_bindgen/web/subduction_wasm_bg.wasm.d.ts +28 -20
  23. package/package.json +1 -1
  24. /package/dist/wasm_bindgen/bundler/snippets/{sedimentree_wasm-68c0499598a3382c → sedimentree_wasm-1de4a01519b0f11f}/inline0.js +0 -0
  25. /package/dist/wasm_bindgen/bundler/snippets/{sedimentree_wasm-68c0499598a3382c → sedimentree_wasm-1de4a01519b0f11f}/inline1.js +0 -0
  26. /package/dist/wasm_bindgen/bundler/snippets/{sedimentree_wasm-68c0499598a3382c → sedimentree_wasm-1de4a01519b0f11f}/inline2.js +0 -0
  27. /package/dist/wasm_bindgen/nodejs/snippets/{sedimentree_wasm-68c0499598a3382c → sedimentree_wasm-1de4a01519b0f11f}/inline0.js +0 -0
  28. /package/dist/wasm_bindgen/nodejs/snippets/{sedimentree_wasm-68c0499598a3382c → sedimentree_wasm-1de4a01519b0f11f}/inline1.js +0 -0
  29. /package/dist/wasm_bindgen/nodejs/snippets/{sedimentree_wasm-68c0499598a3382c → sedimentree_wasm-1de4a01519b0f11f}/inline2.js +0 -0
  30. /package/dist/wasm_bindgen/web/snippets/{sedimentree_wasm-68c0499598a3382c → sedimentree_wasm-1de4a01519b0f11f}/inline0.js +0 -0
  31. /package/dist/wasm_bindgen/web/snippets/{sedimentree_wasm-68c0499598a3382c → sedimentree_wasm-1de4a01519b0f11f}/inline1.js +0 -0
  32. /package/dist/wasm_bindgen/web/snippets/{sedimentree_wasm-68c0499598a3382c → sedimentree_wasm-1de4a01519b0f11f}/inline2.js +0 -0
@@ -1,5 +1,5 @@
1
1
  /* @ts-self-types="./subduction_wasm.d.ts" */
2
- import { tryIntoJsSedimentreeIdsArray } from './snippets/sedimentree_wasm-68c0499598a3382c/inline2.js';
2
+ import { tryIntoJsSedimentreeIdsArray } from './snippets/sedimentree_wasm-1de4a01519b0f11f/inline2.js';
3
3
 
4
4
  /**
5
5
  * An authenticated HTTP long-poll transport.
@@ -74,23 +74,30 @@ if (Symbol.dispose) AuthenticatedLongPoll.prototype[Symbol.dispose] = Authentica
74
74
  * There are three ways to obtain an `AuthenticatedTransport`:
75
75
  *
76
76
  * 1. **Custom transport** — implement the `Transport` interface
77
- * (`sendBytes`/`recvBytes`/`disconnect`) and call [`setup`](Self::setup):
77
+ * (`sendBytes`/`recvBytes`/`disconnect`/`onDisconnect`) and call
78
+ * [`setup`](Self::setup):
78
79
  *
79
80
  * ```js
80
- * const auth = await AuthenticatedTransport.setup(myTransport, signer, peerId);
81
+ * const auth = await AuthenticatedTransport.setup(myTransport, signer, peerId, (peerId) => {
82
+ * console.log(`${peerId} disconnected`);
83
+ * });
81
84
  * ```
82
85
  *
83
86
  * 2. **From WebSocket** — authenticate via [`SubductionWebSocket`] then convert:
84
87
  *
85
88
  * ```js
86
- * const wsAuth = await SubductionWebSocket.tryConnect(url, signer, peerId, timeout);
89
+ * const wsAuth = await SubductionWebSocket.tryConnect(url, signer, peerId, (peerId) => {
90
+ * console.log(`${peerId} disconnected`);
91
+ * });
87
92
  * const auth = wsAuth.toTransport();
88
93
  * ```
89
94
  *
90
95
  * 3. **From HTTP long-poll** — same pattern via [`SubductionLongPoll`]:
91
96
  *
92
97
  * ```js
93
- * const lpAuth = await SubductionLongPoll.tryConnect(url, signer, peerId, timeout);
98
+ * const lpAuth = await SubductionLongPoll.tryConnect(url, signer, peerId, (peerId) => {
99
+ * console.log(`${peerId} disconnected`);
100
+ * });
94
101
  * const auth = lpAuth.toTransport();
95
102
  * ```
96
103
  */
@@ -120,7 +127,7 @@ export class AuthenticatedTransport {
120
127
  *
121
128
  * # Arguments
122
129
  *
123
- * * `transport` - A `Transport` implementing `sendBytes`/`recvBytes`/`disconnect`
130
+ * * `transport` - A `Transport` implementing `sendBytes`/`recvBytes`/`disconnect`/`onDisconnect`
124
131
  * * `signer` - The responder's signer for authentication
125
132
  * * `max_drift_seconds` - Maximum acceptable clock drift in seconds (default: 600)
126
133
  *
@@ -130,10 +137,11 @@ export class AuthenticatedTransport {
130
137
  * @param {Transport} transport
131
138
  * @param {any} signer
132
139
  * @param {number | null} [max_drift_seconds]
140
+ * @param {Function | null} [on_disconnect]
133
141
  * @returns {Promise<AuthenticatedTransport>}
134
142
  */
135
- static accept(transport, signer, max_drift_seconds) {
136
- const ret = wasm.authenticatedtransport_accept(transport, signer, isLikeNone(max_drift_seconds) ? 0x100000001 : (max_drift_seconds) >>> 0);
143
+ static accept(transport, signer, max_drift_seconds, on_disconnect) {
144
+ const ret = wasm.authenticatedtransport_accept(transport, signer, isLikeNone(max_drift_seconds) ? 0x100000001 : (max_drift_seconds) >>> 0, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
137
145
  return ret;
138
146
  }
139
147
  /**
@@ -149,13 +157,13 @@ export class AuthenticatedTransport {
149
157
  * authenticated transport.
150
158
  *
151
159
  * The `transport` object must implement the `Transport` interface
152
- * (`sendBytes`/`recvBytes`/`disconnect`).
160
+ * (`sendBytes`/`recvBytes`/`disconnect`/`onDisconnect`).
153
161
  * The same object is used for both the handshake phase and post-handshake
154
162
  * communication.
155
163
  *
156
164
  * # Arguments
157
165
  *
158
- * * `transport` - A `Transport` implementing `sendBytes`/`recvBytes`/`disconnect`
166
+ * * `transport` - A `Transport` implementing `sendBytes`/`recvBytes`/`disconnect`/`onDisconnect`
159
167
  * * `signer` - The client's signer for authentication
160
168
  * * `expected_peer_id` - The expected server peer ID (verified during handshake)
161
169
  *
@@ -165,11 +173,12 @@ export class AuthenticatedTransport {
165
173
  * @param {Transport} transport
166
174
  * @param {any} signer
167
175
  * @param {PeerId} expected_peer_id
176
+ * @param {Function | null} [on_disconnect]
168
177
  * @returns {Promise<AuthenticatedTransport>}
169
178
  */
170
- static setup(transport, signer, expected_peer_id) {
179
+ static setup(transport, signer, expected_peer_id, on_disconnect) {
171
180
  _assertClass(expected_peer_id, PeerId);
172
- const ret = wasm.authenticatedtransport_setup(transport, signer, expected_peer_id.__wbg_ptr);
181
+ const ret = wasm.authenticatedtransport_setup(transport, signer, expected_peer_id.__wbg_ptr, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
173
182
  return ret;
174
183
  }
175
184
  /**
@@ -182,7 +191,7 @@ export class AuthenticatedTransport {
182
191
  *
183
192
  * # Arguments
184
193
  *
185
- * * `transport` - A `Transport` implementing `sendBytes`/`recvBytes`/`disconnect`
194
+ * * `transport` - A `Transport` implementing `sendBytes`/`recvBytes`/`disconnect`/`onDisconnect`
186
195
  * * `signer` - The client's signer for authentication
187
196
  * * `service_name` - Shared service name for discovery.
188
197
  * Defaults to [`DEFAULT_LOCAL_SERVICE_NAME`] (`"subduction:local"`) if omitted.
@@ -193,12 +202,13 @@ export class AuthenticatedTransport {
193
202
  * @param {Transport} transport
194
203
  * @param {any} signer
195
204
  * @param {string | null} [service_name]
205
+ * @param {Function | null} [on_disconnect]
196
206
  * @returns {Promise<AuthenticatedTransport>}
197
207
  */
198
- static setupDiscover(transport, signer, service_name) {
208
+ static setupDiscover(transport, signer, service_name, on_disconnect) {
199
209
  var ptr0 = isLikeNone(service_name) ? 0 : passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
200
210
  var len0 = WASM_VECTOR_LEN;
201
- const ret = wasm.authenticatedtransport_setupDiscover(transport, signer, ptr0, len0);
211
+ const ret = wasm.authenticatedtransport_setupDiscover(transport, signer, ptr0, len0, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
202
212
  return ret;
203
213
  }
204
214
  }
@@ -1360,7 +1370,7 @@ export class MessagePortTransport {
1360
1370
  wasm.__wbg_messageporttransport_free(ptr, 0);
1361
1371
  }
1362
1372
  /**
1363
- * Disconnect (close the port).
1373
+ * Disconnect (close the port) and fire the `onDisconnect` callback if registered.
1364
1374
  * @returns {Promise<any>}
1365
1375
  */
1366
1376
  disconnect() {
@@ -1377,6 +1387,16 @@ export class MessagePortTransport {
1377
1387
  MessagePortTransportFinalization.register(this, this.__wbg_ptr, this);
1378
1388
  return this;
1379
1389
  }
1390
+ /**
1391
+ * Register a callback to be invoked when the transport disconnects.
1392
+ *
1393
+ * Part of the [`Transport`](super::JsTransport) interface contract.
1394
+ * Typically called by internal wiring rather than directly by user code.
1395
+ * @param {Function} callback
1396
+ */
1397
+ onDisconnect(callback) {
1398
+ wasm.messageporttransport_onDisconnect(this.__wbg_ptr, callback);
1399
+ }
1380
1400
  /**
1381
1401
  * Receive raw bytes (for the handshake phase).
1382
1402
  * @returns {Promise<any>}
@@ -2404,12 +2424,15 @@ export class Subduction {
2404
2424
  * @param {string | null} [service_name]
2405
2425
  * @param {(digest: Digest) => Depth | null} [hash_metric_override]
2406
2426
  * @param {number | null} [max_pending_blob_requests]
2427
+ * @param {any | null} [policy]
2428
+ * @param {Function | null} [on_remote_heads]
2429
+ * @param {Function | null} [on_ephemeral]
2407
2430
  * @returns {Promise<Subduction>}
2408
2431
  */
2409
- static hydrate(signer, storage, service_name, hash_metric_override, max_pending_blob_requests) {
2432
+ static hydrate(signer, storage, service_name, hash_metric_override, max_pending_blob_requests, policy, on_remote_heads, on_ephemeral) {
2410
2433
  var ptr0 = isLikeNone(service_name) ? 0 : passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2411
2434
  var len0 = WASM_VECTOR_LEN;
2412
- const ret = wasm.subduction_hydrate(signer, storage, ptr0, len0, isLikeNone(hash_metric_override) ? 0 : addToExternrefTable0(hash_metric_override), isLikeNone(max_pending_blob_requests) ? 0x100000001 : (max_pending_blob_requests) >>> 0);
2435
+ const ret = wasm.subduction_hydrate(signer, storage, ptr0, len0, isLikeNone(hash_metric_override) ? 0 : addToExternrefTable0(hash_metric_override), isLikeNone(max_pending_blob_requests) ? 0x100000001 : (max_pending_blob_requests) >>> 0, isLikeNone(policy) ? 0 : addToExternrefTable0(policy), isLikeNone(on_remote_heads) ? 0 : addToExternrefTable0(on_remote_heads), isLikeNone(on_ephemeral) ? 0 : addToExternrefTable0(on_ephemeral));
2413
2436
  return ret;
2414
2437
  }
2415
2438
  /**
@@ -2444,6 +2467,9 @@ export class Subduction {
2444
2467
  * When set, clients can connect without knowing the server's peer ID.
2445
2468
  * * `hash_metric_override` - Optional custom depth metric function
2446
2469
  * * `max_pending_blob_requests` - Optional maximum number of pending blob requests (default: 10,000)
2470
+ * * `policy` - Optional JS object implementing authorization.
2471
+ * Must have `authorizeConnect(...)`, `authorizeFetch(...)`, `authorizePut(...)`,
2472
+ * `filterAuthorizedFetch(...)`. Defaults to allow-all.
2447
2473
  *
2448
2474
  * # Panics
2449
2475
  *
@@ -2454,15 +2480,34 @@ export class Subduction {
2454
2480
  * @param {string | null} [service_name]
2455
2481
  * @param {(digest: Digest) => Depth | null} [hash_metric_override]
2456
2482
  * @param {number | null} [max_pending_blob_requests]
2483
+ * @param {any | null} [policy]
2484
+ * @param {Function | null} [on_remote_heads]
2485
+ * @param {Function | null} [on_ephemeral]
2457
2486
  */
2458
- constructor(signer, storage, service_name, hash_metric_override, max_pending_blob_requests) {
2487
+ constructor(signer, storage, service_name, hash_metric_override, max_pending_blob_requests, policy, on_remote_heads, on_ephemeral) {
2459
2488
  var ptr0 = isLikeNone(service_name) ? 0 : passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2460
2489
  var len0 = WASM_VECTOR_LEN;
2461
- const ret = wasm.subduction_new(signer, storage, ptr0, len0, isLikeNone(hash_metric_override) ? 0 : addToExternrefTable0(hash_metric_override), isLikeNone(max_pending_blob_requests) ? 0x100000001 : (max_pending_blob_requests) >>> 0);
2490
+ const ret = wasm.subduction_new(signer, storage, ptr0, len0, isLikeNone(hash_metric_override) ? 0 : addToExternrefTable0(hash_metric_override), isLikeNone(max_pending_blob_requests) ? 0x100000001 : (max_pending_blob_requests) >>> 0, isLikeNone(policy) ? 0 : addToExternrefTable0(policy), isLikeNone(on_remote_heads) ? 0 : addToExternrefTable0(on_remote_heads), isLikeNone(on_ephemeral) ? 0 : addToExternrefTable0(on_ephemeral));
2462
2491
  this.__wbg_ptr = ret >>> 0;
2463
2492
  SubductionFinalization.register(this, this.__wbg_ptr, this);
2464
2493
  return this;
2465
2494
  }
2495
+ /**
2496
+ * Publish an ephemeral message to all subscribers of a sedimentree.
2497
+ *
2498
+ * The payload is opaque bytes — encoding is the caller's responsibility.
2499
+ * Messages are fire-and-forget; delivery is best-effort.
2500
+ * @param {SedimentreeId} id
2501
+ * @param {Uint8Array} payload
2502
+ * @returns {Promise<void>}
2503
+ */
2504
+ publishEphemeral(id, payload) {
2505
+ _assertClass(id, SedimentreeId);
2506
+ const ptr0 = passArray8ToWasm0(payload, wasm.__wbindgen_export);
2507
+ const len0 = WASM_VECTOR_LEN;
2508
+ const ret = wasm.subduction_publishEphemeral(this.__wbg_ptr, id.__wbg_ptr, ptr0, len0);
2509
+ return ret;
2510
+ }
2466
2511
  /**
2467
2512
  * Remove a Sedimentree and all associated data.
2468
2513
  *
@@ -2506,6 +2551,18 @@ export class Subduction {
2506
2551
  const ret = wasm.subduction_storage(this.__wbg_ptr);
2507
2552
  return ret;
2508
2553
  }
2554
+ /**
2555
+ * Subscribe to ephemeral messages for the given sedimentree IDs
2556
+ * from all connected peers.
2557
+ * @param {SedimentreeId[]} ids
2558
+ * @returns {Promise<void>}
2559
+ */
2560
+ subscribeEphemeral(ids) {
2561
+ const ptr0 = passArrayJsValueToWasm0(ids, wasm.__wbindgen_export);
2562
+ const len0 = WASM_VECTOR_LEN;
2563
+ const ret = wasm.subduction_subscribeEphemeral(this.__wbg_ptr, ptr0, len0);
2564
+ return ret;
2565
+ }
2509
2566
  /**
2510
2567
  * Request batch sync for a given Sedimentree ID from all connected peers.
2511
2568
  *
@@ -2553,13 +2610,25 @@ export class Subduction {
2553
2610
  const ret = wasm.subduction_syncWithPeer(this.__wbg_ptr, to_ask.__wbg_ptr, id.__wbg_ptr, subscribe, !isLikeNone(timeout_milliseconds), isLikeNone(timeout_milliseconds) ? BigInt(0) : timeout_milliseconds);
2554
2611
  return ret;
2555
2612
  }
2613
+ /**
2614
+ * Unsubscribe from ephemeral messages for the given sedimentree IDs
2615
+ * from all connected peers.
2616
+ * @param {SedimentreeId[]} ids
2617
+ * @returns {Promise<void>}
2618
+ */
2619
+ unsubscribeEphemeral(ids) {
2620
+ const ptr0 = passArrayJsValueToWasm0(ids, wasm.__wbindgen_export);
2621
+ const len0 = WASM_VECTOR_LEN;
2622
+ const ret = wasm.subduction_unsubscribeEphemeral(this.__wbg_ptr, ptr0, len0);
2623
+ return ret;
2624
+ }
2556
2625
  }
2557
2626
  if (Symbol.dispose) Subduction.prototype[Symbol.dispose] = Subduction.prototype.free;
2558
2627
 
2559
2628
  /**
2560
2629
  * JS-facing wrapper around [`HttpLongPollTransport`] that exposes the
2561
2630
  * byte-oriented [`Transport`](super::JsTransport) interface
2562
- * (`sendBytes`/`recvBytes`/`disconnect`) so it can be used as a
2631
+ * (`sendBytes`/`recvBytes`/`disconnect`/`onDisconnect`) so it can be used as a
2563
2632
  * duck-typed `JsTransport` from JavaScript.
2564
2633
  */
2565
2634
  export class SubductionHttpLongPoll {
@@ -2583,6 +2652,8 @@ export class SubductionHttpLongPoll {
2583
2652
  /**
2584
2653
  * Disconnect from the peer gracefully.
2585
2654
  *
2655
+ * Fires the `onDisconnect` callback if one is registered.
2656
+ *
2586
2657
  * # Errors
2587
2658
  *
2588
2659
  * Returns an error if the disconnect fails.
@@ -2592,6 +2663,16 @@ export class SubductionHttpLongPoll {
2592
2663
  const ret = wasm.subductionhttplongpoll_disconnect(this.__wbg_ptr);
2593
2664
  return ret;
2594
2665
  }
2666
+ /**
2667
+ * Register a callback to be invoked when the transport disconnects.
2668
+ *
2669
+ * Part of the [`Transport`](super::JsTransport) interface contract.
2670
+ * Typically called by internal wiring rather than directly by user code.
2671
+ * @param {Function} callback
2672
+ */
2673
+ onDisconnect(callback) {
2674
+ wasm.subductionhttplongpoll_onDisconnect(this.__wbg_ptr, callback);
2675
+ }
2595
2676
  /**
2596
2677
  * Receive the next message frame as raw bytes.
2597
2678
  *
@@ -2646,7 +2727,7 @@ export class SubductionLongPoll {
2646
2727
  * * `base_url` - The server's HTTP base URL (e.g., `http://localhost:8080`)
2647
2728
  * * `signer` - The client's signer for authentication
2648
2729
  * * `expected_peer_id` - The expected server peer ID (verified during handshake)
2649
- * * `timeout_milliseconds` - Request timeout in milliseconds (default: 30000)
2730
+ * * `on_disconnect` - Optional callback invoked with the peer's [`PeerId`] when the connection closes
2650
2731
  *
2651
2732
  * # Errors
2652
2733
  *
@@ -2654,13 +2735,14 @@ export class SubductionLongPoll {
2654
2735
  * @param {string} base_url
2655
2736
  * @param {any} signer
2656
2737
  * @param {PeerId} expected_peer_id
2738
+ * @param {Function | null} [on_disconnect]
2657
2739
  * @returns {Promise<AuthenticatedLongPoll>}
2658
2740
  */
2659
- static tryConnect(base_url, signer, expected_peer_id) {
2741
+ static tryConnect(base_url, signer, expected_peer_id, on_disconnect) {
2660
2742
  const ptr0 = passStringToWasm0(base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2661
2743
  const len0 = WASM_VECTOR_LEN;
2662
2744
  _assertClass(expected_peer_id, PeerId);
2663
- const ret = wasm.subductionlongpoll_tryConnect(ptr0, len0, signer, expected_peer_id.__wbg_ptr);
2745
+ const ret = wasm.subductionlongpoll_tryConnect(ptr0, len0, signer, expected_peer_id.__wbg_ptr, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
2664
2746
  return ret;
2665
2747
  }
2666
2748
  /**
@@ -2678,14 +2760,15 @@ export class SubductionLongPoll {
2678
2760
  * @param {string} base_url
2679
2761
  * @param {any} signer
2680
2762
  * @param {string | null} [service_name]
2763
+ * @param {Function | null} [on_disconnect]
2681
2764
  * @returns {Promise<AuthenticatedLongPoll>}
2682
2765
  */
2683
- static tryDiscover(base_url, signer, service_name) {
2766
+ static tryDiscover(base_url, signer, service_name, on_disconnect) {
2684
2767
  const ptr0 = passStringToWasm0(base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2685
2768
  const len0 = WASM_VECTOR_LEN;
2686
2769
  var ptr1 = isLikeNone(service_name) ? 0 : passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2687
2770
  var len1 = WASM_VECTOR_LEN;
2688
- const ret = wasm.subductionlongpoll_tryDiscover(ptr0, len0, signer, ptr1, len1);
2771
+ const ret = wasm.subductionlongpoll_tryDiscover(ptr0, len0, signer, ptr1, len1, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
2689
2772
  return ret;
2690
2773
  }
2691
2774
  }
@@ -2725,6 +2808,19 @@ export class SubductionWebSocket {
2725
2808
  const ret = wasm.subductionwebsocket_disconnect(this.__wbg_ptr);
2726
2809
  return ret;
2727
2810
  }
2811
+ /**
2812
+ * Register a callback to be invoked when the WebSocket closes.
2813
+ *
2814
+ * Part of the [`Transport`](super::JsTransport) interface contract.
2815
+ * Typically called by internal wiring (factory methods like `tryConnect`
2816
+ * and `tryDiscover`) rather than directly by user code.
2817
+ *
2818
+ * The callback is fired from the browser WebSocket's `onclose` handler.
2819
+ * @param {Function} callback
2820
+ */
2821
+ onDisconnect(callback) {
2822
+ wasm.subductionwebsocket_onDisconnect(this.__wbg_ptr, callback);
2823
+ }
2728
2824
  /**
2729
2825
  * Receive the next message frame as raw bytes.
2730
2826
  *
@@ -2763,7 +2859,7 @@ export class SubductionWebSocket {
2763
2859
  * * `ws` - An existing WebSocket (CONNECTING or OPEN)
2764
2860
  * * `signer` - The client's signer for authentication
2765
2861
  * * `expected_peer_id` - The expected server peer ID (verified during handshake)
2766
- * * `timeout_milliseconds` - Request timeout in milliseconds
2862
+ * * `on_disconnect` - Optional callback invoked with the peer's [`PeerId`] when the connection closes
2767
2863
  *
2768
2864
  * # Errors
2769
2865
  *
@@ -2771,11 +2867,12 @@ export class SubductionWebSocket {
2771
2867
  * @param {WebSocket} ws
2772
2868
  * @param {any} signer
2773
2869
  * @param {PeerId} expected_peer_id
2870
+ * @param {Function | null} [on_disconnect]
2774
2871
  * @returns {Promise<AuthenticatedWebSocket>}
2775
2872
  */
2776
- static setup(ws, signer, expected_peer_id) {
2873
+ static setup(ws, signer, expected_peer_id, on_disconnect) {
2777
2874
  _assertClass(expected_peer_id, PeerId);
2778
- const ret = wasm.subductionwebsocket_setup(ws, signer, expected_peer_id.__wbg_ptr);
2875
+ const ret = wasm.subductionwebsocket_setup(ws, signer, expected_peer_id.__wbg_ptr, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
2779
2876
  return ret;
2780
2877
  }
2781
2878
  /**
@@ -2786,6 +2883,8 @@ export class SubductionWebSocket {
2786
2883
  * * `address` - The WebSocket URL to connect to
2787
2884
  * * `signer` - The client's signer for authentication
2788
2885
  * * `expected_peer_id` - The expected server peer ID (verified during handshake)
2886
+ * * `on_disconnect` - Optional callback invoked with the peer's [`PeerId`] when the connection closes
2887
+ *
2789
2888
  * # Errors
2790
2889
  *
2791
2890
  * Returns an error if:
@@ -2794,11 +2893,12 @@ export class SubductionWebSocket {
2794
2893
  * @param {URL} address
2795
2894
  * @param {any} signer
2796
2895
  * @param {PeerId} expected_peer_id
2896
+ * @param {Function | null} [on_disconnect]
2797
2897
  * @returns {Promise<AuthenticatedWebSocket>}
2798
2898
  */
2799
- static tryConnect(address, signer, expected_peer_id) {
2899
+ static tryConnect(address, signer, expected_peer_id, on_disconnect) {
2800
2900
  _assertClass(expected_peer_id, PeerId);
2801
- const ret = wasm.subductionwebsocket_tryConnect(address, signer, expected_peer_id.__wbg_ptr);
2901
+ const ret = wasm.subductionwebsocket_tryConnect(address, signer, expected_peer_id.__wbg_ptr, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
2802
2902
  return ret;
2803
2903
  }
2804
2904
  /**
@@ -2812,9 +2912,9 @@ export class SubductionWebSocket {
2812
2912
  *
2813
2913
  * * `address` - The WebSocket URL to connect to
2814
2914
  * * `signer` - The client's signer for authentication
2815
- * * `timeout_milliseconds` - Request timeout in milliseconds. Defaults to 30000 (30s).
2816
2915
  * * `service_name` - The service name for discovery (e.g., `localhost:8080`).
2817
2916
  * If omitted, the host is extracted from the URL.
2917
+ * * `on_disconnect` - Optional callback invoked with the peer's [`PeerId`] when the connection closes
2818
2918
  *
2819
2919
  * # Errors
2820
2920
  *
@@ -2824,12 +2924,13 @@ export class SubductionWebSocket {
2824
2924
  * @param {URL} address
2825
2925
  * @param {any} signer
2826
2926
  * @param {string | null} [service_name]
2927
+ * @param {Function | null} [on_disconnect]
2827
2928
  * @returns {Promise<AuthenticatedWebSocket>}
2828
2929
  */
2829
- static tryDiscover(address, signer, service_name) {
2930
+ static tryDiscover(address, signer, service_name, on_disconnect) {
2830
2931
  var ptr0 = isLikeNone(service_name) ? 0 : passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2831
2932
  var len0 = WASM_VECTOR_LEN;
2832
- const ret = wasm.subductionwebsocket_tryDiscover(address, signer, ptr0, len0);
2933
+ const ret = wasm.subductionwebsocket_tryDiscover(address, signer, ptr0, len0, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
2833
2934
  return ret;
2834
2935
  }
2835
2936
  }
@@ -3092,13 +3193,26 @@ export class SyncStats {
3092
3193
  return ret >>> 0;
3093
3194
  }
3094
3195
  /**
3095
- * Returns true if no data was exchanged.
3196
+ * Returns true if no commits or fragments were transferred.
3197
+ *
3198
+ * Note: `remoteHeads` may still be non-empty (heads metadata is not
3199
+ * considered "data" for this check).
3096
3200
  * @returns {boolean}
3097
3201
  */
3098
3202
  get isEmpty() {
3099
3203
  const ret = wasm.syncstats_isEmpty(this.__wbg_ptr);
3100
3204
  return ret !== 0;
3101
3205
  }
3206
+ /**
3207
+ * The remote peer's heads for this sedimentree.
3208
+ * @returns {Digest[]}
3209
+ */
3210
+ get remoteHeads() {
3211
+ const ret = wasm.syncstats_remoteHeads(this.__wbg_ptr);
3212
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
3213
+ wasm.__wbindgen_export5(ret[0], ret[1] * 4, 4);
3214
+ return v1;
3215
+ }
3102
3216
  /**
3103
3217
  * Total items received (commits + fragments).
3104
3218
  * @returns {number}
@@ -3223,41 +3337,42 @@ export function makeMessagePortTransport(port) {
3223
3337
  export function start() {
3224
3338
  wasm.start();
3225
3339
  }
3340
+ import * as import1 from "./snippets/subduction_wasm-0ed7fd66cebca59f/inline0.js"
3226
3341
 
3227
3342
  function __wbg_get_imports() {
3228
3343
  const import0 = {
3229
3344
  __proto__: null,
3230
- __wbg___wasm_refgen_toWasmCommitWithBlob_dd531ffcf07010df: function(arg0) {
3345
+ __wbg___wasm_refgen_toWasmCommitWithBlob_4c1dc5cc453af7eb: function(arg0) {
3231
3346
  const ret = arg0.__wasm_refgen_toWasmCommitWithBlob();
3232
3347
  _assertClass(ret, CommitWithBlob);
3233
3348
  var ptr1 = ret.__destroy_into_raw();
3234
3349
  return ptr1;
3235
3350
  },
3236
- __wbg___wasm_refgen_toWasmDepth_27ce1b98b370f678: function(arg0) {
3351
+ __wbg___wasm_refgen_toWasmDepth_e11bce6176c8257e: function(arg0) {
3237
3352
  const ret = arg0.__wasm_refgen_toWasmDepth();
3238
3353
  _assertClass(ret, Depth);
3239
3354
  var ptr1 = ret.__destroy_into_raw();
3240
3355
  return ptr1;
3241
3356
  },
3242
- __wbg___wasm_refgen_toWasmDigest_f8a8f75af5a76e32: function(arg0) {
3357
+ __wbg___wasm_refgen_toWasmDigest_86d449f5dc99fc6a: function(arg0) {
3243
3358
  const ret = arg0.__wasm_refgen_toWasmDigest();
3244
3359
  _assertClass(ret, Digest);
3245
3360
  var ptr1 = ret.__destroy_into_raw();
3246
3361
  return ptr1;
3247
3362
  },
3248
- __wbg___wasm_refgen_toWasmFragmentWithBlob_c8c0aa6880d18e47: function(arg0) {
3363
+ __wbg___wasm_refgen_toWasmFragmentWithBlob_d7450dc251166eea: function(arg0) {
3249
3364
  const ret = arg0.__wasm_refgen_toWasmFragmentWithBlob();
3250
3365
  _assertClass(ret, FragmentWithBlob);
3251
3366
  var ptr1 = ret.__destroy_into_raw();
3252
3367
  return ptr1;
3253
3368
  },
3254
- __wbg___wasm_refgen_toWasmFragment_1588222a9da0cef6: function(arg0) {
3369
+ __wbg___wasm_refgen_toWasmFragment_03b5e19d20693b4f: function(arg0) {
3255
3370
  const ret = arg0.__wasm_refgen_toWasmFragment();
3256
3371
  _assertClass(ret, Fragment);
3257
3372
  var ptr1 = ret.__destroy_into_raw();
3258
3373
  return ptr1;
3259
3374
  },
3260
- __wbg___wasm_refgen_toWasmLooseCommit_c9b58ceccbe54e38: function(arg0) {
3375
+ __wbg___wasm_refgen_toWasmLooseCommit_bc6f015053af2dd7: function(arg0) {
3261
3376
  const ret = arg0.__wasm_refgen_toWasmLooseCommit();
3262
3377
  _assertClass(ret, LooseCommit);
3263
3378
  var ptr1 = ret.__destroy_into_raw();
@@ -3301,6 +3416,14 @@ function __wbg_get_imports() {
3301
3416
  getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
3302
3417
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
3303
3418
  },
3419
+ __wbg___wbindgen_string_get_395e606bd0ee4427: function(arg0, arg1) {
3420
+ const obj = arg1;
3421
+ const ret = typeof(obj) === 'string' ? obj : undefined;
3422
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3423
+ var len1 = WASM_VECTOR_LEN;
3424
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3425
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3426
+ },
3304
3427
  __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
3305
3428
  throw new Error(getStringFromWasm0(arg0, arg1));
3306
3429
  },
@@ -3323,6 +3446,18 @@ function __wbg_get_imports() {
3323
3446
  const ret = AuthenticatedWebSocket.__wrap(arg0);
3324
3447
  return ret;
3325
3448
  },
3449
+ __wbg_authorizeConnect_0e61e98d289a37c9: function() { return handleError(function (arg0, arg1) {
3450
+ const ret = arg0.authorizeConnect(arg1);
3451
+ return ret;
3452
+ }, arguments); },
3453
+ __wbg_authorizeFetch_88703389e9c295d0: function() { return handleError(function (arg0, arg1, arg2) {
3454
+ const ret = arg0.authorizeFetch(arg1, arg2);
3455
+ return ret;
3456
+ }, arguments); },
3457
+ __wbg_authorizePut_dab9270462803778: function() { return handleError(function (arg0, arg1, arg2, arg3) {
3458
+ const ret = arg0.authorizePut(arg1, arg2, arg3);
3459
+ return ret;
3460
+ }, arguments); },
3326
3461
  __wbg_buffer_60b8043cd926067d: function(arg0) {
3327
3462
  const ret = arg0.buffer;
3328
3463
  return ret;
@@ -3331,9 +3466,20 @@ function __wbg_get_imports() {
3331
3466
  const ret = arg0.call(arg1, arg2);
3332
3467
  return ret;
3333
3468
  }, arguments); },
3334
- __wbg_close_9b95bf80abb12681: function(arg0) {
3469
+ __wbg_call_e133b57c9155d22c: function() { return handleError(function (arg0, arg1) {
3470
+ const ret = arg0.call(arg1);
3471
+ return ret;
3472
+ }, arguments); },
3473
+ __wbg_call_f858478a02f9600f: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
3474
+ const ret = arg0.call(arg1, arg2, arg3, arg4);
3475
+ return ret;
3476
+ }, arguments); },
3477
+ __wbg_close_574e2788efd7bb53: function(arg0) {
3335
3478
  arg0.close();
3336
3479
  },
3480
+ __wbg_close_af26905c832a88cb: function() { return handleError(function (arg0) {
3481
+ arg0.close();
3482
+ }, arguments); },
3337
3483
  __wbg_close_cbf870bdad0aad99: function(arg0) {
3338
3484
  arg0.close();
3339
3485
  },
@@ -3357,11 +3503,11 @@ function __wbg_get_imports() {
3357
3503
  const ret = arg0.data;
3358
3504
  return ret;
3359
3505
  },
3360
- __wbg_deleteAllCommits_d0ac05a9e8ca602d: function(arg0, arg1) {
3506
+ __wbg_deleteAllCommits_b0197e590f7fce60: function(arg0, arg1) {
3361
3507
  const ret = arg0.deleteAllCommits(arg1);
3362
3508
  return ret;
3363
3509
  },
3364
- __wbg_deleteAllFragments_218b2911a6d1dc45: function(arg0, arg1) {
3510
+ __wbg_deleteAllFragments_f884845698f5afb7: function(arg0, arg1) {
3365
3511
  const ret = arg0.deleteAllFragments(arg1);
3366
3512
  return ret;
3367
3513
  },
@@ -3373,7 +3519,7 @@ function __wbg_get_imports() {
3373
3519
  const ret = Digest.__unwrap(arg0);
3374
3520
  return ret;
3375
3521
  },
3376
- __wbg_disconnect_285027c2ec32acf6: function(arg0) {
3522
+ __wbg_disconnect_849aae59f5879e45: function(arg0) {
3377
3523
  const ret = arg0.disconnect();
3378
3524
  return ret;
3379
3525
  },
@@ -3400,6 +3546,10 @@ function __wbg_get_imports() {
3400
3546
  const ret = arg0.fetch(arg1);
3401
3547
  return ret;
3402
3548
  },
3549
+ __wbg_filterAuthorizedFetch_0d6450fa919b271d: function() { return handleError(function (arg0, arg1, arg2) {
3550
+ const ret = arg0.filterAuthorizedFetch(arg1, arg2);
3551
+ return ret;
3552
+ }, arguments); },
3403
3553
  __wbg_fragment_new: function(arg0) {
3404
3554
  const ret = Fragment.__wrap(arg0);
3405
3555
  return ret;
@@ -3442,6 +3592,10 @@ function __wbg_get_imports() {
3442
3592
  const ret = arg0[arg1 >>> 0];
3443
3593
  return ret;
3444
3594
  },
3595
+ __wbg_get_unchecked_329cfe50afab7352: function(arg0, arg1) {
3596
+ const ret = arg0[arg1 >>> 0];
3597
+ return ret;
3598
+ },
3445
3599
  __wbg_has_926ef2ff40b308cf: function() { return handleError(function (arg0, arg1) {
3446
3600
  const ret = Reflect.has(arg0, arg1);
3447
3601
  return ret;
@@ -3568,6 +3722,10 @@ function __wbg_get_imports() {
3568
3722
  const ret = result;
3569
3723
  return ret;
3570
3724
  },
3725
+ __wbg_isArray_33b91feb269ff46e: function(arg0) {
3726
+ const ret = Array.isArray(arg0);
3727
+ return ret;
3728
+ },
3571
3729
  __wbg_isSafeInteger_ecd6a7f9c3e053cd: function(arg0) {
3572
3730
  const ret = Number.isSafeInteger(arg0);
3573
3731
  return ret;
@@ -3580,15 +3738,15 @@ function __wbg_get_imports() {
3580
3738
  const ret = arg0.length;
3581
3739
  return ret;
3582
3740
  },
3583
- __wbg_loadAllCommits_cb4633fec4cd1b74: function(arg0, arg1) {
3741
+ __wbg_loadAllCommits_0e97df07ed213aa0: function(arg0, arg1) {
3584
3742
  const ret = arg0.loadAllCommits(arg1);
3585
3743
  return ret;
3586
3744
  },
3587
- __wbg_loadAllFragments_299c1fb6ad9bf5c6: function(arg0, arg1) {
3745
+ __wbg_loadAllFragments_12ecf8f9bd0e0b58: function(arg0, arg1) {
3588
3746
  const ret = arg0.loadAllFragments(arg1);
3589
3747
  return ret;
3590
3748
  },
3591
- __wbg_loadAllSedimentreeIds_524a01a05c3d08cc: function(arg0) {
3749
+ __wbg_loadAllSedimentreeIds_1a18451ef1f8e795: function(arg0) {
3592
3750
  const ret = arg0.loadAllSedimentreeIds();
3593
3751
  return ret;
3594
3752
  },
@@ -3631,7 +3789,7 @@ function __wbg_get_imports() {
3631
3789
  const a = state0.a;
3632
3790
  state0.a = 0;
3633
3791
  try {
3634
- return __wasm_bindgen_func_elem_1476_183(a, state0.b, arg0, arg1);
3792
+ return __wasm_bindgen_func_elem_1605_191(a, state0.b, arg0, arg1);
3635
3793
  } finally {
3636
3794
  state0.a = a;
3637
3795
  }
@@ -3665,7 +3823,7 @@ function __wbg_get_imports() {
3665
3823
  const a = state0.a;
3666
3824
  state0.a = 0;
3667
3825
  try {
3668
- return __wasm_bindgen_func_elem_1476_184(a, state0.b, arg0, arg1);
3826
+ return __wasm_bindgen_func_elem_1605_192(a, state0.b, arg0, arg1);
3669
3827
  } finally {
3670
3828
  state0.a = a;
3671
3829
  }
@@ -3676,6 +3834,10 @@ function __wbg_get_imports() {
3676
3834
  state0.a = state0.b = 0;
3677
3835
  }
3678
3836
  },
3837
+ __wbg_new_typed_bccac67128ed885a: function() {
3838
+ const ret = new Array();
3839
+ return ret;
3840
+ },
3679
3841
  __wbg_new_with_length_825018a1616e9e55: function(arg0) {
3680
3842
  const ret = new Uint8Array(arg0 >>> 0);
3681
3843
  return ret;
@@ -3708,6 +3870,9 @@ function __wbg_get_imports() {
3708
3870
  const ret = Array.of(arg0, arg1);
3709
3871
  return ret;
3710
3872
  },
3873
+ __wbg_onDisconnect_12d6884490508121: function(arg0, arg1) {
3874
+ arg0.onDisconnect(arg1);
3875
+ },
3711
3876
  __wbg_open_e7a9d3d6344572f6: function() { return handleError(function (arg0, arg1, arg2, arg3) {
3712
3877
  const ret = arg0.open(getStringFromWasm0(arg1, arg2), arg3 >>> 0);
3713
3878
  return ret;
@@ -3732,7 +3897,7 @@ function __wbg_get_imports() {
3732
3897
  const ret = arg0.port2;
3733
3898
  return ret;
3734
3899
  },
3735
- __wbg_postMessage_1acd85b7323d11a6: function(arg0, arg1) {
3900
+ __wbg_postMessage_0541d6c31330afe3: function(arg0, arg1) {
3736
3901
  arg0.postMessage(arg1);
3737
3902
  },
3738
3903
  __wbg_process_44c7a14e11e9f69e: function(arg0) {
@@ -3764,7 +3929,7 @@ function __wbg_get_imports() {
3764
3929
  const ret = arg0.readyState;
3765
3930
  return ret;
3766
3931
  },
3767
- __wbg_recvBytes_35ad4c7c108ff4dd: function(arg0) {
3932
+ __wbg_recvBytes_c85b12fb48cd7a35: function(arg0) {
3768
3933
  const ret = arg0.recvBytes();
3769
3934
  return ret;
3770
3935
  },
@@ -3780,15 +3945,15 @@ function __wbg_get_imports() {
3780
3945
  const ret = arg0.result;
3781
3946
  return ret;
3782
3947
  }, arguments); },
3783
- __wbg_saveCommit_3c8f305f5ed3d86f: function(arg0, arg1, arg2, arg3, arg4) {
3948
+ __wbg_saveCommit_02f095436fc502e0: function(arg0, arg1, arg2, arg3, arg4) {
3784
3949
  const ret = arg0.saveCommit(arg1, arg2, arg3, arg4);
3785
3950
  return ret;
3786
3951
  },
3787
- __wbg_saveFragment_f534165ab0b0d628: function(arg0, arg1, arg2, arg3, arg4) {
3952
+ __wbg_saveFragment_7681b2171b8cfb35: function(arg0, arg1, arg2, arg3, arg4) {
3788
3953
  const ret = arg0.saveFragment(arg1, arg2, arg3, arg4);
3789
3954
  return ret;
3790
3955
  },
3791
- __wbg_saveSedimentreeId_458321e93f49f548: function(arg0, arg1) {
3956
+ __wbg_saveSedimentreeId_c265aaeef5af34b6: function(arg0, arg1) {
3792
3957
  const ret = arg0.saveSedimentreeId(arg1);
3793
3958
  return ret;
3794
3959
  },
@@ -3800,14 +3965,14 @@ function __wbg_get_imports() {
3800
3965
  const ret = SedimentreeId.__unwrap(arg0);
3801
3966
  return ret;
3802
3967
  },
3803
- __wbg_sendBytes_c3a40be4ec4bfd25: function(arg0, arg1) {
3968
+ __wbg_sendBytes_e6262dd74f1c260a: function(arg0, arg1) {
3804
3969
  const ret = arg0.sendBytes(arg1);
3805
3970
  return ret;
3806
3971
  },
3807
3972
  __wbg_send_d31a693c975dea74: function() { return handleError(function (arg0, arg1, arg2) {
3808
3973
  arg0.send(getArrayU8FromWasm0(arg1, arg2));
3809
3974
  }, arguments); },
3810
- __wbg_setTimeout_5e8107dbc66751b5: function(arg0, arg1) {
3975
+ __wbg_setTimeout_7829585928963a1f: function(arg0, arg1) {
3811
3976
  const ret = setTimeout(arg0, arg1);
3812
3977
  return ret;
3813
3978
  },
@@ -3845,7 +4010,7 @@ function __wbg_get_imports() {
3845
4010
  __wbg_set_onerror_901ca711f94a5bbb: function(arg0, arg1) {
3846
4011
  arg0.onerror = arg1;
3847
4012
  },
3848
- __wbg_set_onmessage_3b92dfded4487295: function(arg0, arg1) {
4013
+ __wbg_set_onmessage_29558b29aee9a78a: function(arg0, arg1) {
3849
4014
  arg0.onmessage = arg1;
3850
4015
  },
3851
4016
  __wbg_set_onmessage_6f80ab771bf151aa: function(arg0, arg1) {
@@ -3860,14 +4025,14 @@ function __wbg_get_imports() {
3860
4025
  __wbg_set_onupgradeneeded_860ce42184f987e7: function(arg0, arg1) {
3861
4026
  arg0.onupgradeneeded = arg1;
3862
4027
  },
3863
- __wbg_sign_23c468db7fe0ee83: function(arg0, arg1) {
3864
- const ret = arg0.sign(arg1);
3865
- return ret;
3866
- },
3867
4028
  __wbg_sign_a34d057afd14c54d: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
3868
4029
  const ret = arg0.sign(arg1, arg2, getArrayU8FromWasm0(arg3, arg4));
3869
4030
  return ret;
3870
4031
  }, arguments); },
4032
+ __wbg_sign_d03455abc6736428: function(arg0, arg1) {
4033
+ const ret = arg0.sign(arg1);
4034
+ return ret;
4035
+ },
3871
4036
  __wbg_signedfragment_new: function(arg0) {
3872
4037
  const ret = SignedFragment.__wrap(arg0);
3873
4038
  return ret;
@@ -3946,14 +4111,14 @@ function __wbg_get_imports() {
3946
4111
  const ret = arg0.transaction(getStringFromWasm0(arg1, arg2));
3947
4112
  return ret;
3948
4113
  }, arguments); },
3949
- __wbg_tryIntoJsSedimentreeIdsArray_6f2961e02ae84900: function() { return handleError(function (arg0, arg1) {
4114
+ __wbg_tryIntoJsSedimentreeIdsArray_d6337c0aa0f28604: function() { return handleError(function (arg0, arg1) {
3950
4115
  const ret = tryIntoJsSedimentreeIdsArray(arg1);
3951
4116
  const ptr1 = passArrayJsValueToWasm0(ret, wasm.__wbindgen_export);
3952
4117
  const len1 = WASM_VECTOR_LEN;
3953
4118
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3954
4119
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3955
4120
  }, arguments); },
3956
- __wbg_verifyingKey_e2a30e05511820c4: function(arg0) {
4121
+ __wbg_verifyingKey_29533740d75f8cdb: function(arg0) {
3957
4122
  const ret = arg0.verifyingKey();
3958
4123
  return ret;
3959
4124
  },
@@ -3966,74 +4131,79 @@ function __wbg_get_imports() {
3966
4131
  return ret;
3967
4132
  },
3968
4133
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
3969
- // Cast intrinsic for `Closure(Closure { dtor_idx: 10, function: Function { arguments: [Externref], shim_idx: 11, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3970
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_255, __wasm_bindgen_func_elem_552);
4134
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 11, function: Function { arguments: [Externref], shim_idx: 12, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
4135
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_274, __wasm_bindgen_func_elem_590);
3971
4136
  return ret;
3972
4137
  },
3973
4138
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
3974
- // Cast intrinsic for `Closure(Closure { dtor_idx: 10, function: Function { arguments: [NamedExternref("Event")], shim_idx: 11, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3975
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_255, __wasm_bindgen_func_elem_552_1);
4139
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 11, function: Function { arguments: [NamedExternref("Event")], shim_idx: 12, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
4140
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_274, __wasm_bindgen_func_elem_590_1);
3976
4141
  return ret;
3977
4142
  },
3978
4143
  __wbindgen_cast_0000000000000003: function(arg0, arg1) {
3979
- // Cast intrinsic for `Closure(Closure { dtor_idx: 10, function: Function { arguments: [NamedExternref("IDBVersionChangeEvent")], shim_idx: 11, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3980
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_255, __wasm_bindgen_func_elem_552_2);
4144
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 11, function: Function { arguments: [NamedExternref("IDBVersionChangeEvent")], shim_idx: 12, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
4145
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_274, __wasm_bindgen_func_elem_590_2);
3981
4146
  return ret;
3982
4147
  },
3983
4148
  __wbindgen_cast_0000000000000004: function(arg0, arg1) {
3984
- // Cast intrinsic for `Closure(Closure { dtor_idx: 10, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 11, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3985
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_255, __wasm_bindgen_func_elem_552_3);
4149
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 11, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 12, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
4150
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_274, __wasm_bindgen_func_elem_590_3);
3986
4151
  return ret;
3987
4152
  },
3988
4153
  __wbindgen_cast_0000000000000005: function(arg0, arg1) {
3989
- // Cast intrinsic for `Closure(Closure { dtor_idx: 609, function: Function { arguments: [Externref], shim_idx: 698, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
3990
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_255, __wasm_bindgen_func_elem_1476);
4154
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 11, function: Function { arguments: [], shim_idx: 13, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
4155
+ const ret = makeClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_274, __wasm_bindgen_func_elem_589);
4156
+ return ret;
4157
+ },
4158
+ __wbindgen_cast_0000000000000006: function(arg0, arg1) {
4159
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 655, function: Function { arguments: [Externref], shim_idx: 738, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
4160
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_274, __wasm_bindgen_func_elem_1605);
3991
4161
  return ret;
3992
4162
  },
3993
- __wbindgen_cast_0000000000000006: function(arg0) {
4163
+ __wbindgen_cast_0000000000000007: function(arg0) {
3994
4164
  // Cast intrinsic for `F64 -> Externref`.
3995
4165
  const ret = arg0;
3996
4166
  return ret;
3997
4167
  },
3998
- __wbindgen_cast_0000000000000007: function(arg0, arg1) {
4168
+ __wbindgen_cast_0000000000000008: function(arg0, arg1) {
3999
4169
  // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
4000
4170
  const ret = getArrayU8FromWasm0(arg0, arg1);
4001
4171
  return ret;
4002
4172
  },
4003
- __wbindgen_cast_0000000000000008: function(arg0, arg1) {
4173
+ __wbindgen_cast_0000000000000009: function(arg0, arg1) {
4004
4174
  // Cast intrinsic for `Ref(String) -> Externref`.
4005
4175
  const ret = getStringFromWasm0(arg0, arg1);
4006
4176
  return ret;
4007
4177
  },
4008
- __wbindgen_cast_0000000000000009: function(arg0, arg1) {
4178
+ __wbindgen_cast_000000000000000a: function(arg0, arg1) {
4009
4179
  var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
4010
4180
  wasm.__wbindgen_export5(arg0, arg1 * 4, 4);
4011
4181
  // Cast intrinsic for `Vector(NamedExternref("Fragment")) -> Externref`.
4012
4182
  const ret = v0;
4013
4183
  return ret;
4014
4184
  },
4015
- __wbindgen_cast_000000000000000a: function(arg0, arg1) {
4185
+ __wbindgen_cast_000000000000000b: function(arg0, arg1) {
4016
4186
  var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
4017
4187
  wasm.__wbindgen_export5(arg0, arg1 * 4, 4);
4018
4188
  // Cast intrinsic for `Vector(NamedExternref("LooseCommit")) -> Externref`.
4019
4189
  const ret = v0;
4020
4190
  return ret;
4021
4191
  },
4022
- __wbindgen_cast_000000000000000b: function(arg0, arg1) {
4192
+ __wbindgen_cast_000000000000000c: function(arg0, arg1) {
4023
4193
  var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
4024
4194
  wasm.__wbindgen_export5(arg0, arg1 * 4, 4);
4025
4195
  // Cast intrinsic for `Vector(NamedExternref("PeerId")) -> Externref`.
4026
4196
  const ret = v0;
4027
4197
  return ret;
4028
4198
  },
4029
- __wbindgen_cast_000000000000000c: function(arg0, arg1) {
4199
+ __wbindgen_cast_000000000000000d: function(arg0, arg1) {
4030
4200
  var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
4031
4201
  wasm.__wbindgen_export5(arg0, arg1 * 4, 4);
4032
4202
  // Cast intrinsic for `Vector(NamedExternref("SedimentreeId")) -> Externref`.
4033
4203
  const ret = v0;
4034
4204
  return ret;
4035
4205
  },
4036
- __wbindgen_cast_000000000000000d: function(arg0, arg1) {
4206
+ __wbindgen_cast_000000000000000e: function(arg0, arg1) {
4037
4207
  var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
4038
4208
  wasm.__wbindgen_export5(arg0, arg1 * 4, 4);
4039
4209
  // Cast intrinsic for `Vector(NamedExternref("Uint8Array")) -> Externref`.
@@ -4053,38 +4223,43 @@ function __wbg_get_imports() {
4053
4223
  return {
4054
4224
  __proto__: null,
4055
4225
  "./subduction_wasm_bg.js": import0,
4226
+ "./snippets/subduction_wasm-0ed7fd66cebca59f/inline0.js": import1,
4056
4227
  };
4057
4228
  }
4058
4229
 
4059
- function __wasm_bindgen_func_elem_552(arg0, arg1, arg2) {
4060
- wasm.__wasm_bindgen_func_elem_552(arg0, arg1, arg2);
4230
+ function __wasm_bindgen_func_elem_589(arg0, arg1) {
4231
+ wasm.__wasm_bindgen_func_elem_589(arg0, arg1);
4061
4232
  }
4062
4233
 
4063
- function __wasm_bindgen_func_elem_552_1(arg0, arg1, arg2) {
4064
- wasm.__wasm_bindgen_func_elem_552_1(arg0, arg1, arg2);
4234
+ function __wasm_bindgen_func_elem_590(arg0, arg1, arg2) {
4235
+ wasm.__wasm_bindgen_func_elem_590(arg0, arg1, arg2);
4065
4236
  }
4066
4237
 
4067
- function __wasm_bindgen_func_elem_552_2(arg0, arg1, arg2) {
4068
- wasm.__wasm_bindgen_func_elem_552_2(arg0, arg1, arg2);
4238
+ function __wasm_bindgen_func_elem_590_1(arg0, arg1, arg2) {
4239
+ wasm.__wasm_bindgen_func_elem_590_1(arg0, arg1, arg2);
4069
4240
  }
4070
4241
 
4071
- function __wasm_bindgen_func_elem_552_3(arg0, arg1, arg2) {
4072
- wasm.__wasm_bindgen_func_elem_552_3(arg0, arg1, arg2);
4242
+ function __wasm_bindgen_func_elem_590_2(arg0, arg1, arg2) {
4243
+ wasm.__wasm_bindgen_func_elem_590_2(arg0, arg1, arg2);
4073
4244
  }
4074
4245
 
4075
- function __wasm_bindgen_func_elem_1476(arg0, arg1, arg2) {
4076
- const ret = wasm.__wasm_bindgen_func_elem_1476(arg0, arg1, arg2);
4246
+ function __wasm_bindgen_func_elem_590_3(arg0, arg1, arg2) {
4247
+ wasm.__wasm_bindgen_func_elem_590_3(arg0, arg1, arg2);
4248
+ }
4249
+
4250
+ function __wasm_bindgen_func_elem_1605(arg0, arg1, arg2) {
4251
+ const ret = wasm.__wasm_bindgen_func_elem_1605(arg0, arg1, arg2);
4077
4252
  if (ret[1]) {
4078
4253
  throw takeFromExternrefTable0(ret[0]);
4079
4254
  }
4080
4255
  }
4081
4256
 
4082
- function __wasm_bindgen_func_elem_1476_183(arg0, arg1, arg2, arg3) {
4083
- wasm.__wasm_bindgen_func_elem_1476_183(arg0, arg1, arg2, arg3);
4257
+ function __wasm_bindgen_func_elem_1605_191(arg0, arg1, arg2, arg3) {
4258
+ wasm.__wasm_bindgen_func_elem_1605_191(arg0, arg1, arg2, arg3);
4084
4259
  }
4085
4260
 
4086
- function __wasm_bindgen_func_elem_1476_184(arg0, arg1, arg2, arg3) {
4087
- wasm.__wasm_bindgen_func_elem_1476_184(arg0, arg1, arg2, arg3);
4261
+ function __wasm_bindgen_func_elem_1605_192(arg0, arg1, arg2, arg3) {
4262
+ wasm.__wasm_bindgen_func_elem_1605_192(arg0, arg1, arg2, arg3);
4088
4263
  }
4089
4264
 
4090
4265
 
@@ -4335,6 +4510,31 @@ function isLikeNone(x) {
4335
4510
  return x === undefined || x === null;
4336
4511
  }
4337
4512
 
4513
+ function makeClosure(arg0, arg1, dtor, f) {
4514
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
4515
+ const real = (...args) => {
4516
+
4517
+ // First up with a closure we increment the internal reference
4518
+ // count. This ensures that the Rust closure environment won't
4519
+ // be deallocated while we're invoking it.
4520
+ state.cnt++;
4521
+ try {
4522
+ return f(state.a, state.b, ...args);
4523
+ } finally {
4524
+ real._wbg_cb_unref();
4525
+ }
4526
+ };
4527
+ real._wbg_cb_unref = () => {
4528
+ if (--state.cnt === 0) {
4529
+ state.dtor(state.a, state.b);
4530
+ state.a = 0;
4531
+ CLOSURE_DTORS.unregister(state);
4532
+ }
4533
+ };
4534
+ CLOSURE_DTORS.register(real, state, state);
4535
+ return real;
4536
+ }
4537
+
4338
4538
  function makeMutClosure(arg0, arg1, dtor, f) {
4339
4539
  const state = { a: arg0, b: arg1, cnt: 1, dtor };
4340
4540
  const real = (...args) => {