@ray-js/ipc-player-integration 0.0.61-beta.1 → 0.0.63

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.
Files changed (49) hide show
  1. package/lib/ctx/ctx.composition.js +4 -19
  2. package/lib/ctx/ctx.js +55 -103
  3. package/lib/ctx/ports.output.d.ts +0 -1
  4. package/lib/ctx/resolution.d.ts +1 -1
  5. package/lib/ctx/resolution.js +1 -3
  6. package/lib/i18n/index.d.ts +0 -12
  7. package/lib/i18n/strings.d.ts +0 -6
  8. package/lib/i18n/strings.js +0 -6
  9. package/lib/interface.d.ts +3 -19
  10. package/lib/ui/bottomLeftContent.js +1 -3
  11. package/lib/ui/ui.d.ts +0 -2
  12. package/lib/ui/ui.js +26 -30
  13. package/lib/utils/navigation.d.ts +1 -2
  14. package/lib/utils/navigation.js +3 -13
  15. package/lib/utils/ttt.js +8 -2
  16. package/lib/widgets/index.d.ts +0 -1
  17. package/lib/widgets/index.js +1 -2
  18. package/lib/widgets/recordVideo/recordVideo.js +52 -53
  19. package/lib/widgets/recordVideo/recordVideo.less +74 -17
  20. package/lib/widgets/recordVideo/recordVideo.test.js +0 -1
  21. package/lib/widgets/screenshot/screenshot.js +44 -66
  22. package/lib/widgets/screenshot/screenshot.less +40 -1
  23. package/lib/widgets/trialBadge/index.d.ts +1 -2
  24. package/lib/widgets/trialBadge/index.js +9 -17
  25. package/lib/widgets/trialBadge/useTrialBadge.d.ts +2 -3
  26. package/lib/widgets/trialBadge/useTrialBadge.js +2 -13
  27. package/lib/widgets/tryExperience/tryExperience.js +1 -0
  28. package/package.json +2 -3
  29. package/lib/ctx/ctx.album.test.d.ts +0 -1
  30. package/lib/ctx/ctx.album.test.js +0 -197
  31. package/lib/ui/absoluteContent.d.ts +0 -2
  32. package/lib/ui/absoluteContent.js +0 -3
  33. package/lib/utils/captureResult.d.ts +0 -14
  34. package/lib/utils/captureResult.js +0 -70
  35. package/lib/utils/captureResult.test.d.ts +0 -1
  36. package/lib/utils/captureResult.test.js +0 -117
  37. package/lib/utils/fullLinkTracking.d.ts +0 -5
  38. package/lib/utils/fullLinkTracking.js +0 -71
  39. package/lib/widgets/captureResult/captureResult.d.ts +0 -16
  40. package/lib/widgets/captureResult/captureResult.js +0 -85
  41. package/lib/widgets/captureResult/captureResult.less +0 -144
  42. package/lib/widgets/captureResult/captureResult.test.d.ts +0 -1
  43. package/lib/widgets/captureResult/captureResult.test.js +0 -80
  44. package/lib/widgets/captureResult/index.d.ts +0 -2
  45. package/lib/widgets/captureResult/index.js +0 -2
  46. package/lib/widgets/recordVideo/recordVideo.lifecycle.test.d.ts +0 -1
  47. package/lib/widgets/recordVideo/recordVideo.lifecycle.test.js +0 -106
  48. package/lib/widgets/screenshot/screenshot.test.d.ts +0 -1
  49. package/lib/widgets/screenshot/screenshot.test.js +0 -120
@@ -1,5 +1,5 @@
1
- import React, { useContext, useEffect, useRef } from 'react';
2
- import { View, Text, getSystemInfoSync } from '@ray-js/ray';
1
+ import React, { useContext, useRef } from 'react';
2
+ import { View, Image, Text, getSystemInfoSync } from '@ray-js/ray';
3
3
  import { useSetState, useUpdateEffect, useMemoizedFn } from 'ahooks';
4
4
  import clsx from 'clsx';
5
5
  import { goToIpcPageNativeRoute } from '@ray-js/ray-ipc-utils';
@@ -7,9 +7,7 @@ import Strings from '../../i18n';
7
7
  import { useStore } from '../../ctx/store';
8
8
  import { UIEventContext } from '../../ui/context';
9
9
  import { pauseTimeToHideAllComponent, changeIgnoreHideStopPreview, widgetLabs, widgetClick } from '../../ui/constant';
10
- import { getCaptureResultSummary } from '../../utils/captureResult';
11
10
  import { ensureAlbumPermission } from '../../utils/authorize/album';
12
- import { CaptureResultToast } from '../captureResult/captureResult';
13
11
  import './screenshot.less';
14
12
  const CLOSE_TIME = 5000;
15
13
  export function Screenshot(props) {
@@ -37,15 +35,8 @@ export function Screenshot(props) {
37
35
  /** 记录截屏url */
38
36
  const [state, setState] = useSetState({
39
37
  showShot: false,
40
- shotUrl: '',
41
- shotCount: 0
38
+ shotUrl: ''
42
39
  });
43
- const snapshotRequestIdRef = useRef(0);
44
- useEffect(() => {
45
- return () => {
46
- snapshotRequestIdRef.current += 1;
47
- };
48
- }, []);
49
40
  useUpdateEffect(() => {
50
41
  if (state.showShot && screenType) {
51
42
  showShotToast();
@@ -58,8 +49,7 @@ export function Screenshot(props) {
58
49
  timer.current = setTimeout(() => {
59
50
  setState({
60
51
  showShot: false,
61
- shotUrl: '',
62
- shotCount: 0
52
+ shotUrl: ''
63
53
  });
64
54
  deleteContent('absolute', 'plugin-screenshot-toast');
65
55
  }, CLOSE_TIME);
@@ -69,8 +59,7 @@ export function Screenshot(props) {
69
59
  const handCheck = () => {
70
60
  setState({
71
61
  showShot: false,
72
- shotUrl: '',
73
- shotCount: 0
62
+ shotUrl: ''
74
63
  });
75
64
  deleteContent('absolute', 'plugin-screenshot-toast');
76
65
  clearInterval(timer.current);
@@ -92,20 +81,31 @@ export function Screenshot(props) {
92
81
  marginLeft: screenType === 'vertical' ? '0' : '-200px'
93
82
  },
94
83
  content: () => {
95
- return /*#__PURE__*/React.createElement(CaptureResultToast, {
96
- brandColor: brandColor,
97
- count: state.shotCount,
98
- kind: "screenshot",
99
- onCheck: handCheck,
100
- thumbnailPath: state.shotUrl
101
- });
84
+ return /*#__PURE__*/React.createElement(View, {
85
+ className: "ipc-player-plugin-screenshot-toast"
86
+ }, /*#__PURE__*/React.createElement(View, {
87
+ className: "ipc-player-plugin-screenshot-toast-image-box"
88
+ }, /*#__PURE__*/React.createElement(Image, {
89
+ className: "ipc-player-plugin-screenshot-toast-image",
90
+ src: state.shotUrl
91
+ })), /*#__PURE__*/React.createElement(View, {
92
+ className: "ipc-player-plugin-screenshot-toast-title"
93
+ }, Strings.getLang('ipc_player_screenshot_success_tip')), /*#__PURE__*/React.createElement(View, {
94
+ onClick: handCheck,
95
+ className: "ipc-player-plugin-screenshot-toast-bottom",
96
+ style: {
97
+ color: brandColor,
98
+ borderColor: brandColor
99
+ }
100
+ }, Strings.getLang('ipc_player_shot_success_check')));
102
101
  }
103
102
  });
104
103
  timeToCloseToast();
105
104
  };
106
105
  const handClick = useMemoizedFn(async () => {
107
- var _props$event;
108
- ((_props$event = props.event) !== null && _props$event !== void 0 ? _props$event : event).emit(widgetClick, {
106
+ var _props$event, _props$event2;
107
+ const ev = (_props$event = props.event) !== null && _props$event !== void 0 ? _props$event : event;
108
+ ((_props$event2 = props.event) !== null && _props$event2 !== void 0 ? _props$event2 : event).emit(widgetClick, {
109
109
  widgetId: widgetLabs.SCREENSHOT
110
110
  });
111
111
  console.log('截屏!!!');
@@ -119,49 +119,27 @@ export function Screenshot(props) {
119
119
  props.event ? props.event.emit(changeIgnoreHideStopPreview, true) : event.emit(changeIgnoreHideStopPreview, true);
120
120
  }
121
121
  event.emit(pauseTimeToHideAllComponent);
122
- const setIgnoreHideStopPreview = value => {
123
- var _props$event2;
124
- ((_props$event2 = props.event) !== null && _props$event2 !== void 0 ? _props$event2 : event).emit(changeIgnoreHideStopPreview, value);
125
- };
126
- const handleSnapshotFail = err => {
127
- setIgnoreHideStopPreview(false);
128
- console.log(err, 'err');
129
- const errObj = err.innerError || err || {};
130
- const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_screenshot_error_tip');
131
- toast({
132
- title: errMsg
133
- });
134
- };
135
122
  const granted = await ensureAlbumPermission();
136
- setIgnoreHideStopPreview(false);
123
+ ev.emit(changeIgnoreHideStopPreview, false);
137
124
  if (!granted) return;
138
- (() => {
139
- const requestId = ++snapshotRequestIdRef.current;
140
- IPCPlayerContext.snapshot({
141
- saveToAlbum,
142
- success: async res => {
143
- var _props$multiCameraCtx;
144
- setIgnoreHideStopPreview(false);
145
- const splitNum = (_props$multiCameraCtx = props.multiCameraCtx) === null || _props$multiCameraCtx === void 0 || (_props$multiCameraCtx = _props$multiCameraCtx.protocol) === null || _props$multiCameraCtx === void 0 ? void 0 : _props$multiCameraCtx.total_split_num;
146
- const summary = await getCaptureResultSummary(res, {
147
- multiLens: props.multiLens,
148
- protocolCount: splitNum,
149
- devId
150
- });
151
- if (requestId !== snapshotRequestIdRef.current) return;
152
- if (!summary) {
153
- handleSnapshotFail({});
154
- return;
155
- }
156
- setState({
157
- showShot: true,
158
- shotUrl: summary.thumbnailPath,
159
- shotCount: summary.isMultiLens ? summary.count : 0
160
- });
161
- },
162
- fail: handleSnapshotFail
163
- });
164
- })();
125
+ IPCPlayerContext.snapshot({
126
+ saveToAlbum,
127
+ success: res => {
128
+ ev.emit(changeIgnoreHideStopPreview, false);
129
+ setState({
130
+ showShot: true,
131
+ shotUrl: res.tempImagePath
132
+ });
133
+ },
134
+ fail: err => {
135
+ ev.emit(changeIgnoreHideStopPreview, false);
136
+ const errObj = err.innerError || err || {};
137
+ const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_screenshot_error_tip');
138
+ toast({
139
+ title: errMsg
140
+ });
141
+ }
142
+ });
165
143
  });
166
144
  if (hideScreenShotMenu) return null;
167
145
  return /*#__PURE__*/React.createElement(View, {
@@ -2,7 +2,46 @@
2
2
  color: var(--iconColor);
3
3
  font-size: calc(var(--iconPlayerSize) * var(--ipc-player-size-scale, 1)) !important;
4
4
  }
5
-
6
5
  .ipc-player-plugin-screenshot-toast-wrap {
7
6
  position: absolute;
8
7
  }
8
+ .ipc-player-plugin-screenshot-toast {
9
+ flex: 1;
10
+ border-radius: calc(8px * var(--ipc-player-size-scale, 1));;
11
+ background-color: var(--shot-card-bg-color);
12
+ display: flex;
13
+ align-items: center;
14
+ padding: calc(8px * var(--ipc-player-size-scale, 1)) calc(12px * var(--ipc-player-size-scale, 1));
15
+ z-index: 100;
16
+ .ipc-player-plugin-screenshot-toast-image-box {
17
+ border-radius: calc(4px * var(--ipc-player-size-scale, 1));
18
+ overflow: hidden;
19
+ width: calc(66px * var(--ipc-player-size-scale, 1));
20
+ height: calc(66px * 0.57 * var(--ipc-player-size-scale, 1));
21
+ }
22
+ .ipc-player-plugin-screenshot-toast-image {
23
+ width: 100%;
24
+ height: 100%;
25
+ object-fit: cover;
26
+ }
27
+ .ipc-player-plugin-screenshot-toast-title {
28
+ flex: 1;
29
+ margin-left: calc(12px * var(--ipc-player-size-scale, 1));
30
+ font-size: calc(14px * var(--ipc-player-size-scale, 1));
31
+ color: var(--fontColor);
32
+ margin-right: calc(12px * var(--ipc-player-size-scale, 1));
33
+ word-break: break-word;
34
+
35
+ }
36
+ .ipc-player-plugin-screenshot-toast-bottom {
37
+ border: 1px solid #1989FA;
38
+ min-width: calc(52px * var(--ipc-player-size-scale, 1));
39
+ max-width: calc(100px * var(--ipc-player-size-scale, 1));
40
+ border-radius: calc(4px * var(--ipc-player-size-scale, 1));
41
+ padding: calc(5px * var(--ipc-player-size-scale, 1)) calc(11px * var(--ipc-player-size-scale, 1));
42
+ font-size: calc(14px * var(--ipc-player-size-scale, 1));
43
+ white-space: nowrap;
44
+ overflow: hidden;
45
+ text-overflow: ellipsis;
46
+ }
47
+ }
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import './index.less';
3
3
  type Props = {
4
4
  className?: string;
5
- onView?: () => void;
6
5
  /** 主题色(用于「开通」按钮背景)。默认与 player brandColor 一致 */
7
6
  brandColor?: string;
8
7
  /** 试看倒计时初始秒数,来源于 smartImageQualityState.trialRemainingSec */
@@ -12,5 +11,5 @@ type Props = {
12
11
  /** 倒计时归零时触发,本组件保证整个生命周期内只回调一次 */
13
12
  onCountdownEnd?: () => void;
14
13
  };
15
- export declare const TrialBadge: ({ className, onView, brandColor, trialRemainingSec, onSubscribe, onCountdownEnd, }: Props) => React.JSX.Element;
14
+ export declare const TrialBadge: ({ className, brandColor, trialRemainingSec, onSubscribe, onCountdownEnd, }: Props) => React.JSX.Element;
16
15
  export { useTrialBadge } from './useTrialBadge';
@@ -16,15 +16,11 @@ const formatCountdown = seconds => {
16
16
  export const TrialBadge = _ref => {
17
17
  let {
18
18
  className,
19
- onView,
20
19
  brandColor = FALLBACK_BRAND_COLOR,
21
20
  trialRemainingSec = 0,
22
21
  onSubscribe,
23
22
  onCountdownEnd
24
23
  } = _ref;
25
- useEffect(() => {
26
- onView === null || onView === void 0 || onView();
27
- }, [onView]);
28
24
  const [remainingSec, setRemainingSec] = useState(Math.max(0, Math.floor(trialRemainingSec)));
29
25
  const endedRef = useRef(false);
30
26
  const onCountdownEndRef = useRef(onCountdownEnd);
@@ -81,19 +77,15 @@ export const TrialBadge = _ref => {
81
77
  backgroundColor: brandColor
82
78
  },
83
79
  onClick: () => {
84
- try {
85
- ty.event({
86
- eventId: 'thing_qbwpX5zfbKOSjD4jz1tPv61rqrhGX7iV',
87
- event: {
88
- business_type: 'ipc',
89
- scene_type: 'smart_image_quality',
90
- feat_type: 'go_pay',
91
- biz: 'preview_mini'
92
- }
93
- });
94
- } catch (error) {
95
- console.warn('[IPC] trial subscription tracking failed:', error);
96
- }
80
+ ty.event({
81
+ eventId: 'thing_qbwpX5zfbKOSjD4jz1tPv61rqrhGX7iV',
82
+ event: {
83
+ business_type: 'ipc',
84
+ scene_type: 'smart_image_quality',
85
+ feat_type: 'go_pay',
86
+ biz: 'preview_mini'
87
+ }
88
+ });
97
89
  onSubscribe === null || onSubscribe === void 0 || onSubscribe();
98
90
  }
99
91
  }, /*#__PURE__*/React.createElement(Text, {
@@ -1,9 +1,8 @@
1
- import type { MutableRefObject } from 'react';
1
+ /// <reference types="react" />
2
2
  import type { EventInstance } from '../../interface';
3
- export declare const useTrialBadge: (event: EventInstance, devId: string, trialRemainingSec: number, viewedRef?: MutableRefObject<boolean>) => {
3
+ export declare const useTrialBadge: (event: EventInstance, devId: string, trialRemainingSec: number) => {
4
4
  showTrialBadge: boolean;
5
5
  setShowTrialBadge: import("react").Dispatch<import("react").SetStateAction<boolean>>;
6
- handleTrialView: () => void;
7
6
  handleTrialSubscribe: () => Promise<void>;
8
7
  handleCountdownEnd: () => Promise<void>;
9
8
  };
@@ -3,10 +3,7 @@ import { setTrailFinish } from '../../utils/ttt';
3
3
  import { gotoSecurityCloudService2 } from '../../utils';
4
4
  import { trialCountdownEnd } from '../../ui/constant';
5
5
  import Strings from '../../i18n';
6
- import { createEntryTracking, reportEntryClick, reportEntryView } from '../../utils/fullLinkTracking';
7
- export const useTrialBadge = (event, devId, trialRemainingSec, viewedRef) => {
8
- const localViewedRef = useRef(false);
9
- const pageViewedRef = viewedRef || localViewedRef;
6
+ export const useTrialBadge = (event, devId, trialRemainingSec) => {
10
7
  const [showTrialBadge, setShowTrialBadge] = useState(false);
11
8
  const prevTrialSecRef = useRef(trialRemainingSec);
12
9
  useEffect(() => {
@@ -17,16 +14,9 @@ export const useTrialBadge = (event, devId, trialRemainingSec, viewedRef) => {
17
14
  }
18
15
  prevTrialSecRef.current = trialRemainingSec;
19
16
  }, [trialRemainingSec]);
20
- const handleTrialView = useCallback(() => {
21
- if (pageViewedRef.current) return;
22
- pageViewedRef.current = true;
23
- reportEntryView(devId, createEntryTracking());
24
- }, [devId, pageViewedRef]);
25
17
  const handleTrialSubscribe = useCallback(async () => {
26
18
  try {
27
- const tracking = createEntryTracking();
28
- await reportEntryClick(devId, tracking);
29
- await gotoSecurityCloudService2(devId, tracking);
19
+ await gotoSecurityCloudService2(devId);
30
20
  } catch (error) {
31
21
  ty.showToast({
32
22
  title: Strings.getLang('ipc_player_fetch_error'),
@@ -61,7 +51,6 @@ export const useTrialBadge = (event, devId, trialRemainingSec, viewedRef) => {
61
51
  return {
62
52
  showTrialBadge,
63
53
  setShowTrialBadge,
64
- handleTrialView,
65
54
  handleTrialSubscribe,
66
55
  handleCountdownEnd
67
56
  };
@@ -77,6 +77,7 @@ export const TryExperience = props => {
77
77
  }
78
78
  }, [buttonState]);
79
79
  const onTryExperience = useCallback(async () => {
80
+ console.log('res===onTryExperience', lockRef.current, isLowPhone);
80
81
  if (lockRef.current) return;
81
82
  if (isLowPhone) {
82
83
  showToast({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.61-beta.1",
3
+ "version": "0.0.63",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -37,8 +37,7 @@
37
37
  "dependencies": {
38
38
  "@ray-js/direction-control": "^0.0.8",
39
39
  "@ray-js/ipc-ptz-zoom": "^0.0.3",
40
- "@ray-js/ray-ipc-player": "2.1.7-beta.0",
41
- "@ray-js/panel-sdk": "^1.13.1",
40
+ "@ray-js/ray-ipc-player": "^2.1.7",
42
41
  "@ray-js/ray-ipc-utils": "^1.1.16",
43
42
  "@ray-js/svg": "0.2.0",
44
43
  "clsx": "^1.2.1",
@@ -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,2 +0,0 @@
1
- import type { ComponentConfig, ComponentRenderState } from '../interface';
2
- export declare function shouldRenderContent<T>(item: ComponentConfig<T>, state: ComponentRenderState): boolean;
@@ -1,3 +0,0 @@
1
- export function shouldRenderContent(item, state) {
2
- return !item.hidden && (!item.renderWhen || item.renderWhen(state));
3
- }
@@ -1,14 +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
- 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>;
@@ -1,70 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export {};