kitchen-simulator 5.10.4-react.18 → 5.10.5-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.
Files changed (2) hide show
  1. package/es/index.js +41 -17
  2. package/package.json +1 -1
package/es/index.js CHANGED
@@ -436,7 +436,7 @@ export function renderKitchenSimulator(container) {
436
436
  }
437
437
  function _drain() {
438
438
  _drain = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
439
- var item;
439
+ var item, _t;
440
440
  return _regeneratorRuntime.wrap(function (_context8) {
441
441
  while (1) switch (_context8.prev = _context8.next) {
442
442
  case 0:
@@ -450,7 +450,7 @@ export function renderKitchenSimulator(container) {
450
450
  _context8.prev = 2;
451
451
  case 3:
452
452
  if (!(!destroyed && queue.length)) {
453
- _context8.next = 8;
453
+ _context8.next = 10;
454
454
  break;
455
455
  }
456
456
  if (setExternalEventFn) {
@@ -470,21 +470,31 @@ export function renderKitchenSimulator(container) {
470
470
  pendingMarkers["delete"](item.token);
471
471
  return _context8.abrupt("continue", 3);
472
472
  case 6:
473
+ _context8.prev = 6;
473
474
  setExternalEventFn(item);
474
475
  _context8.next = 7;
475
476
  return settle(item);
476
477
  case 7:
477
- _context8.next = 3;
478
+ _context8.next = 9;
478
479
  break;
479
480
  case 8:
480
481
  _context8.prev = 8;
481
- draining = false;
482
- return _context8.finish(8);
482
+ _t = _context8["catch"](6);
483
+ console.error('[kitchen-simulator] event failed:', item, _t);
484
+ // IMPORTANT: continue so we can eventually consume the marker
485
+ // Optionally you can decide to clear remaining queue here.
483
486
  case 9:
487
+ _context8.next = 3;
488
+ break;
489
+ case 10:
490
+ _context8.prev = 10;
491
+ draining = false;
492
+ return _context8.finish(10);
493
+ case 11:
484
494
  case "end":
485
495
  return _context8.stop();
486
496
  }
487
- }, _callee8, null, [[2,, 8, 9]]);
497
+ }, _callee8, null, [[2,, 10, 11], [6, 8]]);
488
498
  }));
489
499
  return _drain.apply(this, arguments);
490
500
  }
@@ -540,6 +550,9 @@ export function renderKitchenSimulator(container) {
540
550
  return gltfTracker.subscribe(cb);
541
551
  },
542
552
  sendExternalEvents: function sendExternalEvents(eventOrEvents) {
553
+ var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
554
+ _ref5$timeoutMs = _ref5.timeoutMs,
555
+ timeoutMs = _ref5$timeoutMs === void 0 ? 60000 : _ref5$timeoutMs;
543
556
  var events = Array.isArray(eventOrEvents) ? eventOrEvents : [eventOrEvents];
544
557
  var _iterator2 = _createForOfIteratorHelper(events),
545
558
  _step2;
@@ -563,36 +576,47 @@ export function renderKitchenSimulator(container) {
563
576
 
564
577
  // resolve when marker cleared
565
578
  return new Promise(function (resolve) {
579
+ var start = Date.now();
566
580
  var check = /*#__PURE__*/function () {
567
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
581
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
568
582
  return _regeneratorRuntime.wrap(function (_context6) {
569
583
  while (1) switch (_context6.prev = _context6.next) {
570
584
  case 0:
571
585
  if (destroyed) {
572
- _context6.next = 3;
586
+ _context6.next = 4;
573
587
  break;
574
588
  }
575
- if (!pendingMarkers.has(token)) {
576
- _context6.next = 2;
589
+ if (pendingMarkers.has(token)) {
590
+ _context6.next = 1;
577
591
  break;
578
592
  }
579
- _context6.next = 1;
580
- return nextFrame();
581
- case 1:
582
- return _context6.abrupt("continue", 0);
583
- case 2:
584
593
  resolve(true);
585
594
  return _context6.abrupt("return");
586
- case 3:
595
+ case 1:
596
+ if (!(Date.now() - start > timeoutMs)) {
597
+ _context6.next = 2;
598
+ break;
599
+ }
600
+ console.error('[kitchen-simulator] sendExternalEvents timed out');
601
+ pendingMarkers["delete"](token); // fail-open
587
602
  resolve(false);
603
+ return _context6.abrupt("return");
604
+ case 2:
605
+ _context6.next = 3;
606
+ return nextFrame();
607
+ case 3:
608
+ _context6.next = 0;
609
+ break;
588
610
  case 4:
611
+ resolve(false);
612
+ case 5:
589
613
  case "end":
590
614
  return _context6.stop();
591
615
  }
592
616
  }, _callee6);
593
617
  }));
594
618
  return function check() {
595
- return _ref5.apply(this, arguments);
619
+ return _ref6.apply(this, arguments);
596
620
  };
597
621
  }();
598
622
  check();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "5.10.4-react.18",
3
+ "version": "5.10.5-react.18",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "module": "es/index.js",