kitchen-simulator 3.1.0-alpha.14 → 3.1.0-alpha.15
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/LiteKitchenConfigurator.js +14 -30
- package/es/index.js +17 -6
- package/lib/LiteKitchenConfigurator.js +14 -30
- package/lib/index.js +17 -6
- package/package.json +1 -1
|
@@ -331,38 +331,22 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
331
331
|
}, {
|
|
332
332
|
key: "componentDidUpdate",
|
|
333
333
|
value: function componentDidUpdate(prevProps) {
|
|
334
|
-
var _this3 = this;
|
|
335
334
|
var ev = this.props.externalEvent;
|
|
336
|
-
|
|
337
|
-
// nothing new
|
|
338
335
|
if (!ev || ev === prevProps.externalEvent) return;
|
|
339
|
-
|
|
340
|
-
// must have id to ack
|
|
341
336
|
var eventId = ev.__eventId;
|
|
342
337
|
if (eventId == null) return;
|
|
343
|
-
|
|
344
|
-
// exactly-once guard
|
|
345
338
|
if (this.lastProcessedExternalEventId === eventId) return;
|
|
346
339
|
this.lastProcessedExternalEventId = eventId;
|
|
340
|
+
console.log('[Tool] got external', eventId, ev.type, !!this.props.onExternalEventProcessed);
|
|
347
341
|
try {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
// if it returns a promise, ack after it resolves/rejects
|
|
351
|
-
if (result && typeof result.then === 'function') {
|
|
352
|
-
result["finally"](function () {
|
|
353
|
-
var _this3$props$onExtern, _this3$props;
|
|
354
|
-
(_this3$props$onExtern = (_this3$props = _this3.props).onExternalEventProcessed) === null || _this3$props$onExtern === void 0 || _this3$props$onExtern.call(_this3$props, eventId);
|
|
355
|
-
});
|
|
356
|
-
} else {
|
|
357
|
-
var _this$props$onExterna, _this$props2;
|
|
358
|
-
// sync case
|
|
359
|
-
(_this$props$onExterna = (_this$props2 = this.props).onExternalEventProcessed) === null || _this$props$onExterna === void 0 || _this$props$onExterna.call(_this$props2, eventId);
|
|
360
|
-
}
|
|
342
|
+
handleExternalEvent(this.props);
|
|
361
343
|
} catch (e) {
|
|
362
|
-
|
|
363
|
-
// never deadlock the host queue
|
|
364
|
-
(_this$props$onExterna2 = (_this$props3 = this.props).onExternalEventProcessed) === null || _this$props$onExterna2 === void 0 || _this$props$onExterna2.call(_this$props3, eventId);
|
|
344
|
+
console.error('[Tool] handleExternalEvent crashed', e);
|
|
365
345
|
throw e;
|
|
346
|
+
} finally {
|
|
347
|
+
var _this$props$onExterna, _this$props2;
|
|
348
|
+
(_this$props$onExterna = (_this$props2 = this.props).onExternalEventProcessed) === null || _this$props$onExterna === void 0 || _this$props$onExterna.call(_this$props2, eventId);
|
|
349
|
+
console.log('[Tool] ack external', eventId);
|
|
366
350
|
}
|
|
367
351
|
}
|
|
368
352
|
}, {
|
|
@@ -376,13 +360,13 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
376
360
|
}, {
|
|
377
361
|
key: "render",
|
|
378
362
|
value: function render() {
|
|
379
|
-
var _this$
|
|
380
|
-
width = _this$
|
|
381
|
-
height = _this$
|
|
382
|
-
state = _this$
|
|
383
|
-
stateExtractor = _this$
|
|
384
|
-
measurementUnit = _this$
|
|
385
|
-
props = _objectWithoutProperties(_this$
|
|
363
|
+
var _this$props3 = this.props,
|
|
364
|
+
width = _this$props3.width,
|
|
365
|
+
height = _this$props3.height,
|
|
366
|
+
state = _this$props3.state,
|
|
367
|
+
stateExtractor = _this$props3.stateExtractor,
|
|
368
|
+
measurementUnit = _this$props3.measurementUnit,
|
|
369
|
+
props = _objectWithoutProperties(_this$props3, _excluded);
|
|
386
370
|
var _this$state = this.state,
|
|
387
371
|
savePopupVisible = _this$state.savePopupVisible,
|
|
388
372
|
quotePopupVisible = _this$state.quotePopupVisible,
|
package/es/index.js
CHANGED
|
@@ -62,14 +62,9 @@ export function renderKitchenSimulator(container) {
|
|
|
62
62
|
var promise = new Promise(function (res) {
|
|
63
63
|
return _resolve = res;
|
|
64
64
|
});
|
|
65
|
-
|
|
66
|
-
// failsafe: resolve after X ms no matter what (avoid host deadlock)
|
|
67
65
|
var timeoutMs = (_ev$waitForAckMs = ev === null || ev === void 0 ? void 0 : ev.waitForAckMs) !== null && _ev$waitForAckMs !== void 0 ? _ev$waitForAckMs : 15000;
|
|
68
66
|
var t = setTimeout(function () {
|
|
69
|
-
|
|
70
|
-
console.warn('External event ack timeout', id, ev);
|
|
71
|
-
_this3.onExternalEventProcessed(id); // force-drain
|
|
72
|
-
}
|
|
67
|
+
_this3.forceComplete(id, 'ack-timeout');
|
|
73
68
|
}, timeoutMs);
|
|
74
69
|
this.queue.push({
|
|
75
70
|
id: id,
|
|
@@ -109,6 +104,22 @@ export function renderKitchenSimulator(container) {
|
|
|
109
104
|
});
|
|
110
105
|
});
|
|
111
106
|
}
|
|
107
|
+
}, {
|
|
108
|
+
key: "forceComplete",
|
|
109
|
+
value: function forceComplete(id, reason) {
|
|
110
|
+
// only force-complete if this is still the in-flight event
|
|
111
|
+
if (this._currentId !== id) return;
|
|
112
|
+
console.warn('[Tool] force complete external event', id, reason);
|
|
113
|
+
try {
|
|
114
|
+
var _this$_currentResolve2;
|
|
115
|
+
(_this$_currentResolve2 = this._currentResolve) === null || _this$_currentResolve2 === void 0 || _this$_currentResolve2.call(this);
|
|
116
|
+
} finally {
|
|
117
|
+
this._currentResolve = null;
|
|
118
|
+
this._currentId = null;
|
|
119
|
+
this.processing = false;
|
|
120
|
+
this.processNext();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
112
123
|
}, {
|
|
113
124
|
key: "render",
|
|
114
125
|
value: function render() {
|
|
@@ -340,38 +340,22 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
340
340
|
}, {
|
|
341
341
|
key: "componentDidUpdate",
|
|
342
342
|
value: function componentDidUpdate(prevProps) {
|
|
343
|
-
var _this3 = this;
|
|
344
343
|
var ev = this.props.externalEvent;
|
|
345
|
-
|
|
346
|
-
// nothing new
|
|
347
344
|
if (!ev || ev === prevProps.externalEvent) return;
|
|
348
|
-
|
|
349
|
-
// must have id to ack
|
|
350
345
|
var eventId = ev.__eventId;
|
|
351
346
|
if (eventId == null) return;
|
|
352
|
-
|
|
353
|
-
// exactly-once guard
|
|
354
347
|
if (this.lastProcessedExternalEventId === eventId) return;
|
|
355
348
|
this.lastProcessedExternalEventId = eventId;
|
|
349
|
+
console.log('[Tool] got external', eventId, ev.type, !!this.props.onExternalEventProcessed);
|
|
356
350
|
try {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
// if it returns a promise, ack after it resolves/rejects
|
|
360
|
-
if (result && typeof result.then === 'function') {
|
|
361
|
-
result["finally"](function () {
|
|
362
|
-
var _this3$props$onExtern, _this3$props;
|
|
363
|
-
(_this3$props$onExtern = (_this3$props = _this3.props).onExternalEventProcessed) === null || _this3$props$onExtern === void 0 || _this3$props$onExtern.call(_this3$props, eventId);
|
|
364
|
-
});
|
|
365
|
-
} else {
|
|
366
|
-
var _this$props$onExterna, _this$props2;
|
|
367
|
-
// sync case
|
|
368
|
-
(_this$props$onExterna = (_this$props2 = this.props).onExternalEventProcessed) === null || _this$props$onExterna === void 0 || _this$props$onExterna.call(_this$props2, eventId);
|
|
369
|
-
}
|
|
351
|
+
(0, _isolateEventHandler.handleExternalEvent)(this.props);
|
|
370
352
|
} catch (e) {
|
|
371
|
-
|
|
372
|
-
// never deadlock the host queue
|
|
373
|
-
(_this$props$onExterna2 = (_this$props3 = this.props).onExternalEventProcessed) === null || _this$props$onExterna2 === void 0 || _this$props$onExterna2.call(_this$props3, eventId);
|
|
353
|
+
console.error('[Tool] handleExternalEvent crashed', e);
|
|
374
354
|
throw e;
|
|
355
|
+
} finally {
|
|
356
|
+
var _this$props$onExterna, _this$props2;
|
|
357
|
+
(_this$props$onExterna = (_this$props2 = this.props).onExternalEventProcessed) === null || _this$props$onExterna === void 0 || _this$props$onExterna.call(_this$props2, eventId);
|
|
358
|
+
console.log('[Tool] ack external', eventId);
|
|
375
359
|
}
|
|
376
360
|
}
|
|
377
361
|
}, {
|
|
@@ -385,13 +369,13 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
385
369
|
}, {
|
|
386
370
|
key: "render",
|
|
387
371
|
value: function render() {
|
|
388
|
-
var _this$
|
|
389
|
-
width = _this$
|
|
390
|
-
height = _this$
|
|
391
|
-
state = _this$
|
|
392
|
-
stateExtractor = _this$
|
|
393
|
-
measurementUnit = _this$
|
|
394
|
-
props = (0, _objectWithoutProperties2["default"])(_this$
|
|
372
|
+
var _this$props3 = this.props,
|
|
373
|
+
width = _this$props3.width,
|
|
374
|
+
height = _this$props3.height,
|
|
375
|
+
state = _this$props3.state,
|
|
376
|
+
stateExtractor = _this$props3.stateExtractor,
|
|
377
|
+
measurementUnit = _this$props3.measurementUnit,
|
|
378
|
+
props = (0, _objectWithoutProperties2["default"])(_this$props3, _excluded);
|
|
395
379
|
var _this$state = this.state,
|
|
396
380
|
savePopupVisible = _this$state.savePopupVisible,
|
|
397
381
|
quotePopupVisible = _this$state.quotePopupVisible,
|
package/lib/index.js
CHANGED
|
@@ -70,14 +70,9 @@ function renderKitchenSimulator(container) {
|
|
|
70
70
|
var promise = new Promise(function (res) {
|
|
71
71
|
return _resolve = res;
|
|
72
72
|
});
|
|
73
|
-
|
|
74
|
-
// failsafe: resolve after X ms no matter what (avoid host deadlock)
|
|
75
73
|
var timeoutMs = (_ev$waitForAckMs = ev === null || ev === void 0 ? void 0 : ev.waitForAckMs) !== null && _ev$waitForAckMs !== void 0 ? _ev$waitForAckMs : 15000;
|
|
76
74
|
var t = setTimeout(function () {
|
|
77
|
-
|
|
78
|
-
console.warn('External event ack timeout', id, ev);
|
|
79
|
-
_this3.onExternalEventProcessed(id); // force-drain
|
|
80
|
-
}
|
|
75
|
+
_this3.forceComplete(id, 'ack-timeout');
|
|
81
76
|
}, timeoutMs);
|
|
82
77
|
this.queue.push({
|
|
83
78
|
id: id,
|
|
@@ -117,6 +112,22 @@ function renderKitchenSimulator(container) {
|
|
|
117
112
|
});
|
|
118
113
|
});
|
|
119
114
|
}
|
|
115
|
+
}, {
|
|
116
|
+
key: "forceComplete",
|
|
117
|
+
value: function forceComplete(id, reason) {
|
|
118
|
+
// only force-complete if this is still the in-flight event
|
|
119
|
+
if (this._currentId !== id) return;
|
|
120
|
+
console.warn('[Tool] force complete external event', id, reason);
|
|
121
|
+
try {
|
|
122
|
+
var _this$_currentResolve2;
|
|
123
|
+
(_this$_currentResolve2 = this._currentResolve) === null || _this$_currentResolve2 === void 0 || _this$_currentResolve2.call(this);
|
|
124
|
+
} finally {
|
|
125
|
+
this._currentResolve = null;
|
|
126
|
+
this._currentId = null;
|
|
127
|
+
this.processing = false;
|
|
128
|
+
this.processNext();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
120
131
|
}, {
|
|
121
132
|
key: "render",
|
|
122
133
|
value: function render() {
|