pb-sxp-ui 1.15.12-alpha.8 → 1.15.13-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +348 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +346 -46
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +6 -6
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +6 -6
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +348 -47
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +6 -6
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/DiyStoryPreview/PictureGroup.d.ts +16 -0
- package/es/core/components/DiyStoryPreview/PictureGroup.js +34 -0
- package/es/core/components/DiyStoryPreview/VideoWidget.d.ts +17 -0
- package/es/core/components/DiyStoryPreview/VideoWidget.js +193 -0
- package/es/core/components/DiyStoryPreview/index.d.ts +26 -0
- package/es/core/components/DiyStoryPreview/index.js +118 -0
- package/es/core/context/SxpDataSourceProvider.js +5 -17
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/lib/core/components/DiyStoryPreview/PictureGroup.d.ts +16 -0
- package/lib/core/components/DiyStoryPreview/PictureGroup.js +37 -0
- package/lib/core/components/DiyStoryPreview/VideoWidget.d.ts +17 -0
- package/lib/core/components/DiyStoryPreview/VideoWidget.js +196 -0
- package/lib/core/components/DiyStoryPreview/index.d.ts +26 -0
- package/lib/core/components/DiyStoryPreview/index.js +121 -0
- package/lib/core/context/SxpDataSourceProvider.js +5 -17
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/package.json +1 -1
@@ -0,0 +1,196 @@
|
|
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 hooks_1 = require("../../../core/hooks");
|
9
|
+
const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width, swiperRef, loopPlay }) => {
|
10
|
+
const { isActive } = (0, react_2.useSwiperSlide)();
|
11
|
+
const [isPauseVideo, setIsPauseVideo] = (0, react_1.useState)(false);
|
12
|
+
const videoRef = (0, react_1.useRef)(null);
|
13
|
+
const { bffEventReport, sxpParameter, waterFallData, openHashtag } = (0, hooks_1.useSxpDataSource)();
|
14
|
+
const videoStartTime = (0, react_1.useRef)(0);
|
15
|
+
const [isLoadFinish, setIsLoadFinish] = (0, react_1.useState)(false);
|
16
|
+
const [isFirstPlay, setIsFirstPlay] = (0, react_1.useState)(true);
|
17
|
+
const canvasRef = (0, react_1.useRef)(null);
|
18
|
+
const [firstFrameSrc, setFirstFrameSrc] = (0, react_1.useState)('');
|
19
|
+
const videoId = `pb-cache-video-${index}`;
|
20
|
+
const hlsRef = (0, react_1.useRef)(null);
|
21
|
+
(0, react_1.useEffect)(() => {
|
22
|
+
if (!videoRef.current)
|
23
|
+
return;
|
24
|
+
videoRef.current.muted = muted;
|
25
|
+
}, [muted]);
|
26
|
+
const handleVideoStart = (0, react_1.useCallback)(() => {
|
27
|
+
var _a;
|
28
|
+
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
29
|
+
}, []);
|
30
|
+
const PAUSE_ICON = (0, useIconLink_1.useIconLink)('/pb_static/06f28a2025c74c1cb49be6767316d827.png');
|
31
|
+
const handlePlaying = (0, react_1.useCallback)(() => {
|
32
|
+
var _a, _b, _c, _d, _e, _f;
|
33
|
+
setIsPauseVideo(false);
|
34
|
+
const item = data[index];
|
35
|
+
if (item && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration)) {
|
36
|
+
videoStartTime.current = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.currentTime) || 0;
|
37
|
+
const videoDuration = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 0).toFixed(2);
|
38
|
+
const videoCurrentTime = ((_f = (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime) !== null && _f !== void 0 ? _f : 0).toFixed(2);
|
39
|
+
const playType = isFirstPlay ? '0' : '1';
|
40
|
+
setIsFirstPlay(false);
|
41
|
+
}
|
42
|
+
}, [bffEventReport, data, index, isFirstPlay]);
|
43
|
+
const handleLoadedMetadata = (0, react_1.useCallback)(() => {
|
44
|
+
var _a;
|
45
|
+
(_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
46
|
+
setIsLoadFinish(true);
|
47
|
+
}, []);
|
48
|
+
const handleClickVideo = (0, react_1.useCallback)((type) => () => {
|
49
|
+
var _a, _b, _c, _d, _e;
|
50
|
+
if (!isLoadFinish)
|
51
|
+
return;
|
52
|
+
const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
|
53
|
+
switch (type) {
|
54
|
+
case 'start':
|
55
|
+
if (!isPause)
|
56
|
+
return;
|
57
|
+
(_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.play();
|
58
|
+
setIsPauseVideo(false);
|
59
|
+
break;
|
60
|
+
case 'pause':
|
61
|
+
if (isPause)
|
62
|
+
return;
|
63
|
+
(_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
|
64
|
+
setIsPauseVideo(true);
|
65
|
+
break;
|
66
|
+
default:
|
67
|
+
if (isPause) {
|
68
|
+
(_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.play();
|
69
|
+
}
|
70
|
+
else {
|
71
|
+
(_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.pause();
|
72
|
+
}
|
73
|
+
setIsPauseVideo(!isPause);
|
74
|
+
break;
|
75
|
+
}
|
76
|
+
}, [isLoadFinish]);
|
77
|
+
const onPause = (0, react_1.useCallback)(() => {
|
78
|
+
var _a, _b, _c, _d, _e, _f;
|
79
|
+
const item = data[index];
|
80
|
+
const videoDuration = ((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.duration) !== null && _b !== void 0 ? _b : 0).toFixed(2);
|
81
|
+
const videoCurrentTime = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.currentTime) !== null && _d !== void 0 ? _d : 0).toFixed(2);
|
82
|
+
if ((_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.duration) {
|
83
|
+
const playDuration = (((_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.currentTime) - videoStartTime.current).toFixed(2);
|
84
|
+
}
|
85
|
+
}, [data, index, bffEventReport]);
|
86
|
+
const blur = (0, react_1.useMemo)(() => {
|
87
|
+
return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2';
|
88
|
+
}, [videoPostConfig]);
|
89
|
+
const translateY = (0, react_1.useMemo)(() => {
|
90
|
+
var _a;
|
91
|
+
return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2'
|
92
|
+
? `translateY(-${50 + ((_a = videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.offsetTop) !== null && _a !== void 0 ? _a : 0)}%) translate3d(0px, 0px, 0px)`
|
93
|
+
: 'translateY(-50%)';
|
94
|
+
}, [videoPostConfig]);
|
95
|
+
const handLoadeddata = (0, react_1.useCallback)(() => {
|
96
|
+
if (!canvasRef || !videoRef || !videoRef.current || !canvasRef.current)
|
97
|
+
return;
|
98
|
+
const video = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current;
|
99
|
+
const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
|
100
|
+
const ctx = canvas.getContext('2d');
|
101
|
+
const targetWidth = window === null || window === void 0 ? void 0 : window.innerWidth;
|
102
|
+
const targetHeight = window === null || window === void 0 ? void 0 : window.innerHeight;
|
103
|
+
canvas.height = targetHeight;
|
104
|
+
canvas.width = targetWidth;
|
105
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
106
|
+
setFirstFrameSrc(canvas.toDataURL());
|
107
|
+
}, []);
|
108
|
+
const handleTimeUpload = (0, react_1.useCallback)(() => {
|
109
|
+
var _a, _b, _c;
|
110
|
+
if (!videoRef.current)
|
111
|
+
return;
|
112
|
+
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)) {
|
113
|
+
(_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
|
114
|
+
}
|
115
|
+
}, []);
|
116
|
+
const handlePause = () => {
|
117
|
+
var _a, _b, _c, _d, _e, _f;
|
118
|
+
if (!loopPlay)
|
119
|
+
return;
|
120
|
+
if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
|
121
|
+
(_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);
|
122
|
+
}
|
123
|
+
else {
|
124
|
+
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;
|
125
|
+
(_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);
|
126
|
+
}
|
127
|
+
};
|
128
|
+
(0, react_1.useEffect)(() => {
|
129
|
+
var _a, _b, _c;
|
130
|
+
if (!isActive)
|
131
|
+
return;
|
132
|
+
const videoSrc = rec === null || rec === void 0 ? void 0 : rec.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
|
+
videoRef.current.currentTime = rec === null || rec === void 0 ? void 0 : rec.startTime;
|
141
|
+
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
142
|
+
return;
|
143
|
+
const Hls = window === null || window === void 0 ? void 0 : window.Hls;
|
144
|
+
let hls = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current;
|
145
|
+
if (videoSrc.includes('.m3u8') && Hls && Hls.isSupported()) {
|
146
|
+
hls = new Hls();
|
147
|
+
hls === null || hls === void 0 ? void 0 : hls.loadSource(videoSrc);
|
148
|
+
hls === null || hls === void 0 ? void 0 : hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
|
149
|
+
hls === null || hls === void 0 ? void 0 : hls.on(Hls.Events.MANIFEST_PARSED, function () {
|
150
|
+
var _a;
|
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.current) === null || _c === void 0 ? void 0 : _c.addEventListener('timeupdate', handleTimeUpload);
|
160
|
+
return () => {
|
161
|
+
var _a, _b, _c, _d;
|
162
|
+
if (hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current)
|
163
|
+
(_a = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
|
164
|
+
setIsLoadFinish(false);
|
165
|
+
(_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('loadedmetadata', handleLoadedMetadata);
|
166
|
+
(_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('pause', handlePause);
|
167
|
+
(_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.removeEventListener('timeupdate', handleTimeUpload);
|
168
|
+
};
|
169
|
+
}, [handleLoadedMetadata, handlePlaying, rec, handLoadeddata, isActive]);
|
170
|
+
const renderPoster = (0, react_1.useMemo)(() => {
|
171
|
+
if (!(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image) || isLoadFinish) {
|
172
|
+
return null;
|
173
|
+
}
|
174
|
+
return (react_1.default.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' }));
|
175
|
+
}, [isLoadFinish, sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image]);
|
176
|
+
const blurStyle = (0, react_1.useMemo)(() => {
|
177
|
+
return blur
|
178
|
+
? {
|
179
|
+
filter: 'blur(10px)',
|
180
|
+
transform: 'translate3d(0px, 0px, 0px) scale(1.2)'
|
181
|
+
}
|
182
|
+
: {};
|
183
|
+
}, [blur]);
|
184
|
+
if (!(rec === null || rec === void 0 ? void 0 : rec.mediaUrl)) {
|
185
|
+
return null;
|
186
|
+
}
|
187
|
+
return (react_1.default.createElement("div", { className: 'video-container', key: rec.itemId, style: {
|
188
|
+
position: 'relative',
|
189
|
+
width: '100%',
|
190
|
+
height,
|
191
|
+
overflow: 'hidden',
|
192
|
+
pointerEvents: 'none'
|
193
|
+
} },
|
194
|
+
react_1.default.createElement("div", { className: 'n-full-screen', id: videoId, style: { width: '100%', height: '100%' } })));
|
195
|
+
};
|
196
|
+
exports.default = (0, react_1.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,121 @@
|
|
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 Nudge_1 = tslib_1.__importDefault(require("../SxpPageRender/Nudge"));
|
7
|
+
const RenderCard_1 = tslib_1.__importDefault(require("../SxpPageRender/RenderCard"));
|
8
|
+
const ExpandableText_1 = tslib_1.__importDefault(require("../SxpPageRender/ExpandableText"));
|
9
|
+
const Hashtag_1 = tslib_1.__importDefault(require("../SxpPageRender/Hashtag"));
|
10
|
+
const LikeButton_1 = tslib_1.__importDefault(require("../SxpPageRender/LikeButton"));
|
11
|
+
const useIconLink_1 = require("../SxpPageRender/useIconLink");
|
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
|
+
const RESOLVER = {};
|
16
|
+
Object.values(_materials_).forEach((v) => {
|
17
|
+
RESOLVER[v.extend.type] = v;
|
18
|
+
});
|
19
|
+
const defaultUnLikeIconPath = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
|
20
|
+
const defaultLikeIconPath = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
|
21
|
+
const DiyStoryPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, descStyle, hashTagStyle, containerHeight = 664, containerWidth = 375, appDomain, tagList = [], scenes, onActiveChange, activeIndex, loopPlay = false }) => {
|
22
|
+
const swiperRef = (0, react_1.useRef)(null);
|
23
|
+
const height = (0, react_1.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
|
+
const isVideoUrl = (url) => {
|
34
|
+
if (url && url !== '' && typeof url === 'string') {
|
35
|
+
const imageExtensions = ['.mp4', '.m3u8'];
|
36
|
+
const lowerCaseUrl = url === null || url === void 0 ? void 0 : url.toLowerCase();
|
37
|
+
return imageExtensions.some((ext) => lowerCaseUrl === null || lowerCaseUrl === void 0 ? void 0 : lowerCaseUrl.endsWith(ext));
|
38
|
+
}
|
39
|
+
else {
|
40
|
+
return false;
|
41
|
+
}
|
42
|
+
};
|
43
|
+
const renderContent = (rec, index) => {
|
44
|
+
const isVideo = isVideoUrl(rec === null || rec === void 0 ? void 0 : rec.mediaUrl);
|
45
|
+
if (isVideo) {
|
46
|
+
return (react_1.default.createElement(VideoWidget_1.default, { 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 }));
|
47
|
+
}
|
48
|
+
else {
|
49
|
+
return (react_1.default.createElement(PictureGroup_1.default, { 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 }));
|
50
|
+
}
|
51
|
+
};
|
52
|
+
const renderLogo = (0, react_1.useMemo)(() => {
|
53
|
+
if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
|
54
|
+
return (react_1.default.createElement("div", { className: 'clc-sxp-logo-banner', style: { backgroundColor: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.color } },
|
55
|
+
react_1.default.createElement("img", { src: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl, alt: 'logo' })));
|
56
|
+
}
|
57
|
+
return null;
|
58
|
+
}, [globalConfig]);
|
59
|
+
const CTA = (rec, index) => {
|
60
|
+
if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA) === undefined || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA)) {
|
61
|
+
return (react_1.default.createElement("div", { className: 'clc-sxp-bottom-card' },
|
62
|
+
react_1.default.createElement(RenderCard_1.default, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER })));
|
63
|
+
}
|
64
|
+
return null;
|
65
|
+
};
|
66
|
+
const renderBottom = (rec, index) => {
|
67
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
68
|
+
if (rec === null || rec === void 0 ? void 0 : rec.video) {
|
69
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
70
|
+
((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.title) && react_1.default.createElement("div", { className: 'clc-sxp-bottom-shadow' }),
|
71
|
+
react_1.default.createElement("div", { className: 'clc-sxp-bottom' },
|
72
|
+
react_1.default.createElement(Nudge_1.default, { nudge: nudge }),
|
73
|
+
CTA(rec, index),
|
74
|
+
react_1.default.createElement("div", null,
|
75
|
+
react_1.default.createElement(ExpandableText_1.default, { 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' }) })),
|
76
|
+
react_1.default.createElement(Hashtag_1.default, { 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 }))));
|
77
|
+
}
|
78
|
+
return null;
|
79
|
+
};
|
80
|
+
const likeIcon = (0, useIconLink_1.useIconLink)(defaultLikeIconPath, appDomain);
|
81
|
+
const unlikeIcon = (0, useIconLink_1.useIconLink)(defaultUnLikeIconPath, appDomain);
|
82
|
+
const renderLikeButton = (rec, index) => {
|
83
|
+
var _a, _b, _c, _d;
|
84
|
+
if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLike))
|
85
|
+
return;
|
86
|
+
let top = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconY) !== null && _a !== void 0 ? _a : 400;
|
87
|
+
if (top < 40) {
|
88
|
+
top += 40;
|
89
|
+
}
|
90
|
+
if (rec === null || rec === void 0 ? void 0 : rec.video) {
|
91
|
+
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, className: 'clc-sxp-like-button', style: {
|
92
|
+
top,
|
93
|
+
right: (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconX) !== null && _d !== void 0 ? _d : 0
|
94
|
+
} }));
|
95
|
+
}
|
96
|
+
return null;
|
97
|
+
};
|
98
|
+
const mutedIcon = (0, useIconLink_1.useIconLink)('/pb_static/5beaaa5ce7f3477b99db3838619cc471.png', appDomain);
|
99
|
+
const unmutedIcon = (0, useIconLink_1.useIconLink)('/pb_static/fea8668a8a894e4aa3a86bcc775e895e.png', appDomain);
|
100
|
+
const renderView = (rec, index) => {
|
101
|
+
return (react_1.default.createElement(react_2.SwiperSlide, { key: index, virtualIndex: index, style: { overflow: 'hidden', position: 'relative' } }, renderContent(rec, index)));
|
102
|
+
};
|
103
|
+
(0, react_1.useEffect)(() => {
|
104
|
+
var _a, _b;
|
105
|
+
if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
|
106
|
+
return;
|
107
|
+
(_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);
|
108
|
+
}, [activeIndex]);
|
109
|
+
(0, react_1.useEffect)(() => {
|
110
|
+
var _a, _b;
|
111
|
+
if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
|
112
|
+
return;
|
113
|
+
(_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);
|
114
|
+
}, [loopPlay]);
|
115
|
+
return (react_1.default.createElement(react_2.Swiper, { ref: swiperRef, allowTouchMove: false, onActiveIndexChange: (swiper) => {
|
116
|
+
onActiveChange === null || onActiveChange === void 0 ? void 0 : onActiveChange(swiper.activeIndex);
|
117
|
+
}, direction: 'vertical', style: { overflow: 'hidden', height: containerHeight } }, scenes === null || scenes === void 0 ? void 0 : scenes.map((rec, index) => {
|
118
|
+
return renderView(rec, index);
|
119
|
+
})));
|
120
|
+
};
|
121
|
+
exports.default = (0, react_1.memo)(DiyStoryPreview);
|
@@ -117,12 +117,8 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
117
117
|
}
|
118
118
|
if (options.type === 'beacon' && navigator.sendBeacon) {
|
119
119
|
return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
|
120
|
-
JSON.stringify({
|
121
|
-
|
122
|
-
})
|
123
|
-
], {
|
124
|
-
type: 'application/json;charset=UTF-8'
|
125
|
-
}));
|
120
|
+
JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))
|
121
|
+
], { type: 'application/json;charset=UTF-8' }));
|
126
122
|
}
|
127
123
|
return window
|
128
124
|
.fetch(`${url}/api/${path}`, {
|
@@ -276,7 +272,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
276
272
|
console.log('userInfo:', userInfo);
|
277
273
|
console.log('eventInfo:', ef);
|
278
274
|
console.log('========= 结束 =========');
|
279
|
-
return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/
|
275
|
+
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}`, {
|
280
276
|
method: 'POST',
|
281
277
|
body: { userInfo: realUserInfo, eventInfo: realEventInfo },
|
282
278
|
type: 'beacon'
|
@@ -292,7 +288,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
292
288
|
bffDataSource
|
293
289
|
]);
|
294
290
|
const bffFbReport = (0, react_1.useCallback)(({ eventName, product }) => {
|
295
|
-
var _a, _b, _c, _d, _e, _f
|
291
|
+
var _a, _b, _c, _d, _e, _f;
|
296
292
|
if (!enableReportEvent ||
|
297
293
|
!enabledMetaConversionApi ||
|
298
294
|
(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) ||
|
@@ -356,15 +352,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
356
352
|
}
|
357
353
|
};
|
358
354
|
getEventParams(jsonParams);
|
359
|
-
|
360
|
-
const queryString = location.search.slice(1);
|
361
|
-
(_f = (0, tool_1.splitUrlParams)(queryString)) === null || _f === void 0 ? void 0 : _f.map((val) => {
|
362
|
-
const key = val.split('=')[0];
|
363
|
-
const value = val.split('=')[1];
|
364
|
-
params[key] = value;
|
365
|
-
});
|
366
|
-
const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
|
367
|
-
return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/fb/${(_g = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _g === void 0 ? void 0 : _g['x-app-id']}/${eventName}${cl_source ? `/${decodeURIComponent(cl_source)}` : ''}`, {
|
355
|
+
return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/event/report/FB/${(_f = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _f === void 0 ? void 0 : _f['x-app-id']}/${eventName}`, {
|
368
356
|
method: 'POST',
|
369
357
|
body: jsonParams,
|
370
358
|
type: 'beacon'
|
package/lib/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/lib/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.useEditorDataProvider = exports.EditorDataProvider = exports.SxpPageCore = exports.SxpDataSourceProvider = exports.Modal = exports.DiyPortalPreview = exports.SxpPageRender = exports.materials = exports.core = void 0;
|
3
|
+
exports.useEditorDataProvider = exports.EditorDataProvider = exports.SxpPageCore = exports.SxpDataSourceProvider = exports.Modal = exports.DiyStoryPreview = exports.DiyPortalPreview = exports.SxpPageRender = exports.materials = exports.core = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const Pagebuilder_1 = require("./core/Pagebuilder");
|
6
6
|
require("./index.css");
|
@@ -10,6 +10,8 @@ var SxpPageRender_1 = require("./core/components/SxpPageRender");
|
|
10
10
|
Object.defineProperty(exports, "SxpPageRender", { enumerable: true, get: function () { return tslib_1.__importDefault(SxpPageRender_1).default; } });
|
11
11
|
var DiyPortalPreview_1 = require("./core/components/DiyPortalPreview");
|
12
12
|
Object.defineProperty(exports, "DiyPortalPreview", { enumerable: true, get: function () { return tslib_1.__importDefault(DiyPortalPreview_1).default; } });
|
13
|
+
var DiyStoryPreview_1 = require("./core/components/DiyStoryPreview");
|
14
|
+
Object.defineProperty(exports, "DiyStoryPreview", { enumerable: true, get: function () { return tslib_1.__importDefault(DiyStoryPreview_1).default; } });
|
13
15
|
var Modal_1 = require("./core/components/SxpPageRender/Modal");
|
14
16
|
Object.defineProperty(exports, "Modal", { enumerable: true, get: function () { return tslib_1.__importDefault(Modal_1).default; } });
|
15
17
|
var SxpDataSourceProvider_1 = require("./core/context/SxpDataSourceProvider");
|