pb-sxp-ui 1.19.17 → 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,111 +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
- // 检测是否启用了系统字体缩放
19056
- const fontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
19057
- const isScaled = fontSize !== 52; // 默认 1rem = 16px
19058
- // 检测是否处于 Display Zoom 模式(通过屏幕宽高比间接判断)
19059
- const isZoomed = screen.width <= 375 && screen.height <= 667 && window.devicePixelRatio < 3;
19060
- const systemInfo = {
19061
- visualViewport: (_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height,
19062
- innerHeight: window.innerHeight,
19063
- clientHeight: document.documentElement.clientHeight,
19064
- screenHeight: window.screen.height,
19065
- bodyHeight: (_b = document === null || document === void 0 ? void 0 : document.body) === null || _b === void 0 ? void 0 : _b.clientHeight,
19066
- agent: navigator.userAgent,
19067
- version: '1.19.17',
19068
- safeArea: getHeightWithSafeArea(),
19069
- dvh: dvhToPx(100),
19070
- dvhInPx: getDvhInPx(),
19071
- vhInPx: getVhInPx(),
19072
- fillAvailableInPx: getFillAvailableInPx(),
19073
- isScaled,
19074
- isZoomed,
19075
- meta: `${window === null || window === void 0 ? void 0 : window.Instagram},${window === null || window === void 0 ? void 0 : window.Facebook}`
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;
19076
19026
  };
19077
- console.log(systemInfo, 'fundebug-init--------------------->systemInfo');
19078
- if ('fundebug' in window) {
19079
- window === null || window === void 0 ? void 0 : window.fundebug.notify('Collect_Info', 'init', { metaData: { systemInfo, otherInfo: {} } });
19080
- }
19081
19027
  const updateHeight = React.useCallback(() => {
19082
- var _a, _b, _c;
19083
- const fontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
19084
- const isScaled = fontSize !== 52; // 默认 1rem = 16px
19085
- const systemInfo = {
19086
- visualViewport: (_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height,
19087
- innerHeight: window.innerHeight,
19088
- clientHeight: document.documentElement.clientHeight,
19089
- screenHeight: window.screen.height,
19090
- bodyHeight: (_b = document === null || document === void 0 ? void 0 : document.body) === null || _b === void 0 ? void 0 : _b.clientHeight,
19091
- agent: navigator.userAgent,
19092
- version: '1.19.17',
19093
- safeArea: getHeightWithSafeArea(),
19094
- dvh: dvhToPx(100),
19095
- dvhInPx: getDvhInPx(),
19096
- vhInPx: getVhInPx(),
19097
- fillAvailableInPx: getFillAvailableInPx(),
19098
- isScaled,
19099
- isZoomed,
19100
- meta: `${window === null || window === void 0 ? void 0 : window.Instagram},${window === null || window === void 0 ? void 0 : window.Facebook}`
19101
- };
19102
- 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);
19103
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
+ };
19104
19058
  window === null || window === void 0 ? void 0 : window.fundebug.notify('Collect_Info', 'resize', { metaData: { systemInfo, otherInfo: {} } });
19105
19059
  }
19106
- 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);
19107
- setVisibleHeight(height);
19108
- }, [getHeightWithSafeArea, dvhToPx, getDvhInPx, getVhInPx, getFillAvailableInPx]);
19060
+ setVisibleHeight(finalHeight);
19061
+ }, [getVisibleContentHeight]);
19109
19062
  React.useEffect(() => {
19110
19063
  // 初始计算
19111
19064
  updateHeight();
@@ -19123,8 +19076,6 @@ const useVisibleHeight = () => {
19123
19076
  if ('virtualKeyboard' in navigator) {
19124
19077
  navigator.virtualKeyboard.addEventListener('geometrychange', updateHeight);
19125
19078
  }
19126
- // 定期检查(应对某些特殊情况)
19127
- const interval = setInterval(updateHeight, 1000);
19128
19079
  return () => {
19129
19080
  events.forEach((event) => {
19130
19081
  window.removeEventListener(event, updateHeight);
@@ -19136,7 +19087,6 @@ const useVisibleHeight = () => {
19136
19087
  if ('virtualKeyboard' in navigator) {
19137
19088
  navigator.virtualKeyboard.removeEventListener('geometrychange', updateHeight);
19138
19089
  }
19139
- clearInterval(interval);
19140
19090
  };
19141
19091
  }, [updateHeight]);
19142
19092
  return visibleHeight;
@@ -19150,7 +19100,7 @@ const useVisibleHeight = () => {
19150
19100
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
19151
19101
  *
19152
19102
  */
19153
- 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 }) => {
19154
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;
19155
19105
  const mutedIcon = useIconLink('/pb_static/5beaaa5ce7f3477b99db3838619cc471.png');
19156
19106
  const unmutedIcon = useIconLink('/pb_static/fea8668a8a894e4aa3a86bcc775e895e.png');
@@ -19339,29 +19289,10 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19339
19289
  }
19340
19290
  return minusHeight;
19341
19291
  }, [globalConfig]);
19342
- const getHeightWithSafeArea = () => {
19343
- const root = document.documentElement;
19344
- const value = getComputedStyle(root).getPropertyValue('--safe-area-inset-bottom');
19345
- // 处理可能的值(可能是 '0px', '34px' 等)
19346
- const numericValue = parseInt(value) || 0;
19347
- return numericValue;
19348
- };
19349
- const getDvhInPx = () => {
19350
- const detector = document.createElement('div');
19351
- detector.style.position = 'fixed';
19352
- detector.style.bottom = `${getHeightWithSafeArea()}px`;
19353
- detector.style.left = '0';
19354
- detector.style.height = '100dvh';
19355
- detector.style.visibility = 'hidden';
19356
- detector.style.zIndex = '-1';
19357
- document.body.appendChild(detector);
19358
- const dvhInPx = detector.clientHeight;
19359
- document.body.removeChild(detector);
19360
- return dvhInPx;
19361
- };
19362
19292
  const height = React.useMemo(() => {
19363
- return getDvhInPx() - minusHeight - tagHeight - getHeightWithSafeArea();
19364
- }, [minusHeight, visibleHeight, tagHeight, getHeightWithSafeArea, containerHeight, getDvhInPx]);
19293
+ const h = containerHeight || visibleHeight;
19294
+ return h - minusHeight - tagHeight;
19295
+ }, [containerHeight, visibleHeight, minusHeight, tagHeight]);
19365
19296
  const visList = React.useMemo(() => {
19366
19297
  var _a;
19367
19298
  const list = activeIndex === 0 && !waterFallData && !isEditor && !isDiyH5
@@ -19502,9 +19433,6 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19502
19433
  if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconYPosit) === 'top') {
19503
19434
  top += minusHeight;
19504
19435
  }
19505
- if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconFixed) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconYPosit) !== 'top') {
19506
- top += getHeightWithSafeArea();
19507
- }
19508
19436
  if (rec === null || rec === void 0 ? void 0 : rec.video) {
19509
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: {
19510
19438
  position: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconFixed) ? 'fixed' : 'absolute',
@@ -19739,9 +19667,6 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19739
19667
  if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconYPosit) === 'top') {
19740
19668
  top += minusHeight;
19741
19669
  }
19742
- if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconFixed) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconYPosit) !== 'top') {
19743
- top += getHeightWithSafeArea();
19744
- }
19745
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: {
19746
19671
  position: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconFixed) ? 'fixed' : 'absolute',
19747
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',
@@ -19782,7 +19707,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19782
19707
  isReload,
19783
19708
  renderToggleButton
19784
19709
  ]);
19785
- 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 } },
19786
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' } },
19787
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` })) },
19788
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: () => {
@@ -19844,10 +19769,10 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19844
19769
  renderToggleButton(!!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconFixed))),
19845
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)),
19846
19771
  React.createElement(ConsentPopup, { resolver: resolver, globalConfig: globalConfig }),
19847
- 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 } }))))),
19848
19773
  (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableCookieSetting) && (React.createElement("div", { style: {
19849
19774
  position: 'fixed',
19850
- bottom: 'var(--safe-area-inset-bottom,0px)',
19775
+ bottom: 0,
19851
19776
  left: 0,
19852
19777
  right: 0,
19853
19778
  width: '100%',