@cloud-app-dev/vidc 4.0.7 → 4.0.9

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.
Files changed (119) hide show
  1. package/.dumirc.ts +0 -10
  2. package/.fatherrc.ts +1 -4
  3. package/es/AppContext/Sync.js +10 -24
  4. package/es/AppContext/index.js +19 -19
  5. package/es/AppContext/static.js +0 -6
  6. package/es/Auth/index.js +2 -5
  7. package/es/AutoExit/index.js +2 -2
  8. package/es/CheckGroupFixed/demo.js +0 -2
  9. package/es/CheckGroupFixed/index.js +25 -42
  10. package/es/CustomRenderSelect/index.js +2 -2
  11. package/es/DisableMark/index.js +2 -2
  12. package/es/DomMove/index.js +31 -42
  13. package/es/DomMove/utils.js +3 -8
  14. package/es/Drag/DragAndDropItem.js +28 -45
  15. package/es/Drag/DropItem.js +11 -21
  16. package/es/DynamicGridList/Demo.js +1 -13
  17. package/es/DynamicList/demo.js +1 -10
  18. package/es/DynamicList/index.js +27 -41
  19. package/es/ErrorFallback/index.js +1 -3
  20. package/es/EventTools/index.d.ts +3 -0
  21. package/es/EventTools/index.js +12 -0
  22. package/es/GridList/Demo.js +5 -18
  23. package/es/GridList/utils.js +0 -1
  24. package/es/HightLevel/index.js +1 -5
  25. package/es/IconFont/index.js +9 -18
  26. package/es/InstanceHistory/index.js +0 -2
  27. package/es/ListWithSizeAnimate/index.js +15 -31
  28. package/es/LoaderScript/index.js +10 -21
  29. package/es/LoaderScript/utils.js +2 -2
  30. package/es/Map/BasicMap/AMapInstance.js +6 -16
  31. package/es/Map/BasicMap/LeafletInstance.js +16 -26
  32. package/es/Map/ClusterLayer/hook.js +16 -38
  33. package/es/Map/ClusterLayer/index.js +2 -6
  34. package/es/Map/Context/index.js +6 -30
  35. package/es/Map/FindPio/index.js +0 -2
  36. package/es/Map/LevelCenter/DragMarker/index.js +6 -9
  37. package/es/Map/LevelCenter/demo.js +12 -21
  38. package/es/Map/LevelCenter/index.js +8 -14
  39. package/es/Map/LoaderMap/index.js +14 -17
  40. package/es/Map/MapDrawSelect/demo.js +14 -25
  41. package/es/Map/MapDrawSelect/index.js +14 -20
  42. package/es/Map/MouseTool/index.js +17 -27
  43. package/es/Map/MouseTool/useMouseTools.js +12 -35
  44. package/es/Map/ResetTools/index.js +4 -8
  45. package/es/Map/SinglePoint/index.js +6 -13
  46. package/es/Map/hook/useMapEvent.js +3 -7
  47. package/es/Map/hook/useMapType.js +1 -2
  48. package/es/Map/useMarker/index.js +17 -30
  49. package/es/Map/withMap/index.js +4 -6
  50. package/es/Picture/component/DefaultRects/RectInfo.js +13 -27
  51. package/es/Picture/component/DefaultRects/index.js +7 -10
  52. package/es/Picture/component/DrawRect/index.js +10 -13
  53. package/es/Picture/component/RectMenu/index.js +10 -15
  54. package/es/Picture/component/RectMenu/utils.js +3 -6
  55. package/es/Picture/component/WheelScale/index.js +3 -5
  56. package/es/Picture/loadCaptureRectImage.js +42 -61
  57. package/es/Picture/useDraw.js +23 -39
  58. package/es/Player/api/index.js +2 -2
  59. package/es/Player/context.js +5 -9
  60. package/es/Player/contraller_bar/bar.js +9 -16
  61. package/es/Player/contraller_bar/contraller_event.js +7 -25
  62. package/es/Player/contraller_bar/index.js +7 -9
  63. package/es/Player/contraller_bar/left_bar.js +17 -29
  64. package/es/Player/contraller_bar/time.js +5 -14
  65. package/es/Player/contraller_bar/useBarStatus.js +12 -24
  66. package/es/Player/contraller_bar/volume.js +9 -29
  67. package/es/Player/event/eventName.js +1 -1
  68. package/es/Player/event/index.js +28 -63
  69. package/es/Player/frontend_player.js +16 -27
  70. package/es/Player/iconfont.js +6 -12
  71. package/es/Player/live_heart.js +2 -18
  72. package/es/Player/message.js +15 -35
  73. package/es/Player/segment_player.js +48 -86
  74. package/es/Player/single_player.js +1 -1
  75. package/es/Player/timeline.js +19 -41
  76. package/es/PlayerExt/demo.js +15 -25
  77. package/es/PlayerExt/index.js +29 -51
  78. package/es/ROI/demo.js +0 -2
  79. package/es/ScreenPlayer/RatePick.js +8 -10
  80. package/es/ScreenPlayer/Record.js +11 -32
  81. package/es/ScreenPlayer/TimeMode.js +1 -3
  82. package/es/ScreenPlayer/useTimeSlider.js +3 -3
  83. package/es/ScreenPlayer/useVideoFit.js +8 -21
  84. package/es/SocketEmitter/eventEmitter.d.ts +27 -0
  85. package/es/SocketEmitter/eventEmitter.js +87 -0
  86. package/es/SocketEmitter/index.d.ts +24 -0
  87. package/es/SocketEmitter/index.js +125 -0
  88. package/es/SocketEmitter/interface.d.ts +4 -0
  89. package/es/ThemeAntd/demo.js +0 -2
  90. package/es/VList/utils.js +2 -3
  91. package/es/bigNumberTransformCN/index.d.ts +5 -0
  92. package/es/bigNumberTransformCN/index.js +60 -0
  93. package/es/cache/index.d.ts +34 -0
  94. package/es/cache/index.js +94 -0
  95. package/es/copy/index.d.ts +1 -0
  96. package/es/copy/index.js +9 -0
  97. package/es/getThemeStyle/index.d.ts +2 -0
  98. package/es/getThemeStyle/index.js +5 -0
  99. package/es/index.d.ts +11 -0
  100. package/es/index.js +12 -1
  101. package/es/logger/index.d.ts +7 -0
  102. package/es/logger/index.js +30 -0
  103. package/es/nextTick/index.d.ts +1 -0
  104. package/es/nextTick/index.js +7 -0
  105. package/es/submidstr/index.d.ts +5 -0
  106. package/es/submidstr/index.js +14 -0
  107. package/es/treeHelper/index.d.ts +11 -0
  108. package/es/treeHelper/index.js +173 -0
  109. package/es/useEventEmitterHandle/index.js +5 -9
  110. package/es/useFullscreen/demo.js +8 -18
  111. package/es/useFullscreen/index.js +7 -28
  112. package/es/useHistory/index.js +0 -2
  113. package/es/useRafInterval/index.js +3 -27
  114. package/es/useSimpleState/index.js +11 -22
  115. package/es/useVirtualList/index.js +21 -57
  116. package/es/utils.js +2 -2
  117. package/es/uuid/index.d.ts +4 -0
  118. package/es/uuid/index.js +15 -0
  119. package/package.json +4 -5
@@ -2,8 +2,7 @@ import { useContext, useMemo } from 'react';
2
2
  import { mapContext } from "../Context";
3
3
  export default function useMapType() {
4
4
  var _useContext = useContext(mapContext),
5
- glaobalKey = _useContext.glaobalKey;
6
-
5
+ glaobalKey = _useContext.glaobalKey;
7
6
  return useMemo(function () {
8
7
  return {
9
8
  leaflet: glaobalKey === 'L',
@@ -1,50 +1,40 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
7
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
-
9
8
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
-
11
9
  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); }
12
-
13
- 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; }
14
-
15
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
16
-
10
+ 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; }
11
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
17
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
-
19
13
  // eslint-disable-next-line @typescript-eslint/triple-slash-reference
20
14
  /// <reference path="../AMap.d.ts" />
15
+
21
16
  import { useEffect, useRef, useState } from 'react';
22
17
  import useMapType from "../hook/useMapType";
23
-
24
18
  function useMarker(_ref) {
25
19
  var map = _ref.map,
26
- center = _ref.center,
27
- createIcon = _ref.createIcon,
28
- options = _ref.options;
29
-
20
+ center = _ref.center,
21
+ createIcon = _ref.createIcon,
22
+ options = _ref.options;
30
23
  var _useState = useState({
31
- marker: null
32
- }),
33
- _useState2 = _slicedToArray(_useState, 2),
34
- state = _useState2[0],
35
- setState = _useState2[1];
36
-
24
+ marker: null
25
+ }),
26
+ _useState2 = _slicedToArray(_useState, 2),
27
+ state = _useState2[0],
28
+ setState = _useState2[1];
37
29
  var inMap = useRef(false);
38
30
  var type = useMapType();
39
31
  useEffect(function () {
40
32
  if (!(center && center.length === 2) || !map) {
41
33
  return;
42
34
  }
43
-
44
35
  if (type.leaflet) {
45
36
  var L = window.L;
46
37
  var latlng = L.latLng(center);
47
-
48
38
  if (inMap.current) {
49
39
  state.marker.setLatLng(latlng);
50
40
  } else {
@@ -60,7 +50,6 @@ function useMarker(_ref) {
60
50
  inMap.current = true;
61
51
  }
62
52
  }
63
-
64
53
  if (type.AMap) {
65
54
  if (inMap.current) {
66
55
  state.marker.setPosition(center);
@@ -68,17 +57,15 @@ function useMarker(_ref) {
68
57
  var _marker = new AMap.Marker(_objectSpread({
69
58
  position: center
70
59
  }, options));
71
-
72
60
  map.add(_marker);
73
61
  setState({
74
62
  marker: _marker
75
63
  });
76
64
  inMap.current = true;
77
65
  }
78
- } // eslint-disable-next-line react-hooks/exhaustive-deps
79
-
66
+ }
67
+ // eslint-disable-next-line react-hooks/exhaustive-deps
80
68
  }, [center, map, options]);
81
69
  return state.marker;
82
70
  }
83
-
84
71
  export default useMarker;
@@ -1,13 +1,12 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
7
  import React from 'react';
8
8
  import Map from "../BasicMap";
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
-
11
10
  function withMap(Component, className) {
12
11
  return function withMapComponent(props) {
13
12
  return /*#__PURE__*/_jsx(Map, {
@@ -16,5 +15,4 @@ function withMap(Component, className) {
16
15
  });
17
16
  };
18
17
  }
19
-
20
18
  export default withMap;
@@ -1,15 +1,9 @@
1
1
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
-
3
2
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
-
5
3
  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); }
6
-
7
- 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; }
8
-
9
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
-
4
+ 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; }
5
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
11
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
-
13
7
  import React, { useMemo } from 'react';
14
8
  import IconFont from "../../../IconFont";
15
9
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -17,42 +11,35 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
17
11
  var RECT_INFO_WIDTH = 150;
18
12
  var RECT_INFO_HEIGHT = 24;
19
13
  var RECT_WINDOW_MARGIN = 6;
20
-
21
14
  function RectInfo(_ref) {
22
15
  var item = _ref.item,
23
- containerDom = _ref.containerDom;
16
+ containerDom = _ref.containerDom;
24
17
  var position = useMemo(function () {
25
18
  var _containerDom$getBoun = containerDom.getBoundingClientRect(),
26
- width = _containerDom$getBoun.width,
27
- height = _containerDom$getBoun.height;
28
-
19
+ width = _containerDom$getBoun.width,
20
+ height = _containerDom$getBoun.height;
29
21
  var _rectInfoWidth$rectIn = {
30
- rectInfoWidth: RECT_INFO_WIDTH,
31
- rectInfoHeight: item.tags.length * RECT_INFO_HEIGHT + 6 + 30
32
- },
33
- rectInfoWidth = _rectInfoWidth$rectIn.rectInfoWidth,
34
- rectInfoHeight = _rectInfoWidth$rectIn.rectInfoHeight;
35
-
22
+ rectInfoWidth: RECT_INFO_WIDTH,
23
+ rectInfoHeight: item.tags.length * RECT_INFO_HEIGHT + 6 + 30
24
+ },
25
+ rectInfoWidth = _rectInfoWidth$rectIn.rectInfoWidth,
26
+ rectInfoHeight = _rectInfoWidth$rectIn.rectInfoHeight;
36
27
  var _item$rect = _slicedToArray(item.rect, 3),
37
- rectLeft = _item$rect[0],
38
- rectTop = _item$rect[1],
39
- rectWidth = _item$rect[2];
40
-
28
+ rectLeft = _item$rect[0],
29
+ rectTop = _item$rect[1],
30
+ rectWidth = _item$rect[2];
41
31
  var x, y;
42
-
43
32
  if (rectWidth + rectLeft + rectInfoWidth < width) {
44
33
  x = rectWidth + rectLeft + RECT_WINDOW_MARGIN;
45
34
  } else {
46
35
  x = rectLeft - RECT_WINDOW_MARGIN - rectInfoWidth;
47
36
  }
48
-
49
37
  if (rectTop + rectInfoHeight < height) {
50
38
  y = rectTop;
51
39
  y = y < 0 ? RECT_WINDOW_MARGIN : y;
52
40
  } else {
53
41
  y = height - rectInfoHeight;
54
42
  }
55
-
56
43
  return {
57
44
  x: x,
58
45
  y: y,
@@ -98,5 +85,4 @@ function RectInfo(_ref) {
98
85
  })]
99
86
  });
100
87
  }
101
-
102
88
  export default RectInfo;
@@ -1,9 +1,9 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
7
  import React, { useCallback, useMemo } from 'react';
8
8
  import RectInfo from "./RectInfo";
9
9
  import { computedZIndex } from "./utils";
@@ -11,18 +11,16 @@ import "./index.less";
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
12
  import { jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { Fragment as _Fragment } from "react/jsx-runtime";
14
-
15
14
  function DefaultRects(_ref) {
16
15
  var rects = _ref.rects,
17
- containerDom = _ref.containerDom,
18
- onClickRect = _ref.onClickRect,
19
- getRectImage = _ref.getRectImage;
16
+ containerDom = _ref.containerDom,
17
+ onClickRect = _ref.onClickRect,
18
+ getRectImage = _ref.getRectImage;
20
19
  var renderRects = useMemo(function () {
21
20
  return computedZIndex(rects);
22
21
  }, [rects]);
23
22
  var rectClick = useCallback(function (e, item) {
24
23
  var _getRectImage;
25
-
26
24
  e.stopPropagation();
27
25
  onClickRect === null || onClickRect === void 0 ? void 0 : onClickRect(_objectSpread(_objectSpread({}, item), {}, {
28
26
  base64: (_getRectImage = getRectImage(item.rect)) !== null && _getRectImage !== void 0 ? _getRectImage : ''
@@ -57,5 +55,4 @@ function DefaultRects(_ref) {
57
55
  })
58
56
  });
59
57
  }
60
-
61
58
  export default DefaultRects;
@@ -1,24 +1,23 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
7
  import React, { useCallback, useMemo } from 'react';
8
8
  import RectMenu from "../RectMenu";
9
9
  import "./index.less";
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  import { Fragment as _Fragment } from "react/jsx-runtime";
12
12
  import { jsxs as _jsxs } from "react/jsx-runtime";
13
-
14
13
  function DrawRect(_ref) {
15
14
  var _ref$rect = _ref.rect,
16
- rect = _ref$rect === void 0 ? [] : _ref$rect,
17
- canRenderMenu = _ref.canRenderMenu,
18
- containerDom = _ref.containerDom,
19
- onMenuClick = _ref.onMenuClick,
20
- menus = _ref.menus,
21
- getRectImage = _ref.getRectImage;
15
+ rect = _ref$rect === void 0 ? [] : _ref$rect,
16
+ canRenderMenu = _ref.canRenderMenu,
17
+ containerDom = _ref.containerDom,
18
+ onMenuClick = _ref.onMenuClick,
19
+ menus = _ref.menus,
20
+ getRectImage = _ref.getRectImage;
22
21
  var x = useMemo(function () {
23
22
  return rect[0] + rect[2];
24
23
  }, [rect]);
@@ -27,7 +26,6 @@ function DrawRect(_ref) {
27
26
  }, [rect]);
28
27
  var onMenuClickAction = useCallback(function (item) {
29
28
  var _getRectImage;
30
-
31
29
  onMenuClick === null || onMenuClick === void 0 ? void 0 : onMenuClick(_objectSpread(_objectSpread({}, item), {}, {
32
30
  base64: (_getRectImage = getRectImage(rect)) !== null && _getRectImage !== void 0 ? _getRectImage : ''
33
31
  }));
@@ -50,5 +48,4 @@ function DrawRect(_ref) {
50
48
  })]
51
49
  });
52
50
  }
53
-
54
51
  export default DrawRect;
@@ -6,20 +6,17 @@ import { jsx as _jsx } from "react/jsx-runtime";
6
6
  import { jsxs as _jsxs } from "react/jsx-runtime";
7
7
  var MENU_WIDTH = 110;
8
8
  var MENU_HEIGHT = 30;
9
-
10
9
  function RectMenu(_ref) {
11
10
  var x = _ref.x,
12
- y = _ref.y,
13
- menus = _ref.menus,
14
- containerDom = _ref.containerDom,
15
- onMenuClick = _ref.onMenuClick;
16
-
11
+ y = _ref.y,
12
+ menus = _ref.menus,
13
+ containerDom = _ref.containerDom,
14
+ onMenuClick = _ref.onMenuClick;
17
15
  var _useMemo = useMemo(function () {
18
- return containerDom.getBoundingClientRect();
19
- }, [containerDom]),
20
- width = _useMemo.width,
21
- height = _useMemo.height;
22
-
16
+ return containerDom.getBoundingClientRect();
17
+ }, [containerDom]),
18
+ width = _useMemo.width,
19
+ height = _useMemo.height;
23
20
  var size = useMemo(function () {
24
21
  return {
25
22
  w: MENU_WIDTH,
@@ -37,17 +34,16 @@ function RectMenu(_ref) {
37
34
  var domRef = useRef(null);
38
35
  var handleCancelB = useCallback(function (e) {
39
36
  return e.stopPropagation();
40
- }, []); //防止click事件冒泡到查看器
37
+ }, []);
41
38
 
39
+ //防止click事件冒泡到查看器
42
40
  useEffect(function () {
43
41
  var dom = domRef.current;
44
-
45
42
  if (dom) {
46
43
  dom.addEventListener('mousedown', handleCancelB, false);
47
44
  dom.addEventListener('mousemove', handleCancelB, false);
48
45
  dom.addEventListener('mouseup', handleCancelB, false);
49
46
  }
50
-
51
47
  return function () {
52
48
  if (dom) {
53
49
  dom.removeEventListener('mousedown', handleCancelB, false);
@@ -80,5 +76,4 @@ function RectMenu(_ref) {
80
76
  })
81
77
  });
82
78
  }
83
-
84
79
  export default RectMenu;
@@ -1,20 +1,17 @@
1
1
  export function computedMenuPosition(_ref) {
2
2
  var width = _ref.width,
3
- height = _ref.height,
4
- position = _ref.position,
5
- size = _ref.size;
3
+ height = _ref.height,
4
+ position = _ref.position,
5
+ size = _ref.size;
6
6
  var x, y;
7
7
  x = position[0];
8
8
  y = position[1];
9
-
10
9
  if (width - x < size.w) {
11
10
  x = width - size.w;
12
11
  }
13
-
14
12
  if (height - y < size.h) {
15
13
  y = height - size.h;
16
14
  }
17
-
18
15
  return {
19
16
  x: x,
20
17
  y: y
@@ -1,23 +1,22 @@
1
1
  import React, { useCallback, useEffect } from 'react';
2
2
  import { Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { jsx as _jsx } from "react/jsx-runtime";
4
-
5
4
  function WheelScale(_ref) {
6
5
  var dom = _ref.dom,
7
- setScale = _ref.setScale;
6
+ setScale = _ref.setScale;
8
7
  var onWheel = useCallback(function (e) {
9
8
  if (e.ctrlKey || e.metaKey) {
10
9
  e.preventDefault();
11
10
  e.stopPropagation();
12
11
  setScale(e.deltaY > 0 ? -0.2 : 0.2);
13
12
  }
14
- }, [setScale]); //滚轮缩放
13
+ }, [setScale]);
15
14
 
15
+ //滚轮缩放
16
16
  useEffect(function () {
17
17
  if (!dom) {
18
18
  return undefined;
19
19
  }
20
-
21
20
  dom.addEventListener('wheel', onWheel, {
22
21
  passive: false
23
22
  });
@@ -27,5 +26,4 @@ function WheelScale(_ref) {
27
26
  }, [dom, onWheel]);
28
27
  return /*#__PURE__*/_jsx(_Fragment, {});
29
28
  }
30
-
31
29
  export default WheelScale;
@@ -1,83 +1,64 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
-
3
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
4
-
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
5
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
-
7
4
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
-
9
5
  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); }
10
-
11
- 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; }
12
-
13
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
14
-
6
+ 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; }
7
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
15
8
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
-
17
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
18
-
19
10
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
20
-
21
11
  import { getCaptureRect } from "./utils";
22
12
  export function loadCaptureRectImage(_x, _x2, _x3) {
23
13
  return _loadCaptureRectImage.apply(this, arguments);
24
14
  }
25
-
26
15
  function _loadCaptureRectImage() {
27
16
  _loadCaptureRectImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(image, rect, imageType) {
28
17
  var _getCaptureRect, _getCaptureRect2, x, y, w, h, canvas, ctx, url;
29
-
30
18
  return _regeneratorRuntime().wrap(function _callee$(_context) {
31
- while (1) {
32
- switch (_context.prev = _context.next) {
33
- case 0:
34
- if (image) {
35
- _context.next = 2;
36
- break;
37
- }
38
-
39
- throw Error('image is HTMLImgElement');
40
-
41
- case 2:
42
- _getCaptureRect = getCaptureRect(rect, imageType), _getCaptureRect2 = _slicedToArray(_getCaptureRect, 4), x = _getCaptureRect2[0], y = _getCaptureRect2[1], w = _getCaptureRect2[2], h = _getCaptureRect2[3];
43
- canvas = document.createElement('canvas');
44
- ctx = canvas.getContext('2d');
45
- canvas.width = image.width;
46
- canvas.height = image.height;
47
- ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
48
- ctx.beginPath();
49
- ctx.strokeStyle = 'red';
50
- ctx.lineWidth = 3;
51
- ctx.strokeRect(x, y, w, h);
52
- url = canvas.toDataURL();
53
- setTimeout(function () {
54
- canvas.remove();
55
- canvas = null;
56
- ctx = null;
57
- }, 500);
58
- return _context.abrupt("return", url);
59
-
60
- case 15:
61
- case "end":
62
- return _context.stop();
63
- }
19
+ while (1) switch (_context.prev = _context.next) {
20
+ case 0:
21
+ if (image) {
22
+ _context.next = 2;
23
+ break;
24
+ }
25
+ throw Error('image is HTMLImgElement');
26
+ case 2:
27
+ _getCaptureRect = getCaptureRect(rect, imageType), _getCaptureRect2 = _slicedToArray(_getCaptureRect, 4), x = _getCaptureRect2[0], y = _getCaptureRect2[1], w = _getCaptureRect2[2], h = _getCaptureRect2[3];
28
+ canvas = document.createElement('canvas');
29
+ ctx = canvas.getContext('2d');
30
+ canvas.width = image.width;
31
+ canvas.height = image.height;
32
+ ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
33
+ ctx.beginPath();
34
+ ctx.strokeStyle = 'red';
35
+ ctx.lineWidth = 3;
36
+ ctx.strokeRect(x, y, w, h);
37
+ url = canvas.toDataURL();
38
+ setTimeout(function () {
39
+ canvas.remove();
40
+ canvas = null;
41
+ ctx = null;
42
+ }, 500);
43
+ return _context.abrupt("return", url);
44
+ case 15:
45
+ case "end":
46
+ return _context.stop();
64
47
  }
65
48
  }, _callee);
66
49
  }));
67
50
  return _loadCaptureRectImage.apply(this, arguments);
68
51
  }
69
-
70
52
  export function getRectImagePath(image, rect) {
71
53
  var _rect = _slicedToArray(rect, 4),
72
- x = _rect[0],
73
- y = _rect[1],
74
- w = _rect[2],
75
- h = _rect[3];
76
-
54
+ x = _rect[0],
55
+ y = _rect[1],
56
+ w = _rect[2],
57
+ h = _rect[3];
77
58
  var naturalWidth = image.naturalWidth,
78
- naturalHeight = image.naturalHeight,
79
- width = image.width,
80
- height = image.height;
59
+ naturalHeight = image.naturalHeight,
60
+ width = image.width,
61
+ height = image.height;
81
62
  var sourceSize = {
82
63
  width: naturalWidth,
83
64
  height: naturalHeight,
@@ -91,9 +72,9 @@ export function getRectImagePath(image, rect) {
91
72
  var fullCtx = fullCanvas.getContext('2d');
92
73
  fullCanvas.width = naturalWidth;
93
74
  fullCanvas.height = naturalHeight;
94
- fullCtx.save(); // fullCtx.transform;
75
+ fullCtx.save();
76
+ // fullCtx.transform;
95
77
  // document.body.appendChild(fullCanvas);
96
-
97
78
  fullCtx.translate(naturalWidth / 2, naturalHeight / 2);
98
79
  fullCtx.drawImage(image, -naturalWidth / 2, -naturalHeight / 2, naturalWidth, naturalHeight);
99
80
  fullCtx.restore();
@@ -101,8 +82,8 @@ export function getRectImagePath(image, rect) {
101
82
  var tempCanvas = document.createElement('canvas');
102
83
  var tempCtx = tempCanvas.getContext('2d');
103
84
  tempCanvas.width = area[2];
104
- tempCanvas.height = area[3]; // document.body.appendChild(tempCanvas);
105
-
85
+ tempCanvas.height = area[3];
86
+ // document.body.appendChild(tempCanvas);
106
87
  tempCtx.putImageData(imageData, 0, 0);
107
88
  var dataUrl = tempCanvas.toDataURL();
108
89
  setTimeout(function () {