@ray-js/ipc-player-integration 0.0.64 → 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.
Files changed (44) hide show
  1. package/lib/ctx/ctx.album.test.d.ts +1 -0
  2. package/lib/ctx/ctx.album.test.js +197 -0
  3. package/lib/ctx/ctx.composition.js +13 -3
  4. package/lib/ctx/ctx.js +46 -35
  5. package/lib/i18n/index.d.ts +12 -0
  6. package/lib/i18n/strings.d.ts +6 -0
  7. package/lib/i18n/strings.js +6 -0
  8. package/lib/interface.d.ts +17 -3
  9. package/lib/ui/absoluteContent.d.ts +2 -0
  10. package/lib/ui/absoluteContent.js +3 -0
  11. package/lib/ui/bottomLeftContent.js +3 -1
  12. package/lib/ui/ui.js +26 -22
  13. package/lib/utils/captureResult.d.ts +14 -0
  14. package/lib/utils/captureResult.js +70 -0
  15. package/lib/utils/captureResult.test.d.ts +1 -0
  16. package/lib/utils/captureResult.test.js +117 -0
  17. package/lib/utils/fullLinkTracking.d.ts +5 -0
  18. package/lib/utils/fullLinkTracking.js +71 -0
  19. package/lib/utils/navigation.d.ts +2 -1
  20. package/lib/utils/navigation.js +13 -3
  21. package/lib/widgets/captureResult/captureResult.d.ts +16 -0
  22. package/lib/widgets/captureResult/captureResult.js +85 -0
  23. package/lib/widgets/captureResult/captureResult.less +144 -0
  24. package/lib/widgets/captureResult/captureResult.test.d.ts +1 -0
  25. package/lib/widgets/captureResult/captureResult.test.js +80 -0
  26. package/lib/widgets/captureResult/index.d.ts +2 -0
  27. package/lib/widgets/captureResult/index.js +2 -0
  28. package/lib/widgets/index.d.ts +1 -0
  29. package/lib/widgets/index.js +2 -1
  30. package/lib/widgets/multiCamera/index.less +1 -0
  31. package/lib/widgets/recordVideo/recordVideo.js +53 -52
  32. package/lib/widgets/recordVideo/recordVideo.less +17 -74
  33. package/lib/widgets/recordVideo/recordVideo.lifecycle.test.d.ts +1 -0
  34. package/lib/widgets/recordVideo/recordVideo.lifecycle.test.js +106 -0
  35. package/lib/widgets/recordVideo/recordVideo.test.js +1 -0
  36. package/lib/widgets/screenshot/screenshot.js +66 -44
  37. package/lib/widgets/screenshot/screenshot.less +1 -40
  38. package/lib/widgets/screenshot/screenshot.test.d.ts +1 -0
  39. package/lib/widgets/screenshot/screenshot.test.js +120 -0
  40. package/lib/widgets/trialBadge/index.d.ts +2 -1
  41. package/lib/widgets/trialBadge/index.js +17 -9
  42. package/lib/widgets/trialBadge/useTrialBadge.d.ts +3 -2
  43. package/lib/widgets/trialBadge/useTrialBadge.js +13 -2
  44. package/package.json +2 -2
@@ -0,0 +1,120 @@
1
+ import { act, renderHook } from '@testing-library/react-hooks/dom';
2
+ import { atom } from 'jotai';
3
+ import { authorize, authorizeStatus, getSystemInfoSync, showModal } from '@ray-js/ray';
4
+ import { getDeviceInfo } from '../../utils/device';
5
+ import { Screenshot } from './screenshot';
6
+ jest.mock('@ray-js/ray', () => ({
7
+ View: 'div',
8
+ Text: 'span',
9
+ Image: 'img',
10
+ getSystemInfoSync: jest.fn(),
11
+ authorize: jest.fn(),
12
+ authorizeStatus: jest.fn(),
13
+ showModal: jest.fn(),
14
+ openAppSystemSettingPage: jest.fn()
15
+ }));
16
+ jest.mock('@ray-js/ray-ipc-utils', () => ({
17
+ goToIpcPageNativeRoute: jest.fn()
18
+ }));
19
+ jest.mock('../../utils/device', () => ({
20
+ getDeviceInfo: jest.fn()
21
+ }));
22
+ jest.mock('../../i18n', () => ({
23
+ __esModule: true,
24
+ default: {
25
+ getLang: key => key
26
+ }
27
+ }));
28
+ jest.mock('./screenshot.less', () => ({}));
29
+ jest.mock('../captureResult/captureResult.less', () => ({}));
30
+ beforeEach(() => {
31
+ jest.clearAllMocks();
32
+ getSystemInfoSync.mockReturnValue({
33
+ platform: 'android',
34
+ system: 'android 12'
35
+ });
36
+ authorizeStatus.mockImplementation(_ref => {
37
+ let {
38
+ fail
39
+ } = _ref;
40
+ return fail({
41
+ errorCode: 9004
42
+ });
43
+ });
44
+ authorize.mockImplementation(_ref2 => {
45
+ let {
46
+ fail
47
+ } = _ref2;
48
+ return fail({
49
+ errorCode: 9004
50
+ });
51
+ });
52
+ getDeviceInfo.mockResolvedValue({
53
+ configMetas: {
54
+ tyabimr4v3: {
55
+ total_split_num: 3
56
+ }
57
+ }
58
+ });
59
+ });
60
+ const createProps = () => ({
61
+ IPCPlayerContext: {
62
+ snapshot: jest.fn(_ref3 => {
63
+ let {
64
+ success
65
+ } = _ref3;
66
+ return success({
67
+ tempImagePath: 'thingfile://capture.jpg'
68
+ });
69
+ })
70
+ },
71
+ addContent: jest.fn(),
72
+ deleteContent: jest.fn(),
73
+ saveToAlbum: 0,
74
+ devId: 'camera-1',
75
+ toast: jest.fn(),
76
+ screenType: atom('vertical'),
77
+ brandColor: atom('#000000'),
78
+ multiLens: true,
79
+ event: {
80
+ emit: jest.fn()
81
+ }
82
+ });
83
+ it('keeps multi-lens results when legacy album authorization is unavailable', async () => {
84
+ const props = createProps();
85
+ const {
86
+ result,
87
+ unmount
88
+ } = renderHook(() => Screenshot(props));
89
+ await act(async () => {
90
+ await result.current.props.onClick();
91
+ });
92
+ expect(authorizeStatus).not.toHaveBeenCalled();
93
+ expect(props.IPCPlayerContext.snapshot).toHaveBeenCalledWith(expect.objectContaining({
94
+ saveToAlbum: 0
95
+ }));
96
+ const [, config] = props.addContent.mock.calls[0];
97
+ expect(config.content().props).toEqual(expect.objectContaining({
98
+ count: 3,
99
+ thumbnailPath: 'thingfile://capture_lens1.jpg'
100
+ }));
101
+ unmount();
102
+ });
103
+ it('keeps the permission rejection path before taking a snapshot', async () => {
104
+ getSystemInfoSync.mockReturnValue({
105
+ platform: 'ios',
106
+ system: 'iOS 18'
107
+ });
108
+ const props = createProps();
109
+ const {
110
+ result,
111
+ unmount
112
+ } = renderHook(() => Screenshot(props));
113
+ await act(async () => {
114
+ await result.current.props.onClick();
115
+ });
116
+ expect(props.IPCPlayerContext.snapshot).not.toHaveBeenCalled();
117
+ expect(props.addContent).not.toHaveBeenCalled();
118
+ expect(showModal).toHaveBeenCalledTimes(1);
119
+ unmount();
120
+ });
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import './index.less';
3
3
  type Props = {
4
4
  className?: string;
5
+ onView?: () => void;
5
6
  /** 主题色(用于「开通」按钮背景)。默认与 player brandColor 一致 */
6
7
  brandColor?: string;
7
8
  /** 试看倒计时初始秒数,来源于 smartImageQualityState.trialRemainingSec */
@@ -11,5 +12,5 @@ type Props = {
11
12
  /** 倒计时归零时触发,本组件保证整个生命周期内只回调一次 */
12
13
  onCountdownEnd?: () => void;
13
14
  };
14
- export declare const TrialBadge: ({ className, brandColor, trialRemainingSec, onSubscribe, onCountdownEnd, }: Props) => React.JSX.Element;
15
+ export declare const TrialBadge: ({ className, onView, brandColor, trialRemainingSec, onSubscribe, onCountdownEnd, }: Props) => React.JSX.Element;
15
16
  export { useTrialBadge } from './useTrialBadge';
@@ -16,11 +16,15 @@ const formatCountdown = seconds => {
16
16
  export const TrialBadge = _ref => {
17
17
  let {
18
18
  className,
19
+ onView,
19
20
  brandColor = FALLBACK_BRAND_COLOR,
20
21
  trialRemainingSec = 0,
21
22
  onSubscribe,
22
23
  onCountdownEnd
23
24
  } = _ref;
25
+ useEffect(() => {
26
+ onView === null || onView === void 0 || onView();
27
+ }, [onView]);
24
28
  const [remainingSec, setRemainingSec] = useState(Math.max(0, Math.floor(trialRemainingSec)));
25
29
  const endedRef = useRef(false);
26
30
  const onCountdownEndRef = useRef(onCountdownEnd);
@@ -77,15 +81,19 @@ export const TrialBadge = _ref => {
77
81
  backgroundColor: brandColor
78
82
  },
79
83
  onClick: () => {
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
- });
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
+ }
89
97
  onSubscribe === null || onSubscribe === void 0 || onSubscribe();
90
98
  }
91
99
  }, /*#__PURE__*/React.createElement(Text, {
@@ -1,8 +1,9 @@
1
- /// <reference types="react" />
1
+ import type { MutableRefObject } from 'react';
2
2
  import type { EventInstance } from '../../interface';
3
- export declare const useTrialBadge: (event: EventInstance, devId: string, trialRemainingSec: number) => {
3
+ export declare const useTrialBadge: (event: EventInstance, devId: string, trialRemainingSec: number, viewedRef?: MutableRefObject<boolean>) => {
4
4
  showTrialBadge: boolean;
5
5
  setShowTrialBadge: import("react").Dispatch<import("react").SetStateAction<boolean>>;
6
+ handleTrialView: () => void;
6
7
  handleTrialSubscribe: () => Promise<void>;
7
8
  handleCountdownEnd: () => Promise<void>;
8
9
  };
@@ -3,7 +3,10 @@ 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
- export const useTrialBadge = (event, devId, trialRemainingSec) => {
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;
7
10
  const [showTrialBadge, setShowTrialBadge] = useState(false);
8
11
  const prevTrialSecRef = useRef(trialRemainingSec);
9
12
  useEffect(() => {
@@ -14,9 +17,16 @@ export const useTrialBadge = (event, devId, trialRemainingSec) => {
14
17
  }
15
18
  prevTrialSecRef.current = trialRemainingSec;
16
19
  }, [trialRemainingSec]);
20
+ const handleTrialView = useCallback(() => {
21
+ if (pageViewedRef.current) return;
22
+ pageViewedRef.current = true;
23
+ reportEntryView(devId, createEntryTracking());
24
+ }, [devId, pageViewedRef]);
17
25
  const handleTrialSubscribe = useCallback(async () => {
18
26
  try {
19
- await gotoSecurityCloudService2(devId);
27
+ const tracking = createEntryTracking();
28
+ await reportEntryClick(devId, tracking);
29
+ await gotoSecurityCloudService2(devId, tracking);
20
30
  } catch (error) {
21
31
  ty.showToast({
22
32
  title: Strings.getLang('ipc_player_fetch_error'),
@@ -51,6 +61,7 @@ export const useTrialBadge = (event, devId, trialRemainingSec) => {
51
61
  return {
52
62
  showTrialBadge,
53
63
  setShowTrialBadge,
64
+ handleTrialView,
54
65
  handleTrialSubscribe,
55
66
  handleCountdownEnd
56
67
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.64",
3
+ "version": "0.0.65-beta.0",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -37,8 +37,8 @@
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",
40
41
  "@ray-js/panel-sdk": "^1.13.1",
41
- "@ray-js/ray-ipc-player": "^2.1.7",
42
42
  "@ray-js/ray-ipc-utils": "^1.1.16",
43
43
  "@ray-js/svg": "0.2.0",
44
44
  "clsx": "^1.2.1",