mo-h5-bridge 0.0.36 → 0.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/mo-h5-bridge.js +224 -185
- package/dist/mo-h5-bridge.js.map +1 -1
- package/dist-doc/assets/{index-B0yXd2d4.js → index--vr-ogPd.js} +1 -1
- package/dist-doc/assets/{index-6G5kKEmO.js → index-B-v8HhE9.js} +1 -1
- package/dist-doc/assets/{index-DXrSUzHl.js → index-B9O-pvFv.js} +1 -1
- package/dist-doc/assets/{index-Czia4XQy.js → index-BJtubsIy.js} +1 -1
- package/dist-doc/assets/{index-DHtMatgJ.js → index-BOY2v7SC.js} +1 -1
- package/dist-doc/assets/{index-byjBO21D.js → index-BXpuuNqO.js} +1 -1
- package/dist-doc/assets/{index-Cwz4wBzV.js → index-BdnFYay5.js} +1 -1
- package/dist-doc/assets/{index-Bcn8KBoH.js → index-ClxOrcFI.js} +1 -1
- package/dist-doc/assets/{index-Ds3ZgNtp.js → index-D4WNZCgR.js} +1 -1
- package/dist-doc/assets/{index-CVQYLomJ.js → index-DQh8FIBo.js} +1 -1
- package/dist-doc/assets/{index-Ba0Fwn4c.js → index-DVpCRRK1.js} +1 -1
- package/dist-doc/assets/{index-DOiZW0lW.js → index-DdPEB-se.js} +3 -3
- package/dist-doc/assets/{index-CbGMLWri.js → index-U0ZajFgL.js} +1 -1
- package/dist-doc/assets/{index-C-eCLbHz.js → index-oq9Bd0UD.js} +1 -1
- package/dist-doc/assets/{index-DBqBK2BI.js → index-xshNlWrA.js} +1 -1
- package/dist-doc/assets/main-D8QW5WbL.js +1 -0
- package/package.json +2 -2
- package/dist-doc/assets/main-DZxBhGij.js +0 -1
package/dist/index.d.ts
CHANGED
package/dist/mo-h5-bridge.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
function
|
|
2
|
-
return new Promise((
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}, document.head.appendChild(
|
|
1
|
+
function f(t) {
|
|
2
|
+
return new Promise((e) => {
|
|
3
|
+
const i = document.createElement("script");
|
|
4
|
+
i.type = "text/javascript", i.src = t, i.onload = function() {
|
|
5
|
+
e();
|
|
6
|
+
}, document.head.appendChild(i);
|
|
7
7
|
});
|
|
8
8
|
}
|
|
9
|
-
const
|
|
9
|
+
const r = navigator.userAgent, m = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(r), w = /Windows|Macintosh|Linux/i.test(r) && !m, s = {
|
|
10
10
|
WeChatMini: "WeChatMini",
|
|
11
11
|
// 微信小程序
|
|
12
12
|
AlipayMini: "AlipayMini",
|
|
@@ -19,53 +19,53 @@ const c = navigator.userAgent, p = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IE
|
|
|
19
19
|
// 移动端
|
|
20
20
|
Pc: "Pc"
|
|
21
21
|
// pc端
|
|
22
|
-
},
|
|
23
|
-
["is" +
|
|
22
|
+
}, g = {
|
|
23
|
+
["is" + s.WeChatMini]: /miniProgram/i.test(r),
|
|
24
24
|
// 微信小程序
|
|
25
|
-
["is" +
|
|
25
|
+
["is" + s.AlipayMini]: /AlipayClient.*miniProgram/i.test(r),
|
|
26
26
|
// 支付宝小程序
|
|
27
|
-
["is" +
|
|
27
|
+
["is" + s.Android]: /Android/i.test(r),
|
|
28
28
|
// andorid
|
|
29
|
-
["is" +
|
|
29
|
+
["is" + s.Ios]: /iPhone|iPad|iPod/i.test(r),
|
|
30
30
|
// ios
|
|
31
|
-
["is" +
|
|
32
|
-
["is" +
|
|
31
|
+
["is" + s.Mobile]: m,
|
|
32
|
+
["is" + s.Pc]: w
|
|
33
33
|
}, h = "https://appx/web-view.min.js", v = {
|
|
34
34
|
// 用于在外勤app中,app返回到库存管理页面中,刷新库存管理页面
|
|
35
35
|
refreshCar: void 0
|
|
36
36
|
};
|
|
37
37
|
class y {
|
|
38
38
|
constructor() {
|
|
39
|
-
this.map = /* @__PURE__ */ new Map(), Object.keys(v).forEach((
|
|
40
|
-
this.map.set(
|
|
39
|
+
this.map = /* @__PURE__ */ new Map(), Object.keys(v).forEach((e) => {
|
|
40
|
+
this.map.set(e, /* @__PURE__ */ new Set());
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
// 添加元素到指定键的集合
|
|
44
|
-
add(
|
|
45
|
-
return this.map.has(
|
|
44
|
+
add(e, i) {
|
|
45
|
+
return this.map.has(e) || this.map.set(e, /* @__PURE__ */ new Set()), this.map.get(e).add(i), this;
|
|
46
46
|
}
|
|
47
47
|
// 从指定键的集合中删除元素
|
|
48
|
-
delete(
|
|
49
|
-
if (!this.map.has(
|
|
48
|
+
delete(e, i) {
|
|
49
|
+
if (!this.map.has(e))
|
|
50
50
|
return !1;
|
|
51
|
-
const
|
|
52
|
-
return
|
|
51
|
+
const n = this.map.get(e), a = n.delete(i);
|
|
52
|
+
return n.size === 0 && this.map.delete(e), a;
|
|
53
53
|
}
|
|
54
54
|
// 检查指定键的集合是否包含元素
|
|
55
|
-
has(
|
|
56
|
-
return this.map.has(
|
|
55
|
+
has(e, i) {
|
|
56
|
+
return this.map.has(e) && this.map.get(e).has(i);
|
|
57
57
|
}
|
|
58
58
|
// 获取指定键的集合
|
|
59
|
-
get(
|
|
60
|
-
return this.map.get(
|
|
59
|
+
get(e) {
|
|
60
|
+
return this.map.get(e) || /* @__PURE__ */ new Set();
|
|
61
61
|
}
|
|
62
62
|
// 删除整个键及其集合
|
|
63
|
-
deleteKey(
|
|
64
|
-
return this.map.delete(
|
|
63
|
+
deleteKey(e) {
|
|
64
|
+
return this.map.delete(e);
|
|
65
65
|
}
|
|
66
66
|
// 检查键是否存在
|
|
67
|
-
hasKey(
|
|
68
|
-
return this.map.has(
|
|
67
|
+
hasKey(e) {
|
|
68
|
+
return this.map.has(e);
|
|
69
69
|
}
|
|
70
70
|
// 获取所有键
|
|
71
71
|
keys() {
|
|
@@ -84,234 +84,262 @@ class y {
|
|
|
84
84
|
this.map.clear();
|
|
85
85
|
}
|
|
86
86
|
// 遍历每个键的集合
|
|
87
|
-
forEach(
|
|
88
|
-
this.map.forEach((
|
|
89
|
-
i
|
|
87
|
+
forEach(e) {
|
|
88
|
+
this.map.forEach((i, n) => {
|
|
89
|
+
e(i, n, this.map);
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
const
|
|
94
|
-
navigateTo:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
93
|
+
const B = new y(), o = {
|
|
94
|
+
navigateTo: () => {
|
|
95
|
+
console.warn("Bridge:navigateTo not init");
|
|
96
|
+
},
|
|
97
|
+
navigateBack: () => {
|
|
98
|
+
console.warn("Bridge:navigateBack not init");
|
|
99
|
+
},
|
|
100
|
+
switchTab: () => {
|
|
101
|
+
console.warn("Bridge:switchTab not init");
|
|
102
|
+
},
|
|
103
|
+
getLocation: () => {
|
|
104
|
+
console.warn("Bridge:getLocation not init");
|
|
105
|
+
},
|
|
106
|
+
openLocation: () => {
|
|
107
|
+
console.warn("Bridge:openLocation not init");
|
|
108
|
+
},
|
|
109
|
+
postMessage: () => {
|
|
110
|
+
console.warn("Bridge:postMessage not init");
|
|
111
|
+
},
|
|
112
|
+
onMessage: () => {
|
|
113
|
+
console.warn("Bridge:onMessage not init");
|
|
114
|
+
},
|
|
115
|
+
authorize: () => {
|
|
116
|
+
console.warn("Bridge:authorize not init");
|
|
117
|
+
},
|
|
118
|
+
getToken: () => {
|
|
119
|
+
console.warn("Bridge:getToken not init");
|
|
120
|
+
},
|
|
121
|
+
gotoOrderDetail: () => {
|
|
122
|
+
console.warn("Bridge:gotoOrderDetail not init");
|
|
123
|
+
},
|
|
124
|
+
getAreas: () => {
|
|
125
|
+
console.warn("Bridge:getAreas not init");
|
|
126
|
+
},
|
|
127
|
+
updateAppMessageShareData: () => {
|
|
128
|
+
console.warn("Bridge:updateAppMessageShareData not init");
|
|
129
|
+
},
|
|
130
|
+
updateTimelineShareData: () => {
|
|
131
|
+
console.warn("Bridge:updateTimelineShareData not init");
|
|
132
|
+
},
|
|
133
|
+
getArea: () => {
|
|
134
|
+
console.warn("Bridge:getArea not init");
|
|
135
|
+
}
|
|
107
136
|
};
|
|
108
|
-
async function
|
|
109
|
-
return new Promise((
|
|
137
|
+
async function P(t) {
|
|
138
|
+
return new Promise((e) => {
|
|
110
139
|
my.postMessage({
|
|
111
|
-
...t
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
});
|
|
140
|
+
...t
|
|
141
|
+
}), e();
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
async function M(t) {
|
|
145
|
+
return new Promise((e) => {
|
|
146
|
+
my.onMessage = t, e();
|
|
119
147
|
});
|
|
120
148
|
}
|
|
121
149
|
async function T(t) {
|
|
122
|
-
return new Promise((
|
|
150
|
+
return new Promise((e, i) => {
|
|
123
151
|
my.getLocation({
|
|
124
152
|
...t,
|
|
125
|
-
success: function(
|
|
126
|
-
|
|
153
|
+
success: function(n) {
|
|
154
|
+
e(n);
|
|
127
155
|
},
|
|
128
|
-
fail: function(
|
|
129
|
-
n
|
|
156
|
+
fail: function(n) {
|
|
157
|
+
i(n);
|
|
130
158
|
}
|
|
131
159
|
});
|
|
132
160
|
});
|
|
133
161
|
}
|
|
134
162
|
async function b(t) {
|
|
135
|
-
return new Promise((
|
|
163
|
+
return new Promise((e, i) => {
|
|
136
164
|
my.openLocation({
|
|
137
165
|
...t,
|
|
138
|
-
success: function(
|
|
139
|
-
|
|
166
|
+
success: function(n) {
|
|
167
|
+
e(n);
|
|
140
168
|
},
|
|
141
|
-
fail: function(
|
|
142
|
-
n
|
|
169
|
+
fail: function(n) {
|
|
170
|
+
i(n);
|
|
143
171
|
}
|
|
144
172
|
});
|
|
145
173
|
});
|
|
146
174
|
}
|
|
147
|
-
async function
|
|
148
|
-
return new Promise((
|
|
175
|
+
async function L(t) {
|
|
176
|
+
return new Promise((e, i) => {
|
|
149
177
|
my.navigateTo({
|
|
150
178
|
...t,
|
|
151
|
-
success: function(
|
|
152
|
-
|
|
179
|
+
success: function(n) {
|
|
180
|
+
e(n);
|
|
153
181
|
},
|
|
154
|
-
fail: function(
|
|
155
|
-
n
|
|
182
|
+
fail: function(n) {
|
|
183
|
+
i(n);
|
|
156
184
|
}
|
|
157
185
|
});
|
|
158
186
|
});
|
|
159
187
|
}
|
|
160
|
-
async function
|
|
161
|
-
return new Promise((
|
|
188
|
+
async function A(t) {
|
|
189
|
+
return new Promise((e, i) => {
|
|
162
190
|
my.navigateBack({
|
|
163
191
|
...t,
|
|
164
|
-
success: function(
|
|
165
|
-
|
|
192
|
+
success: function(n) {
|
|
193
|
+
e(n);
|
|
166
194
|
},
|
|
167
|
-
fail: function(
|
|
168
|
-
n
|
|
195
|
+
fail: function(n) {
|
|
196
|
+
i(n);
|
|
169
197
|
}
|
|
170
198
|
});
|
|
171
199
|
});
|
|
172
200
|
}
|
|
173
|
-
async function
|
|
174
|
-
return new Promise((
|
|
201
|
+
async function C(t) {
|
|
202
|
+
return new Promise((e, i) => {
|
|
175
203
|
my.redirectTo({
|
|
176
204
|
...t,
|
|
177
|
-
success: function(
|
|
178
|
-
|
|
205
|
+
success: function(n) {
|
|
206
|
+
e(n);
|
|
179
207
|
},
|
|
180
|
-
fail: function(
|
|
181
|
-
n
|
|
208
|
+
fail: function(n) {
|
|
209
|
+
i(n);
|
|
182
210
|
}
|
|
183
211
|
});
|
|
184
212
|
});
|
|
185
213
|
}
|
|
186
214
|
function W(t) {
|
|
187
|
-
return new Promise((
|
|
215
|
+
return new Promise((e, i) => {
|
|
188
216
|
my.switchTab({
|
|
189
217
|
...t,
|
|
190
|
-
success: function(
|
|
191
|
-
|
|
218
|
+
success: function(n) {
|
|
219
|
+
e(n);
|
|
192
220
|
},
|
|
193
|
-
fail: function(
|
|
194
|
-
n
|
|
221
|
+
fail: function(n) {
|
|
222
|
+
i(n);
|
|
195
223
|
}
|
|
196
224
|
});
|
|
197
225
|
});
|
|
198
226
|
}
|
|
199
|
-
function
|
|
200
|
-
o.postMessage =
|
|
227
|
+
function J() {
|
|
228
|
+
o.postMessage = P, o.onMessage = M, o.getLocation = T, o.openLocation = b, o.navigateTo = L, o.navigateBack = A, o.redirectTo = C, o.switchTab = W;
|
|
201
229
|
}
|
|
202
230
|
async function x() {
|
|
203
|
-
await
|
|
231
|
+
await f(h), J();
|
|
204
232
|
}
|
|
205
|
-
const
|
|
233
|
+
const S = "https://res.wx.qq.com/open/js/jweixin-1.6.0.js";
|
|
206
234
|
async function E(t = {}) {
|
|
207
|
-
return new Promise((
|
|
235
|
+
return new Promise((e, i) => {
|
|
208
236
|
wx.getLocation({
|
|
209
237
|
...t,
|
|
210
|
-
success: function(
|
|
211
|
-
console.log("success",
|
|
238
|
+
success: function(n) {
|
|
239
|
+
console.log("success", n), e(n);
|
|
212
240
|
},
|
|
213
|
-
fail: function(
|
|
214
|
-
console.log("fail",
|
|
241
|
+
fail: function(n) {
|
|
242
|
+
console.log("fail", n), i(n);
|
|
215
243
|
}
|
|
216
244
|
});
|
|
217
245
|
});
|
|
218
246
|
}
|
|
219
247
|
async function V(t) {
|
|
220
|
-
return new Promise((
|
|
248
|
+
return new Promise((e, i) => {
|
|
221
249
|
wx.openLocation({
|
|
222
250
|
...t,
|
|
223
|
-
success: function(
|
|
224
|
-
|
|
251
|
+
success: function(n) {
|
|
252
|
+
e(n);
|
|
225
253
|
},
|
|
226
|
-
fail: function(
|
|
227
|
-
n
|
|
254
|
+
fail: function(n) {
|
|
255
|
+
i(n);
|
|
228
256
|
}
|
|
229
257
|
});
|
|
230
258
|
});
|
|
231
259
|
}
|
|
232
260
|
async function $(t) {
|
|
233
|
-
return new Promise((
|
|
261
|
+
return new Promise((e, i) => {
|
|
234
262
|
wx.miniProgram.postMessage({
|
|
235
263
|
...t,
|
|
236
|
-
success: function(
|
|
237
|
-
|
|
264
|
+
success: function(n) {
|
|
265
|
+
e(n);
|
|
238
266
|
},
|
|
239
|
-
fail: function(
|
|
240
|
-
n
|
|
267
|
+
fail: function(n) {
|
|
268
|
+
i(n);
|
|
241
269
|
}
|
|
242
270
|
});
|
|
243
271
|
});
|
|
244
272
|
}
|
|
245
|
-
async function
|
|
246
|
-
return new Promise((
|
|
273
|
+
async function I(t) {
|
|
274
|
+
return new Promise((e, i) => {
|
|
247
275
|
wx.miniProgram.navigateTo({
|
|
248
276
|
...t,
|
|
249
|
-
success: function(
|
|
250
|
-
|
|
277
|
+
success: function(n) {
|
|
278
|
+
e(n);
|
|
251
279
|
},
|
|
252
|
-
fail: function(
|
|
253
|
-
n
|
|
280
|
+
fail: function(n) {
|
|
281
|
+
i(n);
|
|
254
282
|
}
|
|
255
283
|
});
|
|
256
284
|
});
|
|
257
285
|
}
|
|
258
|
-
async function
|
|
259
|
-
return new Promise((
|
|
286
|
+
async function j(t) {
|
|
287
|
+
return new Promise((e, i) => {
|
|
260
288
|
wx.miniProgram.navigateBack({
|
|
261
289
|
...t,
|
|
262
|
-
success: function(
|
|
263
|
-
|
|
290
|
+
success: function(n) {
|
|
291
|
+
e(n);
|
|
264
292
|
},
|
|
265
|
-
fail: function(
|
|
266
|
-
n
|
|
293
|
+
fail: function(n) {
|
|
294
|
+
i(n);
|
|
267
295
|
}
|
|
268
296
|
});
|
|
269
297
|
});
|
|
270
298
|
}
|
|
271
|
-
async function
|
|
272
|
-
return new Promise((
|
|
299
|
+
async function R(t) {
|
|
300
|
+
return new Promise((e, i) => {
|
|
273
301
|
wx.miniProgram.switchTab({
|
|
274
302
|
...t,
|
|
275
|
-
success: function(
|
|
276
|
-
|
|
303
|
+
success: function(n) {
|
|
304
|
+
e(n);
|
|
277
305
|
},
|
|
278
|
-
fail: function(
|
|
279
|
-
n
|
|
306
|
+
fail: function(n) {
|
|
307
|
+
i(n);
|
|
280
308
|
}
|
|
281
309
|
});
|
|
282
310
|
});
|
|
283
311
|
}
|
|
284
312
|
async function k(t) {
|
|
285
|
-
return new Promise((
|
|
313
|
+
return new Promise((e, i) => {
|
|
286
314
|
wx.miniProgram.redirectTo({
|
|
287
315
|
...t,
|
|
288
|
-
success: function(
|
|
289
|
-
|
|
316
|
+
success: function(n) {
|
|
317
|
+
e(n);
|
|
290
318
|
},
|
|
291
|
-
fail: function(
|
|
292
|
-
n
|
|
319
|
+
fail: function(n) {
|
|
320
|
+
i(n);
|
|
293
321
|
}
|
|
294
322
|
});
|
|
295
323
|
});
|
|
296
324
|
}
|
|
297
325
|
function l() {
|
|
298
|
-
o.navigateTo =
|
|
326
|
+
o.navigateTo = I, o.navigateBack = j, o.redirectTo = k, o.switchTab = R, o.postMessage = $, o.getLocation = E, o.openLocation = V;
|
|
299
327
|
}
|
|
300
|
-
async function
|
|
301
|
-
const
|
|
302
|
-
return await fetch(`${t.requestUrl}?url=${
|
|
328
|
+
async function D(t) {
|
|
329
|
+
const e = location.href.split("#")[0];
|
|
330
|
+
return await fetch(`${t.requestUrl}?url=${e}`, {
|
|
303
331
|
method: "GET"
|
|
304
|
-
}).then((
|
|
332
|
+
}).then((i) => i.json());
|
|
305
333
|
}
|
|
306
|
-
function
|
|
307
|
-
async function
|
|
308
|
-
const
|
|
309
|
-
|
|
334
|
+
function O(t) {
|
|
335
|
+
async function e() {
|
|
336
|
+
const i = await D(t);
|
|
337
|
+
console.log({
|
|
310
338
|
debug: !1,
|
|
311
|
-
appId:
|
|
312
|
-
timestamp:
|
|
313
|
-
nonceStr:
|
|
314
|
-
signature:
|
|
339
|
+
appId: i.data.appId,
|
|
340
|
+
timestamp: i.data.timestamp,
|
|
341
|
+
nonceStr: i.data.nonceStr,
|
|
342
|
+
signature: i.data.signature,
|
|
315
343
|
jsApiList: [
|
|
316
344
|
// 获取当前的地理位置、速度:
|
|
317
345
|
// 微信小程序与支付宝同名
|
|
@@ -322,23 +350,34 @@ function N(t) {
|
|
|
322
350
|
"startRecord",
|
|
323
351
|
"chooseImage",
|
|
324
352
|
"scanQRCode"
|
|
325
|
-
]
|
|
326
|
-
|
|
353
|
+
]
|
|
354
|
+
}), wx.config({
|
|
355
|
+
debug: !1,
|
|
356
|
+
appId: i.data.appId,
|
|
357
|
+
timestamp: i.data.timestamp,
|
|
358
|
+
nonceStr: i.data.nonceStr,
|
|
359
|
+
signature: i.data.signature,
|
|
360
|
+
jsApiList: [
|
|
361
|
+
// 获取当前的地理位置、速度:
|
|
362
|
+
// 微信小程序与支付宝同名
|
|
363
|
+
"getLocation",
|
|
364
|
+
// 使用微信内置地图查看位置:
|
|
365
|
+
// 微信小程序与支付宝同名
|
|
366
|
+
"openLocation",
|
|
367
|
+
"startRecord",
|
|
368
|
+
"chooseImage",
|
|
369
|
+
"scanQRCode"
|
|
370
|
+
]
|
|
327
371
|
});
|
|
328
372
|
}
|
|
329
|
-
return
|
|
330
|
-
async (n) => {
|
|
331
|
-
console.log("js-sdk 重新初始化", n), i();
|
|
332
|
-
},
|
|
333
|
-
1e3 * 60 * 4
|
|
334
|
-
), Promise.resolve();
|
|
373
|
+
return e(), Promise.resolve();
|
|
335
374
|
}
|
|
336
|
-
async function
|
|
337
|
-
await
|
|
375
|
+
async function N(t) {
|
|
376
|
+
await f(S), t.requestUrl ? (await O(t), wx.ready(function() {
|
|
338
377
|
l();
|
|
339
378
|
})) : l();
|
|
340
379
|
}
|
|
341
|
-
const
|
|
380
|
+
const p = g.isAndroid, _ = (t) => {
|
|
342
381
|
window.WebViewJavascriptBridge ? t(window.WebViewJavascriptBridge) : document.addEventListener(
|
|
343
382
|
"WebViewJavascriptBridgeReady",
|
|
344
383
|
function() {
|
|
@@ -346,63 +385,63 @@ const g = f.isAndroid, D = (t) => {
|
|
|
346
385
|
},
|
|
347
386
|
!1
|
|
348
387
|
);
|
|
349
|
-
},
|
|
388
|
+
}, q = (t) => {
|
|
350
389
|
if (window.WebViewJavascriptBridge)
|
|
351
390
|
return t(window.WebViewJavascriptBridge);
|
|
352
391
|
if (window.WVJBCallbacks)
|
|
353
392
|
return window.WVJBCallbacks.push(t);
|
|
354
393
|
window.WVJBCallbacks = [t];
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
document.documentElement.removeChild(
|
|
394
|
+
const e = document.createElement("iframe");
|
|
395
|
+
e.style.display = "none", e.src = "wvjbscheme://__BRIDGE_LOADED__", document.documentElement.appendChild(e), setTimeout(function() {
|
|
396
|
+
document.documentElement.removeChild(e);
|
|
358
397
|
}, 0);
|
|
359
398
|
};
|
|
360
|
-
window.setupWebViewJavascriptBridge =
|
|
361
|
-
|
|
362
|
-
t.init(function(
|
|
363
|
-
|
|
399
|
+
window.setupWebViewJavascriptBridge = p ? _ : q;
|
|
400
|
+
p && window.setupWebViewJavascriptBridge(function(t) {
|
|
401
|
+
t.init(function(e, i) {
|
|
402
|
+
i("JS 返回给原生的消息内容");
|
|
364
403
|
});
|
|
365
404
|
});
|
|
366
|
-
async function
|
|
405
|
+
async function H() {
|
|
367
406
|
return new Promise((t) => {
|
|
368
|
-
window.setupWebViewJavascriptBridge((
|
|
369
|
-
Object.keys(o).forEach((
|
|
370
|
-
o[
|
|
371
|
-
return new Promise((
|
|
372
|
-
|
|
407
|
+
window.setupWebViewJavascriptBridge((e) => {
|
|
408
|
+
Object.keys(o).forEach((i) => {
|
|
409
|
+
o[i] = function(n) {
|
|
410
|
+
return new Promise((a, d) => {
|
|
411
|
+
e.callHandler(
|
|
373
412
|
"sendToNative",
|
|
374
413
|
// 传递给原生的参数
|
|
375
414
|
{
|
|
376
|
-
type:
|
|
377
|
-
value:
|
|
415
|
+
type: i,
|
|
416
|
+
value: n
|
|
378
417
|
},
|
|
379
418
|
(u) => {
|
|
380
419
|
console.log("fromNativeParams 1", u);
|
|
381
|
-
const
|
|
382
|
-
console.log("fromNativeParams 2",
|
|
420
|
+
const c = typeof u == "string" ? JSON.parse(u) : u;
|
|
421
|
+
console.log("fromNativeParams 2", c), c.type === "success" ? (console.log("fromNativeParams 3", c.value), a(c.value)) : d(c.value);
|
|
383
422
|
}
|
|
384
423
|
);
|
|
385
424
|
});
|
|
386
425
|
};
|
|
387
|
-
}),
|
|
426
|
+
}), e.registerHandler(
|
|
388
427
|
"receiveFromNative",
|
|
389
|
-
(
|
|
390
|
-
console.log(1111,
|
|
391
|
-
const
|
|
392
|
-
console.log(2222,
|
|
393
|
-
console.log(3333,
|
|
394
|
-
}),
|
|
428
|
+
(i, n) => {
|
|
429
|
+
console.log(1111, i);
|
|
430
|
+
const a = typeof i == "string" ? JSON.parse(i) : i;
|
|
431
|
+
console.log(2222, a), B.get(a.type).forEach((d) => {
|
|
432
|
+
console.log(3333, a.value), d(a.value);
|
|
433
|
+
}), n();
|
|
395
434
|
}
|
|
396
435
|
), t();
|
|
397
436
|
});
|
|
398
437
|
});
|
|
399
438
|
}
|
|
400
|
-
async function
|
|
401
|
-
|
|
439
|
+
async function U(t) {
|
|
440
|
+
g.isAlipayMini ? await x() : g.isWeChatMini ? await N(t) : g.isMobile && await H();
|
|
402
441
|
}
|
|
403
442
|
export {
|
|
404
443
|
o as Bridge,
|
|
405
|
-
|
|
406
|
-
|
|
444
|
+
B as BridgeReceive,
|
|
445
|
+
U as initBridge
|
|
407
446
|
};
|
|
408
447
|
//# sourceMappingURL=mo-h5-bridge.js.map
|