@ray-js/ipc-player-integration 0.0.71-beta.0 → 0.0.72-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.
Files changed (145) hide show
  1. package/README.md +0 -6
  2. package/lib/ctx/ctx.composition.d.ts +5 -1
  3. package/lib/ctx/ctx.composition.js +4 -1
  4. package/lib/ctx/ctx.js +17 -12
  5. package/lib/ctx/ctx.test.js +19 -54
  6. package/lib/features/initPlayerWidgets/index.d.ts +3 -0
  7. package/lib/features/initPlayerWidgets/index.js +4 -0
  8. package/lib/index.d.ts +0 -4
  9. package/lib/index.js +1 -3
  10. package/lib/interface.d.ts +1 -1
  11. package/lib/ui/bottomControlLayout.d.ts +11 -0
  12. package/lib/ui/bottomControlLayout.js +19 -0
  13. package/lib/ui/bottomControlLayout.test.js +64 -0
  14. package/lib/ui/bottomLeftContent.js +73 -180
  15. package/lib/ui/bottomLeftContent.test.js +138 -0
  16. package/lib/ui/bottomRightContent.d.ts +2 -2
  17. package/lib/ui/bottomRightContent.js +24 -16
  18. package/lib/ui/bottomRightContent.test.js +144 -0
  19. package/lib/ui/constant.d.ts +2 -0
  20. package/lib/ui/constant.js +4 -1
  21. package/lib/ui/topLeftContent.js +2 -4
  22. package/lib/ui/topRightContent.js +2 -4
  23. package/lib/ui/ui.d.ts +0 -5
  24. package/lib/ui/ui.js +33 -86
  25. package/lib/ui/ui.less +24 -59
  26. package/lib/widgets/battery/battery.js +5 -7
  27. package/lib/widgets/battery/batteryFull.js +5 -7
  28. package/lib/widgets/captureResult/captureResult.js +1 -2
  29. package/lib/widgets/floatWindow/floatWindow.d.ts +13 -0
  30. package/lib/widgets/floatWindow/floatWindow.js +93 -0
  31. package/lib/widgets/floatWindow/floatWindow.less +14 -0
  32. package/lib/widgets/floatWindow/floatWindow.test.d.ts +1 -0
  33. package/lib/widgets/floatWindow/floatWindow.test.js +164 -0
  34. package/lib/widgets/floatWindow/icon.d.ts +1 -0
  35. package/lib/widgets/floatWindow/icon.js +4 -0
  36. package/lib/widgets/floatWindow/index.d.ts +1 -0
  37. package/lib/widgets/floatWindow/index.js +1 -0
  38. package/lib/widgets/floodlight/floodlight.js +1 -2
  39. package/lib/widgets/flowLowTip/flowLowTip.js +1 -2
  40. package/lib/widgets/fullScreen/fullScreen.js +1 -2
  41. package/lib/widgets/fullScreen/fullTravelRouteControl.d.ts +1 -1
  42. package/lib/widgets/fullScreen/fullTravelRouteControl.js +1 -1
  43. package/lib/widgets/fullScreen/verticalScreen.js +1 -2
  44. package/lib/widgets/index.d.ts +1 -0
  45. package/lib/widgets/index.js +2 -1
  46. package/lib/widgets/moveInteractiveControl/controlButton.js +1 -2
  47. package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.js +5 -16
  48. package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.less +4 -24
  49. package/lib/widgets/multiCamera/landscapeTip.js +2 -8
  50. package/lib/widgets/multiCamera/moveablePtzControl.js +3 -5
  51. package/lib/widgets/multiCamera/multiPtz.js +1 -2
  52. package/lib/widgets/multiCamera/ptzMoveableTip.js +2 -8
  53. package/lib/widgets/multiCamera/switchLayout.js +1 -2
  54. package/lib/widgets/multiCamera/tileMultiPtz.js +1 -2
  55. package/lib/widgets/multiCamera/tileSwitchLayout.js +1 -2
  56. package/lib/widgets/multiCamera/tileTip.js +2 -8
  57. package/lib/widgets/muted/muted.js +1 -2
  58. package/lib/widgets/muted/muted.test.js +52 -66
  59. package/lib/widgets/ptz/ptz.js +1 -2
  60. package/lib/widgets/ptz/ptzControl.js +3 -4
  61. package/lib/widgets/ptzControlTip/ptzControlTip.js +4 -9
  62. package/lib/widgets/ptzControlTip/ptzControlTip.less +0 -6
  63. package/lib/widgets/realTimeMagnification/realTimeMagnification.js +1 -2
  64. package/lib/widgets/recordVideo/recordVideo.js +169 -47
  65. package/lib/widgets/recordVideo/recordVideo.lifecycle.test.js +2 -4
  66. package/lib/widgets/recordVideo/recordVideo.test.js +2 -169
  67. package/lib/widgets/resolution/fullResolutionControl.js +19 -29
  68. package/lib/widgets/resolution/resolution.js +2 -3
  69. package/lib/widgets/screenshot/screenshot.js +122 -48
  70. package/lib/widgets/screenshot/screenshot.test.js +113 -108
  71. package/lib/widgets/signal4G/signal4G.js +1 -4
  72. package/lib/widgets/siren/siren.js +1 -2
  73. package/lib/widgets/tempHumidity/tempHumidity.js +1 -2
  74. package/lib/widgets/toggleVerticalFull/toggleVerticalFull.js +1 -2
  75. package/lib/widgets/trialBadge/index.js +3 -8
  76. package/lib/widgets/trialBadge/index.less +0 -24
  77. package/lib/widgets/tryExperience/tryExperience.js +1 -2
  78. package/lib/widgets/videoBitKBP/videoBitKBP.js +1 -2
  79. package/lib/widgets/voiceIntercom/voiceIntercom.js +81 -57
  80. package/lib/widgets/voiceIntercom/voiceIntercom.less +0 -35
  81. package/lib/widgets/zoomTurntable/turntable/index.d.ts +7 -5
  82. package/lib/widgets/zoomTurntable/turntable/index.js +1 -3
  83. package/lib/widgets/zoomTurntable/zoomTurntableDock.d.ts +3 -5
  84. package/lib/widgets/zoomTurntable/zoomTurntableDock.js +4 -4
  85. package/lib/widgets/zoomTurntable/zoomTurntableEntry.js +19 -32
  86. package/lib/widgets/zoomTurntable/zoomTurntableTip.js +3 -17
  87. package/package.json +7 -15
  88. package/lib/ctx/intercom.test.js +0 -85
  89. package/lib/renderer/capabilities.d.ts +0 -8
  90. package/lib/renderer/capabilities.js +0 -19
  91. package/lib/renderer/context.d.ts +0 -5
  92. package/lib/renderer/context.js +0 -6
  93. package/lib/renderer/directionControl.d.ts +0 -6
  94. package/lib/renderer/directionControl.js +0 -3
  95. package/lib/renderer/font-manifest.json +0 -9
  96. package/lib/renderer/font.less +0 -5
  97. package/lib/renderer/glyphs.d.ts +0 -1
  98. package/lib/renderer/glyphs.js +0 -256
  99. package/lib/renderer/index.module.less +0 -48
  100. package/lib/renderer/overlay.d.ts +0 -6
  101. package/lib/renderer/overlay.js +0 -18
  102. package/lib/renderer/ptzZoom.d.ts +0 -6
  103. package/lib/renderer/ptzZoom.js +0 -3
  104. package/lib/renderer/text.d.ts +0 -4
  105. package/lib/renderer/text.js +0 -32
  106. package/lib/renderer/text.module.less +0 -4
  107. package/lib/renderer/viewport.d.ts +0 -7
  108. package/lib/renderer/viewport.js +0 -24
  109. package/lib/res/lynx-signal/index.d.ts +0 -1
  110. package/lib/res/lynx-signal/index.js +0 -22
  111. package/lib/res/lynx-signal/signalFour0.png +0 -0
  112. package/lib/res/lynx-signal/signalFour1.png +0 -0
  113. package/lib/res/lynx-signal/signalFour2.png +0 -0
  114. package/lib/res/lynx-signal/signalFour3.png +0 -0
  115. package/lib/res/lynx-signal/signalFour4.png +0 -0
  116. package/lib/res/lynx-signal/signalThree0.png +0 -0
  117. package/lib/res/lynx-signal/signalThree1.png +0 -0
  118. package/lib/res/lynx-signal/signalThree2.png +0 -0
  119. package/lib/res/lynx-signal/signalThree3.png +0 -0
  120. package/lib/res/player-charging.png +0 -0
  121. package/lib/res/player-more-arrow.png +0 -0
  122. package/lib/res/player-solar.png +0 -0
  123. package/lib/ui/scrollHintArrow.d.ts +0 -23
  124. package/lib/ui/scrollHintArrow.js +0 -83
  125. package/lib/widgets/battery/statusIcon.d.ts +0 -6
  126. package/lib/widgets/battery/statusIcon.js +0 -36
  127. package/lib/widgets/battery/statusIcon.less +0 -24
  128. package/lib/widgets/captureToast/captureToast.d.ts +0 -10
  129. package/lib/widgets/captureToast/captureToast.js +0 -58
  130. package/lib/widgets/recordVideo/recordVideoTimer.d.ts +0 -3
  131. package/lib/widgets/recordVideo/recordVideoTimer.js +0 -26
  132. package/lib/widgets/screenshot/screenshot.permissions.test.js +0 -137
  133. package/lib/widgets/voiceIntercom/voiceIntercom.test.js +0 -135
  134. package/lib/widgets/zoomTurntable/lynxDockLayout.d.ts +0 -6
  135. package/lib/widgets/zoomTurntable/lynxDockLayout.js +0 -30
  136. package/lib/widgets/zoomTurntable/turntable/lynx.d.ts +0 -5
  137. package/lib/widgets/zoomTurntable/turntable/lynx.js +0 -273
  138. package/lib/widgets/zoomTurntable/turntable/lynx.less +0 -9
  139. package/lib/widgets/zoomTurntable/turntable/lynxModel.d.ts +0 -37
  140. package/lib/widgets/zoomTurntable/turntable/lynxModel.js +0 -122
  141. package/lib/widgets/zoomTurntable/turntable/lynxPaint.d.ts +0 -3
  142. package/lib/widgets/zoomTurntable/turntable/lynxPaint.js +0 -36
  143. /package/lib/{ctx/intercom.test.d.ts → ui/bottomControlLayout.test.d.ts} +0 -0
  144. /package/lib/{widgets/screenshot/screenshot.permissions.test.d.ts → ui/bottomLeftContent.test.d.ts} +0 -0
  145. /package/lib/{widgets/voiceIntercom/voiceIntercom.test.d.ts → ui/bottomRightContent.test.d.ts} +0 -0
@@ -1,22 +1,80 @@
1
1
  import "core-js/modules/esnext.iterator.constructor.js";
2
2
  import "core-js/modules/esnext.iterator.map.js";
3
- import React, { useEffect, useRef, useContext } from 'react';
4
- import { View, getSystemInfoSync } from '@ray-js/ray';
5
- import { useMemoizedFn } from 'ahooks';
3
+ import React, { useState, useEffect, useRef, useContext } from 'react';
4
+ import { View, Text, getSystemInfoSync } from '@ray-js/ray';
5
+ import { useSetState, useUpdateEffect } from 'ahooks';
6
6
  import clsx from 'clsx';
7
- import { getCaptureResultSummary } from '../../utils/captureResult';
8
- import { PlayerText as Text } from '../../renderer/text';
7
+ import { goToIpcPageNativeRoute } from '@ray-js/ray-ipc-utils';
9
8
  import Strings from '../../i18n';
10
9
  import { PlayState } from '../../interface';
10
+ import { getCaptureResultSummary } from '../../utils/captureResult';
11
+ import { CaptureResultToast } from '../captureResult/captureResult';
11
12
  import { UIEventContext } from '../../ui/context';
12
13
  import { pauseTimeToHideAllComponent, changeIgnoreHideStopPreview, widgetLabs, widgetClick } from '../../ui/constant';
13
14
  import { useStore, getDefaultStore } from '../../ctx/store';
14
- import RecordVideoTimer from './recordVideoTimer';
15
- import CaptureToast from '../captureToast/captureToast';
16
15
  import './recordVideo.less';
16
+ const CLOSE_TIME = 5000;
17
17
  const RESET_TIMER = 3000;
18
18
  const RECORD_VIDEO_SUCCESS_TOAST_ID = 'record_video_SUCCESS_toast_id';
19
19
  const RECORD_VIDEO_TIMER_ID = 'record_video_timer_id';
20
+ function formatTimeDiff(diff) {
21
+ const padWithZero = true;
22
+ const diffMs = Math.abs(diff);
23
+ const minutes = Math.floor(diffMs / (1000 * 60));
24
+ const sec = Math.floor(diffMs % (1000 * 60) / 1000);
25
+ const formattedMinutes = String(minutes).padStart(2, '0');
26
+ const formattedSec = String(sec).padStart(2, '0');
27
+ return [formattedMinutes, formattedSec];
28
+ }
29
+ function useTime() {
30
+ const timer = useRef();
31
+ const startTime = useRef(0);
32
+ if (!startTime.current) {
33
+ startTime.current = new Date().getTime();
34
+ }
35
+ const [diffTime, setDiffTime] = useState(0);
36
+ useEffect(() => {
37
+ // @ts-ignore
38
+ timer.current = setInterval(() => {
39
+ const now = new Date().getTime();
40
+ setDiffTime(now - startTime.current);
41
+ }, 1000);
42
+ return () => {
43
+ clearInterval(timer.current);
44
+ };
45
+ }, []);
46
+ const cancel = () => {
47
+ clearInterval(timer.current);
48
+ };
49
+ if (!diffTime) {
50
+ return {
51
+ min: '00',
52
+ sec: '00',
53
+ cancel
54
+ };
55
+ }
56
+ const ret = formatTimeDiff(diffTime);
57
+ return {
58
+ min: ret[0],
59
+ sec: ret[1]
60
+ };
61
+ }
62
+ function TimeRecord() {
63
+ const {
64
+ min,
65
+ sec,
66
+ cancel
67
+ } = useTime();
68
+ return /*#__PURE__*/React.createElement(View, {
69
+ className: "ipc-player-plugin-record-video-toast-time"
70
+ }, /*#__PURE__*/React.createElement(View, {
71
+ className: "ipc-player-plugin-record-video-toast-time-warp"
72
+ }, min), /*#__PURE__*/React.createElement(View, {
73
+ className: "ipc-player-plugin-record-video-toast-time-delimiter"
74
+ }, ":"), /*#__PURE__*/React.createElement(View, {
75
+ className: "ipc-player-plugin-record-video-toast-time-warp"
76
+ }, sec));
77
+ }
20
78
  export function RecordVideo(props) {
21
79
  const {
22
80
  event
@@ -35,52 +93,76 @@ export function RecordVideo(props) {
35
93
  const {
36
94
  recording,
37
95
  brandColor,
96
+ screenType,
38
97
  recordingDisabled,
39
98
  playState
40
99
  } = useStore({
41
100
  recording: recordingAtom,
42
101
  brandColor: props.brandColor,
102
+ screenType: props.screenType,
43
103
  recordingDisabled: props.recordingDisabled,
44
104
  playState: props.playState
45
105
  });
46
- const requestIdRef = useRef(0);
47
- useEffect(() => () => {
48
- requestIdRef.current += 1;
106
+ const [state, setState] = useSetState({
107
+ showShot: false,
108
+ shotUrl: '',
109
+ shotCount: 0
110
+ });
111
+ const recordResultRequestIdRef = useRef(0);
112
+ useEffect(() => {
113
+ return () => {
114
+ recordResultRequestIdRef.current += 1;
115
+ };
49
116
  }, []);
50
117
  const showRecordResult = async recordInfo => {
51
118
  var _props$multiCameraCtx;
52
- const requestId = ++requestIdRef.current;
119
+ const requestId = ++recordResultRequestIdRef.current;
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);
53
121
  const summary = await getCaptureResultSummary(recordInfo, {
54
122
  multiLens: props.multiLens,
55
- 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),
123
+ lensIndices,
56
124
  devId
57
125
  });
58
- if (requestId !== requestIdRef.current || !summary) return;
59
- showRecordToast(summary.thumbnailPath, summary.isMultiLens ? summary.count : 0);
126
+ if (requestId !== recordResultRequestIdRef.current) return;
127
+ if (!summary) return;
128
+ setState({
129
+ showShot: true,
130
+ shotUrl: summary.thumbnailPath,
131
+ shotCount: summary.isMultiLens ? summary.count : 0
132
+ });
60
133
  };
61
- const removeRecordTimer = useMemoizedFn(() => deleteContent('absolute', RECORD_VIDEO_TIMER_ID));
62
- useEffect(() => {
63
- if (!recording) removeRecordTimer();
64
- }, [recording, removeRecordTimer]);
65
134
 
66
135
  /**
67
136
  * 针对 playState为非连接中状态时,如果处于录制中, 结束录制
68
137
  */
69
138
  useEffect(() => {
70
139
  (async () => {
71
- if (playState !== PlayState.PLAYING) {
72
- if (recording) {
73
- try {
74
- const recordInfo = await setRecording(false);
75
- await showRecordResult(recordInfo);
76
- } catch {
77
- // setRecording reports native failures through its toast.
78
- }
140
+ if (playState !== PlayState.PLAYING && recording) {
141
+ try {
142
+ const recordInfo = await setRecording(false);
143
+ await showRecordResult(recordInfo);
144
+ } catch {
145
+ // setRecording reports the native failure through the configured toast.
79
146
  }
80
147
  }
81
148
  })();
82
149
  }, [playState, recording]);
83
150
 
151
+ /** 设置5秒后关闭录制成功弹窗 */
152
+ const timer = useRef();
153
+ const timeToCloseRecordToast = () => {
154
+ clearTimeout(timer.current);
155
+ // @ts-ignore
156
+ timer.current = setTimeout(() => {
157
+ setState({
158
+ showShot: false,
159
+ shotUrl: '',
160
+ shotCount: 0
161
+ });
162
+ deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
163
+ }, CLOSE_TIME);
164
+ };
165
+
84
166
  /** 设置3秒后还原禁止结束录像状态 */
85
167
  const recordDisabledTimer = useRef();
86
168
  const timeToResetRecordDisabled = () => {
@@ -90,23 +172,56 @@ export function RecordVideo(props) {
90
172
  setRecordingDisabled(false);
91
173
  }, RESET_TIMER);
92
174
  };
93
- const showRecordToast = (imageUrl, count) => {
175
+ useUpdateEffect(() => {
176
+ if (state.showShot && screenType) {
177
+ showRecordToast();
178
+ }
179
+ }, [state.showShot, screenType]);
180
+ useUpdateEffect(() => {
181
+ if (recording) {
182
+ showRecordTimer();
183
+ } else {
184
+ deleteContent('absolute', RECORD_VIDEO_TIMER_ID);
185
+ }
186
+ }, [recording]);
187
+
188
+ /** 跳转相册 */
189
+ const handCheck = () => {
190
+ setState({
191
+ showShot: false,
192
+ shotUrl: '',
193
+ shotCount: 0
194
+ });
195
+ deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
196
+ clearInterval(timer.current);
197
+ goToIpcPageNativeRoute('ipc_album_panel', devId);
198
+ };
199
+
200
+ /** 添加录制成功弹窗 */
201
+ const showRecordToast = () => {
94
202
  deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
95
203
  addContent('absolute', {
96
204
  id: RECORD_VIDEO_SUCCESS_TOAST_ID,
97
- absoluteNoCoverView: true,
98
- content: CaptureToast,
99
- initProps: {
100
- kind: 'record',
101
- count,
102
- imageUrl,
103
- captureId: Date.now(),
104
- screenType: props.screenType,
105
- brandColor: props.brandColor,
106
- devId,
107
- deleteContent
205
+ absoluteContentClassName: 'ipc-player-plugin-record-success-toast-wrap',
206
+ absolutePosition: {
207
+ top: screenType === 'vertical' ? '12px' : '60px',
208
+ left: screenType === 'vertical' ? '16px' : '50%',
209
+ right: screenType === 'vertical' ? '16px' : 'unset',
210
+ display: 'flex',
211
+ width: screenType === 'vertical' ? 'auto' : '400px',
212
+ marginLeft: screenType === 'vertical' ? '0' : '-200px'
213
+ },
214
+ content: () => {
215
+ return /*#__PURE__*/React.createElement(CaptureResultToast, {
216
+ brandColor: brandColor,
217
+ count: state.shotCount,
218
+ kind: "record",
219
+ onCheck: handCheck,
220
+ thumbnailPath: state.shotUrl
221
+ });
108
222
  }
109
223
  });
224
+ timeToCloseRecordToast();
110
225
  };
111
226
  const showRecordTimer = () => {
112
227
  deleteContent('absolute', RECORD_VIDEO_TIMER_ID);
@@ -114,19 +229,22 @@ export function RecordVideo(props) {
114
229
  id: RECORD_VIDEO_TIMER_ID,
115
230
  absoluteContentClassName: 'ipc-player-plugin-record-video-toast-wrap',
116
231
  content: () => /*#__PURE__*/React.createElement(View, {
117
- className: "ipc-player-plugin-record-video-toast ipc-player-plugin-record-video-toast-show"
232
+ className: clsx('ipc-player-plugin-record-video-toast', {
233
+ 'ipc-player-plugin-record-video-toast-show': recording,
234
+ 'ipc-player-plugin-record-video-toast-hide': !recording
235
+ })
118
236
  }, /*#__PURE__*/React.createElement(View, {
119
237
  className: "ipc-player-plugin-record-video-toast-point",
120
238
  style: {
121
239
  backgroundColor: brandColor
122
240
  }
123
- }), /*#__PURE__*/React.createElement(RecordVideoTimer, null))
241
+ }), /*#__PURE__*/React.createElement(TimeRecord, null))
124
242
  });
125
243
  };
126
244
  const handRecordVideo = async () => {
127
- var _props$event, _props$event2;
245
+ var _props$event;
128
246
  const ev = (_props$event = props.event) !== null && _props$event !== void 0 ? _props$event : event;
129
- ((_props$event2 = props.event) !== null && _props$event2 !== void 0 ? _props$event2 : event).emit(widgetClick, {
247
+ ev.emit(widgetClick, {
130
248
  widgetId: widgetLabs.RECORD_VIDEO
131
249
  });
132
250
  event.emit(pauseTimeToHideAllComponent);
@@ -136,7 +254,14 @@ export function RecordVideo(props) {
136
254
  if (recordingDisabled) {
137
255
  return false;
138
256
  }
139
- deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
257
+ recordResultRequestIdRef.current += 1;
258
+ if (state.showShot) {
259
+ setState({
260
+ showShot: false
261
+ });
262
+ deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
263
+ clearTimeout(timer.current);
264
+ }
140
265
  // 发送忽略进入后台停止预览的标记
141
266
  const {
142
267
  platform
@@ -152,23 +277,20 @@ export function RecordVideo(props) {
152
277
  }
153
278
  if (target) {
154
279
  setRecordingDisabled(true);
155
- showRecordTimer();
156
280
  /** 录制开始后3秒后才可结束 */
157
281
  timeToResetRecordDisabled();
158
282
  } else {
159
283
  props.event ? props.event.emit(changeIgnoreHideStopPreview, false) : event.emit(changeIgnoreHideStopPreview, false);
160
- removeRecordTimer();
161
284
  await showRecordResult(recordInfo);
162
285
  }
163
286
  } catch (err) {
164
287
  props.event ? props.event.emit(changeIgnoreHideStopPreview, false) : event.emit(changeIgnoreHideStopPreview, false);
165
288
  console.log('录制失败', err);
166
- const errObj = (err === null || err === void 0 ? void 0 : err.innerError) || err || {};
289
+ const errObj = err.innerError || err || {};
167
290
  const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_record_tip');
168
291
  toast({
169
292
  title: errMsg
170
293
  });
171
- removeRecordTimer();
172
294
  }
173
295
  return true;
174
296
  };
@@ -1,4 +1,3 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
1
  import "core-js/modules/esnext.iterator.constructor.js";
3
2
  import "core-js/modules/esnext.iterator.filter.js";
4
3
  import "core-js/modules/esnext.iterator.map.js";
@@ -10,7 +9,6 @@ import { PlayState } from '../../interface';
10
9
  import { RecordVideo } from './recordVideo';
11
10
  jest.mock('@ray-js/ray', () => ({
12
11
  View: 'div',
13
- CoverView: 'div',
14
12
  Text: 'span',
15
13
  Image: 'img',
16
14
  getSystemInfoSync: () => ({
@@ -74,9 +72,9 @@ describe('RecordVideo', () => {
74
72
  setRecordingDisabled: value => store.set(recordingDisabled, value),
75
73
  addContent: (_type, content) => setContents(items => [...items, content]),
76
74
  deleteContent: (_type, id) => setContents(items => items.filter(item => item.id !== id))
77
- }), contents.map(item => /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread({}, item.initProps), {}, {
75
+ }), contents.map(item => /*#__PURE__*/React.createElement(item.content, {
78
76
  key: item.id
79
- }))));
77
+ })));
80
78
  }
81
79
  const clickRecord = async () => {
82
80
  await act(async () => {
@@ -1,18 +1,9 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import "core-js/modules/esnext.iterator.constructor.js";
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: () => ({
@@ -65,162 +56,4 @@ it('keeps the record control idle when starting is declined', async () => {
65
56
  expect(setRecordingDisabled).not.toHaveBeenCalled();
66
57
  expect(toast).not.toHaveBeenCalled();
67
58
  unmount();
68
- });
69
- describe('successful recording timer', () => {
70
- let container;
71
- beforeEach(() => {
72
- jest.useFakeTimers();
73
- jest.setSystemTime(10000);
74
- container = document.createElement('div');
75
- document.body.appendChild(container);
76
- });
77
- afterEach(() => {
78
- act(() => {
79
- ReactDOM.unmountComponentAtNode(container);
80
- });
81
- container.remove();
82
- jest.clearAllTimers();
83
- jest.restoreAllMocks();
84
- jest.useRealTimers();
85
- });
86
- function mountRecorder(mode) {
87
- const store = getDefaultStore();
88
- const recording = atom(false);
89
- const recordingDisabled = atom(false);
90
- const brandColor = atom('#000000');
91
- let updateContents;
92
- let recreateControl;
93
- const props = {
94
- recording,
95
- recordingDisabled,
96
- brandColor,
97
- screenType: atom('vertical'),
98
- playState: atom(PlayState.PLAYING),
99
- setRecording: jest.fn(async value => {
100
- store.set(recording, value);
101
- return value ? true : {
102
- tempImagePath: 'record.jpg'
103
- };
104
- }),
105
- setRecordingDisabled: value => store.set(recordingDisabled, value),
106
- addContent: (_area, item) => updateContents(items => [...items, item]),
107
- deleteContent: (_area, id) => updateContents(items => items.filter(item => item.id !== id)),
108
- toast: jest.fn(),
109
- devId: 'test-device',
110
- event: {
111
- emit: jest.fn()
112
- }
113
- };
114
- const Harness = () => {
115
- const [contents, setContents] = React.useState([]);
116
- const [generation, setGeneration] = React.useState(0);
117
- recreateControl = () => setGeneration(value => value + 1);
118
- updateContents = setContents;
119
- return /*#__PURE__*/React.createElement(PlayerRenderModeContext.Provider, {
120
- value: mode
121
- }, /*#__PURE__*/React.createElement(RecordVideo, _extends({
122
- key: generation
123
- }, props)), contents.map(item => /*#__PURE__*/React.createElement(item.content, _extends({
124
- key: item.id
125
- }, item.initProps))));
126
- };
127
- act(() => {
128
- ReactDOM.render(/*#__PURE__*/React.createElement(Harness, null), container);
129
- });
130
- return {
131
- props,
132
- store,
133
- brandColor,
134
- remountControl: () => {
135
- act(() => {
136
- recreateControl();
137
- });
138
- },
139
- click: async () => {
140
- await act(async () => {
141
- Simulate.click(container.firstElementChild);
142
- });
143
- },
144
- timer: () => container.querySelector('.ipc-player-plugin-record-video-toast-time')
145
- };
146
- }
147
- it.each(['webview', 'lynx'])('ticks and cleans up in %s', async mode => {
148
- const clear = jest.spyOn(global, 'clearInterval');
149
- const start = jest.spyOn(global, 'setInterval');
150
- const recorder = mountRecorder(mode);
151
- await recorder.click();
152
- expect(recorder.props.setRecording).toHaveBeenCalledWith(true);
153
- expect(recorder.timer().textContent).toBe('00:00');
154
- expect(start).toHaveBeenCalledTimes(1);
155
- const interval = start.mock.results[0].value;
156
- act(() => {
157
- jest.advanceTimersByTime(1000);
158
- });
159
- expect(recorder.timer().textContent).toBe('00:01');
160
- act(() => {
161
- recorder.store.set(recorder.brandColor, '#ffffff');
162
- });
163
- expect(recorder.timer().textContent).toBe('00:01');
164
- act(() => {
165
- jest.advanceTimersByTime(59000);
166
- });
167
- expect(recorder.timer().textContent).toBe('01:00');
168
- expect(start).toHaveBeenCalledTimes(1);
169
- await recorder.click();
170
- expect(recorder.props.setRecording).toHaveBeenLastCalledWith(false);
171
- expect(recorder.timer()).toBeNull();
172
- expect(clear).toHaveBeenCalledWith(interval);
173
- await recorder.click();
174
- expect(recorder.timer().textContent).toBe('00:00');
175
- const nextInterval = start.mock.results[1].value;
176
- act(() => {
177
- ReactDOM.unmountComponentAtNode(container);
178
- });
179
- expect(clear).toHaveBeenCalledWith(nextInterval);
180
- });
181
- it('uses elapsed wall time after a delayed tick', async () => {
182
- const recorder = mountRecorder('lynx');
183
- await recorder.click();
184
- act(() => {
185
- jest.setSystemTime(74000);
186
- jest.advanceTimersByTime(1000);
187
- });
188
- expect(recorder.timer().textContent).toBe('01:05');
189
- });
190
- it.each(['webview', 'lynx'])('stops the persistent timer after orientation remounts the %s toolbar', async mode => {
191
- const clear = jest.spyOn(global, 'clearInterval');
192
- const start = jest.spyOn(global, 'setInterval');
193
- const recorder = mountRecorder(mode);
194
- await recorder.click();
195
- const interval = start.mock.results[0].value;
196
- act(() => {
197
- jest.advanceTimersByTime(4000);
198
- });
199
- act(() => {
200
- recorder.store.set(recorder.props.screenType, 'full');
201
- });
202
- recorder.remountControl();
203
- expect(recorder.timer().textContent).toBe('00:04');
204
- act(() => {
205
- jest.advanceTimersByTime(1000);
206
- });
207
- act(() => {
208
- recorder.store.set(recorder.props.screenType, 'vertical');
209
- });
210
- recorder.remountControl();
211
- expect(recorder.timer().textContent).toBe('00:05');
212
- await recorder.click();
213
- expect(recorder.props.setRecording).toHaveBeenLastCalledWith(false);
214
- expect(recorder.timer()).toBeNull();
215
- expect(clear).toHaveBeenCalledWith(interval);
216
- });
217
- it('removes the timer when recording stops outside the remounted control', async () => {
218
- const recorder = mountRecorder('lynx');
219
- await recorder.click();
220
- recorder.remountControl();
221
- act(() => {
222
- recorder.store.set(recorder.props.recording, false);
223
- });
224
- expect(recorder.timer()).toBeNull();
225
- });
226
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
- const targetResolution = normalizeResolution(value);
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(targetResolution).then(() => {
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
- const normalizedItem = normalizeResolution(item);
79
- const selected = normalizedItem === normalizeResolution(resolution);
80
- return /*#__PURE__*/React.createElement(Text, {
81
- key: item,
82
- onClick: () => {
83
- event.emit(widgetClick, {
84
- widgetId: widgetLabs.FULL_RESOLUTION_CONTROL,
85
- extra: {
86
- resolution: normalizedItem
87
- }
88
- });
89
- changeResolution(normalizedItem);
90
- },
91
- className: clsx('ipc-player-plugin-full-resolution-control-text'),
92
- style: selected ? {
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(String(resolution).toUpperCase() === 'HD' ? 'SD' : 'HD');
55
+ setResolution(resolution === 'HD' ? 'SD' : 'HD');
57
56
  }
58
57
  event.emit(pauseTimeToHideAllComponent);
59
58
  return true;