kitchen-simulator 5.10.13-react.18 → 6.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/LiteKitchenConfigurator.js +31 -81
- package/es/index.js +244 -769
- package/package.json +1 -1
|
@@ -43,10 +43,6 @@ 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;
|
|
50
46
|
_this.state = {
|
|
51
47
|
savePopupVisible: false,
|
|
52
48
|
quotePopupVisible: false,
|
|
@@ -79,6 +75,7 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
79
75
|
isSaved: false,
|
|
80
76
|
isLeaving: false
|
|
81
77
|
};
|
|
78
|
+
_this._catalogInitRequested = false;
|
|
82
79
|
_this.openFloor = _this.openFloor.bind(_this);
|
|
83
80
|
_this.openCabinet = _this.openCabinet.bind(_this);
|
|
84
81
|
_this.openFinishing = _this.openFinishing.bind(_this);
|
|
@@ -296,6 +293,7 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
296
293
|
key: "componentDidMount",
|
|
297
294
|
value: function componentDidMount() {
|
|
298
295
|
var _extractedState$getIn;
|
|
296
|
+
window.forRedo = [];
|
|
299
297
|
var _this$props = this.props,
|
|
300
298
|
catalog = _this$props.catalog,
|
|
301
299
|
extractedState = _this$props.extractedState,
|
|
@@ -303,86 +301,29 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
303
301
|
var catalogReady = extractedState === null || extractedState === void 0 || (_extractedState$getIn = extractedState.getIn) === null || _extractedState$getIn === void 0 ? void 0 : _extractedState$getIn.call(extractedState, ['catalog', 'ready']);
|
|
304
302
|
if (!catalogReady && !this._catalogInitRequested) {
|
|
305
303
|
this._catalogInitRequested = true;
|
|
306
|
-
console.log('[LiteKitchenConfigurator] initCatalog (mount)');
|
|
307
304
|
projectActions.initCatalog(catalog);
|
|
308
305
|
}
|
|
309
306
|
}
|
|
310
307
|
}, {
|
|
311
308
|
key: "componentDidUpdate",
|
|
312
309
|
value: function componentDidUpdate(prevProps) {
|
|
313
|
-
var _extractedState$getIn2
|
|
314
|
-
_this2 = this,
|
|
315
|
-
_extractedState$getIn3;
|
|
310
|
+
var _extractedState$getIn2;
|
|
316
311
|
var _this$props2 = this.props,
|
|
317
312
|
externalEvent = _this$props2.externalEvent,
|
|
318
313
|
extractedState = _this$props2.extractedState,
|
|
319
314
|
projectActions = _this$props2.projectActions,
|
|
320
315
|
catalog = _this$props2.catalog;
|
|
321
|
-
var viewer2D = extractedState === null || extractedState === void 0 || (_extractedState$getIn2 = extractedState.getIn) === null || _extractedState$getIn2 === void 0 ? void 0 : _extractedState$getIn2.call(extractedState, ['viewer2D']);
|
|
322
|
-
if (viewer2D) {
|
|
323
|
-
var v = viewer2D.toJS();
|
|
324
|
-
if (v.e === 0 && v.f === 0) {
|
|
325
|
-
projectActions.updateViewer2D({
|
|
326
|
-
e: v.viewerWidth / 2 - v.SVGWidth / 2,
|
|
327
|
-
f: v.viewerHeight / 2 - v.SVGHeight / 2,
|
|
328
|
-
a: 0.99,
|
|
329
|
-
d: 0.99
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
316
|
|
|
334
|
-
//
|
|
317
|
+
// handle external event when it changes
|
|
335
318
|
if (prevProps.externalEvent !== externalEvent && externalEvent) {
|
|
336
|
-
|
|
337
|
-
console.warn('[LiteKitchenConfigurator] externalEvent already handled (same ref), skipping');
|
|
338
|
-
} else if (this._handlingExternalEvent) {
|
|
339
|
-
console.warn('[LiteKitchenConfigurator] externalEvent handling already in progress, skipping');
|
|
340
|
-
} else {
|
|
341
|
-
this._lastHandledExternalEvent = externalEvent;
|
|
342
|
-
this._handlingExternalEvent = true;
|
|
343
|
-
|
|
344
|
-
// capture props snapshot corresponding to this event
|
|
345
|
-
var propsSnapshot = this.props;
|
|
346
|
-
var type = (externalEvent === null || externalEvent === void 0 ? void 0 : externalEvent.type) || 'unknown';
|
|
347
|
-
if (this._scheduledExternalEventRaf) {
|
|
348
|
-
clearTimeout(this._scheduledExternalEventRaf);
|
|
349
|
-
this._scheduledExternalEventRaf = null;
|
|
350
|
-
}
|
|
351
|
-
this._scheduledExternalEventRaf = setTimeout(function () {
|
|
352
|
-
_this2._scheduledExternalEventRaf = null;
|
|
353
|
-
console.time("[handleExternalEvent] ".concat(type));
|
|
354
|
-
try {
|
|
355
|
-
handleExternalEvent(propsSnapshot);
|
|
356
|
-
} catch (e) {
|
|
357
|
-
console.error('[LiteKitchenConfigurator] handleExternalEvent crashed', e);
|
|
358
|
-
} finally {
|
|
359
|
-
console.timeEnd("[handleExternalEvent] ".concat(type));
|
|
360
|
-
_this2._handlingExternalEvent = false;
|
|
361
|
-
}
|
|
362
|
-
}, 0);
|
|
363
|
-
}
|
|
319
|
+
handleExternalEvent(this.props);
|
|
364
320
|
}
|
|
365
|
-
|
|
366
|
-
// ---- (B) initCatalog: request once until ready ----
|
|
367
|
-
var catalogReady = extractedState === null || extractedState === void 0 || (_extractedState$getIn3 = extractedState.getIn) === null || _extractedState$getIn3 === void 0 ? void 0 : _extractedState$getIn3.call(extractedState, ['catalog', 'ready']);
|
|
321
|
+
var catalogReady = extractedState === null || extractedState === void 0 || (_extractedState$getIn2 = extractedState.getIn) === null || _extractedState$getIn2 === void 0 ? void 0 : _extractedState$getIn2.call(extractedState, ['catalog', 'ready']);
|
|
368
322
|
if (catalogReady) {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
this._catalogInitRequested = true;
|
|
374
|
-
console.log('[LiteKitchenConfigurator] initCatalog (update)');
|
|
375
|
-
projectActions.initCatalog(catalog);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}, {
|
|
380
|
-
key: "componentWillUnmount",
|
|
381
|
-
value: function componentWillUnmount() {
|
|
382
|
-
// cleanup scheduled external event
|
|
383
|
-
if (this._scheduledExternalEventRaf) {
|
|
384
|
-
cancelAnimationFrame(this._scheduledExternalEventRaf);
|
|
385
|
-
this._scheduledExternalEventRaf = null;
|
|
323
|
+
this._catalogInitRequested = false; // allow re-init if state resets later
|
|
324
|
+
} else if (!this._catalogInitRequested) {
|
|
325
|
+
this._catalogInitRequested = true;
|
|
326
|
+
projectActions.initCatalog(catalog);
|
|
386
327
|
}
|
|
387
328
|
}
|
|
388
329
|
}, {
|
|
@@ -406,25 +347,34 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
406
347
|
}
|
|
407
348
|
var _viewer2D = extractedState.getIn(['viewer2D']);
|
|
408
349
|
if (!_viewer2D || _viewer2D.size <= 0) return extractedState;
|
|
409
|
-
var
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
var cacheKey = "".concat(width, ":").concat(height, ":").concat(
|
|
350
|
+
var e = _viewer2D.get('e');
|
|
351
|
+
var f = _viewer2D.get('f');
|
|
352
|
+
if (e !== 0 || f !== 0) return extractedState;
|
|
353
|
+
var viewerWidth = _viewer2D.get('viewerWidth');
|
|
354
|
+
var viewerHeight = _viewer2D.get('viewerHeight');
|
|
355
|
+
var SVGWidth = _viewer2D.get('SVGWidth');
|
|
356
|
+
var SVGHeight = _viewer2D.get('SVGHeight');
|
|
357
|
+
var cacheKey = "".concat(width, ":").concat(height, ":").concat(viewerWidth, ":").concat(viewerHeight, ":").concat(SVGWidth, ":").concat(SVGHeight);
|
|
417
358
|
if (this._cachedViewer2DKey === cacheKey && this._cachedExtractedState) {
|
|
418
359
|
return this._cachedExtractedState;
|
|
419
360
|
}
|
|
361
|
+
var centeredViewer2D = _viewer2D.merge({
|
|
362
|
+
e: viewerWidth / 2 - SVGWidth / 2,
|
|
363
|
+
f: viewerHeight / 2 - SVGHeight / 2,
|
|
364
|
+
a: 0.99,
|
|
365
|
+
d: 0.99
|
|
366
|
+
});
|
|
367
|
+
var merged = extractedState.merge({
|
|
368
|
+
viewer2D: centeredViewer2D
|
|
369
|
+
});
|
|
420
370
|
this._cachedViewer2DKey = cacheKey;
|
|
421
|
-
this._cachedExtractedState =
|
|
422
|
-
return
|
|
371
|
+
this._cachedExtractedState = merged;
|
|
372
|
+
return merged;
|
|
423
373
|
}
|
|
424
374
|
}, {
|
|
425
375
|
key: "render",
|
|
426
376
|
value: function render() {
|
|
427
|
-
var
|
|
377
|
+
var _this2 = this;
|
|
428
378
|
var _this$props3 = this.props,
|
|
429
379
|
width = _this$props3.width,
|
|
430
380
|
height = _this$props3.height,
|
|
@@ -440,7 +390,7 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
440
390
|
var contentH = height;
|
|
441
391
|
var extracted = this.getExtractedStateWithViewer2DInit(extractedState, width, height);
|
|
442
392
|
var ctxValue = _objectSpread(_objectSpread({}, objectsMap(actions, function (actionNamespace) {
|
|
443
|
-
return
|
|
393
|
+
return _this2.props[actionNamespace];
|
|
444
394
|
})), {}, {
|
|
445
395
|
translator: this.props.translator,
|
|
446
396
|
catalog: this.props.catalog
|