@ray-js/ipc-player-integration 0.0.35-beta.3 → 0.0.35-beta.30
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/features/initPlayerWidgets/index.js +0 -1
- package/lib/i18n/index.d.ts +4 -0
- package/lib/i18n/strings.d.ts +2 -0
- package/lib/i18n/strings.js +4 -2
- package/lib/res/try/try_close.png +0 -0
- package/lib/ui/bottomLeftContent.d.ts +8 -3
- package/lib/ui/bottomLeftContent.js +50 -48
- package/lib/ui/bottomRightContent.d.ts +6 -2
- package/lib/ui/bottomRightContent.js +15 -6
- package/lib/ui/constant.d.ts +2 -2
- package/lib/ui/constant.js +2 -3
- package/lib/ui/index.d.ts +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/ui.js +106 -70
- package/lib/ui/ui.less +2 -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 +5 -2
- package/lib/utils/ttt.d.ts +7 -5
- package/lib/utils/ttt.js +132 -74
- package/lib/widgets/trialBadge/index.d.ts +1 -3
- package/lib/widgets/trialBadge/index.js +20 -22
- package/lib/widgets/trialBadge/index.less +17 -6
- package/lib/widgets/trialBadge/useTrialBadge.js +24 -15
- package/lib/widgets/tryExperience/tryExperience.d.ts +5 -0
- package/lib/widgets/tryExperience/tryExperience.js +109 -13
- package/package.json +3 -3
|
@@ -18,21 +18,24 @@ export const TrialBadge = _ref => {
|
|
|
18
18
|
className,
|
|
19
19
|
brandColor = FALLBACK_BRAND_COLOR,
|
|
20
20
|
trialRemainingSec = 0,
|
|
21
|
-
refreshToken,
|
|
22
21
|
onSubscribe,
|
|
23
22
|
onCountdownEnd
|
|
24
23
|
} = _ref;
|
|
25
24
|
const [remainingSec, setRemainingSec] = useState(Math.max(0, Math.floor(trialRemainingSec)));
|
|
26
|
-
/** 防止 onCountdownEnd 被重复触发;同时持有最新回调,避免依赖变化导致 effect 重跑 */
|
|
27
25
|
const endedRef = useRef(false);
|
|
28
26
|
const onCountdownEndRef = useRef(onCountdownEnd);
|
|
29
27
|
onCountdownEndRef.current = onCountdownEnd;
|
|
28
|
+
const startTimeRef = useRef(Date.now());
|
|
29
|
+
const initialSecRef = useRef(Math.max(0, Math.floor(trialRemainingSec)));
|
|
30
30
|
useEffect(() => {
|
|
31
|
+
const sec = Math.max(0, Math.floor(trialRemainingSec));
|
|
31
32
|
endedRef.current = false;
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
initialSecRef.current = sec;
|
|
34
|
+
startTimeRef.current = Date.now();
|
|
35
|
+
setRemainingSec(sec);
|
|
36
|
+
}, [trialRemainingSec]);
|
|
34
37
|
useEffect(() => {
|
|
35
|
-
if (
|
|
38
|
+
if (trialRemainingSec <= 0) {
|
|
36
39
|
if (!endedRef.current) {
|
|
37
40
|
var _onCountdownEndRef$cu;
|
|
38
41
|
endedRef.current = true;
|
|
@@ -41,22 +44,20 @@ export const TrialBadge = _ref => {
|
|
|
41
44
|
return undefined;
|
|
42
45
|
}
|
|
43
46
|
const timer = setInterval(() => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return 0;
|
|
47
|
+
const elapsed = Math.floor((Date.now() - startTimeRef.current) / 1000);
|
|
48
|
+
const next = Math.max(0, initialSecRef.current - elapsed);
|
|
49
|
+
setRemainingSec(next);
|
|
50
|
+
if (next <= 0) {
|
|
51
|
+
clearInterval(timer);
|
|
52
|
+
if (!endedRef.current) {
|
|
53
|
+
var _onCountdownEndRef$cu2;
|
|
54
|
+
endedRef.current = true;
|
|
55
|
+
(_onCountdownEndRef$cu2 = onCountdownEndRef.current) === null || _onCountdownEndRef$cu2 === void 0 || _onCountdownEndRef$cu2.call(onCountdownEndRef);
|
|
54
56
|
}
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
+
}
|
|
57
58
|
}, 1000);
|
|
58
59
|
return () => clearInterval(timer);
|
|
59
|
-
}, [trialRemainingSec
|
|
60
|
+
}, [trialRemainingSec]);
|
|
60
61
|
const countdownText = formatCountdown(remainingSec);
|
|
61
62
|
return /*#__PURE__*/React.createElement(View, {
|
|
62
63
|
className: clsx('ipc-player-trial-badge', className)
|
|
@@ -75,10 +76,7 @@ export const TrialBadge = _ref => {
|
|
|
75
76
|
style: {
|
|
76
77
|
backgroundColor: brandColor
|
|
77
78
|
},
|
|
78
|
-
onClick:
|
|
79
|
-
if (e && typeof e.stopPropagation === 'function') {
|
|
80
|
-
e.stopPropagation();
|
|
81
|
-
}
|
|
79
|
+
onClick: () => {
|
|
82
80
|
onSubscribe === null || onSubscribe === void 0 || onSubscribe();
|
|
83
81
|
}
|
|
84
82
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
@@ -1,13 +1,23 @@
|
|
|
1
|
+
@keyframes ipc-player-trial-badge-slide-in {
|
|
2
|
+
from {
|
|
3
|
+
transform: translateX(-100%);
|
|
4
|
+
}
|
|
5
|
+
to {
|
|
6
|
+
transform: translateX(0);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
1
10
|
.ipc-player-trial-badge {
|
|
2
11
|
display: inline-flex;
|
|
3
12
|
align-items: center;
|
|
4
|
-
height:
|
|
5
|
-
padding: 0
|
|
6
|
-
border-radius:
|
|
13
|
+
height: 32px;
|
|
14
|
+
padding: 0 6px 0 8px;
|
|
15
|
+
border-radius: 8px;
|
|
7
16
|
background: rgba(0, 0, 0, 0.65);
|
|
8
17
|
flex-shrink: 0;
|
|
9
18
|
vertical-align: middle;
|
|
10
19
|
white-space: nowrap;
|
|
20
|
+
animation: ipc-player-trial-badge-slide-in 0.3s linear;
|
|
11
21
|
}
|
|
12
22
|
|
|
13
23
|
.ipc-player-trial-badge-icon {
|
|
@@ -43,9 +53,10 @@
|
|
|
43
53
|
display: inline-flex;
|
|
44
54
|
align-items: center;
|
|
45
55
|
justify-content: center;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
min-width: 44px;
|
|
57
|
+
min-height: 28px;
|
|
58
|
+
padding: 0 12px;
|
|
59
|
+
border-radius: 14px;
|
|
49
60
|
flex-shrink: 0;
|
|
50
61
|
}
|
|
51
62
|
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { setTrailFinish } from '../../utils/ttt';
|
|
3
|
+
import { gotoSecurityCloudService2 } 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);
|
|
8
|
+
const prevTrialSecRef = useRef(trialRemainingSec);
|
|
7
9
|
useEffect(() => {
|
|
8
10
|
if (trialRemainingSec > 0 && trialRemainingSec < 300) {
|
|
9
|
-
|
|
11
|
+
if (trialRemainingSec !== prevTrialSecRef.current) {
|
|
12
|
+
setShowTrialBadge(true);
|
|
13
|
+
}
|
|
10
14
|
}
|
|
15
|
+
prevTrialSecRef.current = trialRemainingSec;
|
|
11
16
|
}, [trialRemainingSec]);
|
|
12
17
|
const handleTrialSubscribe = useCallback(async () => {
|
|
13
18
|
try {
|
|
14
|
-
|
|
15
|
-
const deviceInfo = await getDeviceInfoRay(devId);
|
|
16
|
-
console.log('res===', deviceInfo, homeInfo);
|
|
17
|
-
gotoSecurityCloudService(homeInfo.homeId, deviceInfo.uuid);
|
|
19
|
+
await gotoSecurityCloudService2(devId);
|
|
18
20
|
} catch (error) {
|
|
19
|
-
console.log('res===handleTrialSubscribe error', error);
|
|
20
21
|
ty.showToast({
|
|
21
22
|
title: Strings.getLang('ipc_player_fetch_error'),
|
|
22
23
|
icon: 'none'
|
|
@@ -25,13 +26,21 @@ export const useTrialBadge = (event, devId, trialRemainingSec) => {
|
|
|
25
26
|
}, [devId]);
|
|
26
27
|
const handleCountdownEnd = useCallback(async () => {
|
|
27
28
|
try {
|
|
28
|
-
const getAI = await getAIFrameFeature(devId);
|
|
29
|
-
console.log('res===handleCountdownEnd', getAI);
|
|
30
|
-
setAIFrameFeature(devId, {
|
|
31
|
-
enabled: false,
|
|
32
|
-
aiFrameFeature: getAI.aiFrameFeature
|
|
33
|
-
});
|
|
34
29
|
setShowTrialBadge(false);
|
|
30
|
+
// const getAI = await getAIFrameFeature(devId);
|
|
31
|
+
// const scope = { ...getAI.aiFrameFeature?.scope, inPreview: false };
|
|
32
|
+
// await setAIFrameFeature({
|
|
33
|
+
// devId,
|
|
34
|
+
// scene: 'inPreview', // 实时预览场景
|
|
35
|
+
// enabled: getAI.enabled,
|
|
36
|
+
// aiFrameFeature: {
|
|
37
|
+
// scope,
|
|
38
|
+
// feature: getAI.aiFrameFeature?.feature,
|
|
39
|
+
// exportEnabled: getAI.aiFrameFeature?.exportEnabled,
|
|
40
|
+
// },
|
|
41
|
+
// });
|
|
42
|
+
await setTrailFinish(devId);
|
|
43
|
+
event.emit(trialCountdownEnd);
|
|
35
44
|
} catch (error) {
|
|
36
45
|
ty.showToast({
|
|
37
46
|
title: Strings.getLang('ipc_player_fetch_error'),
|
|
@@ -5,6 +5,11 @@ type Props = ComponentConfigProps & {
|
|
|
5
5
|
className?: string;
|
|
6
6
|
hideTryExperienceMenu?: boolean;
|
|
7
7
|
buttonState?: number;
|
|
8
|
+
trialRemainingSec?: number;
|
|
9
|
+
isPurchase?: boolean;
|
|
10
|
+
canOpenSettings?: boolean;
|
|
11
|
+
gRawData?: boolean;
|
|
12
|
+
isLowPhone?: boolean;
|
|
8
13
|
};
|
|
9
14
|
export declare const TryExperience: (props: Props) => React.JSX.Element | null;
|
|
10
15
|
export {};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import { View, Image, getSystemInfoSync, showToast } from '@ray-js/ray';
|
|
2
3
|
import clsx from 'clsx';
|
|
3
|
-
import React from 'react';
|
|
4
|
+
import React, { useState, useEffect, useCallback, useRef } from 'react';
|
|
4
5
|
import { useStore } from '../../ctx/store';
|
|
5
|
-
import
|
|
6
|
+
import Strings from '../../i18n';
|
|
7
|
+
import { getAIFrameFeature, gotoAIDrawMiniProgram, setAIFrameFeature } from '../../utils';
|
|
8
|
+
import { refreshSmartImageQualityEvent } from '../../ui/constant';
|
|
6
9
|
import tryZh from '../../res/try/try_zh.png';
|
|
7
10
|
import tryEn from '../../res/try/try_en.png';
|
|
8
11
|
import tryOpen from '../../res/try/try_open.png';
|
|
@@ -33,36 +36,129 @@ const pickIconByStatus = buttonState => {
|
|
|
33
36
|
case TryExperienceStatus.Close:
|
|
34
37
|
return tryClose;
|
|
35
38
|
case TryExperienceStatus.Default:
|
|
36
|
-
default:
|
|
37
39
|
return getDefaultLangIcon();
|
|
40
|
+
default:
|
|
41
|
+
return '';
|
|
38
42
|
}
|
|
39
43
|
};
|
|
40
44
|
export const TryExperience = props => {
|
|
41
45
|
const {
|
|
42
46
|
className,
|
|
43
47
|
hideTryExperienceMenu,
|
|
44
|
-
buttonState
|
|
48
|
+
buttonState,
|
|
49
|
+
trialRemainingSec,
|
|
50
|
+
isPurchase,
|
|
51
|
+
canOpenSettings,
|
|
52
|
+
gRawData,
|
|
53
|
+
isLowPhone,
|
|
54
|
+
devId
|
|
45
55
|
} = props;
|
|
46
56
|
const {
|
|
47
|
-
brandColor
|
|
57
|
+
brandColor,
|
|
58
|
+
recording
|
|
48
59
|
} = useStore({
|
|
49
|
-
brandColor: props.brandColor
|
|
60
|
+
brandColor: props.brandColor,
|
|
61
|
+
recording: props.recording
|
|
50
62
|
});
|
|
51
|
-
const
|
|
63
|
+
const [imgSrc, setImgSrc] = useState();
|
|
64
|
+
const lockRef = useRef(false);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
updateImgSrc();
|
|
67
|
+
}, [buttonState]);
|
|
68
|
+
const updateImgSrc = useCallback(() => {
|
|
69
|
+
if (isLowPhone) {
|
|
70
|
+
setImgSrc(tryClose);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (buttonState === 0 || buttonState) {
|
|
74
|
+
const iconUrl = pickIconByStatus(buttonState);
|
|
75
|
+
setImgSrc(iconUrl);
|
|
76
|
+
} else {
|
|
77
|
+
setImgSrc(undefined);
|
|
78
|
+
}
|
|
79
|
+
}, [buttonState]);
|
|
80
|
+
const onTryExperience = useCallback(async () => {
|
|
81
|
+
console.log('res===onTryExperience', lockRef.current, isLowPhone);
|
|
82
|
+
if (lockRef.current) return;
|
|
83
|
+
if (isLowPhone) {
|
|
84
|
+
showToast({
|
|
85
|
+
title: Strings.getLang('ipc_player_low_phone_not_support'),
|
|
86
|
+
icon: 'none'
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (recording) {
|
|
91
|
+
showToast({
|
|
92
|
+
title: Strings.getLang('ipc_player_recording_now_tip'),
|
|
93
|
+
icon: 'none'
|
|
94
|
+
});
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
lockRef.current = true;
|
|
98
|
+
try {
|
|
99
|
+
if (buttonState === TryExperienceStatus.Open) {
|
|
100
|
+
var _getAI$aiFrameFeature, _getAI$aiFrameFeature2, _getAI$aiFrameFeature3, _props$event;
|
|
101
|
+
const getAI = await getAIFrameFeature(devId);
|
|
102
|
+
if (!getAI) return;
|
|
103
|
+
// 由开变关的时候,只关inPreview
|
|
104
|
+
const scope = _objectSpread(_objectSpread({}, (_getAI$aiFrameFeature = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature === void 0 ? void 0 : _getAI$aiFrameFeature.scope), {}, {
|
|
105
|
+
inPreview: false
|
|
106
|
+
});
|
|
107
|
+
await setAIFrameFeature({
|
|
108
|
+
devId,
|
|
109
|
+
scene: 'inPreview',
|
|
110
|
+
// 实时预览场景
|
|
111
|
+
enabled: getAI.enabled,
|
|
112
|
+
aiFrameFeature: {
|
|
113
|
+
scope,
|
|
114
|
+
feature: (_getAI$aiFrameFeature2 = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature2 === void 0 ? void 0 : _getAI$aiFrameFeature2.feature,
|
|
115
|
+
exportEnabled: (_getAI$aiFrameFeature3 = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature3 === void 0 ? void 0 : _getAI$aiFrameFeature3.exportEnabled
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
(_props$event = props.event) === null || _props$event === void 0 || _props$event.emit(refreshSmartImageQualityEvent);
|
|
119
|
+
} else if (buttonState === TryExperienceStatus.Close && isPurchase || buttonState === TryExperienceStatus.Close && trialRemainingSec < 300 && trialRemainingSec > 0) {
|
|
120
|
+
var _getAI$aiFrameFeature4, _getAI$aiFrameFeature5, _getAI$aiFrameFeature6, _props$event2;
|
|
121
|
+
const getAI = await getAIFrameFeature(devId);
|
|
122
|
+
if (!getAI) return;
|
|
123
|
+
const scope = _objectSpread(_objectSpread({}, (_getAI$aiFrameFeature4 = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature4 === void 0 ? void 0 : _getAI$aiFrameFeature4.scope), {}, {
|
|
124
|
+
inPreview: true
|
|
125
|
+
});
|
|
126
|
+
// 由关变开的时候,enabled和inPreview两个都开
|
|
127
|
+
await setAIFrameFeature({
|
|
128
|
+
devId,
|
|
129
|
+
scene: 'inPreview',
|
|
130
|
+
// 实时预览场景
|
|
131
|
+
enabled: true,
|
|
132
|
+
aiFrameFeature: {
|
|
133
|
+
scope,
|
|
134
|
+
feature: (_getAI$aiFrameFeature5 = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature5 === void 0 ? void 0 : _getAI$aiFrameFeature5.feature,
|
|
135
|
+
exportEnabled: (_getAI$aiFrameFeature6 = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature6 === void 0 ? void 0 : _getAI$aiFrameFeature6.exportEnabled
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
(_props$event2 = props.event) === null || _props$event2 === void 0 || _props$event2.emit(refreshSmartImageQualityEvent);
|
|
139
|
+
} else {
|
|
140
|
+
gotoAIDrawMiniProgram(devId, brandColor);
|
|
141
|
+
}
|
|
142
|
+
} catch (error) {
|
|
143
|
+
//
|
|
144
|
+
} finally {
|
|
145
|
+
lockRef.current = false;
|
|
146
|
+
}
|
|
147
|
+
}, [buttonState, recording, isPurchase, trialRemainingSec]);
|
|
52
148
|
if (hideTryExperienceMenu) {
|
|
53
149
|
return null;
|
|
54
150
|
}
|
|
151
|
+
if (!imgSrc || !canOpenSettings || !gRawData) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
55
154
|
return /*#__PURE__*/React.createElement(View, {
|
|
56
155
|
className: clsx(className),
|
|
57
|
-
onClick:
|
|
58
|
-
console.log('res===onTryExperience', props.devId, brandColor);
|
|
59
|
-
gotoAIDrawMiniProgram(props.devId, brandColor);
|
|
60
|
-
}
|
|
156
|
+
onClick: onTryExperience
|
|
61
157
|
}, /*#__PURE__*/React.createElement(View, {
|
|
62
158
|
className: "try-experience-box"
|
|
63
159
|
}, /*#__PURE__*/React.createElement(Image, {
|
|
64
160
|
className: "try-experience-icon",
|
|
65
|
-
src:
|
|
161
|
+
src: imgSrc,
|
|
66
162
|
mode: "heightFix"
|
|
67
163
|
})));
|
|
68
164
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/ipc-player-integration",
|
|
3
|
-
"version": "0.0.35-beta.
|
|
3
|
+
"version": "0.0.35-beta.30",
|
|
4
4
|
"description": "IPC 融合播放器",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"files": [
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@ray-js/direction-control": "^0.0.8",
|
|
39
39
|
"@ray-js/ipc-ptz-zoom": "^0.0.3",
|
|
40
|
-
"@ray-js/ray-ipc-player": "2.1.1
|
|
40
|
+
"@ray-js/ray-ipc-player": "^2.1.1",
|
|
41
41
|
"@ray-js/ray-ipc-utils": "^1.1.15",
|
|
42
42
|
"@ray-js/svg": "0.2.0",
|
|
43
43
|
"clsx": "^1.2.1",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"husky": {
|
|
65
65
|
"hooks": {
|
|
66
66
|
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS --config commitlint.config.js",
|
|
67
|
-
"pre-commit": "lint-staged"
|
|
67
|
+
"pre-commit": "node ./scripts/check-protected-files.js && lint-staged"
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
70
|
"lint-staged": {
|