@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
@@ -48,7 +48,7 @@ class BlobMeta {
48
48
  * @param {Uint8Array} blob
49
49
  */
50
50
  constructor(blob) {
51
- const ptr0 = passArray8ToWasm0(blob, wasm.__wbindgen_export3);
51
+ const ptr0 = passArray8ToWasm0(blob, wasm.__wbindgen_export);
52
52
  const len0 = WASM_VECTOR_LEN;
53
53
  const ret = wasm.blobmeta_new(ptr0, len0);
54
54
  this.__wbg_ptr = ret >>> 0;
@@ -67,6 +67,143 @@ class BlobMeta {
67
67
  if (Symbol.dispose) BlobMeta.prototype[Symbol.dispose] = BlobMeta.prototype.free;
68
68
  exports.BlobMeta = BlobMeta;
69
69
 
70
+ /**
71
+ * A user-supplied opaque identifier for a loose commit.
72
+ *
73
+ * Unlike [`Digest`](crate::digest::WasmDigest), which is a content hash
74
+ * computed by the system, `CommitId` is provided by the caller at construction
75
+ * time. This is the identity used for DAG traversal, fragment boundaries,
76
+ * and sync.
77
+ */
78
+ class CommitId {
79
+ static __wrap(ptr) {
80
+ ptr = ptr >>> 0;
81
+ const obj = Object.create(CommitId.prototype);
82
+ obj.__wbg_ptr = ptr;
83
+ CommitIdFinalization.register(obj, obj.__wbg_ptr, obj);
84
+ return obj;
85
+ }
86
+ __destroy_into_raw() {
87
+ const ptr = this.__wbg_ptr;
88
+ this.__wbg_ptr = 0;
89
+ CommitIdFinalization.unregister(this);
90
+ return ptr;
91
+ }
92
+ free() {
93
+ const ptr = this.__destroy_into_raw();
94
+ wasm.__wbg_commitid_free(ptr, 0);
95
+ }
96
+ /**
97
+ * Upcasts; to the JS-import type for [`WasmCommitId`].
98
+ * @returns {CommitId}
99
+ */
100
+ __wasm_refgen_toWasmCommitId() {
101
+ const ret = wasm.commitid___wasm_refgen_toWasmCommitId(this.__wbg_ptr);
102
+ return CommitId.__wrap(ret);
103
+ }
104
+ /**
105
+ * Creates a new commit identifier from its Base58 string representation.
106
+ *
107
+ * # Errors
108
+ *
109
+ * Returns an error if the string cannot be decoded or is not 32 bytes.
110
+ * @param {string} s
111
+ * @returns {CommitId}
112
+ */
113
+ static fromBase58(s) {
114
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_export, wasm.__wbindgen_export2);
115
+ const len0 = WASM_VECTOR_LEN;
116
+ const ret = wasm.commitid_fromBase58(ptr0, len0);
117
+ if (ret[2]) {
118
+ throw takeFromExternrefTable0(ret[1]);
119
+ }
120
+ return CommitId.__wrap(ret[0]);
121
+ }
122
+ /**
123
+ * Creates a new commit identifier from its byte representation.
124
+ *
125
+ * # Errors
126
+ *
127
+ * Returns an error if the byte slice is not exactly 32 bytes.
128
+ * @param {Uint8Array} bytes
129
+ * @returns {CommitId}
130
+ */
131
+ static fromBytes(bytes) {
132
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
133
+ const len0 = WASM_VECTOR_LEN;
134
+ const ret = wasm.commitid_fromBytes(ptr0, len0);
135
+ if (ret[2]) {
136
+ throw takeFromExternrefTable0(ret[1]);
137
+ }
138
+ return CommitId.__wrap(ret[0]);
139
+ }
140
+ /**
141
+ * Creates a new commit identifier from its hexadecimal string representation.
142
+ *
143
+ * # Errors
144
+ *
145
+ * Returns an error if the string is not valid hex or not 32 bytes.
146
+ * @param {string} s
147
+ * @returns {CommitId}
148
+ */
149
+ static fromHexString(s) {
150
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_export, wasm.__wbindgen_export2);
151
+ const len0 = WASM_VECTOR_LEN;
152
+ const ret = wasm.commitid_fromHexString(ptr0, len0);
153
+ if (ret[2]) {
154
+ throw takeFromExternrefTable0(ret[1]);
155
+ }
156
+ return CommitId.__wrap(ret[0]);
157
+ }
158
+ /**
159
+ * Creates a new commit identifier from its byte representation.
160
+ *
161
+ * # Errors
162
+ *
163
+ * Returns an error if the byte slice is not exactly 32 bytes.
164
+ * @param {Uint8Array} bytes
165
+ */
166
+ constructor(bytes) {
167
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
168
+ const len0 = WASM_VECTOR_LEN;
169
+ const ret = wasm.commitid_new(ptr0, len0);
170
+ if (ret[2]) {
171
+ throw takeFromExternrefTable0(ret[1]);
172
+ }
173
+ this.__wbg_ptr = ret[0] >>> 0;
174
+ CommitIdFinalization.register(this, this.__wbg_ptr, this);
175
+ return this;
176
+ }
177
+ /**
178
+ * Returns the byte representation of the commit identifier.
179
+ * @returns {Uint8Array}
180
+ */
181
+ toBytes() {
182
+ const ret = wasm.commitid_toBytes(this.__wbg_ptr);
183
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
184
+ wasm.__wbindgen_export6(ret[0], ret[1] * 1, 1);
185
+ return v1;
186
+ }
187
+ /**
188
+ * Returns the hexadecimal string representation.
189
+ * @returns {string}
190
+ */
191
+ toHexString() {
192
+ let deferred1_0;
193
+ let deferred1_1;
194
+ try {
195
+ const ret = wasm.commitid_toHexString(this.__wbg_ptr);
196
+ deferred1_0 = ret[0];
197
+ deferred1_1 = ret[1];
198
+ return getStringFromWasm0(ret[0], ret[1]);
199
+ } finally {
200
+ wasm.__wbindgen_export6(deferred1_0, deferred1_1, 1);
201
+ }
202
+ }
203
+ }
204
+ if (Symbol.dispose) CommitId.prototype[Symbol.dispose] = CommitId.prototype.free;
205
+ exports.CommitId = CommitId;
206
+
70
207
  /**
71
208
  * A commit stored with its associated blob.
72
209
  */
@@ -237,7 +374,7 @@ class Digest {
237
374
  * @returns {Digest}
238
375
  */
239
376
  static fromBase58(s) {
240
- const ptr0 = passStringToWasm0(s, wasm.__wbindgen_export3, wasm.__wbindgen_export5);
377
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_export, wasm.__wbindgen_export2);
241
378
  const len0 = WASM_VECTOR_LEN;
242
379
  const ret = wasm.digest_fromBase58(ptr0, len0);
243
380
  if (ret[2]) {
@@ -255,7 +392,7 @@ class Digest {
255
392
  * @returns {Digest}
256
393
  */
257
394
  static fromBytes(bytes) {
258
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export3);
395
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
259
396
  const len0 = WASM_VECTOR_LEN;
260
397
  const ret = wasm.digest_fromBytes(ptr0, len0);
261
398
  if (ret[2]) {
@@ -273,7 +410,7 @@ class Digest {
273
410
  * @returns {Digest}
274
411
  */
275
412
  static fromHexString(s) {
276
- const ptr0 = passStringToWasm0(s, wasm.__wbindgen_export3, wasm.__wbindgen_export5);
413
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_export, wasm.__wbindgen_export2);
277
414
  const len0 = WASM_VECTOR_LEN;
278
415
  const ret = wasm.digest_fromHexString(ptr0, len0);
279
416
  if (ret[2]) {
@@ -290,7 +427,7 @@ class Digest {
290
427
  * @param {Uint8Array} bytes
291
428
  */
292
429
  constructor(bytes) {
293
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export3);
430
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
294
431
  const len0 = WASM_VECTOR_LEN;
295
432
  const ret = wasm.digest_new(ptr0, len0);
296
433
  if (ret[2]) {
@@ -368,8 +505,8 @@ class Fragment {
368
505
  return BlobMeta.__wrap(ret);
369
506
  }
370
507
  /**
371
- * Get the boundary digests of the fragment.
372
- * @returns {Digest[]}
508
+ * Get the boundary commit identifiers of the fragment.
509
+ * @returns {CommitId[]}
373
510
  */
374
511
  get boundary() {
375
512
  const ret = wasm.fragment_boundary(this.__wbg_ptr);
@@ -378,29 +515,29 @@ class Fragment {
378
515
  return v1;
379
516
  }
380
517
  /**
381
- * Get the head digest of the fragment.
382
- * @returns {Digest}
518
+ * Get the head commit identifier of the fragment.
519
+ * @returns {CommitId}
383
520
  */
384
521
  get head() {
385
522
  const ret = wasm.fragment_head(this.__wbg_ptr);
386
- return Digest.__wrap(ret);
523
+ return CommitId.__wrap(ret);
387
524
  }
388
525
  /**
389
526
  * Create a new fragment from the given sedimentree ID, head, boundary, checkpoints, and blob metadata.
390
527
  * @param {SedimentreeId} sedimentree_id
391
- * @param {Digest} head
392
- * @param {Digest[]} boundary
393
- * @param {Digest[]} checkpoints
528
+ * @param {CommitId} head
529
+ * @param {CommitId[]} boundary
530
+ * @param {CommitId[]} checkpoints
394
531
  * @param {BlobMeta} blob_meta
395
532
  */
396
533
  constructor(sedimentree_id, head, boundary, checkpoints, blob_meta) {
397
534
  _assertClass(sedimentree_id, SedimentreeId);
398
535
  var ptr0 = sedimentree_id.__destroy_into_raw();
399
- _assertClass(head, Digest);
536
+ _assertClass(head, CommitId);
400
537
  var ptr1 = head.__destroy_into_raw();
401
- const ptr2 = passArrayJsValueToWasm0(boundary, wasm.__wbindgen_export3);
538
+ const ptr2 = passArrayJsValueToWasm0(boundary, wasm.__wbindgen_export);
402
539
  const len2 = WASM_VECTOR_LEN;
403
- const ptr3 = passArrayJsValueToWasm0(checkpoints, wasm.__wbindgen_export3);
540
+ const ptr3 = passArrayJsValueToWasm0(checkpoints, wasm.__wbindgen_export);
404
541
  const len3 = WASM_VECTOR_LEN;
405
542
  _assertClass(blob_meta, BlobMeta);
406
543
  var ptr4 = blob_meta.__destroy_into_raw();
@@ -543,7 +680,15 @@ class LooseCommit {
543
680
  return BlobMeta.__wrap(ret);
544
681
  }
545
682
  /**
546
- * Get the digest of the commit.
683
+ * Get the commit's head identifier.
684
+ * @returns {CommitId}
685
+ */
686
+ get commitId() {
687
+ const ret = wasm.loosecommit_commitId(this.__wbg_ptr);
688
+ return CommitId.__wrap(ret);
689
+ }
690
+ /**
691
+ * Get the digest of the commit (content hash).
547
692
  * @returns {Digest}
548
693
  */
549
694
  get digest() {
@@ -551,25 +696,28 @@ class LooseCommit {
551
696
  return Digest.__wrap(ret);
552
697
  }
553
698
  /**
554
- * Create a new `LooseCommit` from the given sedimentree ID, parents, and blob metadata.
699
+ * Create a new `LooseCommit` from the given sedimentree ID, head, parents, and blob metadata.
555
700
  * @param {SedimentreeId} sedimentree_id
556
- * @param {Digest[]} parents
701
+ * @param {CommitId} head
702
+ * @param {CommitId[]} parents
557
703
  * @param {BlobMeta} blob_meta
558
704
  */
559
- constructor(sedimentree_id, parents, blob_meta) {
705
+ constructor(sedimentree_id, head, parents, blob_meta) {
560
706
  _assertClass(sedimentree_id, SedimentreeId);
561
707
  var ptr0 = sedimentree_id.__destroy_into_raw();
562
- const ptr1 = passArrayJsValueToWasm0(parents, wasm.__wbindgen_export3);
563
- const len1 = WASM_VECTOR_LEN;
708
+ _assertClass(head, CommitId);
709
+ var ptr1 = head.__destroy_into_raw();
710
+ const ptr2 = passArrayJsValueToWasm0(parents, wasm.__wbindgen_export);
711
+ const len2 = WASM_VECTOR_LEN;
564
712
  _assertClass(blob_meta, BlobMeta);
565
- const ret = wasm.loosecommit_new(ptr0, ptr1, len1, blob_meta.__wbg_ptr);
713
+ const ret = wasm.loosecommit_new(ptr0, ptr1, ptr2, len2, blob_meta.__wbg_ptr);
566
714
  this.__wbg_ptr = ret >>> 0;
567
715
  LooseCommitFinalization.register(this, this.__wbg_ptr, this);
568
716
  return this;
569
717
  }
570
718
  /**
571
- * Get the parent digests of the commit.
572
- * @returns {Digest[]}
719
+ * Get the parent commit identifiers.
720
+ * @returns {CommitId[]}
573
721
  */
574
722
  get parents() {
575
723
  const ret = wasm.loosecommit_parents(this.__wbg_ptr);
@@ -618,27 +766,27 @@ class MemoryStorage {
618
766
  return ret;
619
767
  }
620
768
  /**
621
- * Delete a commit by digest.
769
+ * Delete a single commit by its ID.
622
770
  * @param {SedimentreeId} sedimentree_id
623
- * @param {Digest} digest
771
+ * @param {CommitId} commit_id
624
772
  * @returns {Promise<any>}
625
773
  */
626
- deleteCommit(sedimentree_id, digest) {
774
+ deleteCommit(sedimentree_id, commit_id) {
627
775
  _assertClass(sedimentree_id, SedimentreeId);
628
- _assertClass(digest, Digest);
629
- const ret = wasm.memorystorage_deleteCommit(this.__wbg_ptr, sedimentree_id.__wbg_ptr, digest.__wbg_ptr);
776
+ _assertClass(commit_id, CommitId);
777
+ const ret = wasm.memorystorage_deleteCommit(this.__wbg_ptr, sedimentree_id.__wbg_ptr, commit_id.__wbg_ptr);
630
778
  return ret;
631
779
  }
632
780
  /**
633
- * Delete a fragment by digest.
781
+ * Delete a fragment by its identifier.
634
782
  * @param {SedimentreeId} sedimentree_id
635
- * @param {Digest} digest
783
+ * @param {CommitId} fragment_head
636
784
  * @returns {Promise<any>}
637
785
  */
638
- deleteFragment(sedimentree_id, digest) {
786
+ deleteFragment(sedimentree_id, fragment_head) {
639
787
  _assertClass(sedimentree_id, SedimentreeId);
640
- _assertClass(digest, Digest);
641
- const ret = wasm.memorystorage_deleteFragment(this.__wbg_ptr, sedimentree_id.__wbg_ptr, digest.__wbg_ptr);
788
+ _assertClass(fragment_head, CommitId);
789
+ const ret = wasm.memorystorage_deleteFragment(this.__wbg_ptr, sedimentree_id.__wbg_ptr, fragment_head.__wbg_ptr);
642
790
  return ret;
643
791
  }
644
792
  /**
@@ -652,23 +800,23 @@ class MemoryStorage {
652
800
  return ret;
653
801
  }
654
802
  /**
655
- * List all commit digests for a sedimentree.
803
+ * List all commit IDs for a sedimentree.
656
804
  * @param {SedimentreeId} sedimentree_id
657
805
  * @returns {Promise<any>}
658
806
  */
659
- listCommitDigests(sedimentree_id) {
807
+ listCommitIds(sedimentree_id) {
660
808
  _assertClass(sedimentree_id, SedimentreeId);
661
- const ret = wasm.memorystorage_listCommitDigests(this.__wbg_ptr, sedimentree_id.__wbg_ptr);
809
+ const ret = wasm.memorystorage_listCommitIds(this.__wbg_ptr, sedimentree_id.__wbg_ptr);
662
810
  return ret;
663
811
  }
664
812
  /**
665
- * List all fragment digests for a sedimentree.
813
+ * List all fragment IDs for a sedimentree.
666
814
  * @param {SedimentreeId} sedimentree_id
667
815
  * @returns {Promise<any>}
668
816
  */
669
- listFragmentDigests(sedimentree_id) {
817
+ listFragmentIds(sedimentree_id) {
670
818
  _assertClass(sedimentree_id, SedimentreeId);
671
- const ret = wasm.memorystorage_listFragmentDigests(this.__wbg_ptr, sedimentree_id.__wbg_ptr);
819
+ const ret = wasm.memorystorage_listFragmentIds(this.__wbg_ptr, sedimentree_id.__wbg_ptr);
672
820
  return ret;
673
821
  }
674
822
  /**
@@ -700,27 +848,27 @@ class MemoryStorage {
700
848
  return ret;
701
849
  }
702
850
  /**
703
- * Load a commit by digest, returning `CommitWithBlob` or null.
851
+ * Load a single commit by its ID, returning `CommitWithBlob` or null.
704
852
  * @param {SedimentreeId} sedimentree_id
705
- * @param {Digest} digest
853
+ * @param {CommitId} commit_id
706
854
  * @returns {Promise<any>}
707
855
  */
708
- loadCommit(sedimentree_id, digest) {
856
+ loadCommit(sedimentree_id, commit_id) {
709
857
  _assertClass(sedimentree_id, SedimentreeId);
710
- _assertClass(digest, Digest);
711
- const ret = wasm.memorystorage_loadCommit(this.__wbg_ptr, sedimentree_id.__wbg_ptr, digest.__wbg_ptr);
858
+ _assertClass(commit_id, CommitId);
859
+ const ret = wasm.memorystorage_loadCommit(this.__wbg_ptr, sedimentree_id.__wbg_ptr, commit_id.__wbg_ptr);
712
860
  return ret;
713
861
  }
714
862
  /**
715
- * Load a fragment by digest, returning `FragmentWithBlob` or null.
863
+ * Load a fragment by its identifier, returning `FragmentWithBlob` or null.
716
864
  * @param {SedimentreeId} sedimentree_id
717
- * @param {Digest} digest
865
+ * @param {CommitId} fragment_head
718
866
  * @returns {Promise<any>}
719
867
  */
720
- loadFragment(sedimentree_id, digest) {
868
+ loadFragment(sedimentree_id, fragment_head) {
721
869
  _assertClass(sedimentree_id, SedimentreeId);
722
- _assertClass(digest, Digest);
723
- const ret = wasm.memorystorage_loadFragment(this.__wbg_ptr, sedimentree_id.__wbg_ptr, digest.__wbg_ptr);
870
+ _assertClass(fragment_head, CommitId);
871
+ const ret = wasm.memorystorage_loadFragment(this.__wbg_ptr, sedimentree_id.__wbg_ptr, fragment_head.__wbg_ptr);
724
872
  return ret;
725
873
  }
726
874
  /**
@@ -732,34 +880,55 @@ class MemoryStorage {
732
880
  MemoryStorageFinalization.register(this, this.__wbg_ptr, this);
733
881
  return this;
734
882
  }
883
+ /**
884
+ * Save commits and fragments in a single batch.
885
+ * @param {SedimentreeId} sedimentree_id
886
+ * @param {Array<any>} commits
887
+ * @param {Array<any>} fragments
888
+ * @returns {Promise<any>}
889
+ */
890
+ saveBatchAll(sedimentree_id, commits, fragments) {
891
+ _assertClass(sedimentree_id, SedimentreeId);
892
+ const ret = wasm.memorystorage_saveBatchAll(this.__wbg_ptr, sedimentree_id.__wbg_ptr, commits, fragments);
893
+ return ret;
894
+ }
735
895
  /**
736
896
  * Save a commit with its blob.
897
+ *
898
+ * The `commit_id` parameter must match the `head()` embedded in
899
+ * the signed commit payload. Returns an error if they differ.
900
+ *
901
+ * # Errors
902
+ *
903
+ * Returns a JS error if:
904
+ * - The signed payload cannot be decoded
905
+ * - The `commit_id` does not match the embedded `head()`
737
906
  * @param {SedimentreeId} sedimentree_id
738
- * @param {Digest} _digest
907
+ * @param {CommitId} commit_id
739
908
  * @param {SignedLooseCommit} signed_commit
740
909
  * @param {Uint8Array} blob
741
910
  * @returns {Promise<any>}
742
911
  */
743
- saveCommit(sedimentree_id, _digest, signed_commit, blob) {
912
+ saveCommit(sedimentree_id, commit_id, signed_commit, blob) {
744
913
  _assertClass(sedimentree_id, SedimentreeId);
745
- _assertClass(_digest, Digest);
914
+ _assertClass(commit_id, CommitId);
746
915
  _assertClass(signed_commit, SignedLooseCommit);
747
- const ret = wasm.memorystorage_saveCommit(this.__wbg_ptr, sedimentree_id.__wbg_ptr, _digest.__wbg_ptr, signed_commit.__wbg_ptr, blob);
916
+ const ret = wasm.memorystorage_saveCommit(this.__wbg_ptr, sedimentree_id.__wbg_ptr, commit_id.__wbg_ptr, signed_commit.__wbg_ptr, blob);
748
917
  return ret;
749
918
  }
750
919
  /**
751
920
  * Save a fragment with its blob.
752
921
  * @param {SedimentreeId} sedimentree_id
753
- * @param {Digest} _digest
922
+ * @param {CommitId} _fragment_head
754
923
  * @param {SignedFragment} signed_fragment
755
924
  * @param {Uint8Array} blob
756
925
  * @returns {Promise<any>}
757
926
  */
758
- saveFragment(sedimentree_id, _digest, signed_fragment, blob) {
927
+ saveFragment(sedimentree_id, _fragment_head, signed_fragment, blob) {
759
928
  _assertClass(sedimentree_id, SedimentreeId);
760
- _assertClass(_digest, Digest);
929
+ _assertClass(_fragment_head, CommitId);
761
930
  _assertClass(signed_fragment, SignedFragment);
762
- const ret = wasm.memorystorage_saveFragment(this.__wbg_ptr, sedimentree_id.__wbg_ptr, _digest.__wbg_ptr, signed_fragment.__wbg_ptr, blob);
931
+ const ret = wasm.memorystorage_saveFragment(this.__wbg_ptr, sedimentree_id.__wbg_ptr, _fragment_head.__wbg_ptr, signed_fragment.__wbg_ptr, blob);
763
932
  return ret;
764
933
  }
765
934
  /**
@@ -811,9 +980,9 @@ class Sedimentree {
811
980
  * @param {LooseCommit[]} commits
812
981
  */
813
982
  constructor(fragments, commits) {
814
- const ptr0 = passArrayJsValueToWasm0(fragments, wasm.__wbindgen_export3);
983
+ const ptr0 = passArrayJsValueToWasm0(fragments, wasm.__wbindgen_export);
815
984
  const len0 = WASM_VECTOR_LEN;
816
- const ptr1 = passArrayJsValueToWasm0(commits, wasm.__wbindgen_export3);
985
+ const ptr1 = passArrayJsValueToWasm0(commits, wasm.__wbindgen_export);
817
986
  const len1 = WASM_VECTOR_LEN;
818
987
  const ret = wasm.sedimentree_new(ptr0, len0, ptr1, len1);
819
988
  this.__wbg_ptr = ret >>> 0;
@@ -863,7 +1032,7 @@ class SedimentreeId {
863
1032
  * @returns {SedimentreeId}
864
1033
  */
865
1034
  static fromBytes(bytes) {
866
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export3);
1035
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
867
1036
  const len0 = WASM_VECTOR_LEN;
868
1037
  const ret = wasm.sedimentreeid_fromBytes(ptr0, len0);
869
1038
  if (ret[2]) {
@@ -942,6 +1111,12 @@ class SignedFragment {
942
1111
  SignedFragmentFinalization.register(obj, obj.__wbg_ptr, obj);
943
1112
  return obj;
944
1113
  }
1114
+ static __unwrap(jsValue) {
1115
+ if (!(jsValue instanceof SignedFragment)) {
1116
+ return 0;
1117
+ }
1118
+ return jsValue.__destroy_into_raw();
1119
+ }
945
1120
  __destroy_into_raw() {
946
1121
  const ptr = this.__wbg_ptr;
947
1122
  this.__wbg_ptr = 0;
@@ -1014,6 +1189,12 @@ class SignedLooseCommit {
1014
1189
  SignedLooseCommitFinalization.register(obj, obj.__wbg_ptr, obj);
1015
1190
  return obj;
1016
1191
  }
1192
+ static __unwrap(jsValue) {
1193
+ if (!(jsValue instanceof SignedLooseCommit)) {
1194
+ return 0;
1195
+ }
1196
+ return jsValue.__destroy_into_raw();
1197
+ }
1017
1198
  __destroy_into_raw() {
1018
1199
  const ptr = this.__wbg_ptr;
1019
1200
  this.__wbg_ptr = 0;
@@ -1078,24 +1259,31 @@ exports.SignedLooseCommit = SignedLooseCommit;
1078
1259
  function __wbg_get_imports() {
1079
1260
  const import0 = {
1080
1261
  __proto__: null,
1081
- __wbg___wasm_refgen_toWasmDigest_d0fbca90d003e5b2: function(arg0) {
1082
- const ret = arg0.__wasm_refgen_toWasmDigest();
1083
- _assertClass(ret, Digest);
1262
+ __wbg___wasm_refgen_toWasmCommitId_65b818e358f27de6: function(arg0) {
1263
+ const ret = arg0.__wasm_refgen_toWasmCommitId();
1264
+ _assertClass(ret, CommitId);
1084
1265
  var ptr1 = ret.__destroy_into_raw();
1085
1266
  return ptr1;
1086
1267
  },
1087
- __wbg___wasm_refgen_toWasmFragment_32ab33a0a1cf967b: function(arg0) {
1268
+ __wbg___wasm_refgen_toWasmFragment_38ddb9958dbdc455: function(arg0) {
1088
1269
  const ret = arg0.__wasm_refgen_toWasmFragment();
1089
1270
  _assertClass(ret, Fragment);
1090
1271
  var ptr1 = ret.__destroy_into_raw();
1091
1272
  return ptr1;
1092
1273
  },
1093
- __wbg___wasm_refgen_toWasmLooseCommit_6deda612421ca7e6: function(arg0) {
1274
+ __wbg___wasm_refgen_toWasmLooseCommit_876edb05490f6350: function(arg0) {
1094
1275
  const ret = arg0.__wasm_refgen_toWasmLooseCommit();
1095
1276
  _assertClass(ret, LooseCommit);
1096
1277
  var ptr1 = ret.__destroy_into_raw();
1097
1278
  return ptr1;
1098
1279
  },
1280
+ __wbg___wbindgen_debug_string_5398f5bb970e0daa: function(arg0, arg1) {
1281
+ const ret = debugString(arg1);
1282
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1283
+ const len1 = WASM_VECTOR_LEN;
1284
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1285
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1286
+ },
1099
1287
  __wbg___wbindgen_is_function_3c846841762788c1: function(arg0) {
1100
1288
  const ret = typeof(arg0) === 'function';
1101
1289
  return ret;
@@ -1120,26 +1308,42 @@ function __wbg_get_imports() {
1120
1308
  const ret = arg0.call(arg1, arg2);
1121
1309
  return ret;
1122
1310
  }, arguments); },
1123
- __wbg_commitwithblob_new: function(arg0) {
1124
- const ret = CommitWithBlob.__wrap(arg0);
1311
+ __wbg_commitid_new: function(arg0) {
1312
+ const ret = CommitId.__wrap(arg0);
1125
1313
  return ret;
1126
1314
  },
1127
- __wbg_digest_new: function(arg0) {
1128
- const ret = Digest.__wrap(arg0);
1315
+ __wbg_commitwithblob_new: function(arg0) {
1316
+ const ret = CommitWithBlob.__wrap(arg0);
1129
1317
  return ret;
1130
1318
  },
1131
1319
  __wbg_fragmentwithblob_new: function(arg0) {
1132
1320
  const ret = FragmentWithBlob.__wrap(arg0);
1133
1321
  return ret;
1134
1322
  },
1323
+ __wbg_get_3ef1eba1850ade27: function() { return handleError(function (arg0, arg1) {
1324
+ const ret = Reflect.get(arg0, arg1);
1325
+ return ret;
1326
+ }, arguments); },
1327
+ __wbg_get_unchecked_329cfe50afab7352: function(arg0, arg1) {
1328
+ const ret = arg0[arg1 >>> 0];
1329
+ return ret;
1330
+ },
1135
1331
  __wbg_isSafeInteger_ecd6a7f9c3e053cd: function(arg0) {
1136
1332
  const ret = Number.isSafeInteger(arg0);
1137
1333
  return ret;
1138
1334
  },
1335
+ __wbg_length_b3416cf66a5452c8: function(arg0) {
1336
+ const ret = arg0.length;
1337
+ return ret;
1338
+ },
1139
1339
  __wbg_length_ea16607d7b61445b: function(arg0) {
1140
1340
  const ret = arg0.length;
1141
1341
  return ret;
1142
1342
  },
1343
+ __wbg_new_5f486cdf45a04d78: function(arg0) {
1344
+ const ret = new Uint8Array(arg0);
1345
+ return ret;
1346
+ },
1143
1347
  __wbg_new_a70fbab9066b301f: function() {
1144
1348
  const ret = new Array();
1145
1349
  return ret;
@@ -1159,7 +1363,7 @@ function __wbg_get_imports() {
1159
1363
  const a = state0.a;
1160
1364
  state0.a = 0;
1161
1365
  try {
1162
- return __wasm_bindgen_func_elem_533_66(a, state0.b, arg0, arg1);
1366
+ return __wasm_bindgen_func_elem_563_75(a, state0.b, arg0, arg1);
1163
1367
  } finally {
1164
1368
  state0.a = a;
1165
1369
  }
@@ -1195,6 +1399,14 @@ function __wbg_get_imports() {
1195
1399
  __wbg_set_name_7ef37fe858379aaf: function(arg0, arg1, arg2) {
1196
1400
  arg0.name = getStringFromWasm0(arg1, arg2);
1197
1401
  },
1402
+ __wbg_signedfragment_unwrap: function(arg0) {
1403
+ const ret = SignedFragment.__unwrap(arg0);
1404
+ return ret;
1405
+ },
1406
+ __wbg_signedloosecommit_unwrap: function(arg0) {
1407
+ const ret = SignedLooseCommit.__unwrap(arg0);
1408
+ return ret;
1409
+ },
1198
1410
  __wbg_static_accessor_GLOBAL_8adb955bd33fac2f: function() {
1199
1411
  const ret = typeof global === 'undefined' ? null : global;
1200
1412
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
@@ -1216,8 +1428,8 @@ function __wbg_get_imports() {
1216
1428
  return ret;
1217
1429
  },
1218
1430
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1219
- // 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`.
1220
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_366, __wasm_bindgen_func_elem_533);
1431
+ // 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`.
1432
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_400, __wasm_bindgen_func_elem_563);
1221
1433
  return ret;
1222
1434
  },
1223
1435
  __wbindgen_cast_0000000000000002: function(arg0) {
@@ -1246,15 +1458,15 @@ function __wbg_get_imports() {
1246
1458
  };
1247
1459
  }
1248
1460
 
1249
- function __wasm_bindgen_func_elem_533(arg0, arg1, arg2) {
1250
- const ret = wasm.__wasm_bindgen_func_elem_533(arg0, arg1, arg2);
1461
+ function __wasm_bindgen_func_elem_563(arg0, arg1, arg2) {
1462
+ const ret = wasm.__wasm_bindgen_func_elem_563(arg0, arg1, arg2);
1251
1463
  if (ret[1]) {
1252
1464
  throw takeFromExternrefTable0(ret[0]);
1253
1465
  }
1254
1466
  }
1255
1467
 
1256
- function __wasm_bindgen_func_elem_533_66(arg0, arg1, arg2, arg3) {
1257
- wasm.__wasm_bindgen_func_elem_533_66(arg0, arg1, arg2, arg3);
1468
+ function __wasm_bindgen_func_elem_563_75(arg0, arg1, arg2, arg3) {
1469
+ wasm.__wasm_bindgen_func_elem_563_75(arg0, arg1, arg2, arg3);
1258
1470
  }
1259
1471
 
1260
1472
  const MemoryStorageFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -1263,6 +1475,9 @@ const MemoryStorageFinalization = (typeof FinalizationRegistry === 'undefined')
1263
1475
  const BlobMetaFinalization = (typeof FinalizationRegistry === 'undefined')
1264
1476
  ? { register: () => {}, unregister: () => {} }
1265
1477
  : new FinalizationRegistry(ptr => wasm.__wbg_blobmeta_free(ptr >>> 0, 1));
1478
+ const CommitIdFinalization = (typeof FinalizationRegistry === 'undefined')
1479
+ ? { register: () => {}, unregister: () => {} }
1480
+ : new FinalizationRegistry(ptr => wasm.__wbg_commitid_free(ptr >>> 0, 1));
1266
1481
  const CommitWithBlobFinalization = (typeof FinalizationRegistry === 'undefined')
1267
1482
  ? { register: () => {}, unregister: () => {} }
1268
1483
  : new FinalizationRegistry(ptr => wasm.__wbg_commitwithblob_free(ptr >>> 0, 1));
@@ -1301,7 +1516,7 @@ const SignedLooseCommitFinalization = (typeof FinalizationRegistry === 'undefine
1301
1516
  : new FinalizationRegistry(ptr => wasm.__wbg_signedloosecommit_free(ptr >>> 0, 1));
1302
1517
 
1303
1518
  function addToExternrefTable0(obj) {
1304
- const idx = wasm.__wbindgen_export2();
1519
+ const idx = wasm.__wbindgen_export4();
1305
1520
  wasm.__wbindgen_externrefs.set(idx, obj);
1306
1521
  return idx;
1307
1522
  }
@@ -1316,6 +1531,71 @@ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
1316
1531
  ? { register: () => {}, unregister: () => {} }
1317
1532
  : new FinalizationRegistry(state => state.dtor(state.a, state.b));
1318
1533
 
1534
+ function debugString(val) {
1535
+ // primitive types
1536
+ const type = typeof val;
1537
+ if (type == 'number' || type == 'boolean' || val == null) {
1538
+ return `${val}`;
1539
+ }
1540
+ if (type == 'string') {
1541
+ return `"${val}"`;
1542
+ }
1543
+ if (type == 'symbol') {
1544
+ const description = val.description;
1545
+ if (description == null) {
1546
+ return 'Symbol';
1547
+ } else {
1548
+ return `Symbol(${description})`;
1549
+ }
1550
+ }
1551
+ if (type == 'function') {
1552
+ const name = val.name;
1553
+ if (typeof name == 'string' && name.length > 0) {
1554
+ return `Function(${name})`;
1555
+ } else {
1556
+ return 'Function';
1557
+ }
1558
+ }
1559
+ // objects
1560
+ if (Array.isArray(val)) {
1561
+ const length = val.length;
1562
+ let debug = '[';
1563
+ if (length > 0) {
1564
+ debug += debugString(val[0]);
1565
+ }
1566
+ for(let i = 1; i < length; i++) {
1567
+ debug += ', ' + debugString(val[i]);
1568
+ }
1569
+ debug += ']';
1570
+ return debug;
1571
+ }
1572
+ // Test for built-in
1573
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
1574
+ let className;
1575
+ if (builtInMatches && builtInMatches.length > 1) {
1576
+ className = builtInMatches[1];
1577
+ } else {
1578
+ // Failed to match the standard '[object ClassName]'
1579
+ return toString.call(val);
1580
+ }
1581
+ if (className == 'Object') {
1582
+ // we're a user defined class or Object
1583
+ // JSON.stringify avoids problems with cycles, and is generally much
1584
+ // easier than looping through ownProperties of `val`.
1585
+ try {
1586
+ return 'Object(' + JSON.stringify(val) + ')';
1587
+ } catch (_) {
1588
+ return 'Object';
1589
+ }
1590
+ }
1591
+ // errors
1592
+ if (val instanceof Error) {
1593
+ return `${val.name}: ${val.message}\n${val.stack}`;
1594
+ }
1595
+ // TODO we could test for more things here, like `Set`s and `Map`s.
1596
+ return className;
1597
+ }
1598
+
1319
1599
  function getArrayJsValueFromWasm0(ptr, len) {
1320
1600
  ptr = ptr >>> 0;
1321
1601
  const mem = getDataViewMemory0();
@@ -1358,7 +1638,7 @@ function handleError(f, args) {
1358
1638
  return f.apply(this, args);
1359
1639
  } catch (e) {
1360
1640
  const idx = addToExternrefTable0(e);
1361
- wasm.__wbindgen_export(idx);
1641
+ wasm.__wbindgen_export3(idx);
1362
1642
  }
1363
1643
  }
1364
1644
 
@@ -1450,7 +1730,7 @@ function passStringToWasm0(arg, malloc, realloc) {
1450
1730
 
1451
1731
  function takeFromExternrefTable0(idx) {
1452
1732
  const value = wasm.__wbindgen_externrefs.get(idx);
1453
- wasm.__wbindgen_export4(idx);
1733
+ wasm.__wbindgen_export5(idx);
1454
1734
  return value;
1455
1735
  }
1456
1736