minerender 2.1.0-alpha.144 → 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.
@@ -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>;
@@ -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>;
@@ -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
- return this.backing.setItem(key, value).then((res) => res.content);
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
  };
@@ -19716,6 +19727,8 @@ function sectionGeometryTransferables(pages) {
19716
19727
 
19717
19728
  // src/world/SectionWorker.ts
19718
19729
  init_Env();
19730
+ init_log();
19731
+ var log19 = logger("SectionWorker");
19719
19732
  var SectionWorker = class _SectionWorker {
19720
19733
  constructor(worker) {
19721
19734
  this.worker = worker;
@@ -19729,8 +19742,12 @@ var SectionWorker = class _SectionWorker {
19729
19742
  if (reply.type === "pages") pending.resolve(reply.pages);
19730
19743
  else pending.reject(new Error(reply.message));
19731
19744
  });
19732
- worker.addEventListener("error", (event) => this.fail(event.message || "Section worker failed"));
19733
- worker.addEventListener("messageerror", () => this.fail("Section worker message could not be deserialized"));
19745
+ const fallBack = (message) => {
19746
+ log19.warn(`${message}, so sections build on the main thread`);
19747
+ this.fail(message);
19748
+ };
19749
+ worker.addEventListener("error", (event) => fallBack(event.message || "Section worker failed"));
19750
+ worker.addEventListener("messageerror", () => fallBack("Section worker message could not be deserialized"));
19734
19751
  }
19735
19752
  static {
19736
19753
  this.initialized = false;