pb-sxp-ui 1.10.12 → 1.11.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 (35) hide show
  1. package/dist/index.cjs +61 -38
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +61 -38
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.min.cjs +4 -4
  6. package/dist/index.min.cjs.map +1 -1
  7. package/dist/index.min.js +4 -4
  8. package/dist/index.min.js.map +1 -1
  9. package/dist/pb-ui.js +61 -38
  10. package/dist/pb-ui.js.map +1 -1
  11. package/dist/pb-ui.min.js +4 -4
  12. package/dist/pb-ui.min.js.map +1 -1
  13. package/es/core/components/SxpPageRender/index.d.ts +4 -0
  14. package/es/core/components/SxpPageRender/index.js +2 -4
  15. package/es/core/context/EditorDataProvider.d.ts +1 -0
  16. package/es/core/context/EditorDataProvider.js +3 -2
  17. package/es/core/context/SxpDataSourceProvider.d.ts +1 -0
  18. package/es/core/context/SxpDataSourceProvider.js +39 -8
  19. package/es/core/utils/sessionStore.d.ts +1 -0
  20. package/es/core/utils/sessionStore.js +5 -5
  21. package/es/materials/sxp/popup/Iframe/index.d.ts +0 -4
  22. package/es/materials/sxp/popup/Iframe/index.js +4 -5
  23. package/es/materials/sxp/popup/Iframe/settingRender.js +0 -15
  24. package/lib/core/components/SxpPageRender/index.d.ts +4 -0
  25. package/lib/core/components/SxpPageRender/index.js +2 -4
  26. package/lib/core/context/EditorDataProvider.d.ts +1 -0
  27. package/lib/core/context/EditorDataProvider.js +3 -2
  28. package/lib/core/context/SxpDataSourceProvider.d.ts +1 -0
  29. package/lib/core/context/SxpDataSourceProvider.js +38 -7
  30. package/lib/core/utils/sessionStore.d.ts +1 -0
  31. package/lib/core/utils/sessionStore.js +7 -6
  32. package/lib/materials/sxp/popup/Iframe/index.d.ts +0 -4
  33. package/lib/materials/sxp/popup/Iframe/index.js +4 -5
  34. package/lib/materials/sxp/popup/Iframe/settingRender.js +0 -15
  35. package/package.json +1 -1
package/dist/pb-ui.js CHANGED
@@ -497,17 +497,17 @@
497
497
  let result = getFeSessionId();
498
498
  if (!result) {
499
499
  result = generateFeSessionId();
500
- window.sessionStorage.setItem(feRealSessionIdKey, result);
500
+ window.localStorage.setItem(feRealSessionIdKey, result);
501
501
  }
502
502
  return result;
503
503
  };
504
504
  const refreshFeSessionId = () => {
505
505
  const result = generateFeSessionId();
506
- window.sessionStorage.setItem(feRealSessionIdKey, result);
506
+ window.localStorage.setItem(feRealSessionIdKey, result);
507
507
  };
508
508
  // 获取 sessionID
509
509
  const getFeSessionId = () => {
510
- return window.sessionStorage.getItem(feRealSessionIdKey);
510
+ return window.localStorage.getItem(feRealSessionIdKey);
511
511
  };
512
512
 
513
513
  const FAKE_USER_KEY = 'SXP_FAKE_USER_ID';
@@ -847,6 +847,23 @@
847
847
  setCacheRtcList(cacheRtcList.concat(getFilterRecList(data)));
848
848
  return data;
849
849
  }), [getRecommendVideos, rtcList, waterFallData, cacheRtcList]);
850
+ const refreshFeSession = React.useCallback((enableReSid) => {
851
+ var _a, _b, _c, _d, _e;
852
+ const defaultGlobalConfig = (_b = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.sxpPageConf) === null || _b === void 0 ? void 0 : _b.globalConfig;
853
+ if ((_c = defaultGlobalConfig === null || defaultGlobalConfig === void 0 ? void 0 : defaultGlobalConfig.session) === null || _c === void 0 ? void 0 : _c.enable) {
854
+ const sessionStartTime = localStorage.getItem('sessionStartTime');
855
+ const sst = sessionStartTime ? new Date(sessionStartTime) : new Date();
856
+ if (Math.floor((new Date() - sst) / (1000 * 60)) >=
857
+ ((_e = (_d = defaultGlobalConfig === null || defaultGlobalConfig === void 0 ? void 0 : defaultGlobalConfig.session) === null || _d === void 0 ? void 0 : _d.expires) !== null && _e !== void 0 ? _e : 30)) {
858
+ refreshFeSessionId();
859
+ curTime.current = new Date();
860
+ }
861
+ localStorage.setItem('sessionStartTime', new Date().toISOString());
862
+ }
863
+ else if (enableReSid) {
864
+ refreshFeSessionId();
865
+ }
866
+ }, [data]);
850
867
  const bffEventReport = React.useCallback(({ userInfo, eventInfo, reportLayId = true }) => {
851
868
  // 关闭 BFF 事件上报
852
869
  if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
@@ -859,6 +876,7 @@
859
876
  // tpChannelId: 'H5' // 后端处理
860
877
  };
861
878
  }
879
+ refreshFeSession();
862
880
  const sessionID = storeAndLoadFeSessionId();
863
881
  const ef = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ sessionID, rtc: curReqInfo.rtc, requestId: curReqInfo.requestId }, { playbookType }), (layoutVariantId && reportLayId && { layoutVariantId })), eventInfo), (getDevice$1() && { sxpDevice: getDevice$1() })), (getSystem() && { sxpSystem: getSystem() })), (getBrowserInfo() && { sxpBrowser: getBrowserInfo() })), ((eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.position) && channel && { position: Number(eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.position) + 1 + '' }));
864
882
  const realUserInfo = Object.entries(userInfo).map(([k, v]) => ({ name: k, value: v }));
@@ -874,7 +892,16 @@
874
892
  body: { userInfo: realUserInfo, eventInfo: realEventInfo },
875
893
  type: 'beacon'
876
894
  });
877
- }, [bffFetch, curReqInfo, enableReportEvent, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview, layoutVariantId, globalConfig, playbookType]);
895
+ }, [
896
+ bffFetch,
897
+ curReqInfo,
898
+ enableReportEvent,
899
+ globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview,
900
+ layoutVariantId,
901
+ globalConfig,
902
+ playbookType,
903
+ refreshFeSession
904
+ ]);
878
905
  const bffFbReport = React.useCallback(({ eventName, product }) => {
879
906
  var _a, _b, _c, _d, _e;
880
907
  if (!enableReportEvent ||
@@ -1000,7 +1027,7 @@
1000
1027
  });
1001
1028
  }, [bffEventReport, isFromHashtag]);
1002
1029
  const h5EnterLink = React.useCallback(() => {
1003
- var _a, _b;
1030
+ var _a, _b, _c, _d, _e;
1004
1031
  const queryString = location.search.slice(1);
1005
1032
  const params = qs.parse(queryString.replace(/\+/g, '%2B'));
1006
1033
  for (const key in params) {
@@ -1008,7 +1035,10 @@
1008
1035
  }
1009
1036
  const getVal = (key) => { var _a; return (_a = params[key]) !== null && _a !== void 0 ? _a : ''; };
1010
1037
  const time = new Date();
1011
- curTime.current = time;
1038
+ const defaultGlobalConfig = (_b = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.sxpPageConf) === null || _b === void 0 ? void 0 : _b.globalConfig;
1039
+ if (!((_c = defaultGlobalConfig === null || defaultGlobalConfig === void 0 ? void 0 : defaultGlobalConfig.session) === null || _c === void 0 ? void 0 : _c.enable) || !(curTime === null || curTime === void 0 ? void 0 : curTime.current)) {
1040
+ curTime.current = time;
1041
+ }
1012
1042
  bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
1013
1043
  eventInfo: {
1014
1044
  eventSubject: 'h5LinkEnterFeed',
@@ -1020,16 +1050,16 @@
1020
1050
  utmContent: getVal('utm_content'),
1021
1051
  enterTime: Math.floor(time / 1000) + '',
1022
1052
  requestId: null,
1023
- enterUrl: (_b = (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.href) !== null && _b !== void 0 ? _b : '',
1053
+ enterUrl: (_e = (_d = window === null || window === void 0 ? void 0 : window.location) === null || _d === void 0 ? void 0 : _d.href) !== null && _e !== void 0 ? _e : '',
1024
1054
  clSource: getVal('cl_source')
1025
1055
  },
1026
1056
  reportLayId: false
1027
1057
  });
1028
- }, [bffEventReport]);
1058
+ }, [bffEventReport, data, curTime]);
1029
1059
  React.useEffect(() => {
1030
1060
  if (!isShowConsent)
1031
1061
  h5EnterLink();
1032
- }, [isShowConsent]);
1062
+ }, [isShowConsent, h5EnterLink]);
1033
1063
  React.useEffect(() => {
1034
1064
  if (isShowConsent || isPreview)
1035
1065
  return;
@@ -1173,7 +1203,8 @@
1173
1203
  channel,
1174
1204
  eventTimeList,
1175
1205
  setEventTimeList,
1176
- multiPostTimeRef
1206
+ multiPostTimeRef,
1207
+ refreshFeSession
1177
1208
  } }, isShowConsent ? (React.createElement(Consent$4, 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({
1178
1209
  rtcList,
1179
1210
  mutateLike: bffMutateLike,
@@ -11996,7 +12027,7 @@ Made in Italy` })));
11996
12027
  * @Author: binruan@chatlabs.com
11997
12028
  * @Date: 2023-10-27 14:06:35
11998
12029
  * @LastEditors: binruan@chatlabs.com
11999
- * @LastEditTime: 2024-12-12 15:12:57
12030
+ * @LastEditTime: 2024-08-08 17:32:11
12000
12031
  * @FilePath: \pb-sxp-ui\src\materials\sxp\popup\Iframe\settingRender.tsx
12001
12032
  *
12002
12033
  */
@@ -12010,32 +12041,16 @@ Made in Italy` })));
12010
12041
  name: ['style', 'backgroundColor']
12011
12042
  }
12012
12043
  ]
12013
- },
12014
- {
12015
- title: 'iframe',
12016
- child: [
12017
- {
12018
- type: 'TextArea',
12019
- label: 'url',
12020
- name: ['props', 'iframe', 'src']
12021
- },
12022
- {
12023
- type: 'TextArea',
12024
- label: 'allow',
12025
- name: ['props', 'iframe', 'allow']
12026
- }
12027
- ]
12028
12044
  }
12029
12045
  ];
12030
12046
 
12031
12047
  const Iframe$1 = (_a) => {
12032
12048
  var _b, _c;
12033
- var { content, btnText, style, icon, isPopup, isExternalLink, onClose, onClick, submitButtonStyle, contentStyle, isTel, iframe } = _a, props = __rest(_a, ["content", "btnText", "style", "icon", "isPopup", "isExternalLink", "onClose", "onClick", "submitButtonStyle", "contentStyle", "isTel", "iframe"]);
12049
+ var { content, btnText, style, icon, isPopup, isExternalLink, onClose, onClick, submitButtonStyle, contentStyle, isTel } = _a, props = __rest(_a, ["content", "btnText", "style", "icon", "isPopup", "isExternalLink", "onClose", "onClick", "submitButtonStyle", "contentStyle", "isTel"]);
12034
12050
  const { popupDetailData } = useSxpDataSource();
12035
- const { src, allow } = iframe || {};
12036
- const iframeUrl = src || ((_c = (_b = popupDetailData === null || popupDetailData === void 0 ? void 0 : popupDetailData.video) === null || _b === void 0 ? void 0 : _b.bindCta) === null || _c === void 0 ? void 0 : _c.remark);
12037
- return (React.createElement("div", Object.assign({ className: `${css.css(Object.assign(Object.assign({}, style), { overflow: 'hidden' }))}` }, props),
12038
- React.createElement("iframe", { src: iframeUrl, allow: allow, scrolling: 'no', style: {
12051
+ const iframeUrl = (_c = (_b = popupDetailData === null || popupDetailData === void 0 ? void 0 : popupDetailData.video) === null || _b === void 0 ? void 0 : _b.bindCta) === null || _c === void 0 ? void 0 : _c.remark;
12052
+ return (React.createElement("div", Object.assign({ className: `${css.css(Object.assign({}, style))}` }, props),
12053
+ React.createElement("iframe", { src: iframeUrl, style: {
12039
12054
  width: '100%',
12040
12055
  height: 'calc(100% - 50px)',
12041
12056
  marginTop: '50px',
@@ -16618,13 +16633,13 @@ Made in Italy` })));
16618
16633
  * @Author: binruan@chatlabs.com
16619
16634
  * @Date: 2023-12-26 10:38:53
16620
16635
  * @LastEditors: binruan@chatlabs.com
16621
- * @LastEditTime: 2024-10-29 18:04:27
16636
+ * @LastEditTime: 2024-12-11 18:24:31
16622
16637
  * @FilePath: \pb-sxp-ui\src\core\context\EditorDataProvider.tsx
16623
16638
  *
16624
16639
  */
16625
16640
  const EditorDataContext = React.createContext({});
16626
16641
  const EditorDataProvider = ({ children, data }) => {
16627
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
16642
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
16628
16643
  const [openHashtag, setOpenHashtag] = React.useState(false);
16629
16644
  const [openConsent, setOpenConsent] = React.useState(false);
16630
16645
  const [consentPopupCate, setConsentPopupCate] = React.useState('');
@@ -16655,7 +16670,8 @@ Made in Italy` })));
16655
16670
  consentPopupCate,
16656
16671
  setConsentPopupCate,
16657
16672
  openMultiPosts,
16658
- setOpenMultiPosts
16673
+ setOpenMultiPosts,
16674
+ pageTypeList: (_p = data === null || data === void 0 ? void 0 : data.pageTypeList) !== null && _p !== void 0 ? _p : []
16659
16675
  } }, children));
16660
16676
  };
16661
16677
  function useEditorDataProvider() {
@@ -17979,6 +17995,14 @@ Made in Italy` })));
17979
17995
  };
17980
17996
  var NavBack$1 = React.memo(NavBack);
17981
17997
 
17998
+ /*
17999
+ * @Author: binruan@chatlabs.com
18000
+ * @Date: 2024-03-20 10:27:31
18001
+ * @LastEditors: binruan@chatlabs.com
18002
+ * @LastEditTime: 2024-12-16 15:03:38
18003
+ * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
18004
+ *
18005
+ */
17982
18006
  const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.innerHeight, containerWidth = window.innerWidth, tempMap, resolver, data = [], ctaType, tipText, nudge, _schema, hashTagStyle, hashTagRightMargin, tagList = [], licenseUrl }) => {
17983
18007
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
17984
18008
  const mutedIcon = useIconLink('/pb_static/5beaaa5ce7f3477b99db3838619cc471.png');
@@ -17994,13 +18018,13 @@ Made in Italy` })));
17994
18018
  const [isReload, setIsReload] = React.useState(new Date().getTime());
17995
18019
  const skipLinkRef = React.useRef(false);
17996
18020
  const [pageNum, setPageNum] = React.useState(2);
17997
- 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 } = useSxpDataSource();
18021
+ 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();
17998
18022
  const { backMainFeed, productView, jumpToWeb } = useEventReport();
17999
18023
  const isShowFingerTip = React.useMemo(() => {
18000
18024
  return data.length > 0 && !loading && (getFeUserState() || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip));
18001
18025
  }, [data, loading, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip]);
18002
18026
  React.useEffect(() => {
18003
- refreshFeSessionId();
18027
+ refreshFeSession === null || refreshFeSession === void 0 ? void 0 : refreshFeSession(true);
18004
18028
  }, []);
18005
18029
  React.useEffect(() => {
18006
18030
  if ((data === null || data === void 0 ? void 0 : data.length) > 0) {
@@ -18009,7 +18033,6 @@ Made in Italy` })));
18009
18033
  }
18010
18034
  }, [data === null || data === void 0 ? void 0 : data.length]);
18011
18035
  const handleH5EnterLink = React.useCallback(() => {
18012
- refreshFeSessionId();
18013
18036
  h5EnterLink === null || h5EnterLink === void 0 ? void 0 : h5EnterLink();
18014
18037
  if (data.length > 0) {
18015
18038
  const now = new Date();
@@ -18916,7 +18939,7 @@ Made in Italy` })));
18916
18939
  * @Author: binruan@chatlabs.com
18917
18940
  * @Date: 2023-10-31 10:56:01
18918
18941
  * @LastEditors: binruan@chatlabs.com
18919
- * @LastEditTime: 2024-12-12 14:48:31
18942
+ * @LastEditTime: 2024-10-23 15:07:29
18920
18943
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\Popup\index.tsx
18921
18944
  *
18922
18945
  */