@bud-fe/h5-native-bridge 1.0.4 → 1.0.5

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.
@@ -1,9 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
1
  var BridgeErrorCode = /* @__PURE__ */ ((BridgeErrorCode2) => {
8
2
  BridgeErrorCode2[BridgeErrorCode2["SUCCESS"] = 0] = "SUCCESS";
9
3
  BridgeErrorCode2[BridgeErrorCode2["JSON_ERROR"] = 1] = "JSON_ERROR";
@@ -19,27 +13,61 @@ const createBridgeError = (code, message, details) => {
19
13
  error.details = details;
20
14
  return error;
21
15
  };
22
- const _NativeBridgeCore = class _NativeBridgeCore {
16
+ var __defProp$b = Object.defineProperty;
17
+ var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
18
+ var __publicField$b = (obj, key, value) => {
19
+ __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
20
+ return value;
21
+ };
22
+ let AbortControllerPolyfill;
23
+ if (typeof AbortController === "undefined") {
24
+ AbortControllerPolyfill = class {
25
+ constructor() {
26
+ __publicField$b(this, "signal");
27
+ this.signal = {
28
+ aborted: false,
29
+ _listeners: [],
30
+ addEventListener: function(event, callback) {
31
+ this._listeners.push(callback);
32
+ },
33
+ removeEventListener: function(event, callback) {
34
+ const index = this._listeners.indexOf(callback);
35
+ if (index !== -1) {
36
+ this._listeners.splice(index, 1);
37
+ }
38
+ },
39
+ dispatchEvent: function(event) {
40
+ this._listeners.forEach((listener) => listener(event));
41
+ }
42
+ };
43
+ }
44
+ abort() {
45
+ this.signal.aborted = true;
46
+ this.signal.dispatchEvent({ type: "abort" });
47
+ }
48
+ };
49
+ } else {
50
+ AbortControllerPolyfill = AbortController;
51
+ }
52
+ const _NativeBridgeCore = class _NativeBridgeCore2 {
23
53
  /**
24
54
  * 私有构造函数(单例模式)
25
55
  */
26
56
  constructor(options = {}) {
27
- __publicField(this, "callbackMap");
28
- __publicField(this, "callbackId");
29
- __publicField(this, "isReady");
30
- __publicField(this, "readyCallbacks");
31
- __publicField(this, "debugMode");
32
- __publicField(this, "defaultTimeout");
33
- __publicField(this, "plugins");
34
- __publicField(this, "pendingCalls");
35
- __publicField(this, "errorHandler");
36
- __publicField(this, "eventListeners", /* @__PURE__ */ new Map());
37
- __publicField(this, "nativeEventHandlers", /* @__PURE__ */ new Map());
38
- // 版本号管理
39
- __publicField(this, "VERSION", "1.0.0");
40
- __publicField(this, "API_VERSION", "1");
41
- // 新增方法注册机制
42
- __publicField(this, "methodRegistry", /* @__PURE__ */ new Map());
57
+ __publicField$b(this, "callbackMap");
58
+ __publicField$b(this, "callbackId");
59
+ __publicField$b(this, "isReady");
60
+ __publicField$b(this, "readyCallbacks");
61
+ __publicField$b(this, "debugMode");
62
+ __publicField$b(this, "defaultTimeout");
63
+ __publicField$b(this, "plugins");
64
+ __publicField$b(this, "pendingCalls");
65
+ __publicField$b(this, "errorHandler");
66
+ __publicField$b(this, "eventListeners", /* @__PURE__ */ new Map());
67
+ __publicField$b(this, "nativeEventHandlers", /* @__PURE__ */ new Map());
68
+ __publicField$b(this, "VERSION", "1.0.0");
69
+ __publicField$b(this, "API_VERSION", "1");
70
+ __publicField$b(this, "methodRegistry", /* @__PURE__ */ new Map());
43
71
  this.callbackMap = /* @__PURE__ */ new Map();
44
72
  this.callbackId = 1;
45
73
  this.isReady = false;
@@ -58,14 +86,14 @@ const _NativeBridgeCore = class _NativeBridgeCore {
58
86
  * 获取NativeBridge单例
59
87
  */
60
88
  static getInstance(options = {}) {
61
- if (!_NativeBridgeCore.instance) {
62
- _NativeBridgeCore.instance = new _NativeBridgeCore(options);
89
+ if (!_NativeBridgeCore2.instance) {
90
+ _NativeBridgeCore2.instance = new _NativeBridgeCore2(options);
63
91
  } else if (options.plugins && options.plugins.length > 0) {
64
92
  options.plugins.forEach((plugin) => {
65
- _NativeBridgeCore.instance.use(plugin);
93
+ _NativeBridgeCore2.instance.use(plugin);
66
94
  });
67
95
  }
68
- return _NativeBridgeCore.instance;
96
+ return _NativeBridgeCore2.instance;
69
97
  }
70
98
  /**
71
99
  * 注册原生事件监听
@@ -248,7 +276,7 @@ const _NativeBridgeCore = class _NativeBridgeCore {
248
276
  if (callbacks) {
249
277
  this.callbackMap.set(callbackId, callbacks);
250
278
  if (timeout > 0) {
251
- const controller = new AbortController();
279
+ const controller = new AbortControllerPolyfill();
252
280
  const timeoutId = setTimeout(() => {
253
281
  var _a2, _b;
254
282
  if (controller.signal.aborted)
@@ -309,6 +337,9 @@ const _NativeBridgeCore = class _NativeBridgeCore {
309
337
  }
310
338
  return callbackId;
311
339
  }
340
+ isIOS() {
341
+ return /iPhone|iPad|iPod/i.test(navigator.userAgent);
342
+ }
312
343
  /**
313
344
  * 同步调用原生方法
314
345
  *
@@ -321,15 +352,15 @@ const _NativeBridgeCore = class _NativeBridgeCore {
321
352
  * @throws 当发送消息到原生App失败时抛出错误
322
353
  */
323
354
  callNativeSync(action, params, callbacks) {
324
- var _a, _b, _c, _d, _e, _f, _g;
355
+ var _a, _b, _c, _d;
325
356
  let data = void 0;
326
357
  try {
327
358
  const messageString = JSON.stringify({ action, params });
328
359
  const win = typeof window !== "undefined" ? window : void 0;
329
- if ((_c = (_b = (_a = win == null ? void 0 : win.webkit) == null ? void 0 : _a.messageHandlers) == null ? void 0 : _b.nativeBridge) == null ? void 0 : _c.postSyncMessage) {
360
+ if (this.isIOS()) {
330
361
  this.log(`发送消息到 iOS WKWebView: ${messageString}`);
331
- data = win.webkit.messageHandlers.nativeBridge.postSyncMessage(messageString);
332
- } else if ((_d = win == null ? void 0 : win.AndroidBridge) == null ? void 0 : _d.postSyncMessage) {
362
+ data = prompt(messageString);
363
+ } else if ((_a = win == null ? void 0 : win.AndroidBridge) == null ? void 0 : _a.postSyncMessage) {
333
364
  this.log(`发送消息到安卓原生App: ${messageString}`);
334
365
  data = win.AndroidBridge.postSyncMessage(messageString);
335
366
  } else if (win) {
@@ -345,7 +376,7 @@ const _NativeBridgeCore = class _NativeBridgeCore {
345
376
  }, 0);
346
377
  return void 0;
347
378
  } catch (iframeError) {
348
- (_e = callbacks == null ? void 0 : callbacks.fail) == null ? void 0 : _e.call(callbacks, iframeError);
379
+ (_b = callbacks == null ? void 0 : callbacks.fail) == null ? void 0 : _b.call(callbacks, iframeError);
349
380
  throw createBridgeError(
350
381
  BridgeErrorCode.SYSTEM_ERROR,
351
382
  `创建 iframe 失败: ${iframeError.message}`
@@ -353,7 +384,7 @@ const _NativeBridgeCore = class _NativeBridgeCore {
353
384
  }
354
385
  }
355
386
  } catch (error) {
356
- (_f = callbacks == null ? void 0 : callbacks.fail) == null ? void 0 : _f.call(callbacks, error);
387
+ (_c = callbacks == null ? void 0 : callbacks.fail) == null ? void 0 : _c.call(callbacks, error);
357
388
  throw createBridgeError(
358
389
  BridgeErrorCode.SYSTEM_ERROR,
359
390
  `发送消息到原生App失败: ${error.message}`
@@ -362,7 +393,7 @@ const _NativeBridgeCore = class _NativeBridgeCore {
362
393
  if (this.debugMode) {
363
394
  this.log(`收到原生回调: success`, data);
364
395
  }
365
- (_g = callbacks == null ? void 0 : callbacks.success) == null ? void 0 : _g.call(callbacks, processJsonValue(data));
396
+ (_d = callbacks == null ? void 0 : callbacks.success) == null ? void 0 : _d.call(callbacks, processJsonValue(data));
366
397
  return processJsonValue(data);
367
398
  }
368
399
  /**
@@ -455,21 +486,36 @@ const _NativeBridgeCore = class _NativeBridgeCore {
455
486
  }, 100);
456
487
  break;
457
488
  default:
458
- for (const [plugin] of this.plugins.entries()) {
489
+ const entries = Array.from(this.plugins.entries());
490
+ for (let i = 0; i < entries.length; i++) {
491
+ const [plugin] = entries[i];
459
492
  if (plugin.mockAction && typeof plugin.mockAction === "function") {
460
493
  if (plugin.mockAction(message)) {
461
494
  return;
462
495
  }
463
496
  }
464
497
  }
465
- this.warn(`未实现的模拟功能: ${message.action}`);
498
+ setTimeout(() => {
499
+ this.handleNativeCallback(
500
+ message.callbackId,
501
+ "success",
502
+ { message: "Mock成功", data: null }
503
+ );
504
+ }, 100);
466
505
  }
467
506
  }
468
507
  /**
469
- * 释放回调
508
+ * 释放回调资源
470
509
  */
471
510
  releaseCallback(callbackId) {
511
+ var _a, _b;
472
512
  if (this.callbackMap.has(callbackId)) {
513
+ const callbacks = this.callbackMap.get(callbackId);
514
+ (_a = callbacks == null ? void 0 : callbacks.fail) == null ? void 0 : _a.call(
515
+ callbacks,
516
+ createBridgeError(BridgeErrorCode.SYSTEM_ERROR, "调用原生方法失败")
517
+ );
518
+ (_b = callbacks == null ? void 0 : callbacks.complete) == null ? void 0 : _b.call(callbacks);
473
519
  this.callbackMap.delete(callbackId);
474
520
  }
475
521
  if (this.pendingCalls.has(callbackId)) {
@@ -508,37 +554,27 @@ const _NativeBridgeCore = class _NativeBridgeCore {
508
554
  return this.debugMode;
509
555
  }
510
556
  /**
511
- * 日志记录 - 信息
557
+ * 日志输出
512
558
  */
513
- log(message, ...args) {
514
- if (message.includes("调试模式已")) {
515
- console.log(`[NativeBridge] 📢 ${message}`, ...args);
516
- return;
517
- }
559
+ log(message, ...optionalParams) {
518
560
  if (this.debugMode) {
519
- console.log(`[NativeBridge] ${message}`, ...args);
561
+ console.log(`[NativeBridge] ${message}`, ...optionalParams);
520
562
  }
521
563
  }
522
564
  /**
523
- * 日志记录 - 警告
565
+ * 错误日志输出
524
566
  */
525
- warn(message, ...args) {
526
- if (this.debugMode) {
527
- console.warn(`[NativeBridge] ⚠️ ${message}`, ...args);
567
+ error(message, error) {
568
+ console.error(`[NativeBridge Error] ${message}`, error);
569
+ if (this.errorHandler && error) {
570
+ this.errorHandler(error, message);
528
571
  }
529
572
  }
530
573
  /**
531
- * 日志记录 - 错误
574
+ * 警告日志输出
532
575
  */
533
- error(source, error) {
534
- console.error(`[NativeBridge] 🛑 ${source}:`, error);
535
- if (this.errorHandler) {
536
- try {
537
- this.errorHandler(error, source);
538
- } catch (handlerError) {
539
- console.error("[NativeBridge] 错误处理器执行失败:", handlerError);
540
- }
541
- }
576
+ warn(message) {
577
+ console.warn(`[NativeBridge Warn] ${message}`);
542
578
  }
543
579
  /**
544
580
  * 获取回调映射表
@@ -547,7 +583,7 @@ const _NativeBridgeCore = class _NativeBridgeCore {
547
583
  return this.callbackMap;
548
584
  }
549
585
  };
550
- __publicField(_NativeBridgeCore, "instance");
586
+ __publicField$b(_NativeBridgeCore, "instance");
551
587
  let NativeBridgeCore = _NativeBridgeCore;
552
588
  function processJsonValue(value) {
553
589
  if (value === void 0 || value === null) {
@@ -574,11 +610,34 @@ const createNativeBridge = (options) => {
574
610
  return NativeBridgeCore.getInstance(options);
575
611
  };
576
612
  NativeBridgeCore.getInstance();
613
+ var __defProp$a = Object.defineProperty;
614
+ var __defProps$1 = Object.defineProperties;
615
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
616
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
617
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
618
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
619
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
620
+ var __spreadValues$4 = (a, b) => {
621
+ for (var prop in b || (b = {}))
622
+ if (__hasOwnProp$4.call(b, prop))
623
+ __defNormalProp$a(a, prop, b[prop]);
624
+ if (__getOwnPropSymbols$4)
625
+ for (var prop of __getOwnPropSymbols$4(b)) {
626
+ if (__propIsEnum$4.call(b, prop))
627
+ __defNormalProp$a(a, prop, b[prop]);
628
+ }
629
+ return a;
630
+ };
631
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
632
+ var __publicField$a = (obj, key, value) => {
633
+ __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
634
+ return value;
635
+ };
577
636
  class LocationPlugin {
578
637
  constructor() {
579
- __publicField(this, "name", "location");
580
- __publicField(this, "version", "1.0.0");
581
- __publicField(this, "context");
638
+ __publicField$a(this, "name", "location");
639
+ __publicField$a(this, "version", "1.0.0");
640
+ __publicField$a(this, "context");
582
641
  }
583
642
  install(context) {
584
643
  this.context = context;
@@ -587,7 +646,6 @@ class LocationPlugin {
587
646
  this.getLocationSync.bind(this)
588
647
  );
589
648
  context.bridge.registerMethod("getLocation", this.getLocation.bind(this));
590
- context.bridge.log(`位置服务插件 v${this.version} 已安装`);
591
649
  }
592
650
  /**
593
651
  * 获取当前位置信息
@@ -604,15 +662,15 @@ class LocationPlugin {
604
662
  withReGeocode: true,
605
663
  useCache: true
606
664
  }) {
607
- options.useCache = options.useCache ?? true;
665
+ var _a;
666
+ options.useCache = (_a = options.useCache) != null ? _a : true;
608
667
  return new Promise((resolve, reject) => {
609
- this.getLocationSync({
610
- ...options,
668
+ this.getLocationSync(__spreadProps$1(__spreadValues$4({}, options), {
611
669
  success: (location) => {
612
670
  resolve(location);
613
671
  },
614
672
  fail: (error) => reject(error)
615
- });
673
+ }));
616
674
  });
617
675
  }
618
676
  getLocationSync(options = {
@@ -621,6 +679,7 @@ class LocationPlugin {
621
679
  withReGeocode: true,
622
680
  useCache: true
623
681
  }) {
682
+ var _a;
624
683
  if (!this.context) {
625
684
  throw createBridgeError(
626
685
  BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
@@ -651,15 +710,15 @@ class LocationPlugin {
651
710
  "useCache参数格式错误"
652
711
  );
653
712
  }
654
- options.useCache = options.useCache ?? true;
713
+ options.useCache = (_a = options.useCache) != null ? _a : true;
655
714
  const callbacks = {
656
715
  success: options.success,
657
716
  fail: options.fail,
658
717
  complete: options.complete
659
718
  };
660
719
  this.context.bridge.ready(() => {
661
- var _a;
662
- (_a = this.context) == null ? void 0 : _a.bridge.callNative(
720
+ var _a2;
721
+ (_a2 = this.context) == null ? void 0 : _a2.bridge.callNative(
663
722
  {
664
723
  action: "getLocation",
665
724
  params: options
@@ -670,11 +729,31 @@ class LocationPlugin {
670
729
  }
671
730
  }
672
731
  const locationPlugin = new LocationPlugin();
732
+ var __defProp$9 = Object.defineProperty;
733
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
734
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
735
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
736
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
737
+ var __spreadValues$3 = (a, b) => {
738
+ for (var prop in b || (b = {}))
739
+ if (__hasOwnProp$3.call(b, prop))
740
+ __defNormalProp$9(a, prop, b[prop]);
741
+ if (__getOwnPropSymbols$3)
742
+ for (var prop of __getOwnPropSymbols$3(b)) {
743
+ if (__propIsEnum$3.call(b, prop))
744
+ __defNormalProp$9(a, prop, b[prop]);
745
+ }
746
+ return a;
747
+ };
748
+ var __publicField$9 = (obj, key, value) => {
749
+ __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
750
+ return value;
751
+ };
673
752
  class DevicePlugin {
674
753
  constructor() {
675
- __publicField(this, "name", "device");
676
- __publicField(this, "version", "1.0.0");
677
- __publicField(this, "context");
754
+ __publicField$9(this, "name", "device");
755
+ __publicField$9(this, "version", "1.0.0");
756
+ __publicField$9(this, "context");
678
757
  }
679
758
  /**
680
759
  * 安装插件
@@ -689,7 +768,6 @@ class DevicePlugin {
689
768
  "setKeepScreenOn",
690
769
  this.setKeepScreenOn.bind(this)
691
770
  );
692
- context.bridge.log(`设备信息插件 v${this.version} 已安装`);
693
771
  }
694
772
  /**
695
773
  * 设置屏幕常亮状态
@@ -852,7 +930,7 @@ class DevicePlugin {
852
930
  (_a = this.context) == null ? void 0 : _a.bridge.callNative(
853
931
  {
854
932
  action: "getWifiList",
855
- params: { ...options }
933
+ params: __spreadValues$3({}, options)
856
934
  },
857
935
  callbacks
858
936
  );
@@ -894,12 +972,32 @@ class DevicePlugin {
894
972
  }
895
973
  }
896
974
  const devicePlugin = new DevicePlugin();
975
+ var __defProp$8 = Object.defineProperty;
976
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
977
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
978
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
979
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
980
+ var __spreadValues$2 = (a, b) => {
981
+ for (var prop in b || (b = {}))
982
+ if (__hasOwnProp$2.call(b, prop))
983
+ __defNormalProp$8(a, prop, b[prop]);
984
+ if (__getOwnPropSymbols$2)
985
+ for (var prop of __getOwnPropSymbols$2(b)) {
986
+ if (__propIsEnum$2.call(b, prop))
987
+ __defNormalProp$8(a, prop, b[prop]);
988
+ }
989
+ return a;
990
+ };
991
+ var __publicField$8 = (obj, key, value) => {
992
+ __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
993
+ return value;
994
+ };
897
995
  const MAX_VIDEO_DURATION = 60;
898
996
  class MediaPlugin {
899
997
  constructor() {
900
- __publicField(this, "name", "media");
901
- __publicField(this, "version", "1.0.0");
902
- __publicField(this, "context");
998
+ __publicField$8(this, "name", "media");
999
+ __publicField$8(this, "version", "1.0.0");
1000
+ __publicField$8(this, "context");
903
1001
  }
904
1002
  /**
905
1003
  * 安装插件
@@ -911,8 +1009,9 @@ class MediaPlugin {
911
1009
  context.bridge.registerMethod("chooseImage", this.chooseImage.bind(this));
912
1010
  context.bridge.registerMethod("previewImage", this.previewImage.bind(this));
913
1011
  context.bridge.registerMethod("compressImage", this.compressImage.bind(this));
1012
+ context.bridge.registerMethod("compressVideo", this.compressVideo.bind(this));
914
1013
  context.bridge.registerMethod("chooseVideo", this.chooseVideo.bind(this));
915
- context.bridge.log(`设备信息插件 v${this.version} 已安装`);
1014
+ context.bridge.registerMethod("onUploadProgress", this.onUploadProgress.bind(this));
916
1015
  }
917
1016
  /**
918
1017
  * 执行扫码功能
@@ -931,6 +1030,7 @@ class MediaPlugin {
931
1030
  */
932
1031
  scan(options) {
933
1032
  return new Promise((resolve, reject) => {
1033
+ var _a;
934
1034
  if (!this.context) {
935
1035
  throw createBridgeError(
936
1036
  BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
@@ -950,7 +1050,7 @@ class MediaPlugin {
950
1050
  );
951
1051
  }
952
1052
  options.key = options.key || "qr";
953
- options.isSupportAlbum = options.isSupportAlbum ?? true;
1053
+ options.isSupportAlbum = (_a = options.isSupportAlbum) != null ? _a : true;
954
1054
  const callbacks = {
955
1055
  success: (res) => {
956
1056
  resolve(res);
@@ -961,16 +1061,16 @@ class MediaPlugin {
961
1061
  );
962
1062
  },
963
1063
  complete: () => {
964
- var _a;
965
- (_a = options.complete) == null ? void 0 : _a.call(options);
1064
+ var _a2;
1065
+ (_a2 = options.complete) == null ? void 0 : _a2.call(options);
966
1066
  }
967
1067
  };
968
1068
  this.context.bridge.ready(() => {
969
- var _a;
970
- (_a = this.context) == null ? void 0 : _a.bridge.callNative(
1069
+ var _a2;
1070
+ (_a2 = this.context) == null ? void 0 : _a2.bridge.callNative(
971
1071
  {
972
1072
  action: "scan",
973
- params: { ...options }
1073
+ params: __spreadValues$2({}, options)
974
1074
  },
975
1075
  callbacks
976
1076
  );
@@ -1148,6 +1248,7 @@ class MediaPlugin {
1148
1248
  */
1149
1249
  compressImage(options) {
1150
1250
  return new Promise((resolve, reject) => {
1251
+ var _a;
1151
1252
  if (!this.context) {
1152
1253
  throw createBridgeError(
1153
1254
  BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
@@ -1166,7 +1267,7 @@ class MediaPlugin {
1166
1267
  "compressLevel参数格式不正确"
1167
1268
  );
1168
1269
  }
1169
- options.compressLevel = options.compressLevel ?? 4;
1270
+ options.compressLevel = (_a = options.compressLevel) != null ? _a : 4;
1170
1271
  const callbacks = {
1171
1272
  success: (res) => {
1172
1273
  resolve(res || { filePaths: "" });
@@ -1179,8 +1280,8 @@ class MediaPlugin {
1179
1280
  }
1180
1281
  };
1181
1282
  this.context.bridge.ready(() => {
1182
- var _a;
1183
- (_a = this.context) == null ? void 0 : _a.bridge.callNative(
1283
+ var _a2;
1284
+ (_a2 = this.context) == null ? void 0 : _a2.bridge.callNative(
1184
1285
  {
1185
1286
  action: "compressImage",
1186
1287
  params: options
@@ -1190,11 +1291,62 @@ class MediaPlugin {
1190
1291
  });
1191
1292
  });
1192
1293
  }
1294
+ /**
1295
+ * 压缩视频
1296
+ * @param options 压缩视频的配置选项
1297
+ * @returns 返回一个Promise,解析为压缩后的视频响应数据
1298
+ */
1299
+ compressVideo(options) {
1300
+ return new Promise((resolve, reject) => {
1301
+ var _a;
1302
+ if (!this.context) {
1303
+ throw createBridgeError(
1304
+ BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
1305
+ "插件未正确初始化"
1306
+ );
1307
+ }
1308
+ if (!options.filePath || typeof options.filePath !== "string" || !options.filePath.trim()) {
1309
+ throw createBridgeError(
1310
+ BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
1311
+ "filePath参数格式不正确"
1312
+ );
1313
+ }
1314
+ if (options.compressLevel !== void 0 && (typeof options.compressLevel !== "number" || options.compressLevel < 0 || options.compressLevel > 3 || !Number.isInteger(options.compressLevel))) {
1315
+ throw createBridgeError(
1316
+ BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
1317
+ "compressLevel参数格式不正确"
1318
+ );
1319
+ }
1320
+ options.compressLevel = (_a = options.compressLevel) != null ? _a : 3;
1321
+ const callbacks = {
1322
+ success: (res) => {
1323
+ resolve(res || { filePath: "" });
1324
+ },
1325
+ fail: (err) => {
1326
+ console.error("压缩视频失败:", err);
1327
+ reject(err);
1328
+ },
1329
+ complete: () => {
1330
+ }
1331
+ };
1332
+ this.context.bridge.ready(() => {
1333
+ var _a2;
1334
+ (_a2 = this.context) == null ? void 0 : _a2.bridge.callNative(
1335
+ {
1336
+ action: "compressVideo",
1337
+ params: options
1338
+ },
1339
+ callbacks
1340
+ );
1341
+ });
1342
+ });
1343
+ }
1193
1344
  /**
1194
1345
  * 选择视频文件
1195
1346
  * @param options 选择视频的配置选项,包含以下属性:
1196
1347
  * @param options.sourceType 视频来源类型,默认同时支持相册和相机['album','camera']
1197
1348
  * @param options.maxDuration 视频最大时长(秒),默认60秒
1349
+ * @param options.compressLevel?: number; //压缩级别,支持 0 ~ 3 的整数,默认 3, (0:低质量, 1:中等质量,2:高质量,3:不压缩)
1198
1350
  * @returns Promise<ChooseVideoResponse> 返回包含视频信息的Promise对象
1199
1351
  * @returns ChooseVideoResponse.filePath 视频临时文件路径
1200
1352
  * @returns ChooseVideoResponse.duration 视频时长(秒)
@@ -1204,6 +1356,7 @@ class MediaPlugin {
1204
1356
  */
1205
1357
  chooseVideo(options = {}) {
1206
1358
  return new Promise((resolve, reject) => {
1359
+ var _a, _b;
1207
1360
  if (!this.context) {
1208
1361
  throw createBridgeError(
1209
1362
  BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
@@ -1234,8 +1387,15 @@ class MediaPlugin {
1234
1387
  "maxDuration参数格式不正确"
1235
1388
  );
1236
1389
  }
1390
+ if (options.compressLevel !== void 0 && (typeof options.compressLevel !== "number" || options.compressLevel < 0 || options.compressLevel > 3 || !Number.isInteger(options.compressLevel))) {
1391
+ throw createBridgeError(
1392
+ BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
1393
+ "compressLevel参数格式不正确"
1394
+ );
1395
+ }
1237
1396
  options.sourceType = options.sourceType || ["album", "camera"];
1238
- options.maxDuration = options.maxDuration ?? MAX_VIDEO_DURATION;
1397
+ options.maxDuration = (_a = options.maxDuration) != null ? _a : MAX_VIDEO_DURATION;
1398
+ options.compressLevel = (_b = options.compressLevel) != null ? _b : 3;
1239
1399
  const callbacks = {
1240
1400
  success: (res) => {
1241
1401
  resolve(res || { filePath: "", duration: 0, size: 0, height: 0, width: 0 });
@@ -1248,8 +1408,8 @@ class MediaPlugin {
1248
1408
  }
1249
1409
  };
1250
1410
  this.context.bridge.ready(() => {
1251
- var _a;
1252
- (_a = this.context) == null ? void 0 : _a.bridge.callNative(
1411
+ var _a2;
1412
+ (_a2 = this.context) == null ? void 0 : _a2.bridge.callNative(
1253
1413
  {
1254
1414
  action: "chooseVideo",
1255
1415
  params: options
@@ -1259,13 +1419,77 @@ class MediaPlugin {
1259
1419
  });
1260
1420
  });
1261
1421
  }
1422
+ /**
1423
+ * 上传文件进度回调
1424
+ * @param options 上传进度信息
1425
+ * @param options.progress 上传进度,0-100
1426
+ * @param options.status 上传状态,0: 正在上传、1: 上传成功、2: 失败
1427
+ * @returns void
1428
+ */
1429
+ onUploadProgress(callback) {
1430
+ if (!this.context) {
1431
+ throw createBridgeError(
1432
+ BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
1433
+ "插件未正确初始化"
1434
+ );
1435
+ }
1436
+ this.context.bridge.ready(() => {
1437
+ var _a;
1438
+ (_a = this.context) == null ? void 0 : _a.bridge.onNativeEvent(
1439
+ "onUploadProgress",
1440
+ (event) => {
1441
+ callback(event.data ? JSON.parse(event.data) : {});
1442
+ }
1443
+ );
1444
+ });
1445
+ }
1262
1446
  }
1263
1447
  const mediaPlugin = new MediaPlugin();
1448
+ var __defProp$7 = Object.defineProperty;
1449
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
1450
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
1451
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
1452
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1453
+ var __spreadValues$1 = (a, b) => {
1454
+ for (var prop in b || (b = {}))
1455
+ if (__hasOwnProp$1.call(b, prop))
1456
+ __defNormalProp$7(a, prop, b[prop]);
1457
+ if (__getOwnPropSymbols$1)
1458
+ for (var prop of __getOwnPropSymbols$1(b)) {
1459
+ if (__propIsEnum$1.call(b, prop))
1460
+ __defNormalProp$7(a, prop, b[prop]);
1461
+ }
1462
+ return a;
1463
+ };
1464
+ var __publicField$7 = (obj, key, value) => {
1465
+ __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
1466
+ return value;
1467
+ };
1468
+ var __async$2 = (__this, __arguments, generator) => {
1469
+ return new Promise((resolve, reject) => {
1470
+ var fulfilled = (value) => {
1471
+ try {
1472
+ step(generator.next(value));
1473
+ } catch (e) {
1474
+ reject(e);
1475
+ }
1476
+ };
1477
+ var rejected = (value) => {
1478
+ try {
1479
+ step(generator.throw(value));
1480
+ } catch (e) {
1481
+ reject(e);
1482
+ }
1483
+ };
1484
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1485
+ step((generator = generator.apply(__this, __arguments)).next());
1486
+ });
1487
+ };
1264
1488
  class NavigatePlugin {
1265
1489
  constructor() {
1266
- __publicField(this, "name", "navigate");
1267
- __publicField(this, "version", "1.0.0");
1268
- __publicField(this, "context");
1490
+ __publicField$7(this, "name", "navigate");
1491
+ __publicField$7(this, "version", "1.0.0");
1492
+ __publicField$7(this, "context");
1269
1493
  }
1270
1494
  install(context) {
1271
1495
  this.context = context;
@@ -1278,10 +1502,12 @@ class NavigatePlugin {
1278
1502
  this.setNavigationBar.bind(this)
1279
1503
  );
1280
1504
  context.bridge.registerMethod("openLink", this.openLink.bind(this));
1281
- context.bridge.log(`导航插件 v${this.version} 已安装`);
1505
+ context.bridge.registerMethod("navigateToNativePage", this.navigateToNativePage.bind(this));
1506
+ context.bridge.registerMethod("closeCurrentPage", this.closeCurrentPage.bind(this));
1282
1507
  }
1283
1508
  setNavigationBar(options) {
1284
1509
  return new Promise((resolve, reject) => {
1510
+ var _a;
1285
1511
  if (!this.context) {
1286
1512
  throw createBridgeError(
1287
1513
  BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
@@ -1312,7 +1538,7 @@ class NavigatePlugin {
1312
1538
  "reset参数格式不正确"
1313
1539
  );
1314
1540
  }
1315
- options.isShowBar = options.isShowBar ?? true;
1541
+ options.isShowBar = (_a = options.isShowBar) != null ? _a : true;
1316
1542
  const callbacks = {
1317
1543
  success: () => {
1318
1544
  resolve();
@@ -1330,11 +1556,11 @@ class NavigatePlugin {
1330
1556
  }
1331
1557
  };
1332
1558
  this.context.bridge.ready(() => {
1333
- var _a;
1334
- (_a = this.context) == null ? void 0 : _a.bridge.callNative(
1559
+ var _a2;
1560
+ (_a2 = this.context) == null ? void 0 : _a2.bridge.callNative(
1335
1561
  {
1336
1562
  action: "setNavigationBar",
1337
- params: { ...options }
1563
+ params: __spreadValues$1({}, options)
1338
1564
  },
1339
1565
  callbacks
1340
1566
  );
@@ -1390,7 +1616,7 @@ class NavigatePlugin {
1390
1616
  (_a = this.context) == null ? void 0 : _a.bridge.callNative(
1391
1617
  {
1392
1618
  action: type || "navigateTo",
1393
- params: { ...options }
1619
+ params: __spreadValues$1({}, options)
1394
1620
  },
1395
1621
  callbacks
1396
1622
  );
@@ -1407,6 +1633,7 @@ class NavigatePlugin {
1407
1633
  this.navigate(options, "reLaunch");
1408
1634
  }
1409
1635
  navigateBack(options) {
1636
+ var _a;
1410
1637
  if (!this.context) {
1411
1638
  throw createBridgeError(
1412
1639
  BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
@@ -1419,35 +1646,35 @@ class NavigatePlugin {
1419
1646
  "delta参数格式不正确"
1420
1647
  );
1421
1648
  }
1422
- options.delta = options.delta ?? 1;
1649
+ options.delta = (_a = options.delta) != null ? _a : 1;
1423
1650
  const callbacks = {
1424
1651
  success: (res) => {
1425
- var _a;
1652
+ var _a2;
1426
1653
  const resp = {
1427
1654
  code: BridgeErrorCode.SUCCESS,
1428
1655
  message: "跳转成功",
1429
1656
  data: res
1430
1657
  };
1431
- (_a = options.success) == null ? void 0 : _a.call(options, resp);
1658
+ (_a2 = options.success) == null ? void 0 : _a2.call(options, resp);
1432
1659
  },
1433
1660
  fail: (err) => {
1434
- var _a;
1661
+ var _a2;
1435
1662
  const resp = {
1436
1663
  code: BridgeErrorCode.SYSTEM_ERROR,
1437
1664
  message: "跳转失败",
1438
1665
  details: err,
1439
1666
  name: ""
1440
1667
  };
1441
- (_a = options.fail) == null ? void 0 : _a.call(options, resp);
1668
+ (_a2 = options.fail) == null ? void 0 : _a2.call(options, resp);
1442
1669
  },
1443
1670
  complete: () => {
1444
- var _a;
1445
- (_a = options.complete) == null ? void 0 : _a.call(options);
1671
+ var _a2;
1672
+ (_a2 = options.complete) == null ? void 0 : _a2.call(options);
1446
1673
  }
1447
1674
  };
1448
1675
  this.context.bridge.ready(() => {
1449
- var _a;
1450
- (_a = this.context) == null ? void 0 : _a.bridge.callNative(
1676
+ var _a2;
1677
+ (_a2 = this.context) == null ? void 0 : _a2.bridge.callNative(
1451
1678
  {
1452
1679
  action: "navigateBack",
1453
1680
  params: options
@@ -1461,7 +1688,69 @@ class NavigatePlugin {
1461
1688
  * @param options 链接选项
1462
1689
  * @returns Promise对象,解析为打开链接的响应
1463
1690
  */
1464
- async openLink(options) {
1691
+ openLink(options) {
1692
+ return __async$2(this, null, function* () {
1693
+ return new Promise((resolve, reject) => {
1694
+ if (!this.context) {
1695
+ throw createBridgeError(
1696
+ BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
1697
+ "插件未正确初始化"
1698
+ );
1699
+ }
1700
+ if (!options.url) {
1701
+ throw createBridgeError(
1702
+ BridgeErrorCode.INVALID_ACTION,
1703
+ "缺少必需的参数: url"
1704
+ );
1705
+ }
1706
+ if (typeof options.url !== "string" || !options.url.trim()) {
1707
+ throw createBridgeError(
1708
+ BridgeErrorCode.INVALID_ACTION,
1709
+ "url参数格式错误"
1710
+ );
1711
+ }
1712
+ if (options.enableShare !== void 0 && typeof options.enableShare !== "boolean") {
1713
+ throw createBridgeError(
1714
+ BridgeErrorCode.INVALID_ACTION,
1715
+ "enableShare参数格式不正确"
1716
+ );
1717
+ }
1718
+ options.enableShare = options.enableShare || false;
1719
+ const callbacks = {
1720
+ success: () => {
1721
+ resolve();
1722
+ },
1723
+ fail: (err) => {
1724
+ reject(
1725
+ createBridgeError(
1726
+ BridgeErrorCode.SYSTEM_ERROR,
1727
+ "打开链接失败",
1728
+ err
1729
+ )
1730
+ );
1731
+ },
1732
+ complete: () => {
1733
+ }
1734
+ };
1735
+ this.context.bridge.ready(() => {
1736
+ var _a;
1737
+ (_a = this.context) == null ? void 0 : _a.bridge.callNative(
1738
+ {
1739
+ action: "openLink",
1740
+ params: __spreadValues$1({}, options)
1741
+ },
1742
+ callbacks
1743
+ );
1744
+ });
1745
+ });
1746
+ });
1747
+ }
1748
+ /**
1749
+ * 跳转原生设置页面
1750
+ * @param url 要跳转的原生页面URL
1751
+ * @returns Promise<void>
1752
+ */
1753
+ navigateToNativePage(url) {
1465
1754
  return new Promise((resolve, reject) => {
1466
1755
  if (!this.context) {
1467
1756
  throw createBridgeError(
@@ -1469,25 +1758,52 @@ class NavigatePlugin {
1469
1758
  "插件未正确初始化"
1470
1759
  );
1471
1760
  }
1472
- if (!options.url) {
1761
+ if (!url || typeof url !== "string" || !url.trim()) {
1473
1762
  throw createBridgeError(
1474
1763
  BridgeErrorCode.INVALID_ACTION,
1475
- "缺少必需的参数: url"
1764
+ "url参数格式不正确"
1476
1765
  );
1477
1766
  }
1478
- if (typeof options.url !== "string" || !options.url.trim()) {
1479
- throw createBridgeError(
1480
- BridgeErrorCode.INVALID_ACTION,
1481
- "url参数格式错误"
1767
+ const callbacks = {
1768
+ success: () => {
1769
+ resolve();
1770
+ },
1771
+ fail: (err) => {
1772
+ reject(
1773
+ createBridgeError(
1774
+ BridgeErrorCode.SYSTEM_ERROR,
1775
+ "跳转原生页面失败",
1776
+ err
1777
+ )
1778
+ );
1779
+ },
1780
+ complete: () => {
1781
+ }
1782
+ };
1783
+ this.context.bridge.ready(() => {
1784
+ var _a;
1785
+ (_a = this.context) == null ? void 0 : _a.bridge.callNative(
1786
+ {
1787
+ action: "navigateToNativePage",
1788
+ params: { url }
1789
+ },
1790
+ callbacks
1482
1791
  );
1483
- }
1484
- if (options.enableShare !== void 0 && typeof options.enableShare !== "boolean") {
1792
+ });
1793
+ });
1794
+ }
1795
+ /**
1796
+ * 关闭当前WebView页面
1797
+ * @returns Promise<void>
1798
+ */
1799
+ closeCurrentPage() {
1800
+ return new Promise((resolve, reject) => {
1801
+ if (!this.context) {
1485
1802
  throw createBridgeError(
1486
- BridgeErrorCode.INVALID_ACTION,
1487
- "enableShare参数格式不正确"
1803
+ BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
1804
+ "插件未正确初始化"
1488
1805
  );
1489
1806
  }
1490
- options.enableShare = options.enableShare || false;
1491
1807
  const callbacks = {
1492
1808
  success: () => {
1493
1809
  resolve();
@@ -1496,7 +1812,7 @@ class NavigatePlugin {
1496
1812
  reject(
1497
1813
  createBridgeError(
1498
1814
  BridgeErrorCode.SYSTEM_ERROR,
1499
- "打开链接失败",
1815
+ "关闭页面失败",
1500
1816
  err
1501
1817
  )
1502
1818
  );
@@ -1508,8 +1824,8 @@ class NavigatePlugin {
1508
1824
  var _a;
1509
1825
  (_a = this.context) == null ? void 0 : _a.bridge.callNative(
1510
1826
  {
1511
- action: "openLink",
1512
- params: { ...options }
1827
+ action: "closeCurrentPage",
1828
+ params: {}
1513
1829
  },
1514
1830
  callbacks
1515
1831
  );
@@ -1518,11 +1834,17 @@ class NavigatePlugin {
1518
1834
  }
1519
1835
  }
1520
1836
  const navigatePlugin = new NavigatePlugin();
1837
+ var __defProp$6 = Object.defineProperty;
1838
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1839
+ var __publicField$6 = (obj, key, value) => {
1840
+ __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
1841
+ return value;
1842
+ };
1521
1843
  class ToastPlugin {
1522
1844
  constructor() {
1523
- __publicField(this, "name", "toast");
1524
- __publicField(this, "version", "1.0.0");
1525
- __publicField(this, "context");
1845
+ __publicField$6(this, "name", "toast");
1846
+ __publicField$6(this, "version", "1.0.0");
1847
+ __publicField$6(this, "context");
1526
1848
  }
1527
1849
  install(context) {
1528
1850
  this.context = context;
@@ -1530,7 +1852,6 @@ class ToastPlugin {
1530
1852
  context.bridge.registerMethod("hideToast", this.hideToast.bind(this));
1531
1853
  context.bridge.registerMethod("showLoading", this.showLoading.bind(this));
1532
1854
  context.bridge.registerMethod("hideLoading", this.hideLoading.bind(this));
1533
- context.bridge.log(`导航插件 v${this.version} 已安装`);
1534
1855
  }
1535
1856
  hideLoading() {
1536
1857
  return new Promise((resolve, reject) => {
@@ -1724,16 +2045,21 @@ class ToastPlugin {
1724
2045
  }
1725
2046
  }
1726
2047
  const toastPlugin = new ToastPlugin();
2048
+ var __defProp$5 = Object.defineProperty;
2049
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2050
+ var __publicField$5 = (obj, key, value) => {
2051
+ __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
2052
+ return value;
2053
+ };
1727
2054
  class UserInfoPlugin {
1728
2055
  constructor() {
1729
- __publicField(this, "name", "UserInfo");
1730
- __publicField(this, "version", "1.0.0");
1731
- __publicField(this, "context");
2056
+ __publicField$5(this, "name", "UserInfo");
2057
+ __publicField$5(this, "version", "1.0.0");
2058
+ __publicField$5(this, "context");
1732
2059
  }
1733
2060
  install(context) {
1734
2061
  this.context = context;
1735
2062
  context.bridge.registerMethod("getUserInfo", this.getUserInfo.bind(this));
1736
- context.bridge.log(`导航插件 v${this.version} 已安装`);
1737
2063
  }
1738
2064
  getUserInfo() {
1739
2065
  return new Promise((resolve, reject) => {
@@ -1773,11 +2099,17 @@ class UserInfoPlugin {
1773
2099
  }
1774
2100
  }
1775
2101
  const userinfoPlugin = new UserInfoPlugin();
2102
+ var __defProp$4 = Object.defineProperty;
2103
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2104
+ var __publicField$4 = (obj, key, value) => {
2105
+ __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
2106
+ return value;
2107
+ };
1776
2108
  class BluetoothPlugin {
1777
2109
  constructor() {
1778
- __publicField(this, "name", "bluetooth");
1779
- __publicField(this, "version", "1.0.0");
1780
- __publicField(this, "context");
2110
+ __publicField$4(this, "name", "bluetooth");
2111
+ __publicField$4(this, "version", "1.0.0");
2112
+ __publicField$4(this, "context");
1781
2113
  }
1782
2114
  install(context) {
1783
2115
  this.context = context;
@@ -1845,7 +2177,6 @@ class BluetoothPlugin {
1845
2177
  "offBLEConnectionStateChanged",
1846
2178
  this.offBLEConnectionStateChanged.bind(this)
1847
2179
  );
1848
- context.bridge.log(`蓝牙插件 v${this.version} 已安装`);
1849
2180
  }
1850
2181
  //BLE蓝牙:---------------------------------------------------------------
1851
2182
  /**
@@ -2075,7 +2406,7 @@ class BluetoothPlugin {
2075
2406
  "characteristicId参数格式错误"
2076
2407
  );
2077
2408
  }
2078
- if (typeof options.value !== "string" || !/^[0-9A-Fa-f]+$/.test(options.value) || ((_a = options.value) == null ? void 0 : _a.length) > 20) {
2409
+ if (typeof options.value !== "string" || !/^[0-9A-Fa-f]+$/.test(options.value) || ((_a = options.value) == null ? void 0 : _a.length) > 200) {
2079
2410
  throw createBridgeError(
2080
2411
  BridgeErrorCode.JSON_ERROR,
2081
2412
  "value参数格式错误"
@@ -2526,6 +2857,7 @@ class BluetoothPlugin {
2526
2857
  * @example
2527
2858
  */
2528
2859
  openBluetoothAdapter(options = {}) {
2860
+ var _a;
2529
2861
  if (!this.context) {
2530
2862
  throw createBridgeError(
2531
2863
  BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
@@ -2538,15 +2870,15 @@ class BluetoothPlugin {
2538
2870
  "autoClose参数格式不正确"
2539
2871
  );
2540
2872
  }
2541
- options.autoClose = options.autoClose ?? true;
2873
+ options.autoClose = (_a = options.autoClose) != null ? _a : true;
2542
2874
  const callbacks = {
2543
2875
  success: options.success,
2544
2876
  fail: options.fail,
2545
2877
  complete: options.complete
2546
2878
  };
2547
2879
  this.context.bridge.ready(() => {
2548
- var _a;
2549
- (_a = this.context) == null ? void 0 : _a.bridge.callNative(
2880
+ var _a2;
2881
+ (_a2 = this.context) == null ? void 0 : _a2.bridge.callNative(
2550
2882
  {
2551
2883
  action: "openBluetoothAdapter",
2552
2884
  params: options
@@ -2582,11 +2914,54 @@ class BluetoothPlugin {
2582
2914
  }
2583
2915
  }
2584
2916
  const bluetooth = new BluetoothPlugin();
2917
+ var __defProp$3 = Object.defineProperty;
2918
+ var __defProps = Object.defineProperties;
2919
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
2920
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
2921
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
2922
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
2923
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2924
+ var __spreadValues = (a, b) => {
2925
+ for (var prop in b || (b = {}))
2926
+ if (__hasOwnProp.call(b, prop))
2927
+ __defNormalProp$3(a, prop, b[prop]);
2928
+ if (__getOwnPropSymbols)
2929
+ for (var prop of __getOwnPropSymbols(b)) {
2930
+ if (__propIsEnum.call(b, prop))
2931
+ __defNormalProp$3(a, prop, b[prop]);
2932
+ }
2933
+ return a;
2934
+ };
2935
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
2936
+ var __publicField$3 = (obj, key, value) => {
2937
+ __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
2938
+ return value;
2939
+ };
2940
+ var __async$1 = (__this, __arguments, generator) => {
2941
+ return new Promise((resolve, reject) => {
2942
+ var fulfilled = (value) => {
2943
+ try {
2944
+ step(generator.next(value));
2945
+ } catch (e) {
2946
+ reject(e);
2947
+ }
2948
+ };
2949
+ var rejected = (value) => {
2950
+ try {
2951
+ step(generator.throw(value));
2952
+ } catch (e) {
2953
+ reject(e);
2954
+ }
2955
+ };
2956
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2957
+ step((generator = generator.apply(__this, __arguments)).next());
2958
+ });
2959
+ };
2585
2960
  class StoragePlugin {
2586
2961
  constructor() {
2587
- __publicField(this, "context");
2588
- __publicField(this, "name", "storage");
2589
- __publicField(this, "version", "1.0.0");
2962
+ __publicField$3(this, "context");
2963
+ __publicField$3(this, "name", "storage");
2964
+ __publicField$3(this, "version", "1.0.0");
2590
2965
  }
2591
2966
  install(context) {
2592
2967
  this.context = context;
@@ -2595,7 +2970,6 @@ class StoragePlugin {
2595
2970
  context.bridge.registerMethod("getStorage", this.getStorage.bind(this));
2596
2971
  context.bridge.registerMethod("getStorageSync", this.getStorageSync.bind(this));
2597
2972
  context.bridge.registerMethod("removeStorage", this.removeStorage.bind(this));
2598
- context.bridge.log(`本地存储插件 v${this.version} 已安装`);
2599
2973
  }
2600
2974
  _createCallbacks(options) {
2601
2975
  return {
@@ -2604,38 +2978,39 @@ class StoragePlugin {
2604
2978
  complete: options.complete
2605
2979
  };
2606
2980
  }
2607
- async _callNativeMethod(action, params, callbacks) {
2608
- if (!this.context) {
2609
- throw createBridgeError(
2610
- BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
2611
- "插件未正确初始化"
2612
- );
2613
- }
2614
- return new Promise((resolve, reject) => {
2615
- var _a;
2616
- (_a = this.context) == null ? void 0 : _a.bridge.ready(() => {
2617
- var _a2;
2618
- (_a2 = this.context) == null ? void 0 : _a2.bridge.callNative(
2619
- {
2620
- action,
2621
- params
2622
- },
2623
- {
2624
- ...callbacks,
2625
- success: (response) => {
2626
- if (callbacks.success) {
2627
- callbacks.success(response);
2628
- }
2629
- resolve(response);
2981
+ _callNativeMethod(action, params, callbacks) {
2982
+ return __async$1(this, null, function* () {
2983
+ if (!this.context) {
2984
+ throw createBridgeError(
2985
+ BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
2986
+ "插件未正确初始化"
2987
+ );
2988
+ }
2989
+ return new Promise((resolve, reject) => {
2990
+ var _a;
2991
+ (_a = this.context) == null ? void 0 : _a.bridge.ready(() => {
2992
+ var _a2;
2993
+ (_a2 = this.context) == null ? void 0 : _a2.bridge.callNative(
2994
+ {
2995
+ action,
2996
+ params
2630
2997
  },
2631
- fail: (error) => {
2632
- if (callbacks.fail) {
2633
- callbacks.fail(error);
2998
+ __spreadProps(__spreadValues({}, callbacks), {
2999
+ success: (response) => {
3000
+ if (callbacks.success) {
3001
+ callbacks.success(response);
3002
+ }
3003
+ resolve(response);
3004
+ },
3005
+ fail: (error) => {
3006
+ if (callbacks.fail) {
3007
+ callbacks.fail(error);
3008
+ }
3009
+ reject(error);
2634
3010
  }
2635
- reject(error);
2636
- }
2637
- }
2638
- );
3011
+ })
3012
+ );
3013
+ });
2639
3014
  });
2640
3015
  });
2641
3016
  }
@@ -2681,25 +3056,27 @@ class StoragePlugin {
2681
3056
  );
2682
3057
  });
2683
3058
  }
2684
- async setStorage(options) {
2685
- const key = options.key;
2686
- if (!key) {
2687
- throw createBridgeError(BridgeErrorCode.PLUGIN_NOT_INITIALIZED, "缺少必需的参数: key");
2688
- }
2689
- if (!options.data) {
2690
- throw createBridgeError(BridgeErrorCode.INVALID_ACTION, "缺少必需的参数: data");
2691
- }
2692
- if (typeof key !== "string") {
2693
- throw createBridgeError(BridgeErrorCode.INVALID_ACTION, "key参数格式不正确");
2694
- }
2695
- if (typeof options.data !== "object" && typeof options.data !== "string") {
2696
- throw createBridgeError(BridgeErrorCode.INVALID_ACTION, "data参数格式不正确");
2697
- }
2698
- if (typeof options.data === "object" && Object.keys(options.data).length === 0) {
2699
- throw createBridgeError(BridgeErrorCode.INVALID_ACTION, "data参数格式不正确");
2700
- }
2701
- const callbacks = this._createCallbacks(options);
2702
- return this._callNativeMethod("setStorage", { key: options.key, data: options.data }, callbacks);
3059
+ setStorage(options) {
3060
+ return __async$1(this, null, function* () {
3061
+ const key = options.key;
3062
+ if (!key) {
3063
+ throw createBridgeError(BridgeErrorCode.PLUGIN_NOT_INITIALIZED, "缺少必需的参数: key");
3064
+ }
3065
+ if (!options.data) {
3066
+ throw createBridgeError(BridgeErrorCode.INVALID_ACTION, "缺少必需的参数: data");
3067
+ }
3068
+ if (typeof key !== "string") {
3069
+ throw createBridgeError(BridgeErrorCode.INVALID_ACTION, "key参数格式不正确");
3070
+ }
3071
+ if (typeof options.data !== "object" && typeof options.data !== "string") {
3072
+ throw createBridgeError(BridgeErrorCode.INVALID_ACTION, "data参数格式不正确");
3073
+ }
3074
+ if (typeof options.data === "object" && Object.keys(options.data).length === 0) {
3075
+ throw createBridgeError(BridgeErrorCode.INVALID_ACTION, "data参数格式不正确");
3076
+ }
3077
+ const callbacks = this._createCallbacks(options);
3078
+ return this._callNativeMethod("setStorage", { key: options.key, data: options.data }, callbacks);
3079
+ });
2703
3080
  }
2704
3081
  getStorageSync(options) {
2705
3082
  var _a;
@@ -2719,44 +3096,53 @@ class StoragePlugin {
2719
3096
  const callbacks = this._createCallbacks(options);
2720
3097
  return (_a = this.context) == null ? void 0 : _a.bridge.callNativeSync("getStorageSync", options, callbacks);
2721
3098
  }
2722
- async getStorage(options) {
2723
- const key = options.key;
2724
- if (!key) {
2725
- throw createBridgeError(BridgeErrorCode.PLUGIN_NOT_INITIALIZED, "缺少必需的参数: key");
2726
- }
2727
- if (typeof key !== "string") {
2728
- throw createBridgeError(BridgeErrorCode.INVALID_ACTION, "key参数格式不正确");
2729
- }
2730
- const callbacks = this._createCallbacks(options);
2731
- return this._callNativeMethod("getStorage", { key: options.key }, callbacks);
3099
+ getStorage(options) {
3100
+ return __async$1(this, null, function* () {
3101
+ const key = options.key;
3102
+ if (!key) {
3103
+ throw createBridgeError(BridgeErrorCode.PLUGIN_NOT_INITIALIZED, "缺少必需的参数: key");
3104
+ }
3105
+ if (typeof key !== "string") {
3106
+ throw createBridgeError(BridgeErrorCode.INVALID_ACTION, "key参数格式不正确");
3107
+ }
3108
+ const callbacks = this._createCallbacks(options);
3109
+ return this._callNativeMethod("getStorage", { key: options.key }, callbacks);
3110
+ });
2732
3111
  }
2733
3112
  /**
2734
3113
  * 移除指定的存储数据(异步)
2735
3114
  * @param options 存储选项,包含键值
2736
3115
  * @returns 存储响应
2737
3116
  */
2738
- async removeStorage(options) {
2739
- const key = options.key;
2740
- if (!key) {
2741
- throw createBridgeError(BridgeErrorCode.PLUGIN_NOT_INITIALIZED, "缺少必需的参数: key");
2742
- }
2743
- if (typeof key !== "string") {
2744
- throw createBridgeError(BridgeErrorCode.INVALID_ACTION, "key参数格式不正确");
2745
- }
2746
- const callbacks = this._createCallbacks(options);
2747
- return this._callNativeMethod("removeStorage", { key }, callbacks);
3117
+ removeStorage(options) {
3118
+ return __async$1(this, null, function* () {
3119
+ const key = options.key;
3120
+ if (!key) {
3121
+ throw createBridgeError(BridgeErrorCode.PLUGIN_NOT_INITIALIZED, "缺少必需的参数: key");
3122
+ }
3123
+ if (typeof key !== "string") {
3124
+ throw createBridgeError(BridgeErrorCode.INVALID_ACTION, "key参数格式不正确");
3125
+ }
3126
+ const callbacks = this._createCallbacks(options);
3127
+ return this._callNativeMethod("removeStorage", { key }, callbacks);
3128
+ });
2748
3129
  }
2749
3130
  }
2750
3131
  const storagePlugin = new StoragePlugin();
3132
+ var __defProp$2 = Object.defineProperty;
3133
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3134
+ var __publicField$2 = (obj, key, value) => {
3135
+ __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
3136
+ return value;
3137
+ };
2751
3138
  class AuthenticationPlugin {
2752
3139
  constructor() {
2753
- __publicField(this, "context");
2754
- __publicField(this, "name", "authentication");
2755
- __publicField(this, "version", "1.0.0");
3140
+ __publicField$2(this, "context");
3141
+ __publicField$2(this, "name", "authentication");
3142
+ __publicField$2(this, "version", "1.0.0");
2756
3143
  }
2757
3144
  install(context) {
2758
3145
  this.context = context;
2759
- context.bridge.log(`实人认证插件 v${this.version} 已安装`);
2760
3146
  context.bridge.registerMethod(
2761
3147
  "exclusiveLiveCheck",
2762
3148
  this.exclusiveLiveCheck.bind(this)
@@ -2802,11 +3188,17 @@ class AuthenticationPlugin {
2802
3188
  }
2803
3189
  }
2804
3190
  const authenticationPlugin = new AuthenticationPlugin();
3191
+ var __defProp$1 = Object.defineProperty;
3192
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3193
+ var __publicField$1 = (obj, key, value) => {
3194
+ __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
3195
+ return value;
3196
+ };
2805
3197
  class RequestPlugin {
2806
3198
  constructor() {
2807
- __publicField(this, "name", "request");
2808
- __publicField(this, "version", "1.0.0");
2809
- __publicField(this, "context");
3199
+ __publicField$1(this, "name", "request");
3200
+ __publicField$1(this, "version", "1.0.0");
3201
+ __publicField$1(this, "context");
2810
3202
  }
2811
3203
  /**
2812
3204
  * 安装插件
@@ -2817,7 +3209,6 @@ class RequestPlugin {
2817
3209
  context.bridge.registerMethod("httpRequestSync", this.httpRequestSync.bind(this));
2818
3210
  context.bridge.registerMethod("uploadFile", this.uploadFile.bind(this));
2819
3211
  context.bridge.registerMethod("downloadFile", this.downloadFile.bind(this));
2820
- context.bridge.log(`网络请求插件 v${this.version} 已安装`);
2821
3212
  }
2822
3213
  /**
2823
3214
  * 执行HTTP请求
@@ -2880,18 +3271,12 @@ class RequestPlugin {
2880
3271
  options.cacheModel = options.cacheModel || "noStore";
2881
3272
  const callbacks = {
2882
3273
  success: (res) => {
2883
- var _a;
2884
- (_a = options == null ? void 0 : options.success) == null ? void 0 : _a.call(options, res);
2885
3274
  resolve(res);
2886
3275
  },
2887
3276
  fail: (err) => {
2888
- var _a;
2889
- (_a = options.fail) == null ? void 0 : _a.call(options, err);
2890
3277
  reject(err);
2891
3278
  },
2892
3279
  complete: () => {
2893
- var _a;
2894
- (_a = options.complete) == null ? void 0 : _a.call(options);
2895
3280
  }
2896
3281
  };
2897
3282
  this.context.bridge.ready(() => {
@@ -2908,7 +3293,7 @@ class RequestPlugin {
2908
3293
  });
2909
3294
  }
2910
3295
  /**
2911
- *
3296
+ *
2912
3297
  */
2913
3298
  httpRequestSync(options) {
2914
3299
  if (!this.context) {
@@ -3085,6 +3470,32 @@ class RequestPlugin {
3085
3470
  }
3086
3471
  }
3087
3472
  const requestPlugin = new RequestPlugin();
3473
+ var __defProp = Object.defineProperty;
3474
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3475
+ var __publicField = (obj, key, value) => {
3476
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
3477
+ return value;
3478
+ };
3479
+ var __async = (__this, __arguments, generator) => {
3480
+ return new Promise((resolve, reject) => {
3481
+ var fulfilled = (value) => {
3482
+ try {
3483
+ step(generator.next(value));
3484
+ } catch (e) {
3485
+ reject(e);
3486
+ }
3487
+ };
3488
+ var rejected = (value) => {
3489
+ try {
3490
+ step(generator.throw(value));
3491
+ } catch (e) {
3492
+ reject(e);
3493
+ }
3494
+ };
3495
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
3496
+ step((generator = generator.apply(__this, __arguments)).next());
3497
+ });
3498
+ };
3088
3499
  class WifiPlugin {
3089
3500
  constructor() {
3090
3501
  __publicField(this, "context");
@@ -3097,7 +3508,6 @@ class WifiPlugin {
3097
3508
  context.bridge.registerMethod("stopWifi", this.stopWifi.bind(this));
3098
3509
  context.bridge.registerMethod("connectWifi", this.connectWifi.bind(this));
3099
3510
  context.bridge.registerMethod("getScanWifiListAsync", this.getScanWifiListAsync.bind(this));
3100
- context.bridge.log(`Wi-Fi 插件 v${this.version} 已安装`);
3101
3511
  }
3102
3512
  /**
3103
3513
  * 初始化 Wi-Fi 模块
@@ -3171,6 +3581,7 @@ class WifiPlugin {
3171
3581
  */
3172
3582
  connectWifi(options) {
3173
3583
  return new Promise((resolve, reject) => {
3584
+ var _a;
3174
3585
  if (!this.context) {
3175
3586
  throw createBridgeError(
3176
3587
  BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
@@ -3207,7 +3618,7 @@ class WifiPlugin {
3207
3618
  "isWEP参数格式错误"
3208
3619
  );
3209
3620
  }
3210
- options.isWEP = options.isWEP ?? false;
3621
+ options.isWEP = (_a = options.isWEP) != null ? _a : false;
3211
3622
  const callbacks = {
3212
3623
  success: (res) => {
3213
3624
  resolve(res);
@@ -3218,8 +3629,8 @@ class WifiPlugin {
3218
3629
  complete: options.complete
3219
3630
  };
3220
3631
  this.context.bridge.ready(() => {
3221
- var _a;
3222
- (_a = this.context) == null ? void 0 : _a.bridge.callNative(
3632
+ var _a2;
3633
+ (_a2 = this.context) == null ? void 0 : _a2.bridge.callNative(
3223
3634
  {
3224
3635
  action: "connectWifi",
3225
3636
  params: options
@@ -3234,45 +3645,47 @@ class WifiPlugin {
3234
3645
  * @param options 获取 Wi-Fi 列表的选项
3235
3646
  * @returns 返回一个 Promise,解析为 Wi-Fi 列表响应数据
3236
3647
  */
3237
- async getScanWifiListAsync(options) {
3238
- return new Promise((resolve, reject) => {
3239
- if (!this.context) {
3240
- throw createBridgeError(
3241
- BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
3242
- "插件未正确初始化"
3243
- );
3244
- }
3245
- if (typeof options.timeout !== "number") {
3246
- throw createBridgeError(
3247
- BridgeErrorCode.INVALID_ACTION,
3248
- "timeout参数格式错误"
3249
- );
3250
- }
3251
- if (typeof options.cacheTime !== "number") {
3252
- throw createBridgeError(
3253
- BridgeErrorCode.INVALID_ACTION,
3254
- "cacheTime参数格式错误"
3255
- );
3256
- }
3257
- const callbacks = {
3258
- success: (res) => {
3259
- resolve(res);
3260
- },
3261
- fail: (err) => {
3262
- reject(err);
3263
- },
3264
- complete: options.complete
3265
- };
3266
- this.context.bridge.ready(() => {
3267
- var _a;
3268
- (_a = this.context) == null ? void 0 : _a.bridge.callNative(
3269
- {
3270
- action: "getScanWifiListAsync",
3271
- params: options,
3272
- timeout: options.timeout
3648
+ getScanWifiListAsync(options) {
3649
+ return __async(this, null, function* () {
3650
+ return new Promise((resolve, reject) => {
3651
+ if (!this.context) {
3652
+ throw createBridgeError(
3653
+ BridgeErrorCode.PLUGIN_NOT_INITIALIZED,
3654
+ "插件未正确初始化"
3655
+ );
3656
+ }
3657
+ if (typeof options.timeout !== "number") {
3658
+ throw createBridgeError(
3659
+ BridgeErrorCode.INVALID_ACTION,
3660
+ "timeout参数格式错误"
3661
+ );
3662
+ }
3663
+ if (typeof options.cacheTime !== "number") {
3664
+ throw createBridgeError(
3665
+ BridgeErrorCode.INVALID_ACTION,
3666
+ "cacheTime参数格式错误"
3667
+ );
3668
+ }
3669
+ const callbacks = {
3670
+ success: (res) => {
3671
+ resolve(res);
3273
3672
  },
3274
- callbacks
3275
- );
3673
+ fail: (err) => {
3674
+ reject(err);
3675
+ },
3676
+ complete: options.complete
3677
+ };
3678
+ this.context.bridge.ready(() => {
3679
+ var _a;
3680
+ (_a = this.context) == null ? void 0 : _a.bridge.callNative(
3681
+ {
3682
+ action: "getScanWifiListAsync",
3683
+ params: options,
3684
+ timeout: options.timeout
3685
+ },
3686
+ callbacks
3687
+ );
3688
+ });
3276
3689
  });
3277
3690
  });
3278
3691
  }