@ray-js/ipc-player-integration 0.0.61-beta.1 → 0.0.63
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.composition.js +4 -19
- package/lib/ctx/ctx.js +55 -103
- package/lib/ctx/ports.output.d.ts +0 -1
- package/lib/ctx/resolution.d.ts +1 -1
- package/lib/ctx/resolution.js +1 -3
- package/lib/i18n/index.d.ts +0 -12
- package/lib/i18n/strings.d.ts +0 -6
- package/lib/i18n/strings.js +0 -6
- package/lib/interface.d.ts +3 -19
- package/lib/ui/bottomLeftContent.js +1 -3
- package/lib/ui/ui.d.ts +0 -2
- package/lib/ui/ui.js +26 -30
- package/lib/utils/navigation.d.ts +1 -2
- package/lib/utils/navigation.js +3 -13
- package/lib/utils/ttt.js +8 -2
- package/lib/widgets/index.d.ts +0 -1
- package/lib/widgets/index.js +1 -2
- package/lib/widgets/recordVideo/recordVideo.js +52 -53
- package/lib/widgets/recordVideo/recordVideo.less +74 -17
- package/lib/widgets/recordVideo/recordVideo.test.js +0 -1
- package/lib/widgets/screenshot/screenshot.js +44 -66
- package/lib/widgets/screenshot/screenshot.less +40 -1
- package/lib/widgets/trialBadge/index.d.ts +1 -2
- package/lib/widgets/trialBadge/index.js +9 -17
- package/lib/widgets/trialBadge/useTrialBadge.d.ts +2 -3
- package/lib/widgets/trialBadge/useTrialBadge.js +2 -13
- package/lib/widgets/tryExperience/tryExperience.js +1 -0
- package/package.json +2 -3
- package/lib/ctx/ctx.album.test.d.ts +0 -1
- package/lib/ctx/ctx.album.test.js +0 -197
- package/lib/ui/absoluteContent.d.ts +0 -2
- package/lib/ui/absoluteContent.js +0 -3
- package/lib/utils/captureResult.d.ts +0 -14
- package/lib/utils/captureResult.js +0 -70
- package/lib/utils/captureResult.test.d.ts +0 -1
- package/lib/utils/captureResult.test.js +0 -117
- package/lib/utils/fullLinkTracking.d.ts +0 -5
- package/lib/utils/fullLinkTracking.js +0 -71
- package/lib/widgets/captureResult/captureResult.d.ts +0 -16
- package/lib/widgets/captureResult/captureResult.js +0 -85
- package/lib/widgets/captureResult/captureResult.less +0 -144
- package/lib/widgets/captureResult/captureResult.test.d.ts +0 -1
- package/lib/widgets/captureResult/captureResult.test.js +0 -80
- package/lib/widgets/captureResult/index.d.ts +0 -2
- package/lib/widgets/captureResult/index.js +0 -2
- package/lib/widgets/recordVideo/recordVideo.lifecycle.test.d.ts +0 -1
- package/lib/widgets/recordVideo/recordVideo.lifecycle.test.js +0 -106
- package/lib/widgets/screenshot/screenshot.test.d.ts +0 -1
- package/lib/widgets/screenshot/screenshot.test.js +0 -120
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { useContext,
|
|
2
|
-
import { View, Text, getSystemInfoSync } from '@ray-js/ray';
|
|
1
|
+
import React, { useContext, useRef } from 'react';
|
|
2
|
+
import { View, Image, 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,9 +7,7 @@ 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';
|
|
11
10
|
import { ensureAlbumPermission } from '../../utils/authorize/album';
|
|
12
|
-
import { CaptureResultToast } from '../captureResult/captureResult';
|
|
13
11
|
import './screenshot.less';
|
|
14
12
|
const CLOSE_TIME = 5000;
|
|
15
13
|
export function Screenshot(props) {
|
|
@@ -37,15 +35,8 @@ export function Screenshot(props) {
|
|
|
37
35
|
/** 记录截屏url */
|
|
38
36
|
const [state, setState] = useSetState({
|
|
39
37
|
showShot: false,
|
|
40
|
-
shotUrl: ''
|
|
41
|
-
shotCount: 0
|
|
38
|
+
shotUrl: ''
|
|
42
39
|
});
|
|
43
|
-
const snapshotRequestIdRef = useRef(0);
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
return () => {
|
|
46
|
-
snapshotRequestIdRef.current += 1;
|
|
47
|
-
};
|
|
48
|
-
}, []);
|
|
49
40
|
useUpdateEffect(() => {
|
|
50
41
|
if (state.showShot && screenType) {
|
|
51
42
|
showShotToast();
|
|
@@ -58,8 +49,7 @@ export function Screenshot(props) {
|
|
|
58
49
|
timer.current = setTimeout(() => {
|
|
59
50
|
setState({
|
|
60
51
|
showShot: false,
|
|
61
|
-
shotUrl: ''
|
|
62
|
-
shotCount: 0
|
|
52
|
+
shotUrl: ''
|
|
63
53
|
});
|
|
64
54
|
deleteContent('absolute', 'plugin-screenshot-toast');
|
|
65
55
|
}, CLOSE_TIME);
|
|
@@ -69,8 +59,7 @@ export function Screenshot(props) {
|
|
|
69
59
|
const handCheck = () => {
|
|
70
60
|
setState({
|
|
71
61
|
showShot: false,
|
|
72
|
-
shotUrl: ''
|
|
73
|
-
shotCount: 0
|
|
62
|
+
shotUrl: ''
|
|
74
63
|
});
|
|
75
64
|
deleteContent('absolute', 'plugin-screenshot-toast');
|
|
76
65
|
clearInterval(timer.current);
|
|
@@ -92,20 +81,31 @@ export function Screenshot(props) {
|
|
|
92
81
|
marginLeft: screenType === 'vertical' ? '0' : '-200px'
|
|
93
82
|
},
|
|
94
83
|
content: () => {
|
|
95
|
-
return /*#__PURE__*/React.createElement(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
84
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
85
|
+
className: "ipc-player-plugin-screenshot-toast"
|
|
86
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
87
|
+
className: "ipc-player-plugin-screenshot-toast-image-box"
|
|
88
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
89
|
+
className: "ipc-player-plugin-screenshot-toast-image",
|
|
90
|
+
src: state.shotUrl
|
|
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')));
|
|
102
101
|
}
|
|
103
102
|
});
|
|
104
103
|
timeToCloseToast();
|
|
105
104
|
};
|
|
106
105
|
const handClick = useMemoizedFn(async () => {
|
|
107
|
-
var _props$event;
|
|
108
|
-
(
|
|
106
|
+
var _props$event, _props$event2;
|
|
107
|
+
const ev = (_props$event = props.event) !== null && _props$event !== void 0 ? _props$event : event;
|
|
108
|
+
((_props$event2 = props.event) !== null && _props$event2 !== void 0 ? _props$event2 : event).emit(widgetClick, {
|
|
109
109
|
widgetId: widgetLabs.SCREENSHOT
|
|
110
110
|
});
|
|
111
111
|
console.log('截屏!!!');
|
|
@@ -119,49 +119,27 @@ 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
|
-
};
|
|
135
122
|
const granted = await ensureAlbumPermission();
|
|
136
|
-
|
|
123
|
+
ev.emit(changeIgnoreHideStopPreview, false);
|
|
137
124
|
if (!granted) return;
|
|
138
|
-
(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
setState({
|
|
157
|
-
showShot: true,
|
|
158
|
-
shotUrl: summary.thumbnailPath,
|
|
159
|
-
shotCount: summary.isMultiLens ? summary.count : 0
|
|
160
|
-
});
|
|
161
|
-
},
|
|
162
|
-
fail: handleSnapshotFail
|
|
163
|
-
});
|
|
164
|
-
})();
|
|
125
|
+
IPCPlayerContext.snapshot({
|
|
126
|
+
saveToAlbum,
|
|
127
|
+
success: res => {
|
|
128
|
+
ev.emit(changeIgnoreHideStopPreview, false);
|
|
129
|
+
setState({
|
|
130
|
+
showShot: true,
|
|
131
|
+
shotUrl: res.tempImagePath
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
fail: err => {
|
|
135
|
+
ev.emit(changeIgnoreHideStopPreview, false);
|
|
136
|
+
const errObj = err.innerError || err || {};
|
|
137
|
+
const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_screenshot_error_tip');
|
|
138
|
+
toast({
|
|
139
|
+
title: errMsg
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
});
|
|
165
143
|
});
|
|
166
144
|
if (hideScreenShotMenu) return null;
|
|
167
145
|
return /*#__PURE__*/React.createElement(View, {
|
|
@@ -2,7 +2,46 @@
|
|
|
2
2
|
color: var(--iconColor);
|
|
3
3
|
font-size: calc(var(--iconPlayerSize) * var(--ipc-player-size-scale, 1)) !important;
|
|
4
4
|
}
|
|
5
|
-
|
|
6
5
|
.ipc-player-plugin-screenshot-toast-wrap {
|
|
7
6
|
position: absolute;
|
|
8
7
|
}
|
|
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
|
+
}
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import './index.less';
|
|
3
3
|
type Props = {
|
|
4
4
|
className?: string;
|
|
5
|
-
onView?: () => void;
|
|
6
5
|
/** 主题色(用于「开通」按钮背景)。默认与 player brandColor 一致 */
|
|
7
6
|
brandColor?: string;
|
|
8
7
|
/** 试看倒计时初始秒数,来源于 smartImageQualityState.trialRemainingSec */
|
|
@@ -12,5 +11,5 @@ type Props = {
|
|
|
12
11
|
/** 倒计时归零时触发,本组件保证整个生命周期内只回调一次 */
|
|
13
12
|
onCountdownEnd?: () => void;
|
|
14
13
|
};
|
|
15
|
-
export declare const TrialBadge: ({ className,
|
|
14
|
+
export declare const TrialBadge: ({ className, brandColor, trialRemainingSec, onSubscribe, onCountdownEnd, }: Props) => React.JSX.Element;
|
|
16
15
|
export { useTrialBadge } from './useTrialBadge';
|
|
@@ -16,15 +16,11 @@ const formatCountdown = seconds => {
|
|
|
16
16
|
export const TrialBadge = _ref => {
|
|
17
17
|
let {
|
|
18
18
|
className,
|
|
19
|
-
onView,
|
|
20
19
|
brandColor = FALLBACK_BRAND_COLOR,
|
|
21
20
|
trialRemainingSec = 0,
|
|
22
21
|
onSubscribe,
|
|
23
22
|
onCountdownEnd
|
|
24
23
|
} = _ref;
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
onView === null || onView === void 0 || onView();
|
|
27
|
-
}, [onView]);
|
|
28
24
|
const [remainingSec, setRemainingSec] = useState(Math.max(0, Math.floor(trialRemainingSec)));
|
|
29
25
|
const endedRef = useRef(false);
|
|
30
26
|
const onCountdownEndRef = useRef(onCountdownEnd);
|
|
@@ -81,19 +77,15 @@ export const TrialBadge = _ref => {
|
|
|
81
77
|
backgroundColor: brandColor
|
|
82
78
|
},
|
|
83
79
|
onClick: () => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
94
|
-
} catch (error) {
|
|
95
|
-
console.warn('[IPC] trial subscription tracking failed:', error);
|
|
96
|
-
}
|
|
80
|
+
ty.event({
|
|
81
|
+
eventId: 'thing_qbwpX5zfbKOSjD4jz1tPv61rqrhGX7iV',
|
|
82
|
+
event: {
|
|
83
|
+
business_type: 'ipc',
|
|
84
|
+
scene_type: 'smart_image_quality',
|
|
85
|
+
feat_type: 'go_pay',
|
|
86
|
+
biz: 'preview_mini'
|
|
87
|
+
}
|
|
88
|
+
});
|
|
97
89
|
onSubscribe === null || onSubscribe === void 0 || onSubscribe();
|
|
98
90
|
}
|
|
99
91
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import type { EventInstance } from '../../interface';
|
|
3
|
-
export declare const useTrialBadge: (event: EventInstance, devId: string, trialRemainingSec: number
|
|
3
|
+
export declare const useTrialBadge: (event: EventInstance, devId: string, trialRemainingSec: number) => {
|
|
4
4
|
showTrialBadge: boolean;
|
|
5
5
|
setShowTrialBadge: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
6
|
-
handleTrialView: () => void;
|
|
7
6
|
handleTrialSubscribe: () => Promise<void>;
|
|
8
7
|
handleCountdownEnd: () => Promise<void>;
|
|
9
8
|
};
|
|
@@ -3,10 +3,7 @@ import { setTrailFinish } from '../../utils/ttt';
|
|
|
3
3
|
import { gotoSecurityCloudService2 } from '../../utils';
|
|
4
4
|
import { trialCountdownEnd } from '../../ui/constant';
|
|
5
5
|
import Strings from '../../i18n';
|
|
6
|
-
|
|
7
|
-
export const useTrialBadge = (event, devId, trialRemainingSec, viewedRef) => {
|
|
8
|
-
const localViewedRef = useRef(false);
|
|
9
|
-
const pageViewedRef = viewedRef || localViewedRef;
|
|
6
|
+
export const useTrialBadge = (event, devId, trialRemainingSec) => {
|
|
10
7
|
const [showTrialBadge, setShowTrialBadge] = useState(false);
|
|
11
8
|
const prevTrialSecRef = useRef(trialRemainingSec);
|
|
12
9
|
useEffect(() => {
|
|
@@ -17,16 +14,9 @@ export const useTrialBadge = (event, devId, trialRemainingSec, viewedRef) => {
|
|
|
17
14
|
}
|
|
18
15
|
prevTrialSecRef.current = trialRemainingSec;
|
|
19
16
|
}, [trialRemainingSec]);
|
|
20
|
-
const handleTrialView = useCallback(() => {
|
|
21
|
-
if (pageViewedRef.current) return;
|
|
22
|
-
pageViewedRef.current = true;
|
|
23
|
-
reportEntryView(devId, createEntryTracking());
|
|
24
|
-
}, [devId, pageViewedRef]);
|
|
25
17
|
const handleTrialSubscribe = useCallback(async () => {
|
|
26
18
|
try {
|
|
27
|
-
|
|
28
|
-
await reportEntryClick(devId, tracking);
|
|
29
|
-
await gotoSecurityCloudService2(devId, tracking);
|
|
19
|
+
await gotoSecurityCloudService2(devId);
|
|
30
20
|
} catch (error) {
|
|
31
21
|
ty.showToast({
|
|
32
22
|
title: Strings.getLang('ipc_player_fetch_error'),
|
|
@@ -61,7 +51,6 @@ export const useTrialBadge = (event, devId, trialRemainingSec, viewedRef) => {
|
|
|
61
51
|
return {
|
|
62
52
|
showTrialBadge,
|
|
63
53
|
setShowTrialBadge,
|
|
64
|
-
handleTrialView,
|
|
65
54
|
handleTrialSubscribe,
|
|
66
55
|
handleCountdownEnd
|
|
67
56
|
};
|
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.63",
|
|
4
4
|
"description": "IPC 融合播放器",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"files": [
|
|
@@ -37,8 +37,7 @@
|
|
|
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/ray-ipc-player": "2.1.7
|
|
41
|
-
"@ray-js/panel-sdk": "^1.13.1",
|
|
40
|
+
"@ray-js/ray-ipc-player": "^2.1.7",
|
|
42
41
|
"@ray-js/ray-ipc-utils": "^1.1.16",
|
|
43
42
|
"@ray-js/svg": "0.2.0",
|
|
44
43
|
"clsx": "^1.2.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import { act, renderHook } from '@testing-library/react-hooks/dom';
|
|
3
|
-
import { authorize, authorizeStatus, getSystemInfoSync, showModal } from '@ray-js/ray';
|
|
4
|
-
import { createUseCtx } from './ctx';
|
|
5
|
-
import { useStore } from './store';
|
|
6
|
-
jest.mock('@ray-js/ray', () => ({
|
|
7
|
-
authorize: jest.fn(),
|
|
8
|
-
authorizeStatus: jest.fn(),
|
|
9
|
-
getSystemInfoSync: jest.fn(),
|
|
10
|
-
openAppSystemSettingPage: jest.fn(),
|
|
11
|
-
showModal: jest.fn()
|
|
12
|
-
}));
|
|
13
|
-
jest.mock('@ray-js/ray-ipc-utils/lib/interface', () => ({
|
|
14
|
-
ClarityType: {
|
|
15
|
-
HD: 'HD',
|
|
16
|
-
SD: 'SD',
|
|
17
|
-
AUTO: 'AUTO'
|
|
18
|
-
},
|
|
19
|
-
IntercomMode: {
|
|
20
|
-
OneWay: 'OneWay',
|
|
21
|
-
TwoWay: 'TwoWay'
|
|
22
|
-
}
|
|
23
|
-
}));
|
|
24
|
-
jest.mock('../i18n', () => ({
|
|
25
|
-
__esModule: true,
|
|
26
|
-
default: {
|
|
27
|
-
getLang: key => key
|
|
28
|
-
}
|
|
29
|
-
}));
|
|
30
|
-
jest.mock('./multiCameraCtx', () => ({
|
|
31
|
-
isMultiCameraTileSupported: () => false,
|
|
32
|
-
useMultiCameraCtx: () => ({})
|
|
33
|
-
}));
|
|
34
|
-
jest.mock('../utils/ttt', () => ({
|
|
35
|
-
getCachedAutoClarity: jest.fn(),
|
|
36
|
-
isClarityChangedSupported: () => false,
|
|
37
|
-
setCachedAutoClarity: jest.fn(),
|
|
38
|
-
subscribeClarityChanged: () => () => undefined
|
|
39
|
-
}));
|
|
40
|
-
beforeEach(() => {
|
|
41
|
-
jest.clearAllMocks();
|
|
42
|
-
getSystemInfoSync.mockReturnValue({
|
|
43
|
-
platform: 'android',
|
|
44
|
-
system: 'android 12'
|
|
45
|
-
});
|
|
46
|
-
authorizeStatus.mockImplementation(_ref => {
|
|
47
|
-
let {
|
|
48
|
-
fail
|
|
49
|
-
} = _ref;
|
|
50
|
-
return fail({
|
|
51
|
-
errorCode: 9004
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
authorize.mockImplementation(_ref2 => {
|
|
55
|
-
let {
|
|
56
|
-
fail
|
|
57
|
-
} = _ref2;
|
|
58
|
-
return fail({
|
|
59
|
-
errorCode: 9004
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
const mountContext = function () {
|
|
64
|
-
let saveToAlbum = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
65
|
-
const capture = {
|
|
66
|
-
tempImagePath: 'thingfile://capture.jpg',
|
|
67
|
-
filePath: 'thingfile://record.mp4'
|
|
68
|
-
};
|
|
69
|
-
const startRecord = jest.fn(_ref3 => {
|
|
70
|
-
let {
|
|
71
|
-
success
|
|
72
|
-
} = _ref3;
|
|
73
|
-
return success();
|
|
74
|
-
});
|
|
75
|
-
const stopRecord = jest.fn(_ref4 => {
|
|
76
|
-
let {
|
|
77
|
-
success
|
|
78
|
-
} = _ref4;
|
|
79
|
-
return success(capture);
|
|
80
|
-
});
|
|
81
|
-
const useCtx = createUseCtx({
|
|
82
|
-
createPlayContext: () => ({
|
|
83
|
-
startRecord,
|
|
84
|
-
stopRecord
|
|
85
|
-
}),
|
|
86
|
-
getMemoryState: jest.fn().mockResolvedValue({
|
|
87
|
-
resolution: 'HD',
|
|
88
|
-
resolutionList: ['HD', 'SD'],
|
|
89
|
-
mute: true,
|
|
90
|
-
intercomMode: 'TwoWay',
|
|
91
|
-
isIntercomSupported: false
|
|
92
|
-
}),
|
|
93
|
-
setResolutionMemoryState: jest.fn(),
|
|
94
|
-
setMuteMemoryState: jest.fn(),
|
|
95
|
-
authorizeStatus: jest.fn(),
|
|
96
|
-
toast: jest.fn()
|
|
97
|
-
});
|
|
98
|
-
const hook = renderHook(() => {
|
|
99
|
-
const ctx = useCtx({
|
|
100
|
-
devId: 'camera-1',
|
|
101
|
-
multiLens: true,
|
|
102
|
-
saveToAlbum
|
|
103
|
-
});
|
|
104
|
-
const state = useStore({
|
|
105
|
-
recording: ctx.recording
|
|
106
|
-
});
|
|
107
|
-
return _objectSpread(_objectSpread({}, ctx), {}, {
|
|
108
|
-
state
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
return _objectSpread(_objectSpread({}, hook), {}, {
|
|
112
|
-
startRecord,
|
|
113
|
-
stopRecord,
|
|
114
|
-
capture
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
it('starts without legacy authorization and retains the native stop result', async () => {
|
|
118
|
-
const {
|
|
119
|
-
result,
|
|
120
|
-
startRecord,
|
|
121
|
-
stopRecord,
|
|
122
|
-
capture,
|
|
123
|
-
unmount
|
|
124
|
-
} = mountContext();
|
|
125
|
-
await act(async () => {
|
|
126
|
-
expect(await result.current.setRecording(true)).toBe(true);
|
|
127
|
-
});
|
|
128
|
-
expect(startRecord).toHaveBeenCalledWith(expect.objectContaining({
|
|
129
|
-
saveToAlbum: 1
|
|
130
|
-
}));
|
|
131
|
-
expect(result.current.state.recording).toBe(true);
|
|
132
|
-
expect(result.current.multiLens).toBe(true);
|
|
133
|
-
await act(async () => {
|
|
134
|
-
expect(await result.current.setRecording(false)).toEqual(capture);
|
|
135
|
-
});
|
|
136
|
-
expect(stopRecord).toHaveBeenCalledTimes(1);
|
|
137
|
-
expect(result.current.state.recording).toBe(false);
|
|
138
|
-
expect(authorizeStatus).not.toHaveBeenCalled();
|
|
139
|
-
expect(authorize).not.toHaveBeenCalled();
|
|
140
|
-
unmount();
|
|
141
|
-
});
|
|
142
|
-
it('settles a denied start without calling the native recorder', async () => {
|
|
143
|
-
getSystemInfoSync.mockReturnValue({
|
|
144
|
-
platform: 'ios',
|
|
145
|
-
system: 'iOS 18'
|
|
146
|
-
});
|
|
147
|
-
const {
|
|
148
|
-
result,
|
|
149
|
-
startRecord,
|
|
150
|
-
unmount
|
|
151
|
-
} = mountContext();
|
|
152
|
-
await act(async () => {
|
|
153
|
-
expect(await result.current.setRecording(true)).toBe(false);
|
|
154
|
-
});
|
|
155
|
-
expect(startRecord).not.toHaveBeenCalled();
|
|
156
|
-
expect(result.current.state.recording).toBe(false);
|
|
157
|
-
expect(showModal).toHaveBeenCalledTimes(1);
|
|
158
|
-
unmount();
|
|
159
|
-
});
|
|
160
|
-
it('propagates a native start failure without entering recording state', async () => {
|
|
161
|
-
const {
|
|
162
|
-
result,
|
|
163
|
-
startRecord,
|
|
164
|
-
unmount
|
|
165
|
-
} = mountContext();
|
|
166
|
-
const error = {
|
|
167
|
-
errorCode: 1001,
|
|
168
|
-
errorMsg: 'Start failed'
|
|
169
|
-
};
|
|
170
|
-
startRecord.mockImplementationOnce(_ref5 => {
|
|
171
|
-
let {
|
|
172
|
-
fail
|
|
173
|
-
} = _ref5;
|
|
174
|
-
return fail(error);
|
|
175
|
-
});
|
|
176
|
-
await act(async () => {
|
|
177
|
-
await expect(result.current.setRecording(true)).rejects.toEqual(error);
|
|
178
|
-
});
|
|
179
|
-
expect(result.current.state.recording).toBe(false);
|
|
180
|
-
unmount();
|
|
181
|
-
});
|
|
182
|
-
it('keeps the requested album when stopping on page unload', async () => {
|
|
183
|
-
const {
|
|
184
|
-
result,
|
|
185
|
-
stopRecord,
|
|
186
|
-
capture,
|
|
187
|
-
unmount
|
|
188
|
-
} = mountContext(0);
|
|
189
|
-
await act(async () => {
|
|
190
|
-
expect(await result.current.stopRecordingOnUnload()).toEqual(capture);
|
|
191
|
-
});
|
|
192
|
-
expect(stopRecord).toHaveBeenCalledWith(expect.objectContaining({
|
|
193
|
-
saveToAlbum: 0
|
|
194
|
-
}));
|
|
195
|
-
expect(authorizeStatus).not.toHaveBeenCalled();
|
|
196
|
-
unmount();
|
|
197
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { CaptureResult } from '../interface';
|
|
2
|
-
export type CaptureResultSummary = {
|
|
3
|
-
count: number;
|
|
4
|
-
isMultiLens: boolean;
|
|
5
|
-
thumbnailPath: string;
|
|
6
|
-
};
|
|
7
|
-
export type CaptureResultOptions = {
|
|
8
|
-
multiLens: boolean;
|
|
9
|
-
protocolCount?: number | string;
|
|
10
|
-
devId: string;
|
|
11
|
-
};
|
|
12
|
-
/** 从新多目高级能力配置获取当前设备的总镜头数 */
|
|
13
|
-
export declare function getMultiLensCountFromAbility(devId: string): Promise<number>;
|
|
14
|
-
export declare function getCaptureResultSummary(result: CaptureResult, { multiLens, protocolCount, devId }: CaptureResultOptions): Promise<CaptureResultSummary | null>;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/* eslint-disable camelcase */
|
|
2
|
-
|
|
3
|
-
import { getDeviceInfo } from './device';
|
|
4
|
-
const MULTI_LENS_ABILITY_CODE = 'tyabimr4v3';
|
|
5
|
-
const LENS_SUFFIX_PATTERN = /_lens\d+(?=\.[^./?#]+(?:[?#].*)?$)/;
|
|
6
|
-
const FILE_EXTENSION_PATTERN = /(\.[^./?#]+)([?#].*)?$/;
|
|
7
|
-
/** 从新多目高级能力配置获取当前设备的总镜头数 */
|
|
8
|
-
export async function getMultiLensCountFromAbility(devId) {
|
|
9
|
-
if (!devId) return 0;
|
|
10
|
-
try {
|
|
11
|
-
var _devInfo$configMetas;
|
|
12
|
-
const devInfo = await getDeviceInfo(devId);
|
|
13
|
-
const raw = devInfo === null || devInfo === void 0 || (_devInfo$configMetas = devInfo.configMetas) === null || _devInfo$configMetas === void 0 ? void 0 : _devInfo$configMetas[MULTI_LENS_ABILITY_CODE];
|
|
14
|
-
if (raw) {
|
|
15
|
-
const parsed = typeof raw === 'string' ? JSON.parse(raw) : raw;
|
|
16
|
-
const count = Number(parsed === null || parsed === void 0 ? void 0 : parsed.total_split_num) || (Array.isArray(parsed === null || parsed === void 0 ? void 0 : parsed.split_info) ? parsed.split_info.length : 0);
|
|
17
|
-
if (count > 1) {
|
|
18
|
-
return count;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
} catch (e) {
|
|
22
|
-
// ignore
|
|
23
|
-
}
|
|
24
|
-
return 0;
|
|
25
|
-
}
|
|
26
|
-
const normalizeMultiLensThumbnailPath = path => {
|
|
27
|
-
if (!path || LENS_SUFFIX_PATTERN.test(path)) return path;
|
|
28
|
-
return path.replace(FILE_EXTENSION_PATTERN, '_lens1$1$2');
|
|
29
|
-
};
|
|
30
|
-
const extractPath = item => {
|
|
31
|
-
if (!item) return '';
|
|
32
|
-
if (typeof item === 'string') return item;
|
|
33
|
-
if (typeof (item === null || item === void 0 ? void 0 : item.value) === 'string') return item.value;
|
|
34
|
-
return '';
|
|
35
|
-
};
|
|
36
|
-
export async function getCaptureResultSummary(result, _ref) {
|
|
37
|
-
let {
|
|
38
|
-
multiLens,
|
|
39
|
-
protocolCount,
|
|
40
|
-
devId
|
|
41
|
-
} = _ref;
|
|
42
|
-
if (!result || typeof result === 'boolean') return null;
|
|
43
|
-
const thumbnailPath = extractPath(result.tempImagePath) || extractPath(result.thumbPath) || extractPath(result.filePath) || '';
|
|
44
|
-
if (!multiLens) {
|
|
45
|
-
return {
|
|
46
|
-
count: 1,
|
|
47
|
-
isMultiLens: false,
|
|
48
|
-
thumbnailPath
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
const splitCount = Number(protocolCount) > 1 ? Number(protocolCount) : 0;
|
|
52
|
-
const multiLensAbilityCount = await getMultiLensCountFromAbility(devId);
|
|
53
|
-
|
|
54
|
-
// The native multi-lens snapshot can return one object while writing lens-specific
|
|
55
|
-
// files. Use the ability result to distinguish that file-name convention from the
|
|
56
|
-
// legacy split protocol.
|
|
57
|
-
const multiCount = splitCount || multiLensAbilityCount;
|
|
58
|
-
if (multiCount > 1) {
|
|
59
|
-
return {
|
|
60
|
-
count: multiCount,
|
|
61
|
-
isMultiLens: true,
|
|
62
|
-
thumbnailPath: multiLensAbilityCount > 1 ? normalizeMultiLensThumbnailPath(thumbnailPath) : thumbnailPath
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
count: 1,
|
|
67
|
-
isMultiLens: false,
|
|
68
|
-
thumbnailPath
|
|
69
|
-
};
|
|
70
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|