@fireproof/core 0.13.5-dev → 0.13.7-dev
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/browser/fireproof.cjs +68 -34
- package/dist/browser/fireproof.cjs.map +4 -4
- package/dist/browser/fireproof.esm.js +68 -34
- package/dist/browser/fireproof.esm.js.map +4 -4
- package/dist/browser/fireproof.iife.js +68 -34
- package/dist/browser/fireproof.iife.js.map +4 -4
- package/dist/node/fireproof.cjs +68 -34
- package/dist/node/fireproof.cjs.map +4 -4
- package/dist/node/fireproof.esm.js +68 -34
- package/dist/node/fireproof.esm.js.map +4 -4
- package/dist/types/apply-head-queue.d.ts +2 -2
- package/dist/types/crdt-clock.d.ts +3 -3
- package/dist/types/crdt-helpers.d.ts +8 -2
- package/dist/types/crdt.d.ts +2 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
@@ -11605,7 +11605,7 @@ You can use close({ resize: true }) to resize header`);
|
|
11605
11605
|
}));
|
11606
11606
|
|
11607
11607
|
// src/version.ts
|
11608
|
-
var PACKAGE_VERSION = "0.13.
|
11608
|
+
var PACKAGE_VERSION = "0.13.7-dev";
|
11609
11609
|
|
11610
11610
|
// src/store.ts
|
11611
11611
|
var match = PACKAGE_VERSION.match(/^([^.]*\.[^.]*)/);
|
@@ -12031,9 +12031,6 @@ You can use close({ resize: true }) to resize header`);
|
|
12031
12031
|
const header = await encodeCarHeader(fp);
|
12032
12032
|
await t.put(header.cid, header.bytes);
|
12033
12033
|
roots = [header.cid];
|
12034
|
-
const got = await t.get(header.cid);
|
12035
|
-
if (!got)
|
12036
|
-
throw new Error("missing header!!!");
|
12037
12034
|
}
|
12038
12035
|
const theKey = opts.public ? null : await this._getKey();
|
12039
12036
|
const { cid, bytes } = theKey ? await encryptedEncodeCarFile(theKey, roots[0], t) : await encodeCarFile(roots, t);
|
@@ -12807,6 +12804,9 @@ You can use close({ resize: true }) to resize header`);
|
|
12807
12804
|
};
|
12808
12805
|
}
|
12809
12806
|
|
12807
|
+
// ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/link.js
|
12808
|
+
var parse3 = (source, base3) => CID2.parse(source, base3);
|
12809
|
+
|
12810
12810
|
// ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/hashes/hasher.js
|
12811
12811
|
var from4 = ({ name: name8, code: code8, encode: encode19 }) => new Hasher2(name8, code8, encode19);
|
12812
12812
|
var Hasher2 = class {
|
@@ -14643,7 +14643,7 @@ You can use close({ resize: true }) to resize header`);
|
|
14643
14643
|
}
|
14644
14644
|
return d;
|
14645
14645
|
};
|
14646
|
-
Data3.prototype.toJSON = function
|
14646
|
+
Data3.prototype.toJSON = function toJSON3() {
|
14647
14647
|
return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
|
14648
14648
|
};
|
14649
14649
|
Data3.DataType = function() {
|
@@ -14740,7 +14740,7 @@ You can use close({ resize: true }) to resize header`);
|
|
14740
14740
|
}
|
14741
14741
|
return d;
|
14742
14742
|
};
|
14743
|
-
UnixTime3.prototype.toJSON = function
|
14743
|
+
UnixTime3.prototype.toJSON = function toJSON3() {
|
14744
14744
|
return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
|
14745
14745
|
};
|
14746
14746
|
return UnixTime3;
|
@@ -14799,7 +14799,7 @@ You can use close({ resize: true }) to resize header`);
|
|
14799
14799
|
}
|
14800
14800
|
return d;
|
14801
14801
|
};
|
14802
|
-
Metadata3.prototype.toJSON = function
|
14802
|
+
Metadata3.prototype.toJSON = function toJSON3() {
|
14803
14803
|
return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
|
14804
14804
|
};
|
14805
14805
|
return Metadata3;
|
@@ -20954,6 +20954,8 @@ You can use close({ resize: true }) to resize header`);
|
|
20954
20954
|
if (!bl)
|
20955
20955
|
throw new Error("Missing head block: " + cid.toString());
|
20956
20956
|
}
|
20957
|
+
for await (const entry of getAllEntries(blockLog, head)) {
|
20958
|
+
}
|
20957
20959
|
for await (const [, link2] of entries2(blockLog, head)) {
|
20958
20960
|
const bl = await blockLog.get(link2);
|
20959
20961
|
if (!bl)
|
@@ -20970,6 +20972,18 @@ You can use close({ resize: true }) to resize header`);
|
|
20970
20972
|
isCompacting = false;
|
20971
20973
|
return done;
|
20972
20974
|
}
|
20975
|
+
async function getThatBlock({ bytes }) {
|
20976
|
+
const realBytes = Uint8Array.from(atob(bytes), (c) => c.charCodeAt(0));
|
20977
|
+
const { cid, value } = await decode12({ bytes: realBytes, codec: src_exports, hasher: sha256 });
|
20978
|
+
return new Block({ cid, value, bytes: realBytes });
|
20979
|
+
}
|
20980
|
+
async function getBlock(blocks, cidString) {
|
20981
|
+
const block = await blocks.get(parse3(cidString));
|
20982
|
+
if (!block)
|
20983
|
+
throw new Error(`Missing block ${cidString}`);
|
20984
|
+
const { cid, value } = await decode12({ bytes: block.bytes, codec: src_exports, hasher: sha256 });
|
20985
|
+
return new Block({ cid, value, bytes: block.bytes });
|
20986
|
+
}
|
20973
20987
|
|
20974
20988
|
// src/loaders.ts
|
20975
20989
|
var _IdxLoader = class _IdxLoader extends Loader {
|
@@ -21032,18 +21046,17 @@ You can use close({ resize: true }) to resize header`);
|
|
21032
21046
|
return;
|
21033
21047
|
}
|
21034
21048
|
this.isCompacting = true;
|
21035
|
-
|
21036
|
-
|
21037
|
-
|
21038
|
-
|
21039
|
-
return compactingResult;
|
21040
|
-
} finally {
|
21041
|
-
this.isCompacting = false;
|
21042
|
-
}
|
21049
|
+
const compactHead = this.clock.head;
|
21050
|
+
const compactingResult = await doCompact(blocks, this.clock.head);
|
21051
|
+
await this.clock.applyHead(null, compactHead, compactHead, null);
|
21052
|
+
return compactingResult;
|
21043
21053
|
};
|
21044
21054
|
this.compacting = this._setWaitForWrite(compactingFn);
|
21055
|
+
this.compacting.finally(() => {
|
21056
|
+
this.isCompacting = false;
|
21057
|
+
this.awaitingCompact = false;
|
21058
|
+
});
|
21045
21059
|
await this.compacting;
|
21046
|
-
this.awaitingCompact = false;
|
21047
21060
|
}
|
21048
21061
|
async loadFileCar(cid, isPublic = false) {
|
21049
21062
|
return await this.storesLoadCar(cid, this.fileStore, this.remoteFileStore, isPublic);
|
@@ -21257,17 +21270,25 @@ You can use close({ resize: true }) to resize header`);
|
|
21257
21270
|
}
|
21258
21271
|
async applyHead(tblocks, newHead, prevHead, updates = null) {
|
21259
21272
|
const taskId = Math.random().toString().slice(2, 8);
|
21260
|
-
for await (const { updates: updatesAcc, all } of this.applyHeadQueue.push({
|
21261
|
-
|
21262
|
-
|
21263
|
-
|
21264
|
-
|
21265
|
-
|
21266
|
-
|
21267
|
-
|
21268
|
-
|
21269
|
-
|
21270
|
-
|
21273
|
+
for await (const { updates: updatesAcc, all } of this.applyHeadQueue.push({
|
21274
|
+
id: taskId,
|
21275
|
+
tblocks,
|
21276
|
+
newHead,
|
21277
|
+
prevHead,
|
21278
|
+
updates
|
21279
|
+
})) {
|
21280
|
+
;
|
21281
|
+
(async (updatesAcc2, all2) => {
|
21282
|
+
Promise.resolve().then(async () => {
|
21283
|
+
let intUpdates = updatesAcc2;
|
21284
|
+
if (this.watchers.size && !all2) {
|
21285
|
+
const changes = await clockChangesSince(this.blocks, this.head, prevHead, {});
|
21286
|
+
intUpdates = changes.result;
|
21287
|
+
}
|
21288
|
+
this.zoomers.forEach((fn) => fn());
|
21289
|
+
this.notifyWatchers(intUpdates || []);
|
21290
|
+
});
|
21291
|
+
})([...updatesAcc], all);
|
21271
21292
|
}
|
21272
21293
|
}
|
21273
21294
|
async int_applyHead(taskId, tblocks, newHead, prevHead, updates = null) {
|
@@ -21280,13 +21301,11 @@ You can use close({ resize: true }) to resize header`);
|
|
21280
21301
|
}
|
21281
21302
|
});
|
21282
21303
|
if (ogHead.toString() === newHead.toString()) {
|
21283
|
-
this.notifyWatchers(updates || []);
|
21284
21304
|
return;
|
21285
21305
|
}
|
21286
21306
|
const ogPrev = prevHead.sort((a, b) => a.toString().localeCompare(b.toString()));
|
21287
21307
|
if (ogHead.toString() === ogPrev.toString()) {
|
21288
21308
|
this.setHead(newHead);
|
21289
|
-
this.notifyWatchers(updates || []);
|
21290
21309
|
return;
|
21291
21310
|
}
|
21292
21311
|
let head = this.head;
|
@@ -21301,6 +21320,7 @@ You can use close({ resize: true }) to resize header`);
|
|
21301
21320
|
try {
|
21302
21321
|
head = await advance(tblocks2, head, cid);
|
21303
21322
|
} catch (e) {
|
21323
|
+
console.error("failed to advance", cid.toString(), e);
|
21304
21324
|
continue;
|
21305
21325
|
}
|
21306
21326
|
}
|
@@ -21371,16 +21391,22 @@ You can use close({ resize: true }) to resize header`);
|
|
21371
21391
|
if (loader?.isCompacting) {
|
21372
21392
|
throw new Error("cant bulk while compacting");
|
21373
21393
|
}
|
21374
|
-
const
|
21375
|
-
const { head
|
21394
|
+
const got = await this.blocks.transaction(async (tblocks) => {
|
21395
|
+
const { head } = await applyBulkUpdateToCrdt(tblocks, this.clock.head, updates, options);
|
21376
21396
|
updates = updates.map(({ key, value, del: del2 }) => {
|
21377
21397
|
readFiles(this.blocks, { doc: value });
|
21378
21398
|
return { key, value, del: del2 };
|
21379
21399
|
});
|
21380
|
-
|
21400
|
+
if (loader?.awaitingCompact) {
|
21401
|
+
console.log("missing?", head.toString());
|
21402
|
+
}
|
21403
|
+
if (loader?.isCompacting) {
|
21404
|
+
console.log("compacting?", head.toString());
|
21405
|
+
}
|
21406
|
+
return { head };
|
21381
21407
|
});
|
21382
|
-
await this.clock.applyHead(null, head, prevHead, updates);
|
21383
|
-
return
|
21408
|
+
await this.clock.applyHead(null, got.head, prevHead, updates);
|
21409
|
+
return got;
|
21384
21410
|
})();
|
21385
21411
|
if (loader) {
|
21386
21412
|
const wr = loader.writing;
|
@@ -21409,6 +21435,14 @@ You can use close({ resize: true }) to resize header`);
|
|
21409
21435
|
}
|
21410
21436
|
return txt.join("\n");
|
21411
21437
|
}
|
21438
|
+
async getBlock(cidString) {
|
21439
|
+
await this.ready;
|
21440
|
+
return await getBlock(this.blocks, cidString);
|
21441
|
+
}
|
21442
|
+
async getThatBlock() {
|
21443
|
+
const blockJson = { "cid": "bafyreib7ee4pscqpuioxobmh3ac5xbbslypmaqqbkugalhw67hnco6dvoa", "bytes": "omRkYXRhpGNrZXl4JDAxOGFmNzdiLWZmMTUtNzI5Ny04ODZiLTYwMjViM2MxODI2ZWRyb2902CpYJQABcRIgKVLI53HO1TFDbPUoSaybd0mop2oX/CRFm1RrpiY4ne9kdHlwZWNwdXRldmFsdWXYKlglAAFxEiAGw53MVtPzeeGT/itfdLBfCVu6MTj96AHU6v9a3K/wYGdwYXJlbnRzgdgqWCUAAXESIJiL5qjdpgghUfbQLpKJeCgMX+ubhoTpYBoZHYdzbQJ/" };
|
21444
|
+
return await getThatBlock(blockJson);
|
21445
|
+
}
|
21412
21446
|
async get(key) {
|
21413
21447
|
await this.ready;
|
21414
21448
|
const result = await getValueFromCrdt(this.blocks, this.clock.head, key);
|