@bud-fe/h5-native-bridge 1.0.7 → 1.0.8

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.
@@ -1149,7 +1149,7 @@ class MediaPlugin {
1149
1149
  "插件未正确初始化"
1150
1150
  );
1151
1151
  }
1152
- if (options.count !== void 0 && (typeof options.count !== "number" || options.count <= 0 || !Number.isInteger(options.count))) {
1152
+ if (options.count !== void 0 && (typeof options.count !== "number" || options.count <= 0 || !Number.isFinite(options.count) && options.count !== Infinity || Number.isFinite(options.count) && !Number.isInteger(options.count))) {
1153
1153
  throw createBridgeError(
1154
1154
  BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
1155
1155
  "count参数格式不正确"
@@ -1504,6 +1504,7 @@ class NavigatePlugin {
1504
1504
  context.bridge.registerMethod("openLink", this.openLink.bind(this));
1505
1505
  context.bridge.registerMethod("navigateToNativePage", this.navigateToNativePage.bind(this));
1506
1506
  context.bridge.registerMethod("closeCurrentPage", this.closeCurrentPage.bind(this));
1507
+ context.bridge.registerMethod("getStatusBarHeight", this.getStatusBarHeight.bind(this));
1507
1508
  }
1508
1509
  setNavigationBar(options) {
1509
1510
  return new Promise((resolve, reject) => {
@@ -1832,6 +1833,48 @@ class NavigatePlugin {
1832
1833
  });
1833
1834
  });
1834
1835
  }
1836
+ /**
1837
+ * 获取原生页面高度
1838
+ * @returns Promise<number> 页面高度数值
1839
+ */
1840
+ getStatusBarHeight() {
1841
+ return new Promise((resolve, reject) => {
1842
+ if (!this.context) {
1843
+ throw createBridgeError(
1844
+ BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
1845
+ "插件未正确初始化"
1846
+ );
1847
+ }
1848
+ const callbacks = {
1849
+ success: (res) => {
1850
+ var _a;
1851
+ const height = typeof res === "number" ? res : (_a = res == null ? void 0 : res.height) != null ? _a : 0;
1852
+ resolve(height);
1853
+ },
1854
+ fail: (err) => {
1855
+ reject(
1856
+ createBridgeError(
1857
+ BridgeErrorCode.SYSTEM_ERROR,
1858
+ "获取页面高度失败",
1859
+ err
1860
+ )
1861
+ );
1862
+ },
1863
+ complete: () => {
1864
+ }
1865
+ };
1866
+ this.context.bridge.ready(() => {
1867
+ var _a;
1868
+ (_a = this.context) == null ? void 0 : _a.bridge.callNative(
1869
+ {
1870
+ action: "getStatusBarHeight",
1871
+ params: {}
1872
+ },
1873
+ callbacks
1874
+ );
1875
+ });
1876
+ });
1877
+ }
1835
1878
  }
1836
1879
  const navigatePlugin = new NavigatePlugin();
1837
1880
  var __defProp$6 = Object.defineProperty;