minerender 2.1.0-alpha.6 → 2.1.0-alpha.8

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/bundle.js CHANGED
@@ -11465,918 +11465,6 @@ var MineRender = (() => {
11465
11465
  }
11466
11466
  });
11467
11467
 
11468
- // ../../node_modules/@inventivetalent/loading-cache/dist/src/CacheEvents.js
11469
- var require_CacheEvents = __commonJS({
11470
- "../../node_modules/@inventivetalent/loading-cache/dist/src/CacheEvents.js"(exports13) {
11471
- "use strict";
11472
- init_dirname();
11473
- init_buffer2();
11474
- init_process2();
11475
- Object.defineProperty(exports13, "__esModule", { value: true });
11476
- exports13.CacheEvents = void 0;
11477
- var CacheEvents = class _CacheEvents {
11478
- static forward(source, emitter) {
11479
- _CacheEvents.ALL.forEach((e6) => {
11480
- source.on(e6, (...args) => emitter.emit(e6, ...args));
11481
- });
11482
- }
11483
- };
11484
- exports13.CacheEvents = CacheEvents;
11485
- CacheEvents.EXPIRE = "expire";
11486
- CacheEvents.STAT = "stat";
11487
- CacheEvents.ERROR = "error";
11488
- CacheEvents.ALL = [CacheEvents.EXPIRE, CacheEvents.STAT, CacheEvents.ERROR];
11489
- }
11490
- });
11491
-
11492
- // ../../node_modules/@inventivetalent/loading-cache/dist/src/CacheStats.js
11493
- var require_CacheStats = __commonJS({
11494
- "../../node_modules/@inventivetalent/loading-cache/dist/src/CacheStats.js"(exports13) {
11495
- "use strict";
11496
- init_dirname();
11497
- init_buffer2();
11498
- init_process2();
11499
- Object.defineProperty(exports13, "__esModule", { value: true });
11500
- exports13.CacheStats = void 0;
11501
- var events_1 = (init_events(), __toCommonJS(events_exports));
11502
- var CacheEvents_1 = require_CacheEvents();
11503
- var CacheStats = class extends events_1.EventEmitter {
11504
- constructor() {
11505
- super(...arguments);
11506
- this.map = /* @__PURE__ */ new Map();
11507
- }
11508
- inc(key, amount = 1) {
11509
- if (amount === 0)
11510
- return;
11511
- const prev = this.get(key);
11512
- this.map.set(key, prev + amount);
11513
- try {
11514
- this.emit(CacheEvents_1.CacheEvents.STAT, key, amount, prev);
11515
- } catch (e6) {
11516
- console.error(e6);
11517
- }
11518
- }
11519
- get(key) {
11520
- return this.map.get(key) || 0;
11521
- }
11522
- reset() {
11523
- this.map.clear();
11524
- }
11525
- toString() {
11526
- return JSON.stringify(this.map, null, 2);
11527
- }
11528
- };
11529
- exports13.CacheStats = CacheStats;
11530
- CacheStats.HIT = "hit";
11531
- CacheStats.MISS = "miss";
11532
- CacheStats.LOAD_SUCCESS = "load_success";
11533
- CacheStats.LOAD_FAIL = "load_failure";
11534
- CacheStats.EXPIRE = "expire";
11535
- CacheStats.ALL = [CacheStats.HIT, CacheStats.MISS, CacheStats.LOAD_SUCCESS, CacheStats.LOAD_FAIL, CacheStats.EXPIRE];
11536
- }
11537
- });
11538
-
11539
- // ../../node_modules/@inventivetalent/loading-cache/dist/src/util.js
11540
- var require_util = __commonJS({
11541
- "../../node_modules/@inventivetalent/loading-cache/dist/src/util.js"(exports13) {
11542
- "use strict";
11543
- init_dirname();
11544
- init_buffer2();
11545
- init_process2();
11546
- Object.defineProperty(exports13, "__esModule", { value: true });
11547
- exports13.keyPromiseMapToPromiseContainingMap = exports13.asArray = void 0;
11548
- function asArray(iterable) {
11549
- if (iterable instanceof Array) {
11550
- return iterable;
11551
- }
11552
- return Array.from(iterable);
11553
- }
11554
- exports13.asArray = asArray;
11555
- function keyPromiseMapToPromiseContainingMap(keyToPromiseMap) {
11556
- return new Promise((resolve) => {
11557
- const keys = keyToPromiseMap.keys();
11558
- const values = keyToPromiseMap.values();
11559
- Promise.all(values).then((resolvedValues) => {
11560
- const valueMap = /* @__PURE__ */ new Map();
11561
- let i4 = 0;
11562
- for (let key of keys) {
11563
- let promise = resolvedValues[i4++];
11564
- valueMap.set(key, promise);
11565
- }
11566
- resolve(valueMap);
11567
- });
11568
- });
11569
- }
11570
- exports13.keyPromiseMapToPromiseContainingMap = keyPromiseMapToPromiseContainingMap;
11571
- }
11572
- });
11573
-
11574
- // ../../node_modules/@inventivetalent/time/dist/esm/Time.js
11575
- var Time;
11576
- var init_Time = __esm({
11577
- "../../node_modules/@inventivetalent/time/dist/esm/Time.js"() {
11578
- init_dirname();
11579
- init_buffer2();
11580
- init_process2();
11581
- Time = class {
11582
- static millis(m4) {
11583
- return m4;
11584
- }
11585
- /**
11586
- * Convert seconds to milliseconds
11587
- */
11588
- static seconds(s4) {
11589
- return this.millis(s4 * 1e3);
11590
- }
11591
- /**
11592
- * Convert minutes to milliseconds
11593
- */
11594
- static minutes(m4) {
11595
- return this.seconds(m4 * 60);
11596
- }
11597
- /**
11598
- * Convert hours to milliseconds
11599
- */
11600
- static hours(h5) {
11601
- return this.minutes(h5 * 60);
11602
- }
11603
- /**
11604
- * Convert days to milliseconds
11605
- */
11606
- static days(d4) {
11607
- return this.hours(d4 * 24);
11608
- }
11609
- /**
11610
- * Get the current time in milliseconds
11611
- */
11612
- static get now() {
11613
- return Date.now();
11614
- }
11615
- };
11616
- }
11617
- });
11618
-
11619
- // ../../node_modules/@inventivetalent/time/dist/esm/index.js
11620
- var esm_exports = {};
11621
- __export(esm_exports, {
11622
- Time: () => Time
11623
- });
11624
- var init_esm = __esm({
11625
- "../../node_modules/@inventivetalent/time/dist/esm/index.js"() {
11626
- init_dirname();
11627
- init_buffer2();
11628
- init_process2();
11629
- init_Time();
11630
- }
11631
- });
11632
-
11633
- // ../../node_modules/@inventivetalent/loading-cache/dist/src/cache/CacheBase.js
11634
- var require_CacheBase = __commonJS({
11635
- "../../node_modules/@inventivetalent/loading-cache/dist/src/cache/CacheBase.js"(exports13) {
11636
- "use strict";
11637
- init_dirname();
11638
- init_buffer2();
11639
- init_process2();
11640
- Object.defineProperty(exports13, "__esModule", { value: true });
11641
- exports13.Entry = exports13.CacheBase = void 0;
11642
- var events_1 = (init_events(), __toCommonJS(events_exports));
11643
- var CacheStats_1 = require_CacheStats();
11644
- var CacheEvents_1 = require_CacheEvents();
11645
- var util_1 = require_util();
11646
- var time_1 = (init_esm(), __toCommonJS(esm_exports));
11647
- var DEFAULT_OPTIONS2 = {
11648
- expireAfterAccess: 0,
11649
- expireAfterWrite: 0,
11650
- deleteOnExpiration: true,
11651
- expirationInterval: time_1.Time.minutes(5),
11652
- recordStats: true
11653
- };
11654
- var CacheBase = class extends events_1.EventEmitter {
11655
- constructor(options) {
11656
- super({});
11657
- this.data = /* @__PURE__ */ new Map();
11658
- this._stats = new CacheStats_1.CacheStats();
11659
- this._options = Object.assign(Object.assign({}, DEFAULT_OPTIONS2), options);
11660
- this.runCleanup();
11661
- CacheEvents_1.CacheEvents.forward(this._stats, this);
11662
- }
11663
- get options() {
11664
- return this._options;
11665
- }
11666
- get stats() {
11667
- return this._stats;
11668
- }
11669
- runCleanup() {
11670
- if (this.options.deleteOnExpiration) {
11671
- this.deleteExpiredEntries();
11672
- if (this.options.expirationInterval > 0) {
11673
- this._cleanupTimeout = setTimeout(() => this.runCleanup(), this.options.expirationInterval);
11674
- }
11675
- }
11676
- }
11677
- stopCleanupTimer() {
11678
- clearTimeout(this._cleanupTimeout);
11679
- }
11680
- deleteExpiredEntries(recordStats = this.options.recordStats) {
11681
- const toDelete = [];
11682
- this.data.forEach((entry) => {
11683
- if (entry.isExpired(this.options)) {
11684
- toDelete.push(entry.getKey());
11685
- try {
11686
- this.emit(CacheEvents_1.CacheEvents.EXPIRE, entry.getKey(), entry.getValue());
11687
- } catch (e6) {
11688
- console.error(e6);
11689
- }
11690
- }
11691
- });
11692
- toDelete.forEach((k4) => this.data.delete(k4));
11693
- if (recordStats) {
11694
- this.stats.inc(CacheStats_1.CacheStats.EXPIRE, toDelete.length);
11695
- }
11696
- }
11697
- ///// GET
11698
- /**
11699
- * Get the raw entry without doing any checks
11700
- */
11701
- getEntryDirect(key) {
11702
- return this.data.get(key);
11703
- }
11704
- /**
11705
- * Get the entry after checking for expiration, or <code>undefined</code> if it doesn't exist or is expired
11706
- */
11707
- getEntryIfPresent(key, recordStats = this.options.recordStats) {
11708
- const entry = this.getEntryDirect(key);
11709
- if (!entry) {
11710
- if (recordStats) {
11711
- this.stats.inc(CacheStats_1.CacheStats.MISS);
11712
- }
11713
- return void 0;
11714
- }
11715
- if (entry.isExpired(this.options)) {
11716
- if (this.options.deleteOnExpiration) {
11717
- this.invalidateEntry(key);
11718
- if (recordStats) {
11719
- this.stats.inc(CacheStats_1.CacheStats.EXPIRE);
11720
- }
11721
- }
11722
- if (recordStats) {
11723
- this.stats.inc(CacheStats_1.CacheStats.MISS);
11724
- }
11725
- return void 0;
11726
- }
11727
- if (recordStats) {
11728
- this.stats.inc(CacheStats_1.CacheStats.HIT);
11729
- }
11730
- return entry;
11731
- }
11732
- ///// PUT
11733
- putEntry(key, entry) {
11734
- this.data.set(key, entry);
11735
- }
11736
- ///// INVALIDATE
11737
- invalidateEntry(key) {
11738
- return this.data.delete(key);
11739
- }
11740
- /////
11741
- keys() {
11742
- return util_1.asArray(this.data.keys());
11743
- }
11744
- has(key) {
11745
- return this.data.has(key);
11746
- }
11747
- end() {
11748
- this.stopCleanupTimer();
11749
- this.data.clear();
11750
- }
11751
- };
11752
- exports13.CacheBase = CacheBase;
11753
- var Entry2 = class {
11754
- constructor(key) {
11755
- this.key = key;
11756
- }
11757
- getKey() {
11758
- this.accessTime = time_1.Time.now;
11759
- return this.key;
11760
- }
11761
- getValue() {
11762
- this.accessTime = time_1.Time.now;
11763
- return this.value;
11764
- }
11765
- setValue(v5) {
11766
- this.accessTime = time_1.Time.now;
11767
- this.writeTime = time_1.Time.now;
11768
- return this.value = v5;
11769
- }
11770
- isExpired(options) {
11771
- if (options.expireAfterAccess !== 0) {
11772
- if (time_1.Time.now - this.accessTime > options.expireAfterAccess) {
11773
- return true;
11774
- }
11775
- }
11776
- if (options.expireAfterWrite !== 0) {
11777
- if (time_1.Time.now - this.writeTime > options.expireAfterWrite) {
11778
- return true;
11779
- }
11780
- }
11781
- return false;
11782
- }
11783
- };
11784
- exports13.Entry = Entry2;
11785
- }
11786
- });
11787
-
11788
- // ../../node_modules/@inventivetalent/loading-cache/dist/src/cache/SimpleCache.js
11789
- var require_SimpleCache = __commonJS({
11790
- "../../node_modules/@inventivetalent/loading-cache/dist/src/cache/SimpleCache.js"(exports13) {
11791
- "use strict";
11792
- init_dirname();
11793
- init_buffer2();
11794
- init_process2();
11795
- Object.defineProperty(exports13, "__esModule", { value: true });
11796
- exports13.SimpleCache = void 0;
11797
- var CacheBase_1 = require_CacheBase();
11798
- var CacheStats_1 = require_CacheStats();
11799
- var util_1 = require_util();
11800
- var SimpleCache2 = class extends CacheBase_1.CacheBase {
11801
- constructor(options) {
11802
- super(options);
11803
- }
11804
- ///// GET
11805
- getIfPresent(key) {
11806
- const entry = this.getEntryIfPresent(key);
11807
- if (!entry) {
11808
- return void 0;
11809
- }
11810
- return entry.getValue();
11811
- }
11812
- get(key, mappingFunction) {
11813
- return this._get(key, mappingFunction);
11814
- }
11815
- /**
11816
- * @internal
11817
- */
11818
- _get(key, mappingFunction, forceLoad = false) {
11819
- if (!forceLoad) {
11820
- const entry = this.getEntryIfPresent(key);
11821
- if (entry) {
11822
- return entry.getValue();
11823
- }
11824
- }
11825
- if (mappingFunction) {
11826
- const mapped = mappingFunction(key);
11827
- if (mapped) {
11828
- this.put(key, mapped);
11829
- }
11830
- if (this.options.recordStats) {
11831
- if (mapped) {
11832
- this.stats.inc(CacheStats_1.CacheStats.LOAD_SUCCESS);
11833
- } else {
11834
- this.stats.inc(CacheStats_1.CacheStats.LOAD_FAIL);
11835
- }
11836
- }
11837
- return mapped;
11838
- }
11839
- return void 0;
11840
- }
11841
- /// GET ALL
11842
- getAllPresentEntries(keys) {
11843
- const map = /* @__PURE__ */ new Map();
11844
- for (let key of keys) {
11845
- let val = this.getEntryIfPresent(key);
11846
- if (val) {
11847
- map.set(key, val);
11848
- }
11849
- }
11850
- return map;
11851
- }
11852
- getAllEntries(keys) {
11853
- return this.getAllPresentEntries(keys);
11854
- }
11855
- getAllPresent(keys) {
11856
- const entryMap = this.getAllPresentEntries(keys);
11857
- const map = /* @__PURE__ */ new Map();
11858
- entryMap.forEach((v5, k4) => map.set(k4, v5.getValue()));
11859
- return map;
11860
- }
11861
- getAll(keys, mappingFunction) {
11862
- const keyArray = util_1.asArray(keys);
11863
- const present = this.getAllPresent(keys);
11864
- if (mappingFunction && present.size < keyArray.length) {
11865
- const missingKeys = keyArray.filter((k4) => !present.has(k4));
11866
- if (missingKeys.length > 0) {
11867
- const mapped = mappingFunction(missingKeys);
11868
- this.putAll(mapped);
11869
- const combined = /* @__PURE__ */ new Map();
11870
- present.forEach((v5, k4) => combined.set(k4, v5));
11871
- mapped.forEach((v5, k4) => combined.set(k4, v5));
11872
- if (this.options.recordStats) {
11873
- this.stats.inc(CacheStats_1.CacheStats.LOAD_SUCCESS, mapped.size);
11874
- this.stats.inc(CacheStats_1.CacheStats.LOAD_FAIL, missingKeys.length - mapped.size);
11875
- }
11876
- return combined;
11877
- }
11878
- }
11879
- return present;
11880
- }
11881
- ///// PUT
11882
- put(key, value) {
11883
- let entry = this.getEntryIfPresent(key, false);
11884
- if (!entry) {
11885
- entry = new CacheBase_1.Entry(key);
11886
- }
11887
- entry.setValue(value);
11888
- this.putEntry(key, entry);
11889
- }
11890
- putAll(map) {
11891
- map.forEach((v5, k4) => this.put(k4, v5));
11892
- }
11893
- ///// INVALIDATE
11894
- invalidate(key) {
11895
- super.invalidateEntry(key);
11896
- }
11897
- invalidateAll(keys) {
11898
- if (!keys) {
11899
- keys = this.keys();
11900
- }
11901
- for (let key of keys) {
11902
- this.invalidate(key);
11903
- }
11904
- }
11905
- refresh(key) {
11906
- return this.getIfPresent(key);
11907
- }
11908
- };
11909
- exports13.SimpleCache = SimpleCache2;
11910
- }
11911
- });
11912
-
11913
- // ../../node_modules/@inventivetalent/loading-cache/dist/src/cache/LoadingCache.js
11914
- var require_LoadingCache = __commonJS({
11915
- "../../node_modules/@inventivetalent/loading-cache/dist/src/cache/LoadingCache.js"(exports13) {
11916
- "use strict";
11917
- init_dirname();
11918
- init_buffer2();
11919
- init_process2();
11920
- Object.defineProperty(exports13, "__esModule", { value: true });
11921
- exports13.LoadingCache = void 0;
11922
- var SimpleCache_1 = require_SimpleCache();
11923
- var events_1 = (init_events(), __toCommonJS(events_exports));
11924
- var CacheEvents_1 = require_CacheEvents();
11925
- var LoadingCache2 = class extends events_1.EventEmitter {
11926
- constructor(options, loader, multiLoader) {
11927
- super({});
11928
- this._cache = new SimpleCache_1.SimpleCache(options);
11929
- this.loader = loader;
11930
- this.multiLoader = multiLoader;
11931
- CacheEvents_1.CacheEvents.forward(this._cache, this);
11932
- }
11933
- get cache() {
11934
- return this._cache;
11935
- }
11936
- get options() {
11937
- return this.cache.options;
11938
- }
11939
- get stats() {
11940
- return this.cache.stats;
11941
- }
11942
- ///// GET
11943
- getIfPresent(key) {
11944
- return this.cache.getIfPresent(key);
11945
- }
11946
- get(key, mappingFunction, forceLoad = false) {
11947
- return this._get(key, mappingFunction, forceLoad);
11948
- }
11949
- /**
11950
- * @internal
11951
- */
11952
- _get(key, mappingFunction, forceLoad = false) {
11953
- if (!forceLoad) {
11954
- const present = this.getIfPresent(key);
11955
- if (present) {
11956
- return present;
11957
- }
11958
- }
11959
- if (mappingFunction) {
11960
- return this.cache._get(key, mappingFunction, true);
11961
- }
11962
- if (this.loader) {
11963
- return this._get(key, this.loader, true);
11964
- }
11965
- return void 0;
11966
- }
11967
- /// GET ALL
11968
- getAllPresent(keys) {
11969
- return this.cache.getAllPresent(keys);
11970
- }
11971
- getAll(keys, mappingFunction) {
11972
- return this._getAll(keys, mappingFunction);
11973
- }
11974
- /**
11975
- * @internal
11976
- */
11977
- _getAll(keys, mappingFunction) {
11978
- if (mappingFunction) {
11979
- return this.cache.getAll(keys, mappingFunction);
11980
- }
11981
- if (this.multiLoader) {
11982
- return this.cache.getAll(keys, this.multiLoader);
11983
- }
11984
- const present = this.cache.getAllPresent(keys);
11985
- if (this.loader) {
11986
- for (let key of keys) {
11987
- if (!present.has(key)) {
11988
- present.set(key, this.get(key, this.loader));
11989
- }
11990
- }
11991
- }
11992
- return present;
11993
- }
11994
- ///// PUT
11995
- put(key, value) {
11996
- this.cache.put(key, value);
11997
- }
11998
- putAll(map) {
11999
- this.cache.putAll(map);
12000
- }
12001
- ///// INVALIDATE
12002
- invalidate(key) {
12003
- this.cache.invalidate(key);
12004
- }
12005
- invalidateAll(keys) {
12006
- this.cache.invalidateAll(keys);
12007
- }
12008
- refresh(key) {
12009
- return this._get(key, null, true);
12010
- }
12011
- /////
12012
- keys() {
12013
- return this.cache.keys();
12014
- }
12015
- has(key) {
12016
- return this.cache.has(key);
12017
- }
12018
- end() {
12019
- this.cache.end();
12020
- }
12021
- };
12022
- exports13.LoadingCache = LoadingCache2;
12023
- }
12024
- });
12025
-
12026
- // ../../node_modules/@inventivetalent/loading-cache/dist/src/cache/AsyncLoadingCache.js
12027
- var require_AsyncLoadingCache = __commonJS({
12028
- "../../node_modules/@inventivetalent/loading-cache/dist/src/cache/AsyncLoadingCache.js"(exports13) {
12029
- "use strict";
12030
- init_dirname();
12031
- init_buffer2();
12032
- init_process2();
12033
- Object.defineProperty(exports13, "__esModule", { value: true });
12034
- exports13.AsyncLoadingCache = void 0;
12035
- var SimpleCache_1 = require_SimpleCache();
12036
- var CacheStats_1 = require_CacheStats();
12037
- var CacheEvents_1 = require_CacheEvents();
12038
- var events_1 = (init_events(), __toCommonJS(events_exports));
12039
- var util_1 = require_util();
12040
- var AsyncLoadingCache2 = class extends events_1.EventEmitter {
12041
- constructor(options, loader, multiLoader) {
12042
- super({});
12043
- this._cache = new SimpleCache_1.SimpleCache(options);
12044
- this.loader = loader;
12045
- this.multiLoader = multiLoader;
12046
- CacheEvents_1.CacheEvents.forward(this._cache, this);
12047
- }
12048
- get options() {
12049
- return this.cache.options;
12050
- }
12051
- get cache() {
12052
- return this._cache;
12053
- }
12054
- get stats() {
12055
- return this.cache.stats;
12056
- }
12057
- ///// GET
12058
- getIfPresent(key) {
12059
- return this.cache.getIfPresent(key);
12060
- }
12061
- get(key, mappingFunction, forceLoad = false) {
12062
- return this._get(key, mappingFunction, forceLoad);
12063
- }
12064
- /**
12065
- * @internal
12066
- */
12067
- _get(key, mappingFunction, forceLoad = false) {
12068
- if (!forceLoad) {
12069
- const present = this.getIfPresent(key);
12070
- if (present) {
12071
- return present;
12072
- }
12073
- }
12074
- if (mappingFunction) {
12075
- const mapped = mappingFunction(key);
12076
- let mappedPromise;
12077
- if (mapped instanceof Promise) {
12078
- mappedPromise = mapped;
12079
- } else {
12080
- mappedPromise = Promise.resolve(mapped);
12081
- }
12082
- this.put(key, mappedPromise);
12083
- if (this.options.recordStats) {
12084
- if (mapped) {
12085
- this.stats.inc(CacheStats_1.CacheStats.LOAD_SUCCESS);
12086
- } else {
12087
- this.stats.inc(CacheStats_1.CacheStats.LOAD_FAIL);
12088
- }
12089
- }
12090
- return mappedPromise;
12091
- }
12092
- if (this.loader) {
12093
- return this._get(key, this.loader, true);
12094
- }
12095
- return void 0;
12096
- }
12097
- /// GET ALL
12098
- getAllPresent(keys) {
12099
- const present = this.cache.getAllPresent(keys);
12100
- return util_1.keyPromiseMapToPromiseContainingMap(present);
12101
- }
12102
- getAll(keys, mappingFunction) {
12103
- return this._getAll(keys, mappingFunction);
12104
- }
12105
- /**
12106
- * @internal
12107
- */
12108
- _getAll(keys, mappingFunction) {
12109
- const keyArray = util_1.asArray(keys);
12110
- const present = this.cache.getAllPresent(keys);
12111
- if (mappingFunction && present.size < keyArray.length) {
12112
- const missingKeys = keyArray.filter((k4) => !present.has(k4));
12113
- if (missingKeys.length > 0) {
12114
- const mapped = mappingFunction(keys);
12115
- let mappedPromise;
12116
- if (mapped instanceof Promise) {
12117
- mappedPromise = mapped;
12118
- } else {
12119
- mappedPromise = Promise.resolve(mapped);
12120
- }
12121
- return Promise.all([
12122
- util_1.keyPromiseMapToPromiseContainingMap(present),
12123
- mappedPromise
12124
- ]).then(([presentMap, newMap]) => {
12125
- this.putAll(newMap);
12126
- const combined = /* @__PURE__ */ new Map();
12127
- presentMap.forEach((v5, k4) => combined.set(k4, v5));
12128
- newMap.forEach((v5, k4) => combined.set(k4, v5));
12129
- if (this.options.recordStats) {
12130
- this.stats.inc(CacheStats_1.CacheStats.LOAD_SUCCESS, newMap.size);
12131
- this.stats.inc(CacheStats_1.CacheStats.LOAD_FAIL, missingKeys.length - newMap.size);
12132
- }
12133
- return combined;
12134
- });
12135
- }
12136
- }
12137
- if (this.multiLoader) {
12138
- return this.getAll(keys, this.multiLoader);
12139
- }
12140
- if (this.loader) {
12141
- for (let key of keys) {
12142
- if (!present.has(key)) {
12143
- present.set(key, this.get(key));
12144
- }
12145
- }
12146
- }
12147
- return util_1.keyPromiseMapToPromiseContainingMap(present);
12148
- }
12149
- put(key, value) {
12150
- if (value instanceof Promise) {
12151
- this.cache.put(key, value);
12152
- } else {
12153
- this.cache.put(key, Promise.resolve(value));
12154
- }
12155
- }
12156
- putAll(map) {
12157
- map.forEach((v5, k4) => {
12158
- this.cache.put(k4, Promise.resolve(v5));
12159
- });
12160
- }
12161
- ///// INVALIDATE
12162
- invalidate(key) {
12163
- this.cache.invalidate(key);
12164
- }
12165
- invalidateAll(keys) {
12166
- this.cache.invalidateAll(keys);
12167
- }
12168
- refresh(key) {
12169
- return this._get(key, null, true);
12170
- }
12171
- /////
12172
- keys() {
12173
- return this.cache.keys();
12174
- }
12175
- has(key) {
12176
- return this.cache.has(key);
12177
- }
12178
- end() {
12179
- this.cache.end();
12180
- }
12181
- };
12182
- exports13.AsyncLoadingCache = AsyncLoadingCache2;
12183
- }
12184
- });
12185
-
12186
- // ../../node_modules/@inventivetalent/loading-cache/dist/src/cache/index.js
12187
- var require_cache = __commonJS({
12188
- "../../node_modules/@inventivetalent/loading-cache/dist/src/cache/index.js"(exports13) {
12189
- "use strict";
12190
- init_dirname();
12191
- init_buffer2();
12192
- init_process2();
12193
- var __createBinding = exports13 && exports13.__createBinding || (Object.create ? function(o4, m4, k4, k22) {
12194
- if (k22 === void 0) k22 = k4;
12195
- Object.defineProperty(o4, k22, { enumerable: true, get: function() {
12196
- return m4[k4];
12197
- } });
12198
- } : function(o4, m4, k4, k22) {
12199
- if (k22 === void 0) k22 = k4;
12200
- o4[k22] = m4[k4];
12201
- });
12202
- var __exportStar = exports13 && exports13.__exportStar || function(m4, exports14) {
12203
- for (var p16 in m4) if (p16 !== "default" && !Object.prototype.hasOwnProperty.call(exports14, p16)) __createBinding(exports14, m4, p16);
12204
- };
12205
- Object.defineProperty(exports13, "__esModule", { value: true });
12206
- __exportStar(require_CacheBase(), exports13);
12207
- __exportStar(require_SimpleCache(), exports13);
12208
- __exportStar(require_LoadingCache(), exports13);
12209
- __exportStar(require_AsyncLoadingCache(), exports13);
12210
- }
12211
- });
12212
-
12213
- // ../../node_modules/@inventivetalent/loading-cache/dist/src/Caches.js
12214
- var require_Caches = __commonJS({
12215
- "../../node_modules/@inventivetalent/loading-cache/dist/src/Caches.js"(exports13) {
12216
- "use strict";
12217
- init_dirname();
12218
- init_buffer2();
12219
- init_process2();
12220
- Object.defineProperty(exports13, "__esModule", { value: true });
12221
- exports13.Caches = void 0;
12222
- var cache_1 = require_cache();
12223
- var CacheBuilder = class {
12224
- constructor() {
12225
- this.options = {};
12226
- }
12227
- expireAfterAccess(expireAfterAccess) {
12228
- this.options.expireAfterAccess = expireAfterAccess;
12229
- return this;
12230
- }
12231
- expireAfterWrite(expireAfterWrite) {
12232
- this.options.expireAfterWrite = expireAfterWrite;
12233
- return this;
12234
- }
12235
- deleteOnExpiration(deleteOnExpiration) {
12236
- this.options.deleteOnExpiration = deleteOnExpiration;
12237
- return this;
12238
- }
12239
- expirationInterval(expirationInterval) {
12240
- this.options.expirationInterval = expirationInterval;
12241
- return this;
12242
- }
12243
- recordStats(recordStats) {
12244
- this.options.recordStats = recordStats;
12245
- return this;
12246
- }
12247
- build(loader, multiLoader) {
12248
- if (typeof loader === "undefined") {
12249
- return new cache_1.SimpleCache(this.options);
12250
- }
12251
- return new cache_1.LoadingCache(this.options, loader, multiLoader);
12252
- }
12253
- buildAsync(loader, multiLoader) {
12254
- return new cache_1.AsyncLoadingCache(this.options, loader, multiLoader);
12255
- }
12256
- };
12257
- var Caches2 = class extends CacheBuilder {
12258
- constructor() {
12259
- super();
12260
- }
12261
- static builder() {
12262
- return new CacheBuilder();
12263
- }
12264
- };
12265
- exports13.Caches = Caches2;
12266
- }
12267
- });
12268
-
12269
- // ../../node_modules/@inventivetalent/loading-cache/dist/src/loaders.js
12270
- var require_loaders = __commonJS({
12271
- "../../node_modules/@inventivetalent/loading-cache/dist/src/loaders.js"(exports13) {
12272
- "use strict";
12273
- init_dirname();
12274
- init_buffer2();
12275
- init_process2();
12276
- Object.defineProperty(exports13, "__esModule", { value: true });
12277
- }
12278
- });
12279
-
12280
- // ../../node_modules/@inventivetalent/loading-cache/dist/src/interfaces/ICacheBase.js
12281
- var require_ICacheBase = __commonJS({
12282
- "../../node_modules/@inventivetalent/loading-cache/dist/src/interfaces/ICacheBase.js"(exports13) {
12283
- "use strict";
12284
- init_dirname();
12285
- init_buffer2();
12286
- init_process2();
12287
- Object.defineProperty(exports13, "__esModule", { value: true });
12288
- }
12289
- });
12290
-
12291
- // ../../node_modules/@inventivetalent/loading-cache/dist/src/interfaces/ICache.js
12292
- var require_ICache = __commonJS({
12293
- "../../node_modules/@inventivetalent/loading-cache/dist/src/interfaces/ICache.js"(exports13) {
12294
- "use strict";
12295
- init_dirname();
12296
- init_buffer2();
12297
- init_process2();
12298
- Object.defineProperty(exports13, "__esModule", { value: true });
12299
- }
12300
- });
12301
-
12302
- // ../../node_modules/@inventivetalent/loading-cache/dist/src/interfaces/IAsyncCache.js
12303
- var require_IAsyncCache = __commonJS({
12304
- "../../node_modules/@inventivetalent/loading-cache/dist/src/interfaces/IAsyncCache.js"(exports13) {
12305
- "use strict";
12306
- init_dirname();
12307
- init_buffer2();
12308
- init_process2();
12309
- Object.defineProperty(exports13, "__esModule", { value: true });
12310
- }
12311
- });
12312
-
12313
- // ../../node_modules/@inventivetalent/loading-cache/dist/src/interfaces/ICacheEventEmitter.js
12314
- var require_ICacheEventEmitter = __commonJS({
12315
- "../../node_modules/@inventivetalent/loading-cache/dist/src/interfaces/ICacheEventEmitter.js"(exports13) {
12316
- "use strict";
12317
- init_dirname();
12318
- init_buffer2();
12319
- init_process2();
12320
- Object.defineProperty(exports13, "__esModule", { value: true });
12321
- }
12322
- });
12323
-
12324
- // ../../node_modules/@inventivetalent/loading-cache/dist/src/interfaces/index.js
12325
- var require_interfaces = __commonJS({
12326
- "../../node_modules/@inventivetalent/loading-cache/dist/src/interfaces/index.js"(exports13) {
12327
- "use strict";
12328
- init_dirname();
12329
- init_buffer2();
12330
- init_process2();
12331
- var __createBinding = exports13 && exports13.__createBinding || (Object.create ? function(o4, m4, k4, k22) {
12332
- if (k22 === void 0) k22 = k4;
12333
- Object.defineProperty(o4, k22, { enumerable: true, get: function() {
12334
- return m4[k4];
12335
- } });
12336
- } : function(o4, m4, k4, k22) {
12337
- if (k22 === void 0) k22 = k4;
12338
- o4[k22] = m4[k4];
12339
- });
12340
- var __exportStar = exports13 && exports13.__exportStar || function(m4, exports14) {
12341
- for (var p16 in m4) if (p16 !== "default" && !Object.prototype.hasOwnProperty.call(exports14, p16)) __createBinding(exports14, m4, p16);
12342
- };
12343
- Object.defineProperty(exports13, "__esModule", { value: true });
12344
- __exportStar(require_ICacheBase(), exports13);
12345
- __exportStar(require_ICache(), exports13);
12346
- __exportStar(require_IAsyncCache(), exports13);
12347
- __exportStar(require_ICacheEventEmitter(), exports13);
12348
- }
12349
- });
12350
-
12351
- // ../../node_modules/@inventivetalent/loading-cache/dist/src/index.js
12352
- var require_src = __commonJS({
12353
- "../../node_modules/@inventivetalent/loading-cache/dist/src/index.js"(exports13) {
12354
- "use strict";
12355
- init_dirname();
12356
- init_buffer2();
12357
- init_process2();
12358
- var __createBinding = exports13 && exports13.__createBinding || (Object.create ? function(o4, m4, k4, k22) {
12359
- if (k22 === void 0) k22 = k4;
12360
- Object.defineProperty(o4, k22, { enumerable: true, get: function() {
12361
- return m4[k4];
12362
- } });
12363
- } : function(o4, m4, k4, k22) {
12364
- if (k22 === void 0) k22 = k4;
12365
- o4[k22] = m4[k4];
12366
- });
12367
- var __exportStar = exports13 && exports13.__exportStar || function(m4, exports14) {
12368
- for (var p16 in m4) if (p16 !== "default" && !Object.prototype.hasOwnProperty.call(exports14, p16)) __createBinding(exports14, m4, p16);
12369
- };
12370
- Object.defineProperty(exports13, "__esModule", { value: true });
12371
- __exportStar(require_Caches(), exports13);
12372
- __exportStar(require_cache(), exports13);
12373
- __exportStar(require_loaders(), exports13);
12374
- __exportStar(require_CacheStats(), exports13);
12375
- __exportStar(require_CacheEvents(), exports13);
12376
- __exportStar(require_interfaces(), exports13);
12377
- }
12378
- });
12379
-
12380
11468
  // ../../node_modules/axios/lib/helpers/bind.js
12381
11469
  var require_bind = __commonJS({
12382
11470
  "../../node_modules/axios/lib/helpers/bind.js"(exports13, module2) {
@@ -13799,59 +12887,211 @@ var MineRender = (() => {
13799
12887
  init_buffer2();
13800
12888
  init_process2();
13801
12889
  Object.defineProperty(exports13, "__esModule", { value: true });
13802
- exports13.RunnerBase = void 0;
12890
+ exports13.RunnerBase = exports13.JobCancelledError = void 0;
12891
+ var JobCancelledError = class extends Error {
12892
+ constructor(reason) {
12893
+ super(reason === "ended" ? "Job cancelled: queue has ended" : `Job cancelled: ${reason} from queue before it ran`);
12894
+ this.reason = reason;
12895
+ this.name = "JobCancelledError";
12896
+ }
12897
+ };
12898
+ exports13.JobCancelledError = JobCancelledError;
13803
12899
  var RunnerBase = class {
13804
12900
  constructor(interval = 1e3, maxPerRun = -1) {
13805
12901
  this.interval = interval;
13806
12902
  this.maxPerRun = maxPerRun;
13807
12903
  this.queue = /* @__PURE__ */ new Map();
13808
12904
  this.running = /* @__PURE__ */ new Set();
12905
+ this.ended = false;
12906
+ this.unreffed = false;
12907
+ this.lastRunAt = Date.now();
13809
12908
  }
13810
- getAndDelete(key) {
13811
- const entries = this.queue.get(key);
13812
- this.queue.delete(key);
12909
+ /**
12910
+ * Pick the keys to run this tick and take their entries out of the queue.
12911
+ *
12912
+ * Entries are captured at dispatch time, so jobs added while a key is in flight
12913
+ * are queued for a later run instead of being resolved with a value that predates them.
12914
+ */
12915
+ takeBatch() {
12916
+ const batch = /* @__PURE__ */ new Map();
12917
+ const limit = this.maxPerRun < 0 ? Infinity : this.maxPerRun;
12918
+ if (limit < 1) {
12919
+ return batch;
12920
+ }
12921
+ for (const key of this.queue.keys()) {
12922
+ if (this.running.has(key)) {
12923
+ continue;
12924
+ }
12925
+ batch.set(key, this.queue.get(key));
12926
+ if (batch.size >= limit) {
12927
+ break;
12928
+ }
12929
+ }
12930
+ for (const key of batch.keys()) {
12931
+ this.queue.delete(key);
12932
+ this.running.add(key);
12933
+ }
12934
+ return batch;
12935
+ }
12936
+ /**
12937
+ * Mark a key as no longer in flight, allowing it to be run again.
12938
+ */
12939
+ finish(key) {
13813
12940
  this.running.delete(key);
13814
- return entries;
12941
+ this.ensureScheduled();
12942
+ }
12943
+ /**
12944
+ * Run one tick, then re-arm the timer if there is anything left to do.
12945
+ */
12946
+ tick() {
12947
+ this.task = void 0;
12948
+ this.lastRunAt = Date.now();
12949
+ try {
12950
+ this.run();
12951
+ } finally {
12952
+ this.ensureScheduled();
12953
+ }
12954
+ }
12955
+ /**
12956
+ * Whether any queued key is ready to be handed to the runner.
12957
+ */
12958
+ hasDispatchableWork() {
12959
+ for (const key of this.queue.keys()) {
12960
+ if (!this.running.has(key)) {
12961
+ return true;
12962
+ }
12963
+ }
12964
+ return false;
12965
+ }
12966
+ /**
12967
+ * Arm the timer, unless it is armed already or there is nothing to dispatch.
12968
+ *
12969
+ * An idle queue holds no timer at all, so it never keeps the process alive on its own.
12970
+ */
12971
+ ensureScheduled() {
12972
+ if (this.ended || this.task !== void 0 || !this.hasDispatchableWork()) {
12973
+ return;
12974
+ }
12975
+ const delay = Math.max(0, this.interval - (Date.now() - this.lastRunAt));
12976
+ this.task = setTimeout(() => this.tick(), delay);
12977
+ if (this.unreffed) {
12978
+ this.unrefTask();
12979
+ }
12980
+ }
12981
+ unrefTask() {
12982
+ const task = this.task;
12983
+ if (task && typeof task.unref === "function") {
12984
+ task.unref();
12985
+ }
12986
+ }
12987
+ cancelQueued(reason) {
12988
+ const queued = Array.from(this.queue.values());
12989
+ this.queue.clear();
12990
+ for (const entries of queued) {
12991
+ for (const entry of entries) {
12992
+ entry.reject(new JobCancelledError(reason));
12993
+ }
12994
+ }
13815
12995
  }
13816
12996
  /**
13817
- * Stop queue task
12997
+ * Stop the queue task.
12998
+ *
12999
+ * Jobs still queued are rejected with a {@link JobCancelledError}; jobs already handed
13000
+ * to the runner settle as normal. Once ended, the queue does not run again and
13001
+ * {@link RunnerBase.add} rejects immediately.
13818
13002
  */
13819
13003
  end() {
13820
- clearTimeout(this.task);
13004
+ this.ended = true;
13005
+ if (this.task !== void 0) {
13006
+ clearTimeout(this.task);
13007
+ this.task = void 0;
13008
+ }
13009
+ this.cancelQueued("ended");
13010
+ this.running.clear();
13821
13011
  }
13822
13012
  /**
13823
13013
  * Add a job to run to this queue
13824
13014
  * @param key unique key to store this job by - jobs with the same key will resolve/reject together
13825
- * @returns {Promise<V>}
13015
+ * @returns {Promise<V>} rejects with a {@link JobCancelledError} if the queue has ended,
13016
+ * or if the job is removed/cleared before it runs
13826
13017
  */
13827
13018
  add(key) {
13828
- return new Promise((resolve, reject) => {
13829
- let arr = this.queue.get(key);
13830
- if (!arr) {
13831
- arr = [];
13832
- }
13019
+ if (this.ended) {
13020
+ return Promise.reject(new JobCancelledError("ended"));
13021
+ }
13022
+ const promise = new Promise((resolve, reject) => {
13833
13023
  const entry = { resolve, reject };
13834
- arr.push(entry);
13835
- this.queue.set(key, arr);
13024
+ const arr = this.queue.get(key);
13025
+ if (arr) {
13026
+ arr.push(entry);
13027
+ } else {
13028
+ this.queue.set(key, [entry]);
13029
+ }
13836
13030
  });
13031
+ this.ensureScheduled();
13032
+ return promise;
13837
13033
  }
13838
13034
  /**
13839
- * Remove a job
13035
+ * Remove a queued job, rejecting its pending promises with a {@link JobCancelledError}.
13036
+ *
13037
+ * A job already handed to the runner cannot be cancelled and settles as normal.
13840
13038
  * @param key unique job key
13039
+ * @returns whether a queued job was removed
13841
13040
  */
13842
13041
  remove(key) {
13843
- this.running.delete(key);
13844
- return this.queue.delete(key);
13042
+ const entries = this.queue.get(key);
13043
+ if (!entries) {
13044
+ return false;
13045
+ }
13046
+ this.queue.delete(key);
13047
+ for (const entry of entries) {
13048
+ entry.reject(new JobCancelledError("removed"));
13049
+ }
13050
+ return true;
13051
+ }
13052
+ /**
13053
+ * Remove all queued jobs, rejecting their pending promises with a {@link JobCancelledError}.
13054
+ *
13055
+ * Jobs already handed to the runner settle as normal.
13056
+ */
13057
+ clear() {
13058
+ this.cancelQueued("cleared");
13059
+ }
13060
+ /**
13061
+ * Allow the process to exit even while jobs are still queued.
13062
+ *
13063
+ * An idle queue holds no timer anyway, so this is only needed to stop *pending*
13064
+ * jobs from keeping the process alive.
13065
+ * @see https://nodejs.org/api/timers.html#timeoutunref
13066
+ */
13067
+ unref() {
13068
+ this.unreffed = true;
13069
+ this.unrefTask();
13070
+ return this;
13071
+ }
13072
+ /**
13073
+ * Keep the process alive while this queue is running (the default).
13074
+ */
13075
+ ref() {
13076
+ this.unreffed = false;
13077
+ const task = this.task;
13078
+ if (task && typeof task.ref === "function") {
13079
+ task.ref();
13080
+ }
13081
+ return this;
13845
13082
  }
13083
+ /** number of keys waiting to be run */
13846
13084
  get size() {
13847
13085
  return this.queue.size;
13848
13086
  }
13087
+ /** number of keys currently handed to the runner */
13088
+ get activeSize() {
13089
+ return this.running.size;
13090
+ }
13091
+ /** keys waiting to be run */
13849
13092
  keys() {
13850
13093
  return this.queue.keys();
13851
13094
  }
13852
- clear() {
13853
- return this.queue.clear();
13854
- }
13855
13095
  };
13856
13096
  exports13.RunnerBase = RunnerBase;
13857
13097
  }
@@ -13870,38 +13110,35 @@ var MineRender = (() => {
13870
13110
  var JobQueue2 = class extends Base_1.RunnerBase {
13871
13111
  /**
13872
13112
  * Create a new queue
13873
- * @param interval (ms) interval to run in
13874
13113
  * @param runner function(key):Promise to execute the job
13114
+ * @param interval (ms) interval to run in
13875
13115
  * @param maxPerRun maximum queue entries to run per interval (-1 for unlimited)
13876
13116
  */
13877
13117
  constructor(runner, interval = 1e3, maxPerRun = -1) {
13878
13118
  super(interval, maxPerRun);
13879
13119
  this.runner = runner;
13880
- this.interval = interval;
13881
- this.maxPerRun = maxPerRun;
13882
- this.run();
13883
13120
  }
13884
13121
  run() {
13885
- const keys = Array.from(this.queue.keys());
13886
- const n4 = this.maxPerRun === -1 ? this.queue.size : this.maxPerRun;
13887
- const toRunKeys = Array.from(keys.slice(0, n4)).filter((k4) => !this.running.has(k4));
13888
- if (toRunKeys.length > 0) {
13889
- for (let key of toRunKeys) {
13890
- this.running.add(key);
13891
- this.runner(key).then((value) => {
13892
- const entries = this.getAndDelete(key);
13893
- if (entries) {
13894
- entries.forEach((entry) => entry.resolve(value));
13895
- }
13896
- }).catch((err) => {
13897
- const entries = this.getAndDelete(key);
13898
- if (entries) {
13899
- entries.forEach((entry) => entry.reject(err));
13900
- }
13901
- });
13902
- }
13122
+ this.takeBatch().forEach((entries, key) => {
13123
+ this.invokeRunner(key).then((value) => {
13124
+ this.finish(key);
13125
+ entries.forEach((entry) => entry.resolve(value));
13126
+ }, (err) => {
13127
+ this.finish(key);
13128
+ entries.forEach((entry) => entry.reject(err));
13129
+ });
13130
+ });
13131
+ }
13132
+ /**
13133
+ * Call the runner, turning a synchronous throw or a non-promise return value
13134
+ * into a rejected/resolved promise.
13135
+ */
13136
+ invokeRunner(key) {
13137
+ try {
13138
+ return Promise.resolve(this.runner(key));
13139
+ } catch (e6) {
13140
+ return Promise.reject(e6);
13903
13141
  }
13904
- this.task = setTimeout(() => this.run(), this.interval);
13905
13142
  }
13906
13143
  };
13907
13144
  exports13.JobQueue = JobQueue2;
@@ -13916,46 +13153,60 @@ var MineRender = (() => {
13916
13153
  init_buffer2();
13917
13154
  init_process2();
13918
13155
  Object.defineProperty(exports13, "__esModule", { value: true });
13919
- exports13.MultiJobQueue = void 0;
13156
+ exports13.MultiJobQueue = exports13.MissingResultError = void 0;
13920
13157
  var Base_1 = require_Base();
13158
+ var MissingResultError = class extends Error {
13159
+ constructor(key) {
13160
+ super(`Runner returned no result for key ${String(key)}`);
13161
+ this.key = key;
13162
+ this.name = "MissingResultError";
13163
+ }
13164
+ };
13165
+ exports13.MissingResultError = MissingResultError;
13921
13166
  var MultiJobQueue = class extends Base_1.RunnerBase {
13922
13167
  /**
13923
13168
  * Create a new queue
13169
+ * @param runner function(keys):Promise<Map> to execute the jobs
13924
13170
  * @param interval (ms) interval to run in
13925
- * @param runner function(key):Promise<Map> to execute the job
13926
13171
  * @param maxPerRun maximum queue entries to run per interval (-1 for unlimited)
13927
13172
  */
13928
13173
  constructor(runner, interval = 1e3, maxPerRun = -1) {
13929
13174
  super(interval, maxPerRun);
13930
13175
  this.runner = runner;
13931
- this.interval = interval;
13932
- this.maxPerRun = maxPerRun;
13933
- this.run();
13934
13176
  }
13935
13177
  run() {
13936
- const keys = Array.from(this.queue.keys());
13937
- const n4 = this.maxPerRun === -1 ? this.queue.size : this.maxPerRun;
13938
- const toRunKeys = Array.from(keys.slice(0, n4)).filter((k4) => !this.running.has(k4));
13939
- if (toRunKeys.length > 0) {
13940
- toRunKeys.forEach((k4) => this.running.add(k4));
13941
- this.runner(toRunKeys).then((map) => {
13942
- toRunKeys.forEach((key) => {
13178
+ const batch = this.takeBatch();
13179
+ if (batch.size < 1) {
13180
+ return;
13181
+ }
13182
+ this.invokeRunner(Array.from(batch.keys())).then((map) => {
13183
+ batch.forEach((entries, key) => {
13184
+ this.finish(key);
13185
+ if (map instanceof Map && map.has(key)) {
13943
13186
  const value = map.get(key);
13944
- const entries = this.getAndDelete(key);
13945
- if (entries) {
13946
- entries.forEach((entry) => entry.resolve(value));
13947
- }
13948
- });
13949
- }).catch((err) => {
13950
- toRunKeys.forEach((key) => {
13951
- const entries = this.getAndDelete(key);
13952
- if (entries) {
13953
- entries.forEach((entry) => entry.reject(err));
13954
- }
13955
- });
13187
+ entries.forEach((entry) => entry.resolve(value));
13188
+ } else {
13189
+ const err = new MissingResultError(key);
13190
+ entries.forEach((entry) => entry.reject(err));
13191
+ }
13192
+ });
13193
+ }, (err) => {
13194
+ batch.forEach((entries, key) => {
13195
+ this.finish(key);
13196
+ entries.forEach((entry) => entry.reject(err));
13956
13197
  });
13198
+ });
13199
+ }
13200
+ /**
13201
+ * Call the runner, turning a synchronous throw or a non-promise return value
13202
+ * into a rejected/resolved promise.
13203
+ */
13204
+ invokeRunner(keys) {
13205
+ try {
13206
+ return Promise.resolve(this.runner(keys));
13207
+ } catch (e6) {
13208
+ return Promise.reject(e6);
13957
13209
  }
13958
- this.task = setTimeout(() => this.run(), this.interval);
13959
13210
  }
13960
13211
  };
13961
13212
  exports13.MultiJobQueue = MultiJobQueue;
@@ -13963,7 +13214,7 @@ var MineRender = (() => {
13963
13214
  });
13964
13215
 
13965
13216
  // ../../node_modules/jobqu/dist/src/index.js
13966
- var require_src2 = __commonJS({
13217
+ var require_src = __commonJS({
13967
13218
  "../../node_modules/jobqu/dist/src/index.js"(exports13) {
13968
13219
  "use strict";
13969
13220
  init_dirname();
@@ -13971,9 +13222,13 @@ var MineRender = (() => {
13971
13222
  init_process2();
13972
13223
  var __createBinding = exports13 && exports13.__createBinding || (Object.create ? function(o4, m4, k4, k22) {
13973
13224
  if (k22 === void 0) k22 = k4;
13974
- Object.defineProperty(o4, k22, { enumerable: true, get: function() {
13975
- return m4[k4];
13976
- } });
13225
+ var desc = Object.getOwnPropertyDescriptor(m4, k4);
13226
+ if (!desc || ("get" in desc ? !m4.__esModule : desc.writable || desc.configurable)) {
13227
+ desc = { enumerable: true, get: function() {
13228
+ return m4[k4];
13229
+ } };
13230
+ }
13231
+ Object.defineProperty(o4, k22, desc);
13977
13232
  } : function(o4, m4, k4, k22) {
13978
13233
  if (k22 === void 0) k22 = k4;
13979
13234
  o4[k22] = m4[k4];
@@ -28228,7 +27483,7 @@ var MineRender = (() => {
28228
27483
  });
28229
27484
 
28230
27485
  // ../../node_modules/ajv/lib/compile/util.js
28231
- var require_util2 = __commonJS({
27486
+ var require_util = __commonJS({
28232
27487
  "../../node_modules/ajv/lib/compile/util.js"(exports13, module2) {
28233
27488
  "use strict";
28234
27489
  init_dirname();
@@ -28421,7 +27676,7 @@ var MineRender = (() => {
28421
27676
  init_dirname();
28422
27677
  init_buffer2();
28423
27678
  init_process2();
28424
- var util = require_util2();
27679
+ var util = require_util();
28425
27680
  module2.exports = SchemaObject;
28426
27681
  function SchemaObject(obj) {
28427
27682
  util.copy(obj, this);
@@ -28525,7 +27780,7 @@ var MineRender = (() => {
28525
27780
  init_process2();
28526
27781
  var URI = require_uri_all();
28527
27782
  var equal2 = require_fast_deep_equal();
28528
- var util = require_util2();
27783
+ var util = require_util();
28529
27784
  var SchemaObject = require_schema_obj();
28530
27785
  var traverse = require_json_schema_traverse();
28531
27786
  module2.exports = resolve;
@@ -29301,7 +28556,7 @@ var MineRender = (() => {
29301
28556
  init_buffer2();
29302
28557
  init_process2();
29303
28558
  var resolve = require_resolve();
29304
- var util = require_util2();
28559
+ var util = require_util();
29305
28560
  var errorClasses = require_error_classes();
29306
28561
  var stableStringify = require_fast_json_stable_stringify();
29307
28562
  var validateGenerator = require_validate();
@@ -29576,7 +28831,7 @@ var MineRender = (() => {
29576
28831
  });
29577
28832
 
29578
28833
  // ../../node_modules/ajv/lib/cache.js
29579
- var require_cache2 = __commonJS({
28834
+ var require_cache = __commonJS({
29580
28835
  "../../node_modules/ajv/lib/cache.js"(exports13, module2) {
29581
28836
  "use strict";
29582
28837
  init_dirname();
@@ -29607,7 +28862,7 @@ var MineRender = (() => {
29607
28862
  init_dirname();
29608
28863
  init_buffer2();
29609
28864
  init_process2();
29610
- var util = require_util2();
28865
+ var util = require_util();
29611
28866
  var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
29612
28867
  var DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
29613
28868
  var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
@@ -32356,7 +31611,7 @@ var MineRender = (() => {
32356
31611
  init_buffer2();
32357
31612
  init_process2();
32358
31613
  var ruleModules = require_dotjs();
32359
- var toHash = require_util2().toHash;
31614
+ var toHash = require_util().toHash;
32360
31615
  module2.exports = function rules() {
32361
31616
  var RULES = [
32362
31617
  {
@@ -33149,13 +32404,13 @@ var MineRender = (() => {
33149
32404
  init_process2();
33150
32405
  var compileSchema = require_compile();
33151
32406
  var resolve = require_resolve();
33152
- var Cache = require_cache2();
32407
+ var Cache = require_cache();
33153
32408
  var SchemaObject = require_schema_obj();
33154
32409
  var stableStringify = require_fast_json_stable_stringify();
33155
32410
  var formats = require_formats();
33156
32411
  var rules = require_rules();
33157
32412
  var $dataMetaSchema = require_data();
33158
- var util = require_util2();
32413
+ var util = require_util();
33159
32414
  module2.exports = Ajv;
33160
32415
  Ajv.prototype.validate = validate;
33161
32416
  Ajv.prototype.compile = compile;
@@ -40346,7 +39601,7 @@ var MineRender = (() => {
40346
39601
  });
40347
39602
 
40348
39603
  // ../../node_modules/protodef/node_modules/readable-stream/lib/ours/util.js
40349
- var require_util3 = __commonJS({
39604
+ var require_util2 = __commonJS({
40350
39605
  "../../node_modules/protodef/node_modules/readable-stream/lib/ours/util.js"(exports13, module2) {
40351
39606
  "use strict";
40352
39607
  init_dirname();
@@ -40514,8 +39769,8 @@ var MineRender = (() => {
40514
39769
  hideStackFrames,
40515
39770
  codes: { ERR_SOCKET_BAD_PORT, ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_VALUE, ERR_OUT_OF_RANGE, ERR_UNKNOWN_SIGNAL }
40516
39771
  } = require_errors();
40517
- var { normalizeEncoding } = require_util3();
40518
- var { isAsyncFunction, isArrayBufferView } = require_util3().types;
39772
+ var { normalizeEncoding } = require_util2();
39773
+ var { isAsyncFunction, isArrayBufferView } = require_util2().types;
40519
39774
  var signals = {};
40520
39775
  function isInt32(value) {
40521
39776
  return value === (value | 0);
@@ -41141,7 +40396,7 @@ var MineRender = (() => {
41141
40396
  var process5 = require_browser2();
41142
40397
  var { AbortError, codes: codes2 } = require_errors();
41143
40398
  var { ERR_INVALID_ARG_TYPE, ERR_STREAM_PREMATURE_CLOSE } = codes2;
41144
- var { kEmptyObject, once: once4 } = require_util3();
40399
+ var { kEmptyObject, once: once4 } = require_util2();
41145
40400
  var { validateAbortSignal, validateFunction, validateObject, validateBoolean } = require_validators();
41146
40401
  var { Promise: Promise2, PromisePrototypeThen, SymbolDispose } = require_primordials();
41147
40402
  var {
@@ -41314,7 +40569,7 @@ var MineRender = (() => {
41314
40569
  if (options.signal.aborted) {
41315
40570
  process5.nextTick(abort3);
41316
40571
  } else {
41317
- addAbortListener = addAbortListener || require_util3().addAbortListener;
40572
+ addAbortListener = addAbortListener || require_util2().addAbortListener;
41318
40573
  const disposable = addAbortListener(options.signal, abort3);
41319
40574
  const originalCallback = callback;
41320
40575
  callback = once4((...args) => {
@@ -41341,7 +40596,7 @@ var MineRender = (() => {
41341
40596
  if (options.signal.aborted) {
41342
40597
  process5.nextTick(abort3);
41343
40598
  } else {
41344
- addAbortListener = addAbortListener || require_util3().addAbortListener;
40599
+ addAbortListener = addAbortListener || require_util2().addAbortListener;
41345
40600
  const disposable = addAbortListener(options.signal, abort3);
41346
40601
  const originalCallback = callback;
41347
40602
  callback = once4((...args) => {
@@ -41780,7 +41035,7 @@ var MineRender = (() => {
41780
41035
  if (signal.aborted) {
41781
41036
  onAbort();
41782
41037
  } else {
41783
- addAbortListener = addAbortListener || require_util3().addAbortListener;
41038
+ addAbortListener = addAbortListener || require_util2().addAbortListener;
41784
41039
  const disposable = addAbortListener(signal, onAbort);
41785
41040
  eos(stream, disposable[SymbolDispose]);
41786
41041
  }
@@ -41798,7 +41053,7 @@ var MineRender = (() => {
41798
41053
  init_process2();
41799
41054
  var { StringPrototypeSlice, SymbolIterator, TypedArrayPrototypeSet, Uint8Array: Uint8Array2 } = require_primordials();
41800
41055
  var { Buffer: Buffer2 } = (init_buffer(), __toCommonJS(buffer_exports));
41801
- var { inspect: inspect2 } = require_util3();
41056
+ var { inspect: inspect2 } = require_util2();
41802
41057
  module2.exports = class BufferList {
41803
41058
  constructor() {
41804
41059
  this.head = null;
@@ -42421,7 +41676,7 @@ var MineRender = (() => {
42421
41676
  var { Buffer: Buffer2 } = (init_buffer(), __toCommonJS(buffer_exports));
42422
41677
  var { addAbortSignal } = require_add_abort_signal();
42423
41678
  var eos = require_end_of_stream();
42424
- var debug = require_util3().debuglog("stream", (fn) => {
41679
+ var debug = require_util2().debuglog("stream", (fn) => {
42425
41680
  debug = fn;
42426
41681
  });
42427
41682
  var BufferList = require_buffer_list();
@@ -44013,7 +43268,7 @@ var MineRender = (() => {
44013
43268
  var Duplex = require_duplex();
44014
43269
  var Readable2 = require_readable();
44015
43270
  var Writable = require_writable();
44016
- var { createDeferredPromise } = require_util3();
43271
+ var { createDeferredPromise } = require_util2();
44017
43272
  var from = require_from();
44018
43273
  var Blob2 = globalThis.Blob || bufferModule.Blob;
44019
43274
  var isBlob = typeof Blob2 !== "undefined" ? function isBlob2(b4) {
@@ -44591,7 +43846,7 @@ var MineRender = (() => {
44591
43846
  var process5 = require_browser2();
44592
43847
  var { ArrayIsArray, Promise: Promise2, SymbolAsyncIterator, SymbolDispose } = require_primordials();
44593
43848
  var eos = require_end_of_stream();
44594
- var { once: once4 } = require_util3();
43849
+ var { once: once4 } = require_util2();
44595
43850
  var destroyImpl = require_destroy();
44596
43851
  var Duplex = require_duplex();
44597
43852
  var {
@@ -44760,7 +44015,7 @@ var MineRender = (() => {
44760
44015
  function abort3() {
44761
44016
  finishImpl(new AbortError());
44762
44017
  }
44763
- addAbortListener = addAbortListener || require_util3().addAbortListener;
44018
+ addAbortListener = addAbortListener || require_util2().addAbortListener;
44764
44019
  let disposable;
44765
44020
  if (outerSignal) {
44766
44021
  disposable = addAbortListener(outerSignal, abort3);
@@ -45228,7 +44483,7 @@ var MineRender = (() => {
45228
44483
  var staticCompose = require_compose();
45229
44484
  var { addAbortSignalNoValidate } = require_add_abort_signal();
45230
44485
  var { isWritable, isNodeStream } = require_utils6();
45231
- var { deprecate: deprecate2 } = require_util3();
44486
+ var { deprecate: deprecate2 } = require_util2();
45232
44487
  var {
45233
44488
  ArrayPrototypePush,
45234
44489
  Boolean: Boolean2,
@@ -45281,7 +44536,7 @@ var MineRender = (() => {
45281
44536
  validateInteger(highWaterMark, "options.highWaterMark", 0);
45282
44537
  highWaterMark += concurrency;
45283
44538
  return async function* map2() {
45284
- const signal = require_util3().AbortSignalAny(
44539
+ const signal = require_util2().AbortSignalAny(
45285
44540
  [options === null || options === void 0 ? void 0 : options.signal].filter(Boolean2)
45286
44541
  );
45287
44542
  const stream = this;
@@ -45673,7 +44928,7 @@ var MineRender = (() => {
45673
44928
  var { ObjectDefineProperty, ObjectKeys, ReflectApply } = require_primordials();
45674
44929
  var {
45675
44930
  promisify: { custom: customPromisify }
45676
- } = require_util3();
44931
+ } = require_util2();
45677
44932
  var { streamReturningOperators, promiseReturningOperators } = require_operators();
45678
44933
  var {
45679
44934
  codes: { ERR_ILLEGAL_CONSTRUCTOR }
@@ -46907,7 +46162,7 @@ return (ctx.${type})(val)
46907
46162
  });
46908
46163
 
46909
46164
  // ../../node_modules/protodef/src/index.js
46910
- var require_src3 = __commonJS({
46165
+ var require_src2 = __commonJS({
46911
46166
  "../../node_modules/protodef/src/index.js"(exports13, module2) {
46912
46167
  init_dirname();
46913
46168
  init_buffer2();
@@ -46932,7 +46187,7 @@ return (ctx.${type})(val)
46932
46187
  init_dirname();
46933
46188
  init_buffer2();
46934
46189
  init_process2();
46935
- module2.exports = require_src3();
46190
+ module2.exports = require_src2();
46936
46191
  }
46937
46192
  });
46938
46193
 
@@ -67861,8 +67116,967 @@ return ${compiler2.callType("value", tagType)}
67861
67116
  init_dirname();
67862
67117
  init_buffer2();
67863
67118
  init_process2();
67864
- var import_loading_cache = __toESM(require_src());
67865
- init_esm();
67119
+
67120
+ // ../../node_modules/@inventivetalent/loading-cache/dist/esm/index.js
67121
+ init_dirname();
67122
+ init_buffer2();
67123
+ init_process2();
67124
+
67125
+ // ../../node_modules/@inventivetalent/loading-cache/dist/esm/Caches.js
67126
+ init_dirname();
67127
+ init_buffer2();
67128
+ init_process2();
67129
+
67130
+ // ../../node_modules/@inventivetalent/loading-cache/dist/esm/cache/index.js
67131
+ init_dirname();
67132
+ init_buffer2();
67133
+ init_process2();
67134
+
67135
+ // ../../node_modules/@inventivetalent/loading-cache/dist/esm/cache/CacheBase.js
67136
+ init_dirname();
67137
+ init_buffer2();
67138
+ init_process2();
67139
+ init_events();
67140
+
67141
+ // ../../node_modules/@inventivetalent/loading-cache/dist/esm/CacheStats.js
67142
+ init_dirname();
67143
+ init_buffer2();
67144
+ init_process2();
67145
+ init_events();
67146
+
67147
+ // ../../node_modules/@inventivetalent/loading-cache/dist/esm/CacheEvents.js
67148
+ init_dirname();
67149
+ init_buffer2();
67150
+ init_process2();
67151
+ var CacheEvents = class _CacheEvents {
67152
+ static forward(source, emitter) {
67153
+ _CacheEvents.ALL.forEach((e6) => {
67154
+ source.on(e6, (...args) => emitter.emit(e6, ...args));
67155
+ });
67156
+ }
67157
+ };
67158
+ CacheEvents.EXPIRE = "expire";
67159
+ CacheEvents.STAT = "stat";
67160
+ CacheEvents.ERROR = "error";
67161
+ CacheEvents.ALL = [CacheEvents.EXPIRE, CacheEvents.STAT, CacheEvents.ERROR];
67162
+
67163
+ // ../../node_modules/@inventivetalent/loading-cache/dist/esm/CacheStats.js
67164
+ var CacheStats = class extends EventEmitter {
67165
+ constructor() {
67166
+ super(...arguments);
67167
+ this.map = /* @__PURE__ */ new Map();
67168
+ }
67169
+ inc(key, amount = 1) {
67170
+ if (amount === 0)
67171
+ return;
67172
+ const prev = this.get(key);
67173
+ this.map.set(key, prev + amount);
67174
+ try {
67175
+ this.emit(CacheEvents.STAT, key, amount, prev);
67176
+ } catch (e6) {
67177
+ console.error(e6);
67178
+ }
67179
+ }
67180
+ get(key) {
67181
+ return this.map.get(key) || 0;
67182
+ }
67183
+ reset() {
67184
+ this.map.clear();
67185
+ }
67186
+ /**
67187
+ * All recorded stats as a plain object
67188
+ */
67189
+ toObject() {
67190
+ return Object.fromEntries(this.map);
67191
+ }
67192
+ toString() {
67193
+ return JSON.stringify(this.toObject(), null, 2);
67194
+ }
67195
+ };
67196
+ CacheStats.HIT = "hit";
67197
+ CacheStats.MISS = "miss";
67198
+ CacheStats.LOAD_SUCCESS = "load_success";
67199
+ CacheStats.LOAD_FAIL = "load_failure";
67200
+ CacheStats.EXPIRE = "expire";
67201
+ CacheStats.ALL = [CacheStats.HIT, CacheStats.MISS, CacheStats.LOAD_SUCCESS, CacheStats.LOAD_FAIL, CacheStats.EXPIRE];
67202
+
67203
+ // ../../node_modules/@inventivetalent/loading-cache/dist/esm/util.js
67204
+ init_dirname();
67205
+ init_buffer2();
67206
+ init_process2();
67207
+ function asArray(iterable) {
67208
+ if (iterable instanceof Array) {
67209
+ return iterable;
67210
+ }
67211
+ return Array.from(iterable);
67212
+ }
67213
+ function keyCompletablePromiseMapToPromiseContainingMap(keyToPromiseMap) {
67214
+ const keys = asArray(keyToPromiseMap.keys());
67215
+ const values = asArray(keyToPromiseMap.values());
67216
+ return Promise.all(values.map((p16) => p16.promise)).then((resolvedValues) => {
67217
+ const valueMap = /* @__PURE__ */ new Map();
67218
+ keys.forEach((key, i4) => {
67219
+ const value = resolvedValues[i4];
67220
+ if (typeof value !== "undefined") {
67221
+ valueMap.set(key, value);
67222
+ }
67223
+ });
67224
+ return valueMap;
67225
+ });
67226
+ }
67227
+ var CompletablePromise = class _CompletablePromise {
67228
+ constructor() {
67229
+ this._settled = false;
67230
+ this._promise = new Promise((resolve, reject) => {
67231
+ this._resolve = resolve;
67232
+ this._reject = reject;
67233
+ });
67234
+ }
67235
+ static of(value) {
67236
+ const promise = new _CompletablePromise();
67237
+ value.then((v5) => promise.resolve(v5), (e6) => promise.reject(e6));
67238
+ return promise;
67239
+ }
67240
+ static completedPromise(value) {
67241
+ const completable = new _CompletablePromise();
67242
+ completable.resolve(value);
67243
+ return completable;
67244
+ }
67245
+ get promise() {
67246
+ return this._promise;
67247
+ }
67248
+ /**
67249
+ * Whether {@link resolve} or {@link reject} has been called
67250
+ */
67251
+ get settled() {
67252
+ return this._settled;
67253
+ }
67254
+ /**
67255
+ * @deprecated use {@link settled} - this is also <code>true</code> after a rejection
67256
+ */
67257
+ get resolved() {
67258
+ return this._settled;
67259
+ }
67260
+ resolve(value) {
67261
+ if (this._settled) {
67262
+ return;
67263
+ }
67264
+ this._settled = true;
67265
+ this._resolve(value);
67266
+ }
67267
+ reject(reason) {
67268
+ if (this._settled) {
67269
+ return;
67270
+ }
67271
+ this._settled = true;
67272
+ this._reject(reason);
67273
+ }
67274
+ /**
67275
+ * Mark a rejection of this promise as handled, so it is not reported as an unhandled rejection.
67276
+ * Consumers attaching their own handlers later still observe the rejection.
67277
+ */
67278
+ ignoreRejection() {
67279
+ this._promise.catch(() => {
67280
+ });
67281
+ return this;
67282
+ }
67283
+ then(fulfilled, rejected) {
67284
+ return this._promise.then(fulfilled, rejected);
67285
+ }
67286
+ catch(rejected) {
67287
+ return this._promise.catch(rejected);
67288
+ }
67289
+ };
67290
+ function isValue(value) {
67291
+ return typeof value !== "undefined" && value !== null;
67292
+ }
67293
+
67294
+ // ../../node_modules/@inventivetalent/time/dist/esm/index.js
67295
+ init_dirname();
67296
+ init_buffer2();
67297
+ init_process2();
67298
+
67299
+ // ../../node_modules/@inventivetalent/time/dist/esm/Time.js
67300
+ init_dirname();
67301
+ init_buffer2();
67302
+ init_process2();
67303
+ var Time = class {
67304
+ static millis(m4) {
67305
+ return m4;
67306
+ }
67307
+ /**
67308
+ * Convert seconds to milliseconds
67309
+ */
67310
+ static seconds(s4) {
67311
+ return this.millis(s4 * 1e3);
67312
+ }
67313
+ /**
67314
+ * Convert minutes to milliseconds
67315
+ */
67316
+ static minutes(m4) {
67317
+ return this.seconds(m4 * 60);
67318
+ }
67319
+ /**
67320
+ * Convert hours to milliseconds
67321
+ */
67322
+ static hours(h5) {
67323
+ return this.minutes(h5 * 60);
67324
+ }
67325
+ /**
67326
+ * Convert days to milliseconds
67327
+ */
67328
+ static days(d4) {
67329
+ return this.hours(d4 * 24);
67330
+ }
67331
+ /**
67332
+ * Get the current time in milliseconds
67333
+ */
67334
+ static get now() {
67335
+ return Date.now();
67336
+ }
67337
+ };
67338
+
67339
+ // ../../node_modules/@inventivetalent/loading-cache/dist/esm/cache/CacheBase.js
67340
+ var DEFAULT_OPTIONS = {
67341
+ expireAfterAccess: 0,
67342
+ expireAfterWrite: 0,
67343
+ deleteOnExpiration: true,
67344
+ expirationInterval: Time.minutes(5),
67345
+ recordStats: true
67346
+ };
67347
+ function resolveOptions(options = {}) {
67348
+ return {
67349
+ expireAfterAccess: options.expireAfterAccess ?? DEFAULT_OPTIONS.expireAfterAccess,
67350
+ expireAfterWrite: options.expireAfterWrite ?? DEFAULT_OPTIONS.expireAfterWrite,
67351
+ deleteOnExpiration: options.deleteOnExpiration ?? DEFAULT_OPTIONS.deleteOnExpiration,
67352
+ expirationInterval: options.expirationInterval ?? DEFAULT_OPTIONS.expirationInterval,
67353
+ recordStats: options.recordStats ?? DEFAULT_OPTIONS.recordStats
67354
+ };
67355
+ }
67356
+ var CacheBase = class extends EventEmitter {
67357
+ constructor(options) {
67358
+ super({});
67359
+ this.data = /* @__PURE__ */ new Map();
67360
+ this._stats = new CacheStats();
67361
+ this._options = resolveOptions(options);
67362
+ this.runCleanup();
67363
+ CacheEvents.forward(this._stats, this);
67364
+ }
67365
+ get options() {
67366
+ return this._options;
67367
+ }
67368
+ get stats() {
67369
+ return this._stats;
67370
+ }
67371
+ runCleanup() {
67372
+ if (this.options.deleteOnExpiration) {
67373
+ this.deleteExpiredEntries();
67374
+ if (this.options.expirationInterval > 0) {
67375
+ this._cleanupTimeout = setTimeout(() => this.runCleanup(), this.options.expirationInterval);
67376
+ if (typeof this._cleanupTimeout?.unref === "function") {
67377
+ this._cleanupTimeout.unref();
67378
+ }
67379
+ }
67380
+ }
67381
+ }
67382
+ stopCleanupTimer() {
67383
+ if (typeof this._cleanupTimeout !== "undefined") {
67384
+ clearTimeout(this._cleanupTimeout);
67385
+ this._cleanupTimeout = void 0;
67386
+ }
67387
+ }
67388
+ deleteExpiredEntries(recordStats = this.options.recordStats) {
67389
+ const toDelete = [];
67390
+ this.data.forEach((entry) => {
67391
+ if (entry.isExpired(this.options)) {
67392
+ toDelete.push(entry);
67393
+ }
67394
+ });
67395
+ toDelete.forEach((entry) => {
67396
+ this.invalidateEntry(entry.peekKey());
67397
+ try {
67398
+ this.emit(CacheEvents.EXPIRE, entry.peekKey(), entry.peekValue());
67399
+ } catch (e6) {
67400
+ console.error(e6);
67401
+ }
67402
+ });
67403
+ if (recordStats) {
67404
+ this.stats.inc(CacheStats.EXPIRE, toDelete.length);
67405
+ }
67406
+ }
67407
+ ///// GET
67408
+ /**
67409
+ * Get the raw entry without doing any checks
67410
+ */
67411
+ getEntryDirect(key) {
67412
+ return this.data.get(key);
67413
+ }
67414
+ /**
67415
+ * Get the entry after checking for expiration, or <code>undefined</code> if it doesn't exist or is expired
67416
+ */
67417
+ getEntryIfPresent(key, recordStats = this.options.recordStats) {
67418
+ const entry = this.getEntryDirect(key);
67419
+ if (typeof entry === "undefined") {
67420
+ if (recordStats) {
67421
+ this.stats.inc(CacheStats.MISS);
67422
+ }
67423
+ return void 0;
67424
+ }
67425
+ if (entry.isExpired(this.options)) {
67426
+ if (this.options.deleteOnExpiration) {
67427
+ this.invalidateEntry(key);
67428
+ if (recordStats) {
67429
+ this.stats.inc(CacheStats.EXPIRE);
67430
+ }
67431
+ }
67432
+ if (recordStats) {
67433
+ this.stats.inc(CacheStats.MISS);
67434
+ }
67435
+ return void 0;
67436
+ }
67437
+ if (recordStats) {
67438
+ this.stats.inc(CacheStats.HIT);
67439
+ }
67440
+ return entry;
67441
+ }
67442
+ ///// PUT
67443
+ putEntry(key, entry) {
67444
+ this.data.set(key, entry);
67445
+ }
67446
+ ///// INVALIDATE
67447
+ invalidateEntry(key) {
67448
+ return this.data.delete(key);
67449
+ }
67450
+ /////
67451
+ /**
67452
+ * Every stored key, including entries that have expired but not been swept yet.<br/>
67453
+ * For internal bookkeeping - {@link keys} is the public, expiration-aware view.
67454
+ */
67455
+ allKeys() {
67456
+ return asArray(this.data.keys());
67457
+ }
67458
+ keys() {
67459
+ const keys = [];
67460
+ this.data.forEach((entry, key) => {
67461
+ if (!entry.isExpired(this.options)) {
67462
+ keys.push(key);
67463
+ }
67464
+ });
67465
+ return keys;
67466
+ }
67467
+ has(key) {
67468
+ const entry = this.data.get(key);
67469
+ return typeof entry !== "undefined" && !entry.isExpired(this.options);
67470
+ }
67471
+ end() {
67472
+ this.stopCleanupTimer();
67473
+ this.data.clear();
67474
+ }
67475
+ };
67476
+ var Entry = class _Entry {
67477
+ constructor(key) {
67478
+ this.key = key;
67479
+ this.accessTime = Time.now;
67480
+ this.writeTime = Time.now;
67481
+ }
67482
+ static fromJson(key, value) {
67483
+ const entry = new _Entry(key);
67484
+ entry.value = value["value"];
67485
+ entry.accessTime = value["accessTime"];
67486
+ entry.writeTime = value["writeTime"];
67487
+ return entry;
67488
+ }
67489
+ /**
67490
+ * Get the key without counting it as an access
67491
+ */
67492
+ peekKey() {
67493
+ return this.key;
67494
+ }
67495
+ /**
67496
+ * Get the value without counting it as an access
67497
+ */
67498
+ peekValue() {
67499
+ return this.value;
67500
+ }
67501
+ getKey() {
67502
+ this.accessTime = Time.now;
67503
+ return this.key;
67504
+ }
67505
+ getValue() {
67506
+ this.accessTime = Time.now;
67507
+ return this.value;
67508
+ }
67509
+ setValue(v5) {
67510
+ this.accessTime = Time.now;
67511
+ this.writeTime = Time.now;
67512
+ return this.value = v5;
67513
+ }
67514
+ isExpired(options) {
67515
+ const expireAfterAccess = options.expireAfterAccess ?? 0;
67516
+ const expireAfterWrite = options.expireAfterWrite ?? 0;
67517
+ if (expireAfterAccess > 0 && Time.now - this.accessTime > expireAfterAccess) {
67518
+ return true;
67519
+ }
67520
+ if (expireAfterWrite > 0 && Time.now - this.writeTime > expireAfterWrite) {
67521
+ return true;
67522
+ }
67523
+ return false;
67524
+ }
67525
+ };
67526
+
67527
+ // ../../node_modules/@inventivetalent/loading-cache/dist/esm/cache/SimpleCache.js
67528
+ init_dirname();
67529
+ init_buffer2();
67530
+ init_process2();
67531
+ var SimpleCache = class extends CacheBase {
67532
+ constructor(options) {
67533
+ super(options);
67534
+ }
67535
+ ///// GET
67536
+ getIfPresent(key) {
67537
+ const entry = this.getEntryIfPresent(key);
67538
+ if (typeof entry === "undefined") {
67539
+ return void 0;
67540
+ }
67541
+ return entry.getValue();
67542
+ }
67543
+ get(key, mappingFunction) {
67544
+ return this._get(key, mappingFunction);
67545
+ }
67546
+ /**
67547
+ * Get a value without recording stats, refreshing the access time or expiring the entry
67548
+ * @param key key to peek at
67549
+ * @return the mapped value or <code>undefined</code> if absent or expired
67550
+ */
67551
+ peek(key) {
67552
+ const entry = this.getEntryDirect(key);
67553
+ if (typeof entry === "undefined" || entry.isExpired(this.options)) {
67554
+ return void 0;
67555
+ }
67556
+ return entry.peekValue();
67557
+ }
67558
+ /**
67559
+ * @internal
67560
+ */
67561
+ _get(key, mappingFunction, forceLoad = false) {
67562
+ if (!forceLoad) {
67563
+ const entry = this.getEntryIfPresent(key);
67564
+ if (entry) {
67565
+ return entry.getValue();
67566
+ }
67567
+ }
67568
+ if (mappingFunction) {
67569
+ const mapped = mappingFunction(key);
67570
+ const loaded = isValue(mapped);
67571
+ if (loaded) {
67572
+ this.put(key, mapped);
67573
+ }
67574
+ if (this.options.recordStats) {
67575
+ if (loaded) {
67576
+ this.stats.inc(CacheStats.LOAD_SUCCESS);
67577
+ } else {
67578
+ this.stats.inc(CacheStats.LOAD_FAIL);
67579
+ }
67580
+ }
67581
+ return mapped;
67582
+ }
67583
+ return void 0;
67584
+ }
67585
+ /// GET ALL
67586
+ getAllPresentEntries(keys) {
67587
+ const map = /* @__PURE__ */ new Map();
67588
+ for (let key of keys) {
67589
+ let val = this.getEntryIfPresent(key);
67590
+ if (typeof val !== "undefined") {
67591
+ map.set(key, val);
67592
+ }
67593
+ }
67594
+ return map;
67595
+ }
67596
+ getAllEntries(keys) {
67597
+ return this.getAllPresentEntries(keys);
67598
+ }
67599
+ getAllPresent(keys) {
67600
+ const entryMap = this.getAllPresentEntries(keys);
67601
+ const map = /* @__PURE__ */ new Map();
67602
+ entryMap.forEach((v5, k4) => map.set(k4, v5.getValue()));
67603
+ return map;
67604
+ }
67605
+ getAll(keys, mappingFunction) {
67606
+ const keyArray = asArray(keys);
67607
+ const present = this.getAllPresent(keys);
67608
+ if (mappingFunction && present.size < keyArray.length) {
67609
+ const missingKeys = asArray(new Set(keyArray.filter((k4) => !present.has(k4))));
67610
+ if (missingKeys.length > 0) {
67611
+ const mapped = mappingFunction(missingKeys);
67612
+ if (typeof mapped === "undefined") {
67613
+ if (this.options.recordStats) {
67614
+ this.stats.inc(CacheStats.LOAD_FAIL, missingKeys.length);
67615
+ }
67616
+ return present;
67617
+ }
67618
+ this.putAll(mapped);
67619
+ const combined = /* @__PURE__ */ new Map();
67620
+ present.forEach((v5, k4) => combined.set(k4, v5));
67621
+ mapped.forEach((v5, k4) => combined.set(k4, v5));
67622
+ if (this.options.recordStats) {
67623
+ const loadedCount = missingKeys.filter((k4) => mapped.has(k4)).length;
67624
+ this.stats.inc(CacheStats.LOAD_SUCCESS, loadedCount);
67625
+ this.stats.inc(CacheStats.LOAD_FAIL, missingKeys.length - loadedCount);
67626
+ }
67627
+ return combined;
67628
+ }
67629
+ }
67630
+ return present;
67631
+ }
67632
+ ///// PUT
67633
+ put(key, value) {
67634
+ let entry = this.getEntryIfPresent(key, false);
67635
+ if (typeof entry === "undefined") {
67636
+ entry = new Entry(key);
67637
+ }
67638
+ entry.setValue(value);
67639
+ this.putEntry(key, entry);
67640
+ }
67641
+ putAll(map) {
67642
+ map.forEach((v5, k4) => this.put(k4, v5));
67643
+ }
67644
+ ///// INVALIDATE
67645
+ invalidate(key) {
67646
+ this.invalidateEntry(key);
67647
+ }
67648
+ invalidateAll(keys) {
67649
+ if (!keys) {
67650
+ keys = this.allKeys();
67651
+ }
67652
+ for (let key of keys) {
67653
+ this.invalidate(key);
67654
+ }
67655
+ }
67656
+ refresh(key) {
67657
+ return this.getIfPresent(key);
67658
+ }
67659
+ };
67660
+
67661
+ // ../../node_modules/@inventivetalent/loading-cache/dist/esm/cache/LoadingCache.js
67662
+ init_dirname();
67663
+ init_buffer2();
67664
+ init_process2();
67665
+ init_events();
67666
+ var LoadingCache = class extends EventEmitter {
67667
+ constructor(options, loader, multiLoader, internalCache) {
67668
+ super({});
67669
+ if (internalCache) {
67670
+ this._cache = internalCache(options);
67671
+ } else {
67672
+ this._cache = new SimpleCache(options);
67673
+ }
67674
+ this.loader = loader;
67675
+ this.multiLoader = multiLoader;
67676
+ CacheEvents.forward(this._cache, this);
67677
+ }
67678
+ get cache() {
67679
+ return this._cache;
67680
+ }
67681
+ get options() {
67682
+ return this.cache.options;
67683
+ }
67684
+ get stats() {
67685
+ return this.cache.stats;
67686
+ }
67687
+ ///// GET
67688
+ getIfPresent(key) {
67689
+ return this.cache.getIfPresent(key);
67690
+ }
67691
+ get(key, mappingFunction, forceLoad = false) {
67692
+ return this._get(key, mappingFunction, forceLoad);
67693
+ }
67694
+ /**
67695
+ * @internal
67696
+ */
67697
+ _get(key, mappingFunction, forceLoad = false) {
67698
+ if (!forceLoad) {
67699
+ const present = this.getIfPresent(key);
67700
+ if (typeof present !== "undefined") {
67701
+ return present;
67702
+ }
67703
+ }
67704
+ if (mappingFunction) {
67705
+ return this.cache._get(key, mappingFunction, true);
67706
+ }
67707
+ if (this.loader) {
67708
+ return this._get(key, this.loader, true);
67709
+ }
67710
+ return void 0;
67711
+ }
67712
+ /// GET ALL
67713
+ getAllPresent(keys) {
67714
+ return this.cache.getAllPresent(keys);
67715
+ }
67716
+ getAll(keys, mappingFunction) {
67717
+ return this._getAll(keys, mappingFunction);
67718
+ }
67719
+ /**
67720
+ * @internal
67721
+ */
67722
+ _getAll(keys, mappingFunction) {
67723
+ if (mappingFunction) {
67724
+ return this.cache.getAll(keys, mappingFunction);
67725
+ }
67726
+ if (this.multiLoader) {
67727
+ return this.cache.getAll(keys, this.multiLoader);
67728
+ }
67729
+ const present = this.cache.getAllPresent(keys);
67730
+ if (this.loader) {
67731
+ for (let key of keys) {
67732
+ if (!present.has(key)) {
67733
+ const loaded = this.get(key, this.loader);
67734
+ if (typeof loaded !== "undefined") {
67735
+ present.set(key, loaded);
67736
+ }
67737
+ }
67738
+ }
67739
+ }
67740
+ return present;
67741
+ }
67742
+ ///// PUT
67743
+ put(key, value) {
67744
+ this.cache.put(key, value);
67745
+ }
67746
+ putAll(map) {
67747
+ this.cache.putAll(map);
67748
+ }
67749
+ ///// INVALIDATE
67750
+ invalidate(key) {
67751
+ this.cache.invalidate(key);
67752
+ }
67753
+ invalidateAll(keys) {
67754
+ if (keys) {
67755
+ this.cache.invalidateAll(keys);
67756
+ } else {
67757
+ this.cache.invalidateAll();
67758
+ }
67759
+ }
67760
+ refresh(key) {
67761
+ return this._get(key, void 0, true);
67762
+ }
67763
+ /////
67764
+ keys() {
67765
+ return this.cache.keys();
67766
+ }
67767
+ has(key) {
67768
+ return this.cache.has(key);
67769
+ }
67770
+ end() {
67771
+ this.cache.end();
67772
+ }
67773
+ };
67774
+
67775
+ // ../../node_modules/@inventivetalent/loading-cache/dist/esm/cache/AsyncLoadingCache.js
67776
+ init_dirname();
67777
+ init_buffer2();
67778
+ init_process2();
67779
+ init_events();
67780
+ var AsyncLoadingCache = class extends EventEmitter {
67781
+ constructor(options, loader, multiLoader, internalCache) {
67782
+ super({});
67783
+ if (typeof internalCache !== "undefined") {
67784
+ this._cache = internalCache(options);
67785
+ } else {
67786
+ this._cache = new SimpleCache(options);
67787
+ }
67788
+ this.loader = loader;
67789
+ this.multiLoader = multiLoader;
67790
+ CacheEvents.forward(this._cache, this);
67791
+ }
67792
+ get options() {
67793
+ return this.cache.options;
67794
+ }
67795
+ get cache() {
67796
+ return this._cache;
67797
+ }
67798
+ get stats() {
67799
+ return this.cache.stats;
67800
+ }
67801
+ ///// GET
67802
+ getIfPresent(key) {
67803
+ return this.cache.getIfPresent(key)?.promise;
67804
+ }
67805
+ get(key, mappingFunction, forceLoad = false) {
67806
+ return this._get(key, mappingFunction, forceLoad);
67807
+ }
67808
+ /**
67809
+ * @internal
67810
+ */
67811
+ _get(key, mappingFunction, forceLoad = false) {
67812
+ if (!forceLoad) {
67813
+ const present = this.getIfPresent(key);
67814
+ if (typeof present !== "undefined") {
67815
+ return present;
67816
+ }
67817
+ }
67818
+ if (mappingFunction) {
67819
+ const mapped = mappingFunction(key);
67820
+ let mappedPromise;
67821
+ if (mapped instanceof Promise) {
67822
+ mappedPromise = mapped;
67823
+ } else {
67824
+ mappedPromise = Promise.resolve(mapped);
67825
+ }
67826
+ const completable = CompletablePromise.of(mappedPromise);
67827
+ this.cache.put(key, completable);
67828
+ this.trackLoad(key, completable, mappedPromise);
67829
+ return mappedPromise;
67830
+ }
67831
+ if (this.loader) {
67832
+ return this._get(key, this.loader, true);
67833
+ }
67834
+ return Promise.resolve(void 0);
67835
+ }
67836
+ /**
67837
+ * Record load stats once the load settles and evict entries that failed to load,
67838
+ * so a transient error doesn't poison the key for the lifetime of the cache.
67839
+ */
67840
+ trackLoad(key, completable, promise) {
67841
+ completable.ignoreRejection();
67842
+ promise.then((value) => {
67843
+ const loaded = isValue(value);
67844
+ if (this.options.recordStats) {
67845
+ this.stats.inc(loaded ? CacheStats.LOAD_SUCCESS : CacheStats.LOAD_FAIL);
67846
+ }
67847
+ if (!loaded) {
67848
+ this.invalidateIfSame(key, completable);
67849
+ }
67850
+ }, (error) => {
67851
+ if (this.options.recordStats) {
67852
+ this.stats.inc(CacheStats.LOAD_FAIL);
67853
+ }
67854
+ this.invalidateIfSame(key, completable);
67855
+ this.emitError(error);
67856
+ });
67857
+ }
67858
+ /**
67859
+ * Invalidate the key only if it still maps to the given promise, so a concurrent
67860
+ * put/refresh isn't thrown away by a load that failed afterwards.
67861
+ */
67862
+ invalidateIfSame(key, completable) {
67863
+ if (this.cache.peek(key) === completable) {
67864
+ this.cache.invalidate(key);
67865
+ }
67866
+ }
67867
+ emitError(error) {
67868
+ if (this.listenerCount(CacheEvents.ERROR) > 0) {
67869
+ try {
67870
+ this.emit(CacheEvents.ERROR, error);
67871
+ } catch (e6) {
67872
+ console.error(e6);
67873
+ }
67874
+ }
67875
+ }
67876
+ /// GET ALL
67877
+ getAllPresent(keys) {
67878
+ const present = this.cache.getAllPresent(keys);
67879
+ return keyCompletablePromiseMapToPromiseContainingMap(present);
67880
+ }
67881
+ getAll(keys, mappingFunction) {
67882
+ return this._getAll(keys, mappingFunction);
67883
+ }
67884
+ /**
67885
+ * @internal
67886
+ */
67887
+ _getAll(keys, mappingFunction) {
67888
+ const keyArray = asArray(keys);
67889
+ const present = this.cache.getAllPresent(keys);
67890
+ if (mappingFunction) {
67891
+ const missingKeys = asArray(new Set(keyArray.filter((k4) => !present.has(k4))));
67892
+ if (missingKeys.length > 0) {
67893
+ const mapped = mappingFunction(missingKeys);
67894
+ let mappedPromise;
67895
+ if (mapped instanceof Promise) {
67896
+ mappedPromise = mapped;
67897
+ } else {
67898
+ mappedPromise = Promise.resolve(mapped);
67899
+ }
67900
+ const pending = /* @__PURE__ */ new Map();
67901
+ for (let key of missingKeys) {
67902
+ const completable = new CompletablePromise();
67903
+ completable.ignoreRejection();
67904
+ pending.set(key, completable);
67905
+ this.cache.put(key, completable);
67906
+ }
67907
+ const loaded = mappedPromise.then((mappedMap) => {
67908
+ const newMap = mappedMap ?? /* @__PURE__ */ new Map();
67909
+ let loadedCount = 0;
67910
+ pending.forEach((completable, key) => {
67911
+ const value = newMap.get(key);
67912
+ completable.resolve(value);
67913
+ if (isValue(value)) {
67914
+ loadedCount++;
67915
+ } else {
67916
+ this.invalidateIfSame(key, completable);
67917
+ }
67918
+ });
67919
+ if (this.options.recordStats) {
67920
+ this.stats.inc(CacheStats.LOAD_SUCCESS, loadedCount);
67921
+ this.stats.inc(CacheStats.LOAD_FAIL, missingKeys.length - loadedCount);
67922
+ }
67923
+ return newMap;
67924
+ }, (error) => {
67925
+ pending.forEach((completable, key) => {
67926
+ completable.reject(error);
67927
+ this.invalidateIfSame(key, completable);
67928
+ });
67929
+ if (this.options.recordStats) {
67930
+ this.stats.inc(CacheStats.LOAD_FAIL, missingKeys.length);
67931
+ }
67932
+ this.emitError(error);
67933
+ throw error;
67934
+ });
67935
+ return Promise.all([
67936
+ keyCompletablePromiseMapToPromiseContainingMap(present),
67937
+ loaded
67938
+ ]).then(([presentMap, newMap]) => {
67939
+ const combined = /* @__PURE__ */ new Map();
67940
+ presentMap.forEach((v5, k4) => combined.set(k4, v5));
67941
+ newMap.forEach((v5, k4) => combined.set(k4, v5));
67942
+ return combined;
67943
+ });
67944
+ }
67945
+ return keyCompletablePromiseMapToPromiseContainingMap(present);
67946
+ }
67947
+ if (this.multiLoader) {
67948
+ return this.getAll(keys, this.multiLoader);
67949
+ }
67950
+ if (this.loader) {
67951
+ for (let key of keys) {
67952
+ if (!present.has(key)) {
67953
+ present.set(key, CompletablePromise.of(this.get(key)).ignoreRejection());
67954
+ }
67955
+ }
67956
+ }
67957
+ return keyCompletablePromiseMapToPromiseContainingMap(present);
67958
+ }
67959
+ put(key, value) {
67960
+ if (value instanceof Promise) {
67961
+ this.cache.put(key, CompletablePromise.of(value).ignoreRejection());
67962
+ } else {
67963
+ this.cache.put(key, CompletablePromise.completedPromise(value));
67964
+ }
67965
+ }
67966
+ putAll(map) {
67967
+ map.forEach((v5, k4) => {
67968
+ this.cache.put(k4, CompletablePromise.completedPromise(v5));
67969
+ });
67970
+ }
67971
+ ///// INVALIDATE
67972
+ invalidate(key) {
67973
+ this.cache.invalidate(key);
67974
+ }
67975
+ invalidateAll(keys) {
67976
+ if (keys) {
67977
+ this.cache.invalidateAll(keys);
67978
+ } else {
67979
+ this.cache.invalidateAll();
67980
+ }
67981
+ }
67982
+ refresh(key) {
67983
+ return this._get(key, void 0, true);
67984
+ }
67985
+ /////
67986
+ keys() {
67987
+ return this.cache.keys();
67988
+ }
67989
+ has(key) {
67990
+ return this.cache.has(key);
67991
+ }
67992
+ end() {
67993
+ this.cache.end();
67994
+ }
67995
+ };
67996
+
67997
+ // ../../node_modules/@inventivetalent/loading-cache/dist/esm/cache/WrappedCache.js
67998
+ init_dirname();
67999
+ init_buffer2();
68000
+ init_process2();
68001
+
68002
+ // ../../node_modules/@inventivetalent/loading-cache/dist/esm/Caches.js
68003
+ var CacheBuilder = class {
68004
+ constructor() {
68005
+ this.options = {};
68006
+ }
68007
+ expireAfterAccess(expireAfterAccess) {
68008
+ this.options.expireAfterAccess = expireAfterAccess;
68009
+ return this;
68010
+ }
68011
+ expireAfterWrite(expireAfterWrite) {
68012
+ this.options.expireAfterWrite = expireAfterWrite;
68013
+ return this;
68014
+ }
68015
+ deleteOnExpiration(deleteOnExpiration) {
68016
+ this.options.deleteOnExpiration = deleteOnExpiration;
68017
+ return this;
68018
+ }
68019
+ expirationInterval(expirationInterval) {
68020
+ this.options.expirationInterval = expirationInterval;
68021
+ return this;
68022
+ }
68023
+ recordStats(recordStats) {
68024
+ this.options.recordStats = recordStats;
68025
+ return this;
68026
+ }
68027
+ build(loader, multiLoader, loadingInternalCache) {
68028
+ if (typeof loader === "undefined") {
68029
+ if (loadingInternalCache) {
68030
+ return loadingInternalCache(this.options);
68031
+ }
68032
+ return new SimpleCache(this.options);
68033
+ }
68034
+ return new LoadingCache(this.options, loader, multiLoader, loadingInternalCache);
68035
+ }
68036
+ buildAsync(loader, multiLoader, loadingInternalCache) {
68037
+ return new AsyncLoadingCache(this.options, loader, multiLoader, loadingInternalCache);
68038
+ }
68039
+ };
68040
+ var Caches = class extends CacheBuilder {
68041
+ constructor() {
68042
+ super();
68043
+ }
68044
+ static builder() {
68045
+ return new CacheBuilder();
68046
+ }
68047
+ };
68048
+
68049
+ // ../../node_modules/@inventivetalent/loading-cache/dist/esm/loaders.js
68050
+ init_dirname();
68051
+ init_buffer2();
68052
+ init_process2();
68053
+
68054
+ // ../../node_modules/@inventivetalent/loading-cache/dist/esm/interfaces/index.js
68055
+ init_dirname();
68056
+ init_buffer2();
68057
+ init_process2();
68058
+
68059
+ // ../../node_modules/@inventivetalent/loading-cache/dist/esm/interfaces/ICacheBase.js
68060
+ init_dirname();
68061
+ init_buffer2();
68062
+ init_process2();
68063
+
68064
+ // ../../node_modules/@inventivetalent/loading-cache/dist/esm/interfaces/ICache.js
68065
+ init_dirname();
68066
+ init_buffer2();
68067
+ init_process2();
68068
+
68069
+ // ../../node_modules/@inventivetalent/loading-cache/dist/esm/interfaces/IAsyncCache.js
68070
+ init_dirname();
68071
+ init_buffer2();
68072
+ init_process2();
68073
+
68074
+ // ../../node_modules/@inventivetalent/loading-cache/dist/esm/interfaces/ICacheEventEmitter.js
68075
+ init_dirname();
68076
+ init_buffer2();
68077
+ init_process2();
68078
+
68079
+ // src/cache/Caching.ts
67866
68080
  var Caching = class {
67867
68081
  /** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
67868
68082
  static get all() {
@@ -67891,8 +68105,8 @@ return ${compiler2.callType("value", tagType)}
67891
68105
  /**
67892
68106
  * Clears every cache and stops its expiry timer.
67893
68107
  *
67894
- * loading-cache reschedules that timer indefinitely, so a Node process will not exit until
67895
- * this is called - see {@link shutdown}.
68108
+ * Expiry timers are unref'd in Node, so idle processes can exit without this cleanup.
68109
+ * Use {@link shutdown} to also stop requests and the shared Ticker.
67896
68110
  */
67897
68111
  static end() {
67898
68112
  for (const cache of this.all) {
@@ -67906,20 +68120,20 @@ return ${compiler2.callType("value", tagType)}
67906
68120
  };
67907
68121
  }
67908
68122
  };
67909
- Caching.rawImageCache = import_loading_cache.Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(5)).buildAsync();
67910
- Caching.imageDataCache = import_loading_cache.Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(10)).buildAsync();
67911
- Caching.canvasImageDataCache = import_loading_cache.Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(10)).buildAsync();
67912
- Caching.wrappedImageCache = import_loading_cache.Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(10)).buildAsync();
67913
- Caching.boxGeometryCache = import_loading_cache.Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(20)).build();
67914
- Caching.textureCache = import_loading_cache.Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).build();
67915
- Caching.materialCache = import_loading_cache.Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).build();
67916
- Caching.boxMeshCache = import_loading_cache.Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).build();
67917
- Caching.textureAssetCache = import_loading_cache.Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).buildAsync();
67918
- Caching.textureMetaCache = import_loading_cache.Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).buildAsync();
67919
- Caching.rawModelCache = import_loading_cache.Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).buildAsync();
67920
- Caching.mergedModelCache = import_loading_cache.Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).buildAsync();
67921
- Caching.modelTextureAtlasCache = import_loading_cache.Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).buildAsync();
67922
- Caching.blockStateCache = import_loading_cache.Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).buildAsync();
68123
+ Caching.rawImageCache = Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(5)).buildAsync();
68124
+ Caching.imageDataCache = Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(10)).buildAsync();
68125
+ Caching.canvasImageDataCache = Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(10)).buildAsync();
68126
+ Caching.wrappedImageCache = Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(10)).buildAsync();
68127
+ Caching.boxGeometryCache = Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(20)).build();
68128
+ Caching.textureCache = Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).build();
68129
+ Caching.materialCache = Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).build();
68130
+ Caching.boxMeshCache = Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).build();
68131
+ Caching.textureAssetCache = Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).buildAsync();
68132
+ Caching.textureMetaCache = Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).buildAsync();
68133
+ Caching.rawModelCache = Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).buildAsync();
68134
+ Caching.mergedModelCache = Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).buildAsync();
68135
+ Caching.modelTextureAtlasCache = Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).buildAsync();
68136
+ Caching.blockStateCache = Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).buildAsync();
67923
68137
 
67924
68138
  // src/Geometries.ts
67925
68139
  var Geometries = class _Geometries {
@@ -67980,8 +68194,7 @@ return ${compiler2.callType("value", tagType)}
67980
68194
  init_buffer2();
67981
68195
  init_process2();
67982
68196
  var import_axios = __toESM(require_axios2());
67983
- var import_jobqu = __toESM(require_src2());
67984
- init_esm();
68197
+ var import_jobqu = __toESM(require_src());
67985
68198
 
67986
68199
  // src/util/log.ts
67987
68200
  init_dirname();
@@ -68180,13 +68393,14 @@ return ${compiler2.callType("value", tagType)}
68180
68393
  }
68181
68394
  static get queueSizes() {
68182
68395
  return {
68183
- generic: this.genericQueue.size,
68184
- mcAsset: this.mcAssetRequestQueue.size
68396
+ generic: this.genericQueue.size + this.genericQueue.activeSize,
68397
+ mcAsset: this.mcAssetRequestQueue.size + this.mcAssetRequestQueue.activeSize
68185
68398
  };
68186
68399
  }
68187
68400
  /**
68188
- * Stops both queue timers. jobqu reschedules itself indefinitely, so a Node process will not
68189
- * exit until this is called - see {@link shutdown}.
68401
+ * Permanently stops both queues and rejects waiting and future requests.
68402
+ * Requests already running can finish. Idle queues hold no timer, so Node can exit without
68403
+ * this cleanup. See {@link shutdown}.
68190
68404
  */
68191
68405
  static end() {
68192
68406
  this.genericQueue.end();
@@ -68269,29 +68483,41 @@ return ${compiler2.callType("value", tagType)}
68269
68483
  static async loadAsync(src) {
68270
68484
  return new Promise((resolve, reject) => {
68271
68485
  const image = this._createImage();
68272
- image.src = src;
68273
68486
  image.onload = () => resolve(image);
68274
- image.onerror = (err) => reject(err);
68487
+ image.onerror = (err) => reject(err instanceof Error ? err : new Error("Failed to decode image"));
68488
+ image.src = src;
68275
68489
  });
68276
68490
  }
68277
68491
  static loadElement(src, onload, onerr) {
68278
68492
  const image = this._createImage();
68279
- image.src = src;
68280
68493
  if (onload)
68281
68494
  image.onload = onload;
68282
68495
  if (onerr)
68283
68496
  image.onerror = onerr;
68497
+ image.src = src;
68284
68498
  return image;
68285
68499
  }
68286
68500
  static async loadData(src) {
68287
68501
  console.debug(p2, "loadData", src);
68288
- return await this.infoToData(await this.getInfo(src));
68502
+ const image = await this.loadCanvasData(src);
68503
+ return image.data.getImageData(0, 0, image.width, image.height);
68289
68504
  }
68290
68505
  static async loadCanvasData(src) {
68291
- return await this.infoToCanvasData(await this.getInfo(src));
68506
+ const keyStr = serializeImageKey({ src });
68507
+ const info = this.getInfo(src);
68508
+ const cached = Caching.rawImageCache.getIfPresent(keyStr);
68509
+ try {
68510
+ return await this.infoToCanvasData(await info);
68511
+ } catch (err) {
68512
+ if (cached && Caching.rawImageCache.getIfPresent(keyStr) === cached) {
68513
+ Caching.rawImageCache.invalidate(keyStr);
68514
+ }
68515
+ throw err;
68516
+ }
68292
68517
  }
68293
68518
  static async infoToCanvasData(info) {
68294
- const image = await _ImageLoader.loadAsync(info.src);
68519
+ const type = info.type === "jpg" ? "jpeg" : info.type ?? "png";
68520
+ const image = await _ImageLoader.loadAsync(`data:image/${type};base64,${info.data.toString("base64")}`);
68295
68521
  const canvas = createCanvas(info.width, info.height);
68296
68522
  const context = canvas.getContext("2d");
68297
68523
  context.drawImage(image, 0, 0);
@@ -68302,11 +68528,8 @@ return ${compiler2.callType("value", tagType)}
68302
68528
  };
68303
68529
  }
68304
68530
  static async infoToData(info) {
68305
- const image = await _ImageLoader.loadAsync(info.src);
68306
- const canvas = createCanvas(info.width, info.height);
68307
- const context = canvas.getContext("2d");
68308
- context.drawImage(image, 0, 0);
68309
- return context.getImageData(0, 0, canvas.width, canvas.height);
68531
+ const image = await this.infoToCanvasData(info);
68532
+ return image.data.getImageData(0, 0, image.width, image.height);
68310
68533
  }
68311
68534
  static async getData(src) {
68312
68535
  const keyStr = serializeImageKey({ src });
@@ -68321,13 +68544,16 @@ return ${compiler2.callType("value", tagType)}
68321
68544
  });
68322
68545
  }
68323
68546
  static async processResponse(response) {
68324
- const src = response.config.url;
68547
+ const src = response.config?.url;
68325
68548
  const data = Buffer.from(response.data);
68326
68549
  const { width, height, type } = Env.provider.imageSize(data);
68550
+ if (!width || !height) {
68551
+ throw new Error("Invalid or unsupported image dimensions");
68552
+ }
68327
68553
  return {
68328
68554
  src,
68329
- width: width || 0,
68330
- height: height || 0,
68555
+ width,
68556
+ height,
68331
68557
  type,
68332
68558
  data
68333
68559
  };
@@ -68344,15 +68570,7 @@ return ${compiler2.callType("value", tagType)}
68344
68570
  return Requests.genericRequest({
68345
68571
  url: src,
68346
68572
  responseType: "arraybuffer"
68347
- }).then(this.processResponse).catch((err) => {
68348
- return {
68349
- src,
68350
- width: 0,
68351
- height: 0,
68352
- type: void 0,
68353
- data: Buffer.from([0])
68354
- };
68355
- });
68573
+ }).then(this.processResponse);
68356
68574
  }
68357
68575
  static async getInfo(src) {
68358
68576
  const keyStr = serializeImageKey({ src });
@@ -68374,16 +68592,22 @@ return ${compiler2.callType("value", tagType)}
68374
68592
 
68375
68593
  // src/texture/TextureLoader.ts
68376
68594
  var TextureLoader = class {
68595
+ /** Reports whether image loading failed, so cached textures can be retried. */
68596
+ static hasFailed(texture) {
68597
+ return this.failedTextures.has(texture);
68598
+ }
68377
68599
  static createTexture() {
68378
68600
  return new Texture();
68379
68601
  }
68380
68602
  static loadInBackground(src, format2 = RGBAFormat, rotation = 0) {
68381
68603
  const texture = this.createTexture();
68382
68604
  texture.colorSpace = SRGBColorSpace;
68383
- const image = ImageLoader.loadElement(src);
68384
- image.onload = function() {
68605
+ const image = ImageLoader.loadElement(src, () => {
68385
68606
  texture.needsUpdate = true;
68386
- };
68607
+ }, (error) => {
68608
+ this.failedTextures.add(texture);
68609
+ console.warn("Failed to load texture", src, error);
68610
+ });
68387
68611
  texture.image = image;
68388
68612
  texture.format = format2;
68389
68613
  texture.rotation = rotation;
@@ -68393,14 +68617,18 @@ return ${compiler2.callType("value", tagType)}
68393
68617
  const texture = new Texture();
68394
68618
  texture.colorSpace = SRGBColorSpace;
68395
68619
  ImageLoader.getData(src).then((image) => {
68396
- texture.needsUpdate = true;
68397
68620
  texture.image = image;
68621
+ texture.needsUpdate = true;
68622
+ }).catch((error) => {
68623
+ this.failedTextures.add(texture);
68624
+ console.warn("Failed to load texture", src, error);
68398
68625
  });
68399
68626
  texture.format = format2;
68400
68627
  texture.rotation = rotation;
68401
68628
  return Textures.initTextureProps(texture);
68402
68629
  }
68403
68630
  };
68631
+ TextureLoader.failedTextures = /* @__PURE__ */ new WeakSet();
68404
68632
 
68405
68633
  // src/texture/Textures.ts
68406
68634
  var Textures = class _Textures {
@@ -68423,6 +68651,10 @@ return ${compiler2.callType("value", tagType)}
68423
68651
  }
68424
68652
  static getImage(key) {
68425
68653
  const keyStr = serializeTextureKey(key);
68654
+ const cached = Caching.textureCache.peek(keyStr);
68655
+ if (cached && TextureLoader.hasFailed(cached)) {
68656
+ Caching.textureCache.invalidate(keyStr);
68657
+ }
68426
68658
  return Caching.textureCache.get(keyStr, (k4) => {
68427
68659
  return _Textures.createImage(key);
68428
68660
  });
@@ -68567,6 +68799,10 @@ return ${compiler2.callType("value", tagType)}
68567
68799
  }
68568
68800
  static getImage(key) {
68569
68801
  const keyStr = serializeMaterialKey(key);
68802
+ const map = Caching.materialCache.peek(keyStr)?.map;
68803
+ if (map && TextureLoader.hasFailed(map)) {
68804
+ Caching.materialCache.invalidate(keyStr);
68805
+ }
68570
68806
  return Caching.materialCache.get(keyStr, (k4) => {
68571
68807
  return _Materials.createImage(key);
68572
68808
  });
@@ -69078,7 +69314,7 @@ return ${compiler2.callType("value", tagType)}
69078
69314
  // src/assets/source/HostedAssetSource.ts
69079
69315
  var import_ts_deepmerge2 = __toESM(require_dist());
69080
69316
  var p6 = prefix("HostedAssetSource");
69081
- var DEFAULT_OPTIONS = {
69317
+ var DEFAULT_OPTIONS2 = {
69082
69318
  retryDefaults: true
69083
69319
  };
69084
69320
  var _HostedAssetSource = class _HostedAssetSource extends AssetSource {
@@ -69148,7 +69384,7 @@ return ${compiler2.callType("value", tagType)}
69148
69384
  constructor(root, options) {
69149
69385
  super();
69150
69386
  this._root = root;
69151
- this._options = (0, import_ts_deepmerge2.default)({}, DEFAULT_OPTIONS, options ?? {});
69387
+ this._options = (0, import_ts_deepmerge2.default)({}, DEFAULT_OPTIONS2, options ?? {});
69152
69388
  }
69153
69389
  get root() {
69154
69390
  return this._root;
@@ -78054,7 +78290,7 @@ return ${compiler2.callType("value", tagType)}
78054
78290
  "extraFieldNTFS",
78055
78291
  "extraFieldExtendedTimestamp"
78056
78292
  ];
78057
- var Entry = class {
78293
+ var Entry2 = class {
78058
78294
  constructor(data) {
78059
78295
  PROPERTY_NAMES.forEach((name2) => this[name2] = data[name2]);
78060
78296
  }
@@ -78261,13 +78497,13 @@ return ${compiler2.callType("value", tagType)}
78261
78497
  startOffset = Math.max(offsetFileEntry, startOffset);
78262
78498
  readCommonFooter(fileEntry, fileEntry, directoryView, offset + 6);
78263
78499
  fileEntry.zipCrypto = fileEntry.encrypted && !fileEntry.extraFieldAES;
78264
- const entry = new Entry(fileEntry);
78500
+ const entry = new Entry2(fileEntry);
78265
78501
  entry.getData = (writer, options2) => fileEntry.getData(writer, entry, options2);
78266
78502
  offset = endOffset;
78267
78503
  const { onprogress } = options;
78268
78504
  if (onprogress) {
78269
78505
  try {
78270
- await onprogress(indexFile + 1, filesLength, new Entry(fileEntry));
78506
+ await onprogress(indexFile + 1, filesLength, new Entry2(fileEntry));
78271
78507
  } catch (_4) {
78272
78508
  }
78273
78509
  }
@@ -78854,11 +79090,21 @@ return ${compiler2.callType("value", tagType)}
78854
79090
  return this._persistentMetaCache ?? (this._persistentMetaCache = PersistentCache.open("minerender-texturemeta"));
78855
79091
  }
78856
79092
  static async get(key) {
78857
- const asset = await this.preload(key);
78858
- if (asset) {
78859
- return ImageLoader.infoToCanvasData(asset);
79093
+ const keyStr = key.serialize();
79094
+ const pending = this.preload(key);
79095
+ const cached = Caching.textureAssetCache.getIfPresent(keyStr);
79096
+ try {
79097
+ const asset = await pending;
79098
+ if (asset) {
79099
+ return await ImageLoader.infoToCanvasData(asset);
79100
+ }
79101
+ return void 0;
79102
+ } catch (err) {
79103
+ if (cached && Caching.textureAssetCache.getIfPresent(keyStr) === cached) {
79104
+ Caching.textureAssetCache.invalidate(keyStr);
79105
+ }
79106
+ throw err;
78860
79107
  }
78861
- return void 0;
78862
79108
  }
78863
79109
  static async preload(key) {
78864
79110
  const keyStr = key.serialize();
@@ -80153,8 +80399,8 @@ return ${compiler2.callType("value", tagType)}
80153
80399
  dispose() {
80154
80400
  super.dispose();
80155
80401
  }
80156
- async loadTextures() {
80157
- this.imageData = await ModelTextures.get(new AssetKey(
80402
+ get textureKey() {
80403
+ return new AssetKey(
80158
80404
  this.entity.key?.namespace ?? DEFAULT_NAMESPACE,
80159
80405
  this.entity.key.path,
80160
80406
  //TODO: texture may differ from entity name; most of them are in subdirectories for multiple variants etc.
@@ -80162,7 +80408,10 @@ return ${compiler2.callType("value", tagType)}
80162
80408
  "entity",
80163
80409
  "assets",
80164
80410
  ".png"
80165
- ));
80411
+ );
80412
+ }
80413
+ async loadTextures() {
80414
+ this.imageData = await ModelTextures.get(this.textureKey);
80166
80415
  }
80167
80416
  //TODO: abstract this, since extracted model data can be used for entities, blocks, players
80168
80417
  createMeshes(force = false) {
@@ -80195,20 +80444,23 @@ return ${compiler2.callType("value", tagType)}
80195
80444
  this.meshesCreated = true;
80196
80445
  }
80197
80446
  async applyTextures() {
80198
- const textureAsset = await ModelTextures.preload(new AssetKey(
80199
- this.entity.key?.namespace ?? DEFAULT_NAMESPACE,
80200
- this.entity.key.path,
80201
- "textures",
80202
- "entity",
80203
- "assets",
80204
- ".png"
80205
- ));
80206
- if (textureAsset) {
80207
- let mat = Materials.getImage({ texture: { src: textureAsset.src } });
80208
- this.iterateAllMeshes((mesh) => {
80209
- mesh.material = mat;
80210
- });
80211
- }
80447
+ const assetKeyStr = this.textureKey.serialize();
80448
+ const keyStr = `entity:${assetKeyStr}`;
80449
+ let mat = Caching.materialCache.getIfPresent(keyStr);
80450
+ if (!mat) {
80451
+ const pending = this.loadTextures();
80452
+ const cachedAsset = Caching.textureAssetCache.getIfPresent(assetKeyStr);
80453
+ await pending;
80454
+ if (!this.imageData) return;
80455
+ const canvas = this.imageData.data.canvas;
80456
+ const createMaterial = () => Materials.createBasicCanvasMaterial(canvas);
80457
+ mat = cachedAsset && Caching.textureAssetCache.getIfPresent(assetKeyStr) === cachedAsset ? Caching.materialCache.get(keyStr, createMaterial) : createMaterial();
80458
+ this.imageData = void 0;
80459
+ }
80460
+ this.iterateAllMeshes((mesh) => {
80461
+ mesh.material = mat;
80462
+ });
80463
+ this.notifyDirty();
80212
80464
  }
80213
80465
  };
80214
80466
  EntityObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge4.default)({}, SceneObject.DEFAULT_OPTIONS, {});