@ray-js/ipc-player-integration 0.0.67-beta.0 → 0.0.67-beta.2

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.
package/lib/ctx/ctx.js CHANGED
@@ -47,6 +47,7 @@ export const createUseCtx = _ref => {
47
47
  const streamStatus = useRef();
48
48
  // The page owns this context; player UI remounts must retain exposure history.
49
49
  const trialBadgeViewedRef = useRef(false);
50
+ const trialBadgeRtidRef = useRef(new Map());
50
51
  // 全屏、竖屏
51
52
  const [screenType, setScreenType] = useAtom('vertical');
52
53
  const IPCPlayerInstance = useRef();
@@ -347,6 +348,7 @@ export const createUseCtx = _ref => {
347
348
  return {
348
349
  devId,
349
350
  trialBadgeViewedRef,
351
+ trialBadgeRtidRef,
350
352
  brandColor,
351
353
  verticalMic,
352
354
  saveToAlbum,
@@ -55,6 +55,7 @@ export type UseCtx = (options: {
55
55
  }) => {
56
56
  devId: string;
57
57
  trialBadgeViewedRef: React.MutableRefObject<boolean>;
58
+ trialBadgeRtidRef: React.MutableRefObject<Map<string, string>>;
58
59
  brandColor: RetAtom<string>;
59
60
  verticalMic: RetAtom<boolean>;
60
61
  saveToAlbum: 0 | 1;
@@ -85,7 +85,7 @@ const BottomLeftContent = _ref => {
85
85
  handleTrialView,
86
86
  handleTrialSubscribe,
87
87
  handleCountdownEnd
88
- } = useTrialBadge(ctx.event, ctx.devId, trialRemainingSec, ctx.trialBadgeViewedRef);
88
+ } = useTrialBadge(ctx.event, ctx.devId, trialRemainingSec, ctx.trialBadgeViewedRef, ctx.trialBadgeRtidRef);
89
89
 
90
90
  // 横向滚动状态:内容溢出且未滑到对应边缘时,显示左 / 右箭头提示
91
91
  const idRef = useRef(++scrollClsSeq);
@@ -1,5 +1,5 @@
1
1
  export type EntryTracking = Record<'utm_source' | 'utm_medium' | 'entry_source_type' | 'utm_rtid', string>;
2
- export declare const createEntryTracking: () => EntryTracking;
2
+ export declare const createEntryTracking: (fallbackRtid?: string) => EntryTracking;
3
3
  export declare const appendTrackingQuery: (url: string, tracking: EntryTracking) => string;
4
4
  export declare const reportEntryView: (devId: string, tracking: EntryTracking) => Promise<void>;
5
5
  export declare const reportEntryClick: (devId: string, tracking: EntryTracking) => Promise<void>;
@@ -4,7 +4,7 @@ import "core-js/modules/esnext.iterator.filter.js";
4
4
  import "core-js/modules/esnext.iterator.for-each.js";
5
5
  import { getLaunchOptionsSync } from '@ray-js/ray';
6
6
  import { getInitUtmTid } from '@ray-js/ray-ipc-utils';
7
- export const createEntryTracking = () => {
7
+ export const createEntryTracking = fallbackRtid => {
8
8
  let upstreamRtid;
9
9
  try {
10
10
  var _getLaunchOptionsSync;
@@ -16,7 +16,7 @@ export const createEntryTracking = () => {
16
16
  utm_source: 'miniprogram',
17
17
  utm_medium: 'panel_smart_quality',
18
18
  entry_source_type: 'organic',
19
- utm_rtid: upstreamRtid || getInitUtmTid()
19
+ utm_rtid: upstreamRtid || fallbackRtid || getInitUtmTid()
20
20
  };
21
21
  };
22
22
  export const appendTrackingQuery = (url, tracking) => {
@@ -38,11 +38,28 @@ export function FullScreen(props) {
38
38
  * 竖屏统一操作
39
39
  */
40
40
 
41
+ const handleVertical = () => {
42
+ event.emit(pauseTimeToHideAllComponent);
43
+ setNavigationBarBack({
44
+ type: 'system'
45
+ });
46
+ showMenuButton();
47
+ showStatusBar();
48
+ deleteContent('topLeft', verticalScreenId);
49
+ hideContent('bottomLeft', fullSmallIntercomId);
50
+ deleteContent('absolute', voiceIntercomId);
51
+ deleteContent('absolute', ptzControlId);
52
+ deleteContent('absolute', fullResolutionId);
53
+ deleteContent('absolute', fullTravelRouteControlId);
54
+ };
55
+
41
56
  /**
42
57
  * 全屏统一操作
43
58
  */
44
- const handleFull = () => {
59
+ const handleFull = isCurrent => {
45
60
  hasDpCode(devId, DIRECTION_CONTROL_DP_CODE).then(hasDirectionControlDpCode => {
61
+ // 屏幕切换、设备切换或卸载后,旧能力查询不能重新挂载全屏控件。
62
+ if (!isCurrent()) return;
46
63
  hideMenuButton();
47
64
  hideStatusBar();
48
65
  setNavigationBarBack({
@@ -94,33 +111,17 @@ export function FullScreen(props) {
94
111
  }, null);
95
112
  });
96
113
  };
97
-
98
- /**
99
- * 针对横竖屏方法统一集中处理
100
- */
101
- const handlers = {
102
- full: () => {
103
- handleFull();
104
- },
105
- vertical: () => {
106
- event.emit(pauseTimeToHideAllComponent);
107
- setNavigationBarBack({
108
- type: 'system'
109
- });
110
- showMenuButton();
111
- showStatusBar();
112
- deleteContent('topLeft', verticalScreenId);
113
- hideContent('bottomLeft', fullSmallIntercomId);
114
- deleteContent('absolute', voiceIntercomId);
115
- deleteContent('absolute', ptzControlId);
116
- deleteContent('absolute', fullResolutionId);
117
- deleteContent('absolute', fullTravelRouteControlId);
118
- }
119
- };
120
114
  useEffect(() => {
121
- var _handlers$screenType;
122
- (_handlers$screenType = handlers[screenType]) === null || _handlers$screenType === void 0 || _handlers$screenType.call(handlers);
123
- }, [screenType]);
115
+ let active = true;
116
+ if (screenType === 'full') {
117
+ handleFull(() => active);
118
+ } else {
119
+ handleVertical();
120
+ }
121
+ return () => {
122
+ active = false;
123
+ };
124
+ }, [screenType, devId]);
124
125
 
125
126
  // 点击事件处理函数
126
127
  const handClick = target => {
@@ -8,5 +8,5 @@ type RectDirectionControlProps = React.ComponentProps<typeof RectDirectionContro
8
8
  export type FullTravelRouteControlProps = ComponentConfigProps & {
9
9
  directionControlProps?: Partial<RectDirectionControlProps>;
10
10
  };
11
- export declare function FullTravelRouteControl(props: FullTravelRouteControlProps): React.JSX.Element;
11
+ export declare function FullTravelRouteControl(props: FullTravelRouteControlProps): React.JSX.Element | null;
12
12
  export {};
@@ -26,9 +26,11 @@ export function FullTravelRouteControl(props) {
26
26
  const prevRotate = useRef('-1');
27
27
  const pauseTimeToHideAllComponentRef = useRef(false);
28
28
  const {
29
- brandColor
29
+ brandColor,
30
+ screenType
30
31
  } = useStore({
31
- brandColor: props.brandColor
32
+ brandColor: props.brandColor,
33
+ screenType: props.screenType
32
34
  });
33
35
  useRef();
34
36
  const [state, _, sendDp] = useDpState({
@@ -64,6 +66,7 @@ export function FullTravelRouteControl(props) {
64
66
  });
65
67
  prevRotate.current = value;
66
68
  };
69
+ if (screenType !== 'full') return null;
67
70
  return /*#__PURE__*/React.createElement(View, {
68
71
  className: clsx('ipc-player-plugin-full-screen-voice', 'ipc-plugin-absolute-move-in-right', {
69
72
  'ipc-plugin-absolute-move-in-right-hide': shouldHide || isPtzActive
@@ -1,6 +1,6 @@
1
1
  import type { MutableRefObject } from 'react';
2
2
  import type { EventInstance } from '../../interface';
3
- export declare const useTrialBadge: (event: EventInstance, devId: string, trialRemainingSec: number, viewedRef?: MutableRefObject<boolean>) => {
3
+ export declare const useTrialBadge: (event: EventInstance, devId: string, trialRemainingSec: number, viewedRef?: MutableRefObject<boolean>, rtidRef?: MutableRefObject<Map<string, string>>) => {
4
4
  showTrialBadge: boolean;
5
5
  setShowTrialBadge: import("react").Dispatch<import("react").SetStateAction<boolean>>;
6
6
  handleTrialView: () => void;
@@ -4,9 +4,16 @@ import { gotoSecurityCloudService2 } from '../../utils';
4
4
  import { trialCountdownEnd } from '../../ui/constant';
5
5
  import Strings from '../../i18n';
6
6
  import { createEntryTracking, reportEntryClick, reportEntryView } from '../../utils/fullLinkTracking';
7
- export const useTrialBadge = (event, devId, trialRemainingSec, viewedRef) => {
7
+ export const useTrialBadge = (event, devId, trialRemainingSec, viewedRef, rtidRef) => {
8
8
  const localViewedRef = useRef(false);
9
9
  const pageViewedRef = viewedRef || localViewedRef;
10
+ const localRtidRef = useRef(new Map());
11
+ const pageRtidRef = rtidRef || localRtidRef;
12
+ const getTracking = useCallback(() => {
13
+ const tracking = createEntryTracking(pageRtidRef.current.get(devId));
14
+ pageRtidRef.current.set(devId, tracking.utm_rtid);
15
+ return tracking;
16
+ }, [devId, pageRtidRef]);
10
17
  const [showTrialBadge, setShowTrialBadge] = useState(false);
11
18
  const prevTrialSecRef = useRef(trialRemainingSec);
12
19
  useEffect(() => {
@@ -20,11 +27,11 @@ export const useTrialBadge = (event, devId, trialRemainingSec, viewedRef) => {
20
27
  const handleTrialView = useCallback(() => {
21
28
  if (pageViewedRef.current) return;
22
29
  pageViewedRef.current = true;
23
- reportEntryView(devId, createEntryTracking());
24
- }, [devId, pageViewedRef]);
30
+ reportEntryView(devId, getTracking());
31
+ }, [devId, pageViewedRef, getTracking]);
25
32
  const handleTrialSubscribe = useCallback(async () => {
26
33
  try {
27
- const tracking = createEntryTracking();
34
+ const tracking = getTracking();
28
35
  await reportEntryClick(devId, tracking);
29
36
  await gotoSecurityCloudService2(devId, tracking);
30
37
  } catch (error) {
@@ -33,7 +40,7 @@ export const useTrialBadge = (event, devId, trialRemainingSec, viewedRef) => {
33
40
  icon: 'none'
34
41
  });
35
42
  }
36
- }, [devId]);
43
+ }, [devId, getTracking]);
37
44
  const handleCountdownEnd = useCallback(async () => {
38
45
  try {
39
46
  setShowTrialBadge(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.67-beta.0",
3
+ "version": "0.0.67-beta.2",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [