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