kitchen-simulator 5.10.12-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,33 +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
353
|
var _this2 = this,
|
|
314
|
-
_extractedState$
|
|
354
|
+
_extractedState$getIn3;
|
|
315
355
|
var _this$props2 = this.props,
|
|
316
356
|
externalEvent = _this$props2.externalEvent,
|
|
317
357
|
extractedState = _this$props2.extractedState,
|
|
318
358
|
projectActions = _this$props2.projectActions,
|
|
319
|
-
catalog = _this$props2.catalog
|
|
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);
|
|
366
|
+
}
|
|
320
367
|
|
|
321
|
-
// ---- (A) External event handling (
|
|
368
|
+
// ---- (A) External event handling (defer OUTSIDE RAF) ----
|
|
322
369
|
if (prevProps.externalEvent !== externalEvent && externalEvent) {
|
|
323
370
|
if (this._lastHandledExternalEvent === externalEvent) {
|
|
324
371
|
console.warn('[LiteKitchenConfigurator] externalEvent already handled (same ref), skipping');
|
|
@@ -327,16 +374,14 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
327
374
|
} else {
|
|
328
375
|
this._lastHandledExternalEvent = externalEvent;
|
|
329
376
|
this._handlingExternalEvent = true;
|
|
330
|
-
|
|
331
|
-
// capture props snapshot corresponding to this event
|
|
332
377
|
var propsSnapshot = this.props;
|
|
333
378
|
var type = (externalEvent === null || externalEvent === void 0 ? void 0 : externalEvent.type) || 'unknown';
|
|
334
|
-
if (this.
|
|
335
|
-
clearTimeout(this.
|
|
336
|
-
this.
|
|
379
|
+
if (this._scheduledExternalEventTimeout) {
|
|
380
|
+
clearTimeout(this._scheduledExternalEventTimeout);
|
|
381
|
+
this._scheduledExternalEventTimeout = null;
|
|
337
382
|
}
|
|
338
|
-
this.
|
|
339
|
-
_this2.
|
|
383
|
+
this._scheduledExternalEventTimeout = setTimeout(function () {
|
|
384
|
+
_this2._scheduledExternalEventTimeout = null;
|
|
340
385
|
console.time("[handleExternalEvent] ".concat(type));
|
|
341
386
|
try {
|
|
342
387
|
handleExternalEvent(propsSnapshot);
|
|
@@ -351,7 +396,7 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
351
396
|
}
|
|
352
397
|
|
|
353
398
|
// ---- (B) initCatalog: request once until ready ----
|
|
354
|
-
var catalogReady = extractedState === null || extractedState === void 0 || (_extractedState$
|
|
399
|
+
var catalogReady = extractedState === null || extractedState === void 0 || (_extractedState$getIn3 = extractedState.getIn) === null || _extractedState$getIn3 === void 0 ? void 0 : _extractedState$getIn3.call(extractedState, ['catalog', 'ready']);
|
|
355
400
|
if (catalogReady) {
|
|
356
401
|
if (this._catalogInitRequested) console.log('[LiteKitchenConfigurator] catalog ready');
|
|
357
402
|
this._catalogInitRequested = false;
|
|
@@ -366,56 +411,36 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
366
411
|
}, {
|
|
367
412
|
key: "componentWillUnmount",
|
|
368
413
|
value: function componentWillUnmount() {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
this._scheduledExternalEventRaf = null;
|
|
414
|
+
if (this._scheduledExternalEventTimeout) {
|
|
415
|
+
clearTimeout(this._scheduledExternalEventTimeout);
|
|
416
|
+
this._scheduledExternalEventTimeout = null;
|
|
373
417
|
}
|
|
374
418
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
value: function isProjectEmpty(scene) {
|
|
378
|
-
var layers = scene.layers,
|
|
379
|
-
selectedLayer = scene.selectedLayer;
|
|
380
|
-
var layer = layers.get(selectedLayer);
|
|
381
|
-
return layer.areas.size + layer.lines.size + layer.holes.size + layer.items.size === 0;
|
|
382
|
-
}
|
|
419
|
+
|
|
420
|
+
// ✅ IMPORTANT: do NOT mutate/merge redux state in render
|
|
383
421
|
}, {
|
|
384
422
|
key: "getExtractedStateWithViewer2DInit",
|
|
385
423
|
value: function getExtractedStateWithViewer2DInit(extractedState, width, height) {
|
|
386
424
|
if (!extractedState) return extractedState;
|
|
387
|
-
|
|
388
|
-
// ✅ If the extractedState reference changed, drop cache immediately.
|
|
389
425
|
if (this._lastExtractedStateRef !== extractedState) {
|
|
390
426
|
this._lastExtractedStateRef = extractedState;
|
|
391
427
|
this._cachedViewer2DKey = null;
|
|
392
428
|
this._cachedExtractedState = null;
|
|
393
429
|
}
|
|
394
|
-
var
|
|
395
|
-
if (!
|
|
396
|
-
var v =
|
|
397
|
-
|
|
398
|
-
// Only do the "center viewer2D if e/f are zero" logic.
|
|
399
|
-
// ✅ 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;
|
|
400
434
|
if (v.e !== 0 || v.f !== 0) return extractedState;
|
|
401
435
|
|
|
402
|
-
//
|
|
436
|
+
// Keep cache (doesn't change state), mostly no-op now
|
|
403
437
|
var cacheKey = "".concat(width, ":").concat(height, ":").concat(v.viewerWidth, ":").concat(v.viewerHeight, ":").concat(v.SVGWidth, ":").concat(v.SVGHeight);
|
|
404
438
|
if (this._cachedViewer2DKey === cacheKey && this._cachedExtractedState) {
|
|
405
439
|
return this._cachedExtractedState;
|
|
406
440
|
}
|
|
407
|
-
var centeredViewer2D = _viewer2D.merge({
|
|
408
|
-
e: v.viewerWidth / 2 - v.SVGWidth / 2,
|
|
409
|
-
f: v.viewerHeight / 2 - v.SVGHeight / 2,
|
|
410
|
-
a: 0.99,
|
|
411
|
-
d: 0.99
|
|
412
|
-
});
|
|
413
|
-
var merged = extractedState.merge({
|
|
414
|
-
viewer2D: centeredViewer2D
|
|
415
|
-
});
|
|
416
441
|
this._cachedViewer2DKey = cacheKey;
|
|
417
|
-
this._cachedExtractedState =
|
|
418
|
-
return
|
|
442
|
+
this._cachedExtractedState = extractedState;
|
|
443
|
+
return extractedState;
|
|
419
444
|
}
|
|
420
445
|
}, {
|
|
421
446
|
key: "render",
|
|
@@ -429,9 +454,7 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
429
454
|
var _this$state = this.state,
|
|
430
455
|
savePopupVisible = _this$state.savePopupVisible,
|
|
431
456
|
quotePopupVisible = _this$state.quotePopupVisible,
|
|
432
|
-
assistPopupVisible = _this$state.assistPopupVisible
|
|
433
|
-
signOpen = _this$state.signOpen,
|
|
434
|
-
myProjectsOpen = _this$state.myProjectsOpen;
|
|
457
|
+
assistPopupVisible = _this$state.assistPopupVisible;
|
|
435
458
|
var contentW = width - toolbarW;
|
|
436
459
|
var contentH = height;
|
|
437
460
|
var extracted = this.getExtractedStateWithViewer2DInit(extractedState, width, height);
|
|
@@ -494,7 +517,6 @@ LiteKitchenConfigurator.propTypes = {
|
|
|
494
517
|
configData: PropTypes.object,
|
|
495
518
|
onInternalEvent: PropTypes.func,
|
|
496
519
|
extractedState: PropTypes.object,
|
|
497
|
-
// ✅ injected by connect
|
|
498
520
|
externalEvent: PropTypes.object
|
|
499
521
|
};
|
|
500
522
|
LiteKitchenConfigurator.defaultProps = {
|
|
@@ -508,9 +530,6 @@ LiteKitchenConfigurator.defaultProps = {
|
|
|
508
530
|
customContents: {},
|
|
509
531
|
configData: {}
|
|
510
532
|
};
|
|
511
|
-
|
|
512
|
-
// ✅ Only select the slice you actually use.
|
|
513
|
-
// This preserves behavior but massively reduces rerenders.
|
|
514
533
|
function mapStateToProps(reduxState, ownProps) {
|
|
515
534
|
var stateExtractor = ownProps.stateExtractor || function (s) {
|
|
516
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
|
}
|