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/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) {
@@ -747,12 +747,8 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
747
747
  // Beacon API 用于发送异步和非阻塞请求到服务器。这类请求不需要响应。
748
748
  if (options.type === 'beacon' && navigator.sendBeacon) {
749
749
  return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
750
- JSON.stringify({
751
- body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
752
- })
753
- ], {
754
- type: 'application/json;charset=UTF-8'
755
- }));
750
+ JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))
751
+ ], { type: 'application/json;charset=UTF-8' }));
756
752
  }
757
753
  return window
758
754
  .fetch(`${url}/api/${path}`, {
@@ -913,7 +909,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
913
909
  console.log('userInfo:', userInfo);
914
910
  console.log('eventInfo:', ef);
915
911
  console.log('========= 结束 =========');
916
- 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}`, {
917
913
  method: 'POST',
918
914
  body: { userInfo: realUserInfo, eventInfo: realEventInfo },
919
915
  type: 'beacon'
@@ -929,7 +925,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
929
925
  bffDataSource
930
926
  ]);
931
927
  const bffFbReport = React.useCallback(({ eventName, product }) => {
932
- var _a, _b, _c, _d, _e, _f, _g;
928
+ var _a, _b, _c, _d, _e, _f;
933
929
  if (!enableReportEvent ||
934
930
  !enabledMetaConversionApi ||
935
931
  (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) ||
@@ -993,15 +989,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
993
989
  }
994
990
  };
995
991
  getEventParams(jsonParams);
996
- const params = {};
997
- const queryString = location.search.slice(1);
998
- (_f = splitUrlParams(queryString)) === null || _f === void 0 ? void 0 : _f.map((val) => {
999
- const key = val.split('=')[0];
1000
- const value = val.split('=')[1];
1001
- params[key] = value;
1002
- });
1003
- const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
1004
- 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)}` : ''}`, {
992
+ 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}`, {
1005
993
  method: 'POST',
1006
994
  body: jsonParams,
1007
995
  type: 'beacon'
@@ -1498,7 +1486,7 @@ const EditorCore = React.forwardRef(({ children, resolver, isSsr, schema, enable
1498
1486
  React.createElement(DataSourceProvider$1, { isSsr: isSsr, enable: enableDataSource }, children)));
1499
1487
  });
1500
1488
 
1501
- var index$2 = /*#__PURE__*/Object.freeze({
1489
+ var index$3 = /*#__PURE__*/Object.freeze({
1502
1490
  __proto__: null,
1503
1491
  EditorCore: EditorCore
1504
1492
  });
@@ -17580,15 +17568,15 @@ var _materials_ = /*#__PURE__*/Object.freeze({
17580
17568
  Swipe: Swipe
17581
17569
  });
17582
17570
 
17583
- const defaultUnLikeIconPath$1 = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
17584
- const defaultLikeIconPath$1 = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
17571
+ const defaultUnLikeIconPath$2 = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
17572
+ const defaultLikeIconPath$2 = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
17585
17573
  const LikeButton = (_a) => {
17586
17574
  var _b;
17587
17575
  var { active, activeIcon, unActicveIcon, recData, position } = _a, props = __rest(_a, ["active", "activeIcon", "unActicveIcon", "recData", "position"]);
17588
17576
  const { mutateLike, mutateUnlike, bffEventReport, setCacheRtcList, cacheRtcList } = useSxpDataSource();
17589
17577
  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);
17578
+ const likeIcon = useIconLink(defaultLikeIconPath$2);
17579
+ const unlikeIcon = useIconLink(defaultUnLikeIconPath$2);
17592
17580
  const handleClick = lodash.debounce(() => __awaiter(void 0, void 0, void 0, function* () {
17593
17581
  var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
17594
17582
  if (state) {
@@ -17679,7 +17667,7 @@ const mountVideoPlayerAtNode = (() => {
17679
17667
  };
17680
17668
  })();
17681
17669
 
17682
- const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon }) => {
17670
+ const VideoWidget$4 = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon }) => {
17683
17671
  const [isPauseVideo, setIsPauseVideo] = React.useState(false);
17684
17672
  const { bffEventReport, sxpParameter, waterFallData, openHashtag, bffFbReport } = useSxpDataSource();
17685
17673
  const videoStartTime = React.useRef(0);
@@ -18024,7 +18012,7 @@ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPost
18024
18012
  renderLoading,
18025
18013
  isPauseVideo && React.createElement(FormatImage$1, { className: 'clc-pb-video-pause', src: videoPlayIcon !== null && videoPlayIcon !== void 0 ? videoPlayIcon : PAUSE_ICON, alt: 'pause' })))));
18026
18014
  };
18027
- var VideoWidget$3 = React.memo(VideoWidget$2);
18015
+ var VideoWidget$5 = React.memo(VideoWidget$4);
18028
18016
 
18029
18017
  const ToggleButton = ({ defaultValue, activeIcon, unactiveIcon, onChange, style }) => {
18030
18018
  const [isTrue, setIsTure] = React.useState(defaultValue);
@@ -18113,7 +18101,7 @@ const Picture = (props) => {
18113
18101
  }, onLoad: onShowFirstImage }))));
18114
18102
  };
18115
18103
 
18116
- const PictureGroup$2 = ({ imgUrls, width, height, rec, index, onViewImageEndEvent, onViewImageStartEvent, imgUrlsPostConfig }) => {
18104
+ const PictureGroup$4 = ({ imgUrls, width, height, rec, index, onViewImageEndEvent, onViewImageStartEvent, imgUrlsPostConfig }) => {
18117
18105
  var _a, _b;
18118
18106
  const { isActive } = useSwiperSlide();
18119
18107
  const { sxpParameter, openHashtag } = useSxpDataSource();
@@ -18207,7 +18195,7 @@ const PictureGroup$2 = ({ imgUrls, width, height, rec, index, onViewImageEndEven
18207
18195
  React.createElement(Picture, { src: !isLoad && srcKey > 0 ? '' : url, height: height, imgUrlsPostConfig: imgUrlsPostConfig, onShowFirstImage: showFirstImageFn })));
18208
18196
  }))));
18209
18197
  };
18210
- var PictureGroup$3 = React.memo(PictureGroup$2);
18198
+ var PictureGroup$5 = React.memo(PictureGroup$4);
18211
18199
 
18212
18200
  /*
18213
18201
  * @Author: binruan@chatlabs.com
@@ -18717,10 +18705,10 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
18717
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)));
18718
18706
  }
18719
18707
  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 }));
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 }));
18721
18709
  }
18722
18710
  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 }));
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 }));
18724
18712
  }
18725
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) {
18726
18714
  return (_k = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _k === void 0 ? void 0 : _k.map((value, idx) => {
@@ -19090,7 +19078,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19090
19078
  };
19091
19079
  var SxpPageRender$1 = React.memo(SxpPageRender);
19092
19080
 
19093
- const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index }) => {
19081
+ const PictureGroup$2 = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index }) => {
19094
19082
  return (React.createElement(Swiper, { defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: {
19095
19083
  clickable: true,
19096
19084
  bulletActiveClass: 'swipe-item-active-bullet',
@@ -19100,9 +19088,9 @@ const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index })
19100
19088
  React.createElement(Picture, { src: url, height: height, imgUrlsPostConfig: imgUrlsPostConfig })));
19101
19089
  })));
19102
19090
  };
19103
- var PictureGroup$1 = React.memo(PictureGroup);
19091
+ var PictureGroup$3 = React.memo(PictureGroup$2);
19104
19092
 
19105
- const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width }) => {
19093
+ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width }) => {
19106
19094
  const [isPauseVideo, setIsPauseVideo] = React.useState(false);
19107
19095
  const videoRef = React.useRef(null);
19108
19096
  const { bffEventReport, sxpParameter, waterFallData, openHashtag } = useSxpDataSource();
@@ -19332,14 +19320,14 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
19332
19320
  renderPoster,
19333
19321
  React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON, alt: 'video pause image' })))));
19334
19322
  };
19335
- var VideoWidget$1 = React.memo(VideoWidget);
19323
+ var VideoWidget$3 = React.memo(VideoWidget$2);
19336
19324
 
19337
- const RESOLVER$1 = {};
19325
+ const RESOLVER$2 = {};
19338
19326
  Object.values(_materials_).forEach((v) => {
19339
- RESOLVER$1[v.extend.type] = v;
19327
+ RESOLVER$2[v.extend.type] = v;
19340
19328
  });
19341
- const defaultUnLikeIconPath = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
19342
- const defaultLikeIconPath = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
19329
+ const defaultUnLikeIconPath$1 = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
19330
+ const defaultLikeIconPath$1 = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
19343
19331
  const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, descStyle, hashTagStyle, containerHeight = 664, containerWidth = 375, appDomain, tagList = [] }) => {
19344
19332
  const height = React.useMemo(() => {
19345
19333
  let minusHeight = 0;
@@ -19354,16 +19342,16 @@ const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, de
19354
19342
  const renderContent = (rec, index) => {
19355
19343
  var _a, _b, _c, _d;
19356
19344
  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 }));
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 }));
19358
19346
  }
19359
19347
  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 }));
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 }));
19361
19349
  }
19362
19350
  if (rec.product) {
19363
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) {
19364
19352
  return (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _d === void 0 ? void 0 : _d.map((value, idx) => {
19365
19353
  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];
19354
+ const t = RESOLVER$2[(_a = value === null || value === void 0 ? void 0 : value.item) === null || _a === void 0 ? void 0 : _a.type];
19367
19355
  const Component = withBindDataSource(t);
19368
19356
  const defaulSetting = (_b = t === null || t === void 0 ? void 0 : t.extend) === null || _b === void 0 ? void 0 : _b.defaulSetting;
19369
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) || {},
@@ -19385,7 +19373,7 @@ const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, de
19385
19373
  const CTA = (rec, index) => {
19386
19374
  if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA) === undefined || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA)) {
19387
19375
  return (React.createElement("div", { className: 'clc-sxp-bottom-card' },
19388
- 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 })));
19389
19377
  }
19390
19378
  return null;
19391
19379
  };
@@ -19403,8 +19391,8 @@ const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, de
19403
19391
  }
19404
19392
  return null;
19405
19393
  };
19406
- const likeIcon = useIconLink(defaultLikeIconPath, appDomain);
19407
- const unlikeIcon = useIconLink(defaultUnLikeIconPath, appDomain);
19394
+ const likeIcon = useIconLink(defaultLikeIconPath$1, appDomain);
19395
+ const unlikeIcon = useIconLink(defaultUnLikeIconPath$1, appDomain);
19408
19396
  const renderLikeButton = (rec, index) => {
19409
19397
  var _a, _b, _c, _d;
19410
19398
  if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLike))
@@ -19452,7 +19440,319 @@ const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, de
19452
19440
  return renderView(rec, index);
19453
19441
  })));
19454
19442
  };
19455
- 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);
19456
19756
 
19457
19757
  /*
19458
19758
  * @Author: binruan@chatlabs.com
@@ -19591,17 +19891,18 @@ var index = React.memo(SxpPageCore);
19591
19891
  * @Author : haocanweng@chatlabs.cn
19592
19892
  * @Date : 2023-08-21 16:31:58
19593
19893
  * @LastEditors: binruan@chatlabs.com
19594
- * @LastEditTime: 2024-06-25 11:37:48
19894
+ * @LastEditTime: 2025-03-25 14:31:53
19595
19895
  * @FilePath: \pb-sxp-ui\src\index.ts
19596
19896
  */
19597
19897
 
19598
- exports.DiyPortalPreview = index$1;
19898
+ exports.DiyPortalPreview = index$2;
19899
+ exports.DiyStoryPreview = index$1;
19599
19900
  exports.EditorDataProvider = EditorDataProvider;
19600
19901
  exports.Modal = Modal$1;
19601
19902
  exports.SxpDataSourceProvider = SxpDataSourceProvider$1;
19602
19903
  exports.SxpPageCore = index;
19603
19904
  exports.SxpPageRender = SxpPageRender$1;
19604
- exports.core = index$2;
19905
+ exports.core = index$3;
19605
19906
  exports.default = Pagebuilder;
19606
19907
  exports.materials = _materials_;
19607
19908
  exports.useEditorDataProvider = useEditorDataProvider;