@dcloudio/uni-mp-alipay 2.0.0 → 2.0.1-32920211122002

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,75 +1,197 @@
1
- import { isArray, isPromise, isFunction, isPlainObject, hasOwn, isString } from '@vue/shared';
1
+ import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isPromise, isFunction, extend } from '@vue/shared';
2
+ import { injectHook } from 'vue';
2
3
 
3
- const API_TYPE_SYNC = 1;
4
- function validateProtocol(_name, _args, _protocol) {
5
- return true;
4
+ //App
5
+ const ON_LAUNCH = 'onLaunch';
6
+
7
+ const eventChannels = {};
8
+ const eventChannelStack = [];
9
+ let id = 0;
10
+ function initEventChannel(events, cache = true) {
11
+ id++;
12
+ const eventChannel = new my.EventChannel(id, events);
13
+ if (cache) {
14
+ eventChannels[id] = eventChannel;
15
+ eventChannelStack.push(eventChannel);
16
+ }
17
+ return eventChannel;
6
18
  }
7
- function formatApiArgs(args, options) {
8
- if (!options) {
9
- return args;
19
+ function getEventChannel(id) {
20
+ if (id) {
21
+ const eventChannel = eventChannels[id];
22
+ delete eventChannels[id];
23
+ return eventChannel;
10
24
  }
25
+ return eventChannelStack.shift();
11
26
  }
12
- function createApi({ type, name, options }, fn, protocol) {
13
- return function (...args) {
14
- if (type === API_TYPE_SYNC) {
15
- if (!((process.env.NODE_ENV !== 'production') && protocol && !validateProtocol())) {
16
- return fn.apply(null, formatApiArgs(args, options));
17
- }
27
+ const navigateTo = {
28
+ args(fromArgs) {
29
+ const id = initEventChannel(fromArgs.events).id;
30
+ if (fromArgs.url) {
31
+ fromArgs.url =
32
+ fromArgs.url +
33
+ (fromArgs.url.indexOf('?') === -1 ? '?' : '&') +
34
+ '__id__=' +
35
+ id;
18
36
  }
19
- };
20
- }
37
+ },
38
+ returnValue(fromRes) {
39
+ fromRes.eventChannel = getEventChannel();
40
+ },
41
+ };
21
42
 
22
- const Upx2pxProtocol = [
23
- {
24
- name: 'upx',
25
- type: [Number, String],
26
- required: true
43
+ my.appLaunchHooks = [];
44
+ function onAppLaunch(hook) {
45
+ const app = getApp({ allowDefault: true });
46
+ if (app && app.$vm) {
47
+ return injectHook(ON_LAUNCH, hook, app.$vm.$);
27
48
  }
28
- ];
49
+ my.appLaunchHooks.push(hook);
50
+ }
29
51
 
30
- const EPS = 1e-4;
31
- const BASE_DEVICE_WIDTH = 750;
32
- let isIOS = false;
33
- let deviceWidth = 0;
34
- let deviceDPR = 0;
35
- function checkDeviceWidth() {
36
- const { platform, pixelRatio, windowWidth } = my.getSystemInfoSync();
37
- deviceWidth = windowWidth;
38
- deviceDPR = pixelRatio;
39
- isIOS = platform === 'ios';
52
+ function getBaseSystemInfo() {
53
+ return my.getSystemInfoSync()
54
+ }
55
+
56
+ function validateProtocolFail(name, msg) {
57
+ console.warn(`${name}: ${msg}`);
40
58
  }
41
- const upx2px = createApi({ type: API_TYPE_SYNC, name: 'upx2px' }, (number, newDeviceWidth) => {
42
- if (deviceWidth === 0) {
43
- checkDeviceWidth();
59
+ function validateProtocol(name, data, protocol, onFail) {
60
+ if (!onFail) {
61
+ onFail = validateProtocolFail;
62
+ }
63
+ for (const key in protocol) {
64
+ const errMsg = validateProp(key, data[key], protocol[key], !hasOwn(data, key));
65
+ if (isString(errMsg)) {
66
+ onFail(name, errMsg);
67
+ }
44
68
  }
45
- number = Number(number);
46
- if (number === 0) {
47
- return 0;
69
+ }
70
+ function validateProtocols(name, args, protocol, onFail) {
71
+ if (!protocol) {
72
+ return;
48
73
  }
49
- let result = (number / BASE_DEVICE_WIDTH) * (newDeviceWidth || deviceWidth);
50
- if (result < 0) {
51
- result = -result;
74
+ if (!isArray(protocol)) {
75
+ return validateProtocol(name, args[0] || Object.create(null), protocol, onFail);
52
76
  }
53
- result = Math.floor(result + EPS);
54
- if (result === 0) {
55
- if (deviceDPR === 1 || !isIOS) {
56
- result = 1;
77
+ const len = protocol.length;
78
+ const argsLen = args.length;
79
+ for (let i = 0; i < len; i++) {
80
+ const opts = protocol[i];
81
+ const data = Object.create(null);
82
+ if (argsLen > i) {
83
+ data[opts.name] = args[i];
57
84
  }
58
- else {
59
- result = 0.5;
85
+ validateProtocol(name, data, { [opts.name]: opts }, onFail);
86
+ }
87
+ }
88
+ function validateProp(name, value, prop, isAbsent) {
89
+ if (!isPlainObject(prop)) {
90
+ prop = { type: prop };
91
+ }
92
+ const { type, required, validator } = prop;
93
+ // required!
94
+ if (required && isAbsent) {
95
+ return 'Missing required args: "' + name + '"';
96
+ }
97
+ // missing but optional
98
+ if (value == null && !required) {
99
+ return;
100
+ }
101
+ // type check
102
+ if (type != null) {
103
+ let isValid = false;
104
+ const types = isArray(type) ? type : [type];
105
+ const expectedTypes = [];
106
+ // value is valid as long as one of the specified types match
107
+ for (let i = 0; i < types.length && !isValid; i++) {
108
+ const { valid, expectedType } = assertType(value, types[i]);
109
+ expectedTypes.push(expectedType || '');
110
+ isValid = valid;
111
+ }
112
+ if (!isValid) {
113
+ return getInvalidTypeMessage(name, value, expectedTypes);
60
114
  }
61
115
  }
62
- return number < 0 ? -result : result;
63
- }, Upx2pxProtocol);
116
+ // custom validator
117
+ if (validator) {
118
+ return validator(value);
119
+ }
120
+ }
121
+ const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol');
122
+ function assertType(value, type) {
123
+ let valid;
124
+ const expectedType = getType(type);
125
+ if (isSimpleType(expectedType)) {
126
+ const t = typeof value;
127
+ valid = t === expectedType.toLowerCase();
128
+ // for primitive wrapper objects
129
+ if (!valid && t === 'object') {
130
+ valid = value instanceof type;
131
+ }
132
+ }
133
+ else if (expectedType === 'Object') {
134
+ valid = isObject(value);
135
+ }
136
+ else if (expectedType === 'Array') {
137
+ valid = isArray(value);
138
+ }
139
+ else {
140
+ {
141
+ valid = value instanceof type;
142
+ }
143
+ }
144
+ return {
145
+ valid,
146
+ expectedType,
147
+ };
148
+ }
149
+ function getInvalidTypeMessage(name, value, expectedTypes) {
150
+ let message = `Invalid args: type check failed for args "${name}".` +
151
+ ` Expected ${expectedTypes.map(capitalize).join(', ')}`;
152
+ const expectedType = expectedTypes[0];
153
+ const receivedType = toRawType(value);
154
+ const expectedValue = styleValue(value, expectedType);
155
+ const receivedValue = styleValue(value, receivedType);
156
+ // check if we need to specify expected value
157
+ if (expectedTypes.length === 1 &&
158
+ isExplicable(expectedType) &&
159
+ !isBoolean(expectedType, receivedType)) {
160
+ message += ` with value ${expectedValue}`;
161
+ }
162
+ message += `, got ${receivedType} `;
163
+ // check if we need to specify received value
164
+ if (isExplicable(receivedType)) {
165
+ message += `with value ${receivedValue}.`;
166
+ }
167
+ return message;
168
+ }
169
+ function getType(ctor) {
170
+ const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
171
+ return match ? match[1] : '';
172
+ }
173
+ function styleValue(value, type) {
174
+ if (type === 'String') {
175
+ return `"${value}"`;
176
+ }
177
+ else if (type === 'Number') {
178
+ return `${Number(value)}`;
179
+ }
180
+ else {
181
+ return `${value}`;
182
+ }
183
+ }
184
+ function isExplicable(type) {
185
+ const explicitTypes = ['string', 'number', 'boolean'];
186
+ return explicitTypes.some((elem) => type.toLowerCase() === elem);
187
+ }
188
+ function isBoolean(...args) {
189
+ return args.some((elem) => elem.toLowerCase() === 'boolean');
190
+ }
64
191
 
65
- var HOOKS;
66
- (function (HOOKS) {
67
- HOOKS["INVOKE"] = "invoke";
68
- HOOKS["SUCCESS"] = "success";
69
- HOOKS["FAIL"] = "fail";
70
- HOOKS["COMPLETE"] = "complete";
71
- HOOKS["RETURN_VALUE"] = "returnValue";
72
- })(HOOKS || (HOOKS = {}));
192
+ const HOOK_SUCCESS = 'success';
193
+ const HOOK_FAIL = 'fail';
194
+ const HOOK_COMPLETE = 'complete';
73
195
  const globalInterceptors = {};
74
196
  const scopedInterceptors = {};
75
197
  function wrapperHook(hook) {
@@ -92,7 +214,7 @@ function queue(hooks, data) {
92
214
  if (res === false) {
93
215
  return {
94
216
  then() { },
95
- catch() { }
217
+ catch() { },
96
218
  };
97
219
  }
98
220
  }
@@ -101,11 +223,11 @@ function queue(hooks, data) {
101
223
  then(callback) {
102
224
  return callback(data);
103
225
  },
104
- catch() { }
226
+ catch() { },
105
227
  });
106
228
  }
107
229
  function wrapperOptions(interceptors, options = {}) {
108
- [HOOKS.SUCCESS, HOOKS.FAIL, HOOKS.COMPLETE].forEach(name => {
230
+ [HOOK_SUCCESS, HOOK_FAIL, HOOK_COMPLETE].forEach((name) => {
109
231
  const hooks = interceptors[name];
110
232
  if (!isArray(hooks)) {
111
233
  return;
@@ -128,21 +250,21 @@ function wrapperReturnValue(method, returnValue) {
128
250
  if (interceptor && isArray(interceptor.returnValue)) {
129
251
  returnValueHooks.push(...interceptor.returnValue);
130
252
  }
131
- returnValueHooks.forEach(hook => {
253
+ returnValueHooks.forEach((hook) => {
132
254
  returnValue = hook(returnValue) || returnValue;
133
255
  });
134
256
  return returnValue;
135
257
  }
136
258
  function getApiInterceptorHooks(method) {
137
259
  const interceptor = Object.create(null);
138
- Object.keys(globalInterceptors).forEach(hook => {
260
+ Object.keys(globalInterceptors).forEach((hook) => {
139
261
  if (hook !== 'returnValue') {
140
262
  interceptor[hook] = globalInterceptors[hook].slice();
141
263
  }
142
264
  });
143
265
  const scopedInterceptor = scopedInterceptors[method];
144
266
  if (scopedInterceptor) {
145
- Object.keys(scopedInterceptor).forEach(hook => {
267
+ Object.keys(scopedInterceptor).forEach((hook) => {
146
268
  if (hook !== 'returnValue') {
147
269
  interceptor[hook] = (interceptor[hook] || []).concat(scopedInterceptor[hook]);
148
270
  }
@@ -155,7 +277,7 @@ function invokeApi(method, api, options, ...params) {
155
277
  if (interceptor && Object.keys(interceptor).length) {
156
278
  if (isArray(interceptor.invoke)) {
157
279
  const res = queue(interceptor.invoke, options);
158
- return res.then(options => {
280
+ return res.then((options) => {
159
281
  return api(wrapperOptions(interceptor, options), ...params);
160
282
  });
161
283
  }
@@ -166,17 +288,128 @@ function invokeApi(method, api, options, ...params) {
166
288
  return api(options, ...params);
167
289
  }
168
290
 
291
+ function handlePromise(promise) {
292
+ if (__UNI_FEATURE_PROMISE__) {
293
+ return promise
294
+ .then((data) => {
295
+ return [null, data];
296
+ })
297
+ .catch((err) => [err]);
298
+ }
299
+ return promise;
300
+ }
301
+
302
+ function formatApiArgs(args, options) {
303
+ const params = args[0];
304
+ if (!options ||
305
+ (!isPlainObject(options.formatArgs) && isPlainObject(params))) {
306
+ return;
307
+ }
308
+ const formatArgs = options.formatArgs;
309
+ const keys = Object.keys(formatArgs);
310
+ for (let i = 0; i < keys.length; i++) {
311
+ const name = keys[i];
312
+ const formatterOrDefaultValue = formatArgs[name];
313
+ if (isFunction(formatterOrDefaultValue)) {
314
+ const errMsg = formatterOrDefaultValue(args[0][name], params);
315
+ if (isString(errMsg)) {
316
+ return errMsg;
317
+ }
318
+ }
319
+ else {
320
+ // defaultValue
321
+ if (!hasOwn(params, name)) {
322
+ params[name] = formatterOrDefaultValue;
323
+ }
324
+ }
325
+ }
326
+ }
327
+ function beforeInvokeApi(name, args, protocol, options) {
328
+ if ((process.env.NODE_ENV !== 'production')) {
329
+ validateProtocols(name, args, protocol);
330
+ }
331
+ if (options && options.beforeInvoke) {
332
+ const errMsg = options.beforeInvoke(args);
333
+ if (isString(errMsg)) {
334
+ return errMsg;
335
+ }
336
+ }
337
+ const errMsg = formatApiArgs(args, options);
338
+ if (errMsg) {
339
+ return errMsg;
340
+ }
341
+ }
342
+ function wrapperSyncApi(name, fn, protocol, options) {
343
+ return (...args) => {
344
+ const errMsg = beforeInvokeApi(name, args, protocol, options);
345
+ if (errMsg) {
346
+ throw new Error(errMsg);
347
+ }
348
+ return fn.apply(null, args);
349
+ };
350
+ }
351
+ function defineSyncApi(name, fn, protocol, options) {
352
+ return wrapperSyncApi(name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options);
353
+ }
354
+
355
+ const API_UPX2PX = 'upx2px';
356
+ const Upx2pxProtocol = [
357
+ {
358
+ name: 'upx',
359
+ type: [Number, String],
360
+ required: true,
361
+ },
362
+ ];
363
+
364
+ const EPS = 1e-4;
365
+ const BASE_DEVICE_WIDTH = 750;
366
+ let isIOS = false;
367
+ let deviceWidth = 0;
368
+ let deviceDPR = 0;
369
+ function checkDeviceWidth() {
370
+ const { platform, pixelRatio, windowWidth } = getBaseSystemInfo();
371
+ deviceWidth = windowWidth;
372
+ deviceDPR = pixelRatio;
373
+ isIOS = platform === 'ios';
374
+ }
375
+ const upx2px = defineSyncApi(API_UPX2PX, (number, newDeviceWidth) => {
376
+ if (deviceWidth === 0) {
377
+ checkDeviceWidth();
378
+ }
379
+ number = Number(number);
380
+ if (number === 0) {
381
+ return 0;
382
+ }
383
+ let width = newDeviceWidth || deviceWidth;
384
+ let result = (number / BASE_DEVICE_WIDTH) * width;
385
+ if (result < 0) {
386
+ result = -result;
387
+ }
388
+ result = Math.floor(result + EPS);
389
+ if (result === 0) {
390
+ if (deviceDPR === 1 || !isIOS) {
391
+ result = 1;
392
+ }
393
+ else {
394
+ result = 0.5;
395
+ }
396
+ }
397
+ return number < 0 ? -result : result;
398
+ }, Upx2pxProtocol);
399
+
400
+ const API_ADD_INTERCEPTOR = 'addInterceptor';
401
+ const API_REMOVE_INTERCEPTOR = 'removeInterceptor';
169
402
  const AddInterceptorProtocol = [
170
403
  {
171
404
  name: 'method',
172
405
  type: [String, Object],
173
- required: true
174
- }
406
+ required: true,
407
+ },
175
408
  ];
176
409
  const RemoveInterceptorProtocol = AddInterceptorProtocol;
177
410
 
178
411
  function mergeInterceptorHook(interceptors, interceptor) {
179
- Object.keys(interceptor).forEach(hook => {
412
+ Object.keys(interceptor).forEach((hook) => {
180
413
  if (isFunction(interceptor[hook])) {
181
414
  interceptors[hook] = mergeHook(interceptors[hook], interceptor[hook]);
182
415
  }
@@ -186,7 +419,7 @@ function removeInterceptorHook(interceptors, interceptor) {
186
419
  if (!interceptors || !interceptor) {
187
420
  return;
188
421
  }
189
- Object.keys(interceptor).forEach(hook => {
422
+ Object.keys(interceptor).forEach((hook) => {
190
423
  if (isFunction(interceptor[hook])) {
191
424
  removeHook(interceptors[hook], interceptor[hook]);
192
425
  }
@@ -220,7 +453,7 @@ function removeHook(hooks, hook) {
220
453
  hooks.splice(index, 1);
221
454
  }
222
455
  }
223
- const addInterceptor = createApi({ type: API_TYPE_SYNC, name: 'addInterceptor' }, (method, interceptor) => {
456
+ const addInterceptor = defineSyncApi(API_ADD_INTERCEPTOR, (method, interceptor) => {
224
457
  if (typeof method === 'string' && isPlainObject(interceptor)) {
225
458
  mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor);
226
459
  }
@@ -228,7 +461,7 @@ const addInterceptor = createApi({ type: API_TYPE_SYNC, name: 'addInterceptor' }
228
461
  mergeInterceptorHook(globalInterceptors, method);
229
462
  }
230
463
  }, AddInterceptorProtocol);
231
- const removeInterceptor = createApi({ type: API_TYPE_SYNC, name: 'removeInterceptor' }, (method, interceptor) => {
464
+ const removeInterceptor = defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interceptor) => {
232
465
  if (typeof method === 'string') {
233
466
  if (isPlainObject(interceptor)) {
234
467
  removeInterceptorHook(scopedInterceptors[method], interceptor);
@@ -240,9 +473,118 @@ const removeInterceptor = createApi({ type: API_TYPE_SYNC, name: 'removeIntercep
240
473
  else if (isPlainObject(method)) {
241
474
  removeInterceptorHook(globalInterceptors, method);
242
475
  }
243
- }, RemoveInterceptorProtocol);
476
+ }, RemoveInterceptorProtocol);
477
+ const interceptors = {};
478
+
479
+ const API_ON = '$on';
480
+ const OnProtocol = [
481
+ {
482
+ name: 'event',
483
+ type: String,
484
+ required: true,
485
+ },
486
+ {
487
+ name: 'callback',
488
+ type: Function,
489
+ required: true,
490
+ },
491
+ ];
492
+ const API_ONCE = '$once';
493
+ const OnceProtocol = OnProtocol;
494
+ const API_OFF = '$off';
495
+ const OffProtocol = [
496
+ {
497
+ name: 'event',
498
+ type: [String, Array],
499
+ },
500
+ {
501
+ name: 'callback',
502
+ type: Function,
503
+ },
504
+ ];
505
+ const API_EMIT = '$emit';
506
+ const EmitProtocol = [
507
+ {
508
+ name: 'event',
509
+ type: String,
510
+ required: true,
511
+ },
512
+ ];
513
+
514
+ const E = function () {
515
+ // Keep this empty so it's easier to inherit from
516
+ // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
517
+ };
518
+ E.prototype = {
519
+ on: function (name, callback, ctx) {
520
+ var e = this.e || (this.e = {});
521
+ (e[name] || (e[name] = [])).push({
522
+ fn: callback,
523
+ ctx: ctx,
524
+ });
525
+ return this;
526
+ },
527
+ once: function (name, callback, ctx) {
528
+ var self = this;
529
+ function listener() {
530
+ self.off(name, listener);
531
+ callback.apply(ctx, arguments);
532
+ }
533
+ listener._ = callback;
534
+ return this.on(name, listener, ctx);
535
+ },
536
+ emit: function (name) {
537
+ var data = [].slice.call(arguments, 1);
538
+ var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
539
+ var i = 0;
540
+ var len = evtArr.length;
541
+ for (i; i < len; i++) {
542
+ evtArr[i].fn.apply(evtArr[i].ctx, data);
543
+ }
544
+ return this;
545
+ },
546
+ off: function (name, callback) {
547
+ var e = this.e || (this.e = {});
548
+ var evts = e[name];
549
+ var liveEvents = [];
550
+ if (evts && callback) {
551
+ for (var i = 0, len = evts.length; i < len; i++) {
552
+ if (evts[i].fn !== callback && evts[i].fn._ !== callback)
553
+ liveEvents.push(evts[i]);
554
+ }
555
+ }
556
+ // Remove event from queue to prevent memory leak
557
+ // Suggested by https://github.com/lazd
558
+ // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
559
+ liveEvents.length ? (e[name] = liveEvents) : delete e[name];
560
+ return this;
561
+ },
562
+ };
563
+ var Emitter = E;
564
+
565
+ const emitter = new Emitter();
566
+ const $on = defineSyncApi(API_ON, (name, callback) => {
567
+ emitter.on(name, callback);
568
+ return () => emitter.off(name, callback);
569
+ }, OnProtocol);
570
+ const $once = defineSyncApi(API_ONCE, (name, callback) => {
571
+ emitter.once(name, callback);
572
+ return () => emitter.off(name, callback);
573
+ }, OnceProtocol);
574
+ const $off = defineSyncApi(API_OFF, (name, callback) => {
575
+ if (!name) {
576
+ emitter.e = {};
577
+ return;
578
+ }
579
+ if (!Array.isArray(name))
580
+ name = [name];
581
+ name.forEach((n) => emitter.off(n, callback));
582
+ }, OffProtocol);
583
+ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
584
+ emitter.emit(name, ...args);
585
+ }, EmitProtocol);
244
586
 
245
- const SYNC_API_RE = /^\$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
587
+ const SYNC_API_RE = /^\$|getLocale|setLocale|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
246
588
  const CONTEXT_API_RE = /^create|Manager$/;
247
589
  // Context例外情况
248
590
  const CONTEXT_API_RE_EXC = ['createBLEConnection'];
@@ -258,16 +600,6 @@ function isSyncApi(name) {
258
600
  function isCallbackApi(name) {
259
601
  return CALLBACK_API_RE.test(name) && name !== 'onPush';
260
602
  }
261
- function handlePromise(promise) {
262
- if (!__UNI_PROMISE_API__) {
263
- return promise;
264
- }
265
- return promise
266
- .then(data => {
267
- return [null, data];
268
- })
269
- .catch(err => [err]);
270
- }
271
603
  function shouldPromise(name) {
272
604
  if (isContextApi(name) || isSyncApi(name) || isCallbackApi(name)) {
273
605
  return false;
@@ -278,7 +610,7 @@ function shouldPromise(name) {
278
610
  if (!Promise.prototype.finally) {
279
611
  Promise.prototype.finally = function (onfinally) {
280
612
  const promise = this.constructor;
281
- return this.then(value => promise.resolve(onfinally && onfinally()).then(() => value), reason => promise.resolve(onfinally && onfinally()).then(() => {
613
+ return this.then((value) => promise.resolve(onfinally && onfinally()).then(() => value), (reason) => promise.resolve(onfinally && onfinally()).then(() => {
282
614
  throw reason;
283
615
  }));
284
616
  };
@@ -290,17 +622,17 @@ function promisify(name, api) {
290
622
  if (!isFunction(api)) {
291
623
  return api;
292
624
  }
293
- return function promiseApi(options = {}, ...params) {
625
+ return function promiseApi(options = {}) {
294
626
  if (isFunction(options.success) ||
295
627
  isFunction(options.fail) ||
296
628
  isFunction(options.complete)) {
297
- return wrapperReturnValue(name, invokeApi(name, api, options, ...params));
629
+ return wrapperReturnValue(name, invokeApi(name, api, options));
298
630
  }
299
631
  return wrapperReturnValue(name, handlePromise(new Promise((resolve, reject) => {
300
- invokeApi(name, api, Object.assign({}, options, {
632
+ invokeApi(name, api, extend({}, options, {
301
633
  success: resolve,
302
- fail: reject
303
- }), ...params);
634
+ fail: reject,
635
+ }));
304
636
  })));
305
637
  };
306
638
  }
@@ -396,7 +728,51 @@ function initWrapper(protocols) {
396
728
  };
397
729
  }
398
730
 
399
- const baseApis = { upx2px, addInterceptor, removeInterceptor };
731
+ const getLocale = () => {
732
+ // 优先使用 $locale
733
+ const app = getApp({ allowDefault: true });
734
+ if (app && app.$vm) {
735
+ return app.$vm.$locale;
736
+ }
737
+ return my.getSystemInfoSync().language || 'zh-Hans';
738
+ };
739
+ const setLocale = (locale) => {
740
+ const app = getApp();
741
+ if (!app) {
742
+ return false;
743
+ }
744
+ const oldLocale = app.$vm.$locale;
745
+ if (oldLocale !== locale) {
746
+ app.$vm.$locale = locale;
747
+ onLocaleChangeCallbacks.forEach((fn) => fn({ locale }));
748
+ return true;
749
+ }
750
+ return false;
751
+ };
752
+ const onLocaleChangeCallbacks = [];
753
+ const onLocaleChange = (fn) => {
754
+ if (onLocaleChangeCallbacks.indexOf(fn) === -1) {
755
+ onLocaleChangeCallbacks.push(fn);
756
+ }
757
+ };
758
+ if (typeof global !== 'undefined') {
759
+ global.getLocale = getLocale;
760
+ }
761
+
762
+ const baseApis = {
763
+ $on,
764
+ $off,
765
+ $once,
766
+ $emit,
767
+ upx2px,
768
+ interceptors,
769
+ addInterceptor,
770
+ removeInterceptor,
771
+ onAppLaunch,
772
+ getLocale,
773
+ setLocale,
774
+ onLocaleChange,
775
+ };
400
776
  function initUni(api, protocols) {
401
777
  const wrapper = initWrapper(protocols);
402
778
  const UniProxyHandlers = {
@@ -413,25 +789,25 @@ function initUni(api, protocols) {
413
789
  // event-api
414
790
  // provider-api?
415
791
  return promisify(key, wrapper(key, my[key]));
416
- }
792
+ },
417
793
  };
418
794
  return new Proxy({}, UniProxyHandlers);
419
795
  }
420
796
 
421
797
  function initGetProvider(providers) {
422
- return function getProvider({ service, success, fail, complete }) {
798
+ return function getProvider({ service, success, fail, complete, }) {
423
799
  let res;
424
800
  if (providers[service]) {
425
801
  res = {
426
802
  errMsg: 'getProvider:ok',
427
803
  service,
428
- provider: providers[service]
804
+ provider: providers[service],
429
805
  };
430
806
  isFunction(success) && success(res);
431
807
  }
432
808
  else {
433
809
  res = {
434
- errMsg: 'getProvider:fail:服务[' + service + ']不存在'
810
+ errMsg: 'getProvider:fail:服务[' + service + ']不存在',
435
811
  };
436
812
  isFunction(fail) && fail(res);
437
813
  }
@@ -446,46 +822,35 @@ function addSafeAreaInsets(fromRes, toRes) {
446
822
  top: safeArea.top,
447
823
  left: safeArea.left,
448
824
  right: fromRes.windowWidth - safeArea.right,
449
- bottom: fromRes.windowHeight - safeArea.bottom
450
- };
451
- }
452
- }
453
- const redirectTo = {};
454
- const createCanvasContext = {
455
- returnValue(fromRes, toRes) {
456
- const measureText = fromRes.measureText;
457
- toRes.measureText = function (text, callback) {
458
- const textMetrics = measureText.call(this, text);
459
- if (typeof callback === 'function') {
460
- setTimeout(() => callback(textMetrics), 0);
461
- }
462
- return textMetrics;
825
+ bottom: fromRes.windowHeight - safeArea.bottom,
463
826
  };
464
827
  }
465
- };
828
+ }
829
+
830
+ const redirectTo = {};
466
831
 
467
832
  const getProvider = initGetProvider({
468
833
  oauth: ['alipay'],
469
834
  share: ['alipay'],
470
835
  payment: ['alipay'],
471
- push: ['alipay']
836
+ push: ['alipay'],
472
837
  });
473
838
  function setStorageSync(key, data) {
474
839
  return my.setStorageSync({
475
840
  key,
476
- data
841
+ data,
477
842
  });
478
843
  }
479
844
  function getStorageSync(key) {
480
845
  const result = my.getStorageSync({
481
- key
846
+ key,
482
847
  });
483
848
  // 支付宝平台会返回一个 success 值,但是目前测试的结果这个始终是 true。当没有存储数据的时候,其它平台会返回空字符串。
484
849
  return result.data !== null ? result.data : '';
485
850
  }
486
851
  function removeStorageSync(key) {
487
852
  return my.removeStorageSync({
488
- key
853
+ key,
489
854
  });
490
855
  }
491
856
  function startGyroscope(args) {
@@ -494,11 +859,11 @@ function startGyroscope(args) {
494
859
  }
495
860
  args.success &&
496
861
  args.success({
497
- errMsg: 'startGyroscope:ok'
862
+ errMsg: 'startGyroscope:ok',
498
863
  });
499
864
  args.complete &&
500
865
  args.complete({
501
- errMsg: 'startGyroscope:ok'
866
+ errMsg: 'startGyroscope:ok',
502
867
  });
503
868
  }
504
869
  function createExecCallback(execCallback) {
@@ -567,14 +932,14 @@ function createIntersectionObserver(component, options) {
567
932
  }
568
933
 
569
934
  var shims = /*#__PURE__*/Object.freeze({
570
- __proto__: null,
571
- getProvider: getProvider,
572
- setStorageSync: setStorageSync,
573
- getStorageSync: getStorageSync,
574
- removeStorageSync: removeStorageSync,
575
- startGyroscope: startGyroscope,
576
- createSelectorQuery: createSelectorQuery,
577
- createIntersectionObserver: createIntersectionObserver
935
+ __proto__: null,
936
+ getProvider: getProvider,
937
+ setStorageSync: setStorageSync,
938
+ getStorageSync: getStorageSync,
939
+ removeStorageSync: removeStorageSync,
940
+ startGyroscope: startGyroscope,
941
+ createSelectorQuery: createSelectorQuery,
942
+ createIntersectionObserver: createIntersectionObserver
578
943
  });
579
944
 
580
945
  function handleNetworkInfo(fromRes, toRes) {
@@ -600,7 +965,7 @@ function handleSystemInfo(fromRes, toRes) {
600
965
  }
601
966
  toRes.platform = platform;
602
967
  }
603
- function returnValue(methodName, res) {
968
+ function returnValue(methodName, res = {}) {
604
969
  // 通用 returnValue 解析
605
970
  if (res.error || res.errorMessage) {
606
971
  res.errMsg = `${methodName}:fail ${res.errorMessage || res.error}`;
@@ -621,16 +986,16 @@ const request = {
621
986
  fromArgs.header = {};
622
987
  }
623
988
  const headers = {
624
- 'content-type': 'application/json'
989
+ 'content-type': 'application/json',
625
990
  };
626
- Object.keys(fromArgs.header).forEach(key => {
991
+ Object.keys(fromArgs.header).forEach((key) => {
627
992
  headers[key.toLocaleLowerCase()] = fromArgs.header[key];
628
993
  });
629
994
  return {
630
995
  header() {
631
996
  return {
632
997
  name: 'headers',
633
- value: headers
998
+ value: headers,
634
999
  };
635
1000
  },
636
1001
  data(data) {
@@ -641,32 +1006,32 @@ const request = {
641
1006
  isPlainObject(data)) {
642
1007
  return {
643
1008
  name: 'data',
644
- value: JSON.stringify(data)
1009
+ value: JSON.stringify(data),
645
1010
  };
646
1011
  }
647
1012
  return {
648
1013
  name: 'data',
649
- value: data
1014
+ value: data,
650
1015
  };
651
1016
  },
652
1017
  method: 'method',
653
- responseType: false
1018
+ responseType: false,
654
1019
  };
655
1020
  },
656
1021
  returnValue: {
657
1022
  status: 'statusCode',
658
- headers: 'header'
659
- }
1023
+ headers: 'header',
1024
+ },
660
1025
  };
661
1026
  const setNavigationBarColor = {
662
1027
  name: 'setNavigationBar',
663
1028
  args: {
664
1029
  frontColor: false,
665
- animation: false
666
- }
1030
+ animation: false,
1031
+ },
667
1032
  };
668
1033
  const setNavigationBarTitle = {
669
- name: 'setNavigationBar'
1034
+ name: 'setNavigationBar',
670
1035
  };
671
1036
  function showModal({ showCancel = true } = {}) {
672
1037
  if (showCancel) {
@@ -676,24 +1041,24 @@ function showModal({ showCancel = true } = {}) {
676
1041
  cancelColor: false,
677
1042
  confirmColor: false,
678
1043
  cancelText: 'cancelButtonText',
679
- confirmText: 'confirmButtonText'
1044
+ confirmText: 'confirmButtonText',
680
1045
  },
681
1046
  returnValue(fromRes, toRes) {
682
1047
  toRes.confirm = fromRes.confirm;
683
1048
  toRes.cancel = !fromRes.confirm;
684
- }
1049
+ },
685
1050
  };
686
1051
  }
687
1052
  return {
688
1053
  name: 'alert',
689
1054
  args: {
690
1055
  confirmColor: false,
691
- confirmText: 'buttonText'
1056
+ confirmText: 'buttonText',
692
1057
  },
693
1058
  returnValue(fromRes, toRes) {
694
1059
  toRes.confirm = true;
695
1060
  toRes.cancel = false;
696
- }
1061
+ },
697
1062
  };
698
1063
  }
699
1064
  function showToast({ icon = 'success' } = {}) {
@@ -702,50 +1067,50 @@ function showToast({ icon = 'success' } = {}) {
702
1067
  icon: 'type',
703
1068
  duration: false,
704
1069
  image: false,
705
- mask: false
1070
+ mask: false,
706
1071
  };
707
1072
  if (icon === 'loading') {
708
1073
  return {
709
1074
  name: 'showLoading',
710
- args
1075
+ args,
711
1076
  };
712
1077
  }
713
1078
  return {
714
1079
  name: 'showToast',
715
- args
1080
+ args,
716
1081
  };
717
1082
  }
718
1083
  const showActionSheet = {
719
1084
  name: 'showActionSheet',
720
1085
  args: {
721
1086
  itemList: 'items',
722
- itemColor: false
1087
+ itemColor: false,
723
1088
  },
724
1089
  returnValue: {
725
- index: 'tapIndex'
726
- }
1090
+ index: 'tapIndex',
1091
+ },
727
1092
  };
728
1093
  const showLoading = {
729
1094
  args: {
730
1095
  title: 'content',
731
- mask: false
732
- }
1096
+ mask: false,
1097
+ },
733
1098
  };
734
1099
  const uploadFile = {
735
1100
  args: {
736
- name: 'fileName'
737
- }
1101
+ name: 'fileName',
1102
+ },
738
1103
  // 从测试结果看,是有返回对象的,文档上没有说明。
739
1104
  };
740
1105
  const downloadFile = {
741
1106
  returnValue: {
742
- apFilePath: 'tempFilePath'
743
- }
1107
+ apFilePath: 'tempFilePath',
1108
+ },
744
1109
  };
745
1110
  const getFileInfo = {
746
1111
  args: {
747
- filePath: 'apFilePath'
748
- }
1112
+ filePath: 'apFilePath',
1113
+ },
749
1114
  };
750
1115
  const compressImage = {
751
1116
  args(fromArgs, toArgs) {
@@ -762,25 +1127,35 @@ const compressImage = {
762
1127
  if (apFilePaths && apFilePaths.length) {
763
1128
  toRes.tempFilePath = apFilePaths[0];
764
1129
  }
765
- }
1130
+ },
766
1131
  };
767
1132
  const chooseVideo = {
768
1133
  // 支付宝小程序文档中未找到(仅在getSetting处提及),但实际可用
769
1134
  returnValue: {
770
- apFilePath: 'tempFilePath'
771
- }
1135
+ apFilePath: 'tempFilePath',
1136
+ },
772
1137
  };
773
1138
  const connectSocket = {
774
1139
  args: {
775
1140
  method: false,
776
- protocols: false
777
- }
1141
+ protocols: false,
1142
+ },
778
1143
  // TODO 有没有返回值还需要测试下
779
1144
  };
780
1145
  const chooseImage = {
781
- returnValue: {
782
- apFilePaths: 'tempFilePaths'
783
- }
1146
+ returnValue(result) {
1147
+ var _a, _b;
1148
+ const hasTempFilePaths = hasOwn(result, 'tempFilePaths') && result.tempFilePaths;
1149
+ if (hasOwn(result, 'apFilePaths') && !hasTempFilePaths) {
1150
+ result.tempFilePaths = [];
1151
+ (_a = result.apFilePaths) === null || _a === void 0 ? void 0 : _a.forEach((apFilePath) => { var _a; return (_a = result.tempFilePaths) === null || _a === void 0 ? void 0 : _a.push(apFilePath); });
1152
+ }
1153
+ if (!hasOwn(result, 'tempFiles') && hasTempFilePaths) {
1154
+ result.tempFiles = [];
1155
+ (_b = result.tempFilePaths) === null || _b === void 0 ? void 0 : _b.forEach((tempFilePath) => { var _a; return (_a = result.tempFiles) === null || _a === void 0 ? void 0 : _a.push({ path: tempFilePath }); });
1156
+ }
1157
+ return {};
1158
+ },
784
1159
  };
785
1160
  const previewImage = {
786
1161
  args(fromArgs, toArgs) {
@@ -797,93 +1172,93 @@ const previewImage = {
797
1172
  }
798
1173
  return {
799
1174
  indicator: false,
800
- loop: false
1175
+ loop: false,
801
1176
  };
802
- }
1177
+ },
803
1178
  };
804
1179
  const saveFile = {
805
1180
  args: {
806
- tempFilePath: 'apFilePath'
1181
+ tempFilePath: 'apFilePath',
807
1182
  },
808
1183
  returnValue: {
809
- apFilePath: 'savedFilePath'
810
- }
1184
+ apFilePath: 'savedFilePath',
1185
+ },
811
1186
  };
812
1187
  const getSavedFileInfo = {
813
1188
  args: {
814
- filePath: 'apFilePath'
815
- }
1189
+ filePath: 'apFilePath',
1190
+ },
816
1191
  };
817
1192
  const getSavedFileList = {
818
1193
  returnValue(fromRes, toRes) {
819
- toRes.fileList = fromRes.fileList.map(file => {
1194
+ toRes.fileList = fromRes.fileList.map((file) => {
820
1195
  return {
821
1196
  filePath: file.apFilePath,
822
1197
  createTime: file.createTime,
823
- size: file.size
1198
+ size: file.size,
824
1199
  };
825
1200
  });
826
- }
1201
+ },
827
1202
  };
828
1203
  const removeSavedFile = {
829
1204
  args: {
830
- filePath: 'apFilePath'
831
- }
1205
+ filePath: 'apFilePath',
1206
+ },
832
1207
  };
833
1208
  const getLocation = {
834
1209
  args: {
835
1210
  type: false,
836
- altitude: false
837
- }
1211
+ altitude: false,
1212
+ },
838
1213
  };
839
1214
  const openLocation = {
840
1215
  args: {
841
1216
  // TODO address 参数在阿里上是必传的
842
- }
1217
+ },
843
1218
  };
844
1219
  const getNetworkType = {
845
- returnValue: handleNetworkInfo
1220
+ returnValue: handleNetworkInfo,
846
1221
  };
847
1222
  const onNetworkStatusChange = {
848
- returnValue: handleNetworkInfo
1223
+ returnValue: handleNetworkInfo,
849
1224
  };
850
1225
  const stopAccelerometer = {
851
- name: 'offAccelerometerChange'
1226
+ name: 'offAccelerometerChange',
852
1227
  };
853
1228
  const stopCompass = {
854
- name: 'offCompassChange'
1229
+ name: 'offCompassChange',
855
1230
  };
856
1231
  const scanCode = {
857
1232
  name: 'scan',
858
1233
  args: {
859
- onlyFromCamera: 'hideAlbum'
1234
+ onlyFromCamera: 'hideAlbum',
860
1235
  },
861
1236
  returnValue: {
862
- code: 'result'
863
- }
1237
+ code: 'result',
1238
+ },
864
1239
  };
865
1240
  const setClipboardData = {
866
1241
  name: 'setClipboard',
867
1242
  args: {
868
- data: 'text'
869
- }
1243
+ data: 'text',
1244
+ },
870
1245
  };
871
1246
  const getClipboardData = {
872
1247
  name: 'getClipboard',
873
1248
  returnValue: {
874
- text: 'data'
875
- }
1249
+ text: 'data',
1250
+ },
876
1251
  };
877
1252
  const pageScrollTo = {
878
1253
  args: {
879
- duration: false
880
- }
1254
+ duration: false,
1255
+ },
881
1256
  };
882
1257
  const login = {
883
1258
  name: 'getAuthCode',
884
1259
  returnValue: {
885
- authCode: 'code'
886
- }
1260
+ authCode: 'code',
1261
+ },
887
1262
  };
888
1263
  const getUserInfo = {
889
1264
  name: my.canIUse('getOpenUserInfo') ? 'getOpenUserInfo' : 'getAuthUserInfo',
@@ -904,86 +1279,86 @@ const getUserInfo = {
904
1279
  toRes.userInfo = {
905
1280
  openId: '',
906
1281
  nickName: fromRes.nickName,
907
- avatarUrl: fromRes.avatar
1282
+ avatarUrl: fromRes.avatar,
908
1283
  };
909
1284
  }
910
- }
1285
+ },
911
1286
  };
912
1287
  const requestPayment = {
913
1288
  name: 'tradePay',
914
1289
  args: {
915
- orderInfo: 'tradeNO'
916
- }
1290
+ orderInfo: 'tradeNO',
1291
+ },
917
1292
  };
918
1293
  const getBLEDeviceServices = {
919
1294
  returnValue(fromRes, toRes) {
920
- toRes.services = fromRes.services.map(item => {
1295
+ toRes.services = fromRes.services.map((item) => {
921
1296
  return {
922
1297
  uuid: item.serviceId,
923
- isPrimary: item.isPrimary
1298
+ isPrimary: item.isPrimary,
924
1299
  };
925
1300
  });
926
- }
1301
+ },
927
1302
  };
928
1303
  const createBLEConnection = {
929
1304
  name: 'connectBLEDevice',
930
1305
  args: {
931
- timeout: false
932
- }
1306
+ timeout: false,
1307
+ },
933
1308
  };
934
1309
  const closeBLEConnection = {
935
- name: 'disconnectBLEDevice'
1310
+ name: 'disconnectBLEDevice',
936
1311
  };
937
1312
  const onBLEConnectionStateChange = {
938
- name: 'onBLEConnectionStateChanged'
1313
+ name: 'onBLEConnectionStateChanged',
939
1314
  };
940
1315
  const makePhoneCall = {
941
1316
  args: {
942
- phoneNumber: 'number'
943
- }
1317
+ phoneNumber: 'number',
1318
+ },
944
1319
  };
945
1320
  const stopGyroscope = {
946
- name: 'offGyroscopeChange'
1321
+ name: 'offGyroscopeChange',
947
1322
  };
948
1323
  const getSystemInfo = {
949
- returnValue: handleSystemInfo
1324
+ returnValue: handleSystemInfo,
950
1325
  };
951
1326
  const getSystemInfoSync = {
952
- returnValue: handleSystemInfo
1327
+ returnValue: handleSystemInfo,
953
1328
  };
954
1329
  // 文档没提到,但是实测可用。
955
1330
  const canvasToTempFilePath = {
956
1331
  returnValue(fromRes, toRes) {
957
1332
  // 真机的情况下会有 tempFilePath 这个值,因此需要主动修改。
958
1333
  toRes.tempFilePath = fromRes.apFilePath;
959
- }
1334
+ },
960
1335
  };
961
1336
  const setScreenBrightness = {
962
1337
  args: {
963
- value: 'brightness'
964
- }
1338
+ value: 'brightness',
1339
+ },
965
1340
  };
966
1341
  const getScreenBrightness = {
967
1342
  returnValue: {
968
- brightness: 'value'
969
- }
1343
+ brightness: 'value',
1344
+ },
970
1345
  };
971
1346
  const showShareMenu = {
972
- name: 'showSharePanel'
1347
+ name: 'showSharePanel',
973
1348
  };
974
1349
  const hideHomeButton = {
975
- name: 'hideBackHome'
1350
+ name: 'hideBackHome',
976
1351
  };
977
1352
  const saveImageToPhotosAlbum = {
978
1353
  name: 'saveImage',
979
1354
  args: {
980
- filePath: 'url'
981
- }
1355
+ filePath: 'url',
1356
+ },
982
1357
  };
983
1358
  const saveVideoToPhotosAlbum = {
984
1359
  args: {
985
- filePath: 'src'
986
- }
1360
+ filePath: 'src',
1361
+ },
987
1362
  };
988
1363
  const chooseAddress = {
989
1364
  name: 'getAddress',
@@ -996,64 +1371,64 @@ const chooseAddress = {
996
1371
  toRes.detailInfo = info.address;
997
1372
  toRes.telNumber = info.mobilePhone;
998
1373
  toRes.errMsg = toRes.errMsg + ' ' + fromRes.resultStatus;
999
- }
1374
+ },
1000
1375
  };
1001
1376
 
1002
1377
  var protocols = /*#__PURE__*/Object.freeze({
1003
- __proto__: null,
1004
- returnValue: returnValue,
1005
- request: request,
1006
- setNavigationBarColor: setNavigationBarColor,
1007
- setNavigationBarTitle: setNavigationBarTitle,
1008
- showModal: showModal,
1009
- showToast: showToast,
1010
- showActionSheet: showActionSheet,
1011
- showLoading: showLoading,
1012
- uploadFile: uploadFile,
1013
- downloadFile: downloadFile,
1014
- getFileInfo: getFileInfo,
1015
- compressImage: compressImage,
1016
- chooseVideo: chooseVideo,
1017
- connectSocket: connectSocket,
1018
- chooseImage: chooseImage,
1019
- previewImage: previewImage,
1020
- saveFile: saveFile,
1021
- getSavedFileInfo: getSavedFileInfo,
1022
- getSavedFileList: getSavedFileList,
1023
- removeSavedFile: removeSavedFile,
1024
- getLocation: getLocation,
1025
- openLocation: openLocation,
1026
- getNetworkType: getNetworkType,
1027
- onNetworkStatusChange: onNetworkStatusChange,
1028
- stopAccelerometer: stopAccelerometer,
1029
- stopCompass: stopCompass,
1030
- scanCode: scanCode,
1031
- setClipboardData: setClipboardData,
1032
- getClipboardData: getClipboardData,
1033
- pageScrollTo: pageScrollTo,
1034
- login: login,
1035
- getUserInfo: getUserInfo,
1036
- requestPayment: requestPayment,
1037
- getBLEDeviceServices: getBLEDeviceServices,
1038
- createBLEConnection: createBLEConnection,
1039
- closeBLEConnection: closeBLEConnection,
1040
- onBLEConnectionStateChange: onBLEConnectionStateChange,
1041
- makePhoneCall: makePhoneCall,
1042
- stopGyroscope: stopGyroscope,
1043
- getSystemInfo: getSystemInfo,
1044
- getSystemInfoSync: getSystemInfoSync,
1045
- canvasToTempFilePath: canvasToTempFilePath,
1046
- setScreenBrightness: setScreenBrightness,
1047
- getScreenBrightness: getScreenBrightness,
1048
- showShareMenu: showShareMenu,
1049
- hideHomeButton: hideHomeButton,
1050
- saveImageToPhotosAlbum: saveImageToPhotosAlbum,
1051
- saveVideoToPhotosAlbum: saveVideoToPhotosAlbum,
1052
- chooseAddress: chooseAddress,
1053
- redirectTo: redirectTo,
1054
- createCanvasContext: createCanvasContext
1378
+ __proto__: null,
1379
+ returnValue: returnValue,
1380
+ request: request,
1381
+ setNavigationBarColor: setNavigationBarColor,
1382
+ setNavigationBarTitle: setNavigationBarTitle,
1383
+ showModal: showModal,
1384
+ showToast: showToast,
1385
+ showActionSheet: showActionSheet,
1386
+ showLoading: showLoading,
1387
+ uploadFile: uploadFile,
1388
+ downloadFile: downloadFile,
1389
+ getFileInfo: getFileInfo,
1390
+ compressImage: compressImage,
1391
+ chooseVideo: chooseVideo,
1392
+ connectSocket: connectSocket,
1393
+ chooseImage: chooseImage,
1394
+ previewImage: previewImage,
1395
+ saveFile: saveFile,
1396
+ getSavedFileInfo: getSavedFileInfo,
1397
+ getSavedFileList: getSavedFileList,
1398
+ removeSavedFile: removeSavedFile,
1399
+ getLocation: getLocation,
1400
+ openLocation: openLocation,
1401
+ getNetworkType: getNetworkType,
1402
+ onNetworkStatusChange: onNetworkStatusChange,
1403
+ stopAccelerometer: stopAccelerometer,
1404
+ stopCompass: stopCompass,
1405
+ scanCode: scanCode,
1406
+ setClipboardData: setClipboardData,
1407
+ getClipboardData: getClipboardData,
1408
+ pageScrollTo: pageScrollTo,
1409
+ login: login,
1410
+ getUserInfo: getUserInfo,
1411
+ requestPayment: requestPayment,
1412
+ getBLEDeviceServices: getBLEDeviceServices,
1413
+ createBLEConnection: createBLEConnection,
1414
+ closeBLEConnection: closeBLEConnection,
1415
+ onBLEConnectionStateChange: onBLEConnectionStateChange,
1416
+ makePhoneCall: makePhoneCall,
1417
+ stopGyroscope: stopGyroscope,
1418
+ getSystemInfo: getSystemInfo,
1419
+ getSystemInfoSync: getSystemInfoSync,
1420
+ canvasToTempFilePath: canvasToTempFilePath,
1421
+ setScreenBrightness: setScreenBrightness,
1422
+ getScreenBrightness: getScreenBrightness,
1423
+ showShareMenu: showShareMenu,
1424
+ hideHomeButton: hideHomeButton,
1425
+ saveImageToPhotosAlbum: saveImageToPhotosAlbum,
1426
+ saveVideoToPhotosAlbum: saveVideoToPhotosAlbum,
1427
+ chooseAddress: chooseAddress,
1428
+ redirectTo: redirectTo,
1429
+ navigateTo: navigateTo
1055
1430
  });
1056
1431
 
1057
1432
  var index = initUni(shims, protocols);
1058
1433
 
1059
- export default index;
1434
+ export { index as default };