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