kitchen-simulator 7.0.9-react-18 → 11.0.0-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.
@@ -6,7 +6,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
6
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
8
8
  import _inherits from "@babel/runtime/helpers/esm/inherits";
9
- var _excluded = ["width", "height", "configData", "externalEvent", "onInternalEvent", "onError", "onViewer2DChange"];
9
+ var _excluded = ["width", "height", "configData", "externalEvent", "onInternalEvent", "onError"];
10
10
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
11
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
12
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
@@ -32,7 +32,6 @@ import * as Lines from "./catalog/lines/wall/planner-element";
32
32
  import * as Holes from "./catalog/holes/export";
33
33
  import { ConsoleDebugger, Keyboard } from "./plugins/export";
34
34
  import LiteKitchenConfigurator from "./LiteKitchenConfigurator";
35
- import { toPlainObject } from "../es/utils/helper";
36
35
  var isBrowser = typeof window !== 'undefined';
37
36
  if (isBrowser) window.THREE = THREE;
38
37
 
@@ -157,10 +156,6 @@ function createInstanceStore() {
157
156
  function createPlugins() {
158
157
  return [Keyboard(), ConsoleDebugger()];
159
158
  }
160
- function shallowEqualViewer(a, b) {
161
- if (!a || !b) return a === b;
162
- return a.a === b.a && a.d === b.d && a.e === b.e && a.f === b.f && a.viewerWidth === b.viewerWidth && a.viewerHeight === b.viewerHeight && a.SVGWidth === b.SVGWidth && a.SVGHeight === b.SVGHeight;
163
- }
164
159
  export default function LiteRenderer(props) {
165
160
  ensureSentryInit();
166
161
  var width = props.width,
@@ -169,7 +164,6 @@ export default function LiteRenderer(props) {
169
164
  externalEvent = props.externalEvent,
170
165
  onInternalEvent = props.onInternalEvent,
171
166
  onError = props.onError,
172
- onViewer2DChange = props.onViewer2DChange,
173
167
  passThrough = _objectWithoutProperties(props, _excluded);
174
168
  useEffect(function () {
175
169
  return function () {
@@ -183,36 +177,6 @@ export default function LiteRenderer(props) {
183
177
  // ✅ instance-scoped store (no module singleton)
184
178
  var storeRef = useRef(null);
185
179
  if (!storeRef.current) storeRef.current = createInstanceStore();
186
- var prevRef = useRef(null);
187
- useEffect(function () {
188
- var _state$viewer2D2, _state$get2;
189
- if (!onViewer2DChange) return;
190
- if (!storeRef.current) return;
191
-
192
- // you must have `store` in scope here (however LiteRenderer gets it)
193
- var unsub = storeRef.current.subscribe(function () {
194
- var _state$viewer2D, _state$get;
195
- var state = storeRef.current.getState();
196
-
197
- // viewer2D might be immutable or plain
198
- var viewer2D = toPlainObject((_state$viewer2D = state.viewer2D) !== null && _state$viewer2D !== void 0 ? _state$viewer2D : (_state$get = state.get) === null || _state$get === void 0 ? void 0 : _state$get.call(state, 'viewer2D'));
199
-
200
- // emit only when changed
201
- if (!shallowEqualViewer(prevRef.current, viewer2D)) {
202
- prevRef.current = viewer2D;
203
- onViewer2DChange(viewer2D);
204
- }
205
- });
206
-
207
- // emit once immediately
208
- var state = storeRef.current.getState();
209
- var viewer2D = toPlainObject((_state$viewer2D2 = state.viewer2D) !== null && _state$viewer2D2 !== void 0 ? _state$viewer2D2 : (_state$get2 = state.get) === null || _state$get2 === void 0 ? void 0 : _state$get2.call(state, 'viewer2D'));
210
- prevRef.current = viewer2D;
211
- onViewer2DChange(viewer2D);
212
- return function () {
213
- return unsub();
214
- };
215
- }, [onViewer2DChange]);
216
180
 
217
181
  // ✅ instance-scoped catalog (no module singleton)
218
182
  var catalogRef = useRef(null);
@@ -16,7 +16,7 @@ var STYLE_LINE = {
16
16
  // strokeWidth:1
17
17
  };
18
18
  var STYLE_INTERIOR_LINE = {
19
- strokeWidth: 4,
19
+ strokeWidth: 2,
20
20
  stroke: SharedStyle.INTERIOR_LINE.unselected
21
21
  };
22
22
  var STYLE_INTERIOR_LINE_SELECTED = {
@@ -857,8 +857,8 @@ var Project = /*#__PURE__*/function () {
857
857
  if (isEmpty(viewer)) return {
858
858
  updatedState: state
859
859
  };
860
- width = convert(width).from(measurementUnit).to('cm');
861
- height = convert(height).from(measurementUnit).to('cm');
860
+ width = convert(width).from(measurementUnit !== null && measurementUnit !== void 0 ? measurementUnit : 'in').to('cm');
861
+ height = convert(height).from(measurementUnit !== null && measurementUnit !== void 0 ? measurementUnit : 'in').to('cm');
862
862
  var halfWidth = width / 2;
863
863
  var halfHeight = height / 2;
864
864
  var viewerWidth = viewer.SVGWidth;
@@ -12,7 +12,7 @@ import { disposeObject } from "./three-memory-cleaner";
12
12
  import { ANIMATE_STEP_MAX, ANIMATE_STEP_MIN, ARRAY_3D_MODES, ARROW_TEXT_BACKCOLOR, ARROW_TEXT_FONTFACE, ARROW_TEXT_FORECOLOR, BASE_CABINET_LAYOUTPOS, BOTTOM_MOLDING_LOCATION, DECIMAL_PLACES_2, DIFFERENT_VALUES_PATH_LENGTH, DISTANCE_EPSILON, EPSILON, MIDDLE_MOLDING_LOCATION, MODE_DRAGGING_ITEM_3D, MODE_DRAWING_ITEM_3D, MODE_IDLE, MODE_IDLE_3D, MODE_ROTATING_ITEM_3D, OBJTYPE_MESH, SHADE_DARK_PURPLE_COLOR, TOP_MOLDING_LOCATION, UNIT_CENTIMETER, UNIT_FOOT, UNIT_INCH, UNIT_METER, WALL_CABINET_LAYOUTPOS } from "../../constants";
13
13
  import { GeometryUtils, IDBroker, MoldingUtils } from "../../utils/export";
14
14
  import { convert } from "../../utils/convert-units-lite";
15
- import { calcDistancesFromItemToWalls, verticesDistance } from "../../utils/geometry";
15
+ import { calcDistancesFromItemToWalls, getSnappedWallLines, verticesDistance } from "../../utils/geometry";
16
16
  import * as GeomUtils from "../../catalog/utils/geom-utils";
17
17
  import { loadTexture } from "../../catalog/utils/item-loader";
18
18
  import { returnReplaceableDeepSearchType } from "../viewer2d/utils";
@@ -3010,6 +3010,10 @@ export function createBacksplash(item, layer, planData, scene) {
3010
3010
  return;
3011
3011
  }
3012
3012
 
3013
+ // Get current wall line that item is snapped
3014
+ var wLines = getSnappedWallLines(item.itemInfo, layer, planData.catalog);
3015
+ var curLine = wLines.length > 0 ? wLines[0] : null;
3016
+
3013
3017
  // Get wall items
3014
3018
 
3015
3019
  var i,
@@ -3051,7 +3055,7 @@ export function createBacksplash(item, layer, planData, scene) {
3051
3055
  var _hole$properties, _hole$properties2;
3052
3056
  var width = (_hole$properties = hole.properties) === null || _hole$properties === void 0 ? void 0 : _hole$properties.getIn(['width', 'length']);
3053
3057
  var altitude = (_hole$properties2 = hole.properties) === null || _hole$properties2 === void 0 ? void 0 : _hole$properties2.getIn(['altitude', 'length']);
3054
- if (!isEmpty(width) && !isEmpty(altitude)) altItems.push({
3058
+ if (!isEmpty(width) && !isEmpty(altitude) && hole.line === (curLine === null || curLine === void 0 ? void 0 : curLine.id)) altItems.push({
3055
3059
  x: hole.x,
3056
3060
  width: width,
3057
3061
  altitude: altitude
@@ -3068,7 +3072,8 @@ export function createBacksplash(item, layer, planData, scene) {
3068
3072
  }
3069
3073
  });
3070
3074
  }
3071
- if (!flag) depth = 52 * 2.54;
3075
+ var DEFAULT_BACKSPLASH_HEIGHT = 52 * 2.54;
3076
+ if (!flag || depth > DEFAULT_BACKSPLASH_HEIGHT) depth = DEFAULT_BACKSPLASH_HEIGHT;
3072
3077
 
3073
3078
  // Get backsplash info
3074
3079
 
package/es/constants.js CHANGED
@@ -447,6 +447,7 @@ export var UNIT_MILLIMETER = 'mm';
447
447
  export var UNIT_CENTIMETER = 'cm';
448
448
  export var UNIT_METER = 'm';
449
449
  export var UNIT_INCH = 'in';
450
+ export var UNIT_INCH_LONG = 'inch';
450
451
  export var UNIT_FOOT = 'ft';
451
452
  export var UNIT_MILE = 'mi';
452
453
  export var UNITS_LENGTH = [UNIT_MILLIMETER, UNIT_CENTIMETER, UNIT_METER, UNIT_INCH, UNIT_FOOT, UNIT_MILE];
package/es/index.js CHANGED
@@ -368,7 +368,6 @@ export function renderKitchenSimulator(container) {
368
368
 
369
369
  // ✅ Reuse root
370
370
  var root = container[ROOT_KEY];
371
- var latestViewer2D = null;
372
371
  if (!root) {
373
372
  root = createRoot(container);
374
373
  container[ROOT_KEY] = root;
@@ -549,10 +548,7 @@ export function renderKitchenSimulator(container) {
549
548
  key: "render",
550
549
  value: function render() {
551
550
  return /*#__PURE__*/React.createElement(LiteRenderer, _extends({}, this.props, {
552
- externalEvent: this.state.externalEvent,
553
- onViewer2DChange: function onViewer2DChange(v) {
554
- latestViewer2D = v;
555
- }
551
+ externalEvent: this.state.externalEvent
556
552
  }));
557
553
  }
558
554
  }]);
@@ -561,9 +557,6 @@ export function renderKitchenSimulator(container) {
561
557
  __render: function __render(nextProps) {
562
558
  root.render(/*#__PURE__*/React.createElement(Wrapper, nextProps));
563
559
  },
564
- getViewer2D: function getViewer2D() {
565
- return latestViewer2D;
566
- },
567
560
  // ✅ host can query current inFlight
568
561
  getGltfInFlight: function getGltfInFlight() {
569
562
  return gltfTracker.getInFlight();
@@ -1,3 +1,4 @@
1
+ import { UNIT_INCH, UNIT_INCH_LONG } from "../constants";
1
2
  var lengthFactors = {
2
3
  m: 1,
3
4
  cm: 100,
@@ -13,11 +14,19 @@ var lengthFactors = {
13
14
  // (39.3701^2)
14
15
  ft2: 10.7639 // (3.28084^2)
15
16
  };
17
+ function normalizeUnit(unit) {
18
+ if (!unit) return unit;
19
+ var u = unit.toLowerCase();
20
+ if (u === UNIT_INCH_LONG) return UNIT_INCH;
21
+ return u;
22
+ }
16
23
  export function convert(value) {
17
24
  return {
18
25
  from: function from(fromUnit) {
19
26
  return {
20
27
  to: function to(toUnit) {
28
+ fromUnit = normalizeUnit(fromUnit);
29
+ toUnit = normalizeUnit(toUnit);
21
30
  if (!(fromUnit in lengthFactors) || !(toUnit in lengthFactors)) {
22
31
  throw new Error("Unsupported unit conversion: ".concat(fromUnit, " \u2192 ").concat(toUnit));
23
32
  }
@@ -759,7 +759,7 @@ export function getAllItemSpecified(scene, catalog, filter) {
759
759
  // Filter check
760
760
  if (Array.isArray(filter)) {
761
761
  if (info && !filter.includes(info.layoutpos)) return;
762
- } else if (info && (info.layoutpos !== filter || (cat === null || cat === void 0 ? void 0 : cat.type) === 'appliance' && ['Cook Top', 'Microwave'].includes(cat === null || cat === void 0 || (_cat$obj = cat.obj) === null || _cat$obj === void 0 ? void 0 : _cat$obj.category))) {
762
+ } else if ((info === null || info === void 0 ? void 0 : info.layoutpos) !== filter || isEmpty(cat) || (cat === null || cat === void 0 ? void 0 : cat.type) === 'appliance' && ['Cook Top', 'Microwave'].includes(cat === null || cat === void 0 || (_cat$obj = cat.obj) === null || _cat$obj === void 0 ? void 0 : _cat$obj.category)) {
763
763
  return;
764
764
  }
765
765
 
@@ -995,9 +995,9 @@ export function getAllLines(layer) {
995
995
  }
996
996
  }
997
997
  });
998
- allLines.splice(addIdx, 0, [vertices, thick]);
998
+ allLines.splice(addIdx, 0, [vertices, thick, line.id]);
999
999
  } else {
1000
- allLines.push([allAreaLines[i], thick]);
1000
+ allLines.push([allAreaLines[i], thick, line.id]);
1001
1001
  }
1002
1002
  });
1003
1003
  return allLines;
@@ -1039,7 +1039,9 @@ export function buildRectFromLines(layer, lines) {
1039
1039
  var y0 = vxys[1];
1040
1040
  var x1 = vxys[2];
1041
1041
  var y1 = vxys[3];
1042
- rect.push(getCalcRectFromLine(x0, y0, x1, y1, thick, layer));
1042
+ var rectLine = getCalcRectFromLine(x0, y0, x1, y1, thick, layer);
1043
+ rectLine.lineId = line.length > 2 ? line[2] : null;
1044
+ rect.push(rectLine);
1043
1045
  });
1044
1046
  return rect;
1045
1047
  }
@@ -2606,4 +2608,196 @@ export function calcDistancesFromItemToWalls(curItem, layer) {
2606
2608
  return {
2607
2609
  PointArray: PointArray
2608
2610
  };
2611
+ }
2612
+ export function calcDistancesFromHoleToNearestOneOrWall(curHole, layer) {
2613
+ var _layer$lines, _layer$vertices2, _line$vertices, _layer$vertices3, _line$vertices2, _curHole$properties$g, _curHole$properties, _line$get;
2614
+ var distArray = {
2615
+ distLeft: 0,
2616
+ distRight: 0
2617
+ };
2618
+ if (isEmpty(curHole)) return distArray;
2619
+ /***** calculate Left & Right distance from nearest hole ******/
2620
+ // parent line of curHole
2621
+ var line = (_layer$lines = layer.lines) === null || _layer$lines === void 0 ? void 0 : _layer$lines.get(curHole.line);
2622
+ var v0 = (_layer$vertices2 = layer.vertices) === null || _layer$vertices2 === void 0 ? void 0 : _layer$vertices2.get(line === null || line === void 0 || (_line$vertices = line.vertices) === null || _line$vertices === void 0 ? void 0 : _line$vertices.get(0));
2623
+ var v1 = (_layer$vertices3 = layer.vertices) === null || _layer$vertices3 === void 0 ? void 0 : _layer$vertices3.get(line === null || line === void 0 || (_line$vertices2 = line.vertices) === null || _line$vertices2 === void 0 ? void 0 : _line$vertices2.get(1));
2624
+ if (isEmpty(line) || isEmpty(v0) || isEmpty(v1)) return distArray;
2625
+ var angle = angleBetweenTwoPoints(v0.x, v0.y, v1.x, v1.y);
2626
+
2627
+ // start point and end point of current hole
2628
+ var chw = (_curHole$properties$g = (_curHole$properties = curHole.properties) === null || _curHole$properties === void 0 || (_curHole$properties = _curHole$properties.get('width')) === null || _curHole$properties === void 0 ? void 0 : _curHole$properties.get('length')) !== null && _curHole$properties$g !== void 0 ? _curHole$properties$g : 0;
2629
+ var chsp = {
2630
+ x: curHole.x - chw / 2 * Math.cos(angle),
2631
+ y: curHole.y - chw / 2 * Math.sin(angle)
2632
+ };
2633
+ var chep = {
2634
+ x: curHole.x + chw / 2 * Math.cos(angle),
2635
+ y: curHole.y + chw / 2 * Math.sin(angle)
2636
+ };
2637
+ distArray.distLeft = pointsDistance(v0.x, v0.y, chsp.x, chsp.y);
2638
+ distArray.distRight = pointsDistance(v1.x, v1.y, chep.x, chep.y);
2639
+ (_line$get = line.get('holes')) === null || _line$get === void 0 || _line$get.forEach(function (hId) {
2640
+ if (hId !== curHole.id) {
2641
+ var _layer$holes, _hole$properties$get$, _hole$properties;
2642
+ var hole = (_layer$holes = layer.holes) === null || _layer$holes === void 0 ? void 0 : _layer$holes.get(hId);
2643
+ // start point and end point of other hole
2644
+ var hw = (_hole$properties$get$ = (_hole$properties = hole.properties) === null || _hole$properties === void 0 || (_hole$properties = _hole$properties.get('width')) === null || _hole$properties === void 0 ? void 0 : _hole$properties.get('length')) !== null && _hole$properties$get$ !== void 0 ? _hole$properties$get$ : 0;
2645
+ var hsp = {
2646
+ x: hole.x - hw / 2 * Math.cos(angle),
2647
+ y: hole.y - hw / 2 * Math.sin(angle)
2648
+ };
2649
+ var hep = {
2650
+ x: hole.x + hw / 2 * Math.cos(angle),
2651
+ y: hole.y + hw / 2 * Math.sin(angle)
2652
+ };
2653
+ var relation = relationshipOfTwoOverlappedLines({
2654
+ x1: chsp.x,
2655
+ y1: chsp.y,
2656
+ x2: chep.x,
2657
+ y2: chep.y
2658
+ }, {
2659
+ x1: hsp.x,
2660
+ y1: hsp.y,
2661
+ x2: hep.x,
2662
+ y2: hep.y
2663
+ });
2664
+ // two holes(current hole and other hole) are not overlaped, then get distance
2665
+ if (relation.result === OVERLAP_NONE || relation.result === OVERLAP_LINK) {
2666
+ if (hole.offset < curHole.offset)
2667
+ // other hole is on the left side
2668
+ distArray.distLeft = Math.min(distArray.distLeft, pointsDistance(chsp.x, chsp.y, hep.x, hep.y));
2669
+ // other hole is on the right side
2670
+ else distArray.distRight = Math.min(distArray.distRight, pointsDistance(chep.x, chep.y, hsp.x, hsp.y));
2671
+ }
2672
+ }
2673
+ });
2674
+ return distArray;
2675
+ }
2676
+ export function getSnappedWallLines(item, layer, catalog) {
2677
+ var _element;
2678
+ var snappedWallLines = [];
2679
+ if (isEmpty(item)) return snappedWallLines;
2680
+ var vertexLines = getAllLines(layer);
2681
+ var rectLines = buildRectFromLines(layer, vertexLines);
2682
+ var outline = null;
2683
+ var element = catalog.elements[item.get('type')];
2684
+ if (!element) element = catalog.elements[returnReplaceableDeepSearchType(item.get('type'))];
2685
+ var newWidth = item.properties.get('width').get('_length');
2686
+ var wUnit = item.properties.get('width').get('_unit') || 'cm';
2687
+ newWidth = convert(newWidth).from(wUnit).to('cm');
2688
+ var newDepth = item.properties.get('depth').get('_length');
2689
+ var hUnit = item.properties.get('depth').get('_unit') || 'cm';
2690
+ newDepth = convert(newDepth).from(hUnit).to('cm');
2691
+ var overlapList = [OVERLAP_INCLUDED, OVERLAP_SAME, OVERLAP_SOME];
2692
+
2693
+ // Get Outline Data of Selected Item
2694
+ outline = (_element = element) === null || _element === void 0 || (_element = _element.info) === null || _element === void 0 ? void 0 : _element.outline;
2695
+ if (outline) {
2696
+ // Extract Points from `outline`
2697
+ var outlinePaths = outline.paths;
2698
+ var outlineWidth = outline.svgWidth;
2699
+ var outlineHeight = outline.svgHeight;
2700
+ var outlinePoints = []; // Hold Points Of SVG
2701
+ var _iterator7 = _createForOfIteratorHelper(outlinePaths),
2702
+ _step7;
2703
+ try {
2704
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
2705
+ var path = _step7.value;
2706
+ var _iterator8 = _createForOfIteratorHelper(path.subPaths),
2707
+ _step8;
2708
+ try {
2709
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
2710
+ var subPath = _step8.value;
2711
+ outlinePoints = outlinePoints.concat(subPath.getPoints());
2712
+ }
2713
+ } catch (err) {
2714
+ _iterator8.e(err);
2715
+ } finally {
2716
+ _iterator8.f();
2717
+ }
2718
+ }
2719
+ } catch (err) {
2720
+ _iterator7.e(err);
2721
+ } finally {
2722
+ _iterator7.f();
2723
+ }
2724
+ outline.reverse && outlinePoints.reverse();
2725
+ for (var i = 0; i < outlinePoints.length - 1; i++) {
2726
+ var v0 = rotatePointAroundPoint((outlinePoints[i].x / outlineWidth - 0.5) * newWidth + item.x, (outlinePoints[i].y / outlineHeight - 0.5) * newDepth + item.y, item.x, item.y, item.rotation + 90);
2727
+ var v1 = rotatePointAroundPoint((outlinePoints[i + 1].x / outlineWidth - 0.5) * newWidth + item.x, (outlinePoints[i + 1].y / outlineHeight - 0.5) * newDepth + item.y, item.x, item.y, item.rotation + 90);
2728
+ var srcLine = {
2729
+ x1: v0.x,
2730
+ y1: v0.y,
2731
+ x2: v1.x,
2732
+ y2: v1.y
2733
+ };
2734
+ var _loop2 = function _loop2(j) {
2735
+ var destLine1 = {
2736
+ x1: rectLines[j].rect[2].x,
2737
+ y1: rectLines[j].rect[3].y,
2738
+ x2: v1.x,
2739
+ y2: v1.y
2740
+ };
2741
+ var destLine2 = {
2742
+ x1: rectLines[j].rect[0].x,
2743
+ y1: rectLines[j].rect[1].y,
2744
+ x2: v1.x,
2745
+ y2: v1.y
2746
+ };
2747
+ if (overlapList.includes(relationshipOfTwoOverlappedLines(srcLine, destLine1).result) || overlapList.includes(relationshipOfTwoOverlappedLines(srcLine, destLine2).result)) {
2748
+ var idx = snappedWallLines.findIndex(function (v) {
2749
+ return v.id === rectLines[j].lineId;
2750
+ });
2751
+ var snapSide = 'unknown';
2752
+ if (idx < 0) snappedWallLines.push({
2753
+ id: rectLines[j].lineId,
2754
+ snapSide: snapSide
2755
+ });else snappedWallLines[idx].snapSide = snapSide;
2756
+ }
2757
+ };
2758
+ for (var j = 0; j < (rectLines === null || rectLines === void 0 ? void 0 : rectLines.length); j++) {
2759
+ _loop2(j);
2760
+ }
2761
+ }
2762
+ } else {
2763
+ var pos = [[-1, -1], [1, -1], [1, 1], [-1, 1]];
2764
+ for (var _i = 0; _i < 4; _i++) {
2765
+ var _v = rotatePointAroundPoint(pos[_i][0] * newWidth / 2 + item.x, pos[_i][1] * newDepth / 2 + item.y, item.x, item.y, item.rotation);
2766
+ var _v2 = rotatePointAroundPoint(pos[(_i + 1) % 4][0] * newWidth / 2 + item.x, pos[(_i + 1) % 4][1] * newDepth / 2 + item.y, item.x, item.y, item.rotation);
2767
+ var _srcLine = {
2768
+ x1: _v.x,
2769
+ y1: _v.y,
2770
+ x2: _v2.x,
2771
+ y2: _v2.y
2772
+ };
2773
+ var _loop3 = function _loop3(_j) {
2774
+ var destLine1 = {
2775
+ x1: rectLines[_j].rect[2].x,
2776
+ y1: rectLines[_j].rect[2].y,
2777
+ x2: rectLines[_j].rect[3].x,
2778
+ y2: rectLines[_j].rect[3].y
2779
+ };
2780
+ var destLine2 = {
2781
+ x1: rectLines[_j].rect[0].x,
2782
+ y1: rectLines[_j].rect[0].y,
2783
+ x2: rectLines[_j].rect[1].x,
2784
+ y2: rectLines[_j].rect[1].y
2785
+ };
2786
+ if (overlapList.includes(relationshipOfTwoOverlappedLines(_srcLine, destLine1).result) || overlapList.includes(relationshipOfTwoOverlappedLines(_srcLine, destLine2).result)) {
2787
+ var idx = snappedWallLines.findIndex(function (v) {
2788
+ return v.id === rectLines[_j].lineId;
2789
+ });
2790
+ var snapSide = _i === 0 || _i === 2 ? 'front' : 'side';
2791
+ if (idx < 0) snappedWallLines.push({
2792
+ id: rectLines[_j].lineId,
2793
+ snapSide: snapSide
2794
+ });else snappedWallLines[idx].snapSide = snapSide;
2795
+ }
2796
+ };
2797
+ for (var _j = 0; _j < (rectLines === null || rectLines === void 0 ? void 0 : rectLines.length); _j++) {
2798
+ _loop3(_j);
2799
+ }
2800
+ }
2801
+ }
2802
+ return snappedWallLines;
2609
2803
  }
@@ -1,13 +1,25 @@
1
- import { Map } from 'immutable';
1
+ import { List, Map } from 'immutable';
2
2
  import diff from 'immutablediff';
3
3
  import patch from 'immutablepatch';
4
4
  export var historyPush = function historyPush(historyStructure, item) {
5
5
  if (historyStructure.last) {
6
6
  if (historyStructure.last.hashCode() !== item.hashCode()) {
7
+ var _toPush$get;
7
8
  var toPush = new Map({
8
9
  time: Date.now(),
9
10
  diff: diff(historyStructure.last, item)
10
11
  });
12
+
13
+ // convert map to object of the [value] field
14
+ if (List.isList(toPush.get('diff')) && ((_toPush$get = toPush.get('diff')) === null || _toPush$get === void 0 ? void 0 : _toPush$get.size) > 1) {
15
+ for (var i = 0; i < toPush.get('diff').size; i++) {
16
+ var mapValue = toPush.get('diff').get(i).get('value');
17
+ if (Map.isMap(mapValue)) {
18
+ var jsValue = mapValue.toJS();
19
+ toPush = toPush.setIn(['diff', i, 'value'], jsValue);
20
+ }
21
+ }
22
+ }
11
23
  historyStructure = historyStructure.set('last', item).set('list', historyStructure.list.push(toPush));
12
24
  }
13
25
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "7.0.9-react-18",
3
+ "version": "11.0.0-react.18",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "module": "es/index.js",