@ray-js/ipc-player-integration 0.0.67-beta.2 → 0.0.68-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 +6 -0
- package/lib/ctx/ctx.composition.js +3 -13
- package/lib/ctx/ctx.js +35 -48
- package/lib/ctx/multiCameraCtx.d.ts +0 -2
- package/lib/ctx/multiCameraCtx.js +1 -17
- package/lib/i18n/index.d.ts +0 -12
- package/lib/i18n/strings.d.ts +0 -6
- package/lib/i18n/strings.js +0 -6
- package/lib/index.d.ts +4 -0
- package/lib/index.js +3 -1
- package/lib/interface.d.ts +3 -18
- package/lib/renderer/capabilities.d.ts +8 -0
- package/lib/renderer/capabilities.js +19 -0
- package/lib/renderer/context.d.ts +5 -0
- package/lib/renderer/context.js +6 -0
- package/lib/renderer/directionControl.d.ts +6 -0
- package/lib/renderer/directionControl.js +3 -0
- package/lib/renderer/font-manifest.json +9 -0
- package/lib/renderer/font.less +5 -0
- package/lib/renderer/glyphs.d.ts +1 -0
- package/lib/renderer/glyphs.js +256 -0
- package/lib/renderer/index.module.less +48 -0
- package/lib/renderer/overlay.d.ts +4 -0
- package/lib/renderer/overlay.js +6 -0
- package/lib/renderer/ptzZoom.d.ts +6 -0
- package/lib/renderer/ptzZoom.js +3 -0
- package/lib/renderer/text.d.ts +4 -0
- package/lib/renderer/text.js +32 -0
- package/lib/renderer/text.module.less +4 -0
- package/lib/renderer/viewport.d.ts +7 -0
- package/lib/renderer/viewport.js +24 -0
- package/lib/res/lynx-signal/index.d.ts +1 -0
- package/lib/res/lynx-signal/index.js +22 -0
- 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/bottomLeftContent.js +122 -56
- package/lib/ui/bottomRightContent.js +10 -5
- package/lib/ui/scrollHintArrow.d.ts +23 -0
- package/lib/ui/scrollHintArrow.js +83 -0
- package/lib/ui/topLeftContent.js +4 -2
- package/lib/ui/topRightContent.js +4 -2
- package/lib/ui/ui.d.ts +5 -0
- package/lib/ui/ui.js +93 -100
- package/lib/utils/navigation.d.ts +1 -2
- package/lib/utils/navigation.js +3 -13
- package/lib/widgets/battery/battery.js +7 -5
- package/lib/widgets/battery/batteryFull.js +7 -5
- package/lib/widgets/battery/statusIcon.d.ts +6 -0
- package/lib/widgets/battery/statusIcon.js +36 -0
- package/lib/widgets/battery/statusIcon.less +24 -0
- package/lib/widgets/captureToast/captureToast.d.ts +9 -0
- package/lib/widgets/captureToast/captureToast.js +73 -0
- package/lib/widgets/floodlight/floodlight.js +2 -1
- package/lib/widgets/flowLowTip/flowLowTip.js +2 -1
- package/lib/widgets/fullScreen/fullScreen.js +44 -31
- package/lib/widgets/fullScreen/fullTravelRouteControl.d.ts +2 -2
- package/lib/widgets/fullScreen/fullTravelRouteControl.js +3 -6
- package/lib/widgets/fullScreen/verticalScreen.js +2 -1
- package/lib/widgets/index.d.ts +0 -1
- package/lib/widgets/index.js +1 -2
- package/lib/widgets/moveInteractiveControl/controlButton.js +2 -1
- package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.js +16 -5
- package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.less +24 -4
- package/lib/widgets/multiCamera/index.less +0 -1
- package/lib/widgets/multiCamera/landscapeTip.js +5 -2
- package/lib/widgets/multiCamera/moveablePtzControl.js +9 -7
- package/lib/widgets/multiCamera/multiPtz.js +3 -2
- package/lib/widgets/multiCamera/ptzMoveableTip.js +5 -2
- package/lib/widgets/multiCamera/switchLayout.js +2 -1
- package/lib/widgets/multiCamera/tileMultiPtz.js +3 -2
- package/lib/widgets/multiCamera/tileSwitchLayout.js +2 -1
- package/lib/widgets/multiCamera/tileTip.js +5 -2
- package/lib/widgets/muted/muted.js +2 -1
- package/lib/widgets/muted/muted.test.js +66 -52
- package/lib/widgets/ptz/ptz.js +2 -1
- package/lib/widgets/ptz/ptzControl.js +4 -3
- package/lib/widgets/ptzControlTip/ptzControlTip.js +9 -4
- package/lib/widgets/ptzControlTip/ptzControlTip.less +6 -0
- package/lib/widgets/realTimeMagnification/realTimeMagnification.js +2 -1
- package/lib/widgets/recordVideo/recordVideo.js +32 -178
- package/lib/widgets/recordVideo/recordVideo.less +74 -17
- package/lib/widgets/recordVideo/recordVideo.test.js +169 -3
- package/lib/widgets/recordVideo/recordVideoTimer.d.ts +3 -0
- package/lib/widgets/recordVideo/recordVideoTimer.js +26 -0
- package/lib/widgets/resolution/fullResolutionControl.js +29 -19
- package/lib/widgets/resolution/resolution.js +3 -2
- package/lib/widgets/screenshot/screenshot.js +35 -125
- package/lib/widgets/screenshot/screenshot.less +40 -1
- package/lib/widgets/screenshot/screenshot.test.js +108 -113
- package/lib/widgets/signal4G/signal4G.js +4 -1
- package/lib/widgets/siren/siren.js +2 -1
- package/lib/widgets/tempHumidity/tempHumidity.js +2 -1
- package/lib/widgets/toggleVerticalFull/toggleVerticalFull.js +2 -1
- package/lib/widgets/trialBadge/index.d.ts +1 -2
- package/lib/widgets/trialBadge/index.js +17 -20
- package/lib/widgets/trialBadge/index.less +24 -0
- package/lib/widgets/trialBadge/useTrialBadge.d.ts +2 -3
- package/lib/widgets/trialBadge/useTrialBadge.js +3 -21
- package/lib/widgets/tryExperience/tryExperience.js +2 -1
- package/lib/widgets/videoBitKBP/videoBitKBP.js +2 -1
- package/lib/widgets/voiceIntercom/voiceIntercom.js +50 -24
- package/lib/widgets/voiceIntercom/voiceIntercom.less +16 -0
- package/lib/widgets/zoomTurntable/lynxDockLayout.d.ts +6 -0
- package/lib/widgets/zoomTurntable/lynxDockLayout.js +30 -0
- package/lib/widgets/zoomTurntable/turntable/index.d.ts +5 -7
- package/lib/widgets/zoomTurntable/turntable/index.js +3 -1
- package/lib/widgets/zoomTurntable/turntable/lynx.d.ts +5 -0
- package/lib/widgets/zoomTurntable/turntable/lynx.js +273 -0
- package/lib/widgets/zoomTurntable/turntable/lynx.less +9 -0
- package/lib/widgets/zoomTurntable/turntable/lynxModel.d.ts +37 -0
- package/lib/widgets/zoomTurntable/turntable/lynxModel.js +122 -0
- package/lib/widgets/zoomTurntable/turntable/lynxPaint.d.ts +3 -0
- package/lib/widgets/zoomTurntable/turntable/lynxPaint.js +36 -0
- package/lib/widgets/zoomTurntable/zoomTurntableDock.d.ts +5 -3
- package/lib/widgets/zoomTurntable/zoomTurntableDock.js +4 -4
- package/lib/widgets/zoomTurntable/zoomTurntableEntry.js +32 -19
- package/lib/widgets/zoomTurntable/zoomTurntableTip.js +24 -3
- package/package.json +15 -7
- package/lib/ctx/ctx.album.test.d.ts +0 -1
- package/lib/ctx/ctx.album.test.js +0 -197
- package/lib/ctx/multiCameraCtx.test.d.ts +0 -1
- package/lib/ctx/multiCameraCtx.test.js +0 -65
- package/lib/ui/absoluteContent.d.ts +0 -2
- package/lib/ui/absoluteContent.js +0 -3
- package/lib/utils/captureResult.d.ts +0 -12
- package/lib/utils/captureResult.js +0 -70
- package/lib/utils/captureResult.test.d.ts +0 -1
- package/lib/utils/captureResult.test.js +0 -223
- package/lib/utils/fullLinkTracking.d.ts +0 -5
- package/lib/utils/fullLinkTracking.js +0 -71
- package/lib/widgets/captureResult/captureResult.d.ts +0 -16
- package/lib/widgets/captureResult/captureResult.js +0 -85
- package/lib/widgets/captureResult/captureResult.less +0 -144
- package/lib/widgets/captureResult/captureResult.test.d.ts +0 -1
- package/lib/widgets/captureResult/captureResult.test.js +0 -84
- package/lib/widgets/captureResult/index.d.ts +0 -2
- package/lib/widgets/captureResult/index.js +0 -2
- package/lib/widgets/recordVideo/recordVideo.lifecycle.test.d.ts +0 -1
- package/lib/widgets/recordVideo/recordVideo.lifecycle.test.js +0 -106
|
@@ -2,9 +2,14 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
2
2
|
import "core-js/modules/esnext.iterator.constructor.js";
|
|
3
3
|
import "core-js/modules/esnext.iterator.map.js";
|
|
4
4
|
import React, { useContext, useEffect, useRef, useState } from 'react';
|
|
5
|
-
import { View,
|
|
5
|
+
import { View, usePageEvent } from '@ray-js/ray';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
7
|
import { useMemoizedFn } from 'ahooks';
|
|
8
|
+
import { usePlayerRenderMode } from '../../renderer/context';
|
|
9
|
+
import { clipZoomDock } from './lynxDockLayout';
|
|
10
|
+
import { dialGeometry } from './turntable/lynxModel';
|
|
11
|
+
import { STYLE_OPTIONS_RIGHT, CROP_RATIO_RIGHT, FORCE_SHOW_ZOOM_TIP, LONG_PRESS_MS, MOVE_TOLERANCE, TIP_RESHOW_DELAY, getZoomDockBottom, getZoomDockHeight, getZoomDockRight, ZOOM_DOCK_Z_INDEX, zoomTurntableClose, zoomTurntableDockId, zoomTurntableOpen, zoomTurntableTipId } from './constants';
|
|
12
|
+
import { PlayerText as Text } from '../../renderer/text';
|
|
8
13
|
import { useStore } from '../../ctx/store';
|
|
9
14
|
import { UIEventContext } from '../../ui/context';
|
|
10
15
|
import { PlayState } from '../../interface';
|
|
@@ -15,7 +20,6 @@ import { ZoomTurntableDock } from './zoomTurntableDock';
|
|
|
15
20
|
import { ZoomTurntableTip } from './zoomTurntableTip';
|
|
16
21
|
import { measureBottomBarHeight, measureEntryVisible } from './measureVisible';
|
|
17
22
|
import { ZOOM_ENTRY_ANCHOR_CLS } from './entryAnchor';
|
|
18
|
-
import { FORCE_SHOW_ZOOM_TIP, LONG_PRESS_MS, MOVE_TOLERANCE, TIP_RESHOW_DELAY, getZoomDockBottom, getZoomDockHeight, getZoomDockRight, ZOOM_DOCK_Z_INDEX, zoomTurntableClose, zoomTurntableDockId, zoomTurntableOpen, zoomTurntableTipId } from './constants';
|
|
19
23
|
import './zoomTurntableEntry.less';
|
|
20
24
|
/**
|
|
21
25
|
* 焦距转盘入口:左下角工具条中的图标,长按弹出转盘。
|
|
@@ -24,6 +28,7 @@ import './zoomTurntableEntry.less';
|
|
|
24
28
|
*/
|
|
25
29
|
export const ZoomTurntableEntry = props => {
|
|
26
30
|
var _props$event;
|
|
31
|
+
const renderMode = usePlayerRenderMode();
|
|
27
32
|
const {
|
|
28
33
|
devId,
|
|
29
34
|
className,
|
|
@@ -128,27 +133,35 @@ export const ZoomTurntableEntry = props => {
|
|
|
128
133
|
}
|
|
129
134
|
event.emit(pauseTimeToHideAllComponent);
|
|
130
135
|
if (!hasContent('absolute', zoomTurntableDockId)) {
|
|
131
|
-
//
|
|
136
|
+
// 由播放器 absolute 容器承载(不能设 absoluteNoCoverView):WebView 使用 CoverView,Lynx 使用 View,
|
|
132
137
|
// 普通 View 里的 canvas 会被它盖住,touchstart 到不了 canvas,转盘滑不动。
|
|
138
|
+
const legacyPosition = screenType === 'full' ? {
|
|
139
|
+
top: 0,
|
|
140
|
+
right: getZoomDockRight(),
|
|
141
|
+
bottom: 0,
|
|
142
|
+
zIndex: ZOOM_DOCK_Z_INDEX
|
|
143
|
+
} : {
|
|
144
|
+
left: 0,
|
|
145
|
+
right: 0,
|
|
146
|
+
// 一律是带单位的 px 字符串 —— 裸数字会被当 rpx,见 constants 里 px() 的说明。
|
|
147
|
+
// 竖屏全屏让出底部工具条(实测高度,避免与 ui.tsx 的写死值不同步);
|
|
148
|
+
// 普通竖屏工具条已藏,直接下沉一份底部触摸余量贴住播放器底边。
|
|
149
|
+
bottom: getZoomDockBottom(isVerticalFull, barHeight),
|
|
150
|
+
height: getZoomDockHeight(isVerticalFull),
|
|
151
|
+
zIndex: ZOOM_DOCK_Z_INDEX
|
|
152
|
+
};
|
|
153
|
+
const clipped = renderMode === 'lynx' ? clipZoomDock(legacyPosition, screenType === 'full' ? dialGeometry({
|
|
154
|
+
orientation: 'right',
|
|
155
|
+
cropRatio: CROP_RATIO_RIGHT,
|
|
156
|
+
styleOptions: STYLE_OPTIONS_RIGHT
|
|
157
|
+
}).width : undefined) : null;
|
|
133
158
|
addContent('absolute', {
|
|
134
159
|
id: zoomTurntableDockId,
|
|
135
160
|
content: dockProps => /*#__PURE__*/React.createElement(ZoomTurntableDock, dockProps),
|
|
136
|
-
absolutePosition:
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
zIndex: ZOOM_DOCK_Z_INDEX
|
|
141
|
-
} : {
|
|
142
|
-
left: 0,
|
|
143
|
-
right: 0,
|
|
144
|
-
// 一律是带单位的 px 字符串 —— 裸数字会被当 rpx,见 constants 里 px() 的说明。
|
|
145
|
-
// 竖屏全屏让出底部工具条(实测高度,避免与 ui.tsx 的写死值不同步);
|
|
146
|
-
// 普通竖屏工具条已藏,直接下沉一份底部触摸余量贴住播放器底边。
|
|
147
|
-
bottom: getZoomDockBottom(isVerticalFull, barHeight),
|
|
148
|
-
height: getZoomDockHeight(isVerticalFull),
|
|
149
|
-
zIndex: ZOOM_DOCK_Z_INDEX
|
|
150
|
-
},
|
|
151
|
-
initProps: _objectSpread(_objectSpread({}, props), {}, {
|
|
161
|
+
absolutePosition: (clipped === null || clipped === void 0 ? void 0 : clipped.position) || legacyPosition,
|
|
162
|
+
initProps: _objectSpread(_objectSpread({
|
|
163
|
+
lynxClipContentStyle: clipped === null || clipped === void 0 ? void 0 : clipped.content
|
|
164
|
+
}, props), {}, {
|
|
152
165
|
skipLoad: true
|
|
153
166
|
})
|
|
154
167
|
});
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { View } from '@ray-js/ray';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
+
import { usePlayerOverlayHost } from '../../renderer/overlay';
|
|
5
|
+
import { usePlayerRenderMode } from '../../renderer/context';
|
|
6
|
+
import { PlayerText as Text } from '../../renderer/text';
|
|
4
7
|
import { useStore } from '../../ctx/store';
|
|
5
8
|
import { PlayState } from '../../interface';
|
|
6
9
|
import { widgetClick, widgetLabs } from '../../ui/constant';
|
|
@@ -16,11 +19,13 @@ import './zoomTurntableTip.less';
|
|
|
16
19
|
* 差别在于入口位于横向 ScrollView 内、位置不固定,所以圈选框坐标由 JS 内联注入而非写死。
|
|
17
20
|
*/
|
|
18
21
|
export const ZoomTurntableTip = props => {
|
|
22
|
+
const Host = usePlayerOverlayHost();
|
|
19
23
|
const {
|
|
20
24
|
devId,
|
|
21
25
|
deleteContent,
|
|
22
26
|
anchorRect
|
|
23
27
|
} = props;
|
|
28
|
+
const isLynx = usePlayerRenderMode() === 'lynx';
|
|
24
29
|
const {
|
|
25
30
|
playState
|
|
26
31
|
} = useStore({
|
|
@@ -64,7 +69,18 @@ export const ZoomTurntableTip = props => {
|
|
|
64
69
|
if (playState !== PlayState.PLAYING || !layout) {
|
|
65
70
|
return null;
|
|
66
71
|
}
|
|
67
|
-
return /*#__PURE__*/React.createElement(
|
|
72
|
+
return /*#__PURE__*/React.createElement(Host, {
|
|
73
|
+
className: isLynx ? 'ipc-player-plugin-zoom-turntable-tip-native' : undefined,
|
|
74
|
+
style: isLynx ? {
|
|
75
|
+
position: 'absolute',
|
|
76
|
+
left: 0,
|
|
77
|
+
right: 0,
|
|
78
|
+
top: 0,
|
|
79
|
+
bottom: 0,
|
|
80
|
+
width: '100%',
|
|
81
|
+
height: '100%'
|
|
82
|
+
} : undefined
|
|
83
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
68
84
|
className: clsx('ipc-player-plugin-zoom-turntable-tip-ring'),
|
|
69
85
|
style: layout.ring
|
|
70
86
|
}), /*#__PURE__*/React.createElement(View, {
|
|
@@ -84,5 +100,10 @@ export const ZoomTurntableTip = props => {
|
|
|
84
100
|
const storage = new Storage(devId);
|
|
85
101
|
storage.set(zoomTurntableTipId, true);
|
|
86
102
|
}
|
|
87
|
-
},
|
|
103
|
+
}, isLynx ? /*#__PURE__*/React.createElement(Text, {
|
|
104
|
+
style: {
|
|
105
|
+
fontSize: '12px',
|
|
106
|
+
lineHeight: '17px'
|
|
107
|
+
}
|
|
108
|
+
}, Strings.getLang('ipc_player_tip_confirm')) : Strings.getLang('ipc_player_tip_confirm'))));
|
|
88
109
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/ipc-player-integration",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.68-beta.0",
|
|
4
4
|
"description": "IPC 融合播放器",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"files": [
|
|
@@ -29,17 +29,19 @@
|
|
|
29
29
|
"start:web": "ray start ./example -t web",
|
|
30
30
|
"prepublishOnly": "yarn build",
|
|
31
31
|
"release-it": "standard-version",
|
|
32
|
-
"test": "yarn jest"
|
|
32
|
+
"test": "yarn jest",
|
|
33
|
+
"test:lynx": "node --test tests/*.test.cjs",
|
|
34
|
+
"test:features": "jest --runInBand --runTestsByPath tests/master-features.test.tsx tests/auto-clarity-config.test.tsx src/utils/authorize/album.test.ts src/widgets/recordVideo/recordVideo.test.tsx src/widgets/screenshot/screenshot.test.tsx src/widgets/zoomTurntable/lensModel.test.ts src/widgets/muted/muted.test.tsx tests/zoom-turntable-tip.test.tsx tests/zoom-turntable-touch.test.tsx"
|
|
33
35
|
},
|
|
34
36
|
"peerDependencies": {
|
|
35
37
|
"ahooks": "^3.1.6"
|
|
36
38
|
},
|
|
37
39
|
"dependencies": {
|
|
38
|
-
"@ray-js/direction-control": "
|
|
39
|
-
"@ray-js/ipc-ptz-zoom": "
|
|
40
|
-
"@ray-js/ray-ipc-player": "2.1.7-beta.0",
|
|
40
|
+
"@ray-js/direction-control": "0.0.13-beta.1",
|
|
41
|
+
"@ray-js/ipc-ptz-zoom": "0.0.5-beta.0",
|
|
41
42
|
"@ray-js/panel-sdk": "^1.13.1",
|
|
42
|
-
"@ray-js/ray-ipc-
|
|
43
|
+
"@ray-js/ray-ipc-player": "2.1.8-beta.0",
|
|
44
|
+
"@ray-js/ray-ipc-utils": "^1.1.18",
|
|
43
45
|
"@ray-js/svg": "0.2.0",
|
|
44
46
|
"clsx": "^1.2.1",
|
|
45
47
|
"color": "^5.0.2",
|
|
@@ -57,7 +59,13 @@
|
|
|
57
59
|
"eslint-config-tuya-panel": "^0.4.2",
|
|
58
60
|
"husky": "^1.2.0",
|
|
59
61
|
"lint-staged": "^10.2.11",
|
|
60
|
-
"standard-version": "9.3.2"
|
|
62
|
+
"standard-version": "9.3.2",
|
|
63
|
+
"react": "17.0.2",
|
|
64
|
+
"react-dom": "17.0.2",
|
|
65
|
+
"typescript": "4.9.5",
|
|
66
|
+
"jest": "29.7.0",
|
|
67
|
+
"ts-jest": "29.2.6",
|
|
68
|
+
"jest-environment-jsdom": "29.7.0"
|
|
61
69
|
},
|
|
62
70
|
"resolutions": {
|
|
63
71
|
"@ray-js/builder-mp": "^1.7.62"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import { act, renderHook } from '@testing-library/react-hooks/dom';
|
|
3
|
-
import { authorize, authorizeStatus, getSystemInfoSync, showModal } from '@ray-js/ray';
|
|
4
|
-
import { createUseCtx } from './ctx';
|
|
5
|
-
import { useStore } from './store';
|
|
6
|
-
jest.mock('@ray-js/ray', () => ({
|
|
7
|
-
authorize: jest.fn(),
|
|
8
|
-
authorizeStatus: jest.fn(),
|
|
9
|
-
getSystemInfoSync: jest.fn(),
|
|
10
|
-
openAppSystemSettingPage: jest.fn(),
|
|
11
|
-
showModal: jest.fn()
|
|
12
|
-
}));
|
|
13
|
-
jest.mock('@ray-js/ray-ipc-utils/lib/interface', () => ({
|
|
14
|
-
ClarityType: {
|
|
15
|
-
HD: 'HD',
|
|
16
|
-
SD: 'SD',
|
|
17
|
-
AUTO: 'AUTO'
|
|
18
|
-
},
|
|
19
|
-
IntercomMode: {
|
|
20
|
-
OneWay: 'OneWay',
|
|
21
|
-
TwoWay: 'TwoWay'
|
|
22
|
-
}
|
|
23
|
-
}));
|
|
24
|
-
jest.mock('../i18n', () => ({
|
|
25
|
-
__esModule: true,
|
|
26
|
-
default: {
|
|
27
|
-
getLang: key => key
|
|
28
|
-
}
|
|
29
|
-
}));
|
|
30
|
-
jest.mock('./multiCameraCtx', () => ({
|
|
31
|
-
isMultiCameraTileSupported: () => false,
|
|
32
|
-
useMultiCameraCtx: () => ({})
|
|
33
|
-
}));
|
|
34
|
-
jest.mock('../utils/ttt', () => ({
|
|
35
|
-
getCachedAutoClarity: jest.fn(),
|
|
36
|
-
isClarityChangedSupported: () => false,
|
|
37
|
-
setCachedAutoClarity: jest.fn(),
|
|
38
|
-
subscribeClarityChanged: () => () => undefined
|
|
39
|
-
}));
|
|
40
|
-
beforeEach(() => {
|
|
41
|
-
jest.clearAllMocks();
|
|
42
|
-
getSystemInfoSync.mockReturnValue({
|
|
43
|
-
platform: 'android',
|
|
44
|
-
system: 'android 12'
|
|
45
|
-
});
|
|
46
|
-
authorizeStatus.mockImplementation(_ref => {
|
|
47
|
-
let {
|
|
48
|
-
fail
|
|
49
|
-
} = _ref;
|
|
50
|
-
return fail({
|
|
51
|
-
errorCode: 9004
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
authorize.mockImplementation(_ref2 => {
|
|
55
|
-
let {
|
|
56
|
-
fail
|
|
57
|
-
} = _ref2;
|
|
58
|
-
return fail({
|
|
59
|
-
errorCode: 9004
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
const mountContext = function () {
|
|
64
|
-
let saveToAlbum = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
65
|
-
const capture = {
|
|
66
|
-
tempImagePath: 'thingfile://capture.jpg',
|
|
67
|
-
filePath: 'thingfile://record.mp4'
|
|
68
|
-
};
|
|
69
|
-
const startRecord = jest.fn(_ref3 => {
|
|
70
|
-
let {
|
|
71
|
-
success
|
|
72
|
-
} = _ref3;
|
|
73
|
-
return success();
|
|
74
|
-
});
|
|
75
|
-
const stopRecord = jest.fn(_ref4 => {
|
|
76
|
-
let {
|
|
77
|
-
success
|
|
78
|
-
} = _ref4;
|
|
79
|
-
return success(capture);
|
|
80
|
-
});
|
|
81
|
-
const useCtx = createUseCtx({
|
|
82
|
-
createPlayContext: () => ({
|
|
83
|
-
startRecord,
|
|
84
|
-
stopRecord
|
|
85
|
-
}),
|
|
86
|
-
getMemoryState: jest.fn().mockResolvedValue({
|
|
87
|
-
resolution: 'HD',
|
|
88
|
-
resolutionList: ['HD', 'SD'],
|
|
89
|
-
mute: true,
|
|
90
|
-
intercomMode: 'TwoWay',
|
|
91
|
-
isIntercomSupported: false
|
|
92
|
-
}),
|
|
93
|
-
setResolutionMemoryState: jest.fn(),
|
|
94
|
-
setMuteMemoryState: jest.fn(),
|
|
95
|
-
authorizeStatus: jest.fn(),
|
|
96
|
-
toast: jest.fn()
|
|
97
|
-
});
|
|
98
|
-
const hook = renderHook(() => {
|
|
99
|
-
const ctx = useCtx({
|
|
100
|
-
devId: 'camera-1',
|
|
101
|
-
multiLens: true,
|
|
102
|
-
saveToAlbum
|
|
103
|
-
});
|
|
104
|
-
const state = useStore({
|
|
105
|
-
recording: ctx.recording
|
|
106
|
-
});
|
|
107
|
-
return _objectSpread(_objectSpread({}, ctx), {}, {
|
|
108
|
-
state
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
return _objectSpread(_objectSpread({}, hook), {}, {
|
|
112
|
-
startRecord,
|
|
113
|
-
stopRecord,
|
|
114
|
-
capture
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
it('starts without legacy authorization and retains the native stop result', async () => {
|
|
118
|
-
const {
|
|
119
|
-
result,
|
|
120
|
-
startRecord,
|
|
121
|
-
stopRecord,
|
|
122
|
-
capture,
|
|
123
|
-
unmount
|
|
124
|
-
} = mountContext();
|
|
125
|
-
await act(async () => {
|
|
126
|
-
expect(await result.current.setRecording(true)).toBe(true);
|
|
127
|
-
});
|
|
128
|
-
expect(startRecord).toHaveBeenCalledWith(expect.objectContaining({
|
|
129
|
-
saveToAlbum: 1
|
|
130
|
-
}));
|
|
131
|
-
expect(result.current.state.recording).toBe(true);
|
|
132
|
-
expect(result.current.multiLens).toBe(true);
|
|
133
|
-
await act(async () => {
|
|
134
|
-
expect(await result.current.setRecording(false)).toEqual(capture);
|
|
135
|
-
});
|
|
136
|
-
expect(stopRecord).toHaveBeenCalledTimes(1);
|
|
137
|
-
expect(result.current.state.recording).toBe(false);
|
|
138
|
-
expect(authorizeStatus).not.toHaveBeenCalled();
|
|
139
|
-
expect(authorize).not.toHaveBeenCalled();
|
|
140
|
-
unmount();
|
|
141
|
-
});
|
|
142
|
-
it('settles a denied start without calling the native recorder', async () => {
|
|
143
|
-
getSystemInfoSync.mockReturnValue({
|
|
144
|
-
platform: 'ios',
|
|
145
|
-
system: 'iOS 18'
|
|
146
|
-
});
|
|
147
|
-
const {
|
|
148
|
-
result,
|
|
149
|
-
startRecord,
|
|
150
|
-
unmount
|
|
151
|
-
} = mountContext();
|
|
152
|
-
await act(async () => {
|
|
153
|
-
expect(await result.current.setRecording(true)).toBe(false);
|
|
154
|
-
});
|
|
155
|
-
expect(startRecord).not.toHaveBeenCalled();
|
|
156
|
-
expect(result.current.state.recording).toBe(false);
|
|
157
|
-
expect(showModal).toHaveBeenCalledTimes(1);
|
|
158
|
-
unmount();
|
|
159
|
-
});
|
|
160
|
-
it('propagates a native start failure without entering recording state', async () => {
|
|
161
|
-
const {
|
|
162
|
-
result,
|
|
163
|
-
startRecord,
|
|
164
|
-
unmount
|
|
165
|
-
} = mountContext();
|
|
166
|
-
const error = {
|
|
167
|
-
errorCode: 1001,
|
|
168
|
-
errorMsg: 'Start failed'
|
|
169
|
-
};
|
|
170
|
-
startRecord.mockImplementationOnce(_ref5 => {
|
|
171
|
-
let {
|
|
172
|
-
fail
|
|
173
|
-
} = _ref5;
|
|
174
|
-
return fail(error);
|
|
175
|
-
});
|
|
176
|
-
await act(async () => {
|
|
177
|
-
await expect(result.current.setRecording(true)).rejects.toEqual(error);
|
|
178
|
-
});
|
|
179
|
-
expect(result.current.state.recording).toBe(false);
|
|
180
|
-
unmount();
|
|
181
|
-
});
|
|
182
|
-
it('keeps the requested album when stopping on page unload', async () => {
|
|
183
|
-
const {
|
|
184
|
-
result,
|
|
185
|
-
stopRecord,
|
|
186
|
-
capture,
|
|
187
|
-
unmount
|
|
188
|
-
} = mountContext(0);
|
|
189
|
-
await act(async () => {
|
|
190
|
-
expect(await result.current.stopRecordingOnUnload()).toEqual(capture);
|
|
191
|
-
});
|
|
192
|
-
expect(stopRecord).toHaveBeenCalledWith(expect.objectContaining({
|
|
193
|
-
saveToAlbum: 0
|
|
194
|
-
}));
|
|
195
|
-
expect(authorizeStatus).not.toHaveBeenCalled();
|
|
196
|
-
unmount();
|
|
197
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { act, renderHook } from '@testing-library/react-hooks';
|
|
2
|
-
jest.mock('@ray-js/ray-ipc-utils', () => ({}));
|
|
3
|
-
jest.mock('@ray-js/ray-ipc-utils/lib/interface', () => ({}));
|
|
4
|
-
jest.mock('../hooks', () => ({
|
|
5
|
-
useDpSupport: () => ({})
|
|
6
|
-
}));
|
|
7
|
-
jest.mock('../utils', () => ({}));
|
|
8
|
-
const {
|
|
9
|
-
useMultiCameraCtx
|
|
10
|
-
} = require('./multiCameraCtx');
|
|
11
|
-
const {
|
|
12
|
-
getDefaultStore,
|
|
13
|
-
updateAtom
|
|
14
|
-
} = require('./store');
|
|
15
|
-
const {
|
|
16
|
-
MultiCameraScreenMode
|
|
17
|
-
} = require('../interface');
|
|
18
|
-
it('keeps the portrait PTZ opt-out across player remounts until the miniapp restarts', () => {
|
|
19
|
-
const props = {
|
|
20
|
-
devId: 'test-device',
|
|
21
|
-
IPCPlayerInstance: {
|
|
22
|
-
switchLayoutStyle: () => undefined
|
|
23
|
-
},
|
|
24
|
-
videoSplitProtocol: {
|
|
25
|
-
total_split_num: 2,
|
|
26
|
-
p_v: 3,
|
|
27
|
-
split_info: []
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
const store = getDefaultStore();
|
|
31
|
-
const player = renderHook(() => useMultiCameraCtx(props));
|
|
32
|
-
const isOpen = () => store.get(player.result.current.ptzStatus);
|
|
33
|
-
act(() => player.result.current.openDefaultPtz());
|
|
34
|
-
expect(isOpen()).toBe(true);
|
|
35
|
-
|
|
36
|
-
// Programmatic collapse must not disable the next automatic expansion.
|
|
37
|
-
act(() => player.result.current.setPtzStatus(false));
|
|
38
|
-
act(() => player.result.current.openDefaultPtz());
|
|
39
|
-
expect(isOpen()).toBe(true);
|
|
40
|
-
|
|
41
|
-
// Landscape interaction must not opt out of the portrait-only policy.
|
|
42
|
-
act(() => updateAtom(player.result.current.screenMode, MultiCameraScreenMode.landscape));
|
|
43
|
-
act(() => player.result.current.togglePtz());
|
|
44
|
-
expect(isOpen()).toBe(false);
|
|
45
|
-
act(() => updateAtom(player.result.current.screenMode, MultiCameraScreenMode.full));
|
|
46
|
-
act(() => player.result.current.openDefaultPtz());
|
|
47
|
-
expect(isOpen()).toBe(true);
|
|
48
|
-
act(() => player.result.current.togglePtz());
|
|
49
|
-
act(() => player.result.current.openDefaultPtz());
|
|
50
|
-
expect(isOpen()).toBe(false);
|
|
51
|
-
|
|
52
|
-
// Explicit reopening remains available without clearing the opt-out.
|
|
53
|
-
act(() => player.result.current.togglePtz());
|
|
54
|
-
expect(isOpen()).toBe(true);
|
|
55
|
-
act(() => player.result.current.setPtzStatus(false));
|
|
56
|
-
act(() => player.result.current.openDefaultPtz());
|
|
57
|
-
expect(isOpen()).toBe(false);
|
|
58
|
-
player.unmount();
|
|
59
|
-
const remounted = renderHook(() => useMultiCameraCtx(props));
|
|
60
|
-
act(() => remounted.result.current.openDefaultPtz());
|
|
61
|
-
expect(store.get(remounted.result.current.ptzStatus)).toBe(false);
|
|
62
|
-
act(() => remounted.result.current.togglePtz());
|
|
63
|
-
expect(store.get(remounted.result.current.ptzStatus)).toBe(true);
|
|
64
|
-
remounted.unmount();
|
|
65
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { CaptureResult } from '../interface';
|
|
2
|
-
export type CaptureResultSummary = {
|
|
3
|
-
count: number;
|
|
4
|
-
isMultiLens: boolean;
|
|
5
|
-
thumbnailPath: string;
|
|
6
|
-
};
|
|
7
|
-
export type CaptureResultOptions = {
|
|
8
|
-
multiLens: boolean;
|
|
9
|
-
lensIndices?: number[];
|
|
10
|
-
devId: string;
|
|
11
|
-
};
|
|
12
|
-
export declare function getCaptureResultSummary(result: CaptureResult, { multiLens, lensIndices, devId }: CaptureResultOptions): Promise<CaptureResultSummary | null>;
|
|
@@ -1,70 +0,0 @@
|
|
|
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
|
-
/* eslint-disable camelcase */
|
|
5
|
-
import { getFileSystemManager } from '@ray-js/ray';
|
|
6
|
-
import { getDeviceInfo } from './device';
|
|
7
|
-
const MULTI_LENS_ABILITY_CODE = 'tyabimr4v3';
|
|
8
|
-
const LENS_SUFFIX_PATTERN = /_lens\d+(?=\.[^./?#]+(?:[?#].*)?$)/;
|
|
9
|
-
const FILE_EXTENSION_PATTERN = /(\.[^./?#]+)([?#].*)?$/;
|
|
10
|
-
const getMultiLensIndices = async devId => {
|
|
11
|
-
try {
|
|
12
|
-
var _devInfo$configMetas, _config$split_info;
|
|
13
|
-
const devInfo = await getDeviceInfo(devId);
|
|
14
|
-
const raw = devInfo === null || devInfo === void 0 || (_devInfo$configMetas = devInfo.configMetas) === null || _devInfo$configMetas === void 0 ? void 0 : _devInfo$configMetas[MULTI_LENS_ABILITY_CODE];
|
|
15
|
-
const config = typeof raw === 'string' ? JSON.parse(raw) : raw;
|
|
16
|
-
return (config === null || config === void 0 || (_config$split_info = config.split_info) === null || _config$split_info === void 0 ? void 0 : _config$split_info.map(item => Number(item.index))) || [];
|
|
17
|
-
} catch {
|
|
18
|
-
return [];
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
const getLensPath = (path, index) => path.replace(LENS_SUFFIX_PATTERN, '').replace(FILE_EXTENSION_PATTERN, `_lens${index}$1$2`);
|
|
22
|
-
const extractPath = item => {
|
|
23
|
-
if (typeof item === 'string') return item;
|
|
24
|
-
if (typeof (item === null || item === void 0 ? void 0 : item.value) === 'string') return item.value;
|
|
25
|
-
return '';
|
|
26
|
-
};
|
|
27
|
-
const imageExists = async path => {
|
|
28
|
-
if (!path) return false;
|
|
29
|
-
try {
|
|
30
|
-
const manager = await getFileSystemManager();
|
|
31
|
-
return await new Promise(resolve => {
|
|
32
|
-
manager.access({
|
|
33
|
-
path,
|
|
34
|
-
success: () => resolve(true),
|
|
35
|
-
fail: () => resolve(false)
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
} catch {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
export async function getCaptureResultSummary(result, _ref) {
|
|
43
|
-
let {
|
|
44
|
-
multiLens,
|
|
45
|
-
lensIndices,
|
|
46
|
-
devId
|
|
47
|
-
} = _ref;
|
|
48
|
-
if (!result || typeof result === 'boolean') return null;
|
|
49
|
-
if (!multiLens) {
|
|
50
|
-
return {
|
|
51
|
-
count: 1,
|
|
52
|
-
isMultiLens: false,
|
|
53
|
-
thumbnailPath: extractPath(result.tempImagePath) || extractPath(result.thumbPath) || extractPath(result.filePath)
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
const thumbnailPath = extractPath(result.thumbPath) || extractPath(result.tempImagePath);
|
|
57
|
-
if (!thumbnailPath) return null;
|
|
58
|
-
const indices = [...new Set(lensIndices !== null && lensIndices !== void 0 && lensIndices.length ? lensIndices : await getMultiLensIndices(devId))];
|
|
59
|
-
const thumbnails = await Promise.all(indices.map(async index => {
|
|
60
|
-
const path = getLensPath(thumbnailPath, index);
|
|
61
|
-
return (await imageExists(path)) ? path : '';
|
|
62
|
-
}));
|
|
63
|
-
const existingThumbnails = thumbnails.filter(Boolean);
|
|
64
|
-
if (!existingThumbnails.length) return null;
|
|
65
|
-
return {
|
|
66
|
-
count: existingThumbnails.length,
|
|
67
|
-
isMultiLens: true,
|
|
68
|
-
thumbnailPath: existingThumbnails[0]
|
|
69
|
-
};
|
|
70
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|