@cloud-app-dev/vidc 3.2.21 → 3.2.33

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.
@@ -102,8 +102,10 @@ function DomMove(_ref) {
102
102
  });
103
103
 
104
104
  _useEventListener('mouseup', function (event) {
105
- ref.current.isDrag = false;
106
- onDragEnd === null || onDragEnd === void 0 ? void 0 : onDragEnd(event, ref.current.position);
105
+ if (ref.current.isDrag) {
106
+ ref.current.isDrag = false;
107
+ onDragEnd === null || onDragEnd === void 0 ? void 0 : onDragEnd(event, ref.current.position);
108
+ }
107
109
  }, {
108
110
  target: document.body
109
111
  });
@@ -147,8 +149,8 @@ function DomMove(_ref) {
147
149
  DomMove.defaultProps = {
148
150
  className: '',
149
151
  size: {
150
- width: '100%',
151
- height: '100%'
152
+ width: 'max-content',
153
+ height: 'max-content'
152
154
  }
153
155
  };
154
156
  export default /*#__PURE__*/React.forwardRef(function (props, ref) {
@@ -1,3 +1,5 @@
1
+ import _useUpdateEffect from "ahooks/es/useUpdateEffect";
2
+
1
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
4
 
3
5
  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,7 +12,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
10
12
 
11
13
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
14
 
13
- import React, { useEffect } from 'react';
15
+ import React from 'react';
14
16
  import useFullscreen from "../useFullscreen";
15
17
  import IconFont from "../IconFont";
16
18
  import "./index.less";
@@ -28,12 +30,11 @@ function FullScreen(_ref) {
28
30
  isFullscreen = _useFullscreen2[0],
29
31
  toggleFullscreen = _useFullscreen2[1].toggleFullscreen;
30
32
 
31
- useEffect(function () {
32
- if (isFullscreen) {
33
- fullScreenChange === null || fullScreenChange === void 0 ? void 0 : fullScreenChange(isFullscreen);
34
- } // eslint-disable-next-line react-hooks/exhaustive-deps
35
-
33
+ _useUpdateEffect(function () {
34
+ console.log(isFullscreen);
35
+ fullScreenChange === null || fullScreenChange === void 0 ? void 0 : fullScreenChange(isFullscreen); // eslint-disable-next-line react-hooks/exhaustive-deps
36
36
  }, [isFullscreen]);
37
+
37
38
  return /*#__PURE__*/_jsxs("span", {
38
39
  className: "tools-screen-layer ".concat(className !== null && className !== void 0 ? className : ''),
39
40
  onClick: toggleFullscreen,
@@ -7,7 +7,7 @@ interface IToolsProps {
7
7
  setRotate: (rotate: number) => void;
8
8
  containerEle: HTMLDivElement;
9
9
  resetPicture: (event: React.MouseEvent) => void;
10
- fullScreenChange: (flag: boolean) => void;
10
+ fullScreenChange: () => void;
11
11
  }
12
12
  declare function Tools({ scale, imgDownload, setScale, setRotate, containerEle, resetPicture, fullScreenChange }: IToolsProps): JSX.Element;
13
13
  export default Tools;
@@ -15,7 +15,7 @@ function Tools(_ref) {
15
15
  setRotate = _ref.setRotate,
16
16
  containerEle = _ref.containerEle,
17
17
  resetPicture = _ref.resetPicture,
18
- fullScreenChange = _ref.fullScreenChange;
18
+ _fullScreenChange = _ref.fullScreenChange;
19
19
  return /*#__PURE__*/_jsxs(_Fragment, {
20
20
  children: [/*#__PURE__*/_jsxs("div", {
21
21
  className: "picture-tools",
@@ -88,7 +88,11 @@ function Tools(_ref) {
88
88
  getContainer: function getContainer() {
89
89
  return containerEle;
90
90
  },
91
- fullScreenChange: fullScreenChange
91
+ fullScreenChange: function fullScreenChange() {
92
+ return setTimeout(function () {
93
+ return _fullScreenChange();
94
+ }, 200);
95
+ }
92
96
  })
93
97
  })]
94
98
  })]
@@ -1,19 +1,77 @@
1
1
  import "antd/lib/config-provider/style";
2
2
  import _ConfigProvider from "antd/lib/config-provider";
3
+ import "antd/lib/button/style";
4
+ import _Button from "antd/lib/button";
5
+
6
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
7
+
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."); }
9
+
10
+ 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); }
11
+
12
+ 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; }
13
+
14
+ 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; }
15
+
16
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
+
3
18
  import React from 'react';
4
19
  import Picture from '.';
20
+ import { useSimpleState } from '..';
5
21
  import { jsx as _jsx } from "react/jsx-runtime";
6
22
  export default function App() {
23
+ var _useSimpleState = useSimpleState({
24
+ open: false
25
+ }),
26
+ _useSimpleState2 = _slicedToArray(_useSimpleState, 2),
27
+ state = _useSimpleState2[0],
28
+ updateState = _useSimpleState2[1];
29
+
7
30
  return /*#__PURE__*/_jsx(_ConfigProvider, {
8
31
  prefixCls: "cloudapp",
9
32
  children: /*#__PURE__*/_jsx("div", {
10
33
  style: {
11
34
  width: 800,
12
- height: 400
35
+ height: 600,
36
+ background: '#000'
13
37
  },
14
38
  children: /*#__PURE__*/_jsx(Picture, {
15
- imagePath: "https://x0.ifengimg.com/cmpp/fck/2020_30/65cca65a549d6c2_w1024_h578.jpg",
16
- isOpenSelect: false
39
+ onClickRect: console.log,
40
+ onMenuClick: console.log,
41
+ menus: [{
42
+ title: "菜单1",
43
+ pathname: "/",
44
+ icon: ""
45
+ }],
46
+ imagePath: "http://192.168.100.246:1443/image/v1/100005251/objects/63882cf105f5f58310107e95/1669910400.jpg?signature=ad407ae3019acb29b14b4ed2817ad12f&watermark=m_61646D696E0A323032323132303154313332373434&expires=1669910400",
47
+ isOpenSelect: state.open,
48
+ rects: [{
49
+ type: 'face',
50
+ rect: [698, 274, 23, 23],
51
+ needExpand: true
52
+ }, {
53
+ type: 'face',
54
+ rect: [754.0, 268.0, 23.0, 23.0],
55
+ needExpand: true
56
+ }, {
57
+ type: 'face',
58
+ rect: [430.0, 421.0, 49.0, 49.0],
59
+ needExpand: true
60
+ }, {
61
+ type: 'face',
62
+ rect: [240.0, 468.0, 41.0, 36.0],
63
+ needExpand: true
64
+ }],
65
+ children: function children(options) {
66
+ return /*#__PURE__*/_jsx(_Button, {
67
+ onClick: function onClick() {
68
+ updateState({
69
+ open: true
70
+ });
71
+ },
72
+ children: "\xDF\xDF \u622A\u56FE"
73
+ });
74
+ }
17
75
  })
18
76
  })
19
77
  });
@@ -1,6 +1,7 @@
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
2
 
3
3
  import _resizeObserver from "@cloud-app-dev/utils/es/resizeObserver";
4
+ import _useMemoizedFn from "ahooks/es/useMemoizedFn";
4
5
  var _excluded = ["className", "width", "height", "minHeight", "disabledDrag", "imagePath", "rects", "isOpenSelect", "disabledDrawMenu", "menus", "hasTool", "fullScreenEle"];
5
6
 
6
7
  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; }
@@ -41,13 +42,15 @@ import WheelScale from "./component/WheelScale";
41
42
  import { computedBound } from "./dragBound";
42
43
  import { getRectImagePath } from "./loadCaptureRectImage";
43
44
  import useDraw from "./useDraw";
44
- import { cloneImageNode, computedRectScale, customContextMenu } from "./utils";
45
+ import { computedRectScale, customContextMenu } from "./utils";
45
46
  import "./index.less";
46
47
  import { jsx as _jsx } from "react/jsx-runtime";
47
48
  import { jsxs as _jsxs } from "react/jsx-runtime";
48
49
  import { Fragment as _Fragment } from "react/jsx-runtime";
49
50
 
50
51
  function Picture(_ref) {
52
+ var _layoutRef$current;
53
+
51
54
  var className = _ref.className,
52
55
  width = _ref.width,
53
56
  height = _ref.height,
@@ -78,7 +81,8 @@ function Picture(_ref) {
78
81
  baseXOrY: 'x',
79
82
  forceUpdateKey: Date.now(),
80
83
  fullScreenStatus: false,
81
- localUrl: ''
84
+ localUrl: '',
85
+ offset: [0, 0]
82
86
  }),
83
87
  _useSimpleState2 = _slicedToArray(_useSimpleState, 3),
84
88
  state = _useSimpleState2[0],
@@ -88,12 +92,12 @@ function Picture(_ref) {
88
92
  var layoutRef = useRef(null);
89
93
  var moveActionRef = useRef(null);
90
94
  var domImgRef = useRef(null);
91
- var imageSourceRef = useRef(null);
92
95
  useEffect(function () {
93
96
  if (!imagePath) {
94
97
  return undefined;
95
98
  }
96
99
 
100
+ console.log(imagePath);
97
101
  var localUrl;
98
102
  fetch(imagePath).then(function (res) {
99
103
  return res.blob();
@@ -106,53 +110,80 @@ function Picture(_ref) {
106
110
  return function () {
107
111
  return URL.revokeObjectURL(localUrl);
108
112
  };
109
- }, [imagePath]);
113
+ }, [imagePath]); // draw hooks
110
114
 
111
- var _useDraw = useDraw(layoutRef.current, isOpenSelect),
115
+ var _useDraw = useDraw((_layoutRef$current = layoutRef.current) === null || _layoutRef$current === void 0 ? void 0 : _layoutRef$current.querySelector('.picture-overlay'), isOpenSelect),
112
116
  _useDraw2 = _slicedToArray(_useDraw, 2),
113
117
  selectArea = _useDraw2[0],
114
- isEnd = _useDraw2[1];
118
+ isEnd = _useDraw2[1]; // init loaded
119
+
115
120
 
116
- var loadImageSuccess = useCallback( /*#__PURE__*/function () {
117
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(flag) {
118
- var nodeEle, _ref3, width, height;
121
+ var loadImageSuccess = _useMemoizedFn( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
122
+ var _layoutRef$current2, _layoutRect$width, _layoutRect$height;
119
123
 
120
- return _regeneratorRuntime().wrap(function _callee$(_context) {
121
- while (1) {
122
- switch (_context.prev = _context.next) {
123
- case 0:
124
+ var img, naturalWidth, naturalHeight, layoutRect, w, h, baseXOrY, x, y, imagescale, imgHeight, _imagescale, imgWidth, moveObj;
125
+
126
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
127
+ while (1) {
128
+ switch (_context.prev = _context.next) {
129
+ case 0:
130
+ if (state.localUrl) {
124
131
  _context.next = 2;
125
- return cloneImageNode(domImgRef.current);
126
-
127
- case 2:
128
- nodeEle = _context.sent;
129
- imageSourceRef.current = nodeEle;
130
- _ref3 = domImgRef.current, width = _ref3.width, height = _ref3.height;
131
- setState(function (old) {
132
- return _objectSpread(_objectSpread({}, old), {}, {
133
- forceUpdateKey: Date.now(),
134
- baseXOrY: width > height ? 'x' : 'y',
135
- fullScreenStatus: !!flag
136
- });
132
+ break;
133
+ }
134
+
135
+ return _context.abrupt("return");
136
+
137
+ case 2:
138
+ img = domImgRef.current;
139
+ naturalWidth = img.naturalWidth, naturalHeight = img.naturalHeight;
140
+ layoutRect = (_layoutRef$current2 = layoutRef.current) === null || _layoutRef$current2 === void 0 ? void 0 : _layoutRef$current2.getBoundingClientRect();
141
+ w = (_layoutRect$width = layoutRect === null || layoutRect === void 0 ? void 0 : layoutRect.width) !== null && _layoutRect$width !== void 0 ? _layoutRect$width : 0;
142
+ h = (_layoutRect$height = layoutRect === null || layoutRect === void 0 ? void 0 : layoutRect.height) !== null && _layoutRect$height !== void 0 ? _layoutRect$height : 0;
143
+ baseXOrY = naturalWidth > naturalHeight ? 'x' : 'y';
144
+ x = 0;
145
+ y = 0;
146
+
147
+ if (baseXOrY === 'x') {
148
+ imagescale = w / naturalWidth;
149
+ imgHeight = imagescale * naturalHeight;
150
+ y = Math.abs((imgHeight - h) / 2);
151
+ img.width = w;
152
+ } else {
153
+ _imagescale = h / naturalHeight;
154
+ imgWidth = _imagescale * naturalWidth;
155
+ x = Math.abs((imgWidth - w) / 2);
156
+ img.height = h;
157
+ }
158
+
159
+ moveObj = moveActionRef.current;
160
+ moveObj.updatePosition({
161
+ x: x,
162
+ y: y
163
+ });
164
+ setState(function (old) {
165
+ return _objectSpread(_objectSpread({}, old), {}, {
166
+ x: x,
167
+ y: y,
168
+ offset: [x, y],
169
+ forceUpdateKey: Date.now(),
170
+ baseXOrY: baseXOrY
137
171
  });
172
+ });
138
173
 
139
- case 6:
140
- case "end":
141
- return _context.stop();
142
- }
174
+ case 14:
175
+ case "end":
176
+ return _context.stop();
143
177
  }
144
- }, _callee);
145
- }));
146
-
147
- return function (_x) {
148
- return _ref2.apply(this, arguments);
149
- };
150
- }(), []);
178
+ }
179
+ }, _callee);
180
+ })));
151
181
  /**
152
182
  * 设置图片缩放
153
183
  */
154
184
 
155
- var setScale = useCallback(function (changeValue) {
185
+
186
+ var setScale = _useMemoizedFn(function (changeValue) {
156
187
  var currentValue = state.scale;
157
188
 
158
189
  if (currentValue === 3 && changeValue > 0) {
@@ -178,24 +209,26 @@ function Picture(_ref) {
178
209
  scale: scale
179
210
  });
180
211
  });
181
- }, [state.scale]);
212
+ });
182
213
  /**
183
214
  * 设置图谱旋转
184
215
  */
185
216
 
186
- var setRotate = useCallback(function (changeValue) {
217
+
218
+ var setRotate = _useMemoizedFn(function (changeValue) {
187
219
  var currentValue = state.rotate;
188
220
  setState(function (old) {
189
221
  return _objectSpread(_objectSpread({}, old), {}, {
190
222
  rotate: currentValue + changeValue
191
223
  });
192
224
  });
193
- }, [state.rotate]);
225
+ });
194
226
  /**
195
227
  * 重置图片位置
196
228
  */
197
229
 
198
- var resetPicture = useCallback(function (event) {
230
+
231
+ var resetPicture = _useMemoizedFn(function (event) {
199
232
  event.stopPropagation();
200
233
  var moveObj = moveActionRef.current;
201
234
  setState(function (old) {
@@ -205,17 +238,18 @@ function Picture(_ref) {
205
238
  });
206
239
  });
207
240
  moveObj.updatePosition({
208
- x: 0,
209
- y: 0
241
+ x: state.offset[0],
242
+ y: state.offset[1]
210
243
  });
211
- }, []);
244
+ });
212
245
  /**
213
246
  * 拖拽更新位置
214
247
  */
215
248
 
216
- var onDragChange = useCallback(function (_ref4) {
217
- var x = _ref4.x,
218
- y = _ref4.y;
249
+
250
+ var onDragChange = useCallback(function (_ref3) {
251
+ var x = _ref3.x,
252
+ y = _ref3.y;
219
253
  return setState(function (old) {
220
254
  return _objectSpread(_objectSpread({}, old), {}, {
221
255
  x: x,
@@ -227,7 +261,7 @@ function Picture(_ref) {
227
261
  * 拖拽结束更新位置,计算边界
228
262
  */
229
263
 
230
- var onDragEnd = useCallback(function (_, currrentPosition) {
264
+ var onDragEnd = _useMemoizedFn(function (_, currrentPosition) {
231
265
  var scale = state.scale,
232
266
  rotate = state.rotate;
233
267
 
@@ -239,25 +273,31 @@ function Picture(_ref) {
239
273
 
240
274
  if (position) {
241
275
  var moveObj = moveActionRef.current;
242
- moveObj.updatePosition(position);
276
+ var flag = position.x === 0 && position.y === 0;
277
+ moveObj.updatePosition(flag ? {
278
+ x: state.offset[0],
279
+ y: state.offset[1]
280
+ } : position);
243
281
  }
244
- }, [state]);
282
+ });
245
283
  /**
246
284
  * 获取结构化的小图(base64)
247
285
  */
248
286
 
249
- var getRectImage = useCallback(function (rect) {
287
+
288
+ var getRectImage = _useMemoizedFn(function (rect) {
250
289
  var scale = state.scale,
251
290
  rotate = state.rotate,
252
291
  x = state.x,
253
292
  y = state.y;
254
- return getRectImagePath(imageSourceRef.current, domImgRef.current, rect, {
293
+ return getRectImagePath(domImgRef.current, rect, {
255
294
  scale: scale,
256
295
  rotate: rotate,
257
296
  x: x,
258
297
  y: y
259
298
  });
260
- }, [state]);
299
+ });
300
+
261
301
  useEffect(function () {
262
302
  var timer;
263
303
 
@@ -283,7 +323,6 @@ function Picture(_ref) {
283
323
 
284
324
  var scaleRects = useMemo(function () {
285
325
  return computedRectScale({
286
- imageSource: imageSourceRef.current,
287
326
  domImg: domImgRef.current,
288
327
  rects: rects !== null && rects !== void 0 ? rects : []
289
328
  });
@@ -291,24 +330,23 @@ function Picture(_ref) {
291
330
  var isEmpty = useMemo(function () {
292
331
  return selectArea.includes(0);
293
332
  }, [selectArea]);
294
-
295
- var _useMemo2 = useMemo(function () {
296
- return state;
297
- }, [state]),
298
- x = _useMemo2.x,
299
- y = _useMemo2.y,
300
- scale = _useMemo2.scale,
301
- rotate = _useMemo2.rotate,
302
- baseXOrY = _useMemo2.baseXOrY;
303
-
304
333
  var renderOptions = {
305
334
  isEnd: isEnd,
306
335
  isOpenSelect: isOpenSelect,
307
336
  selectArea: selectArea,
308
337
  getRectImage: getRectImage,
309
- containerEle: layoutRef.current,
310
- fullScreenStatus: state.fullScreenStatus
338
+ containerEle: layoutRef.current
311
339
  };
340
+ useEffect(function () {
341
+ if (isOpenSelect && (state.rotate !== 0 || state.scale !== 1)) {
342
+ updateState({
343
+ scale: 1,
344
+ rotate: 0,
345
+ x: state.offset[0],
346
+ y: state.offset[1]
347
+ });
348
+ }
349
+ }, [isOpenSelect, state.rotate, state.scale]);
312
350
  return /*#__PURE__*/_jsxs(_Fragment, {
313
351
  children: [/*#__PURE__*/_jsxs("div", {
314
352
  className: "picture-view-layout ".concat(className),
@@ -322,37 +360,21 @@ function Picture(_ref) {
322
360
  children: [/*#__PURE__*/_jsx(DomMove, {
323
361
  className: "picture-move-layout",
324
362
  disabled: isOpenSelect || disabledDrag,
325
- position: {
326
- x: x,
327
- y: y
328
- },
329
363
  ref: moveActionRef,
330
364
  onDragChange: onDragChange,
331
365
  onDragEnd: onDragEnd,
332
- style: {
333
- minHeight: minHeight
334
- },
335
- size: {
336
- width: '100%',
337
- height: '100%'
338
- },
339
366
  children: /*#__PURE__*/_jsxs("div", {
367
+ className: "picture-overlay",
340
368
  style: {
341
- transform: "scale(".concat(scale, ") rotate(").concat(rotate, "deg)")
369
+ transform: "scale(".concat(state.scale, ") rotate(").concat(state.rotate, "deg)")
342
370
  },
343
371
  children: [/*#__PURE__*/_jsx("img", {
344
372
  ref: domImgRef,
345
- style: {
346
- maxWidth: baseXOrY === 'x' ? width || '100%' : 'unset',
347
- maxHeight: baseXOrY === 'x' ? 'unset' : height || '100%'
348
- },
349
373
  draggable: false,
350
374
  src: state.localUrl,
351
375
  "data-src": imagePath,
352
- onLoad: function onLoad() {
353
- return loadImageSuccess();
354
- }
355
- }, imagePath), !isEmpty ? /*#__PURE__*/_jsx(DrawRect, {
376
+ onLoad: loadImageSuccess
377
+ }), !isEmpty ? /*#__PURE__*/_jsx(DrawRect, {
356
378
  rect: selectArea,
357
379
  onMenuClick: onMenuClick,
358
380
  getRectImage: getRectImage,
@@ -369,7 +391,7 @@ function Picture(_ref) {
369
391
  }), hasTool && /*#__PURE__*/_jsx(Tools, {
370
392
  setScale: setScale,
371
393
  setRotate: setRotate,
372
- scale: scale,
394
+ scale: state.scale,
373
395
  containerEle: fullScreenEle !== null && fullScreenEle !== void 0 ? fullScreenEle : layoutRef.current,
374
396
  resetPicture: resetPicture,
375
397
  imgDownload: imgDownload,
@@ -1,8 +1,8 @@
1
1
  import { ImageType } from './interface';
2
2
  export declare function loadCaptureRectImage(image: HTMLImageElement, rect: number[], imageType: ImageType): Promise<string>;
3
- export declare function getRectImagePath(sourceImage: HTMLImageElement, cuurentImage: HTMLImageElement, rect: number[], options?: {
3
+ export declare function getRectImagePath(image: HTMLImageElement, rect: number[], options?: {
4
4
  scale: number;
5
5
  rotate: number;
6
6
  x: number;
7
7
  y: number;
8
- }): string | null;
8
+ }): string;
@@ -67,18 +67,13 @@ function _loadCaptureRectImage() {
67
67
  return _loadCaptureRectImage.apply(this, arguments);
68
68
  }
69
69
 
70
- export function getRectImagePath(sourceImage, cuurentImage, rect) {
71
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
70
+ export function getRectImagePath(image, rect) {
71
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
72
72
  scale: 1,
73
73
  rotate: 0,
74
74
  x: 0,
75
75
  y: 0
76
76
  };
77
-
78
- if (!sourceImage || !cuurentImage) {
79
- return null;
80
- }
81
-
82
77
  var scale = options.scale,
83
78
  rotate = options.rotate;
84
79
 
@@ -88,28 +83,29 @@ export function getRectImagePath(sourceImage, cuurentImage, rect) {
88
83
  w = _rect[2],
89
84
  h = _rect[3];
90
85
 
91
- var width = sourceImage.width,
92
- height = sourceImage.height;
86
+ var naturalWidth = image.naturalWidth,
87
+ naturalHeight = image.naturalHeight,
88
+ width = image.width,
89
+ height = image.height;
93
90
  var sourceSize = {
94
- width: width,
95
- height: height,
96
- cwidth: cuurentImage.width,
97
- cheight: cuurentImage.height,
98
- wScale: width / cuurentImage.width,
99
- hScale: height / cuurentImage.height
91
+ width: naturalWidth,
92
+ height: naturalHeight,
93
+ cwidth: width,
94
+ cheight: height,
95
+ wScale: naturalWidth / width,
96
+ hScale: naturalHeight / height
100
97
  };
101
98
  var area = [x * sourceSize.wScale, y * sourceSize.hScale, w * sourceSize.wScale, h * sourceSize.hScale];
102
99
  var fullCanvas = document.createElement('canvas');
103
100
  var fullCtx = fullCanvas.getContext('2d');
104
- fullCanvas.width = width;
105
- fullCanvas.height = height;
101
+ fullCanvas.width = naturalWidth;
102
+ fullCanvas.height = naturalHeight;
106
103
  fullCtx.save(); // fullCtx.transform;
107
104
  // document.body.appendChild(fullCanvas);
108
105
 
109
- fullCtx.setTransform(scale, 0, 0, scale, options.x * sourceSize.wScale - (scale - 1) * width / 2, options.y * sourceSize.hScale - (scale - 1) * height / 2);
110
- fullCtx.translate(width / 2, height / 2);
106
+ fullCtx.translate(naturalWidth / 2, naturalHeight / 2);
111
107
  fullCtx.rotate(rotate * Math.PI / 180);
112
- fullCtx.drawImage(sourceImage, -width / 2, -height / 2, width, height);
108
+ fullCtx.drawImage(image, -naturalWidth / 2, -naturalHeight / 2, naturalWidth, naturalHeight);
113
109
  fullCtx.restore();
114
110
  var imageData = fullCtx.getImageData(area[0], area[1], area[2], area[3]);
115
111
  var tempCanvas = document.createElement('canvas');
@@ -2,8 +2,7 @@ import { ImageType, RectType } from './interface';
2
2
  export declare function customContextMenu(e: any): boolean;
3
3
  export declare function cloneImageNode(image: HTMLImageElement): Promise<Node>;
4
4
  export declare function getCaptureRect(rect: number[], type: ImageType): number[];
5
- export declare function computedRectScale({ imageSource, domImg, rects }: {
6
- imageSource: HTMLImageElement;
5
+ export declare function computedRectScale({ domImg, rects }: {
7
6
  domImg: HTMLImageElement;
8
7
  rects: RectType[];
9
8
  }): {
@@ -64,19 +64,24 @@ export function getCaptureRect(rect, type) {
64
64
  return [x, y, w, h];
65
65
  }
66
66
  export function computedRectScale(_ref) {
67
- var imageSource = _ref.imageSource,
68
- domImg = _ref.domImg,
67
+ var _ref2, _ref3;
68
+
69
+ var domImg = _ref.domImg,
69
70
  rects = _ref.rects;
70
71
 
71
- if (!imageSource || !domImg) {
72
+ if (!domImg) {
73
+ return [];
74
+ }
75
+
76
+ if (domImg.naturalWidth === 0 || domImg.naturalHeight === 0) {
72
77
  return [];
73
78
  }
74
79
 
75
80
  var width = domImg.width;
76
81
  var height = domImg.height;
77
82
  var scaleOptions = {
78
- scaleX: width / imageSource.width,
79
- scaleY: height / imageSource.height
83
+ scaleX: (_ref2 = width / domImg.naturalWidth) !== null && _ref2 !== void 0 ? _ref2 : 1,
84
+ scaleY: (_ref3 = height / domImg.naturalHeight) !== null && _ref3 !== void 0 ? _ref3 : 1
80
85
  };
81
86
  return rects.map(function (item) {
82
87
  var rect = item.needExpand ? getCaptureRect(cloneDeep(item.rect), item.type) : cloneDeep(item.rect);
@@ -16,5 +16,5 @@
16
16
  --table-row-hover-color: #1d4788;
17
17
  --radius1: 4px;
18
18
  --color1: #fff;
19
- --color: #333333;
19
+ --color: #333;
20
20
  }
@@ -35,6 +35,7 @@ div {
35
35
 
36
36
  .@{ant-prefix}-pagination-item-active {
37
37
  border-color: var(--form-active-bg);
38
+ color: var(--form-active-bg);
38
39
  }
39
40
 
40
41
  .@{ant-prefix}-pagination-item:focus,
@@ -44,7 +45,7 @@ div {
44
45
 
45
46
  .@{ant-prefix}-pagination-item:focus a,
46
47
  .@{ant-prefix}-pagination-item:hover a {
47
- color: #fff;
48
+ color: var(--form-active-bg);
48
49
  }
49
50
 
50
51
  .@{ant-prefix}-pagination-prev:focus:not(.@{ant-prefix}-pagination-disabled) .@{ant-prefix}-pagination-item-link,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "private": false,
3
3
  "name": "@cloud-app-dev/vidc",
4
4
  "description": "Video Image Data Componennts",
5
- "version": "3.2.21",
5
+ "version": "3.2.33",
6
6
  "scripts": {
7
7
  "docs:deploy": "gh-pages -d docs-dist",
8
8
  "build": "npm run entry && father build",
@@ -66,7 +66,7 @@
66
66
  "@types/react-dom": "^18.0.6",
67
67
  "antd": "^4.22.6",
68
68
  "babel-plugin-import": "^1.13.5",
69
- "dumi": "^2.0.5",
69
+ "dumi": "^2.0.9",
70
70
  "gh-pages": "^4.0.0",
71
71
  "react": "^18.2.0",
72
72
  "react-dom": "^18.2.0",