@tarojs/taro-h5 3.5.11 → 3.6.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/base/system.js +5 -1
- package/dist/api/device/clipboard.js +2 -1
- package/dist/api/location/chooseLocation.js +4 -4
- package/dist/api/location/getLocation.js +2 -2
- package/dist/api/media/image/chooseImage.js +2 -2
- package/dist/api/media/image/getImageInfo.js +2 -2
- package/dist/api/media/image/previewImage.js +2 -1
- package/dist/api/media/video/index.js +2 -2
- package/dist/api/network/request/index.js +9 -8
- package/dist/api/network/websocket/index.d.ts +1 -1
- package/dist/api/network/websocket/index.js +3 -3
- package/dist/api/network/websocket/socketTask.js +7 -6
- package/dist/api/taro.js +2 -1
- package/dist/api/ui/navigation-bar/index.d.ts +1 -1
- package/dist/api/ui/pull-down-refresh.js +4 -4
- package/dist/api/ui/scroll/index.js +3 -3
- package/dist/api/ui/tab-bar.js +16 -16
- package/dist/api/wxml/MediaQueryObserver.js +4 -3
- package/dist/api/wxml/nodesRef.d.ts +1 -0
- package/dist/api/wxml/selectorQuery.js +3 -2
- package/dist/index.cjs.d.ts +2 -2
- package/dist/index.cjs.js +89 -80
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.d.ts +2 -2
- package/dist/index.esm.js +88 -79
- package/dist/index.esm.js.map +1 -1
- package/dist/taroApis.d.ts +2 -2
- package/dist/utils/handler.d.ts +8 -3
- package/dist/utils/handler.js +19 -10
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +6 -6
- package/dist/utils/valid.d.ts +1 -2
- package/dist/utils/valid.js +0 -3
- package/package.json +9 -4
- package/types/global.d.ts +1 -0
package/dist/index.esm.d.ts
CHANGED
|
@@ -551,7 +551,7 @@ declare function onSocketOpen(): void;
|
|
|
551
551
|
declare function onSocketMessage(): void;
|
|
552
552
|
declare function onSocketError(): void;
|
|
553
553
|
declare function onSocketClose(): void;
|
|
554
|
-
declare function connectSocket(options
|
|
554
|
+
declare function connectSocket(options?: Taro.connectSocket.Option): Promise<unknown>;
|
|
555
555
|
declare function closeSocket(): void;
|
|
556
556
|
// 帐号信息
|
|
557
557
|
declare const getAccountInfoSync: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
@@ -686,7 +686,7 @@ declare const disableAlertBeforeUnload: (option?: {}, ...args: any[]) => Promise
|
|
|
686
686
|
declare const getMenuButtonBoundingClientRect: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
687
687
|
// 导航栏
|
|
688
688
|
declare const showNavigationBarLoading: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
689
|
-
declare function setNavigationBarTitle(options
|
|
689
|
+
declare function setNavigationBarTitle(options?: Taro.setNavigationBarTitle.Option): Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
690
690
|
/**
|
|
691
691
|
* 设置页面导航条颜色
|
|
692
692
|
*/
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Taro from '@tarojs/api';
|
|
2
2
|
import { history, navigateBack, navigateTo, reLaunch, redirectTo, getCurrentPages, switchTab } from '@tarojs/router';
|
|
3
3
|
export { getCurrentPages, history, navigateBack, navigateTo, reLaunch, redirectTo, switchTab } from '@tarojs/router';
|
|
4
|
+
import { isFunction } from '@tarojs/shared';
|
|
4
5
|
import { addLeadingSlash, stripBasename, getHomePage } from '@tarojs/router/dist/utils';
|
|
5
6
|
import { hooks, Current as Current$1 } from '@tarojs/runtime';
|
|
6
7
|
import { fromByteArray, toByteArray } from 'base64-js';
|
|
@@ -11,30 +12,38 @@ import jsonpRetry from 'jsonp-retry';
|
|
|
11
12
|
|
|
12
13
|
class MethodHandler {
|
|
13
14
|
constructor({ name, success, fail, complete }) {
|
|
15
|
+
this.isHandlerError = false;
|
|
14
16
|
this.methodName = name;
|
|
15
17
|
this.__success = success;
|
|
16
18
|
this.__fail = fail;
|
|
17
19
|
this.__complete = complete;
|
|
20
|
+
this.isHandlerError = isFunction(this.__complete) || isFunction(this.__fail);
|
|
18
21
|
}
|
|
19
|
-
success(res = {},
|
|
22
|
+
success(res = {}, promise = {}) {
|
|
20
23
|
if (!res.errMsg) {
|
|
21
24
|
res.errMsg = `${this.methodName}:ok`;
|
|
22
25
|
}
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
isFunction(this.__success) && this.__success(res);
|
|
27
|
+
isFunction(this.__complete) && this.__complete(res);
|
|
28
|
+
const { resolve = Promise.resolve.bind(Promise) } = promise;
|
|
25
29
|
return resolve(res);
|
|
26
30
|
}
|
|
27
|
-
fail(res = {},
|
|
31
|
+
fail(res = {}, promise = {}) {
|
|
28
32
|
if (!res.errMsg) {
|
|
29
33
|
res.errMsg = `${this.methodName}:fail`;
|
|
30
34
|
}
|
|
31
35
|
else {
|
|
32
36
|
res.errMsg = `${this.methodName}:fail ${res.errMsg}`;
|
|
33
37
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
39
|
+
console.error(res.errMsg);
|
|
40
|
+
}
|
|
41
|
+
isFunction(this.__fail) && this.__fail(res);
|
|
42
|
+
isFunction(this.__complete) && this.__complete(res);
|
|
43
|
+
const { resolve = Promise.resolve.bind(Promise), reject = Promise.reject.bind(Promise) } = promise;
|
|
44
|
+
return this.isHandlerError
|
|
45
|
+
? resolve(res)
|
|
46
|
+
: reject(res);
|
|
38
47
|
}
|
|
39
48
|
}
|
|
40
49
|
class CallbackManager {
|
|
@@ -78,12 +87,12 @@ class CallbackManager {
|
|
|
78
87
|
*/
|
|
79
88
|
this.trigger = (...args) => {
|
|
80
89
|
this.callbacks.forEach(opt => {
|
|
81
|
-
if (
|
|
90
|
+
if (isFunction(opt)) {
|
|
82
91
|
opt(...args);
|
|
83
92
|
}
|
|
84
93
|
else {
|
|
85
94
|
const { callback, ctx } = opt;
|
|
86
|
-
|
|
95
|
+
isFunction(callback) && callback.call(ctx, ...args);
|
|
87
96
|
}
|
|
88
97
|
});
|
|
89
98
|
};
|
|
@@ -135,16 +144,12 @@ function debounce(fn, ms = 250, scope) {
|
|
|
135
144
|
};
|
|
136
145
|
}
|
|
137
146
|
|
|
138
|
-
function isFunction(obj) {
|
|
139
|
-
return typeof obj === 'function';
|
|
140
|
-
}
|
|
141
147
|
const VALID_COLOR_REG = /^#[0-9a-fA-F]{6}$/;
|
|
142
148
|
const isValidColor = (color) => {
|
|
143
149
|
return VALID_COLOR_REG.test(color);
|
|
144
150
|
};
|
|
145
151
|
|
|
146
152
|
/* eslint-disable prefer-promise-reject-errors */
|
|
147
|
-
const isProd = process.env.NODE_ENV === 'production';
|
|
148
153
|
function shouldBeObject(target) {
|
|
149
154
|
if (target && typeof target === 'object')
|
|
150
155
|
return { flag: true };
|
|
@@ -226,7 +231,7 @@ function temporarilyNotSupport(name = '') {
|
|
|
226
231
|
type: 'method',
|
|
227
232
|
category: 'temporarily',
|
|
228
233
|
});
|
|
229
|
-
if (
|
|
234
|
+
if (process.env.NODE_ENV === 'production') {
|
|
230
235
|
console.warn(errMsg);
|
|
231
236
|
return handle.success({ errMsg });
|
|
232
237
|
}
|
|
@@ -246,7 +251,7 @@ function weixinCorpSupport(name) {
|
|
|
246
251
|
type: 'method',
|
|
247
252
|
category: 'weixin_corp',
|
|
248
253
|
});
|
|
249
|
-
if (
|
|
254
|
+
if (process.env.NODE_ENV === 'production') {
|
|
250
255
|
console.warn(errMsg);
|
|
251
256
|
return handle.success({ errMsg });
|
|
252
257
|
}
|
|
@@ -266,7 +271,7 @@ function permanentlyNotSupport(name = '') {
|
|
|
266
271
|
type: 'method',
|
|
267
272
|
category: 'permanently',
|
|
268
273
|
});
|
|
269
|
-
if (
|
|
274
|
+
if (process.env.NODE_ENV === 'production') {
|
|
270
275
|
console.warn(errMsg);
|
|
271
276
|
return handle.success({ errMsg });
|
|
272
277
|
}
|
|
@@ -282,7 +287,7 @@ function processOpenApi({ name, defaultOptions, standardMethod, formatOptions =
|
|
|
282
287
|
// @ts-ignore
|
|
283
288
|
const targetApi = (_a = window === null || window === void 0 ? void 0 : window.wx) === null || _a === void 0 ? void 0 : _a[name];
|
|
284
289
|
const opts = formatOptions(Object.assign({}, defaultOptions, options));
|
|
285
|
-
if (
|
|
290
|
+
if (isFunction(targetApi)) {
|
|
286
291
|
return new Promise((resolve, reject) => {
|
|
287
292
|
['fail', 'success', 'complete'].forEach(k => {
|
|
288
293
|
opts[k] = preRef => {
|
|
@@ -299,7 +304,7 @@ function processOpenApi({ name, defaultOptions, standardMethod, formatOptions =
|
|
|
299
304
|
});
|
|
300
305
|
});
|
|
301
306
|
}
|
|
302
|
-
else if (
|
|
307
|
+
else if (isFunction(standardMethod)) {
|
|
303
308
|
return standardMethod(opts);
|
|
304
309
|
}
|
|
305
310
|
else {
|
|
@@ -631,6 +636,8 @@ const getDeviceInfo = () => {
|
|
|
631
636
|
const info = {
|
|
632
637
|
/** 应用二进制接口类型(仅 Android 支持) */
|
|
633
638
|
abi: '',
|
|
639
|
+
/** 设备二进制接口类型(仅 Android 支持) */
|
|
640
|
+
deviceAbi: '',
|
|
634
641
|
/** 设备性能等级(仅Android小游戏)。取值为:-2 或 0(该设备无法运行小游戏),-1(性能未知),>=1(设备性能值,该值越高,设备性能越好,目前最高不到50) */
|
|
635
642
|
benchmarkLevel: -1,
|
|
636
643
|
/** 设备品牌 */
|
|
@@ -640,7 +647,9 @@ const getDeviceInfo = () => {
|
|
|
640
647
|
/** 操作系统及版本 */
|
|
641
648
|
system: md.os(),
|
|
642
649
|
/** 客户端平台 */
|
|
643
|
-
platform: navigator.platform
|
|
650
|
+
platform: navigator.platform,
|
|
651
|
+
/** 设备二进制接口类型(仅 Android 支持) */
|
|
652
|
+
CPUType: '',
|
|
644
653
|
};
|
|
645
654
|
return info;
|
|
646
655
|
};
|
|
@@ -1486,7 +1495,7 @@ const setClipboardData = ({ data, success, fail, complete }) => __awaiter(void 0
|
|
|
1486
1495
|
* iOS < 10 的系统可能无法使用编程方式访问剪贴板,参考:
|
|
1487
1496
|
* https://stackoverflow.com/questions/34045777/copy-to-clipboard-using-javascript-in-ios/34046084
|
|
1488
1497
|
*/
|
|
1489
|
-
if (
|
|
1498
|
+
if (isFunction(document.execCommand)) {
|
|
1490
1499
|
const textarea = document.createElement('textarea');
|
|
1491
1500
|
textarea.readOnly = true;
|
|
1492
1501
|
textarea.value = data;
|
|
@@ -1946,9 +1955,9 @@ const getLocationByW3CApi = (options) => {
|
|
|
1946
1955
|
/** 调用结果,自动补充 */
|
|
1947
1956
|
errMsg: ''
|
|
1948
1957
|
};
|
|
1949
|
-
handle.success(result, resolve);
|
|
1958
|
+
handle.success(result, { resolve, reject });
|
|
1950
1959
|
}, (error) => {
|
|
1951
|
-
handle.fail({ errMsg: error.message }, reject);
|
|
1960
|
+
handle.fail({ errMsg: error.message }, { resolve, reject });
|
|
1952
1961
|
}, positionOptions);
|
|
1953
1962
|
});
|
|
1954
1963
|
};
|
|
@@ -2046,7 +2055,7 @@ const chooseLocation = ({ success, fail, complete, mapOpts } = {}) => {
|
|
|
2046
2055
|
console.warn('chooseLocation api 依赖腾讯地图定位api,需要在 defineConstants 中配置 LOCATION_APIKEY');
|
|
2047
2056
|
return handle.fail({
|
|
2048
2057
|
errMsg: 'LOCATION_APIKEY needed'
|
|
2049
|
-
}, reject);
|
|
2058
|
+
}, { resolve, reject });
|
|
2050
2059
|
}
|
|
2051
2060
|
const onMessage = event => {
|
|
2052
2061
|
// 接收位置信息,用户选择确认位置点后选点组件会触发该事件,回传用户的位置信息
|
|
@@ -2065,14 +2074,14 @@ const chooseLocation = ({ success, fail, complete, mapOpts } = {}) => {
|
|
|
2065
2074
|
chooser.remove();
|
|
2066
2075
|
}, 300);
|
|
2067
2076
|
if (res) {
|
|
2068
|
-
return handle.fail(res, reject);
|
|
2077
|
+
return handle.fail(res, { resolve, reject });
|
|
2069
2078
|
}
|
|
2070
2079
|
else {
|
|
2071
2080
|
if (chooseLocation.latitude && chooseLocation.longitude) {
|
|
2072
|
-
return handle.success(chooseLocation, resolve);
|
|
2081
|
+
return handle.success(chooseLocation, { resolve, reject });
|
|
2073
2082
|
}
|
|
2074
2083
|
else {
|
|
2075
|
-
return handle.fail({}, reject);
|
|
2084
|
+
return handle.fail({}, { resolve, reject });
|
|
2076
2085
|
}
|
|
2077
2086
|
}
|
|
2078
2087
|
}, key, mapOpts);
|
|
@@ -2329,12 +2338,12 @@ const getImageInfo = (options) => {
|
|
|
2329
2338
|
width: image.naturalWidth,
|
|
2330
2339
|
height: image.naturalHeight,
|
|
2331
2340
|
path: getBase64Image(image) || src
|
|
2332
|
-
}, resolve);
|
|
2341
|
+
}, { resolve, reject });
|
|
2333
2342
|
};
|
|
2334
2343
|
image.onerror = (e) => {
|
|
2335
2344
|
handle.fail({
|
|
2336
2345
|
errMsg: e.message
|
|
2337
|
-
}, reject);
|
|
2346
|
+
}, { resolve, reject });
|
|
2338
2347
|
};
|
|
2339
2348
|
image.src = src;
|
|
2340
2349
|
});
|
|
@@ -2361,7 +2370,7 @@ const previewImage = (options) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
2361
2370
|
item.appendChild(div);
|
|
2362
2371
|
// Note: 等待图片加载完后返回,会导致轮播被卡住
|
|
2363
2372
|
resolve(item);
|
|
2364
|
-
if (
|
|
2373
|
+
if (isFunction(loadFail)) {
|
|
2365
2374
|
image.addEventListener('error', (err) => {
|
|
2366
2375
|
loadFail({ errMsg: err.message });
|
|
2367
2376
|
});
|
|
@@ -2466,7 +2475,7 @@ const chooseImage = function (options) {
|
|
|
2466
2475
|
el.removeAttribute('capture');
|
|
2467
2476
|
}
|
|
2468
2477
|
}
|
|
2469
|
-
return new Promise(resolve => {
|
|
2478
|
+
return new Promise((resolve, reject) => {
|
|
2470
2479
|
const TaroMouseEvents = document.createEvent('MouseEvents');
|
|
2471
2480
|
TaroMouseEvents.initEvent('click', true, true);
|
|
2472
2481
|
if (el) {
|
|
@@ -2485,7 +2494,7 @@ const chooseImage = function (options) {
|
|
|
2485
2494
|
(_a = res.tempFilePaths) === null || _a === void 0 ? void 0 : _a.push(url);
|
|
2486
2495
|
(_b = res.tempFiles) === null || _b === void 0 ? void 0 : _b.push({ path: url, size: item.size, type: item.type, originalFileObj: item });
|
|
2487
2496
|
});
|
|
2488
|
-
handle.success(res, resolve);
|
|
2497
|
+
handle.success(res, { resolve, reject });
|
|
2489
2498
|
target.value = '';
|
|
2490
2499
|
}
|
|
2491
2500
|
};
|
|
@@ -2553,7 +2562,7 @@ const chooseVideo = (options) => {
|
|
|
2553
2562
|
inputEl.setAttribute('accept', 'video/*');
|
|
2554
2563
|
inputEl.setAttribute('style', 'position: fixed; top: -4000px; left: -3000px; z-index: -300;');
|
|
2555
2564
|
document.body.appendChild(inputEl);
|
|
2556
|
-
return new Promise(resolve => {
|
|
2565
|
+
return new Promise((resolve, reject) => {
|
|
2557
2566
|
const TaroMouseEvents = document.createEvent('MouseEvents');
|
|
2558
2567
|
TaroMouseEvents.initEvent('click', true, true);
|
|
2559
2568
|
inputEl.dispatchEvent(TaroMouseEvents);
|
|
@@ -2574,7 +2583,7 @@ const chooseVideo = (options) => {
|
|
|
2574
2583
|
res.size = event.total;
|
|
2575
2584
|
res.height = videoEl.videoHeight;
|
|
2576
2585
|
res.width = videoEl.videoHeight;
|
|
2577
|
-
return handle.success(res, resolve);
|
|
2586
|
+
return handle.success(res, { resolve, reject });
|
|
2578
2587
|
};
|
|
2579
2588
|
};
|
|
2580
2589
|
if (file) {
|
|
@@ -2855,13 +2864,13 @@ function _request(options) {
|
|
|
2855
2864
|
.then(data => {
|
|
2856
2865
|
res.statusCode = 200;
|
|
2857
2866
|
res.data = data;
|
|
2858
|
-
|
|
2859
|
-
|
|
2867
|
+
isFunction(success) && success(res);
|
|
2868
|
+
isFunction(complete) && complete(res);
|
|
2860
2869
|
return res;
|
|
2861
2870
|
})
|
|
2862
2871
|
.catch(err => {
|
|
2863
|
-
|
|
2864
|
-
|
|
2872
|
+
isFunction(fail) && fail(err);
|
|
2873
|
+
isFunction(complete) && complete(res);
|
|
2865
2874
|
return Promise.reject(err);
|
|
2866
2875
|
});
|
|
2867
2876
|
}
|
|
@@ -2929,13 +2938,13 @@ function _request(options) {
|
|
|
2929
2938
|
})
|
|
2930
2939
|
.then(data => {
|
|
2931
2940
|
res.data = data;
|
|
2932
|
-
|
|
2933
|
-
|
|
2941
|
+
isFunction(success) && success(res);
|
|
2942
|
+
isFunction(complete) && complete(res);
|
|
2934
2943
|
return res;
|
|
2935
2944
|
})
|
|
2936
2945
|
.catch(err => {
|
|
2937
|
-
|
|
2938
|
-
|
|
2946
|
+
isFunction(fail) && fail(err);
|
|
2947
|
+
isFunction(complete) && complete(res);
|
|
2939
2948
|
err.statusCode = res.statusCode;
|
|
2940
2949
|
err.errMsg = err.message;
|
|
2941
2950
|
return Promise.reject(err);
|
|
@@ -3124,14 +3133,14 @@ class SocketTask {
|
|
|
3124
3133
|
if (this.readyState !== 1) {
|
|
3125
3134
|
const res = { errMsg: 'SocketTask.send:fail SocketTask.readState is not OPEN' };
|
|
3126
3135
|
console.error(res.errMsg);
|
|
3127
|
-
|
|
3128
|
-
|
|
3136
|
+
isFunction(fail) && fail(res);
|
|
3137
|
+
isFunction(complete) && complete(res);
|
|
3129
3138
|
return Promise.reject(res);
|
|
3130
3139
|
}
|
|
3131
3140
|
this.ws.send(data);
|
|
3132
3141
|
const res = { errMsg: 'sendSocketMessage:ok' };
|
|
3133
|
-
|
|
3134
|
-
|
|
3142
|
+
isFunction(success) && success(res);
|
|
3143
|
+
isFunction(complete) && complete(res);
|
|
3135
3144
|
return Promise.resolve(res);
|
|
3136
3145
|
}
|
|
3137
3146
|
close(opts = {}) {
|
|
@@ -3143,8 +3152,8 @@ class SocketTask {
|
|
|
3143
3152
|
this._destroyWhenClose && this._destroyWhenClose();
|
|
3144
3153
|
this.ws.close();
|
|
3145
3154
|
const res = { errMsg: 'closeSocket:ok' };
|
|
3146
|
-
|
|
3147
|
-
|
|
3155
|
+
isFunction(success) && success(res);
|
|
3156
|
+
isFunction(complete) && complete(res);
|
|
3148
3157
|
return Promise.resolve(res);
|
|
3149
3158
|
}
|
|
3150
3159
|
onOpen(func) {
|
|
@@ -3202,13 +3211,13 @@ function connectSocket(options) {
|
|
|
3202
3211
|
correct: 'String',
|
|
3203
3212
|
wrong: url
|
|
3204
3213
|
})
|
|
3205
|
-
}, reject);
|
|
3214
|
+
}, { resolve, reject });
|
|
3206
3215
|
}
|
|
3207
3216
|
// options.url must be invalid
|
|
3208
3217
|
if (!url.startsWith('ws://') && !url.startsWith('wss://')) {
|
|
3209
3218
|
return handle.fail({
|
|
3210
3219
|
errMsg: `request:fail invalid url "${url}"`
|
|
3211
|
-
}, reject);
|
|
3220
|
+
}, { resolve, reject });
|
|
3212
3221
|
}
|
|
3213
3222
|
// protocols must be array
|
|
3214
3223
|
const _protocols = Array.isArray(protocols) ? protocols : null;
|
|
@@ -3216,7 +3225,7 @@ function connectSocket(options) {
|
|
|
3216
3225
|
if (socketTasks.length > 1) {
|
|
3217
3226
|
return handle.fail({
|
|
3218
3227
|
errMsg: '同时最多发起 2 个 socket 请求,更多请参考文档。'
|
|
3219
|
-
}, reject);
|
|
3228
|
+
}, { resolve, reject });
|
|
3220
3229
|
}
|
|
3221
3230
|
const task = new SocketTask(url, _protocols);
|
|
3222
3231
|
task._destroyWhenClose = function () {
|
|
@@ -4570,8 +4579,8 @@ const startPullDownRefresh = function ({ success, fail, complete } = {}) {
|
|
|
4570
4579
|
const handle = new MethodHandler({ name: 'startPullDownRefresh', success, fail, complete });
|
|
4571
4580
|
return new Promise((resolve, reject) => {
|
|
4572
4581
|
Taro.eventCenter.trigger('__taroStartPullDownRefresh', {
|
|
4573
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4574
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4582
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4583
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4575
4584
|
});
|
|
4576
4585
|
});
|
|
4577
4586
|
};
|
|
@@ -4582,8 +4591,8 @@ const stopPullDownRefresh = function ({ success, fail, complete } = {}) {
|
|
|
4582
4591
|
const handle = new MethodHandler({ name: 'stopPullDownRefresh', success, fail, complete });
|
|
4583
4592
|
return new Promise((resolve, reject) => {
|
|
4584
4593
|
Taro.eventCenter.trigger('__taroStopPullDownRefresh', {
|
|
4585
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4586
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4594
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4595
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4587
4596
|
});
|
|
4588
4597
|
});
|
|
4589
4598
|
};
|
|
@@ -4602,7 +4611,7 @@ const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300,
|
|
|
4602
4611
|
if (scrollTop === undefined && !selector) {
|
|
4603
4612
|
return handle.fail({
|
|
4604
4613
|
errMsg: 'scrollTop" 或 "selector" 需要其之一'
|
|
4605
|
-
}, reject);
|
|
4614
|
+
}, { resolve, reject });
|
|
4606
4615
|
}
|
|
4607
4616
|
const id = (_b = (_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path) === null || _b === void 0 ? void 0 : _b.replace(/([^a-z0-9\u00a0-\uffff_-])/ig, '\\$1');
|
|
4608
4617
|
const el = (id
|
|
@@ -4656,7 +4665,7 @@ const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300,
|
|
|
4656
4665
|
}, FRAME_DURATION);
|
|
4657
4666
|
}
|
|
4658
4667
|
else {
|
|
4659
|
-
return handle.success({}, resolve);
|
|
4668
|
+
return handle.success({}, { resolve, reject });
|
|
4660
4669
|
}
|
|
4661
4670
|
};
|
|
4662
4671
|
scroll();
|
|
@@ -4664,7 +4673,7 @@ const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300,
|
|
|
4664
4673
|
catch (e) {
|
|
4665
4674
|
return handle.fail({
|
|
4666
4675
|
errMsg: e.message
|
|
4667
|
-
}, reject);
|
|
4676
|
+
}, { resolve, reject });
|
|
4668
4677
|
}
|
|
4669
4678
|
});
|
|
4670
4679
|
};
|
|
@@ -4701,8 +4710,8 @@ const showTabBarRedDot = (options) => {
|
|
|
4701
4710
|
return new Promise((resolve, reject) => {
|
|
4702
4711
|
Taro.eventCenter.trigger('__taroShowTabBarRedDotHandler', {
|
|
4703
4712
|
index,
|
|
4704
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4705
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4713
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4714
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4706
4715
|
});
|
|
4707
4716
|
});
|
|
4708
4717
|
};
|
|
@@ -4731,8 +4740,8 @@ const showTabBar = (options = {}) => {
|
|
|
4731
4740
|
return new Promise((resolve, reject) => {
|
|
4732
4741
|
Taro.eventCenter.trigger('__taroShowTabBar', {
|
|
4733
4742
|
animation,
|
|
4734
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4735
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4743
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4744
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4736
4745
|
});
|
|
4737
4746
|
});
|
|
4738
4747
|
};
|
|
@@ -4783,8 +4792,8 @@ const setTabBarStyle = (options = {}) => {
|
|
|
4783
4792
|
selectedColor,
|
|
4784
4793
|
backgroundColor,
|
|
4785
4794
|
borderStyle,
|
|
4786
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4787
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4795
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4796
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4788
4797
|
});
|
|
4789
4798
|
});
|
|
4790
4799
|
};
|
|
@@ -4816,8 +4825,8 @@ const setTabBarItem = (options) => {
|
|
|
4816
4825
|
text,
|
|
4817
4826
|
iconPath,
|
|
4818
4827
|
selectedIconPath,
|
|
4819
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4820
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4828
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4829
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4821
4830
|
});
|
|
4822
4831
|
});
|
|
4823
4832
|
};
|
|
@@ -4856,8 +4865,8 @@ const setTabBarBadge = (options) => {
|
|
|
4856
4865
|
Taro.eventCenter.trigger('__taroSetTabBarBadge', {
|
|
4857
4866
|
index,
|
|
4858
4867
|
text,
|
|
4859
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4860
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4868
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4869
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4861
4870
|
});
|
|
4862
4871
|
});
|
|
4863
4872
|
};
|
|
@@ -4886,8 +4895,8 @@ const removeTabBarBadge = (options) => {
|
|
|
4886
4895
|
return new Promise((resolve, reject) => {
|
|
4887
4896
|
Taro.eventCenter.trigger('__taroRemoveTabBarBadge', {
|
|
4888
4897
|
index,
|
|
4889
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4890
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4898
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4899
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4891
4900
|
});
|
|
4892
4901
|
});
|
|
4893
4902
|
};
|
|
@@ -4916,8 +4925,8 @@ const hideTabBarRedDot = (options) => {
|
|
|
4916
4925
|
return new Promise((resolve, reject) => {
|
|
4917
4926
|
Taro.eventCenter.trigger('__taroHideTabBarRedDotHandler', {
|
|
4918
4927
|
index,
|
|
4919
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4920
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4928
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4929
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4921
4930
|
});
|
|
4922
4931
|
});
|
|
4923
4932
|
};
|
|
@@ -4946,8 +4955,8 @@ const hideTabBar = (options = {}) => {
|
|
|
4946
4955
|
return new Promise((resolve, reject) => {
|
|
4947
4956
|
Taro.eventCenter.trigger('__taroHideTabBar', {
|
|
4948
4957
|
animation,
|
|
4949
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4950
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4958
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4959
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4951
4960
|
});
|
|
4952
4961
|
});
|
|
4953
4962
|
};
|
|
@@ -5115,7 +5124,7 @@ class MediaQueryObserver {
|
|
|
5115
5124
|
callback({ matches: ev.matches });
|
|
5116
5125
|
};
|
|
5117
5126
|
callback({ matches: this._mediaQueryObserver.matches });
|
|
5118
|
-
// 兼容旧浏览器中MediaQueryList尚未继承于EventTarget导致不存在'addEventListener'
|
|
5127
|
+
// 兼容旧浏览器中 MediaQueryList 尚未继承于 EventTarget 导致不存在 'addEventListener'
|
|
5119
5128
|
if ('addEventListener' in this._mediaQueryObserver) {
|
|
5120
5129
|
this._mediaQueryObserver.addEventListener('change', this._listener);
|
|
5121
5130
|
}
|
|
@@ -5127,7 +5136,7 @@ class MediaQueryObserver {
|
|
|
5127
5136
|
// 停止监听,销毁媒体查询对象
|
|
5128
5137
|
disconnect() {
|
|
5129
5138
|
if (this._mediaQueryObserver && this._listener) {
|
|
5130
|
-
// 兼容旧浏览器中MediaQueryList尚未继承于EventTarget导致不存在'removeEventListener'
|
|
5139
|
+
// 兼容旧浏览器中 MediaQueryList 尚未继承于 EventTarget 导致不存在 'removeEventListener'
|
|
5131
5140
|
if ('removeEventListener' in this._mediaQueryObserver) {
|
|
5132
5141
|
this._mediaQueryObserver.removeEventListener('change', this._listener);
|
|
5133
5142
|
}
|
|
@@ -5363,9 +5372,9 @@ class SelectorQuery {
|
|
|
5363
5372
|
const _queueCb = this._queueCb;
|
|
5364
5373
|
res.forEach((item, index) => {
|
|
5365
5374
|
const cb = _queueCb[index];
|
|
5366
|
-
|
|
5375
|
+
isFunction(cb) && cb.call(this, item);
|
|
5367
5376
|
});
|
|
5368
|
-
|
|
5377
|
+
isFunction(cb) && cb.call(this, res);
|
|
5369
5378
|
});
|
|
5370
5379
|
return this;
|
|
5371
5380
|
}
|
|
@@ -5418,7 +5427,7 @@ const requirePlugin = permanentlyNotSupport('requirePlugin');
|
|
|
5418
5427
|
const pxTransform = function (size) {
|
|
5419
5428
|
const options = taro.config;
|
|
5420
5429
|
const baseFontSize = options.baseFontSize || 20;
|
|
5421
|
-
const designWidth = ((input = 0) =>
|
|
5430
|
+
const designWidth = ((input = 0) => isFunction(options.designWidth)
|
|
5422
5431
|
? options.designWidth(input)
|
|
5423
5432
|
: options.designWidth);
|
|
5424
5433
|
const rootValue = (input = 0) => baseFontSize / options.deviceRatio[designWidth(input)] * 2;
|