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.
Files changed (35) hide show
  1. package/dist/index.cjs +347 -53
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +345 -52
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.min.cjs +6 -6
  6. package/dist/index.min.cjs.map +1 -1
  7. package/dist/index.min.js +6 -6
  8. package/dist/index.min.js.map +1 -1
  9. package/dist/pb-ui.js +347 -53
  10. package/dist/pb-ui.js.map +1 -1
  11. package/dist/pb-ui.min.js +6 -6
  12. package/dist/pb-ui.min.js.map +1 -1
  13. package/es/core/components/DiyStoryPreview/PictureGroup.d.ts +16 -0
  14. package/es/core/components/DiyStoryPreview/PictureGroup.js +34 -0
  15. package/es/core/components/DiyStoryPreview/VideoWidget.d.ts +17 -0
  16. package/es/core/components/DiyStoryPreview/VideoWidget.js +193 -0
  17. package/es/core/components/DiyStoryPreview/index.d.ts +26 -0
  18. package/es/core/components/DiyStoryPreview/index.js +118 -0
  19. package/es/core/context/SxpDataSourceProvider.js +3 -7
  20. package/es/index.d.ts +1 -0
  21. package/es/index.js +1 -0
  22. package/lib/core/components/DiyStoryPreview/PictureGroup.d.ts +16 -0
  23. package/lib/core/components/DiyStoryPreview/PictureGroup.js +37 -0
  24. package/lib/core/components/DiyStoryPreview/VideoWidget.d.ts +17 -0
  25. package/lib/core/components/DiyStoryPreview/VideoWidget.js +196 -0
  26. package/lib/core/components/DiyStoryPreview/index.d.ts +26 -0
  27. package/lib/core/components/DiyStoryPreview/index.js +121 -0
  28. package/lib/core/context/SxpDataSourceProvider.js +3 -7
  29. package/lib/index.d.ts +1 -0
  30. package/lib/index.js +3 -1
  31. package/package.json +1 -2
  32. package/es/core/utils/cryptojs.d.ts +0 -3
  33. package/es/core/utils/cryptojs.js +0 -18
  34. package/lib/core/utils/cryptojs.d.ts +0 -3
  35. package/lib/core/utils/cryptojs.js +0 -23
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { postConfigType } from '../SxpPageRender';
3
+ import { IScene, ScenesType } from '.';
4
+ interface IPictureGroupProps {
5
+ imgUrls?: string[];
6
+ width: number;
7
+ height: number;
8
+ rec: IScene;
9
+ index: number;
10
+ imgUrlsPostConfig?: postConfigType;
11
+ swiperRef?: any;
12
+ data?: ScenesType;
13
+ loopPlay?: boolean;
14
+ }
15
+ declare const _default: React.NamedExoticComponent<IPictureGroupProps>;
16
+ export default _default;
@@ -0,0 +1,34 @@
1
+ import React, { memo, useEffect, useState } from 'react';
2
+ import { Autoplay, Pagination } from 'swiper/modules';
3
+ import { Swiper, SwiperSlide, useSwiperSlide } from 'swiper/react';
4
+ import Picture from '../SxpPageRender/PictureGroup/Picture';
5
+ const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index, swiperRef, data = [], loopPlay }) => {
6
+ const { isActive } = useSwiperSlide();
7
+ const [isload, setIsLoad] = useState(false);
8
+ useEffect(() => {
9
+ if (isActive && isload && loopPlay) {
10
+ setTimeout(() => {
11
+ var _a, _b, _c, _d;
12
+ if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
13
+ (_a = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _a === void 0 ? void 0 : _a.swiper.slideTo(0);
14
+ }
15
+ else {
16
+ 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;
17
+ (_d = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _d === void 0 ? void 0 : _d.swiper.slideTo(i + 1);
18
+ }
19
+ }, 3000);
20
+ }
21
+ }, [isActive, isload, data, index, swiperRef, loopPlay]);
22
+ const loadFinishImage = () => {
23
+ setIsLoad(true);
24
+ };
25
+ return (React.createElement(Swiper, { defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: {
26
+ clickable: true,
27
+ bulletActiveClass: 'swipe-item-active-bullet',
28
+ bulletElement: 'button'
29
+ }, height: height, style: { width }, loop: true, autoplay: false }, imgUrls === null || imgUrls === void 0 ? void 0 : imgUrls.map((url) => {
30
+ return (React.createElement(SwiperSlide, { key: url },
31
+ React.createElement(Picture, { src: url, height: height, imgUrlsPostConfig: imgUrlsPostConfig, onShowFirstImage: loadFinishImage })));
32
+ })));
33
+ };
34
+ export default memo(PictureGroup);
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { postConfigType } from '../SxpPageRender';
3
+ import { IScene, ScenesType } from '.';
4
+ interface IVideoWidgetProps {
5
+ rec: IScene;
6
+ index: number;
7
+ height: number;
8
+ width: number;
9
+ data: ScenesType;
10
+ muted: boolean;
11
+ activeIndex?: number;
12
+ videoPostConfig?: postConfigType;
13
+ swiperRef?: any;
14
+ loopPlay?: boolean;
15
+ }
16
+ declare const _default: React.NamedExoticComponent<IVideoWidgetProps>;
17
+ export default _default;
@@ -0,0 +1,193 @@
1
+ import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+ import { useSwiperSlide } from 'swiper/react';
3
+ import { useIconLink } from '../SxpPageRender/useIconLink';
4
+ import { mountVideoPlayerAtNode } from '../SxpPageRender/VideoWidget/VideoPlayer';
5
+ import { useSxpDataSource } from '../../../core/hooks';
6
+ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width, swiperRef, loopPlay }) => {
7
+ const { isActive } = useSwiperSlide();
8
+ const [isPauseVideo, setIsPauseVideo] = useState(false);
9
+ const videoRef = useRef(null);
10
+ const { bffEventReport, sxpParameter, waterFallData, openHashtag } = useSxpDataSource();
11
+ const videoStartTime = useRef(0);
12
+ const [isLoadFinish, setIsLoadFinish] = useState(false);
13
+ const [isFirstPlay, setIsFirstPlay] = useState(true);
14
+ const canvasRef = useRef(null);
15
+ const [firstFrameSrc, setFirstFrameSrc] = useState('');
16
+ const videoId = `pb-cache-video-${index}`;
17
+ const hlsRef = useRef(null);
18
+ useEffect(() => {
19
+ if (!videoRef.current)
20
+ return;
21
+ videoRef.current.muted = muted;
22
+ }, [muted]);
23
+ const handleVideoStart = useCallback(() => {
24
+ var _a;
25
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
26
+ }, []);
27
+ const PAUSE_ICON = useIconLink('/pb_static/06f28a2025c74c1cb49be6767316d827.png');
28
+ const handlePlaying = useCallback(() => {
29
+ var _a, _b, _c, _d, _e, _f;
30
+ setIsPauseVideo(false);
31
+ const item = data[index];
32
+ if (item && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration)) {
33
+ videoStartTime.current = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.currentTime) || 0;
34
+ const videoDuration = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 0).toFixed(2);
35
+ const videoCurrentTime = ((_f = (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime) !== null && _f !== void 0 ? _f : 0).toFixed(2);
36
+ const playType = isFirstPlay ? '0' : '1';
37
+ setIsFirstPlay(false);
38
+ }
39
+ }, [bffEventReport, data, index, isFirstPlay]);
40
+ const handleLoadedMetadata = useCallback(() => {
41
+ var _a;
42
+ (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
43
+ setIsLoadFinish(true);
44
+ }, []);
45
+ const handleClickVideo = useCallback((type) => () => {
46
+ var _a, _b, _c, _d, _e;
47
+ if (!isLoadFinish)
48
+ return;
49
+ const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
50
+ switch (type) {
51
+ case 'start':
52
+ if (!isPause)
53
+ return;
54
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.play();
55
+ setIsPauseVideo(false);
56
+ break;
57
+ case 'pause':
58
+ if (isPause)
59
+ return;
60
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
61
+ setIsPauseVideo(true);
62
+ break;
63
+ default:
64
+ if (isPause) {
65
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.play();
66
+ }
67
+ else {
68
+ (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.pause();
69
+ }
70
+ setIsPauseVideo(!isPause);
71
+ break;
72
+ }
73
+ }, [isLoadFinish]);
74
+ const onPause = useCallback(() => {
75
+ var _a, _b, _c, _d, _e, _f;
76
+ const item = data[index];
77
+ const videoDuration = ((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.duration) !== null && _b !== void 0 ? _b : 0).toFixed(2);
78
+ const videoCurrentTime = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.currentTime) !== null && _d !== void 0 ? _d : 0).toFixed(2);
79
+ if ((_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.duration) {
80
+ const playDuration = (((_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.currentTime) - videoStartTime.current).toFixed(2);
81
+ }
82
+ }, [data, index, bffEventReport]);
83
+ const blur = useMemo(() => {
84
+ return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2';
85
+ }, [videoPostConfig]);
86
+ const translateY = useMemo(() => {
87
+ var _a;
88
+ return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2'
89
+ ? `translateY(-${50 + ((_a = videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.offsetTop) !== null && _a !== void 0 ? _a : 0)}%) translate3d(0px, 0px, 0px)`
90
+ : 'translateY(-50%)';
91
+ }, [videoPostConfig]);
92
+ const handLoadeddata = useCallback(() => {
93
+ if (!canvasRef || !videoRef || !videoRef.current || !canvasRef.current)
94
+ return;
95
+ const video = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current;
96
+ const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
97
+ const ctx = canvas.getContext('2d');
98
+ const targetWidth = window === null || window === void 0 ? void 0 : window.innerWidth;
99
+ const targetHeight = window === null || window === void 0 ? void 0 : window.innerHeight;
100
+ canvas.height = targetHeight;
101
+ canvas.width = targetWidth;
102
+ ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
103
+ setFirstFrameSrc(canvas.toDataURL());
104
+ }, []);
105
+ const handleTimeUpload = useCallback(() => {
106
+ var _a, _b, _c;
107
+ if (!videoRef.current)
108
+ return;
109
+ 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)) {
110
+ (_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
111
+ }
112
+ }, []);
113
+ const handlePause = () => {
114
+ var _a, _b, _c, _d, _e, _f;
115
+ if (!loopPlay)
116
+ return;
117
+ if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
118
+ (_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);
119
+ }
120
+ else {
121
+ 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;
122
+ (_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);
123
+ }
124
+ };
125
+ useEffect(() => {
126
+ var _a, _b, _c;
127
+ if (!isActive)
128
+ return;
129
+ const videoSrc = rec === null || rec === void 0 ? void 0 : rec.mediaUrl;
130
+ if (!videoSrc)
131
+ return;
132
+ setIsPauseVideo(false);
133
+ const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
134
+ if (!videoPlayerWrapperNode)
135
+ return;
136
+ videoRef.current = mountVideoPlayerAtNode === null || mountVideoPlayerAtNode === void 0 ? void 0 : mountVideoPlayerAtNode(videoPlayerWrapperNode);
137
+ videoRef.current.currentTime = rec === null || rec === void 0 ? void 0 : rec.startTime;
138
+ if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
139
+ return;
140
+ const Hls = window === null || window === void 0 ? void 0 : window.Hls;
141
+ let hls = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current;
142
+ if (videoSrc.includes('.m3u8') && Hls && Hls.isSupported()) {
143
+ hls = new Hls();
144
+ hls === null || hls === void 0 ? void 0 : hls.loadSource(videoSrc);
145
+ hls === null || hls === void 0 ? void 0 : hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
146
+ hls === null || hls === void 0 ? void 0 : hls.on(Hls.Events.MANIFEST_PARSED, function () {
147
+ var _a;
148
+ (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
149
+ });
150
+ }
151
+ else {
152
+ videoRef.current.src = videoSrc;
153
+ }
154
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('loadedmetadata', handleLoadedMetadata);
155
+ (_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('pause', handlePause);
156
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.addEventListener('timeupdate', handleTimeUpload);
157
+ return () => {
158
+ var _a, _b, _c, _d;
159
+ if (hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current)
160
+ (_a = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
161
+ setIsLoadFinish(false);
162
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('loadedmetadata', handleLoadedMetadata);
163
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('pause', handlePause);
164
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.removeEventListener('timeupdate', handleTimeUpload);
165
+ };
166
+ }, [handleLoadedMetadata, handlePlaying, rec, handLoadeddata, isActive]);
167
+ const renderPoster = useMemo(() => {
168
+ if (!(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image) || isLoadFinish) {
169
+ return null;
170
+ }
171
+ 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' }));
172
+ }, [isLoadFinish, sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image]);
173
+ const blurStyle = useMemo(() => {
174
+ return blur
175
+ ? {
176
+ filter: 'blur(10px)',
177
+ transform: 'translate3d(0px, 0px, 0px) scale(1.2)'
178
+ }
179
+ : {};
180
+ }, [blur]);
181
+ if (!(rec === null || rec === void 0 ? void 0 : rec.mediaUrl)) {
182
+ return null;
183
+ }
184
+ return (React.createElement("div", { className: 'video-container', key: rec.itemId, style: {
185
+ position: 'relative',
186
+ width: '100%',
187
+ height,
188
+ overflow: 'hidden',
189
+ pointerEvents: 'none'
190
+ } },
191
+ React.createElement("div", { className: 'n-full-screen', id: videoId, style: { width: '100%', height: '100%' } })));
192
+ };
193
+ export default memo(VideoWidget);
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { ISxpPageRenderProps } from '../SxpPageRender';
3
+ export interface IScene {
4
+ blueprintStep: number;
5
+ endTime: number;
6
+ itemId: string;
7
+ mediaFileNo: string;
8
+ mediaUrl: string;
9
+ position: number;
10
+ postId: string;
11
+ sceneId: string;
12
+ sceneInfo: string;
13
+ sceneTag: string;
14
+ startTime: number;
15
+ traceInfo: string;
16
+ }
17
+ export type ScenesType = IScene[];
18
+ export type DiyStoryPreviewType = ISxpPageRenderProps & {
19
+ appDomain?: string;
20
+ scenes?: ScenesType;
21
+ activeIndex?: number;
22
+ onActiveChange?: (v: number) => void;
23
+ loopPlay?: boolean;
24
+ };
25
+ declare const _default: React.NamedExoticComponent<DiyStoryPreviewType>;
26
+ export default _default;
@@ -0,0 +1,118 @@
1
+ import React, { memo, useEffect, useMemo, useRef } from 'react';
2
+ import { Swiper, SwiperSlide } from 'swiper/react';
3
+ import Nudge from '../SxpPageRender/Nudge';
4
+ import RenderCard from '../SxpPageRender/RenderCard';
5
+ import ExpandableText from '../SxpPageRender/ExpandableText';
6
+ import Hashtag from '../SxpPageRender/Hashtag';
7
+ import LikeButton from '../SxpPageRender/LikeButton';
8
+ import { useIconLink } from '../SxpPageRender/useIconLink';
9
+ import PictureGroup from './PictureGroup';
10
+ import VideoWidget from './VideoWidget';
11
+ import * as _materials_ from '../../../materials';
12
+ const RESOLVER = {};
13
+ Object.values(_materials_).forEach((v) => {
14
+ RESOLVER[v.extend.type] = v;
15
+ });
16
+ const defaultUnLikeIconPath = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
17
+ const defaultLikeIconPath = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
18
+ const DiyStoryPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, descStyle, hashTagStyle, containerHeight = 664, containerWidth = 375, appDomain, tagList = [], scenes, onActiveChange, activeIndex, loopPlay = false }) => {
19
+ const swiperRef = useRef(null);
20
+ const height = useMemo(() => {
21
+ let minusHeight = 0;
22
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
23
+ minusHeight += 45;
24
+ }
25
+ if (tagList.length > 0) {
26
+ minusHeight += 45;
27
+ }
28
+ return containerHeight - minusHeight;
29
+ }, [globalConfig, containerHeight, tagList]);
30
+ const isVideoUrl = (url) => {
31
+ if (url && url !== '' && typeof url === 'string') {
32
+ const imageExtensions = ['.mp4', '.m3u8'];
33
+ const lowerCaseUrl = url === null || url === void 0 ? void 0 : url.toLowerCase();
34
+ return imageExtensions.some((ext) => lowerCaseUrl === null || lowerCaseUrl === void 0 ? void 0 : lowerCaseUrl.endsWith(ext));
35
+ }
36
+ else {
37
+ return false;
38
+ }
39
+ };
40
+ const renderContent = (rec, index) => {
41
+ const isVideo = isVideoUrl(rec === null || rec === void 0 ? void 0 : rec.mediaUrl);
42
+ if (isVideo) {
43
+ return (React.createElement(VideoWidget, { 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 }));
44
+ }
45
+ else {
46
+ return (React.createElement(PictureGroup, { 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 }));
47
+ }
48
+ };
49
+ const renderLogo = useMemo(() => {
50
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
51
+ return (React.createElement("div", { className: 'clc-sxp-logo-banner', style: { backgroundColor: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.color } },
52
+ React.createElement("img", { src: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl, alt: 'logo' })));
53
+ }
54
+ return null;
55
+ }, [globalConfig]);
56
+ const CTA = (rec, index) => {
57
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA) === undefined || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA)) {
58
+ return (React.createElement("div", { className: 'clc-sxp-bottom-card' },
59
+ React.createElement(RenderCard, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER })));
60
+ }
61
+ return null;
62
+ };
63
+ const renderBottom = (rec, index) => {
64
+ var _a, _b, _c, _d, _e, _f, _g;
65
+ if (rec === null || rec === void 0 ? void 0 : rec.video) {
66
+ return (React.createElement(React.Fragment, null,
67
+ ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.title) && React.createElement("div", { className: 'clc-sxp-bottom-shadow' }),
68
+ React.createElement("div", { className: 'clc-sxp-bottom' },
69
+ React.createElement(Nudge, { nudge: nudge }),
70
+ CTA(rec, index),
71
+ React.createElement("div", null,
72
+ React.createElement(ExpandableText, { className: 'clc-sxp-bottom-text', isPost: true, foldText: tipText === null || tipText === void 0 ? void 0 : tipText.foldText, unfoldText: tipText === null || tipText === void 0 ? void 0 : tipText.unfoldText, text: (_c = (_b = rec === null || rec === void 0 ? void 0 : rec.video) === null || _b === void 0 ? void 0 : _b.title) !== null && _c !== void 0 ? _c : '', style: Object.assign(Object.assign({}, descStyle), { textShadow: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isOpenTextShadow) ? '2px 2px 4px rgba(0, 0, 0, 0.5)' : 'none' }) })),
73
+ React.createElement(Hashtag, { index: index, tags: (_e = (_d = rec === null || rec === void 0 ? void 0 : rec.video) === null || _d === void 0 ? void 0 : _d.hashTags) !== null && _e !== void 0 ? _e : [], itemId: (_f = rec === null || rec === void 0 ? void 0 : rec.video) === null || _f === void 0 ? void 0 : _f.itemId, itemType: ((_g = rec === null || rec === void 0 ? void 0 : rec.video) === null || _g === void 0 ? void 0 : _g.itemId) ? 'VIDEO' : null, rec: rec, hashTagStyle: hashTagStyle }))));
74
+ }
75
+ return null;
76
+ };
77
+ const likeIcon = useIconLink(defaultLikeIconPath, appDomain);
78
+ const unlikeIcon = useIconLink(defaultUnLikeIconPath, appDomain);
79
+ const renderLikeButton = (rec, index) => {
80
+ var _a, _b, _c, _d;
81
+ if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLike))
82
+ return;
83
+ let top = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconY) !== null && _a !== void 0 ? _a : 400;
84
+ if (top < 40) {
85
+ top += 40;
86
+ }
87
+ if (rec === null || rec === void 0 ? void 0 : rec.video) {
88
+ return (React.createElement(LikeButton, { key: rec.position, activeIcon: (_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIcon) !== null && _b !== void 0 ? _b : likeIcon, unActicveIcon: (_c = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.unlikeIcon) !== null && _c !== void 0 ? _c : unlikeIcon, position: index, active: rec.isCollected, recData: rec, className: 'clc-sxp-like-button', style: {
89
+ top,
90
+ right: (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconX) !== null && _d !== void 0 ? _d : 0
91
+ } }));
92
+ }
93
+ return null;
94
+ };
95
+ const mutedIcon = useIconLink('/pb_static/5beaaa5ce7f3477b99db3838619cc471.png', appDomain);
96
+ const unmutedIcon = useIconLink('/pb_static/fea8668a8a894e4aa3a86bcc775e895e.png', appDomain);
97
+ const renderView = (rec, index) => {
98
+ return (React.createElement(SwiperSlide, { key: index, virtualIndex: index, style: { overflow: 'hidden', position: 'relative' } }, renderContent(rec, index)));
99
+ };
100
+ useEffect(() => {
101
+ var _a, _b;
102
+ if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
103
+ return;
104
+ (_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);
105
+ }, [activeIndex]);
106
+ useEffect(() => {
107
+ var _a, _b;
108
+ if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
109
+ return;
110
+ (_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);
111
+ }, [loopPlay]);
112
+ return (React.createElement(Swiper, { ref: swiperRef, allowTouchMove: false, onActiveIndexChange: (swiper) => {
113
+ onActiveChange === null || onActiveChange === void 0 ? void 0 : onActiveChange(swiper.activeIndex);
114
+ }, direction: 'vertical', style: { overflow: 'hidden', height: containerHeight } }, scenes === null || scenes === void 0 ? void 0 : scenes.map((rec, index) => {
115
+ return renderView(rec, index);
116
+ })));
117
+ };
118
+ export default memo(DiyStoryPreview);
@@ -114,12 +114,8 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
114
114
  }
115
115
  if (options.type === 'beacon' && navigator.sendBeacon) {
116
116
  return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
117
- JSON.stringify({
118
- body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
119
- })
120
- ], {
121
- type: 'application/json;charset=UTF-8'
122
- }));
117
+ JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))
118
+ ], { type: 'application/json;charset=UTF-8' }));
123
119
  }
124
120
  return window
125
121
  .fetch(`${url}/api/${path}`, {
@@ -273,7 +269,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
273
269
  console.log('userInfo:', userInfo);
274
270
  console.log('eventInfo:', ef);
275
271
  console.log('========= 结束 =========');
276
- return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/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}${cl_source ? `/${decodeURIComponent(cl_source)}` : ''}`, {
272
+ 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}`, {
277
273
  method: 'POST',
278
274
  body: { userInfo: realUserInfo, eventInfo: realEventInfo },
279
275
  type: 'beacon'
package/es/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export * as core from './core';
4
4
  export * as materials from './materials';
5
5
  export { default as SxpPageRender } from './core/components/SxpPageRender';
6
6
  export { default as DiyPortalPreview } from './core/components/DiyPortalPreview';
7
+ export { default as DiyStoryPreview } from './core/components/DiyStoryPreview';
7
8
  export { default as Modal } from './core/components/SxpPageRender/Modal';
8
9
  export { default as SxpDataSourceProvider } from './core/context/SxpDataSourceProvider';
9
10
  export { default as SxpPageCore } from './core/components/SxpPageCore';
package/es/index.js CHANGED
@@ -6,6 +6,7 @@ import * as materials_1 from './materials';
6
6
  export { materials_1 as materials };
7
7
  export { default as SxpPageRender } from './core/components/SxpPageRender';
8
8
  export { default as DiyPortalPreview } from './core/components/DiyPortalPreview';
9
+ export { default as DiyStoryPreview } from './core/components/DiyStoryPreview';
9
10
  export { default as Modal } from './core/components/SxpPageRender/Modal';
10
11
  export { default as SxpDataSourceProvider } from './core/context/SxpDataSourceProvider';
11
12
  export { default as SxpPageCore } from './core/components/SxpPageCore';
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { postConfigType } from '../SxpPageRender';
3
+ import { IScene, ScenesType } from '.';
4
+ interface IPictureGroupProps {
5
+ imgUrls?: string[];
6
+ width: number;
7
+ height: number;
8
+ rec: IScene;
9
+ index: number;
10
+ imgUrlsPostConfig?: postConfigType;
11
+ swiperRef?: any;
12
+ data?: ScenesType;
13
+ loopPlay?: boolean;
14
+ }
15
+ declare const _default: React.NamedExoticComponent<IPictureGroupProps>;
16
+ export default _default;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importStar(require("react"));
5
+ const modules_1 = require("swiper/modules");
6
+ const react_2 = require("swiper/react");
7
+ const Picture_1 = tslib_1.__importDefault(require("../SxpPageRender/PictureGroup/Picture"));
8
+ const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index, swiperRef, data = [], loopPlay }) => {
9
+ const { isActive } = (0, react_2.useSwiperSlide)();
10
+ const [isload, setIsLoad] = (0, react_1.useState)(false);
11
+ (0, react_1.useEffect)(() => {
12
+ if (isActive && isload && loopPlay) {
13
+ setTimeout(() => {
14
+ var _a, _b, _c, _d;
15
+ if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
16
+ (_a = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _a === void 0 ? void 0 : _a.swiper.slideTo(0);
17
+ }
18
+ else {
19
+ 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;
20
+ (_d = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _d === void 0 ? void 0 : _d.swiper.slideTo(i + 1);
21
+ }
22
+ }, 3000);
23
+ }
24
+ }, [isActive, isload, data, index, swiperRef, loopPlay]);
25
+ const loadFinishImage = () => {
26
+ setIsLoad(true);
27
+ };
28
+ return (react_1.default.createElement(react_2.Swiper, { defaultValue: 0, direction: 'horizontal', modules: [modules_1.Pagination, modules_1.Autoplay], pagination: {
29
+ clickable: true,
30
+ bulletActiveClass: 'swipe-item-active-bullet',
31
+ bulletElement: 'button'
32
+ }, height: height, style: { width }, loop: true, autoplay: false }, imgUrls === null || imgUrls === void 0 ? void 0 : imgUrls.map((url) => {
33
+ return (react_1.default.createElement(react_2.SwiperSlide, { key: url },
34
+ react_1.default.createElement(Picture_1.default, { src: url, height: height, imgUrlsPostConfig: imgUrlsPostConfig, onShowFirstImage: loadFinishImage })));
35
+ })));
36
+ };
37
+ exports.default = (0, react_1.memo)(PictureGroup);
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { postConfigType } from '../SxpPageRender';
3
+ import { IScene, ScenesType } from '.';
4
+ interface IVideoWidgetProps {
5
+ rec: IScene;
6
+ index: number;
7
+ height: number;
8
+ width: number;
9
+ data: ScenesType;
10
+ muted: boolean;
11
+ activeIndex?: number;
12
+ videoPostConfig?: postConfigType;
13
+ swiperRef?: any;
14
+ loopPlay?: boolean;
15
+ }
16
+ declare const _default: React.NamedExoticComponent<IVideoWidgetProps>;
17
+ export default _default;