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