kitchen-simulator 5.10.10-react.18 → 5.10.11-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,10 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
43
43
|
var _this;
|
|
44
44
|
_classCallCheck(this, LiteKitchenConfigurator);
|
|
45
45
|
_this = _callSuper(this, LiteKitchenConfigurator, [props]);
|
|
46
|
+
_this._catalogInitRequested = false;
|
|
47
|
+
_this._lastHandledExternalEvent = null;
|
|
48
|
+
_this._handlingExternalEvent = false;
|
|
49
|
+
_this._scheduledExternalEventRaf = null;
|
|
46
50
|
_this.state = {
|
|
47
51
|
savePopupVisible: false,
|
|
48
52
|
quotePopupVisible: false,
|
|
@@ -292,30 +296,86 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
292
296
|
key: "componentDidMount",
|
|
293
297
|
value: function componentDidMount() {
|
|
294
298
|
var _extractedState$getIn;
|
|
295
|
-
window.forRedo = [];
|
|
296
299
|
var _this$props = this.props,
|
|
297
300
|
catalog = _this$props.catalog,
|
|
298
301
|
extractedState = _this$props.extractedState,
|
|
299
302
|
projectActions = _this$props.projectActions;
|
|
300
303
|
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
|
|
304
|
+
if (!catalogReady && !this._catalogInitRequested) {
|
|
305
|
+
this._catalogInitRequested = true;
|
|
306
|
+
console.log('[LiteKitchenConfigurator] initCatalog (mount)');
|
|
307
|
+
projectActions.initCatalog(catalog);
|
|
308
|
+
}
|
|
302
309
|
}
|
|
303
310
|
}, {
|
|
304
311
|
key: "componentDidUpdate",
|
|
305
312
|
value: function componentDidUpdate(prevProps) {
|
|
306
|
-
var
|
|
313
|
+
var _this2 = this,
|
|
314
|
+
_extractedState$getIn2;
|
|
307
315
|
var _this$props2 = this.props,
|
|
308
316
|
externalEvent = _this$props2.externalEvent,
|
|
309
317
|
extractedState = _this$props2.extractedState,
|
|
310
318
|
projectActions = _this$props2.projectActions,
|
|
311
319
|
catalog = _this$props2.catalog;
|
|
312
320
|
|
|
313
|
-
//
|
|
314
|
-
if (prevProps.externalEvent !== externalEvent) {
|
|
315
|
-
|
|
321
|
+
// ---- (A) External event handling (snapshot + defer) ----
|
|
322
|
+
if (prevProps.externalEvent !== externalEvent && externalEvent) {
|
|
323
|
+
if (this._lastHandledExternalEvent === externalEvent) {
|
|
324
|
+
console.warn('[LiteKitchenConfigurator] externalEvent already handled (same ref), skipping');
|
|
325
|
+
} else if (this._handlingExternalEvent) {
|
|
326
|
+
console.warn('[LiteKitchenConfigurator] externalEvent handling already in progress, skipping');
|
|
327
|
+
} else {
|
|
328
|
+
this._lastHandledExternalEvent = externalEvent;
|
|
329
|
+
this._handlingExternalEvent = true;
|
|
330
|
+
|
|
331
|
+
// capture props snapshot corresponding to this event
|
|
332
|
+
var propsSnapshot = this.props;
|
|
333
|
+
var type = (externalEvent === null || externalEvent === void 0 ? void 0 : externalEvent.type) || 'unknown';
|
|
334
|
+
if (this._scheduledExternalEventRaf) {
|
|
335
|
+
cancelAnimationFrame(this._scheduledExternalEventRaf);
|
|
336
|
+
this._scheduledExternalEventRaf = null;
|
|
337
|
+
}
|
|
338
|
+
this._scheduledExternalEventRaf = requestAnimationFrame(function () {
|
|
339
|
+
_this2._scheduledExternalEventRaf = null;
|
|
340
|
+
console.time("[handleExternalEvent] ".concat(type));
|
|
341
|
+
try {
|
|
342
|
+
// IMPORTANT: use snapshot so handler sees matching props
|
|
343
|
+
handleExternalEvent(propsSnapshot);
|
|
344
|
+
} catch (e) {
|
|
345
|
+
console.error('[LiteKitchenConfigurator] handleExternalEvent crashed', e);
|
|
346
|
+
} finally {
|
|
347
|
+
console.timeEnd("[handleExternalEvent] ".concat(type));
|
|
348
|
+
|
|
349
|
+
// clear flag in a macrotask so we definitely yield once
|
|
350
|
+
setTimeout(function () {
|
|
351
|
+
_this2._handlingExternalEvent = false;
|
|
352
|
+
}, 0);
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
}
|
|
316
356
|
}
|
|
357
|
+
|
|
358
|
+
// ---- (B) initCatalog: request once until ready ----
|
|
317
359
|
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 (
|
|
360
|
+
if (catalogReady) {
|
|
361
|
+
if (this._catalogInitRequested) console.log('[LiteKitchenConfigurator] catalog ready');
|
|
362
|
+
this._catalogInitRequested = false;
|
|
363
|
+
} else {
|
|
364
|
+
if (!this._catalogInitRequested) {
|
|
365
|
+
this._catalogInitRequested = true;
|
|
366
|
+
console.log('[LiteKitchenConfigurator] initCatalog (update)');
|
|
367
|
+
projectActions.initCatalog(catalog);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}, {
|
|
372
|
+
key: "componentWillUnmount",
|
|
373
|
+
value: function componentWillUnmount() {
|
|
374
|
+
// cleanup scheduled external event
|
|
375
|
+
if (this._scheduledExternalEventRaf) {
|
|
376
|
+
cancelAnimationFrame(this._scheduledExternalEventRaf);
|
|
377
|
+
this._scheduledExternalEventRaf = null;
|
|
378
|
+
}
|
|
319
379
|
}
|
|
320
380
|
}, {
|
|
321
381
|
key: "isProjectEmpty",
|
|
@@ -365,7 +425,7 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
365
425
|
}, {
|
|
366
426
|
key: "render",
|
|
367
427
|
value: function render() {
|
|
368
|
-
var
|
|
428
|
+
var _this3 = this;
|
|
369
429
|
var _this$props3 = this.props,
|
|
370
430
|
width = _this$props3.width,
|
|
371
431
|
height = _this$props3.height,
|
|
@@ -381,7 +441,7 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
381
441
|
var contentH = height;
|
|
382
442
|
var extracted = this.getExtractedStateWithViewer2DInit(extractedState, width, height);
|
|
383
443
|
var ctxValue = _objectSpread(_objectSpread({}, objectsMap(actions, function (actionNamespace) {
|
|
384
|
-
return
|
|
444
|
+
return _this3.props[actionNamespace];
|
|
385
445
|
})), {}, {
|
|
386
446
|
translator: this.props.translator,
|
|
387
447
|
catalog: this.props.catalog
|