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.js CHANGED
@@ -22,7 +22,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
22
22
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23
23
  PERFORMANCE OF THIS SOFTWARE.
24
24
  ***************************************************************************** */
25
- /* global Reflect, Promise, SuppressedError, Symbol */
25
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
26
26
 
27
27
 
28
28
  function __rest(s, e) {
@@ -725,12 +725,8 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
725
725
  // Beacon API 用于发送异步和非阻塞请求到服务器。这类请求不需要响应。
726
726
  if (options.type === 'beacon' && navigator.sendBeacon) {
727
727
  return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
728
- JSON.stringify({
729
- body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
730
- })
731
- ], {
732
- type: 'application/json;charset=UTF-8'
733
- }));
728
+ JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))
729
+ ], { type: 'application/json;charset=UTF-8' }));
734
730
  }
735
731
  return window
736
732
  .fetch(`${url}/api/${path}`, {
@@ -891,7 +887,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
891
887
  console.log('userInfo:', userInfo);
892
888
  console.log('eventInfo:', ef);
893
889
  console.log('========= 结束 =========');
894
- 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)}` : ''}`, {
890
+ 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}`, {
895
891
  method: 'POST',
896
892
  body: { userInfo: realUserInfo, eventInfo: realEventInfo },
897
893
  type: 'beacon'
@@ -907,7 +903,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
907
903
  bffDataSource
908
904
  ]);
909
905
  const bffFbReport = useCallback(({ eventName, product }) => {
910
- var _a, _b, _c, _d, _e, _f, _g;
906
+ var _a, _b, _c, _d, _e, _f;
911
907
  if (!enableReportEvent ||
912
908
  !enabledMetaConversionApi ||
913
909
  (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) ||
@@ -971,15 +967,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
971
967
  }
972
968
  };
973
969
  getEventParams(jsonParams);
974
- const params = {};
975
- const queryString = location.search.slice(1);
976
- (_f = splitUrlParams(queryString)) === null || _f === void 0 ? void 0 : _f.map((val) => {
977
- const key = val.split('=')[0];
978
- const value = val.split('=')[1];
979
- params[key] = value;
980
- });
981
- const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
982
- 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)}` : ''}`, {
970
+ 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}`, {
983
971
  method: 'POST',
984
972
  body: jsonParams,
985
973
  type: 'beacon'
@@ -1476,7 +1464,7 @@ const EditorCore = forwardRef(({ children, resolver, isSsr, schema, enableDataSo
1476
1464
  React.createElement(DataSourceProvider$1, { isSsr: isSsr, enable: enableDataSource }, children)));
1477
1465
  });
1478
1466
 
1479
- var index$2 = /*#__PURE__*/Object.freeze({
1467
+ var index$3 = /*#__PURE__*/Object.freeze({
1480
1468
  __proto__: null,
1481
1469
  EditorCore: EditorCore
1482
1470
  });
@@ -17558,15 +17546,15 @@ var _materials_ = /*#__PURE__*/Object.freeze({
17558
17546
  Swipe: Swipe
17559
17547
  });
17560
17548
 
17561
- const defaultUnLikeIconPath$1 = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
17562
- const defaultLikeIconPath$1 = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
17549
+ const defaultUnLikeIconPath$2 = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
17550
+ const defaultLikeIconPath$2 = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
17563
17551
  const LikeButton = (_a) => {
17564
17552
  var _b;
17565
17553
  var { active, activeIcon, unActicveIcon, recData, position } = _a, props = __rest(_a, ["active", "activeIcon", "unActicveIcon", "recData", "position"]);
17566
17554
  const { mutateLike, mutateUnlike, bffEventReport, setCacheRtcList, cacheRtcList } = useSxpDataSource();
17567
17555
  const [state, setState] = useState((_b = cacheRtcList === null || cacheRtcList === void 0 ? void 0 : cacheRtcList[position]) === null || _b === void 0 ? void 0 : _b.isCollected);
17568
- const likeIcon = useIconLink(defaultLikeIconPath$1);
17569
- const unlikeIcon = useIconLink(defaultUnLikeIconPath$1);
17556
+ const likeIcon = useIconLink(defaultLikeIconPath$2);
17557
+ const unlikeIcon = useIconLink(defaultUnLikeIconPath$2);
17570
17558
  const handleClick = debounce(() => __awaiter(void 0, void 0, void 0, function* () {
17571
17559
  var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
17572
17560
  if (state) {
@@ -17657,7 +17645,7 @@ const mountVideoPlayerAtNode = (() => {
17657
17645
  };
17658
17646
  })();
17659
17647
 
17660
- const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon }) => {
17648
+ const VideoWidget$4 = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon }) => {
17661
17649
  const [isPauseVideo, setIsPauseVideo] = useState(false);
17662
17650
  const { bffEventReport, sxpParameter, waterFallData, openHashtag, bffFbReport } = useSxpDataSource();
17663
17651
  const videoStartTime = useRef(0);
@@ -18002,7 +17990,7 @@ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPost
18002
17990
  renderLoading,
18003
17991
  isPauseVideo && React.createElement(FormatImage$1, { className: 'clc-pb-video-pause', src: videoPlayIcon !== null && videoPlayIcon !== void 0 ? videoPlayIcon : PAUSE_ICON, alt: 'pause' })))));
18004
17992
  };
18005
- var VideoWidget$3 = memo(VideoWidget$2);
17993
+ var VideoWidget$5 = memo(VideoWidget$4);
18006
17994
 
18007
17995
  const ToggleButton = ({ defaultValue, activeIcon, unactiveIcon, onChange, style }) => {
18008
17996
  const [isTrue, setIsTure] = useState(defaultValue);
@@ -18091,7 +18079,7 @@ const Picture = (props) => {
18091
18079
  }, onLoad: onShowFirstImage }))));
18092
18080
  };
18093
18081
 
18094
- const PictureGroup$2 = ({ imgUrls, width, height, rec, index, onViewImageEndEvent, onViewImageStartEvent, imgUrlsPostConfig }) => {
18082
+ const PictureGroup$4 = ({ imgUrls, width, height, rec, index, onViewImageEndEvent, onViewImageStartEvent, imgUrlsPostConfig }) => {
18095
18083
  var _a, _b;
18096
18084
  const { isActive } = useSwiperSlide();
18097
18085
  const { sxpParameter, openHashtag } = useSxpDataSource();
@@ -18185,7 +18173,7 @@ const PictureGroup$2 = ({ imgUrls, width, height, rec, index, onViewImageEndEven
18185
18173
  React.createElement(Picture, { src: !isLoad && srcKey > 0 ? '' : url, height: height, imgUrlsPostConfig: imgUrlsPostConfig, onShowFirstImage: showFirstImageFn })));
18186
18174
  }))));
18187
18175
  };
18188
- var PictureGroup$3 = memo(PictureGroup$2);
18176
+ var PictureGroup$5 = memo(PictureGroup$4);
18189
18177
 
18190
18178
  /*
18191
18179
  * @Author: binruan@chatlabs.com
@@ -18695,10 +18683,10 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
18695
18683
  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)));
18696
18684
  }
18697
18685
  if ((_g = rec === null || rec === void 0 ? void 0 : rec.video) === null || _g === void 0 ? void 0 : _g.url) {
18698
- 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 }));
18686
+ 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 }));
18699
18687
  }
18700
18688
  if ((_h = rec === null || rec === void 0 ? void 0 : rec.video) === null || _h === void 0 ? void 0 : _h.imgUrls) {
18701
- 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 }));
18689
+ 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 }));
18702
18690
  }
18703
18691
  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) {
18704
18692
  return (_k = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _k === void 0 ? void 0 : _k.map((value, idx) => {
@@ -19068,7 +19056,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19068
19056
  };
19069
19057
  var SxpPageRender$1 = memo(SxpPageRender);
19070
19058
 
19071
- const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index }) => {
19059
+ const PictureGroup$2 = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index }) => {
19072
19060
  return (React.createElement(Swiper, { defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: {
19073
19061
  clickable: true,
19074
19062
  bulletActiveClass: 'swipe-item-active-bullet',
@@ -19078,9 +19066,9 @@ const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index })
19078
19066
  React.createElement(Picture, { src: url, height: height, imgUrlsPostConfig: imgUrlsPostConfig })));
19079
19067
  })));
19080
19068
  };
19081
- var PictureGroup$1 = memo(PictureGroup);
19069
+ var PictureGroup$3 = memo(PictureGroup$2);
19082
19070
 
19083
- const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width }) => {
19071
+ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width }) => {
19084
19072
  const [isPauseVideo, setIsPauseVideo] = useState(false);
19085
19073
  const videoRef = useRef(null);
19086
19074
  const { bffEventReport, sxpParameter, waterFallData, openHashtag } = useSxpDataSource();
@@ -19310,14 +19298,14 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
19310
19298
  renderPoster,
19311
19299
  React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON, alt: 'video pause image' })))));
19312
19300
  };
19313
- var VideoWidget$1 = memo(VideoWidget);
19301
+ var VideoWidget$3 = memo(VideoWidget$2);
19314
19302
 
19315
- const RESOLVER$1 = {};
19303
+ const RESOLVER$2 = {};
19316
19304
  Object.values(_materials_).forEach((v) => {
19317
- RESOLVER$1[v.extend.type] = v;
19305
+ RESOLVER$2[v.extend.type] = v;
19318
19306
  });
19319
- const defaultUnLikeIconPath = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
19320
- const defaultLikeIconPath = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
19307
+ const defaultUnLikeIconPath$1 = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
19308
+ const defaultLikeIconPath$1 = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
19321
19309
  const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, descStyle, hashTagStyle, containerHeight = 664, containerWidth = 375, appDomain, tagList = [] }) => {
19322
19310
  const height = useMemo(() => {
19323
19311
  let minusHeight = 0;
@@ -19332,16 +19320,16 @@ const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, de
19332
19320
  const renderContent = (rec, index) => {
19333
19321
  var _a, _b, _c, _d;
19334
19322
  if ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.url) {
19335
- 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 }));
19323
+ 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 }));
19336
19324
  }
19337
19325
  if ((_b = rec === null || rec === void 0 ? void 0 : rec.video) === null || _b === void 0 ? void 0 : _b.imgUrls) {
19338
- 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 }));
19326
+ 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 }));
19339
19327
  }
19340
19328
  if (rec.product) {
19341
19329
  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) {
19342
19330
  return (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _d === void 0 ? void 0 : _d.map((value, idx) => {
19343
19331
  var _a, _b, _c, _d, _e, _f, _g, _h;
19344
- const t = RESOLVER$1[(_a = value === null || value === void 0 ? void 0 : value.item) === null || _a === void 0 ? void 0 : _a.type];
19332
+ const t = RESOLVER$2[(_a = value === null || value === void 0 ? void 0 : value.item) === null || _a === void 0 ? void 0 : _a.type];
19345
19333
  const Component = withBindDataSource(t);
19346
19334
  const defaulSetting = (_b = t === null || t === void 0 ? void 0 : t.extend) === null || _b === void 0 ? void 0 : _b.defaulSetting;
19347
19335
  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) || {},
@@ -19363,7 +19351,7 @@ const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, de
19363
19351
  const CTA = (rec, index) => {
19364
19352
  if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA) === undefined || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA)) {
19365
19353
  return (React.createElement("div", { className: 'clc-sxp-bottom-card' },
19366
- React.createElement(RenderCard$1, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER$1 })));
19354
+ React.createElement(RenderCard$1, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER$2 })));
19367
19355
  }
19368
19356
  return null;
19369
19357
  };
@@ -19381,8 +19369,8 @@ const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, de
19381
19369
  }
19382
19370
  return null;
19383
19371
  };
19384
- const likeIcon = useIconLink(defaultLikeIconPath, appDomain);
19385
- const unlikeIcon = useIconLink(defaultUnLikeIconPath, appDomain);
19372
+ const likeIcon = useIconLink(defaultLikeIconPath$1, appDomain);
19373
+ const unlikeIcon = useIconLink(defaultUnLikeIconPath$1, appDomain);
19386
19374
  const renderLikeButton = (rec, index) => {
19387
19375
  var _a, _b, _c, _d;
19388
19376
  if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLike))
@@ -19430,7 +19418,319 @@ const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, de
19430
19418
  return renderView(rec, index);
19431
19419
  })));
19432
19420
  };
19433
- var index$1 = memo(DiyPortalPreview);
19421
+ var index$2 = memo(DiyPortalPreview);
19422
+
19423
+ const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index, swiperRef, data = [], loopPlay }) => {
19424
+ const { isActive } = useSwiperSlide();
19425
+ const [isload, setIsLoad] = useState(false);
19426
+ useEffect(() => {
19427
+ if (isActive && isload && loopPlay) {
19428
+ setTimeout(() => {
19429
+ var _a, _b, _c, _d;
19430
+ if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
19431
+ (_a = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _a === void 0 ? void 0 : _a.swiper.slideTo(0);
19432
+ }
19433
+ else {
19434
+ 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;
19435
+ (_d = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _d === void 0 ? void 0 : _d.swiper.slideTo(i + 1);
19436
+ }
19437
+ }, 3000);
19438
+ }
19439
+ }, [isActive, isload, data, index, swiperRef, loopPlay]);
19440
+ const loadFinishImage = () => {
19441
+ setIsLoad(true);
19442
+ };
19443
+ return (React.createElement(Swiper, { defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: {
19444
+ clickable: true,
19445
+ bulletActiveClass: 'swipe-item-active-bullet',
19446
+ bulletElement: 'button'
19447
+ }, height: height, style: { width }, loop: true, autoplay: false }, imgUrls === null || imgUrls === void 0 ? void 0 : imgUrls.map((url) => {
19448
+ return (React.createElement(SwiperSlide, { key: url },
19449
+ React.createElement(Picture, { src: url, height: height, imgUrlsPostConfig: imgUrlsPostConfig, onShowFirstImage: loadFinishImage })));
19450
+ })));
19451
+ };
19452
+ var PictureGroup$1 = memo(PictureGroup);
19453
+
19454
+ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width, swiperRef, loopPlay }) => {
19455
+ const { isActive } = useSwiperSlide();
19456
+ const [isPauseVideo, setIsPauseVideo] = useState(false);
19457
+ const videoRef = useRef(null);
19458
+ const { bffEventReport, sxpParameter, waterFallData, openHashtag } = useSxpDataSource();
19459
+ const videoStartTime = useRef(0);
19460
+ const [isLoadFinish, setIsLoadFinish] = useState(false);
19461
+ const [isFirstPlay, setIsFirstPlay] = useState(true);
19462
+ const canvasRef = useRef(null);
19463
+ const [firstFrameSrc, setFirstFrameSrc] = useState('');
19464
+ const videoId = `pb-cache-video-${index}`;
19465
+ const hlsRef = useRef(null);
19466
+ useEffect(() => {
19467
+ if (!videoRef.current)
19468
+ return;
19469
+ videoRef.current.muted = muted;
19470
+ }, [muted]);
19471
+ useCallback(() => {
19472
+ var _a;
19473
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
19474
+ }, []);
19475
+ useIconLink('/pb_static/06f28a2025c74c1cb49be6767316d827.png');
19476
+ const handlePlaying = useCallback(() => {
19477
+ var _a, _b, _c, _d, _e, _f;
19478
+ setIsPauseVideo(false);
19479
+ const item = data[index];
19480
+ if (item && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration)) {
19481
+ videoStartTime.current = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.currentTime) || 0;
19482
+ ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 0).toFixed(2);
19483
+ ((_f = (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime) !== null && _f !== void 0 ? _f : 0).toFixed(2);
19484
+ setIsFirstPlay(false);
19485
+ }
19486
+ }, [bffEventReport, data, index, isFirstPlay]);
19487
+ const handleLoadedMetadata = useCallback(() => {
19488
+ var _a;
19489
+ (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
19490
+ setIsLoadFinish(true);
19491
+ }, []);
19492
+ useCallback((type) => () => {
19493
+ var _a, _b, _c, _d, _e;
19494
+ if (!isLoadFinish)
19495
+ return;
19496
+ const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
19497
+ switch (type) {
19498
+ case 'start':
19499
+ if (!isPause)
19500
+ return;
19501
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.play();
19502
+ setIsPauseVideo(false);
19503
+ break;
19504
+ case 'pause':
19505
+ if (isPause)
19506
+ return;
19507
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
19508
+ setIsPauseVideo(true);
19509
+ break;
19510
+ default:
19511
+ if (isPause) {
19512
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.play();
19513
+ }
19514
+ else {
19515
+ (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.pause();
19516
+ }
19517
+ setIsPauseVideo(!isPause);
19518
+ break;
19519
+ }
19520
+ }, [isLoadFinish]);
19521
+ useCallback(() => {
19522
+ var _a, _b, _c, _d, _e, _f;
19523
+ data[index];
19524
+ ((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.duration) !== null && _b !== void 0 ? _b : 0).toFixed(2);
19525
+ ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.currentTime) !== null && _d !== void 0 ? _d : 0).toFixed(2);
19526
+ if ((_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.duration) {
19527
+ (((_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.currentTime) - videoStartTime.current).toFixed(2);
19528
+ }
19529
+ }, [data, index, bffEventReport]);
19530
+ const blur = useMemo(() => {
19531
+ return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2';
19532
+ }, [videoPostConfig]);
19533
+ useMemo(() => {
19534
+ var _a;
19535
+ return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2'
19536
+ ? `translateY(-${50 + ((_a = videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.offsetTop) !== null && _a !== void 0 ? _a : 0)}%) translate3d(0px, 0px, 0px)`
19537
+ : 'translateY(-50%)';
19538
+ }, [videoPostConfig]);
19539
+ const handLoadeddata = useCallback(() => {
19540
+ if (!canvasRef || !videoRef || !videoRef.current || !canvasRef.current)
19541
+ return;
19542
+ const video = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current;
19543
+ const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
19544
+ const ctx = canvas.getContext('2d');
19545
+ const targetWidth = window === null || window === void 0 ? void 0 : window.innerWidth;
19546
+ const targetHeight = window === null || window === void 0 ? void 0 : window.innerHeight;
19547
+ canvas.height = targetHeight;
19548
+ canvas.width = targetWidth;
19549
+ ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
19550
+ setFirstFrameSrc(canvas.toDataURL());
19551
+ }, []);
19552
+ const handleTimeUpload = useCallback(() => {
19553
+ var _a, _b, _c;
19554
+ if (!videoRef.current)
19555
+ return;
19556
+ 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)) {
19557
+ (_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
19558
+ }
19559
+ }, []);
19560
+ const handlePause = () => {
19561
+ var _a, _b, _c, _d, _e, _f;
19562
+ if (!loopPlay)
19563
+ return;
19564
+ if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
19565
+ (_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);
19566
+ }
19567
+ else {
19568
+ 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;
19569
+ (_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);
19570
+ }
19571
+ };
19572
+ // useEffect(() => {
19573
+ // if (!isActive) return;
19574
+ // if (!loopPlay) {
19575
+ // videoRef?.current?.pause();
19576
+ // } else {
19577
+ // videoRef?.current?.play();
19578
+ // }
19579
+ // }, [loopPlay, isActive]);
19580
+ useEffect(() => {
19581
+ var _a, _b, _c;
19582
+ if (!isActive)
19583
+ return;
19584
+ const videoSrc = rec === null || rec === void 0 ? void 0 : rec.mediaUrl;
19585
+ if (!videoSrc)
19586
+ return;
19587
+ setIsPauseVideo(false);
19588
+ const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
19589
+ if (!videoPlayerWrapperNode)
19590
+ return;
19591
+ videoRef.current = mountVideoPlayerAtNode === null || mountVideoPlayerAtNode === void 0 ? void 0 : mountVideoPlayerAtNode(videoPlayerWrapperNode);
19592
+ videoRef.current.currentTime = rec === null || rec === void 0 ? void 0 : rec.startTime;
19593
+ if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
19594
+ return;
19595
+ const Hls = window === null || window === void 0 ? void 0 : window.Hls;
19596
+ let hls = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current;
19597
+ if (videoSrc.includes('.m3u8') && Hls && Hls.isSupported()) {
19598
+ hls = new Hls();
19599
+ hls === null || hls === void 0 ? void 0 : hls.loadSource(videoSrc);
19600
+ hls === null || hls === void 0 ? void 0 : hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
19601
+ hls === null || hls === void 0 ? void 0 : hls.on(Hls.Events.MANIFEST_PARSED, function () {
19602
+ var _a;
19603
+ (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
19604
+ });
19605
+ }
19606
+ else {
19607
+ videoRef.current.src = videoSrc;
19608
+ }
19609
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('loadedmetadata', handleLoadedMetadata);
19610
+ // videoRef.current?.addEventListener('playing', handlePlaying);
19611
+ // videoRef.current?.addEventListener('loadeddata', handLoadeddata);
19612
+ (_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('pause', handlePause);
19613
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.addEventListener('timeupdate', handleTimeUpload);
19614
+ return () => {
19615
+ var _a, _b, _c, _d;
19616
+ if (hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current)
19617
+ (_a = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
19618
+ setIsLoadFinish(false);
19619
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('loadedmetadata', handleLoadedMetadata);
19620
+ // videoRef.current?.removeEventListener('playing', handlePlaying);
19621
+ // videoRef.current?.removeEventListener('loadeddata', handLoadeddata);
19622
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('pause', handlePause);
19623
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.removeEventListener('timeupdate', handleTimeUpload);
19624
+ };
19625
+ }, [handleLoadedMetadata, handlePlaying, rec, handLoadeddata, isActive]);
19626
+ useMemo(() => {
19627
+ if (!(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image) || isLoadFinish) {
19628
+ return null;
19629
+ }
19630
+ 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' }));
19631
+ }, [isLoadFinish, sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image]);
19632
+ useMemo(() => {
19633
+ return blur
19634
+ ? {
19635
+ filter: 'blur(10px)',
19636
+ transform: 'translate3d(0px, 0px, 0px) scale(1.2)'
19637
+ }
19638
+ : {};
19639
+ }, [blur]);
19640
+ if (!(rec === null || rec === void 0 ? void 0 : rec.mediaUrl)) {
19641
+ return null;
19642
+ }
19643
+ return (React.createElement("div", { className: 'video-container', key: rec.itemId, style: {
19644
+ position: 'relative',
19645
+ width: '100%',
19646
+ height,
19647
+ overflow: 'hidden',
19648
+ pointerEvents: 'none'
19649
+ } },
19650
+ React.createElement("div", { className: 'n-full-screen', id: videoId, style: { width: '100%', height: '100%' } })));
19651
+ };
19652
+ var VideoWidget$1 = memo(VideoWidget);
19653
+
19654
+ /*
19655
+ * @Author: binruan@chatlabs.com
19656
+ * @Date: 2025-03-25 13:54:27
19657
+ * @LastEditors: binruan@chatlabs.com
19658
+ * @LastEditTime: 2025-03-26 15:01:42
19659
+ * @FilePath: \pb-sxp-ui\src\core\components\DiyStoryPreview\index.tsx
19660
+ *
19661
+ */
19662
+ const RESOLVER$1 = {};
19663
+ Object.values(_materials_).forEach((v) => {
19664
+ RESOLVER$1[v.extend.type] = v;
19665
+ });
19666
+ const defaultUnLikeIconPath = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
19667
+ const defaultLikeIconPath = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
19668
+ const DiyStoryPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, descStyle, hashTagStyle, containerHeight = 664, containerWidth = 375, appDomain, tagList = [], scenes, onActiveChange, activeIndex, loopPlay = false }) => {
19669
+ const swiperRef = useRef(null);
19670
+ useMemo(() => {
19671
+ let minusHeight = 0;
19672
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
19673
+ minusHeight += 45;
19674
+ }
19675
+ if (tagList.length > 0) {
19676
+ minusHeight += 45;
19677
+ }
19678
+ return containerHeight - minusHeight;
19679
+ }, [globalConfig, containerHeight, tagList]);
19680
+ // 判断是否是视频
19681
+ const isVideoUrl = (url) => {
19682
+ if (url && url !== '' && typeof url === 'string') {
19683
+ const imageExtensions = ['.mp4', '.m3u8'];
19684
+ const lowerCaseUrl = url === null || url === void 0 ? void 0 : url.toLowerCase();
19685
+ return imageExtensions.some((ext) => lowerCaseUrl === null || lowerCaseUrl === void 0 ? void 0 : lowerCaseUrl.endsWith(ext));
19686
+ }
19687
+ else {
19688
+ return false;
19689
+ }
19690
+ };
19691
+ const renderContent = (rec, index) => {
19692
+ const isVideo = isVideoUrl(rec === null || rec === void 0 ? void 0 : rec.mediaUrl);
19693
+ if (isVideo) {
19694
+ 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 }));
19695
+ }
19696
+ else {
19697
+ 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 }));
19698
+ }
19699
+ };
19700
+ useMemo(() => {
19701
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
19702
+ return (React.createElement("div", { className: 'clc-sxp-logo-banner', style: { backgroundColor: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.color } },
19703
+ React.createElement("img", { src: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl, alt: 'logo' })));
19704
+ }
19705
+ return null;
19706
+ }, [globalConfig]);
19707
+ useIconLink(defaultLikeIconPath, appDomain);
19708
+ useIconLink(defaultUnLikeIconPath, appDomain);
19709
+ useIconLink('/pb_static/5beaaa5ce7f3477b99db3838619cc471.png', appDomain);
19710
+ useIconLink('/pb_static/fea8668a8a894e4aa3a86bcc775e895e.png', appDomain);
19711
+ const renderView = (rec, index) => {
19712
+ return (React.createElement(SwiperSlide, { key: index, virtualIndex: index, style: { overflow: 'hidden', position: 'relative' } }, renderContent(rec, index)));
19713
+ };
19714
+ useEffect(() => {
19715
+ var _a, _b;
19716
+ if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
19717
+ return;
19718
+ (_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);
19719
+ }, [activeIndex]);
19720
+ useEffect(() => {
19721
+ var _a, _b;
19722
+ if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
19723
+ return;
19724
+ (_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);
19725
+ }, [loopPlay]);
19726
+ return (React.createElement(Swiper, { ref: swiperRef, allowTouchMove: false, onActiveIndexChange: (swiper) => {
19727
+ // setActiveIndex(swiper.activeIndex);
19728
+ onActiveChange === null || onActiveChange === void 0 ? void 0 : onActiveChange(swiper.activeIndex);
19729
+ }, direction: 'vertical', style: { overflow: 'hidden', height: containerHeight } }, scenes === null || scenes === void 0 ? void 0 : scenes.map((rec, index) => {
19730
+ return renderView(rec, index);
19731
+ })));
19732
+ };
19733
+ var index$1 = memo(DiyStoryPreview);
19434
19734
 
19435
19735
  /*
19436
19736
  * @Author: binruan@chatlabs.com
@@ -19569,9 +19869,9 @@ var index = memo(SxpPageCore);
19569
19869
  * @Author : haocanweng@chatlabs.cn
19570
19870
  * @Date : 2023-08-21 16:31:58
19571
19871
  * @LastEditors: binruan@chatlabs.com
19572
- * @LastEditTime: 2024-06-25 11:37:48
19872
+ * @LastEditTime: 2025-03-25 14:31:53
19573
19873
  * @FilePath: \pb-sxp-ui\src\index.ts
19574
19874
  */
19575
19875
 
19576
- export { index$1 as DiyPortalPreview, EditorDataProvider, Modal$1 as Modal, SxpDataSourceProvider$1 as SxpDataSourceProvider, index as SxpPageCore, SxpPageRender$1 as SxpPageRender, index$2 as core, Pagebuilder as default, _materials_ as materials, useEditorDataProvider };
19876
+ export { index$2 as DiyPortalPreview, index$1 as DiyStoryPreview, EditorDataProvider, Modal$1 as Modal, SxpDataSourceProvider$1 as SxpDataSourceProvider, index as SxpPageCore, SxpPageRender$1 as SxpPageRender, index$3 as core, Pagebuilder as default, _materials_ as materials, useEditorDataProvider };
19577
19877
  //# sourceMappingURL=index.js.map