@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.
@@ -358,7 +358,7 @@ var ModelManager = /*#__PURE__*/function () {
358
358
  key: "preloadMissingModels",
359
359
  value: (function () {
360
360
  var _preloadMissingModels = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(data, componentDictionary) {
361
- var _data$scene, _data$scene2, requiredModels, preloaderStatus, cachedModels, missingModels, _iterator, _step, modelKey, _t5, _t6;
361
+ var _data$scene, _data$scene2, requiredModels, preloaderStatus, cachedModels, missingModels, basePath, modelUrls, _iterator, _step, modelKey, _t5, _t6;
362
362
  return _regenerator().w(function (_context4) {
363
363
  while (1) switch (_context4.n) {
364
364
  case 0:
@@ -375,25 +375,58 @@ var ModelManager = /*#__PURE__*/function () {
375
375
  return _context4.a(2);
376
376
  case 1:
377
377
  requiredModels = new Set();
378
+ console.log("\uD83D\uDD0D Checking ".concat(data.scene.children.length, " scene objects for required models..."));
378
379
  data.scene.children.forEach(function (child) {
379
- var _child$userData, _child$userData2;
380
- if ((_child$userData = child.userData) !== null && _child$userData !== void 0 && _child$userData.libraryId && componentDictionary[(_child$userData2 = child.userData) === null || _child$userData2 === void 0 ? void 0 : _child$userData2.libraryId]) {
381
- var _child$userData3;
382
- var modelKey = componentDictionary[(_child$userData3 = child.userData) === null || _child$userData3 === void 0 ? void 0 : _child$userData3.libraryId].modelKey;
383
- if (modelKey) {
384
- requiredModels.add(modelKey);
380
+ var _child$userData;
381
+ var libraryId = (_child$userData = child.userData) === null || _child$userData === void 0 ? void 0 : _child$userData.libraryId;
382
+ if (libraryId) {
383
+ if (componentDictionary[libraryId]) {
384
+ var modelKey = componentDictionary[libraryId].modelKey;
385
+ if (modelKey) {
386
+ requiredModels.add(modelKey);
387
+ // console.log(` Found required model for ${libraryId}: ${modelKey}`)
388
+ } else {
389
+ console.warn(" Item ".concat(libraryId, " has no modelKey in dictionary"));
390
+ }
391
+ } else {
392
+ console.warn(" Item ".concat(libraryId, " found in scene but missing from dictionary"));
385
393
  }
386
394
  }
387
395
  });
388
- console.log('🔍 Required models for this scene:', Array.from(requiredModels));
396
+ console.log('🔍 Required models for this scene (Set):', Array.from(requiredModels));
389
397
  _context4.n = 2;
390
398
  return this.verifyModelPreloaderCache();
391
399
  case 2:
392
400
  preloaderStatus = _context4.v;
393
401
  cachedModels = preloaderStatus.cachedModels;
402
+ console.log('ModelPreloader cached models:', cachedModels);
403
+
404
+ // Calculate missing models for IN-MEMORY preloading
394
405
  missingModels = Array.from(requiredModels).filter(function (model) {
395
406
  return !cachedModels.includes(model);
396
407
  });
408
+ console.log('Missing models (calculated):', missingModels);
409
+
410
+ // OPTIONAL: Prime persistent browser cache (Cache Storage) using injected primer
411
+ // We prime ALL required models to ensure they are in the persistent cache, even if already in memory
412
+ if (requiredModels.size > 0 && this.sceneViewer && this.sceneViewer.centralPlant) {
413
+ // Construct URLs based on preloader's base path
414
+ basePath = modelPreloader.modelsBasePath || '/library/models/';
415
+ modelUrls = Array.from(requiredModels).map(function (key) {
416
+ return "".concat(basePath).concat(key);
417
+ });
418
+ console.log("\uD83D\uDCBE Priming persistent cache for ".concat(modelUrls.length, " assets..."));
419
+ this.sceneViewer.centralPlant.primeCache(modelUrls).then(function (result) {
420
+ if (result && !result.skipped) {
421
+ console.log("\u2705 Persistent cache primed: ".concat(result.success, " success, ").concat(result.failed, " failed"));
422
+ if (result.failed > 0) {
423
+ console.warn('Cache priming failures:', result.errors);
424
+ }
425
+ }
426
+ }).catch(function (err) {
427
+ return console.warn('Persistent cache priming failed:', err);
428
+ });
429
+ }
397
430
  if (!(missingModels.length > 0)) {
398
431
  _context4.n = 12;
399
432
  break;
@@ -401,7 +434,7 @@ var ModelManager = /*#__PURE__*/function () {
401
434
  console.warn('⚠️ Some required models are not cached:', missingModels);
402
435
  console.log('🔄 Attempting to preload missing models...');
403
436
 
404
- // Preload missing models
437
+ // Preload missing models (Main in-memory preloader)
405
438
  _iterator = _createForOfIteratorHelper(missingModels);
406
439
  _context4.p = 3;
407
440
  _iterator.s();
@@ -536,19 +569,22 @@ var ModelManager = /*#__PURE__*/function () {
536
569
  key: "loadComponentDictionary",
537
570
  value: (function () {
538
571
  var _loadComponentDictionary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
539
- var response, _t7;
572
+ var response, dict, _t7;
540
573
  return _regenerator().w(function (_context6) {
541
574
  while (1) switch (_context6.n) {
542
575
  case 0:
543
576
  _context6.p = 0;
577
+ console.log('🔄 ModelManager loading component dictionary...');
544
578
  _context6.n = 1;
545
- return fetch('./library/component-dictionary.json');
579
+ return fetch('/library/component-dictionary.json');
546
580
  case 1:
547
581
  response = _context6.v;
548
582
  _context6.n = 2;
549
583
  return response.json();
550
584
  case 2:
551
- return _context6.a(2, _context6.v);
585
+ dict = _context6.v;
586
+ console.log('✅ ModelManager loaded dictionary:', Object.keys(dict).length, 'entries');
587
+ return _context6.a(2, dict);
552
588
  case 3:
553
589
  _context6.p = 3;
554
590
  _t7 = _context6.v;
@@ -1122,9 +1122,9 @@ var SceneOperationsManager = /*#__PURE__*/function () {
1122
1122
  // Store current scene data even for default scene
1123
1123
  component.currentSceneData = data;
1124
1124
 
1125
- // Use the consolidated scene loading function
1125
+ // Use the consolidated scene loading function (treat as imported to ensure consistent behavior)
1126
1126
  _context8.n = 4;
1127
- return this.loadSceneData(data, false);
1127
+ return this.loadSceneFromData(data);
1128
1128
  case 4:
1129
1129
  _context8.n = 6;
1130
1130
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@2112-lab/central-plant",
3
- "version": "0.1.71",
3
+ "version": "0.1.72",
4
4
  "description": "Utility modules for the Central Plant Application",
5
5
  "main": "dist/bundle/index.js",
6
6
  "module": "dist/esm/index.js",