pb-sxp-ui 1.0.63 → 1.0.65

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
@@ -11,7 +11,6 @@ var EventEmitter = require('eventemitter3');
11
11
  var css = require('@emotion/css');
12
12
  var proComponents = require('@ant-design/pro-components');
13
13
  var ReactDOM = require('react-dom');
14
- var Hls = require('hls.js');
15
14
 
16
15
  function _interopNamespaceDefault(e) {
17
16
  var n = Object.create(null);
@@ -447,7 +446,7 @@ var DataSourceType;
447
446
  DataSourceType[DataSourceType["BFF"] = 5] = "BFF";
448
447
  })(DataSourceType || (DataSourceType = {}));
449
448
  const UTM_KEYS = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_id', 'utm_content', 'cl_source'];
450
- const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent = true, maxSize, defaultSize, isPreview = false, sxpParameter, appDomain, hashTagSize, loadingImage, isOpenHashTag = false, enabledMetaConversionApi = false }) => {
449
+ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent = true, maxSize, defaultSize, isPreview = false, sxpParameter, appDomain, hashTagSize, loadingImage, isOpenHashTag = false, enabledMetaConversionApi = false, isShowTag = true }) => {
451
450
  const [rtcList, setRtcList] = React.useState([]);
452
451
  const [tagList, setTagList] = React.useState([]);
453
452
  const [loading, setLoading] = React.useState(false);
@@ -601,7 +600,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
601
600
  // 获取 Tag
602
601
  const bffGetTagList = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
603
602
  var _h, _j, _k, _l, _m;
604
- if (!utmVal)
603
+ if (!utmVal || !isShowTag)
605
604
  return;
606
605
  try {
607
606
  const val = (_k = (_j = (_h = utmVal === null || utmVal === void 0 ? void 0 : utmVal.split('&')) === null || _h === void 0 ? void 0 : _h.filter((val) => {
@@ -614,7 +613,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
614
613
  catch (e) {
615
614
  console.log('e', e);
616
615
  }
617
- }), [bffFetch, utmVal]);
616
+ }), [bffFetch, utmVal, isShowTag]);
618
617
  const ctaEvent = React.useCallback((eventInfo, rec, product, position) => {
619
618
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
620
619
  const cta = product === null || product === void 0 ? void 0 : product.bindCta;
@@ -8392,7 +8391,7 @@ var ExpandableText$1 = React.memo(ExpandableText);
8392
8391
  * @Author: binruan@chatlabs.com
8393
8392
  * @Date: 2024-03-20 10:27:31
8394
8393
  * @LastEditors: binruan@chatlabs.com
8395
- * @LastEditTime: 2024-04-19 14:12:55
8394
+ * @LastEditTime: 2024-05-17 16:53:11
8396
8395
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\FormatImage.tsx
8397
8396
  *
8398
8397
  */
@@ -8404,10 +8403,32 @@ const FormatImage = React.forwardRef((props, ref) => {
8404
8403
  setImgSrc(v);
8405
8404
  }
8406
8405
  }));
8406
+ // useEffect(() => {
8407
+ // setImgSrc(src);
8408
+ // }, [src]);
8409
+ const imgRef = React.useRef(null);
8407
8410
  React.useEffect(() => {
8408
- setImgSrc(src);
8411
+ let observer = null;
8412
+ const { current } = imgRef;
8413
+ if (current) {
8414
+ observer = new IntersectionObserver((entries) => {
8415
+ entries.forEach((entry) => {
8416
+ if (entry.isIntersecting) {
8417
+ setImgSrc(src);
8418
+ observer.unobserve(current);
8419
+ }
8420
+ });
8421
+ }, { threshold: 0.1 } // 触发阈值,可根据需要调整
8422
+ );
8423
+ observer.observe(current);
8424
+ }
8425
+ return () => {
8426
+ if (observer && current) {
8427
+ observer.unobserve(current);
8428
+ }
8429
+ };
8409
8430
  }, [src]);
8410
- return (React.createElement(React.Fragment, null, (imgSrc === null || imgSrc === void 0 ? void 0 : imgSrc.includes('.avif')) ? (React.createElement("picture", null,
8431
+ return (React.createElement("div", { ref: imgRef }, (imgSrc === null || imgSrc === void 0 ? void 0 : imgSrc.includes('.avif')) ? (React.createElement("picture", null,
8411
8432
  React.createElement("source", { type: 'image/avif', srcSet: imgSrc }),
8412
8433
  React.createElement("source", { type: 'image/webp', srcSet: `${imgSrc}?imageMogr2/format/webp` }),
8413
8434
  React.createElement("source", { type: 'image/jpeg', srcSet: `${imgSrc}?imageMogr2/format/jpg` }),
@@ -12314,6 +12335,7 @@ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPost
12314
12335
  const videoSrc = rec.video.url;
12315
12336
  if (!videoSrc)
12316
12337
  return;
12338
+ videoRef === null || videoRef === void 0 ? void 0 : videoRef.src(videoSrc);
12317
12339
  setIsPauseVideo(false);
12318
12340
  const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
12319
12341
  const dom = document.querySelector('#player-container-id');
@@ -12321,7 +12343,6 @@ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPost
12321
12343
  if (!dom && !dom2)
12322
12344
  return;
12323
12345
  videoPlayerWrapperNode === null || videoPlayerWrapperNode === void 0 ? void 0 : videoPlayerWrapperNode.appendChild(dom || dom2);
12324
- videoRef === null || videoRef === void 0 ? void 0 : videoRef.src(videoSrc);
12325
12346
  videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('loadedmetadata', handleLoadedmetadata);
12326
12347
  videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('loadeddata', handLoadeddata);
12327
12348
  // videoRef?.on('canplay', handleCanplay);
@@ -12777,7 +12798,7 @@ var Tagbar$1 = React.memo(Tagbar);
12777
12798
  * @Author: binruan@chatlabs.com
12778
12799
  * @Date: 2024-01-15 19:03:09
12779
12800
  * @LastEditors: binruan@chatlabs.com
12780
- * @LastEditTime: 2024-05-09 16:23:59
12801
+ * @LastEditTime: 2024-05-20 10:04:39
12781
12802
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
12782
12803
  *
12783
12804
  */
@@ -12837,7 +12858,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
12837
12858
  };
12838
12859
  const firstRef = React.useRef();
12839
12860
  React.useEffect(() => {
12840
- if (!firstRef.current && !videoRef) {
12861
+ if (!firstRef.current && !videoRef && (playerRef === null || playerRef === void 0 ? void 0 : playerRef.current)) {
12841
12862
  firstRef.current = true;
12842
12863
  const player = TCPlayer('player-container-id', {
12843
12864
  licenseUrl, // license 地址,参考准备工作部分,在视立方控制台申请 license 后可获得 licenseUrl
@@ -13394,8 +13415,8 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
13394
13415
  if (!videoRef.current.src) {
13395
13416
  const videoSrc = rec.video.url;
13396
13417
  if (videoSrc.includes('.m3u8')) {
13397
- if (Hls.isSupported()) {
13398
- const hls = new Hls();
13418
+ if (typeof window !== 'undefined' && (window === null || window === void 0 ? void 0 : window.Hls.isSupported())) {
13419
+ const hls = new window.Hls();
13399
13420
  hls.loadSource(videoSrc);
13400
13421
  hls.attachMedia(videoRef.current);
13401
13422
  }
@@ -13681,7 +13702,7 @@ const Popup = () => {
13681
13702
  * @Author: binruan@chatlabs.com
13682
13703
  * @Date: 2024-01-15 19:03:09
13683
13704
  * @LastEditors: binruan@chatlabs.com
13684
- * @LastEditTime: 2024-05-06 17:26:37
13705
+ * @LastEditTime: 2024-05-17 18:41:05
13685
13706
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageCore\index.tsx
13686
13707
  *
13687
13708
  */
@@ -13698,14 +13719,14 @@ Object.values(_materials_).forEach((v) => {
13698
13719
  RESOLVER[v.extend.type] = v;
13699
13720
  });
13700
13721
  const SxpPageCore = ({ data, maxSize = 10, defaultSize = 10, hashTagSize = 20, loadingImage, appDomain, licenseUrl, enabledMetaConversionApi }) => {
13701
- var _a, _b, _c, _d, _e, _f;
13722
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
13702
13723
  const utmVal = React.useMemo(() => {
13703
13724
  var _a;
13704
13725
  const searchParams = (location === null || location === void 0 ? void 0 : location.search) ? (_a = location === null || location === void 0 ? void 0 : location.search) === null || _a === void 0 ? void 0 : _a.replace('?', '') : '';
13705
13726
  return searchParams;
13706
13727
  }, []);
13707
13728
  return (React.createElement(EditorCore, { resolver: RESOLVER, enableDataSource: false, schema: data === null || data === void 0 ? void 0 : data.data, utmVal: utmVal },
13708
- React.createElement(SxpDataSourceProvider$1, { utmVal: utmVal, dataSources: data === null || data === void 0 ? void 0 : data.data_sources, sxpParameter: data === null || data === void 0 ? void 0 : data.sxp_parameter, maxSize: (_b = (_a = data === null || data === void 0 ? void 0 : data.sxp_parameter) === null || _a === void 0 ? void 0 : _a.personalized_recommend) !== null && _b !== void 0 ? _b : maxSize, defaultSize: (_d = (_c = data === null || data === void 0 ? void 0 : data.sxp_parameter) === null || _c === void 0 ? void 0 : _c.default_recommend) !== null && _d !== void 0 ? _d : defaultSize, hashTagSize: (_f = (_e = data === null || data === void 0 ? void 0 : data.sxp_parameter) === null || _e === void 0 ? void 0 : _e.hash_tag_size) !== null && _f !== void 0 ? _f : hashTagSize, loadingImage: loadingImage, appDomain: appDomain, enabledMetaConversionApi: enabledMetaConversionApi, render: ({ rtcList, tagList }) => {
13729
+ React.createElement(SxpDataSourceProvider$1, { utmVal: utmVal, dataSources: data === null || data === void 0 ? void 0 : data.data_sources, sxpParameter: data === null || data === void 0 ? void 0 : data.sxp_parameter, maxSize: (_b = (_a = data === null || data === void 0 ? void 0 : data.sxp_parameter) === null || _a === void 0 ? void 0 : _a.personalized_recommend) !== null && _b !== void 0 ? _b : maxSize, defaultSize: (_d = (_c = data === null || data === void 0 ? void 0 : data.sxp_parameter) === null || _c === void 0 ? void 0 : _c.default_recommend) !== null && _d !== void 0 ? _d : defaultSize, hashTagSize: (_f = (_e = data === null || data === void 0 ? void 0 : data.sxp_parameter) === null || _e === void 0 ? void 0 : _e.hash_tag_size) !== null && _f !== void 0 ? _f : hashTagSize, loadingImage: loadingImage, appDomain: appDomain, enabledMetaConversionApi: enabledMetaConversionApi, isShowTag: (_j = (_h = (_g = data === null || data === void 0 ? void 0 : data.data) === null || _g === void 0 ? void 0 : _g.sxpPageConf) === null || _h === void 0 ? void 0 : _h.globalConfig) === null || _j === void 0 ? void 0 : _j.isShowTag, render: ({ rtcList, tagList }) => {
13709
13730
  var _a;
13710
13731
  return (React.createElement(React.Fragment, null,
13711
13732
  React.createElement(SxpPageRender, Object.assign({}, (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.sxpPageConf, { tagList: tagList, data: rtcList, resolver: RESOLVER, licenseUrl: licenseUrl })),