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/browser/index.d.mts
CHANGED
|
@@ -64,6 +64,7 @@ declare abstract class PersistentCache<B = unknown> {
|
|
|
64
64
|
static open(name: string): PersistentCache;
|
|
65
65
|
protected constructor(backing: B);
|
|
66
66
|
abstract get<T>(key: string): Promise<T>;
|
|
67
|
+
/** Loads a missing entry and stores only non-nullish results. */
|
|
67
68
|
getOrLoad<T>(key: string, loader: (key: string) => Promise<T>): Promise<T>;
|
|
68
69
|
abstract put<T>(key: string, value: T): Promise<T>;
|
|
69
70
|
abstract delete<T>(key: string): Promise<void>;
|
|
@@ -1213,6 +1214,10 @@ declare class Caching {
|
|
|
1213
1214
|
static readonly mergedModelCache: AsyncLoadingCache<CacheKey, Model>;
|
|
1214
1215
|
static readonly modelTextureAtlasCache: AsyncLoadingCache<CacheKey, TextureAtlas>;
|
|
1215
1216
|
static readonly blockStateCache: AsyncLoadingCache<CacheKey, BlockState>;
|
|
1217
|
+
static readonly listAssetCache: AsyncLoadingCache<CacheKey, ListAsset>;
|
|
1218
|
+
static readonly defaultBlockStatesCache: AsyncLoadingCache<CacheKey, DefaultBlockStates>;
|
|
1219
|
+
static readonly entityModelsCache: AsyncLoadingCache<CacheKey, EntityModels>;
|
|
1220
|
+
private static createAssetCache;
|
|
1216
1221
|
/** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
|
|
1217
1222
|
private static get all();
|
|
1218
1223
|
static clear(): void;
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -64,6 +64,7 @@ declare abstract class PersistentCache<B = unknown> {
|
|
|
64
64
|
static open(name: string): PersistentCache;
|
|
65
65
|
protected constructor(backing: B);
|
|
66
66
|
abstract get<T>(key: string): Promise<T>;
|
|
67
|
+
/** Loads a missing entry and stores only non-nullish results. */
|
|
67
68
|
getOrLoad<T>(key: string, loader: (key: string) => Promise<T>): Promise<T>;
|
|
68
69
|
abstract put<T>(key: string, value: T): Promise<T>;
|
|
69
70
|
abstract delete<T>(key: string): Promise<void>;
|
|
@@ -1213,6 +1214,10 @@ declare class Caching {
|
|
|
1213
1214
|
static readonly mergedModelCache: AsyncLoadingCache<CacheKey, Model>;
|
|
1214
1215
|
static readonly modelTextureAtlasCache: AsyncLoadingCache<CacheKey, TextureAtlas>;
|
|
1215
1216
|
static readonly blockStateCache: AsyncLoadingCache<CacheKey, BlockState>;
|
|
1217
|
+
static readonly listAssetCache: AsyncLoadingCache<CacheKey, ListAsset>;
|
|
1218
|
+
static readonly defaultBlockStatesCache: AsyncLoadingCache<CacheKey, DefaultBlockStates>;
|
|
1219
|
+
static readonly entityModelsCache: AsyncLoadingCache<CacheKey, EntityModels>;
|
|
1220
|
+
private static createAssetCache;
|
|
1216
1221
|
/** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
|
|
1217
1222
|
private static get all();
|
|
1218
1223
|
static clear(): void;
|
package/dist/browser/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({
|
|
@@ -308,11 +300,14 @@ var _PersistentCache = class _PersistentCache {
|
|
|
308
300
|
static open(name) {
|
|
309
301
|
return Env.provider.openCache(name, _PersistentCache.VERSION);
|
|
310
302
|
}
|
|
303
|
+
/** Loads a missing entry and stores only non-nullish results. */
|
|
311
304
|
async getOrLoad(key, loader) {
|
|
312
305
|
let v = await this.get(key);
|
|
313
306
|
if (typeof v === "undefined" || v === null) {
|
|
314
307
|
v = await loader(key);
|
|
315
|
-
|
|
308
|
+
if (typeof v !== "undefined" && v !== null) {
|
|
309
|
+
await this.put(key, v);
|
|
310
|
+
}
|
|
316
311
|
}
|
|
317
312
|
return v;
|
|
318
313
|
}
|
|
@@ -548,7 +543,10 @@ function serializeMeshKey(key) {
|
|
|
548
543
|
// src/cache/Caching.ts
|
|
549
544
|
var import_loading_cache = require("@inventivetalent/loading-cache");
|
|
550
545
|
var import_time = require("@inventivetalent/time");
|
|
551
|
-
var
|
|
546
|
+
var _Caching = class _Caching {
|
|
547
|
+
static createAssetCache() {
|
|
548
|
+
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();
|
|
549
|
+
}
|
|
552
550
|
/** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
|
|
553
551
|
static get all() {
|
|
554
552
|
return [
|
|
@@ -565,7 +563,10 @@ var Caching = class {
|
|
|
565
563
|
this.rawModelCache,
|
|
566
564
|
this.mergedModelCache,
|
|
567
565
|
this.modelTextureAtlasCache,
|
|
568
|
-
this.blockStateCache
|
|
566
|
+
this.blockStateCache,
|
|
567
|
+
this.listAssetCache,
|
|
568
|
+
this.defaultBlockStatesCache,
|
|
569
|
+
this.entityModelsCache
|
|
569
570
|
];
|
|
570
571
|
}
|
|
571
572
|
static clear() {
|
|
@@ -591,20 +592,24 @@ var Caching = class {
|
|
|
591
592
|
};
|
|
592
593
|
}
|
|
593
594
|
};
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
595
|
+
_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();
|
|
596
|
+
_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();
|
|
597
|
+
_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();
|
|
598
|
+
_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();
|
|
599
|
+
_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();
|
|
600
|
+
_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();
|
|
601
|
+
_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();
|
|
602
|
+
_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();
|
|
603
|
+
_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();
|
|
604
|
+
_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();
|
|
605
|
+
_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();
|
|
606
|
+
_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();
|
|
607
|
+
_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();
|
|
608
|
+
_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();
|
|
609
|
+
_Caching.listAssetCache = _Caching.createAssetCache();
|
|
610
|
+
_Caching.defaultBlockStatesCache = _Caching.createAssetCache();
|
|
611
|
+
_Caching.entityModelsCache = _Caching.createAssetCache();
|
|
612
|
+
var Caching = _Caching;
|
|
608
613
|
|
|
609
614
|
// src/Geometries.ts
|
|
610
615
|
var Geometries = class _Geometries {
|
|
@@ -1386,9 +1391,6 @@ var ModelMerger = class {
|
|
|
1386
1391
|
}
|
|
1387
1392
|
};
|
|
1388
1393
|
|
|
1389
|
-
// src/assets/Models.ts
|
|
1390
|
-
var import_typescript_memoize = require("typescript-memoize");
|
|
1391
|
-
|
|
1392
1394
|
// src/assets/source/parser/AssetParsers.ts
|
|
1393
1395
|
var AssetParser = /* @__PURE__ */ ((AssetParser2) => {
|
|
1394
1396
|
AssetParser2["MODEL"] = "model";
|
|
@@ -1402,14 +1404,14 @@ var AssetParser = /* @__PURE__ */ ((AssetParser2) => {
|
|
|
1402
1404
|
})(AssetParser || {});
|
|
1403
1405
|
|
|
1404
1406
|
// src/assets/Models.ts
|
|
1405
|
-
var
|
|
1407
|
+
var Models = class _Models {
|
|
1406
1408
|
// opened lazily: touching the store at import time would hit IndexedDB/disk just for loading
|
|
1407
1409
|
// the library, and would require an EnvProvider before any entry has had a chance to register
|
|
1408
1410
|
static get PERSISTENT_CACHE() {
|
|
1409
1411
|
return this._persistentCache ?? (this._persistentCache = PersistentCache.open("minerender-models"));
|
|
1410
1412
|
}
|
|
1411
1413
|
static async getItemList() {
|
|
1412
|
-
|
|
1414
|
+
const key = new AssetKey(
|
|
1413
1415
|
DEFAULT_NAMESPACE,
|
|
1414
1416
|
"_list",
|
|
1415
1417
|
"models",
|
|
@@ -1417,7 +1419,10 @@ var _Models = class _Models {
|
|
|
1417
1419
|
"assets",
|
|
1418
1420
|
".json",
|
|
1419
1421
|
DEFAULT_ROOT
|
|
1420
|
-
)
|
|
1422
|
+
);
|
|
1423
|
+
return Caching.listAssetCache.get(key.serialize(), () => {
|
|
1424
|
+
return AssetLoader.get(key, "list" /* LIST */);
|
|
1425
|
+
}).then((r) => r?.files ?? []);
|
|
1421
1426
|
}
|
|
1422
1427
|
static async loadAndMerge(key) {
|
|
1423
1428
|
const model = await this.getRaw(key);
|
|
@@ -1464,19 +1469,15 @@ var _Models = class _Models {
|
|
|
1464
1469
|
return this.PERSISTENT_CACHE.clear();
|
|
1465
1470
|
}
|
|
1466
1471
|
};
|
|
1467
|
-
__decorateClass([
|
|
1468
|
-
(0, import_typescript_memoize.Memoize)()
|
|
1469
|
-
], _Models, "getItemList", 1);
|
|
1470
|
-
var Models = _Models;
|
|
1471
1472
|
|
|
1472
1473
|
// src/assets/BlockStates.ts
|
|
1473
|
-
var import_typescript_memoize2 = require("typescript-memoize");
|
|
1474
1474
|
var BlockStates = class {
|
|
1475
1475
|
static get PERSISTENT_CACHE() {
|
|
1476
1476
|
return this._persistentCache ?? (this._persistentCache = PersistentCache.open("minerender-blockstates"));
|
|
1477
1477
|
}
|
|
1478
|
+
// BlockState names are hardcoded
|
|
1478
1479
|
static async getList() {
|
|
1479
|
-
|
|
1480
|
+
const key = new AssetKey(
|
|
1480
1481
|
DEFAULT_NAMESPACE,
|
|
1481
1482
|
"_list",
|
|
1482
1483
|
"blockstates",
|
|
@@ -1484,11 +1485,16 @@ var BlockStates = class {
|
|
|
1484
1485
|
"assets",
|
|
1485
1486
|
".json",
|
|
1486
1487
|
DEFAULT_ROOT
|
|
1487
|
-
)
|
|
1488
|
+
);
|
|
1489
|
+
return Caching.listAssetCache.get(key.serialize(), () => {
|
|
1490
|
+
return AssetLoader.get(key, "list" /* LIST */);
|
|
1491
|
+
}).then((r) => r?.files ?? []);
|
|
1488
1492
|
}
|
|
1489
1493
|
static async getDefaultStates() {
|
|
1490
1494
|
const key = AssetKey.parse("blockstates", "minerender:defaultBlockStates");
|
|
1491
|
-
return
|
|
1495
|
+
return Caching.defaultBlockStatesCache.get(key.serialize(), () => {
|
|
1496
|
+
return AssetLoader.get(key, "json" /* JSON */);
|
|
1497
|
+
});
|
|
1492
1498
|
}
|
|
1493
1499
|
static async getDefaultState(key) {
|
|
1494
1500
|
const defaultStates = await this.getDefaultStates();
|
|
@@ -1527,12 +1533,6 @@ var BlockStates = class {
|
|
|
1527
1533
|
await this.PERSISTENT_CACHE.clear();
|
|
1528
1534
|
}
|
|
1529
1535
|
};
|
|
1530
|
-
__decorateClass([
|
|
1531
|
-
(0, import_typescript_memoize2.Memoize)()
|
|
1532
|
-
], BlockStates, "getList", 1);
|
|
1533
|
-
__decorateClass([
|
|
1534
|
-
(0, import_typescript_memoize2.Memoize)()
|
|
1535
|
-
], BlockStates, "getDefaultStates", 1);
|
|
1536
1536
|
var DefaultBlockStates = class {
|
|
1537
1537
|
};
|
|
1538
1538
|
|
|
@@ -2582,17 +2582,20 @@ function shutdown() {
|
|
|
2582
2582
|
}
|
|
2583
2583
|
|
|
2584
2584
|
// src/assets/Entities.ts
|
|
2585
|
-
var import_typescript_memoize3 = require("typescript-memoize");
|
|
2586
2585
|
var Entities = class {
|
|
2587
2586
|
static async getBlockEntityModels() {
|
|
2588
2587
|
const key = AssetKey.parse("models", "minerender:blockEntityModels");
|
|
2589
2588
|
console.log(key);
|
|
2590
|
-
return
|
|
2589
|
+
return Caching.entityModelsCache.get(key.serialize(), () => {
|
|
2590
|
+
return AssetLoader.get(key, "json" /* JSON */);
|
|
2591
|
+
});
|
|
2591
2592
|
}
|
|
2592
2593
|
static async getEntityModels() {
|
|
2593
2594
|
const key = AssetKey.parse("models", "minerender:entityModels");
|
|
2594
2595
|
console.log(key);
|
|
2595
|
-
return
|
|
2596
|
+
return Caching.entityModelsCache.get(key.serialize(), () => {
|
|
2597
|
+
return AssetLoader.get(key, "json" /* JSON */);
|
|
2598
|
+
});
|
|
2596
2599
|
}
|
|
2597
2600
|
// BlockEntity names are hardcoded
|
|
2598
2601
|
static async getBlockList() {
|
|
@@ -2638,12 +2641,6 @@ var Entities = class {
|
|
|
2638
2641
|
};
|
|
2639
2642
|
}
|
|
2640
2643
|
};
|
|
2641
|
-
__decorateClass([
|
|
2642
|
-
(0, import_typescript_memoize3.Memoize)()
|
|
2643
|
-
], Entities, "getBlockEntityModels", 1);
|
|
2644
|
-
__decorateClass([
|
|
2645
|
-
(0, import_typescript_memoize3.Memoize)()
|
|
2646
|
-
], Entities, "getEntityModels", 1);
|
|
2647
2644
|
var EntityModels = class {
|
|
2648
2645
|
};
|
|
2649
2646
|
var BlockEntityModels = class {
|