kitchen-simulator 5.10.13-react.18 → 5.10.14-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.
|
@@ -20,8 +20,7 @@ import React, { Component } from 'react';
|
|
|
20
20
|
import { connect } from 'react-redux';
|
|
21
21
|
import { bindActionCreators } from 'redux';
|
|
22
22
|
import * as constants from "./constants";
|
|
23
|
-
import
|
|
24
|
-
import actions, { projectActions } from "./actions/export";
|
|
23
|
+
import actions from "./actions/export";
|
|
25
24
|
import Catalog from "./catalog/catalog";
|
|
26
25
|
import { Content } from "./components/export";
|
|
27
26
|
import Translator from "./translator/translator";
|
|
@@ -43,10 +42,20 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
43
42
|
var _this;
|
|
44
43
|
_classCallCheck(this, LiteKitchenConfigurator);
|
|
45
44
|
_this = _callSuper(this, LiteKitchenConfigurator, [props]);
|
|
45
|
+
|
|
46
|
+
// ---- guards / schedulers ----
|
|
46
47
|
_this._catalogInitRequested = false;
|
|
47
48
|
_this._lastHandledExternalEvent = null;
|
|
48
49
|
_this._handlingExternalEvent = false;
|
|
49
|
-
_this.
|
|
50
|
+
_this._scheduledExternalEventTimeout = null;
|
|
51
|
+
|
|
52
|
+
// viewer2D init guard (prevents dispatch loops)
|
|
53
|
+
_this._viewer2DInitKeyDone = null;
|
|
54
|
+
|
|
55
|
+
// cache for viewer2D init (no merging in render)
|
|
56
|
+
_this._lastExtractedStateRef = null;
|
|
57
|
+
_this._cachedViewer2DKey = null;
|
|
58
|
+
_this._cachedExtractedState = null;
|
|
50
59
|
_this.state = {
|
|
51
60
|
savePopupVisible: false,
|
|
52
61
|
quotePopupVisible: false,
|
|
@@ -98,13 +107,10 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
98
107
|
_this.setDownloadPopupVisible = _this.setDownloadPopupVisible.bind(_this);
|
|
99
108
|
_this.neverShowInput = /*#__PURE__*/React.createRef(null);
|
|
100
109
|
_this.setShowProperty = _this.setShowProperty.bind(_this);
|
|
101
|
-
|
|
102
|
-
// cache for viewer2D init so we don't allocate merges every render
|
|
103
|
-
_this._lastExtractedStateRef = null;
|
|
104
|
-
_this._cachedViewer2DKey = null;
|
|
105
|
-
_this._cachedExtractedState = null;
|
|
106
110
|
return _this;
|
|
107
111
|
}
|
|
112
|
+
|
|
113
|
+
// ---------------- UI setters (unchanged) ----------------
|
|
108
114
|
_inherits(LiteKitchenConfigurator, _Component);
|
|
109
115
|
return _createClass(LiteKitchenConfigurator, [{
|
|
110
116
|
key: "setToolbar",
|
|
@@ -292,46 +298,74 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
292
298
|
var el = document.getElementById('add_appliances_inactive');
|
|
293
299
|
if (el !== null && el !== void 0 && (_el$parentElement0 = el.parentElement) !== null && _el$parentElement0 !== void 0 && _el$parentElement0.parentElement) el.parentElement.parentElement.style.zIndex = 6;
|
|
294
300
|
}
|
|
301
|
+
|
|
302
|
+
// ---------------- viewer2D init (SAFE, guarded) ----------------
|
|
303
|
+
}, {
|
|
304
|
+
key: "maybeInitViewer2D",
|
|
305
|
+
value: function maybeInitViewer2D(extractedState, width, height) {
|
|
306
|
+
var _extractedState$getIn;
|
|
307
|
+
var viewer2DActions = this.props.viewer2DActions;
|
|
308
|
+
var viewer2D = extractedState === null || extractedState === void 0 || (_extractedState$getIn = extractedState.getIn) === null || _extractedState$getIn === void 0 ? void 0 : _extractedState$getIn.call(extractedState, ['viewer2D']);
|
|
309
|
+
if (!viewer2D || viewer2D.size <= 0) return;
|
|
310
|
+
var v = viewer2D.toJS();
|
|
311
|
+
if (!v) return;
|
|
312
|
+
|
|
313
|
+
// Only init when e/f are exactly zero
|
|
314
|
+
if (v.e !== 0 || v.f !== 0) return;
|
|
315
|
+
var key = "".concat(width, ":").concat(height, ":").concat(v.viewerWidth, ":").concat(v.viewerHeight, ":").concat(v.SVGWidth, ":").concat(v.SVGHeight);
|
|
316
|
+
|
|
317
|
+
// ✅ prevent dispatch loop: do it once per signature
|
|
318
|
+
if (this._viewer2DInitKeyDone === key) return;
|
|
319
|
+
this._viewer2DInitKeyDone = key;
|
|
320
|
+
var payload = {
|
|
321
|
+
e: v.viewerWidth / 2 - v.SVGWidth / 2,
|
|
322
|
+
f: v.viewerHeight / 2 - v.SVGHeight / 2,
|
|
323
|
+
a: 0.99,
|
|
324
|
+
d: 0.99
|
|
325
|
+
};
|
|
326
|
+
viewer2DActions.updateViewer2D(payload);
|
|
327
|
+
}
|
|
295
328
|
}, {
|
|
296
329
|
key: "componentDidMount",
|
|
297
330
|
value: function componentDidMount() {
|
|
298
|
-
var _extractedState$
|
|
331
|
+
var _extractedState$getIn2;
|
|
299
332
|
var _this$props = this.props,
|
|
300
333
|
catalog = _this$props.catalog,
|
|
301
334
|
extractedState = _this$props.extractedState,
|
|
302
|
-
projectActions = _this$props.projectActions
|
|
303
|
-
|
|
335
|
+
projectActions = _this$props.projectActions,
|
|
336
|
+
width = _this$props.width,
|
|
337
|
+
height = _this$props.height;
|
|
338
|
+
|
|
339
|
+
// init catalog once
|
|
340
|
+
var catalogReady = extractedState === null || extractedState === void 0 || (_extractedState$getIn2 = extractedState.getIn) === null || _extractedState$getIn2 === void 0 ? void 0 : _extractedState$getIn2.call(extractedState, ['catalog', 'ready']);
|
|
304
341
|
if (!catalogReady && !this._catalogInitRequested) {
|
|
305
342
|
this._catalogInitRequested = true;
|
|
306
343
|
console.log('[LiteKitchenConfigurator] initCatalog (mount)');
|
|
307
344
|
projectActions.initCatalog(catalog);
|
|
308
345
|
}
|
|
346
|
+
|
|
347
|
+
// viewer2D init (safe)
|
|
348
|
+
this.maybeInitViewer2D(extractedState, width, height);
|
|
309
349
|
}
|
|
310
350
|
}, {
|
|
311
351
|
key: "componentDidUpdate",
|
|
312
352
|
value: function componentDidUpdate(prevProps) {
|
|
313
|
-
var
|
|
314
|
-
_this2 = this,
|
|
353
|
+
var _this2 = this,
|
|
315
354
|
_extractedState$getIn3;
|
|
316
355
|
var _this$props2 = this.props,
|
|
317
356
|
externalEvent = _this$props2.externalEvent,
|
|
318
357
|
extractedState = _this$props2.extractedState,
|
|
319
358
|
projectActions = _this$props2.projectActions,
|
|
320
|
-
catalog = _this$props2.catalog
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
f: v.viewerHeight / 2 - v.SVGHeight / 2,
|
|
328
|
-
a: 0.99,
|
|
329
|
-
d: 0.99
|
|
330
|
-
});
|
|
331
|
-
}
|
|
359
|
+
catalog = _this$props2.catalog,
|
|
360
|
+
width = _this$props2.width,
|
|
361
|
+
height = _this$props2.height;
|
|
362
|
+
|
|
363
|
+
// viewer2D init only when relevant inputs change
|
|
364
|
+
if (prevProps.extractedState !== extractedState || prevProps.width !== width || prevProps.height !== height) {
|
|
365
|
+
this.maybeInitViewer2D(extractedState, width, height);
|
|
332
366
|
}
|
|
333
367
|
|
|
334
|
-
// ---- (A) External event handling (
|
|
368
|
+
// ---- (A) External event handling (defer OUTSIDE RAF) ----
|
|
335
369
|
if (prevProps.externalEvent !== externalEvent && externalEvent) {
|
|
336
370
|
if (this._lastHandledExternalEvent === externalEvent) {
|
|
337
371
|
console.warn('[LiteKitchenConfigurator] externalEvent already handled (same ref), skipping');
|
|
@@ -340,16 +374,14 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
340
374
|
} else {
|
|
341
375
|
this._lastHandledExternalEvent = externalEvent;
|
|
342
376
|
this._handlingExternalEvent = true;
|
|
343
|
-
|
|
344
|
-
// capture props snapshot corresponding to this event
|
|
345
377
|
var propsSnapshot = this.props;
|
|
346
378
|
var type = (externalEvent === null || externalEvent === void 0 ? void 0 : externalEvent.type) || 'unknown';
|
|
347
|
-
if (this.
|
|
348
|
-
clearTimeout(this.
|
|
349
|
-
this.
|
|
379
|
+
if (this._scheduledExternalEventTimeout) {
|
|
380
|
+
clearTimeout(this._scheduledExternalEventTimeout);
|
|
381
|
+
this._scheduledExternalEventTimeout = null;
|
|
350
382
|
}
|
|
351
|
-
this.
|
|
352
|
-
_this2.
|
|
383
|
+
this._scheduledExternalEventTimeout = setTimeout(function () {
|
|
384
|
+
_this2._scheduledExternalEventTimeout = null;
|
|
353
385
|
console.time("[handleExternalEvent] ".concat(type));
|
|
354
386
|
try {
|
|
355
387
|
handleExternalEvent(propsSnapshot);
|
|
@@ -379,40 +411,29 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
379
411
|
}, {
|
|
380
412
|
key: "componentWillUnmount",
|
|
381
413
|
value: function componentWillUnmount() {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
this._scheduledExternalEventRaf = null;
|
|
414
|
+
if (this._scheduledExternalEventTimeout) {
|
|
415
|
+
clearTimeout(this._scheduledExternalEventTimeout);
|
|
416
|
+
this._scheduledExternalEventTimeout = null;
|
|
386
417
|
}
|
|
387
418
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
value: function isProjectEmpty(scene) {
|
|
391
|
-
var layers = scene.layers,
|
|
392
|
-
selectedLayer = scene.selectedLayer;
|
|
393
|
-
var layer = layers.get(selectedLayer);
|
|
394
|
-
return layer.areas.size + layer.lines.size + layer.holes.size + layer.items.size === 0;
|
|
395
|
-
}
|
|
419
|
+
|
|
420
|
+
// ✅ IMPORTANT: do NOT mutate/merge redux state in render
|
|
396
421
|
}, {
|
|
397
422
|
key: "getExtractedStateWithViewer2DInit",
|
|
398
423
|
value: function getExtractedStateWithViewer2DInit(extractedState, width, height) {
|
|
399
424
|
if (!extractedState) return extractedState;
|
|
400
|
-
|
|
401
|
-
// ✅ If the extractedState reference changed, drop cache immediately.
|
|
402
425
|
if (this._lastExtractedStateRef !== extractedState) {
|
|
403
426
|
this._lastExtractedStateRef = extractedState;
|
|
404
427
|
this._cachedViewer2DKey = null;
|
|
405
428
|
this._cachedExtractedState = null;
|
|
406
429
|
}
|
|
407
|
-
var
|
|
408
|
-
if (!
|
|
409
|
-
var v =
|
|
410
|
-
|
|
411
|
-
// Only do the "center viewer2D if e/f are zero" logic.
|
|
412
|
-
// ✅ No need to build keys from unrelated parts of state.
|
|
430
|
+
var viewer2D = extractedState.getIn(['viewer2D']);
|
|
431
|
+
if (!viewer2D || viewer2D.size <= 0) return extractedState;
|
|
432
|
+
var v = viewer2D.toJS();
|
|
433
|
+
if (!v) return extractedState;
|
|
413
434
|
if (v.e !== 0 || v.f !== 0) return extractedState;
|
|
414
435
|
|
|
415
|
-
//
|
|
436
|
+
// Keep cache (doesn't change state), mostly no-op now
|
|
416
437
|
var cacheKey = "".concat(width, ":").concat(height, ":").concat(v.viewerWidth, ":").concat(v.viewerHeight, ":").concat(v.SVGWidth, ":").concat(v.SVGHeight);
|
|
417
438
|
if (this._cachedViewer2DKey === cacheKey && this._cachedExtractedState) {
|
|
418
439
|
return this._cachedExtractedState;
|
|
@@ -433,9 +454,7 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
433
454
|
var _this$state = this.state,
|
|
434
455
|
savePopupVisible = _this$state.savePopupVisible,
|
|
435
456
|
quotePopupVisible = _this$state.quotePopupVisible,
|
|
436
|
-
assistPopupVisible = _this$state.assistPopupVisible
|
|
437
|
-
signOpen = _this$state.signOpen,
|
|
438
|
-
myProjectsOpen = _this$state.myProjectsOpen;
|
|
457
|
+
assistPopupVisible = _this$state.assistPopupVisible;
|
|
439
458
|
var contentW = width - toolbarW;
|
|
440
459
|
var contentH = height;
|
|
441
460
|
var extracted = this.getExtractedStateWithViewer2DInit(extractedState, width, height);
|
|
@@ -498,7 +517,6 @@ LiteKitchenConfigurator.propTypes = {
|
|
|
498
517
|
configData: PropTypes.object,
|
|
499
518
|
onInternalEvent: PropTypes.func,
|
|
500
519
|
extractedState: PropTypes.object,
|
|
501
|
-
// ✅ injected by connect
|
|
502
520
|
externalEvent: PropTypes.object
|
|
503
521
|
};
|
|
504
522
|
LiteKitchenConfigurator.defaultProps = {
|
|
@@ -512,9 +530,6 @@ LiteKitchenConfigurator.defaultProps = {
|
|
|
512
530
|
customContents: {},
|
|
513
531
|
configData: {}
|
|
514
532
|
};
|
|
515
|
-
|
|
516
|
-
// ✅ Only select the slice you actually use.
|
|
517
|
-
// This preserves behavior but massively reduces rerenders.
|
|
518
533
|
function mapStateToProps(reduxState, ownProps) {
|
|
519
534
|
var stateExtractor = ownProps.stateExtractor || function (s) {
|
|
520
535
|
return s;
|
package/es/LiteRenderer.js
CHANGED
|
@@ -25,7 +25,6 @@ import * as THREE from 'three';
|
|
|
25
25
|
import * as Models from "./models";
|
|
26
26
|
import { State } from "./models";
|
|
27
27
|
import PlannerReducer from "./reducers/reducer";
|
|
28
|
-
import AppContext from "./AppContext";
|
|
29
28
|
import Catalog from "./catalog/catalog";
|
|
30
29
|
import * as Areas from "./catalog/areas/area/planner-element";
|
|
31
30
|
import * as Lines from "./catalog/lines/wall/planner-element";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UPDATE_CEIL_HEIGHT_UNIT, UPDATE_CEIL_HEIGHT, UPDATE_2D_CAMERA, SELECT_TOOL_PAN, SELECT_TOOL_ZOOM_IN, SELECT_TOOL_ZOOM_OUT, CHANGE_WALL_LENGTH_MEASURE, CHANGE_BASE_CABINET_MEASURE, CHANGE_WALL_CABINET_MEASURE, CHANGE_WINDOW_DOOR_MEASURE } from "../constants";
|
|
1
|
+
import { UPDATE_CEIL_HEIGHT_UNIT, UPDATE_CEIL_HEIGHT, UPDATE_2D_CAMERA, SELECT_TOOL_PAN, SELECT_TOOL_ZOOM_IN, SELECT_TOOL_ZOOM_OUT, CHANGE_WALL_LENGTH_MEASURE, CHANGE_BASE_CABINET_MEASURE, CHANGE_WALL_CABINET_MEASURE, CHANGE_WINDOW_DOOR_MEASURE, UPDATE_VIEWER2D } from "../constants";
|
|
2
2
|
export function updateCeilHeight(value) {
|
|
3
3
|
return {
|
|
4
4
|
type: UPDATE_CEIL_HEIGHT,
|
|
@@ -55,4 +55,10 @@ export function selectToolZoomIn() {
|
|
|
55
55
|
return {
|
|
56
56
|
type: SELECT_TOOL_ZOOM_IN
|
|
57
57
|
};
|
|
58
|
+
}
|
|
59
|
+
export function updateViewer2D(viewer2D) {
|
|
60
|
+
return {
|
|
61
|
+
type: UPDATE_VIEWER2D,
|
|
62
|
+
viewer2D: viewer2D
|
|
63
|
+
};
|
|
58
64
|
}
|
package/es/constants.js
CHANGED
|
@@ -12,6 +12,7 @@ export var NEW_PROJECT = 'NEW_PROJECT';
|
|
|
12
12
|
export var LOAD_PROJECT = 'LOAD_PROJECT';
|
|
13
13
|
export var SAVE_PROJECT = 'SAVE_PROJECT';
|
|
14
14
|
export var OPEN_CATALOG = 'OPEN_CATALOG';
|
|
15
|
+
export var UPDATE_VIEWER2D = 'UPDATE_VIEWER2D';
|
|
15
16
|
export var SELECT_TOOL_EDIT = 'SELECT_TOOL_EDIT';
|
|
16
17
|
export var UNSELECT_ALL = 'UNSELECT_ALL';
|
|
17
18
|
export var SELECT_ALL = 'SELECT_ALL';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CHANGE_BASE_CABINET_MEASURE, CHANGE_WALL_CABINET_MEASURE, CHANGE_WALL_LENGTH_MEASURE, CHANGE_WINDOW_DOOR_MEASURE, MODE_2D_PAN, MODE_2D_ZOOM_IN, MODE_2D_ZOOM_OUT, SELECT_TOOL_PAN, SELECT_TOOL_ZOOM_IN, SELECT_TOOL_ZOOM_OUT, UPDATE_2D_CAMERA, UPDATE_CEIL_HEIGHT, UPDATE_CEIL_HEIGHT_UNIT } from "../constants";
|
|
1
|
+
import { CHANGE_BASE_CABINET_MEASURE, CHANGE_WALL_CABINET_MEASURE, CHANGE_WALL_LENGTH_MEASURE, CHANGE_WINDOW_DOOR_MEASURE, MODE_2D_PAN, MODE_2D_ZOOM_IN, MODE_2D_ZOOM_OUT, SELECT_TOOL_PAN, SELECT_TOOL_ZOOM_IN, SELECT_TOOL_ZOOM_OUT, UPDATE_2D_CAMERA, UPDATE_CEIL_HEIGHT, UPDATE_CEIL_HEIGHT_UNIT, UPDATE_VIEWER2D } from "../constants";
|
|
2
2
|
import { convert } from "../utils/convert-units-lite";
|
|
3
3
|
export default function (state, action) {
|
|
4
4
|
var _state = state,
|
|
@@ -73,5 +73,13 @@ export default function (state, action) {
|
|
|
73
73
|
return state.set('mode', MODE_2D_ZOOM_IN);
|
|
74
74
|
case SELECT_TOOL_ZOOM_OUT:
|
|
75
75
|
return state.set('mode', MODE_2D_ZOOM_OUT);
|
|
76
|
+
case UPDATE_VIEWER2D:
|
|
77
|
+
{
|
|
78
|
+
var current = state.get('viewer2D');
|
|
79
|
+
if (current && current.merge) {
|
|
80
|
+
return state.set('viewer2D', current.merge(action.viewer2D));
|
|
81
|
+
}
|
|
82
|
+
return state.set('viewer2D', state.constructor(action.viewer2D));
|
|
83
|
+
}
|
|
76
84
|
}
|
|
77
85
|
}
|