@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 +8 -14
- package/lib/ctx/resolution.d.ts +1 -1
- package/lib/ctx/resolution.js +2 -8
- package/lib/interface.d.ts +2 -0
- package/lib/ui/ui.d.ts +2 -0
- package/lib/ui/ui.js +4 -3
- package/package.json +1 -1
- package/lib/ctx/useAutoClarityConfig.d.ts +0 -8
- package/lib/ctx/useAutoClarityConfig.js +0 -40
- package/lib/utils/productAbility.d.ts +0 -6
- package/lib/utils/productAbility.js +0 -20
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
|
|
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
|
-
//
|
|
182
|
+
// 普通档位或宿主配置变化时,决定是否追加 Auto。
|
|
188
183
|
const list = (memoryState === null || memoryState === void 0 ? void 0 : memoryState.devId) === devId ? memoryState.data.resolutionList : [];
|
|
189
|
-
if (
|
|
184
|
+
if (autoClarityDisabled === null) {
|
|
190
185
|
setResolutionList(list.filter(clarity => clarity !== ClarityType.AUTO));
|
|
191
186
|
return;
|
|
192
187
|
}
|
|
193
|
-
setResolutionList(withAutoClarity(list,
|
|
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 (
|
|
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 (!
|
|
196
|
+
} else if (!autoClarityDisabled) {
|
|
203
197
|
restoreResolution(memoryState.data.resolution, list, _setResolution);
|
|
204
198
|
}
|
|
205
|
-
}, [devId, memoryState, currentResolution,
|
|
199
|
+
}, [devId, memoryState, currentResolution, autoClarityDisabled]);
|
|
206
200
|
useEffect(() => {
|
|
207
201
|
refreshAfterPlayback(_playState, currentResolution);
|
|
208
202
|
}, [devId, _playState, currentResolution]);
|
package/lib/ctx/resolution.d.ts
CHANGED
|
@@ -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[],
|
|
6
|
+
export declare const withAutoClarity: (list?: ClarityType[], autoClarityDisabled?: boolean) => ClarityType[];
|
|
7
7
|
export declare const normalizeResolution: (resolution: ClarityType, list: ClarityType[]) => ClarityType;
|
|
8
8
|
export {};
|
package/lib/ctx/resolution.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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) => {
|
package/lib/interface.d.ts
CHANGED
|
@@ -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
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,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,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
|
-
});
|