@ray-js/ipc-player-integration 0.0.35-beta.15 → 0.0.35-beta.16

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.
@@ -39,15 +39,20 @@ const BottomLeftContent = _ref => {
39
39
  const tryExp = bottomLeftContent === null || bottomLeftContent === void 0 ? void 0 : bottomLeftContent.find(item => item.id === 'TryExperience');
40
40
  return (_trialRemainingSec = tryExp === null || tryExp === void 0 || (_tryExp$initProps2 = tryExp.initProps) === null || _tryExp$initProps2 === void 0 ? void 0 : _tryExp$initProps2.trialRemainingSec) !== null && _trialRemainingSec !== void 0 ? _trialRemainingSec : 0;
41
41
  }, [bottomLeftContent]);
42
+ const buttonState = useMemo(() => {
43
+ var _tryExp$initProps3;
44
+ const tryExp = bottomLeftContent === null || bottomLeftContent === void 0 ? void 0 : bottomLeftContent.find(item => item.id === 'TryExperience');
45
+ return tryExp === null || tryExp === void 0 || (_tryExp$initProps3 = tryExp.initProps) === null || _tryExp$initProps3 === void 0 ? void 0 : _tryExp$initProps3.buttonState;
46
+ }, [bottomLeftContent]);
42
47
  const isLowPhone = useMemo(() => {
43
- var _isLowPhone, _tryExp$initProps3;
48
+ var _isLowPhone, _tryExp$initProps4;
44
49
  const tryExp = bottomLeftContent === null || bottomLeftContent === void 0 ? void 0 : bottomLeftContent.find(item => item.id === 'TryExperience');
45
- 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;
50
+ return (_isLowPhone = tryExp === null || tryExp === void 0 || (_tryExp$initProps4 = tryExp.initProps) === null || _tryExp$initProps4 === void 0 ? void 0 : _tryExp$initProps4.isLowPhone) !== null && _isLowPhone !== void 0 ? _isLowPhone : false;
46
51
  }, []);
47
52
  const gRawData = useMemo(() => {
48
- var _gRawData, _tryExp$initProps4;
53
+ var _gRawData, _tryExp$initProps5;
49
54
  const tryExp = bottomLeftContent === null || bottomLeftContent === void 0 ? void 0 : bottomLeftContent.find(item => item.id === 'TryExperience');
50
- 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;
55
+ 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;
51
56
  }, [bottomLeftContent]);
52
57
  const [shouldHide] = useComponentHideState();
53
58
  const {
@@ -56,7 +61,7 @@ const BottomLeftContent = _ref => {
56
61
  handleCountdownEnd
57
62
  } = useTrialBadge(ctx.event, ctx.devId, trialRemainingSec);
58
63
  const paddingLeftPx = screenType === 'vertical' ? 0 : 25;
59
- const showBadge = showSmartImageQuality && showTrialBadge && canOpenSettings && gRawData && !isLowPhone && trialRemainingSec > 0;
64
+ const showBadge = showSmartImageQuality && showTrialBadge && canOpenSettings && gRawData && !isLowPhone && buttonState === 1 && trialRemainingSec > 0;
60
65
  const bottomBarHeight = screenType === 'vertical' ? 40 : 58;
61
66
  const badgeAreaHeight = screenType === 'vertical' ? BADGE_HEIGHT_VERTICAL : BADGE_HEIGHT_FULL;
62
67
  const containerHeight = showBadge ? `${bottomBarHeight + badgeAreaHeight}px` : `${bottomBarHeight}px`;
package/lib/ui/ui.js CHANGED
@@ -455,7 +455,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
455
455
  // canOpenSettings: true,
456
456
  // };
457
457
  const getNgRes = await getNgRawData();
458
- console.log('res===getNgRes', res, getNgRes);
458
+ console.log('res===getNgRes111', res, getNgRes);
459
459
  updatePlayerWidgetProps(instance, 'bottomLeft', 'TryExperience', {
460
460
  isPurchase: res.isPurchase,
461
461
  buttonState: res.buttonState,
@@ -465,8 +465,10 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
465
465
  isLowPhone: isLowPhoneRef.current
466
466
  });
467
467
  });
468
+ const siqInitRef = useRef(false);
468
469
  useEffect(() => {
469
- if (playState === PlayState.PLAYING) {
470
+ if (playState === PlayState.PLAYING && !siqInitRef.current) {
471
+ siqInitRef.current = true;
470
472
  refreshSmartImageQuality();
471
473
  }
472
474
  }, [instance, playState]);
@@ -1,26 +1,22 @@
1
- import { useCallback, useEffect, useState } from 'react';
1
+ import { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import { setTrailFinish } from '../../utils/ttt';
3
3
  import { gotoSecurityCloudService2 } from '../../utils';
4
- import { trialCountdownEnd, hideTrialBadgeEvent } from '../../ui/constant';
4
+ import { trialCountdownEnd } from '../../ui/constant';
5
5
  import Strings from '../../i18n';
6
6
  export const useTrialBadge = (event, devId, trialRemainingSec) => {
7
7
  const [showTrialBadge, setShowTrialBadge] = useState(false);
8
+ const prevTrialSecRef = useRef(trialRemainingSec);
8
9
  useEffect(() => {
9
10
  if (trialRemainingSec > 0 && trialRemainingSec < 300) {
10
- setShowTrialBadge(true);
11
+ if (trialRemainingSec !== prevTrialSecRef.current) {
12
+ setShowTrialBadge(true);
13
+ }
11
14
  }
15
+ prevTrialSecRef.current = trialRemainingSec;
12
16
  }, [trialRemainingSec]);
13
- useEffect(() => {
14
- const hide = () => setShowTrialBadge(false);
15
- event.on(hideTrialBadgeEvent, hide);
16
- return () => {
17
- event.off(hideTrialBadgeEvent, hide);
18
- };
19
- }, [event]);
20
17
  const handleTrialSubscribe = useCallback(async () => {
21
18
  try {
22
- const res = await gotoSecurityCloudService2(devId);
23
- console.log('res===gotoSecurityCloudService2', res);
19
+ await gotoSecurityCloudService2(devId);
24
20
  } catch (error) {
25
21
  ty.showToast({
26
22
  title: Strings.getLang('ipc_player_fetch_error'),
@@ -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, hideTrialBadgeEvent } from '../../ui/constant';
8
+ import { refreshSmartImageQualityEvent } 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';
@@ -71,12 +71,6 @@ export const TryExperience = props => {
71
71
  setImgSrc(tryClose);
72
72
  return;
73
73
  }
74
- // ty.getNgRawData({
75
- // rawKey: 'is_smart_image_quality',
76
- // success: () => {},
77
- // fail: () => {},
78
- // });
79
- // success里具体的值 要看看实际调试结果, APP NG 配置支持的话 才展示智能画质开关哦
80
74
  if (buttonState === 0 || buttonState) {
81
75
  const iconUrl = pickIconByStatus(buttonState);
82
76
  setImgSrc(iconUrl);
@@ -104,7 +98,7 @@ export const TryExperience = props => {
104
98
  try {
105
99
  const getAI = await getAIFrameFeature(devId);
106
100
  if (buttonState === TryExperienceStatus.Open) {
107
- var _getAI$aiFrameFeature, _getAI$aiFrameFeature2, _getAI$aiFrameFeature3, _props$event, _props$event2;
101
+ var _getAI$aiFrameFeature, _getAI$aiFrameFeature2, _getAI$aiFrameFeature3, _props$event;
108
102
  // 由开变关的时候,只关inPreview
109
103
  const scope = _objectSpread(_objectSpread({}, (_getAI$aiFrameFeature = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature === void 0 ? void 0 : _getAI$aiFrameFeature.scope), {}, {
110
104
  inPreview: false
@@ -120,10 +114,9 @@ export const TryExperience = props => {
120
114
  exportEnabled: (_getAI$aiFrameFeature3 = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature3 === void 0 ? void 0 : _getAI$aiFrameFeature3.exportEnabled
121
115
  }
122
116
  });
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
+ (_props$event = props.event) === null || _props$event === void 0 || _props$event.emit(refreshSmartImageQualityEvent);
125
118
  } else if (buttonState === TryExperienceStatus.Close && isPurchase || buttonState === TryExperienceStatus.Close && trialRemainingSec < 300 && trialRemainingSec > 0) {
126
- var _getAI$aiFrameFeature4, _getAI$aiFrameFeature5, _getAI$aiFrameFeature6, _props$event3;
119
+ var _getAI$aiFrameFeature4, _getAI$aiFrameFeature5, _getAI$aiFrameFeature6, _props$event2;
127
120
  const scope = _objectSpread(_objectSpread({}, (_getAI$aiFrameFeature4 = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature4 === void 0 ? void 0 : _getAI$aiFrameFeature4.scope), {}, {
128
121
  inPreview: true
129
122
  });
@@ -139,7 +132,7 @@ export const TryExperience = props => {
139
132
  exportEnabled: (_getAI$aiFrameFeature6 = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature6 === void 0 ? void 0 : _getAI$aiFrameFeature6.exportEnabled
140
133
  }
141
134
  });
142
- (_props$event3 = props.event) === null || _props$event3 === void 0 || _props$event3.emit(refreshSmartImageQualityEvent);
135
+ (_props$event2 = props.event) === null || _props$event2 === void 0 || _props$event2.emit(refreshSmartImageQualityEvent);
143
136
  } else {
144
137
  gotoAIDrawMiniProgram(devId, brandColor);
145
138
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.35-beta.15",
3
+ "version": "0.0.35-beta.16",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [