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.cjs CHANGED
@@ -830,17 +830,20 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
830
830
  });
831
831
  }, [bffFetch, curReqInfo, enableReportEvent, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview]);
832
832
  const bffFbReport = React.useCallback(({ eventName, product }) => {
833
- var _a, _b, _c, _d;
834
- if (!enableReportEvent || !enabledMetaConversionApi || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
833
+ var _a, _b, _c, _d, _e;
834
+ if (!enableReportEvent ||
835
+ !enabledMetaConversionApi ||
836
+ (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) ||
837
+ !((_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _a === void 0 ? void 0 : _a[eventName])) {
835
838
  return;
836
839
  }
837
- let jsonParams = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _a === void 0 ? void 0 : _a[eventName];
840
+ let jsonParams = JSON.parse(JSON.stringify((_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _b === void 0 ? void 0 : _b[eventName]));
838
841
  const urlParams = new URLSearchParams(window.location.search);
839
842
  const fbclid = urlParams === null || urlParams === void 0 ? void 0 : urlParams.get('fbclid');
840
843
  const fix_par = {
841
- event_source_url: (_b = window === null || window === void 0 ? void 0 : window.location) === null || _b === void 0 ? void 0 : _b.href,
844
+ event_source_url: (_c = window === null || window === void 0 ? void 0 : window.location) === null || _c === void 0 ? void 0 : _c.href,
842
845
  external_id: storeAndLoadFeUserId(),
843
- 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 : '',
846
+ 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 : '',
844
847
  fbc: fbclid ? `fb.2.${new Date().getTime()}.${fbclid}` : '',
845
848
  fbp: getCookie('_fbp') ? `fb.2.${new Date().getTime()}.${getCookie('_fbp')}` : '',
846
849
  time: new Date().getTime()
@@ -865,7 +868,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
865
868
  matches.forEach((match) => {
866
869
  const prop = match.substring(2, match.length - 2);
867
870
  try {
868
- const replaceValue = new Function('fix_par', 'product', `return ${prop}`)(fix_par, product);
871
+ let replaceValue = new Function('fix_par', 'product', `return ${prop}`)(fix_par, product);
869
872
  if (replaceValue) {
870
873
  obj[key] = replaceValue;
871
874
  }
@@ -15907,7 +15910,7 @@ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPost
15907
15910
  };
15908
15911
  }, [isActive]);
15909
15912
  React.useEffect(() => {
15910
- var _a, _b, _c, _d;
15913
+ var _a, _b, _c, _d, _e, _f;
15911
15914
  if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
15912
15915
  return;
15913
15916
  if (isActive) {
@@ -15915,10 +15918,14 @@ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPost
15915
15918
  eventName: 'ViewContent',
15916
15919
  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
15917
15920
  });
15918
- (_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.play();
15921
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
15922
+ eventName: 'PageView',
15923
+ 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
15924
+ });
15925
+ (_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.play();
15919
15926
  }
15920
15927
  else {
15921
- (_d = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _d === void 0 ? void 0 : _d.pause();
15928
+ (_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.pause();
15922
15929
  }
15923
15930
  }, [isActive, isLoadFinish, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
15924
15931
  /*
@@ -15940,12 +15947,7 @@ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPost
15940
15947
  if (!isActive)
15941
15948
  return;
15942
15949
  const onShow = () => {
15943
- var _a, _b;
15944
15950
  handleClickVideo('start')();
15945
- bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
15946
- eventName: 'ViewContent',
15947
- 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
15948
- });
15949
15951
  };
15950
15952
  const onHide = handleClickVideo('pause');
15951
15953
  SXP_EVENT_BUS.on(SXP_EVENT_TYPE.PAGE_DID_SHOW, onShow);
@@ -16116,7 +16118,7 @@ const Picture = (props) => {
16116
16118
  }, onLoad: onShowFirstImage }))));
16117
16119
  };
16118
16120
 
16119
- const PictureGroup$2 = ({ imgUrls, width, height, rec, index, onReportViewImageEnd, onViewImageStartEvent, imgUrlsPostConfig }) => {
16121
+ const PictureGroup$2 = ({ imgUrls, width, height, rec, index, onViewImageEndEvent, onViewImageStartEvent, imgUrlsPostConfig }) => {
16120
16122
  var _a, _b;
16121
16123
  const ref = React.useRef();
16122
16124
  const { isActive } = useSwiperSlide();
@@ -16128,16 +16130,16 @@ const PictureGroup$2 = ({ imgUrls, width, height, rec, index, onReportViewImageE
16128
16130
  if (isLoad && isActive) {
16129
16131
  (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.swiper.autoplay.start();
16130
16132
  if (openHashtag) {
16131
- onReportViewImageEnd(rec);
16133
+ onViewImageEndEvent(rec);
16132
16134
  }
16133
16135
  else {
16134
- onViewImageStartEvent(index, imgInfo);
16136
+ onViewImageStartEvent(index, imgInfo, true);
16135
16137
  }
16136
16138
  }
16137
16139
  else {
16138
16140
  (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.swiper.autoplay.stop();
16139
16141
  }
16140
- }, [rec, isActive, onReportViewImageEnd, openHashtag, index, onViewImageStartEvent, isLoad, imgInfo]);
16142
+ }, [rec, isActive, onViewImageEndEvent, openHashtag, index, onViewImageStartEvent, isLoad, imgInfo]);
16141
16143
  const showFirstImageFn = React.useCallback((e) => __awaiter(void 0, void 0, void 0, function* () {
16142
16144
  if (!isLoad) {
16143
16145
  const contentSize = yield getResFileSizeFromSrc(e.src);
@@ -16153,7 +16155,7 @@ const PictureGroup$2 = ({ imgUrls, width, height, rec, index, onReportViewImageE
16153
16155
  // }
16154
16156
  React.useEffect(() => {
16155
16157
  const onShow = () => onViewImageStartEvent(index, imgInfo);
16156
- const onHide = () => onReportViewImageEnd(rec);
16158
+ const onHide = () => onViewImageEndEvent(rec);
16157
16159
  SXP_EVENT_BUS.on(SXP_EVENT_TYPE.PAGE_DID_SHOW, onShow);
16158
16160
  SXP_EVENT_BUS.on(SXP_EVENT_TYPE.PAGE_DID_HIDE, onHide);
16159
16161
  return () => {
@@ -16299,7 +16301,7 @@ function withBindDataSource(Component) {
16299
16301
  * @Author: binruan@chatlabs.com
16300
16302
  * @Date: 2023-12-26 16:11:34
16301
16303
  * @LastEditors: binruan@chatlabs.com
16302
- * @LastEditTime: 2024-10-25 10:36:59
16304
+ * @LastEditTime: 2024-10-29 14:07:29
16303
16305
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\RenderCard.tsx
16304
16306
  *
16305
16307
  */
@@ -16446,7 +16448,7 @@ var Tagbar$1 = React.memo(Tagbar);
16446
16448
  * @Author: binruan@chatlabs.com
16447
16449
  * @Date: 2024-01-15 19:03:09
16448
16450
  * @LastEditors: binruan@chatlabs.com
16449
- * @LastEditTime: 2024-10-25 15:41:58
16451
+ * @LastEditTime: 2024-10-28 16:36:22
16450
16452
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
16451
16453
  *
16452
16454
  */
@@ -16516,7 +16518,6 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16516
16518
  // 移动端h5直接杀掉浏览器或宿主app时不会触发,pc端直接杀掉标签页时能触发
16517
16519
  if (repCond) {
16518
16520
  SXP_EVENT_BUS.emit(SXP_EVENT_TYPE.PAGE_DID_HIDE, item);
16519
- // handleReportViewImageEnd(item);
16520
16521
  handleReportProductView(item);
16521
16522
  }
16522
16523
  let fromKName = '';
@@ -16561,7 +16562,6 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16561
16562
  // 页面可见时触发,注意页面初始化时不会触发
16562
16563
  handleH5EnterLink();
16563
16564
  if (repCond) {
16564
- // handleViewImageStartEvent(activeIndex);
16565
16565
  SXP_EVENT_BUS.emit(SXP_EVENT_TYPE.PAGE_DID_SHOW, item);
16566
16566
  backMainFeed('external', selectTag);
16567
16567
  }
@@ -16646,7 +16646,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16646
16646
  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 }));
16647
16647
  }
16648
16648
  if ((_b = rec === null || rec === void 0 ? void 0 : rec.video) === null || _b === void 0 ? void 0 : _b.imgUrls) {
16649
- 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 }));
16649
+ 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 }));
16650
16650
  }
16651
16651
  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) {
16652
16652
  return (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _d === void 0 ? void 0 : _d.map((value, idx) => {
@@ -16720,7 +16720,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16720
16720
  if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLike) || !visible)
16721
16721
  return;
16722
16722
  let top = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconY) !== null && _a !== void 0 ? _a : 400;
16723
- if (waterFallData && top < 40) {
16723
+ if (waterFallData && top < 40 && globalConfig.likeIconYPosit === 'top') {
16724
16724
  top += 40;
16725
16725
  }
16726
16726
  if (rec === null || rec === void 0 ? void 0 : rec.video) {
@@ -16732,7 +16732,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16732
16732
  }
16733
16733
  return null;
16734
16734
  }, [globalConfig, waterFallData]);
16735
- const handleReportViewImageEnd = (item) => {
16735
+ const handleViewImageStartEnd = (item) => {
16736
16736
  var _a, _b, _c, _d, _e, _f;
16737
16737
  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)) {
16738
16738
  const endTime = Date.now();
@@ -16815,7 +16815,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16815
16815
  }
16816
16816
  });
16817
16817
  // 如果上一个商品是图片集,需上报 浏览图片集结结束 事件
16818
- handleReportViewImageEnd(item);
16818
+ handleViewImageStartEnd(item);
16819
16819
  handleSlideSkip(item, swiper.previousIndex);
16820
16820
  }
16821
16821
  else {
@@ -16832,7 +16832,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16832
16832
  }
16833
16833
  });
16834
16834
  // 如果上一个商品是图片集,需上报 浏览图片集结结束 事件
16835
- handleReportViewImageEnd(item);
16835
+ handleViewImageStartEnd(item);
16836
16836
  }
16837
16837
  // 商品浏览事件
16838
16838
  handleReportProductView(item);
@@ -16853,7 +16853,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16853
16853
  viewTime.current = new Date();
16854
16854
  }
16855
16855
  }, [openHashtag, data, activeIndex]);
16856
- const handleViewImageStartEvent = (activeIndex, imgInfo) => {
16856
+ const handleViewImageStartEvent = (activeIndex, imgInfo, enableCapi) => {
16857
16857
  var _a, _b, _c, _d, _e, _f, _g, _h;
16858
16858
  const item = data[activeIndex];
16859
16859
  // 如果是图片集则上报事件
@@ -16875,29 +16875,35 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16875
16875
  loadTime: imgInfo === null || imgInfo === void 0 ? void 0 : imgInfo.loadTime
16876
16876
  }
16877
16877
  });
16878
- bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
16879
- eventName: 'ViewContent',
16880
- product: (_g = item === null || item === void 0 ? void 0 : item.video) === null || _g === void 0 ? void 0 : _g.bindProduct
16881
- });
16882
- bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
16883
- eventName: 'PageView',
16884
- product: (_h = item === null || item === void 0 ? void 0 : item.video) === null || _h === void 0 ? void 0 : _h.bindProduct
16885
- });
16878
+ if (enableCapi) {
16879
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
16880
+ eventName: 'ViewContent',
16881
+ product: (_g = item === null || item === void 0 ? void 0 : item.video) === null || _g === void 0 ? void 0 : _g.bindProduct
16882
+ });
16883
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
16884
+ eventName: 'PageView',
16885
+ product: (_h = item === null || item === void 0 ? void 0 : item.video) === null || _h === void 0 ? void 0 : _h.bindProduct
16886
+ });
16887
+ }
16886
16888
  }
16887
16889
  };
16888
16890
  const renderToggleButton = React.useCallback((visible) => {
16889
16891
  var _a, _b, _c, _d, _e, _f;
16890
16892
  if (!visible)
16891
16893
  return;
16894
+ let top = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconY) !== null && _a !== void 0 ? _a : 23;
16895
+ if (waterFallData && top < 40 && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconYPosit) === 'top') {
16896
+ top += 40;
16897
+ }
16892
16898
  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: {
16893
16899
  position: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconFixed) ? 'fixed' : 'absolute',
16894
- 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',
16900
+ 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',
16895
16901
  zIndex: 999,
16896
16902
  transform: 'translate3d(0px,0px,0px)',
16897
- [(_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,
16898
- [(_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
16903
+ [(_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,
16904
+ [(_f = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconYPosit) !== null && _f !== void 0 ? _f : 'bottom']: top
16899
16905
  }, 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 })));
16900
- }, [globalConfig, visList, activeIndex, isMuted]);
16906
+ }, [globalConfig, visList, activeIndex, isMuted, waterFallData]);
16901
16907
  const renderView = React.useMemo(() => {
16902
16908
  if (loading) {
16903
16909
  return (React.createElement("div", { style: { height, width: containerWidth, display: 'flex', justifyContent: 'center', alignItems: 'center' } },
@@ -16930,7 +16936,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16930
16936
  renderToggleButton
16931
16937
  ]);
16932
16938
  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` })) },
16933
- 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: () => {
16939
+ 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: () => {
16934
16940
  const isEq = lodash.isEqual(rtcList, cacheRtcList);
16935
16941
  if (!isEq && cacheRtcList && (cacheRtcList === null || cacheRtcList === void 0 ? void 0 : cacheRtcList.length)) {
16936
16942
  setRtcList === null || setRtcList === void 0 ? void 0 : setRtcList(cacheRtcList);