@ray-js/ipc-player-integration 0.0.35-beta.26 → 0.0.35-beta.28
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 +0 -1
- package/lib/ui/bottomLeftContent.d.ts +6 -2
- package/lib/ui/bottomLeftContent.js +20 -6
- package/lib/ui/bottomRightContent.d.ts +6 -2
- package/lib/ui/bottomRightContent.js +13 -5
- package/lib/ui/ui.js +9 -5
- package/lib/utils/ttt.d.ts +3 -5
- package/lib/utils/ttt.js +51 -46
- package/lib/widgets/trialBadge/index.js +0 -1
- package/lib/widgets/tryExperience/tryExperience.js +1 -1
- package/package.json +1 -1
package/lib/ctx/ctx.js
CHANGED
|
@@ -3,8 +3,12 @@ import { UseCtx } from '../interface';
|
|
|
3
3
|
type Props = {
|
|
4
4
|
ctx: ReturnType<UseCtx>;
|
|
5
5
|
children: React.ReactNode;
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* 右下角组件占据的宽度,左下角通过该值约束自身可视宽度避免与右下角重叠。
|
|
8
|
+
* - number: 视为 px
|
|
9
|
+
* - string: 视为合法的 CSS 长度(例如 "35%"),用于横屏按百分比预留
|
|
10
|
+
*/
|
|
11
|
+
reservedRight?: number | string;
|
|
8
12
|
canOpenSettings?: boolean;
|
|
9
13
|
};
|
|
10
14
|
declare const BottomLeftContent: ({ ctx, children, reservedRight, canOpenSettings }: Props) => React.JSX.Element;
|
|
@@ -6,8 +6,17 @@ import clsx from 'clsx';
|
|
|
6
6
|
import { useStore } from '../ctx/store';
|
|
7
7
|
import { useComponentHideState } from './hooks';
|
|
8
8
|
import { TrialBadge, useTrialBadge } from '../widgets/trialBadge';
|
|
9
|
-
/**
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* 右侧透明渐变 mask,用于提示横向可滑动。
|
|
11
|
+
* - 竖屏容器窄,48px 渐变区已足够明显
|
|
12
|
+
* - 横屏容器约占 65% 宽度(≥ 500px),且单个按钮就有 ~72px,
|
|
13
|
+
* 渐变区需大于一个按钮宽度才能让最右侧按钮"半隐半现",
|
|
14
|
+
* 暗示后面还有内容
|
|
15
|
+
*/
|
|
16
|
+
const getFadeMask = screenType => {
|
|
17
|
+
const fadeWidth = screenType === 'vertical' ? 60 : 120;
|
|
18
|
+
return `linear-gradient(to right, #000 calc(100% - ${fadeWidth}px), transparent 100%)`;
|
|
19
|
+
};
|
|
11
20
|
const BottomLeftContent = _ref => {
|
|
12
21
|
let {
|
|
13
22
|
ctx,
|
|
@@ -58,12 +67,17 @@ const BottomLeftContent = _ref => {
|
|
|
58
67
|
} = useTrialBadge(ctx.event, ctx.devId, trialRemainingSec);
|
|
59
68
|
const paddingLeftPx = screenType === 'vertical' ? 0 : 25;
|
|
60
69
|
const showBadge = showSmartImageQuality && showTrialBadge && canOpenSettings && gRawData && !isLowPhone && buttonState === 1 && trialRemainingSec > 0;
|
|
70
|
+
const coverHeight = screenType === 'vertical' ? shouldHide ? 49 : 48 : shouldHide ? 84 : 83;
|
|
61
71
|
const containerHeight = screenType === 'vertical' ? 48 : 58;
|
|
72
|
+
|
|
73
|
+
// reservedRight 兼容 number(px)与 string(任意 CSS 长度,例如 "35%")
|
|
74
|
+
const rightCss = typeof reservedRight === 'number' ? `${reservedRight}px` : reservedRight;
|
|
75
|
+
const fadeMask = getFadeMask(screenType);
|
|
62
76
|
return /*#__PURE__*/React.createElement(CoverView, {
|
|
63
77
|
className: clsx('ipc-player-bottom-left-content-wrap'),
|
|
64
78
|
style: {
|
|
65
|
-
right:
|
|
66
|
-
height: showBadge ? `${
|
|
79
|
+
right: rightCss,
|
|
80
|
+
height: showBadge ? `${coverHeight + 30}px` : `${coverHeight}px`,
|
|
67
81
|
display: 'flex',
|
|
68
82
|
flexDirection: 'column',
|
|
69
83
|
justifyContent: 'center',
|
|
@@ -92,8 +106,8 @@ const BottomLeftContent = _ref => {
|
|
|
92
106
|
overflowY: 'hidden',
|
|
93
107
|
whiteSpace: 'nowrap',
|
|
94
108
|
WebkitOverflowScrolling: 'touch',
|
|
95
|
-
WebkitMaskImage:
|
|
96
|
-
maskImage:
|
|
109
|
+
WebkitMaskImage: fadeMask,
|
|
110
|
+
maskImage: fadeMask
|
|
97
111
|
},
|
|
98
112
|
className: clsx('ipc-player-bottom-left-content-container')
|
|
99
113
|
}, children));
|
|
@@ -3,8 +3,12 @@ import { UseCtx } from '../interface';
|
|
|
3
3
|
type Props = {
|
|
4
4
|
ctx: ReturnType<UseCtx>;
|
|
5
5
|
children: React.ReactNode;
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* 由 ui.tsx 计算得到的右下角组件宽度(与左下角的 reservedRight 保持一致)
|
|
8
|
+
* - number: 视为 px
|
|
9
|
+
* - string: 视为合法的 CSS width 值(例如 "35%" / "20vw")
|
|
10
|
+
*/
|
|
11
|
+
width?: number | string;
|
|
8
12
|
};
|
|
9
13
|
declare const BottomRightContent: ({ ctx, children, width }: Props) => React.JSX.Element;
|
|
10
14
|
export default BottomRightContent;
|
|
@@ -17,18 +17,26 @@ const BottomRightContent = _ref => {
|
|
|
17
17
|
playState: ctx.playState
|
|
18
18
|
});
|
|
19
19
|
const [shouldHide] = useComponentHideState();
|
|
20
|
-
const containerHeight = screenType === 'vertical' ? 48 :
|
|
20
|
+
const containerHeight = screenType === 'vertical' ? 48 : 58;
|
|
21
|
+
|
|
22
|
+
// 将 width 统一规范成 CSS 合法值。number → "${n}px",string → 原样透传。
|
|
23
|
+
// 0 / 空串视为「没有传宽度」,沿用默认布局(不设 width)。
|
|
24
|
+
const widthStyle = typeof width === 'number' && width > 0 ? {
|
|
25
|
+
width: `${width}px`,
|
|
26
|
+
boxSizing: 'border-box'
|
|
27
|
+
} : typeof width === 'string' && width ? {
|
|
28
|
+
width,
|
|
29
|
+
boxSizing: 'border-box'
|
|
30
|
+
} : null;
|
|
21
31
|
return /*#__PURE__*/React.createElement(CoverView, {
|
|
22
32
|
className: clsx('ipc-player-bottom-right-content-wrap'),
|
|
23
33
|
style: _objectSpread({
|
|
24
34
|
paddingLeft: screenType === 'vertical' ? '10px' : '0',
|
|
25
35
|
height: screenType === 'vertical' ? shouldHide ? '49px' : '48px' : shouldHide ? '84px' : '83px'
|
|
26
|
-
},
|
|
27
|
-
width: `${width}px`,
|
|
28
|
-
boxSizing: 'border-box'
|
|
29
|
-
} : null)
|
|
36
|
+
}, widthStyle)
|
|
30
37
|
}, /*#__PURE__*/React.createElement(View, {
|
|
31
38
|
style: {
|
|
39
|
+
paddingBottom: screenType === 'vertical' ? 0 : '25px',
|
|
32
40
|
paddingRight: screenType === 'vertical' ? 0 : '25px',
|
|
33
41
|
width: '100%',
|
|
34
42
|
height: `${containerHeight}px`,
|
package/lib/ui/ui.js
CHANGED
|
@@ -446,7 +446,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
446
446
|
}, [brandColor, verticalMic]);
|
|
447
447
|
const refreshSmartImageQuality = useMemoizedFn(async () => {
|
|
448
448
|
const res = await getSmartImageQualityState(devId);
|
|
449
|
-
if (res
|
|
449
|
+
if (!res) return;
|
|
450
450
|
// 调试时使用
|
|
451
451
|
// res = {
|
|
452
452
|
// isPurchase: false,
|
|
@@ -455,7 +455,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
455
455
|
// canOpenSettings: true,
|
|
456
456
|
// };
|
|
457
457
|
const getNgRes = await getNgRawData();
|
|
458
|
-
console.log('res===
|
|
458
|
+
console.log('res===getSmartImageQualityState', res);
|
|
459
459
|
updatePlayerWidgetProps(instance, 'bottomLeft', 'TryExperience', {
|
|
460
460
|
isPurchase: res.isPurchase,
|
|
461
461
|
buttonState: res.buttonState,
|
|
@@ -680,14 +680,18 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
680
680
|
|
|
681
681
|
/**
|
|
682
682
|
* 右下角可见按钮数 → 右下角组件宽度(左下角同时用作右侧预留宽度)
|
|
683
|
-
*
|
|
683
|
+
* - 横屏: 固定 35%(用百分比,左下角自动按 100% - 35% = 65% 可视,溢出走横向滚动)
|
|
684
|
+
* - 竖屏: 1 个按钮 115px / 2+ 个按钮 132px / 0 个按钮 0
|
|
684
685
|
*/
|
|
685
686
|
const bottomRightWidth = useMemo(() => {
|
|
687
|
+
if (screenType === 'full') {
|
|
688
|
+
return '35%';
|
|
689
|
+
}
|
|
686
690
|
const visibleCount = (bottomRightContent || []).filter(item => !item.hidden).length;
|
|
687
691
|
if (visibleCount <= 0) return 0;
|
|
688
692
|
if (visibleCount === 1) return 115;
|
|
689
693
|
return 132;
|
|
690
|
-
}, [bottomRightContent]);
|
|
694
|
+
}, [bottomRightContent, screenType]);
|
|
691
695
|
|
|
692
696
|
/**
|
|
693
697
|
* 视频流加载状态封装
|
|
@@ -919,7 +923,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
919
923
|
,
|
|
920
924
|
privateState: privateState,
|
|
921
925
|
onPlayerTap: data => {
|
|
922
|
-
console.log('
|
|
926
|
+
console.log('playerTap event');
|
|
923
927
|
if (disablePlayerTap.current) {
|
|
924
928
|
console.log('playerTap 事件已禁止');
|
|
925
929
|
return;
|
package/lib/utils/ttt.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type SmartImageQualityResult = {
|
|
|
4
4
|
trialRemainingSec: number;
|
|
5
5
|
canOpenSettings: boolean;
|
|
6
6
|
};
|
|
7
|
-
export declare function getSmartImageQualityState(devId: string): Promise<SmartImageQualityResult>;
|
|
7
|
+
export declare function getSmartImageQualityState(devId: string): Promise<SmartImageQualityResult | null>;
|
|
8
8
|
export type AIFrameFeatureScope = {
|
|
9
9
|
inPreview: boolean;
|
|
10
10
|
inMessage: boolean;
|
|
@@ -34,10 +34,8 @@ export type GetAIFrameFeatureResult = {
|
|
|
34
34
|
localPath: string;
|
|
35
35
|
thingFileUri: string;
|
|
36
36
|
};
|
|
37
|
-
export declare function getAIFrameFeature(devId: string): Promise<GetAIFrameFeatureResult>;
|
|
37
|
+
export declare function getAIFrameFeature(devId: string): Promise<GetAIFrameFeatureResult | null>;
|
|
38
38
|
export declare function setAIFrameFeature(params: SetAIFrameFeatureParams): Promise<any>;
|
|
39
|
-
export declare function getDeviceInfo(devId: string): Promise<unknown>;
|
|
40
|
-
export declare function getCurrentHomeInfo(): Promise<unknown>;
|
|
41
39
|
export declare function setTrailFinish(devId: string): Promise<unknown>;
|
|
42
|
-
export declare function isLowPhone(): Promise<
|
|
40
|
+
export declare function isLowPhone(): Promise<boolean>;
|
|
43
41
|
export declare function getNgRawData(): Promise<unknown>;
|
package/lib/utils/ttt.js
CHANGED
|
@@ -1,24 +1,37 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
export function getSmartImageQualityState(devId) {
|
|
3
3
|
return new Promise(resolve => {
|
|
4
|
+
var _ty$ipc;
|
|
5
|
+
const isSupport = typeof ((_ty$ipc = ty.ipc) === null || _ty$ipc === void 0 ? void 0 : _ty$ipc.getSmartImageQualityState) === 'function';
|
|
6
|
+
if (!isSupport) {
|
|
7
|
+
resolve(null);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
4
10
|
try {
|
|
5
|
-
|
|
11
|
+
var _ty;
|
|
12
|
+
(_ty = ty) === null || _ty === void 0 || (_ty = _ty.ipc) === null || _ty === void 0 || _ty.getSmartImageQualityState({
|
|
6
13
|
devId,
|
|
7
14
|
scene: 'inPreview',
|
|
8
15
|
success: data => {
|
|
9
16
|
resolve(data);
|
|
10
17
|
},
|
|
11
18
|
fail: () => {
|
|
12
|
-
resolve(
|
|
19
|
+
resolve(null);
|
|
13
20
|
}
|
|
14
21
|
});
|
|
15
22
|
} catch (e) {
|
|
16
|
-
resolve(
|
|
23
|
+
resolve(null);
|
|
17
24
|
}
|
|
18
25
|
});
|
|
19
26
|
}
|
|
20
27
|
export function getAIFrameFeature(devId) {
|
|
21
28
|
return new Promise(resolve => {
|
|
29
|
+
var _ty$ipc2;
|
|
30
|
+
const isSupport = typeof ((_ty$ipc2 = ty.ipc) === null || _ty$ipc2 === void 0 ? void 0 : _ty$ipc2.getAIFrameFeature) === 'function';
|
|
31
|
+
if (!isSupport) {
|
|
32
|
+
resolve(null);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
22
35
|
try {
|
|
23
36
|
ty.ipc.getAIFrameFeature({
|
|
24
37
|
devId,
|
|
@@ -28,16 +41,22 @@ export function getAIFrameFeature(devId) {
|
|
|
28
41
|
},
|
|
29
42
|
fail: e => {
|
|
30
43
|
console.warn('res===getAIFrameFeature fail', e);
|
|
31
|
-
resolve(
|
|
44
|
+
resolve(null);
|
|
32
45
|
}
|
|
33
46
|
});
|
|
34
47
|
} catch (e) {
|
|
35
|
-
resolve(
|
|
48
|
+
resolve(null);
|
|
36
49
|
}
|
|
37
50
|
});
|
|
38
51
|
}
|
|
39
52
|
export function setAIFrameFeature(params) {
|
|
40
53
|
return new Promise(resolve => {
|
|
54
|
+
var _ty$ipc3;
|
|
55
|
+
const isSupport = typeof ((_ty$ipc3 = ty.ipc) === null || _ty$ipc3 === void 0 ? void 0 : _ty$ipc3.setAIFrameFeature) === 'function';
|
|
56
|
+
if (!isSupport) {
|
|
57
|
+
resolve(null);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
41
60
|
try {
|
|
42
61
|
ty.ipc.setAIFrameFeature(_objectSpread(_objectSpread({}, params), {}, {
|
|
43
62
|
success: data => {
|
|
@@ -46,70 +65,50 @@ export function setAIFrameFeature(params) {
|
|
|
46
65
|
},
|
|
47
66
|
fail: e => {
|
|
48
67
|
console.warn('res===setAIFrameFeature fail', e);
|
|
49
|
-
resolve(
|
|
68
|
+
resolve(null);
|
|
50
69
|
}
|
|
51
70
|
}));
|
|
52
71
|
} catch (e) {
|
|
53
|
-
resolve(
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
export function getDeviceInfo(devId) {
|
|
58
|
-
return new Promise(resolve => {
|
|
59
|
-
try {
|
|
60
|
-
ty.device.getDeviceInfo({
|
|
61
|
-
deviceId: devId,
|
|
62
|
-
success: res => {
|
|
63
|
-
resolve(res);
|
|
64
|
-
},
|
|
65
|
-
fail: () => {
|
|
66
|
-
resolve(undefined);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
} catch (e) {
|
|
70
|
-
resolve(undefined);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
export function getCurrentHomeInfo() {
|
|
75
|
-
return new Promise(resolve => {
|
|
76
|
-
try {
|
|
77
|
-
ty.home.getCurrentHomeInfo({
|
|
78
|
-
success: res => {
|
|
79
|
-
resolve(res);
|
|
80
|
-
},
|
|
81
|
-
fail: () => {
|
|
82
|
-
resolve(undefined);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
} catch (e) {
|
|
86
|
-
resolve(undefined);
|
|
72
|
+
resolve(null);
|
|
87
73
|
}
|
|
88
74
|
});
|
|
89
75
|
}
|
|
90
76
|
export function setTrailFinish(devId) {
|
|
91
77
|
return new Promise(resolve => {
|
|
78
|
+
var _ty$ipc4;
|
|
79
|
+
const isSupport = typeof ((_ty$ipc4 = ty.ipc) === null || _ty$ipc4 === void 0 ? void 0 : _ty$ipc4.setTrailFinish) === 'function';
|
|
80
|
+
if (!isSupport) {
|
|
81
|
+
resolve(null);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
92
84
|
try {
|
|
93
|
-
|
|
85
|
+
var _ty2;
|
|
86
|
+
(_ty2 = ty) === null || _ty2 === void 0 || (_ty2 = _ty2.ipc) === null || _ty2 === void 0 || _ty2.setTrailFinish({
|
|
94
87
|
devId,
|
|
95
88
|
success: res => {
|
|
96
89
|
resolve(res);
|
|
97
90
|
},
|
|
98
91
|
fail: () => {
|
|
99
|
-
resolve(
|
|
92
|
+
resolve(null);
|
|
100
93
|
}
|
|
101
94
|
});
|
|
102
95
|
} catch (e) {
|
|
103
|
-
resolve(
|
|
96
|
+
resolve(null);
|
|
104
97
|
}
|
|
105
98
|
});
|
|
106
99
|
}
|
|
107
100
|
export function isLowPhone() {
|
|
108
101
|
return new Promise(resolve => {
|
|
102
|
+
var _ty$ipc5;
|
|
103
|
+
const isSupport = typeof ((_ty$ipc5 = ty.ipc) === null || _ty$ipc5 === void 0 ? void 0 : _ty$ipc5.isLowPhone) === 'function';
|
|
104
|
+
if (!isSupport) {
|
|
105
|
+
resolve(false);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
109
108
|
try {
|
|
110
|
-
ty.
|
|
109
|
+
ty.ipc.isLowPhone({
|
|
111
110
|
success: res => {
|
|
112
|
-
resolve(res);
|
|
111
|
+
resolve(!!res);
|
|
113
112
|
},
|
|
114
113
|
fail: () => {
|
|
115
114
|
resolve(false);
|
|
@@ -122,11 +121,17 @@ export function isLowPhone() {
|
|
|
122
121
|
}
|
|
123
122
|
export function getNgRawData() {
|
|
124
123
|
return new Promise(resolve => {
|
|
124
|
+
var _ty3;
|
|
125
|
+
const isSupport = typeof ((_ty3 = ty) === null || _ty3 === void 0 ? void 0 : _ty3.getNgRawData) === 'function';
|
|
126
|
+
if (!isSupport) {
|
|
127
|
+
resolve(false);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
125
130
|
try {
|
|
126
131
|
ty.getNgRawData({
|
|
127
132
|
rawKey: 'is_smart_image_quality',
|
|
128
133
|
success: res => {
|
|
129
|
-
resolve(res);
|
|
134
|
+
resolve((res === null || res === void 0 ? void 0 : res.rawData) === 'true');
|
|
130
135
|
},
|
|
131
136
|
fail: () => {
|
|
132
137
|
resolve(false);
|
|
@@ -28,7 +28,6 @@ export const TrialBadge = _ref => {
|
|
|
28
28
|
const startTimeRef = useRef(Date.now());
|
|
29
29
|
const initialSecRef = useRef(Math.max(0, Math.floor(trialRemainingSec)));
|
|
30
30
|
useEffect(() => {
|
|
31
|
-
console.log('res===trialRemainingSec', trialRemainingSec);
|
|
32
31
|
const sec = Math.max(0, Math.floor(trialRemainingSec));
|
|
33
32
|
endedRef.current = false;
|
|
34
33
|
initialSecRef.current = sec;
|
|
@@ -66,7 +66,6 @@ export const TryExperience = props => {
|
|
|
66
66
|
updateImgSrc();
|
|
67
67
|
}, [buttonState]);
|
|
68
68
|
const updateImgSrc = useCallback(() => {
|
|
69
|
-
console.log('res===updateImgSrc', buttonState, isLowPhone);
|
|
70
69
|
if (isLowPhone) {
|
|
71
70
|
setImgSrc(tryClose);
|
|
72
71
|
return;
|
|
@@ -98,6 +97,7 @@ export const TryExperience = props => {
|
|
|
98
97
|
lockRef.current = true;
|
|
99
98
|
try {
|
|
100
99
|
const getAI = await getAIFrameFeature(devId);
|
|
100
|
+
if (!getAI) return;
|
|
101
101
|
if (buttonState === TryExperienceStatus.Open) {
|
|
102
102
|
var _getAI$aiFrameFeature, _getAI$aiFrameFeature2, _getAI$aiFrameFeature3, _props$event;
|
|
103
103
|
// 由开变关的时候,只关inPreview
|