@ray-js/ipc-player-integration 0.0.59-beta.0 → 0.0.61-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 (126) hide show
  1. package/README.md +0 -6
  2. package/lib/ctx/ctx.album.test.d.ts +1 -0
  3. package/lib/ctx/ctx.album.test.js +197 -0
  4. package/lib/ctx/ctx.composition.js +19 -4
  5. package/lib/ctx/ctx.js +103 -55
  6. package/lib/ctx/ports.output.d.ts +1 -0
  7. package/lib/ctx/resolution.d.ts +1 -1
  8. package/lib/ctx/resolution.js +3 -1
  9. package/lib/i18n/index.d.ts +12 -0
  10. package/lib/i18n/strings.d.ts +6 -0
  11. package/lib/i18n/strings.js +6 -0
  12. package/lib/index.d.ts +0 -4
  13. package/lib/index.js +1 -3
  14. package/lib/interface.d.ts +19 -3
  15. package/lib/ui/absoluteContent.d.ts +2 -0
  16. package/lib/ui/absoluteContent.js +3 -0
  17. package/lib/ui/bottomLeftContent.js +55 -119
  18. package/lib/ui/bottomRightContent.js +3 -6
  19. package/lib/ui/ui.d.ts +2 -5
  20. package/lib/ui/ui.js +49 -63
  21. package/lib/utils/captureResult.d.ts +14 -0
  22. package/lib/utils/captureResult.js +70 -0
  23. package/lib/utils/captureResult.test.d.ts +1 -0
  24. package/lib/utils/captureResult.test.js +117 -0
  25. package/lib/utils/fullLinkTracking.d.ts +5 -0
  26. package/lib/utils/fullLinkTracking.js +71 -0
  27. package/lib/utils/navigation.d.ts +2 -1
  28. package/lib/utils/navigation.js +13 -3
  29. package/lib/utils/ttt.js +2 -8
  30. package/lib/widgets/battery/battery.js +1 -2
  31. package/lib/widgets/battery/batteryFull.js +1 -2
  32. package/lib/widgets/captureResult/captureResult.d.ts +16 -0
  33. package/lib/widgets/captureResult/captureResult.js +85 -0
  34. package/lib/widgets/captureResult/captureResult.less +144 -0
  35. package/lib/widgets/captureResult/captureResult.test.d.ts +1 -0
  36. package/lib/widgets/captureResult/captureResult.test.js +80 -0
  37. package/lib/widgets/captureResult/index.d.ts +2 -0
  38. package/lib/widgets/captureResult/index.js +2 -0
  39. package/lib/widgets/floodlight/floodlight.js +1 -2
  40. package/lib/widgets/flowLowTip/flowLowTip.js +1 -2
  41. package/lib/widgets/fullScreen/fullScreen.js +1 -2
  42. package/lib/widgets/fullScreen/fullTravelRouteControl.d.ts +1 -1
  43. package/lib/widgets/fullScreen/fullTravelRouteControl.js +1 -1
  44. package/lib/widgets/fullScreen/verticalScreen.js +1 -2
  45. package/lib/widgets/index.d.ts +1 -0
  46. package/lib/widgets/index.js +2 -1
  47. package/lib/widgets/moveInteractiveControl/controlButton.js +1 -2
  48. package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.js +3 -12
  49. package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.less +4 -24
  50. package/lib/widgets/multiCamera/landscapeTip.js +1 -2
  51. package/lib/widgets/multiCamera/moveablePtzControl.js +1 -1
  52. package/lib/widgets/multiCamera/multiPtz.js +1 -2
  53. package/lib/widgets/multiCamera/ptzMoveableTip.js +1 -2
  54. package/lib/widgets/multiCamera/switchLayout.js +1 -2
  55. package/lib/widgets/multiCamera/tileMultiPtz.js +1 -2
  56. package/lib/widgets/multiCamera/tileSwitchLayout.js +1 -2
  57. package/lib/widgets/multiCamera/tileTip.js +1 -2
  58. package/lib/widgets/muted/muted.js +10 -5
  59. package/lib/widgets/muted/muted.less +5 -1
  60. package/lib/widgets/muted/muted.test.d.ts +1 -0
  61. package/lib/widgets/muted/muted.test.js +81 -0
  62. package/lib/widgets/ptz/ptz.js +1 -2
  63. package/lib/widgets/ptz/ptzControl.js +1 -1
  64. package/lib/widgets/ptzControlTip/ptzControlTip.js +3 -6
  65. package/lib/widgets/ptzControlTip/ptzControlTip.less +0 -6
  66. package/lib/widgets/realTimeMagnification/realTimeMagnification.js +1 -2
  67. package/lib/widgets/recordVideo/recordVideo.js +53 -53
  68. package/lib/widgets/recordVideo/recordVideo.less +17 -74
  69. package/lib/widgets/recordVideo/recordVideo.lifecycle.test.d.ts +1 -0
  70. package/lib/widgets/recordVideo/recordVideo.lifecycle.test.js +106 -0
  71. package/lib/widgets/recordVideo/recordVideo.test.js +1 -0
  72. package/lib/widgets/resolution/fullResolutionControl.js +19 -29
  73. package/lib/widgets/resolution/resolution.js +2 -3
  74. package/lib/widgets/screenshot/screenshot.js +66 -45
  75. package/lib/widgets/screenshot/screenshot.less +1 -40
  76. package/lib/widgets/screenshot/screenshot.test.d.ts +1 -0
  77. package/lib/widgets/screenshot/screenshot.test.js +120 -0
  78. package/lib/widgets/signal4G/signal4G.js +1 -4
  79. package/lib/widgets/siren/siren.js +1 -2
  80. package/lib/widgets/tempHumidity/tempHumidity.js +1 -2
  81. package/lib/widgets/toggleVerticalFull/toggleVerticalFull.js +1 -2
  82. package/lib/widgets/trialBadge/index.d.ts +2 -1
  83. package/lib/widgets/trialBadge/index.js +20 -17
  84. package/lib/widgets/trialBadge/index.less +0 -24
  85. package/lib/widgets/trialBadge/useTrialBadge.d.ts +3 -2
  86. package/lib/widgets/trialBadge/useTrialBadge.js +13 -2
  87. package/lib/widgets/tryExperience/tryExperience.js +1 -3
  88. package/lib/widgets/videoBitKBP/videoBitKBP.js +1 -2
  89. package/lib/widgets/voiceIntercom/voiceIntercom.js +24 -50
  90. package/lib/widgets/voiceIntercom/voiceIntercom.less +0 -16
  91. package/lib/widgets/zoomTurntable/turntable/index.d.ts +7 -5
  92. package/lib/widgets/zoomTurntable/turntable/index.js +1 -2
  93. package/lib/widgets/zoomTurntable/zoomTurntableEntry.js +1 -2
  94. package/lib/widgets/zoomTurntable/zoomTurntableTip.js +1 -2
  95. package/package.json +8 -15
  96. package/lib/renderer/capabilities.d.ts +0 -8
  97. package/lib/renderer/capabilities.js +0 -19
  98. package/lib/renderer/context.d.ts +0 -5
  99. package/lib/renderer/context.js +0 -6
  100. package/lib/renderer/directionControl.d.ts +0 -6
  101. package/lib/renderer/directionControl.js +0 -3
  102. package/lib/renderer/font.less +0 -5
  103. package/lib/renderer/glyphs.d.ts +0 -1
  104. package/lib/renderer/glyphs.js +0 -256
  105. package/lib/renderer/index.module.less +0 -48
  106. package/lib/renderer/ptzZoom.d.ts +0 -6
  107. package/lib/renderer/ptzZoom.js +0 -3
  108. package/lib/renderer/text.d.ts +0 -4
  109. package/lib/renderer/text.js +0 -32
  110. package/lib/renderer/text.module.less +0 -4
  111. package/lib/renderer/viewport.d.ts +0 -7
  112. package/lib/renderer/viewport.js +0 -24
  113. package/lib/res/lynx-signal/index.d.ts +0 -1
  114. package/lib/res/lynx-signal/index.js +0 -22
  115. package/lib/res/lynx-signal/signalFour0.png +0 -0
  116. package/lib/res/lynx-signal/signalFour1.png +0 -0
  117. package/lib/res/lynx-signal/signalFour2.png +0 -0
  118. package/lib/res/lynx-signal/signalFour3.png +0 -0
  119. package/lib/res/lynx-signal/signalFour4.png +0 -0
  120. package/lib/res/lynx-signal/signalThree0.png +0 -0
  121. package/lib/res/lynx-signal/signalThree1.png +0 -0
  122. package/lib/res/lynx-signal/signalThree2.png +0 -0
  123. package/lib/res/lynx-signal/signalThree3.png +0 -0
  124. package/lib/res/player-more-arrow.png +0 -0
  125. package/lib/ui/scrollHintArrow.d.ts +0 -23
  126. package/lib/ui/scrollHintArrow.js +0 -82
@@ -1,9 +1,8 @@
1
1
  import "core-js/modules/esnext.iterator.constructor.js";
2
2
  import "core-js/modules/esnext.iterator.map.js";
3
3
  import React, { useState, useContext, useEffect } from 'react';
4
- import { View, showToast } from '@ray-js/ray';
4
+ import { Text, View, showToast } from '@ray-js/ray';
5
5
  import clsx from 'clsx';
6
- import { PlayerText as Text } from '../../renderer/text';
7
6
  import Strings from '../../i18n';
8
7
  import { useMemoizedFn } from '../../hooks';
9
8
  import { useStore } from '../../ctx/store';
@@ -34,10 +33,6 @@ export const FullResolutionControl = props => {
34
33
  const onPlayerTap = useMemoizedFn(() => {
35
34
  setHide(true);
36
35
  });
37
- const normalizeResolution = value => {
38
- const normalized = String(value || '').toUpperCase();
39
- return normalized === 'HD' ? 'HD' : 'SD';
40
- };
41
36
  useEffect(() => {
42
37
  event.on('showFullResolutionControl', onShowFullResolutionControl);
43
38
  event.on(playerTap, onPlayerTap);
@@ -47,14 +42,13 @@ export const FullResolutionControl = props => {
47
42
  };
48
43
  }, []);
49
44
  const changeResolution = useMemoizedFn(value => {
50
- const targetResolution = normalizeResolution(value);
51
- if (targetResolution === normalizeResolution(resolution)) {
45
+ if (value === resolution) {
52
46
  showToast({
53
47
  icon: 'none',
54
48
  title: Strings.getLang('ipc_player_current_resolution_is_equal')
55
49
  });
56
50
  } else {
57
- setResolution(targetResolution).then(() => {
51
+ setResolution(value).then(() => {
58
52
  showToast({
59
53
  icon: 'none',
60
54
  title: Strings.getLang('ipc_player_change_resolution_success')
@@ -74,24 +68,20 @@ export const FullResolutionControl = props => {
74
68
  className: clsx('ipc-player-plugin-full-resolution-control', 'ipc-plugin-absolute-move-in-right', {
75
69
  'ipc-plugin-absolute-move-in-right-hide': hide
76
70
  })
77
- }, resolutionList.map(item => {
78
- const normalizedItem = normalizeResolution(item);
79
- const selected = normalizedItem === normalizeResolution(resolution);
80
- return /*#__PURE__*/React.createElement(Text, {
81
- key: item,
82
- onClick: () => {
83
- event.emit(widgetClick, {
84
- widgetId: widgetLabs.FULL_RESOLUTION_CONTROL,
85
- extra: {
86
- resolution: normalizedItem
87
- }
88
- });
89
- changeResolution(normalizedItem);
90
- },
91
- className: clsx('ipc-player-plugin-full-resolution-control-text'),
92
- style: selected ? {
93
- color: brandColor
94
- } : undefined
95
- }, Strings.getLang(`ipc_player_resolution_${normalizedItem}`));
96
- }));
71
+ }, resolutionList.map(item => /*#__PURE__*/React.createElement(Text, {
72
+ onClick: () => {
73
+ event.emit(widgetClick, {
74
+ widgetId: widgetLabs.FULL_RESOLUTION_CONTROL,
75
+ extra: {
76
+ resolution: item
77
+ }
78
+ });
79
+ changeResolution(item);
80
+ },
81
+ key: item,
82
+ className: clsx('ipc-player-plugin-full-resolution-control-text'),
83
+ style: item === resolution && {
84
+ color: brandColor
85
+ }
86
+ }, Strings.getLang(`ipc_player_resolution_${item}`))));
97
87
  };
@@ -1,9 +1,8 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import { View } from '@ray-js/ray';
2
+ import { View, Text } from '@ray-js/ray';
3
3
  import clsx from 'clsx';
4
4
  import React, { useContext } from 'react';
5
5
  import { useMemoizedFn } from 'ahooks';
6
- import { PlayerText as Text } from '../../renderer/text';
7
6
  import Strings from '../../i18n';
8
7
  import { FullResolutionControl } from './fullResolutionControl';
9
8
  import { fullResolutionId, pauseTimeToHideAllComponent, hideAllComponent, widgetLabs, widgetClick } from '../../ui/constant';
@@ -53,7 +52,7 @@ export const Resolution = props => {
53
52
  }
54
53
  if (verticalResolutionCustomClick) return false;
55
54
  if (screenType === 'vertical') {
56
- setResolution(String(resolution).toUpperCase() === 'HD' ? 'SD' : 'HD');
55
+ setResolution(resolution === 'HD' ? 'SD' : 'HD');
57
56
  }
58
57
  event.emit(pauseTimeToHideAllComponent);
59
58
  return true;
@@ -1,14 +1,15 @@
1
- import React, { useContext, useRef } from 'react';
2
- import { View, Image, getSystemInfoSync } from '@ray-js/ray';
1
+ import React, { useContext, useEffect, useRef } from 'react';
2
+ import { View, 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';
6
- import { PlayerText as Text } from '../../renderer/text';
7
6
  import Strings from '../../i18n';
8
7
  import { useStore } from '../../ctx/store';
9
8
  import { UIEventContext } from '../../ui/context';
10
9
  import { pauseTimeToHideAllComponent, changeIgnoreHideStopPreview, widgetLabs, widgetClick } from '../../ui/constant';
10
+ import { getCaptureResultSummary } from '../../utils/captureResult';
11
11
  import { ensureAlbumPermission } from '../../utils/authorize/album';
12
+ import { CaptureResultToast } from '../captureResult/captureResult';
12
13
  import './screenshot.less';
13
14
  const CLOSE_TIME = 5000;
14
15
  export function Screenshot(props) {
@@ -36,8 +37,15 @@ export function Screenshot(props) {
36
37
  /** 记录截屏url */
37
38
  const [state, setState] = useSetState({
38
39
  showShot: false,
39
- shotUrl: ''
40
+ shotUrl: '',
41
+ shotCount: 0
40
42
  });
43
+ const snapshotRequestIdRef = useRef(0);
44
+ useEffect(() => {
45
+ return () => {
46
+ snapshotRequestIdRef.current += 1;
47
+ };
48
+ }, []);
41
49
  useUpdateEffect(() => {
42
50
  if (state.showShot && screenType) {
43
51
  showShotToast();
@@ -50,7 +58,8 @@ export function Screenshot(props) {
50
58
  timer.current = setTimeout(() => {
51
59
  setState({
52
60
  showShot: false,
53
- shotUrl: ''
61
+ shotUrl: '',
62
+ shotCount: 0
54
63
  });
55
64
  deleteContent('absolute', 'plugin-screenshot-toast');
56
65
  }, CLOSE_TIME);
@@ -60,7 +69,8 @@ export function Screenshot(props) {
60
69
  const handCheck = () => {
61
70
  setState({
62
71
  showShot: false,
63
- shotUrl: ''
72
+ shotUrl: '',
73
+ shotCount: 0
64
74
  });
65
75
  deleteContent('absolute', 'plugin-screenshot-toast');
66
76
  clearInterval(timer.current);
@@ -82,31 +92,20 @@ export function Screenshot(props) {
82
92
  marginLeft: screenType === 'vertical' ? '0' : '-200px'
83
93
  },
84
94
  content: () => {
85
- return /*#__PURE__*/React.createElement(View, {
86
- className: "ipc-player-plugin-screenshot-toast"
87
- }, /*#__PURE__*/React.createElement(View, {
88
- className: "ipc-player-plugin-screenshot-toast-image-box"
89
- }, /*#__PURE__*/React.createElement(Image, {
90
- className: "ipc-player-plugin-screenshot-toast-image",
91
- src: state.shotUrl
92
- })), /*#__PURE__*/React.createElement(View, {
93
- className: "ipc-player-plugin-screenshot-toast-title"
94
- }, Strings.getLang('ipc_player_screenshot_success_tip')), /*#__PURE__*/React.createElement(View, {
95
- onClick: handCheck,
96
- className: "ipc-player-plugin-screenshot-toast-bottom",
97
- style: {
98
- color: brandColor,
99
- borderColor: brandColor
100
- }
101
- }, Strings.getLang('ipc_player_shot_success_check')));
95
+ return /*#__PURE__*/React.createElement(CaptureResultToast, {
96
+ brandColor: brandColor,
97
+ count: state.shotCount,
98
+ kind: "screenshot",
99
+ onCheck: handCheck,
100
+ thumbnailPath: state.shotUrl
101
+ });
102
102
  }
103
103
  });
104
104
  timeToCloseToast();
105
105
  };
106
106
  const handClick = useMemoizedFn(async () => {
107
- var _props$event, _props$event2;
108
- const ev = (_props$event = props.event) !== null && _props$event !== void 0 ? _props$event : event;
109
- ((_props$event2 = props.event) !== null && _props$event2 !== void 0 ? _props$event2 : event).emit(widgetClick, {
107
+ var _props$event;
108
+ ((_props$event = props.event) !== null && _props$event !== void 0 ? _props$event : event).emit(widgetClick, {
110
109
  widgetId: widgetLabs.SCREENSHOT
111
110
  });
112
111
  console.log('截屏!!!');
@@ -120,27 +119,49 @@ export function Screenshot(props) {
120
119
  props.event ? props.event.emit(changeIgnoreHideStopPreview, true) : event.emit(changeIgnoreHideStopPreview, true);
121
120
  }
122
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
+ };
123
135
  const granted = await ensureAlbumPermission();
124
- ev.emit(changeIgnoreHideStopPreview, false);
136
+ setIgnoreHideStopPreview(false);
125
137
  if (!granted) return;
126
- IPCPlayerContext.snapshot({
127
- saveToAlbum,
128
- success: res => {
129
- ev.emit(changeIgnoreHideStopPreview, false);
130
- setState({
131
- showShot: true,
132
- shotUrl: res.tempImagePath
133
- });
134
- },
135
- fail: err => {
136
- ev.emit(changeIgnoreHideStopPreview, false);
137
- const errObj = err.innerError || err || {};
138
- const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_screenshot_error_tip');
139
- toast({
140
- title: errMsg
141
- });
142
- }
143
- });
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
+ })();
144
165
  });
145
166
  if (hideScreenShotMenu) return null;
146
167
  return /*#__PURE__*/React.createElement(View, {
@@ -2,46 +2,7 @@
2
2
  color: var(--iconColor);
3
3
  font-size: calc(var(--iconPlayerSize) * var(--ipc-player-size-scale, 1)) !important;
4
4
  }
5
+
5
6
  .ipc-player-plugin-screenshot-toast-wrap {
6
7
  position: absolute;
7
8
  }
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
- }
@@ -0,0 +1 @@
1
+ export {};
@@ -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
+ });
@@ -3,15 +3,12 @@ import { View, Image } from '@ray-js/ray';
3
3
  import clsx from 'clsx';
4
4
  import { useSignal4G } from '../../hooks';
5
5
  import { signalSvgMap } from '../../res';
6
- import { signalPngMap } from '../../res/lynx-signal';
7
- import { usePlayerRenderMode } from '../../renderer/context';
8
6
  import './signal4G.less';
9
7
  export const Signal4G = props => {
10
8
  const {
11
9
  className,
12
10
  devId
13
11
  } = props;
14
- const isLynx = usePlayerRenderMode() === 'lynx';
15
12
  const {
16
13
  dpValue,
17
14
  signalKey
@@ -25,7 +22,7 @@ export const Signal4G = props => {
25
22
  className: clsx('ipc-player-plugin-signal4g')
26
23
  }, /*#__PURE__*/React.createElement(Image, {
27
24
  className: clsx('ipc-player-plugin-signal4g-icon'),
28
- src: isLynx ? signalPngMap[signalKey] : signalSvgMap[signalKey],
25
+ src: signalSvgMap[signalKey],
29
26
  mode: "aspectFit"
30
27
  })));
31
28
  };
@@ -1,7 +1,6 @@
1
- import { View } from '@ray-js/ray';
1
+ import { View, Text } from '@ray-js/ray';
2
2
  import React, { useContext } from 'react';
3
3
  import clsx from 'clsx';
4
- import { PlayerText as Text } from '../../renderer/text';
5
4
  import { useDpState } from '../../hooks';
6
5
  import { useStore } from '../../ctx/store';
7
6
  import { UIEventContext } from '../../ui/context';
@@ -1,9 +1,8 @@
1
1
  import "core-js/modules/esnext.iterator.constructor.js";
2
2
  import "core-js/modules/esnext.iterator.map.js";
3
3
  import React, { useMemo } from 'react';
4
- import { View } from '@ray-js/ray';
4
+ import { View, Text } from '@ray-js/ray';
5
5
  import clsx from 'clsx';
6
- import { PlayerText as Text } from '../../renderer/text';
7
6
  import { useTemperature, useHumidity, useEc, useWaterTemperature, useDpSupport } from '../../hooks';
8
7
  import { IPC_EC, IPC_WATER_TEMPERATURE, SENSOR_HUMIDITY, SENSOR_TEMPERATURE } from '../../utils/content/dpCode';
9
8
  import './tempHumidity.less';
@@ -1,7 +1,6 @@
1
- import { View } from '@ray-js/ray';
1
+ import { Text, View } from '@ray-js/ray';
2
2
  import clsx from 'clsx';
3
3
  import React from 'react';
4
- import { PlayerText as Text } from '../../renderer/text';
5
4
  import { useStore } from '../../ctx/store';
6
5
  import './toggleVerticalFull.less';
7
6
  export function ToggleVerticalFull(props) {
@@ -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';
@@ -1,8 +1,6 @@
1
1
  import React, { useEffect, useRef, useState } from 'react';
2
- import { Image, View } from '@ray-js/ray';
2
+ import { Image, Text, View } from '@ray-js/ray';
3
3
  import clsx from 'clsx';
4
- import { usePlayerRenderMode } from '../../renderer/context';
5
- import { PlayerText as Text } from '../../renderer/text';
6
4
  import Strings from '../../i18n';
7
5
  import tryOpen from '../../res/try/try_open.png';
8
6
  import './index.less';
@@ -18,12 +16,15 @@ const formatCountdown = seconds => {
18
16
  export const TrialBadge = _ref => {
19
17
  let {
20
18
  className,
19
+ onView,
21
20
  brandColor = FALLBACK_BRAND_COLOR,
22
21
  trialRemainingSec = 0,
23
22
  onSubscribe,
24
23
  onCountdownEnd
25
24
  } = _ref;
26
- const renderMode = usePlayerRenderMode();
25
+ useEffect(() => {
26
+ onView === null || onView === void 0 || onView();
27
+ }, [onView]);
27
28
  const [remainingSec, setRemainingSec] = useState(Math.max(0, Math.floor(trialRemainingSec)));
28
29
  const endedRef = useRef(false);
29
30
  const onCountdownEndRef = useRef(onCountdownEnd);
@@ -63,16 +64,14 @@ export const TrialBadge = _ref => {
63
64
  }, [trialRemainingSec]);
64
65
  const countdownText = formatCountdown(remainingSec);
65
66
  return /*#__PURE__*/React.createElement(View, {
66
- className: clsx('ipc-player-trial-badge', className, {
67
- 'ipc-player-trial-badge--lynx': renderMode === 'lynx'
68
- })
67
+ className: clsx('ipc-player-trial-badge', className)
69
68
  }, /*#__PURE__*/React.createElement(Image, {
70
69
  className: "ipc-player-trial-badge-icon",
71
70
  src: tryOpen,
72
71
  mode: "heightFix"
73
72
  }), /*#__PURE__*/React.createElement(Text, {
74
73
  className: "ipc-player-trial-badge-status"
75
- }, Strings.getLang('ipc_player_trial_in_use').replace(/\s*[||]\s*$/, '')), /*#__PURE__*/React.createElement(Text, {
74
+ }, Strings.getLang('ipc_player_trial_in_use')), /*#__PURE__*/React.createElement(Text, {
76
75
  className: "ipc-player-trial-badge-divider"
77
76
  }, "|"), /*#__PURE__*/React.createElement(Text, {
78
77
  className: "ipc-player-trial-badge-preview"
@@ -82,15 +81,19 @@ export const TrialBadge = _ref => {
82
81
  backgroundColor: brandColor
83
82
  },
84
83
  onClick: () => {
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
- });
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
+ }
94
97
  onSubscribe === null || onSubscribe === void 0 || onSubscribe();
95
98
  }
96
99
  }, /*#__PURE__*/React.createElement(Text, {
@@ -66,27 +66,3 @@
66
66
  font-weight: 600;
67
67
  line-height: 1;
68
68
  }
69
-
70
- // Lynx 不支持 inline-flex 的 WebView 排版语义,显式声明横向 flex。
71
- .ipc-player-trial-badge--lynx {
72
- // Match WebView inline-flex: size to content instead of stretching across its parent.
73
- align-self: flex-start;
74
- display: flex;
75
- flex-direction: row;
76
- background-color: rgba(0, 0, 0, 0.65);
77
-
78
- .ipc-player-trial-badge-icon {
79
- width: 20px;
80
- }
81
-
82
- .ipc-player-trial-badge-status,
83
- .ipc-player-trial-badge-divider,
84
- .ipc-player-trial-badge-preview {
85
- flex-shrink: 0;
86
- }
87
-
88
- .ipc-player-trial-badge-cta {
89
- display: flex;
90
- flex-direction: row;
91
- }
92
- }
@@ -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
  };