@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
package/README.md
CHANGED
|
@@ -359,9 +359,3 @@ yarn build
|
|
|
359
359
|
```
|
|
360
360
|
|
|
361
361
|
Other available scripts: `start:wechat`, `start:web`, `start:native`, `build:tuya`, `build:wechat`, `build:web`, `build:native`.
|
|
362
|
-
|
|
363
|
-
## Lynx integration
|
|
364
|
-
|
|
365
|
-
This branch includes master `1c07c0b` (`0.0.64`) updates for automatic clarity, offline notifications and album permissions. Set `renderMode="lynx"` explicitly; the default remains `webview`.
|
|
366
|
-
|
|
367
|
-
Use **`@ray-js/ray-ipc-player: 2.1.8-beta.1`** exactly and **`@ray-js/ray-ipc-utils: ^1.1.18`** (currently locked to `1.1.18`). Pin **`@ray-js/direction-control: 0.0.13-beta.1`** and **`@ray-js/ipc-ptz-zoom: 0.0.5-beta.0`** as the published Lynx versions. PTZ and direction widgets require compatible `lynxAdapters`; the turntable has a built-in Lynx renderer and still accepts a custom adapter override. See [Lynx integration notes](./README-LYNX.md) for adapter requirements, verification and remaining runtime limitations.
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { FullScreen, ToggleVerticalFull } from '../widgets';
|
|
1
|
+
import { FullScreen, ToggleVerticalFull, FloatWindow } from '../widgets';
|
|
2
2
|
import { ComponentConfig } from '../interface';
|
|
3
3
|
export declare const defaultTopLeftContent: ComponentConfig[];
|
|
4
4
|
export declare const defaultTopRightContent: ComponentConfig[];
|
|
5
5
|
export declare const defaultBottomLeftContent: ComponentConfig[];
|
|
6
6
|
export declare const defaultBottomRightContent: ({
|
|
7
|
+
id: string;
|
|
8
|
+
content: typeof FloatWindow;
|
|
9
|
+
hidden?: undefined;
|
|
10
|
+
} | {
|
|
7
11
|
id: string;
|
|
8
12
|
content: typeof ToggleVerticalFull;
|
|
9
13
|
hidden: boolean;
|
|
@@ -4,7 +4,7 @@ const _excluded = ["title", "duration"];
|
|
|
4
4
|
import { getCameraConfigInfo } from '@ray-js/ray-ipc-utils';
|
|
5
5
|
import { IntercomMode, MuteMode, ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
|
|
6
6
|
import { createUseCtx } from './ctx';
|
|
7
|
-
import { FullSmallIntercom, VerticalSmallIntercom, BatteryFull, Battery, Screenshot, TempHumidity, Signal4G, RecordVideo, FullScreen, VideoBitKBP, Muted, Floodlight, Siren, TryExperience, Resolution, Ptz, MultiPtz, TileTip, PtzMoveableTip, LandscapeTip, TileActions, MoveablePtzControl, SwitchLayout, ToggleVerticalFull, RealTimeMagnification, ZoomTurntableEntry } from '../widgets';
|
|
7
|
+
import { FullSmallIntercom, VerticalSmallIntercom, BatteryFull, Battery, Screenshot, TempHumidity, Signal4G, RecordVideo, FullScreen, VideoBitKBP, Muted, Floodlight, Siren, TryExperience, Resolution, Ptz, MultiPtz, TileTip, PtzMoveableTip, LandscapeTip, TileActions, MoveablePtzControl, SwitchLayout, ToggleVerticalFull, FloatWindow, RealTimeMagnification, ZoomTurntableEntry } from '../widgets';
|
|
8
8
|
import { authorizeStatus } from '../utils/authorize';
|
|
9
9
|
import { PlayState } from '../interface';
|
|
10
10
|
import { landscapeTipId, moveablePtzControlId, multiPtzId, ptzMoveableTipId, tileActionsId, tileTipId } from '../ui/constant';
|
|
@@ -79,6 +79,9 @@ export const defaultBottomRightContent = [{
|
|
|
79
79
|
id: 'SwitchLayout',
|
|
80
80
|
content: SwitchLayout,
|
|
81
81
|
hidden: true
|
|
82
|
+
}, {
|
|
83
|
+
id: 'FloatWindow',
|
|
84
|
+
content: FloatWindow
|
|
82
85
|
}, {
|
|
83
86
|
id: 'ToggleVerticalFull',
|
|
84
87
|
content: ToggleVerticalFull,
|
package/lib/ctx/ctx.js
CHANGED
|
@@ -394,16 +394,6 @@ export const createUseCtx = _ref => {
|
|
|
394
394
|
return true;
|
|
395
395
|
}
|
|
396
396
|
return new Promise((resolve, reject) => {
|
|
397
|
-
const failStartTalk = err => {
|
|
398
|
-
// 部分 Lynx 错误回调没有 payload;先结束请求,避免提示异常锁死按钮。
|
|
399
|
-
reject(err);
|
|
400
|
-
eventRef.current.emit(changeIgnoreHideStopPreview, false);
|
|
401
|
-
const errObj = (err === null || err === void 0 ? void 0 : err.innerError) || err || {};
|
|
402
|
-
const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_intercom');
|
|
403
|
-
toast({
|
|
404
|
-
title: errMsg
|
|
405
|
-
});
|
|
406
|
-
};
|
|
407
397
|
if (target) {
|
|
408
398
|
ty.authorizeStatus({
|
|
409
399
|
// 麦克风权限
|
|
@@ -415,7 +405,15 @@ export const createUseCtx = _ref => {
|
|
|
415
405
|
updateAtom(intercom, true);
|
|
416
406
|
resolve(true);
|
|
417
407
|
},
|
|
418
|
-
fail:
|
|
408
|
+
fail: err => {
|
|
409
|
+
eventRef.current.emit(changeIgnoreHideStopPreview, false);
|
|
410
|
+
const errObj = err.innerError || err || {};
|
|
411
|
+
const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_intercom');
|
|
412
|
+
toast({
|
|
413
|
+
title: errMsg
|
|
414
|
+
});
|
|
415
|
+
reject(err);
|
|
416
|
+
}
|
|
419
417
|
});
|
|
420
418
|
},
|
|
421
419
|
fail: err => {
|
|
@@ -430,7 +428,14 @@ export const createUseCtx = _ref => {
|
|
|
430
428
|
updateAtom(intercom, true);
|
|
431
429
|
resolve(true);
|
|
432
430
|
},
|
|
433
|
-
fail:
|
|
431
|
+
fail: err => {
|
|
432
|
+
const errObj = err.innerError || err || {};
|
|
433
|
+
const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_intercom');
|
|
434
|
+
toast({
|
|
435
|
+
title: errMsg
|
|
436
|
+
});
|
|
437
|
+
reject(err);
|
|
438
|
+
}
|
|
434
439
|
});
|
|
435
440
|
},
|
|
436
441
|
fail: err => {
|
package/lib/ctx/ctx.test.js
CHANGED
|
@@ -1,49 +1,14 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
1
|
import { act, renderHook } from '@testing-library/react-hooks';
|
|
3
2
|
import { createUseCtx } from './ctx';
|
|
4
3
|
import { useStore } from './store';
|
|
5
|
-
jest.mock('@ray-js/ray', () => ({}));
|
|
6
|
-
jest.mock('@ray-js/ray-ipc-utils/lib/interface', () => ({
|
|
7
|
-
ClarityType: {
|
|
8
|
-
HD: 'HD',
|
|
9
|
-
SD: 'SD',
|
|
10
|
-
AUTO: 'AUTO'
|
|
11
|
-
},
|
|
12
|
-
IntercomMode: {
|
|
13
|
-
OneWay: 'OneWay',
|
|
14
|
-
TwoWay: 'TwoWay'
|
|
15
|
-
}
|
|
16
|
-
}));
|
|
17
|
-
jest.mock('../i18n', () => ({
|
|
18
|
-
__esModule: true,
|
|
19
|
-
default: {
|
|
20
|
-
getLang: key => key
|
|
21
|
-
}
|
|
22
|
-
}));
|
|
23
|
-
jest.mock('./multiCameraCtx', () => ({
|
|
24
|
-
isMultiCameraTileSupported: () => false,
|
|
25
|
-
useMultiCameraCtx: () => ({})
|
|
26
|
-
}));
|
|
27
|
-
jest.mock('./useAutoClarity', () => ({
|
|
28
|
-
useAutoClarity: () => ({
|
|
29
|
-
refreshAfterPlayback: () => undefined,
|
|
30
|
-
restoreResolution: () => undefined
|
|
31
|
-
})
|
|
32
|
-
}));
|
|
33
|
-
const createTestUseCtx = options => createUseCtx(_objectSpread({
|
|
34
|
-
getMemoryState: () => new Promise(() => undefined),
|
|
35
|
-
toast: jest.fn(),
|
|
36
|
-
setMuteMemoryState: jest.fn(),
|
|
37
|
-
setResolutionMemoryState: jest.fn()
|
|
38
|
-
}, options));
|
|
39
4
|
describe('createCtx', () => {
|
|
40
5
|
it('init props', () => {
|
|
41
6
|
const topContent = {
|
|
42
|
-
id: '
|
|
7
|
+
id: 'top',
|
|
43
8
|
content: () => null
|
|
44
9
|
};
|
|
45
10
|
const defaultBottomContent = {
|
|
46
|
-
id: '
|
|
11
|
+
id: 'bottom',
|
|
47
12
|
content: () => null,
|
|
48
13
|
initProps: {
|
|
49
14
|
name: 1
|
|
@@ -52,9 +17,9 @@ describe('createCtx', () => {
|
|
|
52
17
|
const IPCPlayerContext = {
|
|
53
18
|
name: 'IPCPlayerContext'
|
|
54
19
|
};
|
|
55
|
-
const useCtx =
|
|
20
|
+
const useCtx = createUseCtx({
|
|
56
21
|
createPlayContext: () => IPCPlayerContext,
|
|
57
|
-
|
|
22
|
+
defaultTopContent: [topContent],
|
|
58
23
|
defaultAbsoluteContent: [{
|
|
59
24
|
id: 'absolute',
|
|
60
25
|
content: () => null,
|
|
@@ -68,13 +33,13 @@ describe('createCtx', () => {
|
|
|
68
33
|
result
|
|
69
34
|
} = renderHook(() => {
|
|
70
35
|
const {
|
|
71
|
-
|
|
72
|
-
|
|
36
|
+
topContent,
|
|
37
|
+
bottomContent,
|
|
73
38
|
absoluteContent,
|
|
74
39
|
IPCPlayerInstance
|
|
75
40
|
} = useCtx({
|
|
76
41
|
devId: 'devId',
|
|
77
|
-
|
|
42
|
+
initBottomContent: [defaultBottomContent],
|
|
78
43
|
initAbsoluteContent: []
|
|
79
44
|
});
|
|
80
45
|
const store = useStore({
|
|
@@ -95,7 +60,7 @@ describe('createCtx', () => {
|
|
|
95
60
|
expect(result.current.IPCPlayerInstance).toBe(IPCPlayerContext);
|
|
96
61
|
});
|
|
97
62
|
it('createCtx, add a content and delete content', async () => {
|
|
98
|
-
const useCtx =
|
|
63
|
+
const useCtx = createUseCtx({
|
|
99
64
|
createPlayContext: () => null,
|
|
100
65
|
authorizeStatus: () => Promise.resolve(true)
|
|
101
66
|
});
|
|
@@ -104,8 +69,8 @@ describe('createCtx', () => {
|
|
|
104
69
|
} = renderHook(() => {
|
|
105
70
|
const {
|
|
106
71
|
addContent,
|
|
107
|
-
|
|
108
|
-
|
|
72
|
+
topContent,
|
|
73
|
+
bottomContent,
|
|
109
74
|
deleteContent
|
|
110
75
|
} = useCtx({
|
|
111
76
|
devId: 'devId'
|
|
@@ -122,29 +87,29 @@ describe('createCtx', () => {
|
|
|
122
87
|
};
|
|
123
88
|
});
|
|
124
89
|
const topContent = {
|
|
125
|
-
id: '
|
|
90
|
+
id: 'top',
|
|
126
91
|
content: () => null
|
|
127
92
|
};
|
|
128
93
|
const bottomContent = {
|
|
129
|
-
id: '
|
|
94
|
+
id: 'bottom',
|
|
130
95
|
content: () => null,
|
|
131
96
|
initProps: {
|
|
132
97
|
name: 1
|
|
133
98
|
}
|
|
134
99
|
};
|
|
135
100
|
act(() => {
|
|
136
|
-
result.current.addContent('
|
|
137
|
-
result.current.addContent('
|
|
101
|
+
result.current.addContent('top', topContent);
|
|
102
|
+
result.current.addContent('bottom', bottomContent);
|
|
138
103
|
});
|
|
139
104
|
expect(result.current.topContent).toEqual([topContent]);
|
|
140
105
|
expect(result.current.bottomContent).toEqual([bottomContent]);
|
|
141
106
|
act(() => {
|
|
142
|
-
result.current.deleteContent('
|
|
107
|
+
result.current.deleteContent('bottom', 'bottom');
|
|
143
108
|
});
|
|
144
109
|
expect(result.current.bottomContent).toEqual([]);
|
|
145
110
|
});
|
|
146
111
|
it('add content list', () => {
|
|
147
|
-
const useCtx =
|
|
112
|
+
const useCtx = createUseCtx({
|
|
148
113
|
createPlayContext: () => null,
|
|
149
114
|
authorizeStatus: () => Promise.resolve(true)
|
|
150
115
|
});
|
|
@@ -153,7 +118,7 @@ describe('createCtx', () => {
|
|
|
153
118
|
} = renderHook(() => {
|
|
154
119
|
const {
|
|
155
120
|
addContent,
|
|
156
|
-
|
|
121
|
+
topContent
|
|
157
122
|
} = useCtx({
|
|
158
123
|
devId: 'devId'
|
|
159
124
|
});
|
|
@@ -174,13 +139,13 @@ describe('createCtx', () => {
|
|
|
174
139
|
content: () => null
|
|
175
140
|
};
|
|
176
141
|
act(() => {
|
|
177
|
-
result.current.addContent('
|
|
142
|
+
result.current.addContent('top', [topContent1, topContent2]);
|
|
178
143
|
});
|
|
179
144
|
expect(result.current.topContent).toEqual([topContent1, topContent2]);
|
|
180
145
|
});
|
|
181
146
|
|
|
182
147
|
// it('Select Update', () => {
|
|
183
|
-
// const useCtx =
|
|
148
|
+
// const useCtx = createUseCtx({
|
|
184
149
|
// createPlayContext: () => null,
|
|
185
150
|
// authorizeStatus: () => Promise.resolve(true),
|
|
186
151
|
// });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ComponentConfig, UseCtx, WidgetId } from '../../interface';
|
|
3
3
|
import { FullScreen } from '../../widgets';
|
|
4
|
+
import type { FloatWindowOptions } from '../../widgets/floatWindow';
|
|
4
5
|
type Ctx = ReturnType<UseCtx>;
|
|
5
6
|
export type InitPlayerWidgetsOptions = {
|
|
6
7
|
verticalResolutionCustomClick?: boolean;
|
|
@@ -20,6 +21,8 @@ export type InitPlayerWidgetsOptions = {
|
|
|
20
21
|
showZoomTurntable?: boolean;
|
|
21
22
|
directionControlProps?: Partial<React.ComponentProps<typeof FullScreen>['directionControlProps']>;
|
|
22
23
|
hideSmartImageQualityState?: boolean;
|
|
24
|
+
/** Panel-owned eligibility and click action. Omitted means hidden. */
|
|
25
|
+
floatWindow?: FloatWindowOptions;
|
|
23
26
|
topLeftContent?: ComponentConfig[];
|
|
24
27
|
topRightContent?: ComponentConfig[];
|
|
25
28
|
bottomLeftContent?: ComponentConfig[];
|
|
@@ -67,6 +67,10 @@ export async function initPlayerWidgets(ctx, options) {
|
|
|
67
67
|
}
|
|
68
68
|
ctx.addContent('bottomLeft', newDefaultBottomLeftContent);
|
|
69
69
|
const newDefaultBottomRightContent = _cloneDeep(options.bottomRightContent || defaultBottomRightContent);
|
|
70
|
+
const floatWindowIndex = newDefaultBottomRightContent.findIndex(item => item.id === 'FloatWindow');
|
|
71
|
+
if (floatWindowIndex !== -1) {
|
|
72
|
+
newDefaultBottomRightContent[floatWindowIndex].initProps = _objectSpread(_objectSpread({}, newDefaultBottomRightContent[floatWindowIndex].initProps), options.floatWindow);
|
|
73
|
+
}
|
|
70
74
|
const fullScreenIndex = newDefaultBottomRightContent.findIndex(item => item.id === 'FullScreen');
|
|
71
75
|
if (fullScreenIndex !== -1) {
|
|
72
76
|
// @ts-ignore
|
package/lib/index.d.ts
CHANGED
|
@@ -5,7 +5,3 @@ import * as Widgets from './widgets';
|
|
|
5
5
|
import * as Features from './features';
|
|
6
6
|
import * as Utils from './utils';
|
|
7
7
|
export { Widgets, Features, Utils };
|
|
8
|
-
export { PlayerRenderModeContext } from './renderer/context';
|
|
9
|
-
export type { PlayerRenderMode } from './renderer/context';
|
|
10
|
-
export type { LynxPlayerAdapters } from './renderer/capabilities';
|
|
11
|
-
export { LynxPlayerAdaptersContext } from './renderer/capabilities';
|
package/lib/index.js
CHANGED
|
@@ -4,6 +4,4 @@ export * from './interface';
|
|
|
4
4
|
import * as Widgets from './widgets';
|
|
5
5
|
import * as Features from './features';
|
|
6
6
|
import * as Utils from './utils';
|
|
7
|
-
export { Widgets, Features, Utils };
|
|
8
|
-
export { PlayerRenderModeContext } from './renderer/context';
|
|
9
|
-
export { LynxPlayerAdaptersContext } from './renderer/capabilities';
|
|
7
|
+
export { Widgets, Features, Utils };
|
package/lib/interface.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type IpcContext = {
|
|
|
14
14
|
};
|
|
15
15
|
export type RetAtom<T> = PrimitiveAtom<T> & WithInitialValue<T>;
|
|
16
16
|
export type ScreenType = 'full' | 'vertical';
|
|
17
|
-
export type WidgetId = 'BatteryFull' | 'TempHumidity' | 'VideoBitKBP' | 'FullSmallIntercom' | 'Screenshot' | 'RecordVideo' | 'Muted' | 'Floodlight' | 'Siren' | 'TryExperience' | 'VerticalSmallIntercom' | 'Ptz' | 'Resolution' | 'FullScreen' | 'RealTimeMagnification' | 'ZoomTurntableEntry' | 'moveablePtzControlId';
|
|
17
|
+
export type WidgetId = 'BatteryFull' | 'TempHumidity' | 'VideoBitKBP' | 'FullSmallIntercom' | 'Screenshot' | 'RecordVideo' | 'Muted' | 'Floodlight' | 'Siren' | 'TryExperience' | 'VerticalSmallIntercom' | 'Ptz' | 'Resolution' | 'FullScreen' | 'FloatWindow' | 'RealTimeMagnification' | 'ZoomTurntableEntry' | 'moveablePtzControlId';
|
|
18
18
|
export declare const enum PlayerStreamStatus {
|
|
19
19
|
UnknownException = -1000,
|
|
20
20
|
ConnectSuccess = 1001,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Minimum CSS-pixel gap between the two control groups, including the scroll arrow. */
|
|
2
|
+
export declare const BOTTOM_CONTROL_SAFE_GAP = 45;
|
|
3
|
+
type Rect = {
|
|
4
|
+
left: number;
|
|
5
|
+
right: number;
|
|
6
|
+
width: number;
|
|
7
|
+
};
|
|
8
|
+
/** The right wrapper can occupy 40% while its buttons only occupy part of it. */
|
|
9
|
+
export declare function getOccupiedRightWidth(wrap?: Rect, items?: Rect[]): number | undefined;
|
|
10
|
+
export declare function getReservedRightWidth(measured: number | null, fallback: number | string): number | string;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
|
+
import "core-js/modules/esnext.iterator.filter.js";
|
|
3
|
+
import "core-js/modules/esnext.iterator.map.js";
|
|
4
|
+
/** Minimum CSS-pixel gap between the two control groups, including the scroll arrow. */
|
|
5
|
+
export const BOTTOM_CONTROL_SAFE_GAP = 45;
|
|
6
|
+
/** The right wrapper can occupy 40% while its buttons only occupy part of it. */
|
|
7
|
+
export function getOccupiedRightWidth(wrap, items) {
|
|
8
|
+
if (!wrap || !Number.isFinite(wrap.right) || !Array.isArray(items)) return undefined;
|
|
9
|
+
const visible = items.filter(item => item.width > 0 && Number.isFinite(item.left));
|
|
10
|
+
if (!visible.length) return 0;
|
|
11
|
+
const width = wrap.right - Math.min(...visible.map(item => item.left));
|
|
12
|
+
return width > 0 ? Math.ceil(width) : undefined;
|
|
13
|
+
}
|
|
14
|
+
export function getReservedRightWidth(measured, fallback) {
|
|
15
|
+
if (measured === 0) return 0;
|
|
16
|
+
const width = measured !== null && measured > 0 ? measured : fallback;
|
|
17
|
+
if (typeof width === 'number') return width > 0 ? Math.ceil(width) + BOTTOM_CONTROL_SAFE_GAP : 0;
|
|
18
|
+
return `calc(${width} + ${BOTTOM_CONTROL_SAFE_GAP}px)`;
|
|
19
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { getOccupiedRightWidth, getReservedRightWidth } from './bottomControlLayout';
|
|
2
|
+
describe('bottom controls safety boundary', () => {
|
|
3
|
+
it.each([375, 667, 1024])('leaves >=45px before the actual buttons at width %s', width => {
|
|
4
|
+
const right = getOccupiedRightWidth({
|
|
5
|
+
left: width * 0.6,
|
|
6
|
+
right: width,
|
|
7
|
+
width: width * 0.4
|
|
8
|
+
}, [0, 1, 2].map(i => ({
|
|
9
|
+
left: width - 120 + i * 40,
|
|
10
|
+
right: width - 80 + i * 40,
|
|
11
|
+
width: 40
|
|
12
|
+
})));
|
|
13
|
+
const leftViewportRight = width - Number(getReservedRightWidth(right, '40%'));
|
|
14
|
+
// Both visible left controls and the arrow are clipped inside this viewport.
|
|
15
|
+
expect(width - 120 - leftViewportRight).toBeGreaterThanOrEqual(45);
|
|
16
|
+
});
|
|
17
|
+
it('measures buttons overflowing the fixed wrapper on a narrow screen', () => {
|
|
18
|
+
const measured = getOccupiedRightWidth({
|
|
19
|
+
left: 240,
|
|
20
|
+
right: 400,
|
|
21
|
+
width: 160
|
|
22
|
+
}, [{
|
|
23
|
+
left: 200,
|
|
24
|
+
right: 400,
|
|
25
|
+
width: 200
|
|
26
|
+
}]);
|
|
27
|
+
expect(getReservedRightWidth(measured, '40%')).toBe(245);
|
|
28
|
+
});
|
|
29
|
+
it('reclaims space when the small-window button disappears', () => {
|
|
30
|
+
const wrap = {
|
|
31
|
+
left: 225,
|
|
32
|
+
right: 375,
|
|
33
|
+
width: 150
|
|
34
|
+
};
|
|
35
|
+
const full = getOccupiedRightWidth(wrap, [{
|
|
36
|
+
left: 255,
|
|
37
|
+
right: 375,
|
|
38
|
+
width: 120
|
|
39
|
+
}]);
|
|
40
|
+
const reduced = getOccupiedRightWidth(wrap, [{
|
|
41
|
+
left: 295,
|
|
42
|
+
right: 375,
|
|
43
|
+
width: 80
|
|
44
|
+
}]);
|
|
45
|
+
expect(Number(getReservedRightWidth(full, 188)) - Number(getReservedRightWidth(reduced, 188))).toBe(40);
|
|
46
|
+
});
|
|
47
|
+
it('ignores zero-width placeholders and reserves nothing for an empty group', () => {
|
|
48
|
+
expect(getOccupiedRightWidth({
|
|
49
|
+
left: 225,
|
|
50
|
+
right: 375,
|
|
51
|
+
width: 150
|
|
52
|
+
}, [{
|
|
53
|
+
left: 0,
|
|
54
|
+
right: 0,
|
|
55
|
+
width: 0
|
|
56
|
+
}])).toBe(0);
|
|
57
|
+
expect(getReservedRightWidth(0, 188)).toBe(0);
|
|
58
|
+
});
|
|
59
|
+
it('keeps a safe fallback when native measurement is unavailable', () => {
|
|
60
|
+
expect(getOccupiedRightWidth(undefined, undefined)).toBeUndefined();
|
|
61
|
+
expect(getReservedRightWidth(null, '40%')).toBe('calc(40% + 45px)');
|
|
62
|
+
expect(getReservedRightWidth(null, 188)).toBe(233);
|
|
63
|
+
});
|
|
64
|
+
});
|