@ray-js/ipc-player-integration 0.0.58-beta.1 → 0.0.58-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/ctx/ctx.js CHANGED
@@ -15,7 +15,6 @@ import { getEventInstance } from './event';
15
15
  import { isMultiCameraTileSupported, useMultiCameraCtx } from './multiCameraCtx';
16
16
  import { toNativeClarity, withAutoClarity } from './resolution';
17
17
  import { useAutoClarity } from './useAutoClarity';
18
- import { useAutoClarityConfig } from './useAutoClarityConfig';
19
18
  const SAVE_TO_ALBUM = 1;
20
19
  export const createUseCtx = _ref => {
21
20
  let {
@@ -34,6 +33,7 @@ export const createUseCtx = _ref => {
34
33
  return _ref2 => {
35
34
  let {
36
35
  devId,
36
+ autoClarityDisabled,
37
37
  initTopLeftContent,
38
38
  initTopRightContent,
39
39
  initBottomLeftContent,
@@ -80,11 +80,6 @@ export const createUseCtx = _ref => {
80
80
  const [resolutionList, setResolutionList] = useAtom([]);
81
81
  const [memoryState, setMemoryState] = useState(null);
82
82
  const autoFallbackPendingRef = useRef(null);
83
- const {
84
- is4G,
85
- enableAutoClarity,
86
- ready: autoConfigReady
87
- } = useAutoClarityConfig(devId);
88
83
  // 自动模式下宿主上报的实际清晰度,供横竖屏码率区域共用
89
84
  const [autoClarity] = useAtom(null);
90
85
 
@@ -141,7 +136,7 @@ export const createUseCtx = _ref => {
141
136
  devId,
142
137
  data: res
143
138
  });
144
- // 历史 Auto 等 4G 和面板云配置确定后再恢复,避免先显示 Auto 再回退。
139
+ // 历史 Auto 等宿主配置确定后再恢复,避免先显示 Auto 再回退。
145
140
  if (res.resolution !== ClarityType.AUTO) {
146
141
  restoreResolution(res.resolution, res.resolutionList, _setResolution);
147
142
  }
@@ -184,25 +179,24 @@ export const createUseCtx = _ref => {
184
179
  };
185
180
  }, [devId, _playState]);
186
181
  useEffect(() => {
187
- // 普通档位或配置变化时,按 432 面板相同的条件决定是否追加 Auto。
182
+ // 普通档位或宿主配置变化时,决定是否追加 Auto。
188
183
  const list = (memoryState === null || memoryState === void 0 ? void 0 : memoryState.devId) === devId ? memoryState.data.resolutionList : [];
189
- if (!autoConfigReady) {
184
+ if (autoClarityDisabled === null) {
190
185
  setResolutionList(list.filter(clarity => clarity !== ClarityType.AUTO));
191
186
  return;
192
187
  }
193
- setResolutionList(withAutoClarity(list, is4G, enableAutoClarity));
194
- const autoDisabled = is4G && enableAutoClarity === false;
188
+ setResolutionList(withAutoClarity(list, autoClarityDisabled));
195
189
  if ((memoryState === null || memoryState === void 0 ? void 0 : memoryState.devId) !== devId || memoryState.data.resolution !== ClarityType.AUTO) return;
196
- if (autoDisabled && autoFallbackPendingRef.current !== devId) {
190
+ if (autoClarityDisabled && autoFallbackPendingRef.current !== devId) {
197
191
  autoFallbackPendingRef.current = devId;
198
192
  _setResolution(memoryState.data.defaultResolution).catch(error => {
199
193
  autoFallbackPendingRef.current = null;
200
194
  console.warn('恢复默认清晰度失败:', error);
201
195
  });
202
- } else if (!autoDisabled) {
196
+ } else if (!autoClarityDisabled) {
203
197
  restoreResolution(memoryState.data.resolution, list, _setResolution);
204
198
  }
205
- }, [devId, memoryState, currentResolution, is4G, enableAutoClarity, autoConfigReady]);
199
+ }, [devId, memoryState, currentResolution, autoClarityDisabled]);
206
200
  useEffect(() => {
207
201
  refreshAfterPlayback(_playState, currentResolution);
208
202
  }, [devId, _playState, currentResolution]);
@@ -3,6 +3,6 @@ type NativeClarity = Parameters<IpcContext['setClarity']>[0]['clarity'];
3
3
  export declare const toNativeClarity: (clarity: ClarityType) => NativeClarity;
4
4
  /** 宿主支持自动清晰度,且返回至少两个档位时才展示 AUTO。 */
5
5
  export declare const canShowAutoClarity: (list?: ClarityType[]) => boolean;
6
- export declare const withAutoClarity: (list?: ClarityType[], is4G?: boolean, enableAutoClarity?: boolean) => ClarityType[];
6
+ export declare const withAutoClarity: (list?: ClarityType[], autoClarityDisabled?: boolean) => ClarityType[];
7
7
  export declare const normalizeResolution: (resolution: ClarityType, list: ClarityType[]) => ClarityType;
8
8
  export {};
@@ -21,15 +21,9 @@ export const canShowAutoClarity = function () {
21
21
  };
22
22
  export const withAutoClarity = function () {
23
23
  let list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
24
- let is4G = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
25
- let enableAutoClarity = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
24
+ let autoClarityDisabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
26
25
  const withoutAuto = list.filter(clarity => clarity !== ClarityType.AUTO);
27
- let showAuto = canShowAutoClarity(withoutAuto);
28
- // 仅 4G 能力开启且面板云配置明确关闭时隐藏 Auto。
29
- if (is4G && enableAutoClarity === false) {
30
- showAuto = false;
31
- }
32
- console.log('res===showAuto', is4G, enableAutoClarity, showAuto);
26
+ const showAuto = !autoClarityDisabled && canShowAutoClarity(withoutAuto);
33
27
  return showAuto ? [...withoutAuto, ClarityType.AUTO] : withoutAuto;
34
28
  };
35
29
  export const normalizeResolution = (resolution, list) => {
@@ -41,6 +41,8 @@ export type EventInstance = {
41
41
  };
42
42
  export type UseCtx = (options: {
43
43
  devId: string;
44
+ /** 宿主决定是否禁用 Auto;null 表示本次配置查询尚未完成。 */
45
+ autoClarityDisabled?: boolean | null;
44
46
  initTopLeftContent?: ComponentConfig[];
45
47
  initTopRightContent?: ComponentConfig[];
46
48
  initBottomLeftContent?: ComponentConfig[];
package/lib/ui/ui.d.ts CHANGED
@@ -15,6 +15,8 @@ type CSSVariable = {
15
15
  };
16
16
  type Props = {
17
17
  devId: string;
18
+ /** 未提供 instance 时,传给播放器内部的 useCtx。null 表示配置查询中。 */
19
+ autoClarityDisabled?: boolean | null;
18
20
  isShare?: boolean;
19
21
  ignoreHideStopPreview?: boolean;
20
22
  instance?: CtxInstance;
package/lib/ui/ui.js CHANGED
@@ -61,11 +61,12 @@ const StandaloneAutoClarity = _ref2 => {
61
61
  instance: instance
62
62
  }));
63
63
  };
64
- function getCtxInstance(instance, devId) {
64
+ function getCtxInstance(instance, devId, autoClarityDisabled) {
65
65
  if (instance) return instance;
66
66
  // eslint-disable-next-line react-hooks/rules-of-hooks
67
67
  return useCtx({
68
- devId
68
+ devId,
69
+ autoClarityDisabled
69
70
  });
70
71
  }
71
72
 
@@ -128,7 +129,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
128
129
  const {
129
130
  event
130
131
  } = useContext(UIEventContext);
131
- const instance = getCtxInstance(props.instance, devId);
132
+ const instance = getCtxInstance(props.instance, devId, props.autoClarityDisabled);
132
133
  const {
133
134
  setPlayState,
134
135
  setScreenType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.58-beta.1",
3
+ "version": "0.0.58-beta.2",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -1,8 +0,0 @@
1
- type AutoClarityConfig = {
2
- is4G: boolean;
3
- enableAutoClarity: boolean;
4
- ready: boolean;
5
- };
6
- /** 与 432 面板一致:先取得 4G 能力和面板云开关,再由清晰度列表决定是否加入 Auto。 */
7
- export declare const useAutoClarityConfig: (devId: string) => AutoClarityConfig;
8
- export {};
@@ -1,40 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { usePanelConfig } from '@ray-js/panel-sdk';
3
- import { getAbilityCodeIsOpened } from '../utils/productAbility';
4
- const TRAFFIC_CAMERA_ABILITY = 'tyabips49q';
5
- const AUTO_CLARITY_CONFIG = 'tyabij5ce4';
6
- /** 与 432 面板一致:先取得 4G 能力和面板云开关,再由清晰度列表决定是否加入 Auto。 */
7
- export const useAutoClarityConfig = devId => {
8
- var _panelConfig$fun;
9
- const panelConfig = usePanelConfig();
10
- const [trafficAbility, setTrafficAbility] = useState(null);
11
- useEffect(() => {
12
- if (!devId) return undefined;
13
- let active = true;
14
- getAbilityCodeIsOpened(TRAFFIC_CAMERA_ABILITY, devId).then(data => {
15
- if (!active) return;
16
- setTrafficAbility({
17
- devId,
18
- is4G: (data === null || data === void 0 ? void 0 : data.isOpen) === true
19
- });
20
- }).catch(error => {
21
- console.warn('获取 4G 能力失败:', error);
22
- if (active) setTrafficAbility({
23
- devId,
24
- is4G: false
25
- });
26
- });
27
- return () => {
28
- active = false;
29
- };
30
- }, [devId]);
31
- const configValue = (_panelConfig$fun = panelConfig.fun) === null || _panelConfig$fun === void 0 ? void 0 : _panelConfig$fun[AUTO_CLARITY_CONFIG];
32
- const abilityReady = (trafficAbility === null || trafficAbility === void 0 ? void 0 : trafficAbility.devId) === devId;
33
- const is4G = abilityReady && trafficAbility.is4G;
34
- // 非 4G 设备只需等待能力查询;4G 设备还需等待面板云配置初始化。
35
- return {
36
- is4G,
37
- enableAutoClarity: configValue !== false && configValue !== 'false',
38
- ready: abilityReady && (!is4G || panelConfig.initialized)
39
- };
40
- };
@@ -1,6 +0,0 @@
1
- type AbilityResult = {
2
- isOpen: boolean;
3
- };
4
- /** 按 PID 维度查询设备的高级能力。 */
5
- export declare const getAbilityCodeIsOpened: (abilityCode: string, deviceId: string) => Promise<AbilityResult>;
6
- export {};
@@ -1,20 +0,0 @@
1
- import { apiRequestByAtop } from '@ray-js/ray';
2
- /** 按 PID 维度查询设备的高级能力。 */
3
- export const getAbilityCodeIsOpened = (abilityCode, deviceId) => new Promise((resolve, reject) => {
4
- apiRequestByAtop({
5
- api: 'm.life.app.device.product.ability',
6
- postData: {
7
- abilityCode,
8
- deviceId
9
- },
10
- version: '1.0',
11
- success: result => {
12
- try {
13
- resolve(typeof result === 'string' ? JSON.parse(result) : result);
14
- } catch (error) {
15
- reject(error);
16
- }
17
- },
18
- fail: reject
19
- });
20
- });