hart-estate-widget 0.0.48 → 0.0.51

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.
@@ -5,10 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getScale = exports.getRoomCoordinates = exports.getClosestPanorama = exports.getCameraFromSrc = exports.getArrayFromNumber = exports.findWallVertices = exports.cameraIdBeginning = void 0;
7
7
 
8
- require("core-js/modules/web.dom-collections.iterator.js");
9
-
10
- require("core-js/modules/es.array.reduce.js");
11
-
12
8
  var _react = _interopRequireDefault(require("react"));
13
9
 
14
10
  var _geometric = require("geometric");
@@ -17,27 +13,49 @@ var _imageExtentions = require("../enums/imageExtentions");
17
13
 
18
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
15
 
20
- const cameraIdBeginning = 'CameraId';
16
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
17
+
18
+ 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."); }
19
+
20
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
21
+
22
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
23
+
24
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
25
+
26
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
27
+
28
+ var cameraIdBeginning = 'cameraid';
21
29
  exports.cameraIdBeginning = cameraIdBeginning;
22
30
 
23
- const getArrayFromNumber = num => [...Array(num).keys()];
31
+ var getArrayFromNumber = function getArrayFromNumber(num) {
32
+ return _toConsumableArray(Array(num).keys());
33
+ };
24
34
 
25
35
  exports.getArrayFromNumber = getArrayFromNumber;
26
36
 
27
- const findWallVertices = (walls, wall, vertices) => {
28
- const currentWall = walls.find(el => el.ID === wall);
29
- return currentWall.Vertices.map(vertexId => {
30
- const vertex = vertices.find(el => el.ID === vertexId);
37
+ var findWallVertices = function findWallVertices(walls, wall, vertices) {
38
+ var currentWall = walls.find(function (el) {
39
+ return el.ID === wall;
40
+ });
41
+ return currentWall.Vertices.map(function (vertexId) {
42
+ var vertex = vertices.find(function (el) {
43
+ return el.ID === vertexId;
44
+ });
31
45
  return [vertex.Location.X, vertex.Location.Y];
32
46
  });
33
47
  };
34
48
 
35
49
  exports.findWallVertices = findWallVertices;
36
50
 
37
- const getRoomCoordinates = (room, walls, vertices) => {
38
- const points = room.Walls.reduce((acc, wallId) => {
39
- const wall = walls.find(wallObject => wallObject.ID === wallId);
40
- findWallVertices(walls, wall.ID, vertices).forEach(vertex => acc.push(vertex));
51
+ var getRoomCoordinates = function getRoomCoordinates(room, walls, vertices) {
52
+ var points = room.Walls.reduce(function (acc, wallId) {
53
+ var wall = walls.find(function (wallObject) {
54
+ return wallObject.ID === wallId;
55
+ });
56
+ findWallVertices(walls, wall.ID, vertices).forEach(function (vertex) {
57
+ return acc.push(vertex);
58
+ });
41
59
  return acc;
42
60
  }, []);
43
61
  return points;
@@ -45,17 +63,17 @@ const getRoomCoordinates = (room, walls, vertices) => {
45
63
 
46
64
  exports.getRoomCoordinates = getRoomCoordinates;
47
65
 
48
- const getScale = (image, json) => {
66
+ var getScale = function getScale(image, json) {
49
67
  if (!json) return {
50
68
  X: 1,
51
69
  Y: 1
52
70
  };
53
- const imageWidth = image.width;
54
- const imageHeight = image.height;
55
- const baseImageWidth = 1024;
56
- const baseImageHeight = imageHeight * (baseImageWidth / imageWidth);
57
- const deltaX = imageWidth / baseImageWidth / json.Scale.X;
58
- const deltaY = imageHeight / baseImageHeight / json.Scale.X;
71
+ var imageWidth = image.width;
72
+ var imageHeight = image.height;
73
+ var baseImageWidth = 1024;
74
+ var baseImageHeight = imageHeight * (baseImageWidth / imageWidth);
75
+ var deltaX = imageWidth / baseImageWidth / json.Scale.X;
76
+ var deltaY = imageHeight / baseImageHeight / json.Scale.X;
59
77
  return {
60
78
  X: deltaX,
61
79
  Y: deltaY
@@ -64,30 +82,28 @@ const getScale = (image, json) => {
64
82
 
65
83
  exports.getScale = getScale;
66
84
 
67
- const getCameraFromSrc = (json, src) => {
85
+ var getCameraFromSrc = function getCameraFromSrc(json, src) {
68
86
  var _json$Floors$0$Camera;
69
87
 
70
- const cameraIdIndex = src.indexOf(cameraIdBeginning);
88
+ var cameraIdIndex = src.toLowerCase().indexOf(cameraIdBeginning);
71
89
  if (cameraIdIndex === -1) return null;
72
- const cameraId = (0, _imageExtentions.removeExtention)(src.substring(cameraIdIndex));
73
- return ((_json$Floors$0$Camera = json.Floors[0].CameraPoints) === null || _json$Floors$0$Camera === void 0 ? void 0 : _json$Floors$0$Camera.find(_ref => {
74
- let {
75
- ID
76
- } = _ref;
90
+ var cameraId = (0, _imageExtentions.removeExtention)(src.substring(cameraIdIndex));
91
+ return ((_json$Floors$0$Camera = json.Floors[0].CameraPoints) === null || _json$Floors$0$Camera === void 0 ? void 0 : _json$Floors$0$Camera.find(function (_ref) {
92
+ var ID = _ref.ID;
77
93
  return ID === cameraId;
78
94
  })) || null;
79
95
  };
80
96
 
81
97
  exports.getCameraFromSrc = getCameraFromSrc;
82
98
 
83
- const getClosestPanorama = (point, panoramas) => {
84
- return panoramas.reduce((closest, current) => {
85
- const length = (0, _geometric.lineLength)([point, [current.userData.left, current.userData.top]]);
99
+ var getClosestPanorama = function getClosestPanorama(point, panoramas) {
100
+ return panoramas.reduce(function (closest, current) {
101
+ var length = (0, _geometric.lineLength)([point, [current.userData.left, current.userData.top]]);
86
102
 
87
103
  if (length < closest.length) {
88
104
  return {
89
105
  panorama: current,
90
- length
106
+ length: length
91
107
  };
92
108
  }
93
109
 
package/package.json CHANGED
@@ -3,21 +3,18 @@
3
3
  "description": "HART Estate widget",
4
4
  "author": "HART",
5
5
  "keywords": [],
6
- "version": "0.0.48",
6
+ "version": "0.0.51",
7
7
  "private": false,
8
8
  "main": "build/index.js",
9
9
  "module": "build/index.js",
10
- "exports": "./build/index.js",
11
- "type": "module",
12
10
  "files": [
13
11
  "build",
14
12
  "README.md"
15
13
  ],
16
14
  "scripts": {
17
- "babel": "babel src --out-dir build --copy-files",
18
- "start": "npm run build:sass && npm run babel -- --watch",
15
+ "start": "npm run build:sass && babel src --watch -d build --copy-files",
19
16
  "start-example": "cd ./example && npm run start",
20
- "build": "rm -rf build && NODE_ENV=production npm run babel && npm run build:sass",
17
+ "build": "rm -rf build && NODE_ENV=production babel src -d build --copy-files && npm run build:sass",
21
18
  "build:sass": "sass src/assets/sass/index.sass:build/assets/css/app.css --style compressed",
22
19
  "local-tunnel": "Lt --port 9000 --subdomain estate-widget --local-host localhost"
23
20
  },
@@ -42,18 +39,11 @@
42
39
  "@babel/core": "^7.17.0",
43
40
  "@babel/eslint-parser": "^7.16.3",
44
41
  "@babel/preset-env": "^7.16.11",
45
- "babel-loader": "^8.2.3",
46
- "css-loader": "^6.6.0",
47
42
  "eslint": "^8.0.0",
48
43
  "eslint-config-react-app": "^7.0.0",
49
44
  "eslint-plugin-react": "^7.28.0",
50
45
  "path": "^0.12.7",
51
- "sass": "^1.46.0",
52
- "sass-loader": "^12.4.0",
53
- "style-loader": "^3.3.1",
54
- "webpack": "^5.68.0",
55
- "webpack-cli": "^4.9.2",
56
- "webpack-dev-server": "^4.7.4"
46
+ "sass": "^1.46.0"
57
47
  },
58
48
  "browserslist": [
59
49
  ">0.2%",