pb-sxp-ui 1.7.0 → 1.7.1

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.
Files changed (34) hide show
  1. package/dist/index.cjs +33 -93
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.css +1 -0
  4. package/dist/index.js +33 -93
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.min.cjs +3 -3
  7. package/dist/index.min.cjs.map +1 -1
  8. package/dist/index.min.js +3 -3
  9. package/dist/index.min.js.map +1 -1
  10. package/dist/pb-ui.js +33 -93
  11. package/dist/pb-ui.js.map +1 -1
  12. package/dist/pb-ui.min.js +3 -3
  13. package/dist/pb-ui.min.js.map +1 -1
  14. package/es/core/components/SxpPageRender/VideoWidget/index.js +5 -8
  15. package/es/core/components/SxpPageRender/WaterFall/index.js +1 -6
  16. package/es/core/components/SxpPageRender/index.d.ts +0 -1
  17. package/es/core/components/SxpPageRender/index.js +11 -7
  18. package/es/core/context/SxpDataSourceProvider.d.ts +4 -2
  19. package/es/core/context/SxpDataSourceProvider.js +11 -52
  20. package/es/materials/sxp/popup/CommodityDetail/index.js +1 -6
  21. package/es/materials/sxp/popup/CommodityDetailDiro/index.js +1 -6
  22. package/es/materials/sxp/popup/CommodityDetailDiroNew/index.js +1 -6
  23. package/es/materials/sxp/popup/CommodityList/index.js +2 -7
  24. package/lib/core/components/SxpPageRender/VideoWidget/index.js +5 -8
  25. package/lib/core/components/SxpPageRender/WaterFall/index.js +1 -6
  26. package/lib/core/components/SxpPageRender/index.d.ts +0 -1
  27. package/lib/core/components/SxpPageRender/index.js +11 -7
  28. package/lib/core/context/SxpDataSourceProvider.d.ts +4 -2
  29. package/lib/core/context/SxpDataSourceProvider.js +11 -52
  30. package/lib/materials/sxp/popup/CommodityDetail/index.js +1 -6
  31. package/lib/materials/sxp/popup/CommodityDetailDiro/index.js +1 -6
  32. package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.js +1 -6
  33. package/lib/materials/sxp/popup/CommodityList/index.js +1 -6
  34. package/package.json +1 -1
package/dist/pb-ui.js CHANGED
@@ -812,64 +812,23 @@
812
812
  type: 'beacon'
813
813
  });
814
814
  }, [bffFetch, curReqInfo, enableReportEvent, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview]);
815
- const bffFbReport = React.useCallback(({ eventName, product }) => {
816
- var _a, _b, _c, _d;
815
+ const bffFbReport = React.useCallback((_a) => {
816
+ var _b, _c, _d;
817
+ var { eventName, actionSource = 'website', eventSourceUrl = (_b = window === null || window === void 0 ? void 0 : window.location) === null || _b === void 0 ? void 0 : _b.href, externalId } = _a;
817
818
  if (!enableReportEvent || !enabledMetaConversionApi || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
818
819
  return;
819
820
  }
820
- let jsonParams = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _a === void 0 ? void 0 : _a[eventName];
821
+ const fakeUserId = storeAndLoadFeUserId();
821
822
  const urlParams = new URLSearchParams(window.location.search);
822
- const fbclid = urlParams === null || urlParams === void 0 ? void 0 : urlParams.get('fbclid');
823
- const fix_par = {
824
- event_source_url: (_b = window === null || window === void 0 ? void 0 : window.location) === null || _b === void 0 ? void 0 : _b.href,
825
- external_id: storeAndLoadFeUserId(),
826
- 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 : '',
827
- fbc: fbclid ? `fb.2.${new Date().getTime()}.${fbclid}` : '',
828
- fbp: getCookie('_fbp') ? `fb.2.${new Date().getTime()}.${getCookie('_fbp')}` : '',
829
- time: new Date().getTime()
830
- };
831
- const regex = /\{\{(.*?)\}\}/g;
832
- const getEventParams = (obj) => {
833
- if (!obj)
834
- return;
835
- if (obj instanceof Array) {
836
- obj === null || obj === void 0 ? void 0 : obj.map((item) => getEventParams(item));
837
- }
838
- else {
839
- for (const key in obj) {
840
- if (obj.hasOwnProperty(key)) {
841
- const value = obj === null || obj === void 0 ? void 0 : obj[key];
842
- if (typeof value === 'object') {
843
- getEventParams(value);
844
- }
845
- else if (typeof value === 'string') {
846
- const matches = value === null || value === void 0 ? void 0 : value.match(regex);
847
- if (matches) {
848
- matches.forEach((match) => {
849
- const prop = match.substring(2, match.length - 2);
850
- try {
851
- const replaceValue = new Function('fix_par', 'product', `return ${prop}`)(fix_par, product);
852
- if (replaceValue) {
853
- obj[key] = replaceValue;
854
- }
855
- else {
856
- delete obj[key];
857
- }
858
- }
859
- catch (error) {
860
- console.error('An error occurred:', error === null || error === void 0 ? void 0 : error.message);
861
- }
862
- });
863
- }
864
- }
865
- }
866
- }
867
- }
868
- };
869
- getEventParams(jsonParams);
823
+ const fbclid = urlParams.get('fbclid');
870
824
  return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/fb/events', {
871
825
  method: 'POST',
872
- body: jsonParams,
826
+ body: {
827
+ eventName,
828
+ actionSource,
829
+ eventSourceUrl,
830
+ userData: Object.assign(Object.assign(Object.assign({ externalId: fakeUserId }, (fbclid && { fbc: `fb.2.${new Date().getTime()}.${fbclid}` })), (getCookie('_fbp') && { fbp: `fb.2.${new Date().getTime()}.${getCookie('_fbp')}` })), { clientUserAgent: (_d = (_c = window === null || window === void 0 ? void 0 : window.navigator) === null || _c === void 0 ? void 0 : _c.userAgent) !== null && _d !== void 0 ? _d : '' })
831
+ },
873
832
  type: 'beacon'
874
833
  });
875
834
  }, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview]);
@@ -9398,14 +9357,9 @@
9398
9357
  React.useEffect(() => {
9399
9358
  if (!isPost) {
9400
9359
  bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
9401
- eventName: 'ProductView',
9402
- product
9360
+ eventName: 'ProductView'
9403
9361
  });
9404
9362
  }
9405
- bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
9406
- eventName: 'PageView',
9407
- product
9408
- });
9409
9363
  }, [isPost, bffFbReport]);
9410
9364
  React.useEffect(() => {
9411
9365
  const initTime = () => {
@@ -10284,12 +10238,7 @@
10284
10238
  React.useEffect(() => {
10285
10239
  if (!isPost) {
10286
10240
  bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
10287
- eventName: 'ProductView',
10288
- product
10289
- });
10290
- bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
10291
- eventName: 'PageView',
10292
- product
10241
+ eventName: 'ProductView'
10293
10242
  });
10294
10243
  }
10295
10244
  }, [isPost, bffFbReport]);
@@ -10914,7 +10863,7 @@ Made in Italy` })));
10914
10863
  const CommodityList$1 = (_a) => {
10915
10864
  var _b, _c, _d;
10916
10865
  var { style, isDefault, rec, viewTime, isPost, bottom_image, commodityStyles, buttonStyle, translateY = 0, commodityPicture, isExternalLink, onClick } = _a, props = __rest(_a, ["style", "isDefault", "rec", "viewTime", "isPost", "bottom_image", "commodityStyles", "buttonStyle", "translateY", "commodityPicture", "isExternalLink", "onClick"]);
10917
- const { sxpParameter, popupDetailData, setPopupDetailData, ctaEvent, globalConfig, bffFbReport } = useSxpDataSource();
10866
+ const { sxpParameter, popupDetailData, setPopupDetailData, ctaEvent, globalConfig } = useSxpDataSource();
10918
10867
  const { jumpToWeb } = useEventReport();
10919
10868
  const { popup } = useEditor();
10920
10869
  const recData = isPost ? rec : popupDetailData;
@@ -10944,11 +10893,6 @@ Made in Italy` })));
10944
10893
  onClick === null || onClick === void 0 ? void 0 : onClick();
10945
10894
  }
10946
10895
  }, popup === null || popup === void 0 ? void 0 : popup.duration);
10947
- React.useEffect(() => {
10948
- bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
10949
- eventName: 'PageView'
10950
- });
10951
- }, []);
10952
10896
  return (React.createElement("div", { className: css.css(Object.assign(Object.assign({}, style), { display: 'flex', flexDirection: 'column', gap: '10px', padding: '0 20px', marginTop: '50px', boxSizing: 'border-box' })) }, product === null || product === void 0 ? void 0 : product.map((item, index) => {
10953
10897
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
10954
10898
  return (React.createElement(React.Fragment, null, recData && !(item === null || item === void 0 ? void 0 : item.bindCta) ? null : (React.createElement("div", Object.assign({ key: index }, props, { className: css.css({
@@ -14466,22 +14410,17 @@ Made in Italy` })));
14466
14410
  * @Author: binruan@chatlabs.com
14467
14411
  * @Date: 2024-01-10 10:58:24
14468
14412
  * @LastEditors: binruan@chatlabs.com
14469
- * @LastEditTime: 2024-10-18 18:59:47
14413
+ * @LastEditTime: 2024-10-11 13:43:22
14470
14414
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\WaterFall\index.tsx
14471
14415
  *
14472
14416
  */
14473
14417
  const WaterFall = (props) => {
14474
14418
  var _a;
14475
- const { waterFallData, setOpenHashtag, openHashtag, swiperRef, setWaterFallData, cacheRtcList, setRtcList, cacheActiveIndex, rtcList, setCacheRtcList, setIsFromHashtag, isFromHashtag, bffEventReport, themeTag, selectTag, bffFbReport } = useSxpDataSource();
14419
+ const { waterFallData, setOpenHashtag, openHashtag, swiperRef, setWaterFallData, cacheRtcList, setRtcList, cacheActiveIndex, rtcList, setCacheRtcList, setIsFromHashtag, isFromHashtag, bffEventReport, themeTag, selectTag } = useSxpDataSource();
14476
14420
  const { backMainFeed } = useEventReport();
14477
14421
  React.useRef(null);
14478
14422
  const modalEleRef = React.useRef(null);
14479
14423
  const [viewTime, setViewTime] = React.useState();
14480
- React.useEffect(() => {
14481
- bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
14482
- eventName: 'PageView'
14483
- });
14484
- }, []);
14485
14424
  React.useEffect(() => {
14486
14425
  const parentNode = document.getElementById('sxp-render');
14487
14426
  const node = document.getElementById('water-fall');
@@ -15856,18 +15795,17 @@ Made in Italy` })));
15856
15795
  };
15857
15796
  }, [isActive]);
15858
15797
  React.useEffect(() => {
15859
- var _a, _b, _c, _d;
15798
+ var _a, _b;
15860
15799
  if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
15861
15800
  return;
15862
15801
  if (isActive) {
15863
15802
  bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
15864
- eventName: 'ViewContent',
15865
- 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
15803
+ eventName: 'ViewContent'
15866
15804
  });
15867
- (_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.play();
15805
+ (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
15868
15806
  }
15869
15807
  else {
15870
- (_d = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _d === void 0 ? void 0 : _d.pause();
15808
+ (_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.pause();
15871
15809
  }
15872
15810
  }, [isActive, isLoadFinish, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
15873
15811
  /*
@@ -15889,11 +15827,9 @@ Made in Italy` })));
15889
15827
  if (!isActive)
15890
15828
  return;
15891
15829
  const onShow = () => {
15892
- var _a, _b;
15893
15830
  handleClickVideo('start')();
15894
15831
  bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
15895
- eventName: 'ViewContent',
15896
- 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
15832
+ eventName: 'ViewContent'
15897
15833
  });
15898
15834
  };
15899
15835
  const onHide = handleClickVideo('pause');
@@ -16380,7 +16316,7 @@ Made in Italy` })));
16380
16316
  * @Author: binruan@chatlabs.com
16381
16317
  * @Date: 2024-01-15 19:03:09
16382
16318
  * @LastEditors: binruan@chatlabs.com
16383
- * @LastEditTime: 2024-10-18 18:54:40
16319
+ * @LastEditTime: 2024-10-17 17:16:42
16384
16320
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
16385
16321
  *
16386
16322
  */
@@ -16410,6 +16346,9 @@ Made in Italy` })));
16410
16346
  if ((data === null || data === void 0 ? void 0 : data.length) > 0) {
16411
16347
  const now = new Date();
16412
16348
  viewTime.current = now;
16349
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
16350
+ eventName: 'PageView'
16351
+ });
16413
16352
  }
16414
16353
  }, [data === null || data === void 0 ? void 0 : data.length]);
16415
16354
  const handleH5EnterLink = React.useCallback(() => {
@@ -16418,8 +16357,11 @@ Made in Italy` })));
16418
16357
  if (data.length > 0) {
16419
16358
  const now = new Date();
16420
16359
  viewTime.current = now;
16360
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
16361
+ eventName: 'PageView'
16362
+ });
16421
16363
  }
16422
- }, [data.length, h5EnterLink]);
16364
+ }, [data.length, bffFbReport, h5EnterLink]);
16423
16365
  React.useEffect(() => {
16424
16366
  var _a;
16425
16367
  if (!ctaType || (ctaType === null || ctaType === void 0 ? void 0 : ctaType.length) < 1)
@@ -16724,7 +16666,7 @@ Made in Italy` })));
16724
16666
  }
16725
16667
  };
16726
16668
  const handleScrollEvent = (swiper) => {
16727
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
16669
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
16728
16670
  const item = data[swiper.previousIndex];
16729
16671
  if (!item)
16730
16672
  return;
@@ -16771,8 +16713,7 @@ Made in Italy` })));
16771
16713
  const curItem = data[swiper.activeIndex];
16772
16714
  if (!((_r = curItem === null || curItem === void 0 ? void 0 : curItem.video) === null || _r === void 0 ? void 0 : _r.url) && !((_s = curItem === null || curItem === void 0 ? void 0 : curItem.video) === null || _s === void 0 ? void 0 : _s.imgUrls) && (curItem === null || curItem === void 0 ? void 0 : curItem.product)) {
16773
16715
  bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
16774
- eventName: 'ProductView',
16775
- product: (_t = curItem === null || curItem === void 0 ? void 0 : curItem.video) === null || _t === void 0 ? void 0 : _t.bindProduct
16716
+ eventName: 'ProductView'
16776
16717
  });
16777
16718
  }
16778
16719
  viewTime.current = new Date();
@@ -16793,7 +16734,7 @@ Made in Italy` })));
16793
16734
  }
16794
16735
  }, [openHashtag, data, activeIndex]);
16795
16736
  const handleViewImageStartEvent = (activeIndex) => {
16796
- var _a, _b, _c, _d, _e, _f, _g;
16737
+ var _a, _b, _c, _d, _e, _f;
16797
16738
  const item = data[activeIndex];
16798
16739
  // 如果是图片集则上报事件
16799
16740
  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)) {
@@ -16813,8 +16754,7 @@ Made in Italy` })));
16813
16754
  }
16814
16755
  });
16815
16756
  bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
16816
- eventName: 'ViewContent',
16817
- product: (_g = item === null || item === void 0 ? void 0 : item.video) === null || _g === void 0 ? void 0 : _g.bindProduct
16757
+ eventName: 'ViewContent'
16818
16758
  });
16819
16759
  }
16820
16760
  };