pb-sxp-ui 1.15.22-alpha.1 → 1.15.22-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,13 +5,13 @@ const react_1 = tslib_1.__importStar(require("react"));
5
5
  const react_2 = require("swiper/react");
6
6
  const useIconLink_1 = require("../useIconLink");
7
7
  const FormatImage_1 = tslib_1.__importDefault(require("../FormatImage"));
8
- const hooks_1 = require("../../../../core/hooks");
9
- const event_1 = tslib_1.__importStar(require("../../../../core/utils/event"));
10
8
  const loading_gif_1 = tslib_1.__importDefault(require("./loading.gif"));
11
9
  const VideoPlayer_1 = require("./VideoPlayer");
12
- const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon }) => {
10
+ const hooks_1 = require("../../../../core/hooks");
11
+ const event_1 = tslib_1.__importStar(require("../../../../core/utils/event"));
12
+ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon, loopPlay, swiperRef }, ref) => {
13
13
  const [isPauseVideo, setIsPauseVideo] = (0, react_1.useState)(false);
14
- const { bffEventReport, sxpParameter, waterFallData, openHashtag, bffFbReport } = (0, hooks_1.useSxpDataSource)();
14
+ const { bffEventReport, sxpParameter, waterFallData, openHashtag, bffFbReport, isDiyH5 } = (0, hooks_1.useSxpDataSource)();
15
15
  const videoStartTime = (0, react_1.useRef)(0);
16
16
  const [isLoadFinish, setIsLoadFinish] = (0, react_1.useState)(false);
17
17
  const { isActive } = (0, react_2.useSwiperSlide)();
@@ -25,6 +25,18 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
25
25
  const initTimeRef = (0, react_1.useRef)();
26
26
  const loadedTimeRef = (0, react_1.useRef)();
27
27
  const isFirstPlayRef = (0, react_1.useRef)(true);
28
+ const loopPlayRef = (0, react_1.useRef)(loopPlay);
29
+ const scene = rec.video.scene;
30
+ (0, react_1.useImperativeHandle)(ref, () => {
31
+ return {
32
+ setLoopPlay(v) {
33
+ loopPlayRef.current = v;
34
+ }
35
+ };
36
+ });
37
+ (0, react_1.useEffect)(() => {
38
+ loopPlayRef.current = loopPlay;
39
+ }, [loopPlay]);
28
40
  const blur = (0, react_1.useMemo)(() => {
29
41
  return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2';
30
42
  }, [videoPostConfig]);
@@ -112,12 +124,15 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
112
124
  const handleLoadedmetadata = (0, react_1.useCallback)(() => {
113
125
  if (!videoRef.current)
114
126
  return;
127
+ if (isDiyH5) {
128
+ videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
129
+ }
115
130
  loadedTimeRef.current = new Date();
116
131
  handleStartPlay();
117
132
  handLoadeddata();
118
133
  }, [videoRef.current, handLoadeddata, handleStartPlay]);
119
134
  const handleClickVideo = (0, react_1.useCallback)((type) => () => {
120
- var _a, _b, _c, _d, _e;
135
+ var _a, _b, _c, _d, _e, _f;
121
136
  if (!videoRef.current)
122
137
  return;
123
138
  if (!isLoadFinish)
@@ -138,10 +153,13 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
138
153
  break;
139
154
  default:
140
155
  if (isPause) {
141
- (_d = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _d === void 0 ? void 0 : _d.play();
156
+ if (isDiyH5 && Math.round((_d = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _d === void 0 ? void 0 : _d.currentTime) >= (scene === null || scene === void 0 ? void 0 : scene.endTime)) {
157
+ videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
158
+ }
159
+ (_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.play();
142
160
  }
143
161
  else {
144
- (_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.pause();
162
+ (_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.pause();
145
163
  }
146
164
  setIsPauseVideo(!isPause);
147
165
  break;
@@ -178,8 +196,27 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
178
196
  const handleWaiting = (0, react_1.useCallback)(() => {
179
197
  setWaiting(true);
180
198
  }, []);
199
+ const handleTimeUpload = () => {
200
+ if (!videoRef.current || !isDiyH5)
201
+ return;
202
+ setTimeout(() => {
203
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
204
+ if (Math.round((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.currentTime) >= ((_b = scene === null || scene === void 0 ? void 0 : scene.endTime) !== null && _b !== void 0 ? _b : 0)) {
205
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
206
+ if (!loopPlayRef.current)
207
+ return;
208
+ if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
209
+ (_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);
210
+ }
211
+ else {
212
+ 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;
213
+ (_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);
214
+ }
215
+ }
216
+ });
217
+ };
181
218
  (0, react_1.useEffect)(() => {
182
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
219
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
183
220
  if (!isActive)
184
221
  return;
185
222
  const videoSrc = rec === null || rec === void 0 ? void 0 : rec.video.url;
@@ -200,6 +237,7 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
200
237
  hls === null || hls === void 0 ? void 0 : hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
201
238
  hls === null || hls === void 0 ? void 0 : hls.on(Hls.Events.MANIFEST_PARSED, function () {
202
239
  var _a;
240
+ videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
203
241
  (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
204
242
  });
205
243
  }
@@ -216,8 +254,9 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
216
254
  (_h = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _h === void 0 ? void 0 : _h.addEventListener('ended', handlePlay);
217
255
  (_j = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _j === void 0 ? void 0 : _j.addEventListener('canplay', handlePlay);
218
256
  (_k = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _k === void 0 ? void 0 : _k.addEventListener('waiting', handleWaiting);
257
+ (_l = videoRef.current) === null || _l === void 0 ? void 0 : _l.addEventListener('timeupdate', handleTimeUpload);
219
258
  return () => {
220
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
259
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
221
260
  const isPause = (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
222
261
  if (!isPause)
223
262
  handlePause();
@@ -232,6 +271,7 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
232
271
  (_h = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _h === void 0 ? void 0 : _h.removeEventListener('ended', handlePlay);
233
272
  (_j = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _j === void 0 ? void 0 : _j.removeEventListener('canplay', handlePlay);
234
273
  (_k = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _k === void 0 ? void 0 : _k.removeEventListener('waiting', handleWaiting);
274
+ (_l = videoRef.current) === null || _l === void 0 ? void 0 : _l.removeEventListener('timeupdate', handleTimeUpload);
235
275
  };
236
276
  }, [isActive]);
237
277
  (0, react_1.useEffect)(() => {
@@ -349,6 +389,6 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
349
389
  react_1.default.createElement("div", { className: 'n-full-screen', ref: videoEleRef, id: videoId, style: { width: '100%', height: '100%' } }),
350
390
  renderPoster,
351
391
  renderLoading,
352
- isPauseVideo && react_1.default.createElement(FormatImage_1.default, { className: 'clc-pb-video-pause', src: videoPlayIcon !== null && videoPlayIcon !== void 0 ? videoPlayIcon : PAUSE_ICON, alt: 'pause' })))));
353
- };
392
+ isPauseVideo && (react_1.default.createElement(FormatImage_1.default, { className: 'clc-pb-video-pause', src: videoPlayIcon !== null && videoPlayIcon !== void 0 ? videoPlayIcon : PAUSE_ICON, alt: 'pause' }))))));
393
+ });
354
394
  exports.default = (0, react_1.memo)(VideoWidget);
@@ -44,7 +44,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
44
44
  const [isReload, setIsReload] = (0, react_1.useState)(new Date().getTime());
45
45
  const skipLinkRef = (0, react_1.useRef)(false);
46
46
  const [pageNum, setPageNum] = (0, react_1.useState)(2);
47
- const { loadVideos, bffEventReport, loading, setPopupDetailData, ctaEvent, swiperRef, waterFallData, setOpenHashtag, appDomain, openHashtag, loadingImage, isFromHashtag, popupDetailData, bffFbReport, curTime, h5EnterLink, isShowConsent, selectTag, isPreview, isEditor, cacheRtcList, setRtcList, cacheActiveIndex, rtcList, isNoMoreData, channel, refreshFeSession } = (0, hooks_1.useSxpDataSource)();
47
+ const videoWidgetRef = (0, react_1.useRef)(null);
48
+ const { loadVideos, bffEventReport, loading, setPopupDetailData, ctaEvent, swiperRef, waterFallData, setOpenHashtag, appDomain, openHashtag, loadingImage, isFromHashtag, popupDetailData, bffFbReport, curTime, h5EnterLink, isShowConsent, selectTag, isPreview, isEditor, cacheRtcList, setRtcList, cacheActiveIndex, rtcList, isNoMoreData, channel, refreshFeSession, isDiyH5 } = (0, hooks_1.useSxpDataSource)();
48
49
  const { backMainFeed, productView, jumpToWeb } = (0, useEventReport_1.useEventReport)();
49
50
  const isShowFingerTip = (0, react_1.useMemo)(() => {
50
51
  return data.length > 0 && !loading && ((0, localStore_1.getFeUserState)() || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip));
@@ -179,6 +180,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
179
180
  refreshFeSession
180
181
  ]);
181
182
  const handleSessionExpire = (0, react_1.useCallback)((0, lodash_1.debounce)(() => {
183
+ var _a;
184
+ (_a = videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.setLoopPlay(false);
182
185
  refreshFeSession === null || refreshFeSession === void 0 ? void 0 : refreshFeSession(false, handleSessionCompleted);
183
186
  }, 1000), [handleSessionCompleted, refreshFeSession]);
184
187
  (0, react_1.useEffect)(() => {
@@ -253,7 +256,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
253
256
  return (react_1.default.createElement(MultiPosts_1.default, Object.assign({ recData: data === null || data === void 0 ? void 0 : data[1] }, (_c = (_b = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.multiPosts) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.item) === null || _c === void 0 ? void 0 : _c.props, (_f = (_e = (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.multiPosts) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.item) === null || _f === void 0 ? void 0 : _f.event)));
254
257
  }
255
258
  if ((_g = rec === null || rec === void 0 ? void 0 : rec.video) === null || _g === void 0 ? void 0 : _g.url) {
256
- return (react_1.default.createElement(VideoWidget_1.default, { key: isReload, rec: rec, index: index, muted: isMuted, data: data, height: height, activeIndex: activeIndex, videoPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPost, videoPlayIcon: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPlayIcon }));
259
+ return (react_1.default.createElement(VideoWidget_1.default, Object.assign({ key: isReload }, (activeIndex === index && { ref: videoWidgetRef }), { rec: rec, index: index, muted: isMuted, data: data, height: height, activeIndex: activeIndex, videoPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPost, videoPlayIcon: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPlayIcon, loopPlay: true, swiperRef: swiperRef })));
257
260
  }
258
261
  if ((_h = rec === null || rec === void 0 ? void 0 : rec.video) === null || _h === void 0 ? void 0 : _h.imgUrls) {
259
262
  return (react_1.default.createElement(PictureGroup_1.default, { key: rec === null || rec === void 0 ? void 0 : rec.video.itemId, imgUrls: rec === null || rec === void 0 ? void 0 : rec.video.imgUrls, width: containerWidth, height: height, rec: rec, index: index, onViewImageEndEvent: handleViewImageStartEnd, onViewImageStartEvent: handleViewImageStartEvent, imgUrlsPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.imgUrlsPost }));
@@ -597,7 +600,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
597
600
  if (openHashtag)
598
601
  return;
599
602
  handleScrollEvent(swiper);
600
- if (waterFallData || isEditor)
603
+ if (waterFallData || isEditor || isDiyH5)
601
604
  return;
602
605
  if ((swiper === null || swiper === void 0 ? void 0 : swiper.activeIndex) + 1 >= (data === null || data === void 0 ? void 0 : data.length)) {
603
606
  if (!isLoadMore) {
@@ -92,6 +92,7 @@ export interface ISxpDataSourceContext {
92
92
  refreshFeSession?: (enableReSid?: boolean, event?: (fk: string) => void) => void;
93
93
  getAccount?: () => Promise<any>;
94
94
  accountSonsent?: (v: boolean) => Promise<boolean>;
95
+ isDiyH5?: boolean;
95
96
  }
96
97
  export declare const SxpDataSourceContext: React.Context<ISxpDataSourceContext>;
97
98
  export interface SxpDataSourceProviderProps {
@@ -628,7 +628,8 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
628
628
  multiPostTimeRef,
629
629
  refreshFeSession,
630
630
  getAccount,
631
- accountSonsent
631
+ accountSonsent,
632
+ isDiyH5
632
633
  } }, isShowConsent ? (react_1.default.createElement(Consent_1.default, Object.assign({}, (_e = (_d = (_c = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.consent) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.item) === null || _e === void 0 ? void 0 : _e.props))) : (render({
633
634
  rtcList,
634
635
  mutateLike: bffMutateLike,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pb-sxp-ui",
3
- "version": "1.15.22-alpha.1",
3
+ "version": "1.15.22-alpha.2",
4
4
  "description": "React enterprise-class UI components",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",