@ray-js/ipc-player-integration 0.0.63 → 0.0.65-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/lib/ctx/ctx.album.test.d.ts +1 -0
- package/lib/ctx/ctx.album.test.js +197 -0
- package/lib/ctx/ctx.composition.js +19 -4
- package/lib/ctx/ctx.js +103 -55
- package/lib/ctx/ports.output.d.ts +1 -0
- package/lib/ctx/resolution.d.ts +1 -1
- package/lib/ctx/resolution.js +3 -1
- 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 +19 -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.d.ts +2 -0
- package/lib/ui/ui.js +30 -26
- 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/utils/ttt.js +2 -8
- 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/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/lib/widgets/tryExperience/tryExperience.js +0 -1
- package/package.json +3 -2
package/lib/interface.d.ts
CHANGED
|
@@ -41,19 +41,24 @@ export type EventInstance = {
|
|
|
41
41
|
};
|
|
42
42
|
export type UseCtx = (options: {
|
|
43
43
|
devId: string;
|
|
44
|
+
/** 宿主决定是否禁用 Auto;null 表示本次配置查询尚未完成。 */
|
|
45
|
+
autoClarityDisabled?: boolean | null;
|
|
44
46
|
initTopLeftContent?: ComponentConfig[];
|
|
45
47
|
initTopRightContent?: ComponentConfig[];
|
|
46
48
|
initBottomLeftContent?: ComponentConfig[];
|
|
47
49
|
initBottomRightContent?: ComponentConfig[];
|
|
48
50
|
initAbsoluteContent?: ComponentConfig[];
|
|
49
51
|
saveToAlbum?: 0 | 1;
|
|
52
|
+
multiLens?: boolean;
|
|
50
53
|
showPtzControlTip?: boolean;
|
|
51
54
|
videoSplitProtocol?: VideoSplitProtocol;
|
|
52
55
|
}) => {
|
|
53
56
|
devId: string;
|
|
57
|
+
trialBadgeViewedRef: React.MutableRefObject<boolean>;
|
|
54
58
|
brandColor: RetAtom<string>;
|
|
55
59
|
verticalMic: RetAtom<boolean>;
|
|
56
60
|
saveToAlbum: 0 | 1;
|
|
61
|
+
multiLens: boolean;
|
|
57
62
|
showPtzControlTip: boolean;
|
|
58
63
|
screenType: RetAtom<ScreenType>;
|
|
59
64
|
isVerticalFullLayout: RetAtom<boolean>;
|
|
@@ -89,7 +94,8 @@ export type UseCtx = (options: {
|
|
|
89
94
|
setRecordingDisabled: (type: boolean) => void;
|
|
90
95
|
setResolution: (type: string) => Promise<boolean>;
|
|
91
96
|
setResolutionList: (type: string[]) => void;
|
|
92
|
-
setRecording: (value: boolean, onlyUpdateAtom?: boolean) => Promise<
|
|
97
|
+
setRecording: (value: boolean, onlyUpdateAtom?: boolean) => Promise<CaptureResult>;
|
|
98
|
+
stopRecordingOnUnload: () => Promise<CaptureResult>;
|
|
93
99
|
setIntercom: (value: boolean, onlyUpdateAtom?: boolean) => Promise<boolean>;
|
|
94
100
|
setMute: (value: boolean) => Promise<boolean>;
|
|
95
101
|
changeStreamStatus: (value: PlayerStreamStatus) => void;
|
|
@@ -120,8 +126,12 @@ export type ComponentConfig<T = ReturnType<UseCtx> & Record<string, any>> = {
|
|
|
120
126
|
absoluteContentClassName?: string;
|
|
121
127
|
absoluteContentStyle?: React.CSSProperties;
|
|
122
128
|
absoluteNoCoverView?: boolean;
|
|
129
|
+
renderWhen?: (state: ComponentRenderState) => boolean;
|
|
123
130
|
hidden?: boolean;
|
|
124
131
|
};
|
|
132
|
+
export type ComponentRenderState = {
|
|
133
|
+
playState: PlayState;
|
|
134
|
+
};
|
|
125
135
|
export type ComponentConfigProps = {
|
|
126
136
|
IPCPlayerContext: IpcContext;
|
|
127
137
|
} & ReturnType<UseCtx>;
|
|
@@ -129,11 +139,17 @@ export type PlayStatusData = {
|
|
|
129
139
|
playState: PlayState;
|
|
130
140
|
playCode: number;
|
|
131
141
|
};
|
|
132
|
-
export type
|
|
142
|
+
export type CaptureFileInfo = {
|
|
143
|
+
index?: number;
|
|
133
144
|
tempImagePath: string;
|
|
134
145
|
filePath: string;
|
|
135
|
-
thumbPath
|
|
146
|
+
thumbPath?: string;
|
|
147
|
+
width?: number;
|
|
148
|
+
height?: number;
|
|
149
|
+
data?: string;
|
|
136
150
|
};
|
|
151
|
+
export type CaptureResult = boolean | CaptureFileInfo;
|
|
152
|
+
export type RecordInfoData = CaptureResult;
|
|
137
153
|
/**
|
|
138
154
|
* 多目屏幕模式
|
|
139
155
|
*/
|
|
@@ -82,9 +82,10 @@ const BottomLeftContent = _ref => {
|
|
|
82
82
|
const [shouldHide] = useComponentHideState();
|
|
83
83
|
const {
|
|
84
84
|
showTrialBadge,
|
|
85
|
+
handleTrialView,
|
|
85
86
|
handleTrialSubscribe,
|
|
86
87
|
handleCountdownEnd
|
|
87
|
-
} = useTrialBadge(ctx.event, ctx.devId, trialRemainingSec);
|
|
88
|
+
} = useTrialBadge(ctx.event, ctx.devId, trialRemainingSec, ctx.trialBadgeViewedRef);
|
|
88
89
|
|
|
89
90
|
// 横向滚动状态:内容溢出且未滑到对应边缘时,显示左 / 右箭头提示
|
|
90
91
|
const idRef = useRef(++scrollClsSeq);
|
|
@@ -405,6 +406,7 @@ const BottomLeftContent = _ref => {
|
|
|
405
406
|
marginLeft: screenType === 'vertical' ? '12px' : '25px'
|
|
406
407
|
}
|
|
407
408
|
}, /*#__PURE__*/React.createElement(TrialBadge, {
|
|
409
|
+
onView: handleTrialView,
|
|
408
410
|
brandColor: brandColor,
|
|
409
411
|
trialRemainingSec: trialRemainingSec,
|
|
410
412
|
onSubscribe: handleTrialSubscribe,
|
package/lib/ui/ui.d.ts
CHANGED
package/lib/ui/ui.js
CHANGED
|
@@ -28,7 +28,9 @@ 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
|
|
@@ -59,11 +61,12 @@ const StandaloneAutoClarity = _ref2 => {
|
|
|
59
61
|
instance: instance
|
|
60
62
|
}));
|
|
61
63
|
};
|
|
62
|
-
function getCtxInstance(instance, devId) {
|
|
64
|
+
function getCtxInstance(instance, devId, autoClarityDisabled) {
|
|
63
65
|
if (instance) return instance;
|
|
64
66
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
65
67
|
return useCtx({
|
|
66
|
-
devId
|
|
68
|
+
devId,
|
|
69
|
+
autoClarityDisabled
|
|
67
70
|
});
|
|
68
71
|
}
|
|
69
72
|
|
|
@@ -126,7 +129,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
126
129
|
const {
|
|
127
130
|
event
|
|
128
131
|
} = useContext(UIEventContext);
|
|
129
|
-
const instance = getCtxInstance(props.instance, devId);
|
|
132
|
+
const instance = getCtxInstance(props.instance, devId, props.autoClarityDisabled);
|
|
130
133
|
const {
|
|
131
134
|
setPlayState,
|
|
132
135
|
setScreenType,
|
|
@@ -563,7 +566,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
563
566
|
// canOpenSettings: true,
|
|
564
567
|
// };
|
|
565
568
|
const getNgRes = await getNgRawData();
|
|
566
|
-
console.log('res===getSmartImageQualityState', res);
|
|
567
569
|
updatePlayerWidgetProps(instance, 'bottomLeft', 'TryExperience', {
|
|
568
570
|
isPurchase: res.isPurchase,
|
|
569
571
|
buttonState: res.buttonState,
|
|
@@ -686,14 +688,16 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
686
688
|
ipcTTTOperatorLog('hide: 调用停止录制方法');
|
|
687
689
|
setRecording(false, true);
|
|
688
690
|
setIntercom(false, true);
|
|
689
|
-
instance === null || instance === void 0 || instance.
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
}
|
|
691
|
+
instance === null || instance === void 0 || instance.stopRecordingOnUnload().then(async result => {
|
|
692
|
+
var _instance$multiLens, _instance$multiCamera;
|
|
693
|
+
const summary = await getCaptureResultSummary(result, {
|
|
694
|
+
multiLens: (_instance$multiLens = instance === null || instance === void 0 ? void 0 : instance.multiLens) !== null && _instance$multiLens !== void 0 ? _instance$multiLens : false,
|
|
695
|
+
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,
|
|
696
|
+
devId
|
|
697
|
+
});
|
|
698
|
+
ipcTTTOperatorLog(summary !== null && summary !== void 0 && summary.isMultiLens ? `hide: stop recording succeeded with ${summary.count} files` : 'hide: 调用停止录制方法成功');
|
|
699
|
+
}).catch(() => {
|
|
700
|
+
ipcTTTOperatorLog('hide: 调用停止录制方法失败');
|
|
697
701
|
});
|
|
698
702
|
ipcTTTOperatorLog('hide: 调用停止对讲方法');
|
|
699
703
|
instance === null || instance === void 0 || instance.IPCPlayerInstance.stopTalk({
|
|
@@ -1155,17 +1159,17 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1155
1159
|
// 这一下起,自动隐藏倒计时才开始生效
|
|
1156
1160
|
hasUserTappedPlayerRef.current = true;
|
|
1157
1161
|
if (instance.multiCameraCtx.isSupport) {
|
|
1158
|
-
var _instance$
|
|
1159
|
-
const preTapIndex = (_instance$
|
|
1162
|
+
var _instance$multiCamera2, _instance$multiCamera3;
|
|
1163
|
+
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
1164
|
const wasHidden = componentHideState;
|
|
1161
1165
|
instance.multiCameraCtx.selectVideoFiredRef.current = false;
|
|
1162
1166
|
if (multiTapTimerRef.current) {
|
|
1163
1167
|
clearTimeout(multiTapTimerRef.current);
|
|
1164
1168
|
}
|
|
1165
1169
|
multiTapTimerRef.current = setTimeout(() => {
|
|
1166
|
-
var _instance$
|
|
1170
|
+
var _instance$multiCamera4, _instance$multiCamera5;
|
|
1167
1171
|
const selectFired = !!instance.multiCameraCtx.selectVideoFiredRef.current;
|
|
1168
|
-
const currentIndex = (_instance$
|
|
1172
|
+
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
1173
|
if (selectFired && currentIndex === preTapIndex) {
|
|
1170
1174
|
if (wasHidden) {
|
|
1171
1175
|
showComponents();
|
|
@@ -1255,13 +1259,16 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1255
1259
|
}, renderBottomRightContent))), (() => {
|
|
1256
1260
|
if (!absoluteContent || !(absoluteContent !== null && absoluteContent !== void 0 && absoluteContent.length)) return null;
|
|
1257
1261
|
return absoluteContent.map(item => {
|
|
1258
|
-
if (item
|
|
1262
|
+
if (!shouldRenderContent(item, {
|
|
1263
|
+
playState
|
|
1264
|
+
})) return null;
|
|
1265
|
+
const contentProps = _objectSpread(_objectSpread(_objectSpread({
|
|
1266
|
+
key: item.id
|
|
1267
|
+
}, item.initProps), instance), {}, {
|
|
1268
|
+
IPCPlayerContext: instance.IPCPlayerInstance
|
|
1269
|
+
});
|
|
1259
1270
|
if (item.absoluteNoCoverView) {
|
|
1260
|
-
return /*#__PURE__*/React.createElement(item.content,
|
|
1261
|
-
key: item.id
|
|
1262
|
-
}, item.initProps), instance), {}, {
|
|
1263
|
-
IPCPlayerContext: instance.IPCPlayerInstance
|
|
1264
|
-
}));
|
|
1271
|
+
return /*#__PURE__*/React.createElement(item.content, contentProps);
|
|
1265
1272
|
}
|
|
1266
1273
|
return /*#__PURE__*/React.createElement(CoverView, {
|
|
1267
1274
|
key: item.id,
|
|
@@ -1269,10 +1276,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1269
1276
|
position: 'absolute'
|
|
1270
1277
|
}, item.absolutePosition),
|
|
1271
1278
|
className: item.absoluteContentClassName
|
|
1272
|
-
}, /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread(
|
|
1273
|
-
key: item.id
|
|
1274
|
-
}, item.initProps), instance), {}, {
|
|
1275
|
-
IPCPlayerContext: instance.IPCPlayerInstance,
|
|
1279
|
+
}, /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread({}, contentProps), {}, {
|
|
1276
1280
|
// 添加通用变量单独组件类名
|
|
1277
1281
|
className: clsx('absolute-item-container')
|
|
1278
1282
|
})));
|
|
@@ -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
|
}
|
package/lib/utils/ttt.js
CHANGED
|
@@ -37,11 +37,9 @@ export function getAIFrameFeature(devId) {
|
|
|
37
37
|
ty.ipc.getAIFrameFeature({
|
|
38
38
|
devId,
|
|
39
39
|
success: data => {
|
|
40
|
-
console.log('res===getAIFrameFeature data', data);
|
|
41
40
|
resolve(data);
|
|
42
41
|
},
|
|
43
|
-
fail:
|
|
44
|
-
console.warn('res===getAIFrameFeature fail', e);
|
|
42
|
+
fail: () => {
|
|
45
43
|
resolve(null);
|
|
46
44
|
}
|
|
47
45
|
});
|
|
@@ -61,11 +59,9 @@ export function setAIFrameFeature(params) {
|
|
|
61
59
|
try {
|
|
62
60
|
ty.ipc.setAIFrameFeature(_objectSpread(_objectSpread({}, params), {}, {
|
|
63
61
|
success: data => {
|
|
64
|
-
console.log('res===setAIFrameFeature data', data);
|
|
65
62
|
resolve(data);
|
|
66
63
|
},
|
|
67
|
-
fail:
|
|
68
|
-
console.warn('res===setAIFrameFeature fail', e);
|
|
64
|
+
fail: () => {
|
|
69
65
|
resolve(null);
|
|
70
66
|
}
|
|
71
67
|
}));
|
|
@@ -135,7 +131,6 @@ export function notifyOfflineShown(deviceId) {
|
|
|
135
131
|
return false;
|
|
136
132
|
}
|
|
137
133
|
try {
|
|
138
|
-
console.warn('res===notifyOfflineShown', deviceId);
|
|
139
134
|
method({
|
|
140
135
|
deviceId,
|
|
141
136
|
scene: 'preview_mini'
|
|
@@ -246,7 +241,6 @@ export function subscribeClarityChanged(devId, handler) {
|
|
|
246
241
|
try {
|
|
247
242
|
ipc.onClarityChanged(listener);
|
|
248
243
|
} catch (error) {
|
|
249
|
-
console.warn('res===onClarityChanged fail', error);
|
|
250
244
|
return () => undefined;
|
|
251
245
|
}
|
|
252
246
|
return () => {
|
|
@@ -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;
|