kitchen-simulator 7.0.0-react-18 → 7.0.1-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 +16 -19
- package/package.json +1 -1
package/es/index.js
CHANGED
|
@@ -374,6 +374,10 @@ export function renderKitchenSimulator(container) {
|
|
|
374
374
|
}
|
|
375
375
|
var setExternalEventFn = null;
|
|
376
376
|
var destroyed = false;
|
|
377
|
+
var resolveReady = null;
|
|
378
|
+
var readyPromise = new Promise(function (res) {
|
|
379
|
+
return resolveReady = res;
|
|
380
|
+
});
|
|
377
381
|
var queue = [];
|
|
378
382
|
var pendingMarkers = new Set();
|
|
379
383
|
var MARKER = Symbol('marker');
|
|
@@ -529,7 +533,8 @@ export function renderKitchenSimulator(container) {
|
|
|
529
533
|
return _createClass(Wrapper, [{
|
|
530
534
|
key: "componentDidMount",
|
|
531
535
|
value: function componentDidMount() {
|
|
532
|
-
var _this3 = this
|
|
536
|
+
var _this3 = this,
|
|
537
|
+
_resolveReady;
|
|
533
538
|
this._mounted = true;
|
|
534
539
|
setExternalEventFn = function setExternalEventFn(newEvent) {
|
|
535
540
|
if (!_this3._mounted) return;
|
|
@@ -537,6 +542,9 @@ export function renderKitchenSimulator(container) {
|
|
|
537
542
|
externalEvent: newEvent
|
|
538
543
|
});
|
|
539
544
|
};
|
|
545
|
+
(_resolveReady = resolveReady) === null || _resolveReady === void 0 || _resolveReady();
|
|
546
|
+
resolveReady = null;
|
|
547
|
+
drain(); // now it can actually process queued events
|
|
540
548
|
}
|
|
541
549
|
}, {
|
|
542
550
|
key: "componentWillUnmount",
|
|
@@ -557,6 +565,9 @@ export function renderKitchenSimulator(container) {
|
|
|
557
565
|
__render: function __render(nextProps) {
|
|
558
566
|
root.render(/*#__PURE__*/React.createElement(Wrapper, nextProps));
|
|
559
567
|
},
|
|
568
|
+
whenReady: function whenReady() {
|
|
569
|
+
return readyPromise;
|
|
570
|
+
},
|
|
560
571
|
// ✅ host can query current inFlight
|
|
561
572
|
getGltfInFlight: function getGltfInFlight() {
|
|
562
573
|
return gltfTracker.getInFlight();
|
|
@@ -565,23 +576,6 @@ export function renderKitchenSimulator(container) {
|
|
|
565
576
|
subscribeGltfInFlight: function subscribeGltfInFlight(cb) {
|
|
566
577
|
return gltfTracker.subscribe(cb);
|
|
567
578
|
},
|
|
568
|
-
setExternalEventImmediate: function setExternalEventImmediate(event) {
|
|
569
|
-
// If Wrapper is mounted, bypass queue/drain and push straight into state
|
|
570
|
-
if (setExternalEventFn) {
|
|
571
|
-
try {
|
|
572
|
-
setExternalEventFn(event);
|
|
573
|
-
return true; // applied immediately
|
|
574
|
-
} catch (e) {
|
|
575
|
-
console.error('[kitchen-simulator] setExternalEventImmediate failed', e);
|
|
576
|
-
// fall through to queue
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
// Wrapper not ready yet: make it the NEXT thing processed
|
|
581
|
-
queue.unshift(event);
|
|
582
|
-
drain();
|
|
583
|
-
return false; // queued (not immediate)
|
|
584
|
-
},
|
|
585
579
|
sendExternalEvents: function sendExternalEvents(eventOrEvents) {
|
|
586
580
|
var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
587
581
|
_ref5$timeoutMs = _ref5.timeoutMs,
|
|
@@ -605,7 +599,7 @@ export function renderKitchenSimulator(container) {
|
|
|
605
599
|
__marker: MARKER,
|
|
606
600
|
token: token
|
|
607
601
|
});
|
|
608
|
-
drain();
|
|
602
|
+
if (setExternalEventFn) drain();
|
|
609
603
|
|
|
610
604
|
// resolve when marker cleared
|
|
611
605
|
return new Promise(function (resolve) {
|
|
@@ -663,9 +657,12 @@ export function renderKitchenSimulator(container) {
|
|
|
663
657
|
pendingMarkers.clear();
|
|
664
658
|
},
|
|
665
659
|
unmount: function unmount() {
|
|
660
|
+
var _resolveReady2;
|
|
666
661
|
destroyed = true;
|
|
667
662
|
api.clearQueue();
|
|
668
663
|
gltfTracker.uninstall();
|
|
664
|
+
(_resolveReady2 = resolveReady) === null || _resolveReady2 === void 0 || _resolveReady2();
|
|
665
|
+
resolveReady = null;
|
|
669
666
|
var doUnmount = function doUnmount() {
|
|
670
667
|
try {
|
|
671
668
|
root.unmount();
|