kitchen-simulator 5.10.7-react.18 → 5.10.8-react.18

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.
@@ -43,6 +43,7 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
43
43
  var _this;
44
44
  _classCallCheck(this, LiteKitchenConfigurator);
45
45
  _this = _callSuper(this, LiteKitchenConfigurator, [props]);
46
+ _this._catalogInitStarted = false;
46
47
  _this.state = {
47
48
  savePopupVisible: false,
48
49
  quotePopupVisible: false,
@@ -289,33 +290,33 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
289
290
  if (el !== null && el !== void 0 && (_el$parentElement0 = el.parentElement) !== null && _el$parentElement0 !== void 0 && _el$parentElement0.parentElement) el.parentElement.parentElement.style.zIndex = 6;
290
291
  }
291
292
  }, {
292
- key: "componentDidMount",
293
- value: function componentDidMount() {
293
+ key: "ensureCatalogReady",
294
+ value: function ensureCatalogReady() {
294
295
  var _extractedState$getIn;
295
- window.forRedo = [];
296
296
  var _this$props = this.props,
297
297
  catalog = _this$props.catalog,
298
298
  extractedState = _this$props.extractedState,
299
299
  projectActions = _this$props.projectActions;
300
- var catalogReady = extractedState === null || extractedState === void 0 || (_extractedState$getIn = extractedState.getIn) === null || _extractedState$getIn === void 0 ? void 0 : _extractedState$getIn.call(extractedState, ['catalog', 'ready']);
301
- if (!catalogReady) projectActions.initCatalog(catalog);
300
+ var ready = extractedState === null || extractedState === void 0 || (_extractedState$getIn = extractedState.getIn) === null || _extractedState$getIn === void 0 ? void 0 : _extractedState$getIn.call(extractedState, ['catalog', 'ready']);
301
+ if (ready) return;
302
+ if (this._catalogInitStarted) return; // ✅ prevent repeated init storms
303
+ this._catalogInitStarted = true;
304
+ projectActions.initCatalog(catalog);
305
+ }
306
+ }, {
307
+ key: "componentDidMount",
308
+ value: function componentDidMount() {
309
+ window.forRedo = [];
310
+ if (this.props.externalEvent) handleExternalEvent(this.props);
311
+ this.ensureCatalogReady();
302
312
  }
303
313
  }, {
304
314
  key: "componentDidUpdate",
305
315
  value: function componentDidUpdate(prevProps) {
306
- var _extractedState$getIn2;
307
- var _this$props2 = this.props,
308
- externalEvent = _this$props2.externalEvent,
309
- extractedState = _this$props2.extractedState,
310
- projectActions = _this$props2.projectActions,
311
- catalog = _this$props2.catalog;
312
-
313
- // same behavior: handle external event when it changes
314
- if (prevProps.externalEvent !== externalEvent) {
316
+ if (prevProps.externalEvent !== this.props.externalEvent) {
315
317
  handleExternalEvent(this.props);
316
318
  }
317
- var catalogReady = extractedState === null || extractedState === void 0 || (_extractedState$getIn2 = extractedState.getIn) === null || _extractedState$getIn2 === void 0 ? void 0 : _extractedState$getIn2.call(extractedState, ['catalog', 'ready']);
318
- if (!catalogReady) projectActions.initCatalog(catalog);
319
+ this.ensureCatalogReady();
319
320
  }
320
321
  }, {
321
322
  key: "isProjectEmpty",
@@ -366,11 +367,11 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
366
367
  key: "render",
367
368
  value: function render() {
368
369
  var _this2 = this;
369
- var _this$props3 = this.props,
370
- width = _this$props3.width,
371
- height = _this$props3.height,
372
- extractedState = _this$props3.extractedState,
373
- props = _objectWithoutProperties(_this$props3, _excluded);
370
+ var _this$props2 = this.props,
371
+ width = _this$props2.width,
372
+ height = _this$props2.height,
373
+ extractedState = _this$props2.extractedState,
374
+ props = _objectWithoutProperties(_this$props2, _excluded);
374
375
  var _this$state = this.state,
375
376
  savePopupVisible = _this$state.savePopupVisible,
376
377
  quotePopupVisible = _this$state.quotePopupVisible,
package/es/index.js CHANGED
@@ -140,14 +140,8 @@ function installGltfTracker() {
140
140
  if (g.inFlight < 0) g.inFlight = 0;
141
141
  notify();
142
142
  _this.removeEventListener('loadend', _done);
143
- _this.removeEventListener('error', _done);
144
- _this.removeEventListener('abort', _done);
145
- _this.removeEventListener('timeout', _done);
146
143
  };
147
144
  this.addEventListener('loadend', _done);
148
- this.addEventListener('error', _done);
149
- this.addEventListener('abort', _done);
150
- this.addEventListener('timeout', _done);
151
145
  }
152
146
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
153
147
  args[_key2] = arguments[_key2];
@@ -246,11 +240,13 @@ function installGltfTracker() {
246
240
  var _ref3,
247
241
  _ref3$timeoutMs,
248
242
  timeoutMs,
243
+ start,
249
244
  _args4 = arguments;
250
245
  return _regeneratorRuntime.wrap(function (_context4) {
251
246
  while (1) switch (_context4.prev = _context4.next) {
252
247
  case 0:
253
248
  _ref3 = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, _ref3$timeoutMs = _ref3.timeoutMs, timeoutMs = _ref3$timeoutMs === void 0 ? 30000 : _ref3$timeoutMs;
249
+ start = Date.now();
254
250
  _context4.next = 1;
255
251
  return waitStableIdle2Frames();
256
252
  case 1:
@@ -262,50 +258,38 @@ function installGltfTracker() {
262
258
  case 2:
263
259
  return _context4.abrupt("return", new Promise(function (resolve, reject) {
264
260
  var unsub = null;
265
- var finished = false;
266
- var finishOk = function finishOk() {
267
- if (finished) return;
268
- finished = true;
269
- if (unsub) unsub();
270
- clearTimeout(timer);
271
- resolve(true);
272
- };
273
- var finishErr = function finishErr(err) {
274
- if (finished) return;
275
- finished = true;
276
- if (unsub) unsub();
277
- clearTimeout(timer);
278
- reject(err);
279
- };
280
-
281
- // ✅ Real timeout no matter what happens with inFlight changes
282
- var timer = setTimeout(function () {
283
- finishErr(new Error('3D assets did not become idle within timeout'));
284
- }, timeoutMs);
285
261
  var onChange = /*#__PURE__*/function () {
286
262
  var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(count) {
287
263
  var stable;
288
264
  return _regeneratorRuntime.wrap(function (_context3) {
289
265
  while (1) switch (_context3.prev = _context3.next) {
290
266
  case 0:
291
- if (!finished) {
267
+ if (!(count !== 0)) {
292
268
  _context3.next = 1;
293
269
  break;
294
270
  }
271
+ if (Date.now() - start > timeoutMs) {
272
+ if (unsub) unsub();
273
+ reject(new Error('3D assets did not become idle within timeout'));
274
+ }
295
275
  return _context3.abrupt("return");
296
276
  case 1:
297
- if (!(count !== 0)) {
298
- _context3.next = 2;
277
+ _context3.next = 2;
278
+ return waitStableIdle2Frames();
279
+ case 2:
280
+ stable = _context3.sent;
281
+ if (!stable) {
282
+ _context3.next = 3;
299
283
  break;
300
284
  }
285
+ if (unsub) unsub();
286
+ resolve(true);
301
287
  return _context3.abrupt("return");
302
- case 2:
303
- _context3.next = 3;
304
- return waitStableIdle2Frames();
305
288
  case 3:
306
- stable = _context3.sent;
307
- if (stable) finishOk();
308
- // else keep waiting
289
+ if (Date.now() - start > timeoutMs) {
290
+ if (unsub) unsub();
291
+ reject(new Error('3D assets did not become idle within timeout'));
292
+ }
309
293
  case 4:
310
294
  case "end":
311
295
  return _context3.stop();
@@ -466,7 +450,7 @@ export function renderKitchenSimulator(container) {
466
450
  _context8.prev = 2;
467
451
  case 3:
468
452
  if (!(!destroyed && queue.length)) {
469
- _context8.next = 10;
453
+ _context8.next = 11;
470
454
  break;
471
455
  }
472
456
  if (setExternalEventFn) {
@@ -486,31 +470,29 @@ export function renderKitchenSimulator(container) {
486
470
  pendingMarkers["delete"](item.token);
487
471
  return _context8.abrupt("continue", 3);
488
472
  case 6:
489
- _context8.prev = 6;
490
473
  setExternalEventFn(item);
491
- _context8.next = 7;
474
+ _context8.prev = 7;
475
+ _context8.next = 8;
492
476
  return settle(item);
493
- case 7:
494
- _context8.next = 9;
495
- break;
496
477
  case 8:
497
- _context8.prev = 8;
498
- _t = _context8["catch"](6);
499
- console.error('[kitchen-simulator] event failed:', item, _t);
500
- // IMPORTANT: continue so we can eventually consume the marker
501
- // Optionally you can decide to clear remaining queue here.
478
+ _context8.next = 10;
479
+ break;
502
480
  case 9:
481
+ _context8.prev = 9;
482
+ _t = _context8["catch"](7);
483
+ console.error('settle failed', _t);
484
+ case 10:
503
485
  _context8.next = 3;
504
486
  break;
505
- case 10:
506
- _context8.prev = 10;
507
- draining = false;
508
- return _context8.finish(10);
509
487
  case 11:
488
+ _context8.prev = 11;
489
+ draining = false;
490
+ return _context8.finish(11);
491
+ case 12:
510
492
  case "end":
511
493
  return _context8.stop();
512
494
  }
513
- }, _callee8, null, [[2,, 10, 11], [6, 8]]);
495
+ }, _callee8, null, [[2,, 11, 12], [7, 9]]);
514
496
  }));
515
497
  return _drain.apply(this, arguments);
516
498
  }
@@ -566,9 +548,6 @@ export function renderKitchenSimulator(container) {
566
548
  return gltfTracker.subscribe(cb);
567
549
  },
568
550
  sendExternalEvents: function sendExternalEvents(eventOrEvents) {
569
- var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
570
- _ref5$timeoutMs = _ref5.timeoutMs,
571
- timeoutMs = _ref5$timeoutMs === void 0 ? 60000 : _ref5$timeoutMs;
572
551
  var events = Array.isArray(eventOrEvents) ? eventOrEvents : [eventOrEvents];
573
552
  var _iterator2 = _createForOfIteratorHelper(events),
574
553
  _step2;
@@ -592,47 +571,36 @@ export function renderKitchenSimulator(container) {
592
571
 
593
572
  // resolve when marker cleared
594
573
  return new Promise(function (resolve) {
595
- var start = Date.now();
596
574
  var check = /*#__PURE__*/function () {
597
- var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
575
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
598
576
  return _regeneratorRuntime.wrap(function (_context6) {
599
577
  while (1) switch (_context6.prev = _context6.next) {
600
578
  case 0:
601
579
  if (destroyed) {
602
- _context6.next = 4;
603
- break;
604
- }
605
- if (pendingMarkers.has(token)) {
606
- _context6.next = 1;
580
+ _context6.next = 3;
607
581
  break;
608
582
  }
609
- resolve(true);
610
- return _context6.abrupt("return");
611
- case 1:
612
- if (!(Date.now() - start > timeoutMs)) {
583
+ if (!pendingMarkers.has(token)) {
613
584
  _context6.next = 2;
614
585
  break;
615
586
  }
616
- console.error('[kitchen-simulator] sendExternalEvents timed out');
617
- pendingMarkers["delete"](token); // fail-open
618
- resolve(false);
619
- return _context6.abrupt("return");
620
- case 2:
621
- _context6.next = 3;
587
+ _context6.next = 1;
622
588
  return nextFrame();
589
+ case 1:
590
+ return _context6.abrupt("continue", 0);
591
+ case 2:
592
+ resolve(true);
593
+ return _context6.abrupt("return");
623
594
  case 3:
624
- _context6.next = 0;
625
- break;
626
- case 4:
627
595
  resolve(false);
628
- case 5:
596
+ case 4:
629
597
  case "end":
630
598
  return _context6.stop();
631
599
  }
632
600
  }, _callee6);
633
601
  }));
634
602
  return function check() {
635
- return _ref6.apply(this, arguments);
603
+ return _ref5.apply(this, arguments);
636
604
  };
637
605
  }();
638
606
  check();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "5.10.7-react.18",
3
+ "version": "5.10.8-react.18",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "module": "es/index.js",