@fireproof/core 0.17.3 → 0.17.5
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/README.md +2 -2
- 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 +81 -112
- 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 +81 -112
- 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 +76 -103
- 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 +8 -5
@@ -4089,7 +4089,7 @@ var Fireproof = (() => {
|
|
4089
4089
|
};
|
4090
4090
|
var parse = (source, base4) => CID.parse(source, base4);
|
4091
4091
|
|
4092
|
-
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.
|
4092
|
+
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/block.js
|
4093
4093
|
var MemoryBlockstore = class {
|
4094
4094
|
/** @type {Map<string, Uint8Array>} */
|
4095
4095
|
#blocks = /* @__PURE__ */ new Map();
|
@@ -4136,6 +4136,22 @@ var Fireproof = (() => {
|
|
4136
4136
|
}
|
4137
4137
|
}
|
4138
4138
|
};
|
4139
|
+
var MultiBlockFetcher = class {
|
4140
|
+
/** @type {API.BlockFetcher[]} */
|
4141
|
+
#fetchers;
|
4142
|
+
/** @param {API.BlockFetcher[]} fetchers */
|
4143
|
+
constructor(...fetchers) {
|
4144
|
+
this.#fetchers = fetchers;
|
4145
|
+
}
|
4146
|
+
/** @type {API.BlockFetcher['get']} */
|
4147
|
+
async get(link2) {
|
4148
|
+
for (const f of this.#fetchers) {
|
4149
|
+
const v = await f.get(link2);
|
4150
|
+
if (v)
|
4151
|
+
return v;
|
4152
|
+
}
|
4153
|
+
}
|
4154
|
+
};
|
4139
4155
|
|
4140
4156
|
// ../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
|
4141
4157
|
var Node = class {
|
@@ -9936,8 +9952,7 @@ You can use close({ resize: true }) to resize header`);
|
|
9936
9952
|
return uint8Array;
|
9937
9953
|
}
|
9938
9954
|
async function encryptedEncodeCarFile(crypto22, key, rootCid, t) {
|
9939
|
-
const
|
9940
|
-
const encryptionKey = encryptionKeyUint8.buffer.slice(0, encryptionKeyUint8.byteLength);
|
9955
|
+
const encryptionKey = hexStringToUint8Array(key);
|
9941
9956
|
const encryptedBlocks = new MemoryBlockstore();
|
9942
9957
|
const cidsToEncrypt = [];
|
9943
9958
|
for (const { cid } of t.entries()) {
|
@@ -10014,7 +10029,7 @@ You can use close({ resize: true }) to resize header`);
|
|
10014
10029
|
}
|
10015
10030
|
return bytes;
|
10016
10031
|
}
|
10017
|
-
var PACKAGE_VERSION = "0.
|
10032
|
+
var PACKAGE_VERSION = "0.17.4";
|
10018
10033
|
var match = PACKAGE_VERSION.match(/^([^.]*\.[^.]*)/);
|
10019
10034
|
if (!match)
|
10020
10035
|
throw new Error("invalid version: " + PACKAGE_VERSION);
|
@@ -10090,11 +10105,11 @@ You can use close({ resize: true }) to resize header`);
|
|
10090
10105
|
constructor(name7, ebOpts) {
|
10091
10106
|
this.name = name7;
|
10092
10107
|
this.ebOpts = ebOpts;
|
10093
|
-
this.
|
10094
|
-
this.
|
10095
|
-
this.
|
10096
|
-
this.remoteWAL = new ebOpts.store.RemoteWAL(this);
|
10108
|
+
this.carStore = ebOpts.store.makeDataStore(this.name);
|
10109
|
+
this.fileStore = ebOpts.store.makeDataStore(this.name);
|
10110
|
+
this.remoteWAL = ebOpts.store.makeRemoteWAL(this);
|
10097
10111
|
this.ready = Promise.resolve().then(async () => {
|
10112
|
+
this.metaStore = ebOpts.store.makeMetaStore(this);
|
10098
10113
|
if (!this.metaStore || !this.carStore || !this.remoteWAL)
|
10099
10114
|
throw new Error("stores not initialized");
|
10100
10115
|
const metas = this.ebOpts.meta ? [this.ebOpts.meta] : await this.metaStore.load("main");
|
@@ -10268,19 +10283,30 @@ You can use close({ resize: true }) to resize header`);
|
|
10268
10283
|
const sCid = cid.toString();
|
10269
10284
|
if (this.getBlockCache.has(sCid))
|
10270
10285
|
return this.getBlockCache.get(sCid);
|
10271
|
-
const
|
10272
|
-
|
10273
|
-
|
10274
|
-
|
10275
|
-
|
10276
|
-
|
10277
|
-
|
10278
|
-
|
10279
|
-
|
10280
|
-
|
10281
|
-
|
10282
|
-
|
10283
|
-
|
10286
|
+
const getCarCid = async (carCid) => {
|
10287
|
+
const reader = await this.loadCar(carCid);
|
10288
|
+
if (!reader) {
|
10289
|
+
throw new Error(`missing car reader ${carCid.toString()}`);
|
10290
|
+
}
|
10291
|
+
await this.cacheCarReader(reader);
|
10292
|
+
if (this.getBlockCache.has(sCid))
|
10293
|
+
return this.getBlockCache.get(sCid);
|
10294
|
+
throw new Error(`block not in reader: ${cid.toString()}`);
|
10295
|
+
};
|
10296
|
+
let got;
|
10297
|
+
const batchSize = 5;
|
10298
|
+
for (let i = 0; i < this.carLog.length; i += batchSize) {
|
10299
|
+
const promises = [];
|
10300
|
+
for (let j = i; j < Math.min(i + batchSize, this.carLog.length); j++) {
|
10301
|
+
promises.push(getCarCid(this.carLog[j]));
|
10302
|
+
}
|
10303
|
+
try {
|
10304
|
+
got = await Promise.any(promises);
|
10305
|
+
} catch {
|
10306
|
+
}
|
10307
|
+
if (got)
|
10308
|
+
break;
|
10309
|
+
}
|
10284
10310
|
if (got) {
|
10285
10311
|
this.getBlockCache.set(sCid, got);
|
10286
10312
|
}
|
@@ -18750,12 +18776,15 @@ ${key.data.toString("base64")}
|
|
18750
18776
|
DataStore: () => DataStore2,
|
18751
18777
|
MetaStore: () => MetaStore2,
|
18752
18778
|
RemoteWAL: () => RemoteWAL2,
|
18779
|
+
makeDataStore: () => makeDataStore,
|
18780
|
+
makeMetaStore: () => makeMetaStore,
|
18781
|
+
makeRemoteWAL: () => makeRemoteWAL,
|
18753
18782
|
testConfig: () => testConfig
|
18754
18783
|
});
|
18755
18784
|
var import_path = __require("path");
|
18756
18785
|
var import_os = __require("os");
|
18757
18786
|
var import_promises = __require("fs/promises");
|
18758
|
-
var PACKAGE_VERSION2 = "0.
|
18787
|
+
var PACKAGE_VERSION2 = "0.17.4";
|
18759
18788
|
var match2 = PACKAGE_VERSION2.match(/^([^.]*\.[^.]*)/);
|
18760
18789
|
if (!match2)
|
18761
18790
|
throw new Error("invalid version: " + PACKAGE_VERSION2);
|
@@ -18843,14 +18872,14 @@ ${key.data.toString("base64")}
|
|
18843
18872
|
processQueue = new CommitQueue2();
|
18844
18873
|
constructor(loader) {
|
18845
18874
|
this.loader = loader;
|
18846
|
-
this.ready = (async () => {
|
18875
|
+
this.ready = Promise.resolve().then(async () => {
|
18847
18876
|
const walState = await this.load().catch((e) => {
|
18848
18877
|
console.error("error loading wal", e);
|
18849
18878
|
return null;
|
18850
18879
|
});
|
18851
18880
|
this.walState.operations = walState?.operations || [];
|
18852
18881
|
this.walState.fileOperations = walState?.fileOperations || [];
|
18853
|
-
})
|
18882
|
+
});
|
18854
18883
|
}
|
18855
18884
|
async enqueue(dbMeta, opts) {
|
18856
18885
|
await this.ready;
|
@@ -18949,6 +18978,9 @@ ${key.data.toString("base64")}
|
|
18949
18978
|
await rmlp;
|
18950
18979
|
}
|
18951
18980
|
};
|
18981
|
+
var makeDataStore = (name7) => new DataStore2(name7);
|
18982
|
+
var makeMetaStore = (loader) => new MetaStore2(loader.name);
|
18983
|
+
var makeRemoteWAL = (loader) => new RemoteWAL2(loader);
|
18952
18984
|
var RemoteWAL2 = class extends RemoteWAL {
|
18953
18985
|
filePathForBranch(branch) {
|
18954
18986
|
return (0, import_path.join)(MetaStore2.dataDir, this.loader.name, "wal", branch + ".json");
|
@@ -19018,7 +19050,7 @@ ${key.data.toString("base64")}
|
|
19018
19050
|
return await (0, import_promises.writeFile)(path, data);
|
19019
19051
|
}
|
19020
19052
|
|
19021
|
-
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.
|
19053
|
+
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/clock/index.js
|
19022
19054
|
var advance = async (blocks, head, event) => {
|
19023
19055
|
const events = new EventFetcher(blocks);
|
19024
19056
|
const headmap = new Map(head.map((cid) => [cid.toString(), cid]));
|
@@ -19092,6 +19124,7 @@ ${key.data.toString("base64")}
|
|
19092
19124
|
return true;
|
19093
19125
|
const [{ value: aevent }, { value: bevent }] = await Promise.all([events.get(a), events.get(b)]);
|
19094
19126
|
const links3 = [...aevent.parents];
|
19127
|
+
const seen = /* @__PURE__ */ new Set();
|
19095
19128
|
while (links3.length) {
|
19096
19129
|
const link2 = links3.shift();
|
19097
19130
|
if (!link2)
|
@@ -19100,6 +19133,9 @@ ${key.data.toString("base64")}
|
|
19100
19133
|
return true;
|
19101
19134
|
if (bevent.parents.some((p) => link2.toString() === p.toString()))
|
19102
19135
|
continue;
|
19136
|
+
if (seen.has(link2.toString()))
|
19137
|
+
continue;
|
19138
|
+
seen.add(link2.toString());
|
19103
19139
|
const { value: event } = await events.get(link2);
|
19104
19140
|
links3.push(...event.parents);
|
19105
19141
|
}
|
@@ -19140,7 +19176,7 @@ ${key.data.toString("base64")}
|
|
19140
19176
|
};
|
19141
19177
|
var shortLink = (l) => `${String(l).slice(0, 4)}..${String(l).slice(-4)}`;
|
19142
19178
|
|
19143
|
-
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.
|
19179
|
+
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/shard.js
|
19144
19180
|
var MaxKeyLength = 64;
|
19145
19181
|
var MaxShardSize = 512 * 1024;
|
19146
19182
|
var CID_TAG2 = new Token(Type.tag, 42);
|
@@ -19272,7 +19308,7 @@ ${key.data.toString("base64")}
|
|
19272
19308
|
}
|
19273
19309
|
};
|
19274
19310
|
|
19275
|
-
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.
|
19311
|
+
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/index.js
|
19276
19312
|
var put = async (blocks, root2, key, value) => {
|
19277
19313
|
const shards = new ShardFetcher(blocks);
|
19278
19314
|
const rshard = await shards.get(root2);
|
@@ -19475,71 +19511,7 @@ ${key.data.toString("base64")}
|
|
19475
19511
|
return [shard];
|
19476
19512
|
};
|
19477
19513
|
|
19478
|
-
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.
|
19479
|
-
var MemoryBlockstore2 = class {
|
19480
|
-
/** @type {Map<string, Uint8Array>} */
|
19481
|
-
#blocks = /* @__PURE__ */ new Map();
|
19482
|
-
/**
|
19483
|
-
* @param {Array<import('multiformats').Block>} [blocks]
|
19484
|
-
*/
|
19485
|
-
constructor(blocks) {
|
19486
|
-
if (blocks) {
|
19487
|
-
this.#blocks = new Map(blocks.map((b) => [b.cid.toString(), b.bytes]));
|
19488
|
-
}
|
19489
|
-
}
|
19490
|
-
/** @type {API.BlockFetcher['get']} */
|
19491
|
-
async get(cid) {
|
19492
|
-
const bytes = this.#blocks.get(cid.toString());
|
19493
|
-
if (!bytes)
|
19494
|
-
return;
|
19495
|
-
return { cid, bytes };
|
19496
|
-
}
|
19497
|
-
/**
|
19498
|
-
* @param {API.UnknownLink} cid
|
19499
|
-
* @param {Uint8Array} bytes
|
19500
|
-
*/
|
19501
|
-
async put(cid, bytes) {
|
19502
|
-
this.#blocks.set(cid.toString(), bytes);
|
19503
|
-
}
|
19504
|
-
/**
|
19505
|
-
* @param {API.UnknownLink} cid
|
19506
|
-
* @param {Uint8Array} bytes
|
19507
|
-
*/
|
19508
|
-
putSync(cid, bytes) {
|
19509
|
-
this.#blocks.set(cid.toString(), bytes);
|
19510
|
-
}
|
19511
|
-
/** @param {API.UnknownLink} cid */
|
19512
|
-
async delete(cid) {
|
19513
|
-
this.#blocks.delete(cid.toString());
|
19514
|
-
}
|
19515
|
-
/** @param {API.UnknownLink} cid */
|
19516
|
-
deleteSync(cid) {
|
19517
|
-
this.#blocks.delete(cid.toString());
|
19518
|
-
}
|
19519
|
-
*entries() {
|
19520
|
-
for (const [str, bytes] of this.#blocks) {
|
19521
|
-
yield { cid: parse(str), bytes };
|
19522
|
-
}
|
19523
|
-
}
|
19524
|
-
};
|
19525
|
-
var MultiBlockFetcher = class {
|
19526
|
-
/** @type {API.BlockFetcher[]} */
|
19527
|
-
#fetchers;
|
19528
|
-
/** @param {API.BlockFetcher[]} fetchers */
|
19529
|
-
constructor(...fetchers) {
|
19530
|
-
this.#fetchers = fetchers;
|
19531
|
-
}
|
19532
|
-
/** @type {API.BlockFetcher['get']} */
|
19533
|
-
async get(link2) {
|
19534
|
-
for (const f of this.#fetchers) {
|
19535
|
-
const v = await f.get(link2);
|
19536
|
-
if (v)
|
19537
|
-
return v;
|
19538
|
-
}
|
19539
|
-
}
|
19540
|
-
};
|
19541
|
-
|
19542
|
-
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/batch/shard.js
|
19514
|
+
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/batch/shard.js
|
19543
19515
|
var ShardLinkByteLength = 36;
|
19544
19516
|
var CID_TAG3 = new Token(Type.tag, 42);
|
19545
19517
|
var create8 = (init2) => ({
|
@@ -19586,7 +19558,7 @@ ${key.data.toString("base64")}
|
|
19586
19558
|
return tokensToLength(tokens);
|
19587
19559
|
};
|
19588
19560
|
|
19589
|
-
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.
|
19561
|
+
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/batch/index.js
|
19590
19562
|
var Batcher = class _Batcher {
|
19591
19563
|
#committed = false;
|
19592
19564
|
/**
|
@@ -19768,9 +19740,9 @@ ${key.data.toString("base64")}
|
|
19768
19740
|
static code = "ERR_BATCH_COMMITTED";
|
19769
19741
|
};
|
19770
19742
|
|
19771
|
-
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.
|
19743
|
+
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/crdt/index.js
|
19772
19744
|
var put3 = async (blocks, head, key, value) => {
|
19773
|
-
const mblocks = new
|
19745
|
+
const mblocks = new MemoryBlockstore();
|
19774
19746
|
blocks = new MultiBlockFetcher(mblocks, blocks);
|
19775
19747
|
if (!head.length) {
|
19776
19748
|
const shard = await ShardBlock.create();
|
@@ -19854,7 +19826,7 @@ ${key.data.toString("base64")}
|
|
19854
19826
|
var root = async (blocks, head) => {
|
19855
19827
|
if (!head.length)
|
19856
19828
|
throw new Error("cannot determine root of headless clock");
|
19857
|
-
const mblocks = new
|
19829
|
+
const mblocks = new MemoryBlockstore();
|
19858
19830
|
blocks = new MultiBlockFetcher(mblocks, blocks);
|
19859
19831
|
const events = new EventFetcher(blocks);
|
19860
19832
|
if (head.length === 1) {
|
@@ -19913,7 +19885,7 @@ ${key.data.toString("base64")}
|
|
19913
19885
|
return;
|
19914
19886
|
const result = await root(blocks, head);
|
19915
19887
|
if (result.additions.length) {
|
19916
|
-
blocks = new MultiBlockFetcher(new
|
19888
|
+
blocks = new MultiBlockFetcher(new MemoryBlockstore(result.additions), blocks);
|
19917
19889
|
}
|
19918
19890
|
return get2(blocks, result.root, key);
|
19919
19891
|
};
|
@@ -19922,7 +19894,7 @@ ${key.data.toString("base64")}
|
|
19922
19894
|
return;
|
19923
19895
|
const result = await root(blocks, head);
|
19924
19896
|
if (result.additions.length) {
|
19925
|
-
blocks = new MultiBlockFetcher(new
|
19897
|
+
blocks = new MultiBlockFetcher(new MemoryBlockstore(result.additions), blocks);
|
19926
19898
|
}
|
19927
19899
|
yield* entries(blocks, result.root, options);
|
19928
19900
|
};
|
@@ -20006,7 +19978,7 @@ ${key.data.toString("base64")}
|
|
20006
19978
|
return acc.concat(...rest);
|
20007
19979
|
};
|
20008
19980
|
|
20009
|
-
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.
|
19981
|
+
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/crdt/batch/index.js
|
20010
19982
|
var Batcher2 = class _Batcher {
|
20011
19983
|
#committed = false;
|
20012
19984
|
/**
|
@@ -20051,7 +20023,7 @@ ${key.data.toString("base64")}
|
|
20051
20023
|
const res = await commit(this);
|
20052
20024
|
const data = { type: "batch", ops: this.ops, root: res.root };
|
20053
20025
|
const event = await EventBlock.create(data, this.head);
|
20054
|
-
const mblocks = new
|
20026
|
+
const mblocks = new MemoryBlockstore();
|
20055
20027
|
const blocks = new MultiBlockFetcher(mblocks, this.blocks);
|
20056
20028
|
mblocks.putSync(event.cid, event.bytes);
|
20057
20029
|
const head = await advance(blocks, this.head, event.cid);
|
@@ -20091,7 +20063,7 @@ ${key.data.toString("base64")}
|
|
20091
20063
|
* @param {string} init.prefix
|
20092
20064
|
*/
|
20093
20065
|
static async create({ blocks, head, prefix }) {
|
20094
|
-
const mblocks = new
|
20066
|
+
const mblocks = new MemoryBlockstore();
|
20095
20067
|
blocks = new MultiBlockFetcher(mblocks, blocks);
|
20096
20068
|
if (!head.length) {
|
20097
20069
|
const base5 = await ShardBlock.create();
|
@@ -28660,6 +28632,7 @@ ${key.data.toString("base64")}
|
|
28660
28632
|
if (!block)
|
28661
28633
|
throw new Error(`Missing linked block ${link2.toString()}`);
|
28662
28634
|
const { value } = await decode11({ bytes: block.bytes, hasher: sha256, codec: src_exports });
|
28635
|
+
value.cid = link2;
|
28663
28636
|
readFiles(blocks, value);
|
28664
28637
|
return value;
|
28665
28638
|
}
|
@@ -29611,8 +29584,8 @@ ${key.data.toString("base64")}
|
|
29611
29584
|
return { head: this.clock.head };
|
29612
29585
|
},
|
29613
29586
|
autoCompact: this.opts.autoCompact || 100,
|
29614
|
-
crypto: crypto_node_exports,
|
29615
|
-
store: store_node_exports,
|
29587
|
+
crypto: this.opts.crypto || crypto_node_exports,
|
29588
|
+
store: this.opts.store || store_node_exports,
|
29616
29589
|
public: this.opts.public,
|
29617
29590
|
meta: this.opts.meta
|
29618
29591
|
});
|