pb-sxp-ui 1.19.16 → 1.19.18

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
@@ -19001,98 +19001,64 @@ const NavBack = ({ data, minusHeight, tagHeight, onClick }) => {
19001
19001
  var NavBack$1 = React.memo(NavBack);
19002
19002
 
19003
19003
  const useVisibleHeight = () => {
19004
- var _a, _b;
19005
19004
  const [visibleHeight, setVisibleHeight] = React.useState(0);
19006
- const getDvhInPx = () => {
19007
- const detector = document.createElement('div');
19008
- detector.style.position = 'fixed';
19009
- detector.style.bottom = `${getHeightWithSafeArea()}px`;
19010
- detector.style.left = '0';
19011
- detector.style.height = '100dvh';
19012
- detector.style.visibility = 'hidden';
19013
- detector.style.zIndex = '-1';
19014
- document.body.appendChild(detector);
19015
- const dvhInPx = detector.clientHeight;
19016
- document.body.removeChild(detector);
19017
- return dvhInPx;
19018
- };
19019
- const getVhInPx = () => {
19020
- const detector = document.createElement('div');
19021
- detector.style.position = 'fixed';
19022
- detector.style.bottom = `${getHeightWithSafeArea()}px`;
19023
- detector.style.left = '0';
19024
- detector.style.height = '100vh';
19025
- detector.style.visibility = 'hidden';
19026
- detector.style.zIndex = '-1';
19027
- document.body.appendChild(detector);
19028
- const dvhInPx = detector.clientHeight;
19029
- document.body.removeChild(detector);
19030
- return dvhInPx;
19031
- };
19032
- const getFillAvailableInPx = () => {
19033
- const detector = document.createElement('div');
19034
- detector.style.position = 'fixed';
19035
- detector.style.bottom = `${getHeightWithSafeArea()}px`;
19036
- detector.style.left = '0';
19037
- detector.style.height = '-webkit-fill-available';
19038
- detector.style.visibility = 'hidden';
19039
- detector.style.zIndex = '-1';
19040
- document.body.appendChild(detector);
19041
- const dvhInPx = detector.clientHeight;
19042
- document.body.removeChild(detector);
19043
- return dvhInPx;
19044
- };
19045
- const getHeightWithSafeArea = () => {
19046
- const root = document.documentElement;
19047
- const value = getComputedStyle(root).getPropertyValue('--safe-area-inset-bottom');
19048
- // 处理可能的值(可能是 '0px', '34px' 等)
19049
- const numericValue = parseInt(value) || 0;
19050
- return numericValue;
19051
- };
19052
- const dvhToPx = (dvh) => {
19053
- return Math.round((dvh / 100) * document.documentElement.clientHeight);
19054
- };
19055
- const systemInfo = {
19056
- visualViewport: (_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height,
19057
- innerHeight: window.innerHeight,
19058
- clientHeight: document.documentElement.clientHeight,
19059
- screenHeight: window.screen.height,
19060
- bodyHeight: (_b = document === null || document === void 0 ? void 0 : document.body) === null || _b === void 0 ? void 0 : _b.clientHeight,
19061
- agent: navigator.userAgent,
19062
- version: '1.19.16',
19063
- safeArea: getHeightWithSafeArea(),
19064
- dvh: dvhToPx(100),
19065
- dvhInPx: getDvhInPx(),
19066
- vhInPx: getVhInPx(),
19067
- fillAvailableInPx: getFillAvailableInPx()
19005
+ const getVisibleContentHeight = () => {
19006
+ // 方法优先级:
19007
+ // 1. visualViewport.height (最准确)
19008
+ // 2. window.innerHeight (次之)
19009
+ // 3. document.documentElement.clientHeight (fallback)
19010
+ if (typeof window === 'undefined')
19011
+ return 0;
19012
+ let height = window.innerHeight;
19013
+ // 优先使用 visualViewport
19014
+ if (window.visualViewport) {
19015
+ height = window.visualViewport.height;
19016
+ }
19017
+ // 验证高度合理性
19018
+ if (height <= 0 || height > window.screen.height) {
19019
+ height = window.innerHeight;
19020
+ }
19021
+ // 最终 fallback
19022
+ if (height <= 0) {
19023
+ height = document.documentElement.clientHeight;
19024
+ }
19025
+ return height;
19068
19026
  };
19069
- console.log(systemInfo, 'fundebug-init--------------------->systemInfo');
19070
- if ('fundebug' in window) {
19071
- window === null || window === void 0 ? void 0 : window.fundebug.notify('Collect_Info', 'init', { metaData: { systemInfo, otherInfo: {} } });
19072
- }
19073
19027
  const updateHeight = React.useCallback(() => {
19074
- var _a, _b, _c;
19075
- const systemInfo = {
19076
- visualViewport: (_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height,
19077
- innerHeight: window.innerHeight,
19078
- clientHeight: document.documentElement.clientHeight,
19079
- screenHeight: window.screen.height,
19080
- bodyHeight: (_b = document === null || document === void 0 ? void 0 : document.body) === null || _b === void 0 ? void 0 : _b.clientHeight,
19081
- agent: navigator.userAgent,
19082
- version: '1.19.15',
19083
- safeArea: getHeightWithSafeArea(),
19084
- dvh: dvhToPx(100),
19085
- dvhInPx: getDvhInPx(),
19086
- vhInPx: getVhInPx(),
19087
- fillAvailableInPx: getFillAvailableInPx()
19088
- };
19089
- console.log(systemInfo, 'fundebug-resize--------------------->systemInfo');
19028
+ var _a;
19029
+ const visibleHeight = getVisibleContentHeight();
19030
+ const screenHeight = (_a = window.screen) === null || _a === void 0 ? void 0 : _a.height;
19031
+ const ua = navigator.userAgent;
19032
+ // Instagram 检测
19033
+ const isInstagram = /Instagram/i.test(ua);
19034
+ // Facebook 检测
19035
+ const isFacebook = /FBAV|FBAN|FBSN/i.test(ua);
19036
+ // 安全检查
19037
+ if (!screenHeight || visibleHeight <= 0 || (!isInstagram && !isFacebook)) {
19038
+ setVisibleHeight(visibleHeight);
19039
+ return;
19040
+ }
19041
+ const ratio = visibleHeight / screenHeight;
19042
+ const threshold = 0.9;
19043
+ const h = screenHeight >= 900 ? screenHeight * 0.8 : screenHeight * 0.79;
19044
+ // 当内容高度占屏幕高度90%以上时,使用按比例计算的高度
19045
+ // 否则使用实际内容高度
19046
+ const finalHeight = Math.round(ratio >= threshold ? h : visibleHeight);
19090
19047
  if ('fundebug' in window) {
19048
+ const systemInfo = {
19049
+ ratio,
19050
+ h,
19051
+ finalHeight,
19052
+ visibleHeight,
19053
+ screenHeight,
19054
+ isInstagram,
19055
+ isFacebook,
19056
+ ua
19057
+ };
19091
19058
  window === null || window === void 0 ? void 0 : window.fundebug.notify('Collect_Info', 'resize', { metaData: { systemInfo, otherInfo: {} } });
19092
19059
  }
19093
- const height = ((_c = document === null || document === void 0 ? void 0 : document.documentElement) === null || _c === void 0 ? void 0 : _c.clientHeight) || (window === null || window === void 0 ? void 0 : window.innerHeight);
19094
- setVisibleHeight(height);
19095
- }, [getHeightWithSafeArea, dvhToPx, getDvhInPx, getVhInPx, getFillAvailableInPx]);
19060
+ setVisibleHeight(finalHeight);
19061
+ }, [getVisibleContentHeight]);
19096
19062
  React.useEffect(() => {
19097
19063
  // 初始计算
19098
19064
  updateHeight();
@@ -19110,8 +19076,6 @@ const useVisibleHeight = () => {
19110
19076
  if ('virtualKeyboard' in navigator) {
19111
19077
  navigator.virtualKeyboard.addEventListener('geometrychange', updateHeight);
19112
19078
  }
19113
- // 定期检查(应对某些特殊情况)
19114
- const interval = setInterval(updateHeight, 1000);
19115
19079
  return () => {
19116
19080
  events.forEach((event) => {
19117
19081
  window.removeEventListener(event, updateHeight);
@@ -19123,7 +19087,6 @@ const useVisibleHeight = () => {
19123
19087
  if ('virtualKeyboard' in navigator) {
19124
19088
  navigator.virtualKeyboard.removeEventListener('geometrychange', updateHeight);
19125
19089
  }
19126
- clearInterval(interval);
19127
19090
  };
19128
19091
  }, [updateHeight]);
19129
19092
  return visibleHeight;
@@ -19137,7 +19100,7 @@ const useVisibleHeight = () => {
19137
19100
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
19138
19101
  *
19139
19102
  */
19140
- const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.innerHeight, containerWidth = window.innerWidth, tempMap, resolver, data = [], ctaType, tipText, nudge, _schema, hashTagStyle, hashTagRightMargin, tagList = [], defaultData }) => {
19103
+ const SxpPageRender = ({ globalConfig, descStyle, containerHeight, containerWidth = window.innerWidth, tempMap, resolver, data = [], ctaType, tipText, nudge, _schema, hashTagStyle, hashTagRightMargin, tagList = [], defaultData }) => {
19141
19104
  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;
19142
19105
  const mutedIcon = useIconLink('/pb_static/5beaaa5ce7f3477b99db3838619cc471.png');
19143
19106
  const unmutedIcon = useIconLink('/pb_static/fea8668a8a894e4aa3a86bcc775e895e.png');
@@ -19326,29 +19289,10 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19326
19289
  }
19327
19290
  return minusHeight;
19328
19291
  }, [globalConfig]);
19329
- const getHeightWithSafeArea = () => {
19330
- const root = document.documentElement;
19331
- const value = getComputedStyle(root).getPropertyValue('--safe-area-inset-bottom');
19332
- // 处理可能的值(可能是 '0px', '34px' 等)
19333
- const numericValue = parseInt(value) || 0;
19334
- return numericValue;
19335
- };
19336
- const getDvhInPx = () => {
19337
- const detector = document.createElement('div');
19338
- detector.style.position = 'fixed';
19339
- detector.style.bottom = `${getHeightWithSafeArea()}px`;
19340
- detector.style.left = '0';
19341
- detector.style.height = '100dvh';
19342
- detector.style.visibility = 'hidden';
19343
- detector.style.zIndex = '-1';
19344
- document.body.appendChild(detector);
19345
- const dvhInPx = detector.clientHeight;
19346
- document.body.removeChild(detector);
19347
- return dvhInPx;
19348
- };
19349
19292
  const height = React.useMemo(() => {
19350
- return getDvhInPx() - minusHeight - tagHeight - getHeightWithSafeArea();
19351
- }, [minusHeight, visibleHeight, tagHeight, getHeightWithSafeArea, containerHeight, getDvhInPx]);
19293
+ const h = containerHeight || visibleHeight;
19294
+ return h - minusHeight - tagHeight;
19295
+ }, [containerHeight, visibleHeight, minusHeight, tagHeight]);
19352
19296
  const visList = React.useMemo(() => {
19353
19297
  var _a;
19354
19298
  const list = activeIndex === 0 && !waterFallData && !isEditor && !isDiyH5
@@ -19489,9 +19433,6 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19489
19433
  if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconYPosit) === 'top') {
19490
19434
  top += minusHeight;
19491
19435
  }
19492
- if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconFixed) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconYPosit) !== 'top') {
19493
- top += getHeightWithSafeArea();
19494
- }
19495
19436
  if (rec === null || rec === void 0 ? void 0 : rec.video) {
19496
19437
  return (React.createElement(LikeButton$1, { key: rec.position, activeIcon: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIcon, unActicveIcon: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.unlikeIcon, active: rec.isCollected, recData: rec, className: 'clc-sxp-like-button', style: {
19497
19438
  position: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconFixed) ? 'fixed' : 'absolute',
@@ -19726,9 +19667,6 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19726
19667
  if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconYPosit) === 'top') {
19727
19668
  top += minusHeight;
19728
19669
  }
19729
- if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconFixed) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconYPosit) !== 'top') {
19730
- top += getHeightWithSafeArea();
19731
- }
19732
19670
  return (((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowMute) === undefined || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowMute) === true) && (React.createElement(ToggleButton$1, { style: {
19733
19671
  position: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconFixed) ? 'fixed' : 'absolute',
19734
19672
  visibility: ((_c = (_b = visList === null || visList === void 0 ? void 0 : visList[activeIndex]) === null || _b === void 0 ? void 0 : _b.video) === null || _c === void 0 ? void 0 : _c.url) ? 'visible' : 'hidden',
@@ -19769,7 +19707,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19769
19707
  isReload,
19770
19708
  renderToggleButton
19771
19709
  ]);
19772
- return (React.createElement("div", { id: 'sxp-render', className: 'clc-sxp-container' },
19710
+ return (React.createElement("div", { id: 'sxp-render', className: 'clc-sxp-container', style: { height } },
19773
19711
  (data === null || data === void 0 ? void 0 : data.length) < 1 && loading ? (React.createElement("div", { style: { height, width: containerWidth, display: 'flex', justifyContent: 'center', alignItems: 'center' } },
19774
19712
  React.createElement("img", { width: 64, height: 64, src: loadingImage, alt: 'loading...', style: { objectFit: 'contain' } }))) : (React.createElement("div", { style: Object.assign({}, ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.textUnderlineOffset) && { textUnderlineOffset: `${globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.textUnderlineOffset}px` })) },
19775
19713
  waterFallData && (React.createElement(Navbar$1, { icon: img, styles: { background: 'rgba(0,0,0,.3)', color: '#fff', top: `${minusHeight}px` }, textStyle: Object.assign(Object.assign({}, (_e = (_d = (_c = (_b = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.hashTag) === 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.textStyles) === null || _e === void 0 ? void 0 : _e.hashTagTitle), { color: '#fff' }), onClose: () => {
@@ -19831,10 +19769,10 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19831
19769
  renderToggleButton(!!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconFixed))),
19832
19770
  React.createElement(WaterFall$1, Object.assign({}, (_u = (_t = (_s = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.hashTag) === null || _s === void 0 ? void 0 : _s[0]) === null || _t === void 0 ? void 0 : _t.item) === null || _u === void 0 ? void 0 : _u.props)),
19833
19771
  React.createElement(ConsentPopup, { resolver: resolver, globalConfig: globalConfig }),
19834
- openMultiPosts && (React.createElement(MultiPosts$2, Object.assign({}, (_x = (_w = (_v = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.multiPosts) === null || _v === void 0 ? void 0 : _v[0]) === null || _w === void 0 ? void 0 : _w.item) === null || _x === void 0 ? void 0 : _x.props, (_0 = (_z = (_y = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.multiPosts) === null || _y === void 0 ? void 0 : _y[0]) === null || _z === void 0 ? void 0 : _z.item) === null || _0 === void 0 ? void 0 : _0.event, { style: { position: 'fixed', top: 0, left: 0, right: 0, bottom: 'var(--safe-area-inset-bottom,0px)' } }))))),
19772
+ openMultiPosts && (React.createElement(MultiPosts$2, Object.assign({}, (_x = (_w = (_v = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.multiPosts) === null || _v === void 0 ? void 0 : _v[0]) === null || _w === void 0 ? void 0 : _w.item) === null || _x === void 0 ? void 0 : _x.props, (_0 = (_z = (_y = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.multiPosts) === null || _y === void 0 ? void 0 : _y[0]) === null || _z === void 0 ? void 0 : _z.item) === null || _0 === void 0 ? void 0 : _0.event, { style: { position: 'fixed', top: 0, left: 0, right: 0 } }))))),
19835
19773
  (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableCookieSetting) && (React.createElement("div", { style: {
19836
19774
  position: 'fixed',
19837
- bottom: 'var(--safe-area-inset-bottom,0px)',
19775
+ bottom: 0,
19838
19776
  left: 0,
19839
19777
  right: 0,
19840
19778
  width: '100%',