@fireproof/core 0.19.100 → 0.19.102
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.cjs +35 -16
- package/index.cjs.map +1 -1
- package/index.d.cts +4 -0
- package/index.d.ts +4 -0
- package/index.global.js +35 -16
- package/index.global.js.map +1 -1
- package/index.js +35 -16
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/metafile-iife.json +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
@@ -356,6 +356,8 @@ var BaseBlockstore = class {
|
|
356
356
|
}
|
357
357
|
async destroy() {
|
358
358
|
}
|
359
|
+
async compact() {
|
360
|
+
}
|
359
361
|
async get(cid) {
|
360
362
|
if (!cid) throw this.logger.Error().Msg("required cid").AsError();
|
361
363
|
for (const f of this.transactions) {
|
@@ -374,6 +376,21 @@ var BaseBlockstore = class {
|
|
374
376
|
this.lastTxMeta = done;
|
375
377
|
return { t, meta: done };
|
376
378
|
}
|
379
|
+
openTransaction(opts = { add: true, noLoader: false }) {
|
380
|
+
return new CarTransaction(this, opts);
|
381
|
+
}
|
382
|
+
async commitTransaction(t, done, opts) {
|
383
|
+
if (!this.loader) throw this.logger.Error().Msg("loader required to commit").AsError();
|
384
|
+
const cars = await this.loader?.commit(t, done, opts);
|
385
|
+
if (this.ebOpts.autoCompact && this.loader.carLog.length > this.ebOpts.autoCompact) {
|
386
|
+
setTimeout(() => void this.compact(), 10);
|
387
|
+
}
|
388
|
+
if (cars) {
|
389
|
+
this.transactions.delete(t);
|
390
|
+
return { meta: done, cars, t };
|
391
|
+
}
|
392
|
+
throw this.logger.Error().Msg("failed to commit car files").AsError();
|
393
|
+
}
|
377
394
|
async *entries() {
|
378
395
|
const seen = /* @__PURE__ */ new Set();
|
379
396
|
for (const t of this.transactions) {
|
@@ -3050,21 +3067,23 @@ var CRDTClock = class {
|
|
3050
3067
|
throw this.logger.Error().Msg("missing blockstore").AsError();
|
3051
3068
|
}
|
3052
3069
|
await validateBlocks(this.logger, newHead, this.blockstore);
|
3053
|
-
|
3054
|
-
|
3055
|
-
|
3056
|
-
|
3057
|
-
|
3058
|
-
|
3059
|
-
|
3060
|
-
|
3061
|
-
|
3062
|
-
|
3063
|
-
|
3064
|
-
|
3065
|
-
|
3066
|
-
|
3067
|
-
|
3070
|
+
if (!this.transaction) {
|
3071
|
+
this.transaction = this.blockstore.openTransaction({ noLoader, add: false });
|
3072
|
+
}
|
3073
|
+
const tblocks = this.transaction;
|
3074
|
+
const advancedHead = await advanceBlocks(this.logger, newHead, tblocks, this.head);
|
3075
|
+
const result = await root2(tblocks, advancedHead);
|
3076
|
+
for (const { cid, bytes } of [
|
3077
|
+
...result.additions
|
3078
|
+
// ...result.removals
|
3079
|
+
]) {
|
3080
|
+
tblocks.putSync(cid, bytes);
|
3081
|
+
}
|
3082
|
+
if (!noLoader) {
|
3083
|
+
await this.blockstore.commitTransaction(tblocks, { head: advancedHead }, { add: false, noLoader });
|
3084
|
+
this.transaction = void 0;
|
3085
|
+
}
|
3086
|
+
this.setHead(advancedHead);
|
3068
3087
|
}
|
3069
3088
|
};
|
3070
3089
|
function sortClockHead(clockHead) {
|
@@ -3427,7 +3446,7 @@ import { runtimeFn as runtimeFn2 } from "@adviser/cement";
|
|
3427
3446
|
|
3428
3447
|
// src/version.ts
|
3429
3448
|
var PACKAGE_VERSION = Object.keys({
|
3430
|
-
"0.19.
|
3449
|
+
"0.19.102": "xxxx"
|
3431
3450
|
})[0];
|
3432
3451
|
export {
|
3433
3452
|
CRDT,
|