kitchen-simulator 1.1.1-test.38 → 1.1.1-test.40

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.
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import * as PropTypes from 'prop-types';
3
3
  import polylabel from 'polylabel';
4
- import areapolygon from 'area-polygon';
5
4
  import convert from 'convert-units';
6
5
  import { formatNumber } from "../../utils/math";
7
6
  import { DECIMAL_PLACES_2 } from "../../constants";
7
+ import { areaPolygon } from "./utils";
8
8
  var STYLE_TEXT = {
9
9
  textAnchor: 'middle',
10
10
  fontSize: '12px',
@@ -44,7 +44,7 @@ export default function Area(_ref) {
44
44
  polygonWithHoles = polygonWithHoles.concat(polygonHole.reverse());
45
45
  });
46
46
  var center = polylabel([polygonWithHoles], 1.0);
47
- var areaSize = areapolygon(polygon, false);
47
+ var areaSize = areaPolygon(polygon, false);
48
48
  //subtract holes area
49
49
  area.holes.forEach(function (areaID) {
50
50
  var hole = layer.areas.get(areaID);
@@ -54,7 +54,7 @@ export default function Area(_ref) {
54
54
  y = _layer$vertices$get3.y;
55
55
  return [x, y];
56
56
  });
57
- areaSize -= areapolygon(holePolygon, false);
57
+ areaSize -= areaPolygon(holePolygon, false);
58
58
  });
59
59
  renderedAreaSize = /*#__PURE__*/React.createElement("text", {
60
60
  x: "0",
@@ -1,5 +1,11 @@
1
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
5
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
6
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
1
7
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- import { isImmutable, toPlainObject } from "../../utils/helper";
8
+ import { toPlainObject } from "../../utils/helper";
3
9
  import { INSTALLATION_SUFFIX_TYPE, INSTALLATION_TYPE_NAME, INSTALLATION_TYPE_SKU_SUFFIX, TOE_KICK_MOLDING } from "../../constants";
4
10
  export var searchForSkuValue = function searchForSkuValue(catalog, selectedLayer, elementType) {
5
11
  return new Promise(function (resolve) {
@@ -159,4 +165,34 @@ export var getToeKickSKU = function getToeKickSKU() {
159
165
  });
160
166
  if (!skuData) return false;
161
167
  return skuData;
168
+ };
169
+
170
+ // ESM version of "area-polygon" with default + named export.
171
+ // Same behavior: takes an array of [x,y] tuples or {x,y} objects.
172
+ // If `signed` is truthy, returns signed area; otherwise absolute area.
173
+ // Does not mutate the input array.
174
+
175
+ function normalize(point) {
176
+ if (Array.isArray(point)) {
177
+ return {
178
+ x: point[0],
179
+ y: point[1]
180
+ };
181
+ }
182
+ return point;
183
+ }
184
+ export var areaPolygon = function areaPolygon(points) {
185
+ var signed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
186
+ if (!Array.isArray(points) || points.length < 3) return 0;
187
+
188
+ // normalize and ensure closed ring (without mutating input)
189
+ var pts = points.map(normalize);
190
+ var closed = pts.length > 0 && (pts[0].x !== pts[pts.length - 1].x || pts[0].y !== pts[pts.length - 1].y) ? [].concat(_toConsumableArray(pts), [pts[0]]) : pts;
191
+ var det = 0;
192
+ var l = closed.length - 1; // last index before the duplicated first point
193
+ for (var i = 0; i < l; i++) {
194
+ det += closed[i].x * closed[i + 1].y - closed[i].y * closed[i + 1].x;
195
+ }
196
+ var area = det / 2;
197
+ return signed ? area : Math.abs(area);
162
198
  };
@@ -8,10 +8,10 @@ exports["default"] = Area;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var PropTypes = _interopRequireWildcard(require("prop-types"));
10
10
  var _polylabel = _interopRequireDefault(require("polylabel"));
11
- var _areaPolygon = _interopRequireDefault(require("area-polygon"));
12
11
  var _convertUnits = _interopRequireDefault(require("convert-units"));
13
12
  var _math = require("../../utils/math");
14
13
  var _constants = require("../../constants");
14
+ var _utils = require("./utils");
15
15
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
16
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
17
17
  var STYLE_TEXT = {
@@ -53,7 +53,7 @@ function Area(_ref) {
53
53
  polygonWithHoles = polygonWithHoles.concat(polygonHole.reverse());
54
54
  });
55
55
  var center = (0, _polylabel["default"])([polygonWithHoles], 1.0);
56
- var areaSize = (0, _areaPolygon["default"])(polygon, false);
56
+ var areaSize = (0, _utils.areaPolygon)(polygon, false);
57
57
  //subtract holes area
58
58
  area.holes.forEach(function (areaID) {
59
59
  var hole = layer.areas.get(areaID);
@@ -63,7 +63,7 @@ function Area(_ref) {
63
63
  y = _layer$vertices$get3.y;
64
64
  return [x, y];
65
65
  });
66
- areaSize -= (0, _areaPolygon["default"])(holePolygon, false);
66
+ areaSize -= (0, _utils.areaPolygon)(holePolygon, false);
67
67
  });
68
68
  renderedAreaSize = /*#__PURE__*/_react["default"].createElement("text", {
69
69
  x: "0",
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.areaPolygon = void 0;
6
7
  exports.getInstallationSuffix = getInstallationSuffix;
7
8
  exports.getToeKickSKU = void 0;
8
9
  exports.isEmpty = isEmpty;
@@ -11,6 +12,12 @@ exports.makeSKUForMagento = makeSKUForMagento;
11
12
  exports.searchForSkuValue = exports.returnReplaceableDeepSearchType = void 0;
12
13
  var _helper = require("../../utils/helper");
13
14
  var _constants = require("../../constants");
15
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
16
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
17
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
18
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
19
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
20
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
14
21
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
15
22
  var searchForSkuValue = exports.searchForSkuValue = function searchForSkuValue(catalog, selectedLayer, elementType) {
16
23
  return new Promise(function (resolve) {
@@ -170,4 +177,34 @@ var getToeKickSKU = exports.getToeKickSKU = function getToeKickSKU() {
170
177
  });
171
178
  if (!skuData) return false;
172
179
  return skuData;
180
+ };
181
+
182
+ // ESM version of "area-polygon" with default + named export.
183
+ // Same behavior: takes an array of [x,y] tuples or {x,y} objects.
184
+ // If `signed` is truthy, returns signed area; otherwise absolute area.
185
+ // Does not mutate the input array.
186
+
187
+ function normalize(point) {
188
+ if (Array.isArray(point)) {
189
+ return {
190
+ x: point[0],
191
+ y: point[1]
192
+ };
193
+ }
194
+ return point;
195
+ }
196
+ var areaPolygon = exports.areaPolygon = function areaPolygon(points) {
197
+ var signed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
198
+ if (!Array.isArray(points) || points.length < 3) return 0;
199
+
200
+ // normalize and ensure closed ring (without mutating input)
201
+ var pts = points.map(normalize);
202
+ var closed = pts.length > 0 && (pts[0].x !== pts[pts.length - 1].x || pts[0].y !== pts[pts.length - 1].y) ? [].concat(_toConsumableArray(pts), [pts[0]]) : pts;
203
+ var det = 0;
204
+ var l = closed.length - 1; // last index before the duplicated first point
205
+ for (var i = 0; i < l; i++) {
206
+ det += closed[i].x * closed[i + 1].y - closed[i].y * closed[i + 1].x;
207
+ }
208
+ var area = det / 2;
209
+ return signed ? area : Math.abs(area);
173
210
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "1.1.1-test.38",
3
+ "version": "1.1.1-test.40",
4
4
  "description": "It is a kitchen simulator.",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -67,18 +67,17 @@
67
67
  "immutablepatch": "0.5.0",
68
68
  "convert-units": "2.3.4",
69
69
  "hoist-non-react-statics": "2.5.5",
70
- "invariant": "^2.0.0"
70
+ "invariant": "^2.0.0",
71
+ "polylabel": "1.0.2"
71
72
  },
72
73
  "dependencies": {
73
74
  "@sentry/react": "^9.10.1",
74
- "area-polygon": "1.0.1",
75
75
  "axios": "^0.20.0",
76
76
  "browserify-zlib": "^0.2.0",
77
77
  "camera-controls": "^2.8.5",
78
78
  "dotenv": "^16.4.7",
79
79
  "history": "4.10.1",
80
80
  "path-browserify": "^1.0.1",
81
- "polylabel": "1.0.2",
82
81
  "posthog-js": "^1.271.0",
83
82
  "react-ga4": "^1.4.1",
84
83
  "react-hotjar": "^1.0.11",
@@ -91,6 +90,7 @@
91
90
  "localstorage-slim": "^1.3.0"
92
91
  },
93
92
  "devDependencies": {
93
+ "polylabel": "1.0.2",
94
94
  "convert-units": "2.3.4",
95
95
  "immutable": "3.8.2",
96
96
  "immutablediff": "0.4.4",