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/index.cjs CHANGED
@@ -44,7 +44,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
44
44
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
45
45
  PERFORMANCE OF THIS SOFTWARE.
46
46
  ***************************************************************************** */
47
- /* global Reflect, Promise, SuppressedError, Symbol */
47
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
48
48
 
49
49
 
50
50
  function __rest(s, e) {
@@ -746,28 +746,9 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
746
746
  // 事件上报优化
747
747
  // Beacon API 用于发送异步和非阻塞请求到服务器。这类请求不需要响应。
748
748
  if (options.type === 'beacon' && navigator.sendBeacon) {
749
- return navigator.sendBeacon(`${url}/api/${path}`, new Blob(
750
- // [
751
- // JSON.stringify({
752
- // body: encrypt(
753
- // JSON.stringify(
754
- // btoa(
755
- // encodeURIComponent(
756
- // JSON.stringify({ ...options.body, ...bffDataSource.headers, 'x-user-id': fakeUserId })
757
- // )
758
- // )
759
- // ),
760
- // 'dcAR82I0b8sgwCku'
761
- // )
762
- // })
763
- // ],
764
- [
765
- JSON.stringify({
766
- body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
767
- })
768
- ], {
769
- type: 'application/json;charset=UTF-8'
770
- }));
749
+ return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
750
+ JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))
751
+ ], { type: 'application/json;charset=UTF-8' }));
771
752
  }
772
753
  return window
773
754
  .fetch(`${url}/api/${path}`, {
@@ -928,7 +909,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
928
909
  console.log('userInfo:', userInfo);
929
910
  console.log('eventInfo:', ef);
930
911
  console.log('========= 结束 =========');
931
- 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)}` : ''}`, {
912
+ 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}`, {
932
913
  method: 'POST',
933
914
  body: { userInfo: realUserInfo, eventInfo: realEventInfo },
934
915
  type: 'beacon'
@@ -1505,7 +1486,7 @@ const EditorCore = React.forwardRef(({ children, resolver, isSsr, schema, enable
1505
1486
  React.createElement(DataSourceProvider$1, { isSsr: isSsr, enable: enableDataSource }, children)));
1506
1487
  });
1507
1488
 
1508
- var index$2 = /*#__PURE__*/Object.freeze({
1489
+ var index$3 = /*#__PURE__*/Object.freeze({
1509
1490
  __proto__: null,
1510
1491
  EditorCore: EditorCore
1511
1492
  });
@@ -17587,15 +17568,15 @@ var _materials_ = /*#__PURE__*/Object.freeze({
17587
17568
  Swipe: Swipe
17588
17569
  });
17589
17570
 
17590
- const defaultUnLikeIconPath$1 = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
17591
- const defaultLikeIconPath$1 = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
17571
+ const defaultUnLikeIconPath$2 = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
17572
+ const defaultLikeIconPath$2 = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
17592
17573
  const LikeButton = (_a) => {
17593
17574
  var _b;
17594
17575
  var { active, activeIcon, unActicveIcon, recData, position } = _a, props = __rest(_a, ["active", "activeIcon", "unActicveIcon", "recData", "position"]);
17595
17576
  const { mutateLike, mutateUnlike, bffEventReport, setCacheRtcList, cacheRtcList } = useSxpDataSource();
17596
17577
  const [state, setState] = React.useState((_b = cacheRtcList === null || cacheRtcList === void 0 ? void 0 : cacheRtcList[position]) === null || _b === void 0 ? void 0 : _b.isCollected);
17597
- const likeIcon = useIconLink(defaultLikeIconPath$1);
17598
- const unlikeIcon = useIconLink(defaultUnLikeIconPath$1);
17578
+ const likeIcon = useIconLink(defaultLikeIconPath$2);
17579
+ const unlikeIcon = useIconLink(defaultUnLikeIconPath$2);
17599
17580
  const handleClick = lodash.debounce(() => __awaiter(void 0, void 0, void 0, function* () {
17600
17581
  var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
17601
17582
  if (state) {
@@ -17686,7 +17667,7 @@ const mountVideoPlayerAtNode = (() => {
17686
17667
  };
17687
17668
  })();
17688
17669
 
17689
- const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon }) => {
17670
+ const VideoWidget$4 = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon }) => {
17690
17671
  const [isPauseVideo, setIsPauseVideo] = React.useState(false);
17691
17672
  const { bffEventReport, sxpParameter, waterFallData, openHashtag, bffFbReport } = useSxpDataSource();
17692
17673
  const videoStartTime = React.useRef(0);
@@ -18031,7 +18012,7 @@ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPost
18031
18012
  renderLoading,
18032
18013
  isPauseVideo && React.createElement(FormatImage$1, { className: 'clc-pb-video-pause', src: videoPlayIcon !== null && videoPlayIcon !== void 0 ? videoPlayIcon : PAUSE_ICON, alt: 'pause' })))));
18033
18014
  };
18034
- var VideoWidget$3 = React.memo(VideoWidget$2);
18015
+ var VideoWidget$5 = React.memo(VideoWidget$4);
18035
18016
 
18036
18017
  const ToggleButton = ({ defaultValue, activeIcon, unactiveIcon, onChange, style }) => {
18037
18018
  const [isTrue, setIsTure] = React.useState(defaultValue);
@@ -18120,7 +18101,7 @@ const Picture = (props) => {
18120
18101
  }, onLoad: onShowFirstImage }))));
18121
18102
  };
18122
18103
 
18123
- const PictureGroup$2 = ({ imgUrls, width, height, rec, index, onViewImageEndEvent, onViewImageStartEvent, imgUrlsPostConfig }) => {
18104
+ const PictureGroup$4 = ({ imgUrls, width, height, rec, index, onViewImageEndEvent, onViewImageStartEvent, imgUrlsPostConfig }) => {
18124
18105
  var _a, _b;
18125
18106
  const { isActive } = useSwiperSlide();
18126
18107
  const { sxpParameter, openHashtag } = useSxpDataSource();
@@ -18214,7 +18195,7 @@ const PictureGroup$2 = ({ imgUrls, width, height, rec, index, onViewImageEndEven
18214
18195
  React.createElement(Picture, { src: !isLoad && srcKey > 0 ? '' : url, height: height, imgUrlsPostConfig: imgUrlsPostConfig, onShowFirstImage: showFirstImageFn })));
18215
18196
  }))));
18216
18197
  };
18217
- var PictureGroup$3 = React.memo(PictureGroup$2);
18198
+ var PictureGroup$5 = React.memo(PictureGroup$4);
18218
18199
 
18219
18200
  /*
18220
18201
  * @Author: binruan@chatlabs.com
@@ -18724,10 +18705,10 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
18724
18705
  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)));
18725
18706
  }
18726
18707
  if ((_g = rec === null || rec === void 0 ? void 0 : rec.video) === null || _g === void 0 ? void 0 : _g.url) {
18727
- 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 }));
18708
+ 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 }));
18728
18709
  }
18729
18710
  if ((_h = rec === null || rec === void 0 ? void 0 : rec.video) === null || _h === void 0 ? void 0 : _h.imgUrls) {
18730
- 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 }));
18711
+ 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 }));
18731
18712
  }
18732
18713
  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) {
18733
18714
  return (_k = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _k === void 0 ? void 0 : _k.map((value, idx) => {
@@ -19097,7 +19078,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19097
19078
  };
19098
19079
  var SxpPageRender$1 = React.memo(SxpPageRender);
19099
19080
 
19100
- const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index }) => {
19081
+ const PictureGroup$2 = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index }) => {
19101
19082
  return (React.createElement(Swiper, { defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: {
19102
19083
  clickable: true,
19103
19084
  bulletActiveClass: 'swipe-item-active-bullet',
@@ -19107,9 +19088,9 @@ const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index })
19107
19088
  React.createElement(Picture, { src: url, height: height, imgUrlsPostConfig: imgUrlsPostConfig })));
19108
19089
  })));
19109
19090
  };
19110
- var PictureGroup$1 = React.memo(PictureGroup);
19091
+ var PictureGroup$3 = React.memo(PictureGroup$2);
19111
19092
 
19112
- const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width }) => {
19093
+ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width }) => {
19113
19094
  const [isPauseVideo, setIsPauseVideo] = React.useState(false);
19114
19095
  const videoRef = React.useRef(null);
19115
19096
  const { bffEventReport, sxpParameter, waterFallData, openHashtag } = useSxpDataSource();
@@ -19339,14 +19320,14 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
19339
19320
  renderPoster,
19340
19321
  React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON, alt: 'video pause image' })))));
19341
19322
  };
19342
- var VideoWidget$1 = React.memo(VideoWidget);
19323
+ var VideoWidget$3 = React.memo(VideoWidget$2);
19343
19324
 
19344
- const RESOLVER$1 = {};
19325
+ const RESOLVER$2 = {};
19345
19326
  Object.values(_materials_).forEach((v) => {
19346
- RESOLVER$1[v.extend.type] = v;
19327
+ RESOLVER$2[v.extend.type] = v;
19347
19328
  });
19348
- const defaultUnLikeIconPath = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
19349
- const defaultLikeIconPath = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
19329
+ const defaultUnLikeIconPath$1 = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
19330
+ const defaultLikeIconPath$1 = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
19350
19331
  const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, descStyle, hashTagStyle, containerHeight = 664, containerWidth = 375, appDomain, tagList = [] }) => {
19351
19332
  const height = React.useMemo(() => {
19352
19333
  let minusHeight = 0;
@@ -19361,16 +19342,16 @@ const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, de
19361
19342
  const renderContent = (rec, index) => {
19362
19343
  var _a, _b, _c, _d;
19363
19344
  if ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.url) {
19364
- 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 }));
19345
+ 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 }));
19365
19346
  }
19366
19347
  if ((_b = rec === null || rec === void 0 ? void 0 : rec.video) === null || _b === void 0 ? void 0 : _b.imgUrls) {
19367
- 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 }));
19348
+ 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 }));
19368
19349
  }
19369
19350
  if (rec.product) {
19370
19351
  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) {
19371
19352
  return (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _d === void 0 ? void 0 : _d.map((value, idx) => {
19372
19353
  var _a, _b, _c, _d, _e, _f, _g, _h;
19373
- const t = RESOLVER$1[(_a = value === null || value === void 0 ? void 0 : value.item) === null || _a === void 0 ? void 0 : _a.type];
19354
+ const t = RESOLVER$2[(_a = value === null || value === void 0 ? void 0 : value.item) === null || _a === void 0 ? void 0 : _a.type];
19374
19355
  const Component = withBindDataSource(t);
19375
19356
  const defaulSetting = (_b = t === null || t === void 0 ? void 0 : t.extend) === null || _b === void 0 ? void 0 : _b.defaulSetting;
19376
19357
  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) || {},
@@ -19392,7 +19373,7 @@ const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, de
19392
19373
  const CTA = (rec, index) => {
19393
19374
  if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA) === undefined || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA)) {
19394
19375
  return (React.createElement("div", { className: 'clc-sxp-bottom-card' },
19395
- React.createElement(RenderCard$1, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER$1 })));
19376
+ React.createElement(RenderCard$1, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER$2 })));
19396
19377
  }
19397
19378
  return null;
19398
19379
  };
@@ -19410,8 +19391,8 @@ const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, de
19410
19391
  }
19411
19392
  return null;
19412
19393
  };
19413
- const likeIcon = useIconLink(defaultLikeIconPath, appDomain);
19414
- const unlikeIcon = useIconLink(defaultUnLikeIconPath, appDomain);
19394
+ const likeIcon = useIconLink(defaultLikeIconPath$1, appDomain);
19395
+ const unlikeIcon = useIconLink(defaultUnLikeIconPath$1, appDomain);
19415
19396
  const renderLikeButton = (rec, index) => {
19416
19397
  var _a, _b, _c, _d;
19417
19398
  if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLike))
@@ -19459,7 +19440,319 @@ const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, de
19459
19440
  return renderView(rec, index);
19460
19441
  })));
19461
19442
  };
19462
- var index$1 = React.memo(DiyPortalPreview);
19443
+ var index$2 = React.memo(DiyPortalPreview);
19444
+
19445
+ const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index, swiperRef, data = [], loopPlay }) => {
19446
+ const { isActive } = useSwiperSlide();
19447
+ const [isload, setIsLoad] = React.useState(false);
19448
+ React.useEffect(() => {
19449
+ if (isActive && isload && loopPlay) {
19450
+ setTimeout(() => {
19451
+ var _a, _b, _c, _d;
19452
+ if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
19453
+ (_a = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _a === void 0 ? void 0 : _a.swiper.slideTo(0);
19454
+ }
19455
+ else {
19456
+ 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;
19457
+ (_d = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _d === void 0 ? void 0 : _d.swiper.slideTo(i + 1);
19458
+ }
19459
+ }, 3000);
19460
+ }
19461
+ }, [isActive, isload, data, index, swiperRef, loopPlay]);
19462
+ const loadFinishImage = () => {
19463
+ setIsLoad(true);
19464
+ };
19465
+ return (React.createElement(Swiper, { defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: {
19466
+ clickable: true,
19467
+ bulletActiveClass: 'swipe-item-active-bullet',
19468
+ bulletElement: 'button'
19469
+ }, height: height, style: { width }, loop: true, autoplay: false }, imgUrls === null || imgUrls === void 0 ? void 0 : imgUrls.map((url) => {
19470
+ return (React.createElement(SwiperSlide, { key: url },
19471
+ React.createElement(Picture, { src: url, height: height, imgUrlsPostConfig: imgUrlsPostConfig, onShowFirstImage: loadFinishImage })));
19472
+ })));
19473
+ };
19474
+ var PictureGroup$1 = React.memo(PictureGroup);
19475
+
19476
+ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width, swiperRef, loopPlay }) => {
19477
+ const { isActive } = useSwiperSlide();
19478
+ const [isPauseVideo, setIsPauseVideo] = React.useState(false);
19479
+ const videoRef = React.useRef(null);
19480
+ const { bffEventReport, sxpParameter, waterFallData, openHashtag } = useSxpDataSource();
19481
+ const videoStartTime = React.useRef(0);
19482
+ const [isLoadFinish, setIsLoadFinish] = React.useState(false);
19483
+ const [isFirstPlay, setIsFirstPlay] = React.useState(true);
19484
+ const canvasRef = React.useRef(null);
19485
+ const [firstFrameSrc, setFirstFrameSrc] = React.useState('');
19486
+ const videoId = `pb-cache-video-${index}`;
19487
+ const hlsRef = React.useRef(null);
19488
+ React.useEffect(() => {
19489
+ if (!videoRef.current)
19490
+ return;
19491
+ videoRef.current.muted = muted;
19492
+ }, [muted]);
19493
+ React.useCallback(() => {
19494
+ var _a;
19495
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
19496
+ }, []);
19497
+ useIconLink('/pb_static/06f28a2025c74c1cb49be6767316d827.png');
19498
+ const handlePlaying = React.useCallback(() => {
19499
+ var _a, _b, _c, _d, _e, _f;
19500
+ setIsPauseVideo(false);
19501
+ const item = data[index];
19502
+ if (item && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration)) {
19503
+ videoStartTime.current = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.currentTime) || 0;
19504
+ ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 0).toFixed(2);
19505
+ ((_f = (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime) !== null && _f !== void 0 ? _f : 0).toFixed(2);
19506
+ setIsFirstPlay(false);
19507
+ }
19508
+ }, [bffEventReport, data, index, isFirstPlay]);
19509
+ const handleLoadedMetadata = React.useCallback(() => {
19510
+ var _a;
19511
+ (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
19512
+ setIsLoadFinish(true);
19513
+ }, []);
19514
+ React.useCallback((type) => () => {
19515
+ var _a, _b, _c, _d, _e;
19516
+ if (!isLoadFinish)
19517
+ return;
19518
+ const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
19519
+ switch (type) {
19520
+ case 'start':
19521
+ if (!isPause)
19522
+ return;
19523
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.play();
19524
+ setIsPauseVideo(false);
19525
+ break;
19526
+ case 'pause':
19527
+ if (isPause)
19528
+ return;
19529
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
19530
+ setIsPauseVideo(true);
19531
+ break;
19532
+ default:
19533
+ if (isPause) {
19534
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.play();
19535
+ }
19536
+ else {
19537
+ (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.pause();
19538
+ }
19539
+ setIsPauseVideo(!isPause);
19540
+ break;
19541
+ }
19542
+ }, [isLoadFinish]);
19543
+ React.useCallback(() => {
19544
+ var _a, _b, _c, _d, _e, _f;
19545
+ data[index];
19546
+ ((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.duration) !== null && _b !== void 0 ? _b : 0).toFixed(2);
19547
+ ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.currentTime) !== null && _d !== void 0 ? _d : 0).toFixed(2);
19548
+ if ((_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.duration) {
19549
+ (((_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.currentTime) - videoStartTime.current).toFixed(2);
19550
+ }
19551
+ }, [data, index, bffEventReport]);
19552
+ const blur = React.useMemo(() => {
19553
+ return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2';
19554
+ }, [videoPostConfig]);
19555
+ React.useMemo(() => {
19556
+ var _a;
19557
+ return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2'
19558
+ ? `translateY(-${50 + ((_a = videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.offsetTop) !== null && _a !== void 0 ? _a : 0)}%) translate3d(0px, 0px, 0px)`
19559
+ : 'translateY(-50%)';
19560
+ }, [videoPostConfig]);
19561
+ const handLoadeddata = React.useCallback(() => {
19562
+ if (!canvasRef || !videoRef || !videoRef.current || !canvasRef.current)
19563
+ return;
19564
+ const video = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current;
19565
+ const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
19566
+ const ctx = canvas.getContext('2d');
19567
+ const targetWidth = window === null || window === void 0 ? void 0 : window.innerWidth;
19568
+ const targetHeight = window === null || window === void 0 ? void 0 : window.innerHeight;
19569
+ canvas.height = targetHeight;
19570
+ canvas.width = targetWidth;
19571
+ ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
19572
+ setFirstFrameSrc(canvas.toDataURL());
19573
+ }, []);
19574
+ const handleTimeUpload = React.useCallback(() => {
19575
+ var _a, _b, _c;
19576
+ if (!videoRef.current)
19577
+ return;
19578
+ 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)) {
19579
+ (_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
19580
+ }
19581
+ }, []);
19582
+ const handlePause = () => {
19583
+ var _a, _b, _c, _d, _e, _f;
19584
+ if (!loopPlay)
19585
+ return;
19586
+ if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
19587
+ (_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);
19588
+ }
19589
+ else {
19590
+ 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;
19591
+ (_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);
19592
+ }
19593
+ };
19594
+ // useEffect(() => {
19595
+ // if (!isActive) return;
19596
+ // if (!loopPlay) {
19597
+ // videoRef?.current?.pause();
19598
+ // } else {
19599
+ // videoRef?.current?.play();
19600
+ // }
19601
+ // }, [loopPlay, isActive]);
19602
+ React.useEffect(() => {
19603
+ var _a, _b, _c;
19604
+ if (!isActive)
19605
+ return;
19606
+ const videoSrc = rec === null || rec === void 0 ? void 0 : rec.mediaUrl;
19607
+ if (!videoSrc)
19608
+ return;
19609
+ setIsPauseVideo(false);
19610
+ const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
19611
+ if (!videoPlayerWrapperNode)
19612
+ return;
19613
+ videoRef.current = mountVideoPlayerAtNode === null || mountVideoPlayerAtNode === void 0 ? void 0 : mountVideoPlayerAtNode(videoPlayerWrapperNode);
19614
+ videoRef.current.currentTime = rec === null || rec === void 0 ? void 0 : rec.startTime;
19615
+ if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
19616
+ return;
19617
+ const Hls = window === null || window === void 0 ? void 0 : window.Hls;
19618
+ let hls = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current;
19619
+ if (videoSrc.includes('.m3u8') && Hls && Hls.isSupported()) {
19620
+ hls = new Hls();
19621
+ hls === null || hls === void 0 ? void 0 : hls.loadSource(videoSrc);
19622
+ hls === null || hls === void 0 ? void 0 : hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
19623
+ hls === null || hls === void 0 ? void 0 : hls.on(Hls.Events.MANIFEST_PARSED, function () {
19624
+ var _a;
19625
+ (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
19626
+ });
19627
+ }
19628
+ else {
19629
+ videoRef.current.src = videoSrc;
19630
+ }
19631
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('loadedmetadata', handleLoadedMetadata);
19632
+ // videoRef.current?.addEventListener('playing', handlePlaying);
19633
+ // videoRef.current?.addEventListener('loadeddata', handLoadeddata);
19634
+ (_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('pause', handlePause);
19635
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.addEventListener('timeupdate', handleTimeUpload);
19636
+ return () => {
19637
+ var _a, _b, _c, _d;
19638
+ if (hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current)
19639
+ (_a = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
19640
+ setIsLoadFinish(false);
19641
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('loadedmetadata', handleLoadedMetadata);
19642
+ // videoRef.current?.removeEventListener('playing', handlePlaying);
19643
+ // videoRef.current?.removeEventListener('loadeddata', handLoadeddata);
19644
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('pause', handlePause);
19645
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.removeEventListener('timeupdate', handleTimeUpload);
19646
+ };
19647
+ }, [handleLoadedMetadata, handlePlaying, rec, handLoadeddata, isActive]);
19648
+ React.useMemo(() => {
19649
+ if (!(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image) || isLoadFinish) {
19650
+ return null;
19651
+ }
19652
+ 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' }));
19653
+ }, [isLoadFinish, sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image]);
19654
+ React.useMemo(() => {
19655
+ return blur
19656
+ ? {
19657
+ filter: 'blur(10px)',
19658
+ transform: 'translate3d(0px, 0px, 0px) scale(1.2)'
19659
+ }
19660
+ : {};
19661
+ }, [blur]);
19662
+ if (!(rec === null || rec === void 0 ? void 0 : rec.mediaUrl)) {
19663
+ return null;
19664
+ }
19665
+ return (React.createElement("div", { className: 'video-container', key: rec.itemId, style: {
19666
+ position: 'relative',
19667
+ width: '100%',
19668
+ height,
19669
+ overflow: 'hidden',
19670
+ pointerEvents: 'none'
19671
+ } },
19672
+ React.createElement("div", { className: 'n-full-screen', id: videoId, style: { width: '100%', height: '100%' } })));
19673
+ };
19674
+ var VideoWidget$1 = React.memo(VideoWidget);
19675
+
19676
+ /*
19677
+ * @Author: binruan@chatlabs.com
19678
+ * @Date: 2025-03-25 13:54:27
19679
+ * @LastEditors: binruan@chatlabs.com
19680
+ * @LastEditTime: 2025-03-26 15:01:42
19681
+ * @FilePath: \pb-sxp-ui\src\core\components\DiyStoryPreview\index.tsx
19682
+ *
19683
+ */
19684
+ const RESOLVER$1 = {};
19685
+ Object.values(_materials_).forEach((v) => {
19686
+ RESOLVER$1[v.extend.type] = v;
19687
+ });
19688
+ const defaultUnLikeIconPath = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
19689
+ const defaultLikeIconPath = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
19690
+ const DiyStoryPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, descStyle, hashTagStyle, containerHeight = 664, containerWidth = 375, appDomain, tagList = [], scenes, onActiveChange, activeIndex, loopPlay = false }) => {
19691
+ const swiperRef = React.useRef(null);
19692
+ React.useMemo(() => {
19693
+ let minusHeight = 0;
19694
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
19695
+ minusHeight += 45;
19696
+ }
19697
+ if (tagList.length > 0) {
19698
+ minusHeight += 45;
19699
+ }
19700
+ return containerHeight - minusHeight;
19701
+ }, [globalConfig, containerHeight, tagList]);
19702
+ // 判断是否是视频
19703
+ const isVideoUrl = (url) => {
19704
+ if (url && url !== '' && typeof url === 'string') {
19705
+ const imageExtensions = ['.mp4', '.m3u8'];
19706
+ const lowerCaseUrl = url === null || url === void 0 ? void 0 : url.toLowerCase();
19707
+ return imageExtensions.some((ext) => lowerCaseUrl === null || lowerCaseUrl === void 0 ? void 0 : lowerCaseUrl.endsWith(ext));
19708
+ }
19709
+ else {
19710
+ return false;
19711
+ }
19712
+ };
19713
+ const renderContent = (rec, index) => {
19714
+ const isVideo = isVideoUrl(rec === null || rec === void 0 ? void 0 : rec.mediaUrl);
19715
+ if (isVideo) {
19716
+ 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 }));
19717
+ }
19718
+ else {
19719
+ 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 }));
19720
+ }
19721
+ };
19722
+ React.useMemo(() => {
19723
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
19724
+ return (React.createElement("div", { className: 'clc-sxp-logo-banner', style: { backgroundColor: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.color } },
19725
+ React.createElement("img", { src: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl, alt: 'logo' })));
19726
+ }
19727
+ return null;
19728
+ }, [globalConfig]);
19729
+ useIconLink(defaultLikeIconPath, appDomain);
19730
+ useIconLink(defaultUnLikeIconPath, appDomain);
19731
+ useIconLink('/pb_static/5beaaa5ce7f3477b99db3838619cc471.png', appDomain);
19732
+ useIconLink('/pb_static/fea8668a8a894e4aa3a86bcc775e895e.png', appDomain);
19733
+ const renderView = (rec, index) => {
19734
+ return (React.createElement(SwiperSlide, { key: index, virtualIndex: index, style: { overflow: 'hidden', position: 'relative' } }, renderContent(rec, index)));
19735
+ };
19736
+ React.useEffect(() => {
19737
+ var _a, _b;
19738
+ if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
19739
+ return;
19740
+ (_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);
19741
+ }, [activeIndex]);
19742
+ React.useEffect(() => {
19743
+ var _a, _b;
19744
+ if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
19745
+ return;
19746
+ (_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);
19747
+ }, [loopPlay]);
19748
+ return (React.createElement(Swiper, { ref: swiperRef, allowTouchMove: false, onActiveIndexChange: (swiper) => {
19749
+ // setActiveIndex(swiper.activeIndex);
19750
+ onActiveChange === null || onActiveChange === void 0 ? void 0 : onActiveChange(swiper.activeIndex);
19751
+ }, direction: 'vertical', style: { overflow: 'hidden', height: containerHeight } }, scenes === null || scenes === void 0 ? void 0 : scenes.map((rec, index) => {
19752
+ return renderView(rec, index);
19753
+ })));
19754
+ };
19755
+ var index$1 = React.memo(DiyStoryPreview);
19463
19756
 
19464
19757
  /*
19465
19758
  * @Author: binruan@chatlabs.com
@@ -19598,17 +19891,18 @@ var index = React.memo(SxpPageCore);
19598
19891
  * @Author : haocanweng@chatlabs.cn
19599
19892
  * @Date : 2023-08-21 16:31:58
19600
19893
  * @LastEditors: binruan@chatlabs.com
19601
- * @LastEditTime: 2024-06-25 11:37:48
19894
+ * @LastEditTime: 2025-03-25 14:31:53
19602
19895
  * @FilePath: \pb-sxp-ui\src\index.ts
19603
19896
  */
19604
19897
 
19605
- exports.DiyPortalPreview = index$1;
19898
+ exports.DiyPortalPreview = index$2;
19899
+ exports.DiyStoryPreview = index$1;
19606
19900
  exports.EditorDataProvider = EditorDataProvider;
19607
19901
  exports.Modal = Modal$1;
19608
19902
  exports.SxpDataSourceProvider = SxpDataSourceProvider$1;
19609
19903
  exports.SxpPageCore = index;
19610
19904
  exports.SxpPageRender = SxpPageRender$1;
19611
- exports.core = index$2;
19905
+ exports.core = index$3;
19612
19906
  exports.default = Pagebuilder;
19613
19907
  exports.materials = _materials_;
19614
19908
  exports.useEditorDataProvider = useEditorDataProvider;