@ray-js/ipc-player-integration 0.0.65-beta.2 → 0.0.65-beta.4
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/ui/ui.js +2 -2
- package/lib/utils/captureResult.d.ts +2 -4
- package/lib/utils/captureResult.js +40 -40
- package/lib/utils/captureResult.test.js +205 -99
- package/lib/widgets/captureResult/captureResult.js +1 -1
- package/lib/widgets/captureResult/captureResult.test.js +4 -0
- package/lib/widgets/recordVideo/recordVideo.js +7 -3
- package/lib/widgets/screenshot/screenshot.js +7 -6
- package/lib/widgets/screenshot/screenshot.test.js +19 -4
- package/package.json +1 -1
package/lib/ui/ui.js
CHANGED
|
@@ -703,10 +703,10 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
703
703
|
var _instance$multiLens, _instance$multiCamera;
|
|
704
704
|
const summary = await getCaptureResultSummary(result, {
|
|
705
705
|
multiLens: (_instance$multiLens = instance === null || instance === void 0 ? void 0 : instance.multiLens) !== null && _instance$multiLens !== void 0 ? _instance$multiLens : false,
|
|
706
|
-
|
|
706
|
+
lensIndices: instance === null || instance === void 0 || (_instance$multiCamera = instance.multiCameraCtx) === null || _instance$multiCamera === void 0 || (_instance$multiCamera = _instance$multiCamera.protocol) === null || _instance$multiCamera === void 0 || (_instance$multiCamera = _instance$multiCamera.split_info) === null || _instance$multiCamera === void 0 ? void 0 : _instance$multiCamera.map(lens => lens.index),
|
|
707
707
|
devId
|
|
708
708
|
});
|
|
709
|
-
ipcTTTOperatorLog(summary !== null && summary !== void 0 && summary.isMultiLens ? `hide: stop recording succeeded with ${summary.count}
|
|
709
|
+
ipcTTTOperatorLog(summary !== null && summary !== void 0 && summary.isMultiLens ? `hide: stop recording succeeded with ${summary.count} thumbnails` : 'hide: 调用停止录制方法成功');
|
|
710
710
|
}).catch(() => {
|
|
711
711
|
ipcTTTOperatorLog('hide: 调用停止录制方法失败');
|
|
712
712
|
});
|
|
@@ -6,9 +6,7 @@ export type CaptureResultSummary = {
|
|
|
6
6
|
};
|
|
7
7
|
export type CaptureResultOptions = {
|
|
8
8
|
multiLens: boolean;
|
|
9
|
-
|
|
9
|
+
lensIndices?: number[];
|
|
10
10
|
devId: string;
|
|
11
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>;
|
|
12
|
+
export declare function getCaptureResultSummary(result: CaptureResult, { multiLens, lensIndices, devId }: CaptureResultOptions): Promise<CaptureResultSummary | null>;
|
|
@@ -1,70 +1,70 @@
|
|
|
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";
|
|
1
4
|
/* eslint-disable camelcase */
|
|
2
|
-
|
|
5
|
+
import { getFileSystemManager } from '@ray-js/ray';
|
|
3
6
|
import { getDeviceInfo } from './device';
|
|
4
7
|
const MULTI_LENS_ABILITY_CODE = 'tyabimr4v3';
|
|
5
8
|
const LENS_SUFFIX_PATTERN = /_lens\d+(?=\.[^./?#]+(?:[?#].*)?$)/;
|
|
6
9
|
const FILE_EXTENSION_PATTERN = /(\.[^./?#]+)([?#].*)?$/;
|
|
7
|
-
|
|
8
|
-
export async function getMultiLensCountFromAbility(devId) {
|
|
9
|
-
if (!devId) return 0;
|
|
10
|
+
const getMultiLensIndices = async devId => {
|
|
10
11
|
try {
|
|
11
|
-
var _devInfo$configMetas;
|
|
12
|
+
var _devInfo$configMetas, _config$split_info;
|
|
12
13
|
const devInfo = await getDeviceInfo(devId);
|
|
13
14
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return count;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
} catch (e) {
|
|
22
|
-
// ignore
|
|
15
|
+
const config = typeof raw === 'string' ? JSON.parse(raw) : raw;
|
|
16
|
+
return (config === null || config === void 0 || (_config$split_info = config.split_info) === null || _config$split_info === void 0 ? void 0 : _config$split_info.map(item => Number(item.index))) || [];
|
|
17
|
+
} catch {
|
|
18
|
+
return [];
|
|
23
19
|
}
|
|
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
20
|
};
|
|
21
|
+
const getLensPath = (path, index) => path.replace(LENS_SUFFIX_PATTERN, '').replace(FILE_EXTENSION_PATTERN, `_lens${index}$1$2`);
|
|
30
22
|
const extractPath = item => {
|
|
31
|
-
if (!item) return '';
|
|
32
23
|
if (typeof item === 'string') return item;
|
|
33
24
|
if (typeof (item === null || item === void 0 ? void 0 : item.value) === 'string') return item.value;
|
|
34
25
|
return '';
|
|
35
26
|
};
|
|
27
|
+
const imageExists = async path => {
|
|
28
|
+
if (!path) return false;
|
|
29
|
+
try {
|
|
30
|
+
const manager = await getFileSystemManager();
|
|
31
|
+
return await new Promise(resolve => {
|
|
32
|
+
manager.access({
|
|
33
|
+
path,
|
|
34
|
+
success: () => resolve(true),
|
|
35
|
+
fail: () => resolve(false)
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
} catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
36
42
|
export async function getCaptureResultSummary(result, _ref) {
|
|
37
43
|
let {
|
|
38
44
|
multiLens,
|
|
39
|
-
|
|
45
|
+
lensIndices,
|
|
40
46
|
devId
|
|
41
47
|
} = _ref;
|
|
42
48
|
if (!result || typeof result === 'boolean') return null;
|
|
43
|
-
const thumbnailPath = extractPath(result.tempImagePath) || extractPath(result.thumbPath) || extractPath(result.filePath) || '';
|
|
44
49
|
if (!multiLens) {
|
|
45
50
|
return {
|
|
46
51
|
count: 1,
|
|
47
52
|
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
|
|
53
|
+
thumbnailPath: extractPath(result.tempImagePath) || extractPath(result.thumbPath) || extractPath(result.filePath)
|
|
63
54
|
};
|
|
64
55
|
}
|
|
56
|
+
const thumbnailPath = extractPath(result.thumbPath) || extractPath(result.tempImagePath);
|
|
57
|
+
if (!thumbnailPath) return null;
|
|
58
|
+
const indices = [...new Set(lensIndices !== null && lensIndices !== void 0 && lensIndices.length ? lensIndices : await getMultiLensIndices(devId))];
|
|
59
|
+
const thumbnails = await Promise.all(indices.map(async index => {
|
|
60
|
+
const path = getLensPath(thumbnailPath, index);
|
|
61
|
+
return (await imageExists(path)) ? path : '';
|
|
62
|
+
}));
|
|
63
|
+
const existingThumbnails = thumbnails.filter(Boolean);
|
|
64
|
+
if (!existingThumbnails.length) return null;
|
|
65
65
|
return {
|
|
66
|
-
count:
|
|
67
|
-
isMultiLens:
|
|
68
|
-
thumbnailPath
|
|
66
|
+
count: existingThumbnails.length,
|
|
67
|
+
isMultiLens: true,
|
|
68
|
+
thumbnailPath: existingThumbnails[0]
|
|
69
69
|
};
|
|
70
70
|
}
|
|
@@ -1,117 +1,223 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import { getFileInfo, getFileSystemManager } from '@ray-js/ray';
|
|
1
3
|
import { getCaptureResultSummary } from './captureResult';
|
|
2
4
|
import { getDeviceInfo } from './device';
|
|
5
|
+
jest.mock('@ray-js/ray', () => ({
|
|
6
|
+
getFileInfo: jest.fn(),
|
|
7
|
+
getFileSystemManager: jest.fn()
|
|
8
|
+
}));
|
|
3
9
|
jest.mock('./device', () => ({
|
|
4
10
|
getDeviceInfo: jest.fn()
|
|
5
11
|
}));
|
|
6
12
|
const mockGetDeviceInfo = getDeviceInfo;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
const mockGetFileInfo = getFileInfo;
|
|
14
|
+
const mockGetFileSystemManager = getFileSystemManager;
|
|
15
|
+
const access = jest.fn();
|
|
16
|
+
const basePath = 'https://thing.miniapp.com/__tmp__/capture.png';
|
|
17
|
+
const result = {
|
|
18
|
+
tempImagePath: basePath,
|
|
19
|
+
filePath: basePath
|
|
20
|
+
};
|
|
21
|
+
const options = {
|
|
22
|
+
multiLens: true,
|
|
23
|
+
lensIndices: [1, 2, 3, 4],
|
|
24
|
+
devId: 'dev-1'
|
|
25
|
+
};
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
jest.resetAllMocks();
|
|
28
|
+
mockGetDeviceInfo.mockResolvedValue({
|
|
29
|
+
configMetas: {}
|
|
30
|
+
});
|
|
31
|
+
mockGetFileSystemManager.mockReturnValue({
|
|
32
|
+
access
|
|
33
|
+
});
|
|
34
|
+
access.mockImplementation(_ref => {
|
|
35
|
+
let {
|
|
36
|
+
success
|
|
37
|
+
} = _ref;
|
|
38
|
+
return success();
|
|
39
|
+
});
|
|
40
|
+
mockGetFileInfo.mockImplementation(() => {
|
|
41
|
+
throw new Error('Source file inspection is forbidden');
|
|
42
|
+
});
|
|
11
43
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
44
|
+
it('counts existing images instead of the configured lens total', async () => {
|
|
45
|
+
access.mockImplementation(_ref2 => {
|
|
46
|
+
let {
|
|
47
|
+
path,
|
|
48
|
+
success,
|
|
49
|
+
fail
|
|
50
|
+
} = _ref2;
|
|
51
|
+
if (path.endsWith('_lens2.png')) fail({
|
|
52
|
+
errorCode: 10011
|
|
53
|
+
});else success();
|
|
18
54
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
});
|
|
55
|
+
await expect(getCaptureResultSummary(result, options)).resolves.toEqual({
|
|
56
|
+
count: 3,
|
|
57
|
+
isMultiLens: true,
|
|
58
|
+
thumbnailPath: 'https://thing.miniapp.com/__tmp__/capture_lens1.png'
|
|
35
59
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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'
|
|
60
|
+
});
|
|
61
|
+
it('uses protocol indices unchanged and selects the first existing image', async () => {
|
|
62
|
+
access.mockImplementation(_ref3 => {
|
|
63
|
+
let {
|
|
64
|
+
path,
|
|
65
|
+
success,
|
|
66
|
+
fail
|
|
67
|
+
} = _ref3;
|
|
68
|
+
if (path === 'https://thing.miniapp.com/__tmp__/capture_lens7.png') success();else fail({
|
|
69
|
+
errorCode: 10011
|
|
76
70
|
});
|
|
77
71
|
});
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
72
|
+
await expect(getCaptureResultSummary(result, _objectSpread(_objectSpread({}, options), {}, {
|
|
73
|
+
lensIndices: [2, 7, 9]
|
|
74
|
+
}))).resolves.toEqual({
|
|
75
|
+
count: 1,
|
|
76
|
+
isMultiLens: true,
|
|
77
|
+
thumbnailPath: 'https://thing.miniapp.com/__tmp__/capture_lens7.png'
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
it('waits for access callbacks even when the method returns undefined', async () => {
|
|
81
|
+
const callbacks = [];
|
|
82
|
+
access.mockImplementation(_ref4 => {
|
|
83
|
+
let {
|
|
84
|
+
success
|
|
85
|
+
} = _ref4;
|
|
86
|
+
callbacks.push(success);
|
|
87
|
+
});
|
|
88
|
+
const summary = getCaptureResultSummary(result, options);
|
|
89
|
+
await Promise.resolve();
|
|
90
|
+
await Promise.resolve();
|
|
91
|
+
expect(callbacks).toHaveLength(4);
|
|
92
|
+
for (const success of callbacks) success();
|
|
93
|
+
await expect(summary).resolves.toMatchObject({
|
|
94
|
+
count: 4
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
it('returns no success summary when every image is missing', async () => {
|
|
98
|
+
access.mockImplementation(_ref5 => {
|
|
99
|
+
let {
|
|
100
|
+
fail
|
|
101
|
+
} = _ref5;
|
|
102
|
+
return fail({
|
|
103
|
+
errorCode: 10011
|
|
94
104
|
});
|
|
95
105
|
});
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
106
|
+
await expect(getCaptureResultSummary(result, options)).resolves.toBeNull();
|
|
107
|
+
});
|
|
108
|
+
it('does not duplicate a lens suffix or count duplicate indices', async () => {
|
|
109
|
+
await expect(getCaptureResultSummary({
|
|
110
|
+
tempImagePath: 'thingfile://tmp/capture_lens7.jpg?token=a',
|
|
111
|
+
filePath: ''
|
|
112
|
+
}, _objectSpread(_objectSpread({}, options), {}, {
|
|
113
|
+
lensIndices: [2, 7, 7]
|
|
114
|
+
}))).resolves.toEqual({
|
|
115
|
+
count: 2,
|
|
116
|
+
isMultiLens: true,
|
|
117
|
+
thumbnailPath: 'thingfile://tmp/capture_lens2.jpg?token=a'
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
it('reads the original lens indices from the ability when no protocol is supplied', async () => {
|
|
121
|
+
mockGetDeviceInfo.mockResolvedValue({
|
|
122
|
+
configMetas: {
|
|
123
|
+
tyabimr4v3: JSON.stringify({
|
|
124
|
+
split_info: [{
|
|
125
|
+
index: '2'
|
|
126
|
+
}, {
|
|
127
|
+
index: '7'
|
|
128
|
+
}]
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
await expect(getCaptureResultSummary(result, {
|
|
133
|
+
multiLens: true,
|
|
134
|
+
devId: 'dev-1'
|
|
135
|
+
})).resolves.toMatchObject({
|
|
136
|
+
count: 2,
|
|
137
|
+
thumbnailPath: basePath.replace('.png', '_lens2.png')
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
it('keeps legacy or mono capture unchanged', async () => {
|
|
141
|
+
await expect(getCaptureResultSummary(result, {
|
|
142
|
+
multiLens: false,
|
|
143
|
+
lensIndices: [1],
|
|
144
|
+
devId: 'dev-1'
|
|
145
|
+
})).resolves.toEqual({
|
|
146
|
+
count: 1,
|
|
147
|
+
isMultiLens: false,
|
|
148
|
+
thumbnailPath: basePath
|
|
149
|
+
});
|
|
150
|
+
expect(access).not.toHaveBeenCalled();
|
|
151
|
+
expect(mockGetFileInfo).not.toHaveBeenCalled();
|
|
152
|
+
});
|
|
153
|
+
it('counts recording thumbnails even when the source video path is missing', async () => {
|
|
154
|
+
const recording = {
|
|
155
|
+
tempImagePath: '',
|
|
156
|
+
thumbPath: basePath,
|
|
157
|
+
filePath: '/missing/record.mp4'
|
|
158
|
+
};
|
|
159
|
+
access.mockImplementation(_ref6 => {
|
|
160
|
+
let {
|
|
161
|
+
path,
|
|
162
|
+
success,
|
|
163
|
+
fail
|
|
164
|
+
} = _ref6;
|
|
165
|
+
if (path.endsWith('_lens2.png')) fail({
|
|
166
|
+
errorCode: 10011
|
|
167
|
+
});else success();
|
|
168
|
+
});
|
|
169
|
+
await expect(getCaptureResultSummary(recording, options)).resolves.toEqual({
|
|
170
|
+
count: 3,
|
|
171
|
+
isMultiLens: true,
|
|
172
|
+
thumbnailPath: basePath.replace('.png', '_lens1.png')
|
|
173
|
+
});
|
|
174
|
+
expect(mockGetFileInfo).not.toHaveBeenCalled();
|
|
175
|
+
expect(recording.filePath).toBe('/missing/record.mp4');
|
|
176
|
+
});
|
|
177
|
+
it('does not count source videos when every recording thumbnail is missing', async () => {
|
|
178
|
+
access.mockImplementation(_ref7 => {
|
|
179
|
+
let {
|
|
180
|
+
fail
|
|
181
|
+
} = _ref7;
|
|
182
|
+
return fail({
|
|
183
|
+
errorCode: 10011
|
|
104
184
|
});
|
|
105
185
|
});
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
186
|
+
await expect(getCaptureResultSummary(_objectSpread(_objectSpread({}, result), {}, {
|
|
187
|
+
filePath: '/album/record.mp4'
|
|
188
|
+
}), options)).resolves.toBeNull();
|
|
189
|
+
expect(mockGetFileInfo).not.toHaveBeenCalled();
|
|
190
|
+
});
|
|
191
|
+
it('never falls back to a source path when no thumbnail is returned', async () => {
|
|
192
|
+
await expect(getCaptureResultSummary({
|
|
193
|
+
tempImagePath: '',
|
|
194
|
+
filePath: '/album/record.mp4'
|
|
195
|
+
}, options)).resolves.toBeNull();
|
|
196
|
+
expect(access).not.toHaveBeenCalled();
|
|
197
|
+
expect(mockGetFileInfo).not.toHaveBeenCalled();
|
|
198
|
+
});
|
|
199
|
+
it('uses explicit thumbnails ahead of other image paths without renumbering lenses', async () => {
|
|
200
|
+
access.mockImplementation(_ref8 => {
|
|
201
|
+
let {
|
|
202
|
+
path,
|
|
203
|
+
success,
|
|
204
|
+
fail
|
|
205
|
+
} = _ref8;
|
|
206
|
+
if (path === 'thingfile://tmp/record_thumb_lens7.png') success();else fail({
|
|
207
|
+
errorCode: 10011
|
|
115
208
|
});
|
|
116
209
|
});
|
|
210
|
+
const recording = {
|
|
211
|
+
tempImagePath: 'thingfile://tmp/other.png',
|
|
212
|
+
thumbPath: 'thingfile://tmp/record_thumb.png',
|
|
213
|
+
filePath: '/album/record.mp4'
|
|
214
|
+
};
|
|
215
|
+
await expect(getCaptureResultSummary(recording, _objectSpread(_objectSpread({}, options), {}, {
|
|
216
|
+
lensIndices: [2, 7, 9]
|
|
217
|
+
}))).resolves.toEqual({
|
|
218
|
+
count: 1,
|
|
219
|
+
isMultiLens: true,
|
|
220
|
+
thumbnailPath: 'thingfile://tmp/record_thumb_lens7.png'
|
|
221
|
+
});
|
|
222
|
+
expect(recording.filePath).toBe('/album/record.mp4');
|
|
117
223
|
});
|
|
@@ -72,7 +72,7 @@ export function CaptureResultToast(_ref) {
|
|
|
72
72
|
className: clsx('icon-panel', 'icon-panel-record-play', 'ipc-player-plugin-capture-result-play-icon', legacyCls.playIcon)
|
|
73
73
|
}))), /*#__PURE__*/React.createElement(View, {
|
|
74
74
|
className: clsx('ipc-player-plugin-capture-result-title', legacyCls.title)
|
|
75
|
-
}, title ? typeof title === 'string' ? /*#__PURE__*/React.createElement(Text, null, title) : title :
|
|
75
|
+
}, title ? typeof title === 'string' ? /*#__PURE__*/React.createElement(Text, null, title) : title : count > 0 ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, null, Strings.getLang(textKeys.multi)), /*#__PURE__*/React.createElement(Text, {
|
|
76
76
|
className: "ipc-player-plugin-capture-result-count"
|
|
77
77
|
}, Strings.formatString(Strings.getLang('ipc_player_multi_capture_success_count'), count))) : Strings.getLang(textKeys.single)), /*#__PURE__*/React.createElement(View, {
|
|
78
78
|
onClick: onCheck,
|
|
@@ -57,6 +57,10 @@ const countClass = (markup, className) => [...markup.matchAll(/class="([^"]*)"/g
|
|
|
57
57
|
return names.split(/\s+/).includes(className);
|
|
58
58
|
}).length;
|
|
59
59
|
describe('CaptureResultToast', () => {
|
|
60
|
+
it('shows the actual count for one successful multi-lens item', () => {
|
|
61
|
+
expect(renderToast(1)).toContain('ipc_player_multi_capture_success_count:1');
|
|
62
|
+
expect(renderToast(0)).not.toContain('ipc_player_multi_capture_success_count');
|
|
63
|
+
});
|
|
60
64
|
it('keeps the single-item thumbnail unchanged', () => {
|
|
61
65
|
const markup = renderToast(1);
|
|
62
66
|
expect(countClass(markup, 'ipc-player-plugin-capture-result-backdrop')).toBe(0);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
|
+
import "core-js/modules/esnext.iterator.map.js";
|
|
1
3
|
import React, { useState, useEffect, useRef, useContext } from 'react';
|
|
2
4
|
import { View, Text, getSystemInfoSync } from '@ray-js/ray';
|
|
3
5
|
import { useSetState, useUpdateEffect } from 'ahooks';
|
|
@@ -115,10 +117,10 @@ export function RecordVideo(props) {
|
|
|
115
117
|
const showRecordResult = async recordInfo => {
|
|
116
118
|
var _props$multiCameraCtx;
|
|
117
119
|
const requestId = ++recordResultRequestIdRef.current;
|
|
118
|
-
const
|
|
120
|
+
const lensIndices = (_props$multiCameraCtx = props.multiCameraCtx) === null || _props$multiCameraCtx === void 0 || (_props$multiCameraCtx = _props$multiCameraCtx.protocol) === null || _props$multiCameraCtx === void 0 || (_props$multiCameraCtx = _props$multiCameraCtx.split_info) === null || _props$multiCameraCtx === void 0 ? void 0 : _props$multiCameraCtx.map(lens => lens.index);
|
|
119
121
|
const summary = await getCaptureResultSummary(recordInfo, {
|
|
120
122
|
multiLens: props.multiLens,
|
|
121
|
-
|
|
123
|
+
lensIndices,
|
|
122
124
|
devId
|
|
123
125
|
});
|
|
124
126
|
if (requestId !== recordResultRequestIdRef.current) return;
|
|
@@ -253,10 +255,12 @@ export function RecordVideo(props) {
|
|
|
253
255
|
return false;
|
|
254
256
|
}
|
|
255
257
|
recordResultRequestIdRef.current += 1;
|
|
256
|
-
if (state.showShot
|
|
258
|
+
if (state.showShot) {
|
|
257
259
|
setState({
|
|
258
260
|
showShot: false
|
|
259
261
|
});
|
|
262
|
+
deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
|
|
263
|
+
clearTimeout(timer.current);
|
|
260
264
|
}
|
|
261
265
|
// 发送忽略进入后台停止预览的标记
|
|
262
266
|
const {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
|
+
import "core-js/modules/esnext.iterator.map.js";
|
|
1
3
|
import React, { useContext, useEffect, useRef } from 'react';
|
|
2
4
|
import { View, Text, getSystemInfoSync } from '@ray-js/ray';
|
|
3
5
|
import { useSetState, useUpdateEffect, useMemoizedFn } from 'ahooks';
|
|
@@ -109,6 +111,8 @@ export function Screenshot(props) {
|
|
|
109
111
|
widgetId: widgetLabs.SCREENSHOT
|
|
110
112
|
});
|
|
111
113
|
console.log('截屏!!!');
|
|
114
|
+
deleteContent('absolute', 'plugin-screenshot-toast');
|
|
115
|
+
clearTimeout(timer.current);
|
|
112
116
|
setState({
|
|
113
117
|
showShot: false
|
|
114
118
|
});
|
|
@@ -142,17 +146,14 @@ export function Screenshot(props) {
|
|
|
142
146
|
success: async res => {
|
|
143
147
|
var _props$multiCameraCtx;
|
|
144
148
|
setIgnoreHideStopPreview(false);
|
|
145
|
-
const
|
|
149
|
+
const lensIndices = (_props$multiCameraCtx = props.multiCameraCtx) === null || _props$multiCameraCtx === void 0 || (_props$multiCameraCtx = _props$multiCameraCtx.protocol) === null || _props$multiCameraCtx === void 0 || (_props$multiCameraCtx = _props$multiCameraCtx.split_info) === null || _props$multiCameraCtx === void 0 ? void 0 : _props$multiCameraCtx.map(lens => lens.index);
|
|
146
150
|
const summary = await getCaptureResultSummary(res, {
|
|
147
151
|
multiLens: props.multiLens,
|
|
148
|
-
|
|
152
|
+
lensIndices,
|
|
149
153
|
devId
|
|
150
154
|
});
|
|
151
155
|
if (requestId !== snapshotRequestIdRef.current) return;
|
|
152
|
-
if (!summary)
|
|
153
|
-
handleSnapshotFail({});
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
+
if (!summary) return;
|
|
156
157
|
setState({
|
|
157
158
|
showShot: true,
|
|
158
159
|
shotUrl: summary.thumbnailPath,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { act, renderHook } from '@testing-library/react-hooks/dom';
|
|
2
2
|
import { atom } from 'jotai';
|
|
3
|
-
import { authorize, authorizeStatus, getSystemInfoSync, showModal } from '@ray-js/ray';
|
|
3
|
+
import { authorize, authorizeStatus, getFileSystemManager, getSystemInfoSync, showModal } from '@ray-js/ray';
|
|
4
4
|
import { getDeviceInfo } from '../../utils/device';
|
|
5
5
|
import { Screenshot } from './screenshot';
|
|
6
6
|
jest.mock('@ray-js/ray', () => ({
|
|
@@ -8,6 +8,7 @@ jest.mock('@ray-js/ray', () => ({
|
|
|
8
8
|
Text: 'span',
|
|
9
9
|
Image: 'img',
|
|
10
10
|
getSystemInfoSync: jest.fn(),
|
|
11
|
+
getFileSystemManager: jest.fn(),
|
|
11
12
|
authorize: jest.fn(),
|
|
12
13
|
authorizeStatus: jest.fn(),
|
|
13
14
|
showModal: jest.fn(),
|
|
@@ -49,20 +50,34 @@ beforeEach(() => {
|
|
|
49
50
|
errorCode: 9004
|
|
50
51
|
});
|
|
51
52
|
});
|
|
53
|
+
getFileSystemManager.mockReturnValue({
|
|
54
|
+
access: jest.fn(_ref3 => {
|
|
55
|
+
let {
|
|
56
|
+
success
|
|
57
|
+
} = _ref3;
|
|
58
|
+
return success();
|
|
59
|
+
})
|
|
60
|
+
});
|
|
52
61
|
getDeviceInfo.mockResolvedValue({
|
|
53
62
|
configMetas: {
|
|
54
63
|
tyabimr4v3: {
|
|
55
|
-
|
|
64
|
+
split_info: [{
|
|
65
|
+
index: 1
|
|
66
|
+
}, {
|
|
67
|
+
index: 2
|
|
68
|
+
}, {
|
|
69
|
+
index: 3
|
|
70
|
+
}]
|
|
56
71
|
}
|
|
57
72
|
}
|
|
58
73
|
});
|
|
59
74
|
});
|
|
60
75
|
const createProps = () => ({
|
|
61
76
|
IPCPlayerContext: {
|
|
62
|
-
snapshot: jest.fn(
|
|
77
|
+
snapshot: jest.fn(_ref4 => {
|
|
63
78
|
let {
|
|
64
79
|
success
|
|
65
|
-
} =
|
|
80
|
+
} = _ref4;
|
|
66
81
|
return success({
|
|
67
82
|
tempImagePath: 'thingfile://capture.jpg'
|
|
68
83
|
});
|