@ray-js/ipc-player-integration 0.0.35-beta.13 → 0.0.35-beta.14

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.
@@ -9,28 +9,6 @@ import { useComponentHideState } from './hooks';
9
9
  import { TrialBadge, useTrialBadge } from '../widgets/trialBadge';
10
10
  /** 右侧透明渐变宽度,用于提示横向可滑动 */
11
11
  const FADE_MASK = 'linear-gradient(to right, #000 calc(100% - 48px), transparent 100%)';
12
-
13
- /**
14
- * 试用徽章在不同 screenType 下的容器样式。
15
- * 「贴在底栏顶部」的策略一致(bottom: 100%),只是 left / marginBottom
16
- * 等数值按横竖屏不同的边距规则做差异化处理。
17
- */
18
- const TRIAL_BADGE_WRAP_STYLE_VERTICAL = {
19
- position: 'absolute',
20
- left: '0px',
21
- bottom: '100%',
22
- marginBottom: 4,
23
- zIndex: 2,
24
- width: 'max-content'
25
- };
26
- const TRIAL_BADGE_WRAP_STYLE_FULL = {
27
- position: 'absolute',
28
- left: '25px',
29
- bottom: '100%',
30
- marginBottom: 8,
31
- zIndex: 2,
32
- width: 'max-content'
33
- };
34
12
  const BottomLeftContent = _ref => {
35
13
  let {
36
14
  ctx,
@@ -63,6 +41,11 @@ const BottomLeftContent = _ref => {
63
41
  const tryExp = bottomLeftContent === null || bottomLeftContent === void 0 ? void 0 : bottomLeftContent.find(item => item.id === 'TryExperience');
64
42
  return (_isLowPhone = tryExp === null || tryExp === void 0 || (_tryExp$initProps3 = tryExp.initProps) === null || _tryExp$initProps3 === void 0 ? void 0 : _tryExp$initProps3.isLowPhone) !== null && _isLowPhone !== void 0 ? _isLowPhone : false;
65
43
  }, []);
44
+ const gRawData = useMemo(() => {
45
+ var _gRawData, _tryExp$initProps4;
46
+ const tryExp = bottomLeftContent === null || bottomLeftContent === void 0 ? void 0 : bottomLeftContent.find(item => item.id === 'TryExperience');
47
+ return (_gRawData = tryExp === null || tryExp === void 0 || (_tryExp$initProps4 = tryExp.initProps) === null || _tryExp$initProps4 === void 0 ? void 0 : _tryExp$initProps4.gRawData) !== null && _gRawData !== void 0 ? _gRawData : false;
48
+ }, [bottomLeftContent]);
66
49
  const [shouldHide] = useComponentHideState();
67
50
  const {
68
51
  showTrialBadge,
@@ -70,35 +53,40 @@ const BottomLeftContent = _ref => {
70
53
  handleCountdownEnd
71
54
  } = useTrialBadge(ctx.event, ctx.devId, trialRemainingSec);
72
55
  const paddingLeftPx = screenType === 'vertical' ? 0 : 25;
73
- const trialBadgeWrapStyle = screenType === 'vertical' ? TRIAL_BADGE_WRAP_STYLE_VERTICAL : TRIAL_BADGE_WRAP_STYLE_FULL;
74
- const showBadge = showSmartImageQuality && showTrialBadge && canOpenSettings && !isLowPhone && trialRemainingSec > 0;
75
- const containerHeight = (() => {
76
- if (showBadge) {
77
- return screenType === 'vertical' ? '40px' : '58px';
78
- }
79
- return screenType === 'vertical' ? shouldHide ? '41px' : '40px' : shouldHide ? '57px' : '58px';
80
- })();
81
- return /*#__PURE__*/React.createElement(CoverView, {
82
- className: clsx('ipc-player-bottom-left-content-wrap')
83
- // 注意:不要在这里覆盖 position,CSS 类已经设置 position: absolute; left: 0; bottom: 0
84
- // 否则 children 会失去贴底定位,从而与 bottomRightContent 不对齐
85
- ,
86
- style: {
87
- right: `${reservedRight}px`,
88
- height: containerHeight
89
- }
90
- }, showBadge && /*#__PURE__*/React.createElement(View, {
91
- className: clsx('bottom-left-item-container'),
92
- style: _objectSpread(_objectSpread({}, trialBadgeWrapStyle), {}, {
56
+ const containerHeight = screenType === 'vertical' ? '40px' : '58px';
57
+ const trialBadgeStyle = screenType === 'vertical' ? {
58
+ position: 'absolute',
59
+ left: '0px',
60
+ bottom: '48px',
61
+ marginBottom: 4,
62
+ zIndex: 101,
63
+ width: 'max-content'
64
+ } : {
65
+ position: 'absolute',
66
+ left: '25px',
67
+ bottom: '72px',
68
+ marginBottom: 8,
69
+ zIndex: 101,
70
+ width: 'max-content'
71
+ };
72
+ return /*#__PURE__*/React.createElement(React.Fragment, null, showSmartImageQuality && showTrialBadge && canOpenSettings && gRawData && !isLowPhone && trialRemainingSec > 0 && /*#__PURE__*/React.createElement(CoverView, {
73
+ style: _objectSpread(_objectSpread({}, trialBadgeStyle), {}, {
93
74
  opacity: shouldHide ? 0 : 1,
94
75
  pointerEvents: shouldHide ? 'none' : 'auto'
95
- })
76
+ }),
77
+ onClick: e => e.stopPropagation()
96
78
  }, /*#__PURE__*/React.createElement(TrialBadge, {
97
79
  brandColor: brandColor,
98
80
  trialRemainingSec: trialRemainingSec,
99
81
  onSubscribe: handleTrialSubscribe,
100
82
  onCountdownEnd: handleCountdownEnd
101
- })), /*#__PURE__*/React.createElement(View, {
83
+ })), /*#__PURE__*/React.createElement(CoverView, {
84
+ className: clsx('ipc-player-bottom-left-content-wrap'),
85
+ style: {
86
+ right: `${reservedRight}px`,
87
+ height: containerHeight
88
+ }
89
+ }, /*#__PURE__*/React.createElement(View, {
102
90
  style: {
103
91
  paddingBottom: screenType === 'vertical' ? '14px' : '32px',
104
92
  paddingLeft: `${paddingLeftPx}px`,
@@ -111,10 +99,7 @@ const BottomLeftContent = _ref => {
111
99
  WebkitMaskImage: FADE_MASK,
112
100
  maskImage: FADE_MASK
113
101
  },
114
- className: clsx('ipc-player-bottom-left-content-container', {
115
- // 'ipc-player-bottom-left-content-hide': shouldHide,
116
- // 'ipc-player-bottom-left-content-show': !shouldHide,
117
- })
118
- }, children));
102
+ className: clsx('ipc-player-bottom-left-content-container')
103
+ }, children)));
119
104
  };
120
105
  export default BottomLeftContent;
@@ -26,6 +26,7 @@ export declare const widgetClick = "widgetClick";
26
26
  * 业务侧/相关控件可监听此事件刷新自己的状态(例如 TryExperience 重新拉取状态)
27
27
  */
28
28
  export declare const trialCountdownEnd = "trialCountdownEnd";
29
+ export declare const hideTrialBadgeEvent = "hideTrialBadge";
29
30
  export declare const refreshSmartImageQualityEvent = "refreshSmartImageQuality";
30
31
  /** 控件点击事件用的 widgetId,统一在此维护 */
31
32
  export declare const widgetLabs: {
@@ -27,6 +27,7 @@ export const widgetClick = 'widgetClick';
27
27
  * 业务侧/相关控件可监听此事件刷新自己的状态(例如 TryExperience 重新拉取状态)
28
28
  */
29
29
  export const trialCountdownEnd = 'trialCountdownEnd';
30
+ export const hideTrialBadgeEvent = 'hideTrialBadge';
30
31
  export const refreshSmartImageQualityEvent = 'refreshSmartImageQuality';
31
32
 
32
33
  /** 控件点击事件用的 widgetId,统一在此维护 */
package/lib/ui/ui.js CHANGED
@@ -22,7 +22,7 @@ import { useMemoizedFn } from '../hooks';
22
22
  import { Storage } from '../utils/storage';
23
23
  import './ui.less';
24
24
  import { updatePlayerWidgetProps } from '../features';
25
- import { getSmartImageQualityState, isLowPhone } from '../utils/ttt';
25
+ import { getNgRawData, getSmartImageQualityState, isLowPhone } from '../utils/ttt';
26
26
  function getCtxInstance(instance, devId) {
27
27
  if (instance) return instance;
28
28
  // eslint-disable-next-line react-hooks/rules-of-hooks
@@ -111,9 +111,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
111
111
  // 是否需要忽略进入后台停止预览
112
112
  const [ignoreStopOnHide, setIgnoreStopOnHide] = useState(ignoreHideStopPreview);
113
113
  const [verticalCoverZoom, setVerticalCoverZoom] = useState(-2);
114
- // const [verticalCoverZoom, setVerticalCoverZoom] = useState(-2);
115
- // const [verticalZoomLevel, setVerticalZoomLevel] = useState(playerFit === 'contain' ? 1 : -2);
116
-
117
114
  const isLowPhoneRef = useRef(false);
118
115
  useEffect(() => {
119
116
  isLowPhone().then(res => {
@@ -450,19 +447,21 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
450
447
  const refreshSmartImageQuality = useMemoizedFn(async () => {
451
448
  const res = await getSmartImageQualityState(devId);
452
449
  if (res === undefined) return;
453
- // 可调试
450
+ // 调试时使用
454
451
  // res = {
455
452
  // isPurchase: false,
456
453
  // buttonState: 0,
457
454
  // trialRemainingSec: 20,
458
455
  // canOpenSettings: true,
459
456
  // };
460
- console.log('res===refreshSmartImageQuality', res);
457
+ const getNgRes = await getNgRawData();
458
+ console.log('res===getNgRes', res, getNgRes);
461
459
  updatePlayerWidgetProps(instance, 'bottomLeft', 'TryExperience', {
462
460
  isPurchase: res.isPurchase,
463
461
  buttonState: res.buttonState,
464
462
  trialRemainingSec: res.trialRemainingSec,
465
463
  canOpenSettings: res.canOpenSettings,
464
+ gRawData: !!getNgRes,
466
465
  isLowPhone: isLowPhoneRef.current
467
466
  });
468
467
  });
@@ -918,7 +917,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
918
917
  console.log('playerTap 事件已禁止');
919
918
  return;
920
919
  }
921
- console.log('res===on onVideoTap', data);
920
+ console.log('res===on onVideoTap1', data);
922
921
  if (instance.multiCameraCtx.isSupport) {
923
922
  var _instance$multiCamera, _instance$multiCamera2;
924
923
  const preTapIndex = (_instance$multiCamera = (_instance$multiCamera2 = instance.multiCameraCtx.selectedLenInfoRef.current) === null || _instance$multiCamera2 === void 0 ? void 0 : _instance$multiCamera2.index) !== null && _instance$multiCamera !== void 0 ? _instance$multiCamera : prevSelectedIndexRef.current;
@@ -40,3 +40,4 @@ export declare function getDeviceInfo(devId: string): Promise<unknown>;
40
40
  export declare function getCurrentHomeInfo(): Promise<unknown>;
41
41
  export declare function setTrailFinish(devId: string): Promise<unknown>;
42
42
  export declare function isLowPhone(): Promise<unknown>;
43
+ export declare function getNgRawData(): Promise<unknown>;
package/lib/utils/ttt.js CHANGED
@@ -6,7 +6,6 @@ export function getSmartImageQualityState(devId) {
6
6
  devId,
7
7
  scene: 'inPreview',
8
8
  success: data => {
9
- console.log('res===getSmartImageQualityState data', data);
10
9
  resolve(data);
11
10
  },
12
11
  fail: () => {
@@ -120,4 +119,21 @@ export function isLowPhone() {
120
119
  resolve(false);
121
120
  }
122
121
  });
122
+ }
123
+ export function getNgRawData() {
124
+ return new Promise(resolve => {
125
+ try {
126
+ ty.getNgRawData({
127
+ rawKey: 'is_smart_image_quality',
128
+ success: res => {
129
+ resolve(res);
130
+ },
131
+ fail: () => {
132
+ resolve(false);
133
+ }
134
+ });
135
+ } catch (e) {
136
+ resolve(false);
137
+ }
138
+ });
123
139
  }
@@ -77,10 +77,7 @@ export const TrialBadge = _ref => {
77
77
  style: {
78
78
  backgroundColor: brandColor
79
79
  },
80
- onClick: e => {
81
- if (e && typeof e.stopPropagation === 'function') {
82
- e.stopPropagation();
83
- }
80
+ onClick: () => {
84
81
  onSubscribe === null || onSubscribe === void 0 || onSubscribe();
85
82
  }
86
83
  }, /*#__PURE__*/React.createElement(Text, {
@@ -1,7 +1,7 @@
1
1
  .ipc-player-trial-badge {
2
2
  display: inline-flex;
3
3
  align-items: center;
4
- height: 28px;
4
+ height: 40px;
5
5
  padding: 0 4px 0 8px;
6
6
  border-radius: 6px;
7
7
  background: rgba(0, 0, 0, 0.65);
@@ -43,9 +43,10 @@
43
43
  display: inline-flex;
44
44
  align-items: center;
45
45
  justify-content: center;
46
- height: 22px;
47
- padding: 0 10px;
48
- border-radius: 11px;
46
+ min-width: 44px;
47
+ min-height: 28px;
48
+ padding: 0 12px;
49
+ border-radius: 14px;
49
50
  flex-shrink: 0;
50
51
  }
51
52
 
@@ -1,7 +1,7 @@
1
1
  import { useCallback, useEffect, useState } from 'react';
2
2
  import { setTrailFinish } from '../../utils/ttt';
3
3
  import { gotoSecurityCloudService2 } from '../../utils';
4
- import { trialCountdownEnd } from '../../ui/constant';
4
+ import { trialCountdownEnd, hideTrialBadgeEvent } from '../../ui/constant';
5
5
  import Strings from '../../i18n';
6
6
  export const useTrialBadge = (event, devId, trialRemainingSec) => {
7
7
  const [showTrialBadge, setShowTrialBadge] = useState(false);
@@ -10,6 +10,13 @@ export const useTrialBadge = (event, devId, trialRemainingSec) => {
10
10
  setShowTrialBadge(true);
11
11
  }
12
12
  }, [trialRemainingSec]);
13
+ useEffect(() => {
14
+ const hide = () => setShowTrialBadge(false);
15
+ event.on(hideTrialBadgeEvent, hide);
16
+ return () => {
17
+ event.off(hideTrialBadgeEvent, hide);
18
+ };
19
+ }, [event]);
13
20
  const handleTrialSubscribe = useCallback(async () => {
14
21
  try {
15
22
  const res = await gotoSecurityCloudService2(devId);
@@ -8,6 +8,7 @@ type Props = ComponentConfigProps & {
8
8
  trialRemainingSec?: number;
9
9
  isPurchase?: boolean;
10
10
  canOpenSettings?: boolean;
11
+ gRawData?: boolean;
11
12
  isLowPhone?: boolean;
12
13
  };
13
14
  export declare const TryExperience: (props: Props) => React.JSX.Element | null;
@@ -5,7 +5,7 @@ import React, { useState, useEffect, useCallback, useRef } from 'react';
5
5
  import { useStore } from '../../ctx/store';
6
6
  import Strings from '../../i18n';
7
7
  import { getAIFrameFeature, gotoAIDrawMiniProgram, setAIFrameFeature } from '../../utils';
8
- import { refreshSmartImageQualityEvent } from '../../ui/constant';
8
+ import { refreshSmartImageQualityEvent, hideTrialBadgeEvent } from '../../ui/constant';
9
9
  import tryZh from '../../res/try/try_zh.png';
10
10
  import tryEn from '../../res/try/try_en.png';
11
11
  import tryOpen from '../../res/try/try_open.png';
@@ -49,6 +49,7 @@ export const TryExperience = props => {
49
49
  trialRemainingSec,
50
50
  isPurchase,
51
51
  canOpenSettings,
52
+ gRawData,
52
53
  isLowPhone,
53
54
  devId
54
55
  } = props;
@@ -70,6 +71,12 @@ export const TryExperience = props => {
70
71
  setImgSrc(tryClose);
71
72
  return;
72
73
  }
74
+ // ty.getNgRawData({
75
+ // rawKey: 'is_smart_image_quality',
76
+ // success: () => {},
77
+ // fail: () => {},
78
+ // });
79
+ // success里具体的值 要看看实际调试结果, APP NG 配置支持的话 才展示智能画质开关哦
73
80
  if (buttonState === 0 || buttonState) {
74
81
  const iconUrl = pickIconByStatus(buttonState);
75
82
  setImgSrc(iconUrl);
@@ -97,7 +104,7 @@ export const TryExperience = props => {
97
104
  try {
98
105
  const getAI = await getAIFrameFeature(devId);
99
106
  if (buttonState === TryExperienceStatus.Open) {
100
- var _getAI$aiFrameFeature, _getAI$aiFrameFeature2, _getAI$aiFrameFeature3, _props$event;
107
+ var _getAI$aiFrameFeature, _getAI$aiFrameFeature2, _getAI$aiFrameFeature3, _props$event, _props$event2;
101
108
  // 由开变关的时候,只关inPreview
102
109
  const scope = _objectSpread(_objectSpread({}, (_getAI$aiFrameFeature = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature === void 0 ? void 0 : _getAI$aiFrameFeature.scope), {}, {
103
110
  inPreview: false
@@ -113,9 +120,10 @@ export const TryExperience = props => {
113
120
  exportEnabled: (_getAI$aiFrameFeature3 = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature3 === void 0 ? void 0 : _getAI$aiFrameFeature3.exportEnabled
114
121
  }
115
122
  });
116
- (_props$event = props.event) === null || _props$event === void 0 || _props$event.emit(refreshSmartImageQualityEvent);
123
+ (_props$event = props.event) === null || _props$event === void 0 || _props$event.emit(hideTrialBadgeEvent);
124
+ (_props$event2 = props.event) === null || _props$event2 === void 0 || _props$event2.emit(refreshSmartImageQualityEvent);
117
125
  } else if (buttonState === TryExperienceStatus.Close && isPurchase || buttonState === TryExperienceStatus.Close && trialRemainingSec < 300 && trialRemainingSec > 0) {
118
- var _getAI$aiFrameFeature4, _getAI$aiFrameFeature5, _getAI$aiFrameFeature6, _props$event2;
126
+ var _getAI$aiFrameFeature4, _getAI$aiFrameFeature5, _getAI$aiFrameFeature6, _props$event3;
119
127
  const scope = _objectSpread(_objectSpread({}, (_getAI$aiFrameFeature4 = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature4 === void 0 ? void 0 : _getAI$aiFrameFeature4.scope), {}, {
120
128
  inPreview: true
121
129
  });
@@ -131,7 +139,7 @@ export const TryExperience = props => {
131
139
  exportEnabled: (_getAI$aiFrameFeature6 = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature6 === void 0 ? void 0 : _getAI$aiFrameFeature6.exportEnabled
132
140
  }
133
141
  });
134
- (_props$event2 = props.event) === null || _props$event2 === void 0 || _props$event2.emit(refreshSmartImageQualityEvent);
142
+ (_props$event3 = props.event) === null || _props$event3 === void 0 || _props$event3.emit(refreshSmartImageQualityEvent);
135
143
  } else {
136
144
  gotoAIDrawMiniProgram(devId, brandColor);
137
145
  }
@@ -144,7 +152,7 @@ export const TryExperience = props => {
144
152
  if (hideTryExperienceMenu) {
145
153
  return null;
146
154
  }
147
- return /*#__PURE__*/React.createElement(React.Fragment, null, imgSrc && canOpenSettings && /*#__PURE__*/React.createElement(View, {
155
+ return /*#__PURE__*/React.createElement(React.Fragment, null, imgSrc && canOpenSettings && gRawData && /*#__PURE__*/React.createElement(View, {
148
156
  className: clsx(className),
149
157
  onClick: onTryExperience
150
158
  }, /*#__PURE__*/React.createElement(View, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.35-beta.13",
3
+ "version": "0.0.35-beta.14",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [