@2112-lab/central-plant 0.1.71 → 0.1.72
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/index.js +1332 -168
- package/dist/cjs/src/core/centralPlant.js +206 -154
- package/dist/cjs/src/index.js +5 -0
- package/dist/cjs/src/managers/CacheManager.js +1083 -0
- package/dist/cjs/src/managers/scene/modelManager.js +48 -12
- package/dist/cjs/src/managers/scene/sceneOperationsManager.js +2 -2
- package/dist/esm/src/core/centralPlant.js +206 -154
- package/dist/esm/src/index.js +1 -0
- package/dist/esm/src/managers/CacheManager.js +1075 -0
- package/dist/esm/src/managers/scene/modelManager.js +48 -12
- package/dist/esm/src/managers/scene/sceneOperationsManager.js +2 -2
- package/package.json +1 -1
package/dist/bundle/index.js
CHANGED
|
@@ -27929,7 +27929,7 @@ var ModelManager = /*#__PURE__*/function () {
|
|
|
27929
27929
|
key: "preloadMissingModels",
|
|
27930
27930
|
value: (function () {
|
|
27931
27931
|
var _preloadMissingModels = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(data, componentDictionary) {
|
|
27932
|
-
var _data$scene, _data$scene2, requiredModels, preloaderStatus, cachedModels, missingModels, _iterator, _step, modelKey, _t5, _t6;
|
|
27932
|
+
var _data$scene, _data$scene2, requiredModels, preloaderStatus, cachedModels, missingModels, basePath, modelUrls, _iterator, _step, modelKey, _t5, _t6;
|
|
27933
27933
|
return _regenerator().w(function (_context4) {
|
|
27934
27934
|
while (1) switch (_context4.n) {
|
|
27935
27935
|
case 0:
|
|
@@ -27946,25 +27946,58 @@ var ModelManager = /*#__PURE__*/function () {
|
|
|
27946
27946
|
return _context4.a(2);
|
|
27947
27947
|
case 1:
|
|
27948
27948
|
requiredModels = new Set();
|
|
27949
|
+
console.log("\uD83D\uDD0D Checking ".concat(data.scene.children.length, " scene objects for required models..."));
|
|
27949
27950
|
data.scene.children.forEach(function (child) {
|
|
27950
|
-
var _child$userData
|
|
27951
|
-
|
|
27952
|
-
|
|
27953
|
-
|
|
27954
|
-
|
|
27955
|
-
|
|
27951
|
+
var _child$userData;
|
|
27952
|
+
var libraryId = (_child$userData = child.userData) === null || _child$userData === void 0 ? void 0 : _child$userData.libraryId;
|
|
27953
|
+
if (libraryId) {
|
|
27954
|
+
if (componentDictionary[libraryId]) {
|
|
27955
|
+
var modelKey = componentDictionary[libraryId].modelKey;
|
|
27956
|
+
if (modelKey) {
|
|
27957
|
+
requiredModels.add(modelKey);
|
|
27958
|
+
// console.log(` Found required model for ${libraryId}: ${modelKey}`)
|
|
27959
|
+
} else {
|
|
27960
|
+
console.warn(" Item ".concat(libraryId, " has no modelKey in dictionary"));
|
|
27961
|
+
}
|
|
27962
|
+
} else {
|
|
27963
|
+
console.warn(" Item ".concat(libraryId, " found in scene but missing from dictionary"));
|
|
27956
27964
|
}
|
|
27957
27965
|
}
|
|
27958
27966
|
});
|
|
27959
|
-
console.log('🔍 Required models for this scene:', Array.from(requiredModels));
|
|
27967
|
+
console.log('🔍 Required models for this scene (Set):', Array.from(requiredModels));
|
|
27960
27968
|
_context4.n = 2;
|
|
27961
27969
|
return this.verifyModelPreloaderCache();
|
|
27962
27970
|
case 2:
|
|
27963
27971
|
preloaderStatus = _context4.v;
|
|
27964
27972
|
cachedModels = preloaderStatus.cachedModels;
|
|
27973
|
+
console.log('ModelPreloader cached models:', cachedModels);
|
|
27974
|
+
|
|
27975
|
+
// Calculate missing models for IN-MEMORY preloading
|
|
27965
27976
|
missingModels = Array.from(requiredModels).filter(function (model) {
|
|
27966
27977
|
return !cachedModels.includes(model);
|
|
27967
27978
|
});
|
|
27979
|
+
console.log('Missing models (calculated):', missingModels);
|
|
27980
|
+
|
|
27981
|
+
// OPTIONAL: Prime persistent browser cache (Cache Storage) using injected primer
|
|
27982
|
+
// We prime ALL required models to ensure they are in the persistent cache, even if already in memory
|
|
27983
|
+
if (requiredModels.size > 0 && this.sceneViewer && this.sceneViewer.centralPlant) {
|
|
27984
|
+
// Construct URLs based on preloader's base path
|
|
27985
|
+
basePath = modelPreloader.modelsBasePath || '/library/models/';
|
|
27986
|
+
modelUrls = Array.from(requiredModels).map(function (key) {
|
|
27987
|
+
return "".concat(basePath).concat(key);
|
|
27988
|
+
});
|
|
27989
|
+
console.log("\uD83D\uDCBE Priming persistent cache for ".concat(modelUrls.length, " assets..."));
|
|
27990
|
+
this.sceneViewer.centralPlant.primeCache(modelUrls).then(function (result) {
|
|
27991
|
+
if (result && !result.skipped) {
|
|
27992
|
+
console.log("\u2705 Persistent cache primed: ".concat(result.success, " success, ").concat(result.failed, " failed"));
|
|
27993
|
+
if (result.failed > 0) {
|
|
27994
|
+
console.warn('Cache priming failures:', result.errors);
|
|
27995
|
+
}
|
|
27996
|
+
}
|
|
27997
|
+
}).catch(function (err) {
|
|
27998
|
+
return console.warn('Persistent cache priming failed:', err);
|
|
27999
|
+
});
|
|
28000
|
+
}
|
|
27968
28001
|
if (!(missingModels.length > 0)) {
|
|
27969
28002
|
_context4.n = 12;
|
|
27970
28003
|
break;
|
|
@@ -27972,7 +28005,7 @@ var ModelManager = /*#__PURE__*/function () {
|
|
|
27972
28005
|
console.warn('⚠️ Some required models are not cached:', missingModels);
|
|
27973
28006
|
console.log('🔄 Attempting to preload missing models...');
|
|
27974
28007
|
|
|
27975
|
-
// Preload missing models
|
|
28008
|
+
// Preload missing models (Main in-memory preloader)
|
|
27976
28009
|
_iterator = _createForOfIteratorHelper(missingModels);
|
|
27977
28010
|
_context4.p = 3;
|
|
27978
28011
|
_iterator.s();
|
|
@@ -28107,19 +28140,22 @@ var ModelManager = /*#__PURE__*/function () {
|
|
|
28107
28140
|
key: "loadComponentDictionary",
|
|
28108
28141
|
value: (function () {
|
|
28109
28142
|
var _loadComponentDictionary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
28110
|
-
var response, _t7;
|
|
28143
|
+
var response, dict, _t7;
|
|
28111
28144
|
return _regenerator().w(function (_context6) {
|
|
28112
28145
|
while (1) switch (_context6.n) {
|
|
28113
28146
|
case 0:
|
|
28114
28147
|
_context6.p = 0;
|
|
28148
|
+
console.log('🔄 ModelManager loading component dictionary...');
|
|
28115
28149
|
_context6.n = 1;
|
|
28116
|
-
return fetch('
|
|
28150
|
+
return fetch('/library/component-dictionary.json');
|
|
28117
28151
|
case 1:
|
|
28118
28152
|
response = _context6.v;
|
|
28119
28153
|
_context6.n = 2;
|
|
28120
28154
|
return response.json();
|
|
28121
28155
|
case 2:
|
|
28122
|
-
|
|
28156
|
+
dict = _context6.v;
|
|
28157
|
+
console.log('✅ ModelManager loaded dictionary:', Object.keys(dict).length, 'entries');
|
|
28158
|
+
return _context6.a(2, dict);
|
|
28123
28159
|
case 3:
|
|
28124
28160
|
_context6.p = 3;
|
|
28125
28161
|
_t7 = _context6.v;
|
|
@@ -29854,9 +29890,9 @@ var SceneOperationsManager = /*#__PURE__*/function () {
|
|
|
29854
29890
|
// Store current scene data even for default scene
|
|
29855
29891
|
component.currentSceneData = data;
|
|
29856
29892
|
|
|
29857
|
-
// Use the consolidated scene loading function
|
|
29893
|
+
// Use the consolidated scene loading function (treat as imported to ensure consistent behavior)
|
|
29858
29894
|
_context8.n = 4;
|
|
29859
|
-
return this.
|
|
29895
|
+
return this.loadSceneFromData(data);
|
|
29860
29896
|
case 4:
|
|
29861
29897
|
_context8.n = 6;
|
|
29862
29898
|
break;
|
|
@@ -34657,7 +34693,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
34657
34693
|
* Initialize the CentralPlant manager
|
|
34658
34694
|
*
|
|
34659
34695
|
* @constructor
|
|
34660
|
-
* @version 0.1.
|
|
34696
|
+
* @version 0.1.72
|
|
34661
34697
|
* @updated 2025-10-22
|
|
34662
34698
|
*
|
|
34663
34699
|
* @description Creates a new CentralPlant instance and initializes internal managers and utilities.
|
|
@@ -34696,6 +34732,9 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
34696
34732
|
// Initialize internals handler
|
|
34697
34733
|
_this.internals = new CentralPlantInternals(_this);
|
|
34698
34734
|
|
|
34735
|
+
// Optional cache primer function (dependency injection)
|
|
34736
|
+
_this.cachePrimer = null;
|
|
34737
|
+
|
|
34699
34738
|
// Initialize utilities immediately (they don't need scene viewer)
|
|
34700
34739
|
_this.internals.initializeUtilities();
|
|
34701
34740
|
|
|
@@ -34723,6 +34762,54 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
34723
34762
|
return this.internals.setSceneViewer(sceneViewer);
|
|
34724
34763
|
}
|
|
34725
34764
|
|
|
34765
|
+
/**
|
|
34766
|
+
* Set the cache primer function (dependency injection)
|
|
34767
|
+
* @param {Function} primerFn - Function that takes array of URLs and primes the cache
|
|
34768
|
+
*/
|
|
34769
|
+
}, {
|
|
34770
|
+
key: "setCachePrimer",
|
|
34771
|
+
value: function setCachePrimer(primerFn) {
|
|
34772
|
+
if (typeof primerFn !== 'function') {
|
|
34773
|
+
console.warn('⚠️ Cache primer must be a function');
|
|
34774
|
+
return;
|
|
34775
|
+
}
|
|
34776
|
+
this.cachePrimer = primerFn;
|
|
34777
|
+
console.log('✅ Cache primer function set');
|
|
34778
|
+
}
|
|
34779
|
+
|
|
34780
|
+
/**
|
|
34781
|
+
* Prime the cache with the given URLs using the injected primer
|
|
34782
|
+
* @param {Array<string>} urls - Array of URLs to cache
|
|
34783
|
+
* @returns {Promise<Object>} Result of priming operation
|
|
34784
|
+
*/
|
|
34785
|
+
}, {
|
|
34786
|
+
key: "primeCache",
|
|
34787
|
+
value: (function () {
|
|
34788
|
+
var _primeCache = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(urls) {
|
|
34789
|
+
return _regenerator().w(function (_context) {
|
|
34790
|
+
while (1) switch (_context.n) {
|
|
34791
|
+
case 0:
|
|
34792
|
+
if (this.cachePrimer) {
|
|
34793
|
+
_context.n = 1;
|
|
34794
|
+
break;
|
|
34795
|
+
}
|
|
34796
|
+
console.log('ℹ️ No cache primer set, skipping explicit cache priming');
|
|
34797
|
+
return _context.a(2, {
|
|
34798
|
+
success: 0,
|
|
34799
|
+
failed: 0,
|
|
34800
|
+
skipped: true
|
|
34801
|
+
});
|
|
34802
|
+
case 1:
|
|
34803
|
+
console.log('🔄 Delegating to injected cache primer...', urls.length, 'urls');
|
|
34804
|
+
return _context.a(2, this.cachePrimer(urls));
|
|
34805
|
+
}
|
|
34806
|
+
}, _callee, this);
|
|
34807
|
+
}));
|
|
34808
|
+
function primeCache(_x) {
|
|
34809
|
+
return _primeCache.apply(this, arguments);
|
|
34810
|
+
}
|
|
34811
|
+
return primeCache;
|
|
34812
|
+
}()
|
|
34726
34813
|
/**
|
|
34727
34814
|
* Set all managers and utilities on the scene viewer instance
|
|
34728
34815
|
* @returns {boolean} True if attachment was successful, false otherwise
|
|
@@ -34734,6 +34821,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
34734
34821
|
* console.log('Managers and utilities attached to component');
|
|
34735
34822
|
* }
|
|
34736
34823
|
*/
|
|
34824
|
+
)
|
|
34737
34825
|
}, {
|
|
34738
34826
|
key: "attachToComponent",
|
|
34739
34827
|
value: function attachToComponent() {
|
|
@@ -34775,12 +34863,12 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
34775
34863
|
}, {
|
|
34776
34864
|
key: "setImportedSceneData",
|
|
34777
34865
|
value: (function () {
|
|
34778
|
-
var _setImportedSceneData = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
34866
|
+
var _setImportedSceneData = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(sceneData) {
|
|
34779
34867
|
var _this$importedSceneDa, _this$importedSceneDa2;
|
|
34780
|
-
return _regenerator().w(function (
|
|
34781
|
-
while (1) switch (
|
|
34868
|
+
return _regenerator().w(function (_context2) {
|
|
34869
|
+
while (1) switch (_context2.n) {
|
|
34782
34870
|
case 0:
|
|
34783
|
-
|
|
34871
|
+
_context2.n = 1;
|
|
34784
34872
|
return this.internals.clearSceneComponents();
|
|
34785
34873
|
case 1:
|
|
34786
34874
|
this.importedSceneData = _objectSpread2({}, sceneData);
|
|
@@ -34793,11 +34881,11 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
34793
34881
|
// Reset component counter based on imported components to avoid ID conflicts
|
|
34794
34882
|
this.internals.resetComponentCounter();
|
|
34795
34883
|
case 2:
|
|
34796
|
-
return
|
|
34884
|
+
return _context2.a(2);
|
|
34797
34885
|
}
|
|
34798
|
-
},
|
|
34886
|
+
}, _callee2, this);
|
|
34799
34887
|
}));
|
|
34800
|
-
function setImportedSceneData(
|
|
34888
|
+
function setImportedSceneData(_x2) {
|
|
34801
34889
|
return _setImportedSceneData.apply(this, arguments);
|
|
34802
34890
|
}
|
|
34803
34891
|
return setImportedSceneData;
|
|
@@ -35703,41 +35791,41 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
35703
35791
|
}, {
|
|
35704
35792
|
key: "getComponents",
|
|
35705
35793
|
value: (function () {
|
|
35706
|
-
var _getComponents = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
35794
|
+
var _getComponents = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
35707
35795
|
var options,
|
|
35708
35796
|
validation,
|
|
35709
35797
|
enhancedOptions,
|
|
35710
|
-
|
|
35798
|
+
_args3 = arguments,
|
|
35711
35799
|
_t;
|
|
35712
|
-
return _regenerator().w(function (
|
|
35713
|
-
while (1) switch (
|
|
35800
|
+
return _regenerator().w(function (_context3) {
|
|
35801
|
+
while (1) switch (_context3.n) {
|
|
35714
35802
|
case 0:
|
|
35715
|
-
options =
|
|
35803
|
+
options = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
|
|
35716
35804
|
// Validate filter options using centralized validator
|
|
35717
35805
|
validation = this.internals.validator.validateComponentFilter(options);
|
|
35718
35806
|
if (validation.isValid) {
|
|
35719
|
-
|
|
35807
|
+
_context3.n = 1;
|
|
35720
35808
|
break;
|
|
35721
35809
|
}
|
|
35722
35810
|
console.warn('⚠️ getComponents(): Invalid filter options provided:', validation.message);
|
|
35723
|
-
return
|
|
35811
|
+
return _context3.a(2, []);
|
|
35724
35812
|
case 1:
|
|
35725
|
-
|
|
35813
|
+
_context3.p = 1;
|
|
35726
35814
|
// Always include metadata
|
|
35727
35815
|
enhancedOptions = _objectSpread2(_objectSpread2({}, options), {}, {
|
|
35728
35816
|
includeMetadata: true
|
|
35729
35817
|
});
|
|
35730
|
-
|
|
35818
|
+
_context3.n = 2;
|
|
35731
35819
|
return this.managers.componentDataManager.getDictionaryComponents(enhancedOptions);
|
|
35732
35820
|
case 2:
|
|
35733
|
-
return
|
|
35821
|
+
return _context3.a(2, _context3.v);
|
|
35734
35822
|
case 3:
|
|
35735
|
-
|
|
35736
|
-
_t =
|
|
35823
|
+
_context3.p = 3;
|
|
35824
|
+
_t = _context3.v;
|
|
35737
35825
|
console.error('❌ getDictionaryComponents(): Error retrieving available components:', _t);
|
|
35738
|
-
return
|
|
35826
|
+
return _context3.a(2, []);
|
|
35739
35827
|
}
|
|
35740
|
-
},
|
|
35828
|
+
}, _callee3, this, [[1, 3]]);
|
|
35741
35829
|
}));
|
|
35742
35830
|
function getComponents() {
|
|
35743
35831
|
return _getComponents.apply(this, arguments);
|
|
@@ -35840,25 +35928,25 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
35840
35928
|
}, {
|
|
35841
35929
|
key: "extendComponentDictionary",
|
|
35842
35930
|
value: (function () {
|
|
35843
|
-
var _extendComponentDictionary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
35844
|
-
return _regenerator().w(function (
|
|
35845
|
-
while (1) switch (
|
|
35931
|
+
var _extendComponentDictionary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(additionalComponents) {
|
|
35932
|
+
return _regenerator().w(function (_context4) {
|
|
35933
|
+
while (1) switch (_context4.n) {
|
|
35846
35934
|
case 0:
|
|
35847
35935
|
if (this.managers.componentDataManager) {
|
|
35848
|
-
|
|
35936
|
+
_context4.n = 1;
|
|
35849
35937
|
break;
|
|
35850
35938
|
}
|
|
35851
35939
|
console.warn('⚠️ extendComponentDictionary(): Component data manager not available');
|
|
35852
|
-
return
|
|
35940
|
+
return _context4.a(2, false);
|
|
35853
35941
|
case 1:
|
|
35854
|
-
|
|
35942
|
+
_context4.n = 2;
|
|
35855
35943
|
return this.managers.componentDataManager.extendComponentDictionary(additionalComponents);
|
|
35856
35944
|
case 2:
|
|
35857
|
-
return
|
|
35945
|
+
return _context4.a(2, _context4.v);
|
|
35858
35946
|
}
|
|
35859
|
-
},
|
|
35947
|
+
}, _callee4, this);
|
|
35860
35948
|
}));
|
|
35861
|
-
function extendComponentDictionary(
|
|
35949
|
+
function extendComponentDictionary(_x3) {
|
|
35862
35950
|
return _extendComponentDictionary.apply(this, arguments);
|
|
35863
35951
|
}
|
|
35864
35952
|
return extendComponentDictionary;
|
|
@@ -35879,23 +35967,23 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
35879
35967
|
}, {
|
|
35880
35968
|
key: "removeS3Components",
|
|
35881
35969
|
value: (function () {
|
|
35882
|
-
var _removeS3Components = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
35883
|
-
return _regenerator().w(function (
|
|
35884
|
-
while (1) switch (
|
|
35970
|
+
var _removeS3Components = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
35971
|
+
return _regenerator().w(function (_context5) {
|
|
35972
|
+
while (1) switch (_context5.n) {
|
|
35885
35973
|
case 0:
|
|
35886
35974
|
if (this.managers.componentDataManager) {
|
|
35887
|
-
|
|
35975
|
+
_context5.n = 1;
|
|
35888
35976
|
break;
|
|
35889
35977
|
}
|
|
35890
35978
|
console.warn('⚠️ removeS3Components(): Component data manager not available');
|
|
35891
|
-
return
|
|
35979
|
+
return _context5.a(2, false);
|
|
35892
35980
|
case 1:
|
|
35893
|
-
|
|
35981
|
+
_context5.n = 2;
|
|
35894
35982
|
return this.managers.componentDataManager.removeS3Components();
|
|
35895
35983
|
case 2:
|
|
35896
|
-
return
|
|
35984
|
+
return _context5.a(2, _context5.v);
|
|
35897
35985
|
}
|
|
35898
|
-
},
|
|
35986
|
+
}, _callee5, this);
|
|
35899
35987
|
}));
|
|
35900
35988
|
function removeS3Components() {
|
|
35901
35989
|
return _removeS3Components.apply(this, arguments);
|
|
@@ -35919,25 +36007,25 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
35919
36007
|
}, {
|
|
35920
36008
|
key: "removeComponentFromDictionary",
|
|
35921
36009
|
value: (function () {
|
|
35922
|
-
var _removeComponentFromDictionary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
35923
|
-
return _regenerator().w(function (
|
|
35924
|
-
while (1) switch (
|
|
36010
|
+
var _removeComponentFromDictionary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(componentKey) {
|
|
36011
|
+
return _regenerator().w(function (_context6) {
|
|
36012
|
+
while (1) switch (_context6.n) {
|
|
35925
36013
|
case 0:
|
|
35926
36014
|
if (this.managers.componentDataManager) {
|
|
35927
|
-
|
|
36015
|
+
_context6.n = 1;
|
|
35928
36016
|
break;
|
|
35929
36017
|
}
|
|
35930
36018
|
console.warn('⚠️ removeComponentFromDictionary(): Component data manager not available');
|
|
35931
|
-
return
|
|
36019
|
+
return _context6.a(2, false);
|
|
35932
36020
|
case 1:
|
|
35933
|
-
|
|
36021
|
+
_context6.n = 2;
|
|
35934
36022
|
return this.managers.componentDataManager.removeComponentFromDictionary(componentKey);
|
|
35935
36023
|
case 2:
|
|
35936
|
-
return
|
|
36024
|
+
return _context6.a(2, _context6.v);
|
|
35937
36025
|
}
|
|
35938
|
-
},
|
|
36026
|
+
}, _callee6, this);
|
|
35939
36027
|
}));
|
|
35940
|
-
function removeComponentFromDictionary(
|
|
36028
|
+
function removeComponentFromDictionary(_x4) {
|
|
35941
36029
|
return _removeComponentFromDictionary.apply(this, arguments);
|
|
35942
36030
|
}
|
|
35943
36031
|
return removeComponentFromDictionary;
|
|
@@ -36139,51 +36227,51 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
36139
36227
|
}, {
|
|
36140
36228
|
key: "initialize2DViewport",
|
|
36141
36229
|
value: function () {
|
|
36142
|
-
var _initialize2DViewport = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
36230
|
+
var _initialize2DViewport = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(container) {
|
|
36143
36231
|
var viewType,
|
|
36144
36232
|
instanceKey,
|
|
36145
36233
|
success,
|
|
36146
|
-
|
|
36234
|
+
_args7 = arguments,
|
|
36147
36235
|
_t2;
|
|
36148
|
-
return _regenerator().w(function (
|
|
36149
|
-
while (1) switch (
|
|
36236
|
+
return _regenerator().w(function (_context7) {
|
|
36237
|
+
while (1) switch (_context7.n) {
|
|
36150
36238
|
case 0:
|
|
36151
|
-
viewType =
|
|
36152
|
-
instanceKey =
|
|
36239
|
+
viewType = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : 'top';
|
|
36240
|
+
instanceKey = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : null;
|
|
36153
36241
|
if (container) {
|
|
36154
|
-
|
|
36242
|
+
_context7.n = 1;
|
|
36155
36243
|
break;
|
|
36156
36244
|
}
|
|
36157
36245
|
console.warn('⚠️ initialize2DViewport(): No container provided');
|
|
36158
|
-
return
|
|
36246
|
+
return _context7.a(2, false);
|
|
36159
36247
|
case 1:
|
|
36160
36248
|
if (this.managers.viewport2DManager) {
|
|
36161
|
-
|
|
36249
|
+
_context7.n = 2;
|
|
36162
36250
|
break;
|
|
36163
36251
|
}
|
|
36164
36252
|
console.warn('⚠️ initialize2DViewport(): Viewport2D manager not available');
|
|
36165
|
-
return
|
|
36253
|
+
return _context7.a(2, false);
|
|
36166
36254
|
case 2:
|
|
36167
|
-
|
|
36168
|
-
|
|
36255
|
+
_context7.p = 2;
|
|
36256
|
+
_context7.n = 3;
|
|
36169
36257
|
return this.managers.viewport2DManager.initialize(container, viewType, instanceKey);
|
|
36170
36258
|
case 3:
|
|
36171
|
-
success =
|
|
36259
|
+
success = _context7.v;
|
|
36172
36260
|
if (success) {
|
|
36173
36261
|
console.log("\u2705 2D viewport initialized successfully (".concat(viewType, " view, key: ").concat(instanceKey || viewType, ")"));
|
|
36174
36262
|
} else {
|
|
36175
36263
|
console.warn("\u26A0\uFE0F Failed to initialize 2D viewport (".concat(viewType, " view)"));
|
|
36176
36264
|
}
|
|
36177
|
-
return
|
|
36265
|
+
return _context7.a(2, success);
|
|
36178
36266
|
case 4:
|
|
36179
|
-
|
|
36180
|
-
_t2 =
|
|
36267
|
+
_context7.p = 4;
|
|
36268
|
+
_t2 = _context7.v;
|
|
36181
36269
|
console.error('❌ initialize2DViewport(): Error initializing 2D viewport:', _t2);
|
|
36182
|
-
return
|
|
36270
|
+
return _context7.a(2, false);
|
|
36183
36271
|
}
|
|
36184
|
-
},
|
|
36272
|
+
}, _callee7, this, [[2, 4]]);
|
|
36185
36273
|
}));
|
|
36186
|
-
function initialize2DViewport(
|
|
36274
|
+
function initialize2DViewport(_x5) {
|
|
36187
36275
|
return _initialize2DViewport.apply(this, arguments);
|
|
36188
36276
|
}
|
|
36189
36277
|
return initialize2DViewport;
|
|
@@ -36329,7 +36417,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
36329
36417
|
}, {
|
|
36330
36418
|
key: "initializeModelPreloading",
|
|
36331
36419
|
value: (function () {
|
|
36332
|
-
var _initializeModelPreloading = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
36420
|
+
var _initializeModelPreloading = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
36333
36421
|
var basePath,
|
|
36334
36422
|
normalizedBasePath,
|
|
36335
36423
|
dictionaryPath,
|
|
@@ -36338,13 +36426,13 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
36338
36426
|
componentDictionary,
|
|
36339
36427
|
_modelPreloader2,
|
|
36340
36428
|
progress,
|
|
36341
|
-
|
|
36429
|
+
_args8 = arguments,
|
|
36342
36430
|
_t3;
|
|
36343
|
-
return _regenerator().w(function (
|
|
36344
|
-
while (1) switch (
|
|
36431
|
+
return _regenerator().w(function (_context8) {
|
|
36432
|
+
while (1) switch (_context8.n) {
|
|
36345
36433
|
case 0:
|
|
36346
|
-
basePath =
|
|
36347
|
-
|
|
36434
|
+
basePath = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : '/library/';
|
|
36435
|
+
_context8.p = 1;
|
|
36348
36436
|
// Ensure basePath ends with a slash
|
|
36349
36437
|
normalizedBasePath = basePath.endsWith('/') ? basePath : "".concat(basePath, "/");
|
|
36350
36438
|
dictionaryPath = "".concat(normalizedBasePath, "component-dictionary.json");
|
|
@@ -36355,39 +36443,39 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
36355
36443
|
console.log("\uFFFD Models path: ".concat(modelsBasePath));
|
|
36356
36444
|
|
|
36357
36445
|
// Load the component dictionary
|
|
36358
|
-
|
|
36446
|
+
_context8.n = 2;
|
|
36359
36447
|
return fetch(dictionaryPath);
|
|
36360
36448
|
case 2:
|
|
36361
|
-
response =
|
|
36449
|
+
response = _context8.v;
|
|
36362
36450
|
if (response.ok) {
|
|
36363
|
-
|
|
36451
|
+
_context8.n = 3;
|
|
36364
36452
|
break;
|
|
36365
36453
|
}
|
|
36366
36454
|
throw new Error("Failed to load component dictionary: ".concat(response.status));
|
|
36367
36455
|
case 3:
|
|
36368
|
-
|
|
36456
|
+
_context8.n = 4;
|
|
36369
36457
|
return response.json();
|
|
36370
36458
|
case 4:
|
|
36371
|
-
componentDictionary =
|
|
36459
|
+
componentDictionary = _context8.v;
|
|
36372
36460
|
console.log('📚 Component dictionary loaded:', Object.keys(componentDictionary));
|
|
36373
36461
|
|
|
36374
36462
|
// Start preloading all models with the specified base path
|
|
36375
36463
|
_modelPreloader2 = this.getUtility('modelPreloader');
|
|
36376
|
-
|
|
36464
|
+
_context8.n = 5;
|
|
36377
36465
|
return _modelPreloader2.preloadAllModels(componentDictionary, modelsBasePath);
|
|
36378
36466
|
case 5:
|
|
36379
|
-
progress =
|
|
36467
|
+
progress = _context8.v;
|
|
36380
36468
|
console.log('🎉 Model preloading completed:', progress);
|
|
36381
|
-
return
|
|
36469
|
+
return _context8.a(2, progress);
|
|
36382
36470
|
case 6:
|
|
36383
|
-
|
|
36384
|
-
_t3 =
|
|
36471
|
+
_context8.p = 6;
|
|
36472
|
+
_t3 = _context8.v;
|
|
36385
36473
|
console.error('❌ Failed to initialize model preloading:', _t3);
|
|
36386
36474
|
throw _t3;
|
|
36387
36475
|
case 7:
|
|
36388
|
-
return
|
|
36476
|
+
return _context8.a(2);
|
|
36389
36477
|
}
|
|
36390
|
-
},
|
|
36478
|
+
}, _callee8, this, [[1, 6]]);
|
|
36391
36479
|
}));
|
|
36392
36480
|
function initializeModelPreloading() {
|
|
36393
36481
|
return _initializeModelPreloading.apply(this, arguments);
|
|
@@ -36404,57 +36492,57 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
36404
36492
|
}, {
|
|
36405
36493
|
key: "importScene",
|
|
36406
36494
|
value: (function () {
|
|
36407
|
-
var _importScene = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
36495
|
+
var _importScene = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(jsonData) {
|
|
36408
36496
|
var validation, _t4;
|
|
36409
|
-
return _regenerator().w(function (
|
|
36410
|
-
while (1) switch (
|
|
36497
|
+
return _regenerator().w(function (_context9) {
|
|
36498
|
+
while (1) switch (_context9.n) {
|
|
36411
36499
|
case 0:
|
|
36412
36500
|
if (jsonData) {
|
|
36413
|
-
|
|
36501
|
+
_context9.n = 1;
|
|
36414
36502
|
break;
|
|
36415
36503
|
}
|
|
36416
36504
|
console.error('❌ No JSON data provided for import');
|
|
36417
|
-
return
|
|
36505
|
+
return _context9.a(2, false);
|
|
36418
36506
|
case 1:
|
|
36419
|
-
|
|
36507
|
+
_context9.p = 1;
|
|
36420
36508
|
// Validate scene data structure
|
|
36421
36509
|
validation = this.internals.validateAndAnalyzeSceneData(jsonData);
|
|
36422
36510
|
if (validation.isValid) {
|
|
36423
|
-
|
|
36511
|
+
_context9.n = 2;
|
|
36424
36512
|
break;
|
|
36425
36513
|
}
|
|
36426
36514
|
console.error('❌ Invalid scene data format:', validation.message);
|
|
36427
|
-
return
|
|
36515
|
+
return _context9.a(2, false);
|
|
36428
36516
|
case 2:
|
|
36429
|
-
|
|
36517
|
+
_context9.n = 3;
|
|
36430
36518
|
return this.setImportedSceneData(jsonData);
|
|
36431
36519
|
case 3:
|
|
36432
36520
|
if (!(this.sceneViewer && this.sceneViewer.sceneOperationsManager)) {
|
|
36433
|
-
|
|
36521
|
+
_context9.n = 5;
|
|
36434
36522
|
break;
|
|
36435
36523
|
}
|
|
36436
|
-
|
|
36524
|
+
_context9.n = 4;
|
|
36437
36525
|
return this.sceneViewer.sceneOperationsManager.loadSceneFromData(jsonData);
|
|
36438
36526
|
case 4:
|
|
36439
36527
|
console.log('✅ Scene imported successfully');
|
|
36440
|
-
return
|
|
36528
|
+
return _context9.a(2, true);
|
|
36441
36529
|
case 5:
|
|
36442
36530
|
console.error('❌ SceneViewer not available for scene loading');
|
|
36443
|
-
return
|
|
36531
|
+
return _context9.a(2, false);
|
|
36444
36532
|
case 6:
|
|
36445
|
-
|
|
36533
|
+
_context9.n = 8;
|
|
36446
36534
|
break;
|
|
36447
36535
|
case 7:
|
|
36448
|
-
|
|
36449
|
-
_t4 =
|
|
36536
|
+
_context9.p = 7;
|
|
36537
|
+
_t4 = _context9.v;
|
|
36450
36538
|
console.error('❌ Error importing scene:', _t4);
|
|
36451
|
-
return
|
|
36539
|
+
return _context9.a(2, false);
|
|
36452
36540
|
case 8:
|
|
36453
|
-
return
|
|
36541
|
+
return _context9.a(2);
|
|
36454
36542
|
}
|
|
36455
|
-
},
|
|
36543
|
+
}, _callee9, this, [[1, 7]]);
|
|
36456
36544
|
}));
|
|
36457
|
-
function importScene(
|
|
36545
|
+
function importScene(_x6) {
|
|
36458
36546
|
return _importScene.apply(this, arguments);
|
|
36459
36547
|
}
|
|
36460
36548
|
return importScene;
|
|
@@ -36476,33 +36564,33 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
36476
36564
|
}, {
|
|
36477
36565
|
key: "exportSceneJSON",
|
|
36478
36566
|
value: (function () {
|
|
36479
|
-
var _exportSceneJSON = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
36567
|
+
var _exportSceneJSON = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
|
|
36480
36568
|
var filename,
|
|
36481
|
-
|
|
36569
|
+
_args0 = arguments,
|
|
36482
36570
|
_t5;
|
|
36483
|
-
return _regenerator().w(function (
|
|
36484
|
-
while (1) switch (
|
|
36571
|
+
return _regenerator().w(function (_context0) {
|
|
36572
|
+
while (1) switch (_context0.n) {
|
|
36485
36573
|
case 0:
|
|
36486
|
-
filename =
|
|
36574
|
+
filename = _args0.length > 0 && _args0[0] !== undefined ? _args0[0] : null;
|
|
36487
36575
|
if (this.managers.sceneExportManager) {
|
|
36488
|
-
|
|
36576
|
+
_context0.n = 1;
|
|
36489
36577
|
break;
|
|
36490
36578
|
}
|
|
36491
36579
|
console.error('❌ Scene export manager not available');
|
|
36492
|
-
return
|
|
36580
|
+
return _context0.a(2, false);
|
|
36493
36581
|
case 1:
|
|
36494
|
-
|
|
36495
|
-
|
|
36582
|
+
_context0.p = 1;
|
|
36583
|
+
_context0.n = 2;
|
|
36496
36584
|
return this.managers.sceneExportManager.downloadSceneJSON(filename);
|
|
36497
36585
|
case 2:
|
|
36498
|
-
return
|
|
36586
|
+
return _context0.a(2, _context0.v);
|
|
36499
36587
|
case 3:
|
|
36500
|
-
|
|
36501
|
-
_t5 =
|
|
36588
|
+
_context0.p = 3;
|
|
36589
|
+
_t5 = _context0.v;
|
|
36502
36590
|
console.error('❌ Error exporting scene as JSON:', _t5);
|
|
36503
|
-
return
|
|
36591
|
+
return _context0.a(2, false);
|
|
36504
36592
|
}
|
|
36505
|
-
},
|
|
36593
|
+
}, _callee0, this, [[1, 3]]);
|
|
36506
36594
|
}));
|
|
36507
36595
|
function exportSceneJSON() {
|
|
36508
36596
|
return _exportSceneJSON.apply(this, arguments);
|
|
@@ -36527,33 +36615,33 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
36527
36615
|
}, {
|
|
36528
36616
|
key: "exportSceneGLTF",
|
|
36529
36617
|
value: (function () {
|
|
36530
|
-
var _exportSceneGLTF = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
36618
|
+
var _exportSceneGLTF = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
|
|
36531
36619
|
var filename,
|
|
36532
|
-
|
|
36620
|
+
_args1 = arguments,
|
|
36533
36621
|
_t6;
|
|
36534
|
-
return _regenerator().w(function (
|
|
36535
|
-
while (1) switch (
|
|
36622
|
+
return _regenerator().w(function (_context1) {
|
|
36623
|
+
while (1) switch (_context1.n) {
|
|
36536
36624
|
case 0:
|
|
36537
|
-
filename =
|
|
36625
|
+
filename = _args1.length > 0 && _args1[0] !== undefined ? _args1[0] : null;
|
|
36538
36626
|
if (this.managers.sceneExportManager) {
|
|
36539
|
-
|
|
36627
|
+
_context1.n = 1;
|
|
36540
36628
|
break;
|
|
36541
36629
|
}
|
|
36542
36630
|
console.error('❌ Scene export manager not available');
|
|
36543
|
-
return
|
|
36631
|
+
return _context1.a(2, false);
|
|
36544
36632
|
case 1:
|
|
36545
|
-
|
|
36546
|
-
|
|
36633
|
+
_context1.p = 1;
|
|
36634
|
+
_context1.n = 2;
|
|
36547
36635
|
return this.managers.sceneExportManager.exportSceneAsGLTF(filename, false);
|
|
36548
36636
|
case 2:
|
|
36549
|
-
return
|
|
36637
|
+
return _context1.a(2, _context1.v);
|
|
36550
36638
|
case 3:
|
|
36551
|
-
|
|
36552
|
-
_t6 =
|
|
36639
|
+
_context1.p = 3;
|
|
36640
|
+
_t6 = _context1.v;
|
|
36553
36641
|
console.error('❌ Error exporting scene as GLTF:', _t6);
|
|
36554
|
-
return
|
|
36642
|
+
return _context1.a(2, false);
|
|
36555
36643
|
}
|
|
36556
|
-
},
|
|
36644
|
+
}, _callee1, this, [[1, 3]]);
|
|
36557
36645
|
}));
|
|
36558
36646
|
function exportSceneGLTF() {
|
|
36559
36647
|
return _exportSceneGLTF.apply(this, arguments);
|
|
@@ -36579,33 +36667,33 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
36579
36667
|
}, {
|
|
36580
36668
|
key: "exportSceneGLB",
|
|
36581
36669
|
value: (function () {
|
|
36582
|
-
var _exportSceneGLB = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
36670
|
+
var _exportSceneGLB = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
|
|
36583
36671
|
var filename,
|
|
36584
|
-
|
|
36672
|
+
_args10 = arguments,
|
|
36585
36673
|
_t7;
|
|
36586
|
-
return _regenerator().w(function (
|
|
36587
|
-
while (1) switch (
|
|
36674
|
+
return _regenerator().w(function (_context10) {
|
|
36675
|
+
while (1) switch (_context10.n) {
|
|
36588
36676
|
case 0:
|
|
36589
|
-
filename =
|
|
36677
|
+
filename = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : null;
|
|
36590
36678
|
if (this.managers.sceneExportManager) {
|
|
36591
|
-
|
|
36679
|
+
_context10.n = 1;
|
|
36592
36680
|
break;
|
|
36593
36681
|
}
|
|
36594
36682
|
console.error('❌ Scene export manager not available');
|
|
36595
|
-
return
|
|
36683
|
+
return _context10.a(2, false);
|
|
36596
36684
|
case 1:
|
|
36597
|
-
|
|
36598
|
-
|
|
36685
|
+
_context10.p = 1;
|
|
36686
|
+
_context10.n = 2;
|
|
36599
36687
|
return this.managers.sceneExportManager.exportSceneAsGLB(filename);
|
|
36600
36688
|
case 2:
|
|
36601
|
-
return
|
|
36689
|
+
return _context10.a(2, _context10.v);
|
|
36602
36690
|
case 3:
|
|
36603
|
-
|
|
36604
|
-
_t7 =
|
|
36691
|
+
_context10.p = 3;
|
|
36692
|
+
_t7 = _context10.v;
|
|
36605
36693
|
console.error('❌ Error exporting scene as GLB:', _t7);
|
|
36606
|
-
return
|
|
36694
|
+
return _context10.a(2, false);
|
|
36607
36695
|
}
|
|
36608
|
-
},
|
|
36696
|
+
}, _callee10, this, [[1, 3]]);
|
|
36609
36697
|
}));
|
|
36610
36698
|
function exportSceneGLB() {
|
|
36611
36699
|
return _exportSceneGLB.apply(this, arguments);
|
|
@@ -36644,18 +36732,18 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
36644
36732
|
}, {
|
|
36645
36733
|
key: "loadSceneFromData",
|
|
36646
36734
|
value: (function () {
|
|
36647
|
-
var _loadSceneFromData = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
36648
|
-
return _regenerator().w(function (
|
|
36649
|
-
while (1) switch (
|
|
36735
|
+
var _loadSceneFromData = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(sceneData) {
|
|
36736
|
+
return _regenerator().w(function (_context11) {
|
|
36737
|
+
while (1) switch (_context11.n) {
|
|
36650
36738
|
case 0:
|
|
36651
|
-
|
|
36739
|
+
_context11.n = 1;
|
|
36652
36740
|
return this.setImportedSceneData(sceneData);
|
|
36653
36741
|
case 1:
|
|
36654
|
-
return
|
|
36742
|
+
return _context11.a(2, true);
|
|
36655
36743
|
}
|
|
36656
|
-
},
|
|
36744
|
+
}, _callee11, this);
|
|
36657
36745
|
}));
|
|
36658
|
-
function loadSceneFromData(
|
|
36746
|
+
function loadSceneFromData(_x7) {
|
|
36659
36747
|
return _loadSceneFromData.apply(this, arguments);
|
|
36660
36748
|
}
|
|
36661
36749
|
return loadSceneFromData;
|
|
@@ -38005,6 +38093,1078 @@ var SceneHierarchyManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
38005
38093
|
}]);
|
|
38006
38094
|
}(BaseDisposable);
|
|
38007
38095
|
|
|
38096
|
+
/**
|
|
38097
|
+
* Generic Cache Management using Browser Cache API
|
|
38098
|
+
* Framework-agnostic implementation of caching logic
|
|
38099
|
+
*/
|
|
38100
|
+
|
|
38101
|
+
// Time constants
|
|
38102
|
+
var SECOND = 1000;
|
|
38103
|
+
var MINUTE = 60 * SECOND;
|
|
38104
|
+
var HOUR = 60 * MINUTE;
|
|
38105
|
+
var DAY = 24 * HOUR;
|
|
38106
|
+
var CACHE_EXPIRY = {
|
|
38107
|
+
MODELS: 7 * DAY,
|
|
38108
|
+
TEXTURES: 7 * DAY,
|
|
38109
|
+
JSON: 24 * HOUR,
|
|
38110
|
+
COMPONENT_DICTIONARY: 24 * HOUR,
|
|
38111
|
+
SCENE_DATA: 12 * HOUR,
|
|
38112
|
+
THUMBNAILS: Infinity,
|
|
38113
|
+
SKYBOXES: 7 * DAY,
|
|
38114
|
+
USER_CONTENT: 6 * HOUR,
|
|
38115
|
+
TEMPORARY: 1 * HOUR,
|
|
38116
|
+
DEFAULT: 24 * HOUR
|
|
38117
|
+
};
|
|
38118
|
+
var CACHE_NAME_PREFIX = 'central-plant-s3-cache-v1';
|
|
38119
|
+
var CacheManager = /*#__PURE__*/function () {
|
|
38120
|
+
function CacheManager() {
|
|
38121
|
+
_classCallCheck(this, CacheManager);
|
|
38122
|
+
this.stats = {
|
|
38123
|
+
hits: 0,
|
|
38124
|
+
misses: 0,
|
|
38125
|
+
errors: 0,
|
|
38126
|
+
totalBytesServed: 0,
|
|
38127
|
+
totalBytesCached: 0,
|
|
38128
|
+
startTime: Date.now()
|
|
38129
|
+
};
|
|
38130
|
+
this.config = {
|
|
38131
|
+
// Default user provider returns null (anonymous)
|
|
38132
|
+
getUser: function () {
|
|
38133
|
+
var _getUser = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
38134
|
+
return _regenerator().w(function (_context) {
|
|
38135
|
+
while (1) switch (_context.n) {
|
|
38136
|
+
case 0:
|
|
38137
|
+
return _context.a(2, null);
|
|
38138
|
+
}
|
|
38139
|
+
}, _callee);
|
|
38140
|
+
}));
|
|
38141
|
+
function getUser() {
|
|
38142
|
+
return _getUser.apply(this, arguments);
|
|
38143
|
+
}
|
|
38144
|
+
return getUser;
|
|
38145
|
+
}(),
|
|
38146
|
+
// Default error logger
|
|
38147
|
+
onError: function onError(error) {
|
|
38148
|
+
return console.error('CacheManager Error:', error);
|
|
38149
|
+
}
|
|
38150
|
+
};
|
|
38151
|
+
}
|
|
38152
|
+
|
|
38153
|
+
/**
|
|
38154
|
+
* Configure the cache manager
|
|
38155
|
+
*/
|
|
38156
|
+
return _createClass(CacheManager, [{
|
|
38157
|
+
key: "configure",
|
|
38158
|
+
value: function configure() {
|
|
38159
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
38160
|
+
this.config = _objectSpread2(_objectSpread2({}, this.config), options);
|
|
38161
|
+
}
|
|
38162
|
+
|
|
38163
|
+
/**
|
|
38164
|
+
* Get cache expiry for a specific file path
|
|
38165
|
+
*/
|
|
38166
|
+
}, {
|
|
38167
|
+
key: "getExpiryForPath",
|
|
38168
|
+
value: function getExpiryForPath(path) {
|
|
38169
|
+
var assetType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
38170
|
+
if (assetType && CACHE_EXPIRY[assetType.toUpperCase()]) {
|
|
38171
|
+
return CACHE_EXPIRY[assetType.toUpperCase()];
|
|
38172
|
+
}
|
|
38173
|
+
var lowerPath = path ? path.toLowerCase() : '';
|
|
38174
|
+
if (lowerPath.includes('/models/') || lowerPath.endsWith('.glb') || lowerPath.endsWith('.gltf')) {
|
|
38175
|
+
return CACHE_EXPIRY.MODELS;
|
|
38176
|
+
}
|
|
38177
|
+
if (lowerPath.includes('/textures/') || lowerPath.endsWith('.jpg') || lowerPath.endsWith('.png') || lowerPath.endsWith('.webp')) {
|
|
38178
|
+
return CACHE_EXPIRY.TEXTURES;
|
|
38179
|
+
}
|
|
38180
|
+
if (lowerPath.includes('/thumbnails/')) {
|
|
38181
|
+
return CACHE_EXPIRY.THUMBNAILS;
|
|
38182
|
+
}
|
|
38183
|
+
if (lowerPath.includes('/skyboxes/') || lowerPath.endsWith('.hdr')) {
|
|
38184
|
+
return CACHE_EXPIRY.SKYBOXES;
|
|
38185
|
+
}
|
|
38186
|
+
if (lowerPath.includes('component-dictionary')) {
|
|
38187
|
+
return CACHE_EXPIRY.COMPONENT_DICTIONARY;
|
|
38188
|
+
}
|
|
38189
|
+
if (lowerPath.endsWith('.json')) {
|
|
38190
|
+
return CACHE_EXPIRY.JSON;
|
|
38191
|
+
}
|
|
38192
|
+
return CACHE_EXPIRY.DEFAULT;
|
|
38193
|
+
}
|
|
38194
|
+
|
|
38195
|
+
/**
|
|
38196
|
+
* Get or open the cache handle efficiently
|
|
38197
|
+
*/
|
|
38198
|
+
}, {
|
|
38199
|
+
key: "_getCacheHandle",
|
|
38200
|
+
value: (function () {
|
|
38201
|
+
var _getCacheHandle2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(cacheName) {
|
|
38202
|
+
return _regenerator().w(function (_context2) {
|
|
38203
|
+
while (1) switch (_context2.n) {
|
|
38204
|
+
case 0:
|
|
38205
|
+
if (!(this._activeCacheName === cacheName && this._activeCacheHandle)) {
|
|
38206
|
+
_context2.n = 1;
|
|
38207
|
+
break;
|
|
38208
|
+
}
|
|
38209
|
+
return _context2.a(2, this._activeCacheHandle);
|
|
38210
|
+
case 1:
|
|
38211
|
+
// If we are switching caches, close/drop reference to the old one (GC handles it, but good practice)
|
|
38212
|
+
this._activeCacheName = cacheName;
|
|
38213
|
+
_context2.n = 2;
|
|
38214
|
+
return caches.open(cacheName);
|
|
38215
|
+
case 2:
|
|
38216
|
+
this._activeCacheHandle = _context2.v;
|
|
38217
|
+
return _context2.a(2, this._activeCacheHandle);
|
|
38218
|
+
}
|
|
38219
|
+
}, _callee2, this);
|
|
38220
|
+
}));
|
|
38221
|
+
function _getCacheHandle(_x) {
|
|
38222
|
+
return _getCacheHandle2.apply(this, arguments);
|
|
38223
|
+
}
|
|
38224
|
+
return _getCacheHandle;
|
|
38225
|
+
}()
|
|
38226
|
+
/**
|
|
38227
|
+
* Get the cache name for the current user
|
|
38228
|
+
* Memoized to prevent excessive Auth calls
|
|
38229
|
+
*/
|
|
38230
|
+
/**
|
|
38231
|
+
* Resets the identity, forcing a re-fetch of the user/cache name on next access
|
|
38232
|
+
*/
|
|
38233
|
+
)
|
|
38234
|
+
}, {
|
|
38235
|
+
key: "resetIdentity",
|
|
38236
|
+
value: function resetIdentity() {
|
|
38237
|
+
this._cachedCacheName = null;
|
|
38238
|
+
}
|
|
38239
|
+
|
|
38240
|
+
/**
|
|
38241
|
+
* Get the cache name for the current user
|
|
38242
|
+
* Memoized indefinitely until resetIdentity() is called
|
|
38243
|
+
*/
|
|
38244
|
+
}, {
|
|
38245
|
+
key: "getCacheName",
|
|
38246
|
+
value: (function () {
|
|
38247
|
+
var _getCacheName = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
38248
|
+
var user, cacheName, _user$attributes, userId, sanitizedUserId, _t;
|
|
38249
|
+
return _regenerator().w(function (_context3) {
|
|
38250
|
+
while (1) switch (_context3.n) {
|
|
38251
|
+
case 0:
|
|
38252
|
+
if (!this._cachedCacheName) {
|
|
38253
|
+
_context3.n = 1;
|
|
38254
|
+
break;
|
|
38255
|
+
}
|
|
38256
|
+
return _context3.a(2, this._cachedCacheName);
|
|
38257
|
+
case 1:
|
|
38258
|
+
_context3.p = 1;
|
|
38259
|
+
_context3.n = 2;
|
|
38260
|
+
return this.config.getUser();
|
|
38261
|
+
case 2:
|
|
38262
|
+
user = _context3.v;
|
|
38263
|
+
if (!user) {
|
|
38264
|
+
cacheName = "".concat(CACHE_NAME_PREFIX, "-anonymous");
|
|
38265
|
+
} else {
|
|
38266
|
+
userId = typeof user === 'string' ? user : user.username || ((_user$attributes = user.attributes) === null || _user$attributes === void 0 ? void 0 : _user$attributes.sub) || 'anonymous';
|
|
38267
|
+
sanitizedUserId = userId.replace(/[^a-zA-Z0-9-]/g, '-');
|
|
38268
|
+
cacheName = "".concat(CACHE_NAME_PREFIX, "-user-").concat(sanitizedUserId);
|
|
38269
|
+
}
|
|
38270
|
+
this._cachedCacheName = cacheName;
|
|
38271
|
+
return _context3.a(2, cacheName);
|
|
38272
|
+
case 3:
|
|
38273
|
+
_context3.p = 3;
|
|
38274
|
+
_t = _context3.v;
|
|
38275
|
+
console.warn('Failed to get user for cache partition, using anonymous:', _t);
|
|
38276
|
+
return _context3.a(2, "".concat(CACHE_NAME_PREFIX, "-anonymous"));
|
|
38277
|
+
}
|
|
38278
|
+
}, _callee3, this, [[1, 3]]);
|
|
38279
|
+
}));
|
|
38280
|
+
function getCacheName() {
|
|
38281
|
+
return _getCacheName.apply(this, arguments);
|
|
38282
|
+
}
|
|
38283
|
+
return getCacheName;
|
|
38284
|
+
}()
|
|
38285
|
+
/**
|
|
38286
|
+
* Execute a cache operation
|
|
38287
|
+
*/
|
|
38288
|
+
)
|
|
38289
|
+
}, {
|
|
38290
|
+
key: "execute",
|
|
38291
|
+
value: (function () {
|
|
38292
|
+
var _execute = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(_ref) {
|
|
38293
|
+
var cacheKey, sourceKey, expiryMs, fetcher, processor, _ref$metadata, metadata, cacheName, cache, cachedResponse, cachedTime, age, result, fetchResult, blobOrJson, contentType, contentSize, responseBody, headers, cacheResponse, fallbackResult, _t2;
|
|
38294
|
+
return _regenerator().w(function (_context4) {
|
|
38295
|
+
while (1) switch (_context4.n) {
|
|
38296
|
+
case 0:
|
|
38297
|
+
cacheKey = _ref.cacheKey, sourceKey = _ref.sourceKey, expiryMs = _ref.expiryMs, fetcher = _ref.fetcher, processor = _ref.processor, _ref$metadata = _ref.metadata, metadata = _ref$metadata === void 0 ? {} : _ref$metadata, _ref.logType;
|
|
38298
|
+
_context4.p = 1;
|
|
38299
|
+
_context4.n = 2;
|
|
38300
|
+
return this.getCacheName();
|
|
38301
|
+
case 2:
|
|
38302
|
+
cacheName = _context4.v;
|
|
38303
|
+
_context4.n = 3;
|
|
38304
|
+
return this._getCacheHandle(cacheName);
|
|
38305
|
+
case 3:
|
|
38306
|
+
cache = _context4.v;
|
|
38307
|
+
_context4.n = 4;
|
|
38308
|
+
return cache.match(cacheKey);
|
|
38309
|
+
case 4:
|
|
38310
|
+
cachedResponse = _context4.v;
|
|
38311
|
+
if (!cachedResponse) {
|
|
38312
|
+
_context4.n = 7;
|
|
38313
|
+
break;
|
|
38314
|
+
}
|
|
38315
|
+
cachedTime = cachedResponse.headers.get('x-cached-time');
|
|
38316
|
+
age = Date.now() - parseInt(cachedTime || '0');
|
|
38317
|
+
if (!(age < expiryMs)) {
|
|
38318
|
+
_context4.n = 6;
|
|
38319
|
+
break;
|
|
38320
|
+
}
|
|
38321
|
+
_context4.n = 5;
|
|
38322
|
+
return processor(cachedResponse.clone());
|
|
38323
|
+
case 5:
|
|
38324
|
+
result = _context4.v;
|
|
38325
|
+
this.stats.hits++;
|
|
38326
|
+
result instanceof Blob ? result.size : 0;
|
|
38327
|
+
if (result instanceof Blob) this.stats.totalBytesServed += result.size;
|
|
38328
|
+
return _context4.a(2, result);
|
|
38329
|
+
case 6:
|
|
38330
|
+
_context4.n = 7;
|
|
38331
|
+
return cache.delete(cacheKey);
|
|
38332
|
+
case 7:
|
|
38333
|
+
this.stats.misses++;
|
|
38334
|
+
_context4.n = 8;
|
|
38335
|
+
return fetcher();
|
|
38336
|
+
case 8:
|
|
38337
|
+
fetchResult = _context4.v;
|
|
38338
|
+
blobOrJson = fetchResult;
|
|
38339
|
+
if (!(fetchResult instanceof Response)) {
|
|
38340
|
+
_context4.n = 11;
|
|
38341
|
+
break;
|
|
38342
|
+
}
|
|
38343
|
+
if (fetchResult.ok) {
|
|
38344
|
+
_context4.n = 9;
|
|
38345
|
+
break;
|
|
38346
|
+
}
|
|
38347
|
+
throw new Error("Fetch failed: ".concat(fetchResult.status));
|
|
38348
|
+
case 9:
|
|
38349
|
+
_context4.n = 10;
|
|
38350
|
+
return processor(fetchResult.clone());
|
|
38351
|
+
case 10:
|
|
38352
|
+
blobOrJson = _context4.v;
|
|
38353
|
+
case 11:
|
|
38354
|
+
contentType = 'application/octet-stream';
|
|
38355
|
+
contentSize = 0;
|
|
38356
|
+
responseBody = blobOrJson;
|
|
38357
|
+
if (blobOrJson instanceof Blob) {
|
|
38358
|
+
contentType = blobOrJson.type;
|
|
38359
|
+
contentSize = blobOrJson.size;
|
|
38360
|
+
this.stats.totalBytesCached += contentSize;
|
|
38361
|
+
this.stats.totalBytesServed += contentSize;
|
|
38362
|
+
} else {
|
|
38363
|
+
contentType = 'application/json';
|
|
38364
|
+
responseBody = JSON.stringify(blobOrJson);
|
|
38365
|
+
contentSize = responseBody.length;
|
|
38366
|
+
}
|
|
38367
|
+
headers = new Headers(_objectSpread2({
|
|
38368
|
+
'Content-Type': contentType,
|
|
38369
|
+
'x-cached-time': Date.now().toString(),
|
|
38370
|
+
'x-source-key': sourceKey || ''
|
|
38371
|
+
}, metadata));
|
|
38372
|
+
cacheResponse = new Response(responseBody, {
|
|
38373
|
+
headers: headers
|
|
38374
|
+
});
|
|
38375
|
+
_context4.n = 12;
|
|
38376
|
+
return cache.put(cacheKey, cacheResponse);
|
|
38377
|
+
case 12:
|
|
38378
|
+
return _context4.a(2, blobOrJson);
|
|
38379
|
+
case 13:
|
|
38380
|
+
_context4.p = 13;
|
|
38381
|
+
_t2 = _context4.v;
|
|
38382
|
+
this.stats.errors++;
|
|
38383
|
+
this.config.onError(_t2);
|
|
38384
|
+
|
|
38385
|
+
// Fallback
|
|
38386
|
+
_context4.p = 14;
|
|
38387
|
+
_context4.n = 15;
|
|
38388
|
+
return fetcher();
|
|
38389
|
+
case 15:
|
|
38390
|
+
fallbackResult = _context4.v;
|
|
38391
|
+
if (!(fallbackResult instanceof Response)) {
|
|
38392
|
+
_context4.n = 16;
|
|
38393
|
+
break;
|
|
38394
|
+
}
|
|
38395
|
+
return _context4.a(2, processor(fallbackResult));
|
|
38396
|
+
case 16:
|
|
38397
|
+
return _context4.a(2, fallbackResult);
|
|
38398
|
+
case 17:
|
|
38399
|
+
_context4.p = 17;
|
|
38400
|
+
_context4.v;
|
|
38401
|
+
throw _t2;
|
|
38402
|
+
case 18:
|
|
38403
|
+
return _context4.a(2);
|
|
38404
|
+
}
|
|
38405
|
+
}, _callee4, this, [[14, 17], [1, 13]]);
|
|
38406
|
+
}));
|
|
38407
|
+
function execute(_x2) {
|
|
38408
|
+
return _execute.apply(this, arguments);
|
|
38409
|
+
}
|
|
38410
|
+
return execute;
|
|
38411
|
+
}())
|
|
38412
|
+
}, {
|
|
38413
|
+
key: "getGlobalStats",
|
|
38414
|
+
value: function getGlobalStats() {
|
|
38415
|
+
var uptime = Date.now() - this.stats.startTime;
|
|
38416
|
+
return _objectSpread2(_objectSpread2({}, this.stats), {}, {
|
|
38417
|
+
hitRate: this.stats.hits + this.stats.misses > 0 ? (this.stats.hits / (this.stats.hits + this.stats.misses) * 100).toFixed(1) + '%' : '0%',
|
|
38418
|
+
totalMBServed: (this.stats.totalBytesServed / 1024 / 1024).toFixed(2),
|
|
38419
|
+
totalMBCached: (this.stats.totalBytesCached / 1024 / 1024).toFixed(2),
|
|
38420
|
+
uptimeMinutes: (uptime / 1000 / 60).toFixed(1)
|
|
38421
|
+
});
|
|
38422
|
+
}
|
|
38423
|
+
}, {
|
|
38424
|
+
key: "resetStats",
|
|
38425
|
+
value: function resetStats() {
|
|
38426
|
+
this.stats = {
|
|
38427
|
+
hits: 0,
|
|
38428
|
+
misses: 0,
|
|
38429
|
+
errors: 0,
|
|
38430
|
+
totalBytesServed: 0,
|
|
38431
|
+
totalBytesCached: 0,
|
|
38432
|
+
startTime: Date.now()
|
|
38433
|
+
};
|
|
38434
|
+
}
|
|
38435
|
+
}, {
|
|
38436
|
+
key: "clearCache",
|
|
38437
|
+
value: function () {
|
|
38438
|
+
var _clearCache = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
38439
|
+
var specificKey,
|
|
38440
|
+
clearAllUsers,
|
|
38441
|
+
cacheName,
|
|
38442
|
+
cache,
|
|
38443
|
+
keys,
|
|
38444
|
+
_iterator,
|
|
38445
|
+
_step,
|
|
38446
|
+
req,
|
|
38447
|
+
cacheNames,
|
|
38448
|
+
appCaches,
|
|
38449
|
+
_iterator2,
|
|
38450
|
+
_step2,
|
|
38451
|
+
name,
|
|
38452
|
+
_cacheName,
|
|
38453
|
+
_args5 = arguments,
|
|
38454
|
+
_t4,
|
|
38455
|
+
_t5,
|
|
38456
|
+
_t6;
|
|
38457
|
+
return _regenerator().w(function (_context5) {
|
|
38458
|
+
while (1) switch (_context5.n) {
|
|
38459
|
+
case 0:
|
|
38460
|
+
specificKey = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : null;
|
|
38461
|
+
clearAllUsers = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : false;
|
|
38462
|
+
_context5.p = 1;
|
|
38463
|
+
if (!specificKey) {
|
|
38464
|
+
_context5.n = 12;
|
|
38465
|
+
break;
|
|
38466
|
+
}
|
|
38467
|
+
_context5.n = 2;
|
|
38468
|
+
return this.getCacheName();
|
|
38469
|
+
case 2:
|
|
38470
|
+
cacheName = _context5.v;
|
|
38471
|
+
_context5.n = 3;
|
|
38472
|
+
return caches.open(cacheName);
|
|
38473
|
+
case 3:
|
|
38474
|
+
cache = _context5.v;
|
|
38475
|
+
_context5.n = 4;
|
|
38476
|
+
return cache.keys();
|
|
38477
|
+
case 4:
|
|
38478
|
+
keys = _context5.v;
|
|
38479
|
+
_iterator = _createForOfIteratorHelper(keys);
|
|
38480
|
+
_context5.p = 5;
|
|
38481
|
+
_iterator.s();
|
|
38482
|
+
case 6:
|
|
38483
|
+
if ((_step = _iterator.n()).done) {
|
|
38484
|
+
_context5.n = 8;
|
|
38485
|
+
break;
|
|
38486
|
+
}
|
|
38487
|
+
req = _step.value;
|
|
38488
|
+
if (!req.url.includes(specificKey)) {
|
|
38489
|
+
_context5.n = 7;
|
|
38490
|
+
break;
|
|
38491
|
+
}
|
|
38492
|
+
_context5.n = 7;
|
|
38493
|
+
return cache.delete(req);
|
|
38494
|
+
case 7:
|
|
38495
|
+
_context5.n = 6;
|
|
38496
|
+
break;
|
|
38497
|
+
case 8:
|
|
38498
|
+
_context5.n = 10;
|
|
38499
|
+
break;
|
|
38500
|
+
case 9:
|
|
38501
|
+
_context5.p = 9;
|
|
38502
|
+
_t4 = _context5.v;
|
|
38503
|
+
_iterator.e(_t4);
|
|
38504
|
+
case 10:
|
|
38505
|
+
_context5.p = 10;
|
|
38506
|
+
_iterator.f();
|
|
38507
|
+
return _context5.f(10);
|
|
38508
|
+
case 11:
|
|
38509
|
+
_context5.n = 23;
|
|
38510
|
+
break;
|
|
38511
|
+
case 12:
|
|
38512
|
+
if (!clearAllUsers) {
|
|
38513
|
+
_context5.n = 21;
|
|
38514
|
+
break;
|
|
38515
|
+
}
|
|
38516
|
+
_context5.n = 13;
|
|
38517
|
+
return caches.keys();
|
|
38518
|
+
case 13:
|
|
38519
|
+
cacheNames = _context5.v;
|
|
38520
|
+
appCaches = cacheNames.filter(function (name) {
|
|
38521
|
+
return name.startsWith(CACHE_NAME_PREFIX);
|
|
38522
|
+
});
|
|
38523
|
+
_iterator2 = _createForOfIteratorHelper(appCaches);
|
|
38524
|
+
_context5.p = 14;
|
|
38525
|
+
_iterator2.s();
|
|
38526
|
+
case 15:
|
|
38527
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
38528
|
+
_context5.n = 17;
|
|
38529
|
+
break;
|
|
38530
|
+
}
|
|
38531
|
+
name = _step2.value;
|
|
38532
|
+
_context5.n = 16;
|
|
38533
|
+
return caches.delete(name);
|
|
38534
|
+
case 16:
|
|
38535
|
+
_context5.n = 15;
|
|
38536
|
+
break;
|
|
38537
|
+
case 17:
|
|
38538
|
+
_context5.n = 19;
|
|
38539
|
+
break;
|
|
38540
|
+
case 18:
|
|
38541
|
+
_context5.p = 18;
|
|
38542
|
+
_t5 = _context5.v;
|
|
38543
|
+
_iterator2.e(_t5);
|
|
38544
|
+
case 19:
|
|
38545
|
+
_context5.p = 19;
|
|
38546
|
+
_iterator2.f();
|
|
38547
|
+
return _context5.f(19);
|
|
38548
|
+
case 20:
|
|
38549
|
+
_context5.n = 23;
|
|
38550
|
+
break;
|
|
38551
|
+
case 21:
|
|
38552
|
+
_context5.n = 22;
|
|
38553
|
+
return this.getCacheName();
|
|
38554
|
+
case 22:
|
|
38555
|
+
_cacheName = _context5.v;
|
|
38556
|
+
_context5.n = 23;
|
|
38557
|
+
return caches.delete(_cacheName);
|
|
38558
|
+
case 23:
|
|
38559
|
+
return _context5.a(2, true);
|
|
38560
|
+
case 24:
|
|
38561
|
+
_context5.p = 24;
|
|
38562
|
+
_t6 = _context5.v;
|
|
38563
|
+
this.config.onError(_t6);
|
|
38564
|
+
return _context5.a(2, false);
|
|
38565
|
+
}
|
|
38566
|
+
}, _callee5, this, [[14, 18, 19, 20], [5, 9, 10, 11], [1, 24]]);
|
|
38567
|
+
}));
|
|
38568
|
+
function clearCache() {
|
|
38569
|
+
return _clearCache.apply(this, arguments);
|
|
38570
|
+
}
|
|
38571
|
+
return clearCache;
|
|
38572
|
+
}()
|
|
38573
|
+
}, {
|
|
38574
|
+
key: "cleanExpired",
|
|
38575
|
+
value: function () {
|
|
38576
|
+
var _cleanExpired = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
38577
|
+
var cacheName, cache, keys, count, _iterator3, _step3, request, response, cachedTime, age, sourceKey, expiryMs, _t7, _t8;
|
|
38578
|
+
return _regenerator().w(function (_context6) {
|
|
38579
|
+
while (1) switch (_context6.n) {
|
|
38580
|
+
case 0:
|
|
38581
|
+
_context6.p = 0;
|
|
38582
|
+
_context6.n = 1;
|
|
38583
|
+
return this.getCacheName();
|
|
38584
|
+
case 1:
|
|
38585
|
+
cacheName = _context6.v;
|
|
38586
|
+
_context6.n = 2;
|
|
38587
|
+
return this._getCacheHandle(cacheName);
|
|
38588
|
+
case 2:
|
|
38589
|
+
cache = _context6.v;
|
|
38590
|
+
_context6.n = 3;
|
|
38591
|
+
return cache.keys();
|
|
38592
|
+
case 3:
|
|
38593
|
+
keys = _context6.v;
|
|
38594
|
+
count = 0;
|
|
38595
|
+
_iterator3 = _createForOfIteratorHelper(keys);
|
|
38596
|
+
_context6.p = 4;
|
|
38597
|
+
_iterator3.s();
|
|
38598
|
+
case 5:
|
|
38599
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
38600
|
+
_context6.n = 9;
|
|
38601
|
+
break;
|
|
38602
|
+
}
|
|
38603
|
+
request = _step3.value;
|
|
38604
|
+
_context6.n = 6;
|
|
38605
|
+
return cache.match(request);
|
|
38606
|
+
case 6:
|
|
38607
|
+
response = _context6.v;
|
|
38608
|
+
cachedTime = response.headers.get('x-cached-time');
|
|
38609
|
+
age = Date.now() - parseInt(cachedTime || '0');
|
|
38610
|
+
sourceKey = response.headers.get('x-source-key') || request.url;
|
|
38611
|
+
expiryMs = this.getExpiryForPath(sourceKey);
|
|
38612
|
+
if (!(age > expiryMs)) {
|
|
38613
|
+
_context6.n = 8;
|
|
38614
|
+
break;
|
|
38615
|
+
}
|
|
38616
|
+
_context6.n = 7;
|
|
38617
|
+
return cache.delete(request);
|
|
38618
|
+
case 7:
|
|
38619
|
+
count++;
|
|
38620
|
+
case 8:
|
|
38621
|
+
_context6.n = 5;
|
|
38622
|
+
break;
|
|
38623
|
+
case 9:
|
|
38624
|
+
_context6.n = 11;
|
|
38625
|
+
break;
|
|
38626
|
+
case 10:
|
|
38627
|
+
_context6.p = 10;
|
|
38628
|
+
_t7 = _context6.v;
|
|
38629
|
+
_iterator3.e(_t7);
|
|
38630
|
+
case 11:
|
|
38631
|
+
_context6.p = 11;
|
|
38632
|
+
_iterator3.f();
|
|
38633
|
+
return _context6.f(11);
|
|
38634
|
+
case 12:
|
|
38635
|
+
return _context6.a(2, count);
|
|
38636
|
+
case 13:
|
|
38637
|
+
_context6.p = 13;
|
|
38638
|
+
_t8 = _context6.v;
|
|
38639
|
+
this.config.onError(_t8);
|
|
38640
|
+
return _context6.a(2, 0);
|
|
38641
|
+
}
|
|
38642
|
+
}, _callee6, this, [[4, 10, 11, 12], [0, 13]]);
|
|
38643
|
+
}));
|
|
38644
|
+
function cleanExpired() {
|
|
38645
|
+
return _cleanExpired.apply(this, arguments);
|
|
38646
|
+
}
|
|
38647
|
+
return cleanExpired;
|
|
38648
|
+
}()
|
|
38649
|
+
}, {
|
|
38650
|
+
key: "cleanInvalid",
|
|
38651
|
+
value: function () {
|
|
38652
|
+
var _cleanInvalid = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
38653
|
+
var cacheName, cache, keys, cleanedCount, _iterator4, _step4, request, url, _t9, _t0;
|
|
38654
|
+
return _regenerator().w(function (_context7) {
|
|
38655
|
+
while (1) switch (_context7.n) {
|
|
38656
|
+
case 0:
|
|
38657
|
+
_context7.p = 0;
|
|
38658
|
+
_context7.n = 1;
|
|
38659
|
+
return this.getCacheName();
|
|
38660
|
+
case 1:
|
|
38661
|
+
cacheName = _context7.v;
|
|
38662
|
+
_context7.n = 2;
|
|
38663
|
+
return this._getCacheHandle(cacheName);
|
|
38664
|
+
case 2:
|
|
38665
|
+
cache = _context7.v;
|
|
38666
|
+
_context7.n = 3;
|
|
38667
|
+
return cache.keys();
|
|
38668
|
+
case 3:
|
|
38669
|
+
keys = _context7.v;
|
|
38670
|
+
cleanedCount = 0;
|
|
38671
|
+
_iterator4 = _createForOfIteratorHelper(keys);
|
|
38672
|
+
_context7.p = 4;
|
|
38673
|
+
_iterator4.s();
|
|
38674
|
+
case 5:
|
|
38675
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
38676
|
+
_context7.n = 8;
|
|
38677
|
+
break;
|
|
38678
|
+
}
|
|
38679
|
+
request = _step4.value;
|
|
38680
|
+
url = request.url;
|
|
38681
|
+
if (!(url.includes('undefined') || url.includes('null') || url.includes('/library/models//'))) {
|
|
38682
|
+
_context7.n = 7;
|
|
38683
|
+
break;
|
|
38684
|
+
}
|
|
38685
|
+
_context7.n = 6;
|
|
38686
|
+
return cache.delete(request);
|
|
38687
|
+
case 6:
|
|
38688
|
+
cleanedCount++;
|
|
38689
|
+
case 7:
|
|
38690
|
+
_context7.n = 5;
|
|
38691
|
+
break;
|
|
38692
|
+
case 8:
|
|
38693
|
+
_context7.n = 10;
|
|
38694
|
+
break;
|
|
38695
|
+
case 9:
|
|
38696
|
+
_context7.p = 9;
|
|
38697
|
+
_t9 = _context7.v;
|
|
38698
|
+
_iterator4.e(_t9);
|
|
38699
|
+
case 10:
|
|
38700
|
+
_context7.p = 10;
|
|
38701
|
+
_iterator4.f();
|
|
38702
|
+
return _context7.f(10);
|
|
38703
|
+
case 11:
|
|
38704
|
+
return _context7.a(2, cleanedCount);
|
|
38705
|
+
case 12:
|
|
38706
|
+
_context7.p = 12;
|
|
38707
|
+
_t0 = _context7.v;
|
|
38708
|
+
this.config.onError(_t0);
|
|
38709
|
+
return _context7.a(2, 0);
|
|
38710
|
+
}
|
|
38711
|
+
}, _callee7, this, [[4, 9, 10, 11], [0, 12]]);
|
|
38712
|
+
}));
|
|
38713
|
+
function cleanInvalid() {
|
|
38714
|
+
return _cleanInvalid.apply(this, arguments);
|
|
38715
|
+
}
|
|
38716
|
+
return cleanInvalid;
|
|
38717
|
+
}()
|
|
38718
|
+
/**
|
|
38719
|
+
* Check if a key exists in cache and is valid
|
|
38720
|
+
*/
|
|
38721
|
+
}, {
|
|
38722
|
+
key: "has",
|
|
38723
|
+
value: (function () {
|
|
38724
|
+
var _has = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(cacheKey) {
|
|
38725
|
+
var expiryMs,
|
|
38726
|
+
cacheName,
|
|
38727
|
+
cache,
|
|
38728
|
+
response,
|
|
38729
|
+
cachedTime,
|
|
38730
|
+
age,
|
|
38731
|
+
expiry,
|
|
38732
|
+
_args8 = arguments,
|
|
38733
|
+
_t1;
|
|
38734
|
+
return _regenerator().w(function (_context8) {
|
|
38735
|
+
while (1) switch (_context8.n) {
|
|
38736
|
+
case 0:
|
|
38737
|
+
expiryMs = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : null;
|
|
38738
|
+
_context8.p = 1;
|
|
38739
|
+
_context8.n = 2;
|
|
38740
|
+
return this.getCacheName();
|
|
38741
|
+
case 2:
|
|
38742
|
+
cacheName = _context8.v;
|
|
38743
|
+
_context8.n = 3;
|
|
38744
|
+
return this._getCacheHandle(cacheName);
|
|
38745
|
+
case 3:
|
|
38746
|
+
cache = _context8.v;
|
|
38747
|
+
_context8.n = 4;
|
|
38748
|
+
return cache.match(cacheKey);
|
|
38749
|
+
case 4:
|
|
38750
|
+
response = _context8.v;
|
|
38751
|
+
if (response) {
|
|
38752
|
+
_context8.n = 5;
|
|
38753
|
+
break;
|
|
38754
|
+
}
|
|
38755
|
+
return _context8.a(2, false);
|
|
38756
|
+
case 5:
|
|
38757
|
+
cachedTime = response.headers.get('x-cached-time');
|
|
38758
|
+
age = Date.now() - parseInt(cachedTime || '0');
|
|
38759
|
+
expiry = expiryMs || this.getExpiryForPath(cacheKey);
|
|
38760
|
+
if (!(age < expiry)) {
|
|
38761
|
+
_context8.n = 6;
|
|
38762
|
+
break;
|
|
38763
|
+
}
|
|
38764
|
+
return _context8.a(2, true);
|
|
38765
|
+
case 6:
|
|
38766
|
+
_context8.n = 7;
|
|
38767
|
+
return cache.delete(cacheKey);
|
|
38768
|
+
case 7:
|
|
38769
|
+
return _context8.a(2, false);
|
|
38770
|
+
case 8:
|
|
38771
|
+
_context8.n = 10;
|
|
38772
|
+
break;
|
|
38773
|
+
case 9:
|
|
38774
|
+
_context8.p = 9;
|
|
38775
|
+
_t1 = _context8.v;
|
|
38776
|
+
this.config.onError(_t1);
|
|
38777
|
+
return _context8.a(2, false);
|
|
38778
|
+
case 10:
|
|
38779
|
+
return _context8.a(2);
|
|
38780
|
+
}
|
|
38781
|
+
}, _callee8, this, [[1, 9]]);
|
|
38782
|
+
}));
|
|
38783
|
+
function has(_x3) {
|
|
38784
|
+
return _has.apply(this, arguments);
|
|
38785
|
+
}
|
|
38786
|
+
return has;
|
|
38787
|
+
}()
|
|
38788
|
+
/**
|
|
38789
|
+
* Get a value from cache without fetching (returns null on miss/expiry)
|
|
38790
|
+
*/
|
|
38791
|
+
)
|
|
38792
|
+
}, {
|
|
38793
|
+
key: "get",
|
|
38794
|
+
value: (function () {
|
|
38795
|
+
var _get = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(cacheKey) {
|
|
38796
|
+
var expiryMs,
|
|
38797
|
+
processor,
|
|
38798
|
+
cacheName,
|
|
38799
|
+
cache,
|
|
38800
|
+
response,
|
|
38801
|
+
cachedTime,
|
|
38802
|
+
age,
|
|
38803
|
+
expiry,
|
|
38804
|
+
_args0 = arguments,
|
|
38805
|
+
_t10;
|
|
38806
|
+
return _regenerator().w(function (_context0) {
|
|
38807
|
+
while (1) switch (_context0.n) {
|
|
38808
|
+
case 0:
|
|
38809
|
+
expiryMs = _args0.length > 1 && _args0[1] !== undefined ? _args0[1] : null;
|
|
38810
|
+
processor = _args0.length > 2 && _args0[2] !== undefined ? _args0[2] : (/*#__PURE__*/function () {
|
|
38811
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(r) {
|
|
38812
|
+
return _regenerator().w(function (_context9) {
|
|
38813
|
+
while (1) switch (_context9.n) {
|
|
38814
|
+
case 0:
|
|
38815
|
+
return _context9.a(2, r.json());
|
|
38816
|
+
}
|
|
38817
|
+
}, _callee9);
|
|
38818
|
+
}));
|
|
38819
|
+
return function (_x5) {
|
|
38820
|
+
return _ref2.apply(this, arguments);
|
|
38821
|
+
};
|
|
38822
|
+
}());
|
|
38823
|
+
_context0.p = 1;
|
|
38824
|
+
_context0.n = 2;
|
|
38825
|
+
return this.getCacheName();
|
|
38826
|
+
case 2:
|
|
38827
|
+
cacheName = _context0.v;
|
|
38828
|
+
_context0.n = 3;
|
|
38829
|
+
return this._getCacheHandle(cacheName);
|
|
38830
|
+
case 3:
|
|
38831
|
+
cache = _context0.v;
|
|
38832
|
+
_context0.n = 4;
|
|
38833
|
+
return cache.match(cacheKey);
|
|
38834
|
+
case 4:
|
|
38835
|
+
response = _context0.v;
|
|
38836
|
+
if (response) {
|
|
38837
|
+
_context0.n = 5;
|
|
38838
|
+
break;
|
|
38839
|
+
}
|
|
38840
|
+
return _context0.a(2, null);
|
|
38841
|
+
case 5:
|
|
38842
|
+
cachedTime = response.headers.get('x-cached-time');
|
|
38843
|
+
age = Date.now() - parseInt(cachedTime || '0');
|
|
38844
|
+
expiry = expiryMs || this.getExpiryForPath(cacheKey);
|
|
38845
|
+
if (!(age < expiry)) {
|
|
38846
|
+
_context0.n = 7;
|
|
38847
|
+
break;
|
|
38848
|
+
}
|
|
38849
|
+
this.stats.hits++;
|
|
38850
|
+
_context0.n = 6;
|
|
38851
|
+
return processor(response);
|
|
38852
|
+
case 6:
|
|
38853
|
+
return _context0.a(2, _context0.v);
|
|
38854
|
+
case 7:
|
|
38855
|
+
_context0.n = 8;
|
|
38856
|
+
return cache.delete(cacheKey);
|
|
38857
|
+
case 8:
|
|
38858
|
+
return _context0.a(2, null);
|
|
38859
|
+
case 9:
|
|
38860
|
+
_context0.n = 11;
|
|
38861
|
+
break;
|
|
38862
|
+
case 10:
|
|
38863
|
+
_context0.p = 10;
|
|
38864
|
+
_t10 = _context0.v;
|
|
38865
|
+
this.config.onError(_t10);
|
|
38866
|
+
return _context0.a(2, null);
|
|
38867
|
+
case 11:
|
|
38868
|
+
return _context0.a(2);
|
|
38869
|
+
}
|
|
38870
|
+
}, _callee0, this, [[1, 10]]);
|
|
38871
|
+
}));
|
|
38872
|
+
function get(_x4) {
|
|
38873
|
+
return _get.apply(this, arguments);
|
|
38874
|
+
}
|
|
38875
|
+
return get;
|
|
38876
|
+
}()
|
|
38877
|
+
/**
|
|
38878
|
+
* Delete a specific key from value
|
|
38879
|
+
*/
|
|
38880
|
+
)
|
|
38881
|
+
}, {
|
|
38882
|
+
key: "delete",
|
|
38883
|
+
value: (function () {
|
|
38884
|
+
var _delete2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(cacheKey) {
|
|
38885
|
+
var cacheName, cache, _t11;
|
|
38886
|
+
return _regenerator().w(function (_context1) {
|
|
38887
|
+
while (1) switch (_context1.n) {
|
|
38888
|
+
case 0:
|
|
38889
|
+
_context1.p = 0;
|
|
38890
|
+
_context1.n = 1;
|
|
38891
|
+
return this.getCacheName();
|
|
38892
|
+
case 1:
|
|
38893
|
+
cacheName = _context1.v;
|
|
38894
|
+
_context1.n = 2;
|
|
38895
|
+
return this._getCacheHandle(cacheName);
|
|
38896
|
+
case 2:
|
|
38897
|
+
cache = _context1.v;
|
|
38898
|
+
_context1.n = 3;
|
|
38899
|
+
return cache.delete(cacheKey);
|
|
38900
|
+
case 3:
|
|
38901
|
+
return _context1.a(2, _context1.v);
|
|
38902
|
+
case 4:
|
|
38903
|
+
_context1.p = 4;
|
|
38904
|
+
_t11 = _context1.v;
|
|
38905
|
+
this.config.onError(_t11);
|
|
38906
|
+
return _context1.a(2, false);
|
|
38907
|
+
}
|
|
38908
|
+
}, _callee1, this, [[0, 4]]);
|
|
38909
|
+
}));
|
|
38910
|
+
function _delete(_x6) {
|
|
38911
|
+
return _delete2.apply(this, arguments);
|
|
38912
|
+
}
|
|
38913
|
+
return _delete;
|
|
38914
|
+
}()
|
|
38915
|
+
/**
|
|
38916
|
+
* Delete a specific named cache (partition)
|
|
38917
|
+
*/
|
|
38918
|
+
)
|
|
38919
|
+
}, {
|
|
38920
|
+
key: "deleteCache",
|
|
38921
|
+
value: (function () {
|
|
38922
|
+
var _deleteCache = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(cacheName) {
|
|
38923
|
+
var _t12;
|
|
38924
|
+
return _regenerator().w(function (_context10) {
|
|
38925
|
+
while (1) switch (_context10.n) {
|
|
38926
|
+
case 0:
|
|
38927
|
+
_context10.p = 0;
|
|
38928
|
+
_context10.n = 1;
|
|
38929
|
+
return caches.delete(cacheName);
|
|
38930
|
+
case 1:
|
|
38931
|
+
return _context10.a(2, _context10.v);
|
|
38932
|
+
case 2:
|
|
38933
|
+
_context10.p = 2;
|
|
38934
|
+
_t12 = _context10.v;
|
|
38935
|
+
this.config.onError(_t12);
|
|
38936
|
+
return _context10.a(2, false);
|
|
38937
|
+
}
|
|
38938
|
+
}, _callee10, this, [[0, 2]]);
|
|
38939
|
+
}));
|
|
38940
|
+
function deleteCache(_x7) {
|
|
38941
|
+
return _deleteCache.apply(this, arguments);
|
|
38942
|
+
}
|
|
38943
|
+
return deleteCache;
|
|
38944
|
+
}())
|
|
38945
|
+
}, {
|
|
38946
|
+
key: "getDetailedStats",
|
|
38947
|
+
value: function () {
|
|
38948
|
+
var _getDetailedStats = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
|
|
38949
|
+
var allUsers,
|
|
38950
|
+
cacheNames,
|
|
38951
|
+
plantCaches,
|
|
38952
|
+
allStats,
|
|
38953
|
+
_iterator5,
|
|
38954
|
+
_step5,
|
|
38955
|
+
_cacheName2,
|
|
38956
|
+
_cache,
|
|
38957
|
+
_keys,
|
|
38958
|
+
_totalSize,
|
|
38959
|
+
_iterator6,
|
|
38960
|
+
_step6,
|
|
38961
|
+
request,
|
|
38962
|
+
response,
|
|
38963
|
+
blob,
|
|
38964
|
+
grandTotal,
|
|
38965
|
+
cacheName,
|
|
38966
|
+
cache,
|
|
38967
|
+
keys,
|
|
38968
|
+
totalSize,
|
|
38969
|
+
items,
|
|
38970
|
+
_iterator7,
|
|
38971
|
+
_step7,
|
|
38972
|
+
_request,
|
|
38973
|
+
_response,
|
|
38974
|
+
_blob,
|
|
38975
|
+
cachedTime,
|
|
38976
|
+
sourceKey,
|
|
38977
|
+
_args11 = arguments,
|
|
38978
|
+
_t13,
|
|
38979
|
+
_t14,
|
|
38980
|
+
_t15,
|
|
38981
|
+
_t16;
|
|
38982
|
+
return _regenerator().w(function (_context11) {
|
|
38983
|
+
while (1) switch (_context11.n) {
|
|
38984
|
+
case 0:
|
|
38985
|
+
allUsers = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : false;
|
|
38986
|
+
_context11.p = 1;
|
|
38987
|
+
if (!allUsers) {
|
|
38988
|
+
_context11.n = 21;
|
|
38989
|
+
break;
|
|
38990
|
+
}
|
|
38991
|
+
_context11.n = 2;
|
|
38992
|
+
return caches.keys();
|
|
38993
|
+
case 2:
|
|
38994
|
+
cacheNames = _context11.v;
|
|
38995
|
+
plantCaches = cacheNames.filter(function (name) {
|
|
38996
|
+
return name.startsWith(CACHE_NAME_PREFIX);
|
|
38997
|
+
});
|
|
38998
|
+
allStats = [];
|
|
38999
|
+
_iterator5 = _createForOfIteratorHelper(plantCaches);
|
|
39000
|
+
_context11.p = 3;
|
|
39001
|
+
_iterator5.s();
|
|
39002
|
+
case 4:
|
|
39003
|
+
if ((_step5 = _iterator5.n()).done) {
|
|
39004
|
+
_context11.n = 17;
|
|
39005
|
+
break;
|
|
39006
|
+
}
|
|
39007
|
+
_cacheName2 = _step5.value;
|
|
39008
|
+
_context11.n = 5;
|
|
39009
|
+
return caches.open(_cacheName2);
|
|
39010
|
+
case 5:
|
|
39011
|
+
_cache = _context11.v;
|
|
39012
|
+
_context11.n = 6;
|
|
39013
|
+
return _cache.keys();
|
|
39014
|
+
case 6:
|
|
39015
|
+
_keys = _context11.v;
|
|
39016
|
+
_totalSize = 0;
|
|
39017
|
+
_iterator6 = _createForOfIteratorHelper(_keys);
|
|
39018
|
+
_context11.p = 7;
|
|
39019
|
+
_iterator6.s();
|
|
39020
|
+
case 8:
|
|
39021
|
+
if ((_step6 = _iterator6.n()).done) {
|
|
39022
|
+
_context11.n = 12;
|
|
39023
|
+
break;
|
|
39024
|
+
}
|
|
39025
|
+
request = _step6.value;
|
|
39026
|
+
_context11.n = 9;
|
|
39027
|
+
return _cache.match(request);
|
|
39028
|
+
case 9:
|
|
39029
|
+
response = _context11.v;
|
|
39030
|
+
_context11.n = 10;
|
|
39031
|
+
return response.blob();
|
|
39032
|
+
case 10:
|
|
39033
|
+
blob = _context11.v;
|
|
39034
|
+
_totalSize += blob.size;
|
|
39035
|
+
case 11:
|
|
39036
|
+
_context11.n = 8;
|
|
39037
|
+
break;
|
|
39038
|
+
case 12:
|
|
39039
|
+
_context11.n = 14;
|
|
39040
|
+
break;
|
|
39041
|
+
case 13:
|
|
39042
|
+
_context11.p = 13;
|
|
39043
|
+
_t13 = _context11.v;
|
|
39044
|
+
_iterator6.e(_t13);
|
|
39045
|
+
case 14:
|
|
39046
|
+
_context11.p = 14;
|
|
39047
|
+
_iterator6.f();
|
|
39048
|
+
return _context11.f(14);
|
|
39049
|
+
case 15:
|
|
39050
|
+
allStats.push({
|
|
39051
|
+
cacheName: _cacheName2,
|
|
39052
|
+
count: _keys.length,
|
|
39053
|
+
totalSize: _totalSize,
|
|
39054
|
+
totalSizeMB: (_totalSize / 1024 / 1024).toFixed(2)
|
|
39055
|
+
});
|
|
39056
|
+
case 16:
|
|
39057
|
+
_context11.n = 4;
|
|
39058
|
+
break;
|
|
39059
|
+
case 17:
|
|
39060
|
+
_context11.n = 19;
|
|
39061
|
+
break;
|
|
39062
|
+
case 18:
|
|
39063
|
+
_context11.p = 18;
|
|
39064
|
+
_t14 = _context11.v;
|
|
39065
|
+
_iterator5.e(_t14);
|
|
39066
|
+
case 19:
|
|
39067
|
+
_context11.p = 19;
|
|
39068
|
+
_iterator5.f();
|
|
39069
|
+
return _context11.f(19);
|
|
39070
|
+
case 20:
|
|
39071
|
+
grandTotal = allStats.reduce(function (sum, stat) {
|
|
39072
|
+
return sum + stat.totalSize;
|
|
39073
|
+
}, 0);
|
|
39074
|
+
return _context11.a(2, {
|
|
39075
|
+
caches: allStats,
|
|
39076
|
+
totalCaches: allStats.length,
|
|
39077
|
+
grandTotalSizeMB: (grandTotal / 1024 / 1024).toFixed(2)
|
|
39078
|
+
});
|
|
39079
|
+
case 21:
|
|
39080
|
+
_context11.n = 22;
|
|
39081
|
+
return this.getCacheName();
|
|
39082
|
+
case 22:
|
|
39083
|
+
cacheName = _context11.v;
|
|
39084
|
+
_context11.n = 23;
|
|
39085
|
+
return caches.open(cacheName);
|
|
39086
|
+
case 23:
|
|
39087
|
+
cache = _context11.v;
|
|
39088
|
+
_context11.n = 24;
|
|
39089
|
+
return cache.keys();
|
|
39090
|
+
case 24:
|
|
39091
|
+
keys = _context11.v;
|
|
39092
|
+
totalSize = 0;
|
|
39093
|
+
items = [];
|
|
39094
|
+
_iterator7 = _createForOfIteratorHelper(keys);
|
|
39095
|
+
_context11.p = 25;
|
|
39096
|
+
_iterator7.s();
|
|
39097
|
+
case 26:
|
|
39098
|
+
if ((_step7 = _iterator7.n()).done) {
|
|
39099
|
+
_context11.n = 30;
|
|
39100
|
+
break;
|
|
39101
|
+
}
|
|
39102
|
+
_request = _step7.value;
|
|
39103
|
+
_context11.n = 27;
|
|
39104
|
+
return cache.match(_request);
|
|
39105
|
+
case 27:
|
|
39106
|
+
_response = _context11.v;
|
|
39107
|
+
_context11.n = 28;
|
|
39108
|
+
return _response.blob();
|
|
39109
|
+
case 28:
|
|
39110
|
+
_blob = _context11.v;
|
|
39111
|
+
cachedTime = _response.headers.get('x-cached-time'); // Try to get key from headers or fallback
|
|
39112
|
+
sourceKey = _response.headers.get('x-source-key') || _response.headers.get('x-s3-key') || _response.headers.get('x-local-path') || _request.url;
|
|
39113
|
+
totalSize += _blob.size;
|
|
39114
|
+
items.push({
|
|
39115
|
+
url: _request.url,
|
|
39116
|
+
sourceKey: sourceKey,
|
|
39117
|
+
size: _blob.size,
|
|
39118
|
+
sizeMB: (_blob.size / 1024 / 1024).toFixed(2),
|
|
39119
|
+
type: _blob.type,
|
|
39120
|
+
cachedTime: parseInt(cachedTime || '0'),
|
|
39121
|
+
age: Date.now() - parseInt(cachedTime || '0')
|
|
39122
|
+
});
|
|
39123
|
+
case 29:
|
|
39124
|
+
_context11.n = 26;
|
|
39125
|
+
break;
|
|
39126
|
+
case 30:
|
|
39127
|
+
_context11.n = 32;
|
|
39128
|
+
break;
|
|
39129
|
+
case 31:
|
|
39130
|
+
_context11.p = 31;
|
|
39131
|
+
_t15 = _context11.v;
|
|
39132
|
+
_iterator7.e(_t15);
|
|
39133
|
+
case 32:
|
|
39134
|
+
_context11.p = 32;
|
|
39135
|
+
_iterator7.f();
|
|
39136
|
+
return _context11.f(32);
|
|
39137
|
+
case 33:
|
|
39138
|
+
return _context11.a(2, {
|
|
39139
|
+
count: keys.length,
|
|
39140
|
+
totalSize: totalSize,
|
|
39141
|
+
totalSizeMB: (totalSize / 1024 / 1024).toFixed(2),
|
|
39142
|
+
items: items.sort(function (a, b) {
|
|
39143
|
+
return b.size - a.size;
|
|
39144
|
+
})
|
|
39145
|
+
});
|
|
39146
|
+
case 34:
|
|
39147
|
+
_context11.p = 34;
|
|
39148
|
+
_t16 = _context11.v;
|
|
39149
|
+
this.config.onError(_t16);
|
|
39150
|
+
return _context11.a(2, {
|
|
39151
|
+
count: 0,
|
|
39152
|
+
totalSize: 0,
|
|
39153
|
+
totalSizeMB: '0',
|
|
39154
|
+
items: []
|
|
39155
|
+
});
|
|
39156
|
+
}
|
|
39157
|
+
}, _callee11, this, [[25, 31, 32, 33], [7, 13, 14, 15], [3, 18, 19, 20], [1, 34]]);
|
|
39158
|
+
}));
|
|
39159
|
+
function getDetailedStats() {
|
|
39160
|
+
return _getDetailedStats.apply(this, arguments);
|
|
39161
|
+
}
|
|
39162
|
+
return getDetailedStats;
|
|
39163
|
+
}()
|
|
39164
|
+
}]);
|
|
39165
|
+
}();
|
|
39166
|
+
var cacheManager = new CacheManager();
|
|
39167
|
+
|
|
38008
39168
|
var Rendering2D = /*#__PURE__*/function (_BaseDisposable) {
|
|
38009
39169
|
function Rendering2D(_canvas) {
|
|
38010
39170
|
var _this;
|
|
@@ -39319,6 +40479,9 @@ var rendering3D = /*#__PURE__*/Object.freeze({
|
|
|
39319
40479
|
});
|
|
39320
40480
|
|
|
39321
40481
|
exports.AnimationManager = AnimationManager;
|
|
40482
|
+
exports.CACHE_EXPIRY = CACHE_EXPIRY;
|
|
40483
|
+
exports.CACHE_NAME_PREFIX = CACHE_NAME_PREFIX;
|
|
40484
|
+
exports.CacheManager = CacheManager;
|
|
39322
40485
|
exports.CameraControlsManager = CameraControlsManager;
|
|
39323
40486
|
exports.CentralPlant = CentralPlant;
|
|
39324
40487
|
exports.ComponentDataManager = ComponentDataManager;
|
|
@@ -39340,6 +40503,7 @@ exports.SceneOperationsManager = SceneOperationsManager;
|
|
|
39340
40503
|
exports.SceneTooltipsManager = SceneTooltipsManager;
|
|
39341
40504
|
exports.SnapshotManager = SnapshotManager;
|
|
39342
40505
|
exports.ThreeJSResourceManager = ThreeJSResourceManager;
|
|
40506
|
+
exports.cacheManager = cacheManager;
|
|
39343
40507
|
exports.createPathfindingRequest = createPathfindingRequest;
|
|
39344
40508
|
exports.createTransformControls = createTransformControls;
|
|
39345
40509
|
exports.findObjectByHardcodedUuid = findObjectByHardcodedUuid;
|