pb-sxp-ui 1.15.12-alpha.7 → 1.15.13-alpha.1
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 +347 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +345 -52
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +6 -6
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +6 -6
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +347 -53
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +6 -6
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/DiyStoryPreview/PictureGroup.d.ts +16 -0
- package/es/core/components/DiyStoryPreview/PictureGroup.js +34 -0
- package/es/core/components/DiyStoryPreview/VideoWidget.d.ts +17 -0
- package/es/core/components/DiyStoryPreview/VideoWidget.js +193 -0
- package/es/core/components/DiyStoryPreview/index.d.ts +26 -0
- package/es/core/components/DiyStoryPreview/index.js +118 -0
- package/es/core/context/SxpDataSourceProvider.js +3 -7
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/lib/core/components/DiyStoryPreview/PictureGroup.d.ts +16 -0
- package/lib/core/components/DiyStoryPreview/PictureGroup.js +37 -0
- package/lib/core/components/DiyStoryPreview/VideoWidget.d.ts +17 -0
- package/lib/core/components/DiyStoryPreview/VideoWidget.js +196 -0
- package/lib/core/components/DiyStoryPreview/index.d.ts +26 -0
- package/lib/core/components/DiyStoryPreview/index.js +121 -0
- package/lib/core/context/SxpDataSourceProvider.js +3 -7
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/package.json +1 -2
- package/es/core/utils/cryptojs.d.ts +0 -3
- package/es/core/utils/cryptojs.js +0 -18
- package/lib/core/utils/cryptojs.d.ts +0 -3
- package/lib/core/utils/cryptojs.js +0 -23
package/dist/index.js
CHANGED
@@ -22,7 +22,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
22
22
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
23
23
|
PERFORMANCE OF THIS SOFTWARE.
|
24
24
|
***************************************************************************** */
|
25
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
25
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
26
26
|
|
27
27
|
|
28
28
|
function __rest(s, e) {
|
@@ -724,28 +724,9 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
724
724
|
// 事件上报优化
|
725
725
|
// Beacon API 用于发送异步和非阻塞请求到服务器。这类请求不需要响应。
|
726
726
|
if (options.type === 'beacon' && navigator.sendBeacon) {
|
727
|
-
return navigator.sendBeacon(`${url}/api/${path}`, new Blob(
|
728
|
-
|
729
|
-
|
730
|
-
// body: encrypt(
|
731
|
-
// JSON.stringify(
|
732
|
-
// btoa(
|
733
|
-
// encodeURIComponent(
|
734
|
-
// JSON.stringify({ ...options.body, ...bffDataSource.headers, 'x-user-id': fakeUserId })
|
735
|
-
// )
|
736
|
-
// )
|
737
|
-
// ),
|
738
|
-
// 'dcAR82I0b8sgwCku'
|
739
|
-
// )
|
740
|
-
// })
|
741
|
-
// ],
|
742
|
-
[
|
743
|
-
JSON.stringify({
|
744
|
-
body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
|
745
|
-
})
|
746
|
-
], {
|
747
|
-
type: 'application/json;charset=UTF-8'
|
748
|
-
}));
|
727
|
+
return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
|
728
|
+
JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))
|
729
|
+
], { type: 'application/json;charset=UTF-8' }));
|
749
730
|
}
|
750
731
|
return window
|
751
732
|
.fetch(`${url}/api/${path}`, {
|
@@ -906,7 +887,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
906
887
|
console.log('userInfo:', userInfo);
|
907
888
|
console.log('eventInfo:', ef);
|
908
889
|
console.log('========= 结束 =========');
|
909
|
-
return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/
|
890
|
+
return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/event/report/CLD/${(_b = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _b === void 0 ? void 0 : _b['x-app-id']}/${eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.eventSubject}`, {
|
910
891
|
method: 'POST',
|
911
892
|
body: { userInfo: realUserInfo, eventInfo: realEventInfo },
|
912
893
|
type: 'beacon'
|
@@ -1483,7 +1464,7 @@ const EditorCore = forwardRef(({ children, resolver, isSsr, schema, enableDataSo
|
|
1483
1464
|
React.createElement(DataSourceProvider$1, { isSsr: isSsr, enable: enableDataSource }, children)));
|
1484
1465
|
});
|
1485
1466
|
|
1486
|
-
var index$
|
1467
|
+
var index$3 = /*#__PURE__*/Object.freeze({
|
1487
1468
|
__proto__: null,
|
1488
1469
|
EditorCore: EditorCore
|
1489
1470
|
});
|
@@ -17565,15 +17546,15 @@ var _materials_ = /*#__PURE__*/Object.freeze({
|
|
17565
17546
|
Swipe: Swipe
|
17566
17547
|
});
|
17567
17548
|
|
17568
|
-
const defaultUnLikeIconPath$
|
17569
|
-
const defaultLikeIconPath$
|
17549
|
+
const defaultUnLikeIconPath$2 = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
|
17550
|
+
const defaultLikeIconPath$2 = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
|
17570
17551
|
const LikeButton = (_a) => {
|
17571
17552
|
var _b;
|
17572
17553
|
var { active, activeIcon, unActicveIcon, recData, position } = _a, props = __rest(_a, ["active", "activeIcon", "unActicveIcon", "recData", "position"]);
|
17573
17554
|
const { mutateLike, mutateUnlike, bffEventReport, setCacheRtcList, cacheRtcList } = useSxpDataSource();
|
17574
17555
|
const [state, setState] = useState((_b = cacheRtcList === null || cacheRtcList === void 0 ? void 0 : cacheRtcList[position]) === null || _b === void 0 ? void 0 : _b.isCollected);
|
17575
|
-
const likeIcon = useIconLink(defaultLikeIconPath$
|
17576
|
-
const unlikeIcon = useIconLink(defaultUnLikeIconPath$
|
17556
|
+
const likeIcon = useIconLink(defaultLikeIconPath$2);
|
17557
|
+
const unlikeIcon = useIconLink(defaultUnLikeIconPath$2);
|
17577
17558
|
const handleClick = debounce(() => __awaiter(void 0, void 0, void 0, function* () {
|
17578
17559
|
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
17579
17560
|
if (state) {
|
@@ -17664,7 +17645,7 @@ const mountVideoPlayerAtNode = (() => {
|
|
17664
17645
|
};
|
17665
17646
|
})();
|
17666
17647
|
|
17667
|
-
const VideoWidget$
|
17648
|
+
const VideoWidget$4 = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon }) => {
|
17668
17649
|
const [isPauseVideo, setIsPauseVideo] = useState(false);
|
17669
17650
|
const { bffEventReport, sxpParameter, waterFallData, openHashtag, bffFbReport } = useSxpDataSource();
|
17670
17651
|
const videoStartTime = useRef(0);
|
@@ -18009,7 +17990,7 @@ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPost
|
|
18009
17990
|
renderLoading,
|
18010
17991
|
isPauseVideo && React.createElement(FormatImage$1, { className: 'clc-pb-video-pause', src: videoPlayIcon !== null && videoPlayIcon !== void 0 ? videoPlayIcon : PAUSE_ICON, alt: 'pause' })))));
|
18011
17992
|
};
|
18012
|
-
var VideoWidget$
|
17993
|
+
var VideoWidget$5 = memo(VideoWidget$4);
|
18013
17994
|
|
18014
17995
|
const ToggleButton = ({ defaultValue, activeIcon, unactiveIcon, onChange, style }) => {
|
18015
17996
|
const [isTrue, setIsTure] = useState(defaultValue);
|
@@ -18098,7 +18079,7 @@ const Picture = (props) => {
|
|
18098
18079
|
}, onLoad: onShowFirstImage }))));
|
18099
18080
|
};
|
18100
18081
|
|
18101
|
-
const PictureGroup$
|
18082
|
+
const PictureGroup$4 = ({ imgUrls, width, height, rec, index, onViewImageEndEvent, onViewImageStartEvent, imgUrlsPostConfig }) => {
|
18102
18083
|
var _a, _b;
|
18103
18084
|
const { isActive } = useSwiperSlide();
|
18104
18085
|
const { sxpParameter, openHashtag } = useSxpDataSource();
|
@@ -18192,7 +18173,7 @@ const PictureGroup$2 = ({ imgUrls, width, height, rec, index, onViewImageEndEven
|
|
18192
18173
|
React.createElement(Picture, { src: !isLoad && srcKey > 0 ? '' : url, height: height, imgUrlsPostConfig: imgUrlsPostConfig, onShowFirstImage: showFirstImageFn })));
|
18193
18174
|
}))));
|
18194
18175
|
};
|
18195
|
-
var PictureGroup$
|
18176
|
+
var PictureGroup$5 = memo(PictureGroup$4);
|
18196
18177
|
|
18197
18178
|
/*
|
18198
18179
|
* @Author: binruan@chatlabs.com
|
@@ -18702,10 +18683,10 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
18702
18683
|
return (React.createElement(MultiPosts$2, Object.assign({ recData: data === null || data === void 0 ? void 0 : data[1] }, (_c = (_b = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.multiPosts) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.item) === null || _c === void 0 ? void 0 : _c.props, (_f = (_e = (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.multiPosts) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.item) === null || _f === void 0 ? void 0 : _f.event)));
|
18703
18684
|
}
|
18704
18685
|
if ((_g = rec === null || rec === void 0 ? void 0 : rec.video) === null || _g === void 0 ? void 0 : _g.url) {
|
18705
|
-
return (React.createElement(VideoWidget$
|
18686
|
+
return (React.createElement(VideoWidget$5, { key: isReload, rec: rec, index: index, muted: isMuted, data: data, height: height, activeIndex: activeIndex, videoPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPost, videoPlayIcon: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPlayIcon }));
|
18706
18687
|
}
|
18707
18688
|
if ((_h = rec === null || rec === void 0 ? void 0 : rec.video) === null || _h === void 0 ? void 0 : _h.imgUrls) {
|
18708
|
-
return (React.createElement(PictureGroup$
|
18689
|
+
return (React.createElement(PictureGroup$5, { key: rec === null || rec === void 0 ? void 0 : rec.video.itemId, imgUrls: rec === null || rec === void 0 ? void 0 : rec.video.imgUrls, width: containerWidth, height: height, rec: rec, index: index, onViewImageEndEvent: handleViewImageStartEnd, onViewImageStartEvent: handleViewImageStartEvent, imgUrlsPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.imgUrlsPost }));
|
18709
18690
|
}
|
18710
18691
|
if (rec.product && Array.isArray(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) && ((_j = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _j === void 0 ? void 0 : _j.length) > 0) {
|
18711
18692
|
return (_k = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _k === void 0 ? void 0 : _k.map((value, idx) => {
|
@@ -19075,7 +19056,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
19075
19056
|
};
|
19076
19057
|
var SxpPageRender$1 = memo(SxpPageRender);
|
19077
19058
|
|
19078
|
-
const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index }) => {
|
19059
|
+
const PictureGroup$2 = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index }) => {
|
19079
19060
|
return (React.createElement(Swiper, { defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: {
|
19080
19061
|
clickable: true,
|
19081
19062
|
bulletActiveClass: 'swipe-item-active-bullet',
|
@@ -19085,9 +19066,9 @@ const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index })
|
|
19085
19066
|
React.createElement(Picture, { src: url, height: height, imgUrlsPostConfig: imgUrlsPostConfig })));
|
19086
19067
|
})));
|
19087
19068
|
};
|
19088
|
-
var PictureGroup$
|
19069
|
+
var PictureGroup$3 = memo(PictureGroup$2);
|
19089
19070
|
|
19090
|
-
const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width }) => {
|
19071
|
+
const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width }) => {
|
19091
19072
|
const [isPauseVideo, setIsPauseVideo] = useState(false);
|
19092
19073
|
const videoRef = useRef(null);
|
19093
19074
|
const { bffEventReport, sxpParameter, waterFallData, openHashtag } = useSxpDataSource();
|
@@ -19317,14 +19298,14 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
19317
19298
|
renderPoster,
|
19318
19299
|
React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON, alt: 'video pause image' })))));
|
19319
19300
|
};
|
19320
|
-
var VideoWidget$
|
19301
|
+
var VideoWidget$3 = memo(VideoWidget$2);
|
19321
19302
|
|
19322
|
-
const RESOLVER$
|
19303
|
+
const RESOLVER$2 = {};
|
19323
19304
|
Object.values(_materials_).forEach((v) => {
|
19324
|
-
RESOLVER$
|
19305
|
+
RESOLVER$2[v.extend.type] = v;
|
19325
19306
|
});
|
19326
|
-
const defaultUnLikeIconPath = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
|
19327
|
-
const defaultLikeIconPath = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
|
19307
|
+
const defaultUnLikeIconPath$1 = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
|
19308
|
+
const defaultLikeIconPath$1 = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
|
19328
19309
|
const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, descStyle, hashTagStyle, containerHeight = 664, containerWidth = 375, appDomain, tagList = [] }) => {
|
19329
19310
|
const height = useMemo(() => {
|
19330
19311
|
let minusHeight = 0;
|
@@ -19339,16 +19320,16 @@ const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, de
|
|
19339
19320
|
const renderContent = (rec, index) => {
|
19340
19321
|
var _a, _b, _c, _d;
|
19341
19322
|
if ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.url) {
|
19342
|
-
return (React.createElement(VideoWidget$
|
19323
|
+
return (React.createElement(VideoWidget$3, { rec: rec, index: index, muted: true, width: containerWidth, data: data !== null && data !== void 0 ? data : [], height: height, activeIndex: index, videoPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPost }));
|
19343
19324
|
}
|
19344
19325
|
if ((_b = rec === null || rec === void 0 ? void 0 : rec.video) === null || _b === void 0 ? void 0 : _b.imgUrls) {
|
19345
|
-
return (React.createElement(PictureGroup$
|
19326
|
+
return (React.createElement(PictureGroup$3, { key: rec === null || rec === void 0 ? void 0 : rec.video.itemId, imgUrls: rec === null || rec === void 0 ? void 0 : rec.video.imgUrls, width: containerWidth, height: height, rec: rec, index: index, imgUrlsPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.imgUrlsPost }));
|
19346
19327
|
}
|
19347
19328
|
if (rec.product) {
|
19348
19329
|
if (rec.product && Array.isArray(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) && ((_c = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
19349
19330
|
return (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _d === void 0 ? void 0 : _d.map((value, idx) => {
|
19350
19331
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
19351
|
-
const t = RESOLVER$
|
19332
|
+
const t = RESOLVER$2[(_a = value === null || value === void 0 ? void 0 : value.item) === null || _a === void 0 ? void 0 : _a.type];
|
19352
19333
|
const Component = withBindDataSource(t);
|
19353
19334
|
const defaulSetting = (_b = t === null || t === void 0 ? void 0 : t.extend) === null || _b === void 0 ? void 0 : _b.defaulSetting;
|
19354
19335
|
return (React.createElement(Component, Object.assign({ key: `${index}${idx}`, textStyle: Object.assign(Object.assign({}, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.textStyle), (_c = value === null || value === void 0 ? void 0 : value.item) === null || _c === void 0 ? void 0 : _c.textStyle), bindDatas: (_e = (_d = value === null || value === void 0 ? void 0 : value.item) === null || _d === void 0 ? void 0 : _d.bindDatas) !== null && _e !== void 0 ? _e : [] }, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.props, (_f = value === null || value === void 0 ? void 0 : value.item) === null || _f === void 0 ? void 0 : _f.props, { event: ((_g = value === null || value === void 0 ? void 0 : value.item) === null || _g === void 0 ? void 0 : _g.event) || {},
|
@@ -19370,7 +19351,7 @@ const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, de
|
|
19370
19351
|
const CTA = (rec, index) => {
|
19371
19352
|
if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA) === undefined || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA)) {
|
19372
19353
|
return (React.createElement("div", { className: 'clc-sxp-bottom-card' },
|
19373
|
-
React.createElement(RenderCard$1, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER$
|
19354
|
+
React.createElement(RenderCard$1, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER$2 })));
|
19374
19355
|
}
|
19375
19356
|
return null;
|
19376
19357
|
};
|
@@ -19388,8 +19369,8 @@ const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, de
|
|
19388
19369
|
}
|
19389
19370
|
return null;
|
19390
19371
|
};
|
19391
|
-
const likeIcon = useIconLink(defaultLikeIconPath, appDomain);
|
19392
|
-
const unlikeIcon = useIconLink(defaultUnLikeIconPath, appDomain);
|
19372
|
+
const likeIcon = useIconLink(defaultLikeIconPath$1, appDomain);
|
19373
|
+
const unlikeIcon = useIconLink(defaultUnLikeIconPath$1, appDomain);
|
19393
19374
|
const renderLikeButton = (rec, index) => {
|
19394
19375
|
var _a, _b, _c, _d;
|
19395
19376
|
if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLike))
|
@@ -19437,7 +19418,319 @@ const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, de
|
|
19437
19418
|
return renderView(rec, index);
|
19438
19419
|
})));
|
19439
19420
|
};
|
19440
|
-
var index$
|
19421
|
+
var index$2 = memo(DiyPortalPreview);
|
19422
|
+
|
19423
|
+
const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index, swiperRef, data = [], loopPlay }) => {
|
19424
|
+
const { isActive } = useSwiperSlide();
|
19425
|
+
const [isload, setIsLoad] = useState(false);
|
19426
|
+
useEffect(() => {
|
19427
|
+
if (isActive && isload && loopPlay) {
|
19428
|
+
setTimeout(() => {
|
19429
|
+
var _a, _b, _c, _d;
|
19430
|
+
if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
|
19431
|
+
(_a = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _a === void 0 ? void 0 : _a.swiper.slideTo(0);
|
19432
|
+
}
|
19433
|
+
else {
|
19434
|
+
const i = (_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.activeIndex;
|
19435
|
+
(_d = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _d === void 0 ? void 0 : _d.swiper.slideTo(i + 1);
|
19436
|
+
}
|
19437
|
+
}, 3000);
|
19438
|
+
}
|
19439
|
+
}, [isActive, isload, data, index, swiperRef, loopPlay]);
|
19440
|
+
const loadFinishImage = () => {
|
19441
|
+
setIsLoad(true);
|
19442
|
+
};
|
19443
|
+
return (React.createElement(Swiper, { defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: {
|
19444
|
+
clickable: true,
|
19445
|
+
bulletActiveClass: 'swipe-item-active-bullet',
|
19446
|
+
bulletElement: 'button'
|
19447
|
+
}, height: height, style: { width }, loop: true, autoplay: false }, imgUrls === null || imgUrls === void 0 ? void 0 : imgUrls.map((url) => {
|
19448
|
+
return (React.createElement(SwiperSlide, { key: url },
|
19449
|
+
React.createElement(Picture, { src: url, height: height, imgUrlsPostConfig: imgUrlsPostConfig, onShowFirstImage: loadFinishImage })));
|
19450
|
+
})));
|
19451
|
+
};
|
19452
|
+
var PictureGroup$1 = memo(PictureGroup);
|
19453
|
+
|
19454
|
+
const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width, swiperRef, loopPlay }) => {
|
19455
|
+
const { isActive } = useSwiperSlide();
|
19456
|
+
const [isPauseVideo, setIsPauseVideo] = useState(false);
|
19457
|
+
const videoRef = useRef(null);
|
19458
|
+
const { bffEventReport, sxpParameter, waterFallData, openHashtag } = useSxpDataSource();
|
19459
|
+
const videoStartTime = useRef(0);
|
19460
|
+
const [isLoadFinish, setIsLoadFinish] = useState(false);
|
19461
|
+
const [isFirstPlay, setIsFirstPlay] = useState(true);
|
19462
|
+
const canvasRef = useRef(null);
|
19463
|
+
const [firstFrameSrc, setFirstFrameSrc] = useState('');
|
19464
|
+
const videoId = `pb-cache-video-${index}`;
|
19465
|
+
const hlsRef = useRef(null);
|
19466
|
+
useEffect(() => {
|
19467
|
+
if (!videoRef.current)
|
19468
|
+
return;
|
19469
|
+
videoRef.current.muted = muted;
|
19470
|
+
}, [muted]);
|
19471
|
+
useCallback(() => {
|
19472
|
+
var _a;
|
19473
|
+
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
19474
|
+
}, []);
|
19475
|
+
useIconLink('/pb_static/06f28a2025c74c1cb49be6767316d827.png');
|
19476
|
+
const handlePlaying = useCallback(() => {
|
19477
|
+
var _a, _b, _c, _d, _e, _f;
|
19478
|
+
setIsPauseVideo(false);
|
19479
|
+
const item = data[index];
|
19480
|
+
if (item && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration)) {
|
19481
|
+
videoStartTime.current = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.currentTime) || 0;
|
19482
|
+
((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 0).toFixed(2);
|
19483
|
+
((_f = (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime) !== null && _f !== void 0 ? _f : 0).toFixed(2);
|
19484
|
+
setIsFirstPlay(false);
|
19485
|
+
}
|
19486
|
+
}, [bffEventReport, data, index, isFirstPlay]);
|
19487
|
+
const handleLoadedMetadata = useCallback(() => {
|
19488
|
+
var _a;
|
19489
|
+
(_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
19490
|
+
setIsLoadFinish(true);
|
19491
|
+
}, []);
|
19492
|
+
useCallback((type) => () => {
|
19493
|
+
var _a, _b, _c, _d, _e;
|
19494
|
+
if (!isLoadFinish)
|
19495
|
+
return;
|
19496
|
+
const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
|
19497
|
+
switch (type) {
|
19498
|
+
case 'start':
|
19499
|
+
if (!isPause)
|
19500
|
+
return;
|
19501
|
+
(_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.play();
|
19502
|
+
setIsPauseVideo(false);
|
19503
|
+
break;
|
19504
|
+
case 'pause':
|
19505
|
+
if (isPause)
|
19506
|
+
return;
|
19507
|
+
(_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
|
19508
|
+
setIsPauseVideo(true);
|
19509
|
+
break;
|
19510
|
+
default:
|
19511
|
+
if (isPause) {
|
19512
|
+
(_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.play();
|
19513
|
+
}
|
19514
|
+
else {
|
19515
|
+
(_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.pause();
|
19516
|
+
}
|
19517
|
+
setIsPauseVideo(!isPause);
|
19518
|
+
break;
|
19519
|
+
}
|
19520
|
+
}, [isLoadFinish]);
|
19521
|
+
useCallback(() => {
|
19522
|
+
var _a, _b, _c, _d, _e, _f;
|
19523
|
+
data[index];
|
19524
|
+
((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.duration) !== null && _b !== void 0 ? _b : 0).toFixed(2);
|
19525
|
+
((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.currentTime) !== null && _d !== void 0 ? _d : 0).toFixed(2);
|
19526
|
+
if ((_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.duration) {
|
19527
|
+
(((_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.currentTime) - videoStartTime.current).toFixed(2);
|
19528
|
+
}
|
19529
|
+
}, [data, index, bffEventReport]);
|
19530
|
+
const blur = useMemo(() => {
|
19531
|
+
return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2';
|
19532
|
+
}, [videoPostConfig]);
|
19533
|
+
useMemo(() => {
|
19534
|
+
var _a;
|
19535
|
+
return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2'
|
19536
|
+
? `translateY(-${50 + ((_a = videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.offsetTop) !== null && _a !== void 0 ? _a : 0)}%) translate3d(0px, 0px, 0px)`
|
19537
|
+
: 'translateY(-50%)';
|
19538
|
+
}, [videoPostConfig]);
|
19539
|
+
const handLoadeddata = useCallback(() => {
|
19540
|
+
if (!canvasRef || !videoRef || !videoRef.current || !canvasRef.current)
|
19541
|
+
return;
|
19542
|
+
const video = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current;
|
19543
|
+
const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
|
19544
|
+
const ctx = canvas.getContext('2d');
|
19545
|
+
const targetWidth = window === null || window === void 0 ? void 0 : window.innerWidth;
|
19546
|
+
const targetHeight = window === null || window === void 0 ? void 0 : window.innerHeight;
|
19547
|
+
canvas.height = targetHeight;
|
19548
|
+
canvas.width = targetWidth;
|
19549
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
19550
|
+
setFirstFrameSrc(canvas.toDataURL());
|
19551
|
+
}, []);
|
19552
|
+
const handleTimeUpload = useCallback(() => {
|
19553
|
+
var _a, _b, _c;
|
19554
|
+
if (!videoRef.current)
|
19555
|
+
return;
|
19556
|
+
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)) {
|
19557
|
+
(_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
|
19558
|
+
}
|
19559
|
+
}, []);
|
19560
|
+
const handlePause = () => {
|
19561
|
+
var _a, _b, _c, _d, _e, _f;
|
19562
|
+
if (!loopPlay)
|
19563
|
+
return;
|
19564
|
+
if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
|
19565
|
+
(_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(0);
|
19566
|
+
}
|
19567
|
+
else {
|
19568
|
+
const i = (_d = (_c = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _c === void 0 ? void 0 : _c.swiper) === null || _d === void 0 ? void 0 : _d.activeIndex;
|
19569
|
+
(_f = (_e = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _e === void 0 ? void 0 : _e.swiper) === null || _f === void 0 ? void 0 : _f.slideTo(i + 1);
|
19570
|
+
}
|
19571
|
+
};
|
19572
|
+
// useEffect(() => {
|
19573
|
+
// if (!isActive) return;
|
19574
|
+
// if (!loopPlay) {
|
19575
|
+
// videoRef?.current?.pause();
|
19576
|
+
// } else {
|
19577
|
+
// videoRef?.current?.play();
|
19578
|
+
// }
|
19579
|
+
// }, [loopPlay, isActive]);
|
19580
|
+
useEffect(() => {
|
19581
|
+
var _a, _b, _c;
|
19582
|
+
if (!isActive)
|
19583
|
+
return;
|
19584
|
+
const videoSrc = rec === null || rec === void 0 ? void 0 : rec.mediaUrl;
|
19585
|
+
if (!videoSrc)
|
19586
|
+
return;
|
19587
|
+
setIsPauseVideo(false);
|
19588
|
+
const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
|
19589
|
+
if (!videoPlayerWrapperNode)
|
19590
|
+
return;
|
19591
|
+
videoRef.current = mountVideoPlayerAtNode === null || mountVideoPlayerAtNode === void 0 ? void 0 : mountVideoPlayerAtNode(videoPlayerWrapperNode);
|
19592
|
+
videoRef.current.currentTime = rec === null || rec === void 0 ? void 0 : rec.startTime;
|
19593
|
+
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
19594
|
+
return;
|
19595
|
+
const Hls = window === null || window === void 0 ? void 0 : window.Hls;
|
19596
|
+
let hls = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current;
|
19597
|
+
if (videoSrc.includes('.m3u8') && Hls && Hls.isSupported()) {
|
19598
|
+
hls = new Hls();
|
19599
|
+
hls === null || hls === void 0 ? void 0 : hls.loadSource(videoSrc);
|
19600
|
+
hls === null || hls === void 0 ? void 0 : hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
|
19601
|
+
hls === null || hls === void 0 ? void 0 : hls.on(Hls.Events.MANIFEST_PARSED, function () {
|
19602
|
+
var _a;
|
19603
|
+
(_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
19604
|
+
});
|
19605
|
+
}
|
19606
|
+
else {
|
19607
|
+
videoRef.current.src = videoSrc;
|
19608
|
+
}
|
19609
|
+
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('loadedmetadata', handleLoadedMetadata);
|
19610
|
+
// videoRef.current?.addEventListener('playing', handlePlaying);
|
19611
|
+
// videoRef.current?.addEventListener('loadeddata', handLoadeddata);
|
19612
|
+
(_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('pause', handlePause);
|
19613
|
+
(_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.addEventListener('timeupdate', handleTimeUpload);
|
19614
|
+
return () => {
|
19615
|
+
var _a, _b, _c, _d;
|
19616
|
+
if (hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current)
|
19617
|
+
(_a = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
|
19618
|
+
setIsLoadFinish(false);
|
19619
|
+
(_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('loadedmetadata', handleLoadedMetadata);
|
19620
|
+
// videoRef.current?.removeEventListener('playing', handlePlaying);
|
19621
|
+
// videoRef.current?.removeEventListener('loadeddata', handLoadeddata);
|
19622
|
+
(_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('pause', handlePause);
|
19623
|
+
(_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.removeEventListener('timeupdate', handleTimeUpload);
|
19624
|
+
};
|
19625
|
+
}, [handleLoadedMetadata, handlePlaying, rec, handLoadeddata, isActive]);
|
19626
|
+
useMemo(() => {
|
19627
|
+
if (!(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image) || isLoadFinish) {
|
19628
|
+
return null;
|
19629
|
+
}
|
19630
|
+
return (React.createElement("img", { style: { position: 'absolute', left: 0, top: 0, width: '100%', height: '100%', objectFit: 'cover' }, src: sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, alt: 'video poster' }));
|
19631
|
+
}, [isLoadFinish, sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image]);
|
19632
|
+
useMemo(() => {
|
19633
|
+
return blur
|
19634
|
+
? {
|
19635
|
+
filter: 'blur(10px)',
|
19636
|
+
transform: 'translate3d(0px, 0px, 0px) scale(1.2)'
|
19637
|
+
}
|
19638
|
+
: {};
|
19639
|
+
}, [blur]);
|
19640
|
+
if (!(rec === null || rec === void 0 ? void 0 : rec.mediaUrl)) {
|
19641
|
+
return null;
|
19642
|
+
}
|
19643
|
+
return (React.createElement("div", { className: 'video-container', key: rec.itemId, style: {
|
19644
|
+
position: 'relative',
|
19645
|
+
width: '100%',
|
19646
|
+
height,
|
19647
|
+
overflow: 'hidden',
|
19648
|
+
pointerEvents: 'none'
|
19649
|
+
} },
|
19650
|
+
React.createElement("div", { className: 'n-full-screen', id: videoId, style: { width: '100%', height: '100%' } })));
|
19651
|
+
};
|
19652
|
+
var VideoWidget$1 = memo(VideoWidget);
|
19653
|
+
|
19654
|
+
/*
|
19655
|
+
* @Author: binruan@chatlabs.com
|
19656
|
+
* @Date: 2025-03-25 13:54:27
|
19657
|
+
* @LastEditors: binruan@chatlabs.com
|
19658
|
+
* @LastEditTime: 2025-03-26 15:01:42
|
19659
|
+
* @FilePath: \pb-sxp-ui\src\core\components\DiyStoryPreview\index.tsx
|
19660
|
+
*
|
19661
|
+
*/
|
19662
|
+
const RESOLVER$1 = {};
|
19663
|
+
Object.values(_materials_).forEach((v) => {
|
19664
|
+
RESOLVER$1[v.extend.type] = v;
|
19665
|
+
});
|
19666
|
+
const defaultUnLikeIconPath = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
|
19667
|
+
const defaultLikeIconPath = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
|
19668
|
+
const DiyStoryPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, descStyle, hashTagStyle, containerHeight = 664, containerWidth = 375, appDomain, tagList = [], scenes, onActiveChange, activeIndex, loopPlay = false }) => {
|
19669
|
+
const swiperRef = useRef(null);
|
19670
|
+
useMemo(() => {
|
19671
|
+
let minusHeight = 0;
|
19672
|
+
if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
|
19673
|
+
minusHeight += 45;
|
19674
|
+
}
|
19675
|
+
if (tagList.length > 0) {
|
19676
|
+
minusHeight += 45;
|
19677
|
+
}
|
19678
|
+
return containerHeight - minusHeight;
|
19679
|
+
}, [globalConfig, containerHeight, tagList]);
|
19680
|
+
// 判断是否是视频
|
19681
|
+
const isVideoUrl = (url) => {
|
19682
|
+
if (url && url !== '' && typeof url === 'string') {
|
19683
|
+
const imageExtensions = ['.mp4', '.m3u8'];
|
19684
|
+
const lowerCaseUrl = url === null || url === void 0 ? void 0 : url.toLowerCase();
|
19685
|
+
return imageExtensions.some((ext) => lowerCaseUrl === null || lowerCaseUrl === void 0 ? void 0 : lowerCaseUrl.endsWith(ext));
|
19686
|
+
}
|
19687
|
+
else {
|
19688
|
+
return false;
|
19689
|
+
}
|
19690
|
+
};
|
19691
|
+
const renderContent = (rec, index) => {
|
19692
|
+
const isVideo = isVideoUrl(rec === null || rec === void 0 ? void 0 : rec.mediaUrl);
|
19693
|
+
if (isVideo) {
|
19694
|
+
return (React.createElement(VideoWidget$1, { 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, swiperRef: swiperRef, loopPlay: loopPlay }));
|
19695
|
+
}
|
19696
|
+
else {
|
19697
|
+
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, loopPlay: loopPlay }));
|
19698
|
+
}
|
19699
|
+
};
|
19700
|
+
useMemo(() => {
|
19701
|
+
if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
|
19702
|
+
return (React.createElement("div", { className: 'clc-sxp-logo-banner', style: { backgroundColor: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.color } },
|
19703
|
+
React.createElement("img", { src: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl, alt: 'logo' })));
|
19704
|
+
}
|
19705
|
+
return null;
|
19706
|
+
}, [globalConfig]);
|
19707
|
+
useIconLink(defaultLikeIconPath, appDomain);
|
19708
|
+
useIconLink(defaultUnLikeIconPath, appDomain);
|
19709
|
+
useIconLink('/pb_static/5beaaa5ce7f3477b99db3838619cc471.png', appDomain);
|
19710
|
+
useIconLink('/pb_static/fea8668a8a894e4aa3a86bcc775e895e.png', appDomain);
|
19711
|
+
const renderView = (rec, index) => {
|
19712
|
+
return (React.createElement(SwiperSlide, { key: index, virtualIndex: index, style: { overflow: 'hidden', position: 'relative' } }, renderContent(rec, index)));
|
19713
|
+
};
|
19714
|
+
useEffect(() => {
|
19715
|
+
var _a, _b;
|
19716
|
+
if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
|
19717
|
+
return;
|
19718
|
+
(_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);
|
19719
|
+
}, [activeIndex]);
|
19720
|
+
useEffect(() => {
|
19721
|
+
var _a, _b;
|
19722
|
+
if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
|
19723
|
+
return;
|
19724
|
+
(_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(0);
|
19725
|
+
}, [loopPlay]);
|
19726
|
+
return (React.createElement(Swiper, { ref: swiperRef, allowTouchMove: false, onActiveIndexChange: (swiper) => {
|
19727
|
+
// setActiveIndex(swiper.activeIndex);
|
19728
|
+
onActiveChange === null || onActiveChange === void 0 ? void 0 : onActiveChange(swiper.activeIndex);
|
19729
|
+
}, direction: 'vertical', style: { overflow: 'hidden', height: containerHeight } }, scenes === null || scenes === void 0 ? void 0 : scenes.map((rec, index) => {
|
19730
|
+
return renderView(rec, index);
|
19731
|
+
})));
|
19732
|
+
};
|
19733
|
+
var index$1 = memo(DiyStoryPreview);
|
19441
19734
|
|
19442
19735
|
/*
|
19443
19736
|
* @Author: binruan@chatlabs.com
|
@@ -19576,9 +19869,9 @@ var index = memo(SxpPageCore);
|
|
19576
19869
|
* @Author : haocanweng@chatlabs.cn
|
19577
19870
|
* @Date : 2023-08-21 16:31:58
|
19578
19871
|
* @LastEditors: binruan@chatlabs.com
|
19579
|
-
* @LastEditTime:
|
19872
|
+
* @LastEditTime: 2025-03-25 14:31:53
|
19580
19873
|
* @FilePath: \pb-sxp-ui\src\index.ts
|
19581
19874
|
*/
|
19582
19875
|
|
19583
|
-
export { index$
|
19876
|
+
export { index$2 as DiyPortalPreview, index$1 as DiyStoryPreview, EditorDataProvider, Modal$1 as Modal, SxpDataSourceProvider$1 as SxpDataSourceProvider, index as SxpPageCore, SxpPageRender$1 as SxpPageRender, index$3 as core, Pagebuilder as default, _materials_ as materials, useEditorDataProvider };
|
19584
19877
|
//# sourceMappingURL=index.js.map
|