@fireproof/core 0.20.0-dev-preview-53 → 0.20.0-dev-preview-54

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.
package/index.js CHANGED
@@ -511,70 +511,34 @@ __export(files_exports, {
511
511
  decodeFile: () => decodeFile,
512
512
  encodeFile: () => encodeFile
513
513
  });
514
- import * as UnixFS from "@ipld/unixfs";
515
514
  import * as raw from "multiformats/codecs/raw";
516
- import { withMaxChunkSize } from "@ipld/unixfs/file/chunker/fixed";
517
- import { withWidth } from "@ipld/unixfs/file/layout/balanced";
518
- import { exporter } from "ipfs-unixfs-exporter";
519
- var queuingStrategy = UnixFS.withCapacity();
520
- var settings = UnixFS.configure({
521
- fileChunkEncoder: raw,
522
- smallFileEncoder: raw,
523
- chunker: withMaxChunkSize(1024 * 1024),
524
- fileLayout: withWidth(1024)
525
- });
526
- async function collect(collectable) {
527
- const chunks = [];
528
- await collectable.pipeTo(
529
- new WritableStream({
530
- write(chunk) {
531
- chunks.push(chunk);
532
- }
533
- })
534
- );
535
- return chunks;
536
- }
515
+ import { CID } from "multiformats/cid";
516
+ import { sha256 as hasher } from "multiformats/hashes/sha2";
517
+ import { exception2Result, Result as Result2, top_uint8 } from "@adviser/cement";
537
518
  async function encodeFile(blob) {
538
- const readable = createFileEncoderStream(blob);
539
- const blocks = await collect(readable);
540
- return { cid: blocks.at(-1).cid, blocks };
519
+ const data = await top_uint8(blob);
520
+ const bytes = raw.encode(data);
521
+ const hash = await hasher.digest(bytes);
522
+ const cid = CID.create(1, raw.code, hash);
523
+ const block = { cid, bytes };
524
+ return { cid, blocks: [block] };
541
525
  }
542
- async function decodeFile(blocks, cid, meta) {
543
- const entry = await exporter(cid.toString(), blocks, { length: meta.size });
544
- const chunks = [];
545
- for await (const chunk of entry.content()) {
546
- chunks.push(chunk);
547
- }
548
- return new File(chunks, entry.name, { type: meta.type, lastModified: 0 });
526
+ function isHasBlockAGet(obj) {
527
+ return typeof obj.get === "function";
549
528
  }
550
- function createFileEncoderStream(blob) {
551
- const { readable, writable } = new TransformStream({}, queuingStrategy);
552
- const unixfsWriter = UnixFS.createWriter({ writable, settings });
553
- const fileBuilder = new UnixFSFileBuilder("", blob);
554
- void (async () => {
555
- await fileBuilder.finalize(unixfsWriter);
556
- await unixfsWriter.close();
557
- })();
558
- return readable;
529
+ async function decodeFile(blocks, cid, meta) {
530
+ if (!isHasBlockAGet(blocks)) {
531
+ return Result2.Err(new Error("Invalid block storage"));
532
+ }
533
+ return exception2Result(async () => {
534
+ const bytes = await blocks.get(cid);
535
+ const data = raw.decode(bytes);
536
+ return new File([data], "file", {
537
+ type: meta.type,
538
+ lastModified: meta.lastModified || 0
539
+ });
540
+ });
559
541
  }
560
- var UnixFSFileBuilder = class {
561
- #file;
562
- constructor(name, file) {
563
- this.name = name;
564
- this.#file = file;
565
- }
566
- async finalize(writer) {
567
- const unixfsFileWriter = UnixFS.createFileWriter(writer);
568
- await this.#file.stream().pipeTo(
569
- new WritableStream({
570
- async write(chunk) {
571
- await unixfsFileWriter.write(chunk);
572
- }
573
- })
574
- );
575
- return await unixfsFileWriter.close();
576
- }
577
- };
578
542
 
579
543
  // src/runtime/key-bag.ts
580
544
  var key_bag_exports = {};
@@ -591,7 +555,7 @@ import {
591
555
  KeyedResolvOnce,
592
556
  ResolveOnce as ResolveOnce2,
593
557
  ResolveSeq,
594
- Result as Result2,
558
+ Result as Result3,
595
559
  runtimeFn as runtimeFn2,
596
560
  toCryptoRuntime as toCryptoRuntime2,
597
561
  URI as URI3
@@ -721,7 +685,7 @@ async function toKeyWithFingerPrint(keybag, materialStrOrUint8) {
721
685
  }
722
686
  const key = await keybag.subtleKey(material);
723
687
  const fpr = await keybag.rt.crypto.digestSHA256(material);
724
- return Result2.Ok({
688
+ return Result3.Ok({
725
689
  key,
726
690
  fingerPrint: base58btc2.encode(new Uint8Array(fpr)),
727
691
  extract: async () => {
@@ -777,13 +741,13 @@ var keysByFingerprint = class _keysByFingerprint {
777
741
  def = !!def;
778
742
  const rKfp = await toKeyWithFingerPrint(this.keybag, materialStrOrUint8);
779
743
  if (rKfp.isErr()) {
780
- return Result2.Err(rKfp);
744
+ return Result3.Err(rKfp);
781
745
  }
782
746
  const kfp = rKfp.Ok();
783
747
  let found = this.keys[kfp.fingerPrint];
784
748
  if (found) {
785
749
  if (found.default === def) {
786
- return Result2.Ok({
750
+ return Result3.Ok({
787
751
  modified: false,
788
752
  kfp: found
789
753
  });
@@ -803,7 +767,7 @@ var keysByFingerprint = class _keysByFingerprint {
803
767
  if (keyBagAction) {
804
768
  this.keybag._upsertNamedKey(this);
805
769
  }
806
- return Result2.Ok({
770
+ return Result3.Ok({
807
771
  modified: keyBagAction && true,
808
772
  kfp: found
809
773
  });
@@ -882,24 +846,24 @@ var KeyBag = class {
882
846
  async ensureKeyFromUrl(url, keyFactory) {
883
847
  const storeKey = url.getParam(PARAM.STORE_KEY);
884
848
  if (storeKey === "insecure") {
885
- return Result2.Ok(url);
849
+ return Result3.Ok(url);
886
850
  }
887
851
  if (!storeKey) {
888
852
  const keyName = `@${keyFactory()}@`;
889
853
  const ret = await this.getNamedKey(keyName);
890
854
  if (ret.isErr()) {
891
- return Result2.Err(ret);
855
+ return Result3.Err(ret);
892
856
  }
893
857
  const urb = url.build().setParam(PARAM.STORE_KEY, keyName);
894
- return Result2.Ok(urb.URI());
858
+ return Result3.Ok(urb.URI());
895
859
  }
896
860
  if (storeKey.startsWith("@") && storeKey.endsWith("@")) {
897
861
  const ret = await this.getNamedKey(storeKey);
898
862
  if (ret.isErr()) {
899
- return Result2.Err(ret);
863
+ return Result3.Err(ret);
900
864
  }
901
865
  }
902
- return Result2.Ok(url);
866
+ return Result3.Ok(url);
903
867
  }
904
868
  async toKeysItem(ki) {
905
869
  if (!ki) return void 0;
@@ -958,7 +922,7 @@ var KeyBag = class {
958
922
  this._namedKeyCache.unget(ksi.name);
959
923
  }
960
924
  await bag.set(await ksi.asKeysItem());
961
- return Result2.Ok(ksi);
925
+ return Result3.Ok(ksi);
962
926
  });
963
927
  }
964
928
  async _getNamedKey(name, failIfNotFound, material) {
@@ -968,7 +932,7 @@ var KeyBag = class {
968
932
  const named = await this.toKeysItem(await bag.get(name));
969
933
  if (named) {
970
934
  this.logger.Debug().Str("id", id).Str("name", name).Any("fprs", Object.keys(named.keys)).Msg("fingerPrint getNamedKey");
971
- return Result2.Ok(await keysByFingerprint.from(this, named));
935
+ return Result3.Ok(await keysByFingerprint.from(this, named));
972
936
  }
973
937
  if (!named && failIfNotFound) {
974
938
  this._namedKeyCache.unget(name);
@@ -989,10 +953,10 @@ var KeyBag = class {
989
953
  }
990
954
  const res = await kp.upsert(keyMaterial, true);
991
955
  if (res.isErr()) {
992
- return Result2.Err(res);
956
+ return Result3.Err(res);
993
957
  }
994
958
  this.logger.Debug().Str("id", id).Str("name", name).Str("fpr", res.Ok().kfp.fingerPrint).Msg("createKey getNamedKey-post");
995
- return Result2.Ok(kp);
959
+ return Result3.Ok(kp);
996
960
  });
997
961
  }
998
962
  async getNamedKey(name, failIfNotFound = false, material) {
@@ -1110,10 +1074,9 @@ var FILESTORE_VERSION = "v0.19-file";
1110
1074
  var INDEXEDDB_VERSION = "v0.19-indexeddb";
1111
1075
 
1112
1076
  // src/runtime/gateways/file/gateway-impl.ts
1113
- import { exception2Result, KeyedResolvOnce as KeyedResolvOnce2, Result as Result3 } from "@adviser/cement";
1077
+ import { exception2Result as exception2Result2, KeyedResolvOnce as KeyedResolvOnce2, Result as Result4 } from "@adviser/cement";
1114
1078
 
1115
1079
  // src/runtime/gateways/file/utils.ts
1116
- import { getStore as getStore2 } from "@fireproof/core";
1117
1080
  function getPath(url, sthis) {
1118
1081
  const basePath = url.pathname;
1119
1082
  const name = url.getParam("name");
@@ -1125,7 +1088,7 @@ function getPath(url, sthis) {
1125
1088
  function getFileName(url, sthis) {
1126
1089
  const key = url.getParam("key");
1127
1090
  if (!key) throw sthis.logger.Error().Url(url).Msg(`key not found`).AsError();
1128
- const res = getStore2(url, sthis, (...a) => a.join("-"));
1091
+ const res = getStore(url, sthis, (...a) => a.join("-"));
1129
1092
  switch (res.fromUrl) {
1130
1093
  case "file":
1131
1094
  return sthis.pathOps.join(res.name, key);
@@ -1165,7 +1128,7 @@ var FileGateway = class {
1165
1128
  });
1166
1129
  }
1167
1130
  start(baseURL, sthis) {
1168
- return exception2Result(async () => {
1131
+ return exception2Result2(async () => {
1169
1132
  await this.fs.start();
1170
1133
  const url = baseURL.build();
1171
1134
  url.defParam(PARAM.VERSION, FILESTORE_VERSION);
@@ -1179,10 +1142,10 @@ var FileGateway = class {
1179
1142
  });
1180
1143
  }
1181
1144
  async buildUrl(baseUrl, key) {
1182
- return Result3.Ok(baseUrl.build().setParam(PARAM.KEY, key).URI());
1145
+ return Result4.Ok(baseUrl.build().setParam(PARAM.KEY, key).URI());
1183
1146
  }
1184
1147
  async close() {
1185
- return Result3.Ok(void 0);
1148
+ return Result4.Ok(void 0);
1186
1149
  }
1187
1150
  getFilePath(url, sthis) {
1188
1151
  const key = url.getParam(PARAM.KEY);
@@ -1190,7 +1153,7 @@ var FileGateway = class {
1190
1153
  return sthis.pathOps.join(getPath(url, sthis), getFileName(url, sthis));
1191
1154
  }
1192
1155
  async put(url, bytes, sthis) {
1193
- return exception2Result(async () => {
1156
+ return exception2Result2(async () => {
1194
1157
  const file = await this.getFilePath(url, sthis);
1195
1158
  sthis.logger.Debug().Str("url", url.toString()).Str("file", file).Msg("put");
1196
1159
  await this.fs.writefile(file, bytes);
@@ -1202,17 +1165,17 @@ var FileGateway = class {
1202
1165
  try {
1203
1166
  sthis.logger.Debug().Url(url).Str("file", file).Msg("get");
1204
1167
  const res = await this.fs.readfile(file);
1205
- return Result3.Ok(res);
1168
+ return Result4.Ok(res);
1206
1169
  } catch (e) {
1207
1170
  if (isNotFoundError(e)) {
1208
- return Result3.Err(new NotFoundError(`file not found: ${file}`));
1171
+ return Result4.Err(new NotFoundError(`file not found: ${file}`));
1209
1172
  }
1210
- return Result3.Err(e);
1173
+ return Result4.Err(e);
1211
1174
  }
1212
1175
  });
1213
1176
  }
1214
1177
  async delete(url, sthis) {
1215
- return exception2Result(async () => {
1178
+ return exception2Result2(async () => {
1216
1179
  await this.fs.unlink(this.getFilePath(url, sthis));
1217
1180
  });
1218
1181
  }
@@ -1238,7 +1201,7 @@ var FileGateway = class {
1238
1201
  }
1239
1202
  }
1240
1203
  }
1241
- return Result3.Ok(void 0);
1204
+ return Result4.Ok(void 0);
1242
1205
  }
1243
1206
  async getPlain(iurl, key, sthis) {
1244
1207
  const url = iurl.build().setParam(PARAM.KEY, key).URI();
@@ -1246,7 +1209,7 @@ var FileGateway = class {
1246
1209
  sthis.logger.Debug().Url(url).Str("dbFile", dbFile).Msg("get");
1247
1210
  const buffer = await this.fs.readfile(dbFile);
1248
1211
  sthis.logger.Debug().Url(url).Str("dbFile", dbFile).Len(buffer).Msg("got");
1249
- return Result3.Ok(buffer);
1212
+ return Result4.Ok(buffer);
1250
1213
  }
1251
1214
  };
1252
1215
 
@@ -1255,7 +1218,7 @@ var gateway_exports = {};
1255
1218
  __export(gateway_exports, {
1256
1219
  MemoryGateway: () => MemoryGateway
1257
1220
  });
1258
- import { Result as Result4 } from "@adviser/cement";
1221
+ import { Result as Result5 } from "@adviser/cement";
1259
1222
 
1260
1223
  // src/runtime/gateways/memory/version.ts
1261
1224
  var MEMORY_VERSION = "v0.19-memory";
@@ -1268,14 +1231,14 @@ var MemoryGateway = class {
1268
1231
  this.sthis = sthis;
1269
1232
  }
1270
1233
  buildUrl(baseUrl, key) {
1271
- return Promise.resolve(Result4.Ok(baseUrl.build().setParam(PARAM.KEY, key).URI()));
1234
+ return Promise.resolve(Result5.Ok(baseUrl.build().setParam(PARAM.KEY, key).URI()));
1272
1235
  }
1273
1236
  start(baseUrl) {
1274
- return Promise.resolve(Result4.Ok(baseUrl.build().setParam(PARAM.VERSION, MEMORY_VERSION).URI()));
1237
+ return Promise.resolve(Result5.Ok(baseUrl.build().setParam(PARAM.VERSION, MEMORY_VERSION).URI()));
1275
1238
  }
1276
1239
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1277
1240
  close(baseUrl) {
1278
- return Promise.resolve(Result4.Ok(void 0));
1241
+ return Promise.resolve(Result5.Ok(void 0));
1279
1242
  }
1280
1243
  destroy(baseUrl) {
1281
1244
  const keyUrl = baseUrl.toString();
@@ -1285,38 +1248,38 @@ var MemoryGateway = class {
1285
1248
  }
1286
1249
  }
1287
1250
  this.memorys.clear();
1288
- return Promise.resolve(Result4.Ok(void 0));
1251
+ return Promise.resolve(Result5.Ok(void 0));
1289
1252
  }
1290
1253
  async put(url, bytes) {
1291
1254
  this.memorys.set(url.toString(), bytes);
1292
- return Result4.Ok(void 0);
1255
+ return Result5.Ok(void 0);
1293
1256
  }
1294
1257
  // get could return a NotFoundError if the key is not found
1295
1258
  get(url) {
1296
1259
  const x = this.memorys.get(url.toString());
1297
1260
  if (!x) {
1298
- return Promise.resolve(Result4.Err(new NotFoundError(`not found: ${url.toString()}`)));
1261
+ return Promise.resolve(Result5.Err(new NotFoundError(`not found: ${url.toString()}`)));
1299
1262
  }
1300
- return Promise.resolve(Result4.Ok(x));
1263
+ return Promise.resolve(Result5.Ok(x));
1301
1264
  }
1302
1265
  delete(url) {
1303
1266
  this.memorys.delete(url.toString());
1304
- return Promise.resolve(Result4.Ok(void 0));
1267
+ return Promise.resolve(Result5.Ok(void 0));
1305
1268
  }
1306
1269
  async getPlain(url, key) {
1307
1270
  const x = this.memorys.get(url.build().setParam(PARAM.KEY, key).toString());
1308
1271
  if (!x) {
1309
- return Result4.Err(new NotFoundError("not found"));
1272
+ return Result5.Err(new NotFoundError("not found"));
1310
1273
  }
1311
- return Result4.Ok(x);
1274
+ return Result5.Ok(x);
1312
1275
  }
1313
1276
  };
1314
1277
 
1315
1278
  // src/runtime/gateways/def-serde-gateway.ts
1316
- import { Result as Result7 } from "@adviser/cement";
1279
+ import { Result as Result8 } from "@adviser/cement";
1317
1280
 
1318
1281
  // src/blockstore/fp-envelope.ts
1319
- import { Result as Result5 } from "@adviser/cement";
1282
+ import { Result as Result6 } from "@adviser/cement";
1320
1283
  var FPEnvelopeTypes = {
1321
1284
  CAR: "car",
1322
1285
  FILE: "file",
@@ -1324,17 +1287,17 @@ var FPEnvelopeTypes = {
1324
1287
  WAL: "wal"
1325
1288
  };
1326
1289
  function Car2FPMsg(fpcar) {
1327
- return Result5.Ok({ type: FPEnvelopeTypes.CAR, payload: fpcar });
1290
+ return Result6.Ok({ type: FPEnvelopeTypes.CAR, payload: fpcar });
1328
1291
  }
1329
1292
  function File2FPMsg(fpfile) {
1330
- return Result5.Ok({ type: FPEnvelopeTypes.FILE, payload: fpfile });
1293
+ return Result6.Ok({ type: FPEnvelopeTypes.FILE, payload: fpfile });
1331
1294
  }
1332
1295
 
1333
1296
  // src/runtime/gateways/fp-envelope-serialize.ts
1334
- import { exception2Result as exception2Result2, Result as Result6 } from "@adviser/cement";
1297
+ import { exception2Result as exception2Result3, Result as Result7 } from "@adviser/cement";
1335
1298
  import { decodeEventBlock, EventBlock } from "@fireproof/vendor/@web3-storage/pail/clock";
1336
1299
  import { base64pad } from "multiformats/bases/base64";
1337
- import { CID } from "multiformats";
1300
+ import { CID as CID2 } from "multiformats";
1338
1301
  import { fromJSON } from "multiformats/link";
1339
1302
  import { format, parse } from "@ipld/dag-json";
1340
1303
  async function dbMetaEvent2Serialized(sthis, dbEvents) {
@@ -1370,10 +1333,10 @@ function WALState2Serialized(sthis, wal) {
1370
1333
  return serializedWAL;
1371
1334
  }
1372
1335
  var defaultEncoder = {
1373
- car: async (sthis, payload) => Result6.Ok(payload),
1374
- file: async (sthis, payload) => Result6.Ok(payload),
1375
- meta: async (sthis, payload) => Result6.Ok(sthis.txt.encode(JSON.stringify(payload))),
1376
- wal: async (sthis, payload) => Result6.Ok(sthis.txt.encode(JSON.stringify(payload)))
1336
+ car: async (sthis, payload) => Result7.Ok(payload),
1337
+ file: async (sthis, payload) => Result7.Ok(payload),
1338
+ meta: async (sthis, payload) => Result7.Ok(sthis.txt.encode(JSON.stringify(payload))),
1339
+ wal: async (sthis, payload) => Result7.Ok(sthis.txt.encode(JSON.stringify(payload)))
1377
1340
  };
1378
1341
  async function fpSerialize(sthis, env, pencoder) {
1379
1342
  const encoder = {
@@ -1395,20 +1358,20 @@ async function fpSerialize(sthis, env, pencoder) {
1395
1358
  }
1396
1359
  async function decode2DbMetaEvents(sthis, rserializedMeta) {
1397
1360
  if (rserializedMeta.isErr()) {
1398
- return Result6.Err(rserializedMeta.Err());
1361
+ return Result7.Err(rserializedMeta.Err());
1399
1362
  }
1400
1363
  const serializedMeta = rserializedMeta.unwrap();
1401
1364
  if (!Array.isArray(serializedMeta)) {
1402
1365
  return sthis.logger.Debug().Any("metaEntries", serializedMeta).Msg("No data in MetaEntries").ResultError();
1403
1366
  }
1404
- return Result6.Ok(
1367
+ return Result7.Ok(
1405
1368
  await Promise.all(
1406
1369
  serializedMeta.map(async (metaEntry) => {
1407
1370
  const eventBlock = await decodeEventBlock(base64pad.decode(metaEntry.data));
1408
1371
  const dbMeta = parse(sthis.txt.decode(eventBlock.value.data.dbMeta));
1409
1372
  return {
1410
1373
  eventCid: eventBlock.cid,
1411
- parents: metaEntry.parents.map((i) => CID.parse(i)),
1374
+ parents: metaEntry.parents.map((i) => CID2.parse(i)),
1412
1375
  dbMeta
1413
1376
  };
1414
1377
  })
@@ -1417,16 +1380,16 @@ async function decode2DbMetaEvents(sthis, rserializedMeta) {
1417
1380
  }
1418
1381
  function toCid(sthis, link) {
1419
1382
  if (typeof link === "string") {
1420
- return CID.parse(link);
1383
+ return CID2.parse(link);
1421
1384
  }
1422
1385
  return fromJSON(link);
1423
1386
  }
1424
1387
  async function decode2WalState(sthis, rserializedWAL) {
1425
1388
  if (rserializedWAL.isErr()) {
1426
- return Result6.Err(rserializedWAL.Err());
1389
+ return Result7.Err(rserializedWAL.Err());
1427
1390
  }
1428
1391
  const serializedWAL = rserializedWAL.unwrap();
1429
- return Result6.Ok({
1392
+ return Result7.Ok({
1430
1393
  fileOperations: (serializedWAL.fileOperations || []).map((fop) => ({
1431
1394
  cid: toCid(sthis, fop.cid),
1432
1395
  public: !!fop.public
@@ -1440,16 +1403,16 @@ async function decode2WalState(sthis, rserializedWAL) {
1440
1403
  });
1441
1404
  }
1442
1405
  var defaultDecoder = {
1443
- car: async (sthis, payload) => Result6.Ok(payload),
1444
- file: async (sthis, payload) => Result6.Ok(payload),
1445
- meta: async (sthis, payload) => exception2Result2(() => JSON.parse(sthis.txt.decode(payload))),
1446
- wal: async (sthis, payload) => exception2Result2(() => JSON.parse(sthis.txt.decode(payload)))
1406
+ car: async (sthis, payload) => Result7.Ok(payload),
1407
+ file: async (sthis, payload) => Result7.Ok(payload),
1408
+ meta: async (sthis, payload) => exception2Result3(() => JSON.parse(sthis.txt.decode(payload))),
1409
+ wal: async (sthis, payload) => exception2Result3(() => JSON.parse(sthis.txt.decode(payload)))
1447
1410
  };
1448
1411
  function makeFPEnvelope(type, payload) {
1449
1412
  if (payload.isErr()) {
1450
- return Result6.Err(payload.Err());
1413
+ return Result7.Err(payload.Err());
1451
1414
  }
1452
- return Result6.Ok({
1415
+ return Result7.Ok({
1453
1416
  type,
1454
1417
  payload: payload.unwrap()
1455
1418
  });
@@ -1457,7 +1420,7 @@ function makeFPEnvelope(type, payload) {
1457
1420
  async function fpDeserialize(sthis, url, intoRaw, pdecoder) {
1458
1421
  const rraw = await coercePromiseIntoUint8(intoRaw);
1459
1422
  if (rraw.isErr()) {
1460
- return Result6.Err(rraw.Err());
1423
+ return Result7.Err(rraw.Err());
1461
1424
  }
1462
1425
  const raw2 = rraw.unwrap();
1463
1426
  const decoder = {
@@ -1508,12 +1471,12 @@ var DefSerdeGateway = class {
1508
1471
  }
1509
1472
  async get({ loader: { sthis }, decoder }, url) {
1510
1473
  const res = await this.gw.get(url, sthis);
1511
- if (res.isErr()) return Result7.Err(res.Err());
1474
+ if (res.isErr()) return Result8.Err(res.Err());
1512
1475
  return fpDeserialize(sthis, url, res, decoder);
1513
1476
  }
1514
1477
  async subscribe({ loader: { sthis }, decoder }, url, callback) {
1515
1478
  function rawCallback(raw2) {
1516
- return fpDeserialize(sthis, url, Result7.Ok(raw2), decoder).then((res) => {
1479
+ return fpDeserialize(sthis, url, Result8.Ok(raw2), decoder).then((res) => {
1517
1480
  if (res.isErr()) {
1518
1481
  sthis.logger.Error().Err(res).Msg("Failed to deserialize");
1519
1482
  return;
@@ -1523,12 +1486,12 @@ var DefSerdeGateway = class {
1523
1486
  }
1524
1487
  if (!this.gw.subscribe) {
1525
1488
  if (!url.hasParam(PARAM.SELF_REFLECT)) {
1526
- return Result7.Ok(() => {
1489
+ return Result8.Ok(() => {
1527
1490
  });
1528
1491
  }
1529
1492
  const urlWithoutKey = url.build().delParam(PARAM.KEY).delParam(PARAM.SELF_REFLECT).toString();
1530
1493
  this.subscribeFn.set(urlWithoutKey, rawCallback);
1531
- return Result7.Ok(() => {
1494
+ return Result8.Ok(() => {
1532
1495
  this.subscribeFn.delete(urlWithoutKey);
1533
1496
  });
1534
1497
  }
@@ -1649,58 +1612,58 @@ __export(block_exports, {
1649
1612
  Block: () => Block,
1650
1613
  create: () => create,
1651
1614
  createUnsafe: () => createUnsafe,
1652
- decode: () => decode,
1653
- encode: () => encode
1615
+ decode: () => decode2,
1616
+ encode: () => encode2
1654
1617
  });
1655
- import { bytes as binary, CID as CID2 } from "multiformats";
1618
+ import { bytes as binary, CID as CID3 } from "multiformats";
1656
1619
  import { Block as mfBlock } from "multiformats/block";
1657
1620
  var Block = mfBlock;
1658
- async function decode({
1621
+ async function decode2({
1659
1622
  bytes,
1660
1623
  codec: codec3,
1661
- hasher: hasher6
1624
+ hasher: hasher7
1662
1625
  }) {
1663
1626
  if (bytes == null) throw new Error('Missing required argument "bytes"');
1664
- if (codec3 == null || hasher6 == null) throw new Error("Missing required argument: codec or hasher");
1627
+ if (codec3 == null || hasher7 == null) throw new Error("Missing required argument: codec or hasher");
1665
1628
  const value = await Promise.resolve(codec3.decode(bytes));
1666
1629
  let toHash = bytes;
1667
1630
  if (codec3.valueToHashBytes) {
1668
1631
  toHash = await Promise.resolve(codec3.valueToHashBytes(value));
1669
1632
  }
1670
- const hash = await hasher6.digest(toHash);
1671
- const cid = CID2.create(1, codec3.code, hash);
1633
+ const hash = await hasher7.digest(toHash);
1634
+ const cid = CID3.create(1, codec3.code, hash);
1672
1635
  return new mfBlock({ value, bytes: toHash, cid });
1673
1636
  }
1674
- async function encode({
1637
+ async function encode2({
1675
1638
  value,
1676
1639
  codec: codec3,
1677
- hasher: hasher6
1640
+ hasher: hasher7
1678
1641
  }) {
1679
1642
  if (typeof value === "undefined") throw new Error('Missing required argument "value"');
1680
- if (codec3 == null || hasher6 == null) throw new Error("Missing required argument: codec or hasher");
1643
+ if (codec3 == null || hasher7 == null) throw new Error("Missing required argument: codec or hasher");
1681
1644
  let bytes;
1682
1645
  let hash;
1683
1646
  if (codec3.bytesToHash) {
1684
1647
  const hashable = await Promise.resolve(codec3.bytesToHash(value));
1685
- hash = await hasher6.digest(hashable);
1648
+ hash = await hasher7.digest(hashable);
1686
1649
  bytes = await Promise.resolve(codec3.encode(value));
1687
1650
  } else {
1688
1651
  bytes = await Promise.resolve(codec3.encode(value));
1689
- hash = await hasher6.digest(bytes);
1652
+ hash = await hasher7.digest(bytes);
1690
1653
  }
1691
- const cid = CID2.create(1, codec3.code, hash);
1654
+ const cid = CID3.create(1, codec3.code, hash);
1692
1655
  return new Block({ value, bytes, cid });
1693
1656
  }
1694
1657
  async function create({
1695
1658
  bytes,
1696
1659
  cid,
1697
- hasher: hasher6,
1660
+ hasher: hasher7,
1698
1661
  codec: codec3
1699
1662
  }) {
1700
1663
  if (bytes == null) throw new Error('Missing required argument "bytes"');
1701
- if (hasher6 == null) throw new Error('Missing required argument "hasher"');
1664
+ if (hasher7 == null) throw new Error('Missing required argument "hasher"');
1702
1665
  const value = await Promise.resolve(codec3.decode(bytes));
1703
- const hash = await hasher6.digest(bytes);
1666
+ const hash = await hasher7.digest(bytes);
1704
1667
  if (!binary.equals(cid.multihash.bytes, hash.bytes)) {
1705
1668
  throw new Error("CID hash does not match bytes");
1706
1669
  }
@@ -1727,7 +1690,7 @@ async function createUnsafe({
1727
1690
  }
1728
1691
 
1729
1692
  // src/indexer-helpers.ts
1730
- import { sha256 as hasher } from "multiformats/hashes/sha2";
1693
+ import { sha256 as hasher2 } from "multiformats/hashes/sha2";
1731
1694
  import * as codec from "@ipld/dag-cbor";
1732
1695
  import charwise from "charwise";
1733
1696
  import * as DbIndex from "prolly-trees/db-index";
@@ -1748,8 +1711,8 @@ function compare(a, b) {
1748
1711
  if (comp !== 0) return comp;
1749
1712
  return refCompare(aRef, bRef);
1750
1713
  }
1751
- var byKeyOpts = { cache, chunker: bf(30), codec, hasher, compare };
1752
- var byIdOpts = { cache, chunker: bf(30), codec, hasher, compare: simpleCompare };
1714
+ var byKeyOpts = { cache, chunker: bf(30), codec, hasher: hasher2, compare };
1715
+ var byIdOpts = { cache, chunker: bf(30), codec, hasher: hasher2, compare: simpleCompare };
1753
1716
  function indexEntriesForChanges(changes, mapFn) {
1754
1717
  const indexEntries = [];
1755
1718
  changes.forEach(({ id: key, value, del }) => {
@@ -1777,7 +1740,7 @@ function makeProllyGetBlock(blocks) {
1777
1740
  const block = await blocks.get(address);
1778
1741
  if (!block) throw new Error(`Missing block ${address.toString()}`);
1779
1742
  const { cid, bytes } = block;
1780
- return create({ cid, bytes, hasher, codec });
1743
+ return create({ cid, bytes, hasher: hasher2, codec });
1781
1744
  };
1782
1745
  }
1783
1746
  async function bulkIndex(logger, tblocks, inIndex, indexEntries, opts) {
@@ -2283,10 +2246,10 @@ var WALActiveStore = class extends BaseActiveStore {
2283
2246
  };
2284
2247
 
2285
2248
  // src/blockstore/store-factory.ts
2286
- import { KeyedResolvOnce as KeyedResolvOnce5, Result as Result10 } from "@adviser/cement";
2249
+ import { KeyedResolvOnce as KeyedResolvOnce5, Result as Result11 } from "@adviser/cement";
2287
2250
 
2288
2251
  // src/blockstore/store.ts
2289
- import { exception2Result as exception2Result3, ResolveOnce as ResolveOnce4, Result as Result9 } from "@adviser/cement";
2252
+ import { exception2Result as exception2Result4, ResolveOnce as ResolveOnce4, Result as Result10 } from "@adviser/cement";
2290
2253
 
2291
2254
  // src/blockstore/loader.ts
2292
2255
  import pLimit from "p-limit";
@@ -2294,13 +2257,13 @@ import { CarReader } from "@ipld/car/reader";
2294
2257
  import { KeyedResolvOnce as KeyedResolvOnce4, LRUSet, ResolveOnce as ResolveOnce3 } from "@adviser/cement";
2295
2258
 
2296
2259
  // src/blockstore/loader-helpers.ts
2297
- import { sha256 as hasher2 } from "multiformats/hashes/sha2";
2260
+ import { sha256 as hasher3 } from "multiformats/hashes/sha2";
2298
2261
  import * as dagCodec from "@ipld/dag-cbor";
2299
2262
  async function parseCarFile(reader, logger) {
2300
2263
  const roots = await reader.roots;
2301
2264
  const header = reader.blocks.find((i) => i.cid.equals(roots[0]));
2302
2265
  if (!header) throw logger.Error().Msg("missing header block").AsError();
2303
- const dec = await decode({ bytes: header.bytes, hasher: hasher2, codec: dagCodec });
2266
+ const dec = await decode2({ bytes: header.bytes, hasher: hasher3, codec: dagCodec });
2304
2267
  const fpvalue = dec.value;
2305
2268
  if (fpvalue && !fpvalue.fp) {
2306
2269
  throw logger.Error().Msg("missing fp").AsError();
@@ -2611,7 +2574,7 @@ async function encodeCarFile(roots, t, codec3) {
2611
2574
  writer.write({ cid, bytes });
2612
2575
  }
2613
2576
  writer.close();
2614
- return await encode({ value: writer.bytes, hasher: sha256, codec: codec3 });
2577
+ return await encode2({ value: writer.bytes, hasher: sha256, codec: codec3 });
2615
2578
  }
2616
2579
  async function createCarFile(encoder, cid, t) {
2617
2580
  return encodeCarFile([cid], t, encoder);
@@ -2649,7 +2612,7 @@ function makeCarHeader(meta, cars, compact = false) {
2649
2612
  return { ...coreHeader, meta };
2650
2613
  }
2651
2614
  async function encodeCarHeader(fp) {
2652
- return await encode({
2615
+ return await encode2({
2653
2616
  value: { fp },
2654
2617
  hasher: sha256,
2655
2618
  codec: dagCodec2
@@ -2694,7 +2657,7 @@ async function prepareCarFiles(encoder, threshold, rootBlock, t) {
2694
2657
  }
2695
2658
 
2696
2659
  // src/blockstore/loader.ts
2697
- import { sha256 as hasher3 } from "multiformats/hashes/sha2";
2660
+ import { sha256 as hasher4 } from "multiformats/hashes/sha2";
2698
2661
 
2699
2662
  // src/blockstore/task-manager.ts
2700
2663
  var TaskManager = class {
@@ -3374,7 +3337,7 @@ var Loader = class {
3374
3337
  if (!loadedCar) {
3375
3338
  throw this.logger.Error().Url(store.local().url()).Str("cid", carCidStr).Msg("missing car files").AsError();
3376
3339
  }
3377
- const bytes = await decode({ bytes: loadedCar.bytes, hasher: hasher3, codec: (await activeStore.keyedCrypto()).codec() });
3340
+ const bytes = await decode2({ bytes: loadedCar.bytes, hasher: hasher4, codec: (await activeStore.keyedCrypto()).codec() });
3378
3341
  const rawReader = await CarReader.fromBytes(bytes.value.data);
3379
3342
  const blocks = [];
3380
3343
  for await (const block of rawReader.blocks()) {
@@ -3415,7 +3378,7 @@ __export(keyed_crypto_exports, {
3415
3378
  keyedCryptoFactory: () => keyedCryptoFactory
3416
3379
  });
3417
3380
  import { base58btc as base58btc3 } from "multiformats/bases/base58";
3418
- import { sha256 as hasher4 } from "multiformats/hashes/sha2";
3381
+ import { sha256 as hasher5 } from "multiformats/hashes/sha2";
3419
3382
  import * as CBOR from "cborg";
3420
3383
  var generateIV = {
3421
3384
  random: {
@@ -3430,7 +3393,7 @@ var generateIV = {
3430
3393
  },
3431
3394
  hash: {
3432
3395
  calc: async (ko, crypto, data) => {
3433
- const hash = await hasher4.digest(data);
3396
+ const hash = await hasher5.digest(data);
3434
3397
  const hashBytes = new Uint8Array(hash.bytes);
3435
3398
  const hashArray = new Uint8Array(ko.ivLength);
3436
3399
  for (let i = 0; i < hashBytes.length; i++) {
@@ -3618,39 +3581,39 @@ import pRetry from "p-retry";
3618
3581
  import pMap from "p-map";
3619
3582
 
3620
3583
  // src/blockstore/interceptor-gateway.ts
3621
- import { Result as Result8 } from "@adviser/cement";
3584
+ import { Result as Result9 } from "@adviser/cement";
3622
3585
  var PassThroughGateway = class {
3623
3586
  async buildUrl(ctx, url, key) {
3624
3587
  const op = { url, key };
3625
- return Result8.Ok({ op });
3588
+ return Result9.Ok({ op });
3626
3589
  }
3627
3590
  async start(ctx, url) {
3628
3591
  const op = { url };
3629
- return Result8.Ok({ op });
3592
+ return Result9.Ok({ op });
3630
3593
  }
3631
3594
  async close(ctx, url) {
3632
3595
  const op = { url };
3633
- return Result8.Ok({ op });
3596
+ return Result9.Ok({ op });
3634
3597
  }
3635
3598
  async delete(ctx, url) {
3636
3599
  const op = { url };
3637
- return Result8.Ok({ op });
3600
+ return Result9.Ok({ op });
3638
3601
  }
3639
3602
  async destroy(ctx, url) {
3640
3603
  const op = { url };
3641
- return Result8.Ok({ op });
3604
+ return Result9.Ok({ op });
3642
3605
  }
3643
3606
  async put(ctx, url, body) {
3644
3607
  const op = { url, body };
3645
- return Result8.Ok({ op });
3608
+ return Result9.Ok({ op });
3646
3609
  }
3647
3610
  async get(ctx, url) {
3648
3611
  const op = { url };
3649
- return Result8.Ok({ op });
3612
+ return Result9.Ok({ op });
3650
3613
  }
3651
3614
  async subscribe(ctx, url, callback) {
3652
3615
  const op = { url, callback };
3653
- return Result8.Ok({ op });
3616
+ return Result9.Ok({ op });
3654
3617
  }
3655
3618
  };
3656
3619
  var passThrougthGateway = new PassThroughGateway();
@@ -3662,7 +3625,7 @@ var InterceptorGateway = class {
3662
3625
  async buildUrl(ctx, baseUrl, key) {
3663
3626
  const rret = await this.interceptor.buildUrl(ctx, baseUrl, key);
3664
3627
  if (rret.isErr()) {
3665
- return Result8.Err(rret.Err());
3628
+ return Result9.Err(rret.Err());
3666
3629
  }
3667
3630
  const ret = rret.unwrap();
3668
3631
  if (ret.stop && ret.value) {
@@ -3673,7 +3636,7 @@ var InterceptorGateway = class {
3673
3636
  async destroy(ctx, iurl) {
3674
3637
  const rret = await this.interceptor.destroy(ctx, iurl);
3675
3638
  if (rret.isErr()) {
3676
- return Result8.Err(rret.Err());
3639
+ return Result9.Err(rret.Err());
3677
3640
  }
3678
3641
  const ret = rret.unwrap();
3679
3642
  if (ret.stop && ret.value) {
@@ -3684,7 +3647,7 @@ var InterceptorGateway = class {
3684
3647
  async start(ctx, url) {
3685
3648
  const rret = await this.interceptor.start(ctx, url);
3686
3649
  if (rret.isErr()) {
3687
- return Result8.Err(rret.Err());
3650
+ return Result9.Err(rret.Err());
3688
3651
  }
3689
3652
  const ret = rret.unwrap();
3690
3653
  if (ret.stop && ret.value) {
@@ -3695,7 +3658,7 @@ var InterceptorGateway = class {
3695
3658
  async close(ctx, url) {
3696
3659
  const rret = await this.interceptor.close(ctx, url);
3697
3660
  if (rret.isErr()) {
3698
- return Result8.Err(rret.Err());
3661
+ return Result9.Err(rret.Err());
3699
3662
  }
3700
3663
  const ret = rret.unwrap();
3701
3664
  if (ret.stop && ret.value) {
@@ -3706,7 +3669,7 @@ var InterceptorGateway = class {
3706
3669
  async put(ctx, url, fpEnv) {
3707
3670
  const rret = await this.interceptor.put(ctx, url, fpEnv);
3708
3671
  if (rret.isErr()) {
3709
- return Result8.Err(rret.Err());
3672
+ return Result9.Err(rret.Err());
3710
3673
  }
3711
3674
  const ret = rret.unwrap();
3712
3675
  if (ret.stop && ret.value) {
@@ -3717,7 +3680,7 @@ var InterceptorGateway = class {
3717
3680
  async get(ctx, url) {
3718
3681
  const rret = await this.interceptor.get(ctx, url);
3719
3682
  if (rret.isErr()) {
3720
- return Result8.Err(rret.Err());
3683
+ return Result9.Err(rret.Err());
3721
3684
  }
3722
3685
  const ret = rret.unwrap();
3723
3686
  if (ret.stop && ret.value) {
@@ -3727,11 +3690,11 @@ var InterceptorGateway = class {
3727
3690
  }
3728
3691
  async subscribe(ctx, url, callback) {
3729
3692
  if (!this.innerGW.subscribe) {
3730
- return Result8.Err(ctx.loader.sthis.logger.Error().Url(url).Msg("subscribe not supported").AsError());
3693
+ return Result9.Err(ctx.loader.sthis.logger.Error().Url(url).Msg("subscribe not supported").AsError());
3731
3694
  }
3732
3695
  const rret = await this.interceptor.subscribe(ctx, url, callback);
3733
3696
  if (rret.isErr()) {
3734
- return Result8.Err(rret.Err());
3697
+ return Result9.Err(rret.Err());
3735
3698
  }
3736
3699
  const ret = rret.unwrap();
3737
3700
  if (ret.stop && ret.value) {
@@ -3742,7 +3705,7 @@ var InterceptorGateway = class {
3742
3705
  async delete(ctx, url) {
3743
3706
  const rret = await this.interceptor.delete(ctx, url);
3744
3707
  if (rret.isErr()) {
3745
- return Result8.Err(rret.Err());
3708
+ return Result9.Err(rret.Err());
3746
3709
  }
3747
3710
  const ret = rret.unwrap();
3748
3711
  if (ret.stop && ret.value) {
@@ -3758,9 +3721,9 @@ var InterceptorGateway = class {
3758
3721
  // src/blockstore/store.ts
3759
3722
  function guardVersion(url) {
3760
3723
  if (!url.hasParam("version")) {
3761
- return Result9.Err(`missing version: ${url.toString()}`);
3724
+ return Result10.Err(`missing version: ${url.toString()}`);
3762
3725
  }
3763
- return Result9.Ok(url);
3726
+ return Result10.Ok(url);
3764
3727
  }
3765
3728
  var BaseStoreImpl = class {
3766
3729
  // readonly loader: Loadable;
@@ -3820,7 +3783,7 @@ var BaseStoreImpl = class {
3820
3783
  }
3821
3784
  if (this.ready) {
3822
3785
  const fn = this.ready.bind(this);
3823
- const ready = await exception2Result3(fn);
3786
+ const ready = await exception2Result4(fn);
3824
3787
  if (ready.isErr()) {
3825
3788
  await this.close();
3826
3789
  return ready;
@@ -3927,7 +3890,7 @@ var MetaStoreImpl = class extends BaseStoreImpl {
3927
3890
  async close() {
3928
3891
  await this.gateway.close({ loader: this.loader }, this.url());
3929
3892
  this._onClosed.forEach((fn) => fn());
3930
- return Result9.Ok(void 0);
3893
+ return Result10.Ok(void 0);
3931
3894
  }
3932
3895
  async destroy() {
3933
3896
  this.logger.Debug().Msg("destroy");
@@ -3994,7 +3957,7 @@ var DataStoreImpl = class extends BaseStoreImpl {
3994
3957
  async close() {
3995
3958
  await this.gateway.close({ loader: this.loader }, this.url());
3996
3959
  this._onClosed.forEach((fn) => fn());
3997
- return Result9.Ok(void 0);
3960
+ return Result10.Ok(void 0);
3998
3961
  }
3999
3962
  destroy() {
4000
3963
  this.logger.Debug().Msg("destroy");
@@ -4196,7 +4159,7 @@ var WALStoreImpl = class extends BaseStoreImpl {
4196
4159
  async close() {
4197
4160
  await this.gateway.close({ loader: this.loader }, this.url());
4198
4161
  this._onClosed.forEach((fn) => fn());
4199
- return Result9.Ok(void 0);
4162
+ return Result10.Ok(void 0);
4200
4163
  }
4201
4164
  destroy() {
4202
4165
  this.logger.Debug().Msg("destroy");
@@ -4219,12 +4182,12 @@ async function getStartedGateway(ctx, url) {
4219
4182
  };
4220
4183
  const res = await ret.gateway.start(ctx, url);
4221
4184
  if (res.isErr()) {
4222
- return Result10.Err(ctx.loader.sthis.logger.Error().Result("start", res).Msg("start failed").AsError());
4185
+ return Result11.Err(ctx.loader.sthis.logger.Error().Result("start", res).Msg("start failed").AsError());
4223
4186
  }
4224
4187
  ret.url = res.Ok();
4225
- return Result10.Ok(ret);
4188
+ return Result11.Ok(ret);
4226
4189
  }
4227
- return Result10.Err(ctx.loader.sthis.logger.Warn().Url(url).Msg("unsupported protocol").AsError());
4190
+ return Result11.Err(ctx.loader.sthis.logger.Warn().Url(url).Msg("unsupported protocol").AsError());
4228
4191
  });
4229
4192
  }
4230
4193
  async function carStoreFactory(ctx, uai) {
@@ -4328,7 +4291,7 @@ function toStoreRuntime(sthis, endeOpts = {}) {
4328
4291
 
4329
4292
  // src/crdt-helpers.ts
4330
4293
  import { parse as parse2 } from "multiformats/link";
4331
- import { sha256 as hasher5 } from "multiformats/hashes/sha2";
4294
+ import { sha256 as hasher6 } from "multiformats/hashes/sha2";
4332
4295
  import * as codec2 from "@ipld/dag-cbor";
4333
4296
  import { put, get, entries, root } from "@fireproof/vendor/@web3-storage/pail/crdt";
4334
4297
  import { EventFetcher, vis } from "@fireproof/vendor/@web3-storage/pail/clock";
@@ -4415,7 +4378,7 @@ async function writeDocContent(store, blocks, update, logger) {
4415
4378
  await processFiles(store, blocks, update.value, logger);
4416
4379
  value = { doc: update.value };
4417
4380
  }
4418
- const block = await encode({ value, hasher: hasher5, codec: codec2 });
4381
+ const block = await encode2({ value, hasher: hasher6, codec: codec2 });
4419
4382
  blocks.putSync(block.cid, block.bytes);
4420
4383
  return block.cid;
4421
4384
  }
@@ -4446,11 +4409,11 @@ async function processFileset(logger, store, blocks, files) {
4446
4409
  for (const block of fileBlocks) {
4447
4410
  t.putSync(block.cid, block.bytes);
4448
4411
  }
4449
- files[filename] = { cid, type: file.type, size: file.size };
4412
+ files[filename] = { cid, type: file.type, size: file.size, lastModified: file.lastModified };
4450
4413
  } else {
4451
- const { cid, type, size, car } = files[filename];
4414
+ const { cid, type, size, car, lastModified } = files[filename];
4452
4415
  if (cid && type && size && car) {
4453
- files[filename] = { cid, type, size, car };
4416
+ files[filename] = { cid, type, size, car, lastModified };
4454
4417
  }
4455
4418
  }
4456
4419
  }
@@ -4490,15 +4453,21 @@ function readFileset(blocks, files, isPublic = false) {
4490
4453
  fileMeta.url = `https://${fileMeta.cid.toString()}.ipfs.w3s.link/`;
4491
4454
  }
4492
4455
  if (fileMeta.car) {
4493
- fileMeta.file = async () => await blocks.ebOpts.storeRuntime.decodeFile(
4494
- {
4495
- get: async (cid) => {
4496
- return await blocks.getFile(throwFalsy(fileMeta.car), cid);
4497
- }
4498
- },
4499
- fileMeta.cid,
4500
- fileMeta
4501
- );
4456
+ fileMeta.file = async () => {
4457
+ const result = await blocks.ebOpts.storeRuntime.decodeFile(
4458
+ {
4459
+ get: async (cid) => {
4460
+ return await blocks.getFile(throwFalsy(fileMeta.car), cid);
4461
+ }
4462
+ },
4463
+ fileMeta.cid,
4464
+ fileMeta
4465
+ );
4466
+ if (result.isErr()) {
4467
+ throw blocks.logger.Error().Any("error", result.Err()).Any("cid", fileMeta.cid).Msg("Error decoding file").AsError();
4468
+ }
4469
+ return result.unwrap();
4470
+ };
4502
4471
  }
4503
4472
  }
4504
4473
  files[filename] = fileMeta;
@@ -4507,7 +4476,7 @@ function readFileset(blocks, files, isPublic = false) {
4507
4476
  async function getValueFromLink(blocks, link, logger) {
4508
4477
  const block = await blocks.get(link);
4509
4478
  if (!block) throw logger.Error().Str("link", link.toString()).Msg(`Missing linked block`).AsError();
4510
- const { value } = await decode({ bytes: block.bytes, hasher: hasher5, codec: codec2 });
4479
+ const { value } = await decode2({ bytes: block.bytes, hasher: hasher6, codec: codec2 });
4511
4480
  const cvalue = {
4512
4481
  ...value,
4513
4482
  cid: link
@@ -4633,7 +4602,7 @@ async function doCompact(blockLog, head, logger) {
4633
4602
  async function getBlock(blocks, cidString) {
4634
4603
  const block = await blocks.get(parse2(cidString));
4635
4604
  if (!block) throw new Error(`Missing block ${cidString}`);
4636
- const { cid, value } = await decode({ bytes: block.bytes, codec: codec2, hasher: hasher5 });
4605
+ const { cid, value } = await decode2({ bytes: block.bytes, codec: codec2, hasher: hasher6 });
4637
4606
  return new Block({ cid, value, bytes: block.bytes });
4638
4607
  }
4639
4608
 
@@ -5257,7 +5226,7 @@ __export(file_exports, {
5257
5226
 
5258
5227
  // src/version.ts
5259
5228
  var PACKAGE_VERSION = Object.keys({
5260
- "0.20.0-dev-preview-53": "xxxx"
5229
+ "0.20.0-dev-preview-54": "xxxx"
5261
5230
  })[0];
5262
5231
  export {
5263
5232
  CRDTImpl,