pb-sxp-ui 1.0.63 → 1.0.64

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);
@@ -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);
@@ -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
  }