@ray-js/ipc-player-integration 0.0.35-beta.3 → 0.0.35-beta.5
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/ui/constant.d.ts +0 -2
- package/lib/ui/constant.js +0 -3
- package/lib/ui/index.d.ts +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/ui.js +12 -4
- package/lib/utils/ttt.d.ts +1 -1
- package/lib/utils/ttt.js +99 -67
- package/lib/widgets/trialBadge/useTrialBadge.js +4 -7
- package/lib/widgets/tryExperience/tryExperience.js +2 -3
- package/package.json +1 -1
package/lib/ui/constant.d.ts
CHANGED
|
@@ -21,8 +21,6 @@ export declare const landscapeTipId = "landscapeTipId";
|
|
|
21
21
|
export declare const multiPtzId = "multiPtzId";
|
|
22
22
|
/** 控件点击统一事件:任意播放器内控件被点击时触发,可用于埋点或统一处理 */
|
|
23
23
|
export declare const widgetClick = "widgetClick";
|
|
24
|
-
/** 「去体验」按钮业务事件,与清晰度 resolutionBtnControlClick 用法一致 */
|
|
25
|
-
export declare const tryExperienceBtnClick = "tryExperienceBtnClick";
|
|
26
24
|
/**
|
|
27
25
|
* 试看倒计时结束事件:试看徽章倒计时归零时触发,
|
|
28
26
|
* 业务侧/相关控件可监听此事件刷新自己的状态(例如 TryExperience 重新拉取状态)
|
package/lib/ui/constant.js
CHANGED
|
@@ -22,9 +22,6 @@ export const multiPtzId = 'multiPtzId';
|
|
|
22
22
|
/** 控件点击统一事件:任意播放器内控件被点击时触发,可用于埋点或统一处理 */
|
|
23
23
|
export const widgetClick = 'widgetClick';
|
|
24
24
|
|
|
25
|
-
/** 「去体验」按钮业务事件,与清晰度 resolutionBtnControlClick 用法一致 */
|
|
26
|
-
export const tryExperienceBtnClick = 'tryExperienceBtnClick';
|
|
27
|
-
|
|
28
25
|
/**
|
|
29
26
|
* 试看倒计时结束事件:试看徽章倒计时归零时触发,
|
|
30
27
|
* 业务侧/相关控件可监听此事件刷新自己的状态(例如 TryExperience 重新拉取状态)
|
package/lib/ui/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export * from './hooks';
|
|
|
3
3
|
export * from './context';
|
|
4
4
|
export type * from './event';
|
|
5
5
|
export { widgetClick } from './widgetClick';
|
|
6
|
-
export { widgetLabs,
|
|
6
|
+
export { widgetLabs, trialCountdownEnd } from './constant';
|
package/lib/ui/index.js
CHANGED
package/lib/ui/ui.js
CHANGED
|
@@ -12,7 +12,7 @@ import { PlayState, PlayerStreamStatus, MultiCameraScreenMode } from '../interfa
|
|
|
12
12
|
import { useCtx } from '../ctx/ctx.composition';
|
|
13
13
|
import { useStore, updateAtom } from '../ctx/store';
|
|
14
14
|
import { UIEventContext } from './context';
|
|
15
|
-
import { showAllComponent, hideAllComponent, playerTap, startTimeToHideAllComponent, pauseTimeToHideAllComponent, decodeClarityDic, changeIgnoreHideStopPreview, moveablePtzControlId, tileActionsId, tileTipId, landscapeTipId, multiPtzId, ptzMoveableTipId, showFlowLowTipId, zoomLevelChange, setScaleMultipleEvent } from './constant';
|
|
15
|
+
import { showAllComponent, hideAllComponent, playerTap, startTimeToHideAllComponent, pauseTimeToHideAllComponent, decodeClarityDic, changeIgnoreHideStopPreview, moveablePtzControlId, tileActionsId, tileTipId, landscapeTipId, multiPtzId, ptzMoveableTipId, showFlowLowTipId, zoomLevelChange, setScaleMultipleEvent, trialCountdownEnd } from './constant';
|
|
16
16
|
import BottomLeftContent from './bottomLeftContent';
|
|
17
17
|
import BottomRightContent from './bottomRightContent';
|
|
18
18
|
import TopLeftContent from './topLeftContent';
|
|
@@ -427,7 +427,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
427
427
|
}, [brandColor, verticalMic]);
|
|
428
428
|
const refreshSmartImageQuality = useMemoizedFn(() => {
|
|
429
429
|
getSmartImageQualityState(devId).then(res => {
|
|
430
|
-
console.log('res===getSmartImageQualityState', res);
|
|
431
430
|
updatePlayerWidgetProps(instance, 'bottomLeft', 'TryExperience', {
|
|
432
431
|
buttonState: res.buttonState,
|
|
433
432
|
trialRemainingSec: res.trialRemainingSec,
|
|
@@ -436,8 +435,10 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
436
435
|
});
|
|
437
436
|
});
|
|
438
437
|
useEffect(() => {
|
|
439
|
-
|
|
440
|
-
|
|
438
|
+
if (playState === PlayState.PLAYING) {
|
|
439
|
+
refreshSmartImageQuality();
|
|
440
|
+
}
|
|
441
|
+
}, [playState]);
|
|
441
442
|
const refreshBottomLeft = () => {
|
|
442
443
|
event.current.emit(startTimeToHideAllComponent);
|
|
443
444
|
event.current.emit(showAllComponent);
|
|
@@ -752,6 +753,11 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
752
753
|
const onSetScaleMultiple = value => {
|
|
753
754
|
setScaleMultiple(value);
|
|
754
755
|
};
|
|
756
|
+
const onTrialCountdownEnd = useMemoizedFn(() => {
|
|
757
|
+
updatePlayerWidgetProps(instance, 'bottomLeft', 'TryExperience', {
|
|
758
|
+
buttonState: 2
|
|
759
|
+
});
|
|
760
|
+
});
|
|
755
761
|
useEffect(() => {
|
|
756
762
|
eventRef.current.on(startTimeToHideAllComponent, listenStart);
|
|
757
763
|
eventRef.current.on(pauseTimeToHideAllComponent, listenPause);
|
|
@@ -761,6 +767,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
761
767
|
eventRef.current.on('refreshBottomLeft', refreshBottomLeft);
|
|
762
768
|
eventRef.current.on(changeIgnoreHideStopPreview, onChangeIgnoreHideStopPreview);
|
|
763
769
|
eventRef.current.on(setScaleMultipleEvent, onSetScaleMultiple);
|
|
770
|
+
eventRef.current.on(trialCountdownEnd, onTrialCountdownEnd);
|
|
764
771
|
return () => {
|
|
765
772
|
eventRef.current.off(startTimeToHideAllComponent, listenStart);
|
|
766
773
|
eventRef.current.off(pauseTimeToHideAllComponent, listenPause);
|
|
@@ -770,6 +777,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
770
777
|
eventRef.current.off('refreshBottomLeft', refreshBottomLeft);
|
|
771
778
|
eventRef.current.off(changeIgnoreHideStopPreview, onChangeIgnoreHideStopPreview);
|
|
772
779
|
eventRef.current.off(setScaleMultipleEvent, onSetScaleMultiple);
|
|
780
|
+
eventRef.current.off(trialCountdownEnd, onTrialCountdownEnd);
|
|
773
781
|
if (multiTapTimerRef.current) {
|
|
774
782
|
clearTimeout(multiTapTimerRef.current);
|
|
775
783
|
multiTapTimerRef.current = null;
|
package/lib/utils/ttt.d.ts
CHANGED
|
@@ -34,6 +34,6 @@ export type GetAIFrameFeatureResult = {
|
|
|
34
34
|
thingFileUri: string;
|
|
35
35
|
};
|
|
36
36
|
export declare function getAIFrameFeature(devId: string): Promise<GetAIFrameFeatureResult>;
|
|
37
|
-
export declare function setAIFrameFeature(
|
|
37
|
+
export declare function setAIFrameFeature(params: SetAIFrameFeatureParams): Promise<any>;
|
|
38
38
|
export declare function getDeviceInfoRay(devId: string): Promise<unknown>;
|
|
39
39
|
export declare function getCurrentHomeInfoRay(): Promise<unknown>;
|
package/lib/utils/ttt.js
CHANGED
|
@@ -1,87 +1,119 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
export function getSmartImageQualityState(devId) {
|
|
3
|
-
// const mockData: SmartImageQualityResult = {
|
|
4
|
-
// isPurchase: false,
|
|
5
|
-
// buttonState: 1,
|
|
6
|
-
// trialRemainingSec: 200,
|
|
7
|
-
// canOpenSettings: false,
|
|
8
|
-
// };
|
|
9
|
-
// if (typeof ty?.ipc?.getSmartImageQualityState !== 'function') {
|
|
10
|
-
// console.log('res===getSmartImageQualityState not exist, use mockData', mockData);
|
|
11
|
-
// return Promise.resolve(mockData);
|
|
12
|
-
// }
|
|
13
3
|
return new Promise((resolve, reject) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
4
|
+
var _ty;
|
|
5
|
+
if (typeof ((_ty = ty) === null || _ty === void 0 || (_ty = _ty.ipc) === null || _ty === void 0 ? void 0 : _ty.getSmartImageQualityState) !== 'function') {
|
|
6
|
+
reject(new Error('getSmartImageQualityState is not supported'));
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
ty.ipc.getSmartImageQualityState({
|
|
11
|
+
devId,
|
|
12
|
+
scene: 'inPreview',
|
|
13
|
+
success: data => {
|
|
14
|
+
console.log('res===getSmartImageQualityState data', data);
|
|
15
|
+
resolve(data);
|
|
16
|
+
},
|
|
17
|
+
fail: e => {
|
|
18
|
+
console.warn('res===getSmartImageQualityState fail', e);
|
|
19
|
+
reject(e);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
} catch (e) {
|
|
23
|
+
console.warn('res===getSmartImageQualityState exception', e);
|
|
24
|
+
reject(e);
|
|
25
|
+
}
|
|
27
26
|
});
|
|
28
27
|
}
|
|
29
28
|
export function getAIFrameFeature(devId) {
|
|
30
29
|
return new Promise((resolve, reject) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
30
|
+
var _ty2;
|
|
31
|
+
if (typeof ((_ty2 = ty) === null || _ty2 === void 0 || (_ty2 = _ty2.ipc) === null || _ty2 === void 0 ? void 0 : _ty2.getAIFrameFeature) !== 'function') {
|
|
32
|
+
reject(new Error('getAIFrameFeature is not supported'));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
ty.ipc.getAIFrameFeature({
|
|
37
|
+
devId,
|
|
38
|
+
success: data => {
|
|
39
|
+
console.log('res===getAIFrameFeature data', data);
|
|
40
|
+
resolve(data);
|
|
41
|
+
},
|
|
42
|
+
fail: e => {
|
|
43
|
+
console.warn('res===getAIFrameFeature fail', e);
|
|
44
|
+
reject(e);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
} catch (e) {
|
|
48
|
+
console.warn('res===getAIFrameFeature exception', e);
|
|
49
|
+
reject(e);
|
|
50
|
+
}
|
|
44
51
|
});
|
|
45
52
|
}
|
|
46
|
-
export function setAIFrameFeature(
|
|
53
|
+
export function setAIFrameFeature(params) {
|
|
47
54
|
return new Promise((resolve, reject) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
var _ty3;
|
|
56
|
+
if (typeof ((_ty3 = ty) === null || _ty3 === void 0 || (_ty3 = _ty3.ipc) === null || _ty3 === void 0 ? void 0 : _ty3.setAIFrameFeature) !== 'function') {
|
|
57
|
+
reject(new Error('setAIFrameFeature is not supported'));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
ty.ipc.setAIFrameFeature(_objectSpread(_objectSpread({}, params), {}, {
|
|
62
|
+
success: data => {
|
|
63
|
+
console.log('res===setAIFrameFeature data', data);
|
|
64
|
+
resolve(data);
|
|
65
|
+
},
|
|
66
|
+
fail: e => {
|
|
67
|
+
console.warn('res===setAIFrameFeature fail', e);
|
|
68
|
+
reject(e);
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
} catch (e) {
|
|
72
|
+
console.warn('res===setAIFrameFeature exception', e);
|
|
73
|
+
reject(e);
|
|
74
|
+
}
|
|
61
75
|
});
|
|
62
76
|
}
|
|
63
77
|
export function getDeviceInfoRay(devId) {
|
|
64
78
|
return new Promise((resolve, reject) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
79
|
+
var _ty4;
|
|
80
|
+
if (typeof ((_ty4 = ty) === null || _ty4 === void 0 || (_ty4 = _ty4.device) === null || _ty4 === void 0 ? void 0 : _ty4.getDeviceInfo) !== 'function') {
|
|
81
|
+
reject(new Error('getDeviceInfo is not supported'));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
ty.device.getDeviceInfo({
|
|
86
|
+
deviceId: devId,
|
|
87
|
+
success: res => {
|
|
88
|
+
resolve(res);
|
|
89
|
+
},
|
|
90
|
+
fail: error => {
|
|
91
|
+
reject(error);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
} catch (e) {
|
|
95
|
+
reject(e);
|
|
96
|
+
}
|
|
74
97
|
});
|
|
75
98
|
}
|
|
76
99
|
export function getCurrentHomeInfoRay() {
|
|
77
100
|
return new Promise((resolve, reject) => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
101
|
+
var _ty5;
|
|
102
|
+
if (typeof ((_ty5 = ty) === null || _ty5 === void 0 || (_ty5 = _ty5.home) === null || _ty5 === void 0 ? void 0 : _ty5.getCurrentHomeInfo) !== 'function') {
|
|
103
|
+
reject(new Error('getCurrentHomeInfo is not supported'));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
ty.home.getCurrentHomeInfo({
|
|
108
|
+
success: res => {
|
|
109
|
+
resolve(res);
|
|
110
|
+
},
|
|
111
|
+
fail: error => {
|
|
112
|
+
reject(error);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
} catch (e) {
|
|
116
|
+
reject(e);
|
|
117
|
+
}
|
|
86
118
|
});
|
|
87
119
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { getCurrentHomeInfoRay, getDeviceInfoRay } from '../../utils/ttt';
|
|
3
3
|
import { gotoSecurityCloudService } from '../../utils';
|
|
4
|
+
import { trialCountdownEnd } from '../../ui/constant';
|
|
4
5
|
import Strings from '../../i18n';
|
|
5
6
|
export const useTrialBadge = (event, devId, trialRemainingSec) => {
|
|
6
7
|
const [showTrialBadge, setShowTrialBadge] = useState(false);
|
|
@@ -25,13 +26,9 @@ export const useTrialBadge = (event, devId, trialRemainingSec) => {
|
|
|
25
26
|
}, [devId]);
|
|
26
27
|
const handleCountdownEnd = useCallback(async () => {
|
|
27
28
|
try {
|
|
28
|
-
|
|
29
|
-
console.log('res===handleCountdownEnd', getAI);
|
|
30
|
-
setAIFrameFeature(devId, {
|
|
31
|
-
enabled: false,
|
|
32
|
-
aiFrameFeature: getAI.aiFrameFeature
|
|
33
|
-
});
|
|
29
|
+
console.log('res===handleCountdownEnd');
|
|
34
30
|
setShowTrialBadge(false);
|
|
31
|
+
event.emit(trialCountdownEnd);
|
|
35
32
|
} catch (error) {
|
|
36
33
|
ty.showToast({
|
|
37
34
|
title: Strings.getLang('ipc_player_fetch_error'),
|
|
@@ -41,21 +41,20 @@ export const TryExperience = props => {
|
|
|
41
41
|
const {
|
|
42
42
|
className,
|
|
43
43
|
hideTryExperienceMenu,
|
|
44
|
-
buttonState
|
|
44
|
+
buttonState
|
|
45
45
|
} = props;
|
|
46
46
|
const {
|
|
47
47
|
brandColor
|
|
48
48
|
} = useStore({
|
|
49
49
|
brandColor: props.brandColor
|
|
50
50
|
});
|
|
51
|
-
const iconUrl = pickIconByStatus(buttonState);
|
|
52
51
|
if (hideTryExperienceMenu) {
|
|
53
52
|
return null;
|
|
54
53
|
}
|
|
54
|
+
const iconUrl = pickIconByStatus(buttonState);
|
|
55
55
|
return /*#__PURE__*/React.createElement(View, {
|
|
56
56
|
className: clsx(className),
|
|
57
57
|
onClick: () => {
|
|
58
|
-
console.log('res===onTryExperience', props.devId, brandColor);
|
|
59
58
|
gotoAIDrawMiniProgram(props.devId, brandColor);
|
|
60
59
|
}
|
|
61
60
|
}, /*#__PURE__*/React.createElement(View, {
|