@ray-js/ipc-player-integration 0.0.64 → 0.0.65-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/lib/ctx/ctx.album.test.d.ts +1 -0
  2. package/lib/ctx/ctx.album.test.js +197 -0
  3. package/lib/ctx/ctx.composition.js +13 -3
  4. package/lib/ctx/ctx.js +46 -35
  5. package/lib/i18n/index.d.ts +12 -0
  6. package/lib/i18n/strings.d.ts +6 -0
  7. package/lib/i18n/strings.js +6 -0
  8. package/lib/interface.d.ts +17 -3
  9. package/lib/ui/absoluteContent.d.ts +2 -0
  10. package/lib/ui/absoluteContent.js +3 -0
  11. package/lib/ui/bottomLeftContent.js +3 -1
  12. package/lib/ui/ui.js +65 -52
  13. package/lib/utils/captureResult.d.ts +14 -0
  14. package/lib/utils/captureResult.js +70 -0
  15. package/lib/utils/captureResult.test.d.ts +1 -0
  16. package/lib/utils/captureResult.test.js +117 -0
  17. package/lib/utils/fullLinkTracking.d.ts +5 -0
  18. package/lib/utils/fullLinkTracking.js +71 -0
  19. package/lib/utils/navigation.d.ts +2 -1
  20. package/lib/utils/navigation.js +13 -3
  21. package/lib/widgets/captureResult/captureResult.d.ts +16 -0
  22. package/lib/widgets/captureResult/captureResult.js +85 -0
  23. package/lib/widgets/captureResult/captureResult.less +144 -0
  24. package/lib/widgets/captureResult/captureResult.test.d.ts +1 -0
  25. package/lib/widgets/captureResult/captureResult.test.js +80 -0
  26. package/lib/widgets/captureResult/index.d.ts +2 -0
  27. package/lib/widgets/captureResult/index.js +2 -0
  28. package/lib/widgets/index.d.ts +1 -0
  29. package/lib/widgets/index.js +2 -1
  30. package/lib/widgets/multiCamera/index.less +1 -0
  31. package/lib/widgets/multiCamera/moveablePtzControl.js +4 -4
  32. package/lib/widgets/recordVideo/recordVideo.js +53 -52
  33. package/lib/widgets/recordVideo/recordVideo.less +17 -74
  34. package/lib/widgets/recordVideo/recordVideo.lifecycle.test.d.ts +1 -0
  35. package/lib/widgets/recordVideo/recordVideo.lifecycle.test.js +106 -0
  36. package/lib/widgets/recordVideo/recordVideo.test.js +1 -0
  37. package/lib/widgets/screenshot/screenshot.js +66 -44
  38. package/lib/widgets/screenshot/screenshot.less +1 -40
  39. package/lib/widgets/screenshot/screenshot.test.d.ts +1 -0
  40. package/lib/widgets/screenshot/screenshot.test.js +120 -0
  41. package/lib/widgets/trialBadge/index.d.ts +2 -1
  42. package/lib/widgets/trialBadge/index.js +17 -9
  43. package/lib/widgets/trialBadge/useTrialBadge.d.ts +3 -2
  44. package/lib/widgets/trialBadge/useTrialBadge.js +13 -2
  45. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,197 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import { act, renderHook } from '@testing-library/react-hooks/dom';
3
+ import { authorize, authorizeStatus, getSystemInfoSync, showModal } from '@ray-js/ray';
4
+ import { createUseCtx } from './ctx';
5
+ import { useStore } from './store';
6
+ jest.mock('@ray-js/ray', () => ({
7
+ authorize: jest.fn(),
8
+ authorizeStatus: jest.fn(),
9
+ getSystemInfoSync: jest.fn(),
10
+ openAppSystemSettingPage: jest.fn(),
11
+ showModal: jest.fn()
12
+ }));
13
+ jest.mock('@ray-js/ray-ipc-utils/lib/interface', () => ({
14
+ ClarityType: {
15
+ HD: 'HD',
16
+ SD: 'SD',
17
+ AUTO: 'AUTO'
18
+ },
19
+ IntercomMode: {
20
+ OneWay: 'OneWay',
21
+ TwoWay: 'TwoWay'
22
+ }
23
+ }));
24
+ jest.mock('../i18n', () => ({
25
+ __esModule: true,
26
+ default: {
27
+ getLang: key => key
28
+ }
29
+ }));
30
+ jest.mock('./multiCameraCtx', () => ({
31
+ isMultiCameraTileSupported: () => false,
32
+ useMultiCameraCtx: () => ({})
33
+ }));
34
+ jest.mock('../utils/ttt', () => ({
35
+ getCachedAutoClarity: jest.fn(),
36
+ isClarityChangedSupported: () => false,
37
+ setCachedAutoClarity: jest.fn(),
38
+ subscribeClarityChanged: () => () => undefined
39
+ }));
40
+ beforeEach(() => {
41
+ jest.clearAllMocks();
42
+ getSystemInfoSync.mockReturnValue({
43
+ platform: 'android',
44
+ system: 'android 12'
45
+ });
46
+ authorizeStatus.mockImplementation(_ref => {
47
+ let {
48
+ fail
49
+ } = _ref;
50
+ return fail({
51
+ errorCode: 9004
52
+ });
53
+ });
54
+ authorize.mockImplementation(_ref2 => {
55
+ let {
56
+ fail
57
+ } = _ref2;
58
+ return fail({
59
+ errorCode: 9004
60
+ });
61
+ });
62
+ });
63
+ const mountContext = function () {
64
+ let saveToAlbum = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
65
+ const capture = {
66
+ tempImagePath: 'thingfile://capture.jpg',
67
+ filePath: 'thingfile://record.mp4'
68
+ };
69
+ const startRecord = jest.fn(_ref3 => {
70
+ let {
71
+ success
72
+ } = _ref3;
73
+ return success();
74
+ });
75
+ const stopRecord = jest.fn(_ref4 => {
76
+ let {
77
+ success
78
+ } = _ref4;
79
+ return success(capture);
80
+ });
81
+ const useCtx = createUseCtx({
82
+ createPlayContext: () => ({
83
+ startRecord,
84
+ stopRecord
85
+ }),
86
+ getMemoryState: jest.fn().mockResolvedValue({
87
+ resolution: 'HD',
88
+ resolutionList: ['HD', 'SD'],
89
+ mute: true,
90
+ intercomMode: 'TwoWay',
91
+ isIntercomSupported: false
92
+ }),
93
+ setResolutionMemoryState: jest.fn(),
94
+ setMuteMemoryState: jest.fn(),
95
+ authorizeStatus: jest.fn(),
96
+ toast: jest.fn()
97
+ });
98
+ const hook = renderHook(() => {
99
+ const ctx = useCtx({
100
+ devId: 'camera-1',
101
+ multiLens: true,
102
+ saveToAlbum
103
+ });
104
+ const state = useStore({
105
+ recording: ctx.recording
106
+ });
107
+ return _objectSpread(_objectSpread({}, ctx), {}, {
108
+ state
109
+ });
110
+ });
111
+ return _objectSpread(_objectSpread({}, hook), {}, {
112
+ startRecord,
113
+ stopRecord,
114
+ capture
115
+ });
116
+ };
117
+ it('starts without legacy authorization and retains the native stop result', async () => {
118
+ const {
119
+ result,
120
+ startRecord,
121
+ stopRecord,
122
+ capture,
123
+ unmount
124
+ } = mountContext();
125
+ await act(async () => {
126
+ expect(await result.current.setRecording(true)).toBe(true);
127
+ });
128
+ expect(startRecord).toHaveBeenCalledWith(expect.objectContaining({
129
+ saveToAlbum: 1
130
+ }));
131
+ expect(result.current.state.recording).toBe(true);
132
+ expect(result.current.multiLens).toBe(true);
133
+ await act(async () => {
134
+ expect(await result.current.setRecording(false)).toEqual(capture);
135
+ });
136
+ expect(stopRecord).toHaveBeenCalledTimes(1);
137
+ expect(result.current.state.recording).toBe(false);
138
+ expect(authorizeStatus).not.toHaveBeenCalled();
139
+ expect(authorize).not.toHaveBeenCalled();
140
+ unmount();
141
+ });
142
+ it('settles a denied start without calling the native recorder', async () => {
143
+ getSystemInfoSync.mockReturnValue({
144
+ platform: 'ios',
145
+ system: 'iOS 18'
146
+ });
147
+ const {
148
+ result,
149
+ startRecord,
150
+ unmount
151
+ } = mountContext();
152
+ await act(async () => {
153
+ expect(await result.current.setRecording(true)).toBe(false);
154
+ });
155
+ expect(startRecord).not.toHaveBeenCalled();
156
+ expect(result.current.state.recording).toBe(false);
157
+ expect(showModal).toHaveBeenCalledTimes(1);
158
+ unmount();
159
+ });
160
+ it('propagates a native start failure without entering recording state', async () => {
161
+ const {
162
+ result,
163
+ startRecord,
164
+ unmount
165
+ } = mountContext();
166
+ const error = {
167
+ errorCode: 1001,
168
+ errorMsg: 'Start failed'
169
+ };
170
+ startRecord.mockImplementationOnce(_ref5 => {
171
+ let {
172
+ fail
173
+ } = _ref5;
174
+ return fail(error);
175
+ });
176
+ await act(async () => {
177
+ await expect(result.current.setRecording(true)).rejects.toEqual(error);
178
+ });
179
+ expect(result.current.state.recording).toBe(false);
180
+ unmount();
181
+ });
182
+ it('keeps the requested album when stopping on page unload', async () => {
183
+ const {
184
+ result,
185
+ stopRecord,
186
+ capture,
187
+ unmount
188
+ } = mountContext(0);
189
+ await act(async () => {
190
+ expect(await result.current.stopRecordingOnUnload()).toEqual(capture);
191
+ });
192
+ expect(stopRecord).toHaveBeenCalledWith(expect.objectContaining({
193
+ saveToAlbum: 0
194
+ }));
195
+ expect(authorizeStatus).not.toHaveBeenCalled();
196
+ unmount();
197
+ });
@@ -6,6 +6,7 @@ import { IntercomMode, MuteMode, ClarityType } from '@ray-js/ray-ipc-utils/lib/i
6
6
  import { createUseCtx } from './ctx';
7
7
  import { FullSmallIntercom, VerticalSmallIntercom, BatteryFull, Battery, Screenshot, TempHumidity, Signal4G, RecordVideo, FullScreen, VideoBitKBP, Muted, Floodlight, Siren, TryExperience, Resolution, Ptz, MultiPtz, TileTip, PtzMoveableTip, LandscapeTip, TileActions, MoveablePtzControl, SwitchLayout, ToggleVerticalFull, RealTimeMagnification, ZoomTurntableEntry } from '../widgets';
8
8
  import { authorizeStatus } from '../utils/authorize';
9
+ import { PlayState } from '../interface';
9
10
  import { landscapeTipId, moveablePtzControlId, multiPtzId, ptzMoveableTipId, tileActionsId, tileTipId } from '../ui/constant';
10
11
  import { multiPrefix } from '../widgets/multiCamera/constants';
11
12
  const createPlayContext = ty.createIpcPlayerContext;
@@ -87,20 +88,29 @@ export const defaultBottomRightContent = [{
87
88
  content: FullScreen
88
89
  }];
89
90
  const absoluteContent = [];
91
+ const renderWhenPlaying = _ref => {
92
+ let {
93
+ playState
94
+ } = _ref;
95
+ return playState === PlayState.PLAYING;
96
+ };
90
97
  export const multiCameraAbsoluteContent = [{
91
98
  id: tileTipId,
92
99
  content: TileTip,
93
100
  absoluteContentClassName: `${multiPrefix}-tile-tip-wrap`,
101
+ renderWhen: renderWhenPlaying,
94
102
  hidden: true
95
103
  }, {
96
104
  id: ptzMoveableTipId,
97
105
  content: PtzMoveableTip,
98
106
  absoluteContentClassName: `${multiPrefix}-tile-tip-wrap`,
107
+ renderWhen: renderWhenPlaying,
99
108
  hidden: true
100
109
  }, {
101
110
  id: landscapeTipId,
102
111
  content: LandscapeTip,
103
112
  absoluteContentClassName: `${multiPrefix}-tile-tip-wrap`,
113
+ renderWhen: renderWhenPlaying,
104
114
  hidden: true
105
115
  }, {
106
116
  id: tileActionsId,
@@ -112,12 +122,12 @@ export const multiCameraAbsoluteContent = [{
112
122
  absoluteNoCoverView: true,
113
123
  hidden: true
114
124
  }];
115
- const toast = _ref => {
125
+ const toast = _ref2 => {
116
126
  let {
117
127
  title,
118
128
  duration
119
- } = _ref,
120
- config = _objectWithoutProperties(_ref, _excluded);
129
+ } = _ref2,
130
+ config = _objectWithoutProperties(_ref2, _excluded);
121
131
  ty.showToast(_objectSpread({
122
132
  title,
123
133
  duration,
package/lib/ctx/ctx.js CHANGED
@@ -40,10 +40,13 @@ export const createUseCtx = _ref => {
40
40
  initBottomRightContent,
41
41
  initAbsoluteContent,
42
42
  saveToAlbum = SAVE_TO_ALBUM,
43
+ multiLens = false,
43
44
  showPtzControlTip = false,
44
45
  videoSplitProtocol
45
46
  } = _ref2;
46
47
  const streamStatus = useRef();
48
+ // The page owns this context; player UI remounts must retain exposure history.
49
+ const trialBadgeViewedRef = useRef(false);
47
50
  // 全屏、竖屏
48
51
  const [screenType, setScreenType] = useAtom('vertical');
49
52
  const IPCPlayerInstance = useRef();
@@ -59,6 +62,7 @@ export const createUseCtx = _ref => {
59
62
 
60
63
  // 录像中
61
64
  const [recording] = useAtom(false);
65
+ const recordingMultiLensRef = useRef(false);
62
66
 
63
67
  // 录像是否不可点击
64
68
  const [recordingDisabled, setRecordingDisabled] = useAtom(false);
@@ -311,6 +315,30 @@ export const createUseCtx = _ref => {
311
315
  });
312
316
  });
313
317
  };
318
+ const stopRecording = showError => {
319
+ return new Promise((resolve, reject) => {
320
+ IPCPlayerInstance.current.stopRecord({
321
+ saveToAlbum,
322
+ success: res => {
323
+ recordingMultiLensRef.current = false;
324
+ updateAtom(recording, false);
325
+ resolve(res);
326
+ },
327
+ fail: err => {
328
+ recordingMultiLensRef.current = false;
329
+ updateAtom(recording, false);
330
+ reject(err);
331
+ if (showError) {
332
+ const errObj = err.innerError || err || {};
333
+ const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_stop_recording_err');
334
+ toast({
335
+ title: errMsg
336
+ });
337
+ }
338
+ }
339
+ });
340
+ });
341
+ };
314
342
  const multiCameraCtx = useMultiCameraCtx({
315
343
  devId,
316
344
  IPCPlayerInstance: IPCPlayerInstance.current,
@@ -318,9 +346,11 @@ export const createUseCtx = _ref => {
318
346
  });
319
347
  return {
320
348
  devId,
349
+ trialBadgeViewedRef,
321
350
  brandColor,
322
351
  verticalMic,
323
352
  saveToAlbum,
353
+ multiLens,
324
354
  screenType,
325
355
  isVerticalFullLayout,
326
356
  setIsVerticalFullLayout,
@@ -465,44 +495,25 @@ export const createUseCtx = _ref => {
465
495
  eventRef.current.emit(changeIgnoreHideStopPreview, false);
466
496
  return false;
467
497
  }
468
- if (target) {
469
- const granted = await ensureAlbumPermission();
470
- eventRef.current.emit(changeIgnoreHideStopPreview, false);
471
- if (!granted) return false;
472
- }
498
+ if (!target) return stopRecording(true);
499
+ const granted = await ensureAlbumPermission();
500
+ eventRef.current.emit(changeIgnoreHideStopPreview, false);
501
+ if (!granted) return false;
473
502
  return new Promise((resolve, reject) => {
474
- if (target) {
475
- IPCPlayerInstance.current.startRecord({
476
- saveToAlbum,
477
- success: () => {
478
- updateAtom(recording, true);
479
- resolve(true);
480
- },
481
- fail: err => {
482
- eventRef.current.emit(changeIgnoreHideStopPreview, false);
483
- reject(err);
484
- }
485
- });
486
- } else {
487
- IPCPlayerInstance.current.stopRecord({
488
- saveToAlbum,
489
- success: res => {
490
- updateAtom(recording, false);
491
- resolve(res);
492
- },
493
- fail: err => {
494
- updateAtom(recording, false);
495
- reject(err);
496
- const errObj = err.innerError || err || {};
497
- const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_stop_recording_err');
498
- toast({
499
- title: errMsg
500
- });
501
- }
502
- });
503
- }
503
+ IPCPlayerInstance.current.startRecord({
504
+ saveToAlbum,
505
+ success: () => {
506
+ updateAtom(recording, true);
507
+ resolve(true);
508
+ },
509
+ fail: err => {
510
+ eventRef.current.emit(changeIgnoreHideStopPreview, false);
511
+ reject(err);
512
+ }
513
+ });
504
514
  });
505
515
  },
516
+ stopRecordingOnUnload: () => stopRecording(false),
506
517
  setRecordingDisabled,
507
518
  setScreenType,
508
519
  topLeftContent,
@@ -10,8 +10,11 @@ declare const Strings: kit.I18N<{
10
10
  ipc_player_resolution_AUDIO: string;
11
11
  ipc_player_current_resolution_is_equal: string;
12
12
  ipc_player_screenshot_success_tip: string;
13
+ ipc_player_screenshot_multi_success_tip: string;
13
14
  ipc_player_error_screenshot_error_tip: string;
14
15
  ipc_player_record_success_tip: string;
16
+ ipc_player_record_multi_success_tip: string;
17
+ ipc_player_multi_capture_success_count: string;
15
18
  ipc_player_shot_success_check: string;
16
19
  ipc_player_record_success_check: string;
17
20
  ipc_player_recording_now_tip: string;
@@ -52,8 +55,11 @@ declare const Strings: kit.I18N<{
52
55
  ipc_player_resolution_AUDIO: string;
53
56
  ipc_player_current_resolution_is_equal: string;
54
57
  ipc_player_screenshot_success_tip: string;
58
+ ipc_player_screenshot_multi_success_tip: string;
55
59
  ipc_player_error_screenshot_error_tip: string;
56
60
  ipc_player_record_success_tip: string;
61
+ ipc_player_record_multi_success_tip: string;
62
+ ipc_player_multi_capture_success_count: string;
57
63
  ipc_player_shot_success_check: string;
58
64
  ipc_player_record_success_check: string;
59
65
  ipc_player_recording_now_tip: string;
@@ -94,8 +100,11 @@ declare const Strings: kit.I18N<{
94
100
  ipc_player_resolution_AUDIO: string;
95
101
  ipc_player_current_resolution_is_equal: string;
96
102
  ipc_player_screenshot_success_tip: string;
103
+ ipc_player_screenshot_multi_success_tip: string;
97
104
  ipc_player_error_screenshot_error_tip: string;
98
105
  ipc_player_record_success_tip: string;
106
+ ipc_player_record_multi_success_tip: string;
107
+ ipc_player_multi_capture_success_count: string;
99
108
  ipc_player_shot_success_check: string;
100
109
  ipc_player_record_success_check: string;
101
110
  ipc_player_recording_now_tip: string;
@@ -135,8 +144,11 @@ declare const Strings: kit.I18N<{
135
144
  ipc_player_resolution_AUDIO: string;
136
145
  ipc_player_current_resolution_is_equal: string;
137
146
  ipc_player_screenshot_success_tip: string;
147
+ ipc_player_screenshot_multi_success_tip: string;
138
148
  ipc_player_error_screenshot_error_tip: string;
139
149
  ipc_player_record_success_tip: string;
150
+ ipc_player_record_multi_success_tip: string;
151
+ ipc_player_multi_capture_success_count: string;
140
152
  ipc_player_shot_success_check: string;
141
153
  ipc_player_record_success_check: string;
142
154
  ipc_player_recording_now_tip: string;
@@ -9,8 +9,11 @@ declare const _default: {
9
9
  ipc_player_resolution_AUDIO: string;
10
10
  ipc_player_current_resolution_is_equal: string;
11
11
  ipc_player_screenshot_success_tip: string;
12
+ ipc_player_screenshot_multi_success_tip: string;
12
13
  ipc_player_error_screenshot_error_tip: string;
13
14
  ipc_player_record_success_tip: string;
15
+ ipc_player_record_multi_success_tip: string;
16
+ ipc_player_multi_capture_success_count: string;
14
17
  ipc_player_shot_success_check: string;
15
18
  ipc_player_record_success_check: string;
16
19
  ipc_player_recording_now_tip: string;
@@ -51,8 +54,11 @@ declare const _default: {
51
54
  ipc_player_resolution_AUDIO: string;
52
55
  ipc_player_current_resolution_is_equal: string;
53
56
  ipc_player_screenshot_success_tip: string;
57
+ ipc_player_screenshot_multi_success_tip: string;
54
58
  ipc_player_error_screenshot_error_tip: string;
55
59
  ipc_player_record_success_tip: string;
60
+ ipc_player_record_multi_success_tip: string;
61
+ ipc_player_multi_capture_success_count: string;
56
62
  ipc_player_shot_success_check: string;
57
63
  ipc_player_record_success_check: string;
58
64
  ipc_player_recording_now_tip: string;
@@ -9,8 +9,11 @@ export default {
9
9
  ipc_player_resolution_AUDIO: 'Audio Mode',
10
10
  ipc_player_current_resolution_is_equal: 'Already at current clarity',
11
11
  ipc_player_screenshot_success_tip: 'Screenshot saved to album',
12
+ ipc_player_screenshot_multi_success_tip: 'Screenshots saved to album',
12
13
  ipc_player_error_screenshot_error_tip: 'Screenshot failed. Please try again later.',
13
14
  ipc_player_record_success_tip: 'Recording saved to album',
15
+ ipc_player_record_multi_success_tip: 'Recordings saved to album',
16
+ ipc_player_multi_capture_success_count: '{0} items',
14
17
  ipc_player_shot_success_check: 'View',
15
18
  ipc_player_record_success_check: 'View',
16
19
  ipc_player_recording_now_tip: 'Recording in progress...',
@@ -51,8 +54,11 @@ export default {
51
54
  ipc_player_resolution_AUDIO: '音频模式',
52
55
  ipc_player_current_resolution_is_equal: '已是当前清晰度',
53
56
  ipc_player_screenshot_success_tip: '截图已保存在APP相册',
57
+ ipc_player_screenshot_multi_success_tip: '图片已保存至相册',
54
58
  ipc_player_error_screenshot_error_tip: '截图失败了,请稍后再试',
55
59
  ipc_player_record_success_tip: '录像已保存在APP相册',
60
+ ipc_player_record_multi_success_tip: '视频已保存至相册',
61
+ ipc_player_multi_capture_success_count: '共{0}个',
56
62
  ipc_player_shot_success_check: '查看',
57
63
  ipc_player_record_success_check: '查看',
58
64
  ipc_player_recording_now_tip: '正在录像中...',
@@ -49,13 +49,16 @@ export type UseCtx = (options: {
49
49
  initBottomRightContent?: ComponentConfig[];
50
50
  initAbsoluteContent?: ComponentConfig[];
51
51
  saveToAlbum?: 0 | 1;
52
+ multiLens?: boolean;
52
53
  showPtzControlTip?: boolean;
53
54
  videoSplitProtocol?: VideoSplitProtocol;
54
55
  }) => {
55
56
  devId: string;
57
+ trialBadgeViewedRef: React.MutableRefObject<boolean>;
56
58
  brandColor: RetAtom<string>;
57
59
  verticalMic: RetAtom<boolean>;
58
60
  saveToAlbum: 0 | 1;
61
+ multiLens: boolean;
59
62
  showPtzControlTip: boolean;
60
63
  screenType: RetAtom<ScreenType>;
61
64
  isVerticalFullLayout: RetAtom<boolean>;
@@ -91,7 +94,8 @@ export type UseCtx = (options: {
91
94
  setRecordingDisabled: (type: boolean) => void;
92
95
  setResolution: (type: string) => Promise<boolean>;
93
96
  setResolutionList: (type: string[]) => void;
94
- setRecording: (value: boolean, onlyUpdateAtom?: boolean) => Promise<RecordInfoData>;
97
+ setRecording: (value: boolean, onlyUpdateAtom?: boolean) => Promise<CaptureResult>;
98
+ stopRecordingOnUnload: () => Promise<CaptureResult>;
95
99
  setIntercom: (value: boolean, onlyUpdateAtom?: boolean) => Promise<boolean>;
96
100
  setMute: (value: boolean) => Promise<boolean>;
97
101
  changeStreamStatus: (value: PlayerStreamStatus) => void;
@@ -122,8 +126,12 @@ export type ComponentConfig<T = ReturnType<UseCtx> & Record<string, any>> = {
122
126
  absoluteContentClassName?: string;
123
127
  absoluteContentStyle?: React.CSSProperties;
124
128
  absoluteNoCoverView?: boolean;
129
+ renderWhen?: (state: ComponentRenderState) => boolean;
125
130
  hidden?: boolean;
126
131
  };
132
+ export type ComponentRenderState = {
133
+ playState: PlayState;
134
+ };
127
135
  export type ComponentConfigProps = {
128
136
  IPCPlayerContext: IpcContext;
129
137
  } & ReturnType<UseCtx>;
@@ -131,11 +139,17 @@ export type PlayStatusData = {
131
139
  playState: PlayState;
132
140
  playCode: number;
133
141
  };
134
- export type RecordInfoData = boolean | {
142
+ export type CaptureFileInfo = {
143
+ index?: number;
135
144
  tempImagePath: string;
136
145
  filePath: string;
137
- thumbPath: string;
146
+ thumbPath?: string;
147
+ width?: number;
148
+ height?: number;
149
+ data?: string;
138
150
  };
151
+ export type CaptureResult = boolean | CaptureFileInfo;
152
+ export type RecordInfoData = CaptureResult;
139
153
  /**
140
154
  * 多目屏幕模式
141
155
  */
@@ -0,0 +1,2 @@
1
+ import type { ComponentConfig, ComponentRenderState } from '../interface';
2
+ export declare function shouldRenderContent<T>(item: ComponentConfig<T>, state: ComponentRenderState): boolean;
@@ -0,0 +1,3 @@
1
+ export function shouldRenderContent(item, state) {
2
+ return !item.hidden && (!item.renderWhen || item.renderWhen(state));
3
+ }
@@ -82,9 +82,10 @@ const BottomLeftContent = _ref => {
82
82
  const [shouldHide] = useComponentHideState();
83
83
  const {
84
84
  showTrialBadge,
85
+ handleTrialView,
85
86
  handleTrialSubscribe,
86
87
  handleCountdownEnd
87
- } = useTrialBadge(ctx.event, ctx.devId, trialRemainingSec);
88
+ } = useTrialBadge(ctx.event, ctx.devId, trialRemainingSec, ctx.trialBadgeViewedRef);
88
89
 
89
90
  // 横向滚动状态:内容溢出且未滑到对应边缘时,显示左 / 右箭头提示
90
91
  const idRef = useRef(++scrollClsSeq);
@@ -405,6 +406,7 @@ const BottomLeftContent = _ref => {
405
406
  marginLeft: screenType === 'vertical' ? '12px' : '25px'
406
407
  }
407
408
  }, /*#__PURE__*/React.createElement(TrialBadge, {
409
+ onView: handleTrialView,
408
410
  brandColor: brandColor,
409
411
  trialRemainingSec: trialRemainingSec,
410
412
  onSubscribe: handleTrialSubscribe,