@tarojs/taro-h5 3.5.11 → 3.6.0-alpha.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.
- 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 +84 -79
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.d.ts +2 -2
- package/dist/index.esm.js +83 -78
- 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 {
|
|
@@ -1486,7 +1491,7 @@ const setClipboardData = ({ data, success, fail, complete }) => __awaiter(void 0
|
|
|
1486
1491
|
* iOS < 10 的系统可能无法使用编程方式访问剪贴板,参考:
|
|
1487
1492
|
* https://stackoverflow.com/questions/34045777/copy-to-clipboard-using-javascript-in-ios/34046084
|
|
1488
1493
|
*/
|
|
1489
|
-
if (
|
|
1494
|
+
if (isFunction(document.execCommand)) {
|
|
1490
1495
|
const textarea = document.createElement('textarea');
|
|
1491
1496
|
textarea.readOnly = true;
|
|
1492
1497
|
textarea.value = data;
|
|
@@ -1946,9 +1951,9 @@ const getLocationByW3CApi = (options) => {
|
|
|
1946
1951
|
/** 调用结果,自动补充 */
|
|
1947
1952
|
errMsg: ''
|
|
1948
1953
|
};
|
|
1949
|
-
handle.success(result, resolve);
|
|
1954
|
+
handle.success(result, { resolve, reject });
|
|
1950
1955
|
}, (error) => {
|
|
1951
|
-
handle.fail({ errMsg: error.message }, reject);
|
|
1956
|
+
handle.fail({ errMsg: error.message }, { resolve, reject });
|
|
1952
1957
|
}, positionOptions);
|
|
1953
1958
|
});
|
|
1954
1959
|
};
|
|
@@ -2046,7 +2051,7 @@ const chooseLocation = ({ success, fail, complete, mapOpts } = {}) => {
|
|
|
2046
2051
|
console.warn('chooseLocation api 依赖腾讯地图定位api,需要在 defineConstants 中配置 LOCATION_APIKEY');
|
|
2047
2052
|
return handle.fail({
|
|
2048
2053
|
errMsg: 'LOCATION_APIKEY needed'
|
|
2049
|
-
}, reject);
|
|
2054
|
+
}, { resolve, reject });
|
|
2050
2055
|
}
|
|
2051
2056
|
const onMessage = event => {
|
|
2052
2057
|
// 接收位置信息,用户选择确认位置点后选点组件会触发该事件,回传用户的位置信息
|
|
@@ -2065,14 +2070,14 @@ const chooseLocation = ({ success, fail, complete, mapOpts } = {}) => {
|
|
|
2065
2070
|
chooser.remove();
|
|
2066
2071
|
}, 300);
|
|
2067
2072
|
if (res) {
|
|
2068
|
-
return handle.fail(res, reject);
|
|
2073
|
+
return handle.fail(res, { resolve, reject });
|
|
2069
2074
|
}
|
|
2070
2075
|
else {
|
|
2071
2076
|
if (chooseLocation.latitude && chooseLocation.longitude) {
|
|
2072
|
-
return handle.success(chooseLocation, resolve);
|
|
2077
|
+
return handle.success(chooseLocation, { resolve, reject });
|
|
2073
2078
|
}
|
|
2074
2079
|
else {
|
|
2075
|
-
return handle.fail({}, reject);
|
|
2080
|
+
return handle.fail({}, { resolve, reject });
|
|
2076
2081
|
}
|
|
2077
2082
|
}
|
|
2078
2083
|
}, key, mapOpts);
|
|
@@ -2329,12 +2334,12 @@ const getImageInfo = (options) => {
|
|
|
2329
2334
|
width: image.naturalWidth,
|
|
2330
2335
|
height: image.naturalHeight,
|
|
2331
2336
|
path: getBase64Image(image) || src
|
|
2332
|
-
}, resolve);
|
|
2337
|
+
}, { resolve, reject });
|
|
2333
2338
|
};
|
|
2334
2339
|
image.onerror = (e) => {
|
|
2335
2340
|
handle.fail({
|
|
2336
2341
|
errMsg: e.message
|
|
2337
|
-
}, reject);
|
|
2342
|
+
}, { resolve, reject });
|
|
2338
2343
|
};
|
|
2339
2344
|
image.src = src;
|
|
2340
2345
|
});
|
|
@@ -2361,7 +2366,7 @@ const previewImage = (options) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
2361
2366
|
item.appendChild(div);
|
|
2362
2367
|
// Note: 等待图片加载完后返回,会导致轮播被卡住
|
|
2363
2368
|
resolve(item);
|
|
2364
|
-
if (
|
|
2369
|
+
if (isFunction(loadFail)) {
|
|
2365
2370
|
image.addEventListener('error', (err) => {
|
|
2366
2371
|
loadFail({ errMsg: err.message });
|
|
2367
2372
|
});
|
|
@@ -2466,7 +2471,7 @@ const chooseImage = function (options) {
|
|
|
2466
2471
|
el.removeAttribute('capture');
|
|
2467
2472
|
}
|
|
2468
2473
|
}
|
|
2469
|
-
return new Promise(resolve => {
|
|
2474
|
+
return new Promise((resolve, reject) => {
|
|
2470
2475
|
const TaroMouseEvents = document.createEvent('MouseEvents');
|
|
2471
2476
|
TaroMouseEvents.initEvent('click', true, true);
|
|
2472
2477
|
if (el) {
|
|
@@ -2485,7 +2490,7 @@ const chooseImage = function (options) {
|
|
|
2485
2490
|
(_a = res.tempFilePaths) === null || _a === void 0 ? void 0 : _a.push(url);
|
|
2486
2491
|
(_b = res.tempFiles) === null || _b === void 0 ? void 0 : _b.push({ path: url, size: item.size, type: item.type, originalFileObj: item });
|
|
2487
2492
|
});
|
|
2488
|
-
handle.success(res, resolve);
|
|
2493
|
+
handle.success(res, { resolve, reject });
|
|
2489
2494
|
target.value = '';
|
|
2490
2495
|
}
|
|
2491
2496
|
};
|
|
@@ -2553,7 +2558,7 @@ const chooseVideo = (options) => {
|
|
|
2553
2558
|
inputEl.setAttribute('accept', 'video/*');
|
|
2554
2559
|
inputEl.setAttribute('style', 'position: fixed; top: -4000px; left: -3000px; z-index: -300;');
|
|
2555
2560
|
document.body.appendChild(inputEl);
|
|
2556
|
-
return new Promise(resolve => {
|
|
2561
|
+
return new Promise((resolve, reject) => {
|
|
2557
2562
|
const TaroMouseEvents = document.createEvent('MouseEvents');
|
|
2558
2563
|
TaroMouseEvents.initEvent('click', true, true);
|
|
2559
2564
|
inputEl.dispatchEvent(TaroMouseEvents);
|
|
@@ -2574,7 +2579,7 @@ const chooseVideo = (options) => {
|
|
|
2574
2579
|
res.size = event.total;
|
|
2575
2580
|
res.height = videoEl.videoHeight;
|
|
2576
2581
|
res.width = videoEl.videoHeight;
|
|
2577
|
-
return handle.success(res, resolve);
|
|
2582
|
+
return handle.success(res, { resolve, reject });
|
|
2578
2583
|
};
|
|
2579
2584
|
};
|
|
2580
2585
|
if (file) {
|
|
@@ -2855,13 +2860,13 @@ function _request(options) {
|
|
|
2855
2860
|
.then(data => {
|
|
2856
2861
|
res.statusCode = 200;
|
|
2857
2862
|
res.data = data;
|
|
2858
|
-
|
|
2859
|
-
|
|
2863
|
+
isFunction(success) && success(res);
|
|
2864
|
+
isFunction(complete) && complete(res);
|
|
2860
2865
|
return res;
|
|
2861
2866
|
})
|
|
2862
2867
|
.catch(err => {
|
|
2863
|
-
|
|
2864
|
-
|
|
2868
|
+
isFunction(fail) && fail(err);
|
|
2869
|
+
isFunction(complete) && complete(res);
|
|
2865
2870
|
return Promise.reject(err);
|
|
2866
2871
|
});
|
|
2867
2872
|
}
|
|
@@ -2929,13 +2934,13 @@ function _request(options) {
|
|
|
2929
2934
|
})
|
|
2930
2935
|
.then(data => {
|
|
2931
2936
|
res.data = data;
|
|
2932
|
-
|
|
2933
|
-
|
|
2937
|
+
isFunction(success) && success(res);
|
|
2938
|
+
isFunction(complete) && complete(res);
|
|
2934
2939
|
return res;
|
|
2935
2940
|
})
|
|
2936
2941
|
.catch(err => {
|
|
2937
|
-
|
|
2938
|
-
|
|
2942
|
+
isFunction(fail) && fail(err);
|
|
2943
|
+
isFunction(complete) && complete(res);
|
|
2939
2944
|
err.statusCode = res.statusCode;
|
|
2940
2945
|
err.errMsg = err.message;
|
|
2941
2946
|
return Promise.reject(err);
|
|
@@ -3124,14 +3129,14 @@ class SocketTask {
|
|
|
3124
3129
|
if (this.readyState !== 1) {
|
|
3125
3130
|
const res = { errMsg: 'SocketTask.send:fail SocketTask.readState is not OPEN' };
|
|
3126
3131
|
console.error(res.errMsg);
|
|
3127
|
-
|
|
3128
|
-
|
|
3132
|
+
isFunction(fail) && fail(res);
|
|
3133
|
+
isFunction(complete) && complete(res);
|
|
3129
3134
|
return Promise.reject(res);
|
|
3130
3135
|
}
|
|
3131
3136
|
this.ws.send(data);
|
|
3132
3137
|
const res = { errMsg: 'sendSocketMessage:ok' };
|
|
3133
|
-
|
|
3134
|
-
|
|
3138
|
+
isFunction(success) && success(res);
|
|
3139
|
+
isFunction(complete) && complete(res);
|
|
3135
3140
|
return Promise.resolve(res);
|
|
3136
3141
|
}
|
|
3137
3142
|
close(opts = {}) {
|
|
@@ -3143,8 +3148,8 @@ class SocketTask {
|
|
|
3143
3148
|
this._destroyWhenClose && this._destroyWhenClose();
|
|
3144
3149
|
this.ws.close();
|
|
3145
3150
|
const res = { errMsg: 'closeSocket:ok' };
|
|
3146
|
-
|
|
3147
|
-
|
|
3151
|
+
isFunction(success) && success(res);
|
|
3152
|
+
isFunction(complete) && complete(res);
|
|
3148
3153
|
return Promise.resolve(res);
|
|
3149
3154
|
}
|
|
3150
3155
|
onOpen(func) {
|
|
@@ -3202,13 +3207,13 @@ function connectSocket(options) {
|
|
|
3202
3207
|
correct: 'String',
|
|
3203
3208
|
wrong: url
|
|
3204
3209
|
})
|
|
3205
|
-
}, reject);
|
|
3210
|
+
}, { resolve, reject });
|
|
3206
3211
|
}
|
|
3207
3212
|
// options.url must be invalid
|
|
3208
3213
|
if (!url.startsWith('ws://') && !url.startsWith('wss://')) {
|
|
3209
3214
|
return handle.fail({
|
|
3210
3215
|
errMsg: `request:fail invalid url "${url}"`
|
|
3211
|
-
}, reject);
|
|
3216
|
+
}, { resolve, reject });
|
|
3212
3217
|
}
|
|
3213
3218
|
// protocols must be array
|
|
3214
3219
|
const _protocols = Array.isArray(protocols) ? protocols : null;
|
|
@@ -3216,7 +3221,7 @@ function connectSocket(options) {
|
|
|
3216
3221
|
if (socketTasks.length > 1) {
|
|
3217
3222
|
return handle.fail({
|
|
3218
3223
|
errMsg: '同时最多发起 2 个 socket 请求,更多请参考文档。'
|
|
3219
|
-
}, reject);
|
|
3224
|
+
}, { resolve, reject });
|
|
3220
3225
|
}
|
|
3221
3226
|
const task = new SocketTask(url, _protocols);
|
|
3222
3227
|
task._destroyWhenClose = function () {
|
|
@@ -4570,8 +4575,8 @@ const startPullDownRefresh = function ({ success, fail, complete } = {}) {
|
|
|
4570
4575
|
const handle = new MethodHandler({ name: 'startPullDownRefresh', success, fail, complete });
|
|
4571
4576
|
return new Promise((resolve, reject) => {
|
|
4572
4577
|
Taro.eventCenter.trigger('__taroStartPullDownRefresh', {
|
|
4573
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4574
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4578
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4579
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4575
4580
|
});
|
|
4576
4581
|
});
|
|
4577
4582
|
};
|
|
@@ -4582,8 +4587,8 @@ const stopPullDownRefresh = function ({ success, fail, complete } = {}) {
|
|
|
4582
4587
|
const handle = new MethodHandler({ name: 'stopPullDownRefresh', success, fail, complete });
|
|
4583
4588
|
return new Promise((resolve, reject) => {
|
|
4584
4589
|
Taro.eventCenter.trigger('__taroStopPullDownRefresh', {
|
|
4585
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4586
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4590
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4591
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4587
4592
|
});
|
|
4588
4593
|
});
|
|
4589
4594
|
};
|
|
@@ -4602,7 +4607,7 @@ const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300,
|
|
|
4602
4607
|
if (scrollTop === undefined && !selector) {
|
|
4603
4608
|
return handle.fail({
|
|
4604
4609
|
errMsg: 'scrollTop" 或 "selector" 需要其之一'
|
|
4605
|
-
}, reject);
|
|
4610
|
+
}, { resolve, reject });
|
|
4606
4611
|
}
|
|
4607
4612
|
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
4613
|
const el = (id
|
|
@@ -4656,7 +4661,7 @@ const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300,
|
|
|
4656
4661
|
}, FRAME_DURATION);
|
|
4657
4662
|
}
|
|
4658
4663
|
else {
|
|
4659
|
-
return handle.success({}, resolve);
|
|
4664
|
+
return handle.success({}, { resolve, reject });
|
|
4660
4665
|
}
|
|
4661
4666
|
};
|
|
4662
4667
|
scroll();
|
|
@@ -4664,7 +4669,7 @@ const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300,
|
|
|
4664
4669
|
catch (e) {
|
|
4665
4670
|
return handle.fail({
|
|
4666
4671
|
errMsg: e.message
|
|
4667
|
-
}, reject);
|
|
4672
|
+
}, { resolve, reject });
|
|
4668
4673
|
}
|
|
4669
4674
|
});
|
|
4670
4675
|
};
|
|
@@ -4701,8 +4706,8 @@ const showTabBarRedDot = (options) => {
|
|
|
4701
4706
|
return new Promise((resolve, reject) => {
|
|
4702
4707
|
Taro.eventCenter.trigger('__taroShowTabBarRedDotHandler', {
|
|
4703
4708
|
index,
|
|
4704
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4705
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4709
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4710
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4706
4711
|
});
|
|
4707
4712
|
});
|
|
4708
4713
|
};
|
|
@@ -4731,8 +4736,8 @@ const showTabBar = (options = {}) => {
|
|
|
4731
4736
|
return new Promise((resolve, reject) => {
|
|
4732
4737
|
Taro.eventCenter.trigger('__taroShowTabBar', {
|
|
4733
4738
|
animation,
|
|
4734
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4735
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4739
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4740
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4736
4741
|
});
|
|
4737
4742
|
});
|
|
4738
4743
|
};
|
|
@@ -4783,8 +4788,8 @@ const setTabBarStyle = (options = {}) => {
|
|
|
4783
4788
|
selectedColor,
|
|
4784
4789
|
backgroundColor,
|
|
4785
4790
|
borderStyle,
|
|
4786
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4787
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4791
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4792
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4788
4793
|
});
|
|
4789
4794
|
});
|
|
4790
4795
|
};
|
|
@@ -4816,8 +4821,8 @@ const setTabBarItem = (options) => {
|
|
|
4816
4821
|
text,
|
|
4817
4822
|
iconPath,
|
|
4818
4823
|
selectedIconPath,
|
|
4819
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4820
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4824
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4825
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4821
4826
|
});
|
|
4822
4827
|
});
|
|
4823
4828
|
};
|
|
@@ -4856,8 +4861,8 @@ const setTabBarBadge = (options) => {
|
|
|
4856
4861
|
Taro.eventCenter.trigger('__taroSetTabBarBadge', {
|
|
4857
4862
|
index,
|
|
4858
4863
|
text,
|
|
4859
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4860
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4864
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4865
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4861
4866
|
});
|
|
4862
4867
|
});
|
|
4863
4868
|
};
|
|
@@ -4886,8 +4891,8 @@ const removeTabBarBadge = (options) => {
|
|
|
4886
4891
|
return new Promise((resolve, reject) => {
|
|
4887
4892
|
Taro.eventCenter.trigger('__taroRemoveTabBarBadge', {
|
|
4888
4893
|
index,
|
|
4889
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4890
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4894
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4895
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4891
4896
|
});
|
|
4892
4897
|
});
|
|
4893
4898
|
};
|
|
@@ -4916,8 +4921,8 @@ const hideTabBarRedDot = (options) => {
|
|
|
4916
4921
|
return new Promise((resolve, reject) => {
|
|
4917
4922
|
Taro.eventCenter.trigger('__taroHideTabBarRedDotHandler', {
|
|
4918
4923
|
index,
|
|
4919
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4920
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4924
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4925
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4921
4926
|
});
|
|
4922
4927
|
});
|
|
4923
4928
|
};
|
|
@@ -4946,8 +4951,8 @@ const hideTabBar = (options = {}) => {
|
|
|
4946
4951
|
return new Promise((resolve, reject) => {
|
|
4947
4952
|
Taro.eventCenter.trigger('__taroHideTabBar', {
|
|
4948
4953
|
animation,
|
|
4949
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4950
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4954
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4955
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4951
4956
|
});
|
|
4952
4957
|
});
|
|
4953
4958
|
};
|
|
@@ -5115,7 +5120,7 @@ class MediaQueryObserver {
|
|
|
5115
5120
|
callback({ matches: ev.matches });
|
|
5116
5121
|
};
|
|
5117
5122
|
callback({ matches: this._mediaQueryObserver.matches });
|
|
5118
|
-
// 兼容旧浏览器中MediaQueryList尚未继承于EventTarget导致不存在'addEventListener'
|
|
5123
|
+
// 兼容旧浏览器中 MediaQueryList 尚未继承于 EventTarget 导致不存在 'addEventListener'
|
|
5119
5124
|
if ('addEventListener' in this._mediaQueryObserver) {
|
|
5120
5125
|
this._mediaQueryObserver.addEventListener('change', this._listener);
|
|
5121
5126
|
}
|
|
@@ -5127,7 +5132,7 @@ class MediaQueryObserver {
|
|
|
5127
5132
|
// 停止监听,销毁媒体查询对象
|
|
5128
5133
|
disconnect() {
|
|
5129
5134
|
if (this._mediaQueryObserver && this._listener) {
|
|
5130
|
-
// 兼容旧浏览器中MediaQueryList尚未继承于EventTarget导致不存在'removeEventListener'
|
|
5135
|
+
// 兼容旧浏览器中 MediaQueryList 尚未继承于 EventTarget 导致不存在 'removeEventListener'
|
|
5131
5136
|
if ('removeEventListener' in this._mediaQueryObserver) {
|
|
5132
5137
|
this._mediaQueryObserver.removeEventListener('change', this._listener);
|
|
5133
5138
|
}
|
|
@@ -5363,9 +5368,9 @@ class SelectorQuery {
|
|
|
5363
5368
|
const _queueCb = this._queueCb;
|
|
5364
5369
|
res.forEach((item, index) => {
|
|
5365
5370
|
const cb = _queueCb[index];
|
|
5366
|
-
|
|
5371
|
+
isFunction(cb) && cb.call(this, item);
|
|
5367
5372
|
});
|
|
5368
|
-
|
|
5373
|
+
isFunction(cb) && cb.call(this, res);
|
|
5369
5374
|
});
|
|
5370
5375
|
return this;
|
|
5371
5376
|
}
|
|
@@ -5418,7 +5423,7 @@ const requirePlugin = permanentlyNotSupport('requirePlugin');
|
|
|
5418
5423
|
const pxTransform = function (size) {
|
|
5419
5424
|
const options = taro.config;
|
|
5420
5425
|
const baseFontSize = options.baseFontSize || 20;
|
|
5421
|
-
const designWidth = ((input = 0) =>
|
|
5426
|
+
const designWidth = ((input = 0) => isFunction(options.designWidth)
|
|
5422
5427
|
? options.designWidth(input)
|
|
5423
5428
|
: options.designWidth);
|
|
5424
5429
|
const rootValue = (input = 0) => baseFontSize / options.deviceRatio[designWidth(input)] * 2;
|