qsh-webview-sdk 2.2.2 → 2.3.0
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/README.md +18 -49
- package/dist/index.d.ts +5 -1
- package/dist/qsh-webview-sdk.es.js +948 -809
- package/dist/qsh-webview-sdk.es.js.map +1 -1
- package/dist/qsh-webview-sdk.umd.js +1 -1
- package/dist/qsh-webview-sdk.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var zt = Object.defineProperty, Kt = Object.defineProperties;
|
|
2
|
+
var Gt = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var ke = Object.getOwnPropertySymbols;
|
|
4
|
+
var Vt = Object.prototype.hasOwnProperty, jt = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var Pe = (t, e, r) => e in t ? zt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, d = (t, e) => {
|
|
6
6
|
for (var r in e || (e = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var r of
|
|
10
|
-
|
|
7
|
+
Vt.call(e, r) && Pe(t, r, e[r]);
|
|
8
|
+
if (ke)
|
|
9
|
+
for (var r of ke(e))
|
|
10
|
+
jt.call(e, r) && Pe(t, r, e[r]);
|
|
11
11
|
return t;
|
|
12
|
-
},
|
|
13
|
-
var U = (t, e, r) =>
|
|
14
|
-
var
|
|
12
|
+
}, p = (t, e) => Kt(t, Gt(e));
|
|
13
|
+
var U = (t, e, r) => Pe(t, typeof e != "symbol" ? e + "" : e, r);
|
|
14
|
+
var m = (t, e, r) => new Promise((n, i) => {
|
|
15
15
|
var a = (h) => {
|
|
16
16
|
try {
|
|
17
17
|
f(r.next(h));
|
|
@@ -27,60 +27,72 @@ var p = (t, e, r) => new Promise((n, i) => {
|
|
|
27
27
|
}, f = (h) => h.done ? n(h.value) : Promise.resolve(h.value).then(a, o);
|
|
28
28
|
f((r = r.apply(t, e)).next());
|
|
29
29
|
});
|
|
30
|
-
function
|
|
30
|
+
function ue() {
|
|
31
31
|
return typeof window != "undefined" ? window : void 0;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function Me() {
|
|
34
34
|
return typeof navigator == "undefined" ? "" : navigator.userAgent || "";
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
const t =
|
|
36
|
+
function I() {
|
|
37
|
+
const t = ue();
|
|
38
38
|
if (!t) return !1;
|
|
39
39
|
if (t.__wxjs_environment === "miniprogram" || t.wx && t.wx.miniProgram)
|
|
40
40
|
return !0;
|
|
41
|
-
const e =
|
|
41
|
+
const e = Me();
|
|
42
42
|
return !!(e && /micromessenger/i.test(e) && /miniProgram/i.test(e));
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
const t =
|
|
44
|
+
function ye() {
|
|
45
|
+
const t = ue();
|
|
46
46
|
return !!(t && t.plus);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
const t =
|
|
48
|
+
function Ie() {
|
|
49
|
+
const t = ue();
|
|
50
50
|
return !!(t && (t.__dcloud_weex_postMessage || t.__dcloud_weex_));
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
const t =
|
|
52
|
+
function Ae() {
|
|
53
|
+
const t = ue();
|
|
54
54
|
return !!(t && (t.__uniapp_x_postMessage || t.__uniapp_x_));
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
const t =
|
|
56
|
+
function Oe() {
|
|
57
|
+
const t = Me();
|
|
58
58
|
return /uni-app/i.test(t);
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
const t =
|
|
60
|
+
function Le() {
|
|
61
|
+
const t = Me();
|
|
62
62
|
return /Html5Plus/i.test(t);
|
|
63
63
|
}
|
|
64
|
-
function
|
|
65
|
-
return
|
|
66
|
-
}
|
|
67
|
-
function
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
64
|
+
function Je() {
|
|
65
|
+
return Oe() || Le();
|
|
66
|
+
}
|
|
67
|
+
function H() {
|
|
68
|
+
const t = ue();
|
|
69
|
+
if (!t) return !1;
|
|
70
|
+
if (t.__offline_bridge_postMessage) return !0;
|
|
71
|
+
try {
|
|
72
|
+
const e = t.location && t.location.hostname;
|
|
73
|
+
if (e && /\.?offline\.?/i.test(e)) return !0;
|
|
74
|
+
} catch (e) {
|
|
75
|
+
}
|
|
76
|
+
return !1;
|
|
77
|
+
}
|
|
78
|
+
function qt() {
|
|
79
|
+
return Ae() ? "uvue" : Ie() ? "nvue" : I() ? "weixin" : H() ? "offline" : ye() ? "plus" : Je() ? "webview" : Oe() ? "UniApp" : "h5";
|
|
80
|
+
}
|
|
81
|
+
let de = null;
|
|
82
|
+
function ne(t = !1) {
|
|
83
|
+
return de && !t || (de = {
|
|
84
|
+
isWeixinMiniProgram: I(),
|
|
85
|
+
isAppPlus: ye(),
|
|
86
|
+
isNvue: Ie(),
|
|
87
|
+
isUvue: Ae(),
|
|
88
|
+
isUniApp: Oe(),
|
|
89
|
+
isHtml5Plus: Le(),
|
|
90
|
+
isUniAppWebView: Je(),
|
|
91
|
+
isOfflineWebview: H(),
|
|
92
|
+
type: qt()
|
|
93
|
+
}), de;
|
|
94
|
+
}
|
|
95
|
+
const l = ne(), L = {
|
|
84
96
|
PLATFORM_NOT_SUPPORTED: "PLATFORM_NOT_SUPPORTED",
|
|
85
97
|
API_CALL_FAILED: "API_CALL_FAILED",
|
|
86
98
|
BRIDGE_NOT_READY: "BRIDGE_NOT_READY",
|
|
@@ -218,7 +230,7 @@ const C = class C {
|
|
|
218
230
|
* @returns {Promise} Promise 对象
|
|
219
231
|
*/
|
|
220
232
|
static safeExecuteAsync(n) {
|
|
221
|
-
return
|
|
233
|
+
return m(this, arguments, function* (e, r = {}) {
|
|
222
234
|
try {
|
|
223
235
|
return yield e();
|
|
224
236
|
} catch (i) {
|
|
@@ -265,20 +277,20 @@ const C = class C {
|
|
|
265
277
|
return function(r, n, i) {
|
|
266
278
|
const a = i.value;
|
|
267
279
|
return i.value = function(...o) {
|
|
268
|
-
return C.safeExecute(() => a.apply(this, o),
|
|
280
|
+
return C.safeExecute(() => a.apply(this, o), p(d({}, e), { method: n, target: r.constructor.name }));
|
|
269
281
|
}, i;
|
|
270
282
|
};
|
|
271
283
|
}
|
|
272
284
|
};
|
|
273
285
|
U(C, "isDebugMode", !1), U(C, "errorCallbacks", []);
|
|
274
|
-
let
|
|
286
|
+
let u = C;
|
|
275
287
|
const M = {
|
|
276
288
|
UNINITIALIZED: "uninitialized",
|
|
277
289
|
INITIALIZING: "initializing",
|
|
278
290
|
READY: "ready",
|
|
279
291
|
ERROR: "error"
|
|
280
292
|
};
|
|
281
|
-
class
|
|
293
|
+
class Jt {
|
|
282
294
|
constructor() {
|
|
283
295
|
this.state = M.UNINITIALIZED, this.readyPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.initializationError = null, this.handleBridgeReady = this.handleBridgeReady.bind(this), this.handleInitializationError = this.handleInitializationError.bind(this);
|
|
284
296
|
}
|
|
@@ -332,7 +344,7 @@ class Vt {
|
|
|
332
344
|
* @returns {Promise<void>} 初始化 Promise
|
|
333
345
|
*/
|
|
334
346
|
startInitialization(e) {
|
|
335
|
-
return
|
|
347
|
+
return m(this, null, function* () {
|
|
336
348
|
if (this.state !== M.UNINITIALIZED)
|
|
337
349
|
return this.waitForReady();
|
|
338
350
|
this.state = M.INITIALIZING;
|
|
@@ -353,7 +365,7 @@ class Vt {
|
|
|
353
365
|
try {
|
|
354
366
|
e();
|
|
355
367
|
} catch (r) {
|
|
356
|
-
|
|
368
|
+
u.handleApiError(r, { context: "StateManager.handleBridgeReady" });
|
|
357
369
|
}
|
|
358
370
|
}), this.readyCallbacks = [], this.errorCallbacks = []);
|
|
359
371
|
}
|
|
@@ -367,7 +379,7 @@ class Vt {
|
|
|
367
379
|
try {
|
|
368
380
|
r(e);
|
|
369
381
|
} catch (n) {
|
|
370
|
-
|
|
382
|
+
u.handleApiError(n, { context: "StateManager.handleInitializationError" });
|
|
371
383
|
}
|
|
372
384
|
}), this.readyCallbacks = [], this.errorCallbacks = [];
|
|
373
385
|
}
|
|
@@ -411,52 +423,52 @@ class Vt {
|
|
|
411
423
|
};
|
|
412
424
|
}
|
|
413
425
|
}
|
|
414
|
-
const
|
|
426
|
+
const q = new Jt(), He = () => q.waitForReady(), Ht = () => q.isReady(), Yt = () => q.getState(), A = {
|
|
415
427
|
ERROR: 0,
|
|
416
428
|
WARN: 1,
|
|
417
429
|
INFO: 2,
|
|
418
430
|
DEBUG: 3,
|
|
419
431
|
TRACE: 4
|
|
420
|
-
},
|
|
421
|
-
[
|
|
422
|
-
[
|
|
423
|
-
[
|
|
424
|
-
[
|
|
425
|
-
[
|
|
426
|
-
},
|
|
432
|
+
}, ie = {
|
|
433
|
+
[A.ERROR]: "ERROR",
|
|
434
|
+
[A.WARN]: "WARN",
|
|
435
|
+
[A.INFO]: "INFO",
|
|
436
|
+
[A.DEBUG]: "DEBUG",
|
|
437
|
+
[A.TRACE]: "TRACE"
|
|
438
|
+
}, g = class g {
|
|
427
439
|
// 可注入的外部 reporter
|
|
428
440
|
/**
|
|
429
441
|
* 设置日志级别
|
|
430
442
|
* @param {number} level - 日志级别
|
|
431
443
|
*/
|
|
432
444
|
static setLevel(e) {
|
|
433
|
-
e >=
|
|
445
|
+
e >= A.ERROR && e <= A.TRACE && (g.currentLevel = e, g.log(A.INFO, "Logger", `日志级别设置为: ${ie[e]}`));
|
|
434
446
|
}
|
|
435
447
|
/**
|
|
436
448
|
* 启用开发模式(显示所有日志)
|
|
437
449
|
*/
|
|
438
450
|
static enableDevMode() {
|
|
439
|
-
|
|
451
|
+
g.setLevel(A.DEBUG), g.log(A.INFO, "Logger", "开发模式已启用");
|
|
440
452
|
}
|
|
441
453
|
/**
|
|
442
454
|
* 启用生产模式(只显示错误和警告)
|
|
443
455
|
*/
|
|
444
456
|
static enableProdMode() {
|
|
445
|
-
|
|
457
|
+
g.setLevel(A.WARN), g.log(A.INFO, "Logger", "生产模式已启用");
|
|
446
458
|
}
|
|
447
459
|
/**
|
|
448
460
|
* 启用特定模块的日志
|
|
449
461
|
* @param {string} module - 模块名称
|
|
450
462
|
*/
|
|
451
463
|
static enableModule(e) {
|
|
452
|
-
|
|
464
|
+
g.enabledModules.add(e), g.log(A.INFO, "Logger", `模块日志已启用: ${e}`);
|
|
453
465
|
}
|
|
454
466
|
/**
|
|
455
467
|
* 禁用特定模块的日志
|
|
456
468
|
* @param {string} module - 模块名称
|
|
457
469
|
*/
|
|
458
470
|
static disableModule(e) {
|
|
459
|
-
|
|
471
|
+
g.enabledModules.delete(e), g.log(A.INFO, "Logger", `模块日志已禁用: ${e}`);
|
|
460
472
|
}
|
|
461
473
|
/**
|
|
462
474
|
* 检查是否应该记录日志
|
|
@@ -466,7 +478,7 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
466
478
|
* @private
|
|
467
479
|
*/
|
|
468
480
|
static shouldLog(e, r) {
|
|
469
|
-
return e >
|
|
481
|
+
return e > g.currentLevel ? !1 : r && g.enabledModules.size > 0 ? g.enabledModules.has(r) : !0;
|
|
470
482
|
}
|
|
471
483
|
/**
|
|
472
484
|
* 核心日志记录方法
|
|
@@ -477,9 +489,9 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
477
489
|
* @private
|
|
478
490
|
*/
|
|
479
491
|
static log(e, r, n, ...i) {
|
|
480
|
-
if (!
|
|
492
|
+
if (!g.shouldLog(e, r))
|
|
481
493
|
return;
|
|
482
|
-
const a = (/* @__PURE__ */ new Date()).toISOString(), o =
|
|
494
|
+
const a = (/* @__PURE__ */ new Date()).toISOString(), o = ie[e], f = r ? `[${r}]` : "", h = `${g.prefix} ${f} ${n}`, O = {
|
|
483
495
|
timestamp: a,
|
|
484
496
|
level: e,
|
|
485
497
|
levelName: o,
|
|
@@ -487,12 +499,12 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
487
499
|
message: n,
|
|
488
500
|
args: i
|
|
489
501
|
};
|
|
490
|
-
if (
|
|
502
|
+
if (g.addToHistory(O), typeof g.reporter == "function")
|
|
491
503
|
try {
|
|
492
|
-
|
|
504
|
+
g.reporter(O);
|
|
493
505
|
} catch (b) {
|
|
494
506
|
}
|
|
495
|
-
|
|
507
|
+
g.outputToConsole(e, h, ...i);
|
|
496
508
|
}
|
|
497
509
|
/**
|
|
498
510
|
* 添加日志到历史记录
|
|
@@ -500,7 +512,7 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
500
512
|
* @private
|
|
501
513
|
*/
|
|
502
514
|
static addToHistory(e) {
|
|
503
|
-
|
|
515
|
+
g.logHistory.push(e), g.logHistory.length > g.maxHistorySize && g.logHistory.shift();
|
|
504
516
|
}
|
|
505
517
|
/**
|
|
506
518
|
* 输出到控制台
|
|
@@ -514,17 +526,17 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
514
526
|
return;
|
|
515
527
|
const i = n && n.length > 0;
|
|
516
528
|
switch (e) {
|
|
517
|
-
case
|
|
529
|
+
case A.ERROR:
|
|
518
530
|
i ? console.error(r, ...n) : console.error(r);
|
|
519
531
|
break;
|
|
520
|
-
case
|
|
532
|
+
case A.WARN:
|
|
521
533
|
i ? console.warn(r, ...n) : console.warn(r);
|
|
522
534
|
break;
|
|
523
|
-
case
|
|
535
|
+
case A.INFO:
|
|
524
536
|
i ? console.info(r, ...n) : console.info(r);
|
|
525
537
|
break;
|
|
526
|
-
case
|
|
527
|
-
case
|
|
538
|
+
case A.DEBUG:
|
|
539
|
+
case A.TRACE:
|
|
528
540
|
i ? console.log(r, ...n) : console.log(r);
|
|
529
541
|
break;
|
|
530
542
|
}
|
|
@@ -536,7 +548,7 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
536
548
|
* @param {any[]} args - 额外参数
|
|
537
549
|
*/
|
|
538
550
|
static error(e, r, ...n) {
|
|
539
|
-
|
|
551
|
+
g.log(A.ERROR, e, r, ...n);
|
|
540
552
|
}
|
|
541
553
|
/**
|
|
542
554
|
* 警告级别日志
|
|
@@ -545,7 +557,7 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
545
557
|
* @param {any[]} args - 额外参数
|
|
546
558
|
*/
|
|
547
559
|
static warn(e, r, ...n) {
|
|
548
|
-
|
|
560
|
+
g.log(A.WARN, e, r, ...n);
|
|
549
561
|
}
|
|
550
562
|
/**
|
|
551
563
|
* 信息级别日志
|
|
@@ -554,7 +566,7 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
554
566
|
* @param {any[]} args - 额外参数
|
|
555
567
|
*/
|
|
556
568
|
static info(e, r, ...n) {
|
|
557
|
-
|
|
569
|
+
g.log(A.INFO, e, r, ...n);
|
|
558
570
|
}
|
|
559
571
|
/**
|
|
560
572
|
* 调试级别日志
|
|
@@ -563,7 +575,7 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
563
575
|
* @param {any[]} args - 额外参数
|
|
564
576
|
*/
|
|
565
577
|
static debug(e, r, ...n) {
|
|
566
|
-
|
|
578
|
+
g.log(A.DEBUG, e, r, ...n);
|
|
567
579
|
}
|
|
568
580
|
/**
|
|
569
581
|
* 跟踪级别日志
|
|
@@ -572,7 +584,7 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
572
584
|
* @param {any[]} args - 额外参数
|
|
573
585
|
*/
|
|
574
586
|
static trace(e, r, ...n) {
|
|
575
|
-
|
|
587
|
+
g.log(A.TRACE, e, r, ...n);
|
|
576
588
|
}
|
|
577
589
|
/**
|
|
578
590
|
* 获取日志历史
|
|
@@ -580,13 +592,13 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
580
592
|
* @returns {Array} 日志条目数组
|
|
581
593
|
*/
|
|
582
594
|
static getHistory(e) {
|
|
583
|
-
return e && e > 0 ?
|
|
595
|
+
return e && e > 0 ? g.logHistory.slice(-e) : [...g.logHistory];
|
|
584
596
|
}
|
|
585
597
|
/**
|
|
586
598
|
* 清空日志历史
|
|
587
599
|
*/
|
|
588
600
|
static clearHistory() {
|
|
589
|
-
|
|
601
|
+
g.logHistory = [], g.log(A.INFO, "Logger", "日志历史已清空");
|
|
590
602
|
}
|
|
591
603
|
/**
|
|
592
604
|
* 获取日志统计信息
|
|
@@ -594,15 +606,15 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
594
606
|
*/
|
|
595
607
|
static getStats() {
|
|
596
608
|
const e = {
|
|
597
|
-
currentLevel:
|
|
598
|
-
currentLevelName:
|
|
599
|
-
enabledModules: Array.from(
|
|
600
|
-
historySize:
|
|
601
|
-
maxHistorySize:
|
|
609
|
+
currentLevel: g.currentLevel,
|
|
610
|
+
currentLevelName: ie[g.currentLevel],
|
|
611
|
+
enabledModules: Array.from(g.enabledModules),
|
|
612
|
+
historySize: g.logHistory.length,
|
|
613
|
+
maxHistorySize: g.maxHistorySize
|
|
602
614
|
}, r = {};
|
|
603
|
-
for (const n of Object.keys(
|
|
604
|
-
r[
|
|
605
|
-
return
|
|
615
|
+
for (const n of Object.keys(ie))
|
|
616
|
+
r[ie[n]] = 0;
|
|
617
|
+
return g.logHistory.forEach((n) => {
|
|
606
618
|
r[n.levelName]++;
|
|
607
619
|
}), e.levelCounts = r, e;
|
|
608
620
|
}
|
|
@@ -612,7 +624,7 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
612
624
|
* @returns {string} JSON 字符串
|
|
613
625
|
*/
|
|
614
626
|
static exportToJSON(e) {
|
|
615
|
-
const r =
|
|
627
|
+
const r = g.getHistory(e), n = g.getStats();
|
|
616
628
|
return JSON.stringify({
|
|
617
629
|
exportTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
618
630
|
stats: n,
|
|
@@ -626,11 +638,11 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
626
638
|
*/
|
|
627
639
|
static createModuleLogger(e) {
|
|
628
640
|
return {
|
|
629
|
-
error: (r, ...n) =>
|
|
630
|
-
warn: (r, ...n) =>
|
|
631
|
-
info: (r, ...n) =>
|
|
632
|
-
debug: (r, ...n) =>
|
|
633
|
-
trace: (r, ...n) =>
|
|
641
|
+
error: (r, ...n) => g.error(e, r, ...n),
|
|
642
|
+
warn: (r, ...n) => g.warn(e, r, ...n),
|
|
643
|
+
info: (r, ...n) => g.info(e, r, ...n),
|
|
644
|
+
debug: (r, ...n) => g.debug(e, r, ...n),
|
|
645
|
+
trace: (r, ...n) => g.trace(e, r, ...n)
|
|
634
646
|
};
|
|
635
647
|
}
|
|
636
648
|
/**
|
|
@@ -638,14 +650,14 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
638
650
|
* @param {(entry: any) => void|null} reporter
|
|
639
651
|
*/
|
|
640
652
|
static setReporter(e) {
|
|
641
|
-
|
|
653
|
+
g.reporter = typeof e == "function" ? e : null;
|
|
642
654
|
}
|
|
643
655
|
};
|
|
644
|
-
U(
|
|
645
|
-
U(
|
|
646
|
-
U(
|
|
647
|
-
U(
|
|
648
|
-
let T =
|
|
656
|
+
U(g, "currentLevel", A.ERROR), // 生产环境默认只显示错误
|
|
657
|
+
U(g, "enabledModules", /* @__PURE__ */ new Set()), // 启用日志的模块
|
|
658
|
+
U(g, "logHistory", []), // 日志历史(最多保留1000条)
|
|
659
|
+
U(g, "maxHistorySize", 1e3), U(g, "prefix", "[QSH-SDK]"), U(g, "reporter", null);
|
|
660
|
+
let T = g;
|
|
649
661
|
if (typeof window != "undefined") {
|
|
650
662
|
const t = window.location && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname.includes("192.168.")), e = window.location && (window.location.search.includes("debug=true") || window.location.search.includes("qsh_debug=1"));
|
|
651
663
|
let r = !1;
|
|
@@ -655,32 +667,50 @@ if (typeof window != "undefined") {
|
|
|
655
667
|
}
|
|
656
668
|
(t || e || r) && T.enableDevMode();
|
|
657
669
|
}
|
|
658
|
-
const
|
|
659
|
-
function
|
|
660
|
-
|
|
670
|
+
const E = T.createModuleLogger("Bridge"), w = T.createModuleLogger("Platform"), s = T.createModuleLogger("API"), x = T.createModuleLogger("State"), pe = /complete|loaded|interactive/;
|
|
671
|
+
function Xt(t) {
|
|
672
|
+
if (!H()) return !1;
|
|
673
|
+
E.debug("检测到离线包环境,开始初始化");
|
|
674
|
+
const e = () => {
|
|
675
|
+
t();
|
|
676
|
+
};
|
|
677
|
+
if (pe.test(document.readyState))
|
|
678
|
+
E.debug("离线包环境 DOM 已就绪,立即初始化"), setTimeout(e, 0);
|
|
679
|
+
else {
|
|
680
|
+
E.debug("离线包环境,等待 DOMContentLoaded");
|
|
681
|
+
let r = !1;
|
|
682
|
+
const n = () => {
|
|
683
|
+
r || (r = !0, e());
|
|
684
|
+
};
|
|
685
|
+
document.addEventListener("DOMContentLoaded", n), setTimeout(n, 500);
|
|
686
|
+
}
|
|
687
|
+
return !0;
|
|
661
688
|
}
|
|
662
|
-
function
|
|
663
|
-
return window.
|
|
689
|
+
function Zt(t) {
|
|
690
|
+
return Oe() || Le() ? (E.debug("检测到 APP 环境,开始初始化"), window.__uniapp_x_postMessage || window.__uniapp_x_ || window.__dcloud_weex_postMessage || window.__dcloud_weex_ ? (E.debug("NVUE/UVUE 环境,等待 DOMContentLoaded"), document.addEventListener("DOMContentLoaded", t)) : window.plus && pe.test(document.readyState) ? (E.debug("Plus 环境已就绪,立即初始化"), setTimeout(t, 0)) : window.plus ? (E.debug("Plus 环境,等待 plusready 事件"), document.addEventListener("plusready", t)) : pe.test(document.readyState) ? setTimeout(t, 0) : document.addEventListener("DOMContentLoaded", t, { once: !0 }), !0) : !1;
|
|
664
691
|
}
|
|
665
|
-
function
|
|
666
|
-
return
|
|
692
|
+
function Qt(t) {
|
|
693
|
+
return window.wx && window.wx.miniProgram ? (E.debug("检测到微信小程序环境,开始初始化"), window.WeixinJSBridge && window.WeixinJSBridge.invoke ? (E.debug("微信 JSBridge 已就绪,立即初始化"), setTimeout(t, 0)) : (E.debug("微信 JSBridge 未就绪,等待 WeixinJSBridgeReady 事件"), document.addEventListener("WeixinJSBridgeReady", t)), !0) : !1;
|
|
667
694
|
}
|
|
668
|
-
function
|
|
669
|
-
return
|
|
695
|
+
function er(t) {
|
|
696
|
+
return E.info("开始初始化 JSBridge"), Xt(t) ? (E.info("使用离线包环境初始化"), !0) : Zt(t) ? (E.info("使用 APP 环境初始化"), !0) : Qt(t) ? (E.info("使用微信小程序环境初始化"), !0) : (E.debug("使用默认 H5 环境初始化"), pe.test(document.readyState) ? (E.debug("DOM 已就绪,立即初始化"), setTimeout(t, 0)) : (E.debug("DOM 未就绪,等待 DOMContentLoaded"), document.addEventListener("DOMContentLoaded", t)), !0);
|
|
670
697
|
}
|
|
671
|
-
function
|
|
672
|
-
return
|
|
698
|
+
function tr() {
|
|
699
|
+
return q.waitForReady();
|
|
700
|
+
}
|
|
701
|
+
function Ye() {
|
|
702
|
+
return q.startInitialization(() => m(null, null, function* () {
|
|
673
703
|
return new Promise((t, e) => {
|
|
674
704
|
const r = () => {
|
|
675
705
|
t();
|
|
676
706
|
}, n = (i) => {
|
|
677
|
-
const a =
|
|
707
|
+
const a = u.handleApiError(i, {
|
|
678
708
|
context: "bridge initialization"
|
|
679
709
|
});
|
|
680
710
|
e(a);
|
|
681
711
|
};
|
|
682
712
|
try {
|
|
683
|
-
|
|
713
|
+
er(() => {
|
|
684
714
|
r();
|
|
685
715
|
});
|
|
686
716
|
} catch (i) {
|
|
@@ -698,12 +728,12 @@ const P = {
|
|
|
698
728
|
function $() {
|
|
699
729
|
return typeof window == "undefined" || !window.wx ? !1 : typeof window.wx.config == "function" && typeof window.wx.ready == "function" && typeof window.wx.error == "function";
|
|
700
730
|
}
|
|
701
|
-
class
|
|
731
|
+
class rr {
|
|
702
732
|
constructor() {
|
|
703
733
|
this.state = P.UNINITIALIZED, this.configPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.lastError = null, this.runtimeConfig = {
|
|
704
734
|
clientId: null,
|
|
705
735
|
isProd: !1
|
|
706
|
-
}, this.CONFIG_API_URL = this.getConfigApiUrl(this.runtimeConfig.isProd), this.DEFAULT_JS_API_LIST = ["chooseImage", "uploadImage", "previewImage", "downloadImage", "getLocalImgData", "scanQRCode", "getLocation", "openLocation", "updateAppMessageShareData", "updateTimelineShareData"], this.handleConfigSuccess = this.handleConfigSuccess.bind(this), this.handleConfigError = this.handleConfigError.bind(this);
|
|
736
|
+
}, this.CONFIG_API_URL = this.getConfigApiUrl(this.runtimeConfig.isProd), this.DEFAULT_JS_API_LIST = ["chooseImage", "uploadImage", "previewImage", "downloadImage", "getLocalImgData", "scanQRCode", "getLocation", "openLocation", "updateAppMessageShareData", "updateTimelineShareData"], this.DEFAULT_OPEN_TAG_LIST = ["wx-open-launch-weapp", "wx-open-launch-app"], this.handleConfigSuccess = this.handleConfigSuccess.bind(this), this.handleConfigError = this.handleConfigError.bind(this);
|
|
707
737
|
}
|
|
708
738
|
configure(e = {}) {
|
|
709
739
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
@@ -727,17 +757,17 @@ class Zt {
|
|
|
727
757
|
{ isProd: e.isProd }
|
|
728
758
|
);
|
|
729
759
|
const r = e.clientId.trim(), n = e.isProd === !0, i = r !== this.runtimeConfig.clientId || n !== this.runtimeConfig.isProd;
|
|
730
|
-
return this.runtimeConfig =
|
|
760
|
+
return this.runtimeConfig = p(d({}, this.runtimeConfig), {
|
|
731
761
|
clientId: r,
|
|
732
762
|
isProd: n
|
|
733
|
-
}), this.CONFIG_API_URL = this.getConfigApiUrl(n), (this.state === P.ERROR || i && (this.state === P.CONFIGURING || this.state === P.CONFIGURED)) && this.reset(),
|
|
763
|
+
}), this.CONFIG_API_URL = this.getConfigApiUrl(n), (this.state === P.ERROR || i && (this.state === P.CONFIGURING || this.state === P.CONFIGURED)) && this.reset(), w.info("Updated Weixin runtime config", {
|
|
734
764
|
clientId: this.runtimeConfig.clientId,
|
|
735
765
|
isProd: this.runtimeConfig.isProd,
|
|
736
766
|
configApiUrl: this.CONFIG_API_URL
|
|
737
767
|
}), this.getRuntimeConfig();
|
|
738
768
|
}
|
|
739
769
|
getRuntimeConfig() {
|
|
740
|
-
return
|
|
770
|
+
return d({}, this.runtimeConfig);
|
|
741
771
|
}
|
|
742
772
|
hasClientId() {
|
|
743
773
|
return typeof this.runtimeConfig.clientId == "string" && this.runtimeConfig.clientId.length > 0;
|
|
@@ -777,30 +807,30 @@ class Zt {
|
|
|
777
807
|
* @private
|
|
778
808
|
*/
|
|
779
809
|
fetchWeixinConfig() {
|
|
780
|
-
return
|
|
810
|
+
return m(this, null, function* () {
|
|
781
811
|
const e = this.getCurrentPageUrl();
|
|
782
812
|
if (this.isTestMode())
|
|
783
|
-
return
|
|
813
|
+
return w.info("使用测试模式,返回模拟配置"), this.getMockConfig();
|
|
784
814
|
if (!this.hasClientId())
|
|
785
815
|
throw this.createMissingClientIdError();
|
|
786
816
|
const r = this.getConfigApiUrl(this.runtimeConfig.isProd);
|
|
787
817
|
this.CONFIG_API_URL = r;
|
|
788
818
|
const n = `${r}?clientId=${this.runtimeConfig.clientId}&url=${encodeURIComponent(e)}`;
|
|
789
|
-
|
|
819
|
+
w.debug("请求微信配置", { url: n });
|
|
790
820
|
try {
|
|
791
821
|
const i = yield fetch(n);
|
|
792
822
|
if (!i.ok)
|
|
793
823
|
throw new Error(`HTTP ${i.status}: ${i.statusText}`);
|
|
794
824
|
const a = yield i.json();
|
|
795
|
-
if (
|
|
825
|
+
if (w.debug("微信配置响应", a), !a.success || a.code !== 200)
|
|
796
826
|
throw new Error(`配置获取失败: ${a.message || "未知错误"}`);
|
|
797
827
|
const { data: o } = a;
|
|
798
828
|
if (!o || !o.appId || !o.timestamp || !o.nonceStr || !o.signature)
|
|
799
829
|
throw new Error("配置数据格式不正确,缺少必需字段");
|
|
800
830
|
return o;
|
|
801
831
|
} catch (i) {
|
|
802
|
-
if (
|
|
803
|
-
return
|
|
832
|
+
if (w.error("获取微信配置失败", i), this.shouldUseTestMode(i))
|
|
833
|
+
return w.warn("网络请求失败,降级到测试模式"), this.getMockConfig();
|
|
804
834
|
throw new R(
|
|
805
835
|
L.NETWORK_ERROR,
|
|
806
836
|
`获取微信配置失败: ${i.message}`,
|
|
@@ -854,7 +884,7 @@ class Zt {
|
|
|
854
884
|
*/
|
|
855
885
|
executeWeixinConfig(e) {
|
|
856
886
|
if (this.isTestMode() || e.appId === "wx_test_app_id") {
|
|
857
|
-
|
|
887
|
+
w.info("测试模式:模拟微信配置成功"), setTimeout(() => {
|
|
858
888
|
this.handleConfigSuccess();
|
|
859
889
|
}, 100);
|
|
860
890
|
return;
|
|
@@ -868,22 +898,23 @@ class Zt {
|
|
|
868
898
|
timestamp: parseInt(e.timestamp),
|
|
869
899
|
nonceStr: e.nonceStr,
|
|
870
900
|
signature: e.signature,
|
|
871
|
-
jsApiList: this.DEFAULT_JS_API_LIST
|
|
901
|
+
jsApiList: this.DEFAULT_JS_API_LIST,
|
|
902
|
+
openTagList: this.DEFAULT_OPEN_TAG_LIST
|
|
872
903
|
};
|
|
873
|
-
|
|
904
|
+
w.info("执行微信配置", r), window.wx.ready(this.handleConfigSuccess), window.wx.error(this.handleConfigError), window.wx.config(r);
|
|
874
905
|
}
|
|
875
906
|
/**
|
|
876
907
|
* 处理配置成功
|
|
877
908
|
* @private
|
|
878
909
|
*/
|
|
879
910
|
handleConfigSuccess() {
|
|
880
|
-
|
|
911
|
+
w.info("微信配置成功"), this.state = P.CONFIGURED, this.lastError = null, this.configPromise = null;
|
|
881
912
|
const e = [...this.readyCallbacks];
|
|
882
913
|
this.readyCallbacks = [], this.errorCallbacks = [], e.forEach((r) => {
|
|
883
914
|
try {
|
|
884
915
|
r();
|
|
885
916
|
} catch (n) {
|
|
886
|
-
|
|
917
|
+
u.handleApiError(n, { context: "WeixinConfigManager.handleConfigSuccess" });
|
|
887
918
|
}
|
|
888
919
|
});
|
|
889
920
|
}
|
|
@@ -894,7 +925,7 @@ class Zt {
|
|
|
894
925
|
*/
|
|
895
926
|
handleConfigError(e) {
|
|
896
927
|
const r = `微信配置验证失败: ${JSON.stringify(e)}`;
|
|
897
|
-
|
|
928
|
+
w.error(r, e);
|
|
898
929
|
const n = new R(
|
|
899
930
|
L.API_CALL_FAILED,
|
|
900
931
|
r,
|
|
@@ -906,7 +937,7 @@ class Zt {
|
|
|
906
937
|
try {
|
|
907
938
|
a(n);
|
|
908
939
|
} catch (o) {
|
|
909
|
-
|
|
940
|
+
u.handleApiError(o, { context: "WeixinConfigManager.handleConfigError" });
|
|
910
941
|
}
|
|
911
942
|
});
|
|
912
943
|
}
|
|
@@ -915,8 +946,8 @@ class Zt {
|
|
|
915
946
|
* @returns {Promise<void>} 配置完成的Promise
|
|
916
947
|
*/
|
|
917
948
|
autoConfig() {
|
|
918
|
-
return
|
|
919
|
-
return this.hasRequiredConfig() ? this.state === P.CONFIGURED ? Promise.resolve() : this.state === P.ERROR ? Promise.reject(this.lastError) : this.configPromise ? this.configPromise : (this.state = P.CONFIGURING, this.configPromise = this.performAutoConfig(), this.configPromise) : (
|
|
949
|
+
return m(this, null, function* () {
|
|
950
|
+
return this.hasRequiredConfig() ? this.state === P.CONFIGURED ? Promise.resolve() : this.state === P.ERROR ? Promise.reject(this.lastError) : this.configPromise ? this.configPromise : (this.state = P.CONFIGURING, this.configPromise = this.performAutoConfig(), this.configPromise) : (w.warn("clientId为空,等待qsh.config({ clientId })"), Promise.resolve());
|
|
920
951
|
});
|
|
921
952
|
}
|
|
922
953
|
/**
|
|
@@ -925,7 +956,7 @@ class Zt {
|
|
|
925
956
|
* @private
|
|
926
957
|
*/
|
|
927
958
|
performAutoConfig() {
|
|
928
|
-
return
|
|
959
|
+
return m(this, null, function* () {
|
|
929
960
|
try {
|
|
930
961
|
if (typeof window == "undefined")
|
|
931
962
|
throw new Error("非浏览器环境无法执行微信配置");
|
|
@@ -944,14 +975,14 @@ class Zt {
|
|
|
944
975
|
this.readyCallbacks.push(r), this.errorCallbacks.push(n);
|
|
945
976
|
});
|
|
946
977
|
} catch (e) {
|
|
947
|
-
const r = e instanceof R ? e :
|
|
978
|
+
const r = e instanceof R ? e : u.handleApiError(e, { context: "WeixinConfigManager.performAutoConfig" });
|
|
948
979
|
this.state = P.ERROR, this.lastError = r, this.configPromise = null;
|
|
949
980
|
const n = [...this.errorCallbacks];
|
|
950
981
|
throw this.readyCallbacks = [], this.errorCallbacks = [], n.forEach((i) => {
|
|
951
982
|
try {
|
|
952
983
|
i(r);
|
|
953
984
|
} catch (a) {
|
|
954
|
-
|
|
985
|
+
u.handleApiError(a, { context: "WeixinConfigManager.performAutoConfig.errorCallback" });
|
|
955
986
|
}
|
|
956
987
|
}), r;
|
|
957
988
|
}
|
|
@@ -991,7 +1022,7 @@ class Zt {
|
|
|
991
1022
|
* 重置配置管理器(用于重试或测试)
|
|
992
1023
|
*/
|
|
993
1024
|
reset() {
|
|
994
|
-
this.state = P.UNINITIALIZED, this.configPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.lastError = null,
|
|
1025
|
+
this.state = P.UNINITIALIZED, this.configPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.lastError = null, w.debug("微信配置管理器已重置");
|
|
995
1026
|
}
|
|
996
1027
|
/**
|
|
997
1028
|
* 获取配置统计信息
|
|
@@ -1007,27 +1038,28 @@ class Zt {
|
|
|
1007
1038
|
configApiUrl: this.CONFIG_API_URL,
|
|
1008
1039
|
clientId: this.runtimeConfig.clientId,
|
|
1009
1040
|
isProd: this.runtimeConfig.isProd,
|
|
1010
|
-
jsApiList: this.DEFAULT_JS_API_LIST
|
|
1041
|
+
jsApiList: this.DEFAULT_JS_API_LIST,
|
|
1042
|
+
openTagList: this.DEFAULT_OPEN_TAG_LIST
|
|
1011
1043
|
};
|
|
1012
1044
|
}
|
|
1013
1045
|
}
|
|
1014
|
-
const S = new
|
|
1015
|
-
let
|
|
1016
|
-
function
|
|
1046
|
+
const S = new rr();
|
|
1047
|
+
let Z = !1, oe = !1, v = null, me = !1;
|
|
1048
|
+
function nr(t) {
|
|
1017
1049
|
return new Promise((e) => {
|
|
1018
1050
|
let r = !1, n = null;
|
|
1019
|
-
const i = (f) =>
|
|
1051
|
+
const i = (f) => m(null, null, function* () {
|
|
1020
1052
|
if (!r) {
|
|
1021
|
-
if (r = !0, n && clearTimeout(n),
|
|
1053
|
+
if (r = !0, n && clearTimeout(n), Z = !1, oe = f, f)
|
|
1022
1054
|
try {
|
|
1023
|
-
yield
|
|
1055
|
+
yield Xe();
|
|
1024
1056
|
} catch (h) {
|
|
1025
|
-
|
|
1057
|
+
w.error("微信配置失败,将使用消息桥作为后备", h);
|
|
1026
1058
|
}
|
|
1027
1059
|
e();
|
|
1028
1060
|
}
|
|
1029
1061
|
}), a = () => i($()), o = () => {
|
|
1030
|
-
|
|
1062
|
+
w.warn("已存在的微信 JS-SDK 脚本加载失败,SDK 将使用消息桥作为后备"), i(!1);
|
|
1031
1063
|
};
|
|
1032
1064
|
t.addEventListener("load", a, { once: !0 }), t.addEventListener("error", o, { once: !0 }), setTimeout(() => {
|
|
1033
1065
|
$() && a();
|
|
@@ -1036,104 +1068,104 @@ function Qt(t) {
|
|
|
1036
1068
|
}, 3e3);
|
|
1037
1069
|
});
|
|
1038
1070
|
}
|
|
1039
|
-
function
|
|
1040
|
-
return
|
|
1071
|
+
function be() {
|
|
1072
|
+
return m(this, arguments, function* (t = {}) {
|
|
1041
1073
|
const { force: e = !1, recoverFromError: r = !1 } = t;
|
|
1042
|
-
if (yield
|
|
1074
|
+
if (yield Ze({ force: e }), !$())
|
|
1043
1075
|
throw new Error("微信 JS-SDK 未正确加载,无法执行配置");
|
|
1044
|
-
r &&
|
|
1076
|
+
r && sr();
|
|
1045
1077
|
});
|
|
1046
1078
|
}
|
|
1047
|
-
function
|
|
1079
|
+
function ir(t = !1) {
|
|
1048
1080
|
if (typeof window == "undefined") return !1;
|
|
1049
1081
|
if ($())
|
|
1050
|
-
return
|
|
1051
|
-
if (
|
|
1082
|
+
return oe = !0, !1;
|
|
1083
|
+
if (oe || H()) return !1;
|
|
1052
1084
|
if (t) return !0;
|
|
1053
1085
|
const e = navigator.userAgent || "", r = /micromessenger/i.test(e), n = /miniProgram/i.test(e), i = typeof window.__wxjs_environment != "undefined" && window.__wxjs_environment === "miniprogram", a = !!(window.wx && window.wx.miniProgram);
|
|
1054
1086
|
return r && (n || i || a);
|
|
1055
1087
|
}
|
|
1056
|
-
function
|
|
1057
|
-
S.getState() === "error" && (S.reset(),
|
|
1088
|
+
function sr() {
|
|
1089
|
+
S.getState() === "error" && (S.reset(), me = !1);
|
|
1058
1090
|
}
|
|
1059
|
-
function
|
|
1060
|
-
return
|
|
1061
|
-
if (
|
|
1091
|
+
function Xe() {
|
|
1092
|
+
return m(this, null, function* () {
|
|
1093
|
+
if (me)
|
|
1062
1094
|
return S.waitForReady();
|
|
1063
|
-
|
|
1095
|
+
me = !0, w.info("开始自动配置微信JS-SDK");
|
|
1064
1096
|
try {
|
|
1065
|
-
yield S.autoConfig(),
|
|
1097
|
+
yield S.autoConfig(), w.info("微信JS-SDK自动配置完成");
|
|
1066
1098
|
} catch (t) {
|
|
1067
|
-
|
|
1099
|
+
w.error("微信JS-SDK自动配置失败", t);
|
|
1068
1100
|
}
|
|
1069
1101
|
});
|
|
1070
1102
|
}
|
|
1071
|
-
function
|
|
1103
|
+
function Ze(t = {}) {
|
|
1072
1104
|
const { force: e = !1 } = t;
|
|
1073
1105
|
if (typeof window == "undefined")
|
|
1074
1106
|
return Promise.resolve();
|
|
1075
1107
|
if ($())
|
|
1076
|
-
return
|
|
1108
|
+
return oe = !0, Promise.resolve();
|
|
1077
1109
|
const r = document.getElementById("weixin-jssdk");
|
|
1078
|
-
return r ? v || (
|
|
1110
|
+
return r ? v || (Z = !0, v = nr(r).finally(() => {
|
|
1079
1111
|
v = null;
|
|
1080
|
-
}), v) :
|
|
1081
|
-
|
|
1112
|
+
}), v) : ir(e) ? v || (v = new Promise((n) => {
|
|
1113
|
+
Z = !0;
|
|
1082
1114
|
try {
|
|
1083
1115
|
const i = document.createElement("script");
|
|
1084
1116
|
i.id = "weixin-jssdk", i.type = "text/javascript", i.async = !0, i.src = "https://res.wx.qq.com/open/js/jweixin-1.6.2.js", i.onload = function() {
|
|
1085
|
-
return
|
|
1086
|
-
|
|
1117
|
+
return m(this, null, function* () {
|
|
1118
|
+
oe = !0, Z = !1, w.info("微信 JS-SDK 已自动加载");
|
|
1087
1119
|
try {
|
|
1088
|
-
yield
|
|
1120
|
+
yield Xe();
|
|
1089
1121
|
} catch (o) {
|
|
1090
|
-
|
|
1122
|
+
w.error("微信配置失败,将使用消息桥作为后备", o);
|
|
1091
1123
|
}
|
|
1092
1124
|
n();
|
|
1093
1125
|
});
|
|
1094
1126
|
}, i.onerror = function() {
|
|
1095
|
-
|
|
1127
|
+
Z = !1, w.warn("微信 JS-SDK 加载失败,SDK 将使用消息桥作为后备"), n();
|
|
1096
1128
|
}, (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(i);
|
|
1097
1129
|
} catch (i) {
|
|
1098
|
-
|
|
1130
|
+
Z = !1, w.error("注入微信 JS-SDK 失败", i), n();
|
|
1099
1131
|
}
|
|
1100
1132
|
}).finally(() => {
|
|
1101
1133
|
v = null;
|
|
1102
1134
|
}), v) : Promise.resolve();
|
|
1103
1135
|
}
|
|
1104
1136
|
function B() {
|
|
1105
|
-
return
|
|
1137
|
+
return be({ force: !0, recoverFromError: !0 }).then(() => S.waitForReady());
|
|
1106
1138
|
}
|
|
1107
|
-
function
|
|
1139
|
+
function ze(t = {}) {
|
|
1108
1140
|
const e = S.configure(t);
|
|
1109
|
-
return typeof window == "undefined" ||
|
|
1141
|
+
return typeof window == "undefined" || be({
|
|
1110
1142
|
force: !0,
|
|
1111
1143
|
recoverFromError: S.getState() === "error"
|
|
1112
1144
|
}).then(() => {
|
|
1113
1145
|
if (!S.isReady())
|
|
1114
1146
|
return S.waitForReady().catch((r) => {
|
|
1115
|
-
|
|
1147
|
+
w.error("Failed to auto-configure Weixin after qsh.config()", r);
|
|
1116
1148
|
});
|
|
1117
|
-
window.wx && !$() &&
|
|
1149
|
+
window.wx && !$() && w.warn("window.wx 已存在,但微信 JS-SDK 尚未就绪,跳过自动配置");
|
|
1118
1150
|
}).catch((r) => {
|
|
1119
|
-
|
|
1151
|
+
w.error("Failed to preload Weixin JS-SDK", r);
|
|
1120
1152
|
}), e;
|
|
1121
1153
|
}
|
|
1122
1154
|
function G() {
|
|
1123
1155
|
return S.isReady();
|
|
1124
1156
|
}
|
|
1125
|
-
function
|
|
1157
|
+
function ar() {
|
|
1126
1158
|
return S.getState();
|
|
1127
1159
|
}
|
|
1128
|
-
function
|
|
1160
|
+
function Re() {
|
|
1129
1161
|
return S;
|
|
1130
1162
|
}
|
|
1131
|
-
function
|
|
1132
|
-
return
|
|
1133
|
-
return
|
|
1163
|
+
function or() {
|
|
1164
|
+
return m(this, null, function* () {
|
|
1165
|
+
return w.info("手动重试微信配置"), S.reset(), me = !1, yield be({ force: !0 }), S.waitForReady();
|
|
1134
1166
|
});
|
|
1135
1167
|
}
|
|
1136
|
-
class
|
|
1168
|
+
class cr {
|
|
1137
1169
|
constructor() {
|
|
1138
1170
|
this.plugins = /* @__PURE__ */ new Map(), this.installed = /* @__PURE__ */ new Set(), this.installOrder = [], s.debug("插件管理器已初始化");
|
|
1139
1171
|
}
|
|
@@ -1145,7 +1177,7 @@ class ir {
|
|
|
1145
1177
|
* pluginManager.register(imagePlugin)
|
|
1146
1178
|
*/
|
|
1147
1179
|
register(e) {
|
|
1148
|
-
return
|
|
1180
|
+
return u.safeExecute(() => {
|
|
1149
1181
|
this.validatePlugin(e);
|
|
1150
1182
|
const { name: r, version: n } = e;
|
|
1151
1183
|
if (this.plugins.has(r)) {
|
|
@@ -1185,8 +1217,8 @@ class ir {
|
|
|
1185
1217
|
* await pluginManager.install('image', qsh)
|
|
1186
1218
|
*/
|
|
1187
1219
|
install(e, r) {
|
|
1188
|
-
return
|
|
1189
|
-
return
|
|
1220
|
+
return m(this, null, function* () {
|
|
1221
|
+
return u.safeExecute(() => m(this, null, function* () {
|
|
1190
1222
|
if (!this.plugins.has(e))
|
|
1191
1223
|
throw new Error(`插件 ${e} 未注册`);
|
|
1192
1224
|
if (this.installed.has(e)) {
|
|
@@ -1215,8 +1247,8 @@ class ir {
|
|
|
1215
1247
|
* await pluginManager.uninstall('image', qsh)
|
|
1216
1248
|
*/
|
|
1217
1249
|
uninstall(e, r) {
|
|
1218
|
-
return
|
|
1219
|
-
return
|
|
1250
|
+
return m(this, null, function* () {
|
|
1251
|
+
return u.safeExecute(() => m(this, null, function* () {
|
|
1220
1252
|
if (!this.installed.has(e)) {
|
|
1221
1253
|
s.debug(`插件 ${e} 未安装,跳过卸载`);
|
|
1222
1254
|
return;
|
|
@@ -1237,7 +1269,7 @@ class ir {
|
|
|
1237
1269
|
* @returns {Promise<void>}
|
|
1238
1270
|
*/
|
|
1239
1271
|
uninstallAll(e) {
|
|
1240
|
-
return
|
|
1272
|
+
return m(this, null, function* () {
|
|
1241
1273
|
const r = [...this.installOrder].reverse();
|
|
1242
1274
|
for (const n of r)
|
|
1243
1275
|
yield this.uninstall(n, e);
|
|
@@ -1264,7 +1296,7 @@ class ir {
|
|
|
1264
1296
|
* await pluginManager.installAll(['image', 'location'], qsh)
|
|
1265
1297
|
*/
|
|
1266
1298
|
installAll(e, r) {
|
|
1267
|
-
return
|
|
1299
|
+
return m(this, null, function* () {
|
|
1268
1300
|
if (!Array.isArray(e))
|
|
1269
1301
|
throw new Error("names 必须是数组");
|
|
1270
1302
|
for (const n of e)
|
|
@@ -1326,8 +1358,8 @@ class ir {
|
|
|
1326
1358
|
this.plugins.clear(), this.installed.clear(), this.installOrder = [];
|
|
1327
1359
|
}
|
|
1328
1360
|
}
|
|
1329
|
-
const
|
|
1330
|
-
class
|
|
1361
|
+
const se = new cr();
|
|
1362
|
+
class ur {
|
|
1331
1363
|
constructor() {
|
|
1332
1364
|
this.requestInterceptors = [], this.responseInterceptors = [], s.debug("拦截器链已初始化");
|
|
1333
1365
|
}
|
|
@@ -1386,8 +1418,8 @@ class sr {
|
|
|
1386
1418
|
* @private
|
|
1387
1419
|
*/
|
|
1388
1420
|
runRequest(e) {
|
|
1389
|
-
return
|
|
1390
|
-
let r =
|
|
1421
|
+
return m(this, null, function* () {
|
|
1422
|
+
let r = d({}, e);
|
|
1391
1423
|
for (const { fn: n } of this.requestInterceptors) {
|
|
1392
1424
|
if (r.abort) {
|
|
1393
1425
|
s.debug("请求被中止", { apiName: r.apiName });
|
|
@@ -1412,7 +1444,7 @@ class sr {
|
|
|
1412
1444
|
* @private
|
|
1413
1445
|
*/
|
|
1414
1446
|
runResponse(e, r) {
|
|
1415
|
-
return
|
|
1447
|
+
return m(this, null, function* () {
|
|
1416
1448
|
let n = e;
|
|
1417
1449
|
for (const { fn: i } of this.responseInterceptors)
|
|
1418
1450
|
try {
|
|
@@ -1441,7 +1473,7 @@ class sr {
|
|
|
1441
1473
|
};
|
|
1442
1474
|
}
|
|
1443
1475
|
}
|
|
1444
|
-
const
|
|
1476
|
+
const j = new ur(), lr = {
|
|
1445
1477
|
/**
|
|
1446
1478
|
* 请求日志
|
|
1447
1479
|
*/
|
|
@@ -1486,7 +1518,7 @@ const V = new sr(), ar = {
|
|
|
1486
1518
|
getReport: () => {
|
|
1487
1519
|
const t = {};
|
|
1488
1520
|
return k.metrics.forEach((e, r) => {
|
|
1489
|
-
t[r] =
|
|
1521
|
+
t[r] = d({}, e);
|
|
1490
1522
|
}), t;
|
|
1491
1523
|
},
|
|
1492
1524
|
/**
|
|
@@ -1496,19 +1528,19 @@ const V = new sr(), ar = {
|
|
|
1496
1528
|
k.metrics.clear();
|
|
1497
1529
|
}
|
|
1498
1530
|
};
|
|
1499
|
-
function
|
|
1531
|
+
function fr(t = {}) {
|
|
1500
1532
|
const {
|
|
1501
1533
|
maxRetries: e = 3,
|
|
1502
1534
|
retryDelay: r = 1e3,
|
|
1503
1535
|
shouldRetry: n = (i) => !i.success
|
|
1504
1536
|
} = t;
|
|
1505
1537
|
return {
|
|
1506
|
-
response: (i, a) =>
|
|
1538
|
+
response: (i, a) => m(null, null, function* () {
|
|
1507
1539
|
return a.retryCount || (a.retryCount = 0), n(i) && a.retryCount < e && (a.retryCount++, s.warn(`API 调用失败,第 ${a.retryCount} 次重试: ${a.apiName}`), yield new Promise((o) => setTimeout(o, r)), i.shouldRetry = !0, i.retryContext = a), i;
|
|
1508
1540
|
})
|
|
1509
1541
|
};
|
|
1510
1542
|
}
|
|
1511
|
-
function
|
|
1543
|
+
function dr(t = {}) {
|
|
1512
1544
|
return {
|
|
1513
1545
|
request: (e) => {
|
|
1514
1546
|
const r = t[e.apiName];
|
|
@@ -1520,7 +1552,7 @@ function cr(t = {}) {
|
|
|
1520
1552
|
}
|
|
1521
1553
|
};
|
|
1522
1554
|
}
|
|
1523
|
-
class
|
|
1555
|
+
class gr {
|
|
1524
1556
|
constructor() {
|
|
1525
1557
|
this.state = {
|
|
1526
1558
|
// SDK 状态
|
|
@@ -1532,11 +1564,12 @@ class ur {
|
|
|
1532
1564
|
},
|
|
1533
1565
|
// 平台信息
|
|
1534
1566
|
platform: {
|
|
1535
|
-
type:
|
|
1536
|
-
isWeixinMiniProgram:
|
|
1537
|
-
isAppPlus:
|
|
1538
|
-
isNvue:
|
|
1539
|
-
isUvue:
|
|
1567
|
+
type: l.type,
|
|
1568
|
+
isWeixinMiniProgram: l.isWeixinMiniProgram,
|
|
1569
|
+
isAppPlus: l.isAppPlus,
|
|
1570
|
+
isNvue: l.isNvue,
|
|
1571
|
+
isUvue: l.isUvue,
|
|
1572
|
+
isOfflineWebview: l.isOfflineWebview,
|
|
1540
1573
|
features: {}
|
|
1541
1574
|
// 平台支持的特性
|
|
1542
1575
|
},
|
|
@@ -1697,7 +1730,7 @@ class ur {
|
|
|
1697
1730
|
*/
|
|
1698
1731
|
setApiLoading(e, r = !0) {
|
|
1699
1732
|
const n = `api.${e}`, i = this.get(n) || {};
|
|
1700
|
-
this.set(n,
|
|
1733
|
+
this.set(n, p(d({}, i), {
|
|
1701
1734
|
loading: r,
|
|
1702
1735
|
lastCall: r ? Date.now() : i.lastCall
|
|
1703
1736
|
}));
|
|
@@ -1709,7 +1742,7 @@ class ur {
|
|
|
1709
1742
|
*/
|
|
1710
1743
|
setApiResult(e, r) {
|
|
1711
1744
|
const n = `api.${e}`, i = this.get(n) || {};
|
|
1712
|
-
this.set(n,
|
|
1745
|
+
this.set(n, p(d({}, i), {
|
|
1713
1746
|
loading: !1,
|
|
1714
1747
|
lastResult: r,
|
|
1715
1748
|
lastCallEnd: Date.now()
|
|
@@ -1764,7 +1797,7 @@ class ur {
|
|
|
1764
1797
|
};
|
|
1765
1798
|
}
|
|
1766
1799
|
}
|
|
1767
|
-
const W = new
|
|
1800
|
+
const W = new gr(), c = {
|
|
1768
1801
|
// SDK 核心错误 (E_SDK_xxx)
|
|
1769
1802
|
SDK_NOT_READY: "E_SDK_001",
|
|
1770
1803
|
SDK_INIT_FAILED: "E_SDK_002",
|
|
@@ -1815,7 +1848,7 @@ const W = new ur(), c = {
|
|
|
1815
1848
|
API_TIMEOUT: "E_TIMEOUT_001",
|
|
1816
1849
|
// 通用错误
|
|
1817
1850
|
UNKNOWN_ERROR: "E_UNKNOWN_999"
|
|
1818
|
-
},
|
|
1851
|
+
}, Se = {
|
|
1819
1852
|
// SDK 核心
|
|
1820
1853
|
[c.SDK_NOT_READY]: "SDK 未就绪",
|
|
1821
1854
|
[c.SDK_INIT_FAILED]: "SDK 初始化失败",
|
|
@@ -1871,7 +1904,7 @@ const W = new ur(), c = {
|
|
|
1871
1904
|
// 配置问题
|
|
1872
1905
|
UNKNOWN: "unknown"
|
|
1873
1906
|
// 未知问题
|
|
1874
|
-
},
|
|
1907
|
+
}, hr = {
|
|
1875
1908
|
// 图片相关
|
|
1876
1909
|
"IMAGE/USER_CANCEL": c.IMAGE_CANCELLED,
|
|
1877
1910
|
"IMAGE/PERMISSION_DENIED": c.IMAGE_NO_PERMISSION,
|
|
@@ -1879,7 +1912,7 @@ const W = new ur(), c = {
|
|
|
1879
1912
|
"COMMON/UNKNOWN": c.UNKNOWN_ERROR,
|
|
1880
1913
|
"COMMON/CONFIG_NOT_READY": c.IMAGE_CONFIG_NOT_READY,
|
|
1881
1914
|
"COMMON/PLATFORM_NOT_SUPPORTED": c.PLATFORM_NOT_SUPPORTED
|
|
1882
|
-
},
|
|
1915
|
+
}, Ke = {
|
|
1883
1916
|
// 微信平台错误模式
|
|
1884
1917
|
weixin: {
|
|
1885
1918
|
patterns: [
|
|
@@ -1901,8 +1934,19 @@ const W = new ur(), c = {
|
|
|
1901
1934
|
{ pattern: /not_in_container/i, code: c.PLATFORM_NOT_SUPPORTED }
|
|
1902
1935
|
],
|
|
1903
1936
|
default: c.UNKNOWN_ERROR
|
|
1937
|
+
},
|
|
1938
|
+
// 离线包环境错误模式(与 uniapp 一致,走消息桥)
|
|
1939
|
+
offline: {
|
|
1940
|
+
patterns: [
|
|
1941
|
+
{ pattern: /cancel/i, code: c.IMAGE_CANCELLED },
|
|
1942
|
+
{ pattern: /permission|denied/i, code: c.IMAGE_NO_PERMISSION },
|
|
1943
|
+
{ pattern: /timeout/i, code: c.API_TIMEOUT },
|
|
1944
|
+
{ pattern: /network/i, code: c.NETWORK_ERROR },
|
|
1945
|
+
{ pattern: /not_in_container/i, code: c.PLATFORM_NOT_SUPPORTED }
|
|
1946
|
+
],
|
|
1947
|
+
default: c.UNKNOWN_ERROR
|
|
1904
1948
|
}
|
|
1905
|
-
},
|
|
1949
|
+
}, Ge = {
|
|
1906
1950
|
chooseImage: {
|
|
1907
1951
|
"fail cancel": c.IMAGE_CANCELLED,
|
|
1908
1952
|
"fail auth deny": c.IMAGE_NO_PERMISSION,
|
|
@@ -1916,17 +1960,17 @@ const W = new ur(), c = {
|
|
|
1916
1960
|
NOT_IN_CONTAINER: c.PLATFORM_NOT_SUPPORTED
|
|
1917
1961
|
}
|
|
1918
1962
|
};
|
|
1919
|
-
function
|
|
1963
|
+
function Qe(t) {
|
|
1920
1964
|
return t ? t.includes("CANCEL") ? D.USER_CANCEL : t.includes("PERM") || t.includes("PERMISSION") ? D.PERMISSION : t.includes("NET") || t.includes("NETWORK") ? D.NETWORK : t.includes("PARAM") ? D.PARAM : t.includes("CONFIG") ? D.CONFIG : t.includes("SDK") || t.includes("PLATFORM") ? D.SYSTEM : D.UNKNOWN : D.UNKNOWN;
|
|
1921
1965
|
}
|
|
1922
|
-
function
|
|
1966
|
+
function pr(t) {
|
|
1923
1967
|
return t.includes("NET_") || t.includes("TIMEOUT") || t === c.NETWORK_ERROR || t === c.NETWORK_TIMEOUT || t === c.API_TIMEOUT;
|
|
1924
1968
|
}
|
|
1925
|
-
function
|
|
1926
|
-
return t.includes("CANCEL") ||
|
|
1969
|
+
function mr(t) {
|
|
1970
|
+
return t.includes("CANCEL") || Qe(t) === D.USER_CANCEL;
|
|
1927
1971
|
}
|
|
1928
|
-
function
|
|
1929
|
-
return
|
|
1972
|
+
function Q(t) {
|
|
1973
|
+
return Se[t] || Se[c.UNKNOWN_ERROR];
|
|
1930
1974
|
}
|
|
1931
1975
|
class F extends Error {
|
|
1932
1976
|
/**
|
|
@@ -1936,7 +1980,7 @@ class F extends Error {
|
|
|
1936
1980
|
* @param {Object} options - 选项
|
|
1937
1981
|
*/
|
|
1938
1982
|
constructor(e, r, n = {}) {
|
|
1939
|
-
super(r), this.name = "StandardError", this.code = e, this.message = r ||
|
|
1983
|
+
super(r), this.name = "StandardError", this.code = e, this.message = r || Q(e), this.platform = n.platform || l.type, this.apiName = n.apiName, this.category = n.category || Qe(e), this.retriable = n.retriable !== void 0 ? n.retriable : pr(e), this.originalError = n.originalError, this.details = n.details || {}, this.timestamp = Date.now();
|
|
1940
1984
|
}
|
|
1941
1985
|
/**
|
|
1942
1986
|
* 是否可重试
|
|
@@ -1950,14 +1994,14 @@ class F extends Error {
|
|
|
1950
1994
|
* @returns {boolean}
|
|
1951
1995
|
*/
|
|
1952
1996
|
isUserAction() {
|
|
1953
|
-
return
|
|
1997
|
+
return mr(this.code);
|
|
1954
1998
|
}
|
|
1955
1999
|
/**
|
|
1956
2000
|
* 转为普通对象
|
|
1957
2001
|
* @returns {Object}
|
|
1958
2002
|
*/
|
|
1959
2003
|
toJSON() {
|
|
1960
|
-
return
|
|
2004
|
+
return d({
|
|
1961
2005
|
code: this.code,
|
|
1962
2006
|
message: this.message,
|
|
1963
2007
|
platform: this.platform,
|
|
@@ -1971,11 +2015,11 @@ class F extends Error {
|
|
|
1971
2015
|
} : {});
|
|
1972
2016
|
}
|
|
1973
2017
|
}
|
|
1974
|
-
function
|
|
2018
|
+
function et(t, e = {}) {
|
|
1975
2019
|
if (t instanceof F)
|
|
1976
2020
|
return t;
|
|
1977
|
-
const { apiName: r, platform: n =
|
|
1978
|
-
return t && typeof t.code == "string" && t.code.includes("/") ?
|
|
2021
|
+
const { apiName: r, platform: n = l.type } = e;
|
|
2022
|
+
return t && typeof t.code == "string" && t.code.includes("/") ? wr(t, { apiName: r, platform: n }) : t && (t.errMsg || t.message) ? Er(t, { apiName: r, platform: n }) : typeof t == "string" ? new F(
|
|
1979
2023
|
c.UNKNOWN_ERROR,
|
|
1980
2024
|
t,
|
|
1981
2025
|
{ apiName: r, platform: n, originalError: t }
|
|
@@ -1990,41 +2034,41 @@ function Ze(t, e = {}) {
|
|
|
1990
2034
|
}
|
|
1991
2035
|
);
|
|
1992
2036
|
}
|
|
1993
|
-
function
|
|
1994
|
-
const { apiName: r, platform: n } = e, i = t.code, a =
|
|
2037
|
+
function wr(t, e) {
|
|
2038
|
+
const { apiName: r, platform: n } = e, i = t.code, a = hr[i] || c.UNKNOWN_ERROR;
|
|
1995
2039
|
return s.debug("转换旧版错误码", {
|
|
1996
2040
|
legacy: i,
|
|
1997
2041
|
new: a
|
|
1998
2042
|
}), new F(
|
|
1999
2043
|
a,
|
|
2000
|
-
t.message ||
|
|
2044
|
+
t.message || Q(a),
|
|
2001
2045
|
{
|
|
2002
2046
|
apiName: r,
|
|
2003
2047
|
platform: t.platform || n,
|
|
2004
2048
|
originalError: t,
|
|
2005
|
-
details:
|
|
2049
|
+
details: d({
|
|
2006
2050
|
legacyCode: i,
|
|
2007
2051
|
legacyVersion: t.version
|
|
2008
2052
|
}, t.details)
|
|
2009
2053
|
}
|
|
2010
2054
|
);
|
|
2011
2055
|
}
|
|
2012
|
-
function
|
|
2056
|
+
function Er(t, e) {
|
|
2013
2057
|
const { apiName: r, platform: n } = e, i = (t.errMsg || t.message || "").toLowerCase();
|
|
2014
|
-
if (r &&
|
|
2015
|
-
const f =
|
|
2058
|
+
if (r && Ge[r]) {
|
|
2059
|
+
const f = Ge[r];
|
|
2016
2060
|
for (const [h, O] of Object.entries(f))
|
|
2017
2061
|
if (i.includes(h.toLowerCase()))
|
|
2018
|
-
return new F(O,
|
|
2062
|
+
return new F(O, Q(O), {
|
|
2019
2063
|
apiName: r,
|
|
2020
2064
|
platform: n,
|
|
2021
2065
|
originalError: t
|
|
2022
2066
|
});
|
|
2023
2067
|
}
|
|
2024
|
-
const a =
|
|
2068
|
+
const a = Ke[n] || Ke.uniapp;
|
|
2025
2069
|
for (const { pattern: f, code: h } of a.patterns)
|
|
2026
2070
|
if (f.test(i))
|
|
2027
|
-
return new F(h,
|
|
2071
|
+
return new F(h, Q(h), {
|
|
2028
2072
|
apiName: r,
|
|
2029
2073
|
platform: n,
|
|
2030
2074
|
originalError: t
|
|
@@ -2032,7 +2076,7 @@ function hr(t, e) {
|
|
|
2032
2076
|
const o = a.default || c.UNKNOWN_ERROR;
|
|
2033
2077
|
return new F(
|
|
2034
2078
|
o,
|
|
2035
|
-
t.errMsg || t.message ||
|
|
2079
|
+
t.errMsg || t.message || Q(o),
|
|
2036
2080
|
{
|
|
2037
2081
|
apiName: r,
|
|
2038
2082
|
platform: n,
|
|
@@ -2040,7 +2084,7 @@ function hr(t, e) {
|
|
|
2040
2084
|
}
|
|
2041
2085
|
);
|
|
2042
2086
|
}
|
|
2043
|
-
const
|
|
2087
|
+
const tt = {
|
|
2044
2088
|
/**
|
|
2045
2089
|
* 响应拦截器
|
|
2046
2090
|
* @param {Object} result - API 响应结果
|
|
@@ -2049,9 +2093,9 @@ const Qe = {
|
|
|
2049
2093
|
*/
|
|
2050
2094
|
response: (t, e) => {
|
|
2051
2095
|
if (!t.success && t.error) {
|
|
2052
|
-
const r =
|
|
2096
|
+
const r = et(t.error, {
|
|
2053
2097
|
apiName: e.apiName,
|
|
2054
|
-
platform:
|
|
2098
|
+
platform: l.type
|
|
2055
2099
|
});
|
|
2056
2100
|
t.error = r.toJSON(), t.errorCode = r.code, t.errorCategory = r.category, t.retriable = r.isRetriable(), s.debug("错误已标准化", {
|
|
2057
2101
|
api: e.apiName,
|
|
@@ -2062,25 +2106,25 @@ const Qe = {
|
|
|
2062
2106
|
return t;
|
|
2063
2107
|
}
|
|
2064
2108
|
};
|
|
2065
|
-
function
|
|
2066
|
-
return new F(t,
|
|
2109
|
+
function yr(t, e = {}) {
|
|
2110
|
+
return new F(t, Q(t), e);
|
|
2067
2111
|
}
|
|
2068
|
-
function
|
|
2112
|
+
function Ir(t) {
|
|
2069
2113
|
return t instanceof F;
|
|
2070
2114
|
}
|
|
2071
|
-
function
|
|
2115
|
+
function Ar(t, e, r) {
|
|
2072
2116
|
return e ? Promise.race([
|
|
2073
2117
|
t(),
|
|
2074
2118
|
new Promise((n, i) => setTimeout(() => i(new Error(`Init task timeout: ${r}`)), e))
|
|
2075
2119
|
]) : t();
|
|
2076
2120
|
}
|
|
2077
|
-
function
|
|
2078
|
-
return
|
|
2121
|
+
function Or() {
|
|
2122
|
+
return m(this, arguments, function* (t = [], e = {}) {
|
|
2079
2123
|
for (const r of t) {
|
|
2080
2124
|
const n = (r == null ? void 0 : r.name) || "anonymous-task", i = (r == null ? void 0 : r.run) || r;
|
|
2081
2125
|
if (typeof i == "function")
|
|
2082
2126
|
try {
|
|
2083
|
-
yield
|
|
2127
|
+
yield Ar(() => Promise.resolve().then(() => i()), r.timeoutMs, n), typeof r.onSuccess == "function" && r.onSuccess();
|
|
2084
2128
|
} catch (a) {
|
|
2085
2129
|
if (typeof r.onError == "function" && r.onError(a), typeof e.onError == "function")
|
|
2086
2130
|
e.onError(a, r);
|
|
@@ -2090,7 +2134,7 @@ function Er() {
|
|
|
2090
2134
|
}
|
|
2091
2135
|
});
|
|
2092
2136
|
}
|
|
2093
|
-
class
|
|
2137
|
+
class rt {
|
|
2094
2138
|
/**
|
|
2095
2139
|
* 构造函数
|
|
2096
2140
|
* @param {string} name - 平台名称
|
|
@@ -2105,7 +2149,7 @@ class et {
|
|
|
2105
2149
|
*/
|
|
2106
2150
|
processNavigationOptions(e = {}) {
|
|
2107
2151
|
const { url: r, delta: n = 1 } = e, i = r && encodeURI(r), a = parseInt(n) || 1;
|
|
2108
|
-
return
|
|
2152
|
+
return p(d({}, e), {
|
|
2109
2153
|
url: i,
|
|
2110
2154
|
delta: a
|
|
2111
2155
|
});
|
|
@@ -2216,18 +2260,18 @@ class et {
|
|
|
2216
2260
|
throw new Error(`${this.name} platform must implement performGetEnv method`);
|
|
2217
2261
|
}
|
|
2218
2262
|
}
|
|
2219
|
-
let
|
|
2220
|
-
function
|
|
2221
|
-
if (
|
|
2263
|
+
let ae = [];
|
|
2264
|
+
function Cr() {
|
|
2265
|
+
if (ae.length === 0 && window.plus) {
|
|
2222
2266
|
const t = plus.webview.currentWebview();
|
|
2223
2267
|
if (!t)
|
|
2224
2268
|
throw new Error("plus.webview.currentWebview() is undefined");
|
|
2225
2269
|
const e = t.parent(), r = e ? e.id : t.id;
|
|
2226
|
-
|
|
2270
|
+
ae.push(r);
|
|
2227
2271
|
}
|
|
2228
|
-
return
|
|
2272
|
+
return ae;
|
|
2229
2273
|
}
|
|
2230
|
-
function
|
|
2274
|
+
function _r(t, e) {
|
|
2231
2275
|
const r = {
|
|
2232
2276
|
options: {
|
|
2233
2277
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2243,12 +2287,12 @@ function Ir(t, e) {
|
|
|
2243
2287
|
type: "WEB_INVOKE_APPSERVICE",
|
|
2244
2288
|
args: {
|
|
2245
2289
|
data: r,
|
|
2246
|
-
webviewIds:
|
|
2290
|
+
webviewIds: ae
|
|
2247
2291
|
}
|
|
2248
2292
|
};
|
|
2249
2293
|
window.__uniapp_x_postMessage ? window.__uniapp_x_postMessageToService(n) : window.__uniapp_x_.postMessageToService(JSON.stringify(n));
|
|
2250
2294
|
}
|
|
2251
|
-
function
|
|
2295
|
+
function Pr(t, e) {
|
|
2252
2296
|
const r = {
|
|
2253
2297
|
options: {
|
|
2254
2298
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2264,19 +2308,19 @@ function Ar(t, e) {
|
|
|
2264
2308
|
type: "WEB_INVOKE_APPSERVICE",
|
|
2265
2309
|
args: {
|
|
2266
2310
|
data: r,
|
|
2267
|
-
webviewIds:
|
|
2311
|
+
webviewIds: ae
|
|
2268
2312
|
}
|
|
2269
2313
|
};
|
|
2270
2314
|
window.__dcloud_weex_postMessage ? window.__dcloud_weex_postMessageToService(n) : window.__dcloud_weex_.postMessageToService(JSON.stringify(n));
|
|
2271
2315
|
}
|
|
2272
|
-
function
|
|
2316
|
+
function Rr(t, e) {
|
|
2273
2317
|
const r = {
|
|
2274
2318
|
options: {
|
|
2275
2319
|
timestamp: +/* @__PURE__ */ new Date()
|
|
2276
2320
|
},
|
|
2277
2321
|
name: t,
|
|
2278
2322
|
arg: e
|
|
2279
|
-
}, n =
|
|
2323
|
+
}, n = Cr();
|
|
2280
2324
|
if (plus.webview.getWebviewById("__uniapp__service"))
|
|
2281
2325
|
plus.webview.postMessageToUniNView({
|
|
2282
2326
|
type: "WEB_INVOKE_APPSERVICE",
|
|
@@ -2292,7 +2336,7 @@ function Or(t, e) {
|
|
|
2292
2336
|
);
|
|
2293
2337
|
}
|
|
2294
2338
|
}
|
|
2295
|
-
function
|
|
2339
|
+
function Sr(t, e) {
|
|
2296
2340
|
const r = {
|
|
2297
2341
|
options: {
|
|
2298
2342
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2306,10 +2350,29 @@ function Cr(t, e) {
|
|
|
2306
2350
|
pageId: ""
|
|
2307
2351
|
}, "*");
|
|
2308
2352
|
}
|
|
2309
|
-
function
|
|
2310
|
-
|
|
2353
|
+
function Nr(t) {
|
|
2354
|
+
return !!(t && typeof t == "object" && t.type === "qsh_api_call" && typeof t.api == "string" && typeof t.callbackId == "string");
|
|
2311
2355
|
}
|
|
2312
|
-
|
|
2356
|
+
function Tr(t, e) {
|
|
2357
|
+
const r = {
|
|
2358
|
+
options: {
|
|
2359
|
+
timestamp: +/* @__PURE__ */ new Date()
|
|
2360
|
+
},
|
|
2361
|
+
name: t,
|
|
2362
|
+
arg: e
|
|
2363
|
+
};
|
|
2364
|
+
if (t === "postMessage" && Nr(e))
|
|
2365
|
+
return window.__offline_bridge_postMessage(e);
|
|
2366
|
+
window.__offline_bridge_postMessage({
|
|
2367
|
+
type: "WEB_INVOKE_APPSERVICE",
|
|
2368
|
+
data: r,
|
|
2369
|
+
pageId: ""
|
|
2370
|
+
});
|
|
2371
|
+
}
|
|
2372
|
+
function ce(t, e) {
|
|
2373
|
+
Ae() ? _r(t, e) : Ie() ? Pr(t, e) : H() ? Tr(t, e) : ye() ? Rr(t, e) : Sr(t, e);
|
|
2374
|
+
}
|
|
2375
|
+
class nt extends rt {
|
|
2313
2376
|
constructor() {
|
|
2314
2377
|
super("weixin");
|
|
2315
2378
|
}
|
|
@@ -2328,17 +2391,17 @@ class tt extends et {
|
|
|
2328
2391
|
* @returns {void}
|
|
2329
2392
|
*/
|
|
2330
2393
|
performNavigation(e, r) {
|
|
2331
|
-
return
|
|
2394
|
+
return u.safeExecute(() => {
|
|
2332
2395
|
const { url: n, delta: i } = r;
|
|
2333
|
-
if (
|
|
2396
|
+
if (w.debug(`微信平台执行导航操作: ${e}`, r), this.isWeixinApiAvailable()) {
|
|
2334
2397
|
const o = window.wx.miniProgram[e];
|
|
2335
2398
|
if (typeof o == "function") {
|
|
2336
|
-
|
|
2399
|
+
w.debug(`使用微信原生 API: wx.miniProgram.${e}`);
|
|
2337
2400
|
const f = e === "navigateBack" ? { delta: i } : { url: n };
|
|
2338
2401
|
return o.call(window.wx.miniProgram, f);
|
|
2339
2402
|
}
|
|
2340
2403
|
}
|
|
2341
|
-
|
|
2404
|
+
w.debug(`使用消息桥接执行: ${e}`), ce(e, e === "navigateBack" ? { delta: i } : { url: n });
|
|
2342
2405
|
}, {
|
|
2343
2406
|
platform: this.name,
|
|
2344
2407
|
method: "performNavigation",
|
|
@@ -2352,11 +2415,11 @@ class tt extends et {
|
|
|
2352
2415
|
* @returns {void}
|
|
2353
2416
|
*/
|
|
2354
2417
|
performPostMessage(e) {
|
|
2355
|
-
return
|
|
2418
|
+
return u.safeExecute(() => {
|
|
2356
2419
|
const { data: r } = e;
|
|
2357
2420
|
if (this.isWeixinApiAvailable())
|
|
2358
2421
|
return window.wx.miniProgram.postMessage({ data: r });
|
|
2359
|
-
|
|
2422
|
+
ce("postMessage", r);
|
|
2360
2423
|
}, {
|
|
2361
2424
|
platform: this.name,
|
|
2362
2425
|
method: "performPostMessage",
|
|
@@ -2369,7 +2432,7 @@ class tt extends et {
|
|
|
2369
2432
|
* @returns {void}
|
|
2370
2433
|
*/
|
|
2371
2434
|
performGetEnv(e) {
|
|
2372
|
-
return
|
|
2435
|
+
return u.safeExecute(() => {
|
|
2373
2436
|
if (!e || typeof e != "function")
|
|
2374
2437
|
throw new Error("Callback function is required for getEnv");
|
|
2375
2438
|
if (this.isWeixinApiAvailable() && window.wx.miniProgram.getEnv)
|
|
@@ -2384,19 +2447,19 @@ class tt extends et {
|
|
|
2384
2447
|
});
|
|
2385
2448
|
}
|
|
2386
2449
|
}
|
|
2387
|
-
const
|
|
2388
|
-
var
|
|
2450
|
+
const Y = new nt(), Mr = (t) => Y.navigateTo(t), Lr = (t) => Y.navigateBack(t), br = (t) => Y.switchTab(t), xr = (t) => Y.reLaunch(t), vr = (t) => Y.redirectTo(t), Dr = (t) => Y.postMessage(t), Ur = (t) => Y.getEnv(t);
|
|
2451
|
+
var it = /* @__PURE__ */ Object.freeze({
|
|
2389
2452
|
__proto__: null,
|
|
2390
|
-
WeixinPlatform:
|
|
2391
|
-
getEnv:
|
|
2392
|
-
navigateBack:
|
|
2393
|
-
navigateTo:
|
|
2394
|
-
postMessage:
|
|
2395
|
-
reLaunch:
|
|
2396
|
-
redirectTo:
|
|
2397
|
-
switchTab:
|
|
2453
|
+
WeixinPlatform: nt,
|
|
2454
|
+
getEnv: Ur,
|
|
2455
|
+
navigateBack: Lr,
|
|
2456
|
+
navigateTo: Mr,
|
|
2457
|
+
postMessage: Dr,
|
|
2458
|
+
reLaunch: xr,
|
|
2459
|
+
redirectTo: vr,
|
|
2460
|
+
switchTab: br
|
|
2398
2461
|
});
|
|
2399
|
-
class
|
|
2462
|
+
class st extends rt {
|
|
2400
2463
|
constructor() {
|
|
2401
2464
|
super("app");
|
|
2402
2465
|
}
|
|
@@ -2407,9 +2470,9 @@ class nt extends et {
|
|
|
2407
2470
|
* @returns {void}
|
|
2408
2471
|
*/
|
|
2409
2472
|
performNavigation(e, r) {
|
|
2410
|
-
return
|
|
2473
|
+
return u.safeExecute(() => {
|
|
2411
2474
|
const { url: n, delta: i } = r;
|
|
2412
|
-
|
|
2475
|
+
ce(e, e === "navigateBack" ? { delta: i } : { url: n });
|
|
2413
2476
|
}, {
|
|
2414
2477
|
platform: this.name,
|
|
2415
2478
|
method: "performNavigation",
|
|
@@ -2423,9 +2486,9 @@ class nt extends et {
|
|
|
2423
2486
|
* @returns {void}
|
|
2424
2487
|
*/
|
|
2425
2488
|
performPostMessage(e) {
|
|
2426
|
-
return
|
|
2489
|
+
return u.safeExecute(() => {
|
|
2427
2490
|
const { data: r } = e;
|
|
2428
|
-
|
|
2491
|
+
ce("postMessage", r);
|
|
2429
2492
|
}, {
|
|
2430
2493
|
platform: this.name,
|
|
2431
2494
|
method: "performPostMessage",
|
|
@@ -2438,66 +2501,66 @@ class nt extends et {
|
|
|
2438
2501
|
* @returns {void}
|
|
2439
2502
|
*/
|
|
2440
2503
|
performGetEnv(e) {
|
|
2441
|
-
return
|
|
2504
|
+
return u.safeExecute(() => {
|
|
2442
2505
|
if (!e || typeof e != "function")
|
|
2443
2506
|
throw new Error("Callback function is required for getEnv");
|
|
2444
2507
|
const r = {};
|
|
2445
2508
|
let n = !1;
|
|
2446
|
-
|
|
2509
|
+
Ae() ? (r.uvue = !0, n = !0) : Ie() ? (r.nvue = !0, n = !0) : ye() ? (r.plus = !0, n = !0) : H() && (r.offline = !0, n = !0), n ? r.app = !0 : r.h5 = !0, e(r);
|
|
2447
2510
|
}, {
|
|
2448
2511
|
platform: this.name,
|
|
2449
2512
|
method: "performGetEnv"
|
|
2450
2513
|
});
|
|
2451
2514
|
}
|
|
2452
2515
|
}
|
|
2453
|
-
const
|
|
2454
|
-
var
|
|
2516
|
+
const X = new st(), Wr = (t) => X.navigateTo(t), $r = (t) => X.navigateBack(t), Fr = (t) => X.switchTab(t), Br = (t) => X.reLaunch(t), kr = (t) => X.redirectTo(t), zr = (t) => X.postMessage(t), Kr = (t) => X.getEnv(t);
|
|
2517
|
+
var at = /* @__PURE__ */ Object.freeze({
|
|
2455
2518
|
__proto__: null,
|
|
2456
|
-
AppPlatform:
|
|
2457
|
-
getEnv:
|
|
2458
|
-
navigateBack:
|
|
2459
|
-
navigateTo:
|
|
2460
|
-
postMessage:
|
|
2461
|
-
reLaunch:
|
|
2462
|
-
redirectTo:
|
|
2463
|
-
switchTab:
|
|
2519
|
+
AppPlatform: st,
|
|
2520
|
+
getEnv: Kr,
|
|
2521
|
+
navigateBack: $r,
|
|
2522
|
+
navigateTo: Wr,
|
|
2523
|
+
postMessage: zr,
|
|
2524
|
+
reLaunch: Br,
|
|
2525
|
+
redirectTo: kr,
|
|
2526
|
+
switchTab: Fr
|
|
2464
2527
|
});
|
|
2465
|
-
function
|
|
2466
|
-
return
|
|
2528
|
+
function le() {
|
|
2529
|
+
return I() ? it : at;
|
|
2467
2530
|
}
|
|
2468
|
-
function
|
|
2469
|
-
return
|
|
2531
|
+
function Gr(t) {
|
|
2532
|
+
return le().navigateTo(t);
|
|
2470
2533
|
}
|
|
2471
|
-
function
|
|
2472
|
-
return
|
|
2534
|
+
function Vr(t) {
|
|
2535
|
+
return le().navigateBack(t);
|
|
2473
2536
|
}
|
|
2474
|
-
function
|
|
2475
|
-
return
|
|
2537
|
+
function jr(t) {
|
|
2538
|
+
return le().switchTab(t);
|
|
2476
2539
|
}
|
|
2477
|
-
function
|
|
2478
|
-
return
|
|
2540
|
+
function qr(t) {
|
|
2541
|
+
return le().reLaunch(t);
|
|
2479
2542
|
}
|
|
2480
|
-
function
|
|
2481
|
-
return
|
|
2543
|
+
function Jr(t) {
|
|
2544
|
+
return le().redirectTo(t);
|
|
2482
2545
|
}
|
|
2483
|
-
function
|
|
2484
|
-
return
|
|
2546
|
+
function ot() {
|
|
2547
|
+
return I() ? it : at;
|
|
2485
2548
|
}
|
|
2486
|
-
function
|
|
2487
|
-
return
|
|
2549
|
+
function Hr(t = {}) {
|
|
2550
|
+
return ot().postMessage(t);
|
|
2488
2551
|
}
|
|
2489
|
-
function
|
|
2490
|
-
return
|
|
2552
|
+
function Yr(t) {
|
|
2553
|
+
return ot().getEnv(t);
|
|
2491
2554
|
}
|
|
2492
|
-
function
|
|
2555
|
+
function Xr(t) {
|
|
2493
2556
|
return t && typeof t == "object" && t.__v_raw ? t.__v_raw : t;
|
|
2494
2557
|
}
|
|
2495
|
-
function
|
|
2558
|
+
function Zr() {
|
|
2496
2559
|
return "qsh_callback_" + Date.now() + "_" + Math.random().toString(36).substring(2, 9);
|
|
2497
2560
|
}
|
|
2498
|
-
class
|
|
2561
|
+
class Qr {
|
|
2499
2562
|
constructor() {
|
|
2500
|
-
this.callbacks = /* @__PURE__ */ new Map(), this.timeouts = /* @__PURE__ */ new Map(), this.persistentCallbacksByApi = /* @__PURE__ */ new Map(), this.defaultTimeout = 3e4, typeof window != "undefined" && (window.qshWebviewCallbacks || (window.qshWebviewCallbacks = {})),
|
|
2563
|
+
this.callbacks = /* @__PURE__ */ new Map(), this.timeouts = /* @__PURE__ */ new Map(), this.persistentCallbacksByApi = /* @__PURE__ */ new Map(), this.defaultTimeout = 3e4, typeof window != "undefined" && (window.qshWebviewCallbacks || (window.qshWebviewCallbacks = {})), E.debug("WebView 桥接器已初始化");
|
|
2501
2564
|
}
|
|
2502
2565
|
/**
|
|
2503
2566
|
* 向主应用发送 API 调用消息
|
|
@@ -2507,10 +2570,10 @@ class qr {
|
|
|
2507
2570
|
* @returns {void}
|
|
2508
2571
|
*/
|
|
2509
2572
|
callApi(i) {
|
|
2510
|
-
return
|
|
2511
|
-
return
|
|
2573
|
+
return m(this, arguments, function* (e, r = {}, n = {}) {
|
|
2574
|
+
return u.safeExecute(() => m(this, null, function* () {
|
|
2512
2575
|
var O;
|
|
2513
|
-
if (typeof window != "undefined" && window === window.parent && !window.plus && !window.__uniapp_x_postMessage && !window.__uniapp_x_ && !window.__dcloud_weex_postMessage && !window.__dcloud_weex_) {
|
|
2576
|
+
if (typeof window != "undefined" && window === window.parent && !window.plus && !window.__uniapp_x_postMessage && !window.__uniapp_x_ && !window.__dcloud_weex_postMessage && !window.__dcloud_weex_ && !H()) {
|
|
2514
2577
|
const b = new R(
|
|
2515
2578
|
L.PLATFORM_NOT_SUPPORTED,
|
|
2516
2579
|
"当前不在宿主 WebView 容器中,无法发送消息"
|
|
@@ -2527,35 +2590,35 @@ class qr {
|
|
|
2527
2590
|
metadata: {}
|
|
2528
2591
|
};
|
|
2529
2592
|
W.setApiLoading(e, !0);
|
|
2530
|
-
const f = yield
|
|
2593
|
+
const f = yield j.runRequest(o);
|
|
2531
2594
|
if (f.abort) {
|
|
2532
|
-
|
|
2595
|
+
E.warn("API 调用被拦截器中止", { api: e }), W.setApiLoading(e, !1), n.fail && n.fail({
|
|
2533
2596
|
errMsg: ((O = f.error) == null ? void 0 : O.message) || "API 调用被中止",
|
|
2534
2597
|
code: "INTERCEPTED"
|
|
2535
2598
|
}), n.complete && n.complete({ success: !1 });
|
|
2536
2599
|
return;
|
|
2537
2600
|
}
|
|
2538
|
-
const h =
|
|
2601
|
+
const h = Zr();
|
|
2539
2602
|
if (n.success || n.fail || n.complete) {
|
|
2540
|
-
if (this.callbacks.set(h,
|
|
2603
|
+
if (this.callbacks.set(h, p(d({}, n), {
|
|
2541
2604
|
context: f
|
|
2542
2605
|
// 保存上下文用于响应拦截
|
|
2543
|
-
})), window.qshWebviewCallbacks[h] = (
|
|
2544
|
-
this.handleCallback(h,
|
|
2606
|
+
})), window.qshWebviewCallbacks[h] = (_e) => {
|
|
2607
|
+
this.handleCallback(h, _e);
|
|
2545
2608
|
}, r.isPersistent && (this.persistentCallbacksByApi.has(e) || this.persistentCallbacksByApi.set(e, /* @__PURE__ */ new Set()), this.persistentCallbacksByApi.get(e).add(h)), r.isPersistent || r.disableTimeout)
|
|
2546
|
-
|
|
2609
|
+
E.info(`API ${e} 禁用超时清理,将等待回调返回后清理`, {
|
|
2547
2610
|
callbackId: h,
|
|
2548
2611
|
isPersistent: r.isPersistent,
|
|
2549
2612
|
disableTimeout: r.disableTimeout
|
|
2550
2613
|
});
|
|
2551
2614
|
else {
|
|
2552
|
-
const
|
|
2553
|
-
|
|
2615
|
+
const _e = setTimeout(() => {
|
|
2616
|
+
E.warn("API 调用超时,自动清理回调", { api: e, callbackId: h }), n.fail && n.fail({
|
|
2554
2617
|
errMsg: `API ${e} 调用超时`,
|
|
2555
2618
|
code: "TIMEOUT"
|
|
2556
2619
|
}), this.cleanupCallback(h);
|
|
2557
2620
|
}, r.timeout || this.defaultTimeout);
|
|
2558
|
-
this.timeouts.set(h,
|
|
2621
|
+
this.timeouts.set(h, _e);
|
|
2559
2622
|
}
|
|
2560
2623
|
const N = {
|
|
2561
2624
|
type: "qsh_api_call",
|
|
@@ -2564,12 +2627,12 @@ class qr {
|
|
|
2564
2627
|
callbackId: h,
|
|
2565
2628
|
timestamp: Date.now()
|
|
2566
2629
|
};
|
|
2567
|
-
|
|
2630
|
+
E.info("发送 API 调用消息", {
|
|
2568
2631
|
api: e,
|
|
2569
2632
|
callbackId: h,
|
|
2570
2633
|
hasSuccess: !!n.success,
|
|
2571
2634
|
hasFail: !!n.fail
|
|
2572
|
-
}), console.log("message:", JSON.stringify(
|
|
2635
|
+
}), console.log("message:", JSON.stringify(Xr(N), null, 2)), ce("postMessage", N);
|
|
2573
2636
|
}
|
|
2574
2637
|
}), {
|
|
2575
2638
|
context: "WebViewBridge.callApi",
|
|
@@ -2584,18 +2647,18 @@ class qr {
|
|
|
2584
2647
|
* @private
|
|
2585
2648
|
*/
|
|
2586
2649
|
handleCallback(e, r) {
|
|
2587
|
-
return
|
|
2588
|
-
return
|
|
2650
|
+
return m(this, null, function* () {
|
|
2651
|
+
return u.safeExecute(() => m(this, null, function* () {
|
|
2589
2652
|
var b, N;
|
|
2590
2653
|
const n = this.callbacks.get(e);
|
|
2591
2654
|
if (!n) {
|
|
2592
|
-
|
|
2655
|
+
E.warn("未找到回调函数", { callbackId: e });
|
|
2593
2656
|
return;
|
|
2594
2657
|
}
|
|
2595
2658
|
const { success: i, fail: a, complete: o, context: f } = n;
|
|
2596
|
-
|
|
2597
|
-
const h = yield
|
|
2598
|
-
f && W.setApiResult(f.apiName, h), h.success && i ? i(h.data) : !h.success && a && a(h.error || { errMsg: "操作失败" }), o && o(h), ((N = (b = n.context) == null ? void 0 : b.params) == null ? void 0 : N.isPersistent) ?
|
|
2659
|
+
E.debug("处理回调", { callbackId: e, result: r });
|
|
2660
|
+
const h = yield j.runResponse(r, f);
|
|
2661
|
+
f && W.setApiResult(f.apiName, h), h.success && i ? i(h.data) : !h.success && a && a(h.error || { errMsg: "操作失败" }), o && o(h), ((N = (b = n.context) == null ? void 0 : b.params) == null ? void 0 : N.isPersistent) ? E.debug("持久监听API:保留回调", { callbackId: e }) : (this.cleanupCallback(e), E.debug("回调执行完成,已清理", { callbackId: e }));
|
|
2599
2662
|
}), {
|
|
2600
2663
|
context: "WebViewBridge.handleCallback",
|
|
2601
2664
|
callbackId: e
|
|
@@ -2620,7 +2683,7 @@ class qr {
|
|
|
2620
2683
|
* 清理所有待处理的回调
|
|
2621
2684
|
*/
|
|
2622
2685
|
clearCallbacks() {
|
|
2623
|
-
|
|
2686
|
+
E.debug("清理所有回调", { count: this.callbacks.size }), this.timeouts.forEach((e) => clearTimeout(e)), this.timeouts.clear(), this.callbacks.clear(), this.persistentCallbacksByApi && this.persistentCallbacksByApi.clear(), typeof window != "undefined" && window.qshWebviewCallbacks && Object.keys(window.qshWebviewCallbacks).forEach((e) => {
|
|
2624
2687
|
e.startsWith("qsh_callback_") && delete window.qshWebviewCallbacks[e];
|
|
2625
2688
|
});
|
|
2626
2689
|
}
|
|
@@ -2634,7 +2697,7 @@ class qr {
|
|
|
2634
2697
|
if (!r || r.size === 0)
|
|
2635
2698
|
return 0;
|
|
2636
2699
|
const n = Array.from(r);
|
|
2637
|
-
return n.forEach((i) => this.cleanupCallback(i)), this.persistentCallbacksByApi.delete(e),
|
|
2700
|
+
return n.forEach((i) => this.cleanupCallback(i)), this.persistentCallbacksByApi.delete(e), E.info("已清理持久回调", { api: e, count: n.length }), n.length;
|
|
2638
2701
|
}
|
|
2639
2702
|
/**
|
|
2640
2703
|
* 获取桥接器状态信息
|
|
@@ -2648,30 +2711,93 @@ class qr {
|
|
|
2648
2711
|
};
|
|
2649
2712
|
}
|
|
2650
2713
|
}
|
|
2651
|
-
const
|
|
2714
|
+
const ct = new Qr(), _ = (t, e, r) => ct.callApi(t, e, r), ee = (t) => ct.cleanupPersistentCallbacksByApi(t);
|
|
2715
|
+
function ut() {
|
|
2716
|
+
return ne(!0);
|
|
2717
|
+
}
|
|
2718
|
+
function en(t) {
|
|
2719
|
+
return t === "offline";
|
|
2720
|
+
}
|
|
2721
|
+
function tn(t = {}) {
|
|
2722
|
+
return u.safeExecute(() => {
|
|
2723
|
+
s.debug("Call getCode through offline webview bridge", {
|
|
2724
|
+
clientId: t.clientId
|
|
2725
|
+
}), _(
|
|
2726
|
+
"getCode",
|
|
2727
|
+
{
|
|
2728
|
+
clientId: t.clientId
|
|
2729
|
+
},
|
|
2730
|
+
{
|
|
2731
|
+
success: (e) => {
|
|
2732
|
+
var r;
|
|
2733
|
+
s.info("Get code success"), (r = t.success) == null || r.call(t, e);
|
|
2734
|
+
},
|
|
2735
|
+
fail: (e) => {
|
|
2736
|
+
var r;
|
|
2737
|
+
s.error("Get code failed", e), (r = t.fail) == null || r.call(t, e);
|
|
2738
|
+
},
|
|
2739
|
+
complete: t.complete
|
|
2740
|
+
}
|
|
2741
|
+
);
|
|
2742
|
+
}, {
|
|
2743
|
+
context: "getCodeInHost",
|
|
2744
|
+
platform: ut().type
|
|
2745
|
+
});
|
|
2746
|
+
}
|
|
2747
|
+
function rn(t = {}) {
|
|
2748
|
+
return u.safeExecute(() => {
|
|
2749
|
+
var n, i;
|
|
2750
|
+
const e = ut(), r = String((t == null ? void 0 : t.clientId) || "").trim();
|
|
2751
|
+
if (!r) {
|
|
2752
|
+
const a = {
|
|
2753
|
+
errMsg: "clientId is required",
|
|
2754
|
+
code: "APP_KEY_MISSING"
|
|
2755
|
+
};
|
|
2756
|
+
s.error("Get code missing clientId"), (n = t.fail) == null || n.call(t, a);
|
|
2757
|
+
return;
|
|
2758
|
+
}
|
|
2759
|
+
if (!en(e.type)) {
|
|
2760
|
+
const a = {
|
|
2761
|
+
errMsg: `Current environment (${e.type}) does not support getCode`,
|
|
2762
|
+
code: "PLATFORM_NOT_SUPPORTED"
|
|
2763
|
+
};
|
|
2764
|
+
s.error("Platform does not support getCode", {
|
|
2765
|
+
platform: e.type
|
|
2766
|
+
}), (i = t.fail) == null || i.call(t, a);
|
|
2767
|
+
return;
|
|
2768
|
+
}
|
|
2769
|
+
tn(p(d({}, t), {
|
|
2770
|
+
clientId: r
|
|
2771
|
+
}));
|
|
2772
|
+
}, {
|
|
2773
|
+
context: "getCode",
|
|
2774
|
+
options: t
|
|
2775
|
+
});
|
|
2776
|
+
}
|
|
2777
|
+
const we = {
|
|
2652
2778
|
ALBUM: "album",
|
|
2653
2779
|
// 相册
|
|
2654
2780
|
CAMERA: "camera"
|
|
2655
2781
|
// 相机
|
|
2656
|
-
},
|
|
2782
|
+
}, Ee = {
|
|
2657
2783
|
ORIGINAL: "original",
|
|
2658
2784
|
// 原图
|
|
2659
2785
|
COMPRESSED: "compressed"
|
|
2660
2786
|
// 压缩图
|
|
2661
|
-
},
|
|
2787
|
+
}, nn = {
|
|
2662
2788
|
count: 9,
|
|
2663
|
-
sizeType: [
|
|
2664
|
-
sourceType: [
|
|
2789
|
+
sizeType: [Ee.ORIGINAL, Ee.COMPRESSED],
|
|
2790
|
+
sourceType: [we.ALBUM, we.CAMERA]
|
|
2665
2791
|
};
|
|
2666
|
-
function
|
|
2667
|
-
const e =
|
|
2668
|
-
return Array.isArray(e.sizeType) || (e.sizeType = [e.sizeType].filter(Boolean)), Array.isArray(e.sourceType) || (e.sourceType = [e.sourceType].filter(Boolean)), e.count = Math.max(1, Math.min(9, parseInt(e.count) || 1)), e.sizeType.length === 0 && (e.sizeType = [
|
|
2792
|
+
function sn(t = {}) {
|
|
2793
|
+
const e = d(d({}, nn), t);
|
|
2794
|
+
return Array.isArray(e.sizeType) || (e.sizeType = [e.sizeType].filter(Boolean)), Array.isArray(e.sourceType) || (e.sourceType = [e.sourceType].filter(Boolean)), e.count = Math.max(1, Math.min(9, parseInt(e.count) || 1)), e.sizeType.length === 0 && (e.sizeType = [Ee.COMPRESSED]), e.sourceType.length === 0 && (e.sourceType = [we.ALBUM]), e;
|
|
2669
2795
|
}
|
|
2670
|
-
function
|
|
2671
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
2796
|
+
function lt() {
|
|
2797
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
2672
2798
|
}
|
|
2673
|
-
function
|
|
2674
|
-
return
|
|
2799
|
+
function ft(t) {
|
|
2800
|
+
return u.safeExecute(() => {
|
|
2675
2801
|
var e;
|
|
2676
2802
|
if (!window.wx) {
|
|
2677
2803
|
const r = {
|
|
@@ -2682,7 +2808,7 @@ function ct(t) {
|
|
|
2682
2808
|
return;
|
|
2683
2809
|
}
|
|
2684
2810
|
if (!G()) {
|
|
2685
|
-
s.info("等待微信配置完成"), B().then(() =>
|
|
2811
|
+
s.info("等待微信配置完成"), B().then(() => ft(t)).catch((r) => {
|
|
2686
2812
|
var n;
|
|
2687
2813
|
s.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
2688
2814
|
});
|
|
@@ -2707,9 +2833,9 @@ function ct(t) {
|
|
|
2707
2833
|
platform: "weixin"
|
|
2708
2834
|
});
|
|
2709
2835
|
}
|
|
2710
|
-
function
|
|
2711
|
-
return
|
|
2712
|
-
s.debug("通过 WebView 桥接调用图片选择", t), _("chooseImage",
|
|
2836
|
+
function an(t) {
|
|
2837
|
+
return u.safeExecute(() => {
|
|
2838
|
+
s.debug("通过 WebView 桥接调用图片选择", t), _("chooseImage", p(d({}, t), { disableTimeout: !0 }), {
|
|
2713
2839
|
success: (e) => {
|
|
2714
2840
|
var r, n;
|
|
2715
2841
|
s.info("UniApp 图片选择成功", {
|
|
@@ -2727,34 +2853,34 @@ function Yr(t) {
|
|
|
2727
2853
|
platform: "uniapp"
|
|
2728
2854
|
});
|
|
2729
2855
|
}
|
|
2730
|
-
function
|
|
2731
|
-
return
|
|
2856
|
+
function on(t = {}) {
|
|
2857
|
+
return u.safeExecute(() => {
|
|
2732
2858
|
var r;
|
|
2733
|
-
if (!
|
|
2859
|
+
if (!lt()) {
|
|
2734
2860
|
const n = {
|
|
2735
|
-
errMsg: `当前环境 (${
|
|
2861
|
+
errMsg: `当前环境 (${l.type}) 不支持图片选择功能`,
|
|
2736
2862
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
2737
2863
|
};
|
|
2738
|
-
s.error("平台不支持图片选择", { platform:
|
|
2864
|
+
s.error("平台不支持图片选择", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
2739
2865
|
return;
|
|
2740
2866
|
}
|
|
2741
|
-
const e =
|
|
2867
|
+
const e = sn(t);
|
|
2742
2868
|
s.info("开始选择图片", {
|
|
2743
|
-
platform:
|
|
2869
|
+
platform: l.type,
|
|
2744
2870
|
count: e.count,
|
|
2745
2871
|
sizeType: e.sizeType,
|
|
2746
2872
|
sourceType: e.sourceType
|
|
2747
|
-
}),
|
|
2873
|
+
}), I() ? ft(e) : an(e);
|
|
2748
2874
|
}, {
|
|
2749
2875
|
context: "chooseImage",
|
|
2750
2876
|
options: t
|
|
2751
2877
|
});
|
|
2752
2878
|
}
|
|
2753
|
-
function
|
|
2879
|
+
function cn() {
|
|
2754
2880
|
return {
|
|
2755
|
-
supported:
|
|
2756
|
-
environment:
|
|
2757
|
-
implementation:
|
|
2881
|
+
supported: lt(),
|
|
2882
|
+
environment: l.type,
|
|
2883
|
+
implementation: I() ? "weixin" : "webview",
|
|
2758
2884
|
features: {
|
|
2759
2885
|
multipleSelection: !0,
|
|
2760
2886
|
// 支持多选
|
|
@@ -2767,7 +2893,7 @@ function Zr() {
|
|
|
2767
2893
|
}
|
|
2768
2894
|
};
|
|
2769
2895
|
}
|
|
2770
|
-
const
|
|
2896
|
+
const J = {
|
|
2771
2897
|
QR_CODE: "qrCode",
|
|
2772
2898
|
// 二维码
|
|
2773
2899
|
BAR_CODE: "barCode",
|
|
@@ -2776,21 +2902,21 @@ const q = {
|
|
|
2776
2902
|
// Data Matrix 码
|
|
2777
2903
|
PDF417: "pdf417"
|
|
2778
2904
|
// PDF417 条码
|
|
2779
|
-
},
|
|
2905
|
+
}, un = {
|
|
2780
2906
|
onlyFromCamera: !0,
|
|
2781
2907
|
// 只从相机扫码
|
|
2782
|
-
scanType: [
|
|
2908
|
+
scanType: [J.QR_CODE, J.BAR_CODE]
|
|
2783
2909
|
// 支持二维码和一维码
|
|
2784
2910
|
};
|
|
2785
|
-
function
|
|
2786
|
-
const e =
|
|
2787
|
-
return Array.isArray(e.scanType) || (e.scanType = [e.scanType].filter(Boolean)), e.scanType.length === 0 && (e.scanType = [
|
|
2911
|
+
function ln(t = {}) {
|
|
2912
|
+
const e = d(d({}, un), t);
|
|
2913
|
+
return Array.isArray(e.scanType) || (e.scanType = [e.scanType].filter(Boolean)), e.scanType.length === 0 && (e.scanType = [J.QR_CODE, J.BAR_CODE]), e.onlyFromCamera = !!e.onlyFromCamera, e;
|
|
2788
2914
|
}
|
|
2789
|
-
function
|
|
2790
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
2915
|
+
function dt() {
|
|
2916
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
2791
2917
|
}
|
|
2792
|
-
function
|
|
2793
|
-
return
|
|
2918
|
+
function gt(t) {
|
|
2919
|
+
return u.safeExecute(() => {
|
|
2794
2920
|
var e;
|
|
2795
2921
|
if (!window.wx) {
|
|
2796
2922
|
const r = {
|
|
@@ -2801,7 +2927,7 @@ function lt(t) {
|
|
|
2801
2927
|
return;
|
|
2802
2928
|
}
|
|
2803
2929
|
if (!G()) {
|
|
2804
|
-
s.info("等待微信配置完成"), B().then(() =>
|
|
2930
|
+
s.info("等待微信配置完成"), B().then(() => gt(t)).catch((r) => {
|
|
2805
2931
|
var n;
|
|
2806
2932
|
s.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
2807
2933
|
});
|
|
@@ -2817,7 +2943,7 @@ function lt(t) {
|
|
|
2817
2943
|
const n = {
|
|
2818
2944
|
result: r.resultStr,
|
|
2819
2945
|
// 扫码内容
|
|
2820
|
-
scanType:
|
|
2946
|
+
scanType: fn(r.resultStr),
|
|
2821
2947
|
// 推测扫码类型
|
|
2822
2948
|
charSet: "utf-8",
|
|
2823
2949
|
// 微信默认 UTF-8
|
|
@@ -2836,12 +2962,12 @@ function lt(t) {
|
|
|
2836
2962
|
platform: "weixin"
|
|
2837
2963
|
});
|
|
2838
2964
|
}
|
|
2839
|
-
function
|
|
2840
|
-
return t ? t.length > 50 || /[^\d]/.test(t) ?
|
|
2965
|
+
function fn(t) {
|
|
2966
|
+
return t ? t.length > 50 || /[^\d]/.test(t) ? J.QR_CODE : J.BAR_CODE : "unknown";
|
|
2841
2967
|
}
|
|
2842
|
-
function
|
|
2843
|
-
return
|
|
2844
|
-
s.debug("通过 WebView 桥接调用扫码", t), _("scanCode",
|
|
2968
|
+
function dn(t) {
|
|
2969
|
+
return u.safeExecute(() => {
|
|
2970
|
+
s.debug("通过 WebView 桥接调用扫码", t), _("scanCode", p(d({}, t), { disableTimeout: !0 }), {
|
|
2845
2971
|
success: (e) => {
|
|
2846
2972
|
var r;
|
|
2847
2973
|
s.info("UniApp 扫码成功", {
|
|
@@ -2860,33 +2986,33 @@ function rn(t) {
|
|
|
2860
2986
|
platform: "uniapp"
|
|
2861
2987
|
});
|
|
2862
2988
|
}
|
|
2863
|
-
function
|
|
2864
|
-
return
|
|
2989
|
+
function gn(t = {}) {
|
|
2990
|
+
return u.safeExecute(() => {
|
|
2865
2991
|
var r;
|
|
2866
|
-
if (!
|
|
2992
|
+
if (!dt()) {
|
|
2867
2993
|
const n = {
|
|
2868
|
-
errMsg: `当前环境 (${
|
|
2994
|
+
errMsg: `当前环境 (${l.type}) 不支持扫码功能`,
|
|
2869
2995
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
2870
2996
|
};
|
|
2871
|
-
s.error("平台不支持扫码", { platform:
|
|
2997
|
+
s.error("平台不支持扫码", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
2872
2998
|
return;
|
|
2873
2999
|
}
|
|
2874
|
-
const e =
|
|
3000
|
+
const e = ln(t);
|
|
2875
3001
|
s.info("开始扫码", {
|
|
2876
|
-
platform:
|
|
3002
|
+
platform: l.type,
|
|
2877
3003
|
onlyFromCamera: e.onlyFromCamera,
|
|
2878
3004
|
scanType: e.scanType
|
|
2879
|
-
}),
|
|
3005
|
+
}), I() ? gt(e) : dn(e);
|
|
2880
3006
|
}, {
|
|
2881
3007
|
context: "scanCode",
|
|
2882
3008
|
options: t
|
|
2883
3009
|
});
|
|
2884
3010
|
}
|
|
2885
|
-
function
|
|
3011
|
+
function hn() {
|
|
2886
3012
|
return {
|
|
2887
|
-
supported:
|
|
2888
|
-
environment:
|
|
2889
|
-
implementation:
|
|
3013
|
+
supported: dt(),
|
|
3014
|
+
environment: l.type,
|
|
3015
|
+
implementation: I() ? "weixin" : "webview",
|
|
2890
3016
|
features: {
|
|
2891
3017
|
onlyFromCamera: !0,
|
|
2892
3018
|
// 支持只从相机扫码
|
|
@@ -2899,30 +3025,30 @@ function sn() {
|
|
|
2899
3025
|
}
|
|
2900
3026
|
};
|
|
2901
3027
|
}
|
|
2902
|
-
const
|
|
3028
|
+
const te = {
|
|
2903
3029
|
WGS84: "wgs84",
|
|
2904
3030
|
// GPS 坐标
|
|
2905
3031
|
GCJ02: "gcj02",
|
|
2906
3032
|
// 国测局坐标(火星坐标)
|
|
2907
3033
|
BD09: "bd09"
|
|
2908
3034
|
// 百度坐标
|
|
2909
|
-
},
|
|
2910
|
-
type:
|
|
3035
|
+
}, pn = {
|
|
3036
|
+
type: te.WGS84,
|
|
2911
3037
|
altitude: !1
|
|
2912
|
-
},
|
|
3038
|
+
}, mn = {
|
|
2913
3039
|
scale: 18
|
|
2914
3040
|
// 地图缩放级别 1-28
|
|
2915
3041
|
};
|
|
2916
|
-
function
|
|
2917
|
-
const e =
|
|
2918
|
-
return Object.values(
|
|
3042
|
+
function wn(t = {}) {
|
|
3043
|
+
const e = d(d({}, pn), t);
|
|
3044
|
+
return Object.values(te).includes(e.type) || (e.type = te.WGS84), e.altitude = !!e.altitude, e;
|
|
2919
3045
|
}
|
|
2920
|
-
function
|
|
2921
|
-
const e =
|
|
2922
|
-
return Object.values(
|
|
3046
|
+
function En(t = {}) {
|
|
3047
|
+
const e = d({}, t);
|
|
3048
|
+
return Object.values(te).includes(e.type) || (e.type = te.WGS84), e.needFullAccuracy = !!e.needFullAccuracy, e;
|
|
2923
3049
|
}
|
|
2924
|
-
function
|
|
2925
|
-
const e =
|
|
3050
|
+
function yn(t = {}) {
|
|
3051
|
+
const e = d(d({}, mn), t);
|
|
2926
3052
|
if (e.latitude === void 0 || e.latitude === null)
|
|
2927
3053
|
throw {
|
|
2928
3054
|
errMsg: "缺少必需参数:latitude(纬度)",
|
|
@@ -2981,11 +3107,11 @@ function ln(t = {}) {
|
|
|
2981
3107
|
}
|
|
2982
3108
|
return e;
|
|
2983
3109
|
}
|
|
2984
|
-
function
|
|
2985
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
3110
|
+
function xe() {
|
|
3111
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
2986
3112
|
}
|
|
2987
|
-
function
|
|
2988
|
-
return
|
|
3113
|
+
function ht(t) {
|
|
3114
|
+
return u.safeExecute(() => {
|
|
2989
3115
|
var e;
|
|
2990
3116
|
if (!window.wx) {
|
|
2991
3117
|
const r = {
|
|
@@ -2996,7 +3122,7 @@ function ft(t) {
|
|
|
2996
3122
|
return;
|
|
2997
3123
|
}
|
|
2998
3124
|
if (!G()) {
|
|
2999
|
-
s.info("等待微信配置完成"), B().then(() =>
|
|
3125
|
+
s.info("等待微信配置完成"), B().then(() => ht(t)).catch((r) => {
|
|
3000
3126
|
var n;
|
|
3001
3127
|
s.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
3002
3128
|
});
|
|
@@ -3022,8 +3148,8 @@ function ft(t) {
|
|
|
3022
3148
|
platform: "weixin"
|
|
3023
3149
|
});
|
|
3024
3150
|
}
|
|
3025
|
-
function
|
|
3026
|
-
return
|
|
3151
|
+
function pt(t) {
|
|
3152
|
+
return u.safeExecute(() => {
|
|
3027
3153
|
var e;
|
|
3028
3154
|
if (!window.wx) {
|
|
3029
3155
|
const r = {
|
|
@@ -3034,7 +3160,7 @@ function dt(t) {
|
|
|
3034
3160
|
return;
|
|
3035
3161
|
}
|
|
3036
3162
|
if (!G()) {
|
|
3037
|
-
s.info("等待微信配置完成"), B().then(() =>
|
|
3163
|
+
s.info("等待微信配置完成"), B().then(() => pt(t)).catch((r) => {
|
|
3038
3164
|
var n;
|
|
3039
3165
|
s.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
3040
3166
|
});
|
|
@@ -3062,8 +3188,8 @@ function dt(t) {
|
|
|
3062
3188
|
platform: "weixin"
|
|
3063
3189
|
});
|
|
3064
3190
|
}
|
|
3065
|
-
function
|
|
3066
|
-
return
|
|
3191
|
+
function In(t) {
|
|
3192
|
+
return u.safeExecute(() => {
|
|
3067
3193
|
s.debug("通过 WebView 桥接调用获取位置", t), _("getLocation", t, {
|
|
3068
3194
|
success: (e) => {
|
|
3069
3195
|
var r;
|
|
@@ -3083,8 +3209,8 @@ function fn(t) {
|
|
|
3083
3209
|
platform: "uniapp"
|
|
3084
3210
|
});
|
|
3085
3211
|
}
|
|
3086
|
-
function
|
|
3087
|
-
return
|
|
3212
|
+
function An(t) {
|
|
3213
|
+
return u.safeExecute(() => {
|
|
3088
3214
|
s.debug("通过 WebView 桥接调用查看位置", t), _("openLocation", t, {
|
|
3089
3215
|
success: (e) => {
|
|
3090
3216
|
var r;
|
|
@@ -3101,62 +3227,62 @@ function dn(t) {
|
|
|
3101
3227
|
platform: "uniapp"
|
|
3102
3228
|
});
|
|
3103
3229
|
}
|
|
3104
|
-
function
|
|
3105
|
-
return
|
|
3230
|
+
function On(t = {}) {
|
|
3231
|
+
return u.safeExecute(() => {
|
|
3106
3232
|
var r;
|
|
3107
|
-
if (!
|
|
3233
|
+
if (!xe()) {
|
|
3108
3234
|
const n = {
|
|
3109
|
-
errMsg: `当前环境 (${
|
|
3235
|
+
errMsg: `当前环境 (${l.type}) 不支持定位功能`,
|
|
3110
3236
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3111
3237
|
};
|
|
3112
|
-
s.error("平台不支持定位", { platform:
|
|
3238
|
+
s.error("平台不支持定位", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
3113
3239
|
return;
|
|
3114
3240
|
}
|
|
3115
|
-
const e =
|
|
3241
|
+
const e = wn(t);
|
|
3116
3242
|
s.info("开始获取位置", {
|
|
3117
|
-
platform:
|
|
3243
|
+
platform: l.type,
|
|
3118
3244
|
type: e.type,
|
|
3119
3245
|
altitude: e.altitude
|
|
3120
|
-
}),
|
|
3246
|
+
}), I() ? ht(e) : In(e);
|
|
3121
3247
|
}, {
|
|
3122
3248
|
context: "getLocation",
|
|
3123
3249
|
options: t
|
|
3124
3250
|
});
|
|
3125
3251
|
}
|
|
3126
|
-
function
|
|
3127
|
-
return
|
|
3252
|
+
function Cn(t = {}) {
|
|
3253
|
+
return u.safeExecute(() => {
|
|
3128
3254
|
var r, n, i;
|
|
3129
|
-
if (!
|
|
3255
|
+
if (!xe()) {
|
|
3130
3256
|
const a = {
|
|
3131
|
-
errMsg: `当前环境 (${
|
|
3257
|
+
errMsg: `当前环境 (${l.type}) 不支持查看位置功能`,
|
|
3132
3258
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3133
3259
|
};
|
|
3134
|
-
s.error("平台不支持查看位置", { platform:
|
|
3260
|
+
s.error("平台不支持查看位置", { platform: l.type }), (r = t.fail) == null || r.call(t, a);
|
|
3135
3261
|
return;
|
|
3136
3262
|
}
|
|
3137
3263
|
let e;
|
|
3138
3264
|
try {
|
|
3139
|
-
e =
|
|
3265
|
+
e = yn(t);
|
|
3140
3266
|
} catch (a) {
|
|
3141
3267
|
s.error("参数验证失败", a), (n = t.fail) == null || n.call(t, a), (i = t.complete) == null || i.call(t);
|
|
3142
3268
|
return;
|
|
3143
3269
|
}
|
|
3144
3270
|
s.info("开始查看位置", {
|
|
3145
|
-
platform:
|
|
3271
|
+
platform: l.type,
|
|
3146
3272
|
latitude: e.latitude,
|
|
3147
3273
|
longitude: e.longitude,
|
|
3148
3274
|
name: e.name
|
|
3149
|
-
}),
|
|
3275
|
+
}), I() ? pt(e) : An(e);
|
|
3150
3276
|
}, {
|
|
3151
3277
|
context: "openLocation",
|
|
3152
3278
|
options: t
|
|
3153
3279
|
});
|
|
3154
3280
|
}
|
|
3155
|
-
function
|
|
3156
|
-
const t =
|
|
3281
|
+
function _n() {
|
|
3282
|
+
const t = I();
|
|
3157
3283
|
return {
|
|
3158
|
-
supported:
|
|
3159
|
-
environment:
|
|
3284
|
+
supported: xe(),
|
|
3285
|
+
environment: l.type,
|
|
3160
3286
|
implementation: t ? "weixin" : "webview",
|
|
3161
3287
|
features: {
|
|
3162
3288
|
getLocation: !0,
|
|
@@ -3175,27 +3301,27 @@ function pn() {
|
|
|
3175
3301
|
};
|
|
3176
3302
|
}
|
|
3177
3303
|
const z = /* @__PURE__ */ new Set(), K = /* @__PURE__ */ new Set();
|
|
3178
|
-
function
|
|
3304
|
+
function mt(t, e, r) {
|
|
3179
3305
|
t.forEach((n) => {
|
|
3180
3306
|
if (typeof n == "function") {
|
|
3181
|
-
|
|
3307
|
+
u.safeExecute(() => n(e), { context: r });
|
|
3182
3308
|
return;
|
|
3183
3309
|
}
|
|
3184
3310
|
s.warn("监听回调不是函数,已跳过", { type: typeof n });
|
|
3185
3311
|
});
|
|
3186
3312
|
}
|
|
3187
|
-
function
|
|
3188
|
-
return
|
|
3313
|
+
function Pn(t = {}) {
|
|
3314
|
+
return u.safeExecute(() => {
|
|
3189
3315
|
var r, n;
|
|
3190
|
-
if (
|
|
3316
|
+
if (I()) {
|
|
3191
3317
|
const i = {
|
|
3192
|
-
errMsg: `当前环境 (${
|
|
3318
|
+
errMsg: `当前环境 (${l.type}) 不支持该接口`,
|
|
3193
3319
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3194
3320
|
};
|
|
3195
|
-
s.error("当前环境不支持此接口", { platform:
|
|
3321
|
+
s.error("当前环境不支持此接口", { platform: l.type }), (r = t.fail) == null || r.call(t, i), (n = t.complete) == null || n.call(t, i);
|
|
3196
3322
|
return;
|
|
3197
3323
|
}
|
|
3198
|
-
const e =
|
|
3324
|
+
const e = En(t);
|
|
3199
3325
|
s.info("正在开启定位监听"), _("startLocationUpdate", {
|
|
3200
3326
|
type: e.type,
|
|
3201
3327
|
needFullAccuracy: e.needFullAccuracy
|
|
@@ -3212,15 +3338,15 @@ function mn(t = {}) {
|
|
|
3212
3338
|
});
|
|
3213
3339
|
}, { context: "startLocationUpdate" });
|
|
3214
3340
|
}
|
|
3215
|
-
function
|
|
3216
|
-
return
|
|
3341
|
+
function Rn(t = {}) {
|
|
3342
|
+
return u.safeExecute(() => {
|
|
3217
3343
|
var e, r;
|
|
3218
|
-
if (
|
|
3344
|
+
if (I()) {
|
|
3219
3345
|
const n = {
|
|
3220
|
-
errMsg: `当前环境 (${
|
|
3346
|
+
errMsg: `当前环境 (${l.type}) 不支持该接口`,
|
|
3221
3347
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3222
3348
|
};
|
|
3223
|
-
s.error("当前环境不支持此接口", { platform:
|
|
3349
|
+
s.error("当前环境不支持此接口", { platform: l.type }), (e = t.fail) == null || e.call(t, n), (r = t.complete) == null || r.call(t, n);
|
|
3224
3350
|
return;
|
|
3225
3351
|
}
|
|
3226
3352
|
s.info("正在停止定位监听"), _("stopLocationUpdate", t, {
|
|
@@ -3236,10 +3362,10 @@ function wn(t = {}) {
|
|
|
3236
3362
|
});
|
|
3237
3363
|
}, { context: "stopLocationUpdate" });
|
|
3238
3364
|
}
|
|
3239
|
-
function
|
|
3240
|
-
return
|
|
3241
|
-
if (
|
|
3242
|
-
s.warn("当前环境不支持此接口", { platform:
|
|
3365
|
+
function Sn(t) {
|
|
3366
|
+
return u.safeExecute(() => {
|
|
3367
|
+
if (I()) {
|
|
3368
|
+
s.warn("当前环境不支持此接口", { platform: l.type });
|
|
3243
3369
|
return;
|
|
3244
3370
|
}
|
|
3245
3371
|
if (typeof t != "function")
|
|
@@ -3250,18 +3376,18 @@ function En(t) {
|
|
|
3250
3376
|
const e = z.size > 0;
|
|
3251
3377
|
z.add(t), e || (s.debug("注册实时位置变化监听器"), _("onLocationChange", { isPersistent: !0 }, {
|
|
3252
3378
|
success: (r) => {
|
|
3253
|
-
s.debug("收到实时位置推送", r),
|
|
3379
|
+
s.debug("收到实时位置推送", r), mt(z, r, "onLocationChange");
|
|
3254
3380
|
},
|
|
3255
3381
|
fail: (r) => {
|
|
3256
|
-
s.warn("位置变化监听出错,请通过 onLocationChangeError 监听错误", r), z.delete(t), z.size === 0 &&
|
|
3382
|
+
s.warn("位置变化监听出错,请通过 onLocationChangeError 监听错误", r), z.delete(t), z.size === 0 && ee("onLocationChange");
|
|
3257
3383
|
}
|
|
3258
3384
|
}));
|
|
3259
3385
|
}, { context: "onLocationChange" });
|
|
3260
3386
|
}
|
|
3261
|
-
function
|
|
3262
|
-
return
|
|
3263
|
-
if (
|
|
3264
|
-
s.warn("当前环境不支持此接口", { platform:
|
|
3387
|
+
function Nn(t) {
|
|
3388
|
+
return u.safeExecute(() => {
|
|
3389
|
+
if (I()) {
|
|
3390
|
+
s.warn("当前环境不支持此接口", { platform: l.type });
|
|
3265
3391
|
return;
|
|
3266
3392
|
}
|
|
3267
3393
|
if (t && typeof t != "function")
|
|
@@ -3271,18 +3397,18 @@ function yn(t) {
|
|
|
3271
3397
|
};
|
|
3272
3398
|
t ? z.delete(t) : z.clear(), !(z.size > 0) && (s.info("移除位置变化监听器"), _("offLocationChange", {}, {
|
|
3273
3399
|
success: () => {
|
|
3274
|
-
s.info("位置变化监听已移除"),
|
|
3400
|
+
s.info("位置变化监听已移除"), ee("onLocationChange");
|
|
3275
3401
|
},
|
|
3276
3402
|
fail: (e) => {
|
|
3277
|
-
s.error("移除位置变化监听失败", e),
|
|
3403
|
+
s.error("移除位置变化监听失败", e), ee("onLocationChange");
|
|
3278
3404
|
}
|
|
3279
3405
|
}));
|
|
3280
3406
|
}, { context: "offLocationChange" });
|
|
3281
3407
|
}
|
|
3282
|
-
function
|
|
3283
|
-
return
|
|
3284
|
-
if (
|
|
3285
|
-
s.warn("当前环境不支持此接口", { platform:
|
|
3408
|
+
function Tn(t) {
|
|
3409
|
+
return u.safeExecute(() => {
|
|
3410
|
+
if (I()) {
|
|
3411
|
+
s.warn("当前环境不支持此接口", { platform: l.type });
|
|
3286
3412
|
return;
|
|
3287
3413
|
}
|
|
3288
3414
|
if (typeof t != "function")
|
|
@@ -3293,18 +3419,18 @@ function In(t) {
|
|
|
3293
3419
|
const e = K.size > 0;
|
|
3294
3420
|
K.add(t), e || (s.debug("注册位置更新错误监听器"), _("onLocationChangeError", { isPersistent: !0 }, {
|
|
3295
3421
|
success: (r) => {
|
|
3296
|
-
s.warn("持续定位发生异常", r),
|
|
3422
|
+
s.warn("持续定位发生异常", r), mt(K, r, "onLocationChangeError");
|
|
3297
3423
|
},
|
|
3298
3424
|
fail: (r) => {
|
|
3299
|
-
s.warn("位置更新错误监听注册失败", r), K.delete(t), K.size === 0 &&
|
|
3425
|
+
s.warn("位置更新错误监听注册失败", r), K.delete(t), K.size === 0 && ee("onLocationChangeError");
|
|
3300
3426
|
}
|
|
3301
3427
|
}));
|
|
3302
3428
|
}, { context: "onLocationChangeError" });
|
|
3303
3429
|
}
|
|
3304
|
-
function
|
|
3305
|
-
return
|
|
3306
|
-
if (
|
|
3307
|
-
s.warn("当前环境不支持此接口", { platform:
|
|
3430
|
+
function Mn(t) {
|
|
3431
|
+
return u.safeExecute(() => {
|
|
3432
|
+
if (I()) {
|
|
3433
|
+
s.warn("当前环境不支持此接口", { platform: l.type });
|
|
3308
3434
|
return;
|
|
3309
3435
|
}
|
|
3310
3436
|
if (t && typeof t != "function")
|
|
@@ -3314,22 +3440,22 @@ function An(t) {
|
|
|
3314
3440
|
};
|
|
3315
3441
|
t ? K.delete(t) : K.clear(), !(K.size > 0) && (s.info("移除定位错误监听器"), _("offLocationChangeError", {}, {
|
|
3316
3442
|
success: () => {
|
|
3317
|
-
s.info("定位错误监听已移除"),
|
|
3443
|
+
s.info("定位错误监听已移除"), ee("onLocationChangeError");
|
|
3318
3444
|
},
|
|
3319
3445
|
fail: (e) => {
|
|
3320
|
-
s.error("移除定位错误监听失败", e),
|
|
3446
|
+
s.error("移除定位错误监听失败", e), ee("onLocationChangeError");
|
|
3321
3447
|
}
|
|
3322
3448
|
}));
|
|
3323
3449
|
}, { context: "offLocationChangeError" });
|
|
3324
3450
|
}
|
|
3325
|
-
const
|
|
3451
|
+
const Ln = {
|
|
3326
3452
|
latitude: null,
|
|
3327
3453
|
// 目标地纬度
|
|
3328
3454
|
longitude: null
|
|
3329
3455
|
// 目标地经度
|
|
3330
3456
|
};
|
|
3331
|
-
function
|
|
3332
|
-
const e =
|
|
3457
|
+
function bn(t = {}) {
|
|
3458
|
+
const e = d(d({}, Ln), t);
|
|
3333
3459
|
return e.latitude !== null && e.latitude !== void 0 && (typeof e.latitude != "number" ? (s.warn("latitude 参数类型错误,已忽略", {
|
|
3334
3460
|
latitude: e.latitude
|
|
3335
3461
|
}), e.latitude = null) : (e.latitude < -90 || e.latitude > 90) && (s.warn("latitude 超出范围,已忽略", {
|
|
@@ -3340,11 +3466,11 @@ function Cn(t = {}) {
|
|
|
3340
3466
|
longitude: e.longitude
|
|
3341
3467
|
}), e.longitude = null)), e;
|
|
3342
3468
|
}
|
|
3343
|
-
function
|
|
3344
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
3469
|
+
function wt() {
|
|
3470
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
3345
3471
|
}
|
|
3346
|
-
function
|
|
3347
|
-
return
|
|
3472
|
+
function Et(t) {
|
|
3473
|
+
return u.safeExecute(() => {
|
|
3348
3474
|
var n;
|
|
3349
3475
|
if (!window.wx) {
|
|
3350
3476
|
const i = {
|
|
@@ -3355,7 +3481,7 @@ function pt(t) {
|
|
|
3355
3481
|
return;
|
|
3356
3482
|
}
|
|
3357
3483
|
if (!G()) {
|
|
3358
|
-
s.info("等待微信配置完成"), B().then(() =>
|
|
3484
|
+
s.info("等待微信配置完成"), B().then(() => Et(t)).catch((i) => {
|
|
3359
3485
|
var a;
|
|
3360
3486
|
s.error("微信配置失败", i), (a = t.fail) == null || a.call(t, { errMsg: `微信配置失败: ${i.message}` });
|
|
3361
3487
|
});
|
|
@@ -3390,7 +3516,7 @@ function pt(t) {
|
|
|
3390
3516
|
},
|
|
3391
3517
|
complete: t.complete
|
|
3392
3518
|
}, r = {};
|
|
3393
|
-
t.latitude !== null && t.latitude !== void 0 && (r.latitude = t.latitude), t.longitude !== null && t.longitude !== void 0 && (r.longitude = t.longitude), window.wx.chooseLocation(
|
|
3519
|
+
t.latitude !== null && t.latitude !== void 0 && (r.latitude = t.latitude), t.longitude !== null && t.longitude !== void 0 && (r.longitude = t.longitude), window.wx.chooseLocation(p(d({}, r), {
|
|
3394
3520
|
success: e.success,
|
|
3395
3521
|
fail: e.fail,
|
|
3396
3522
|
complete: e.complete
|
|
@@ -3400,8 +3526,8 @@ function pt(t) {
|
|
|
3400
3526
|
platform: "weixin"
|
|
3401
3527
|
});
|
|
3402
3528
|
}
|
|
3403
|
-
function
|
|
3404
|
-
return
|
|
3529
|
+
function xn(t) {
|
|
3530
|
+
return u.safeExecute(() => {
|
|
3405
3531
|
s.debug("通过 WebView 桥接调用位置选择", t);
|
|
3406
3532
|
const e = {
|
|
3407
3533
|
// 禁用超时清理,等待用户操作完成后才清理
|
|
@@ -3435,33 +3561,33 @@ function _n(t) {
|
|
|
3435
3561
|
platform: "uniapp"
|
|
3436
3562
|
});
|
|
3437
3563
|
}
|
|
3438
|
-
function
|
|
3439
|
-
return
|
|
3564
|
+
function vn(t = {}) {
|
|
3565
|
+
return u.safeExecute(() => {
|
|
3440
3566
|
var r;
|
|
3441
|
-
if (!
|
|
3567
|
+
if (!wt()) {
|
|
3442
3568
|
const n = {
|
|
3443
|
-
errMsg: `当前环境 (${
|
|
3569
|
+
errMsg: `当前环境 (${l.type}) 不支持位置选择功能`,
|
|
3444
3570
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3445
3571
|
};
|
|
3446
|
-
s.error("平台不支持位置选择", { platform:
|
|
3572
|
+
s.error("平台不支持位置选择", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
3447
3573
|
return;
|
|
3448
3574
|
}
|
|
3449
|
-
const e =
|
|
3575
|
+
const e = bn(t);
|
|
3450
3576
|
s.info("开始选择位置", {
|
|
3451
|
-
platform:
|
|
3577
|
+
platform: l.type,
|
|
3452
3578
|
latitude: e.latitude,
|
|
3453
3579
|
longitude: e.longitude
|
|
3454
|
-
}),
|
|
3580
|
+
}), I() ? Et(e) : xn(e);
|
|
3455
3581
|
}, {
|
|
3456
3582
|
context: "chooseLocation",
|
|
3457
3583
|
options: t
|
|
3458
3584
|
});
|
|
3459
3585
|
}
|
|
3460
|
-
function
|
|
3586
|
+
function Dn() {
|
|
3461
3587
|
return {
|
|
3462
|
-
supported:
|
|
3463
|
-
environment:
|
|
3464
|
-
implementation:
|
|
3588
|
+
supported: wt(),
|
|
3589
|
+
environment: l.type,
|
|
3590
|
+
implementation: I() ? "weixin" : "webview",
|
|
3465
3591
|
features: {
|
|
3466
3592
|
chooseLocation: !0,
|
|
3467
3593
|
// 支持位置选择
|
|
@@ -3472,21 +3598,21 @@ function Rn() {
|
|
|
3472
3598
|
}
|
|
3473
3599
|
};
|
|
3474
3600
|
}
|
|
3475
|
-
const
|
|
3476
|
-
function
|
|
3477
|
-
|
|
3601
|
+
const yt = /* @__PURE__ */ new Map();
|
|
3602
|
+
function Un(t, e = {}) {
|
|
3603
|
+
yt.set(t, e);
|
|
3478
3604
|
}
|
|
3479
|
-
function
|
|
3480
|
-
const r =
|
|
3605
|
+
function It(t, e) {
|
|
3606
|
+
const r = yt.get(t);
|
|
3481
3607
|
if (r)
|
|
3482
3608
|
return r[e] || r.default;
|
|
3483
3609
|
}
|
|
3484
|
-
const
|
|
3610
|
+
const Wn = {
|
|
3485
3611
|
0: "WXSceneSession",
|
|
3486
3612
|
// 聊天界面
|
|
3487
3613
|
1: "WXSceneTimeline"
|
|
3488
3614
|
// 朋友圈
|
|
3489
|
-
},
|
|
3615
|
+
}, $n = {
|
|
3490
3616
|
0: "图文/网页",
|
|
3491
3617
|
1: "纯文字",
|
|
3492
3618
|
2: "纯图片",
|
|
@@ -3494,8 +3620,8 @@ const Nn = {
|
|
|
3494
3620
|
4: "视频",
|
|
3495
3621
|
5: "小程序"
|
|
3496
3622
|
};
|
|
3497
|
-
function
|
|
3498
|
-
return
|
|
3623
|
+
function At(t = {}) {
|
|
3624
|
+
return u.safeExecute(
|
|
3499
3625
|
() => {
|
|
3500
3626
|
var r;
|
|
3501
3627
|
if (typeof window == "undefined" || !window.wx) {
|
|
@@ -3503,8 +3629,8 @@ function Et(t = {}) {
|
|
|
3503
3629
|
return (r = t.fail) == null || r.call(t, n), Promise.reject(n);
|
|
3504
3630
|
}
|
|
3505
3631
|
if (!G())
|
|
3506
|
-
return s.info("等待微信配置完成"), B().then(() =>
|
|
3507
|
-
const e =
|
|
3632
|
+
return s.info("等待微信配置完成"), B().then(() => At(t));
|
|
3633
|
+
const e = d({}, t);
|
|
3508
3634
|
return s.debug("调用微信分享", e), t != null && t.isCallBack ? new Promise((n, i) => {
|
|
3509
3635
|
_("toShareData", t, {
|
|
3510
3636
|
success: (a) => {
|
|
@@ -3518,7 +3644,7 @@ function Et(t = {}) {
|
|
|
3518
3644
|
complete: t.complete
|
|
3519
3645
|
});
|
|
3520
3646
|
}) : new Promise((n, i) => {
|
|
3521
|
-
window.wx[e.scene](
|
|
3647
|
+
window.wx[e.scene](p(d({}, e), {
|
|
3522
3648
|
success: () => {
|
|
3523
3649
|
var o;
|
|
3524
3650
|
const a = { errMsg: "weixinShare:ok" };
|
|
@@ -3539,15 +3665,15 @@ function Et(t = {}) {
|
|
|
3539
3665
|
}
|
|
3540
3666
|
);
|
|
3541
3667
|
}
|
|
3542
|
-
function
|
|
3543
|
-
const r =
|
|
3668
|
+
function Ot(t = {}, e) {
|
|
3669
|
+
const r = d({}, t), n = {
|
|
3544
3670
|
scene: r.scene === 1 ? "updateTimelineShareData" : "updateAppMessageShareData"
|
|
3545
3671
|
};
|
|
3546
3672
|
return s.info("格式化微信参数", r), Object.prototype.hasOwnProperty.call(r, "title") ? Object.prototype.hasOwnProperty.call(r, "imageUrl") ? Object.prototype.hasOwnProperty.call(r, "path") ? Object.prototype.hasOwnProperty.call(r, "summary") ? (n.title = r.title, n.imgUrl = r.imageUrl, n.link = r.path, n.desc = r.summary, { params: n, success: !0 }) : { message: "参数字段summary值缺少!", success: !1 } : { message: "参数字段path值缺少!", success: !1 } : { message: "参数字段imageUrl值缺少!9999", success: !1 } : { message: "参数字段title值缺少!", success: !1 };
|
|
3547
3673
|
}
|
|
3548
|
-
function
|
|
3549
|
-
return
|
|
3550
|
-
() => (s.debug("通过 WebView 桥接调用微信分享", t), console.log("桥接调用微信分享桥接调用微信分享:", JSON.stringify(
|
|
3674
|
+
function V(t = {}) {
|
|
3675
|
+
return u.safeExecute(
|
|
3676
|
+
() => (s.debug("通过 WebView 桥接调用微信分享", t), console.log("桥接调用微信分享桥接调用微信分享:", JSON.stringify(Ne(t), null, 2)), new Promise((e, r) => {
|
|
3551
3677
|
_("toShareData", t, {
|
|
3552
3678
|
success: (n) => {
|
|
3553
3679
|
var i;
|
|
@@ -3566,14 +3692,14 @@ function Y(t = {}) {
|
|
|
3566
3692
|
}
|
|
3567
3693
|
);
|
|
3568
3694
|
}
|
|
3569
|
-
function
|
|
3570
|
-
const e =
|
|
3695
|
+
function Ct(t = {}) {
|
|
3696
|
+
const e = d({}, t), r = {
|
|
3571
3697
|
provider: "weixin",
|
|
3572
3698
|
scene: "WXSceneSession"
|
|
3573
3699
|
};
|
|
3574
|
-
if (s.info("格式化 UniApp 参数", e), [0, 1].some((n) => parseInt(n) === parseInt(e.scene)) ? r.scene =
|
|
3700
|
+
if (s.info("格式化 UniApp 参数", e), [0, 1].some((n) => parseInt(n) === parseInt(e.scene)) ? r.scene = Wn[e.scene] : r.scene = "WXSceneSession", Object.prototype.hasOwnProperty.call(e, "type")) {
|
|
3575
3701
|
const n = Number(e.type);
|
|
3576
|
-
if (Object.keys(
|
|
3702
|
+
if (Object.keys($n).some((a) => parseInt(a) === n)) {
|
|
3577
3703
|
if (r.type = n, [0].includes(n))
|
|
3578
3704
|
if (Object.prototype.hasOwnProperty.call(e, "path"))
|
|
3579
3705
|
r.href = e.path;
|
|
@@ -3589,32 +3715,33 @@ function It(t = {}) {
|
|
|
3589
3715
|
r.imageUrl = e.imageUrl;
|
|
3590
3716
|
else
|
|
3591
3717
|
return { message: "参数字段imageUrl值缺少!", success: !1 };
|
|
3592
|
-
[5].includes(n) && Object.prototype.hasOwnProperty.call(e, "miniProgram") &&
|
|
3718
|
+
[5].includes(n) && Object.prototype.hasOwnProperty.call(e, "miniProgram") && d({}, e.miniProgram), Object.prototype.hasOwnProperty.call(e, "title") && (r.title = e.title), Object.prototype.hasOwnProperty.call(e, "success") && (r.success = e.success), Object.prototype.hasOwnProperty.call(e, "fail") && (r.fail = e.fail), Object.prototype.hasOwnProperty.call(e, "complete") && (r.complete = e.complete);
|
|
3593
3719
|
} else
|
|
3594
3720
|
return { message: "参数字段type值有误!", success: !1 };
|
|
3595
3721
|
} else
|
|
3596
3722
|
return { message: "参数字段type缺少!", success: !1 };
|
|
3597
3723
|
return { params: r, success: !0 };
|
|
3598
3724
|
}
|
|
3599
|
-
const
|
|
3600
|
-
|
|
3601
|
-
weixin:
|
|
3602
|
-
webview:
|
|
3603
|
-
plus:
|
|
3604
|
-
nvue:
|
|
3605
|
-
uvue:
|
|
3606
|
-
UniApp:
|
|
3607
|
-
|
|
3725
|
+
const ve = "share.toShare";
|
|
3726
|
+
Un(ve, {
|
|
3727
|
+
weixin: At,
|
|
3728
|
+
webview: V,
|
|
3729
|
+
plus: V,
|
|
3730
|
+
nvue: V,
|
|
3731
|
+
uvue: V,
|
|
3732
|
+
UniApp: V,
|
|
3733
|
+
offline: V,
|
|
3734
|
+
h5: V,
|
|
3608
3735
|
default: void 0
|
|
3609
3736
|
});
|
|
3610
|
-
function
|
|
3737
|
+
function Ne(t) {
|
|
3611
3738
|
return t && typeof t == "object" && t.__v_raw ? t.__v_raw : t;
|
|
3612
3739
|
}
|
|
3613
|
-
function
|
|
3614
|
-
return
|
|
3740
|
+
function _t(t = {}) {
|
|
3741
|
+
return u.safeExecute(
|
|
3615
3742
|
() => {
|
|
3616
3743
|
var a, o;
|
|
3617
|
-
const e =
|
|
3744
|
+
const e = ne(), r = It(ve, e.type);
|
|
3618
3745
|
if (typeof r != "function") {
|
|
3619
3746
|
const f = {
|
|
3620
3747
|
errMsg: `当前环境 (${e.type}) 不支持微信分享功能`,
|
|
@@ -3622,7 +3749,7 @@ function At(t = {}) {
|
|
|
3622
3749
|
};
|
|
3623
3750
|
return s.error("平台不支持微信分享", { platform: e.type }), (a = t.fail) == null || a.call(t, f), Promise.reject(f);
|
|
3624
3751
|
}
|
|
3625
|
-
const n =
|
|
3752
|
+
const n = I() ? Ot(t) : Ct(t);
|
|
3626
3753
|
if (!n.success) {
|
|
3627
3754
|
const f = { errMsg: n.message || "参数校验失败", code: "INVALID_PARAMS" };
|
|
3628
3755
|
return (o = t.fail) == null || o.call(t, f), Promise.reject(f);
|
|
@@ -3636,19 +3763,19 @@ function At(t = {}) {
|
|
|
3636
3763
|
}
|
|
3637
3764
|
);
|
|
3638
3765
|
}
|
|
3639
|
-
function
|
|
3766
|
+
function Fn(t = {}) {
|
|
3640
3767
|
return new Promise((e, r) => {
|
|
3641
|
-
|
|
3768
|
+
_t(p(d({}, t), {
|
|
3642
3769
|
success: e,
|
|
3643
3770
|
fail: r
|
|
3644
3771
|
}));
|
|
3645
3772
|
});
|
|
3646
3773
|
}
|
|
3647
|
-
function
|
|
3648
|
-
return
|
|
3774
|
+
function Pt(t = {}) {
|
|
3775
|
+
return u.safeExecute(
|
|
3649
3776
|
() => {
|
|
3650
3777
|
var a, o;
|
|
3651
|
-
const e =
|
|
3778
|
+
const e = ne(), r = It(ve, e.type);
|
|
3652
3779
|
if (typeof r != "function") {
|
|
3653
3780
|
const f = {
|
|
3654
3781
|
errMsg: `当前环境 (${e.type}) 不支持微信分享功能`,
|
|
@@ -3656,13 +3783,13 @@ function Ot(t = {}) {
|
|
|
3656
3783
|
};
|
|
3657
3784
|
return s.error("平台不支持微信分享", { platform: e.type }), (a = t.fail) == null || a.call(t, f), Promise.reject(f);
|
|
3658
3785
|
}
|
|
3659
|
-
const n =
|
|
3660
|
-
if (console.log("normalizednormalizednormalized:", JSON.stringify(
|
|
3786
|
+
const n = I() ? Ot(t) : Ct(t);
|
|
3787
|
+
if (console.log("normalizednormalizednormalized:", JSON.stringify(Ne(n), null, 2)), !n.success) {
|
|
3661
3788
|
const f = { errMsg: n.message || "参数校验失败", code: "INVALID_PARAMS" };
|
|
3662
|
-
return (o = t.fail) == null || o.call(t, f), console.log("你是什么东西啊:", JSON.stringify(
|
|
3789
|
+
return (o = t.fail) == null || o.call(t, f), console.log("你是什么东西啊:", JSON.stringify(Ne(f), null, 2)), Promise.reject(f);
|
|
3663
3790
|
}
|
|
3664
3791
|
const i = n.params;
|
|
3665
|
-
return s.info("开始微信分享", { platform: e.type, type: i == null ? void 0 : i.type }), r(
|
|
3792
|
+
return s.info("开始微信分享", { platform: e.type, type: i == null ? void 0 : i.type }), r(p(d({}, i), { isCallBack: !0 }));
|
|
3666
3793
|
},
|
|
3667
3794
|
{
|
|
3668
3795
|
context: "toShare",
|
|
@@ -3670,15 +3797,15 @@ function Ot(t = {}) {
|
|
|
3670
3797
|
}
|
|
3671
3798
|
);
|
|
3672
3799
|
}
|
|
3673
|
-
function
|
|
3800
|
+
function Bn(t = {}) {
|
|
3674
3801
|
return new Promise((e, r) => {
|
|
3675
|
-
|
|
3802
|
+
Pt(p(d({}, t), {
|
|
3676
3803
|
success: e,
|
|
3677
3804
|
fail: r
|
|
3678
3805
|
}));
|
|
3679
3806
|
});
|
|
3680
3807
|
}
|
|
3681
|
-
const
|
|
3808
|
+
const kn = {
|
|
3682
3809
|
OFF: "off",
|
|
3683
3810
|
// 蓝牙关闭
|
|
3684
3811
|
ON: "on",
|
|
@@ -3687,20 +3814,20 @@ const bn = {
|
|
|
3687
3814
|
// 不支持蓝牙
|
|
3688
3815
|
UNAUTHORIZED: "unauthorized"
|
|
3689
3816
|
// 未授权
|
|
3690
|
-
},
|
|
3817
|
+
}, zn = {
|
|
3691
3818
|
allowDuplicatesKey: !1,
|
|
3692
3819
|
// 是否允许重复上报同一设备
|
|
3693
3820
|
services: []
|
|
3694
3821
|
// 指定服务 UUID 列表
|
|
3695
3822
|
};
|
|
3696
|
-
function
|
|
3697
|
-
return
|
|
3823
|
+
function Ce(t = {}) {
|
|
3824
|
+
return d(d({}, zn), t);
|
|
3698
3825
|
}
|
|
3699
|
-
function
|
|
3700
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
3826
|
+
function fe() {
|
|
3827
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
3701
3828
|
}
|
|
3702
|
-
function
|
|
3703
|
-
return
|
|
3829
|
+
function Kn(t) {
|
|
3830
|
+
return u.safeExecute(() => m(null, null, function* () {
|
|
3704
3831
|
var e;
|
|
3705
3832
|
if (!window.wx) {
|
|
3706
3833
|
const r = { errMsg: "微信JS-SDK未加载", code: "WEIXIN_SDK_NOT_LOADED" };
|
|
@@ -3709,7 +3836,7 @@ function vn(t) {
|
|
|
3709
3836
|
}
|
|
3710
3837
|
G() || (s.info("等待微信配置完成"), yield B()), wx.openBluetoothAdapter({
|
|
3711
3838
|
success: () => {
|
|
3712
|
-
s.info("微信蓝牙适配器已打开"),
|
|
3839
|
+
s.info("微信蓝牙适配器已打开"), Rt(t);
|
|
3713
3840
|
},
|
|
3714
3841
|
fail: (r) => {
|
|
3715
3842
|
var n;
|
|
@@ -3718,8 +3845,8 @@ function vn(t) {
|
|
|
3718
3845
|
});
|
|
3719
3846
|
}), { context: "openBluetoothAdapterInWeixin" });
|
|
3720
3847
|
}
|
|
3721
|
-
function
|
|
3722
|
-
return
|
|
3848
|
+
function Gn(t) {
|
|
3849
|
+
return u.safeExecute(() => {
|
|
3723
3850
|
s.debug("通过 WebView 桥接调用蓝牙功能", t), _("bluetooth", t, {
|
|
3724
3851
|
success: (e) => {
|
|
3725
3852
|
var r;
|
|
@@ -3733,8 +3860,8 @@ function Dn(t) {
|
|
|
3733
3860
|
});
|
|
3734
3861
|
}, { context: "bluetoothInUniApp" });
|
|
3735
3862
|
}
|
|
3736
|
-
function
|
|
3737
|
-
return
|
|
3863
|
+
function Vn(t) {
|
|
3864
|
+
return u.safeExecute(() => {
|
|
3738
3865
|
var e;
|
|
3739
3866
|
s.debug("通过 WebView 桥接调用蓝牙设备搜索功能", t), _("bluetoothDevicesDiscovery", {
|
|
3740
3867
|
action: "startBluetoothDevicesDiscovery",
|
|
@@ -3755,11 +3882,11 @@ function Un(t) {
|
|
|
3755
3882
|
});
|
|
3756
3883
|
}, { context: "startBluetoothDevicesDiscoveryInUniApp" });
|
|
3757
3884
|
}
|
|
3758
|
-
const
|
|
3759
|
-
function
|
|
3760
|
-
return
|
|
3885
|
+
const ge = /* @__PURE__ */ new Set();
|
|
3886
|
+
function jn(t, e = {}) {
|
|
3887
|
+
return u.safeExecute(() => {
|
|
3761
3888
|
var r;
|
|
3762
|
-
return
|
|
3889
|
+
return ge.add(t), ge.size === 1 && _("onBluetoothDeviceFound", {
|
|
3763
3890
|
action: "onBluetoothDeviceFound",
|
|
3764
3891
|
isPersistent: !0,
|
|
3765
3892
|
params: {
|
|
@@ -3768,8 +3895,8 @@ function Wn(t, e = {}) {
|
|
|
3768
3895
|
}
|
|
3769
3896
|
}, {
|
|
3770
3897
|
success: (n) => {
|
|
3771
|
-
|
|
3772
|
-
typeof i == "function" ?
|
|
3898
|
+
ge.forEach((i) => {
|
|
3899
|
+
typeof i == "function" ? u.safeExecute(() => i(n), { context: "BluetoothDeviceCallback" }) : console.warn("[BluetoothDeviceCallback] 不是函数:", i);
|
|
3773
3900
|
});
|
|
3774
3901
|
},
|
|
3775
3902
|
fail: (n) => {
|
|
@@ -3777,11 +3904,11 @@ function Wn(t, e = {}) {
|
|
|
3777
3904
|
console.error("[Bluetooth] 搜索失败:", n), (i = e.fail) == null || i.call(e, n);
|
|
3778
3905
|
},
|
|
3779
3906
|
complete: e.complete
|
|
3780
|
-
}), () =>
|
|
3907
|
+
}), () => ge.delete(t);
|
|
3781
3908
|
}, { context: "qsh_onBluetoothDeviceFound" });
|
|
3782
3909
|
}
|
|
3783
|
-
function
|
|
3784
|
-
return
|
|
3910
|
+
function qn(t) {
|
|
3911
|
+
return u.safeExecute(() => {
|
|
3785
3912
|
var e;
|
|
3786
3913
|
s.debug("通过 WebView 桥接调用蓝牙连接功能", t), _("bluetoothConnection", {
|
|
3787
3914
|
action: "createBLEConnection",
|
|
@@ -3803,90 +3930,90 @@ function $n(t) {
|
|
|
3803
3930
|
});
|
|
3804
3931
|
}, { context: "createBLEConnectionInUniApp" });
|
|
3805
3932
|
}
|
|
3806
|
-
function
|
|
3807
|
-
return
|
|
3933
|
+
function Jn(t = {}) {
|
|
3934
|
+
return u.safeExecute(() => {
|
|
3808
3935
|
var r;
|
|
3809
|
-
if (!
|
|
3936
|
+
if (!fe()) {
|
|
3810
3937
|
const n = {
|
|
3811
|
-
errMsg: `当前环境 (${
|
|
3938
|
+
errMsg: `当前环境 (${l.type}) 不支持蓝牙功能`,
|
|
3812
3939
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3813
3940
|
};
|
|
3814
|
-
s.error("平台不支持蓝牙", { platform:
|
|
3941
|
+
s.error("平台不支持蓝牙", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
3815
3942
|
return;
|
|
3816
3943
|
}
|
|
3817
|
-
const e =
|
|
3944
|
+
const e = Ce(t);
|
|
3818
3945
|
s.info("开始蓝牙操作", {
|
|
3819
|
-
platform:
|
|
3946
|
+
platform: l.type,
|
|
3820
3947
|
services: e.services,
|
|
3821
3948
|
allowDuplicatesKey: e.allowDuplicatesKey
|
|
3822
|
-
}),
|
|
3949
|
+
}), I() ? Kn(e) : Gn(e);
|
|
3823
3950
|
}, { context: "openBluetoothAdapter", options: t });
|
|
3824
3951
|
}
|
|
3825
|
-
function
|
|
3826
|
-
return
|
|
3952
|
+
function Hn(t = {}) {
|
|
3953
|
+
return u.safeExecute(() => {
|
|
3827
3954
|
var r, n;
|
|
3828
|
-
if (!
|
|
3955
|
+
if (!fe()) {
|
|
3829
3956
|
const i = {
|
|
3830
|
-
errMsg: `当前环境 (${
|
|
3957
|
+
errMsg: `当前环境 (${l.type}) 不支持蓝牙功能`,
|
|
3831
3958
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3832
3959
|
};
|
|
3833
|
-
s.error("平台不支持蓝牙", { platform:
|
|
3960
|
+
s.error("平台不支持蓝牙", { platform: l.type }), (r = t.fail) == null || r.call(t, i), (n = t.complete) == null || n.call(t, i);
|
|
3834
3961
|
return;
|
|
3835
3962
|
}
|
|
3836
|
-
const e =
|
|
3963
|
+
const e = Ce(t);
|
|
3837
3964
|
s.info("开始搜索蓝牙设备", {
|
|
3838
|
-
platform:
|
|
3965
|
+
platform: l.type,
|
|
3839
3966
|
services: e.services,
|
|
3840
3967
|
allowDuplicatesKey: e.allowDuplicatesKey
|
|
3841
|
-
}),
|
|
3968
|
+
}), I() ? startBluetoothDevicesDiscoveryInWeixin(e) : Vn(e);
|
|
3842
3969
|
}, { context: "startBluetoothDevicesDiscovery", options: t });
|
|
3843
3970
|
}
|
|
3844
|
-
function
|
|
3845
|
-
return
|
|
3971
|
+
function Rt(t, e = {}) {
|
|
3972
|
+
return u.safeExecute(() => {
|
|
3846
3973
|
var n, i;
|
|
3847
|
-
if (!
|
|
3974
|
+
if (!fe()) {
|
|
3848
3975
|
const a = {
|
|
3849
|
-
errMsg: `当前环境 (${
|
|
3976
|
+
errMsg: `当前环境 (${l.type}) 不支持蓝牙功能`,
|
|
3850
3977
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3851
3978
|
};
|
|
3852
|
-
s.error("平台不支持蓝牙", { platform:
|
|
3979
|
+
s.error("平台不支持蓝牙", { platform: l.type }), (n = e.fail) == null || n.call(e, a), (i = e.complete) == null || i.call(e, a);
|
|
3853
3980
|
return;
|
|
3854
3981
|
}
|
|
3855
|
-
const r =
|
|
3856
|
-
s.info("注册蓝牙设备发现监听", { platform:
|
|
3982
|
+
const r = Ce(e);
|
|
3983
|
+
s.info("注册蓝牙设备发现监听", { platform: l.type }), I() ? onBluetoothDeviceFoundInWeixin(r) : jn(t, r);
|
|
3857
3984
|
}, { context: "onBluetoothDeviceFound", options: e });
|
|
3858
3985
|
}
|
|
3859
|
-
function
|
|
3860
|
-
return
|
|
3986
|
+
function Yn(t = {}) {
|
|
3987
|
+
return u.safeExecute(() => {
|
|
3861
3988
|
var a, o, f, h;
|
|
3862
|
-
if (!
|
|
3989
|
+
if (!fe()) {
|
|
3863
3990
|
const O = {
|
|
3864
|
-
errMsg: `当前环境 (${
|
|
3991
|
+
errMsg: `当前环境 (${l.type}) 不支持蓝牙功能`,
|
|
3865
3992
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3866
3993
|
};
|
|
3867
|
-
s.error("平台不支持蓝牙连接", { platform:
|
|
3994
|
+
s.error("平台不支持蓝牙连接", { platform: l.type }), (a = t.fail) == null || a.call(t, O), (o = t.complete) == null || o.call(t, O);
|
|
3868
3995
|
return;
|
|
3869
3996
|
}
|
|
3870
|
-
const e =
|
|
3997
|
+
const e = Ce(t), { name: r, deviceId: n, autoConnect: i = !1 } = e;
|
|
3871
3998
|
if (!n) {
|
|
3872
3999
|
const O = { errMsg: "缺少 deviceId 参数", code: "INVALID_PARAMS" };
|
|
3873
4000
|
(f = t.fail) == null || f.call(t, O), (h = t.complete) == null || h.call(t, O);
|
|
3874
4001
|
return;
|
|
3875
4002
|
}
|
|
3876
|
-
s.info("创建蓝牙连接", { deviceId: n, autoConnect: i, platform:
|
|
4003
|
+
s.info("创建蓝牙连接", { deviceId: n, autoConnect: i, platform: l.type }), I() ? uni.createBLEConnection({
|
|
3877
4004
|
deviceId: n,
|
|
3878
4005
|
autoConnect: i,
|
|
3879
4006
|
success: t.success,
|
|
3880
4007
|
fail: t.fail,
|
|
3881
4008
|
complete: t.complete
|
|
3882
|
-
}) :
|
|
4009
|
+
}) : qn(e);
|
|
3883
4010
|
}, { context: "createBLEConnection", options: t });
|
|
3884
4011
|
}
|
|
3885
|
-
function
|
|
4012
|
+
function Xn() {
|
|
3886
4013
|
return {
|
|
3887
|
-
supported:
|
|
3888
|
-
environment:
|
|
3889
|
-
implementation:
|
|
4014
|
+
supported: fe(),
|
|
4015
|
+
environment: l.type,
|
|
4016
|
+
implementation: I() ? "weixin" : "webview",
|
|
3890
4017
|
features: {
|
|
3891
4018
|
discovery: !0,
|
|
3892
4019
|
connect: !0,
|
|
@@ -3896,18 +4023,18 @@ function zn() {
|
|
|
3896
4023
|
}
|
|
3897
4024
|
};
|
|
3898
4025
|
}
|
|
3899
|
-
const
|
|
4026
|
+
const Zn = {
|
|
3900
4027
|
// TODO: 添加更多默认配置
|
|
3901
4028
|
};
|
|
3902
|
-
function
|
|
3903
|
-
return
|
|
4029
|
+
function Qn(t = {}) {
|
|
4030
|
+
return d(d({}, Zn), t);
|
|
3904
4031
|
}
|
|
3905
|
-
function
|
|
3906
|
-
return ["webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
4032
|
+
function St() {
|
|
4033
|
+
return ["webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
3907
4034
|
}
|
|
3908
|
-
function
|
|
3909
|
-
return
|
|
3910
|
-
s.debug("通过 WebView 桥接调用打印PDF", t), _("printPdf",
|
|
4035
|
+
function ei(t) {
|
|
4036
|
+
return u.safeExecute(() => {
|
|
4037
|
+
s.debug("通过 WebView 桥接调用打印PDF", t), _("printPdf", p(d({}, t), {
|
|
3911
4038
|
isPersistent: !0
|
|
3912
4039
|
// 强制禁用超时自动清理
|
|
3913
4040
|
}), {
|
|
@@ -3926,37 +4053,37 @@ function Vn(t) {
|
|
|
3926
4053
|
platform: "uniapp"
|
|
3927
4054
|
});
|
|
3928
4055
|
}
|
|
3929
|
-
function
|
|
3930
|
-
return
|
|
4056
|
+
function ti(t = {}) {
|
|
4057
|
+
return u.safeExecute(() => {
|
|
3931
4058
|
var r;
|
|
3932
|
-
if (!
|
|
4059
|
+
if (!St()) {
|
|
3933
4060
|
const n = {
|
|
3934
|
-
errMsg: `当前环境 (${
|
|
4061
|
+
errMsg: `当前环境 (${l.type}) 不支持打印PDF功能`,
|
|
3935
4062
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3936
4063
|
};
|
|
3937
|
-
s.error("平台不支持打印PDF", { platform:
|
|
4064
|
+
s.error("平台不支持打印PDF", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
3938
4065
|
return;
|
|
3939
4066
|
}
|
|
3940
|
-
const e =
|
|
3941
|
-
s.info("开始打印PDF", { platform:
|
|
4067
|
+
const e = Qn(t);
|
|
4068
|
+
s.info("开始打印PDF", { platform: l.type }), ei(e);
|
|
3942
4069
|
}, {
|
|
3943
4070
|
context: "printPdf",
|
|
3944
4071
|
options: t
|
|
3945
4072
|
});
|
|
3946
4073
|
}
|
|
3947
|
-
function
|
|
4074
|
+
function ri() {
|
|
3948
4075
|
return {
|
|
3949
|
-
supported:
|
|
3950
|
-
environment:
|
|
4076
|
+
supported: St(),
|
|
4077
|
+
environment: l.type,
|
|
3951
4078
|
implementation: "uniapp",
|
|
3952
4079
|
features: {
|
|
3953
4080
|
asyncSupport: !0
|
|
3954
4081
|
}
|
|
3955
4082
|
};
|
|
3956
4083
|
}
|
|
3957
|
-
const
|
|
3958
|
-
function
|
|
3959
|
-
const e =
|
|
4084
|
+
const Te = "/pages/face/index";
|
|
4085
|
+
function ni(t = {}) {
|
|
4086
|
+
const e = d({}, t);
|
|
3960
4087
|
if (!e.name || typeof e.name != "string" || !e.name.trim())
|
|
3961
4088
|
throw {
|
|
3962
4089
|
errMsg: "缺少必需参数:name(姓名)",
|
|
@@ -3969,26 +4096,26 @@ function Jn(t = {}) {
|
|
|
3969
4096
|
};
|
|
3970
4097
|
return e.idCardNumber = e.idCardNumber.trim(), e;
|
|
3971
4098
|
}
|
|
3972
|
-
function
|
|
3973
|
-
return
|
|
4099
|
+
function Nt() {
|
|
4100
|
+
return I();
|
|
3974
4101
|
}
|
|
3975
|
-
function
|
|
4102
|
+
function ii() {
|
|
3976
4103
|
return typeof window != "undefined" && window.wx && window.wx.miniProgram && typeof window.wx.miniProgram.navigateTo == "function";
|
|
3977
4104
|
}
|
|
3978
|
-
function
|
|
3979
|
-
const e =
|
|
4105
|
+
function si(t) {
|
|
4106
|
+
const e = p(d({}, t), {
|
|
3980
4107
|
title: document.title || "",
|
|
3981
4108
|
url: window.location.href || ""
|
|
3982
4109
|
}), r = Object.entries(e).filter(([, n]) => n != null && n !== "").map(([n, i]) => `${encodeURIComponent(n)}=${encodeURIComponent(String(i))}`).join("&");
|
|
3983
|
-
return r ? `${
|
|
4110
|
+
return r ? `${Te}?${r}` : Te;
|
|
3984
4111
|
}
|
|
3985
|
-
function
|
|
3986
|
-
return
|
|
3987
|
-
if (!
|
|
4112
|
+
function ai(t) {
|
|
4113
|
+
return u.safeExecute(() => {
|
|
4114
|
+
if (!ii()) {
|
|
3988
4115
|
s.error("微信小程序导航API不可用");
|
|
3989
4116
|
return;
|
|
3990
4117
|
}
|
|
3991
|
-
const e =
|
|
4118
|
+
const e = si(t);
|
|
3992
4119
|
s.debug("跳转宿主人脸识别页面", {
|
|
3993
4120
|
name: t.name,
|
|
3994
4121
|
targetUrl: e
|
|
@@ -4006,33 +4133,33 @@ function Xn(t) {
|
|
|
4006
4133
|
platform: "weixin"
|
|
4007
4134
|
});
|
|
4008
4135
|
}
|
|
4009
|
-
function
|
|
4010
|
-
return
|
|
4011
|
-
if (!
|
|
4012
|
-
s.error("平台不支持人脸识别", { platform:
|
|
4136
|
+
function oi(t = {}) {
|
|
4137
|
+
return u.safeExecute(() => {
|
|
4138
|
+
if (!Nt()) {
|
|
4139
|
+
s.error("平台不支持人脸识别", { platform: l.type });
|
|
4013
4140
|
return;
|
|
4014
4141
|
}
|
|
4015
4142
|
let e;
|
|
4016
4143
|
try {
|
|
4017
|
-
e =
|
|
4144
|
+
e = ni(t);
|
|
4018
4145
|
} catch (r) {
|
|
4019
4146
|
s.error("人脸识别参数校验失败", r);
|
|
4020
4147
|
return;
|
|
4021
4148
|
}
|
|
4022
4149
|
s.info("开始人脸识别", {
|
|
4023
|
-
platform:
|
|
4150
|
+
platform: l.type,
|
|
4024
4151
|
name: e.name,
|
|
4025
|
-
pagePath:
|
|
4026
|
-
}),
|
|
4152
|
+
pagePath: Te
|
|
4153
|
+
}), ai(e);
|
|
4027
4154
|
}, {
|
|
4028
4155
|
context: "faceVerify",
|
|
4029
4156
|
options: t
|
|
4030
4157
|
});
|
|
4031
4158
|
}
|
|
4032
|
-
function
|
|
4159
|
+
function ci() {
|
|
4033
4160
|
return {
|
|
4034
|
-
supported:
|
|
4035
|
-
environment:
|
|
4161
|
+
supported: Nt(),
|
|
4162
|
+
environment: l.type,
|
|
4036
4163
|
implementation: "weixin",
|
|
4037
4164
|
features: {
|
|
4038
4165
|
asyncSupport: !0,
|
|
@@ -4040,36 +4167,36 @@ function Qn() {
|
|
|
4040
4167
|
}
|
|
4041
4168
|
};
|
|
4042
4169
|
}
|
|
4043
|
-
const
|
|
4044
|
-
function
|
|
4045
|
-
if (typeof window == "undefined" || !
|
|
4170
|
+
const Tt = ne();
|
|
4171
|
+
function ui() {
|
|
4172
|
+
if (typeof window == "undefined" || !ne(!0).isWeixinMiniProgram)
|
|
4046
4173
|
return !1;
|
|
4047
|
-
const e =
|
|
4174
|
+
const e = Re().getRuntimeConfig();
|
|
4048
4175
|
return typeof e.clientId == "string" && e.clientId.length > 0;
|
|
4049
4176
|
}
|
|
4050
|
-
function
|
|
4051
|
-
return
|
|
4052
|
-
yield
|
|
4177
|
+
function li() {
|
|
4178
|
+
return m(this, null, function* () {
|
|
4179
|
+
yield tr(), ui() && (yield B());
|
|
4053
4180
|
});
|
|
4054
4181
|
}
|
|
4055
|
-
|
|
4056
|
-
let
|
|
4057
|
-
function
|
|
4058
|
-
if (
|
|
4059
|
-
|
|
4060
|
-
{ name: "load-weixin-sdk", run:
|
|
4061
|
-
{ name: "init-bridge", run:
|
|
4182
|
+
j.useResponse(tt.response, { priority: 1e3 });
|
|
4183
|
+
let Ve = !1;
|
|
4184
|
+
function je() {
|
|
4185
|
+
if (Ve) return;
|
|
4186
|
+
Ve = !0, Or([
|
|
4187
|
+
{ name: "load-weixin-sdk", run: Ze, timeoutMs: 8e3 },
|
|
4188
|
+
{ name: "init-bridge", run: Ye, timeoutMs: 8e3 }
|
|
4062
4189
|
], {
|
|
4063
4190
|
onError: (e, r) => {
|
|
4064
4191
|
console.error(`[QSH-SDK] 初始化失败(${(r == null ? void 0 : r.name) || "unknown"}):`, e);
|
|
4065
4192
|
}
|
|
4066
4193
|
});
|
|
4067
4194
|
}
|
|
4068
|
-
typeof window != "undefined" && (document.readyState === "complete" || document.readyState === "interactive" ? setTimeout(
|
|
4069
|
-
function
|
|
4195
|
+
typeof window != "undefined" && (document.readyState === "complete" || document.readyState === "interactive" ? setTimeout(je, 0) : document.addEventListener("DOMContentLoaded", je));
|
|
4196
|
+
function y(t, { apiName: e } = {}) {
|
|
4070
4197
|
return function(r = {}, ...n) {
|
|
4071
4198
|
const i = r && typeof r == "object" && (typeof r.success == "function" || typeof r.fail == "function" || typeof r.complete == "function"), a = r && typeof r == "object" ? r : {}, o = () => i ? t(a, ...n) : new Promise((h, O) => {
|
|
4072
|
-
const b =
|
|
4199
|
+
const b = p(d({}, a), {
|
|
4073
4200
|
success: (N) => {
|
|
4074
4201
|
typeof a.success == "function" && a.success(N), h(N);
|
|
4075
4202
|
},
|
|
@@ -4080,141 +4207,152 @@ function E(t, { apiName: e } = {}) {
|
|
|
4080
4207
|
});
|
|
4081
4208
|
t(b, ...n);
|
|
4082
4209
|
});
|
|
4083
|
-
return (typeof window == "undefined" ? Promise.resolve() :
|
|
4210
|
+
return (typeof window == "undefined" ? Promise.resolve() : He()).then(() => o()).catch((h) => {
|
|
4084
4211
|
throw console.error(`[QSH-SDK] ${e || "API"} call failed:`, h), h;
|
|
4085
4212
|
});
|
|
4086
4213
|
};
|
|
4087
4214
|
}
|
|
4088
|
-
function
|
|
4215
|
+
function he(t) {
|
|
4089
4216
|
return typeof t == "function" ? { success: t } : t && typeof t == "object" ? t : {};
|
|
4090
4217
|
}
|
|
4091
|
-
const
|
|
4092
|
-
function
|
|
4093
|
-
const e = () =>
|
|
4094
|
-
return (typeof window == "undefined" ? Promise.resolve() :
|
|
4218
|
+
const Mt = y(Gr), Lt = y(Vr), bt = y(jr), xt = y(qr), vt = y(Jr), Dt = y(Hr);
|
|
4219
|
+
function Ut(t) {
|
|
4220
|
+
const e = () => Yr(t);
|
|
4221
|
+
return (typeof window == "undefined" ? Promise.resolve() : He()).then(() => e());
|
|
4095
4222
|
}
|
|
4096
|
-
const
|
|
4097
|
-
function
|
|
4223
|
+
const De = y(rn, { apiName: "getCode" });
|
|
4224
|
+
function fi(t = {}) {
|
|
4098
4225
|
return new Promise((e, r) => {
|
|
4099
|
-
|
|
4226
|
+
De(p(d({}, t), {
|
|
4100
4227
|
success: e,
|
|
4101
4228
|
fail: r
|
|
4102
4229
|
}));
|
|
4103
4230
|
});
|
|
4104
4231
|
}
|
|
4105
|
-
const
|
|
4106
|
-
function
|
|
4232
|
+
const Ue = y(on);
|
|
4233
|
+
function di(t = {}) {
|
|
4107
4234
|
return new Promise((e, r) => {
|
|
4108
|
-
|
|
4235
|
+
Ue(p(d({}, t), {
|
|
4109
4236
|
success: e,
|
|
4110
4237
|
fail: r
|
|
4111
4238
|
}));
|
|
4112
4239
|
});
|
|
4113
4240
|
}
|
|
4114
|
-
const
|
|
4115
|
-
function
|
|
4241
|
+
const Wt = y(ti);
|
|
4242
|
+
function gi(t = {}) {
|
|
4116
4243
|
return new Promise((e, r) => {
|
|
4117
|
-
|
|
4244
|
+
Wt(p(d({}, t), {
|
|
4118
4245
|
success: e,
|
|
4119
4246
|
fail: r
|
|
4120
4247
|
}));
|
|
4121
4248
|
});
|
|
4122
4249
|
}
|
|
4123
|
-
const
|
|
4124
|
-
function
|
|
4250
|
+
const We = y(gn), hi = y(oi);
|
|
4251
|
+
function pi(t = {}) {
|
|
4125
4252
|
return new Promise((e, r) => {
|
|
4126
|
-
|
|
4253
|
+
We(p(d({}, t), {
|
|
4127
4254
|
success: e,
|
|
4128
4255
|
fail: r
|
|
4129
4256
|
}));
|
|
4130
4257
|
});
|
|
4131
4258
|
}
|
|
4132
|
-
const
|
|
4133
|
-
function
|
|
4259
|
+
const mi = y(_t), wi = y(Fn), Ei = y(Pt), yi = y(Bn), $e = y(On);
|
|
4260
|
+
function Ii(t = {}) {
|
|
4134
4261
|
return new Promise((e, r) => {
|
|
4135
|
-
|
|
4262
|
+
$e(p(d({}, t), {
|
|
4136
4263
|
success: e,
|
|
4137
4264
|
fail: r
|
|
4138
4265
|
}));
|
|
4139
4266
|
});
|
|
4140
4267
|
}
|
|
4141
|
-
const
|
|
4142
|
-
function
|
|
4268
|
+
const Fe = y(Cn);
|
|
4269
|
+
function Ai(t = {}) {
|
|
4143
4270
|
return new Promise((e, r) => {
|
|
4144
|
-
|
|
4271
|
+
Fe(p(d({}, t), {
|
|
4145
4272
|
success: e,
|
|
4146
4273
|
fail: r
|
|
4147
4274
|
}));
|
|
4148
4275
|
});
|
|
4149
4276
|
}
|
|
4150
|
-
const
|
|
4151
|
-
function
|
|
4277
|
+
const Be = y(vn);
|
|
4278
|
+
function Oi(t = {}) {
|
|
4152
4279
|
return new Promise((e, r) => {
|
|
4153
|
-
|
|
4280
|
+
Be(p(d({}, t), {
|
|
4154
4281
|
success: e,
|
|
4155
4282
|
fail: r
|
|
4156
4283
|
}));
|
|
4157
4284
|
});
|
|
4158
4285
|
}
|
|
4159
|
-
const
|
|
4160
|
-
function
|
|
4286
|
+
const $t = y(Jn);
|
|
4287
|
+
function Ci(t = {}) {
|
|
4161
4288
|
return new Promise((e, r) => {
|
|
4162
|
-
|
|
4289
|
+
$t(p(d({}, t), {
|
|
4163
4290
|
success: e,
|
|
4164
4291
|
fail: r
|
|
4165
4292
|
}));
|
|
4166
4293
|
});
|
|
4167
4294
|
}
|
|
4168
|
-
const
|
|
4169
|
-
function
|
|
4295
|
+
const Ft = y(Hn);
|
|
4296
|
+
function _i(t = {}) {
|
|
4170
4297
|
return new Promise((e, r) => {
|
|
4171
|
-
|
|
4298
|
+
Ft(p(d({}, t), {
|
|
4172
4299
|
success: e,
|
|
4173
4300
|
fail: r
|
|
4174
4301
|
}));
|
|
4175
4302
|
});
|
|
4176
4303
|
}
|
|
4177
|
-
const
|
|
4178
|
-
function
|
|
4304
|
+
const Bt = y(Rt);
|
|
4305
|
+
function Pi(t = {}) {
|
|
4179
4306
|
return new Promise((e, r) => {
|
|
4180
|
-
|
|
4307
|
+
Bt(p(d({}, t), {
|
|
4181
4308
|
success: e,
|
|
4182
4309
|
fail: r
|
|
4183
4310
|
}));
|
|
4184
4311
|
});
|
|
4185
4312
|
}
|
|
4186
|
-
const
|
|
4313
|
+
const kt = y(Yn);
|
|
4314
|
+
function Ri(t = {}) {
|
|
4315
|
+
return new Promise((e, r) => {
|
|
4316
|
+
kt(p(d({}, t), {
|
|
4317
|
+
success: e,
|
|
4318
|
+
fail: r
|
|
4319
|
+
}));
|
|
4320
|
+
});
|
|
4321
|
+
}
|
|
4322
|
+
const re = {
|
|
4187
4323
|
// 导航 API
|
|
4188
|
-
navigateTo:
|
|
4189
|
-
navigateBack:
|
|
4190
|
-
switchTab:
|
|
4191
|
-
reLaunch:
|
|
4192
|
-
redirectTo:
|
|
4324
|
+
navigateTo: Mt,
|
|
4325
|
+
navigateBack: Lt,
|
|
4326
|
+
switchTab: bt,
|
|
4327
|
+
reLaunch: xt,
|
|
4328
|
+
redirectTo: vt,
|
|
4193
4329
|
// 消息 API
|
|
4194
|
-
postMessage:
|
|
4195
|
-
getEnv:
|
|
4330
|
+
postMessage: Dt,
|
|
4331
|
+
getEnv: Ut,
|
|
4332
|
+
getCode: De,
|
|
4333
|
+
getCodeAsync: fi,
|
|
4196
4334
|
// 图片 API
|
|
4197
|
-
chooseImage:
|
|
4198
|
-
chooseImageAsync:
|
|
4335
|
+
chooseImage: Ue,
|
|
4336
|
+
chooseImageAsync: di,
|
|
4199
4337
|
// 扫码 API
|
|
4200
|
-
scanCode:
|
|
4201
|
-
scanCodeAsync:
|
|
4338
|
+
scanCode: We,
|
|
4339
|
+
scanCodeAsync: pi,
|
|
4202
4340
|
// 位置 API
|
|
4203
|
-
getLocation:
|
|
4204
|
-
getLocationAsync:
|
|
4205
|
-
openLocation:
|
|
4206
|
-
openLocationAsync:
|
|
4207
|
-
chooseLocation:
|
|
4208
|
-
chooseLocationAsync:
|
|
4341
|
+
getLocation: $e,
|
|
4342
|
+
getLocationAsync: Ii,
|
|
4343
|
+
openLocation: Fe,
|
|
4344
|
+
openLocationAsync: Ai,
|
|
4345
|
+
chooseLocation: Be,
|
|
4346
|
+
chooseLocationAsync: Oi,
|
|
4209
4347
|
// 位置监听 API(保留回调签名)
|
|
4210
|
-
onLocationChange: (t) =>
|
|
4211
|
-
offLocationChange: (t) =>
|
|
4212
|
-
onLocationChangeError: (t) =>
|
|
4213
|
-
offLocationChangeError: (t) =>
|
|
4214
|
-
startLocationUpdate:
|
|
4215
|
-
stopLocationUpdate:
|
|
4348
|
+
onLocationChange: (t) => y((e = {}) => Sn(e.success), { apiName: "onLocationChange" })(he(t)),
|
|
4349
|
+
offLocationChange: (t) => y((e = {}) => Nn(e.success), { apiName: "offLocationChange" })(he(t)),
|
|
4350
|
+
onLocationChangeError: (t) => y((e = {}) => Tn(e.success), { apiName: "onLocationChangeError" })(he(t)),
|
|
4351
|
+
offLocationChangeError: (t) => y((e = {}) => Mn(e.success), { apiName: "offLocationChangeError" })(he(t)),
|
|
4352
|
+
startLocationUpdate: y(Pn, { apiName: "startLocationUpdate" }),
|
|
4353
|
+
stopLocationUpdate: y(Rn, { apiName: "stopLocationUpdate" }),
|
|
4216
4354
|
// 环境信息
|
|
4217
|
-
environment:
|
|
4355
|
+
environment: Tt,
|
|
4218
4356
|
/**
|
|
4219
4357
|
* Wait for SDK readiness.
|
|
4220
4358
|
* In Weixin mini-program web-view, if qsh.config({ clientId }) was called,
|
|
@@ -4224,7 +4362,7 @@ const te = {
|
|
|
4224
4362
|
* await qsh.ready()
|
|
4225
4363
|
* @since 2.0.0
|
|
4226
4364
|
*/
|
|
4227
|
-
ready:
|
|
4365
|
+
ready: li,
|
|
4228
4366
|
/**
|
|
4229
4367
|
* 手动初始化 JSBridge
|
|
4230
4368
|
* 默认会在 DOM 就绪时自动初始化;如需更早或手动控制,可调用本方法。
|
|
@@ -4233,7 +4371,7 @@ const te = {
|
|
|
4233
4371
|
* await qsh.init()
|
|
4234
4372
|
* @since 2.0.0
|
|
4235
4373
|
*/
|
|
4236
|
-
init:
|
|
4374
|
+
init: Ye,
|
|
4237
4375
|
/**
|
|
4238
4376
|
* 检查 JSBridge 是否就绪
|
|
4239
4377
|
* @returns {boolean}
|
|
@@ -4241,7 +4379,7 @@ const te = {
|
|
|
4241
4379
|
* if (qsh.isReady()) { console.log('ready') }
|
|
4242
4380
|
* @since 2.0.0
|
|
4243
4381
|
*/
|
|
4244
|
-
isReady:
|
|
4382
|
+
isReady: Ht,
|
|
4245
4383
|
/**
|
|
4246
4384
|
* 获取当前 SDK 状态
|
|
4247
4385
|
* @returns {string}
|
|
@@ -4249,8 +4387,8 @@ const te = {
|
|
|
4249
4387
|
* console.log(qsh.getState()) // 'ready'
|
|
4250
4388
|
* @since 2.0.0
|
|
4251
4389
|
*/
|
|
4252
|
-
getState:
|
|
4253
|
-
config:
|
|
4390
|
+
getState: Yt,
|
|
4391
|
+
config: ze,
|
|
4254
4392
|
// 微信配置 API
|
|
4255
4393
|
weixin: {
|
|
4256
4394
|
/**
|
|
@@ -4260,7 +4398,7 @@ const te = {
|
|
|
4260
4398
|
* await qsh.weixin.waitForConfig()
|
|
4261
4399
|
* @since 2.0.0
|
|
4262
4400
|
*/
|
|
4263
|
-
config:
|
|
4401
|
+
config: ze,
|
|
4264
4402
|
waitForConfig: B,
|
|
4265
4403
|
/**
|
|
4266
4404
|
* 检查微信配置是否完成
|
|
@@ -4277,7 +4415,7 @@ const te = {
|
|
|
4277
4415
|
* console.log(qsh.weixin.getConfigState()) // 'configured'
|
|
4278
4416
|
* @since 2.0.0
|
|
4279
4417
|
*/
|
|
4280
|
-
getConfigState:
|
|
4418
|
+
getConfigState: ar,
|
|
4281
4419
|
/**
|
|
4282
4420
|
* 手动重试微信配置
|
|
4283
4421
|
* @returns {Promise<void>}
|
|
@@ -4285,13 +4423,13 @@ const te = {
|
|
|
4285
4423
|
* await qsh.weixin.retryConfig()
|
|
4286
4424
|
* @since 2.0.0
|
|
4287
4425
|
*/
|
|
4288
|
-
retryConfig:
|
|
4426
|
+
retryConfig: or
|
|
4289
4427
|
},
|
|
4290
4428
|
// WebView 对象(兼容旧版本)
|
|
4291
4429
|
webView: null,
|
|
4292
4430
|
// 图片相关常量
|
|
4293
|
-
ImageSourceTypes:
|
|
4294
|
-
ImageSizeTypes:
|
|
4431
|
+
ImageSourceTypes: we,
|
|
4432
|
+
ImageSizeTypes: Ee,
|
|
4295
4433
|
/**
|
|
4296
4434
|
* 获取图片功能能力信息
|
|
4297
4435
|
* @returns {Object} 能力信息对象
|
|
@@ -4300,9 +4438,9 @@ const te = {
|
|
|
4300
4438
|
* console.log('是否支持:', capabilities.supported)
|
|
4301
4439
|
* @since 2.0.0
|
|
4302
4440
|
*/
|
|
4303
|
-
getImageCapabilities:
|
|
4441
|
+
getImageCapabilities: cn,
|
|
4304
4442
|
// 扫码相关常量
|
|
4305
|
-
ScanTypes:
|
|
4443
|
+
ScanTypes: J,
|
|
4306
4444
|
/**
|
|
4307
4445
|
* 获取扫码功能能力信息
|
|
4308
4446
|
* @returns {Object} 能力信息对象
|
|
@@ -4311,9 +4449,9 @@ const te = {
|
|
|
4311
4449
|
* console.log('是否支持:', capabilities.supported)
|
|
4312
4450
|
* @since 2.1.0
|
|
4313
4451
|
*/
|
|
4314
|
-
getScanCapabilities:
|
|
4452
|
+
getScanCapabilities: hn,
|
|
4315
4453
|
// 位置相关常量
|
|
4316
|
-
CoordinateTypes:
|
|
4454
|
+
CoordinateTypes: te,
|
|
4317
4455
|
/**
|
|
4318
4456
|
* 获取位置功能能力信息
|
|
4319
4457
|
* @returns {Object} 能力信息对象
|
|
@@ -4322,7 +4460,7 @@ const te = {
|
|
|
4322
4460
|
* console.log('是否支持:', capabilities.supported)
|
|
4323
4461
|
* @since 2.1.0
|
|
4324
4462
|
*/
|
|
4325
|
-
getLocationCapabilities:
|
|
4463
|
+
getLocationCapabilities: _n,
|
|
4326
4464
|
/**
|
|
4327
4465
|
* 获取位置选择功能能力信息
|
|
4328
4466
|
* @returns {Object} 能力信息对象
|
|
@@ -4331,23 +4469,23 @@ const te = {
|
|
|
4331
4469
|
* console.log('是否支持:', capabilities.supported)
|
|
4332
4470
|
* @since 2.1.0
|
|
4333
4471
|
*/
|
|
4334
|
-
getChooseLocationCapabilities:
|
|
4472
|
+
getChooseLocationCapabilities: Dn,
|
|
4335
4473
|
// 蓝牙 API
|
|
4336
|
-
openBluetoothAdapter:
|
|
4337
|
-
openBluetoothAdapterAsync:
|
|
4338
|
-
startBluetoothDevicesDiscovery:
|
|
4339
|
-
startBluetoothDevicesDiscoveryAsync:
|
|
4340
|
-
onBluetoothDeviceFound:
|
|
4341
|
-
onBluetoothDeviceFoundAsync:
|
|
4342
|
-
createBLEConnection:
|
|
4343
|
-
createBLEConnectionAsync:
|
|
4474
|
+
openBluetoothAdapter: $t,
|
|
4475
|
+
openBluetoothAdapterAsync: Ci,
|
|
4476
|
+
startBluetoothDevicesDiscovery: Ft,
|
|
4477
|
+
startBluetoothDevicesDiscoveryAsync: _i,
|
|
4478
|
+
onBluetoothDeviceFound: Bt,
|
|
4479
|
+
onBluetoothDeviceFoundAsync: Pi,
|
|
4480
|
+
createBLEConnection: kt,
|
|
4481
|
+
createBLEConnectionAsync: Ri,
|
|
4344
4482
|
// 蓝牙相关常量
|
|
4345
|
-
BluetoothStates:
|
|
4483
|
+
BluetoothStates: kn,
|
|
4346
4484
|
//微信分享
|
|
4347
|
-
toShare:
|
|
4348
|
-
toShareAsync:
|
|
4349
|
-
toShareCallBack:
|
|
4350
|
-
toShareCallBackAsync:
|
|
4485
|
+
toShare: mi,
|
|
4486
|
+
toShareAsync: wi,
|
|
4487
|
+
toShareCallBack: Ei,
|
|
4488
|
+
toShareCallBackAsync: yi,
|
|
4351
4489
|
/**
|
|
4352
4490
|
* 获取蓝牙功能能力信息
|
|
4353
4491
|
* @returns {Object} 能力信息对象
|
|
@@ -4355,10 +4493,10 @@ const te = {
|
|
|
4355
4493
|
* const capabilities = qsh.getBluetoothCapabilities()
|
|
4356
4494
|
* console.log('是否支持:', capabilities.supported)
|
|
4357
4495
|
*/
|
|
4358
|
-
getBluetoothCapabilities:
|
|
4496
|
+
getBluetoothCapabilities: Xn,
|
|
4359
4497
|
// 打印PDF API
|
|
4360
|
-
printPdf:
|
|
4361
|
-
printPdfAsync:
|
|
4498
|
+
printPdf: Wt,
|
|
4499
|
+
printPdfAsync: gi,
|
|
4362
4500
|
/**
|
|
4363
4501
|
* 获取打印PDF功能能力信息
|
|
4364
4502
|
* @returns {Object} 能力信息对象
|
|
@@ -4366,16 +4504,16 @@ const te = {
|
|
|
4366
4504
|
* const capabilities = qsh.getPrintCapabilities()
|
|
4367
4505
|
* console.log('是否支持:', capabilities.supported)
|
|
4368
4506
|
*/
|
|
4369
|
-
getPrintCapabilities:
|
|
4507
|
+
getPrintCapabilities: ri,
|
|
4370
4508
|
// 人脸识别 API(仅支持微信小程序环境)
|
|
4371
|
-
faceVerify:
|
|
4372
|
-
getFaceCapabilities:
|
|
4509
|
+
faceVerify: hi,
|
|
4510
|
+
getFaceCapabilities: ci,
|
|
4373
4511
|
// 插件系统
|
|
4374
4512
|
plugins: {
|
|
4375
4513
|
/**
|
|
4376
4514
|
* 插件管理器
|
|
4377
4515
|
*/
|
|
4378
|
-
manager:
|
|
4516
|
+
manager: se,
|
|
4379
4517
|
/**
|
|
4380
4518
|
* 注册插件
|
|
4381
4519
|
* @param {Object} plugin - 插件对象
|
|
@@ -4383,7 +4521,7 @@ const te = {
|
|
|
4383
4521
|
* @example
|
|
4384
4522
|
* qsh.plugins.register(myPlugin)
|
|
4385
4523
|
*/
|
|
4386
|
-
register: (t) =>
|
|
4524
|
+
register: (t) => se.register(t),
|
|
4387
4525
|
/**
|
|
4388
4526
|
* 安装插件
|
|
4389
4527
|
* @param {string} name - 插件名称
|
|
@@ -4391,21 +4529,21 @@ const te = {
|
|
|
4391
4529
|
* @example
|
|
4392
4530
|
* await qsh.plugins.install('image')
|
|
4393
4531
|
*/
|
|
4394
|
-
install: (t) =>
|
|
4532
|
+
install: (t) => se.install(t, re),
|
|
4395
4533
|
/**
|
|
4396
4534
|
* 获取插件列表
|
|
4397
4535
|
* @returns {Array} 插件列表
|
|
4398
4536
|
* @example
|
|
4399
4537
|
* console.log(qsh.plugins.list())
|
|
4400
4538
|
*/
|
|
4401
|
-
list: () =>
|
|
4539
|
+
list: () => se.getPluginList()
|
|
4402
4540
|
},
|
|
4403
4541
|
// 拦截器系统
|
|
4404
4542
|
interceptors: {
|
|
4405
4543
|
/**
|
|
4406
4544
|
* 拦截器链
|
|
4407
4545
|
*/
|
|
4408
|
-
chain:
|
|
4546
|
+
chain: j,
|
|
4409
4547
|
/**
|
|
4410
4548
|
* 注册请求拦截器
|
|
4411
4549
|
* @param {Function} interceptor - 拦截器函数
|
|
@@ -4417,7 +4555,7 @@ const te = {
|
|
|
4417
4555
|
* return ctx
|
|
4418
4556
|
* })
|
|
4419
4557
|
*/
|
|
4420
|
-
useRequest: (t, e) =>
|
|
4558
|
+
useRequest: (t, e) => j.useRequest(t, e),
|
|
4421
4559
|
/**
|
|
4422
4560
|
* 注册响应拦截器
|
|
4423
4561
|
* @param {Function} interceptor - 拦截器函数
|
|
@@ -4429,16 +4567,16 @@ const te = {
|
|
|
4429
4567
|
* return result
|
|
4430
4568
|
* })
|
|
4431
4569
|
*/
|
|
4432
|
-
useResponse: (t, e) =>
|
|
4570
|
+
useResponse: (t, e) => j.useResponse(t, e),
|
|
4433
4571
|
/**
|
|
4434
4572
|
* 内置拦截器
|
|
4435
4573
|
*/
|
|
4436
4574
|
builtin: {
|
|
4437
|
-
logging:
|
|
4575
|
+
logging: lr,
|
|
4438
4576
|
performance: k,
|
|
4439
|
-
createRetry:
|
|
4440
|
-
createValidation:
|
|
4441
|
-
errorNormalizer:
|
|
4577
|
+
createRetry: fr,
|
|
4578
|
+
createValidation: dr,
|
|
4579
|
+
errorNormalizer: tt
|
|
4442
4580
|
}
|
|
4443
4581
|
},
|
|
4444
4582
|
// 观测指标
|
|
@@ -4461,7 +4599,7 @@ const te = {
|
|
|
4461
4599
|
/**
|
|
4462
4600
|
* 错误消息
|
|
4463
4601
|
*/
|
|
4464
|
-
messages:
|
|
4602
|
+
messages: Se,
|
|
4465
4603
|
/**
|
|
4466
4604
|
* 错误分类
|
|
4467
4605
|
*/
|
|
@@ -4474,7 +4612,7 @@ const te = {
|
|
|
4474
4612
|
* @example
|
|
4475
4613
|
* const standardError = qsh.errors.normalize(error, { apiName: 'chooseImage' })
|
|
4476
4614
|
*/
|
|
4477
|
-
normalize:
|
|
4615
|
+
normalize: et,
|
|
4478
4616
|
/**
|
|
4479
4617
|
* 创建标准错误
|
|
4480
4618
|
* @param {string} code - 错误码
|
|
@@ -4483,7 +4621,7 @@ const te = {
|
|
|
4483
4621
|
* @example
|
|
4484
4622
|
* const error = qsh.errors.create('E_IMG_001', { apiName: 'chooseImage' })
|
|
4485
4623
|
*/
|
|
4486
|
-
create:
|
|
4624
|
+
create: yr,
|
|
4487
4625
|
/**
|
|
4488
4626
|
* 判断是否为标准错误
|
|
4489
4627
|
* @param {any} error - 错误对象
|
|
@@ -4491,7 +4629,7 @@ const te = {
|
|
|
4491
4629
|
* @example
|
|
4492
4630
|
* if (qsh.errors.isStandard(error)) { ... }
|
|
4493
4631
|
*/
|
|
4494
|
-
isStandard:
|
|
4632
|
+
isStandard: Ir
|
|
4495
4633
|
},
|
|
4496
4634
|
// 状态管理
|
|
4497
4635
|
store: {
|
|
@@ -4547,11 +4685,11 @@ const te = {
|
|
|
4547
4685
|
/**
|
|
4548
4686
|
* 错误处理器
|
|
4549
4687
|
*/
|
|
4550
|
-
errorHandler:
|
|
4688
|
+
errorHandler: u,
|
|
4551
4689
|
/**
|
|
4552
4690
|
* 状态管理器
|
|
4553
4691
|
*/
|
|
4554
|
-
stateManager:
|
|
4692
|
+
stateManager: q,
|
|
4555
4693
|
/**
|
|
4556
4694
|
* 启用调试模式
|
|
4557
4695
|
* @example
|
|
@@ -4574,10 +4712,10 @@ const te = {
|
|
|
4574
4712
|
*/
|
|
4575
4713
|
getStats: () => ({
|
|
4576
4714
|
logger: T.getStats(),
|
|
4577
|
-
state:
|
|
4578
|
-
weixinConfig:
|
|
4579
|
-
plugins:
|
|
4580
|
-
interceptors:
|
|
4715
|
+
state: q.getStats(),
|
|
4716
|
+
weixinConfig: Re().getStats(),
|
|
4717
|
+
plugins: se.getStats(),
|
|
4718
|
+
interceptors: j.getStats(),
|
|
4581
4719
|
store: W.getStats()
|
|
4582
4720
|
}),
|
|
4583
4721
|
/**
|
|
@@ -4586,7 +4724,7 @@ const te = {
|
|
|
4586
4724
|
* @example
|
|
4587
4725
|
* console.log(qsh.debug.getWeixinConfigManager().getStats())
|
|
4588
4726
|
*/
|
|
4589
|
-
getWeixinConfigManager:
|
|
4727
|
+
getWeixinConfigManager: Re,
|
|
4590
4728
|
/**
|
|
4591
4729
|
* 导出调试信息
|
|
4592
4730
|
* @returns {string} JSON 格式的调试信息
|
|
@@ -4596,26 +4734,27 @@ const te = {
|
|
|
4596
4734
|
exportDebugInfo: () => T.exportToJSON()
|
|
4597
4735
|
}
|
|
4598
4736
|
};
|
|
4599
|
-
|
|
4600
|
-
navigateTo:
|
|
4601
|
-
navigateBack:
|
|
4602
|
-
switchTab:
|
|
4603
|
-
reLaunch:
|
|
4604
|
-
redirectTo:
|
|
4605
|
-
postMessage:
|
|
4606
|
-
getEnv:
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4737
|
+
Tt.isWeixinMiniProgram ? re.webView = window.wx && window.wx.miniProgram : re.webView = {
|
|
4738
|
+
navigateTo: Mt,
|
|
4739
|
+
navigateBack: Lt,
|
|
4740
|
+
switchTab: bt,
|
|
4741
|
+
reLaunch: xt,
|
|
4742
|
+
redirectTo: vt,
|
|
4743
|
+
postMessage: Dt,
|
|
4744
|
+
getEnv: Ut,
|
|
4745
|
+
getCode: De,
|
|
4746
|
+
chooseImage: Ue,
|
|
4747
|
+
scanCode: We,
|
|
4748
|
+
getLocation: $e,
|
|
4749
|
+
openLocation: Fe,
|
|
4750
|
+
chooseLocation: Be
|
|
4612
4751
|
};
|
|
4613
|
-
const
|
|
4614
|
-
Object.keys(
|
|
4615
|
-
|
|
4752
|
+
const qe = typeof window.uni != "undefined" ? window.uni : {};
|
|
4753
|
+
Object.keys(qe).forEach((t) => {
|
|
4754
|
+
re.hasOwnProperty(t) || (re[t] = qe[t]);
|
|
4616
4755
|
});
|
|
4617
|
-
typeof window != "undefined" && (window.qsh =
|
|
4756
|
+
typeof window != "undefined" && (window.qsh = re);
|
|
4618
4757
|
export {
|
|
4619
|
-
|
|
4758
|
+
re as default
|
|
4620
4759
|
};
|
|
4621
4760
|
//# sourceMappingURL=qsh-webview-sdk.es.js.map
|