pb-sxp-ui 1.15.21 → 1.15.22-alpha.2

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 (52) hide show
  1. package/dist/index.cjs +7737 -7247
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.css +46 -46
  4. package/dist/index.js +7735 -7246
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.min.cjs +6 -6
  7. package/dist/index.min.cjs.map +1 -1
  8. package/dist/index.min.js +6 -6
  9. package/dist/index.min.js.map +1 -1
  10. package/dist/pb-ui.js +7737 -7247
  11. package/dist/pb-ui.js.map +1 -1
  12. package/dist/pb-ui.min.js +6 -6
  13. package/dist/pb-ui.min.js.map +1 -1
  14. package/es/core/Pagebuilder/type.d.ts +10 -5
  15. package/es/core/components/DiyStoryPreview/PictureGroup.d.ts +16 -0
  16. package/es/core/components/DiyStoryPreview/PictureGroup.js +34 -0
  17. package/es/core/components/DiyStoryPreview/VideoWidget.d.ts +27 -0
  18. package/es/core/components/DiyStoryPreview/VideoWidget.js +197 -0
  19. package/es/core/components/DiyStoryPreview/index.d.ts +32 -0
  20. package/es/core/components/DiyStoryPreview/index.js +232 -0
  21. package/es/core/components/SxpPageCore/index.js +3 -2
  22. package/es/core/components/SxpPageRender/VideoWidget/index.d.ts +6 -1
  23. package/es/core/components/SxpPageRender/VideoWidget/index.js +52 -12
  24. package/es/core/components/SxpPageRender/index.d.ts +0 -1
  25. package/es/core/components/SxpPageRender/index.js +6 -3
  26. package/es/core/components/SxpPageRender/typing.d.ts +19 -0
  27. package/es/core/context/SxpDataSourceProvider.d.ts +3 -1
  28. package/es/core/context/SxpDataSourceProvider.js +50 -98
  29. package/es/index.d.ts +1 -0
  30. package/es/index.js +1 -0
  31. package/es/materials/sxp/popup/CommodityDetail/index.js +2 -2
  32. package/es/materials/sxp/popup/CommodityDetailDiroNew/index.js +1 -1
  33. package/lib/core/Pagebuilder/type.d.ts +10 -5
  34. package/lib/core/components/DiyStoryPreview/PictureGroup.d.ts +16 -0
  35. package/lib/core/components/DiyStoryPreview/PictureGroup.js +37 -0
  36. package/lib/core/components/DiyStoryPreview/VideoWidget.d.ts +27 -0
  37. package/lib/core/components/DiyStoryPreview/VideoWidget.js +200 -0
  38. package/lib/core/components/DiyStoryPreview/index.d.ts +32 -0
  39. package/lib/core/components/DiyStoryPreview/index.js +235 -0
  40. package/lib/core/components/SxpPageCore/index.js +3 -2
  41. package/lib/core/components/SxpPageRender/VideoWidget/index.d.ts +6 -1
  42. package/lib/core/components/SxpPageRender/VideoWidget/index.js +51 -11
  43. package/lib/core/components/SxpPageRender/index.d.ts +0 -1
  44. package/lib/core/components/SxpPageRender/index.js +6 -3
  45. package/lib/core/components/SxpPageRender/typing.d.ts +19 -0
  46. package/lib/core/context/SxpDataSourceProvider.d.ts +3 -1
  47. package/lib/core/context/SxpDataSourceProvider.js +50 -98
  48. package/lib/index.d.ts +1 -0
  49. package/lib/index.js +3 -1
  50. package/lib/materials/sxp/popup/CommodityDetail/index.js +2 -2
  51. package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.js +1 -1
  52. package/package.json +1 -1
@@ -50,11 +50,16 @@ export interface SeoParameter {
50
50
  key_word: string;
51
51
  }
52
52
  export interface UtmParameter {
53
- utm_source: string;
54
- utm_medium: string;
55
- utm_campaign: string;
56
- channels?: string[];
57
- enabled_meta_conversion_api?: boolean;
53
+ channels: string[];
54
+ enabled_meta_conversion_api: boolean;
55
+ values: string[];
56
+ cos_path: string;
57
+ enabled_google_no_index: boolean;
58
+ enabled_google_analytics: boolean;
59
+ enabled_gtm: boolean;
60
+ enabled_alibaba_cloud: boolean;
61
+ enabled_uptime: boolean;
62
+ experience_id: string | null;
58
63
  }
59
64
  interface PagebuilderProps {
60
65
  init: (e: initParams) => void;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { postConfigType } from '../SxpPageRender';
3
+ import { RecItemType } from '../SxpPageRender/typing';
4
+ interface IPictureGroupProps {
5
+ imgUrls?: string[];
6
+ width: number;
7
+ height: number;
8
+ rec: RecItemType;
9
+ index: number;
10
+ imgUrlsPostConfig?: postConfigType;
11
+ swiperRef?: any;
12
+ data?: RecItemType[];
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,27 @@
1
+ import React from 'react';
2
+ import { postConfigType } from '../SxpPageRender';
3
+ import { RecItemType } from '../SxpPageRender/typing';
4
+ interface IVideoWidgetProps {
5
+ rec: RecItemType;
6
+ index: number;
7
+ height: number;
8
+ width: number;
9
+ data: RecItemType[];
10
+ muted: boolean;
11
+ activeIndex?: number;
12
+ videoPostConfig?: postConfigType;
13
+ swiperRef?: any;
14
+ videoPlayIcon?: string;
15
+ onUpdateTimeLine?: (index: number, v: number) => void;
16
+ loopPlay: any;
17
+ onPlay?: (index: number, v: number) => void;
18
+ onPause?: () => void;
19
+ }
20
+ export interface IVideoWidgetRef {
21
+ play: () => void;
22
+ pause: () => void;
23
+ setLoopPlay: (v: boolean) => void;
24
+ isPlaying: () => boolean;
25
+ }
26
+ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<IVideoWidgetProps & React.RefAttributes<IVideoWidgetRef>>>;
27
+ export default _default;
@@ -0,0 +1,197 @@
1
+ import React, { forwardRef, memo, useCallback, useEffect, useImperativeHandle, 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 FormatImage from '../SxpPageRender/FormatImage';
6
+ import { useSxpDataSource } from '../../../core/hooks';
7
+ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex, videoPostConfig, width, swiperRef, videoPlayIcon, onUpdateTimeLine, loopPlay, onPlay, onPause }, ref) => {
8
+ const { isActive } = useSwiperSlide();
9
+ const [isPauseVideo, setIsPauseVideo] = useState(false);
10
+ const videoRef = useRef(null);
11
+ const { bffEventReport, sxpParameter, waterFallData, openHashtag } = useSxpDataSource();
12
+ const videoStartTime = useRef(0);
13
+ const [isLoadFinish, setIsLoadFinish] = useState(false);
14
+ const [isFirstPlay, setIsFirstPlay] = useState(true);
15
+ const canvasRef = useRef(null);
16
+ const [firstFrameSrc, setFirstFrameSrc] = useState('');
17
+ const videoId = `pb-cache-video-${index}`;
18
+ const hlsRef = useRef(null);
19
+ const loopPlayRef = useRef(loopPlay);
20
+ const scene = rec.video.scene;
21
+ useEffect(() => {
22
+ loopPlayRef.current = loopPlay;
23
+ }, [loopPlay]);
24
+ useImperativeHandle(ref, () => {
25
+ return {
26
+ play() {
27
+ var _a;
28
+ if (!videoRef.current)
29
+ return;
30
+ handleTimeUpload();
31
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
32
+ setIsPauseVideo(false);
33
+ },
34
+ pause() {
35
+ var _a;
36
+ if (!videoRef.current)
37
+ return;
38
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.pause();
39
+ setIsPauseVideo(true);
40
+ },
41
+ setLoopPlay(v) {
42
+ loopPlayRef.current = v;
43
+ },
44
+ isPlaying() {
45
+ var _a;
46
+ return !((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.paused);
47
+ }
48
+ };
49
+ });
50
+ useEffect(() => {
51
+ if (!videoRef.current)
52
+ return;
53
+ videoRef.current.muted = muted;
54
+ }, [muted]);
55
+ const PAUSE_ICON = useIconLink('/pb_static/06f28a2025c74c1cb49be6767316d827.png');
56
+ const handleLoadedMetadata = useCallback(() => {
57
+ var _a;
58
+ videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
59
+ (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
60
+ setIsLoadFinish(true);
61
+ }, []);
62
+ const handleClickVideo = useCallback((type) => () => {
63
+ var _a, _b, _c, _d, _e, _f;
64
+ if (!isActive || !(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
65
+ return;
66
+ const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
67
+ switch (type) {
68
+ case 'start':
69
+ if (!isPause)
70
+ return;
71
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.play();
72
+ setIsPauseVideo(false);
73
+ break;
74
+ case 'pause':
75
+ if (isPause)
76
+ return;
77
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
78
+ setIsPauseVideo(true);
79
+ break;
80
+ default:
81
+ if (isPause) {
82
+ if (((_d = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _d === void 0 ? void 0 : _d.currentTime) >= (scene === null || scene === void 0 ? void 0 : scene.endTime)) {
83
+ videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
84
+ }
85
+ (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.play();
86
+ }
87
+ else {
88
+ (_f = videoRef.current) === null || _f === void 0 ? void 0 : _f.pause();
89
+ }
90
+ setIsPauseVideo(!isPause);
91
+ break;
92
+ }
93
+ }, [isLoadFinish]);
94
+ const blur = useMemo(() => {
95
+ return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2';
96
+ }, [videoPostConfig]);
97
+ const handleTimeUpload = () => {
98
+ if (!videoRef.current)
99
+ return;
100
+ setTimeout(() => {
101
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
102
+ if (((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.currentTime) >= ((_b = scene === null || scene === void 0 ? void 0 : scene.endTime) !== null && _b !== void 0 ? _b : 0)) {
103
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
104
+ if (!loopPlayRef.current)
105
+ return;
106
+ if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
107
+ (_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.slideTo(0);
108
+ }
109
+ else {
110
+ const i = (_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.activeIndex;
111
+ (_j = (_h = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _h === void 0 ? void 0 : _h.swiper) === null || _j === void 0 ? void 0 : _j.slideTo(i + 1);
112
+ }
113
+ }
114
+ });
115
+ };
116
+ const handlePause = () => {
117
+ setIsPauseVideo(true);
118
+ onPause === null || onPause === void 0 ? void 0 : onPause();
119
+ };
120
+ const handlePlay = () => {
121
+ var _a;
122
+ const localTime = ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.currentTime) - (scene === null || scene === void 0 ? void 0 : scene.startTime);
123
+ onPlay === null || onPlay === void 0 ? void 0 : onPlay(index, localTime);
124
+ };
125
+ useEffect(() => {
126
+ var _a, _b, _c, _d;
127
+ if (!isActive)
128
+ return;
129
+ const videoSrc = scene === null || scene === void 0 ? void 0 : scene.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
+ if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
138
+ return;
139
+ const Hls = window === null || window === void 0 ? void 0 : window.Hls;
140
+ let hls = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current;
141
+ if (videoSrc.includes('.m3u8') && Hls && Hls.isSupported()) {
142
+ hls = new Hls();
143
+ hls === null || hls === void 0 ? void 0 : hls.loadSource(videoSrc);
144
+ hls === null || hls === void 0 ? void 0 : hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
145
+ hls === null || hls === void 0 ? void 0 : hls.on(Hls.Events.MANIFEST_PARSED, function () {
146
+ var _a;
147
+ videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
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 === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.addEventListener('play', handlePlay);
157
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('timeupdate', handleTimeUpload);
158
+ return () => {
159
+ var _a, _b, _c, _d, _e;
160
+ if (hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current)
161
+ (_a = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
162
+ setIsLoadFinish(false);
163
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('loadedmetadata', handleLoadedMetadata);
164
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('pause', handlePause);
165
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.removeEventListener('play', handlePlay);
166
+ (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.removeEventListener('timeupdate', handleTimeUpload);
167
+ };
168
+ }, [isActive]);
169
+ const renderPoster = useMemo(() => {
170
+ var _a;
171
+ if (!(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image) || isLoadFinish) {
172
+ return null;
173
+ }
174
+ return (React.createElement("img", { style: { position: 'absolute', left: 0, top: 0, width: '100%', height: '100%', objectFit: 'cover' }, src: ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.cover) || (sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image), alt: 'video poster' }));
175
+ }, [isLoadFinish, sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image]);
176
+ const blurStyle = useMemo(() => {
177
+ return blur
178
+ ? {
179
+ filter: 'blur(10px)',
180
+ transform: 'translate3d(0px, 0px, 0px) scale(1.2)'
181
+ }
182
+ : {};
183
+ }, [blur]);
184
+ if (!(scene === null || scene === void 0 ? void 0 : scene.mediaUrl)) {
185
+ return null;
186
+ }
187
+ return (React.createElement("div", { className: 'video-container', key: scene.itemId, style: {
188
+ position: 'relative',
189
+ width: '100%',
190
+ height,
191
+ overflow: 'hidden'
192
+ }, onClick: handleClickVideo() },
193
+ React.createElement("div", { className: 'n-full-screen', id: videoId, style: { width: '100%', height: '100%' } }),
194
+ renderPoster,
195
+ isPauseVideo && React.createElement(FormatImage, { className: 'clc-pb-video-pause', src: videoPlayIcon !== null && videoPlayIcon !== void 0 ? videoPlayIcon : PAUSE_ICON, alt: 'pause' })));
196
+ });
197
+ export default memo(VideoWidget);
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import { ISxpPageRenderProps } from '../SxpPageRender';
3
+ import '../SxpPageRender/index.less';
4
+ export type DiyStoryPreviewType = ISxpPageRenderProps & {
5
+ appDomain?: string;
6
+ activeIndex?: number;
7
+ onActiveChange?: (v: number) => void;
8
+ loopPlay?: boolean;
9
+ pointerEvents?: any;
10
+ onUpdateTimeLine: (index: number, curTime: number) => void;
11
+ onPlay: (index: number, curTime: number) => void;
12
+ onPause: () => void;
13
+ disabledListener?: boolean;
14
+ };
15
+ export interface IDiyStoryPreviewRef {
16
+ play: () => void;
17
+ pause: () => void;
18
+ slideTo: (n: number) => void;
19
+ isPlaying: () => boolean;
20
+ }
21
+ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<ISxpPageRenderProps & {
22
+ appDomain?: string | undefined;
23
+ activeIndex?: number | undefined;
24
+ onActiveChange?: ((v: number) => void) | undefined;
25
+ loopPlay?: boolean | undefined;
26
+ pointerEvents?: any;
27
+ onUpdateTimeLine: (index: number, curTime: number) => void;
28
+ onPlay: (index: number, curTime: number) => void;
29
+ onPause: () => void;
30
+ disabledListener?: boolean | undefined;
31
+ } & React.RefAttributes<IDiyStoryPreviewRef>>>;
32
+ export default _default;
@@ -0,0 +1,232 @@
1
+ import React, { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
2
+ import { Swiper, SwiperSlide } from 'swiper/react';
3
+ import { debounce } from 'lodash';
4
+ import RenderCard from '../SxpPageRender/RenderCard';
5
+ import ExpandableText from '../SxpPageRender/ExpandableText';
6
+ import LikeButton from '../SxpPageRender/LikeButton';
7
+ import { useIconLink } from '../SxpPageRender/useIconLink';
8
+ import ToggleButton from '../SxpPageRender/ToggleButton';
9
+ import PictureGroup from './PictureGroup';
10
+ import VideoWidget from './VideoWidget';
11
+ import * as _materials_ from '../../../materials';
12
+ import '../SxpPageRender/index.less';
13
+ const RESOLVER = {};
14
+ Object.values(_materials_).forEach((v) => {
15
+ RESOLVER[v.extend.type] = v;
16
+ });
17
+ const defaultUnLikeIconPath = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
18
+ const defaultLikeIconPath = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
19
+ const DiyStoryPreview = forwardRef(({ data = [], globalConfig, tipText, nudge, tempMap, descStyle, hashTagStyle, containerHeight = 664, containerWidth = 375, appDomain, tagList = [], onActiveChange, activeIndex, loopPlay = false, pointerEvents = 'none', onUpdateTimeLine, disabledListener, onPlay, onPause }, ref) => {
20
+ const videoWidgetRef = useRef(null);
21
+ const swiperRef = useRef(null);
22
+ const [curIndex, setCurIndex] = useState(0);
23
+ const height = useMemo(() => {
24
+ let minusHeight = 0;
25
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
26
+ minusHeight += 45;
27
+ }
28
+ if (tagList.length > 0) {
29
+ minusHeight += 45;
30
+ }
31
+ return containerHeight - minusHeight;
32
+ }, [globalConfig, containerHeight, tagList]);
33
+ useImperativeHandle(ref, () => {
34
+ return {
35
+ play() {
36
+ var _a;
37
+ (_a = videoWidgetRef === null || videoWidgetRef === void 0 ? void 0 : videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.play();
38
+ },
39
+ pause() {
40
+ var _a;
41
+ (_a = videoWidgetRef === null || videoWidgetRef === void 0 ? void 0 : videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.pause();
42
+ },
43
+ slideTo(n) {
44
+ var _a, _b;
45
+ if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
46
+ return;
47
+ (_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);
48
+ },
49
+ isPlaying() {
50
+ var _a, _b;
51
+ 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;
52
+ }
53
+ };
54
+ });
55
+ const isVideoUrl = (url) => {
56
+ if (url && url !== '' && typeof url === 'string') {
57
+ const imageExtensions = ['.mp4', '.m3u8'];
58
+ const lowerCaseUrl = url === null || url === void 0 ? void 0 : url.toLowerCase();
59
+ return imageExtensions.some((ext) => lowerCaseUrl === null || lowerCaseUrl === void 0 ? void 0 : lowerCaseUrl.endsWith(ext));
60
+ }
61
+ else {
62
+ return false;
63
+ }
64
+ };
65
+ const renderContent = (rec, index) => {
66
+ var _a, _b;
67
+ const scene = (_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.scene;
68
+ const isVideo = isVideoUrl(scene === null || scene === void 0 ? void 0 : scene.mediaUrl);
69
+ if (isVideo) {
70
+ return (React.createElement(VideoWidget, Object.assign({ key: index }, (curIndex === index && { ref: videoWidgetRef }), { rec: rec, index: index, muted: true, width: containerWidth, data: data, 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, onUpdateTimeLine: onUpdateTimeLine, onPlay: onPlay, onPause: onPause })));
71
+ }
72
+ else {
73
+ return (React.createElement(PictureGroup, { key: index, imgUrls: [(_b = scene === null || scene === void 0 ? void 0 : scene.mediaUrl) !== null && _b !== void 0 ? _b : ''], width: containerWidth, height: containerHeight, rec: rec, index: index, imgUrlsPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.imgUrlsPost, data: data, swiperRef: swiperRef }));
74
+ }
75
+ };
76
+ const renderLogo = useMemo(() => {
77
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
78
+ return (React.createElement("div", { className: 'clc-sxp-logo-banner', style: { backgroundColor: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.color } },
79
+ React.createElement("img", { src: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl, alt: 'logo' })));
80
+ }
81
+ return null;
82
+ }, [globalConfig]);
83
+ const renderBottom = (rec, index) => {
84
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
85
+ if (rec === null || rec === void 0 ? void 0 : rec.video) {
86
+ let cta = null;
87
+ if ((_b = (_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.bindProducts) === null || _b === void 0 ? void 0 : _b.length) {
88
+ cta = '多商品CTA';
89
+ }
90
+ else if ((_c = rec === null || rec === void 0 ? void 0 : rec.video) === null || _c === void 0 ? void 0 : _c.bindProduct) {
91
+ cta = '商品CTA';
92
+ }
93
+ else {
94
+ cta = (_e = (_d = rec === null || rec === void 0 ? void 0 : rec.video) === null || _d === void 0 ? void 0 : _d.bindCta) === null || _e === void 0 ? void 0 : _e.itemId;
95
+ }
96
+ const value = tempMap === null || tempMap === void 0 ? void 0 : tempMap[cta];
97
+ return (React.createElement(React.Fragment, null,
98
+ ((_f = rec === null || rec === void 0 ? void 0 : rec.video) === null || _f === void 0 ? void 0 : _f.title) && (React.createElement("div", { style: {
99
+ background: 'repeating-linear-gradient(0deg, rgba(26, 26, 25, 0.7), hsla(0, 0%, 100%, 0))',
100
+ height: '130px',
101
+ position: 'absolute',
102
+ bottom: 0,
103
+ width: '100%',
104
+ willChange: 'transform',
105
+ zIndex: 2,
106
+ pointerEvents
107
+ } })),
108
+ React.createElement("div", { style: {
109
+ marginBottom: `${(_g = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.bottomInfoDist) !== null && _g !== void 0 ? _g : 40}px`,
110
+ zIndex: 999,
111
+ position: 'absolute',
112
+ bottom: 0,
113
+ left: 0,
114
+ right: 0,
115
+ paddingTop: '20px'
116
+ } },
117
+ (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA) === undefined || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA) ? (React.createElement("div", { style: {} },
118
+ React.createElement(RenderCard, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER, isActive: index === activeIndex, value: value }))) : null,
119
+ React.createElement("div", null,
120
+ React.createElement(ExpandableText, { isPost: true, foldText: tipText === null || tipText === void 0 ? void 0 : tipText.foldText, unfoldText: tipText === null || tipText === void 0 ? void 0 : tipText.unfoldText, text: (_j = (_h = rec === null || rec === void 0 ? void 0 : rec.video) === null || _h === void 0 ? void 0 : _h.title) !== null && _j !== void 0 ? _j : '', 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', padding: '0 20px', fontSize: '12px' }) }),
121
+ React.createElement(RenderCard, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER, includesCtaType: ['AniLink'], isActive: index === activeIndex, value: value }))),
122
+ React.createElement(RenderCard, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER, includesCtaType: ['AniLinkPopup'], isActive: index === activeIndex, value: value })));
123
+ }
124
+ return null;
125
+ };
126
+ const likeIcon = useIconLink(defaultLikeIconPath, appDomain);
127
+ const unlikeIcon = useIconLink(defaultUnLikeIconPath, appDomain);
128
+ const renderLikeButton = (rec, index) => {
129
+ var _a, _b, _c, _d;
130
+ if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLike))
131
+ return null;
132
+ let top = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconY) !== null && _a !== void 0 ? _a : 400;
133
+ if (top < 40) {
134
+ top += 40;
135
+ }
136
+ if (rec === null || rec === void 0 ? void 0 : rec.video) {
137
+ 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, style: {
138
+ top,
139
+ right: (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconX) !== null && _d !== void 0 ? _d : 0,
140
+ position: 'absolute',
141
+ zIndex: 999,
142
+ backgroundColor: 'transparent',
143
+ width: '50px',
144
+ height: '50px',
145
+ outline: 'none',
146
+ border: 'none',
147
+ boxSizing: 'content-box',
148
+ padding: 0,
149
+ transform: 'translate3d(0px, 0px, 0px)'
150
+ } }));
151
+ }
152
+ return null;
153
+ };
154
+ const mutedIcon = useIconLink('/pb_static/5beaaa5ce7f3477b99db3838619cc471.png', appDomain);
155
+ const unmutedIcon = useIconLink('/pb_static/fea8668a8a894e4aa3a86bcc775e895e.png', appDomain);
156
+ const renderToggleButton = (visible) => {
157
+ var _a, _b, _c, _d;
158
+ if (!visible)
159
+ return null;
160
+ let top = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconY) !== null && _a !== void 0 ? _a : 23;
161
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconYPosit) === 'top') {
162
+ top += 45;
163
+ }
164
+ return (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowMute) === undefined || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowMute) === true ? (React.createElement(ToggleButton, { style: {
165
+ position: 'absolute',
166
+ visibility: 'visible',
167
+ zIndex: 999,
168
+ transform: 'translate3d(0px,0px,0px)',
169
+ [(_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconXPosit) !== null && _b !== void 0 ? _b : 'right']: (_c = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconX) !== null && _c !== void 0 ? _c : 0,
170
+ [(_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconYPosit) !== null && _d !== void 0 ? _d : 'bottom']: top,
171
+ backgroundColor: 'transparent',
172
+ width: '50px',
173
+ height: '50px',
174
+ outline: 'none',
175
+ border: 'none',
176
+ boxSizing: 'content-box',
177
+ padding: 0
178
+ }, defaultValue: true, activeIcon: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.unMuteIcon) ? globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.unMuteIcon : mutedIcon, unactiveIcon: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIcon) ? globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIcon : unmutedIcon })) : null;
179
+ };
180
+ const renderView = (item, index) => {
181
+ var _a, _b, _c, _d;
182
+ return (React.createElement("div", { style: { position: 'relative' } },
183
+ React.createElement(SwiperSlide, { key: index, virtualIndex: index, style: { overflow: 'hidden', position: 'relative' } },
184
+ renderBottom(item, index),
185
+ renderLikeButton(item, index),
186
+ renderToggleButton(!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconFixed)),
187
+ React.createElement(ToggleButton, { style: {
188
+ position: 'absolute',
189
+ right: (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconX) !== null && _a !== void 0 ? _a : 0,
190
+ visibility: ((_c = (_b = data === null || data === void 0 ? void 0 : data[index]) === null || _b === void 0 ? void 0 : _b.video) === null || _c === void 0 ? void 0 : _c.url) ? 'visible' : 'hidden',
191
+ bottom: (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconY) !== null && _d !== void 0 ? _d : 23,
192
+ zIndex: 999
193
+ }, defaultValue: true, activeIcon: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.unMuteIcon) ? globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.unMuteIcon : mutedIcon, unactiveIcon: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIcon) ? globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIcon : unmutedIcon }),
194
+ renderContent(item, index))));
195
+ };
196
+ useEffect(() => {
197
+ var _a, _b;
198
+ if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
199
+ return;
200
+ (_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);
201
+ }, [activeIndex]);
202
+ const handleSessionExpire = useCallback(debounce(() => {
203
+ var _a;
204
+ (_a = videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.setLoopPlay(false);
205
+ }, 1000), []);
206
+ useEffect(() => {
207
+ if (disabledListener)
208
+ return;
209
+ const events = ['touchstart', 'touchcancel'];
210
+ events.forEach((event) => {
211
+ window.addEventListener(event, handleSessionExpire);
212
+ });
213
+ return () => {
214
+ events.forEach((event) => {
215
+ window.removeEventListener(event, handleSessionExpire);
216
+ });
217
+ };
218
+ }, [handleSessionExpire, disabledListener]);
219
+ return (React.createElement("div", { id: 'sxp-render', style: { height: containerHeight, position: 'relative', pointerEvents } },
220
+ React.createElement(Swiper, { ref: swiperRef, allowTouchMove: pointerEvents !== 'none', onSlideChange: () => {
221
+ swiperRef.current.swiper.allowTouchMove = false;
222
+ setTimeout(() => {
223
+ swiperRef.current.swiper.allowTouchMove = true;
224
+ }, 500);
225
+ }, onActiveIndexChange: (swiper) => {
226
+ setCurIndex(swiper === null || swiper === void 0 ? void 0 : swiper.activeIndex);
227
+ onActiveChange === null || onActiveChange === void 0 ? void 0 : onActiveChange(swiper.activeIndex);
228
+ }, direction: 'vertical', style: { overflow: 'hidden', height: containerHeight }, height: containerHeight }, data === null || data === void 0 ? void 0 : data.map((rec, index) => {
229
+ return renderView(rec, index);
230
+ }))));
231
+ });
232
+ export default memo(DiyStoryPreview);
@@ -9,7 +9,8 @@ Object.values(_materials_).forEach((v) => {
9
9
  RESOLVER[v.extend.type] = v;
10
10
  });
11
11
  const SxpPageCore = ({ data, maxSize = 10, defaultSize = 10, hashTagSize = 20, loadingImage, appDomain, enabledMetaConversionApi, dataList }) => {
12
- var _a, _b, _c, _d, _e, _f;
12
+ var _a, _b, _c, _d, _e, _f, _g;
13
+ const isDiyH5 = ((_a = data === null || data === void 0 ? void 0 : data.page_type) === null || _a === void 0 ? void 0 : _a.path_type) === 5;
13
14
  const utmVal = useMemo(() => {
14
15
  var _a;
15
16
  const searchParams = (location === null || location === void 0 ? void 0 : location.search) ? (_a = location === null || location === void 0 ? void 0 : location.search) === null || _a === void 0 ? void 0 : _a.replace('?', '') : '';
@@ -18,7 +19,7 @@ const SxpPageCore = ({ data, maxSize = 10, defaultSize = 10, hashTagSize = 20, l
18
19
  const [_schema, setSchema] = useState(data === null || data === void 0 ? void 0 : data.data);
19
20
  const [channel, setChannel] = useState();
20
21
  return (React.createElement(EditorCore, { resolver: RESOLVER, enableDataSource: false, schema: _schema, utmVal: channel || utmVal },
21
- React.createElement(SxpDataSourceProvider, { utmVal: utmVal, dataSources: data === null || data === void 0 ? void 0 : data.data_sources, sxpParameter: data === null || data === void 0 ? void 0 : data.sxp_parameter, maxSize: (_b = (_a = data === null || data === void 0 ? void 0 : data.sxp_parameter) === null || _a === void 0 ? void 0 : _a.personalized_recommend) !== null && _b !== void 0 ? _b : maxSize, defaultSize: (_d = (_c = data === null || data === void 0 ? void 0 : data.sxp_parameter) === null || _c === void 0 ? void 0 : _c.default_recommend) !== null && _d !== void 0 ? _d : defaultSize, hashTagSize: (_f = (_e = data === null || data === void 0 ? void 0 : data.sxp_parameter) === null || _e === void 0 ? void 0 : _e.hash_tag_size) !== null && _f !== void 0 ? _f : hashTagSize, loadingImage: loadingImage, appDomain: appDomain, enabledMetaConversionApi: enabledMetaConversionApi, utmParameter: data === null || data === void 0 ? void 0 : data.utm_parameter, data: data, dataList: dataList, onUpdateSchema: (d) => setSchema(d), onUpdateChannel: (d) => setChannel(d), render: ({ rtcList, tagList, pageData }) => {
22
+ React.createElement(SxpDataSourceProvider, { utmVal: utmVal, dataSources: data === null || data === void 0 ? void 0 : data.data_sources, sxpParameter: data === null || data === void 0 ? void 0 : data.sxp_parameter, maxSize: (_c = (_b = data === null || data === void 0 ? void 0 : data.sxp_parameter) === null || _b === void 0 ? void 0 : _b.personalized_recommend) !== null && _c !== void 0 ? _c : maxSize, defaultSize: (_e = (_d = data === null || data === void 0 ? void 0 : data.sxp_parameter) === null || _d === void 0 ? void 0 : _d.default_recommend) !== null && _e !== void 0 ? _e : defaultSize, hashTagSize: (_g = (_f = data === null || data === void 0 ? void 0 : data.sxp_parameter) === null || _f === void 0 ? void 0 : _f.hash_tag_size) !== null && _g !== void 0 ? _g : hashTagSize, loadingImage: loadingImage, appDomain: appDomain, enabledMetaConversionApi: enabledMetaConversionApi, utmParameter: data === null || data === void 0 ? void 0 : data.utm_parameter, data: data, dataList: dataList, isDiyH5: isDiyH5, onUpdateSchema: (d) => setSchema(d), onUpdateChannel: (d) => setChannel(d), render: ({ rtcList, tagList, pageData }) => {
22
23
  var _a;
23
24
  return (React.createElement(React.Fragment, null,
24
25
  React.createElement(SxpPageRender, Object.assign({ defaultData: data }, (_a = pageData === null || pageData === void 0 ? void 0 : pageData.data) === null || _a === void 0 ? void 0 : _a.sxpPageConf, { tagList: tagList, data: rtcList, resolver: RESOLVER })),
@@ -10,6 +10,11 @@ interface IVideoWidgetProps {
10
10
  activeIndex?: number;
11
11
  videoPostConfig?: postConfigType;
12
12
  videoPlayIcon?: string;
13
+ loopPlay: any;
14
+ swiperRef?: any;
13
15
  }
14
- declare const _default: React.NamedExoticComponent<IVideoWidgetProps>;
16
+ export interface IVideoWidgetRef {
17
+ setLoopPlay: (v: boolean) => void;
18
+ }
19
+ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<IVideoWidgetProps & React.RefAttributes<IVideoWidgetRef>>>;
15
20
  export default _default;