@automerge/subduction 0.10.0 → 0.10.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.
Files changed (43) hide show
  1. package/dist/cjs/node.cjs +5 -0
  2. package/dist/cjs/slim.cjs +1 -0
  3. package/dist/cjs/wasm-base64.cjs +1 -0
  4. package/dist/cjs/web-bindings.cjs +4768 -0
  5. package/dist/cjs/web.cjs +4719 -0
  6. package/dist/esm/bundler.js +7 -0
  7. package/dist/esm/node.js +7 -0
  8. package/dist/esm/slim.js +2 -0
  9. package/dist/esm/wasm-base64.js +1 -0
  10. package/dist/esm/web.js +5 -0
  11. package/dist/esm/workerd.js +5 -0
  12. package/dist/iife/index.js +4677 -0
  13. package/dist/index.d.ts +1706 -0
  14. package/dist/subduction.wasm +0 -0
  15. package/dist/wasm_bindgen/bundler/snippets/sedimentree_wasm-75027ecce41278de/inline0.js +2 -0
  16. package/dist/wasm_bindgen/bundler/snippets/sedimentree_wasm-75027ecce41278de/inline1.js +2 -0
  17. package/dist/wasm_bindgen/bundler/snippets/sedimentree_wasm-75027ecce41278de/inline2.js +2 -0
  18. package/dist/wasm_bindgen/bundler/snippets/subduction_wasm-ec51bcf335db35bd/inline0.js +8 -0
  19. package/dist/wasm_bindgen/bundler/snippets/subduction_wasm-ec51bcf335db35bd/inline1.js +9 -0
  20. package/dist/wasm_bindgen/bundler/subduction_wasm.d.ts +1706 -0
  21. package/dist/wasm_bindgen/bundler/subduction_wasm.js +9 -0
  22. package/dist/wasm_bindgen/bundler/subduction_wasm_bg.js +4774 -0
  23. package/dist/wasm_bindgen/bundler/subduction_wasm_bg.wasm +0 -0
  24. package/dist/wasm_bindgen/bundler/subduction_wasm_bg.wasm.d.ts +246 -0
  25. package/dist/wasm_bindgen/nodejs/snippets/sedimentree_wasm-75027ecce41278de/inline0.js +2 -0
  26. package/dist/wasm_bindgen/nodejs/snippets/sedimentree_wasm-75027ecce41278de/inline1.js +2 -0
  27. package/dist/wasm_bindgen/nodejs/snippets/sedimentree_wasm-75027ecce41278de/inline2.js +2 -0
  28. package/dist/wasm_bindgen/nodejs/snippets/subduction_wasm-ec51bcf335db35bd/inline0.js +8 -0
  29. package/dist/wasm_bindgen/nodejs/snippets/subduction_wasm-ec51bcf335db35bd/inline1.js +9 -0
  30. package/dist/wasm_bindgen/nodejs/subduction_wasm.cjs +4821 -0
  31. package/dist/wasm_bindgen/nodejs/subduction_wasm.d.ts +1706 -0
  32. package/dist/wasm_bindgen/nodejs/subduction_wasm_bg.wasm +0 -0
  33. package/dist/wasm_bindgen/nodejs/subduction_wasm_bg.wasm.d.ts +246 -0
  34. package/dist/wasm_bindgen/web/snippets/sedimentree_wasm-75027ecce41278de/inline0.js +2 -0
  35. package/dist/wasm_bindgen/web/snippets/sedimentree_wasm-75027ecce41278de/inline1.js +2 -0
  36. package/dist/wasm_bindgen/web/snippets/sedimentree_wasm-75027ecce41278de/inline2.js +2 -0
  37. package/dist/wasm_bindgen/web/snippets/subduction_wasm-ec51bcf335db35bd/inline0.js +8 -0
  38. package/dist/wasm_bindgen/web/snippets/subduction_wasm-ec51bcf335db35bd/inline1.js +9 -0
  39. package/dist/wasm_bindgen/web/subduction_wasm.d.ts +1977 -0
  40. package/dist/wasm_bindgen/web/subduction_wasm.js +4879 -0
  41. package/dist/wasm_bindgen/web/subduction_wasm_bg.wasm +0 -0
  42. package/dist/wasm_bindgen/web/subduction_wasm_bg.wasm.d.ts +246 -0
  43. package/package.json +1 -1
@@ -0,0 +1,4821 @@
1
+ /* @ts-self-types="./subduction_wasm.d.ts" */
2
+ const { tryIntoJsSedimentreeIdsArray } = require(String.raw`./snippets/sedimentree_wasm-75027ecce41278de/inline2.js`);
3
+
4
+ /**
5
+ * An authenticated HTTP long-poll transport.
6
+ *
7
+ * This wrapper proves that the transport has completed the Subduction handshake
8
+ * and the peer identity has been cryptographically verified.
9
+ *
10
+ * Obtain via [`SubductionLongPoll::tryConnect`] or [`SubductionLongPoll::tryDiscover`].
11
+ */
12
+ class AuthenticatedLongPoll {
13
+ static __wrap(ptr) {
14
+ ptr = ptr >>> 0;
15
+ const obj = Object.create(AuthenticatedLongPoll.prototype);
16
+ obj.__wbg_ptr = ptr;
17
+ AuthenticatedLongPollFinalization.register(obj, obj.__wbg_ptr, obj);
18
+ return obj;
19
+ }
20
+ __destroy_into_raw() {
21
+ const ptr = this.__wbg_ptr;
22
+ this.__wbg_ptr = 0;
23
+ AuthenticatedLongPollFinalization.unregister(this);
24
+ return ptr;
25
+ }
26
+ free() {
27
+ const ptr = this.__destroy_into_raw();
28
+ wasm.__wbg_authenticatedlongpoll_free(ptr, 0);
29
+ }
30
+ /**
31
+ * The verified peer identity.
32
+ * @returns {PeerId}
33
+ */
34
+ get peerId() {
35
+ const ret = wasm.authenticatedlongpoll_peerId(this.__wbg_ptr);
36
+ return PeerId.__wrap(ret);
37
+ }
38
+ /**
39
+ * The session ID assigned by the server.
40
+ * @returns {string}
41
+ */
42
+ get sessionId() {
43
+ let deferred1_0;
44
+ let deferred1_1;
45
+ try {
46
+ const ret = wasm.authenticatedlongpoll_sessionId(this.__wbg_ptr);
47
+ deferred1_0 = ret[0];
48
+ deferred1_1 = ret[1];
49
+ return getStringFromWasm0(ret[0], ret[1]);
50
+ } finally {
51
+ wasm.__wbindgen_export5(deferred1_0, deferred1_1, 1);
52
+ }
53
+ }
54
+ /**
55
+ * Convert to a transport-erased [`AuthenticatedTransport`](super::WasmAuthenticatedTransport).
56
+ * @returns {AuthenticatedTransport}
57
+ */
58
+ toTransport() {
59
+ const ptr = this.__destroy_into_raw();
60
+ const ret = wasm.authenticatedlongpoll_toTransport(ptr);
61
+ return AuthenticatedTransport.__wrap(ret);
62
+ }
63
+ }
64
+ if (Symbol.dispose) AuthenticatedLongPoll.prototype[Symbol.dispose] = AuthenticatedLongPoll.prototype.free;
65
+ exports.AuthenticatedLongPoll = AuthenticatedLongPoll;
66
+
67
+ /**
68
+ * A transport-erased authenticated transport.
69
+ *
70
+ * Wraps an [`Authenticated<MessageTransport<JsTransport>>`] and is the common type
71
+ * accepted by [`addConnection`](crate::subduction::WasmSubduction::add_connection).
72
+ *
73
+ * # Construction
74
+ *
75
+ * There are three ways to obtain an `AuthenticatedTransport`:
76
+ *
77
+ * 1. **Custom transport** — implement the `Transport` interface
78
+ * (`sendBytes`/`recvBytes`/`disconnect`/`onDisconnect`) and call
79
+ * [`setup`](Self::setup):
80
+ *
81
+ * ```js
82
+ * const auth = await AuthenticatedTransport.setup(myTransport, signer, peerId, (peerId) => {
83
+ * console.log(`${peerId} disconnected`);
84
+ * });
85
+ * ```
86
+ *
87
+ * 2. **From WebSocket** — authenticate via [`SubductionWebSocket`] then convert:
88
+ *
89
+ * ```js
90
+ * const wsAuth = await SubductionWebSocket.tryConnect(url, signer, peerId, (peerId) => {
91
+ * console.log(`${peerId} disconnected`);
92
+ * });
93
+ * const auth = wsAuth.toTransport();
94
+ * ```
95
+ *
96
+ * 3. **From HTTP long-poll** — same pattern via [`SubductionLongPoll`]:
97
+ *
98
+ * ```js
99
+ * const lpAuth = await SubductionLongPoll.tryConnect(url, signer, peerId, (peerId) => {
100
+ * console.log(`${peerId} disconnected`);
101
+ * });
102
+ * const auth = lpAuth.toTransport();
103
+ * ```
104
+ */
105
+ class AuthenticatedTransport {
106
+ static __wrap(ptr) {
107
+ ptr = ptr >>> 0;
108
+ const obj = Object.create(AuthenticatedTransport.prototype);
109
+ obj.__wbg_ptr = ptr;
110
+ AuthenticatedTransportFinalization.register(obj, obj.__wbg_ptr, obj);
111
+ return obj;
112
+ }
113
+ __destroy_into_raw() {
114
+ const ptr = this.__wbg_ptr;
115
+ this.__wbg_ptr = 0;
116
+ AuthenticatedTransportFinalization.unregister(this);
117
+ return ptr;
118
+ }
119
+ free() {
120
+ const ptr = this.__destroy_into_raw();
121
+ wasm.__wbg_authenticatedtransport_free(ptr, 0);
122
+ }
123
+ /**
124
+ * Accept an incoming handshake over a custom transport (responder side).
125
+ *
126
+ * This is the counterpart to [`setup`](Self::setup). The initiator calls
127
+ * `setup`, and the responder calls `accept` over the same underlying channel.
128
+ *
129
+ * # Arguments
130
+ *
131
+ * * `transport` - A `Transport` implementing `sendBytes`/`recvBytes`/`disconnect`/`onDisconnect`
132
+ * * `signer` - The responder's signer for authentication
133
+ * * `max_drift_seconds` - Maximum acceptable clock drift in seconds (default: 600)
134
+ *
135
+ * # Errors
136
+ *
137
+ * Returns a [`HandshakeError`](WasmHandshakeError) if the handshake fails.
138
+ * @param {Transport} transport
139
+ * @param {any} signer
140
+ * @param {number | null} [max_drift_seconds]
141
+ * @param {Function | null} [on_disconnect]
142
+ * @returns {Promise<AuthenticatedTransport>}
143
+ */
144
+ static accept(transport, signer, max_drift_seconds, on_disconnect) {
145
+ const ret = wasm.authenticatedtransport_accept(transport, signer, isLikeNone(max_drift_seconds) ? 0x100000001 : (max_drift_seconds) >>> 0, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
146
+ return ret;
147
+ }
148
+ /**
149
+ * The verified peer identity.
150
+ * @returns {PeerId}
151
+ */
152
+ get peerId() {
153
+ const ret = wasm.authenticatedtransport_peerId(this.__wbg_ptr);
154
+ return PeerId.__wrap(ret);
155
+ }
156
+ /**
157
+ * Run the Subduction handshake over a custom transport, producing an
158
+ * authenticated transport.
159
+ *
160
+ * The `transport` object must implement the `Transport` interface
161
+ * (`sendBytes`/`recvBytes`/`disconnect`/`onDisconnect`).
162
+ * The same object is used for both the handshake phase and post-handshake
163
+ * communication.
164
+ *
165
+ * # Arguments
166
+ *
167
+ * * `transport` - A `Transport` implementing `sendBytes`/`recvBytes`/`disconnect`/`onDisconnect`
168
+ * * `signer` - The client's signer for authentication
169
+ * * `expected_peer_id` - The expected server peer ID (verified during handshake)
170
+ *
171
+ * # Errors
172
+ *
173
+ * Returns a [`HandshakeError`](WasmHandshakeError) if the handshake fails.
174
+ * @param {Transport} transport
175
+ * @param {any} signer
176
+ * @param {PeerId} expected_peer_id
177
+ * @param {Function | null} [on_disconnect]
178
+ * @returns {Promise<AuthenticatedTransport>}
179
+ */
180
+ static setup(transport, signer, expected_peer_id, on_disconnect) {
181
+ _assertClass(expected_peer_id, PeerId);
182
+ const ret = wasm.authenticatedtransport_setup(transport, signer, expected_peer_id.__wbg_ptr, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
183
+ return ret;
184
+ }
185
+ /**
186
+ * Run the Subduction handshake over a custom transport using discovery
187
+ * mode, producing an authenticated transport.
188
+ *
189
+ * Unlike [`setup`](Self::setup) which requires a known peer ID,
190
+ * this method discovers the peer's identity during the handshake
191
+ * using a shared service name.
192
+ *
193
+ * # Arguments
194
+ *
195
+ * * `transport` - A `Transport` implementing `sendBytes`/`recvBytes`/`disconnect`/`onDisconnect`
196
+ * * `signer` - The client's signer for authentication
197
+ * * `service_name` - Shared service name for discovery.
198
+ * Defaults to [`DEFAULT_LOCAL_SERVICE_NAME`] (`"subduction:local"`) if omitted.
199
+ *
200
+ * # Errors
201
+ *
202
+ * Returns a [`HandshakeError`](WasmHandshakeError) if the handshake fails.
203
+ * @param {Transport} transport
204
+ * @param {any} signer
205
+ * @param {string | null} [service_name]
206
+ * @param {Function | null} [on_disconnect]
207
+ * @returns {Promise<AuthenticatedTransport>}
208
+ */
209
+ static setupDiscover(transport, signer, service_name, on_disconnect) {
210
+ var ptr0 = isLikeNone(service_name) ? 0 : passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
211
+ var len0 = WASM_VECTOR_LEN;
212
+ const ret = wasm.authenticatedtransport_setupDiscover(transport, signer, ptr0, len0, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
213
+ return ret;
214
+ }
215
+ }
216
+ if (Symbol.dispose) AuthenticatedTransport.prototype[Symbol.dispose] = AuthenticatedTransport.prototype.free;
217
+ exports.AuthenticatedTransport = AuthenticatedTransport;
218
+
219
+ /**
220
+ * An authenticated WebSocket transport.
221
+ *
222
+ * This wrapper proves that the connection has completed the Subduction handshake
223
+ * and the peer identity has been cryptographically verified.
224
+ *
225
+ * Obtain via [`SubductionWebSocket::setup`], [`SubductionWebSocket::tryConnect`],
226
+ * or [`SubductionWebSocket::tryDiscover`].
227
+ */
228
+ class AuthenticatedWebSocket {
229
+ static __wrap(ptr) {
230
+ ptr = ptr >>> 0;
231
+ const obj = Object.create(AuthenticatedWebSocket.prototype);
232
+ obj.__wbg_ptr = ptr;
233
+ AuthenticatedWebSocketFinalization.register(obj, obj.__wbg_ptr, obj);
234
+ return obj;
235
+ }
236
+ __destroy_into_raw() {
237
+ const ptr = this.__wbg_ptr;
238
+ this.__wbg_ptr = 0;
239
+ AuthenticatedWebSocketFinalization.unregister(this);
240
+ return ptr;
241
+ }
242
+ free() {
243
+ const ptr = this.__destroy_into_raw();
244
+ wasm.__wbg_authenticatedwebsocket_free(ptr, 0);
245
+ }
246
+ /**
247
+ * The verified peer identity.
248
+ * @returns {PeerId}
249
+ */
250
+ get peerId() {
251
+ const ret = wasm.authenticatedwebsocket_peerId(this.__wbg_ptr);
252
+ return PeerId.__wrap(ret);
253
+ }
254
+ /**
255
+ * Convert to a transport-erased [`AuthenticatedTransport`](super::WasmAuthenticatedTransport).
256
+ * @returns {AuthenticatedTransport}
257
+ */
258
+ toTransport() {
259
+ const ptr = this.__destroy_into_raw();
260
+ const ret = wasm.authenticatedwebsocket_toTransport(ptr);
261
+ return AuthenticatedTransport.__wrap(ret);
262
+ }
263
+ }
264
+ if (Symbol.dispose) AuthenticatedWebSocket.prototype[Symbol.dispose] = AuthenticatedWebSocket.prototype.free;
265
+ exports.AuthenticatedWebSocket = AuthenticatedWebSocket;
266
+
267
+ /**
268
+ * Wasm wrapper for [`BatchSyncRequest`].
269
+ */
270
+ class BatchSyncRequest {
271
+ static __wrap(ptr) {
272
+ ptr = ptr >>> 0;
273
+ const obj = Object.create(BatchSyncRequest.prototype);
274
+ obj.__wbg_ptr = ptr;
275
+ BatchSyncRequestFinalization.register(obj, obj.__wbg_ptr, obj);
276
+ return obj;
277
+ }
278
+ __destroy_into_raw() {
279
+ const ptr = this.__wbg_ptr;
280
+ this.__wbg_ptr = 0;
281
+ BatchSyncRequestFinalization.unregister(this);
282
+ return ptr;
283
+ }
284
+ free() {
285
+ const ptr = this.__destroy_into_raw();
286
+ wasm.__wbg_batchsyncrequest_free(ptr, 0);
287
+ }
288
+ /**
289
+ * The sedimentree ID this request corresponds to.
290
+ * @returns {SedimentreeId}
291
+ */
292
+ id() {
293
+ const ret = wasm.batchsyncrequest_id(this.__wbg_ptr);
294
+ return SedimentreeId.__wrap(ret);
295
+ }
296
+ /**
297
+ * The request ID for this request.
298
+ * @returns {RequestId}
299
+ */
300
+ request_id() {
301
+ const ret = wasm.batchsyncrequest_request_id(this.__wbg_ptr);
302
+ return RequestId.__wrap(ret);
303
+ }
304
+ /**
305
+ * Whether this request subscribes to future updates.
306
+ * @returns {boolean}
307
+ */
308
+ subscribe() {
309
+ const ret = wasm.batchsyncrequest_subscribe(this.__wbg_ptr);
310
+ return ret !== 0;
311
+ }
312
+ }
313
+ if (Symbol.dispose) BatchSyncRequest.prototype[Symbol.dispose] = BatchSyncRequest.prototype.free;
314
+ exports.BatchSyncRequest = BatchSyncRequest;
315
+
316
+ /**
317
+ * Wasm wrapper for [`BatchSyncResponse`].
318
+ */
319
+ class BatchSyncResponse {
320
+ static __wrap(ptr) {
321
+ ptr = ptr >>> 0;
322
+ const obj = Object.create(BatchSyncResponse.prototype);
323
+ obj.__wbg_ptr = ptr;
324
+ BatchSyncResponseFinalization.register(obj, obj.__wbg_ptr, obj);
325
+ return obj;
326
+ }
327
+ __destroy_into_raw() {
328
+ const ptr = this.__wbg_ptr;
329
+ this.__wbg_ptr = 0;
330
+ BatchSyncResponseFinalization.unregister(this);
331
+ return ptr;
332
+ }
333
+ free() {
334
+ const ptr = this.__destroy_into_raw();
335
+ wasm.__wbg_batchsyncresponse_free(ptr, 0);
336
+ }
337
+ /**
338
+ * Upcasts; to the JS-import type for [`WasmBatchSyncResponse`].
339
+ * @returns {BatchSyncResponse}
340
+ */
341
+ __wasm_refgen_toWasmBatchSyncResponse() {
342
+ const ret = wasm.batchsyncresponse___wasm_refgen_toWasmBatchSyncResponse(this.__wbg_ptr);
343
+ return BatchSyncResponse.__wrap(ret);
344
+ }
345
+ /**
346
+ * The sedimentree ID this response corresponds to.
347
+ * @returns {SedimentreeId}
348
+ */
349
+ id() {
350
+ const ret = wasm.batchsyncresponse_id(this.__wbg_ptr);
351
+ return SedimentreeId.__wrap(ret);
352
+ }
353
+ /**
354
+ * The request ID this response corresponds to.
355
+ * @returns {RequestId}
356
+ */
357
+ request_id() {
358
+ const ret = wasm.batchsyncresponse_request_id(this.__wbg_ptr);
359
+ return RequestId.__wrap(ret);
360
+ }
361
+ }
362
+ if (Symbol.dispose) BatchSyncResponse.prototype[Symbol.dispose] = BatchSyncResponse.prototype.free;
363
+ exports.BatchSyncResponse = BatchSyncResponse;
364
+
365
+ /**
366
+ * A Wasm wrapper around the [`BlobMeta`] type.
367
+ */
368
+ class BlobMeta {
369
+ static __wrap(ptr) {
370
+ ptr = ptr >>> 0;
371
+ const obj = Object.create(BlobMeta.prototype);
372
+ obj.__wbg_ptr = ptr;
373
+ BlobMetaFinalization.register(obj, obj.__wbg_ptr, obj);
374
+ return obj;
375
+ }
376
+ __destroy_into_raw() {
377
+ const ptr = this.__wbg_ptr;
378
+ this.__wbg_ptr = 0;
379
+ BlobMetaFinalization.unregister(this);
380
+ return ptr;
381
+ }
382
+ free() {
383
+ const ptr = this.__destroy_into_raw();
384
+ wasm.__wbg_blobmeta_free(ptr, 0);
385
+ }
386
+ /**
387
+ * Get the digest of the blob.
388
+ * @returns {Digest}
389
+ */
390
+ digest() {
391
+ const ret = wasm.blobmeta_digest(this.__wbg_ptr);
392
+ return Digest.__wrap(ret);
393
+ }
394
+ /**
395
+ * Create a `BlobMeta` from a digest and size.
396
+ *
397
+ * This is useful for deserialization when the original blob is not available.
398
+ * Since this is manual, the caller must ensure the digest and size are correct.
399
+ * @param {Digest} digest
400
+ * @param {bigint} size_bytes
401
+ * @returns {BlobMeta}
402
+ */
403
+ static fromDigestSize(digest, size_bytes) {
404
+ _assertClass(digest, Digest);
405
+ const ret = wasm.blobmeta_fromDigestSize(digest.__wbg_ptr, size_bytes);
406
+ return BlobMeta.__wrap(ret);
407
+ }
408
+ /**
409
+ * Create a new `BlobMeta` from the given blob contents.
410
+ * @param {Uint8Array} blob
411
+ */
412
+ constructor(blob) {
413
+ const ptr0 = passArray8ToWasm0(blob, wasm.__wbindgen_export);
414
+ const len0 = WASM_VECTOR_LEN;
415
+ const ret = wasm.blobmeta_new(ptr0, len0);
416
+ this.__wbg_ptr = ret >>> 0;
417
+ BlobMetaFinalization.register(this, this.__wbg_ptr, this);
418
+ return this;
419
+ }
420
+ /**
421
+ * Get the size of the blob in bytes.
422
+ * @returns {bigint}
423
+ */
424
+ get sizeBytes() {
425
+ const ret = wasm.blobmeta_sizeBytes(this.__wbg_ptr);
426
+ return BigInt.asUintN(64, ret);
427
+ }
428
+ }
429
+ if (Symbol.dispose) BlobMeta.prototype[Symbol.dispose] = BlobMeta.prototype.free;
430
+ exports.BlobMeta = BlobMeta;
431
+
432
+ /**
433
+ * Wasm wrapper for call errors.
434
+ */
435
+ class CallError {
436
+ __destroy_into_raw() {
437
+ const ptr = this.__wbg_ptr;
438
+ this.__wbg_ptr = 0;
439
+ CallErrorFinalization.unregister(this);
440
+ return ptr;
441
+ }
442
+ free() {
443
+ const ptr = this.__destroy_into_raw();
444
+ wasm.__wbg_callerror_free(ptr, 0);
445
+ }
446
+ }
447
+ if (Symbol.dispose) CallError.prototype[Symbol.dispose] = CallError.prototype.free;
448
+ exports.CallError = CallError;
449
+
450
+ /**
451
+ * A commit stored with its associated blob.
452
+ */
453
+ class CommitWithBlob {
454
+ static __wrap(ptr) {
455
+ ptr = ptr >>> 0;
456
+ const obj = Object.create(CommitWithBlob.prototype);
457
+ obj.__wbg_ptr = ptr;
458
+ CommitWithBlobFinalization.register(obj, obj.__wbg_ptr, obj);
459
+ return obj;
460
+ }
461
+ __destroy_into_raw() {
462
+ const ptr = this.__wbg_ptr;
463
+ this.__wbg_ptr = 0;
464
+ CommitWithBlobFinalization.unregister(this);
465
+ return ptr;
466
+ }
467
+ free() {
468
+ const ptr = this.__destroy_into_raw();
469
+ wasm.__wbg_commitwithblob_free(ptr, 0);
470
+ }
471
+ /**
472
+ * Upcasts; to the JS-import type for [`WasmCommitWithBlob`].
473
+ * @returns {CommitWithBlob}
474
+ */
475
+ __wasm_refgen_toWasmCommitWithBlob() {
476
+ const ret = wasm.commitwithblob___wasm_refgen_toWasmCommitWithBlob(this.__wbg_ptr);
477
+ return CommitWithBlob.__wrap(ret);
478
+ }
479
+ /**
480
+ * Get the blob.
481
+ * @returns {Uint8Array}
482
+ */
483
+ get blob() {
484
+ const ret = wasm.commitwithblob_blob(this.__wbg_ptr);
485
+ return ret;
486
+ }
487
+ /**
488
+ * Create a new commit with blob.
489
+ * @param {SignedLooseCommit} signed
490
+ * @param {Uint8Array} blob
491
+ */
492
+ constructor(signed, blob) {
493
+ _assertClass(signed, SignedLooseCommit);
494
+ var ptr0 = signed.__destroy_into_raw();
495
+ const ret = wasm.commitwithblob_new(ptr0, blob);
496
+ this.__wbg_ptr = ret >>> 0;
497
+ CommitWithBlobFinalization.register(this, this.__wbg_ptr, this);
498
+ return this;
499
+ }
500
+ /**
501
+ * Get the signed commit.
502
+ * @returns {SignedLooseCommit}
503
+ */
504
+ get signed() {
505
+ const ret = wasm.commitwithblob_signed(this.__wbg_ptr);
506
+ return SignedLooseCommit.__wrap(ret);
507
+ }
508
+ }
509
+ if (Symbol.dispose) CommitWithBlob.prototype[Symbol.dispose] = CommitWithBlob.prototype.free;
510
+ exports.CommitWithBlob = CommitWithBlob;
511
+
512
+ /**
513
+ * A JavaScript wrapper around `Depth`.
514
+ */
515
+ class Depth {
516
+ static __wrap(ptr) {
517
+ ptr = ptr >>> 0;
518
+ const obj = Object.create(Depth.prototype);
519
+ obj.__wbg_ptr = ptr;
520
+ DepthFinalization.register(obj, obj.__wbg_ptr, obj);
521
+ return obj;
522
+ }
523
+ __destroy_into_raw() {
524
+ const ptr = this.__wbg_ptr;
525
+ this.__wbg_ptr = 0;
526
+ DepthFinalization.unregister(this);
527
+ return ptr;
528
+ }
529
+ free() {
530
+ const ptr = this.__destroy_into_raw();
531
+ wasm.__wbg_depth_free(ptr, 0);
532
+ }
533
+ /**
534
+ * Internal method for a hack crossing the JS boundary.
535
+ * @returns {Depth}
536
+ */
537
+ __subduction_castToDepth() {
538
+ const ret = wasm.depth___subduction_castToDepth(this.__wbg_ptr);
539
+ return Depth.__wrap(ret);
540
+ }
541
+ /**
542
+ * Upcasts; to the JS-import type for [`WasmDepth`].
543
+ * @returns {Depth}
544
+ */
545
+ __wasm_refgen_toWasmDepth() {
546
+ const ret = wasm.depth___wasm_refgen_toWasmDepth(this.__wbg_ptr);
547
+ return Depth.__wrap(ret);
548
+ }
549
+ /**
550
+ * Creates a new `WasmDepth` from a JavaScript value.
551
+ *
552
+ * # Errors
553
+ *
554
+ * Returns a `NotU32Error` if the JS value is not safely coercible to `u32`.
555
+ * @param {any} js_value
556
+ */
557
+ constructor(js_value) {
558
+ const ret = wasm.depth_new(js_value);
559
+ if (ret[2]) {
560
+ throw takeFromExternrefTable0(ret[1]);
561
+ }
562
+ this.__wbg_ptr = ret[0] >>> 0;
563
+ DepthFinalization.register(this, this.__wbg_ptr, this);
564
+ return this;
565
+ }
566
+ /**
567
+ * The depth value as an integer.
568
+ * @returns {number}
569
+ */
570
+ get value() {
571
+ const ret = wasm.depth_value(this.__wbg_ptr);
572
+ return ret >>> 0;
573
+ }
574
+ }
575
+ if (Symbol.dispose) Depth.prototype[Symbol.dispose] = Depth.prototype.free;
576
+ exports.Depth = Depth;
577
+
578
+ /**
579
+ * A wrapper around digest bytes for use in JavaScript via wasm-bindgen.
580
+ *
581
+ * Since JavaScript doesn't have Rust's type system, this stores raw bytes
582
+ * and converts to/from typed `Digest<T>` at the Rust boundary.
583
+ */
584
+ class Digest {
585
+ static __wrap(ptr) {
586
+ ptr = ptr >>> 0;
587
+ const obj = Object.create(Digest.prototype);
588
+ obj.__wbg_ptr = ptr;
589
+ DigestFinalization.register(obj, obj.__wbg_ptr, obj);
590
+ return obj;
591
+ }
592
+ static __unwrap(jsValue) {
593
+ if (!(jsValue instanceof Digest)) {
594
+ return 0;
595
+ }
596
+ return jsValue.__destroy_into_raw();
597
+ }
598
+ __destroy_into_raw() {
599
+ const ptr = this.__wbg_ptr;
600
+ this.__wbg_ptr = 0;
601
+ DigestFinalization.unregister(this);
602
+ return ptr;
603
+ }
604
+ free() {
605
+ const ptr = this.__destroy_into_raw();
606
+ wasm.__wbg_digest_free(ptr, 0);
607
+ }
608
+ /**
609
+ * Upcasts; to the JS-import type for [`WasmDigest`].
610
+ * @returns {Digest}
611
+ */
612
+ __wasm_refgen_toWasmDigest() {
613
+ const ret = wasm.digest___wasm_refgen_toWasmDigest(this.__wbg_ptr);
614
+ return Digest.__wrap(ret);
615
+ }
616
+ /**
617
+ * Creates a new digest from its Base58 string representation.
618
+ *
619
+ * # Errors
620
+ *
621
+ * Returns a `WasmInvalidDigest` error if the string cannot be decoded or is not a valid digest.
622
+ * @param {string} s
623
+ * @returns {Digest}
624
+ */
625
+ static fromBase58(s) {
626
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_export, wasm.__wbindgen_export2);
627
+ const len0 = WASM_VECTOR_LEN;
628
+ const ret = wasm.digest_fromBase58(ptr0, len0);
629
+ if (ret[2]) {
630
+ throw takeFromExternrefTable0(ret[1]);
631
+ }
632
+ return Digest.__wrap(ret[0]);
633
+ }
634
+ /**
635
+ * Creates a new digest from its byte representation.
636
+ *
637
+ * # Errors
638
+ *
639
+ * Returns a `WasmValue` error if the byte slice is not a valid digest.
640
+ * @param {Uint8Array} bytes
641
+ * @returns {Digest}
642
+ */
643
+ static fromBytes(bytes) {
644
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
645
+ const len0 = WASM_VECTOR_LEN;
646
+ const ret = wasm.digest_fromBytes(ptr0, len0);
647
+ if (ret[2]) {
648
+ throw takeFromExternrefTable0(ret[1]);
649
+ }
650
+ return Digest.__wrap(ret[0]);
651
+ }
652
+ /**
653
+ * Creates a new digest from its hexadecimal string representation.
654
+ *
655
+ * # Errors
656
+ *
657
+ * Returns a [`WasmInvalidDigest`] if the string is not a valid digest.
658
+ * @param {string} s
659
+ * @returns {Digest}
660
+ */
661
+ static fromHexString(s) {
662
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_export, wasm.__wbindgen_export2);
663
+ const len0 = WASM_VECTOR_LEN;
664
+ const ret = wasm.digest_fromHexString(ptr0, len0);
665
+ if (ret[2]) {
666
+ throw takeFromExternrefTable0(ret[1]);
667
+ }
668
+ return Digest.__wrap(ret[0]);
669
+ }
670
+ /**
671
+ * Creates a new digest from its byte representation.
672
+ *
673
+ * # Errors
674
+ *
675
+ * Returns a `WasmValue` error if the byte slice is not a valid digest.
676
+ * @param {Uint8Array} bytes
677
+ */
678
+ constructor(bytes) {
679
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
680
+ const len0 = WASM_VECTOR_LEN;
681
+ const ret = wasm.digest_new(ptr0, len0);
682
+ if (ret[2]) {
683
+ throw takeFromExternrefTable0(ret[1]);
684
+ }
685
+ this.__wbg_ptr = ret[0] >>> 0;
686
+ DigestFinalization.register(this, this.__wbg_ptr, this);
687
+ return this;
688
+ }
689
+ /**
690
+ * Returns the byte representation of the digest.
691
+ * @returns {Uint8Array}
692
+ */
693
+ toBytes() {
694
+ const ret = wasm.digest_toBytes(this.__wbg_ptr);
695
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
696
+ wasm.__wbindgen_export5(ret[0], ret[1] * 1, 1);
697
+ return v1;
698
+ }
699
+ /**
700
+ * Returns the hexadecimal string representation of the digest.
701
+ * @returns {string}
702
+ */
703
+ toHexString() {
704
+ let deferred1_0;
705
+ let deferred1_1;
706
+ try {
707
+ const ret = wasm.digest_toHexString(this.__wbg_ptr);
708
+ deferred1_0 = ret[0];
709
+ deferred1_1 = ret[1];
710
+ return getStringFromWasm0(ret[0], ret[1]);
711
+ } finally {
712
+ wasm.__wbindgen_export5(deferred1_0, deferred1_1, 1);
713
+ }
714
+ }
715
+ }
716
+ if (Symbol.dispose) Digest.prototype[Symbol.dispose] = Digest.prototype.free;
717
+ exports.Digest = Digest;
718
+
719
+ /**
720
+ * A data fragment used in the Sedimentree system.
721
+ */
722
+ class Fragment {
723
+ static __wrap(ptr) {
724
+ ptr = ptr >>> 0;
725
+ const obj = Object.create(Fragment.prototype);
726
+ obj.__wbg_ptr = ptr;
727
+ FragmentFinalization.register(obj, obj.__wbg_ptr, obj);
728
+ return obj;
729
+ }
730
+ __destroy_into_raw() {
731
+ const ptr = this.__wbg_ptr;
732
+ this.__wbg_ptr = 0;
733
+ FragmentFinalization.unregister(this);
734
+ return ptr;
735
+ }
736
+ free() {
737
+ const ptr = this.__destroy_into_raw();
738
+ wasm.__wbg_fragment_free(ptr, 0);
739
+ }
740
+ /**
741
+ * Upcasts; to the JS-import type for [`WasmFragment`].
742
+ * @returns {Fragment}
743
+ */
744
+ __wasm_refgen_toWasmFragment() {
745
+ const ret = wasm.fragment___wasm_refgen_toWasmFragment(this.__wbg_ptr);
746
+ return Fragment.__wrap(ret);
747
+ }
748
+ /**
749
+ * Get the blob metadata of the fragment.
750
+ * @returns {BlobMeta}
751
+ */
752
+ get blobMeta() {
753
+ const ret = wasm.fragment_blobMeta(this.__wbg_ptr);
754
+ return BlobMeta.__wrap(ret);
755
+ }
756
+ /**
757
+ * Get the boundary digests of the fragment.
758
+ * @returns {Digest[]}
759
+ */
760
+ get boundary() {
761
+ const ret = wasm.fragment_boundary(this.__wbg_ptr);
762
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
763
+ wasm.__wbindgen_export5(ret[0], ret[1] * 4, 4);
764
+ return v1;
765
+ }
766
+ /**
767
+ * Get the head digest of the fragment.
768
+ * @returns {Digest}
769
+ */
770
+ get head() {
771
+ const ret = wasm.fragment_head(this.__wbg_ptr);
772
+ return Digest.__wrap(ret);
773
+ }
774
+ /**
775
+ * Create a new fragment from the given sedimentree ID, head, boundary, checkpoints, and blob metadata.
776
+ * @param {SedimentreeId} sedimentree_id
777
+ * @param {Digest} head
778
+ * @param {Digest[]} boundary
779
+ * @param {Digest[]} checkpoints
780
+ * @param {BlobMeta} blob_meta
781
+ */
782
+ constructor(sedimentree_id, head, boundary, checkpoints, blob_meta) {
783
+ _assertClass(sedimentree_id, SedimentreeId);
784
+ var ptr0 = sedimentree_id.__destroy_into_raw();
785
+ _assertClass(head, Digest);
786
+ var ptr1 = head.__destroy_into_raw();
787
+ const ptr2 = passArrayJsValueToWasm0(boundary, wasm.__wbindgen_export);
788
+ const len2 = WASM_VECTOR_LEN;
789
+ const ptr3 = passArrayJsValueToWasm0(checkpoints, wasm.__wbindgen_export);
790
+ const len3 = WASM_VECTOR_LEN;
791
+ _assertClass(blob_meta, BlobMeta);
792
+ var ptr4 = blob_meta.__destroy_into_raw();
793
+ const ret = wasm.fragment_new(ptr0, ptr1, ptr2, len2, ptr3, len3, ptr4);
794
+ this.__wbg_ptr = ret >>> 0;
795
+ FragmentFinalization.register(this, this.__wbg_ptr, this);
796
+ return this;
797
+ }
798
+ }
799
+ if (Symbol.dispose) Fragment.prototype[Symbol.dispose] = Fragment.prototype.free;
800
+ exports.Fragment = Fragment;
801
+
802
+ /**
803
+ * A request for a specific fragment in the Sedimentree system.
804
+ */
805
+ class FragmentRequested {
806
+ static __wrap(ptr) {
807
+ ptr = ptr >>> 0;
808
+ const obj = Object.create(FragmentRequested.prototype);
809
+ obj.__wbg_ptr = ptr;
810
+ FragmentRequestedFinalization.register(obj, obj.__wbg_ptr, obj);
811
+ return obj;
812
+ }
813
+ __destroy_into_raw() {
814
+ const ptr = this.__wbg_ptr;
815
+ this.__wbg_ptr = 0;
816
+ FragmentRequestedFinalization.unregister(this);
817
+ return ptr;
818
+ }
819
+ free() {
820
+ const ptr = this.__destroy_into_raw();
821
+ wasm.__wbg_fragmentrequested_free(ptr, 0);
822
+ }
823
+ /**
824
+ * Get the depth of the requested fragment.
825
+ * @returns {Depth}
826
+ */
827
+ get depth() {
828
+ const ret = wasm.fragmentrequested_depth(this.__wbg_ptr);
829
+ return Depth.__wrap(ret);
830
+ }
831
+ /**
832
+ * Get the digest of the requested fragment.
833
+ * @returns {Digest}
834
+ */
835
+ get head() {
836
+ const ret = wasm.fragmentrequested_head(this.__wbg_ptr);
837
+ return Digest.__wrap(ret);
838
+ }
839
+ /**
840
+ * Create a new fragment request from the given digest.
841
+ * @param {Digest} digest
842
+ * @param {Depth} depth
843
+ */
844
+ constructor(digest, depth) {
845
+ _assertClass(digest, Digest);
846
+ _assertClass(depth, Depth);
847
+ const ret = wasm.fragmentrequested_new(digest.__wbg_ptr, depth.__wbg_ptr);
848
+ this.__wbg_ptr = ret >>> 0;
849
+ FragmentRequestedFinalization.register(this, this.__wbg_ptr, this);
850
+ return this;
851
+ }
852
+ }
853
+ if (Symbol.dispose) FragmentRequested.prototype[Symbol.dispose] = FragmentRequested.prototype.free;
854
+ exports.FragmentRequested = FragmentRequested;
855
+
856
+ /**
857
+ * A fragment stored with its associated blob.
858
+ */
859
+ class FragmentWithBlob {
860
+ static __wrap(ptr) {
861
+ ptr = ptr >>> 0;
862
+ const obj = Object.create(FragmentWithBlob.prototype);
863
+ obj.__wbg_ptr = ptr;
864
+ FragmentWithBlobFinalization.register(obj, obj.__wbg_ptr, obj);
865
+ return obj;
866
+ }
867
+ __destroy_into_raw() {
868
+ const ptr = this.__wbg_ptr;
869
+ this.__wbg_ptr = 0;
870
+ FragmentWithBlobFinalization.unregister(this);
871
+ return ptr;
872
+ }
873
+ free() {
874
+ const ptr = this.__destroy_into_raw();
875
+ wasm.__wbg_fragmentwithblob_free(ptr, 0);
876
+ }
877
+ /**
878
+ * Upcasts; to the JS-import type for [`WasmFragmentWithBlob`].
879
+ * @returns {FragmentWithBlob}
880
+ */
881
+ __wasm_refgen_toWasmFragmentWithBlob() {
882
+ const ret = wasm.fragmentwithblob___wasm_refgen_toWasmFragmentWithBlob(this.__wbg_ptr);
883
+ return FragmentWithBlob.__wrap(ret);
884
+ }
885
+ /**
886
+ * Get the blob.
887
+ * @returns {Uint8Array}
888
+ */
889
+ get blob() {
890
+ const ret = wasm.fragmentwithblob_blob(this.__wbg_ptr);
891
+ return ret;
892
+ }
893
+ /**
894
+ * Create a new fragment with blob.
895
+ * @param {SignedFragment} signed
896
+ * @param {Uint8Array} blob
897
+ */
898
+ constructor(signed, blob) {
899
+ _assertClass(signed, SignedFragment);
900
+ var ptr0 = signed.__destroy_into_raw();
901
+ const ret = wasm.fragmentwithblob_new(ptr0, blob);
902
+ this.__wbg_ptr = ret >>> 0;
903
+ FragmentWithBlobFinalization.register(this, this.__wbg_ptr, this);
904
+ return this;
905
+ }
906
+ /**
907
+ * Get the signed fragment.
908
+ * @returns {SignedFragment}
909
+ */
910
+ get signed() {
911
+ const ret = wasm.fragmentwithblob_signed(this.__wbg_ptr);
912
+ return SignedFragment.__wrap(ret);
913
+ }
914
+ }
915
+ if (Symbol.dispose) FragmentWithBlob.prototype[Symbol.dispose] = FragmentWithBlob.prototype.free;
916
+ exports.FragmentWithBlob = FragmentWithBlob;
917
+
918
+ class FragmentsArray {
919
+ static __wrap(ptr) {
920
+ ptr = ptr >>> 0;
921
+ const obj = Object.create(FragmentsArray.prototype);
922
+ obj.__wbg_ptr = ptr;
923
+ FragmentsArrayFinalization.register(obj, obj.__wbg_ptr, obj);
924
+ return obj;
925
+ }
926
+ __destroy_into_raw() {
927
+ const ptr = this.__wbg_ptr;
928
+ this.__wbg_ptr = 0;
929
+ FragmentsArrayFinalization.unregister(this);
930
+ return ptr;
931
+ }
932
+ free() {
933
+ const ptr = this.__destroy_into_raw();
934
+ wasm.__wbg_fragmentsarray_free(ptr, 0);
935
+ }
936
+ /**
937
+ * Upcasts; to the JS-import type for [`WasmFragmentsArray`].
938
+ * @returns {FragmentsArray}
939
+ */
940
+ __wasm_refgen_toWasmFragmentsArray() {
941
+ const ret = wasm.fragmentsarray___wasm_refgen_toWasmFragmentsArray(this.__wbg_ptr);
942
+ return FragmentsArray.__wrap(ret);
943
+ }
944
+ }
945
+ if (Symbol.dispose) FragmentsArray.prototype[Symbol.dispose] = FragmentsArray.prototype.free;
946
+ exports.FragmentsArray = FragmentsArray;
947
+
948
+ /**
949
+ * An overridable hash metric.
950
+ */
951
+ class HashMetric {
952
+ __destroy_into_raw() {
953
+ const ptr = this.__wbg_ptr;
954
+ this.__wbg_ptr = 0;
955
+ HashMetricFinalization.unregister(this);
956
+ return ptr;
957
+ }
958
+ free() {
959
+ const ptr = this.__destroy_into_raw();
960
+ wasm.__wbg_hashmetric_free(ptr, 0);
961
+ }
962
+ /**
963
+ * Create a new `WasmHashMetric` with an optional JavaScript function.
964
+ *
965
+ * Defaults to counting leading zero bytes if no function is provided.
966
+ * @param {Function | null} [func]
967
+ */
968
+ constructor(func) {
969
+ const ret = wasm.hashmetric_new(isLikeNone(func) ? 0 : addToExternrefTable0(func));
970
+ this.__wbg_ptr = ret >>> 0;
971
+ HashMetricFinalization.register(this, this.__wbg_ptr, this);
972
+ return this;
973
+ }
974
+ }
975
+ if (Symbol.dispose) HashMetric.prototype[Symbol.dispose] = HashMetric.prototype.free;
976
+ exports.HashMetric = HashMetric;
977
+
978
+ /**
979
+ * A Wasm wrapper around the [`LooseCommit`] type.
980
+ */
981
+ class LooseCommit {
982
+ static __wrap(ptr) {
983
+ ptr = ptr >>> 0;
984
+ const obj = Object.create(LooseCommit.prototype);
985
+ obj.__wbg_ptr = ptr;
986
+ LooseCommitFinalization.register(obj, obj.__wbg_ptr, obj);
987
+ return obj;
988
+ }
989
+ __destroy_into_raw() {
990
+ const ptr = this.__wbg_ptr;
991
+ this.__wbg_ptr = 0;
992
+ LooseCommitFinalization.unregister(this);
993
+ return ptr;
994
+ }
995
+ free() {
996
+ const ptr = this.__destroy_into_raw();
997
+ wasm.__wbg_loosecommit_free(ptr, 0);
998
+ }
999
+ /**
1000
+ * Upcasts; to the JS-import type for [`WasmLooseCommit`].
1001
+ * @returns {LooseCommit}
1002
+ */
1003
+ __wasm_refgen_toWasmLooseCommit() {
1004
+ const ret = wasm.loosecommit___wasm_refgen_toWasmLooseCommit(this.__wbg_ptr);
1005
+ return LooseCommit.__wrap(ret);
1006
+ }
1007
+ /**
1008
+ * Get the blob metadata of the commit.
1009
+ * @returns {BlobMeta}
1010
+ */
1011
+ get blobMeta() {
1012
+ const ret = wasm.loosecommit_blobMeta(this.__wbg_ptr);
1013
+ return BlobMeta.__wrap(ret);
1014
+ }
1015
+ /**
1016
+ * Get the digest of the commit.
1017
+ * @returns {Digest}
1018
+ */
1019
+ get digest() {
1020
+ const ret = wasm.loosecommit_digest(this.__wbg_ptr);
1021
+ return Digest.__wrap(ret);
1022
+ }
1023
+ /**
1024
+ * Create a new `LooseCommit` from the given sedimentree ID, parents, and blob metadata.
1025
+ * @param {SedimentreeId} sedimentree_id
1026
+ * @param {Digest[]} parents
1027
+ * @param {BlobMeta} blob_meta
1028
+ */
1029
+ constructor(sedimentree_id, parents, blob_meta) {
1030
+ _assertClass(sedimentree_id, SedimentreeId);
1031
+ var ptr0 = sedimentree_id.__destroy_into_raw();
1032
+ const ptr1 = passArrayJsValueToWasm0(parents, wasm.__wbindgen_export);
1033
+ const len1 = WASM_VECTOR_LEN;
1034
+ _assertClass(blob_meta, BlobMeta);
1035
+ const ret = wasm.loosecommit_new(ptr0, ptr1, len1, blob_meta.__wbg_ptr);
1036
+ this.__wbg_ptr = ret >>> 0;
1037
+ LooseCommitFinalization.register(this, this.__wbg_ptr, this);
1038
+ return this;
1039
+ }
1040
+ /**
1041
+ * Get the parent digests of the commit.
1042
+ * @returns {Digest[]}
1043
+ */
1044
+ get parents() {
1045
+ const ret = wasm.loosecommit_parents(this.__wbg_ptr);
1046
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
1047
+ wasm.__wbindgen_export5(ret[0], ret[1] * 4, 4);
1048
+ return v1;
1049
+ }
1050
+ }
1051
+ if (Symbol.dispose) LooseCommit.prototype[Symbol.dispose] = LooseCommit.prototype.free;
1052
+ exports.LooseCommit = LooseCommit;
1053
+
1054
+ /**
1055
+ * An in-memory Ed25519 signer exposed to JavaScript.
1056
+ *
1057
+ * Implements the `Signer` interface (`sign` / `verifyingKey`) so it can be
1058
+ * passed anywhere a [`JsSigner`](crate::signer::JsSigner) is expected.
1059
+ *
1060
+ * # Example
1061
+ *
1062
+ * ```javascript
1063
+ * import { MemorySigner } from "@automerge/subduction";
1064
+ *
1065
+ * const signer = MemorySigner.generate();
1066
+ * console.log("Peer ID:", signer.peerId().toString());
1067
+ * ```
1068
+ */
1069
+ class MemorySigner {
1070
+ static __wrap(ptr) {
1071
+ ptr = ptr >>> 0;
1072
+ const obj = Object.create(MemorySigner.prototype);
1073
+ obj.__wbg_ptr = ptr;
1074
+ MemorySignerFinalization.register(obj, obj.__wbg_ptr, obj);
1075
+ return obj;
1076
+ }
1077
+ __destroy_into_raw() {
1078
+ const ptr = this.__wbg_ptr;
1079
+ this.__wbg_ptr = 0;
1080
+ MemorySignerFinalization.unregister(this);
1081
+ return ptr;
1082
+ }
1083
+ free() {
1084
+ const ptr = this.__destroy_into_raw();
1085
+ wasm.__wbg_memorysigner_free(ptr, 0);
1086
+ }
1087
+ /**
1088
+ * Create a signer from raw 32-byte Ed25519 secret key bytes.
1089
+ *
1090
+ * # Errors
1091
+ *
1092
+ * Returns an error if `bytes` is not exactly 32 bytes.
1093
+ * @param {Uint8Array} bytes
1094
+ * @returns {MemorySigner}
1095
+ */
1096
+ static fromBytes(bytes) {
1097
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
1098
+ const len0 = WASM_VECTOR_LEN;
1099
+ const ret = wasm.memorysigner_fromBytes(ptr0, len0);
1100
+ if (ret[2]) {
1101
+ throw takeFromExternrefTable0(ret[1]);
1102
+ }
1103
+ return MemorySigner.__wrap(ret[0]);
1104
+ }
1105
+ /**
1106
+ * Create a new signer with a randomly generated Ed25519 key.
1107
+ *
1108
+ * # Panics
1109
+ *
1110
+ * Panics if the system random number generator fails.
1111
+ * @returns {MemorySigner}
1112
+ */
1113
+ static generate() {
1114
+ const ret = wasm.memorysigner_generate();
1115
+ return MemorySigner.__wrap(ret);
1116
+ }
1117
+ /**
1118
+ * Create a new signer with a randomly generated Ed25519 key.
1119
+ *
1120
+ * This is the JS constructor (`new MemorySigner()`), equivalent to
1121
+ * [`generate`](Self::generate).
1122
+ *
1123
+ * # Panics
1124
+ *
1125
+ * Panics if the system random number generator fails.
1126
+ */
1127
+ constructor() {
1128
+ const ret = wasm.memorysigner_new();
1129
+ this.__wbg_ptr = ret >>> 0;
1130
+ MemorySignerFinalization.register(this, this.__wbg_ptr, this);
1131
+ return this;
1132
+ }
1133
+ /**
1134
+ * Get the peer ID derived from this signer's verifying key.
1135
+ * @returns {PeerId}
1136
+ */
1137
+ peerId() {
1138
+ const ret = wasm.memorysigner_peerId(this.__wbg_ptr);
1139
+ return PeerId.__wrap(ret);
1140
+ }
1141
+ /**
1142
+ * Sign a message and return the 64-byte Ed25519 signature as a `Uint8Array`.
1143
+ *
1144
+ * This fulfils the `Signer.sign(message)` interface contract.
1145
+ * Returns a `Promise<Uint8Array>` for consistency with the async signer interface.
1146
+ * @param {Uint8Array} message
1147
+ * @returns {Promise<Uint8Array>}
1148
+ */
1149
+ sign(message) {
1150
+ const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_export);
1151
+ const len0 = WASM_VECTOR_LEN;
1152
+ const ret = wasm.memorysigner_sign(this.__wbg_ptr, ptr0, len0);
1153
+ return ret;
1154
+ }
1155
+ /**
1156
+ * Get the 32-byte Ed25519 verifying (public) key as a `Uint8Array`.
1157
+ *
1158
+ * This fulfils the `Signer.verifyingKey()` interface contract.
1159
+ * @returns {Uint8Array}
1160
+ */
1161
+ verifyingKey() {
1162
+ const ret = wasm.memorysigner_verifyingKey(this.__wbg_ptr);
1163
+ return ret;
1164
+ }
1165
+ }
1166
+ if (Symbol.dispose) MemorySigner.prototype[Symbol.dispose] = MemorySigner.prototype.free;
1167
+ exports.MemorySigner = MemorySigner;
1168
+
1169
+ /**
1170
+ * An in-memory storage implementation for use in tests and development.
1171
+ *
1172
+ * This wraps the core `MemoryStorage` and exposes it via the `SedimentreeStorage` interface.
1173
+ */
1174
+ class MemoryStorage {
1175
+ __destroy_into_raw() {
1176
+ const ptr = this.__wbg_ptr;
1177
+ this.__wbg_ptr = 0;
1178
+ MemoryStorageFinalization.unregister(this);
1179
+ return ptr;
1180
+ }
1181
+ free() {
1182
+ const ptr = this.__destroy_into_raw();
1183
+ wasm.__wbg_memorystorage_free(ptr, 0);
1184
+ }
1185
+ /**
1186
+ * Delete all commits for a sedimentree.
1187
+ * @param {SedimentreeId} sedimentree_id
1188
+ * @returns {Promise<any>}
1189
+ */
1190
+ deleteAllCommits(sedimentree_id) {
1191
+ _assertClass(sedimentree_id, SedimentreeId);
1192
+ const ret = wasm.memorystorage_deleteAllCommits(this.__wbg_ptr, sedimentree_id.__wbg_ptr);
1193
+ return ret;
1194
+ }
1195
+ /**
1196
+ * Delete all fragments for a sedimentree.
1197
+ * @param {SedimentreeId} sedimentree_id
1198
+ * @returns {Promise<any>}
1199
+ */
1200
+ deleteAllFragments(sedimentree_id) {
1201
+ _assertClass(sedimentree_id, SedimentreeId);
1202
+ const ret = wasm.memorystorage_deleteAllFragments(this.__wbg_ptr, sedimentree_id.__wbg_ptr);
1203
+ return ret;
1204
+ }
1205
+ /**
1206
+ * Delete a commit by digest.
1207
+ * @param {SedimentreeId} sedimentree_id
1208
+ * @param {Digest} digest
1209
+ * @returns {Promise<any>}
1210
+ */
1211
+ deleteCommit(sedimentree_id, digest) {
1212
+ _assertClass(sedimentree_id, SedimentreeId);
1213
+ _assertClass(digest, Digest);
1214
+ const ret = wasm.memorystorage_deleteCommit(this.__wbg_ptr, sedimentree_id.__wbg_ptr, digest.__wbg_ptr);
1215
+ return ret;
1216
+ }
1217
+ /**
1218
+ * Delete a fragment by digest.
1219
+ * @param {SedimentreeId} sedimentree_id
1220
+ * @param {Digest} digest
1221
+ * @returns {Promise<any>}
1222
+ */
1223
+ deleteFragment(sedimentree_id, digest) {
1224
+ _assertClass(sedimentree_id, SedimentreeId);
1225
+ _assertClass(digest, Digest);
1226
+ const ret = wasm.memorystorage_deleteFragment(this.__wbg_ptr, sedimentree_id.__wbg_ptr, digest.__wbg_ptr);
1227
+ return ret;
1228
+ }
1229
+ /**
1230
+ * Delete a sedimentree ID.
1231
+ * @param {SedimentreeId} sedimentree_id
1232
+ * @returns {Promise<any>}
1233
+ */
1234
+ deleteSedimentreeId(sedimentree_id) {
1235
+ _assertClass(sedimentree_id, SedimentreeId);
1236
+ const ret = wasm.memorystorage_deleteSedimentreeId(this.__wbg_ptr, sedimentree_id.__wbg_ptr);
1237
+ return ret;
1238
+ }
1239
+ /**
1240
+ * List all commit digests for a sedimentree.
1241
+ * @param {SedimentreeId} sedimentree_id
1242
+ * @returns {Promise<any>}
1243
+ */
1244
+ listCommitDigests(sedimentree_id) {
1245
+ _assertClass(sedimentree_id, SedimentreeId);
1246
+ const ret = wasm.memorystorage_listCommitDigests(this.__wbg_ptr, sedimentree_id.__wbg_ptr);
1247
+ return ret;
1248
+ }
1249
+ /**
1250
+ * List all fragment digests for a sedimentree.
1251
+ * @param {SedimentreeId} sedimentree_id
1252
+ * @returns {Promise<any>}
1253
+ */
1254
+ listFragmentDigests(sedimentree_id) {
1255
+ _assertClass(sedimentree_id, SedimentreeId);
1256
+ const ret = wasm.memorystorage_listFragmentDigests(this.__wbg_ptr, sedimentree_id.__wbg_ptr);
1257
+ return ret;
1258
+ }
1259
+ /**
1260
+ * Load all commits for a sedimentree, returning `CommitWithBlob[]`.
1261
+ * @param {SedimentreeId} sedimentree_id
1262
+ * @returns {Promise<any>}
1263
+ */
1264
+ loadAllCommits(sedimentree_id) {
1265
+ _assertClass(sedimentree_id, SedimentreeId);
1266
+ const ret = wasm.memorystorage_loadAllCommits(this.__wbg_ptr, sedimentree_id.__wbg_ptr);
1267
+ return ret;
1268
+ }
1269
+ /**
1270
+ * Load all fragments for a sedimentree, returning `FragmentWithBlob[]`.
1271
+ * @param {SedimentreeId} sedimentree_id
1272
+ * @returns {Promise<any>}
1273
+ */
1274
+ loadAllFragments(sedimentree_id) {
1275
+ _assertClass(sedimentree_id, SedimentreeId);
1276
+ const ret = wasm.memorystorage_loadAllFragments(this.__wbg_ptr, sedimentree_id.__wbg_ptr);
1277
+ return ret;
1278
+ }
1279
+ /**
1280
+ * Load all sedimentree IDs.
1281
+ * @returns {Promise<any>}
1282
+ */
1283
+ loadAllSedimentreeIds() {
1284
+ const ret = wasm.memorystorage_loadAllSedimentreeIds(this.__wbg_ptr);
1285
+ return ret;
1286
+ }
1287
+ /**
1288
+ * Load a commit by digest, returning `CommitWithBlob` or null.
1289
+ * @param {SedimentreeId} sedimentree_id
1290
+ * @param {Digest} digest
1291
+ * @returns {Promise<any>}
1292
+ */
1293
+ loadCommit(sedimentree_id, digest) {
1294
+ _assertClass(sedimentree_id, SedimentreeId);
1295
+ _assertClass(digest, Digest);
1296
+ const ret = wasm.memorystorage_loadCommit(this.__wbg_ptr, sedimentree_id.__wbg_ptr, digest.__wbg_ptr);
1297
+ return ret;
1298
+ }
1299
+ /**
1300
+ * Load a fragment by digest, returning `FragmentWithBlob` or null.
1301
+ * @param {SedimentreeId} sedimentree_id
1302
+ * @param {Digest} digest
1303
+ * @returns {Promise<any>}
1304
+ */
1305
+ loadFragment(sedimentree_id, digest) {
1306
+ _assertClass(sedimentree_id, SedimentreeId);
1307
+ _assertClass(digest, Digest);
1308
+ const ret = wasm.memorystorage_loadFragment(this.__wbg_ptr, sedimentree_id.__wbg_ptr, digest.__wbg_ptr);
1309
+ return ret;
1310
+ }
1311
+ /**
1312
+ * Create a new in-memory storage instance.
1313
+ */
1314
+ constructor() {
1315
+ const ret = wasm.memorystorage_new();
1316
+ this.__wbg_ptr = ret >>> 0;
1317
+ MemoryStorageFinalization.register(this, this.__wbg_ptr, this);
1318
+ return this;
1319
+ }
1320
+ /**
1321
+ * Save a commit with its blob.
1322
+ * @param {SedimentreeId} sedimentree_id
1323
+ * @param {Digest} _digest
1324
+ * @param {SignedLooseCommit} signed_commit
1325
+ * @param {Uint8Array} blob
1326
+ * @returns {Promise<any>}
1327
+ */
1328
+ saveCommit(sedimentree_id, _digest, signed_commit, blob) {
1329
+ _assertClass(sedimentree_id, SedimentreeId);
1330
+ _assertClass(_digest, Digest);
1331
+ _assertClass(signed_commit, SignedLooseCommit);
1332
+ const ret = wasm.memorystorage_saveCommit(this.__wbg_ptr, sedimentree_id.__wbg_ptr, _digest.__wbg_ptr, signed_commit.__wbg_ptr, blob);
1333
+ return ret;
1334
+ }
1335
+ /**
1336
+ * Save a fragment with its blob.
1337
+ * @param {SedimentreeId} sedimentree_id
1338
+ * @param {Digest} _digest
1339
+ * @param {SignedFragment} signed_fragment
1340
+ * @param {Uint8Array} blob
1341
+ * @returns {Promise<any>}
1342
+ */
1343
+ saveFragment(sedimentree_id, _digest, signed_fragment, blob) {
1344
+ _assertClass(sedimentree_id, SedimentreeId);
1345
+ _assertClass(_digest, Digest);
1346
+ _assertClass(signed_fragment, SignedFragment);
1347
+ const ret = wasm.memorystorage_saveFragment(this.__wbg_ptr, sedimentree_id.__wbg_ptr, _digest.__wbg_ptr, signed_fragment.__wbg_ptr, blob);
1348
+ return ret;
1349
+ }
1350
+ /**
1351
+ * Save a sedimentree ID.
1352
+ * @param {SedimentreeId} sedimentree_id
1353
+ * @returns {Promise<any>}
1354
+ */
1355
+ saveSedimentreeId(sedimentree_id) {
1356
+ _assertClass(sedimentree_id, SedimentreeId);
1357
+ const ret = wasm.memorystorage_saveSedimentreeId(this.__wbg_ptr, sedimentree_id.__wbg_ptr);
1358
+ return ret;
1359
+ }
1360
+ }
1361
+ if (Symbol.dispose) MemoryStorage.prototype[Symbol.dispose] = MemoryStorage.prototype.free;
1362
+ exports.MemoryStorage = MemoryStorage;
1363
+
1364
+ /**
1365
+ * A `Transport` backed by a `MessagePort` (or any object with
1366
+ * `postMessage` / `onmessage` / `close`).
1367
+ *
1368
+ * Implements the byte-oriented `Transport` interface (`sendBytes`,
1369
+ * `recvBytes`, `disconnect`) using the port as the underlying channel.
1370
+ * After the handshake, the [`Authenticated`] wrapper provides the sync API.
1371
+ */
1372
+ class MessagePortTransport {
1373
+ static __wrap(ptr) {
1374
+ ptr = ptr >>> 0;
1375
+ const obj = Object.create(MessagePortTransport.prototype);
1376
+ obj.__wbg_ptr = ptr;
1377
+ MessagePortTransportFinalization.register(obj, obj.__wbg_ptr, obj);
1378
+ return obj;
1379
+ }
1380
+ __destroy_into_raw() {
1381
+ const ptr = this.__wbg_ptr;
1382
+ this.__wbg_ptr = 0;
1383
+ MessagePortTransportFinalization.unregister(this);
1384
+ return ptr;
1385
+ }
1386
+ free() {
1387
+ const ptr = this.__destroy_into_raw();
1388
+ wasm.__wbg_messageporttransport_free(ptr, 0);
1389
+ }
1390
+ /**
1391
+ * Disconnect (close the port) and fire the `onDisconnect` callback if registered.
1392
+ * @returns {Promise<any>}
1393
+ */
1394
+ disconnect() {
1395
+ const ret = wasm.messageporttransport_disconnect(this.__wbg_ptr);
1396
+ return ret;
1397
+ }
1398
+ /**
1399
+ * Create a new connection wrapping the given `MessagePort`.
1400
+ * @param {any} port
1401
+ */
1402
+ constructor(port) {
1403
+ const ret = wasm.messageporttransport_new(port);
1404
+ this.__wbg_ptr = ret >>> 0;
1405
+ MessagePortTransportFinalization.register(this, this.__wbg_ptr, this);
1406
+ return this;
1407
+ }
1408
+ /**
1409
+ * Register a callback to be invoked when the transport disconnects.
1410
+ *
1411
+ * Part of the [`Transport`](super::JsTransport) interface contract.
1412
+ * Typically called by internal wiring rather than directly by user code.
1413
+ * @param {Function} callback
1414
+ */
1415
+ onDisconnect(callback) {
1416
+ wasm.messageporttransport_onDisconnect(this.__wbg_ptr, callback);
1417
+ }
1418
+ /**
1419
+ * Receive raw bytes (for the handshake phase).
1420
+ * @returns {Promise<any>}
1421
+ */
1422
+ recvBytes() {
1423
+ const ret = wasm.messageporttransport_recvBytes(this.__wbg_ptr);
1424
+ return ret;
1425
+ }
1426
+ /**
1427
+ * Send raw bytes (for the handshake phase).
1428
+ * @param {Uint8Array} bytes
1429
+ * @returns {Promise<any>}
1430
+ */
1431
+ sendBytes(bytes) {
1432
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
1433
+ const len0 = WASM_VECTOR_LEN;
1434
+ const ret = wasm.messageporttransport_sendBytes(this.__wbg_ptr, ptr0, len0);
1435
+ return ret;
1436
+ }
1437
+ }
1438
+ if (Symbol.dispose) MessagePortTransport.prototype[Symbol.dispose] = MessagePortTransport.prototype.free;
1439
+ exports.MessagePortTransport = MessagePortTransport;
1440
+
1441
+ /**
1442
+ * A 64-bit nonce represented as big-endian bytes.
1443
+ */
1444
+ class Nonce {
1445
+ static __wrap(ptr) {
1446
+ ptr = ptr >>> 0;
1447
+ const obj = Object.create(Nonce.prototype);
1448
+ obj.__wbg_ptr = ptr;
1449
+ NonceFinalization.register(obj, obj.__wbg_ptr, obj);
1450
+ return obj;
1451
+ }
1452
+ __destroy_into_raw() {
1453
+ const ptr = this.__wbg_ptr;
1454
+ this.__wbg_ptr = 0;
1455
+ NonceFinalization.unregister(this);
1456
+ return ptr;
1457
+ }
1458
+ free() {
1459
+ const ptr = this.__destroy_into_raw();
1460
+ wasm.__wbg_nonce_free(ptr, 0);
1461
+ }
1462
+ /**
1463
+ * Get the nonce as big-endian bytes.
1464
+ * @returns {Uint8Array}
1465
+ */
1466
+ get bytes() {
1467
+ const ret = wasm.nonce_bytes(this.__wbg_ptr);
1468
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1469
+ wasm.__wbindgen_export5(ret[0], ret[1] * 1, 1);
1470
+ return v1;
1471
+ }
1472
+ /**
1473
+ * Create a new [`WasmNonce`] from exactly 8 big-endian bytes.
1474
+ *
1475
+ * # Errors
1476
+ *
1477
+ * Returns [`WasmNonceError`] if the input is not exactly 8 bytes.
1478
+ * @param {Uint8Array} bytes
1479
+ */
1480
+ constructor(bytes) {
1481
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
1482
+ const len0 = WASM_VECTOR_LEN;
1483
+ const ret = wasm.nonce_new(ptr0, len0);
1484
+ if (ret[2]) {
1485
+ throw takeFromExternrefTable0(ret[1]);
1486
+ }
1487
+ this.__wbg_ptr = ret[0] >>> 0;
1488
+ NonceFinalization.register(this, this.__wbg_ptr, this);
1489
+ return this;
1490
+ }
1491
+ /**
1492
+ * Generate a random nonce.
1493
+ *
1494
+ * # Panics
1495
+ *
1496
+ * Panics if the system random number generator fails.
1497
+ * @returns {Nonce}
1498
+ */
1499
+ static random() {
1500
+ const ret = wasm.nonce_random();
1501
+ return Nonce.__wrap(ret);
1502
+ }
1503
+ }
1504
+ if (Symbol.dispose) Nonce.prototype[Symbol.dispose] = Nonce.prototype.free;
1505
+ exports.Nonce = Nonce;
1506
+
1507
+ /**
1508
+ * Result of a peer batch sync request.
1509
+ */
1510
+ class PeerBatchSyncResult {
1511
+ static __wrap(ptr) {
1512
+ ptr = ptr >>> 0;
1513
+ const obj = Object.create(PeerBatchSyncResult.prototype);
1514
+ obj.__wbg_ptr = ptr;
1515
+ PeerBatchSyncResultFinalization.register(obj, obj.__wbg_ptr, obj);
1516
+ return obj;
1517
+ }
1518
+ __destroy_into_raw() {
1519
+ const ptr = this.__wbg_ptr;
1520
+ this.__wbg_ptr = 0;
1521
+ PeerBatchSyncResultFinalization.unregister(this);
1522
+ return ptr;
1523
+ }
1524
+ free() {
1525
+ const ptr = this.__destroy_into_raw();
1526
+ wasm.__wbg_peerbatchsyncresult_free(ptr, 0);
1527
+ }
1528
+ /**
1529
+ * Statistics about the sync operation.
1530
+ * @returns {SyncStats}
1531
+ */
1532
+ get stats() {
1533
+ const ret = wasm.peerbatchsyncresult_stats(this.__wbg_ptr);
1534
+ return SyncStats.__wrap(ret);
1535
+ }
1536
+ /**
1537
+ * Whether the batch sync was successful with at least one connection.
1538
+ * @returns {boolean}
1539
+ */
1540
+ get success() {
1541
+ const ret = wasm.peerbatchsyncresult_success(this.__wbg_ptr);
1542
+ return ret !== 0;
1543
+ }
1544
+ /**
1545
+ * Errors that occurred during the batch sync.
1546
+ * @returns {Error[]}
1547
+ */
1548
+ get transportErrors() {
1549
+ const ret = wasm.peerbatchsyncresult_transportErrors(this.__wbg_ptr);
1550
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
1551
+ wasm.__wbindgen_export5(ret[0], ret[1] * 4, 4);
1552
+ return v1;
1553
+ }
1554
+ }
1555
+ if (Symbol.dispose) PeerBatchSyncResult.prototype[Symbol.dispose] = PeerBatchSyncResult.prototype.free;
1556
+ exports.PeerBatchSyncResult = PeerBatchSyncResult;
1557
+
1558
+ /**
1559
+ * A JavaScript-compatible wrapper around the Rust `PeerId` type.
1560
+ */
1561
+ class PeerId {
1562
+ static __wrap(ptr) {
1563
+ ptr = ptr >>> 0;
1564
+ const obj = Object.create(PeerId.prototype);
1565
+ obj.__wbg_ptr = ptr;
1566
+ PeerIdFinalization.register(obj, obj.__wbg_ptr, obj);
1567
+ return obj;
1568
+ }
1569
+ __destroy_into_raw() {
1570
+ const ptr = this.__wbg_ptr;
1571
+ this.__wbg_ptr = 0;
1572
+ PeerIdFinalization.unregister(this);
1573
+ return ptr;
1574
+ }
1575
+ free() {
1576
+ const ptr = this.__destroy_into_raw();
1577
+ wasm.__wbg_peerid_free(ptr, 0);
1578
+ }
1579
+ /**
1580
+ * Creates a new `WasmPeerId` from a `PeerId`.
1581
+ *
1582
+ * # Errors
1583
+ *
1584
+ * Returns a `WasmInvalidPeerId` if the provided byte slice is not exactly 32 bytes long.
1585
+ * @param {Uint8Array} bytes
1586
+ */
1587
+ constructor(bytes) {
1588
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
1589
+ const len0 = WASM_VECTOR_LEN;
1590
+ const ret = wasm.peerid_new(ptr0, len0);
1591
+ if (ret[2]) {
1592
+ throw takeFromExternrefTable0(ret[1]);
1593
+ }
1594
+ this.__wbg_ptr = ret[0] >>> 0;
1595
+ PeerIdFinalization.register(this, this.__wbg_ptr, this);
1596
+ return this;
1597
+ }
1598
+ /**
1599
+ * Returns the byte representation of the `PeerId`.
1600
+ * @returns {Uint8Array}
1601
+ */
1602
+ toBytes() {
1603
+ const ret = wasm.peerid_toBytes(this.__wbg_ptr);
1604
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1605
+ wasm.__wbindgen_export5(ret[0], ret[1] * 1, 1);
1606
+ return v1;
1607
+ }
1608
+ /**
1609
+ * Returns the string representation of the `PeerId`.
1610
+ * @returns {string}
1611
+ */
1612
+ toString() {
1613
+ let deferred1_0;
1614
+ let deferred1_1;
1615
+ try {
1616
+ const ret = wasm.peerid_toString(this.__wbg_ptr);
1617
+ deferred1_0 = ret[0];
1618
+ deferred1_1 = ret[1];
1619
+ return getStringFromWasm0(ret[0], ret[1]);
1620
+ } finally {
1621
+ wasm.__wbindgen_export5(deferred1_0, deferred1_1, 1);
1622
+ }
1623
+ }
1624
+ }
1625
+ if (Symbol.dispose) PeerId.prototype[Symbol.dispose] = PeerId.prototype.free;
1626
+ exports.PeerId = PeerId;
1627
+
1628
+ /**
1629
+ * Map of peer IDs to their batch sync results.
1630
+ */
1631
+ class PeerResultMap {
1632
+ static __wrap(ptr) {
1633
+ ptr = ptr >>> 0;
1634
+ const obj = Object.create(PeerResultMap.prototype);
1635
+ obj.__wbg_ptr = ptr;
1636
+ PeerResultMapFinalization.register(obj, obj.__wbg_ptr, obj);
1637
+ return obj;
1638
+ }
1639
+ __destroy_into_raw() {
1640
+ const ptr = this.__wbg_ptr;
1641
+ this.__wbg_ptr = 0;
1642
+ PeerResultMapFinalization.unregister(this);
1643
+ return ptr;
1644
+ }
1645
+ free() {
1646
+ const ptr = this.__destroy_into_raw();
1647
+ wasm.__wbg_peerresultmap_free(ptr, 0);
1648
+ }
1649
+ /**
1650
+ * Get all entries in the peer result map.
1651
+ * @returns {PeerBatchSyncResult[]}
1652
+ */
1653
+ entries() {
1654
+ const ret = wasm.peerresultmap_entries(this.__wbg_ptr);
1655
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
1656
+ wasm.__wbindgen_export5(ret[0], ret[1] * 4, 4);
1657
+ return v1;
1658
+ }
1659
+ /**
1660
+ * Get the result for a specific peer ID.
1661
+ * @param {PeerId} peer_id
1662
+ * @returns {PeerBatchSyncResult | undefined}
1663
+ */
1664
+ getResult(peer_id) {
1665
+ _assertClass(peer_id, PeerId);
1666
+ const ret = wasm.peerresultmap_getResult(this.__wbg_ptr, peer_id.__wbg_ptr);
1667
+ return ret === 0 ? undefined : PeerBatchSyncResult.__wrap(ret);
1668
+ }
1669
+ }
1670
+ if (Symbol.dispose) PeerResultMap.prototype[Symbol.dispose] = PeerResultMap.prototype.free;
1671
+ exports.PeerResultMap = PeerResultMap;
1672
+
1673
+ /**
1674
+ * Wasm wrapper for [`RequestId`].
1675
+ */
1676
+ class RequestId {
1677
+ static __wrap(ptr) {
1678
+ ptr = ptr >>> 0;
1679
+ const obj = Object.create(RequestId.prototype);
1680
+ obj.__wbg_ptr = ptr;
1681
+ RequestIdFinalization.register(obj, obj.__wbg_ptr, obj);
1682
+ return obj;
1683
+ }
1684
+ __destroy_into_raw() {
1685
+ const ptr = this.__wbg_ptr;
1686
+ this.__wbg_ptr = 0;
1687
+ RequestIdFinalization.unregister(this);
1688
+ return ptr;
1689
+ }
1690
+ free() {
1691
+ const ptr = this.__destroy_into_raw();
1692
+ wasm.__wbg_requestid_free(ptr, 0);
1693
+ }
1694
+ /**
1695
+ * Upcasts; to the JS-import type for [`WasmRequestId`].
1696
+ * @returns {RequestId}
1697
+ */
1698
+ __wasm_refgen_toWasmRequestId() {
1699
+ const ret = wasm.requestid___wasm_refgen_toWasmRequestId(this.__wbg_ptr);
1700
+ return RequestId.__wrap(ret);
1701
+ }
1702
+ /**
1703
+ * Create a new [`RequestId`] from a requestor peer ID and nonce.
1704
+ * @param {PeerId} requestor
1705
+ * @param {Nonce} nonce
1706
+ */
1707
+ constructor(requestor, nonce) {
1708
+ _assertClass(requestor, PeerId);
1709
+ _assertClass(nonce, Nonce);
1710
+ const ret = wasm.requestid_new(requestor.__wbg_ptr, nonce.__wbg_ptr);
1711
+ this.__wbg_ptr = ret >>> 0;
1712
+ RequestIdFinalization.register(this, this.__wbg_ptr, this);
1713
+ return this;
1714
+ }
1715
+ /**
1716
+ * The request nonce.
1717
+ * @returns {Nonce}
1718
+ */
1719
+ get nonce() {
1720
+ const ret = wasm.requestid_nonce(this.__wbg_ptr);
1721
+ return Nonce.__wrap(ret);
1722
+ }
1723
+ /**
1724
+ * The peer ID of the requestor.
1725
+ * @returns {PeerId}
1726
+ */
1727
+ get requestor() {
1728
+ const ret = wasm.requestid_requestor(this.__wbg_ptr);
1729
+ return PeerId.__wrap(ret);
1730
+ }
1731
+ }
1732
+ if (Symbol.dispose) RequestId.prototype[Symbol.dispose] = RequestId.prototype.free;
1733
+ exports.RequestId = RequestId;
1734
+
1735
+ /**
1736
+ * The main Sedimentree data structure.
1737
+ */
1738
+ class Sedimentree {
1739
+ static __wrap(ptr) {
1740
+ ptr = ptr >>> 0;
1741
+ const obj = Object.create(Sedimentree.prototype);
1742
+ obj.__wbg_ptr = ptr;
1743
+ SedimentreeFinalization.register(obj, obj.__wbg_ptr, obj);
1744
+ return obj;
1745
+ }
1746
+ __destroy_into_raw() {
1747
+ const ptr = this.__wbg_ptr;
1748
+ this.__wbg_ptr = 0;
1749
+ SedimentreeFinalization.unregister(this);
1750
+ return ptr;
1751
+ }
1752
+ free() {
1753
+ const ptr = this.__destroy_into_raw();
1754
+ wasm.__wbg_sedimentree_free(ptr, 0);
1755
+ }
1756
+ /**
1757
+ * Create an empty Sedimentree.
1758
+ * @returns {Sedimentree}
1759
+ */
1760
+ static empty() {
1761
+ const ret = wasm.sedimentree_empty();
1762
+ return Sedimentree.__wrap(ret);
1763
+ }
1764
+ /**
1765
+ * Create a new Sedimentree from fragments and loose commits.
1766
+ * @param {Fragment[]} fragments
1767
+ * @param {LooseCommit[]} commits
1768
+ */
1769
+ constructor(fragments, commits) {
1770
+ const ptr0 = passArrayJsValueToWasm0(fragments, wasm.__wbindgen_export);
1771
+ const len0 = WASM_VECTOR_LEN;
1772
+ const ptr1 = passArrayJsValueToWasm0(commits, wasm.__wbindgen_export);
1773
+ const len1 = WASM_VECTOR_LEN;
1774
+ const ret = wasm.sedimentree_new(ptr0, len0, ptr1, len1);
1775
+ this.__wbg_ptr = ret >>> 0;
1776
+ SedimentreeFinalization.register(this, this.__wbg_ptr, this);
1777
+ return this;
1778
+ }
1779
+ }
1780
+ if (Symbol.dispose) Sedimentree.prototype[Symbol.dispose] = Sedimentree.prototype.free;
1781
+ exports.Sedimentree = Sedimentree;
1782
+
1783
+ /**
1784
+ * A Wasm wrapper around the [`SedimentreeId`] type.
1785
+ */
1786
+ class SedimentreeId {
1787
+ static __wrap(ptr) {
1788
+ ptr = ptr >>> 0;
1789
+ const obj = Object.create(SedimentreeId.prototype);
1790
+ obj.__wbg_ptr = ptr;
1791
+ SedimentreeIdFinalization.register(obj, obj.__wbg_ptr, obj);
1792
+ return obj;
1793
+ }
1794
+ static __unwrap(jsValue) {
1795
+ if (!(jsValue instanceof SedimentreeId)) {
1796
+ return 0;
1797
+ }
1798
+ return jsValue.__destroy_into_raw();
1799
+ }
1800
+ __destroy_into_raw() {
1801
+ const ptr = this.__wbg_ptr;
1802
+ this.__wbg_ptr = 0;
1803
+ SedimentreeIdFinalization.unregister(this);
1804
+ return ptr;
1805
+ }
1806
+ free() {
1807
+ const ptr = this.__destroy_into_raw();
1808
+ wasm.__wbg_sedimentreeid_free(ptr, 0);
1809
+ }
1810
+ /**
1811
+ * Upcasts; to the JS-import type for [`WasmSedimentreeId`].
1812
+ * @returns {SedimentreeId}
1813
+ */
1814
+ __wasm_refgen_toWasmSedimentreeId() {
1815
+ const ret = wasm.sedimentreeid___wasm_refgen_toWasmSedimentreeId(this.__wbg_ptr);
1816
+ return SedimentreeId.__wrap(ret);
1817
+ }
1818
+ /**
1819
+ * Create an ID from a byte array.
1820
+ *
1821
+ * # Errors
1822
+ *
1823
+ * Returns `Not32Bytes` if the provided byte array is not exactly 32 bytes long.
1824
+ * @param {Uint8Array} bytes
1825
+ * @returns {SedimentreeId}
1826
+ */
1827
+ static fromBytes(bytes) {
1828
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
1829
+ const len0 = WASM_VECTOR_LEN;
1830
+ const ret = wasm.sedimentreeid_fromBytes(ptr0, len0);
1831
+ if (ret[2]) {
1832
+ throw takeFromExternrefTable0(ret[1]);
1833
+ }
1834
+ return SedimentreeId.__wrap(ret[0]);
1835
+ }
1836
+ /**
1837
+ * Returns the raw bytes of this ID.
1838
+ * @returns {Uint8Array}
1839
+ */
1840
+ toBytes() {
1841
+ const ret = wasm.sedimentreeid_toBytes(this.__wbg_ptr);
1842
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1843
+ wasm.__wbindgen_export5(ret[0], ret[1] * 1, 1);
1844
+ return v1;
1845
+ }
1846
+ /**
1847
+ * Returns the string representation of the ID.
1848
+ * @returns {string}
1849
+ */
1850
+ toString() {
1851
+ let deferred1_0;
1852
+ let deferred1_1;
1853
+ try {
1854
+ const ret = wasm.sedimentreeid_toString(this.__wbg_ptr);
1855
+ deferred1_0 = ret[0];
1856
+ deferred1_1 = ret[1];
1857
+ return getStringFromWasm0(ret[0], ret[1]);
1858
+ } finally {
1859
+ wasm.__wbindgen_export5(deferred1_0, deferred1_1, 1);
1860
+ }
1861
+ }
1862
+ }
1863
+ if (Symbol.dispose) SedimentreeId.prototype[Symbol.dispose] = SedimentreeId.prototype.free;
1864
+ exports.SedimentreeId = SedimentreeId;
1865
+
1866
+ class SedimentreeIdsArray {
1867
+ static __wrap(ptr) {
1868
+ ptr = ptr >>> 0;
1869
+ const obj = Object.create(SedimentreeIdsArray.prototype);
1870
+ obj.__wbg_ptr = ptr;
1871
+ SedimentreeIdsArrayFinalization.register(obj, obj.__wbg_ptr, obj);
1872
+ return obj;
1873
+ }
1874
+ __destroy_into_raw() {
1875
+ const ptr = this.__wbg_ptr;
1876
+ this.__wbg_ptr = 0;
1877
+ SedimentreeIdsArrayFinalization.unregister(this);
1878
+ return ptr;
1879
+ }
1880
+ free() {
1881
+ const ptr = this.__destroy_into_raw();
1882
+ wasm.__wbg_sedimentreeidsarray_free(ptr, 0);
1883
+ }
1884
+ /**
1885
+ * Upcasts; to the JS-import type for [`WasmSedimentreeIdsArray`].
1886
+ * @returns {SedimentreeIdsArray}
1887
+ */
1888
+ __wasm_refgen_toWasmSedimentreeIdsArray() {
1889
+ const ret = wasm.sedimentreeidsarray___wasm_refgen_toWasmSedimentreeIdsArray(this.__wbg_ptr);
1890
+ return SedimentreeIdsArray.__wrap(ret);
1891
+ }
1892
+ }
1893
+ if (Symbol.dispose) SedimentreeIdsArray.prototype[Symbol.dispose] = SedimentreeIdsArray.prototype.free;
1894
+ exports.SedimentreeIdsArray = SedimentreeIdsArray;
1895
+
1896
+ /**
1897
+ * A Wasm wrapper around `Signed<Fragment>`.
1898
+ */
1899
+ class SignedFragment {
1900
+ static __wrap(ptr) {
1901
+ ptr = ptr >>> 0;
1902
+ const obj = Object.create(SignedFragment.prototype);
1903
+ obj.__wbg_ptr = ptr;
1904
+ SignedFragmentFinalization.register(obj, obj.__wbg_ptr, obj);
1905
+ return obj;
1906
+ }
1907
+ __destroy_into_raw() {
1908
+ const ptr = this.__wbg_ptr;
1909
+ this.__wbg_ptr = 0;
1910
+ SignedFragmentFinalization.unregister(this);
1911
+ return ptr;
1912
+ }
1913
+ free() {
1914
+ const ptr = this.__destroy_into_raw();
1915
+ wasm.__wbg_signedfragment_free(ptr, 0);
1916
+ }
1917
+ /**
1918
+ * Upcasts; to the JS-import type for [`WasmSignedFragment`].
1919
+ * @returns {SignedFragment}
1920
+ */
1921
+ __wasm_refgen_toWasmSignedFragment() {
1922
+ const ret = wasm.signedfragment___wasm_refgen_toWasmSignedFragment(this.__wbg_ptr);
1923
+ return SignedFragment.__wrap(ret);
1924
+ }
1925
+ /**
1926
+ * Encode this signed fragment to raw bytes.
1927
+ * @returns {Uint8Array}
1928
+ */
1929
+ encode() {
1930
+ const ret = wasm.signedfragment_encode(this.__wbg_ptr);
1931
+ return ret;
1932
+ }
1933
+ /**
1934
+ * Get the unsigned payload without re-verifying the signature.
1935
+ *
1936
+ * # Errors
1937
+ *
1938
+ * Returns an error if the payload cannot be decoded.
1939
+ * @returns {Fragment}
1940
+ */
1941
+ get payload() {
1942
+ const ret = wasm.signedfragment_payload(this.__wbg_ptr);
1943
+ if (ret[2]) {
1944
+ throw takeFromExternrefTable0(ret[1]);
1945
+ }
1946
+ return Fragment.__wrap(ret[0]);
1947
+ }
1948
+ /**
1949
+ * Decode a `SignedFragment` from raw bytes.
1950
+ *
1951
+ * # Errors
1952
+ *
1953
+ * Returns an error if the bytes are not a valid signed fragment.
1954
+ * @param {Uint8Array} bytes
1955
+ * @returns {SignedFragment}
1956
+ */
1957
+ static tryDecode(bytes) {
1958
+ const ret = wasm.signedfragment_tryDecode(bytes);
1959
+ if (ret[2]) {
1960
+ throw takeFromExternrefTable0(ret[1]);
1961
+ }
1962
+ return SignedFragment.__wrap(ret[0]);
1963
+ }
1964
+ }
1965
+ if (Symbol.dispose) SignedFragment.prototype[Symbol.dispose] = SignedFragment.prototype.free;
1966
+ exports.SignedFragment = SignedFragment;
1967
+
1968
+ /**
1969
+ * A Wasm wrapper around `Signed<LooseCommit>`.
1970
+ */
1971
+ class SignedLooseCommit {
1972
+ static __wrap(ptr) {
1973
+ ptr = ptr >>> 0;
1974
+ const obj = Object.create(SignedLooseCommit.prototype);
1975
+ obj.__wbg_ptr = ptr;
1976
+ SignedLooseCommitFinalization.register(obj, obj.__wbg_ptr, obj);
1977
+ return obj;
1978
+ }
1979
+ __destroy_into_raw() {
1980
+ const ptr = this.__wbg_ptr;
1981
+ this.__wbg_ptr = 0;
1982
+ SignedLooseCommitFinalization.unregister(this);
1983
+ return ptr;
1984
+ }
1985
+ free() {
1986
+ const ptr = this.__destroy_into_raw();
1987
+ wasm.__wbg_signedloosecommit_free(ptr, 0);
1988
+ }
1989
+ /**
1990
+ * Upcasts; to the JS-import type for [`WasmSignedLooseCommit`].
1991
+ * @returns {SignedLooseCommit}
1992
+ */
1993
+ __wasm_refgen_toWasmSignedLooseCommit() {
1994
+ const ret = wasm.signedloosecommit___wasm_refgen_toWasmSignedLooseCommit(this.__wbg_ptr);
1995
+ return SignedLooseCommit.__wrap(ret);
1996
+ }
1997
+ /**
1998
+ * Encode this signed loose commit to raw bytes.
1999
+ * @returns {Uint8Array}
2000
+ */
2001
+ encode() {
2002
+ const ret = wasm.signedloosecommit_encode(this.__wbg_ptr);
2003
+ return ret;
2004
+ }
2005
+ /**
2006
+ * Get the unsigned payload without re-verifying the signature.
2007
+ *
2008
+ * # Errors
2009
+ *
2010
+ * Returns an error if the payload cannot be decoded.
2011
+ * @returns {LooseCommit}
2012
+ */
2013
+ get payload() {
2014
+ const ret = wasm.signedloosecommit_payload(this.__wbg_ptr);
2015
+ if (ret[2]) {
2016
+ throw takeFromExternrefTable0(ret[1]);
2017
+ }
2018
+ return LooseCommit.__wrap(ret[0]);
2019
+ }
2020
+ /**
2021
+ * Decode a `SignedLooseCommit` from raw bytes.
2022
+ *
2023
+ * # Errors
2024
+ *
2025
+ * Returns an error if the bytes are not a valid signed loose commit.
2026
+ * @param {Uint8Array} bytes
2027
+ * @returns {SignedLooseCommit}
2028
+ */
2029
+ static tryDecode(bytes) {
2030
+ const ret = wasm.signedloosecommit_tryDecode(bytes);
2031
+ if (ret[2]) {
2032
+ throw takeFromExternrefTable0(ret[1]);
2033
+ }
2034
+ return SignedLooseCommit.__wrap(ret[0]);
2035
+ }
2036
+ }
2037
+ if (Symbol.dispose) SignedLooseCommit.prototype[Symbol.dispose] = SignedLooseCommit.prototype.free;
2038
+ exports.SignedLooseCommit = SignedLooseCommit;
2039
+
2040
+ /**
2041
+ * Wasm bindings for [`Subduction`](subduction_core::Subduction)
2042
+ */
2043
+ class Subduction {
2044
+ static __wrap(ptr) {
2045
+ ptr = ptr >>> 0;
2046
+ const obj = Object.create(Subduction.prototype);
2047
+ obj.__wbg_ptr = ptr;
2048
+ SubductionFinalization.register(obj, obj.__wbg_ptr, obj);
2049
+ return obj;
2050
+ }
2051
+ __destroy_into_raw() {
2052
+ const ptr = this.__wbg_ptr;
2053
+ this.__wbg_ptr = 0;
2054
+ SubductionFinalization.unregister(this);
2055
+ return ptr;
2056
+ }
2057
+ free() {
2058
+ const ptr = this.__destroy_into_raw();
2059
+ wasm.__wbg_subduction_free(ptr, 0);
2060
+ }
2061
+ /**
2062
+ * Accept a connection from a peer over any [`Transport`](JsTransport).
2063
+ *
2064
+ * Performs the responder side of the handshake, then adds the authenticated
2065
+ * connection. This is the counterpart to [`connectTransport`](Self::connect_transport).
2066
+ *
2067
+ * # Arguments
2068
+ *
2069
+ * * `transport` - Any JS object with `sendBytes`/`recvBytes`/`disconnect`
2070
+ * * `service_name` - Shared service name for discovery
2071
+ *
2072
+ * # Errors
2073
+ *
2074
+ * Returns an error if the handshake or connection fails.
2075
+ * @param {Transport} transport
2076
+ * @param {string} service_name
2077
+ * @returns {Promise<PeerId>}
2078
+ */
2079
+ acceptTransport(transport, service_name) {
2080
+ const ptr0 = passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2081
+ const len0 = WASM_VECTOR_LEN;
2082
+ const ret = wasm.subduction_acceptTransport(this.__wbg_ptr, transport, ptr0, len0);
2083
+ return ret;
2084
+ }
2085
+ /**
2086
+ * Add a commit with its associated blob to the storage.
2087
+ *
2088
+ * The commit metadata (including `BlobMeta`) is computed internally from
2089
+ * the provided blob, ensuring consistency by construction.
2090
+ *
2091
+ * # Errors
2092
+ *
2093
+ * Returns a [`WasmWriteError`] if storage, networking, or policy fail.
2094
+ * @param {SedimentreeId} id
2095
+ * @param {Digest[]} parents
2096
+ * @param {Uint8Array} blob
2097
+ * @returns {Promise<FragmentRequested | undefined>}
2098
+ */
2099
+ addCommit(id, parents, blob) {
2100
+ _assertClass(id, SedimentreeId);
2101
+ const ptr0 = passArrayJsValueToWasm0(parents, wasm.__wbindgen_export);
2102
+ const len0 = WASM_VECTOR_LEN;
2103
+ const ret = wasm.subduction_addCommit(this.__wbg_ptr, id.__wbg_ptr, ptr0, len0, blob);
2104
+ return ret;
2105
+ }
2106
+ /**
2107
+ * Onboard an authenticated transport: add it and sync all sedimentrees.
2108
+ *
2109
+ * Accepts an [`AuthenticatedTransport`](WasmAuthenticatedTransport),
2110
+ * obtained via [`AuthenticatedTransport.setup`](WasmAuthenticatedTransport::setup),
2111
+ * [`AuthenticatedWebSocket.toTransport`], or [`AuthenticatedLongPoll.toTransport`].
2112
+ *
2113
+ * Returns `true` if this is a new peer, `false` if already connected.
2114
+ *
2115
+ * Add an authenticated transport to tracking.
2116
+ *
2117
+ * This does not perform any synchronization. To sync after adding,
2118
+ * call [`fullSyncWithPeer`](Self::full_sync_with_peer).
2119
+ *
2120
+ * Returns `true` if this is a new peer, `false` if already connected.
2121
+ *
2122
+ * # Errors
2123
+ *
2124
+ * Returns an error if the connection is rejected by the policy.
2125
+ * @param {AuthenticatedTransport} transport
2126
+ * @returns {Promise<boolean>}
2127
+ */
2128
+ addConnection(transport) {
2129
+ _assertClass(transport, AuthenticatedTransport);
2130
+ const ret = wasm.subduction_addConnection(this.__wbg_ptr, transport.__wbg_ptr);
2131
+ return ret;
2132
+ }
2133
+ /**
2134
+ * Add a fragment with its associated blob to the storage.
2135
+ *
2136
+ * The fragment metadata (including `BlobMeta`) is computed internally from
2137
+ * the provided blob, ensuring consistency by construction.
2138
+ *
2139
+ * # Errors
2140
+ *
2141
+ * Returns a [`WasmWriteError`] if storage, networking, or policy fail.
2142
+ * @param {SedimentreeId} id
2143
+ * @param {Digest} head
2144
+ * @param {Digest[]} boundary
2145
+ * @param {Digest[]} checkpoints
2146
+ * @param {Uint8Array} blob
2147
+ * @returns {Promise<void>}
2148
+ */
2149
+ addFragment(id, head, boundary, checkpoints, blob) {
2150
+ _assertClass(id, SedimentreeId);
2151
+ _assertClass(head, Digest);
2152
+ const ptr0 = passArrayJsValueToWasm0(boundary, wasm.__wbindgen_export);
2153
+ const len0 = WASM_VECTOR_LEN;
2154
+ const ptr1 = passArrayJsValueToWasm0(checkpoints, wasm.__wbindgen_export);
2155
+ const len1 = WASM_VECTOR_LEN;
2156
+ const ret = wasm.subduction_addFragment(this.__wbg_ptr, id.__wbg_ptr, head.__wbg_ptr, ptr0, len0, ptr1, len1, blob);
2157
+ return ret;
2158
+ }
2159
+ /**
2160
+ * Add a Sedimentree.
2161
+ *
2162
+ * # Errors
2163
+ *
2164
+ * Returns [`WasmWriteError`] if there is a problem with storage, networking, or policy.
2165
+ * @param {SedimentreeId} id
2166
+ * @param {Sedimentree} sedimentree
2167
+ * @param {Uint8Array[]} blobs
2168
+ * @returns {Promise<void>}
2169
+ */
2170
+ addSedimentree(id, sedimentree, blobs) {
2171
+ _assertClass(id, SedimentreeId);
2172
+ _assertClass(sedimentree, Sedimentree);
2173
+ const ptr0 = passArrayJsValueToWasm0(blobs, wasm.__wbindgen_export);
2174
+ const len0 = WASM_VECTOR_LEN;
2175
+ const ret = wasm.subduction_addSedimentree(this.__wbg_ptr, id.__wbg_ptr, sedimentree.__wbg_ptr, ptr0, len0);
2176
+ return ret;
2177
+ }
2178
+ /**
2179
+ * Connect to a peer via WebSocket and add the connection.
2180
+ *
2181
+ * This performs the cryptographic handshake, verifies the server's identity,
2182
+ * and adds the authenticated connection for syncing.
2183
+ *
2184
+ * Returns the verified peer ID on success.
2185
+ *
2186
+ * # Arguments
2187
+ *
2188
+ * * `address` - The WebSocket URL to connect to
2189
+ * * `expected_peer_id` - The expected server peer ID (verified during handshake)
2190
+ *
2191
+ * # Errors
2192
+ *
2193
+ * Returns an error if connection, handshake, or adding the connection fails.
2194
+ * @param {URL} address
2195
+ * @param {PeerId} expected_peer_id
2196
+ * @returns {Promise<PeerId>}
2197
+ */
2198
+ connect(address, expected_peer_id) {
2199
+ _assertClass(expected_peer_id, PeerId);
2200
+ const ret = wasm.subduction_connect(this.__wbg_ptr, address, expected_peer_id.__wbg_ptr);
2201
+ return ret;
2202
+ }
2203
+ /**
2204
+ * Connect to a peer via WebSocket using discovery mode and add the connection.
2205
+ *
2206
+ * Returns the discovered and verified peer ID on success.
2207
+ *
2208
+ * # Arguments
2209
+ *
2210
+ * * `address` - The WebSocket URL to connect to
2211
+ * * `timeout_milliseconds` - Request timeout in milliseconds (defaults to 30000)
2212
+ * * `service_name` - The service name for discovery (defaults to URL host)
2213
+ *
2214
+ * # Errors
2215
+ *
2216
+ * Returns an error if connection, handshake, or adding the connection fails.
2217
+ * @param {URL} address
2218
+ * @param {string | null} [service_name]
2219
+ * @returns {Promise<PeerId>}
2220
+ */
2221
+ connectDiscover(address, service_name) {
2222
+ var ptr0 = isLikeNone(service_name) ? 0 : passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2223
+ var len0 = WASM_VECTOR_LEN;
2224
+ const ret = wasm.subduction_connectDiscover(this.__wbg_ptr, address, ptr0, len0);
2225
+ return ret;
2226
+ }
2227
+ /**
2228
+ * Connect to a peer via HTTP long-poll using discovery mode.
2229
+ *
2230
+ * Returns the discovered and verified peer ID on success.
2231
+ *
2232
+ * # Arguments
2233
+ *
2234
+ * * `base_url` - The server's HTTP base URL (e.g., `http://localhost:8080`)
2235
+ * * `timeout_milliseconds` - Request timeout in milliseconds (default: 30000)
2236
+ * * `service_name` - The service name for discovery (defaults to `base_url`)
2237
+ *
2238
+ * # Errors
2239
+ *
2240
+ * Returns an error if connection, handshake, or adding the connection fails.
2241
+ * @param {string} base_url
2242
+ * @param {string | null} [service_name]
2243
+ * @returns {Promise<PeerId>}
2244
+ */
2245
+ connectDiscoverLongPoll(base_url, service_name) {
2246
+ const ptr0 = passStringToWasm0(base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2247
+ const len0 = WASM_VECTOR_LEN;
2248
+ var ptr1 = isLikeNone(service_name) ? 0 : passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2249
+ var len1 = WASM_VECTOR_LEN;
2250
+ const ret = wasm.subduction_connectDiscoverLongPoll(this.__wbg_ptr, ptr0, len0, ptr1, len1);
2251
+ return ret;
2252
+ }
2253
+ /**
2254
+ * Connect to a peer via HTTP long-poll and add the connection.
2255
+ *
2256
+ * Returns the verified peer ID on success.
2257
+ *
2258
+ * # Arguments
2259
+ *
2260
+ * * `base_url` - The server's HTTP base URL (e.g., `http://localhost:8080`)
2261
+ * * `expected_peer_id` - The expected server peer ID (verified during handshake)
2262
+ * * `timeout_milliseconds` - Request timeout in milliseconds (default: 30000)
2263
+ *
2264
+ * # Errors
2265
+ *
2266
+ * Returns an error if connection, handshake, or adding the connection fails.
2267
+ * @param {string} base_url
2268
+ * @param {PeerId} expected_peer_id
2269
+ * @returns {Promise<PeerId>}
2270
+ */
2271
+ connectLongPoll(base_url, expected_peer_id) {
2272
+ const ptr0 = passStringToWasm0(base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2273
+ const len0 = WASM_VECTOR_LEN;
2274
+ _assertClass(expected_peer_id, PeerId);
2275
+ const ret = wasm.subduction_connectLongPoll(this.__wbg_ptr, ptr0, len0, expected_peer_id.__wbg_ptr);
2276
+ return ret;
2277
+ }
2278
+ /**
2279
+ * Connect to a peer over any [`Transport`](JsTransport) using discovery mode.
2280
+ *
2281
+ * Performs a discovery handshake, then adds the authenticated connection.
2282
+ * The peer's identity is discovered during the handshake.
2283
+ *
2284
+ * # Arguments
2285
+ *
2286
+ * * `transport` - Any JS object with `sendBytes`/`recvBytes`/`disconnect`
2287
+ * * `service_name` - Shared service name for discovery
2288
+ *
2289
+ * # Errors
2290
+ *
2291
+ * Returns an error if the handshake or connection fails.
2292
+ * @param {Transport} transport
2293
+ * @param {string} service_name
2294
+ * @returns {Promise<PeerId>}
2295
+ */
2296
+ connectTransport(transport, service_name) {
2297
+ const ptr0 = passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2298
+ const len0 = WASM_VECTOR_LEN;
2299
+ const ret = wasm.subduction_connectTransport(this.__wbg_ptr, transport, ptr0, len0);
2300
+ return ret;
2301
+ }
2302
+ /**
2303
+ * Disconnect from all peers.
2304
+ *
2305
+ * # Errors
2306
+ *
2307
+ * Returns a [`WasmDisconnectionError`] if disconnection was not graceful.
2308
+ * @returns {Promise<void>}
2309
+ */
2310
+ disconnectAll() {
2311
+ const ret = wasm.subduction_disconnectAll(this.__wbg_ptr);
2312
+ return ret;
2313
+ }
2314
+ /**
2315
+ * Disconnect from a peer by its ID.
2316
+ *
2317
+ * # Errors
2318
+ *
2319
+ * Returns a `WasmDisconnectionError` if disconnection fails.
2320
+ * @param {PeerId} peer_id
2321
+ * @returns {Promise<boolean>}
2322
+ */
2323
+ disconnectFromPeer(peer_id) {
2324
+ _assertClass(peer_id, PeerId);
2325
+ const ret = wasm.subduction_disconnectFromPeer(this.__wbg_ptr, peer_id.__wbg_ptr);
2326
+ return ret;
2327
+ }
2328
+ /**
2329
+ * Fetch blobs by their digests, with an optional timeout in milliseconds.
2330
+ *
2331
+ * # Errors
2332
+ *
2333
+ * Returns a [`WasmIoError`] if storage or networking fail.
2334
+ * @param {SedimentreeId} id
2335
+ * @param {bigint | null} [timeout_milliseconds]
2336
+ * @returns {Promise<Uint8Array[] | undefined>}
2337
+ */
2338
+ fetchBlobs(id, timeout_milliseconds) {
2339
+ _assertClass(id, SedimentreeId);
2340
+ const ret = wasm.subduction_fetchBlobs(this.__wbg_ptr, id.__wbg_ptr, !isLikeNone(timeout_milliseconds), isLikeNone(timeout_milliseconds) ? BigInt(0) : timeout_milliseconds);
2341
+ return ret;
2342
+ }
2343
+ /**
2344
+ * Sync all known Sedimentree IDs with all connected peers.
2345
+ * @param {bigint | null} [timeout_milliseconds]
2346
+ * @returns {Promise<PeerBatchSyncResult>}
2347
+ */
2348
+ fullSyncWithAllPeers(timeout_milliseconds) {
2349
+ const ret = wasm.subduction_fullSyncWithAllPeers(this.__wbg_ptr, !isLikeNone(timeout_milliseconds), isLikeNone(timeout_milliseconds) ? BigInt(0) : timeout_milliseconds);
2350
+ return ret;
2351
+ }
2352
+ /**
2353
+ * Sync all known Sedimentree IDs with a single peer.
2354
+ *
2355
+ * # Arguments
2356
+ *
2357
+ * * `peer_id` - The peer to sync with
2358
+ * * `subscribe` - Whether to subscribe to future updates (default: `true`)
2359
+ * * `timeout_milliseconds` - Per-call timeout in milliseconds
2360
+ * @param {PeerId} peer_id
2361
+ * @param {boolean | null} [subscribe]
2362
+ * @param {bigint | null} [timeout_milliseconds]
2363
+ * @returns {Promise<PeerBatchSyncResult>}
2364
+ */
2365
+ fullSyncWithPeer(peer_id, subscribe, timeout_milliseconds) {
2366
+ _assertClass(peer_id, PeerId);
2367
+ const ret = wasm.subduction_fullSyncWithPeer(this.__wbg_ptr, peer_id.__wbg_ptr, isLikeNone(subscribe) ? 0xFFFFFF : subscribe ? 1 : 0, !isLikeNone(timeout_milliseconds), isLikeNone(timeout_milliseconds) ? BigInt(0) : timeout_milliseconds);
2368
+ return ret;
2369
+ }
2370
+ /**
2371
+ * Get a local blob by its digest.
2372
+ *
2373
+ * # Errors
2374
+ *
2375
+ * Returns a [`JsStorageError`] if JS storage fails.
2376
+ * @param {SedimentreeId} id
2377
+ * @param {Digest} digest
2378
+ * @returns {Promise<Uint8Array | undefined>}
2379
+ */
2380
+ getBlob(id, digest) {
2381
+ _assertClass(id, SedimentreeId);
2382
+ _assertClass(digest, Digest);
2383
+ const ret = wasm.subduction_getBlob(this.__wbg_ptr, id.__wbg_ptr, digest.__wbg_ptr);
2384
+ return ret;
2385
+ }
2386
+ /**
2387
+ * Get all local blobs for a given Sedimentree ID.
2388
+ *
2389
+ * # Errors
2390
+ *
2391
+ * Returns a [`JsStorageError`] if JS storage fails.
2392
+ * @param {SedimentreeId} id
2393
+ * @returns {Promise<Uint8Array[]>}
2394
+ */
2395
+ getBlobs(id) {
2396
+ _assertClass(id, SedimentreeId);
2397
+ const ret = wasm.subduction_getBlobs(this.__wbg_ptr, id.__wbg_ptr);
2398
+ return ret;
2399
+ }
2400
+ /**
2401
+ * Get all commits for a given Sedimentree ID
2402
+ * @param {SedimentreeId} id
2403
+ * @returns {Promise<LooseCommit[] | undefined>}
2404
+ */
2405
+ getCommits(id) {
2406
+ _assertClass(id, SedimentreeId);
2407
+ const ret = wasm.subduction_getCommits(this.__wbg_ptr, id.__wbg_ptr);
2408
+ return ret;
2409
+ }
2410
+ /**
2411
+ * Get the peer IDs of all connected peers.
2412
+ * @returns {Promise<PeerId[]>}
2413
+ */
2414
+ getConnectedPeerIds() {
2415
+ const ret = wasm.subduction_getConnectedPeerIds(this.__wbg_ptr);
2416
+ return ret;
2417
+ }
2418
+ /**
2419
+ * Get all fragments for a given Sedimentree ID
2420
+ * @param {SedimentreeId} id
2421
+ * @returns {Promise<Fragment[] | undefined>}
2422
+ */
2423
+ getFragments(id) {
2424
+ _assertClass(id, SedimentreeId);
2425
+ const ret = wasm.subduction_getFragments(this.__wbg_ptr, id.__wbg_ptr);
2426
+ return ret;
2427
+ }
2428
+ /**
2429
+ * Hydrate a [`Subduction`] instance from external storage.
2430
+ *
2431
+ * Loads all sedimentree data from storage and reconstructs the in-memory
2432
+ * state before initializing the sync engine.
2433
+ *
2434
+ * # Arguments
2435
+ *
2436
+ * * `signer` - The cryptographic signer for this node's identity
2437
+ * * `storage` - Storage backend for persisting data
2438
+ * * `service_name` - Optional service identifier for discovery mode (e.g., `sync.example.com`).
2439
+ * When set, clients can connect without knowing the server's peer ID.
2440
+ * * `hash_metric_override` - Optional custom depth metric function
2441
+ * * `max_pending_blob_requests` - Optional maximum number of pending blob requests (default: 10,000)
2442
+ * * `policy` - Optional connection/storage authorization policy.
2443
+ * Defaults to allow-all.
2444
+ * * `ephemeral_policy` - Optional ephemeral message authorization policy.
2445
+ * Defaults to allow-all.
2446
+ *
2447
+ * # Panics
2448
+ *
2449
+ * Panics if `hash_metric_override` is `Some` but the underlying JS value
2450
+ * cannot be cast to a `Function`.
2451
+ *
2452
+ * # Errors
2453
+ *
2454
+ * Returns [`WasmHydrationError`] if hydration fails.
2455
+ * @param {any} signer
2456
+ * @param {SedimentreeStorage} storage
2457
+ * @param {string | null} [service_name]
2458
+ * @param {(digest: Digest) => Depth | null} [hash_metric_override]
2459
+ * @param {number | null} [max_pending_blob_requests]
2460
+ * @param {Policy | null} [policy]
2461
+ * @param {EphemeralPolicy | null} [ephemeral_policy]
2462
+ * @param {Function | null} [on_remote_heads]
2463
+ * @param {Function | null} [on_ephemeral]
2464
+ * @returns {Promise<Subduction>}
2465
+ */
2466
+ static hydrate(signer, storage, service_name, hash_metric_override, max_pending_blob_requests, policy, ephemeral_policy, on_remote_heads, on_ephemeral) {
2467
+ var ptr0 = isLikeNone(service_name) ? 0 : passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2468
+ var len0 = WASM_VECTOR_LEN;
2469
+ 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(ephemeral_policy) ? 0 : addToExternrefTable0(ephemeral_policy), isLikeNone(on_remote_heads) ? 0 : addToExternrefTable0(on_remote_heads), isLikeNone(on_ephemeral) ? 0 : addToExternrefTable0(on_ephemeral));
2470
+ return ret;
2471
+ }
2472
+ /**
2473
+ * Link two local [`Subduction`](WasmSubduction) instances over a
2474
+ * [`MessageChannel`](web_sys::MessageChannel).
2475
+ *
2476
+ * Creates a `MessageChannel`, performs a discovery handshake between
2477
+ * the two instances, and adds the connections to both. This is the
2478
+ * simplest way to sync two local instances.
2479
+ *
2480
+ * # Errors
2481
+ *
2482
+ * Returns an error if the handshake or connection fails.
2483
+ * @param {Subduction} a
2484
+ * @param {Subduction} b
2485
+ * @returns {Promise<void>}
2486
+ */
2487
+ static link(a, b) {
2488
+ _assertClass(a, Subduction);
2489
+ _assertClass(b, Subduction);
2490
+ const ret = wasm.subduction_link(a.__wbg_ptr, b.__wbg_ptr);
2491
+ return ret;
2492
+ }
2493
+ /**
2494
+ * Create a new [`Subduction`] instance.
2495
+ *
2496
+ * # Arguments
2497
+ *
2498
+ * * `signer` - The cryptographic signer for this node's identity
2499
+ * * `storage` - Storage backend for persisting data
2500
+ * * `service_name` - Optional service identifier for discovery mode (e.g., `sync.example.com`).
2501
+ * When set, clients can connect without knowing the server's peer ID.
2502
+ * * `hash_metric_override` - Optional custom depth metric function
2503
+ * * `max_pending_blob_requests` - Optional maximum number of pending blob requests (default: 10,000)
2504
+ * * `policy` - Optional connection/storage authorization policy.
2505
+ * Defaults to allow-all.
2506
+ * * `ephemeral_policy` - Optional ephemeral message authorization policy.
2507
+ * Defaults to allow-all.
2508
+ *
2509
+ * # Panics
2510
+ *
2511
+ * Panics if `hash_metric_override` is `Some` but the underlying JS value
2512
+ * cannot be cast to a `Function`.
2513
+ * @param {any} signer
2514
+ * @param {SedimentreeStorage} storage
2515
+ * @param {string | null} [service_name]
2516
+ * @param {(digest: Digest) => Depth | null} [hash_metric_override]
2517
+ * @param {number | null} [max_pending_blob_requests]
2518
+ * @param {Policy | null} [policy]
2519
+ * @param {EphemeralPolicy | null} [ephemeral_policy]
2520
+ * @param {Function | null} [on_remote_heads]
2521
+ * @param {Function | null} [on_ephemeral]
2522
+ */
2523
+ constructor(signer, storage, service_name, hash_metric_override, max_pending_blob_requests, policy, ephemeral_policy, on_remote_heads, on_ephemeral) {
2524
+ var ptr0 = isLikeNone(service_name) ? 0 : passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2525
+ var len0 = WASM_VECTOR_LEN;
2526
+ 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(ephemeral_policy) ? 0 : addToExternrefTable0(ephemeral_policy), isLikeNone(on_remote_heads) ? 0 : addToExternrefTable0(on_remote_heads), isLikeNone(on_ephemeral) ? 0 : addToExternrefTable0(on_ephemeral));
2527
+ this.__wbg_ptr = ret >>> 0;
2528
+ SubductionFinalization.register(this, this.__wbg_ptr, this);
2529
+ return this;
2530
+ }
2531
+ /**
2532
+ * Publish an ephemeral message to all subscribers of a topic.
2533
+ *
2534
+ * The payload is opaque bytes — encoding is the caller's responsibility.
2535
+ * Messages are fire-and-forget; delivery is best-effort.
2536
+ *
2537
+ * # Panics
2538
+ *
2539
+ * Panics if the platform's random number generator fails.
2540
+ * @param {Topic} topic
2541
+ * @param {Uint8Array} payload
2542
+ * @returns {Promise<void>}
2543
+ */
2544
+ publishEphemeral(topic, payload) {
2545
+ _assertClass(topic, Topic);
2546
+ const ptr0 = passArray8ToWasm0(payload, wasm.__wbindgen_export);
2547
+ const len0 = WASM_VECTOR_LEN;
2548
+ const ret = wasm.subduction_publishEphemeral(this.__wbg_ptr, topic.__wbg_ptr, ptr0, len0);
2549
+ return ret;
2550
+ }
2551
+ /**
2552
+ * Remove a Sedimentree and all associated data.
2553
+ *
2554
+ * # Errors
2555
+ *
2556
+ * Returns a [`WasmIoError`] if storage or networking fail.
2557
+ * @param {SedimentreeId} id
2558
+ * @returns {Promise<void>}
2559
+ */
2560
+ removeSedimentree(id) {
2561
+ _assertClass(id, SedimentreeId);
2562
+ const ret = wasm.subduction_removeSedimentree(this.__wbg_ptr, id.__wbg_ptr);
2563
+ return ret;
2564
+ }
2565
+ /**
2566
+ * Request blobs by their digests from connected peers for a specific sedimentree.
2567
+ * @param {SedimentreeId} id
2568
+ * @param {Digest[]} digests
2569
+ * @returns {Promise<void>}
2570
+ */
2571
+ requestBlobs(id, digests) {
2572
+ _assertClass(id, SedimentreeId);
2573
+ const ptr0 = passArrayJsValueToWasm0(digests, wasm.__wbindgen_export);
2574
+ const len0 = WASM_VECTOR_LEN;
2575
+ const ret = wasm.subduction_requestBlobs(this.__wbg_ptr, id.__wbg_ptr, ptr0, len0);
2576
+ return ret;
2577
+ }
2578
+ /**
2579
+ * Get all known Sedimentree IDs
2580
+ * @returns {Promise<SedimentreeId[]>}
2581
+ */
2582
+ sedimentreeIds() {
2583
+ const ret = wasm.subduction_sedimentreeIds(this.__wbg_ptr);
2584
+ return ret;
2585
+ }
2586
+ /**
2587
+ * Get the backing storage.
2588
+ * @returns {any}
2589
+ */
2590
+ get storage() {
2591
+ const ret = wasm.subduction_storage(this.__wbg_ptr);
2592
+ return ret;
2593
+ }
2594
+ /**
2595
+ * Subscribe to ephemeral messages for the given topics
2596
+ * from all connected peers.
2597
+ * @param {Topic[]} topics
2598
+ * @returns {Promise<void>}
2599
+ */
2600
+ subscribeEphemeral(topics) {
2601
+ const ptr0 = passArrayJsValueToWasm0(topics, wasm.__wbindgen_export);
2602
+ const len0 = WASM_VECTOR_LEN;
2603
+ const ret = wasm.subduction_subscribeEphemeral(this.__wbg_ptr, ptr0, len0);
2604
+ return ret;
2605
+ }
2606
+ /**
2607
+ * Request batch sync for a given Sedimentree ID from all connected peers.
2608
+ *
2609
+ * # Arguments
2610
+ *
2611
+ * * `id` - The sedimentree ID to sync
2612
+ * * `subscribe` - Whether to subscribe for incremental updates
2613
+ * * `timeout_milliseconds` - Optional timeout in milliseconds
2614
+ *
2615
+ * # Errors
2616
+ *
2617
+ * Returns a [`WasmIoError`] if storage or networking fail.
2618
+ * @param {SedimentreeId} id
2619
+ * @param {boolean} subscribe
2620
+ * @param {bigint | null} [timeout_milliseconds]
2621
+ * @returns {Promise<PeerResultMap>}
2622
+ */
2623
+ syncWithAllPeers(id, subscribe, timeout_milliseconds) {
2624
+ _assertClass(id, SedimentreeId);
2625
+ const ret = wasm.subduction_syncWithAllPeers(this.__wbg_ptr, id.__wbg_ptr, subscribe, !isLikeNone(timeout_milliseconds), isLikeNone(timeout_milliseconds) ? BigInt(0) : timeout_milliseconds);
2626
+ return ret;
2627
+ }
2628
+ /**
2629
+ * Request batch sync for a given Sedimentree ID from a specific peer.
2630
+ *
2631
+ * # Arguments
2632
+ *
2633
+ * * `to_ask` - The peer ID to sync with
2634
+ * * `id` - The sedimentree ID to sync
2635
+ * * `subscribe` - Whether to subscribe for incremental updates
2636
+ * * `timeout_milliseconds` - Optional timeout in milliseconds
2637
+ *
2638
+ * # Errors
2639
+ *
2640
+ * Returns a [`WasmIoError`] if storage or networking fail.
2641
+ * @param {PeerId} to_ask
2642
+ * @param {SedimentreeId} id
2643
+ * @param {boolean} subscribe
2644
+ * @param {bigint | null} [timeout_milliseconds]
2645
+ * @returns {Promise<PeerBatchSyncResult>}
2646
+ */
2647
+ syncWithPeer(to_ask, id, subscribe, timeout_milliseconds) {
2648
+ _assertClass(to_ask, PeerId);
2649
+ _assertClass(id, SedimentreeId);
2650
+ 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);
2651
+ return ret;
2652
+ }
2653
+ /**
2654
+ * Unsubscribe from ephemeral messages for the given topics
2655
+ * from all connected peers.
2656
+ * @param {Topic[]} topics
2657
+ * @returns {Promise<void>}
2658
+ */
2659
+ unsubscribeEphemeral(topics) {
2660
+ const ptr0 = passArrayJsValueToWasm0(topics, wasm.__wbindgen_export);
2661
+ const len0 = WASM_VECTOR_LEN;
2662
+ const ret = wasm.subduction_unsubscribeEphemeral(this.__wbg_ptr, ptr0, len0);
2663
+ return ret;
2664
+ }
2665
+ }
2666
+ if (Symbol.dispose) Subduction.prototype[Symbol.dispose] = Subduction.prototype.free;
2667
+ exports.Subduction = Subduction;
2668
+
2669
+ /**
2670
+ * JS-facing wrapper around [`HttpLongPollTransport`] that exposes the
2671
+ * byte-oriented [`Transport`](super::JsTransport) interface
2672
+ * (`sendBytes`/`recvBytes`/`disconnect`/`onDisconnect`) so it can be used as a
2673
+ * duck-typed `JsTransport` from JavaScript.
2674
+ */
2675
+ class SubductionHttpLongPoll {
2676
+ static __wrap(ptr) {
2677
+ ptr = ptr >>> 0;
2678
+ const obj = Object.create(SubductionHttpLongPoll.prototype);
2679
+ obj.__wbg_ptr = ptr;
2680
+ SubductionHttpLongPollFinalization.register(obj, obj.__wbg_ptr, obj);
2681
+ return obj;
2682
+ }
2683
+ __destroy_into_raw() {
2684
+ const ptr = this.__wbg_ptr;
2685
+ this.__wbg_ptr = 0;
2686
+ SubductionHttpLongPollFinalization.unregister(this);
2687
+ return ptr;
2688
+ }
2689
+ free() {
2690
+ const ptr = this.__destroy_into_raw();
2691
+ wasm.__wbg_subductionhttplongpoll_free(ptr, 0);
2692
+ }
2693
+ /**
2694
+ * Disconnect from the peer gracefully.
2695
+ *
2696
+ * Fires the `onDisconnect` callback if one is registered.
2697
+ *
2698
+ * # Errors
2699
+ *
2700
+ * Returns an error if the disconnect fails.
2701
+ * @returns {Promise<void>}
2702
+ */
2703
+ disconnect() {
2704
+ const ret = wasm.subductionhttplongpoll_disconnect(this.__wbg_ptr);
2705
+ return ret;
2706
+ }
2707
+ /**
2708
+ * Register a callback to be invoked when the transport disconnects.
2709
+ *
2710
+ * Part of the [`Transport`](super::JsTransport) interface contract.
2711
+ * Typically called by internal wiring rather than directly by user code.
2712
+ * @param {Function} callback
2713
+ */
2714
+ onDisconnect(callback) {
2715
+ wasm.subductionhttplongpoll_onDisconnect(this.__wbg_ptr, callback);
2716
+ }
2717
+ /**
2718
+ * Receive the next message frame as raw bytes.
2719
+ *
2720
+ * # Errors
2721
+ *
2722
+ * Returns an error if the inbound channel is closed.
2723
+ * @returns {Promise<Uint8Array>}
2724
+ */
2725
+ recvBytes() {
2726
+ const ret = wasm.subductionhttplongpoll_recvBytes(this.__wbg_ptr);
2727
+ return ret;
2728
+ }
2729
+ /**
2730
+ * Send raw bytes over the transport.
2731
+ *
2732
+ * # Errors
2733
+ *
2734
+ * Returns an error if the outbound channel is closed.
2735
+ * @param {Uint8Array} bytes
2736
+ * @returns {Promise<void>}
2737
+ */
2738
+ sendBytes(bytes) {
2739
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
2740
+ const len0 = WASM_VECTOR_LEN;
2741
+ const ret = wasm.subductionhttplongpoll_sendBytes(this.__wbg_ptr, ptr0, len0);
2742
+ return ret;
2743
+ }
2744
+ }
2745
+ if (Symbol.dispose) SubductionHttpLongPoll.prototype[Symbol.dispose] = SubductionHttpLongPoll.prototype.free;
2746
+ exports.SubductionHttpLongPoll = SubductionHttpLongPoll;
2747
+
2748
+ /**
2749
+ * HTTP long-poll transport factory for browser/worker environments.
2750
+ *
2751
+ * Analogous to [`SubductionWebSocket`] but uses HTTP long-poll instead of WebSocket.
2752
+ */
2753
+ class SubductionLongPoll {
2754
+ __destroy_into_raw() {
2755
+ const ptr = this.__wbg_ptr;
2756
+ this.__wbg_ptr = 0;
2757
+ SubductionLongPollFinalization.unregister(this);
2758
+ return ptr;
2759
+ }
2760
+ free() {
2761
+ const ptr = this.__destroy_into_raw();
2762
+ wasm.__wbg_subductionlongpoll_free(ptr, 0);
2763
+ }
2764
+ /**
2765
+ * Connect to a server with a known peer ID.
2766
+ *
2767
+ * # Arguments
2768
+ *
2769
+ * * `base_url` - The server's HTTP base URL (e.g., `http://localhost:8080`)
2770
+ * * `signer` - The client's signer for authentication
2771
+ * * `expected_peer_id` - The expected server peer ID (verified during handshake)
2772
+ * * `on_disconnect` - Optional callback invoked with the peer's [`PeerId`] when the connection closes
2773
+ *
2774
+ * # Errors
2775
+ *
2776
+ * Returns [`LongPollTransportError`] if connection or handshake fails.
2777
+ * @param {string} base_url
2778
+ * @param {any} signer
2779
+ * @param {PeerId} expected_peer_id
2780
+ * @param {Function | null} [on_disconnect]
2781
+ * @returns {Promise<AuthenticatedLongPoll>}
2782
+ */
2783
+ static tryConnect(base_url, signer, expected_peer_id, on_disconnect) {
2784
+ const ptr0 = passStringToWasm0(base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2785
+ const len0 = WASM_VECTOR_LEN;
2786
+ _assertClass(expected_peer_id, PeerId);
2787
+ const ret = wasm.subductionlongpoll_tryConnect(ptr0, len0, signer, expected_peer_id.__wbg_ptr, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
2788
+ return ret;
2789
+ }
2790
+ /**
2791
+ * Connect to a server using discovery mode.
2792
+ *
2793
+ * # Arguments
2794
+ *
2795
+ * * `base_url` - The server's HTTP base URL (e.g., `http://localhost:8080`)
2796
+ * * `signer` - The client's signer for authentication
2797
+ * * `service_name` - The service name for discovery. If omitted, the base URL is used.
2798
+ *
2799
+ * # Errors
2800
+ *
2801
+ * Returns [`LongPollTransportError`] if connection or handshake fails.
2802
+ * @param {string} base_url
2803
+ * @param {any} signer
2804
+ * @param {string | null} [service_name]
2805
+ * @param {Function | null} [on_disconnect]
2806
+ * @returns {Promise<AuthenticatedLongPoll>}
2807
+ */
2808
+ static tryDiscover(base_url, signer, service_name, on_disconnect) {
2809
+ const ptr0 = passStringToWasm0(base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2810
+ const len0 = WASM_VECTOR_LEN;
2811
+ var ptr1 = isLikeNone(service_name) ? 0 : passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2812
+ var len1 = WASM_VECTOR_LEN;
2813
+ const ret = wasm.subductionlongpoll_tryDiscover(ptr0, len0, signer, ptr1, len1, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
2814
+ return ret;
2815
+ }
2816
+ }
2817
+ if (Symbol.dispose) SubductionLongPoll.prototype[Symbol.dispose] = SubductionLongPoll.prototype.free;
2818
+ exports.SubductionLongPoll = SubductionLongPoll;
2819
+
2820
+ /**
2821
+ * A WebSocket transport exposing the byte-oriented `Transport` interface.
2822
+ *
2823
+ * Raw bytes from the WebSocket's `onmessage` handler are buffered in an
2824
+ * `async_channel` and returned via `recvBytes`. No message decoding or
2825
+ * request-response routing happens here — that's handled by
2826
+ * [`MessageTransport`](subduction_core::transport::message::MessageTransport).
2827
+ */
2828
+ class SubductionWebSocket {
2829
+ static __wrap(ptr) {
2830
+ ptr = ptr >>> 0;
2831
+ const obj = Object.create(SubductionWebSocket.prototype);
2832
+ obj.__wbg_ptr = ptr;
2833
+ SubductionWebSocketFinalization.register(obj, obj.__wbg_ptr, obj);
2834
+ return obj;
2835
+ }
2836
+ __destroy_into_raw() {
2837
+ const ptr = this.__wbg_ptr;
2838
+ this.__wbg_ptr = 0;
2839
+ SubductionWebSocketFinalization.unregister(this);
2840
+ return ptr;
2841
+ }
2842
+ free() {
2843
+ const ptr = this.__destroy_into_raw();
2844
+ wasm.__wbg_subductionwebsocket_free(ptr, 0);
2845
+ }
2846
+ /**
2847
+ * Disconnect from the peer gracefully.
2848
+ * @returns {Promise<void>}
2849
+ */
2850
+ disconnect() {
2851
+ const ret = wasm.subductionwebsocket_disconnect(this.__wbg_ptr);
2852
+ return ret;
2853
+ }
2854
+ /**
2855
+ * Register a callback to be invoked when the WebSocket closes.
2856
+ *
2857
+ * Part of the [`Transport`](super::JsTransport) interface contract.
2858
+ * Typically called by internal wiring (factory methods like `tryConnect`
2859
+ * and `tryDiscover`) rather than directly by user code.
2860
+ *
2861
+ * The callback is fired from the browser WebSocket's `onclose` handler.
2862
+ * @param {Function} callback
2863
+ */
2864
+ onDisconnect(callback) {
2865
+ wasm.subductionwebsocket_onDisconnect(this.__wbg_ptr, callback);
2866
+ }
2867
+ /**
2868
+ * Receive the next message frame as raw bytes.
2869
+ *
2870
+ * # Errors
2871
+ *
2872
+ * Returns [`ReadFromClosedChannel`] if the channel has been closed.
2873
+ * @returns {Promise<Uint8Array>}
2874
+ */
2875
+ recvBytes() {
2876
+ const ret = wasm.subductionwebsocket_recvBytes(this.__wbg_ptr);
2877
+ return ret;
2878
+ }
2879
+ /**
2880
+ * Send raw bytes over the WebSocket.
2881
+ *
2882
+ * # Errors
2883
+ *
2884
+ * Returns [`WasmSendError`] if the bytes could not be sent.
2885
+ * @param {Uint8Array} bytes
2886
+ * @returns {Promise<void>}
2887
+ */
2888
+ sendBytes(bytes) {
2889
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
2890
+ const len0 = WASM_VECTOR_LEN;
2891
+ const ret = wasm.subductionwebsocket_sendBytes(this.__wbg_ptr, ptr0, len0);
2892
+ return ret;
2893
+ }
2894
+ /**
2895
+ * Authenticate an existing WebSocket via handshake.
2896
+ *
2897
+ * This performs the Subduction handshake protocol over the provided WebSocket
2898
+ * to establish mutual identity. The WebSocket can be in CONNECTING or OPEN state.
2899
+ *
2900
+ * # Arguments
2901
+ *
2902
+ * * `ws` - An existing WebSocket (CONNECTING or OPEN)
2903
+ * * `signer` - The client's signer for authentication
2904
+ * * `expected_peer_id` - The expected server peer ID (verified during handshake)
2905
+ * * `on_disconnect` - Optional callback invoked with the peer's [`PeerId`] when the connection closes
2906
+ *
2907
+ * # Errors
2908
+ *
2909
+ * Returns an error if the handshake fails (signature invalid, wrong peer, etc.)
2910
+ * @param {WebSocket} ws
2911
+ * @param {any} signer
2912
+ * @param {PeerId} expected_peer_id
2913
+ * @param {Function | null} [on_disconnect]
2914
+ * @returns {Promise<AuthenticatedWebSocket>}
2915
+ */
2916
+ static setup(ws, signer, expected_peer_id, on_disconnect) {
2917
+ _assertClass(expected_peer_id, PeerId);
2918
+ const ret = wasm.subductionwebsocket_setup(ws, signer, expected_peer_id.__wbg_ptr, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
2919
+ return ret;
2920
+ }
2921
+ /**
2922
+ * Connect to a WebSocket server with mutual authentication via handshake.
2923
+ *
2924
+ * # Arguments
2925
+ *
2926
+ * * `address` - The WebSocket URL to connect to
2927
+ * * `signer` - The client's signer for authentication
2928
+ * * `expected_peer_id` - The expected server peer ID (verified during handshake)
2929
+ * * `on_disconnect` - Optional callback invoked with the peer's [`PeerId`] when the connection closes
2930
+ *
2931
+ * # Errors
2932
+ *
2933
+ * Returns an error if:
2934
+ * - The WebSocket connection could not be established
2935
+ * - The handshake fails (signature invalid, wrong server, clock drift, etc.)
2936
+ * @param {URL} address
2937
+ * @param {any} signer
2938
+ * @param {PeerId} expected_peer_id
2939
+ * @param {Function | null} [on_disconnect]
2940
+ * @returns {Promise<AuthenticatedWebSocket>}
2941
+ */
2942
+ static tryConnect(address, signer, expected_peer_id, on_disconnect) {
2943
+ _assertClass(expected_peer_id, PeerId);
2944
+ const ret = wasm.subductionwebsocket_tryConnect(address, signer, expected_peer_id.__wbg_ptr, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
2945
+ return ret;
2946
+ }
2947
+ /**
2948
+ * Connect to a WebSocket server using discovery mode.
2949
+ *
2950
+ * This method performs a cryptographic handshake using a service name
2951
+ * instead of a known peer ID. The server's peer ID is discovered during
2952
+ * the handshake and returned.
2953
+ *
2954
+ * # Arguments
2955
+ *
2956
+ * * `address` - The WebSocket URL to connect to
2957
+ * * `signer` - The client's signer for authentication
2958
+ * * `service_name` - The service name for discovery (e.g., `localhost:8080`).
2959
+ * If omitted, the host is extracted from the URL.
2960
+ * * `on_disconnect` - Optional callback invoked with the peer's [`PeerId`] when the connection closes
2961
+ *
2962
+ * # Errors
2963
+ *
2964
+ * Returns an error if:
2965
+ * - The WebSocket connection could not be established
2966
+ * - The handshake fails (signature invalid, clock drift, etc.)
2967
+ * @param {URL} address
2968
+ * @param {any} signer
2969
+ * @param {string | null} [service_name]
2970
+ * @param {Function | null} [on_disconnect]
2971
+ * @returns {Promise<AuthenticatedWebSocket>}
2972
+ */
2973
+ static tryDiscover(address, signer, service_name, on_disconnect) {
2974
+ var ptr0 = isLikeNone(service_name) ? 0 : passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2975
+ var len0 = WASM_VECTOR_LEN;
2976
+ const ret = wasm.subductionwebsocket_tryDiscover(address, signer, ptr0, len0, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
2977
+ return ret;
2978
+ }
2979
+ }
2980
+ if (Symbol.dispose) SubductionWebSocket.prototype[Symbol.dispose] = SubductionWebSocket.prototype.free;
2981
+ exports.SubductionWebSocket = SubductionWebSocket;
2982
+
2983
+ /**
2984
+ * Wasm wrapper for [`SyncMessage`].
2985
+ */
2986
+ class SyncMessage {
2987
+ static __wrap(ptr) {
2988
+ ptr = ptr >>> 0;
2989
+ const obj = Object.create(SyncMessage.prototype);
2990
+ obj.__wbg_ptr = ptr;
2991
+ SyncMessageFinalization.register(obj, obj.__wbg_ptr, obj);
2992
+ return obj;
2993
+ }
2994
+ __destroy_into_raw() {
2995
+ const ptr = this.__wbg_ptr;
2996
+ this.__wbg_ptr = 0;
2997
+ SyncMessageFinalization.unregister(this);
2998
+ return ptr;
2999
+ }
3000
+ free() {
3001
+ const ptr = this.__destroy_into_raw();
3002
+ wasm.__wbg_syncmessage_free(ptr, 0);
3003
+ }
3004
+ /**
3005
+ * Upcasts; to the JS-import type for [`WasmMessage`].
3006
+ * @returns {SyncMessage}
3007
+ */
3008
+ __wasm_refgen_toWasmMessage() {
3009
+ const ret = wasm.syncmessage___wasm_refgen_toWasmMessage(this.__wbg_ptr);
3010
+ return SyncMessage.__wrap(ret);
3011
+ }
3012
+ /**
3013
+ * Create a [`SyncMessage::BatchSyncRequest`] message.
3014
+ * @param {BatchSyncRequest} request
3015
+ * @returns {SyncMessage}
3016
+ */
3017
+ static batchSyncRequest(request) {
3018
+ _assertClass(request, BatchSyncRequest);
3019
+ const ret = wasm.syncmessage_batchSyncRequest(request.__wbg_ptr);
3020
+ return SyncMessage.__wrap(ret);
3021
+ }
3022
+ /**
3023
+ * Create a [`SyncMessage::BatchSyncResponse`] message.
3024
+ * @param {BatchSyncResponse} response
3025
+ * @returns {SyncMessage}
3026
+ */
3027
+ static batchSyncResponse(response) {
3028
+ _assertClass(response, BatchSyncResponse);
3029
+ const ret = wasm.syncmessage_batchSyncResponse(response.__wbg_ptr);
3030
+ return SyncMessage.__wrap(ret);
3031
+ }
3032
+ /**
3033
+ * The [`Blob`] for commit or fragment messages, if applicable.
3034
+ * @returns {Uint8Array | undefined}
3035
+ */
3036
+ get blob() {
3037
+ const ret = wasm.syncmessage_blob(this.__wbg_ptr);
3038
+ return ret;
3039
+ }
3040
+ /**
3041
+ * The [`Blob`]s for a [`SyncMessage::BlobsResponse`], if applicable.
3042
+ * @returns {Uint8Array[] | undefined}
3043
+ */
3044
+ get blobs() {
3045
+ const ret = wasm.syncmessage_blobs(this.__wbg_ptr);
3046
+ let v1;
3047
+ if (ret[0] !== 0) {
3048
+ v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
3049
+ wasm.__wbindgen_export5(ret[0], ret[1] * 4, 4);
3050
+ }
3051
+ return v1;
3052
+ }
3053
+ /**
3054
+ * Create a [`SyncMessage::BlobsRequest`] message.
3055
+ * @param {SedimentreeId} id
3056
+ * @param {Digest[]} digests
3057
+ * @returns {SyncMessage}
3058
+ */
3059
+ static blobsRequest(id, digests) {
3060
+ _assertClass(id, SedimentreeId);
3061
+ const ptr0 = passArrayJsValueToWasm0(digests, wasm.__wbindgen_export);
3062
+ const len0 = WASM_VECTOR_LEN;
3063
+ const ret = wasm.syncmessage_blobsRequest(id.__wbg_ptr, ptr0, len0);
3064
+ return SyncMessage.__wrap(ret);
3065
+ }
3066
+ /**
3067
+ * Create a [`SyncMessage::BlobsResponse`] message.
3068
+ * @param {SedimentreeId} id
3069
+ * @param {Uint8Array[]} blobs
3070
+ * @returns {SyncMessage}
3071
+ */
3072
+ static blobsResponse(id, blobs) {
3073
+ _assertClass(id, SedimentreeId);
3074
+ const ptr0 = passArrayJsValueToWasm0(blobs, wasm.__wbindgen_export);
3075
+ const len0 = WASM_VECTOR_LEN;
3076
+ const ret = wasm.syncmessage_blobsResponse(id.__wbg_ptr, ptr0, len0);
3077
+ return SyncMessage.__wrap(ret);
3078
+ }
3079
+ /**
3080
+ * The [`LooseCommit`] for a [`SyncMessage::LooseCommit`], if applicable.
3081
+ *
3082
+ * Decodes the signed payload to extract the underlying commit.
3083
+ * @returns {LooseCommit | undefined}
3084
+ */
3085
+ get commit() {
3086
+ const ret = wasm.syncmessage_commit(this.__wbg_ptr);
3087
+ return ret === 0 ? undefined : LooseCommit.__wrap(ret);
3088
+ }
3089
+ /**
3090
+ * The requested [`Digest`]s for a [`SyncMessage::BlobsRequest`], if applicable.
3091
+ * @returns {Digest[] | undefined}
3092
+ */
3093
+ get digests() {
3094
+ const ret = wasm.syncmessage_digests(this.__wbg_ptr);
3095
+ let v1;
3096
+ if (ret[0] !== 0) {
3097
+ v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
3098
+ wasm.__wbindgen_export5(ret[0], ret[1] * 4, 4);
3099
+ }
3100
+ return v1;
3101
+ }
3102
+ /**
3103
+ * The [`Fragment`] for a [`SyncMessage::Fragment`], if applicable.
3104
+ *
3105
+ * Decodes the signed payload to extract the underlying fragment.
3106
+ * @returns {Fragment | undefined}
3107
+ */
3108
+ get fragment() {
3109
+ const ret = wasm.syncmessage_fragment(this.__wbg_ptr);
3110
+ return ret === 0 ? undefined : Fragment.__wrap(ret);
3111
+ }
3112
+ /**
3113
+ * Deserialize a message from bytes.
3114
+ *
3115
+ * # Errors
3116
+ *
3117
+ * Returns a [`JsMessageDeserializationError`] if deserialization fails.
3118
+ * @param {Uint8Array} bytes
3119
+ * @returns {SyncMessage}
3120
+ */
3121
+ static fromBytes(bytes) {
3122
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
3123
+ const len0 = WASM_VECTOR_LEN;
3124
+ const ret = wasm.syncmessage_fromBytes(ptr0, len0);
3125
+ if (ret[2]) {
3126
+ throw takeFromExternrefTable0(ret[1]);
3127
+ }
3128
+ return SyncMessage.__wrap(ret[0]);
3129
+ }
3130
+ /**
3131
+ * The [`BatchSyncRequest`] for a [`SyncMessage::BatchSyncRequest`], if applicable.
3132
+ * @returns {BatchSyncRequest | undefined}
3133
+ */
3134
+ get request() {
3135
+ const ret = wasm.syncmessage_request(this.__wbg_ptr);
3136
+ return ret === 0 ? undefined : BatchSyncRequest.__wrap(ret);
3137
+ }
3138
+ /**
3139
+ * The [`BatchSyncResponse`] for a [`SyncMessage::BatchSyncResponse`], if applicable.
3140
+ * @returns {BatchSyncResponse | undefined}
3141
+ */
3142
+ get response() {
3143
+ const ret = wasm.syncmessage_response(this.__wbg_ptr);
3144
+ return ret === 0 ? undefined : BatchSyncResponse.__wrap(ret);
3145
+ }
3146
+ /**
3147
+ * The [`SedimentreeId`] associated with this message, if any.
3148
+ * @returns {SedimentreeId | undefined}
3149
+ */
3150
+ get sedimentreeId() {
3151
+ const ret = wasm.syncmessage_sedimentreeId(this.__wbg_ptr);
3152
+ return ret === 0 ? undefined : SedimentreeId.__wrap(ret);
3153
+ }
3154
+ /**
3155
+ * Serialize the message to bytes.
3156
+ * @returns {Uint8Array}
3157
+ */
3158
+ toBytes() {
3159
+ const ret = wasm.syncmessage_toBytes(this.__wbg_ptr);
3160
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
3161
+ wasm.__wbindgen_export5(ret[0], ret[1] * 1, 1);
3162
+ return v1;
3163
+ }
3164
+ /**
3165
+ * The message variant name.
3166
+ * @returns {string}
3167
+ */
3168
+ get type() {
3169
+ let deferred1_0;
3170
+ let deferred1_1;
3171
+ try {
3172
+ const ret = wasm.syncmessage_type(this.__wbg_ptr);
3173
+ deferred1_0 = ret[0];
3174
+ deferred1_1 = ret[1];
3175
+ return getStringFromWasm0(ret[0], ret[1]);
3176
+ } finally {
3177
+ wasm.__wbindgen_export5(deferred1_0, deferred1_1, 1);
3178
+ }
3179
+ }
3180
+ }
3181
+ if (Symbol.dispose) SyncMessage.prototype[Symbol.dispose] = SyncMessage.prototype.free;
3182
+ exports.SyncMessage = SyncMessage;
3183
+
3184
+ /**
3185
+ * Statistics from a sync operation.
3186
+ *
3187
+ * The "sent" counts reflect items that were _successfully_ sent over the wire,
3188
+ * not just items that were requested.
3189
+ */
3190
+ class SyncStats {
3191
+ static __wrap(ptr) {
3192
+ ptr = ptr >>> 0;
3193
+ const obj = Object.create(SyncStats.prototype);
3194
+ obj.__wbg_ptr = ptr;
3195
+ SyncStatsFinalization.register(obj, obj.__wbg_ptr, obj);
3196
+ return obj;
3197
+ }
3198
+ __destroy_into_raw() {
3199
+ const ptr = this.__wbg_ptr;
3200
+ this.__wbg_ptr = 0;
3201
+ SyncStatsFinalization.unregister(this);
3202
+ return ptr;
3203
+ }
3204
+ free() {
3205
+ const ptr = this.__destroy_into_raw();
3206
+ wasm.__wbg_syncstats_free(ptr, 0);
3207
+ }
3208
+ /**
3209
+ * Number of commits received from the peer.
3210
+ * @returns {number}
3211
+ */
3212
+ get commitsReceived() {
3213
+ const ret = wasm.syncstats_commitsReceived(this.__wbg_ptr);
3214
+ return ret >>> 0;
3215
+ }
3216
+ /**
3217
+ * Number of commits successfully sent to the peer.
3218
+ * @returns {number}
3219
+ */
3220
+ get commitsSent() {
3221
+ const ret = wasm.syncstats_commitsSent(this.__wbg_ptr);
3222
+ return ret >>> 0;
3223
+ }
3224
+ /**
3225
+ * Number of fragments received from the peer.
3226
+ * @returns {number}
3227
+ */
3228
+ get fragmentsReceived() {
3229
+ const ret = wasm.syncstats_fragmentsReceived(this.__wbg_ptr);
3230
+ return ret >>> 0;
3231
+ }
3232
+ /**
3233
+ * Number of fragments successfully sent to the peer.
3234
+ * @returns {number}
3235
+ */
3236
+ get fragmentsSent() {
3237
+ const ret = wasm.syncstats_fragmentsSent(this.__wbg_ptr);
3238
+ return ret >>> 0;
3239
+ }
3240
+ /**
3241
+ * Returns true if no commits or fragments were transferred.
3242
+ *
3243
+ * Note: `remoteHeads` may still be non-empty (heads metadata is not
3244
+ * considered "data" for this check).
3245
+ * @returns {boolean}
3246
+ */
3247
+ get isEmpty() {
3248
+ const ret = wasm.syncstats_isEmpty(this.__wbg_ptr);
3249
+ return ret !== 0;
3250
+ }
3251
+ /**
3252
+ * The remote peer's heads for this sedimentree.
3253
+ * @returns {Digest[]}
3254
+ */
3255
+ get remoteHeads() {
3256
+ const ret = wasm.syncstats_remoteHeads(this.__wbg_ptr);
3257
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
3258
+ wasm.__wbindgen_export5(ret[0], ret[1] * 4, 4);
3259
+ return v1;
3260
+ }
3261
+ /**
3262
+ * Total items received (commits + fragments).
3263
+ * @returns {number}
3264
+ */
3265
+ get totalReceived() {
3266
+ const ret = wasm.syncstats_totalReceived(this.__wbg_ptr);
3267
+ return ret >>> 0;
3268
+ }
3269
+ /**
3270
+ * Total items sent (commits + fragments).
3271
+ * @returns {number}
3272
+ */
3273
+ get totalSent() {
3274
+ const ret = wasm.syncstats_totalSent(this.__wbg_ptr);
3275
+ return ret >>> 0;
3276
+ }
3277
+ }
3278
+ if (Symbol.dispose) SyncStats.prototype[Symbol.dispose] = SyncStats.prototype.free;
3279
+ exports.SyncStats = SyncStats;
3280
+
3281
+ /**
3282
+ * A Wasm wrapper around the ephemeral [`Topic`] type.
3283
+ *
3284
+ * Topics are opaque 32-byte identifiers for ephemeral pubsub channels.
3285
+ * A [`SedimentreeId`] can be used as a topic, but topics are not
3286
+ * limited to sedimentrees.
3287
+ *
3288
+ * [`SedimentreeId`]: sedimentree_core::id::SedimentreeId
3289
+ */
3290
+ class Topic {
3291
+ static __wrap(ptr) {
3292
+ ptr = ptr >>> 0;
3293
+ const obj = Object.create(Topic.prototype);
3294
+ obj.__wbg_ptr = ptr;
3295
+ TopicFinalization.register(obj, obj.__wbg_ptr, obj);
3296
+ return obj;
3297
+ }
3298
+ static __unwrap(jsValue) {
3299
+ if (!(jsValue instanceof Topic)) {
3300
+ return 0;
3301
+ }
3302
+ return jsValue.__destroy_into_raw();
3303
+ }
3304
+ __destroy_into_raw() {
3305
+ const ptr = this.__wbg_ptr;
3306
+ this.__wbg_ptr = 0;
3307
+ TopicFinalization.unregister(this);
3308
+ return ptr;
3309
+ }
3310
+ free() {
3311
+ const ptr = this.__destroy_into_raw();
3312
+ wasm.__wbg_topic_free(ptr, 0);
3313
+ }
3314
+ /**
3315
+ * Create a topic from a 32-byte array.
3316
+ *
3317
+ * # Errors
3318
+ *
3319
+ * Returns an error if the provided byte array is not exactly 32 bytes.
3320
+ * @param {Uint8Array} bytes
3321
+ * @returns {Topic}
3322
+ */
3323
+ static fromBytes(bytes) {
3324
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
3325
+ const len0 = WASM_VECTOR_LEN;
3326
+ const ret = wasm.topic_fromBytes(ptr0, len0);
3327
+ if (ret[2]) {
3328
+ throw takeFromExternrefTable0(ret[1]);
3329
+ }
3330
+ return Topic.__wrap(ret[0]);
3331
+ }
3332
+ /**
3333
+ * Returns the raw 32 bytes of this topic.
3334
+ * @returns {Uint8Array}
3335
+ */
3336
+ toBytes() {
3337
+ const ret = wasm.topic_toBytes(this.__wbg_ptr);
3338
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
3339
+ wasm.__wbindgen_export5(ret[0], ret[1] * 1, 1);
3340
+ return v1;
3341
+ }
3342
+ /**
3343
+ * Returns a shortened hex prefix representation (first 4 bytes + `…`).
3344
+ * @returns {string}
3345
+ */
3346
+ toString() {
3347
+ let deferred1_0;
3348
+ let deferred1_1;
3349
+ try {
3350
+ const ret = wasm.topic_toString(this.__wbg_ptr);
3351
+ deferred1_0 = ret[0];
3352
+ deferred1_1 = ret[1];
3353
+ return getStringFromWasm0(ret[0], ret[1]);
3354
+ } finally {
3355
+ wasm.__wbindgen_export5(deferred1_0, deferred1_1, 1);
3356
+ }
3357
+ }
3358
+ }
3359
+ if (Symbol.dispose) Topic.prototype[Symbol.dispose] = Topic.prototype.free;
3360
+ exports.Topic = Topic;
3361
+
3362
+ /**
3363
+ * An Ed25519 signer using the browser's `WebCrypto` API.
3364
+ *
3365
+ * This signer generates and stores Ed25519 keys using `crypto.subtle`,
3366
+ * providing secure key generation and signing operations. The key is
3367
+ * persisted to `IndexedDB` so it survives page reloads.
3368
+ *
3369
+ * # Example
3370
+ *
3371
+ * ```javascript
3372
+ * import { WebCryptoSigner } from "@anthropic/subduction";
3373
+ *
3374
+ * const signer = await WebCryptoSigner.setup();
3375
+ * console.log("Peer ID:", signer.peerId().toString());
3376
+ * ```
3377
+ */
3378
+ class WebCryptoSigner {
3379
+ static __wrap(ptr) {
3380
+ ptr = ptr >>> 0;
3381
+ const obj = Object.create(WebCryptoSigner.prototype);
3382
+ obj.__wbg_ptr = ptr;
3383
+ WebCryptoSignerFinalization.register(obj, obj.__wbg_ptr, obj);
3384
+ return obj;
3385
+ }
3386
+ __destroy_into_raw() {
3387
+ const ptr = this.__wbg_ptr;
3388
+ this.__wbg_ptr = 0;
3389
+ WebCryptoSignerFinalization.unregister(this);
3390
+ return ptr;
3391
+ }
3392
+ free() {
3393
+ const ptr = this.__destroy_into_raw();
3394
+ wasm.__wbg_webcryptosigner_free(ptr, 0);
3395
+ }
3396
+ /**
3397
+ * Get the peer ID derived from this signer's verifying key.
3398
+ *
3399
+ * # Panics
3400
+ *
3401
+ * Panics if the stored public key bytes are invalid (should never happen).
3402
+ * @returns {PeerId}
3403
+ */
3404
+ peerId() {
3405
+ const ret = wasm.webcryptosigner_peerId(this.__wbg_ptr);
3406
+ return PeerId.__wrap(ret);
3407
+ }
3408
+ /**
3409
+ * Set up the signer, loading an existing key from `IndexedDB` or generating a new one.
3410
+ *
3411
+ * # Errors
3412
+ *
3413
+ * Returns an error if `WebCrypto` or `IndexedDB` operations fail.
3414
+ * @returns {Promise<WebCryptoSigner>}
3415
+ */
3416
+ static setup() {
3417
+ const ret = wasm.webcryptosigner_setup();
3418
+ return ret;
3419
+ }
3420
+ /**
3421
+ * Sign a message and return the 64-byte Ed25519 signature.
3422
+ *
3423
+ * # Errors
3424
+ *
3425
+ * Returns an error if `WebCrypto` signing fails.
3426
+ * @param {Uint8Array} message
3427
+ * @returns {Promise<Uint8Array>}
3428
+ */
3429
+ sign(message) {
3430
+ const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_export);
3431
+ const len0 = WASM_VECTOR_LEN;
3432
+ const ret = wasm.webcryptosigner_sign(this.__wbg_ptr, ptr0, len0);
3433
+ return ret;
3434
+ }
3435
+ /**
3436
+ * Get the 32-byte Ed25519 verifying (public) key.
3437
+ * @returns {Uint8Array}
3438
+ */
3439
+ verifyingKey() {
3440
+ const ret = wasm.webcryptosigner_verifyingKey(this.__wbg_ptr);
3441
+ return ret;
3442
+ }
3443
+ }
3444
+ if (Symbol.dispose) WebCryptoSigner.prototype[Symbol.dispose] = WebCryptoSigner.prototype.free;
3445
+ exports.WebCryptoSigner = WebCryptoSigner;
3446
+
3447
+ /**
3448
+ * Convenience factory — equivalent to `new MessagePortTransport(port)`.
3449
+ * @param {any} port
3450
+ * @returns {MessagePortTransport}
3451
+ */
3452
+ function makeMessagePortTransport(port) {
3453
+ const ret = wasm.makeMessagePortTransport(port);
3454
+ return MessagePortTransport.__wrap(ret);
3455
+ }
3456
+ exports.makeMessagePortTransport = makeMessagePortTransport;
3457
+
3458
+ /**
3459
+ * Entry point called when the Wasm module is instantiated.
3460
+ *
3461
+ * Only compiled when the `standalone` feature is active. Downstream cdylib
3462
+ * crates that define their own `#[wasm_bindgen(start)]` should depend on
3463
+ * `subduction_wasm` with `default-features = false` and call
3464
+ * [`set_panic_hook`] from their own start function.
3465
+ */
3466
+ function start() {
3467
+ wasm.start();
3468
+ }
3469
+ exports.start = start;
3470
+ const import1 = require("./snippets/subduction_wasm-ec51bcf335db35bd/inline0.js");
3471
+ const import2 = require("./snippets/subduction_wasm-ec51bcf335db35bd/inline1.js");
3472
+
3473
+ function __wbg_get_imports() {
3474
+ const import0 = {
3475
+ __proto__: null,
3476
+ __wbg___wasm_refgen_toWasmCommitWithBlob_fcbd230cf952f128: function(arg0) {
3477
+ const ret = arg0.__wasm_refgen_toWasmCommitWithBlob();
3478
+ _assertClass(ret, CommitWithBlob);
3479
+ var ptr1 = ret.__destroy_into_raw();
3480
+ return ptr1;
3481
+ },
3482
+ __wbg___wasm_refgen_toWasmDepth_4f8de5b877457c3d: function(arg0) {
3483
+ const ret = arg0.__wasm_refgen_toWasmDepth();
3484
+ _assertClass(ret, Depth);
3485
+ var ptr1 = ret.__destroy_into_raw();
3486
+ return ptr1;
3487
+ },
3488
+ __wbg___wasm_refgen_toWasmDigest_d0fbca90d003e5b2: function(arg0) {
3489
+ const ret = arg0.__wasm_refgen_toWasmDigest();
3490
+ _assertClass(ret, Digest);
3491
+ var ptr1 = ret.__destroy_into_raw();
3492
+ return ptr1;
3493
+ },
3494
+ __wbg___wasm_refgen_toWasmFragmentWithBlob_814bb2b3d862ac90: function(arg0) {
3495
+ const ret = arg0.__wasm_refgen_toWasmFragmentWithBlob();
3496
+ _assertClass(ret, FragmentWithBlob);
3497
+ var ptr1 = ret.__destroy_into_raw();
3498
+ return ptr1;
3499
+ },
3500
+ __wbg___wasm_refgen_toWasmFragment_32ab33a0a1cf967b: function(arg0) {
3501
+ const ret = arg0.__wasm_refgen_toWasmFragment();
3502
+ _assertClass(ret, Fragment);
3503
+ var ptr1 = ret.__destroy_into_raw();
3504
+ return ptr1;
3505
+ },
3506
+ __wbg___wasm_refgen_toWasmLooseCommit_6deda612421ca7e6: function(arg0) {
3507
+ const ret = arg0.__wasm_refgen_toWasmLooseCommit();
3508
+ _assertClass(ret, LooseCommit);
3509
+ var ptr1 = ret.__destroy_into_raw();
3510
+ return ptr1;
3511
+ },
3512
+ __wbg___wbindgen_debug_string_5398f5bb970e0daa: function(arg0, arg1) {
3513
+ const ret = debugString(arg1);
3514
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3515
+ const len1 = WASM_VECTOR_LEN;
3516
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3517
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3518
+ },
3519
+ __wbg___wbindgen_is_function_3c846841762788c1: function(arg0) {
3520
+ const ret = typeof(arg0) === 'function';
3521
+ return ret;
3522
+ },
3523
+ __wbg___wbindgen_is_null_0b605fc6b167c56f: function(arg0) {
3524
+ const ret = arg0 === null;
3525
+ return ret;
3526
+ },
3527
+ __wbg___wbindgen_is_object_781bc9f159099513: function(arg0) {
3528
+ const val = arg0;
3529
+ const ret = typeof(val) === 'object' && val !== null;
3530
+ return ret;
3531
+ },
3532
+ __wbg___wbindgen_is_string_7ef6b97b02428fae: function(arg0) {
3533
+ const ret = typeof(arg0) === 'string';
3534
+ return ret;
3535
+ },
3536
+ __wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
3537
+ const ret = arg0 === undefined;
3538
+ return ret;
3539
+ },
3540
+ __wbg___wbindgen_jsval_eq_ee31bfad3e536463: function(arg0, arg1) {
3541
+ const ret = arg0 === arg1;
3542
+ return ret;
3543
+ },
3544
+ __wbg___wbindgen_number_get_34bb9d9dcfa21373: function(arg0, arg1) {
3545
+ const obj = arg1;
3546
+ const ret = typeof(obj) === 'number' ? obj : undefined;
3547
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
3548
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
3549
+ },
3550
+ __wbg___wbindgen_string_get_395e606bd0ee4427: function(arg0, arg1) {
3551
+ const obj = arg1;
3552
+ const ret = typeof(obj) === 'string' ? obj : undefined;
3553
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3554
+ var len1 = WASM_VECTOR_LEN;
3555
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3556
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3557
+ },
3558
+ __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
3559
+ throw new Error(getStringFromWasm0(arg0, arg1));
3560
+ },
3561
+ __wbg__wbg_cb_unref_6b5b6b8576d35cb1: function(arg0) {
3562
+ arg0._wbg_cb_unref();
3563
+ },
3564
+ __wbg_arrayBuffer_eb8e9ca620af2a19: function() { return handleError(function (arg0) {
3565
+ const ret = arg0.arrayBuffer();
3566
+ return ret;
3567
+ }, arguments); },
3568
+ __wbg_authenticatedlongpoll_new: function(arg0) {
3569
+ const ret = AuthenticatedLongPoll.__wrap(arg0);
3570
+ return ret;
3571
+ },
3572
+ __wbg_authenticatedtransport_new: function(arg0) {
3573
+ const ret = AuthenticatedTransport.__wrap(arg0);
3574
+ return ret;
3575
+ },
3576
+ __wbg_authenticatedwebsocket_new: function(arg0) {
3577
+ const ret = AuthenticatedWebSocket.__wrap(arg0);
3578
+ return ret;
3579
+ },
3580
+ __wbg_authorizeConnect_8e2609308bbbbcfd: function() { return handleError(function (arg0, arg1) {
3581
+ const ret = arg0.authorizeConnect(PeerId.__wrap(arg1));
3582
+ return ret;
3583
+ }, arguments); },
3584
+ __wbg_authorizeFetch_b7bcc4e437112c73: function() { return handleError(function (arg0, arg1, arg2) {
3585
+ const ret = arg0.authorizeFetch(PeerId.__wrap(arg1), SedimentreeId.__wrap(arg2));
3586
+ return ret;
3587
+ }, arguments); },
3588
+ __wbg_authorizePublish_7e546fc3d8103532: function() { return handleError(function (arg0, arg1, arg2) {
3589
+ const ret = arg0.authorizePublish(PeerId.__wrap(arg1), Topic.__wrap(arg2));
3590
+ return ret;
3591
+ }, arguments); },
3592
+ __wbg_authorizePut_ba5a5e36c9e9bbfa: function() { return handleError(function (arg0, arg1, arg2, arg3) {
3593
+ const ret = arg0.authorizePut(PeerId.__wrap(arg1), PeerId.__wrap(arg2), SedimentreeId.__wrap(arg3));
3594
+ return ret;
3595
+ }, arguments); },
3596
+ __wbg_authorizeSubscribe_34f5ba6f23bab853: function() { return handleError(function (arg0, arg1, arg2) {
3597
+ const ret = arg0.authorizeSubscribe(PeerId.__wrap(arg1), Topic.__wrap(arg2));
3598
+ return ret;
3599
+ }, arguments); },
3600
+ __wbg_buffer_60b8043cd926067d: function(arg0) {
3601
+ const ret = arg0.buffer;
3602
+ return ret;
3603
+ },
3604
+ __wbg_call_2d781c1f4d5c0ef8: function() { return handleError(function (arg0, arg1, arg2) {
3605
+ const ret = arg0.call(arg1, arg2);
3606
+ return ret;
3607
+ }, arguments); },
3608
+ __wbg_call_e133b57c9155d22c: function() { return handleError(function (arg0, arg1) {
3609
+ const ret = arg0.call(arg1);
3610
+ return ret;
3611
+ }, arguments); },
3612
+ __wbg_call_f858478a02f9600f: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
3613
+ const ret = arg0.call(arg1, arg2, arg3, arg4);
3614
+ return ret;
3615
+ }, arguments); },
3616
+ __wbg_close_af26905c832a88cb: function() { return handleError(function (arg0) {
3617
+ arg0.close();
3618
+ }, arguments); },
3619
+ __wbg_close_cbf870bdad0aad99: function(arg0) {
3620
+ arg0.close();
3621
+ },
3622
+ __wbg_close_f85b3643ad9ed8d4: function(arg0) {
3623
+ arg0.close();
3624
+ },
3625
+ __wbg_commitwithblob_new: function(arg0) {
3626
+ const ret = CommitWithBlob.__wrap(arg0);
3627
+ return ret;
3628
+ },
3629
+ __wbg_contains_ef4bfb7fa5a241b7: function(arg0, arg1, arg2) {
3630
+ const ret = arg0.contains(getStringFromWasm0(arg1, arg2));
3631
+ return ret;
3632
+ },
3633
+ __wbg_createObjectStore_92a8aebcc6f9d7e3: function() { return handleError(function (arg0, arg1, arg2) {
3634
+ const ret = arg0.createObjectStore(getStringFromWasm0(arg1, arg2));
3635
+ return ret;
3636
+ }, arguments); },
3637
+ __wbg_crypto_38df2bab126b63dc: function(arg0) {
3638
+ const ret = arg0.crypto;
3639
+ return ret;
3640
+ },
3641
+ __wbg_data_a3d9ff9cdd801002: function(arg0) {
3642
+ const ret = arg0.data;
3643
+ return ret;
3644
+ },
3645
+ __wbg_deleteAllCommits_87e95e34aba169ea: function(arg0, arg1) {
3646
+ const ret = arg0.deleteAllCommits(arg1);
3647
+ return ret;
3648
+ },
3649
+ __wbg_deleteAllFragments_b5a40f8b94689ee5: function(arg0, arg1) {
3650
+ const ret = arg0.deleteAllFragments(arg1);
3651
+ return ret;
3652
+ },
3653
+ __wbg_digest_new: function(arg0) {
3654
+ const ret = Digest.__wrap(arg0);
3655
+ return ret;
3656
+ },
3657
+ __wbg_digest_unwrap: function(arg0) {
3658
+ const ret = Digest.__unwrap(arg0);
3659
+ return ret;
3660
+ },
3661
+ __wbg_disconnect_91312bb506e834b1: function(arg0) {
3662
+ const ret = arg0.disconnect();
3663
+ return ret;
3664
+ },
3665
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
3666
+ let deferred0_0;
3667
+ let deferred0_1;
3668
+ try {
3669
+ deferred0_0 = arg0;
3670
+ deferred0_1 = arg1;
3671
+ console.error(getStringFromWasm0(arg0, arg1));
3672
+ } finally {
3673
+ wasm.__wbindgen_export5(deferred0_0, deferred0_1, 1);
3674
+ }
3675
+ },
3676
+ __wbg_exportKey_c43b919dba5a1db2: function() { return handleError(function (arg0, arg1, arg2, arg3) {
3677
+ const ret = arg0.exportKey(getStringFromWasm0(arg1, arg2), arg3);
3678
+ return ret;
3679
+ }, arguments); },
3680
+ __wbg_fetch_5550a88cf343aaa9: function(arg0, arg1) {
3681
+ const ret = arg0.fetch(arg1);
3682
+ return ret;
3683
+ },
3684
+ __wbg_fetch_f8a611684c3b5fe5: function(arg0, arg1) {
3685
+ const ret = arg0.fetch(arg1);
3686
+ return ret;
3687
+ },
3688
+ __wbg_filterAuthorizedFetch_a647f13dc33948f1: function() { return handleError(function (arg0, arg1, arg2, arg3) {
3689
+ var v0 = getArrayJsValueFromWasm0(arg2, arg3).slice();
3690
+ wasm.__wbindgen_export5(arg2, arg3 * 4, 4);
3691
+ const ret = arg0.filterAuthorizedFetch(PeerId.__wrap(arg1), v0);
3692
+ return ret;
3693
+ }, arguments); },
3694
+ __wbg_filterAuthorizedSubscribers_34bdeaaac0eb31a5: function() { return handleError(function (arg0, arg1, arg2, arg3) {
3695
+ var v0 = getArrayJsValueFromWasm0(arg2, arg3).slice();
3696
+ wasm.__wbindgen_export5(arg2, arg3 * 4, 4);
3697
+ const ret = arg0.filterAuthorizedSubscribers(Topic.__wrap(arg1), v0);
3698
+ return ret;
3699
+ }, arguments); },
3700
+ __wbg_fragment_new: function(arg0) {
3701
+ const ret = Fragment.__wrap(arg0);
3702
+ return ret;
3703
+ },
3704
+ __wbg_fragmentrequested_new: function(arg0) {
3705
+ const ret = FragmentRequested.__wrap(arg0);
3706
+ return ret;
3707
+ },
3708
+ __wbg_fragmentwithblob_new: function(arg0) {
3709
+ const ret = FragmentWithBlob.__wrap(arg0);
3710
+ return ret;
3711
+ },
3712
+ __wbg_from_4bdf88943703fd48: function(arg0) {
3713
+ const ret = Array.from(arg0);
3714
+ return ret;
3715
+ },
3716
+ __wbg_generateKey_2b6cf71e7c9ad526: function() { return handleError(function (arg0, arg1, arg2, arg3) {
3717
+ const ret = arg0.generateKey(arg1, arg2 !== 0, arg3);
3718
+ return ret;
3719
+ }, arguments); },
3720
+ __wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
3721
+ arg0.getRandomValues(arg1);
3722
+ }, arguments); },
3723
+ __wbg_get_3ef1eba1850ade27: function() { return handleError(function (arg0, arg1) {
3724
+ const ret = Reflect.get(arg0, arg1);
3725
+ return ret;
3726
+ }, arguments); },
3727
+ __wbg_get_6ac8c8119f577720: function() { return handleError(function (arg0, arg1) {
3728
+ const ret = arg0.get(arg1);
3729
+ return ret;
3730
+ }, arguments); },
3731
+ __wbg_get_a867a94064ecd263: function() { return handleError(function (arg0, arg1, arg2, arg3) {
3732
+ const ret = arg1.get(getStringFromWasm0(arg2, arg3));
3733
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3734
+ var len1 = WASM_VECTOR_LEN;
3735
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3736
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3737
+ }, arguments); },
3738
+ __wbg_get_a8ee5c45dabc1b3b: function(arg0, arg1) {
3739
+ const ret = arg0[arg1 >>> 0];
3740
+ return ret;
3741
+ },
3742
+ __wbg_get_unchecked_329cfe50afab7352: function(arg0, arg1) {
3743
+ const ret = arg0[arg1 >>> 0];
3744
+ return ret;
3745
+ },
3746
+ __wbg_has_926ef2ff40b308cf: function() { return handleError(function (arg0, arg1) {
3747
+ const ret = Reflect.has(arg0, arg1);
3748
+ return ret;
3749
+ }, arguments); },
3750
+ __wbg_headers_eb2234545f9ff993: function(arg0) {
3751
+ const ret = arg0.headers;
3752
+ return ret;
3753
+ },
3754
+ __wbg_host_5b3ec3e9d4d1fc78: function(arg0, arg1) {
3755
+ const ret = arg1.host;
3756
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3757
+ const len1 = WASM_VECTOR_LEN;
3758
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3759
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3760
+ },
3761
+ __wbg_href_da367531ce807a58: function(arg0, arg1) {
3762
+ const ret = arg1.href;
3763
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3764
+ const len1 = WASM_VECTOR_LEN;
3765
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3766
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3767
+ },
3768
+ __wbg_importKey_397406e38b080c57: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
3769
+ const ret = arg0.importKey(getStringFromWasm0(arg1, arg2), arg3, arg4, arg5 !== 0, arg6);
3770
+ return ret;
3771
+ }, arguments); },
3772
+ __wbg_instanceof_ArrayBuffer_101e2bf31071a9f6: function(arg0) {
3773
+ let result;
3774
+ try {
3775
+ result = arg0 instanceof ArrayBuffer;
3776
+ } catch (_) {
3777
+ result = false;
3778
+ }
3779
+ const ret = result;
3780
+ return ret;
3781
+ },
3782
+ __wbg_instanceof_Crypto_5c2a4c15287b0332: function(arg0) {
3783
+ let result;
3784
+ try {
3785
+ result = arg0 instanceof Crypto;
3786
+ } catch (_) {
3787
+ result = false;
3788
+ }
3789
+ const ret = result;
3790
+ return ret;
3791
+ },
3792
+ __wbg_instanceof_IdbDatabase_5f436cc89cc07f14: function(arg0) {
3793
+ let result;
3794
+ try {
3795
+ result = arg0 instanceof IDBDatabase;
3796
+ } catch (_) {
3797
+ result = false;
3798
+ }
3799
+ const ret = result;
3800
+ return ret;
3801
+ },
3802
+ __wbg_instanceof_IdbFactory_efcffbfd9020e4ac: function(arg0) {
3803
+ let result;
3804
+ try {
3805
+ result = arg0 instanceof IDBFactory;
3806
+ } catch (_) {
3807
+ result = false;
3808
+ }
3809
+ const ret = result;
3810
+ return ret;
3811
+ },
3812
+ __wbg_instanceof_IdbOpenDbRequest_10c2576001eb6613: function(arg0) {
3813
+ let result;
3814
+ try {
3815
+ result = arg0 instanceof IDBOpenDBRequest;
3816
+ } catch (_) {
3817
+ result = false;
3818
+ }
3819
+ const ret = result;
3820
+ return ret;
3821
+ },
3822
+ __wbg_instanceof_Promise_7c3bdd7805c2c6e6: function(arg0) {
3823
+ let result;
3824
+ try {
3825
+ result = arg0 instanceof Promise;
3826
+ } catch (_) {
3827
+ result = false;
3828
+ }
3829
+ const ret = result;
3830
+ return ret;
3831
+ },
3832
+ __wbg_instanceof_Response_9b4d9fd451e051b1: function(arg0) {
3833
+ let result;
3834
+ try {
3835
+ result = arg0 instanceof Response;
3836
+ } catch (_) {
3837
+ result = false;
3838
+ }
3839
+ const ret = result;
3840
+ return ret;
3841
+ },
3842
+ __wbg_instanceof_Uint8Array_740438561a5b956d: function(arg0) {
3843
+ let result;
3844
+ try {
3845
+ result = arg0 instanceof Uint8Array;
3846
+ } catch (_) {
3847
+ result = false;
3848
+ }
3849
+ const ret = result;
3850
+ return ret;
3851
+ },
3852
+ __wbg_instanceof_Window_23e677d2c6843922: function(arg0) {
3853
+ let result;
3854
+ try {
3855
+ result = arg0 instanceof Window;
3856
+ } catch (_) {
3857
+ result = false;
3858
+ }
3859
+ const ret = result;
3860
+ return ret;
3861
+ },
3862
+ __wbg_instanceof_WorkerGlobalScope_de6976d00cb213c6: function(arg0) {
3863
+ let result;
3864
+ try {
3865
+ result = arg0 instanceof WorkerGlobalScope;
3866
+ } catch (_) {
3867
+ result = false;
3868
+ }
3869
+ const ret = result;
3870
+ return ret;
3871
+ },
3872
+ __wbg_isArray_33b91feb269ff46e: function(arg0) {
3873
+ const ret = Array.isArray(arg0);
3874
+ return ret;
3875
+ },
3876
+ __wbg_isSafeInteger_ecd6a7f9c3e053cd: function(arg0) {
3877
+ const ret = Number.isSafeInteger(arg0);
3878
+ return ret;
3879
+ },
3880
+ __wbg_length_b3416cf66a5452c8: function(arg0) {
3881
+ const ret = arg0.length;
3882
+ return ret;
3883
+ },
3884
+ __wbg_length_ea16607d7b61445b: function(arg0) {
3885
+ const ret = arg0.length;
3886
+ return ret;
3887
+ },
3888
+ __wbg_loadAllCommits_1b040f2bd61f63de: function(arg0, arg1) {
3889
+ const ret = arg0.loadAllCommits(arg1);
3890
+ return ret;
3891
+ },
3892
+ __wbg_loadAllFragments_cf081afbfee53965: function(arg0, arg1) {
3893
+ const ret = arg0.loadAllFragments(arg1);
3894
+ return ret;
3895
+ },
3896
+ __wbg_loadAllSedimentreeIds_a9046bfade082517: function(arg0) {
3897
+ const ret = arg0.loadAllSedimentreeIds();
3898
+ return ret;
3899
+ },
3900
+ __wbg_loosecommit_new: function(arg0) {
3901
+ const ret = LooseCommit.__wrap(arg0);
3902
+ return ret;
3903
+ },
3904
+ __wbg_messageporttransport_new: function(arg0) {
3905
+ const ret = MessagePortTransport.__wrap(arg0);
3906
+ return ret;
3907
+ },
3908
+ __wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
3909
+ const ret = arg0.msCrypto;
3910
+ return ret;
3911
+ },
3912
+ __wbg_new_0837727332ac86ba: function() { return handleError(function () {
3913
+ const ret = new Headers();
3914
+ return ret;
3915
+ }, arguments); },
3916
+ __wbg_new_227d7c05414eb861: function() {
3917
+ const ret = new Error();
3918
+ return ret;
3919
+ },
3920
+ __wbg_new_5f486cdf45a04d78: function(arg0) {
3921
+ const ret = new Uint8Array(arg0);
3922
+ return ret;
3923
+ },
3924
+ __wbg_new_a70fbab9066b301f: function() {
3925
+ const ret = new Array();
3926
+ return ret;
3927
+ },
3928
+ __wbg_new_ab79df5bd7c26067: function() {
3929
+ const ret = new Object();
3930
+ return ret;
3931
+ },
3932
+ __wbg_new_d098e265629cd10f: function(arg0, arg1) {
3933
+ try {
3934
+ var state0 = {a: arg0, b: arg1};
3935
+ var cb0 = (arg0, arg1) => {
3936
+ const a = state0.a;
3937
+ state0.a = 0;
3938
+ try {
3939
+ return __wasm_bindgen_func_elem_1651_194(a, state0.b, arg0, arg1);
3940
+ } finally {
3941
+ state0.a = a;
3942
+ }
3943
+ };
3944
+ const ret = new Promise(cb0);
3945
+ return ret;
3946
+ } finally {
3947
+ state0.a = state0.b = 0;
3948
+ }
3949
+ },
3950
+ __wbg_new_d15cb560a6a0e5f0: function(arg0, arg1) {
3951
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
3952
+ return ret;
3953
+ },
3954
+ __wbg_new_dd50bcc3f60ba434: function() { return handleError(function (arg0, arg1) {
3955
+ const ret = new WebSocket(getStringFromWasm0(arg0, arg1));
3956
+ return ret;
3957
+ }, arguments); },
3958
+ __wbg_new_f7708ba82c4c12f6: function() { return handleError(function () {
3959
+ const ret = new MessageChannel();
3960
+ return ret;
3961
+ }, arguments); },
3962
+ __wbg_new_from_slice_22da9388ac046e50: function(arg0, arg1) {
3963
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
3964
+ return ret;
3965
+ },
3966
+ __wbg_new_typed_aaaeaf29cf802876: function(arg0, arg1) {
3967
+ try {
3968
+ var state0 = {a: arg0, b: arg1};
3969
+ var cb0 = (arg0, arg1) => {
3970
+ const a = state0.a;
3971
+ state0.a = 0;
3972
+ try {
3973
+ return __wasm_bindgen_func_elem_1651_195(a, state0.b, arg0, arg1);
3974
+ } finally {
3975
+ state0.a = a;
3976
+ }
3977
+ };
3978
+ const ret = new Promise(cb0);
3979
+ return ret;
3980
+ } finally {
3981
+ state0.a = state0.b = 0;
3982
+ }
3983
+ },
3984
+ __wbg_new_typed_bccac67128ed885a: function() {
3985
+ const ret = new Array();
3986
+ return ret;
3987
+ },
3988
+ __wbg_new_with_length_3259a525196bd8cc: function(arg0) {
3989
+ const ret = new Array(arg0 >>> 0);
3990
+ return ret;
3991
+ },
3992
+ __wbg_new_with_length_825018a1616e9e55: function(arg0) {
3993
+ const ret = new Uint8Array(arg0 >>> 0);
3994
+ return ret;
3995
+ },
3996
+ __wbg_new_with_str_and_init_b4b54d1a819bc724: function() { return handleError(function (arg0, arg1, arg2) {
3997
+ const ret = new Request(getStringFromWasm0(arg0, arg1), arg2);
3998
+ return ret;
3999
+ }, arguments); },
4000
+ __wbg_node_84ea875411254db1: function(arg0) {
4001
+ const ret = arg0.node;
4002
+ return ret;
4003
+ },
4004
+ __wbg_now_16f0c993d5dd6c27: function() {
4005
+ const ret = Date.now();
4006
+ return ret;
4007
+ },
4008
+ __wbg_objectStoreNames_564985d2e9ae7523: function(arg0) {
4009
+ const ret = arg0.objectStoreNames;
4010
+ return ret;
4011
+ },
4012
+ __wbg_objectStore_f314ab152a5c7bd0: function() { return handleError(function (arg0, arg1, arg2) {
4013
+ const ret = arg0.objectStore(getStringFromWasm0(arg1, arg2));
4014
+ return ret;
4015
+ }, arguments); },
4016
+ __wbg_of_8bf7ed3eca00ea43: function(arg0) {
4017
+ const ret = Array.of(arg0);
4018
+ return ret;
4019
+ },
4020
+ __wbg_of_d6376e3774c51f89: function(arg0, arg1) {
4021
+ const ret = Array.of(arg0, arg1);
4022
+ return ret;
4023
+ },
4024
+ __wbg_onDisconnect_a24437def131c941: function(arg0, arg1) {
4025
+ arg0.onDisconnect(arg1);
4026
+ },
4027
+ __wbg_open_e7a9d3d6344572f6: function() { return handleError(function (arg0, arg1, arg2, arg3) {
4028
+ const ret = arg0.open(getStringFromWasm0(arg1, arg2), arg3 >>> 0);
4029
+ return ret;
4030
+ }, arguments); },
4031
+ __wbg_peerbatchsyncresult_new: function(arg0) {
4032
+ const ret = PeerBatchSyncResult.__wrap(arg0);
4033
+ return ret;
4034
+ },
4035
+ __wbg_peerid_new: function(arg0) {
4036
+ const ret = PeerId.__wrap(arg0);
4037
+ return ret;
4038
+ },
4039
+ __wbg_peerresultmap_new: function(arg0) {
4040
+ const ret = PeerResultMap.__wrap(arg0);
4041
+ return ret;
4042
+ },
4043
+ __wbg_port1_869a7ef90538dbdf: function(arg0) {
4044
+ const ret = arg0.port1;
4045
+ return ret;
4046
+ },
4047
+ __wbg_port2_947a51b8ba00adc9: function(arg0) {
4048
+ const ret = arg0.port2;
4049
+ return ret;
4050
+ },
4051
+ __wbg_postMessage_fb1c205fdbbf796d: function(arg0, arg1) {
4052
+ arg0.postMessage(arg1);
4053
+ },
4054
+ __wbg_process_44c7a14e11e9f69e: function(arg0) {
4055
+ const ret = arg0.process;
4056
+ return ret;
4057
+ },
4058
+ __wbg_prototypesetcall_d62e5099504357e6: function(arg0, arg1, arg2) {
4059
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
4060
+ },
4061
+ __wbg_push_e87b0e732085a946: function(arg0, arg1) {
4062
+ const ret = arg0.push(arg1);
4063
+ return ret;
4064
+ },
4065
+ __wbg_put_f1673d719f93ce22: function() { return handleError(function (arg0, arg1, arg2) {
4066
+ const ret = arg0.put(arg1, arg2);
4067
+ return ret;
4068
+ }, arguments); },
4069
+ __wbg_queueMicrotask_0c399741342fb10f: function(arg0) {
4070
+ const ret = arg0.queueMicrotask;
4071
+ return ret;
4072
+ },
4073
+ __wbg_queueMicrotask_a082d78ce798393e: function(arg0) {
4074
+ queueMicrotask(arg0);
4075
+ },
4076
+ __wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
4077
+ arg0.randomFillSync(arg1);
4078
+ }, arguments); },
4079
+ __wbg_readyState_1f1e7f1bdf9f4d42: function(arg0) {
4080
+ const ret = arg0.readyState;
4081
+ return ret;
4082
+ },
4083
+ __wbg_recvBytes_e13f381294da16db: function(arg0) {
4084
+ const ret = arg0.recvBytes();
4085
+ return ret;
4086
+ },
4087
+ __wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
4088
+ const ret = module.require;
4089
+ return ret;
4090
+ }, arguments); },
4091
+ __wbg_resolve_ae8d83246e5bcc12: function(arg0) {
4092
+ const ret = Promise.resolve(arg0);
4093
+ return ret;
4094
+ },
4095
+ __wbg_result_c5baa2d3d690a01a: function() { return handleError(function (arg0) {
4096
+ const ret = arg0.result;
4097
+ return ret;
4098
+ }, arguments); },
4099
+ __wbg_saveBatchAll_b9359532f5a65936: function(arg0, arg1, arg2, arg3) {
4100
+ const ret = arg0.saveBatchAll(arg1, arg2, arg3);
4101
+ return ret;
4102
+ },
4103
+ __wbg_saveCommit_f6c4180a159edfdf: function(arg0, arg1, arg2, arg3, arg4) {
4104
+ const ret = arg0.saveCommit(arg1, arg2, arg3, arg4);
4105
+ return ret;
4106
+ },
4107
+ __wbg_saveFragment_49505af74bd5abe3: function(arg0, arg1, arg2, arg3, arg4) {
4108
+ const ret = arg0.saveFragment(arg1, arg2, arg3, arg4);
4109
+ return ret;
4110
+ },
4111
+ __wbg_saveSedimentreeId_7b6b4310628fe78c: function(arg0, arg1) {
4112
+ const ret = arg0.saveSedimentreeId(arg1);
4113
+ return ret;
4114
+ },
4115
+ __wbg_sedimentreeid_new: function(arg0) {
4116
+ const ret = SedimentreeId.__wrap(arg0);
4117
+ return ret;
4118
+ },
4119
+ __wbg_sedimentreeid_unwrap: function(arg0) {
4120
+ const ret = SedimentreeId.__unwrap(arg0);
4121
+ return ret;
4122
+ },
4123
+ __wbg_sendBytes_9a00cdaf7c891eff: function(arg0, arg1) {
4124
+ const ret = arg0.sendBytes(arg1);
4125
+ return ret;
4126
+ },
4127
+ __wbg_send_d31a693c975dea74: function() { return handleError(function (arg0, arg1, arg2) {
4128
+ arg0.send(getArrayU8FromWasm0(arg1, arg2));
4129
+ }, arguments); },
4130
+ __wbg_setTimeout_43db2c2050a4d3d2: function(arg0, arg1) {
4131
+ const ret = setTimeout(arg0, arg1);
4132
+ return ret;
4133
+ },
4134
+ __wbg_set_282384002438957f: function(arg0, arg1, arg2) {
4135
+ arg0[arg1 >>> 0] = arg2;
4136
+ },
4137
+ __wbg_set_7eaa4f96924fd6b3: function() { return handleError(function (arg0, arg1, arg2) {
4138
+ const ret = Reflect.set(arg0, arg1, arg2);
4139
+ return ret;
4140
+ }, arguments); },
4141
+ __wbg_set_binaryType_3dcf8281ec100a8f: function(arg0, arg1) {
4142
+ arg0.binaryType = __wbindgen_enum_BinaryType[arg1];
4143
+ },
4144
+ __wbg_set_body_a3d856b097dfda04: function(arg0, arg1) {
4145
+ arg0.body = arg1;
4146
+ },
4147
+ __wbg_set_e09648bea3f1af1e: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
4148
+ arg0.set(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
4149
+ }, arguments); },
4150
+ __wbg_set_headers_3c8fecc693b75327: function(arg0, arg1) {
4151
+ arg0.headers = arg1;
4152
+ },
4153
+ __wbg_set_method_8c015e8bcafd7be1: function(arg0, arg1, arg2) {
4154
+ arg0.method = getStringFromWasm0(arg1, arg2);
4155
+ },
4156
+ __wbg_set_mode_5a87f2c809cf37c2: function(arg0, arg1) {
4157
+ arg0.mode = __wbindgen_enum_RequestMode[arg1];
4158
+ },
4159
+ __wbg_set_name_7ef37fe858379aaf: function(arg0, arg1, arg2) {
4160
+ arg0.name = getStringFromWasm0(arg1, arg2);
4161
+ },
4162
+ __wbg_set_onclose_8da801226bdd7a7b: function(arg0, arg1) {
4163
+ arg0.onclose = arg1;
4164
+ },
4165
+ __wbg_set_onerror_8a268cb237177bba: function(arg0, arg1) {
4166
+ arg0.onerror = arg1;
4167
+ },
4168
+ __wbg_set_onerror_901ca711f94a5bbb: function(arg0, arg1) {
4169
+ arg0.onerror = arg1;
4170
+ },
4171
+ __wbg_set_onmessage_284248c97c42cb93: function(arg0, arg1) {
4172
+ arg0.onmessage = arg1;
4173
+ },
4174
+ __wbg_set_onmessage_6f80ab771bf151aa: function(arg0, arg1) {
4175
+ arg0.onmessage = arg1;
4176
+ },
4177
+ __wbg_set_onopen_34e3e24cf9337ddd: function(arg0, arg1) {
4178
+ arg0.onopen = arg1;
4179
+ },
4180
+ __wbg_set_onsuccess_fca94ded107b64af: function(arg0, arg1) {
4181
+ arg0.onsuccess = arg1;
4182
+ },
4183
+ __wbg_set_onupgradeneeded_860ce42184f987e7: function(arg0, arg1) {
4184
+ arg0.onupgradeneeded = arg1;
4185
+ },
4186
+ __wbg_sign_a34d057afd14c54d: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
4187
+ const ret = arg0.sign(arg1, arg2, getArrayU8FromWasm0(arg3, arg4));
4188
+ return ret;
4189
+ }, arguments); },
4190
+ __wbg_sign_e6fa76bd4ef9c75a: function(arg0, arg1) {
4191
+ const ret = arg0.sign(arg1);
4192
+ return ret;
4193
+ },
4194
+ __wbg_signedfragment_new: function(arg0) {
4195
+ const ret = SignedFragment.__wrap(arg0);
4196
+ return ret;
4197
+ },
4198
+ __wbg_signedloosecommit_new: function(arg0) {
4199
+ const ret = SignedLooseCommit.__wrap(arg0);
4200
+ return ret;
4201
+ },
4202
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
4203
+ const ret = arg1.stack;
4204
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
4205
+ const len1 = WASM_VECTOR_LEN;
4206
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
4207
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
4208
+ },
4209
+ __wbg_start_f837ba2bac4733b5: function(arg0) {
4210
+ arg0.start();
4211
+ },
4212
+ __wbg_static_accessor_GLOBAL_8adb955bd33fac2f: function() {
4213
+ const ret = typeof global === 'undefined' ? null : global;
4214
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4215
+ },
4216
+ __wbg_static_accessor_GLOBAL_THIS_ad356e0db91c7913: function() {
4217
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
4218
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4219
+ },
4220
+ __wbg_static_accessor_SELF_f207c857566db248: function() {
4221
+ const ret = typeof self === 'undefined' ? null : self;
4222
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4223
+ },
4224
+ __wbg_static_accessor_WINDOW_bb9f1ba69d61b386: function() {
4225
+ const ret = typeof window === 'undefined' ? null : window;
4226
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4227
+ },
4228
+ __wbg_status_318629ab93a22955: function(arg0) {
4229
+ const ret = arg0.status;
4230
+ return ret;
4231
+ },
4232
+ __wbg_subarray_a068d24e39478a8a: function(arg0, arg1, arg2) {
4233
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
4234
+ return ret;
4235
+ },
4236
+ __wbg_subduction_new: function(arg0) {
4237
+ const ret = Subduction.__wrap(arg0);
4238
+ return ret;
4239
+ },
4240
+ __wbg_subductionhttplongpoll_new: function(arg0) {
4241
+ const ret = SubductionHttpLongPoll.__wrap(arg0);
4242
+ return ret;
4243
+ },
4244
+ __wbg_subductionwebsocket_new: function(arg0) {
4245
+ const ret = SubductionWebSocket.__wrap(arg0);
4246
+ return ret;
4247
+ },
4248
+ __wbg_subtle_c060fa3eb5c6248d: function(arg0) {
4249
+ const ret = arg0.subtle;
4250
+ return ret;
4251
+ },
4252
+ __wbg_target_7bc90f314634b37b: function(arg0) {
4253
+ const ret = arg0.target;
4254
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4255
+ },
4256
+ __wbg_then_098abe61755d12f6: function(arg0, arg1) {
4257
+ const ret = arg0.then(arg1);
4258
+ return ret;
4259
+ },
4260
+ __wbg_then_9e335f6dd892bc11: function(arg0, arg1, arg2) {
4261
+ const ret = arg0.then(arg1, arg2);
4262
+ return ret;
4263
+ },
4264
+ __wbg_topic_new: function(arg0) {
4265
+ const ret = Topic.__wrap(arg0);
4266
+ return ret;
4267
+ },
4268
+ __wbg_topic_unwrap: function(arg0) {
4269
+ const ret = Topic.__unwrap(arg0);
4270
+ return ret;
4271
+ },
4272
+ __wbg_transaction_1309b463c399d2b3: function() { return handleError(function (arg0, arg1, arg2, arg3) {
4273
+ const ret = arg0.transaction(getStringFromWasm0(arg1, arg2), __wbindgen_enum_IdbTransactionMode[arg3]);
4274
+ return ret;
4275
+ }, arguments); },
4276
+ __wbg_transaction_2237af0233efbdf3: function() { return handleError(function (arg0, arg1, arg2) {
4277
+ const ret = arg0.transaction(getStringFromWasm0(arg1, arg2));
4278
+ return ret;
4279
+ }, arguments); },
4280
+ __wbg_tryIntoJsSedimentreeIdsArray_6803cc05ac20ff4f: function() { return handleError(function (arg0, arg1) {
4281
+ const ret = tryIntoJsSedimentreeIdsArray(arg1);
4282
+ const ptr1 = passArrayJsValueToWasm0(ret, wasm.__wbindgen_export);
4283
+ const len1 = WASM_VECTOR_LEN;
4284
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
4285
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
4286
+ }, arguments); },
4287
+ __wbg_verifyingKey_28c38fc6525caed5: function(arg0) {
4288
+ const ret = arg0.verifyingKey();
4289
+ return ret;
4290
+ },
4291
+ __wbg_versions_276b2795b1c6a219: function(arg0) {
4292
+ const ret = arg0.versions;
4293
+ return ret;
4294
+ },
4295
+ __wbg_webcryptosigner_new: function(arg0) {
4296
+ const ret = WebCryptoSigner.__wrap(arg0);
4297
+ return ret;
4298
+ },
4299
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
4300
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 11, function: Function { arguments: [Externref], shim_idx: 12, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
4301
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_285, __wasm_bindgen_func_elem_638);
4302
+ return ret;
4303
+ },
4304
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
4305
+ // 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`.
4306
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_285, __wasm_bindgen_func_elem_638_1);
4307
+ return ret;
4308
+ },
4309
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
4310
+ // 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`.
4311
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_285, __wasm_bindgen_func_elem_638_2);
4312
+ return ret;
4313
+ },
4314
+ __wbindgen_cast_0000000000000004: function(arg0, arg1) {
4315
+ // 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`.
4316
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_285, __wasm_bindgen_func_elem_638_3);
4317
+ return ret;
4318
+ },
4319
+ __wbindgen_cast_0000000000000005: function(arg0, arg1) {
4320
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 11, function: Function { arguments: [], shim_idx: 13, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
4321
+ const ret = makeClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_285, __wasm_bindgen_func_elem_637);
4322
+ return ret;
4323
+ },
4324
+ __wbindgen_cast_0000000000000006: function(arg0, arg1) {
4325
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 672, function: Function { arguments: [Externref], shim_idx: 756, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
4326
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_285, __wasm_bindgen_func_elem_1651);
4327
+ return ret;
4328
+ },
4329
+ __wbindgen_cast_0000000000000007: function(arg0) {
4330
+ // Cast intrinsic for `F64 -> Externref`.
4331
+ const ret = arg0;
4332
+ return ret;
4333
+ },
4334
+ __wbindgen_cast_0000000000000008: function(arg0, arg1) {
4335
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
4336
+ const ret = getArrayU8FromWasm0(arg0, arg1);
4337
+ return ret;
4338
+ },
4339
+ __wbindgen_cast_0000000000000009: function(arg0, arg1) {
4340
+ // Cast intrinsic for `Ref(String) -> Externref`.
4341
+ const ret = getStringFromWasm0(arg0, arg1);
4342
+ return ret;
4343
+ },
4344
+ __wbindgen_cast_000000000000000a: function(arg0, arg1) {
4345
+ var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
4346
+ wasm.__wbindgen_export5(arg0, arg1 * 4, 4);
4347
+ // Cast intrinsic for `Vector(NamedExternref("Fragment")) -> Externref`.
4348
+ const ret = v0;
4349
+ return ret;
4350
+ },
4351
+ __wbindgen_cast_000000000000000b: function(arg0, arg1) {
4352
+ var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
4353
+ wasm.__wbindgen_export5(arg0, arg1 * 4, 4);
4354
+ // Cast intrinsic for `Vector(NamedExternref("LooseCommit")) -> Externref`.
4355
+ const ret = v0;
4356
+ return ret;
4357
+ },
4358
+ __wbindgen_cast_000000000000000c: function(arg0, arg1) {
4359
+ var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
4360
+ wasm.__wbindgen_export5(arg0, arg1 * 4, 4);
4361
+ // Cast intrinsic for `Vector(NamedExternref("PeerId")) -> Externref`.
4362
+ const ret = v0;
4363
+ return ret;
4364
+ },
4365
+ __wbindgen_cast_000000000000000d: function(arg0, arg1) {
4366
+ var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
4367
+ wasm.__wbindgen_export5(arg0, arg1 * 4, 4);
4368
+ // Cast intrinsic for `Vector(NamedExternref("SedimentreeId")) -> Externref`.
4369
+ const ret = v0;
4370
+ return ret;
4371
+ },
4372
+ __wbindgen_cast_000000000000000e: function(arg0, arg1) {
4373
+ var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
4374
+ wasm.__wbindgen_export5(arg0, arg1 * 4, 4);
4375
+ // Cast intrinsic for `Vector(NamedExternref("Uint8Array")) -> Externref`.
4376
+ const ret = v0;
4377
+ return ret;
4378
+ },
4379
+ __wbindgen_init_externref_table: function() {
4380
+ const table = wasm.__wbindgen_externrefs;
4381
+ const offset = table.grow(4);
4382
+ table.set(0, undefined);
4383
+ table.set(offset + 0, undefined);
4384
+ table.set(offset + 1, null);
4385
+ table.set(offset + 2, true);
4386
+ table.set(offset + 3, false);
4387
+ },
4388
+ };
4389
+ return {
4390
+ __proto__: null,
4391
+ "./subduction_wasm_bg.js": import0,
4392
+ "./snippets/subduction_wasm-ec51bcf335db35bd/inline0.js": import1,
4393
+ "./snippets/subduction_wasm-ec51bcf335db35bd/inline1.js": import2,
4394
+ };
4395
+ }
4396
+
4397
+ function __wasm_bindgen_func_elem_637(arg0, arg1) {
4398
+ wasm.__wasm_bindgen_func_elem_637(arg0, arg1);
4399
+ }
4400
+
4401
+ function __wasm_bindgen_func_elem_638(arg0, arg1, arg2) {
4402
+ wasm.__wasm_bindgen_func_elem_638(arg0, arg1, arg2);
4403
+ }
4404
+
4405
+ function __wasm_bindgen_func_elem_638_1(arg0, arg1, arg2) {
4406
+ wasm.__wasm_bindgen_func_elem_638_1(arg0, arg1, arg2);
4407
+ }
4408
+
4409
+ function __wasm_bindgen_func_elem_638_2(arg0, arg1, arg2) {
4410
+ wasm.__wasm_bindgen_func_elem_638_2(arg0, arg1, arg2);
4411
+ }
4412
+
4413
+ function __wasm_bindgen_func_elem_638_3(arg0, arg1, arg2) {
4414
+ wasm.__wasm_bindgen_func_elem_638_3(arg0, arg1, arg2);
4415
+ }
4416
+
4417
+ function __wasm_bindgen_func_elem_1651(arg0, arg1, arg2) {
4418
+ const ret = wasm.__wasm_bindgen_func_elem_1651(arg0, arg1, arg2);
4419
+ if (ret[1]) {
4420
+ throw takeFromExternrefTable0(ret[0]);
4421
+ }
4422
+ }
4423
+
4424
+ function __wasm_bindgen_func_elem_1651_194(arg0, arg1, arg2, arg3) {
4425
+ wasm.__wasm_bindgen_func_elem_1651_194(arg0, arg1, arg2, arg3);
4426
+ }
4427
+
4428
+ function __wasm_bindgen_func_elem_1651_195(arg0, arg1, arg2, arg3) {
4429
+ wasm.__wasm_bindgen_func_elem_1651_195(arg0, arg1, arg2, arg3);
4430
+ }
4431
+
4432
+
4433
+ const __wbindgen_enum_BinaryType = ["blob", "arraybuffer"];
4434
+
4435
+
4436
+ const __wbindgen_enum_IdbTransactionMode = ["readonly", "readwrite", "versionchange", "readwriteflush", "cleanup"];
4437
+
4438
+
4439
+ const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"];
4440
+ const MemorySignerFinalization = (typeof FinalizationRegistry === 'undefined')
4441
+ ? { register: () => {}, unregister: () => {} }
4442
+ : new FinalizationRegistry(ptr => wasm.__wbg_memorysigner_free(ptr >>> 0, 1));
4443
+ const MemoryStorageFinalization = (typeof FinalizationRegistry === 'undefined')
4444
+ ? { register: () => {}, unregister: () => {} }
4445
+ : new FinalizationRegistry(ptr => wasm.__wbg_memorystorage_free(ptr >>> 0, 1));
4446
+ const PeerBatchSyncResultFinalization = (typeof FinalizationRegistry === 'undefined')
4447
+ ? { register: () => {}, unregister: () => {} }
4448
+ : new FinalizationRegistry(ptr => wasm.__wbg_peerbatchsyncresult_free(ptr >>> 0, 1));
4449
+ const AuthenticatedLongPollFinalization = (typeof FinalizationRegistry === 'undefined')
4450
+ ? { register: () => {}, unregister: () => {} }
4451
+ : new FinalizationRegistry(ptr => wasm.__wbg_authenticatedlongpoll_free(ptr >>> 0, 1));
4452
+ const AuthenticatedTransportFinalization = (typeof FinalizationRegistry === 'undefined')
4453
+ ? { register: () => {}, unregister: () => {} }
4454
+ : new FinalizationRegistry(ptr => wasm.__wbg_authenticatedtransport_free(ptr >>> 0, 1));
4455
+ const AuthenticatedWebSocketFinalization = (typeof FinalizationRegistry === 'undefined')
4456
+ ? { register: () => {}, unregister: () => {} }
4457
+ : new FinalizationRegistry(ptr => wasm.__wbg_authenticatedwebsocket_free(ptr >>> 0, 1));
4458
+ const BatchSyncRequestFinalization = (typeof FinalizationRegistry === 'undefined')
4459
+ ? { register: () => {}, unregister: () => {} }
4460
+ : new FinalizationRegistry(ptr => wasm.__wbg_batchsyncrequest_free(ptr >>> 0, 1));
4461
+ const BatchSyncResponseFinalization = (typeof FinalizationRegistry === 'undefined')
4462
+ ? { register: () => {}, unregister: () => {} }
4463
+ : new FinalizationRegistry(ptr => wasm.__wbg_batchsyncresponse_free(ptr >>> 0, 1));
4464
+ const BlobMetaFinalization = (typeof FinalizationRegistry === 'undefined')
4465
+ ? { register: () => {}, unregister: () => {} }
4466
+ : new FinalizationRegistry(ptr => wasm.__wbg_blobmeta_free(ptr >>> 0, 1));
4467
+ const CallErrorFinalization = (typeof FinalizationRegistry === 'undefined')
4468
+ ? { register: () => {}, unregister: () => {} }
4469
+ : new FinalizationRegistry(ptr => wasm.__wbg_callerror_free(ptr >>> 0, 1));
4470
+ const CommitWithBlobFinalization = (typeof FinalizationRegistry === 'undefined')
4471
+ ? { register: () => {}, unregister: () => {} }
4472
+ : new FinalizationRegistry(ptr => wasm.__wbg_commitwithblob_free(ptr >>> 0, 1));
4473
+ const DepthFinalization = (typeof FinalizationRegistry === 'undefined')
4474
+ ? { register: () => {}, unregister: () => {} }
4475
+ : new FinalizationRegistry(ptr => wasm.__wbg_depth_free(ptr >>> 0, 1));
4476
+ const DigestFinalization = (typeof FinalizationRegistry === 'undefined')
4477
+ ? { register: () => {}, unregister: () => {} }
4478
+ : new FinalizationRegistry(ptr => wasm.__wbg_digest_free(ptr >>> 0, 1));
4479
+ const FragmentFinalization = (typeof FinalizationRegistry === 'undefined')
4480
+ ? { register: () => {}, unregister: () => {} }
4481
+ : new FinalizationRegistry(ptr => wasm.__wbg_fragment_free(ptr >>> 0, 1));
4482
+ const FragmentRequestedFinalization = (typeof FinalizationRegistry === 'undefined')
4483
+ ? { register: () => {}, unregister: () => {} }
4484
+ : new FinalizationRegistry(ptr => wasm.__wbg_fragmentrequested_free(ptr >>> 0, 1));
4485
+ const FragmentWithBlobFinalization = (typeof FinalizationRegistry === 'undefined')
4486
+ ? { register: () => {}, unregister: () => {} }
4487
+ : new FinalizationRegistry(ptr => wasm.__wbg_fragmentwithblob_free(ptr >>> 0, 1));
4488
+ const FragmentsArrayFinalization = (typeof FinalizationRegistry === 'undefined')
4489
+ ? { register: () => {}, unregister: () => {} }
4490
+ : new FinalizationRegistry(ptr => wasm.__wbg_fragmentsarray_free(ptr >>> 0, 1));
4491
+ const HashMetricFinalization = (typeof FinalizationRegistry === 'undefined')
4492
+ ? { register: () => {}, unregister: () => {} }
4493
+ : new FinalizationRegistry(ptr => wasm.__wbg_hashmetric_free(ptr >>> 0, 1));
4494
+ const SubductionHttpLongPollFinalization = (typeof FinalizationRegistry === 'undefined')
4495
+ ? { register: () => {}, unregister: () => {} }
4496
+ : new FinalizationRegistry(ptr => wasm.__wbg_subductionhttplongpoll_free(ptr >>> 0, 1));
4497
+ const SubductionLongPollFinalization = (typeof FinalizationRegistry === 'undefined')
4498
+ ? { register: () => {}, unregister: () => {} }
4499
+ : new FinalizationRegistry(ptr => wasm.__wbg_subductionlongpoll_free(ptr >>> 0, 1));
4500
+ const LooseCommitFinalization = (typeof FinalizationRegistry === 'undefined')
4501
+ ? { register: () => {}, unregister: () => {} }
4502
+ : new FinalizationRegistry(ptr => wasm.__wbg_loosecommit_free(ptr >>> 0, 1));
4503
+ const SyncMessageFinalization = (typeof FinalizationRegistry === 'undefined')
4504
+ ? { register: () => {}, unregister: () => {} }
4505
+ : new FinalizationRegistry(ptr => wasm.__wbg_syncmessage_free(ptr >>> 0, 1));
4506
+ const MessagePortTransportFinalization = (typeof FinalizationRegistry === 'undefined')
4507
+ ? { register: () => {}, unregister: () => {} }
4508
+ : new FinalizationRegistry(ptr => wasm.__wbg_messageporttransport_free(ptr >>> 0, 1));
4509
+ const NonceFinalization = (typeof FinalizationRegistry === 'undefined')
4510
+ ? { register: () => {}, unregister: () => {} }
4511
+ : new FinalizationRegistry(ptr => wasm.__wbg_nonce_free(ptr >>> 0, 1));
4512
+ const PeerIdFinalization = (typeof FinalizationRegistry === 'undefined')
4513
+ ? { register: () => {}, unregister: () => {} }
4514
+ : new FinalizationRegistry(ptr => wasm.__wbg_peerid_free(ptr >>> 0, 1));
4515
+ const PeerResultMapFinalization = (typeof FinalizationRegistry === 'undefined')
4516
+ ? { register: () => {}, unregister: () => {} }
4517
+ : new FinalizationRegistry(ptr => wasm.__wbg_peerresultmap_free(ptr >>> 0, 1));
4518
+ const RequestIdFinalization = (typeof FinalizationRegistry === 'undefined')
4519
+ ? { register: () => {}, unregister: () => {} }
4520
+ : new FinalizationRegistry(ptr => wasm.__wbg_requestid_free(ptr >>> 0, 1));
4521
+ const SedimentreeFinalization = (typeof FinalizationRegistry === 'undefined')
4522
+ ? { register: () => {}, unregister: () => {} }
4523
+ : new FinalizationRegistry(ptr => wasm.__wbg_sedimentree_free(ptr >>> 0, 1));
4524
+ const SedimentreeIdFinalization = (typeof FinalizationRegistry === 'undefined')
4525
+ ? { register: () => {}, unregister: () => {} }
4526
+ : new FinalizationRegistry(ptr => wasm.__wbg_sedimentreeid_free(ptr >>> 0, 1));
4527
+ const SedimentreeIdsArrayFinalization = (typeof FinalizationRegistry === 'undefined')
4528
+ ? { register: () => {}, unregister: () => {} }
4529
+ : new FinalizationRegistry(ptr => wasm.__wbg_sedimentreeidsarray_free(ptr >>> 0, 1));
4530
+ const SignedFragmentFinalization = (typeof FinalizationRegistry === 'undefined')
4531
+ ? { register: () => {}, unregister: () => {} }
4532
+ : new FinalizationRegistry(ptr => wasm.__wbg_signedfragment_free(ptr >>> 0, 1));
4533
+ const SignedLooseCommitFinalization = (typeof FinalizationRegistry === 'undefined')
4534
+ ? { register: () => {}, unregister: () => {} }
4535
+ : new FinalizationRegistry(ptr => wasm.__wbg_signedloosecommit_free(ptr >>> 0, 1));
4536
+ const SubductionFinalization = (typeof FinalizationRegistry === 'undefined')
4537
+ ? { register: () => {}, unregister: () => {} }
4538
+ : new FinalizationRegistry(ptr => wasm.__wbg_subduction_free(ptr >>> 0, 1));
4539
+ const SyncStatsFinalization = (typeof FinalizationRegistry === 'undefined')
4540
+ ? { register: () => {}, unregister: () => {} }
4541
+ : new FinalizationRegistry(ptr => wasm.__wbg_syncstats_free(ptr >>> 0, 1));
4542
+ const TopicFinalization = (typeof FinalizationRegistry === 'undefined')
4543
+ ? { register: () => {}, unregister: () => {} }
4544
+ : new FinalizationRegistry(ptr => wasm.__wbg_topic_free(ptr >>> 0, 1));
4545
+ const SubductionWebSocketFinalization = (typeof FinalizationRegistry === 'undefined')
4546
+ ? { register: () => {}, unregister: () => {} }
4547
+ : new FinalizationRegistry(ptr => wasm.__wbg_subductionwebsocket_free(ptr >>> 0, 1));
4548
+ const WebCryptoSignerFinalization = (typeof FinalizationRegistry === 'undefined')
4549
+ ? { register: () => {}, unregister: () => {} }
4550
+ : new FinalizationRegistry(ptr => wasm.__wbg_webcryptosigner_free(ptr >>> 0, 1));
4551
+
4552
+ function addToExternrefTable0(obj) {
4553
+ const idx = wasm.__wbindgen_export4();
4554
+ wasm.__wbindgen_externrefs.set(idx, obj);
4555
+ return idx;
4556
+ }
4557
+
4558
+ function _assertClass(instance, klass) {
4559
+ if (!(instance instanceof klass)) {
4560
+ throw new Error(`expected instance of ${klass.name}`);
4561
+ }
4562
+ }
4563
+
4564
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
4565
+ ? { register: () => {}, unregister: () => {} }
4566
+ : new FinalizationRegistry(state => state.dtor(state.a, state.b));
4567
+
4568
+ function debugString(val) {
4569
+ // primitive types
4570
+ const type = typeof val;
4571
+ if (type == 'number' || type == 'boolean' || val == null) {
4572
+ return `${val}`;
4573
+ }
4574
+ if (type == 'string') {
4575
+ return `"${val}"`;
4576
+ }
4577
+ if (type == 'symbol') {
4578
+ const description = val.description;
4579
+ if (description == null) {
4580
+ return 'Symbol';
4581
+ } else {
4582
+ return `Symbol(${description})`;
4583
+ }
4584
+ }
4585
+ if (type == 'function') {
4586
+ const name = val.name;
4587
+ if (typeof name == 'string' && name.length > 0) {
4588
+ return `Function(${name})`;
4589
+ } else {
4590
+ return 'Function';
4591
+ }
4592
+ }
4593
+ // objects
4594
+ if (Array.isArray(val)) {
4595
+ const length = val.length;
4596
+ let debug = '[';
4597
+ if (length > 0) {
4598
+ debug += debugString(val[0]);
4599
+ }
4600
+ for(let i = 1; i < length; i++) {
4601
+ debug += ', ' + debugString(val[i]);
4602
+ }
4603
+ debug += ']';
4604
+ return debug;
4605
+ }
4606
+ // Test for built-in
4607
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
4608
+ let className;
4609
+ if (builtInMatches && builtInMatches.length > 1) {
4610
+ className = builtInMatches[1];
4611
+ } else {
4612
+ // Failed to match the standard '[object ClassName]'
4613
+ return toString.call(val);
4614
+ }
4615
+ if (className == 'Object') {
4616
+ // we're a user defined class or Object
4617
+ // JSON.stringify avoids problems with cycles, and is generally much
4618
+ // easier than looping through ownProperties of `val`.
4619
+ try {
4620
+ return 'Object(' + JSON.stringify(val) + ')';
4621
+ } catch (_) {
4622
+ return 'Object';
4623
+ }
4624
+ }
4625
+ // errors
4626
+ if (val instanceof Error) {
4627
+ return `${val.name}: ${val.message}\n${val.stack}`;
4628
+ }
4629
+ // TODO we could test for more things here, like `Set`s and `Map`s.
4630
+ return className;
4631
+ }
4632
+
4633
+ function getArrayJsValueFromWasm0(ptr, len) {
4634
+ ptr = ptr >>> 0;
4635
+ const mem = getDataViewMemory0();
4636
+ const result = [];
4637
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
4638
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
4639
+ }
4640
+ wasm.__wbindgen_export6(ptr, len);
4641
+ return result;
4642
+ }
4643
+
4644
+ function getArrayU8FromWasm0(ptr, len) {
4645
+ ptr = ptr >>> 0;
4646
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
4647
+ }
4648
+
4649
+ let cachedDataViewMemory0 = null;
4650
+ function getDataViewMemory0() {
4651
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
4652
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
4653
+ }
4654
+ return cachedDataViewMemory0;
4655
+ }
4656
+
4657
+ function getStringFromWasm0(ptr, len) {
4658
+ ptr = ptr >>> 0;
4659
+ return decodeText(ptr, len);
4660
+ }
4661
+
4662
+ let cachedUint8ArrayMemory0 = null;
4663
+ function getUint8ArrayMemory0() {
4664
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
4665
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
4666
+ }
4667
+ return cachedUint8ArrayMemory0;
4668
+ }
4669
+
4670
+ function handleError(f, args) {
4671
+ try {
4672
+ return f.apply(this, args);
4673
+ } catch (e) {
4674
+ const idx = addToExternrefTable0(e);
4675
+ wasm.__wbindgen_export3(idx);
4676
+ }
4677
+ }
4678
+
4679
+ function isLikeNone(x) {
4680
+ return x === undefined || x === null;
4681
+ }
4682
+
4683
+ function makeClosure(arg0, arg1, dtor, f) {
4684
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
4685
+ const real = (...args) => {
4686
+
4687
+ // First up with a closure we increment the internal reference
4688
+ // count. This ensures that the Rust closure environment won't
4689
+ // be deallocated while we're invoking it.
4690
+ state.cnt++;
4691
+ try {
4692
+ return f(state.a, state.b, ...args);
4693
+ } finally {
4694
+ real._wbg_cb_unref();
4695
+ }
4696
+ };
4697
+ real._wbg_cb_unref = () => {
4698
+ if (--state.cnt === 0) {
4699
+ state.dtor(state.a, state.b);
4700
+ state.a = 0;
4701
+ CLOSURE_DTORS.unregister(state);
4702
+ }
4703
+ };
4704
+ CLOSURE_DTORS.register(real, state, state);
4705
+ return real;
4706
+ }
4707
+
4708
+ function makeMutClosure(arg0, arg1, dtor, f) {
4709
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
4710
+ const real = (...args) => {
4711
+
4712
+ // First up with a closure we increment the internal reference
4713
+ // count. This ensures that the Rust closure environment won't
4714
+ // be deallocated while we're invoking it.
4715
+ state.cnt++;
4716
+ const a = state.a;
4717
+ state.a = 0;
4718
+ try {
4719
+ return f(a, state.b, ...args);
4720
+ } finally {
4721
+ state.a = a;
4722
+ real._wbg_cb_unref();
4723
+ }
4724
+ };
4725
+ real._wbg_cb_unref = () => {
4726
+ if (--state.cnt === 0) {
4727
+ state.dtor(state.a, state.b);
4728
+ state.a = 0;
4729
+ CLOSURE_DTORS.unregister(state);
4730
+ }
4731
+ };
4732
+ CLOSURE_DTORS.register(real, state, state);
4733
+ return real;
4734
+ }
4735
+
4736
+ function passArray8ToWasm0(arg, malloc) {
4737
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
4738
+ getUint8ArrayMemory0().set(arg, ptr / 1);
4739
+ WASM_VECTOR_LEN = arg.length;
4740
+ return ptr;
4741
+ }
4742
+
4743
+ function passArrayJsValueToWasm0(array, malloc) {
4744
+ const ptr = malloc(array.length * 4, 4) >>> 0;
4745
+ for (let i = 0; i < array.length; i++) {
4746
+ const add = addToExternrefTable0(array[i]);
4747
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
4748
+ }
4749
+ WASM_VECTOR_LEN = array.length;
4750
+ return ptr;
4751
+ }
4752
+
4753
+ function passStringToWasm0(arg, malloc, realloc) {
4754
+ if (realloc === undefined) {
4755
+ const buf = cachedTextEncoder.encode(arg);
4756
+ const ptr = malloc(buf.length, 1) >>> 0;
4757
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
4758
+ WASM_VECTOR_LEN = buf.length;
4759
+ return ptr;
4760
+ }
4761
+
4762
+ let len = arg.length;
4763
+ let ptr = malloc(len, 1) >>> 0;
4764
+
4765
+ const mem = getUint8ArrayMemory0();
4766
+
4767
+ let offset = 0;
4768
+
4769
+ for (; offset < len; offset++) {
4770
+ const code = arg.charCodeAt(offset);
4771
+ if (code > 0x7F) break;
4772
+ mem[ptr + offset] = code;
4773
+ }
4774
+ if (offset !== len) {
4775
+ if (offset !== 0) {
4776
+ arg = arg.slice(offset);
4777
+ }
4778
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
4779
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
4780
+ const ret = cachedTextEncoder.encodeInto(arg, view);
4781
+
4782
+ offset += ret.written;
4783
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
4784
+ }
4785
+
4786
+ WASM_VECTOR_LEN = offset;
4787
+ return ptr;
4788
+ }
4789
+
4790
+ function takeFromExternrefTable0(idx) {
4791
+ const value = wasm.__wbindgen_externrefs.get(idx);
4792
+ wasm.__wbindgen_export7(idx);
4793
+ return value;
4794
+ }
4795
+
4796
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
4797
+ cachedTextDecoder.decode();
4798
+ function decodeText(ptr, len) {
4799
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
4800
+ }
4801
+
4802
+ const cachedTextEncoder = new TextEncoder();
4803
+
4804
+ if (!('encodeInto' in cachedTextEncoder)) {
4805
+ cachedTextEncoder.encodeInto = function (arg, view) {
4806
+ const buf = cachedTextEncoder.encode(arg);
4807
+ view.set(buf);
4808
+ return {
4809
+ read: arg.length,
4810
+ written: buf.length
4811
+ };
4812
+ };
4813
+ }
4814
+
4815
+ let WASM_VECTOR_LEN = 0;
4816
+
4817
+ const wasmPath = `${__dirname}/subduction_wasm_bg.wasm`;
4818
+ const wasmBytes = require('fs').readFileSync(wasmPath);
4819
+ const wasmModule = new WebAssembly.Module(wasmBytes);
4820
+ let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
4821
+ wasm.__wbindgen_start();