@fireproof/core 0.17.3 → 0.17.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/browser/fireproof.cjs +9 -3
- package/dist/browser/fireproof.cjs.map +1 -1
- package/dist/browser/fireproof.d.cts +15 -12
- package/dist/browser/fireproof.d.ts +15 -12
- package/dist/browser/fireproof.global.js +51 -34
- package/dist/browser/fireproof.global.js.map +1 -1
- package/dist/browser/fireproof.js +13 -3
- package/dist/browser/fireproof.js.map +1 -1
- package/dist/browser/metafile-cjs.json +1 -1
- package/dist/browser/metafile-esm.json +1 -1
- package/dist/browser/metafile-iife.json +1 -1
- package/dist/memory/fireproof.cjs +9 -3
- package/dist/memory/fireproof.cjs.map +1 -1
- package/dist/memory/fireproof.d.cts +15 -12
- package/dist/memory/fireproof.d.ts +15 -12
- package/dist/memory/fireproof.global.js +51 -34
- package/dist/memory/fireproof.global.js.map +1 -1
- package/dist/memory/fireproof.js +13 -3
- package/dist/memory/fireproof.js.map +1 -1
- package/dist/memory/metafile-cjs.json +1 -1
- package/dist/memory/metafile-esm.json +1 -1
- package/dist/memory/metafile-iife.json +1 -1
- package/dist/node/fireproof.cjs +3 -2
- package/dist/node/fireproof.cjs.map +1 -1
- package/dist/node/fireproof.d.cts +15 -12
- package/dist/node/fireproof.d.ts +15 -12
- package/dist/node/fireproof.global.js +46 -25
- package/dist/node/fireproof.global.js.map +1 -1
- package/dist/node/fireproof.js +3 -2
- package/dist/node/fireproof.js.map +1 -1
- package/dist/node/metafile-cjs.json +1 -1
- package/dist/node/metafile-esm.json +1 -1
- package/dist/node/metafile-iife.json +1 -1
- package/package.json +7 -4
@@ -9936,8 +9936,7 @@ You can use close({ resize: true }) to resize header`);
|
|
9936
9936
|
return uint8Array;
|
9937
9937
|
}
|
9938
9938
|
async function encryptedEncodeCarFile(crypto22, key, rootCid, t) {
|
9939
|
-
const
|
9940
|
-
const encryptionKey = encryptionKeyUint8.buffer.slice(0, encryptionKeyUint8.byteLength);
|
9939
|
+
const encryptionKey = hexStringToUint8Array(key);
|
9941
9940
|
const encryptedBlocks = new MemoryBlockstore();
|
9942
9941
|
const cidsToEncrypt = [];
|
9943
9942
|
for (const { cid } of t.entries()) {
|
@@ -10014,7 +10013,7 @@ You can use close({ resize: true }) to resize header`);
|
|
10014
10013
|
}
|
10015
10014
|
return bytes;
|
10016
10015
|
}
|
10017
|
-
var PACKAGE_VERSION = "0.
|
10016
|
+
var PACKAGE_VERSION = "0.17.3";
|
10018
10017
|
var match = PACKAGE_VERSION.match(/^([^.]*\.[^.]*)/);
|
10019
10018
|
if (!match)
|
10020
10019
|
throw new Error("invalid version: " + PACKAGE_VERSION);
|
@@ -10090,11 +10089,11 @@ You can use close({ resize: true }) to resize header`);
|
|
10090
10089
|
constructor(name7, ebOpts) {
|
10091
10090
|
this.name = name7;
|
10092
10091
|
this.ebOpts = ebOpts;
|
10093
|
-
this.
|
10094
|
-
this.
|
10095
|
-
this.
|
10096
|
-
this.remoteWAL = new ebOpts.store.RemoteWAL(this);
|
10092
|
+
this.carStore = ebOpts.store.makeDataStore(this.name);
|
10093
|
+
this.fileStore = ebOpts.store.makeDataStore(this.name);
|
10094
|
+
this.remoteWAL = ebOpts.store.makeRemoteWAL(this);
|
10097
10095
|
this.ready = Promise.resolve().then(async () => {
|
10096
|
+
this.metaStore = ebOpts.store.makeMetaStore(this);
|
10098
10097
|
if (!this.metaStore || !this.carStore || !this.remoteWAL)
|
10099
10098
|
throw new Error("stores not initialized");
|
10100
10099
|
const metas = this.ebOpts.meta ? [this.ebOpts.meta] : await this.metaStore.load("main");
|
@@ -10268,19 +10267,30 @@ You can use close({ resize: true }) to resize header`);
|
|
10268
10267
|
const sCid = cid.toString();
|
10269
10268
|
if (this.getBlockCache.has(sCid))
|
10270
10269
|
return this.getBlockCache.get(sCid);
|
10271
|
-
const
|
10272
|
-
|
10273
|
-
|
10274
|
-
|
10275
|
-
|
10276
|
-
|
10277
|
-
|
10278
|
-
|
10279
|
-
|
10280
|
-
|
10281
|
-
|
10282
|
-
|
10283
|
-
|
10270
|
+
const getCarCid = async (carCid) => {
|
10271
|
+
const reader = await this.loadCar(carCid);
|
10272
|
+
if (!reader) {
|
10273
|
+
throw new Error(`missing car reader ${carCid.toString()}`);
|
10274
|
+
}
|
10275
|
+
await this.cacheCarReader(reader);
|
10276
|
+
if (this.getBlockCache.has(sCid))
|
10277
|
+
return this.getBlockCache.get(sCid);
|
10278
|
+
throw new Error(`block not in reader: ${cid.toString()}`);
|
10279
|
+
};
|
10280
|
+
let got;
|
10281
|
+
const batchSize = 5;
|
10282
|
+
for (let i = 0; i < this.carLog.length; i += batchSize) {
|
10283
|
+
const promises = [];
|
10284
|
+
for (let j = i; j < Math.min(i + batchSize, this.carLog.length); j++) {
|
10285
|
+
promises.push(getCarCid(this.carLog[j]));
|
10286
|
+
}
|
10287
|
+
try {
|
10288
|
+
got = await Promise.any(promises);
|
10289
|
+
} catch {
|
10290
|
+
}
|
10291
|
+
if (got)
|
10292
|
+
break;
|
10293
|
+
}
|
10284
10294
|
if (got) {
|
10285
10295
|
this.getBlockCache.set(sCid, got);
|
10286
10296
|
}
|
@@ -18750,12 +18760,15 @@ ${key.data.toString("base64")}
|
|
18750
18760
|
DataStore: () => DataStore2,
|
18751
18761
|
MetaStore: () => MetaStore2,
|
18752
18762
|
RemoteWAL: () => RemoteWAL2,
|
18763
|
+
makeDataStore: () => makeDataStore,
|
18764
|
+
makeMetaStore: () => makeMetaStore,
|
18765
|
+
makeRemoteWAL: () => makeRemoteWAL,
|
18753
18766
|
testConfig: () => testConfig
|
18754
18767
|
});
|
18755
18768
|
var import_path = __require("path");
|
18756
18769
|
var import_os = __require("os");
|
18757
18770
|
var import_promises = __require("fs/promises");
|
18758
|
-
var PACKAGE_VERSION2 = "0.
|
18771
|
+
var PACKAGE_VERSION2 = "0.17.3";
|
18759
18772
|
var match2 = PACKAGE_VERSION2.match(/^([^.]*\.[^.]*)/);
|
18760
18773
|
if (!match2)
|
18761
18774
|
throw new Error("invalid version: " + PACKAGE_VERSION2);
|
@@ -18843,14 +18856,14 @@ ${key.data.toString("base64")}
|
|
18843
18856
|
processQueue = new CommitQueue2();
|
18844
18857
|
constructor(loader) {
|
18845
18858
|
this.loader = loader;
|
18846
|
-
this.ready = (async () => {
|
18859
|
+
this.ready = Promise.resolve().then(async () => {
|
18847
18860
|
const walState = await this.load().catch((e) => {
|
18848
18861
|
console.error("error loading wal", e);
|
18849
18862
|
return null;
|
18850
18863
|
});
|
18851
18864
|
this.walState.operations = walState?.operations || [];
|
18852
18865
|
this.walState.fileOperations = walState?.fileOperations || [];
|
18853
|
-
})
|
18866
|
+
});
|
18854
18867
|
}
|
18855
18868
|
async enqueue(dbMeta, opts) {
|
18856
18869
|
await this.ready;
|
@@ -18949,6 +18962,9 @@ ${key.data.toString("base64")}
|
|
18949
18962
|
await rmlp;
|
18950
18963
|
}
|
18951
18964
|
};
|
18965
|
+
var makeDataStore = (name7) => new DataStore2(name7);
|
18966
|
+
var makeMetaStore = (loader) => new MetaStore2(loader.name);
|
18967
|
+
var makeRemoteWAL = (loader) => new RemoteWAL2(loader);
|
18952
18968
|
var RemoteWAL2 = class extends RemoteWAL {
|
18953
18969
|
filePathForBranch(branch) {
|
18954
18970
|
return (0, import_path.join)(MetaStore2.dataDir, this.loader.name, "wal", branch + ".json");
|
@@ -19092,6 +19108,7 @@ ${key.data.toString("base64")}
|
|
19092
19108
|
return true;
|
19093
19109
|
const [{ value: aevent }, { value: bevent }] = await Promise.all([events.get(a), events.get(b)]);
|
19094
19110
|
const links3 = [...aevent.parents];
|
19111
|
+
const seen = /* @__PURE__ */ new Set();
|
19095
19112
|
while (links3.length) {
|
19096
19113
|
const link2 = links3.shift();
|
19097
19114
|
if (!link2)
|
@@ -19100,6 +19117,9 @@ ${key.data.toString("base64")}
|
|
19100
19117
|
return true;
|
19101
19118
|
if (bevent.parents.some((p) => link2.toString() === p.toString()))
|
19102
19119
|
continue;
|
19120
|
+
if (seen.has(link2.toString()))
|
19121
|
+
continue;
|
19122
|
+
seen.add(link2.toString());
|
19103
19123
|
const { value: event } = await events.get(link2);
|
19104
19124
|
links3.push(...event.parents);
|
19105
19125
|
}
|
@@ -28660,6 +28680,7 @@ ${key.data.toString("base64")}
|
|
28660
28680
|
if (!block)
|
28661
28681
|
throw new Error(`Missing linked block ${link2.toString()}`);
|
28662
28682
|
const { value } = await decode11({ bytes: block.bytes, hasher: sha256, codec: src_exports });
|
28683
|
+
value.cid = link2;
|
28663
28684
|
readFiles(blocks, value);
|
28664
28685
|
return value;
|
28665
28686
|
}
|
@@ -29611,8 +29632,8 @@ ${key.data.toString("base64")}
|
|
29611
29632
|
return { head: this.clock.head };
|
29612
29633
|
},
|
29613
29634
|
autoCompact: this.opts.autoCompact || 100,
|
29614
|
-
crypto: crypto_node_exports,
|
29615
|
-
store: store_node_exports,
|
29635
|
+
crypto: this.opts.crypto || crypto_node_exports,
|
29636
|
+
store: this.opts.store || store_node_exports,
|
29616
29637
|
public: this.opts.public,
|
29617
29638
|
meta: this.opts.meta
|
29618
29639
|
});
|