@ray-js/ipc-player-integration 0.0.1-beta-51 → 0.0.1-beta-52
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/plugins/battery/battery.composition.js +3 -3
- package/lib/plugins/battery/batteryFull.d.ts +1 -1
- package/lib/plugins/battery/batteryFull.js +19 -6
- package/lib/plugins/fullScreen/fullScreen.d.ts +2 -1
- package/lib/plugins/fullScreen/fullScreen.less +4 -0
- package/lib/plugins/fullScreen/fullTravelRouteControl.d.ts +4 -3
- package/lib/plugins/fullScreen/fullTravelRouteControl.js +36 -12
- package/lib/plugins/resolution/resolution.js +2 -4
- package/lib/ui/bottomLeftContent.js +4 -1
- package/lib/ui/bottomRightContent.js +4 -1
- package/lib/ui/topLeftContent.js +4 -1
- package/lib/utils/device/index.js +5 -1
- package/lib/utils/plugins/index.d.ts +1 -0
- package/lib/utils/plugins/index.js +2 -1
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createBattery } from './battery';
|
|
2
|
-
import { createBatteryFull } from './batteryFull';
|
|
2
|
+
import { createBattery as createBatteryFull } from './batteryFull';
|
|
3
3
|
import { useBattery } from '../../hooks';
|
|
4
4
|
export const Battery = createBattery({
|
|
5
|
-
useBattery
|
|
5
|
+
useBattery
|
|
6
6
|
});
|
|
7
7
|
export const BatteryFull = createBatteryFull({
|
|
8
|
-
useBattery
|
|
8
|
+
useBattery
|
|
9
9
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
import { View, Text } from '@ray-js/ray';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { useStore } from '../../ctx/store';
|
|
5
5
|
import './battery.less';
|
|
6
|
-
export const
|
|
6
|
+
export const createBattery = _ref => {
|
|
7
7
|
let {
|
|
8
8
|
useBattery
|
|
9
9
|
} = _ref;
|
|
10
|
-
return props => {
|
|
10
|
+
return /*#__PURE__*/React.memo(props => {
|
|
11
11
|
const {
|
|
12
12
|
className,
|
|
13
13
|
devId
|
|
@@ -21,6 +21,16 @@ export const createBatteryFull = _ref => {
|
|
|
21
21
|
batteryValue,
|
|
22
22
|
batteryCharging
|
|
23
23
|
} = useBattery(devId);
|
|
24
|
+
const batteryColor = useMemo(() => {
|
|
25
|
+
if (!batteryValue) return '#eb3223';
|
|
26
|
+
if (batteryValue >= 60) {
|
|
27
|
+
return '#5cc83b';
|
|
28
|
+
}
|
|
29
|
+
if (batteryValue >= 30) {
|
|
30
|
+
return '#f8cd46';
|
|
31
|
+
}
|
|
32
|
+
return '#eb3223';
|
|
33
|
+
}, [batteryValue]);
|
|
24
34
|
if (batteryValue === undefined || screenType === 'vertical') {
|
|
25
35
|
return null;
|
|
26
36
|
}
|
|
@@ -28,7 +38,9 @@ export const createBatteryFull = _ref => {
|
|
|
28
38
|
className: clsx(className)
|
|
29
39
|
}, /*#__PURE__*/React.createElement(View, {
|
|
30
40
|
className: "ipc-player-plugin-battery"
|
|
31
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
41
|
+
}, batteryCharging ? /*#__PURE__*/React.createElement(View, {
|
|
42
|
+
className: "icon-panel icon-panel-charging ipc-player-plugin-battery-charging"
|
|
43
|
+
}) : /*#__PURE__*/React.createElement(View, {
|
|
32
44
|
className: "ipc-player-plugin-battery-border"
|
|
33
45
|
}, /*#__PURE__*/React.createElement(View, {
|
|
34
46
|
className: "ipc-player-plugin-battery-border-1"
|
|
@@ -36,11 +48,12 @@ export const createBatteryFull = _ref => {
|
|
|
36
48
|
className: "ipc-player-plugin-battery-value-wrap"
|
|
37
49
|
}, /*#__PURE__*/React.createElement(View, {
|
|
38
50
|
style: {
|
|
39
|
-
width: `${batteryValue}
|
|
51
|
+
width: `${batteryValue}%`,
|
|
52
|
+
backgroundColor: batteryColor
|
|
40
53
|
},
|
|
41
54
|
className: "ipc-player-plugin-battery-value-value"
|
|
42
55
|
}))), /*#__PURE__*/React.createElement(Text, {
|
|
43
56
|
className: "ipc-player-plugin-battery-text"
|
|
44
57
|
}, batteryValue, "%")));
|
|
45
|
-
};
|
|
58
|
+
});
|
|
46
59
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { FullTravelRouteControlProps } from './fullTravelRouteControl';
|
|
2
3
|
import './fullScreen.less';
|
|
3
4
|
import type { ComponentConfigProps } from '../../interface';
|
|
4
5
|
type Props = ComponentConfigProps & {
|
|
5
6
|
className?: string;
|
|
6
7
|
hideHorizontalMenu?: boolean;
|
|
7
|
-
}
|
|
8
|
+
} & Pick<FullTravelRouteControlProps, 'throttleTime'>;
|
|
8
9
|
export declare function FullScreen(props: Props): React.JSX.Element | null;
|
|
9
10
|
export {};
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
.ipc-player-plugin-full-screen-voice {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
align-items: flex-end;
|
|
23
|
+
justify-content: center;
|
|
20
24
|
transform: translate(0, 0);
|
|
21
25
|
transition: transform ease-in 0.3s;
|
|
22
26
|
&.ipc-player-plugin-full-screen-voice-hide {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import type { ComponentConfigProps } from '../../interface';
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export type FullTravelRouteControlProps = ComponentConfigProps & {
|
|
7
|
+
throttleTime?: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function FullTravelRouteControl(props: FullTravelRouteControlProps): React.JSX.Element;
|
|
@@ -6,7 +6,7 @@ import React, { useEffect, useContext, useState, useRef } from 'react';
|
|
|
6
6
|
import { View } from '@ray-js/ray';
|
|
7
7
|
import clsx from 'clsx';
|
|
8
8
|
import RectDirectionControl from '@ray-js/direction-control';
|
|
9
|
-
import {
|
|
9
|
+
import { useThrottleFn, useMemoizedFn } from 'ahooks';
|
|
10
10
|
import { UIEventContext } from '../../ui/context';
|
|
11
11
|
import { useDpState } from '../../hooks';
|
|
12
12
|
import { useComponentHideState } from '../../ui/hooks';
|
|
@@ -14,6 +14,9 @@ import { pauseTimeToHideAllComponent, startTimeToHideAllComponent } from '../../
|
|
|
14
14
|
import { DIRECTION_CONTROL_DP_CODE } from './constant';
|
|
15
15
|
import { useStore } from '../../ctx/store';
|
|
16
16
|
export function FullTravelRouteControl(props) {
|
|
17
|
+
const {
|
|
18
|
+
throttleTime = 300
|
|
19
|
+
} = props;
|
|
17
20
|
const [shouldHide] = useComponentHideState();
|
|
18
21
|
const [isPtzActive, setIsPtzActive] = useState(false);
|
|
19
22
|
const {
|
|
@@ -25,11 +28,14 @@ export function FullTravelRouteControl(props) {
|
|
|
25
28
|
} = useStore({
|
|
26
29
|
brandColor: props.brandColor
|
|
27
30
|
});
|
|
31
|
+
const timerRef = useRef();
|
|
32
|
+
const [touching, setTouching] = useState(false);
|
|
28
33
|
const [state, _, sendDp] = useDpState({
|
|
29
34
|
devId: props.devId,
|
|
30
35
|
dpCodes: [DIRECTION_CONTROL_DP_CODE],
|
|
31
36
|
listenDpChange: true
|
|
32
37
|
});
|
|
38
|
+
console.log('touching', touching);
|
|
33
39
|
const onPtzControlShow = useMemoizedFn(() => {
|
|
34
40
|
setIsPtzActive(true);
|
|
35
41
|
});
|
|
@@ -44,39 +50,57 @@ export function FullTravelRouteControl(props) {
|
|
|
44
50
|
event.off('ptzControlHide', onPtzControlHide);
|
|
45
51
|
};
|
|
46
52
|
}, []);
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
const pauseTimeToHideAllComponentFn = () => {
|
|
54
|
+
if (timerRef.current) {
|
|
55
|
+
clearTimeout(timerRef.current);
|
|
56
|
+
}
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
timerRef.current = setTimeout(() => {
|
|
59
|
+
event.emit(pauseTimeToHideAllComponent);
|
|
60
|
+
}, 300);
|
|
50
61
|
};
|
|
51
62
|
const {
|
|
52
63
|
run: sendDpValue
|
|
53
|
-
} =
|
|
64
|
+
} = useThrottleFn(value => {
|
|
54
65
|
if (value === prevRotate.current) return;
|
|
55
66
|
sendDp({
|
|
56
67
|
[DIRECTION_CONTROL_DP_CODE]: value
|
|
57
68
|
});
|
|
58
69
|
prevRotate.current = value;
|
|
59
70
|
}, {
|
|
60
|
-
wait:
|
|
61
|
-
leading:
|
|
62
|
-
trailing:
|
|
71
|
+
wait: throttleTime,
|
|
72
|
+
leading: true,
|
|
73
|
+
trailing: true
|
|
63
74
|
});
|
|
64
75
|
return /*#__PURE__*/React.createElement(View, {
|
|
65
76
|
className: clsx('ipc-player-plugin-full-screen-voice', {
|
|
66
77
|
'ipc-player-plugin-full-screen-voice-hide': shouldHide || isPtzActive
|
|
67
|
-
})
|
|
78
|
+
}),
|
|
79
|
+
style: {
|
|
80
|
+
width: touching ? '100vw' : 'auto',
|
|
81
|
+
height: touching ? '100vh' : 'auto',
|
|
82
|
+
backgroundColor: 'transparent'
|
|
83
|
+
}
|
|
68
84
|
}, /*#__PURE__*/React.createElement(RectDirectionControl, {
|
|
69
85
|
className: "ipc-plugin-full-travel-route-control",
|
|
70
86
|
value: 0,
|
|
71
87
|
onTouchStart: value => {
|
|
88
|
+
setTouching(true);
|
|
72
89
|
sendDpValue(String(value));
|
|
73
90
|
},
|
|
74
91
|
onTouchMove: value => {
|
|
75
|
-
|
|
92
|
+
setTouching(true);
|
|
93
|
+
pauseTimeToHideAllComponentFn();
|
|
76
94
|
sendDpValue(String(value));
|
|
77
95
|
},
|
|
78
|
-
onTouchEnd:
|
|
79
|
-
|
|
96
|
+
onTouchEnd: () => {
|
|
97
|
+
event.emit(startTimeToHideAllComponent);
|
|
98
|
+
setTouching(false);
|
|
99
|
+
sendDpValue('-1');
|
|
100
|
+
},
|
|
101
|
+
onMoveNonIntersection: () => {
|
|
102
|
+
sendDpValue('-1');
|
|
103
|
+
},
|
|
80
104
|
showArcOnTouchInEdgeProximity: true,
|
|
81
105
|
arcEdgeProximityColor: brandColor,
|
|
82
106
|
touchDistanceThreshold: 50
|
|
@@ -60,10 +60,8 @@ export const Resolution = props => {
|
|
|
60
60
|
}, /*#__PURE__*/React.createElement(View, {
|
|
61
61
|
className: clsx('ipc-player-plugin-resolution', {
|
|
62
62
|
'ipc-player-plugin-resolution-full': screenType === 'full'
|
|
63
|
-
})
|
|
64
|
-
onClick: onResolution
|
|
63
|
+
})
|
|
65
64
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
66
|
-
className: "resolutionText"
|
|
67
|
-
onClick: onResolution
|
|
65
|
+
className: "resolutionText"
|
|
68
66
|
}, Strings.getLang(`ipc_player_resolution_${resolution}`))));
|
|
69
67
|
};
|
|
@@ -16,7 +16,10 @@ const BottomLeftContent = _ref => {
|
|
|
16
16
|
});
|
|
17
17
|
const [shouldHide] = useComponentHideState();
|
|
18
18
|
return /*#__PURE__*/React.createElement(CoverView, {
|
|
19
|
-
className: clsx('ipc-player-bottom-left-content-wrap')
|
|
19
|
+
className: clsx('ipc-player-bottom-left-content-wrap'),
|
|
20
|
+
style: {
|
|
21
|
+
paddingRight: screenType === 'vertical' ? '0' : '50px'
|
|
22
|
+
}
|
|
20
23
|
}, /*#__PURE__*/React.createElement(View, {
|
|
21
24
|
style: {
|
|
22
25
|
paddingBottom: screenType === 'vertical' ? '14px' : '32px',
|
|
@@ -16,7 +16,10 @@ const BottomRightContent = _ref => {
|
|
|
16
16
|
});
|
|
17
17
|
const [shouldHide] = useComponentHideState();
|
|
18
18
|
return /*#__PURE__*/React.createElement(CoverView, {
|
|
19
|
-
className: clsx('ipc-player-bottom-right-content-wrap')
|
|
19
|
+
className: clsx('ipc-player-bottom-right-content-wrap'),
|
|
20
|
+
style: {
|
|
21
|
+
paddingLeft: screenType === 'vertical' ? '10px' : '0'
|
|
22
|
+
}
|
|
20
23
|
}, /*#__PURE__*/React.createElement(View, {
|
|
21
24
|
style: {
|
|
22
25
|
paddingBottom: screenType === 'vertical' ? '14px' : '32px',
|
package/lib/ui/topLeftContent.js
CHANGED
|
@@ -16,7 +16,10 @@ const TopLeftContent = _ref => {
|
|
|
16
16
|
});
|
|
17
17
|
const [shouldHide] = useComponentHideState();
|
|
18
18
|
return /*#__PURE__*/React.createElement(CoverView, {
|
|
19
|
-
className: clsx('ipc-player-top-left-content-wrap')
|
|
19
|
+
className: clsx('ipc-player-top-left-content-wrap'),
|
|
20
|
+
style: {
|
|
21
|
+
paddingRight: screenType === 'vertical' ? '0' : '20px'
|
|
22
|
+
}
|
|
20
23
|
}, /*#__PURE__*/React.createElement(View, {
|
|
21
24
|
style: {
|
|
22
25
|
paddingTop: screenType === 'vertical' ? '12px' : '16px',
|
|
@@ -144,7 +144,11 @@ export const getEnumRangeIsValid = async (devId, dpCode, rangValue) => {
|
|
|
144
144
|
export function hasDpCode(devId, code) {
|
|
145
145
|
return new Promise((resolve, reject) => {
|
|
146
146
|
getDeviceInfo(devId).then(res => {
|
|
147
|
-
|
|
147
|
+
const {
|
|
148
|
+
schema = []
|
|
149
|
+
} = res || {};
|
|
150
|
+
const target = schema.find(item => item.code === code);
|
|
151
|
+
resolve(!!target);
|
|
148
152
|
}, err => reject(err));
|
|
149
153
|
});
|
|
150
154
|
}
|
|
@@ -18,7 +18,8 @@ export async function initPlayerPlugins(ctx, options) {
|
|
|
18
18
|
const fullScreenIndex = newDefaultBottomRightContent.findIndex(item => item.id === 'FullScreen');
|
|
19
19
|
if (fullScreenIndex !== -1) {
|
|
20
20
|
newDefaultBottomRightContent[fullScreenIndex].initProps = {
|
|
21
|
-
hideHorizontalMenu: options.hideHorizontalMenu
|
|
21
|
+
hideHorizontalMenu: options.hideHorizontalMenu,
|
|
22
|
+
throttleTime: options.throttleTime
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
ctx.addContent('bottomRight', newDefaultBottomRightContent);
|