@mpxjs/api-proxy 2.7.53 → 2.8.0-beta.1
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/LICENSE +433 -0
- package/package.json +3 -2
- package/src/common/js/ToPromise.js +3 -0
- package/src/common/js/utils.js +10 -3
- package/src/index.js +1 -1
- package/src/index.web.js +1 -1
- package/src/mini/platform/wxToAli.js +12 -11
- package/src/mini/platform/wxToQq.js +1 -1
- package/src/mini/platform/wxToTt.js +9 -0
- package/src/mini/transform.js +9 -6
- package/src/web/api/base/base64.js +28 -28
- package/src/web/api/create-selector-query/NodesRef.js +1 -0
- package/src/web/api/create-selector-query/SelectQuery.js +1 -0
- package/src/web/api/device/network/onNetworkStatusChange.js +3 -3
- package/src/web/api/event-channel/index.js +9 -3
- package/src/web/api/modal/Modal.js +3 -1
- package/src/web/api/socket/SocketTask.js +5 -5
- package/src/web/api/storage/index.js +5 -4
- package/src/web/api/system/index.js +1 -1
- package/src/web/api/tab-bar/index.js +3 -3
- package/src/web/api/toast/Toast.js +1 -1
- package/src/web/api/window/index.js +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
|
|
5
|
+
http://www.apache.org/licenses/
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
1. Definitions.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
21
|
+
|
|
22
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
28
|
+
|
|
29
|
+
the copyright owner that is granting the License.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
35
|
+
|
|
36
|
+
other entities that control, are controlled by, or are under common
|
|
37
|
+
|
|
38
|
+
control with that entity. For the purposes of this definition,
|
|
39
|
+
|
|
40
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
41
|
+
|
|
42
|
+
direction or management of such entity, whether by contract or
|
|
43
|
+
|
|
44
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
45
|
+
|
|
46
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
52
|
+
|
|
53
|
+
exercising permissions granted by this License.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
59
|
+
|
|
60
|
+
including but not limited to software source code, documentation
|
|
61
|
+
|
|
62
|
+
source, and configuration files.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
"Object" form shall mean any form resulting from mechanical
|
|
68
|
+
|
|
69
|
+
transformation or translation of a Source form, including but
|
|
70
|
+
|
|
71
|
+
not limited to compiled object code, generated documentation,
|
|
72
|
+
|
|
73
|
+
and conversions to other media types.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
79
|
+
|
|
80
|
+
Object form, made available under the License, as indicated by a
|
|
81
|
+
|
|
82
|
+
copyright notice that is included in or attached to the work
|
|
83
|
+
|
|
84
|
+
(an example is provided in the Appendix below).
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
90
|
+
|
|
91
|
+
form, that is based on (or derived from) the Work and for which the
|
|
92
|
+
|
|
93
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
94
|
+
|
|
95
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
96
|
+
|
|
97
|
+
of this License, Derivative Works shall not include works that remain
|
|
98
|
+
|
|
99
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
100
|
+
|
|
101
|
+
the Work and Derivative Works thereof.
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
"Contribution" shall mean any work of authorship, including
|
|
107
|
+
|
|
108
|
+
the original version of the Work and any modifications or additions
|
|
109
|
+
|
|
110
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
111
|
+
|
|
112
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
113
|
+
|
|
114
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
115
|
+
|
|
116
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
117
|
+
|
|
118
|
+
means any form of electronic, verbal, or written communication sent
|
|
119
|
+
|
|
120
|
+
to the Licensor or its representatives, including but not limited to
|
|
121
|
+
|
|
122
|
+
communication on electronic mailing lists, source code control systems,
|
|
123
|
+
|
|
124
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
125
|
+
|
|
126
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
127
|
+
|
|
128
|
+
excluding communication that is conspicuously marked or otherwise
|
|
129
|
+
|
|
130
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
136
|
+
|
|
137
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
138
|
+
|
|
139
|
+
subsequently incorporated within the Work.
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
145
|
+
|
|
146
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
147
|
+
|
|
148
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
149
|
+
|
|
150
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
151
|
+
|
|
152
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
153
|
+
|
|
154
|
+
Work and such Derivative Works in Source or Object form.
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
160
|
+
|
|
161
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
162
|
+
|
|
163
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
164
|
+
|
|
165
|
+
(except as stated in this section) patent license to make, have made,
|
|
166
|
+
|
|
167
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
168
|
+
|
|
169
|
+
where such license applies only to those patent claims licensable
|
|
170
|
+
|
|
171
|
+
by such Contributor that are necessarily infringed by their
|
|
172
|
+
|
|
173
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
174
|
+
|
|
175
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
176
|
+
|
|
177
|
+
institute patent litigation against any entity (including a
|
|
178
|
+
|
|
179
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
180
|
+
|
|
181
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
182
|
+
|
|
183
|
+
or contributory patent infringement, then any patent licenses
|
|
184
|
+
|
|
185
|
+
granted to You under this License for that Work shall terminate
|
|
186
|
+
|
|
187
|
+
as of the date such litigation is filed.
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
193
|
+
|
|
194
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
195
|
+
|
|
196
|
+
modifications, and in Source or Object form, provided that You
|
|
197
|
+
|
|
198
|
+
meet the following conditions:
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
(a) You must give any other recipients of the Work or
|
|
204
|
+
|
|
205
|
+
Derivative Works a copy of this License; and
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
(b) You must cause any modified files to carry prominent notices
|
|
211
|
+
|
|
212
|
+
stating that You changed the files; and
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
218
|
+
|
|
219
|
+
that You distribute, all copyright, patent, trademark, and
|
|
220
|
+
|
|
221
|
+
attribution notices from the Source form of the Work,
|
|
222
|
+
|
|
223
|
+
excluding those notices that do not pertain to any part of
|
|
224
|
+
|
|
225
|
+
the Derivative Works; and
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
231
|
+
|
|
232
|
+
distribution, then any Derivative Works that You distribute must
|
|
233
|
+
|
|
234
|
+
include a readable copy of the attribution notices contained
|
|
235
|
+
|
|
236
|
+
within such NOTICE file, excluding those notices that do not
|
|
237
|
+
|
|
238
|
+
pertain to any part of the Derivative Works, in at least one
|
|
239
|
+
|
|
240
|
+
of the following places: within a NOTICE text file distributed
|
|
241
|
+
|
|
242
|
+
as part of the Derivative Works; within the Source form or
|
|
243
|
+
|
|
244
|
+
documentation, if provided along with the Derivative Works; or,
|
|
245
|
+
|
|
246
|
+
within a display generated by the Derivative Works, if and
|
|
247
|
+
|
|
248
|
+
wherever such third-party notices normally appear. The contents
|
|
249
|
+
|
|
250
|
+
of the NOTICE file are for informational purposes only and
|
|
251
|
+
|
|
252
|
+
do not modify the License. You may add Your own attribution
|
|
253
|
+
|
|
254
|
+
notices within Derivative Works that You distribute, alongside
|
|
255
|
+
|
|
256
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
257
|
+
|
|
258
|
+
that such additional attribution notices cannot be construed
|
|
259
|
+
|
|
260
|
+
as modifying the License.
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
You may add Your own copyright statement to Your modifications and
|
|
266
|
+
|
|
267
|
+
may provide additional or different license terms and conditions
|
|
268
|
+
|
|
269
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
270
|
+
|
|
271
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
272
|
+
|
|
273
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
274
|
+
|
|
275
|
+
the conditions stated in this License.
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
281
|
+
|
|
282
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
283
|
+
|
|
284
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
285
|
+
|
|
286
|
+
this License, without any additional terms or conditions.
|
|
287
|
+
|
|
288
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
289
|
+
|
|
290
|
+
the terms of any separate license agreement you may have executed
|
|
291
|
+
|
|
292
|
+
with Licensor regarding such Contributions.
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
298
|
+
|
|
299
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
300
|
+
|
|
301
|
+
except as required for reasonable and customary use in describing the
|
|
302
|
+
|
|
303
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
309
|
+
|
|
310
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
311
|
+
|
|
312
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
313
|
+
|
|
314
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
315
|
+
|
|
316
|
+
implied, including, without limitation, any warranties or conditions
|
|
317
|
+
|
|
318
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
319
|
+
|
|
320
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
321
|
+
|
|
322
|
+
appropriateness of using or redistributing the Work and assume any
|
|
323
|
+
|
|
324
|
+
risks associated with Your exercise of permissions under this License.
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
330
|
+
|
|
331
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
332
|
+
|
|
333
|
+
unless required by applicable law (such as deliberate and grossly
|
|
334
|
+
|
|
335
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
336
|
+
|
|
337
|
+
liable to You for damages, including any direct, indirect, special,
|
|
338
|
+
|
|
339
|
+
incidental, or consequential damages of any character arising as a
|
|
340
|
+
|
|
341
|
+
result of this License or out of the use or inability to use the
|
|
342
|
+
|
|
343
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
344
|
+
|
|
345
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
346
|
+
|
|
347
|
+
other commercial damages or losses), even if such Contributor
|
|
348
|
+
|
|
349
|
+
has been advised of the possibility of such damages.
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
355
|
+
|
|
356
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
357
|
+
|
|
358
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
359
|
+
|
|
360
|
+
or other liability obligations and/or rights consistent with this
|
|
361
|
+
|
|
362
|
+
License. However, in accepting such obligations, You may act only
|
|
363
|
+
|
|
364
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
365
|
+
|
|
366
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
367
|
+
|
|
368
|
+
defend, and hold each Contributor harmless for any liability
|
|
369
|
+
|
|
370
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
371
|
+
|
|
372
|
+
of your accepting any such warranty or additional liability.
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
END OF TERMS AND CONDITIONS
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
To apply the Apache License to your work, attach the following
|
|
388
|
+
|
|
389
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
390
|
+
|
|
391
|
+
replaced with your own identifying information. (Don't include
|
|
392
|
+
|
|
393
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
394
|
+
|
|
395
|
+
comment syntax for the file format. We also recommend that a
|
|
396
|
+
|
|
397
|
+
file or class name and description of purpose be included on the
|
|
398
|
+
|
|
399
|
+
same "printed page" as the copyright notice for easier
|
|
400
|
+
|
|
401
|
+
identification within third-party archives.
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
Copyright (C) 2017 Beijing Didi Infinity Technology and Development Co.,Ltd. All rights reserved.
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
412
|
+
|
|
413
|
+
you may not use this file except in compliance with the License.
|
|
414
|
+
|
|
415
|
+
You may obtain a copy of the License at
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
Unless required by applicable law or agreed to in writing, software
|
|
426
|
+
|
|
427
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
428
|
+
|
|
429
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
430
|
+
|
|
431
|
+
See the License for the specific language governing permissions and
|
|
432
|
+
|
|
433
|
+
limitations under the License.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/api-proxy",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0-beta.1",
|
|
4
4
|
"description": "convert miniprogram API at each end",
|
|
5
5
|
"module": "src/index.js",
|
|
6
6
|
"types": "@types/index.d.ts",
|
|
@@ -38,5 +38,6 @@
|
|
|
38
38
|
"homepage": "https://github.com/didi/mpx#readme",
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"axios": "^0.21.1"
|
|
41
|
-
}
|
|
41
|
+
},
|
|
42
|
+
"gitHead": "2d37697869b9bdda3efab92dda8c910b68fd05c0"
|
|
42
43
|
}
|
|
@@ -3,15 +3,18 @@ class ToPromise {
|
|
|
3
3
|
this._resolve = null
|
|
4
4
|
this._reject = null
|
|
5
5
|
}
|
|
6
|
+
|
|
6
7
|
toPromiseInitPromise () {
|
|
7
8
|
return new Promise((resolve, reject) => {
|
|
8
9
|
this._resolve = resolve
|
|
9
10
|
this._reject = reject
|
|
10
11
|
})
|
|
11
12
|
}
|
|
13
|
+
|
|
12
14
|
toPromiseResolve (res) {
|
|
13
15
|
this._resolve(res)
|
|
14
16
|
}
|
|
17
|
+
|
|
15
18
|
toPromiseReject (err) {
|
|
16
19
|
this._reject(err)
|
|
17
20
|
}
|
package/src/common/js/utils.js
CHANGED
|
@@ -12,12 +12,17 @@
|
|
|
12
12
|
* d: 4 // 增加 d
|
|
13
13
|
* })
|
|
14
14
|
*/
|
|
15
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty
|
|
16
|
+
|
|
17
|
+
function hasOwn (obj, key) {
|
|
18
|
+
return hasOwnProperty.call(obj, key)
|
|
19
|
+
}
|
|
15
20
|
|
|
16
21
|
function changeOpts (options, updateOrRemoveOpt = {}, extraOpt = {}) {
|
|
17
22
|
let opts = {}
|
|
18
23
|
|
|
19
24
|
Object.keys(options).forEach(key => {
|
|
20
|
-
|
|
25
|
+
const myKey = hasOwn(updateOrRemoveOpt, key) ? updateOrRemoveOpt[key] : key
|
|
21
26
|
if (myKey !== '') {
|
|
22
27
|
opts[myKey] = options[key]
|
|
23
28
|
}
|
|
@@ -31,6 +36,7 @@ function changeOpts (options, updateOrRemoveOpt = {}, extraOpt = {}) {
|
|
|
31
36
|
/**
|
|
32
37
|
* @param {Object} opts 原参数
|
|
33
38
|
* @param {Function} getOptions 获取 success 回调修改后的参数
|
|
39
|
+
* @param {Object} thisObj this对象
|
|
34
40
|
*/
|
|
35
41
|
const handleSuccess = (opts, getOptions = noop, thisObj) => {
|
|
36
42
|
if (!opts.success) {
|
|
@@ -92,7 +98,7 @@ function makeMap (arr) {
|
|
|
92
98
|
}, {})
|
|
93
99
|
}
|
|
94
100
|
|
|
95
|
-
const
|
|
101
|
+
const isBrowser = typeof window !== 'undefined'
|
|
96
102
|
|
|
97
103
|
export {
|
|
98
104
|
changeOpts,
|
|
@@ -103,5 +109,6 @@ export {
|
|
|
103
109
|
warn,
|
|
104
110
|
noop,
|
|
105
111
|
makeMap,
|
|
106
|
-
|
|
112
|
+
isBrowser,
|
|
113
|
+
hasOwn
|
|
107
114
|
}
|
package/src/index.js
CHANGED
package/src/index.web.js
CHANGED
|
@@ -38,7 +38,7 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
38
38
|
if (systemInfo) return systemInfo
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
const res = ALI_OBJ.getSystemInfoSync() || {}
|
|
42
42
|
|
|
43
43
|
res.system = `${res.platform} ${res.system}`
|
|
44
44
|
res.SDKVersion = ALI_OBJ.SDKVersion
|
|
@@ -54,7 +54,7 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
54
54
|
},
|
|
55
55
|
|
|
56
56
|
nextTick (fn) {
|
|
57
|
-
|
|
57
|
+
Promise.resolve().then(fn)
|
|
58
58
|
},
|
|
59
59
|
|
|
60
60
|
/**
|
|
@@ -86,7 +86,7 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
86
86
|
})
|
|
87
87
|
|
|
88
88
|
handleSuccess(opts, res => {
|
|
89
|
-
return changeOpts(res, undefined, {
|
|
89
|
+
return changeOpts(res, undefined, { cancel: !res.confirm })
|
|
90
90
|
})
|
|
91
91
|
|
|
92
92
|
ALI_OBJ.confirm(opts)
|
|
@@ -122,7 +122,7 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
122
122
|
const cacheFail = opts.fail || noop
|
|
123
123
|
|
|
124
124
|
opts.success = function (res) {
|
|
125
|
-
|
|
125
|
+
const sucRes = changeOpts(res, {
|
|
126
126
|
index: 'tapIndex'
|
|
127
127
|
})
|
|
128
128
|
if (sucRes.tapIndex === -1) {
|
|
@@ -235,7 +235,7 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
235
235
|
const opts = changeOpts(options)
|
|
236
236
|
|
|
237
237
|
if (opts.current) {
|
|
238
|
-
|
|
238
|
+
const idx = options.urls.indexOf(opts.current)
|
|
239
239
|
opts.current = idx !== -1 ? idx : 0
|
|
240
240
|
}
|
|
241
241
|
|
|
@@ -328,7 +328,7 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
328
328
|
handleSuccess(opts, res => {
|
|
329
329
|
if (res.fileList) {
|
|
330
330
|
res.fileList.forEach(file => {
|
|
331
|
-
|
|
331
|
+
const resFile = changeOpts(file, {
|
|
332
332
|
apFilePath: 'filePath'
|
|
333
333
|
})
|
|
334
334
|
file = resFile
|
|
@@ -490,10 +490,10 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
490
490
|
warn(`支付宝不支持在 ${TIPS_NAME}.getUserInfo 中使用 lang 参数`)
|
|
491
491
|
}
|
|
492
492
|
|
|
493
|
-
|
|
493
|
+
const opts = changeOpts(options)
|
|
494
494
|
|
|
495
495
|
handleSuccess(opts, res => {
|
|
496
|
-
|
|
496
|
+
const userInfo = changeOpts(res, { avatar: 'avatarUrl' }, { gender: 0 })
|
|
497
497
|
const params = ['country', 'province', 'city', 'language']
|
|
498
498
|
|
|
499
499
|
params.forEach(key => {
|
|
@@ -518,7 +518,7 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
518
518
|
error(`请在支付函数 ${TIPS_NAME}.requestPayment 中添加 tradeNO 参数用于支付宝支付`)
|
|
519
519
|
}
|
|
520
520
|
|
|
521
|
-
|
|
521
|
+
const opts = changeOpts(options, {
|
|
522
522
|
timeStamp: '',
|
|
523
523
|
nonceStr: '',
|
|
524
524
|
package: '',
|
|
@@ -556,7 +556,7 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
556
556
|
*/
|
|
557
557
|
|
|
558
558
|
createCanvasContext (canvasId = {}) {
|
|
559
|
-
|
|
559
|
+
const ctx = ALI_OBJ.createCanvasContext(canvasId)
|
|
560
560
|
|
|
561
561
|
CANVAS_MAP[canvasId] = ctx
|
|
562
562
|
|
|
@@ -620,6 +620,7 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
620
620
|
* WXML
|
|
621
621
|
*/
|
|
622
622
|
|
|
623
|
+
// todo 支付宝基础库升级至2.7.4以上可去除
|
|
623
624
|
createSelectorQuery (options = {}) {
|
|
624
625
|
const selectorQuery = ALI_OBJ.createSelectorQuery(options)
|
|
625
626
|
const proxyMethods = ['boundingClientRect', 'scrollOffset']
|
|
@@ -636,7 +637,7 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
636
637
|
selectorQuery.exec = function (originalCb = noop) {
|
|
637
638
|
const cb = function (results) {
|
|
638
639
|
results.forEach((item, index) => {
|
|
639
|
-
cbs[index]
|
|
640
|
+
cbs[index](item)
|
|
640
641
|
})
|
|
641
642
|
originalCb(results)
|
|
642
643
|
}
|
package/src/mini/transform.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { error, getEnvObj, genFromMap, makeMap } from '../common/js'
|
|
2
2
|
import getWxToAliApi from './platform/wxToAli'
|
|
3
3
|
import getWxToQqApi from './platform/wxToQq'
|
|
4
|
+
import getWxToTtApi from './platform/wxToTt'
|
|
4
5
|
|
|
5
6
|
const fromMap = genFromMap()
|
|
6
7
|
|
|
@@ -14,17 +15,19 @@ function transformApi (options) {
|
|
|
14
15
|
const to = options.to
|
|
15
16
|
const fromTo = joinName(from, to)
|
|
16
17
|
const wxToAliApi = getWxToAliApi({ optimize: options.optimize })
|
|
17
|
-
const wxToQqApi = getWxToQqApi(
|
|
18
|
+
const wxToQqApi = getWxToQqApi()
|
|
19
|
+
const wxToTtApi = getWxToTtApi()
|
|
18
20
|
const platformMap = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
wx_ali: wxToAliApi,
|
|
22
|
+
wx_qq: wxToQqApi,
|
|
23
|
+
wx_tt: wxToTtApi
|
|
21
24
|
}
|
|
22
25
|
const needProxy = Object.create(null)
|
|
23
26
|
const excludeMap = makeMap(options.exclude)
|
|
24
|
-
const
|
|
25
|
-
Object.keys(envObj).concat(Object.keys(
|
|
27
|
+
const platformApi = platformMap[fromTo] || {}
|
|
28
|
+
Object.keys(envObj).concat(Object.keys(platformApi)).forEach((key) => {
|
|
26
29
|
if (!excludeMap[key]) {
|
|
27
|
-
needProxy[key] = envObj[key] ||
|
|
30
|
+
needProxy[key] = envObj[key] || platformApi[key]
|
|
28
31
|
}
|
|
29
32
|
})
|
|
30
33
|
const result = Object.create(null)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// fork base64-js@1.3.1
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
const lookup = []
|
|
3
|
+
const revLookup = []
|
|
4
|
+
const Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
for (
|
|
6
|
+
const code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
|
7
|
+
for (let i = 0, len = code.length; i < len; ++i) {
|
|
8
8
|
lookup[i] = code[i]
|
|
9
9
|
revLookup[code.charCodeAt(i)] = i
|
|
10
10
|
}
|
|
@@ -15,7 +15,7 @@ revLookup['-'.charCodeAt(0)] = 62
|
|
|
15
15
|
revLookup['_'.charCodeAt(0)] = 63
|
|
16
16
|
|
|
17
17
|
function getLens (b64) {
|
|
18
|
-
|
|
18
|
+
const len = b64.length
|
|
19
19
|
|
|
20
20
|
if (len % 4 > 0) {
|
|
21
21
|
throw new Error('Invalid string. Length must be a multiple of 4')
|
|
@@ -23,10 +23,10 @@ function getLens (b64) {
|
|
|
23
23
|
|
|
24
24
|
// Trim off extra bytes after placeholder bytes are found
|
|
25
25
|
// See: https://github.com/beatgammit/base64-js/issues/42
|
|
26
|
-
|
|
26
|
+
let validLen = b64.indexOf('=')
|
|
27
27
|
if (validLen === -1) validLen = len
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
const placeHoldersLen = validLen === len
|
|
30
30
|
? 0
|
|
31
31
|
: 4 - (validLen % 4)
|
|
32
32
|
|
|
@@ -35,9 +35,9 @@ function getLens (b64) {
|
|
|
35
35
|
|
|
36
36
|
// base64 is 4/3 + up to two characters of the original data
|
|
37
37
|
function byteLength (b64) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const lens = getLens(b64)
|
|
39
|
+
const validLen = lens[0]
|
|
40
|
+
const placeHoldersLen = lens[1]
|
|
41
41
|
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -46,21 +46,21 @@ function _byteLength (b64, validLen, placeHoldersLen) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function toByteArray (b64) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
let tmp
|
|
50
|
+
const lens = getLens(b64)
|
|
51
|
+
const validLen = lens[0]
|
|
52
|
+
const placeHoldersLen = lens[1]
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
const arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
let curByte = 0
|
|
57
57
|
|
|
58
58
|
// if there are placeholders, only get up to the last complete 4 chars
|
|
59
|
-
|
|
59
|
+
const len = placeHoldersLen > 0
|
|
60
60
|
? validLen - 4
|
|
61
61
|
: validLen
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
let i
|
|
64
64
|
for (i = 0; i < len; i += 4) {
|
|
65
65
|
tmp =
|
|
66
66
|
(revLookup[b64.charCodeAt(i)] << 18) |
|
|
@@ -99,9 +99,9 @@ function tripletToBase64 (num) {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
function encodeChunk (uint8, start, end) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
for (
|
|
102
|
+
let tmp
|
|
103
|
+
const output = []
|
|
104
|
+
for (let i = start; i < end; i += 3) {
|
|
105
105
|
tmp =
|
|
106
106
|
((uint8[i] << 16) & 0xFF0000) +
|
|
107
107
|
((uint8[i + 1] << 8) & 0xFF00) +
|
|
@@ -112,14 +112,14 @@ function encodeChunk (uint8, start, end) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
function fromByteArray (uint8) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
let tmp
|
|
116
|
+
const len = uint8.length
|
|
117
|
+
const extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
|
|
118
|
+
const parts = []
|
|
119
|
+
const maxChunkLength = 16383 // must be multiple of 3
|
|
120
120
|
|
|
121
121
|
// go through the array every three bytes, we'll deal with trailing stuff later
|
|
122
|
-
for (
|
|
122
|
+
for (let i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
|
|
123
123
|
parts.push(encodeChunk(
|
|
124
124
|
uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
|
|
125
125
|
))
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isBrowser } from '../../../../common/js/utils'
|
|
2
2
|
const fnMap = new Map()
|
|
3
3
|
|
|
4
4
|
const oldObserveList = new Set()
|
|
5
5
|
|
|
6
|
-
if (
|
|
6
|
+
if (isBrowser) {
|
|
7
7
|
window.addEventListener('offline', () => {
|
|
8
8
|
oldObserveList.forEach(fn => fn({ isConnected: false, type: 'none' }))
|
|
9
9
|
})
|
|
@@ -14,7 +14,7 @@ if (inBrowser) {
|
|
|
14
14
|
|
|
15
15
|
export function onNetworkStatusChange (callbackFn) {
|
|
16
16
|
if (navigator.connection) {
|
|
17
|
-
|
|
17
|
+
const proxyCallback = evt => {
|
|
18
18
|
const isConnected = navigator.onLine
|
|
19
19
|
callbackFn({
|
|
20
20
|
isConnected,
|
|
@@ -2,10 +2,11 @@ class EventChannel {
|
|
|
2
2
|
constructor () {
|
|
3
3
|
this.listener = {}
|
|
4
4
|
}
|
|
5
|
+
|
|
5
6
|
emit (eventName, ...args) {
|
|
6
7
|
const cbs = this.listener[eventName]
|
|
7
8
|
if (cbs) {
|
|
8
|
-
cbs.
|
|
9
|
+
cbs.forEach((item, index) => {
|
|
9
10
|
try {
|
|
10
11
|
item.fn.apply(this, args)
|
|
11
12
|
} catch (e) {
|
|
@@ -17,12 +18,13 @@ class EventChannel {
|
|
|
17
18
|
})
|
|
18
19
|
}
|
|
19
20
|
}
|
|
21
|
+
|
|
20
22
|
off (eventName, EventCallback) {
|
|
21
23
|
if (EventCallback) {
|
|
22
24
|
const cbs = this.listener[eventName]
|
|
23
25
|
const copyCbs = []
|
|
24
26
|
if (cbs) {
|
|
25
|
-
cbs.
|
|
27
|
+
cbs.forEach((item) => {
|
|
26
28
|
if (item.fn !== EventCallback) {
|
|
27
29
|
copyCbs.push(item)
|
|
28
30
|
}
|
|
@@ -33,18 +35,22 @@ class EventChannel {
|
|
|
33
35
|
this.listener[eventName] && (this.listener[eventName].length = 0)
|
|
34
36
|
}
|
|
35
37
|
}
|
|
38
|
+
|
|
36
39
|
on (eventName, EventCallback) {
|
|
37
40
|
(this.listener[eventName] || (this.listener[eventName] = [])).push({ fn: EventCallback, type: 'on' })
|
|
38
41
|
}
|
|
42
|
+
|
|
39
43
|
once (eventName, EventCallback) {
|
|
40
44
|
(this.listener[eventName] || (this.listener[eventName] = [])).push({ fn: EventCallback, type: 'once' })
|
|
41
45
|
}
|
|
46
|
+
|
|
42
47
|
_addListener (eventName, EventCallback, type) {
|
|
43
48
|
(this.listener[eventName] || (this.listener[eventName] = [])).push({ fn: EventCallback, type })
|
|
44
49
|
}
|
|
50
|
+
|
|
45
51
|
_addListeners (events) {
|
|
46
52
|
if (Object.prototype.toString.call(events) === '[object Object]') {
|
|
47
|
-
Object.keys(events).
|
|
53
|
+
Object.keys(events).forEach((eventName) => {
|
|
48
54
|
(this.listener[eventName] || (this.listener[eventName] = [])).push({ fn: events[eventName], type: 'on' })
|
|
49
55
|
})
|
|
50
56
|
}
|
|
@@ -2,7 +2,7 @@ import { ToPromise, webHandleSuccess } from '../../../common/js'
|
|
|
2
2
|
import '../../../common/stylus/Modal.styl'
|
|
3
3
|
// import { forEach } from '@didi/mpx-fetch/src/util'
|
|
4
4
|
// 汉字为两个字符,字母/数字为一个字符
|
|
5
|
-
|
|
5
|
+
const _getLength = (t) => {
|
|
6
6
|
let len = 0
|
|
7
7
|
for (let i = 0; i < t.length; i++) {
|
|
8
8
|
if (t.charCodeAt(i) > 127 || t.charCodeAt(i) === 94) {
|
|
@@ -72,6 +72,7 @@ export default class Modal extends ToPromise {
|
|
|
72
72
|
this.cancelBtn = cancelBtn
|
|
73
73
|
this.confirmBtn = confirmBtn
|
|
74
74
|
}
|
|
75
|
+
|
|
75
76
|
show (options = {}) {
|
|
76
77
|
if (options.confirmText && _getLength(options.confirmText) > 8) {
|
|
77
78
|
// eslint-disable-next-line
|
|
@@ -126,6 +127,7 @@ export default class Modal extends ToPromise {
|
|
|
126
127
|
|
|
127
128
|
return this.toPromiseInitPromise()
|
|
128
129
|
}
|
|
130
|
+
|
|
129
131
|
hide () {
|
|
130
132
|
if (this.hideTimer) {
|
|
131
133
|
clearTimeout(this.hideTimer)
|
|
@@ -20,23 +20,23 @@ class SocketTask {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
get CONNECTING () {
|
|
23
|
-
return this._socket
|
|
23
|
+
return this._socket.CONNECTING || 0
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
get OPEN () {
|
|
27
|
-
return this._socket
|
|
27
|
+
return this._socket.OPEN || 1
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
get CLOSING () {
|
|
31
|
-
return this._socket
|
|
31
|
+
return this._socket.CLOSING || 2
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
get CLOSED () {
|
|
35
|
-
return this._socket
|
|
35
|
+
return this._socket.CLOSED || 3
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
get readyState () {
|
|
39
|
-
return this._socket
|
|
39
|
+
return this._socket.readyState
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
send (options) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { webHandleSuccess, webHandleFail } from '../../../common/js'
|
|
1
|
+
import { webHandleSuccess, webHandleFail, hasOwn } from '../../../common/js'
|
|
2
2
|
|
|
3
3
|
function setStorage (options = {}) {
|
|
4
4
|
const { key, data, success, fail, complete } = options
|
|
@@ -43,7 +43,7 @@ function getStorage (options = {}) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
function getStorageSync (key) {
|
|
46
|
-
|
|
46
|
+
const res = getItem(key)
|
|
47
47
|
if (res.result) return res.data
|
|
48
48
|
|
|
49
49
|
return ''
|
|
@@ -53,9 +53,10 @@ function getItem (key) {
|
|
|
53
53
|
let item
|
|
54
54
|
try {
|
|
55
55
|
item = JSON.parse(window.localStorage.getItem(key))
|
|
56
|
-
} catch (e) {
|
|
56
|
+
} catch (e) {
|
|
57
|
+
}
|
|
57
58
|
|
|
58
|
-
if (item && typeof item === 'object' && item
|
|
59
|
+
if (item && typeof item === 'object' && hasOwn(item, 'data')) {
|
|
59
60
|
return { result: true, data: item.data }
|
|
60
61
|
} else {
|
|
61
62
|
return { result: false }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { webHandleSuccess, webHandleFail } from '../../../common/js'
|
|
1
|
+
import { webHandleSuccess, webHandleFail, hasOwn } from '../../../common/js'
|
|
2
2
|
import Vue from 'vue'
|
|
3
3
|
|
|
4
4
|
function setTabBarStyle (options = {}) {
|
|
@@ -9,7 +9,7 @@ function setTabBarStyle (options = {}) {
|
|
|
9
9
|
rejected = { errMsg: 'setTabBarStyle:fail custom Tabbar' }
|
|
10
10
|
} else {
|
|
11
11
|
'color|selectedColor|backgroundColor|borderStyle'.split('|').forEach((key) => {
|
|
12
|
-
if (options
|
|
12
|
+
if (hasOwn(options, key)) {
|
|
13
13
|
Vue.set(tabBar, key, options[key])
|
|
14
14
|
}
|
|
15
15
|
})
|
|
@@ -37,7 +37,7 @@ function setTabBarItem (options = {}) {
|
|
|
37
37
|
const item = tabBar.list[options.index]
|
|
38
38
|
if (item) {
|
|
39
39
|
'text|iconPath|selectedIconPath'.split('|').forEach((key) => {
|
|
40
|
-
if (options
|
|
40
|
+
if (hasOwn(options, key)) {
|
|
41
41
|
Vue.set(item, key, options[key])
|
|
42
42
|
}
|
|
43
43
|
})
|
|
@@ -3,7 +3,7 @@ import '../../../common/stylus/Toast.styl'
|
|
|
3
3
|
import '../../../common/stylus/Loading.styl'
|
|
4
4
|
|
|
5
5
|
function createDom (tag, attrs = {}, children = []) {
|
|
6
|
-
|
|
6
|
+
const dom = document.createElement(tag)
|
|
7
7
|
Object.keys(attrs).forEach(k => dom.setAttribute(k, attrs[k]))
|
|
8
8
|
children.length && children.forEach(child => dom.appendChild(child))
|
|
9
9
|
return dom
|