@automerge/subduction 0.9.0 → 0.10.0

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