@ray-js/ipc-player-integration 0.0.64 → 0.0.65-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ctx/ctx.album.test.d.ts +1 -0
- package/lib/ctx/ctx.album.test.js +197 -0
- package/lib/ctx/ctx.composition.js +13 -3
- package/lib/ctx/ctx.js +46 -35
- package/lib/i18n/index.d.ts +12 -0
- package/lib/i18n/strings.d.ts +6 -0
- package/lib/i18n/strings.js +6 -0
- package/lib/interface.d.ts +17 -3
- package/lib/ui/absoluteContent.d.ts +2 -0
- package/lib/ui/absoluteContent.js +3 -0
- package/lib/ui/bottomLeftContent.js +3 -1
- package/lib/ui/ui.js +65 -52
- package/lib/utils/captureResult.d.ts +14 -0
- package/lib/utils/captureResult.js +70 -0
- package/lib/utils/captureResult.test.d.ts +1 -0
- package/lib/utils/captureResult.test.js +117 -0
- package/lib/utils/fullLinkTracking.d.ts +5 -0
- package/lib/utils/fullLinkTracking.js +71 -0
- package/lib/utils/navigation.d.ts +2 -1
- package/lib/utils/navigation.js +13 -3
- package/lib/widgets/captureResult/captureResult.d.ts +16 -0
- package/lib/widgets/captureResult/captureResult.js +85 -0
- package/lib/widgets/captureResult/captureResult.less +144 -0
- package/lib/widgets/captureResult/captureResult.test.d.ts +1 -0
- package/lib/widgets/captureResult/captureResult.test.js +80 -0
- package/lib/widgets/captureResult/index.d.ts +2 -0
- package/lib/widgets/captureResult/index.js +2 -0
- package/lib/widgets/index.d.ts +1 -0
- package/lib/widgets/index.js +2 -1
- package/lib/widgets/multiCamera/index.less +1 -0
- package/lib/widgets/multiCamera/moveablePtzControl.js +4 -4
- package/lib/widgets/recordVideo/recordVideo.js +53 -52
- package/lib/widgets/recordVideo/recordVideo.less +17 -74
- package/lib/widgets/recordVideo/recordVideo.lifecycle.test.d.ts +1 -0
- package/lib/widgets/recordVideo/recordVideo.lifecycle.test.js +106 -0
- package/lib/widgets/recordVideo/recordVideo.test.js +1 -0
- package/lib/widgets/screenshot/screenshot.js +66 -44
- package/lib/widgets/screenshot/screenshot.less +1 -40
- package/lib/widgets/screenshot/screenshot.test.d.ts +1 -0
- package/lib/widgets/screenshot/screenshot.test.js +120 -0
- package/lib/widgets/trialBadge/index.d.ts +2 -1
- package/lib/widgets/trialBadge/index.js +17 -9
- package/lib/widgets/trialBadge/useTrialBadge.d.ts +3 -2
- package/lib/widgets/trialBadge/useTrialBadge.js +13 -2
- package/package.json +2 -2
package/lib/ui/ui.js
CHANGED
|
@@ -14,21 +14,23 @@ import { ipcTTTOperatorLog } from '@ray-js/ray-ipc-utils';
|
|
|
14
14
|
import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
|
|
15
15
|
import { PlayState, PlayerStreamStatus, MultiCameraScreenMode } from '../interface';
|
|
16
16
|
import { useCtx } from '../ctx/ctx.composition';
|
|
17
|
-
import { useStore, updateAtom
|
|
17
|
+
import { useStore, updateAtom } from '../ctx/store';
|
|
18
18
|
import { UIEventContext } from './context';
|
|
19
|
-
import { showAllComponent, hideAllComponent, playerTap, startTimeToHideAllComponent, pauseTimeToHideAllComponent, decodeClarityDic, changeIgnoreHideStopPreview, moveablePtzControlId, tileActionsId, tileTipId, landscapeTipId, multiPtzId, ptzMoveableTipId, showFlowLowTipId, zoomLevelChange, setScaleMultipleEvent, trialCountdownEnd, refreshSmartImageQualityEvent } from './constant';
|
|
19
|
+
import { showAllComponent, hideAllComponent, playerTap, startTimeToHideAllComponent, pauseTimeToHideAllComponent, decodeClarityDic, changeIgnoreHideStopPreview, moveablePtzControlId, tileActionsId, tileTipId, landscapeTipId, multiPtzId, ptzMoveableTipId, ptzControlTipId, showFlowLowTipId, zoomLevelChange, setScaleMultipleEvent, trialCountdownEnd, refreshSmartImageQualityEvent } from './constant';
|
|
20
20
|
import BottomLeftContent from './bottomLeftContent';
|
|
21
21
|
import BottomRightContent from './bottomRightContent';
|
|
22
22
|
import TopLeftContent from './topLeftContent';
|
|
23
23
|
import TopRightContent from './topRightContent';
|
|
24
24
|
import { useOfflineShownNotification } from './useOfflineShownNotification';
|
|
25
|
-
import { FlowLowTip, VideoBitKBP } from '../widgets';
|
|
25
|
+
import { FlowLowTip, VideoBitKBP, zoomTurntableTipId } from '../widgets';
|
|
26
26
|
import { useMemoizedFn } from '../hooks';
|
|
27
27
|
import { Storage } from '../utils/storage';
|
|
28
28
|
import './ui.less';
|
|
29
29
|
import { updatePlayerWidgetProps } from '../features';
|
|
30
30
|
import { getNgRawData, getSmartImageQualityState, isLowPhone } from '../utils/ttt';
|
|
31
|
+
import { getCaptureResultSummary } from '../utils/captureResult';
|
|
31
32
|
import { lensCount } from '../widgets/zoomTurntable/lensSkill';
|
|
33
|
+
import { shouldRenderContent } from './absoluteContent';
|
|
32
34
|
const AutoClarityOnly = _ref => {
|
|
33
35
|
let {
|
|
34
36
|
instance
|
|
@@ -329,6 +331,9 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
329
331
|
maxZoomSettings: instance.maxZoomSettings,
|
|
330
332
|
zoomSkill: instance.zoomSkill
|
|
331
333
|
});
|
|
334
|
+
const hasVisibleGuideTip = absoluteContent === null || absoluteContent === void 0 ? void 0 : absoluteContent.some(item => [tileTipId, landscapeTipId, ptzMoveableTipId, ptzControlTipId, zoomTurntableTipId].includes(item.id) && playState === PlayState.PLAYING && shouldRenderContent(item, {
|
|
335
|
+
playState
|
|
336
|
+
}));
|
|
332
337
|
|
|
333
338
|
// 默认最大缩放倍数下发给播放器;多镜头设备的上限要按当前镜头换算,交给 zoomTurntable 下发
|
|
334
339
|
useEffect(() => {
|
|
@@ -454,13 +459,16 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
454
459
|
instance.multiCameraCtx.getNextLayoutStyle().then(res => {
|
|
455
460
|
instance.multiCameraCtx.setNextLayoutStyle(res);
|
|
456
461
|
});
|
|
462
|
+
if (isVerticalFullLayout && screenType === 'vertical') {
|
|
463
|
+
showComponents();
|
|
464
|
+
}
|
|
457
465
|
}, [layoutStyle, screenMode, instance]);
|
|
458
466
|
useEffect(() => {
|
|
459
467
|
if (!instance.multiCameraCtx.isSupport) return;
|
|
460
468
|
|
|
461
469
|
// 组件隐藏时也隐藏镜头名
|
|
462
470
|
instance.multiCameraCtx.showLenNames(!componentHideState);
|
|
463
|
-
}, [componentHideState, instance]);
|
|
471
|
+
}, [componentHideState, instance, layoutStyle, screenMode]);
|
|
464
472
|
useEffect(() => {
|
|
465
473
|
if (!instance.multiCameraCtx.isSupport) return;
|
|
466
474
|
if (ptzStatus) {
|
|
@@ -471,7 +479,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
471
479
|
}, [instance, ptzStatus]);
|
|
472
480
|
useEffect(() => {
|
|
473
481
|
if (!instance.multiCameraCtx.isSupport) return;
|
|
474
|
-
if (!ptzStatus || screenMode !== MultiCameraScreenMode.full) {
|
|
482
|
+
if (!ptzStatus || screenMode !== MultiCameraScreenMode.full || componentHideState) {
|
|
475
483
|
instance.hideContent('absolute', ptzMoveableTipId);
|
|
476
484
|
}
|
|
477
485
|
|
|
@@ -485,7 +493,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
485
493
|
|
|
486
494
|
// ptz 提示
|
|
487
495
|
const storage = new Storage(devId);
|
|
488
|
-
if (!storage.getSync(ptzMoveableTipId) && selectedLenInfo.supportPTZ && screenMode === MultiCameraScreenMode.full) {
|
|
496
|
+
if (!storage.getSync(ptzMoveableTipId) && !componentHideState && selectedLenInfo.supportPTZ && screenMode === MultiCameraScreenMode.full) {
|
|
489
497
|
instance.showContent('absolute', ptzMoveableTipId);
|
|
490
498
|
}
|
|
491
499
|
}
|
|
@@ -506,8 +514,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
506
514
|
const handDisablePlayerTap = useMemoizedFn(value => {
|
|
507
515
|
disablePlayerTap.current = !!value;
|
|
508
516
|
});
|
|
509
|
-
|
|
510
|
-
// 须在竖屏全屏 effect 之前注册,否则多目首帧 emit('disablePlayerTap') 时 listener 尚未挂载
|
|
511
517
|
useEffect(() => {
|
|
512
518
|
eventRef.current.on('disablePlayerTap', handDisablePlayerTap);
|
|
513
519
|
return () => {
|
|
@@ -517,17 +523,10 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
517
523
|
|
|
518
524
|
// 竖屏全屏副作用处理
|
|
519
525
|
useEffect(() => {
|
|
526
|
+
eventRef.current.emit('disablePlayerTap', false);
|
|
527
|
+
showComponents();
|
|
520
528
|
if (isVerticalFullLayout && screenType === 'vertical') {
|
|
521
|
-
// 竖屏全屏时,控件常驻显示
|
|
522
|
-
eventRef.current.emit(showAllComponent);
|
|
523
|
-
eventRef.current.emit('disablePlayerTap', true);
|
|
524
|
-
eventRef.current.emit(pauseTimeToHideAllComponent);
|
|
525
|
-
// 按宽填充,保证播放流宽度为屏幕宽度,高度自适应设为1倍
|
|
526
529
|
setScaleMultiple(1);
|
|
527
|
-
} else {
|
|
528
|
-
// 短屏或横屏时,恢复自动隐藏
|
|
529
|
-
eventRef.current.emit('disablePlayerTap', false);
|
|
530
|
-
showComponents();
|
|
531
530
|
}
|
|
532
531
|
}, [isVerticalFullLayout, screenType, playerFit]);
|
|
533
532
|
useEffect(() => {
|
|
@@ -686,14 +685,16 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
686
685
|
ipcTTTOperatorLog('hide: 调用停止录制方法');
|
|
687
686
|
setRecording(false, true);
|
|
688
687
|
setIntercom(false, true);
|
|
689
|
-
instance === null || instance === void 0 || instance.
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
}
|
|
688
|
+
instance === null || instance === void 0 || instance.stopRecordingOnUnload().then(async result => {
|
|
689
|
+
var _instance$multiLens, _instance$multiCamera;
|
|
690
|
+
const summary = await getCaptureResultSummary(result, {
|
|
691
|
+
multiLens: (_instance$multiLens = instance === null || instance === void 0 ? void 0 : instance.multiLens) !== null && _instance$multiLens !== void 0 ? _instance$multiLens : false,
|
|
692
|
+
protocolCount: instance === null || instance === void 0 || (_instance$multiCamera = instance.multiCameraCtx) === null || _instance$multiCamera === void 0 || (_instance$multiCamera = _instance$multiCamera.protocol) === null || _instance$multiCamera === void 0 ? void 0 : _instance$multiCamera.total_split_num,
|
|
693
|
+
devId
|
|
694
|
+
});
|
|
695
|
+
ipcTTTOperatorLog(summary !== null && summary !== void 0 && summary.isMultiLens ? `hide: stop recording succeeded with ${summary.count} files` : 'hide: 调用停止录制方法成功');
|
|
696
|
+
}).catch(() => {
|
|
697
|
+
ipcTTTOperatorLog('hide: 调用停止录制方法失败');
|
|
697
698
|
});
|
|
698
699
|
ipcTTTOperatorLog('hide: 调用停止对讲方法');
|
|
699
700
|
instance === null || instance === void 0 || instance.IPCPlayerInstance.stopTalk({
|
|
@@ -917,7 +918,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
917
918
|
clearTimeout(timer.current);
|
|
918
919
|
timer.current = null;
|
|
919
920
|
}
|
|
920
|
-
if (!hasUserTappedPlayerRef.current) return;
|
|
921
|
+
if (!hasUserTappedPlayerRef.current || hasVisibleGuideTip) return;
|
|
921
922
|
timer.current = setTimeout(onTimeout, HIDE_COMPONENT_TIME);
|
|
922
923
|
});
|
|
923
924
|
|
|
@@ -946,9 +947,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
946
947
|
const listenStart = useMemoizedFn(() => {
|
|
947
948
|
// 重新开始计时(用户还没点过画面时不启动,见 startHideTimer)
|
|
948
949
|
startHideTimer(() => {
|
|
949
|
-
// 定时器触发时从 store 读最新状态,避免启动时闭包拿到过期的 isVerticalFullLayout
|
|
950
|
-
const store = getDefaultStore();
|
|
951
|
-
if (store.get(instance.isVerticalFullLayout) && store.get(instance.screenType) === 'vertical') return;
|
|
952
950
|
triggerEvent(hideAllComponent);
|
|
953
951
|
});
|
|
954
952
|
});
|
|
@@ -963,6 +961,13 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
963
961
|
if (isHidingByTapRef.current) return;
|
|
964
962
|
setComponentHideState(false);
|
|
965
963
|
});
|
|
964
|
+
useEffect(() => {
|
|
965
|
+
if (hasVisibleGuideTip) {
|
|
966
|
+
showComponents();
|
|
967
|
+
} else {
|
|
968
|
+
listenStart();
|
|
969
|
+
}
|
|
970
|
+
}, [hasVisibleGuideTip]);
|
|
966
971
|
const onChangeIgnoreHideStopPreview = state => {
|
|
967
972
|
setIgnoreStopOnHide(state);
|
|
968
973
|
};
|
|
@@ -1086,7 +1091,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1086
1091
|
return false;
|
|
1087
1092
|
});
|
|
1088
1093
|
const playerContainerHeight = screenType === 'vertical' ? (style === null || style === void 0 ? void 0 : style.height) || '100%' : '100vh';
|
|
1089
|
-
const
|
|
1094
|
+
const bottomHideState = isVerticalFullLayout && screenType === 'vertical' ? false : componentHideState;
|
|
1090
1095
|
return /*#__PURE__*/React.createElement(UIEventContext.Provider, {
|
|
1091
1096
|
value: {
|
|
1092
1097
|
event: eventRef.current,
|
|
@@ -1100,7 +1105,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1100
1105
|
})
|
|
1101
1106
|
}, /*#__PURE__*/React.createElement(View, {
|
|
1102
1107
|
style: {
|
|
1103
|
-
height:
|
|
1108
|
+
height: isVerticalFullLayout && screenType === 'vertical' ? `calc(${playerContainerHeight} - 48px)` : playerContainerHeight
|
|
1104
1109
|
}
|
|
1105
1110
|
}, /*#__PURE__*/React.createElement(IPCPlayer, {
|
|
1106
1111
|
defaultMute: mute,
|
|
@@ -1114,6 +1119,9 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1114
1119
|
onCtx: res => {
|
|
1115
1120
|
if (res) {
|
|
1116
1121
|
setCreateCtx(true);
|
|
1122
|
+
if (instance.multiCameraCtx.isSupport) {
|
|
1123
|
+
instance.multiCameraCtx.showLenNames(!componentHideState);
|
|
1124
|
+
}
|
|
1117
1125
|
}
|
|
1118
1126
|
}
|
|
1119
1127
|
// onPlayerTap={handlePlayerClick}
|
|
@@ -1144,9 +1152,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1144
1152
|
onPlayerTap: data => {
|
|
1145
1153
|
console.log('playerTap event');
|
|
1146
1154
|
if (disablePlayerTap.current) {
|
|
1147
|
-
//
|
|
1148
|
-
// 但用户确实点了画面这个事实仍要派发出去 —— 转盘、PTZ 这类浮层靠它收起。
|
|
1149
|
-
// 不派发的话,竖屏全屏下点播放器关不掉转盘(普通竖屏可以,因为那时没禁用)。
|
|
1155
|
+
// Host overlays may disable toggling; popups still need the tap notification.
|
|
1150
1156
|
console.log('playerTap 事件已禁止显隐切换,仅派发 tap 通知浮层');
|
|
1151
1157
|
eventRef.current.emit(playerTap);
|
|
1152
1158
|
return;
|
|
@@ -1155,17 +1161,17 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1155
1161
|
// 这一下起,自动隐藏倒计时才开始生效
|
|
1156
1162
|
hasUserTappedPlayerRef.current = true;
|
|
1157
1163
|
if (instance.multiCameraCtx.isSupport) {
|
|
1158
|
-
var _instance$
|
|
1159
|
-
const preTapIndex = (_instance$
|
|
1164
|
+
var _instance$multiCamera2, _instance$multiCamera3;
|
|
1165
|
+
const preTapIndex = (_instance$multiCamera2 = (_instance$multiCamera3 = instance.multiCameraCtx.selectedLenInfoRef.current) === null || _instance$multiCamera3 === void 0 ? void 0 : _instance$multiCamera3.index) !== null && _instance$multiCamera2 !== void 0 ? _instance$multiCamera2 : prevSelectedIndexRef.current;
|
|
1160
1166
|
const wasHidden = componentHideState;
|
|
1161
1167
|
instance.multiCameraCtx.selectVideoFiredRef.current = false;
|
|
1162
1168
|
if (multiTapTimerRef.current) {
|
|
1163
1169
|
clearTimeout(multiTapTimerRef.current);
|
|
1164
1170
|
}
|
|
1165
1171
|
multiTapTimerRef.current = setTimeout(() => {
|
|
1166
|
-
var _instance$
|
|
1172
|
+
var _instance$multiCamera4, _instance$multiCamera5;
|
|
1167
1173
|
const selectFired = !!instance.multiCameraCtx.selectVideoFiredRef.current;
|
|
1168
|
-
const currentIndex = (_instance$
|
|
1174
|
+
const currentIndex = (_instance$multiCamera4 = (_instance$multiCamera5 = instance.multiCameraCtx.selectedLenInfoRef.current) === null || _instance$multiCamera5 === void 0 ? void 0 : _instance$multiCamera5.index) !== null && _instance$multiCamera4 !== void 0 ? _instance$multiCamera4 : preTapIndex;
|
|
1169
1175
|
if (selectFired && currentIndex === preTapIndex) {
|
|
1170
1176
|
if (wasHidden) {
|
|
1171
1177
|
showComponents();
|
|
@@ -1238,14 +1244,20 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1238
1244
|
show: !showTopContent || componentHideState || !playerReady
|
|
1239
1245
|
}), /*#__PURE__*/React.createElement(View, {
|
|
1240
1246
|
className: clsx('ipc-player-bottom-content', {
|
|
1241
|
-
'ipc-player-bottom-content-hide':
|
|
1242
|
-
'ipc-player-bottom-content-show': !
|
|
1243
|
-
'ipc-player-bottom-content-full':
|
|
1247
|
+
'ipc-player-bottom-content-hide': bottomHideState,
|
|
1248
|
+
'ipc-player-bottom-content-show': !bottomHideState,
|
|
1249
|
+
'ipc-player-bottom-content-full': isVerticalFullLayout && screenType === 'vertical'
|
|
1244
1250
|
}),
|
|
1245
1251
|
style: {
|
|
1246
1252
|
height: screenType === 'vertical' ? '48px' : '72px'
|
|
1247
1253
|
}
|
|
1248
|
-
}, /*#__PURE__*/React.createElement(
|
|
1254
|
+
}, /*#__PURE__*/React.createElement(UIEventContext.Provider, {
|
|
1255
|
+
value: {
|
|
1256
|
+
event: eventRef.current,
|
|
1257
|
+
componentHideState: bottomHideState,
|
|
1258
|
+
refreshElement
|
|
1259
|
+
}
|
|
1260
|
+
}, /*#__PURE__*/React.createElement(BottomLeftContent, {
|
|
1249
1261
|
ctx: instance,
|
|
1250
1262
|
reservedRight: bottomRightReserved
|
|
1251
1263
|
}, renderBottomLeftContent), /*#__PURE__*/React.createElement(BottomRightContent, {
|
|
@@ -1255,13 +1267,17 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1255
1267
|
}, renderBottomRightContent))), (() => {
|
|
1256
1268
|
if (!absoluteContent || !(absoluteContent !== null && absoluteContent !== void 0 && absoluteContent.length)) return null;
|
|
1257
1269
|
return absoluteContent.map(item => {
|
|
1258
|
-
if (item
|
|
1270
|
+
if (!shouldRenderContent(item, {
|
|
1271
|
+
playState
|
|
1272
|
+
})) return null;
|
|
1273
|
+
if (item.id === tileActionsId && isVerticalFullLayout && componentHideState) return null;
|
|
1274
|
+
const contentProps = _objectSpread(_objectSpread(_objectSpread({
|
|
1275
|
+
key: item.id
|
|
1276
|
+
}, item.initProps), instance), {}, {
|
|
1277
|
+
IPCPlayerContext: instance.IPCPlayerInstance
|
|
1278
|
+
});
|
|
1259
1279
|
if (item.absoluteNoCoverView) {
|
|
1260
|
-
return /*#__PURE__*/React.createElement(item.content,
|
|
1261
|
-
key: item.id
|
|
1262
|
-
}, item.initProps), instance), {}, {
|
|
1263
|
-
IPCPlayerContext: instance.IPCPlayerInstance
|
|
1264
|
-
}));
|
|
1280
|
+
return /*#__PURE__*/React.createElement(item.content, contentProps);
|
|
1265
1281
|
}
|
|
1266
1282
|
return /*#__PURE__*/React.createElement(CoverView, {
|
|
1267
1283
|
key: item.id,
|
|
@@ -1269,10 +1285,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1269
1285
|
position: 'absolute'
|
|
1270
1286
|
}, item.absolutePosition),
|
|
1271
1287
|
className: item.absoluteContentClassName
|
|
1272
|
-
}, /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread(
|
|
1273
|
-
key: item.id
|
|
1274
|
-
}, item.initProps), instance), {}, {
|
|
1275
|
-
IPCPlayerContext: instance.IPCPlayerInstance,
|
|
1288
|
+
}, /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread({}, contentProps), {}, {
|
|
1276
1289
|
// 添加通用变量单独组件类名
|
|
1277
1290
|
className: clsx('absolute-item-container')
|
|
1278
1291
|
})));
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
protocolCount?: number | string;
|
|
10
|
+
devId: string;
|
|
11
|
+
};
|
|
12
|
+
/** 从新多目高级能力配置获取当前设备的总镜头数 */
|
|
13
|
+
export declare function getMultiLensCountFromAbility(devId: string): Promise<number>;
|
|
14
|
+
export declare function getCaptureResultSummary(result: CaptureResult, { multiLens, protocolCount, devId }: CaptureResultOptions): Promise<CaptureResultSummary | null>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
|
+
|
|
3
|
+
import { getDeviceInfo } from './device';
|
|
4
|
+
const MULTI_LENS_ABILITY_CODE = 'tyabimr4v3';
|
|
5
|
+
const LENS_SUFFIX_PATTERN = /_lens\d+(?=\.[^./?#]+(?:[?#].*)?$)/;
|
|
6
|
+
const FILE_EXTENSION_PATTERN = /(\.[^./?#]+)([?#].*)?$/;
|
|
7
|
+
/** 从新多目高级能力配置获取当前设备的总镜头数 */
|
|
8
|
+
export async function getMultiLensCountFromAbility(devId) {
|
|
9
|
+
if (!devId) return 0;
|
|
10
|
+
try {
|
|
11
|
+
var _devInfo$configMetas;
|
|
12
|
+
const devInfo = await getDeviceInfo(devId);
|
|
13
|
+
const raw = devInfo === null || devInfo === void 0 || (_devInfo$configMetas = devInfo.configMetas) === null || _devInfo$configMetas === void 0 ? void 0 : _devInfo$configMetas[MULTI_LENS_ABILITY_CODE];
|
|
14
|
+
if (raw) {
|
|
15
|
+
const parsed = typeof raw === 'string' ? JSON.parse(raw) : raw;
|
|
16
|
+
const count = Number(parsed === null || parsed === void 0 ? void 0 : parsed.total_split_num) || (Array.isArray(parsed === null || parsed === void 0 ? void 0 : parsed.split_info) ? parsed.split_info.length : 0);
|
|
17
|
+
if (count > 1) {
|
|
18
|
+
return count;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
} catch (e) {
|
|
22
|
+
// ignore
|
|
23
|
+
}
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
const normalizeMultiLensThumbnailPath = path => {
|
|
27
|
+
if (!path || LENS_SUFFIX_PATTERN.test(path)) return path;
|
|
28
|
+
return path.replace(FILE_EXTENSION_PATTERN, '_lens1$1$2');
|
|
29
|
+
};
|
|
30
|
+
const extractPath = item => {
|
|
31
|
+
if (!item) return '';
|
|
32
|
+
if (typeof item === 'string') return item;
|
|
33
|
+
if (typeof (item === null || item === void 0 ? void 0 : item.value) === 'string') return item.value;
|
|
34
|
+
return '';
|
|
35
|
+
};
|
|
36
|
+
export async function getCaptureResultSummary(result, _ref) {
|
|
37
|
+
let {
|
|
38
|
+
multiLens,
|
|
39
|
+
protocolCount,
|
|
40
|
+
devId
|
|
41
|
+
} = _ref;
|
|
42
|
+
if (!result || typeof result === 'boolean') return null;
|
|
43
|
+
const thumbnailPath = extractPath(result.tempImagePath) || extractPath(result.thumbPath) || extractPath(result.filePath) || '';
|
|
44
|
+
if (!multiLens) {
|
|
45
|
+
return {
|
|
46
|
+
count: 1,
|
|
47
|
+
isMultiLens: false,
|
|
48
|
+
thumbnailPath
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const splitCount = Number(protocolCount) > 1 ? Number(protocolCount) : 0;
|
|
52
|
+
const multiLensAbilityCount = await getMultiLensCountFromAbility(devId);
|
|
53
|
+
|
|
54
|
+
// The native multi-lens snapshot can return one object while writing lens-specific
|
|
55
|
+
// files. Use the ability result to distinguish that file-name convention from the
|
|
56
|
+
// legacy split protocol.
|
|
57
|
+
const multiCount = splitCount || multiLensAbilityCount;
|
|
58
|
+
if (multiCount > 1) {
|
|
59
|
+
return {
|
|
60
|
+
count: multiCount,
|
|
61
|
+
isMultiLens: true,
|
|
62
|
+
thumbnailPath: multiLensAbilityCount > 1 ? normalizeMultiLensThumbnailPath(thumbnailPath) : thumbnailPath
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
count: 1,
|
|
67
|
+
isMultiLens: false,
|
|
68
|
+
thumbnailPath
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { getCaptureResultSummary } from './captureResult';
|
|
2
|
+
import { getDeviceInfo } from './device';
|
|
3
|
+
jest.mock('./device', () => ({
|
|
4
|
+
getDeviceInfo: jest.fn()
|
|
5
|
+
}));
|
|
6
|
+
const mockGetDeviceInfo = getDeviceInfo;
|
|
7
|
+
const basePath = 'thingfile://tmp/capture_123.jpg';
|
|
8
|
+
const createCaptureResult = tempImagePath => ({
|
|
9
|
+
tempImagePath,
|
|
10
|
+
filePath: tempImagePath
|
|
11
|
+
});
|
|
12
|
+
describe('getCaptureResultSummary', () => {
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
mockGetDeviceInfo.mockReset();
|
|
15
|
+
mockGetDeviceInfo.mockResolvedValue({
|
|
16
|
+
configMetas: {}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
it('normalizes the thumbnail path for the new multi-lens ability', async () => {
|
|
20
|
+
mockGetDeviceInfo.mockResolvedValue({
|
|
21
|
+
configMetas: {
|
|
22
|
+
tyabimr4v3: {
|
|
23
|
+
total_split_num: 4
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
await expect(getCaptureResultSummary(createCaptureResult(basePath), {
|
|
28
|
+
multiLens: true,
|
|
29
|
+
devId: 'dev-1'
|
|
30
|
+
})).resolves.toEqual({
|
|
31
|
+
count: 4,
|
|
32
|
+
isMultiLens: true,
|
|
33
|
+
thumbnailPath: 'thingfile://tmp/capture_123_lens1.jpg'
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
it('keeps the single-lens result for a legacy multi-camera device', async () => {
|
|
37
|
+
await expect(getCaptureResultSummary(createCaptureResult(basePath), {
|
|
38
|
+
multiLens: false,
|
|
39
|
+
protocolCount: 4,
|
|
40
|
+
devId: 'dev-1'
|
|
41
|
+
})).resolves.toEqual({
|
|
42
|
+
count: 1,
|
|
43
|
+
isMultiLens: false,
|
|
44
|
+
thumbnailPath: basePath
|
|
45
|
+
});
|
|
46
|
+
expect(mockGetDeviceInfo).not.toHaveBeenCalled();
|
|
47
|
+
});
|
|
48
|
+
it('uses the protocol count when the multi-lens mode is enabled', async () => {
|
|
49
|
+
await expect(getCaptureResultSummary(createCaptureResult(basePath), {
|
|
50
|
+
multiLens: true,
|
|
51
|
+
protocolCount: 4,
|
|
52
|
+
devId: 'dev-1'
|
|
53
|
+
})).resolves.toEqual({
|
|
54
|
+
count: 4,
|
|
55
|
+
isMultiLens: true,
|
|
56
|
+
thumbnailPath: basePath
|
|
57
|
+
});
|
|
58
|
+
expect(mockGetDeviceInfo).toHaveBeenCalledWith('dev-1');
|
|
59
|
+
});
|
|
60
|
+
it('uses the lens path when both multi-lens sources are present', async () => {
|
|
61
|
+
mockGetDeviceInfo.mockResolvedValue({
|
|
62
|
+
configMetas: {
|
|
63
|
+
tyabimr4v3: {
|
|
64
|
+
total_split_num: 4
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
await expect(getCaptureResultSummary(createCaptureResult(basePath), {
|
|
69
|
+
multiLens: true,
|
|
70
|
+
protocolCount: 4,
|
|
71
|
+
devId: 'dev-1'
|
|
72
|
+
})).resolves.toEqual({
|
|
73
|
+
count: 4,
|
|
74
|
+
isMultiLens: true,
|
|
75
|
+
thumbnailPath: 'thingfile://tmp/capture_123_lens1.jpg'
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
it('does not add a duplicate lens suffix', async () => {
|
|
79
|
+
mockGetDeviceInfo.mockResolvedValue({
|
|
80
|
+
configMetas: {
|
|
81
|
+
tyabimr4v3: JSON.stringify({
|
|
82
|
+
total_split_num: 4
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const path = 'thingfile://tmp/capture_123_lens1.jpg';
|
|
87
|
+
await expect(getCaptureResultSummary(createCaptureResult(path), {
|
|
88
|
+
multiLens: true,
|
|
89
|
+
devId: 'dev-1'
|
|
90
|
+
})).resolves.toEqual({
|
|
91
|
+
count: 4,
|
|
92
|
+
isMultiLens: true,
|
|
93
|
+
thumbnailPath: path
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
it('keeps a mono result unchanged', async () => {
|
|
97
|
+
await expect(getCaptureResultSummary(createCaptureResult(basePath), {
|
|
98
|
+
multiLens: false,
|
|
99
|
+
devId: 'dev-1'
|
|
100
|
+
})).resolves.toEqual({
|
|
101
|
+
count: 1,
|
|
102
|
+
isMultiLens: false,
|
|
103
|
+
thumbnailPath: basePath
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
it('keeps a single-lens result when multi-lens mode has one lens', async () => {
|
|
107
|
+
await expect(getCaptureResultSummary(createCaptureResult(basePath), {
|
|
108
|
+
multiLens: true,
|
|
109
|
+
protocolCount: 1,
|
|
110
|
+
devId: 'dev-1'
|
|
111
|
+
})).resolves.toEqual({
|
|
112
|
+
count: 1,
|
|
113
|
+
isMultiLens: false,
|
|
114
|
+
thumbnailPath: basePath
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type EntryTracking = Record<'utm_source' | 'utm_medium' | 'entry_source_type' | 'utm_rtid', string>;
|
|
2
|
+
export declare const createEntryTracking: () => EntryTracking;
|
|
3
|
+
export declare const appendTrackingQuery: (url: string, tracking: EntryTracking) => string;
|
|
4
|
+
export declare const reportEntryView: (devId: string, tracking: EntryTracking) => Promise<void>;
|
|
5
|
+
export declare const reportEntryClick: (devId: string, tracking: EntryTracking) => Promise<void>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
3
|
+
import "core-js/modules/esnext.iterator.filter.js";
|
|
4
|
+
import "core-js/modules/esnext.iterator.for-each.js";
|
|
5
|
+
import { getLaunchOptionsSync } from '@ray-js/ray';
|
|
6
|
+
import { getInitUtmTid } from '@ray-js/ray-ipc-utils';
|
|
7
|
+
export const createEntryTracking = () => {
|
|
8
|
+
let upstreamRtid;
|
|
9
|
+
try {
|
|
10
|
+
var _getLaunchOptionsSync;
|
|
11
|
+
upstreamRtid = (_getLaunchOptionsSync = getLaunchOptionsSync()) === null || _getLaunchOptionsSync === void 0 || (_getLaunchOptionsSync = _getLaunchOptionsSync.query) === null || _getLaunchOptionsSync === void 0 ? void 0 : _getLaunchOptionsSync.utm_rtid;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
// Tracking must not prevent navigation when launch options are unavailable.
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
utm_source: 'miniprogram',
|
|
17
|
+
utm_medium: 'panel_smart_quality',
|
|
18
|
+
entry_source_type: 'organic',
|
|
19
|
+
utm_rtid: upstreamRtid || getInitUtmTid()
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export const appendTrackingQuery = (url, tracking) => {
|
|
23
|
+
const hashIndex = url.indexOf('#');
|
|
24
|
+
const base = hashIndex < 0 ? url : url.slice(0, hashIndex);
|
|
25
|
+
const hash = hashIndex < 0 ? '' : url.slice(hashIndex);
|
|
26
|
+
const queryIndex = base.indexOf('?');
|
|
27
|
+
const path = queryIndex < 0 ? base : base.slice(0, queryIndex);
|
|
28
|
+
const params = (queryIndex < 0 ? [] : base.slice(queryIndex + 1).split('&')).filter(param => {
|
|
29
|
+
if (!param) return false;
|
|
30
|
+
return !Object.prototype.hasOwnProperty.call(tracking, decodeURIComponent(param.split('=')[0]));
|
|
31
|
+
});
|
|
32
|
+
Object.entries(tracking).forEach(_ref => {
|
|
33
|
+
let [key, value] = _ref;
|
|
34
|
+
params.push(`${key}=${encodeURIComponent(value)}`);
|
|
35
|
+
});
|
|
36
|
+
return `${path}?${params.join('&')}${hash}`;
|
|
37
|
+
};
|
|
38
|
+
const reportEntry = async (eventType, devId, tracking) => {
|
|
39
|
+
try {
|
|
40
|
+
const {
|
|
41
|
+
homeId
|
|
42
|
+
} = await new Promise((resolve, reject) => {
|
|
43
|
+
ty.home.getCurrentHomeInfo({
|
|
44
|
+
success: resolve,
|
|
45
|
+
fail: reject
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
const {
|
|
49
|
+
miniProgram
|
|
50
|
+
} = ty.getAccountInfoSync();
|
|
51
|
+
const event = _objectSpread(_objectSpread({
|
|
52
|
+
project_type: 'cloud_storage',
|
|
53
|
+
event_type: eventType,
|
|
54
|
+
container_type: 'miniapp',
|
|
55
|
+
miniapp_code: miniProgram.appId,
|
|
56
|
+
miniapp_version: miniProgram.version,
|
|
57
|
+
service_type: 'security_cloud_service'
|
|
58
|
+
}, tracking), {}, {
|
|
59
|
+
device_id: devId,
|
|
60
|
+
homeid: homeId
|
|
61
|
+
});
|
|
62
|
+
ty.event({
|
|
63
|
+
eventId: eventType === 'card_view' ? 'ty_XjSozxV0YkDMjzH8orMHx0g2HMc6GQ3q' : 'ty_tUWSmFcHcSetzZd5soRTq6Y3nEYE0RgP',
|
|
64
|
+
event
|
|
65
|
+
});
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.warn('[IPC] entry tracking failed:', error);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
export const reportEntryView = (devId, tracking) => reportEntry('card_view', devId, tracking);
|
|
71
|
+
export const reportEntryClick = (devId, tracking) => reportEntry('card_click', devId, tracking);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { EntryTracking } from './fullLinkTracking';
|
|
1
2
|
export declare const miniIdLabs: {
|
|
2
3
|
aiDrawMini: string;
|
|
3
4
|
securityCloudService: string;
|
|
4
5
|
};
|
|
5
6
|
export declare function gotoAIDrawMiniProgram(devId: string, brandColor: string): void;
|
|
6
7
|
export declare function gotoSecurityCloudService(homeId: string, uuid: string): Promise<void>;
|
|
7
|
-
export declare function gotoSecurityCloudService2(devId: string): Promise<import("@ray-js/ray-ipc-utils/lib/interface").IRes<unknown>>;
|
|
8
|
+
export declare function gotoSecurityCloudService2(devId: string, tracking?: EntryTracking): Promise<import("@ray-js/ray-ipc-utils/lib/interface").IRes<unknown>>;
|
package/lib/utils/navigation.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { getServiceUrl, goToMiniProgramByShortLink } from '@ray-js/ray-ipc-utils';
|
|
1
|
+
import { getServiceUrl, goToMiniProgramByShortLink, jumpToWebView } from '@ray-js/ray-ipc-utils';
|
|
2
2
|
import Color from 'color';
|
|
3
|
+
import { appendTrackingQuery } from './fullLinkTracking';
|
|
3
4
|
|
|
4
5
|
// 小程序ID集合
|
|
5
6
|
export const miniIdLabs = {
|
|
@@ -18,6 +19,15 @@ export async function gotoSecurityCloudService(homeId, uuid) {
|
|
|
18
19
|
const url = `godzilla://${miniIdLabs.securityCloudService}${'/pages/serviceList/index'}?homeId=${homeId}&deviceId=${uuid}&categoryCode=${'security_cloud_service'}`;
|
|
19
20
|
goToMiniProgramByShortLink(url, 'right');
|
|
20
21
|
}
|
|
21
|
-
export async function gotoSecurityCloudService2(devId) {
|
|
22
|
-
|
|
22
|
+
export async function gotoSecurityCloudService2(devId, tracking) {
|
|
23
|
+
var _result$data;
|
|
24
|
+
const serviceType = 'security_cloud_service';
|
|
25
|
+
const params = {};
|
|
26
|
+
if (!tracking) return getServiceUrl(devId, serviceType, params, true);
|
|
27
|
+
const result = await getServiceUrl(devId, serviceType, params, false, tracking.utm_rtid);
|
|
28
|
+
if ((result === null || result === void 0 ? void 0 : result.code) !== 0 || !((_result$data = result.data) !== null && _result$data !== void 0 && _result$data.url)) {
|
|
29
|
+
throw new Error('Failed to fetch the cloud service URL');
|
|
30
|
+
}
|
|
31
|
+
const url = appendTrackingQuery(result.data.url, tracking);
|
|
32
|
+
return result.data.type === 2 ? goToMiniProgramByShortLink(url) : jumpToWebView(url);
|
|
23
33
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './captureResult.less';
|
|
3
|
+
export type CaptureKind = 'record' | 'screenshot';
|
|
4
|
+
export interface CaptureResultToastProps {
|
|
5
|
+
brandColor: string;
|
|
6
|
+
kind: CaptureKind;
|
|
7
|
+
thumbnailPath: string;
|
|
8
|
+
onCheck: () => void;
|
|
9
|
+
count?: number;
|
|
10
|
+
/** 自定义标题(可选),不传时使用默认文案 */
|
|
11
|
+
title?: React.ReactNode;
|
|
12
|
+
/** 自定义操作按钮文案(可选),不传时默认为“查看” */
|
|
13
|
+
checkText?: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function CaptureResultToast({ brandColor, count, kind, onCheck, thumbnailPath, title, checkText, className, }: CaptureResultToastProps): React.JSX.Element;
|