qsh-webview-sdk 2.3.3 → 2.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var Bt = Object.defineProperty, kt = Object.defineProperties;
|
|
2
|
+
var Gt = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var Ke = Object.getOwnPropertySymbols;
|
|
4
|
+
var Kt = Object.prototype.hasOwnProperty, zt = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var Ne = (t, e, r) => e in t ? Bt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, g = (t, e) => {
|
|
6
6
|
for (var r in e || (e = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var r of
|
|
10
|
-
|
|
7
|
+
Kt.call(e, r) && Ne(t, r, e[r]);
|
|
8
|
+
if (Ke)
|
|
9
|
+
for (var r of Ke(e))
|
|
10
|
+
zt.call(e, r) && Ne(t, r, e[r]);
|
|
11
11
|
return t;
|
|
12
|
-
},
|
|
13
|
-
var U = (t, e, r) =>
|
|
12
|
+
}, p = (t, e) => kt(t, Gt(e));
|
|
13
|
+
var U = (t, e, r) => Ne(t, typeof e != "symbol" ? e + "" : e, r);
|
|
14
14
|
var w = (t, e, r) => new Promise((n, i) => {
|
|
15
|
-
var s = (
|
|
15
|
+
var s = (f) => {
|
|
16
16
|
try {
|
|
17
|
-
|
|
18
|
-
} catch (
|
|
19
|
-
i(
|
|
17
|
+
h(r.next(f));
|
|
18
|
+
} catch (A) {
|
|
19
|
+
i(A);
|
|
20
20
|
}
|
|
21
|
-
}, c = (
|
|
21
|
+
}, c = (f) => {
|
|
22
22
|
try {
|
|
23
|
-
|
|
24
|
-
} catch (
|
|
25
|
-
i(
|
|
23
|
+
h(r.throw(f));
|
|
24
|
+
} catch (A) {
|
|
25
|
+
i(A);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
|
|
27
|
+
}, h = (f) => f.done ? n(f.value) : Promise.resolve(f.value).then(s, c);
|
|
28
|
+
h((r = r.apply(t, e)).next());
|
|
29
29
|
});
|
|
30
|
-
function
|
|
30
|
+
function de() {
|
|
31
31
|
return typeof window != "undefined" ? window : void 0;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function Le() {
|
|
34
34
|
return typeof navigator == "undefined" ? "" : navigator.userAgent || "";
|
|
35
35
|
}
|
|
36
36
|
function C() {
|
|
37
|
-
const t =
|
|
37
|
+
const t = de();
|
|
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 = Le();
|
|
42
42
|
return !!(e && /micromessenger/i.test(e) && /miniProgram/i.test(e));
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
const t =
|
|
44
|
+
function _e() {
|
|
45
|
+
const t = de();
|
|
46
46
|
return !!(t && t.plus);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
const t =
|
|
48
|
+
function Ce() {
|
|
49
|
+
const t = de();
|
|
50
50
|
return !!(t && (t.__dcloud_weex_postMessage || t.__dcloud_weex_));
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
const t =
|
|
52
|
+
function Oe() {
|
|
53
|
+
const t = de();
|
|
54
54
|
return !!(t && (t.__uniapp_x_postMessage || t.__uniapp_x_));
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
const t =
|
|
56
|
+
function Pe() {
|
|
57
|
+
const t = Le();
|
|
58
58
|
return /uni-app/i.test(t);
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
const t =
|
|
60
|
+
function be() {
|
|
61
|
+
const t = Le();
|
|
62
62
|
return /Html5Plus/i.test(t);
|
|
63
63
|
}
|
|
64
|
-
function
|
|
65
|
-
return
|
|
64
|
+
function Ze() {
|
|
65
|
+
return Pe() || be();
|
|
66
66
|
}
|
|
67
67
|
function J() {
|
|
68
|
-
const t =
|
|
68
|
+
const t = de();
|
|
69
69
|
if (!t) return !1;
|
|
70
70
|
if (t.__offline_bridge_postMessage) return !0;
|
|
71
71
|
try {
|
|
@@ -75,22 +75,22 @@ function J() {
|
|
|
75
75
|
}
|
|
76
76
|
return !1;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
return
|
|
78
|
+
function Vt() {
|
|
79
|
+
return Oe() ? "uvue" : Ce() ? "nvue" : C() ? "weixin" : J() ? "offline" : _e() ? "plus" : Ze() ? "webview" : Pe() ? "UniApp" : "h5";
|
|
80
80
|
}
|
|
81
|
-
let
|
|
81
|
+
let me = null;
|
|
82
82
|
function ne(t = !1) {
|
|
83
|
-
return
|
|
83
|
+
return me && !t || (me = {
|
|
84
84
|
isWeixinMiniProgram: C(),
|
|
85
|
-
isAppPlus:
|
|
86
|
-
isNvue:
|
|
87
|
-
isUvue:
|
|
88
|
-
isUniApp:
|
|
89
|
-
isHtml5Plus:
|
|
90
|
-
isUniAppWebView:
|
|
85
|
+
isAppPlus: _e(),
|
|
86
|
+
isNvue: Ce(),
|
|
87
|
+
isUvue: Oe(),
|
|
88
|
+
isUniApp: Pe(),
|
|
89
|
+
isHtml5Plus: be(),
|
|
90
|
+
isUniAppWebView: Ze(),
|
|
91
91
|
isOfflineWebview: J(),
|
|
92
|
-
type:
|
|
93
|
-
}),
|
|
92
|
+
type: Vt()
|
|
93
|
+
}), me;
|
|
94
94
|
}
|
|
95
95
|
const l = ne(), b = {
|
|
96
96
|
PLATFORM_NOT_SUPPORTED: "PLATFORM_NOT_SUPPORTED",
|
|
@@ -99,7 +99,7 @@ const l = ne(), b = {
|
|
|
99
99
|
INVALID_PARAMETERS: "INVALID_PARAMETERS",
|
|
100
100
|
NETWORK_ERROR: "NETWORK_ERROR"
|
|
101
101
|
};
|
|
102
|
-
class
|
|
102
|
+
class N extends Error {
|
|
103
103
|
/**
|
|
104
104
|
* 构造函数
|
|
105
105
|
* @param {string} type - 错误类型
|
|
@@ -108,7 +108,7 @@ class M extends Error {
|
|
|
108
108
|
* @param {Error} [originalError] - 原始错误对象
|
|
109
109
|
*/
|
|
110
110
|
constructor(e, r, n = {}, i = null) {
|
|
111
|
-
super(r), this.name = "QshError", this.type = e, this.context = n, this.originalError = i, this.timestamp = (/* @__PURE__ */ new Date()).toISOString(), Error.captureStackTrace && Error.captureStackTrace(this,
|
|
111
|
+
super(r), this.name = "QshError", this.type = e, this.context = n, this.originalError = i, this.timestamp = (/* @__PURE__ */ new Date()).toISOString(), Error.captureStackTrace && Error.captureStackTrace(this, N);
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
114
|
* 转换为 JSON 格式
|
|
@@ -125,28 +125,28 @@ class M extends Error {
|
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
const
|
|
128
|
+
const O = class O {
|
|
129
129
|
/**
|
|
130
130
|
* 设置调试模式
|
|
131
131
|
* @param {boolean} enabled - 是否启用调试模式
|
|
132
132
|
*/
|
|
133
133
|
static setDebugMode(e) {
|
|
134
|
-
|
|
134
|
+
O.isDebugMode = e;
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
137
|
* 添加错误回调
|
|
138
138
|
* @param {Function} callback - 错误处理回调函数
|
|
139
139
|
*/
|
|
140
140
|
static addErrorCallback(e) {
|
|
141
|
-
typeof e == "function" &&
|
|
141
|
+
typeof e == "function" && O.errorCallbacks.push(e);
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
144
144
|
* 移除错误回调
|
|
145
145
|
* @param {Function} callback - 要移除的回调函数
|
|
146
146
|
*/
|
|
147
147
|
static removeErrorCallback(e) {
|
|
148
|
-
const r =
|
|
149
|
-
r > -1 &&
|
|
148
|
+
const r = O.errorCallbacks.indexOf(e);
|
|
149
|
+
r > -1 && O.errorCallbacks.splice(r, 1);
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
152
|
* 处理 API 调用错误
|
|
@@ -156,16 +156,16 @@ const _ = class _ {
|
|
|
156
156
|
*/
|
|
157
157
|
static handleApiError(e, r = {}) {
|
|
158
158
|
let n;
|
|
159
|
-
return e instanceof
|
|
159
|
+
return e instanceof N ? n = e : e instanceof Error ? n = new N(
|
|
160
160
|
b.API_CALL_FAILED,
|
|
161
161
|
e.message,
|
|
162
162
|
r,
|
|
163
163
|
e
|
|
164
|
-
) : n = new
|
|
164
|
+
) : n = new N(
|
|
165
165
|
b.API_CALL_FAILED,
|
|
166
166
|
String(e),
|
|
167
167
|
r
|
|
168
|
-
),
|
|
168
|
+
), O.logError(n), O.notifyCallbacks(n), n;
|
|
169
169
|
}
|
|
170
170
|
/**
|
|
171
171
|
* 处理平台不支持错误
|
|
@@ -174,12 +174,12 @@ const _ = class _ {
|
|
|
174
174
|
* @returns {QshError} 错误对象
|
|
175
175
|
*/
|
|
176
176
|
static handlePlatformNotSupported(e, r) {
|
|
177
|
-
const n = new
|
|
177
|
+
const n = new N(
|
|
178
178
|
b.PLATFORM_NOT_SUPPORTED,
|
|
179
179
|
`API "${r}" is not supported on platform "${e}"`,
|
|
180
180
|
{ platformType: e, apiName: r }
|
|
181
181
|
);
|
|
182
|
-
return
|
|
182
|
+
return O.logError(n), O.notifyCallbacks(n), n;
|
|
183
183
|
}
|
|
184
184
|
/**
|
|
185
185
|
* 处理桥接未就绪错误
|
|
@@ -187,12 +187,12 @@ const _ = class _ {
|
|
|
187
187
|
* @returns {QshError} 错误对象
|
|
188
188
|
*/
|
|
189
189
|
static handleBridgeNotReady(e) {
|
|
190
|
-
const r = new
|
|
190
|
+
const r = new N(
|
|
191
191
|
b.BRIDGE_NOT_READY,
|
|
192
192
|
`Bridge is not ready when calling "${e}"`,
|
|
193
193
|
{ apiName: e }
|
|
194
194
|
);
|
|
195
|
-
return
|
|
195
|
+
return O.logError(r), O.notifyCallbacks(r), r;
|
|
196
196
|
}
|
|
197
197
|
/**
|
|
198
198
|
* 处理参数验证错误
|
|
@@ -203,12 +203,12 @@ const _ = class _ {
|
|
|
203
203
|
* @returns {QshError} 错误对象
|
|
204
204
|
*/
|
|
205
205
|
static handleInvalidParameters(e, r, n, i) {
|
|
206
|
-
const s = new
|
|
206
|
+
const s = new N(
|
|
207
207
|
b.INVALID_PARAMETERS,
|
|
208
208
|
`Invalid parameter "${r}" in "${e}": expected ${n}, got ${typeof i}`,
|
|
209
209
|
{ apiName: e, paramName: r, expectedType: n, actualValue: i }
|
|
210
210
|
);
|
|
211
|
-
return
|
|
211
|
+
return O.logError(s), O.notifyCallbacks(s), s;
|
|
212
212
|
}
|
|
213
213
|
/**
|
|
214
214
|
* 安全地包装函数执行,捕获并处理错误
|
|
@@ -220,7 +220,7 @@ const _ = class _ {
|
|
|
220
220
|
try {
|
|
221
221
|
return e();
|
|
222
222
|
} catch (n) {
|
|
223
|
-
return
|
|
223
|
+
return O.handleApiError(n, r);
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
/**
|
|
@@ -234,7 +234,7 @@ const _ = class _ {
|
|
|
234
234
|
try {
|
|
235
235
|
return yield e();
|
|
236
236
|
} catch (i) {
|
|
237
|
-
return
|
|
237
|
+
return O.handleApiError(i, r);
|
|
238
238
|
}
|
|
239
239
|
});
|
|
240
240
|
}
|
|
@@ -246,7 +246,7 @@ const _ = class _ {
|
|
|
246
246
|
static logError(e) {
|
|
247
247
|
if (typeof console != "undefined") {
|
|
248
248
|
const r = `[QSH-SDK Error] ${e.type}: ${e.message}`;
|
|
249
|
-
|
|
249
|
+
O.isDebugMode ? console.error(r, {
|
|
250
250
|
context: e.context,
|
|
251
251
|
originalError: e.originalError,
|
|
252
252
|
stack: e.stack,
|
|
@@ -260,7 +260,7 @@ const _ = class _ {
|
|
|
260
260
|
* @private
|
|
261
261
|
*/
|
|
262
262
|
static notifyCallbacks(e) {
|
|
263
|
-
|
|
263
|
+
O.errorCallbacks.forEach((r) => {
|
|
264
264
|
try {
|
|
265
265
|
r(e);
|
|
266
266
|
} catch (n) {
|
|
@@ -277,20 +277,20 @@ const _ = class _ {
|
|
|
277
277
|
return function(r, n, i) {
|
|
278
278
|
const s = i.value;
|
|
279
279
|
return i.value = function(...c) {
|
|
280
|
-
return
|
|
280
|
+
return O.safeExecute(() => s.apply(this, c), p(g({}, e), { method: n, target: r.constructor.name }));
|
|
281
281
|
}, i;
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
284
|
};
|
|
285
|
-
U(
|
|
286
|
-
let u =
|
|
285
|
+
U(O, "isDebugMode", !1), U(O, "errorCallbacks", []);
|
|
286
|
+
let u = O;
|
|
287
287
|
const L = {
|
|
288
288
|
UNINITIALIZED: "uninitialized",
|
|
289
289
|
INITIALIZING: "initializing",
|
|
290
290
|
READY: "ready",
|
|
291
291
|
ERROR: "error"
|
|
292
292
|
};
|
|
293
|
-
class
|
|
293
|
+
class qt {
|
|
294
294
|
constructor() {
|
|
295
295
|
this.state = L.UNINITIALIZED, this.readyPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.initializationError = null, this.handleBridgeReady = this.handleBridgeReady.bind(this), this.handleInitializationError = this.handleInitializationError.bind(this);
|
|
296
296
|
}
|
|
@@ -423,52 +423,52 @@ class Kt {
|
|
|
423
423
|
};
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
|
-
const V = new
|
|
426
|
+
const V = new qt(), Xe = () => V.waitForReady(), Jt = () => V.isReady(), jt = () => V.getState(), _ = {
|
|
427
427
|
ERROR: 0,
|
|
428
428
|
WARN: 1,
|
|
429
429
|
INFO: 2,
|
|
430
430
|
DEBUG: 3,
|
|
431
431
|
TRACE: 4
|
|
432
|
-
},
|
|
433
|
-
[
|
|
434
|
-
[
|
|
435
|
-
[
|
|
436
|
-
[
|
|
437
|
-
[
|
|
438
|
-
},
|
|
432
|
+
}, oe = {
|
|
433
|
+
[_.ERROR]: "ERROR",
|
|
434
|
+
[_.WARN]: "WARN",
|
|
435
|
+
[_.INFO]: "INFO",
|
|
436
|
+
[_.DEBUG]: "DEBUG",
|
|
437
|
+
[_.TRACE]: "TRACE"
|
|
438
|
+
}, d = class d {
|
|
439
439
|
// 可注入的外部 reporter
|
|
440
440
|
/**
|
|
441
441
|
* 设置日志级别
|
|
442
442
|
* @param {number} level - 日志级别
|
|
443
443
|
*/
|
|
444
444
|
static setLevel(e) {
|
|
445
|
-
e >=
|
|
445
|
+
e >= _.ERROR && e <= _.TRACE && (d.currentLevel = e, d.log(_.INFO, "Logger", `日志级别设置为: ${oe[e]}`));
|
|
446
446
|
}
|
|
447
447
|
/**
|
|
448
448
|
* 启用开发模式(显示所有日志)
|
|
449
449
|
*/
|
|
450
450
|
static enableDevMode() {
|
|
451
|
-
|
|
451
|
+
d.setLevel(_.DEBUG), d.log(_.INFO, "Logger", "开发模式已启用");
|
|
452
452
|
}
|
|
453
453
|
/**
|
|
454
454
|
* 启用生产模式(只显示错误和警告)
|
|
455
455
|
*/
|
|
456
456
|
static enableProdMode() {
|
|
457
|
-
|
|
457
|
+
d.setLevel(_.WARN), d.log(_.INFO, "Logger", "生产模式已启用");
|
|
458
458
|
}
|
|
459
459
|
/**
|
|
460
460
|
* 启用特定模块的日志
|
|
461
461
|
* @param {string} module - 模块名称
|
|
462
462
|
*/
|
|
463
463
|
static enableModule(e) {
|
|
464
|
-
|
|
464
|
+
d.enabledModules.add(e), d.log(_.INFO, "Logger", `模块日志已启用: ${e}`);
|
|
465
465
|
}
|
|
466
466
|
/**
|
|
467
467
|
* 禁用特定模块的日志
|
|
468
468
|
* @param {string} module - 模块名称
|
|
469
469
|
*/
|
|
470
470
|
static disableModule(e) {
|
|
471
|
-
|
|
471
|
+
d.enabledModules.delete(e), d.log(_.INFO, "Logger", `模块日志已禁用: ${e}`);
|
|
472
472
|
}
|
|
473
473
|
/**
|
|
474
474
|
* 检查是否应该记录日志
|
|
@@ -478,7 +478,7 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
478
478
|
* @private
|
|
479
479
|
*/
|
|
480
480
|
static shouldLog(e, r) {
|
|
481
|
-
return e >
|
|
481
|
+
return e > d.currentLevel ? !1 : r && d.enabledModules.size > 0 ? d.enabledModules.has(r) : !0;
|
|
482
482
|
}
|
|
483
483
|
/**
|
|
484
484
|
* 核心日志记录方法
|
|
@@ -489,9 +489,9 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
489
489
|
* @private
|
|
490
490
|
*/
|
|
491
491
|
static log(e, r, n, ...i) {
|
|
492
|
-
if (!
|
|
492
|
+
if (!d.shouldLog(e, r))
|
|
493
493
|
return;
|
|
494
|
-
const s = (/* @__PURE__ */ new Date()).toISOString(), c =
|
|
494
|
+
const s = (/* @__PURE__ */ new Date()).toISOString(), c = oe[e], h = r ? `[${r}]` : "", f = `${d.prefix} ${h} ${n}`, A = {
|
|
495
495
|
timestamp: s,
|
|
496
496
|
level: e,
|
|
497
497
|
levelName: c,
|
|
@@ -499,12 +499,12 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
499
499
|
message: n,
|
|
500
500
|
args: i
|
|
501
501
|
};
|
|
502
|
-
if (
|
|
502
|
+
if (d.addToHistory(A), typeof d.reporter == "function")
|
|
503
503
|
try {
|
|
504
|
-
|
|
505
|
-
} catch (
|
|
504
|
+
d.reporter(A);
|
|
505
|
+
} catch (M) {
|
|
506
506
|
}
|
|
507
|
-
|
|
507
|
+
d.outputToConsole(e, f, ...i);
|
|
508
508
|
}
|
|
509
509
|
/**
|
|
510
510
|
* 添加日志到历史记录
|
|
@@ -512,7 +512,7 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
512
512
|
* @private
|
|
513
513
|
*/
|
|
514
514
|
static addToHistory(e) {
|
|
515
|
-
|
|
515
|
+
d.logHistory.push(e), d.logHistory.length > d.maxHistorySize && d.logHistory.shift();
|
|
516
516
|
}
|
|
517
517
|
/**
|
|
518
518
|
* 输出到控制台
|
|
@@ -526,17 +526,17 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
526
526
|
return;
|
|
527
527
|
const i = n && n.length > 0;
|
|
528
528
|
switch (e) {
|
|
529
|
-
case
|
|
529
|
+
case _.ERROR:
|
|
530
530
|
i ? console.error(r, ...n) : console.error(r);
|
|
531
531
|
break;
|
|
532
|
-
case
|
|
532
|
+
case _.WARN:
|
|
533
533
|
i ? console.warn(r, ...n) : console.warn(r);
|
|
534
534
|
break;
|
|
535
|
-
case
|
|
535
|
+
case _.INFO:
|
|
536
536
|
i ? console.info(r, ...n) : console.info(r);
|
|
537
537
|
break;
|
|
538
|
-
case
|
|
539
|
-
case
|
|
538
|
+
case _.DEBUG:
|
|
539
|
+
case _.TRACE:
|
|
540
540
|
i ? console.log(r, ...n) : console.log(r);
|
|
541
541
|
break;
|
|
542
542
|
}
|
|
@@ -548,7 +548,7 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
548
548
|
* @param {any[]} args - 额外参数
|
|
549
549
|
*/
|
|
550
550
|
static error(e, r, ...n) {
|
|
551
|
-
|
|
551
|
+
d.log(_.ERROR, e, r, ...n);
|
|
552
552
|
}
|
|
553
553
|
/**
|
|
554
554
|
* 警告级别日志
|
|
@@ -557,7 +557,7 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
557
557
|
* @param {any[]} args - 额外参数
|
|
558
558
|
*/
|
|
559
559
|
static warn(e, r, ...n) {
|
|
560
|
-
|
|
560
|
+
d.log(_.WARN, e, r, ...n);
|
|
561
561
|
}
|
|
562
562
|
/**
|
|
563
563
|
* 信息级别日志
|
|
@@ -566,7 +566,7 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
566
566
|
* @param {any[]} args - 额外参数
|
|
567
567
|
*/
|
|
568
568
|
static info(e, r, ...n) {
|
|
569
|
-
|
|
569
|
+
d.log(_.INFO, e, r, ...n);
|
|
570
570
|
}
|
|
571
571
|
/**
|
|
572
572
|
* 调试级别日志
|
|
@@ -575,7 +575,7 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
575
575
|
* @param {any[]} args - 额外参数
|
|
576
576
|
*/
|
|
577
577
|
static debug(e, r, ...n) {
|
|
578
|
-
|
|
578
|
+
d.log(_.DEBUG, e, r, ...n);
|
|
579
579
|
}
|
|
580
580
|
/**
|
|
581
581
|
* 跟踪级别日志
|
|
@@ -584,7 +584,7 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
584
584
|
* @param {any[]} args - 额外参数
|
|
585
585
|
*/
|
|
586
586
|
static trace(e, r, ...n) {
|
|
587
|
-
|
|
587
|
+
d.log(_.TRACE, e, r, ...n);
|
|
588
588
|
}
|
|
589
589
|
/**
|
|
590
590
|
* 获取日志历史
|
|
@@ -592,13 +592,13 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
592
592
|
* @returns {Array} 日志条目数组
|
|
593
593
|
*/
|
|
594
594
|
static getHistory(e) {
|
|
595
|
-
return e && e > 0 ?
|
|
595
|
+
return e && e > 0 ? d.logHistory.slice(-e) : [...d.logHistory];
|
|
596
596
|
}
|
|
597
597
|
/**
|
|
598
598
|
* 清空日志历史
|
|
599
599
|
*/
|
|
600
600
|
static clearHistory() {
|
|
601
|
-
|
|
601
|
+
d.logHistory = [], d.log(_.INFO, "Logger", "日志历史已清空");
|
|
602
602
|
}
|
|
603
603
|
/**
|
|
604
604
|
* 获取日志统计信息
|
|
@@ -606,15 +606,15 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
606
606
|
*/
|
|
607
607
|
static getStats() {
|
|
608
608
|
const e = {
|
|
609
|
-
currentLevel:
|
|
610
|
-
currentLevelName:
|
|
611
|
-
enabledModules: Array.from(
|
|
612
|
-
historySize:
|
|
613
|
-
maxHistorySize:
|
|
609
|
+
currentLevel: d.currentLevel,
|
|
610
|
+
currentLevelName: oe[d.currentLevel],
|
|
611
|
+
enabledModules: Array.from(d.enabledModules),
|
|
612
|
+
historySize: d.logHistory.length,
|
|
613
|
+
maxHistorySize: d.maxHistorySize
|
|
614
614
|
}, r = {};
|
|
615
|
-
for (const n of Object.keys(
|
|
616
|
-
r[
|
|
617
|
-
return
|
|
615
|
+
for (const n of Object.keys(oe))
|
|
616
|
+
r[oe[n]] = 0;
|
|
617
|
+
return d.logHistory.forEach((n) => {
|
|
618
618
|
r[n.levelName]++;
|
|
619
619
|
}), e.levelCounts = r, e;
|
|
620
620
|
}
|
|
@@ -624,7 +624,7 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
624
624
|
* @returns {string} JSON 字符串
|
|
625
625
|
*/
|
|
626
626
|
static exportToJSON(e) {
|
|
627
|
-
const r =
|
|
627
|
+
const r = d.getHistory(e), n = d.getStats();
|
|
628
628
|
return JSON.stringify({
|
|
629
629
|
exportTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
630
630
|
stats: n,
|
|
@@ -638,11 +638,11 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
638
638
|
*/
|
|
639
639
|
static createModuleLogger(e) {
|
|
640
640
|
return {
|
|
641
|
-
error: (r, ...n) =>
|
|
642
|
-
warn: (r, ...n) =>
|
|
643
|
-
info: (r, ...n) =>
|
|
644
|
-
debug: (r, ...n) =>
|
|
645
|
-
trace: (r, ...n) =>
|
|
641
|
+
error: (r, ...n) => d.error(e, r, ...n),
|
|
642
|
+
warn: (r, ...n) => d.warn(e, r, ...n),
|
|
643
|
+
info: (r, ...n) => d.info(e, r, ...n),
|
|
644
|
+
debug: (r, ...n) => d.debug(e, r, ...n),
|
|
645
|
+
trace: (r, ...n) => d.trace(e, r, ...n)
|
|
646
646
|
};
|
|
647
647
|
}
|
|
648
648
|
/**
|
|
@@ -650,14 +650,14 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
650
650
|
* @param {(entry: any) => void|null} reporter
|
|
651
651
|
*/
|
|
652
652
|
static setReporter(e) {
|
|
653
|
-
|
|
653
|
+
d.reporter = typeof e == "function" ? e : null;
|
|
654
654
|
}
|
|
655
655
|
};
|
|
656
|
-
U(
|
|
657
|
-
U(
|
|
658
|
-
U(
|
|
659
|
-
U(
|
|
660
|
-
let T =
|
|
656
|
+
U(d, "currentLevel", _.ERROR), // 生产环境默认只显示错误
|
|
657
|
+
U(d, "enabledModules", /* @__PURE__ */ new Set()), // 启用日志的模块
|
|
658
|
+
U(d, "logHistory", []), // 日志历史(最多保留1000条)
|
|
659
|
+
U(d, "maxHistorySize", 1e3), U(d, "prefix", "[QSH-SDK]"), U(d, "reporter", null);
|
|
660
|
+
let T = d;
|
|
661
661
|
if (typeof window != "undefined") {
|
|
662
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"));
|
|
663
663
|
let r = !1;
|
|
@@ -667,14 +667,14 @@ if (typeof window != "undefined") {
|
|
|
667
667
|
}
|
|
668
668
|
(t || e || r) && T.enableDevMode();
|
|
669
669
|
}
|
|
670
|
-
const y = T.createModuleLogger("Bridge"), E = T.createModuleLogger("Platform"), a = T.createModuleLogger("API"), v = T.createModuleLogger("State"),
|
|
671
|
-
function
|
|
670
|
+
const y = T.createModuleLogger("Bridge"), E = T.createModuleLogger("Platform"), a = T.createModuleLogger("API"), v = T.createModuleLogger("State"), Ee = /complete|loaded|interactive/;
|
|
671
|
+
function Ht(t) {
|
|
672
672
|
if (!J()) return !1;
|
|
673
673
|
y.debug("检测到离线包环境,开始初始化");
|
|
674
674
|
const e = () => {
|
|
675
675
|
t();
|
|
676
676
|
};
|
|
677
|
-
if (
|
|
677
|
+
if (Ee.test(document.readyState))
|
|
678
678
|
y.debug("离线包环境 DOM 已就绪,立即初始化"), setTimeout(e, 0);
|
|
679
679
|
else {
|
|
680
680
|
y.debug("离线包环境,等待 DOMContentLoaded");
|
|
@@ -686,19 +686,19 @@ function Vt(t) {
|
|
|
686
686
|
}
|
|
687
687
|
return !0;
|
|
688
688
|
}
|
|
689
|
-
function
|
|
690
|
-
return
|
|
689
|
+
function Yt(t) {
|
|
690
|
+
return Pe() || be() ? (y.debug("检测到 APP 环境,开始初始化"), window.__uniapp_x_postMessage || window.__uniapp_x_ || window.__dcloud_weex_postMessage || window.__dcloud_weex_ ? (y.debug("NVUE/UVUE 环境,等待 DOMContentLoaded"), document.addEventListener("DOMContentLoaded", t)) : window.plus && Ee.test(document.readyState) ? (y.debug("Plus 环境已就绪,立即初始化"), setTimeout(t, 0)) : window.plus ? (y.debug("Plus 环境,等待 plusready 事件"), document.addEventListener("plusready", t)) : Ee.test(document.readyState) ? setTimeout(t, 0) : document.addEventListener("DOMContentLoaded", t, { once: !0 }), !0) : !1;
|
|
691
691
|
}
|
|
692
|
-
function
|
|
692
|
+
function Zt(t) {
|
|
693
693
|
return window.wx && window.wx.miniProgram ? (y.debug("检测到微信小程序环境,开始初始化"), window.WeixinJSBridge && window.WeixinJSBridge.invoke ? (y.debug("微信 JSBridge 已就绪,立即初始化"), setTimeout(t, 0)) : (y.debug("微信 JSBridge 未就绪,等待 WeixinJSBridgeReady 事件"), document.addEventListener("WeixinJSBridgeReady", t)), !0) : !1;
|
|
694
694
|
}
|
|
695
|
-
function
|
|
696
|
-
return y.info("开始初始化 JSBridge"),
|
|
695
|
+
function Xt(t) {
|
|
696
|
+
return y.info("开始初始化 JSBridge"), Ht(t) ? (y.info("使用离线包环境初始化"), !0) : Yt(t) ? (y.info("使用 APP 环境初始化"), !0) : Zt(t) ? (y.info("使用微信小程序环境初始化"), !0) : (y.debug("使用默认 H5 环境初始化"), Ee.test(document.readyState) ? (y.debug("DOM 已就绪,立即初始化"), setTimeout(t, 0)) : (y.debug("DOM 未就绪,等待 DOMContentLoaded"), document.addEventListener("DOMContentLoaded", t)), !0);
|
|
697
697
|
}
|
|
698
|
-
function
|
|
698
|
+
function Qt() {
|
|
699
699
|
return V.waitForReady();
|
|
700
700
|
}
|
|
701
|
-
function
|
|
701
|
+
function Qe() {
|
|
702
702
|
return V.startInitialization(() => w(null, null, function* () {
|
|
703
703
|
return new Promise((t, e) => {
|
|
704
704
|
const r = () => {
|
|
@@ -710,7 +710,7 @@ function He() {
|
|
|
710
710
|
e(s);
|
|
711
711
|
};
|
|
712
712
|
try {
|
|
713
|
-
|
|
713
|
+
Xt(() => {
|
|
714
714
|
r();
|
|
715
715
|
});
|
|
716
716
|
} catch (i) {
|
|
@@ -719,7 +719,7 @@ function He() {
|
|
|
719
719
|
});
|
|
720
720
|
}));
|
|
721
721
|
}
|
|
722
|
-
const
|
|
722
|
+
const R = {
|
|
723
723
|
UNINITIALIZED: "uninitialized",
|
|
724
724
|
CONFIGURING: "configuring",
|
|
725
725
|
CONFIGURED: "configured",
|
|
@@ -728,16 +728,16 @@ const N = {
|
|
|
728
728
|
function $() {
|
|
729
729
|
return typeof window == "undefined" || !window.wx ? !1 : typeof window.wx.config == "function" && typeof window.wx.ready == "function" && typeof window.wx.error == "function";
|
|
730
730
|
}
|
|
731
|
-
class
|
|
731
|
+
class er {
|
|
732
732
|
constructor() {
|
|
733
|
-
this.state =
|
|
733
|
+
this.state = R.UNINITIALIZED, this.configPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.lastError = null, this.runtimeConfig = {
|
|
734
734
|
clientId: null,
|
|
735
735
|
isProd: !1
|
|
736
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.handleConfigSuccess = this.handleConfigSuccess.bind(this), this.handleConfigError = this.handleConfigError.bind(this);
|
|
737
737
|
}
|
|
738
738
|
configure(e = {}) {
|
|
739
739
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
740
|
-
throw new
|
|
740
|
+
throw new N(
|
|
741
741
|
b.INVALID_PARAMETERS,
|
|
742
742
|
"config参数异常",
|
|
743
743
|
{ config: e }
|
|
@@ -745,29 +745,29 @@ class Yt {
|
|
|
745
745
|
if (!Object.prototype.hasOwnProperty.call(e, "clientId"))
|
|
746
746
|
throw this.createMissingClientIdError();
|
|
747
747
|
if (typeof e.clientId != "string" || !e.clientId.trim())
|
|
748
|
-
throw new
|
|
748
|
+
throw new N(
|
|
749
749
|
b.INVALID_PARAMETERS,
|
|
750
750
|
"clientId参数异常",
|
|
751
751
|
{ clientId: e.clientId }
|
|
752
752
|
);
|
|
753
753
|
if (Object.prototype.hasOwnProperty.call(e, "isProd") && typeof e.isProd != "boolean")
|
|
754
|
-
throw new
|
|
754
|
+
throw new N(
|
|
755
755
|
b.INVALID_PARAMETERS,
|
|
756
756
|
"isProd参数异常",
|
|
757
757
|
{ isProd: e.isProd }
|
|
758
758
|
);
|
|
759
759
|
const r = e.clientId.trim(), n = e.isProd === !0, i = r !== this.runtimeConfig.clientId || n !== this.runtimeConfig.isProd;
|
|
760
|
-
return this.runtimeConfig =
|
|
760
|
+
return this.runtimeConfig = p(g({}, this.runtimeConfig), {
|
|
761
761
|
clientId: r,
|
|
762
762
|
isProd: n
|
|
763
|
-
}), this.CONFIG_API_URL = this.getConfigApiUrl(n), (this.state ===
|
|
763
|
+
}), this.CONFIG_API_URL = this.getConfigApiUrl(n), (this.state === R.ERROR || i && (this.state === R.CONFIGURING || this.state === R.CONFIGURED)) && this.reset(), E.info("Updated Weixin runtime config", {
|
|
764
764
|
clientId: this.runtimeConfig.clientId,
|
|
765
765
|
isProd: this.runtimeConfig.isProd,
|
|
766
766
|
configApiUrl: this.CONFIG_API_URL
|
|
767
767
|
}), this.getRuntimeConfig();
|
|
768
768
|
}
|
|
769
769
|
getRuntimeConfig() {
|
|
770
|
-
return
|
|
770
|
+
return g({}, this.runtimeConfig);
|
|
771
771
|
}
|
|
772
772
|
hasClientId() {
|
|
773
773
|
return typeof this.runtimeConfig.clientId == "string" && this.runtimeConfig.clientId.length > 0;
|
|
@@ -776,7 +776,7 @@ class Yt {
|
|
|
776
776
|
return this.isTestMode() || this.hasClientId();
|
|
777
777
|
}
|
|
778
778
|
createMissingClientIdError() {
|
|
779
|
-
return new
|
|
779
|
+
return new N(
|
|
780
780
|
b.INVALID_PARAMETERS,
|
|
781
781
|
"clientId错误",
|
|
782
782
|
{ field: "clientId" }
|
|
@@ -831,7 +831,7 @@ class Yt {
|
|
|
831
831
|
} catch (i) {
|
|
832
832
|
if (E.error("获取微信配置失败", i), this.shouldUseTestMode(i))
|
|
833
833
|
return E.warn("网络请求失败,降级到测试模式"), this.getMockConfig();
|
|
834
|
-
throw new
|
|
834
|
+
throw new N(
|
|
835
835
|
b.NETWORK_ERROR,
|
|
836
836
|
`获取微信配置失败: ${i.message}`,
|
|
837
837
|
{ url: n, originalError: i }
|
|
@@ -907,7 +907,7 @@ class Yt {
|
|
|
907
907
|
* @private
|
|
908
908
|
*/
|
|
909
909
|
handleConfigSuccess() {
|
|
910
|
-
E.info("微信配置成功"), this.state =
|
|
910
|
+
E.info("微信配置成功"), this.state = R.CONFIGURED, this.lastError = null, this.configPromise = null;
|
|
911
911
|
const e = [...this.readyCallbacks];
|
|
912
912
|
this.readyCallbacks = [], this.errorCallbacks = [], e.forEach((r) => {
|
|
913
913
|
try {
|
|
@@ -925,12 +925,12 @@ class Yt {
|
|
|
925
925
|
handleConfigError(e) {
|
|
926
926
|
const r = `微信配置验证失败: ${JSON.stringify(e)}`;
|
|
927
927
|
E.error(r, e);
|
|
928
|
-
const n = new
|
|
928
|
+
const n = new N(
|
|
929
929
|
b.API_CALL_FAILED,
|
|
930
930
|
r,
|
|
931
931
|
{ weixinErrorResponse: e }
|
|
932
932
|
);
|
|
933
|
-
this.state =
|
|
933
|
+
this.state = R.ERROR, this.lastError = n, this.configPromise = null;
|
|
934
934
|
const i = [...this.errorCallbacks];
|
|
935
935
|
this.readyCallbacks = [], this.errorCallbacks = [], i.forEach((s) => {
|
|
936
936
|
try {
|
|
@@ -946,7 +946,7 @@ class Yt {
|
|
|
946
946
|
*/
|
|
947
947
|
autoConfig() {
|
|
948
948
|
return w(this, null, function* () {
|
|
949
|
-
return this.hasRequiredConfig() ? this.state ===
|
|
949
|
+
return this.hasRequiredConfig() ? this.state === R.CONFIGURED ? Promise.resolve() : this.state === R.ERROR ? Promise.reject(this.lastError) : this.configPromise ? this.configPromise : (this.state = R.CONFIGURING, this.configPromise = this.performAutoConfig(), this.configPromise) : (E.warn("clientId为空,等待qsh.config({ clientId })"), Promise.resolve());
|
|
950
950
|
});
|
|
951
951
|
}
|
|
952
952
|
/**
|
|
@@ -963,19 +963,19 @@ class Yt {
|
|
|
963
963
|
throw new Error("微信JS-SDK未加载,无法执行配置");
|
|
964
964
|
const e = yield this.fetchWeixinConfig();
|
|
965
965
|
return this.executeWeixinConfig(e), yield new Promise((r, n) => {
|
|
966
|
-
if (this.state ===
|
|
966
|
+
if (this.state === R.CONFIGURED) {
|
|
967
967
|
r();
|
|
968
968
|
return;
|
|
969
969
|
}
|
|
970
|
-
if (this.state ===
|
|
970
|
+
if (this.state === R.ERROR) {
|
|
971
971
|
n(this.lastError);
|
|
972
972
|
return;
|
|
973
973
|
}
|
|
974
974
|
this.readyCallbacks.push(r), this.errorCallbacks.push(n);
|
|
975
975
|
});
|
|
976
976
|
} catch (e) {
|
|
977
|
-
const r = e instanceof
|
|
978
|
-
this.state =
|
|
977
|
+
const r = e instanceof N ? e : u.handleApiError(e, { context: "WeixinConfigManager.performAutoConfig" });
|
|
978
|
+
this.state = R.ERROR, this.lastError = r, this.configPromise = null;
|
|
979
979
|
const n = [...this.errorCallbacks];
|
|
980
980
|
throw this.readyCallbacks = [], this.errorCallbacks = [], n.forEach((i) => {
|
|
981
981
|
try {
|
|
@@ -992,7 +992,7 @@ class Yt {
|
|
|
992
992
|
* @returns {Promise<void>} 配置完成的Promise
|
|
993
993
|
*/
|
|
994
994
|
waitForReady() {
|
|
995
|
-
return this.state ===
|
|
995
|
+
return this.state === R.CONFIGURED ? Promise.resolve() : this.state === R.ERROR ? Promise.reject(this.lastError) : this.hasRequiredConfig() ? this.state === R.UNINITIALIZED ? this.autoConfig() : new Promise((e, r) => {
|
|
996
996
|
this.readyCallbacks.push(e), this.errorCallbacks.push(r);
|
|
997
997
|
}) : Promise.reject(this.createMissingClientIdError());
|
|
998
998
|
}
|
|
@@ -1001,7 +1001,7 @@ class Yt {
|
|
|
1001
1001
|
* @returns {boolean} 是否已配置
|
|
1002
1002
|
*/
|
|
1003
1003
|
isReady() {
|
|
1004
|
-
return this.state ===
|
|
1004
|
+
return this.state === R.CONFIGURED;
|
|
1005
1005
|
}
|
|
1006
1006
|
/**
|
|
1007
1007
|
* 获取当前状态
|
|
@@ -1021,7 +1021,7 @@ class Yt {
|
|
|
1021
1021
|
* 重置配置管理器(用于重试或测试)
|
|
1022
1022
|
*/
|
|
1023
1023
|
reset() {
|
|
1024
|
-
this.state =
|
|
1024
|
+
this.state = R.UNINITIALIZED, this.configPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.lastError = null, E.debug("微信配置管理器已重置");
|
|
1025
1025
|
}
|
|
1026
1026
|
/**
|
|
1027
1027
|
* 获取配置统计信息
|
|
@@ -1041,18 +1041,18 @@ class Yt {
|
|
|
1041
1041
|
};
|
|
1042
1042
|
}
|
|
1043
1043
|
}
|
|
1044
|
-
const S = new
|
|
1045
|
-
let X = !1,
|
|
1046
|
-
function
|
|
1044
|
+
const S = new er();
|
|
1045
|
+
let X = !1, le = !1, x = null, ye = !1;
|
|
1046
|
+
function tr(t) {
|
|
1047
1047
|
return new Promise((e) => {
|
|
1048
1048
|
let r = !1, n = null;
|
|
1049
|
-
const i = (
|
|
1049
|
+
const i = (h) => w(null, null, function* () {
|
|
1050
1050
|
if (!r) {
|
|
1051
|
-
if (r = !0, n && clearTimeout(n), X = !1,
|
|
1051
|
+
if (r = !0, n && clearTimeout(n), X = !1, le = h, h)
|
|
1052
1052
|
try {
|
|
1053
|
-
yield
|
|
1054
|
-
} catch (
|
|
1055
|
-
E.error("微信配置失败,将使用消息桥作为后备",
|
|
1053
|
+
yield et();
|
|
1054
|
+
} catch (f) {
|
|
1055
|
+
E.error("微信配置失败,将使用消息桥作为后备", f);
|
|
1056
1056
|
}
|
|
1057
1057
|
e();
|
|
1058
1058
|
}
|
|
@@ -1066,31 +1066,31 @@ function Zt(t) {
|
|
|
1066
1066
|
}, 3e3);
|
|
1067
1067
|
});
|
|
1068
1068
|
}
|
|
1069
|
-
function
|
|
1069
|
+
function ve() {
|
|
1070
1070
|
return w(this, arguments, function* (t = {}) {
|
|
1071
1071
|
const { force: e = !1, recoverFromError: r = !1 } = t;
|
|
1072
|
-
if (yield
|
|
1072
|
+
if (yield tt({ force: e }), !$())
|
|
1073
1073
|
throw new Error("微信 JS-SDK 未正确加载,无法执行配置");
|
|
1074
|
-
r &&
|
|
1074
|
+
r && nr();
|
|
1075
1075
|
});
|
|
1076
1076
|
}
|
|
1077
|
-
function
|
|
1077
|
+
function rr(t = !1) {
|
|
1078
1078
|
if (typeof window == "undefined") return !1;
|
|
1079
1079
|
if ($())
|
|
1080
|
-
return
|
|
1081
|
-
if (
|
|
1080
|
+
return le = !0, !1;
|
|
1081
|
+
if (le || J()) return !1;
|
|
1082
1082
|
if (t) return !0;
|
|
1083
1083
|
const e = navigator.userAgent || "", r = /micromessenger/i.test(e), n = /miniProgram/i.test(e), i = typeof window.__wxjs_environment != "undefined" && window.__wxjs_environment === "miniprogram", s = !!(window.wx && window.wx.miniProgram);
|
|
1084
1084
|
return r && (n || i || s);
|
|
1085
1085
|
}
|
|
1086
|
-
function
|
|
1087
|
-
S.getState() === "error" && (S.reset(),
|
|
1086
|
+
function nr() {
|
|
1087
|
+
S.getState() === "error" && (S.reset(), ye = !1);
|
|
1088
1088
|
}
|
|
1089
|
-
function
|
|
1089
|
+
function et() {
|
|
1090
1090
|
return w(this, null, function* () {
|
|
1091
|
-
if (
|
|
1091
|
+
if (ye)
|
|
1092
1092
|
return S.waitForReady();
|
|
1093
|
-
|
|
1093
|
+
ye = !0, E.info("开始自动配置微信JS-SDK");
|
|
1094
1094
|
try {
|
|
1095
1095
|
yield S.autoConfig(), E.info("微信JS-SDK自动配置完成");
|
|
1096
1096
|
} catch (t) {
|
|
@@ -1098,24 +1098,24 @@ function Ye() {
|
|
|
1098
1098
|
}
|
|
1099
1099
|
});
|
|
1100
1100
|
}
|
|
1101
|
-
function
|
|
1101
|
+
function tt(t = {}) {
|
|
1102
1102
|
const { force: e = !1 } = t;
|
|
1103
1103
|
if (typeof window == "undefined")
|
|
1104
1104
|
return Promise.resolve();
|
|
1105
1105
|
if ($())
|
|
1106
|
-
return
|
|
1106
|
+
return le = !0, Promise.resolve();
|
|
1107
1107
|
const r = document.getElementById("weixin-jssdk");
|
|
1108
|
-
return r ? x || (X = !0, x =
|
|
1108
|
+
return r ? x || (X = !0, x = tr(r).finally(() => {
|
|
1109
1109
|
x = null;
|
|
1110
|
-
}), x) :
|
|
1110
|
+
}), x) : rr(e) ? x || (x = new Promise((n) => {
|
|
1111
1111
|
X = !0;
|
|
1112
1112
|
try {
|
|
1113
1113
|
const i = document.createElement("script");
|
|
1114
1114
|
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() {
|
|
1115
1115
|
return w(this, null, function* () {
|
|
1116
|
-
|
|
1116
|
+
le = !0, X = !1, E.info("微信 JS-SDK 已自动加载");
|
|
1117
1117
|
try {
|
|
1118
|
-
yield
|
|
1118
|
+
yield et();
|
|
1119
1119
|
} catch (c) {
|
|
1120
1120
|
E.error("微信配置失败,将使用消息桥作为后备", c);
|
|
1121
1121
|
}
|
|
@@ -1131,12 +1131,12 @@ function Ze(t = {}) {
|
|
|
1131
1131
|
x = null;
|
|
1132
1132
|
}), x) : Promise.resolve();
|
|
1133
1133
|
}
|
|
1134
|
-
function
|
|
1135
|
-
return
|
|
1134
|
+
function K() {
|
|
1135
|
+
return ve({ force: !0, recoverFromError: !0 }).then(() => S.waitForReady());
|
|
1136
1136
|
}
|
|
1137
|
-
function
|
|
1137
|
+
function ze(t = {}) {
|
|
1138
1138
|
const e = S.configure(t);
|
|
1139
|
-
return typeof window == "undefined" ||
|
|
1139
|
+
return typeof window == "undefined" || ve({
|
|
1140
1140
|
force: !0,
|
|
1141
1141
|
recoverFromError: S.getState() === "error"
|
|
1142
1142
|
}).then(() => {
|
|
@@ -1152,18 +1152,18 @@ function Be(t = {}) {
|
|
|
1152
1152
|
function j() {
|
|
1153
1153
|
return S.isReady();
|
|
1154
1154
|
}
|
|
1155
|
-
function
|
|
1155
|
+
function ir() {
|
|
1156
1156
|
return S.getState();
|
|
1157
1157
|
}
|
|
1158
|
-
function
|
|
1158
|
+
function Me() {
|
|
1159
1159
|
return S;
|
|
1160
1160
|
}
|
|
1161
|
-
function
|
|
1161
|
+
function ar() {
|
|
1162
1162
|
return w(this, null, function* () {
|
|
1163
|
-
return E.info("手动重试微信配置"), S.reset(),
|
|
1163
|
+
return E.info("手动重试微信配置"), S.reset(), ye = !1, yield ve({ force: !0 }), S.waitForReady();
|
|
1164
1164
|
});
|
|
1165
1165
|
}
|
|
1166
|
-
class
|
|
1166
|
+
class sr {
|
|
1167
1167
|
constructor() {
|
|
1168
1168
|
this.plugins = /* @__PURE__ */ new Map(), this.installed = /* @__PURE__ */ new Set(), this.installOrder = [], a.debug("插件管理器已初始化");
|
|
1169
1169
|
}
|
|
@@ -1356,8 +1356,8 @@ class rr {
|
|
|
1356
1356
|
this.plugins.clear(), this.installed.clear(), this.installOrder = [];
|
|
1357
1357
|
}
|
|
1358
1358
|
}
|
|
1359
|
-
const
|
|
1360
|
-
class
|
|
1359
|
+
const ce = new sr();
|
|
1360
|
+
class or {
|
|
1361
1361
|
constructor() {
|
|
1362
1362
|
this.requestInterceptors = [], this.responseInterceptors = [], a.debug("拦截器链已初始化");
|
|
1363
1363
|
}
|
|
@@ -1417,7 +1417,7 @@ class nr {
|
|
|
1417
1417
|
*/
|
|
1418
1418
|
runRequest(e) {
|
|
1419
1419
|
return w(this, null, function* () {
|
|
1420
|
-
let r =
|
|
1420
|
+
let r = g({}, e);
|
|
1421
1421
|
for (const { fn: n } of this.requestInterceptors) {
|
|
1422
1422
|
if (r.abort) {
|
|
1423
1423
|
a.debug("请求被中止", { apiName: r.apiName });
|
|
@@ -1471,7 +1471,7 @@ class nr {
|
|
|
1471
1471
|
};
|
|
1472
1472
|
}
|
|
1473
1473
|
}
|
|
1474
|
-
const z = new
|
|
1474
|
+
const z = new or(), cr = {
|
|
1475
1475
|
/**
|
|
1476
1476
|
* 请求日志
|
|
1477
1477
|
*/
|
|
@@ -1516,7 +1516,7 @@ const z = new nr(), ir = {
|
|
|
1516
1516
|
getReport: () => {
|
|
1517
1517
|
const t = {};
|
|
1518
1518
|
return B.metrics.forEach((e, r) => {
|
|
1519
|
-
t[r] =
|
|
1519
|
+
t[r] = g({}, e);
|
|
1520
1520
|
}), t;
|
|
1521
1521
|
},
|
|
1522
1522
|
/**
|
|
@@ -1526,7 +1526,7 @@ const z = new nr(), ir = {
|
|
|
1526
1526
|
B.metrics.clear();
|
|
1527
1527
|
}
|
|
1528
1528
|
};
|
|
1529
|
-
function
|
|
1529
|
+
function ur(t = {}) {
|
|
1530
1530
|
const {
|
|
1531
1531
|
maxRetries: e = 3,
|
|
1532
1532
|
retryDelay: r = 1e3,
|
|
@@ -1538,7 +1538,7 @@ function ar(t = {}) {
|
|
|
1538
1538
|
})
|
|
1539
1539
|
};
|
|
1540
1540
|
}
|
|
1541
|
-
function
|
|
1541
|
+
function lr(t = {}) {
|
|
1542
1542
|
return {
|
|
1543
1543
|
request: (e) => {
|
|
1544
1544
|
const r = t[e.apiName];
|
|
@@ -1550,7 +1550,7 @@ function sr(t = {}) {
|
|
|
1550
1550
|
}
|
|
1551
1551
|
};
|
|
1552
1552
|
}
|
|
1553
|
-
class
|
|
1553
|
+
class fr {
|
|
1554
1554
|
constructor() {
|
|
1555
1555
|
this.state = {
|
|
1556
1556
|
// SDK 状态
|
|
@@ -1617,7 +1617,7 @@ class or {
|
|
|
1617
1617
|
* store.set('network.online', false)
|
|
1618
1618
|
*/
|
|
1619
1619
|
set(e, r) {
|
|
1620
|
-
const n = e.split("."), i = n.pop(), s = n.reduce((
|
|
1620
|
+
const n = e.split("."), i = n.pop(), s = n.reduce((h, f) => ((!h[f] || typeof h[f] != "object") && (h[f] = {}), h[f]), this.state), c = s[i];
|
|
1621
1621
|
c !== r && (s[i] = r, v.debug(`状态已更新: ${e}`, { oldValue: c, newValue: r }), this.notify(e, r, c));
|
|
1622
1622
|
}
|
|
1623
1623
|
/**
|
|
@@ -1680,20 +1680,20 @@ class or {
|
|
|
1680
1680
|
i && i.forEach((c) => {
|
|
1681
1681
|
try {
|
|
1682
1682
|
c(r, n, e);
|
|
1683
|
-
} catch (
|
|
1684
|
-
v.error("订阅者执行失败",
|
|
1683
|
+
} catch (h) {
|
|
1684
|
+
v.error("订阅者执行失败", h);
|
|
1685
1685
|
}
|
|
1686
1686
|
});
|
|
1687
1687
|
const s = e.split(".");
|
|
1688
1688
|
for (let c = 1; c < s.length; c++) {
|
|
1689
|
-
const
|
|
1690
|
-
if (
|
|
1691
|
-
const
|
|
1692
|
-
|
|
1689
|
+
const h = s.slice(0, c).join("."), f = this.listeners.get(h);
|
|
1690
|
+
if (f) {
|
|
1691
|
+
const A = this.get(h);
|
|
1692
|
+
f.forEach((M) => {
|
|
1693
1693
|
try {
|
|
1694
|
-
|
|
1695
|
-
} catch (
|
|
1696
|
-
v.error("父路径订阅者执行失败",
|
|
1694
|
+
M(A, void 0, h);
|
|
1695
|
+
} catch (m) {
|
|
1696
|
+
v.error("父路径订阅者执行失败", m);
|
|
1697
1697
|
}
|
|
1698
1698
|
});
|
|
1699
1699
|
}
|
|
@@ -1701,8 +1701,8 @@ class or {
|
|
|
1701
1701
|
this.wildcardListeners.forEach((c) => {
|
|
1702
1702
|
try {
|
|
1703
1703
|
c(r, n, e);
|
|
1704
|
-
} catch (
|
|
1705
|
-
v.error("通配符订阅者执行失败",
|
|
1704
|
+
} catch (h) {
|
|
1705
|
+
v.error("通配符订阅者执行失败", h);
|
|
1706
1706
|
}
|
|
1707
1707
|
});
|
|
1708
1708
|
}
|
|
@@ -1728,7 +1728,7 @@ class or {
|
|
|
1728
1728
|
*/
|
|
1729
1729
|
setApiLoading(e, r = !0) {
|
|
1730
1730
|
const n = `api.${e}`, i = this.get(n) || {};
|
|
1731
|
-
this.set(n,
|
|
1731
|
+
this.set(n, p(g({}, i), {
|
|
1732
1732
|
loading: r,
|
|
1733
1733
|
lastCall: r ? Date.now() : i.lastCall
|
|
1734
1734
|
}));
|
|
@@ -1740,7 +1740,7 @@ class or {
|
|
|
1740
1740
|
*/
|
|
1741
1741
|
setApiResult(e, r) {
|
|
1742
1742
|
const n = `api.${e}`, i = this.get(n) || {};
|
|
1743
|
-
this.set(n,
|
|
1743
|
+
this.set(n, p(g({}, i), {
|
|
1744
1744
|
loading: !1,
|
|
1745
1745
|
lastResult: r,
|
|
1746
1746
|
lastCallEnd: Date.now()
|
|
@@ -1795,7 +1795,7 @@ class or {
|
|
|
1795
1795
|
};
|
|
1796
1796
|
}
|
|
1797
1797
|
}
|
|
1798
|
-
const W = new
|
|
1798
|
+
const W = new fr(), o = {
|
|
1799
1799
|
// SDK 核心错误 (E_SDK_xxx)
|
|
1800
1800
|
SDK_NOT_READY: "E_SDK_001",
|
|
1801
1801
|
SDK_INIT_FAILED: "E_SDK_002",
|
|
@@ -1846,7 +1846,7 @@ const W = new or(), o = {
|
|
|
1846
1846
|
API_TIMEOUT: "E_TIMEOUT_001",
|
|
1847
1847
|
// 通用错误
|
|
1848
1848
|
UNKNOWN_ERROR: "E_UNKNOWN_999"
|
|
1849
|
-
},
|
|
1849
|
+
}, Se = {
|
|
1850
1850
|
// SDK 核心
|
|
1851
1851
|
[o.SDK_NOT_READY]: "SDK 未就绪",
|
|
1852
1852
|
[o.SDK_INIT_FAILED]: "SDK 初始化失败",
|
|
@@ -1902,7 +1902,7 @@ const W = new or(), o = {
|
|
|
1902
1902
|
// 配置问题
|
|
1903
1903
|
UNKNOWN: "unknown"
|
|
1904
1904
|
// 未知问题
|
|
1905
|
-
},
|
|
1905
|
+
}, dr = {
|
|
1906
1906
|
// 图片相关
|
|
1907
1907
|
"IMAGE/USER_CANCEL": o.IMAGE_CANCELLED,
|
|
1908
1908
|
"IMAGE/PERMISSION_DENIED": o.IMAGE_NO_PERMISSION,
|
|
@@ -1910,7 +1910,7 @@ const W = new or(), o = {
|
|
|
1910
1910
|
"COMMON/UNKNOWN": o.UNKNOWN_ERROR,
|
|
1911
1911
|
"COMMON/CONFIG_NOT_READY": o.IMAGE_CONFIG_NOT_READY,
|
|
1912
1912
|
"COMMON/PLATFORM_NOT_SUPPORTED": o.PLATFORM_NOT_SUPPORTED
|
|
1913
|
-
},
|
|
1913
|
+
}, Ve = {
|
|
1914
1914
|
// 微信平台错误模式
|
|
1915
1915
|
weixin: {
|
|
1916
1916
|
patterns: [
|
|
@@ -1944,7 +1944,7 @@ const W = new or(), o = {
|
|
|
1944
1944
|
],
|
|
1945
1945
|
default: o.UNKNOWN_ERROR
|
|
1946
1946
|
}
|
|
1947
|
-
},
|
|
1947
|
+
}, qe = {
|
|
1948
1948
|
chooseImage: {
|
|
1949
1949
|
"fail cancel": o.IMAGE_CANCELLED,
|
|
1950
1950
|
"fail auth deny": o.IMAGE_NO_PERMISSION,
|
|
@@ -1958,17 +1958,17 @@ const W = new or(), o = {
|
|
|
1958
1958
|
NOT_IN_CONTAINER: o.PLATFORM_NOT_SUPPORTED
|
|
1959
1959
|
}
|
|
1960
1960
|
};
|
|
1961
|
-
function
|
|
1961
|
+
function rt(t) {
|
|
1962
1962
|
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;
|
|
1963
1963
|
}
|
|
1964
|
-
function
|
|
1964
|
+
function gr(t) {
|
|
1965
1965
|
return t.includes("NET_") || t.includes("TIMEOUT") || t === o.NETWORK_ERROR || t === o.NETWORK_TIMEOUT || t === o.API_TIMEOUT;
|
|
1966
1966
|
}
|
|
1967
|
-
function
|
|
1968
|
-
return t.includes("CANCEL") ||
|
|
1967
|
+
function hr(t) {
|
|
1968
|
+
return t.includes("CANCEL") || rt(t) === D.USER_CANCEL;
|
|
1969
1969
|
}
|
|
1970
1970
|
function Q(t) {
|
|
1971
|
-
return
|
|
1971
|
+
return Se[t] || Se[o.UNKNOWN_ERROR];
|
|
1972
1972
|
}
|
|
1973
1973
|
class F extends Error {
|
|
1974
1974
|
/**
|
|
@@ -1978,7 +1978,7 @@ class F extends Error {
|
|
|
1978
1978
|
* @param {Object} options - 选项
|
|
1979
1979
|
*/
|
|
1980
1980
|
constructor(e, r, n = {}) {
|
|
1981
|
-
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 ||
|
|
1981
|
+
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 || rt(e), this.retriable = n.retriable !== void 0 ? n.retriable : gr(e), this.originalError = n.originalError, this.details = n.details || {}, this.timestamp = Date.now();
|
|
1982
1982
|
}
|
|
1983
1983
|
/**
|
|
1984
1984
|
* 是否可重试
|
|
@@ -1992,14 +1992,14 @@ class F extends Error {
|
|
|
1992
1992
|
* @returns {boolean}
|
|
1993
1993
|
*/
|
|
1994
1994
|
isUserAction() {
|
|
1995
|
-
return
|
|
1995
|
+
return hr(this.code);
|
|
1996
1996
|
}
|
|
1997
1997
|
/**
|
|
1998
1998
|
* 转为普通对象
|
|
1999
1999
|
* @returns {Object}
|
|
2000
2000
|
*/
|
|
2001
2001
|
toJSON() {
|
|
2002
|
-
return
|
|
2002
|
+
return g({
|
|
2003
2003
|
code: this.code,
|
|
2004
2004
|
message: this.message,
|
|
2005
2005
|
platform: this.platform,
|
|
@@ -2013,11 +2013,11 @@ class F extends Error {
|
|
|
2013
2013
|
} : {});
|
|
2014
2014
|
}
|
|
2015
2015
|
}
|
|
2016
|
-
function
|
|
2016
|
+
function nt(t, e = {}) {
|
|
2017
2017
|
if (t instanceof F)
|
|
2018
2018
|
return t;
|
|
2019
2019
|
const { apiName: r, platform: n = l.type } = e;
|
|
2020
|
-
return t && typeof t.code == "string" && t.code.includes("/") ?
|
|
2020
|
+
return t && typeof t.code == "string" && t.code.includes("/") ? mr(t, { apiName: r, platform: n }) : t && (t.errMsg || t.message) ? pr(t, { apiName: r, platform: n }) : typeof t == "string" ? new F(
|
|
2021
2021
|
o.UNKNOWN_ERROR,
|
|
2022
2022
|
t,
|
|
2023
2023
|
{ apiName: r, platform: n, originalError: t }
|
|
@@ -2032,8 +2032,8 @@ function Qe(t, e = {}) {
|
|
|
2032
2032
|
}
|
|
2033
2033
|
);
|
|
2034
2034
|
}
|
|
2035
|
-
function
|
|
2036
|
-
const { apiName: r, platform: n } = e, i = t.code, s =
|
|
2035
|
+
function mr(t, e) {
|
|
2036
|
+
const { apiName: r, platform: n } = e, i = t.code, s = dr[i] || o.UNKNOWN_ERROR;
|
|
2037
2037
|
return a.debug("转换旧版错误码", {
|
|
2038
2038
|
legacy: i,
|
|
2039
2039
|
new: s
|
|
@@ -2044,29 +2044,29 @@ function fr(t, e) {
|
|
|
2044
2044
|
apiName: r,
|
|
2045
2045
|
platform: t.platform || n,
|
|
2046
2046
|
originalError: t,
|
|
2047
|
-
details:
|
|
2047
|
+
details: g({
|
|
2048
2048
|
legacyCode: i,
|
|
2049
2049
|
legacyVersion: t.version
|
|
2050
2050
|
}, t.details)
|
|
2051
2051
|
}
|
|
2052
2052
|
);
|
|
2053
2053
|
}
|
|
2054
|
-
function
|
|
2054
|
+
function pr(t, e) {
|
|
2055
2055
|
const { apiName: r, platform: n } = e, i = (t.errMsg || t.message || "").toLowerCase();
|
|
2056
|
-
if (r &&
|
|
2057
|
-
const
|
|
2058
|
-
for (const [
|
|
2059
|
-
if (i.includes(
|
|
2060
|
-
return new F(
|
|
2056
|
+
if (r && qe[r]) {
|
|
2057
|
+
const h = qe[r];
|
|
2058
|
+
for (const [f, A] of Object.entries(h))
|
|
2059
|
+
if (i.includes(f.toLowerCase()))
|
|
2060
|
+
return new F(A, Q(A), {
|
|
2061
2061
|
apiName: r,
|
|
2062
2062
|
platform: n,
|
|
2063
2063
|
originalError: t
|
|
2064
2064
|
});
|
|
2065
2065
|
}
|
|
2066
|
-
const s =
|
|
2067
|
-
for (const { pattern:
|
|
2068
|
-
if (
|
|
2069
|
-
return new F(
|
|
2066
|
+
const s = Ve[n] || Ve.uniapp;
|
|
2067
|
+
for (const { pattern: h, code: f } of s.patterns)
|
|
2068
|
+
if (h.test(i))
|
|
2069
|
+
return new F(f, Q(f), {
|
|
2070
2070
|
apiName: r,
|
|
2071
2071
|
platform: n,
|
|
2072
2072
|
originalError: t
|
|
@@ -2082,7 +2082,7 @@ function dr(t, e) {
|
|
|
2082
2082
|
}
|
|
2083
2083
|
);
|
|
2084
2084
|
}
|
|
2085
|
-
const
|
|
2085
|
+
const it = {
|
|
2086
2086
|
/**
|
|
2087
2087
|
* 响应拦截器
|
|
2088
2088
|
* @param {Object} result - API 响应结果
|
|
@@ -2091,7 +2091,7 @@ const et = {
|
|
|
2091
2091
|
*/
|
|
2092
2092
|
response: (t, e) => {
|
|
2093
2093
|
if (!t.success && t.error) {
|
|
2094
|
-
const r =
|
|
2094
|
+
const r = nt(t.error, {
|
|
2095
2095
|
apiName: e.apiName,
|
|
2096
2096
|
platform: l.type
|
|
2097
2097
|
});
|
|
@@ -2104,25 +2104,25 @@ const et = {
|
|
|
2104
2104
|
return t;
|
|
2105
2105
|
}
|
|
2106
2106
|
};
|
|
2107
|
-
function
|
|
2107
|
+
function wr(t, e = {}) {
|
|
2108
2108
|
return new F(t, Q(t), e);
|
|
2109
2109
|
}
|
|
2110
|
-
function
|
|
2110
|
+
function Er(t) {
|
|
2111
2111
|
return t instanceof F;
|
|
2112
2112
|
}
|
|
2113
|
-
function
|
|
2113
|
+
function yr(t, e, r) {
|
|
2114
2114
|
return e ? Promise.race([
|
|
2115
2115
|
t(),
|
|
2116
2116
|
new Promise((n, i) => setTimeout(() => i(new Error(`Init task timeout: ${r}`)), e))
|
|
2117
2117
|
]) : t();
|
|
2118
2118
|
}
|
|
2119
|
-
function
|
|
2119
|
+
function Ir() {
|
|
2120
2120
|
return w(this, arguments, function* (t = [], e = {}) {
|
|
2121
2121
|
for (const r of t) {
|
|
2122
2122
|
const n = (r == null ? void 0 : r.name) || "anonymous-task", i = (r == null ? void 0 : r.run) || r;
|
|
2123
2123
|
if (typeof i == "function")
|
|
2124
2124
|
try {
|
|
2125
|
-
yield
|
|
2125
|
+
yield yr(() => Promise.resolve().then(() => i()), r.timeoutMs, n), typeof r.onSuccess == "function" && r.onSuccess();
|
|
2126
2126
|
} catch (s) {
|
|
2127
2127
|
if (typeof r.onError == "function" && r.onError(s), typeof e.onError == "function")
|
|
2128
2128
|
e.onError(s, r);
|
|
@@ -2132,7 +2132,7 @@ function pr() {
|
|
|
2132
2132
|
}
|
|
2133
2133
|
});
|
|
2134
2134
|
}
|
|
2135
|
-
class
|
|
2135
|
+
class at {
|
|
2136
2136
|
/**
|
|
2137
2137
|
* 构造函数
|
|
2138
2138
|
* @param {string} name - 平台名称
|
|
@@ -2147,7 +2147,7 @@ class tt {
|
|
|
2147
2147
|
*/
|
|
2148
2148
|
processNavigationOptions(e = {}) {
|
|
2149
2149
|
const { url: r, delta: n = 1 } = e, i = r && encodeURI(r), s = parseInt(n) || 1;
|
|
2150
|
-
return
|
|
2150
|
+
return p(g({}, e), {
|
|
2151
2151
|
url: i,
|
|
2152
2152
|
delta: s
|
|
2153
2153
|
});
|
|
@@ -2258,18 +2258,18 @@ class tt {
|
|
|
2258
2258
|
throw new Error(`${this.name} platform must implement performGetEnv method`);
|
|
2259
2259
|
}
|
|
2260
2260
|
}
|
|
2261
|
-
let
|
|
2262
|
-
function
|
|
2263
|
-
if (
|
|
2261
|
+
let ue = [];
|
|
2262
|
+
function Ar() {
|
|
2263
|
+
if (ue.length === 0 && window.plus) {
|
|
2264
2264
|
const t = plus.webview.currentWebview();
|
|
2265
2265
|
if (!t)
|
|
2266
2266
|
throw new Error("plus.webview.currentWebview() is undefined");
|
|
2267
2267
|
const e = t.parent(), r = e ? e.id : t.id;
|
|
2268
|
-
|
|
2268
|
+
ue.push(r);
|
|
2269
2269
|
}
|
|
2270
|
-
return
|
|
2270
|
+
return ue;
|
|
2271
2271
|
}
|
|
2272
|
-
function
|
|
2272
|
+
function _r(t, e) {
|
|
2273
2273
|
const r = {
|
|
2274
2274
|
options: {
|
|
2275
2275
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2285,12 +2285,12 @@ function Er(t, e) {
|
|
|
2285
2285
|
type: "WEB_INVOKE_APPSERVICE",
|
|
2286
2286
|
args: {
|
|
2287
2287
|
data: r,
|
|
2288
|
-
webviewIds:
|
|
2288
|
+
webviewIds: ue
|
|
2289
2289
|
}
|
|
2290
2290
|
};
|
|
2291
2291
|
window.__uniapp_x_postMessage ? window.__uniapp_x_postMessageToService(n) : window.__uniapp_x_.postMessageToService(JSON.stringify(n));
|
|
2292
2292
|
}
|
|
2293
|
-
function
|
|
2293
|
+
function Cr(t, e) {
|
|
2294
2294
|
const r = {
|
|
2295
2295
|
options: {
|
|
2296
2296
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2306,19 +2306,19 @@ function yr(t, e) {
|
|
|
2306
2306
|
type: "WEB_INVOKE_APPSERVICE",
|
|
2307
2307
|
args: {
|
|
2308
2308
|
data: r,
|
|
2309
|
-
webviewIds:
|
|
2309
|
+
webviewIds: ue
|
|
2310
2310
|
}
|
|
2311
2311
|
};
|
|
2312
2312
|
window.__dcloud_weex_postMessage ? window.__dcloud_weex_postMessageToService(n) : window.__dcloud_weex_.postMessageToService(JSON.stringify(n));
|
|
2313
2313
|
}
|
|
2314
|
-
function
|
|
2314
|
+
function Or(t, e) {
|
|
2315
2315
|
const r = {
|
|
2316
2316
|
options: {
|
|
2317
2317
|
timestamp: +/* @__PURE__ */ new Date()
|
|
2318
2318
|
},
|
|
2319
2319
|
name: t,
|
|
2320
2320
|
arg: e
|
|
2321
|
-
}, n =
|
|
2321
|
+
}, n = Ar();
|
|
2322
2322
|
if (plus.webview.getWebviewById("__uniapp__service"))
|
|
2323
2323
|
plus.webview.postMessageToUniNView({
|
|
2324
2324
|
type: "WEB_INVOKE_APPSERVICE",
|
|
@@ -2334,7 +2334,7 @@ function Ir(t, e) {
|
|
|
2334
2334
|
);
|
|
2335
2335
|
}
|
|
2336
2336
|
}
|
|
2337
|
-
function
|
|
2337
|
+
function Pr(t, e) {
|
|
2338
2338
|
const r = {
|
|
2339
2339
|
options: {
|
|
2340
2340
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2348,10 +2348,10 @@ function Ar(t, e) {
|
|
|
2348
2348
|
pageId: ""
|
|
2349
2349
|
}, "*");
|
|
2350
2350
|
}
|
|
2351
|
-
function
|
|
2351
|
+
function Rr(t) {
|
|
2352
2352
|
return !!(t && typeof t == "object" && t.type === "qsh_api_call" && typeof t.api == "string" && typeof t.callbackId == "string");
|
|
2353
2353
|
}
|
|
2354
|
-
function
|
|
2354
|
+
function Nr(t, e) {
|
|
2355
2355
|
const r = {
|
|
2356
2356
|
options: {
|
|
2357
2357
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2359,7 +2359,7 @@ function _r(t, e) {
|
|
|
2359
2359
|
name: t,
|
|
2360
2360
|
arg: e
|
|
2361
2361
|
};
|
|
2362
|
-
if (t === "postMessage" &&
|
|
2362
|
+
if (t === "postMessage" && Rr(e))
|
|
2363
2363
|
return window.__offline_bridge_postMessage(e);
|
|
2364
2364
|
window.__offline_bridge_postMessage({
|
|
2365
2365
|
type: "WEB_INVOKE_APPSERVICE",
|
|
@@ -2367,10 +2367,10 @@ function _r(t, e) {
|
|
|
2367
2367
|
pageId: ""
|
|
2368
2368
|
});
|
|
2369
2369
|
}
|
|
2370
|
-
function
|
|
2371
|
-
|
|
2370
|
+
function fe(t, e) {
|
|
2371
|
+
Oe() ? _r(t, e) : Ce() ? Cr(t, e) : J() ? Nr(t, e) : _e() ? Or(t, e) : Pr(t, e);
|
|
2372
2372
|
}
|
|
2373
|
-
class
|
|
2373
|
+
class st extends at {
|
|
2374
2374
|
constructor() {
|
|
2375
2375
|
super("weixin");
|
|
2376
2376
|
}
|
|
@@ -2395,11 +2395,11 @@ class rt extends tt {
|
|
|
2395
2395
|
const c = window.wx.miniProgram[e];
|
|
2396
2396
|
if (typeof c == "function") {
|
|
2397
2397
|
E.debug(`使用微信原生 API: wx.miniProgram.${e}`);
|
|
2398
|
-
const
|
|
2399
|
-
return c.call(window.wx.miniProgram,
|
|
2398
|
+
const h = e === "navigateBack" ? { delta: i } : { url: n };
|
|
2399
|
+
return c.call(window.wx.miniProgram, h);
|
|
2400
2400
|
}
|
|
2401
2401
|
}
|
|
2402
|
-
E.debug(`使用消息桥接执行: ${e}`),
|
|
2402
|
+
E.debug(`使用消息桥接执行: ${e}`), fe(e, e === "navigateBack" ? { delta: i } : { url: n });
|
|
2403
2403
|
}, {
|
|
2404
2404
|
platform: this.name,
|
|
2405
2405
|
method: "performNavigation",
|
|
@@ -2417,7 +2417,7 @@ class rt extends tt {
|
|
|
2417
2417
|
const { data: r } = e;
|
|
2418
2418
|
if (this.isWeixinApiAvailable())
|
|
2419
2419
|
return window.wx.miniProgram.postMessage({ data: r });
|
|
2420
|
-
|
|
2420
|
+
fe("postMessage", r);
|
|
2421
2421
|
}, {
|
|
2422
2422
|
platform: this.name,
|
|
2423
2423
|
method: "performPostMessage",
|
|
@@ -2445,19 +2445,19 @@ class rt extends tt {
|
|
|
2445
2445
|
});
|
|
2446
2446
|
}
|
|
2447
2447
|
}
|
|
2448
|
-
const H = new
|
|
2449
|
-
var
|
|
2448
|
+
const H = new st(), Mr = (t) => H.navigateTo(t), Sr = (t) => H.navigateBack(t), Tr = (t) => H.switchTab(t), Lr = (t) => H.reLaunch(t), br = (t) => H.redirectTo(t), vr = (t) => H.postMessage(t), xr = (t) => H.getEnv(t);
|
|
2449
|
+
var ot = /* @__PURE__ */ Object.freeze({
|
|
2450
2450
|
__proto__: null,
|
|
2451
|
-
WeixinPlatform:
|
|
2452
|
-
getEnv:
|
|
2453
|
-
navigateBack:
|
|
2454
|
-
navigateTo:
|
|
2455
|
-
postMessage:
|
|
2456
|
-
reLaunch:
|
|
2457
|
-
redirectTo:
|
|
2458
|
-
switchTab:
|
|
2451
|
+
WeixinPlatform: st,
|
|
2452
|
+
getEnv: xr,
|
|
2453
|
+
navigateBack: Sr,
|
|
2454
|
+
navigateTo: Mr,
|
|
2455
|
+
postMessage: vr,
|
|
2456
|
+
reLaunch: Lr,
|
|
2457
|
+
redirectTo: br,
|
|
2458
|
+
switchTab: Tr
|
|
2459
2459
|
});
|
|
2460
|
-
class
|
|
2460
|
+
class ct extends at {
|
|
2461
2461
|
constructor() {
|
|
2462
2462
|
super("app");
|
|
2463
2463
|
}
|
|
@@ -2470,7 +2470,7 @@ class it extends tt {
|
|
|
2470
2470
|
performNavigation(e, r) {
|
|
2471
2471
|
return u.safeExecute(() => {
|
|
2472
2472
|
const { url: n, delta: i } = r;
|
|
2473
|
-
|
|
2473
|
+
fe(e, e === "navigateBack" ? { delta: i } : { url: n });
|
|
2474
2474
|
}, {
|
|
2475
2475
|
platform: this.name,
|
|
2476
2476
|
method: "performNavigation",
|
|
@@ -2486,7 +2486,7 @@ class it extends tt {
|
|
|
2486
2486
|
performPostMessage(e) {
|
|
2487
2487
|
return u.safeExecute(() => {
|
|
2488
2488
|
const { data: r } = e;
|
|
2489
|
-
|
|
2489
|
+
fe("postMessage", r);
|
|
2490
2490
|
}, {
|
|
2491
2491
|
platform: this.name,
|
|
2492
2492
|
method: "performPostMessage",
|
|
@@ -2504,59 +2504,59 @@ class it extends tt {
|
|
|
2504
2504
|
throw new Error("Callback function is required for getEnv");
|
|
2505
2505
|
const r = {};
|
|
2506
2506
|
let n = !1;
|
|
2507
|
-
|
|
2507
|
+
Oe() ? (r.uvue = !0, n = !0) : Ce() ? (r.nvue = !0, n = !0) : _e() ? (r.plus = !0, n = !0) : J() && (r.offline = !0, n = !0), n ? r.app = !0 : r.h5 = !0, e(r);
|
|
2508
2508
|
}, {
|
|
2509
2509
|
platform: this.name,
|
|
2510
2510
|
method: "performGetEnv"
|
|
2511
2511
|
});
|
|
2512
2512
|
}
|
|
2513
2513
|
}
|
|
2514
|
-
const Y = new
|
|
2515
|
-
var
|
|
2514
|
+
const Y = new ct(), Dr = (t) => Y.navigateTo(t), Ur = (t) => Y.navigateBack(t), Wr = (t) => Y.switchTab(t), $r = (t) => Y.reLaunch(t), Fr = (t) => Y.redirectTo(t), Br = (t) => Y.postMessage(t), kr = (t) => Y.getEnv(t);
|
|
2515
|
+
var ut = /* @__PURE__ */ Object.freeze({
|
|
2516
2516
|
__proto__: null,
|
|
2517
|
-
AppPlatform:
|
|
2518
|
-
getEnv:
|
|
2519
|
-
navigateBack:
|
|
2520
|
-
navigateTo:
|
|
2521
|
-
postMessage:
|
|
2522
|
-
reLaunch:
|
|
2523
|
-
redirectTo:
|
|
2524
|
-
switchTab:
|
|
2517
|
+
AppPlatform: ct,
|
|
2518
|
+
getEnv: kr,
|
|
2519
|
+
navigateBack: Ur,
|
|
2520
|
+
navigateTo: Dr,
|
|
2521
|
+
postMessage: Br,
|
|
2522
|
+
reLaunch: $r,
|
|
2523
|
+
redirectTo: Fr,
|
|
2524
|
+
switchTab: Wr
|
|
2525
2525
|
});
|
|
2526
|
-
function
|
|
2527
|
-
return C() ?
|
|
2526
|
+
function ge() {
|
|
2527
|
+
return C() ? ot : ut;
|
|
2528
2528
|
}
|
|
2529
|
-
function
|
|
2530
|
-
return
|
|
2529
|
+
function Gr(t) {
|
|
2530
|
+
return ge().navigateTo(t);
|
|
2531
2531
|
}
|
|
2532
|
-
function
|
|
2533
|
-
return
|
|
2532
|
+
function Kr(t) {
|
|
2533
|
+
return ge().navigateBack(t);
|
|
2534
2534
|
}
|
|
2535
|
-
function
|
|
2536
|
-
return
|
|
2535
|
+
function zr(t) {
|
|
2536
|
+
return ge().switchTab(t);
|
|
2537
2537
|
}
|
|
2538
|
-
function
|
|
2539
|
-
return
|
|
2538
|
+
function Vr(t) {
|
|
2539
|
+
return ge().reLaunch(t);
|
|
2540
2540
|
}
|
|
2541
|
-
function
|
|
2542
|
-
return
|
|
2541
|
+
function qr(t) {
|
|
2542
|
+
return ge().redirectTo(t);
|
|
2543
2543
|
}
|
|
2544
|
-
function
|
|
2545
|
-
return C() ?
|
|
2544
|
+
function lt() {
|
|
2545
|
+
return C() ? ot : ut;
|
|
2546
2546
|
}
|
|
2547
|
-
function
|
|
2548
|
-
return
|
|
2547
|
+
function Jr(t = {}) {
|
|
2548
|
+
return lt().postMessage(t);
|
|
2549
2549
|
}
|
|
2550
|
-
function
|
|
2551
|
-
return
|
|
2550
|
+
function jr(t) {
|
|
2551
|
+
return lt().getEnv(t);
|
|
2552
2552
|
}
|
|
2553
|
-
function
|
|
2553
|
+
function Hr(t) {
|
|
2554
2554
|
return t && typeof t == "object" && t.__v_raw ? t.__v_raw : t;
|
|
2555
2555
|
}
|
|
2556
|
-
function
|
|
2556
|
+
function Yr() {
|
|
2557
2557
|
return "qsh_callback_" + Date.now() + "_" + Math.random().toString(36).substring(2, 9);
|
|
2558
2558
|
}
|
|
2559
|
-
class
|
|
2559
|
+
class Zr {
|
|
2560
2560
|
constructor() {
|
|
2561
2561
|
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 = {})), y.debug("WebView 桥接器已初始化");
|
|
2562
2562
|
}
|
|
@@ -2570,13 +2570,13 @@ class Jr {
|
|
|
2570
2570
|
callApi(i) {
|
|
2571
2571
|
return w(this, arguments, function* (e, r = {}, n = {}) {
|
|
2572
2572
|
return u.safeExecute(() => w(this, null, function* () {
|
|
2573
|
-
var
|
|
2573
|
+
var A;
|
|
2574
2574
|
if (typeof window != "undefined" && window === window.parent && !window.plus && !window.__uniapp_x_postMessage && !window.__uniapp_x_ && !window.__dcloud_weex_postMessage && !window.__dcloud_weex_ && !J()) {
|
|
2575
|
-
const
|
|
2575
|
+
const M = new N(
|
|
2576
2576
|
b.PLATFORM_NOT_SUPPORTED,
|
|
2577
2577
|
"当前不在宿主 WebView 容器中,无法发送消息"
|
|
2578
2578
|
);
|
|
2579
|
-
n && typeof n.fail == "function" && n.fail({ errMsg:
|
|
2579
|
+
n && typeof n.fail == "function" && n.fail({ errMsg: M.message, code: "NOT_IN_CONTAINER" }), n && typeof n.complete == "function" && n.complete({ success: !1, error: { errMsg: M.message } });
|
|
2580
2580
|
return;
|
|
2581
2581
|
}
|
|
2582
2582
|
const c = {
|
|
@@ -2588,49 +2588,49 @@ class Jr {
|
|
|
2588
2588
|
metadata: {}
|
|
2589
2589
|
};
|
|
2590
2590
|
W.setApiLoading(e, !0);
|
|
2591
|
-
const
|
|
2592
|
-
if (
|
|
2591
|
+
const h = yield z.runRequest(c);
|
|
2592
|
+
if (h.abort) {
|
|
2593
2593
|
y.warn("API 调用被拦截器中止", { api: e }), W.setApiLoading(e, !1), n.fail && n.fail({
|
|
2594
|
-
errMsg: ((
|
|
2594
|
+
errMsg: ((A = h.error) == null ? void 0 : A.message) || "API 调用被中止",
|
|
2595
2595
|
code: "INTERCEPTED"
|
|
2596
2596
|
}), n.complete && n.complete({ success: !1 });
|
|
2597
2597
|
return;
|
|
2598
2598
|
}
|
|
2599
|
-
const
|
|
2599
|
+
const f = Yr();
|
|
2600
2600
|
if (n.success || n.fail || n.complete) {
|
|
2601
|
-
if (this.callbacks.set(
|
|
2602
|
-
context:
|
|
2601
|
+
if (this.callbacks.set(f, p(g({}, n), {
|
|
2602
|
+
context: h
|
|
2603
2603
|
// 保存上下文用于响应拦截
|
|
2604
|
-
})), window.qshWebviewCallbacks[
|
|
2605
|
-
this.handleCallback(
|
|
2606
|
-
}, r.isPersistent && (this.persistentCallbacksByApi.has(e) || this.persistentCallbacksByApi.set(e, /* @__PURE__ */ new Set()), this.persistentCallbacksByApi.get(e).add(
|
|
2604
|
+
})), window.qshWebviewCallbacks[f] = (ie) => {
|
|
2605
|
+
this.handleCallback(f, ie);
|
|
2606
|
+
}, r.isPersistent && (this.persistentCallbacksByApi.has(e) || this.persistentCallbacksByApi.set(e, /* @__PURE__ */ new Set()), this.persistentCallbacksByApi.get(e).add(f)), r.isPersistent || r.disableTimeout)
|
|
2607
2607
|
y.info(`API ${e} 禁用超时清理,将等待回调返回后清理`, {
|
|
2608
|
-
callbackId:
|
|
2608
|
+
callbackId: f,
|
|
2609
2609
|
isPersistent: r.isPersistent,
|
|
2610
2610
|
disableTimeout: r.disableTimeout
|
|
2611
2611
|
});
|
|
2612
2612
|
else {
|
|
2613
|
-
const
|
|
2614
|
-
y.warn("API 调用超时,自动清理回调", { api: e, callbackId:
|
|
2613
|
+
const ie = setTimeout(() => {
|
|
2614
|
+
y.warn("API 调用超时,自动清理回调", { api: e, callbackId: f }), n.fail && n.fail({
|
|
2615
2615
|
errMsg: `API ${e} 调用超时`,
|
|
2616
2616
|
code: "TIMEOUT"
|
|
2617
|
-
}), this.cleanupCallback(
|
|
2617
|
+
}), this.cleanupCallback(f);
|
|
2618
2618
|
}, r.timeout || this.defaultTimeout);
|
|
2619
|
-
this.timeouts.set(
|
|
2619
|
+
this.timeouts.set(f, ie);
|
|
2620
2620
|
}
|
|
2621
|
-
const
|
|
2621
|
+
const m = {
|
|
2622
2622
|
type: "qsh_api_call",
|
|
2623
2623
|
api: e,
|
|
2624
|
-
params:
|
|
2625
|
-
callbackId:
|
|
2624
|
+
params: h.params,
|
|
2625
|
+
callbackId: f,
|
|
2626
2626
|
timestamp: Date.now()
|
|
2627
2627
|
};
|
|
2628
2628
|
y.info("发送 API 调用消息", {
|
|
2629
2629
|
api: e,
|
|
2630
|
-
callbackId:
|
|
2630
|
+
callbackId: f,
|
|
2631
2631
|
hasSuccess: !!n.success,
|
|
2632
2632
|
hasFail: !!n.fail
|
|
2633
|
-
}), console.log("message:", JSON.stringify(
|
|
2633
|
+
}), console.log("message:", JSON.stringify(Hr(m), null, 2)), fe("postMessage", m);
|
|
2634
2634
|
}
|
|
2635
2635
|
}), {
|
|
2636
2636
|
context: "WebViewBridge.callApi",
|
|
@@ -2647,16 +2647,16 @@ class Jr {
|
|
|
2647
2647
|
handleCallback(e, r) {
|
|
2648
2648
|
return w(this, null, function* () {
|
|
2649
2649
|
return u.safeExecute(() => w(this, null, function* () {
|
|
2650
|
-
var
|
|
2650
|
+
var M, m;
|
|
2651
2651
|
const n = this.callbacks.get(e);
|
|
2652
2652
|
if (!n) {
|
|
2653
2653
|
y.warn("未找到回调函数", { callbackId: e });
|
|
2654
2654
|
return;
|
|
2655
2655
|
}
|
|
2656
|
-
const { success: i, fail: s, complete: c, context:
|
|
2656
|
+
const { success: i, fail: s, complete: c, context: h } = n;
|
|
2657
2657
|
y.debug("处理回调", { callbackId: e, result: r });
|
|
2658
|
-
const
|
|
2659
|
-
|
|
2658
|
+
const f = yield z.runResponse(r, h);
|
|
2659
|
+
h && W.setApiResult(h.apiName, f), f.success && i ? i(f.data) : !f.success && s && s(f.error || { errMsg: "操作失败" }), c && c(f), ((m = (M = n.context) == null ? void 0 : M.params) == null ? void 0 : m.isPersistent) ? y.debug("持久监听API:保留回调", { callbackId: e }) : (this.cleanupCallback(e), y.debug("回调执行完成,已清理", { callbackId: e }));
|
|
2660
2660
|
}), {
|
|
2661
2661
|
context: "WebViewBridge.handleCallback",
|
|
2662
2662
|
callbackId: e
|
|
@@ -2709,14 +2709,14 @@ class Jr {
|
|
|
2709
2709
|
};
|
|
2710
2710
|
}
|
|
2711
2711
|
}
|
|
2712
|
-
const
|
|
2713
|
-
function
|
|
2712
|
+
const ft = new Zr(), P = (t, e, r) => ft.callApi(t, e, r), ee = (t) => ft.cleanupPersistentCallbacksByApi(t);
|
|
2713
|
+
function dt() {
|
|
2714
2714
|
return ne(!0);
|
|
2715
2715
|
}
|
|
2716
|
-
function
|
|
2716
|
+
function Xr(t) {
|
|
2717
2717
|
return t === "offline";
|
|
2718
2718
|
}
|
|
2719
|
-
function
|
|
2719
|
+
function Qr(t = {}) {
|
|
2720
2720
|
return u.safeExecute(() => {
|
|
2721
2721
|
a.debug("Call getCode through offline webview bridge", {
|
|
2722
2722
|
clientId: t.clientId
|
|
@@ -2739,13 +2739,13 @@ function Hr(t = {}) {
|
|
|
2739
2739
|
);
|
|
2740
2740
|
}, {
|
|
2741
2741
|
context: "getCodeInHost",
|
|
2742
|
-
platform:
|
|
2742
|
+
platform: dt().type
|
|
2743
2743
|
});
|
|
2744
2744
|
}
|
|
2745
|
-
function
|
|
2745
|
+
function en(t = {}) {
|
|
2746
2746
|
return u.safeExecute(() => {
|
|
2747
2747
|
var n, i;
|
|
2748
|
-
const e =
|
|
2748
|
+
const e = dt(), r = String((t == null ? void 0 : t.clientId) || "").trim();
|
|
2749
2749
|
if (!r) {
|
|
2750
2750
|
const s = {
|
|
2751
2751
|
errMsg: "clientId is required",
|
|
@@ -2754,7 +2754,7 @@ function Yr(t = {}) {
|
|
|
2754
2754
|
a.error("Get code missing clientId"), (n = t.fail) == null || n.call(t, s);
|
|
2755
2755
|
return;
|
|
2756
2756
|
}
|
|
2757
|
-
if (!
|
|
2757
|
+
if (!Xr(e.type)) {
|
|
2758
2758
|
const s = {
|
|
2759
2759
|
errMsg: `Current environment (${e.type}) does not support getCode`,
|
|
2760
2760
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -2764,7 +2764,7 @@ function Yr(t = {}) {
|
|
|
2764
2764
|
}), (i = t.fail) == null || i.call(t, s);
|
|
2765
2765
|
return;
|
|
2766
2766
|
}
|
|
2767
|
-
|
|
2767
|
+
Qr(p(g({}, t), {
|
|
2768
2768
|
clientId: r
|
|
2769
2769
|
}));
|
|
2770
2770
|
}, {
|
|
@@ -2772,11 +2772,11 @@ function Yr(t = {}) {
|
|
|
2772
2772
|
options: t
|
|
2773
2773
|
});
|
|
2774
2774
|
}
|
|
2775
|
-
function
|
|
2775
|
+
function gt() {
|
|
2776
2776
|
return ne(!0);
|
|
2777
2777
|
}
|
|
2778
|
-
const
|
|
2779
|
-
function
|
|
2778
|
+
const Je = ["release", "trial", "develop"];
|
|
2779
|
+
function tn(t = {}) {
|
|
2780
2780
|
const e = String((t == null ? void 0 : t.appid) || "").trim(), r = (t == null ? void 0 : t.path) == null ? "" : t.path, n = t == null ? void 0 : t.env, i = n == null || n === "" ? void 0 : String(n).trim();
|
|
2781
2781
|
if (!e)
|
|
2782
2782
|
throw {
|
|
@@ -2788,24 +2788,24 @@ function Zr(t = {}) {
|
|
|
2788
2788
|
errMsg: "path must be a string",
|
|
2789
2789
|
code: "PARAM_TYPE_ERROR"
|
|
2790
2790
|
};
|
|
2791
|
-
if (i !== void 0 && !
|
|
2791
|
+
if (i !== void 0 && !Je.includes(i))
|
|
2792
2792
|
throw {
|
|
2793
|
-
errMsg: `env must be one of ${
|
|
2793
|
+
errMsg: `env must be one of ${Je.join("/")}`,
|
|
2794
2794
|
code: "PARAM_INVALID"
|
|
2795
2795
|
};
|
|
2796
|
-
return
|
|
2796
|
+
return p(g({}, t), {
|
|
2797
2797
|
appid: e,
|
|
2798
2798
|
path: r.trim(),
|
|
2799
2799
|
env: i
|
|
2800
2800
|
});
|
|
2801
2801
|
}
|
|
2802
|
-
function
|
|
2802
|
+
function rn() {
|
|
2803
2803
|
return typeof window != "undefined" && window.wx && window.wx.miniProgram && typeof window.wx.miniProgram.postMessage == "function" && typeof window.wx.miniProgram.navigateBack == "function";
|
|
2804
2804
|
}
|
|
2805
|
-
function
|
|
2805
|
+
function nn(t = {}) {
|
|
2806
2806
|
return u.safeExecute(() => {
|
|
2807
2807
|
var r;
|
|
2808
|
-
if (!
|
|
2808
|
+
if (!rn()) {
|
|
2809
2809
|
const n = {
|
|
2810
2810
|
errMsg: "wx.miniProgram.postMessage or wx.miniProgram.navigateBack is not available",
|
|
2811
2811
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -2838,19 +2838,19 @@ function Qr(t = {}) {
|
|
|
2838
2838
|
window.wx.miniProgram.navigateBack({
|
|
2839
2839
|
delta: 1,
|
|
2840
2840
|
success: (c) => {
|
|
2841
|
-
var
|
|
2842
|
-
const
|
|
2841
|
+
var f;
|
|
2842
|
+
const h = p(g({}, c), {
|
|
2843
2843
|
errMsg: (c == null ? void 0 : c.errMsg) || "navigateToMiniProgram:queued"
|
|
2844
2844
|
});
|
|
2845
2845
|
a.info("Navigate to mini program request queued in weixin web-view", {
|
|
2846
2846
|
appid: t.appid,
|
|
2847
2847
|
path: t.path,
|
|
2848
2848
|
env: t.env
|
|
2849
|
-
}), (
|
|
2849
|
+
}), (f = t.success) == null || f.call(t, h), n(h);
|
|
2850
2850
|
},
|
|
2851
2851
|
fail: (c) => {
|
|
2852
|
-
var
|
|
2853
|
-
a.error("Navigate back after posting mini program message failed", c), (
|
|
2852
|
+
var h;
|
|
2853
|
+
a.error("Navigate back after posting mini program message failed", c), (h = t.fail) == null || h.call(t, c), i(c);
|
|
2854
2854
|
},
|
|
2855
2855
|
complete: t.complete
|
|
2856
2856
|
});
|
|
@@ -2860,7 +2860,7 @@ function Qr(t = {}) {
|
|
|
2860
2860
|
platform: "weixin"
|
|
2861
2861
|
});
|
|
2862
2862
|
}
|
|
2863
|
-
function
|
|
2863
|
+
function an(t = {}) {
|
|
2864
2864
|
return u.safeExecute(() => (a.debug("Call navigateToMiniProgram through webview bridge", {
|
|
2865
2865
|
appid: t.appid,
|
|
2866
2866
|
path: t.path,
|
|
@@ -2887,16 +2887,16 @@ function en(t = {}) {
|
|
|
2887
2887
|
);
|
|
2888
2888
|
})), {
|
|
2889
2889
|
context: "navigateToMiniProgramInHost",
|
|
2890
|
-
platform:
|
|
2890
|
+
platform: gt().type
|
|
2891
2891
|
});
|
|
2892
2892
|
}
|
|
2893
|
-
function
|
|
2893
|
+
function sn(t = {}) {
|
|
2894
2894
|
return u.safeExecute(() => {
|
|
2895
2895
|
var n;
|
|
2896
|
-
const e =
|
|
2896
|
+
const e = gt();
|
|
2897
2897
|
let r;
|
|
2898
2898
|
try {
|
|
2899
|
-
r =
|
|
2899
|
+
r = tn(t);
|
|
2900
2900
|
} catch (i) {
|
|
2901
2901
|
a.error("Navigate to mini program params validation failed", i), (n = t.fail) == null || n.call(t, i);
|
|
2902
2902
|
return;
|
|
@@ -2906,35 +2906,35 @@ function tn(t = {}) {
|
|
|
2906
2906
|
appid: r.appid,
|
|
2907
2907
|
path: r.path,
|
|
2908
2908
|
env: r.env
|
|
2909
|
-
}), e.isWeixinMiniProgram ?
|
|
2909
|
+
}), e.isWeixinMiniProgram ? nn(r) : an(r);
|
|
2910
2910
|
}, {
|
|
2911
2911
|
context: "navigateToMiniProgram",
|
|
2912
2912
|
options: t
|
|
2913
2913
|
});
|
|
2914
2914
|
}
|
|
2915
|
-
const
|
|
2915
|
+
const Ie = {
|
|
2916
2916
|
ALBUM: "album",
|
|
2917
2917
|
// 相册
|
|
2918
2918
|
CAMERA: "camera"
|
|
2919
2919
|
// 相机
|
|
2920
|
-
},
|
|
2920
|
+
}, Ae = {
|
|
2921
2921
|
ORIGINAL: "original",
|
|
2922
2922
|
// 原图
|
|
2923
2923
|
COMPRESSED: "compressed"
|
|
2924
2924
|
// 压缩图
|
|
2925
|
-
},
|
|
2925
|
+
}, on = {
|
|
2926
2926
|
count: 9,
|
|
2927
|
-
sizeType: [
|
|
2928
|
-
sourceType: [
|
|
2927
|
+
sizeType: [Ae.ORIGINAL, Ae.COMPRESSED],
|
|
2928
|
+
sourceType: [Ie.ALBUM, Ie.CAMERA]
|
|
2929
2929
|
};
|
|
2930
|
-
function
|
|
2931
|
-
const e =
|
|
2932
|
-
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 = [
|
|
2930
|
+
function cn(t = {}) {
|
|
2931
|
+
const e = g(g({}, on), t);
|
|
2932
|
+
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 = [Ae.COMPRESSED]), e.sourceType.length === 0 && (e.sourceType = [Ie.ALBUM]), e;
|
|
2933
2933
|
}
|
|
2934
|
-
function
|
|
2934
|
+
function ht() {
|
|
2935
2935
|
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
2936
2936
|
}
|
|
2937
|
-
function
|
|
2937
|
+
function mt(t) {
|
|
2938
2938
|
return u.safeExecute(() => {
|
|
2939
2939
|
var e;
|
|
2940
2940
|
if (!window.wx) {
|
|
@@ -2946,7 +2946,7 @@ function ft(t) {
|
|
|
2946
2946
|
return;
|
|
2947
2947
|
}
|
|
2948
2948
|
if (!j()) {
|
|
2949
|
-
a.info("等待微信配置完成"),
|
|
2949
|
+
a.info("等待微信配置完成"), K().then(() => mt(t)).catch((r) => {
|
|
2950
2950
|
var n;
|
|
2951
2951
|
a.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
2952
2952
|
});
|
|
@@ -2971,9 +2971,9 @@ function ft(t) {
|
|
|
2971
2971
|
platform: "weixin"
|
|
2972
2972
|
});
|
|
2973
2973
|
}
|
|
2974
|
-
function
|
|
2974
|
+
function un(t) {
|
|
2975
2975
|
return u.safeExecute(() => {
|
|
2976
|
-
a.debug("通过 WebView 桥接调用图片选择", t), P("chooseImage",
|
|
2976
|
+
a.debug("通过 WebView 桥接调用图片选择", t), P("chooseImage", p(g({}, t), { disableTimeout: !0 }), {
|
|
2977
2977
|
success: (e) => {
|
|
2978
2978
|
var r, n;
|
|
2979
2979
|
a.info("UniApp 图片选择成功", {
|
|
@@ -2991,10 +2991,10 @@ function an(t) {
|
|
|
2991
2991
|
platform: "uniapp"
|
|
2992
2992
|
});
|
|
2993
2993
|
}
|
|
2994
|
-
function
|
|
2994
|
+
function ln(t = {}) {
|
|
2995
2995
|
return u.safeExecute(() => {
|
|
2996
2996
|
var r;
|
|
2997
|
-
if (!
|
|
2997
|
+
if (!ht()) {
|
|
2998
2998
|
const n = {
|
|
2999
2999
|
errMsg: `当前环境 (${l.type}) 不支持图片选择功能`,
|
|
3000
3000
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -3002,21 +3002,21 @@ function sn(t = {}) {
|
|
|
3002
3002
|
a.error("平台不支持图片选择", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
3003
3003
|
return;
|
|
3004
3004
|
}
|
|
3005
|
-
const e =
|
|
3005
|
+
const e = cn(t);
|
|
3006
3006
|
a.info("开始选择图片", {
|
|
3007
3007
|
platform: l.type,
|
|
3008
3008
|
count: e.count,
|
|
3009
3009
|
sizeType: e.sizeType,
|
|
3010
3010
|
sourceType: e.sourceType
|
|
3011
|
-
}), C() ?
|
|
3011
|
+
}), C() ? mt(e) : un(e);
|
|
3012
3012
|
}, {
|
|
3013
3013
|
context: "chooseImage",
|
|
3014
3014
|
options: t
|
|
3015
3015
|
});
|
|
3016
3016
|
}
|
|
3017
|
-
function
|
|
3017
|
+
function fn() {
|
|
3018
3018
|
return {
|
|
3019
|
-
supported:
|
|
3019
|
+
supported: ht(),
|
|
3020
3020
|
environment: l.type,
|
|
3021
3021
|
implementation: C() ? "weixin" : "webview",
|
|
3022
3022
|
features: {
|
|
@@ -3040,20 +3040,20 @@ const q = {
|
|
|
3040
3040
|
// Data Matrix 码
|
|
3041
3041
|
PDF417: "pdf417"
|
|
3042
3042
|
// PDF417 条码
|
|
3043
|
-
},
|
|
3043
|
+
}, dn = {
|
|
3044
3044
|
onlyFromCamera: !0,
|
|
3045
3045
|
// 只从相机扫码
|
|
3046
3046
|
scanType: [q.QR_CODE, q.BAR_CODE]
|
|
3047
3047
|
// 支持二维码和一维码
|
|
3048
3048
|
};
|
|
3049
|
-
function
|
|
3050
|
-
const e =
|
|
3049
|
+
function gn(t = {}) {
|
|
3050
|
+
const e = g(g({}, dn), t);
|
|
3051
3051
|
return Array.isArray(e.scanType) || (e.scanType = [e.scanType].filter(Boolean)), e.scanType.length === 0 && (e.scanType = [q.QR_CODE, q.BAR_CODE]), e.onlyFromCamera = !!e.onlyFromCamera, e;
|
|
3052
3052
|
}
|
|
3053
|
-
function
|
|
3053
|
+
function pt() {
|
|
3054
3054
|
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
3055
3055
|
}
|
|
3056
|
-
function
|
|
3056
|
+
function wt(t) {
|
|
3057
3057
|
return u.safeExecute(() => {
|
|
3058
3058
|
var e;
|
|
3059
3059
|
if (!window.wx) {
|
|
@@ -3065,7 +3065,7 @@ function gt(t) {
|
|
|
3065
3065
|
return;
|
|
3066
3066
|
}
|
|
3067
3067
|
if (!j()) {
|
|
3068
|
-
a.info("等待微信配置完成"),
|
|
3068
|
+
a.info("等待微信配置完成"), K().then(() => wt(t)).catch((r) => {
|
|
3069
3069
|
var n;
|
|
3070
3070
|
a.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
3071
3071
|
});
|
|
@@ -3081,7 +3081,7 @@ function gt(t) {
|
|
|
3081
3081
|
const n = {
|
|
3082
3082
|
result: r.resultStr,
|
|
3083
3083
|
// 扫码内容
|
|
3084
|
-
scanType:
|
|
3084
|
+
scanType: hn(r.resultStr),
|
|
3085
3085
|
// 推测扫码类型
|
|
3086
3086
|
charSet: "utf-8",
|
|
3087
3087
|
// 微信默认 UTF-8
|
|
@@ -3100,12 +3100,12 @@ function gt(t) {
|
|
|
3100
3100
|
platform: "weixin"
|
|
3101
3101
|
});
|
|
3102
3102
|
}
|
|
3103
|
-
function
|
|
3103
|
+
function hn(t) {
|
|
3104
3104
|
return t ? t.length > 50 || /[^\d]/.test(t) ? q.QR_CODE : q.BAR_CODE : "unknown";
|
|
3105
3105
|
}
|
|
3106
|
-
function
|
|
3106
|
+
function mn(t) {
|
|
3107
3107
|
return u.safeExecute(() => {
|
|
3108
|
-
a.debug("通过 WebView 桥接调用扫码", t), P("scanCode",
|
|
3108
|
+
a.debug("通过 WebView 桥接调用扫码", t), P("scanCode", p(g({}, t), { disableTimeout: !0 }), {
|
|
3109
3109
|
success: (e) => {
|
|
3110
3110
|
var r;
|
|
3111
3111
|
a.info("UniApp 扫码成功", {
|
|
@@ -3124,10 +3124,10 @@ function fn(t) {
|
|
|
3124
3124
|
platform: "uniapp"
|
|
3125
3125
|
});
|
|
3126
3126
|
}
|
|
3127
|
-
function
|
|
3127
|
+
function pn(t = {}) {
|
|
3128
3128
|
return u.safeExecute(() => {
|
|
3129
3129
|
var r;
|
|
3130
|
-
if (!
|
|
3130
|
+
if (!pt()) {
|
|
3131
3131
|
const n = {
|
|
3132
3132
|
errMsg: `当前环境 (${l.type}) 不支持扫码功能`,
|
|
3133
3133
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -3135,20 +3135,20 @@ function dn(t = {}) {
|
|
|
3135
3135
|
a.error("平台不支持扫码", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
3136
3136
|
return;
|
|
3137
3137
|
}
|
|
3138
|
-
const e =
|
|
3138
|
+
const e = gn(t);
|
|
3139
3139
|
a.info("开始扫码", {
|
|
3140
3140
|
platform: l.type,
|
|
3141
3141
|
onlyFromCamera: e.onlyFromCamera,
|
|
3142
3142
|
scanType: e.scanType
|
|
3143
|
-
}), C() ?
|
|
3143
|
+
}), C() ? wt(e) : mn(e);
|
|
3144
3144
|
}, {
|
|
3145
3145
|
context: "scanCode",
|
|
3146
3146
|
options: t
|
|
3147
3147
|
});
|
|
3148
3148
|
}
|
|
3149
|
-
function
|
|
3149
|
+
function wn() {
|
|
3150
3150
|
return {
|
|
3151
|
-
supported:
|
|
3151
|
+
supported: pt(),
|
|
3152
3152
|
environment: l.type,
|
|
3153
3153
|
implementation: C() ? "weixin" : "webview",
|
|
3154
3154
|
features: {
|
|
@@ -3170,23 +3170,23 @@ const te = {
|
|
|
3170
3170
|
// 国测局坐标(火星坐标)
|
|
3171
3171
|
BD09: "bd09"
|
|
3172
3172
|
// 百度坐标
|
|
3173
|
-
},
|
|
3173
|
+
}, En = {
|
|
3174
3174
|
type: te.WGS84,
|
|
3175
3175
|
altitude: !1
|
|
3176
|
-
},
|
|
3176
|
+
}, yn = {
|
|
3177
3177
|
scale: 18
|
|
3178
3178
|
// 地图缩放级别 1-28
|
|
3179
3179
|
};
|
|
3180
|
-
function
|
|
3181
|
-
const e =
|
|
3180
|
+
function In(t = {}) {
|
|
3181
|
+
const e = g(g({}, En), t);
|
|
3182
3182
|
return Object.values(te).includes(e.type) || (e.type = te.WGS84), e.altitude = !!e.altitude, e;
|
|
3183
3183
|
}
|
|
3184
|
-
function
|
|
3185
|
-
const e =
|
|
3184
|
+
function An(t = {}) {
|
|
3185
|
+
const e = g({}, t);
|
|
3186
3186
|
return Object.values(te).includes(e.type) || (e.type = te.WGS84), e.needFullAccuracy = !!e.needFullAccuracy, e;
|
|
3187
3187
|
}
|
|
3188
|
-
function
|
|
3189
|
-
const e =
|
|
3188
|
+
function _n(t = {}) {
|
|
3189
|
+
const e = g(g({}, yn), t);
|
|
3190
3190
|
if (e.latitude === void 0 || e.latitude === null)
|
|
3191
3191
|
throw {
|
|
3192
3192
|
errMsg: "缺少必需参数:latitude(纬度)",
|
|
@@ -3245,10 +3245,10 @@ function En(t = {}) {
|
|
|
3245
3245
|
}
|
|
3246
3246
|
return e;
|
|
3247
3247
|
}
|
|
3248
|
-
function
|
|
3248
|
+
function xe() {
|
|
3249
3249
|
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
3250
3250
|
}
|
|
3251
|
-
function
|
|
3251
|
+
function Et(t) {
|
|
3252
3252
|
return u.safeExecute(() => {
|
|
3253
3253
|
var e;
|
|
3254
3254
|
if (!window.wx) {
|
|
@@ -3260,7 +3260,7 @@ function ht(t) {
|
|
|
3260
3260
|
return;
|
|
3261
3261
|
}
|
|
3262
3262
|
if (!j()) {
|
|
3263
|
-
a.info("等待微信配置完成"),
|
|
3263
|
+
a.info("等待微信配置完成"), K().then(() => Et(t)).catch((r) => {
|
|
3264
3264
|
var n;
|
|
3265
3265
|
a.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
3266
3266
|
});
|
|
@@ -3286,7 +3286,7 @@ function ht(t) {
|
|
|
3286
3286
|
platform: "weixin"
|
|
3287
3287
|
});
|
|
3288
3288
|
}
|
|
3289
|
-
function
|
|
3289
|
+
function yt(t) {
|
|
3290
3290
|
return u.safeExecute(() => {
|
|
3291
3291
|
var e;
|
|
3292
3292
|
if (!window.wx) {
|
|
@@ -3298,7 +3298,7 @@ function mt(t) {
|
|
|
3298
3298
|
return;
|
|
3299
3299
|
}
|
|
3300
3300
|
if (!j()) {
|
|
3301
|
-
a.info("等待微信配置完成"),
|
|
3301
|
+
a.info("等待微信配置完成"), K().then(() => yt(t)).catch((r) => {
|
|
3302
3302
|
var n;
|
|
3303
3303
|
a.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
3304
3304
|
});
|
|
@@ -3326,7 +3326,7 @@ function mt(t) {
|
|
|
3326
3326
|
platform: "weixin"
|
|
3327
3327
|
});
|
|
3328
3328
|
}
|
|
3329
|
-
function
|
|
3329
|
+
function Cn(t) {
|
|
3330
3330
|
return u.safeExecute(() => {
|
|
3331
3331
|
a.debug("通过 WebView 桥接调用获取位置", t), P("getLocation", t, {
|
|
3332
3332
|
success: (e) => {
|
|
@@ -3347,7 +3347,7 @@ function yn(t) {
|
|
|
3347
3347
|
platform: "uniapp"
|
|
3348
3348
|
});
|
|
3349
3349
|
}
|
|
3350
|
-
function
|
|
3350
|
+
function On(t) {
|
|
3351
3351
|
return u.safeExecute(() => {
|
|
3352
3352
|
a.debug("通过 WebView 桥接调用查看位置", t), P("openLocation", t, {
|
|
3353
3353
|
success: (e) => {
|
|
@@ -3365,10 +3365,10 @@ function In(t) {
|
|
|
3365
3365
|
platform: "uniapp"
|
|
3366
3366
|
});
|
|
3367
3367
|
}
|
|
3368
|
-
function
|
|
3368
|
+
function Pn(t = {}) {
|
|
3369
3369
|
return u.safeExecute(() => {
|
|
3370
3370
|
var r;
|
|
3371
|
-
if (!
|
|
3371
|
+
if (!xe()) {
|
|
3372
3372
|
const n = {
|
|
3373
3373
|
errMsg: `当前环境 (${l.type}) 不支持定位功能`,
|
|
3374
3374
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -3376,21 +3376,21 @@ function An(t = {}) {
|
|
|
3376
3376
|
a.error("平台不支持定位", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
3377
3377
|
return;
|
|
3378
3378
|
}
|
|
3379
|
-
const e =
|
|
3379
|
+
const e = In(t);
|
|
3380
3380
|
a.info("开始获取位置", {
|
|
3381
3381
|
platform: l.type,
|
|
3382
3382
|
type: e.type,
|
|
3383
3383
|
altitude: e.altitude
|
|
3384
|
-
}), C() ?
|
|
3384
|
+
}), C() ? Et(e) : Cn(e);
|
|
3385
3385
|
}, {
|
|
3386
3386
|
context: "getLocation",
|
|
3387
3387
|
options: t
|
|
3388
3388
|
});
|
|
3389
3389
|
}
|
|
3390
|
-
function
|
|
3390
|
+
function Rn(t = {}) {
|
|
3391
3391
|
return u.safeExecute(() => {
|
|
3392
3392
|
var r, n, i;
|
|
3393
|
-
if (!
|
|
3393
|
+
if (!xe()) {
|
|
3394
3394
|
const s = {
|
|
3395
3395
|
errMsg: `当前环境 (${l.type}) 不支持查看位置功能`,
|
|
3396
3396
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -3400,7 +3400,7 @@ function Cn(t = {}) {
|
|
|
3400
3400
|
}
|
|
3401
3401
|
let e;
|
|
3402
3402
|
try {
|
|
3403
|
-
e =
|
|
3403
|
+
e = _n(t);
|
|
3404
3404
|
} catch (s) {
|
|
3405
3405
|
a.error("参数验证失败", s), (n = t.fail) == null || n.call(t, s), (i = t.complete) == null || i.call(t);
|
|
3406
3406
|
return;
|
|
@@ -3410,16 +3410,16 @@ function Cn(t = {}) {
|
|
|
3410
3410
|
latitude: e.latitude,
|
|
3411
3411
|
longitude: e.longitude,
|
|
3412
3412
|
name: e.name
|
|
3413
|
-
}), C() ?
|
|
3413
|
+
}), C() ? yt(e) : On(e);
|
|
3414
3414
|
}, {
|
|
3415
3415
|
context: "openLocation",
|
|
3416
3416
|
options: t
|
|
3417
3417
|
});
|
|
3418
3418
|
}
|
|
3419
|
-
function
|
|
3419
|
+
function Nn() {
|
|
3420
3420
|
const t = C();
|
|
3421
3421
|
return {
|
|
3422
|
-
supported:
|
|
3422
|
+
supported: xe(),
|
|
3423
3423
|
environment: l.type,
|
|
3424
3424
|
implementation: t ? "weixin" : "webview",
|
|
3425
3425
|
features: {
|
|
@@ -3438,8 +3438,8 @@ function _n() {
|
|
|
3438
3438
|
}
|
|
3439
3439
|
};
|
|
3440
3440
|
}
|
|
3441
|
-
const k = /* @__PURE__ */ new Set(),
|
|
3442
|
-
function
|
|
3441
|
+
const k = /* @__PURE__ */ new Set(), G = /* @__PURE__ */ new Set();
|
|
3442
|
+
function It(t, e, r) {
|
|
3443
3443
|
t.forEach((n) => {
|
|
3444
3444
|
if (typeof n == "function") {
|
|
3445
3445
|
u.safeExecute(() => n(e), { context: r });
|
|
@@ -3448,7 +3448,7 @@ function pt(t, e, r) {
|
|
|
3448
3448
|
a.warn("监听回调不是函数,已跳过", { type: typeof n });
|
|
3449
3449
|
});
|
|
3450
3450
|
}
|
|
3451
|
-
function
|
|
3451
|
+
function Mn(t = {}) {
|
|
3452
3452
|
return u.safeExecute(() => {
|
|
3453
3453
|
var r, n;
|
|
3454
3454
|
if (C()) {
|
|
@@ -3459,7 +3459,7 @@ function On(t = {}) {
|
|
|
3459
3459
|
a.error("当前环境不支持此接口", { platform: l.type }), (r = t.fail) == null || r.call(t, i), (n = t.complete) == null || n.call(t, i);
|
|
3460
3460
|
return;
|
|
3461
3461
|
}
|
|
3462
|
-
const e =
|
|
3462
|
+
const e = An(t);
|
|
3463
3463
|
a.info("正在开启定位监听"), P("startLocationUpdate", {
|
|
3464
3464
|
type: e.type,
|
|
3465
3465
|
needFullAccuracy: e.needFullAccuracy
|
|
@@ -3476,7 +3476,7 @@ function On(t = {}) {
|
|
|
3476
3476
|
});
|
|
3477
3477
|
}, { context: "startLocationUpdate" });
|
|
3478
3478
|
}
|
|
3479
|
-
function
|
|
3479
|
+
function Sn(t = {}) {
|
|
3480
3480
|
return u.safeExecute(() => {
|
|
3481
3481
|
var e, r;
|
|
3482
3482
|
if (C()) {
|
|
@@ -3500,7 +3500,7 @@ function Pn(t = {}) {
|
|
|
3500
3500
|
});
|
|
3501
3501
|
}, { context: "stopLocationUpdate" });
|
|
3502
3502
|
}
|
|
3503
|
-
function
|
|
3503
|
+
function Tn(t) {
|
|
3504
3504
|
return u.safeExecute(() => {
|
|
3505
3505
|
if (C()) {
|
|
3506
3506
|
a.warn("当前环境不支持此接口", { platform: l.type });
|
|
@@ -3514,7 +3514,7 @@ function Rn(t) {
|
|
|
3514
3514
|
const e = k.size > 0;
|
|
3515
3515
|
k.add(t), e || (a.debug("注册实时位置变化监听器"), P("onLocationChange", { isPersistent: !0 }, {
|
|
3516
3516
|
success: (r) => {
|
|
3517
|
-
a.debug("收到实时位置推送", r),
|
|
3517
|
+
a.debug("收到实时位置推送", r), It(k, r, "onLocationChange");
|
|
3518
3518
|
},
|
|
3519
3519
|
fail: (r) => {
|
|
3520
3520
|
a.warn("位置变化监听出错,请通过 onLocationChangeError 监听错误", r), k.delete(t), k.size === 0 && ee("onLocationChange");
|
|
@@ -3522,7 +3522,7 @@ function Rn(t) {
|
|
|
3522
3522
|
}));
|
|
3523
3523
|
}, { context: "onLocationChange" });
|
|
3524
3524
|
}
|
|
3525
|
-
function
|
|
3525
|
+
function Ln(t) {
|
|
3526
3526
|
return u.safeExecute(() => {
|
|
3527
3527
|
if (C()) {
|
|
3528
3528
|
a.warn("当前环境不支持此接口", { platform: l.type });
|
|
@@ -3543,7 +3543,7 @@ function Nn(t) {
|
|
|
3543
3543
|
}));
|
|
3544
3544
|
}, { context: "offLocationChange" });
|
|
3545
3545
|
}
|
|
3546
|
-
function
|
|
3546
|
+
function bn(t) {
|
|
3547
3547
|
return u.safeExecute(() => {
|
|
3548
3548
|
if (C()) {
|
|
3549
3549
|
a.warn("当前环境不支持此接口", { platform: l.type });
|
|
@@ -3554,18 +3554,18 @@ function Mn(t) {
|
|
|
3554
3554
|
errMsg: "onLocationChangeError 回调必须是函数",
|
|
3555
3555
|
code: "INVALID_CALLBACK"
|
|
3556
3556
|
};
|
|
3557
|
-
const e =
|
|
3558
|
-
|
|
3557
|
+
const e = G.size > 0;
|
|
3558
|
+
G.add(t), e || (a.debug("注册位置更新错误监听器"), P("onLocationChangeError", { isPersistent: !0 }, {
|
|
3559
3559
|
success: (r) => {
|
|
3560
|
-
a.warn("持续定位发生异常", r),
|
|
3560
|
+
a.warn("持续定位发生异常", r), It(G, r, "onLocationChangeError");
|
|
3561
3561
|
},
|
|
3562
3562
|
fail: (r) => {
|
|
3563
|
-
a.warn("位置更新错误监听注册失败", r),
|
|
3563
|
+
a.warn("位置更新错误监听注册失败", r), G.delete(t), G.size === 0 && ee("onLocationChangeError");
|
|
3564
3564
|
}
|
|
3565
3565
|
}));
|
|
3566
3566
|
}, { context: "onLocationChangeError" });
|
|
3567
3567
|
}
|
|
3568
|
-
function
|
|
3568
|
+
function vn(t) {
|
|
3569
3569
|
return u.safeExecute(() => {
|
|
3570
3570
|
if (C()) {
|
|
3571
3571
|
a.warn("当前环境不支持此接口", { platform: l.type });
|
|
@@ -3576,7 +3576,7 @@ function Sn(t) {
|
|
|
3576
3576
|
errMsg: "offLocationChangeError 回调必须是函数",
|
|
3577
3577
|
code: "INVALID_CALLBACK"
|
|
3578
3578
|
};
|
|
3579
|
-
t ?
|
|
3579
|
+
t ? G.delete(t) : G.clear(), !(G.size > 0) && (a.info("移除定位错误监听器"), P("offLocationChangeError", {}, {
|
|
3580
3580
|
success: () => {
|
|
3581
3581
|
a.info("定位错误监听已移除"), ee("onLocationChangeError");
|
|
3582
3582
|
},
|
|
@@ -3586,14 +3586,14 @@ function Sn(t) {
|
|
|
3586
3586
|
}));
|
|
3587
3587
|
}, { context: "offLocationChangeError" });
|
|
3588
3588
|
}
|
|
3589
|
-
const
|
|
3589
|
+
const xn = {
|
|
3590
3590
|
latitude: null,
|
|
3591
3591
|
// 目标地纬度
|
|
3592
3592
|
longitude: null
|
|
3593
3593
|
// 目标地经度
|
|
3594
3594
|
};
|
|
3595
|
-
function
|
|
3596
|
-
const e =
|
|
3595
|
+
function Dn(t = {}) {
|
|
3596
|
+
const e = g(g({}, xn), t);
|
|
3597
3597
|
return e.latitude !== null && e.latitude !== void 0 && (typeof e.latitude != "number" ? (a.warn("latitude 参数类型错误,已忽略", {
|
|
3598
3598
|
latitude: e.latitude
|
|
3599
3599
|
}), e.latitude = null) : (e.latitude < -90 || e.latitude > 90) && (a.warn("latitude 超出范围,已忽略", {
|
|
@@ -3604,10 +3604,10 @@ function Ln(t = {}) {
|
|
|
3604
3604
|
longitude: e.longitude
|
|
3605
3605
|
}), e.longitude = null)), e;
|
|
3606
3606
|
}
|
|
3607
|
-
function
|
|
3607
|
+
function At() {
|
|
3608
3608
|
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
3609
3609
|
}
|
|
3610
|
-
function
|
|
3610
|
+
function _t(t) {
|
|
3611
3611
|
return u.safeExecute(() => {
|
|
3612
3612
|
var n;
|
|
3613
3613
|
if (!window.wx) {
|
|
@@ -3619,7 +3619,7 @@ function Et(t) {
|
|
|
3619
3619
|
return;
|
|
3620
3620
|
}
|
|
3621
3621
|
if (!j()) {
|
|
3622
|
-
a.info("等待微信配置完成"),
|
|
3622
|
+
a.info("等待微信配置完成"), K().then(() => _t(t)).catch((i) => {
|
|
3623
3623
|
var s;
|
|
3624
3624
|
a.error("微信配置失败", i), (s = t.fail) == null || s.call(t, { errMsg: `微信配置失败: ${i.message}` });
|
|
3625
3625
|
});
|
|
@@ -3654,7 +3654,7 @@ function Et(t) {
|
|
|
3654
3654
|
},
|
|
3655
3655
|
complete: t.complete
|
|
3656
3656
|
}, r = {};
|
|
3657
|
-
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(
|
|
3657
|
+
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(g({}, r), {
|
|
3658
3658
|
success: e.success,
|
|
3659
3659
|
fail: e.fail,
|
|
3660
3660
|
complete: e.complete
|
|
@@ -3664,7 +3664,7 @@ function Et(t) {
|
|
|
3664
3664
|
platform: "weixin"
|
|
3665
3665
|
});
|
|
3666
3666
|
}
|
|
3667
|
-
function
|
|
3667
|
+
function Un(t) {
|
|
3668
3668
|
return u.safeExecute(() => {
|
|
3669
3669
|
a.debug("通过 WebView 桥接调用位置选择", t);
|
|
3670
3670
|
const e = {
|
|
@@ -3699,10 +3699,10 @@ function bn(t) {
|
|
|
3699
3699
|
platform: "uniapp"
|
|
3700
3700
|
});
|
|
3701
3701
|
}
|
|
3702
|
-
function
|
|
3702
|
+
function Wn(t = {}) {
|
|
3703
3703
|
return u.safeExecute(() => {
|
|
3704
3704
|
var r;
|
|
3705
|
-
if (!
|
|
3705
|
+
if (!At()) {
|
|
3706
3706
|
const n = {
|
|
3707
3707
|
errMsg: `当前环境 (${l.type}) 不支持位置选择功能`,
|
|
3708
3708
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -3710,20 +3710,20 @@ function vn(t = {}) {
|
|
|
3710
3710
|
a.error("平台不支持位置选择", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
3711
3711
|
return;
|
|
3712
3712
|
}
|
|
3713
|
-
const e =
|
|
3713
|
+
const e = Dn(t);
|
|
3714
3714
|
a.info("开始选择位置", {
|
|
3715
3715
|
platform: l.type,
|
|
3716
3716
|
latitude: e.latitude,
|
|
3717
3717
|
longitude: e.longitude
|
|
3718
|
-
}), C() ?
|
|
3718
|
+
}), C() ? _t(e) : Un(e);
|
|
3719
3719
|
}, {
|
|
3720
3720
|
context: "chooseLocation",
|
|
3721
3721
|
options: t
|
|
3722
3722
|
});
|
|
3723
3723
|
}
|
|
3724
|
-
function
|
|
3724
|
+
function $n() {
|
|
3725
3725
|
return {
|
|
3726
|
-
supported:
|
|
3726
|
+
supported: At(),
|
|
3727
3727
|
environment: l.type,
|
|
3728
3728
|
implementation: C() ? "weixin" : "webview",
|
|
3729
3729
|
features: {
|
|
@@ -3736,13 +3736,13 @@ function xn() {
|
|
|
3736
3736
|
}
|
|
3737
3737
|
};
|
|
3738
3738
|
}
|
|
3739
|
-
function
|
|
3739
|
+
function Fn(t) {
|
|
3740
3740
|
return t === "timeline" || Number(t) === 1 ? 1 : 0;
|
|
3741
3741
|
}
|
|
3742
|
-
function
|
|
3742
|
+
function Bn(t = {}) {
|
|
3743
3743
|
if (!t || typeof t != "object")
|
|
3744
3744
|
throw { errMsg: "shareDirected 参数必须是对象", code: "PARAM_TYPE_ERROR" };
|
|
3745
|
-
const e = String(t.kind || "").trim(), r = t.payload || {}, n =
|
|
3745
|
+
const e = String(t.kind || "").trim(), r = t.payload || {}, n = Fn(t.scene);
|
|
3746
3746
|
if (!["web", "image", "text"].includes(e))
|
|
3747
3747
|
throw { errMsg: 'shareDirected: kind 仅支持 "web"|"image"|"text"', code: "PARAM_INVALID" };
|
|
3748
3748
|
if (e === "web") {
|
|
@@ -3764,27 +3764,58 @@ function Un(t = {}) {
|
|
|
3764
3764
|
complete: t.complete
|
|
3765
3765
|
};
|
|
3766
3766
|
}
|
|
3767
|
-
function
|
|
3767
|
+
function kn(t) {
|
|
3768
3768
|
return t.isWeixinMiniProgram ? "已同步分享内容,请点击右上角“···”选择发送给朋友或分享到朋友圈。" : "正在拉起微信分享面板,请选择聊天框或朋友圈。";
|
|
3769
3769
|
}
|
|
3770
|
-
function
|
|
3770
|
+
function Gn(t) {
|
|
3771
|
+
return {
|
|
3772
|
+
type: "qsh_api_call",
|
|
3773
|
+
api: "shareDirected",
|
|
3774
|
+
params: {
|
|
3775
|
+
kind: t.kind,
|
|
3776
|
+
scene: t.scene,
|
|
3777
|
+
payload: t.payload
|
|
3778
|
+
},
|
|
3779
|
+
timestamp: Date.now()
|
|
3780
|
+
};
|
|
3781
|
+
}
|
|
3782
|
+
function Kn(t) {
|
|
3783
|
+
const e = typeof window != "undefined" && window.wx && window.wx.miniProgram;
|
|
3784
|
+
if (!e || typeof e.postMessage != "function")
|
|
3785
|
+
throw {
|
|
3786
|
+
errMsg: "当前微信小程序容器未注入 postMessage 能力,无法发起 shareDirected",
|
|
3787
|
+
code: "MINIPROGRAM_BRIDGE_UNAVAILABLE"
|
|
3788
|
+
};
|
|
3789
|
+
e.postMessage({
|
|
3790
|
+
data: [t]
|
|
3791
|
+
});
|
|
3792
|
+
}
|
|
3793
|
+
function Ct(t = {}) {
|
|
3771
3794
|
return u.safeExecute(() => {
|
|
3772
|
-
var i, s, c;
|
|
3795
|
+
var i, s, c, h, f, A, M;
|
|
3773
3796
|
let e;
|
|
3774
3797
|
try {
|
|
3775
|
-
e =
|
|
3776
|
-
} catch (
|
|
3777
|
-
return (i = t.fail) == null || i.call(t,
|
|
3798
|
+
e = Bn(t);
|
|
3799
|
+
} catch (m) {
|
|
3800
|
+
return (i = t.fail) == null || i.call(t, m), Promise.reject(m);
|
|
3778
3801
|
}
|
|
3779
|
-
const r = ne(!0), n =
|
|
3780
|
-
if (r.
|
|
3781
|
-
|
|
3802
|
+
const r = ne(!0), n = kn(r);
|
|
3803
|
+
if (r.isWeixinMiniProgram)
|
|
3804
|
+
try {
|
|
3805
|
+
Kn(Gn(e));
|
|
3806
|
+
const m = { success: !0, hint: n };
|
|
3807
|
+
return (s = e.success) == null || s.call(e, m), (c = e.complete) == null || c.call(e, m), Promise.resolve(m);
|
|
3808
|
+
} catch (m) {
|
|
3809
|
+
return (h = e.fail) == null || h.call(e, m), (f = e.complete) == null || f.call(e, m), Promise.reject(m);
|
|
3810
|
+
}
|
|
3811
|
+
if (r.type === "h5" && !r.isUniAppWebView && !r.isOfflineWebview) {
|
|
3812
|
+
const m = {
|
|
3782
3813
|
errMsg: "当前页面不在宿主 WebView 中,无法分享。请在 unified-platform-app 内打开该 H5 再重试。",
|
|
3783
3814
|
code: "NOT_IN_CONTAINER"
|
|
3784
3815
|
};
|
|
3785
|
-
return (
|
|
3816
|
+
return (A = e.fail) == null || A.call(e, m), (M = e.complete) == null || M.call(e, m), Promise.reject(m);
|
|
3786
3817
|
}
|
|
3787
|
-
return new Promise((
|
|
3818
|
+
return new Promise((m, ie) => {
|
|
3788
3819
|
P(
|
|
3789
3820
|
"shareDirected",
|
|
3790
3821
|
{
|
|
@@ -3793,14 +3824,14 @@ function yt(t = {}) {
|
|
|
3793
3824
|
payload: e.payload
|
|
3794
3825
|
},
|
|
3795
3826
|
{
|
|
3796
|
-
success: (
|
|
3797
|
-
var
|
|
3798
|
-
const
|
|
3799
|
-
(
|
|
3827
|
+
success: (ae) => {
|
|
3828
|
+
var se, Ge;
|
|
3829
|
+
const Z = p(g({}, ae), { hint: n });
|
|
3830
|
+
(se = e.success) == null || se.call(e, Z), (Ge = e.complete) == null || Ge.call(e, Z), m(Z);
|
|
3800
3831
|
},
|
|
3801
|
-
fail: (
|
|
3802
|
-
var
|
|
3803
|
-
(
|
|
3832
|
+
fail: (ae) => {
|
|
3833
|
+
var Z, se;
|
|
3834
|
+
(Z = e.fail) == null || Z.call(e, ae), (se = e.complete) == null || se.call(e, ae), ie(ae);
|
|
3804
3835
|
}
|
|
3805
3836
|
}
|
|
3806
3837
|
);
|
|
@@ -3810,15 +3841,15 @@ function yt(t = {}) {
|
|
|
3810
3841
|
options: t
|
|
3811
3842
|
});
|
|
3812
3843
|
}
|
|
3813
|
-
function
|
|
3844
|
+
function zn(t = {}) {
|
|
3814
3845
|
return new Promise((e, r) => {
|
|
3815
|
-
|
|
3846
|
+
Ct(p(g({}, t), {
|
|
3816
3847
|
success: e,
|
|
3817
3848
|
fail: r
|
|
3818
3849
|
}));
|
|
3819
3850
|
});
|
|
3820
3851
|
}
|
|
3821
|
-
const
|
|
3852
|
+
const Vn = {
|
|
3822
3853
|
OFF: "off",
|
|
3823
3854
|
// 蓝牙关闭
|
|
3824
3855
|
ON: "on",
|
|
@@ -3827,19 +3858,19 @@ const Fn = {
|
|
|
3827
3858
|
// 不支持蓝牙
|
|
3828
3859
|
UNAUTHORIZED: "unauthorized"
|
|
3829
3860
|
// 未授权
|
|
3830
|
-
},
|
|
3861
|
+
}, qn = {
|
|
3831
3862
|
allowDuplicatesKey: !1,
|
|
3832
3863
|
// 是否允许重复上报同一设备
|
|
3833
3864
|
services: []
|
|
3834
3865
|
// 指定服务 UUID 列表
|
|
3835
3866
|
};
|
|
3836
|
-
function
|
|
3837
|
-
return
|
|
3867
|
+
function Re(t = {}) {
|
|
3868
|
+
return g(g({}, qn), t);
|
|
3838
3869
|
}
|
|
3839
|
-
function
|
|
3870
|
+
function he() {
|
|
3840
3871
|
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
3841
3872
|
}
|
|
3842
|
-
function
|
|
3873
|
+
function Jn(t) {
|
|
3843
3874
|
return u.safeExecute(() => w(null, null, function* () {
|
|
3844
3875
|
var e;
|
|
3845
3876
|
if (!window.wx) {
|
|
@@ -3847,9 +3878,9 @@ function kn(t) {
|
|
|
3847
3878
|
(e = t.fail) == null || e.call(t, r);
|
|
3848
3879
|
return;
|
|
3849
3880
|
}
|
|
3850
|
-
j() || (a.info("等待微信配置完成"), yield
|
|
3881
|
+
j() || (a.info("等待微信配置完成"), yield K()), wx.openBluetoothAdapter({
|
|
3851
3882
|
success: () => {
|
|
3852
|
-
a.info("微信蓝牙适配器已打开"),
|
|
3883
|
+
a.info("微信蓝牙适配器已打开"), Ot(t);
|
|
3853
3884
|
},
|
|
3854
3885
|
fail: (r) => {
|
|
3855
3886
|
var n;
|
|
@@ -3858,7 +3889,7 @@ function kn(t) {
|
|
|
3858
3889
|
});
|
|
3859
3890
|
}), { context: "openBluetoothAdapterInWeixin" });
|
|
3860
3891
|
}
|
|
3861
|
-
function
|
|
3892
|
+
function jn(t) {
|
|
3862
3893
|
return u.safeExecute(() => {
|
|
3863
3894
|
a.debug("通过 WebView 桥接调用蓝牙功能", t), P("bluetooth", t, {
|
|
3864
3895
|
success: (e) => {
|
|
@@ -3873,7 +3904,7 @@ function Kn(t) {
|
|
|
3873
3904
|
});
|
|
3874
3905
|
}, { context: "bluetoothInUniApp" });
|
|
3875
3906
|
}
|
|
3876
|
-
function
|
|
3907
|
+
function Hn(t) {
|
|
3877
3908
|
return u.safeExecute(() => {
|
|
3878
3909
|
var e;
|
|
3879
3910
|
a.debug("通过 WebView 桥接调用蓝牙设备搜索功能", t), P("bluetoothDevicesDiscovery", {
|
|
@@ -3895,11 +3926,11 @@ function Gn(t) {
|
|
|
3895
3926
|
});
|
|
3896
3927
|
}, { context: "startBluetoothDevicesDiscoveryInUniApp" });
|
|
3897
3928
|
}
|
|
3898
|
-
const
|
|
3899
|
-
function
|
|
3929
|
+
const pe = /* @__PURE__ */ new Set();
|
|
3930
|
+
function Yn(t, e = {}) {
|
|
3900
3931
|
return u.safeExecute(() => {
|
|
3901
3932
|
var r;
|
|
3902
|
-
return
|
|
3933
|
+
return pe.add(t), pe.size === 1 && P("onBluetoothDeviceFound", {
|
|
3903
3934
|
action: "onBluetoothDeviceFound",
|
|
3904
3935
|
isPersistent: !0,
|
|
3905
3936
|
params: {
|
|
@@ -3908,7 +3939,7 @@ function zn(t, e = {}) {
|
|
|
3908
3939
|
}
|
|
3909
3940
|
}, {
|
|
3910
3941
|
success: (n) => {
|
|
3911
|
-
|
|
3942
|
+
pe.forEach((i) => {
|
|
3912
3943
|
typeof i == "function" ? u.safeExecute(() => i(n), { context: "BluetoothDeviceCallback" }) : console.warn("[BluetoothDeviceCallback] 不是函数:", i);
|
|
3913
3944
|
});
|
|
3914
3945
|
},
|
|
@@ -3917,10 +3948,10 @@ function zn(t, e = {}) {
|
|
|
3917
3948
|
console.error("[Bluetooth] 搜索失败:", n), (i = e.fail) == null || i.call(e, n);
|
|
3918
3949
|
},
|
|
3919
3950
|
complete: e.complete
|
|
3920
|
-
}), () =>
|
|
3951
|
+
}), () => pe.delete(t);
|
|
3921
3952
|
}, { context: "qsh_onBluetoothDeviceFound" });
|
|
3922
3953
|
}
|
|
3923
|
-
function
|
|
3954
|
+
function Zn(t) {
|
|
3924
3955
|
return u.safeExecute(() => {
|
|
3925
3956
|
var e;
|
|
3926
3957
|
a.debug("通过 WebView 桥接调用蓝牙连接功能", t), P("bluetoothConnection", {
|
|
@@ -3943,10 +3974,10 @@ function Vn(t) {
|
|
|
3943
3974
|
});
|
|
3944
3975
|
}, { context: "createBLEConnectionInUniApp" });
|
|
3945
3976
|
}
|
|
3946
|
-
function
|
|
3977
|
+
function Xn(t = {}) {
|
|
3947
3978
|
return u.safeExecute(() => {
|
|
3948
3979
|
var r;
|
|
3949
|
-
if (!
|
|
3980
|
+
if (!he()) {
|
|
3950
3981
|
const n = {
|
|
3951
3982
|
errMsg: `当前环境 (${l.type}) 不支持蓝牙功能`,
|
|
3952
3983
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -3954,18 +3985,18 @@ function qn(t = {}) {
|
|
|
3954
3985
|
a.error("平台不支持蓝牙", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
3955
3986
|
return;
|
|
3956
3987
|
}
|
|
3957
|
-
const e =
|
|
3988
|
+
const e = Re(t);
|
|
3958
3989
|
a.info("开始蓝牙操作", {
|
|
3959
3990
|
platform: l.type,
|
|
3960
3991
|
services: e.services,
|
|
3961
3992
|
allowDuplicatesKey: e.allowDuplicatesKey
|
|
3962
|
-
}), C() ?
|
|
3993
|
+
}), C() ? Jn(e) : jn(e);
|
|
3963
3994
|
}, { context: "openBluetoothAdapter", options: t });
|
|
3964
3995
|
}
|
|
3965
|
-
function
|
|
3996
|
+
function Qn(t = {}) {
|
|
3966
3997
|
return u.safeExecute(() => {
|
|
3967
3998
|
var r, n;
|
|
3968
|
-
if (!
|
|
3999
|
+
if (!he()) {
|
|
3969
4000
|
const i = {
|
|
3970
4001
|
errMsg: `当前环境 (${l.type}) 不支持蓝牙功能`,
|
|
3971
4002
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -3973,18 +4004,18 @@ function Jn(t = {}) {
|
|
|
3973
4004
|
a.error("平台不支持蓝牙", { platform: l.type }), (r = t.fail) == null || r.call(t, i), (n = t.complete) == null || n.call(t, i);
|
|
3974
4005
|
return;
|
|
3975
4006
|
}
|
|
3976
|
-
const e =
|
|
4007
|
+
const e = Re(t);
|
|
3977
4008
|
a.info("开始搜索蓝牙设备", {
|
|
3978
4009
|
platform: l.type,
|
|
3979
4010
|
services: e.services,
|
|
3980
4011
|
allowDuplicatesKey: e.allowDuplicatesKey
|
|
3981
|
-
}), C() ? startBluetoothDevicesDiscoveryInWeixin(e) :
|
|
4012
|
+
}), C() ? startBluetoothDevicesDiscoveryInWeixin(e) : Hn(e);
|
|
3982
4013
|
}, { context: "startBluetoothDevicesDiscovery", options: t });
|
|
3983
4014
|
}
|
|
3984
|
-
function
|
|
4015
|
+
function Ot(t, e = {}) {
|
|
3985
4016
|
return u.safeExecute(() => {
|
|
3986
4017
|
var n, i;
|
|
3987
|
-
if (!
|
|
4018
|
+
if (!he()) {
|
|
3988
4019
|
const s = {
|
|
3989
4020
|
errMsg: `当前环境 (${l.type}) 不支持蓝牙功能`,
|
|
3990
4021
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -3992,25 +4023,25 @@ function It(t, e = {}) {
|
|
|
3992
4023
|
a.error("平台不支持蓝牙", { platform: l.type }), (n = e.fail) == null || n.call(e, s), (i = e.complete) == null || i.call(e, s);
|
|
3993
4024
|
return;
|
|
3994
4025
|
}
|
|
3995
|
-
const r =
|
|
3996
|
-
a.info("注册蓝牙设备发现监听", { platform: l.type }), C() ? onBluetoothDeviceFoundInWeixin(r) :
|
|
4026
|
+
const r = Re(e);
|
|
4027
|
+
a.info("注册蓝牙设备发现监听", { platform: l.type }), C() ? onBluetoothDeviceFoundInWeixin(r) : Yn(t, r);
|
|
3997
4028
|
}, { context: "onBluetoothDeviceFound", options: e });
|
|
3998
4029
|
}
|
|
3999
|
-
function
|
|
4030
|
+
function ei(t = {}) {
|
|
4000
4031
|
return u.safeExecute(() => {
|
|
4001
|
-
var s, c,
|
|
4002
|
-
if (!
|
|
4003
|
-
const
|
|
4032
|
+
var s, c, h, f;
|
|
4033
|
+
if (!he()) {
|
|
4034
|
+
const A = {
|
|
4004
4035
|
errMsg: `当前环境 (${l.type}) 不支持蓝牙功能`,
|
|
4005
4036
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
4006
4037
|
};
|
|
4007
|
-
a.error("平台不支持蓝牙连接", { platform: l.type }), (s = t.fail) == null || s.call(t,
|
|
4038
|
+
a.error("平台不支持蓝牙连接", { platform: l.type }), (s = t.fail) == null || s.call(t, A), (c = t.complete) == null || c.call(t, A);
|
|
4008
4039
|
return;
|
|
4009
4040
|
}
|
|
4010
|
-
const e =
|
|
4041
|
+
const e = Re(t), { name: r, deviceId: n, autoConnect: i = !1 } = e;
|
|
4011
4042
|
if (!n) {
|
|
4012
|
-
const
|
|
4013
|
-
(
|
|
4043
|
+
const A = { errMsg: "缺少 deviceId 参数", code: "INVALID_PARAMS" };
|
|
4044
|
+
(h = t.fail) == null || h.call(t, A), (f = t.complete) == null || f.call(t, A);
|
|
4014
4045
|
return;
|
|
4015
4046
|
}
|
|
4016
4047
|
a.info("创建蓝牙连接", { deviceId: n, autoConnect: i, platform: l.type }), C() ? uni.createBLEConnection({
|
|
@@ -4019,12 +4050,12 @@ function jn(t = {}) {
|
|
|
4019
4050
|
success: t.success,
|
|
4020
4051
|
fail: t.fail,
|
|
4021
4052
|
complete: t.complete
|
|
4022
|
-
}) :
|
|
4053
|
+
}) : Zn(e);
|
|
4023
4054
|
}, { context: "createBLEConnection", options: t });
|
|
4024
4055
|
}
|
|
4025
|
-
function
|
|
4056
|
+
function ti() {
|
|
4026
4057
|
return {
|
|
4027
|
-
supported:
|
|
4058
|
+
supported: he(),
|
|
4028
4059
|
environment: l.type,
|
|
4029
4060
|
implementation: C() ? "weixin" : "webview",
|
|
4030
4061
|
features: {
|
|
@@ -4036,18 +4067,18 @@ function Hn() {
|
|
|
4036
4067
|
}
|
|
4037
4068
|
};
|
|
4038
4069
|
}
|
|
4039
|
-
const
|
|
4070
|
+
const ri = {
|
|
4040
4071
|
// TODO: 添加更多默认配置
|
|
4041
4072
|
};
|
|
4042
|
-
function
|
|
4043
|
-
return
|
|
4073
|
+
function ni(t = {}) {
|
|
4074
|
+
return g(g({}, ri), t);
|
|
4044
4075
|
}
|
|
4045
|
-
function
|
|
4076
|
+
function Pt() {
|
|
4046
4077
|
return ["webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
4047
4078
|
}
|
|
4048
|
-
function
|
|
4079
|
+
function ii(t) {
|
|
4049
4080
|
return u.safeExecute(() => {
|
|
4050
|
-
a.debug("通过 WebView 桥接调用打印PDF", t), P("printPdf",
|
|
4081
|
+
a.debug("通过 WebView 桥接调用打印PDF", t), P("printPdf", p(g({}, t), {
|
|
4051
4082
|
isPersistent: !0
|
|
4052
4083
|
// 强制禁用超时自动清理
|
|
4053
4084
|
}), {
|
|
@@ -4066,10 +4097,10 @@ function Xn(t) {
|
|
|
4066
4097
|
platform: "uniapp"
|
|
4067
4098
|
});
|
|
4068
4099
|
}
|
|
4069
|
-
function
|
|
4100
|
+
function ai(t = {}) {
|
|
4070
4101
|
return u.safeExecute(() => {
|
|
4071
4102
|
var r;
|
|
4072
|
-
if (!
|
|
4103
|
+
if (!Pt()) {
|
|
4073
4104
|
const n = {
|
|
4074
4105
|
errMsg: `当前环境 (${l.type}) 不支持打印PDF功能`,
|
|
4075
4106
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -4077,16 +4108,16 @@ function Qn(t = {}) {
|
|
|
4077
4108
|
a.error("平台不支持打印PDF", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
4078
4109
|
return;
|
|
4079
4110
|
}
|
|
4080
|
-
const e =
|
|
4081
|
-
a.info("开始打印PDF", { platform: l.type }),
|
|
4111
|
+
const e = ni(t);
|
|
4112
|
+
a.info("开始打印PDF", { platform: l.type }), ii(e);
|
|
4082
4113
|
}, {
|
|
4083
4114
|
context: "printPdf",
|
|
4084
4115
|
options: t
|
|
4085
4116
|
});
|
|
4086
4117
|
}
|
|
4087
|
-
function
|
|
4118
|
+
function si() {
|
|
4088
4119
|
return {
|
|
4089
|
-
supported:
|
|
4120
|
+
supported: Pt(),
|
|
4090
4121
|
environment: l.type,
|
|
4091
4122
|
implementation: "uniapp",
|
|
4092
4123
|
features: {
|
|
@@ -4094,9 +4125,9 @@ function ei() {
|
|
|
4094
4125
|
}
|
|
4095
4126
|
};
|
|
4096
4127
|
}
|
|
4097
|
-
const
|
|
4098
|
-
function
|
|
4099
|
-
const e =
|
|
4128
|
+
const Te = "/pages/face/index";
|
|
4129
|
+
function oi(t = {}) {
|
|
4130
|
+
const e = g({}, t);
|
|
4100
4131
|
if (!e.name || typeof e.name != "string" || !e.name.trim())
|
|
4101
4132
|
throw {
|
|
4102
4133
|
errMsg: "缺少必需参数:name(姓名)",
|
|
@@ -4109,26 +4140,26 @@ function ti(t = {}) {
|
|
|
4109
4140
|
};
|
|
4110
4141
|
return e.idCardNumber = e.idCardNumber.trim(), e;
|
|
4111
4142
|
}
|
|
4112
|
-
function
|
|
4143
|
+
function Rt() {
|
|
4113
4144
|
return C();
|
|
4114
4145
|
}
|
|
4115
|
-
function
|
|
4146
|
+
function ci() {
|
|
4116
4147
|
return typeof window != "undefined" && window.wx && window.wx.miniProgram && typeof window.wx.miniProgram.navigateTo == "function";
|
|
4117
4148
|
}
|
|
4118
|
-
function
|
|
4119
|
-
const e =
|
|
4149
|
+
function ui(t) {
|
|
4150
|
+
const e = p(g({}, t), {
|
|
4120
4151
|
title: document.title || "",
|
|
4121
4152
|
url: window.location.href || ""
|
|
4122
4153
|
}), r = Object.entries(e).filter(([, n]) => n != null && n !== "").map(([n, i]) => `${encodeURIComponent(n)}=${encodeURIComponent(String(i))}`).join("&");
|
|
4123
|
-
return r ? `${
|
|
4154
|
+
return r ? `${Te}?${r}` : Te;
|
|
4124
4155
|
}
|
|
4125
|
-
function
|
|
4156
|
+
function li(t) {
|
|
4126
4157
|
return u.safeExecute(() => {
|
|
4127
|
-
if (!
|
|
4158
|
+
if (!ci()) {
|
|
4128
4159
|
a.error("微信小程序导航API不可用");
|
|
4129
4160
|
return;
|
|
4130
4161
|
}
|
|
4131
|
-
const e =
|
|
4162
|
+
const e = ui(t);
|
|
4132
4163
|
a.debug("跳转宿主人脸识别页面", {
|
|
4133
4164
|
name: t.name,
|
|
4134
4165
|
targetUrl: e
|
|
@@ -4146,15 +4177,15 @@ function ii(t) {
|
|
|
4146
4177
|
platform: "weixin"
|
|
4147
4178
|
});
|
|
4148
4179
|
}
|
|
4149
|
-
function
|
|
4180
|
+
function fi(t = {}) {
|
|
4150
4181
|
return u.safeExecute(() => {
|
|
4151
|
-
if (!
|
|
4182
|
+
if (!Rt()) {
|
|
4152
4183
|
a.error("平台不支持人脸识别", { platform: l.type });
|
|
4153
4184
|
return;
|
|
4154
4185
|
}
|
|
4155
4186
|
let e;
|
|
4156
4187
|
try {
|
|
4157
|
-
e =
|
|
4188
|
+
e = oi(t);
|
|
4158
4189
|
} catch (r) {
|
|
4159
4190
|
a.error("人脸识别参数校验失败", r);
|
|
4160
4191
|
return;
|
|
@@ -4162,16 +4193,16 @@ function ai(t = {}) {
|
|
|
4162
4193
|
a.info("开始人脸识别", {
|
|
4163
4194
|
platform: l.type,
|
|
4164
4195
|
name: e.name,
|
|
4165
|
-
pagePath:
|
|
4166
|
-
}),
|
|
4196
|
+
pagePath: Te
|
|
4197
|
+
}), li(e);
|
|
4167
4198
|
}, {
|
|
4168
4199
|
context: "faceVerify",
|
|
4169
4200
|
options: t
|
|
4170
4201
|
});
|
|
4171
4202
|
}
|
|
4172
|
-
function
|
|
4203
|
+
function di() {
|
|
4173
4204
|
return {
|
|
4174
|
-
supported:
|
|
4205
|
+
supported: Rt(),
|
|
4175
4206
|
environment: l.type,
|
|
4176
4207
|
implementation: "weixin",
|
|
4177
4208
|
features: {
|
|
@@ -4180,164 +4211,164 @@ function si() {
|
|
|
4180
4211
|
}
|
|
4181
4212
|
};
|
|
4182
4213
|
}
|
|
4183
|
-
const
|
|
4184
|
-
function
|
|
4214
|
+
const Nt = ne();
|
|
4215
|
+
function gi() {
|
|
4185
4216
|
if (typeof window == "undefined" || !ne(!0).isWeixinMiniProgram)
|
|
4186
4217
|
return !1;
|
|
4187
|
-
const e =
|
|
4218
|
+
const e = Me().getRuntimeConfig();
|
|
4188
4219
|
return typeof e.clientId == "string" && e.clientId.length > 0;
|
|
4189
4220
|
}
|
|
4190
|
-
function
|
|
4221
|
+
function hi() {
|
|
4191
4222
|
return w(this, null, function* () {
|
|
4192
|
-
yield
|
|
4223
|
+
yield Qt(), gi() && (yield K());
|
|
4193
4224
|
});
|
|
4194
4225
|
}
|
|
4195
|
-
z.useResponse(
|
|
4196
|
-
let
|
|
4197
|
-
function
|
|
4198
|
-
if (
|
|
4199
|
-
|
|
4200
|
-
{ name: "load-weixin-sdk", run:
|
|
4201
|
-
{ name: "init-bridge", run:
|
|
4226
|
+
z.useResponse(it.response, { priority: 1e3 });
|
|
4227
|
+
let je = !1;
|
|
4228
|
+
function He() {
|
|
4229
|
+
if (je) return;
|
|
4230
|
+
je = !0, Ir([
|
|
4231
|
+
{ name: "load-weixin-sdk", run: tt, timeoutMs: 8e3 },
|
|
4232
|
+
{ name: "init-bridge", run: Qe, timeoutMs: 8e3 }
|
|
4202
4233
|
], {
|
|
4203
4234
|
onError: (e, r) => {
|
|
4204
4235
|
console.error(`[QSH-SDK] 初始化失败(${(r == null ? void 0 : r.name) || "unknown"}):`, e);
|
|
4205
4236
|
}
|
|
4206
4237
|
});
|
|
4207
4238
|
}
|
|
4208
|
-
typeof window != "undefined" && (document.readyState === "complete" || document.readyState === "interactive" ? setTimeout(
|
|
4239
|
+
typeof window != "undefined" && (document.readyState === "complete" || document.readyState === "interactive" ? setTimeout(He, 0) : document.addEventListener("DOMContentLoaded", He));
|
|
4209
4240
|
function I(t, { apiName: e } = {}) {
|
|
4210
4241
|
return function(r = {}, ...n) {
|
|
4211
|
-
const i = r && typeof r == "object" && (typeof r.success == "function" || typeof r.fail == "function" || typeof r.complete == "function"), s = r && typeof r == "object" ? r : {}, c = () => i ? t(s, ...n) : new Promise((
|
|
4212
|
-
const
|
|
4213
|
-
success: (
|
|
4214
|
-
typeof s.success == "function" && s.success(
|
|
4242
|
+
const i = r && typeof r == "object" && (typeof r.success == "function" || typeof r.fail == "function" || typeof r.complete == "function"), s = r && typeof r == "object" ? r : {}, c = () => i ? t(s, ...n) : new Promise((f, A) => {
|
|
4243
|
+
const M = p(g({}, s), {
|
|
4244
|
+
success: (m) => {
|
|
4245
|
+
typeof s.success == "function" && s.success(m), f(m);
|
|
4215
4246
|
},
|
|
4216
|
-
fail: (
|
|
4217
|
-
typeof s.fail == "function" && s.fail(
|
|
4247
|
+
fail: (m) => {
|
|
4248
|
+
typeof s.fail == "function" && s.fail(m), A(m);
|
|
4218
4249
|
},
|
|
4219
4250
|
complete: s.complete
|
|
4220
4251
|
});
|
|
4221
|
-
t(
|
|
4252
|
+
t(M, ...n);
|
|
4222
4253
|
});
|
|
4223
|
-
return (typeof window == "undefined" ? Promise.resolve() :
|
|
4224
|
-
throw console.error(`[QSH-SDK] ${e || "API"} call failed:`,
|
|
4254
|
+
return (typeof window == "undefined" ? Promise.resolve() : Xe()).then(() => c()).catch((f) => {
|
|
4255
|
+
throw console.error(`[QSH-SDK] ${e || "API"} call failed:`, f), f;
|
|
4225
4256
|
});
|
|
4226
4257
|
};
|
|
4227
4258
|
}
|
|
4228
|
-
function
|
|
4259
|
+
function we(t) {
|
|
4229
4260
|
return typeof t == "function" ? { success: t } : t && typeof t == "object" ? t : {};
|
|
4230
4261
|
}
|
|
4231
|
-
const
|
|
4232
|
-
function
|
|
4233
|
-
const e = () =>
|
|
4234
|
-
return (typeof window == "undefined" ? Promise.resolve() :
|
|
4262
|
+
const Mt = I(Gr), St = I(Kr), Tt = I(zr), Lt = I(Vr), bt = I(qr), vt = I(Jr);
|
|
4263
|
+
function xt(t) {
|
|
4264
|
+
const e = () => jr(t);
|
|
4265
|
+
return (typeof window == "undefined" ? Promise.resolve() : Xe()).then(() => e());
|
|
4235
4266
|
}
|
|
4236
|
-
const
|
|
4237
|
-
function
|
|
4267
|
+
const De = I(en, { apiName: "getCode" });
|
|
4268
|
+
function mi(t = {}) {
|
|
4238
4269
|
return new Promise((e, r) => {
|
|
4239
|
-
|
|
4270
|
+
De(p(g({}, t), {
|
|
4240
4271
|
success: e,
|
|
4241
4272
|
fail: r
|
|
4242
4273
|
}));
|
|
4243
4274
|
});
|
|
4244
4275
|
}
|
|
4245
|
-
const
|
|
4276
|
+
const Ue = I(sn, {
|
|
4246
4277
|
apiName: "navigateToMiniProgram"
|
|
4247
4278
|
});
|
|
4248
|
-
function
|
|
4279
|
+
function pi(t = {}) {
|
|
4249
4280
|
return new Promise((e, r) => {
|
|
4250
|
-
|
|
4281
|
+
Ue(p(g({}, t), {
|
|
4251
4282
|
success: e,
|
|
4252
4283
|
fail: r
|
|
4253
4284
|
}));
|
|
4254
4285
|
});
|
|
4255
4286
|
}
|
|
4256
|
-
const
|
|
4257
|
-
function
|
|
4287
|
+
const We = I(ln);
|
|
4288
|
+
function wi(t = {}) {
|
|
4258
4289
|
return new Promise((e, r) => {
|
|
4259
|
-
|
|
4290
|
+
We(p(g({}, t), {
|
|
4260
4291
|
success: e,
|
|
4261
4292
|
fail: r
|
|
4262
4293
|
}));
|
|
4263
4294
|
});
|
|
4264
4295
|
}
|
|
4265
|
-
const
|
|
4266
|
-
function
|
|
4296
|
+
const Dt = I(ai);
|
|
4297
|
+
function Ei(t = {}) {
|
|
4267
4298
|
return new Promise((e, r) => {
|
|
4268
|
-
|
|
4299
|
+
Dt(p(g({}, t), {
|
|
4269
4300
|
success: e,
|
|
4270
4301
|
fail: r
|
|
4271
4302
|
}));
|
|
4272
4303
|
});
|
|
4273
4304
|
}
|
|
4274
|
-
const
|
|
4275
|
-
function
|
|
4305
|
+
const $e = I(pn), yi = I(fi);
|
|
4306
|
+
function Ii(t = {}) {
|
|
4276
4307
|
return new Promise((e, r) => {
|
|
4277
|
-
|
|
4308
|
+
$e(p(g({}, t), {
|
|
4278
4309
|
success: e,
|
|
4279
4310
|
fail: r
|
|
4280
4311
|
}));
|
|
4281
4312
|
});
|
|
4282
4313
|
}
|
|
4283
|
-
const
|
|
4284
|
-
function
|
|
4314
|
+
const Ai = I(Ct, { apiName: "shareDirected" }), _i = I(zn, { apiName: "shareDirectedAsync" }), Fe = I(Pn);
|
|
4315
|
+
function Ci(t = {}) {
|
|
4285
4316
|
return new Promise((e, r) => {
|
|
4286
|
-
|
|
4317
|
+
Fe(p(g({}, t), {
|
|
4287
4318
|
success: e,
|
|
4288
4319
|
fail: r
|
|
4289
4320
|
}));
|
|
4290
4321
|
});
|
|
4291
4322
|
}
|
|
4292
|
-
const
|
|
4293
|
-
function
|
|
4323
|
+
const Be = I(Rn);
|
|
4324
|
+
function Oi(t = {}) {
|
|
4294
4325
|
return new Promise((e, r) => {
|
|
4295
|
-
|
|
4326
|
+
Be(p(g({}, t), {
|
|
4296
4327
|
success: e,
|
|
4297
4328
|
fail: r
|
|
4298
4329
|
}));
|
|
4299
4330
|
});
|
|
4300
4331
|
}
|
|
4301
|
-
const
|
|
4302
|
-
function
|
|
4332
|
+
const ke = I(Wn);
|
|
4333
|
+
function Pi(t = {}) {
|
|
4303
4334
|
return new Promise((e, r) => {
|
|
4304
|
-
|
|
4335
|
+
ke(p(g({}, t), {
|
|
4305
4336
|
success: e,
|
|
4306
4337
|
fail: r
|
|
4307
4338
|
}));
|
|
4308
4339
|
});
|
|
4309
4340
|
}
|
|
4310
|
-
const
|
|
4311
|
-
function
|
|
4341
|
+
const Ut = I(Xn);
|
|
4342
|
+
function Ri(t = {}) {
|
|
4312
4343
|
return new Promise((e, r) => {
|
|
4313
|
-
|
|
4344
|
+
Ut(p(g({}, t), {
|
|
4314
4345
|
success: e,
|
|
4315
4346
|
fail: r
|
|
4316
4347
|
}));
|
|
4317
4348
|
});
|
|
4318
4349
|
}
|
|
4319
|
-
const
|
|
4320
|
-
function
|
|
4350
|
+
const Wt = I(Qn);
|
|
4351
|
+
function Ni(t = {}) {
|
|
4321
4352
|
return new Promise((e, r) => {
|
|
4322
|
-
|
|
4353
|
+
Wt(p(g({}, t), {
|
|
4323
4354
|
success: e,
|
|
4324
4355
|
fail: r
|
|
4325
4356
|
}));
|
|
4326
4357
|
});
|
|
4327
4358
|
}
|
|
4328
|
-
const
|
|
4329
|
-
function
|
|
4359
|
+
const $t = I(Ot);
|
|
4360
|
+
function Mi(t = {}) {
|
|
4330
4361
|
return new Promise((e, r) => {
|
|
4331
|
-
|
|
4362
|
+
$t(p(g({}, t), {
|
|
4332
4363
|
success: e,
|
|
4333
4364
|
fail: r
|
|
4334
4365
|
}));
|
|
4335
4366
|
});
|
|
4336
4367
|
}
|
|
4337
|
-
const
|
|
4338
|
-
function
|
|
4368
|
+
const Ft = I(ei);
|
|
4369
|
+
function Si(t = {}) {
|
|
4339
4370
|
return new Promise((e, r) => {
|
|
4340
|
-
|
|
4371
|
+
Ft(p(g({}, t), {
|
|
4341
4372
|
success: e,
|
|
4342
4373
|
fail: r
|
|
4343
4374
|
}));
|
|
@@ -4345,40 +4376,40 @@ function _i(t = {}) {
|
|
|
4345
4376
|
}
|
|
4346
4377
|
const re = {
|
|
4347
4378
|
// 导航 API
|
|
4348
|
-
navigateTo:
|
|
4349
|
-
navigateBack:
|
|
4350
|
-
switchTab:
|
|
4351
|
-
reLaunch:
|
|
4352
|
-
redirectTo:
|
|
4379
|
+
navigateTo: Mt,
|
|
4380
|
+
navigateBack: St,
|
|
4381
|
+
switchTab: Tt,
|
|
4382
|
+
reLaunch: Lt,
|
|
4383
|
+
redirectTo: bt,
|
|
4353
4384
|
// 消息 API
|
|
4354
|
-
postMessage:
|
|
4355
|
-
getEnv:
|
|
4356
|
-
getCode:
|
|
4357
|
-
getCodeAsync:
|
|
4358
|
-
navigateToMiniProgram:
|
|
4359
|
-
navigateToMiniProgramAsync:
|
|
4385
|
+
postMessage: vt,
|
|
4386
|
+
getEnv: xt,
|
|
4387
|
+
getCode: De,
|
|
4388
|
+
getCodeAsync: mi,
|
|
4389
|
+
navigateToMiniProgram: Ue,
|
|
4390
|
+
navigateToMiniProgramAsync: pi,
|
|
4360
4391
|
// 图片 API
|
|
4361
|
-
chooseImage:
|
|
4362
|
-
chooseImageAsync:
|
|
4392
|
+
chooseImage: We,
|
|
4393
|
+
chooseImageAsync: wi,
|
|
4363
4394
|
// 扫码 API
|
|
4364
|
-
scanCode:
|
|
4365
|
-
scanCodeAsync:
|
|
4395
|
+
scanCode: $e,
|
|
4396
|
+
scanCodeAsync: Ii,
|
|
4366
4397
|
// 位置 API
|
|
4367
|
-
getLocation:
|
|
4368
|
-
getLocationAsync:
|
|
4369
|
-
openLocation:
|
|
4370
|
-
openLocationAsync:
|
|
4371
|
-
chooseLocation:
|
|
4372
|
-
chooseLocationAsync:
|
|
4398
|
+
getLocation: Fe,
|
|
4399
|
+
getLocationAsync: Ci,
|
|
4400
|
+
openLocation: Be,
|
|
4401
|
+
openLocationAsync: Oi,
|
|
4402
|
+
chooseLocation: ke,
|
|
4403
|
+
chooseLocationAsync: Pi,
|
|
4373
4404
|
// 位置监听 API(保留回调签名)
|
|
4374
|
-
onLocationChange: (t) => I((e = {}) =>
|
|
4375
|
-
offLocationChange: (t) => I((e = {}) =>
|
|
4376
|
-
onLocationChangeError: (t) => I((e = {}) =>
|
|
4377
|
-
offLocationChangeError: (t) => I((e = {}) =>
|
|
4378
|
-
startLocationUpdate: I(
|
|
4379
|
-
stopLocationUpdate: I(
|
|
4405
|
+
onLocationChange: (t) => I((e = {}) => Tn(e.success), { apiName: "onLocationChange" })(we(t)),
|
|
4406
|
+
offLocationChange: (t) => I((e = {}) => Ln(e.success), { apiName: "offLocationChange" })(we(t)),
|
|
4407
|
+
onLocationChangeError: (t) => I((e = {}) => bn(e.success), { apiName: "onLocationChangeError" })(we(t)),
|
|
4408
|
+
offLocationChangeError: (t) => I((e = {}) => vn(e.success), { apiName: "offLocationChangeError" })(we(t)),
|
|
4409
|
+
startLocationUpdate: I(Mn, { apiName: "startLocationUpdate" }),
|
|
4410
|
+
stopLocationUpdate: I(Sn, { apiName: "stopLocationUpdate" }),
|
|
4380
4411
|
// 环境信息
|
|
4381
|
-
environment:
|
|
4412
|
+
environment: Nt,
|
|
4382
4413
|
/**
|
|
4383
4414
|
* Wait for SDK readiness.
|
|
4384
4415
|
* In Weixin mini-program web-view, if qsh.config({ clientId }) was called,
|
|
@@ -4388,7 +4419,7 @@ const re = {
|
|
|
4388
4419
|
* await qsh.ready()
|
|
4389
4420
|
* @since 2.0.0
|
|
4390
4421
|
*/
|
|
4391
|
-
ready:
|
|
4422
|
+
ready: hi,
|
|
4392
4423
|
/**
|
|
4393
4424
|
* 手动初始化 JSBridge
|
|
4394
4425
|
* 默认会在 DOM 就绪时自动初始化;如需更早或手动控制,可调用本方法。
|
|
@@ -4397,7 +4428,7 @@ const re = {
|
|
|
4397
4428
|
* await qsh.init()
|
|
4398
4429
|
* @since 2.0.0
|
|
4399
4430
|
*/
|
|
4400
|
-
init:
|
|
4431
|
+
init: Qe,
|
|
4401
4432
|
/**
|
|
4402
4433
|
* 检查 JSBridge 是否就绪
|
|
4403
4434
|
* @returns {boolean}
|
|
@@ -4405,7 +4436,7 @@ const re = {
|
|
|
4405
4436
|
* if (qsh.isReady()) { console.log('ready') }
|
|
4406
4437
|
* @since 2.0.0
|
|
4407
4438
|
*/
|
|
4408
|
-
isReady:
|
|
4439
|
+
isReady: Jt,
|
|
4409
4440
|
/**
|
|
4410
4441
|
* 获取当前 SDK 状态
|
|
4411
4442
|
* @returns {string}
|
|
@@ -4413,8 +4444,8 @@ const re = {
|
|
|
4413
4444
|
* console.log(qsh.getState()) // 'ready'
|
|
4414
4445
|
* @since 2.0.0
|
|
4415
4446
|
*/
|
|
4416
|
-
getState:
|
|
4417
|
-
config:
|
|
4447
|
+
getState: jt,
|
|
4448
|
+
config: ze,
|
|
4418
4449
|
// 微信配置 API
|
|
4419
4450
|
weixin: {
|
|
4420
4451
|
/**
|
|
@@ -4424,8 +4455,8 @@ const re = {
|
|
|
4424
4455
|
* await qsh.weixin.waitForConfig()
|
|
4425
4456
|
* @since 2.0.0
|
|
4426
4457
|
*/
|
|
4427
|
-
config:
|
|
4428
|
-
waitForConfig:
|
|
4458
|
+
config: ze,
|
|
4459
|
+
waitForConfig: K,
|
|
4429
4460
|
/**
|
|
4430
4461
|
* 检查微信配置是否完成
|
|
4431
4462
|
* @returns {boolean}
|
|
@@ -4441,7 +4472,7 @@ const re = {
|
|
|
4441
4472
|
* console.log(qsh.weixin.getConfigState()) // 'configured'
|
|
4442
4473
|
* @since 2.0.0
|
|
4443
4474
|
*/
|
|
4444
|
-
getConfigState:
|
|
4475
|
+
getConfigState: ir,
|
|
4445
4476
|
/**
|
|
4446
4477
|
* 手动重试微信配置
|
|
4447
4478
|
* @returns {Promise<void>}
|
|
@@ -4449,13 +4480,13 @@ const re = {
|
|
|
4449
4480
|
* await qsh.weixin.retryConfig()
|
|
4450
4481
|
* @since 2.0.0
|
|
4451
4482
|
*/
|
|
4452
|
-
retryConfig:
|
|
4483
|
+
retryConfig: ar
|
|
4453
4484
|
},
|
|
4454
4485
|
// WebView 对象(兼容旧版本)
|
|
4455
4486
|
webView: null,
|
|
4456
4487
|
// 图片相关常量
|
|
4457
|
-
ImageSourceTypes:
|
|
4458
|
-
ImageSizeTypes:
|
|
4488
|
+
ImageSourceTypes: Ie,
|
|
4489
|
+
ImageSizeTypes: Ae,
|
|
4459
4490
|
/**
|
|
4460
4491
|
* 获取图片功能能力信息
|
|
4461
4492
|
* @returns {Object} 能力信息对象
|
|
@@ -4464,7 +4495,7 @@ const re = {
|
|
|
4464
4495
|
* console.log('是否支持:', capabilities.supported)
|
|
4465
4496
|
* @since 2.0.0
|
|
4466
4497
|
*/
|
|
4467
|
-
getImageCapabilities:
|
|
4498
|
+
getImageCapabilities: fn,
|
|
4468
4499
|
// 扫码相关常量
|
|
4469
4500
|
ScanTypes: q,
|
|
4470
4501
|
/**
|
|
@@ -4475,7 +4506,7 @@ const re = {
|
|
|
4475
4506
|
* console.log('是否支持:', capabilities.supported)
|
|
4476
4507
|
* @since 2.1.0
|
|
4477
4508
|
*/
|
|
4478
|
-
getScanCapabilities:
|
|
4509
|
+
getScanCapabilities: wn,
|
|
4479
4510
|
// 位置相关常量
|
|
4480
4511
|
CoordinateTypes: te,
|
|
4481
4512
|
/**
|
|
@@ -4486,7 +4517,7 @@ const re = {
|
|
|
4486
4517
|
* console.log('是否支持:', capabilities.supported)
|
|
4487
4518
|
* @since 2.1.0
|
|
4488
4519
|
*/
|
|
4489
|
-
getLocationCapabilities:
|
|
4520
|
+
getLocationCapabilities: Nn,
|
|
4490
4521
|
/**
|
|
4491
4522
|
* 获取位置选择功能能力信息
|
|
4492
4523
|
* @returns {Object} 能力信息对象
|
|
@@ -4495,22 +4526,22 @@ const re = {
|
|
|
4495
4526
|
* console.log('是否支持:', capabilities.supported)
|
|
4496
4527
|
* @since 2.1.0
|
|
4497
4528
|
*/
|
|
4498
|
-
getChooseLocationCapabilities:
|
|
4529
|
+
getChooseLocationCapabilities: $n,
|
|
4499
4530
|
// 蓝牙 API
|
|
4500
|
-
openBluetoothAdapter:
|
|
4501
|
-
openBluetoothAdapterAsync:
|
|
4502
|
-
startBluetoothDevicesDiscovery:
|
|
4503
|
-
startBluetoothDevicesDiscoveryAsync:
|
|
4504
|
-
onBluetoothDeviceFound:
|
|
4505
|
-
onBluetoothDeviceFoundAsync:
|
|
4506
|
-
createBLEConnection:
|
|
4507
|
-
createBLEConnectionAsync:
|
|
4531
|
+
openBluetoothAdapter: Ut,
|
|
4532
|
+
openBluetoothAdapterAsync: Ri,
|
|
4533
|
+
startBluetoothDevicesDiscovery: Wt,
|
|
4534
|
+
startBluetoothDevicesDiscoveryAsync: Ni,
|
|
4535
|
+
onBluetoothDeviceFound: $t,
|
|
4536
|
+
onBluetoothDeviceFoundAsync: Mi,
|
|
4537
|
+
createBLEConnection: Ft,
|
|
4538
|
+
createBLEConnectionAsync: Si,
|
|
4508
4539
|
// 蓝牙相关常量
|
|
4509
|
-
BluetoothStates:
|
|
4540
|
+
BluetoothStates: Vn,
|
|
4510
4541
|
//微信分享(定向模块)
|
|
4511
4542
|
/** 定向分享模块:仅 H5->宿主 WebView,图文/文字/图片到微信会话/朋友圈 */
|
|
4512
|
-
shareDirected:
|
|
4513
|
-
shareDirectedAsync:
|
|
4543
|
+
shareDirected: Ai,
|
|
4544
|
+
shareDirectedAsync: _i,
|
|
4514
4545
|
/**
|
|
4515
4546
|
* 获取蓝牙功能能力信息
|
|
4516
4547
|
* @returns {Object} 能力信息对象
|
|
@@ -4518,10 +4549,10 @@ const re = {
|
|
|
4518
4549
|
* const capabilities = qsh.getBluetoothCapabilities()
|
|
4519
4550
|
* console.log('是否支持:', capabilities.supported)
|
|
4520
4551
|
*/
|
|
4521
|
-
getBluetoothCapabilities:
|
|
4552
|
+
getBluetoothCapabilities: ti,
|
|
4522
4553
|
// 打印PDF API
|
|
4523
|
-
printPdf:
|
|
4524
|
-
printPdfAsync:
|
|
4554
|
+
printPdf: Dt,
|
|
4555
|
+
printPdfAsync: Ei,
|
|
4525
4556
|
/**
|
|
4526
4557
|
* 获取打印PDF功能能力信息
|
|
4527
4558
|
* @returns {Object} 能力信息对象
|
|
@@ -4529,16 +4560,16 @@ const re = {
|
|
|
4529
4560
|
* const capabilities = qsh.getPrintCapabilities()
|
|
4530
4561
|
* console.log('是否支持:', capabilities.supported)
|
|
4531
4562
|
*/
|
|
4532
|
-
getPrintCapabilities:
|
|
4563
|
+
getPrintCapabilities: si,
|
|
4533
4564
|
// 人脸识别 API(仅支持微信小程序环境)
|
|
4534
|
-
faceVerify:
|
|
4535
|
-
getFaceCapabilities:
|
|
4565
|
+
faceVerify: yi,
|
|
4566
|
+
getFaceCapabilities: di,
|
|
4536
4567
|
// 插件系统
|
|
4537
4568
|
plugins: {
|
|
4538
4569
|
/**
|
|
4539
4570
|
* 插件管理器
|
|
4540
4571
|
*/
|
|
4541
|
-
manager:
|
|
4572
|
+
manager: ce,
|
|
4542
4573
|
/**
|
|
4543
4574
|
* 注册插件
|
|
4544
4575
|
* @param {Object} plugin - 插件对象
|
|
@@ -4546,7 +4577,7 @@ const re = {
|
|
|
4546
4577
|
* @example
|
|
4547
4578
|
* qsh.plugins.register(myPlugin)
|
|
4548
4579
|
*/
|
|
4549
|
-
register: (t) =>
|
|
4580
|
+
register: (t) => ce.register(t),
|
|
4550
4581
|
/**
|
|
4551
4582
|
* 安装插件
|
|
4552
4583
|
* @param {string} name - 插件名称
|
|
@@ -4554,14 +4585,14 @@ const re = {
|
|
|
4554
4585
|
* @example
|
|
4555
4586
|
* await qsh.plugins.install('image')
|
|
4556
4587
|
*/
|
|
4557
|
-
install: (t) =>
|
|
4588
|
+
install: (t) => ce.install(t, re),
|
|
4558
4589
|
/**
|
|
4559
4590
|
* 获取插件列表
|
|
4560
4591
|
* @returns {Array} 插件列表
|
|
4561
4592
|
* @example
|
|
4562
4593
|
* console.log(qsh.plugins.list())
|
|
4563
4594
|
*/
|
|
4564
|
-
list: () =>
|
|
4595
|
+
list: () => ce.getPluginList()
|
|
4565
4596
|
},
|
|
4566
4597
|
// 拦截器系统
|
|
4567
4598
|
interceptors: {
|
|
@@ -4597,11 +4628,11 @@ const re = {
|
|
|
4597
4628
|
* 内置拦截器
|
|
4598
4629
|
*/
|
|
4599
4630
|
builtin: {
|
|
4600
|
-
logging:
|
|
4631
|
+
logging: cr,
|
|
4601
4632
|
performance: B,
|
|
4602
|
-
createRetry:
|
|
4603
|
-
createValidation:
|
|
4604
|
-
errorNormalizer:
|
|
4633
|
+
createRetry: ur,
|
|
4634
|
+
createValidation: lr,
|
|
4635
|
+
errorNormalizer: it
|
|
4605
4636
|
}
|
|
4606
4637
|
},
|
|
4607
4638
|
// 观测指标
|
|
@@ -4624,7 +4655,7 @@ const re = {
|
|
|
4624
4655
|
/**
|
|
4625
4656
|
* 错误消息
|
|
4626
4657
|
*/
|
|
4627
|
-
messages:
|
|
4658
|
+
messages: Se,
|
|
4628
4659
|
/**
|
|
4629
4660
|
* 错误分类
|
|
4630
4661
|
*/
|
|
@@ -4637,7 +4668,7 @@ const re = {
|
|
|
4637
4668
|
* @example
|
|
4638
4669
|
* const standardError = qsh.errors.normalize(error, { apiName: 'chooseImage' })
|
|
4639
4670
|
*/
|
|
4640
|
-
normalize:
|
|
4671
|
+
normalize: nt,
|
|
4641
4672
|
/**
|
|
4642
4673
|
* 创建标准错误
|
|
4643
4674
|
* @param {string} code - 错误码
|
|
@@ -4646,7 +4677,7 @@ const re = {
|
|
|
4646
4677
|
* @example
|
|
4647
4678
|
* const error = qsh.errors.create('E_IMG_001', { apiName: 'chooseImage' })
|
|
4648
4679
|
*/
|
|
4649
|
-
create:
|
|
4680
|
+
create: wr,
|
|
4650
4681
|
/**
|
|
4651
4682
|
* 判断是否为标准错误
|
|
4652
4683
|
* @param {any} error - 错误对象
|
|
@@ -4654,7 +4685,7 @@ const re = {
|
|
|
4654
4685
|
* @example
|
|
4655
4686
|
* if (qsh.errors.isStandard(error)) { ... }
|
|
4656
4687
|
*/
|
|
4657
|
-
isStandard:
|
|
4688
|
+
isStandard: Er
|
|
4658
4689
|
},
|
|
4659
4690
|
// 状态管理
|
|
4660
4691
|
store: {
|
|
@@ -4738,8 +4769,8 @@ const re = {
|
|
|
4738
4769
|
getStats: () => ({
|
|
4739
4770
|
logger: T.getStats(),
|
|
4740
4771
|
state: V.getStats(),
|
|
4741
|
-
weixinConfig:
|
|
4742
|
-
plugins:
|
|
4772
|
+
weixinConfig: Me().getStats(),
|
|
4773
|
+
plugins: ce.getStats(),
|
|
4743
4774
|
interceptors: z.getStats(),
|
|
4744
4775
|
store: W.getStats()
|
|
4745
4776
|
}),
|
|
@@ -4749,7 +4780,7 @@ const re = {
|
|
|
4749
4780
|
* @example
|
|
4750
4781
|
* console.log(qsh.debug.getWeixinConfigManager().getStats())
|
|
4751
4782
|
*/
|
|
4752
|
-
getWeixinConfigManager:
|
|
4783
|
+
getWeixinConfigManager: Me,
|
|
4753
4784
|
/**
|
|
4754
4785
|
* 导出调试信息
|
|
4755
4786
|
* @returns {string} JSON 格式的调试信息
|
|
@@ -4759,25 +4790,25 @@ const re = {
|
|
|
4759
4790
|
exportDebugInfo: () => T.exportToJSON()
|
|
4760
4791
|
}
|
|
4761
4792
|
};
|
|
4762
|
-
|
|
4763
|
-
navigateTo:
|
|
4764
|
-
navigateBack:
|
|
4765
|
-
switchTab:
|
|
4766
|
-
reLaunch:
|
|
4767
|
-
redirectTo:
|
|
4768
|
-
postMessage:
|
|
4769
|
-
getEnv:
|
|
4770
|
-
getCode:
|
|
4771
|
-
navigateToMiniProgram:
|
|
4772
|
-
chooseImage:
|
|
4773
|
-
scanCode:
|
|
4774
|
-
getLocation:
|
|
4775
|
-
openLocation:
|
|
4776
|
-
chooseLocation:
|
|
4793
|
+
Nt.isWeixinMiniProgram ? re.webView = window.wx && window.wx.miniProgram : re.webView = {
|
|
4794
|
+
navigateTo: Mt,
|
|
4795
|
+
navigateBack: St,
|
|
4796
|
+
switchTab: Tt,
|
|
4797
|
+
reLaunch: Lt,
|
|
4798
|
+
redirectTo: bt,
|
|
4799
|
+
postMessage: vt,
|
|
4800
|
+
getEnv: xt,
|
|
4801
|
+
getCode: De,
|
|
4802
|
+
navigateToMiniProgram: Ue,
|
|
4803
|
+
chooseImage: We,
|
|
4804
|
+
scanCode: $e,
|
|
4805
|
+
getLocation: Fe,
|
|
4806
|
+
openLocation: Be,
|
|
4807
|
+
chooseLocation: ke
|
|
4777
4808
|
};
|
|
4778
|
-
const
|
|
4779
|
-
Object.keys(
|
|
4780
|
-
re.hasOwnProperty(t) || (re[t] =
|
|
4809
|
+
const Ye = typeof window.uni != "undefined" ? window.uni : {};
|
|
4810
|
+
Object.keys(Ye).forEach((t) => {
|
|
4811
|
+
re.hasOwnProperty(t) || (re[t] = Ye[t]);
|
|
4781
4812
|
});
|
|
4782
4813
|
typeof window != "undefined" && (window.qsh = re);
|
|
4783
4814
|
export {
|