@ray-js/ipc-player-integration 0.0.71-beta.0 → 0.0.72-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 (145) hide show
  1. package/README.md +0 -6
  2. package/lib/ctx/ctx.composition.d.ts +5 -1
  3. package/lib/ctx/ctx.composition.js +4 -1
  4. package/lib/ctx/ctx.js +17 -12
  5. package/lib/ctx/ctx.test.js +19 -54
  6. package/lib/features/initPlayerWidgets/index.d.ts +3 -0
  7. package/lib/features/initPlayerWidgets/index.js +4 -0
  8. package/lib/index.d.ts +0 -4
  9. package/lib/index.js +1 -3
  10. package/lib/interface.d.ts +1 -1
  11. package/lib/ui/bottomControlLayout.d.ts +11 -0
  12. package/lib/ui/bottomControlLayout.js +19 -0
  13. package/lib/ui/bottomControlLayout.test.js +64 -0
  14. package/lib/ui/bottomLeftContent.js +73 -180
  15. package/lib/ui/bottomLeftContent.test.js +138 -0
  16. package/lib/ui/bottomRightContent.d.ts +2 -2
  17. package/lib/ui/bottomRightContent.js +24 -16
  18. package/lib/ui/bottomRightContent.test.js +144 -0
  19. package/lib/ui/constant.d.ts +2 -0
  20. package/lib/ui/constant.js +4 -1
  21. package/lib/ui/topLeftContent.js +2 -4
  22. package/lib/ui/topRightContent.js +2 -4
  23. package/lib/ui/ui.d.ts +0 -5
  24. package/lib/ui/ui.js +33 -86
  25. package/lib/ui/ui.less +24 -59
  26. package/lib/widgets/battery/battery.js +5 -7
  27. package/lib/widgets/battery/batteryFull.js +5 -7
  28. package/lib/widgets/captureResult/captureResult.js +1 -2
  29. package/lib/widgets/floatWindow/floatWindow.d.ts +13 -0
  30. package/lib/widgets/floatWindow/floatWindow.js +93 -0
  31. package/lib/widgets/floatWindow/floatWindow.less +14 -0
  32. package/lib/widgets/floatWindow/floatWindow.test.d.ts +1 -0
  33. package/lib/widgets/floatWindow/floatWindow.test.js +164 -0
  34. package/lib/widgets/floatWindow/icon.d.ts +1 -0
  35. package/lib/widgets/floatWindow/icon.js +4 -0
  36. package/lib/widgets/floatWindow/index.d.ts +1 -0
  37. package/lib/widgets/floatWindow/index.js +1 -0
  38. package/lib/widgets/floodlight/floodlight.js +1 -2
  39. package/lib/widgets/flowLowTip/flowLowTip.js +1 -2
  40. package/lib/widgets/fullScreen/fullScreen.js +1 -2
  41. package/lib/widgets/fullScreen/fullTravelRouteControl.d.ts +1 -1
  42. package/lib/widgets/fullScreen/fullTravelRouteControl.js +1 -1
  43. package/lib/widgets/fullScreen/verticalScreen.js +1 -2
  44. package/lib/widgets/index.d.ts +1 -0
  45. package/lib/widgets/index.js +2 -1
  46. package/lib/widgets/moveInteractiveControl/controlButton.js +1 -2
  47. package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.js +5 -16
  48. package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.less +4 -24
  49. package/lib/widgets/multiCamera/landscapeTip.js +2 -8
  50. package/lib/widgets/multiCamera/moveablePtzControl.js +3 -5
  51. package/lib/widgets/multiCamera/multiPtz.js +1 -2
  52. package/lib/widgets/multiCamera/ptzMoveableTip.js +2 -8
  53. package/lib/widgets/multiCamera/switchLayout.js +1 -2
  54. package/lib/widgets/multiCamera/tileMultiPtz.js +1 -2
  55. package/lib/widgets/multiCamera/tileSwitchLayout.js +1 -2
  56. package/lib/widgets/multiCamera/tileTip.js +2 -8
  57. package/lib/widgets/muted/muted.js +1 -2
  58. package/lib/widgets/muted/muted.test.js +52 -66
  59. package/lib/widgets/ptz/ptz.js +1 -2
  60. package/lib/widgets/ptz/ptzControl.js +3 -4
  61. package/lib/widgets/ptzControlTip/ptzControlTip.js +4 -9
  62. package/lib/widgets/ptzControlTip/ptzControlTip.less +0 -6
  63. package/lib/widgets/realTimeMagnification/realTimeMagnification.js +1 -2
  64. package/lib/widgets/recordVideo/recordVideo.js +169 -47
  65. package/lib/widgets/recordVideo/recordVideo.lifecycle.test.js +2 -4
  66. package/lib/widgets/recordVideo/recordVideo.test.js +2 -169
  67. package/lib/widgets/resolution/fullResolutionControl.js +19 -29
  68. package/lib/widgets/resolution/resolution.js +2 -3
  69. package/lib/widgets/screenshot/screenshot.js +122 -48
  70. package/lib/widgets/screenshot/screenshot.test.js +113 -108
  71. package/lib/widgets/signal4G/signal4G.js +1 -4
  72. package/lib/widgets/siren/siren.js +1 -2
  73. package/lib/widgets/tempHumidity/tempHumidity.js +1 -2
  74. package/lib/widgets/toggleVerticalFull/toggleVerticalFull.js +1 -2
  75. package/lib/widgets/trialBadge/index.js +3 -8
  76. package/lib/widgets/trialBadge/index.less +0 -24
  77. package/lib/widgets/tryExperience/tryExperience.js +1 -2
  78. package/lib/widgets/videoBitKBP/videoBitKBP.js +1 -2
  79. package/lib/widgets/voiceIntercom/voiceIntercom.js +81 -57
  80. package/lib/widgets/voiceIntercom/voiceIntercom.less +0 -35
  81. package/lib/widgets/zoomTurntable/turntable/index.d.ts +7 -5
  82. package/lib/widgets/zoomTurntable/turntable/index.js +1 -3
  83. package/lib/widgets/zoomTurntable/zoomTurntableDock.d.ts +3 -5
  84. package/lib/widgets/zoomTurntable/zoomTurntableDock.js +4 -4
  85. package/lib/widgets/zoomTurntable/zoomTurntableEntry.js +19 -32
  86. package/lib/widgets/zoomTurntable/zoomTurntableTip.js +3 -17
  87. package/package.json +7 -15
  88. package/lib/ctx/intercom.test.js +0 -85
  89. package/lib/renderer/capabilities.d.ts +0 -8
  90. package/lib/renderer/capabilities.js +0 -19
  91. package/lib/renderer/context.d.ts +0 -5
  92. package/lib/renderer/context.js +0 -6
  93. package/lib/renderer/directionControl.d.ts +0 -6
  94. package/lib/renderer/directionControl.js +0 -3
  95. package/lib/renderer/font-manifest.json +0 -9
  96. package/lib/renderer/font.less +0 -5
  97. package/lib/renderer/glyphs.d.ts +0 -1
  98. package/lib/renderer/glyphs.js +0 -256
  99. package/lib/renderer/index.module.less +0 -48
  100. package/lib/renderer/overlay.d.ts +0 -6
  101. package/lib/renderer/overlay.js +0 -18
  102. package/lib/renderer/ptzZoom.d.ts +0 -6
  103. package/lib/renderer/ptzZoom.js +0 -3
  104. package/lib/renderer/text.d.ts +0 -4
  105. package/lib/renderer/text.js +0 -32
  106. package/lib/renderer/text.module.less +0 -4
  107. package/lib/renderer/viewport.d.ts +0 -7
  108. package/lib/renderer/viewport.js +0 -24
  109. package/lib/res/lynx-signal/index.d.ts +0 -1
  110. package/lib/res/lynx-signal/index.js +0 -22
  111. package/lib/res/lynx-signal/signalFour0.png +0 -0
  112. package/lib/res/lynx-signal/signalFour1.png +0 -0
  113. package/lib/res/lynx-signal/signalFour2.png +0 -0
  114. package/lib/res/lynx-signal/signalFour3.png +0 -0
  115. package/lib/res/lynx-signal/signalFour4.png +0 -0
  116. package/lib/res/lynx-signal/signalThree0.png +0 -0
  117. package/lib/res/lynx-signal/signalThree1.png +0 -0
  118. package/lib/res/lynx-signal/signalThree2.png +0 -0
  119. package/lib/res/lynx-signal/signalThree3.png +0 -0
  120. package/lib/res/player-charging.png +0 -0
  121. package/lib/res/player-more-arrow.png +0 -0
  122. package/lib/res/player-solar.png +0 -0
  123. package/lib/ui/scrollHintArrow.d.ts +0 -23
  124. package/lib/ui/scrollHintArrow.js +0 -83
  125. package/lib/widgets/battery/statusIcon.d.ts +0 -6
  126. package/lib/widgets/battery/statusIcon.js +0 -36
  127. package/lib/widgets/battery/statusIcon.less +0 -24
  128. package/lib/widgets/captureToast/captureToast.d.ts +0 -10
  129. package/lib/widgets/captureToast/captureToast.js +0 -58
  130. package/lib/widgets/recordVideo/recordVideoTimer.d.ts +0 -3
  131. package/lib/widgets/recordVideo/recordVideoTimer.js +0 -26
  132. package/lib/widgets/screenshot/screenshot.permissions.test.js +0 -137
  133. package/lib/widgets/voiceIntercom/voiceIntercom.test.js +0 -135
  134. package/lib/widgets/zoomTurntable/lynxDockLayout.d.ts +0 -6
  135. package/lib/widgets/zoomTurntable/lynxDockLayout.js +0 -30
  136. package/lib/widgets/zoomTurntable/turntable/lynx.d.ts +0 -5
  137. package/lib/widgets/zoomTurntable/turntable/lynx.js +0 -273
  138. package/lib/widgets/zoomTurntable/turntable/lynx.less +0 -9
  139. package/lib/widgets/zoomTurntable/turntable/lynxModel.d.ts +0 -37
  140. package/lib/widgets/zoomTurntable/turntable/lynxModel.js +0 -122
  141. package/lib/widgets/zoomTurntable/turntable/lynxPaint.d.ts +0 -3
  142. package/lib/widgets/zoomTurntable/turntable/lynxPaint.js +0 -36
  143. /package/lib/{ctx/intercom.test.d.ts → ui/bottomControlLayout.test.d.ts} +0 -0
  144. /package/lib/{widgets/screenshot/screenshot.permissions.test.d.ts → ui/bottomLeftContent.test.d.ts} +0 -0
  145. /package/lib/{widgets/voiceIntercom/voiceIntercom.test.d.ts → ui/bottomRightContent.test.d.ts} +0 -0
@@ -1,4 +1,3 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
2
  import "core-js/modules/esnext.iterator.constructor.js";
4
3
  import "core-js/modules/esnext.iterator.every.js";
@@ -7,11 +6,8 @@ import "core-js/modules/esnext.iterator.find.js";
7
6
  import "core-js/modules/esnext.iterator.map.js";
8
7
  import "core-js/modules/esnext.iterator.reduce.js";
9
8
  import React, { useEffect, useMemo, useRef, useState } from 'react';
10
- import { ScrollView, View, getSystemInfoSync } from '@ray-js/ray';
9
+ import { CoverView, ScrollView, View } from '@ray-js/ray';
11
10
  import clsx from 'clsx';
12
- import { usePlayerOverlayHost } from '../renderer/overlay';
13
- import { ScrollHintArrow, ScrollHintButton, usesNativeHintImage, getHintViewport } from './scrollHintArrow';
14
- import { usePlayerRenderMode } from '../renderer/context';
15
11
  import { useStore } from '../ctx/store';
16
12
  import { useComponentHideState } from './hooks';
17
13
  import { getBottomCoverHeight } from './bottomCoverHeight';
@@ -28,17 +24,10 @@ const VERTICAL_FLAT_MAX = 4;
28
24
  // 这段同时也是箭头的落位区 —— 箭头贴着内容压在第 5 项露出的一角上(和改动前的观感一致),
29
25
  // 因此至少要放得下箭头本体 26 + 左右各 4 的间隙。
30
26
  const VERTICAL_PEEK_WIDTH = 34;
31
- const VERTICAL_HINT_EDGE_GAP = 4;
32
27
 
33
28
  // 平铺档内容与右下角按钮之间的最小安全间距
34
29
  const VERTICAL_FLAT_SAFE_GAP = 8;
35
30
 
36
- // 收紧态(.ipc-player-bottom-left-content-container-tight)下每项省下的宽度:
37
- // 竖屏 item 左右 padding 由 12px 收到 10px,中间项左右各省 2px;
38
- // 首项只省右侧 2px —— 左侧 16px 是内容起始留白,要和其余三个角落对齐,不能动。
39
- const TIGHT_SAVE_FIRST = 2;
40
- const TIGHT_SAVE_OTHER = 4;
41
-
42
31
  // 左下角子元素统一类名(由 ui.tsx 渲染时挂上),用于 selectAll 逐项测量
43
32
  const ITEM_CLASS = 'bottom-left-item-container';
44
33
  const BottomLeftContent = _ref => {
@@ -49,7 +38,6 @@ const BottomLeftContent = _ref => {
49
38
  canOpenSettings = true,
50
39
  scrollHintMode = 'button'
51
40
  } = _ref;
52
- const OverlayView = usePlayerOverlayHost();
53
41
  const {
54
42
  screenType,
55
43
  isVerticalFullLayout,
@@ -88,11 +76,6 @@ const BottomLeftContent = _ref => {
88
76
  const tryExp = bottomLeftContent === null || bottomLeftContent === void 0 ? void 0 : bottomLeftContent.find(item => item.id === 'TryExperience');
89
77
  return (_gRawData = tryExp === null || tryExp === void 0 || (_tryExp$initProps5 = tryExp.initProps) === null || _tryExp$initProps5 === void 0 ? void 0 : _tryExp$initProps5.gRawData) !== null && _gRawData !== void 0 ? _gRawData : false;
90
78
  }, [bottomLeftContent]);
91
- const renderMode = usePlayerRenderMode();
92
- const hintPlatform = useMemo(() => {
93
- var _getSystemInfoSync;
94
- return renderMode === 'lynx' ? ((_getSystemInfoSync = getSystemInfoSync()) === null || _getSystemInfoSync === void 0 ? void 0 : _getSystemInfoSync.platform) || '' : '';
95
- }, [renderMode]);
96
79
  const [shouldHide] = useComponentHideState();
97
80
  const {
98
81
  showTrialBadge,
@@ -101,7 +84,7 @@ const BottomLeftContent = _ref => {
101
84
  handleCountdownEnd
102
85
  } = useTrialBadge(ctx.event, ctx.devId, trialRemainingSec, ctx.trialBadgeViewedRef, ctx.trialBadgeRtidRef);
103
86
 
104
- // 横向滚动状态:右侧仍有内容时显示右箭头提示
87
+ // 横向滚动状态:内容溢出且未滑到对应边缘时,显示左 / 右箭头提示
105
88
  const idRef = useRef(++scrollClsSeq);
106
89
  // wrap 是左下角的可用区(left:0 ~ right:reservedRight),宽度不随 ScrollView 收窄而变,
107
90
  // 因此用它、而不是 ScrollView 自身,作为“能摆多宽”的基准,避免收窄与分档互相依赖
@@ -122,8 +105,6 @@ const BottomLeftContent = _ref => {
122
105
  // 点击箭头时的受控滚动目标;仅在程序化滚动期间为数值,结束后置回 undefined,
123
106
  // 避免持续受控导致用户手动拖动被回弹
124
107
  const [scrollTo, setScrollTo] = useState(undefined);
125
- const [lynxAtEnd, setLynxAtEnd] = useState(false);
126
- const endPageTouchRef = useRef(null);
127
108
  // 横竖屏切换后,强制 ScrollView 重新挂载并把滚动状态重置为初始值
128
109
  const [scrollResetKey, setScrollResetKey] = useState(0);
129
110
  // 用户在某种屏幕模式下拖动过一次之后,该模式不再展示箭头(竖屏 / 横屏各自独立记录)
@@ -136,29 +117,21 @@ const BottomLeftContent = _ref => {
136
117
  // 这类变化 bottomLeftContent.length 捕获不到,由 widget 主动 emit。
137
118
  const [resizeSignal, setResizeSignal] = useState(0);
138
119
 
139
- // 是否收紧 item 间距(窄屏专用,判定见下方 useEffect)。
140
- // 只升不降:收紧后各项变窄 → 重测 → 可能又判成“放得下”→ 取消收紧 → 又放不下,
141
- // 那就是一个自激振荡。锁存住,只在横竖屏切换时随其余测量值一起清零。
142
- const [tightened, setTightened] = useState(false);
143
-
144
120
  // 滑动期间暂停整体的自动隐藏,滑动停止后再恢复(无原生 scrollend,用防抖判定结束)
145
121
  const scrollingRef = useRef(false);
146
122
  const scrollEndTimerRef = useRef();
147
123
  // 测量时需要叠加当前滚动量,用 ref 避免闭包拿到过期值
148
124
  const scrollLeftRef = useRef(0);
149
- const pageOffsetRef = useRef(0);
150
125
  useEffect(() => {
151
126
  setScrollResetKey(k => k + 1);
152
127
  setScrollLeft(0);
153
128
  setScrollTo(undefined);
154
- setLynxAtEnd(false);
155
129
  scrollLeftRef.current = 0;
156
130
  // 清零上一屏的测量值,避免用旧 clientWidth/contentWidth 在重新测量前误判溢出导致箭头闪现
157
131
  setClientWidth(0);
158
132
  setContentWidth(0);
159
133
  setWrapWidth(0);
160
134
  setItemWidths([]);
161
- setTightened(false);
162
135
  }, [screenType]);
163
136
 
164
137
  // 程序化滚动目标只在动画期间短暂受控,之后释放为非受控,避免回弹影响手动拖动
@@ -211,36 +184,6 @@ const BottomLeftContent = _ref => {
211
184
  if (want > availableWidth) return 0;
212
185
  return want;
213
186
  })();
214
- /**
215
- * 收紧后前 4 项能省下多少(估算:按每项的 padding 差值累加)。
216
- * 逐项宽是实测值,收紧后的真实宽度未必精确等于这个差值,作为“够不够”的预判足够。
217
- */
218
- const tightenSaving = (() => {
219
- const n = Math.min(measuredCount, VERTICAL_FLAT_MAX);
220
- if (n <= 0) return 0;
221
- return TIGHT_SAVE_FIRST + TIGHT_SAVE_OTHER * (n - 1);
222
- })();
223
-
224
- /**
225
- * 是否要把 item 间距从 12px 收到 10px。
226
- *
227
- * 两头都不收:
228
- * - **本来就放得下**(宽屏):不动,保持 12px 的宽松间距 —— 不为个别窄屏机型
229
- * 让全量机型的图标挤在一起;
230
- * - **收紧了也放不下**(更窄的屏 / 3 镜头的转盘胶囊):白挤一遍换不回箭头的
231
- * 专属落位区,不如保住观感,让箭头压在第 4 项右缘上(见下方 hasArrowRoom)。
232
- *
233
- * 只有“差一点、收紧刚好够”这一段才收 —— 这正是真机上遇到的那一档。
234
- */
235
- useEffect(() => {
236
- if (tightened) return;
237
- if (!isScrollMode || measuredCount === 0 || !(availableWidth > 0)) return;
238
- const want = firstFourWidth + VERTICAL_PEEK_WIDTH;
239
- if (want <= availableWidth) return;
240
- if (want - tightenSaving > availableWidth) return;
241
- setTightened(true);
242
- }, [tightened, isScrollMode, measuredCount, availableWidth, firstFourWidth, tightenSaving]);
243
-
244
187
  /**
245
188
  * 竖屏 scroll 档一律出箭头。
246
189
  *
@@ -312,7 +255,7 @@ const BottomLeftContent = _ref => {
312
255
  // 这样即使内容容器被撑满到可视内盒宽,也能拿到真实内容宽;哨兵不可用时回退到容器宽。
313
256
  let tw = 0;
314
257
  if (scrollRect && endRect && typeof endRect.left === 'number') {
315
- tw = endRect.left - scrollRect.left - paddingLeftPx + scrollLeftRef.current + pageOffsetRef.current;
258
+ tw = endRect.left - scrollRect.left - paddingLeftPx + scrollLeftRef.current;
316
259
  }
317
260
  if (!(tw > 0)) {
318
261
  tw = (contentRect === null || contentRect === void 0 ? void 0 : contentRect.width) || 0;
@@ -321,11 +264,11 @@ const BottomLeftContent = _ref => {
321
264
  setContentWidth(tw);
322
265
  }
323
266
  attempts += 1;
324
- // Lynx 首轮加密测量以尽快收敛,WebView 保持原有 400ms/15 次节奏。
325
- if (attempts >= (renderMode === 'lynx' ? 20 : 15)) {
267
+ // 最多轮询 15 次(约 6s)兜底,避免无限轮询
268
+ if (attempts >= 15) {
326
269
  return;
327
270
  }
328
- timer = setTimeout(measure, renderMode === 'lynx' && attempts < 8 ? 150 : 400);
271
+ timer = setTimeout(measure, 400);
329
272
  });
330
273
  };
331
274
 
@@ -339,9 +282,7 @@ const BottomLeftContent = _ref => {
339
282
  // reservedRight 决定 ScrollView 可视宽度(右下角内容异步加载后会从 0 变为实际宽度)
340
283
  reservedRight,
341
284
  // playState:视频就绪后 overlay 可能重新布局,需重新测量
342
- playState, bottomLeftContent === null || bottomLeftContent === void 0 ? void 0 : bottomLeftContent.length, shouldHide, showBadge, wrapCls, scrollCls, contentCls, scrollResetKey, resizeSignal,
343
- // 收紧后各项 padding 变小,必须重测一遍逐项宽,否则分档还在用收紧前的旧值
344
- tightened, renderMode]);
285
+ playState, bottomLeftContent === null || bottomLeftContent === void 0 ? void 0 : bottomLeftContent.length, shouldHide, showBadge, wrapCls, scrollCls, contentCls, scrollResetKey, resizeSignal]);
345
286
 
346
287
  // 子元素主动上报宽度变化 → 重跑测量,及时更新横滑箭头与右边缘淡出
347
288
  useEffect(() => {
@@ -371,37 +312,20 @@ const BottomLeftContent = _ref => {
371
312
  const totalContentWidth = naturalWidth > 0 ? paddingLeftPx + naturalWidth + paddingRightPx : 0;
372
313
  // 竖屏由“个数”决定是否溢出(平铺档恒不溢出);横屏保持原来的像素比对
373
314
  const isOverflow = isVertical ? !isFlat : totalContentWidth > clientWidth + 1;
374
- const isButtonHint = scrollHintMode === 'button';
375
- const hintSize = isButtonHint ? 26 : 16;
376
- // Once the end is reached there is no hint to mask: restore the WebView layout budget.
377
-
378
- const hintViewport = getHintViewport(renderMode, hintPlatform, isScrollMode, verticalScrollWidth, usesNativeHintImage(renderMode, hintPlatform) ? availableWidth : clientWidth, hintSize, VERTICAL_HINT_EDGE_GAP, lynxAtEnd);
379
- const scrollViewWidth = hintViewport.visibleWidth;
380
- const atEnd = lynxAtEnd || !isOverflow || scrollLeft + scrollViewWidth >= totalContentWidth - 2;
381
- // Lynx 不响应 ScrollView 的受控 scrollLeft / scrollIntoView,点击时平移现有内容。
382
- // 保留原节点;末页通过右滑返回,不增加 WebView 没有的反向箭头。
383
- const pageOffset = renderMode === 'lynx' && lynxAtEnd ? Math.max(0, totalContentWidth - scrollViewWidth - scrollLeft) : 0;
384
- pageOffsetRef.current = pageOffset;
315
+ const scrollViewWidth = verticalScrollWidth > 0 ? verticalScrollWidth : clientWidth;
316
+ const atEnd = !isOverflow || scrollLeft + scrollViewWidth >= totalContentWidth - 2;
385
317
  const isDismissed = dismissed[screenType];
318
+ const isButtonHint = scrollHintMode === 'button';
386
319
  // button 模式:溢出且未到末端即常显(不受 dismissed 影响);pulse 模式:保留拖动后消失的旧逻辑。
387
320
  // compact 档(<= 4 个但摆不下)不出箭头:那点空间要留给元素本身,箭头只会遮更多
321
+ const showRightHint = isOverflow && !atEnd && !isCompact && (!isVertical || isScrollMode) && (isButtonHint || !isDismissed);
388
322
 
389
323
  // 右侧还有未滚到头的内容时,启用右边缘淡出,把没完全露出的元素渐隐隐藏(横竖屏都生效)
390
324
  const fadeRightEdge = isOverflow && !atEnd;
391
325
 
392
- // Lynx 用子节点 id 定位末端:其受控 scrollLeft 属性不会可靠地驱动原生横滑。
393
- // WebView 仍以有限的实际最大偏移滚动。
326
+ // 点击右箭头:直接滚动到最右端。
327
+ // 给一个足够大的目标值,交由 ScrollView 自身夹取到真实最右端,避免测量误差导致滚不到底。
394
328
 
395
- const readTouch = event => {
396
- var _event$touches, _event$changedTouches, _event$origin, _event$origin2, _touch$clientX, _touch$clientY;
397
- const touch = (event === null || event === void 0 || (_event$touches = event.touches) === null || _event$touches === void 0 ? void 0 : _event$touches[0]) || (event === null || event === void 0 || (_event$changedTouches = event.changedTouches) === null || _event$changedTouches === void 0 ? void 0 : _event$changedTouches[0]) || (event === null || event === void 0 || (_event$origin = event.origin) === null || _event$origin === void 0 || (_event$origin = _event$origin.touches) === null || _event$origin === void 0 ? void 0 : _event$origin[0]) || (event === null || event === void 0 || (_event$origin2 = event.origin) === null || _event$origin2 === void 0 || (_event$origin2 = _event$origin2.changedTouches) === null || _event$origin2 === void 0 ? void 0 : _event$origin2[0]);
398
- const x = (_touch$clientX = touch === null || touch === void 0 ? void 0 : touch.clientX) !== null && _touch$clientX !== void 0 ? _touch$clientX : touch === null || touch === void 0 ? void 0 : touch.pageX;
399
- const y = (_touch$clientY = touch === null || touch === void 0 ? void 0 : touch.clientY) !== null && _touch$clientY !== void 0 ? _touch$clientY : touch === null || touch === void 0 ? void 0 : touch.pageY;
400
- return typeof x === 'number' && typeof y === 'number' ? {
401
- x,
402
- y
403
- } : null;
404
- };
405
329
  const coverHeight = getBottomCoverHeight(screenType, isVerticalFullLayout, shouldHide);
406
330
  const containerHeight = screenType === 'vertical' ? 48 : 58;
407
331
 
@@ -414,33 +338,30 @@ const BottomLeftContent = _ref => {
414
338
  // 竖屏: 0 + 24 = 24 → bottom = 16
415
339
  // 横屏: 25 + 16.5 = 41.5 → bottom = 33.5
416
340
  const visibleRowHeight = containerHeight - paddingBottomPx;
417
-
418
341
  // button 模式用半透明圆做点击热区,比 pulse 提示大;下移半个差值以保持图标中心不变
419
-
342
+ const hintSize = isButtonHint ? 26 : 16;
420
343
  // 竖屏:箭头贴着可视区右缘、压在第 5 项露出的那一角上(改动前就是这个观感)。
421
344
  // 箭头右缘距可视区右缘 4px => right = 可用宽 - 可视宽 + 4
422
345
  // 可视宽是“前 4 项 + 34 露出区”,箭头宽 26,因此箭头左缘落在第 4 项之后 4px,碰不到它。
423
346
  // 横屏维持原来的 6px
424
347
  const hintRight = (() => {
425
348
  if (!isVertical) return 6;
426
- if (!(availableWidth > 0) || !(hintViewport.layoutWidth > 0)) return VERTICAL_HINT_EDGE_GAP;
427
- return Math.max(availableWidth - hintViewport.layoutWidth + VERTICAL_HINT_EDGE_GAP, VERTICAL_HINT_EDGE_GAP);
349
+ if (!(availableWidth > 0) || !(scrollViewWidth > 0)) return 4;
350
+ return Math.max(availableWidth - scrollViewWidth + 4, 4);
428
351
  })();
429
- return /*#__PURE__*/React.createElement(OverlayView, {
352
+ return /*#__PURE__*/React.createElement(CoverView, {
430
353
  className: clsx('ipc-player-bottom-left-content-wrap', wrapCls),
431
- style: _objectSpread(_objectSpread({
354
+ style: {
432
355
  right: rightCss,
433
356
  height: showBadge ? `${coverHeight + 30}px` : `${coverHeight}px`,
434
357
  boxSizing: 'border-box',
358
+ overflow: 'hidden',
435
359
  display: 'flex',
436
360
  flexDirection: 'column',
437
361
  justifyContent: 'flex-start',
438
- opacity: shouldHide ? 0 : 1
439
- }, renderMode === 'lynx' ? {
440
- transition: 'opacity 0.3s ease'
441
- } : {}), {}, {
362
+ opacity: shouldHide ? 0 : 1,
442
363
  pointerEvents: shouldHide ? 'none' : 'auto'
443
- })
364
+ }
444
365
  }, showBadge && /*#__PURE__*/React.createElement(View, {
445
366
  style: {
446
367
  height: '32px',
@@ -454,14 +375,26 @@ const BottomLeftContent = _ref => {
454
375
  trialRemainingSec: trialRemainingSec,
455
376
  onSubscribe: handleTrialSubscribe,
456
377
  onCountdownEnd: handleCountdownEnd
457
- })), /*#__PURE__*/React.createElement(ScrollView, _extends({
378
+ })), /*#__PURE__*/React.createElement(View, {
379
+ className: clsx('ipc-player-bottom-left-scroll-viewport', {
380
+ 'ipc-player-bottom-left-scroll-fademask': fadeRightEdge,
381
+ 'ipc-player-bottom-left-scroll-fademask--narrow': fadeRightEdge && isScrollMode,
382
+ 'ipc-player-bottom-left-scroll-fademask--arrow': fadeRightEdge && showRightHint
383
+ }),
384
+ style: {
385
+ width: verticalScrollWidth > 0 ? `${verticalScrollWidth}px` : '100%',
386
+ height: `${containerHeight}px`,
387
+ position: 'relative',
388
+ top: `${coverHeight - containerHeight}px`,
389
+ marginTop: showBadge ? '-2px' : 0,
390
+ overflow: 'hidden',
391
+ flexShrink: 0
392
+ }
393
+ }, /*#__PURE__*/React.createElement(ScrollView, {
458
394
  key: scrollResetKey,
459
- scrollX: renderMode !== 'lynx' || !lynxAtEnd,
395
+ scrollX: true,
460
396
  scrollLeft: scrollTo,
461
- scrollWithAnimation: true
462
- }, usesNativeHintImage(renderMode, hintPlatform) ? {
463
- bounces: false
464
- } : {}, {
397
+ scrollWithAnimation: true,
465
398
  onScroll: e => {
466
399
  var _e$detail;
467
400
  // 滑动开始时暂停自动隐藏(仅在一次滑动会话内触发一次),滑动停止后恢复
@@ -482,13 +415,8 @@ const BottomLeftContent = _ref => {
482
415
  // Ray ScrollView 在不同实现下,scrollLeft 可能直接挂在事件上,也可能在 detail 内
483
416
  const sl = typeof (e === null || e === void 0 ? void 0 : e.scrollLeft) === 'number' ? e.scrollLeft : e === null || e === void 0 || (_e$detail = e.detail) === null || _e$detail === void 0 ? void 0 : _e$detail.scrollLeft;
484
417
  if (typeof sl === 'number') {
485
- // Android's boundary events can overshoot the range; never use elastic offsets as page state.
486
- const nextScrollLeft = usesNativeHintImage(renderMode, hintPlatform) ? Math.max(0, Math.min(sl, Math.max(0, totalContentWidth - clientWidth))) : sl;
487
- scrollLeftRef.current = nextScrollLeft;
488
- setScrollLeft(nextScrollLeft);
489
- if (usesNativeHintImage(renderMode, hintPlatform) && isScrollMode && !lynxAtEnd && nextScrollLeft > 0 && clientWidth > 0 && nextScrollLeft + clientWidth >= totalContentWidth - 2) {
490
- setLynxAtEnd(true);
491
- }
418
+ scrollLeftRef.current = sl;
419
+ setScrollLeft(sl);
492
420
  // 一旦真的拖动过(>2px 阈值过滤抖动 / 重置触发的 0 值),当前屏幕模式下不再展示箭头
493
421
  if (sl > 2 && !dismissed[screenType]) {
494
422
  setDismissed(d => _objectSpread(_objectSpread({}, d), {}, {
@@ -497,55 +425,24 @@ const BottomLeftContent = _ref => {
497
425
  }
498
426
  }
499
427
  },
500
- className: clsx(scrollCls, {
501
- 'ipc-player-bottom-left-scroll-fademask': fadeRightEdge,
502
- // 竖屏 scroll 档一律用窄渐变(34px,只覆盖箭头那块)。
503
- // 原条件是「锁宽成功」,可没锁宽时可视区右缘同样压着第 4 项,
504
- // 72px 的宽渐变会把宽 widget(转盘胶囊约 100px)淡掉一大半。
505
- // 横屏 isScrollMode 恒为 false,仍走 72px 宽渐变,行为不变。
506
- 'ipc-player-bottom-left-scroll-fademask--narrow': fadeRightEdge && isScrollMode
507
- }),
508
- style: _objectSpread(_objectSpread({
428
+ className: scrollCls,
429
+ style: {
509
430
  paddingBottom: `${paddingBottomPx}px`,
510
431
  paddingLeft: `${paddingLeftPx}px`,
511
432
  paddingRight: `${paddingRightPx}px`,
512
- width: hintViewport.width
513
- }, usesNativeHintImage(renderMode, hintPlatform) && isScrollMode ? {
514
- clipPath: 'none'
515
- } : {}), {}, {
516
- height: `${containerHeight}px`,
517
- position: 'relative',
518
- top: `${coverHeight - containerHeight}px`,
519
- marginTop: showBadge ? '-2px' : 0,
433
+ width: '100%',
434
+ height: '100%',
520
435
  whiteSpace: 'nowrap'
521
- })
522
- }), /*#__PURE__*/React.createElement(View, {
523
- onTouchStart: renderMode === 'lynx' ? event => {
524
- endPageTouchRef.current = renderMode === 'lynx' && lynxAtEnd ? readTouch(event) : null;
525
- } : undefined,
526
- onTouchEnd: renderMode === 'lynx' ? event => {
527
- const start = endPageTouchRef.current;
528
- const end = readTouch(event);
529
- endPageTouchRef.current = null;
530
- if (!start || !end || renderMode !== 'lynx' || !lynxAtEnd) return;
531
- const dx = end.x - start.x;
532
- if (dx > 24 && dx > Math.abs(end.y - start.y)) setLynxAtEnd(false);
533
- } : undefined,
534
- onTouchCancel: () => {
535
- endPageTouchRef.current = null;
536
- },
537
- className: clsx('ipc-player-bottom-left-content-container', contentCls, {
538
- 'ipc-player-bottom-left-content-container-tight': tightened
539
- }),
540
- style: _objectSpread({
541
- display: renderMode === 'lynx' ? 'flex' : 'inline-flex',
436
+ }
437
+ }, /*#__PURE__*/React.createElement(View, {
438
+ className: clsx('ipc-player-bottom-left-content-container', contentCls),
439
+ style: {
440
+ display: 'inline-flex',
542
441
  flexDirection: 'row',
543
442
  height: `${visibleRowHeight}px`,
544
443
  alignItems: 'center',
545
444
  paddingLeft: `${contentPaddingLeftPx}px`
546
- }, pageOffset > 0 ? {
547
- transform: `translateX(-${pageOffset}px)`
548
- } : {})
445
+ }
549
446
  }, children, /*#__PURE__*/React.createElement(View, {
550
447
  className: endCls,
551
448
  style: {
@@ -553,26 +450,11 @@ const BottomLeftContent = _ref => {
553
450
  height: '1px',
554
451
  flexShrink: 0
555
452
  }
556
- }))), isOverflow && !atEnd && !isCompact && (!isVertical || isScrollMode) && (isButtonHint || !isDismissed) && /*#__PURE__*/React.createElement(ScrollHintButton, {
557
- renderMode: renderMode,
558
- platform: hintPlatform,
559
- onPress: isButtonHint ? () => {
560
- if (!isOverflow) {
561
- return;
562
- }
563
- if (renderMode === 'lynx') {
564
- var _ctx$event6, _ctx$event7;
565
- (_ctx$event6 = ctx.event) === null || _ctx$event6 === void 0 || _ctx$event6.emit(pauseTimeToHideAllComponent);
566
- setLynxAtEnd(true);
567
- (_ctx$event7 = ctx.event) === null || _ctx$event7 === void 0 || _ctx$event7.emit(startTimeToHideAllComponent);
568
- return;
569
- }
570
- setScrollTo(Math.max(0, Math.ceil(totalContentWidth - scrollViewWidth)));
571
- } : undefined,
453
+ })))), showRightHint && /*#__PURE__*/React.createElement(CoverView, {
572
454
  className: clsx('ipc-player-bottom-left-scroll-hint', {
573
455
  'ipc-player-bottom-left-scroll-hint--button': isButtonHint
574
456
  }),
575
- style: _objectSpread({
457
+ style: {
576
458
  position: 'absolute',
577
459
  right: `${hintRight}px`,
578
460
  bottom: `${paddingBottomPx + visibleRowHeight / 2 - 8 - (hintSize - 16) / 2}px`,
@@ -582,15 +464,26 @@ const BottomLeftContent = _ref => {
582
464
  alignItems: 'center',
583
465
  justifyContent: 'center',
584
466
  pointerEvents: isButtonHint ? 'auto' : 'none'
585
- }, usesNativeHintImage(renderMode, hintPlatform) && isButtonHint ? {
586
- backgroundColor: 'rgba(0, 0, 0, 0.45)',
587
- backgroundImage: 'none',
588
- borderRadius: '50%'
589
- } : {})
590
- }, /*#__PURE__*/React.createElement(ScrollHintArrow, {
591
- renderMode: renderMode,
592
- platform: hintPlatform,
593
- button: isButtonHint
467
+ },
468
+ onClick: isButtonHint ? () => {
469
+ if (!isOverflow) {
470
+ return;
471
+ }
472
+ setScrollTo(totalContentWidth + clientWidth + 9999);
473
+ } : undefined
474
+ }, /*#__PURE__*/React.createElement(View, {
475
+ className: clsx('ipc-player-bottom-left-scroll-hint-arrow', {
476
+ 'ipc-player-bottom-left-scroll-hint-arrow--right': true,
477
+ 'ipc-player-bottom-left-scroll-hint-arrow--light': isButtonHint,
478
+ 'ipc-player-bottom-left-scroll-hint-arrow--static': isButtonHint
479
+ })
480
+ // 右向 chevron 由 top+right 描边旋转而成,视觉重心偏右;放大并整体左移使其在圆内居中
481
+ ,
482
+ style: isButtonHint ? {
483
+ width: '9px',
484
+ height: '9px',
485
+ transform: 'translate(-1px, 0) rotate(45deg)'
486
+ } : undefined
594
487
  })));
595
488
  };
596
489
  export default BottomLeftContent;
@@ -0,0 +1,138 @@
1
+ import "core-js/modules/esnext.iterator.constructor.js";
2
+ import "core-js/modules/esnext.iterator.map.js";
3
+ import "core-js/modules/esnext.iterator.reduce.js";
4
+ import React from 'react';
5
+ import ReactDOM from 'react-dom';
6
+ import { act, Simulate } from 'react-dom/test-utils';
7
+ import { atom } from 'jotai';
8
+ import BottomLeftContent from './bottomLeftContent';
9
+ jest.mock('@ray-js/ray', () => {
10
+ const React = require('react');
11
+ return {
12
+ View: 'div',
13
+ CoverView: 'div',
14
+ ScrollView: _ref => {
15
+ let {
16
+ children,
17
+ onScroll,
18
+ className,
19
+ style
20
+ } = _ref;
21
+ return React.createElement('div', {
22
+ onScroll,
23
+ className,
24
+ style
25
+ }, children);
26
+ }
27
+ };
28
+ });
29
+ jest.mock('./hooks', () => ({
30
+ useComponentHideState: () => [false]
31
+ }));
32
+ jest.mock('../widgets/trialBadge', () => ({
33
+ TrialBadge: () => null,
34
+ useTrialBadge: () => ({
35
+ showTrialBadge: false
36
+ })
37
+ }));
38
+ describe('left toolbar fade', () => {
39
+ let container;
40
+ let widths;
41
+ let available;
42
+ beforeEach(() => {
43
+ jest.useFakeTimers();
44
+ container = document.createElement('div');
45
+ document.body.appendChild(container);
46
+ widths = [49, 45, 44, 56, 55];
47
+ available = 204;
48
+ global.ty = {
49
+ createSelectorQuery: () => {
50
+ const query = {
51
+ select: () => query,
52
+ selectAll: () => query,
53
+ boundingClientRect: () => query,
54
+ exec: cb => {
55
+ const total = widths.reduce((a, b) => a + b, 0);
56
+ cb([{
57
+ width: available
58
+ }, {
59
+ left: 0,
60
+ width: available
61
+ }, {
62
+ width: total
63
+ }, {
64
+ left: total
65
+ }, widths.map(width => ({
66
+ width
67
+ }))]);
68
+ }
69
+ };
70
+ return query;
71
+ }
72
+ };
73
+ });
74
+ afterEach(() => {
75
+ act(() => {
76
+ ReactDOM.unmountComponentAtNode(container);
77
+ });
78
+ container.remove();
79
+ jest.clearAllTimers();
80
+ jest.useRealTimers();
81
+ });
82
+ const render = () => {
83
+ const ctx = {
84
+ devId: 'camera',
85
+ screenType: atom('vertical'),
86
+ isVerticalFullLayout: atom(false),
87
+ playState: atom(1),
88
+ brandColor: atom('#0085ff'),
89
+ bottomLeftContent: atom([]),
90
+ event: {
91
+ on: jest.fn(),
92
+ off: jest.fn(),
93
+ emit: jest.fn()
94
+ }
95
+ };
96
+ act(() => {
97
+ ReactDOM.render(/*#__PURE__*/React.createElement(BottomLeftContent, {
98
+ ctx: ctx,
99
+ reservedRight: 171
100
+ }, widths.map((width, i) => /*#__PURE__*/React.createElement("div", {
101
+ className: "bottom-left-item-container",
102
+ key: width
103
+ }, i))), container);
104
+ });
105
+ act(() => {
106
+ jest.advanceTimersByTime(60);
107
+ });
108
+ };
109
+ it('fades clipped content in a fixed viewport while keeping the arrow outside the mask', () => {
110
+ render();
111
+ const viewport = container.querySelector('.ipc-player-bottom-left-scroll-viewport');
112
+ const arrow = container.querySelector('.ipc-player-bottom-left-scroll-hint');
113
+ expect(viewport.classList.contains('ipc-player-bottom-left-scroll-fademask--arrow')).toBe(true);
114
+ expect(viewport.style.overflow).toBe('hidden');
115
+ expect(arrow).not.toBeNull();
116
+ expect(viewport.contains(arrow)).toBe(false);
117
+ const scroll = viewport.firstElementChild;
118
+ expect(scroll.classList.contains('ipc-player-bottom-left-scroll-fademask')).toBe(false);
119
+ });
120
+ it('removes both the fade and arrow after scrolling to the final item', () => {
121
+ render();
122
+ const scroll = container.querySelector('.ipc-player-bottom-left-scroll-viewport').firstElementChild;
123
+ act(() => {
124
+ Simulate.scroll(scroll, {
125
+ scrollLeft: 999
126
+ });
127
+ });
128
+ expect(container.querySelector('.ipc-player-bottom-left-scroll-fademask')).toBeNull();
129
+ expect(container.querySelector('.ipc-player-bottom-left-scroll-hint')).toBeNull();
130
+ });
131
+ it('leaves a toolbar that fits completely opaque', () => {
132
+ widths = [49, 45, 44, 56];
133
+ available = 280;
134
+ render();
135
+ expect(container.querySelector('.ipc-player-bottom-left-scroll-fademask')).toBeNull();
136
+ expect(container.querySelector('.ipc-player-bottom-left-scroll-hint')).toBeNull();
137
+ });
138
+ });
@@ -10,10 +10,10 @@ type Props = {
10
10
  */
11
11
  width?: number | string;
12
12
  /**
13
- * 右下角实际渲染宽度的上报回调(竖屏用)。
13
+ * 右下角实际可见按钮占用宽度的上报回调(横竖屏通用)。
14
14
  * 左下角据此决定自己能摆多宽 —— 右边挂几个功能都能自动让位,不再靠固定常量拍脑袋。
15
15
  */
16
- onWidthChange?: (width: number) => void;
16
+ onWidthChange?: (width: number | null) => void;
17
17
  };
18
18
  declare const BottomRightContent: ({ ctx, children, width, onWidthChange }: Props) => React.JSX.Element;
19
19
  export default BottomRightContent;