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/pb-ui.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash'), require('uuid'), require('pako'), require('react'), require('qs'), require('eventemitter3'), require('@emotion/css'), require('@ant-design/pro-components'), require('react-dom'), require('hls.js')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'lodash', 'uuid', 'pako', 'react', 'qs', 'eventemitter3', '@emotion/css', '@ant-design/pro-components', 'react-dom', 'hls.js'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.PUI = {}, global.lodash, global.uuid$1, global.pako, global.React, global.qs, global.EventEmitter, global.css, global.proComponents, global.ReactDOM, global.Hls));
5
- })(this, (function (exports, lodash, uuid$1, pako, React, qs, EventEmitter, css, proComponents, ReactDOM, Hls) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash'), require('uuid'), require('pako'), require('react'), require('qs'), require('eventemitter3'), require('@emotion/css'), require('@ant-design/pro-components'), require('react-dom')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'lodash', 'uuid', 'pako', 'react', 'qs', 'eventemitter3', '@emotion/css', '@ant-design/pro-components', 'react-dom'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.PUI = {}, global.lodash, global.uuid$1, global.pako, global.React, global.qs, global.EventEmitter, global.css, global.proComponents, global.ReactDOM));
5
+ })(this, (function (exports, lodash, uuid$1, pako, React, qs, EventEmitter, css, proComponents, ReactDOM) { 'use strict';
6
6
 
7
7
  function _interopNamespaceDefault(e) {
8
8
  var n = Object.create(null);
@@ -438,7 +438,7 @@
438
438
  DataSourceType[DataSourceType["BFF"] = 5] = "BFF";
439
439
  })(DataSourceType || (DataSourceType = {}));
440
440
  const UTM_KEYS = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_id', 'utm_content', 'cl_source'];
441
- const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent = true, maxSize, defaultSize, isPreview = false, sxpParameter, appDomain, hashTagSize, loadingImage, isOpenHashTag = false, enabledMetaConversionApi = false }) => {
441
+ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent = true, maxSize, defaultSize, isPreview = false, sxpParameter, appDomain, hashTagSize, loadingImage, isOpenHashTag = false, enabledMetaConversionApi = false, isShowTag = true }) => {
442
442
  const [rtcList, setRtcList] = React.useState([]);
443
443
  const [tagList, setTagList] = React.useState([]);
444
444
  const [loading, setLoading] = React.useState(false);
@@ -592,7 +592,7 @@
592
592
  // 获取 Tag
593
593
  const bffGetTagList = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
594
594
  var _h, _j, _k, _l, _m;
595
- if (!utmVal)
595
+ if (!utmVal || !isShowTag)
596
596
  return;
597
597
  try {
598
598
  const val = (_k = (_j = (_h = utmVal === null || utmVal === void 0 ? void 0 : utmVal.split('&')) === null || _h === void 0 ? void 0 : _h.filter((val) => {
@@ -605,7 +605,7 @@
605
605
  catch (e) {
606
606
  console.log('e', e);
607
607
  }
608
- }), [bffFetch, utmVal]);
608
+ }), [bffFetch, utmVal, isShowTag]);
609
609
  const ctaEvent = React.useCallback((eventInfo, rec, product, position) => {
610
610
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
611
611
  const cta = product === null || product === void 0 ? void 0 : product.bindCta;
@@ -8383,7 +8383,7 @@
8383
8383
  * @Author: binruan@chatlabs.com
8384
8384
  * @Date: 2024-03-20 10:27:31
8385
8385
  * @LastEditors: binruan@chatlabs.com
8386
- * @LastEditTime: 2024-04-19 14:12:55
8386
+ * @LastEditTime: 2024-05-17 16:53:11
8387
8387
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\FormatImage.tsx
8388
8388
  *
8389
8389
  */
@@ -8395,10 +8395,32 @@
8395
8395
  setImgSrc(v);
8396
8396
  }
8397
8397
  }));
8398
+ // useEffect(() => {
8399
+ // setImgSrc(src);
8400
+ // }, [src]);
8401
+ const imgRef = React.useRef(null);
8398
8402
  React.useEffect(() => {
8399
- setImgSrc(src);
8403
+ let observer = null;
8404
+ const { current } = imgRef;
8405
+ if (current) {
8406
+ observer = new IntersectionObserver((entries) => {
8407
+ entries.forEach((entry) => {
8408
+ if (entry.isIntersecting) {
8409
+ setImgSrc(src);
8410
+ observer.unobserve(current);
8411
+ }
8412
+ });
8413
+ }, { threshold: 0.1 } // 触发阈值,可根据需要调整
8414
+ );
8415
+ observer.observe(current);
8416
+ }
8417
+ return () => {
8418
+ if (observer && current) {
8419
+ observer.unobserve(current);
8420
+ }
8421
+ };
8400
8422
  }, [src]);
8401
- return (React.createElement(React.Fragment, null, (imgSrc === null || imgSrc === void 0 ? void 0 : imgSrc.includes('.avif')) ? (React.createElement("picture", null,
8423
+ return (React.createElement("div", { ref: imgRef }, (imgSrc === null || imgSrc === void 0 ? void 0 : imgSrc.includes('.avif')) ? (React.createElement("picture", null,
8402
8424
  React.createElement("source", { type: 'image/avif', srcSet: imgSrc }),
8403
8425
  React.createElement("source", { type: 'image/webp', srcSet: `${imgSrc}?imageMogr2/format/webp` }),
8404
8426
  React.createElement("source", { type: 'image/jpeg', srcSet: `${imgSrc}?imageMogr2/format/jpg` }),
@@ -12305,6 +12327,7 @@ Made in Italy` })));
12305
12327
  const videoSrc = rec.video.url;
12306
12328
  if (!videoSrc)
12307
12329
  return;
12330
+ videoRef === null || videoRef === void 0 ? void 0 : videoRef.src(videoSrc);
12308
12331
  setIsPauseVideo(false);
12309
12332
  const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
12310
12333
  const dom = document.querySelector('#player-container-id');
@@ -12312,7 +12335,6 @@ Made in Italy` })));
12312
12335
  if (!dom && !dom2)
12313
12336
  return;
12314
12337
  videoPlayerWrapperNode === null || videoPlayerWrapperNode === void 0 ? void 0 : videoPlayerWrapperNode.appendChild(dom || dom2);
12315
- videoRef === null || videoRef === void 0 ? void 0 : videoRef.src(videoSrc);
12316
12338
  videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('loadedmetadata', handleLoadedmetadata);
12317
12339
  videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('loadeddata', handLoadeddata);
12318
12340
  // videoRef?.on('canplay', handleCanplay);
@@ -12768,7 +12790,7 @@ Made in Italy` })));
12768
12790
  * @Author: binruan@chatlabs.com
12769
12791
  * @Date: 2024-01-15 19:03:09
12770
12792
  * @LastEditors: binruan@chatlabs.com
12771
- * @LastEditTime: 2024-05-09 16:23:59
12793
+ * @LastEditTime: 2024-05-20 10:04:39
12772
12794
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
12773
12795
  *
12774
12796
  */
@@ -12828,7 +12850,7 @@ Made in Italy` })));
12828
12850
  };
12829
12851
  const firstRef = React.useRef();
12830
12852
  React.useEffect(() => {
12831
- if (!firstRef.current && !videoRef) {
12853
+ if (!firstRef.current && !videoRef && (playerRef === null || playerRef === void 0 ? void 0 : playerRef.current)) {
12832
12854
  firstRef.current = true;
12833
12855
  const player = TCPlayer('player-container-id', {
12834
12856
  licenseUrl, // license 地址,参考准备工作部分,在视立方控制台申请 license 后可获得 licenseUrl
@@ -13385,8 +13407,8 @@ Made in Italy` })));
13385
13407
  if (!videoRef.current.src) {
13386
13408
  const videoSrc = rec.video.url;
13387
13409
  if (videoSrc.includes('.m3u8')) {
13388
- if (Hls.isSupported()) {
13389
- const hls = new Hls();
13410
+ if (typeof window !== 'undefined' && (window === null || window === void 0 ? void 0 : window.Hls.isSupported())) {
13411
+ const hls = new window.Hls();
13390
13412
  hls.loadSource(videoSrc);
13391
13413
  hls.attachMedia(videoRef.current);
13392
13414
  }
@@ -13672,7 +13694,7 @@ Made in Italy` })));
13672
13694
  * @Author: binruan@chatlabs.com
13673
13695
  * @Date: 2024-01-15 19:03:09
13674
13696
  * @LastEditors: binruan@chatlabs.com
13675
- * @LastEditTime: 2024-05-06 17:26:37
13697
+ * @LastEditTime: 2024-05-17 18:41:05
13676
13698
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageCore\index.tsx
13677
13699
  *
13678
13700
  */
@@ -13689,14 +13711,14 @@ Made in Italy` })));
13689
13711
  RESOLVER[v.extend.type] = v;
13690
13712
  });
13691
13713
  const SxpPageCore = ({ data, maxSize = 10, defaultSize = 10, hashTagSize = 20, loadingImage, appDomain, licenseUrl, enabledMetaConversionApi }) => {
13692
- var _a, _b, _c, _d, _e, _f;
13714
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
13693
13715
  const utmVal = React.useMemo(() => {
13694
13716
  var _a;
13695
13717
  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('?', '') : '';
13696
13718
  return searchParams;
13697
13719
  }, []);
13698
13720
  return (React.createElement(EditorCore, { resolver: RESOLVER, enableDataSource: false, schema: data === null || data === void 0 ? void 0 : data.data, utmVal: utmVal },
13699
- 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 }) => {
13721
+ 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 }) => {
13700
13722
  var _a;
13701
13723
  return (React.createElement(React.Fragment, null,
13702
13724
  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 })),