@siafoundation/sia-storage 0.0.8

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.
@@ -0,0 +1,1995 @@
1
+ /* @ts-self-types="./sia_storage_wasm.d.ts" */
2
+
3
+ /**
4
+ * An application key used for authentication with the indexer.
5
+ *
6
+ * AppKeys are derived from a BIP-39 recovery phrase during registration.
7
+ * They can be exported as a 32-byte seed and re-imported for future
8
+ * connections. The key must be stored securely — anyone with access
9
+ * can authenticate as the user.
10
+ */
11
+ export class AppKey {
12
+ static __wrap(ptr) {
13
+ ptr = ptr >>> 0;
14
+ const obj = Object.create(AppKey.prototype);
15
+ obj.__wbg_ptr = ptr;
16
+ AppKeyFinalization.register(obj, obj.__wbg_ptr, obj);
17
+ return obj;
18
+ }
19
+ __destroy_into_raw() {
20
+ const ptr = this.__wbg_ptr;
21
+ this.__wbg_ptr = 0;
22
+ AppKeyFinalization.unregister(this);
23
+ return ptr;
24
+ }
25
+ free() {
26
+ const ptr = this.__destroy_into_raw();
27
+ wasm.__wbg_appkey_free(ptr, 0);
28
+ }
29
+ /**
30
+ * Exports the AppKey as a 32-byte seed (Uint8Array).
31
+ * @returns {Uint8Array}
32
+ */
33
+ export() {
34
+ const ret = wasm.appkey_export(this.__wbg_ptr);
35
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
36
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
37
+ return v1;
38
+ }
39
+ /**
40
+ * Imports an AppKey from a 32-byte seed (Uint8Array).
41
+ * @param {Uint8Array} seed
42
+ */
43
+ constructor(seed) {
44
+ const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
45
+ const len0 = WASM_VECTOR_LEN;
46
+ const ret = wasm.appkey_new(ptr0, len0);
47
+ if (ret[2]) {
48
+ throw takeFromExternrefTable0(ret[1]);
49
+ }
50
+ this.__wbg_ptr = ret[0] >>> 0;
51
+ AppKeyFinalization.register(this, this.__wbg_ptr, this);
52
+ return this;
53
+ }
54
+ /**
55
+ * Returns the ed25519 public key as a string (e.g. "ed25519:abc123...").
56
+ * @returns {string}
57
+ */
58
+ publicKey() {
59
+ let deferred1_0;
60
+ let deferred1_1;
61
+ try {
62
+ const ret = wasm.appkey_publicKey(this.__wbg_ptr);
63
+ deferred1_0 = ret[0];
64
+ deferred1_1 = ret[1];
65
+ return getStringFromWasm0(ret[0], ret[1]);
66
+ } finally {
67
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
68
+ }
69
+ }
70
+ /**
71
+ * Signs a message and returns the 64-byte ed25519 signature (Uint8Array).
72
+ * @param {Uint8Array} message
73
+ * @returns {Uint8Array}
74
+ */
75
+ sign(message) {
76
+ const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
77
+ const len0 = WASM_VECTOR_LEN;
78
+ const ret = wasm.appkey_sign(this.__wbg_ptr, ptr0, len0);
79
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
80
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
81
+ return v2;
82
+ }
83
+ /**
84
+ * Verifies a signature for a given message.
85
+ * Returns true if the signature is valid.
86
+ * @param {Uint8Array} message
87
+ * @param {Uint8Array} signature
88
+ * @returns {boolean}
89
+ */
90
+ verifySignature(message, signature) {
91
+ const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
92
+ const len0 = WASM_VECTOR_LEN;
93
+ const ptr1 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
94
+ const len1 = WASM_VECTOR_LEN;
95
+ const ret = wasm.appkey_verifySignature(this.__wbg_ptr, ptr0, len0, ptr1, len1);
96
+ if (ret[2]) {
97
+ throw takeFromExternrefTable0(ret[1]);
98
+ }
99
+ return ret[0] !== 0;
100
+ }
101
+ }
102
+ if (Symbol.dispose) AppKey.prototype[Symbol.dispose] = AppKey.prototype.free;
103
+
104
+ /**
105
+ * SDK Builder — handles the connection and registration flow with an indexer.
106
+ */
107
+ export class Builder {
108
+ __destroy_into_raw() {
109
+ const ptr = this.__wbg_ptr;
110
+ this.__wbg_ptr = 0;
111
+ BuilderFinalization.unregister(this);
112
+ return ptr;
113
+ }
114
+ free() {
115
+ const ptr = this.__destroy_into_raw();
116
+ wasm.__wbg_builder_free(ptr, 0);
117
+ }
118
+ /**
119
+ * Attempts to connect using an existing AppKey.
120
+ * Returns a Sdk if the key is valid, or undefined if not registered.
121
+ * @param {AppKey} app_key
122
+ * @returns {Promise<Sdk | undefined>}
123
+ */
124
+ connected(app_key) {
125
+ _assertClass(app_key, AppKey);
126
+ const ret = wasm.builder_connected(this.__wbg_ptr, app_key.__wbg_ptr);
127
+ return ret;
128
+ }
129
+ /**
130
+ * @param {string} indexer_url
131
+ * @param {AppMetadata} app
132
+ */
133
+ constructor(indexer_url, app) {
134
+ const ptr0 = passStringToWasm0(indexer_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
135
+ const len0 = WASM_VECTOR_LEN;
136
+ const ret = wasm.builder_new(ptr0, len0, app);
137
+ if (ret[2]) {
138
+ throw takeFromExternrefTable0(ret[1]);
139
+ }
140
+ this.__wbg_ptr = ret[0] >>> 0;
141
+ BuilderFinalization.register(this, this.__wbg_ptr, this);
142
+ return this;
143
+ }
144
+ /**
145
+ * Completes registration and returns a Sdk instance.
146
+ * @param {string} mnemonic
147
+ * @returns {Promise<Sdk>}
148
+ */
149
+ register(mnemonic) {
150
+ const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
151
+ const len0 = WASM_VECTOR_LEN;
152
+ const ret = wasm.builder_register(this.__wbg_ptr, ptr0, len0);
153
+ return ret;
154
+ }
155
+ /**
156
+ * Requests connection approval from the indexer.
157
+ * @returns {Promise<void>}
158
+ */
159
+ requestConnection() {
160
+ const ret = wasm.builder_requestConnection(this.__wbg_ptr);
161
+ return ret;
162
+ }
163
+ /**
164
+ * Returns the approval URL the user must visit.
165
+ * @returns {string}
166
+ */
167
+ responseUrl() {
168
+ let deferred2_0;
169
+ let deferred2_1;
170
+ try {
171
+ const ret = wasm.builder_responseUrl(this.__wbg_ptr);
172
+ var ptr1 = ret[0];
173
+ var len1 = ret[1];
174
+ if (ret[3]) {
175
+ ptr1 = 0; len1 = 0;
176
+ throw takeFromExternrefTable0(ret[2]);
177
+ }
178
+ deferred2_0 = ptr1;
179
+ deferred2_1 = len1;
180
+ return getStringFromWasm0(ptr1, len1);
181
+ } finally {
182
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
183
+ }
184
+ }
185
+ /**
186
+ * Waits for the user to approve the connection request.
187
+ * @returns {Promise<void>}
188
+ */
189
+ waitForApproval() {
190
+ const ret = wasm.builder_waitForApproval(this.__wbg_ptr);
191
+ return ret;
192
+ }
193
+ }
194
+ if (Symbol.dispose) Builder.prototype[Symbol.dispose] = Builder.prototype.free;
195
+
196
+ export class IntoUnderlyingByteSource {
197
+ static __wrap(ptr) {
198
+ ptr = ptr >>> 0;
199
+ const obj = Object.create(IntoUnderlyingByteSource.prototype);
200
+ obj.__wbg_ptr = ptr;
201
+ IntoUnderlyingByteSourceFinalization.register(obj, obj.__wbg_ptr, obj);
202
+ return obj;
203
+ }
204
+ __destroy_into_raw() {
205
+ const ptr = this.__wbg_ptr;
206
+ this.__wbg_ptr = 0;
207
+ IntoUnderlyingByteSourceFinalization.unregister(this);
208
+ return ptr;
209
+ }
210
+ free() {
211
+ const ptr = this.__destroy_into_raw();
212
+ wasm.__wbg_intounderlyingbytesource_free(ptr, 0);
213
+ }
214
+ /**
215
+ * @returns {number}
216
+ */
217
+ get autoAllocateChunkSize() {
218
+ const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr);
219
+ return ret >>> 0;
220
+ }
221
+ cancel() {
222
+ const ptr = this.__destroy_into_raw();
223
+ wasm.intounderlyingbytesource_cancel(ptr);
224
+ }
225
+ /**
226
+ * @param {ReadableByteStreamController} controller
227
+ * @returns {Promise<any>}
228
+ */
229
+ pull(controller) {
230
+ const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, controller);
231
+ return ret;
232
+ }
233
+ /**
234
+ * @param {ReadableByteStreamController} controller
235
+ */
236
+ start(controller) {
237
+ wasm.intounderlyingbytesource_start(this.__wbg_ptr, controller);
238
+ }
239
+ /**
240
+ * @returns {ReadableStreamType}
241
+ */
242
+ get type() {
243
+ const ret = wasm.intounderlyingbytesource_type(this.__wbg_ptr);
244
+ return __wbindgen_enum_ReadableStreamType[ret];
245
+ }
246
+ }
247
+ if (Symbol.dispose) IntoUnderlyingByteSource.prototype[Symbol.dispose] = IntoUnderlyingByteSource.prototype.free;
248
+
249
+ export class IntoUnderlyingSink {
250
+ __destroy_into_raw() {
251
+ const ptr = this.__wbg_ptr;
252
+ this.__wbg_ptr = 0;
253
+ IntoUnderlyingSinkFinalization.unregister(this);
254
+ return ptr;
255
+ }
256
+ free() {
257
+ const ptr = this.__destroy_into_raw();
258
+ wasm.__wbg_intounderlyingsink_free(ptr, 0);
259
+ }
260
+ /**
261
+ * @param {any} reason
262
+ * @returns {Promise<any>}
263
+ */
264
+ abort(reason) {
265
+ const ptr = this.__destroy_into_raw();
266
+ const ret = wasm.intounderlyingsink_abort(ptr, reason);
267
+ return ret;
268
+ }
269
+ /**
270
+ * @returns {Promise<any>}
271
+ */
272
+ close() {
273
+ const ptr = this.__destroy_into_raw();
274
+ const ret = wasm.intounderlyingsink_close(ptr);
275
+ return ret;
276
+ }
277
+ /**
278
+ * @param {any} chunk
279
+ * @returns {Promise<any>}
280
+ */
281
+ write(chunk) {
282
+ const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, chunk);
283
+ return ret;
284
+ }
285
+ }
286
+ if (Symbol.dispose) IntoUnderlyingSink.prototype[Symbol.dispose] = IntoUnderlyingSink.prototype.free;
287
+
288
+ export class IntoUnderlyingSource {
289
+ __destroy_into_raw() {
290
+ const ptr = this.__wbg_ptr;
291
+ this.__wbg_ptr = 0;
292
+ IntoUnderlyingSourceFinalization.unregister(this);
293
+ return ptr;
294
+ }
295
+ free() {
296
+ const ptr = this.__destroy_into_raw();
297
+ wasm.__wbg_intounderlyingsource_free(ptr, 0);
298
+ }
299
+ cancel() {
300
+ const ptr = this.__destroy_into_raw();
301
+ wasm.intounderlyingsource_cancel(ptr);
302
+ }
303
+ /**
304
+ * @param {ReadableStreamDefaultController} controller
305
+ * @returns {Promise<any>}
306
+ */
307
+ pull(controller) {
308
+ const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, controller);
309
+ return ret;
310
+ }
311
+ }
312
+ if (Symbol.dispose) IntoUnderlyingSource.prototype[Symbol.dispose] = IntoUnderlyingSource.prototype.free;
313
+
314
+ /**
315
+ * An object event from the indexer.
316
+ */
317
+ export class ObjectEvent {
318
+ static __wrap(ptr) {
319
+ ptr = ptr >>> 0;
320
+ const obj = Object.create(ObjectEvent.prototype);
321
+ obj.__wbg_ptr = ptr;
322
+ ObjectEventFinalization.register(obj, obj.__wbg_ptr, obj);
323
+ return obj;
324
+ }
325
+ __destroy_into_raw() {
326
+ const ptr = this.__wbg_ptr;
327
+ this.__wbg_ptr = 0;
328
+ ObjectEventFinalization.unregister(this);
329
+ return ptr;
330
+ }
331
+ free() {
332
+ const ptr = this.__destroy_into_raw();
333
+ wasm.__wbg_objectevent_free(ptr, 0);
334
+ }
335
+ /**
336
+ * @returns {boolean}
337
+ */
338
+ get deleted() {
339
+ const ret = wasm.objectevent_deleted(this.__wbg_ptr);
340
+ return ret !== 0;
341
+ }
342
+ /**
343
+ * @returns {string}
344
+ */
345
+ get id() {
346
+ let deferred1_0;
347
+ let deferred1_1;
348
+ try {
349
+ const ret = wasm.objectevent_id(this.__wbg_ptr);
350
+ deferred1_0 = ret[0];
351
+ deferred1_1 = ret[1];
352
+ return getStringFromWasm0(ret[0], ret[1]);
353
+ } finally {
354
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
355
+ }
356
+ }
357
+ /**
358
+ * Returns the object associated with this event, if it exists.
359
+ * @returns {PinnedObject | undefined}
360
+ */
361
+ get object() {
362
+ const ret = wasm.objectevent_object(this.__wbg_ptr);
363
+ return ret === 0 ? undefined : PinnedObject.__wrap(ret);
364
+ }
365
+ /**
366
+ * Returns the time the event occurred.
367
+ * @returns {Date}
368
+ */
369
+ get updatedAt() {
370
+ const ret = wasm.objectevent_updatedAt(this.__wbg_ptr);
371
+ return ret;
372
+ }
373
+ }
374
+ if (Symbol.dispose) ObjectEvent.prototype[Symbol.dispose] = ObjectEvent.prototype.free;
375
+
376
+ /**
377
+ * A packed upload handle for efficiently uploading multiple objects
378
+ * together. Objects are packed into shared slabs to avoid wasting storage.
379
+ *
380
+ * ```js
381
+ * const packed = sdk.uploadPacked();
382
+ * await packed.add(file1.stream());
383
+ * await packed.add(file2.stream());
384
+ * const objects = await packed.finalize();
385
+ * for (const obj of objects) await sdk.pinObject(obj);
386
+ * ```
387
+ */
388
+ export class PackedUpload {
389
+ static __wrap(ptr) {
390
+ ptr = ptr >>> 0;
391
+ const obj = Object.create(PackedUpload.prototype);
392
+ obj.__wbg_ptr = ptr;
393
+ PackedUploadFinalization.register(obj, obj.__wbg_ptr, obj);
394
+ return obj;
395
+ }
396
+ __destroy_into_raw() {
397
+ const ptr = this.__wbg_ptr;
398
+ this.__wbg_ptr = 0;
399
+ PackedUploadFinalization.unregister(this);
400
+ return ptr;
401
+ }
402
+ free() {
403
+ const ptr = this.__destroy_into_raw();
404
+ wasm.__wbg_packedupload_free(ptr, 0);
405
+ }
406
+ /**
407
+ * Adds an object to the packed upload. Returns the number of bytes written.
408
+ *
409
+ * ```js
410
+ * const packed = sdk.uploadPacked();
411
+ * await packed.add(file.stream());
412
+ * await packed.add(blob.stream());
413
+ * ```
414
+ * @param {ReadableStream} stream
415
+ * @returns {Promise<number>}
416
+ */
417
+ add(stream) {
418
+ const ret = wasm.packedupload_add(this.__wbg_ptr, stream);
419
+ return ret;
420
+ }
421
+ /**
422
+ * Cancels the packed upload. Immediately interrupts any in-flight `add`
423
+ * and aborts all pending slab uploads.
424
+ */
425
+ cancel() {
426
+ wasm.packedupload_cancel(this.__wbg_ptr);
427
+ }
428
+ /**
429
+ * Finalizes the packed upload and returns the resulting objects.
430
+ * Each object must be pinned separately with `sdk.pinObject()`.
431
+ * @returns {Promise<PinnedObject[]>}
432
+ */
433
+ finalize() {
434
+ const ptr = this.__destroy_into_raw();
435
+ const ret = wasm.packedupload_finalize(ptr);
436
+ return ret;
437
+ }
438
+ /**
439
+ * Total bytes added so far across all objects.
440
+ * @returns {number}
441
+ */
442
+ length() {
443
+ const ret = wasm.packedupload_length(this.__wbg_ptr);
444
+ return ret;
445
+ }
446
+ /**
447
+ * Bytes remaining until the current slab is full. Adding objects that
448
+ * fit within this size avoids starting a new slab and minimizes padding.
449
+ * @returns {number}
450
+ */
451
+ remaining() {
452
+ const ret = wasm.packedupload_remaining(this.__wbg_ptr);
453
+ return ret;
454
+ }
455
+ /**
456
+ * Optimal size of each slab in bytes.
457
+ * @returns {number}
458
+ */
459
+ slabSize() {
460
+ const ret = wasm.packedupload_slabSize(this.__wbg_ptr);
461
+ return ret;
462
+ }
463
+ /**
464
+ * Number of slabs in the upload.
465
+ * @returns {number}
466
+ */
467
+ slabs() {
468
+ const ret = wasm.packedupload_slabs(this.__wbg_ptr);
469
+ return ret;
470
+ }
471
+ }
472
+ if (Symbol.dispose) PackedUpload.prototype[Symbol.dispose] = PackedUpload.prototype.free;
473
+
474
+ /**
475
+ * An object stored on the Sia network. JS holds this as an opaque handle
476
+ * and passes it back to Rust for operations like pin, download, share, and
477
+ * metadata updates. The internal state (encryption keys, slab data) cannot
478
+ * be serialized to JS.
479
+ */
480
+ export class PinnedObject {
481
+ static __wrap(ptr) {
482
+ ptr = ptr >>> 0;
483
+ const obj = Object.create(PinnedObject.prototype);
484
+ obj.__wbg_ptr = ptr;
485
+ PinnedObjectFinalization.register(obj, obj.__wbg_ptr, obj);
486
+ return obj;
487
+ }
488
+ __destroy_into_raw() {
489
+ const ptr = this.__wbg_ptr;
490
+ this.__wbg_ptr = 0;
491
+ PinnedObjectFinalization.unregister(this);
492
+ return ptr;
493
+ }
494
+ free() {
495
+ const ptr = this.__destroy_into_raw();
496
+ wasm.__wbg_pinnedobject_free(ptr, 0);
497
+ }
498
+ /**
499
+ * Returns the creation time.
500
+ * @returns {Date}
501
+ */
502
+ createdAt() {
503
+ const ret = wasm.pinnedobject_createdAt(this.__wbg_ptr);
504
+ return ret;
505
+ }
506
+ /**
507
+ * Returns the encoded (on-network) size after erasure coding.
508
+ * @returns {number}
509
+ */
510
+ encodedSize() {
511
+ const ret = wasm.pinnedobject_encodedSize(this.__wbg_ptr);
512
+ return ret;
513
+ }
514
+ /**
515
+ * Returns the object's ID as a hex string.
516
+ * @returns {string}
517
+ */
518
+ id() {
519
+ let deferred1_0;
520
+ let deferred1_1;
521
+ try {
522
+ const ret = wasm.pinnedobject_id(this.__wbg_ptr);
523
+ deferred1_0 = ret[0];
524
+ deferred1_1 = ret[1];
525
+ return getStringFromWasm0(ret[0], ret[1]);
526
+ } finally {
527
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
528
+ }
529
+ }
530
+ /**
531
+ * Returns the object's metadata as raw bytes.
532
+ * @returns {Uint8Array}
533
+ */
534
+ metadata() {
535
+ const ret = wasm.pinnedobject_metadata(this.__wbg_ptr);
536
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
537
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
538
+ return v1;
539
+ }
540
+ /**
541
+ * Creates a new empty object.
542
+ */
543
+ constructor() {
544
+ const ret = wasm.pinnedobject_new();
545
+ this.__wbg_ptr = ret >>> 0;
546
+ PinnedObjectFinalization.register(this, this.__wbg_ptr, this);
547
+ return this;
548
+ }
549
+ /**
550
+ * Opens a previously sealed object.
551
+ * @param {AppKey} app_key
552
+ * @param {SealedObject} sealed_obj
553
+ * @returns {PinnedObject}
554
+ */
555
+ static open(app_key, sealed_obj) {
556
+ _assertClass(app_key, AppKey);
557
+ const ret = wasm.pinnedobject_open(app_key.__wbg_ptr, sealed_obj);
558
+ if (ret[2]) {
559
+ throw takeFromExternrefTable0(ret[1]);
560
+ }
561
+ return PinnedObject.__wrap(ret[0]);
562
+ }
563
+ /**
564
+ * Seals the object for offline storage.
565
+ * @param {AppKey} app_key
566
+ * @returns {SealedObject}
567
+ */
568
+ seal(app_key) {
569
+ _assertClass(app_key, AppKey);
570
+ const ret = wasm.pinnedobject_seal(this.__wbg_ptr, app_key.__wbg_ptr);
571
+ return ret;
572
+ }
573
+ /**
574
+ * Returns the total size of the object in bytes.
575
+ * @returns {number}
576
+ */
577
+ size() {
578
+ const ret = wasm.pinnedobject_size(this.__wbg_ptr);
579
+ return ret;
580
+ }
581
+ /**
582
+ * Returns the slabs that make up the object.
583
+ * @returns {Slab[]}
584
+ */
585
+ slabs() {
586
+ const ret = wasm.pinnedobject_slabs(this.__wbg_ptr);
587
+ if (ret[2]) {
588
+ throw takeFromExternrefTable0(ret[1]);
589
+ }
590
+ return takeFromExternrefTable0(ret[0]);
591
+ }
592
+ /**
593
+ * Updates the object's metadata.
594
+ * @param {Uint8Array} metadata
595
+ */
596
+ updateMetadata(metadata) {
597
+ const ptr0 = passArray8ToWasm0(metadata, wasm.__wbindgen_malloc);
598
+ const len0 = WASM_VECTOR_LEN;
599
+ wasm.pinnedobject_updateMetadata(this.__wbg_ptr, ptr0, len0);
600
+ }
601
+ /**
602
+ * Returns the last updated time.
603
+ * @returns {Date}
604
+ */
605
+ updatedAt() {
606
+ const ret = wasm.pinnedobject_updatedAt(this.__wbg_ptr);
607
+ return ret;
608
+ }
609
+ }
610
+ if (Symbol.dispose) PinnedObject.prototype[Symbol.dispose] = PinnedObject.prototype.free;
611
+
612
+ /**
613
+ * The main Sia storage SDK. Provides methods for uploading, downloading,
614
+ * and managing objects on the Sia storage network via an indexer.
615
+ */
616
+ export class Sdk {
617
+ static __wrap(ptr) {
618
+ ptr = ptr >>> 0;
619
+ const obj = Object.create(Sdk.prototype);
620
+ obj.__wbg_ptr = ptr;
621
+ SdkFinalization.register(obj, obj.__wbg_ptr, obj);
622
+ return obj;
623
+ }
624
+ __destroy_into_raw() {
625
+ const ptr = this.__wbg_ptr;
626
+ this.__wbg_ptr = 0;
627
+ SdkFinalization.unregister(this);
628
+ return ptr;
629
+ }
630
+ free() {
631
+ const ptr = this.__destroy_into_raw();
632
+ wasm.__wbg_sdk_free(ptr, 0);
633
+ }
634
+ /**
635
+ * Returns account information from the indexer.
636
+ * @returns {Account}
637
+ */
638
+ account() {
639
+ const ret = wasm.sdk_account(this.__wbg_ptr);
640
+ return ret;
641
+ }
642
+ /**
643
+ * Returns the AppKey used by this SDK instance.
644
+ * @returns {AppKey}
645
+ */
646
+ appKey() {
647
+ const ret = wasm.sdk_appKey(this.__wbg_ptr);
648
+ return AppKey.__wrap(ret);
649
+ }
650
+ /**
651
+ * Deletes an object from the indexer by its hex ID.
652
+ * @param {string} key_hex
653
+ * @returns {Promise<void>}
654
+ */
655
+ deleteObject(key_hex) {
656
+ const ptr0 = passStringToWasm0(key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
657
+ const len0 = WASM_VECTOR_LEN;
658
+ const ret = wasm.sdk_deleteObject(this.__wbg_ptr, ptr0, len0);
659
+ return ret;
660
+ }
661
+ /**
662
+ * Downloads an object and returns a `ReadableStream` of `Uint8Array` chunks.
663
+ *
664
+ * ```js
665
+ * // as a blob
666
+ * const stream = sdk.download(obj);
667
+ * const blob = await new Response(stream).blob();
668
+ *
669
+ * // as a stream
670
+ * for await (const chunk of sdk.download(obj)) {
671
+ * console.log('got', chunk.length, 'bytes');
672
+ * }
673
+ * ```
674
+ * @param {PinnedObject} object
675
+ * @param {any | null} [options]
676
+ * @returns {ReadableStream}
677
+ */
678
+ download(object, options) {
679
+ _assertClass(object, PinnedObject);
680
+ const ret = wasm.sdk_download(this.__wbg_ptr, object.__wbg_ptr, isLikeNone(options) ? 0 : addToExternrefTable0(options));
681
+ if (ret[2]) {
682
+ throw takeFromExternrefTable0(ret[1]);
683
+ }
684
+ return takeFromExternrefTable0(ret[0]);
685
+ }
686
+ /**
687
+ * Returns a list of usable hosts, optionally filtered by a HostQuery.
688
+ * @param {HostQuery | null} [query]
689
+ * @returns {Host[]}
690
+ */
691
+ hosts(query) {
692
+ const ret = wasm.sdk_hosts(this.__wbg_ptr, isLikeNone(query) ? 0 : addToExternrefTable0(query));
693
+ return ret;
694
+ }
695
+ /**
696
+ * Retrieves an object from the indexer by its hex ID.
697
+ * Returns a `PinnedObject` handle for use with download, share, seal, etc.
698
+ * @param {string} key_hex
699
+ * @returns {Promise<PinnedObject>}
700
+ */
701
+ object(key_hex) {
702
+ const ptr0 = passStringToWasm0(key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
703
+ const len0 = WASM_VECTOR_LEN;
704
+ const ret = wasm.sdk_object(this.__wbg_ptr, ptr0, len0);
705
+ return ret;
706
+ }
707
+ /**
708
+ * Returns object events for syncing local state with the indexer.
709
+ * @param {ObjectsCursor | null | undefined} cursor
710
+ * @param {number} limit
711
+ * @returns {Promise<ObjectEvent[]>}
712
+ */
713
+ objectEvents(cursor, limit) {
714
+ const ret = wasm.sdk_objectEvents(this.__wbg_ptr, isLikeNone(cursor) ? 0 : addToExternrefTable0(cursor), limit);
715
+ return ret;
716
+ }
717
+ /**
718
+ * Pins an object to the indexer so it persists beyond temporary storage.
719
+ * @param {PinnedObject} object
720
+ * @returns {Promise<void>}
721
+ */
722
+ pinObject(object) {
723
+ _assertClass(object, PinnedObject);
724
+ const ret = wasm.sdk_pinObject(this.__wbg_ptr, object.__wbg_ptr);
725
+ return ret;
726
+ }
727
+ /**
728
+ * Prunes unused slabs from the indexer.
729
+ * @returns {Promise<void>}
730
+ */
731
+ pruneSlabs() {
732
+ const ret = wasm.sdk_pruneSlabs(this.__wbg_ptr);
733
+ return ret;
734
+ }
735
+ /**
736
+ * Generates a signed share URL for an object. Anyone with the URL can
737
+ * download and decrypt the object until `validUntil`.
738
+ * @param {PinnedObject} object
739
+ * @param {Date} valid_until
740
+ * @returns {string}
741
+ */
742
+ shareObject(object, valid_until) {
743
+ let deferred2_0;
744
+ let deferred2_1;
745
+ try {
746
+ _assertClass(object, PinnedObject);
747
+ const ret = wasm.sdk_shareObject(this.__wbg_ptr, object.__wbg_ptr, valid_until);
748
+ var ptr1 = ret[0];
749
+ var len1 = ret[1];
750
+ if (ret[3]) {
751
+ ptr1 = 0; len1 = 0;
752
+ throw takeFromExternrefTable0(ret[2]);
753
+ }
754
+ deferred2_0 = ptr1;
755
+ deferred2_1 = len1;
756
+ return getStringFromWasm0(ptr1, len1);
757
+ } finally {
758
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
759
+ }
760
+ }
761
+ /**
762
+ * Resolves a share URL (sia://...) and returns the shared object.
763
+ * The encryption key is extracted from the URL fragment (never sent
764
+ * to the indexer).
765
+ * @param {string} share_url
766
+ * @returns {Promise<PinnedObject>}
767
+ */
768
+ sharedObject(share_url) {
769
+ const ptr0 = passStringToWasm0(share_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
770
+ const len0 = WASM_VECTOR_LEN;
771
+ const ret = wasm.sdk_sharedObject(this.__wbg_ptr, ptr0, len0);
772
+ return ret;
773
+ }
774
+ /**
775
+ * Retrieves a pinned slab from the indexer by its hex ID.
776
+ * @param {string} slab_id
777
+ * @returns {PinnedSlab}
778
+ */
779
+ slab(slab_id) {
780
+ const ptr0 = passStringToWasm0(slab_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
781
+ const len0 = WASM_VECTOR_LEN;
782
+ const ret = wasm.sdk_slab(this.__wbg_ptr, ptr0, len0);
783
+ return ret;
784
+ }
785
+ /**
786
+ * Updates an object's metadata on the indexer.
787
+ * @param {PinnedObject} object
788
+ * @returns {Promise<void>}
789
+ */
790
+ updateObjectMetadata(object) {
791
+ _assertClass(object, PinnedObject);
792
+ const ret = wasm.sdk_updateObjectMetadata(this.__wbg_ptr, object.__wbg_ptr);
793
+ return ret;
794
+ }
795
+ /**
796
+ * Uploads data from a `ReadableStream` to the Sia network.
797
+ *
798
+ * Pass an existing `PinnedObject` to append new slabs to it, or `null`
799
+ * for a new upload. Appending changes the object's ID — the caller must
800
+ * re-pin and update any references to the old ID.
801
+ *
802
+ * ```js
803
+ * const obj = await sdk.upload(new PinnedObject(), file.stream());
804
+ * await sdk.pinObject(obj);
805
+ * ```
806
+ * @param {PinnedObject} object
807
+ * @param {ReadableStream} source
808
+ * @param {any | null} [options]
809
+ * @returns {Promise<PinnedObject>}
810
+ */
811
+ upload(object, source, options) {
812
+ _assertClass(object, PinnedObject);
813
+ var ptr0 = object.__destroy_into_raw();
814
+ const ret = wasm.sdk_upload(this.__wbg_ptr, ptr0, source, isLikeNone(options) ? 0 : addToExternrefTable0(options));
815
+ return ret;
816
+ }
817
+ /**
818
+ * Starts a packed upload for efficiently uploading multiple small objects.
819
+ * Objects smaller than the slab size (~40 MiB) are packed into shared slabs
820
+ * to avoid wasting storage. Call `add(data)` for each object, then
821
+ * `finalize()` to get the resulting `PinnedObject` handles.
822
+ * @param {any | null} [options]
823
+ * @returns {PackedUpload}
824
+ */
825
+ uploadPacked(options) {
826
+ const ret = wasm.sdk_uploadPacked(this.__wbg_ptr, isLikeNone(options) ? 0 : addToExternrefTable0(options));
827
+ if (ret[2]) {
828
+ throw takeFromExternrefTable0(ret[1]);
829
+ }
830
+ return PackedUpload.__wrap(ret[0]);
831
+ }
832
+ }
833
+ if (Symbol.dispose) Sdk.prototype[Symbol.dispose] = Sdk.prototype.free;
834
+
835
+ /**
836
+ * Calculates the encoded size of data after erasure coding.
837
+ * @param {number} data_size
838
+ * @param {number} data_shards
839
+ * @param {number} parity_shards
840
+ * @returns {number}
841
+ */
842
+ export function encodedSize(data_size, data_shards, parity_shards) {
843
+ const ret = wasm.encodedSize(data_size, data_shards, parity_shards);
844
+ return ret;
845
+ }
846
+
847
+ /**
848
+ * Generates a new BIP-39 12-word recovery phrase.
849
+ * @returns {string}
850
+ */
851
+ export function generateRecoveryPhrase() {
852
+ let deferred1_0;
853
+ let deferred1_1;
854
+ try {
855
+ const ret = wasm.generateRecoveryPhrase();
856
+ deferred1_0 = ret[0];
857
+ deferred1_1 = ret[1];
858
+ return getStringFromWasm0(ret[0], ret[1]);
859
+ } finally {
860
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
861
+ }
862
+ }
863
+
864
+ /**
865
+ * Set up panic hook and tokio runtime for browser use.
866
+ *
867
+ * Call `setLogger` to receive log messages.
868
+ */
869
+ export function init() {
870
+ wasm.init();
871
+ }
872
+
873
+ /**
874
+ * Sets a logging callback to receive log messages from the SDK.
875
+ *
876
+ * The callback receives formatted log messages as strings.
877
+ * `level` should be one of: "off", "error", "warn", "info", "debug", "trace".
878
+ * @param {(message: string) => void} callback
879
+ * @param {"off" | "error" | "warn" | "info" | "debug" | "trace"} level
880
+ */
881
+ export function setLogger(callback, level) {
882
+ wasm.setLogger(callback, level);
883
+ }
884
+
885
+ /**
886
+ * Validates a BIP-39 recovery phrase.
887
+ * @param {string} phrase
888
+ */
889
+ export function validateRecoveryPhrase(phrase) {
890
+ const ptr0 = passStringToWasm0(phrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
891
+ const len0 = WASM_VECTOR_LEN;
892
+ const ret = wasm.validateRecoveryPhrase(ptr0, len0);
893
+ if (ret[1]) {
894
+ throw takeFromExternrefTable0(ret[0]);
895
+ }
896
+ }
897
+ function __wbg_get_imports() {
898
+ const import0 = {
899
+ __proto__: null,
900
+ __wbg_Error_960c155d3d49e4c2: function(arg0, arg1) {
901
+ const ret = Error(getStringFromWasm0(arg0, arg1));
902
+ return ret;
903
+ },
904
+ __wbg_Number_32bf70a599af1d4b: function(arg0) {
905
+ const ret = Number(arg0);
906
+ return ret;
907
+ },
908
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
909
+ const ret = String(arg1);
910
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
911
+ const len1 = WASM_VECTOR_LEN;
912
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
913
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
914
+ },
915
+ __wbg_String_b51de6b05a10845b: function(arg0, arg1) {
916
+ const ret = String(arg1);
917
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
918
+ const len1 = WASM_VECTOR_LEN;
919
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
920
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
921
+ },
922
+ __wbg___wbindgen_bigint_get_as_i64_3d3aba5d616c6a51: function(arg0, arg1) {
923
+ const v = arg1;
924
+ const ret = typeof(v) === 'bigint' ? v : undefined;
925
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
926
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
927
+ },
928
+ __wbg___wbindgen_boolean_get_6ea149f0a8dcc5ff: function(arg0) {
929
+ const v = arg0;
930
+ const ret = typeof(v) === 'boolean' ? v : undefined;
931
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
932
+ },
933
+ __wbg___wbindgen_debug_string_ab4b34d23d6778bd: function(arg0, arg1) {
934
+ const ret = debugString(arg1);
935
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
936
+ const len1 = WASM_VECTOR_LEN;
937
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
938
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
939
+ },
940
+ __wbg___wbindgen_in_a5d8b22e52b24dd1: function(arg0, arg1) {
941
+ const ret = arg0 in arg1;
942
+ return ret;
943
+ },
944
+ __wbg___wbindgen_is_bigint_ec25c7f91b4d9e93: function(arg0) {
945
+ const ret = typeof(arg0) === 'bigint';
946
+ return ret;
947
+ },
948
+ __wbg___wbindgen_is_function_3baa9db1a987f47d: function(arg0) {
949
+ const ret = typeof(arg0) === 'function';
950
+ return ret;
951
+ },
952
+ __wbg___wbindgen_is_object_63322ec0cd6ea4ef: function(arg0) {
953
+ const val = arg0;
954
+ const ret = typeof(val) === 'object' && val !== null;
955
+ return ret;
956
+ },
957
+ __wbg___wbindgen_is_string_6df3bf7ef1164ed3: function(arg0) {
958
+ const ret = typeof(arg0) === 'string';
959
+ return ret;
960
+ },
961
+ __wbg___wbindgen_is_undefined_29a43b4d42920abd: function(arg0) {
962
+ const ret = arg0 === undefined;
963
+ return ret;
964
+ },
965
+ __wbg___wbindgen_jsval_eq_d3465d8a07697228: function(arg0, arg1) {
966
+ const ret = arg0 === arg1;
967
+ return ret;
968
+ },
969
+ __wbg___wbindgen_jsval_loose_eq_cac3565e89b4134c: function(arg0, arg1) {
970
+ const ret = arg0 == arg1;
971
+ return ret;
972
+ },
973
+ __wbg___wbindgen_number_get_c7f42aed0525c451: function(arg0, arg1) {
974
+ const obj = arg1;
975
+ const ret = typeof(obj) === 'number' ? obj : undefined;
976
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
977
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
978
+ },
979
+ __wbg___wbindgen_string_get_7ed5322991caaec5: function(arg0, arg1) {
980
+ const obj = arg1;
981
+ const ret = typeof(obj) === 'string' ? obj : undefined;
982
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
983
+ var len1 = WASM_VECTOR_LEN;
984
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
985
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
986
+ },
987
+ __wbg___wbindgen_throw_6b64449b9b9ed33c: function(arg0, arg1) {
988
+ throw new Error(getStringFromWasm0(arg0, arg1));
989
+ },
990
+ __wbg__wbg_cb_unref_b46c9b5a9f08ec37: function(arg0) {
991
+ arg0._wbg_cb_unref();
992
+ },
993
+ __wbg_abort_4ce5b484434ef6fd: function(arg0) {
994
+ arg0.abort();
995
+ },
996
+ __wbg_abort_d53712380a54cc81: function(arg0, arg1) {
997
+ arg0.abort(arg1);
998
+ },
999
+ __wbg_append_e8fc56ce7c00e874: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
1000
+ arg0.append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
1001
+ }, arguments); },
1002
+ __wbg_arrayBuffer_848c392b70c67d3d: function() { return handleError(function (arg0) {
1003
+ const ret = arg0.arrayBuffer();
1004
+ return ret;
1005
+ }, arguments); },
1006
+ __wbg_buffer_d0f5ea0926a691fd: function(arg0) {
1007
+ const ret = arg0.buffer;
1008
+ return ret;
1009
+ },
1010
+ __wbg_byobRequest_dc6aed9db01b12c6: function(arg0) {
1011
+ const ret = arg0.byobRequest;
1012
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1013
+ },
1014
+ __wbg_byteLength_3e660e5661f3327e: function(arg0) {
1015
+ const ret = arg0.byteLength;
1016
+ return ret;
1017
+ },
1018
+ __wbg_byteOffset_ecd62abe44dd28d4: function(arg0) {
1019
+ const ret = arg0.byteOffset;
1020
+ return ret;
1021
+ },
1022
+ __wbg_call_14b169f759b26747: function() { return handleError(function (arg0, arg1) {
1023
+ const ret = arg0.call(arg1);
1024
+ return ret;
1025
+ }, arguments); },
1026
+ __wbg_call_a24592a6f349a97e: function() { return handleError(function (arg0, arg1, arg2) {
1027
+ const ret = arg0.call(arg1, arg2);
1028
+ return ret;
1029
+ }, arguments); },
1030
+ __wbg_call_bb28efe6b2f55b86: function() { return handleError(function (arg0, arg1, arg2, arg3) {
1031
+ const ret = arg0.call(arg1, arg2, arg3);
1032
+ return ret;
1033
+ }, arguments); },
1034
+ __wbg_cancel_0fefd9f8b9d572b7: function(arg0) {
1035
+ const ret = arg0.cancel();
1036
+ return ret;
1037
+ },
1038
+ __wbg_catch_e9362815fd0b24cf: function(arg0, arg1) {
1039
+ const ret = arg0.catch(arg1);
1040
+ return ret;
1041
+ },
1042
+ __wbg_clearTimeout_6b8d9a38b9263d65: function(arg0) {
1043
+ const ret = clearTimeout(arg0);
1044
+ return ret;
1045
+ },
1046
+ __wbg_close_d67fbcab21f3394e: function(arg0) {
1047
+ arg0.close();
1048
+ },
1049
+ __wbg_close_e6c8977a002e9e13: function() { return handleError(function (arg0) {
1050
+ arg0.close();
1051
+ }, arguments); },
1052
+ __wbg_close_fb954dfaf67b5732: function() { return handleError(function (arg0) {
1053
+ arg0.close();
1054
+ }, arguments); },
1055
+ __wbg_createBidirectionalStream_ca9f0bbcf625e093: function(arg0) {
1056
+ const ret = arg0.createBidirectionalStream();
1057
+ return ret;
1058
+ },
1059
+ __wbg_crypto_48300657fced39f9: function(arg0) {
1060
+ const ret = arg0.crypto;
1061
+ return ret;
1062
+ },
1063
+ __wbg_done_58115a35ffd6a698: function(arg0) {
1064
+ const ret = arg0.done;
1065
+ return ret;
1066
+ },
1067
+ __wbg_done_9158f7cc8751ba32: function(arg0) {
1068
+ const ret = arg0.done;
1069
+ return ret;
1070
+ },
1071
+ __wbg_enqueue_4767ce322820c94d: function() { return handleError(function (arg0, arg1) {
1072
+ arg0.enqueue(arg1);
1073
+ }, arguments); },
1074
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
1075
+ let deferred0_0;
1076
+ let deferred0_1;
1077
+ try {
1078
+ deferred0_0 = arg0;
1079
+ deferred0_1 = arg1;
1080
+ console.error(getStringFromWasm0(arg0, arg1));
1081
+ } finally {
1082
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
1083
+ }
1084
+ },
1085
+ __wbg_fetch_0d322c0aed196b8b: function(arg0, arg1) {
1086
+ const ret = arg0.fetch(arg1);
1087
+ return ret;
1088
+ },
1089
+ __wbg_fetch_9dad4fe911207b37: function(arg0) {
1090
+ const ret = fetch(arg0);
1091
+ return ret;
1092
+ },
1093
+ __wbg_getRandomValues_263d0aa5464054ee: function() { return handleError(function (arg0, arg1) {
1094
+ arg0.getRandomValues(arg1);
1095
+ }, arguments); },
1096
+ __wbg_getRandomValues_76dfc69825c9c552: function() { return handleError(function (arg0, arg1) {
1097
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
1098
+ }, arguments); },
1099
+ __wbg_getReader_811d24fccad83740: function() { return handleError(function (arg0, arg1) {
1100
+ const ret = arg0.getReader(arg1);
1101
+ return ret;
1102
+ }, arguments); },
1103
+ __wbg_getReader_9094ac3b37a7d171: function(arg0) {
1104
+ const ret = arg0.getReader();
1105
+ return ret;
1106
+ },
1107
+ __wbg_getTime_da7c55f52b71e8c6: function(arg0) {
1108
+ const ret = arg0.getTime();
1109
+ return ret;
1110
+ },
1111
+ __wbg_getWriter_288dd368894e012f: function() { return handleError(function (arg0) {
1112
+ const ret = arg0.getWriter();
1113
+ return ret;
1114
+ }, arguments); },
1115
+ __wbg_get_1affdbdd5573b16a: function() { return handleError(function (arg0, arg1) {
1116
+ const ret = Reflect.get(arg0, arg1);
1117
+ return ret;
1118
+ }, arguments); },
1119
+ __wbg_get_6011fa3a58f61074: function() { return handleError(function (arg0, arg1) {
1120
+ const ret = Reflect.get(arg0, arg1);
1121
+ return ret;
1122
+ }, arguments); },
1123
+ __wbg_get_done_282bca5d3f90e0a8: function(arg0) {
1124
+ const ret = arg0.done;
1125
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
1126
+ },
1127
+ __wbg_get_unchecked_17f53dad852b9588: function(arg0, arg1) {
1128
+ const ret = arg0[arg1 >>> 0];
1129
+ return ret;
1130
+ },
1131
+ __wbg_get_value_65a7a2c60b42fd75: function(arg0) {
1132
+ const ret = arg0.value;
1133
+ return ret;
1134
+ },
1135
+ __wbg_get_with_ref_key_f64427178466f623: function(arg0, arg1) {
1136
+ const ret = arg0[arg1];
1137
+ return ret;
1138
+ },
1139
+ __wbg_has_880f1d472f7cecba: function() { return handleError(function (arg0, arg1) {
1140
+ const ret = Reflect.has(arg0, arg1);
1141
+ return ret;
1142
+ }, arguments); },
1143
+ __wbg_headers_6022deb4e576fb8e: function(arg0) {
1144
+ const ret = arg0.headers;
1145
+ return ret;
1146
+ },
1147
+ __wbg_instanceof_ArrayBuffer_7c8433c6ed14ffe3: function(arg0) {
1148
+ let result;
1149
+ try {
1150
+ result = arg0 instanceof ArrayBuffer;
1151
+ } catch (_) {
1152
+ result = false;
1153
+ }
1154
+ const ret = result;
1155
+ return ret;
1156
+ },
1157
+ __wbg_instanceof_Date_81b75f5ed36b30ea: function(arg0) {
1158
+ let result;
1159
+ try {
1160
+ result = arg0 instanceof Date;
1161
+ } catch (_) {
1162
+ result = false;
1163
+ }
1164
+ const ret = result;
1165
+ return ret;
1166
+ },
1167
+ __wbg_instanceof_Response_9b2d111407865ff2: function(arg0) {
1168
+ let result;
1169
+ try {
1170
+ result = arg0 instanceof Response;
1171
+ } catch (_) {
1172
+ result = false;
1173
+ }
1174
+ const ret = result;
1175
+ return ret;
1176
+ },
1177
+ __wbg_instanceof_Uint8Array_152ba1f289edcf3f: function(arg0) {
1178
+ let result;
1179
+ try {
1180
+ result = arg0 instanceof Uint8Array;
1181
+ } catch (_) {
1182
+ result = false;
1183
+ }
1184
+ const ret = result;
1185
+ return ret;
1186
+ },
1187
+ __wbg_isArray_c3109d14ffc06469: function(arg0) {
1188
+ const ret = Array.isArray(arg0);
1189
+ return ret;
1190
+ },
1191
+ __wbg_isSafeInteger_4fc213d1989d6d2a: function(arg0) {
1192
+ const ret = Number.isSafeInteger(arg0);
1193
+ return ret;
1194
+ },
1195
+ __wbg_iterator_013bc09ec998c2a7: function() {
1196
+ const ret = Symbol.iterator;
1197
+ return ret;
1198
+ },
1199
+ __wbg_length_3d4ecd04bd8d22f1: function(arg0) {
1200
+ const ret = arg0.length;
1201
+ return ret;
1202
+ },
1203
+ __wbg_length_9f1775224cf1d815: function(arg0) {
1204
+ const ret = arg0.length;
1205
+ return ret;
1206
+ },
1207
+ __wbg_msCrypto_8c6d45a75ef1d3da: function(arg0) {
1208
+ const ret = arg0.msCrypto;
1209
+ return ret;
1210
+ },
1211
+ __wbg_new_036bd6cd9cea9e73: function(arg0, arg1) {
1212
+ try {
1213
+ var state0 = {a: arg0, b: arg1};
1214
+ var cb0 = (arg0, arg1) => {
1215
+ const a = state0.a;
1216
+ state0.a = 0;
1217
+ try {
1218
+ return wasm_bindgen__convert__closures_____invoke__h29f5bd75867abdc1(a, state0.b, arg0, arg1);
1219
+ } finally {
1220
+ state0.a = a;
1221
+ }
1222
+ };
1223
+ const ret = new Promise(cb0);
1224
+ return ret;
1225
+ } finally {
1226
+ state0.a = 0;
1227
+ }
1228
+ },
1229
+ __wbg_new_0_4d657201ced14de3: function() {
1230
+ const ret = new Date();
1231
+ return ret;
1232
+ },
1233
+ __wbg_new_0c7403db6e782f19: function(arg0) {
1234
+ const ret = new Uint8Array(arg0);
1235
+ return ret;
1236
+ },
1237
+ __wbg_new_15a4889b4b90734d: function() { return handleError(function () {
1238
+ const ret = new Headers();
1239
+ return ret;
1240
+ }, arguments); },
1241
+ __wbg_new_227d7c05414eb861: function() {
1242
+ const ret = new Error();
1243
+ return ret;
1244
+ },
1245
+ __wbg_new_5e360d2ff7b9e1c3: function(arg0, arg1) {
1246
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
1247
+ return ret;
1248
+ },
1249
+ __wbg_new_682678e2f47e32bc: function() {
1250
+ const ret = new Array();
1251
+ return ret;
1252
+ },
1253
+ __wbg_new_7913666fe5070684: function(arg0) {
1254
+ const ret = new Date(arg0);
1255
+ return ret;
1256
+ },
1257
+ __wbg_new_98c22165a42231aa: function() { return handleError(function () {
1258
+ const ret = new AbortController();
1259
+ return ret;
1260
+ }, arguments); },
1261
+ __wbg_new_aa8d0fa9762c29bd: function() {
1262
+ const ret = new Object();
1263
+ return ret;
1264
+ },
1265
+ __wbg_new_from_slice_b5ea43e23f6008c0: function(arg0, arg1) {
1266
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
1267
+ return ret;
1268
+ },
1269
+ __wbg_new_typed_323f37fd55ab048d: function(arg0, arg1) {
1270
+ try {
1271
+ var state0 = {a: arg0, b: arg1};
1272
+ var cb0 = (arg0, arg1) => {
1273
+ const a = state0.a;
1274
+ state0.a = 0;
1275
+ try {
1276
+ return wasm_bindgen__convert__closures_____invoke__h29f5bd75867abdc1(a, state0.b, arg0, arg1);
1277
+ } finally {
1278
+ state0.a = a;
1279
+ }
1280
+ };
1281
+ const ret = new Promise(cb0);
1282
+ return ret;
1283
+ } finally {
1284
+ state0.a = 0;
1285
+ }
1286
+ },
1287
+ __wbg_new_with_byte_offset_and_length_01848e8d6a3d49ad: function(arg0, arg1, arg2) {
1288
+ const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
1289
+ return ret;
1290
+ },
1291
+ __wbg_new_with_into_underlying_byte_source_3d91ced279a72a85: function() { return handleError(function (arg0) {
1292
+ const ret = new ReadableStream(IntoUnderlyingByteSource.__wrap(arg0));
1293
+ return ret;
1294
+ }, arguments); },
1295
+ __wbg_new_with_length_8c854e41ea4dae9b: function(arg0) {
1296
+ const ret = new Uint8Array(arg0 >>> 0);
1297
+ return ret;
1298
+ },
1299
+ __wbg_new_with_options_50d51c89a750cdc0: function() { return handleError(function (arg0, arg1, arg2) {
1300
+ const ret = new WebTransport(getStringFromWasm0(arg0, arg1), arg2);
1301
+ return ret;
1302
+ }, arguments); },
1303
+ __wbg_new_with_str_and_init_897be1708e42f39d: function() { return handleError(function (arg0, arg1, arg2) {
1304
+ const ret = new Request(getStringFromWasm0(arg0, arg1), arg2);
1305
+ return ret;
1306
+ }, arguments); },
1307
+ __wbg_next_0340c4ae324393c3: function() { return handleError(function (arg0) {
1308
+ const ret = arg0.next();
1309
+ return ret;
1310
+ }, arguments); },
1311
+ __wbg_next_7646edaa39458ef7: function(arg0) {
1312
+ const ret = arg0.next;
1313
+ return ret;
1314
+ },
1315
+ __wbg_node_95beb7570492fd97: function(arg0) {
1316
+ const ret = arg0.node;
1317
+ return ret;
1318
+ },
1319
+ __wbg_now_36a3148ac47c4ad7: function(arg0) {
1320
+ const ret = arg0.now();
1321
+ return ret;
1322
+ },
1323
+ __wbg_now_e7c6795a7f81e10f: function(arg0) {
1324
+ const ret = arg0.now();
1325
+ return ret;
1326
+ },
1327
+ __wbg_objectevent_new: function(arg0) {
1328
+ const ret = ObjectEvent.__wrap(arg0);
1329
+ return ret;
1330
+ },
1331
+ __wbg_performance_3fcf6e32a7e1ed0a: function(arg0) {
1332
+ const ret = arg0.performance;
1333
+ return ret;
1334
+ },
1335
+ __wbg_pinnedobject_new: function(arg0) {
1336
+ const ret = PinnedObject.__wrap(arg0);
1337
+ return ret;
1338
+ },
1339
+ __wbg_process_b2fea42461d03994: function(arg0) {
1340
+ const ret = arg0.process;
1341
+ return ret;
1342
+ },
1343
+ __wbg_prototypesetcall_a6b02eb00b0f4ce2: function(arg0, arg1, arg2) {
1344
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1345
+ },
1346
+ __wbg_queueMicrotask_5d15a957e6aa920e: function(arg0) {
1347
+ queueMicrotask(arg0);
1348
+ },
1349
+ __wbg_queueMicrotask_f8819e5ffc402f36: function(arg0) {
1350
+ const ret = arg0.queueMicrotask;
1351
+ return ret;
1352
+ },
1353
+ __wbg_randomFillSync_ca9f178fb14c88cb: function() { return handleError(function (arg0, arg1) {
1354
+ arg0.randomFillSync(arg1);
1355
+ }, arguments); },
1356
+ __wbg_read_59292bbb2477ba34: function(arg0, arg1) {
1357
+ const ret = arg0.read(arg1);
1358
+ return ret;
1359
+ },
1360
+ __wbg_read_ddc2d178d2e57272: function(arg0) {
1361
+ const ret = arg0.read();
1362
+ return ret;
1363
+ },
1364
+ __wbg_readable_98f8ed088fcd6057: function(arg0) {
1365
+ const ret = arg0.readable;
1366
+ return ret;
1367
+ },
1368
+ __wbg_ready_487eb6c03d6e0cb3: function(arg0) {
1369
+ const ret = arg0.ready;
1370
+ return ret;
1371
+ },
1372
+ __wbg_releaseLock_38a8537ebe7067e2: function(arg0) {
1373
+ arg0.releaseLock();
1374
+ },
1375
+ __wbg_require_7a9419e39d796c95: function() { return handleError(function () {
1376
+ const ret = module.require;
1377
+ return ret;
1378
+ }, arguments); },
1379
+ __wbg_resolve_e6c466bc1052f16c: function(arg0) {
1380
+ const ret = Promise.resolve(arg0);
1381
+ return ret;
1382
+ },
1383
+ __wbg_respond_008ca9525ae22847: function() { return handleError(function (arg0, arg1) {
1384
+ arg0.respond(arg1 >>> 0);
1385
+ }, arguments); },
1386
+ __wbg_sdk_new: function(arg0) {
1387
+ const ret = Sdk.__wrap(arg0);
1388
+ return ret;
1389
+ },
1390
+ __wbg_setTimeout_f757f00851f76c42: function(arg0, arg1) {
1391
+ const ret = setTimeout(arg0, arg1);
1392
+ return ret;
1393
+ },
1394
+ __wbg_set_3bf1de9fab0cd644: function(arg0, arg1, arg2) {
1395
+ arg0[arg1 >>> 0] = arg2;
1396
+ },
1397
+ __wbg_set_3d484eb794afec82: function(arg0, arg1, arg2) {
1398
+ arg0.set(getArrayU8FromWasm0(arg1, arg2));
1399
+ },
1400
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
1401
+ arg0[arg1] = arg2;
1402
+ },
1403
+ __wbg_set_body_be11680f34217f75: function(arg0, arg1) {
1404
+ arg0.body = arg1;
1405
+ },
1406
+ __wbg_set_cache_968edea422613d1b: function(arg0, arg1) {
1407
+ arg0.cache = __wbindgen_enum_RequestCache[arg1];
1408
+ },
1409
+ __wbg_set_credentials_6577be90e0e85eb6: function(arg0, arg1) {
1410
+ arg0.credentials = __wbindgen_enum_RequestCredentials[arg1];
1411
+ },
1412
+ __wbg_set_f071dbb3bd088e0e: function(arg0, arg1, arg2) {
1413
+ arg0[arg1] = arg2;
1414
+ },
1415
+ __wbg_set_headers_50fc01786240a440: function(arg0, arg1) {
1416
+ arg0.headers = arg1;
1417
+ },
1418
+ __wbg_set_method_c9f1f985f6b6c427: function(arg0, arg1, arg2) {
1419
+ arg0.method = getStringFromWasm0(arg1, arg2);
1420
+ },
1421
+ __wbg_set_mode_5e08d503428c06b9: function(arg0, arg1) {
1422
+ arg0.mode = __wbindgen_enum_RequestMode[arg1];
1423
+ },
1424
+ __wbg_set_mode_8727fb062fc15677: function(arg0, arg1) {
1425
+ arg0.mode = __wbindgen_enum_ReadableStreamReaderMode[arg1];
1426
+ },
1427
+ __wbg_set_signal_1d4e73c2305a0e7c: function(arg0, arg1) {
1428
+ arg0.signal = arg1;
1429
+ },
1430
+ __wbg_signal_fdc54643b47bf85b: function(arg0) {
1431
+ const ret = arg0.signal;
1432
+ return ret;
1433
+ },
1434
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
1435
+ const ret = arg1.stack;
1436
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1437
+ const len1 = WASM_VECTOR_LEN;
1438
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1439
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1440
+ },
1441
+ __wbg_static_accessor_GLOBAL_8cfadc87a297ca02: function() {
1442
+ const ret = typeof global === 'undefined' ? null : global;
1443
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1444
+ },
1445
+ __wbg_static_accessor_GLOBAL_THIS_602256ae5c8f42cf: function() {
1446
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
1447
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1448
+ },
1449
+ __wbg_static_accessor_SELF_e445c1c7484aecc3: function() {
1450
+ const ret = typeof self === 'undefined' ? null : self;
1451
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1452
+ },
1453
+ __wbg_static_accessor_WINDOW_f20e8576ef1e0f17: function() {
1454
+ const ret = typeof window === 'undefined' ? null : window;
1455
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1456
+ },
1457
+ __wbg_status_43e0d2f15b22d69f: function(arg0) {
1458
+ const ret = arg0.status;
1459
+ return ret;
1460
+ },
1461
+ __wbg_stringify_91082ed7a5a5769e: function() { return handleError(function (arg0) {
1462
+ const ret = JSON.stringify(arg0);
1463
+ return ret;
1464
+ }, arguments); },
1465
+ __wbg_subarray_f8ca46a25b1f5e0d: function(arg0, arg1, arg2) {
1466
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
1467
+ return ret;
1468
+ },
1469
+ __wbg_text_595ef75535aa25c1: function() { return handleError(function (arg0) {
1470
+ const ret = arg0.text();
1471
+ return ret;
1472
+ }, arguments); },
1473
+ __wbg_then_792e0c862b060889: function(arg0, arg1, arg2) {
1474
+ const ret = arg0.then(arg1, arg2);
1475
+ return ret;
1476
+ },
1477
+ __wbg_then_8e16ee11f05e4827: function(arg0, arg1) {
1478
+ const ret = arg0.then(arg1);
1479
+ return ret;
1480
+ },
1481
+ __wbg_toString_306ed0b9f320c1ca: function(arg0) {
1482
+ const ret = arg0.toString();
1483
+ return ret;
1484
+ },
1485
+ __wbg_url_2bf741820e6563a0: function(arg0, arg1) {
1486
+ const ret = arg1.url;
1487
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1488
+ const len1 = WASM_VECTOR_LEN;
1489
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1490
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1491
+ },
1492
+ __wbg_value_b6a01ce6fe7cf2d7: function(arg0) {
1493
+ const ret = arg0.value;
1494
+ return ret;
1495
+ },
1496
+ __wbg_value_ee3a06f4579184fa: function(arg0) {
1497
+ const ret = arg0.value;
1498
+ return ret;
1499
+ },
1500
+ __wbg_versions_215a3ab1c9d5745a: function(arg0) {
1501
+ const ret = arg0.versions;
1502
+ return ret;
1503
+ },
1504
+ __wbg_view_701664ffb3b1ce67: function(arg0) {
1505
+ const ret = arg0.view;
1506
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1507
+ },
1508
+ __wbg_writable_d91c90e654ba5e7a: function(arg0) {
1509
+ const ret = arg0.writable;
1510
+ return ret;
1511
+ },
1512
+ __wbg_write_5cde8c29c0e594f9: function(arg0, arg1) {
1513
+ const ret = arg0.write(arg1);
1514
+ return ret;
1515
+ },
1516
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1517
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1126, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1518
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h0c753f5de41a6544);
1519
+ return ret;
1520
+ },
1521
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
1522
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 466, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1523
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h3bdeb7de158ed318);
1524
+ return ret;
1525
+ },
1526
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
1527
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("WebTransportBidirectionalStream")], shim_idx: 812, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1528
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h461ed1cf4779c6f2);
1529
+ return ret;
1530
+ },
1531
+ __wbindgen_cast_0000000000000004: function(arg0, arg1) {
1532
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx: 812, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1533
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h461ed1cf4779c6f2_3);
1534
+ return ret;
1535
+ },
1536
+ __wbindgen_cast_0000000000000005: function(arg0, arg1) {
1537
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 915, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1538
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__hed868b385381c6ed);
1539
+ return ret;
1540
+ },
1541
+ __wbindgen_cast_0000000000000006: function(arg0) {
1542
+ // Cast intrinsic for `F64 -> Externref`.
1543
+ const ret = arg0;
1544
+ return ret;
1545
+ },
1546
+ __wbindgen_cast_0000000000000007: function(arg0, arg1) {
1547
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
1548
+ const ret = getArrayU8FromWasm0(arg0, arg1);
1549
+ return ret;
1550
+ },
1551
+ __wbindgen_cast_0000000000000008: function(arg0, arg1) {
1552
+ // Cast intrinsic for `Ref(String) -> Externref`.
1553
+ const ret = getStringFromWasm0(arg0, arg1);
1554
+ return ret;
1555
+ },
1556
+ __wbindgen_cast_0000000000000009: function(arg0) {
1557
+ // Cast intrinsic for `U64 -> Externref`.
1558
+ const ret = BigInt.asUintN(64, arg0);
1559
+ return ret;
1560
+ },
1561
+ __wbindgen_cast_000000000000000a: function(arg0, arg1) {
1562
+ var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
1563
+ wasm.__wbindgen_free(arg0, arg1 * 4, 4);
1564
+ // Cast intrinsic for `Vector(NamedExternref("ObjectEvent")) -> Externref`.
1565
+ const ret = v0;
1566
+ return ret;
1567
+ },
1568
+ __wbindgen_cast_000000000000000b: function(arg0, arg1) {
1569
+ var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
1570
+ wasm.__wbindgen_free(arg0, arg1 * 4, 4);
1571
+ // Cast intrinsic for `Vector(NamedExternref("PinnedObject")) -> Externref`.
1572
+ const ret = v0;
1573
+ return ret;
1574
+ },
1575
+ __wbindgen_init_externref_table: function() {
1576
+ const table = wasm.__wbindgen_externrefs;
1577
+ const offset = table.grow(4);
1578
+ table.set(0, undefined);
1579
+ table.set(offset + 0, undefined);
1580
+ table.set(offset + 1, null);
1581
+ table.set(offset + 2, true);
1582
+ table.set(offset + 3, false);
1583
+ },
1584
+ };
1585
+ return {
1586
+ __proto__: null,
1587
+ "./sia_storage_wasm_bg.js": import0,
1588
+ };
1589
+ }
1590
+
1591
+ function wasm_bindgen__convert__closures_____invoke__hed868b385381c6ed(arg0, arg1) {
1592
+ wasm.wasm_bindgen__convert__closures_____invoke__hed868b385381c6ed(arg0, arg1);
1593
+ }
1594
+
1595
+ function wasm_bindgen__convert__closures_____invoke__h3bdeb7de158ed318(arg0, arg1, arg2) {
1596
+ wasm.wasm_bindgen__convert__closures_____invoke__h3bdeb7de158ed318(arg0, arg1, arg2);
1597
+ }
1598
+
1599
+ function wasm_bindgen__convert__closures_____invoke__h0c753f5de41a6544(arg0, arg1, arg2) {
1600
+ const ret = wasm.wasm_bindgen__convert__closures_____invoke__h0c753f5de41a6544(arg0, arg1, arg2);
1601
+ if (ret[1]) {
1602
+ throw takeFromExternrefTable0(ret[0]);
1603
+ }
1604
+ }
1605
+
1606
+ function wasm_bindgen__convert__closures_____invoke__h461ed1cf4779c6f2(arg0, arg1, arg2) {
1607
+ const ret = wasm.wasm_bindgen__convert__closures_____invoke__h461ed1cf4779c6f2(arg0, arg1, arg2);
1608
+ if (ret[1]) {
1609
+ throw takeFromExternrefTable0(ret[0]);
1610
+ }
1611
+ }
1612
+
1613
+ function wasm_bindgen__convert__closures_____invoke__h461ed1cf4779c6f2_3(arg0, arg1, arg2) {
1614
+ const ret = wasm.wasm_bindgen__convert__closures_____invoke__h461ed1cf4779c6f2_3(arg0, arg1, arg2);
1615
+ if (ret[1]) {
1616
+ throw takeFromExternrefTable0(ret[0]);
1617
+ }
1618
+ }
1619
+
1620
+ function wasm_bindgen__convert__closures_____invoke__h29f5bd75867abdc1(arg0, arg1, arg2, arg3) {
1621
+ wasm.wasm_bindgen__convert__closures_____invoke__h29f5bd75867abdc1(arg0, arg1, arg2, arg3);
1622
+ }
1623
+
1624
+
1625
+ const __wbindgen_enum_ReadableStreamReaderMode = ["byob"];
1626
+
1627
+
1628
+ const __wbindgen_enum_ReadableStreamType = ["bytes"];
1629
+
1630
+
1631
+ const __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
1632
+
1633
+
1634
+ const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
1635
+
1636
+
1637
+ const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"];
1638
+ const AppKeyFinalization = (typeof FinalizationRegistry === 'undefined')
1639
+ ? { register: () => {}, unregister: () => {} }
1640
+ : new FinalizationRegistry(ptr => wasm.__wbg_appkey_free(ptr >>> 0, 1));
1641
+ const BuilderFinalization = (typeof FinalizationRegistry === 'undefined')
1642
+ ? { register: () => {}, unregister: () => {} }
1643
+ : new FinalizationRegistry(ptr => wasm.__wbg_builder_free(ptr >>> 0, 1));
1644
+ const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined')
1645
+ ? { register: () => {}, unregister: () => {} }
1646
+ : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0, 1));
1647
+ const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined')
1648
+ ? { register: () => {}, unregister: () => {} }
1649
+ : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0, 1));
1650
+ const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined')
1651
+ ? { register: () => {}, unregister: () => {} }
1652
+ : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0, 1));
1653
+ const ObjectEventFinalization = (typeof FinalizationRegistry === 'undefined')
1654
+ ? { register: () => {}, unregister: () => {} }
1655
+ : new FinalizationRegistry(ptr => wasm.__wbg_objectevent_free(ptr >>> 0, 1));
1656
+ const PackedUploadFinalization = (typeof FinalizationRegistry === 'undefined')
1657
+ ? { register: () => {}, unregister: () => {} }
1658
+ : new FinalizationRegistry(ptr => wasm.__wbg_packedupload_free(ptr >>> 0, 1));
1659
+ const PinnedObjectFinalization = (typeof FinalizationRegistry === 'undefined')
1660
+ ? { register: () => {}, unregister: () => {} }
1661
+ : new FinalizationRegistry(ptr => wasm.__wbg_pinnedobject_free(ptr >>> 0, 1));
1662
+ const SdkFinalization = (typeof FinalizationRegistry === 'undefined')
1663
+ ? { register: () => {}, unregister: () => {} }
1664
+ : new FinalizationRegistry(ptr => wasm.__wbg_sdk_free(ptr >>> 0, 1));
1665
+
1666
+ function addToExternrefTable0(obj) {
1667
+ const idx = wasm.__externref_table_alloc();
1668
+ wasm.__wbindgen_externrefs.set(idx, obj);
1669
+ return idx;
1670
+ }
1671
+
1672
+ function _assertClass(instance, klass) {
1673
+ if (!(instance instanceof klass)) {
1674
+ throw new Error(`expected instance of ${klass.name}`);
1675
+ }
1676
+ }
1677
+
1678
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
1679
+ ? { register: () => {}, unregister: () => {} }
1680
+ : new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b));
1681
+
1682
+ function debugString(val) {
1683
+ // primitive types
1684
+ const type = typeof val;
1685
+ if (type == 'number' || type == 'boolean' || val == null) {
1686
+ return `${val}`;
1687
+ }
1688
+ if (type == 'string') {
1689
+ return `"${val}"`;
1690
+ }
1691
+ if (type == 'symbol') {
1692
+ const description = val.description;
1693
+ if (description == null) {
1694
+ return 'Symbol';
1695
+ } else {
1696
+ return `Symbol(${description})`;
1697
+ }
1698
+ }
1699
+ if (type == 'function') {
1700
+ const name = val.name;
1701
+ if (typeof name == 'string' && name.length > 0) {
1702
+ return `Function(${name})`;
1703
+ } else {
1704
+ return 'Function';
1705
+ }
1706
+ }
1707
+ // objects
1708
+ if (Array.isArray(val)) {
1709
+ const length = val.length;
1710
+ let debug = '[';
1711
+ if (length > 0) {
1712
+ debug += debugString(val[0]);
1713
+ }
1714
+ for(let i = 1; i < length; i++) {
1715
+ debug += ', ' + debugString(val[i]);
1716
+ }
1717
+ debug += ']';
1718
+ return debug;
1719
+ }
1720
+ // Test for built-in
1721
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
1722
+ let className;
1723
+ if (builtInMatches && builtInMatches.length > 1) {
1724
+ className = builtInMatches[1];
1725
+ } else {
1726
+ // Failed to match the standard '[object ClassName]'
1727
+ return toString.call(val);
1728
+ }
1729
+ if (className == 'Object') {
1730
+ // we're a user defined class or Object
1731
+ // JSON.stringify avoids problems with cycles, and is generally much
1732
+ // easier than looping through ownProperties of `val`.
1733
+ try {
1734
+ return 'Object(' + JSON.stringify(val) + ')';
1735
+ } catch (_) {
1736
+ return 'Object';
1737
+ }
1738
+ }
1739
+ // errors
1740
+ if (val instanceof Error) {
1741
+ return `${val.name}: ${val.message}\n${val.stack}`;
1742
+ }
1743
+ // TODO we could test for more things here, like `Set`s and `Map`s.
1744
+ return className;
1745
+ }
1746
+
1747
+ function getArrayJsValueFromWasm0(ptr, len) {
1748
+ ptr = ptr >>> 0;
1749
+ const mem = getDataViewMemory0();
1750
+ const result = [];
1751
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
1752
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
1753
+ }
1754
+ wasm.__externref_drop_slice(ptr, len);
1755
+ return result;
1756
+ }
1757
+
1758
+ function getArrayU8FromWasm0(ptr, len) {
1759
+ ptr = ptr >>> 0;
1760
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1761
+ }
1762
+
1763
+ let cachedDataViewMemory0 = null;
1764
+ function getDataViewMemory0() {
1765
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
1766
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
1767
+ }
1768
+ return cachedDataViewMemory0;
1769
+ }
1770
+
1771
+ function getStringFromWasm0(ptr, len) {
1772
+ ptr = ptr >>> 0;
1773
+ return decodeText(ptr, len);
1774
+ }
1775
+
1776
+ let cachedUint8ArrayMemory0 = null;
1777
+ function getUint8ArrayMemory0() {
1778
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1779
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1780
+ }
1781
+ return cachedUint8ArrayMemory0;
1782
+ }
1783
+
1784
+ function handleError(f, args) {
1785
+ try {
1786
+ return f.apply(this, args);
1787
+ } catch (e) {
1788
+ const idx = addToExternrefTable0(e);
1789
+ wasm.__wbindgen_exn_store(idx);
1790
+ }
1791
+ }
1792
+
1793
+ function isLikeNone(x) {
1794
+ return x === undefined || x === null;
1795
+ }
1796
+
1797
+ function makeMutClosure(arg0, arg1, f) {
1798
+ const state = { a: arg0, b: arg1, cnt: 1 };
1799
+ const real = (...args) => {
1800
+
1801
+ // First up with a closure we increment the internal reference
1802
+ // count. This ensures that the Rust closure environment won't
1803
+ // be deallocated while we're invoking it.
1804
+ state.cnt++;
1805
+ const a = state.a;
1806
+ state.a = 0;
1807
+ try {
1808
+ return f(a, state.b, ...args);
1809
+ } finally {
1810
+ state.a = a;
1811
+ real._wbg_cb_unref();
1812
+ }
1813
+ };
1814
+ real._wbg_cb_unref = () => {
1815
+ if (--state.cnt === 0) {
1816
+ wasm.__wbindgen_destroy_closure(state.a, state.b);
1817
+ state.a = 0;
1818
+ CLOSURE_DTORS.unregister(state);
1819
+ }
1820
+ };
1821
+ CLOSURE_DTORS.register(real, state, state);
1822
+ return real;
1823
+ }
1824
+
1825
+ function passArray8ToWasm0(arg, malloc) {
1826
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
1827
+ getUint8ArrayMemory0().set(arg, ptr / 1);
1828
+ WASM_VECTOR_LEN = arg.length;
1829
+ return ptr;
1830
+ }
1831
+
1832
+ function passStringToWasm0(arg, malloc, realloc) {
1833
+ if (realloc === undefined) {
1834
+ const buf = cachedTextEncoder.encode(arg);
1835
+ const ptr = malloc(buf.length, 1) >>> 0;
1836
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1837
+ WASM_VECTOR_LEN = buf.length;
1838
+ return ptr;
1839
+ }
1840
+
1841
+ let len = arg.length;
1842
+ let ptr = malloc(len, 1) >>> 0;
1843
+
1844
+ const mem = getUint8ArrayMemory0();
1845
+
1846
+ let offset = 0;
1847
+
1848
+ for (; offset < len; offset++) {
1849
+ const code = arg.charCodeAt(offset);
1850
+ if (code > 0x7F) break;
1851
+ mem[ptr + offset] = code;
1852
+ }
1853
+ if (offset !== len) {
1854
+ if (offset !== 0) {
1855
+ arg = arg.slice(offset);
1856
+ }
1857
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1858
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1859
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1860
+
1861
+ offset += ret.written;
1862
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1863
+ }
1864
+
1865
+ WASM_VECTOR_LEN = offset;
1866
+ return ptr;
1867
+ }
1868
+
1869
+ function takeFromExternrefTable0(idx) {
1870
+ const value = wasm.__wbindgen_externrefs.get(idx);
1871
+ wasm.__externref_table_dealloc(idx);
1872
+ return value;
1873
+ }
1874
+
1875
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1876
+ cachedTextDecoder.decode();
1877
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1878
+ let numBytesDecoded = 0;
1879
+ function decodeText(ptr, len) {
1880
+ numBytesDecoded += len;
1881
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1882
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1883
+ cachedTextDecoder.decode();
1884
+ numBytesDecoded = len;
1885
+ }
1886
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1887
+ }
1888
+
1889
+ const cachedTextEncoder = new TextEncoder();
1890
+
1891
+ if (!('encodeInto' in cachedTextEncoder)) {
1892
+ cachedTextEncoder.encodeInto = function (arg, view) {
1893
+ const buf = cachedTextEncoder.encode(arg);
1894
+ view.set(buf);
1895
+ return {
1896
+ read: arg.length,
1897
+ written: buf.length
1898
+ };
1899
+ };
1900
+ }
1901
+
1902
+ let WASM_VECTOR_LEN = 0;
1903
+
1904
+ let wasmModule, wasm;
1905
+ function __wbg_finalize_init(instance, module) {
1906
+ wasm = instance.exports;
1907
+ wasmModule = module;
1908
+ cachedDataViewMemory0 = null;
1909
+ cachedUint8ArrayMemory0 = null;
1910
+ wasm.__wbindgen_start();
1911
+ return wasm;
1912
+ }
1913
+
1914
+ async function __wbg_load(module, imports) {
1915
+ if (typeof Response === 'function' && module instanceof Response) {
1916
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1917
+ try {
1918
+ return await WebAssembly.instantiateStreaming(module, imports);
1919
+ } catch (e) {
1920
+ const validResponse = module.ok && expectedResponseType(module.type);
1921
+
1922
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1923
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
1924
+
1925
+ } else { throw e; }
1926
+ }
1927
+ }
1928
+
1929
+ const bytes = await module.arrayBuffer();
1930
+ return await WebAssembly.instantiate(bytes, imports);
1931
+ } else {
1932
+ const instance = await WebAssembly.instantiate(module, imports);
1933
+
1934
+ if (instance instanceof WebAssembly.Instance) {
1935
+ return { instance, module };
1936
+ } else {
1937
+ return instance;
1938
+ }
1939
+ }
1940
+
1941
+ function expectedResponseType(type) {
1942
+ switch (type) {
1943
+ case 'basic': case 'cors': case 'default': return true;
1944
+ }
1945
+ return false;
1946
+ }
1947
+ }
1948
+
1949
+ function initSync(module) {
1950
+ if (wasm !== undefined) return wasm;
1951
+
1952
+
1953
+ if (module !== undefined) {
1954
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1955
+ ({module} = module)
1956
+ } else {
1957
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1958
+ }
1959
+ }
1960
+
1961
+ const imports = __wbg_get_imports();
1962
+ if (!(module instanceof WebAssembly.Module)) {
1963
+ module = new WebAssembly.Module(module);
1964
+ }
1965
+ const instance = new WebAssembly.Instance(module, imports);
1966
+ return __wbg_finalize_init(instance, module);
1967
+ }
1968
+
1969
+ async function __wbg_init(module_or_path) {
1970
+ if (wasm !== undefined) return wasm;
1971
+
1972
+
1973
+ if (module_or_path !== undefined) {
1974
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1975
+ ({module_or_path} = module_or_path)
1976
+ } else {
1977
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1978
+ }
1979
+ }
1980
+
1981
+ if (module_or_path === undefined) {
1982
+ module_or_path = new URL('sia_storage_wasm_bg.wasm', import.meta.url);
1983
+ }
1984
+ const imports = __wbg_get_imports();
1985
+
1986
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1987
+ module_or_path = fetch(module_or_path);
1988
+ }
1989
+
1990
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1991
+
1992
+ return __wbg_finalize_init(instance, module);
1993
+ }
1994
+
1995
+ export { initSync, __wbg_init as default };