@tarojs/plugin-platform-alipay 3.5.0-alpha.13 → 3.5.0-alpha.16

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/runtime.js CHANGED
@@ -1,683 +1,693 @@
1
1
  import { processApis, singleQuote, mergeReconciler, mergeInternalComponents } from '@tarojs/shared';
2
2
 
3
- const needPromiseApis = new Set([
4
- 'addCardAuth',
5
- 'getOpenUserInfo',
6
- 'chooseAlipayContact',
7
- 'chooseCity',
8
- 'chooseContact',
9
- 'choosePhoneContact',
10
- 'datePicker',
11
- 'getAddress',
12
- 'getAuthCode',
13
- 'getPhoneNumber',
14
- 'getRunData',
15
- 'getRunScene',
16
- 'getServerTime',
17
- 'getTitleColor',
18
- 'rsa',
19
- 'paySignCenter',
20
- 'tradePay',
21
- 'isCollected',
22
- 'multiLevelSelect',
23
- 'onLocatedComplete',
24
- 'optionsSelect',
25
- 'prompt',
26
- 'regionPicker',
27
- 'setLocatedCity',
28
- 'showAuthGuide',
29
- 'textRiskIdentification',
30
- 'vibrate',
31
- 'watchShake',
32
- 'connectBLEDevice',
33
- 'disconnectBLEDevice',
34
- 'makeBluetoothPair',
35
- 'writeBLECharacteristicValue',
36
- 'readBLECharacteristicValue',
37
- 'notifyBLECharacteristicValueChange',
38
- 'getBLEDeviceServices',
39
- 'getBLEDeviceCharacteristics',
40
- 'openBluetoothAdapter',
41
- 'closeBluetoothAdapter',
42
- 'getBluetoothAdapterState',
43
- 'startBluetoothDevicesDiscovery',
44
- 'stopBluetoothDevicesDiscovery',
45
- 'getBluetoothDevices',
46
- 'getConnectedBluetoothDevices'
3
+ const needPromiseApis = new Set([
4
+ 'addCardAuth',
5
+ 'getOpenUserInfo',
6
+ 'chooseAlipayContact',
7
+ 'chooseCity',
8
+ 'chooseContact',
9
+ 'choosePhoneContact',
10
+ 'datePicker',
11
+ 'getAddress',
12
+ 'getAuthCode',
13
+ 'getPhoneNumber',
14
+ 'getRunData',
15
+ 'getRunScene',
16
+ 'getServerTime',
17
+ 'getTitleColor',
18
+ 'rsa',
19
+ 'paySignCenter',
20
+ 'tradePay',
21
+ 'isCollected',
22
+ 'multiLevelSelect',
23
+ 'onLocatedComplete',
24
+ 'optionsSelect',
25
+ 'prompt',
26
+ 'regionPicker',
27
+ 'setLocatedCity',
28
+ 'showAuthGuide',
29
+ 'textRiskIdentification',
30
+ 'vibrate',
31
+ 'watchShake',
32
+ 'connectBLEDevice',
33
+ 'disconnectBLEDevice',
34
+ 'makeBluetoothPair',
35
+ 'writeBLECharacteristicValue',
36
+ 'readBLECharacteristicValue',
37
+ 'notifyBLECharacteristicValueChange',
38
+ 'getBLEDeviceServices',
39
+ 'getBLEDeviceCharacteristics',
40
+ 'openBluetoothAdapter',
41
+ 'closeBluetoothAdapter',
42
+ 'getBluetoothAdapterState',
43
+ 'startBluetoothDevicesDiscovery',
44
+ 'stopBluetoothDevicesDiscovery',
45
+ 'getBluetoothDevices',
46
+ 'getConnectedBluetoothDevices'
47
47
  ]);
48
48
 
49
- const apiDiff = {
50
- login: {
51
- alias: 'getAuthCode',
52
- options: {
53
- set: [
54
- {
55
- key: 'scopes',
56
- value: 'auth_base'
57
- }
58
- ]
59
- }
60
- },
61
- showActionSheet: {
62
- options: {
63
- change: [{
64
- old: 'itemList',
65
- new: 'items'
66
- }]
67
- }
68
- },
69
- showToast: {
70
- options: {
71
- change: [{
72
- old: 'title',
73
- new: 'content'
74
- }, {
75
- old: 'icon',
76
- new: 'type'
77
- }]
78
- }
79
- },
80
- showLoading: {
81
- options: {
82
- change: [{
83
- old: 'title',
84
- new: 'content'
85
- }]
86
- }
87
- },
88
- setNavigationBarTitle: {
89
- alias: 'setNavigationBar'
90
- },
91
- setNavigationBarColor: {
92
- alias: 'setNavigationBar'
93
- },
94
- saveImageToPhotosAlbum: {
95
- alias: 'saveImage',
96
- options: {
97
- change: [{
98
- old: 'filePath',
99
- new: 'url'
100
- }]
101
- }
102
- },
103
- previewImage: {
104
- options: {
105
- set: [{
106
- key: 'current',
107
- value(options) {
108
- return options.urls.indexOf(options.current || options.urls[0]);
109
- }
110
- }]
111
- }
112
- },
113
- getFileInfo: {
114
- options: {
115
- change: [{
116
- old: 'filePath',
117
- new: 'apFilePath'
118
- }]
119
- }
120
- },
121
- getSavedFileInfo: {
122
- options: {
123
- change: [{
124
- old: 'filePath',
125
- new: 'apFilePath'
126
- }]
127
- }
128
- },
129
- removeSavedFile: {
130
- options: {
131
- change: [{
132
- old: 'filePath',
133
- new: 'apFilePath'
134
- }]
135
- }
136
- },
137
- saveFile: {
138
- options: {
139
- change: [{
140
- old: 'tempFilePath',
141
- new: 'apFilePath'
142
- }]
143
- }
144
- },
145
- openLocation: {
146
- options: {
147
- set: [{
148
- key: 'latitude',
149
- value(options) {
150
- return String(options.latitude);
151
- }
152
- }, {
153
- key: 'longitude',
154
- value(options) {
155
- return String(options.longitude);
156
- }
157
- }]
158
- }
159
- },
160
- uploadFile: {
161
- options: {
162
- change: [{
163
- old: 'name',
164
- new: 'fileName'
165
- }]
166
- }
167
- },
168
- getClipboardData: {
169
- alias: 'getClipboard'
170
- },
171
- setClipboardData: {
172
- alias: 'setClipboard',
173
- options: {
174
- change: [{
175
- old: 'data',
176
- new: 'text'
177
- }]
178
- }
179
- },
180
- makePhoneCall: {
181
- options: {
182
- change: [{
183
- old: 'phoneNumber',
184
- new: 'number'
185
- }]
186
- }
187
- },
188
- scanCode: {
189
- alias: 'scan',
190
- options: {
191
- change: [{
192
- old: 'onlyFromCamera',
193
- new: 'hideAlbum'
194
- }],
195
- set: [{
196
- key: 'type',
197
- value(options) {
198
- return (options.scanType && options.scanType[0].slice(0, -4)) || 'qr';
199
- }
200
- }]
201
- }
202
- },
203
- setScreenBrightness: {
204
- options: {
205
- change: [{
206
- old: 'value',
207
- new: 'brightness'
208
- }]
209
- }
210
- },
211
- onBLEConnectionStateChange: {
212
- alias: 'onBLEConnectionStateChanged'
213
- },
214
- offBLEConnectionStateChange: {
215
- alias: 'offBLEConnectionStateChanged'
216
- },
217
- createBLEConnection: {
218
- alias: 'connectBLEDevice'
219
- },
220
- closeBLEConnection: {
221
- alias: 'disconnectBLEDevice'
222
- }
223
- };
224
- /**
225
- * 抹平API返回值的差异
226
- * key 为 alipay小程序中的api名称
227
- */
228
- const asyncResultApiDiff = {
229
- getScreenBrightness: {
230
- res: {
231
- set: [
232
- {
233
- key: 'value',
234
- value(res) {
235
- return res.brightness;
236
- }
237
- }
238
- ],
239
- remove: ['brightness']
240
- }
241
- },
242
- scan: {
243
- res: {
244
- set: [
245
- {
246
- key: 'result',
247
- value(res) {
248
- return res.code;
249
- }
250
- }
251
- ]
252
- }
253
- },
254
- getClipboard: {
255
- res: {
256
- set: [
257
- {
258
- key: 'data',
259
- value(res) {
260
- return res.text;
261
- }
262
- }
263
- ]
264
- }
265
- },
266
- chooseImage: {
267
- res: {
268
- set: [
269
- {
270
- key: 'tempFilePaths',
271
- value(res) {
272
- return res.apFilePaths;
273
- }
274
- }
275
- ]
276
- }
277
- },
278
- downloadFile: {
279
- res: {
280
- set: [
281
- {
282
- key: 'tempFilePath',
283
- value(res) {
284
- return res.apFilePath;
285
- }
286
- }
287
- ]
288
- }
289
- },
290
- getAuthCode: {
291
- res: {
292
- set: [{
293
- key: 'code',
294
- value(res) {
295
- return res.authCode;
296
- }
297
- }]
298
- }
299
- },
300
- getExtConfig: {
301
- res: {
302
- set: [{
303
- key: 'extConfig',
304
- value(res) {
305
- return res.data;
306
- }
307
- }]
308
- }
309
- },
310
- saveFile: {
311
- res: {
312
- set: [
313
- {
314
- key: 'savedFilePath',
315
- value(res) {
316
- return res.apFilePath;
317
- }
318
- }
319
- ]
320
- }
321
- }
322
- };
323
- const nativeRequest = my.canIUse('request') ? my.request : my.httpRequest;
324
- function request(options) {
325
- options = options || {};
326
- if (typeof options === 'string') {
327
- options = {
328
- url: options
329
- };
330
- }
331
- const defaultHeaders = {
332
- 'content-type': 'application/json'
333
- };
334
- options.headers = defaultHeaders;
335
- if (options.header) {
336
- for (const k in options.header) {
337
- const lowerK = k.toLocaleLowerCase();
338
- options.headers[lowerK] = options.header[k];
339
- }
340
- delete options.header;
341
- }
342
- const originSuccess = options.success;
343
- const originFail = options.fail;
344
- const originComplete = options.complete;
345
- let requestTask;
346
- const p = new Promise((resolve, reject) => {
347
- options.success = res => {
348
- res.statusCode = res.status;
349
- delete res.status;
350
- res.header = res.headers;
351
- delete res.headers;
352
- originSuccess && originSuccess(res);
353
- resolve(res);
354
- };
355
- options.fail = res => {
356
- originFail && originFail(res);
357
- reject(res);
358
- };
359
- options.complete = res => {
360
- originComplete && originComplete(res);
361
- };
362
- requestTask = nativeRequest(options);
363
- });
364
- p.abort = (cb) => {
365
- cb && cb();
366
- if (requestTask) {
367
- requestTask.abort();
368
- }
369
- return p;
370
- };
371
- return p;
372
- }
373
- function handleSyncApis(key, global, args) {
374
- if (key === 'getStorageSync') {
375
- const arg1 = args[0];
376
- if (arg1 != null) {
377
- const res = global[key]({ key: arg1 });
378
- // 支付宝小程序遗留bug:值可能在data或APDataStorage字段下
379
- let data = null;
380
- if (res.hasOwnProperty('data')) {
381
- data = res.data;
382
- }
383
- else if (res.hasOwnProperty('APDataStorage')) {
384
- data = res.APDataStorage;
385
- }
386
- return data === null ? '' : data;
387
- }
388
- return console.error('getStorageSync 传入参数错误');
389
- }
390
- if (key === 'setStorageSync') {
391
- const arg1 = args[0];
392
- const arg2 = args[1];
393
- if (arg1 != null) {
394
- return global[key]({
395
- key: arg1,
396
- data: arg2
397
- });
398
- }
399
- return console.error('setStorageSync 传入参数错误');
400
- }
401
- if (key === 'removeStorageSync') {
402
- const arg1 = args[0];
403
- if (arg1 != null) {
404
- return global[key]({ key: arg1 });
405
- }
406
- return console.error('removeStorageSync 传入参数错误');
407
- }
408
- if (key === 'createSelectorQuery') {
409
- const query = global[key]();
410
- query.in = function () { return query; };
411
- return query;
412
- }
413
- return global[key].apply(global, args);
414
- }
415
- function transformMeta(api, options) {
416
- let apiAlias = api;
417
- if (api === 'showModal') {
418
- options.cancelButtonText = options.cancelText || '取消';
419
- options.confirmButtonText = options.confirmText || '确定';
420
- apiAlias = 'confirm';
421
- if (options.showCancel === false) {
422
- options.buttonText = options.confirmText || '确定';
423
- apiAlias = 'alert';
424
- }
425
- }
426
- else {
427
- Object.keys(apiDiff).forEach(item => {
428
- const apiItem = apiDiff[item];
429
- if (api === item) {
430
- if (apiItem.alias) {
431
- apiAlias = apiItem.alias;
432
- }
433
- if (apiItem.options) {
434
- const change = apiItem.options.change;
435
- const set = apiItem.options.set;
436
- if (change) {
437
- change.forEach(changeItem => {
438
- options[changeItem.new] = options[changeItem.old];
439
- });
440
- }
441
- if (set) {
442
- set.forEach(setItem => {
443
- options[setItem.key] = typeof setItem.value === 'function' ? setItem.value(options) : setItem.value;
444
- });
445
- }
446
- }
447
- }
448
- });
449
- }
450
- return {
451
- key: apiAlias,
452
- options
453
- };
454
- }
455
- function modifyApis(apis) {
456
- Object.keys(apiDiff).map(key => {
457
- apis.add(key);
458
- const platformKey = apiDiff[key].alias;
459
- platformKey && apis.delete(platformKey);
460
- });
461
- apis.add('showModal');
462
- apis.delete('confirm');
463
- apis.delete('alert');
464
- }
465
- function modifyAsyncResult(key, res) {
466
- if (key === 'connectSocket') {
467
- res.onClose = function (cb) {
468
- my.onSocketClose(cb);
469
- };
470
- res.onError = function (cb) {
471
- my.onSocketError(cb);
472
- };
473
- res.onMessage = function (cb) {
474
- my.onSocketMessage(cb);
475
- };
476
- res.onOpen = function (cb) {
477
- my.onSocketOpen(cb);
478
- };
479
- res.send = function (opt) {
480
- my.sendSocketMessage(opt);
481
- };
482
- res.close = function () {
483
- my.closeSocket();
484
- };
485
- }
486
- Object.keys(asyncResultApiDiff).forEach(apiKey => {
487
- const apiItem = asyncResultApiDiff[apiKey];
488
- if (key !== apiKey) {
489
- return;
490
- }
491
- if (!apiItem.res) {
492
- return;
493
- }
494
- const set = apiItem.res.set;
495
- const remove = apiItem.res.remove;
496
- if (set) {
497
- set.forEach(setItem => {
498
- res[setItem.key] = typeof setItem.value === 'function' ? setItem.value(res) : setItem.value;
499
- });
500
- }
501
- if (remove) {
502
- remove.forEach(removeItem => {
503
- delete res[removeItem];
504
- });
505
- }
506
- });
507
- }
508
- function initNativeApi(taro) {
509
- processApis(taro, my, {
510
- needPromiseApis,
511
- handleSyncApis,
512
- transformMeta,
513
- modifyApis,
514
- modifyAsyncResult,
515
- request
516
- });
49
+ const apiDiff = {
50
+ login: {
51
+ alias: 'getAuthCode',
52
+ options: {
53
+ set: [
54
+ {
55
+ key: 'scopes',
56
+ value: 'auth_base'
57
+ }
58
+ ]
59
+ }
60
+ },
61
+ showActionSheet: {
62
+ options: {
63
+ change: [{
64
+ old: 'itemList',
65
+ new: 'items'
66
+ }]
67
+ }
68
+ },
69
+ showToast: {
70
+ options: {
71
+ change: [{
72
+ old: 'title',
73
+ new: 'content'
74
+ }, {
75
+ old: 'icon',
76
+ new: 'type'
77
+ }]
78
+ }
79
+ },
80
+ showLoading: {
81
+ options: {
82
+ change: [{
83
+ old: 'title',
84
+ new: 'content'
85
+ }]
86
+ }
87
+ },
88
+ setNavigationBarTitle: {
89
+ alias: 'setNavigationBar'
90
+ },
91
+ setNavigationBarColor: {
92
+ alias: 'setNavigationBar'
93
+ },
94
+ saveImageToPhotosAlbum: {
95
+ alias: 'saveImage',
96
+ options: {
97
+ change: [{
98
+ old: 'filePath',
99
+ new: 'url'
100
+ }]
101
+ }
102
+ },
103
+ previewImage: {
104
+ options: {
105
+ set: [{
106
+ key: 'current',
107
+ value(options) {
108
+ return options.urls.indexOf(options.current || options.urls[0]);
109
+ }
110
+ }]
111
+ }
112
+ },
113
+ getFileInfo: {
114
+ options: {
115
+ change: [{
116
+ old: 'filePath',
117
+ new: 'apFilePath'
118
+ }]
119
+ }
120
+ },
121
+ getSavedFileInfo: {
122
+ options: {
123
+ change: [{
124
+ old: 'filePath',
125
+ new: 'apFilePath'
126
+ }]
127
+ }
128
+ },
129
+ removeSavedFile: {
130
+ options: {
131
+ change: [{
132
+ old: 'filePath',
133
+ new: 'apFilePath'
134
+ }]
135
+ }
136
+ },
137
+ saveFile: {
138
+ options: {
139
+ change: [{
140
+ old: 'tempFilePath',
141
+ new: 'apFilePath'
142
+ }]
143
+ }
144
+ },
145
+ openLocation: {
146
+ options: {
147
+ set: [{
148
+ key: 'latitude',
149
+ value(options) {
150
+ return String(options.latitude);
151
+ }
152
+ }, {
153
+ key: 'longitude',
154
+ value(options) {
155
+ return String(options.longitude);
156
+ }
157
+ }]
158
+ }
159
+ },
160
+ uploadFile: {
161
+ options: {
162
+ change: [{
163
+ old: 'name',
164
+ new: 'fileName'
165
+ }]
166
+ }
167
+ },
168
+ getClipboardData: {
169
+ alias: 'getClipboard'
170
+ },
171
+ setClipboardData: {
172
+ alias: 'setClipboard',
173
+ options: {
174
+ change: [{
175
+ old: 'data',
176
+ new: 'text'
177
+ }]
178
+ }
179
+ },
180
+ makePhoneCall: {
181
+ options: {
182
+ change: [{
183
+ old: 'phoneNumber',
184
+ new: 'number'
185
+ }]
186
+ }
187
+ },
188
+ scanCode: {
189
+ alias: 'scan',
190
+ options: {
191
+ change: [{
192
+ old: 'onlyFromCamera',
193
+ new: 'hideAlbum'
194
+ }],
195
+ set: [{
196
+ key: 'type',
197
+ value(options) {
198
+ return (options.scanType && options.scanType[0].slice(0, -4)) || 'qr';
199
+ }
200
+ }]
201
+ }
202
+ },
203
+ setScreenBrightness: {
204
+ options: {
205
+ change: [{
206
+ old: 'value',
207
+ new: 'brightness'
208
+ }]
209
+ }
210
+ },
211
+ onBLEConnectionStateChange: {
212
+ alias: 'onBLEConnectionStateChanged'
213
+ },
214
+ offBLEConnectionStateChange: {
215
+ alias: 'offBLEConnectionStateChanged'
216
+ },
217
+ createBLEConnection: {
218
+ alias: 'connectBLEDevice'
219
+ },
220
+ closeBLEConnection: {
221
+ alias: 'disconnectBLEDevice'
222
+ }
223
+ };
224
+ /**
225
+ * 抹平API返回值的差异
226
+ * key 为 alipay小程序中的api名称
227
+ */
228
+ const asyncResultApiDiff = {
229
+ getScreenBrightness: {
230
+ res: {
231
+ set: [
232
+ {
233
+ key: 'value',
234
+ value(res) {
235
+ return res.brightness;
236
+ }
237
+ }
238
+ ],
239
+ remove: ['brightness']
240
+ }
241
+ },
242
+ scan: {
243
+ res: {
244
+ set: [
245
+ {
246
+ key: 'result',
247
+ value(res) {
248
+ return res.code;
249
+ }
250
+ }
251
+ ]
252
+ }
253
+ },
254
+ getClipboard: {
255
+ res: {
256
+ set: [
257
+ {
258
+ key: 'data',
259
+ value(res) {
260
+ return res.text;
261
+ }
262
+ }
263
+ ]
264
+ }
265
+ },
266
+ chooseImage: {
267
+ res: {
268
+ set: [
269
+ {
270
+ key: 'tempFilePaths',
271
+ value(res) {
272
+ return res.apFilePaths;
273
+ }
274
+ }
275
+ ]
276
+ }
277
+ },
278
+ downloadFile: {
279
+ res: {
280
+ set: [
281
+ {
282
+ key: 'tempFilePath',
283
+ value(res) {
284
+ return res.apFilePath;
285
+ }
286
+ }
287
+ ]
288
+ }
289
+ },
290
+ getAuthCode: {
291
+ res: {
292
+ set: [{
293
+ key: 'code',
294
+ value(res) {
295
+ return res.authCode;
296
+ }
297
+ }]
298
+ }
299
+ },
300
+ getExtConfig: {
301
+ res: {
302
+ set: [{
303
+ key: 'extConfig',
304
+ value(res) {
305
+ return res.data;
306
+ }
307
+ }]
308
+ }
309
+ },
310
+ saveFile: {
311
+ res: {
312
+ set: [
313
+ {
314
+ key: 'savedFilePath',
315
+ value(res) {
316
+ return res.apFilePath;
317
+ }
318
+ }
319
+ ]
320
+ }
321
+ }
322
+ };
323
+ const nativeRequest = my.canIUse('request') ? my.request : my.httpRequest;
324
+ function request(options) {
325
+ options = options || {};
326
+ if (typeof options === 'string') {
327
+ options = {
328
+ url: options
329
+ };
330
+ }
331
+ const defaultHeaders = {
332
+ 'content-type': 'application/json'
333
+ };
334
+ options.headers = defaultHeaders;
335
+ if (options.header) {
336
+ for (const k in options.header) {
337
+ const lowerK = k.toLocaleLowerCase();
338
+ options.headers[lowerK] = options.header[k];
339
+ }
340
+ delete options.header;
341
+ }
342
+ const originSuccess = options.success;
343
+ const originFail = options.fail;
344
+ const originComplete = options.complete;
345
+ let requestTask;
346
+ const p = new Promise((resolve, reject) => {
347
+ options.success = res => {
348
+ res.statusCode = res.status;
349
+ delete res.status;
350
+ res.header = res.headers;
351
+ delete res.headers;
352
+ originSuccess && originSuccess(res);
353
+ resolve(res);
354
+ };
355
+ options.fail = res => {
356
+ originFail && originFail(res);
357
+ reject(res);
358
+ };
359
+ options.complete = res => {
360
+ originComplete && originComplete(res);
361
+ };
362
+ requestTask = nativeRequest(options);
363
+ });
364
+ p.abort = (cb) => {
365
+ cb && cb();
366
+ if (requestTask) {
367
+ requestTask.abort();
368
+ }
369
+ return p;
370
+ };
371
+ return p;
372
+ }
373
+ function handleSyncApis(key, global, args) {
374
+ if (key === 'getStorageSync') {
375
+ const arg1 = args[0];
376
+ if (arg1 != null) {
377
+ const res = global[key]({ key: arg1 });
378
+ // 支付宝小程序遗留bug:值可能在data或APDataStorage字段下
379
+ let data = null;
380
+ if (res.hasOwnProperty('data')) {
381
+ data = res.data;
382
+ }
383
+ else if (res.hasOwnProperty('APDataStorage')) {
384
+ data = res.APDataStorage;
385
+ }
386
+ return data === null ? '' : data;
387
+ }
388
+ return console.error('getStorageSync 传入参数错误');
389
+ }
390
+ if (key === 'setStorageSync') {
391
+ const arg1 = args[0];
392
+ const arg2 = args[1];
393
+ if (arg1 != null) {
394
+ return global[key]({
395
+ key: arg1,
396
+ data: arg2
397
+ });
398
+ }
399
+ return console.error('setStorageSync 传入参数错误');
400
+ }
401
+ if (key === 'removeStorageSync') {
402
+ const arg1 = args[0];
403
+ if (arg1 != null) {
404
+ return global[key]({ key: arg1 });
405
+ }
406
+ return console.error('removeStorageSync 传入参数错误');
407
+ }
408
+ if (key === 'createSelectorQuery') {
409
+ const query = global[key]();
410
+ query.in = function () { return query; };
411
+ return query;
412
+ }
413
+ return global[key].apply(global, args);
414
+ }
415
+ function transformMeta(api, options) {
416
+ let apiAlias = api;
417
+ if (api === 'showModal') {
418
+ options.cancelButtonText = options.cancelText || '取消';
419
+ options.confirmButtonText = options.confirmText || '确定';
420
+ apiAlias = 'confirm';
421
+ if (options.showCancel === false) {
422
+ options.buttonText = options.confirmText || '确定';
423
+ apiAlias = 'alert';
424
+ }
425
+ }
426
+ else {
427
+ Object.keys(apiDiff).forEach(item => {
428
+ const apiItem = apiDiff[item];
429
+ if (api === item) {
430
+ if (apiItem.alias) {
431
+ apiAlias = apiItem.alias;
432
+ }
433
+ if (apiItem.options) {
434
+ const change = apiItem.options.change;
435
+ const set = apiItem.options.set;
436
+ if (change) {
437
+ change.forEach(changeItem => {
438
+ options[changeItem.new] = options[changeItem.old];
439
+ });
440
+ }
441
+ if (set) {
442
+ set.forEach(setItem => {
443
+ options[setItem.key] = typeof setItem.value === 'function' ? setItem.value(options) : setItem.value;
444
+ });
445
+ }
446
+ }
447
+ }
448
+ });
449
+ }
450
+ return {
451
+ key: apiAlias,
452
+ options
453
+ };
454
+ }
455
+ function modifyApis(apis) {
456
+ Object.keys(apiDiff).map(key => {
457
+ apis.add(key);
458
+ const platformKey = apiDiff[key].alias;
459
+ platformKey && apis.delete(platformKey);
460
+ });
461
+ apis.add('showModal');
462
+ apis.delete('confirm');
463
+ apis.delete('alert');
464
+ }
465
+ function modifyAsyncResult(key, res) {
466
+ if (key === 'connectSocket') {
467
+ res.onClose = function (cb) {
468
+ my.onSocketClose(cb);
469
+ };
470
+ res.onError = function (cb) {
471
+ my.onSocketError(cb);
472
+ };
473
+ res.onMessage = function (cb) {
474
+ my.onSocketMessage(cb);
475
+ };
476
+ res.onOpen = function (cb) {
477
+ my.onSocketOpen(cb);
478
+ };
479
+ res.send = function (opt) {
480
+ my.sendSocketMessage(opt);
481
+ };
482
+ res.close = function () {
483
+ my.closeSocket();
484
+ };
485
+ }
486
+ Object.keys(asyncResultApiDiff).forEach(apiKey => {
487
+ const apiItem = asyncResultApiDiff[apiKey];
488
+ if (key !== apiKey) {
489
+ return;
490
+ }
491
+ if (!apiItem.res) {
492
+ return;
493
+ }
494
+ const set = apiItem.res.set;
495
+ const remove = apiItem.res.remove;
496
+ if (set) {
497
+ set.forEach(setItem => {
498
+ res[setItem.key] = typeof setItem.value === 'function' ? setItem.value(res) : setItem.value;
499
+ });
500
+ }
501
+ if (remove) {
502
+ remove.forEach(removeItem => {
503
+ delete res[removeItem];
504
+ });
505
+ }
506
+ });
507
+ }
508
+ function initNativeApi(taro) {
509
+ processApis(taro, my, {
510
+ needPromiseApis,
511
+ handleSyncApis,
512
+ transformMeta,
513
+ modifyApis,
514
+ modifyAsyncResult,
515
+ request
516
+ });
517
517
  }
518
518
 
519
- const components = {
520
- // ======== 调整属性 ========
521
- View: {
522
- 'disable-scroll': 'false',
523
- hidden: 'false',
524
- bindAppear: '',
525
- bindDisappear: '',
526
- bindFirstAppear: ''
527
- },
528
- Text: {
529
- 'number-of-lines': ''
530
- },
531
- Map: {
532
- skew: '0',
533
- rotate: '0',
534
- polygons: '[]',
535
- 'include-padding': '',
536
- 'ground-overlays': '',
537
- 'tile-overlay': '',
538
- 'custom-map-style': '',
539
- setting: '{}',
540
- optimize: '',
541
- bindRegionChange: '',
542
- bindPanelTap: ''
543
- },
544
- Button: {
545
- scope: '',
546
- 'public-id': '',
547
- bindGetAuthorize: '',
548
- bindError: ''
549
- },
550
- Checkbox: {
551
- bindChange: ''
552
- },
553
- Input: {
554
- 'random-number': 'false',
555
- controlled: 'false',
556
- enableNative: 'false'
557
- },
558
- Slider: {
559
- 'track-size': '4',
560
- 'handle-size': '22',
561
- 'handle-color': singleQuote('#ffffff')
562
- },
563
- Switch: {
564
- controlled: 'false'
565
- },
566
- Textarea: {
567
- 'show-count': 'true',
568
- controlled: 'false',
569
- enableNative: 'false'
570
- },
571
- MovableView: {
572
- bindChangeEnd: ''
573
- },
574
- ScrollView: {
575
- 'scroll-animation-duration': '',
576
- 'trap-scroll': 'false'
577
- },
578
- Swiper: {
579
- 'active-class': '',
580
- 'changing-class': '',
581
- acceleration: 'false',
582
- 'disable-programmatic-animation': 'false',
583
- 'disable-touch': 'false',
584
- bindAnimationEnd: ''
585
- },
586
- Image: {
587
- 'default-source': ''
588
- },
589
- Canvas: {
590
- type: '',
591
- width: singleQuote('300px'),
592
- height: singleQuote('225px'),
593
- bindReady: ''
594
- },
595
- Video: {
596
- 'poster-size': singleQuote('contain'),
597
- 'mobilenet-hint-type': '1',
598
- enableNative: 'false',
599
- bindLoading: '',
600
- bindUserAction: '',
601
- bindStop: '',
602
- bindRenderStart: ''
603
- },
604
- // ======== 额外组件 ========
605
- Lottie: {
606
- autoplay: 'false',
607
- path: '',
608
- speed: '1.0',
609
- repeatCount: '0',
610
- autoReverse: 'false',
611
- assetsPath: '',
612
- placeholder: '',
613
- djangoId: '',
614
- md5: '',
615
- optimize: 'false',
616
- bindDataReady: '',
617
- bindDataFailed: '',
618
- bindAnimationStart: '',
619
- bindAnimationEnd: '',
620
- bindAnimationRepeat: '',
621
- bindAnimationCancel: '',
622
- bindDataLoadReady: ''
623
- },
624
- Lifestyle: {
625
- 'public-id': '',
626
- memo: '',
627
- bindFollow: ''
628
- },
629
- LifeFollow: {
630
- sceneId: '',
631
- checkFollow: '',
632
- bindCheckFollow: '',
633
- bindClose: ''
634
- },
635
- ContactButton: {
636
- 'tnt-inst-id': '',
637
- scene: '',
638
- size: '25',
639
- color: singleQuote('#00A3FF'),
640
- icon: '',
641
- 'alipay-card-no': '',
642
- 'ext-info': ''
643
- }
519
+ const components = {
520
+ // ======== 调整属性 ========
521
+ View: {
522
+ 'disable-scroll': 'false',
523
+ hidden: 'false',
524
+ bindAppear: '',
525
+ bindDisappear: '',
526
+ bindFirstAppear: ''
527
+ },
528
+ Text: {
529
+ 'number-of-lines': ''
530
+ },
531
+ Map: {
532
+ skew: '0',
533
+ rotate: '0',
534
+ polygons: '[]',
535
+ 'include-padding': '',
536
+ 'ground-overlays': '',
537
+ 'tile-overlay': '',
538
+ 'custom-map-style': '',
539
+ setting: '{}',
540
+ optimize: '',
541
+ bindRegionChange: '',
542
+ bindPanelTap: ''
543
+ },
544
+ Button: {
545
+ scope: '',
546
+ 'public-id': '',
547
+ bindGetAuthorize: '',
548
+ bindError: ''
549
+ },
550
+ Checkbox: {
551
+ bindChange: ''
552
+ },
553
+ Input: {
554
+ 'random-number': 'false',
555
+ controlled: 'false',
556
+ enableNative: 'false'
557
+ },
558
+ Slider: {
559
+ 'track-size': '4',
560
+ 'handle-size': '22',
561
+ 'handle-color': singleQuote('#ffffff')
562
+ },
563
+ Switch: {
564
+ controlled: 'false'
565
+ },
566
+ Textarea: {
567
+ 'show-count': 'true',
568
+ controlled: 'false',
569
+ enableNative: 'false'
570
+ },
571
+ MovableView: {
572
+ bindChangeEnd: ''
573
+ },
574
+ ScrollView: {
575
+ 'scroll-animation-duration': '',
576
+ 'trap-scroll': 'false'
577
+ },
578
+ Swiper: {
579
+ 'active-class': '',
580
+ 'changing-class': '',
581
+ acceleration: 'false',
582
+ 'disable-programmatic-animation': 'false',
583
+ 'disable-touch': 'false',
584
+ bindAnimationEnd: ''
585
+ },
586
+ Image: {
587
+ 'default-source': ''
588
+ },
589
+ Canvas: {
590
+ type: '',
591
+ width: singleQuote('300px'),
592
+ height: singleQuote('225px'),
593
+ bindReady: ''
594
+ },
595
+ Video: {
596
+ 'poster-size': singleQuote('contain'),
597
+ 'mobilenet-hint-type': '1',
598
+ enableNative: 'false',
599
+ bindLoading: '',
600
+ bindUserAction: '',
601
+ bindStop: '',
602
+ bindRenderStart: ''
603
+ },
604
+ // ======== 额外组件 ========
605
+ Lottie: {
606
+ autoplay: 'false',
607
+ path: '',
608
+ speed: '1.0',
609
+ repeatCount: '0',
610
+ autoReverse: 'false',
611
+ assetsPath: '',
612
+ placeholder: '',
613
+ djangoId: '',
614
+ md5: '',
615
+ optimize: 'false',
616
+ bindDataReady: '',
617
+ bindDataFailed: '',
618
+ bindAnimationStart: '',
619
+ bindAnimationEnd: '',
620
+ bindAnimationRepeat: '',
621
+ bindAnimationCancel: '',
622
+ bindDataLoadReady: ''
623
+ },
624
+ Lifestyle: {
625
+ 'public-id': '',
626
+ memo: '',
627
+ bindFollow: ''
628
+ },
629
+ LifeFollow: {
630
+ sceneId: '',
631
+ checkFollow: '',
632
+ bindCheckFollow: '',
633
+ bindClose: ''
634
+ },
635
+ ContactButton: {
636
+ 'tnt-inst-id': '',
637
+ scene: '',
638
+ size: '25',
639
+ color: singleQuote('#00A3FF'),
640
+ icon: '',
641
+ 'alipay-card-no': '',
642
+ 'ext-info': ''
643
+ },
644
+ ArCamera: {
645
+ devicePosition: singleQuote('back'),
646
+ marker: '',
647
+ mode: singleQuote('imageTracking'),
648
+ useCapturedImage: 'false',
649
+ bindInit: '',
650
+ bindStop: '',
651
+ bindError: '',
652
+ bindARFrame: ''
653
+ }
644
654
  };
645
655
 
646
- const BUBBLE_EVENTS = new Set([
647
- 'touchStart',
648
- 'touchMove',
649
- 'touchEnd',
650
- 'touchCancel',
651
- 'tap',
652
- 'longTap'
653
- ]);
654
- const hostConfig = {
655
- initNativeApi,
656
- getEventCenter(Events) {
657
- if (!my.taroEventCenter) {
658
- my.taroEventCenter = new Events();
659
- }
660
- return my.taroEventCenter;
661
- },
662
- modifyTaroEvent(event, node) {
663
- if (node.tagName === 'SWIPER' && event.type === 'animationend') {
664
- event.type = 'animationfinish';
665
- }
666
- },
667
- isBubbleEvents(eventName) {
668
- return BUBBLE_EVENTS.has(eventName);
669
- }
656
+ const BUBBLE_EVENTS = new Set([
657
+ 'touchStart',
658
+ 'touchMove',
659
+ 'touchEnd',
660
+ 'touchCancel',
661
+ 'tap',
662
+ 'longTap'
663
+ ]);
664
+ const hostConfig = {
665
+ initNativeApi,
666
+ getEventCenter(Events) {
667
+ if (!my.taroEventCenter) {
668
+ my.taroEventCenter = new Events();
669
+ }
670
+ return my.taroEventCenter;
671
+ },
672
+ modifyTaroEvent(event, node) {
673
+ if (node.tagName === 'SWIPER' && event.type === 'animationend') {
674
+ event.type = 'animationfinish';
675
+ }
676
+ },
677
+ isBubbleEvents(eventName) {
678
+ return BUBBLE_EVENTS.has(eventName);
679
+ }
670
680
  };
671
681
 
672
- // 支付宝真机只有 navigator.swuserAgent
673
- const { userAgent } = navigator;
674
- Object.defineProperty(navigator, 'userAgent', {
675
- configurable: true,
676
- enumerable: true,
677
- get() {
678
- return userAgent || navigator.swuserAgent || '';
679
- }
680
- });
681
- mergeReconciler(hostConfig);
682
+ // 支付宝真机只有 navigator.swuserAgent
683
+ const { userAgent } = navigator;
684
+ Object.defineProperty(navigator, 'userAgent', {
685
+ configurable: true,
686
+ enumerable: true,
687
+ get() {
688
+ return userAgent || navigator.swuserAgent || '';
689
+ }
690
+ });
691
+ mergeReconciler(hostConfig);
682
692
  mergeInternalComponents(components);
683
693
  //# sourceMappingURL=runtime.js.map