@ray-js/ipc-player-integration 0.0.54 → 0.0.55-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 (31) hide show
  1. package/lib/ctx/ctx.js +20 -144
  2. package/lib/i18n/index.d.ts +0 -20
  3. package/lib/i18n/strings.d.ts +0 -10
  4. package/lib/i18n/strings.js +0 -10
  5. package/lib/interface.d.ts +1 -3
  6. package/lib/ui/ui.js +2 -43
  7. package/lib/utils/authorize/album.d.ts +1 -0
  8. package/lib/utils/authorize/album.js +39 -0
  9. package/lib/utils/authorize/album.test.js +82 -0
  10. package/lib/utils/ttt.d.ts +0 -26
  11. package/lib/utils/ttt.js +2 -112
  12. package/lib/widgets/recordVideo/recordVideo.js +5 -1
  13. package/lib/widgets/recordVideo/recordVideo.test.js +58 -0
  14. package/lib/widgets/resolution/resolution.js +1 -0
  15. package/lib/widgets/screenshot/screenshot.js +20 -71
  16. package/lib/widgets/videoBitKBP/videoBitKBP.js +12 -42
  17. package/lib/widgets/videoBitKBP/videoBitKBP.less +8 -17
  18. package/lib/widgets/zoomTurntable/lensSkill.js +4 -1
  19. package/package.json +2 -2
  20. package/lib/ctx/ctx.autoClarity.test.js +0 -150
  21. package/lib/ui/useOfflineShownNotification.d.ts +0 -1
  22. package/lib/ui/useOfflineShownNotification.js +0 -32
  23. package/lib/ui/useOfflineShownNotification.test.js +0 -98
  24. package/lib/utils/ttt.autoClarity.test.d.ts +0 -1
  25. package/lib/utils/ttt.autoClarity.test.js +0 -75
  26. package/lib/utils/ttt.notifyOfflineShown.test.d.ts +0 -1
  27. package/lib/utils/ttt.notifyOfflineShown.test.js +0 -30
  28. package/lib/widgets/videoBitKBP/videoBitKBP.test.d.ts +0 -1
  29. package/lib/widgets/videoBitKBP/videoBitKBP.test.js +0 -156
  30. /package/lib/{ctx/ctx.autoClarity.test.d.ts → utils/authorize/album.test.d.ts} +0 -0
  31. /package/lib/{ui/useOfflineShownNotification.test.d.ts → widgets/recordVideo/recordVideo.test.d.ts} +0 -0
package/lib/utils/ttt.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
3
2
  export function getSmartImageQualityState(devId) {
4
3
  return new Promise(resolve => {
5
4
  var _ty$ipc;
@@ -121,34 +120,10 @@ export function isLowPhone() {
121
120
  }
122
121
  });
123
122
  }
124
-
125
- /**
126
- * 通知宿主离线提示已经展示。
127
- *
128
- * 这个 TTT 方法不是所有宿主都提供,因此调用前必须做能力判断;
129
- * 老宿主或 Web 环境下直接跳过,不能影响播放器自身的离线处理。
130
- */
131
- export function notifyOfflineShown(deviceId) {
132
- var _ty3;
133
- const method = typeof ty !== 'undefined' ? (_ty3 = ty) === null || _ty3 === void 0 || (_ty3 = _ty3.ipc) === null || _ty3 === void 0 ? void 0 : _ty3.notifyOfflineShown : undefined;
134
- if (typeof method !== 'function') {
135
- return false;
136
- }
137
- try {
138
- console.warn('res===notifyOfflineShown', deviceId);
139
- method({
140
- deviceId,
141
- scene: 'preview_mini'
142
- });
143
- return true;
144
- } catch (error) {
145
- return false;
146
- }
147
- }
148
123
  export function getNgRawData() {
149
124
  return new Promise(resolve => {
150
- var _ty4;
151
- const isSupport = typeof ((_ty4 = ty) === null || _ty4 === void 0 ? void 0 : _ty4.getNgRawData) === 'function';
125
+ var _ty3;
126
+ const isSupport = typeof ((_ty3 = ty) === null || _ty3 === void 0 ? void 0 : _ty3.getNgRawData) === 'function';
152
127
  if (!isSupport) {
153
128
  resolve(false);
154
129
  return;
@@ -167,89 +142,4 @@ export function getNgRawData() {
167
142
  resolve(false);
168
143
  }
169
144
  });
170
- }
171
-
172
- // 是否支持自动清晰度(ttt 方法 onClarityChanged 存在即支持)
173
- export function isClarityChangedSupported() {
174
- var _ty5;
175
- return typeof ty !== 'undefined' && typeof ((_ty5 = ty) === null || _ty5 === void 0 || (_ty5 = _ty5.ipc) === null || _ty5 === void 0 ? void 0 : _ty5.onClarityChanged) === 'function';
176
- }
177
- const actualClarityTypes = [ClarityType.SS, ClarityType.SD, ClarityType.HD, ClarityType.UD, ClarityType.SSP];
178
- const autoClarityStorageKey = devId => `${devId}_auto_clarity`;
179
- export function getCachedAutoClarity(devId) {
180
- try {
181
- const stored = ty.getStorageSync({
182
- key: autoClarityStorageKey(devId)
183
- });
184
- const clarity = typeof stored === 'string' ? stored : stored === null || stored === void 0 ? void 0 : stored.data;
185
- return actualClarityTypes.includes(clarity) ? clarity : null;
186
- } catch (error) {
187
- return null;
188
- }
189
- }
190
- export function setCachedAutoClarity(devId, clarity) {
191
- if (!actualClarityTypes.includes(clarity)) return;
192
- try {
193
- ty.setStorageSync({
194
- key: autoClarityStorageKey(devId),
195
- data: clarity
196
- });
197
- } catch (error) {
198
- console.warn('res===setCachedAutoClarity fail', error);
199
- }
200
- }
201
- export function offClarityChanged(listener) {
202
- var _ty6;
203
- const ipc = typeof ty !== 'undefined' ? (_ty6 = ty) === null || _ty6 === void 0 ? void 0 : _ty6.ipc : undefined;
204
- if (!ipc || typeof ipc.offClarityChanged !== 'function') {
205
- return;
206
- }
207
- try {
208
- ipc.offClarityChanged(listener);
209
- } catch (error) {
210
- console.warn('res===offClarityChanged fail', error);
211
- }
212
- }
213
-
214
- /**
215
- * 监听自动清晰度变化,返回取消监听函数。
216
- *
217
- * onClarityChanged / offClarityChanged 均使用同一个 listener 引用,
218
- * 否则宿主无法正确移除监听。
219
- */
220
- export function subscribeClarityChanged(devId, handler) {
221
- var _ty7;
222
- const ipc = typeof ty !== 'undefined' ? (_ty7 = ty) === null || _ty7 === void 0 ? void 0 : _ty7.ipc : undefined;
223
- if (!ipc || typeof ipc.onClarityChanged !== 'function') {
224
- return () => undefined;
225
- }
226
- const listener = payload => {
227
- console.log('[resolution] onClarityChanged 事件到达', JSON.stringify(payload !== null && payload !== void 0 ? payload : null));
228
- const {
229
- deviceId,
230
- clarity
231
- } = payload || {};
232
- if (!actualClarityTypes.includes(clarity)) {
233
- console.warn('[resolution] onClarityChanged 未返回实际清晰度');
234
- return;
235
- }
236
- // 一页多设备时只认自己的;宿主没带 deviceId 就不过滤
237
- if (deviceId && deviceId !== devId) {
238
- console.warn('[resolution] onClarityChanged 非本设备,已忽略', `${deviceId} != ${devId}`);
239
- return;
240
- }
241
- handler({
242
- deviceId,
243
- clarity
244
- });
245
- };
246
- try {
247
- ipc.onClarityChanged(listener);
248
- } catch (error) {
249
- console.warn('res===onClarityChanged fail', error);
250
- return () => undefined;
251
- }
252
- return () => {
253
- offClarityChanged(listener);
254
- };
255
145
  }
@@ -231,7 +231,7 @@ export function RecordVideo(props) {
231
231
  };
232
232
  const handRecordVideo = async () => {
233
233
  var _props$event, _props$event2;
234
- (_props$event = props.event) !== null && _props$event !== void 0 ? _props$event : event;
234
+ const ev = (_props$event = props.event) !== null && _props$event !== void 0 ? _props$event : event;
235
235
  ((_props$event2 = props.event) !== null && _props$event2 !== void 0 ? _props$event2 : event).emit(widgetClick, {
236
236
  widgetId: widgetLabs.RECORD_VIDEO
237
237
  });
@@ -256,6 +256,10 @@ export function RecordVideo(props) {
256
256
  }
257
257
  try {
258
258
  const recordInfo = await setRecording(target);
259
+ if (recordInfo === false) {
260
+ ev.emit(changeIgnoreHideStopPreview, false);
261
+ return false;
262
+ }
259
263
  if (target) {
260
264
  setRecordingDisabled(true);
261
265
  setState({
@@ -0,0 +1,58 @@
1
+ import { act, renderHook } from '@testing-library/react-hooks/dom';
2
+ import { atom } from 'jotai';
3
+ import { RecordVideo } from './recordVideo';
4
+ import { PlayState } from '../../interface';
5
+ jest.mock('@ray-js/ray', () => ({
6
+ View: 'div',
7
+ Text: 'span',
8
+ Image: 'img',
9
+ getSystemInfoSync: () => ({
10
+ platform: 'ios',
11
+ system: 'iOS 18'
12
+ })
13
+ }));
14
+ jest.mock('@ray-js/ray-ipc-utils', () => ({
15
+ goToIpcPageNativeRoute: jest.fn()
16
+ }));
17
+ jest.mock('@ray-js/ray-ipc-utils/lib/interface', () => ({}));
18
+ jest.mock('../../i18n', () => ({
19
+ __esModule: true,
20
+ default: {
21
+ getLang: key => key
22
+ }
23
+ }));
24
+ jest.mock('./recordVideo.less', () => ({}));
25
+ it('keeps the record control idle when starting is declined', async () => {
26
+ const addContent = jest.fn();
27
+ const setRecordingDisabled = jest.fn();
28
+ const setRecording = jest.fn().mockResolvedValue(false);
29
+ const toast = jest.fn();
30
+ const props = {
31
+ recording: atom(false),
32
+ brandColor: atom('#000000'),
33
+ screenType: atom('vertical'),
34
+ recordingDisabled: atom(false),
35
+ playState: atom(PlayState.PLAYING),
36
+ setRecording,
37
+ setRecordingDisabled,
38
+ addContent,
39
+ deleteContent: jest.fn(),
40
+ toast,
41
+ devId: 'test-device',
42
+ event: {
43
+ emit: jest.fn()
44
+ }
45
+ };
46
+ const {
47
+ result,
48
+ unmount
49
+ } = renderHook(() => RecordVideo(props));
50
+ await act(async () => {
51
+ await result.current.props.onClick();
52
+ });
53
+ expect(setRecording).toHaveBeenCalledWith(true);
54
+ expect(addContent).not.toHaveBeenCalled();
55
+ expect(setRecordingDisabled).not.toHaveBeenCalled();
56
+ expect(toast).not.toHaveBeenCalled();
57
+ unmount();
58
+ });
@@ -11,6 +11,7 @@ import { useStore } from '../../ctx/store';
11
11
  import './resolution.less';
12
12
  export const Resolution = props => {
13
13
  const {
14
+ IPCPlayerContext,
14
15
  setResolution,
15
16
  addContent,
16
17
  hasContent,
@@ -1,5 +1,5 @@
1
1
  import React, { useContext, useRef } from 'react';
2
- import { View, Image, Text, showModal, openAppSystemSettingPage, getSystemInfoSync } from '@ray-js/ray';
2
+ import { View, Image, Text, getSystemInfoSync } from '@ray-js/ray';
3
3
  import { useSetState, useUpdateEffect, useMemoizedFn } from 'ahooks';
4
4
  import clsx from 'clsx';
5
5
  import { goToIpcPageNativeRoute } from '@ray-js/ray-ipc-utils';
@@ -7,6 +7,7 @@ import Strings from '../../i18n';
7
7
  import { useStore } from '../../ctx/store';
8
8
  import { UIEventContext } from '../../ui/context';
9
9
  import { pauseTimeToHideAllComponent, changeIgnoreHideStopPreview, widgetLabs, widgetClick } from '../../ui/constant';
10
+ import { ensureAlbumPermission } from '../../utils/authorize/album';
10
11
  import './screenshot.less';
11
12
  const CLOSE_TIME = 5000;
12
13
  export function Screenshot(props) {
@@ -101,9 +102,9 @@ export function Screenshot(props) {
101
102
  });
102
103
  timeToCloseToast();
103
104
  };
104
- const handClick = useMemoizedFn(() => {
105
+ const handClick = useMemoizedFn(async () => {
105
106
  var _props$event, _props$event2;
106
- (_props$event = props.event) !== null && _props$event !== void 0 ? _props$event : event;
107
+ const ev = (_props$event = props.event) !== null && _props$event !== void 0 ? _props$event : event;
107
108
  ((_props$event2 = props.event) !== null && _props$event2 !== void 0 ? _props$event2 : event).emit(widgetClick, {
108
109
  widgetId: widgetLabs.SCREENSHOT
109
110
  });
@@ -118,76 +119,24 @@ export function Screenshot(props) {
118
119
  props.event ? props.event.emit(changeIgnoreHideStopPreview, true) : event.emit(changeIgnoreHideStopPreview, true);
119
120
  }
120
121
  event.emit(pauseTimeToHideAllComponent);
121
- ty.authorizeStatus({
122
- // 相册写入权限
123
- scope: 'scope.writePhotosAlbum',
124
- success: () => {
125
- props.event ? props.event.emit(changeIgnoreHideStopPreview, false) : event.emit(changeIgnoreHideStopPreview, false);
126
- IPCPlayerContext.snapshot({
127
- saveToAlbum,
128
- // 保存到 IPC 相册
129
- success: res => {
130
- console.log(res, 'res');
131
- props.event ? props.event.emit(changeIgnoreHideStopPreview, false) : event.emit(changeIgnoreHideStopPreview, false);
132
- setState({
133
- showShot: true,
134
- shotUrl: res.tempImagePath
135
- });
136
- },
137
- fail: err => {
138
- props.event ? props.event.emit(changeIgnoreHideStopPreview, false) : event.emit(changeIgnoreHideStopPreview, false);
139
- console.log(err, 'err');
140
- const errObj = err.innerError || err || {};
141
- const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_screenshot_error_tip');
142
- toast({
143
- title: errMsg
144
- });
145
- }
122
+ const granted = await ensureAlbumPermission();
123
+ ev.emit(changeIgnoreHideStopPreview, false);
124
+ if (!granted) return;
125
+ IPCPlayerContext.snapshot({
126
+ saveToAlbum,
127
+ success: res => {
128
+ ev.emit(changeIgnoreHideStopPreview, false);
129
+ setState({
130
+ showShot: true,
131
+ shotUrl: res.tempImagePath
146
132
  });
147
133
  },
148
- fail: () => {
149
- ty.authorize({
150
- scope: 'scope.writePhotosAlbum',
151
- success: () => {
152
- IPCPlayerContext.snapshot({
153
- saveToAlbum,
154
- // 保存到 IPC 相册
155
- success: res => {
156
- console.log(res, 'res');
157
- setState({
158
- showShot: true,
159
- shotUrl: res.tempImagePath
160
- });
161
- },
162
- fail: err => {
163
- console.log(err, 'err');
164
- const errObj = err.innerError || err || {};
165
- const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_screenshot_error_tip');
166
- toast({
167
- title: errMsg
168
- });
169
- }
170
- });
171
- },
172
- fail: () => {
173
- showModal({
174
- title: '',
175
- content: Strings.getLang('ipc_player_no_album_permission'),
176
- cancelText: Strings.getLang('ipc_player_authorize_cancel_text'),
177
- confirmText: Strings.getLang('ipc_player_authorize_confirm_text'),
178
- isShowGlobal: true,
179
- success: res => {
180
- if (res.confirm) {
181
- openAppSystemSettingPage({
182
- scope: 'App-Settings',
183
- success: () => {
184
- console.log('跳转成功');
185
- }
186
- });
187
- }
188
- }
189
- });
190
- }
134
+ fail: err => {
135
+ ev.emit(changeIgnoreHideStopPreview, false);
136
+ const errObj = err.innerError || err || {};
137
+ const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_screenshot_error_tip');
138
+ toast({
139
+ title: errMsg
191
140
  });
192
141
  }
193
142
  });
@@ -2,11 +2,9 @@ import React, { useEffect, useRef, useState } from 'react';
2
2
  import { View, Text, usePageEvent } from '@ray-js/ray';
3
3
  import clsx from 'clsx';
4
4
  import { getVideoBitrateKbps, requestWifiSignal } from '@ray-js/ray-ipc-utils';
5
- import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
6
5
  import { PlayState } from '../../interface';
7
6
  import './videoBitKBP.less';
8
7
  import { useStore } from '../../ctx/store';
9
- import Strings from '../../i18n';
10
8
  export const VideoBitKBP = props => {
11
9
  const {
12
10
  devId,
@@ -18,9 +16,7 @@ export const VideoBitKBP = props => {
18
16
  const [bitKBP, setBitKBP] = useState('');
19
17
  const [signalStrength, setSignalStrength] = useState(null);
20
18
  const store = useStore({
21
- playState,
22
- resolution: props.resolution,
23
- autoClarity: props.autoClarity
19
+ playState
24
20
  });
25
21
  const timerRef = useRef();
26
22
  useEffect(() => {
@@ -56,34 +52,12 @@ export const VideoBitKBP = props => {
56
52
  }
57
53
  }
58
54
  };
59
- const isPlaying = store.playState === PlayState.PLAYING;
60
- const hasKbps = isPlaying && !hideKbsMenu && bitKBP !== '' && bitKBP !== '0';
61
- const hasSignal = isPlaying && !hideSignalMenu && signalStrength !== null;
62
- const activeClarity = store.resolution === ClarityType.AUTO ? store.autoClarity : null;
63
- const hasClarity = Boolean(activeClarity);
64
- const bitrateLabel = [activeClarity ? (clarity => {
65
- switch (clarity) {
66
- case ClarityType.SS:
67
- return Strings.getLang('ipc_player_resolution_SS');
68
- case ClarityType.SD:
69
- return Strings.getLang('ipc_player_resolution_SD');
70
- case ClarityType.HD:
71
- return Strings.getLang('ipc_player_resolution_HD');
72
- case ClarityType.UD:
73
- return Strings.getLang('ipc_player_resolution_UD');
74
- case ClarityType.SSP:
75
- return Strings.getLang('ipc_player_resolution_SSP');
76
- case ClarityType.AUTO:
77
- return Strings.getLang('ipc_player_resolution_AUTO');
78
- case ClarityType.AUDIO:
79
- return Strings.getLang('ipc_player_resolution_AUDIO');
80
- default:
81
- return clarity;
82
- }
83
- })(activeClarity) : '', hasKbps ? `${bitKBP} KB/S` : ''].filter(Boolean).join(' ');
84
- if (!hasKbps && !hasSignal && !hasClarity) {
55
+ const hasKbps = !hideKbsMenu && bitKBP !== '' && bitKBP !== '0';
56
+ const hasSignal = !hideSignalMenu && signalStrength !== null;
57
+ if (!hasKbps && !hasSignal || store.playState !== PlayState.PLAYING) {
85
58
  return null;
86
59
  }
60
+ if (hideKbsMenu && hideSignalMenu) return null;
87
61
  return /*#__PURE__*/React.createElement(View, {
88
62
  className: clsx({
89
63
  'ipc-player-plugin-videoBitKBP-container': true,
@@ -91,21 +65,17 @@ export const VideoBitKBP = props => {
91
65
  })
92
66
  }, /*#__PURE__*/React.createElement(View, {
93
67
  className: "ipc-player-plugin-videoBitKBP"
94
- }, /*#__PURE__*/React.createElement(View, {
95
- className: "ipc-player-plugin-videoBitKBP-content"
96
68
  }, hasSignal && /*#__PURE__*/React.createElement(View, {
97
69
  className: "ipc-player-plugin-videoBitKBP-signal"
98
70
  }, /*#__PURE__*/React.createElement(Text, {
99
71
  className: clsx('icon-panel', 'icon-panel-wi-Fi', 'ipc-player-plugin-videoBitKBP-signal-icon')
100
- }), /*#__PURE__*/React.createElement(Text, {
101
- className: "ipc-player-plugin-videoBitKBP-signal-text"
102
- }, signalStrength), /*#__PURE__*/React.createElement(Text, {
103
- className: "ipc-player-plugin-videoBitKBP-signal-text ipc-player-plugin-videoBitKBP-unit-percent"
104
- }, signalStrength > 0 ? '%' : 'dBm')), hasSignal && (hasKbps || hasClarity) && /*#__PURE__*/React.createElement(View, {
72
+ }), /*#__PURE__*/React.createElement(Text, null, signalStrength), /*#__PURE__*/React.createElement(Text, {
73
+ className: "ipc-player-plugin-videoBitKBP-unit-percent"
74
+ }, signalStrength > 0 ? '%' : 'dBm')), hasSignal && hasKbps && /*#__PURE__*/React.createElement(View, {
105
75
  className: "ipc-player-plugin-videoBitKBP-divider"
106
- }), (hasKbps || hasClarity) && /*#__PURE__*/React.createElement(View, {
76
+ }), hasKbps && /*#__PURE__*/React.createElement(View, {
107
77
  className: "ipc-player-plugin-videoBitKBP-kbps"
108
- }, /*#__PURE__*/React.createElement(Text, {
109
- className: "ipc-player-plugin-videoBitKBP-kbps-text"
110
- }, bitrateLabel)))));
78
+ }, /*#__PURE__*/React.createElement(Text, null, bitKBP), /*#__PURE__*/React.createElement(Text, {
79
+ className: "ipc-player-plugin-videoBitKBP-unit-kbs"
80
+ }, "KB/S"))));
111
81
  };
@@ -18,35 +18,26 @@
18
18
  background-color: rgba(255, 255, 255, 0.2);
19
19
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
20
20
  }
21
- .ipc-player-plugin-videoBitKBP-content {
21
+ .ipc-player-plugin-videoBitKBP-signal {
22
22
  display: flex;
23
- align-items: baseline;
24
- }
25
- .ipc-player-plugin-videoBitKBP-signal,
26
- .ipc-player-plugin-videoBitKBP-kbps {
27
- display: flex;
28
- align-items: baseline;
29
- height: calc(16px * var(--ipc-player-size-scale, 1));
30
- line-height: calc(16px * var(--ipc-player-size-scale, 1));
23
+ align-items: center;
31
24
  }
32
25
  .ipc-player-plugin-videoBitKBP-signal-icon {
33
- align-self: center;
34
26
  font-size: calc(14px * var(--ipc-player-size-scale, 1));
35
27
  margin-right: calc(4px * var(--ipc-player-size-scale, 1));
36
28
  }
37
- .ipc-player-plugin-videoBitKBP-signal-text,
38
- .ipc-player-plugin-videoBitKBP-kbps-text {
39
- line-height: calc(16px * var(--ipc-player-size-scale, 1));
40
- }
41
29
  .ipc-player-plugin-videoBitKBP-divider {
42
- align-self: center;
43
30
  width: 1px;
44
31
  height: calc(10px * var(--ipc-player-size-scale, 1));
45
32
  background-color: var(--iconColor);
46
33
  margin: 0 calc(4px * var(--ipc-player-size-scale, 1));
47
34
  }
48
- .ipc-player-plugin-videoBitKBP-kbps-text {
49
- white-space: nowrap;
35
+ .ipc-player-plugin-videoBitKBP-kbps {
36
+ display: flex;
37
+ align-items: center;
38
+ }
39
+ .ipc-player-plugin-videoBitKBP-unit-kbs {
40
+ margin-left: calc(4px * var(--ipc-player-size-scale, 1));
50
41
  }
51
42
  .ipc-player-plugin-videoBitKBP-unit-percent {
52
43
  margin-left: calc(2px * var(--ipc-player-size-scale, 1));
@@ -126,7 +126,10 @@ export const isSwitchChannelSupported = () => {
126
126
  const supported = typeof ((_ty = ty) === null || _ty === void 0 || (_ty = _ty.ipc) === null || _ty === void 0 ? void 0 : _ty.switchChannel) === 'function';
127
127
  if (!supported && !switchChannelMissingLogged) {
128
128
  switchChannelMissingLogged = true;
129
- console.warn('[zoomTurntable] 宿主不支持 ty.ipc.switchChannel,焦距转盘入口不展示');
129
+ // 只能用 log:本判定会在 render 期被调用,而 IDE 宿主下 render 期的 console.warn
130
+ // 会打坏 Ray 运行时,整个面板崩在 areHookInputsEqual / TDZ —— 且症状伪装成
131
+ // 「hook 顺序错位」(报 change in the order of Hooks),极难归因,勿改回 warn
132
+ console.log('[zoomTurntable] 宿主不支持 ty.ipc.switchChannel,焦距转盘入口不展示');
130
133
  dumpChannelApis();
131
134
  }
132
135
  return supported;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.54",
3
+ "version": "0.0.55-beta.0",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -37,7 +37,7 @@
37
37
  "dependencies": {
38
38
  "@ray-js/direction-control": "^0.0.8",
39
39
  "@ray-js/ipc-ptz-zoom": "^0.0.3",
40
- "@ray-js/ray-ipc-player": "^2.1.4",
40
+ "@ray-js/ray-ipc-player": "^2.1.3",
41
41
  "@ray-js/ray-ipc-utils": "^1.1.16",
42
42
  "@ray-js/svg": "0.2.0",
43
43
  "clsx": "^1.2.1",
@@ -1,150 +0,0 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import { act, renderHook } from '@testing-library/react-hooks';
3
- import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
4
- import { createUseCtx } from './ctx';
5
- import { useStore } from './store';
6
- import { PlayState } from '../interface';
7
- import { getCachedAutoClarity, setCachedAutoClarity, subscribeClarityChanged } from '../utils/ttt';
8
- jest.mock('@ray-js/ray', () => ({}));
9
- jest.mock('@ray-js/ray-ipc-utils/lib/interface', () => ({
10
- ClarityType: {
11
- SS: 'SS',
12
- SD: 'SD',
13
- HD: 'HD',
14
- UD: 'UD',
15
- SSP: 'SSP',
16
- AUTO: 'AUTO',
17
- AUDIO: 'AUDIO'
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: () => true,
37
- setCachedAutoClarity: jest.fn(),
38
- subscribeClarityChanged: jest.fn(() => () => undefined)
39
- }));
40
- const cameraState = resolution => ({
41
- resolution,
42
- resolutionList: [ClarityType.HD, ClarityType.SD],
43
- mute: true,
44
- intercomMode: 'TwoWay',
45
- isIntercomSupported: false,
46
- maxZoomSettings: 6
47
- });
48
- describe('cached auto clarity restoration', () => {
49
- beforeEach(() => {
50
- jest.clearAllMocks();
51
- });
52
- const mountContext = resolution => {
53
- const setClarity = jest.fn();
54
- const getMemoryState = jest.fn().mockResolvedValue(cameraState(resolution));
55
- const useCtx = createUseCtx({
56
- createPlayContext: () => ({
57
- setClarity
58
- }),
59
- getMemoryState,
60
- setResolutionMemoryState: jest.fn(),
61
- setMuteMemoryState: jest.fn(),
62
- authorizeStatus: jest.fn(),
63
- toast: jest.fn()
64
- });
65
- const hook = renderHook(() => {
66
- const ctx = useCtx({
67
- devId: 'camera-1'
68
- });
69
- const state = useStore({
70
- resolution: ctx.resolution,
71
- autoClarity: ctx.autoClarity
72
- });
73
- return _objectSpread(_objectSpread({}, ctx), {}, {
74
- state
75
- });
76
- });
77
- return _objectSpread(_objectSpread({}, hook), {}, {
78
- setClarity
79
- });
80
- };
81
- it('shows last listener value on reopening AUTO and refreshes it after preview', async () => {
82
- getCachedAutoClarity.mockReturnValue(ClarityType.HD);
83
- const {
84
- result,
85
- setClarity,
86
- unmount
87
- } = mountContext(ClarityType.AUTO);
88
- await act(async () => Promise.resolve());
89
- expect(result.current.state).toEqual({
90
- resolution: ClarityType.AUTO,
91
- autoClarity: ClarityType.HD
92
- });
93
- act(() => result.current.setPlayState(PlayState.PLAYING));
94
- await act(async () => Promise.resolve());
95
- expect(setClarity).toHaveBeenCalledTimes(1);
96
- expect(setClarity).toHaveBeenCalledWith(expect.objectContaining({
97
- clarity: 'auto'
98
- }));
99
- const onReport = subscribeClarityChanged.mock.calls[0][1];
100
- act(() => onReport({
101
- deviceId: 'camera-1',
102
- clarity: ClarityType.SD
103
- }));
104
- expect(result.current.state.autoClarity).toBe(ClarityType.SD);
105
- expect(setCachedAutoClarity).toHaveBeenCalledWith('camera-1', ClarityType.SD);
106
- unmount();
107
- });
108
- it('does not restore cached actual clarity in manual mode', async () => {
109
- getCachedAutoClarity.mockReturnValue(ClarityType.HD);
110
- const {
111
- result,
112
- unmount
113
- } = mountContext(ClarityType.SD);
114
- await act(async () => Promise.resolve());
115
- expect(result.current.state).toEqual({
116
- resolution: ClarityType.SD,
117
- autoClarity: null
118
- });
119
- expect(getCachedAutoClarity).not.toHaveBeenCalled();
120
- const onReport = subscribeClarityChanged.mock.calls[0][1];
121
- act(() => onReport({
122
- deviceId: 'camera-1',
123
- clarity: ClarityType.HD
124
- }));
125
- expect(result.current.state.autoClarity).toBeNull();
126
- expect(setCachedAutoClarity).not.toHaveBeenCalled();
127
- unmount();
128
- });
129
- it('requests a fresh report when reopening AUTO without an actual clarity cache', async () => {
130
- getCachedAutoClarity.mockReturnValue(null);
131
- const {
132
- result,
133
- setClarity,
134
- unmount
135
- } = mountContext(ClarityType.AUTO);
136
- await act(async () => Promise.resolve());
137
- expect(result.current.state.autoClarity).toBeNull();
138
- act(() => result.current.setPlayState(PlayState.PLAYING));
139
- expect(setClarity).toHaveBeenCalledWith(expect.objectContaining({
140
- clarity: 'auto'
141
- }));
142
- const onReport = subscribeClarityChanged.mock.calls[0][1];
143
- act(() => onReport({
144
- deviceId: 'camera-1',
145
- clarity: ClarityType.HD
146
- }));
147
- expect(result.current.state.autoClarity).toBe(ClarityType.HD);
148
- unmount();
149
- });
150
- });
@@ -1 +0,0 @@
1
- export declare function useOfflineShownNotification(deviceId: string, deviceOnline: boolean): void;