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.cjs
CHANGED
@@ -19482,7 +19482,7 @@ const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index, s
|
|
19482
19482
|
};
|
19483
19483
|
var PictureGroup$1 = React.memo(PictureGroup);
|
19484
19484
|
|
19485
|
-
const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width, swiperRef,
|
19485
|
+
const VideoWidget = React.forwardRef(({ rec, index, height, data, muted, activeIndex, videoPostConfig, width, swiperRef, videoPlayIcon, handleUpdateTimeline, loopPlay }, ref) => {
|
19486
19486
|
const { isActive } = useSwiperSlide();
|
19487
19487
|
const [isPauseVideo, setIsPauseVideo] = React.useState(false);
|
19488
19488
|
const videoRef = React.useRef(null);
|
@@ -19494,6 +19494,38 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
19494
19494
|
const [firstFrameSrc, setFirstFrameSrc] = React.useState('');
|
19495
19495
|
const videoId = `pb-cache-video-${index}`;
|
19496
19496
|
const hlsRef = React.useRef(null);
|
19497
|
+
const loopPlayRef = React.useRef(loopPlay);
|
19498
|
+
React.useEffect(() => {
|
19499
|
+
loopPlayRef.current = loopPlay;
|
19500
|
+
}, [loopPlay]);
|
19501
|
+
React.useImperativeHandle(ref, () => {
|
19502
|
+
return {
|
19503
|
+
play() {
|
19504
|
+
var _a;
|
19505
|
+
if (!videoRef.current)
|
19506
|
+
return;
|
19507
|
+
handleTimeUpload();
|
19508
|
+
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
19509
|
+
setIsPauseVideo(false);
|
19510
|
+
},
|
19511
|
+
pause() {
|
19512
|
+
var _a;
|
19513
|
+
if (!videoRef.current)
|
19514
|
+
return;
|
19515
|
+
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.pause();
|
19516
|
+
setIsPauseVideo(true);
|
19517
|
+
},
|
19518
|
+
setLoopPlay(v) {
|
19519
|
+
if (!videoRef.current)
|
19520
|
+
return;
|
19521
|
+
loopPlayRef.current = v;
|
19522
|
+
},
|
19523
|
+
isPlaying() {
|
19524
|
+
var _a;
|
19525
|
+
return !((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.paused);
|
19526
|
+
}
|
19527
|
+
};
|
19528
|
+
});
|
19497
19529
|
React.useEffect(() => {
|
19498
19530
|
if (!videoRef.current)
|
19499
19531
|
return;
|
@@ -19504,7 +19536,7 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
19504
19536
|
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
19505
19537
|
}, []);
|
19506
19538
|
const PAUSE_ICON = useIconLink('/pb_static/06f28a2025c74c1cb49be6767316d827.png');
|
19507
|
-
|
19539
|
+
React.useCallback(() => {
|
19508
19540
|
var _a, _b, _c, _d, _e, _f;
|
19509
19541
|
setIsPauseVideo(false);
|
19510
19542
|
const item = data[index];
|
@@ -19521,9 +19553,9 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
19521
19553
|
(_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
19522
19554
|
setIsLoadFinish(true);
|
19523
19555
|
}, []);
|
19524
|
-
React.useCallback((type) => () => {
|
19525
|
-
var _a, _b, _c, _d, _e;
|
19526
|
-
if (!isLoadFinish)
|
19556
|
+
const handleClickVideo = React.useCallback((type) => () => {
|
19557
|
+
var _a, _b, _c, _d, _e, _f;
|
19558
|
+
if (!isActive || !(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
|
19527
19559
|
return;
|
19528
19560
|
const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
|
19529
19561
|
switch (type) {
|
@@ -19541,13 +19573,13 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
19541
19573
|
break;
|
19542
19574
|
default:
|
19543
19575
|
if (isPause) {
|
19544
|
-
|
19545
|
-
|
19546
|
-
|
19547
|
-
(
|
19576
|
+
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)) {
|
19577
|
+
videoRef.current.currentTime = rec === null || rec === void 0 ? void 0 : rec.startTime;
|
19578
|
+
}
|
19579
|
+
(_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.play();
|
19548
19580
|
}
|
19549
19581
|
else {
|
19550
|
-
(
|
19582
|
+
(_f = videoRef.current) === null || _f === void 0 ? void 0 : _f.pause();
|
19551
19583
|
}
|
19552
19584
|
setIsPauseVideo(!isPause);
|
19553
19585
|
break;
|
@@ -19571,7 +19603,7 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
19571
19603
|
? `translateY(-${50 + ((_a = videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.offsetTop) !== null && _a !== void 0 ? _a : 0)}%) translate3d(0px, 0px, 0px)`
|
19572
19604
|
: 'translateY(-50%)';
|
19573
19605
|
}, [videoPostConfig]);
|
19574
|
-
|
19606
|
+
React.useCallback(() => {
|
19575
19607
|
if (!canvasRef || !videoRef || !videoRef.current || !canvasRef.current)
|
19576
19608
|
return;
|
19577
19609
|
const video = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current;
|
@@ -19585,35 +19617,34 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
19585
19617
|
setFirstFrameSrc(canvas.toDataURL());
|
19586
19618
|
}, []);
|
19587
19619
|
const handleTimeUpload = React.useCallback(() => {
|
19588
|
-
var _a
|
19620
|
+
var _a;
|
19589
19621
|
if (!videoRef.current)
|
19590
19622
|
return;
|
19591
|
-
|
19592
|
-
|
19593
|
-
|
19623
|
+
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);
|
19624
|
+
handleUpdateTimeline === null || handleUpdateTimeline === void 0 ? void 0 : handleUpdateTimeline(index, localTime);
|
19625
|
+
setTimeout(() => {
|
19626
|
+
var _a, _b;
|
19627
|
+
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)) {
|
19628
|
+
slideSwiper();
|
19629
|
+
}
|
19630
|
+
});
|
19594
19631
|
}, []);
|
19595
|
-
|
19596
|
-
|
19597
|
-
|
19598
|
-
|
19599
|
-
// } else {
|
19600
|
-
// videoRef.current?.pause();
|
19601
|
-
// }
|
19602
|
-
// }, [isPlay, isActive]);
|
19603
|
-
const handlePause = () => {
|
19604
|
-
var _a, _b, _c, _d, _e, _f;
|
19605
|
-
if (!videoRef.current || !isActive)
|
19606
|
-
return;
|
19607
|
-
if (!loopPlay)
|
19632
|
+
const slideSwiper = () => {
|
19633
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
19634
|
+
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.pause();
|
19635
|
+
if (!loopPlayRef.current)
|
19608
19636
|
return;
|
19609
19637
|
if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
|
19610
|
-
(
|
19638
|
+
(_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);
|
19611
19639
|
}
|
19612
19640
|
else {
|
19613
|
-
const i = (
|
19614
|
-
(
|
19641
|
+
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;
|
19642
|
+
(_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);
|
19615
19643
|
}
|
19616
19644
|
};
|
19645
|
+
const handlePause = () => {
|
19646
|
+
setIsPauseVideo(true);
|
19647
|
+
};
|
19617
19648
|
React.useEffect(() => {
|
19618
19649
|
var _a, _b, _c;
|
19619
19650
|
if (!isActive)
|
@@ -19659,7 +19690,7 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
19659
19690
|
(_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('pause', handlePause);
|
19660
19691
|
(_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.removeEventListener('timeupdate', handleTimeUpload);
|
19661
19692
|
};
|
19662
|
-
}, [
|
19693
|
+
}, [isActive]);
|
19663
19694
|
const renderPoster = React.useMemo(() => {
|
19664
19695
|
if (!(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image) || isLoadFinish) {
|
19665
19696
|
return null;
|
@@ -19702,18 +19733,18 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
19702
19733
|
width: '100%',
|
19703
19734
|
height,
|
19704
19735
|
overflow: 'hidden'
|
19705
|
-
} },
|
19736
|
+
}, onClick: handleClickVideo() },
|
19706
19737
|
React.createElement("div", { className: 'n-full-screen', id: videoId, style: { width: '100%', height: '100%' } }),
|
19707
19738
|
renderPoster,
|
19708
19739
|
isPauseVideo && React.createElement(FormatImage$1, { className: 'clc-pb-video-pause', src: videoPlayIcon !== null && videoPlayIcon !== void 0 ? videoPlayIcon : PAUSE_ICON, alt: 'pause' })));
|
19709
|
-
};
|
19740
|
+
});
|
19710
19741
|
var VideoWidget$1 = React.memo(VideoWidget);
|
19711
19742
|
|
19712
19743
|
/*
|
19713
19744
|
* @Author: binruan@chatlabs.com
|
19714
19745
|
* @Date: 2025-03-25 13:54:27
|
19715
19746
|
* @LastEditors: binruan@chatlabs.com
|
19716
|
-
* @LastEditTime: 2025-03-
|
19747
|
+
* @LastEditTime: 2025-03-31 14:29:21
|
19717
19748
|
* @FilePath: \pb-sxp-ui\src\core\components\DiyStoryPreview\index.tsx
|
19718
19749
|
*
|
19719
19750
|
*/
|
@@ -19901,9 +19932,10 @@ Object.values(_materials_).forEach((v) => {
|
|
19901
19932
|
});
|
19902
19933
|
const defaultUnLikeIconPath = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
|
19903
19934
|
const defaultLikeIconPath = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
|
19904
|
-
const DiyStoryPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, descStyle, hashTagStyle, containerHeight = 664, containerWidth = 375, appDomain, tagList = [], scenes, onActiveChange, activeIndex, loopPlay = false, pointerEvents = 'none',
|
19905
|
-
const
|
19935
|
+
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) => {
|
19936
|
+
const videoWidgetRef = React.useRef(null);
|
19906
19937
|
const swiperRef = React.useRef(null);
|
19938
|
+
const [curIndex, setCurIndex] = React.useState(0);
|
19907
19939
|
React.useMemo(() => {
|
19908
19940
|
let minusHeight = 0;
|
19909
19941
|
if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
|
@@ -19914,6 +19946,32 @@ const DiyStoryPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, des
|
|
19914
19946
|
}
|
19915
19947
|
return containerHeight - minusHeight;
|
19916
19948
|
}, [globalConfig, containerHeight, tagList]);
|
19949
|
+
React.useImperativeHandle(ref, () => {
|
19950
|
+
return {
|
19951
|
+
play() {
|
19952
|
+
var _a;
|
19953
|
+
(_a = videoWidgetRef === null || videoWidgetRef === void 0 ? void 0 : videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
19954
|
+
},
|
19955
|
+
pause() {
|
19956
|
+
var _a;
|
19957
|
+
(_a = videoWidgetRef === null || videoWidgetRef === void 0 ? void 0 : videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.pause();
|
19958
|
+
},
|
19959
|
+
slideTo(n) {
|
19960
|
+
var _a, _b;
|
19961
|
+
if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
|
19962
|
+
return;
|
19963
|
+
(_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);
|
19964
|
+
},
|
19965
|
+
isPlaying() {
|
19966
|
+
var _a, _b;
|
19967
|
+
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;
|
19968
|
+
},
|
19969
|
+
setLoopPlay(v) {
|
19970
|
+
var _a;
|
19971
|
+
(_a = videoWidgetRef === null || videoWidgetRef === void 0 ? void 0 : videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.setLoopPlay(v);
|
19972
|
+
}
|
19973
|
+
};
|
19974
|
+
});
|
19917
19975
|
// 判断是否是视频
|
19918
19976
|
const isVideoUrl = (url) => {
|
19919
19977
|
if (url && url !== '' && typeof url === 'string') {
|
@@ -19928,10 +19986,10 @@ const DiyStoryPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, des
|
|
19928
19986
|
const renderContent = (rec, index) => {
|
19929
19987
|
const isVideo = isVideoUrl(rec === null || rec === void 0 ? void 0 : rec.mediaUrl);
|
19930
19988
|
if (isVideo) {
|
19931
|
-
return (React.createElement(VideoWidget$1, {
|
19989
|
+
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 })));
|
19932
19990
|
}
|
19933
19991
|
else {
|
19934
|
-
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
|
19992
|
+
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 }));
|
19935
19993
|
}
|
19936
19994
|
};
|
19937
19995
|
React.useMemo(() => {
|
@@ -20069,16 +20127,13 @@ const DiyStoryPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, des
|
|
20069
20127
|
return;
|
20070
20128
|
(_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);
|
20071
20129
|
}, [activeIndex]);
|
20072
|
-
React.useEffect(() => {
|
20073
|
-
if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
|
20074
|
-
return;
|
20075
|
-
// swiperRef?.current?.swiper?.slideTo(0);
|
20076
|
-
setLooPlaySwiper(loopPlay);
|
20077
|
-
}, [loopPlay]);
|
20078
20130
|
const handleSessionExpire = React.useCallback(lodash.debounce(() => {
|
20079
|
-
|
20131
|
+
var _a;
|
20132
|
+
(_a = videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.setLoopPlay(false);
|
20080
20133
|
}, 1000), []);
|
20081
20134
|
React.useEffect(() => {
|
20135
|
+
if (disabledListener)
|
20136
|
+
return;
|
20082
20137
|
const events = ['touchstart', 'touchcancel'];
|
20083
20138
|
events.forEach((event) => {
|
20084
20139
|
window.addEventListener(event, handleSessionExpire);
|
@@ -20088,7 +20143,7 @@ const DiyStoryPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, des
|
|
20088
20143
|
window.removeEventListener(event, handleSessionExpire);
|
20089
20144
|
});
|
20090
20145
|
};
|
20091
|
-
}, [handleSessionExpire]);
|
20146
|
+
}, [handleSessionExpire, disabledListener]);
|
20092
20147
|
return (React.createElement("div", { id: 'sxp-render',
|
20093
20148
|
// className={style['clc-sxp-container']}
|
20094
20149
|
style: { height: containerHeight, position: 'relative', pointerEvents } },
|
@@ -20098,12 +20153,12 @@ const DiyStoryPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, des
|
|
20098
20153
|
swiperRef.current.swiper.allowTouchMove = true;
|
20099
20154
|
}, 500);
|
20100
20155
|
}, onActiveIndexChange: (swiper) => {
|
20101
|
-
|
20156
|
+
setCurIndex(swiper === null || swiper === void 0 ? void 0 : swiper.activeIndex);
|
20102
20157
|
onActiveChange === null || onActiveChange === void 0 ? void 0 : onActiveChange(swiper.activeIndex);
|
20103
20158
|
}, direction: 'vertical', style: { overflow: 'hidden', height: containerHeight }, height: containerHeight }, scenes === null || scenes === void 0 ? void 0 : scenes.map((rec, index) => {
|
20104
20159
|
return renderView(rec, index);
|
20105
20160
|
}))));
|
20106
|
-
};
|
20161
|
+
});
|
20107
20162
|
var DiyStoryPreview$1 = React.memo(DiyStoryPreview);
|
20108
20163
|
|
20109
20164
|
/*
|