minerender 2.1.0-alpha.145 → 2.1.0-alpha.146
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/node/index.d.mts +1 -0
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +13 -2
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +13 -2
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.d.mts
CHANGED
|
@@ -4459,6 +4459,7 @@ declare function registerNodeEnv(): NodeEnv;
|
|
|
4459
4459
|
*/
|
|
4460
4460
|
declare class NodeCache extends PersistentCache<LocalStorage> {
|
|
4461
4461
|
private initialized;
|
|
4462
|
+
private readonly pendingWrites;
|
|
4462
4463
|
constructor(backing: LocalStorage);
|
|
4463
4464
|
private ready;
|
|
4464
4465
|
get<T>(key: string): Promise<T>;
|
package/dist/node/index.d.ts
CHANGED
|
@@ -4459,6 +4459,7 @@ declare function registerNodeEnv(): NodeEnv;
|
|
|
4459
4459
|
*/
|
|
4460
4460
|
declare class NodeCache extends PersistentCache<LocalStorage> {
|
|
4461
4461
|
private initialized;
|
|
4462
|
+
private readonly pendingWrites;
|
|
4462
4463
|
constructor(backing: LocalStorage);
|
|
4463
4464
|
private ready;
|
|
4464
4465
|
get<T>(key: string): Promise<T>;
|
package/dist/node/index.js
CHANGED
|
@@ -11750,6 +11750,7 @@ init_PersistentCache();
|
|
|
11750
11750
|
var NodeCache = class extends PersistentCache {
|
|
11751
11751
|
constructor(backing) {
|
|
11752
11752
|
super(backing);
|
|
11753
|
+
this.pendingWrites = /* @__PURE__ */ new Map();
|
|
11753
11754
|
}
|
|
11754
11755
|
ready() {
|
|
11755
11756
|
return this.initialized ??= this.backing.init();
|
|
@@ -11760,7 +11761,14 @@ var NodeCache = class extends PersistentCache {
|
|
|
11760
11761
|
}
|
|
11761
11762
|
async put(key, value) {
|
|
11762
11763
|
await this.ready();
|
|
11763
|
-
|
|
11764
|
+
const previous = this.pendingWrites.get(key);
|
|
11765
|
+
const write = (previous ? previous.catch(() => void 0) : Promise.resolve()).then(() => this.backing.setItem(key, value)).then(() => value);
|
|
11766
|
+
this.pendingWrites.set(key, write);
|
|
11767
|
+
try {
|
|
11768
|
+
return await write;
|
|
11769
|
+
} finally {
|
|
11770
|
+
if (this.pendingWrites.get(key) === write) this.pendingWrites.delete(key);
|
|
11771
|
+
}
|
|
11764
11772
|
}
|
|
11765
11773
|
async delete(key) {
|
|
11766
11774
|
await this.ready();
|
|
@@ -11806,7 +11814,10 @@ var NodeEnv = class {
|
|
|
11806
11814
|
openCache(name, version2) {
|
|
11807
11815
|
return new NodeCache(import_node_persist.default.create({
|
|
11808
11816
|
dir: name + version2,
|
|
11809
|
-
encoding: "utf8"
|
|
11817
|
+
encoding: "utf8",
|
|
11818
|
+
// node-persist's unref'd one-second write queue delays loads and lets Node exit before writes finish.
|
|
11819
|
+
// NodeCache serializes writes to each key while allowing different files to write concurrently.
|
|
11820
|
+
writeQueue: false
|
|
11810
11821
|
}));
|
|
11811
11822
|
}
|
|
11812
11823
|
};
|