@cloud-app-dev/vidc 3.1.15 → 3.1.17
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.
- package/es/Api/index.js +0 -23
- package/es/AppContext/Sync.js +1 -15
- package/es/AppContext/index.js +21 -52
- package/es/AppContext/static.js +0 -7
- package/es/Auth/index.js +2 -5
- package/es/AutoExit/index.js +1 -5
- package/es/Box/BetweenBox/index.js +6 -8
- package/es/Box/InfoBox/index.js +6 -8
- package/es/Box/TwoColumnBox/index.js +8 -18
- package/es/Box/deps/grid-factory.js +0 -12
- package/es/Box/index.js +4 -6
- package/es/CheckGroupFixed/index.js +19 -34
- package/es/Config/index.js +0 -4
- package/es/Config/utils.js +3 -18
- package/es/ConfigContext/index.js +1 -3
- package/es/CustomRenderSelect/index.js +13 -29
- package/es/DisableMark/index.js +2 -2
- package/es/DomMove/index.js +24 -37
- package/es/DomMove/utils.js +3 -8
- package/es/Drag/DragAndDropItem.js +19 -37
- package/es/Drag/DropItem.js +5 -15
- package/es/Drawer/Demo.js +3 -17
- package/es/Drawer/Footer.js +3 -5
- package/es/Drawer/index.js +28 -50
- package/es/ErrorFallback/index.js +1 -3
- package/es/FullScreen/index.js +8 -18
- package/es/HightLevel/index.js +1 -5
- package/es/IconFont/index.js +5 -11
- package/es/ImageView/index.js +8 -20
- package/es/Input/index.js +14 -27
- package/es/InstanceHistory/index.js +0 -2
- package/es/LabelValue/index.js +8 -10
- package/es/List/DynamicGridList/Demo.js +0 -11
- package/es/List/DynamicGridList/index.js +16 -25
- package/es/List/DynamicList/index.js +23 -38
- package/es/List/GridList/Demo.js +3 -16
- package/es/List/GridList/hook.js +34 -65
- package/es/List/GridList/utils.js +0 -1
- package/es/List/VList/index.js +10 -20
- package/es/List/VList/utils.js +2 -3
- package/es/List/index.js +5 -7
- package/es/LoaderApp/index.js +5 -22
- package/es/LoaderApp/loader.js +5 -13
- package/es/LoaderApp/sandbox.back.js +16 -81
- package/es/LoaderApp/sandbox.js +8 -22
- package/es/LoaderApp/utils.js +20 -49
- package/es/LoaderScript/index.js +8 -19
- package/es/LoaderScript/utils.js +0 -51
- package/es/Map/BasicMap/AMapInstance.js +0 -10
- package/es/Map/BasicMap/LeafletInstance.js +11 -20
- package/es/Map/BasicMap/index.js +6 -28
- package/es/Map/ClusterLayer/hook.js +10 -32
- package/es/Map/ClusterLayer/index.js +2 -6
- package/es/Map/Config/index.js +8 -21
- package/es/Map/Config/utils.js +0 -6
- package/es/Map/Context/index.js +2 -22
- package/es/Map/FindPio/index.js +0 -2
- package/es/Map/InfoWindow/MakerLikeWindow.js +9 -28
- package/es/Map/InfoWindow/demo.js +5 -22
- package/es/Map/InfoWindow/index.js +13 -29
- package/es/Map/LevelCenter/DragMarker/index.js +5 -9
- package/es/Map/LevelCenter/demo.js +6 -16
- package/es/Map/LevelCenter/index.js +8 -15
- package/es/Map/LoaderMap/index.js +10 -10
- package/es/Map/MapDrawSelect/demo.js +12 -23
- package/es/Map/MapDrawSelect/index.js +14 -21
- package/es/Map/MouseTool/index.js +16 -26
- package/es/Map/MouseTool/useMouseTools.js +6 -29
- package/es/Map/ResetTools/index.js +4 -8
- package/es/Map/SinglePoint/index.js +6 -13
- package/es/Map/hook/useMapEvent.js +3 -7
- package/es/Map/hook/useMapType.js +1 -2
- package/es/Map/useMarker/index.js +10 -24
- package/es/Map/withMap/index.js +0 -2
- package/es/Modal/index.d.ts +1 -1
- package/es/Modal/index.js +29 -50
- package/es/Picture/component/DefaultRects/RectInfo.js +11 -25
- package/es/Picture/component/DefaultRects/index.js +3 -5
- package/es/Picture/component/DrawRect/index.js +6 -8
- package/es/Picture/component/RectMenu/index.js +10 -16
- package/es/Picture/component/RectMenu/utils.js +3 -6
- package/es/Picture/component/Tools/index.js +6 -8
- package/es/Picture/component/WheelScale/index.js +3 -6
- package/es/Picture/dragBound.js +4 -17
- package/es/Picture/index.js +46 -87
- package/es/Picture/loadCaptureRectImage.js +10 -26
- package/es/Picture/useDraw.js +20 -39
- package/es/Picture/utils.js +2 -11
- package/es/Player/api/index.js +14 -78
- package/es/Player/context.js +1 -2
- package/es/Player/contraller_bar/bar.js +5 -9
- package/es/Player/contraller_bar/contraller_event.js +5 -23
- package/es/Player/contraller_bar/index.js +7 -9
- package/es/Player/contraller_bar/left_bar.js +15 -27
- package/es/Player/contraller_bar/right_bar.js +7 -18
- package/es/Player/contraller_bar/time.js +6 -16
- package/es/Player/contraller_bar/useBarStatus.js +5 -16
- package/es/Player/contraller_bar/volume.js +6 -26
- package/es/Player/demo.js +59 -75
- package/es/Player/event/errorEvent.js +14 -39
- package/es/Player/event/eventName.js +1 -1
- package/es/Player/event/index.js +19 -53
- package/es/Player/fps_play.js +10 -27
- package/es/Player/frontend_player.js +10 -19
- package/es/Player/frontend_timeline.js +25 -47
- package/es/Player/iconfont.js +2 -5
- package/es/Player/live_heart.js +2 -14
- package/es/Player/message.js +9 -29
- package/es/Player/segment_player.js +39 -77
- package/es/Player/segment_timeline.js +42 -68
- package/es/Player/single_player.js +64 -87
- package/es/Player/style/iconfont.js +10 -17
- package/es/Player/timeline.js +11 -28
- package/es/Player/util.js +0 -21
- package/es/PlayerExt/demo.js +11 -21
- package/es/PlayerExt/index.js +18 -43
- package/es/Progress/index.js +3 -15
- package/es/ROI/demo.js +0 -2
- package/es/ROI/index.js +15 -22
- package/es/ScreenPlayer/Live.js +35 -68
- package/es/ScreenPlayer/LiveTools.js +24 -37
- package/es/ScreenPlayer/PlayerWithExt.js +43 -78
- package/es/ScreenPlayer/RatePick.js +1 -3
- package/es/ScreenPlayer/Record.js +52 -123
- package/es/ScreenPlayer/RecordTools.js +32 -53
- package/es/ScreenPlayer/ScreenSelect.js +1 -3
- package/es/ScreenPlayer/SegmentTimeLine.js +8 -12
- package/es/ScreenPlayer/TimeMode.js +1 -3
- package/es/ScreenPlayer/TimeSelect.js +11 -26
- package/es/ScreenPlayer/demo.js +3 -1
- package/es/ScreenPlayer/demo2.js +10 -46
- package/es/ScreenPlayer/useRecordList.js +7 -72
- package/es/ScreenPlayer/useTimeSlider.js +40 -132
- package/es/ScreenPlayer/useVideoFit.js +5 -18
- package/es/ScreenPlayer/utils.js +0 -8
- package/es/Service/fetch-adapter.js +2 -37
- package/es/Service/http.js +8 -27
- package/es/TableLayout/index.js +3 -7
- package/es/ThemeAntd/demo.js +0 -2
- package/es/Timeout/index.js +10 -26
- package/es/Tree/demo.js +0 -2
- package/es/Tree/index.js +14 -21
- package/es/useDrawROI/index.js +51 -105
- package/es/useEventEmitterHandle/index.js +2 -6
- package/es/useFullscreen/demo.js +6 -16
- package/es/useFullscreen/index.js +5 -25
- package/es/useHistory/index.js +0 -2
- package/es/useInfiniteScroll/index.js +14 -39
- package/es/useRafInterval/index.js +2 -26
- package/es/useSimpleState/index.js +5 -16
- package/es/useVirtualList/index.js +19 -57
- package/es/utils.js +0 -28
- package/package.json +14 -14
package/es/Picture/index.js
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
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
2
|
import _resizeObserver from "@cloud-app-dev/utils/es/resizeObserver";
|
|
4
|
-
|
|
5
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; }
|
|
6
|
-
|
|
7
4
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
-
|
|
9
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
|
-
|
|
11
6
|
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
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; }
|
|
14
|
-
|
|
15
8
|
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
|
-
|
|
17
9
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
-
|
|
19
10
|
import { __awaiter, __rest } from "tslib";
|
|
20
11
|
import React, { useMemo, useRef, useState, useCallback, useEffect } from 'react';
|
|
21
12
|
import DomMove from '../DomMove';
|
|
@@ -28,66 +19,57 @@ import DrawRect from './component/DrawRect';
|
|
|
28
19
|
import WheelScale from './component/WheelScale';
|
|
29
20
|
import DefaultRects from './component/DefaultRects';
|
|
30
21
|
import "./index.css";
|
|
31
|
-
|
|
32
22
|
function Picture(_a) {
|
|
33
23
|
var _this = this;
|
|
34
|
-
|
|
35
24
|
var className = _a.className,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
25
|
+
width = _a.width,
|
|
26
|
+
height = _a.height,
|
|
27
|
+
minHeight = _a.minHeight,
|
|
28
|
+
disabledDrag = _a.disabledDrag,
|
|
29
|
+
imagePath = _a.imagePath,
|
|
30
|
+
rects = _a.rects,
|
|
31
|
+
isOpenSelect = _a.isOpenSelect,
|
|
32
|
+
disabledDrawMenu = _a.disabledDrawMenu,
|
|
33
|
+
menus = _a.menus,
|
|
34
|
+
hasTool = _a.hasTool,
|
|
35
|
+
fullScreenEle = _a.fullScreenEle,
|
|
36
|
+
props = __rest(_a, ["className", "width", "height", "minHeight", "disabledDrag", "imagePath", "rects", "isOpenSelect", "disabledDrawMenu", "menus", "hasTool", "fullScreenEle"]);
|
|
49
37
|
var _useMemo = useMemo(function () {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
38
|
+
return props;
|
|
39
|
+
}, [props]),
|
|
40
|
+
imgDownload = _useMemo.imgDownload,
|
|
41
|
+
onClickRect = _useMemo.onClickRect,
|
|
42
|
+
onMenuClick = _useMemo.onMenuClick,
|
|
43
|
+
children = _useMemo.children;
|
|
57
44
|
var _useState = useState({
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
45
|
+
x: 0,
|
|
46
|
+
y: 0,
|
|
47
|
+
rotate: 0,
|
|
48
|
+
scale: 1,
|
|
49
|
+
baseXOrY: 'x',
|
|
50
|
+
forceUpdateKey: Date.now(),
|
|
51
|
+
fullScreenStatus: false
|
|
52
|
+
}),
|
|
53
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
54
|
+
state = _useState2[0],
|
|
55
|
+
setState = _useState2[1];
|
|
70
56
|
var layoutRef = useRef(null);
|
|
71
57
|
var moveActionRef = useRef(null);
|
|
72
58
|
var domImgRef = useRef(null);
|
|
73
59
|
var imageSourceRef = useRef(null);
|
|
74
|
-
|
|
75
60
|
var _useDraw = useDraw(layoutRef.current, isOpenSelect),
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
61
|
+
_useDraw2 = _slicedToArray(_useDraw, 2),
|
|
62
|
+
selectArea = _useDraw2[0],
|
|
63
|
+
isEnd = _useDraw2[1];
|
|
80
64
|
var loadImageSuccess = useCallback(function (flag) {
|
|
81
65
|
return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
82
66
|
var _domImgRef$current, width, height;
|
|
83
|
-
|
|
84
67
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
85
68
|
while (1) {
|
|
86
69
|
switch (_context.prev = _context.next) {
|
|
87
70
|
case 0:
|
|
88
71
|
_context.next = 2;
|
|
89
72
|
return cloneImageNode(domImgRef.current);
|
|
90
|
-
|
|
91
73
|
case 2:
|
|
92
74
|
imageSourceRef.current = _context.sent;
|
|
93
75
|
_domImgRef$current = domImgRef.current, width = _domImgRef$current.width, height = _domImgRef$current.height;
|
|
@@ -98,7 +80,6 @@ function Picture(_a) {
|
|
|
98
80
|
fullScreenStatus: !!flag
|
|
99
81
|
});
|
|
100
82
|
});
|
|
101
|
-
|
|
102
83
|
case 5:
|
|
103
84
|
case "end":
|
|
104
85
|
return _context.stop();
|
|
@@ -110,28 +91,21 @@ function Picture(_a) {
|
|
|
110
91
|
/**
|
|
111
92
|
* 设置图片缩放
|
|
112
93
|
*/
|
|
113
|
-
|
|
114
94
|
var setScale = useCallback(function (changeValue) {
|
|
115
95
|
var currentValue = state.scale;
|
|
116
|
-
|
|
117
96
|
if (currentValue === 3 && changeValue > 0) {
|
|
118
97
|
return;
|
|
119
98
|
}
|
|
120
|
-
|
|
121
99
|
if (currentValue === 1 && changeValue < 0) {
|
|
122
100
|
return;
|
|
123
101
|
}
|
|
124
|
-
|
|
125
102
|
var scale = currentValue + changeValue;
|
|
126
|
-
|
|
127
103
|
if (scale > 3) {
|
|
128
104
|
scale = 3;
|
|
129
105
|
}
|
|
130
|
-
|
|
131
106
|
if (scale < 1) {
|
|
132
107
|
scale = 1;
|
|
133
108
|
}
|
|
134
|
-
|
|
135
109
|
setState(function (old) {
|
|
136
110
|
return Object.assign(Object.assign({}, old), {
|
|
137
111
|
scale: scale
|
|
@@ -141,7 +115,6 @@ function Picture(_a) {
|
|
|
141
115
|
/**
|
|
142
116
|
* 设置图谱旋转
|
|
143
117
|
*/
|
|
144
|
-
|
|
145
118
|
var setRotate = useCallback(function (changeValue) {
|
|
146
119
|
var currentValue = state.rotate;
|
|
147
120
|
setState(function (old) {
|
|
@@ -153,7 +126,6 @@ function Picture(_a) {
|
|
|
153
126
|
/**
|
|
154
127
|
* 重置图片位置
|
|
155
128
|
*/
|
|
156
|
-
|
|
157
129
|
var resetPicture = useCallback(function (event) {
|
|
158
130
|
event.stopPropagation();
|
|
159
131
|
setState(function (old) {
|
|
@@ -170,10 +142,9 @@ function Picture(_a) {
|
|
|
170
142
|
/**
|
|
171
143
|
* 拖拽更新位置
|
|
172
144
|
*/
|
|
173
|
-
|
|
174
145
|
var onDragChange = useCallback(function (_ref) {
|
|
175
146
|
var x = _ref.x,
|
|
176
|
-
|
|
147
|
+
y = _ref.y;
|
|
177
148
|
return setState(function (old) {
|
|
178
149
|
return Object.assign(Object.assign({}, old), {
|
|
179
150
|
x: x,
|
|
@@ -184,17 +155,13 @@ function Picture(_a) {
|
|
|
184
155
|
/**
|
|
185
156
|
* 拖拽结束更新位置,计算边界
|
|
186
157
|
*/
|
|
187
|
-
|
|
188
158
|
var onDragEnd = useCallback(function (_, currrentPosition) {
|
|
189
159
|
var scale = state.scale,
|
|
190
|
-
|
|
191
|
-
|
|
160
|
+
rotate = state.rotate;
|
|
192
161
|
if (!layoutRef.current) {
|
|
193
162
|
return undefined;
|
|
194
163
|
}
|
|
195
|
-
|
|
196
164
|
var position = computedBound(layoutRef.current, currrentPosition, scale, rotate);
|
|
197
|
-
|
|
198
165
|
if (position) {
|
|
199
166
|
moveActionRef.current.updatePosition(position);
|
|
200
167
|
}
|
|
@@ -202,12 +169,11 @@ function Picture(_a) {
|
|
|
202
169
|
/**
|
|
203
170
|
* 获取结构化的小图(base64)
|
|
204
171
|
*/
|
|
205
|
-
|
|
206
172
|
var getRectImage = useCallback(function (rect) {
|
|
207
173
|
var scale = state.scale,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
174
|
+
rotate = state.rotate,
|
|
175
|
+
x = state.x,
|
|
176
|
+
y = state.y;
|
|
211
177
|
return getRectImagePath(imageSourceRef.current, domImgRef.current, rect, {
|
|
212
178
|
scale: scale,
|
|
213
179
|
rotate: rotate,
|
|
@@ -217,7 +183,6 @@ function Picture(_a) {
|
|
|
217
183
|
}, [state]);
|
|
218
184
|
useEffect(function () {
|
|
219
185
|
var timer;
|
|
220
|
-
|
|
221
186
|
var fn = function fn() {
|
|
222
187
|
clearTimeout(timer);
|
|
223
188
|
timer = setTimeout(function () {
|
|
@@ -228,16 +193,13 @@ function Picture(_a) {
|
|
|
228
193
|
});
|
|
229
194
|
}, 200);
|
|
230
195
|
};
|
|
231
|
-
|
|
232
196
|
var dom = layoutRef.current;
|
|
233
|
-
|
|
234
197
|
_resizeObserver.createResizeObserver(dom, fn);
|
|
235
|
-
|
|
236
198
|
return function () {
|
|
237
199
|
_resizeObserver.unResizeObserver(dom, fn);
|
|
238
200
|
};
|
|
239
|
-
}, []);
|
|
240
|
-
|
|
201
|
+
}, []);
|
|
202
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
241
203
|
var scaleRects = useMemo(function () {
|
|
242
204
|
return computedRectScale({
|
|
243
205
|
imageSource: imageSourceRef.current,
|
|
@@ -248,16 +210,14 @@ function Picture(_a) {
|
|
|
248
210
|
var isEmpty = useMemo(function () {
|
|
249
211
|
return selectArea.includes(0);
|
|
250
212
|
}, [selectArea]);
|
|
251
|
-
|
|
252
213
|
var _useMemo2 = useMemo(function () {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
214
|
+
return state;
|
|
215
|
+
}, [state]),
|
|
216
|
+
x = _useMemo2.x,
|
|
217
|
+
y = _useMemo2.y,
|
|
218
|
+
scale = _useMemo2.scale,
|
|
219
|
+
rotate = _useMemo2.rotate,
|
|
220
|
+
baseXOrY = _useMemo2.baseXOrY;
|
|
261
221
|
var renderOptions = {
|
|
262
222
|
isEnd: isEnd,
|
|
263
223
|
isOpenSelect: isOpenSelect,
|
|
@@ -335,7 +295,6 @@ function Picture(_a) {
|
|
|
335
295
|
dom: layoutRef.current
|
|
336
296
|
})), children === null || children === void 0 ? void 0 : children(renderOptions));
|
|
337
297
|
}
|
|
338
|
-
|
|
339
298
|
Picture.defaultProps = {
|
|
340
299
|
width: '100%',
|
|
341
300
|
height: '100%',
|
|
@@ -1,25 +1,16 @@
|
|
|
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
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, $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
|
-
|
|
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
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; }
|
|
12
|
-
|
|
13
7
|
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
|
-
|
|
15
8
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
-
|
|
17
9
|
import { __awaiter } from "tslib";
|
|
18
10
|
import { getCaptureRect } from './utils';
|
|
19
11
|
export function loadCaptureRectImage(image, rect, imageType) {
|
|
20
12
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
21
13
|
var _getCaptureRect, _getCaptureRect2, x, y, w, h, canvas, ctx, url;
|
|
22
|
-
|
|
23
14
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
24
15
|
while (1) {
|
|
25
16
|
switch (_context.prev = _context.next) {
|
|
@@ -28,9 +19,7 @@ export function loadCaptureRectImage(image, rect, imageType) {
|
|
|
28
19
|
_context.next = 2;
|
|
29
20
|
break;
|
|
30
21
|
}
|
|
31
|
-
|
|
32
22
|
throw Error('image is HTMLImgElement');
|
|
33
|
-
|
|
34
23
|
case 2:
|
|
35
24
|
_getCaptureRect = getCaptureRect(rect, imageType), _getCaptureRect2 = _slicedToArray(_getCaptureRect, 4), x = _getCaptureRect2[0], y = _getCaptureRect2[1], w = _getCaptureRect2[2], h = _getCaptureRect2[3];
|
|
36
25
|
canvas = document.createElement('canvas');
|
|
@@ -49,7 +38,6 @@ export function loadCaptureRectImage(image, rect, imageType) {
|
|
|
49
38
|
ctx = null;
|
|
50
39
|
}, 500);
|
|
51
40
|
return _context.abrupt("return", url);
|
|
52
|
-
|
|
53
41
|
case 15:
|
|
54
42
|
case "end":
|
|
55
43
|
return _context.stop();
|
|
@@ -65,22 +53,18 @@ export function getRectImagePath(sourceImage, cuurentImage, rect) {
|
|
|
65
53
|
x: 0,
|
|
66
54
|
y: 0
|
|
67
55
|
};
|
|
68
|
-
|
|
69
56
|
if (!sourceImage || !cuurentImage) {
|
|
70
57
|
return null;
|
|
71
58
|
}
|
|
72
|
-
|
|
73
59
|
var scale = options.scale,
|
|
74
|
-
|
|
75
|
-
|
|
60
|
+
rotate = options.rotate;
|
|
76
61
|
var _rect = _slicedToArray(rect, 4),
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
62
|
+
x = _rect[0],
|
|
63
|
+
y = _rect[1],
|
|
64
|
+
w = _rect[2],
|
|
65
|
+
h = _rect[3];
|
|
82
66
|
var width = sourceImage.width,
|
|
83
|
-
|
|
67
|
+
height = sourceImage.height;
|
|
84
68
|
var sourceSize = {
|
|
85
69
|
width: width,
|
|
86
70
|
height: height,
|
|
@@ -94,9 +78,9 @@ export function getRectImagePath(sourceImage, cuurentImage, rect) {
|
|
|
94
78
|
var fullCtx = fullCanvas.getContext('2d');
|
|
95
79
|
fullCanvas.width = width;
|
|
96
80
|
fullCanvas.height = height;
|
|
97
|
-
fullCtx.save();
|
|
81
|
+
fullCtx.save();
|
|
82
|
+
// fullCtx.transform;
|
|
98
83
|
// document.body.appendChild(fullCanvas);
|
|
99
|
-
|
|
100
84
|
fullCtx.setTransform(scale, 0, 0, scale, options.x * sourceSize.wScale - (scale - 1) * width / 2, options.y * sourceSize.hScale - (scale - 1) * height / 2);
|
|
101
85
|
fullCtx.translate(width / 2, height / 2);
|
|
102
86
|
fullCtx.rotate(rotate * Math.PI / 180);
|
|
@@ -106,8 +90,8 @@ export function getRectImagePath(sourceImage, cuurentImage, rect) {
|
|
|
106
90
|
var tempCanvas = document.createElement('canvas');
|
|
107
91
|
var tempCtx = tempCanvas.getContext('2d');
|
|
108
92
|
tempCanvas.width = area[2];
|
|
109
|
-
tempCanvas.height = area[3];
|
|
110
|
-
|
|
93
|
+
tempCanvas.height = area[3];
|
|
94
|
+
// document.body.appendChild(tempCanvas);
|
|
111
95
|
tempCtx.putImageData(imageData, 0, 0);
|
|
112
96
|
var dataUrl = tempCanvas.toDataURL();
|
|
113
97
|
setTimeout(function () {
|
package/es/Picture/useDraw.js
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
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
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; }
|
|
8
|
-
|
|
9
5
|
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
|
-
|
|
11
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
-
|
|
13
7
|
import { useEffect, useState, useRef, useCallback } from 'react';
|
|
14
8
|
export default function useDraw(dom, flag) {
|
|
15
9
|
var _useState = useState({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
rect: [0, 0, 0, 0],
|
|
11
|
+
isEnd: false
|
|
12
|
+
}),
|
|
13
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
14
|
+
state = _useState2[0],
|
|
15
|
+
setState = _useState2[1];
|
|
23
16
|
var selectOptionsRef = useRef({
|
|
24
17
|
start: [0, 0],
|
|
25
18
|
end: [0, 0],
|
|
@@ -28,50 +21,42 @@ export default function useDraw(dom, flag) {
|
|
|
28
21
|
/**
|
|
29
22
|
* 绘制框选矩形区域
|
|
30
23
|
*/
|
|
31
|
-
|
|
32
24
|
var drawSelectRact = useCallback(function (isEnd) {
|
|
33
25
|
var _dom$getBoundingClien = dom.getBoundingClientRect(),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
left = _dom$getBoundingClien.left,
|
|
27
|
+
top = _dom$getBoundingClien.top,
|
|
28
|
+
width = _dom$getBoundingClien.width,
|
|
29
|
+
height = _dom$getBoundingClien.height;
|
|
39
30
|
var x = 0,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
31
|
+
y = 0,
|
|
32
|
+
w = 0,
|
|
33
|
+
h = 0;
|
|
34
|
+
//TODO 开始X > 结束X
|
|
44
35
|
if (selectOptionsRef.current.end[0] > selectOptionsRef.current.start[0]) {
|
|
45
36
|
x = selectOptionsRef.current.start[0] - left;
|
|
46
37
|
w = selectOptionsRef.current.end[0] - selectOptionsRef.current.start[0];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
}
|
|
39
|
+
//TODO 开始X < 结束X
|
|
50
40
|
if (selectOptionsRef.current.end[0] < selectOptionsRef.current.start[0]) {
|
|
51
41
|
x = selectOptionsRef.current.end[0] - left;
|
|
52
42
|
w = selectOptionsRef.current.start[0] - selectOptionsRef.current.end[0];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
43
|
+
}
|
|
44
|
+
//TODO 开始Y > 结束Y
|
|
56
45
|
if (selectOptionsRef.current.end[1] > selectOptionsRef.current.start[1]) {
|
|
57
46
|
y = selectOptionsRef.current.start[1] - top;
|
|
58
47
|
h = selectOptionsRef.current.end[1] - selectOptionsRef.current.start[1];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
}
|
|
49
|
+
//TODO 开始Y < 结束Y
|
|
62
50
|
if (selectOptionsRef.current.end[1] < selectOptionsRef.current.start[1]) {
|
|
63
51
|
y = selectOptionsRef.current.end[1] - top;
|
|
64
52
|
h = selectOptionsRef.current.start[1] - selectOptionsRef.current.end[1];
|
|
65
53
|
}
|
|
66
|
-
|
|
67
54
|
if (w + x > width) {
|
|
68
55
|
w = width - x;
|
|
69
56
|
}
|
|
70
|
-
|
|
71
57
|
if (h + y > height) {
|
|
72
58
|
h = height - y;
|
|
73
59
|
}
|
|
74
|
-
|
|
75
60
|
if (w * h < 160 && isEnd) {
|
|
76
61
|
setState({
|
|
77
62
|
rect: [0, 0, 0, 0],
|
|
@@ -87,7 +72,6 @@ export default function useDraw(dom, flag) {
|
|
|
87
72
|
/**
|
|
88
73
|
* move 修改框选区域
|
|
89
74
|
*/
|
|
90
|
-
|
|
91
75
|
var changeSelect = useCallback(function (event) {
|
|
92
76
|
if (selectOptionsRef.current.startSelect) {
|
|
93
77
|
selectOptionsRef.current.end = [event.clientX, event.clientY];
|
|
@@ -97,7 +81,6 @@ export default function useDraw(dom, flag) {
|
|
|
97
81
|
/**
|
|
98
82
|
* 结束当前框选
|
|
99
83
|
*/
|
|
100
|
-
|
|
101
84
|
var selectEnd = useCallback(function (event) {
|
|
102
85
|
if (selectOptionsRef.current.startSelect) {
|
|
103
86
|
selectOptionsRef.current.startSelect = false;
|
|
@@ -115,7 +98,6 @@ export default function useDraw(dom, flag) {
|
|
|
115
98
|
dom.addEventListener('mousemove', changeSelect, false);
|
|
116
99
|
dom.addEventListener('mouseup', selectEnd, false);
|
|
117
100
|
}
|
|
118
|
-
|
|
119
101
|
if (dom && !flag) {
|
|
120
102
|
setState(function (old) {
|
|
121
103
|
return Object.assign(Object.assign({}, old), {
|
|
@@ -123,7 +105,6 @@ export default function useDraw(dom, flag) {
|
|
|
123
105
|
});
|
|
124
106
|
});
|
|
125
107
|
}
|
|
126
|
-
|
|
127
108
|
return function () {
|
|
128
109
|
if (dom) {
|
|
129
110
|
dom.removeEventListener('mousedown', openSelect, false);
|
package/es/Picture/utils.js
CHANGED
|
@@ -7,7 +7,6 @@ export function cloneImageNode(image) {
|
|
|
7
7
|
if (!image) {
|
|
8
8
|
return Promise.resolve();
|
|
9
9
|
}
|
|
10
|
-
|
|
11
10
|
var newImage = image.cloneNode();
|
|
12
11
|
return new Promise(function (resolve, reject) {
|
|
13
12
|
newImage.addEventListener('load', function () {
|
|
@@ -20,13 +19,11 @@ export function cloneImageNode(image) {
|
|
|
20
19
|
}
|
|
21
20
|
export function computedRectScale(_ref) {
|
|
22
21
|
var imageSource = _ref.imageSource,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
domImg = _ref.domImg,
|
|
23
|
+
rects = _ref.rects;
|
|
26
24
|
if (!imageSource || !domImg) {
|
|
27
25
|
return [];
|
|
28
26
|
}
|
|
29
|
-
|
|
30
27
|
var width = domImg.width;
|
|
31
28
|
var height = domImg.height;
|
|
32
29
|
var scaleOptions = {
|
|
@@ -52,14 +49,11 @@ export function computedRectScale(_ref) {
|
|
|
52
49
|
}
|
|
53
50
|
export function getCaptureRect(rect, type) {
|
|
54
51
|
var rectArea = rect;
|
|
55
|
-
|
|
56
52
|
if (rectArea.length !== 4) {
|
|
57
53
|
console.error('区域有误 实例:string = "x,y,w,h"! ', rect);
|
|
58
54
|
return [0, 0, 0, 0];
|
|
59
55
|
}
|
|
60
|
-
|
|
61
56
|
var x, y, w, h;
|
|
62
|
-
|
|
63
57
|
switch (type) {
|
|
64
58
|
case 'body':
|
|
65
59
|
x = rectArea[0] - rectArea[2] * 0.2;
|
|
@@ -67,7 +61,6 @@ export function getCaptureRect(rect, type) {
|
|
|
67
61
|
w = rectArea[2] * 1.4;
|
|
68
62
|
h = rectArea[3] * 1.4;
|
|
69
63
|
break;
|
|
70
|
-
|
|
71
64
|
case 'nonVehicle':
|
|
72
65
|
case 'vehicle':
|
|
73
66
|
case 'thing':
|
|
@@ -76,7 +69,6 @@ export function getCaptureRect(rect, type) {
|
|
|
76
69
|
w = rectArea[2];
|
|
77
70
|
h = rectArea[3];
|
|
78
71
|
break;
|
|
79
|
-
|
|
80
72
|
default:
|
|
81
73
|
// face
|
|
82
74
|
x = rectArea[0] - rectArea[2] * 0.8;
|
|
@@ -85,6 +77,5 @@ export function getCaptureRect(rect, type) {
|
|
|
85
77
|
h = rectArea[3] * 3.2;
|
|
86
78
|
break;
|
|
87
79
|
}
|
|
88
|
-
|
|
89
80
|
return [x, y, w, h];
|
|
90
81
|
}
|