@bud-fe/h5-native-bridge 1.0.6 → 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;
@@ -3142,11 +3185,18 @@ var __publicField$2 = (obj, key, value) => {
3142
3185
  __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
3143
3186
  return value;
3144
3187
  };
3188
+ var TriggerSource = /* @__PURE__ */ ((TriggerSource2) => {
3189
+ TriggerSource2["LOGIN"] = "LOGIN";
3190
+ TriggerSource2["DAILY_OPEN"] = "DAILY_OPEN";
3191
+ TriggerSource2["MORNING_MEETING"] = "MORNING_MEETING";
3192
+ TriggerSource2["VISIT"] = "VISIT";
3193
+ return TriggerSource2;
3194
+ })(TriggerSource || {});
3145
3195
  class AuthenticationPlugin {
3146
3196
  constructor() {
3147
3197
  __publicField$2(this, "context");
3148
3198
  __publicField$2(this, "name", "authentication");
3149
- __publicField$2(this, "version", "1.0.0");
3199
+ __publicField$2(this, "version", "1.1.0");
3150
3200
  }
3151
3201
  install(context) {
3152
3202
  this.context = context;
@@ -3157,14 +3207,15 @@ class AuthenticationPlugin {
3157
3207
  }
3158
3208
  /**
3159
3209
  * 执行实人认证
3160
- * @param options - 认证选项,包含成功、失败和完成的回调函数
3210
+ * @param options - 认证选项,包含触发来源和回调函数
3211
+ * @property options.triggerSource - 触发来源(必填),必须是TriggerSource枚举中的值
3161
3212
  * @property options.success - 认证成功时的回调函数,接收认证结果
3162
3213
  * @property options.fail - 认证失败时的回调函数,接收错误信息
3163
3214
  * @property options.complete - 认证完成时的回调函数(无论成功或失败)
3164
3215
  * @returns Promise<AuthenticationResult> - 返回认证结果的Promise对象
3165
- * @throws {BridgeError} - 如果插件未正确初始化,抛出BridgeError异常
3216
+ * @throws {BridgeError} - 如果插件未初始化或参数不合法,抛出BridgeError异常
3166
3217
  */
3167
- exclusiveLiveCheck(options = {}) {
3218
+ exclusiveLiveCheck(options) {
3168
3219
  return new Promise((resolve, reject) => {
3169
3220
  if (!this.context) {
3170
3221
  throw createBridgeError(
@@ -3172,6 +3223,19 @@ class AuthenticationPlugin {
3172
3223
  "插件未正确初始化"
3173
3224
  );
3174
3225
  }
3226
+ if (!options.triggerSource) {
3227
+ throw createBridgeError(
3228
+ BridgeErrorCode.INVALID_ACTION,
3229
+ "缺少必填参数:triggerSource"
3230
+ );
3231
+ }
3232
+ const validSources = Object.values(TriggerSource);
3233
+ if (!validSources.includes(options.triggerSource)) {
3234
+ throw createBridgeError(
3235
+ BridgeErrorCode.INVALID_ACTION,
3236
+ `triggerSource参数值不合法,合法值为:${validSources.join(" / ")}`
3237
+ );
3238
+ }
3175
3239
  const callbacks = {
3176
3240
  success: (res) => {
3177
3241
  resolve(res);
@@ -3186,7 +3250,9 @@ class AuthenticationPlugin {
3186
3250
  (_a = this.context) == null ? void 0 : _a.bridge.callNative(
3187
3251
  {
3188
3252
  action: "exclusiveLiveCheck",
3189
- params: {}
3253
+ params: {
3254
+ triggerSource: options.triggerSource
3255
+ }
3190
3256
  },
3191
3257
  callbacks
3192
3258
  );