pb-sxp-ui 1.15.15-alpha.1 → 1.15.16-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/index.cjs +135 -824
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +134 -822
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.min.cjs +6 -6
  6. package/dist/index.min.cjs.map +1 -1
  7. package/dist/index.min.js +6 -6
  8. package/dist/index.min.js.map +1 -1
  9. package/dist/pb-ui.js +135 -824
  10. package/dist/pb-ui.js.map +1 -1
  11. package/dist/pb-ui.min.js +6 -6
  12. package/dist/pb-ui.min.js.map +1 -1
  13. package/es/core/components/SxpPageCore/index.d.ts +0 -1
  14. package/es/core/components/SxpPageCore/index.js +7 -7
  15. package/es/core/components/SxpPageRender/ExpandableText.js +2 -10
  16. package/es/core/components/SxpPageRender/RenderCard.js +4 -4
  17. package/es/core/context/EditorContext.js +1 -1
  18. package/es/core/context/SxpDataSourceProvider.d.ts +1 -1
  19. package/es/core/context/SxpDataSourceProvider.js +47 -28
  20. package/es/index.d.ts +0 -1
  21. package/es/index.js +0 -1
  22. package/es/materials/sxp/template/MultiCommodity/index.js +1 -1
  23. package/es/materials/sxp/template/MultiCommodityDiro/index.js +1 -2
  24. package/es/materials/sxp/template/MultiCommodityDiroNew/index.js +1 -2
  25. package/es/materials/sxp/template/components/EventProvider.js +2 -2
  26. package/lib/core/components/SxpPageCore/index.d.ts +0 -1
  27. package/lib/core/components/SxpPageCore/index.js +7 -7
  28. package/lib/core/components/SxpPageRender/ExpandableText.js +2 -10
  29. package/lib/core/components/SxpPageRender/RenderCard.js +4 -4
  30. package/lib/core/context/EditorContext.js +1 -1
  31. package/lib/core/context/SxpDataSourceProvider.d.ts +1 -1
  32. package/lib/core/context/SxpDataSourceProvider.js +47 -28
  33. package/lib/index.d.ts +0 -1
  34. package/lib/index.js +1 -3
  35. package/lib/materials/sxp/template/MultiCommodity/index.js +1 -1
  36. package/lib/materials/sxp/template/MultiCommodityDiro/index.js +1 -2
  37. package/lib/materials/sxp/template/MultiCommodityDiroNew/index.js +1 -2
  38. package/lib/materials/sxp/template/components/EventProvider.js +2 -2
  39. package/package.json +1 -1
  40. package/es/core/components/DiyStoryPreview/PictureGroup.d.ts +0 -16
  41. package/es/core/components/DiyStoryPreview/PictureGroup.js +0 -34
  42. package/es/core/components/DiyStoryPreview/VideoWidget.d.ts +0 -27
  43. package/es/core/components/DiyStoryPreview/VideoWidget.js +0 -239
  44. package/es/core/components/DiyStoryPreview/index.d.ts +0 -51
  45. package/es/core/components/DiyStoryPreview/index.js +0 -411
  46. package/lib/core/components/DiyStoryPreview/PictureGroup.d.ts +0 -16
  47. package/lib/core/components/DiyStoryPreview/PictureGroup.js +0 -37
  48. package/lib/core/components/DiyStoryPreview/VideoWidget.d.ts +0 -27
  49. package/lib/core/components/DiyStoryPreview/VideoWidget.js +0 -242
  50. package/lib/core/components/DiyStoryPreview/index.d.ts +0 -51
  51. package/lib/core/components/DiyStoryPreview/index.js +0 -414
@@ -1,242 +0,0 @@
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
- (0, react_1.useEffect)(() => {
24
- loopPlayRef.current = loopPlay;
25
- }, [loopPlay]);
26
- (0, react_1.useImperativeHandle)(ref, () => {
27
- return {
28
- play() {
29
- var _a;
30
- if (!videoRef.current)
31
- return;
32
- handleTimeUpload();
33
- (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
34
- setIsPauseVideo(false);
35
- },
36
- pause() {
37
- var _a;
38
- if (!videoRef.current)
39
- return;
40
- (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.pause();
41
- setIsPauseVideo(true);
42
- },
43
- setLoopPlay(v) {
44
- if (!videoRef.current)
45
- return;
46
- loopPlayRef.current = v;
47
- },
48
- isPlaying() {
49
- var _a;
50
- return !((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.paused);
51
- }
52
- };
53
- });
54
- (0, react_1.useEffect)(() => {
55
- if (!videoRef.current)
56
- return;
57
- videoRef.current.muted = muted;
58
- }, [muted]);
59
- const handleVideoStart = (0, react_1.useCallback)(() => {
60
- var _a;
61
- (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
62
- }, []);
63
- const PAUSE_ICON = (0, useIconLink_1.useIconLink)('/pb_static/06f28a2025c74c1cb49be6767316d827.png');
64
- const handlePlaying = (0, react_1.useCallback)(() => {
65
- var _a, _b, _c, _d, _e, _f;
66
- setIsPauseVideo(false);
67
- const item = data[index];
68
- if (item && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration)) {
69
- videoStartTime.current = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.currentTime) || 0;
70
- const videoDuration = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 0).toFixed(2);
71
- const videoCurrentTime = ((_f = (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime) !== null && _f !== void 0 ? _f : 0).toFixed(2);
72
- const playType = isFirstPlay ? '0' : '1';
73
- setIsFirstPlay(false);
74
- }
75
- }, [bffEventReport, data, index, isFirstPlay]);
76
- const handleLoadedMetadata = (0, react_1.useCallback)(() => {
77
- var _a;
78
- videoRef.current.currentTime = rec === null || rec === void 0 ? void 0 : rec.startTime;
79
- (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
80
- setIsLoadFinish(true);
81
- }, []);
82
- const handleClickVideo = (0, react_1.useCallback)((type) => () => {
83
- var _a, _b, _c, _d, _e, _f;
84
- if (!isActive || !(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
85
- return;
86
- const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
87
- switch (type) {
88
- case 'start':
89
- if (!isPause)
90
- return;
91
- (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.play();
92
- setIsPauseVideo(false);
93
- break;
94
- case 'pause':
95
- if (isPause)
96
- return;
97
- (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
98
- setIsPauseVideo(true);
99
- break;
100
- default:
101
- if (isPause) {
102
- if (((_d = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _d === void 0 ? void 0 : _d.currentTime) >= (rec === null || rec === void 0 ? void 0 : rec.endTime)) {
103
- videoRef.current.currentTime = rec === null || rec === void 0 ? void 0 : rec.startTime;
104
- }
105
- (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.play();
106
- }
107
- else {
108
- (_f = videoRef.current) === null || _f === void 0 ? void 0 : _f.pause();
109
- }
110
- setIsPauseVideo(!isPause);
111
- break;
112
- }
113
- }, [isLoadFinish]);
114
- const blur = (0, react_1.useMemo)(() => {
115
- return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2';
116
- }, [videoPostConfig]);
117
- const translateY = (0, react_1.useMemo)(() => {
118
- var _a;
119
- return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2'
120
- ? `translateY(-${50 + ((_a = videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.offsetTop) !== null && _a !== void 0 ? _a : 0)}%) translate3d(0px, 0px, 0px)`
121
- : 'translateY(-50%)';
122
- }, [videoPostConfig]);
123
- const handLoadeddata = (0, react_1.useCallback)(() => {
124
- if (!canvasRef || !videoRef || !videoRef.current || !canvasRef.current)
125
- return;
126
- const video = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current;
127
- const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
128
- const ctx = canvas.getContext('2d');
129
- const targetWidth = window === null || window === void 0 ? void 0 : window.innerWidth;
130
- const targetHeight = window === null || window === void 0 ? void 0 : window.innerHeight;
131
- canvas.height = targetHeight;
132
- canvas.width = targetWidth;
133
- ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
134
- setFirstFrameSrc(canvas.toDataURL());
135
- }, []);
136
- const handleTimeUpload = (0, react_1.useCallback)(() => {
137
- var _a;
138
- if (!videoRef.current)
139
- return;
140
- const localTime = ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.currentTime) - (rec === null || rec === void 0 ? void 0 : rec.startTime);
141
- onUpdateTimeLine === null || onUpdateTimeLine === void 0 ? void 0 : onUpdateTimeLine(index, localTime);
142
- setTimeout(() => {
143
- var _a, _b;
144
- 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)) {
145
- slideSwiper();
146
- }
147
- });
148
- }, []);
149
- const slideSwiper = () => {
150
- var _a, _b, _c, _d, _e, _f, _g;
151
- (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.pause();
152
- if (!loopPlayRef.current)
153
- return;
154
- if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
155
- (_c = (_b = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _b === void 0 ? void 0 : _b.swiper) === null || _c === void 0 ? void 0 : _c.slideTo(0);
156
- }
157
- else {
158
- const i = (_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.activeIndex;
159
- (_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.slideTo(i + 1);
160
- }
161
- };
162
- const handlePause = () => {
163
- setIsPauseVideo(true);
164
- onPause === null || onPause === void 0 ? void 0 : onPause();
165
- };
166
- const handlePlay = () => {
167
- var _a;
168
- const localTime = ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.currentTime) - (rec === null || rec === void 0 ? void 0 : rec.startTime);
169
- onPlay === null || onPlay === void 0 ? void 0 : onPlay(index, localTime);
170
- };
171
- (0, react_1.useEffect)(() => {
172
- var _a, _b, _c, _d;
173
- if (!isActive)
174
- return;
175
- const videoSrc = rec === null || rec === void 0 ? void 0 : rec.mediaUrl;
176
- if (!videoSrc)
177
- return;
178
- setIsPauseVideo(false);
179
- const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
180
- if (!videoPlayerWrapperNode)
181
- return;
182
- videoRef.current = VideoPlayer_1.mountVideoPlayerAtNode === null || VideoPlayer_1.mountVideoPlayerAtNode === void 0 ? void 0 : (0, VideoPlayer_1.mountVideoPlayerAtNode)(videoPlayerWrapperNode);
183
- if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
184
- return;
185
- const Hls = window === null || window === void 0 ? void 0 : window.Hls;
186
- let hls = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current;
187
- if (videoSrc.includes('.m3u8') && Hls && Hls.isSupported()) {
188
- hls = new Hls();
189
- hls === null || hls === void 0 ? void 0 : hls.loadSource(videoSrc);
190
- hls === null || hls === void 0 ? void 0 : hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
191
- hls === null || hls === void 0 ? void 0 : hls.on(Hls.Events.MANIFEST_PARSED, function () {
192
- var _a;
193
- videoRef.current.currentTime = rec === null || rec === void 0 ? void 0 : rec.startTime;
194
- (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
195
- });
196
- }
197
- else {
198
- videoRef.current.src = videoSrc;
199
- }
200
- (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('loadedmetadata', handleLoadedMetadata);
201
- (_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('pause', handlePause);
202
- (_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.addEventListener('play', handlePlay);
203
- (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('timeupdate', handleTimeUpload);
204
- return () => {
205
- var _a, _b, _c, _d, _e;
206
- if (hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current)
207
- (_a = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
208
- setIsLoadFinish(false);
209
- (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('loadedmetadata', handleLoadedMetadata);
210
- (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('pause', handlePause);
211
- (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.removeEventListener('play', handlePlay);
212
- (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.removeEventListener('timeupdate', handleTimeUpload);
213
- };
214
- }, [isActive]);
215
- const renderPoster = (0, react_1.useMemo)(() => {
216
- if (!(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image) || isLoadFinish) {
217
- return null;
218
- }
219
- 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' }));
220
- }, [isLoadFinish, sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image]);
221
- const blurStyle = (0, react_1.useMemo)(() => {
222
- return blur
223
- ? {
224
- filter: 'blur(10px)',
225
- transform: 'translate3d(0px, 0px, 0px) scale(1.2)'
226
- }
227
- : {};
228
- }, [blur]);
229
- if (!(rec === null || rec === void 0 ? void 0 : rec.mediaUrl)) {
230
- return null;
231
- }
232
- return (react_1.default.createElement("div", { className: 'video-container', key: rec.itemId, style: {
233
- position: 'relative',
234
- width: '100%',
235
- height,
236
- overflow: 'hidden'
237
- }, onClick: handleClickVideo() },
238
- react_1.default.createElement("div", { className: 'n-full-screen', id: videoId, style: { width: '100%', height: '100%' } }),
239
- renderPoster,
240
- isPauseVideo && react_1.default.createElement(FormatImage_1.default, { className: 'clc-pb-video-pause', src: videoPlayIcon !== null && videoPlayIcon !== void 0 ? videoPlayIcon : PAUSE_ICON, alt: 'pause' })));
241
- });
242
- exports.default = (0, react_1.memo)(VideoWidget);
@@ -1,51 +0,0 @@
1
- import React from 'react';
2
- import { ISxpPageRenderProps } from '../SxpPageRender';
3
- import '../SxpPageRender/index.less';
4
- export interface IScene {
5
- blueprintStep: number;
6
- endTime: number;
7
- itemId: string;
8
- mediaFileNo: string;
9
- mediaUrl: string;
10
- position: number;
11
- postId: string;
12
- sceneId: string;
13
- sceneInfo: string;
14
- sceneTag: string;
15
- startTime: number;
16
- traceInfo: string;
17
- bindProducts?: any[];
18
- title?: string;
19
- }
20
- export type ScenesType = IScene[];
21
- export type DiyStoryPreviewType = ISxpPageRenderProps & {
22
- appDomain?: string;
23
- scenes?: ScenesType;
24
- activeIndex?: number;
25
- onActiveChange?: (v: number) => void;
26
- loopPlay?: boolean;
27
- pointerEvents?: any;
28
- onUpdateTimeLine: (index: number, curTime: number) => void;
29
- onPlay: (index: number, curTime: number) => void;
30
- onPause: () => void;
31
- disabledListener?: boolean;
32
- };
33
- export interface IDiyStoryPreviewRef {
34
- play: () => void;
35
- pause: () => void;
36
- slideTo: (n: number) => void;
37
- isPlaying: () => boolean;
38
- }
39
- declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<ISxpPageRenderProps & {
40
- appDomain?: string | undefined;
41
- scenes?: ScenesType | undefined;
42
- activeIndex?: number | undefined;
43
- onActiveChange?: ((v: number) => void) | undefined;
44
- loopPlay?: boolean | undefined;
45
- pointerEvents?: any;
46
- onUpdateTimeLine: (index: number, curTime: number) => void;
47
- onPlay: (index: number, curTime: number) => void;
48
- onPause: () => void;
49
- disabledListener?: boolean | undefined;
50
- } & React.RefAttributes<IDiyStoryPreviewRef>>>;
51
- export default _default;