minerender 2.1.0-alpha.8 → 2.1.0-alpha.9
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/browser/index.d.mts +5 -0
- package/dist/browser/index.d.ts +5 -0
- package/dist/browser/index.js +51 -54
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +51 -54
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +51 -138
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +5 -0
- package/dist/node/index.d.ts +5 -0
- package/dist/node/index.js +51 -54
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +51 -54
- package/dist/node/index.mjs.map +1 -1
- package/package.json +2 -3
package/dist/node/index.d.mts
CHANGED
|
@@ -65,6 +65,7 @@ declare abstract class PersistentCache<B = unknown> {
|
|
|
65
65
|
static open(name: string): PersistentCache;
|
|
66
66
|
protected constructor(backing: B);
|
|
67
67
|
abstract get<T>(key: string): Promise<T>;
|
|
68
|
+
/** Loads a missing entry and stores only non-nullish results. */
|
|
68
69
|
getOrLoad<T>(key: string, loader: (key: string) => Promise<T>): Promise<T>;
|
|
69
70
|
abstract put<T>(key: string, value: T): Promise<T>;
|
|
70
71
|
abstract delete<T>(key: string): Promise<void>;
|
|
@@ -1214,6 +1215,10 @@ declare class Caching {
|
|
|
1214
1215
|
static readonly mergedModelCache: AsyncLoadingCache<CacheKey, Model>;
|
|
1215
1216
|
static readonly modelTextureAtlasCache: AsyncLoadingCache<CacheKey, TextureAtlas>;
|
|
1216
1217
|
static readonly blockStateCache: AsyncLoadingCache<CacheKey, BlockState>;
|
|
1218
|
+
static readonly listAssetCache: AsyncLoadingCache<CacheKey, ListAsset>;
|
|
1219
|
+
static readonly defaultBlockStatesCache: AsyncLoadingCache<CacheKey, DefaultBlockStates>;
|
|
1220
|
+
static readonly entityModelsCache: AsyncLoadingCache<CacheKey, EntityModels>;
|
|
1221
|
+
private static createAssetCache;
|
|
1217
1222
|
/** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
|
|
1218
1223
|
private static get all();
|
|
1219
1224
|
static clear(): void;
|
package/dist/node/index.d.ts
CHANGED
|
@@ -65,6 +65,7 @@ declare abstract class PersistentCache<B = unknown> {
|
|
|
65
65
|
static open(name: string): PersistentCache;
|
|
66
66
|
protected constructor(backing: B);
|
|
67
67
|
abstract get<T>(key: string): Promise<T>;
|
|
68
|
+
/** Loads a missing entry and stores only non-nullish results. */
|
|
68
69
|
getOrLoad<T>(key: string, loader: (key: string) => Promise<T>): Promise<T>;
|
|
69
70
|
abstract put<T>(key: string, value: T): Promise<T>;
|
|
70
71
|
abstract delete<T>(key: string): Promise<void>;
|
|
@@ -1214,6 +1215,10 @@ declare class Caching {
|
|
|
1214
1215
|
static readonly mergedModelCache: AsyncLoadingCache<CacheKey, Model>;
|
|
1215
1216
|
static readonly modelTextureAtlasCache: AsyncLoadingCache<CacheKey, TextureAtlas>;
|
|
1216
1217
|
static readonly blockStateCache: AsyncLoadingCache<CacheKey, BlockState>;
|
|
1218
|
+
static readonly listAssetCache: AsyncLoadingCache<CacheKey, ListAsset>;
|
|
1219
|
+
static readonly defaultBlockStatesCache: AsyncLoadingCache<CacheKey, DefaultBlockStates>;
|
|
1220
|
+
static readonly entityModelsCache: AsyncLoadingCache<CacheKey, EntityModels>;
|
|
1221
|
+
private static createAssetCache;
|
|
1217
1222
|
/** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
|
|
1218
1223
|
private static get all();
|
|
1219
1224
|
static clear(): void;
|
package/dist/node/index.js
CHANGED
|
@@ -28,14 +28,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
mod
|
|
29
29
|
));
|
|
30
30
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
32
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
33
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
34
|
-
if (decorator = decorators[i])
|
|
35
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
36
|
-
if (kind && result) __defProp(target, key, result);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
31
|
|
|
40
32
|
// ../../node_modules/ts-deepmerge/dist/index.js
|
|
41
33
|
var require_dist = __commonJS({
|
|
@@ -309,11 +301,14 @@ var _PersistentCache = class _PersistentCache {
|
|
|
309
301
|
static open(name) {
|
|
310
302
|
return Env.provider.openCache(name, _PersistentCache.VERSION);
|
|
311
303
|
}
|
|
304
|
+
/** Loads a missing entry and stores only non-nullish results. */
|
|
312
305
|
async getOrLoad(key, loader) {
|
|
313
306
|
let v = await this.get(key);
|
|
314
307
|
if (typeof v === "undefined" || v === null) {
|
|
315
308
|
v = await loader(key);
|
|
316
|
-
|
|
309
|
+
if (typeof v !== "undefined" && v !== null) {
|
|
310
|
+
await this.put(key, v);
|
|
311
|
+
}
|
|
317
312
|
}
|
|
318
313
|
return v;
|
|
319
314
|
}
|
|
@@ -510,7 +505,10 @@ function serializeMeshKey(key) {
|
|
|
510
505
|
// src/cache/Caching.ts
|
|
511
506
|
var import_loading_cache = require("@inventivetalent/loading-cache");
|
|
512
507
|
var import_time = require("@inventivetalent/time");
|
|
513
|
-
var
|
|
508
|
+
var _Caching = class _Caching {
|
|
509
|
+
static createAssetCache() {
|
|
510
|
+
return import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).buildAsync();
|
|
511
|
+
}
|
|
514
512
|
/** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
|
|
515
513
|
static get all() {
|
|
516
514
|
return [
|
|
@@ -527,7 +525,10 @@ var Caching = class {
|
|
|
527
525
|
this.rawModelCache,
|
|
528
526
|
this.mergedModelCache,
|
|
529
527
|
this.modelTextureAtlasCache,
|
|
530
|
-
this.blockStateCache
|
|
528
|
+
this.blockStateCache,
|
|
529
|
+
this.listAssetCache,
|
|
530
|
+
this.defaultBlockStatesCache,
|
|
531
|
+
this.entityModelsCache
|
|
531
532
|
];
|
|
532
533
|
}
|
|
533
534
|
static clear() {
|
|
@@ -553,20 +554,24 @@ var Caching = class {
|
|
|
553
554
|
};
|
|
554
555
|
}
|
|
555
556
|
};
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
557
|
+
_Caching.rawImageCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(5)).buildAsync();
|
|
558
|
+
_Caching.imageDataCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(10)).buildAsync();
|
|
559
|
+
_Caching.canvasImageDataCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(10)).buildAsync();
|
|
560
|
+
_Caching.wrappedImageCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(10)).buildAsync();
|
|
561
|
+
_Caching.boxGeometryCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(20)).build();
|
|
562
|
+
_Caching.textureCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).build();
|
|
563
|
+
_Caching.materialCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).build();
|
|
564
|
+
_Caching.boxMeshCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).build();
|
|
565
|
+
_Caching.textureAssetCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).buildAsync();
|
|
566
|
+
_Caching.textureMetaCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).buildAsync();
|
|
567
|
+
_Caching.rawModelCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).buildAsync();
|
|
568
|
+
_Caching.mergedModelCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).buildAsync();
|
|
569
|
+
_Caching.modelTextureAtlasCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).buildAsync();
|
|
570
|
+
_Caching.blockStateCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).buildAsync();
|
|
571
|
+
_Caching.listAssetCache = _Caching.createAssetCache();
|
|
572
|
+
_Caching.defaultBlockStatesCache = _Caching.createAssetCache();
|
|
573
|
+
_Caching.entityModelsCache = _Caching.createAssetCache();
|
|
574
|
+
var Caching = _Caching;
|
|
570
575
|
|
|
571
576
|
// src/Geometries.ts
|
|
572
577
|
var Geometries = class _Geometries {
|
|
@@ -1350,9 +1355,6 @@ var ModelMerger = class {
|
|
|
1350
1355
|
}
|
|
1351
1356
|
};
|
|
1352
1357
|
|
|
1353
|
-
// src/assets/Models.ts
|
|
1354
|
-
var import_typescript_memoize = require("typescript-memoize");
|
|
1355
|
-
|
|
1356
1358
|
// src/assets/source/parser/AssetParsers.ts
|
|
1357
1359
|
var AssetParser = /* @__PURE__ */ ((AssetParser2) => {
|
|
1358
1360
|
AssetParser2["MODEL"] = "model";
|
|
@@ -1366,14 +1368,14 @@ var AssetParser = /* @__PURE__ */ ((AssetParser2) => {
|
|
|
1366
1368
|
})(AssetParser || {});
|
|
1367
1369
|
|
|
1368
1370
|
// src/assets/Models.ts
|
|
1369
|
-
var
|
|
1371
|
+
var Models = class _Models {
|
|
1370
1372
|
// opened lazily: touching the store at import time would hit IndexedDB/disk just for loading
|
|
1371
1373
|
// the library, and would require an EnvProvider before any entry has had a chance to register
|
|
1372
1374
|
static get PERSISTENT_CACHE() {
|
|
1373
1375
|
return this._persistentCache ??= PersistentCache.open("minerender-models");
|
|
1374
1376
|
}
|
|
1375
1377
|
static async getItemList() {
|
|
1376
|
-
|
|
1378
|
+
const key = new AssetKey(
|
|
1377
1379
|
DEFAULT_NAMESPACE,
|
|
1378
1380
|
"_list",
|
|
1379
1381
|
"models",
|
|
@@ -1381,7 +1383,10 @@ var _Models = class _Models {
|
|
|
1381
1383
|
"assets",
|
|
1382
1384
|
".json",
|
|
1383
1385
|
DEFAULT_ROOT
|
|
1384
|
-
)
|
|
1386
|
+
);
|
|
1387
|
+
return Caching.listAssetCache.get(key.serialize(), () => {
|
|
1388
|
+
return AssetLoader.get(key, "list" /* LIST */);
|
|
1389
|
+
}).then((r) => (r == null ? void 0 : r.files) ?? []);
|
|
1385
1390
|
}
|
|
1386
1391
|
static async loadAndMerge(key) {
|
|
1387
1392
|
const model = await this.getRaw(key);
|
|
@@ -1428,19 +1433,15 @@ var _Models = class _Models {
|
|
|
1428
1433
|
return this.PERSISTENT_CACHE.clear();
|
|
1429
1434
|
}
|
|
1430
1435
|
};
|
|
1431
|
-
__decorateClass([
|
|
1432
|
-
(0, import_typescript_memoize.Memoize)()
|
|
1433
|
-
], _Models, "getItemList", 1);
|
|
1434
|
-
var Models = _Models;
|
|
1435
1436
|
|
|
1436
1437
|
// src/assets/BlockStates.ts
|
|
1437
|
-
var import_typescript_memoize2 = require("typescript-memoize");
|
|
1438
1438
|
var BlockStates = class {
|
|
1439
1439
|
static get PERSISTENT_CACHE() {
|
|
1440
1440
|
return this._persistentCache ??= PersistentCache.open("minerender-blockstates");
|
|
1441
1441
|
}
|
|
1442
|
+
// BlockState names are hardcoded
|
|
1442
1443
|
static async getList() {
|
|
1443
|
-
|
|
1444
|
+
const key = new AssetKey(
|
|
1444
1445
|
DEFAULT_NAMESPACE,
|
|
1445
1446
|
"_list",
|
|
1446
1447
|
"blockstates",
|
|
@@ -1448,11 +1449,16 @@ var BlockStates = class {
|
|
|
1448
1449
|
"assets",
|
|
1449
1450
|
".json",
|
|
1450
1451
|
DEFAULT_ROOT
|
|
1451
|
-
)
|
|
1452
|
+
);
|
|
1453
|
+
return Caching.listAssetCache.get(key.serialize(), () => {
|
|
1454
|
+
return AssetLoader.get(key, "list" /* LIST */);
|
|
1455
|
+
}).then((r) => (r == null ? void 0 : r.files) ?? []);
|
|
1452
1456
|
}
|
|
1453
1457
|
static async getDefaultStates() {
|
|
1454
1458
|
const key = AssetKey.parse("blockstates", "minerender:defaultBlockStates");
|
|
1455
|
-
return
|
|
1459
|
+
return Caching.defaultBlockStatesCache.get(key.serialize(), () => {
|
|
1460
|
+
return AssetLoader.get(key, "json" /* JSON */);
|
|
1461
|
+
});
|
|
1456
1462
|
}
|
|
1457
1463
|
static async getDefaultState(key) {
|
|
1458
1464
|
const defaultStates = await this.getDefaultStates();
|
|
@@ -1491,12 +1497,6 @@ var BlockStates = class {
|
|
|
1491
1497
|
await this.PERSISTENT_CACHE.clear();
|
|
1492
1498
|
}
|
|
1493
1499
|
};
|
|
1494
|
-
__decorateClass([
|
|
1495
|
-
(0, import_typescript_memoize2.Memoize)()
|
|
1496
|
-
], BlockStates, "getList", 1);
|
|
1497
|
-
__decorateClass([
|
|
1498
|
-
(0, import_typescript_memoize2.Memoize)()
|
|
1499
|
-
], BlockStates, "getDefaultStates", 1);
|
|
1500
1500
|
var DefaultBlockStates = class {
|
|
1501
1501
|
};
|
|
1502
1502
|
|
|
@@ -2548,17 +2548,20 @@ function shutdown() {
|
|
|
2548
2548
|
}
|
|
2549
2549
|
|
|
2550
2550
|
// src/assets/Entities.ts
|
|
2551
|
-
var import_typescript_memoize3 = require("typescript-memoize");
|
|
2552
2551
|
var Entities = class {
|
|
2553
2552
|
static async getBlockEntityModels() {
|
|
2554
2553
|
const key = AssetKey.parse("models", "minerender:blockEntityModels");
|
|
2555
2554
|
console.log(key);
|
|
2556
|
-
return
|
|
2555
|
+
return Caching.entityModelsCache.get(key.serialize(), () => {
|
|
2556
|
+
return AssetLoader.get(key, "json" /* JSON */);
|
|
2557
|
+
});
|
|
2557
2558
|
}
|
|
2558
2559
|
static async getEntityModels() {
|
|
2559
2560
|
const key = AssetKey.parse("models", "minerender:entityModels");
|
|
2560
2561
|
console.log(key);
|
|
2561
|
-
return
|
|
2562
|
+
return Caching.entityModelsCache.get(key.serialize(), () => {
|
|
2563
|
+
return AssetLoader.get(key, "json" /* JSON */);
|
|
2564
|
+
});
|
|
2562
2565
|
}
|
|
2563
2566
|
// BlockEntity names are hardcoded
|
|
2564
2567
|
static async getBlockList() {
|
|
@@ -2604,12 +2607,6 @@ var Entities = class {
|
|
|
2604
2607
|
};
|
|
2605
2608
|
}
|
|
2606
2609
|
};
|
|
2607
|
-
__decorateClass([
|
|
2608
|
-
(0, import_typescript_memoize3.Memoize)()
|
|
2609
|
-
], Entities, "getBlockEntityModels", 1);
|
|
2610
|
-
__decorateClass([
|
|
2611
|
-
(0, import_typescript_memoize3.Memoize)()
|
|
2612
|
-
], Entities, "getEntityModels", 1);
|
|
2613
2610
|
var EntityModels = class {
|
|
2614
2611
|
};
|
|
2615
2612
|
var BlockEntityModels = class {
|