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/index.js
CHANGED
@@ -19460,7 +19460,7 @@ const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index, s
|
|
19460
19460
|
};
|
19461
19461
|
var PictureGroup$1 = memo(PictureGroup);
|
19462
19462
|
|
19463
|
-
const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width, swiperRef,
|
19463
|
+
const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex, videoPostConfig, width, swiperRef, videoPlayIcon, handleUpdateTimeline, loopPlay }, ref) => {
|
19464
19464
|
const { isActive } = useSwiperSlide();
|
19465
19465
|
const [isPauseVideo, setIsPauseVideo] = useState(false);
|
19466
19466
|
const videoRef = useRef(null);
|
@@ -19472,6 +19472,38 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
19472
19472
|
const [firstFrameSrc, setFirstFrameSrc] = useState('');
|
19473
19473
|
const videoId = `pb-cache-video-${index}`;
|
19474
19474
|
const hlsRef = useRef(null);
|
19475
|
+
const loopPlayRef = useRef(loopPlay);
|
19476
|
+
useEffect(() => {
|
19477
|
+
loopPlayRef.current = loopPlay;
|
19478
|
+
}, [loopPlay]);
|
19479
|
+
useImperativeHandle(ref, () => {
|
19480
|
+
return {
|
19481
|
+
play() {
|
19482
|
+
var _a;
|
19483
|
+
if (!videoRef.current)
|
19484
|
+
return;
|
19485
|
+
handleTimeUpload();
|
19486
|
+
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
19487
|
+
setIsPauseVideo(false);
|
19488
|
+
},
|
19489
|
+
pause() {
|
19490
|
+
var _a;
|
19491
|
+
if (!videoRef.current)
|
19492
|
+
return;
|
19493
|
+
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.pause();
|
19494
|
+
setIsPauseVideo(true);
|
19495
|
+
},
|
19496
|
+
setLoopPlay(v) {
|
19497
|
+
if (!videoRef.current)
|
19498
|
+
return;
|
19499
|
+
loopPlayRef.current = v;
|
19500
|
+
},
|
19501
|
+
isPlaying() {
|
19502
|
+
var _a;
|
19503
|
+
return !((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.paused);
|
19504
|
+
}
|
19505
|
+
};
|
19506
|
+
});
|
19475
19507
|
useEffect(() => {
|
19476
19508
|
if (!videoRef.current)
|
19477
19509
|
return;
|
@@ -19482,7 +19514,7 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
19482
19514
|
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
19483
19515
|
}, []);
|
19484
19516
|
const PAUSE_ICON = useIconLink('/pb_static/06f28a2025c74c1cb49be6767316d827.png');
|
19485
|
-
|
19517
|
+
useCallback(() => {
|
19486
19518
|
var _a, _b, _c, _d, _e, _f;
|
19487
19519
|
setIsPauseVideo(false);
|
19488
19520
|
const item = data[index];
|
@@ -19499,9 +19531,9 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
19499
19531
|
(_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
19500
19532
|
setIsLoadFinish(true);
|
19501
19533
|
}, []);
|
19502
|
-
useCallback((type) => () => {
|
19503
|
-
var _a, _b, _c, _d, _e;
|
19504
|
-
if (!isLoadFinish)
|
19534
|
+
const handleClickVideo = useCallback((type) => () => {
|
19535
|
+
var _a, _b, _c, _d, _e, _f;
|
19536
|
+
if (!isActive || !(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
|
19505
19537
|
return;
|
19506
19538
|
const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
|
19507
19539
|
switch (type) {
|
@@ -19519,13 +19551,13 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
19519
19551
|
break;
|
19520
19552
|
default:
|
19521
19553
|
if (isPause) {
|
19522
|
-
|
19523
|
-
|
19524
|
-
|
19525
|
-
(
|
19554
|
+
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)) {
|
19555
|
+
videoRef.current.currentTime = rec === null || rec === void 0 ? void 0 : rec.startTime;
|
19556
|
+
}
|
19557
|
+
(_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.play();
|
19526
19558
|
}
|
19527
19559
|
else {
|
19528
|
-
(
|
19560
|
+
(_f = videoRef.current) === null || _f === void 0 ? void 0 : _f.pause();
|
19529
19561
|
}
|
19530
19562
|
setIsPauseVideo(!isPause);
|
19531
19563
|
break;
|
@@ -19549,7 +19581,7 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
19549
19581
|
? `translateY(-${50 + ((_a = videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.offsetTop) !== null && _a !== void 0 ? _a : 0)}%) translate3d(0px, 0px, 0px)`
|
19550
19582
|
: 'translateY(-50%)';
|
19551
19583
|
}, [videoPostConfig]);
|
19552
|
-
|
19584
|
+
useCallback(() => {
|
19553
19585
|
if (!canvasRef || !videoRef || !videoRef.current || !canvasRef.current)
|
19554
19586
|
return;
|
19555
19587
|
const video = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current;
|
@@ -19563,35 +19595,34 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
19563
19595
|
setFirstFrameSrc(canvas.toDataURL());
|
19564
19596
|
}, []);
|
19565
19597
|
const handleTimeUpload = useCallback(() => {
|
19566
|
-
var _a
|
19598
|
+
var _a;
|
19567
19599
|
if (!videoRef.current)
|
19568
19600
|
return;
|
19569
|
-
|
19570
|
-
|
19571
|
-
|
19601
|
+
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);
|
19602
|
+
handleUpdateTimeline === null || handleUpdateTimeline === void 0 ? void 0 : handleUpdateTimeline(index, localTime);
|
19603
|
+
setTimeout(() => {
|
19604
|
+
var _a, _b;
|
19605
|
+
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)) {
|
19606
|
+
slideSwiper();
|
19607
|
+
}
|
19608
|
+
});
|
19572
19609
|
}, []);
|
19573
|
-
|
19574
|
-
|
19575
|
-
|
19576
|
-
|
19577
|
-
// } else {
|
19578
|
-
// videoRef.current?.pause();
|
19579
|
-
// }
|
19580
|
-
// }, [isPlay, isActive]);
|
19581
|
-
const handlePause = () => {
|
19582
|
-
var _a, _b, _c, _d, _e, _f;
|
19583
|
-
if (!videoRef.current || !isActive)
|
19584
|
-
return;
|
19585
|
-
if (!loopPlay)
|
19610
|
+
const slideSwiper = () => {
|
19611
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
19612
|
+
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.pause();
|
19613
|
+
if (!loopPlayRef.current)
|
19586
19614
|
return;
|
19587
19615
|
if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
|
19588
|
-
(
|
19616
|
+
(_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);
|
19589
19617
|
}
|
19590
19618
|
else {
|
19591
|
-
const i = (
|
19592
|
-
(
|
19619
|
+
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;
|
19620
|
+
(_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);
|
19593
19621
|
}
|
19594
19622
|
};
|
19623
|
+
const handlePause = () => {
|
19624
|
+
setIsPauseVideo(true);
|
19625
|
+
};
|
19595
19626
|
useEffect(() => {
|
19596
19627
|
var _a, _b, _c;
|
19597
19628
|
if (!isActive)
|
@@ -19637,7 +19668,7 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
19637
19668
|
(_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('pause', handlePause);
|
19638
19669
|
(_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.removeEventListener('timeupdate', handleTimeUpload);
|
19639
19670
|
};
|
19640
|
-
}, [
|
19671
|
+
}, [isActive]);
|
19641
19672
|
const renderPoster = useMemo(() => {
|
19642
19673
|
if (!(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image) || isLoadFinish) {
|
19643
19674
|
return null;
|
@@ -19680,18 +19711,18 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
19680
19711
|
width: '100%',
|
19681
19712
|
height,
|
19682
19713
|
overflow: 'hidden'
|
19683
|
-
} },
|
19714
|
+
}, onClick: handleClickVideo() },
|
19684
19715
|
React.createElement("div", { className: 'n-full-screen', id: videoId, style: { width: '100%', height: '100%' } }),
|
19685
19716
|
renderPoster,
|
19686
19717
|
isPauseVideo && React.createElement(FormatImage$1, { className: 'clc-pb-video-pause', src: videoPlayIcon !== null && videoPlayIcon !== void 0 ? videoPlayIcon : PAUSE_ICON, alt: 'pause' })));
|
19687
|
-
};
|
19718
|
+
});
|
19688
19719
|
var VideoWidget$1 = memo(VideoWidget);
|
19689
19720
|
|
19690
19721
|
/*
|
19691
19722
|
* @Author: binruan@chatlabs.com
|
19692
19723
|
* @Date: 2025-03-25 13:54:27
|
19693
19724
|
* @LastEditors: binruan@chatlabs.com
|
19694
|
-
* @LastEditTime: 2025-03-
|
19725
|
+
* @LastEditTime: 2025-03-31 14:29:21
|
19695
19726
|
* @FilePath: \pb-sxp-ui\src\core\components\DiyStoryPreview\index.tsx
|
19696
19727
|
*
|
19697
19728
|
*/
|
@@ -19879,9 +19910,10 @@ Object.values(_materials_).forEach((v) => {
|
|
19879
19910
|
});
|
19880
19911
|
const defaultUnLikeIconPath = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
|
19881
19912
|
const defaultLikeIconPath = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
|
19882
|
-
const DiyStoryPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, descStyle, hashTagStyle, containerHeight = 664, containerWidth = 375, appDomain, tagList = [], scenes, onActiveChange, activeIndex, loopPlay = false, pointerEvents = 'none',
|
19883
|
-
const
|
19913
|
+
const DiyStoryPreview = forwardRef(({ data = [], globalConfig, tipText, nudge, tempMap, descStyle, hashTagStyle, containerHeight = 664, containerWidth = 375, appDomain, tagList = [], scenes, onActiveChange, activeIndex, loopPlay = false, pointerEvents = 'none', onUpdateTimeLine, disabledListener }, ref) => {
|
19914
|
+
const videoWidgetRef = useRef(null);
|
19884
19915
|
const swiperRef = useRef(null);
|
19916
|
+
const [curIndex, setCurIndex] = useState(0);
|
19885
19917
|
useMemo(() => {
|
19886
19918
|
let minusHeight = 0;
|
19887
19919
|
if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
|
@@ -19892,6 +19924,32 @@ const DiyStoryPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, des
|
|
19892
19924
|
}
|
19893
19925
|
return containerHeight - minusHeight;
|
19894
19926
|
}, [globalConfig, containerHeight, tagList]);
|
19927
|
+
useImperativeHandle(ref, () => {
|
19928
|
+
return {
|
19929
|
+
play() {
|
19930
|
+
var _a;
|
19931
|
+
(_a = videoWidgetRef === null || videoWidgetRef === void 0 ? void 0 : videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
19932
|
+
},
|
19933
|
+
pause() {
|
19934
|
+
var _a;
|
19935
|
+
(_a = videoWidgetRef === null || videoWidgetRef === void 0 ? void 0 : videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.pause();
|
19936
|
+
},
|
19937
|
+
slideTo(n) {
|
19938
|
+
var _a, _b;
|
19939
|
+
if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
|
19940
|
+
return;
|
19941
|
+
(_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);
|
19942
|
+
},
|
19943
|
+
isPlaying() {
|
19944
|
+
var _a, _b;
|
19945
|
+
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;
|
19946
|
+
},
|
19947
|
+
setLoopPlay(v) {
|
19948
|
+
var _a;
|
19949
|
+
(_a = videoWidgetRef === null || videoWidgetRef === void 0 ? void 0 : videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.setLoopPlay(v);
|
19950
|
+
}
|
19951
|
+
};
|
19952
|
+
});
|
19895
19953
|
// 判断是否是视频
|
19896
19954
|
const isVideoUrl = (url) => {
|
19897
19955
|
if (url && url !== '' && typeof url === 'string') {
|
@@ -19906,10 +19964,10 @@ const DiyStoryPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, des
|
|
19906
19964
|
const renderContent = (rec, index) => {
|
19907
19965
|
const isVideo = isVideoUrl(rec === null || rec === void 0 ? void 0 : rec.mediaUrl);
|
19908
19966
|
if (isVideo) {
|
19909
|
-
return (React.createElement(VideoWidget$1, {
|
19967
|
+
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 })));
|
19910
19968
|
}
|
19911
19969
|
else {
|
19912
|
-
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
|
19970
|
+
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 }));
|
19913
19971
|
}
|
19914
19972
|
};
|
19915
19973
|
useMemo(() => {
|
@@ -20047,16 +20105,13 @@ const DiyStoryPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, des
|
|
20047
20105
|
return;
|
20048
20106
|
(_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);
|
20049
20107
|
}, [activeIndex]);
|
20050
|
-
useEffect(() => {
|
20051
|
-
if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
|
20052
|
-
return;
|
20053
|
-
// swiperRef?.current?.swiper?.slideTo(0);
|
20054
|
-
setLooPlaySwiper(loopPlay);
|
20055
|
-
}, [loopPlay]);
|
20056
20108
|
const handleSessionExpire = useCallback(debounce(() => {
|
20057
|
-
|
20109
|
+
var _a;
|
20110
|
+
(_a = videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.setLoopPlay(false);
|
20058
20111
|
}, 1000), []);
|
20059
20112
|
useEffect(() => {
|
20113
|
+
if (disabledListener)
|
20114
|
+
return;
|
20060
20115
|
const events = ['touchstart', 'touchcancel'];
|
20061
20116
|
events.forEach((event) => {
|
20062
20117
|
window.addEventListener(event, handleSessionExpire);
|
@@ -20066,7 +20121,7 @@ const DiyStoryPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, des
|
|
20066
20121
|
window.removeEventListener(event, handleSessionExpire);
|
20067
20122
|
});
|
20068
20123
|
};
|
20069
|
-
}, [handleSessionExpire]);
|
20124
|
+
}, [handleSessionExpire, disabledListener]);
|
20070
20125
|
return (React.createElement("div", { id: 'sxp-render',
|
20071
20126
|
// className={style['clc-sxp-container']}
|
20072
20127
|
style: { height: containerHeight, position: 'relative', pointerEvents } },
|
@@ -20076,12 +20131,12 @@ const DiyStoryPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, des
|
|
20076
20131
|
swiperRef.current.swiper.allowTouchMove = true;
|
20077
20132
|
}, 500);
|
20078
20133
|
}, onActiveIndexChange: (swiper) => {
|
20079
|
-
|
20134
|
+
setCurIndex(swiper === null || swiper === void 0 ? void 0 : swiper.activeIndex);
|
20080
20135
|
onActiveChange === null || onActiveChange === void 0 ? void 0 : onActiveChange(swiper.activeIndex);
|
20081
20136
|
}, direction: 'vertical', style: { overflow: 'hidden', height: containerHeight }, height: containerHeight }, scenes === null || scenes === void 0 ? void 0 : scenes.map((rec, index) => {
|
20082
20137
|
return renderView(rec, index);
|
20083
20138
|
}))));
|
20084
|
-
};
|
20139
|
+
});
|
20085
20140
|
var DiyStoryPreview$1 = memo(DiyStoryPreview);
|
20086
20141
|
|
20087
20142
|
/*
|