pb-sxp-ui 1.0.84 → 1.0.85

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.
package/dist/index.cjs CHANGED
@@ -511,8 +511,8 @@ var DataSourceType;
511
511
  DataSourceType[DataSourceType["BFF"] = 5] = "BFF";
512
512
  })(DataSourceType || (DataSourceType = {}));
513
513
  const UTM_KEYS = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_id', 'utm_content', 'cl_source'];
514
- const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent = true, maxSize, defaultSize, isPreview = false, sxpParameter, appDomain, hashTagSize, loadingImage, isOpenHashTag = false, enabledMetaConversionApi = false, consentHeight, consentWidth, isShowTag = true, isOpenConsent = false, globalConfig }) => {
515
- var _a, _b, _c, _d, _e, _f, _g;
514
+ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent = true, maxSize, defaultSize, isPreview = false, sxpParameter, appDomain, hashTagSize, loadingImage, isOpenHashTag = false, enabledMetaConversionApi = false, consentHeight, consentWidth, isShowTag = true, isOpenConsent = false, globalConfig, isEditor = false }) => {
515
+ var _a, _b, _c;
516
516
  const [rtcList, setRtcList] = React.useState([]);
517
517
  const [tagList, setTagList] = React.useState([]);
518
518
  const [loading, setLoading] = React.useState(false);
@@ -530,6 +530,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
530
530
  const [videoRef, setVideoRef] = React.useState(null);
531
531
  const themeTag = React.useRef();
532
532
  const curTime = React.useRef();
533
+ const isShowConsent = React.useMemo(() => {
534
+ var _a, _b, _c, _d;
535
+ return (((_d = (_c = (_b = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.consent) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.item) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.privacy_necessity) && !isAgreePolicy && !isEditor) || isOpenConsent;
536
+ }, [isAgreePolicy, globalConfig, isOpenConsent, isEditor]);
533
537
  React.useEffect(() => {
534
538
  const handleChangeThemeTag = (tag) => {
535
539
  themeTag.current = tag;
@@ -574,10 +578,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
574
578
  }, [bffDataSource]);
575
579
  // 获取推荐视频数据
576
580
  const getRecommendVideos = React.useCallback((query) => __awaiter(void 0, void 0, void 0, function* () {
577
- var _h, _j, _k, _l, _m;
581
+ var _d, _e, _f, _g, _h;
578
582
  query = {
579
- maxSize: (_h = query === null || query === void 0 ? void 0 : query.maxSize) !== null && _h !== void 0 ? _h : maxSize,
580
- defaultSize: (_j = query === null || query === void 0 ? void 0 : query.defaultSize) !== null && _j !== void 0 ? _j : defaultSize,
583
+ maxSize: (_d = query === null || query === void 0 ? void 0 : query.maxSize) !== null && _d !== void 0 ? _d : maxSize,
584
+ defaultSize: (_e = query === null || query === void 0 ? void 0 : query.defaultSize) !== null && _e !== void 0 ? _e : defaultSize,
581
585
  'itemFilter.itemId': query === null || query === void 0 ? void 0 : query['itemFilter.itemId'],
582
586
  'itemFilter.itemType': query === null || query === void 0 ? void 0 : query['itemFilter.itemType'],
583
587
  hashTag: query === null || query === void 0 ? void 0 : query.hashTag,
@@ -585,10 +589,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
585
589
  themeTag: query === null || query === void 0 ? void 0 : query.themeTag
586
590
  };
587
591
  if (utmVal) {
588
- const val = (_m = (_l = (_k = utmVal === null || utmVal === void 0 ? void 0 : utmVal.split('&')) === null || _k === void 0 ? void 0 : _k.filter((val) => {
592
+ const val = (_h = (_g = (_f = utmVal === null || utmVal === void 0 ? void 0 : utmVal.split('&')) === null || _f === void 0 ? void 0 : _f.filter((val) => {
589
593
  const key = val.split('=')[0];
590
594
  return UTM_KEYS.includes(key);
591
- })) === null || _l === void 0 ? void 0 : _l.join('&')) !== null && _m !== void 0 ? _m : '';
595
+ })) === null || _g === void 0 ? void 0 : _g.join('&')) !== null && _h !== void 0 ? _h : '';
592
596
  query = Object.assign(Object.assign({}, query), { channel: decodeURIComponent(val) });
593
597
  }
594
598
  const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/recommend/list', { method: 'GET', query }));
@@ -600,7 +604,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
600
604
  return result === null || result === void 0 ? void 0 : result.data;
601
605
  }), [bffFetch, utmVal, maxSize, defaultSize]);
602
606
  const loadVideos = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
603
- var _o, _p;
607
+ var _j, _k;
604
608
  if (rtcList.length <= 0) {
605
609
  return;
606
610
  }
@@ -610,8 +614,8 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
610
614
  'itemFilter.itemType': waterFallData === null || waterFallData === void 0 ? void 0 : waterFallData.itemType,
611
615
  themeTag: themeTag.current
612
616
  });
613
- setRtcList(rtcList.concat((_o = data === null || data === void 0 ? void 0 : data.recList) !== null && _o !== void 0 ? _o : []));
614
- setCacheRtcList(cacheRtcList.concat((_p = data === null || data === void 0 ? void 0 : data.recList) !== null && _p !== void 0 ? _p : []));
617
+ setRtcList(rtcList.concat((_j = data === null || data === void 0 ? void 0 : data.recList) !== null && _j !== void 0 ? _j : []));
618
+ setCacheRtcList(cacheRtcList.concat((_k = data === null || data === void 0 ? void 0 : data.recList) !== null && _k !== void 0 ? _k : []));
615
619
  }), [getRecommendVideos, rtcList, waterFallData, cacheRtcList]);
616
620
  const bffEventReport = React.useCallback(({ userInfo, eventInfo }) => {
617
621
  // 关闭 BFF 事件上报
@@ -675,16 +679,16 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
675
679
  }), [bffFetch]);
676
680
  // 获取 Tag
677
681
  const bffGetTagList = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
678
- var _q, _r, _s, _t, _u;
682
+ var _l, _m, _o, _p, _q;
679
683
  if (!utmVal || !isShowTag)
680
684
  return;
681
685
  try {
682
- const val = (_s = (_r = (_q = utmVal === null || utmVal === void 0 ? void 0 : utmVal.split('&')) === null || _q === void 0 ? void 0 : _q.filter((val) => {
686
+ const val = (_o = (_m = (_l = utmVal === null || utmVal === void 0 ? void 0 : utmVal.split('&')) === null || _l === void 0 ? void 0 : _l.filter((val) => {
683
687
  const key = val.split('=')[0];
684
688
  return UTM_KEYS.includes(key);
685
- })) === null || _r === void 0 ? void 0 : _r.join('&')) !== null && _s !== void 0 ? _s : '';
689
+ })) === null || _m === void 0 ? void 0 : _m.join('&')) !== null && _o !== void 0 ? _o : '';
686
690
  const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/tag/list', { method: 'GET', query: { channel: decodeURIComponent(val) } }));
687
- setTagList((_u = (_t = result === null || result === void 0 ? void 0 : result.data) === null || _t === void 0 ? void 0 : _t.tags) !== null && _u !== void 0 ? _u : []);
691
+ setTagList((_q = (_p = result === null || result === void 0 ? void 0 : result.data) === null || _p === void 0 ? void 0 : _p.tags) !== null && _q !== void 0 ? _q : []);
688
692
  }
689
693
  catch (e) {
690
694
  console.log('e', e);
@@ -738,7 +742,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
738
742
  h5EnterLink();
739
743
  }, []);
740
744
  React.useEffect(() => {
741
- if (!isAgreePolicy)
745
+ if (isShowConsent)
742
746
  return;
743
747
  setLoading(true);
744
748
  bffGetTagList();
@@ -758,7 +762,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
758
762
  setLoading(false);
759
763
  isInit.current = true;
760
764
  });
761
- }, [isAgreePolicy]);
765
+ }, [isShowConsent]);
762
766
  React.useEffect(() => {
763
767
  if (!isInit.current)
764
768
  return;
@@ -816,7 +820,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
816
820
  curTime,
817
821
  h5EnterLink,
818
822
  themeTag
819
- } }, (((_d = (_c = (_b = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.consent) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.item) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.privacy_necessity) && !isAgreePolicy) || isOpenConsent ? (React.createElement(Consent$3, Object.assign({}, (_g = (_f = (_e = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.consent) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.item) === null || _g === void 0 ? void 0 : _g.props))) : (render({
823
+ } }, isShowConsent ? (React.createElement(Consent$3, Object.assign({}, (_c = (_b = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.consent) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.item) === null || _c === void 0 ? void 0 : _c.props))) : (render({
820
824
  rtcList,
821
825
  mutateLike: bffMutateLike,
822
826
  mutateUnlike: bffMutateUnlike,