@automerge/sedimentree 0.8.2 → 0.9.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 (30) hide show
  1. package/dist/cjs/wasm-base64.cjs +1 -1
  2. package/dist/cjs/web-bindings.cjs +345 -80
  3. package/dist/cjs/web.cjs +346 -81
  4. package/dist/esm/wasm-base64.js +1 -1
  5. package/dist/iife/index.js +345 -81
  6. package/dist/index.d.ts +107 -33
  7. package/dist/sedimentree.wasm +0 -0
  8. package/dist/wasm_bindgen/bundler/sedimentree_wasm.d.ts +107 -33
  9. package/dist/wasm_bindgen/bundler/sedimentree_wasm.js +1 -1
  10. package/dist/wasm_bindgen/bundler/sedimentree_wasm_bg.js +360 -81
  11. package/dist/wasm_bindgen/bundler/sedimentree_wasm_bg.wasm +0 -0
  12. package/dist/wasm_bindgen/bundler/sedimentree_wasm_bg.wasm.d.ts +26 -16
  13. package/dist/wasm_bindgen/nodejs/sedimentree_wasm.cjs +361 -81
  14. package/dist/wasm_bindgen/nodejs/sedimentree_wasm.d.ts +107 -33
  15. package/dist/wasm_bindgen/nodejs/sedimentree_wasm_bg.wasm +0 -0
  16. package/dist/wasm_bindgen/nodejs/sedimentree_wasm_bg.wasm.d.ts +26 -16
  17. package/dist/wasm_bindgen/web/sedimentree_wasm.d.ts +133 -49
  18. package/dist/wasm_bindgen/web/sedimentree_wasm.js +360 -81
  19. package/dist/wasm_bindgen/web/sedimentree_wasm_bg.wasm +0 -0
  20. package/dist/wasm_bindgen/web/sedimentree_wasm_bg.wasm.d.ts +26 -16
  21. package/package.json +1 -1
  22. /package/dist/wasm_bindgen/bundler/snippets/{sedimentree_wasm-75027ecce41278de → sedimentree_wasm-8e1863d4f7634be2}/inline0.js +0 -0
  23. /package/dist/wasm_bindgen/bundler/snippets/{sedimentree_wasm-75027ecce41278de → sedimentree_wasm-8e1863d4f7634be2}/inline1.js +0 -0
  24. /package/dist/wasm_bindgen/bundler/snippets/{sedimentree_wasm-75027ecce41278de → sedimentree_wasm-8e1863d4f7634be2}/inline2.js +0 -0
  25. /package/dist/wasm_bindgen/nodejs/snippets/{sedimentree_wasm-75027ecce41278de → sedimentree_wasm-8e1863d4f7634be2}/inline0.js +0 -0
  26. /package/dist/wasm_bindgen/nodejs/snippets/{sedimentree_wasm-75027ecce41278de → sedimentree_wasm-8e1863d4f7634be2}/inline1.js +0 -0
  27. /package/dist/wasm_bindgen/nodejs/snippets/{sedimentree_wasm-75027ecce41278de → sedimentree_wasm-8e1863d4f7634be2}/inline2.js +0 -0
  28. /package/dist/wasm_bindgen/web/snippets/{sedimentree_wasm-75027ecce41278de → sedimentree_wasm-8e1863d4f7634be2}/inline0.js +0 -0
  29. /package/dist/wasm_bindgen/web/snippets/{sedimentree_wasm-75027ecce41278de → sedimentree_wasm-8e1863d4f7634be2}/inline1.js +0 -0
  30. /package/dist/wasm_bindgen/web/snippets/{sedimentree_wasm-75027ecce41278de → sedimentree_wasm-8e1863d4f7634be2}/inline2.js +0 -0
@@ -46,7 +46,7 @@ export class BlobMeta {
46
46
  * @param {Uint8Array} blob
47
47
  */
48
48
  constructor(blob) {
49
- const ptr0 = passArray8ToWasm0(blob, wasm.__wbindgen_export3);
49
+ const ptr0 = passArray8ToWasm0(blob, wasm.__wbindgen_export);
50
50
  const len0 = WASM_VECTOR_LEN;
51
51
  const ret = wasm.blobmeta_new(ptr0, len0);
52
52
  this.__wbg_ptr = ret >>> 0;
@@ -64,6 +64,142 @@ export class BlobMeta {
64
64
  }
65
65
  if (Symbol.dispose) BlobMeta.prototype[Symbol.dispose] = BlobMeta.prototype.free;
66
66
 
67
+ /**
68
+ * A user-supplied opaque identifier for a loose commit.
69
+ *
70
+ * Unlike [`Digest`](crate::digest::WasmDigest), which is a content hash
71
+ * computed by the system, `CommitId` is provided by the caller at construction
72
+ * time. This is the identity used for DAG traversal, fragment boundaries,
73
+ * and sync.
74
+ */
75
+ export class CommitId {
76
+ static __wrap(ptr) {
77
+ ptr = ptr >>> 0;
78
+ const obj = Object.create(CommitId.prototype);
79
+ obj.__wbg_ptr = ptr;
80
+ CommitIdFinalization.register(obj, obj.__wbg_ptr, obj);
81
+ return obj;
82
+ }
83
+ __destroy_into_raw() {
84
+ const ptr = this.__wbg_ptr;
85
+ this.__wbg_ptr = 0;
86
+ CommitIdFinalization.unregister(this);
87
+ return ptr;
88
+ }
89
+ free() {
90
+ const ptr = this.__destroy_into_raw();
91
+ wasm.__wbg_commitid_free(ptr, 0);
92
+ }
93
+ /**
94
+ * Upcasts; to the JS-import type for [`WasmCommitId`].
95
+ * @returns {CommitId}
96
+ */
97
+ __wasm_refgen_toWasmCommitId() {
98
+ const ret = wasm.commitid___wasm_refgen_toWasmCommitId(this.__wbg_ptr);
99
+ return CommitId.__wrap(ret);
100
+ }
101
+ /**
102
+ * Creates a new commit identifier from its Base58 string representation.
103
+ *
104
+ * # Errors
105
+ *
106
+ * Returns an error if the string cannot be decoded or is not 32 bytes.
107
+ * @param {string} s
108
+ * @returns {CommitId}
109
+ */
110
+ static fromBase58(s) {
111
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_export, wasm.__wbindgen_export2);
112
+ const len0 = WASM_VECTOR_LEN;
113
+ const ret = wasm.commitid_fromBase58(ptr0, len0);
114
+ if (ret[2]) {
115
+ throw takeFromExternrefTable0(ret[1]);
116
+ }
117
+ return CommitId.__wrap(ret[0]);
118
+ }
119
+ /**
120
+ * Creates a new commit identifier from its byte representation.
121
+ *
122
+ * # Errors
123
+ *
124
+ * Returns an error if the byte slice is not exactly 32 bytes.
125
+ * @param {Uint8Array} bytes
126
+ * @returns {CommitId}
127
+ */
128
+ static fromBytes(bytes) {
129
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
130
+ const len0 = WASM_VECTOR_LEN;
131
+ const ret = wasm.commitid_fromBytes(ptr0, len0);
132
+ if (ret[2]) {
133
+ throw takeFromExternrefTable0(ret[1]);
134
+ }
135
+ return CommitId.__wrap(ret[0]);
136
+ }
137
+ /**
138
+ * Creates a new commit identifier from its hexadecimal string representation.
139
+ *
140
+ * # Errors
141
+ *
142
+ * Returns an error if the string is not valid hex or not 32 bytes.
143
+ * @param {string} s
144
+ * @returns {CommitId}
145
+ */
146
+ static fromHexString(s) {
147
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_export, wasm.__wbindgen_export2);
148
+ const len0 = WASM_VECTOR_LEN;
149
+ const ret = wasm.commitid_fromHexString(ptr0, len0);
150
+ if (ret[2]) {
151
+ throw takeFromExternrefTable0(ret[1]);
152
+ }
153
+ return CommitId.__wrap(ret[0]);
154
+ }
155
+ /**
156
+ * Creates a new commit identifier from its byte representation.
157
+ *
158
+ * # Errors
159
+ *
160
+ * Returns an error if the byte slice is not exactly 32 bytes.
161
+ * @param {Uint8Array} bytes
162
+ */
163
+ constructor(bytes) {
164
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
165
+ const len0 = WASM_VECTOR_LEN;
166
+ const ret = wasm.commitid_new(ptr0, len0);
167
+ if (ret[2]) {
168
+ throw takeFromExternrefTable0(ret[1]);
169
+ }
170
+ this.__wbg_ptr = ret[0] >>> 0;
171
+ CommitIdFinalization.register(this, this.__wbg_ptr, this);
172
+ return this;
173
+ }
174
+ /**
175
+ * Returns the byte representation of the commit identifier.
176
+ * @returns {Uint8Array}
177
+ */
178
+ toBytes() {
179
+ const ret = wasm.commitid_toBytes(this.__wbg_ptr);
180
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
181
+ wasm.__wbindgen_export6(ret[0], ret[1] * 1, 1);
182
+ return v1;
183
+ }
184
+ /**
185
+ * Returns the hexadecimal string representation.
186
+ * @returns {string}
187
+ */
188
+ toHexString() {
189
+ let deferred1_0;
190
+ let deferred1_1;
191
+ try {
192
+ const ret = wasm.commitid_toHexString(this.__wbg_ptr);
193
+ deferred1_0 = ret[0];
194
+ deferred1_1 = ret[1];
195
+ return getStringFromWasm0(ret[0], ret[1]);
196
+ } finally {
197
+ wasm.__wbindgen_export6(deferred1_0, deferred1_1, 1);
198
+ }
199
+ }
200
+ }
201
+ if (Symbol.dispose) CommitId.prototype[Symbol.dispose] = CommitId.prototype.free;
202
+
67
203
  /**
68
204
  * A commit stored with its associated blob.
69
205
  */
@@ -232,7 +368,7 @@ export class Digest {
232
368
  * @returns {Digest}
233
369
  */
234
370
  static fromBase58(s) {
235
- const ptr0 = passStringToWasm0(s, wasm.__wbindgen_export3, wasm.__wbindgen_export5);
371
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_export, wasm.__wbindgen_export2);
236
372
  const len0 = WASM_VECTOR_LEN;
237
373
  const ret = wasm.digest_fromBase58(ptr0, len0);
238
374
  if (ret[2]) {
@@ -250,7 +386,7 @@ export class Digest {
250
386
  * @returns {Digest}
251
387
  */
252
388
  static fromBytes(bytes) {
253
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export3);
389
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
254
390
  const len0 = WASM_VECTOR_LEN;
255
391
  const ret = wasm.digest_fromBytes(ptr0, len0);
256
392
  if (ret[2]) {
@@ -268,7 +404,7 @@ export class Digest {
268
404
  * @returns {Digest}
269
405
  */
270
406
  static fromHexString(s) {
271
- const ptr0 = passStringToWasm0(s, wasm.__wbindgen_export3, wasm.__wbindgen_export5);
407
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_export, wasm.__wbindgen_export2);
272
408
  const len0 = WASM_VECTOR_LEN;
273
409
  const ret = wasm.digest_fromHexString(ptr0, len0);
274
410
  if (ret[2]) {
@@ -285,7 +421,7 @@ export class Digest {
285
421
  * @param {Uint8Array} bytes
286
422
  */
287
423
  constructor(bytes) {
288
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export3);
424
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
289
425
  const len0 = WASM_VECTOR_LEN;
290
426
  const ret = wasm.digest_new(ptr0, len0);
291
427
  if (ret[2]) {
@@ -362,8 +498,8 @@ export class Fragment {
362
498
  return BlobMeta.__wrap(ret);
363
499
  }
364
500
  /**
365
- * Get the boundary digests of the fragment.
366
- * @returns {Digest[]}
501
+ * Get the boundary commit identifiers of the fragment.
502
+ * @returns {CommitId[]}
367
503
  */
368
504
  get boundary() {
369
505
  const ret = wasm.fragment_boundary(this.__wbg_ptr);
@@ -372,29 +508,29 @@ export class Fragment {
372
508
  return v1;
373
509
  }
374
510
  /**
375
- * Get the head digest of the fragment.
376
- * @returns {Digest}
511
+ * Get the head commit identifier of the fragment.
512
+ * @returns {CommitId}
377
513
  */
378
514
  get head() {
379
515
  const ret = wasm.fragment_head(this.__wbg_ptr);
380
- return Digest.__wrap(ret);
516
+ return CommitId.__wrap(ret);
381
517
  }
382
518
  /**
383
519
  * Create a new fragment from the given sedimentree ID, head, boundary, checkpoints, and blob metadata.
384
520
  * @param {SedimentreeId} sedimentree_id
385
- * @param {Digest} head
386
- * @param {Digest[]} boundary
387
- * @param {Digest[]} checkpoints
521
+ * @param {CommitId} head
522
+ * @param {CommitId[]} boundary
523
+ * @param {CommitId[]} checkpoints
388
524
  * @param {BlobMeta} blob_meta
389
525
  */
390
526
  constructor(sedimentree_id, head, boundary, checkpoints, blob_meta) {
391
527
  _assertClass(sedimentree_id, SedimentreeId);
392
528
  var ptr0 = sedimentree_id.__destroy_into_raw();
393
- _assertClass(head, Digest);
529
+ _assertClass(head, CommitId);
394
530
  var ptr1 = head.__destroy_into_raw();
395
- const ptr2 = passArrayJsValueToWasm0(boundary, wasm.__wbindgen_export3);
531
+ const ptr2 = passArrayJsValueToWasm0(boundary, wasm.__wbindgen_export);
396
532
  const len2 = WASM_VECTOR_LEN;
397
- const ptr3 = passArrayJsValueToWasm0(checkpoints, wasm.__wbindgen_export3);
533
+ const ptr3 = passArrayJsValueToWasm0(checkpoints, wasm.__wbindgen_export);
398
534
  const len3 = WASM_VECTOR_LEN;
399
535
  _assertClass(blob_meta, BlobMeta);
400
536
  var ptr4 = blob_meta.__destroy_into_raw();
@@ -534,7 +670,15 @@ export class LooseCommit {
534
670
  return BlobMeta.__wrap(ret);
535
671
  }
536
672
  /**
537
- * Get the digest of the commit.
673
+ * Get the commit's head identifier.
674
+ * @returns {CommitId}
675
+ */
676
+ get commitId() {
677
+ const ret = wasm.loosecommit_commitId(this.__wbg_ptr);
678
+ return CommitId.__wrap(ret);
679
+ }
680
+ /**
681
+ * Get the digest of the commit (content hash).
538
682
  * @returns {Digest}
539
683
  */
540
684
  get digest() {
@@ -542,25 +686,28 @@ export class LooseCommit {
542
686
  return Digest.__wrap(ret);
543
687
  }
544
688
  /**
545
- * Create a new `LooseCommit` from the given sedimentree ID, parents, and blob metadata.
689
+ * Create a new `LooseCommit` from the given sedimentree ID, head, parents, and blob metadata.
546
690
  * @param {SedimentreeId} sedimentree_id
547
- * @param {Digest[]} parents
691
+ * @param {CommitId} head
692
+ * @param {CommitId[]} parents
548
693
  * @param {BlobMeta} blob_meta
549
694
  */
550
- constructor(sedimentree_id, parents, blob_meta) {
695
+ constructor(sedimentree_id, head, parents, blob_meta) {
551
696
  _assertClass(sedimentree_id, SedimentreeId);
552
697
  var ptr0 = sedimentree_id.__destroy_into_raw();
553
- const ptr1 = passArrayJsValueToWasm0(parents, wasm.__wbindgen_export3);
554
- const len1 = WASM_VECTOR_LEN;
698
+ _assertClass(head, CommitId);
699
+ var ptr1 = head.__destroy_into_raw();
700
+ const ptr2 = passArrayJsValueToWasm0(parents, wasm.__wbindgen_export);
701
+ const len2 = WASM_VECTOR_LEN;
555
702
  _assertClass(blob_meta, BlobMeta);
556
- const ret = wasm.loosecommit_new(ptr0, ptr1, len1, blob_meta.__wbg_ptr);
703
+ const ret = wasm.loosecommit_new(ptr0, ptr1, ptr2, len2, blob_meta.__wbg_ptr);
557
704
  this.__wbg_ptr = ret >>> 0;
558
705
  LooseCommitFinalization.register(this, this.__wbg_ptr, this);
559
706
  return this;
560
707
  }
561
708
  /**
562
- * Get the parent digests of the commit.
563
- * @returns {Digest[]}
709
+ * Get the parent commit identifiers.
710
+ * @returns {CommitId[]}
564
711
  */
565
712
  get parents() {
566
713
  const ret = wasm.loosecommit_parents(this.__wbg_ptr);
@@ -608,27 +755,27 @@ export class MemoryStorage {
608
755
  return ret;
609
756
  }
610
757
  /**
611
- * Delete a commit by digest.
758
+ * Delete a single commit by its ID.
612
759
  * @param {SedimentreeId} sedimentree_id
613
- * @param {Digest} digest
760
+ * @param {CommitId} commit_id
614
761
  * @returns {Promise<any>}
615
762
  */
616
- deleteCommit(sedimentree_id, digest) {
763
+ deleteCommit(sedimentree_id, commit_id) {
617
764
  _assertClass(sedimentree_id, SedimentreeId);
618
- _assertClass(digest, Digest);
619
- const ret = wasm.memorystorage_deleteCommit(this.__wbg_ptr, sedimentree_id.__wbg_ptr, digest.__wbg_ptr);
765
+ _assertClass(commit_id, CommitId);
766
+ const ret = wasm.memorystorage_deleteCommit(this.__wbg_ptr, sedimentree_id.__wbg_ptr, commit_id.__wbg_ptr);
620
767
  return ret;
621
768
  }
622
769
  /**
623
- * Delete a fragment by digest.
770
+ * Delete a fragment by its identifier.
624
771
  * @param {SedimentreeId} sedimentree_id
625
- * @param {Digest} digest
772
+ * @param {CommitId} fragment_head
626
773
  * @returns {Promise<any>}
627
774
  */
628
- deleteFragment(sedimentree_id, digest) {
775
+ deleteFragment(sedimentree_id, fragment_head) {
629
776
  _assertClass(sedimentree_id, SedimentreeId);
630
- _assertClass(digest, Digest);
631
- const ret = wasm.memorystorage_deleteFragment(this.__wbg_ptr, sedimentree_id.__wbg_ptr, digest.__wbg_ptr);
777
+ _assertClass(fragment_head, CommitId);
778
+ const ret = wasm.memorystorage_deleteFragment(this.__wbg_ptr, sedimentree_id.__wbg_ptr, fragment_head.__wbg_ptr);
632
779
  return ret;
633
780
  }
634
781
  /**
@@ -642,23 +789,23 @@ export class MemoryStorage {
642
789
  return ret;
643
790
  }
644
791
  /**
645
- * List all commit digests for a sedimentree.
792
+ * List all commit IDs for a sedimentree.
646
793
  * @param {SedimentreeId} sedimentree_id
647
794
  * @returns {Promise<any>}
648
795
  */
649
- listCommitDigests(sedimentree_id) {
796
+ listCommitIds(sedimentree_id) {
650
797
  _assertClass(sedimentree_id, SedimentreeId);
651
- const ret = wasm.memorystorage_listCommitDigests(this.__wbg_ptr, sedimentree_id.__wbg_ptr);
798
+ const ret = wasm.memorystorage_listCommitIds(this.__wbg_ptr, sedimentree_id.__wbg_ptr);
652
799
  return ret;
653
800
  }
654
801
  /**
655
- * List all fragment digests for a sedimentree.
802
+ * List all fragment IDs for a sedimentree.
656
803
  * @param {SedimentreeId} sedimentree_id
657
804
  * @returns {Promise<any>}
658
805
  */
659
- listFragmentDigests(sedimentree_id) {
806
+ listFragmentIds(sedimentree_id) {
660
807
  _assertClass(sedimentree_id, SedimentreeId);
661
- const ret = wasm.memorystorage_listFragmentDigests(this.__wbg_ptr, sedimentree_id.__wbg_ptr);
808
+ const ret = wasm.memorystorage_listFragmentIds(this.__wbg_ptr, sedimentree_id.__wbg_ptr);
662
809
  return ret;
663
810
  }
664
811
  /**
@@ -690,27 +837,27 @@ export class MemoryStorage {
690
837
  return ret;
691
838
  }
692
839
  /**
693
- * Load a commit by digest, returning `CommitWithBlob` or null.
840
+ * Load a single commit by its ID, returning `CommitWithBlob` or null.
694
841
  * @param {SedimentreeId} sedimentree_id
695
- * @param {Digest} digest
842
+ * @param {CommitId} commit_id
696
843
  * @returns {Promise<any>}
697
844
  */
698
- loadCommit(sedimentree_id, digest) {
845
+ loadCommit(sedimentree_id, commit_id) {
699
846
  _assertClass(sedimentree_id, SedimentreeId);
700
- _assertClass(digest, Digest);
701
- const ret = wasm.memorystorage_loadCommit(this.__wbg_ptr, sedimentree_id.__wbg_ptr, digest.__wbg_ptr);
847
+ _assertClass(commit_id, CommitId);
848
+ const ret = wasm.memorystorage_loadCommit(this.__wbg_ptr, sedimentree_id.__wbg_ptr, commit_id.__wbg_ptr);
702
849
  return ret;
703
850
  }
704
851
  /**
705
- * Load a fragment by digest, returning `FragmentWithBlob` or null.
852
+ * Load a fragment by its identifier, returning `FragmentWithBlob` or null.
706
853
  * @param {SedimentreeId} sedimentree_id
707
- * @param {Digest} digest
854
+ * @param {CommitId} fragment_head
708
855
  * @returns {Promise<any>}
709
856
  */
710
- loadFragment(sedimentree_id, digest) {
857
+ loadFragment(sedimentree_id, fragment_head) {
711
858
  _assertClass(sedimentree_id, SedimentreeId);
712
- _assertClass(digest, Digest);
713
- const ret = wasm.memorystorage_loadFragment(this.__wbg_ptr, sedimentree_id.__wbg_ptr, digest.__wbg_ptr);
859
+ _assertClass(fragment_head, CommitId);
860
+ const ret = wasm.memorystorage_loadFragment(this.__wbg_ptr, sedimentree_id.__wbg_ptr, fragment_head.__wbg_ptr);
714
861
  return ret;
715
862
  }
716
863
  /**
@@ -722,34 +869,55 @@ export class MemoryStorage {
722
869
  MemoryStorageFinalization.register(this, this.__wbg_ptr, this);
723
870
  return this;
724
871
  }
872
+ /**
873
+ * Save commits and fragments in a single batch.
874
+ * @param {SedimentreeId} sedimentree_id
875
+ * @param {Array<any>} commits
876
+ * @param {Array<any>} fragments
877
+ * @returns {Promise<any>}
878
+ */
879
+ saveBatchAll(sedimentree_id, commits, fragments) {
880
+ _assertClass(sedimentree_id, SedimentreeId);
881
+ const ret = wasm.memorystorage_saveBatchAll(this.__wbg_ptr, sedimentree_id.__wbg_ptr, commits, fragments);
882
+ return ret;
883
+ }
725
884
  /**
726
885
  * Save a commit with its blob.
886
+ *
887
+ * The `commit_id` parameter must match the `head()` embedded in
888
+ * the signed commit payload. Returns an error if they differ.
889
+ *
890
+ * # Errors
891
+ *
892
+ * Returns a JS error if:
893
+ * - The signed payload cannot be decoded
894
+ * - The `commit_id` does not match the embedded `head()`
727
895
  * @param {SedimentreeId} sedimentree_id
728
- * @param {Digest} _digest
896
+ * @param {CommitId} commit_id
729
897
  * @param {SignedLooseCommit} signed_commit
730
898
  * @param {Uint8Array} blob
731
899
  * @returns {Promise<any>}
732
900
  */
733
- saveCommit(sedimentree_id, _digest, signed_commit, blob) {
901
+ saveCommit(sedimentree_id, commit_id, signed_commit, blob) {
734
902
  _assertClass(sedimentree_id, SedimentreeId);
735
- _assertClass(_digest, Digest);
903
+ _assertClass(commit_id, CommitId);
736
904
  _assertClass(signed_commit, SignedLooseCommit);
737
- const ret = wasm.memorystorage_saveCommit(this.__wbg_ptr, sedimentree_id.__wbg_ptr, _digest.__wbg_ptr, signed_commit.__wbg_ptr, blob);
905
+ const ret = wasm.memorystorage_saveCommit(this.__wbg_ptr, sedimentree_id.__wbg_ptr, commit_id.__wbg_ptr, signed_commit.__wbg_ptr, blob);
738
906
  return ret;
739
907
  }
740
908
  /**
741
909
  * Save a fragment with its blob.
742
910
  * @param {SedimentreeId} sedimentree_id
743
- * @param {Digest} _digest
911
+ * @param {CommitId} _fragment_head
744
912
  * @param {SignedFragment} signed_fragment
745
913
  * @param {Uint8Array} blob
746
914
  * @returns {Promise<any>}
747
915
  */
748
- saveFragment(sedimentree_id, _digest, signed_fragment, blob) {
916
+ saveFragment(sedimentree_id, _fragment_head, signed_fragment, blob) {
749
917
  _assertClass(sedimentree_id, SedimentreeId);
750
- _assertClass(_digest, Digest);
918
+ _assertClass(_fragment_head, CommitId);
751
919
  _assertClass(signed_fragment, SignedFragment);
752
- const ret = wasm.memorystorage_saveFragment(this.__wbg_ptr, sedimentree_id.__wbg_ptr, _digest.__wbg_ptr, signed_fragment.__wbg_ptr, blob);
920
+ const ret = wasm.memorystorage_saveFragment(this.__wbg_ptr, sedimentree_id.__wbg_ptr, _fragment_head.__wbg_ptr, signed_fragment.__wbg_ptr, blob);
753
921
  return ret;
754
922
  }
755
923
  /**
@@ -800,9 +968,9 @@ export class Sedimentree {
800
968
  * @param {LooseCommit[]} commits
801
969
  */
802
970
  constructor(fragments, commits) {
803
- const ptr0 = passArrayJsValueToWasm0(fragments, wasm.__wbindgen_export3);
971
+ const ptr0 = passArrayJsValueToWasm0(fragments, wasm.__wbindgen_export);
804
972
  const len0 = WASM_VECTOR_LEN;
805
- const ptr1 = passArrayJsValueToWasm0(commits, wasm.__wbindgen_export3);
973
+ const ptr1 = passArrayJsValueToWasm0(commits, wasm.__wbindgen_export);
806
974
  const len1 = WASM_VECTOR_LEN;
807
975
  const ret = wasm.sedimentree_new(ptr0, len0, ptr1, len1);
808
976
  this.__wbg_ptr = ret >>> 0;
@@ -851,7 +1019,7 @@ export class SedimentreeId {
851
1019
  * @returns {SedimentreeId}
852
1020
  */
853
1021
  static fromBytes(bytes) {
854
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export3);
1022
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
855
1023
  const len0 = WASM_VECTOR_LEN;
856
1024
  const ret = wasm.sedimentreeid_fromBytes(ptr0, len0);
857
1025
  if (ret[2]) {
@@ -928,6 +1096,12 @@ export class SignedFragment {
928
1096
  SignedFragmentFinalization.register(obj, obj.__wbg_ptr, obj);
929
1097
  return obj;
930
1098
  }
1099
+ static __unwrap(jsValue) {
1100
+ if (!(jsValue instanceof SignedFragment)) {
1101
+ return 0;
1102
+ }
1103
+ return jsValue.__destroy_into_raw();
1104
+ }
931
1105
  __destroy_into_raw() {
932
1106
  const ptr = this.__wbg_ptr;
933
1107
  this.__wbg_ptr = 0;
@@ -999,6 +1173,12 @@ export class SignedLooseCommit {
999
1173
  SignedLooseCommitFinalization.register(obj, obj.__wbg_ptr, obj);
1000
1174
  return obj;
1001
1175
  }
1176
+ static __unwrap(jsValue) {
1177
+ if (!(jsValue instanceof SignedLooseCommit)) {
1178
+ return 0;
1179
+ }
1180
+ return jsValue.__destroy_into_raw();
1181
+ }
1002
1182
  __destroy_into_raw() {
1003
1183
  const ptr = this.__wbg_ptr;
1004
1184
  this.__wbg_ptr = 0;
@@ -1058,24 +1238,31 @@ export class SignedLooseCommit {
1058
1238
  }
1059
1239
  }
1060
1240
  if (Symbol.dispose) SignedLooseCommit.prototype[Symbol.dispose] = SignedLooseCommit.prototype.free;
1061
- export function __wbg___wasm_refgen_toWasmDigest_d0fbca90d003e5b2(arg0) {
1062
- const ret = arg0.__wasm_refgen_toWasmDigest();
1063
- _assertClass(ret, Digest);
1241
+ export function __wbg___wasm_refgen_toWasmCommitId_65b818e358f27de6(arg0) {
1242
+ const ret = arg0.__wasm_refgen_toWasmCommitId();
1243
+ _assertClass(ret, CommitId);
1064
1244
  var ptr1 = ret.__destroy_into_raw();
1065
1245
  return ptr1;
1066
1246
  }
1067
- export function __wbg___wasm_refgen_toWasmFragment_32ab33a0a1cf967b(arg0) {
1247
+ export function __wbg___wasm_refgen_toWasmFragment_38ddb9958dbdc455(arg0) {
1068
1248
  const ret = arg0.__wasm_refgen_toWasmFragment();
1069
1249
  _assertClass(ret, Fragment);
1070
1250
  var ptr1 = ret.__destroy_into_raw();
1071
1251
  return ptr1;
1072
1252
  }
1073
- export function __wbg___wasm_refgen_toWasmLooseCommit_6deda612421ca7e6(arg0) {
1253
+ export function __wbg___wasm_refgen_toWasmLooseCommit_876edb05490f6350(arg0) {
1074
1254
  const ret = arg0.__wasm_refgen_toWasmLooseCommit();
1075
1255
  _assertClass(ret, LooseCommit);
1076
1256
  var ptr1 = ret.__destroy_into_raw();
1077
1257
  return ptr1;
1078
1258
  }
1259
+ export function __wbg___wbindgen_debug_string_5398f5bb970e0daa(arg0, arg1) {
1260
+ const ret = debugString(arg1);
1261
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1262
+ const len1 = WASM_VECTOR_LEN;
1263
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1264
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1265
+ }
1079
1266
  export function __wbg___wbindgen_is_function_3c846841762788c1(arg0) {
1080
1267
  const ret = typeof(arg0) === 'function';
1081
1268
  return ret;
@@ -1100,26 +1287,42 @@ export function __wbg_call_2d781c1f4d5c0ef8() { return handleError(function (arg
1100
1287
  const ret = arg0.call(arg1, arg2);
1101
1288
  return ret;
1102
1289
  }, arguments); }
1103
- export function __wbg_commitwithblob_new(arg0) {
1104
- const ret = CommitWithBlob.__wrap(arg0);
1290
+ export function __wbg_commitid_new(arg0) {
1291
+ const ret = CommitId.__wrap(arg0);
1105
1292
  return ret;
1106
1293
  }
1107
- export function __wbg_digest_new(arg0) {
1108
- const ret = Digest.__wrap(arg0);
1294
+ export function __wbg_commitwithblob_new(arg0) {
1295
+ const ret = CommitWithBlob.__wrap(arg0);
1109
1296
  return ret;
1110
1297
  }
1111
1298
  export function __wbg_fragmentwithblob_new(arg0) {
1112
1299
  const ret = FragmentWithBlob.__wrap(arg0);
1113
1300
  return ret;
1114
1301
  }
1302
+ export function __wbg_get_3ef1eba1850ade27() { return handleError(function (arg0, arg1) {
1303
+ const ret = Reflect.get(arg0, arg1);
1304
+ return ret;
1305
+ }, arguments); }
1306
+ export function __wbg_get_unchecked_329cfe50afab7352(arg0, arg1) {
1307
+ const ret = arg0[arg1 >>> 0];
1308
+ return ret;
1309
+ }
1115
1310
  export function __wbg_isSafeInteger_ecd6a7f9c3e053cd(arg0) {
1116
1311
  const ret = Number.isSafeInteger(arg0);
1117
1312
  return ret;
1118
1313
  }
1314
+ export function __wbg_length_b3416cf66a5452c8(arg0) {
1315
+ const ret = arg0.length;
1316
+ return ret;
1317
+ }
1119
1318
  export function __wbg_length_ea16607d7b61445b(arg0) {
1120
1319
  const ret = arg0.length;
1121
1320
  return ret;
1122
1321
  }
1322
+ export function __wbg_new_5f486cdf45a04d78(arg0) {
1323
+ const ret = new Uint8Array(arg0);
1324
+ return ret;
1325
+ }
1123
1326
  export function __wbg_new_a70fbab9066b301f() {
1124
1327
  const ret = new Array();
1125
1328
  return ret;
@@ -1139,7 +1342,7 @@ export function __wbg_new_typed_aaaeaf29cf802876(arg0, arg1) {
1139
1342
  const a = state0.a;
1140
1343
  state0.a = 0;
1141
1344
  try {
1142
- return __wasm_bindgen_func_elem_533_66(a, state0.b, arg0, arg1);
1345
+ return __wasm_bindgen_func_elem_563_75(a, state0.b, arg0, arg1);
1143
1346
  } finally {
1144
1347
  state0.a = a;
1145
1348
  }
@@ -1175,6 +1378,14 @@ export function __wbg_sedimentreeid_new(arg0) {
1175
1378
  export function __wbg_set_name_7ef37fe858379aaf(arg0, arg1, arg2) {
1176
1379
  arg0.name = getStringFromWasm0(arg1, arg2);
1177
1380
  }
1381
+ export function __wbg_signedfragment_unwrap(arg0) {
1382
+ const ret = SignedFragment.__unwrap(arg0);
1383
+ return ret;
1384
+ }
1385
+ export function __wbg_signedloosecommit_unwrap(arg0) {
1386
+ const ret = SignedLooseCommit.__unwrap(arg0);
1387
+ return ret;
1388
+ }
1178
1389
  export function __wbg_static_accessor_GLOBAL_8adb955bd33fac2f() {
1179
1390
  const ret = typeof global === 'undefined' ? null : global;
1180
1391
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
@@ -1196,8 +1407,8 @@ export function __wbg_then_098abe61755d12f6(arg0, arg1) {
1196
1407
  return ret;
1197
1408
  }
1198
1409
  export function __wbindgen_cast_0000000000000001(arg0, arg1) {
1199
- // Cast intrinsic for `Closure(Closure { dtor_idx: 64, function: Function { arguments: [Externref], shim_idx: 126, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1200
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_366, __wasm_bindgen_func_elem_533);
1410
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 73, function: Function { arguments: [Externref], shim_idx: 136, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1411
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_400, __wasm_bindgen_func_elem_563);
1201
1412
  return ret;
1202
1413
  }
1203
1414
  export function __wbindgen_cast_0000000000000002(arg0) {
@@ -1219,15 +1430,15 @@ export function __wbindgen_init_externref_table() {
1219
1430
  table.set(offset + 2, true);
1220
1431
  table.set(offset + 3, false);
1221
1432
  }
1222
- function __wasm_bindgen_func_elem_533(arg0, arg1, arg2) {
1223
- const ret = wasm.__wasm_bindgen_func_elem_533(arg0, arg1, arg2);
1433
+ function __wasm_bindgen_func_elem_563(arg0, arg1, arg2) {
1434
+ const ret = wasm.__wasm_bindgen_func_elem_563(arg0, arg1, arg2);
1224
1435
  if (ret[1]) {
1225
1436
  throw takeFromExternrefTable0(ret[0]);
1226
1437
  }
1227
1438
  }
1228
1439
 
1229
- function __wasm_bindgen_func_elem_533_66(arg0, arg1, arg2, arg3) {
1230
- wasm.__wasm_bindgen_func_elem_533_66(arg0, arg1, arg2, arg3);
1440
+ function __wasm_bindgen_func_elem_563_75(arg0, arg1, arg2, arg3) {
1441
+ wasm.__wasm_bindgen_func_elem_563_75(arg0, arg1, arg2, arg3);
1231
1442
  }
1232
1443
 
1233
1444
  const MemoryStorageFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -1236,6 +1447,9 @@ const MemoryStorageFinalization = (typeof FinalizationRegistry === 'undefined')
1236
1447
  const BlobMetaFinalization = (typeof FinalizationRegistry === 'undefined')
1237
1448
  ? { register: () => {}, unregister: () => {} }
1238
1449
  : new FinalizationRegistry(ptr => wasm.__wbg_blobmeta_free(ptr >>> 0, 1));
1450
+ const CommitIdFinalization = (typeof FinalizationRegistry === 'undefined')
1451
+ ? { register: () => {}, unregister: () => {} }
1452
+ : new FinalizationRegistry(ptr => wasm.__wbg_commitid_free(ptr >>> 0, 1));
1239
1453
  const CommitWithBlobFinalization = (typeof FinalizationRegistry === 'undefined')
1240
1454
  ? { register: () => {}, unregister: () => {} }
1241
1455
  : new FinalizationRegistry(ptr => wasm.__wbg_commitwithblob_free(ptr >>> 0, 1));
@@ -1274,7 +1488,7 @@ const SignedLooseCommitFinalization = (typeof FinalizationRegistry === 'undefine
1274
1488
  : new FinalizationRegistry(ptr => wasm.__wbg_signedloosecommit_free(ptr >>> 0, 1));
1275
1489
 
1276
1490
  function addToExternrefTable0(obj) {
1277
- const idx = wasm.__wbindgen_export2();
1491
+ const idx = wasm.__wbindgen_export4();
1278
1492
  wasm.__wbindgen_externrefs.set(idx, obj);
1279
1493
  return idx;
1280
1494
  }
@@ -1289,6 +1503,71 @@ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
1289
1503
  ? { register: () => {}, unregister: () => {} }
1290
1504
  : new FinalizationRegistry(state => state.dtor(state.a, state.b));
1291
1505
 
1506
+ function debugString(val) {
1507
+ // primitive types
1508
+ const type = typeof val;
1509
+ if (type == 'number' || type == 'boolean' || val == null) {
1510
+ return `${val}`;
1511
+ }
1512
+ if (type == 'string') {
1513
+ return `"${val}"`;
1514
+ }
1515
+ if (type == 'symbol') {
1516
+ const description = val.description;
1517
+ if (description == null) {
1518
+ return 'Symbol';
1519
+ } else {
1520
+ return `Symbol(${description})`;
1521
+ }
1522
+ }
1523
+ if (type == 'function') {
1524
+ const name = val.name;
1525
+ if (typeof name == 'string' && name.length > 0) {
1526
+ return `Function(${name})`;
1527
+ } else {
1528
+ return 'Function';
1529
+ }
1530
+ }
1531
+ // objects
1532
+ if (Array.isArray(val)) {
1533
+ const length = val.length;
1534
+ let debug = '[';
1535
+ if (length > 0) {
1536
+ debug += debugString(val[0]);
1537
+ }
1538
+ for(let i = 1; i < length; i++) {
1539
+ debug += ', ' + debugString(val[i]);
1540
+ }
1541
+ debug += ']';
1542
+ return debug;
1543
+ }
1544
+ // Test for built-in
1545
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
1546
+ let className;
1547
+ if (builtInMatches && builtInMatches.length > 1) {
1548
+ className = builtInMatches[1];
1549
+ } else {
1550
+ // Failed to match the standard '[object ClassName]'
1551
+ return toString.call(val);
1552
+ }
1553
+ if (className == 'Object') {
1554
+ // we're a user defined class or Object
1555
+ // JSON.stringify avoids problems with cycles, and is generally much
1556
+ // easier than looping through ownProperties of `val`.
1557
+ try {
1558
+ return 'Object(' + JSON.stringify(val) + ')';
1559
+ } catch (_) {
1560
+ return 'Object';
1561
+ }
1562
+ }
1563
+ // errors
1564
+ if (val instanceof Error) {
1565
+ return `${val.name}: ${val.message}\n${val.stack}`;
1566
+ }
1567
+ // TODO we could test for more things here, like `Set`s and `Map`s.
1568
+ return className;
1569
+ }
1570
+
1292
1571
  function getArrayJsValueFromWasm0(ptr, len) {
1293
1572
  ptr = ptr >>> 0;
1294
1573
  const mem = getDataViewMemory0();
@@ -1331,7 +1610,7 @@ function handleError(f, args) {
1331
1610
  return f.apply(this, args);
1332
1611
  } catch (e) {
1333
1612
  const idx = addToExternrefTable0(e);
1334
- wasm.__wbindgen_export(idx);
1613
+ wasm.__wbindgen_export3(idx);
1335
1614
  }
1336
1615
  }
1337
1616
 
@@ -1423,7 +1702,7 @@ function passStringToWasm0(arg, malloc, realloc) {
1423
1702
 
1424
1703
  function takeFromExternrefTable0(idx) {
1425
1704
  const value = wasm.__wbindgen_externrefs.get(idx);
1426
- wasm.__wbindgen_export4(idx);
1705
+ wasm.__wbindgen_export5(idx);
1427
1706
  return value;
1428
1707
  }
1429
1708