@cloud-app-dev/vidc 3.2.17 → 3.2.19
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/.prettierrc.js +1 -1
- package/.stylelintrc.js +113 -0
- package/es/AppContext/Sync.d.ts +0 -1
- package/es/AppContext/index.js +3 -4
- package/es/Box/InfoBox/index.less +8 -6
- package/es/Box/TwoColumnBox/index.less +32 -22
- package/es/Box/index.d.ts +3 -3
- package/es/Box/index.less +1 -1
- package/es/CheckGroupFixed/demo.d.ts +0 -1
- package/es/CheckGroupFixed/index.d.ts +0 -1
- package/es/CheckGroupFixed/index.less +17 -14
- package/es/CustomRenderSelect/index.less +7 -7
- package/es/DisableMark/index.less +3 -3
- package/es/DomMove/demo.d.ts +0 -1
- package/es/DomMove/index.js +5 -5
- package/es/Drag/DragAndDropItem.js +1 -2
- package/es/Drag/DropItem.js +2 -2
- package/es/Drawer/Footer.d.ts +0 -1
- package/es/Drawer/index.d.ts +1 -1
- package/es/Drawer/index.js +19 -20
- package/es/Drawer/index.less +8 -8
- package/es/Drawer/interface.d.ts +4 -3
- package/es/DynamicGridList/Demo.d.ts +0 -1
- package/es/DynamicList/demo.d.ts +0 -1
- package/es/DynamicList/index.d.ts +0 -1
- package/es/DynamicList/index.less +2 -0
- package/es/ErrorFallback/index.d.ts +0 -1
- package/es/FullScreen/index.d.ts +0 -1
- package/es/FullScreen/index.less +6 -4
- package/es/GridList/Demo.d.ts +0 -1
- package/es/GridList/index.js +1 -1
- package/es/GridList/index.less +1 -1
- package/es/ImageView/index.less +2 -1
- package/es/Input/demo.d.ts +0 -1
- package/es/Input/index.d.ts +0 -1
- package/es/Input/index.less +1 -1
- package/es/InstanceHistory/index.d.ts +0 -1
- package/es/LabelValue/index.less +5 -2
- package/es/List/demo.d.ts +0 -1
- package/es/List/index.d.ts +4 -4
- package/es/List/index.less +2 -2
- package/es/ListWithSizeAnimate/demo.d.ts +0 -1
- package/es/ListWithSizeAnimate/demo.js +0 -1
- package/es/ListWithSizeAnimate/index.d.ts +0 -1
- package/es/ListWithSizeAnimate/index.js +18 -28
- package/es/ListWithSizeAnimate/index.less +10 -6
- package/es/Map/BasicMap/LeafletInstance.d.ts +1 -1
- package/es/Map/BasicMap/index.less +8 -3
- package/es/Map/ClusterLayer/hook.d.ts +2 -2
- package/es/Map/ClusterLayer/index.d.ts +0 -1
- package/es/Map/ClusterLayer/index.less +8 -6
- package/es/Map/FindPio/index.d.ts +0 -1
- package/es/Map/FindPio/index.less +2 -2
- package/es/Map/InfoWindow/MakerLikeWindow.d.ts +0 -1
- package/es/Map/InfoWindow/demo.d.ts +0 -1
- package/es/Map/InfoWindow/index.d.ts +0 -1
- package/es/Map/LevelCenter/DragMarker/index.d.ts +0 -1
- package/es/Map/LevelCenter/demo.d.ts +0 -1
- package/es/Map/LevelCenter/index.d.ts +1 -2
- package/es/Map/LevelCenter/index.js +3 -4
- package/es/Map/MapDrawSelect/demo.d.ts +0 -1
- package/es/Map/MapDrawSelect/index.d.ts +1 -2
- package/es/Map/MapDrawSelect/index.js +2 -3
- package/es/Map/ResetTools/index.d.ts +0 -1
- package/es/Map/ResetTools/index.less +10 -6
- package/es/Map/SinglePoint/index.d.ts +1 -1
- package/es/Map/SinglePoint/index.less +3 -3
- package/es/Map/icon.d.ts +1 -1
- package/es/Map/index.d.ts +11 -21
- package/es/Map/useMarker/index.d.ts +0 -1
- package/es/Map/useMarker/index.js +1 -1
- package/es/Map/withMap/index.d.ts +0 -1
- package/es/Modal/demo.d.ts +0 -1
- package/es/Modal/index.d.ts +9 -9
- package/es/Modal/index.js +17 -17
- package/es/Modal/index.less +10 -11
- package/es/Picture/component/DefaultRects/RectInfo.d.ts +0 -1
- package/es/Picture/component/DefaultRects/index.d.ts +1 -2
- package/es/Picture/component/DefaultRects/index.js +3 -1
- package/es/Picture/component/DefaultRects/index.less +51 -28
- package/es/Picture/component/DrawRect/index.d.ts +2 -3
- package/es/Picture/component/DrawRect/index.js +3 -1
- package/es/Picture/component/DrawRect/index.less +2 -2
- package/es/Picture/component/RectMenu/index.d.ts +0 -1
- package/es/Picture/component/RectMenu/index.less +11 -6
- package/es/Picture/component/Tools/index.d.ts +1 -1
- package/es/Picture/component/Tools/index.js +1 -1
- package/es/Picture/component/Tools/index.less +12 -6
- package/es/Picture/component/WheelScale/index.d.ts +0 -1
- package/es/Picture/demo.d.ts +0 -1
- package/es/Picture/index.d.ts +0 -1
- package/es/Picture/index.js +50 -26
- package/es/Picture/index.less +3 -2
- package/es/Picture/useDraw.d.ts +1 -1
- package/es/Picture/useDraw.js +1 -1
- package/es/Picture/utils.d.ts +3 -3
- package/es/Picture/utils.js +35 -34
- package/es/Player/api/index.d.ts +8 -8
- package/es/Player/api/index.js +67 -35
- package/es/Player/context.d.ts +4 -4
- package/es/Player/contraller_bar/contraller_event.js +4 -4
- package/es/Player/contraller_bar/left_bar.js +12 -10
- package/es/Player/contraller_bar/time.d.ts +0 -1
- package/es/Player/demo.d.ts +0 -1
- package/es/Player/empty.d.ts +1 -0
- package/es/Player/empty.js +6 -0
- package/es/Player/event/errorEvent.d.ts +3 -5
- package/es/Player/event/errorEvent.js +7 -8
- package/es/Player/event/index.d.ts +3 -3
- package/es/Player/event/index.js +1 -1
- package/es/Player/fps_play.d.ts +2 -3
- package/es/Player/fps_play.js +10 -8
- package/es/Player/frontend_player.d.ts +0 -1
- package/es/Player/frontend_player.js +13 -10
- package/es/Player/frontend_timeline.d.ts +0 -1
- package/es/Player/frontend_timeline.js +41 -41
- package/es/Player/iconfont.d.ts +0 -1
- package/es/Player/live_heart.d.ts +3 -3
- package/es/Player/live_heart.js +15 -5
- package/es/Player/message.d.ts +0 -1
- package/es/Player/message.js +5 -5
- package/es/Player/segment_player.d.ts +0 -1
- package/es/Player/segment_player.js +31 -24
- package/es/Player/segment_timeline.d.ts +0 -1
- package/es/Player/segment_timeline.js +71 -71
- package/es/Player/single_player.d.ts +1 -1
- package/es/Player/single_player.js +17 -21
- package/es/Player/style/bar.less +13 -9
- package/es/Player/style/index.less +8 -4
- package/es/Player/style/message.less +22 -16
- package/es/Player/style/slider.less +40 -37
- package/es/Player/style/timeline.less +43 -33
- package/es/Player/style/volume.less +7 -4
- package/es/Player/timeline.d.ts +0 -1
- package/es/Player/timeline.js +16 -8
- package/es/Player/util.d.ts +21 -7
- package/es/Player/util.js +82 -58
- package/es/PlayerExt/demo.d.ts +0 -1
- package/es/PlayerExt/index.d.ts +0 -1
- package/es/PlayerExt/index.less +2 -2
- package/es/Progress/index.d.ts +0 -1
- package/es/Progress/index.less +5 -4
- package/es/ROI/demo.d.ts +0 -1
- package/es/ROI/index.less +8 -4
- package/es/ScreenPlayer/Live.d.ts +0 -1
- package/es/ScreenPlayer/RatePick.d.ts +0 -1
- package/es/ScreenPlayer/Record.d.ts +0 -1
- package/es/ScreenPlayer/ScreenSelect.d.ts +0 -1
- package/es/ScreenPlayer/SegmentTimeLine.d.ts +0 -1
- package/es/ScreenPlayer/TimeMode.d.ts +0 -1
- package/es/ScreenPlayer/TimeSelect.d.ts +0 -1
- package/es/ScreenPlayer/demo.d.ts +0 -1
- package/es/ScreenPlayer/demo2.d.ts +0 -1
- package/es/ScreenPlayer/index.d.ts +2 -3
- package/es/ScreenPlayer/index.less +49 -26
- package/es/ScreenPlayer/useTimeSlider.d.ts +0 -1
- package/es/ScreenPlayer/useVideoFit.d.ts +2 -2
- package/es/TableLayout/index.less +1 -1
- package/es/ThemeAntd/demo.d.ts +0 -1
- package/es/ThemeAntd/demo.less +4 -3
- package/es/ThemeAntd/index.less +12 -12
- package/es/ThemeAntd/style/button.less +4 -4
- package/es/ThemeAntd/style/checkbox.less +3 -3
- package/es/ThemeAntd/style/input.less +7 -7
- package/es/ThemeAntd/style/pagination.less +4 -4
- package/es/ThemeAntd/style/picker.less +5 -5
- package/es/ThemeAntd/style/radio.less +2 -2
- package/es/ThemeAntd/style/scrollbar.less +5 -3
- package/es/ThemeAntd/style/select.less +8 -8
- package/es/ThemeAntd/style/table.less +4 -4
- package/es/Timeout/index.d.ts +0 -1
- package/es/Tree/demo.d.ts +0 -1
- package/es/Tree/index.d.ts +1 -1
- package/es/Tree/index.less +13 -12
- package/es/VList/index.d.ts +0 -1
- package/es/useDrawROI/index.d.ts +4 -4
- package/es/useFullscreen/demo.d.ts +0 -1
- package/es/useFullscreen/index.d.ts +4 -5
- package/es/useHistory/index.d.ts +0 -1
- package/es/useSimpleState/index.js +1 -1
- package/es/useVirtualList/index.d.ts +1 -1
- package/package.json +12 -6
- package/tsconfig.json +1 -0
- package/es/Drag/index.less +0 -0
- package/es/Map/LevelCenter/index.less +0 -2
- package/es/Map/MapDrawSelect/index.less +0 -2
- package/es/Map/useMarker/index.less +0 -0
package/es/Picture/index.js
CHANGED
|
@@ -31,17 +31,17 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
31
31
|
|
|
32
32
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
import React, { useMemo, useRef, useState, useCallback, useEffect } from 'react';
|
|
34
|
+
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
36
35
|
import DomMove from "../DomMove";
|
|
37
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import { customContextMenu, computedRectScale, cloneImageNode } from "./utils";
|
|
40
|
-
import useDraw from "./useDraw";
|
|
41
|
-
import Tools from "./component/Tools";
|
|
36
|
+
import useSimpleState from "../useSimpleState";
|
|
37
|
+
import DefaultRects from "./component/DefaultRects";
|
|
42
38
|
import DrawRect from "./component/DrawRect";
|
|
39
|
+
import Tools from "./component/Tools";
|
|
43
40
|
import WheelScale from "./component/WheelScale";
|
|
44
|
-
import
|
|
41
|
+
import { computedBound } from "./dragBound";
|
|
42
|
+
import { getRectImagePath } from "./loadCaptureRectImage";
|
|
43
|
+
import useDraw from "./useDraw";
|
|
44
|
+
import { cloneImageNode, computedRectScale, customContextMenu } from "./utils";
|
|
45
45
|
import "./index.less";
|
|
46
46
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
47
47
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -70,23 +70,43 @@ function Picture(_ref) {
|
|
|
70
70
|
onMenuClick = _useMemo.onMenuClick,
|
|
71
71
|
children = _useMemo.children;
|
|
72
72
|
|
|
73
|
-
var
|
|
73
|
+
var _useSimpleState = useSimpleState({
|
|
74
74
|
x: 0,
|
|
75
75
|
y: 0,
|
|
76
76
|
rotate: 0,
|
|
77
77
|
scale: 1,
|
|
78
78
|
baseXOrY: 'x',
|
|
79
79
|
forceUpdateKey: Date.now(),
|
|
80
|
-
fullScreenStatus: false
|
|
80
|
+
fullScreenStatus: false,
|
|
81
|
+
localUrl: ''
|
|
81
82
|
}),
|
|
82
|
-
|
|
83
|
-
state =
|
|
84
|
-
|
|
83
|
+
_useSimpleState2 = _slicedToArray(_useSimpleState, 3),
|
|
84
|
+
state = _useSimpleState2[0],
|
|
85
|
+
updateState = _useSimpleState2[1],
|
|
86
|
+
setState = _useSimpleState2[2];
|
|
85
87
|
|
|
86
88
|
var layoutRef = useRef(null);
|
|
87
89
|
var moveActionRef = useRef(null);
|
|
88
90
|
var domImgRef = useRef(null);
|
|
89
91
|
var imageSourceRef = useRef(null);
|
|
92
|
+
useEffect(function () {
|
|
93
|
+
if (!imagePath) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
var localUrl;
|
|
98
|
+
fetch(imagePath).then(function (res) {
|
|
99
|
+
return res.blob();
|
|
100
|
+
}).then(function (blob) {
|
|
101
|
+
localUrl = URL.createObjectURL(blob);
|
|
102
|
+
updateState({
|
|
103
|
+
localUrl: localUrl
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
return function () {
|
|
107
|
+
return URL.revokeObjectURL(localUrl);
|
|
108
|
+
};
|
|
109
|
+
}, [imagePath]);
|
|
90
110
|
|
|
91
111
|
var _useDraw = useDraw(layoutRef.current, isOpenSelect),
|
|
92
112
|
_useDraw2 = _slicedToArray(_useDraw, 2),
|
|
@@ -95,7 +115,7 @@ function Picture(_ref) {
|
|
|
95
115
|
|
|
96
116
|
var loadImageSuccess = useCallback( /*#__PURE__*/function () {
|
|
97
117
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(flag) {
|
|
98
|
-
var
|
|
118
|
+
var nodeEle, _ref3, width, height;
|
|
99
119
|
|
|
100
120
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
101
121
|
while (1) {
|
|
@@ -105,8 +125,9 @@ function Picture(_ref) {
|
|
|
105
125
|
return cloneImageNode(domImgRef.current);
|
|
106
126
|
|
|
107
127
|
case 2:
|
|
108
|
-
|
|
109
|
-
|
|
128
|
+
nodeEle = _context.sent;
|
|
129
|
+
imageSourceRef.current = nodeEle;
|
|
130
|
+
_ref3 = domImgRef.current, width = _ref3.width, height = _ref3.height;
|
|
110
131
|
setState(function (old) {
|
|
111
132
|
return _objectSpread(_objectSpread({}, old), {}, {
|
|
112
133
|
forceUpdateKey: Date.now(),
|
|
@@ -115,7 +136,7 @@ function Picture(_ref) {
|
|
|
115
136
|
});
|
|
116
137
|
});
|
|
117
138
|
|
|
118
|
-
case
|
|
139
|
+
case 6:
|
|
119
140
|
case "end":
|
|
120
141
|
return _context.stop();
|
|
121
142
|
}
|
|
@@ -176,13 +197,14 @@ function Picture(_ref) {
|
|
|
176
197
|
|
|
177
198
|
var resetPicture = useCallback(function (event) {
|
|
178
199
|
event.stopPropagation();
|
|
200
|
+
var moveObj = moveActionRef.current;
|
|
179
201
|
setState(function (old) {
|
|
180
202
|
return _objectSpread(_objectSpread({}, old), {}, {
|
|
181
203
|
scale: 1,
|
|
182
204
|
rotate: 0
|
|
183
205
|
});
|
|
184
206
|
});
|
|
185
|
-
|
|
207
|
+
moveObj.updatePosition({
|
|
186
208
|
x: 0,
|
|
187
209
|
y: 0
|
|
188
210
|
});
|
|
@@ -191,9 +213,9 @@ function Picture(_ref) {
|
|
|
191
213
|
* 拖拽更新位置
|
|
192
214
|
*/
|
|
193
215
|
|
|
194
|
-
var onDragChange = useCallback(function (
|
|
195
|
-
var x =
|
|
196
|
-
y =
|
|
216
|
+
var onDragChange = useCallback(function (_ref4) {
|
|
217
|
+
var x = _ref4.x,
|
|
218
|
+
y = _ref4.y;
|
|
197
219
|
return setState(function (old) {
|
|
198
220
|
return _objectSpread(_objectSpread({}, old), {}, {
|
|
199
221
|
x: x,
|
|
@@ -216,7 +238,8 @@ function Picture(_ref) {
|
|
|
216
238
|
var position = computedBound(layoutRef.current, currrentPosition, scale, rotate);
|
|
217
239
|
|
|
218
240
|
if (position) {
|
|
219
|
-
moveActionRef.current
|
|
241
|
+
var moveObj = moveActionRef.current;
|
|
242
|
+
moveObj.updatePosition(position);
|
|
220
243
|
}
|
|
221
244
|
}, [state]);
|
|
222
245
|
/**
|
|
@@ -262,7 +285,7 @@ function Picture(_ref) {
|
|
|
262
285
|
return computedRectScale({
|
|
263
286
|
imageSource: imageSourceRef.current,
|
|
264
287
|
domImg: domImgRef.current,
|
|
265
|
-
rects: rects
|
|
288
|
+
rects: rects !== null && rects !== void 0 ? rects : []
|
|
266
289
|
});
|
|
267
290
|
}, [rects, state.forceUpdateKey]);
|
|
268
291
|
var isEmpty = useMemo(function () {
|
|
@@ -324,7 +347,8 @@ function Picture(_ref) {
|
|
|
324
347
|
maxHeight: baseXOrY === 'x' ? 'unset' : height || '100%'
|
|
325
348
|
},
|
|
326
349
|
draggable: false,
|
|
327
|
-
src:
|
|
350
|
+
src: state.localUrl,
|
|
351
|
+
"data-src": imagePath,
|
|
328
352
|
onLoad: function onLoad() {
|
|
329
353
|
return loadImageSuccess();
|
|
330
354
|
}
|
|
@@ -332,8 +356,8 @@ function Picture(_ref) {
|
|
|
332
356
|
rect: selectArea,
|
|
333
357
|
onMenuClick: onMenuClick,
|
|
334
358
|
getRectImage: getRectImage,
|
|
335
|
-
menus: menus,
|
|
336
|
-
canRenderMenu: isEnd && !disabledDrawMenu && menus.length > 0,
|
|
359
|
+
menus: menus !== null && menus !== void 0 ? menus : [],
|
|
360
|
+
canRenderMenu: isEnd && !disabledDrawMenu && menus && menus.length > 0,
|
|
337
361
|
containerDom: layoutRef.current
|
|
338
362
|
}) : !isOpenSelect ? /*#__PURE__*/_jsx(DefaultRects, {
|
|
339
363
|
rects: scaleRects,
|
package/es/Picture/index.less
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
.picture-view-layout {
|
|
2
2
|
position: relative;
|
|
3
|
+
min-height: 300px;
|
|
3
4
|
overflow: hidden;
|
|
4
5
|
user-select: none;
|
|
5
|
-
|
|
6
|
+
|
|
6
7
|
.picture-move-layout {
|
|
7
8
|
& > div {
|
|
8
9
|
width: 100%;
|
|
9
10
|
height: 100%;
|
|
10
|
-
transition: all
|
|
11
|
+
transition: all .3s;
|
|
11
12
|
overflow: hidden;
|
|
12
13
|
}
|
|
13
14
|
}
|
package/es/Picture/useDraw.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function useDraw(dom: HTMLElement, open
|
|
1
|
+
export default function useDraw(dom: HTMLElement, open?: boolean): [number[], boolean];
|
package/es/Picture/useDraw.js
CHANGED
|
@@ -12,7 +12,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
12
12
|
|
|
13
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { useCallback, useRef, useState } from 'react';
|
|
16
16
|
export default function useDraw(dom, open) {
|
|
17
17
|
var _useState = useState({
|
|
18
18
|
rect: [0, 0, 0, 0],
|
package/es/Picture/utils.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ImageType, RectType } from './interface';
|
|
2
2
|
export declare function customContextMenu(e: any): boolean;
|
|
3
|
-
export declare function cloneImageNode(image: HTMLImageElement): Promise<
|
|
3
|
+
export declare function cloneImageNode(image: HTMLImageElement): Promise<Node>;
|
|
4
|
+
export declare function getCaptureRect(rect: number[], type: ImageType): number[];
|
|
4
5
|
export declare function computedRectScale({ imageSource, domImg, rects }: {
|
|
5
6
|
imageSource: HTMLImageElement;
|
|
6
7
|
domImg: HTMLImageElement;
|
|
7
8
|
rects: RectType[];
|
|
8
9
|
}): {
|
|
9
|
-
rect:
|
|
10
|
+
rect: any;
|
|
10
11
|
type: ImageType;
|
|
11
12
|
needExpand?: boolean | undefined;
|
|
12
13
|
imgId?: string | undefined;
|
|
@@ -18,4 +19,3 @@ export declare function computedRectScale({ imageSource, domImg, rects }: {
|
|
|
18
19
|
lowQuality?: boolean | undefined;
|
|
19
20
|
base64?: string | undefined;
|
|
20
21
|
}[];
|
|
21
|
-
export declare function getCaptureRect(rect: number[], type: ImageType): number[];
|
package/es/Picture/utils.js
CHANGED
|
@@ -4,6 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
|
|
5
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
6
|
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
7
8
|
import { cloneDeep } from 'lodash-es';
|
|
8
9
|
export function customContextMenu(e) {
|
|
9
10
|
e.preventDefault();
|
|
@@ -11,7 +12,7 @@ export function customContextMenu(e) {
|
|
|
11
12
|
}
|
|
12
13
|
export function cloneImageNode(image) {
|
|
13
14
|
if (!image) {
|
|
14
|
-
return Promise.
|
|
15
|
+
return Promise.reject();
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
var newImage = image.cloneNode();
|
|
@@ -24,43 +25,11 @@ export function cloneImageNode(image) {
|
|
|
24
25
|
}, false);
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
|
-
export function computedRectScale(_ref) {
|
|
28
|
-
var imageSource = _ref.imageSource,
|
|
29
|
-
domImg = _ref.domImg,
|
|
30
|
-
rects = _ref.rects;
|
|
31
|
-
|
|
32
|
-
if (!imageSource || !domImg) {
|
|
33
|
-
return [];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
var width = domImg.width;
|
|
37
|
-
var height = domImg.height;
|
|
38
|
-
var scaleOptions = {
|
|
39
|
-
scaleX: width / imageSource.width,
|
|
40
|
-
scaleY: height / imageSource.height
|
|
41
|
-
};
|
|
42
|
-
return rects.map(function (item) {
|
|
43
|
-
var rect = item.needExpand ? getCaptureRect(cloneDeep(item.rect), item.type) : cloneDeep(item.rect);
|
|
44
|
-
rect[0] = Math.round(rect[0] * scaleOptions.scaleX);
|
|
45
|
-
rect[0] < 0 && (rect[0] = 0);
|
|
46
|
-
rect[2] = Math.round(rect[2] * scaleOptions.scaleX);
|
|
47
|
-
rect[2] < 0 && (rect[2] = 0);
|
|
48
|
-
rect[1] = Math.round(rect[1] * scaleOptions.scaleY);
|
|
49
|
-
rect[1] < 0 && (rect[1] = 0);
|
|
50
|
-
rect[3] = Math.round(rect[3] * scaleOptions.scaleY);
|
|
51
|
-
rect[3] < 0 && (rect[3] = 0);
|
|
52
|
-
rect[2] > width - rect[0] && (rect[2] = width - rect[0]);
|
|
53
|
-
rect[3] > height - rect[1] && (rect[3] = height - rect[1]);
|
|
54
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
55
|
-
rect: rect
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
28
|
export function getCaptureRect(rect, type) {
|
|
60
29
|
var rectArea = rect;
|
|
61
30
|
|
|
62
31
|
if (rectArea.length !== 4) {
|
|
63
|
-
console.error('区域有误
|
|
32
|
+
console.error('区域有误 rect = "[x,y,w,h]"! ', rect);
|
|
64
33
|
return [0, 0, 0, 0];
|
|
65
34
|
}
|
|
66
35
|
|
|
@@ -93,4 +62,36 @@ export function getCaptureRect(rect, type) {
|
|
|
93
62
|
}
|
|
94
63
|
|
|
95
64
|
return [x, y, w, h];
|
|
65
|
+
}
|
|
66
|
+
export function computedRectScale(_ref) {
|
|
67
|
+
var imageSource = _ref.imageSource,
|
|
68
|
+
domImg = _ref.domImg,
|
|
69
|
+
rects = _ref.rects;
|
|
70
|
+
|
|
71
|
+
if (!imageSource || !domImg) {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
var width = domImg.width;
|
|
76
|
+
var height = domImg.height;
|
|
77
|
+
var scaleOptions = {
|
|
78
|
+
scaleX: width / imageSource.width,
|
|
79
|
+
scaleY: height / imageSource.height
|
|
80
|
+
};
|
|
81
|
+
return rects.map(function (item) {
|
|
82
|
+
var rect = item.needExpand ? getCaptureRect(cloneDeep(item.rect), item.type) : cloneDeep(item.rect);
|
|
83
|
+
rect[0] = Math.round(rect[0] * scaleOptions.scaleX);
|
|
84
|
+
rect[0] < 0 && (rect[0] = 0);
|
|
85
|
+
rect[2] = Math.round(rect[2] * scaleOptions.scaleX);
|
|
86
|
+
rect[2] < 0 && (rect[2] = 0);
|
|
87
|
+
rect[1] = Math.round(rect[1] * scaleOptions.scaleY);
|
|
88
|
+
rect[1] < 0 && (rect[1] = 0);
|
|
89
|
+
rect[3] = Math.round(rect[3] * scaleOptions.scaleY);
|
|
90
|
+
rect[3] < 0 && (rect[3] = 0);
|
|
91
|
+
rect[2] > width - rect[0] && (rect[2] = width - rect[0]);
|
|
92
|
+
rect[3] > height - rect[1] && (rect[3] = height - rect[1]);
|
|
93
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
94
|
+
rect: rect
|
|
95
|
+
});
|
|
96
|
+
});
|
|
96
97
|
}
|
package/es/Player/api/index.d.ts
CHANGED
|
@@ -7,15 +7,15 @@ declare class Api {
|
|
|
7
7
|
get video(): HTMLVideoElement | null;
|
|
8
8
|
play: () => void;
|
|
9
9
|
pause: () => void;
|
|
10
|
-
get paused(): boolean;
|
|
11
|
-
get muted(): boolean;
|
|
10
|
+
get paused(): boolean | undefined;
|
|
11
|
+
get muted(): boolean | undefined;
|
|
12
12
|
/**
|
|
13
13
|
* 设置currentTime实现seek
|
|
14
14
|
* @param {*} seconds
|
|
15
15
|
*/
|
|
16
16
|
seekTo: (seconds: number) => void;
|
|
17
17
|
setVolume: (fraction: number) => void;
|
|
18
|
-
getVolume: () => number;
|
|
18
|
+
getVolume: () => number | undefined;
|
|
19
19
|
mute: () => void;
|
|
20
20
|
unmute: () => void;
|
|
21
21
|
/**
|
|
@@ -34,19 +34,19 @@ declare class Api {
|
|
|
34
34
|
/**
|
|
35
35
|
* 获取视频总时长
|
|
36
36
|
*/
|
|
37
|
-
getDuration: () =>
|
|
37
|
+
getDuration: () => number | undefined;
|
|
38
38
|
/**
|
|
39
39
|
* 获取当前播放时间
|
|
40
40
|
*/
|
|
41
|
-
getCurrentTime: () => number;
|
|
41
|
+
getCurrentTime: () => number | undefined;
|
|
42
42
|
/**
|
|
43
43
|
* 获取缓存时间
|
|
44
44
|
*/
|
|
45
|
-
getSecondsLoaded: () =>
|
|
45
|
+
getSecondsLoaded: () => number;
|
|
46
46
|
/**
|
|
47
47
|
* 获取当前视频缓存的起止时间
|
|
48
48
|
*/
|
|
49
|
-
getBufferedTime: () =>
|
|
49
|
+
getBufferedTime: () => number[];
|
|
50
50
|
/**
|
|
51
51
|
* 视频截屏方法
|
|
52
52
|
*/
|
|
@@ -64,5 +64,5 @@ export declare type TypeAndPlay = {
|
|
|
64
64
|
hls?: Hls;
|
|
65
65
|
};
|
|
66
66
|
export declare function useTypeAndPlay(url?: string, type?: string, isLive?: boolean, container?: HTMLElement, segments?: Flvjs.MediaSegment[], flvConfig?: FlvPlayerConfig, hlsConfig?: HlsConfig): [string, Flvjs.Player, Hls];
|
|
67
|
-
export declare function usePlayerApi(url?: string, type?: string, isLive?: boolean, container?: HTMLElement, segments?: Flvjs.MediaSegment[], flvConfig?: FlvPlayerConfig, hlsConfig?: HlsConfig): [Api, [string, Flvjs.Player, Hls]];
|
|
67
|
+
export declare function usePlayerApi(url?: string, type?: string, isLive?: boolean, container?: HTMLElement, segments?: Flvjs.MediaSegment[], flvConfig?: FlvPlayerConfig, hlsConfig?: HlsConfig): [Api | undefined, [string, Flvjs.Player, Hls]];
|
|
68
68
|
export default Api;
|
package/es/Player/api/index.js
CHANGED
|
@@ -33,36 +33,52 @@ var Api = /*#__PURE__*/function () {
|
|
|
33
33
|
|
|
34
34
|
_defineProperty(this, "play", function () {
|
|
35
35
|
tryCatch(function () {
|
|
36
|
-
|
|
36
|
+
var _this$video;
|
|
37
|
+
|
|
38
|
+
return (_this$video = _this.video) === null || _this$video === void 0 ? void 0 : _this$video.play();
|
|
37
39
|
});
|
|
38
40
|
});
|
|
39
41
|
|
|
40
42
|
_defineProperty(this, "pause", function () {
|
|
41
|
-
_this
|
|
43
|
+
var _this$video2;
|
|
44
|
+
|
|
45
|
+
(_this$video2 = _this.video) === null || _this$video2 === void 0 ? void 0 : _this$video2.pause();
|
|
42
46
|
});
|
|
43
47
|
|
|
44
48
|
_defineProperty(this, "seekTo", function (seconds) {
|
|
45
|
-
_this.video
|
|
49
|
+
if (_this.video) {
|
|
50
|
+
_this.video.currentTime = seconds;
|
|
51
|
+
}
|
|
46
52
|
});
|
|
47
53
|
|
|
48
54
|
_defineProperty(this, "setVolume", function (fraction) {
|
|
49
|
-
_this.video
|
|
55
|
+
if (_this.video) {
|
|
56
|
+
_this.video.volume = fraction;
|
|
57
|
+
}
|
|
50
58
|
});
|
|
51
59
|
|
|
52
60
|
_defineProperty(this, "getVolume", function () {
|
|
53
|
-
|
|
61
|
+
var _this$video3;
|
|
62
|
+
|
|
63
|
+
return (_this$video3 = _this.video) === null || _this$video3 === void 0 ? void 0 : _this$video3.volume;
|
|
54
64
|
});
|
|
55
65
|
|
|
56
66
|
_defineProperty(this, "mute", function () {
|
|
57
|
-
_this.video
|
|
67
|
+
if (_this.video) {
|
|
68
|
+
_this.video.muted = true;
|
|
69
|
+
}
|
|
58
70
|
});
|
|
59
71
|
|
|
60
72
|
_defineProperty(this, "unmute", function () {
|
|
61
|
-
_this.video
|
|
73
|
+
if (_this.video) {
|
|
74
|
+
_this.video.muted = false;
|
|
75
|
+
}
|
|
62
76
|
});
|
|
63
77
|
|
|
64
78
|
_defineProperty(this, "requestPictureInPicture", function () {
|
|
65
|
-
_this
|
|
79
|
+
var _this$video4;
|
|
80
|
+
|
|
81
|
+
(_this$video4 = _this.video) === null || _this$video4 === void 0 ? void 0 : _this$video4.requestPictureInPicture();
|
|
66
82
|
});
|
|
67
83
|
|
|
68
84
|
_defineProperty(this, "exitPictureInPicture", function () {
|
|
@@ -72,15 +88,17 @@ var Api = /*#__PURE__*/function () {
|
|
|
72
88
|
});
|
|
73
89
|
|
|
74
90
|
_defineProperty(this, "setPlaybackRate", function (rate) {
|
|
75
|
-
_this.video
|
|
91
|
+
if (_this.video) {
|
|
92
|
+
_this.video.playbackRate = rate;
|
|
93
|
+
}
|
|
76
94
|
});
|
|
77
95
|
|
|
78
96
|
_defineProperty(this, "getDuration", function () {
|
|
79
|
-
var
|
|
80
|
-
duration =
|
|
81
|
-
seekable =
|
|
97
|
+
var _ref = _this.video || {},
|
|
98
|
+
duration = _ref.duration,
|
|
99
|
+
seekable = _ref.seekable;
|
|
82
100
|
|
|
83
|
-
if (duration === Infinity && seekable.length > 0) {
|
|
101
|
+
if (duration === Infinity && seekable && seekable.length > 0) {
|
|
84
102
|
return seekable.end(seekable.length - 1);
|
|
85
103
|
}
|
|
86
104
|
|
|
@@ -88,7 +106,9 @@ var Api = /*#__PURE__*/function () {
|
|
|
88
106
|
});
|
|
89
107
|
|
|
90
108
|
_defineProperty(this, "getCurrentTime", function () {
|
|
91
|
-
|
|
109
|
+
var _this$video5;
|
|
110
|
+
|
|
111
|
+
return (_this$video5 = _this.video) === null || _this$video5 === void 0 ? void 0 : _this$video5.currentTime;
|
|
92
112
|
});
|
|
93
113
|
|
|
94
114
|
_defineProperty(this, "getSecondsLoaded", function () {
|
|
@@ -96,30 +116,34 @@ var Api = /*#__PURE__*/function () {
|
|
|
96
116
|
});
|
|
97
117
|
|
|
98
118
|
_defineProperty(this, "getBufferedTime", function () {
|
|
99
|
-
var
|
|
119
|
+
var _buffered$end, _buffered$start, _this$getDuration;
|
|
120
|
+
|
|
121
|
+
var _ref2 = _this.video || {},
|
|
122
|
+
buffered = _ref2.buffered;
|
|
100
123
|
|
|
101
|
-
if (buffered.length === 0) {
|
|
124
|
+
if (buffered && buffered.length === 0) {
|
|
102
125
|
return [0, 0];
|
|
103
126
|
}
|
|
104
127
|
|
|
105
|
-
var end = buffered.end(buffered.length - 1);
|
|
106
|
-
var start = buffered.start(buffered.length - 1);
|
|
107
|
-
|
|
108
|
-
var duration = _this.getDuration();
|
|
128
|
+
var end = (_buffered$end = buffered === null || buffered === void 0 ? void 0 : buffered.end(buffered.length - 1)) !== null && _buffered$end !== void 0 ? _buffered$end : 0;
|
|
129
|
+
var start = (_buffered$start = buffered === null || buffered === void 0 ? void 0 : buffered.start(buffered.length - 1)) !== null && _buffered$start !== void 0 ? _buffered$start : 0;
|
|
130
|
+
var duration = (_this$getDuration = _this.getDuration()) !== null && _this$getDuration !== void 0 ? _this$getDuration : 0;
|
|
109
131
|
|
|
110
132
|
if (end > duration) {
|
|
111
|
-
return duration;
|
|
133
|
+
return [start, duration];
|
|
112
134
|
}
|
|
113
135
|
|
|
114
136
|
return [start, end];
|
|
115
137
|
});
|
|
116
138
|
|
|
117
139
|
_defineProperty(this, "snapshot", function () {
|
|
140
|
+
var _this$video$videoWidt, _this$video6, _this$video$videoHeig, _this$video7, _ctx;
|
|
141
|
+
|
|
118
142
|
var canvas = document.createElement('canvas');
|
|
119
143
|
var ctx = canvas.getContext('2d');
|
|
120
|
-
canvas.width = _this.video.videoWidth;
|
|
121
|
-
canvas.height = _this.video.videoHeight;
|
|
122
|
-
ctx.drawImage(_this.video, 0, 0, canvas.width, canvas.height);
|
|
144
|
+
canvas.width = (_this$video$videoWidt = (_this$video6 = _this.video) === null || _this$video6 === void 0 ? void 0 : _this$video6.videoWidth) !== null && _this$video$videoWidt !== void 0 ? _this$video$videoWidt : 0;
|
|
145
|
+
canvas.height = (_this$video$videoHeig = (_this$video7 = _this.video) === null || _this$video7 === void 0 ? void 0 : _this$video7.videoHeight) !== null && _this$video$videoHeig !== void 0 ? _this$video$videoHeig : 0;
|
|
146
|
+
(_ctx = ctx) === null || _ctx === void 0 ? void 0 : _ctx.drawImage(_this.video, 0, 0, canvas.width, canvas.height);
|
|
123
147
|
setTimeout(function () {
|
|
124
148
|
canvas.remove();
|
|
125
149
|
canvas = null;
|
|
@@ -153,12 +177,16 @@ var Api = /*#__PURE__*/function () {
|
|
|
153
177
|
}, {
|
|
154
178
|
key: "paused",
|
|
155
179
|
get: function get() {
|
|
156
|
-
|
|
180
|
+
var _this$video8;
|
|
181
|
+
|
|
182
|
+
return (_this$video8 = this.video) === null || _this$video8 === void 0 ? void 0 : _this$video8.paused;
|
|
157
183
|
}
|
|
158
184
|
}, {
|
|
159
185
|
key: "muted",
|
|
160
186
|
get: function get() {
|
|
161
|
-
|
|
187
|
+
var _this$video9;
|
|
188
|
+
|
|
189
|
+
return (_this$video9 = this.video) === null || _this$video9 === void 0 ? void 0 : _this$video9.muted;
|
|
162
190
|
}
|
|
163
191
|
/**
|
|
164
192
|
* 设置currentTime实现seek
|
|
@@ -204,28 +232,32 @@ export function useTypeAndPlay(url, type, isLive, container, segments, flvConfig
|
|
|
204
232
|
|
|
205
233
|
default:
|
|
206
234
|
options.type = 'native';
|
|
207
|
-
video.setAttribute('src', url);
|
|
235
|
+
video === null || video === void 0 ? void 0 : video.setAttribute('src', url !== null && url !== void 0 ? url : '');
|
|
208
236
|
break;
|
|
209
237
|
}
|
|
210
238
|
|
|
211
|
-
video.paused && tryCatch(function () {
|
|
212
|
-
return video.play();
|
|
239
|
+
(video === null || video === void 0 ? void 0 : video.paused) && tryCatch(function () {
|
|
240
|
+
return video === null || video === void 0 ? void 0 : video.play();
|
|
213
241
|
});
|
|
214
242
|
setState(options);
|
|
215
243
|
return function () {
|
|
216
244
|
if (options.flv) {
|
|
217
245
|
options.flv.pause();
|
|
218
246
|
tryCatch(function () {
|
|
219
|
-
|
|
247
|
+
var _options$flv;
|
|
248
|
+
|
|
249
|
+
return (_options$flv = options.flv) === null || _options$flv === void 0 ? void 0 : _options$flv.destroy();
|
|
220
250
|
});
|
|
221
251
|
} else if (options.hls) {
|
|
222
|
-
video.pause();
|
|
252
|
+
video === null || video === void 0 ? void 0 : video.pause();
|
|
223
253
|
tryCatch(function () {
|
|
224
|
-
|
|
254
|
+
var _options$hls;
|
|
255
|
+
|
|
256
|
+
return (_options$hls = options.hls) === null || _options$hls === void 0 ? void 0 : _options$hls.destroy();
|
|
225
257
|
});
|
|
226
258
|
} else {
|
|
227
|
-
video.pause();
|
|
228
|
-
video.removeAttribute('src');
|
|
259
|
+
video === null || video === void 0 ? void 0 : video.pause();
|
|
260
|
+
video === null || video === void 0 ? void 0 : video.removeAttribute('src');
|
|
229
261
|
}
|
|
230
262
|
|
|
231
263
|
setState({});
|
|
@@ -235,7 +267,7 @@ export function useTypeAndPlay(url, type, isLive, container, segments, flvConfig
|
|
|
235
267
|
} //创建Api
|
|
236
268
|
|
|
237
269
|
export function usePlayerApi(url, type, isLive, container, segments, flvConfig, hlsConfig) {
|
|
238
|
-
var _useState3 = useState(
|
|
270
|
+
var _useState3 = useState(undefined),
|
|
239
271
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
240
272
|
api = _useState4[0],
|
|
241
273
|
setApi = _useState4[1];
|
package/es/Player/context.d.ts
CHANGED
|
@@ -5,10 +5,10 @@ export interface IPlayerContextProps {
|
|
|
5
5
|
/**
|
|
6
6
|
* @description 用于获取微应用顶层的dom节点
|
|
7
7
|
*/
|
|
8
|
-
container
|
|
9
|
-
api
|
|
10
|
-
event
|
|
11
|
-
isLive
|
|
8
|
+
container?: HTMLElement;
|
|
9
|
+
api?: Api;
|
|
10
|
+
event?: VideoEventInstance;
|
|
11
|
+
isLive?: boolean;
|
|
12
12
|
isFpsPlay: boolean;
|
|
13
13
|
children: React.ReactNode;
|
|
14
14
|
}
|
|
@@ -13,7 +13,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
13
13
|
|
|
14
14
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
15
|
|
|
16
|
-
import React, {
|
|
16
|
+
import React, { useContext, useRef, useState } from 'react';
|
|
17
17
|
import { Context } from "../context";
|
|
18
18
|
import EventName from "../event/eventName";
|
|
19
19
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -26,7 +26,7 @@ function ContrallerEvent(_ref) {
|
|
|
26
26
|
event = _useContext.event,
|
|
27
27
|
container = _useContext.container;
|
|
28
28
|
|
|
29
|
-
var timer = useRef(
|
|
29
|
+
var timer = useRef();
|
|
30
30
|
|
|
31
31
|
var _useState = useState(true),
|
|
32
32
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -36,14 +36,14 @@ function ContrallerEvent(_ref) {
|
|
|
36
36
|
var showContraller = function showContraller() {
|
|
37
37
|
clearTimeout(timer.current);
|
|
38
38
|
setVisibel(true);
|
|
39
|
-
event.emit(EventName.SHOW_CONTRALLER);
|
|
39
|
+
event === null || event === void 0 ? void 0 : event.emit(EventName.SHOW_CONTRALLER);
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
var hideContraller = function hideContraller() {
|
|
43
43
|
clearTimeout(timer.current);
|
|
44
44
|
timer.current = setTimeout(function () {
|
|
45
45
|
setVisibel(false);
|
|
46
|
-
event.emit(EventName.HIDE_CONTRALLER);
|
|
46
|
+
event === null || event === void 0 ? void 0 : event.emit(EventName.HIDE_CONTRALLER);
|
|
47
47
|
}, 3 * 1000);
|
|
48
48
|
};
|
|
49
49
|
|