qsh-webview-sdk 2.0.7 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var St = Object.defineProperty, Pt = Object.defineProperties;
|
|
2
|
+
var Tt = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var be = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
5
|
-
var ye = (t, e, r) => e in t ?
|
|
4
|
+
var Lt = Object.prototype.hasOwnProperty, Mt = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var ye = (t, e, r) => e in t ? St(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, p = (t, e) => {
|
|
6
6
|
for (var r in e || (e = {}))
|
|
7
|
-
|
|
7
|
+
Lt.call(e, r) && ye(t, r, e[r]);
|
|
8
8
|
if (be)
|
|
9
9
|
for (var r of be(e))
|
|
10
|
-
|
|
10
|
+
Mt.call(e, r) && ye(t, r, e[r]);
|
|
11
11
|
return t;
|
|
12
|
-
},
|
|
12
|
+
}, A = (t, e) => Pt(t, Tt(e));
|
|
13
13
|
var v = (t, e, r) => ye(t, typeof e != "symbol" ? e + "" : e, r);
|
|
14
14
|
var m = (t, e, r) => new Promise((n, i) => {
|
|
15
|
-
var a = (
|
|
15
|
+
var a = (l) => {
|
|
16
16
|
try {
|
|
17
|
-
d(r.next(
|
|
18
|
-
} catch (
|
|
19
|
-
i(
|
|
17
|
+
d(r.next(l));
|
|
18
|
+
} catch (h) {
|
|
19
|
+
i(h);
|
|
20
20
|
}
|
|
21
|
-
}, g = (
|
|
21
|
+
}, g = (l) => {
|
|
22
22
|
try {
|
|
23
|
-
d(r.throw(
|
|
24
|
-
} catch (
|
|
25
|
-
i(
|
|
23
|
+
d(r.throw(l));
|
|
24
|
+
} catch (h) {
|
|
25
|
+
i(h);
|
|
26
26
|
}
|
|
27
|
-
}, d = (
|
|
27
|
+
}, d = (l) => l.done ? n(l.value) : Promise.resolve(l.value).then(a, g);
|
|
28
28
|
d((r = r.apply(t, e)).next());
|
|
29
29
|
});
|
|
30
30
|
function de() {
|
|
@@ -45,11 +45,11 @@ function ge() {
|
|
|
45
45
|
const t = de();
|
|
46
46
|
return !!(t && t.plus);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function pe() {
|
|
49
49
|
const t = de();
|
|
50
50
|
return !!(t && (t.__dcloud_weex_postMessage || t.__dcloud_weex_));
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function he() {
|
|
53
53
|
const t = de();
|
|
54
54
|
return !!(t && (t.__uniapp_x_postMessage || t.__uniapp_x_));
|
|
55
55
|
}
|
|
@@ -61,26 +61,26 @@ function Ce() {
|
|
|
61
61
|
const t = _e();
|
|
62
62
|
return /Html5Plus/i.test(t);
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function Be() {
|
|
65
65
|
return me() || Ce();
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
return
|
|
67
|
+
function bt() {
|
|
68
|
+
return he() ? "uvue" : pe() ? "nvue" : E() ? "weixin" : ge() ? "plus" : Be() ? "webview" : me() ? "UniApp" : "h5";
|
|
69
69
|
}
|
|
70
70
|
let ae = null;
|
|
71
71
|
function Ne(t = !1) {
|
|
72
72
|
return ae && !t || (ae = {
|
|
73
73
|
isWeixinMiniProgram: E(),
|
|
74
74
|
isAppPlus: ge(),
|
|
75
|
-
isNvue:
|
|
76
|
-
isUvue:
|
|
75
|
+
isNvue: pe(),
|
|
76
|
+
isUvue: he(),
|
|
77
77
|
isUniApp: me(),
|
|
78
78
|
isHtml5Plus: Ce(),
|
|
79
|
-
isUniAppWebView:
|
|
80
|
-
type:
|
|
79
|
+
isUniAppWebView: Be(),
|
|
80
|
+
type: bt()
|
|
81
81
|
}), ae;
|
|
82
82
|
}
|
|
83
|
-
const
|
|
83
|
+
const c = Ne(), U = {
|
|
84
84
|
PLATFORM_NOT_SUPPORTED: "PLATFORM_NOT_SUPPORTED",
|
|
85
85
|
API_CALL_FAILED: "API_CALL_FAILED",
|
|
86
86
|
BRIDGE_NOT_READY: "BRIDGE_NOT_READY",
|
|
@@ -113,28 +113,28 @@ class L extends Error {
|
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
const
|
|
116
|
+
const O = class O {
|
|
117
117
|
/**
|
|
118
118
|
* 设置调试模式
|
|
119
119
|
* @param {boolean} enabled - 是否启用调试模式
|
|
120
120
|
*/
|
|
121
121
|
static setDebugMode(e) {
|
|
122
|
-
|
|
122
|
+
O.isDebugMode = e;
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
125
|
* 添加错误回调
|
|
126
126
|
* @param {Function} callback - 错误处理回调函数
|
|
127
127
|
*/
|
|
128
128
|
static addErrorCallback(e) {
|
|
129
|
-
typeof e == "function" &&
|
|
129
|
+
typeof e == "function" && O.errorCallbacks.push(e);
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
132
|
* 移除错误回调
|
|
133
133
|
* @param {Function} callback - 要移除的回调函数
|
|
134
134
|
*/
|
|
135
135
|
static removeErrorCallback(e) {
|
|
136
|
-
const r =
|
|
137
|
-
r > -1 &&
|
|
136
|
+
const r = O.errorCallbacks.indexOf(e);
|
|
137
|
+
r > -1 && O.errorCallbacks.splice(r, 1);
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
140
|
* 处理 API 调用错误
|
|
@@ -153,7 +153,7 @@ const A = class A {
|
|
|
153
153
|
U.API_CALL_FAILED,
|
|
154
154
|
String(e),
|
|
155
155
|
r
|
|
156
|
-
),
|
|
156
|
+
), O.logError(n), O.notifyCallbacks(n), n;
|
|
157
157
|
}
|
|
158
158
|
/**
|
|
159
159
|
* 处理平台不支持错误
|
|
@@ -167,7 +167,7 @@ const A = class A {
|
|
|
167
167
|
`API "${r}" is not supported on platform "${e}"`,
|
|
168
168
|
{ platformType: e, apiName: r }
|
|
169
169
|
);
|
|
170
|
-
return
|
|
170
|
+
return O.logError(n), O.notifyCallbacks(n), n;
|
|
171
171
|
}
|
|
172
172
|
/**
|
|
173
173
|
* 处理桥接未就绪错误
|
|
@@ -180,7 +180,7 @@ const A = class A {
|
|
|
180
180
|
`Bridge is not ready when calling "${e}"`,
|
|
181
181
|
{ apiName: e }
|
|
182
182
|
);
|
|
183
|
-
return
|
|
183
|
+
return O.logError(r), O.notifyCallbacks(r), r;
|
|
184
184
|
}
|
|
185
185
|
/**
|
|
186
186
|
* 处理参数验证错误
|
|
@@ -196,7 +196,7 @@ const A = class A {
|
|
|
196
196
|
`Invalid parameter "${r}" in "${e}": expected ${n}, got ${typeof i}`,
|
|
197
197
|
{ apiName: e, paramName: r, expectedType: n, actualValue: i }
|
|
198
198
|
);
|
|
199
|
-
return
|
|
199
|
+
return O.logError(a), O.notifyCallbacks(a), a;
|
|
200
200
|
}
|
|
201
201
|
/**
|
|
202
202
|
* 安全地包装函数执行,捕获并处理错误
|
|
@@ -208,7 +208,7 @@ const A = class A {
|
|
|
208
208
|
try {
|
|
209
209
|
return e();
|
|
210
210
|
} catch (n) {
|
|
211
|
-
return
|
|
211
|
+
return O.handleApiError(n, r);
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
/**
|
|
@@ -222,7 +222,7 @@ const A = class A {
|
|
|
222
222
|
try {
|
|
223
223
|
return yield e();
|
|
224
224
|
} catch (i) {
|
|
225
|
-
return
|
|
225
|
+
return O.handleApiError(i, r);
|
|
226
226
|
}
|
|
227
227
|
});
|
|
228
228
|
}
|
|
@@ -234,7 +234,7 @@ const A = class A {
|
|
|
234
234
|
static logError(e) {
|
|
235
235
|
if (typeof console != "undefined") {
|
|
236
236
|
const r = `[QSH-SDK Error] ${e.type}: ${e.message}`;
|
|
237
|
-
|
|
237
|
+
O.isDebugMode ? console.error(r, {
|
|
238
238
|
context: e.context,
|
|
239
239
|
originalError: e.originalError,
|
|
240
240
|
stack: e.stack,
|
|
@@ -248,7 +248,7 @@ const A = class A {
|
|
|
248
248
|
* @private
|
|
249
249
|
*/
|
|
250
250
|
static notifyCallbacks(e) {
|
|
251
|
-
|
|
251
|
+
O.errorCallbacks.forEach((r) => {
|
|
252
252
|
try {
|
|
253
253
|
r(e);
|
|
254
254
|
} catch (n) {
|
|
@@ -265,22 +265,22 @@ const A = class A {
|
|
|
265
265
|
return function(r, n, i) {
|
|
266
266
|
const a = i.value;
|
|
267
267
|
return i.value = function(...g) {
|
|
268
|
-
return
|
|
268
|
+
return O.safeExecute(() => a.apply(this, g), A(p({}, e), { method: n, target: r.constructor.name }));
|
|
269
269
|
}, i;
|
|
270
270
|
};
|
|
271
271
|
}
|
|
272
272
|
};
|
|
273
|
-
v(
|
|
274
|
-
let u =
|
|
275
|
-
const
|
|
273
|
+
v(O, "isDebugMode", !1), v(O, "errorCallbacks", []);
|
|
274
|
+
let u = O;
|
|
275
|
+
const P = {
|
|
276
276
|
UNINITIALIZED: "uninitialized",
|
|
277
277
|
INITIALIZING: "initializing",
|
|
278
278
|
READY: "ready",
|
|
279
279
|
ERROR: "error"
|
|
280
280
|
};
|
|
281
|
-
class
|
|
281
|
+
class vt {
|
|
282
282
|
constructor() {
|
|
283
|
-
this.state =
|
|
283
|
+
this.state = P.UNINITIALIZED, this.readyPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.initializationError = null, this.handleBridgeReady = this.handleBridgeReady.bind(this), this.handleInitializationError = this.handleInitializationError.bind(this);
|
|
284
284
|
}
|
|
285
285
|
/**
|
|
286
286
|
* 获取当前状态
|
|
@@ -294,21 +294,21 @@ class Mt {
|
|
|
294
294
|
* @returns {boolean} 是否就绪
|
|
295
295
|
*/
|
|
296
296
|
isReady() {
|
|
297
|
-
return this.state ===
|
|
297
|
+
return this.state === P.READY;
|
|
298
298
|
}
|
|
299
299
|
/**
|
|
300
300
|
* 检查是否正在初始化
|
|
301
301
|
* @returns {boolean} 是否正在初始化
|
|
302
302
|
*/
|
|
303
303
|
isInitializing() {
|
|
304
|
-
return this.state ===
|
|
304
|
+
return this.state === P.INITIALIZING;
|
|
305
305
|
}
|
|
306
306
|
/**
|
|
307
307
|
* 检查是否出错
|
|
308
308
|
* @returns {boolean} 是否出错
|
|
309
309
|
*/
|
|
310
310
|
hasError() {
|
|
311
|
-
return this.state ===
|
|
311
|
+
return this.state === P.ERROR;
|
|
312
312
|
}
|
|
313
313
|
/**
|
|
314
314
|
* 获取初始化错误
|
|
@@ -333,9 +333,9 @@ class Mt {
|
|
|
333
333
|
*/
|
|
334
334
|
startInitialization(e) {
|
|
335
335
|
return m(this, null, function* () {
|
|
336
|
-
if (this.state !==
|
|
336
|
+
if (this.state !== P.UNINITIALIZED)
|
|
337
337
|
return this.waitForReady();
|
|
338
|
-
this.state =
|
|
338
|
+
this.state = P.INITIALIZING;
|
|
339
339
|
try {
|
|
340
340
|
yield e(), this.handleBridgeReady();
|
|
341
341
|
} catch (r) {
|
|
@@ -349,7 +349,7 @@ class Mt {
|
|
|
349
349
|
* @private
|
|
350
350
|
*/
|
|
351
351
|
handleBridgeReady() {
|
|
352
|
-
this.state ===
|
|
352
|
+
this.state === P.INITIALIZING && (this.state = P.READY, this.readyCallbacks.forEach((e) => {
|
|
353
353
|
try {
|
|
354
354
|
e();
|
|
355
355
|
} catch (r) {
|
|
@@ -363,7 +363,7 @@ class Mt {
|
|
|
363
363
|
* @private
|
|
364
364
|
*/
|
|
365
365
|
handleInitializationError(e) {
|
|
366
|
-
this.state =
|
|
366
|
+
this.state = P.ERROR, this.initializationError = e, this.errorCallbacks.forEach((r) => {
|
|
367
367
|
try {
|
|
368
368
|
r(e);
|
|
369
369
|
} catch (n) {
|
|
@@ -375,7 +375,7 @@ class Mt {
|
|
|
375
375
|
* 重置状态管理器(用于测试或重新初始化)
|
|
376
376
|
*/
|
|
377
377
|
reset() {
|
|
378
|
-
this.state =
|
|
378
|
+
this.state = P.UNINITIALIZED, this.readyPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.initializationError = null;
|
|
379
379
|
}
|
|
380
380
|
/**
|
|
381
381
|
* 添加状态变化监听器
|
|
@@ -390,7 +390,7 @@ class Mt {
|
|
|
390
390
|
const n = () => {
|
|
391
391
|
this.state === e && r(this.state);
|
|
392
392
|
};
|
|
393
|
-
return e ===
|
|
393
|
+
return e === P.READY ? this.readyCallbacks.push(n) : e === P.ERROR && this.errorCallbacks.push(n), () => {
|
|
394
394
|
const i = this.readyCallbacks.indexOf(n);
|
|
395
395
|
i > -1 && this.readyCallbacks.splice(i, 1);
|
|
396
396
|
const a = this.errorCallbacks.indexOf(n);
|
|
@@ -411,7 +411,7 @@ class Mt {
|
|
|
411
411
|
};
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
|
-
const G = new
|
|
414
|
+
const G = new vt(), Fe = () => G.waitForReady(), xt = () => G.isReady(), Dt = () => G.getState(), w = {
|
|
415
415
|
ERROR: 0,
|
|
416
416
|
WARN: 1,
|
|
417
417
|
INFO: 2,
|
|
@@ -423,40 +423,40 @@ const G = new Mt(), ke = () => G.waitForReady(), bt = () => G.isReady(), vt = ()
|
|
|
423
423
|
[w.INFO]: "INFO",
|
|
424
424
|
[w.DEBUG]: "DEBUG",
|
|
425
425
|
[w.TRACE]: "TRACE"
|
|
426
|
-
},
|
|
426
|
+
}, f = class f {
|
|
427
427
|
// 可注入的外部 reporter
|
|
428
428
|
/**
|
|
429
429
|
* 设置日志级别
|
|
430
430
|
* @param {number} level - 日志级别
|
|
431
431
|
*/
|
|
432
432
|
static setLevel(e) {
|
|
433
|
-
e >= w.ERROR && e <= w.TRACE && (
|
|
433
|
+
e >= w.ERROR && e <= w.TRACE && (f.currentLevel = e, f.log(w.INFO, "Logger", `日志级别设置为: ${ee[e]}`));
|
|
434
434
|
}
|
|
435
435
|
/**
|
|
436
436
|
* 启用开发模式(显示所有日志)
|
|
437
437
|
*/
|
|
438
438
|
static enableDevMode() {
|
|
439
|
-
|
|
439
|
+
f.setLevel(w.DEBUG), f.log(w.INFO, "Logger", "开发模式已启用");
|
|
440
440
|
}
|
|
441
441
|
/**
|
|
442
442
|
* 启用生产模式(只显示错误和警告)
|
|
443
443
|
*/
|
|
444
444
|
static enableProdMode() {
|
|
445
|
-
|
|
445
|
+
f.setLevel(w.WARN), f.log(w.INFO, "Logger", "生产模式已启用");
|
|
446
446
|
}
|
|
447
447
|
/**
|
|
448
448
|
* 启用特定模块的日志
|
|
449
449
|
* @param {string} module - 模块名称
|
|
450
450
|
*/
|
|
451
451
|
static enableModule(e) {
|
|
452
|
-
|
|
452
|
+
f.enabledModules.add(e), f.log(w.INFO, "Logger", `模块日志已启用: ${e}`);
|
|
453
453
|
}
|
|
454
454
|
/**
|
|
455
455
|
* 禁用特定模块的日志
|
|
456
456
|
* @param {string} module - 模块名称
|
|
457
457
|
*/
|
|
458
458
|
static disableModule(e) {
|
|
459
|
-
|
|
459
|
+
f.enabledModules.delete(e), f.log(w.INFO, "Logger", `模块日志已禁用: ${e}`);
|
|
460
460
|
}
|
|
461
461
|
/**
|
|
462
462
|
* 检查是否应该记录日志
|
|
@@ -466,7 +466,7 @@ const G = new Mt(), ke = () => G.waitForReady(), bt = () => G.isReady(), vt = ()
|
|
|
466
466
|
* @private
|
|
467
467
|
*/
|
|
468
468
|
static shouldLog(e, r) {
|
|
469
|
-
return e >
|
|
469
|
+
return e > f.currentLevel ? !1 : r && f.enabledModules.size > 0 ? f.enabledModules.has(r) : !0;
|
|
470
470
|
}
|
|
471
471
|
/**
|
|
472
472
|
* 核心日志记录方法
|
|
@@ -477,9 +477,9 @@ const G = new Mt(), ke = () => G.waitForReady(), bt = () => G.isReady(), vt = ()
|
|
|
477
477
|
* @private
|
|
478
478
|
*/
|
|
479
479
|
static log(e, r, n, ...i) {
|
|
480
|
-
if (!
|
|
480
|
+
if (!f.shouldLog(e, r))
|
|
481
481
|
return;
|
|
482
|
-
const a = (/* @__PURE__ */ new Date()).toISOString(), g = ee[e], d = r ? `[${r}]` : "",
|
|
482
|
+
const a = (/* @__PURE__ */ new Date()).toISOString(), g = ee[e], d = r ? `[${r}]` : "", l = `${f.prefix} ${d} ${n}`, h = {
|
|
483
483
|
timestamp: a,
|
|
484
484
|
level: e,
|
|
485
485
|
levelName: g,
|
|
@@ -487,12 +487,12 @@ const G = new Mt(), ke = () => G.waitForReady(), bt = () => G.isReady(), vt = ()
|
|
|
487
487
|
message: n,
|
|
488
488
|
args: i
|
|
489
489
|
};
|
|
490
|
-
if (
|
|
490
|
+
if (f.addToHistory(h), typeof f.reporter == "function")
|
|
491
491
|
try {
|
|
492
|
-
|
|
493
|
-
} catch (
|
|
492
|
+
f.reporter(h);
|
|
493
|
+
} catch (T) {
|
|
494
494
|
}
|
|
495
|
-
|
|
495
|
+
f.outputToConsole(e, l, ...i);
|
|
496
496
|
}
|
|
497
497
|
/**
|
|
498
498
|
* 添加日志到历史记录
|
|
@@ -500,7 +500,7 @@ const G = new Mt(), ke = () => G.waitForReady(), bt = () => G.isReady(), vt = ()
|
|
|
500
500
|
* @private
|
|
501
501
|
*/
|
|
502
502
|
static addToHistory(e) {
|
|
503
|
-
|
|
503
|
+
f.logHistory.push(e), f.logHistory.length > f.maxHistorySize && f.logHistory.shift();
|
|
504
504
|
}
|
|
505
505
|
/**
|
|
506
506
|
* 输出到控制台
|
|
@@ -536,7 +536,7 @@ const G = new Mt(), ke = () => G.waitForReady(), bt = () => G.isReady(), vt = ()
|
|
|
536
536
|
* @param {any[]} args - 额外参数
|
|
537
537
|
*/
|
|
538
538
|
static error(e, r, ...n) {
|
|
539
|
-
|
|
539
|
+
f.log(w.ERROR, e, r, ...n);
|
|
540
540
|
}
|
|
541
541
|
/**
|
|
542
542
|
* 警告级别日志
|
|
@@ -545,7 +545,7 @@ const G = new Mt(), ke = () => G.waitForReady(), bt = () => G.isReady(), vt = ()
|
|
|
545
545
|
* @param {any[]} args - 额外参数
|
|
546
546
|
*/
|
|
547
547
|
static warn(e, r, ...n) {
|
|
548
|
-
|
|
548
|
+
f.log(w.WARN, e, r, ...n);
|
|
549
549
|
}
|
|
550
550
|
/**
|
|
551
551
|
* 信息级别日志
|
|
@@ -554,7 +554,7 @@ const G = new Mt(), ke = () => G.waitForReady(), bt = () => G.isReady(), vt = ()
|
|
|
554
554
|
* @param {any[]} args - 额外参数
|
|
555
555
|
*/
|
|
556
556
|
static info(e, r, ...n) {
|
|
557
|
-
|
|
557
|
+
f.log(w.INFO, e, r, ...n);
|
|
558
558
|
}
|
|
559
559
|
/**
|
|
560
560
|
* 调试级别日志
|
|
@@ -563,7 +563,7 @@ const G = new Mt(), ke = () => G.waitForReady(), bt = () => G.isReady(), vt = ()
|
|
|
563
563
|
* @param {any[]} args - 额外参数
|
|
564
564
|
*/
|
|
565
565
|
static debug(e, r, ...n) {
|
|
566
|
-
|
|
566
|
+
f.log(w.DEBUG, e, r, ...n);
|
|
567
567
|
}
|
|
568
568
|
/**
|
|
569
569
|
* 跟踪级别日志
|
|
@@ -572,7 +572,7 @@ const G = new Mt(), ke = () => G.waitForReady(), bt = () => G.isReady(), vt = ()
|
|
|
572
572
|
* @param {any[]} args - 额外参数
|
|
573
573
|
*/
|
|
574
574
|
static trace(e, r, ...n) {
|
|
575
|
-
|
|
575
|
+
f.log(w.TRACE, e, r, ...n);
|
|
576
576
|
}
|
|
577
577
|
/**
|
|
578
578
|
* 获取日志历史
|
|
@@ -580,13 +580,13 @@ const G = new Mt(), ke = () => G.waitForReady(), bt = () => G.isReady(), vt = ()
|
|
|
580
580
|
* @returns {Array} 日志条目数组
|
|
581
581
|
*/
|
|
582
582
|
static getHistory(e) {
|
|
583
|
-
return e && e > 0 ?
|
|
583
|
+
return e && e > 0 ? f.logHistory.slice(-e) : [...f.logHistory];
|
|
584
584
|
}
|
|
585
585
|
/**
|
|
586
586
|
* 清空日志历史
|
|
587
587
|
*/
|
|
588
588
|
static clearHistory() {
|
|
589
|
-
|
|
589
|
+
f.logHistory = [], f.log(w.INFO, "Logger", "日志历史已清空");
|
|
590
590
|
}
|
|
591
591
|
/**
|
|
592
592
|
* 获取日志统计信息
|
|
@@ -594,15 +594,15 @@ const G = new Mt(), ke = () => G.waitForReady(), bt = () => G.isReady(), vt = ()
|
|
|
594
594
|
*/
|
|
595
595
|
static getStats() {
|
|
596
596
|
const e = {
|
|
597
|
-
currentLevel:
|
|
598
|
-
currentLevelName: ee[
|
|
599
|
-
enabledModules: Array.from(
|
|
600
|
-
historySize:
|
|
601
|
-
maxHistorySize:
|
|
597
|
+
currentLevel: f.currentLevel,
|
|
598
|
+
currentLevelName: ee[f.currentLevel],
|
|
599
|
+
enabledModules: Array.from(f.enabledModules),
|
|
600
|
+
historySize: f.logHistory.length,
|
|
601
|
+
maxHistorySize: f.maxHistorySize
|
|
602
602
|
}, r = {};
|
|
603
603
|
for (const n of Object.keys(ee))
|
|
604
604
|
r[ee[n]] = 0;
|
|
605
|
-
return
|
|
605
|
+
return f.logHistory.forEach((n) => {
|
|
606
606
|
r[n.levelName]++;
|
|
607
607
|
}), e.levelCounts = r, e;
|
|
608
608
|
}
|
|
@@ -612,7 +612,7 @@ const G = new Mt(), ke = () => G.waitForReady(), bt = () => G.isReady(), vt = ()
|
|
|
612
612
|
* @returns {string} JSON 字符串
|
|
613
613
|
*/
|
|
614
614
|
static exportToJSON(e) {
|
|
615
|
-
const r =
|
|
615
|
+
const r = f.getHistory(e), n = f.getStats();
|
|
616
616
|
return JSON.stringify({
|
|
617
617
|
exportTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
618
618
|
stats: n,
|
|
@@ -626,11 +626,11 @@ const G = new Mt(), ke = () => G.waitForReady(), bt = () => G.isReady(), vt = ()
|
|
|
626
626
|
*/
|
|
627
627
|
static createModuleLogger(e) {
|
|
628
628
|
return {
|
|
629
|
-
error: (r, ...n) =>
|
|
630
|
-
warn: (r, ...n) =>
|
|
631
|
-
info: (r, ...n) =>
|
|
632
|
-
debug: (r, ...n) =>
|
|
633
|
-
trace: (r, ...n) =>
|
|
629
|
+
error: (r, ...n) => f.error(e, r, ...n),
|
|
630
|
+
warn: (r, ...n) => f.warn(e, r, ...n),
|
|
631
|
+
info: (r, ...n) => f.info(e, r, ...n),
|
|
632
|
+
debug: (r, ...n) => f.debug(e, r, ...n),
|
|
633
|
+
trace: (r, ...n) => f.trace(e, r, ...n)
|
|
634
634
|
};
|
|
635
635
|
}
|
|
636
636
|
/**
|
|
@@ -638,14 +638,14 @@ const G = new Mt(), ke = () => G.waitForReady(), bt = () => G.isReady(), vt = ()
|
|
|
638
638
|
* @param {(entry: any) => void|null} reporter
|
|
639
639
|
*/
|
|
640
640
|
static setReporter(e) {
|
|
641
|
-
|
|
641
|
+
f.reporter = typeof e == "function" ? e : null;
|
|
642
642
|
}
|
|
643
643
|
};
|
|
644
|
-
v(
|
|
645
|
-
v(
|
|
646
|
-
v(
|
|
647
|
-
v(
|
|
648
|
-
let S =
|
|
644
|
+
v(f, "currentLevel", w.ERROR), // 生产环境默认只显示错误
|
|
645
|
+
v(f, "enabledModules", /* @__PURE__ */ new Set()), // 启用日志的模块
|
|
646
|
+
v(f, "logHistory", []), // 日志历史(最多保留1000条)
|
|
647
|
+
v(f, "maxHistorySize", 1e3), v(f, "prefix", "[QSH-SDK]"), v(f, "reporter", null);
|
|
648
|
+
let S = f;
|
|
649
649
|
if (typeof window != "undefined") {
|
|
650
650
|
const t = window.location && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname.includes("192.168.")), e = window.location && (window.location.search.includes("debug=true") || window.location.search.includes("qsh_debug=1"));
|
|
651
651
|
let r = !1;
|
|
@@ -655,17 +655,17 @@ if (typeof window != "undefined") {
|
|
|
655
655
|
}
|
|
656
656
|
(t || e || r) && S.enableDevMode();
|
|
657
657
|
}
|
|
658
|
-
const y = S.createModuleLogger("Bridge"),
|
|
659
|
-
function
|
|
660
|
-
return me() || Ce() ? (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 &&
|
|
658
|
+
const y = S.createModuleLogger("Bridge"), _ = S.createModuleLogger("Platform"), s = S.createModuleLogger("API"), M = S.createModuleLogger("State"), ke = /complete|loaded|interactive/;
|
|
659
|
+
function Ut(t) {
|
|
660
|
+
return me() || Ce() ? (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 && ke.test(document.readyState) ? (y.debug("Plus 环境已就绪,立即初始化"), setTimeout(t, 0)) : (y.debug("Plus 环境,等待 plusready 事件"), document.addEventListener("plusready", t)), !0) : !1;
|
|
661
661
|
}
|
|
662
|
-
function
|
|
662
|
+
function Wt(t) {
|
|
663
663
|
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;
|
|
664
664
|
}
|
|
665
|
-
function
|
|
666
|
-
return y.info("开始初始化 JSBridge"),
|
|
665
|
+
function $t(t) {
|
|
666
|
+
return y.info("开始初始化 JSBridge"), Ut(t) ? (y.info("使用 APP 环境初始化"), !0) : Wt(t) ? (y.info("使用微信小程序环境初始化"), !0) : (y.debug("使用默认 H5 环境初始化"), ke.test(document.readyState) ? (y.debug("DOM 已就绪,立即初始化"), setTimeout(t, 0)) : (y.debug("DOM 未就绪,等待 DOMContentLoaded"), document.addEventListener("DOMContentLoaded", t)), !0);
|
|
667
667
|
}
|
|
668
|
-
function
|
|
668
|
+
function Bt() {
|
|
669
669
|
return G.waitForReady();
|
|
670
670
|
}
|
|
671
671
|
function ze() {
|
|
@@ -680,7 +680,7 @@ function ze() {
|
|
|
680
680
|
e(a);
|
|
681
681
|
};
|
|
682
682
|
try {
|
|
683
|
-
|
|
683
|
+
$t(() => {
|
|
684
684
|
r();
|
|
685
685
|
});
|
|
686
686
|
} catch (i) {
|
|
@@ -695,7 +695,7 @@ const R = {
|
|
|
695
695
|
CONFIGURED: "configured",
|
|
696
696
|
ERROR: "error"
|
|
697
697
|
};
|
|
698
|
-
class
|
|
698
|
+
class Ft {
|
|
699
699
|
constructor() {
|
|
700
700
|
this.state = R.UNINITIALIZED, this.configPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.lastError = null, this.CONFIG_API_URL = this.getConfigApiUrl(), this.CLIENT_ID = "bmfw-client", 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);
|
|
701
701
|
}
|
|
@@ -727,23 +727,23 @@ class Bt {
|
|
|
727
727
|
return m(this, null, function* () {
|
|
728
728
|
const e = this.getCurrentPageUrl();
|
|
729
729
|
if (this.isTestMode())
|
|
730
|
-
return
|
|
730
|
+
return _.info("使用测试模式,返回模拟配置"), this.getMockConfig();
|
|
731
731
|
const r = `${this.CONFIG_API_URL}?clientId=${this.CLIENT_ID}&url=${encodeURIComponent(e)}`;
|
|
732
|
-
|
|
732
|
+
_.debug("请求微信配置", { url: r });
|
|
733
733
|
try {
|
|
734
734
|
const n = yield fetch(r);
|
|
735
735
|
if (!n.ok)
|
|
736
736
|
throw new Error(`HTTP ${n.status}: ${n.statusText}`);
|
|
737
737
|
const i = yield n.json();
|
|
738
|
-
if (
|
|
738
|
+
if (_.debug("微信配置响应", i), !i.success || i.code !== 200)
|
|
739
739
|
throw new Error(`配置获取失败: ${i.message || "未知错误"}`);
|
|
740
740
|
const { data: a } = i;
|
|
741
741
|
if (!a || !a.appId || !a.timestamp || !a.nonceStr || !a.signature)
|
|
742
742
|
throw new Error("配置数据格式不正确,缺少必需字段");
|
|
743
743
|
return a;
|
|
744
744
|
} catch (n) {
|
|
745
|
-
if (
|
|
746
|
-
return
|
|
745
|
+
if (_.error("获取微信配置失败", n), this.shouldUseTestMode(n))
|
|
746
|
+
return _.warn("网络请求失败,降级到测试模式"), this.getMockConfig();
|
|
747
747
|
throw new L(
|
|
748
748
|
U.NETWORK_ERROR,
|
|
749
749
|
`获取微信配置失败: ${n.message}`,
|
|
@@ -796,7 +796,7 @@ class Bt {
|
|
|
796
796
|
*/
|
|
797
797
|
executeWeixinConfig(e) {
|
|
798
798
|
if (this.isTestMode() || e.appId === "wx_test_app_id") {
|
|
799
|
-
|
|
799
|
+
_.info("测试模式:模拟微信配置成功"), setTimeout(() => {
|
|
800
800
|
this.handleConfigSuccess();
|
|
801
801
|
}, 100);
|
|
802
802
|
return;
|
|
@@ -812,14 +812,14 @@ class Bt {
|
|
|
812
812
|
signature: e.signature,
|
|
813
813
|
jsApiList: this.DEFAULT_JS_API_LIST
|
|
814
814
|
};
|
|
815
|
-
|
|
815
|
+
_.info("执行微信配置", r), window.wx.ready(this.handleConfigSuccess), window.wx.error(this.handleConfigError), window.wx.config(r);
|
|
816
816
|
}
|
|
817
817
|
/**
|
|
818
818
|
* 处理配置成功
|
|
819
819
|
* @private
|
|
820
820
|
*/
|
|
821
821
|
handleConfigSuccess() {
|
|
822
|
-
|
|
822
|
+
_.info("微信配置成功"), this.state = R.CONFIGURED, this.readyCallbacks.forEach((e) => {
|
|
823
823
|
try {
|
|
824
824
|
e();
|
|
825
825
|
} catch (r) {
|
|
@@ -834,7 +834,7 @@ class Bt {
|
|
|
834
834
|
*/
|
|
835
835
|
handleConfigError(e) {
|
|
836
836
|
const r = `微信配置验证失败: ${JSON.stringify(e)}`;
|
|
837
|
-
|
|
837
|
+
_.error(r, e), this.state = R.ERROR, this.lastError = new L(
|
|
838
838
|
U.API_CALL_FAILED,
|
|
839
839
|
r,
|
|
840
840
|
{ weixinErrorResponse: e }
|
|
@@ -916,7 +916,7 @@ class Bt {
|
|
|
916
916
|
* 重置配置管理器(用于重试或测试)
|
|
917
917
|
*/
|
|
918
918
|
reset() {
|
|
919
|
-
this.state = R.UNINITIALIZED, this.configPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.lastError = null,
|
|
919
|
+
this.state = R.UNINITIALIZED, this.configPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.lastError = null, _.debug("微信配置管理器已重置");
|
|
920
920
|
}
|
|
921
921
|
/**
|
|
922
922
|
* 获取配置统计信息
|
|
@@ -935,9 +935,9 @@ class Bt {
|
|
|
935
935
|
};
|
|
936
936
|
}
|
|
937
937
|
}
|
|
938
|
-
const
|
|
938
|
+
const F = new Ft();
|
|
939
939
|
let H = !1, Ie = !1, ue = !1;
|
|
940
|
-
function
|
|
940
|
+
function kt() {
|
|
941
941
|
if (typeof window == "undefined" || Ie || H || window.wx && window.wx.miniProgram) return !1;
|
|
942
942
|
const t = navigator.userAgent || "", e = /micromessenger/i.test(t), r = /miniProgram/i.test(t), n = typeof window.__wxjs_environment != "undefined" && window.__wxjs_environment === "miniprogram";
|
|
943
943
|
return e && (r || n);
|
|
@@ -945,56 +945,56 @@ function $t() {
|
|
|
945
945
|
function Ae() {
|
|
946
946
|
return m(this, null, function* () {
|
|
947
947
|
if (ue)
|
|
948
|
-
return
|
|
949
|
-
ue = !0,
|
|
948
|
+
return F.waitForReady();
|
|
949
|
+
ue = !0, _.info("开始自动配置微信JS-SDK");
|
|
950
950
|
try {
|
|
951
|
-
yield
|
|
951
|
+
yield F.autoConfig(), _.info("微信JS-SDK自动配置完成");
|
|
952
952
|
} catch (t) {
|
|
953
|
-
|
|
953
|
+
_.error("微信JS-SDK自动配置失败", t);
|
|
954
954
|
}
|
|
955
955
|
});
|
|
956
956
|
}
|
|
957
|
-
function
|
|
958
|
-
return
|
|
957
|
+
function zt() {
|
|
958
|
+
return kt() ? document.getElementById("weixin-jssdk") ? (H = !1, Ie = !0, ue ? F.waitForReady() : Ae()) : new Promise((t) => {
|
|
959
959
|
H = !0;
|
|
960
960
|
try {
|
|
961
961
|
const e = document.createElement("script");
|
|
962
962
|
e.id = "weixin-jssdk", e.type = "text/javascript", e.async = !0, e.src = "https://res.wx.qq.com/open/js/jweixin-1.6.2.js", e.onload = function() {
|
|
963
963
|
return m(this, null, function* () {
|
|
964
|
-
Ie = !0, H = !1,
|
|
964
|
+
Ie = !0, H = !1, _.info("微信 JS-SDK 已自动加载");
|
|
965
965
|
try {
|
|
966
966
|
yield Ae();
|
|
967
967
|
} catch (n) {
|
|
968
|
-
|
|
968
|
+
_.error("微信配置失败,将使用消息桥作为后备", n);
|
|
969
969
|
}
|
|
970
970
|
t();
|
|
971
971
|
});
|
|
972
972
|
}, e.onerror = function() {
|
|
973
|
-
H = !1,
|
|
973
|
+
H = !1, _.warn("微信 JS-SDK 加载失败,SDK 将使用消息桥作为后备"), t();
|
|
974
974
|
}, (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(e);
|
|
975
975
|
} catch (e) {
|
|
976
|
-
H = !1,
|
|
976
|
+
H = !1, _.error("注入微信 JS-SDK 失败", e), t();
|
|
977
977
|
}
|
|
978
978
|
}) : Promise.resolve();
|
|
979
979
|
}
|
|
980
|
-
function
|
|
981
|
-
return
|
|
980
|
+
function k() {
|
|
981
|
+
return F.waitForReady();
|
|
982
982
|
}
|
|
983
983
|
function z() {
|
|
984
|
-
return
|
|
984
|
+
return F.isReady();
|
|
985
985
|
}
|
|
986
|
-
function
|
|
987
|
-
return
|
|
986
|
+
function Kt() {
|
|
987
|
+
return F.getState();
|
|
988
988
|
}
|
|
989
989
|
function ve() {
|
|
990
|
-
return
|
|
990
|
+
return F;
|
|
991
991
|
}
|
|
992
|
-
function
|
|
992
|
+
function Gt() {
|
|
993
993
|
return m(this, null, function* () {
|
|
994
|
-
return
|
|
994
|
+
return _.info("手动重试微信配置"), F.reset(), ue = !1, Ae();
|
|
995
995
|
});
|
|
996
996
|
}
|
|
997
|
-
class
|
|
997
|
+
class Vt {
|
|
998
998
|
constructor() {
|
|
999
999
|
this.plugins = /* @__PURE__ */ new Map(), this.installed = /* @__PURE__ */ new Set(), this.installOrder = [], s.debug("插件管理器已初始化");
|
|
1000
1000
|
}
|
|
@@ -1187,8 +1187,8 @@ class Kt {
|
|
|
1187
1187
|
this.plugins.clear(), this.installed.clear(), this.installOrder = [];
|
|
1188
1188
|
}
|
|
1189
1189
|
}
|
|
1190
|
-
const te = new
|
|
1191
|
-
class
|
|
1190
|
+
const te = new Vt();
|
|
1191
|
+
class jt {
|
|
1192
1192
|
constructor() {
|
|
1193
1193
|
this.requestInterceptors = [], this.responseInterceptors = [], s.debug("拦截器链已初始化");
|
|
1194
1194
|
}
|
|
@@ -1248,7 +1248,7 @@ class Gt {
|
|
|
1248
1248
|
*/
|
|
1249
1249
|
runRequest(e) {
|
|
1250
1250
|
return m(this, null, function* () {
|
|
1251
|
-
let r =
|
|
1251
|
+
let r = p({}, e);
|
|
1252
1252
|
for (const { fn: n } of this.requestInterceptors) {
|
|
1253
1253
|
if (r.abort) {
|
|
1254
1254
|
s.debug("请求被中止", { apiName: r.apiName });
|
|
@@ -1302,7 +1302,7 @@ class Gt {
|
|
|
1302
1302
|
};
|
|
1303
1303
|
}
|
|
1304
1304
|
}
|
|
1305
|
-
const K = new
|
|
1305
|
+
const K = new jt(), qt = {
|
|
1306
1306
|
/**
|
|
1307
1307
|
* 请求日志
|
|
1308
1308
|
*/
|
|
@@ -1347,7 +1347,7 @@ const K = new Gt(), Vt = {
|
|
|
1347
1347
|
getReport: () => {
|
|
1348
1348
|
const t = {};
|
|
1349
1349
|
return W.metrics.forEach((e, r) => {
|
|
1350
|
-
t[r] =
|
|
1350
|
+
t[r] = p({}, e);
|
|
1351
1351
|
}), t;
|
|
1352
1352
|
},
|
|
1353
1353
|
/**
|
|
@@ -1357,7 +1357,7 @@ const K = new Gt(), Vt = {
|
|
|
1357
1357
|
W.metrics.clear();
|
|
1358
1358
|
}
|
|
1359
1359
|
};
|
|
1360
|
-
function
|
|
1360
|
+
function Jt(t = {}) {
|
|
1361
1361
|
const {
|
|
1362
1362
|
maxRetries: e = 3,
|
|
1363
1363
|
retryDelay: r = 1e3,
|
|
@@ -1369,7 +1369,7 @@ function jt(t = {}) {
|
|
|
1369
1369
|
})
|
|
1370
1370
|
};
|
|
1371
1371
|
}
|
|
1372
|
-
function
|
|
1372
|
+
function Ht(t = {}) {
|
|
1373
1373
|
return {
|
|
1374
1374
|
request: (e) => {
|
|
1375
1375
|
const r = t[e.apiName];
|
|
@@ -1381,7 +1381,7 @@ function qt(t = {}) {
|
|
|
1381
1381
|
}
|
|
1382
1382
|
};
|
|
1383
1383
|
}
|
|
1384
|
-
class
|
|
1384
|
+
class Yt {
|
|
1385
1385
|
constructor() {
|
|
1386
1386
|
this.state = {
|
|
1387
1387
|
// SDK 状态
|
|
@@ -1393,11 +1393,11 @@ class Jt {
|
|
|
1393
1393
|
},
|
|
1394
1394
|
// 平台信息
|
|
1395
1395
|
platform: {
|
|
1396
|
-
type:
|
|
1397
|
-
isWeixinMiniProgram:
|
|
1398
|
-
isAppPlus:
|
|
1399
|
-
isNvue:
|
|
1400
|
-
isUvue:
|
|
1396
|
+
type: c.type,
|
|
1397
|
+
isWeixinMiniProgram: c.isWeixinMiniProgram,
|
|
1398
|
+
isAppPlus: c.isAppPlus,
|
|
1399
|
+
isNvue: c.isNvue,
|
|
1400
|
+
isUvue: c.isUvue,
|
|
1401
1401
|
features: {}
|
|
1402
1402
|
// 平台支持的特性
|
|
1403
1403
|
},
|
|
@@ -1447,7 +1447,7 @@ class Jt {
|
|
|
1447
1447
|
* store.set('network.online', false)
|
|
1448
1448
|
*/
|
|
1449
1449
|
set(e, r) {
|
|
1450
|
-
const n = e.split("."), i = n.pop(), a = n.reduce((d,
|
|
1450
|
+
const n = e.split("."), i = n.pop(), a = n.reduce((d, l) => ((!d[l] || typeof d[l] != "object") && (d[l] = {}), d[l]), this.state), g = a[i];
|
|
1451
1451
|
g !== r && (a[i] = r, M.debug(`状态已更新: ${e}`, { oldValue: g, newValue: r }), this.notify(e, r, g));
|
|
1452
1452
|
}
|
|
1453
1453
|
/**
|
|
@@ -1516,12 +1516,12 @@ class Jt {
|
|
|
1516
1516
|
});
|
|
1517
1517
|
const a = e.split(".");
|
|
1518
1518
|
for (let g = 1; g < a.length; g++) {
|
|
1519
|
-
const d = a.slice(0, g).join("."),
|
|
1520
|
-
if (
|
|
1521
|
-
const
|
|
1522
|
-
|
|
1519
|
+
const d = a.slice(0, g).join("."), l = this.listeners.get(d);
|
|
1520
|
+
if (l) {
|
|
1521
|
+
const h = this.get(d);
|
|
1522
|
+
l.forEach((T) => {
|
|
1523
1523
|
try {
|
|
1524
|
-
|
|
1524
|
+
T(h, void 0, d);
|
|
1525
1525
|
} catch (N) {
|
|
1526
1526
|
M.error("父路径订阅者执行失败", N);
|
|
1527
1527
|
}
|
|
@@ -1558,7 +1558,7 @@ class Jt {
|
|
|
1558
1558
|
*/
|
|
1559
1559
|
setApiLoading(e, r = !0) {
|
|
1560
1560
|
const n = `api.${e}`, i = this.get(n) || {};
|
|
1561
|
-
this.set(n,
|
|
1561
|
+
this.set(n, A(p({}, i), {
|
|
1562
1562
|
loading: r,
|
|
1563
1563
|
lastCall: r ? Date.now() : i.lastCall
|
|
1564
1564
|
}));
|
|
@@ -1570,7 +1570,7 @@ class Jt {
|
|
|
1570
1570
|
*/
|
|
1571
1571
|
setApiResult(e, r) {
|
|
1572
1572
|
const n = `api.${e}`, i = this.get(n) || {};
|
|
1573
|
-
this.set(n,
|
|
1573
|
+
this.set(n, A(p({}, i), {
|
|
1574
1574
|
loading: !1,
|
|
1575
1575
|
lastResult: r,
|
|
1576
1576
|
lastCallEnd: Date.now()
|
|
@@ -1625,7 +1625,7 @@ class Jt {
|
|
|
1625
1625
|
};
|
|
1626
1626
|
}
|
|
1627
1627
|
}
|
|
1628
|
-
const x = new
|
|
1628
|
+
const x = new Yt(), o = {
|
|
1629
1629
|
// SDK 核心错误 (E_SDK_xxx)
|
|
1630
1630
|
SDK_NOT_READY: "E_SDK_001",
|
|
1631
1631
|
SDK_INIT_FAILED: "E_SDK_002",
|
|
@@ -1732,7 +1732,7 @@ const x = new Jt(), o = {
|
|
|
1732
1732
|
// 配置问题
|
|
1733
1733
|
UNKNOWN: "unknown"
|
|
1734
1734
|
// 未知问题
|
|
1735
|
-
},
|
|
1735
|
+
}, Xt = {
|
|
1736
1736
|
// 图片相关
|
|
1737
1737
|
"IMAGE/USER_CANCEL": o.IMAGE_CANCELLED,
|
|
1738
1738
|
"IMAGE/PERMISSION_DENIED": o.IMAGE_NO_PERMISSION,
|
|
@@ -1780,10 +1780,10 @@ const x = new Jt(), o = {
|
|
|
1780
1780
|
function Ke(t) {
|
|
1781
1781
|
return t ? t.includes("CANCEL") ? b.USER_CANCEL : t.includes("PERM") || t.includes("PERMISSION") ? b.PERMISSION : t.includes("NET") || t.includes("NETWORK") ? b.NETWORK : t.includes("PARAM") ? b.PARAM : t.includes("CONFIG") ? b.CONFIG : t.includes("SDK") || t.includes("PLATFORM") ? b.SYSTEM : b.UNKNOWN : b.UNKNOWN;
|
|
1782
1782
|
}
|
|
1783
|
-
function
|
|
1783
|
+
function Zt(t) {
|
|
1784
1784
|
return t.includes("NET_") || t.includes("TIMEOUT") || t === o.NETWORK_ERROR || t === o.NETWORK_TIMEOUT || t === o.API_TIMEOUT;
|
|
1785
1785
|
}
|
|
1786
|
-
function
|
|
1786
|
+
function Qt(t) {
|
|
1787
1787
|
return t.includes("CANCEL") || Ke(t) === b.USER_CANCEL;
|
|
1788
1788
|
}
|
|
1789
1789
|
function Y(t) {
|
|
@@ -1797,7 +1797,7 @@ class D extends Error {
|
|
|
1797
1797
|
* @param {Object} options - 选项
|
|
1798
1798
|
*/
|
|
1799
1799
|
constructor(e, r, n = {}) {
|
|
1800
|
-
super(r), this.name = "StandardError", this.code = e, this.message = r || Y(e), this.platform = n.platform ||
|
|
1800
|
+
super(r), this.name = "StandardError", this.code = e, this.message = r || Y(e), this.platform = n.platform || c.type, this.apiName = n.apiName, this.category = n.category || Ke(e), this.retriable = n.retriable !== void 0 ? n.retriable : Zt(e), this.originalError = n.originalError, this.details = n.details || {}, this.timestamp = Date.now();
|
|
1801
1801
|
}
|
|
1802
1802
|
/**
|
|
1803
1803
|
* 是否可重试
|
|
@@ -1811,14 +1811,14 @@ class D extends Error {
|
|
|
1811
1811
|
* @returns {boolean}
|
|
1812
1812
|
*/
|
|
1813
1813
|
isUserAction() {
|
|
1814
|
-
return
|
|
1814
|
+
return Qt(this.code);
|
|
1815
1815
|
}
|
|
1816
1816
|
/**
|
|
1817
1817
|
* 转为普通对象
|
|
1818
1818
|
* @returns {Object}
|
|
1819
1819
|
*/
|
|
1820
1820
|
toJSON() {
|
|
1821
|
-
return
|
|
1821
|
+
return p({
|
|
1822
1822
|
code: this.code,
|
|
1823
1823
|
message: this.message,
|
|
1824
1824
|
platform: this.platform,
|
|
@@ -1835,8 +1835,8 @@ class D extends Error {
|
|
|
1835
1835
|
function Ge(t, e = {}) {
|
|
1836
1836
|
if (t instanceof D)
|
|
1837
1837
|
return t;
|
|
1838
|
-
const { apiName: r, platform: n =
|
|
1839
|
-
return t && typeof t.code == "string" && t.code.includes("/") ?
|
|
1838
|
+
const { apiName: r, platform: n = c.type } = e;
|
|
1839
|
+
return t && typeof t.code == "string" && t.code.includes("/") ? er(t, { apiName: r, platform: n }) : t && (t.errMsg || t.message) ? tr(t, { apiName: r, platform: n }) : typeof t == "string" ? new D(
|
|
1840
1840
|
o.UNKNOWN_ERROR,
|
|
1841
1841
|
t,
|
|
1842
1842
|
{ apiName: r, platform: n, originalError: t }
|
|
@@ -1851,8 +1851,8 @@ function Ge(t, e = {}) {
|
|
|
1851
1851
|
}
|
|
1852
1852
|
);
|
|
1853
1853
|
}
|
|
1854
|
-
function
|
|
1855
|
-
const { apiName: r, platform: n } = e, i = t.code, a =
|
|
1854
|
+
function er(t, e) {
|
|
1855
|
+
const { apiName: r, platform: n } = e, i = t.code, a = Xt[i] || o.UNKNOWN_ERROR;
|
|
1856
1856
|
return s.debug("转换旧版错误码", {
|
|
1857
1857
|
legacy: i,
|
|
1858
1858
|
new: a
|
|
@@ -1863,29 +1863,29 @@ function Zt(t, e) {
|
|
|
1863
1863
|
apiName: r,
|
|
1864
1864
|
platform: t.platform || n,
|
|
1865
1865
|
originalError: t,
|
|
1866
|
-
details:
|
|
1866
|
+
details: p({
|
|
1867
1867
|
legacyCode: i,
|
|
1868
1868
|
legacyVersion: t.version
|
|
1869
1869
|
}, t.details)
|
|
1870
1870
|
}
|
|
1871
1871
|
);
|
|
1872
1872
|
}
|
|
1873
|
-
function
|
|
1873
|
+
function tr(t, e) {
|
|
1874
1874
|
const { apiName: r, platform: n } = e, i = (t.errMsg || t.message || "").toLowerCase();
|
|
1875
1875
|
if (r && De[r]) {
|
|
1876
1876
|
const d = De[r];
|
|
1877
|
-
for (const [
|
|
1878
|
-
if (i.includes(
|
|
1879
|
-
return new D(
|
|
1877
|
+
for (const [l, h] of Object.entries(d))
|
|
1878
|
+
if (i.includes(l.toLowerCase()))
|
|
1879
|
+
return new D(h, Y(h), {
|
|
1880
1880
|
apiName: r,
|
|
1881
1881
|
platform: n,
|
|
1882
1882
|
originalError: t
|
|
1883
1883
|
});
|
|
1884
1884
|
}
|
|
1885
1885
|
const a = xe[n] || xe.uniapp;
|
|
1886
|
-
for (const { pattern: d, code:
|
|
1886
|
+
for (const { pattern: d, code: l } of a.patterns)
|
|
1887
1887
|
if (d.test(i))
|
|
1888
|
-
return new D(
|
|
1888
|
+
return new D(l, Y(l), {
|
|
1889
1889
|
apiName: r,
|
|
1890
1890
|
platform: n,
|
|
1891
1891
|
originalError: t
|
|
@@ -1912,7 +1912,7 @@ const Ve = {
|
|
|
1912
1912
|
if (!t.success && t.error) {
|
|
1913
1913
|
const r = Ge(t.error, {
|
|
1914
1914
|
apiName: e.apiName,
|
|
1915
|
-
platform:
|
|
1915
|
+
platform: c.type
|
|
1916
1916
|
});
|
|
1917
1917
|
t.error = r.toJSON(), t.errorCode = r.code, t.errorCategory = r.category, t.retriable = r.isRetriable(), s.debug("错误已标准化", {
|
|
1918
1918
|
api: e.apiName,
|
|
@@ -1923,25 +1923,25 @@ const Ve = {
|
|
|
1923
1923
|
return t;
|
|
1924
1924
|
}
|
|
1925
1925
|
};
|
|
1926
|
-
function
|
|
1926
|
+
function rr(t, e = {}) {
|
|
1927
1927
|
return new D(t, Y(t), e);
|
|
1928
1928
|
}
|
|
1929
|
-
function
|
|
1929
|
+
function nr(t) {
|
|
1930
1930
|
return t instanceof D;
|
|
1931
1931
|
}
|
|
1932
|
-
function
|
|
1932
|
+
function ir(t, e, r) {
|
|
1933
1933
|
return e ? Promise.race([
|
|
1934
1934
|
t(),
|
|
1935
1935
|
new Promise((n, i) => setTimeout(() => i(new Error(`Init task timeout: ${r}`)), e))
|
|
1936
1936
|
]) : t();
|
|
1937
1937
|
}
|
|
1938
|
-
function
|
|
1938
|
+
function sr() {
|
|
1939
1939
|
return m(this, arguments, function* (t = [], e = {}) {
|
|
1940
1940
|
for (const r of t) {
|
|
1941
1941
|
const n = (r == null ? void 0 : r.name) || "anonymous-task", i = (r == null ? void 0 : r.run) || r;
|
|
1942
1942
|
if (typeof i == "function")
|
|
1943
1943
|
try {
|
|
1944
|
-
yield
|
|
1944
|
+
yield ir(() => Promise.resolve().then(() => i()), r.timeoutMs, n), typeof r.onSuccess == "function" && r.onSuccess();
|
|
1945
1945
|
} catch (a) {
|
|
1946
1946
|
if (typeof r.onError == "function" && r.onError(a), typeof e.onError == "function")
|
|
1947
1947
|
e.onError(a, r);
|
|
@@ -1966,7 +1966,7 @@ class je {
|
|
|
1966
1966
|
*/
|
|
1967
1967
|
processNavigationOptions(e = {}) {
|
|
1968
1968
|
const { url: r, delta: n = 1 } = e, i = r && encodeURI(r), a = parseInt(n) || 1;
|
|
1969
|
-
return
|
|
1969
|
+
return A(p({}, e), {
|
|
1970
1970
|
url: i,
|
|
1971
1971
|
delta: a
|
|
1972
1972
|
});
|
|
@@ -2078,7 +2078,7 @@ class je {
|
|
|
2078
2078
|
}
|
|
2079
2079
|
}
|
|
2080
2080
|
let re = [];
|
|
2081
|
-
function
|
|
2081
|
+
function ar() {
|
|
2082
2082
|
if (re.length === 0 && window.plus) {
|
|
2083
2083
|
const t = plus.webview.currentWebview();
|
|
2084
2084
|
if (!t)
|
|
@@ -2088,7 +2088,7 @@ function ir() {
|
|
|
2088
2088
|
}
|
|
2089
2089
|
return re;
|
|
2090
2090
|
}
|
|
2091
|
-
function
|
|
2091
|
+
function or(t, e) {
|
|
2092
2092
|
const r = {
|
|
2093
2093
|
options: {
|
|
2094
2094
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2109,7 +2109,7 @@ function sr(t, e) {
|
|
|
2109
2109
|
};
|
|
2110
2110
|
window.__uniapp_x_postMessage ? window.__uniapp_x_postMessageToService(n) : window.__uniapp_x_.postMessageToService(JSON.stringify(n));
|
|
2111
2111
|
}
|
|
2112
|
-
function
|
|
2112
|
+
function cr(t, e) {
|
|
2113
2113
|
const r = {
|
|
2114
2114
|
options: {
|
|
2115
2115
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2130,14 +2130,14 @@ function ar(t, e) {
|
|
|
2130
2130
|
};
|
|
2131
2131
|
window.__dcloud_weex_postMessage ? window.__dcloud_weex_postMessageToService(n) : window.__dcloud_weex_.postMessageToService(JSON.stringify(n));
|
|
2132
2132
|
}
|
|
2133
|
-
function
|
|
2133
|
+
function ur(t, e) {
|
|
2134
2134
|
const r = {
|
|
2135
2135
|
options: {
|
|
2136
2136
|
timestamp: +/* @__PURE__ */ new Date()
|
|
2137
2137
|
},
|
|
2138
2138
|
name: t,
|
|
2139
2139
|
arg: e
|
|
2140
|
-
}, n =
|
|
2140
|
+
}, n = ar();
|
|
2141
2141
|
if (plus.webview.getWebviewById("__uniapp__service"))
|
|
2142
2142
|
plus.webview.postMessageToUniNView({
|
|
2143
2143
|
type: "WEB_INVOKE_APPSERVICE",
|
|
@@ -2153,7 +2153,7 @@ function or(t, e) {
|
|
|
2153
2153
|
);
|
|
2154
2154
|
}
|
|
2155
2155
|
}
|
|
2156
|
-
function
|
|
2156
|
+
function lr(t, e) {
|
|
2157
2157
|
const r = {
|
|
2158
2158
|
options: {
|
|
2159
2159
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2168,7 +2168,7 @@ function cr(t, e) {
|
|
|
2168
2168
|
}, "*");
|
|
2169
2169
|
}
|
|
2170
2170
|
function ne(t, e) {
|
|
2171
|
-
|
|
2171
|
+
he() ? or(t, e) : pe() ? cr(t, e) : ge() ? ur(t, e) : lr(t, e);
|
|
2172
2172
|
}
|
|
2173
2173
|
class qe extends je {
|
|
2174
2174
|
constructor() {
|
|
@@ -2191,15 +2191,15 @@ class qe extends je {
|
|
|
2191
2191
|
performNavigation(e, r) {
|
|
2192
2192
|
return u.safeExecute(() => {
|
|
2193
2193
|
const { url: n, delta: i } = r;
|
|
2194
|
-
if (
|
|
2194
|
+
if (_.debug(`微信平台执行导航操作: ${e}`, r), this.isWeixinApiAvailable()) {
|
|
2195
2195
|
const g = window.wx.miniProgram[e];
|
|
2196
2196
|
if (typeof g == "function") {
|
|
2197
|
-
|
|
2197
|
+
_.debug(`使用微信原生 API: wx.miniProgram.${e}`);
|
|
2198
2198
|
const d = e === "navigateBack" ? { delta: i } : { url: n };
|
|
2199
2199
|
return g.call(window.wx.miniProgram, d);
|
|
2200
2200
|
}
|
|
2201
2201
|
}
|
|
2202
|
-
|
|
2202
|
+
_.debug(`使用消息桥接执行: ${e}`), ne(e, e === "navigateBack" ? { delta: i } : { url: n });
|
|
2203
2203
|
}, {
|
|
2204
2204
|
platform: this.name,
|
|
2205
2205
|
method: "performNavigation",
|
|
@@ -2245,17 +2245,17 @@ class qe extends je {
|
|
|
2245
2245
|
});
|
|
2246
2246
|
}
|
|
2247
2247
|
}
|
|
2248
|
-
const j = new qe(),
|
|
2248
|
+
const j = new qe(), fr = (t) => j.navigateTo(t), dr = (t) => j.navigateBack(t), gr = (t) => j.switchTab(t), pr = (t) => j.reLaunch(t), hr = (t) => j.redirectTo(t), mr = (t) => j.postMessage(t), wr = (t) => j.getEnv(t);
|
|
2249
2249
|
var Je = /* @__PURE__ */ Object.freeze({
|
|
2250
2250
|
__proto__: null,
|
|
2251
2251
|
WeixinPlatform: qe,
|
|
2252
|
-
getEnv:
|
|
2253
|
-
navigateBack:
|
|
2254
|
-
navigateTo:
|
|
2255
|
-
postMessage:
|
|
2256
|
-
reLaunch:
|
|
2257
|
-
redirectTo:
|
|
2258
|
-
switchTab:
|
|
2252
|
+
getEnv: wr,
|
|
2253
|
+
navigateBack: dr,
|
|
2254
|
+
navigateTo: fr,
|
|
2255
|
+
postMessage: mr,
|
|
2256
|
+
reLaunch: pr,
|
|
2257
|
+
redirectTo: hr,
|
|
2258
|
+
switchTab: gr
|
|
2259
2259
|
});
|
|
2260
2260
|
class He extends je {
|
|
2261
2261
|
constructor() {
|
|
@@ -2304,59 +2304,59 @@ class He extends je {
|
|
|
2304
2304
|
throw new Error("Callback function is required for getEnv");
|
|
2305
2305
|
const r = {};
|
|
2306
2306
|
let n = !1;
|
|
2307
|
-
|
|
2307
|
+
he() ? (r.uvue = !0, n = !0) : pe() ? (r.nvue = !0, n = !0) : ge() && (r.plus = !0, n = !0), n ? r.app = !0 : r.h5 = !0, e(r);
|
|
2308
2308
|
}, {
|
|
2309
2309
|
platform: this.name,
|
|
2310
2310
|
method: "performGetEnv"
|
|
2311
2311
|
});
|
|
2312
2312
|
}
|
|
2313
2313
|
}
|
|
2314
|
-
const q = new He(),
|
|
2314
|
+
const q = new He(), Er = (t) => q.navigateTo(t), yr = (t) => q.navigateBack(t), Ir = (t) => q.switchTab(t), Ar = (t) => q.reLaunch(t), Or = (t) => q.redirectTo(t), _r = (t) => q.postMessage(t), Cr = (t) => q.getEnv(t);
|
|
2315
2315
|
var Ye = /* @__PURE__ */ Object.freeze({
|
|
2316
2316
|
__proto__: null,
|
|
2317
2317
|
AppPlatform: He,
|
|
2318
|
-
getEnv:
|
|
2319
|
-
navigateBack:
|
|
2320
|
-
navigateTo:
|
|
2321
|
-
postMessage:
|
|
2322
|
-
reLaunch:
|
|
2323
|
-
redirectTo:
|
|
2324
|
-
switchTab:
|
|
2318
|
+
getEnv: Cr,
|
|
2319
|
+
navigateBack: yr,
|
|
2320
|
+
navigateTo: Er,
|
|
2321
|
+
postMessage: _r,
|
|
2322
|
+
reLaunch: Ar,
|
|
2323
|
+
redirectTo: Or,
|
|
2324
|
+
switchTab: Ir
|
|
2325
2325
|
});
|
|
2326
2326
|
function ie() {
|
|
2327
2327
|
return E() ? Je : Ye;
|
|
2328
2328
|
}
|
|
2329
|
-
function
|
|
2329
|
+
function Nr(t) {
|
|
2330
2330
|
return ie().navigateTo(t);
|
|
2331
2331
|
}
|
|
2332
|
-
function
|
|
2332
|
+
function Rr(t) {
|
|
2333
2333
|
return ie().navigateBack(t);
|
|
2334
2334
|
}
|
|
2335
|
-
function
|
|
2335
|
+
function Sr(t) {
|
|
2336
2336
|
return ie().switchTab(t);
|
|
2337
2337
|
}
|
|
2338
|
-
function
|
|
2338
|
+
function Pr(t) {
|
|
2339
2339
|
return ie().reLaunch(t);
|
|
2340
2340
|
}
|
|
2341
|
-
function
|
|
2341
|
+
function Tr(t) {
|
|
2342
2342
|
return ie().redirectTo(t);
|
|
2343
2343
|
}
|
|
2344
2344
|
function Xe() {
|
|
2345
2345
|
return E() ? Je : Ye;
|
|
2346
2346
|
}
|
|
2347
|
-
function
|
|
2347
|
+
function Lr(t = {}) {
|
|
2348
2348
|
return Xe().postMessage(t);
|
|
2349
2349
|
}
|
|
2350
|
-
function
|
|
2350
|
+
function Mr(t) {
|
|
2351
2351
|
return Xe().getEnv(t);
|
|
2352
2352
|
}
|
|
2353
|
-
function
|
|
2353
|
+
function br(t) {
|
|
2354
2354
|
return t && typeof t == "object" && t.__v_raw ? t.__v_raw : t;
|
|
2355
2355
|
}
|
|
2356
|
-
function
|
|
2356
|
+
function vr() {
|
|
2357
2357
|
return "qsh_callback_" + Date.now() + "_" + Math.random().toString(36).substring(2, 9);
|
|
2358
2358
|
}
|
|
2359
|
-
class
|
|
2359
|
+
class xr {
|
|
2360
2360
|
constructor() {
|
|
2361
2361
|
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 桥接器已初始化");
|
|
2362
2362
|
}
|
|
@@ -2370,13 +2370,13 @@ class br {
|
|
|
2370
2370
|
callApi(i) {
|
|
2371
2371
|
return m(this, arguments, function* (e, r = {}, n = {}) {
|
|
2372
2372
|
return u.safeExecute(() => m(this, null, function* () {
|
|
2373
|
-
var
|
|
2373
|
+
var h;
|
|
2374
2374
|
if (typeof window != "undefined" && window === window.parent && !window.plus && !window.__uniapp_x_postMessage && !window.__uniapp_x_ && !window.__dcloud_weex_postMessage && !window.__dcloud_weex_) {
|
|
2375
|
-
const
|
|
2375
|
+
const T = new L(
|
|
2376
2376
|
U.PLATFORM_NOT_SUPPORTED,
|
|
2377
2377
|
"当前不在宿主 WebView 容器中,无法发送消息"
|
|
2378
2378
|
);
|
|
2379
|
-
n && typeof n.fail == "function" && n.fail({ errMsg:
|
|
2379
|
+
n && typeof n.fail == "function" && n.fail({ errMsg: T.message, code: "NOT_IN_CONTAINER" }), n && typeof n.complete == "function" && n.complete({ success: !1, error: { errMsg: T.message } });
|
|
2380
2380
|
return;
|
|
2381
2381
|
}
|
|
2382
2382
|
const g = {
|
|
@@ -2391,46 +2391,46 @@ class br {
|
|
|
2391
2391
|
const d = yield K.runRequest(g);
|
|
2392
2392
|
if (d.abort) {
|
|
2393
2393
|
y.warn("API 调用被拦截器中止", { api: e }), x.setApiLoading(e, !1), n.fail && n.fail({
|
|
2394
|
-
errMsg: ((
|
|
2394
|
+
errMsg: ((h = d.error) == null ? void 0 : h.message) || "API 调用被中止",
|
|
2395
2395
|
code: "INTERCEPTED"
|
|
2396
2396
|
}), n.complete && n.complete({ success: !1 });
|
|
2397
2397
|
return;
|
|
2398
2398
|
}
|
|
2399
|
-
const
|
|
2399
|
+
const l = vr();
|
|
2400
2400
|
if (n.success || n.fail || n.complete) {
|
|
2401
|
-
if (this.callbacks.set(
|
|
2401
|
+
if (this.callbacks.set(l, A(p({}, n), {
|
|
2402
2402
|
context: d
|
|
2403
2403
|
// 保存上下文用于响应拦截
|
|
2404
|
-
})), window.qshWebviewCallbacks[
|
|
2405
|
-
this.handleCallback(
|
|
2406
|
-
}, r.isPersistent && (this.persistentCallbacksByApi.has(e) || this.persistentCallbacksByApi.set(e, /* @__PURE__ */ new Set()), this.persistentCallbacksByApi.get(e).add(
|
|
2404
|
+
})), window.qshWebviewCallbacks[l] = (Ee) => {
|
|
2405
|
+
this.handleCallback(l, Ee);
|
|
2406
|
+
}, r.isPersistent && (this.persistentCallbacksByApi.has(e) || this.persistentCallbacksByApi.set(e, /* @__PURE__ */ new Set()), this.persistentCallbacksByApi.get(e).add(l)), r.isPersistent || r.disableTimeout)
|
|
2407
2407
|
y.info(`API ${e} 禁用超时清理,将等待回调返回后清理`, {
|
|
2408
|
-
callbackId:
|
|
2408
|
+
callbackId: l,
|
|
2409
2409
|
isPersistent: r.isPersistent,
|
|
2410
2410
|
disableTimeout: r.disableTimeout
|
|
2411
2411
|
});
|
|
2412
2412
|
else {
|
|
2413
2413
|
const Ee = setTimeout(() => {
|
|
2414
|
-
y.warn("API 调用超时,自动清理回调", { api: e, callbackId:
|
|
2414
|
+
y.warn("API 调用超时,自动清理回调", { api: e, callbackId: l }), n.fail && n.fail({
|
|
2415
2415
|
errMsg: `API ${e} 调用超时`,
|
|
2416
2416
|
code: "TIMEOUT"
|
|
2417
|
-
}), this.cleanupCallback(
|
|
2417
|
+
}), this.cleanupCallback(l);
|
|
2418
2418
|
}, r.timeout || this.defaultTimeout);
|
|
2419
|
-
this.timeouts.set(
|
|
2419
|
+
this.timeouts.set(l, Ee);
|
|
2420
2420
|
}
|
|
2421
2421
|
const N = {
|
|
2422
2422
|
type: "qsh_api_call",
|
|
2423
2423
|
api: e,
|
|
2424
2424
|
params: d.params,
|
|
2425
|
-
callbackId:
|
|
2425
|
+
callbackId: l,
|
|
2426
2426
|
timestamp: Date.now()
|
|
2427
2427
|
};
|
|
2428
2428
|
y.info("发送 API 调用消息", {
|
|
2429
2429
|
api: e,
|
|
2430
|
-
callbackId:
|
|
2430
|
+
callbackId: l,
|
|
2431
2431
|
hasSuccess: !!n.success,
|
|
2432
2432
|
hasFail: !!n.fail
|
|
2433
|
-
}), console.log("message:", JSON.stringify(
|
|
2433
|
+
}), console.log("message:", JSON.stringify(br(N), null, 2)), ne("postMessage", N);
|
|
2434
2434
|
}
|
|
2435
2435
|
}), {
|
|
2436
2436
|
context: "WebViewBridge.callApi",
|
|
@@ -2447,7 +2447,7 @@ class br {
|
|
|
2447
2447
|
handleCallback(e, r) {
|
|
2448
2448
|
return m(this, null, function* () {
|
|
2449
2449
|
return u.safeExecute(() => m(this, null, function* () {
|
|
2450
|
-
var
|
|
2450
|
+
var T, N;
|
|
2451
2451
|
const n = this.callbacks.get(e);
|
|
2452
2452
|
if (!n) {
|
|
2453
2453
|
y.warn("未找到回调函数", { callbackId: e });
|
|
@@ -2455,8 +2455,8 @@ class br {
|
|
|
2455
2455
|
}
|
|
2456
2456
|
const { success: i, fail: a, complete: g, context: d } = n;
|
|
2457
2457
|
y.debug("处理回调", { callbackId: e, result: r });
|
|
2458
|
-
const
|
|
2459
|
-
d && x.setApiResult(d.apiName,
|
|
2458
|
+
const l = yield K.runResponse(r, d);
|
|
2459
|
+
d && x.setApiResult(d.apiName, l), l.success && i ? i(l.data) : !l.success && a && a(l.error || { errMsg: "操作失败" }), g && g(l), ((N = (T = n.context) == null ? void 0 : T.params) == null ? void 0 : N.isPersistent) ? y.debug("持久监听API:保留回调", { callbackId: e }) : (this.cleanupCallback(e), y.debug("回调执行完成,已清理", { callbackId: e }));
|
|
2460
2460
|
}), {
|
|
2461
2461
|
context: "WebViewBridge.handleCallback",
|
|
2462
2462
|
callbackId: e
|
|
@@ -2509,7 +2509,7 @@ class br {
|
|
|
2509
2509
|
};
|
|
2510
2510
|
}
|
|
2511
2511
|
}
|
|
2512
|
-
const Ze = new
|
|
2512
|
+
const Ze = new xr(), C = (t, e, r) => Ze.callApi(t, e, r), X = (t) => Ze.cleanupPersistentCallbacksByApi(t), le = {
|
|
2513
2513
|
ALBUM: "album",
|
|
2514
2514
|
// 相册
|
|
2515
2515
|
CAMERA: "camera"
|
|
@@ -2519,17 +2519,17 @@ const Ze = new br(), C = (t, e, r) => Ze.callApi(t, e, r), X = (t) => Ze.cleanup
|
|
|
2519
2519
|
// 原图
|
|
2520
2520
|
COMPRESSED: "compressed"
|
|
2521
2521
|
// 压缩图
|
|
2522
|
-
},
|
|
2522
|
+
}, Dr = {
|
|
2523
2523
|
count: 9,
|
|
2524
2524
|
sizeType: [fe.ORIGINAL, fe.COMPRESSED],
|
|
2525
2525
|
sourceType: [le.ALBUM, le.CAMERA]
|
|
2526
2526
|
};
|
|
2527
|
-
function
|
|
2528
|
-
const e =
|
|
2527
|
+
function Ur(t = {}) {
|
|
2528
|
+
const e = p(p({}, Dr), t);
|
|
2529
2529
|
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 = [fe.COMPRESSED]), e.sourceType.length === 0 && (e.sourceType = [le.ALBUM]), e;
|
|
2530
2530
|
}
|
|
2531
2531
|
function Qe() {
|
|
2532
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
2532
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(c.type);
|
|
2533
2533
|
}
|
|
2534
2534
|
function et(t) {
|
|
2535
2535
|
return u.safeExecute(() => {
|
|
@@ -2543,7 +2543,7 @@ function et(t) {
|
|
|
2543
2543
|
return;
|
|
2544
2544
|
}
|
|
2545
2545
|
if (!z()) {
|
|
2546
|
-
s.info("等待微信配置完成"),
|
|
2546
|
+
s.info("等待微信配置完成"), k().then(() => et(t)).catch((r) => {
|
|
2547
2547
|
var n;
|
|
2548
2548
|
s.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
2549
2549
|
});
|
|
@@ -2568,9 +2568,9 @@ function et(t) {
|
|
|
2568
2568
|
platform: "weixin"
|
|
2569
2569
|
});
|
|
2570
2570
|
}
|
|
2571
|
-
function
|
|
2571
|
+
function Wr(t) {
|
|
2572
2572
|
return u.safeExecute(() => {
|
|
2573
|
-
s.debug("通过 WebView 桥接调用图片选择", t), C("chooseImage",
|
|
2573
|
+
s.debug("通过 WebView 桥接调用图片选择", t), C("chooseImage", A(p({}, t), { disableTimeout: !0 }), {
|
|
2574
2574
|
success: (e) => {
|
|
2575
2575
|
var r, n;
|
|
2576
2576
|
s.info("UniApp 图片选择成功", {
|
|
@@ -2588,33 +2588,33 @@ function Dr(t) {
|
|
|
2588
2588
|
platform: "uniapp"
|
|
2589
2589
|
});
|
|
2590
2590
|
}
|
|
2591
|
-
function
|
|
2591
|
+
function $r(t = {}) {
|
|
2592
2592
|
return u.safeExecute(() => {
|
|
2593
2593
|
var r;
|
|
2594
2594
|
if (!Qe()) {
|
|
2595
2595
|
const n = {
|
|
2596
|
-
errMsg: `当前环境 (${
|
|
2596
|
+
errMsg: `当前环境 (${c.type}) 不支持图片选择功能`,
|
|
2597
2597
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
2598
2598
|
};
|
|
2599
|
-
s.error("平台不支持图片选择", { platform:
|
|
2599
|
+
s.error("平台不支持图片选择", { platform: c.type }), (r = t.fail) == null || r.call(t, n);
|
|
2600
2600
|
return;
|
|
2601
2601
|
}
|
|
2602
|
-
const e =
|
|
2602
|
+
const e = Ur(t);
|
|
2603
2603
|
s.info("开始选择图片", {
|
|
2604
|
-
platform:
|
|
2604
|
+
platform: c.type,
|
|
2605
2605
|
count: e.count,
|
|
2606
2606
|
sizeType: e.sizeType,
|
|
2607
2607
|
sourceType: e.sourceType
|
|
2608
|
-
}), E() ? et(e) :
|
|
2608
|
+
}), E() ? et(e) : Wr(e);
|
|
2609
2609
|
}, {
|
|
2610
2610
|
context: "chooseImage",
|
|
2611
2611
|
options: t
|
|
2612
2612
|
});
|
|
2613
2613
|
}
|
|
2614
|
-
function
|
|
2614
|
+
function Br() {
|
|
2615
2615
|
return {
|
|
2616
2616
|
supported: Qe(),
|
|
2617
|
-
environment:
|
|
2617
|
+
environment: c.type,
|
|
2618
2618
|
implementation: E() ? "weixin" : "webview",
|
|
2619
2619
|
features: {
|
|
2620
2620
|
multipleSelection: !0,
|
|
@@ -2637,18 +2637,18 @@ const V = {
|
|
|
2637
2637
|
// Data Matrix 码
|
|
2638
2638
|
PDF417: "pdf417"
|
|
2639
2639
|
// PDF417 条码
|
|
2640
|
-
},
|
|
2640
|
+
}, Fr = {
|
|
2641
2641
|
onlyFromCamera: !0,
|
|
2642
2642
|
// 只从相机扫码
|
|
2643
2643
|
scanType: [V.QR_CODE, V.BAR_CODE]
|
|
2644
2644
|
// 支持二维码和一维码
|
|
2645
2645
|
};
|
|
2646
|
-
function
|
|
2647
|
-
const e =
|
|
2646
|
+
function kr(t = {}) {
|
|
2647
|
+
const e = p(p({}, Fr), t);
|
|
2648
2648
|
return Array.isArray(e.scanType) || (e.scanType = [e.scanType].filter(Boolean)), e.scanType.length === 0 && (e.scanType = [V.QR_CODE, V.BAR_CODE]), e.onlyFromCamera = !!e.onlyFromCamera, e;
|
|
2649
2649
|
}
|
|
2650
2650
|
function tt() {
|
|
2651
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
2651
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(c.type);
|
|
2652
2652
|
}
|
|
2653
2653
|
function rt(t) {
|
|
2654
2654
|
return u.safeExecute(() => {
|
|
@@ -2662,7 +2662,7 @@ function rt(t) {
|
|
|
2662
2662
|
return;
|
|
2663
2663
|
}
|
|
2664
2664
|
if (!z()) {
|
|
2665
|
-
s.info("等待微信配置完成"),
|
|
2665
|
+
s.info("等待微信配置完成"), k().then(() => rt(t)).catch((r) => {
|
|
2666
2666
|
var n;
|
|
2667
2667
|
s.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
2668
2668
|
});
|
|
@@ -2678,7 +2678,7 @@ function rt(t) {
|
|
|
2678
2678
|
const n = {
|
|
2679
2679
|
result: r.resultStr,
|
|
2680
2680
|
// 扫码内容
|
|
2681
|
-
scanType:
|
|
2681
|
+
scanType: zr(r.resultStr),
|
|
2682
2682
|
// 推测扫码类型
|
|
2683
2683
|
charSet: "utf-8",
|
|
2684
2684
|
// 微信默认 UTF-8
|
|
@@ -2697,12 +2697,12 @@ function rt(t) {
|
|
|
2697
2697
|
platform: "weixin"
|
|
2698
2698
|
});
|
|
2699
2699
|
}
|
|
2700
|
-
function
|
|
2700
|
+
function zr(t) {
|
|
2701
2701
|
return t ? t.length > 50 || /[^\d]/.test(t) ? V.QR_CODE : V.BAR_CODE : "unknown";
|
|
2702
2702
|
}
|
|
2703
|
-
function
|
|
2703
|
+
function Kr(t) {
|
|
2704
2704
|
return u.safeExecute(() => {
|
|
2705
|
-
s.debug("通过 WebView 桥接调用扫码", t), C("scanCode",
|
|
2705
|
+
s.debug("通过 WebView 桥接调用扫码", t), C("scanCode", A(p({}, t), { disableTimeout: !0 }), {
|
|
2706
2706
|
success: (e) => {
|
|
2707
2707
|
var r;
|
|
2708
2708
|
s.info("UniApp 扫码成功", {
|
|
@@ -2721,32 +2721,32 @@ function Fr(t) {
|
|
|
2721
2721
|
platform: "uniapp"
|
|
2722
2722
|
});
|
|
2723
2723
|
}
|
|
2724
|
-
function
|
|
2724
|
+
function Gr(t = {}) {
|
|
2725
2725
|
return u.safeExecute(() => {
|
|
2726
2726
|
var r;
|
|
2727
2727
|
if (!tt()) {
|
|
2728
2728
|
const n = {
|
|
2729
|
-
errMsg: `当前环境 (${
|
|
2729
|
+
errMsg: `当前环境 (${c.type}) 不支持扫码功能`,
|
|
2730
2730
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
2731
2731
|
};
|
|
2732
|
-
s.error("平台不支持扫码", { platform:
|
|
2732
|
+
s.error("平台不支持扫码", { platform: c.type }), (r = t.fail) == null || r.call(t, n);
|
|
2733
2733
|
return;
|
|
2734
2734
|
}
|
|
2735
|
-
const e =
|
|
2735
|
+
const e = kr(t);
|
|
2736
2736
|
s.info("开始扫码", {
|
|
2737
|
-
platform:
|
|
2737
|
+
platform: c.type,
|
|
2738
2738
|
onlyFromCamera: e.onlyFromCamera,
|
|
2739
2739
|
scanType: e.scanType
|
|
2740
|
-
}), E() ? rt(e) :
|
|
2740
|
+
}), E() ? rt(e) : Kr(e);
|
|
2741
2741
|
}, {
|
|
2742
2742
|
context: "scanCode",
|
|
2743
2743
|
options: t
|
|
2744
2744
|
});
|
|
2745
2745
|
}
|
|
2746
|
-
function
|
|
2746
|
+
function Vr() {
|
|
2747
2747
|
return {
|
|
2748
2748
|
supported: tt(),
|
|
2749
|
-
environment:
|
|
2749
|
+
environment: c.type,
|
|
2750
2750
|
implementation: E() ? "weixin" : "webview",
|
|
2751
2751
|
features: {
|
|
2752
2752
|
onlyFromCamera: !0,
|
|
@@ -2767,23 +2767,23 @@ const Z = {
|
|
|
2767
2767
|
// 国测局坐标(火星坐标)
|
|
2768
2768
|
BD09: "bd09"
|
|
2769
2769
|
// 百度坐标
|
|
2770
|
-
},
|
|
2770
|
+
}, jr = {
|
|
2771
2771
|
type: Z.WGS84,
|
|
2772
2772
|
altitude: !1
|
|
2773
|
-
},
|
|
2773
|
+
}, qr = {
|
|
2774
2774
|
scale: 18
|
|
2775
2775
|
// 地图缩放级别 1-28
|
|
2776
2776
|
};
|
|
2777
|
-
function
|
|
2778
|
-
const e =
|
|
2777
|
+
function Jr(t = {}) {
|
|
2778
|
+
const e = p(p({}, jr), t);
|
|
2779
2779
|
return Object.values(Z).includes(e.type) || (e.type = Z.WGS84), e.altitude = !!e.altitude, e;
|
|
2780
2780
|
}
|
|
2781
|
-
function
|
|
2782
|
-
const e =
|
|
2781
|
+
function Hr(t = {}) {
|
|
2782
|
+
const e = p({}, t);
|
|
2783
2783
|
return Object.values(Z).includes(e.type) || (e.type = Z.WGS84), e.needFullAccuracy = !!e.needFullAccuracy, e;
|
|
2784
2784
|
}
|
|
2785
|
-
function
|
|
2786
|
-
const e =
|
|
2785
|
+
function Yr(t = {}) {
|
|
2786
|
+
const e = p(p({}, qr), t);
|
|
2787
2787
|
if (e.latitude === void 0 || e.latitude === null)
|
|
2788
2788
|
throw {
|
|
2789
2789
|
errMsg: "缺少必需参数:latitude(纬度)",
|
|
@@ -2843,7 +2843,7 @@ function Jr(t = {}) {
|
|
|
2843
2843
|
return e;
|
|
2844
2844
|
}
|
|
2845
2845
|
function Re() {
|
|
2846
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
2846
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(c.type);
|
|
2847
2847
|
}
|
|
2848
2848
|
function nt(t) {
|
|
2849
2849
|
return u.safeExecute(() => {
|
|
@@ -2857,7 +2857,7 @@ function nt(t) {
|
|
|
2857
2857
|
return;
|
|
2858
2858
|
}
|
|
2859
2859
|
if (!z()) {
|
|
2860
|
-
s.info("等待微信配置完成"),
|
|
2860
|
+
s.info("等待微信配置完成"), k().then(() => nt(t)).catch((r) => {
|
|
2861
2861
|
var n;
|
|
2862
2862
|
s.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
2863
2863
|
});
|
|
@@ -2895,7 +2895,7 @@ function it(t) {
|
|
|
2895
2895
|
return;
|
|
2896
2896
|
}
|
|
2897
2897
|
if (!z()) {
|
|
2898
|
-
s.info("等待微信配置完成"),
|
|
2898
|
+
s.info("等待微信配置完成"), k().then(() => it(t)).catch((r) => {
|
|
2899
2899
|
var n;
|
|
2900
2900
|
s.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
2901
2901
|
});
|
|
@@ -2923,7 +2923,7 @@ function it(t) {
|
|
|
2923
2923
|
platform: "weixin"
|
|
2924
2924
|
});
|
|
2925
2925
|
}
|
|
2926
|
-
function
|
|
2926
|
+
function Xr(t) {
|
|
2927
2927
|
return u.safeExecute(() => {
|
|
2928
2928
|
s.debug("通过 WebView 桥接调用获取位置", t), C("getLocation", t, {
|
|
2929
2929
|
success: (e) => {
|
|
@@ -2944,7 +2944,7 @@ function Hr(t) {
|
|
|
2944
2944
|
platform: "uniapp"
|
|
2945
2945
|
});
|
|
2946
2946
|
}
|
|
2947
|
-
function
|
|
2947
|
+
function Zr(t) {
|
|
2948
2948
|
return u.safeExecute(() => {
|
|
2949
2949
|
s.debug("通过 WebView 桥接调用查看位置", t), C("openLocation", t, {
|
|
2950
2950
|
success: (e) => {
|
|
@@ -2962,62 +2962,62 @@ function Yr(t) {
|
|
|
2962
2962
|
platform: "uniapp"
|
|
2963
2963
|
});
|
|
2964
2964
|
}
|
|
2965
|
-
function
|
|
2965
|
+
function Qr(t = {}) {
|
|
2966
2966
|
return u.safeExecute(() => {
|
|
2967
2967
|
var r;
|
|
2968
2968
|
if (!Re()) {
|
|
2969
2969
|
const n = {
|
|
2970
|
-
errMsg: `当前环境 (${
|
|
2970
|
+
errMsg: `当前环境 (${c.type}) 不支持定位功能`,
|
|
2971
2971
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
2972
2972
|
};
|
|
2973
|
-
s.error("平台不支持定位", { platform:
|
|
2973
|
+
s.error("平台不支持定位", { platform: c.type }), (r = t.fail) == null || r.call(t, n);
|
|
2974
2974
|
return;
|
|
2975
2975
|
}
|
|
2976
|
-
const e =
|
|
2976
|
+
const e = Jr(t);
|
|
2977
2977
|
s.info("开始获取位置", {
|
|
2978
|
-
platform:
|
|
2978
|
+
platform: c.type,
|
|
2979
2979
|
type: e.type,
|
|
2980
2980
|
altitude: e.altitude
|
|
2981
|
-
}), E() ? nt(e) :
|
|
2981
|
+
}), E() ? nt(e) : Xr(e);
|
|
2982
2982
|
}, {
|
|
2983
2983
|
context: "getLocation",
|
|
2984
2984
|
options: t
|
|
2985
2985
|
});
|
|
2986
2986
|
}
|
|
2987
|
-
function
|
|
2987
|
+
function en(t = {}) {
|
|
2988
2988
|
return u.safeExecute(() => {
|
|
2989
2989
|
var r, n, i;
|
|
2990
2990
|
if (!Re()) {
|
|
2991
2991
|
const a = {
|
|
2992
|
-
errMsg: `当前环境 (${
|
|
2992
|
+
errMsg: `当前环境 (${c.type}) 不支持查看位置功能`,
|
|
2993
2993
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
2994
2994
|
};
|
|
2995
|
-
s.error("平台不支持查看位置", { platform:
|
|
2995
|
+
s.error("平台不支持查看位置", { platform: c.type }), (r = t.fail) == null || r.call(t, a);
|
|
2996
2996
|
return;
|
|
2997
2997
|
}
|
|
2998
2998
|
let e;
|
|
2999
2999
|
try {
|
|
3000
|
-
e =
|
|
3000
|
+
e = Yr(t);
|
|
3001
3001
|
} catch (a) {
|
|
3002
3002
|
s.error("参数验证失败", a), (n = t.fail) == null || n.call(t, a), (i = t.complete) == null || i.call(t);
|
|
3003
3003
|
return;
|
|
3004
3004
|
}
|
|
3005
3005
|
s.info("开始查看位置", {
|
|
3006
|
-
platform:
|
|
3006
|
+
platform: c.type,
|
|
3007
3007
|
latitude: e.latitude,
|
|
3008
3008
|
longitude: e.longitude,
|
|
3009
3009
|
name: e.name
|
|
3010
|
-
}), E() ? it(e) :
|
|
3010
|
+
}), E() ? it(e) : Zr(e);
|
|
3011
3011
|
}, {
|
|
3012
3012
|
context: "openLocation",
|
|
3013
3013
|
options: t
|
|
3014
3014
|
});
|
|
3015
3015
|
}
|
|
3016
|
-
function
|
|
3016
|
+
function tn() {
|
|
3017
3017
|
const t = E();
|
|
3018
3018
|
return {
|
|
3019
3019
|
supported: Re(),
|
|
3020
|
-
environment:
|
|
3020
|
+
environment: c.type,
|
|
3021
3021
|
implementation: t ? "weixin" : "webview",
|
|
3022
3022
|
features: {
|
|
3023
3023
|
getLocation: !0,
|
|
@@ -3035,7 +3035,7 @@ function Qr() {
|
|
|
3035
3035
|
}
|
|
3036
3036
|
};
|
|
3037
3037
|
}
|
|
3038
|
-
const
|
|
3038
|
+
const $ = /* @__PURE__ */ new Set(), B = /* @__PURE__ */ new Set();
|
|
3039
3039
|
function st(t, e, r) {
|
|
3040
3040
|
t.forEach((n) => {
|
|
3041
3041
|
if (typeof n == "function") {
|
|
@@ -3045,18 +3045,18 @@ function st(t, e, r) {
|
|
|
3045
3045
|
s.warn("监听回调不是函数,已跳过", { type: typeof n });
|
|
3046
3046
|
});
|
|
3047
3047
|
}
|
|
3048
|
-
function
|
|
3048
|
+
function rn(t = {}) {
|
|
3049
3049
|
return u.safeExecute(() => {
|
|
3050
3050
|
var r, n;
|
|
3051
3051
|
if (E()) {
|
|
3052
3052
|
const i = {
|
|
3053
|
-
errMsg: `当前环境 (${
|
|
3053
|
+
errMsg: `当前环境 (${c.type}) 不支持该接口`,
|
|
3054
3054
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3055
3055
|
};
|
|
3056
|
-
s.error("当前环境不支持此接口", { platform:
|
|
3056
|
+
s.error("当前环境不支持此接口", { platform: c.type }), (r = t.fail) == null || r.call(t, i), (n = t.complete) == null || n.call(t, i);
|
|
3057
3057
|
return;
|
|
3058
3058
|
}
|
|
3059
|
-
const e =
|
|
3059
|
+
const e = Hr(t);
|
|
3060
3060
|
s.info("正在开启定位监听"), C("startLocationUpdate", {
|
|
3061
3061
|
type: e.type,
|
|
3062
3062
|
needFullAccuracy: e.needFullAccuracy
|
|
@@ -3073,15 +3073,15 @@ function en(t = {}) {
|
|
|
3073
3073
|
});
|
|
3074
3074
|
}, { context: "startLocationUpdate" });
|
|
3075
3075
|
}
|
|
3076
|
-
function
|
|
3076
|
+
function nn(t = {}) {
|
|
3077
3077
|
return u.safeExecute(() => {
|
|
3078
3078
|
var e, r;
|
|
3079
3079
|
if (E()) {
|
|
3080
3080
|
const n = {
|
|
3081
|
-
errMsg: `当前环境 (${
|
|
3081
|
+
errMsg: `当前环境 (${c.type}) 不支持该接口`,
|
|
3082
3082
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3083
3083
|
};
|
|
3084
|
-
s.error("当前环境不支持此接口", { platform:
|
|
3084
|
+
s.error("当前环境不支持此接口", { platform: c.type }), (e = t.fail) == null || e.call(t, n), (r = t.complete) == null || r.call(t, n);
|
|
3085
3085
|
return;
|
|
3086
3086
|
}
|
|
3087
3087
|
s.info("正在停止定位监听"), C("stopLocationUpdate", t, {
|
|
@@ -3097,10 +3097,10 @@ function tn(t = {}) {
|
|
|
3097
3097
|
});
|
|
3098
3098
|
}, { context: "stopLocationUpdate" });
|
|
3099
3099
|
}
|
|
3100
|
-
function
|
|
3100
|
+
function sn(t) {
|
|
3101
3101
|
return u.safeExecute(() => {
|
|
3102
3102
|
if (E()) {
|
|
3103
|
-
s.warn("当前环境不支持此接口", { platform:
|
|
3103
|
+
s.warn("当前环境不支持此接口", { platform: c.type });
|
|
3104
3104
|
return;
|
|
3105
3105
|
}
|
|
3106
3106
|
if (typeof t != "function")
|
|
@@ -3108,21 +3108,21 @@ function rn(t) {
|
|
|
3108
3108
|
errMsg: "onLocationChange 回调必须是函数",
|
|
3109
3109
|
code: "INVALID_CALLBACK"
|
|
3110
3110
|
};
|
|
3111
|
-
const e =
|
|
3112
|
-
|
|
3111
|
+
const e = $.size > 0;
|
|
3112
|
+
$.add(t), e || (s.debug("注册实时位置变化监听器"), C("onLocationChange", { isPersistent: !0 }, {
|
|
3113
3113
|
success: (r) => {
|
|
3114
|
-
s.debug("收到实时位置推送", r), st(
|
|
3114
|
+
s.debug("收到实时位置推送", r), st($, r, "onLocationChange");
|
|
3115
3115
|
},
|
|
3116
3116
|
fail: (r) => {
|
|
3117
|
-
s.warn("位置变化监听出错,请通过 onLocationChangeError 监听错误", r),
|
|
3117
|
+
s.warn("位置变化监听出错,请通过 onLocationChangeError 监听错误", r), $.delete(t), $.size === 0 && X("onLocationChange");
|
|
3118
3118
|
}
|
|
3119
3119
|
}));
|
|
3120
3120
|
}, { context: "onLocationChange" });
|
|
3121
3121
|
}
|
|
3122
|
-
function
|
|
3122
|
+
function an(t) {
|
|
3123
3123
|
return u.safeExecute(() => {
|
|
3124
3124
|
if (E()) {
|
|
3125
|
-
s.warn("当前环境不支持此接口", { platform:
|
|
3125
|
+
s.warn("当前环境不支持此接口", { platform: c.type });
|
|
3126
3126
|
return;
|
|
3127
3127
|
}
|
|
3128
3128
|
if (t && typeof t != "function")
|
|
@@ -3130,7 +3130,7 @@ function nn(t) {
|
|
|
3130
3130
|
errMsg: "offLocationChange 回调必须是函数",
|
|
3131
3131
|
code: "INVALID_CALLBACK"
|
|
3132
3132
|
};
|
|
3133
|
-
t ?
|
|
3133
|
+
t ? $.delete(t) : $.clear(), !($.size > 0) && (s.info("移除位置变化监听器"), C("offLocationChange", {}, {
|
|
3134
3134
|
success: () => {
|
|
3135
3135
|
s.info("位置变化监听已移除"), X("onLocationChange");
|
|
3136
3136
|
},
|
|
@@ -3140,10 +3140,10 @@ function nn(t) {
|
|
|
3140
3140
|
}));
|
|
3141
3141
|
}, { context: "offLocationChange" });
|
|
3142
3142
|
}
|
|
3143
|
-
function
|
|
3143
|
+
function on(t) {
|
|
3144
3144
|
return u.safeExecute(() => {
|
|
3145
3145
|
if (E()) {
|
|
3146
|
-
s.warn("当前环境不支持此接口", { platform:
|
|
3146
|
+
s.warn("当前环境不支持此接口", { platform: c.type });
|
|
3147
3147
|
return;
|
|
3148
3148
|
}
|
|
3149
3149
|
if (typeof t != "function")
|
|
@@ -3151,21 +3151,21 @@ function sn(t) {
|
|
|
3151
3151
|
errMsg: "onLocationChangeError 回调必须是函数",
|
|
3152
3152
|
code: "INVALID_CALLBACK"
|
|
3153
3153
|
};
|
|
3154
|
-
const e =
|
|
3155
|
-
|
|
3154
|
+
const e = B.size > 0;
|
|
3155
|
+
B.add(t), e || (s.debug("注册位置更新错误监听器"), C("onLocationChangeError", { isPersistent: !0 }, {
|
|
3156
3156
|
success: (r) => {
|
|
3157
|
-
s.warn("持续定位发生异常", r), st(
|
|
3157
|
+
s.warn("持续定位发生异常", r), st(B, r, "onLocationChangeError");
|
|
3158
3158
|
},
|
|
3159
3159
|
fail: (r) => {
|
|
3160
|
-
s.warn("位置更新错误监听注册失败", r),
|
|
3160
|
+
s.warn("位置更新错误监听注册失败", r), B.delete(t), B.size === 0 && X("onLocationChangeError");
|
|
3161
3161
|
}
|
|
3162
3162
|
}));
|
|
3163
3163
|
}, { context: "onLocationChangeError" });
|
|
3164
3164
|
}
|
|
3165
|
-
function
|
|
3165
|
+
function cn(t) {
|
|
3166
3166
|
return u.safeExecute(() => {
|
|
3167
3167
|
if (E()) {
|
|
3168
|
-
s.warn("当前环境不支持此接口", { platform:
|
|
3168
|
+
s.warn("当前环境不支持此接口", { platform: c.type });
|
|
3169
3169
|
return;
|
|
3170
3170
|
}
|
|
3171
3171
|
if (t && typeof t != "function")
|
|
@@ -3173,7 +3173,7 @@ function an(t) {
|
|
|
3173
3173
|
errMsg: "offLocationChangeError 回调必须是函数",
|
|
3174
3174
|
code: "INVALID_CALLBACK"
|
|
3175
3175
|
};
|
|
3176
|
-
t ?
|
|
3176
|
+
t ? B.delete(t) : B.clear(), !(B.size > 0) && (s.info("移除定位错误监听器"), C("offLocationChangeError", {}, {
|
|
3177
3177
|
success: () => {
|
|
3178
3178
|
s.info("定位错误监听已移除"), X("onLocationChangeError");
|
|
3179
3179
|
},
|
|
@@ -3183,14 +3183,14 @@ function an(t) {
|
|
|
3183
3183
|
}));
|
|
3184
3184
|
}, { context: "offLocationChangeError" });
|
|
3185
3185
|
}
|
|
3186
|
-
const
|
|
3186
|
+
const un = {
|
|
3187
3187
|
latitude: null,
|
|
3188
3188
|
// 目标地纬度
|
|
3189
3189
|
longitude: null
|
|
3190
3190
|
// 目标地经度
|
|
3191
3191
|
};
|
|
3192
|
-
function
|
|
3193
|
-
const e =
|
|
3192
|
+
function ln(t = {}) {
|
|
3193
|
+
const e = p(p({}, un), t);
|
|
3194
3194
|
return e.latitude !== null && e.latitude !== void 0 && (typeof e.latitude != "number" ? (s.warn("latitude 参数类型错误,已忽略", {
|
|
3195
3195
|
latitude: e.latitude
|
|
3196
3196
|
}), e.latitude = null) : (e.latitude < -90 || e.latitude > 90) && (s.warn("latitude 超出范围,已忽略", {
|
|
@@ -3202,7 +3202,7 @@ function cn(t = {}) {
|
|
|
3202
3202
|
}), e.longitude = null)), e;
|
|
3203
3203
|
}
|
|
3204
3204
|
function at() {
|
|
3205
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
3205
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(c.type);
|
|
3206
3206
|
}
|
|
3207
3207
|
function ot(t) {
|
|
3208
3208
|
return u.safeExecute(() => {
|
|
@@ -3216,7 +3216,7 @@ function ot(t) {
|
|
|
3216
3216
|
return;
|
|
3217
3217
|
}
|
|
3218
3218
|
if (!z()) {
|
|
3219
|
-
s.info("等待微信配置完成"),
|
|
3219
|
+
s.info("等待微信配置完成"), k().then(() => ot(t)).catch((i) => {
|
|
3220
3220
|
var a;
|
|
3221
3221
|
s.error("微信配置失败", i), (a = t.fail) == null || a.call(t, { errMsg: `微信配置失败: ${i.message}` });
|
|
3222
3222
|
});
|
|
@@ -3251,7 +3251,7 @@ function ot(t) {
|
|
|
3251
3251
|
},
|
|
3252
3252
|
complete: t.complete
|
|
3253
3253
|
}, r = {};
|
|
3254
|
-
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(
|
|
3254
|
+
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(A(p({}, r), {
|
|
3255
3255
|
success: e.success,
|
|
3256
3256
|
fail: e.fail,
|
|
3257
3257
|
complete: e.complete
|
|
@@ -3261,7 +3261,7 @@ function ot(t) {
|
|
|
3261
3261
|
platform: "weixin"
|
|
3262
3262
|
});
|
|
3263
3263
|
}
|
|
3264
|
-
function
|
|
3264
|
+
function fn(t) {
|
|
3265
3265
|
return u.safeExecute(() => {
|
|
3266
3266
|
s.debug("通过 WebView 桥接调用位置选择", t);
|
|
3267
3267
|
const e = {
|
|
@@ -3296,32 +3296,32 @@ function un(t) {
|
|
|
3296
3296
|
platform: "uniapp"
|
|
3297
3297
|
});
|
|
3298
3298
|
}
|
|
3299
|
-
function
|
|
3299
|
+
function dn(t = {}) {
|
|
3300
3300
|
return u.safeExecute(() => {
|
|
3301
3301
|
var r;
|
|
3302
3302
|
if (!at()) {
|
|
3303
3303
|
const n = {
|
|
3304
|
-
errMsg: `当前环境 (${
|
|
3304
|
+
errMsg: `当前环境 (${c.type}) 不支持位置选择功能`,
|
|
3305
3305
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3306
3306
|
};
|
|
3307
|
-
s.error("平台不支持位置选择", { platform:
|
|
3307
|
+
s.error("平台不支持位置选择", { platform: c.type }), (r = t.fail) == null || r.call(t, n);
|
|
3308
3308
|
return;
|
|
3309
3309
|
}
|
|
3310
|
-
const e =
|
|
3310
|
+
const e = ln(t);
|
|
3311
3311
|
s.info("开始选择位置", {
|
|
3312
|
-
platform:
|
|
3312
|
+
platform: c.type,
|
|
3313
3313
|
latitude: e.latitude,
|
|
3314
3314
|
longitude: e.longitude
|
|
3315
|
-
}), E() ? ot(e) :
|
|
3315
|
+
}), E() ? ot(e) : fn(e);
|
|
3316
3316
|
}, {
|
|
3317
3317
|
context: "chooseLocation",
|
|
3318
3318
|
options: t
|
|
3319
3319
|
});
|
|
3320
3320
|
}
|
|
3321
|
-
function
|
|
3321
|
+
function gn() {
|
|
3322
3322
|
return {
|
|
3323
3323
|
supported: at(),
|
|
3324
|
-
environment:
|
|
3324
|
+
environment: c.type,
|
|
3325
3325
|
implementation: E() ? "weixin" : "webview",
|
|
3326
3326
|
features: {
|
|
3327
3327
|
chooseLocation: !0,
|
|
@@ -3334,20 +3334,20 @@ function fn() {
|
|
|
3334
3334
|
};
|
|
3335
3335
|
}
|
|
3336
3336
|
const ct = /* @__PURE__ */ new Map();
|
|
3337
|
-
function
|
|
3337
|
+
function pn(t, e = {}) {
|
|
3338
3338
|
ct.set(t, e);
|
|
3339
3339
|
}
|
|
3340
|
-
function
|
|
3340
|
+
function hn(t, e) {
|
|
3341
3341
|
const r = ct.get(t);
|
|
3342
3342
|
if (r)
|
|
3343
3343
|
return r[e] || r.default;
|
|
3344
3344
|
}
|
|
3345
|
-
const
|
|
3345
|
+
const mn = {
|
|
3346
3346
|
0: "WXSceneSession",
|
|
3347
3347
|
// 聊天界面
|
|
3348
3348
|
1: "WXSceneTimeline"
|
|
3349
3349
|
// 朋友圈
|
|
3350
|
-
},
|
|
3350
|
+
}, wn = {
|
|
3351
3351
|
0: "图文/网页",
|
|
3352
3352
|
1: "纯文字",
|
|
3353
3353
|
2: "纯图片",
|
|
@@ -3364,7 +3364,7 @@ function ut(t = {}) {
|
|
|
3364
3364
|
return (n = t.fail) == null || n.call(t, a), Promise.reject(a);
|
|
3365
3365
|
}
|
|
3366
3366
|
if (!z())
|
|
3367
|
-
return s.info("等待微信配置完成"),
|
|
3367
|
+
return s.info("等待微信配置完成"), k().then(() => ut(t));
|
|
3368
3368
|
const e = lt(t);
|
|
3369
3369
|
if (!e.success) {
|
|
3370
3370
|
const a = { errMsg: e.message || "参数校验失败", code: "INVALID_PARAMS" };
|
|
@@ -3372,16 +3372,16 @@ function ut(t = {}) {
|
|
|
3372
3372
|
}
|
|
3373
3373
|
const r = e.params;
|
|
3374
3374
|
return s.debug("调用微信分享", r), new Promise((a, g) => {
|
|
3375
|
-
window.wx[r.scene](
|
|
3375
|
+
window.wx[r.scene](A(p({}, r), {
|
|
3376
3376
|
success: () => {
|
|
3377
|
-
var
|
|
3377
|
+
var l;
|
|
3378
3378
|
const d = { errMsg: "weixinShare:ok" };
|
|
3379
|
-
(
|
|
3379
|
+
(l = t.success) == null || l.call(t, d), a(d);
|
|
3380
3380
|
},
|
|
3381
3381
|
fail: (d) => {
|
|
3382
|
-
var
|
|
3383
|
-
const
|
|
3384
|
-
s.error("微信分享失败",
|
|
3382
|
+
var h;
|
|
3383
|
+
const l = { errMsg: (d == null ? void 0 : d.errMsg) || "weixinShare:fail", details: d };
|
|
3384
|
+
s.error("微信分享失败", l), (h = t.fail) == null || h.call(t, l), g(l);
|
|
3385
3385
|
},
|
|
3386
3386
|
complete: t.complete
|
|
3387
3387
|
}));
|
|
@@ -3394,7 +3394,7 @@ function ut(t = {}) {
|
|
|
3394
3394
|
);
|
|
3395
3395
|
}
|
|
3396
3396
|
function lt(t = {}) {
|
|
3397
|
-
const e =
|
|
3397
|
+
const e = p({}, t), r = {
|
|
3398
3398
|
scene: e.scene === 1 ? "updateTimelineShareData" : "updateAppMessageShareData"
|
|
3399
3399
|
};
|
|
3400
3400
|
return s.info("格式化微信参数", e), Object.prototype.hasOwnProperty.call(e, "title") ? Object.prototype.hasOwnProperty.call(e, "imageUrl") ? Object.prototype.hasOwnProperty.call(e, "path") ? Object.prototype.hasOwnProperty.call(e, "summary") ? (r.title = e.title, r.imgUrl = e.imageUrl, r.link = e.path, r.desc = e.summary, { params: r, success: !0 }) : { message: "参数字段summary值缺少!", success: !1 } : { message: "参数字段path值缺少!", success: !1 } : { message: "参数字段imageUrl值缺少!", success: !1 } : { message: "参数字段title值缺少!", success: !1 };
|
|
@@ -3420,14 +3420,14 @@ function J(t = {}) {
|
|
|
3420
3420
|
}
|
|
3421
3421
|
);
|
|
3422
3422
|
}
|
|
3423
|
-
function
|
|
3424
|
-
const e =
|
|
3423
|
+
function En(t = {}) {
|
|
3424
|
+
const e = p({}, t), r = {
|
|
3425
3425
|
provider: "weixin",
|
|
3426
3426
|
scene: "WXSceneSession"
|
|
3427
3427
|
};
|
|
3428
|
-
if (s.info("格式化 UniApp 参数", e), [0, 1].some((n) => parseInt(n) === parseInt(e.scene)) ? r.scene =
|
|
3428
|
+
if (s.info("格式化 UniApp 参数", e), [0, 1].some((n) => parseInt(n) === parseInt(e.scene)) ? r.scene = mn[e.scene] : r.scene = "WXSceneSession", Object.prototype.hasOwnProperty.call(e, "type")) {
|
|
3429
3429
|
const n = Number(e.type);
|
|
3430
|
-
if (Object.keys(
|
|
3430
|
+
if (Object.keys(wn).some((a) => parseInt(a) === n)) {
|
|
3431
3431
|
if (r.type = n, [0].includes(n))
|
|
3432
3432
|
if (Object.prototype.hasOwnProperty.call(e, "path"))
|
|
3433
3433
|
r.href = e.path;
|
|
@@ -3443,7 +3443,7 @@ function mn(t = {}) {
|
|
|
3443
3443
|
r.imageUrl = e.imageUrl;
|
|
3444
3444
|
else
|
|
3445
3445
|
return { message: "参数字段imageUrl值缺少!", success: !1 };
|
|
3446
|
-
[5].includes(n) && Object.prototype.hasOwnProperty.call(e, "miniProgram") &&
|
|
3446
|
+
[5].includes(n) && Object.prototype.hasOwnProperty.call(e, "miniProgram") && p({}, e.miniProgram), Object.prototype.hasOwnProperty.call(e, "title") && (r.title = e.title), Object.prototype.hasOwnProperty.call(e, "success") && (r.success = e.success), Object.prototype.hasOwnProperty.call(e, "fail") && (r.fail = e.fail), Object.prototype.hasOwnProperty.call(e, "complete") && (r.complete = e.complete);
|
|
3447
3447
|
} else
|
|
3448
3448
|
return { message: "参数字段type值有误!", success: !1 };
|
|
3449
3449
|
} else
|
|
@@ -3451,7 +3451,7 @@ function mn(t = {}) {
|
|
|
3451
3451
|
return { params: r, success: !0 };
|
|
3452
3452
|
}
|
|
3453
3453
|
const ft = "share.toShare";
|
|
3454
|
-
|
|
3454
|
+
pn(ft, {
|
|
3455
3455
|
weixin: ut,
|
|
3456
3456
|
webview: J,
|
|
3457
3457
|
plus: J,
|
|
@@ -3461,11 +3461,11 @@ dn(ft, {
|
|
|
3461
3461
|
h5: J,
|
|
3462
3462
|
default: void 0
|
|
3463
3463
|
});
|
|
3464
|
-
function
|
|
3464
|
+
function yn(t = {}) {
|
|
3465
3465
|
return u.safeExecute(
|
|
3466
3466
|
() => {
|
|
3467
3467
|
var a, g;
|
|
3468
|
-
const e = Ne(), r =
|
|
3468
|
+
const e = Ne(), r = hn(ft, e.type);
|
|
3469
3469
|
if (typeof r != "function") {
|
|
3470
3470
|
const d = {
|
|
3471
3471
|
errMsg: `当前环境 (${e.type}) 不支持微信分享功能`,
|
|
@@ -3473,7 +3473,7 @@ function wn(t = {}) {
|
|
|
3473
3473
|
};
|
|
3474
3474
|
return s.error("平台不支持微信分享", { platform: e.type }), (a = t.fail) == null || a.call(t, d), Promise.reject(d);
|
|
3475
3475
|
}
|
|
3476
|
-
const n = E() ? lt(t) :
|
|
3476
|
+
const n = E() ? lt(t) : En(t);
|
|
3477
3477
|
if (!n.success) {
|
|
3478
3478
|
const d = { errMsg: n.message || "参数校验失败", code: "INVALID_PARAMS" };
|
|
3479
3479
|
return (g = t.fail) == null || g.call(t, d), Promise.reject(d);
|
|
@@ -3487,7 +3487,7 @@ function wn(t = {}) {
|
|
|
3487
3487
|
}
|
|
3488
3488
|
);
|
|
3489
3489
|
}
|
|
3490
|
-
const
|
|
3490
|
+
const In = {
|
|
3491
3491
|
OFF: "off",
|
|
3492
3492
|
// 蓝牙关闭
|
|
3493
3493
|
ON: "on",
|
|
@@ -3496,19 +3496,19 @@ const En = {
|
|
|
3496
3496
|
// 不支持蓝牙
|
|
3497
3497
|
UNAUTHORIZED: "unauthorized"
|
|
3498
3498
|
// 未授权
|
|
3499
|
-
},
|
|
3499
|
+
}, An = {
|
|
3500
3500
|
allowDuplicatesKey: !1,
|
|
3501
3501
|
// 是否允许重复上报同一设备
|
|
3502
3502
|
services: []
|
|
3503
3503
|
// 指定服务 UUID 列表
|
|
3504
3504
|
};
|
|
3505
3505
|
function we(t = {}) {
|
|
3506
|
-
return
|
|
3506
|
+
return p(p({}, An), t);
|
|
3507
3507
|
}
|
|
3508
3508
|
function se() {
|
|
3509
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
3509
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(c.type);
|
|
3510
3510
|
}
|
|
3511
|
-
function
|
|
3511
|
+
function On(t) {
|
|
3512
3512
|
return u.safeExecute(() => m(null, null, function* () {
|
|
3513
3513
|
var e;
|
|
3514
3514
|
if (!window.wx) {
|
|
@@ -3516,7 +3516,7 @@ function In(t) {
|
|
|
3516
3516
|
(e = t.fail) == null || e.call(t, r);
|
|
3517
3517
|
return;
|
|
3518
3518
|
}
|
|
3519
|
-
z() || (s.info("等待微信配置完成"), yield
|
|
3519
|
+
z() || (s.info("等待微信配置完成"), yield k()), wx.openBluetoothAdapter({
|
|
3520
3520
|
success: () => {
|
|
3521
3521
|
s.info("微信蓝牙适配器已打开"), dt(t);
|
|
3522
3522
|
},
|
|
@@ -3527,7 +3527,7 @@ function In(t) {
|
|
|
3527
3527
|
});
|
|
3528
3528
|
}), { context: "openBluetoothAdapterInWeixin" });
|
|
3529
3529
|
}
|
|
3530
|
-
function
|
|
3530
|
+
function _n(t) {
|
|
3531
3531
|
return u.safeExecute(() => {
|
|
3532
3532
|
s.debug("通过 WebView 桥接调用蓝牙功能", t), C("bluetooth", t, {
|
|
3533
3533
|
success: (e) => {
|
|
@@ -3542,7 +3542,7 @@ function An(t) {
|
|
|
3542
3542
|
});
|
|
3543
3543
|
}, { context: "bluetoothInUniApp" });
|
|
3544
3544
|
}
|
|
3545
|
-
function
|
|
3545
|
+
function Cn(t) {
|
|
3546
3546
|
return u.safeExecute(() => {
|
|
3547
3547
|
var e;
|
|
3548
3548
|
s.debug("通过 WebView 桥接调用蓝牙设备搜索功能", t), C("bluetoothDevicesDiscovery", {
|
|
@@ -3565,7 +3565,7 @@ function On(t) {
|
|
|
3565
3565
|
}, { context: "startBluetoothDevicesDiscoveryInUniApp" });
|
|
3566
3566
|
}
|
|
3567
3567
|
const oe = /* @__PURE__ */ new Set();
|
|
3568
|
-
function
|
|
3568
|
+
function Nn(t, e = {}) {
|
|
3569
3569
|
return u.safeExecute(() => {
|
|
3570
3570
|
var r;
|
|
3571
3571
|
return oe.add(t), oe.size === 1 && C("onBluetoothDeviceFound", {
|
|
@@ -3589,7 +3589,7 @@ function _n(t, e = {}) {
|
|
|
3589
3589
|
}), () => oe.delete(t);
|
|
3590
3590
|
}, { context: "qsh_onBluetoothDeviceFound" });
|
|
3591
3591
|
}
|
|
3592
|
-
function
|
|
3592
|
+
function Rn(t) {
|
|
3593
3593
|
return u.safeExecute(() => {
|
|
3594
3594
|
var e;
|
|
3595
3595
|
s.debug("通过 WebView 桥接调用蓝牙连接功能", t), C("bluetoothConnection", {
|
|
@@ -3612,42 +3612,42 @@ function Cn(t) {
|
|
|
3612
3612
|
});
|
|
3613
3613
|
}, { context: "createBLEConnectionInUniApp" });
|
|
3614
3614
|
}
|
|
3615
|
-
function
|
|
3615
|
+
function Sn(t = {}) {
|
|
3616
3616
|
return u.safeExecute(() => {
|
|
3617
3617
|
var r;
|
|
3618
3618
|
if (!se()) {
|
|
3619
3619
|
const n = {
|
|
3620
|
-
errMsg: `当前环境 (${
|
|
3620
|
+
errMsg: `当前环境 (${c.type}) 不支持蓝牙功能`,
|
|
3621
3621
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3622
3622
|
};
|
|
3623
|
-
s.error("平台不支持蓝牙", { platform:
|
|
3623
|
+
s.error("平台不支持蓝牙", { platform: c.type }), (r = t.fail) == null || r.call(t, n);
|
|
3624
3624
|
return;
|
|
3625
3625
|
}
|
|
3626
3626
|
const e = we(t);
|
|
3627
3627
|
s.info("开始蓝牙操作", {
|
|
3628
|
-
platform:
|
|
3628
|
+
platform: c.type,
|
|
3629
3629
|
services: e.services,
|
|
3630
3630
|
allowDuplicatesKey: e.allowDuplicatesKey
|
|
3631
|
-
}), E() ?
|
|
3631
|
+
}), E() ? On(e) : _n(e);
|
|
3632
3632
|
}, { context: "openBluetoothAdapter", options: t });
|
|
3633
3633
|
}
|
|
3634
|
-
function
|
|
3634
|
+
function Pn(t = {}) {
|
|
3635
3635
|
return u.safeExecute(() => {
|
|
3636
3636
|
var r, n;
|
|
3637
3637
|
if (!se()) {
|
|
3638
3638
|
const i = {
|
|
3639
|
-
errMsg: `当前环境 (${
|
|
3639
|
+
errMsg: `当前环境 (${c.type}) 不支持蓝牙功能`,
|
|
3640
3640
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3641
3641
|
};
|
|
3642
|
-
s.error("平台不支持蓝牙", { platform:
|
|
3642
|
+
s.error("平台不支持蓝牙", { platform: c.type }), (r = t.fail) == null || r.call(t, i), (n = t.complete) == null || n.call(t, i);
|
|
3643
3643
|
return;
|
|
3644
3644
|
}
|
|
3645
3645
|
const e = we(t);
|
|
3646
3646
|
s.info("开始搜索蓝牙设备", {
|
|
3647
|
-
platform:
|
|
3647
|
+
platform: c.type,
|
|
3648
3648
|
services: e.services,
|
|
3649
3649
|
allowDuplicatesKey: e.allowDuplicatesKey
|
|
3650
|
-
}), E() ? startBluetoothDevicesDiscoveryInWeixin(e) :
|
|
3650
|
+
}), E() ? startBluetoothDevicesDiscoveryInWeixin(e) : Cn(e);
|
|
3651
3651
|
}, { context: "startBluetoothDevicesDiscovery", options: t });
|
|
3652
3652
|
}
|
|
3653
3653
|
function dt(t, e = {}) {
|
|
@@ -3655,46 +3655,46 @@ function dt(t, e = {}) {
|
|
|
3655
3655
|
var n, i;
|
|
3656
3656
|
if (!se()) {
|
|
3657
3657
|
const a = {
|
|
3658
|
-
errMsg: `当前环境 (${
|
|
3658
|
+
errMsg: `当前环境 (${c.type}) 不支持蓝牙功能`,
|
|
3659
3659
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3660
3660
|
};
|
|
3661
|
-
s.error("平台不支持蓝牙", { platform:
|
|
3661
|
+
s.error("平台不支持蓝牙", { platform: c.type }), (n = e.fail) == null || n.call(e, a), (i = e.complete) == null || i.call(e, a);
|
|
3662
3662
|
return;
|
|
3663
3663
|
}
|
|
3664
3664
|
const r = we(e);
|
|
3665
|
-
s.info("注册蓝牙设备发现监听", { platform:
|
|
3665
|
+
s.info("注册蓝牙设备发现监听", { platform: c.type }), E() ? onBluetoothDeviceFoundInWeixin(r) : Nn(t, r);
|
|
3666
3666
|
}, { context: "onBluetoothDeviceFound", options: e });
|
|
3667
3667
|
}
|
|
3668
|
-
function
|
|
3668
|
+
function Tn(t = {}) {
|
|
3669
3669
|
return u.safeExecute(() => {
|
|
3670
|
-
var a, g, d,
|
|
3670
|
+
var a, g, d, l;
|
|
3671
3671
|
if (!se()) {
|
|
3672
|
-
const
|
|
3673
|
-
errMsg: `当前环境 (${
|
|
3672
|
+
const h = {
|
|
3673
|
+
errMsg: `当前环境 (${c.type}) 不支持蓝牙功能`,
|
|
3674
3674
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3675
3675
|
};
|
|
3676
|
-
s.error("平台不支持蓝牙连接", { platform:
|
|
3676
|
+
s.error("平台不支持蓝牙连接", { platform: c.type }), (a = t.fail) == null || a.call(t, h), (g = t.complete) == null || g.call(t, h);
|
|
3677
3677
|
return;
|
|
3678
3678
|
}
|
|
3679
3679
|
const e = we(t), { name: r, deviceId: n, autoConnect: i = !1 } = e;
|
|
3680
3680
|
if (!n) {
|
|
3681
|
-
const
|
|
3682
|
-
(d = t.fail) == null || d.call(t,
|
|
3681
|
+
const h = { errMsg: "缺少 deviceId 参数", code: "INVALID_PARAMS" };
|
|
3682
|
+
(d = t.fail) == null || d.call(t, h), (l = t.complete) == null || l.call(t, h);
|
|
3683
3683
|
return;
|
|
3684
3684
|
}
|
|
3685
|
-
s.info("创建蓝牙连接", { deviceId: n, autoConnect: i, platform:
|
|
3685
|
+
s.info("创建蓝牙连接", { deviceId: n, autoConnect: i, platform: c.type }), E() ? uni.createBLEConnection({
|
|
3686
3686
|
deviceId: n,
|
|
3687
3687
|
autoConnect: i,
|
|
3688
3688
|
success: t.success,
|
|
3689
3689
|
fail: t.fail,
|
|
3690
3690
|
complete: t.complete
|
|
3691
|
-
}) :
|
|
3691
|
+
}) : Rn(e);
|
|
3692
3692
|
}, { context: "createBLEConnection", options: t });
|
|
3693
3693
|
}
|
|
3694
|
-
function
|
|
3694
|
+
function Ln() {
|
|
3695
3695
|
return {
|
|
3696
3696
|
supported: se(),
|
|
3697
|
-
environment:
|
|
3697
|
+
environment: c.type,
|
|
3698
3698
|
implementation: E() ? "weixin" : "webview",
|
|
3699
3699
|
features: {
|
|
3700
3700
|
discovery: !0,
|
|
@@ -3705,13 +3705,71 @@ function Tn() {
|
|
|
3705
3705
|
}
|
|
3706
3706
|
};
|
|
3707
3707
|
}
|
|
3708
|
-
const
|
|
3708
|
+
const Mn = {
|
|
3709
|
+
// TODO: 添加更多默认配置
|
|
3710
|
+
};
|
|
3711
|
+
function bn(t = {}) {
|
|
3712
|
+
return p(p({}, Mn), t);
|
|
3713
|
+
}
|
|
3714
|
+
function gt() {
|
|
3715
|
+
return ["UniApp", "plus", "nvue", "uvue"].includes(c.type);
|
|
3716
|
+
}
|
|
3717
|
+
function vn(t) {
|
|
3718
|
+
return u.safeExecute(() => {
|
|
3719
|
+
s.debug("通过 WebView 桥接调用打印PDF", t), C("printPdf", A(p({}, t), {
|
|
3720
|
+
isPersistent: !0
|
|
3721
|
+
// 强制禁用超时自动清理
|
|
3722
|
+
}), {
|
|
3723
|
+
success: (e) => {
|
|
3724
|
+
var r;
|
|
3725
|
+
s.info("UniApp 打印PDF成功", e), (r = t.success) == null || r.call(t, e);
|
|
3726
|
+
},
|
|
3727
|
+
fail: (e) => {
|
|
3728
|
+
var r;
|
|
3729
|
+
s.error("UniApp 打印PDF失败", e), (r = t.fail) == null || r.call(t, e);
|
|
3730
|
+
},
|
|
3731
|
+
complete: t.complete
|
|
3732
|
+
});
|
|
3733
|
+
}, {
|
|
3734
|
+
context: "printPdfInUniApp",
|
|
3735
|
+
platform: "uniapp"
|
|
3736
|
+
});
|
|
3737
|
+
}
|
|
3738
|
+
function xn(t = {}) {
|
|
3739
|
+
return u.safeExecute(() => {
|
|
3740
|
+
var r;
|
|
3741
|
+
if (!gt()) {
|
|
3742
|
+
const n = {
|
|
3743
|
+
errMsg: `当前环境 (${c.type}) 不支持打印PDF功能`,
|
|
3744
|
+
code: "PLATFORM_NOT_SUPPORTED"
|
|
3745
|
+
};
|
|
3746
|
+
s.error("平台不支持打印PDF", { platform: c.type }), (r = t.fail) == null || r.call(t, n);
|
|
3747
|
+
return;
|
|
3748
|
+
}
|
|
3749
|
+
const e = bn(t);
|
|
3750
|
+
s.info("开始打印PDF", { platform: c.type }), vn(e);
|
|
3751
|
+
}, {
|
|
3752
|
+
context: "printPdf",
|
|
3753
|
+
options: t
|
|
3754
|
+
});
|
|
3755
|
+
}
|
|
3756
|
+
function Dn() {
|
|
3757
|
+
return {
|
|
3758
|
+
supported: gt(),
|
|
3759
|
+
environment: c.type,
|
|
3760
|
+
implementation: "uniapp",
|
|
3761
|
+
features: {
|
|
3762
|
+
asyncSupport: !0
|
|
3763
|
+
}
|
|
3764
|
+
};
|
|
3765
|
+
}
|
|
3766
|
+
const pt = Ne();
|
|
3709
3767
|
K.useResponse(Ve.response, { priority: 1e3 });
|
|
3710
3768
|
let Ue = !1;
|
|
3711
3769
|
function We() {
|
|
3712
3770
|
if (Ue) return;
|
|
3713
|
-
Ue = !0,
|
|
3714
|
-
{ name: "load-weixin-sdk", run:
|
|
3771
|
+
Ue = !0, sr([
|
|
3772
|
+
{ name: "load-weixin-sdk", run: zt, timeoutMs: 8e3 },
|
|
3715
3773
|
{ name: "init-bridge", run: ze, timeoutMs: 8e3 }
|
|
3716
3774
|
], {
|
|
3717
3775
|
onError: (e, r) => {
|
|
@@ -3722,107 +3780,116 @@ function We() {
|
|
|
3722
3780
|
typeof window != "undefined" && (document.readyState === "complete" || document.readyState === "interactive" ? setTimeout(We, 0) : document.addEventListener("DOMContentLoaded", We));
|
|
3723
3781
|
function I(t, { apiName: e } = {}) {
|
|
3724
3782
|
return function(r = {}, ...n) {
|
|
3725
|
-
const i = r && typeof r == "object" && (typeof r.success == "function" || typeof r.fail == "function" || typeof r.complete == "function"), a = r && typeof r == "object" ? r : {}, g = () => i ? t(a, ...n) : new Promise((
|
|
3726
|
-
const
|
|
3783
|
+
const i = r && typeof r == "object" && (typeof r.success == "function" || typeof r.fail == "function" || typeof r.complete == "function"), a = r && typeof r == "object" ? r : {}, g = () => i ? t(a, ...n) : new Promise((l, h) => {
|
|
3784
|
+
const T = A(p({}, a), {
|
|
3727
3785
|
success: (N) => {
|
|
3728
|
-
typeof a.success == "function" && a.success(N),
|
|
3786
|
+
typeof a.success == "function" && a.success(N), l(N);
|
|
3729
3787
|
},
|
|
3730
3788
|
fail: (N) => {
|
|
3731
|
-
typeof a.fail == "function" && a.fail(N),
|
|
3789
|
+
typeof a.fail == "function" && a.fail(N), h(N);
|
|
3732
3790
|
},
|
|
3733
3791
|
complete: a.complete
|
|
3734
3792
|
});
|
|
3735
|
-
t(
|
|
3793
|
+
t(T, ...n);
|
|
3736
3794
|
});
|
|
3737
|
-
return (typeof window == "undefined" ? Promise.resolve() :
|
|
3738
|
-
throw console.error(`[QSH-SDK] ${e || "API"} call failed:`,
|
|
3795
|
+
return (typeof window == "undefined" ? Promise.resolve() : Fe()).then(() => g()).catch((l) => {
|
|
3796
|
+
throw console.error(`[QSH-SDK] ${e || "API"} call failed:`, l), l;
|
|
3739
3797
|
});
|
|
3740
3798
|
};
|
|
3741
3799
|
}
|
|
3742
3800
|
function ce(t) {
|
|
3743
3801
|
return typeof t == "function" ? { success: t } : t && typeof t == "object" ? t : {};
|
|
3744
3802
|
}
|
|
3745
|
-
const ht = I(
|
|
3746
|
-
function
|
|
3747
|
-
const e = () =>
|
|
3748
|
-
return (typeof window == "undefined" ? Promise.resolve() :
|
|
3803
|
+
const ht = I(Nr), mt = I(Rr), wt = I(Sr), Et = I(Pr), yt = I(Tr), It = I(Lr);
|
|
3804
|
+
function At(t) {
|
|
3805
|
+
const e = () => Mr(t);
|
|
3806
|
+
return (typeof window == "undefined" ? Promise.resolve() : Fe()).then(() => e());
|
|
3749
3807
|
}
|
|
3750
|
-
const Se = I(
|
|
3751
|
-
function
|
|
3808
|
+
const Se = I($r);
|
|
3809
|
+
function Un(t = {}) {
|
|
3752
3810
|
return new Promise((e, r) => {
|
|
3753
|
-
Se(
|
|
3811
|
+
Se(A(p({}, t), {
|
|
3754
3812
|
success: e,
|
|
3755
3813
|
fail: r
|
|
3756
3814
|
}));
|
|
3757
3815
|
});
|
|
3758
3816
|
}
|
|
3759
|
-
const
|
|
3760
|
-
function
|
|
3817
|
+
const Ot = I(xn);
|
|
3818
|
+
function Wn(t = {}) {
|
|
3761
3819
|
return new Promise((e, r) => {
|
|
3762
|
-
|
|
3820
|
+
Ot(A(p({}, t), {
|
|
3763
3821
|
success: e,
|
|
3764
3822
|
fail: r
|
|
3765
3823
|
}));
|
|
3766
3824
|
});
|
|
3767
3825
|
}
|
|
3768
|
-
const
|
|
3769
|
-
function
|
|
3826
|
+
const Pe = I(Gr);
|
|
3827
|
+
function $n(t = {}) {
|
|
3770
3828
|
return new Promise((e, r) => {
|
|
3771
|
-
Pe(
|
|
3829
|
+
Pe(A(p({}, t), {
|
|
3772
3830
|
success: e,
|
|
3773
3831
|
fail: r
|
|
3774
3832
|
}));
|
|
3775
3833
|
});
|
|
3776
3834
|
}
|
|
3777
|
-
const
|
|
3778
|
-
function
|
|
3835
|
+
const Bn = I(yn), Te = I(Qr);
|
|
3836
|
+
function Fn(t = {}) {
|
|
3779
3837
|
return new Promise((e, r) => {
|
|
3780
|
-
|
|
3838
|
+
Te(A(p({}, t), {
|
|
3781
3839
|
success: e,
|
|
3782
3840
|
fail: r
|
|
3783
3841
|
}));
|
|
3784
3842
|
});
|
|
3785
3843
|
}
|
|
3786
|
-
const
|
|
3787
|
-
function
|
|
3844
|
+
const Le = I(en);
|
|
3845
|
+
function kn(t = {}) {
|
|
3788
3846
|
return new Promise((e, r) => {
|
|
3789
|
-
|
|
3847
|
+
Le(A(p({}, t), {
|
|
3790
3848
|
success: e,
|
|
3791
3849
|
fail: r
|
|
3792
3850
|
}));
|
|
3793
3851
|
});
|
|
3794
3852
|
}
|
|
3795
|
-
const
|
|
3796
|
-
function
|
|
3853
|
+
const Me = I(dn);
|
|
3854
|
+
function zn(t = {}) {
|
|
3797
3855
|
return new Promise((e, r) => {
|
|
3798
|
-
|
|
3856
|
+
Me(A(p({}, t), {
|
|
3799
3857
|
success: e,
|
|
3800
3858
|
fail: r
|
|
3801
3859
|
}));
|
|
3802
3860
|
});
|
|
3803
3861
|
}
|
|
3804
|
-
const
|
|
3805
|
-
function
|
|
3862
|
+
const _t = I(Sn);
|
|
3863
|
+
function Kn(t = {}) {
|
|
3806
3864
|
return new Promise((e, r) => {
|
|
3807
|
-
|
|
3865
|
+
_t(A(p({}, t), {
|
|
3808
3866
|
success: e,
|
|
3809
3867
|
fail: r
|
|
3810
3868
|
}));
|
|
3811
3869
|
});
|
|
3812
3870
|
}
|
|
3813
|
-
const
|
|
3814
|
-
function
|
|
3871
|
+
const Ct = I(Pn);
|
|
3872
|
+
function Gn(t = {}) {
|
|
3873
|
+
return new Promise((e, r) => {
|
|
3874
|
+
Ct(A(p({}, t), {
|
|
3875
|
+
success: e,
|
|
3876
|
+
fail: r
|
|
3877
|
+
}));
|
|
3878
|
+
});
|
|
3879
|
+
}
|
|
3880
|
+
const Nt = I(dt);
|
|
3881
|
+
function Vn(t = {}) {
|
|
3815
3882
|
return new Promise((e, r) => {
|
|
3816
|
-
|
|
3883
|
+
Nt(A(p({}, t), {
|
|
3817
3884
|
success: e,
|
|
3818
3885
|
fail: r
|
|
3819
3886
|
}));
|
|
3820
3887
|
});
|
|
3821
3888
|
}
|
|
3822
|
-
const
|
|
3823
|
-
function
|
|
3889
|
+
const Rt = I(Tn);
|
|
3890
|
+
function jn(t = {}) {
|
|
3824
3891
|
return new Promise((e, r) => {
|
|
3825
|
-
|
|
3892
|
+
Rt(A(p({}, t), {
|
|
3826
3893
|
success: e,
|
|
3827
3894
|
fail: r
|
|
3828
3895
|
}));
|
|
@@ -3831,35 +3898,35 @@ function Bn(t = {}) {
|
|
|
3831
3898
|
const Q = {
|
|
3832
3899
|
// 导航 API
|
|
3833
3900
|
navigateTo: ht,
|
|
3834
|
-
navigateBack:
|
|
3835
|
-
switchTab:
|
|
3836
|
-
reLaunch:
|
|
3837
|
-
redirectTo:
|
|
3901
|
+
navigateBack: mt,
|
|
3902
|
+
switchTab: wt,
|
|
3903
|
+
reLaunch: Et,
|
|
3904
|
+
redirectTo: yt,
|
|
3838
3905
|
// 消息 API
|
|
3839
|
-
postMessage:
|
|
3840
|
-
getEnv:
|
|
3906
|
+
postMessage: It,
|
|
3907
|
+
getEnv: At,
|
|
3841
3908
|
// 图片 API
|
|
3842
3909
|
chooseImage: Se,
|
|
3843
|
-
chooseImageAsync:
|
|
3910
|
+
chooseImageAsync: Un,
|
|
3844
3911
|
// 扫码 API
|
|
3845
|
-
scanCode:
|
|
3846
|
-
scanCodeAsync:
|
|
3912
|
+
scanCode: Pe,
|
|
3913
|
+
scanCodeAsync: $n,
|
|
3847
3914
|
// 位置 API
|
|
3848
|
-
getLocation:
|
|
3849
|
-
getLocationAsync:
|
|
3915
|
+
getLocation: Te,
|
|
3916
|
+
getLocationAsync: Fn,
|
|
3850
3917
|
openLocation: Le,
|
|
3851
|
-
openLocationAsync:
|
|
3918
|
+
openLocationAsync: kn,
|
|
3852
3919
|
chooseLocation: Me,
|
|
3853
|
-
chooseLocationAsync:
|
|
3920
|
+
chooseLocationAsync: zn,
|
|
3854
3921
|
// 位置监听 API(保留回调签名)
|
|
3855
|
-
onLocationChange: (t) => I((e = {}) =>
|
|
3856
|
-
offLocationChange: (t) => I((e = {}) =>
|
|
3857
|
-
onLocationChangeError: (t) => I((e = {}) =>
|
|
3858
|
-
offLocationChangeError: (t) => I((e = {}) =>
|
|
3859
|
-
startLocationUpdate: I(
|
|
3860
|
-
stopLocationUpdate: I(
|
|
3922
|
+
onLocationChange: (t) => I((e = {}) => sn(e.success), { apiName: "onLocationChange" })(ce(t)),
|
|
3923
|
+
offLocationChange: (t) => I((e = {}) => an(e.success), { apiName: "offLocationChange" })(ce(t)),
|
|
3924
|
+
onLocationChangeError: (t) => I((e = {}) => on(e.success), { apiName: "onLocationChangeError" })(ce(t)),
|
|
3925
|
+
offLocationChangeError: (t) => I((e = {}) => cn(e.success), { apiName: "offLocationChangeError" })(ce(t)),
|
|
3926
|
+
startLocationUpdate: I(rn, { apiName: "startLocationUpdate" }),
|
|
3927
|
+
stopLocationUpdate: I(nn, { apiName: "stopLocationUpdate" }),
|
|
3861
3928
|
// 环境信息
|
|
3862
|
-
environment:
|
|
3929
|
+
environment: pt,
|
|
3863
3930
|
/**
|
|
3864
3931
|
* 等待 JSBridge 就绪
|
|
3865
3932
|
* 返回一个 Promise,当桥接完成初始化后 resolve。
|
|
@@ -3868,7 +3935,7 @@ const Q = {
|
|
|
3868
3935
|
* await qsh.ready()
|
|
3869
3936
|
* @since 2.0.0
|
|
3870
3937
|
*/
|
|
3871
|
-
ready:
|
|
3938
|
+
ready: Bt,
|
|
3872
3939
|
/**
|
|
3873
3940
|
* 手动初始化 JSBridge
|
|
3874
3941
|
* 默认会在 DOM 就绪时自动初始化;如需更早或手动控制,可调用本方法。
|
|
@@ -3885,7 +3952,7 @@ const Q = {
|
|
|
3885
3952
|
* if (qsh.isReady()) { console.log('ready') }
|
|
3886
3953
|
* @since 2.0.0
|
|
3887
3954
|
*/
|
|
3888
|
-
isReady:
|
|
3955
|
+
isReady: xt,
|
|
3889
3956
|
/**
|
|
3890
3957
|
* 获取当前 SDK 状态
|
|
3891
3958
|
* @returns {string}
|
|
@@ -3893,7 +3960,7 @@ const Q = {
|
|
|
3893
3960
|
* console.log(qsh.getState()) // 'ready'
|
|
3894
3961
|
* @since 2.0.0
|
|
3895
3962
|
*/
|
|
3896
|
-
getState:
|
|
3963
|
+
getState: Dt,
|
|
3897
3964
|
// 微信配置 API
|
|
3898
3965
|
weixin: {
|
|
3899
3966
|
/**
|
|
@@ -3903,7 +3970,7 @@ const Q = {
|
|
|
3903
3970
|
* await qsh.weixin.waitForConfig()
|
|
3904
3971
|
* @since 2.0.0
|
|
3905
3972
|
*/
|
|
3906
|
-
waitForConfig:
|
|
3973
|
+
waitForConfig: k,
|
|
3907
3974
|
/**
|
|
3908
3975
|
* 检查微信配置是否完成
|
|
3909
3976
|
* @returns {boolean}
|
|
@@ -3919,7 +3986,7 @@ const Q = {
|
|
|
3919
3986
|
* console.log(qsh.weixin.getConfigState()) // 'configured'
|
|
3920
3987
|
* @since 2.0.0
|
|
3921
3988
|
*/
|
|
3922
|
-
getConfigState:
|
|
3989
|
+
getConfigState: Kt,
|
|
3923
3990
|
/**
|
|
3924
3991
|
* 手动重试微信配置
|
|
3925
3992
|
* @returns {Promise<void>}
|
|
@@ -3927,7 +3994,7 @@ const Q = {
|
|
|
3927
3994
|
* await qsh.weixin.retryConfig()
|
|
3928
3995
|
* @since 2.0.0
|
|
3929
3996
|
*/
|
|
3930
|
-
retryConfig:
|
|
3997
|
+
retryConfig: Gt
|
|
3931
3998
|
},
|
|
3932
3999
|
// WebView 对象(兼容旧版本)
|
|
3933
4000
|
webView: null,
|
|
@@ -3942,7 +4009,7 @@ const Q = {
|
|
|
3942
4009
|
* console.log('是否支持:', capabilities.supported)
|
|
3943
4010
|
* @since 2.0.0
|
|
3944
4011
|
*/
|
|
3945
|
-
getImageCapabilities:
|
|
4012
|
+
getImageCapabilities: Br,
|
|
3946
4013
|
// 扫码相关常量
|
|
3947
4014
|
ScanTypes: V,
|
|
3948
4015
|
/**
|
|
@@ -3953,7 +4020,7 @@ const Q = {
|
|
|
3953
4020
|
* console.log('是否支持:', capabilities.supported)
|
|
3954
4021
|
* @since 2.1.0
|
|
3955
4022
|
*/
|
|
3956
|
-
getScanCapabilities:
|
|
4023
|
+
getScanCapabilities: Vr,
|
|
3957
4024
|
// 位置相关常量
|
|
3958
4025
|
CoordinateTypes: Z,
|
|
3959
4026
|
/**
|
|
@@ -3964,7 +4031,7 @@ const Q = {
|
|
|
3964
4031
|
* console.log('是否支持:', capabilities.supported)
|
|
3965
4032
|
* @since 2.1.0
|
|
3966
4033
|
*/
|
|
3967
|
-
getLocationCapabilities:
|
|
4034
|
+
getLocationCapabilities: tn,
|
|
3968
4035
|
/**
|
|
3969
4036
|
* 获取位置选择功能能力信息
|
|
3970
4037
|
* @returns {Object} 能力信息对象
|
|
@@ -3973,20 +4040,20 @@ const Q = {
|
|
|
3973
4040
|
* console.log('是否支持:', capabilities.supported)
|
|
3974
4041
|
* @since 2.1.0
|
|
3975
4042
|
*/
|
|
3976
|
-
getChooseLocationCapabilities:
|
|
4043
|
+
getChooseLocationCapabilities: gn,
|
|
3977
4044
|
// 蓝牙 API
|
|
3978
|
-
openBluetoothAdapter:
|
|
3979
|
-
openBluetoothAdapterAsync:
|
|
3980
|
-
startBluetoothDevicesDiscovery:
|
|
3981
|
-
startBluetoothDevicesDiscoveryAsync:
|
|
3982
|
-
onBluetoothDeviceFound:
|
|
3983
|
-
onBluetoothDeviceFoundAsync:
|
|
3984
|
-
createBLEConnection:
|
|
3985
|
-
createBLEConnectionAsync:
|
|
4045
|
+
openBluetoothAdapter: _t,
|
|
4046
|
+
openBluetoothAdapterAsync: Kn,
|
|
4047
|
+
startBluetoothDevicesDiscovery: Ct,
|
|
4048
|
+
startBluetoothDevicesDiscoveryAsync: Gn,
|
|
4049
|
+
onBluetoothDeviceFound: Nt,
|
|
4050
|
+
onBluetoothDeviceFoundAsync: Vn,
|
|
4051
|
+
createBLEConnection: Rt,
|
|
4052
|
+
createBLEConnectionAsync: jn,
|
|
3986
4053
|
// 蓝牙相关常量
|
|
3987
|
-
BluetoothStates:
|
|
4054
|
+
BluetoothStates: In,
|
|
3988
4055
|
//微信分享
|
|
3989
|
-
toShare:
|
|
4056
|
+
toShare: Bn,
|
|
3990
4057
|
/**
|
|
3991
4058
|
* 获取蓝牙功能能力信息
|
|
3992
4059
|
* @returns {Object} 能力信息对象
|
|
@@ -3994,7 +4061,18 @@ const Q = {
|
|
|
3994
4061
|
* const capabilities = qsh.getBluetoothCapabilities()
|
|
3995
4062
|
* console.log('是否支持:', capabilities.supported)
|
|
3996
4063
|
*/
|
|
3997
|
-
getBluetoothCapabilities:
|
|
4064
|
+
getBluetoothCapabilities: Ln,
|
|
4065
|
+
// 打印PDF API
|
|
4066
|
+
printPdf: Ot,
|
|
4067
|
+
printPdfAsync: Wn,
|
|
4068
|
+
/**
|
|
4069
|
+
* 获取打印PDF功能能力信息
|
|
4070
|
+
* @returns {Object} 能力信息对象
|
|
4071
|
+
* @example
|
|
4072
|
+
* const capabilities = qsh.getPrintCapabilities()
|
|
4073
|
+
* console.log('是否支持:', capabilities.supported)
|
|
4074
|
+
*/
|
|
4075
|
+
getPrintCapabilities: Dn,
|
|
3998
4076
|
// 插件系统
|
|
3999
4077
|
plugins: {
|
|
4000
4078
|
/**
|
|
@@ -4059,10 +4137,10 @@ const Q = {
|
|
|
4059
4137
|
* 内置拦截器
|
|
4060
4138
|
*/
|
|
4061
4139
|
builtin: {
|
|
4062
|
-
logging:
|
|
4140
|
+
logging: qt,
|
|
4063
4141
|
performance: W,
|
|
4064
|
-
createRetry:
|
|
4065
|
-
createValidation:
|
|
4142
|
+
createRetry: Jt,
|
|
4143
|
+
createValidation: Ht,
|
|
4066
4144
|
errorNormalizer: Ve
|
|
4067
4145
|
}
|
|
4068
4146
|
},
|
|
@@ -4108,7 +4186,7 @@ const Q = {
|
|
|
4108
4186
|
* @example
|
|
4109
4187
|
* const error = qsh.errors.create('E_IMG_001', { apiName: 'chooseImage' })
|
|
4110
4188
|
*/
|
|
4111
|
-
create:
|
|
4189
|
+
create: rr,
|
|
4112
4190
|
/**
|
|
4113
4191
|
* 判断是否为标准错误
|
|
4114
4192
|
* @param {any} error - 错误对象
|
|
@@ -4116,7 +4194,7 @@ const Q = {
|
|
|
4116
4194
|
* @example
|
|
4117
4195
|
* if (qsh.errors.isStandard(error)) { ... }
|
|
4118
4196
|
*/
|
|
4119
|
-
isStandard:
|
|
4197
|
+
isStandard: nr
|
|
4120
4198
|
},
|
|
4121
4199
|
// 状态管理
|
|
4122
4200
|
store: {
|
|
@@ -4221,23 +4299,23 @@ const Q = {
|
|
|
4221
4299
|
exportDebugInfo: () => S.exportToJSON()
|
|
4222
4300
|
}
|
|
4223
4301
|
};
|
|
4224
|
-
|
|
4302
|
+
pt.isWeixinMiniProgram ? Q.webView = window.wx && window.wx.miniProgram : Q.webView = {
|
|
4225
4303
|
navigateTo: ht,
|
|
4226
|
-
navigateBack:
|
|
4227
|
-
switchTab:
|
|
4228
|
-
reLaunch:
|
|
4229
|
-
redirectTo:
|
|
4230
|
-
postMessage:
|
|
4231
|
-
getEnv:
|
|
4304
|
+
navigateBack: mt,
|
|
4305
|
+
switchTab: wt,
|
|
4306
|
+
reLaunch: Et,
|
|
4307
|
+
redirectTo: yt,
|
|
4308
|
+
postMessage: It,
|
|
4309
|
+
getEnv: At,
|
|
4232
4310
|
chooseImage: Se,
|
|
4233
|
-
scanCode:
|
|
4234
|
-
getLocation:
|
|
4311
|
+
scanCode: Pe,
|
|
4312
|
+
getLocation: Te,
|
|
4235
4313
|
openLocation: Le,
|
|
4236
4314
|
chooseLocation: Me
|
|
4237
4315
|
};
|
|
4238
|
-
const
|
|
4239
|
-
Object.keys(
|
|
4240
|
-
Q.hasOwnProperty(t) || (Q[t] =
|
|
4316
|
+
const $e = typeof window.uni != "undefined" ? window.uni : {};
|
|
4317
|
+
Object.keys($e).forEach((t) => {
|
|
4318
|
+
Q.hasOwnProperty(t) || (Q[t] = $e[t]);
|
|
4241
4319
|
});
|
|
4242
4320
|
typeof window != "undefined" && (window.qsh = Q);
|
|
4243
4321
|
export {
|