@ray-js/ipc-player-integration 0.0.60-beta.0 → 0.0.61-beta.1
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
package/lib/interface.d.ts
CHANGED
|
@@ -41,12 +41,15 @@ export type EventInstance = {
|
|
|
41
41
|
};
|
|
42
42
|
export type UseCtx = (options: {
|
|
43
43
|
devId: string;
|
|
44
|
+
/** 宿主决定是否禁用 Auto;null 表示本次配置查询尚未完成。 */
|
|
45
|
+
autoClarityDisabled?: boolean | null;
|
|
44
46
|
initTopLeftContent?: ComponentConfig[];
|
|
45
47
|
initTopRightContent?: ComponentConfig[];
|
|
46
48
|
initBottomLeftContent?: ComponentConfig[];
|
|
47
49
|
initBottomRightContent?: ComponentConfig[];
|
|
48
50
|
initAbsoluteContent?: ComponentConfig[];
|
|
49
51
|
saveToAlbum?: 0 | 1;
|
|
52
|
+
multiLens?: boolean;
|
|
50
53
|
showPtzControlTip?: boolean;
|
|
51
54
|
videoSplitProtocol?: VideoSplitProtocol;
|
|
52
55
|
}) => {
|
|
@@ -55,6 +58,7 @@ export type UseCtx = (options: {
|
|
|
55
58
|
brandColor: RetAtom<string>;
|
|
56
59
|
verticalMic: RetAtom<boolean>;
|
|
57
60
|
saveToAlbum: 0 | 1;
|
|
61
|
+
multiLens: boolean;
|
|
58
62
|
showPtzControlTip: boolean;
|
|
59
63
|
screenType: RetAtom<ScreenType>;
|
|
60
64
|
isVerticalFullLayout: RetAtom<boolean>;
|
|
@@ -90,7 +94,8 @@ export type UseCtx = (options: {
|
|
|
90
94
|
setRecordingDisabled: (type: boolean) => void;
|
|
91
95
|
setResolution: (type: string) => Promise<boolean>;
|
|
92
96
|
setResolutionList: (type: string[]) => void;
|
|
93
|
-
setRecording: (value: boolean, onlyUpdateAtom?: boolean) => Promise<
|
|
97
|
+
setRecording: (value: boolean, onlyUpdateAtom?: boolean) => Promise<CaptureResult>;
|
|
98
|
+
stopRecordingOnUnload: () => Promise<CaptureResult>;
|
|
94
99
|
setIntercom: (value: boolean, onlyUpdateAtom?: boolean) => Promise<boolean>;
|
|
95
100
|
setMute: (value: boolean) => Promise<boolean>;
|
|
96
101
|
changeStreamStatus: (value: PlayerStreamStatus) => void;
|
|
@@ -121,8 +126,12 @@ export type ComponentConfig<T = ReturnType<UseCtx> & Record<string, any>> = {
|
|
|
121
126
|
absoluteContentClassName?: string;
|
|
122
127
|
absoluteContentStyle?: React.CSSProperties;
|
|
123
128
|
absoluteNoCoverView?: boolean;
|
|
129
|
+
renderWhen?: (state: ComponentRenderState) => boolean;
|
|
124
130
|
hidden?: boolean;
|
|
125
131
|
};
|
|
132
|
+
export type ComponentRenderState = {
|
|
133
|
+
playState: PlayState;
|
|
134
|
+
};
|
|
126
135
|
export type ComponentConfigProps = {
|
|
127
136
|
IPCPlayerContext: IpcContext;
|
|
128
137
|
} & ReturnType<UseCtx>;
|
|
@@ -130,11 +139,17 @@ export type PlayStatusData = {
|
|
|
130
139
|
playState: PlayState;
|
|
131
140
|
playCode: number;
|
|
132
141
|
};
|
|
133
|
-
export type
|
|
142
|
+
export type CaptureFileInfo = {
|
|
143
|
+
index?: number;
|
|
134
144
|
tempImagePath: string;
|
|
135
145
|
filePath: string;
|
|
136
|
-
thumbPath
|
|
146
|
+
thumbPath?: string;
|
|
147
|
+
width?: number;
|
|
148
|
+
height?: number;
|
|
149
|
+
data?: string;
|
|
137
150
|
};
|
|
151
|
+
export type CaptureResult = boolean | CaptureFileInfo;
|
|
152
|
+
export type RecordInfoData = CaptureResult;
|
|
138
153
|
/**
|
|
139
154
|
* 多目屏幕模式
|
|
140
155
|
*/
|
package/lib/ui/ui.d.ts
CHANGED
package/lib/ui/ui.js
CHANGED
|
@@ -28,7 +28,9 @@ import { Storage } from '../utils/storage';
|
|
|
28
28
|
import './ui.less';
|
|
29
29
|
import { updatePlayerWidgetProps } from '../features';
|
|
30
30
|
import { getNgRawData, getSmartImageQualityState, isLowPhone } from '../utils/ttt';
|
|
31
|
+
import { getCaptureResultSummary } from '../utils/captureResult';
|
|
31
32
|
import { lensCount } from '../widgets/zoomTurntable/lensSkill';
|
|
33
|
+
import { shouldRenderContent } from './absoluteContent';
|
|
32
34
|
const AutoClarityOnly = _ref => {
|
|
33
35
|
let {
|
|
34
36
|
instance
|
|
@@ -59,11 +61,12 @@ const StandaloneAutoClarity = _ref2 => {
|
|
|
59
61
|
instance: instance
|
|
60
62
|
}));
|
|
61
63
|
};
|
|
62
|
-
function getCtxInstance(instance, devId) {
|
|
64
|
+
function getCtxInstance(instance, devId, autoClarityDisabled) {
|
|
63
65
|
if (instance) return instance;
|
|
64
66
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
65
67
|
return useCtx({
|
|
66
|
-
devId
|
|
68
|
+
devId,
|
|
69
|
+
autoClarityDisabled
|
|
67
70
|
});
|
|
68
71
|
}
|
|
69
72
|
|
|
@@ -126,7 +129,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
126
129
|
const {
|
|
127
130
|
event
|
|
128
131
|
} = useContext(UIEventContext);
|
|
129
|
-
const instance = getCtxInstance(props.instance, devId);
|
|
132
|
+
const instance = getCtxInstance(props.instance, devId, props.autoClarityDisabled);
|
|
130
133
|
const {
|
|
131
134
|
setPlayState,
|
|
132
135
|
setScreenType,
|
|
@@ -563,7 +566,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
563
566
|
// canOpenSettings: true,
|
|
564
567
|
// };
|
|
565
568
|
const getNgRes = await getNgRawData();
|
|
566
|
-
console.log('res===getSmartImageQualityState', res);
|
|
567
569
|
updatePlayerWidgetProps(instance, 'bottomLeft', 'TryExperience', {
|
|
568
570
|
isPurchase: res.isPurchase,
|
|
569
571
|
buttonState: res.buttonState,
|
|
@@ -686,14 +688,16 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
686
688
|
ipcTTTOperatorLog('hide: 调用停止录制方法');
|
|
687
689
|
setRecording(false, true);
|
|
688
690
|
setIntercom(false, true);
|
|
689
|
-
instance === null || instance === void 0 || instance.
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
}
|
|
691
|
+
instance === null || instance === void 0 || instance.stopRecordingOnUnload().then(async result => {
|
|
692
|
+
var _instance$multiLens, _instance$multiCamera;
|
|
693
|
+
const summary = await getCaptureResultSummary(result, {
|
|
694
|
+
multiLens: (_instance$multiLens = instance === null || instance === void 0 ? void 0 : instance.multiLens) !== null && _instance$multiLens !== void 0 ? _instance$multiLens : false,
|
|
695
|
+
protocolCount: instance === null || instance === void 0 || (_instance$multiCamera = instance.multiCameraCtx) === null || _instance$multiCamera === void 0 || (_instance$multiCamera = _instance$multiCamera.protocol) === null || _instance$multiCamera === void 0 ? void 0 : _instance$multiCamera.total_split_num,
|
|
696
|
+
devId
|
|
697
|
+
});
|
|
698
|
+
ipcTTTOperatorLog(summary !== null && summary !== void 0 && summary.isMultiLens ? `hide: stop recording succeeded with ${summary.count} files` : 'hide: 调用停止录制方法成功');
|
|
699
|
+
}).catch(() => {
|
|
700
|
+
ipcTTTOperatorLog('hide: 调用停止录制方法失败');
|
|
697
701
|
});
|
|
698
702
|
ipcTTTOperatorLog('hide: 调用停止对讲方法');
|
|
699
703
|
instance === null || instance === void 0 || instance.IPCPlayerInstance.stopTalk({
|
|
@@ -1155,17 +1159,17 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1155
1159
|
// 这一下起,自动隐藏倒计时才开始生效
|
|
1156
1160
|
hasUserTappedPlayerRef.current = true;
|
|
1157
1161
|
if (instance.multiCameraCtx.isSupport) {
|
|
1158
|
-
var _instance$
|
|
1159
|
-
const preTapIndex = (_instance$
|
|
1162
|
+
var _instance$multiCamera2, _instance$multiCamera3;
|
|
1163
|
+
const preTapIndex = (_instance$multiCamera2 = (_instance$multiCamera3 = instance.multiCameraCtx.selectedLenInfoRef.current) === null || _instance$multiCamera3 === void 0 ? void 0 : _instance$multiCamera3.index) !== null && _instance$multiCamera2 !== void 0 ? _instance$multiCamera2 : prevSelectedIndexRef.current;
|
|
1160
1164
|
const wasHidden = componentHideState;
|
|
1161
1165
|
instance.multiCameraCtx.selectVideoFiredRef.current = false;
|
|
1162
1166
|
if (multiTapTimerRef.current) {
|
|
1163
1167
|
clearTimeout(multiTapTimerRef.current);
|
|
1164
1168
|
}
|
|
1165
1169
|
multiTapTimerRef.current = setTimeout(() => {
|
|
1166
|
-
var _instance$
|
|
1170
|
+
var _instance$multiCamera4, _instance$multiCamera5;
|
|
1167
1171
|
const selectFired = !!instance.multiCameraCtx.selectVideoFiredRef.current;
|
|
1168
|
-
const currentIndex = (_instance$
|
|
1172
|
+
const currentIndex = (_instance$multiCamera4 = (_instance$multiCamera5 = instance.multiCameraCtx.selectedLenInfoRef.current) === null || _instance$multiCamera5 === void 0 ? void 0 : _instance$multiCamera5.index) !== null && _instance$multiCamera4 !== void 0 ? _instance$multiCamera4 : preTapIndex;
|
|
1169
1173
|
if (selectFired && currentIndex === preTapIndex) {
|
|
1170
1174
|
if (wasHidden) {
|
|
1171
1175
|
showComponents();
|
|
@@ -1255,13 +1259,16 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1255
1259
|
}, renderBottomRightContent))), (() => {
|
|
1256
1260
|
if (!absoluteContent || !(absoluteContent !== null && absoluteContent !== void 0 && absoluteContent.length)) return null;
|
|
1257
1261
|
return absoluteContent.map(item => {
|
|
1258
|
-
if (item
|
|
1262
|
+
if (!shouldRenderContent(item, {
|
|
1263
|
+
playState
|
|
1264
|
+
})) return null;
|
|
1265
|
+
const contentProps = _objectSpread(_objectSpread(_objectSpread({
|
|
1266
|
+
key: item.id
|
|
1267
|
+
}, item.initProps), instance), {}, {
|
|
1268
|
+
IPCPlayerContext: instance.IPCPlayerInstance
|
|
1269
|
+
});
|
|
1259
1270
|
if (item.absoluteNoCoverView) {
|
|
1260
|
-
return /*#__PURE__*/React.createElement(item.content,
|
|
1261
|
-
key: item.id
|
|
1262
|
-
}, item.initProps), instance), {}, {
|
|
1263
|
-
IPCPlayerContext: instance.IPCPlayerInstance
|
|
1264
|
-
}));
|
|
1271
|
+
return /*#__PURE__*/React.createElement(item.content, contentProps);
|
|
1265
1272
|
}
|
|
1266
1273
|
return /*#__PURE__*/React.createElement(CoverView, {
|
|
1267
1274
|
key: item.id,
|
|
@@ -1269,10 +1276,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1269
1276
|
position: 'absolute'
|
|
1270
1277
|
}, item.absolutePosition),
|
|
1271
1278
|
className: item.absoluteContentClassName
|
|
1272
|
-
}, /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread(
|
|
1273
|
-
key: item.id
|
|
1274
|
-
}, item.initProps), instance), {}, {
|
|
1275
|
-
IPCPlayerContext: instance.IPCPlayerInstance,
|
|
1279
|
+
}, /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread({}, contentProps), {}, {
|
|
1276
1280
|
// 添加通用变量单独组件类名
|
|
1277
1281
|
className: clsx('absolute-item-container')
|
|
1278
1282
|
})));
|
|
@@ -0,0 +1,14 @@
|
|
|
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>;
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { getCaptureResultSummary } from './captureResult';
|
|
2
|
+
import { getDeviceInfo } from './device';
|
|
3
|
+
jest.mock('./device', () => ({
|
|
4
|
+
getDeviceInfo: jest.fn()
|
|
5
|
+
}));
|
|
6
|
+
const mockGetDeviceInfo = getDeviceInfo;
|
|
7
|
+
const basePath = 'thingfile://tmp/capture_123.jpg';
|
|
8
|
+
const createCaptureResult = tempImagePath => ({
|
|
9
|
+
tempImagePath,
|
|
10
|
+
filePath: tempImagePath
|
|
11
|
+
});
|
|
12
|
+
describe('getCaptureResultSummary', () => {
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
mockGetDeviceInfo.mockReset();
|
|
15
|
+
mockGetDeviceInfo.mockResolvedValue({
|
|
16
|
+
configMetas: {}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
it('normalizes the thumbnail path for the new multi-lens ability', async () => {
|
|
20
|
+
mockGetDeviceInfo.mockResolvedValue({
|
|
21
|
+
configMetas: {
|
|
22
|
+
tyabimr4v3: {
|
|
23
|
+
total_split_num: 4
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
await expect(getCaptureResultSummary(createCaptureResult(basePath), {
|
|
28
|
+
multiLens: true,
|
|
29
|
+
devId: 'dev-1'
|
|
30
|
+
})).resolves.toEqual({
|
|
31
|
+
count: 4,
|
|
32
|
+
isMultiLens: true,
|
|
33
|
+
thumbnailPath: 'thingfile://tmp/capture_123_lens1.jpg'
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
it('keeps the single-lens result for a legacy multi-camera device', async () => {
|
|
37
|
+
await expect(getCaptureResultSummary(createCaptureResult(basePath), {
|
|
38
|
+
multiLens: false,
|
|
39
|
+
protocolCount: 4,
|
|
40
|
+
devId: 'dev-1'
|
|
41
|
+
})).resolves.toEqual({
|
|
42
|
+
count: 1,
|
|
43
|
+
isMultiLens: false,
|
|
44
|
+
thumbnailPath: basePath
|
|
45
|
+
});
|
|
46
|
+
expect(mockGetDeviceInfo).not.toHaveBeenCalled();
|
|
47
|
+
});
|
|
48
|
+
it('uses the protocol count when the multi-lens mode is enabled', async () => {
|
|
49
|
+
await expect(getCaptureResultSummary(createCaptureResult(basePath), {
|
|
50
|
+
multiLens: true,
|
|
51
|
+
protocolCount: 4,
|
|
52
|
+
devId: 'dev-1'
|
|
53
|
+
})).resolves.toEqual({
|
|
54
|
+
count: 4,
|
|
55
|
+
isMultiLens: true,
|
|
56
|
+
thumbnailPath: basePath
|
|
57
|
+
});
|
|
58
|
+
expect(mockGetDeviceInfo).toHaveBeenCalledWith('dev-1');
|
|
59
|
+
});
|
|
60
|
+
it('uses the lens path when both multi-lens sources are present', async () => {
|
|
61
|
+
mockGetDeviceInfo.mockResolvedValue({
|
|
62
|
+
configMetas: {
|
|
63
|
+
tyabimr4v3: {
|
|
64
|
+
total_split_num: 4
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
await expect(getCaptureResultSummary(createCaptureResult(basePath), {
|
|
69
|
+
multiLens: true,
|
|
70
|
+
protocolCount: 4,
|
|
71
|
+
devId: 'dev-1'
|
|
72
|
+
})).resolves.toEqual({
|
|
73
|
+
count: 4,
|
|
74
|
+
isMultiLens: true,
|
|
75
|
+
thumbnailPath: 'thingfile://tmp/capture_123_lens1.jpg'
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
it('does not add a duplicate lens suffix', async () => {
|
|
79
|
+
mockGetDeviceInfo.mockResolvedValue({
|
|
80
|
+
configMetas: {
|
|
81
|
+
tyabimr4v3: JSON.stringify({
|
|
82
|
+
total_split_num: 4
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const path = 'thingfile://tmp/capture_123_lens1.jpg';
|
|
87
|
+
await expect(getCaptureResultSummary(createCaptureResult(path), {
|
|
88
|
+
multiLens: true,
|
|
89
|
+
devId: 'dev-1'
|
|
90
|
+
})).resolves.toEqual({
|
|
91
|
+
count: 4,
|
|
92
|
+
isMultiLens: true,
|
|
93
|
+
thumbnailPath: path
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
it('keeps a mono result unchanged', async () => {
|
|
97
|
+
await expect(getCaptureResultSummary(createCaptureResult(basePath), {
|
|
98
|
+
multiLens: false,
|
|
99
|
+
devId: 'dev-1'
|
|
100
|
+
})).resolves.toEqual({
|
|
101
|
+
count: 1,
|
|
102
|
+
isMultiLens: false,
|
|
103
|
+
thumbnailPath: basePath
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
it('keeps a single-lens result when multi-lens mode has one lens', async () => {
|
|
107
|
+
await expect(getCaptureResultSummary(createCaptureResult(basePath), {
|
|
108
|
+
multiLens: true,
|
|
109
|
+
protocolCount: 1,
|
|
110
|
+
devId: 'dev-1'
|
|
111
|
+
})).resolves.toEqual({
|
|
112
|
+
count: 1,
|
|
113
|
+
isMultiLens: false,
|
|
114
|
+
thumbnailPath: basePath
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|
package/lib/utils/ttt.js
CHANGED
|
@@ -37,11 +37,9 @@ export function getAIFrameFeature(devId) {
|
|
|
37
37
|
ty.ipc.getAIFrameFeature({
|
|
38
38
|
devId,
|
|
39
39
|
success: data => {
|
|
40
|
-
console.log('res===getAIFrameFeature data', data);
|
|
41
40
|
resolve(data);
|
|
42
41
|
},
|
|
43
|
-
fail:
|
|
44
|
-
console.warn('res===getAIFrameFeature fail', e);
|
|
42
|
+
fail: () => {
|
|
45
43
|
resolve(null);
|
|
46
44
|
}
|
|
47
45
|
});
|
|
@@ -61,11 +59,9 @@ export function setAIFrameFeature(params) {
|
|
|
61
59
|
try {
|
|
62
60
|
ty.ipc.setAIFrameFeature(_objectSpread(_objectSpread({}, params), {}, {
|
|
63
61
|
success: data => {
|
|
64
|
-
console.log('res===setAIFrameFeature data', data);
|
|
65
62
|
resolve(data);
|
|
66
63
|
},
|
|
67
|
-
fail:
|
|
68
|
-
console.warn('res===setAIFrameFeature fail', e);
|
|
64
|
+
fail: () => {
|
|
69
65
|
resolve(null);
|
|
70
66
|
}
|
|
71
67
|
}));
|
|
@@ -135,7 +131,6 @@ export function notifyOfflineShown(deviceId) {
|
|
|
135
131
|
return false;
|
|
136
132
|
}
|
|
137
133
|
try {
|
|
138
|
-
console.warn('res===notifyOfflineShown', deviceId);
|
|
139
134
|
method({
|
|
140
135
|
deviceId,
|
|
141
136
|
scene: 'preview_mini'
|
|
@@ -246,7 +241,6 @@ export function subscribeClarityChanged(devId, handler) {
|
|
|
246
241
|
try {
|
|
247
242
|
ipc.onClarityChanged(listener);
|
|
248
243
|
} catch (error) {
|
|
249
|
-
console.warn('res===onClarityChanged fail', error);
|
|
250
244
|
return () => undefined;
|
|
251
245
|
}
|
|
252
246
|
return () => {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './captureResult.less';
|
|
3
|
+
export type CaptureKind = 'record' | 'screenshot';
|
|
4
|
+
export interface CaptureResultToastProps {
|
|
5
|
+
brandColor: string;
|
|
6
|
+
kind: CaptureKind;
|
|
7
|
+
thumbnailPath: string;
|
|
8
|
+
onCheck: () => void;
|
|
9
|
+
count?: number;
|
|
10
|
+
/** 自定义标题(可选),不传时使用默认文案 */
|
|
11
|
+
title?: React.ReactNode;
|
|
12
|
+
/** 自定义操作按钮文案(可选),不传时默认为“查看” */
|
|
13
|
+
checkText?: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function CaptureResultToast({ brandColor, count, kind, onCheck, thumbnailPath, title, checkText, className, }: CaptureResultToastProps): React.JSX.Element;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Image, Text, View } from '@ray-js/ray';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import Strings from '../../i18n';
|
|
5
|
+
import './captureResult.less';
|
|
6
|
+
const BACKDROP_LAYERS = ['back', 'middle'];
|
|
7
|
+
const TEXT_KEYS = {
|
|
8
|
+
record: {
|
|
9
|
+
check: 'ipc_player_record_success_check',
|
|
10
|
+
multi: 'ipc_player_record_multi_success_tip',
|
|
11
|
+
single: 'ipc_player_record_success_tip'
|
|
12
|
+
},
|
|
13
|
+
screenshot: {
|
|
14
|
+
check: 'ipc_player_shot_success_check',
|
|
15
|
+
multi: 'ipc_player_screenshot_multi_success_tip',
|
|
16
|
+
single: 'ipc_player_screenshot_success_tip'
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const LEGACY_CLASS_MAP = {
|
|
20
|
+
record: {
|
|
21
|
+
toast: 'ipc-player-plugin-record-success-toast',
|
|
22
|
+
imageBox: 'ipc-player-plugin-record-success-toast-image-box',
|
|
23
|
+
imageBoxMulti: 'ipc-player-plugin-record-success-toast-image-box-multi',
|
|
24
|
+
image: 'ipc-player-plugin-record-success-toast-image',
|
|
25
|
+
playIconBox: 'ipc-player-plugin-record-success-play-icon-box',
|
|
26
|
+
playIcon: 'ipc-player-plugin-record-success-play-icon',
|
|
27
|
+
title: 'ipc-player-plugin-record-success-toast-title',
|
|
28
|
+
check: 'ipc-player-plugin-record-success-toast-bottom'
|
|
29
|
+
},
|
|
30
|
+
screenshot: {
|
|
31
|
+
toast: 'ipc-player-plugin-screenshot-toast',
|
|
32
|
+
imageBox: 'ipc-player-plugin-screenshot-toast-image-box',
|
|
33
|
+
imageBoxMulti: 'ipc-player-plugin-screenshot-toast-image-box-multi',
|
|
34
|
+
image: 'ipc-player-plugin-screenshot-toast-image',
|
|
35
|
+
playIconBox: '',
|
|
36
|
+
playIcon: '',
|
|
37
|
+
title: 'ipc-player-plugin-screenshot-toast-title',
|
|
38
|
+
check: 'ipc-player-plugin-screenshot-toast-bottom'
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
export function CaptureResultToast(_ref) {
|
|
42
|
+
let {
|
|
43
|
+
brandColor,
|
|
44
|
+
count = 0,
|
|
45
|
+
kind,
|
|
46
|
+
onCheck,
|
|
47
|
+
thumbnailPath,
|
|
48
|
+
title,
|
|
49
|
+
checkText,
|
|
50
|
+
className
|
|
51
|
+
} = _ref;
|
|
52
|
+
const isMultiLens = count > 1;
|
|
53
|
+
const textKeys = TEXT_KEYS[kind];
|
|
54
|
+
const legacyCls = LEGACY_CLASS_MAP[kind];
|
|
55
|
+
const imageClassName = clsx('ipc-player-plugin-capture-result-image', legacyCls.image);
|
|
56
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
57
|
+
className: clsx('ipc-player-plugin-capture-result-toast', legacyCls.toast, className)
|
|
58
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
59
|
+
className: clsx('ipc-player-plugin-capture-result-image-box', legacyCls.imageBox, isMultiLens && ['ipc-player-plugin-capture-result-image-box-multi', legacyCls.imageBoxMulti])
|
|
60
|
+
}, isMultiLens ? /*#__PURE__*/React.createElement(React.Fragment, null, BACKDROP_LAYERS.map(layer => /*#__PURE__*/React.createElement(View, {
|
|
61
|
+
key: layer,
|
|
62
|
+
className: clsx('ipc-player-plugin-capture-result-backdrop', `ipc-player-plugin-capture-result-image-${layer}`)
|
|
63
|
+
})), /*#__PURE__*/React.createElement(Image, {
|
|
64
|
+
className: clsx(imageClassName, 'ipc-player-plugin-capture-result-image-front'),
|
|
65
|
+
src: thumbnailPath
|
|
66
|
+
})) : /*#__PURE__*/React.createElement(Image, {
|
|
67
|
+
className: imageClassName,
|
|
68
|
+
src: thumbnailPath
|
|
69
|
+
}), kind === 'record' && /*#__PURE__*/React.createElement(View, {
|
|
70
|
+
className: clsx('ipc-player-plugin-capture-result-play-icon-box', legacyCls.playIconBox)
|
|
71
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
72
|
+
className: clsx('icon-panel', 'icon-panel-record-play', 'ipc-player-plugin-capture-result-play-icon', legacyCls.playIcon)
|
|
73
|
+
}))), /*#__PURE__*/React.createElement(View, {
|
|
74
|
+
className: clsx('ipc-player-plugin-capture-result-title', legacyCls.title)
|
|
75
|
+
}, title ? typeof title === 'string' ? /*#__PURE__*/React.createElement(Text, null, title) : title : isMultiLens ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, null, Strings.getLang(textKeys.multi)), /*#__PURE__*/React.createElement(Text, {
|
|
76
|
+
className: "ipc-player-plugin-capture-result-count"
|
|
77
|
+
}, Strings.formatString(Strings.getLang('ipc_player_multi_capture_success_count'), count))) : Strings.getLang(textKeys.single)), /*#__PURE__*/React.createElement(View, {
|
|
78
|
+
onClick: onCheck,
|
|
79
|
+
className: clsx('ipc-player-plugin-capture-result-check', legacyCls.check),
|
|
80
|
+
style: {
|
|
81
|
+
color: brandColor,
|
|
82
|
+
borderColor: brandColor
|
|
83
|
+
}
|
|
84
|
+
}, checkText || Strings.getLang(textKeys.check)));
|
|
85
|
+
}
|