pb-sxp-ui 1.15.12-alpha.8 → 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.
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) {
@@ -740,12 +740,8 @@
740
740
  // Beacon API 用于发送异步和非阻塞请求到服务器。这类请求不需要响应。
741
741
  if (options.type === 'beacon' && navigator.sendBeacon) {
742
742
  return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
743
- JSON.stringify({
744
- body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
745
- })
746
- ], {
747
- type: 'application/json;charset=UTF-8'
748
- }));
743
+ JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))
744
+ ], { type: 'application/json;charset=UTF-8' }));
749
745
  }
750
746
  return window
751
747
  .fetch(`${url}/api/${path}`, {
@@ -906,7 +902,7 @@
906
902
  console.log('userInfo:', userInfo);
907
903
  console.log('eventInfo:', ef);
908
904
  console.log('========= 结束 =========');
909
- 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}`, {
910
906
  method: 'POST',
911
907
  body: { userInfo: realUserInfo, eventInfo: realEventInfo },
912
908
  type: 'beacon'
@@ -922,7 +918,7 @@
922
918
  bffDataSource
923
919
  ]);
924
920
  const bffFbReport = React.useCallback(({ eventName, product }) => {
925
- var _a, _b, _c, _d, _e, _f, _g;
921
+ var _a, _b, _c, _d, _e, _f;
926
922
  if (!enableReportEvent ||
927
923
  !enabledMetaConversionApi ||
928
924
  (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) ||
@@ -986,15 +982,7 @@
986
982
  }
987
983
  };
988
984
  getEventParams(jsonParams);
989
- const params = {};
990
- const queryString = location.search.slice(1);
991
- (_f = splitUrlParams(queryString)) === null || _f === void 0 ? void 0 : _f.map((val) => {
992
- const key = val.split('=')[0];
993
- const value = val.split('=')[1];
994
- params[key] = value;
995
- });
996
- const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
997
- return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/fb/${(_g = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _g === void 0 ? void 0 : _g['x-app-id']}/${eventName}${cl_source ? `/${decodeURIComponent(cl_source)}` : ''}`, {
985
+ return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/event/report/FB/${(_f = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _f === void 0 ? void 0 : _f['x-app-id']}/${eventName}`, {
998
986
  method: 'POST',
999
987
  body: jsonParams,
1000
988
  type: 'beacon'
@@ -1491,7 +1479,7 @@
1491
1479
  React.createElement(DataSourceProvider$1, { isSsr: isSsr, enable: enableDataSource }, children)));
1492
1480
  });
1493
1481
 
1494
- var index$2 = /*#__PURE__*/Object.freeze({
1482
+ var index$3 = /*#__PURE__*/Object.freeze({
1495
1483
  __proto__: null,
1496
1484
  EditorCore: EditorCore
1497
1485
  });
@@ -17573,15 +17561,15 @@ Made in Italy` })));
17573
17561
  Swipe: Swipe
17574
17562
  });
17575
17563
 
17576
- const defaultUnLikeIconPath$1 = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
17577
- const defaultLikeIconPath$1 = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
17564
+ const defaultUnLikeIconPath$2 = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
17565
+ const defaultLikeIconPath$2 = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
17578
17566
  const LikeButton = (_a) => {
17579
17567
  var _b;
17580
17568
  var { active, activeIcon, unActicveIcon, recData, position } = _a, props = __rest(_a, ["active", "activeIcon", "unActicveIcon", "recData", "position"]);
17581
17569
  const { mutateLike, mutateUnlike, bffEventReport, setCacheRtcList, cacheRtcList } = useSxpDataSource();
17582
17570
  const [state, setState] = React.useState((_b = cacheRtcList === null || cacheRtcList === void 0 ? void 0 : cacheRtcList[position]) === null || _b === void 0 ? void 0 : _b.isCollected);
17583
- const likeIcon = useIconLink(defaultLikeIconPath$1);
17584
- const unlikeIcon = useIconLink(defaultUnLikeIconPath$1);
17571
+ const likeIcon = useIconLink(defaultLikeIconPath$2);
17572
+ const unlikeIcon = useIconLink(defaultUnLikeIconPath$2);
17585
17573
  const handleClick = lodash.debounce(() => __awaiter(void 0, void 0, void 0, function* () {
17586
17574
  var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
17587
17575
  if (state) {
@@ -17672,7 +17660,7 @@ Made in Italy` })));
17672
17660
  };
17673
17661
  })();
17674
17662
 
17675
- const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon }) => {
17663
+ const VideoWidget$4 = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon }) => {
17676
17664
  const [isPauseVideo, setIsPauseVideo] = React.useState(false);
17677
17665
  const { bffEventReport, sxpParameter, waterFallData, openHashtag, bffFbReport } = useSxpDataSource();
17678
17666
  const videoStartTime = React.useRef(0);
@@ -18017,7 +18005,7 @@ Made in Italy` })));
18017
18005
  renderLoading,
18018
18006
  isPauseVideo && React.createElement(FormatImage$1, { className: 'clc-pb-video-pause', src: videoPlayIcon !== null && videoPlayIcon !== void 0 ? videoPlayIcon : PAUSE_ICON, alt: 'pause' })))));
18019
18007
  };
18020
- var VideoWidget$3 = React.memo(VideoWidget$2);
18008
+ var VideoWidget$5 = React.memo(VideoWidget$4);
18021
18009
 
18022
18010
  const ToggleButton = ({ defaultValue, activeIcon, unactiveIcon, onChange, style }) => {
18023
18011
  const [isTrue, setIsTure] = React.useState(defaultValue);
@@ -18106,7 +18094,7 @@ Made in Italy` })));
18106
18094
  }, onLoad: onShowFirstImage }))));
18107
18095
  };
18108
18096
 
18109
- const PictureGroup$2 = ({ imgUrls, width, height, rec, index, onViewImageEndEvent, onViewImageStartEvent, imgUrlsPostConfig }) => {
18097
+ const PictureGroup$4 = ({ imgUrls, width, height, rec, index, onViewImageEndEvent, onViewImageStartEvent, imgUrlsPostConfig }) => {
18110
18098
  var _a, _b;
18111
18099
  const { isActive } = useSwiperSlide();
18112
18100
  const { sxpParameter, openHashtag } = useSxpDataSource();
@@ -18200,7 +18188,7 @@ Made in Italy` })));
18200
18188
  React.createElement(Picture, { src: !isLoad && srcKey > 0 ? '' : url, height: height, imgUrlsPostConfig: imgUrlsPostConfig, onShowFirstImage: showFirstImageFn })));
18201
18189
  }))));
18202
18190
  };
18203
- var PictureGroup$3 = React.memo(PictureGroup$2);
18191
+ var PictureGroup$5 = React.memo(PictureGroup$4);
18204
18192
 
18205
18193
  /*
18206
18194
  * @Author: binruan@chatlabs.com
@@ -18710,10 +18698,10 @@ Made in Italy` })));
18710
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)));
18711
18699
  }
18712
18700
  if ((_g = rec === null || rec === void 0 ? void 0 : rec.video) === null || _g === void 0 ? void 0 : _g.url) {
18713
- 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 }));
18714
18702
  }
18715
18703
  if ((_h = rec === null || rec === void 0 ? void 0 : rec.video) === null || _h === void 0 ? void 0 : _h.imgUrls) {
18716
- 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 }));
18717
18705
  }
18718
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) {
18719
18707
  return (_k = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _k === void 0 ? void 0 : _k.map((value, idx) => {
@@ -19083,7 +19071,7 @@ Made in Italy` })));
19083
19071
  };
19084
19072
  var SxpPageRender$1 = React.memo(SxpPageRender);
19085
19073
 
19086
- const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index }) => {
19074
+ const PictureGroup$2 = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index }) => {
19087
19075
  return (React.createElement(Swiper, { defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: {
19088
19076
  clickable: true,
19089
19077
  bulletActiveClass: 'swipe-item-active-bullet',
@@ -19093,9 +19081,9 @@ Made in Italy` })));
19093
19081
  React.createElement(Picture, { src: url, height: height, imgUrlsPostConfig: imgUrlsPostConfig })));
19094
19082
  })));
19095
19083
  };
19096
- var PictureGroup$1 = React.memo(PictureGroup);
19084
+ var PictureGroup$3 = React.memo(PictureGroup$2);
19097
19085
 
19098
- const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width }) => {
19086
+ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width }) => {
19099
19087
  const [isPauseVideo, setIsPauseVideo] = React.useState(false);
19100
19088
  const videoRef = React.useRef(null);
19101
19089
  const { bffEventReport, sxpParameter, waterFallData, openHashtag } = useSxpDataSource();
@@ -19325,14 +19313,14 @@ Made in Italy` })));
19325
19313
  renderPoster,
19326
19314
  React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON, alt: 'video pause image' })))));
19327
19315
  };
19328
- var VideoWidget$1 = React.memo(VideoWidget);
19316
+ var VideoWidget$3 = React.memo(VideoWidget$2);
19329
19317
 
19330
- const RESOLVER$1 = {};
19318
+ const RESOLVER$2 = {};
19331
19319
  Object.values(_materials_).forEach((v) => {
19332
- RESOLVER$1[v.extend.type] = v;
19320
+ RESOLVER$2[v.extend.type] = v;
19333
19321
  });
19334
- const defaultUnLikeIconPath = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
19335
- const defaultLikeIconPath = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
19322
+ const defaultUnLikeIconPath$1 = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
19323
+ const defaultLikeIconPath$1 = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
19336
19324
  const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, descStyle, hashTagStyle, containerHeight = 664, containerWidth = 375, appDomain, tagList = [] }) => {
19337
19325
  const height = React.useMemo(() => {
19338
19326
  let minusHeight = 0;
@@ -19347,16 +19335,16 @@ Made in Italy` })));
19347
19335
  const renderContent = (rec, index) => {
19348
19336
  var _a, _b, _c, _d;
19349
19337
  if ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.url) {
19350
- 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 }));
19351
19339
  }
19352
19340
  if ((_b = rec === null || rec === void 0 ? void 0 : rec.video) === null || _b === void 0 ? void 0 : _b.imgUrls) {
19353
- 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 }));
19354
19342
  }
19355
19343
  if (rec.product) {
19356
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) {
19357
19345
  return (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _d === void 0 ? void 0 : _d.map((value, idx) => {
19358
19346
  var _a, _b, _c, _d, _e, _f, _g, _h;
19359
- 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];
19360
19348
  const Component = withBindDataSource(t);
19361
19349
  const defaulSetting = (_b = t === null || t === void 0 ? void 0 : t.extend) === null || _b === void 0 ? void 0 : _b.defaulSetting;
19362
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) || {},
@@ -19378,7 +19366,7 @@ Made in Italy` })));
19378
19366
  const CTA = (rec, index) => {
19379
19367
  if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA) === undefined || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA)) {
19380
19368
  return (React.createElement("div", { className: 'clc-sxp-bottom-card' },
19381
- 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 })));
19382
19370
  }
19383
19371
  return null;
19384
19372
  };
@@ -19396,8 +19384,8 @@ Made in Italy` })));
19396
19384
  }
19397
19385
  return null;
19398
19386
  };
19399
- const likeIcon = useIconLink(defaultLikeIconPath, appDomain);
19400
- const unlikeIcon = useIconLink(defaultUnLikeIconPath, appDomain);
19387
+ const likeIcon = useIconLink(defaultLikeIconPath$1, appDomain);
19388
+ const unlikeIcon = useIconLink(defaultUnLikeIconPath$1, appDomain);
19401
19389
  const renderLikeButton = (rec, index) => {
19402
19390
  var _a, _b, _c, _d;
19403
19391
  if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLike))
@@ -19445,7 +19433,319 @@ Made in Italy` })));
19445
19433
  return renderView(rec, index);
19446
19434
  })));
19447
19435
  };
19448
- 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);
19449
19749
 
19450
19750
  /*
19451
19751
  * @Author: binruan@chatlabs.com
@@ -19584,17 +19884,18 @@ Made in Italy` })));
19584
19884
  * @Author : haocanweng@chatlabs.cn
19585
19885
  * @Date : 2023-08-21 16:31:58
19586
19886
  * @LastEditors: binruan@chatlabs.com
19587
- * @LastEditTime: 2024-06-25 11:37:48
19887
+ * @LastEditTime: 2025-03-25 14:31:53
19588
19888
  * @FilePath: \pb-sxp-ui\src\index.ts
19589
19889
  */
19590
19890
 
19591
- exports.DiyPortalPreview = index$1;
19891
+ exports.DiyPortalPreview = index$2;
19892
+ exports.DiyStoryPreview = index$1;
19592
19893
  exports.EditorDataProvider = EditorDataProvider;
19593
19894
  exports.Modal = Modal$1;
19594
19895
  exports.SxpDataSourceProvider = SxpDataSourceProvider$1;
19595
19896
  exports.SxpPageCore = index;
19596
19897
  exports.SxpPageRender = SxpPageRender$1;
19597
- exports.core = index$2;
19898
+ exports.core = index$3;
19598
19899
  exports.default = Pagebuilder;
19599
19900
  exports.materials = _materials_;
19600
19901
  exports.useEditorDataProvider = useEditorDataProvider;