@ray-js/ipc-player-integration 0.0.35-beta.6 → 0.0.35-beta.7
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/features/initPlayerWidgets/index.js +0 -1
- package/lib/ui/bottomLeftContent.js +1 -0
- package/lib/ui/ui.js +30 -2
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.js +0 -10
- package/lib/utils/navigation.d.ts +1 -0
- package/lib/utils/navigation.js +4 -1
- package/lib/utils/ttt.d.ts +1 -0
- package/lib/utils/ttt.js +35 -47
- package/lib/widgets/trialBadge/useTrialBadge.js +10 -8
- package/lib/widgets/tryExperience/tryExperience.d.ts +2 -0
- package/lib/widgets/tryExperience/tryExperience.js +20 -6
- package/package.json +1 -1
|
@@ -52,7 +52,6 @@ export async function initPlayerWidgets(ctx, options) {
|
|
|
52
52
|
newDefaultBottomLeftContent[magnificationIndex].hidden = false;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
console.log('res===1', newDefaultBottomLeftContent);
|
|
56
55
|
ctx.addContent('bottomLeft', newDefaultBottomLeftContent);
|
|
57
56
|
const newDefaultBottomRightContent = _cloneDeep(options.bottomRightContent || defaultBottomRightContent);
|
|
58
57
|
const fullScreenIndex = newDefaultBottomRightContent.findIndex(item => item.id === 'FullScreen');
|
package/lib/ui/ui.js
CHANGED
|
@@ -22,7 +22,6 @@ import { useMemoizedFn } from '../hooks';
|
|
|
22
22
|
import { Storage } from '../utils/storage';
|
|
23
23
|
import './ui.less';
|
|
24
24
|
import { updatePlayerWidgetProps } from '../features';
|
|
25
|
-
import { isSmallScreen } from '../utils';
|
|
26
25
|
import { getSmartImageQualityState } from '../utils/ttt';
|
|
27
26
|
function getCtxInstance(instance, devId) {
|
|
28
27
|
if (instance) return instance;
|
|
@@ -116,6 +115,19 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
116
115
|
// 展示顶部内容
|
|
117
116
|
const [showTopContent, setShowTopContent] = useState(true);
|
|
118
117
|
|
|
118
|
+
// pad / 折叠屏小窗口展示面板的情况;getSystemInfoSync 在 onLoad 之后才有准确值,
|
|
119
|
+
// 这里给安全默认 false,由 onLoad / onResize 实际计算并更新
|
|
120
|
+
const [isSmallScreen, setIsSmallScreen] = useState(false);
|
|
121
|
+
const computeIsSmallScreen = useMemoizedFn(() => {
|
|
122
|
+
const {
|
|
123
|
+
windowWidth,
|
|
124
|
+
screenWidth,
|
|
125
|
+
windowHeight
|
|
126
|
+
} = getSystemInfoSync();
|
|
127
|
+
// 取小屏值判断是最准确的 pad / 折叠屏小窗口情况
|
|
128
|
+
return !(screenWidth === windowWidth || screenWidth === windowHeight);
|
|
129
|
+
});
|
|
130
|
+
|
|
119
131
|
// 外部传入的ignoreHideStopPreview变化时,同步更新
|
|
120
132
|
useEffect(() => {
|
|
121
133
|
setIgnoreStopOnHide(ignoreHideStopPreview);
|
|
@@ -428,10 +440,14 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
428
440
|
}, [brandColor, verticalMic]);
|
|
429
441
|
const refreshSmartImageQuality = useMemoizedFn(() => {
|
|
430
442
|
getSmartImageQualityState(devId).then(res => {
|
|
443
|
+
if (res === undefined) return;
|
|
431
444
|
updatePlayerWidgetProps(instance, 'bottomLeft', 'TryExperience', {
|
|
445
|
+
isPurchase: res.isPurchase,
|
|
432
446
|
buttonState: res.buttonState,
|
|
433
447
|
trialRemainingSec: res.trialRemainingSec,
|
|
434
448
|
refreshToken: Date.now()
|
|
449
|
+
}).catch(() => {
|
|
450
|
+
// ignore
|
|
435
451
|
});
|
|
436
452
|
});
|
|
437
453
|
});
|
|
@@ -469,6 +485,13 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
469
485
|
* 监听播放器实例创建完成
|
|
470
486
|
*/
|
|
471
487
|
|
|
488
|
+
/**
|
|
489
|
+
* 页面 onLoad 后才能拿到准确的 systemInfo,这里第一次确定小屏状态
|
|
490
|
+
*/
|
|
491
|
+
usePageEvent('onLoad', () => {
|
|
492
|
+
setIsSmallScreen(computeIsSmallScreen());
|
|
493
|
+
});
|
|
494
|
+
|
|
472
495
|
/**
|
|
473
496
|
* 监听屏幕布局变化
|
|
474
497
|
*/
|
|
@@ -482,8 +505,13 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
482
505
|
const {
|
|
483
506
|
type
|
|
484
507
|
} = sizeData;
|
|
508
|
+
|
|
509
|
+
// 折叠屏展开/收起、pad 多窗口拖拽等场景,需要重新计算并同步
|
|
510
|
+
const small = computeIsSmallScreen();
|
|
511
|
+
setIsSmallScreen(small);
|
|
512
|
+
|
|
485
513
|
// 针对pad 和折叠屏展开的情况暂不支持横屏,且在ios pad模式下 会触发onResize事件, 待解决
|
|
486
|
-
if (
|
|
514
|
+
if (small) {
|
|
487
515
|
setScreenType('vertical');
|
|
488
516
|
} else {
|
|
489
517
|
setScreenType(type === 'landscape' ? 'full' : 'vertical');
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import { getSystemInfoSync } from '@ray-js/ray';
|
|
3
|
-
const {
|
|
4
|
-
windowWidth,
|
|
5
|
-
screenWidth,
|
|
6
|
-
windowHeight
|
|
7
|
-
} = getSystemInfoSync();
|
|
8
|
-
|
|
9
|
-
// pad和折叠屏小窗口展示面板的情况
|
|
10
|
-
export const isSmallScreen = !(screenWidth === windowWidth || screenWidth === windowHeight);
|
|
11
|
-
|
|
12
2
|
/**
|
|
13
3
|
* 麦克风对讲按钮径向渐变
|
|
14
4
|
*/
|
|
@@ -4,3 +4,4 @@ export declare const miniIdLabs: {
|
|
|
4
4
|
};
|
|
5
5
|
export declare function gotoAIDrawMiniProgram(devId: string, brandColor: string): void;
|
|
6
6
|
export declare function gotoSecurityCloudService(homeId: string, uuid: string): Promise<void>;
|
|
7
|
+
export declare function gotoSecurityCloudService2(devId: string): Promise<import("@ray-js/ray-ipc-utils/lib/interface").IRes<unknown>>;
|
package/lib/utils/navigation.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { goToMiniProgramByShortLink } from '@ray-js/ray-ipc-utils';
|
|
1
|
+
import { getServiceUrl, goToMiniProgramByShortLink } from '@ray-js/ray-ipc-utils';
|
|
2
2
|
import Color from 'color';
|
|
3
3
|
|
|
4
4
|
// 小程序ID集合
|
|
@@ -17,4 +17,7 @@ export function gotoAIDrawMiniProgram(devId, brandColor) {
|
|
|
17
17
|
export async function gotoSecurityCloudService(homeId, uuid) {
|
|
18
18
|
const url = `godzilla://${miniIdLabs.securityCloudService}${'/pages/serviceList/index'}?homeId=${homeId}&deviceId=${uuid}&categoryCode=${'security_cloud_service'}`;
|
|
19
19
|
goToMiniProgramByShortLink(url, 'right');
|
|
20
|
+
}
|
|
21
|
+
export async function gotoSecurityCloudService2(devId) {
|
|
22
|
+
return getServiceUrl(devId, 'security_cloud_service', {}, true);
|
|
20
23
|
}
|
package/lib/utils/ttt.d.ts
CHANGED
|
@@ -37,3 +37,4 @@ export declare function getAIFrameFeature(devId: string): Promise<GetAIFrameFeat
|
|
|
37
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>;
|
|
40
|
+
export declare function setTrailFinish(devId: string): Promise<unknown>;
|
package/lib/utils/ttt.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
export function getSmartImageQualityState(devId) {
|
|
3
|
-
return new Promise(
|
|
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
|
-
}
|
|
3
|
+
return new Promise(resolve => {
|
|
9
4
|
try {
|
|
10
5
|
ty.ipc.getSmartImageQualityState({
|
|
11
6
|
devId,
|
|
@@ -14,24 +9,17 @@ export function getSmartImageQualityState(devId) {
|
|
|
14
9
|
console.log('res===getSmartImageQualityState data', data);
|
|
15
10
|
resolve(data);
|
|
16
11
|
},
|
|
17
|
-
fail:
|
|
18
|
-
|
|
19
|
-
reject(e);
|
|
12
|
+
fail: () => {
|
|
13
|
+
resolve(undefined);
|
|
20
14
|
}
|
|
21
15
|
});
|
|
22
16
|
} catch (e) {
|
|
23
|
-
|
|
24
|
-
reject(e);
|
|
17
|
+
resolve(undefined);
|
|
25
18
|
}
|
|
26
19
|
});
|
|
27
20
|
}
|
|
28
21
|
export function getAIFrameFeature(devId) {
|
|
29
|
-
return new Promise(
|
|
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
|
-
}
|
|
22
|
+
return new Promise(resolve => {
|
|
35
23
|
try {
|
|
36
24
|
ty.ipc.getAIFrameFeature({
|
|
37
25
|
devId,
|
|
@@ -41,22 +29,16 @@ export function getAIFrameFeature(devId) {
|
|
|
41
29
|
},
|
|
42
30
|
fail: e => {
|
|
43
31
|
console.warn('res===getAIFrameFeature fail', e);
|
|
44
|
-
|
|
32
|
+
resolve(undefined);
|
|
45
33
|
}
|
|
46
34
|
});
|
|
47
35
|
} catch (e) {
|
|
48
|
-
|
|
49
|
-
reject(e);
|
|
36
|
+
resolve(undefined);
|
|
50
37
|
}
|
|
51
38
|
});
|
|
52
39
|
}
|
|
53
40
|
export function setAIFrameFeature(params) {
|
|
54
|
-
return new Promise(
|
|
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
|
-
}
|
|
41
|
+
return new Promise(resolve => {
|
|
60
42
|
try {
|
|
61
43
|
ty.ipc.setAIFrameFeature(_objectSpread(_objectSpread({}, params), {}, {
|
|
62
44
|
success: data => {
|
|
@@ -65,55 +47,61 @@ export function setAIFrameFeature(params) {
|
|
|
65
47
|
},
|
|
66
48
|
fail: e => {
|
|
67
49
|
console.warn('res===setAIFrameFeature fail', e);
|
|
68
|
-
|
|
50
|
+
resolve(undefined);
|
|
69
51
|
}
|
|
70
52
|
}));
|
|
71
53
|
} catch (e) {
|
|
72
|
-
|
|
73
|
-
reject(e);
|
|
54
|
+
resolve(undefined);
|
|
74
55
|
}
|
|
75
56
|
});
|
|
76
57
|
}
|
|
77
58
|
export function getDeviceInfoRay(devId) {
|
|
78
|
-
return new Promise(
|
|
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
|
-
}
|
|
59
|
+
return new Promise(resolve => {
|
|
84
60
|
try {
|
|
85
61
|
ty.device.getDeviceInfo({
|
|
86
62
|
deviceId: devId,
|
|
87
63
|
success: res => {
|
|
88
64
|
resolve(res);
|
|
89
65
|
},
|
|
90
|
-
fail:
|
|
91
|
-
|
|
66
|
+
fail: () => {
|
|
67
|
+
resolve(undefined);
|
|
92
68
|
}
|
|
93
69
|
});
|
|
94
70
|
} catch (e) {
|
|
95
|
-
|
|
71
|
+
resolve(undefined);
|
|
96
72
|
}
|
|
97
73
|
});
|
|
98
74
|
}
|
|
99
75
|
export function getCurrentHomeInfoRay() {
|
|
100
|
-
return new Promise(
|
|
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
|
-
}
|
|
76
|
+
return new Promise(resolve => {
|
|
106
77
|
try {
|
|
107
78
|
ty.home.getCurrentHomeInfo({
|
|
108
79
|
success: res => {
|
|
109
80
|
resolve(res);
|
|
110
81
|
},
|
|
111
|
-
fail:
|
|
112
|
-
|
|
82
|
+
fail: () => {
|
|
83
|
+
resolve(undefined);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
} catch (e) {
|
|
87
|
+
resolve(undefined);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
export function setTrailFinish(devId) {
|
|
92
|
+
return new Promise(resolve => {
|
|
93
|
+
try {
|
|
94
|
+
ty.ipc.setTrailFinish({
|
|
95
|
+
devId,
|
|
96
|
+
success: res => {
|
|
97
|
+
resolve(res);
|
|
98
|
+
},
|
|
99
|
+
fail: () => {
|
|
100
|
+
resolve(undefined);
|
|
113
101
|
}
|
|
114
102
|
});
|
|
115
103
|
} catch (e) {
|
|
116
|
-
|
|
104
|
+
resolve(undefined);
|
|
117
105
|
}
|
|
118
106
|
});
|
|
119
107
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { setTrailFinish } from '../../utils/ttt';
|
|
3
|
+
import { gotoSecurityCloudService2 } from '../../utils';
|
|
4
4
|
import { trialCountdownEnd } from '../../ui/constant';
|
|
5
5
|
import Strings from '../../i18n';
|
|
6
6
|
export const useTrialBadge = (event, devId, trialRemainingSec) => {
|
|
@@ -12,12 +12,14 @@ export const useTrialBadge = (event, devId, trialRemainingSec) => {
|
|
|
12
12
|
}, [trialRemainingSec]);
|
|
13
13
|
const handleTrialSubscribe = useCallback(async () => {
|
|
14
14
|
try {
|
|
15
|
-
const homeInfo = await getCurrentHomeInfoRay();
|
|
16
|
-
const deviceInfo = await getDeviceInfoRay(devId);
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
// const homeInfo = await getCurrentHomeInfoRay();
|
|
16
|
+
// const deviceInfo = await getDeviceInfoRay(devId);
|
|
17
|
+
// if (homeInfo !== undefined && deviceInfo !== undefined) {
|
|
18
|
+
// console.log('res===', deviceInfo, homeInfo);
|
|
19
|
+
// gotoSecurityCloudService(homeInfo.homeId, deviceInfo.uuid);
|
|
20
|
+
const res = await gotoSecurityCloudService2(devId);
|
|
21
|
+
console.log('res===gotoSecurityCloudService2', res);
|
|
19
22
|
} catch (error) {
|
|
20
|
-
console.log('res===handleTrialSubscribe error', error);
|
|
21
23
|
ty.showToast({
|
|
22
24
|
title: Strings.getLang('ipc_player_fetch_error'),
|
|
23
25
|
icon: 'none'
|
|
@@ -26,9 +28,9 @@ export const useTrialBadge = (event, devId, trialRemainingSec) => {
|
|
|
26
28
|
}, [devId]);
|
|
27
29
|
const handleCountdownEnd = useCallback(async () => {
|
|
28
30
|
try {
|
|
29
|
-
console.log('res===handleCountdownEnd');
|
|
30
31
|
setShowTrialBadge(false);
|
|
31
32
|
event.emit(trialCountdownEnd);
|
|
33
|
+
await setTrailFinish(devId);
|
|
32
34
|
} catch (error) {
|
|
33
35
|
ty.showToast({
|
|
34
36
|
title: Strings.getLang('ipc_player_fetch_error'),
|
|
@@ -5,6 +5,8 @@ type Props = ComponentConfigProps & {
|
|
|
5
5
|
className?: string;
|
|
6
6
|
hideTryExperienceMenu?: boolean;
|
|
7
7
|
buttonState?: number;
|
|
8
|
+
trialRemainingSec?: number;
|
|
9
|
+
isPurchase?: boolean;
|
|
8
10
|
};
|
|
9
11
|
export declare const TryExperience: (props: Props) => React.JSX.Element | null;
|
|
10
12
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { View, Image, getSystemInfoSync } from '@ray-js/ray';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { useState, useEffect } from 'react';
|
|
4
4
|
import { useStore } from '../../ctx/store';
|
|
5
5
|
import { gotoAIDrawMiniProgram } from '../../utils';
|
|
6
6
|
import tryZh from '../../res/try/try_zh.png';
|
|
@@ -41,27 +41,41 @@ export const TryExperience = props => {
|
|
|
41
41
|
const {
|
|
42
42
|
className,
|
|
43
43
|
hideTryExperienceMenu,
|
|
44
|
-
buttonState
|
|
44
|
+
buttonState,
|
|
45
|
+
trialRemainingSec,
|
|
46
|
+
isPurchase
|
|
45
47
|
} = props;
|
|
46
48
|
const {
|
|
47
49
|
brandColor
|
|
48
50
|
} = useStore({
|
|
49
51
|
brandColor: props.brandColor
|
|
50
52
|
});
|
|
53
|
+
const [imgSrc, setImgSrc] = useState();
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const iconUrl = pickIconByStatus(buttonState);
|
|
56
|
+
setImgSrc(iconUrl);
|
|
57
|
+
}, [buttonState]);
|
|
51
58
|
if (hideTryExperienceMenu) {
|
|
52
59
|
return null;
|
|
53
60
|
}
|
|
54
|
-
const iconUrl = pickIconByStatus(buttonState);
|
|
55
61
|
return /*#__PURE__*/React.createElement(View, {
|
|
56
62
|
className: clsx(className),
|
|
57
63
|
onClick: () => {
|
|
58
|
-
|
|
64
|
+
if (buttonState === TryExperienceStatus.Open) {
|
|
65
|
+
setImgSrc(tryOpen);
|
|
66
|
+
} else if (buttonState === TryExperienceStatus.Close && isPurchase) {
|
|
67
|
+
setImgSrc(tryClose);
|
|
68
|
+
} else if (buttonState === TryExperienceStatus.Close && trialRemainingSec < 300 && trialRemainingSec > 0) {
|
|
69
|
+
setImgSrc(tryClose);
|
|
70
|
+
} else {
|
|
71
|
+
gotoAIDrawMiniProgram(props.devId, brandColor);
|
|
72
|
+
}
|
|
59
73
|
}
|
|
60
74
|
}, /*#__PURE__*/React.createElement(View, {
|
|
61
75
|
className: "try-experience-box"
|
|
62
|
-
}, /*#__PURE__*/React.createElement(Image, {
|
|
76
|
+
}, imgSrc && /*#__PURE__*/React.createElement(Image, {
|
|
63
77
|
className: "try-experience-icon",
|
|
64
|
-
src:
|
|
78
|
+
src: imgSrc,
|
|
65
79
|
mode: "heightFix"
|
|
66
80
|
})));
|
|
67
81
|
};
|