pb-sxp-ui 1.15.21 → 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.
Files changed (52) hide show
  1. package/dist/index.cjs +7737 -7247
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.css +46 -46
  4. package/dist/index.js +7735 -7246
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.min.cjs +6 -6
  7. package/dist/index.min.cjs.map +1 -1
  8. package/dist/index.min.js +6 -6
  9. package/dist/index.min.js.map +1 -1
  10. package/dist/pb-ui.js +7737 -7247
  11. package/dist/pb-ui.js.map +1 -1
  12. package/dist/pb-ui.min.js +6 -6
  13. package/dist/pb-ui.min.js.map +1 -1
  14. package/es/core/Pagebuilder/type.d.ts +10 -5
  15. package/es/core/components/DiyStoryPreview/PictureGroup.d.ts +16 -0
  16. package/es/core/components/DiyStoryPreview/PictureGroup.js +34 -0
  17. package/es/core/components/DiyStoryPreview/VideoWidget.d.ts +27 -0
  18. package/es/core/components/DiyStoryPreview/VideoWidget.js +197 -0
  19. package/es/core/components/DiyStoryPreview/index.d.ts +32 -0
  20. package/es/core/components/DiyStoryPreview/index.js +232 -0
  21. package/es/core/components/SxpPageCore/index.js +3 -2
  22. package/es/core/components/SxpPageRender/VideoWidget/index.d.ts +6 -1
  23. package/es/core/components/SxpPageRender/VideoWidget/index.js +52 -12
  24. package/es/core/components/SxpPageRender/index.d.ts +0 -1
  25. package/es/core/components/SxpPageRender/index.js +6 -3
  26. package/es/core/components/SxpPageRender/typing.d.ts +19 -0
  27. package/es/core/context/SxpDataSourceProvider.d.ts +3 -1
  28. package/es/core/context/SxpDataSourceProvider.js +50 -98
  29. package/es/index.d.ts +1 -0
  30. package/es/index.js +1 -0
  31. package/es/materials/sxp/popup/CommodityDetail/index.js +2 -2
  32. package/es/materials/sxp/popup/CommodityDetailDiroNew/index.js +1 -1
  33. package/lib/core/Pagebuilder/type.d.ts +10 -5
  34. package/lib/core/components/DiyStoryPreview/PictureGroup.d.ts +16 -0
  35. package/lib/core/components/DiyStoryPreview/PictureGroup.js +37 -0
  36. package/lib/core/components/DiyStoryPreview/VideoWidget.d.ts +27 -0
  37. package/lib/core/components/DiyStoryPreview/VideoWidget.js +200 -0
  38. package/lib/core/components/DiyStoryPreview/index.d.ts +32 -0
  39. package/lib/core/components/DiyStoryPreview/index.js +235 -0
  40. package/lib/core/components/SxpPageCore/index.js +3 -2
  41. package/lib/core/components/SxpPageRender/VideoWidget/index.d.ts +6 -1
  42. package/lib/core/components/SxpPageRender/VideoWidget/index.js +51 -11
  43. package/lib/core/components/SxpPageRender/index.d.ts +0 -1
  44. package/lib/core/components/SxpPageRender/index.js +6 -3
  45. package/lib/core/components/SxpPageRender/typing.d.ts +19 -0
  46. package/lib/core/context/SxpDataSourceProvider.d.ts +3 -1
  47. package/lib/core/context/SxpDataSourceProvider.js +50 -98
  48. package/lib/index.d.ts +1 -0
  49. package/lib/index.js +3 -1
  50. package/lib/materials/sxp/popup/CommodityDetail/index.js +2 -2
  51. package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.js +1 -1
  52. package/package.json +1 -1
@@ -1,15 +1,15 @@
1
1
  import { __awaiter } from "tslib";
2
- import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+ import React, { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
3
3
  import { useSwiperSlide } from 'swiper/react';
4
4
  import { useIconLink } from '../useIconLink';
5
5
  import FormatImage from '../FormatImage';
6
- import { useSxpDataSource } from '../../../../core/hooks';
7
- import SXP_EVENT_BUS, { SXP_EVENT_TYPE } from '../../../../core/utils/event';
8
6
  import loading_gif from './loading.gif';
9
7
  import { mountVideoPlayerAtNode } from './VideoPlayer';
10
- const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon }) => {
8
+ import { useSxpDataSource } from '../../../../core/hooks';
9
+ import SXP_EVENT_BUS, { SXP_EVENT_TYPE } from '../../../../core/utils/event';
10
+ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon, loopPlay, swiperRef }, ref) => {
11
11
  const [isPauseVideo, setIsPauseVideo] = useState(false);
12
- const { bffEventReport, sxpParameter, waterFallData, openHashtag, bffFbReport } = useSxpDataSource();
12
+ const { bffEventReport, sxpParameter, waterFallData, openHashtag, bffFbReport, isDiyH5 } = useSxpDataSource();
13
13
  const videoStartTime = useRef(0);
14
14
  const [isLoadFinish, setIsLoadFinish] = useState(false);
15
15
  const { isActive } = useSwiperSlide();
@@ -23,6 +23,18 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
23
23
  const initTimeRef = useRef();
24
24
  const loadedTimeRef = useRef();
25
25
  const isFirstPlayRef = useRef(true);
26
+ const loopPlayRef = useRef(loopPlay);
27
+ const scene = rec.video.scene;
28
+ useImperativeHandle(ref, () => {
29
+ return {
30
+ setLoopPlay(v) {
31
+ loopPlayRef.current = v;
32
+ }
33
+ };
34
+ });
35
+ useEffect(() => {
36
+ loopPlayRef.current = loopPlay;
37
+ }, [loopPlay]);
26
38
  const blur = useMemo(() => {
27
39
  return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2';
28
40
  }, [videoPostConfig]);
@@ -110,12 +122,15 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
110
122
  const handleLoadedmetadata = useCallback(() => {
111
123
  if (!videoRef.current)
112
124
  return;
125
+ if (isDiyH5) {
126
+ videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
127
+ }
113
128
  loadedTimeRef.current = new Date();
114
129
  handleStartPlay();
115
130
  handLoadeddata();
116
131
  }, [videoRef.current, handLoadeddata, handleStartPlay]);
117
132
  const handleClickVideo = useCallback((type) => () => {
118
- var _a, _b, _c, _d, _e;
133
+ var _a, _b, _c, _d, _e, _f;
119
134
  if (!videoRef.current)
120
135
  return;
121
136
  if (!isLoadFinish)
@@ -136,10 +151,13 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
136
151
  break;
137
152
  default:
138
153
  if (isPause) {
139
- (_d = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _d === void 0 ? void 0 : _d.play();
154
+ 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)) {
155
+ videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
156
+ }
157
+ (_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.play();
140
158
  }
141
159
  else {
142
- (_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.pause();
160
+ (_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.pause();
143
161
  }
144
162
  setIsPauseVideo(!isPause);
145
163
  break;
@@ -176,8 +194,27 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
176
194
  const handleWaiting = useCallback(() => {
177
195
  setWaiting(true);
178
196
  }, []);
197
+ const handleTimeUpload = () => {
198
+ if (!videoRef.current || !isDiyH5)
199
+ return;
200
+ setTimeout(() => {
201
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
202
+ 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)) {
203
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
204
+ if (!loopPlayRef.current)
205
+ return;
206
+ if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
207
+ (_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);
208
+ }
209
+ else {
210
+ 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;
211
+ (_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);
212
+ }
213
+ }
214
+ });
215
+ };
179
216
  useEffect(() => {
180
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
217
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
181
218
  if (!isActive)
182
219
  return;
183
220
  const videoSrc = rec === null || rec === void 0 ? void 0 : rec.video.url;
@@ -198,6 +235,7 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
198
235
  hls === null || hls === void 0 ? void 0 : hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
199
236
  hls === null || hls === void 0 ? void 0 : hls.on(Hls.Events.MANIFEST_PARSED, function () {
200
237
  var _a;
238
+ videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
201
239
  (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
202
240
  });
203
241
  }
@@ -214,8 +252,9 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
214
252
  (_h = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _h === void 0 ? void 0 : _h.addEventListener('ended', handlePlay);
215
253
  (_j = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _j === void 0 ? void 0 : _j.addEventListener('canplay', handlePlay);
216
254
  (_k = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _k === void 0 ? void 0 : _k.addEventListener('waiting', handleWaiting);
255
+ (_l = videoRef.current) === null || _l === void 0 ? void 0 : _l.addEventListener('timeupdate', handleTimeUpload);
217
256
  return () => {
218
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
257
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
219
258
  const isPause = (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
220
259
  if (!isPause)
221
260
  handlePause();
@@ -230,6 +269,7 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
230
269
  (_h = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _h === void 0 ? void 0 : _h.removeEventListener('ended', handlePlay);
231
270
  (_j = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _j === void 0 ? void 0 : _j.removeEventListener('canplay', handlePlay);
232
271
  (_k = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _k === void 0 ? void 0 : _k.removeEventListener('waiting', handleWaiting);
272
+ (_l = videoRef.current) === null || _l === void 0 ? void 0 : _l.removeEventListener('timeupdate', handleTimeUpload);
233
273
  };
234
274
  }, [isActive]);
235
275
  useEffect(() => {
@@ -347,6 +387,6 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
347
387
  React.createElement("div", { className: 'n-full-screen', ref: videoEleRef, id: videoId, style: { width: '100%', height: '100%' } }),
348
388
  renderPoster,
349
389
  renderLoading,
350
- isPauseVideo && React.createElement(FormatImage, { className: 'clc-pb-video-pause', src: videoPlayIcon !== null && videoPlayIcon !== void 0 ? videoPlayIcon : PAUSE_ICON, alt: 'pause' })))));
351
- };
390
+ isPauseVideo && (React.createElement(FormatImage, { className: 'clc-pb-video-pause', src: videoPlayIcon !== null && videoPlayIcon !== void 0 ? videoPlayIcon : PAUSE_ICON, alt: 'pause' }))))));
391
+ });
352
392
  export default memo(VideoWidget);
@@ -67,7 +67,6 @@ export interface ISxpPageRenderProps {
67
67
  y: number;
68
68
  };
69
69
  converApi?: any;
70
- pixel?: any;
71
70
  consentPopup?: any;
72
71
  multiPosts?: any;
73
72
  playbook?: 'paid media' | 'organic menu';
@@ -41,7 +41,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
41
41
  const [isReload, setIsReload] = useState(new Date().getTime());
42
42
  const skipLinkRef = useRef(false);
43
43
  const [pageNum, setPageNum] = useState(2);
44
- 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 } = useSxpDataSource();
44
+ const videoWidgetRef = useRef(null);
45
+ 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 } = useSxpDataSource();
45
46
  const { backMainFeed, productView, jumpToWeb } = useEventReport();
46
47
  const isShowFingerTip = useMemo(() => {
47
48
  return data.length > 0 && !loading && (getFeUserState() || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip));
@@ -176,6 +177,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
176
177
  refreshFeSession
177
178
  ]);
178
179
  const handleSessionExpire = useCallback(debounce(() => {
180
+ var _a;
181
+ (_a = videoWidgetRef.current) === null || _a === void 0 ? void 0 : _a.setLoopPlay(false);
179
182
  refreshFeSession === null || refreshFeSession === void 0 ? void 0 : refreshFeSession(false, handleSessionCompleted);
180
183
  }, 1000), [handleSessionCompleted, refreshFeSession]);
181
184
  useEffect(() => {
@@ -250,7 +253,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
250
253
  return (React.createElement(MultiPosts, 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)));
251
254
  }
252
255
  if ((_g = rec === null || rec === void 0 ? void 0 : rec.video) === null || _g === void 0 ? void 0 : _g.url) {
253
- return (React.createElement(VideoWidget, { 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 }));
256
+ return (React.createElement(VideoWidget, 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 })));
254
257
  }
255
258
  if ((_h = rec === null || rec === void 0 ? void 0 : rec.video) === null || _h === void 0 ? void 0 : _h.imgUrls) {
256
259
  return (React.createElement(PictureGroup, { 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 }));
@@ -594,7 +597,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
594
597
  if (openHashtag)
595
598
  return;
596
599
  handleScrollEvent(swiper);
597
- if (waterFallData || isEditor)
600
+ if (waterFallData || isEditor || isDiyH5)
598
601
  return;
599
602
  if ((swiper === null || swiper === void 0 ? void 0 : swiper.activeIndex) + 1 >= (data === null || data === void 0 ? void 0 : data.length)) {
600
603
  if (!isLoadMore) {
@@ -47,6 +47,24 @@ export type ProductInfoType = {
47
47
  cover?: string;
48
48
  remark?: string;
49
49
  };
50
+ export interface IScene {
51
+ blueprintStep: number;
52
+ endTime: number;
53
+ itemId: string;
54
+ mediaFileNo: string;
55
+ mediaUrl: string;
56
+ position: number;
57
+ postId: string;
58
+ sceneId: string;
59
+ sceneInfo: string;
60
+ sceneTag: string;
61
+ startTime: number;
62
+ traceInfo: string;
63
+ cover: string;
64
+ bindProducts?: any[];
65
+ title?: string;
66
+ }
67
+ export type ScenesType = IScene[];
50
68
  export type VideoInfoType = {
51
69
  bindCtaId: string;
52
70
  bindProductId: string;
@@ -65,6 +83,7 @@ export type VideoInfoType = {
65
83
  bindProduct: ProductInfoType;
66
84
  bindCta: CTAInfoType;
67
85
  hashTags: string[];
86
+ scene: IScene;
68
87
  };
69
88
  export type RecommendVideoResultType = {
70
89
  recList: Array<RecItemType>;
@@ -72,7 +72,7 @@ export interface ISxpDataSourceContext {
72
72
  bffFbReport?: (body: {
73
73
  eventName: 'PageView' | 'ProductView' | 'ViewContent';
74
74
  product?: any;
75
- }) => void;
75
+ }) => Promise<any> | undefined | boolean;
76
76
  curTime?: any;
77
77
  h5EnterLink?: () => void;
78
78
  themeTag?: any;
@@ -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 {
@@ -133,6 +134,7 @@ export interface SxpDataSourceProviderProps {
133
134
  channelQueryList?: any[];
134
135
  data?: PageData;
135
136
  dataList?: PageData[];
137
+ isDiyH5?: boolean;
136
138
  onUpdateSchema?: (d: PageData['data']) => void;
137
139
  onUpdateChannel?: (d: string) => void;
138
140
  }
@@ -17,7 +17,7 @@ var DataSourceType;
17
17
  DataSourceType[DataSourceType["BFF"] = 5] = "BFF";
18
18
  })(DataSourceType || (DataSourceType = {}));
19
19
  export const DEFAULT_TAG = 'FOR U';
20
- const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent = true, maxSize, defaultSize, isPreview = false, sxpParameter, appDomain, hashTagSize, loadingImage, isOpenHashTag = false, enabledMetaConversionApi = false, consentHeight, consentWidth, isOpenConsent = false, isEditor = false, utmParameter, channelQueryList, data, dataList, onUpdateSchema, onUpdateChannel }) => {
20
+ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent = true, maxSize, defaultSize, isPreview = false, sxpParameter, appDomain, hashTagSize, loadingImage, isOpenHashTag = false, enabledMetaConversionApi = false, consentHeight, consentWidth, isOpenConsent = false, isEditor = false, utmParameter, channelQueryList, data, dataList, isDiyH5, onUpdateSchema, onUpdateChannel }) => {
21
21
  var _a, _b, _c, _d, _e;
22
22
  const [rtcList, setRtcList] = useState([]);
23
23
  const [tagList, setTagList] = useState([]);
@@ -105,7 +105,6 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
105
105
  return ((_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']) + storeAndLoadFeUserId();
106
106
  }, [bffDataSource]);
107
107
  const bffFetch = useCallback((path, options) => {
108
- var _a, _b;
109
108
  if (!bffDataSource)
110
109
  return;
111
110
  const url = bffDataSource.url;
@@ -113,33 +112,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
113
112
  const queryString = qs.stringify(options.query);
114
113
  path = `${path}?${queryString}`;
115
114
  }
116
- let isTikTokChannel = false;
117
- const params = {};
118
- const queryString = location.search.slice(1);
119
- (_a = splitUrlParams(queryString)) === null || _a === void 0 ? void 0 : _a.forEach((val) => {
120
- const key = val.split('=')[0];
121
- const value = val.split('=')[1];
122
- params[key] = value;
123
- });
124
- const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
125
- if (cl_source &&
126
- ((_b = [
127
- '40A-SPRK--DRESS_EYEWEAR-',
128
- '41A-SPRK--MADRAGUE-',
129
- '42A-SPRK--MOOD-',
130
- '43A-SPRK--SUMMER-',
131
- '44A-SPRK--DRESS_EYEWEAR-',
132
- '45A-SPRK--MADRAGUE-',
133
- '46A-SPRK--MOOD-',
134
- '47A-SPRK--SUMMER-',
135
- '48A-SPRK--DRESS_EYEWEAR-',
136
- '49A-SPRK--MADRAGUE-',
137
- '50A-SPRK--MOOD-',
138
- '51A-SPRK--SUMMER-'
139
- ]) === null || _b === void 0 ? void 0 : _b.includes(cl_source))) {
140
- isTikTokChannel = true;
141
- }
142
- if (options.type === 'beacon' && navigator.sendBeacon && !isTikTokChannel) {
115
+ if (options.type === 'beacon' && navigator.sendBeacon) {
143
116
  return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
144
117
  JSON.stringify({
145
118
  body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
@@ -149,11 +122,11 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
149
122
  }));
150
123
  }
151
124
  return window
152
- .fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers), method: options.method, body: isTikTokChannel
153
- ? JSON.stringify({
154
- body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
155
- })
156
- : JSON.stringify(options.body) }, (isTikTokChannel && { keepalive: true })))
125
+ .fetch(`${url}/api/${path}`, {
126
+ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers),
127
+ method: options.method,
128
+ body: JSON.stringify(options.body)
129
+ })
157
130
  .then((res) => res.json())
158
131
  .catch((err) => Promise.reject(err));
159
132
  }, [bffDataSource, fakeUserId]);
@@ -176,7 +149,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
176
149
  }, [bffDataSource]);
177
150
  const getRecommendVideos = useCallback((query) => __awaiter(void 0, void 0, void 0, function* () {
178
151
  var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
179
- query = Object.assign({ maxSize: (_f = query === null || query === void 0 ? void 0 : query.maxSize) !== null && _f !== void 0 ? _f : maxSize, defaultSize: (_g = query === null || query === void 0 ? void 0 : query.defaultSize) !== null && _g !== void 0 ? _g : defaultSize, hashTag: query === null || query === void 0 ? void 0 : query.hashTag, traceInfo: query === null || query === void 0 ? void 0 : query.traceInfo, themeTag: query === null || query === void 0 ? void 0 : query.themeTag, pageNum: query === null || query === void 0 ? void 0 : query.pageNum, contentFilter: query === null || query === void 0 ? void 0 : query.contentFilter, productFilter: query === null || query === void 0 ? void 0 : query.productFilter }, (chatlabsId && { chatlabsId }));
152
+ query = Object.assign(Object.assign({ maxSize: (_f = query === null || query === void 0 ? void 0 : query.maxSize) !== null && _f !== void 0 ? _f : maxSize, defaultSize: (_g = query === null || query === void 0 ? void 0 : query.defaultSize) !== null && _g !== void 0 ? _g : defaultSize, hashTag: query === null || query === void 0 ? void 0 : query.hashTag, traceInfo: query === null || query === void 0 ? void 0 : query.traceInfo, themeTag: query === null || query === void 0 ? void 0 : query.themeTag, pageNum: query === null || query === void 0 ? void 0 : query.pageNum, contentFilter: query === null || query === void 0 ? void 0 : query.contentFilter, productFilter: query === null || query === void 0 ? void 0 : query.productFilter }, (chatlabsId && { chatlabsId })), (isDiyH5 && { type: 'story' }));
180
153
  if (channel) {
181
154
  query = Object.assign(Object.assign({}, query), { channel: decodeURIComponent(channel) });
182
155
  }
@@ -225,7 +198,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
225
198
  if (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) {
226
199
  query = Object.assign(Object.assign({}, query), { directPage: true, level: 1, pageNum: (_o = query === null || query === void 0 ? void 0 : query.pageNum) !== null && _o !== void 0 ? _o : 1 });
227
200
  }
228
- const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/list', { method: 'POST', body: query }));
201
+ const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/list', {
202
+ method: 'POST',
203
+ body: query
204
+ }));
229
205
  if (!(result === null || result === void 0 ? void 0 : result.success)) {
230
206
  return undefined;
231
207
  }
@@ -285,7 +261,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
285
261
  const sessionID = storeAndLoadFeSessionId();
286
262
  const params = {};
287
263
  const queryString = location.search.slice(1);
288
- (_a = splitUrlParams(queryString)) === null || _a === void 0 ? void 0 : _a.map((val) => {
264
+ (_a = splitUrlParams(queryString)) === null || _a === void 0 ? void 0 : _a.forEach((val) => {
289
265
  const key = val.split('=')[0];
290
266
  const value = val.split('=')[1];
291
267
  params[key] = value;
@@ -315,17 +291,23 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
315
291
  playbookType,
316
292
  bffDataSource
317
293
  ]);
318
- const getEventParamsByJson = useCallback((json, product) => {
319
- var _a, _b, _c;
320
- const jsonParams = cloneDeep(json);
294
+ const bffFbReport = useCallback(({ eventName, product }) => {
295
+ var _a, _b, _c, _d, _e, _f, _g;
296
+ if (!enableReportEvent ||
297
+ !enabledMetaConversionApi ||
298
+ (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) ||
299
+ !((_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _a === void 0 ? void 0 : _a[eventName])) {
300
+ return;
301
+ }
302
+ const jsonParams = cloneDeep((_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _b === void 0 ? void 0 : _b[eventName]);
321
303
  const urlParams = new URLSearchParams(window.location.search);
322
304
  const fbclid = urlParams === null || urlParams === void 0 ? void 0 : urlParams.get('fbclid');
323
305
  const fix_par = {
324
- event_source_url: (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.href,
306
+ event_source_url: (_c = window === null || window === void 0 ? void 0 : window.location) === null || _c === void 0 ? void 0 : _c.href,
325
307
  external_id: fakeUserId,
326
- client_user_agent: (_c = (_b = window === null || window === void 0 ? void 0 : window.navigator) === null || _b === void 0 ? void 0 : _b.userAgent) !== null && _c !== void 0 ? _c : '',
308
+ client_user_agent: (_e = (_d = window === null || window === void 0 ? void 0 : window.navigator) === null || _d === void 0 ? void 0 : _d.userAgent) !== null && _e !== void 0 ? _e : '',
327
309
  fbc: fbclid ? `fb.2.${new Date().getTime()}.${fbclid}` : '',
328
- fbp: getCookie('_fbp') ? `${getCookie('_fbp')}` : '',
310
+ fbp: getCookie('_fbp') ? `fb.2.${new Date().getTime()}.${getCookie('_fbp')}` : '',
329
311
  time: Math.floor(Date.now() / 1000)
330
312
  };
331
313
  const regex = /\{\{(.*?)\}\}/g;
@@ -337,7 +319,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
337
319
  }
338
320
  else {
339
321
  for (const key in obj) {
340
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
322
+ if (obj.hasOwnProperty(key)) {
341
323
  const value = obj === null || obj === void 0 ? void 0 : obj[key];
342
324
  if (typeof value === 'object') {
343
325
  getEventParams(value);
@@ -374,59 +356,28 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
374
356
  }
375
357
  };
376
358
  getEventParams(jsonParams);
377
- return jsonParams;
378
- }, [fakeUserId]);
379
- const bffFbReport = useCallback(({ eventName, product }) => {
380
- var _a, _b, _c, _d;
381
- if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
382
- return;
383
- }
384
- const pixelEventParamsJson = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.pixel) === null || _a === void 0 ? void 0 : _a[eventName];
385
- if ((pixelEventParamsJson === null || pixelEventParamsJson === void 0 ? void 0 : pixelEventParamsJson.event_name) && typeof (window === null || window === void 0 ? void 0 : window.fbq) === 'function') {
386
- function updateQueryStringParameter(uri, key, value) {
387
- const re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
388
- const separator = uri.indexOf('?') !== -1 ? '&' : '?';
389
- if (uri.match(re)) {
390
- return uri.replace(re, '$1' + key + '=' + value + '$2');
391
- }
392
- else {
393
- return uri + separator + key + '=' + value;
394
- }
395
- }
396
- if (eventName === 'PageView' && (pixelEventParamsJson === null || pixelEventParamsJson === void 0 ? void 0 : pixelEventParamsJson.event_name) === 'PageView') {
397
- const currentUrl = window.location.href;
398
- const newUrl = updateQueryStringParameter(currentUrl, 'timestamp', Date.now());
399
- history.pushState({ path: newUrl }, '', newUrl);
400
- }
401
- else {
402
- const body = getEventParamsByJson(pixelEventParamsJson);
403
- window === null || window === void 0 ? void 0 : window.fbq('track', pixelEventParamsJson === null || pixelEventParamsJson === void 0 ? void 0 : pixelEventParamsJson.event_name, body);
404
- if (eventName === 'PageView' && typeof (window === null || window === void 0 ? void 0 : window.gtag) === 'function') {
405
- window === null || window === void 0 ? void 0 : window.gtag('event', 'page_view');
406
- }
407
- }
408
- }
409
- else if (eventName === 'PageView' && typeof (window === null || window === void 0 ? void 0 : window.gtag) === 'function') {
410
- window === null || window === void 0 ? void 0 : window.gtag('event', 'page_view');
411
- }
412
- const converApiEventParamsJson = (_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _b === void 0 ? void 0 : _b[eventName];
413
- if (enabledMetaConversionApi && converApiEventParamsJson) {
414
- const body = getEventParamsByJson(converApiEventParamsJson, product);
415
- const params = {};
416
- const queryString = location.search.slice(1);
417
- (_c = splitUrlParams(queryString)) === null || _c === void 0 ? void 0 : _c.forEach((val) => {
418
- const key = val.split('=')[0];
419
- const value = val.split('=')[1];
420
- params[key] = value;
421
- });
422
- const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
423
- bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/fb/${(_d = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _d === void 0 ? void 0 : _d['x-app-id']}/${eventName}${cl_source ? `/${decodeURIComponent(cl_source)}` : ''}`, {
424
- method: 'POST',
425
- body,
426
- type: 'beacon'
427
- });
428
- }
429
- }, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig, bffDataSource, getEventParamsByJson]);
359
+ const params = {};
360
+ const queryString = location.search.slice(1);
361
+ (_f = 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)}` : ''}`, {
368
+ method: 'POST',
369
+ body: jsonParams,
370
+ type: 'beacon'
371
+ });
372
+ }, [
373
+ bffFetch,
374
+ enableReportEvent,
375
+ enabledMetaConversionApi,
376
+ globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview,
377
+ globalConfig,
378
+ fakeUserId,
379
+ bffDataSource
380
+ ]);
430
381
  const bffMutateLike = useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
431
382
  const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/like', { method: 'POST', body }));
432
383
  return res === null || res === void 0 ? void 0 : res.success;
@@ -674,7 +625,8 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
674
625
  multiPostTimeRef,
675
626
  refreshFeSession,
676
627
  getAccount,
677
- accountSonsent
628
+ accountSonsent,
629
+ isDiyH5
678
630
  } }, isShowConsent ? (React.createElement(Consent, 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({
679
631
  rtcList,
680
632
  mutateLike: bffMutateLike,
package/es/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/es/index.js CHANGED
@@ -6,6 +6,7 @@ import * as materials_1 from './materials';
6
6
  export { materials_1 as materials };
7
7
  export { default as SxpPageRender } from './core/components/SxpPageRender';
8
8
  export { default as DiyPortalPreview } from './core/components/DiyPortalPreview';
9
+ export { default as DiyStoryPreview } from './core/components/DiyStoryPreview';
9
10
  export { default as Modal } from './core/components/SxpPageRender/Modal';
10
11
  export { default as SxpDataSourceProvider } from './core/context/SxpDataSourceProvider';
11
12
  export { default as SxpPageCore } from './core/components/SxpPageCore';
@@ -1,7 +1,6 @@
1
1
  import { __rest } from "tslib";
2
2
  import { css } from '@emotion/css';
3
3
  import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
- import CommodityGroup from '../../template/components/CommodityGroup';
5
4
  import { useSxpDataSource } from '../../../../core/hooks';
6
5
  import './index.less';
7
6
  import { A11y, Autoplay, Keyboard, Mousewheel, Navigation, Pagination } from 'swiper/modules';
@@ -11,6 +10,7 @@ import Modal from '../../../../core/components/SxpPageRender/Modal';
11
10
  import ExpandableText from '../../../../core/components/SxpPageRender/ExpandableText';
12
11
  import FormatImage from '../../../../core/components/SxpPageRender/FormatImage';
13
12
  import { getScreenReader, setFontForText } from '../../../../core/utils/tool';
13
+ import CommodityGroup from '../../template/components/CommodityGroup';
14
14
  import { getPriceText } from '../../../../core/utils/materials';
15
15
  const CommodityDetail = (_a) => {
16
16
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
@@ -67,7 +67,7 @@ const CommodityDetail = (_a) => {
67
67
  };
68
68
  }, []);
69
69
  const priceText = getPriceText({
70
- product,
70
+ product: product,
71
71
  enableFormattedPrice: (_t = commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.price) === null || _t === void 0 ? void 0 : _t.enableFormattedPrice,
72
72
  globalConfig,
73
73
  style: commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.price
@@ -1,7 +1,6 @@
1
1
  import { __rest } from "tslib";
2
2
  import { css } from '@emotion/css';
3
3
  import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
- import CommodityGroup from '../../template/components/CommodityGroup';
5
4
  import { useSxpDataSource } from '../../../../core/hooks';
6
5
  import './index.less';
7
6
  import { Autoplay, Pagination, Navigation, A11y, Mousewheel, Keyboard } from 'swiper/modules';
@@ -11,6 +10,7 @@ import ExpandableText from '../../../../core/components/SxpPageRender/Expandable
11
10
  import { useEventReport } from '../../../../core/hooks/useEventReport';
12
11
  import FormatImage from '../../../../core/components/SxpPageRender/FormatImage';
13
12
  import { getScreenReader, setFontForText } from '../../../../core/utils/tool';
13
+ import CommodityGroup from '../../template/components/CommodityGroup';
14
14
  import { getPriceText } from '../../../../core/utils/materials';
15
15
  const CommodityDetailDiroNew = (_a) => {
16
16
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
@@ -50,11 +50,16 @@ export interface SeoParameter {
50
50
  key_word: string;
51
51
  }
52
52
  export interface UtmParameter {
53
- utm_source: string;
54
- utm_medium: string;
55
- utm_campaign: string;
56
- channels?: string[];
57
- enabled_meta_conversion_api?: boolean;
53
+ channels: string[];
54
+ enabled_meta_conversion_api: boolean;
55
+ values: string[];
56
+ cos_path: string;
57
+ enabled_google_no_index: boolean;
58
+ enabled_google_analytics: boolean;
59
+ enabled_gtm: boolean;
60
+ enabled_alibaba_cloud: boolean;
61
+ enabled_uptime: boolean;
62
+ experience_id: string | null;
58
63
  }
59
64
  interface PagebuilderProps {
60
65
  init: (e: initParams) => void;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { postConfigType } from '../SxpPageRender';
3
+ import { RecItemType } from '../SxpPageRender/typing';
4
+ interface IPictureGroupProps {
5
+ imgUrls?: string[];
6
+ width: number;
7
+ height: number;
8
+ rec: RecItemType;
9
+ index: number;
10
+ imgUrlsPostConfig?: postConfigType;
11
+ swiperRef?: any;
12
+ data?: RecItemType[];
13
+ loopPlay?: boolean;
14
+ }
15
+ declare const _default: React.NamedExoticComponent<IPictureGroupProps>;
16
+ export default _default;
@@ -0,0 +1,37 @@
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 modules_1 = require("swiper/modules");
6
+ const react_2 = require("swiper/react");
7
+ const Picture_1 = tslib_1.__importDefault(require("../SxpPageRender/PictureGroup/Picture"));
8
+ const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index, swiperRef, data = [], loopPlay }) => {
9
+ const { isActive } = (0, react_2.useSwiperSlide)();
10
+ const [isload, setIsLoad] = (0, react_1.useState)(false);
11
+ (0, react_1.useEffect)(() => {
12
+ if (isActive && isload && loopPlay) {
13
+ setTimeout(() => {
14
+ var _a, _b, _c, _d;
15
+ if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
16
+ (_a = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _a === void 0 ? void 0 : _a.swiper.slideTo(0);
17
+ }
18
+ else {
19
+ 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;
20
+ (_d = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _d === void 0 ? void 0 : _d.swiper.slideTo(i + 1);
21
+ }
22
+ }, 3000);
23
+ }
24
+ }, [isActive, isload, data, index, swiperRef, loopPlay]);
25
+ const loadFinishImage = () => {
26
+ setIsLoad(true);
27
+ };
28
+ return (react_1.default.createElement(react_2.Swiper, { defaultValue: 0, direction: 'horizontal', modules: [modules_1.Pagination, modules_1.Autoplay], pagination: {
29
+ clickable: true,
30
+ bulletActiveClass: 'swipe-item-active-bullet',
31
+ bulletElement: 'button'
32
+ }, height: height, style: { width }, loop: true, autoplay: false }, imgUrls === null || imgUrls === void 0 ? void 0 : imgUrls.map((url) => {
33
+ return (react_1.default.createElement(react_2.SwiperSlide, { key: url },
34
+ react_1.default.createElement(Picture_1.default, { src: url, height: height, imgUrlsPostConfig: imgUrlsPostConfig, onShowFirstImage: loadFinishImage })));
35
+ })));
36
+ };
37
+ exports.default = (0, react_1.memo)(PictureGroup);