@tarojs/plugin-platform-alipay 3.5.0-canary.1 → 3.5.0

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,560 +1,682 @@
1
1
  import { processApis, singleQuote } 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
- showActionSheet: {
51
- options: {
52
- change: [{
53
- old: 'itemList',
54
- new: 'items'
55
- }]
56
- }
57
- },
58
- showToast: {
59
- options: {
60
- change: [{
61
- old: 'title',
62
- new: 'content'
63
- }, {
64
- old: 'icon',
65
- new: 'type'
66
- }]
67
- }
68
- },
69
- showLoading: {
70
- options: {
71
- change: [{
72
- old: 'title',
73
- new: 'content'
74
- }]
75
- }
76
- },
77
- setNavigationBarTitle: {
78
- alias: 'setNavigationBar'
79
- },
80
- setNavigationBarColor: {
81
- alias: 'setNavigationBar'
82
- },
83
- saveImageToPhotosAlbum: {
84
- alias: 'saveImage',
85
- options: {
86
- change: [{
87
- old: 'filePath',
88
- new: 'url'
89
- }]
90
- }
91
- },
92
- previewImage: {
93
- options: {
94
- set: [{
95
- key: 'current',
96
- value(options) {
97
- return options.urls.indexOf(options.current || options.urls[0]);
98
- }
99
- }]
100
- }
101
- },
102
- getFileInfo: {
103
- options: {
104
- change: [{
105
- old: 'filePath',
106
- new: 'apFilePath'
107
- }]
108
- }
109
- },
110
- getSavedFileInfo: {
111
- options: {
112
- change: [{
113
- old: 'filePath',
114
- new: 'apFilePath'
115
- }]
116
- }
117
- },
118
- removeSavedFile: {
119
- options: {
120
- change: [{
121
- old: 'filePath',
122
- new: 'apFilePath'
123
- }]
124
- }
125
- },
126
- saveFile: {
127
- options: {
128
- change: [{
129
- old: 'tempFilePath',
130
- new: 'apFilePath'
131
- }]
132
- }
133
- },
134
- openLocation: {
135
- options: {
136
- set: [{
137
- key: 'latitude',
138
- value(options) {
139
- return String(options.latitude);
140
- }
141
- }, {
142
- key: 'longitude',
143
- value(options) {
144
- return String(options.longitude);
145
- }
146
- }]
147
- }
148
- },
149
- uploadFile: {
150
- options: {
151
- change: [{
152
- old: 'name',
153
- new: 'fileName'
154
- }]
155
- }
156
- },
157
- getClipboardData: {
158
- alias: 'getClipboard'
159
- },
160
- setClipboardData: {
161
- alias: 'setClipboard',
162
- options: {
163
- change: [{
164
- old: 'data',
165
- new: 'text'
166
- }]
167
- }
168
- },
169
- makePhoneCall: {
170
- options: {
171
- change: [{
172
- old: 'phoneNumber',
173
- new: 'number'
174
- }]
175
- }
176
- },
177
- scanCode: {
178
- alias: 'scan',
179
- options: {
180
- change: [{
181
- old: 'onlyFromCamera',
182
- new: 'hideAlbum'
183
- }],
184
- set: [{
185
- key: 'type',
186
- value(options) {
187
- return (options.scanType && options.scanType[0].slice(0, -4)) || 'qr';
188
- }
189
- }]
190
- }
191
- },
192
- setScreenBrightness: {
193
- options: {
194
- change: [{
195
- old: 'value',
196
- new: 'brightness'
197
- }]
198
- }
199
- },
200
- onBLEConnectionStateChange: {
201
- alias: 'onBLEConnectionStateChanged'
202
- },
203
- offBLEConnectionStateChange: {
204
- alias: 'offBLEConnectionStateChanged'
205
- },
206
- createBLEConnection: {
207
- alias: 'connectBLEDevice'
208
- },
209
- closeBLEConnection: {
210
- alias: 'disconnectBLEDevice'
211
- }
212
- };
213
- const nativeRequest = my.canIUse('request') ? my.request : my.httpRequest;
214
- function request(options) {
215
- options = options || {};
216
- if (typeof options === 'string') {
217
- options = {
218
- url: options
219
- };
220
- }
221
- const defaultHeaders = {
222
- 'content-type': 'application/json'
223
- };
224
- options.headers = defaultHeaders;
225
- if (options.header) {
226
- for (const k in options.header) {
227
- const lowerK = k.toLocaleLowerCase();
228
- options.headers[lowerK] = options.header[k];
229
- }
230
- delete options.header;
231
- }
232
- const originSuccess = options.success;
233
- const originFail = options.fail;
234
- const originComplete = options.complete;
235
- let requestTask;
236
- const p = new Promise((resolve, reject) => {
237
- options.success = res => {
238
- res.statusCode = res.status;
239
- delete res.status;
240
- res.header = res.headers;
241
- delete res.headers;
242
- originSuccess && originSuccess(res);
243
- resolve(res);
244
- };
245
- options.fail = res => {
246
- originFail && originFail(res);
247
- reject(res);
248
- };
249
- options.complete = res => {
250
- originComplete && originComplete(res);
251
- };
252
- requestTask = nativeRequest(options);
253
- });
254
- p.abort = (cb) => {
255
- cb && cb();
256
- if (requestTask) {
257
- requestTask.abort();
258
- }
259
- return p;
260
- };
261
- return p;
262
- }
263
- function handleSyncApis(key, global, args) {
264
- if (key === 'getStorageSync') {
265
- const arg1 = args[0];
266
- if (arg1 != null) {
267
- const res = global[key]({ key: arg1 });
268
- // 支付宝小程序遗留bug:值可能在data或APDataStorage字段下
269
- let data = null;
270
- if (res.hasOwnProperty('data')) {
271
- data = res.data;
272
- }
273
- else if (res.hasOwnProperty('APDataStorage')) {
274
- data = res.APDataStorage;
275
- }
276
- return data === null ? '' : data;
277
- }
278
- return console.error('getStorageSync 传入参数错误');
279
- }
280
- if (key === 'setStorageSync') {
281
- const arg1 = args[0];
282
- const arg2 = args[1];
283
- if (arg1 != null) {
284
- return global[key]({
285
- key: arg1,
286
- data: arg2
287
- });
288
- }
289
- return console.error('setStorageSync 传入参数错误');
290
- }
291
- if (key === 'removeStorageSync') {
292
- const arg1 = args[0];
293
- if (arg1 != null) {
294
- return global[key]({ key: arg1 });
295
- }
296
- return console.error('removeStorageSync 传入参数错误');
297
- }
298
- if (key === 'createSelectorQuery') {
299
- const query = global[key]();
300
- query.in = function () { return query; };
301
- return query;
302
- }
303
- return global[key].apply(global, args);
304
- }
305
- function transformMeta(api, options) {
306
- let apiAlias = api;
307
- if (api === 'showModal') {
308
- options.cancelButtonText = options.cancelText || '取消';
309
- options.confirmButtonText = options.confirmText || '确定';
310
- apiAlias = 'confirm';
311
- if (options.showCancel === false) {
312
- options.buttonText = options.confirmText || '确定';
313
- apiAlias = 'alert';
314
- }
315
- }
316
- else {
317
- Object.keys(apiDiff).forEach(item => {
318
- const apiItem = apiDiff[item];
319
- if (api === item) {
320
- if (apiItem.alias) {
321
- apiAlias = apiItem.alias;
322
- }
323
- if (apiItem.options) {
324
- const change = apiItem.options.change;
325
- const set = apiItem.options.set;
326
- if (change) {
327
- change.forEach(changeItem => {
328
- options[changeItem.new] = options[changeItem.old];
329
- });
330
- }
331
- if (set) {
332
- set.forEach(setItem => {
333
- options[setItem.key] = typeof setItem.value === 'function' ? setItem.value(options) : setItem.value;
334
- });
335
- }
336
- }
337
- }
338
- });
339
- }
340
- return {
341
- key: apiAlias,
342
- options
343
- };
344
- }
345
- function modifyApis(apis) {
346
- Object.keys(apiDiff).map(key => {
347
- apis.add(key);
348
- const platformKey = apiDiff[key].alias;
349
- platformKey && apis.delete(platformKey);
350
- });
351
- apis.add('showModal');
352
- apis.delete('confirm');
353
- apis.delete('alert');
354
- }
355
- function modifyAsyncResult(key, res) {
356
- if (key === 'saveFile') {
357
- res.savedFilePath = res.apFilePath;
358
- }
359
- else if (key === 'downloadFile') {
360
- res.tempFilePath = res.apFilePath;
361
- }
362
- else if (key === 'chooseImage') {
363
- res.tempFilePaths = res.apFilePaths;
364
- }
365
- else if (key === 'getClipboard') {
366
- res.data = res.text;
367
- }
368
- else if (key === 'scan') {
369
- res.result = res.code;
370
- }
371
- else if (key === 'getScreenBrightness') {
372
- res.value = res.brightness;
373
- delete res.brightness;
374
- }
375
- else if (key === 'connectSocket') {
376
- res.onClose = function (cb) {
377
- my.onSocketClose(cb);
378
- };
379
- res.onError = function (cb) {
380
- my.onSocketError(cb);
381
- };
382
- res.onMessage = function (cb) {
383
- my.onSocketMessage(cb);
384
- };
385
- res.onOpen = function (cb) {
386
- my.onSocketOpen(cb);
387
- };
388
- res.send = function (opt) {
389
- my.sendSocketMessage(opt);
390
- };
391
- res.close = function () {
392
- my.closeSocket();
393
- };
394
- }
395
- }
396
- function initNativeApi(taro) {
397
- processApis(taro, my, {
398
- needPromiseApis,
399
- handleSyncApis,
400
- transformMeta,
401
- modifyApis,
402
- modifyAsyncResult,
403
- request
404
- });
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
+ });
405
517
  }
406
518
 
407
- const components = {
408
- // ======== 调整属性 ========
409
- View: {
410
- 'disable-scroll': 'false',
411
- hidden: 'false',
412
- bindAppear: '',
413
- bindDisappear: '',
414
- bindFirstAppear: ''
415
- },
416
- Text: {
417
- 'number-of-lines': ''
418
- },
419
- Map: {
420
- skew: '0',
421
- rotate: '0',
422
- polygons: '[]',
423
- 'include-padding': '',
424
- 'ground-overlays': '',
425
- 'tile-overlay': '',
426
- 'custom-map-style': '',
427
- setting: '{}',
428
- optimize: '',
429
- bindRegionChange: '',
430
- bindPanelTap: ''
431
- },
432
- Button: {
433
- scope: '',
434
- 'public-id': '',
435
- bindGetAuthorize: '',
436
- bindError: ''
437
- },
438
- Checkbox: {
439
- bindChange: ''
440
- },
441
- Input: {
442
- 'random-number': 'false',
443
- controlled: 'false',
444
- enableNative: 'false'
445
- },
446
- Slider: {
447
- 'track-size': '4',
448
- 'handle-size': '22',
449
- 'handle-color': singleQuote('#ffffff')
450
- },
451
- Switch: {
452
- controlled: 'false'
453
- },
454
- Textarea: {
455
- 'show-count': 'true',
456
- controlled: 'false',
457
- enableNative: 'false'
458
- },
459
- MovableView: {
460
- bindChangeEnd: ''
461
- },
462
- ScrollView: {
463
- 'scroll-animation-duration': '',
464
- 'trap-scroll': 'false'
465
- },
466
- Swiper: {
467
- 'active-class': '',
468
- 'changing-class': '',
469
- acceleration: 'false',
470
- 'disable-programmatic-animation': 'false',
471
- 'disable-touch': 'false',
472
- bindAnimationEnd: ''
473
- },
474
- Image: {
475
- 'default-source': ''
476
- },
477
- Canvas: {
478
- type: '',
479
- width: singleQuote('300px'),
480
- height: singleQuote('225px'),
481
- bindReady: ''
482
- },
483
- Video: {
484
- 'poster-size': singleQuote('contain'),
485
- 'mobilenet-hint-type': '1',
486
- enableNative: 'false',
487
- bindLoading: '',
488
- bindUserAction: '',
489
- bindStop: '',
490
- bindRenderStart: ''
491
- },
492
- // ======== 额外组件 ========
493
- Lottie: {
494
- autoplay: 'false',
495
- path: '',
496
- speed: '1.0',
497
- repeatCount: '0',
498
- autoReverse: 'false',
499
- assetsPath: '',
500
- placeholder: '',
501
- djangoId: '',
502
- md5: '',
503
- optimize: 'false',
504
- bindDataReady: '',
505
- bindDataFailed: '',
506
- bindAnimationStart: '',
507
- bindAnimationEnd: '',
508
- bindAnimationRepeat: '',
509
- bindAnimationCancel: '',
510
- bindDataLoadReady: ''
511
- },
512
- Lifestyle: {
513
- 'public-id': '',
514
- memo: '',
515
- bindFollow: ''
516
- },
517
- LifeFollow: {
518
- sceneId: '',
519
- checkFollow: '',
520
- bindCheckFollow: '',
521
- bindClose: ''
522
- },
523
- ContactButton: {
524
- 'tnt-inst-id': '',
525
- scene: '',
526
- size: '25',
527
- color: singleQuote('#00A3FF'),
528
- icon: '',
529
- 'alipay-card-no': '',
530
- 'ext-info': ''
531
- }
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
+ }
532
654
  };
533
655
 
534
- const BUBBLE_EVENTS = new Set([
535
- 'touchStart',
536
- 'touchMove',
537
- 'touchEnd',
538
- 'touchCancel',
539
- 'tap',
540
- 'longTap'
541
- ]);
542
- const hostConfig = {
543
- initNativeApi,
544
- getEventCenter(Events) {
545
- if (!my.taroEventCenter) {
546
- my.taroEventCenter = new Events();
547
- }
548
- return my.taroEventCenter;
549
- },
550
- modifyTaroEvent(event, node) {
551
- if (node.tagName === 'SWIPER' && event.type === 'animationend') {
552
- event.type = 'animationfinish';
553
- }
554
- },
555
- isBubbleEvents(eventName) {
556
- return BUBBLE_EVENTS.has(eventName);
557
- }
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
+ }
558
680
  };
559
681
 
560
682
  export { components, handleSyncApis, hostConfig, initNativeApi, modifyApis, modifyAsyncResult, needPromiseApis, request, transformMeta };