pb-sxp-ui 14.0.2 → 14.0.3

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.
@@ -1,13 +1,13 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import React, { createContext, memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
3
  import qs from 'qs';
4
+ import { cloneDeep } from 'lodash';
4
5
  import { refreshFeSessionId, storeAndLoadFeSessionId } from '../utils/sessionStore';
5
6
  import { storeAndLoadFeUserId, AGREE_POLICY } from '../utils/localStore';
6
7
  import { useIconLink } from '../components/SxpPageRender/useIconLink';
7
8
  import SXP_EVENT_BUS, { SXP_EVENT_TYPE } from '../utils/event';
8
9
  import Consent from '../components/Consent';
9
10
  import { getCookie } from '../utils/tool';
10
- import { cloneDeep } from 'lodash';
11
11
  export const SxpDataSourceContext = createContext({
12
12
  rtcList: [],
13
13
  tagList: []
@@ -167,8 +167,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
167
167
  }
168
168
  setLoading(false);
169
169
  list = list.concat((_y = (_x = (_w = (_v = result === null || result === void 0 ? void 0 : result.data) === null || _v === void 0 ? void 0 : _v.recList) === null || _w === void 0 ? void 0 : _w.filter) === null || _x === void 0 ? void 0 : _x.call(_w, (item) => (item === null || item === void 0 ? void 0 : item.product) || (item === null || item === void 0 ? void 0 : item.video))) !== null && _y !== void 0 ? _y : []);
170
- setRtcList(getFilterRecList(Object.assign(Object.assign({}, result.data), { recList: list })));
171
- setCacheRtcList(getFilterRecList(Object.assign(Object.assign({}, result.data), { recList: list })));
170
+ if ((rtcList === null || rtcList === void 0 ? void 0 : rtcList.length) === 0) {
171
+ setRtcList(getFilterRecList(Object.assign(Object.assign({}, result === null || result === void 0 ? void 0 : result.data), { recList: list })));
172
+ setCacheRtcList(getFilterRecList(Object.assign(Object.assign({}, result === null || result === void 0 ? void 0 : result.data), { recList: list })));
173
+ }
172
174
  const isNotNullList = (_0 = (_z = result === null || result === void 0 ? void 0 : result.data) === null || _z === void 0 ? void 0 : _z.recList) === null || _0 === void 0 ? void 0 : _0.some((item) => (item === null || item === void 0 ? void 0 : item.product) || (item === null || item === void 0 ? void 0 : item.video));
173
175
  if (isNotNullList) {
174
176
  pageNum = pageNum + 1;
@@ -178,7 +180,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
178
180
  yield recurveRecList(query);
179
181
  if (!(query === null || query === void 0 ? void 0 : query.hashTag) && result)
180
182
  setCurReqInfo({ rtc: (_l = result === null || result === void 0 ? void 0 : result.data) === null || _l === void 0 ? void 0 : _l.rtc, requestId: (_m = result === null || result === void 0 ? void 0 : result.data) === null || _m === void 0 ? void 0 : _m.requestId });
181
- return Object.assign(Object.assign({}, result.data), { recList: list });
183
+ return Object.assign(Object.assign({}, result === null || result === void 0 ? void 0 : result.data), { recList: list });
182
184
  }
183
185
  if (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) {
184
186
  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 });
@@ -233,7 +235,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
233
235
  return expire;
234
236
  }, [data]);
235
237
  const bffEventReport = useCallback(({ userInfo, eventInfo, reportLayId = true }) => {
236
- var _a;
238
+ var _a, _b;
237
239
  if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
238
240
  return;
239
241
  }
@@ -241,7 +243,9 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
241
243
  userInfo = {};
242
244
  }
243
245
  const sessionID = storeAndLoadFeSessionId();
244
- const ef = Object.assign(Object.assign(Object.assign(Object.assign({ sessionID, rtc: curReqInfo.rtc, requestId: curReqInfo.requestId }, { playbookType }), (layoutVariantId && reportLayId && { layoutVariantId })), eventInfo), ((eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.position) && channel && { position: Number(eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.position) + 1 + '' }));
246
+ const urlParams = new URLSearchParams((_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.search);
247
+ const cl_source = urlParams === null || urlParams === void 0 ? void 0 : urlParams.get('cl_source');
248
+ const ef = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ sessionID, rtc: curReqInfo.rtc, requestId: curReqInfo.requestId }, { playbookType }), (layoutVariantId && reportLayId && { layoutVariantId })), eventInfo), ((eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.position) && channel && { position: Number(eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.position) + 1 + '' })), (cl_source && { cl_source }));
245
249
  const realUserInfo = Object.entries(userInfo).map(([k, v]) => ({ name: k, value: v }));
246
250
  const realEventInfo = Object.entries(ef)
247
251
  .map(([k, v]) => v && { name: k, value: v })
@@ -250,7 +254,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
250
254
  console.log('userInfo:', userInfo);
251
255
  console.log('eventInfo:', ef);
252
256
  console.log('========= 结束 =========');
253
- return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/event/report/CLD/${(_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']}/${eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.eventSubject}`, {
257
+ return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/event/report/CLD/${(_b = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _b === void 0 ? void 0 : _b['x-app-id']}/${eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.eventSubject}`, {
254
258
  method: 'POST',
255
259
  body: { userInfo: realUserInfo, eventInfo: realEventInfo },
256
260
  type: 'beacon'
@@ -273,7 +277,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
273
277
  !((_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _a === void 0 ? void 0 : _a[eventName])) {
274
278
  return;
275
279
  }
276
- let jsonParams = cloneDeep((_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _b === void 0 ? void 0 : _b[eventName]);
280
+ const jsonParams = cloneDeep((_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _b === void 0 ? void 0 : _b[eventName]);
277
281
  const urlParams = new URLSearchParams(window.location.search);
278
282
  const fbclid = urlParams === null || urlParams === void 0 ? void 0 : urlParams.get('fbclid');
279
283
  const fix_par = {
@@ -4,13 +4,13 @@ exports.DEFAULT_TAG = exports.SxpDataSourceContext = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importStar(require("react"));
6
6
  const qs_1 = tslib_1.__importDefault(require("qs"));
7
+ const lodash_1 = require("lodash");
7
8
  const sessionStore_1 = require("../utils/sessionStore");
8
9
  const localStore_1 = require("../utils/localStore");
9
10
  const useIconLink_1 = require("../components/SxpPageRender/useIconLink");
10
11
  const event_1 = tslib_1.__importStar(require("../utils/event"));
11
12
  const Consent_1 = tslib_1.__importDefault(require("../components/Consent"));
12
13
  const tool_1 = require("../utils/tool");
13
- const lodash_1 = require("lodash");
14
14
  exports.SxpDataSourceContext = (0, react_1.createContext)({
15
15
  rtcList: [],
16
16
  tagList: []
@@ -170,8 +170,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
170
170
  }
171
171
  setLoading(false);
172
172
  list = list.concat((_y = (_x = (_w = (_v = result === null || result === void 0 ? void 0 : result.data) === null || _v === void 0 ? void 0 : _v.recList) === null || _w === void 0 ? void 0 : _w.filter) === null || _x === void 0 ? void 0 : _x.call(_w, (item) => (item === null || item === void 0 ? void 0 : item.product) || (item === null || item === void 0 ? void 0 : item.video))) !== null && _y !== void 0 ? _y : []);
173
- setRtcList(getFilterRecList(Object.assign(Object.assign({}, result.data), { recList: list })));
174
- setCacheRtcList(getFilterRecList(Object.assign(Object.assign({}, result.data), { recList: list })));
173
+ if ((rtcList === null || rtcList === void 0 ? void 0 : rtcList.length) === 0) {
174
+ setRtcList(getFilterRecList(Object.assign(Object.assign({}, result === null || result === void 0 ? void 0 : result.data), { recList: list })));
175
+ setCacheRtcList(getFilterRecList(Object.assign(Object.assign({}, result === null || result === void 0 ? void 0 : result.data), { recList: list })));
176
+ }
175
177
  const isNotNullList = (_0 = (_z = result === null || result === void 0 ? void 0 : result.data) === null || _z === void 0 ? void 0 : _z.recList) === null || _0 === void 0 ? void 0 : _0.some((item) => (item === null || item === void 0 ? void 0 : item.product) || (item === null || item === void 0 ? void 0 : item.video));
176
178
  if (isNotNullList) {
177
179
  pageNum = pageNum + 1;
@@ -181,7 +183,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
181
183
  yield recurveRecList(query);
182
184
  if (!(query === null || query === void 0 ? void 0 : query.hashTag) && result)
183
185
  setCurReqInfo({ rtc: (_l = result === null || result === void 0 ? void 0 : result.data) === null || _l === void 0 ? void 0 : _l.rtc, requestId: (_m = result === null || result === void 0 ? void 0 : result.data) === null || _m === void 0 ? void 0 : _m.requestId });
184
- return Object.assign(Object.assign({}, result.data), { recList: list });
186
+ return Object.assign(Object.assign({}, result === null || result === void 0 ? void 0 : result.data), { recList: list });
185
187
  }
186
188
  if (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) {
187
189
  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 });
@@ -236,7 +238,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
236
238
  return expire;
237
239
  }, [data]);
238
240
  const bffEventReport = (0, react_1.useCallback)(({ userInfo, eventInfo, reportLayId = true }) => {
239
- var _a;
241
+ var _a, _b;
240
242
  if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
241
243
  return;
242
244
  }
@@ -244,7 +246,9 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
244
246
  userInfo = {};
245
247
  }
246
248
  const sessionID = (0, sessionStore_1.storeAndLoadFeSessionId)();
247
- const ef = Object.assign(Object.assign(Object.assign(Object.assign({ sessionID, rtc: curReqInfo.rtc, requestId: curReqInfo.requestId }, { playbookType }), (layoutVariantId && reportLayId && { layoutVariantId })), eventInfo), ((eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.position) && channel && { position: Number(eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.position) + 1 + '' }));
249
+ const urlParams = new URLSearchParams((_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.search);
250
+ const cl_source = urlParams === null || urlParams === void 0 ? void 0 : urlParams.get('cl_source');
251
+ const ef = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ sessionID, rtc: curReqInfo.rtc, requestId: curReqInfo.requestId }, { playbookType }), (layoutVariantId && reportLayId && { layoutVariantId })), eventInfo), ((eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.position) && channel && { position: Number(eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.position) + 1 + '' })), (cl_source && { cl_source }));
248
252
  const realUserInfo = Object.entries(userInfo).map(([k, v]) => ({ name: k, value: v }));
249
253
  const realEventInfo = Object.entries(ef)
250
254
  .map(([k, v]) => v && { name: k, value: v })
@@ -253,7 +257,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
253
257
  console.log('userInfo:', userInfo);
254
258
  console.log('eventInfo:', ef);
255
259
  console.log('========= 结束 =========');
256
- return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/event/report/CLD/${(_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']}/${eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.eventSubject}`, {
260
+ return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/event/report/CLD/${(_b = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _b === void 0 ? void 0 : _b['x-app-id']}/${eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.eventSubject}`, {
257
261
  method: 'POST',
258
262
  body: { userInfo: realUserInfo, eventInfo: realEventInfo },
259
263
  type: 'beacon'
@@ -276,7 +280,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
276
280
  !((_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _a === void 0 ? void 0 : _a[eventName])) {
277
281
  return;
278
282
  }
279
- let jsonParams = (0, lodash_1.cloneDeep)((_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _b === void 0 ? void 0 : _b[eventName]);
283
+ const jsonParams = (0, lodash_1.cloneDeep)((_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _b === void 0 ? void 0 : _b[eventName]);
280
284
  const urlParams = new URLSearchParams(window.location.search);
281
285
  const fbclid = urlParams === null || urlParams === void 0 ? void 0 : urlParams.get('fbclid');
282
286
  const fix_par = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pb-sxp-ui",
3
- "version": "14.0.2",
3
+ "version": "14.0.3",
4
4
  "description": "React enterprise-class UI components",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",