pb-sxp-ui 1.15.12-alpha.7 → 1.15.13-alpha.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 (35) hide show
  1. package/dist/index.cjs +347 -53
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +345 -52
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.min.cjs +6 -6
  6. package/dist/index.min.cjs.map +1 -1
  7. package/dist/index.min.js +6 -6
  8. package/dist/index.min.js.map +1 -1
  9. package/dist/pb-ui.js +347 -53
  10. package/dist/pb-ui.js.map +1 -1
  11. package/dist/pb-ui.min.js +6 -6
  12. package/dist/pb-ui.min.js.map +1 -1
  13. package/es/core/components/DiyStoryPreview/PictureGroup.d.ts +16 -0
  14. package/es/core/components/DiyStoryPreview/PictureGroup.js +34 -0
  15. package/es/core/components/DiyStoryPreview/VideoWidget.d.ts +17 -0
  16. package/es/core/components/DiyStoryPreview/VideoWidget.js +193 -0
  17. package/es/core/components/DiyStoryPreview/index.d.ts +26 -0
  18. package/es/core/components/DiyStoryPreview/index.js +118 -0
  19. package/es/core/context/SxpDataSourceProvider.js +3 -7
  20. package/es/index.d.ts +1 -0
  21. package/es/index.js +1 -0
  22. package/lib/core/components/DiyStoryPreview/PictureGroup.d.ts +16 -0
  23. package/lib/core/components/DiyStoryPreview/PictureGroup.js +37 -0
  24. package/lib/core/components/DiyStoryPreview/VideoWidget.d.ts +17 -0
  25. package/lib/core/components/DiyStoryPreview/VideoWidget.js +196 -0
  26. package/lib/core/components/DiyStoryPreview/index.d.ts +26 -0
  27. package/lib/core/components/DiyStoryPreview/index.js +121 -0
  28. package/lib/core/context/SxpDataSourceProvider.js +3 -7
  29. package/lib/index.d.ts +1 -0
  30. package/lib/index.js +3 -1
  31. package/package.json +1 -2
  32. package/es/core/utils/cryptojs.d.ts +0 -3
  33. package/es/core/utils/cryptojs.js +0 -18
  34. package/lib/core/utils/cryptojs.d.ts +0 -3
  35. package/lib/core/utils/cryptojs.js +0 -23
package/dist/pb-ui.js CHANGED
@@ -37,7 +37,7 @@
37
37
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
38
38
  PERFORMANCE OF THIS SOFTWARE.
39
39
  ***************************************************************************** */
40
- /* global Reflect, Promise, SuppressedError, Symbol */
40
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
41
41
 
42
42
 
43
43
  function __rest(s, e) {
@@ -739,28 +739,9 @@
739
739
  // 事件上报优化
740
740
  // Beacon API 用于发送异步和非阻塞请求到服务器。这类请求不需要响应。
741
741
  if (options.type === 'beacon' && navigator.sendBeacon) {
742
- return navigator.sendBeacon(`${url}/api/${path}`, new Blob(
743
- // [
744
- // JSON.stringify({
745
- // body: encrypt(
746
- // JSON.stringify(
747
- // btoa(
748
- // encodeURIComponent(
749
- // JSON.stringify({ ...options.body, ...bffDataSource.headers, 'x-user-id': fakeUserId })
750
- // )
751
- // )
752
- // ),
753
- // 'dcAR82I0b8sgwCku'
754
- // )
755
- // })
756
- // ],
757
- [
758
- JSON.stringify({
759
- body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
760
- })
761
- ], {
762
- type: 'application/json;charset=UTF-8'
763
- }));
742
+ return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
743
+ JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))
744
+ ], { type: 'application/json;charset=UTF-8' }));
764
745
  }
765
746
  return window
766
747
  .fetch(`${url}/api/${path}`, {
@@ -921,7 +902,7 @@
921
902
  console.log('userInfo:', userInfo);
922
903
  console.log('eventInfo:', ef);
923
904
  console.log('========= 结束 =========');
924
- return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/cld/${(_b = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _b === void 0 ? void 0 : _b['x-app-id']}/${eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.eventSubject}${cl_source ? `/${decodeURIComponent(cl_source)}` : ''}`, {
905
+ return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/event/report/CLD/${(_b = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _b === void 0 ? void 0 : _b['x-app-id']}/${eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.eventSubject}`, {
925
906
  method: 'POST',
926
907
  body: { userInfo: realUserInfo, eventInfo: realEventInfo },
927
908
  type: 'beacon'
@@ -1498,7 +1479,7 @@
1498
1479
  React.createElement(DataSourceProvider$1, { isSsr: isSsr, enable: enableDataSource }, children)));
1499
1480
  });
1500
1481
 
1501
- var index$2 = /*#__PURE__*/Object.freeze({
1482
+ var index$3 = /*#__PURE__*/Object.freeze({
1502
1483
  __proto__: null,
1503
1484
  EditorCore: EditorCore
1504
1485
  });
@@ -17580,15 +17561,15 @@ Made in Italy` })));
17580
17561
  Swipe: Swipe
17581
17562
  });
17582
17563
 
17583
- const defaultUnLikeIconPath$1 = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
17584
- const defaultLikeIconPath$1 = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
17564
+ const defaultUnLikeIconPath$2 = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
17565
+ const defaultLikeIconPath$2 = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
17585
17566
  const LikeButton = (_a) => {
17586
17567
  var _b;
17587
17568
  var { active, activeIcon, unActicveIcon, recData, position } = _a, props = __rest(_a, ["active", "activeIcon", "unActicveIcon", "recData", "position"]);
17588
17569
  const { mutateLike, mutateUnlike, bffEventReport, setCacheRtcList, cacheRtcList } = useSxpDataSource();
17589
17570
  const [state, setState] = React.useState((_b = cacheRtcList === null || cacheRtcList === void 0 ? void 0 : cacheRtcList[position]) === null || _b === void 0 ? void 0 : _b.isCollected);
17590
- const likeIcon = useIconLink(defaultLikeIconPath$1);
17591
- const unlikeIcon = useIconLink(defaultUnLikeIconPath$1);
17571
+ const likeIcon = useIconLink(defaultLikeIconPath$2);
17572
+ const unlikeIcon = useIconLink(defaultUnLikeIconPath$2);
17592
17573
  const handleClick = lodash.debounce(() => __awaiter(void 0, void 0, void 0, function* () {
17593
17574
  var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
17594
17575
  if (state) {
@@ -17679,7 +17660,7 @@ Made in Italy` })));
17679
17660
  };
17680
17661
  })();
17681
17662
 
17682
- const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon }) => {
17663
+ const VideoWidget$4 = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon }) => {
17683
17664
  const [isPauseVideo, setIsPauseVideo] = React.useState(false);
17684
17665
  const { bffEventReport, sxpParameter, waterFallData, openHashtag, bffFbReport } = useSxpDataSource();
17685
17666
  const videoStartTime = React.useRef(0);
@@ -18024,7 +18005,7 @@ Made in Italy` })));
18024
18005
  renderLoading,
18025
18006
  isPauseVideo && React.createElement(FormatImage$1, { className: 'clc-pb-video-pause', src: videoPlayIcon !== null && videoPlayIcon !== void 0 ? videoPlayIcon : PAUSE_ICON, alt: 'pause' })))));
18026
18007
  };
18027
- var VideoWidget$3 = React.memo(VideoWidget$2);
18008
+ var VideoWidget$5 = React.memo(VideoWidget$4);
18028
18009
 
18029
18010
  const ToggleButton = ({ defaultValue, activeIcon, unactiveIcon, onChange, style }) => {
18030
18011
  const [isTrue, setIsTure] = React.useState(defaultValue);
@@ -18113,7 +18094,7 @@ Made in Italy` })));
18113
18094
  }, onLoad: onShowFirstImage }))));
18114
18095
  };
18115
18096
 
18116
- const PictureGroup$2 = ({ imgUrls, width, height, rec, index, onViewImageEndEvent, onViewImageStartEvent, imgUrlsPostConfig }) => {
18097
+ const PictureGroup$4 = ({ imgUrls, width, height, rec, index, onViewImageEndEvent, onViewImageStartEvent, imgUrlsPostConfig }) => {
18117
18098
  var _a, _b;
18118
18099
  const { isActive } = useSwiperSlide();
18119
18100
  const { sxpParameter, openHashtag } = useSxpDataSource();
@@ -18207,7 +18188,7 @@ Made in Italy` })));
18207
18188
  React.createElement(Picture, { src: !isLoad && srcKey > 0 ? '' : url, height: height, imgUrlsPostConfig: imgUrlsPostConfig, onShowFirstImage: showFirstImageFn })));
18208
18189
  }))));
18209
18190
  };
18210
- var PictureGroup$3 = React.memo(PictureGroup$2);
18191
+ var PictureGroup$5 = React.memo(PictureGroup$4);
18211
18192
 
18212
18193
  /*
18213
18194
  * @Author: binruan@chatlabs.com
@@ -18717,10 +18698,10 @@ Made in Italy` })));
18717
18698
  return (React.createElement(MultiPosts$2, Object.assign({ recData: data === null || data === void 0 ? void 0 : data[1] }, (_c = (_b = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.multiPosts) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.item) === null || _c === void 0 ? void 0 : _c.props, (_f = (_e = (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.multiPosts) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.item) === null || _f === void 0 ? void 0 : _f.event)));
18718
18699
  }
18719
18700
  if ((_g = rec === null || rec === void 0 ? void 0 : rec.video) === null || _g === void 0 ? void 0 : _g.url) {
18720
- 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 }));
18701
+ return (React.createElement(VideoWidget$5, { 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 }));
18721
18702
  }
18722
18703
  if ((_h = rec === null || rec === void 0 ? void 0 : rec.video) === null || _h === void 0 ? void 0 : _h.imgUrls) {
18723
- 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 }));
18704
+ return (React.createElement(PictureGroup$5, { 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 }));
18724
18705
  }
18725
18706
  if (rec.product && Array.isArray(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) && ((_j = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _j === void 0 ? void 0 : _j.length) > 0) {
18726
18707
  return (_k = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _k === void 0 ? void 0 : _k.map((value, idx) => {
@@ -19090,7 +19071,7 @@ Made in Italy` })));
19090
19071
  };
19091
19072
  var SxpPageRender$1 = React.memo(SxpPageRender);
19092
19073
 
19093
- const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index }) => {
19074
+ const PictureGroup$2 = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index }) => {
19094
19075
  return (React.createElement(Swiper, { defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: {
19095
19076
  clickable: true,
19096
19077
  bulletActiveClass: 'swipe-item-active-bullet',
@@ -19100,9 +19081,9 @@ Made in Italy` })));
19100
19081
  React.createElement(Picture, { src: url, height: height, imgUrlsPostConfig: imgUrlsPostConfig })));
19101
19082
  })));
19102
19083
  };
19103
- var PictureGroup$1 = React.memo(PictureGroup);
19084
+ var PictureGroup$3 = React.memo(PictureGroup$2);
19104
19085
 
19105
- const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width }) => {
19086
+ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width }) => {
19106
19087
  const [isPauseVideo, setIsPauseVideo] = React.useState(false);
19107
19088
  const videoRef = React.useRef(null);
19108
19089
  const { bffEventReport, sxpParameter, waterFallData, openHashtag } = useSxpDataSource();
@@ -19332,14 +19313,14 @@ Made in Italy` })));
19332
19313
  renderPoster,
19333
19314
  React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON, alt: 'video pause image' })))));
19334
19315
  };
19335
- var VideoWidget$1 = React.memo(VideoWidget);
19316
+ var VideoWidget$3 = React.memo(VideoWidget$2);
19336
19317
 
19337
- const RESOLVER$1 = {};
19318
+ const RESOLVER$2 = {};
19338
19319
  Object.values(_materials_).forEach((v) => {
19339
- RESOLVER$1[v.extend.type] = v;
19320
+ RESOLVER$2[v.extend.type] = v;
19340
19321
  });
19341
- const defaultUnLikeIconPath = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
19342
- const defaultLikeIconPath = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
19322
+ const defaultUnLikeIconPath$1 = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
19323
+ const defaultLikeIconPath$1 = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
19343
19324
  const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, descStyle, hashTagStyle, containerHeight = 664, containerWidth = 375, appDomain, tagList = [] }) => {
19344
19325
  const height = React.useMemo(() => {
19345
19326
  let minusHeight = 0;
@@ -19354,16 +19335,16 @@ Made in Italy` })));
19354
19335
  const renderContent = (rec, index) => {
19355
19336
  var _a, _b, _c, _d;
19356
19337
  if ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.url) {
19357
- return (React.createElement(VideoWidget$1, { rec: rec, index: index, muted: true, width: containerWidth, data: data !== null && data !== void 0 ? data : [], height: height, activeIndex: index, videoPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPost }));
19338
+ return (React.createElement(VideoWidget$3, { rec: rec, index: index, muted: true, width: containerWidth, data: data !== null && data !== void 0 ? data : [], height: height, activeIndex: index, videoPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPost }));
19358
19339
  }
19359
19340
  if ((_b = rec === null || rec === void 0 ? void 0 : rec.video) === null || _b === void 0 ? void 0 : _b.imgUrls) {
19360
- return (React.createElement(PictureGroup$1, { 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, imgUrlsPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.imgUrlsPost }));
19341
+ 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, imgUrlsPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.imgUrlsPost }));
19361
19342
  }
19362
19343
  if (rec.product) {
19363
19344
  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) {
19364
19345
  return (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _d === void 0 ? void 0 : _d.map((value, idx) => {
19365
19346
  var _a, _b, _c, _d, _e, _f, _g, _h;
19366
- const t = RESOLVER$1[(_a = value === null || value === void 0 ? void 0 : value.item) === null || _a === void 0 ? void 0 : _a.type];
19347
+ const t = RESOLVER$2[(_a = value === null || value === void 0 ? void 0 : value.item) === null || _a === void 0 ? void 0 : _a.type];
19367
19348
  const Component = withBindDataSource(t);
19368
19349
  const defaulSetting = (_b = t === null || t === void 0 ? void 0 : t.extend) === null || _b === void 0 ? void 0 : _b.defaulSetting;
19369
19350
  return (React.createElement(Component, Object.assign({ key: `${index}${idx}`, textStyle: Object.assign(Object.assign({}, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.textStyle), (_c = value === null || value === void 0 ? void 0 : value.item) === null || _c === void 0 ? void 0 : _c.textStyle), bindDatas: (_e = (_d = value === null || value === void 0 ? void 0 : value.item) === null || _d === void 0 ? void 0 : _d.bindDatas) !== null && _e !== void 0 ? _e : [] }, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.props, (_f = value === null || value === void 0 ? void 0 : value.item) === null || _f === void 0 ? void 0 : _f.props, { event: ((_g = value === null || value === void 0 ? void 0 : value.item) === null || _g === void 0 ? void 0 : _g.event) || {},
@@ -19385,7 +19366,7 @@ Made in Italy` })));
19385
19366
  const CTA = (rec, index) => {
19386
19367
  if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA) === undefined || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA)) {
19387
19368
  return (React.createElement("div", { className: 'clc-sxp-bottom-card' },
19388
- React.createElement(RenderCard$1, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER$1 })));
19369
+ React.createElement(RenderCard$1, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER$2 })));
19389
19370
  }
19390
19371
  return null;
19391
19372
  };
@@ -19403,8 +19384,8 @@ Made in Italy` })));
19403
19384
  }
19404
19385
  return null;
19405
19386
  };
19406
- const likeIcon = useIconLink(defaultLikeIconPath, appDomain);
19407
- const unlikeIcon = useIconLink(defaultUnLikeIconPath, appDomain);
19387
+ const likeIcon = useIconLink(defaultLikeIconPath$1, appDomain);
19388
+ const unlikeIcon = useIconLink(defaultUnLikeIconPath$1, appDomain);
19408
19389
  const renderLikeButton = (rec, index) => {
19409
19390
  var _a, _b, _c, _d;
19410
19391
  if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLike))
@@ -19452,7 +19433,319 @@ Made in Italy` })));
19452
19433
  return renderView(rec, index);
19453
19434
  })));
19454
19435
  };
19455
- var index$1 = React.memo(DiyPortalPreview);
19436
+ var index$2 = React.memo(DiyPortalPreview);
19437
+
19438
+ const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index, swiperRef, data = [], loopPlay }) => {
19439
+ const { isActive } = useSwiperSlide();
19440
+ const [isload, setIsLoad] = React.useState(false);
19441
+ React.useEffect(() => {
19442
+ if (isActive && isload && loopPlay) {
19443
+ setTimeout(() => {
19444
+ var _a, _b, _c, _d;
19445
+ if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
19446
+ (_a = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _a === void 0 ? void 0 : _a.swiper.slideTo(0);
19447
+ }
19448
+ else {
19449
+ const i = (_c = (_b = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _b === void 0 ? void 0 : _b.swiper) === null || _c === void 0 ? void 0 : _c.activeIndex;
19450
+ (_d = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _d === void 0 ? void 0 : _d.swiper.slideTo(i + 1);
19451
+ }
19452
+ }, 3000);
19453
+ }
19454
+ }, [isActive, isload, data, index, swiperRef, loopPlay]);
19455
+ const loadFinishImage = () => {
19456
+ setIsLoad(true);
19457
+ };
19458
+ return (React.createElement(Swiper, { defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: {
19459
+ clickable: true,
19460
+ bulletActiveClass: 'swipe-item-active-bullet',
19461
+ bulletElement: 'button'
19462
+ }, height: height, style: { width }, loop: true, autoplay: false }, imgUrls === null || imgUrls === void 0 ? void 0 : imgUrls.map((url) => {
19463
+ return (React.createElement(SwiperSlide, { key: url },
19464
+ React.createElement(Picture, { src: url, height: height, imgUrlsPostConfig: imgUrlsPostConfig, onShowFirstImage: loadFinishImage })));
19465
+ })));
19466
+ };
19467
+ var PictureGroup$1 = React.memo(PictureGroup);
19468
+
19469
+ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width, swiperRef, loopPlay }) => {
19470
+ const { isActive } = useSwiperSlide();
19471
+ const [isPauseVideo, setIsPauseVideo] = React.useState(false);
19472
+ const videoRef = React.useRef(null);
19473
+ const { bffEventReport, sxpParameter, waterFallData, openHashtag } = useSxpDataSource();
19474
+ const videoStartTime = React.useRef(0);
19475
+ const [isLoadFinish, setIsLoadFinish] = React.useState(false);
19476
+ const [isFirstPlay, setIsFirstPlay] = React.useState(true);
19477
+ const canvasRef = React.useRef(null);
19478
+ const [firstFrameSrc, setFirstFrameSrc] = React.useState('');
19479
+ const videoId = `pb-cache-video-${index}`;
19480
+ const hlsRef = React.useRef(null);
19481
+ React.useEffect(() => {
19482
+ if (!videoRef.current)
19483
+ return;
19484
+ videoRef.current.muted = muted;
19485
+ }, [muted]);
19486
+ React.useCallback(() => {
19487
+ var _a;
19488
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
19489
+ }, []);
19490
+ useIconLink('/pb_static/06f28a2025c74c1cb49be6767316d827.png');
19491
+ const handlePlaying = React.useCallback(() => {
19492
+ var _a, _b, _c, _d, _e, _f;
19493
+ setIsPauseVideo(false);
19494
+ const item = data[index];
19495
+ if (item && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration)) {
19496
+ videoStartTime.current = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.currentTime) || 0;
19497
+ ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 0).toFixed(2);
19498
+ ((_f = (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime) !== null && _f !== void 0 ? _f : 0).toFixed(2);
19499
+ setIsFirstPlay(false);
19500
+ }
19501
+ }, [bffEventReport, data, index, isFirstPlay]);
19502
+ const handleLoadedMetadata = React.useCallback(() => {
19503
+ var _a;
19504
+ (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
19505
+ setIsLoadFinish(true);
19506
+ }, []);
19507
+ React.useCallback((type) => () => {
19508
+ var _a, _b, _c, _d, _e;
19509
+ if (!isLoadFinish)
19510
+ return;
19511
+ const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
19512
+ switch (type) {
19513
+ case 'start':
19514
+ if (!isPause)
19515
+ return;
19516
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.play();
19517
+ setIsPauseVideo(false);
19518
+ break;
19519
+ case 'pause':
19520
+ if (isPause)
19521
+ return;
19522
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
19523
+ setIsPauseVideo(true);
19524
+ break;
19525
+ default:
19526
+ if (isPause) {
19527
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.play();
19528
+ }
19529
+ else {
19530
+ (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.pause();
19531
+ }
19532
+ setIsPauseVideo(!isPause);
19533
+ break;
19534
+ }
19535
+ }, [isLoadFinish]);
19536
+ React.useCallback(() => {
19537
+ var _a, _b, _c, _d, _e, _f;
19538
+ data[index];
19539
+ ((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.duration) !== null && _b !== void 0 ? _b : 0).toFixed(2);
19540
+ ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.currentTime) !== null && _d !== void 0 ? _d : 0).toFixed(2);
19541
+ if ((_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.duration) {
19542
+ (((_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.currentTime) - videoStartTime.current).toFixed(2);
19543
+ }
19544
+ }, [data, index, bffEventReport]);
19545
+ const blur = React.useMemo(() => {
19546
+ return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2';
19547
+ }, [videoPostConfig]);
19548
+ React.useMemo(() => {
19549
+ var _a;
19550
+ return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2'
19551
+ ? `translateY(-${50 + ((_a = videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.offsetTop) !== null && _a !== void 0 ? _a : 0)}%) translate3d(0px, 0px, 0px)`
19552
+ : 'translateY(-50%)';
19553
+ }, [videoPostConfig]);
19554
+ const handLoadeddata = React.useCallback(() => {
19555
+ if (!canvasRef || !videoRef || !videoRef.current || !canvasRef.current)
19556
+ return;
19557
+ const video = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current;
19558
+ const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
19559
+ const ctx = canvas.getContext('2d');
19560
+ const targetWidth = window === null || window === void 0 ? void 0 : window.innerWidth;
19561
+ const targetHeight = window === null || window === void 0 ? void 0 : window.innerHeight;
19562
+ canvas.height = targetHeight;
19563
+ canvas.width = targetWidth;
19564
+ ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
19565
+ setFirstFrameSrc(canvas.toDataURL());
19566
+ }, []);
19567
+ const handleTimeUpload = React.useCallback(() => {
19568
+ var _a, _b, _c;
19569
+ if (!videoRef.current)
19570
+ return;
19571
+ if (((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.currentTime) >= ((_b = rec === null || rec === void 0 ? void 0 : rec.endTime) !== null && _b !== void 0 ? _b : 0)) {
19572
+ (_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
19573
+ }
19574
+ }, []);
19575
+ const handlePause = () => {
19576
+ var _a, _b, _c, _d, _e, _f;
19577
+ if (!loopPlay)
19578
+ return;
19579
+ if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
19580
+ (_b = (_a = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _a === void 0 ? void 0 : _a.swiper) === null || _b === void 0 ? void 0 : _b.slideTo(0);
19581
+ }
19582
+ else {
19583
+ const i = (_d = (_c = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _c === void 0 ? void 0 : _c.swiper) === null || _d === void 0 ? void 0 : _d.activeIndex;
19584
+ (_f = (_e = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _e === void 0 ? void 0 : _e.swiper) === null || _f === void 0 ? void 0 : _f.slideTo(i + 1);
19585
+ }
19586
+ };
19587
+ // useEffect(() => {
19588
+ // if (!isActive) return;
19589
+ // if (!loopPlay) {
19590
+ // videoRef?.current?.pause();
19591
+ // } else {
19592
+ // videoRef?.current?.play();
19593
+ // }
19594
+ // }, [loopPlay, isActive]);
19595
+ React.useEffect(() => {
19596
+ var _a, _b, _c;
19597
+ if (!isActive)
19598
+ return;
19599
+ const videoSrc = rec === null || rec === void 0 ? void 0 : rec.mediaUrl;
19600
+ if (!videoSrc)
19601
+ return;
19602
+ setIsPauseVideo(false);
19603
+ const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
19604
+ if (!videoPlayerWrapperNode)
19605
+ return;
19606
+ videoRef.current = mountVideoPlayerAtNode === null || mountVideoPlayerAtNode === void 0 ? void 0 : mountVideoPlayerAtNode(videoPlayerWrapperNode);
19607
+ videoRef.current.currentTime = rec === null || rec === void 0 ? void 0 : rec.startTime;
19608
+ if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
19609
+ return;
19610
+ const Hls = window === null || window === void 0 ? void 0 : window.Hls;
19611
+ let hls = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current;
19612
+ if (videoSrc.includes('.m3u8') && Hls && Hls.isSupported()) {
19613
+ hls = new Hls();
19614
+ hls === null || hls === void 0 ? void 0 : hls.loadSource(videoSrc);
19615
+ hls === null || hls === void 0 ? void 0 : hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
19616
+ hls === null || hls === void 0 ? void 0 : hls.on(Hls.Events.MANIFEST_PARSED, function () {
19617
+ var _a;
19618
+ (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
19619
+ });
19620
+ }
19621
+ else {
19622
+ videoRef.current.src = videoSrc;
19623
+ }
19624
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('loadedmetadata', handleLoadedMetadata);
19625
+ // videoRef.current?.addEventListener('playing', handlePlaying);
19626
+ // videoRef.current?.addEventListener('loadeddata', handLoadeddata);
19627
+ (_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('pause', handlePause);
19628
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.addEventListener('timeupdate', handleTimeUpload);
19629
+ return () => {
19630
+ var _a, _b, _c, _d;
19631
+ if (hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current)
19632
+ (_a = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
19633
+ setIsLoadFinish(false);
19634
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('loadedmetadata', handleLoadedMetadata);
19635
+ // videoRef.current?.removeEventListener('playing', handlePlaying);
19636
+ // videoRef.current?.removeEventListener('loadeddata', handLoadeddata);
19637
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('pause', handlePause);
19638
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.removeEventListener('timeupdate', handleTimeUpload);
19639
+ };
19640
+ }, [handleLoadedMetadata, handlePlaying, rec, handLoadeddata, isActive]);
19641
+ React.useMemo(() => {
19642
+ if (!(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image) || isLoadFinish) {
19643
+ return null;
19644
+ }
19645
+ return (React.createElement("img", { style: { position: 'absolute', left: 0, top: 0, width: '100%', height: '100%', objectFit: 'cover' }, src: sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, alt: 'video poster' }));
19646
+ }, [isLoadFinish, sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image]);
19647
+ React.useMemo(() => {
19648
+ return blur
19649
+ ? {
19650
+ filter: 'blur(10px)',
19651
+ transform: 'translate3d(0px, 0px, 0px) scale(1.2)'
19652
+ }
19653
+ : {};
19654
+ }, [blur]);
19655
+ if (!(rec === null || rec === void 0 ? void 0 : rec.mediaUrl)) {
19656
+ return null;
19657
+ }
19658
+ return (React.createElement("div", { className: 'video-container', key: rec.itemId, style: {
19659
+ position: 'relative',
19660
+ width: '100%',
19661
+ height,
19662
+ overflow: 'hidden',
19663
+ pointerEvents: 'none'
19664
+ } },
19665
+ React.createElement("div", { className: 'n-full-screen', id: videoId, style: { width: '100%', height: '100%' } })));
19666
+ };
19667
+ var VideoWidget$1 = React.memo(VideoWidget);
19668
+
19669
+ /*
19670
+ * @Author: binruan@chatlabs.com
19671
+ * @Date: 2025-03-25 13:54:27
19672
+ * @LastEditors: binruan@chatlabs.com
19673
+ * @LastEditTime: 2025-03-26 15:01:42
19674
+ * @FilePath: \pb-sxp-ui\src\core\components\DiyStoryPreview\index.tsx
19675
+ *
19676
+ */
19677
+ const RESOLVER$1 = {};
19678
+ Object.values(_materials_).forEach((v) => {
19679
+ RESOLVER$1[v.extend.type] = v;
19680
+ });
19681
+ const defaultUnLikeIconPath = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
19682
+ const defaultLikeIconPath = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
19683
+ const DiyStoryPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, descStyle, hashTagStyle, containerHeight = 664, containerWidth = 375, appDomain, tagList = [], scenes, onActiveChange, activeIndex, loopPlay = false }) => {
19684
+ const swiperRef = React.useRef(null);
19685
+ React.useMemo(() => {
19686
+ let minusHeight = 0;
19687
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
19688
+ minusHeight += 45;
19689
+ }
19690
+ if (tagList.length > 0) {
19691
+ minusHeight += 45;
19692
+ }
19693
+ return containerHeight - minusHeight;
19694
+ }, [globalConfig, containerHeight, tagList]);
19695
+ // 判断是否是视频
19696
+ const isVideoUrl = (url) => {
19697
+ if (url && url !== '' && typeof url === 'string') {
19698
+ const imageExtensions = ['.mp4', '.m3u8'];
19699
+ const lowerCaseUrl = url === null || url === void 0 ? void 0 : url.toLowerCase();
19700
+ return imageExtensions.some((ext) => lowerCaseUrl === null || lowerCaseUrl === void 0 ? void 0 : lowerCaseUrl.endsWith(ext));
19701
+ }
19702
+ else {
19703
+ return false;
19704
+ }
19705
+ };
19706
+ const renderContent = (rec, index) => {
19707
+ const isVideo = isVideoUrl(rec === null || rec === void 0 ? void 0 : rec.mediaUrl);
19708
+ if (isVideo) {
19709
+ return (React.createElement(VideoWidget$1, { rec: rec, index: index, muted: true, width: containerWidth, data: scenes !== null && scenes !== void 0 ? scenes : [], height: containerHeight, activeIndex: index, videoPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPost, swiperRef: swiperRef, loopPlay: loopPlay }));
19710
+ }
19711
+ else {
19712
+ return (React.createElement(PictureGroup$1, { key: rec.itemId, imgUrls: [rec === null || rec === void 0 ? void 0 : rec.mediaUrl], width: containerWidth, height: containerHeight, rec: rec, index: index, imgUrlsPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.imgUrlsPost, data: scenes !== null && scenes !== void 0 ? scenes : [], swiperRef: swiperRef, loopPlay: loopPlay }));
19713
+ }
19714
+ };
19715
+ React.useMemo(() => {
19716
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
19717
+ return (React.createElement("div", { className: 'clc-sxp-logo-banner', style: { backgroundColor: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.color } },
19718
+ React.createElement("img", { src: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl, alt: 'logo' })));
19719
+ }
19720
+ return null;
19721
+ }, [globalConfig]);
19722
+ useIconLink(defaultLikeIconPath, appDomain);
19723
+ useIconLink(defaultUnLikeIconPath, appDomain);
19724
+ useIconLink('/pb_static/5beaaa5ce7f3477b99db3838619cc471.png', appDomain);
19725
+ useIconLink('/pb_static/fea8668a8a894e4aa3a86bcc775e895e.png', appDomain);
19726
+ const renderView = (rec, index) => {
19727
+ return (React.createElement(SwiperSlide, { key: index, virtualIndex: index, style: { overflow: 'hidden', position: 'relative' } }, renderContent(rec, index)));
19728
+ };
19729
+ React.useEffect(() => {
19730
+ var _a, _b;
19731
+ if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
19732
+ return;
19733
+ (_b = (_a = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _a === void 0 ? void 0 : _a.swiper) === null || _b === void 0 ? void 0 : _b.slideTo(activeIndex);
19734
+ }, [activeIndex]);
19735
+ React.useEffect(() => {
19736
+ var _a, _b;
19737
+ if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
19738
+ return;
19739
+ (_b = (_a = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _a === void 0 ? void 0 : _a.swiper) === null || _b === void 0 ? void 0 : _b.slideTo(0);
19740
+ }, [loopPlay]);
19741
+ return (React.createElement(Swiper, { ref: swiperRef, allowTouchMove: false, onActiveIndexChange: (swiper) => {
19742
+ // setActiveIndex(swiper.activeIndex);
19743
+ onActiveChange === null || onActiveChange === void 0 ? void 0 : onActiveChange(swiper.activeIndex);
19744
+ }, direction: 'vertical', style: { overflow: 'hidden', height: containerHeight } }, scenes === null || scenes === void 0 ? void 0 : scenes.map((rec, index) => {
19745
+ return renderView(rec, index);
19746
+ })));
19747
+ };
19748
+ var index$1 = React.memo(DiyStoryPreview);
19456
19749
 
19457
19750
  /*
19458
19751
  * @Author: binruan@chatlabs.com
@@ -19591,17 +19884,18 @@ Made in Italy` })));
19591
19884
  * @Author : haocanweng@chatlabs.cn
19592
19885
  * @Date : 2023-08-21 16:31:58
19593
19886
  * @LastEditors: binruan@chatlabs.com
19594
- * @LastEditTime: 2024-06-25 11:37:48
19887
+ * @LastEditTime: 2025-03-25 14:31:53
19595
19888
  * @FilePath: \pb-sxp-ui\src\index.ts
19596
19889
  */
19597
19890
 
19598
- exports.DiyPortalPreview = index$1;
19891
+ exports.DiyPortalPreview = index$2;
19892
+ exports.DiyStoryPreview = index$1;
19599
19893
  exports.EditorDataProvider = EditorDataProvider;
19600
19894
  exports.Modal = Modal$1;
19601
19895
  exports.SxpDataSourceProvider = SxpDataSourceProvider$1;
19602
19896
  exports.SxpPageCore = index;
19603
19897
  exports.SxpPageRender = SxpPageRender$1;
19604
- exports.core = index$2;
19898
+ exports.core = index$3;
19605
19899
  exports.default = Pagebuilder;
19606
19900
  exports.materials = _materials_;
19607
19901
  exports.useEditorDataProvider = useEditorDataProvider;