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
@@ -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,200 @@
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 react_2 = require("swiper/react");
6
+ const useIconLink_1 = require("../SxpPageRender/useIconLink");
7
+ const VideoPlayer_1 = require("../SxpPageRender/VideoWidget/VideoPlayer");
8
+ const FormatImage_1 = tslib_1.__importDefault(require("../SxpPageRender/FormatImage"));
9
+ const hooks_1 = require("../../../core/hooks");
10
+ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted, activeIndex, videoPostConfig, width, swiperRef, videoPlayIcon, onUpdateTimeLine, loopPlay, onPlay, onPause }, ref) => {
11
+ const { isActive } = (0, react_2.useSwiperSlide)();
12
+ const [isPauseVideo, setIsPauseVideo] = (0, react_1.useState)(false);
13
+ const videoRef = (0, react_1.useRef)(null);
14
+ const { bffEventReport, sxpParameter, waterFallData, openHashtag } = (0, hooks_1.useSxpDataSource)();
15
+ const videoStartTime = (0, react_1.useRef)(0);
16
+ const [isLoadFinish, setIsLoadFinish] = (0, react_1.useState)(false);
17
+ const [isFirstPlay, setIsFirstPlay] = (0, react_1.useState)(true);
18
+ const canvasRef = (0, react_1.useRef)(null);
19
+ const [firstFrameSrc, setFirstFrameSrc] = (0, react_1.useState)('');
20
+ const videoId = `pb-cache-video-${index}`;
21
+ const hlsRef = (0, react_1.useRef)(null);
22
+ const loopPlayRef = (0, react_1.useRef)(loopPlay);
23
+ const scene = rec.video.scene;
24
+ (0, react_1.useEffect)(() => {
25
+ loopPlayRef.current = loopPlay;
26
+ }, [loopPlay]);
27
+ (0, react_1.useImperativeHandle)(ref, () => {
28
+ return {
29
+ play() {
30
+ var _a;
31
+ if (!videoRef.current)
32
+ return;
33
+ handleTimeUpload();
34
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
35
+ setIsPauseVideo(false);
36
+ },
37
+ pause() {
38
+ var _a;
39
+ if (!videoRef.current)
40
+ return;
41
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.pause();
42
+ setIsPauseVideo(true);
43
+ },
44
+ setLoopPlay(v) {
45
+ loopPlayRef.current = v;
46
+ },
47
+ isPlaying() {
48
+ var _a;
49
+ return !((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.paused);
50
+ }
51
+ };
52
+ });
53
+ (0, react_1.useEffect)(() => {
54
+ if (!videoRef.current)
55
+ return;
56
+ videoRef.current.muted = muted;
57
+ }, [muted]);
58
+ const PAUSE_ICON = (0, useIconLink_1.useIconLink)('/pb_static/06f28a2025c74c1cb49be6767316d827.png');
59
+ const handleLoadedMetadata = (0, react_1.useCallback)(() => {
60
+ var _a;
61
+ videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
62
+ (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
63
+ setIsLoadFinish(true);
64
+ }, []);
65
+ const handleClickVideo = (0, react_1.useCallback)((type) => () => {
66
+ var _a, _b, _c, _d, _e, _f;
67
+ if (!isActive || !(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
68
+ return;
69
+ const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
70
+ switch (type) {
71
+ case 'start':
72
+ if (!isPause)
73
+ return;
74
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.play();
75
+ setIsPauseVideo(false);
76
+ break;
77
+ case 'pause':
78
+ if (isPause)
79
+ return;
80
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
81
+ setIsPauseVideo(true);
82
+ break;
83
+ default:
84
+ if (isPause) {
85
+ 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)) {
86
+ videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
87
+ }
88
+ (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.play();
89
+ }
90
+ else {
91
+ (_f = videoRef.current) === null || _f === void 0 ? void 0 : _f.pause();
92
+ }
93
+ setIsPauseVideo(!isPause);
94
+ break;
95
+ }
96
+ }, [isLoadFinish]);
97
+ const blur = (0, react_1.useMemo)(() => {
98
+ return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2';
99
+ }, [videoPostConfig]);
100
+ const handleTimeUpload = () => {
101
+ if (!videoRef.current)
102
+ return;
103
+ setTimeout(() => {
104
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
105
+ 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)) {
106
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
107
+ if (!loopPlayRef.current)
108
+ return;
109
+ if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
110
+ (_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);
111
+ }
112
+ else {
113
+ 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;
114
+ (_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);
115
+ }
116
+ }
117
+ });
118
+ };
119
+ const handlePause = () => {
120
+ setIsPauseVideo(true);
121
+ onPause === null || onPause === void 0 ? void 0 : onPause();
122
+ };
123
+ const handlePlay = () => {
124
+ var _a;
125
+ 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);
126
+ onPlay === null || onPlay === void 0 ? void 0 : onPlay(index, localTime);
127
+ };
128
+ (0, react_1.useEffect)(() => {
129
+ var _a, _b, _c, _d;
130
+ if (!isActive)
131
+ return;
132
+ const videoSrc = scene === null || scene === void 0 ? void 0 : scene.mediaUrl;
133
+ if (!videoSrc)
134
+ return;
135
+ setIsPauseVideo(false);
136
+ const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
137
+ if (!videoPlayerWrapperNode)
138
+ return;
139
+ videoRef.current = VideoPlayer_1.mountVideoPlayerAtNode === null || VideoPlayer_1.mountVideoPlayerAtNode === void 0 ? void 0 : (0, VideoPlayer_1.mountVideoPlayerAtNode)(videoPlayerWrapperNode);
140
+ if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
141
+ return;
142
+ const Hls = window === null || window === void 0 ? void 0 : window.Hls;
143
+ let hls = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current;
144
+ if (videoSrc.includes('.m3u8') && Hls && Hls.isSupported()) {
145
+ hls = new Hls();
146
+ hls === null || hls === void 0 ? void 0 : hls.loadSource(videoSrc);
147
+ hls === null || hls === void 0 ? void 0 : hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
148
+ hls === null || hls === void 0 ? void 0 : hls.on(Hls.Events.MANIFEST_PARSED, function () {
149
+ var _a;
150
+ videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
151
+ (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
152
+ });
153
+ }
154
+ else {
155
+ videoRef.current.src = videoSrc;
156
+ }
157
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('loadedmetadata', handleLoadedMetadata);
158
+ (_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('pause', handlePause);
159
+ (_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.addEventListener('play', handlePlay);
160
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('timeupdate', handleTimeUpload);
161
+ return () => {
162
+ var _a, _b, _c, _d, _e;
163
+ if (hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current)
164
+ (_a = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
165
+ setIsLoadFinish(false);
166
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('loadedmetadata', handleLoadedMetadata);
167
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('pause', handlePause);
168
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.removeEventListener('play', handlePlay);
169
+ (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.removeEventListener('timeupdate', handleTimeUpload);
170
+ };
171
+ }, [isActive]);
172
+ const renderPoster = (0, react_1.useMemo)(() => {
173
+ var _a;
174
+ if (!(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image) || isLoadFinish) {
175
+ return null;
176
+ }
177
+ return (react_1.default.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' }));
178
+ }, [isLoadFinish, sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image]);
179
+ const blurStyle = (0, react_1.useMemo)(() => {
180
+ return blur
181
+ ? {
182
+ filter: 'blur(10px)',
183
+ transform: 'translate3d(0px, 0px, 0px) scale(1.2)'
184
+ }
185
+ : {};
186
+ }, [blur]);
187
+ if (!(scene === null || scene === void 0 ? void 0 : scene.mediaUrl)) {
188
+ return null;
189
+ }
190
+ return (react_1.default.createElement("div", { className: 'video-container', key: scene.itemId, style: {
191
+ position: 'relative',
192
+ width: '100%',
193
+ height,
194
+ overflow: 'hidden'
195
+ }, onClick: handleClickVideo() },
196
+ react_1.default.createElement("div", { className: 'n-full-screen', id: videoId, style: { width: '100%', height: '100%' } }),
197
+ renderPoster,
198
+ isPauseVideo && react_1.default.createElement(FormatImage_1.default, { className: 'clc-pb-video-pause', src: videoPlayIcon !== null && videoPlayIcon !== void 0 ? videoPlayIcon : PAUSE_ICON, alt: 'pause' })));
199
+ });
200
+ exports.default = (0, react_1.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,235 @@
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 react_2 = require("swiper/react");
6
+ const lodash_1 = require("lodash");
7
+ const RenderCard_1 = tslib_1.__importDefault(require("../SxpPageRender/RenderCard"));
8
+ const ExpandableText_1 = tslib_1.__importDefault(require("../SxpPageRender/ExpandableText"));
9
+ const LikeButton_1 = tslib_1.__importDefault(require("../SxpPageRender/LikeButton"));
10
+ const useIconLink_1 = require("../SxpPageRender/useIconLink");
11
+ const ToggleButton_1 = tslib_1.__importDefault(require("../SxpPageRender/ToggleButton"));
12
+ const PictureGroup_1 = tslib_1.__importDefault(require("./PictureGroup"));
13
+ const VideoWidget_1 = tslib_1.__importDefault(require("./VideoWidget"));
14
+ const _materials_ = tslib_1.__importStar(require("../../../materials"));
15
+ require("../SxpPageRender/index.less");
16
+ const RESOLVER = {};
17
+ Object.values(_materials_).forEach((v) => {
18
+ RESOLVER[v.extend.type] = v;
19
+ });
20
+ const defaultUnLikeIconPath = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
21
+ const defaultLikeIconPath = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
22
+ const DiyStoryPreview = (0, react_1.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) => {
23
+ const videoWidgetRef = (0, react_1.useRef)(null);
24
+ const swiperRef = (0, react_1.useRef)(null);
25
+ const [curIndex, setCurIndex] = (0, react_1.useState)(0);
26
+ const height = (0, react_1.useMemo)(() => {
27
+ let minusHeight = 0;
28
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
29
+ minusHeight += 45;
30
+ }
31
+ if (tagList.length > 0) {
32
+ minusHeight += 45;
33
+ }
34
+ return containerHeight - minusHeight;
35
+ }, [globalConfig, containerHeight, tagList]);
36
+ (0, react_1.useImperativeHandle)(ref, () => {
37
+ return {
38
+ play() {
39
+ var _a;
40
+ (_a = videoWidgetRef === null || videoWidgetRef === void 0 ? void 0 : videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.play();
41
+ },
42
+ pause() {
43
+ var _a;
44
+ (_a = videoWidgetRef === null || videoWidgetRef === void 0 ? void 0 : videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.pause();
45
+ },
46
+ slideTo(n) {
47
+ var _a, _b;
48
+ if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
49
+ return;
50
+ (_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);
51
+ },
52
+ isPlaying() {
53
+ var _a, _b;
54
+ 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;
55
+ }
56
+ };
57
+ });
58
+ const isVideoUrl = (url) => {
59
+ if (url && url !== '' && typeof url === 'string') {
60
+ const imageExtensions = ['.mp4', '.m3u8'];
61
+ const lowerCaseUrl = url === null || url === void 0 ? void 0 : url.toLowerCase();
62
+ return imageExtensions.some((ext) => lowerCaseUrl === null || lowerCaseUrl === void 0 ? void 0 : lowerCaseUrl.endsWith(ext));
63
+ }
64
+ else {
65
+ return false;
66
+ }
67
+ };
68
+ const renderContent = (rec, index) => {
69
+ var _a, _b;
70
+ const scene = (_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.scene;
71
+ const isVideo = isVideoUrl(scene === null || scene === void 0 ? void 0 : scene.mediaUrl);
72
+ if (isVideo) {
73
+ return (react_1.default.createElement(VideoWidget_1.default, 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 })));
74
+ }
75
+ else {
76
+ return (react_1.default.createElement(PictureGroup_1.default, { 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 }));
77
+ }
78
+ };
79
+ const renderLogo = (0, react_1.useMemo)(() => {
80
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
81
+ return (react_1.default.createElement("div", { className: 'clc-sxp-logo-banner', style: { backgroundColor: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.color } },
82
+ react_1.default.createElement("img", { src: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl, alt: 'logo' })));
83
+ }
84
+ return null;
85
+ }, [globalConfig]);
86
+ const renderBottom = (rec, index) => {
87
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
88
+ if (rec === null || rec === void 0 ? void 0 : rec.video) {
89
+ let cta = null;
90
+ 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) {
91
+ cta = '多商品CTA';
92
+ }
93
+ else if ((_c = rec === null || rec === void 0 ? void 0 : rec.video) === null || _c === void 0 ? void 0 : _c.bindProduct) {
94
+ cta = '商品CTA';
95
+ }
96
+ else {
97
+ 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;
98
+ }
99
+ const value = tempMap === null || tempMap === void 0 ? void 0 : tempMap[cta];
100
+ return (react_1.default.createElement(react_1.default.Fragment, null,
101
+ ((_f = rec === null || rec === void 0 ? void 0 : rec.video) === null || _f === void 0 ? void 0 : _f.title) && (react_1.default.createElement("div", { style: {
102
+ background: 'repeating-linear-gradient(0deg, rgba(26, 26, 25, 0.7), hsla(0, 0%, 100%, 0))',
103
+ height: '130px',
104
+ position: 'absolute',
105
+ bottom: 0,
106
+ width: '100%',
107
+ willChange: 'transform',
108
+ zIndex: 2,
109
+ pointerEvents
110
+ } })),
111
+ react_1.default.createElement("div", { style: {
112
+ marginBottom: `${(_g = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.bottomInfoDist) !== null && _g !== void 0 ? _g : 40}px`,
113
+ zIndex: 999,
114
+ position: 'absolute',
115
+ bottom: 0,
116
+ left: 0,
117
+ right: 0,
118
+ paddingTop: '20px'
119
+ } },
120
+ (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA) === undefined || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA) ? (react_1.default.createElement("div", { style: {} },
121
+ react_1.default.createElement(RenderCard_1.default, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER, isActive: index === activeIndex, value: value }))) : null,
122
+ react_1.default.createElement("div", null,
123
+ react_1.default.createElement(ExpandableText_1.default, { 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' }) }),
124
+ react_1.default.createElement(RenderCard_1.default, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER, includesCtaType: ['AniLink'], isActive: index === activeIndex, value: value }))),
125
+ react_1.default.createElement(RenderCard_1.default, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER, includesCtaType: ['AniLinkPopup'], isActive: index === activeIndex, value: value })));
126
+ }
127
+ return null;
128
+ };
129
+ const likeIcon = (0, useIconLink_1.useIconLink)(defaultLikeIconPath, appDomain);
130
+ const unlikeIcon = (0, useIconLink_1.useIconLink)(defaultUnLikeIconPath, appDomain);
131
+ const renderLikeButton = (rec, index) => {
132
+ var _a, _b, _c, _d;
133
+ if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLike))
134
+ return null;
135
+ let top = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconY) !== null && _a !== void 0 ? _a : 400;
136
+ if (top < 40) {
137
+ top += 40;
138
+ }
139
+ if (rec === null || rec === void 0 ? void 0 : rec.video) {
140
+ return (react_1.default.createElement(LikeButton_1.default, { 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: {
141
+ top,
142
+ right: (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconX) !== null && _d !== void 0 ? _d : 0,
143
+ position: 'absolute',
144
+ zIndex: 999,
145
+ backgroundColor: 'transparent',
146
+ width: '50px',
147
+ height: '50px',
148
+ outline: 'none',
149
+ border: 'none',
150
+ boxSizing: 'content-box',
151
+ padding: 0,
152
+ transform: 'translate3d(0px, 0px, 0px)'
153
+ } }));
154
+ }
155
+ return null;
156
+ };
157
+ const mutedIcon = (0, useIconLink_1.useIconLink)('/pb_static/5beaaa5ce7f3477b99db3838619cc471.png', appDomain);
158
+ const unmutedIcon = (0, useIconLink_1.useIconLink)('/pb_static/fea8668a8a894e4aa3a86bcc775e895e.png', appDomain);
159
+ const renderToggleButton = (visible) => {
160
+ var _a, _b, _c, _d;
161
+ if (!visible)
162
+ return null;
163
+ let top = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconY) !== null && _a !== void 0 ? _a : 23;
164
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconYPosit) === 'top') {
165
+ top += 45;
166
+ }
167
+ return (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowMute) === undefined || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowMute) === true ? (react_1.default.createElement(ToggleButton_1.default, { style: {
168
+ position: 'absolute',
169
+ visibility: 'visible',
170
+ zIndex: 999,
171
+ transform: 'translate3d(0px,0px,0px)',
172
+ [(_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,
173
+ [(_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconYPosit) !== null && _d !== void 0 ? _d : 'bottom']: top,
174
+ backgroundColor: 'transparent',
175
+ width: '50px',
176
+ height: '50px',
177
+ outline: 'none',
178
+ border: 'none',
179
+ boxSizing: 'content-box',
180
+ padding: 0
181
+ }, 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;
182
+ };
183
+ const renderView = (item, index) => {
184
+ var _a, _b, _c, _d;
185
+ return (react_1.default.createElement("div", { style: { position: 'relative' } },
186
+ react_1.default.createElement(react_2.SwiperSlide, { key: index, virtualIndex: index, style: { overflow: 'hidden', position: 'relative' } },
187
+ renderBottom(item, index),
188
+ renderLikeButton(item, index),
189
+ renderToggleButton(!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconFixed)),
190
+ react_1.default.createElement(ToggleButton_1.default, { style: {
191
+ position: 'absolute',
192
+ right: (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconX) !== null && _a !== void 0 ? _a : 0,
193
+ 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',
194
+ bottom: (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconY) !== null && _d !== void 0 ? _d : 23,
195
+ zIndex: 999
196
+ }, 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 }),
197
+ renderContent(item, index))));
198
+ };
199
+ (0, react_1.useEffect)(() => {
200
+ var _a, _b;
201
+ if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
202
+ return;
203
+ (_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);
204
+ }, [activeIndex]);
205
+ const handleSessionExpire = (0, react_1.useCallback)((0, lodash_1.debounce)(() => {
206
+ var _a;
207
+ (_a = videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.setLoopPlay(false);
208
+ }, 1000), []);
209
+ (0, react_1.useEffect)(() => {
210
+ if (disabledListener)
211
+ return;
212
+ const events = ['touchstart', 'touchcancel'];
213
+ events.forEach((event) => {
214
+ window.addEventListener(event, handleSessionExpire);
215
+ });
216
+ return () => {
217
+ events.forEach((event) => {
218
+ window.removeEventListener(event, handleSessionExpire);
219
+ });
220
+ };
221
+ }, [handleSessionExpire, disabledListener]);
222
+ return (react_1.default.createElement("div", { id: 'sxp-render', style: { height: containerHeight, position: 'relative', pointerEvents } },
223
+ react_1.default.createElement(react_2.Swiper, { ref: swiperRef, allowTouchMove: pointerEvents !== 'none', onSlideChange: () => {
224
+ swiperRef.current.swiper.allowTouchMove = false;
225
+ setTimeout(() => {
226
+ swiperRef.current.swiper.allowTouchMove = true;
227
+ }, 500);
228
+ }, onActiveIndexChange: (swiper) => {
229
+ setCurIndex(swiper === null || swiper === void 0 ? void 0 : swiper.activeIndex);
230
+ onActiveChange === null || onActiveChange === void 0 ? void 0 : onActiveChange(swiper.activeIndex);
231
+ }, direction: 'vertical', style: { overflow: 'hidden', height: containerHeight }, height: containerHeight }, data === null || data === void 0 ? void 0 : data.map((rec, index) => {
232
+ return renderView(rec, index);
233
+ }))));
234
+ });
235
+ exports.default = (0, react_1.memo)(DiyStoryPreview);
@@ -12,7 +12,8 @@ Object.values(_materials_).forEach((v) => {
12
12
  RESOLVER[v.extend.type] = v;
13
13
  });
14
14
  const SxpPageCore = ({ data, maxSize = 10, defaultSize = 10, hashTagSize = 20, loadingImage, appDomain, enabledMetaConversionApi, dataList }) => {
15
- var _a, _b, _c, _d, _e, _f;
15
+ var _a, _b, _c, _d, _e, _f, _g;
16
+ const isDiyH5 = ((_a = data === null || data === void 0 ? void 0 : data.page_type) === null || _a === void 0 ? void 0 : _a.path_type) === 5;
16
17
  const utmVal = (0, react_1.useMemo)(() => {
17
18
  var _a;
18
19
  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('?', '') : '';
@@ -21,7 +22,7 @@ const SxpPageCore = ({ data, maxSize = 10, defaultSize = 10, hashTagSize = 20, l
21
22
  const [_schema, setSchema] = (0, react_1.useState)(data === null || data === void 0 ? void 0 : data.data);
22
23
  const [channel, setChannel] = (0, react_1.useState)();
23
24
  return (react_1.default.createElement(core_1.EditorCore, { resolver: RESOLVER, enableDataSource: false, schema: _schema, utmVal: channel || utmVal },
24
- react_1.default.createElement(SxpDataSourceProvider_1.default, { 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 }) => {
25
+ react_1.default.createElement(SxpDataSourceProvider_1.default, { 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 }) => {
25
26
  var _a;
26
27
  return (react_1.default.createElement(react_1.default.Fragment, null,
27
28
  react_1.default.createElement(SxpPageRender_1.default, 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;