pb-sxp-ui 1.0.42 → 1.0.43
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/LICENSE +21 -21
- package/README.md +111 -111
- package/dist/index.cjs +237 -600
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +4 -54
- package/dist/index.js +237 -599
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +3 -4
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +3 -4
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +241 -603
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +3 -4
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageCore/index.js +2 -2
- package/es/core/components/SxpPageRender/Nudge/index.js +5 -6
- package/es/core/components/SxpPageRender/VideoWidget/index.d.ts +1 -0
- package/es/core/components/SxpPageRender/VideoWidget/index.js +119 -88
- package/es/core/components/SxpPageRender/WaterFall/index.js +1 -1
- package/es/core/components/SxpPageRender/index.d.ts +0 -2
- package/es/core/components/SxpPageRender/index.js +63 -25
- package/es/core/context/SxpDataSourceProvider.d.ts +2 -3
- package/es/core/context/SxpDataSourceProvider.js +7 -28
- package/es/core/hooks/useEventReport.js +4 -4
- package/es/index.d.ts +0 -1
- package/es/index.js +0 -1
- package/es/materials/sxp/popup/CommodityDetail/index.js +10 -10
- package/es/materials/sxp/popup/CommodityDetailDiroNew/index.js +10 -10
- package/lib/core/components/SxpPageCore/index.js +2 -2
- package/lib/core/components/SxpPageRender/Nudge/index.js +5 -6
- package/lib/core/components/SxpPageRender/VideoWidget/index.d.ts +1 -0
- package/lib/core/components/SxpPageRender/VideoWidget/index.js +119 -88
- package/lib/core/components/SxpPageRender/WaterFall/index.js +1 -1
- package/lib/core/components/SxpPageRender/index.d.ts +0 -2
- package/lib/core/components/SxpPageRender/index.js +63 -25
- package/lib/core/context/SxpDataSourceProvider.d.ts +2 -3
- package/lib/core/context/SxpDataSourceProvider.js +7 -28
- package/lib/core/hooks/useEventReport.js +4 -4
- package/lib/index.d.ts +0 -1
- package/lib/index.js +1 -3
- package/lib/materials/sxp/popup/CommodityDetail/index.js +10 -10
- package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.js +10 -10
- package/package.json +114 -115
- package/es/core/components/DiyPortalPreview/PictureGroup.d.ts +0 -13
- package/es/core/components/DiyPortalPreview/PictureGroup.js +0 -11
- package/es/core/components/DiyPortalPreview/VideoWidget.d.ts +0 -15
- package/es/core/components/DiyPortalPreview/VideoWidget.js +0 -236
- package/es/core/components/DiyPortalPreview/index.d.ts +0 -6
- package/es/core/components/DiyPortalPreview/index.js +0 -127
- package/es/core/components/SxpPageRender/Tagbar.d.ts +0 -7
- package/es/core/components/SxpPageRender/Tagbar.js +0 -37
- package/lib/core/components/DiyPortalPreview/PictureGroup.d.ts +0 -13
- package/lib/core/components/DiyPortalPreview/PictureGroup.js +0 -14
- package/lib/core/components/DiyPortalPreview/VideoWidget.d.ts +0 -15
- package/lib/core/components/DiyPortalPreview/VideoWidget.js +0 -239
- package/lib/core/components/DiyPortalPreview/index.d.ts +0 -6
- package/lib/core/components/DiyPortalPreview/index.js +0 -130
- package/lib/core/components/SxpPageRender/Tagbar.d.ts +0 -7
- package/lib/core/components/SxpPageRender/Tagbar.js +0 -40
@@ -16,10 +16,10 @@ const SxpPageCore = ({ data, maxSize = 10, defaultSize = 10, hashTagSize = 20, l
|
|
16
16
|
return searchParams;
|
17
17
|
}, []);
|
18
18
|
return (React.createElement(EditorCore, { resolver: RESOLVER, enableDataSource: false, schema: data === null || data === void 0 ? void 0 : data.data, utmVal: utmVal },
|
19
|
-
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, render: ({ rtcList
|
19
|
+
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, render: ({ rtcList }) => {
|
20
20
|
var _a;
|
21
21
|
return (React.createElement(React.Fragment, null,
|
22
|
-
React.createElement(SxpPageRender, Object.assign({}, (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.sxpPageConf, {
|
22
|
+
React.createElement(SxpPageRender, Object.assign({}, (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.sxpPageConf, { data: rtcList, resolver: RESOLVER })),
|
23
23
|
React.createElement(Popup, null)));
|
24
24
|
} })));
|
25
25
|
};
|
@@ -1,14 +1,13 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
const Nudge = ({ nudge }) => {
|
3
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
4
3
|
return (React.createElement(React.Fragment, null, (nudge === null || nudge === void 0 ? void 0 : nudge.isOpen) && (React.createElement("div", { className: 'clc-sxp-bottom-nudge', style: {
|
5
|
-
marginBottom:
|
6
|
-
width:
|
7
|
-
height:
|
4
|
+
marginBottom: nudge === null || nudge === void 0 ? void 0 : nudge.marginBottom,
|
5
|
+
width: nudge === null || nudge === void 0 ? void 0 : nudge.size.width,
|
6
|
+
height: nudge === null || nudge === void 0 ? void 0 : nudge.size.height,
|
8
7
|
backgroundColor: nudge === null || nudge === void 0 ? void 0 : nudge.backgroundColor,
|
9
|
-
borderRadius:
|
8
|
+
borderRadius: nudge === null || nudge === void 0 ? void 0 : nudge.borderRadius
|
10
9
|
} },
|
11
10
|
(nudge === null || nudge === void 0 ? void 0 : nudge.icon) ? React.createElement("img", { src: nudge.icon, style: { height: '100%', objectFit: 'cover' } }) : null,
|
12
|
-
React.createElement("p", { style: Object.assign({}, nudge === null || nudge === void 0 ? void 0 : nudge.textStyle) },
|
11
|
+
React.createElement("p", { style: Object.assign({}, nudge === null || nudge === void 0 ? void 0 : nudge.textStyle) }, nudge === null || nudge === void 0 ? void 0 : nudge.content)))));
|
13
12
|
};
|
14
13
|
export default Nudge;
|
@@ -4,9 +4,8 @@ import { useIconLink } from '../useIconLink';
|
|
4
4
|
import FormatImage from '../FormatImage';
|
5
5
|
import { useSxpDataSource } from '../../../../core/hooks';
|
6
6
|
import SXP_EVENT_BUS, { SXP_EVENT_TYPE } from '../../../../core/utils/event';
|
7
|
-
const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig }) => {
|
7
|
+
const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoRef }) => {
|
8
8
|
const [isPauseVideo, setIsPauseVideo] = useState(false);
|
9
|
-
const videoRef = useRef(null);
|
10
9
|
const { bffEventReport, sxpParameter, waterFallData, openHashtag } = useSxpDataSource();
|
11
10
|
const videoStartTime = useRef(0);
|
12
11
|
const [isLoadFinish, setIsLoadFinish] = useState(false);
|
@@ -14,99 +13,118 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
14
13
|
const { isActive } = useSwiperSlide();
|
15
14
|
const canvasRef = useRef(null);
|
16
15
|
const [firstFrameSrc, setFirstFrameSrc] = useState('');
|
16
|
+
const videoId = `pb-cache-video-${index}`;
|
17
|
+
const videoEleRef = useRef(null);
|
17
18
|
useEffect(() => {
|
18
|
-
if (!videoRef
|
19
|
+
if (!videoRef)
|
19
20
|
return;
|
20
|
-
videoRef
|
21
|
-
}, [muted]);
|
22
|
-
const
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.muted(muted);
|
22
|
+
}, [muted, videoRef]);
|
23
|
+
const handleEnded = useCallback(() => {
|
24
|
+
if (!videoRef)
|
25
|
+
return;
|
26
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.play();
|
27
|
+
}, [videoRef]);
|
26
28
|
const PAUSE_ICON = useIconLink('/pb_static/06f28a2025c74c1cb49be6767316d827.png');
|
27
29
|
const handlePlaying = useCallback(() => {
|
28
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j
|
30
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
31
|
+
if (!videoRef)
|
32
|
+
return;
|
29
33
|
setIsPauseVideo(false);
|
30
34
|
const item = data[index];
|
31
|
-
if (item && (
|
32
|
-
videoStartTime.current = (
|
33
|
-
const videoDuration = ((
|
34
|
-
const videoCurrentTime = ((
|
35
|
+
if (item && (videoRef === null || videoRef === void 0 ? void 0 : videoRef.duration())) {
|
36
|
+
videoStartTime.current = (videoRef === null || videoRef === void 0 ? void 0 : videoRef.currentTime()) || 0;
|
37
|
+
const videoDuration = ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.duration()) !== null && _a !== void 0 ? _a : 0).toFixed(2);
|
38
|
+
const videoCurrentTime = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.currentTime()) !== null && _b !== void 0 ? _b : 0).toFixed(2);
|
35
39
|
const playType = isFirstPlay ? '0' : '1';
|
36
40
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
37
41
|
eventInfo: {
|
38
42
|
eventSubject: 'playVideo',
|
39
43
|
eventDescription: 'User played the video',
|
40
|
-
contentId: (
|
41
|
-
contentName: (
|
44
|
+
contentId: (_d = (_c = item.video) === null || _c === void 0 ? void 0 : _c.itemId) !== null && _d !== void 0 ? _d : '',
|
45
|
+
contentName: (_f = (_e = item.video) === null || _e === void 0 ? void 0 : _e.title) !== null && _f !== void 0 ? _f : '',
|
42
46
|
playType,
|
43
47
|
startTime: videoCurrentTime,
|
44
48
|
videoDuration,
|
45
|
-
contentTags: JSON.stringify((
|
49
|
+
contentTags: JSON.stringify((_h = (_g = item.video) === null || _g === void 0 ? void 0 : _g.tags) !== null && _h !== void 0 ? _h : []),
|
46
50
|
position: index + '',
|
47
51
|
contentFormat: 'video',
|
48
|
-
traceInfo: (
|
52
|
+
traceInfo: (_j = item.video) === null || _j === void 0 ? void 0 : _j.traceInfo
|
49
53
|
}
|
50
54
|
});
|
51
55
|
setIsFirstPlay(false);
|
52
56
|
}
|
53
|
-
}, [bffEventReport, data, index, isFirstPlay]);
|
54
|
-
const
|
57
|
+
}, [bffEventReport, data, index, isFirstPlay, videoRef]);
|
58
|
+
const handleLoadedmetadata = useCallback(() => {
|
59
|
+
if (!videoRef)
|
60
|
+
return;
|
61
|
+
if (activeIndex !== index) {
|
62
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.play();
|
63
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.pause();
|
64
|
+
}
|
65
|
+
setIsLoadFinish(true);
|
66
|
+
}, [activeIndex, index, videoRef]);
|
67
|
+
const handleCanplay = useCallback(() => {
|
55
68
|
setIsLoadFinish(true);
|
56
69
|
}, []);
|
57
70
|
const handleClickVideo = useCallback((type) => () => {
|
58
|
-
|
71
|
+
if (!videoRef)
|
72
|
+
return;
|
59
73
|
if (!isLoadFinish)
|
60
74
|
return;
|
61
|
-
const isPause =
|
75
|
+
const isPause = videoRef === null || videoRef === void 0 ? void 0 : videoRef.paused();
|
62
76
|
switch (type) {
|
63
77
|
case 'start':
|
64
78
|
if (!isPause)
|
65
79
|
return;
|
66
|
-
|
80
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.play();
|
67
81
|
setIsPauseVideo(false);
|
68
82
|
break;
|
69
83
|
case 'pause':
|
70
84
|
if (isPause)
|
71
85
|
return;
|
72
|
-
|
86
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.pause();
|
73
87
|
setIsPauseVideo(true);
|
74
88
|
break;
|
75
89
|
default:
|
76
90
|
if (isPause) {
|
77
|
-
|
91
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.play();
|
78
92
|
}
|
79
93
|
else {
|
80
|
-
|
94
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.pause();
|
81
95
|
}
|
82
96
|
setIsPauseVideo(!isPause);
|
83
97
|
break;
|
84
98
|
}
|
85
|
-
}, [isLoadFinish]);
|
86
|
-
const
|
87
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j
|
99
|
+
}, [isLoadFinish, videoRef]);
|
100
|
+
const handlePause = useCallback(() => {
|
101
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
102
|
+
if (!videoRef)
|
103
|
+
return;
|
104
|
+
if (activeIndex !== index)
|
105
|
+
return;
|
88
106
|
const item = data[index];
|
89
|
-
const videoDuration = ((
|
90
|
-
const videoCurrentTime = ((
|
91
|
-
if (
|
92
|
-
const playDuration = ((
|
107
|
+
const videoDuration = ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.duration()) !== null && _a !== void 0 ? _a : 0).toFixed(2);
|
108
|
+
const videoCurrentTime = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.currentTime()) !== null && _b !== void 0 ? _b : 0).toFixed(2);
|
109
|
+
if (videoRef === null || videoRef === void 0 ? void 0 : videoRef.duration()) {
|
110
|
+
const playDuration = ((videoRef === null || videoRef === void 0 ? void 0 : videoRef.currentTime()) - videoStartTime.current).toFixed(2);
|
93
111
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
94
112
|
eventInfo: {
|
95
113
|
eventSubject: 'playOverVideo',
|
96
114
|
eventDescription: 'User finished playing the video',
|
97
|
-
contentId: (
|
98
|
-
contentName: (
|
115
|
+
contentId: (_d = (_c = item.video) === null || _c === void 0 ? void 0 : _c.itemId) !== null && _d !== void 0 ? _d : '',
|
116
|
+
contentName: (_f = (_e = item.video) === null || _e === void 0 ? void 0 : _e.title) !== null && _f !== void 0 ? _f : '',
|
99
117
|
endTime: videoCurrentTime,
|
100
118
|
videoDuration,
|
101
119
|
playDuration,
|
102
|
-
contentTags: JSON.stringify((
|
120
|
+
contentTags: JSON.stringify((_h = (_g = item.video) === null || _g === void 0 ? void 0 : _g.tags) !== null && _h !== void 0 ? _h : []),
|
103
121
|
position: index + '',
|
104
122
|
contentFormat: 'video',
|
105
|
-
traceInfo: (
|
123
|
+
traceInfo: (_j = item.video) === null || _j === void 0 ? void 0 : _j.traceInfo
|
106
124
|
}
|
107
125
|
});
|
108
126
|
}
|
109
|
-
}, [data, index, bffEventReport]);
|
127
|
+
}, [data, index, bffEventReport, videoRef]);
|
110
128
|
const blur = useMemo(() => {
|
111
129
|
return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2';
|
112
130
|
}, [videoPostConfig]);
|
@@ -121,64 +139,79 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
121
139
|
return ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.cover) || firstFrameSrc;
|
122
140
|
}, [firstFrameSrc, rec]);
|
123
141
|
const handLoadeddata = useCallback(() => {
|
124
|
-
|
142
|
+
var _a;
|
143
|
+
if (!videoRef)
|
125
144
|
return;
|
126
|
-
const
|
127
|
-
|
128
|
-
|
129
|
-
const
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
145
|
+
const videoDomRef = document.getElementById(`${videoId}_html5_api`);
|
146
|
+
if (((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.cover) || !canvasRef || !videoDomRef || !canvasRef.current)
|
147
|
+
return;
|
148
|
+
const setFrameImg = () => {
|
149
|
+
const video = videoDomRef;
|
150
|
+
const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
|
151
|
+
const ctx = canvas.getContext('2d');
|
152
|
+
const targetWidth = window === null || window === void 0 ? void 0 : window.innerWidth;
|
153
|
+
const targetHeight = window === null || window === void 0 ? void 0 : window.innerHeight;
|
154
|
+
canvas.height = targetHeight;
|
155
|
+
canvas.width = targetWidth;
|
156
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
157
|
+
setFirstFrameSrc(canvas.toDataURL());
|
158
|
+
};
|
159
|
+
setFrameImg();
|
160
|
+
setTimeout(() => {
|
161
|
+
setFrameImg();
|
162
|
+
}, 500);
|
163
|
+
}, [videoRef]);
|
136
164
|
useEffect(() => {
|
137
|
-
|
138
|
-
|
165
|
+
if (!isActive || !videoRef)
|
166
|
+
return;
|
167
|
+
const videoSrc = rec.video.url;
|
168
|
+
if (!videoSrc)
|
139
169
|
return;
|
140
170
|
setIsPauseVideo(false);
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
171
|
+
const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
|
172
|
+
const dom = document.querySelector('#player-container-id');
|
173
|
+
const dom2 = document.querySelector('#player-container-id-copy');
|
174
|
+
if (!dom && !dom2)
|
175
|
+
return;
|
176
|
+
videoPlayerWrapperNode === null || videoPlayerWrapperNode === void 0 ? void 0 : videoPlayerWrapperNode.appendChild(dom || dom2);
|
177
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.src(videoSrc);
|
178
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('loadedmetadata', handleLoadedmetadata);
|
179
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('loadeddata', handLoadeddata);
|
180
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('canplay', handleCanplay);
|
181
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('playing', handlePlaying);
|
182
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('pause', handlePause);
|
183
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('ended', handleEnded);
|
151
184
|
return () => {
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
185
|
+
dom2 === null || dom2 === void 0 ? void 0 : dom2.appendChild(dom);
|
186
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.off('loadedmetadata', handleLoadedmetadata);
|
187
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.off('loadeddata', handLoadeddata);
|
188
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.off('canplay', handleCanplay);
|
189
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.off('playing', handlePlaying);
|
190
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.off('pause', handlePause);
|
191
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.off('ended', handleEnded);
|
157
192
|
};
|
158
|
-
}, [
|
193
|
+
}, [isActive, videoId, rec, videoRef]);
|
159
194
|
useEffect(() => {
|
160
|
-
|
161
|
-
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
|
195
|
+
if (!videoRef || !isLoadFinish)
|
162
196
|
return;
|
163
197
|
if (isActive) {
|
164
|
-
videoRef.
|
198
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.play();
|
165
199
|
}
|
166
200
|
else {
|
167
|
-
|
201
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.pause();
|
168
202
|
}
|
169
|
-
}, [isActive, isLoadFinish]);
|
203
|
+
}, [isActive, isLoadFinish, videoRef]);
|
170
204
|
useEffect(() => {
|
171
|
-
|
172
|
-
if (!isActive || !(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
205
|
+
if (!isActive || !videoRef)
|
173
206
|
return;
|
174
|
-
const isPause =
|
207
|
+
const isPause = videoRef === null || videoRef === void 0 ? void 0 : videoRef.paused();
|
175
208
|
if (!isPause && openHashtag) {
|
176
|
-
|
209
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.pause();
|
177
210
|
}
|
178
211
|
else if (!openHashtag) {
|
179
|
-
|
212
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.play();
|
180
213
|
}
|
181
|
-
}, [openHashtag, isActive]);
|
214
|
+
}, [openHashtag, isActive, videoRef]);
|
182
215
|
useEffect(() => {
|
183
216
|
if (!isActive)
|
184
217
|
return;
|
@@ -198,9 +231,11 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
198
231
|
return (React.createElement("img", { style: { position: 'absolute', left: 0, top: 0, width: '100%', height: '100%', objectFit: 'cover' }, src: sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image }));
|
199
232
|
}, [isLoadFinish, sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image]);
|
200
233
|
useEffect(() => {
|
234
|
+
if (!videoRef)
|
235
|
+
return;
|
201
236
|
const handleBeforeUnload = () => {
|
202
|
-
var _a
|
203
|
-
if (activeIndex === index && ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.url) &&
|
237
|
+
var _a;
|
238
|
+
if (activeIndex === index && ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.url) && videoRef && !isPauseVideo) {
|
204
239
|
handleClickVideo('pause')();
|
205
240
|
}
|
206
241
|
};
|
@@ -238,19 +273,15 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
238
273
|
right: 0
|
239
274
|
} },
|
240
275
|
React.createElement("div", { style: { position: 'relative', width: '100%', height: '100%' } },
|
241
|
-
React.createElement("
|
242
|
-
width: '100%',
|
243
|
-
height: '100%',
|
244
|
-
objectFit: 'contain'
|
245
|
-
} }),
|
276
|
+
React.createElement("div", { className: 'n-full-screen', ref: videoEleRef, id: videoId, style: { width: '100%', height: '100%' } }),
|
246
277
|
React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON }))),
|
247
|
-
renderPoster)) : (React.createElement("div", { className: 'video-container', key: rec.video.itemId,
|
278
|
+
renderPoster)) : (React.createElement("div", { className: 'video-container', key: rec.video.itemId, style: {
|
248
279
|
position: 'relative',
|
249
280
|
width: '100%',
|
250
281
|
height,
|
251
282
|
overflow: 'hidden'
|
252
|
-
} },
|
253
|
-
React.createElement("
|
283
|
+
}, onClick: handleClickVideo() },
|
284
|
+
React.createElement("div", { className: 'n-full-screen', ref: videoEleRef, id: videoId, style: { width: '100%', height: '100%' } }),
|
254
285
|
renderPoster,
|
255
286
|
React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON })))));
|
256
287
|
};
|
@@ -63,7 +63,7 @@ const WaterFall = (props) => {
|
|
63
63
|
}
|
64
64
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
65
65
|
eventInfo: {
|
66
|
-
|
66
|
+
relatedContentId: (_d = rec === null || rec === void 0 ? void 0 : rec.video) === null || _d === void 0 ? void 0 : _d.itemId,
|
67
67
|
position: cacheActiveIndex + '',
|
68
68
|
contentTags: JSON.stringify((_e = rec === null || rec === void 0 ? void 0 : rec.video) === null || _e === void 0 ? void 0 : _e.tags),
|
69
69
|
traceInfo: (_f = rec === null || rec === void 0 ? void 0 : rec.video) === null || _f === void 0 ? void 0 : _f.traceInfo,
|
@@ -9,7 +9,6 @@ export type postConfigType = {
|
|
9
9
|
export interface ISxpPageRenderProps {
|
10
10
|
globalConfig?: {
|
11
11
|
isShowLogo?: boolean;
|
12
|
-
isShowCTA?: boolean;
|
13
12
|
logoUrl?: string;
|
14
13
|
muteIcon?: string;
|
15
14
|
unMuteIcon?: string;
|
@@ -56,7 +55,6 @@ export interface ISxpPageRenderProps {
|
|
56
55
|
containerWidth?: number;
|
57
56
|
tempMap?: Record<string, any>;
|
58
57
|
data?: RecItemType[];
|
59
|
-
tagList?: string[];
|
60
58
|
resolver: any;
|
61
59
|
ctaType?: string;
|
62
60
|
_schema?: any;
|
@@ -21,8 +21,7 @@ import './index.less';
|
|
21
21
|
import { useEventReport } from '../../../core/hooks/useEventReport';
|
22
22
|
import withBindDataSource from '../../../core/hoc/withBindDataSource';
|
23
23
|
import { getFeUserId } from '../../../core/utils/localStore';
|
24
|
-
|
25
|
-
const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.innerHeight, containerWidth = window.innerWidth, tempMap, resolver, data = [], ctaType, tipText, nudge, _schema, hashTagStyle, tagList = [] }) => {
|
24
|
+
const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.innerHeight, containerWidth = window.innerWidth, tempMap, resolver, data = [], ctaType, tipText, nudge, _schema, hashTagStyle }) => {
|
26
25
|
var _a, _b, _c, _d, _e, _f, _g;
|
27
26
|
const { schema } = useEditor();
|
28
27
|
const [activeIndex, setActiveIndex] = useState(0);
|
@@ -34,6 +33,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
34
33
|
const [isLoadMore, setIsLoadMore] = useState(false);
|
35
34
|
const [isShowMore, setIsShowMore] = useState(false);
|
36
35
|
const { loadVideos, bffEventReport, loading, setPopupDetailData, ctaEvent, swiperRef, waterFallData, setOpenHashtag, appDomain, openHashtag, loadingImage, isFromHashtag, popupDetailData } = useSxpDataSource();
|
36
|
+
const [videoRef, setVideoRef] = useState(null);
|
37
|
+
const playerRef = useRef();
|
37
38
|
const { productView } = useEventReport();
|
38
39
|
const isShowFingerTip = useMemo(() => {
|
39
40
|
return data.length > 0 && !loading && getFeUserId();
|
@@ -69,6 +70,25 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
69
70
|
viewTime.current = new Date();
|
70
71
|
refreshFeSessionId();
|
71
72
|
};
|
73
|
+
const firstRef = useRef();
|
74
|
+
useEffect(() => {
|
75
|
+
if (!firstRef.current && !videoRef) {
|
76
|
+
firstRef.current = true;
|
77
|
+
const player = TCPlayer('player-container-id', {
|
78
|
+
licenseUrl: 'https://license.vod2.myqcloud.com/license/v2/1325816236_1/v_cube.license',
|
79
|
+
controls: false,
|
80
|
+
autoplay: false,
|
81
|
+
loop: false,
|
82
|
+
muted: true,
|
83
|
+
preload: 'auto',
|
84
|
+
posterImage: false,
|
85
|
+
bigPlayButton: true
|
86
|
+
});
|
87
|
+
player === null || player === void 0 ? void 0 : player.ready(() => {
|
88
|
+
setVideoRef(player);
|
89
|
+
});
|
90
|
+
}
|
91
|
+
}, [videoRef]);
|
72
92
|
useEffect(() => {
|
73
93
|
if (!isInit)
|
74
94
|
handleH5EnterLink();
|
@@ -121,12 +141,12 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
121
141
|
sessionDuration: Math.floor((new Date() - curTime.current) / 1000) + '',
|
122
142
|
eventSubject: 'sessionCompleted',
|
123
143
|
eventDescription: 'Session completed',
|
124
|
-
|
125
|
-
|
144
|
+
relatedContentId: (_l = item === null || item === void 0 ? void 0 : item.video) === null || _l === void 0 ? void 0 : _l.itemId,
|
145
|
+
relatedProductId: (_m = item === null || item === void 0 ? void 0 : item.product) === null || _m === void 0 ? void 0 : _m.itemId,
|
126
146
|
position: activeIndex + '',
|
127
147
|
fromKName,
|
128
148
|
fromKPage: location === null || location === void 0 ? void 0 : location.href,
|
129
|
-
|
149
|
+
relatedCtatId: (_q = (_p = (_o = item.video) === null || _o === void 0 ? void 0 : _o.bindCta) === null || _p === void 0 ? void 0 : _p.itemId) !== null && _q !== void 0 ? _q : ''
|
130
150
|
}
|
131
151
|
});
|
132
152
|
}
|
@@ -142,15 +162,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
142
162
|
};
|
143
163
|
}, [activeIndex, bffEventReport, curTime, data, handleH5EnterLink, popupDetailData, isFromHashtag, tempMap]);
|
144
164
|
const height = useMemo(() => {
|
145
|
-
|
146
|
-
|
147
|
-
minusHeight += 45;
|
148
|
-
}
|
149
|
-
if (tagList.length > 0) {
|
150
|
-
minusHeight += 45;
|
151
|
-
}
|
152
|
-
return containerHeight - minusHeight;
|
153
|
-
}, [globalConfig, containerHeight, tagList]);
|
165
|
+
return (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo) ? containerHeight - 45 : containerHeight;
|
166
|
+
}, [globalConfig, containerHeight]);
|
154
167
|
const renderLogo = useMemo(() => {
|
155
168
|
if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
|
156
169
|
return (React.createElement("div", { className: 'clc-sxp-logo-banner', style: { backgroundColor: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.color } },
|
@@ -161,7 +174,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
161
174
|
const renderContent = useCallback((rec, index) => {
|
162
175
|
var _a, _b, _c, _d;
|
163
176
|
if ((_a = rec.video) === null || _a === void 0 ? void 0 : _a.url) {
|
164
|
-
return (React.createElement(VideoWidget, { rec: rec, index: index, muted: isMuted, data: data, height: height, activeIndex: activeIndex, videoPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPost }));
|
177
|
+
return (React.createElement(VideoWidget, { rec: rec, index: index, muted: isMuted, data: data, height: height, activeIndex: activeIndex, videoPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPost, videoRef: videoRef }));
|
165
178
|
}
|
166
179
|
if ((_b = rec.video) === null || _b === void 0 ? void 0 : _b.imgUrls) {
|
167
180
|
return (React.createElement(PictureGroup, { key: rec.video.itemId, imgUrls: rec.video.imgUrls, width: containerWidth, height: height, rec: rec, index: index, onReportViewImageEnd: handleReportViewImageEnd, onViewImageStartEvent: handleViewImageStartEvent, imgUrlsPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.imgUrlsPost }));
|
@@ -176,7 +189,19 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
176
189
|
});
|
177
190
|
}
|
178
191
|
return null;
|
179
|
-
}, [
|
192
|
+
}, [
|
193
|
+
containerWidth,
|
194
|
+
data,
|
195
|
+
height,
|
196
|
+
isMuted,
|
197
|
+
activeIndex,
|
198
|
+
globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost,
|
199
|
+
viewTime,
|
200
|
+
tipText,
|
201
|
+
resolver,
|
202
|
+
schema,
|
203
|
+
videoRef
|
204
|
+
]);
|
180
205
|
const onExpandableChange = useCallback((v) => {
|
181
206
|
setIsShowMore(v);
|
182
207
|
}, []);
|
@@ -198,8 +223,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
198
223
|
((_a = rec.video) === null || _a === void 0 ? void 0 : _a.title) && !isShowMore && React.createElement("div", { className: 'clc-sxp-bottom-shadow' }),
|
199
224
|
React.createElement("div", { className: 'clc-sxp-bottom' },
|
200
225
|
React.createElement(Nudge, { nudge: nudge }),
|
201
|
-
|
202
|
-
React.createElement(RenderCard, { rec: rec, index: index, tempMap: tempMap, resolver: resolver }))
|
226
|
+
React.createElement("div", { className: 'clc-sxp-bottom-card' },
|
227
|
+
React.createElement(RenderCard, { rec: rec, index: index, tempMap: tempMap, resolver: resolver })),
|
203
228
|
React.createElement("div", null,
|
204
229
|
React.createElement(ExpandableText, { className: 'clc-sxp-bottom-text', isPost: true, foldText: tipText === null || tipText === void 0 ? void 0 : tipText.foldText, unfoldText: tipText === null || tipText === void 0 ? void 0 : tipText.unfoldText, text: (_c = (_b = rec.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' }), onChange: onExpandableChange }),
|
205
230
|
React.createElement(Hashtag, { index: activeIndex, 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.video) === null || _g === void 0 ? void 0 : _g.itemId) ? 'VIDEO' : null, rec: rec, hashTagStyle: hashTagStyle })))));
|
@@ -266,8 +291,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
266
291
|
eventInfo: {
|
267
292
|
eventSubject: 'scrollDown',
|
268
293
|
eventDescription: 'User scroll down',
|
269
|
-
|
270
|
-
|
294
|
+
relatedContentId: (_b = (_a = item.video) === null || _a === void 0 ? void 0 : _a.itemId) !== null && _b !== void 0 ? _b : '',
|
295
|
+
relatedProductId: (_d = (_c = item.product) === null || _c === void 0 ? void 0 : _c.itemId) !== null && _d !== void 0 ? _d : '',
|
271
296
|
requestId: null
|
272
297
|
}
|
273
298
|
});
|
@@ -278,8 +303,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
278
303
|
eventInfo: {
|
279
304
|
eventSubject: 'scrollUp',
|
280
305
|
eventDescription: 'User scroll up',
|
281
|
-
|
282
|
-
|
306
|
+
relatedContentId: (_f = (_e = item.video) === null || _e === void 0 ? void 0 : _e.itemId) !== null && _f !== void 0 ? _f : '',
|
307
|
+
relatedProductId: (_h = (_g = item.product) === null || _g === void 0 ? void 0 : _g.itemId) !== null && _h !== void 0 ? _h : '',
|
283
308
|
requestId: null
|
284
309
|
}
|
285
310
|
});
|
@@ -356,9 +381,13 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
356
381
|
setOpenHashtag === null || setOpenHashtag === void 0 ? void 0 : setOpenHashtag(true);
|
357
382
|
} })),
|
358
383
|
renderLogo,
|
359
|
-
React.createElement(Tagbar, { tagList: tagList, setActiveIndex: setActiveIndex }),
|
360
384
|
isShowFingerTip ? React.createElement(FingerSwipeTip, { imageUrl: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.swipeTipIcon }) : null,
|
361
|
-
React.createElement(Swiper, { ref: swiperRef,
|
385
|
+
React.createElement(Swiper, { ref: swiperRef, onSlideChange: () => {
|
386
|
+
swiperRef.current.swiper.allowTouchMove = false;
|
387
|
+
setTimeout(() => {
|
388
|
+
swiperRef.current.swiper.allowTouchMove = true;
|
389
|
+
}, 500);
|
390
|
+
}, onActiveIndexChange: (swiper) => {
|
362
391
|
setActiveIndex(swiper.activeIndex);
|
363
392
|
if (openHashtag)
|
364
393
|
return;
|
@@ -382,6 +411,15 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
382
411
|
zIndex: 999
|
383
412
|
}, defaultValue: isMuted, 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, onChange: setIsMuted }),
|
384
413
|
renderView),
|
385
|
-
React.createElement(WaterFall, Object.assign({}, (_g = (_f = (_e = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.hashTag) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.item) === null || _g === void 0 ? void 0 : _g.props))
|
414
|
+
React.createElement(WaterFall, Object.assign({}, (_g = (_f = (_e = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.hashTag) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.item) === null || _g === void 0 ? void 0 : _g.props)),
|
415
|
+
React.createElement("div", { style: { position: 'absolute', zIndex: -100 } },
|
416
|
+
React.createElement("video", { ref: playerRef, id: 'player-container-id', playsInline: true, crossOrigin: 'anonymous', style: {
|
417
|
+
backgroundColor: 'transparent',
|
418
|
+
width: '100%',
|
419
|
+
height: '100%',
|
420
|
+
objectFit: 'cover',
|
421
|
+
pointerEvents: 'none'
|
422
|
+
} }),
|
423
|
+
React.createElement("div", { id: 'player-container-id-copy' }))));
|
386
424
|
};
|
387
425
|
export default SxpPageRender;
|
@@ -60,15 +60,14 @@ export interface ISxpDataSourceContext {
|
|
60
60
|
hashTagSize?: number;
|
61
61
|
loadingImage?: string;
|
62
62
|
isOpenHashTag?: boolean;
|
63
|
-
|
64
|
-
|
63
|
+
videoRef?: any;
|
64
|
+
setVideoRef?: React.Dispatch<React.SetStateAction<any>>;
|
65
65
|
}
|
66
66
|
export declare const SxpDataSourceContext: React.Context<ISxpDataSourceContext>;
|
67
67
|
export interface SxpDataSourceProviderProps {
|
68
68
|
dataSources?: DataSource[];
|
69
69
|
render: (data: {
|
70
70
|
rtcList: RecItemType[];
|
71
|
-
tagList: string[];
|
72
71
|
submitForm: (body: {
|
73
72
|
attributes: Array<{
|
74
73
|
name: string;
|