@fireproof/core 0.14.1 → 0.14.3
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/dist/browser/fireproof.cjs +19 -23
- package/dist/browser/fireproof.cjs.map +3 -3
- package/dist/browser/fireproof.esm.js +19 -23
- package/dist/browser/fireproof.esm.js.map +3 -3
- package/dist/browser/fireproof.iife.js +19 -23
- package/dist/browser/fireproof.iife.js.map +3 -3
- package/dist/node/fireproof.cjs +19 -23
- package/dist/node/fireproof.cjs.map +3 -3
- package/dist/node/fireproof.esm.js +19 -23
- package/dist/node/fireproof.esm.js.map +3 -3
- package/dist/types/apply-head-queue.d.ts +1 -3
- package/dist/types/crdt-clock.d.ts +3 -3
- package/dist/types/store-memory.d.ts +24 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +7 -2
@@ -20977,7 +20977,7 @@ import { homedir } from "os";
|
|
20977
20977
|
import { mkdir, readFile, writeFile, unlink } from "fs/promises";
|
20978
20978
|
|
20979
20979
|
// src/version.ts
|
20980
|
-
var PACKAGE_VERSION = "0.14.
|
20980
|
+
var PACKAGE_VERSION = "0.14.3";
|
20981
20981
|
|
20982
20982
|
// src/store.ts
|
20983
20983
|
var match = PACKAGE_VERSION.match(/^([^.]*\.[^.]*)/);
|
@@ -30132,11 +30132,9 @@ async function processFileset(blocks, files, publicFiles = false) {
|
|
30132
30132
|
const dbBlockstore = blocks.parent;
|
30133
30133
|
const t = new Transaction(dbBlockstore);
|
30134
30134
|
const didPut = [];
|
30135
|
-
let totalSize = 0;
|
30136
30135
|
for (const filename in files) {
|
30137
30136
|
if (File === files[filename].constructor) {
|
30138
30137
|
const file = files[filename];
|
30139
|
-
totalSize += file.size;
|
30140
30138
|
const { cid, blocks: fileBlocks } = await encodeFile2(file);
|
30141
30139
|
didPut.push(filename);
|
30142
30140
|
for (const block of fileBlocks) {
|
@@ -30145,8 +30143,6 @@ async function processFileset(blocks, files, publicFiles = false) {
|
|
30145
30143
|
files[filename] = { cid, type: file.type, size: file.size };
|
30146
30144
|
}
|
30147
30145
|
}
|
30148
|
-
if (totalSize > 1024 * 1024 * 1)
|
30149
|
-
throw new Error("Sync limit for files in a single update is 1MB");
|
30150
30146
|
if (didPut.length) {
|
30151
30147
|
const car = await dbBlockstore.loader?.commit(t, { files }, { public: publicFiles });
|
30152
30148
|
if (car) {
|
@@ -30373,7 +30369,7 @@ var DbLoader = class _DbLoader extends Loader {
|
|
30373
30369
|
this.isCompacting = true;
|
30374
30370
|
const compactHead = this.clock.head;
|
30375
30371
|
const compactingResult = await doCompact(blocks, this.clock.head);
|
30376
|
-
await this.clock.applyHead(
|
30372
|
+
await this.clock.applyHead(compactHead, compactHead, null);
|
30377
30373
|
return compactingResult;
|
30378
30374
|
};
|
30379
30375
|
this.compacting = this._setWaitForWrite(compactingFn);
|
@@ -30388,9 +30384,9 @@ var DbLoader = class _DbLoader extends Loader {
|
|
30388
30384
|
}
|
30389
30385
|
async _applyCarHeader(carHeader, snap = false) {
|
30390
30386
|
if (snap) {
|
30391
|
-
await this.clock.applyHead(
|
30387
|
+
await this.clock.applyHead(carHeader.head, this.clock.head);
|
30392
30388
|
} else {
|
30393
|
-
await this.clock.applyHead(
|
30389
|
+
await this.clock.applyHead(carHeader.head, []);
|
30394
30390
|
}
|
30395
30391
|
}
|
30396
30392
|
makeCarHeader(result, cars, compact = false) {
|
@@ -30546,7 +30542,7 @@ function applyHeadQueue(worker) {
|
|
30546
30542
|
const task = queue.shift();
|
30547
30543
|
if (!task)
|
30548
30544
|
continue;
|
30549
|
-
await worker(task.id, task.
|
30545
|
+
await worker(task.id, task.newHead, task.prevHead, task.updates);
|
30550
30546
|
if (task.updates) {
|
30551
30547
|
allUpdates.push(...task.updates);
|
30552
30548
|
}
|
@@ -30590,18 +30586,18 @@ var CRDTClock = class {
|
|
30590
30586
|
setHead(head) {
|
30591
30587
|
this.head = head;
|
30592
30588
|
}
|
30593
|
-
async applyHead(
|
30589
|
+
async applyHead(newHead, prevHead, updates = null) {
|
30594
30590
|
const taskId = Math.random().toString().slice(2, 8);
|
30595
30591
|
for await (const { updates: updatesAcc, all } of this.applyHeadQueue.push({
|
30596
30592
|
id: taskId,
|
30597
|
-
tblocks,
|
30593
|
+
// tblocks,
|
30598
30594
|
newHead,
|
30599
30595
|
prevHead,
|
30600
30596
|
updates
|
30601
30597
|
})) {
|
30602
30598
|
;
|
30603
|
-
(
|
30604
|
-
Promise.resolve().then(async () => {
|
30599
|
+
((updatesAcc2, all2) => {
|
30600
|
+
void Promise.resolve().then(async () => {
|
30605
30601
|
let intUpdates = updatesAcc2;
|
30606
30602
|
if (this.watchers.size && !all2) {
|
30607
30603
|
const changes = await clockChangesSince(this.blocks, this.head, prevHead, {});
|
@@ -30613,11 +30609,11 @@ var CRDTClock = class {
|
|
30613
30609
|
})([...updatesAcc], all);
|
30614
30610
|
}
|
30615
30611
|
}
|
30616
|
-
async int_applyHead(taskId,
|
30612
|
+
async int_applyHead(taskId, newHead, prevHead) {
|
30617
30613
|
const ogHead = this.head.sort((a, b) => a.toString().localeCompare(b.toString()));
|
30618
30614
|
newHead = newHead.sort((a, b) => a.toString().localeCompare(b.toString()));
|
30619
|
-
newHead.map((cid) => {
|
30620
|
-
const got = this.blocks.get(cid);
|
30615
|
+
newHead.map(async (cid) => {
|
30616
|
+
const got = await this.blocks.get(cid);
|
30621
30617
|
if (!got) {
|
30622
30618
|
throw new Error("int_applyHead missing block: " + cid.toString());
|
30623
30619
|
}
|
@@ -30632,23 +30628,23 @@ var CRDTClock = class {
|
|
30632
30628
|
}
|
30633
30629
|
let head = this.head;
|
30634
30630
|
const noLoader = false;
|
30635
|
-
const withBlocks = async (
|
30631
|
+
const withBlocks = async (fn) => {
|
30636
30632
|
if (!this.blocks)
|
30637
30633
|
throw new Error("missing blocks");
|
30638
30634
|
return await this.blocks.transaction(fn, void 0, { noLoader });
|
30639
30635
|
};
|
30640
|
-
await withBlocks(
|
30636
|
+
await withBlocks(async (tblocks) => {
|
30641
30637
|
for (const cid of newHead) {
|
30642
30638
|
try {
|
30643
|
-
head = await advance(
|
30639
|
+
head = await advance(tblocks, head, cid);
|
30644
30640
|
} catch (e) {
|
30645
30641
|
console.error("failed to advance", cid.toString(), e);
|
30646
30642
|
continue;
|
30647
30643
|
}
|
30648
30644
|
}
|
30649
|
-
const result = await root(
|
30645
|
+
const result = await root(tblocks, head);
|
30650
30646
|
for (const { cid, bytes } of [...result.additions, ...result.removals]) {
|
30651
|
-
|
30647
|
+
tblocks.putSync(cid, bytes);
|
30652
30648
|
}
|
30653
30649
|
return { head };
|
30654
30650
|
});
|
@@ -30727,7 +30723,7 @@ var CRDT = class {
|
|
30727
30723
|
}
|
30728
30724
|
return { head };
|
30729
30725
|
});
|
30730
|
-
await this.clock.applyHead(
|
30726
|
+
await this.clock.applyHead(got.head, prevHead, updates);
|
30731
30727
|
return got;
|
30732
30728
|
})();
|
30733
30729
|
if (loader) {
|
@@ -30762,7 +30758,7 @@ var CRDT = class {
|
|
30762
30758
|
return await getBlock(this.blocks, cidString);
|
30763
30759
|
}
|
30764
30760
|
async getThatBlock() {
|
30765
|
-
const blockJson = {
|
30761
|
+
const blockJson = { cid: "bafyreib7ee4pscqpuioxobmh3ac5xbbslypmaqqbkugalhw67hnco6dvoa", bytes: "omRkYXRhpGNrZXl4JDAxOGFmNzdiLWZmMTUtNzI5Ny04ODZiLTYwMjViM2MxODI2ZWRyb2902CpYJQABcRIgKVLI53HO1TFDbPUoSaybd0mop2oX/CRFm1RrpiY4ne9kdHlwZWNwdXRldmFsdWXYKlglAAFxEiAGw53MVtPzeeGT/itfdLBfCVu6MTj96AHU6v9a3K/wYGdwYXJlbnRzgdgqWCUAAXESIJiL5qjdpgghUfbQLpKJeCgMX+ubhoTpYBoZHYdzbQJ/" };
|
30766
30762
|
return await getThatBlock(blockJson);
|
30767
30763
|
}
|
30768
30764
|
async get(key) {
|