@ray-js/ipc-player-integration 0.0.65-beta.4 → 0.0.66-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.
Files changed (141) hide show
  1. package/README.md +6 -0
  2. package/lib/ctx/ctx.composition.js +3 -13
  3. package/lib/ctx/ctx.js +35 -46
  4. package/lib/ctx/multiCameraCtx.d.ts +0 -2
  5. package/lib/ctx/multiCameraCtx.js +1 -17
  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/index.d.ts +4 -0
  10. package/lib/index.js +3 -1
  11. package/lib/interface.d.ts +3 -17
  12. package/lib/renderer/capabilities.d.ts +8 -0
  13. package/lib/renderer/capabilities.js +19 -0
  14. package/lib/renderer/context.d.ts +5 -0
  15. package/lib/renderer/context.js +6 -0
  16. package/lib/renderer/directionControl.d.ts +6 -0
  17. package/lib/renderer/directionControl.js +3 -0
  18. package/lib/renderer/font.less +5 -0
  19. package/lib/renderer/glyphs.d.ts +1 -0
  20. package/lib/renderer/glyphs.js +256 -0
  21. package/lib/renderer/index.module.less +48 -0
  22. package/lib/renderer/ptzZoom.d.ts +6 -0
  23. package/lib/renderer/ptzZoom.js +3 -0
  24. package/lib/renderer/text.d.ts +4 -0
  25. package/lib/renderer/text.js +32 -0
  26. package/lib/renderer/text.module.less +4 -0
  27. package/lib/renderer/viewport.d.ts +7 -0
  28. package/lib/renderer/viewport.js +24 -0
  29. package/lib/res/lynx-signal/index.d.ts +1 -0
  30. package/lib/res/lynx-signal/index.js +22 -0
  31. package/lib/res/lynx-signal/signalFour0.png +0 -0
  32. package/lib/res/lynx-signal/signalFour1.png +0 -0
  33. package/lib/res/lynx-signal/signalFour2.png +0 -0
  34. package/lib/res/lynx-signal/signalFour3.png +0 -0
  35. package/lib/res/lynx-signal/signalFour4.png +0 -0
  36. package/lib/res/lynx-signal/signalThree0.png +0 -0
  37. package/lib/res/lynx-signal/signalThree1.png +0 -0
  38. package/lib/res/lynx-signal/signalThree2.png +0 -0
  39. package/lib/res/lynx-signal/signalThree3.png +0 -0
  40. package/lib/res/player-charging.png +0 -0
  41. package/lib/res/player-more-arrow.png +0 -0
  42. package/lib/res/player-solar.png +0 -0
  43. package/lib/ui/bottomLeftContent.js +119 -55
  44. package/lib/ui/bottomRightContent.js +6 -3
  45. package/lib/ui/scrollHintArrow.d.ts +23 -0
  46. package/lib/ui/scrollHintArrow.js +82 -0
  47. package/lib/ui/ui.d.ts +5 -0
  48. package/lib/ui/ui.js +89 -98
  49. package/lib/utils/navigation.d.ts +1 -2
  50. package/lib/utils/navigation.js +3 -13
  51. package/lib/widgets/battery/battery.js +7 -5
  52. package/lib/widgets/battery/batteryFull.js +7 -5
  53. package/lib/widgets/battery/statusIcon.d.ts +6 -0
  54. package/lib/widgets/battery/statusIcon.js +36 -0
  55. package/lib/widgets/battery/statusIcon.less +24 -0
  56. package/lib/widgets/floodlight/floodlight.js +2 -1
  57. package/lib/widgets/flowLowTip/flowLowTip.js +2 -1
  58. package/lib/widgets/fullScreen/fullScreen.js +2 -1
  59. package/lib/widgets/fullScreen/fullTravelRouteControl.d.ts +1 -1
  60. package/lib/widgets/fullScreen/fullTravelRouteControl.js +1 -1
  61. package/lib/widgets/fullScreen/verticalScreen.js +2 -1
  62. package/lib/widgets/index.d.ts +0 -1
  63. package/lib/widgets/index.js +1 -2
  64. package/lib/widgets/moveInteractiveControl/controlButton.js +2 -1
  65. package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.js +12 -3
  66. package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.less +24 -4
  67. package/lib/widgets/multiCamera/index.less +0 -1
  68. package/lib/widgets/multiCamera/landscapeTip.js +2 -1
  69. package/lib/widgets/multiCamera/moveablePtzControl.js +5 -5
  70. package/lib/widgets/multiCamera/multiPtz.js +3 -2
  71. package/lib/widgets/multiCamera/ptzMoveableTip.js +2 -1
  72. package/lib/widgets/multiCamera/switchLayout.js +2 -1
  73. package/lib/widgets/multiCamera/tileMultiPtz.js +3 -2
  74. package/lib/widgets/multiCamera/tileSwitchLayout.js +2 -1
  75. package/lib/widgets/multiCamera/tileTip.js +2 -1
  76. package/lib/widgets/muted/muted.js +2 -1
  77. package/lib/widgets/muted/muted.test.js +66 -52
  78. package/lib/widgets/ptz/ptz.js +2 -1
  79. package/lib/widgets/ptz/ptzControl.js +1 -1
  80. package/lib/widgets/ptzControlTip/ptzControlTip.js +6 -3
  81. package/lib/widgets/ptzControlTip/ptzControlTip.less +6 -0
  82. package/lib/widgets/realTimeMagnification/realTimeMagnification.js +2 -1
  83. package/lib/widgets/recordVideo/recordVideo.js +54 -58
  84. package/lib/widgets/recordVideo/recordVideo.less +74 -17
  85. package/lib/widgets/recordVideo/recordVideo.test.js +0 -1
  86. package/lib/widgets/resolution/fullResolutionControl.js +29 -19
  87. package/lib/widgets/resolution/resolution.js +3 -2
  88. package/lib/widgets/screenshot/screenshot.js +45 -67
  89. package/lib/widgets/screenshot/screenshot.less +40 -1
  90. package/lib/widgets/signal4G/signal4G.js +4 -1
  91. package/lib/widgets/siren/siren.js +2 -1
  92. package/lib/widgets/tempHumidity/tempHumidity.js +2 -1
  93. package/lib/widgets/toggleVerticalFull/toggleVerticalFull.js +2 -1
  94. package/lib/widgets/trialBadge/index.d.ts +1 -2
  95. package/lib/widgets/trialBadge/index.js +17 -20
  96. package/lib/widgets/trialBadge/index.less +24 -0
  97. package/lib/widgets/trialBadge/useTrialBadge.d.ts +2 -3
  98. package/lib/widgets/trialBadge/useTrialBadge.js +2 -13
  99. package/lib/widgets/tryExperience/tryExperience.js +2 -1
  100. package/lib/widgets/videoBitKBP/videoBitKBP.js +2 -1
  101. package/lib/widgets/voiceIntercom/voiceIntercom.js +50 -24
  102. package/lib/widgets/voiceIntercom/voiceIntercom.less +16 -0
  103. package/lib/widgets/zoomTurntable/lynxDockLayout.d.ts +6 -0
  104. package/lib/widgets/zoomTurntable/lynxDockLayout.js +30 -0
  105. package/lib/widgets/zoomTurntable/turntable/index.d.ts +5 -7
  106. package/lib/widgets/zoomTurntable/turntable/index.js +3 -1
  107. package/lib/widgets/zoomTurntable/turntable/lynx.d.ts +5 -0
  108. package/lib/widgets/zoomTurntable/turntable/lynx.js +273 -0
  109. package/lib/widgets/zoomTurntable/turntable/lynx.less +9 -0
  110. package/lib/widgets/zoomTurntable/turntable/lynxModel.d.ts +37 -0
  111. package/lib/widgets/zoomTurntable/turntable/lynxModel.js +122 -0
  112. package/lib/widgets/zoomTurntable/turntable/lynxPaint.d.ts +3 -0
  113. package/lib/widgets/zoomTurntable/turntable/lynxPaint.js +36 -0
  114. package/lib/widgets/zoomTurntable/zoomTurntableDock.d.ts +2 -0
  115. package/lib/widgets/zoomTurntable/zoomTurntableDock.js +1 -1
  116. package/lib/widgets/zoomTurntable/zoomTurntableEntry.js +31 -18
  117. package/lib/widgets/zoomTurntable/zoomTurntableTip.js +23 -3
  118. package/package.json +15 -7
  119. package/lib/ctx/ctx.album.test.d.ts +0 -1
  120. package/lib/ctx/ctx.album.test.js +0 -197
  121. package/lib/ctx/multiCameraCtx.test.d.ts +0 -1
  122. package/lib/ctx/multiCameraCtx.test.js +0 -65
  123. package/lib/ui/absoluteContent.d.ts +0 -2
  124. package/lib/ui/absoluteContent.js +0 -3
  125. package/lib/utils/captureResult.d.ts +0 -12
  126. package/lib/utils/captureResult.js +0 -70
  127. package/lib/utils/captureResult.test.d.ts +0 -1
  128. package/lib/utils/captureResult.test.js +0 -223
  129. package/lib/utils/fullLinkTracking.d.ts +0 -5
  130. package/lib/utils/fullLinkTracking.js +0 -71
  131. package/lib/widgets/captureResult/captureResult.d.ts +0 -16
  132. package/lib/widgets/captureResult/captureResult.js +0 -85
  133. package/lib/widgets/captureResult/captureResult.less +0 -144
  134. package/lib/widgets/captureResult/captureResult.test.d.ts +0 -1
  135. package/lib/widgets/captureResult/captureResult.test.js +0 -84
  136. package/lib/widgets/captureResult/index.d.ts +0 -2
  137. package/lib/widgets/captureResult/index.js +0 -2
  138. package/lib/widgets/recordVideo/recordVideo.lifecycle.test.d.ts +0 -1
  139. package/lib/widgets/recordVideo/recordVideo.lifecycle.test.js +0 -106
  140. package/lib/widgets/screenshot/screenshot.test.d.ts +0 -1
  141. package/lib/widgets/screenshot/screenshot.test.js +0 -135
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.65-beta.4",
3
+ "version": "0.0.66-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/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": "^0.0.8",
39
- "@ray-js/ipc-ptz-zoom": "^0.0.3",
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-utils": "^1.1.16",
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,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,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 {};
@@ -1,223 +0,0 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import { getFileInfo, getFileSystemManager } from '@ray-js/ray';
3
- import { getCaptureResultSummary } from './captureResult';
4
- import { getDeviceInfo } from './device';
5
- jest.mock('@ray-js/ray', () => ({
6
- getFileInfo: jest.fn(),
7
- getFileSystemManager: jest.fn()
8
- }));
9
- jest.mock('./device', () => ({
10
- getDeviceInfo: jest.fn()
11
- }));
12
- const mockGetDeviceInfo = getDeviceInfo;
13
- const mockGetFileInfo = getFileInfo;
14
- const mockGetFileSystemManager = getFileSystemManager;
15
- const access = jest.fn();
16
- const basePath = 'https://thing.miniapp.com/__tmp__/capture.png';
17
- const result = {
18
- tempImagePath: basePath,
19
- filePath: basePath
20
- };
21
- const options = {
22
- multiLens: true,
23
- lensIndices: [1, 2, 3, 4],
24
- devId: 'dev-1'
25
- };
26
- beforeEach(() => {
27
- jest.resetAllMocks();
28
- mockGetDeviceInfo.mockResolvedValue({
29
- configMetas: {}
30
- });
31
- mockGetFileSystemManager.mockReturnValue({
32
- access
33
- });
34
- access.mockImplementation(_ref => {
35
- let {
36
- success
37
- } = _ref;
38
- return success();
39
- });
40
- mockGetFileInfo.mockImplementation(() => {
41
- throw new Error('Source file inspection is forbidden');
42
- });
43
- });
44
- it('counts existing images instead of the configured lens total', async () => {
45
- access.mockImplementation(_ref2 => {
46
- let {
47
- path,
48
- success,
49
- fail
50
- } = _ref2;
51
- if (path.endsWith('_lens2.png')) fail({
52
- errorCode: 10011
53
- });else success();
54
- });
55
- await expect(getCaptureResultSummary(result, options)).resolves.toEqual({
56
- count: 3,
57
- isMultiLens: true,
58
- thumbnailPath: 'https://thing.miniapp.com/__tmp__/capture_lens1.png'
59
- });
60
- });
61
- it('uses protocol indices unchanged and selects the first existing image', async () => {
62
- access.mockImplementation(_ref3 => {
63
- let {
64
- path,
65
- success,
66
- fail
67
- } = _ref3;
68
- if (path === 'https://thing.miniapp.com/__tmp__/capture_lens7.png') success();else fail({
69
- errorCode: 10011
70
- });
71
- });
72
- await expect(getCaptureResultSummary(result, _objectSpread(_objectSpread({}, options), {}, {
73
- lensIndices: [2, 7, 9]
74
- }))).resolves.toEqual({
75
- count: 1,
76
- isMultiLens: true,
77
- thumbnailPath: 'https://thing.miniapp.com/__tmp__/capture_lens7.png'
78
- });
79
- });
80
- it('waits for access callbacks even when the method returns undefined', async () => {
81
- const callbacks = [];
82
- access.mockImplementation(_ref4 => {
83
- let {
84
- success
85
- } = _ref4;
86
- callbacks.push(success);
87
- });
88
- const summary = getCaptureResultSummary(result, options);
89
- await Promise.resolve();
90
- await Promise.resolve();
91
- expect(callbacks).toHaveLength(4);
92
- for (const success of callbacks) success();
93
- await expect(summary).resolves.toMatchObject({
94
- count: 4
95
- });
96
- });
97
- it('returns no success summary when every image is missing', async () => {
98
- access.mockImplementation(_ref5 => {
99
- let {
100
- fail
101
- } = _ref5;
102
- return fail({
103
- errorCode: 10011
104
- });
105
- });
106
- await expect(getCaptureResultSummary(result, options)).resolves.toBeNull();
107
- });
108
- it('does not duplicate a lens suffix or count duplicate indices', async () => {
109
- await expect(getCaptureResultSummary({
110
- tempImagePath: 'thingfile://tmp/capture_lens7.jpg?token=a',
111
- filePath: ''
112
- }, _objectSpread(_objectSpread({}, options), {}, {
113
- lensIndices: [2, 7, 7]
114
- }))).resolves.toEqual({
115
- count: 2,
116
- isMultiLens: true,
117
- thumbnailPath: 'thingfile://tmp/capture_lens2.jpg?token=a'
118
- });
119
- });
120
- it('reads the original lens indices from the ability when no protocol is supplied', async () => {
121
- mockGetDeviceInfo.mockResolvedValue({
122
- configMetas: {
123
- tyabimr4v3: JSON.stringify({
124
- split_info: [{
125
- index: '2'
126
- }, {
127
- index: '7'
128
- }]
129
- })
130
- }
131
- });
132
- await expect(getCaptureResultSummary(result, {
133
- multiLens: true,
134
- devId: 'dev-1'
135
- })).resolves.toMatchObject({
136
- count: 2,
137
- thumbnailPath: basePath.replace('.png', '_lens2.png')
138
- });
139
- });
140
- it('keeps legacy or mono capture unchanged', async () => {
141
- await expect(getCaptureResultSummary(result, {
142
- multiLens: false,
143
- lensIndices: [1],
144
- devId: 'dev-1'
145
- })).resolves.toEqual({
146
- count: 1,
147
- isMultiLens: false,
148
- thumbnailPath: basePath
149
- });
150
- expect(access).not.toHaveBeenCalled();
151
- expect(mockGetFileInfo).not.toHaveBeenCalled();
152
- });
153
- it('counts recording thumbnails even when the source video path is missing', async () => {
154
- const recording = {
155
- tempImagePath: '',
156
- thumbPath: basePath,
157
- filePath: '/missing/record.mp4'
158
- };
159
- access.mockImplementation(_ref6 => {
160
- let {
161
- path,
162
- success,
163
- fail
164
- } = _ref6;
165
- if (path.endsWith('_lens2.png')) fail({
166
- errorCode: 10011
167
- });else success();
168
- });
169
- await expect(getCaptureResultSummary(recording, options)).resolves.toEqual({
170
- count: 3,
171
- isMultiLens: true,
172
- thumbnailPath: basePath.replace('.png', '_lens1.png')
173
- });
174
- expect(mockGetFileInfo).not.toHaveBeenCalled();
175
- expect(recording.filePath).toBe('/missing/record.mp4');
176
- });
177
- it('does not count source videos when every recording thumbnail is missing', async () => {
178
- access.mockImplementation(_ref7 => {
179
- let {
180
- fail
181
- } = _ref7;
182
- return fail({
183
- errorCode: 10011
184
- });
185
- });
186
- await expect(getCaptureResultSummary(_objectSpread(_objectSpread({}, result), {}, {
187
- filePath: '/album/record.mp4'
188
- }), options)).resolves.toBeNull();
189
- expect(mockGetFileInfo).not.toHaveBeenCalled();
190
- });
191
- it('never falls back to a source path when no thumbnail is returned', async () => {
192
- await expect(getCaptureResultSummary({
193
- tempImagePath: '',
194
- filePath: '/album/record.mp4'
195
- }, options)).resolves.toBeNull();
196
- expect(access).not.toHaveBeenCalled();
197
- expect(mockGetFileInfo).not.toHaveBeenCalled();
198
- });
199
- it('uses explicit thumbnails ahead of other image paths without renumbering lenses', async () => {
200
- access.mockImplementation(_ref8 => {
201
- let {
202
- path,
203
- success,
204
- fail
205
- } = _ref8;
206
- if (path === 'thingfile://tmp/record_thumb_lens7.png') success();else fail({
207
- errorCode: 10011
208
- });
209
- });
210
- const recording = {
211
- tempImagePath: 'thingfile://tmp/other.png',
212
- thumbPath: 'thingfile://tmp/record_thumb.png',
213
- filePath: '/album/record.mp4'
214
- };
215
- await expect(getCaptureResultSummary(recording, _objectSpread(_objectSpread({}, options), {}, {
216
- lensIndices: [2, 7, 9]
217
- }))).resolves.toEqual({
218
- count: 1,
219
- isMultiLens: true,
220
- thumbnailPath: 'thingfile://tmp/record_thumb_lens7.png'
221
- });
222
- expect(recording.filePath).toBe('/album/record.mp4');
223
- });
@@ -1,5 +0,0 @@
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>;