pb-sxp-ui 1.7.3 → 1.7.4

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/dist/index.js CHANGED
@@ -808,17 +808,20 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
808
808
  });
809
809
  }, [bffFetch, curReqInfo, enableReportEvent, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview]);
810
810
  const bffFbReport = useCallback(({ eventName, product }) => {
811
- var _a, _b, _c, _d;
812
- if (!enableReportEvent || !enabledMetaConversionApi || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
811
+ var _a, _b, _c, _d, _e;
812
+ if (!enableReportEvent ||
813
+ !enabledMetaConversionApi ||
814
+ (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) ||
815
+ !((_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _a === void 0 ? void 0 : _a[eventName])) {
813
816
  return;
814
817
  }
815
- let jsonParams = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _a === void 0 ? void 0 : _a[eventName];
818
+ let jsonParams = JSON.parse(JSON.stringify((_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _b === void 0 ? void 0 : _b[eventName]));
816
819
  const urlParams = new URLSearchParams(window.location.search);
817
820
  const fbclid = urlParams === null || urlParams === void 0 ? void 0 : urlParams.get('fbclid');
818
821
  const fix_par = {
819
- event_source_url: (_b = window === null || window === void 0 ? void 0 : window.location) === null || _b === void 0 ? void 0 : _b.href,
822
+ event_source_url: (_c = window === null || window === void 0 ? void 0 : window.location) === null || _c === void 0 ? void 0 : _c.href,
820
823
  external_id: storeAndLoadFeUserId(),
821
- client_user_agent: (_d = (_c = window === null || window === void 0 ? void 0 : window.navigator) === null || _c === void 0 ? void 0 : _c.userAgent) !== null && _d !== void 0 ? _d : '',
824
+ client_user_agent: (_e = (_d = window === null || window === void 0 ? void 0 : window.navigator) === null || _d === void 0 ? void 0 : _d.userAgent) !== null && _e !== void 0 ? _e : '',
822
825
  fbc: fbclid ? `fb.2.${new Date().getTime()}.${fbclid}` : '',
823
826
  fbp: getCookie('_fbp') ? `fb.2.${new Date().getTime()}.${getCookie('_fbp')}` : '',
824
827
  time: new Date().getTime()
@@ -843,7 +846,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
843
846
  matches.forEach((match) => {
844
847
  const prop = match.substring(2, match.length - 2);
845
848
  try {
846
- const replaceValue = new Function('fix_par', 'product', `return ${prop}`)(fix_par, product);
849
+ let replaceValue = new Function('fix_par', 'product', `return ${prop}`)(fix_par, product);
847
850
  if (replaceValue) {
848
851
  obj[key] = replaceValue;
849
852
  }
@@ -15885,7 +15888,7 @@ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPost
15885
15888
  };
15886
15889
  }, [isActive]);
15887
15890
  useEffect(() => {
15888
- var _a, _b, _c, _d;
15891
+ var _a, _b, _c, _d, _e, _f;
15889
15892
  if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
15890
15893
  return;
15891
15894
  if (isActive) {
@@ -15893,10 +15896,14 @@ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPost
15893
15896
  eventName: 'ViewContent',
15894
15897
  product: (_b = (_a = data === null || data === void 0 ? void 0 : data[index]) === null || _a === void 0 ? void 0 : _a.video) === null || _b === void 0 ? void 0 : _b.bindProduct
15895
15898
  });
15896
- (_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.play();
15899
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
15900
+ eventName: 'PageView',
15901
+ product: (_d = (_c = data === null || data === void 0 ? void 0 : data[index]) === null || _c === void 0 ? void 0 : _c.video) === null || _d === void 0 ? void 0 : _d.bindProduct
15902
+ });
15903
+ (_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.play();
15897
15904
  }
15898
15905
  else {
15899
- (_d = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _d === void 0 ? void 0 : _d.pause();
15906
+ (_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.pause();
15900
15907
  }
15901
15908
  }, [isActive, isLoadFinish, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
15902
15909
  /*
@@ -15918,12 +15925,7 @@ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPost
15918
15925
  if (!isActive)
15919
15926
  return;
15920
15927
  const onShow = () => {
15921
- var _a, _b;
15922
15928
  handleClickVideo('start')();
15923
- bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
15924
- eventName: 'ViewContent',
15925
- product: (_b = (_a = data === null || data === void 0 ? void 0 : data[index]) === null || _a === void 0 ? void 0 : _a.video) === null || _b === void 0 ? void 0 : _b.bindProduct
15926
- });
15927
15929
  };
15928
15930
  const onHide = handleClickVideo('pause');
15929
15931
  SXP_EVENT_BUS.on(SXP_EVENT_TYPE.PAGE_DID_SHOW, onShow);
@@ -16094,7 +16096,7 @@ const Picture = (props) => {
16094
16096
  }, onLoad: onShowFirstImage }))));
16095
16097
  };
16096
16098
 
16097
- const PictureGroup$2 = ({ imgUrls, width, height, rec, index, onReportViewImageEnd, onViewImageStartEvent, imgUrlsPostConfig }) => {
16099
+ const PictureGroup$2 = ({ imgUrls, width, height, rec, index, onViewImageEndEvent, onViewImageStartEvent, imgUrlsPostConfig }) => {
16098
16100
  var _a, _b;
16099
16101
  const ref = useRef();
16100
16102
  const { isActive } = useSwiperSlide();
@@ -16106,16 +16108,16 @@ const PictureGroup$2 = ({ imgUrls, width, height, rec, index, onReportViewImageE
16106
16108
  if (isLoad && isActive) {
16107
16109
  (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.swiper.autoplay.start();
16108
16110
  if (openHashtag) {
16109
- onReportViewImageEnd(rec);
16111
+ onViewImageEndEvent(rec);
16110
16112
  }
16111
16113
  else {
16112
- onViewImageStartEvent(index, imgInfo);
16114
+ onViewImageStartEvent(index, imgInfo, true);
16113
16115
  }
16114
16116
  }
16115
16117
  else {
16116
16118
  (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.swiper.autoplay.stop();
16117
16119
  }
16118
- }, [rec, isActive, onReportViewImageEnd, openHashtag, index, onViewImageStartEvent, isLoad, imgInfo]);
16120
+ }, [rec, isActive, onViewImageEndEvent, openHashtag, index, onViewImageStartEvent, isLoad, imgInfo]);
16119
16121
  const showFirstImageFn = useCallback((e) => __awaiter(void 0, void 0, void 0, function* () {
16120
16122
  if (!isLoad) {
16121
16123
  const contentSize = yield getResFileSizeFromSrc(e.src);
@@ -16131,7 +16133,7 @@ const PictureGroup$2 = ({ imgUrls, width, height, rec, index, onReportViewImageE
16131
16133
  // }
16132
16134
  useEffect(() => {
16133
16135
  const onShow = () => onViewImageStartEvent(index, imgInfo);
16134
- const onHide = () => onReportViewImageEnd(rec);
16136
+ const onHide = () => onViewImageEndEvent(rec);
16135
16137
  SXP_EVENT_BUS.on(SXP_EVENT_TYPE.PAGE_DID_SHOW, onShow);
16136
16138
  SXP_EVENT_BUS.on(SXP_EVENT_TYPE.PAGE_DID_HIDE, onHide);
16137
16139
  return () => {
@@ -16277,7 +16279,7 @@ function withBindDataSource(Component) {
16277
16279
  * @Author: binruan@chatlabs.com
16278
16280
  * @Date: 2023-12-26 16:11:34
16279
16281
  * @LastEditors: binruan@chatlabs.com
16280
- * @LastEditTime: 2024-10-25 10:36:59
16282
+ * @LastEditTime: 2024-10-29 14:07:29
16281
16283
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\RenderCard.tsx
16282
16284
  *
16283
16285
  */
@@ -16424,7 +16426,7 @@ var Tagbar$1 = memo(Tagbar);
16424
16426
  * @Author: binruan@chatlabs.com
16425
16427
  * @Date: 2024-01-15 19:03:09
16426
16428
  * @LastEditors: binruan@chatlabs.com
16427
- * @LastEditTime: 2024-10-25 15:41:58
16429
+ * @LastEditTime: 2024-10-28 16:36:22
16428
16430
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
16429
16431
  *
16430
16432
  */
@@ -16494,7 +16496,6 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16494
16496
  // 移动端h5直接杀掉浏览器或宿主app时不会触发,pc端直接杀掉标签页时能触发
16495
16497
  if (repCond) {
16496
16498
  SXP_EVENT_BUS.emit(SXP_EVENT_TYPE.PAGE_DID_HIDE, item);
16497
- // handleReportViewImageEnd(item);
16498
16499
  handleReportProductView(item);
16499
16500
  }
16500
16501
  let fromKName = '';
@@ -16539,7 +16540,6 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16539
16540
  // 页面可见时触发,注意页面初始化时不会触发
16540
16541
  handleH5EnterLink();
16541
16542
  if (repCond) {
16542
- // handleViewImageStartEvent(activeIndex);
16543
16543
  SXP_EVENT_BUS.emit(SXP_EVENT_TYPE.PAGE_DID_SHOW, item);
16544
16544
  backMainFeed('external', selectTag);
16545
16545
  }
@@ -16624,7 +16624,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16624
16624
  return (React.createElement(VideoWidget$3, { key: isReload, rec: rec, index: index, muted: isMuted, data: data, height: height, activeIndex: activeIndex, videoPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPost, videoPlayIcon: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPlayIcon }));
16625
16625
  }
16626
16626
  if ((_b = rec === null || rec === void 0 ? void 0 : rec.video) === null || _b === void 0 ? void 0 : _b.imgUrls) {
16627
- return (React.createElement(PictureGroup$3, { key: rec === null || rec === void 0 ? void 0 : rec.video.itemId, imgUrls: rec === null || rec === void 0 ? void 0 : rec.video.imgUrls, width: containerWidth, height: height, rec: rec, index: index, onReportViewImageEnd: handleReportViewImageEnd, onViewImageStartEvent: handleViewImageStartEvent, imgUrlsPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.imgUrlsPost }));
16627
+ return (React.createElement(PictureGroup$3, { key: rec === null || rec === void 0 ? void 0 : rec.video.itemId, imgUrls: rec === null || rec === void 0 ? void 0 : rec.video.imgUrls, width: containerWidth, height: height, rec: rec, index: index, onViewImageEndEvent: handleViewImageStartEnd, onViewImageStartEvent: handleViewImageStartEvent, imgUrlsPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.imgUrlsPost }));
16628
16628
  }
16629
16629
  if (rec.product && Array.isArray(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) && ((_c = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _c === void 0 ? void 0 : _c.length) > 0) {
16630
16630
  return (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _d === void 0 ? void 0 : _d.map((value, idx) => {
@@ -16698,7 +16698,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16698
16698
  if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLike) || !visible)
16699
16699
  return;
16700
16700
  let top = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconY) !== null && _a !== void 0 ? _a : 400;
16701
- if (waterFallData && top < 40) {
16701
+ if (waterFallData && top < 40 && globalConfig.likeIconYPosit === 'top') {
16702
16702
  top += 40;
16703
16703
  }
16704
16704
  if (rec === null || rec === void 0 ? void 0 : rec.video) {
@@ -16710,7 +16710,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16710
16710
  }
16711
16711
  return null;
16712
16712
  }, [globalConfig, waterFallData]);
16713
- const handleReportViewImageEnd = (item) => {
16713
+ const handleViewImageStartEnd = (item) => {
16714
16714
  var _a, _b, _c, _d, _e, _f;
16715
16715
  if (!((_a = item === null || item === void 0 ? void 0 : item.video) === null || _a === void 0 ? void 0 : _a.url) && ((_b = item === null || item === void 0 ? void 0 : item.video) === null || _b === void 0 ? void 0 : _b.imgUrls)) {
16716
16716
  const endTime = Date.now();
@@ -16793,7 +16793,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16793
16793
  }
16794
16794
  });
16795
16795
  // 如果上一个商品是图片集,需上报 浏览图片集结结束 事件
16796
- handleReportViewImageEnd(item);
16796
+ handleViewImageStartEnd(item);
16797
16797
  handleSlideSkip(item, swiper.previousIndex);
16798
16798
  }
16799
16799
  else {
@@ -16810,7 +16810,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16810
16810
  }
16811
16811
  });
16812
16812
  // 如果上一个商品是图片集,需上报 浏览图片集结结束 事件
16813
- handleReportViewImageEnd(item);
16813
+ handleViewImageStartEnd(item);
16814
16814
  }
16815
16815
  // 商品浏览事件
16816
16816
  handleReportProductView(item);
@@ -16831,7 +16831,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16831
16831
  viewTime.current = new Date();
16832
16832
  }
16833
16833
  }, [openHashtag, data, activeIndex]);
16834
- const handleViewImageStartEvent = (activeIndex, imgInfo) => {
16834
+ const handleViewImageStartEvent = (activeIndex, imgInfo, enableCapi) => {
16835
16835
  var _a, _b, _c, _d, _e, _f, _g, _h;
16836
16836
  const item = data[activeIndex];
16837
16837
  // 如果是图片集则上报事件
@@ -16853,29 +16853,35 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16853
16853
  loadTime: imgInfo === null || imgInfo === void 0 ? void 0 : imgInfo.loadTime
16854
16854
  }
16855
16855
  });
16856
- bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
16857
- eventName: 'ViewContent',
16858
- product: (_g = item === null || item === void 0 ? void 0 : item.video) === null || _g === void 0 ? void 0 : _g.bindProduct
16859
- });
16860
- bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
16861
- eventName: 'PageView',
16862
- product: (_h = item === null || item === void 0 ? void 0 : item.video) === null || _h === void 0 ? void 0 : _h.bindProduct
16863
- });
16856
+ if (enableCapi) {
16857
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
16858
+ eventName: 'ViewContent',
16859
+ product: (_g = item === null || item === void 0 ? void 0 : item.video) === null || _g === void 0 ? void 0 : _g.bindProduct
16860
+ });
16861
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
16862
+ eventName: 'PageView',
16863
+ product: (_h = item === null || item === void 0 ? void 0 : item.video) === null || _h === void 0 ? void 0 : _h.bindProduct
16864
+ });
16865
+ }
16864
16866
  }
16865
16867
  };
16866
16868
  const renderToggleButton = useCallback((visible) => {
16867
16869
  var _a, _b, _c, _d, _e, _f;
16868
16870
  if (!visible)
16869
16871
  return;
16872
+ let top = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconY) !== null && _a !== void 0 ? _a : 23;
16873
+ if (waterFallData && top < 40 && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconYPosit) === 'top') {
16874
+ top += 40;
16875
+ }
16870
16876
  return (((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowMute) === undefined || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowMute) === true) && (React.createElement(ToggleButton$1, { style: {
16871
16877
  position: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconFixed) ? 'fixed' : 'absolute',
16872
- visibility: ((_b = (_a = visList === null || visList === void 0 ? void 0 : visList[activeIndex]) === null || _a === void 0 ? void 0 : _a.video) === null || _b === void 0 ? void 0 : _b.url) ? 'visible' : 'hidden',
16878
+ visibility: ((_c = (_b = visList === null || visList === void 0 ? void 0 : visList[activeIndex]) === null || _b === void 0 ? void 0 : _b.video) === null || _c === void 0 ? void 0 : _c.url) ? 'visible' : 'hidden',
16873
16879
  zIndex: 999,
16874
16880
  transform: 'translate3d(0px,0px,0px)',
16875
- [(_c = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconXPosit) !== null && _c !== void 0 ? _c : 'right']: (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconX) !== null && _d !== void 0 ? _d : 0,
16876
- [(_e = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconYPosit) !== null && _e !== void 0 ? _e : 'bottom']: (_f = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconY) !== null && _f !== void 0 ? _f : 23
16881
+ [(_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconXPosit) !== null && _d !== void 0 ? _d : 'right']: (_e = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconX) !== null && _e !== void 0 ? _e : 0,
16882
+ [(_f = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconYPosit) !== null && _f !== void 0 ? _f : 'bottom']: top
16877
16883
  }, defaultValue: isMuted, activeIcon: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.unMuteIcon) ? globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.unMuteIcon : mutedIcon, unactiveIcon: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIcon) ? globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIcon : unmutedIcon, onChange: setIsMuted })));
16878
- }, [globalConfig, visList, activeIndex, isMuted]);
16884
+ }, [globalConfig, visList, activeIndex, isMuted, waterFallData]);
16879
16885
  const renderView = useMemo(() => {
16880
16886
  if (loading) {
16881
16887
  return (React.createElement("div", { style: { height, width: containerWidth, display: 'flex', justifyContent: 'center', alignItems: 'center' } },
@@ -16908,7 +16914,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16908
16914
  renderToggleButton
16909
16915
  ]);
16910
16916
  return (React.createElement("div", { id: 'sxp-render', className: 'clc-sxp-container', style: Object.assign({}, ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.textUnderlineOffset) && { textUnderlineOffset: `${globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.textUnderlineOffset}px` })) },
16911
- waterFallData && (React.createElement(Navbar$1, { icon: img, styles: { background: 'rgba(0,0,0,.3)', color: '#fff' }, textStyle: Object.assign(Object.assign({}, (_e = (_d = (_c = (_b = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.hashTag) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.item) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.textStyles) === null || _e === void 0 ? void 0 : _e.hashTagTitle), { color: '#fff' }), onClose: () => {
16917
+ waterFallData && (React.createElement(Navbar$1, { icon: img, styles: { background: 'rgba(0,0,0,.3)', color: '#fff', top: `${minusHeight}px` }, textStyle: Object.assign(Object.assign({}, (_e = (_d = (_c = (_b = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.hashTag) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.item) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.textStyles) === null || _e === void 0 ? void 0 : _e.hashTagTitle), { color: '#fff' }), onClose: () => {
16912
16918
  const isEq = isEqual(rtcList, cacheRtcList);
16913
16919
  if (!isEq && cacheRtcList && (cacheRtcList === null || cacheRtcList === void 0 ? void 0 : cacheRtcList.length)) {
16914
16920
  setRtcList === null || setRtcList === void 0 ? void 0 : setRtcList(cacheRtcList);