@ray-js/ipc-player-integration 0.0.60-beta.0 → 0.0.61-beta.0
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/lib/ctx/ctx.album.test.d.ts +1 -0
- package/lib/ctx/ctx.album.test.js +197 -0
- package/lib/ctx/ctx.composition.js +19 -4
- package/lib/ctx/ctx.js +100 -55
- package/lib/ctx/ports.output.d.ts +1 -0
- package/lib/ctx/resolution.d.ts +1 -1
- package/lib/ctx/resolution.js +3 -1
- package/lib/i18n/index.d.ts +12 -0
- package/lib/i18n/strings.d.ts +6 -0
- package/lib/i18n/strings.js +6 -0
- package/lib/interface.d.ts +18 -3
- package/lib/ui/absoluteContent.d.ts +2 -0
- package/lib/ui/absoluteContent.js +3 -0
- package/lib/ui/ui.d.ts +2 -0
- package/lib/ui/ui.js +30 -26
- package/lib/utils/captureResult.d.ts +14 -0
- package/lib/utils/captureResult.js +70 -0
- package/lib/utils/captureResult.test.d.ts +1 -0
- package/lib/utils/captureResult.test.js +117 -0
- package/lib/utils/ttt.js +2 -8
- package/lib/widgets/captureResult/captureResult.d.ts +16 -0
- package/lib/widgets/captureResult/captureResult.js +85 -0
- package/lib/widgets/captureResult/captureResult.less +144 -0
- package/lib/widgets/captureResult/captureResult.test.d.ts +1 -0
- package/lib/widgets/captureResult/captureResult.test.js +80 -0
- package/lib/widgets/captureResult/index.d.ts +2 -0
- package/lib/widgets/captureResult/index.js +2 -0
- package/lib/widgets/index.d.ts +1 -0
- package/lib/widgets/index.js +2 -1
- package/lib/widgets/muted/muted.js +9 -3
- package/lib/widgets/muted/muted.less +5 -1
- package/lib/widgets/muted/muted.test.d.ts +1 -0
- package/lib/widgets/muted/muted.test.js +81 -0
- package/lib/widgets/recordVideo/recordVideo.js +53 -52
- package/lib/widgets/recordVideo/recordVideo.less +17 -74
- package/lib/widgets/recordVideo/recordVideo.lifecycle.test.d.ts +1 -0
- package/lib/widgets/recordVideo/recordVideo.lifecycle.test.js +106 -0
- package/lib/widgets/recordVideo/recordVideo.test.js +1 -0
- package/lib/widgets/screenshot/screenshot.js +66 -44
- package/lib/widgets/screenshot/screenshot.less +1 -40
- package/lib/widgets/screenshot/screenshot.test.d.ts +1 -0
- package/lib/widgets/screenshot/screenshot.test.js +120 -0
- package/lib/widgets/tryExperience/tryExperience.js +0 -1
- package/package.json +3 -2
|
@@ -1,116 +1,59 @@
|
|
|
1
1
|
.ipc-player-plugin-record-video-icon {
|
|
2
|
-
font-size: calc(var(--iconPlayerSize) * var(--ipc-player-size-scale, 1)) !important;
|
|
3
2
|
color: var(--iconColor);
|
|
3
|
+
font-size: calc(var(--iconPlayerSize) * var(--ipc-player-size-scale, 1)) !important;
|
|
4
4
|
}
|
|
5
|
+
|
|
5
6
|
.ipc-player-plugin-record-video-toast-wrap {
|
|
6
|
-
z-index: 400;
|
|
7
7
|
position: absolute;
|
|
8
8
|
top: calc(7px * var(--ipc-player-size-scale, 1));
|
|
9
9
|
left: 50%;
|
|
10
|
+
z-index: 400;
|
|
10
11
|
transform: translateX(-50%);
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
// 计时器显示
|
|
14
14
|
.ipc-player-plugin-record-video-toast-show {
|
|
15
15
|
transform: translate(0, 0) !important;
|
|
16
16
|
transition: transform ease-in 3s;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
.ipc-player-plugin-record-video-toast-hide {
|
|
20
20
|
transform: translate(0, -110%) !important;
|
|
21
21
|
transition: transform 0.3s ease-in-out;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
.ipc-player-plugin-record-video-toast {
|
|
25
|
-
transform: translate(0, -110%);
|
|
26
25
|
display: flex;
|
|
27
|
-
padding: calc(12px * var(--ipc-player-size-scale, 1));
|
|
28
26
|
align-items: center;
|
|
29
|
-
|
|
27
|
+
padding: calc(12px * var(--ipc-player-size-scale, 1));
|
|
28
|
+
background: linear-gradient(0deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.15)),
|
|
29
|
+
#000000;
|
|
30
30
|
border-radius: calc(8px * var(--ipc-player-size-scale, 1));
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
transform: translate(0, -110%);
|
|
32
|
+
|
|
33
33
|
.ipc-player-plugin-record-video-toast-point {
|
|
34
34
|
width: calc(6px * var(--ipc-player-size-scale, 1));
|
|
35
35
|
height: calc(6px * var(--ipc-player-size-scale, 1));
|
|
36
36
|
border-radius: calc(6px * var(--ipc-player-size-scale, 1));
|
|
37
37
|
}
|
|
38
|
+
|
|
38
39
|
.ipc-player-plugin-record-video-toast-time {
|
|
39
|
-
font-size: calc(12px * var(--ipc-player-size-scale, 1));;
|
|
40
|
-
font-weight: 700;
|
|
41
|
-
color: var(--fontColor);
|
|
42
|
-
margin-left: calc(8px * var(--ipc-player-size-scale, 1));;
|
|
43
40
|
display: flex;
|
|
44
41
|
align-items: center;
|
|
42
|
+
margin-left: calc(8px * var(--ipc-player-size-scale, 1));
|
|
43
|
+
color: var(--fontColor);
|
|
44
|
+
font-weight: 700;
|
|
45
|
+
font-size: calc(12px * var(--ipc-player-size-scale, 1));
|
|
46
|
+
|
|
45
47
|
.ipc-player-plugin-record-video-toast-time-warp {
|
|
46
48
|
text-align: center;
|
|
47
49
|
}
|
|
50
|
+
|
|
48
51
|
.ipc-player-plugin-record-video-toast-time-delimiter {
|
|
49
|
-
margin: 0 calc(2px * var(--ipc-player-size-scale, 1))
|
|
52
|
+
margin: 0 calc(2px * var(--ipc-player-size-scale, 1));
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
|
|
54
|
-
/** 录制成功弹窗 */
|
|
55
57
|
.ipc-player-plugin-record-success-toast-wrap {
|
|
56
58
|
position: absolute;
|
|
57
59
|
}
|
|
58
|
-
.ipc-player-plugin-record-success-toast {
|
|
59
|
-
flex: 1;
|
|
60
|
-
border-radius: calc(8px * var(--ipc-player-size-scale, 1));;
|
|
61
|
-
background-color: var(--shot-card-bg-color);
|
|
62
|
-
display: flex;
|
|
63
|
-
align-items: center;
|
|
64
|
-
padding: calc(8px * var(--ipc-player-size-scale, 1)) calc(12px * var(--ipc-player-size-scale, 1));
|
|
65
|
-
z-index: 100;
|
|
66
|
-
.ipc-player-plugin-record-success-toast-image-box {
|
|
67
|
-
border-radius: calc(4px * var(--ipc-player-size-scale, 1));
|
|
68
|
-
overflow: hidden;
|
|
69
|
-
width: calc(66px * var(--ipc-player-size-scale, 1));
|
|
70
|
-
height: calc(66px * 0.57 * var(--ipc-player-size-scale, 1));
|
|
71
|
-
position: relative;
|
|
72
|
-
}
|
|
73
|
-
.ipc-player-plugin-record-success-toast-image {
|
|
74
|
-
width: 100%;
|
|
75
|
-
height: 100%;
|
|
76
|
-
object-fit: cover;
|
|
77
|
-
}
|
|
78
|
-
.ipc-player-plugin-record-success-play-icon-box {
|
|
79
|
-
width: 30px;
|
|
80
|
-
height: 30px;
|
|
81
|
-
background-color: rgba(0, 0, 0, 0.2);
|
|
82
|
-
border-radius: 50%;
|
|
83
|
-
overflow: hidden;
|
|
84
|
-
position: absolute;
|
|
85
|
-
top: 50%;
|
|
86
|
-
left: 50%;
|
|
87
|
-
transform: translate(-50%, -50%);
|
|
88
|
-
display: flex;
|
|
89
|
-
align-items: center;
|
|
90
|
-
justify-content: center;
|
|
91
|
-
}
|
|
92
|
-
.ipc-player-plugin-record-success-play-icon {
|
|
93
|
-
font-size: calc(18px * var(--ipc-player-size-scale, 1)) !important;
|
|
94
|
-
color: #ffffff;
|
|
95
|
-
}
|
|
96
|
-
.ipc-player-plugin-record-success-toast-title {
|
|
97
|
-
flex: 1;
|
|
98
|
-
margin-left: calc(12px * var(--ipc-player-size-scale, 1));
|
|
99
|
-
font-size: calc(14px * var(--ipc-player-size-scale, 1));
|
|
100
|
-
color: var(--fontColor);
|
|
101
|
-
margin-right: calc(12px * var(--ipc-player-size-scale, 1));
|
|
102
|
-
word-break: break-word;
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
.ipc-player-plugin-record-success-toast-bottom {
|
|
106
|
-
border: 1px solid #1989FA;
|
|
107
|
-
min-width: calc(52px * var(--ipc-player-size-scale, 1));
|
|
108
|
-
max-width: calc(100px * var(--ipc-player-size-scale, 1));
|
|
109
|
-
border-radius: calc(4px * var(--ipc-player-size-scale, 1));
|
|
110
|
-
padding: calc(5px * var(--ipc-player-size-scale, 1)) calc(11px * var(--ipc-player-size-scale, 1));
|
|
111
|
-
font-size: calc(14px * var(--ipc-player-size-scale, 1));
|
|
112
|
-
white-space: nowrap;
|
|
113
|
-
overflow: hidden;
|
|
114
|
-
text-overflow: ellipsis;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
|
+
import "core-js/modules/esnext.iterator.filter.js";
|
|
3
|
+
import "core-js/modules/esnext.iterator.map.js";
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
|
+
import ReactDOM from 'react-dom';
|
|
6
|
+
import { act, Simulate } from 'react-dom/test-utils';
|
|
7
|
+
import { atom, getDefaultStore } from 'jotai';
|
|
8
|
+
import { PlayState } from '../../interface';
|
|
9
|
+
import { RecordVideo } from './recordVideo';
|
|
10
|
+
jest.mock('@ray-js/ray', () => ({
|
|
11
|
+
View: 'div',
|
|
12
|
+
Text: 'span',
|
|
13
|
+
Image: 'img',
|
|
14
|
+
getSystemInfoSync: () => ({
|
|
15
|
+
platform: 'android'
|
|
16
|
+
})
|
|
17
|
+
}));
|
|
18
|
+
jest.mock('@ray-js/ray-ipc-utils', () => ({
|
|
19
|
+
goToIpcPageNativeRoute: jest.fn()
|
|
20
|
+
}));
|
|
21
|
+
jest.mock('@ray-js/ray-ipc-utils/lib/interface', () => ({}));
|
|
22
|
+
jest.mock('../../utils/device', () => ({
|
|
23
|
+
getDeviceInfo: jest.fn()
|
|
24
|
+
}));
|
|
25
|
+
jest.mock('../../i18n', () => ({
|
|
26
|
+
__esModule: true,
|
|
27
|
+
default: {
|
|
28
|
+
getLang: key => key
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
jest.mock('./recordVideo.less', () => ({}));
|
|
32
|
+
jest.mock('../captureResult/captureResult.less', () => ({}));
|
|
33
|
+
describe('RecordVideo', () => {
|
|
34
|
+
let container;
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
jest.useFakeTimers('modern');
|
|
37
|
+
container = document.createElement('div');
|
|
38
|
+
document.body.appendChild(container);
|
|
39
|
+
});
|
|
40
|
+
afterEach(() => {
|
|
41
|
+
act(() => ReactDOM.unmountComponentAtNode(container));
|
|
42
|
+
container.remove();
|
|
43
|
+
jest.clearAllTimers();
|
|
44
|
+
jest.useRealTimers();
|
|
45
|
+
});
|
|
46
|
+
it.each([false, true])('removes the recording timer after stop (remounted: %s)', async remount => {
|
|
47
|
+
var _container$querySelec, _container$querySelec2;
|
|
48
|
+
const store = getDefaultStore();
|
|
49
|
+
const recording = atom(false);
|
|
50
|
+
const recordingDisabled = atom(false);
|
|
51
|
+
const screenType = atom('vertical');
|
|
52
|
+
const setRecording = jest.fn(async value => {
|
|
53
|
+
store.set(recording, value);
|
|
54
|
+
return value ? true : {
|
|
55
|
+
tempImagePath: 'thingfile://record.jpg'
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
function Harness(_ref) {
|
|
59
|
+
let {
|
|
60
|
+
widgetKey
|
|
61
|
+
} = _ref;
|
|
62
|
+
const [contents, setContents] = useState([]);
|
|
63
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(RecordVideo, {
|
|
64
|
+
key: widgetKey,
|
|
65
|
+
devId: 'device',
|
|
66
|
+
recording,
|
|
67
|
+
recordingDisabled,
|
|
68
|
+
screenType,
|
|
69
|
+
brandColor: atom('#ff592a'),
|
|
70
|
+
playState: atom(PlayState.PLAYING),
|
|
71
|
+
setRecording,
|
|
72
|
+
setRecordingDisabled: value => store.set(recordingDisabled, value),
|
|
73
|
+
addContent: (_type, content) => setContents(items => [...items, content]),
|
|
74
|
+
deleteContent: (_type, id) => setContents(items => items.filter(item => item.id !== id))
|
|
75
|
+
}), contents.map(item => /*#__PURE__*/React.createElement(item.content, {
|
|
76
|
+
key: item.id
|
|
77
|
+
})));
|
|
78
|
+
}
|
|
79
|
+
const clickRecord = async () => {
|
|
80
|
+
await act(async () => {
|
|
81
|
+
Simulate.click(container.querySelector('.ipc-player-plugin-record-video-icon').parentElement);
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
await act(async () => {
|
|
85
|
+
ReactDOM.render(/*#__PURE__*/React.createElement(Harness, {
|
|
86
|
+
widgetKey: 0
|
|
87
|
+
}), container);
|
|
88
|
+
});
|
|
89
|
+
await clickRecord();
|
|
90
|
+
act(() => jest.advanceTimersByTime(3000));
|
|
91
|
+
expect((_container$querySelec = container.querySelector('.ipc-player-plugin-record-video-toast-time')) === null || _container$querySelec === void 0 ? void 0 : _container$querySelec.textContent).toBe('00:03');
|
|
92
|
+
if (remount) {
|
|
93
|
+
await act(async () => {
|
|
94
|
+
store.set(screenType, 'full');
|
|
95
|
+
ReactDOM.render(/*#__PURE__*/React.createElement(Harness, {
|
|
96
|
+
widgetKey: 1
|
|
97
|
+
}), container);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
expect((_container$querySelec2 = container.querySelector('.ipc-player-plugin-record-video-toast-time')) === null || _container$querySelec2 === void 0 ? void 0 : _container$querySelec2.textContent).toBe('00:03');
|
|
101
|
+
await clickRecord();
|
|
102
|
+
expect(setRecording).toHaveBeenLastCalledWith(false);
|
|
103
|
+
expect(container.querySelector('.icon-panel-record-stop')).toBeNull();
|
|
104
|
+
expect(container.querySelector('.ipc-player-plugin-record-video-toast-time')).toBeNull();
|
|
105
|
+
});
|
|
106
|
+
});
|
|
@@ -22,6 +22,7 @@ jest.mock('../../i18n', () => ({
|
|
|
22
22
|
}
|
|
23
23
|
}));
|
|
24
24
|
jest.mock('./recordVideo.less', () => ({}));
|
|
25
|
+
jest.mock('../captureResult/captureResult.less', () => ({}));
|
|
25
26
|
it('keeps the record control idle when starting is declined', async () => {
|
|
26
27
|
const addContent = jest.fn();
|
|
27
28
|
const setRecordingDisabled = jest.fn();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { useContext, useRef } from 'react';
|
|
2
|
-
import { View,
|
|
1
|
+
import React, { useContext, useEffect, useRef } from 'react';
|
|
2
|
+
import { View, Text, getSystemInfoSync } from '@ray-js/ray';
|
|
3
3
|
import { useSetState, useUpdateEffect, useMemoizedFn } from 'ahooks';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { goToIpcPageNativeRoute } from '@ray-js/ray-ipc-utils';
|
|
@@ -7,7 +7,9 @@ import Strings from '../../i18n';
|
|
|
7
7
|
import { useStore } from '../../ctx/store';
|
|
8
8
|
import { UIEventContext } from '../../ui/context';
|
|
9
9
|
import { pauseTimeToHideAllComponent, changeIgnoreHideStopPreview, widgetLabs, widgetClick } from '../../ui/constant';
|
|
10
|
+
import { getCaptureResultSummary } from '../../utils/captureResult';
|
|
10
11
|
import { ensureAlbumPermission } from '../../utils/authorize/album';
|
|
12
|
+
import { CaptureResultToast } from '../captureResult/captureResult';
|
|
11
13
|
import './screenshot.less';
|
|
12
14
|
const CLOSE_TIME = 5000;
|
|
13
15
|
export function Screenshot(props) {
|
|
@@ -35,8 +37,15 @@ export function Screenshot(props) {
|
|
|
35
37
|
/** 记录截屏url */
|
|
36
38
|
const [state, setState] = useSetState({
|
|
37
39
|
showShot: false,
|
|
38
|
-
shotUrl: ''
|
|
40
|
+
shotUrl: '',
|
|
41
|
+
shotCount: 0
|
|
39
42
|
});
|
|
43
|
+
const snapshotRequestIdRef = useRef(0);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
return () => {
|
|
46
|
+
snapshotRequestIdRef.current += 1;
|
|
47
|
+
};
|
|
48
|
+
}, []);
|
|
40
49
|
useUpdateEffect(() => {
|
|
41
50
|
if (state.showShot && screenType) {
|
|
42
51
|
showShotToast();
|
|
@@ -49,7 +58,8 @@ export function Screenshot(props) {
|
|
|
49
58
|
timer.current = setTimeout(() => {
|
|
50
59
|
setState({
|
|
51
60
|
showShot: false,
|
|
52
|
-
shotUrl: ''
|
|
61
|
+
shotUrl: '',
|
|
62
|
+
shotCount: 0
|
|
53
63
|
});
|
|
54
64
|
deleteContent('absolute', 'plugin-screenshot-toast');
|
|
55
65
|
}, CLOSE_TIME);
|
|
@@ -59,7 +69,8 @@ export function Screenshot(props) {
|
|
|
59
69
|
const handCheck = () => {
|
|
60
70
|
setState({
|
|
61
71
|
showShot: false,
|
|
62
|
-
shotUrl: ''
|
|
72
|
+
shotUrl: '',
|
|
73
|
+
shotCount: 0
|
|
63
74
|
});
|
|
64
75
|
deleteContent('absolute', 'plugin-screenshot-toast');
|
|
65
76
|
clearInterval(timer.current);
|
|
@@ -81,31 +92,20 @@ export function Screenshot(props) {
|
|
|
81
92
|
marginLeft: screenType === 'vertical' ? '0' : '-200px'
|
|
82
93
|
},
|
|
83
94
|
content: () => {
|
|
84
|
-
return /*#__PURE__*/React.createElement(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
})), /*#__PURE__*/React.createElement(View, {
|
|
92
|
-
className: "ipc-player-plugin-screenshot-toast-title"
|
|
93
|
-
}, Strings.getLang('ipc_player_screenshot_success_tip')), /*#__PURE__*/React.createElement(View, {
|
|
94
|
-
onClick: handCheck,
|
|
95
|
-
className: "ipc-player-plugin-screenshot-toast-bottom",
|
|
96
|
-
style: {
|
|
97
|
-
color: brandColor,
|
|
98
|
-
borderColor: brandColor
|
|
99
|
-
}
|
|
100
|
-
}, Strings.getLang('ipc_player_shot_success_check')));
|
|
95
|
+
return /*#__PURE__*/React.createElement(CaptureResultToast, {
|
|
96
|
+
brandColor: brandColor,
|
|
97
|
+
count: state.shotCount,
|
|
98
|
+
kind: "screenshot",
|
|
99
|
+
onCheck: handCheck,
|
|
100
|
+
thumbnailPath: state.shotUrl
|
|
101
|
+
});
|
|
101
102
|
}
|
|
102
103
|
});
|
|
103
104
|
timeToCloseToast();
|
|
104
105
|
};
|
|
105
106
|
const handClick = useMemoizedFn(async () => {
|
|
106
|
-
var _props$event
|
|
107
|
-
|
|
108
|
-
((_props$event2 = props.event) !== null && _props$event2 !== void 0 ? _props$event2 : event).emit(widgetClick, {
|
|
107
|
+
var _props$event;
|
|
108
|
+
((_props$event = props.event) !== null && _props$event !== void 0 ? _props$event : event).emit(widgetClick, {
|
|
109
109
|
widgetId: widgetLabs.SCREENSHOT
|
|
110
110
|
});
|
|
111
111
|
console.log('截屏!!!');
|
|
@@ -119,27 +119,49 @@ export function Screenshot(props) {
|
|
|
119
119
|
props.event ? props.event.emit(changeIgnoreHideStopPreview, true) : event.emit(changeIgnoreHideStopPreview, true);
|
|
120
120
|
}
|
|
121
121
|
event.emit(pauseTimeToHideAllComponent);
|
|
122
|
+
const setIgnoreHideStopPreview = value => {
|
|
123
|
+
var _props$event2;
|
|
124
|
+
((_props$event2 = props.event) !== null && _props$event2 !== void 0 ? _props$event2 : event).emit(changeIgnoreHideStopPreview, value);
|
|
125
|
+
};
|
|
126
|
+
const handleSnapshotFail = err => {
|
|
127
|
+
setIgnoreHideStopPreview(false);
|
|
128
|
+
console.log(err, 'err');
|
|
129
|
+
const errObj = err.innerError || err || {};
|
|
130
|
+
const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_screenshot_error_tip');
|
|
131
|
+
toast({
|
|
132
|
+
title: errMsg
|
|
133
|
+
});
|
|
134
|
+
};
|
|
122
135
|
const granted = await ensureAlbumPermission();
|
|
123
|
-
|
|
136
|
+
setIgnoreHideStopPreview(false);
|
|
124
137
|
if (!granted) return;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
138
|
+
(() => {
|
|
139
|
+
const requestId = ++snapshotRequestIdRef.current;
|
|
140
|
+
IPCPlayerContext.snapshot({
|
|
141
|
+
saveToAlbum,
|
|
142
|
+
success: async res => {
|
|
143
|
+
var _props$multiCameraCtx;
|
|
144
|
+
setIgnoreHideStopPreview(false);
|
|
145
|
+
const splitNum = (_props$multiCameraCtx = props.multiCameraCtx) === null || _props$multiCameraCtx === void 0 || (_props$multiCameraCtx = _props$multiCameraCtx.protocol) === null || _props$multiCameraCtx === void 0 ? void 0 : _props$multiCameraCtx.total_split_num;
|
|
146
|
+
const summary = await getCaptureResultSummary(res, {
|
|
147
|
+
multiLens: props.multiLens,
|
|
148
|
+
protocolCount: splitNum,
|
|
149
|
+
devId
|
|
150
|
+
});
|
|
151
|
+
if (requestId !== snapshotRequestIdRef.current) return;
|
|
152
|
+
if (!summary) {
|
|
153
|
+
handleSnapshotFail({});
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
setState({
|
|
157
|
+
showShot: true,
|
|
158
|
+
shotUrl: summary.thumbnailPath,
|
|
159
|
+
shotCount: summary.isMultiLens ? summary.count : 0
|
|
160
|
+
});
|
|
161
|
+
},
|
|
162
|
+
fail: handleSnapshotFail
|
|
163
|
+
});
|
|
164
|
+
})();
|
|
143
165
|
});
|
|
144
166
|
if (hideScreenShotMenu) return null;
|
|
145
167
|
return /*#__PURE__*/React.createElement(View, {
|
|
@@ -2,46 +2,7 @@
|
|
|
2
2
|
color: var(--iconColor);
|
|
3
3
|
font-size: calc(var(--iconPlayerSize) * var(--ipc-player-size-scale, 1)) !important;
|
|
4
4
|
}
|
|
5
|
+
|
|
5
6
|
.ipc-player-plugin-screenshot-toast-wrap {
|
|
6
7
|
position: absolute;
|
|
7
8
|
}
|
|
8
|
-
.ipc-player-plugin-screenshot-toast {
|
|
9
|
-
flex: 1;
|
|
10
|
-
border-radius: calc(8px * var(--ipc-player-size-scale, 1));;
|
|
11
|
-
background-color: var(--shot-card-bg-color);
|
|
12
|
-
display: flex;
|
|
13
|
-
align-items: center;
|
|
14
|
-
padding: calc(8px * var(--ipc-player-size-scale, 1)) calc(12px * var(--ipc-player-size-scale, 1));
|
|
15
|
-
z-index: 100;
|
|
16
|
-
.ipc-player-plugin-screenshot-toast-image-box {
|
|
17
|
-
border-radius: calc(4px * var(--ipc-player-size-scale, 1));
|
|
18
|
-
overflow: hidden;
|
|
19
|
-
width: calc(66px * var(--ipc-player-size-scale, 1));
|
|
20
|
-
height: calc(66px * 0.57 * var(--ipc-player-size-scale, 1));
|
|
21
|
-
}
|
|
22
|
-
.ipc-player-plugin-screenshot-toast-image {
|
|
23
|
-
width: 100%;
|
|
24
|
-
height: 100%;
|
|
25
|
-
object-fit: cover;
|
|
26
|
-
}
|
|
27
|
-
.ipc-player-plugin-screenshot-toast-title {
|
|
28
|
-
flex: 1;
|
|
29
|
-
margin-left: calc(12px * var(--ipc-player-size-scale, 1));
|
|
30
|
-
font-size: calc(14px * var(--ipc-player-size-scale, 1));
|
|
31
|
-
color: var(--fontColor);
|
|
32
|
-
margin-right: calc(12px * var(--ipc-player-size-scale, 1));
|
|
33
|
-
word-break: break-word;
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
.ipc-player-plugin-screenshot-toast-bottom {
|
|
37
|
-
border: 1px solid #1989FA;
|
|
38
|
-
min-width: calc(52px * var(--ipc-player-size-scale, 1));
|
|
39
|
-
max-width: calc(100px * var(--ipc-player-size-scale, 1));
|
|
40
|
-
border-radius: calc(4px * var(--ipc-player-size-scale, 1));
|
|
41
|
-
padding: calc(5px * var(--ipc-player-size-scale, 1)) calc(11px * var(--ipc-player-size-scale, 1));
|
|
42
|
-
font-size: calc(14px * var(--ipc-player-size-scale, 1));
|
|
43
|
-
white-space: nowrap;
|
|
44
|
-
overflow: hidden;
|
|
45
|
-
text-overflow: ellipsis;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { act, renderHook } from '@testing-library/react-hooks/dom';
|
|
2
|
+
import { atom } from 'jotai';
|
|
3
|
+
import { authorize, authorizeStatus, getSystemInfoSync, showModal } from '@ray-js/ray';
|
|
4
|
+
import { getDeviceInfo } from '../../utils/device';
|
|
5
|
+
import { Screenshot } from './screenshot';
|
|
6
|
+
jest.mock('@ray-js/ray', () => ({
|
|
7
|
+
View: 'div',
|
|
8
|
+
Text: 'span',
|
|
9
|
+
Image: 'img',
|
|
10
|
+
getSystemInfoSync: jest.fn(),
|
|
11
|
+
authorize: jest.fn(),
|
|
12
|
+
authorizeStatus: jest.fn(),
|
|
13
|
+
showModal: jest.fn(),
|
|
14
|
+
openAppSystemSettingPage: jest.fn()
|
|
15
|
+
}));
|
|
16
|
+
jest.mock('@ray-js/ray-ipc-utils', () => ({
|
|
17
|
+
goToIpcPageNativeRoute: jest.fn()
|
|
18
|
+
}));
|
|
19
|
+
jest.mock('../../utils/device', () => ({
|
|
20
|
+
getDeviceInfo: jest.fn()
|
|
21
|
+
}));
|
|
22
|
+
jest.mock('../../i18n', () => ({
|
|
23
|
+
__esModule: true,
|
|
24
|
+
default: {
|
|
25
|
+
getLang: key => key
|
|
26
|
+
}
|
|
27
|
+
}));
|
|
28
|
+
jest.mock('./screenshot.less', () => ({}));
|
|
29
|
+
jest.mock('../captureResult/captureResult.less', () => ({}));
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
jest.clearAllMocks();
|
|
32
|
+
getSystemInfoSync.mockReturnValue({
|
|
33
|
+
platform: 'android',
|
|
34
|
+
system: 'android 12'
|
|
35
|
+
});
|
|
36
|
+
authorizeStatus.mockImplementation(_ref => {
|
|
37
|
+
let {
|
|
38
|
+
fail
|
|
39
|
+
} = _ref;
|
|
40
|
+
return fail({
|
|
41
|
+
errorCode: 9004
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
authorize.mockImplementation(_ref2 => {
|
|
45
|
+
let {
|
|
46
|
+
fail
|
|
47
|
+
} = _ref2;
|
|
48
|
+
return fail({
|
|
49
|
+
errorCode: 9004
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
getDeviceInfo.mockResolvedValue({
|
|
53
|
+
configMetas: {
|
|
54
|
+
tyabimr4v3: {
|
|
55
|
+
total_split_num: 3
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
const createProps = () => ({
|
|
61
|
+
IPCPlayerContext: {
|
|
62
|
+
snapshot: jest.fn(_ref3 => {
|
|
63
|
+
let {
|
|
64
|
+
success
|
|
65
|
+
} = _ref3;
|
|
66
|
+
return success({
|
|
67
|
+
tempImagePath: 'thingfile://capture.jpg'
|
|
68
|
+
});
|
|
69
|
+
})
|
|
70
|
+
},
|
|
71
|
+
addContent: jest.fn(),
|
|
72
|
+
deleteContent: jest.fn(),
|
|
73
|
+
saveToAlbum: 0,
|
|
74
|
+
devId: 'camera-1',
|
|
75
|
+
toast: jest.fn(),
|
|
76
|
+
screenType: atom('vertical'),
|
|
77
|
+
brandColor: atom('#000000'),
|
|
78
|
+
multiLens: true,
|
|
79
|
+
event: {
|
|
80
|
+
emit: jest.fn()
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
it('keeps multi-lens results when legacy album authorization is unavailable', async () => {
|
|
84
|
+
const props = createProps();
|
|
85
|
+
const {
|
|
86
|
+
result,
|
|
87
|
+
unmount
|
|
88
|
+
} = renderHook(() => Screenshot(props));
|
|
89
|
+
await act(async () => {
|
|
90
|
+
await result.current.props.onClick();
|
|
91
|
+
});
|
|
92
|
+
expect(authorizeStatus).not.toHaveBeenCalled();
|
|
93
|
+
expect(props.IPCPlayerContext.snapshot).toHaveBeenCalledWith(expect.objectContaining({
|
|
94
|
+
saveToAlbum: 0
|
|
95
|
+
}));
|
|
96
|
+
const [, config] = props.addContent.mock.calls[0];
|
|
97
|
+
expect(config.content().props).toEqual(expect.objectContaining({
|
|
98
|
+
count: 3,
|
|
99
|
+
thumbnailPath: 'thingfile://capture_lens1.jpg'
|
|
100
|
+
}));
|
|
101
|
+
unmount();
|
|
102
|
+
});
|
|
103
|
+
it('keeps the permission rejection path before taking a snapshot', async () => {
|
|
104
|
+
getSystemInfoSync.mockReturnValue({
|
|
105
|
+
platform: 'ios',
|
|
106
|
+
system: 'iOS 18'
|
|
107
|
+
});
|
|
108
|
+
const props = createProps();
|
|
109
|
+
const {
|
|
110
|
+
result,
|
|
111
|
+
unmount
|
|
112
|
+
} = renderHook(() => Screenshot(props));
|
|
113
|
+
await act(async () => {
|
|
114
|
+
await result.current.props.onClick();
|
|
115
|
+
});
|
|
116
|
+
expect(props.IPCPlayerContext.snapshot).not.toHaveBeenCalled();
|
|
117
|
+
expect(props.addContent).not.toHaveBeenCalled();
|
|
118
|
+
expect(showModal).toHaveBeenCalledTimes(1);
|
|
119
|
+
unmount();
|
|
120
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/ipc-player-integration",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.61-beta.0",
|
|
4
4
|
"description": "IPC 融合播放器",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"files": [
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@ray-js/direction-control": "^0.0.8",
|
|
39
39
|
"@ray-js/ipc-ptz-zoom": "^0.0.3",
|
|
40
|
-
"@ray-js/
|
|
40
|
+
"@ray-js/panel-sdk": "^1.13.1",
|
|
41
|
+
"@ray-js/ray-ipc-player": "2.1.5-beta.0",
|
|
41
42
|
"@ray-js/ray-ipc-utils": "^1.1.16",
|
|
42
43
|
"@ray-js/svg": "0.2.0",
|
|
43
44
|
"clsx": "^1.2.1",
|