kitchen-simulator 5.10.4-react.18 → 5.10.6-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.
- package/es/index.js +76 -36
- package/package.json +1 -1
package/es/index.js
CHANGED
|
@@ -140,8 +140,14 @@ 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);
|
|
143
146
|
};
|
|
144
147
|
this.addEventListener('loadend', _done);
|
|
148
|
+
this.addEventListener('error', _done);
|
|
149
|
+
this.addEventListener('abort', _done);
|
|
150
|
+
this.addEventListener('timeout', _done);
|
|
145
151
|
}
|
|
146
152
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
147
153
|
args[_key2] = arguments[_key2];
|
|
@@ -240,13 +246,11 @@ function installGltfTracker() {
|
|
|
240
246
|
var _ref3,
|
|
241
247
|
_ref3$timeoutMs,
|
|
242
248
|
timeoutMs,
|
|
243
|
-
start,
|
|
244
249
|
_args4 = arguments;
|
|
245
250
|
return _regeneratorRuntime.wrap(function (_context4) {
|
|
246
251
|
while (1) switch (_context4.prev = _context4.next) {
|
|
247
252
|
case 0:
|
|
248
253
|
_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();
|
|
250
254
|
_context4.next = 1;
|
|
251
255
|
return waitStableIdle2Frames();
|
|
252
256
|
case 1:
|
|
@@ -258,38 +262,50 @@ function installGltfTracker() {
|
|
|
258
262
|
case 2:
|
|
259
263
|
return _context4.abrupt("return", new Promise(function (resolve, reject) {
|
|
260
264
|
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);
|
|
261
285
|
var onChange = /*#__PURE__*/function () {
|
|
262
286
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(count) {
|
|
263
287
|
var stable;
|
|
264
288
|
return _regeneratorRuntime.wrap(function (_context3) {
|
|
265
289
|
while (1) switch (_context3.prev = _context3.next) {
|
|
266
290
|
case 0:
|
|
267
|
-
if (!
|
|
291
|
+
if (!finished) {
|
|
268
292
|
_context3.next = 1;
|
|
269
293
|
break;
|
|
270
294
|
}
|
|
271
|
-
if (Date.now() - start > timeoutMs) {
|
|
272
|
-
if (unsub) unsub();
|
|
273
|
-
reject(new Error('3D assets did not become idle within timeout'));
|
|
274
|
-
}
|
|
275
295
|
return _context3.abrupt("return");
|
|
276
296
|
case 1:
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
case 2:
|
|
280
|
-
stable = _context3.sent;
|
|
281
|
-
if (!stable) {
|
|
282
|
-
_context3.next = 3;
|
|
297
|
+
if (!(count !== 0)) {
|
|
298
|
+
_context3.next = 2;
|
|
283
299
|
break;
|
|
284
300
|
}
|
|
285
|
-
if (unsub) unsub();
|
|
286
|
-
resolve(true);
|
|
287
301
|
return _context3.abrupt("return");
|
|
302
|
+
case 2:
|
|
303
|
+
_context3.next = 3;
|
|
304
|
+
return waitStableIdle2Frames();
|
|
288
305
|
case 3:
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
}
|
|
306
|
+
stable = _context3.sent;
|
|
307
|
+
if (stable) finishOk();
|
|
308
|
+
// else keep waiting
|
|
293
309
|
case 4:
|
|
294
310
|
case "end":
|
|
295
311
|
return _context3.stop();
|
|
@@ -436,7 +452,7 @@ export function renderKitchenSimulator(container) {
|
|
|
436
452
|
}
|
|
437
453
|
function _drain() {
|
|
438
454
|
_drain = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
439
|
-
var item;
|
|
455
|
+
var item, _t;
|
|
440
456
|
return _regeneratorRuntime.wrap(function (_context8) {
|
|
441
457
|
while (1) switch (_context8.prev = _context8.next) {
|
|
442
458
|
case 0:
|
|
@@ -450,7 +466,7 @@ export function renderKitchenSimulator(container) {
|
|
|
450
466
|
_context8.prev = 2;
|
|
451
467
|
case 3:
|
|
452
468
|
if (!(!destroyed && queue.length)) {
|
|
453
|
-
_context8.next =
|
|
469
|
+
_context8.next = 10;
|
|
454
470
|
break;
|
|
455
471
|
}
|
|
456
472
|
if (setExternalEventFn) {
|
|
@@ -470,21 +486,31 @@ export function renderKitchenSimulator(container) {
|
|
|
470
486
|
pendingMarkers["delete"](item.token);
|
|
471
487
|
return _context8.abrupt("continue", 3);
|
|
472
488
|
case 6:
|
|
489
|
+
_context8.prev = 6;
|
|
473
490
|
setExternalEventFn(item);
|
|
474
491
|
_context8.next = 7;
|
|
475
492
|
return settle(item);
|
|
476
493
|
case 7:
|
|
477
|
-
_context8.next =
|
|
494
|
+
_context8.next = 9;
|
|
478
495
|
break;
|
|
479
496
|
case 8:
|
|
480
497
|
_context8.prev = 8;
|
|
481
|
-
|
|
482
|
-
|
|
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.
|
|
483
502
|
case 9:
|
|
503
|
+
_context8.next = 3;
|
|
504
|
+
break;
|
|
505
|
+
case 10:
|
|
506
|
+
_context8.prev = 10;
|
|
507
|
+
draining = false;
|
|
508
|
+
return _context8.finish(10);
|
|
509
|
+
case 11:
|
|
484
510
|
case "end":
|
|
485
511
|
return _context8.stop();
|
|
486
512
|
}
|
|
487
|
-
}, _callee8, null, [[2,,
|
|
513
|
+
}, _callee8, null, [[2,, 10, 11], [6, 8]]);
|
|
488
514
|
}));
|
|
489
515
|
return _drain.apply(this, arguments);
|
|
490
516
|
}
|
|
@@ -540,6 +566,9 @@ export function renderKitchenSimulator(container) {
|
|
|
540
566
|
return gltfTracker.subscribe(cb);
|
|
541
567
|
},
|
|
542
568
|
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;
|
|
543
572
|
var events = Array.isArray(eventOrEvents) ? eventOrEvents : [eventOrEvents];
|
|
544
573
|
var _iterator2 = _createForOfIteratorHelper(events),
|
|
545
574
|
_step2;
|
|
@@ -563,36 +592,47 @@ export function renderKitchenSimulator(container) {
|
|
|
563
592
|
|
|
564
593
|
// resolve when marker cleared
|
|
565
594
|
return new Promise(function (resolve) {
|
|
595
|
+
var start = Date.now();
|
|
566
596
|
var check = /*#__PURE__*/function () {
|
|
567
|
-
var
|
|
597
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
568
598
|
return _regeneratorRuntime.wrap(function (_context6) {
|
|
569
599
|
while (1) switch (_context6.prev = _context6.next) {
|
|
570
600
|
case 0:
|
|
571
601
|
if (destroyed) {
|
|
572
|
-
_context6.next =
|
|
602
|
+
_context6.next = 4;
|
|
573
603
|
break;
|
|
574
604
|
}
|
|
575
|
-
if (
|
|
576
|
-
_context6.next =
|
|
605
|
+
if (pendingMarkers.has(token)) {
|
|
606
|
+
_context6.next = 1;
|
|
577
607
|
break;
|
|
578
608
|
}
|
|
579
|
-
_context6.next = 1;
|
|
580
|
-
return nextFrame();
|
|
581
|
-
case 1:
|
|
582
|
-
return _context6.abrupt("continue", 0);
|
|
583
|
-
case 2:
|
|
584
609
|
resolve(true);
|
|
585
610
|
return _context6.abrupt("return");
|
|
586
|
-
case
|
|
611
|
+
case 1:
|
|
612
|
+
if (!(Date.now() - start > timeoutMs)) {
|
|
613
|
+
_context6.next = 2;
|
|
614
|
+
break;
|
|
615
|
+
}
|
|
616
|
+
console.error('[kitchen-simulator] sendExternalEvents timed out');
|
|
617
|
+
pendingMarkers["delete"](token); // fail-open
|
|
587
618
|
resolve(false);
|
|
619
|
+
return _context6.abrupt("return");
|
|
620
|
+
case 2:
|
|
621
|
+
_context6.next = 3;
|
|
622
|
+
return nextFrame();
|
|
623
|
+
case 3:
|
|
624
|
+
_context6.next = 0;
|
|
625
|
+
break;
|
|
588
626
|
case 4:
|
|
627
|
+
resolve(false);
|
|
628
|
+
case 5:
|
|
589
629
|
case "end":
|
|
590
630
|
return _context6.stop();
|
|
591
631
|
}
|
|
592
632
|
}, _callee6);
|
|
593
633
|
}));
|
|
594
634
|
return function check() {
|
|
595
|
-
return
|
|
635
|
+
return _ref6.apply(this, arguments);
|
|
596
636
|
};
|
|
597
637
|
}();
|
|
598
638
|
check();
|