@automerge/subduction 0.10.0 → 0.10.2

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 +4800 -0
  5. package/dist/cjs/web.cjs +4751 -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 +4709 -0
  13. package/dist/index.d.ts +1710 -0
  14. package/dist/subduction.wasm +0 -0
  15. package/dist/wasm_bindgen/bundler/snippets/sedimentree_wasm-c507f5285f2927a0/inline0.js +2 -0
  16. package/dist/wasm_bindgen/bundler/snippets/sedimentree_wasm-c507f5285f2927a0/inline1.js +2 -0
  17. package/dist/wasm_bindgen/bundler/snippets/sedimentree_wasm-c507f5285f2927a0/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 +1710 -0
  21. package/dist/wasm_bindgen/bundler/subduction_wasm.js +9 -0
  22. package/dist/wasm_bindgen/bundler/subduction_wasm_bg.js +4806 -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 +247 -0
  25. package/dist/wasm_bindgen/nodejs/snippets/sedimentree_wasm-c507f5285f2927a0/inline0.js +2 -0
  26. package/dist/wasm_bindgen/nodejs/snippets/sedimentree_wasm-c507f5285f2927a0/inline1.js +2 -0
  27. package/dist/wasm_bindgen/nodejs/snippets/sedimentree_wasm-c507f5285f2927a0/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 +4853 -0
  31. package/dist/wasm_bindgen/nodejs/subduction_wasm.d.ts +1710 -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 +247 -0
  34. package/dist/wasm_bindgen/web/snippets/sedimentree_wasm-c507f5285f2927a0/inline0.js +2 -0
  35. package/dist/wasm_bindgen/web/snippets/sedimentree_wasm-c507f5285f2927a0/inline1.js +2 -0
  36. package/dist/wasm_bindgen/web/snippets/sedimentree_wasm-c507f5285f2927a0/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 +1982 -0
  40. package/dist/wasm_bindgen/web/subduction_wasm.js +4911 -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 +247 -0
  43. package/package.json +1 -1
@@ -0,0 +1,4853 @@
1
+ /* @ts-self-types="./subduction_wasm.d.ts" */
2
+ const { tryIntoJsSedimentreeIdsArray } = require(String.raw`./snippets/sedimentree_wasm-c507f5285f2927a0/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 commits and fragments in a single batch.
1322
+ * @param {SedimentreeId} sedimentree_id
1323
+ * @param {Array<any>} commits
1324
+ * @param {Array<any>} fragments
1325
+ * @returns {Promise<any>}
1326
+ */
1327
+ saveBatchAll(sedimentree_id, commits, fragments) {
1328
+ _assertClass(sedimentree_id, SedimentreeId);
1329
+ const ret = wasm.memorystorage_saveBatchAll(this.__wbg_ptr, sedimentree_id.__wbg_ptr, commits, fragments);
1330
+ return ret;
1331
+ }
1332
+ /**
1333
+ * Save a commit with its blob.
1334
+ * @param {SedimentreeId} sedimentree_id
1335
+ * @param {Digest} _digest
1336
+ * @param {SignedLooseCommit} signed_commit
1337
+ * @param {Uint8Array} blob
1338
+ * @returns {Promise<any>}
1339
+ */
1340
+ saveCommit(sedimentree_id, _digest, signed_commit, blob) {
1341
+ _assertClass(sedimentree_id, SedimentreeId);
1342
+ _assertClass(_digest, Digest);
1343
+ _assertClass(signed_commit, SignedLooseCommit);
1344
+ const ret = wasm.memorystorage_saveCommit(this.__wbg_ptr, sedimentree_id.__wbg_ptr, _digest.__wbg_ptr, signed_commit.__wbg_ptr, blob);
1345
+ return ret;
1346
+ }
1347
+ /**
1348
+ * Save a fragment with its blob.
1349
+ * @param {SedimentreeId} sedimentree_id
1350
+ * @param {Digest} _digest
1351
+ * @param {SignedFragment} signed_fragment
1352
+ * @param {Uint8Array} blob
1353
+ * @returns {Promise<any>}
1354
+ */
1355
+ saveFragment(sedimentree_id, _digest, signed_fragment, blob) {
1356
+ _assertClass(sedimentree_id, SedimentreeId);
1357
+ _assertClass(_digest, Digest);
1358
+ _assertClass(signed_fragment, SignedFragment);
1359
+ const ret = wasm.memorystorage_saveFragment(this.__wbg_ptr, sedimentree_id.__wbg_ptr, _digest.__wbg_ptr, signed_fragment.__wbg_ptr, blob);
1360
+ return ret;
1361
+ }
1362
+ /**
1363
+ * Save a sedimentree ID.
1364
+ * @param {SedimentreeId} sedimentree_id
1365
+ * @returns {Promise<any>}
1366
+ */
1367
+ saveSedimentreeId(sedimentree_id) {
1368
+ _assertClass(sedimentree_id, SedimentreeId);
1369
+ const ret = wasm.memorystorage_saveSedimentreeId(this.__wbg_ptr, sedimentree_id.__wbg_ptr);
1370
+ return ret;
1371
+ }
1372
+ }
1373
+ if (Symbol.dispose) MemoryStorage.prototype[Symbol.dispose] = MemoryStorage.prototype.free;
1374
+ exports.MemoryStorage = MemoryStorage;
1375
+
1376
+ /**
1377
+ * A `Transport` backed by a `MessagePort` (or any object with
1378
+ * `postMessage` / `onmessage` / `close`).
1379
+ *
1380
+ * Implements the byte-oriented `Transport` interface (`sendBytes`,
1381
+ * `recvBytes`, `disconnect`) using the port as the underlying channel.
1382
+ * After the handshake, the [`Authenticated`] wrapper provides the sync API.
1383
+ */
1384
+ class MessagePortTransport {
1385
+ static __wrap(ptr) {
1386
+ ptr = ptr >>> 0;
1387
+ const obj = Object.create(MessagePortTransport.prototype);
1388
+ obj.__wbg_ptr = ptr;
1389
+ MessagePortTransportFinalization.register(obj, obj.__wbg_ptr, obj);
1390
+ return obj;
1391
+ }
1392
+ __destroy_into_raw() {
1393
+ const ptr = this.__wbg_ptr;
1394
+ this.__wbg_ptr = 0;
1395
+ MessagePortTransportFinalization.unregister(this);
1396
+ return ptr;
1397
+ }
1398
+ free() {
1399
+ const ptr = this.__destroy_into_raw();
1400
+ wasm.__wbg_messageporttransport_free(ptr, 0);
1401
+ }
1402
+ /**
1403
+ * Disconnect (close the port) and fire the `onDisconnect` callback if registered.
1404
+ * @returns {Promise<any>}
1405
+ */
1406
+ disconnect() {
1407
+ const ret = wasm.messageporttransport_disconnect(this.__wbg_ptr);
1408
+ return ret;
1409
+ }
1410
+ /**
1411
+ * Create a new connection wrapping the given `MessagePort`.
1412
+ * @param {any} port
1413
+ */
1414
+ constructor(port) {
1415
+ const ret = wasm.messageporttransport_new(port);
1416
+ this.__wbg_ptr = ret >>> 0;
1417
+ MessagePortTransportFinalization.register(this, this.__wbg_ptr, this);
1418
+ return this;
1419
+ }
1420
+ /**
1421
+ * Register a callback to be invoked when the transport disconnects.
1422
+ *
1423
+ * Part of the [`Transport`](super::JsTransport) interface contract.
1424
+ * Typically called by internal wiring rather than directly by user code.
1425
+ * @param {Function} callback
1426
+ */
1427
+ onDisconnect(callback) {
1428
+ wasm.messageporttransport_onDisconnect(this.__wbg_ptr, callback);
1429
+ }
1430
+ /**
1431
+ * Receive raw bytes (for the handshake phase).
1432
+ * @returns {Promise<any>}
1433
+ */
1434
+ recvBytes() {
1435
+ const ret = wasm.messageporttransport_recvBytes(this.__wbg_ptr);
1436
+ return ret;
1437
+ }
1438
+ /**
1439
+ * Send raw bytes (for the handshake phase).
1440
+ * @param {Uint8Array} bytes
1441
+ * @returns {Promise<any>}
1442
+ */
1443
+ sendBytes(bytes) {
1444
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
1445
+ const len0 = WASM_VECTOR_LEN;
1446
+ const ret = wasm.messageporttransport_sendBytes(this.__wbg_ptr, ptr0, len0);
1447
+ return ret;
1448
+ }
1449
+ }
1450
+ if (Symbol.dispose) MessagePortTransport.prototype[Symbol.dispose] = MessagePortTransport.prototype.free;
1451
+ exports.MessagePortTransport = MessagePortTransport;
1452
+
1453
+ /**
1454
+ * A 64-bit nonce represented as big-endian bytes.
1455
+ */
1456
+ class Nonce {
1457
+ static __wrap(ptr) {
1458
+ ptr = ptr >>> 0;
1459
+ const obj = Object.create(Nonce.prototype);
1460
+ obj.__wbg_ptr = ptr;
1461
+ NonceFinalization.register(obj, obj.__wbg_ptr, obj);
1462
+ return obj;
1463
+ }
1464
+ __destroy_into_raw() {
1465
+ const ptr = this.__wbg_ptr;
1466
+ this.__wbg_ptr = 0;
1467
+ NonceFinalization.unregister(this);
1468
+ return ptr;
1469
+ }
1470
+ free() {
1471
+ const ptr = this.__destroy_into_raw();
1472
+ wasm.__wbg_nonce_free(ptr, 0);
1473
+ }
1474
+ /**
1475
+ * Get the nonce as big-endian bytes.
1476
+ * @returns {Uint8Array}
1477
+ */
1478
+ get bytes() {
1479
+ const ret = wasm.nonce_bytes(this.__wbg_ptr);
1480
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1481
+ wasm.__wbindgen_export5(ret[0], ret[1] * 1, 1);
1482
+ return v1;
1483
+ }
1484
+ /**
1485
+ * Create a new [`WasmNonce`] from exactly 8 big-endian bytes.
1486
+ *
1487
+ * # Errors
1488
+ *
1489
+ * Returns [`WasmNonceError`] if the input is not exactly 8 bytes.
1490
+ * @param {Uint8Array} bytes
1491
+ */
1492
+ constructor(bytes) {
1493
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
1494
+ const len0 = WASM_VECTOR_LEN;
1495
+ const ret = wasm.nonce_new(ptr0, len0);
1496
+ if (ret[2]) {
1497
+ throw takeFromExternrefTable0(ret[1]);
1498
+ }
1499
+ this.__wbg_ptr = ret[0] >>> 0;
1500
+ NonceFinalization.register(this, this.__wbg_ptr, this);
1501
+ return this;
1502
+ }
1503
+ /**
1504
+ * Generate a random nonce.
1505
+ *
1506
+ * # Panics
1507
+ *
1508
+ * Panics if the system random number generator fails.
1509
+ * @returns {Nonce}
1510
+ */
1511
+ static random() {
1512
+ const ret = wasm.nonce_random();
1513
+ return Nonce.__wrap(ret);
1514
+ }
1515
+ }
1516
+ if (Symbol.dispose) Nonce.prototype[Symbol.dispose] = Nonce.prototype.free;
1517
+ exports.Nonce = Nonce;
1518
+
1519
+ /**
1520
+ * Result of a peer batch sync request.
1521
+ */
1522
+ class PeerBatchSyncResult {
1523
+ static __wrap(ptr) {
1524
+ ptr = ptr >>> 0;
1525
+ const obj = Object.create(PeerBatchSyncResult.prototype);
1526
+ obj.__wbg_ptr = ptr;
1527
+ PeerBatchSyncResultFinalization.register(obj, obj.__wbg_ptr, obj);
1528
+ return obj;
1529
+ }
1530
+ __destroy_into_raw() {
1531
+ const ptr = this.__wbg_ptr;
1532
+ this.__wbg_ptr = 0;
1533
+ PeerBatchSyncResultFinalization.unregister(this);
1534
+ return ptr;
1535
+ }
1536
+ free() {
1537
+ const ptr = this.__destroy_into_raw();
1538
+ wasm.__wbg_peerbatchsyncresult_free(ptr, 0);
1539
+ }
1540
+ /**
1541
+ * Statistics about the sync operation.
1542
+ * @returns {SyncStats}
1543
+ */
1544
+ get stats() {
1545
+ const ret = wasm.peerbatchsyncresult_stats(this.__wbg_ptr);
1546
+ return SyncStats.__wrap(ret);
1547
+ }
1548
+ /**
1549
+ * Whether the batch sync was successful with at least one connection.
1550
+ * @returns {boolean}
1551
+ */
1552
+ get success() {
1553
+ const ret = wasm.peerbatchsyncresult_success(this.__wbg_ptr);
1554
+ return ret !== 0;
1555
+ }
1556
+ /**
1557
+ * Errors that occurred during the batch sync.
1558
+ * @returns {Error[]}
1559
+ */
1560
+ get transportErrors() {
1561
+ const ret = wasm.peerbatchsyncresult_transportErrors(this.__wbg_ptr);
1562
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
1563
+ wasm.__wbindgen_export5(ret[0], ret[1] * 4, 4);
1564
+ return v1;
1565
+ }
1566
+ }
1567
+ if (Symbol.dispose) PeerBatchSyncResult.prototype[Symbol.dispose] = PeerBatchSyncResult.prototype.free;
1568
+ exports.PeerBatchSyncResult = PeerBatchSyncResult;
1569
+
1570
+ /**
1571
+ * A JavaScript-compatible wrapper around the Rust `PeerId` type.
1572
+ */
1573
+ class PeerId {
1574
+ static __wrap(ptr) {
1575
+ ptr = ptr >>> 0;
1576
+ const obj = Object.create(PeerId.prototype);
1577
+ obj.__wbg_ptr = ptr;
1578
+ PeerIdFinalization.register(obj, obj.__wbg_ptr, obj);
1579
+ return obj;
1580
+ }
1581
+ __destroy_into_raw() {
1582
+ const ptr = this.__wbg_ptr;
1583
+ this.__wbg_ptr = 0;
1584
+ PeerIdFinalization.unregister(this);
1585
+ return ptr;
1586
+ }
1587
+ free() {
1588
+ const ptr = this.__destroy_into_raw();
1589
+ wasm.__wbg_peerid_free(ptr, 0);
1590
+ }
1591
+ /**
1592
+ * Creates a new `WasmPeerId` from a `PeerId`.
1593
+ *
1594
+ * # Errors
1595
+ *
1596
+ * Returns a `WasmInvalidPeerId` if the provided byte slice is not exactly 32 bytes long.
1597
+ * @param {Uint8Array} bytes
1598
+ */
1599
+ constructor(bytes) {
1600
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
1601
+ const len0 = WASM_VECTOR_LEN;
1602
+ const ret = wasm.peerid_new(ptr0, len0);
1603
+ if (ret[2]) {
1604
+ throw takeFromExternrefTable0(ret[1]);
1605
+ }
1606
+ this.__wbg_ptr = ret[0] >>> 0;
1607
+ PeerIdFinalization.register(this, this.__wbg_ptr, this);
1608
+ return this;
1609
+ }
1610
+ /**
1611
+ * Returns the byte representation of the `PeerId`.
1612
+ * @returns {Uint8Array}
1613
+ */
1614
+ toBytes() {
1615
+ const ret = wasm.peerid_toBytes(this.__wbg_ptr);
1616
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1617
+ wasm.__wbindgen_export5(ret[0], ret[1] * 1, 1);
1618
+ return v1;
1619
+ }
1620
+ /**
1621
+ * Returns the string representation of the `PeerId`.
1622
+ * @returns {string}
1623
+ */
1624
+ toString() {
1625
+ let deferred1_0;
1626
+ let deferred1_1;
1627
+ try {
1628
+ const ret = wasm.peerid_toString(this.__wbg_ptr);
1629
+ deferred1_0 = ret[0];
1630
+ deferred1_1 = ret[1];
1631
+ return getStringFromWasm0(ret[0], ret[1]);
1632
+ } finally {
1633
+ wasm.__wbindgen_export5(deferred1_0, deferred1_1, 1);
1634
+ }
1635
+ }
1636
+ }
1637
+ if (Symbol.dispose) PeerId.prototype[Symbol.dispose] = PeerId.prototype.free;
1638
+ exports.PeerId = PeerId;
1639
+
1640
+ /**
1641
+ * Map of peer IDs to their batch sync results.
1642
+ */
1643
+ class PeerResultMap {
1644
+ static __wrap(ptr) {
1645
+ ptr = ptr >>> 0;
1646
+ const obj = Object.create(PeerResultMap.prototype);
1647
+ obj.__wbg_ptr = ptr;
1648
+ PeerResultMapFinalization.register(obj, obj.__wbg_ptr, obj);
1649
+ return obj;
1650
+ }
1651
+ __destroy_into_raw() {
1652
+ const ptr = this.__wbg_ptr;
1653
+ this.__wbg_ptr = 0;
1654
+ PeerResultMapFinalization.unregister(this);
1655
+ return ptr;
1656
+ }
1657
+ free() {
1658
+ const ptr = this.__destroy_into_raw();
1659
+ wasm.__wbg_peerresultmap_free(ptr, 0);
1660
+ }
1661
+ /**
1662
+ * Get all entries in the peer result map.
1663
+ * @returns {PeerBatchSyncResult[]}
1664
+ */
1665
+ entries() {
1666
+ const ret = wasm.peerresultmap_entries(this.__wbg_ptr);
1667
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
1668
+ wasm.__wbindgen_export5(ret[0], ret[1] * 4, 4);
1669
+ return v1;
1670
+ }
1671
+ /**
1672
+ * Get the result for a specific peer ID.
1673
+ * @param {PeerId} peer_id
1674
+ * @returns {PeerBatchSyncResult | undefined}
1675
+ */
1676
+ getResult(peer_id) {
1677
+ _assertClass(peer_id, PeerId);
1678
+ const ret = wasm.peerresultmap_getResult(this.__wbg_ptr, peer_id.__wbg_ptr);
1679
+ return ret === 0 ? undefined : PeerBatchSyncResult.__wrap(ret);
1680
+ }
1681
+ }
1682
+ if (Symbol.dispose) PeerResultMap.prototype[Symbol.dispose] = PeerResultMap.prototype.free;
1683
+ exports.PeerResultMap = PeerResultMap;
1684
+
1685
+ /**
1686
+ * Wasm wrapper for [`RequestId`].
1687
+ */
1688
+ class RequestId {
1689
+ static __wrap(ptr) {
1690
+ ptr = ptr >>> 0;
1691
+ const obj = Object.create(RequestId.prototype);
1692
+ obj.__wbg_ptr = ptr;
1693
+ RequestIdFinalization.register(obj, obj.__wbg_ptr, obj);
1694
+ return obj;
1695
+ }
1696
+ __destroy_into_raw() {
1697
+ const ptr = this.__wbg_ptr;
1698
+ this.__wbg_ptr = 0;
1699
+ RequestIdFinalization.unregister(this);
1700
+ return ptr;
1701
+ }
1702
+ free() {
1703
+ const ptr = this.__destroy_into_raw();
1704
+ wasm.__wbg_requestid_free(ptr, 0);
1705
+ }
1706
+ /**
1707
+ * Upcasts; to the JS-import type for [`WasmRequestId`].
1708
+ * @returns {RequestId}
1709
+ */
1710
+ __wasm_refgen_toWasmRequestId() {
1711
+ const ret = wasm.requestid___wasm_refgen_toWasmRequestId(this.__wbg_ptr);
1712
+ return RequestId.__wrap(ret);
1713
+ }
1714
+ /**
1715
+ * Create a new [`RequestId`] from a requestor peer ID and nonce.
1716
+ * @param {PeerId} requestor
1717
+ * @param {Nonce} nonce
1718
+ */
1719
+ constructor(requestor, nonce) {
1720
+ _assertClass(requestor, PeerId);
1721
+ _assertClass(nonce, Nonce);
1722
+ const ret = wasm.requestid_new(requestor.__wbg_ptr, nonce.__wbg_ptr);
1723
+ this.__wbg_ptr = ret >>> 0;
1724
+ RequestIdFinalization.register(this, this.__wbg_ptr, this);
1725
+ return this;
1726
+ }
1727
+ /**
1728
+ * The request nonce.
1729
+ * @returns {Nonce}
1730
+ */
1731
+ get nonce() {
1732
+ const ret = wasm.requestid_nonce(this.__wbg_ptr);
1733
+ return Nonce.__wrap(ret);
1734
+ }
1735
+ /**
1736
+ * The peer ID of the requestor.
1737
+ * @returns {PeerId}
1738
+ */
1739
+ get requestor() {
1740
+ const ret = wasm.requestid_requestor(this.__wbg_ptr);
1741
+ return PeerId.__wrap(ret);
1742
+ }
1743
+ }
1744
+ if (Symbol.dispose) RequestId.prototype[Symbol.dispose] = RequestId.prototype.free;
1745
+ exports.RequestId = RequestId;
1746
+
1747
+ /**
1748
+ * The main Sedimentree data structure.
1749
+ */
1750
+ class Sedimentree {
1751
+ static __wrap(ptr) {
1752
+ ptr = ptr >>> 0;
1753
+ const obj = Object.create(Sedimentree.prototype);
1754
+ obj.__wbg_ptr = ptr;
1755
+ SedimentreeFinalization.register(obj, obj.__wbg_ptr, obj);
1756
+ return obj;
1757
+ }
1758
+ __destroy_into_raw() {
1759
+ const ptr = this.__wbg_ptr;
1760
+ this.__wbg_ptr = 0;
1761
+ SedimentreeFinalization.unregister(this);
1762
+ return ptr;
1763
+ }
1764
+ free() {
1765
+ const ptr = this.__destroy_into_raw();
1766
+ wasm.__wbg_sedimentree_free(ptr, 0);
1767
+ }
1768
+ /**
1769
+ * Create an empty Sedimentree.
1770
+ * @returns {Sedimentree}
1771
+ */
1772
+ static empty() {
1773
+ const ret = wasm.sedimentree_empty();
1774
+ return Sedimentree.__wrap(ret);
1775
+ }
1776
+ /**
1777
+ * Create a new Sedimentree from fragments and loose commits.
1778
+ * @param {Fragment[]} fragments
1779
+ * @param {LooseCommit[]} commits
1780
+ */
1781
+ constructor(fragments, commits) {
1782
+ const ptr0 = passArrayJsValueToWasm0(fragments, wasm.__wbindgen_export);
1783
+ const len0 = WASM_VECTOR_LEN;
1784
+ const ptr1 = passArrayJsValueToWasm0(commits, wasm.__wbindgen_export);
1785
+ const len1 = WASM_VECTOR_LEN;
1786
+ const ret = wasm.sedimentree_new(ptr0, len0, ptr1, len1);
1787
+ this.__wbg_ptr = ret >>> 0;
1788
+ SedimentreeFinalization.register(this, this.__wbg_ptr, this);
1789
+ return this;
1790
+ }
1791
+ }
1792
+ if (Symbol.dispose) Sedimentree.prototype[Symbol.dispose] = Sedimentree.prototype.free;
1793
+ exports.Sedimentree = Sedimentree;
1794
+
1795
+ /**
1796
+ * A Wasm wrapper around the [`SedimentreeId`] type.
1797
+ */
1798
+ class SedimentreeId {
1799
+ static __wrap(ptr) {
1800
+ ptr = ptr >>> 0;
1801
+ const obj = Object.create(SedimentreeId.prototype);
1802
+ obj.__wbg_ptr = ptr;
1803
+ SedimentreeIdFinalization.register(obj, obj.__wbg_ptr, obj);
1804
+ return obj;
1805
+ }
1806
+ static __unwrap(jsValue) {
1807
+ if (!(jsValue instanceof SedimentreeId)) {
1808
+ return 0;
1809
+ }
1810
+ return jsValue.__destroy_into_raw();
1811
+ }
1812
+ __destroy_into_raw() {
1813
+ const ptr = this.__wbg_ptr;
1814
+ this.__wbg_ptr = 0;
1815
+ SedimentreeIdFinalization.unregister(this);
1816
+ return ptr;
1817
+ }
1818
+ free() {
1819
+ const ptr = this.__destroy_into_raw();
1820
+ wasm.__wbg_sedimentreeid_free(ptr, 0);
1821
+ }
1822
+ /**
1823
+ * Upcasts; to the JS-import type for [`WasmSedimentreeId`].
1824
+ * @returns {SedimentreeId}
1825
+ */
1826
+ __wasm_refgen_toWasmSedimentreeId() {
1827
+ const ret = wasm.sedimentreeid___wasm_refgen_toWasmSedimentreeId(this.__wbg_ptr);
1828
+ return SedimentreeId.__wrap(ret);
1829
+ }
1830
+ /**
1831
+ * Create an ID from a byte array.
1832
+ *
1833
+ * # Errors
1834
+ *
1835
+ * Returns `Not32Bytes` if the provided byte array is not exactly 32 bytes long.
1836
+ * @param {Uint8Array} bytes
1837
+ * @returns {SedimentreeId}
1838
+ */
1839
+ static fromBytes(bytes) {
1840
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
1841
+ const len0 = WASM_VECTOR_LEN;
1842
+ const ret = wasm.sedimentreeid_fromBytes(ptr0, len0);
1843
+ if (ret[2]) {
1844
+ throw takeFromExternrefTable0(ret[1]);
1845
+ }
1846
+ return SedimentreeId.__wrap(ret[0]);
1847
+ }
1848
+ /**
1849
+ * Returns the raw bytes of this ID.
1850
+ * @returns {Uint8Array}
1851
+ */
1852
+ toBytes() {
1853
+ const ret = wasm.sedimentreeid_toBytes(this.__wbg_ptr);
1854
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1855
+ wasm.__wbindgen_export5(ret[0], ret[1] * 1, 1);
1856
+ return v1;
1857
+ }
1858
+ /**
1859
+ * Returns the string representation of the ID.
1860
+ * @returns {string}
1861
+ */
1862
+ toString() {
1863
+ let deferred1_0;
1864
+ let deferred1_1;
1865
+ try {
1866
+ const ret = wasm.sedimentreeid_toString(this.__wbg_ptr);
1867
+ deferred1_0 = ret[0];
1868
+ deferred1_1 = ret[1];
1869
+ return getStringFromWasm0(ret[0], ret[1]);
1870
+ } finally {
1871
+ wasm.__wbindgen_export5(deferred1_0, deferred1_1, 1);
1872
+ }
1873
+ }
1874
+ }
1875
+ if (Symbol.dispose) SedimentreeId.prototype[Symbol.dispose] = SedimentreeId.prototype.free;
1876
+ exports.SedimentreeId = SedimentreeId;
1877
+
1878
+ class SedimentreeIdsArray {
1879
+ static __wrap(ptr) {
1880
+ ptr = ptr >>> 0;
1881
+ const obj = Object.create(SedimentreeIdsArray.prototype);
1882
+ obj.__wbg_ptr = ptr;
1883
+ SedimentreeIdsArrayFinalization.register(obj, obj.__wbg_ptr, obj);
1884
+ return obj;
1885
+ }
1886
+ __destroy_into_raw() {
1887
+ const ptr = this.__wbg_ptr;
1888
+ this.__wbg_ptr = 0;
1889
+ SedimentreeIdsArrayFinalization.unregister(this);
1890
+ return ptr;
1891
+ }
1892
+ free() {
1893
+ const ptr = this.__destroy_into_raw();
1894
+ wasm.__wbg_sedimentreeidsarray_free(ptr, 0);
1895
+ }
1896
+ /**
1897
+ * Upcasts; to the JS-import type for [`WasmSedimentreeIdsArray`].
1898
+ * @returns {SedimentreeIdsArray}
1899
+ */
1900
+ __wasm_refgen_toWasmSedimentreeIdsArray() {
1901
+ const ret = wasm.sedimentreeidsarray___wasm_refgen_toWasmSedimentreeIdsArray(this.__wbg_ptr);
1902
+ return SedimentreeIdsArray.__wrap(ret);
1903
+ }
1904
+ }
1905
+ if (Symbol.dispose) SedimentreeIdsArray.prototype[Symbol.dispose] = SedimentreeIdsArray.prototype.free;
1906
+ exports.SedimentreeIdsArray = SedimentreeIdsArray;
1907
+
1908
+ /**
1909
+ * A Wasm wrapper around `Signed<Fragment>`.
1910
+ */
1911
+ class SignedFragment {
1912
+ static __wrap(ptr) {
1913
+ ptr = ptr >>> 0;
1914
+ const obj = Object.create(SignedFragment.prototype);
1915
+ obj.__wbg_ptr = ptr;
1916
+ SignedFragmentFinalization.register(obj, obj.__wbg_ptr, obj);
1917
+ return obj;
1918
+ }
1919
+ static __unwrap(jsValue) {
1920
+ if (!(jsValue instanceof SignedFragment)) {
1921
+ return 0;
1922
+ }
1923
+ return jsValue.__destroy_into_raw();
1924
+ }
1925
+ __destroy_into_raw() {
1926
+ const ptr = this.__wbg_ptr;
1927
+ this.__wbg_ptr = 0;
1928
+ SignedFragmentFinalization.unregister(this);
1929
+ return ptr;
1930
+ }
1931
+ free() {
1932
+ const ptr = this.__destroy_into_raw();
1933
+ wasm.__wbg_signedfragment_free(ptr, 0);
1934
+ }
1935
+ /**
1936
+ * Upcasts; to the JS-import type for [`WasmSignedFragment`].
1937
+ * @returns {SignedFragment}
1938
+ */
1939
+ __wasm_refgen_toWasmSignedFragment() {
1940
+ const ret = wasm.signedfragment___wasm_refgen_toWasmSignedFragment(this.__wbg_ptr);
1941
+ return SignedFragment.__wrap(ret);
1942
+ }
1943
+ /**
1944
+ * Encode this signed fragment to raw bytes.
1945
+ * @returns {Uint8Array}
1946
+ */
1947
+ encode() {
1948
+ const ret = wasm.signedfragment_encode(this.__wbg_ptr);
1949
+ return ret;
1950
+ }
1951
+ /**
1952
+ * Get the unsigned payload without re-verifying the signature.
1953
+ *
1954
+ * # Errors
1955
+ *
1956
+ * Returns an error if the payload cannot be decoded.
1957
+ * @returns {Fragment}
1958
+ */
1959
+ get payload() {
1960
+ const ret = wasm.signedfragment_payload(this.__wbg_ptr);
1961
+ if (ret[2]) {
1962
+ throw takeFromExternrefTable0(ret[1]);
1963
+ }
1964
+ return Fragment.__wrap(ret[0]);
1965
+ }
1966
+ /**
1967
+ * Decode a `SignedFragment` from raw bytes.
1968
+ *
1969
+ * # Errors
1970
+ *
1971
+ * Returns an error if the bytes are not a valid signed fragment.
1972
+ * @param {Uint8Array} bytes
1973
+ * @returns {SignedFragment}
1974
+ */
1975
+ static tryDecode(bytes) {
1976
+ const ret = wasm.signedfragment_tryDecode(bytes);
1977
+ if (ret[2]) {
1978
+ throw takeFromExternrefTable0(ret[1]);
1979
+ }
1980
+ return SignedFragment.__wrap(ret[0]);
1981
+ }
1982
+ }
1983
+ if (Symbol.dispose) SignedFragment.prototype[Symbol.dispose] = SignedFragment.prototype.free;
1984
+ exports.SignedFragment = SignedFragment;
1985
+
1986
+ /**
1987
+ * A Wasm wrapper around `Signed<LooseCommit>`.
1988
+ */
1989
+ class SignedLooseCommit {
1990
+ static __wrap(ptr) {
1991
+ ptr = ptr >>> 0;
1992
+ const obj = Object.create(SignedLooseCommit.prototype);
1993
+ obj.__wbg_ptr = ptr;
1994
+ SignedLooseCommitFinalization.register(obj, obj.__wbg_ptr, obj);
1995
+ return obj;
1996
+ }
1997
+ static __unwrap(jsValue) {
1998
+ if (!(jsValue instanceof SignedLooseCommit)) {
1999
+ return 0;
2000
+ }
2001
+ return jsValue.__destroy_into_raw();
2002
+ }
2003
+ __destroy_into_raw() {
2004
+ const ptr = this.__wbg_ptr;
2005
+ this.__wbg_ptr = 0;
2006
+ SignedLooseCommitFinalization.unregister(this);
2007
+ return ptr;
2008
+ }
2009
+ free() {
2010
+ const ptr = this.__destroy_into_raw();
2011
+ wasm.__wbg_signedloosecommit_free(ptr, 0);
2012
+ }
2013
+ /**
2014
+ * Upcasts; to the JS-import type for [`WasmSignedLooseCommit`].
2015
+ * @returns {SignedLooseCommit}
2016
+ */
2017
+ __wasm_refgen_toWasmSignedLooseCommit() {
2018
+ const ret = wasm.signedloosecommit___wasm_refgen_toWasmSignedLooseCommit(this.__wbg_ptr);
2019
+ return SignedLooseCommit.__wrap(ret);
2020
+ }
2021
+ /**
2022
+ * Encode this signed loose commit to raw bytes.
2023
+ * @returns {Uint8Array}
2024
+ */
2025
+ encode() {
2026
+ const ret = wasm.signedloosecommit_encode(this.__wbg_ptr);
2027
+ return ret;
2028
+ }
2029
+ /**
2030
+ * Get the unsigned payload without re-verifying the signature.
2031
+ *
2032
+ * # Errors
2033
+ *
2034
+ * Returns an error if the payload cannot be decoded.
2035
+ * @returns {LooseCommit}
2036
+ */
2037
+ get payload() {
2038
+ const ret = wasm.signedloosecommit_payload(this.__wbg_ptr);
2039
+ if (ret[2]) {
2040
+ throw takeFromExternrefTable0(ret[1]);
2041
+ }
2042
+ return LooseCommit.__wrap(ret[0]);
2043
+ }
2044
+ /**
2045
+ * Decode a `SignedLooseCommit` from raw bytes.
2046
+ *
2047
+ * # Errors
2048
+ *
2049
+ * Returns an error if the bytes are not a valid signed loose commit.
2050
+ * @param {Uint8Array} bytes
2051
+ * @returns {SignedLooseCommit}
2052
+ */
2053
+ static tryDecode(bytes) {
2054
+ const ret = wasm.signedloosecommit_tryDecode(bytes);
2055
+ if (ret[2]) {
2056
+ throw takeFromExternrefTable0(ret[1]);
2057
+ }
2058
+ return SignedLooseCommit.__wrap(ret[0]);
2059
+ }
2060
+ }
2061
+ if (Symbol.dispose) SignedLooseCommit.prototype[Symbol.dispose] = SignedLooseCommit.prototype.free;
2062
+ exports.SignedLooseCommit = SignedLooseCommit;
2063
+
2064
+ /**
2065
+ * Wasm bindings for [`Subduction`](subduction_core::Subduction)
2066
+ */
2067
+ class Subduction {
2068
+ static __wrap(ptr) {
2069
+ ptr = ptr >>> 0;
2070
+ const obj = Object.create(Subduction.prototype);
2071
+ obj.__wbg_ptr = ptr;
2072
+ SubductionFinalization.register(obj, obj.__wbg_ptr, obj);
2073
+ return obj;
2074
+ }
2075
+ __destroy_into_raw() {
2076
+ const ptr = this.__wbg_ptr;
2077
+ this.__wbg_ptr = 0;
2078
+ SubductionFinalization.unregister(this);
2079
+ return ptr;
2080
+ }
2081
+ free() {
2082
+ const ptr = this.__destroy_into_raw();
2083
+ wasm.__wbg_subduction_free(ptr, 0);
2084
+ }
2085
+ /**
2086
+ * Accept a connection from a peer over any [`Transport`](JsTransport).
2087
+ *
2088
+ * Performs the responder side of the handshake, then adds the authenticated
2089
+ * connection. This is the counterpart to [`connectTransport`](Self::connect_transport).
2090
+ *
2091
+ * # Arguments
2092
+ *
2093
+ * * `transport` - Any JS object with `sendBytes`/`recvBytes`/`disconnect`
2094
+ * * `service_name` - Shared service name for discovery
2095
+ *
2096
+ * # Errors
2097
+ *
2098
+ * Returns an error if the handshake or connection fails.
2099
+ * @param {Transport} transport
2100
+ * @param {string} service_name
2101
+ * @returns {Promise<PeerId>}
2102
+ */
2103
+ acceptTransport(transport, service_name) {
2104
+ const ptr0 = passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2105
+ const len0 = WASM_VECTOR_LEN;
2106
+ const ret = wasm.subduction_acceptTransport(this.__wbg_ptr, transport, ptr0, len0);
2107
+ return ret;
2108
+ }
2109
+ /**
2110
+ * Add a commit with its associated blob to the storage.
2111
+ *
2112
+ * The commit metadata (including `BlobMeta`) is computed internally from
2113
+ * the provided blob, ensuring consistency by construction.
2114
+ *
2115
+ * # Errors
2116
+ *
2117
+ * Returns a [`WasmWriteError`] if storage, networking, or policy fail.
2118
+ * @param {SedimentreeId} id
2119
+ * @param {Digest[]} parents
2120
+ * @param {Uint8Array} blob
2121
+ * @returns {Promise<FragmentRequested | undefined>}
2122
+ */
2123
+ addCommit(id, parents, blob) {
2124
+ _assertClass(id, SedimentreeId);
2125
+ const ptr0 = passArrayJsValueToWasm0(parents, wasm.__wbindgen_export);
2126
+ const len0 = WASM_VECTOR_LEN;
2127
+ const ret = wasm.subduction_addCommit(this.__wbg_ptr, id.__wbg_ptr, ptr0, len0, blob);
2128
+ return ret;
2129
+ }
2130
+ /**
2131
+ * Onboard an authenticated transport: add it and sync all sedimentrees.
2132
+ *
2133
+ * Accepts an [`AuthenticatedTransport`](WasmAuthenticatedTransport),
2134
+ * obtained via [`AuthenticatedTransport.setup`](WasmAuthenticatedTransport::setup),
2135
+ * [`AuthenticatedWebSocket.toTransport`], or [`AuthenticatedLongPoll.toTransport`].
2136
+ *
2137
+ * Returns `true` if this is a new peer, `false` if already connected.
2138
+ *
2139
+ * Add an authenticated transport to tracking.
2140
+ *
2141
+ * This does not perform any synchronization. To sync after adding,
2142
+ * call [`fullSyncWithPeer`](Self::full_sync_with_peer).
2143
+ *
2144
+ * Returns `true` if this is a new peer, `false` if already connected.
2145
+ *
2146
+ * # Errors
2147
+ *
2148
+ * Returns an error if the connection is rejected by the policy.
2149
+ * @param {AuthenticatedTransport} transport
2150
+ * @returns {Promise<boolean>}
2151
+ */
2152
+ addConnection(transport) {
2153
+ _assertClass(transport, AuthenticatedTransport);
2154
+ const ret = wasm.subduction_addConnection(this.__wbg_ptr, transport.__wbg_ptr);
2155
+ return ret;
2156
+ }
2157
+ /**
2158
+ * Add a fragment with its associated blob to the storage.
2159
+ *
2160
+ * The fragment metadata (including `BlobMeta`) is computed internally from
2161
+ * the provided blob, ensuring consistency by construction.
2162
+ *
2163
+ * # Errors
2164
+ *
2165
+ * Returns a [`WasmWriteError`] if storage, networking, or policy fail.
2166
+ * @param {SedimentreeId} id
2167
+ * @param {Digest} head
2168
+ * @param {Digest[]} boundary
2169
+ * @param {Digest[]} checkpoints
2170
+ * @param {Uint8Array} blob
2171
+ * @returns {Promise<void>}
2172
+ */
2173
+ addFragment(id, head, boundary, checkpoints, blob) {
2174
+ _assertClass(id, SedimentreeId);
2175
+ _assertClass(head, Digest);
2176
+ const ptr0 = passArrayJsValueToWasm0(boundary, wasm.__wbindgen_export);
2177
+ const len0 = WASM_VECTOR_LEN;
2178
+ const ptr1 = passArrayJsValueToWasm0(checkpoints, wasm.__wbindgen_export);
2179
+ const len1 = WASM_VECTOR_LEN;
2180
+ const ret = wasm.subduction_addFragment(this.__wbg_ptr, id.__wbg_ptr, head.__wbg_ptr, ptr0, len0, ptr1, len1, blob);
2181
+ return ret;
2182
+ }
2183
+ /**
2184
+ * Add a Sedimentree.
2185
+ *
2186
+ * # Errors
2187
+ *
2188
+ * Returns [`WasmWriteError`] if there is a problem with storage, networking, or policy.
2189
+ * @param {SedimentreeId} id
2190
+ * @param {Sedimentree} sedimentree
2191
+ * @param {Uint8Array[]} blobs
2192
+ * @returns {Promise<void>}
2193
+ */
2194
+ addSedimentree(id, sedimentree, blobs) {
2195
+ _assertClass(id, SedimentreeId);
2196
+ _assertClass(sedimentree, Sedimentree);
2197
+ const ptr0 = passArrayJsValueToWasm0(blobs, wasm.__wbindgen_export);
2198
+ const len0 = WASM_VECTOR_LEN;
2199
+ const ret = wasm.subduction_addSedimentree(this.__wbg_ptr, id.__wbg_ptr, sedimentree.__wbg_ptr, ptr0, len0);
2200
+ return ret;
2201
+ }
2202
+ /**
2203
+ * Connect to a peer via WebSocket and add the connection.
2204
+ *
2205
+ * This performs the cryptographic handshake, verifies the server's identity,
2206
+ * and adds the authenticated connection for syncing.
2207
+ *
2208
+ * Returns the verified peer ID on success.
2209
+ *
2210
+ * # Arguments
2211
+ *
2212
+ * * `address` - The WebSocket URL to connect to
2213
+ * * `expected_peer_id` - The expected server peer ID (verified during handshake)
2214
+ *
2215
+ * # Errors
2216
+ *
2217
+ * Returns an error if connection, handshake, or adding the connection fails.
2218
+ * @param {URL} address
2219
+ * @param {PeerId} expected_peer_id
2220
+ * @returns {Promise<PeerId>}
2221
+ */
2222
+ connect(address, expected_peer_id) {
2223
+ _assertClass(expected_peer_id, PeerId);
2224
+ const ret = wasm.subduction_connect(this.__wbg_ptr, address, expected_peer_id.__wbg_ptr);
2225
+ return ret;
2226
+ }
2227
+ /**
2228
+ * Connect to a peer via WebSocket using discovery mode and add the connection.
2229
+ *
2230
+ * Returns the discovered and verified peer ID on success.
2231
+ *
2232
+ * # Arguments
2233
+ *
2234
+ * * `address` - The WebSocket URL to connect to
2235
+ * * `timeout_milliseconds` - Request timeout in milliseconds (defaults to 30000)
2236
+ * * `service_name` - The service name for discovery (defaults to URL host)
2237
+ *
2238
+ * # Errors
2239
+ *
2240
+ * Returns an error if connection, handshake, or adding the connection fails.
2241
+ * @param {URL} address
2242
+ * @param {string | null} [service_name]
2243
+ * @returns {Promise<PeerId>}
2244
+ */
2245
+ connectDiscover(address, service_name) {
2246
+ var ptr0 = isLikeNone(service_name) ? 0 : passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2247
+ var len0 = WASM_VECTOR_LEN;
2248
+ const ret = wasm.subduction_connectDiscover(this.__wbg_ptr, address, ptr0, len0);
2249
+ return ret;
2250
+ }
2251
+ /**
2252
+ * Connect to a peer via HTTP long-poll using discovery mode.
2253
+ *
2254
+ * Returns the discovered and verified peer ID on success.
2255
+ *
2256
+ * # Arguments
2257
+ *
2258
+ * * `base_url` - The server's HTTP base URL (e.g., `http://localhost:8080`)
2259
+ * * `timeout_milliseconds` - Request timeout in milliseconds (default: 30000)
2260
+ * * `service_name` - The service name for discovery (defaults to `base_url`)
2261
+ *
2262
+ * # Errors
2263
+ *
2264
+ * Returns an error if connection, handshake, or adding the connection fails.
2265
+ * @param {string} base_url
2266
+ * @param {string | null} [service_name]
2267
+ * @returns {Promise<PeerId>}
2268
+ */
2269
+ connectDiscoverLongPoll(base_url, service_name) {
2270
+ const ptr0 = passStringToWasm0(base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2271
+ const len0 = WASM_VECTOR_LEN;
2272
+ var ptr1 = isLikeNone(service_name) ? 0 : passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2273
+ var len1 = WASM_VECTOR_LEN;
2274
+ const ret = wasm.subduction_connectDiscoverLongPoll(this.__wbg_ptr, ptr0, len0, ptr1, len1);
2275
+ return ret;
2276
+ }
2277
+ /**
2278
+ * Connect to a peer via HTTP long-poll and add the connection.
2279
+ *
2280
+ * Returns the verified peer ID on success.
2281
+ *
2282
+ * # Arguments
2283
+ *
2284
+ * * `base_url` - The server's HTTP base URL (e.g., `http://localhost:8080`)
2285
+ * * `expected_peer_id` - The expected server peer ID (verified during handshake)
2286
+ * * `timeout_milliseconds` - Request timeout in milliseconds (default: 30000)
2287
+ *
2288
+ * # Errors
2289
+ *
2290
+ * Returns an error if connection, handshake, or adding the connection fails.
2291
+ * @param {string} base_url
2292
+ * @param {PeerId} expected_peer_id
2293
+ * @returns {Promise<PeerId>}
2294
+ */
2295
+ connectLongPoll(base_url, expected_peer_id) {
2296
+ const ptr0 = passStringToWasm0(base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2297
+ const len0 = WASM_VECTOR_LEN;
2298
+ _assertClass(expected_peer_id, PeerId);
2299
+ const ret = wasm.subduction_connectLongPoll(this.__wbg_ptr, ptr0, len0, expected_peer_id.__wbg_ptr);
2300
+ return ret;
2301
+ }
2302
+ /**
2303
+ * Connect to a peer over any [`Transport`](JsTransport) using discovery mode.
2304
+ *
2305
+ * Performs a discovery handshake, then adds the authenticated connection.
2306
+ * The peer's identity is discovered during the handshake.
2307
+ *
2308
+ * # Arguments
2309
+ *
2310
+ * * `transport` - Any JS object with `sendBytes`/`recvBytes`/`disconnect`
2311
+ * * `service_name` - Shared service name for discovery
2312
+ *
2313
+ * # Errors
2314
+ *
2315
+ * Returns an error if the handshake or connection fails.
2316
+ * @param {Transport} transport
2317
+ * @param {string} service_name
2318
+ * @returns {Promise<PeerId>}
2319
+ */
2320
+ connectTransport(transport, service_name) {
2321
+ const ptr0 = passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2322
+ const len0 = WASM_VECTOR_LEN;
2323
+ const ret = wasm.subduction_connectTransport(this.__wbg_ptr, transport, ptr0, len0);
2324
+ return ret;
2325
+ }
2326
+ /**
2327
+ * Disconnect from all peers.
2328
+ *
2329
+ * # Errors
2330
+ *
2331
+ * Returns a [`WasmDisconnectionError`] if disconnection was not graceful.
2332
+ * @returns {Promise<void>}
2333
+ */
2334
+ disconnectAll() {
2335
+ const ret = wasm.subduction_disconnectAll(this.__wbg_ptr);
2336
+ return ret;
2337
+ }
2338
+ /**
2339
+ * Disconnect from a peer by its ID.
2340
+ *
2341
+ * # Errors
2342
+ *
2343
+ * Returns a `WasmDisconnectionError` if disconnection fails.
2344
+ * @param {PeerId} peer_id
2345
+ * @returns {Promise<boolean>}
2346
+ */
2347
+ disconnectFromPeer(peer_id) {
2348
+ _assertClass(peer_id, PeerId);
2349
+ const ret = wasm.subduction_disconnectFromPeer(this.__wbg_ptr, peer_id.__wbg_ptr);
2350
+ return ret;
2351
+ }
2352
+ /**
2353
+ * Fetch blobs by their digests, with an optional timeout in milliseconds.
2354
+ *
2355
+ * # Errors
2356
+ *
2357
+ * Returns a [`WasmIoError`] if storage or networking fail.
2358
+ * @param {SedimentreeId} id
2359
+ * @param {bigint | null} [timeout_milliseconds]
2360
+ * @returns {Promise<Uint8Array[] | undefined>}
2361
+ */
2362
+ fetchBlobs(id, timeout_milliseconds) {
2363
+ _assertClass(id, SedimentreeId);
2364
+ const ret = wasm.subduction_fetchBlobs(this.__wbg_ptr, id.__wbg_ptr, !isLikeNone(timeout_milliseconds), isLikeNone(timeout_milliseconds) ? BigInt(0) : timeout_milliseconds);
2365
+ return ret;
2366
+ }
2367
+ /**
2368
+ * Sync all known Sedimentree IDs with all connected peers.
2369
+ * @param {bigint | null} [timeout_milliseconds]
2370
+ * @returns {Promise<PeerBatchSyncResult>}
2371
+ */
2372
+ fullSyncWithAllPeers(timeout_milliseconds) {
2373
+ const ret = wasm.subduction_fullSyncWithAllPeers(this.__wbg_ptr, !isLikeNone(timeout_milliseconds), isLikeNone(timeout_milliseconds) ? BigInt(0) : timeout_milliseconds);
2374
+ return ret;
2375
+ }
2376
+ /**
2377
+ * Sync all known Sedimentree IDs with a single peer.
2378
+ *
2379
+ * # Arguments
2380
+ *
2381
+ * * `peer_id` - The peer to sync with
2382
+ * * `subscribe` - Whether to subscribe to future updates (default: `true`)
2383
+ * * `timeout_milliseconds` - Per-call timeout in milliseconds
2384
+ * @param {PeerId} peer_id
2385
+ * @param {boolean | null} [subscribe]
2386
+ * @param {bigint | null} [timeout_milliseconds]
2387
+ * @returns {Promise<PeerBatchSyncResult>}
2388
+ */
2389
+ fullSyncWithPeer(peer_id, subscribe, timeout_milliseconds) {
2390
+ _assertClass(peer_id, PeerId);
2391
+ 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);
2392
+ return ret;
2393
+ }
2394
+ /**
2395
+ * Get a local blob by its digest.
2396
+ *
2397
+ * # Errors
2398
+ *
2399
+ * Returns a [`JsStorageError`] if JS storage fails.
2400
+ * @param {SedimentreeId} id
2401
+ * @param {Digest} digest
2402
+ * @returns {Promise<Uint8Array | undefined>}
2403
+ */
2404
+ getBlob(id, digest) {
2405
+ _assertClass(id, SedimentreeId);
2406
+ _assertClass(digest, Digest);
2407
+ const ret = wasm.subduction_getBlob(this.__wbg_ptr, id.__wbg_ptr, digest.__wbg_ptr);
2408
+ return ret;
2409
+ }
2410
+ /**
2411
+ * Get all local blobs for a given Sedimentree ID.
2412
+ *
2413
+ * # Errors
2414
+ *
2415
+ * Returns a [`JsStorageError`] if JS storage fails.
2416
+ * @param {SedimentreeId} id
2417
+ * @returns {Promise<Uint8Array[]>}
2418
+ */
2419
+ getBlobs(id) {
2420
+ _assertClass(id, SedimentreeId);
2421
+ const ret = wasm.subduction_getBlobs(this.__wbg_ptr, id.__wbg_ptr);
2422
+ return ret;
2423
+ }
2424
+ /**
2425
+ * Get all commits for a given Sedimentree ID
2426
+ * @param {SedimentreeId} id
2427
+ * @returns {Promise<LooseCommit[] | undefined>}
2428
+ */
2429
+ getCommits(id) {
2430
+ _assertClass(id, SedimentreeId);
2431
+ const ret = wasm.subduction_getCommits(this.__wbg_ptr, id.__wbg_ptr);
2432
+ return ret;
2433
+ }
2434
+ /**
2435
+ * Get the peer IDs of all connected peers.
2436
+ * @returns {Promise<PeerId[]>}
2437
+ */
2438
+ getConnectedPeerIds() {
2439
+ const ret = wasm.subduction_getConnectedPeerIds(this.__wbg_ptr);
2440
+ return ret;
2441
+ }
2442
+ /**
2443
+ * Get all fragments for a given Sedimentree ID
2444
+ * @param {SedimentreeId} id
2445
+ * @returns {Promise<Fragment[] | undefined>}
2446
+ */
2447
+ getFragments(id) {
2448
+ _assertClass(id, SedimentreeId);
2449
+ const ret = wasm.subduction_getFragments(this.__wbg_ptr, id.__wbg_ptr);
2450
+ return ret;
2451
+ }
2452
+ /**
2453
+ * Hydrate a [`Subduction`] instance from external storage.
2454
+ *
2455
+ * Loads all sedimentree data from storage and reconstructs the in-memory
2456
+ * state before initializing the sync engine.
2457
+ *
2458
+ * # Arguments
2459
+ *
2460
+ * * `signer` - The cryptographic signer for this node's identity
2461
+ * * `storage` - Storage backend for persisting data
2462
+ * * `service_name` - Optional service identifier for discovery mode (e.g., `sync.example.com`).
2463
+ * When set, clients can connect without knowing the server's peer ID.
2464
+ * * `hash_metric_override` - Optional custom depth metric function
2465
+ * * `max_pending_blob_requests` - Optional maximum number of pending blob requests (default: 10,000)
2466
+ * * `policy` - Optional connection/storage authorization policy.
2467
+ * Defaults to allow-all.
2468
+ * * `ephemeral_policy` - Optional ephemeral message authorization policy.
2469
+ * Defaults to allow-all.
2470
+ *
2471
+ * # Panics
2472
+ *
2473
+ * Panics if `hash_metric_override` is `Some` but the underlying JS value
2474
+ * cannot be cast to a `Function`.
2475
+ *
2476
+ * # Errors
2477
+ *
2478
+ * Returns [`WasmHydrationError`] if hydration fails.
2479
+ * @param {any} signer
2480
+ * @param {SedimentreeStorage} storage
2481
+ * @param {string | null} [service_name]
2482
+ * @param {(digest: Digest) => Depth | null} [hash_metric_override]
2483
+ * @param {number | null} [max_pending_blob_requests]
2484
+ * @param {Policy | null} [policy]
2485
+ * @param {EphemeralPolicy | null} [ephemeral_policy]
2486
+ * @param {Function | null} [on_remote_heads]
2487
+ * @param {Function | null} [on_ephemeral]
2488
+ * @returns {Promise<Subduction>}
2489
+ */
2490
+ static hydrate(signer, storage, service_name, hash_metric_override, max_pending_blob_requests, policy, ephemeral_policy, on_remote_heads, on_ephemeral) {
2491
+ var ptr0 = isLikeNone(service_name) ? 0 : passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2492
+ var len0 = WASM_VECTOR_LEN;
2493
+ 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));
2494
+ return ret;
2495
+ }
2496
+ /**
2497
+ * Link two local [`Subduction`](WasmSubduction) instances over a
2498
+ * [`MessageChannel`](web_sys::MessageChannel).
2499
+ *
2500
+ * Creates a `MessageChannel`, performs a discovery handshake between
2501
+ * the two instances, and adds the connections to both. This is the
2502
+ * simplest way to sync two local instances.
2503
+ *
2504
+ * # Errors
2505
+ *
2506
+ * Returns an error if the handshake or connection fails.
2507
+ * @param {Subduction} a
2508
+ * @param {Subduction} b
2509
+ * @returns {Promise<void>}
2510
+ */
2511
+ static link(a, b) {
2512
+ _assertClass(a, Subduction);
2513
+ _assertClass(b, Subduction);
2514
+ const ret = wasm.subduction_link(a.__wbg_ptr, b.__wbg_ptr);
2515
+ return ret;
2516
+ }
2517
+ /**
2518
+ * Create a new [`Subduction`] instance.
2519
+ *
2520
+ * # Arguments
2521
+ *
2522
+ * * `signer` - The cryptographic signer for this node's identity
2523
+ * * `storage` - Storage backend for persisting data
2524
+ * * `service_name` - Optional service identifier for discovery mode (e.g., `sync.example.com`).
2525
+ * When set, clients can connect without knowing the server's peer ID.
2526
+ * * `hash_metric_override` - Optional custom depth metric function
2527
+ * * `max_pending_blob_requests` - Optional maximum number of pending blob requests (default: 10,000)
2528
+ * * `policy` - Optional connection/storage authorization policy.
2529
+ * Defaults to allow-all.
2530
+ * * `ephemeral_policy` - Optional ephemeral message authorization policy.
2531
+ * Defaults to allow-all.
2532
+ *
2533
+ * # Panics
2534
+ *
2535
+ * Panics if `hash_metric_override` is `Some` but the underlying JS value
2536
+ * cannot be cast to a `Function`.
2537
+ * @param {any} signer
2538
+ * @param {SedimentreeStorage} storage
2539
+ * @param {string | null} [service_name]
2540
+ * @param {(digest: Digest) => Depth | null} [hash_metric_override]
2541
+ * @param {number | null} [max_pending_blob_requests]
2542
+ * @param {Policy | null} [policy]
2543
+ * @param {EphemeralPolicy | null} [ephemeral_policy]
2544
+ * @param {Function | null} [on_remote_heads]
2545
+ * @param {Function | null} [on_ephemeral]
2546
+ */
2547
+ constructor(signer, storage, service_name, hash_metric_override, max_pending_blob_requests, policy, ephemeral_policy, on_remote_heads, on_ephemeral) {
2548
+ var ptr0 = isLikeNone(service_name) ? 0 : passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2549
+ var len0 = WASM_VECTOR_LEN;
2550
+ 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));
2551
+ this.__wbg_ptr = ret >>> 0;
2552
+ SubductionFinalization.register(this, this.__wbg_ptr, this);
2553
+ return this;
2554
+ }
2555
+ /**
2556
+ * Publish an ephemeral message to all subscribers of a topic.
2557
+ *
2558
+ * The payload is opaque bytes — encoding is the caller's responsibility.
2559
+ * Messages are fire-and-forget; delivery is best-effort.
2560
+ *
2561
+ * # Panics
2562
+ *
2563
+ * Panics if the platform's random number generator fails.
2564
+ * @param {Topic} topic
2565
+ * @param {Uint8Array} payload
2566
+ * @returns {Promise<void>}
2567
+ */
2568
+ publishEphemeral(topic, payload) {
2569
+ _assertClass(topic, Topic);
2570
+ const ptr0 = passArray8ToWasm0(payload, wasm.__wbindgen_export);
2571
+ const len0 = WASM_VECTOR_LEN;
2572
+ const ret = wasm.subduction_publishEphemeral(this.__wbg_ptr, topic.__wbg_ptr, ptr0, len0);
2573
+ return ret;
2574
+ }
2575
+ /**
2576
+ * Remove a Sedimentree and all associated data.
2577
+ *
2578
+ * # Errors
2579
+ *
2580
+ * Returns a [`WasmIoError`] if storage or networking fail.
2581
+ * @param {SedimentreeId} id
2582
+ * @returns {Promise<void>}
2583
+ */
2584
+ removeSedimentree(id) {
2585
+ _assertClass(id, SedimentreeId);
2586
+ const ret = wasm.subduction_removeSedimentree(this.__wbg_ptr, id.__wbg_ptr);
2587
+ return ret;
2588
+ }
2589
+ /**
2590
+ * Request blobs by their digests from connected peers for a specific sedimentree.
2591
+ * @param {SedimentreeId} id
2592
+ * @param {Digest[]} digests
2593
+ * @returns {Promise<void>}
2594
+ */
2595
+ requestBlobs(id, digests) {
2596
+ _assertClass(id, SedimentreeId);
2597
+ const ptr0 = passArrayJsValueToWasm0(digests, wasm.__wbindgen_export);
2598
+ const len0 = WASM_VECTOR_LEN;
2599
+ const ret = wasm.subduction_requestBlobs(this.__wbg_ptr, id.__wbg_ptr, ptr0, len0);
2600
+ return ret;
2601
+ }
2602
+ /**
2603
+ * Get all known Sedimentree IDs
2604
+ * @returns {Promise<SedimentreeId[]>}
2605
+ */
2606
+ sedimentreeIds() {
2607
+ const ret = wasm.subduction_sedimentreeIds(this.__wbg_ptr);
2608
+ return ret;
2609
+ }
2610
+ /**
2611
+ * Get the backing storage.
2612
+ * @returns {any}
2613
+ */
2614
+ get storage() {
2615
+ const ret = wasm.subduction_storage(this.__wbg_ptr);
2616
+ return ret;
2617
+ }
2618
+ /**
2619
+ * Subscribe to ephemeral messages for the given topics
2620
+ * from all connected peers.
2621
+ * @param {Topic[]} topics
2622
+ * @returns {Promise<void>}
2623
+ */
2624
+ subscribeEphemeral(topics) {
2625
+ const ptr0 = passArrayJsValueToWasm0(topics, wasm.__wbindgen_export);
2626
+ const len0 = WASM_VECTOR_LEN;
2627
+ const ret = wasm.subduction_subscribeEphemeral(this.__wbg_ptr, ptr0, len0);
2628
+ return ret;
2629
+ }
2630
+ /**
2631
+ * Request batch sync for a given Sedimentree ID from all connected peers.
2632
+ *
2633
+ * # Arguments
2634
+ *
2635
+ * * `id` - The sedimentree ID to sync
2636
+ * * `subscribe` - Whether to subscribe for incremental updates
2637
+ * * `timeout_milliseconds` - Optional timeout in milliseconds
2638
+ *
2639
+ * # Errors
2640
+ *
2641
+ * Returns a [`WasmIoError`] if storage or networking fail.
2642
+ * @param {SedimentreeId} id
2643
+ * @param {boolean} subscribe
2644
+ * @param {bigint | null} [timeout_milliseconds]
2645
+ * @returns {Promise<PeerResultMap>}
2646
+ */
2647
+ syncWithAllPeers(id, subscribe, timeout_milliseconds) {
2648
+ _assertClass(id, SedimentreeId);
2649
+ const ret = wasm.subduction_syncWithAllPeers(this.__wbg_ptr, id.__wbg_ptr, subscribe, !isLikeNone(timeout_milliseconds), isLikeNone(timeout_milliseconds) ? BigInt(0) : timeout_milliseconds);
2650
+ return ret;
2651
+ }
2652
+ /**
2653
+ * Request batch sync for a given Sedimentree ID from a specific peer.
2654
+ *
2655
+ * # Arguments
2656
+ *
2657
+ * * `to_ask` - The peer ID to sync with
2658
+ * * `id` - The sedimentree ID to sync
2659
+ * * `subscribe` - Whether to subscribe for incremental updates
2660
+ * * `timeout_milliseconds` - Optional timeout in milliseconds
2661
+ *
2662
+ * # Errors
2663
+ *
2664
+ * Returns a [`WasmIoError`] if storage or networking fail.
2665
+ * @param {PeerId} to_ask
2666
+ * @param {SedimentreeId} id
2667
+ * @param {boolean} subscribe
2668
+ * @param {bigint | null} [timeout_milliseconds]
2669
+ * @returns {Promise<PeerBatchSyncResult>}
2670
+ */
2671
+ syncWithPeer(to_ask, id, subscribe, timeout_milliseconds) {
2672
+ _assertClass(to_ask, PeerId);
2673
+ _assertClass(id, SedimentreeId);
2674
+ 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);
2675
+ return ret;
2676
+ }
2677
+ /**
2678
+ * Unsubscribe from ephemeral messages for the given topics
2679
+ * from all connected peers.
2680
+ * @param {Topic[]} topics
2681
+ * @returns {Promise<void>}
2682
+ */
2683
+ unsubscribeEphemeral(topics) {
2684
+ const ptr0 = passArrayJsValueToWasm0(topics, wasm.__wbindgen_export);
2685
+ const len0 = WASM_VECTOR_LEN;
2686
+ const ret = wasm.subduction_unsubscribeEphemeral(this.__wbg_ptr, ptr0, len0);
2687
+ return ret;
2688
+ }
2689
+ }
2690
+ if (Symbol.dispose) Subduction.prototype[Symbol.dispose] = Subduction.prototype.free;
2691
+ exports.Subduction = Subduction;
2692
+
2693
+ /**
2694
+ * JS-facing wrapper around [`HttpLongPollTransport`] that exposes the
2695
+ * byte-oriented [`Transport`](super::JsTransport) interface
2696
+ * (`sendBytes`/`recvBytes`/`disconnect`/`onDisconnect`) so it can be used as a
2697
+ * duck-typed `JsTransport` from JavaScript.
2698
+ */
2699
+ class SubductionHttpLongPoll {
2700
+ static __wrap(ptr) {
2701
+ ptr = ptr >>> 0;
2702
+ const obj = Object.create(SubductionHttpLongPoll.prototype);
2703
+ obj.__wbg_ptr = ptr;
2704
+ SubductionHttpLongPollFinalization.register(obj, obj.__wbg_ptr, obj);
2705
+ return obj;
2706
+ }
2707
+ __destroy_into_raw() {
2708
+ const ptr = this.__wbg_ptr;
2709
+ this.__wbg_ptr = 0;
2710
+ SubductionHttpLongPollFinalization.unregister(this);
2711
+ return ptr;
2712
+ }
2713
+ free() {
2714
+ const ptr = this.__destroy_into_raw();
2715
+ wasm.__wbg_subductionhttplongpoll_free(ptr, 0);
2716
+ }
2717
+ /**
2718
+ * Disconnect from the peer gracefully.
2719
+ *
2720
+ * Fires the `onDisconnect` callback if one is registered.
2721
+ *
2722
+ * # Errors
2723
+ *
2724
+ * Returns an error if the disconnect fails.
2725
+ * @returns {Promise<void>}
2726
+ */
2727
+ disconnect() {
2728
+ const ret = wasm.subductionhttplongpoll_disconnect(this.__wbg_ptr);
2729
+ return ret;
2730
+ }
2731
+ /**
2732
+ * Register a callback to be invoked when the transport disconnects.
2733
+ *
2734
+ * Part of the [`Transport`](super::JsTransport) interface contract.
2735
+ * Typically called by internal wiring rather than directly by user code.
2736
+ * @param {Function} callback
2737
+ */
2738
+ onDisconnect(callback) {
2739
+ wasm.subductionhttplongpoll_onDisconnect(this.__wbg_ptr, callback);
2740
+ }
2741
+ /**
2742
+ * Receive the next message frame as raw bytes.
2743
+ *
2744
+ * # Errors
2745
+ *
2746
+ * Returns an error if the inbound channel is closed.
2747
+ * @returns {Promise<Uint8Array>}
2748
+ */
2749
+ recvBytes() {
2750
+ const ret = wasm.subductionhttplongpoll_recvBytes(this.__wbg_ptr);
2751
+ return ret;
2752
+ }
2753
+ /**
2754
+ * Send raw bytes over the transport.
2755
+ *
2756
+ * # Errors
2757
+ *
2758
+ * Returns an error if the outbound channel is closed.
2759
+ * @param {Uint8Array} bytes
2760
+ * @returns {Promise<void>}
2761
+ */
2762
+ sendBytes(bytes) {
2763
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
2764
+ const len0 = WASM_VECTOR_LEN;
2765
+ const ret = wasm.subductionhttplongpoll_sendBytes(this.__wbg_ptr, ptr0, len0);
2766
+ return ret;
2767
+ }
2768
+ }
2769
+ if (Symbol.dispose) SubductionHttpLongPoll.prototype[Symbol.dispose] = SubductionHttpLongPoll.prototype.free;
2770
+ exports.SubductionHttpLongPoll = SubductionHttpLongPoll;
2771
+
2772
+ /**
2773
+ * HTTP long-poll transport factory for browser/worker environments.
2774
+ *
2775
+ * Analogous to [`SubductionWebSocket`] but uses HTTP long-poll instead of WebSocket.
2776
+ */
2777
+ class SubductionLongPoll {
2778
+ __destroy_into_raw() {
2779
+ const ptr = this.__wbg_ptr;
2780
+ this.__wbg_ptr = 0;
2781
+ SubductionLongPollFinalization.unregister(this);
2782
+ return ptr;
2783
+ }
2784
+ free() {
2785
+ const ptr = this.__destroy_into_raw();
2786
+ wasm.__wbg_subductionlongpoll_free(ptr, 0);
2787
+ }
2788
+ /**
2789
+ * Connect to a server with a known peer ID.
2790
+ *
2791
+ * # Arguments
2792
+ *
2793
+ * * `base_url` - The server's HTTP base URL (e.g., `http://localhost:8080`)
2794
+ * * `signer` - The client's signer for authentication
2795
+ * * `expected_peer_id` - The expected server peer ID (verified during handshake)
2796
+ * * `on_disconnect` - Optional callback invoked with the peer's [`PeerId`] when the connection closes
2797
+ *
2798
+ * # Errors
2799
+ *
2800
+ * Returns [`LongPollTransportError`] if connection or handshake fails.
2801
+ * @param {string} base_url
2802
+ * @param {any} signer
2803
+ * @param {PeerId} expected_peer_id
2804
+ * @param {Function | null} [on_disconnect]
2805
+ * @returns {Promise<AuthenticatedLongPoll>}
2806
+ */
2807
+ static tryConnect(base_url, signer, expected_peer_id, on_disconnect) {
2808
+ const ptr0 = passStringToWasm0(base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2809
+ const len0 = WASM_VECTOR_LEN;
2810
+ _assertClass(expected_peer_id, PeerId);
2811
+ const ret = wasm.subductionlongpoll_tryConnect(ptr0, len0, signer, expected_peer_id.__wbg_ptr, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
2812
+ return ret;
2813
+ }
2814
+ /**
2815
+ * Connect to a server using discovery mode.
2816
+ *
2817
+ * # Arguments
2818
+ *
2819
+ * * `base_url` - The server's HTTP base URL (e.g., `http://localhost:8080`)
2820
+ * * `signer` - The client's signer for authentication
2821
+ * * `service_name` - The service name for discovery. If omitted, the base URL is used.
2822
+ *
2823
+ * # Errors
2824
+ *
2825
+ * Returns [`LongPollTransportError`] if connection or handshake fails.
2826
+ * @param {string} base_url
2827
+ * @param {any} signer
2828
+ * @param {string | null} [service_name]
2829
+ * @param {Function | null} [on_disconnect]
2830
+ * @returns {Promise<AuthenticatedLongPoll>}
2831
+ */
2832
+ static tryDiscover(base_url, signer, service_name, on_disconnect) {
2833
+ const ptr0 = passStringToWasm0(base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2834
+ const len0 = WASM_VECTOR_LEN;
2835
+ var ptr1 = isLikeNone(service_name) ? 0 : passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2836
+ var len1 = WASM_VECTOR_LEN;
2837
+ const ret = wasm.subductionlongpoll_tryDiscover(ptr0, len0, signer, ptr1, len1, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
2838
+ return ret;
2839
+ }
2840
+ }
2841
+ if (Symbol.dispose) SubductionLongPoll.prototype[Symbol.dispose] = SubductionLongPoll.prototype.free;
2842
+ exports.SubductionLongPoll = SubductionLongPoll;
2843
+
2844
+ /**
2845
+ * A WebSocket transport exposing the byte-oriented `Transport` interface.
2846
+ *
2847
+ * Raw bytes from the WebSocket's `onmessage` handler are buffered in an
2848
+ * `async_channel` and returned via `recvBytes`. No message decoding or
2849
+ * request-response routing happens here — that's handled by
2850
+ * [`MessageTransport`](subduction_core::transport::message::MessageTransport).
2851
+ */
2852
+ class SubductionWebSocket {
2853
+ static __wrap(ptr) {
2854
+ ptr = ptr >>> 0;
2855
+ const obj = Object.create(SubductionWebSocket.prototype);
2856
+ obj.__wbg_ptr = ptr;
2857
+ SubductionWebSocketFinalization.register(obj, obj.__wbg_ptr, obj);
2858
+ return obj;
2859
+ }
2860
+ __destroy_into_raw() {
2861
+ const ptr = this.__wbg_ptr;
2862
+ this.__wbg_ptr = 0;
2863
+ SubductionWebSocketFinalization.unregister(this);
2864
+ return ptr;
2865
+ }
2866
+ free() {
2867
+ const ptr = this.__destroy_into_raw();
2868
+ wasm.__wbg_subductionwebsocket_free(ptr, 0);
2869
+ }
2870
+ /**
2871
+ * Disconnect from the peer gracefully.
2872
+ * @returns {Promise<void>}
2873
+ */
2874
+ disconnect() {
2875
+ const ret = wasm.subductionwebsocket_disconnect(this.__wbg_ptr);
2876
+ return ret;
2877
+ }
2878
+ /**
2879
+ * Register a callback to be invoked when the WebSocket closes.
2880
+ *
2881
+ * Part of the [`Transport`](super::JsTransport) interface contract.
2882
+ * Typically called by internal wiring (factory methods like `tryConnect`
2883
+ * and `tryDiscover`) rather than directly by user code.
2884
+ *
2885
+ * The callback is fired from the browser WebSocket's `onclose` handler.
2886
+ * @param {Function} callback
2887
+ */
2888
+ onDisconnect(callback) {
2889
+ wasm.subductionwebsocket_onDisconnect(this.__wbg_ptr, callback);
2890
+ }
2891
+ /**
2892
+ * Receive the next message frame as raw bytes.
2893
+ *
2894
+ * # Errors
2895
+ *
2896
+ * Returns [`ReadFromClosedChannel`] if the channel has been closed.
2897
+ * @returns {Promise<Uint8Array>}
2898
+ */
2899
+ recvBytes() {
2900
+ const ret = wasm.subductionwebsocket_recvBytes(this.__wbg_ptr);
2901
+ return ret;
2902
+ }
2903
+ /**
2904
+ * Send raw bytes over the WebSocket.
2905
+ *
2906
+ * # Errors
2907
+ *
2908
+ * Returns [`WasmSendError`] if the bytes could not be sent.
2909
+ * @param {Uint8Array} bytes
2910
+ * @returns {Promise<void>}
2911
+ */
2912
+ sendBytes(bytes) {
2913
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
2914
+ const len0 = WASM_VECTOR_LEN;
2915
+ const ret = wasm.subductionwebsocket_sendBytes(this.__wbg_ptr, ptr0, len0);
2916
+ return ret;
2917
+ }
2918
+ /**
2919
+ * Authenticate an existing WebSocket via handshake.
2920
+ *
2921
+ * This performs the Subduction handshake protocol over the provided WebSocket
2922
+ * to establish mutual identity. The WebSocket can be in CONNECTING or OPEN state.
2923
+ *
2924
+ * # Arguments
2925
+ *
2926
+ * * `ws` - An existing WebSocket (CONNECTING or OPEN)
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 the handshake fails (signature invalid, wrong peer, etc.)
2934
+ * @param {WebSocket} ws
2935
+ * @param {any} signer
2936
+ * @param {PeerId} expected_peer_id
2937
+ * @param {Function | null} [on_disconnect]
2938
+ * @returns {Promise<AuthenticatedWebSocket>}
2939
+ */
2940
+ static setup(ws, signer, expected_peer_id, on_disconnect) {
2941
+ _assertClass(expected_peer_id, PeerId);
2942
+ const ret = wasm.subductionwebsocket_setup(ws, signer, expected_peer_id.__wbg_ptr, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
2943
+ return ret;
2944
+ }
2945
+ /**
2946
+ * Connect to a WebSocket server with mutual authentication via handshake.
2947
+ *
2948
+ * # Arguments
2949
+ *
2950
+ * * `address` - The WebSocket URL to connect to
2951
+ * * `signer` - The client's signer for authentication
2952
+ * * `expected_peer_id` - The expected server peer ID (verified during handshake)
2953
+ * * `on_disconnect` - Optional callback invoked with the peer's [`PeerId`] when the connection closes
2954
+ *
2955
+ * # Errors
2956
+ *
2957
+ * Returns an error if:
2958
+ * - The WebSocket connection could not be established
2959
+ * - The handshake fails (signature invalid, wrong server, clock drift, etc.)
2960
+ * @param {URL} address
2961
+ * @param {any} signer
2962
+ * @param {PeerId} expected_peer_id
2963
+ * @param {Function | null} [on_disconnect]
2964
+ * @returns {Promise<AuthenticatedWebSocket>}
2965
+ */
2966
+ static tryConnect(address, signer, expected_peer_id, on_disconnect) {
2967
+ _assertClass(expected_peer_id, PeerId);
2968
+ const ret = wasm.subductionwebsocket_tryConnect(address, signer, expected_peer_id.__wbg_ptr, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
2969
+ return ret;
2970
+ }
2971
+ /**
2972
+ * Connect to a WebSocket server using discovery mode.
2973
+ *
2974
+ * This method performs a cryptographic handshake using a service name
2975
+ * instead of a known peer ID. The server's peer ID is discovered during
2976
+ * the handshake and returned.
2977
+ *
2978
+ * # Arguments
2979
+ *
2980
+ * * `address` - The WebSocket URL to connect to
2981
+ * * `signer` - The client's signer for authentication
2982
+ * * `service_name` - The service name for discovery (e.g., `localhost:8080`).
2983
+ * If omitted, the host is extracted from the URL.
2984
+ * * `on_disconnect` - Optional callback invoked with the peer's [`PeerId`] when the connection closes
2985
+ *
2986
+ * # Errors
2987
+ *
2988
+ * Returns an error if:
2989
+ * - The WebSocket connection could not be established
2990
+ * - The handshake fails (signature invalid, clock drift, etc.)
2991
+ * @param {URL} address
2992
+ * @param {any} signer
2993
+ * @param {string | null} [service_name]
2994
+ * @param {Function | null} [on_disconnect]
2995
+ * @returns {Promise<AuthenticatedWebSocket>}
2996
+ */
2997
+ static tryDiscover(address, signer, service_name, on_disconnect) {
2998
+ var ptr0 = isLikeNone(service_name) ? 0 : passStringToWasm0(service_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2999
+ var len0 = WASM_VECTOR_LEN;
3000
+ const ret = wasm.subductionwebsocket_tryDiscover(address, signer, ptr0, len0, isLikeNone(on_disconnect) ? 0 : addToExternrefTable0(on_disconnect));
3001
+ return ret;
3002
+ }
3003
+ }
3004
+ if (Symbol.dispose) SubductionWebSocket.prototype[Symbol.dispose] = SubductionWebSocket.prototype.free;
3005
+ exports.SubductionWebSocket = SubductionWebSocket;
3006
+
3007
+ /**
3008
+ * Wasm wrapper for [`SyncMessage`].
3009
+ */
3010
+ class SyncMessage {
3011
+ static __wrap(ptr) {
3012
+ ptr = ptr >>> 0;
3013
+ const obj = Object.create(SyncMessage.prototype);
3014
+ obj.__wbg_ptr = ptr;
3015
+ SyncMessageFinalization.register(obj, obj.__wbg_ptr, obj);
3016
+ return obj;
3017
+ }
3018
+ __destroy_into_raw() {
3019
+ const ptr = this.__wbg_ptr;
3020
+ this.__wbg_ptr = 0;
3021
+ SyncMessageFinalization.unregister(this);
3022
+ return ptr;
3023
+ }
3024
+ free() {
3025
+ const ptr = this.__destroy_into_raw();
3026
+ wasm.__wbg_syncmessage_free(ptr, 0);
3027
+ }
3028
+ /**
3029
+ * Upcasts; to the JS-import type for [`WasmMessage`].
3030
+ * @returns {SyncMessage}
3031
+ */
3032
+ __wasm_refgen_toWasmMessage() {
3033
+ const ret = wasm.syncmessage___wasm_refgen_toWasmMessage(this.__wbg_ptr);
3034
+ return SyncMessage.__wrap(ret);
3035
+ }
3036
+ /**
3037
+ * Create a [`SyncMessage::BatchSyncRequest`] message.
3038
+ * @param {BatchSyncRequest} request
3039
+ * @returns {SyncMessage}
3040
+ */
3041
+ static batchSyncRequest(request) {
3042
+ _assertClass(request, BatchSyncRequest);
3043
+ const ret = wasm.syncmessage_batchSyncRequest(request.__wbg_ptr);
3044
+ return SyncMessage.__wrap(ret);
3045
+ }
3046
+ /**
3047
+ * Create a [`SyncMessage::BatchSyncResponse`] message.
3048
+ * @param {BatchSyncResponse} response
3049
+ * @returns {SyncMessage}
3050
+ */
3051
+ static batchSyncResponse(response) {
3052
+ _assertClass(response, BatchSyncResponse);
3053
+ const ret = wasm.syncmessage_batchSyncResponse(response.__wbg_ptr);
3054
+ return SyncMessage.__wrap(ret);
3055
+ }
3056
+ /**
3057
+ * The [`Blob`] for commit or fragment messages, if applicable.
3058
+ * @returns {Uint8Array | undefined}
3059
+ */
3060
+ get blob() {
3061
+ const ret = wasm.syncmessage_blob(this.__wbg_ptr);
3062
+ return ret;
3063
+ }
3064
+ /**
3065
+ * The [`Blob`]s for a [`SyncMessage::BlobsResponse`], if applicable.
3066
+ * @returns {Uint8Array[] | undefined}
3067
+ */
3068
+ get blobs() {
3069
+ const ret = wasm.syncmessage_blobs(this.__wbg_ptr);
3070
+ let v1;
3071
+ if (ret[0] !== 0) {
3072
+ v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
3073
+ wasm.__wbindgen_export5(ret[0], ret[1] * 4, 4);
3074
+ }
3075
+ return v1;
3076
+ }
3077
+ /**
3078
+ * Create a [`SyncMessage::BlobsRequest`] message.
3079
+ * @param {SedimentreeId} id
3080
+ * @param {Digest[]} digests
3081
+ * @returns {SyncMessage}
3082
+ */
3083
+ static blobsRequest(id, digests) {
3084
+ _assertClass(id, SedimentreeId);
3085
+ const ptr0 = passArrayJsValueToWasm0(digests, wasm.__wbindgen_export);
3086
+ const len0 = WASM_VECTOR_LEN;
3087
+ const ret = wasm.syncmessage_blobsRequest(id.__wbg_ptr, ptr0, len0);
3088
+ return SyncMessage.__wrap(ret);
3089
+ }
3090
+ /**
3091
+ * Create a [`SyncMessage::BlobsResponse`] message.
3092
+ * @param {SedimentreeId} id
3093
+ * @param {Uint8Array[]} blobs
3094
+ * @returns {SyncMessage}
3095
+ */
3096
+ static blobsResponse(id, blobs) {
3097
+ _assertClass(id, SedimentreeId);
3098
+ const ptr0 = passArrayJsValueToWasm0(blobs, wasm.__wbindgen_export);
3099
+ const len0 = WASM_VECTOR_LEN;
3100
+ const ret = wasm.syncmessage_blobsResponse(id.__wbg_ptr, ptr0, len0);
3101
+ return SyncMessage.__wrap(ret);
3102
+ }
3103
+ /**
3104
+ * The [`LooseCommit`] for a [`SyncMessage::LooseCommit`], if applicable.
3105
+ *
3106
+ * Decodes the signed payload to extract the underlying commit.
3107
+ * @returns {LooseCommit | undefined}
3108
+ */
3109
+ get commit() {
3110
+ const ret = wasm.syncmessage_commit(this.__wbg_ptr);
3111
+ return ret === 0 ? undefined : LooseCommit.__wrap(ret);
3112
+ }
3113
+ /**
3114
+ * The requested [`Digest`]s for a [`SyncMessage::BlobsRequest`], if applicable.
3115
+ * @returns {Digest[] | undefined}
3116
+ */
3117
+ get digests() {
3118
+ const ret = wasm.syncmessage_digests(this.__wbg_ptr);
3119
+ let v1;
3120
+ if (ret[0] !== 0) {
3121
+ v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
3122
+ wasm.__wbindgen_export5(ret[0], ret[1] * 4, 4);
3123
+ }
3124
+ return v1;
3125
+ }
3126
+ /**
3127
+ * The [`Fragment`] for a [`SyncMessage::Fragment`], if applicable.
3128
+ *
3129
+ * Decodes the signed payload to extract the underlying fragment.
3130
+ * @returns {Fragment | undefined}
3131
+ */
3132
+ get fragment() {
3133
+ const ret = wasm.syncmessage_fragment(this.__wbg_ptr);
3134
+ return ret === 0 ? undefined : Fragment.__wrap(ret);
3135
+ }
3136
+ /**
3137
+ * Deserialize a message from bytes.
3138
+ *
3139
+ * # Errors
3140
+ *
3141
+ * Returns a [`JsMessageDeserializationError`] if deserialization fails.
3142
+ * @param {Uint8Array} bytes
3143
+ * @returns {SyncMessage}
3144
+ */
3145
+ static fromBytes(bytes) {
3146
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
3147
+ const len0 = WASM_VECTOR_LEN;
3148
+ const ret = wasm.syncmessage_fromBytes(ptr0, len0);
3149
+ if (ret[2]) {
3150
+ throw takeFromExternrefTable0(ret[1]);
3151
+ }
3152
+ return SyncMessage.__wrap(ret[0]);
3153
+ }
3154
+ /**
3155
+ * The [`BatchSyncRequest`] for a [`SyncMessage::BatchSyncRequest`], if applicable.
3156
+ * @returns {BatchSyncRequest | undefined}
3157
+ */
3158
+ get request() {
3159
+ const ret = wasm.syncmessage_request(this.__wbg_ptr);
3160
+ return ret === 0 ? undefined : BatchSyncRequest.__wrap(ret);
3161
+ }
3162
+ /**
3163
+ * The [`BatchSyncResponse`] for a [`SyncMessage::BatchSyncResponse`], if applicable.
3164
+ * @returns {BatchSyncResponse | undefined}
3165
+ */
3166
+ get response() {
3167
+ const ret = wasm.syncmessage_response(this.__wbg_ptr);
3168
+ return ret === 0 ? undefined : BatchSyncResponse.__wrap(ret);
3169
+ }
3170
+ /**
3171
+ * The [`SedimentreeId`] associated with this message, if any.
3172
+ * @returns {SedimentreeId | undefined}
3173
+ */
3174
+ get sedimentreeId() {
3175
+ const ret = wasm.syncmessage_sedimentreeId(this.__wbg_ptr);
3176
+ return ret === 0 ? undefined : SedimentreeId.__wrap(ret);
3177
+ }
3178
+ /**
3179
+ * Serialize the message to bytes.
3180
+ * @returns {Uint8Array}
3181
+ */
3182
+ toBytes() {
3183
+ const ret = wasm.syncmessage_toBytes(this.__wbg_ptr);
3184
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
3185
+ wasm.__wbindgen_export5(ret[0], ret[1] * 1, 1);
3186
+ return v1;
3187
+ }
3188
+ /**
3189
+ * The message variant name.
3190
+ * @returns {string}
3191
+ */
3192
+ get type() {
3193
+ let deferred1_0;
3194
+ let deferred1_1;
3195
+ try {
3196
+ const ret = wasm.syncmessage_type(this.__wbg_ptr);
3197
+ deferred1_0 = ret[0];
3198
+ deferred1_1 = ret[1];
3199
+ return getStringFromWasm0(ret[0], ret[1]);
3200
+ } finally {
3201
+ wasm.__wbindgen_export5(deferred1_0, deferred1_1, 1);
3202
+ }
3203
+ }
3204
+ }
3205
+ if (Symbol.dispose) SyncMessage.prototype[Symbol.dispose] = SyncMessage.prototype.free;
3206
+ exports.SyncMessage = SyncMessage;
3207
+
3208
+ /**
3209
+ * Statistics from a sync operation.
3210
+ *
3211
+ * The "sent" counts reflect items that were _successfully_ sent over the wire,
3212
+ * not just items that were requested.
3213
+ */
3214
+ class SyncStats {
3215
+ static __wrap(ptr) {
3216
+ ptr = ptr >>> 0;
3217
+ const obj = Object.create(SyncStats.prototype);
3218
+ obj.__wbg_ptr = ptr;
3219
+ SyncStatsFinalization.register(obj, obj.__wbg_ptr, obj);
3220
+ return obj;
3221
+ }
3222
+ __destroy_into_raw() {
3223
+ const ptr = this.__wbg_ptr;
3224
+ this.__wbg_ptr = 0;
3225
+ SyncStatsFinalization.unregister(this);
3226
+ return ptr;
3227
+ }
3228
+ free() {
3229
+ const ptr = this.__destroy_into_raw();
3230
+ wasm.__wbg_syncstats_free(ptr, 0);
3231
+ }
3232
+ /**
3233
+ * Number of commits received from the peer.
3234
+ * @returns {number}
3235
+ */
3236
+ get commitsReceived() {
3237
+ const ret = wasm.syncstats_commitsReceived(this.__wbg_ptr);
3238
+ return ret >>> 0;
3239
+ }
3240
+ /**
3241
+ * Number of commits successfully sent to the peer.
3242
+ * @returns {number}
3243
+ */
3244
+ get commitsSent() {
3245
+ const ret = wasm.syncstats_commitsSent(this.__wbg_ptr);
3246
+ return ret >>> 0;
3247
+ }
3248
+ /**
3249
+ * Number of fragments received from the peer.
3250
+ * @returns {number}
3251
+ */
3252
+ get fragmentsReceived() {
3253
+ const ret = wasm.syncstats_fragmentsReceived(this.__wbg_ptr);
3254
+ return ret >>> 0;
3255
+ }
3256
+ /**
3257
+ * Number of fragments successfully sent to the peer.
3258
+ * @returns {number}
3259
+ */
3260
+ get fragmentsSent() {
3261
+ const ret = wasm.syncstats_fragmentsSent(this.__wbg_ptr);
3262
+ return ret >>> 0;
3263
+ }
3264
+ /**
3265
+ * Returns true if no commits or fragments were transferred.
3266
+ *
3267
+ * Note: `remoteHeads` may still be non-empty (heads metadata is not
3268
+ * considered "data" for this check).
3269
+ * @returns {boolean}
3270
+ */
3271
+ get isEmpty() {
3272
+ const ret = wasm.syncstats_isEmpty(this.__wbg_ptr);
3273
+ return ret !== 0;
3274
+ }
3275
+ /**
3276
+ * The remote peer's heads for this sedimentree.
3277
+ * @returns {Digest[]}
3278
+ */
3279
+ get remoteHeads() {
3280
+ const ret = wasm.syncstats_remoteHeads(this.__wbg_ptr);
3281
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
3282
+ wasm.__wbindgen_export5(ret[0], ret[1] * 4, 4);
3283
+ return v1;
3284
+ }
3285
+ /**
3286
+ * Total items received (commits + fragments).
3287
+ * @returns {number}
3288
+ */
3289
+ get totalReceived() {
3290
+ const ret = wasm.syncstats_totalReceived(this.__wbg_ptr);
3291
+ return ret >>> 0;
3292
+ }
3293
+ /**
3294
+ * Total items sent (commits + fragments).
3295
+ * @returns {number}
3296
+ */
3297
+ get totalSent() {
3298
+ const ret = wasm.syncstats_totalSent(this.__wbg_ptr);
3299
+ return ret >>> 0;
3300
+ }
3301
+ }
3302
+ if (Symbol.dispose) SyncStats.prototype[Symbol.dispose] = SyncStats.prototype.free;
3303
+ exports.SyncStats = SyncStats;
3304
+
3305
+ /**
3306
+ * A Wasm wrapper around the ephemeral [`Topic`] type.
3307
+ *
3308
+ * Topics are opaque 32-byte identifiers for ephemeral pubsub channels.
3309
+ * A [`SedimentreeId`] can be used as a topic, but topics are not
3310
+ * limited to sedimentrees.
3311
+ *
3312
+ * [`SedimentreeId`]: sedimentree_core::id::SedimentreeId
3313
+ */
3314
+ class Topic {
3315
+ static __wrap(ptr) {
3316
+ ptr = ptr >>> 0;
3317
+ const obj = Object.create(Topic.prototype);
3318
+ obj.__wbg_ptr = ptr;
3319
+ TopicFinalization.register(obj, obj.__wbg_ptr, obj);
3320
+ return obj;
3321
+ }
3322
+ static __unwrap(jsValue) {
3323
+ if (!(jsValue instanceof Topic)) {
3324
+ return 0;
3325
+ }
3326
+ return jsValue.__destroy_into_raw();
3327
+ }
3328
+ __destroy_into_raw() {
3329
+ const ptr = this.__wbg_ptr;
3330
+ this.__wbg_ptr = 0;
3331
+ TopicFinalization.unregister(this);
3332
+ return ptr;
3333
+ }
3334
+ free() {
3335
+ const ptr = this.__destroy_into_raw();
3336
+ wasm.__wbg_topic_free(ptr, 0);
3337
+ }
3338
+ /**
3339
+ * Create a topic from a 32-byte array.
3340
+ *
3341
+ * # Errors
3342
+ *
3343
+ * Returns an error if the provided byte array is not exactly 32 bytes.
3344
+ * @param {Uint8Array} bytes
3345
+ * @returns {Topic}
3346
+ */
3347
+ static fromBytes(bytes) {
3348
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
3349
+ const len0 = WASM_VECTOR_LEN;
3350
+ const ret = wasm.topic_fromBytes(ptr0, len0);
3351
+ if (ret[2]) {
3352
+ throw takeFromExternrefTable0(ret[1]);
3353
+ }
3354
+ return Topic.__wrap(ret[0]);
3355
+ }
3356
+ /**
3357
+ * Returns the raw 32 bytes of this topic.
3358
+ * @returns {Uint8Array}
3359
+ */
3360
+ toBytes() {
3361
+ const ret = wasm.topic_toBytes(this.__wbg_ptr);
3362
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
3363
+ wasm.__wbindgen_export5(ret[0], ret[1] * 1, 1);
3364
+ return v1;
3365
+ }
3366
+ /**
3367
+ * Returns a shortened hex prefix representation (first 4 bytes + `…`).
3368
+ * @returns {string}
3369
+ */
3370
+ toString() {
3371
+ let deferred1_0;
3372
+ let deferred1_1;
3373
+ try {
3374
+ const ret = wasm.topic_toString(this.__wbg_ptr);
3375
+ deferred1_0 = ret[0];
3376
+ deferred1_1 = ret[1];
3377
+ return getStringFromWasm0(ret[0], ret[1]);
3378
+ } finally {
3379
+ wasm.__wbindgen_export5(deferred1_0, deferred1_1, 1);
3380
+ }
3381
+ }
3382
+ }
3383
+ if (Symbol.dispose) Topic.prototype[Symbol.dispose] = Topic.prototype.free;
3384
+ exports.Topic = Topic;
3385
+
3386
+ /**
3387
+ * An Ed25519 signer using the browser's `WebCrypto` API.
3388
+ *
3389
+ * This signer generates and stores Ed25519 keys using `crypto.subtle`,
3390
+ * providing secure key generation and signing operations. The key is
3391
+ * persisted to `IndexedDB` so it survives page reloads.
3392
+ *
3393
+ * # Example
3394
+ *
3395
+ * ```javascript
3396
+ * import { WebCryptoSigner } from "@anthropic/subduction";
3397
+ *
3398
+ * const signer = await WebCryptoSigner.setup();
3399
+ * console.log("Peer ID:", signer.peerId().toString());
3400
+ * ```
3401
+ */
3402
+ class WebCryptoSigner {
3403
+ static __wrap(ptr) {
3404
+ ptr = ptr >>> 0;
3405
+ const obj = Object.create(WebCryptoSigner.prototype);
3406
+ obj.__wbg_ptr = ptr;
3407
+ WebCryptoSignerFinalization.register(obj, obj.__wbg_ptr, obj);
3408
+ return obj;
3409
+ }
3410
+ __destroy_into_raw() {
3411
+ const ptr = this.__wbg_ptr;
3412
+ this.__wbg_ptr = 0;
3413
+ WebCryptoSignerFinalization.unregister(this);
3414
+ return ptr;
3415
+ }
3416
+ free() {
3417
+ const ptr = this.__destroy_into_raw();
3418
+ wasm.__wbg_webcryptosigner_free(ptr, 0);
3419
+ }
3420
+ /**
3421
+ * Get the peer ID derived from this signer's verifying key.
3422
+ *
3423
+ * # Panics
3424
+ *
3425
+ * Panics if the stored public key bytes are invalid (should never happen).
3426
+ * @returns {PeerId}
3427
+ */
3428
+ peerId() {
3429
+ const ret = wasm.webcryptosigner_peerId(this.__wbg_ptr);
3430
+ return PeerId.__wrap(ret);
3431
+ }
3432
+ /**
3433
+ * Set up the signer, loading an existing key from `IndexedDB` or generating a new one.
3434
+ *
3435
+ * # Errors
3436
+ *
3437
+ * Returns an error if `WebCrypto` or `IndexedDB` operations fail.
3438
+ * @returns {Promise<WebCryptoSigner>}
3439
+ */
3440
+ static setup() {
3441
+ const ret = wasm.webcryptosigner_setup();
3442
+ return ret;
3443
+ }
3444
+ /**
3445
+ * Sign a message and return the 64-byte Ed25519 signature.
3446
+ *
3447
+ * # Errors
3448
+ *
3449
+ * Returns an error if `WebCrypto` signing fails.
3450
+ * @param {Uint8Array} message
3451
+ * @returns {Promise<Uint8Array>}
3452
+ */
3453
+ sign(message) {
3454
+ const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_export);
3455
+ const len0 = WASM_VECTOR_LEN;
3456
+ const ret = wasm.webcryptosigner_sign(this.__wbg_ptr, ptr0, len0);
3457
+ return ret;
3458
+ }
3459
+ /**
3460
+ * Get the 32-byte Ed25519 verifying (public) key.
3461
+ * @returns {Uint8Array}
3462
+ */
3463
+ verifyingKey() {
3464
+ const ret = wasm.webcryptosigner_verifyingKey(this.__wbg_ptr);
3465
+ return ret;
3466
+ }
3467
+ }
3468
+ if (Symbol.dispose) WebCryptoSigner.prototype[Symbol.dispose] = WebCryptoSigner.prototype.free;
3469
+ exports.WebCryptoSigner = WebCryptoSigner;
3470
+
3471
+ /**
3472
+ * Convenience factory — equivalent to `new MessagePortTransport(port)`.
3473
+ * @param {any} port
3474
+ * @returns {MessagePortTransport}
3475
+ */
3476
+ function makeMessagePortTransport(port) {
3477
+ const ret = wasm.makeMessagePortTransport(port);
3478
+ return MessagePortTransport.__wrap(ret);
3479
+ }
3480
+ exports.makeMessagePortTransport = makeMessagePortTransport;
3481
+
3482
+ /**
3483
+ * Entry point called when the Wasm module is instantiated.
3484
+ *
3485
+ * Only compiled when the `standalone` feature is active. Downstream cdylib
3486
+ * crates that define their own `#[wasm_bindgen(start)]` should depend on
3487
+ * `subduction_wasm` with `default-features = false` and call
3488
+ * [`set_panic_hook`] from their own start function.
3489
+ */
3490
+ function start() {
3491
+ wasm.start();
3492
+ }
3493
+ exports.start = start;
3494
+ const import1 = require("./snippets/subduction_wasm-ec51bcf335db35bd/inline0.js");
3495
+ const import2 = require("./snippets/subduction_wasm-ec51bcf335db35bd/inline1.js");
3496
+
3497
+ function __wbg_get_imports() {
3498
+ const import0 = {
3499
+ __proto__: null,
3500
+ __wbg___wasm_refgen_toWasmCommitWithBlob_bcab5aaed3558280: function(arg0) {
3501
+ const ret = arg0.__wasm_refgen_toWasmCommitWithBlob();
3502
+ _assertClass(ret, CommitWithBlob);
3503
+ var ptr1 = ret.__destroy_into_raw();
3504
+ return ptr1;
3505
+ },
3506
+ __wbg___wasm_refgen_toWasmDepth_5124f666e343ff0c: function(arg0) {
3507
+ const ret = arg0.__wasm_refgen_toWasmDepth();
3508
+ _assertClass(ret, Depth);
3509
+ var ptr1 = ret.__destroy_into_raw();
3510
+ return ptr1;
3511
+ },
3512
+ __wbg___wasm_refgen_toWasmDigest_476b24805f220005: function(arg0) {
3513
+ const ret = arg0.__wasm_refgen_toWasmDigest();
3514
+ _assertClass(ret, Digest);
3515
+ var ptr1 = ret.__destroy_into_raw();
3516
+ return ptr1;
3517
+ },
3518
+ __wbg___wasm_refgen_toWasmFragmentWithBlob_ed713e5c5f4cc52e: function(arg0) {
3519
+ const ret = arg0.__wasm_refgen_toWasmFragmentWithBlob();
3520
+ _assertClass(ret, FragmentWithBlob);
3521
+ var ptr1 = ret.__destroy_into_raw();
3522
+ return ptr1;
3523
+ },
3524
+ __wbg___wasm_refgen_toWasmFragment_10dd1ff9b3934840: function(arg0) {
3525
+ const ret = arg0.__wasm_refgen_toWasmFragment();
3526
+ _assertClass(ret, Fragment);
3527
+ var ptr1 = ret.__destroy_into_raw();
3528
+ return ptr1;
3529
+ },
3530
+ __wbg___wasm_refgen_toWasmLooseCommit_f36ad6a9389cee03: function(arg0) {
3531
+ const ret = arg0.__wasm_refgen_toWasmLooseCommit();
3532
+ _assertClass(ret, LooseCommit);
3533
+ var ptr1 = ret.__destroy_into_raw();
3534
+ return ptr1;
3535
+ },
3536
+ __wbg___wbindgen_debug_string_5398f5bb970e0daa: function(arg0, arg1) {
3537
+ const ret = debugString(arg1);
3538
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3539
+ const len1 = WASM_VECTOR_LEN;
3540
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3541
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3542
+ },
3543
+ __wbg___wbindgen_is_function_3c846841762788c1: function(arg0) {
3544
+ const ret = typeof(arg0) === 'function';
3545
+ return ret;
3546
+ },
3547
+ __wbg___wbindgen_is_null_0b605fc6b167c56f: function(arg0) {
3548
+ const ret = arg0 === null;
3549
+ return ret;
3550
+ },
3551
+ __wbg___wbindgen_is_object_781bc9f159099513: function(arg0) {
3552
+ const val = arg0;
3553
+ const ret = typeof(val) === 'object' && val !== null;
3554
+ return ret;
3555
+ },
3556
+ __wbg___wbindgen_is_string_7ef6b97b02428fae: function(arg0) {
3557
+ const ret = typeof(arg0) === 'string';
3558
+ return ret;
3559
+ },
3560
+ __wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
3561
+ const ret = arg0 === undefined;
3562
+ return ret;
3563
+ },
3564
+ __wbg___wbindgen_jsval_eq_ee31bfad3e536463: function(arg0, arg1) {
3565
+ const ret = arg0 === arg1;
3566
+ return ret;
3567
+ },
3568
+ __wbg___wbindgen_number_get_34bb9d9dcfa21373: function(arg0, arg1) {
3569
+ const obj = arg1;
3570
+ const ret = typeof(obj) === 'number' ? obj : undefined;
3571
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
3572
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
3573
+ },
3574
+ __wbg___wbindgen_string_get_395e606bd0ee4427: function(arg0, arg1) {
3575
+ const obj = arg1;
3576
+ const ret = typeof(obj) === 'string' ? obj : undefined;
3577
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3578
+ var len1 = WASM_VECTOR_LEN;
3579
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3580
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3581
+ },
3582
+ __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
3583
+ throw new Error(getStringFromWasm0(arg0, arg1));
3584
+ },
3585
+ __wbg__wbg_cb_unref_6b5b6b8576d35cb1: function(arg0) {
3586
+ arg0._wbg_cb_unref();
3587
+ },
3588
+ __wbg_arrayBuffer_eb8e9ca620af2a19: function() { return handleError(function (arg0) {
3589
+ const ret = arg0.arrayBuffer();
3590
+ return ret;
3591
+ }, arguments); },
3592
+ __wbg_authenticatedlongpoll_new: function(arg0) {
3593
+ const ret = AuthenticatedLongPoll.__wrap(arg0);
3594
+ return ret;
3595
+ },
3596
+ __wbg_authenticatedtransport_new: function(arg0) {
3597
+ const ret = AuthenticatedTransport.__wrap(arg0);
3598
+ return ret;
3599
+ },
3600
+ __wbg_authenticatedwebsocket_new: function(arg0) {
3601
+ const ret = AuthenticatedWebSocket.__wrap(arg0);
3602
+ return ret;
3603
+ },
3604
+ __wbg_authorizeConnect_8e2609308bbbbcfd: function() { return handleError(function (arg0, arg1) {
3605
+ const ret = arg0.authorizeConnect(PeerId.__wrap(arg1));
3606
+ return ret;
3607
+ }, arguments); },
3608
+ __wbg_authorizeFetch_b7bcc4e437112c73: function() { return handleError(function (arg0, arg1, arg2) {
3609
+ const ret = arg0.authorizeFetch(PeerId.__wrap(arg1), SedimentreeId.__wrap(arg2));
3610
+ return ret;
3611
+ }, arguments); },
3612
+ __wbg_authorizePublish_7e546fc3d8103532: function() { return handleError(function (arg0, arg1, arg2) {
3613
+ const ret = arg0.authorizePublish(PeerId.__wrap(arg1), Topic.__wrap(arg2));
3614
+ return ret;
3615
+ }, arguments); },
3616
+ __wbg_authorizePut_ba5a5e36c9e9bbfa: function() { return handleError(function (arg0, arg1, arg2, arg3) {
3617
+ const ret = arg0.authorizePut(PeerId.__wrap(arg1), PeerId.__wrap(arg2), SedimentreeId.__wrap(arg3));
3618
+ return ret;
3619
+ }, arguments); },
3620
+ __wbg_authorizeSubscribe_34f5ba6f23bab853: function() { return handleError(function (arg0, arg1, arg2) {
3621
+ const ret = arg0.authorizeSubscribe(PeerId.__wrap(arg1), Topic.__wrap(arg2));
3622
+ return ret;
3623
+ }, arguments); },
3624
+ __wbg_buffer_60b8043cd926067d: function(arg0) {
3625
+ const ret = arg0.buffer;
3626
+ return ret;
3627
+ },
3628
+ __wbg_call_2d781c1f4d5c0ef8: function() { return handleError(function (arg0, arg1, arg2) {
3629
+ const ret = arg0.call(arg1, arg2);
3630
+ return ret;
3631
+ }, arguments); },
3632
+ __wbg_call_e133b57c9155d22c: function() { return handleError(function (arg0, arg1) {
3633
+ const ret = arg0.call(arg1);
3634
+ return ret;
3635
+ }, arguments); },
3636
+ __wbg_call_f858478a02f9600f: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
3637
+ const ret = arg0.call(arg1, arg2, arg3, arg4);
3638
+ return ret;
3639
+ }, arguments); },
3640
+ __wbg_close_af26905c832a88cb: function() { return handleError(function (arg0) {
3641
+ arg0.close();
3642
+ }, arguments); },
3643
+ __wbg_close_cbf870bdad0aad99: function(arg0) {
3644
+ arg0.close();
3645
+ },
3646
+ __wbg_close_f85b3643ad9ed8d4: function(arg0) {
3647
+ arg0.close();
3648
+ },
3649
+ __wbg_commitwithblob_new: function(arg0) {
3650
+ const ret = CommitWithBlob.__wrap(arg0);
3651
+ return ret;
3652
+ },
3653
+ __wbg_contains_ef4bfb7fa5a241b7: function(arg0, arg1, arg2) {
3654
+ const ret = arg0.contains(getStringFromWasm0(arg1, arg2));
3655
+ return ret;
3656
+ },
3657
+ __wbg_createObjectStore_92a8aebcc6f9d7e3: function() { return handleError(function (arg0, arg1, arg2) {
3658
+ const ret = arg0.createObjectStore(getStringFromWasm0(arg1, arg2));
3659
+ return ret;
3660
+ }, arguments); },
3661
+ __wbg_crypto_38df2bab126b63dc: function(arg0) {
3662
+ const ret = arg0.crypto;
3663
+ return ret;
3664
+ },
3665
+ __wbg_data_a3d9ff9cdd801002: function(arg0) {
3666
+ const ret = arg0.data;
3667
+ return ret;
3668
+ },
3669
+ __wbg_deleteAllCommits_026a63e00bba2a2c: function(arg0, arg1) {
3670
+ const ret = arg0.deleteAllCommits(arg1);
3671
+ return ret;
3672
+ },
3673
+ __wbg_deleteAllFragments_857ddb74b3342f83: function(arg0, arg1) {
3674
+ const ret = arg0.deleteAllFragments(arg1);
3675
+ return ret;
3676
+ },
3677
+ __wbg_digest_new: function(arg0) {
3678
+ const ret = Digest.__wrap(arg0);
3679
+ return ret;
3680
+ },
3681
+ __wbg_digest_unwrap: function(arg0) {
3682
+ const ret = Digest.__unwrap(arg0);
3683
+ return ret;
3684
+ },
3685
+ __wbg_disconnect_91312bb506e834b1: function(arg0) {
3686
+ const ret = arg0.disconnect();
3687
+ return ret;
3688
+ },
3689
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
3690
+ let deferred0_0;
3691
+ let deferred0_1;
3692
+ try {
3693
+ deferred0_0 = arg0;
3694
+ deferred0_1 = arg1;
3695
+ console.error(getStringFromWasm0(arg0, arg1));
3696
+ } finally {
3697
+ wasm.__wbindgen_export5(deferred0_0, deferred0_1, 1);
3698
+ }
3699
+ },
3700
+ __wbg_exportKey_c43b919dba5a1db2: function() { return handleError(function (arg0, arg1, arg2, arg3) {
3701
+ const ret = arg0.exportKey(getStringFromWasm0(arg1, arg2), arg3);
3702
+ return ret;
3703
+ }, arguments); },
3704
+ __wbg_fetch_5550a88cf343aaa9: function(arg0, arg1) {
3705
+ const ret = arg0.fetch(arg1);
3706
+ return ret;
3707
+ },
3708
+ __wbg_fetch_f8a611684c3b5fe5: function(arg0, arg1) {
3709
+ const ret = arg0.fetch(arg1);
3710
+ return ret;
3711
+ },
3712
+ __wbg_filterAuthorizedFetch_a647f13dc33948f1: function() { return handleError(function (arg0, arg1, arg2, arg3) {
3713
+ var v0 = getArrayJsValueFromWasm0(arg2, arg3).slice();
3714
+ wasm.__wbindgen_export5(arg2, arg3 * 4, 4);
3715
+ const ret = arg0.filterAuthorizedFetch(PeerId.__wrap(arg1), v0);
3716
+ return ret;
3717
+ }, arguments); },
3718
+ __wbg_filterAuthorizedSubscribers_34bdeaaac0eb31a5: function() { return handleError(function (arg0, arg1, arg2, arg3) {
3719
+ var v0 = getArrayJsValueFromWasm0(arg2, arg3).slice();
3720
+ wasm.__wbindgen_export5(arg2, arg3 * 4, 4);
3721
+ const ret = arg0.filterAuthorizedSubscribers(Topic.__wrap(arg1), v0);
3722
+ return ret;
3723
+ }, arguments); },
3724
+ __wbg_fragment_new: function(arg0) {
3725
+ const ret = Fragment.__wrap(arg0);
3726
+ return ret;
3727
+ },
3728
+ __wbg_fragmentrequested_new: function(arg0) {
3729
+ const ret = FragmentRequested.__wrap(arg0);
3730
+ return ret;
3731
+ },
3732
+ __wbg_fragmentwithblob_new: function(arg0) {
3733
+ const ret = FragmentWithBlob.__wrap(arg0);
3734
+ return ret;
3735
+ },
3736
+ __wbg_from_4bdf88943703fd48: function(arg0) {
3737
+ const ret = Array.from(arg0);
3738
+ return ret;
3739
+ },
3740
+ __wbg_generateKey_2b6cf71e7c9ad526: function() { return handleError(function (arg0, arg1, arg2, arg3) {
3741
+ const ret = arg0.generateKey(arg1, arg2 !== 0, arg3);
3742
+ return ret;
3743
+ }, arguments); },
3744
+ __wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
3745
+ arg0.getRandomValues(arg1);
3746
+ }, arguments); },
3747
+ __wbg_get_3ef1eba1850ade27: function() { return handleError(function (arg0, arg1) {
3748
+ const ret = Reflect.get(arg0, arg1);
3749
+ return ret;
3750
+ }, arguments); },
3751
+ __wbg_get_6ac8c8119f577720: function() { return handleError(function (arg0, arg1) {
3752
+ const ret = arg0.get(arg1);
3753
+ return ret;
3754
+ }, arguments); },
3755
+ __wbg_get_a867a94064ecd263: function() { return handleError(function (arg0, arg1, arg2, arg3) {
3756
+ const ret = arg1.get(getStringFromWasm0(arg2, arg3));
3757
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3758
+ var len1 = WASM_VECTOR_LEN;
3759
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3760
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3761
+ }, arguments); },
3762
+ __wbg_get_a8ee5c45dabc1b3b: function(arg0, arg1) {
3763
+ const ret = arg0[arg1 >>> 0];
3764
+ return ret;
3765
+ },
3766
+ __wbg_get_unchecked_329cfe50afab7352: function(arg0, arg1) {
3767
+ const ret = arg0[arg1 >>> 0];
3768
+ return ret;
3769
+ },
3770
+ __wbg_has_926ef2ff40b308cf: function() { return handleError(function (arg0, arg1) {
3771
+ const ret = Reflect.has(arg0, arg1);
3772
+ return ret;
3773
+ }, arguments); },
3774
+ __wbg_headers_eb2234545f9ff993: function(arg0) {
3775
+ const ret = arg0.headers;
3776
+ return ret;
3777
+ },
3778
+ __wbg_host_5b3ec3e9d4d1fc78: function(arg0, arg1) {
3779
+ const ret = arg1.host;
3780
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3781
+ const len1 = WASM_VECTOR_LEN;
3782
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3783
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3784
+ },
3785
+ __wbg_href_da367531ce807a58: function(arg0, arg1) {
3786
+ const ret = arg1.href;
3787
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3788
+ const len1 = WASM_VECTOR_LEN;
3789
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3790
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3791
+ },
3792
+ __wbg_importKey_397406e38b080c57: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
3793
+ const ret = arg0.importKey(getStringFromWasm0(arg1, arg2), arg3, arg4, arg5 !== 0, arg6);
3794
+ return ret;
3795
+ }, arguments); },
3796
+ __wbg_instanceof_ArrayBuffer_101e2bf31071a9f6: function(arg0) {
3797
+ let result;
3798
+ try {
3799
+ result = arg0 instanceof ArrayBuffer;
3800
+ } catch (_) {
3801
+ result = false;
3802
+ }
3803
+ const ret = result;
3804
+ return ret;
3805
+ },
3806
+ __wbg_instanceof_Crypto_5c2a4c15287b0332: function(arg0) {
3807
+ let result;
3808
+ try {
3809
+ result = arg0 instanceof Crypto;
3810
+ } catch (_) {
3811
+ result = false;
3812
+ }
3813
+ const ret = result;
3814
+ return ret;
3815
+ },
3816
+ __wbg_instanceof_IdbDatabase_5f436cc89cc07f14: function(arg0) {
3817
+ let result;
3818
+ try {
3819
+ result = arg0 instanceof IDBDatabase;
3820
+ } catch (_) {
3821
+ result = false;
3822
+ }
3823
+ const ret = result;
3824
+ return ret;
3825
+ },
3826
+ __wbg_instanceof_IdbFactory_efcffbfd9020e4ac: function(arg0) {
3827
+ let result;
3828
+ try {
3829
+ result = arg0 instanceof IDBFactory;
3830
+ } catch (_) {
3831
+ result = false;
3832
+ }
3833
+ const ret = result;
3834
+ return ret;
3835
+ },
3836
+ __wbg_instanceof_IdbOpenDbRequest_10c2576001eb6613: function(arg0) {
3837
+ let result;
3838
+ try {
3839
+ result = arg0 instanceof IDBOpenDBRequest;
3840
+ } catch (_) {
3841
+ result = false;
3842
+ }
3843
+ const ret = result;
3844
+ return ret;
3845
+ },
3846
+ __wbg_instanceof_Promise_7c3bdd7805c2c6e6: function(arg0) {
3847
+ let result;
3848
+ try {
3849
+ result = arg0 instanceof Promise;
3850
+ } catch (_) {
3851
+ result = false;
3852
+ }
3853
+ const ret = result;
3854
+ return ret;
3855
+ },
3856
+ __wbg_instanceof_Response_9b4d9fd451e051b1: function(arg0) {
3857
+ let result;
3858
+ try {
3859
+ result = arg0 instanceof Response;
3860
+ } catch (_) {
3861
+ result = false;
3862
+ }
3863
+ const ret = result;
3864
+ return ret;
3865
+ },
3866
+ __wbg_instanceof_Uint8Array_740438561a5b956d: function(arg0) {
3867
+ let result;
3868
+ try {
3869
+ result = arg0 instanceof Uint8Array;
3870
+ } catch (_) {
3871
+ result = false;
3872
+ }
3873
+ const ret = result;
3874
+ return ret;
3875
+ },
3876
+ __wbg_instanceof_Window_23e677d2c6843922: function(arg0) {
3877
+ let result;
3878
+ try {
3879
+ result = arg0 instanceof Window;
3880
+ } catch (_) {
3881
+ result = false;
3882
+ }
3883
+ const ret = result;
3884
+ return ret;
3885
+ },
3886
+ __wbg_instanceof_WorkerGlobalScope_de6976d00cb213c6: function(arg0) {
3887
+ let result;
3888
+ try {
3889
+ result = arg0 instanceof WorkerGlobalScope;
3890
+ } catch (_) {
3891
+ result = false;
3892
+ }
3893
+ const ret = result;
3894
+ return ret;
3895
+ },
3896
+ __wbg_isArray_33b91feb269ff46e: function(arg0) {
3897
+ const ret = Array.isArray(arg0);
3898
+ return ret;
3899
+ },
3900
+ __wbg_isSafeInteger_ecd6a7f9c3e053cd: function(arg0) {
3901
+ const ret = Number.isSafeInteger(arg0);
3902
+ return ret;
3903
+ },
3904
+ __wbg_length_b3416cf66a5452c8: function(arg0) {
3905
+ const ret = arg0.length;
3906
+ return ret;
3907
+ },
3908
+ __wbg_length_ea16607d7b61445b: function(arg0) {
3909
+ const ret = arg0.length;
3910
+ return ret;
3911
+ },
3912
+ __wbg_loadAllCommits_c18e977eb552890c: function(arg0, arg1) {
3913
+ const ret = arg0.loadAllCommits(arg1);
3914
+ return ret;
3915
+ },
3916
+ __wbg_loadAllFragments_499f304a483c7f7f: function(arg0, arg1) {
3917
+ const ret = arg0.loadAllFragments(arg1);
3918
+ return ret;
3919
+ },
3920
+ __wbg_loadAllSedimentreeIds_da48711155f73930: function(arg0) {
3921
+ const ret = arg0.loadAllSedimentreeIds();
3922
+ return ret;
3923
+ },
3924
+ __wbg_loosecommit_new: function(arg0) {
3925
+ const ret = LooseCommit.__wrap(arg0);
3926
+ return ret;
3927
+ },
3928
+ __wbg_messageporttransport_new: function(arg0) {
3929
+ const ret = MessagePortTransport.__wrap(arg0);
3930
+ return ret;
3931
+ },
3932
+ __wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
3933
+ const ret = arg0.msCrypto;
3934
+ return ret;
3935
+ },
3936
+ __wbg_new_0837727332ac86ba: function() { return handleError(function () {
3937
+ const ret = new Headers();
3938
+ return ret;
3939
+ }, arguments); },
3940
+ __wbg_new_227d7c05414eb861: function() {
3941
+ const ret = new Error();
3942
+ return ret;
3943
+ },
3944
+ __wbg_new_5f486cdf45a04d78: function(arg0) {
3945
+ const ret = new Uint8Array(arg0);
3946
+ return ret;
3947
+ },
3948
+ __wbg_new_a70fbab9066b301f: function() {
3949
+ const ret = new Array();
3950
+ return ret;
3951
+ },
3952
+ __wbg_new_ab79df5bd7c26067: function() {
3953
+ const ret = new Object();
3954
+ return ret;
3955
+ },
3956
+ __wbg_new_d098e265629cd10f: function(arg0, arg1) {
3957
+ try {
3958
+ var state0 = {a: arg0, b: arg1};
3959
+ var cb0 = (arg0, arg1) => {
3960
+ const a = state0.a;
3961
+ state0.a = 0;
3962
+ try {
3963
+ return __wasm_bindgen_func_elem_1652_195(a, state0.b, arg0, arg1);
3964
+ } finally {
3965
+ state0.a = a;
3966
+ }
3967
+ };
3968
+ const ret = new Promise(cb0);
3969
+ return ret;
3970
+ } finally {
3971
+ state0.a = state0.b = 0;
3972
+ }
3973
+ },
3974
+ __wbg_new_d15cb560a6a0e5f0: function(arg0, arg1) {
3975
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
3976
+ return ret;
3977
+ },
3978
+ __wbg_new_dd50bcc3f60ba434: function() { return handleError(function (arg0, arg1) {
3979
+ const ret = new WebSocket(getStringFromWasm0(arg0, arg1));
3980
+ return ret;
3981
+ }, arguments); },
3982
+ __wbg_new_f7708ba82c4c12f6: function() { return handleError(function () {
3983
+ const ret = new MessageChannel();
3984
+ return ret;
3985
+ }, arguments); },
3986
+ __wbg_new_from_slice_22da9388ac046e50: function(arg0, arg1) {
3987
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
3988
+ return ret;
3989
+ },
3990
+ __wbg_new_typed_aaaeaf29cf802876: function(arg0, arg1) {
3991
+ try {
3992
+ var state0 = {a: arg0, b: arg1};
3993
+ var cb0 = (arg0, arg1) => {
3994
+ const a = state0.a;
3995
+ state0.a = 0;
3996
+ try {
3997
+ return __wasm_bindgen_func_elem_1652_196(a, state0.b, arg0, arg1);
3998
+ } finally {
3999
+ state0.a = a;
4000
+ }
4001
+ };
4002
+ const ret = new Promise(cb0);
4003
+ return ret;
4004
+ } finally {
4005
+ state0.a = state0.b = 0;
4006
+ }
4007
+ },
4008
+ __wbg_new_typed_bccac67128ed885a: function() {
4009
+ const ret = new Array();
4010
+ return ret;
4011
+ },
4012
+ __wbg_new_with_length_3259a525196bd8cc: function(arg0) {
4013
+ const ret = new Array(arg0 >>> 0);
4014
+ return ret;
4015
+ },
4016
+ __wbg_new_with_length_825018a1616e9e55: function(arg0) {
4017
+ const ret = new Uint8Array(arg0 >>> 0);
4018
+ return ret;
4019
+ },
4020
+ __wbg_new_with_str_and_init_b4b54d1a819bc724: function() { return handleError(function (arg0, arg1, arg2) {
4021
+ const ret = new Request(getStringFromWasm0(arg0, arg1), arg2);
4022
+ return ret;
4023
+ }, arguments); },
4024
+ __wbg_node_84ea875411254db1: function(arg0) {
4025
+ const ret = arg0.node;
4026
+ return ret;
4027
+ },
4028
+ __wbg_now_16f0c993d5dd6c27: function() {
4029
+ const ret = Date.now();
4030
+ return ret;
4031
+ },
4032
+ __wbg_objectStoreNames_564985d2e9ae7523: function(arg0) {
4033
+ const ret = arg0.objectStoreNames;
4034
+ return ret;
4035
+ },
4036
+ __wbg_objectStore_f314ab152a5c7bd0: function() { return handleError(function (arg0, arg1, arg2) {
4037
+ const ret = arg0.objectStore(getStringFromWasm0(arg1, arg2));
4038
+ return ret;
4039
+ }, arguments); },
4040
+ __wbg_of_8bf7ed3eca00ea43: function(arg0) {
4041
+ const ret = Array.of(arg0);
4042
+ return ret;
4043
+ },
4044
+ __wbg_of_d6376e3774c51f89: function(arg0, arg1) {
4045
+ const ret = Array.of(arg0, arg1);
4046
+ return ret;
4047
+ },
4048
+ __wbg_onDisconnect_a24437def131c941: function(arg0, arg1) {
4049
+ arg0.onDisconnect(arg1);
4050
+ },
4051
+ __wbg_open_e7a9d3d6344572f6: function() { return handleError(function (arg0, arg1, arg2, arg3) {
4052
+ const ret = arg0.open(getStringFromWasm0(arg1, arg2), arg3 >>> 0);
4053
+ return ret;
4054
+ }, arguments); },
4055
+ __wbg_peerbatchsyncresult_new: function(arg0) {
4056
+ const ret = PeerBatchSyncResult.__wrap(arg0);
4057
+ return ret;
4058
+ },
4059
+ __wbg_peerid_new: function(arg0) {
4060
+ const ret = PeerId.__wrap(arg0);
4061
+ return ret;
4062
+ },
4063
+ __wbg_peerresultmap_new: function(arg0) {
4064
+ const ret = PeerResultMap.__wrap(arg0);
4065
+ return ret;
4066
+ },
4067
+ __wbg_port1_869a7ef90538dbdf: function(arg0) {
4068
+ const ret = arg0.port1;
4069
+ return ret;
4070
+ },
4071
+ __wbg_port2_947a51b8ba00adc9: function(arg0) {
4072
+ const ret = arg0.port2;
4073
+ return ret;
4074
+ },
4075
+ __wbg_postMessage_fb1c205fdbbf796d: function(arg0, arg1) {
4076
+ arg0.postMessage(arg1);
4077
+ },
4078
+ __wbg_process_44c7a14e11e9f69e: function(arg0) {
4079
+ const ret = arg0.process;
4080
+ return ret;
4081
+ },
4082
+ __wbg_prototypesetcall_d62e5099504357e6: function(arg0, arg1, arg2) {
4083
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
4084
+ },
4085
+ __wbg_push_e87b0e732085a946: function(arg0, arg1) {
4086
+ const ret = arg0.push(arg1);
4087
+ return ret;
4088
+ },
4089
+ __wbg_put_f1673d719f93ce22: function() { return handleError(function (arg0, arg1, arg2) {
4090
+ const ret = arg0.put(arg1, arg2);
4091
+ return ret;
4092
+ }, arguments); },
4093
+ __wbg_queueMicrotask_0c399741342fb10f: function(arg0) {
4094
+ const ret = arg0.queueMicrotask;
4095
+ return ret;
4096
+ },
4097
+ __wbg_queueMicrotask_a082d78ce798393e: function(arg0) {
4098
+ queueMicrotask(arg0);
4099
+ },
4100
+ __wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
4101
+ arg0.randomFillSync(arg1);
4102
+ }, arguments); },
4103
+ __wbg_readyState_1f1e7f1bdf9f4d42: function(arg0) {
4104
+ const ret = arg0.readyState;
4105
+ return ret;
4106
+ },
4107
+ __wbg_recvBytes_e13f381294da16db: function(arg0) {
4108
+ const ret = arg0.recvBytes();
4109
+ return ret;
4110
+ },
4111
+ __wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
4112
+ const ret = module.require;
4113
+ return ret;
4114
+ }, arguments); },
4115
+ __wbg_resolve_ae8d83246e5bcc12: function(arg0) {
4116
+ const ret = Promise.resolve(arg0);
4117
+ return ret;
4118
+ },
4119
+ __wbg_result_c5baa2d3d690a01a: function() { return handleError(function (arg0) {
4120
+ const ret = arg0.result;
4121
+ return ret;
4122
+ }, arguments); },
4123
+ __wbg_saveBatchAll_7c5c5f486aefa571: function(arg0, arg1, arg2, arg3) {
4124
+ const ret = arg0.saveBatchAll(arg1, arg2, arg3);
4125
+ return ret;
4126
+ },
4127
+ __wbg_saveCommit_fb38edd913837eb2: function(arg0, arg1, arg2, arg3, arg4) {
4128
+ const ret = arg0.saveCommit(arg1, arg2, arg3, arg4);
4129
+ return ret;
4130
+ },
4131
+ __wbg_saveFragment_8682cc697a38dbad: function(arg0, arg1, arg2, arg3, arg4) {
4132
+ const ret = arg0.saveFragment(arg1, arg2, arg3, arg4);
4133
+ return ret;
4134
+ },
4135
+ __wbg_saveSedimentreeId_ec8145842e87e53b: function(arg0, arg1) {
4136
+ const ret = arg0.saveSedimentreeId(arg1);
4137
+ return ret;
4138
+ },
4139
+ __wbg_sedimentreeid_new: function(arg0) {
4140
+ const ret = SedimentreeId.__wrap(arg0);
4141
+ return ret;
4142
+ },
4143
+ __wbg_sedimentreeid_unwrap: function(arg0) {
4144
+ const ret = SedimentreeId.__unwrap(arg0);
4145
+ return ret;
4146
+ },
4147
+ __wbg_sendBytes_9a00cdaf7c891eff: function(arg0, arg1) {
4148
+ const ret = arg0.sendBytes(arg1);
4149
+ return ret;
4150
+ },
4151
+ __wbg_send_d31a693c975dea74: function() { return handleError(function (arg0, arg1, arg2) {
4152
+ arg0.send(getArrayU8FromWasm0(arg1, arg2));
4153
+ }, arguments); },
4154
+ __wbg_setTimeout_43db2c2050a4d3d2: function(arg0, arg1) {
4155
+ const ret = setTimeout(arg0, arg1);
4156
+ return ret;
4157
+ },
4158
+ __wbg_set_282384002438957f: function(arg0, arg1, arg2) {
4159
+ arg0[arg1 >>> 0] = arg2;
4160
+ },
4161
+ __wbg_set_7eaa4f96924fd6b3: function() { return handleError(function (arg0, arg1, arg2) {
4162
+ const ret = Reflect.set(arg0, arg1, arg2);
4163
+ return ret;
4164
+ }, arguments); },
4165
+ __wbg_set_binaryType_3dcf8281ec100a8f: function(arg0, arg1) {
4166
+ arg0.binaryType = __wbindgen_enum_BinaryType[arg1];
4167
+ },
4168
+ __wbg_set_body_a3d856b097dfda04: function(arg0, arg1) {
4169
+ arg0.body = arg1;
4170
+ },
4171
+ __wbg_set_e09648bea3f1af1e: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
4172
+ arg0.set(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
4173
+ }, arguments); },
4174
+ __wbg_set_headers_3c8fecc693b75327: function(arg0, arg1) {
4175
+ arg0.headers = arg1;
4176
+ },
4177
+ __wbg_set_method_8c015e8bcafd7be1: function(arg0, arg1, arg2) {
4178
+ arg0.method = getStringFromWasm0(arg1, arg2);
4179
+ },
4180
+ __wbg_set_mode_5a87f2c809cf37c2: function(arg0, arg1) {
4181
+ arg0.mode = __wbindgen_enum_RequestMode[arg1];
4182
+ },
4183
+ __wbg_set_name_7ef37fe858379aaf: function(arg0, arg1, arg2) {
4184
+ arg0.name = getStringFromWasm0(arg1, arg2);
4185
+ },
4186
+ __wbg_set_onclose_8da801226bdd7a7b: function(arg0, arg1) {
4187
+ arg0.onclose = arg1;
4188
+ },
4189
+ __wbg_set_onerror_8a268cb237177bba: function(arg0, arg1) {
4190
+ arg0.onerror = arg1;
4191
+ },
4192
+ __wbg_set_onerror_901ca711f94a5bbb: function(arg0, arg1) {
4193
+ arg0.onerror = arg1;
4194
+ },
4195
+ __wbg_set_onmessage_284248c97c42cb93: function(arg0, arg1) {
4196
+ arg0.onmessage = arg1;
4197
+ },
4198
+ __wbg_set_onmessage_6f80ab771bf151aa: function(arg0, arg1) {
4199
+ arg0.onmessage = arg1;
4200
+ },
4201
+ __wbg_set_onopen_34e3e24cf9337ddd: function(arg0, arg1) {
4202
+ arg0.onopen = arg1;
4203
+ },
4204
+ __wbg_set_onsuccess_fca94ded107b64af: function(arg0, arg1) {
4205
+ arg0.onsuccess = arg1;
4206
+ },
4207
+ __wbg_set_onupgradeneeded_860ce42184f987e7: function(arg0, arg1) {
4208
+ arg0.onupgradeneeded = arg1;
4209
+ },
4210
+ __wbg_sign_a34d057afd14c54d: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
4211
+ const ret = arg0.sign(arg1, arg2, getArrayU8FromWasm0(arg3, arg4));
4212
+ return ret;
4213
+ }, arguments); },
4214
+ __wbg_sign_e6fa76bd4ef9c75a: function(arg0, arg1) {
4215
+ const ret = arg0.sign(arg1);
4216
+ return ret;
4217
+ },
4218
+ __wbg_signedfragment_new: function(arg0) {
4219
+ const ret = SignedFragment.__wrap(arg0);
4220
+ return ret;
4221
+ },
4222
+ __wbg_signedfragment_unwrap: function(arg0) {
4223
+ const ret = SignedFragment.__unwrap(arg0);
4224
+ return ret;
4225
+ },
4226
+ __wbg_signedloosecommit_new: function(arg0) {
4227
+ const ret = SignedLooseCommit.__wrap(arg0);
4228
+ return ret;
4229
+ },
4230
+ __wbg_signedloosecommit_unwrap: function(arg0) {
4231
+ const ret = SignedLooseCommit.__unwrap(arg0);
4232
+ return ret;
4233
+ },
4234
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
4235
+ const ret = arg1.stack;
4236
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
4237
+ const len1 = WASM_VECTOR_LEN;
4238
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
4239
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
4240
+ },
4241
+ __wbg_start_f837ba2bac4733b5: function(arg0) {
4242
+ arg0.start();
4243
+ },
4244
+ __wbg_static_accessor_GLOBAL_8adb955bd33fac2f: function() {
4245
+ const ret = typeof global === 'undefined' ? null : global;
4246
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4247
+ },
4248
+ __wbg_static_accessor_GLOBAL_THIS_ad356e0db91c7913: function() {
4249
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
4250
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4251
+ },
4252
+ __wbg_static_accessor_SELF_f207c857566db248: function() {
4253
+ const ret = typeof self === 'undefined' ? null : self;
4254
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4255
+ },
4256
+ __wbg_static_accessor_WINDOW_bb9f1ba69d61b386: function() {
4257
+ const ret = typeof window === 'undefined' ? null : window;
4258
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4259
+ },
4260
+ __wbg_status_318629ab93a22955: function(arg0) {
4261
+ const ret = arg0.status;
4262
+ return ret;
4263
+ },
4264
+ __wbg_subarray_a068d24e39478a8a: function(arg0, arg1, arg2) {
4265
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
4266
+ return ret;
4267
+ },
4268
+ __wbg_subduction_new: function(arg0) {
4269
+ const ret = Subduction.__wrap(arg0);
4270
+ return ret;
4271
+ },
4272
+ __wbg_subductionhttplongpoll_new: function(arg0) {
4273
+ const ret = SubductionHttpLongPoll.__wrap(arg0);
4274
+ return ret;
4275
+ },
4276
+ __wbg_subductionwebsocket_new: function(arg0) {
4277
+ const ret = SubductionWebSocket.__wrap(arg0);
4278
+ return ret;
4279
+ },
4280
+ __wbg_subtle_c060fa3eb5c6248d: function(arg0) {
4281
+ const ret = arg0.subtle;
4282
+ return ret;
4283
+ },
4284
+ __wbg_target_7bc90f314634b37b: function(arg0) {
4285
+ const ret = arg0.target;
4286
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4287
+ },
4288
+ __wbg_then_098abe61755d12f6: function(arg0, arg1) {
4289
+ const ret = arg0.then(arg1);
4290
+ return ret;
4291
+ },
4292
+ __wbg_then_9e335f6dd892bc11: function(arg0, arg1, arg2) {
4293
+ const ret = arg0.then(arg1, arg2);
4294
+ return ret;
4295
+ },
4296
+ __wbg_topic_new: function(arg0) {
4297
+ const ret = Topic.__wrap(arg0);
4298
+ return ret;
4299
+ },
4300
+ __wbg_topic_unwrap: function(arg0) {
4301
+ const ret = Topic.__unwrap(arg0);
4302
+ return ret;
4303
+ },
4304
+ __wbg_transaction_1309b463c399d2b3: function() { return handleError(function (arg0, arg1, arg2, arg3) {
4305
+ const ret = arg0.transaction(getStringFromWasm0(arg1, arg2), __wbindgen_enum_IdbTransactionMode[arg3]);
4306
+ return ret;
4307
+ }, arguments); },
4308
+ __wbg_transaction_2237af0233efbdf3: function() { return handleError(function (arg0, arg1, arg2) {
4309
+ const ret = arg0.transaction(getStringFromWasm0(arg1, arg2));
4310
+ return ret;
4311
+ }, arguments); },
4312
+ __wbg_tryIntoJsSedimentreeIdsArray_b07d2438a6f2a3b9: function() { return handleError(function (arg0, arg1) {
4313
+ const ret = tryIntoJsSedimentreeIdsArray(arg1);
4314
+ const ptr1 = passArrayJsValueToWasm0(ret, wasm.__wbindgen_export);
4315
+ const len1 = WASM_VECTOR_LEN;
4316
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
4317
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
4318
+ }, arguments); },
4319
+ __wbg_verifyingKey_28c38fc6525caed5: function(arg0) {
4320
+ const ret = arg0.verifyingKey();
4321
+ return ret;
4322
+ },
4323
+ __wbg_versions_276b2795b1c6a219: function(arg0) {
4324
+ const ret = arg0.versions;
4325
+ return ret;
4326
+ },
4327
+ __wbg_webcryptosigner_new: function(arg0) {
4328
+ const ret = WebCryptoSigner.__wrap(arg0);
4329
+ return ret;
4330
+ },
4331
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
4332
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 11, function: Function { arguments: [Externref], shim_idx: 12, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
4333
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_287, __wasm_bindgen_func_elem_639);
4334
+ return ret;
4335
+ },
4336
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
4337
+ // 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`.
4338
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_287, __wasm_bindgen_func_elem_639_1);
4339
+ return ret;
4340
+ },
4341
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
4342
+ // 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`.
4343
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_287, __wasm_bindgen_func_elem_639_2);
4344
+ return ret;
4345
+ },
4346
+ __wbindgen_cast_0000000000000004: function(arg0, arg1) {
4347
+ // 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`.
4348
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_287, __wasm_bindgen_func_elem_639_3);
4349
+ return ret;
4350
+ },
4351
+ __wbindgen_cast_0000000000000005: function(arg0, arg1) {
4352
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 11, function: Function { arguments: [], shim_idx: 13, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
4353
+ const ret = makeClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_287, __wasm_bindgen_func_elem_638);
4354
+ return ret;
4355
+ },
4356
+ __wbindgen_cast_0000000000000006: function(arg0, arg1) {
4357
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 677, function: Function { arguments: [Externref], shim_idx: 761, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
4358
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_287, __wasm_bindgen_func_elem_1652);
4359
+ return ret;
4360
+ },
4361
+ __wbindgen_cast_0000000000000007: function(arg0) {
4362
+ // Cast intrinsic for `F64 -> Externref`.
4363
+ const ret = arg0;
4364
+ return ret;
4365
+ },
4366
+ __wbindgen_cast_0000000000000008: function(arg0, arg1) {
4367
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
4368
+ const ret = getArrayU8FromWasm0(arg0, arg1);
4369
+ return ret;
4370
+ },
4371
+ __wbindgen_cast_0000000000000009: function(arg0, arg1) {
4372
+ // Cast intrinsic for `Ref(String) -> Externref`.
4373
+ const ret = getStringFromWasm0(arg0, arg1);
4374
+ return ret;
4375
+ },
4376
+ __wbindgen_cast_000000000000000a: function(arg0, arg1) {
4377
+ var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
4378
+ wasm.__wbindgen_export5(arg0, arg1 * 4, 4);
4379
+ // Cast intrinsic for `Vector(NamedExternref("Fragment")) -> Externref`.
4380
+ const ret = v0;
4381
+ return ret;
4382
+ },
4383
+ __wbindgen_cast_000000000000000b: function(arg0, arg1) {
4384
+ var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
4385
+ wasm.__wbindgen_export5(arg0, arg1 * 4, 4);
4386
+ // Cast intrinsic for `Vector(NamedExternref("LooseCommit")) -> Externref`.
4387
+ const ret = v0;
4388
+ return ret;
4389
+ },
4390
+ __wbindgen_cast_000000000000000c: function(arg0, arg1) {
4391
+ var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
4392
+ wasm.__wbindgen_export5(arg0, arg1 * 4, 4);
4393
+ // Cast intrinsic for `Vector(NamedExternref("PeerId")) -> Externref`.
4394
+ const ret = v0;
4395
+ return ret;
4396
+ },
4397
+ __wbindgen_cast_000000000000000d: function(arg0, arg1) {
4398
+ var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
4399
+ wasm.__wbindgen_export5(arg0, arg1 * 4, 4);
4400
+ // Cast intrinsic for `Vector(NamedExternref("SedimentreeId")) -> Externref`.
4401
+ const ret = v0;
4402
+ return ret;
4403
+ },
4404
+ __wbindgen_cast_000000000000000e: function(arg0, arg1) {
4405
+ var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
4406
+ wasm.__wbindgen_export5(arg0, arg1 * 4, 4);
4407
+ // Cast intrinsic for `Vector(NamedExternref("Uint8Array")) -> Externref`.
4408
+ const ret = v0;
4409
+ return ret;
4410
+ },
4411
+ __wbindgen_init_externref_table: function() {
4412
+ const table = wasm.__wbindgen_externrefs;
4413
+ const offset = table.grow(4);
4414
+ table.set(0, undefined);
4415
+ table.set(offset + 0, undefined);
4416
+ table.set(offset + 1, null);
4417
+ table.set(offset + 2, true);
4418
+ table.set(offset + 3, false);
4419
+ },
4420
+ };
4421
+ return {
4422
+ __proto__: null,
4423
+ "./subduction_wasm_bg.js": import0,
4424
+ "./snippets/subduction_wasm-ec51bcf335db35bd/inline0.js": import1,
4425
+ "./snippets/subduction_wasm-ec51bcf335db35bd/inline1.js": import2,
4426
+ };
4427
+ }
4428
+
4429
+ function __wasm_bindgen_func_elem_638(arg0, arg1) {
4430
+ wasm.__wasm_bindgen_func_elem_638(arg0, arg1);
4431
+ }
4432
+
4433
+ function __wasm_bindgen_func_elem_639(arg0, arg1, arg2) {
4434
+ wasm.__wasm_bindgen_func_elem_639(arg0, arg1, arg2);
4435
+ }
4436
+
4437
+ function __wasm_bindgen_func_elem_639_1(arg0, arg1, arg2) {
4438
+ wasm.__wasm_bindgen_func_elem_639_1(arg0, arg1, arg2);
4439
+ }
4440
+
4441
+ function __wasm_bindgen_func_elem_639_2(arg0, arg1, arg2) {
4442
+ wasm.__wasm_bindgen_func_elem_639_2(arg0, arg1, arg2);
4443
+ }
4444
+
4445
+ function __wasm_bindgen_func_elem_639_3(arg0, arg1, arg2) {
4446
+ wasm.__wasm_bindgen_func_elem_639_3(arg0, arg1, arg2);
4447
+ }
4448
+
4449
+ function __wasm_bindgen_func_elem_1652(arg0, arg1, arg2) {
4450
+ const ret = wasm.__wasm_bindgen_func_elem_1652(arg0, arg1, arg2);
4451
+ if (ret[1]) {
4452
+ throw takeFromExternrefTable0(ret[0]);
4453
+ }
4454
+ }
4455
+
4456
+ function __wasm_bindgen_func_elem_1652_195(arg0, arg1, arg2, arg3) {
4457
+ wasm.__wasm_bindgen_func_elem_1652_195(arg0, arg1, arg2, arg3);
4458
+ }
4459
+
4460
+ function __wasm_bindgen_func_elem_1652_196(arg0, arg1, arg2, arg3) {
4461
+ wasm.__wasm_bindgen_func_elem_1652_196(arg0, arg1, arg2, arg3);
4462
+ }
4463
+
4464
+
4465
+ const __wbindgen_enum_BinaryType = ["blob", "arraybuffer"];
4466
+
4467
+
4468
+ const __wbindgen_enum_IdbTransactionMode = ["readonly", "readwrite", "versionchange", "readwriteflush", "cleanup"];
4469
+
4470
+
4471
+ const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"];
4472
+ const MemorySignerFinalization = (typeof FinalizationRegistry === 'undefined')
4473
+ ? { register: () => {}, unregister: () => {} }
4474
+ : new FinalizationRegistry(ptr => wasm.__wbg_memorysigner_free(ptr >>> 0, 1));
4475
+ const MemoryStorageFinalization = (typeof FinalizationRegistry === 'undefined')
4476
+ ? { register: () => {}, unregister: () => {} }
4477
+ : new FinalizationRegistry(ptr => wasm.__wbg_memorystorage_free(ptr >>> 0, 1));
4478
+ const PeerBatchSyncResultFinalization = (typeof FinalizationRegistry === 'undefined')
4479
+ ? { register: () => {}, unregister: () => {} }
4480
+ : new FinalizationRegistry(ptr => wasm.__wbg_peerbatchsyncresult_free(ptr >>> 0, 1));
4481
+ const AuthenticatedLongPollFinalization = (typeof FinalizationRegistry === 'undefined')
4482
+ ? { register: () => {}, unregister: () => {} }
4483
+ : new FinalizationRegistry(ptr => wasm.__wbg_authenticatedlongpoll_free(ptr >>> 0, 1));
4484
+ const AuthenticatedTransportFinalization = (typeof FinalizationRegistry === 'undefined')
4485
+ ? { register: () => {}, unregister: () => {} }
4486
+ : new FinalizationRegistry(ptr => wasm.__wbg_authenticatedtransport_free(ptr >>> 0, 1));
4487
+ const AuthenticatedWebSocketFinalization = (typeof FinalizationRegistry === 'undefined')
4488
+ ? { register: () => {}, unregister: () => {} }
4489
+ : new FinalizationRegistry(ptr => wasm.__wbg_authenticatedwebsocket_free(ptr >>> 0, 1));
4490
+ const BatchSyncRequestFinalization = (typeof FinalizationRegistry === 'undefined')
4491
+ ? { register: () => {}, unregister: () => {} }
4492
+ : new FinalizationRegistry(ptr => wasm.__wbg_batchsyncrequest_free(ptr >>> 0, 1));
4493
+ const BatchSyncResponseFinalization = (typeof FinalizationRegistry === 'undefined')
4494
+ ? { register: () => {}, unregister: () => {} }
4495
+ : new FinalizationRegistry(ptr => wasm.__wbg_batchsyncresponse_free(ptr >>> 0, 1));
4496
+ const BlobMetaFinalization = (typeof FinalizationRegistry === 'undefined')
4497
+ ? { register: () => {}, unregister: () => {} }
4498
+ : new FinalizationRegistry(ptr => wasm.__wbg_blobmeta_free(ptr >>> 0, 1));
4499
+ const CallErrorFinalization = (typeof FinalizationRegistry === 'undefined')
4500
+ ? { register: () => {}, unregister: () => {} }
4501
+ : new FinalizationRegistry(ptr => wasm.__wbg_callerror_free(ptr >>> 0, 1));
4502
+ const CommitWithBlobFinalization = (typeof FinalizationRegistry === 'undefined')
4503
+ ? { register: () => {}, unregister: () => {} }
4504
+ : new FinalizationRegistry(ptr => wasm.__wbg_commitwithblob_free(ptr >>> 0, 1));
4505
+ const DepthFinalization = (typeof FinalizationRegistry === 'undefined')
4506
+ ? { register: () => {}, unregister: () => {} }
4507
+ : new FinalizationRegistry(ptr => wasm.__wbg_depth_free(ptr >>> 0, 1));
4508
+ const DigestFinalization = (typeof FinalizationRegistry === 'undefined')
4509
+ ? { register: () => {}, unregister: () => {} }
4510
+ : new FinalizationRegistry(ptr => wasm.__wbg_digest_free(ptr >>> 0, 1));
4511
+ const FragmentFinalization = (typeof FinalizationRegistry === 'undefined')
4512
+ ? { register: () => {}, unregister: () => {} }
4513
+ : new FinalizationRegistry(ptr => wasm.__wbg_fragment_free(ptr >>> 0, 1));
4514
+ const FragmentRequestedFinalization = (typeof FinalizationRegistry === 'undefined')
4515
+ ? { register: () => {}, unregister: () => {} }
4516
+ : new FinalizationRegistry(ptr => wasm.__wbg_fragmentrequested_free(ptr >>> 0, 1));
4517
+ const FragmentWithBlobFinalization = (typeof FinalizationRegistry === 'undefined')
4518
+ ? { register: () => {}, unregister: () => {} }
4519
+ : new FinalizationRegistry(ptr => wasm.__wbg_fragmentwithblob_free(ptr >>> 0, 1));
4520
+ const FragmentsArrayFinalization = (typeof FinalizationRegistry === 'undefined')
4521
+ ? { register: () => {}, unregister: () => {} }
4522
+ : new FinalizationRegistry(ptr => wasm.__wbg_fragmentsarray_free(ptr >>> 0, 1));
4523
+ const HashMetricFinalization = (typeof FinalizationRegistry === 'undefined')
4524
+ ? { register: () => {}, unregister: () => {} }
4525
+ : new FinalizationRegistry(ptr => wasm.__wbg_hashmetric_free(ptr >>> 0, 1));
4526
+ const SubductionHttpLongPollFinalization = (typeof FinalizationRegistry === 'undefined')
4527
+ ? { register: () => {}, unregister: () => {} }
4528
+ : new FinalizationRegistry(ptr => wasm.__wbg_subductionhttplongpoll_free(ptr >>> 0, 1));
4529
+ const SubductionLongPollFinalization = (typeof FinalizationRegistry === 'undefined')
4530
+ ? { register: () => {}, unregister: () => {} }
4531
+ : new FinalizationRegistry(ptr => wasm.__wbg_subductionlongpoll_free(ptr >>> 0, 1));
4532
+ const LooseCommitFinalization = (typeof FinalizationRegistry === 'undefined')
4533
+ ? { register: () => {}, unregister: () => {} }
4534
+ : new FinalizationRegistry(ptr => wasm.__wbg_loosecommit_free(ptr >>> 0, 1));
4535
+ const SyncMessageFinalization = (typeof FinalizationRegistry === 'undefined')
4536
+ ? { register: () => {}, unregister: () => {} }
4537
+ : new FinalizationRegistry(ptr => wasm.__wbg_syncmessage_free(ptr >>> 0, 1));
4538
+ const MessagePortTransportFinalization = (typeof FinalizationRegistry === 'undefined')
4539
+ ? { register: () => {}, unregister: () => {} }
4540
+ : new FinalizationRegistry(ptr => wasm.__wbg_messageporttransport_free(ptr >>> 0, 1));
4541
+ const NonceFinalization = (typeof FinalizationRegistry === 'undefined')
4542
+ ? { register: () => {}, unregister: () => {} }
4543
+ : new FinalizationRegistry(ptr => wasm.__wbg_nonce_free(ptr >>> 0, 1));
4544
+ const PeerIdFinalization = (typeof FinalizationRegistry === 'undefined')
4545
+ ? { register: () => {}, unregister: () => {} }
4546
+ : new FinalizationRegistry(ptr => wasm.__wbg_peerid_free(ptr >>> 0, 1));
4547
+ const PeerResultMapFinalization = (typeof FinalizationRegistry === 'undefined')
4548
+ ? { register: () => {}, unregister: () => {} }
4549
+ : new FinalizationRegistry(ptr => wasm.__wbg_peerresultmap_free(ptr >>> 0, 1));
4550
+ const RequestIdFinalization = (typeof FinalizationRegistry === 'undefined')
4551
+ ? { register: () => {}, unregister: () => {} }
4552
+ : new FinalizationRegistry(ptr => wasm.__wbg_requestid_free(ptr >>> 0, 1));
4553
+ const SedimentreeFinalization = (typeof FinalizationRegistry === 'undefined')
4554
+ ? { register: () => {}, unregister: () => {} }
4555
+ : new FinalizationRegistry(ptr => wasm.__wbg_sedimentree_free(ptr >>> 0, 1));
4556
+ const SedimentreeIdFinalization = (typeof FinalizationRegistry === 'undefined')
4557
+ ? { register: () => {}, unregister: () => {} }
4558
+ : new FinalizationRegistry(ptr => wasm.__wbg_sedimentreeid_free(ptr >>> 0, 1));
4559
+ const SedimentreeIdsArrayFinalization = (typeof FinalizationRegistry === 'undefined')
4560
+ ? { register: () => {}, unregister: () => {} }
4561
+ : new FinalizationRegistry(ptr => wasm.__wbg_sedimentreeidsarray_free(ptr >>> 0, 1));
4562
+ const SignedFragmentFinalization = (typeof FinalizationRegistry === 'undefined')
4563
+ ? { register: () => {}, unregister: () => {} }
4564
+ : new FinalizationRegistry(ptr => wasm.__wbg_signedfragment_free(ptr >>> 0, 1));
4565
+ const SignedLooseCommitFinalization = (typeof FinalizationRegistry === 'undefined')
4566
+ ? { register: () => {}, unregister: () => {} }
4567
+ : new FinalizationRegistry(ptr => wasm.__wbg_signedloosecommit_free(ptr >>> 0, 1));
4568
+ const SubductionFinalization = (typeof FinalizationRegistry === 'undefined')
4569
+ ? { register: () => {}, unregister: () => {} }
4570
+ : new FinalizationRegistry(ptr => wasm.__wbg_subduction_free(ptr >>> 0, 1));
4571
+ const SyncStatsFinalization = (typeof FinalizationRegistry === 'undefined')
4572
+ ? { register: () => {}, unregister: () => {} }
4573
+ : new FinalizationRegistry(ptr => wasm.__wbg_syncstats_free(ptr >>> 0, 1));
4574
+ const TopicFinalization = (typeof FinalizationRegistry === 'undefined')
4575
+ ? { register: () => {}, unregister: () => {} }
4576
+ : new FinalizationRegistry(ptr => wasm.__wbg_topic_free(ptr >>> 0, 1));
4577
+ const SubductionWebSocketFinalization = (typeof FinalizationRegistry === 'undefined')
4578
+ ? { register: () => {}, unregister: () => {} }
4579
+ : new FinalizationRegistry(ptr => wasm.__wbg_subductionwebsocket_free(ptr >>> 0, 1));
4580
+ const WebCryptoSignerFinalization = (typeof FinalizationRegistry === 'undefined')
4581
+ ? { register: () => {}, unregister: () => {} }
4582
+ : new FinalizationRegistry(ptr => wasm.__wbg_webcryptosigner_free(ptr >>> 0, 1));
4583
+
4584
+ function addToExternrefTable0(obj) {
4585
+ const idx = wasm.__wbindgen_export4();
4586
+ wasm.__wbindgen_externrefs.set(idx, obj);
4587
+ return idx;
4588
+ }
4589
+
4590
+ function _assertClass(instance, klass) {
4591
+ if (!(instance instanceof klass)) {
4592
+ throw new Error(`expected instance of ${klass.name}`);
4593
+ }
4594
+ }
4595
+
4596
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
4597
+ ? { register: () => {}, unregister: () => {} }
4598
+ : new FinalizationRegistry(state => state.dtor(state.a, state.b));
4599
+
4600
+ function debugString(val) {
4601
+ // primitive types
4602
+ const type = typeof val;
4603
+ if (type == 'number' || type == 'boolean' || val == null) {
4604
+ return `${val}`;
4605
+ }
4606
+ if (type == 'string') {
4607
+ return `"${val}"`;
4608
+ }
4609
+ if (type == 'symbol') {
4610
+ const description = val.description;
4611
+ if (description == null) {
4612
+ return 'Symbol';
4613
+ } else {
4614
+ return `Symbol(${description})`;
4615
+ }
4616
+ }
4617
+ if (type == 'function') {
4618
+ const name = val.name;
4619
+ if (typeof name == 'string' && name.length > 0) {
4620
+ return `Function(${name})`;
4621
+ } else {
4622
+ return 'Function';
4623
+ }
4624
+ }
4625
+ // objects
4626
+ if (Array.isArray(val)) {
4627
+ const length = val.length;
4628
+ let debug = '[';
4629
+ if (length > 0) {
4630
+ debug += debugString(val[0]);
4631
+ }
4632
+ for(let i = 1; i < length; i++) {
4633
+ debug += ', ' + debugString(val[i]);
4634
+ }
4635
+ debug += ']';
4636
+ return debug;
4637
+ }
4638
+ // Test for built-in
4639
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
4640
+ let className;
4641
+ if (builtInMatches && builtInMatches.length > 1) {
4642
+ className = builtInMatches[1];
4643
+ } else {
4644
+ // Failed to match the standard '[object ClassName]'
4645
+ return toString.call(val);
4646
+ }
4647
+ if (className == 'Object') {
4648
+ // we're a user defined class or Object
4649
+ // JSON.stringify avoids problems with cycles, and is generally much
4650
+ // easier than looping through ownProperties of `val`.
4651
+ try {
4652
+ return 'Object(' + JSON.stringify(val) + ')';
4653
+ } catch (_) {
4654
+ return 'Object';
4655
+ }
4656
+ }
4657
+ // errors
4658
+ if (val instanceof Error) {
4659
+ return `${val.name}: ${val.message}\n${val.stack}`;
4660
+ }
4661
+ // TODO we could test for more things here, like `Set`s and `Map`s.
4662
+ return className;
4663
+ }
4664
+
4665
+ function getArrayJsValueFromWasm0(ptr, len) {
4666
+ ptr = ptr >>> 0;
4667
+ const mem = getDataViewMemory0();
4668
+ const result = [];
4669
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
4670
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
4671
+ }
4672
+ wasm.__wbindgen_export6(ptr, len);
4673
+ return result;
4674
+ }
4675
+
4676
+ function getArrayU8FromWasm0(ptr, len) {
4677
+ ptr = ptr >>> 0;
4678
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
4679
+ }
4680
+
4681
+ let cachedDataViewMemory0 = null;
4682
+ function getDataViewMemory0() {
4683
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
4684
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
4685
+ }
4686
+ return cachedDataViewMemory0;
4687
+ }
4688
+
4689
+ function getStringFromWasm0(ptr, len) {
4690
+ ptr = ptr >>> 0;
4691
+ return decodeText(ptr, len);
4692
+ }
4693
+
4694
+ let cachedUint8ArrayMemory0 = null;
4695
+ function getUint8ArrayMemory0() {
4696
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
4697
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
4698
+ }
4699
+ return cachedUint8ArrayMemory0;
4700
+ }
4701
+
4702
+ function handleError(f, args) {
4703
+ try {
4704
+ return f.apply(this, args);
4705
+ } catch (e) {
4706
+ const idx = addToExternrefTable0(e);
4707
+ wasm.__wbindgen_export3(idx);
4708
+ }
4709
+ }
4710
+
4711
+ function isLikeNone(x) {
4712
+ return x === undefined || x === null;
4713
+ }
4714
+
4715
+ function makeClosure(arg0, arg1, dtor, f) {
4716
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
4717
+ const real = (...args) => {
4718
+
4719
+ // First up with a closure we increment the internal reference
4720
+ // count. This ensures that the Rust closure environment won't
4721
+ // be deallocated while we're invoking it.
4722
+ state.cnt++;
4723
+ try {
4724
+ return f(state.a, state.b, ...args);
4725
+ } finally {
4726
+ real._wbg_cb_unref();
4727
+ }
4728
+ };
4729
+ real._wbg_cb_unref = () => {
4730
+ if (--state.cnt === 0) {
4731
+ state.dtor(state.a, state.b);
4732
+ state.a = 0;
4733
+ CLOSURE_DTORS.unregister(state);
4734
+ }
4735
+ };
4736
+ CLOSURE_DTORS.register(real, state, state);
4737
+ return real;
4738
+ }
4739
+
4740
+ function makeMutClosure(arg0, arg1, dtor, f) {
4741
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
4742
+ const real = (...args) => {
4743
+
4744
+ // First up with a closure we increment the internal reference
4745
+ // count. This ensures that the Rust closure environment won't
4746
+ // be deallocated while we're invoking it.
4747
+ state.cnt++;
4748
+ const a = state.a;
4749
+ state.a = 0;
4750
+ try {
4751
+ return f(a, state.b, ...args);
4752
+ } finally {
4753
+ state.a = a;
4754
+ real._wbg_cb_unref();
4755
+ }
4756
+ };
4757
+ real._wbg_cb_unref = () => {
4758
+ if (--state.cnt === 0) {
4759
+ state.dtor(state.a, state.b);
4760
+ state.a = 0;
4761
+ CLOSURE_DTORS.unregister(state);
4762
+ }
4763
+ };
4764
+ CLOSURE_DTORS.register(real, state, state);
4765
+ return real;
4766
+ }
4767
+
4768
+ function passArray8ToWasm0(arg, malloc) {
4769
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
4770
+ getUint8ArrayMemory0().set(arg, ptr / 1);
4771
+ WASM_VECTOR_LEN = arg.length;
4772
+ return ptr;
4773
+ }
4774
+
4775
+ function passArrayJsValueToWasm0(array, malloc) {
4776
+ const ptr = malloc(array.length * 4, 4) >>> 0;
4777
+ for (let i = 0; i < array.length; i++) {
4778
+ const add = addToExternrefTable0(array[i]);
4779
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
4780
+ }
4781
+ WASM_VECTOR_LEN = array.length;
4782
+ return ptr;
4783
+ }
4784
+
4785
+ function passStringToWasm0(arg, malloc, realloc) {
4786
+ if (realloc === undefined) {
4787
+ const buf = cachedTextEncoder.encode(arg);
4788
+ const ptr = malloc(buf.length, 1) >>> 0;
4789
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
4790
+ WASM_VECTOR_LEN = buf.length;
4791
+ return ptr;
4792
+ }
4793
+
4794
+ let len = arg.length;
4795
+ let ptr = malloc(len, 1) >>> 0;
4796
+
4797
+ const mem = getUint8ArrayMemory0();
4798
+
4799
+ let offset = 0;
4800
+
4801
+ for (; offset < len; offset++) {
4802
+ const code = arg.charCodeAt(offset);
4803
+ if (code > 0x7F) break;
4804
+ mem[ptr + offset] = code;
4805
+ }
4806
+ if (offset !== len) {
4807
+ if (offset !== 0) {
4808
+ arg = arg.slice(offset);
4809
+ }
4810
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
4811
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
4812
+ const ret = cachedTextEncoder.encodeInto(arg, view);
4813
+
4814
+ offset += ret.written;
4815
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
4816
+ }
4817
+
4818
+ WASM_VECTOR_LEN = offset;
4819
+ return ptr;
4820
+ }
4821
+
4822
+ function takeFromExternrefTable0(idx) {
4823
+ const value = wasm.__wbindgen_externrefs.get(idx);
4824
+ wasm.__wbindgen_export7(idx);
4825
+ return value;
4826
+ }
4827
+
4828
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
4829
+ cachedTextDecoder.decode();
4830
+ function decodeText(ptr, len) {
4831
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
4832
+ }
4833
+
4834
+ const cachedTextEncoder = new TextEncoder();
4835
+
4836
+ if (!('encodeInto' in cachedTextEncoder)) {
4837
+ cachedTextEncoder.encodeInto = function (arg, view) {
4838
+ const buf = cachedTextEncoder.encode(arg);
4839
+ view.set(buf);
4840
+ return {
4841
+ read: arg.length,
4842
+ written: buf.length
4843
+ };
4844
+ };
4845
+ }
4846
+
4847
+ let WASM_VECTOR_LEN = 0;
4848
+
4849
+ const wasmPath = `${__dirname}/subduction_wasm_bg.wasm`;
4850
+ const wasmBytes = require('fs').readFileSync(wasmPath);
4851
+ const wasmModule = new WebAssembly.Module(wasmBytes);
4852
+ let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
4853
+ wasm.__wbindgen_start();