pb-sxp-ui 1.15.14 → 1.15.15-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 (51) hide show
  1. package/dist/index.cjs +781 -129
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +779 -128
  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 +781 -129
  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/DiyStoryPreview/PictureGroup.d.ts +16 -0
  14. package/es/core/components/DiyStoryPreview/PictureGroup.js +34 -0
  15. package/es/core/components/DiyStoryPreview/VideoWidget.d.ts +27 -0
  16. package/es/core/components/DiyStoryPreview/VideoWidget.js +195 -0
  17. package/es/core/components/DiyStoryPreview/index.d.ts +51 -0
  18. package/es/core/components/DiyStoryPreview/index.js +411 -0
  19. package/es/core/components/SxpPageCore/index.d.ts +1 -0
  20. package/es/core/components/SxpPageCore/index.js +7 -7
  21. package/es/core/components/SxpPageRender/ExpandableText.js +10 -2
  22. package/es/core/components/SxpPageRender/RenderCard.js +4 -4
  23. package/es/core/context/EditorContext.js +1 -1
  24. package/es/core/context/SxpDataSourceProvider.d.ts +1 -1
  25. package/es/core/context/SxpDataSourceProvider.js +28 -41
  26. package/es/index.d.ts +1 -0
  27. package/es/index.js +1 -0
  28. package/es/materials/sxp/template/MultiCommodity/index.js +1 -1
  29. package/es/materials/sxp/template/MultiCommodityDiro/index.js +2 -1
  30. package/es/materials/sxp/template/MultiCommodityDiroNew/index.js +2 -1
  31. package/es/materials/sxp/template/components/EventProvider.js +2 -2
  32. package/lib/core/components/DiyStoryPreview/PictureGroup.d.ts +16 -0
  33. package/lib/core/components/DiyStoryPreview/PictureGroup.js +37 -0
  34. package/lib/core/components/DiyStoryPreview/VideoWidget.d.ts +27 -0
  35. package/lib/core/components/DiyStoryPreview/VideoWidget.js +198 -0
  36. package/lib/core/components/DiyStoryPreview/index.d.ts +51 -0
  37. package/lib/core/components/DiyStoryPreview/index.js +414 -0
  38. package/lib/core/components/SxpPageCore/index.d.ts +1 -0
  39. package/lib/core/components/SxpPageCore/index.js +7 -7
  40. package/lib/core/components/SxpPageRender/ExpandableText.js +10 -2
  41. package/lib/core/components/SxpPageRender/RenderCard.js +4 -4
  42. package/lib/core/context/EditorContext.js +1 -1
  43. package/lib/core/context/SxpDataSourceProvider.d.ts +1 -1
  44. package/lib/core/context/SxpDataSourceProvider.js +28 -41
  45. package/lib/index.d.ts +1 -0
  46. package/lib/index.js +3 -1
  47. package/lib/materials/sxp/template/MultiCommodity/index.js +1 -1
  48. package/lib/materials/sxp/template/MultiCommodityDiro/index.js +2 -1
  49. package/lib/materials/sxp/template/MultiCommodityDiroNew/index.js +2 -1
  50. package/lib/materials/sxp/template/components/EventProvider.js +2 -2
  51. package/package.json +1 -1
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { postConfigType } from '../SxpPageRender';
3
+ import { IScene, ScenesType } from '.';
4
+ interface IPictureGroupProps {
5
+ imgUrls?: string[];
6
+ width: number;
7
+ height: number;
8
+ rec: IScene;
9
+ index: number;
10
+ imgUrlsPostConfig?: postConfigType;
11
+ swiperRef?: any;
12
+ data?: ScenesType;
13
+ loopPlay?: boolean;
14
+ }
15
+ declare const _default: React.NamedExoticComponent<IPictureGroupProps>;
16
+ export default _default;
@@ -0,0 +1,34 @@
1
+ import React, { memo, useEffect, useState } from 'react';
2
+ import { Autoplay, Pagination } from 'swiper/modules';
3
+ import { Swiper, SwiperSlide, useSwiperSlide } from 'swiper/react';
4
+ import Picture from '../SxpPageRender/PictureGroup/Picture';
5
+ const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index, swiperRef, data = [], loopPlay }) => {
6
+ const { isActive } = useSwiperSlide();
7
+ const [isload, setIsLoad] = useState(false);
8
+ useEffect(() => {
9
+ if (isActive && isload && loopPlay) {
10
+ setTimeout(() => {
11
+ var _a, _b, _c, _d;
12
+ if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
13
+ (_a = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _a === void 0 ? void 0 : _a.swiper.slideTo(0);
14
+ }
15
+ else {
16
+ const i = (_c = (_b = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _b === void 0 ? void 0 : _b.swiper) === null || _c === void 0 ? void 0 : _c.activeIndex;
17
+ (_d = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _d === void 0 ? void 0 : _d.swiper.slideTo(i + 1);
18
+ }
19
+ }, 3000);
20
+ }
21
+ }, [isActive, isload, data, index, swiperRef, loopPlay]);
22
+ const loadFinishImage = () => {
23
+ setIsLoad(true);
24
+ };
25
+ return (React.createElement(Swiper, { defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: {
26
+ clickable: true,
27
+ bulletActiveClass: 'swipe-item-active-bullet',
28
+ bulletElement: 'button'
29
+ }, height: height, style: { width }, loop: true, autoplay: false }, imgUrls === null || imgUrls === void 0 ? void 0 : imgUrls.map((url) => {
30
+ return (React.createElement(SwiperSlide, { key: url },
31
+ React.createElement(Picture, { src: url, height: height, imgUrlsPostConfig: imgUrlsPostConfig, onShowFirstImage: loadFinishImage })));
32
+ })));
33
+ };
34
+ export default memo(PictureGroup);
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { postConfigType } from '../SxpPageRender';
3
+ import { IScene, ScenesType } from '.';
4
+ interface IVideoWidgetProps {
5
+ rec: IScene;
6
+ index: number;
7
+ height: number;
8
+ width: number;
9
+ data: ScenesType;
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,195 @@
1
+ import React, { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
2
+ import { useSwiperSlide } from 'swiper/react';
3
+ import { useIconLink } from '../SxpPageRender/useIconLink';
4
+ import { mountVideoPlayerAtNode } from '../SxpPageRender/VideoWidget/VideoPlayer';
5
+ import FormatImage from '../SxpPageRender/FormatImage';
6
+ import { useSxpDataSource } from '../../../core/hooks';
7
+ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex, videoPostConfig, width, swiperRef, videoPlayIcon, onUpdateTimeLine, loopPlay, onPlay, onPause }, ref) => {
8
+ const { isActive } = useSwiperSlide();
9
+ const [isPauseVideo, setIsPauseVideo] = useState(false);
10
+ const videoRef = useRef(null);
11
+ const { bffEventReport, sxpParameter, waterFallData, openHashtag } = useSxpDataSource();
12
+ const videoStartTime = useRef(0);
13
+ const [isLoadFinish, setIsLoadFinish] = useState(false);
14
+ const [isFirstPlay, setIsFirstPlay] = useState(true);
15
+ const canvasRef = useRef(null);
16
+ const [firstFrameSrc, setFirstFrameSrc] = useState('');
17
+ const videoId = `pb-cache-video-${index}`;
18
+ const hlsRef = useRef(null);
19
+ const loopPlayRef = useRef(loopPlay);
20
+ useEffect(() => {
21
+ loopPlayRef.current = loopPlay;
22
+ }, [loopPlay]);
23
+ useImperativeHandle(ref, () => {
24
+ return {
25
+ play() {
26
+ var _a;
27
+ if (!videoRef.current)
28
+ return;
29
+ handleTimeUpload();
30
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
31
+ setIsPauseVideo(false);
32
+ },
33
+ pause() {
34
+ var _a;
35
+ if (!videoRef.current)
36
+ return;
37
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.pause();
38
+ setIsPauseVideo(true);
39
+ },
40
+ setLoopPlay(v) {
41
+ loopPlayRef.current = v;
42
+ },
43
+ isPlaying() {
44
+ var _a;
45
+ return !((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.paused);
46
+ }
47
+ };
48
+ });
49
+ useEffect(() => {
50
+ if (!videoRef.current)
51
+ return;
52
+ videoRef.current.muted = muted;
53
+ }, [muted]);
54
+ const PAUSE_ICON = useIconLink('/pb_static/06f28a2025c74c1cb49be6767316d827.png');
55
+ const handleLoadedMetadata = useCallback(() => {
56
+ var _a;
57
+ videoRef.current.currentTime = rec === null || rec === void 0 ? void 0 : rec.startTime;
58
+ (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
59
+ setIsLoadFinish(true);
60
+ }, []);
61
+ const handleClickVideo = useCallback((type) => () => {
62
+ var _a, _b, _c, _d, _e, _f;
63
+ if (!isActive || !(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
64
+ return;
65
+ const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
66
+ switch (type) {
67
+ case 'start':
68
+ if (!isPause)
69
+ return;
70
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.play();
71
+ setIsPauseVideo(false);
72
+ break;
73
+ case 'pause':
74
+ if (isPause)
75
+ return;
76
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
77
+ setIsPauseVideo(true);
78
+ break;
79
+ default:
80
+ if (isPause) {
81
+ 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)) {
82
+ videoRef.current.currentTime = rec === null || rec === void 0 ? void 0 : rec.startTime;
83
+ }
84
+ (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.play();
85
+ }
86
+ else {
87
+ (_f = videoRef.current) === null || _f === void 0 ? void 0 : _f.pause();
88
+ }
89
+ setIsPauseVideo(!isPause);
90
+ break;
91
+ }
92
+ }, [isLoadFinish]);
93
+ const blur = useMemo(() => {
94
+ return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2';
95
+ }, [videoPostConfig]);
96
+ const handleTimeUpload = () => {
97
+ if (!videoRef.current)
98
+ return;
99
+ setTimeout(() => {
100
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
101
+ 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)) {
102
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
103
+ if (!loopPlayRef.current)
104
+ return;
105
+ if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
106
+ (_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);
107
+ }
108
+ else {
109
+ 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;
110
+ (_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);
111
+ }
112
+ }
113
+ });
114
+ };
115
+ const handlePause = () => {
116
+ setIsPauseVideo(true);
117
+ onPause === null || onPause === void 0 ? void 0 : onPause();
118
+ };
119
+ const handlePlay = () => {
120
+ var _a;
121
+ 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);
122
+ onPlay === null || onPlay === void 0 ? void 0 : onPlay(index, localTime);
123
+ };
124
+ useEffect(() => {
125
+ var _a, _b, _c, _d;
126
+ if (!isActive)
127
+ return;
128
+ const videoSrc = rec === null || rec === void 0 ? void 0 : rec.mediaUrl;
129
+ if (!videoSrc)
130
+ return;
131
+ setIsPauseVideo(false);
132
+ const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
133
+ if (!videoPlayerWrapperNode)
134
+ return;
135
+ videoRef.current = mountVideoPlayerAtNode === null || mountVideoPlayerAtNode === void 0 ? void 0 : mountVideoPlayerAtNode(videoPlayerWrapperNode);
136
+ if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
137
+ return;
138
+ const Hls = window === null || window === void 0 ? void 0 : window.Hls;
139
+ let hls = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current;
140
+ if (videoSrc.includes('.m3u8') && Hls && Hls.isSupported()) {
141
+ hls = new Hls();
142
+ hls === null || hls === void 0 ? void 0 : hls.loadSource(videoSrc);
143
+ hls === null || hls === void 0 ? void 0 : hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
144
+ hls === null || hls === void 0 ? void 0 : hls.on(Hls.Events.MANIFEST_PARSED, function () {
145
+ var _a;
146
+ videoRef.current.currentTime = rec === null || rec === void 0 ? void 0 : rec.startTime;
147
+ (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
148
+ });
149
+ }
150
+ else {
151
+ videoRef.current.src = videoSrc;
152
+ }
153
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('loadedmetadata', handleLoadedMetadata);
154
+ (_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('pause', handlePause);
155
+ (_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.addEventListener('play', handlePlay);
156
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('timeupdate', handleTimeUpload);
157
+ return () => {
158
+ var _a, _b, _c, _d, _e;
159
+ if (hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current)
160
+ (_a = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
161
+ setIsLoadFinish(false);
162
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('loadedmetadata', handleLoadedMetadata);
163
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('pause', handlePause);
164
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.removeEventListener('play', handlePlay);
165
+ (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.removeEventListener('timeupdate', handleTimeUpload);
166
+ };
167
+ }, [isActive]);
168
+ const renderPoster = useMemo(() => {
169
+ if (!(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image) || isLoadFinish) {
170
+ return null;
171
+ }
172
+ 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, alt: 'video poster' }));
173
+ }, [isLoadFinish, sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image]);
174
+ const blurStyle = useMemo(() => {
175
+ return blur
176
+ ? {
177
+ filter: 'blur(10px)',
178
+ transform: 'translate3d(0px, 0px, 0px) scale(1.2)'
179
+ }
180
+ : {};
181
+ }, [blur]);
182
+ if (!(rec === null || rec === void 0 ? void 0 : rec.mediaUrl)) {
183
+ return null;
184
+ }
185
+ return (React.createElement("div", { className: 'video-container', key: rec.itemId, style: {
186
+ position: 'relative',
187
+ width: '100%',
188
+ height,
189
+ overflow: 'hidden'
190
+ }, onClick: handleClickVideo() },
191
+ React.createElement("div", { className: 'n-full-screen', id: videoId, style: { width: '100%', height: '100%' } }),
192
+ renderPoster,
193
+ isPauseVideo && React.createElement(FormatImage, { className: 'clc-pb-video-pause', src: videoPlayIcon !== null && videoPlayIcon !== void 0 ? videoPlayIcon : PAUSE_ICON, alt: 'pause' })));
194
+ });
195
+ export default memo(VideoWidget);
@@ -0,0 +1,51 @@
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;