@ray-js/ipc-player-integration 0.0.68-beta.0 → 0.0.70-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/README.md +0 -6
- 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 +13 -3
- package/lib/ctx/ctx.js +48 -35
- package/lib/ctx/multiCameraCtx.d.ts +2 -0
- package/lib/ctx/multiCameraCtx.js +17 -1
- package/lib/ctx/multiCameraCtx.test.d.ts +1 -0
- package/lib/ctx/multiCameraCtx.test.js +65 -0
- 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/index.d.ts +0 -4
- package/lib/index.js +1 -3
- 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/bottomCoverHeight.d.ts +2 -0
- package/lib/ui/bottomCoverHeight.js +6 -0
- package/lib/ui/bottomCoverHeight.test.d.ts +1 -0
- package/lib/ui/bottomCoverHeight.test.js +15 -0
- package/lib/ui/bottomLeftContent.js +65 -123
- package/lib/ui/bottomRightContent.js +13 -11
- package/lib/ui/topLeftContent.js +2 -4
- package/lib/ui/topRightContent.js +2 -4
- package/lib/ui/ui.d.ts +0 -5
- package/lib/ui/ui.js +100 -93
- package/lib/utils/captureResult.d.ts +12 -0
- package/lib/utils/captureResult.js +70 -0
- package/lib/utils/captureResult.test.d.ts +1 -0
- package/lib/utils/captureResult.test.js +223 -0
- package/lib/utils/fullLinkTracking.d.ts +5 -0
- package/lib/utils/fullLinkTracking.js +71 -0
- package/lib/utils/navigation.d.ts +2 -1
- package/lib/utils/navigation.js +13 -3
- package/lib/widgets/battery/battery.js +5 -7
- package/lib/widgets/battery/batteryFull.js +5 -7
- 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 +84 -0
- package/lib/widgets/captureResult/index.d.ts +2 -0
- package/lib/widgets/captureResult/index.js +2 -0
- package/lib/widgets/floodlight/floodlight.js +1 -2
- package/lib/widgets/flowLowTip/flowLowTip.js +1 -2
- package/lib/widgets/fullScreen/fullScreen.js +31 -44
- package/lib/widgets/fullScreen/fullTravelRouteControl.d.ts +2 -2
- package/lib/widgets/fullScreen/fullTravelRouteControl.js +6 -3
- package/lib/widgets/fullScreen/verticalScreen.js +1 -2
- package/lib/widgets/index.d.ts +1 -0
- package/lib/widgets/index.js +2 -1
- package/lib/widgets/moveInteractiveControl/controlButton.js +1 -2
- package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.js +5 -16
- package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.less +4 -24
- package/lib/widgets/multiCamera/index.less +1 -0
- package/lib/widgets/multiCamera/landscapeTip.js +2 -5
- package/lib/widgets/multiCamera/moveablePtzControl.js +7 -9
- package/lib/widgets/multiCamera/multiPtz.js +2 -3
- package/lib/widgets/multiCamera/ptzMoveableTip.js +2 -5
- package/lib/widgets/multiCamera/switchLayout.js +1 -2
- package/lib/widgets/multiCamera/tileMultiPtz.js +2 -3
- package/lib/widgets/multiCamera/tileSwitchLayout.js +1 -2
- package/lib/widgets/multiCamera/tileTip.js +2 -5
- package/lib/widgets/muted/muted.js +1 -2
- package/lib/widgets/muted/muted.test.js +52 -66
- package/lib/widgets/ptz/ptz.js +1 -2
- package/lib/widgets/ptz/ptzControl.js +3 -4
- package/lib/widgets/ptzControlTip/ptzControlTip.js +4 -9
- package/lib/widgets/ptzControlTip/ptzControlTip.less +0 -6
- package/lib/widgets/realTimeMagnification/realTimeMagnification.js +1 -2
- package/lib/widgets/recordVideo/recordVideo.js +178 -32
- 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 +3 -169
- package/lib/widgets/resolution/fullResolutionControl.js +19 -29
- package/lib/widgets/resolution/resolution.js +2 -3
- package/lib/widgets/screenshot/screenshot.js +125 -35
- package/lib/widgets/screenshot/screenshot.less +1 -40
- package/lib/widgets/screenshot/screenshot.test.js +113 -108
- package/lib/widgets/signal4G/signal4G.js +1 -4
- package/lib/widgets/siren/siren.js +1 -2
- package/lib/widgets/tempHumidity/tempHumidity.js +1 -2
- package/lib/widgets/toggleVerticalFull/toggleVerticalFull.js +1 -2
- package/lib/widgets/trialBadge/index.d.ts +2 -1
- package/lib/widgets/trialBadge/index.js +20 -17
- package/lib/widgets/trialBadge/index.less +0 -24
- package/lib/widgets/trialBadge/useTrialBadge.d.ts +3 -2
- package/lib/widgets/trialBadge/useTrialBadge.js +21 -3
- package/lib/widgets/tryExperience/tryExperience.js +1 -2
- package/lib/widgets/videoBitKBP/videoBitKBP.js +1 -2
- package/lib/widgets/voiceIntercom/voiceIntercom.js +24 -50
- package/lib/widgets/voiceIntercom/voiceIntercom.less +0 -16
- package/lib/widgets/zoomTurntable/turntable/index.d.ts +7 -5
- package/lib/widgets/zoomTurntable/turntable/index.js +1 -3
- package/lib/widgets/zoomTurntable/zoomTurntableDock.d.ts +3 -5
- package/lib/widgets/zoomTurntable/zoomTurntableDock.js +4 -4
- package/lib/widgets/zoomTurntable/zoomTurntableEntry.js +19 -32
- package/lib/widgets/zoomTurntable/zoomTurntableTip.js +3 -24
- package/package.json +7 -15
- package/lib/renderer/capabilities.d.ts +0 -8
- package/lib/renderer/capabilities.js +0 -19
- package/lib/renderer/context.d.ts +0 -5
- package/lib/renderer/context.js +0 -6
- package/lib/renderer/directionControl.d.ts +0 -6
- package/lib/renderer/directionControl.js +0 -3
- package/lib/renderer/font-manifest.json +0 -9
- package/lib/renderer/font.less +0 -5
- package/lib/renderer/glyphs.d.ts +0 -1
- package/lib/renderer/glyphs.js +0 -256
- package/lib/renderer/index.module.less +0 -48
- package/lib/renderer/overlay.d.ts +0 -4
- package/lib/renderer/overlay.js +0 -6
- package/lib/renderer/ptzZoom.d.ts +0 -6
- package/lib/renderer/ptzZoom.js +0 -3
- package/lib/renderer/text.d.ts +0 -4
- package/lib/renderer/text.js +0 -32
- package/lib/renderer/text.module.less +0 -4
- package/lib/renderer/viewport.d.ts +0 -7
- package/lib/renderer/viewport.js +0 -24
- package/lib/res/lynx-signal/index.d.ts +0 -1
- package/lib/res/lynx-signal/index.js +0 -22
- package/lib/res/lynx-signal/signalFour0.png +0 -0
- package/lib/res/lynx-signal/signalFour1.png +0 -0
- package/lib/res/lynx-signal/signalFour2.png +0 -0
- package/lib/res/lynx-signal/signalFour3.png +0 -0
- package/lib/res/lynx-signal/signalFour4.png +0 -0
- package/lib/res/lynx-signal/signalThree0.png +0 -0
- package/lib/res/lynx-signal/signalThree1.png +0 -0
- package/lib/res/lynx-signal/signalThree2.png +0 -0
- package/lib/res/lynx-signal/signalThree3.png +0 -0
- package/lib/res/player-charging.png +0 -0
- package/lib/res/player-more-arrow.png +0 -0
- package/lib/res/player-solar.png +0 -0
- package/lib/ui/scrollHintArrow.d.ts +0 -23
- package/lib/ui/scrollHintArrow.js +0 -83
- package/lib/widgets/battery/statusIcon.d.ts +0 -6
- package/lib/widgets/battery/statusIcon.js +0 -36
- package/lib/widgets/battery/statusIcon.less +0 -24
- package/lib/widgets/captureToast/captureToast.d.ts +0 -9
- package/lib/widgets/captureToast/captureToast.js +0 -73
- package/lib/widgets/recordVideo/recordVideoTimer.d.ts +0 -3
- package/lib/widgets/recordVideo/recordVideoTimer.js +0 -26
- package/lib/widgets/zoomTurntable/lynxDockLayout.d.ts +0 -6
- package/lib/widgets/zoomTurntable/lynxDockLayout.js +0 -30
- package/lib/widgets/zoomTurntable/turntable/lynx.d.ts +0 -5
- package/lib/widgets/zoomTurntable/turntable/lynx.js +0 -273
- package/lib/widgets/zoomTurntable/turntable/lynx.less +0 -9
- package/lib/widgets/zoomTurntable/turntable/lynxModel.d.ts +0 -37
- package/lib/widgets/zoomTurntable/turntable/lynxModel.js +0 -122
- package/lib/widgets/zoomTurntable/turntable/lynxPaint.d.ts +0 -3
- package/lib/widgets/zoomTurntable/turntable/lynxPaint.js +0 -36
|
@@ -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
|
+
});
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import "core-js/modules/esnext.iterator.filter.js";
|
|
4
|
-
import "core-js/modules/esnext.iterator.map.js";
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import ReactDOM from 'react-dom';
|
|
7
|
-
import { act, Simulate } from 'react-dom/test-utils';
|
|
8
|
-
import { renderHook } from '@testing-library/react-hooks/dom';
|
|
9
|
-
import { atom, getDefaultStore } from 'jotai';
|
|
1
|
+
import { act, renderHook } from '@testing-library/react-hooks/dom';
|
|
2
|
+
import { atom } from 'jotai';
|
|
10
3
|
import { RecordVideo } from './recordVideo';
|
|
11
4
|
import { PlayState } from '../../interface';
|
|
12
|
-
import { PlayerRenderModeContext } from '../../renderer/context';
|
|
13
5
|
jest.mock('@ray-js/ray', () => ({
|
|
14
6
|
View: 'div',
|
|
15
|
-
CoverView: 'div',
|
|
16
7
|
Text: 'span',
|
|
17
8
|
Image: 'img',
|
|
18
9
|
getSystemInfoSync: () => ({
|
|
@@ -31,6 +22,7 @@ jest.mock('../../i18n', () => ({
|
|
|
31
22
|
}
|
|
32
23
|
}));
|
|
33
24
|
jest.mock('./recordVideo.less', () => ({}));
|
|
25
|
+
jest.mock('../captureResult/captureResult.less', () => ({}));
|
|
34
26
|
it('keeps the record control idle when starting is declined', async () => {
|
|
35
27
|
const addContent = jest.fn();
|
|
36
28
|
const setRecordingDisabled = jest.fn();
|
|
@@ -64,162 +56,4 @@ it('keeps the record control idle when starting is declined', async () => {
|
|
|
64
56
|
expect(setRecordingDisabled).not.toHaveBeenCalled();
|
|
65
57
|
expect(toast).not.toHaveBeenCalled();
|
|
66
58
|
unmount();
|
|
67
|
-
});
|
|
68
|
-
describe('successful recording timer', () => {
|
|
69
|
-
let container;
|
|
70
|
-
beforeEach(() => {
|
|
71
|
-
jest.useFakeTimers();
|
|
72
|
-
jest.setSystemTime(10000);
|
|
73
|
-
container = document.createElement('div');
|
|
74
|
-
document.body.appendChild(container);
|
|
75
|
-
});
|
|
76
|
-
afterEach(() => {
|
|
77
|
-
act(() => {
|
|
78
|
-
ReactDOM.unmountComponentAtNode(container);
|
|
79
|
-
});
|
|
80
|
-
container.remove();
|
|
81
|
-
jest.clearAllTimers();
|
|
82
|
-
jest.restoreAllMocks();
|
|
83
|
-
jest.useRealTimers();
|
|
84
|
-
});
|
|
85
|
-
function mountRecorder(mode) {
|
|
86
|
-
const store = getDefaultStore();
|
|
87
|
-
const recording = atom(false);
|
|
88
|
-
const recordingDisabled = atom(false);
|
|
89
|
-
const brandColor = atom('#000000');
|
|
90
|
-
let updateContents;
|
|
91
|
-
let recreateControl;
|
|
92
|
-
const props = {
|
|
93
|
-
recording,
|
|
94
|
-
recordingDisabled,
|
|
95
|
-
brandColor,
|
|
96
|
-
screenType: atom('vertical'),
|
|
97
|
-
playState: atom(PlayState.PLAYING),
|
|
98
|
-
setRecording: jest.fn(async value => {
|
|
99
|
-
store.set(recording, value);
|
|
100
|
-
return value ? true : {
|
|
101
|
-
tempImagePath: 'record.jpg'
|
|
102
|
-
};
|
|
103
|
-
}),
|
|
104
|
-
setRecordingDisabled: value => store.set(recordingDisabled, value),
|
|
105
|
-
addContent: (_area, item) => updateContents(items => [...items, item]),
|
|
106
|
-
deleteContent: (_area, id) => updateContents(items => items.filter(item => item.id !== id)),
|
|
107
|
-
toast: jest.fn(),
|
|
108
|
-
devId: 'test-device',
|
|
109
|
-
event: {
|
|
110
|
-
emit: jest.fn()
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
const Harness = () => {
|
|
114
|
-
const [contents, setContents] = React.useState([]);
|
|
115
|
-
const [generation, setGeneration] = React.useState(0);
|
|
116
|
-
recreateControl = () => setGeneration(value => value + 1);
|
|
117
|
-
updateContents = setContents;
|
|
118
|
-
return /*#__PURE__*/React.createElement(PlayerRenderModeContext.Provider, {
|
|
119
|
-
value: mode
|
|
120
|
-
}, /*#__PURE__*/React.createElement(RecordVideo, _extends({
|
|
121
|
-
key: generation
|
|
122
|
-
}, props)), contents.map(item => /*#__PURE__*/React.createElement(item.content, _extends({
|
|
123
|
-
key: item.id
|
|
124
|
-
}, item.initProps))));
|
|
125
|
-
};
|
|
126
|
-
act(() => {
|
|
127
|
-
ReactDOM.render(/*#__PURE__*/React.createElement(Harness, null), container);
|
|
128
|
-
});
|
|
129
|
-
return {
|
|
130
|
-
props,
|
|
131
|
-
store,
|
|
132
|
-
brandColor,
|
|
133
|
-
remountControl: () => {
|
|
134
|
-
act(() => {
|
|
135
|
-
recreateControl();
|
|
136
|
-
});
|
|
137
|
-
},
|
|
138
|
-
click: async () => {
|
|
139
|
-
await act(async () => {
|
|
140
|
-
Simulate.click(container.firstElementChild);
|
|
141
|
-
});
|
|
142
|
-
},
|
|
143
|
-
timer: () => container.querySelector('.ipc-player-plugin-record-video-toast-time')
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
it.each(['webview', 'lynx'])('ticks and cleans up in %s', async mode => {
|
|
147
|
-
const clear = jest.spyOn(global, 'clearInterval');
|
|
148
|
-
const start = jest.spyOn(global, 'setInterval');
|
|
149
|
-
const recorder = mountRecorder(mode);
|
|
150
|
-
await recorder.click();
|
|
151
|
-
expect(recorder.props.setRecording).toHaveBeenCalledWith(true);
|
|
152
|
-
expect(recorder.timer().textContent).toBe('00:00');
|
|
153
|
-
expect(start).toHaveBeenCalledTimes(1);
|
|
154
|
-
const interval = start.mock.results[0].value;
|
|
155
|
-
act(() => {
|
|
156
|
-
jest.advanceTimersByTime(1000);
|
|
157
|
-
});
|
|
158
|
-
expect(recorder.timer().textContent).toBe('00:01');
|
|
159
|
-
act(() => {
|
|
160
|
-
recorder.store.set(recorder.brandColor, '#ffffff');
|
|
161
|
-
});
|
|
162
|
-
expect(recorder.timer().textContent).toBe('00:01');
|
|
163
|
-
act(() => {
|
|
164
|
-
jest.advanceTimersByTime(59000);
|
|
165
|
-
});
|
|
166
|
-
expect(recorder.timer().textContent).toBe('01:00');
|
|
167
|
-
expect(start).toHaveBeenCalledTimes(1);
|
|
168
|
-
await recorder.click();
|
|
169
|
-
expect(recorder.props.setRecording).toHaveBeenLastCalledWith(false);
|
|
170
|
-
expect(recorder.timer()).toBeNull();
|
|
171
|
-
expect(clear).toHaveBeenCalledWith(interval);
|
|
172
|
-
await recorder.click();
|
|
173
|
-
expect(recorder.timer().textContent).toBe('00:00');
|
|
174
|
-
const nextInterval = start.mock.results[1].value;
|
|
175
|
-
act(() => {
|
|
176
|
-
ReactDOM.unmountComponentAtNode(container);
|
|
177
|
-
});
|
|
178
|
-
expect(clear).toHaveBeenCalledWith(nextInterval);
|
|
179
|
-
});
|
|
180
|
-
it('uses elapsed wall time after a delayed tick', async () => {
|
|
181
|
-
const recorder = mountRecorder('lynx');
|
|
182
|
-
await recorder.click();
|
|
183
|
-
act(() => {
|
|
184
|
-
jest.setSystemTime(74000);
|
|
185
|
-
jest.advanceTimersByTime(1000);
|
|
186
|
-
});
|
|
187
|
-
expect(recorder.timer().textContent).toBe('01:05');
|
|
188
|
-
});
|
|
189
|
-
it.each(['webview', 'lynx'])('stops the persistent timer after orientation remounts the %s toolbar', async mode => {
|
|
190
|
-
const clear = jest.spyOn(global, 'clearInterval');
|
|
191
|
-
const start = jest.spyOn(global, 'setInterval');
|
|
192
|
-
const recorder = mountRecorder(mode);
|
|
193
|
-
await recorder.click();
|
|
194
|
-
const interval = start.mock.results[0].value;
|
|
195
|
-
act(() => {
|
|
196
|
-
jest.advanceTimersByTime(4000);
|
|
197
|
-
});
|
|
198
|
-
act(() => {
|
|
199
|
-
recorder.store.set(recorder.props.screenType, 'full');
|
|
200
|
-
});
|
|
201
|
-
recorder.remountControl();
|
|
202
|
-
expect(recorder.timer().textContent).toBe('00:04');
|
|
203
|
-
act(() => {
|
|
204
|
-
jest.advanceTimersByTime(1000);
|
|
205
|
-
});
|
|
206
|
-
act(() => {
|
|
207
|
-
recorder.store.set(recorder.props.screenType, 'vertical');
|
|
208
|
-
});
|
|
209
|
-
recorder.remountControl();
|
|
210
|
-
expect(recorder.timer().textContent).toBe('00:05');
|
|
211
|
-
await recorder.click();
|
|
212
|
-
expect(recorder.props.setRecording).toHaveBeenLastCalledWith(false);
|
|
213
|
-
expect(recorder.timer()).toBeNull();
|
|
214
|
-
expect(clear).toHaveBeenCalledWith(interval);
|
|
215
|
-
});
|
|
216
|
-
it('removes the timer when recording stops outside the remounted control', async () => {
|
|
217
|
-
const recorder = mountRecorder('lynx');
|
|
218
|
-
await recorder.click();
|
|
219
|
-
recorder.remountControl();
|
|
220
|
-
act(() => {
|
|
221
|
-
recorder.store.set(recorder.props.recording, false);
|
|
222
|
-
});
|
|
223
|
-
expect(recorder.timer()).toBeNull();
|
|
224
|
-
});
|
|
225
59
|
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
2
|
import "core-js/modules/esnext.iterator.map.js";
|
|
3
3
|
import React, { useState, useContext, useEffect } from 'react';
|
|
4
|
-
import { View, showToast } from '@ray-js/ray';
|
|
4
|
+
import { Text, View, showToast } from '@ray-js/ray';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
import { PlayerText as Text } from '../../renderer/text';
|
|
7
6
|
import Strings from '../../i18n';
|
|
8
7
|
import { useMemoizedFn } from '../../hooks';
|
|
9
8
|
import { useStore } from '../../ctx/store';
|
|
@@ -34,10 +33,6 @@ export const FullResolutionControl = props => {
|
|
|
34
33
|
const onPlayerTap = useMemoizedFn(() => {
|
|
35
34
|
setHide(true);
|
|
36
35
|
});
|
|
37
|
-
const normalizeResolution = value => {
|
|
38
|
-
const normalized = String(value || '').toUpperCase();
|
|
39
|
-
return normalized === 'HD' ? 'HD' : 'SD';
|
|
40
|
-
};
|
|
41
36
|
useEffect(() => {
|
|
42
37
|
event.on('showFullResolutionControl', onShowFullResolutionControl);
|
|
43
38
|
event.on(playerTap, onPlayerTap);
|
|
@@ -47,14 +42,13 @@ export const FullResolutionControl = props => {
|
|
|
47
42
|
};
|
|
48
43
|
}, []);
|
|
49
44
|
const changeResolution = useMemoizedFn(value => {
|
|
50
|
-
|
|
51
|
-
if (targetResolution === normalizeResolution(resolution)) {
|
|
45
|
+
if (value === resolution) {
|
|
52
46
|
showToast({
|
|
53
47
|
icon: 'none',
|
|
54
48
|
title: Strings.getLang('ipc_player_current_resolution_is_equal')
|
|
55
49
|
});
|
|
56
50
|
} else {
|
|
57
|
-
setResolution(
|
|
51
|
+
setResolution(value).then(() => {
|
|
58
52
|
showToast({
|
|
59
53
|
icon: 'none',
|
|
60
54
|
title: Strings.getLang('ipc_player_change_resolution_success')
|
|
@@ -74,24 +68,20 @@ export const FullResolutionControl = props => {
|
|
|
74
68
|
className: clsx('ipc-player-plugin-full-resolution-control', 'ipc-plugin-absolute-move-in-right', {
|
|
75
69
|
'ipc-plugin-absolute-move-in-right-hide': hide
|
|
76
70
|
})
|
|
77
|
-
}, resolutionList.map(item => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
color: brandColor
|
|
94
|
-
} : undefined
|
|
95
|
-
}, Strings.getLang(`ipc_player_resolution_${normalizedItem}`));
|
|
96
|
-
}));
|
|
71
|
+
}, resolutionList.map(item => /*#__PURE__*/React.createElement(Text, {
|
|
72
|
+
onClick: () => {
|
|
73
|
+
event.emit(widgetClick, {
|
|
74
|
+
widgetId: widgetLabs.FULL_RESOLUTION_CONTROL,
|
|
75
|
+
extra: {
|
|
76
|
+
resolution: item
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
changeResolution(item);
|
|
80
|
+
},
|
|
81
|
+
key: item,
|
|
82
|
+
className: clsx('ipc-player-plugin-full-resolution-control-text'),
|
|
83
|
+
style: item === resolution && {
|
|
84
|
+
color: brandColor
|
|
85
|
+
}
|
|
86
|
+
}, Strings.getLang(`ipc_player_resolution_${item}`))));
|
|
97
87
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import { View } from '@ray-js/ray';
|
|
2
|
+
import { View, Text } from '@ray-js/ray';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import React, { useContext } from 'react';
|
|
5
5
|
import { useMemoizedFn } from 'ahooks';
|
|
6
|
-
import { PlayerText as Text } from '../../renderer/text';
|
|
7
6
|
import Strings from '../../i18n';
|
|
8
7
|
import { FullResolutionControl } from './fullResolutionControl';
|
|
9
8
|
import { fullResolutionId, pauseTimeToHideAllComponent, hideAllComponent, widgetLabs, widgetClick } from '../../ui/constant';
|
|
@@ -53,7 +52,7 @@ export const Resolution = props => {
|
|
|
53
52
|
}
|
|
54
53
|
if (verticalResolutionCustomClick) return false;
|
|
55
54
|
if (screenType === 'vertical') {
|
|
56
|
-
setResolution(
|
|
55
|
+
setResolution(resolution === 'HD' ? 'SD' : 'HD');
|
|
57
56
|
}
|
|
58
57
|
event.emit(pauseTimeToHideAllComponent);
|
|
59
58
|
return true;
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
|
+
import "core-js/modules/esnext.iterator.map.js";
|
|
3
|
+
import React, { useContext, useEffect, useRef } from 'react';
|
|
4
|
+
import { View, Text, getSystemInfoSync } from '@ray-js/ray';
|
|
5
|
+
import { useSetState, useUpdateEffect, useMemoizedFn } from 'ahooks';
|
|
4
6
|
import clsx from 'clsx';
|
|
5
|
-
import {
|
|
7
|
+
import { goToIpcPageNativeRoute } from '@ray-js/ray-ipc-utils';
|
|
6
8
|
import Strings from '../../i18n';
|
|
9
|
+
import { useStore } from '../../ctx/store';
|
|
7
10
|
import { UIEventContext } from '../../ui/context';
|
|
8
11
|
import { pauseTimeToHideAllComponent, changeIgnoreHideStopPreview, widgetLabs, widgetClick } from '../../ui/constant';
|
|
12
|
+
import { getCaptureResultSummary } from '../../utils/captureResult';
|
|
9
13
|
import { ensureAlbumPermission } from '../../utils/authorize/album';
|
|
10
|
-
import
|
|
14
|
+
import { CaptureResultToast } from '../captureResult/captureResult';
|
|
11
15
|
import './screenshot.less';
|
|
16
|
+
const CLOSE_TIME = 5000;
|
|
12
17
|
export function Screenshot(props) {
|
|
13
18
|
const {
|
|
14
19
|
IPCPlayerContext,
|
|
@@ -20,34 +25,97 @@ export function Screenshot(props) {
|
|
|
20
25
|
className,
|
|
21
26
|
hideScreenShotMenu
|
|
22
27
|
} = props;
|
|
28
|
+
const {
|
|
29
|
+
screenType,
|
|
30
|
+
brandColor
|
|
31
|
+
} = useStore({
|
|
32
|
+
screenType: props.screenType,
|
|
33
|
+
brandColor: props.brandColor
|
|
34
|
+
});
|
|
23
35
|
const {
|
|
24
36
|
event
|
|
25
37
|
} = useContext(UIEventContext);
|
|
26
|
-
|
|
38
|
+
|
|
39
|
+
/** 记录截屏url */
|
|
40
|
+
const [state, setState] = useSetState({
|
|
41
|
+
showShot: false,
|
|
42
|
+
shotUrl: '',
|
|
43
|
+
shotCount: 0
|
|
44
|
+
});
|
|
45
|
+
const snapshotRequestIdRef = useRef(0);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
return () => {
|
|
48
|
+
snapshotRequestIdRef.current += 1;
|
|
49
|
+
};
|
|
50
|
+
}, []);
|
|
51
|
+
useUpdateEffect(() => {
|
|
52
|
+
if (state.showShot && screenType) {
|
|
53
|
+
showShotToast();
|
|
54
|
+
}
|
|
55
|
+
}, [state.showShot, screenType]);
|
|
56
|
+
const timer = useRef();
|
|
57
|
+
const timeToCloseToast = () => {
|
|
58
|
+
clearInterval(timer.current);
|
|
59
|
+
// @ts-ignore
|
|
60
|
+
timer.current = setTimeout(() => {
|
|
61
|
+
setState({
|
|
62
|
+
showShot: false,
|
|
63
|
+
shotUrl: '',
|
|
64
|
+
shotCount: 0
|
|
65
|
+
});
|
|
66
|
+
deleteContent('absolute', 'plugin-screenshot-toast');
|
|
67
|
+
}, CLOSE_TIME);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/** 跳转相册 */
|
|
71
|
+
const handCheck = () => {
|
|
72
|
+
setState({
|
|
73
|
+
showShot: false,
|
|
74
|
+
shotUrl: '',
|
|
75
|
+
shotCount: 0
|
|
76
|
+
});
|
|
77
|
+
deleteContent('absolute', 'plugin-screenshot-toast');
|
|
78
|
+
clearInterval(timer.current);
|
|
79
|
+
goToIpcPageNativeRoute('ipc_album_panel', devId);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/** 添加截屏成功弹窗 */
|
|
83
|
+
const showShotToast = () => {
|
|
27
84
|
deleteContent('absolute', 'plugin-screenshot-toast');
|
|
28
85
|
addContent('absolute', {
|
|
29
86
|
id: 'plugin-screenshot-toast',
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
screenType:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
87
|
+
absoluteContentClassName: 'ipc-player-plugin-screenshot-toast-wrap',
|
|
88
|
+
absolutePosition: {
|
|
89
|
+
top: screenType === 'vertical' ? '12px' : '60px',
|
|
90
|
+
left: screenType === 'vertical' ? '16px' : '50%',
|
|
91
|
+
right: screenType === 'vertical' ? '16px' : 'unset',
|
|
92
|
+
display: 'flex',
|
|
93
|
+
width: screenType === 'vertical' ? 'auto' : '400px',
|
|
94
|
+
marginLeft: screenType === 'vertical' ? '0' : '-200px'
|
|
95
|
+
},
|
|
96
|
+
content: () => {
|
|
97
|
+
return /*#__PURE__*/React.createElement(CaptureResultToast, {
|
|
98
|
+
brandColor: brandColor,
|
|
99
|
+
count: state.shotCount,
|
|
100
|
+
kind: "screenshot",
|
|
101
|
+
onCheck: handCheck,
|
|
102
|
+
thumbnailPath: state.shotUrl
|
|
103
|
+
});
|
|
40
104
|
}
|
|
41
105
|
});
|
|
106
|
+
timeToCloseToast();
|
|
42
107
|
};
|
|
43
108
|
const handClick = useMemoizedFn(async () => {
|
|
44
|
-
var _props$event
|
|
45
|
-
|
|
46
|
-
((_props$event2 = props.event) !== null && _props$event2 !== void 0 ? _props$event2 : event).emit(widgetClick, {
|
|
109
|
+
var _props$event;
|
|
110
|
+
((_props$event = props.event) !== null && _props$event !== void 0 ? _props$event : event).emit(widgetClick, {
|
|
47
111
|
widgetId: widgetLabs.SCREENSHOT
|
|
48
112
|
});
|
|
49
113
|
console.log('截屏!!!');
|
|
50
114
|
deleteContent('absolute', 'plugin-screenshot-toast');
|
|
115
|
+
clearTimeout(timer.current);
|
|
116
|
+
setState({
|
|
117
|
+
showShot: false
|
|
118
|
+
});
|
|
51
119
|
const {
|
|
52
120
|
platform
|
|
53
121
|
} = getSystemInfoSync();
|
|
@@ -55,24 +123,46 @@ export function Screenshot(props) {
|
|
|
55
123
|
props.event ? props.event.emit(changeIgnoreHideStopPreview, true) : event.emit(changeIgnoreHideStopPreview, true);
|
|
56
124
|
}
|
|
57
125
|
event.emit(pauseTimeToHideAllComponent);
|
|
126
|
+
const setIgnoreHideStopPreview = value => {
|
|
127
|
+
var _props$event2;
|
|
128
|
+
((_props$event2 = props.event) !== null && _props$event2 !== void 0 ? _props$event2 : event).emit(changeIgnoreHideStopPreview, value);
|
|
129
|
+
};
|
|
130
|
+
const handleSnapshotFail = err => {
|
|
131
|
+
setIgnoreHideStopPreview(false);
|
|
132
|
+
console.log(err, 'err');
|
|
133
|
+
const errObj = err.innerError || err || {};
|
|
134
|
+
const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_screenshot_error_tip');
|
|
135
|
+
toast({
|
|
136
|
+
title: errMsg
|
|
137
|
+
});
|
|
138
|
+
};
|
|
58
139
|
const granted = await ensureAlbumPermission();
|
|
59
|
-
|
|
140
|
+
setIgnoreHideStopPreview(false);
|
|
60
141
|
if (!granted) return;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
142
|
+
(() => {
|
|
143
|
+
const requestId = ++snapshotRequestIdRef.current;
|
|
144
|
+
IPCPlayerContext.snapshot({
|
|
145
|
+
saveToAlbum,
|
|
146
|
+
success: async res => {
|
|
147
|
+
var _props$multiCameraCtx;
|
|
148
|
+
setIgnoreHideStopPreview(false);
|
|
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);
|
|
150
|
+
const summary = await getCaptureResultSummary(res, {
|
|
151
|
+
multiLens: props.multiLens,
|
|
152
|
+
lensIndices,
|
|
153
|
+
devId
|
|
154
|
+
});
|
|
155
|
+
if (requestId !== snapshotRequestIdRef.current) return;
|
|
156
|
+
if (!summary) return;
|
|
157
|
+
setState({
|
|
158
|
+
showShot: true,
|
|
159
|
+
shotUrl: summary.thumbnailPath,
|
|
160
|
+
shotCount: summary.isMultiLens ? summary.count : 0
|
|
161
|
+
});
|
|
162
|
+
},
|
|
163
|
+
fail: handleSnapshotFail
|
|
164
|
+
});
|
|
165
|
+
})();
|
|
76
166
|
});
|
|
77
167
|
if (hideScreenShotMenu) return null;
|
|
78
168
|
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
|
-
}
|