pb-sxp-ui 1.15.13-alpha.4 → 1.15.13-alpha.5
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 +104 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +104 -49
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +5 -5
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +5 -5
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +104 -49
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +5 -5
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/DiyStoryPreview/VideoWidget.d.ts +9 -3
- package/es/core/components/DiyStoryPreview/VideoWidget.js +63 -21
- package/es/core/components/DiyStoryPreview/index.d.ts +19 -2
- package/es/core/components/DiyStoryPreview/index.js +39 -13
- package/lib/core/components/DiyStoryPreview/VideoWidget.d.ts +9 -3
- package/lib/core/components/DiyStoryPreview/VideoWidget.js +62 -20
- package/lib/core/components/DiyStoryPreview/index.d.ts +19 -2
- package/lib/core/components/DiyStoryPreview/index.js +38 -12
- package/package.json +1 -1
package/dist/pb-ui.js
CHANGED
@@ -19475,7 +19475,7 @@ Made in Italy` })));
|
|
19475
19475
|
};
|
19476
19476
|
var PictureGroup$1 = React.memo(PictureGroup);
|
19477
19477
|
|
19478
|
-
const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width, swiperRef,
|
19478
|
+
const VideoWidget = React.forwardRef(({ rec, index, height, data, muted, activeIndex, videoPostConfig, width, swiperRef, videoPlayIcon, handleUpdateTimeline, loopPlay }, ref) => {
|
19479
19479
|
const { isActive } = useSwiperSlide();
|
19480
19480
|
const [isPauseVideo, setIsPauseVideo] = React.useState(false);
|
19481
19481
|
const videoRef = React.useRef(null);
|
@@ -19487,6 +19487,38 @@ Made in Italy` })));
|
|
19487
19487
|
const [firstFrameSrc, setFirstFrameSrc] = React.useState('');
|
19488
19488
|
const videoId = `pb-cache-video-${index}`;
|
19489
19489
|
const hlsRef = React.useRef(null);
|
19490
|
+
const loopPlayRef = React.useRef(loopPlay);
|
19491
|
+
React.useEffect(() => {
|
19492
|
+
loopPlayRef.current = loopPlay;
|
19493
|
+
}, [loopPlay]);
|
19494
|
+
React.useImperativeHandle(ref, () => {
|
19495
|
+
return {
|
19496
|
+
play() {
|
19497
|
+
var _a;
|
19498
|
+
if (!videoRef.current)
|
19499
|
+
return;
|
19500
|
+
handleTimeUpload();
|
19501
|
+
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
19502
|
+
setIsPauseVideo(false);
|
19503
|
+
},
|
19504
|
+
pause() {
|
19505
|
+
var _a;
|
19506
|
+
if (!videoRef.current)
|
19507
|
+
return;
|
19508
|
+
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.pause();
|
19509
|
+
setIsPauseVideo(true);
|
19510
|
+
},
|
19511
|
+
setLoopPlay(v) {
|
19512
|
+
if (!videoRef.current)
|
19513
|
+
return;
|
19514
|
+
loopPlayRef.current = v;
|
19515
|
+
},
|
19516
|
+
isPlaying() {
|
19517
|
+
var _a;
|
19518
|
+
return !((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.paused);
|
19519
|
+
}
|
19520
|
+
};
|
19521
|
+
});
|
19490
19522
|
React.useEffect(() => {
|
19491
19523
|
if (!videoRef.current)
|
19492
19524
|
return;
|
@@ -19497,7 +19529,7 @@ Made in Italy` })));
|
|
19497
19529
|
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
19498
19530
|
}, []);
|
19499
19531
|
const PAUSE_ICON = useIconLink('/pb_static/06f28a2025c74c1cb49be6767316d827.png');
|
19500
|
-
|
19532
|
+
React.useCallback(() => {
|
19501
19533
|
var _a, _b, _c, _d, _e, _f;
|
19502
19534
|
setIsPauseVideo(false);
|
19503
19535
|
const item = data[index];
|
@@ -19514,9 +19546,9 @@ Made in Italy` })));
|
|
19514
19546
|
(_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
19515
19547
|
setIsLoadFinish(true);
|
19516
19548
|
}, []);
|
19517
|
-
React.useCallback((type) => () => {
|
19518
|
-
var _a, _b, _c, _d, _e;
|
19519
|
-
if (!isLoadFinish)
|
19549
|
+
const handleClickVideo = React.useCallback((type) => () => {
|
19550
|
+
var _a, _b, _c, _d, _e, _f;
|
19551
|
+
if (!isActive || !(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
|
19520
19552
|
return;
|
19521
19553
|
const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
|
19522
19554
|
switch (type) {
|
@@ -19534,13 +19566,13 @@ Made in Italy` })));
|
|
19534
19566
|
break;
|
19535
19567
|
default:
|
19536
19568
|
if (isPause) {
|
19537
|
-
|
19538
|
-
|
19539
|
-
|
19540
|
-
(
|
19569
|
+
if (((_d = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _d === void 0 ? void 0 : _d.currentTime) >= (rec === null || rec === void 0 ? void 0 : rec.endTime)) {
|
19570
|
+
videoRef.current.currentTime = rec === null || rec === void 0 ? void 0 : rec.startTime;
|
19571
|
+
}
|
19572
|
+
(_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.play();
|
19541
19573
|
}
|
19542
19574
|
else {
|
19543
|
-
(
|
19575
|
+
(_f = videoRef.current) === null || _f === void 0 ? void 0 : _f.pause();
|
19544
19576
|
}
|
19545
19577
|
setIsPauseVideo(!isPause);
|
19546
19578
|
break;
|
@@ -19564,7 +19596,7 @@ Made in Italy` })));
|
|
19564
19596
|
? `translateY(-${50 + ((_a = videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.offsetTop) !== null && _a !== void 0 ? _a : 0)}%) translate3d(0px, 0px, 0px)`
|
19565
19597
|
: 'translateY(-50%)';
|
19566
19598
|
}, [videoPostConfig]);
|
19567
|
-
|
19599
|
+
React.useCallback(() => {
|
19568
19600
|
if (!canvasRef || !videoRef || !videoRef.current || !canvasRef.current)
|
19569
19601
|
return;
|
19570
19602
|
const video = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current;
|
@@ -19578,35 +19610,34 @@ Made in Italy` })));
|
|
19578
19610
|
setFirstFrameSrc(canvas.toDataURL());
|
19579
19611
|
}, []);
|
19580
19612
|
const handleTimeUpload = React.useCallback(() => {
|
19581
|
-
var _a
|
19613
|
+
var _a;
|
19582
19614
|
if (!videoRef.current)
|
19583
19615
|
return;
|
19584
|
-
|
19585
|
-
|
19586
|
-
|
19616
|
+
const localTime = ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.currentTime) - (rec === null || rec === void 0 ? void 0 : rec.startTime);
|
19617
|
+
handleUpdateTimeline === null || handleUpdateTimeline === void 0 ? void 0 : handleUpdateTimeline(index, localTime);
|
19618
|
+
setTimeout(() => {
|
19619
|
+
var _a, _b;
|
19620
|
+
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)) {
|
19621
|
+
slideSwiper();
|
19622
|
+
}
|
19623
|
+
});
|
19587
19624
|
}, []);
|
19588
|
-
|
19589
|
-
|
19590
|
-
|
19591
|
-
|
19592
|
-
// } else {
|
19593
|
-
// videoRef.current?.pause();
|
19594
|
-
// }
|
19595
|
-
// }, [isPlay, isActive]);
|
19596
|
-
const handlePause = () => {
|
19597
|
-
var _a, _b, _c, _d, _e, _f;
|
19598
|
-
if (!videoRef.current || !isActive)
|
19599
|
-
return;
|
19600
|
-
if (!loopPlay)
|
19625
|
+
const slideSwiper = () => {
|
19626
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
19627
|
+
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.pause();
|
19628
|
+
if (!loopPlayRef.current)
|
19601
19629
|
return;
|
19602
19630
|
if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
|
19603
|
-
(
|
19631
|
+
(_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.slideTo(0);
|
19604
19632
|
}
|
19605
19633
|
else {
|
19606
|
-
const i = (
|
19607
|
-
(
|
19634
|
+
const i = (_e = (_d = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _d === void 0 ? void 0 : _d.swiper) === null || _e === void 0 ? void 0 : _e.activeIndex;
|
19635
|
+
(_g = (_f = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _f === void 0 ? void 0 : _f.swiper) === null || _g === void 0 ? void 0 : _g.slideTo(i + 1);
|
19608
19636
|
}
|
19609
19637
|
};
|
19638
|
+
const handlePause = () => {
|
19639
|
+
setIsPauseVideo(true);
|
19640
|
+
};
|
19610
19641
|
React.useEffect(() => {
|
19611
19642
|
var _a, _b, _c;
|
19612
19643
|
if (!isActive)
|
@@ -19652,7 +19683,7 @@ Made in Italy` })));
|
|
19652
19683
|
(_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('pause', handlePause);
|
19653
19684
|
(_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.removeEventListener('timeupdate', handleTimeUpload);
|
19654
19685
|
};
|
19655
|
-
}, [
|
19686
|
+
}, [isActive]);
|
19656
19687
|
const renderPoster = React.useMemo(() => {
|
19657
19688
|
if (!(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image) || isLoadFinish) {
|
19658
19689
|
return null;
|
@@ -19695,18 +19726,18 @@ Made in Italy` })));
|
|
19695
19726
|
width: '100%',
|
19696
19727
|
height,
|
19697
19728
|
overflow: 'hidden'
|
19698
|
-
} },
|
19729
|
+
}, onClick: handleClickVideo() },
|
19699
19730
|
React.createElement("div", { className: 'n-full-screen', id: videoId, style: { width: '100%', height: '100%' } }),
|
19700
19731
|
renderPoster,
|
19701
19732
|
isPauseVideo && React.createElement(FormatImage$1, { className: 'clc-pb-video-pause', src: videoPlayIcon !== null && videoPlayIcon !== void 0 ? videoPlayIcon : PAUSE_ICON, alt: 'pause' })));
|
19702
|
-
};
|
19733
|
+
});
|
19703
19734
|
var VideoWidget$1 = React.memo(VideoWidget);
|
19704
19735
|
|
19705
19736
|
/*
|
19706
19737
|
* @Author: binruan@chatlabs.com
|
19707
19738
|
* @Date: 2025-03-25 13:54:27
|
19708
19739
|
* @LastEditors: binruan@chatlabs.com
|
19709
|
-
* @LastEditTime: 2025-03-
|
19740
|
+
* @LastEditTime: 2025-03-31 14:29:21
|
19710
19741
|
* @FilePath: \pb-sxp-ui\src\core\components\DiyStoryPreview\index.tsx
|
19711
19742
|
*
|
19712
19743
|
*/
|
@@ -19894,9 +19925,10 @@ Made in Italy` })));
|
|
19894
19925
|
});
|
19895
19926
|
const defaultUnLikeIconPath = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
|
19896
19927
|
const defaultLikeIconPath = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
|
19897
|
-
const DiyStoryPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, descStyle, hashTagStyle, containerHeight = 664, containerWidth = 375, appDomain, tagList = [], scenes, onActiveChange, activeIndex, loopPlay = false, pointerEvents = 'none',
|
19898
|
-
const
|
19928
|
+
const DiyStoryPreview = React.forwardRef(({ data = [], globalConfig, tipText, nudge, tempMap, descStyle, hashTagStyle, containerHeight = 664, containerWidth = 375, appDomain, tagList = [], scenes, onActiveChange, activeIndex, loopPlay = false, pointerEvents = 'none', onUpdateTimeLine, disabledListener }, ref) => {
|
19929
|
+
const videoWidgetRef = React.useRef(null);
|
19899
19930
|
const swiperRef = React.useRef(null);
|
19931
|
+
const [curIndex, setCurIndex] = React.useState(0);
|
19900
19932
|
React.useMemo(() => {
|
19901
19933
|
let minusHeight = 0;
|
19902
19934
|
if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
|
@@ -19907,6 +19939,32 @@ Made in Italy` })));
|
|
19907
19939
|
}
|
19908
19940
|
return containerHeight - minusHeight;
|
19909
19941
|
}, [globalConfig, containerHeight, tagList]);
|
19942
|
+
React.useImperativeHandle(ref, () => {
|
19943
|
+
return {
|
19944
|
+
play() {
|
19945
|
+
var _a;
|
19946
|
+
(_a = videoWidgetRef === null || videoWidgetRef === void 0 ? void 0 : videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
19947
|
+
},
|
19948
|
+
pause() {
|
19949
|
+
var _a;
|
19950
|
+
(_a = videoWidgetRef === null || videoWidgetRef === void 0 ? void 0 : videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.pause();
|
19951
|
+
},
|
19952
|
+
slideTo(n) {
|
19953
|
+
var _a, _b;
|
19954
|
+
if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
|
19955
|
+
return;
|
19956
|
+
(_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(n);
|
19957
|
+
},
|
19958
|
+
isPlaying() {
|
19959
|
+
var _a, _b;
|
19960
|
+
return (_b = (_a = videoWidgetRef === null || videoWidgetRef === void 0 ? void 0 : videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.isPlaying()) !== null && _b !== void 0 ? _b : false;
|
19961
|
+
},
|
19962
|
+
setLoopPlay(v) {
|
19963
|
+
var _a;
|
19964
|
+
(_a = videoWidgetRef === null || videoWidgetRef === void 0 ? void 0 : videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.setLoopPlay(v);
|
19965
|
+
}
|
19966
|
+
};
|
19967
|
+
});
|
19910
19968
|
// 判断是否是视频
|
19911
19969
|
const isVideoUrl = (url) => {
|
19912
19970
|
if (url && url !== '' && typeof url === 'string') {
|
@@ -19921,10 +19979,10 @@ Made in Italy` })));
|
|
19921
19979
|
const renderContent = (rec, index) => {
|
19922
19980
|
const isVideo = isVideoUrl(rec === null || rec === void 0 ? void 0 : rec.mediaUrl);
|
19923
19981
|
if (isVideo) {
|
19924
|
-
return (React.createElement(VideoWidget$1, {
|
19982
|
+
return (React.createElement(VideoWidget$1, Object.assign({ key: index }, (curIndex === index && { ref: videoWidgetRef }), { 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, videoPlayIcon: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPlayIcon, swiperRef: swiperRef, loopPlay: loopPlay, handleUpdateTimeline: onUpdateTimeLine })));
|
19925
19983
|
}
|
19926
19984
|
else {
|
19927
|
-
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
|
19985
|
+
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 }));
|
19928
19986
|
}
|
19929
19987
|
};
|
19930
19988
|
React.useMemo(() => {
|
@@ -20062,16 +20120,13 @@ Made in Italy` })));
|
|
20062
20120
|
return;
|
20063
20121
|
(_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);
|
20064
20122
|
}, [activeIndex]);
|
20065
|
-
React.useEffect(() => {
|
20066
|
-
if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
|
20067
|
-
return;
|
20068
|
-
// swiperRef?.current?.swiper?.slideTo(0);
|
20069
|
-
setLooPlaySwiper(loopPlay);
|
20070
|
-
}, [loopPlay]);
|
20071
20123
|
const handleSessionExpire = React.useCallback(lodash.debounce(() => {
|
20072
|
-
|
20124
|
+
var _a;
|
20125
|
+
(_a = videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.setLoopPlay(false);
|
20073
20126
|
}, 1000), []);
|
20074
20127
|
React.useEffect(() => {
|
20128
|
+
if (disabledListener)
|
20129
|
+
return;
|
20075
20130
|
const events = ['touchstart', 'touchcancel'];
|
20076
20131
|
events.forEach((event) => {
|
20077
20132
|
window.addEventListener(event, handleSessionExpire);
|
@@ -20081,7 +20136,7 @@ Made in Italy` })));
|
|
20081
20136
|
window.removeEventListener(event, handleSessionExpire);
|
20082
20137
|
});
|
20083
20138
|
};
|
20084
|
-
}, [handleSessionExpire]);
|
20139
|
+
}, [handleSessionExpire, disabledListener]);
|
20085
20140
|
return (React.createElement("div", { id: 'sxp-render',
|
20086
20141
|
// className={style['clc-sxp-container']}
|
20087
20142
|
style: { height: containerHeight, position: 'relative', pointerEvents } },
|
@@ -20091,12 +20146,12 @@ Made in Italy` })));
|
|
20091
20146
|
swiperRef.current.swiper.allowTouchMove = true;
|
20092
20147
|
}, 500);
|
20093
20148
|
}, onActiveIndexChange: (swiper) => {
|
20094
|
-
|
20149
|
+
setCurIndex(swiper === null || swiper === void 0 ? void 0 : swiper.activeIndex);
|
20095
20150
|
onActiveChange === null || onActiveChange === void 0 ? void 0 : onActiveChange(swiper.activeIndex);
|
20096
20151
|
}, direction: 'vertical', style: { overflow: 'hidden', height: containerHeight }, height: containerHeight }, scenes === null || scenes === void 0 ? void 0 : scenes.map((rec, index) => {
|
20097
20152
|
return renderView(rec, index);
|
20098
20153
|
}))));
|
20099
|
-
};
|
20154
|
+
});
|
20100
20155
|
var DiyStoryPreview$1 = React.memo(DiyStoryPreview);
|
20101
20156
|
|
20102
20157
|
/*
|