@ray-js/ipc-player-integration 0.0.71-beta.0 → 0.0.72-beta.0
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/README.md +0 -6
- package/lib/ctx/ctx.composition.d.ts +5 -1
- package/lib/ctx/ctx.composition.js +4 -1
- package/lib/ctx/ctx.js +17 -12
- package/lib/ctx/ctx.test.js +19 -54
- package/lib/features/initPlayerWidgets/index.d.ts +3 -0
- package/lib/features/initPlayerWidgets/index.js +4 -0
- package/lib/index.d.ts +0 -4
- package/lib/index.js +1 -3
- package/lib/interface.d.ts +1 -1
- package/lib/ui/bottomControlLayout.d.ts +11 -0
- package/lib/ui/bottomControlLayout.js +19 -0
- package/lib/ui/bottomControlLayout.test.js +64 -0
- package/lib/ui/bottomLeftContent.js +73 -180
- package/lib/ui/bottomLeftContent.test.js +138 -0
- package/lib/ui/bottomRightContent.d.ts +2 -2
- package/lib/ui/bottomRightContent.js +24 -16
- package/lib/ui/bottomRightContent.test.js +144 -0
- package/lib/ui/constant.d.ts +2 -0
- package/lib/ui/constant.js +4 -1
- package/lib/ui/topLeftContent.js +2 -4
- package/lib/ui/topRightContent.js +2 -4
- package/lib/ui/ui.d.ts +0 -5
- package/lib/ui/ui.js +33 -86
- package/lib/ui/ui.less +24 -59
- package/lib/widgets/battery/battery.js +5 -7
- package/lib/widgets/battery/batteryFull.js +5 -7
- package/lib/widgets/captureResult/captureResult.js +1 -2
- package/lib/widgets/floatWindow/floatWindow.d.ts +13 -0
- package/lib/widgets/floatWindow/floatWindow.js +93 -0
- package/lib/widgets/floatWindow/floatWindow.less +14 -0
- package/lib/widgets/floatWindow/floatWindow.test.d.ts +1 -0
- package/lib/widgets/floatWindow/floatWindow.test.js +164 -0
- package/lib/widgets/floatWindow/icon.d.ts +1 -0
- package/lib/widgets/floatWindow/icon.js +4 -0
- package/lib/widgets/floatWindow/index.d.ts +1 -0
- package/lib/widgets/floatWindow/index.js +1 -0
- package/lib/widgets/floodlight/floodlight.js +1 -2
- package/lib/widgets/flowLowTip/flowLowTip.js +1 -2
- package/lib/widgets/fullScreen/fullScreen.js +1 -2
- package/lib/widgets/fullScreen/fullTravelRouteControl.d.ts +1 -1
- package/lib/widgets/fullScreen/fullTravelRouteControl.js +1 -1
- package/lib/widgets/fullScreen/verticalScreen.js +1 -2
- package/lib/widgets/index.d.ts +1 -0
- package/lib/widgets/index.js +2 -1
- package/lib/widgets/moveInteractiveControl/controlButton.js +1 -2
- package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.js +5 -16
- package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.less +4 -24
- package/lib/widgets/multiCamera/landscapeTip.js +2 -8
- package/lib/widgets/multiCamera/moveablePtzControl.js +3 -5
- package/lib/widgets/multiCamera/multiPtz.js +1 -2
- package/lib/widgets/multiCamera/ptzMoveableTip.js +2 -8
- package/lib/widgets/multiCamera/switchLayout.js +1 -2
- package/lib/widgets/multiCamera/tileMultiPtz.js +1 -2
- package/lib/widgets/multiCamera/tileSwitchLayout.js +1 -2
- package/lib/widgets/multiCamera/tileTip.js +2 -8
- package/lib/widgets/muted/muted.js +1 -2
- package/lib/widgets/muted/muted.test.js +52 -66
- package/lib/widgets/ptz/ptz.js +1 -2
- package/lib/widgets/ptz/ptzControl.js +3 -4
- package/lib/widgets/ptzControlTip/ptzControlTip.js +4 -9
- package/lib/widgets/ptzControlTip/ptzControlTip.less +0 -6
- package/lib/widgets/realTimeMagnification/realTimeMagnification.js +1 -2
- package/lib/widgets/recordVideo/recordVideo.js +169 -47
- package/lib/widgets/recordVideo/recordVideo.lifecycle.test.js +2 -4
- package/lib/widgets/recordVideo/recordVideo.test.js +2 -169
- package/lib/widgets/resolution/fullResolutionControl.js +19 -29
- package/lib/widgets/resolution/resolution.js +2 -3
- package/lib/widgets/screenshot/screenshot.js +122 -48
- package/lib/widgets/screenshot/screenshot.test.js +113 -108
- package/lib/widgets/signal4G/signal4G.js +1 -4
- package/lib/widgets/siren/siren.js +1 -2
- package/lib/widgets/tempHumidity/tempHumidity.js +1 -2
- package/lib/widgets/toggleVerticalFull/toggleVerticalFull.js +1 -2
- package/lib/widgets/trialBadge/index.js +3 -8
- package/lib/widgets/trialBadge/index.less +0 -24
- package/lib/widgets/tryExperience/tryExperience.js +1 -2
- package/lib/widgets/videoBitKBP/videoBitKBP.js +1 -2
- package/lib/widgets/voiceIntercom/voiceIntercom.js +81 -57
- package/lib/widgets/voiceIntercom/voiceIntercom.less +0 -35
- package/lib/widgets/zoomTurntable/turntable/index.d.ts +7 -5
- package/lib/widgets/zoomTurntable/turntable/index.js +1 -3
- package/lib/widgets/zoomTurntable/zoomTurntableDock.d.ts +3 -5
- package/lib/widgets/zoomTurntable/zoomTurntableDock.js +4 -4
- package/lib/widgets/zoomTurntable/zoomTurntableEntry.js +19 -32
- package/lib/widgets/zoomTurntable/zoomTurntableTip.js +3 -17
- package/package.json +7 -15
- package/lib/ctx/intercom.test.js +0 -85
- package/lib/renderer/capabilities.d.ts +0 -8
- package/lib/renderer/capabilities.js +0 -19
- package/lib/renderer/context.d.ts +0 -5
- package/lib/renderer/context.js +0 -6
- package/lib/renderer/directionControl.d.ts +0 -6
- package/lib/renderer/directionControl.js +0 -3
- package/lib/renderer/font-manifest.json +0 -9
- package/lib/renderer/font.less +0 -5
- package/lib/renderer/glyphs.d.ts +0 -1
- package/lib/renderer/glyphs.js +0 -256
- package/lib/renderer/index.module.less +0 -48
- package/lib/renderer/overlay.d.ts +0 -6
- package/lib/renderer/overlay.js +0 -18
- package/lib/renderer/ptzZoom.d.ts +0 -6
- package/lib/renderer/ptzZoom.js +0 -3
- package/lib/renderer/text.d.ts +0 -4
- package/lib/renderer/text.js +0 -32
- package/lib/renderer/text.module.less +0 -4
- package/lib/renderer/viewport.d.ts +0 -7
- package/lib/renderer/viewport.js +0 -24
- package/lib/res/lynx-signal/index.d.ts +0 -1
- package/lib/res/lynx-signal/index.js +0 -22
- package/lib/res/lynx-signal/signalFour0.png +0 -0
- package/lib/res/lynx-signal/signalFour1.png +0 -0
- package/lib/res/lynx-signal/signalFour2.png +0 -0
- package/lib/res/lynx-signal/signalFour3.png +0 -0
- package/lib/res/lynx-signal/signalFour4.png +0 -0
- package/lib/res/lynx-signal/signalThree0.png +0 -0
- package/lib/res/lynx-signal/signalThree1.png +0 -0
- package/lib/res/lynx-signal/signalThree2.png +0 -0
- package/lib/res/lynx-signal/signalThree3.png +0 -0
- package/lib/res/player-charging.png +0 -0
- package/lib/res/player-more-arrow.png +0 -0
- package/lib/res/player-solar.png +0 -0
- package/lib/ui/scrollHintArrow.d.ts +0 -23
- package/lib/ui/scrollHintArrow.js +0 -83
- package/lib/widgets/battery/statusIcon.d.ts +0 -6
- package/lib/widgets/battery/statusIcon.js +0 -36
- package/lib/widgets/battery/statusIcon.less +0 -24
- package/lib/widgets/captureToast/captureToast.d.ts +0 -10
- package/lib/widgets/captureToast/captureToast.js +0 -58
- package/lib/widgets/recordVideo/recordVideoTimer.d.ts +0 -3
- package/lib/widgets/recordVideo/recordVideoTimer.js +0 -26
- package/lib/widgets/screenshot/screenshot.permissions.test.js +0 -137
- package/lib/widgets/voiceIntercom/voiceIntercom.test.js +0 -135
- package/lib/widgets/zoomTurntable/lynxDockLayout.d.ts +0 -6
- package/lib/widgets/zoomTurntable/lynxDockLayout.js +0 -30
- package/lib/widgets/zoomTurntable/turntable/lynx.d.ts +0 -5
- package/lib/widgets/zoomTurntable/turntable/lynx.js +0 -273
- package/lib/widgets/zoomTurntable/turntable/lynx.less +0 -9
- package/lib/widgets/zoomTurntable/turntable/lynxModel.d.ts +0 -37
- package/lib/widgets/zoomTurntable/turntable/lynxModel.js +0 -122
- package/lib/widgets/zoomTurntable/turntable/lynxPaint.d.ts +0 -3
- package/lib/widgets/zoomTurntable/turntable/lynxPaint.js +0 -36
- /package/lib/{ctx/intercom.test.d.ts → ui/bottomControlLayout.test.d.ts} +0 -0
- /package/lib/{widgets/screenshot/screenshot.permissions.test.d.ts → ui/bottomLeftContent.test.d.ts} +0 -0
- /package/lib/{widgets/voiceIntercom/voiceIntercom.test.d.ts → ui/bottomRightContent.test.d.ts} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import React, { useEffect, useRef } from 'react';
|
|
3
|
-
import { View } from '@ray-js/ray';
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { CoverView, View } from '@ray-js/ray';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
|
-
import { usePlayerOverlayHost } from '../renderer/overlay';
|
|
6
|
-
import { usePlayerRenderMode } from '../renderer/context';
|
|
7
5
|
import { useStore } from '../ctx/store';
|
|
8
6
|
import { useComponentHideState } from './hooks';
|
|
9
7
|
import { getBottomCoverHeight } from './bottomCoverHeight';
|
|
8
|
+
import { getOccupiedRightWidth } from './bottomControlLayout';
|
|
9
|
+
import { bottomRightContentResize } from './constant';
|
|
10
10
|
|
|
11
11
|
// 用唯一 className 在 createSelectorQuery 中区分多个实例,避免互相干扰
|
|
12
12
|
let rightClsSeq = 0;
|
|
@@ -17,7 +17,6 @@ const BottomRightContent = _ref => {
|
|
|
17
17
|
width,
|
|
18
18
|
onWidthChange
|
|
19
19
|
} = _ref;
|
|
20
|
-
const OverlayView = usePlayerOverlayHost();
|
|
21
20
|
const {
|
|
22
21
|
screenType,
|
|
23
22
|
isVerticalFullLayout,
|
|
@@ -30,39 +29,48 @@ const BottomRightContent = _ref => {
|
|
|
30
29
|
bottomRightContent: ctx.bottomRightContent
|
|
31
30
|
});
|
|
32
31
|
const [shouldHide] = useComponentHideState();
|
|
33
|
-
const renderMode = usePlayerRenderMode();
|
|
34
32
|
const idRef = useRef(++rightClsSeq);
|
|
35
33
|
const wrapCls = `ipc-br-wrap-${idRef.current}`;
|
|
36
|
-
const lastWidthRef = useRef(
|
|
34
|
+
const lastWidthRef = useRef(null);
|
|
35
|
+
const [resizeSignal, setResizeSignal] = useState(0);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
const resize = () => setResizeSignal(value => value + 1);
|
|
38
|
+
ctx.event.on(bottomRightContentResize, resize);
|
|
39
|
+
return () => ctx.event.off(bottomRightContentResize, resize);
|
|
40
|
+
}, [ctx.event]);
|
|
37
41
|
|
|
38
42
|
// 实测自身宽度并上报。按钮是异步 / 按 dp 条件渲染的,宽度会在首测之后才长大,
|
|
39
43
|
// 因此和左下角一样在时间窗内轮询,值没变时不重复上报。
|
|
40
44
|
useEffect(() => {
|
|
41
45
|
let timer;
|
|
42
46
|
let attempts = 0;
|
|
47
|
+
let active = true;
|
|
48
|
+
lastWidthRef.current = null;
|
|
49
|
+
onWidthChange === null || onWidthChange === void 0 || onWidthChange(null);
|
|
43
50
|
const measure = () => {
|
|
44
51
|
const query = ty.createSelectorQuery();
|
|
45
52
|
query.select(`.${wrapCls}`).boundingClientRect();
|
|
53
|
+
query.selectAll(`.${wrapCls} .bottom-right-item-container`).boundingClientRect();
|
|
46
54
|
query.exec(res => {
|
|
47
|
-
|
|
48
|
-
const w = (res === null || res === void 0
|
|
49
|
-
if (w
|
|
55
|
+
if (!active) return;
|
|
56
|
+
const w = getOccupiedRightWidth(res === null || res === void 0 ? void 0 : res[0], res === null || res === void 0 ? void 0 : res[1]);
|
|
57
|
+
if (w !== undefined && (lastWidthRef.current === null || Math.abs(w - lastWidthRef.current) >= 1)) {
|
|
50
58
|
lastWidthRef.current = w;
|
|
51
59
|
onWidthChange === null || onWidthChange === void 0 || onWidthChange(w);
|
|
52
60
|
}
|
|
53
61
|
attempts += 1;
|
|
54
|
-
|
|
55
|
-
if (attempts >= (renderMode === 'lynx' ? 20 : 15)) {
|
|
62
|
+
if (attempts >= 15) {
|
|
56
63
|
return;
|
|
57
64
|
}
|
|
58
|
-
timer = setTimeout(measure,
|
|
65
|
+
timer = setTimeout(measure, 400);
|
|
59
66
|
});
|
|
60
67
|
};
|
|
61
68
|
timer = setTimeout(measure, 60);
|
|
62
69
|
return () => {
|
|
70
|
+
active = false;
|
|
63
71
|
if (timer) clearTimeout(timer);
|
|
64
72
|
};
|
|
65
|
-
}, [screenType, playState, bottomRightContent
|
|
73
|
+
}, [screenType, playState, bottomRightContent, shouldHide, wrapCls, onWidthChange, resizeSignal]);
|
|
66
74
|
const containerHeight = screenType === 'vertical' ? 48 : 58;
|
|
67
75
|
const coverHeight = getBottomCoverHeight(screenType, isVerticalFullLayout, shouldHide);
|
|
68
76
|
|
|
@@ -75,11 +83,11 @@ const BottomRightContent = _ref => {
|
|
|
75
83
|
width,
|
|
76
84
|
boxSizing: 'border-box'
|
|
77
85
|
} : null;
|
|
78
|
-
return /*#__PURE__*/React.createElement(
|
|
86
|
+
return /*#__PURE__*/React.createElement(CoverView, {
|
|
79
87
|
className: clsx('ipc-player-bottom-right-content-wrap', wrapCls),
|
|
80
88
|
style: _objectSpread({
|
|
81
89
|
// 竖屏归 0:这 10px 是纯空白,且计入实测宽后又被 reservedRight 带给左下角,
|
|
82
|
-
// 等于左下角白让 10px
|
|
90
|
+
// 等于左下角白让 10px。安全距离由左侧视口单独预留。
|
|
83
91
|
paddingLeft: '0',
|
|
84
92
|
height: `${coverHeight}px`,
|
|
85
93
|
boxSizing: 'border-box'
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import { act } from 'react-dom/test-utils';
|
|
4
|
+
import { atom } from 'jotai';
|
|
5
|
+
import BottomRightContent from './bottomRightContent';
|
|
6
|
+
import { bottomRightContentResize } from './constant';
|
|
7
|
+
jest.mock('@ray-js/ray', () => ({
|
|
8
|
+
View: 'div',
|
|
9
|
+
CoverView: 'div'
|
|
10
|
+
}));
|
|
11
|
+
jest.mock('./hooks', () => ({
|
|
12
|
+
useComponentHideState: () => [false]
|
|
13
|
+
}));
|
|
14
|
+
describe('actual right-control measurement', () => {
|
|
15
|
+
let container;
|
|
16
|
+
let resize;
|
|
17
|
+
let ctx;
|
|
18
|
+
let result;
|
|
19
|
+
let pending;
|
|
20
|
+
let callback;
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
jest.useFakeTimers();
|
|
23
|
+
container = document.createElement('div');
|
|
24
|
+
document.body.appendChild(container);
|
|
25
|
+
callback = jest.fn();
|
|
26
|
+
result = [{
|
|
27
|
+
left: 400,
|
|
28
|
+
right: 800,
|
|
29
|
+
width: 400
|
|
30
|
+
}, [{
|
|
31
|
+
left: 680,
|
|
32
|
+
right: 800,
|
|
33
|
+
width: 120
|
|
34
|
+
}]];
|
|
35
|
+
global.ty = {
|
|
36
|
+
createSelectorQuery: () => {
|
|
37
|
+
const query = {
|
|
38
|
+
select: () => query,
|
|
39
|
+
selectAll: () => query,
|
|
40
|
+
boundingClientRect: () => query,
|
|
41
|
+
exec: cb => {
|
|
42
|
+
if (result) cb(result);else pending = cb;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
return query;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
ctx = {
|
|
49
|
+
screenType: atom('full'),
|
|
50
|
+
isVerticalFullLayout: atom(false),
|
|
51
|
+
playState: atom(1),
|
|
52
|
+
bottomRightContent: atom([]),
|
|
53
|
+
event: {
|
|
54
|
+
on: jest.fn((name, cb) => {
|
|
55
|
+
if (name === bottomRightContentResize) resize = cb;
|
|
56
|
+
}),
|
|
57
|
+
off: jest.fn()
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
afterEach(() => {
|
|
62
|
+
act(() => {
|
|
63
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
64
|
+
});
|
|
65
|
+
container.remove();
|
|
66
|
+
jest.clearAllTimers();
|
|
67
|
+
jest.useRealTimers();
|
|
68
|
+
});
|
|
69
|
+
const render = () => act(() => {
|
|
70
|
+
ReactDOM.render(/*#__PURE__*/React.createElement(BottomRightContent, {
|
|
71
|
+
ctx: ctx,
|
|
72
|
+
width: "40%",
|
|
73
|
+
onWidthChange: callback
|
|
74
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
75
|
+
className: "bottom-right-item-container"
|
|
76
|
+
})), container);
|
|
77
|
+
});
|
|
78
|
+
it('measures occupied buttons while keeping the right group in its existing 40% wrapper', () => {
|
|
79
|
+
render();
|
|
80
|
+
act(() => {
|
|
81
|
+
jest.advanceTimersByTime(60);
|
|
82
|
+
});
|
|
83
|
+
expect(callback).toHaveBeenLastCalledWith(120);
|
|
84
|
+
expect(container.firstChild.style.width).toBe('40%');
|
|
85
|
+
});
|
|
86
|
+
it('remeasures a visibility change after polling has finished and clears stale width first', () => {
|
|
87
|
+
render();
|
|
88
|
+
act(() => {
|
|
89
|
+
jest.advanceTimersByTime(6500);
|
|
90
|
+
});
|
|
91
|
+
result = [{
|
|
92
|
+
left: 400,
|
|
93
|
+
right: 800,
|
|
94
|
+
width: 400
|
|
95
|
+
}, [{
|
|
96
|
+
left: 640,
|
|
97
|
+
right: 800,
|
|
98
|
+
width: 160
|
|
99
|
+
}]];
|
|
100
|
+
act(() => resize());
|
|
101
|
+
expect(callback).toHaveBeenLastCalledWith(null);
|
|
102
|
+
act(() => {
|
|
103
|
+
jest.advanceTimersByTime(60);
|
|
104
|
+
});
|
|
105
|
+
expect(callback).toHaveBeenLastCalledWith(160);
|
|
106
|
+
});
|
|
107
|
+
it('reports an empty group instead of keeping the last nonempty width', () => {
|
|
108
|
+
render();
|
|
109
|
+
act(() => {
|
|
110
|
+
jest.advanceTimersByTime(60);
|
|
111
|
+
});
|
|
112
|
+
result = [{
|
|
113
|
+
left: 400,
|
|
114
|
+
right: 800,
|
|
115
|
+
width: 400
|
|
116
|
+
}, []];
|
|
117
|
+
act(() => resize());
|
|
118
|
+
act(() => {
|
|
119
|
+
jest.advanceTimersByTime(60);
|
|
120
|
+
});
|
|
121
|
+
expect(callback).toHaveBeenLastCalledWith(0);
|
|
122
|
+
});
|
|
123
|
+
it('ignores a measurement callback after unmount', () => {
|
|
124
|
+
result = undefined;
|
|
125
|
+
render();
|
|
126
|
+
act(() => {
|
|
127
|
+
jest.advanceTimersByTime(60);
|
|
128
|
+
});
|
|
129
|
+
act(() => {
|
|
130
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
131
|
+
});
|
|
132
|
+
callback.mockClear();
|
|
133
|
+
act(() => pending([{
|
|
134
|
+
left: 400,
|
|
135
|
+
right: 800,
|
|
136
|
+
width: 400
|
|
137
|
+
}, [{
|
|
138
|
+
left: 680,
|
|
139
|
+
right: 800,
|
|
140
|
+
width: 120
|
|
141
|
+
}]]));
|
|
142
|
+
expect(callback).not.toHaveBeenCalled();
|
|
143
|
+
});
|
|
144
|
+
});
|
package/lib/ui/constant.d.ts
CHANGED
package/lib/ui/constant.js
CHANGED
|
@@ -78,4 +78,7 @@ export const decodeClarityDic = {
|
|
|
78
78
|
AUTO: 'auto',
|
|
79
79
|
// 自动
|
|
80
80
|
AUDIO: 'audio' // 音频模式
|
|
81
|
-
};
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/** A right-hand widget changed its actual visibility without changing the content list. */
|
|
84
|
+
export const bottomRightContentResize = 'bottomRightContentResize';
|
package/lib/ui/topLeftContent.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { View } from '@ray-js/ray';
|
|
2
|
+
import { CoverView, View } from '@ray-js/ray';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import { usePlayerOverlayHost } from '../renderer/overlay';
|
|
5
4
|
import { useStore } from '../ctx/store';
|
|
6
5
|
import { useComponentHideState } from './hooks';
|
|
7
6
|
const TopLeftContent = _ref => {
|
|
@@ -9,7 +8,6 @@ const TopLeftContent = _ref => {
|
|
|
9
8
|
ctx,
|
|
10
9
|
children
|
|
11
10
|
} = _ref;
|
|
12
|
-
const OverlayView = usePlayerOverlayHost();
|
|
13
11
|
const {
|
|
14
12
|
screenType
|
|
15
13
|
} = useStore({
|
|
@@ -17,7 +15,7 @@ const TopLeftContent = _ref => {
|
|
|
17
15
|
playState: ctx.playState
|
|
18
16
|
});
|
|
19
17
|
const [shouldHide] = useComponentHideState();
|
|
20
|
-
return /*#__PURE__*/React.createElement(
|
|
18
|
+
return /*#__PURE__*/React.createElement(CoverView, {
|
|
21
19
|
className: clsx('ipc-player-top-left-content-wrap'),
|
|
22
20
|
style: {
|
|
23
21
|
paddingRight: screenType === 'vertical' ? '0' : '20px',
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { View } from '@ray-js/ray';
|
|
2
|
+
import { CoverView, View } from '@ray-js/ray';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import { usePlayerOverlayHost } from '../renderer/overlay';
|
|
5
4
|
import { useStore } from '../ctx/store';
|
|
6
5
|
import { useComponentHideState } from './hooks';
|
|
7
6
|
const TopRightContent = _ref => {
|
|
@@ -9,7 +8,6 @@ const TopRightContent = _ref => {
|
|
|
9
8
|
ctx,
|
|
10
9
|
children
|
|
11
10
|
} = _ref;
|
|
12
|
-
const OverlayView = usePlayerOverlayHost();
|
|
13
11
|
const {
|
|
14
12
|
screenType
|
|
15
13
|
} = useStore({
|
|
@@ -17,7 +15,7 @@ const TopRightContent = _ref => {
|
|
|
17
15
|
playState: ctx.playState
|
|
18
16
|
});
|
|
19
17
|
const [shouldHide] = useComponentHideState();
|
|
20
|
-
return /*#__PURE__*/React.createElement(
|
|
18
|
+
return /*#__PURE__*/React.createElement(CoverView, {
|
|
21
19
|
className: clsx('ipc-player-top-right-content-wrap'),
|
|
22
20
|
style: {
|
|
23
21
|
height: screenType === 'vertical' ? shouldHide ? '37px' : '36px' : shouldHide ? '41px' : '40px'
|
package/lib/ui/ui.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PlayerRenderMode } from '../renderer/context';
|
|
3
|
-
import { LynxPlayerAdapters } from '../renderer/capabilities';
|
|
4
2
|
import { PlayStatusData, UseCtx, EventInstance } from '../interface';
|
|
5
3
|
import './ui.less';
|
|
6
4
|
type CtxInstance = ReturnType<UseCtx>;
|
|
@@ -16,9 +14,6 @@ type CSSVariable = {
|
|
|
16
14
|
'--fontSize': string;
|
|
17
15
|
};
|
|
18
16
|
type Props = {
|
|
19
|
-
renderMode?: PlayerRenderMode;
|
|
20
|
-
/** Required when Lynx enables widgets backed by WebView-only renderers. */
|
|
21
|
-
lynxAdapters?: LynxPlayerAdapters;
|
|
22
17
|
devId: string;
|
|
23
18
|
/** 未提供 instance 时,传给播放器内部的 useCtx。null 表示配置查询中。 */
|
|
24
19
|
autoClarityDisabled?: boolean | null;
|
package/lib/ui/ui.js
CHANGED
|
@@ -6,23 +6,19 @@ import "core-js/modules/esnext.iterator.find.js";
|
|
|
6
6
|
import "core-js/modules/esnext.iterator.map.js";
|
|
7
7
|
import "core-js/modules/esnext.iterator.some.js";
|
|
8
8
|
import React, { useContext, useState, useRef, useMemo, useEffect, useImperativeHandle } from 'react';
|
|
9
|
-
import { View, getSystemInfoSync, usePageEvent, setNavigationBarBack, setPageOrientation, getCurrentPages } from '@ray-js/ray';
|
|
9
|
+
import { View, CoverView, getSystemInfoSync, usePageEvent, setNavigationBarBack, setPageOrientation, getCurrentPages } from '@ray-js/ray';
|
|
10
10
|
import { unstable_batchedUpdates as batchedUpdates } from '@ray-core/ray';
|
|
11
11
|
import clsx from 'clsx';
|
|
12
12
|
import IPCPlayer from '@ray-js/ray-ipc-player';
|
|
13
13
|
import { ipcTTTOperatorLog } from '@ray-js/ray-ipc-utils';
|
|
14
14
|
import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
|
|
15
|
-
import { getPlayerOverlayHost } from '../renderer/overlay';
|
|
16
|
-
import { PlayerRenderModeContext, PlayerControlVisibilityContext } from '../renderer/context';
|
|
17
|
-
import lynxStyles from '../renderer/index.module.less';
|
|
18
|
-
import { getPlayerViewport } from '../renderer/viewport';
|
|
19
|
-
import { LynxPlayerAdaptersContext } from '../renderer/capabilities';
|
|
20
15
|
import { PlayState, PlayerStreamStatus, MultiCameraScreenMode } from '../interface';
|
|
21
16
|
import { useCtx } from '../ctx/ctx.composition';
|
|
22
17
|
import { useStore, updateAtom } from '../ctx/store';
|
|
23
18
|
import { UIEventContext } from './context';
|
|
24
|
-
import { showAllComponent, hideAllComponent, playerTap, startTimeToHideAllComponent, pauseTimeToHideAllComponent, decodeClarityDic, changeIgnoreHideStopPreview, moveablePtzControlId, tileActionsId, tileTipId, landscapeTipId, multiPtzId, ptzMoveableTipId, ptzControlTipId, showFlowLowTipId, zoomLevelChange, setScaleMultipleEvent, trialCountdownEnd, refreshSmartImageQualityEvent } from './constant';
|
|
19
|
+
import { showAllComponent, bottomRightContentResize, bottomLeftContentResize, hideAllComponent, playerTap, startTimeToHideAllComponent, pauseTimeToHideAllComponent, decodeClarityDic, changeIgnoreHideStopPreview, moveablePtzControlId, tileActionsId, tileTipId, landscapeTipId, multiPtzId, ptzMoveableTipId, ptzControlTipId, showFlowLowTipId, zoomLevelChange, setScaleMultipleEvent, trialCountdownEnd, refreshSmartImageQualityEvent } from './constant';
|
|
25
20
|
import BottomLeftContent from './bottomLeftContent';
|
|
21
|
+
import { getReservedRightWidth } from './bottomControlLayout';
|
|
26
22
|
import BottomRightContent from './bottomRightContent';
|
|
27
23
|
import TopLeftContent from './topLeftContent';
|
|
28
24
|
import TopRightContent from './topRightContent';
|
|
@@ -99,15 +95,8 @@ const SET_SCALE_ALIGN_TIMEOUT = 1500;
|
|
|
99
95
|
|
|
100
96
|
/** 回读值与对齐值 / 目标值的比对容差 */
|
|
101
97
|
const SCALE_MATCH_EPS = 0.01;
|
|
102
|
-
|
|
103
|
-
/** 竖屏左下角内容与右下角按钮之间的安全间距(px) */
|
|
104
|
-
// 左下角内容右缘与右下角按钮之间的安全间距。
|
|
105
|
-
// 原为 12px:右下角 wrap 当时还带 10px paddingLeft,两段叠起来是 22px 空白,窄屏上太奢侈。
|
|
106
|
-
// paddingLeft 已归 0,这里收到 4px —— 右下角按钮自身还有 16px 的右留白撑着,不会显挤。
|
|
107
|
-
const BOTTOM_RIGHT_SAFE_GAP = 4;
|
|
108
98
|
export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
109
99
|
const {
|
|
110
|
-
renderMode = 'webview',
|
|
111
100
|
className,
|
|
112
101
|
devId,
|
|
113
102
|
style,
|
|
@@ -132,7 +121,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
132
121
|
previewEnabled = undefined,
|
|
133
122
|
onPreviewEnabledChange
|
|
134
123
|
} = props;
|
|
135
|
-
const OverlayView = getPlayerOverlayHost(renderMode);
|
|
136
124
|
const {
|
|
137
125
|
event
|
|
138
126
|
} = useContext(UIEventContext);
|
|
@@ -681,6 +669,8 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
681
669
|
|
|
682
670
|
// 折叠屏展开/收起、pad 多窗口拖拽等场景,需要重新计算并同步
|
|
683
671
|
setIsSmallScreen(computeIsSmallScreen());
|
|
672
|
+
instance.event.emit(bottomRightContentResize);
|
|
673
|
+
instance.event.emit(bottomLeftContentResize);
|
|
684
674
|
setScreenType(type === 'landscape' ? 'full' : 'vertical');
|
|
685
675
|
if (type === 'landscape') {
|
|
686
676
|
// 记录切换横屏前的竖屏全屏状态
|
|
@@ -838,43 +828,16 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
838
828
|
const visibleCount = (bottomRightContent || []).filter(item => !item.hidden).length;
|
|
839
829
|
if (visibleCount <= 0) return 0;
|
|
840
830
|
if (visibleCount === 1) return 115;
|
|
841
|
-
return 132;
|
|
831
|
+
return 132 + Math.max(0, visibleCount - 2) * 56;
|
|
842
832
|
}, [bottomRightContent, screenType]);
|
|
843
833
|
|
|
844
|
-
//
|
|
845
|
-
|
|
846
|
-
const [bottomRightMeasuredWidth, setBottomRightMeasuredWidth] = useState(0);
|
|
834
|
+
// Measure the visible buttons in both orientations without moving the right group.
|
|
835
|
+
const [bottomRightMeasuredWidth, setBottomRightMeasuredWidth] = useState(null);
|
|
847
836
|
const handleBottomRightWidthChange = useMemoizedFn(w => {
|
|
848
|
-
setBottomRightMeasuredWidth(prev => Math.abs(prev - w) >= 1 ? w : prev);
|
|
837
|
+
setBottomRightMeasuredWidth(prev => w === null || prev === null || Math.abs(prev - w) >= 1 ? w : prev);
|
|
849
838
|
});
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
const windowWidthRef = useRef(0);
|
|
853
|
-
if (!windowWidthRef.current) {
|
|
854
|
-
var _getSystemInfoSync;
|
|
855
|
-
windowWidthRef.current = ((_getSystemInfoSync = getSystemInfoSync()) === null || _getSystemInfoSync === void 0 ? void 0 : _getSystemInfoSync.windowWidth) || 0;
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
/**
|
|
859
|
-
* 左下角右侧要预留的宽度:竖屏优先用实测值 + 安全间距,实测不到再退回常量估算;
|
|
860
|
-
* 横屏保持原来的 40% 不变。
|
|
861
|
-
*/
|
|
862
|
-
const bottomRightReserved = useMemo(() => {
|
|
863
|
-
if (screenType === 'full') {
|
|
864
|
-
return bottomRightWidth;
|
|
865
|
-
}
|
|
866
|
-
// 安卓上 CoverView 的 boundingClientRect 可能一直测不出宽度,轮询跑完仍是 0
|
|
867
|
-
if (!(bottomRightMeasuredWidth > 0)) {
|
|
868
|
-
return bottomRightWidth;
|
|
869
|
-
}
|
|
870
|
-
// 封顶保护:个别宿主里不设宽度的 CoverView 可能撑满整行,实测值会异常放大,
|
|
871
|
-
// 那样左下角会被挤没。超过屏宽一半就当测量不可信,退回常量估算。
|
|
872
|
-
const maxReserved = windowWidthRef.current ? windowWidthRef.current / 2 : 0;
|
|
873
|
-
if (maxReserved && bottomRightMeasuredWidth > maxReserved) {
|
|
874
|
-
return bottomRightWidth;
|
|
875
|
-
}
|
|
876
|
-
return Math.ceil(bottomRightMeasuredWidth) + BOTTOM_RIGHT_SAFE_GAP;
|
|
877
|
-
}, [screenType, bottomRightWidth, bottomRightMeasuredWidth]);
|
|
839
|
+
useEffect(() => setBottomRightMeasuredWidth(null), [screenType, bottomRightContent]);
|
|
840
|
+
const bottomRightReserved = getReservedRightWidth(bottomRightMeasuredWidth, bottomRightWidth);
|
|
878
841
|
|
|
879
842
|
/**
|
|
880
843
|
* 传给右下角自身的 width:竖屏不再强制固定宽(否则测出来的永远是那个常量),
|
|
@@ -1112,33 +1075,23 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1112
1075
|
return false;
|
|
1113
1076
|
});
|
|
1114
1077
|
const playerContainerHeight = screenType === 'vertical' ? (style === null || style === void 0 ? void 0 : style.height) || '100%' : '100vh';
|
|
1115
|
-
const
|
|
1116
|
-
|
|
1117
|
-
const lynxVerticalFull = renderMode === 'lynx' && isVerticalFullMode;
|
|
1118
|
-
const viewport = getPlayerViewport(renderMode, isVerticalFullMode, playerContainerHeight);
|
|
1119
|
-
return /*#__PURE__*/React.createElement(PlayerRenderModeContext.Provider, {
|
|
1120
|
-
value: renderMode
|
|
1121
|
-
}, /*#__PURE__*/React.createElement(LynxPlayerAdaptersContext.Provider, {
|
|
1122
|
-
value: props.lynxAdapters || {}
|
|
1123
|
-
}, /*#__PURE__*/React.createElement(UIEventContext.Provider, {
|
|
1078
|
+
const bottomHideState = isVerticalFullLayout && screenType === 'vertical' ? false : componentHideState;
|
|
1079
|
+
return /*#__PURE__*/React.createElement(UIEventContext.Provider, {
|
|
1124
1080
|
value: {
|
|
1125
1081
|
event: eventRef.current,
|
|
1126
1082
|
componentHideState,
|
|
1127
1083
|
refreshElement
|
|
1128
1084
|
}
|
|
1129
1085
|
}, /*#__PURE__*/React.createElement(View, {
|
|
1130
|
-
className: clsx('ipc-player-content',
|
|
1086
|
+
className: clsx('ipc-player-content', isSmallScreen && 'ipc-player-content-small-screen', className),
|
|
1131
1087
|
style: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, defaultCSSVariable), CSSVariable), style), {}, {
|
|
1132
1088
|
height: playerContainerHeight
|
|
1133
|
-
}
|
|
1134
|
-
backgroundColor: '#000'
|
|
1135
|
-
} : {})
|
|
1089
|
+
})
|
|
1136
1090
|
}, /*#__PURE__*/React.createElement(View, {
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
} : {}, {
|
|
1091
|
+
style: {
|
|
1092
|
+
height: isVerticalFullLayout && screenType === 'vertical' ? `calc(${playerContainerHeight} - 48px)` : playerContainerHeight
|
|
1093
|
+
}
|
|
1094
|
+
}, /*#__PURE__*/React.createElement(IPCPlayer, {
|
|
1142
1095
|
defaultMute: mute,
|
|
1143
1096
|
devId: devId,
|
|
1144
1097
|
onlineStatus: deviceOnline,
|
|
@@ -1160,7 +1113,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1160
1113
|
onCameraNotifyWeakNetwork: data => {
|
|
1161
1114
|
console.log(`onCameraNotifyWeakNetwork: ${JSON.stringify(data)}`);
|
|
1162
1115
|
},
|
|
1163
|
-
clarity: decodeClarityDic[
|
|
1116
|
+
clarity: decodeClarityDic[resolution],
|
|
1164
1117
|
onZoomChange: onZoomChange
|
|
1165
1118
|
// objectFit={
|
|
1166
1119
|
// screenType === 'vertical'
|
|
@@ -1174,7 +1127,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1174
1127
|
// scaleMultiple={0}
|
|
1175
1128
|
,
|
|
1176
1129
|
awakeStatus: awakeStatus,
|
|
1177
|
-
objectFit:
|
|
1130
|
+
objectFit: "fillCrop",
|
|
1178
1131
|
scaleMultiple: scaleMultiple
|
|
1179
1132
|
// 安卓横屏问题
|
|
1180
1133
|
// ptzControllable={screenType === 'vertical'}
|
|
@@ -1254,11 +1207,9 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1254
1207
|
limitFlow: limitFlow,
|
|
1255
1208
|
autoWakeUp: autoWakeUp,
|
|
1256
1209
|
extend: _objectSpread(_objectSpread({
|
|
1257
|
-
backgroundColor:
|
|
1210
|
+
backgroundColor: '#262626'
|
|
1258
1211
|
}, instance.multiCameraCtx.extendProps), extend)
|
|
1259
|
-
}))
|
|
1260
|
-
value: !componentHideState && !refreshElement
|
|
1261
|
-
}, showTopContent && /*#__PURE__*/React.createElement(View, {
|
|
1212
|
+
})), showTopContent && /*#__PURE__*/React.createElement(View, {
|
|
1262
1213
|
className: clsx('ipc-player-top-content', {
|
|
1263
1214
|
'ipc-player-top-content-hide': componentHideState,
|
|
1264
1215
|
'ipc-player-top-content-show': !componentHideState
|
|
@@ -1272,19 +1223,18 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1272
1223
|
ctx: instance
|
|
1273
1224
|
}, renderTopRightContent, !hasVisibleBitrateWidget && /*#__PURE__*/React.createElement(AutoClarityOnly, {
|
|
1274
1225
|
instance: instance
|
|
1275
|
-
})))), /*#__PURE__*/React.createElement(
|
|
1226
|
+
})))), /*#__PURE__*/React.createElement(StandaloneAutoClarity, {
|
|
1227
|
+
instance: instance,
|
|
1228
|
+
show: !showTopContent || componentHideState || !playerReady
|
|
1229
|
+
}), /*#__PURE__*/React.createElement(View, {
|
|
1276
1230
|
className: clsx('ipc-player-bottom-content', {
|
|
1277
1231
|
'ipc-player-bottom-content-hide': bottomHideState,
|
|
1278
1232
|
'ipc-player-bottom-content-show': !bottomHideState,
|
|
1279
|
-
'ipc-player-bottom-content-full':
|
|
1233
|
+
'ipc-player-bottom-content-full': isVerticalFullLayout && screenType === 'vertical'
|
|
1280
1234
|
}),
|
|
1281
|
-
style:
|
|
1235
|
+
style: {
|
|
1282
1236
|
height: screenType === 'vertical' ? '48px' : '72px'
|
|
1283
|
-
}
|
|
1284
|
-
paddingBottom: 0
|
|
1285
|
-
} : {})
|
|
1286
|
-
}, /*#__PURE__*/React.createElement(PlayerControlVisibilityContext.Provider, {
|
|
1287
|
-
value: !bottomHideState && !refreshElement
|
|
1237
|
+
}
|
|
1288
1238
|
}, /*#__PURE__*/React.createElement(UIEventContext.Provider, {
|
|
1289
1239
|
value: {
|
|
1290
1240
|
event: eventRef.current,
|
|
@@ -1298,10 +1248,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1298
1248
|
ctx: instance,
|
|
1299
1249
|
width: bottomRightStyleWidth,
|
|
1300
1250
|
onWidthChange: handleBottomRightWidthChange
|
|
1301
|
-
}, renderBottomRightContent)))
|
|
1302
|
-
instance: instance,
|
|
1303
|
-
show: !showTopContent || componentHideState || !playerReady
|
|
1304
|
-
}), (() => {
|
|
1251
|
+
}, renderBottomRightContent))), (() => {
|
|
1305
1252
|
if (!absoluteContent || !(absoluteContent !== null && absoluteContent !== void 0 && absoluteContent.length)) return null;
|
|
1306
1253
|
return absoluteContent.map(item => {
|
|
1307
1254
|
if (!shouldRenderContent(item, {
|
|
@@ -1316,7 +1263,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1316
1263
|
if (item.absoluteNoCoverView) {
|
|
1317
1264
|
return /*#__PURE__*/React.createElement(item.content, contentProps);
|
|
1318
1265
|
}
|
|
1319
|
-
return /*#__PURE__*/React.createElement(
|
|
1266
|
+
return /*#__PURE__*/React.createElement(CoverView, {
|
|
1320
1267
|
key: item.id,
|
|
1321
1268
|
style: _objectSpread({
|
|
1322
1269
|
position: 'absolute'
|
|
@@ -1327,5 +1274,5 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1327
1274
|
className: clsx('absolute-item-container')
|
|
1328
1275
|
})));
|
|
1329
1276
|
});
|
|
1330
|
-
})()))
|
|
1277
|
+
})()));
|
|
1331
1278
|
});
|