@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/api/base/system.js
CHANGED
|
@@ -62,6 +62,8 @@ export const getDeviceInfo = () => {
|
|
|
62
62
|
const info = {
|
|
63
63
|
/** 应用二进制接口类型(仅 Android 支持) */
|
|
64
64
|
abi: '',
|
|
65
|
+
/** 设备二进制接口类型(仅 Android 支持) */
|
|
66
|
+
deviceAbi: '',
|
|
65
67
|
/** 设备性能等级(仅Android小游戏)。取值为:-2 或 0(该设备无法运行小游戏),-1(性能未知),>=1(设备性能值,该值越高,设备性能越好,目前最高不到50) */
|
|
66
68
|
benchmarkLevel: -1,
|
|
67
69
|
/** 设备品牌 */
|
|
@@ -71,7 +73,9 @@ export const getDeviceInfo = () => {
|
|
|
71
73
|
/** 操作系统及版本 */
|
|
72
74
|
system: md.os(),
|
|
73
75
|
/** 客户端平台 */
|
|
74
|
-
platform: navigator.platform
|
|
76
|
+
platform: navigator.platform,
|
|
77
|
+
/** 设备二进制接口类型(仅 Android 支持) */
|
|
78
|
+
CPUType: '',
|
|
75
79
|
};
|
|
76
80
|
return info;
|
|
77
81
|
};
|
|
@@ -13,6 +13,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
|
+
import { isFunction } from '@tarojs/shared';
|
|
16
17
|
import { MethodHandler } from '../../utils/handler';
|
|
17
18
|
import { getStorageSync, setStorage, setStorageSync } from '../storage/index';
|
|
18
19
|
const CLIPBOARD_STORAGE_NAME = 'taro_clipboard';
|
|
@@ -37,7 +38,7 @@ export const setClipboardData = ({ data, success, fail, complete }) => __awaiter
|
|
|
37
38
|
* iOS < 10 的系统可能无法使用编程方式访问剪贴板,参考:
|
|
38
39
|
* https://stackoverflow.com/questions/34045777/copy-to-clipboard-using-javascript-in-ios/34046084
|
|
39
40
|
*/
|
|
40
|
-
if (
|
|
41
|
+
if (isFunction(document.execCommand)) {
|
|
41
42
|
const textarea = document.createElement('textarea');
|
|
42
43
|
textarea.readOnly = true;
|
|
43
44
|
textarea.value = data;
|
|
@@ -70,7 +70,7 @@ export const chooseLocation = ({ success, fail, complete, mapOpts } = {}) => {
|
|
|
70
70
|
console.warn('chooseLocation api 依赖腾讯地图定位api,需要在 defineConstants 中配置 LOCATION_APIKEY');
|
|
71
71
|
return handle.fail({
|
|
72
72
|
errMsg: 'LOCATION_APIKEY needed'
|
|
73
|
-
}, reject);
|
|
73
|
+
}, { resolve, reject });
|
|
74
74
|
}
|
|
75
75
|
const onMessage = event => {
|
|
76
76
|
// 接收位置信息,用户选择确认位置点后选点组件会触发该事件,回传用户的位置信息
|
|
@@ -89,14 +89,14 @@ export const chooseLocation = ({ success, fail, complete, mapOpts } = {}) => {
|
|
|
89
89
|
chooser.remove();
|
|
90
90
|
}, 300);
|
|
91
91
|
if (res) {
|
|
92
|
-
return handle.fail(res, reject);
|
|
92
|
+
return handle.fail(res, { resolve, reject });
|
|
93
93
|
}
|
|
94
94
|
else {
|
|
95
95
|
if (chooseLocation.latitude && chooseLocation.longitude) {
|
|
96
|
-
return handle.success(chooseLocation, resolve);
|
|
96
|
+
return handle.success(chooseLocation, { resolve, reject });
|
|
97
97
|
}
|
|
98
98
|
else {
|
|
99
|
-
return handle.fail({}, reject);
|
|
99
|
+
return handle.fail({}, { resolve, reject });
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
}, key, mapOpts);
|
|
@@ -52,9 +52,9 @@ const getLocationByW3CApi = (options) => {
|
|
|
52
52
|
/** 调用结果,自动补充 */
|
|
53
53
|
errMsg: ''
|
|
54
54
|
};
|
|
55
|
-
handle.success(result, resolve);
|
|
55
|
+
handle.success(result, { resolve, reject });
|
|
56
56
|
}, (error) => {
|
|
57
|
-
handle.fail({ errMsg: error.message }, reject);
|
|
57
|
+
handle.fail({ errMsg: error.message }, { resolve, reject });
|
|
58
58
|
}, positionOptions);
|
|
59
59
|
});
|
|
60
60
|
};
|
|
@@ -57,7 +57,7 @@ export const chooseImage = function (options) {
|
|
|
57
57
|
el.removeAttribute('capture');
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
return new Promise(resolve => {
|
|
60
|
+
return new Promise((resolve, reject) => {
|
|
61
61
|
const TaroMouseEvents = document.createEvent('MouseEvents');
|
|
62
62
|
TaroMouseEvents.initEvent('click', true, true);
|
|
63
63
|
if (el) {
|
|
@@ -76,7 +76,7 @@ export const chooseImage = function (options) {
|
|
|
76
76
|
(_a = res.tempFilePaths) === null || _a === void 0 ? void 0 : _a.push(url);
|
|
77
77
|
(_b = res.tempFiles) === null || _b === void 0 ? void 0 : _b.push({ path: url, size: item.size, type: item.type, originalFileObj: item });
|
|
78
78
|
});
|
|
79
|
-
handle.success(res, resolve);
|
|
79
|
+
handle.success(res, { resolve, reject });
|
|
80
80
|
target.value = '';
|
|
81
81
|
}
|
|
82
82
|
};
|
|
@@ -34,12 +34,12 @@ export const getImageInfo = (options) => {
|
|
|
34
34
|
width: image.naturalWidth,
|
|
35
35
|
height: image.naturalHeight,
|
|
36
36
|
path: getBase64Image(image) || src
|
|
37
|
-
}, resolve);
|
|
37
|
+
}, { resolve, reject });
|
|
38
38
|
};
|
|
39
39
|
image.onerror = (e) => {
|
|
40
40
|
handle.fail({
|
|
41
41
|
errMsg: e.message
|
|
42
|
-
}, reject);
|
|
42
|
+
}, { resolve, reject });
|
|
43
43
|
};
|
|
44
44
|
image.src = src;
|
|
45
45
|
});
|
|
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import { isFunction } from '@tarojs/shared';
|
|
10
11
|
import { shouldBeObject } from '../../../utils';
|
|
11
12
|
import { MethodHandler } from '../../../utils/handler';
|
|
12
13
|
/**
|
|
@@ -30,7 +31,7 @@ export const previewImage = (options) => __awaiter(void 0, void 0, void 0, funct
|
|
|
30
31
|
item.appendChild(div);
|
|
31
32
|
// Note: 等待图片加载完后返回,会导致轮播被卡住
|
|
32
33
|
resolve(item);
|
|
33
|
-
if (
|
|
34
|
+
if (isFunction(loadFail)) {
|
|
34
35
|
image.addEventListener('error', (err) => {
|
|
35
36
|
loadFail({ errMsg: err.message });
|
|
36
37
|
});
|
|
@@ -39,7 +39,7 @@ export const chooseVideo = (options) => {
|
|
|
39
39
|
inputEl.setAttribute('accept', 'video/*');
|
|
40
40
|
inputEl.setAttribute('style', 'position: fixed; top: -4000px; left: -3000px; z-index: -300;');
|
|
41
41
|
document.body.appendChild(inputEl);
|
|
42
|
-
return new Promise(resolve => {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
43
|
const TaroMouseEvents = document.createEvent('MouseEvents');
|
|
44
44
|
TaroMouseEvents.initEvent('click', true, true);
|
|
45
45
|
inputEl.dispatchEvent(TaroMouseEvents);
|
|
@@ -60,7 +60,7 @@ export const chooseVideo = (options) => {
|
|
|
60
60
|
res.size = event.total;
|
|
61
61
|
res.height = videoEl.videoHeight;
|
|
62
62
|
res.width = videoEl.videoHeight;
|
|
63
|
-
return handle.success(res, resolve);
|
|
63
|
+
return handle.success(res, { resolve, reject });
|
|
64
64
|
};
|
|
65
65
|
};
|
|
66
66
|
if (file) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import 'whatwg-fetch';
|
|
2
2
|
import Taro from '@tarojs/api';
|
|
3
|
+
import { isFunction } from '@tarojs/shared';
|
|
3
4
|
import jsonpRetry from 'jsonp-retry';
|
|
4
5
|
import { serializeParams } from '../../../utils';
|
|
5
6
|
// @ts-ignore
|
|
@@ -36,13 +37,13 @@ function _request(options) {
|
|
|
36
37
|
.then(data => {
|
|
37
38
|
res.statusCode = 200;
|
|
38
39
|
res.data = data;
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
isFunction(success) && success(res);
|
|
41
|
+
isFunction(complete) && complete(res);
|
|
41
42
|
return res;
|
|
42
43
|
})
|
|
43
44
|
.catch(err => {
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
isFunction(fail) && fail(err);
|
|
46
|
+
isFunction(complete) && complete(res);
|
|
46
47
|
return Promise.reject(err);
|
|
47
48
|
});
|
|
48
49
|
}
|
|
@@ -110,13 +111,13 @@ function _request(options) {
|
|
|
110
111
|
})
|
|
111
112
|
.then(data => {
|
|
112
113
|
res.data = data;
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
isFunction(success) && success(res);
|
|
115
|
+
isFunction(complete) && complete(res);
|
|
115
116
|
return res;
|
|
116
117
|
})
|
|
117
118
|
.catch(err => {
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
isFunction(fail) && fail(err);
|
|
120
|
+
isFunction(complete) && complete(res);
|
|
120
121
|
err.statusCode = res.statusCode;
|
|
121
122
|
err.errMsg = err.message;
|
|
122
123
|
return Promise.reject(err);
|
|
@@ -3,5 +3,5 @@ export declare function onSocketOpen(): void;
|
|
|
3
3
|
export declare function onSocketMessage(): void;
|
|
4
4
|
export declare function onSocketError(): void;
|
|
5
5
|
export declare function onSocketClose(): void;
|
|
6
|
-
export declare function connectSocket(options
|
|
6
|
+
export declare function connectSocket(options?: Taro.connectSocket.Option): Promise<unknown>;
|
|
7
7
|
export declare function closeSocket(): void;
|
|
@@ -38,13 +38,13 @@ export function connectSocket(options) {
|
|
|
38
38
|
correct: 'String',
|
|
39
39
|
wrong: url
|
|
40
40
|
})
|
|
41
|
-
}, reject);
|
|
41
|
+
}, { resolve, reject });
|
|
42
42
|
}
|
|
43
43
|
// options.url must be invalid
|
|
44
44
|
if (!url.startsWith('ws://') && !url.startsWith('wss://')) {
|
|
45
45
|
return handle.fail({
|
|
46
46
|
errMsg: `request:fail invalid url "${url}"`
|
|
47
|
-
}, reject);
|
|
47
|
+
}, { resolve, reject });
|
|
48
48
|
}
|
|
49
49
|
// protocols must be array
|
|
50
50
|
const _protocols = Array.isArray(protocols) ? protocols : null;
|
|
@@ -52,7 +52,7 @@ export function connectSocket(options) {
|
|
|
52
52
|
if (socketTasks.length > 1) {
|
|
53
53
|
return handle.fail({
|
|
54
54
|
errMsg: '同时最多发起 2 个 socket 请求,更多请参考文档。'
|
|
55
|
-
}, reject);
|
|
55
|
+
}, { resolve, reject });
|
|
56
56
|
}
|
|
57
57
|
const task = new SocketTask(url, _protocols);
|
|
58
58
|
task._destroyWhenClose = function () {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isFunction } from '@tarojs/shared';
|
|
1
2
|
export class SocketTask {
|
|
2
3
|
constructor(url, protocols) {
|
|
3
4
|
if (protocols && protocols.length) {
|
|
@@ -21,14 +22,14 @@ export class SocketTask {
|
|
|
21
22
|
if (this.readyState !== 1) {
|
|
22
23
|
const res = { errMsg: 'SocketTask.send:fail SocketTask.readState is not OPEN' };
|
|
23
24
|
console.error(res.errMsg);
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
isFunction(fail) && fail(res);
|
|
26
|
+
isFunction(complete) && complete(res);
|
|
26
27
|
return Promise.reject(res);
|
|
27
28
|
}
|
|
28
29
|
this.ws.send(data);
|
|
29
30
|
const res = { errMsg: 'sendSocketMessage:ok' };
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
isFunction(success) && success(res);
|
|
32
|
+
isFunction(complete) && complete(res);
|
|
32
33
|
return Promise.resolve(res);
|
|
33
34
|
}
|
|
34
35
|
close(opts = {}) {
|
|
@@ -40,8 +41,8 @@ export class SocketTask {
|
|
|
40
41
|
this._destroyWhenClose && this._destroyWhenClose();
|
|
41
42
|
this.ws.close();
|
|
42
43
|
const res = { errMsg: 'closeSocket:ok' };
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
isFunction(success) && success(res);
|
|
45
|
+
isFunction(complete) && complete(res);
|
|
45
46
|
return Promise.resolve(res);
|
|
46
47
|
}
|
|
47
48
|
onOpen(func) {
|
package/dist/api/taro.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Taro from '@tarojs/api';
|
|
2
2
|
import { history } from '@tarojs/router';
|
|
3
|
+
import { isFunction } from '@tarojs/shared';
|
|
3
4
|
import { getApp, getCurrentInstance, getCurrentPages, navigateBack, navigateTo, nextTick, redirectTo, reLaunch, switchTab } from '../api';
|
|
4
5
|
import { permanentlyNotSupport } from '../utils';
|
|
5
6
|
const { Behavior, getEnv, ENV_TYPE, Link, interceptors, getInitPxTransform, Current, options, eventCenter, Events, preload } = Taro;
|
|
@@ -30,7 +31,7 @@ const requirePlugin = permanentlyNotSupport('requirePlugin');
|
|
|
30
31
|
const pxTransform = function (size) {
|
|
31
32
|
const options = taro.config;
|
|
32
33
|
const baseFontSize = options.baseFontSize || 20;
|
|
33
|
-
const designWidth = ((input = 0) =>
|
|
34
|
+
const designWidth = ((input = 0) => isFunction(options.designWidth)
|
|
34
35
|
? options.designWidth(input)
|
|
35
36
|
: options.designWidth);
|
|
36
37
|
const rootValue = (input = 0) => baseFontSize / options.deviceRatio[designWidth(input)] * 2;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Taro from '@tarojs/api';
|
|
2
2
|
export declare const showNavigationBarLoading: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
3
|
-
export declare function setNavigationBarTitle(options
|
|
3
|
+
export declare function setNavigationBarTitle(options?: Taro.setNavigationBarTitle.Option): Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
4
4
|
/**
|
|
5
5
|
* 设置页面导航条颜色
|
|
6
6
|
*/
|
|
@@ -7,8 +7,8 @@ export const startPullDownRefresh = function ({ success, fail, complete } = {})
|
|
|
7
7
|
const handle = new MethodHandler({ name: 'startPullDownRefresh', success, fail, complete });
|
|
8
8
|
return new Promise((resolve, reject) => {
|
|
9
9
|
Taro.eventCenter.trigger('__taroStartPullDownRefresh', {
|
|
10
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
11
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
10
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
11
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
12
12
|
});
|
|
13
13
|
});
|
|
14
14
|
};
|
|
@@ -19,8 +19,8 @@ export const stopPullDownRefresh = function ({ success, fail, complete } = {}) {
|
|
|
19
19
|
const handle = new MethodHandler({ name: 'stopPullDownRefresh', success, fail, complete });
|
|
20
20
|
return new Promise((resolve, reject) => {
|
|
21
21
|
Taro.eventCenter.trigger('__taroStopPullDownRefresh', {
|
|
22
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
23
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
22
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
23
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
26
|
};
|
|
@@ -15,7 +15,7 @@ export const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration
|
|
|
15
15
|
if (scrollTop === undefined && !selector) {
|
|
16
16
|
return handle.fail({
|
|
17
17
|
errMsg: 'scrollTop" 或 "selector" 需要其之一'
|
|
18
|
-
}, reject);
|
|
18
|
+
}, { resolve, reject });
|
|
19
19
|
}
|
|
20
20
|
const id = (_b = (_a = Current.page) === null || _a === void 0 ? void 0 : _a.path) === null || _b === void 0 ? void 0 : _b.replace(/([^a-z0-9\u00a0-\uffff_-])/ig, '\\$1');
|
|
21
21
|
const el = (id
|
|
@@ -69,7 +69,7 @@ export const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration
|
|
|
69
69
|
}, FRAME_DURATION);
|
|
70
70
|
}
|
|
71
71
|
else {
|
|
72
|
-
return handle.success({}, resolve);
|
|
72
|
+
return handle.success({}, { resolve, reject });
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
75
|
scroll();
|
|
@@ -77,7 +77,7 @@ export const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration
|
|
|
77
77
|
catch (e) {
|
|
78
78
|
return handle.fail({
|
|
79
79
|
errMsg: e.message
|
|
80
|
-
}, reject);
|
|
80
|
+
}, { resolve, reject });
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
};
|
package/dist/api/ui/tab-bar.js
CHANGED
|
@@ -30,8 +30,8 @@ export const showTabBarRedDot = (options) => {
|
|
|
30
30
|
return new Promise((resolve, reject) => {
|
|
31
31
|
Taro.eventCenter.trigger('__taroShowTabBarRedDotHandler', {
|
|
32
32
|
index,
|
|
33
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
34
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
33
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
34
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
37
|
};
|
|
@@ -60,8 +60,8 @@ export const showTabBar = (options = {}) => {
|
|
|
60
60
|
return new Promise((resolve, reject) => {
|
|
61
61
|
Taro.eventCenter.trigger('__taroShowTabBar', {
|
|
62
62
|
animation,
|
|
63
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
64
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
63
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
64
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
67
|
};
|
|
@@ -112,8 +112,8 @@ export const setTabBarStyle = (options = {}) => {
|
|
|
112
112
|
selectedColor,
|
|
113
113
|
backgroundColor,
|
|
114
114
|
borderStyle,
|
|
115
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
116
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
115
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
116
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
117
117
|
});
|
|
118
118
|
});
|
|
119
119
|
};
|
|
@@ -145,8 +145,8 @@ export const setTabBarItem = (options) => {
|
|
|
145
145
|
text,
|
|
146
146
|
iconPath,
|
|
147
147
|
selectedIconPath,
|
|
148
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
149
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
148
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
149
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
150
150
|
});
|
|
151
151
|
});
|
|
152
152
|
};
|
|
@@ -185,8 +185,8 @@ export const setTabBarBadge = (options) => {
|
|
|
185
185
|
Taro.eventCenter.trigger('__taroSetTabBarBadge', {
|
|
186
186
|
index,
|
|
187
187
|
text,
|
|
188
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
189
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
188
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
189
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
190
190
|
});
|
|
191
191
|
});
|
|
192
192
|
};
|
|
@@ -215,8 +215,8 @@ export const removeTabBarBadge = (options) => {
|
|
|
215
215
|
return new Promise((resolve, reject) => {
|
|
216
216
|
Taro.eventCenter.trigger('__taroRemoveTabBarBadge', {
|
|
217
217
|
index,
|
|
218
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
219
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
218
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
219
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
220
220
|
});
|
|
221
221
|
});
|
|
222
222
|
};
|
|
@@ -245,8 +245,8 @@ export const hideTabBarRedDot = (options) => {
|
|
|
245
245
|
return new Promise((resolve, reject) => {
|
|
246
246
|
Taro.eventCenter.trigger('__taroHideTabBarRedDotHandler', {
|
|
247
247
|
index,
|
|
248
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
249
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
248
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
249
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
250
250
|
});
|
|
251
251
|
});
|
|
252
252
|
};
|
|
@@ -275,8 +275,8 @@ export const hideTabBar = (options = {}) => {
|
|
|
275
275
|
return new Promise((resolve, reject) => {
|
|
276
276
|
Taro.eventCenter.trigger('__taroHideTabBar', {
|
|
277
277
|
animation,
|
|
278
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
279
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
278
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
279
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
280
280
|
});
|
|
281
281
|
});
|
|
282
282
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { isFunction
|
|
1
|
+
import { isFunction } from '@tarojs/shared';
|
|
2
|
+
import { toKebabCase } from '../../utils';
|
|
2
3
|
function generateMediaQueryStr(descriptor) {
|
|
3
4
|
const mediaQueryArr = [];
|
|
4
5
|
const descriptorMenu = ['width', 'minWidth', 'maxWidth', 'height', 'minHeight', 'maxHeight', 'orientation'];
|
|
@@ -25,7 +26,7 @@ export class MediaQueryObserver {
|
|
|
25
26
|
callback({ matches: ev.matches });
|
|
26
27
|
};
|
|
27
28
|
callback({ matches: this._mediaQueryObserver.matches });
|
|
28
|
-
// 兼容旧浏览器中MediaQueryList尚未继承于EventTarget导致不存在'addEventListener'
|
|
29
|
+
// 兼容旧浏览器中 MediaQueryList 尚未继承于 EventTarget 导致不存在 'addEventListener'
|
|
29
30
|
if ('addEventListener' in this._mediaQueryObserver) {
|
|
30
31
|
this._mediaQueryObserver.addEventListener('change', this._listener);
|
|
31
32
|
}
|
|
@@ -37,7 +38,7 @@ export class MediaQueryObserver {
|
|
|
37
38
|
// 停止监听,销毁媒体查询对象
|
|
38
39
|
disconnect() {
|
|
39
40
|
if (this._mediaQueryObserver && this._listener) {
|
|
40
|
-
// 兼容旧浏览器中MediaQueryList尚未继承于EventTarget导致不存在'removeEventListener'
|
|
41
|
+
// 兼容旧浏览器中 MediaQueryList 尚未继承于 EventTarget 导致不存在 'removeEventListener'
|
|
41
42
|
if ('removeEventListener' in this._mediaQueryObserver) {
|
|
42
43
|
this._mediaQueryObserver.removeEventListener('change', this._listener);
|
|
43
44
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isFunction } from '@tarojs/shared';
|
|
1
2
|
import { findDOM } from '../../utils';
|
|
2
3
|
import { CanvasContext } from '../canvas/CanvasContext';
|
|
3
4
|
import { NodesRef } from './nodesRef';
|
|
@@ -183,9 +184,9 @@ export class SelectorQuery {
|
|
|
183
184
|
const _queueCb = this._queueCb;
|
|
184
185
|
res.forEach((item, index) => {
|
|
185
186
|
const cb = _queueCb[index];
|
|
186
|
-
|
|
187
|
+
isFunction(cb) && cb.call(this, item);
|
|
187
188
|
});
|
|
188
|
-
|
|
189
|
+
isFunction(cb) && cb.call(this, res);
|
|
189
190
|
});
|
|
190
191
|
return this;
|
|
191
192
|
}
|
package/dist/index.cjs.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
|
*/
|