@tarojs/taro-h5 3.5.10 → 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/interaction/index.js +10 -4
- package/dist/api/ui/interaction/modal.d.ts +1 -0
- package/dist/api/ui/interaction/modal.js +9 -1
- package/dist/api/ui/interaction/toast.d.ts +1 -0
- package/dist/api/ui/interaction/toast.js +9 -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/IntersectionObserver.d.ts +20 -0
- package/dist/api/wxml/IntersectionObserver.js +104 -0
- package/dist/api/wxml/MediaQueryObserver.d.ts +7 -0
- package/dist/api/wxml/MediaQueryObserver.js +50 -0
- package/dist/api/wxml/index.d.ts +2 -1
- package/dist/api/wxml/index.js +8 -2
- package/dist/api/wxml/nodesRef.d.ts +1 -0
- package/dist/api/wxml/selectorQuery.js +3 -2
- package/dist/index.cjs.d.ts +5 -4
- package/dist/index.cjs.js +310 -81
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.d.ts +5 -4
- package/dist/index.esm.js +292 -82
- package/dist/index.esm.js.map +1 -1
- package/dist/taroApis.d.ts +5 -4
- package/dist/taroApis.js +1 -1
- package/dist/utils/handler.d.ts +8 -3
- package/dist/utils/handler.js +19 -10
- package/dist/utils/index.d.ts +6 -1
- package/dist/utils/index.js +34 -6
- package/dist/utils/valid.d.ts +1 -2
- package/dist/utils/valid.js +0 -3
- package/package.json +14 -5
- package/types/global.d.ts +1 -0
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
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';
|
|
5
|
+
import { addLeadingSlash, stripBasename, getHomePage } from '@tarojs/router/dist/utils';
|
|
4
6
|
import { hooks, Current as Current$1 } from '@tarojs/runtime';
|
|
5
7
|
import { fromByteArray, toByteArray } from 'base64-js';
|
|
6
8
|
import { getMobileDetect, setTitle } from '@tarojs/router/dist/utils/navigate';
|
|
@@ -10,30 +12,38 @@ import jsonpRetry from 'jsonp-retry';
|
|
|
10
12
|
|
|
11
13
|
class MethodHandler {
|
|
12
14
|
constructor({ name, success, fail, complete }) {
|
|
15
|
+
this.isHandlerError = false;
|
|
13
16
|
this.methodName = name;
|
|
14
17
|
this.__success = success;
|
|
15
18
|
this.__fail = fail;
|
|
16
19
|
this.__complete = complete;
|
|
20
|
+
this.isHandlerError = isFunction(this.__complete) || isFunction(this.__fail);
|
|
17
21
|
}
|
|
18
|
-
success(res = {},
|
|
22
|
+
success(res = {}, promise = {}) {
|
|
19
23
|
if (!res.errMsg) {
|
|
20
24
|
res.errMsg = `${this.methodName}:ok`;
|
|
21
25
|
}
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
isFunction(this.__success) && this.__success(res);
|
|
27
|
+
isFunction(this.__complete) && this.__complete(res);
|
|
28
|
+
const { resolve = Promise.resolve.bind(Promise) } = promise;
|
|
24
29
|
return resolve(res);
|
|
25
30
|
}
|
|
26
|
-
fail(res = {},
|
|
31
|
+
fail(res = {}, promise = {}) {
|
|
27
32
|
if (!res.errMsg) {
|
|
28
33
|
res.errMsg = `${this.methodName}:fail`;
|
|
29
34
|
}
|
|
30
35
|
else {
|
|
31
36
|
res.errMsg = `${this.methodName}:fail ${res.errMsg}`;
|
|
32
37
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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);
|
|
37
47
|
}
|
|
38
48
|
}
|
|
39
49
|
class CallbackManager {
|
|
@@ -77,12 +87,12 @@ class CallbackManager {
|
|
|
77
87
|
*/
|
|
78
88
|
this.trigger = (...args) => {
|
|
79
89
|
this.callbacks.forEach(opt => {
|
|
80
|
-
if (
|
|
90
|
+
if (isFunction(opt)) {
|
|
81
91
|
opt(...args);
|
|
82
92
|
}
|
|
83
93
|
else {
|
|
84
94
|
const { callback, ctx } = opt;
|
|
85
|
-
|
|
95
|
+
isFunction(callback) && callback.call(ctx, ...args);
|
|
86
96
|
}
|
|
87
97
|
});
|
|
88
98
|
};
|
|
@@ -134,16 +144,12 @@ function debounce(fn, ms = 250, scope) {
|
|
|
134
144
|
};
|
|
135
145
|
}
|
|
136
146
|
|
|
137
|
-
function isFunction(obj) {
|
|
138
|
-
return typeof obj === 'function';
|
|
139
|
-
}
|
|
140
147
|
const VALID_COLOR_REG = /^#[0-9a-fA-F]{6}$/;
|
|
141
148
|
const isValidColor = (color) => {
|
|
142
149
|
return VALID_COLOR_REG.test(color);
|
|
143
150
|
};
|
|
144
151
|
|
|
145
152
|
/* eslint-disable prefer-promise-reject-errors */
|
|
146
|
-
const isProd = process.env.NODE_ENV === 'production';
|
|
147
153
|
function shouldBeObject(target) {
|
|
148
154
|
if (target && typeof target === 'object')
|
|
149
155
|
return { flag: true };
|
|
@@ -187,6 +193,9 @@ function upperCaseFirstLetter(string) {
|
|
|
187
193
|
string = string.replace(/^./, match => match.toUpperCase());
|
|
188
194
|
return string;
|
|
189
195
|
}
|
|
196
|
+
const toKebabCase = function (string) {
|
|
197
|
+
return string.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
198
|
+
};
|
|
190
199
|
function inlineStyle(style) {
|
|
191
200
|
let res = '';
|
|
192
201
|
for (const attr in style)
|
|
@@ -222,7 +231,7 @@ function temporarilyNotSupport(name = '') {
|
|
|
222
231
|
type: 'method',
|
|
223
232
|
category: 'temporarily',
|
|
224
233
|
});
|
|
225
|
-
if (
|
|
234
|
+
if (process.env.NODE_ENV === 'production') {
|
|
226
235
|
console.warn(errMsg);
|
|
227
236
|
return handle.success({ errMsg });
|
|
228
237
|
}
|
|
@@ -242,7 +251,7 @@ function weixinCorpSupport(name) {
|
|
|
242
251
|
type: 'method',
|
|
243
252
|
category: 'weixin_corp',
|
|
244
253
|
});
|
|
245
|
-
if (
|
|
254
|
+
if (process.env.NODE_ENV === 'production') {
|
|
246
255
|
console.warn(errMsg);
|
|
247
256
|
return handle.success({ errMsg });
|
|
248
257
|
}
|
|
@@ -262,7 +271,7 @@ function permanentlyNotSupport(name = '') {
|
|
|
262
271
|
type: 'method',
|
|
263
272
|
category: 'permanently',
|
|
264
273
|
});
|
|
265
|
-
if (
|
|
274
|
+
if (process.env.NODE_ENV === 'production') {
|
|
266
275
|
console.warn(errMsg);
|
|
267
276
|
return handle.success({ errMsg });
|
|
268
277
|
}
|
|
@@ -278,7 +287,7 @@ function processOpenApi({ name, defaultOptions, standardMethod, formatOptions =
|
|
|
278
287
|
// @ts-ignore
|
|
279
288
|
const targetApi = (_a = window === null || window === void 0 ? void 0 : window.wx) === null || _a === void 0 ? void 0 : _a[name];
|
|
280
289
|
const opts = formatOptions(Object.assign({}, defaultOptions, options));
|
|
281
|
-
if (
|
|
290
|
+
if (isFunction(targetApi)) {
|
|
282
291
|
return new Promise((resolve, reject) => {
|
|
283
292
|
['fail', 'success', 'complete'].forEach(k => {
|
|
284
293
|
opts[k] = preRef => {
|
|
@@ -295,7 +304,7 @@ function processOpenApi({ name, defaultOptions, standardMethod, formatOptions =
|
|
|
295
304
|
});
|
|
296
305
|
});
|
|
297
306
|
}
|
|
298
|
-
else if (
|
|
307
|
+
else if (isFunction(standardMethod)) {
|
|
299
308
|
return standardMethod(opts);
|
|
300
309
|
}
|
|
301
310
|
else {
|
|
@@ -303,6 +312,30 @@ function processOpenApi({ name, defaultOptions, standardMethod, formatOptions =
|
|
|
303
312
|
}
|
|
304
313
|
};
|
|
305
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* 根据url获取应用的启动页面
|
|
317
|
+
* @returns
|
|
318
|
+
*/
|
|
319
|
+
function getLaunchPage() {
|
|
320
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
321
|
+
const appConfig = window.__taroAppConfig || {};
|
|
322
|
+
// createPageConfig时根据stack的长度来设置stamp以保证页面path的唯一,此函数是在createPageConfig之前调用,预先设置stamp=1
|
|
323
|
+
const stamp = '?stamp=1';
|
|
324
|
+
let entryPath = '';
|
|
325
|
+
if (((_a = appConfig.router) === null || _a === void 0 ? void 0 : _a.mode) === 'browser' || ((_b = appConfig.router) === null || _b === void 0 ? void 0 : _b.mode) === 'multi') {
|
|
326
|
+
entryPath = location.pathname;
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
entryPath = location.hash.slice(1).split('?')[0];
|
|
330
|
+
}
|
|
331
|
+
const routePath = addLeadingSlash(stripBasename(entryPath, (_c = appConfig.router) === null || _c === void 0 ? void 0 : _c.basename));
|
|
332
|
+
const homePath = addLeadingSlash(getHomePage((_e = (_d = appConfig.routes) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.path, (_f = appConfig.router) === null || _f === void 0 ? void 0 : _f.basename, (_g = appConfig.router) === null || _g === void 0 ? void 0 : _g.customRoutes, appConfig.entryPagePath));
|
|
333
|
+
// url上没有指定应用的启动页面时使用homePath
|
|
334
|
+
if (routePath === '/') {
|
|
335
|
+
return homePath + stamp;
|
|
336
|
+
}
|
|
337
|
+
return routePath + stamp;
|
|
338
|
+
}
|
|
306
339
|
|
|
307
340
|
// 广告
|
|
308
341
|
const createRewardedVideoAd = temporarilyNotSupport('createRewardedVideoAd');
|
|
@@ -1458,7 +1491,7 @@ const setClipboardData = ({ data, success, fail, complete }) => __awaiter(void 0
|
|
|
1458
1491
|
* iOS < 10 的系统可能无法使用编程方式访问剪贴板,参考:
|
|
1459
1492
|
* https://stackoverflow.com/questions/34045777/copy-to-clipboard-using-javascript-in-ios/34046084
|
|
1460
1493
|
*/
|
|
1461
|
-
if (
|
|
1494
|
+
if (isFunction(document.execCommand)) {
|
|
1462
1495
|
const textarea = document.createElement('textarea');
|
|
1463
1496
|
textarea.readOnly = true;
|
|
1464
1497
|
textarea.value = data;
|
|
@@ -1918,9 +1951,9 @@ const getLocationByW3CApi = (options) => {
|
|
|
1918
1951
|
/** 调用结果,自动补充 */
|
|
1919
1952
|
errMsg: ''
|
|
1920
1953
|
};
|
|
1921
|
-
handle.success(result, resolve);
|
|
1954
|
+
handle.success(result, { resolve, reject });
|
|
1922
1955
|
}, (error) => {
|
|
1923
|
-
handle.fail({ errMsg: error.message }, reject);
|
|
1956
|
+
handle.fail({ errMsg: error.message }, { resolve, reject });
|
|
1924
1957
|
}, positionOptions);
|
|
1925
1958
|
});
|
|
1926
1959
|
};
|
|
@@ -2018,7 +2051,7 @@ const chooseLocation = ({ success, fail, complete, mapOpts } = {}) => {
|
|
|
2018
2051
|
console.warn('chooseLocation api 依赖腾讯地图定位api,需要在 defineConstants 中配置 LOCATION_APIKEY');
|
|
2019
2052
|
return handle.fail({
|
|
2020
2053
|
errMsg: 'LOCATION_APIKEY needed'
|
|
2021
|
-
}, reject);
|
|
2054
|
+
}, { resolve, reject });
|
|
2022
2055
|
}
|
|
2023
2056
|
const onMessage = event => {
|
|
2024
2057
|
// 接收位置信息,用户选择确认位置点后选点组件会触发该事件,回传用户的位置信息
|
|
@@ -2037,14 +2070,14 @@ const chooseLocation = ({ success, fail, complete, mapOpts } = {}) => {
|
|
|
2037
2070
|
chooser.remove();
|
|
2038
2071
|
}, 300);
|
|
2039
2072
|
if (res) {
|
|
2040
|
-
return handle.fail(res, reject);
|
|
2073
|
+
return handle.fail(res, { resolve, reject });
|
|
2041
2074
|
}
|
|
2042
2075
|
else {
|
|
2043
2076
|
if (chooseLocation.latitude && chooseLocation.longitude) {
|
|
2044
|
-
return handle.success(chooseLocation, resolve);
|
|
2077
|
+
return handle.success(chooseLocation, { resolve, reject });
|
|
2045
2078
|
}
|
|
2046
2079
|
else {
|
|
2047
|
-
return handle.fail({}, reject);
|
|
2080
|
+
return handle.fail({}, { resolve, reject });
|
|
2048
2081
|
}
|
|
2049
2082
|
}
|
|
2050
2083
|
}, key, mapOpts);
|
|
@@ -2301,12 +2334,12 @@ const getImageInfo = (options) => {
|
|
|
2301
2334
|
width: image.naturalWidth,
|
|
2302
2335
|
height: image.naturalHeight,
|
|
2303
2336
|
path: getBase64Image(image) || src
|
|
2304
|
-
}, resolve);
|
|
2337
|
+
}, { resolve, reject });
|
|
2305
2338
|
};
|
|
2306
2339
|
image.onerror = (e) => {
|
|
2307
2340
|
handle.fail({
|
|
2308
2341
|
errMsg: e.message
|
|
2309
|
-
}, reject);
|
|
2342
|
+
}, { resolve, reject });
|
|
2310
2343
|
};
|
|
2311
2344
|
image.src = src;
|
|
2312
2345
|
});
|
|
@@ -2333,7 +2366,7 @@ const previewImage = (options) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
2333
2366
|
item.appendChild(div);
|
|
2334
2367
|
// Note: 等待图片加载完后返回,会导致轮播被卡住
|
|
2335
2368
|
resolve(item);
|
|
2336
|
-
if (
|
|
2369
|
+
if (isFunction(loadFail)) {
|
|
2337
2370
|
image.addEventListener('error', (err) => {
|
|
2338
2371
|
loadFail({ errMsg: err.message });
|
|
2339
2372
|
});
|
|
@@ -2438,7 +2471,7 @@ const chooseImage = function (options) {
|
|
|
2438
2471
|
el.removeAttribute('capture');
|
|
2439
2472
|
}
|
|
2440
2473
|
}
|
|
2441
|
-
return new Promise(resolve => {
|
|
2474
|
+
return new Promise((resolve, reject) => {
|
|
2442
2475
|
const TaroMouseEvents = document.createEvent('MouseEvents');
|
|
2443
2476
|
TaroMouseEvents.initEvent('click', true, true);
|
|
2444
2477
|
if (el) {
|
|
@@ -2457,7 +2490,7 @@ const chooseImage = function (options) {
|
|
|
2457
2490
|
(_a = res.tempFilePaths) === null || _a === void 0 ? void 0 : _a.push(url);
|
|
2458
2491
|
(_b = res.tempFiles) === null || _b === void 0 ? void 0 : _b.push({ path: url, size: item.size, type: item.type, originalFileObj: item });
|
|
2459
2492
|
});
|
|
2460
|
-
handle.success(res, resolve);
|
|
2493
|
+
handle.success(res, { resolve, reject });
|
|
2461
2494
|
target.value = '';
|
|
2462
2495
|
}
|
|
2463
2496
|
};
|
|
@@ -2525,7 +2558,7 @@ const chooseVideo = (options) => {
|
|
|
2525
2558
|
inputEl.setAttribute('accept', 'video/*');
|
|
2526
2559
|
inputEl.setAttribute('style', 'position: fixed; top: -4000px; left: -3000px; z-index: -300;');
|
|
2527
2560
|
document.body.appendChild(inputEl);
|
|
2528
|
-
return new Promise(resolve => {
|
|
2561
|
+
return new Promise((resolve, reject) => {
|
|
2529
2562
|
const TaroMouseEvents = document.createEvent('MouseEvents');
|
|
2530
2563
|
TaroMouseEvents.initEvent('click', true, true);
|
|
2531
2564
|
inputEl.dispatchEvent(TaroMouseEvents);
|
|
@@ -2546,7 +2579,7 @@ const chooseVideo = (options) => {
|
|
|
2546
2579
|
res.size = event.total;
|
|
2547
2580
|
res.height = videoEl.videoHeight;
|
|
2548
2581
|
res.width = videoEl.videoHeight;
|
|
2549
|
-
return handle.success(res, resolve);
|
|
2582
|
+
return handle.success(res, { resolve, reject });
|
|
2550
2583
|
};
|
|
2551
2584
|
};
|
|
2552
2585
|
if (file) {
|
|
@@ -2827,13 +2860,13 @@ function _request(options) {
|
|
|
2827
2860
|
.then(data => {
|
|
2828
2861
|
res.statusCode = 200;
|
|
2829
2862
|
res.data = data;
|
|
2830
|
-
|
|
2831
|
-
|
|
2863
|
+
isFunction(success) && success(res);
|
|
2864
|
+
isFunction(complete) && complete(res);
|
|
2832
2865
|
return res;
|
|
2833
2866
|
})
|
|
2834
2867
|
.catch(err => {
|
|
2835
|
-
|
|
2836
|
-
|
|
2868
|
+
isFunction(fail) && fail(err);
|
|
2869
|
+
isFunction(complete) && complete(res);
|
|
2837
2870
|
return Promise.reject(err);
|
|
2838
2871
|
});
|
|
2839
2872
|
}
|
|
@@ -2901,13 +2934,13 @@ function _request(options) {
|
|
|
2901
2934
|
})
|
|
2902
2935
|
.then(data => {
|
|
2903
2936
|
res.data = data;
|
|
2904
|
-
|
|
2905
|
-
|
|
2937
|
+
isFunction(success) && success(res);
|
|
2938
|
+
isFunction(complete) && complete(res);
|
|
2906
2939
|
return res;
|
|
2907
2940
|
})
|
|
2908
2941
|
.catch(err => {
|
|
2909
|
-
|
|
2910
|
-
|
|
2942
|
+
isFunction(fail) && fail(err);
|
|
2943
|
+
isFunction(complete) && complete(res);
|
|
2911
2944
|
err.statusCode = res.statusCode;
|
|
2912
2945
|
err.errMsg = err.message;
|
|
2913
2946
|
return Promise.reject(err);
|
|
@@ -3096,14 +3129,14 @@ class SocketTask {
|
|
|
3096
3129
|
if (this.readyState !== 1) {
|
|
3097
3130
|
const res = { errMsg: 'SocketTask.send:fail SocketTask.readState is not OPEN' };
|
|
3098
3131
|
console.error(res.errMsg);
|
|
3099
|
-
|
|
3100
|
-
|
|
3132
|
+
isFunction(fail) && fail(res);
|
|
3133
|
+
isFunction(complete) && complete(res);
|
|
3101
3134
|
return Promise.reject(res);
|
|
3102
3135
|
}
|
|
3103
3136
|
this.ws.send(data);
|
|
3104
3137
|
const res = { errMsg: 'sendSocketMessage:ok' };
|
|
3105
|
-
|
|
3106
|
-
|
|
3138
|
+
isFunction(success) && success(res);
|
|
3139
|
+
isFunction(complete) && complete(res);
|
|
3107
3140
|
return Promise.resolve(res);
|
|
3108
3141
|
}
|
|
3109
3142
|
close(opts = {}) {
|
|
@@ -3115,8 +3148,8 @@ class SocketTask {
|
|
|
3115
3148
|
this._destroyWhenClose && this._destroyWhenClose();
|
|
3116
3149
|
this.ws.close();
|
|
3117
3150
|
const res = { errMsg: 'closeSocket:ok' };
|
|
3118
|
-
|
|
3119
|
-
|
|
3151
|
+
isFunction(success) && success(res);
|
|
3152
|
+
isFunction(complete) && complete(res);
|
|
3120
3153
|
return Promise.resolve(res);
|
|
3121
3154
|
}
|
|
3122
3155
|
onOpen(func) {
|
|
@@ -3174,13 +3207,13 @@ function connectSocket(options) {
|
|
|
3174
3207
|
correct: 'String',
|
|
3175
3208
|
wrong: url
|
|
3176
3209
|
})
|
|
3177
|
-
}, reject);
|
|
3210
|
+
}, { resolve, reject });
|
|
3178
3211
|
}
|
|
3179
3212
|
// options.url must be invalid
|
|
3180
3213
|
if (!url.startsWith('ws://') && !url.startsWith('wss://')) {
|
|
3181
3214
|
return handle.fail({
|
|
3182
3215
|
errMsg: `request:fail invalid url "${url}"`
|
|
3183
|
-
}, reject);
|
|
3216
|
+
}, { resolve, reject });
|
|
3184
3217
|
}
|
|
3185
3218
|
// protocols must be array
|
|
3186
3219
|
const _protocols = Array.isArray(protocols) ? protocols : null;
|
|
@@ -3188,7 +3221,7 @@ function connectSocket(options) {
|
|
|
3188
3221
|
if (socketTasks.length > 1) {
|
|
3189
3222
|
return handle.fail({
|
|
3190
3223
|
errMsg: '同时最多发起 2 个 socket 请求,更多请参考文档。'
|
|
3191
|
-
}, reject);
|
|
3224
|
+
}, { resolve, reject });
|
|
3192
3225
|
}
|
|
3193
3226
|
const task = new SocketTask(url, _protocols);
|
|
3194
3227
|
task._destroyWhenClose = function () {
|
|
@@ -3918,6 +3951,7 @@ class Modal {
|
|
|
3918
3951
|
}
|
|
3919
3952
|
create(options = {}) {
|
|
3920
3953
|
return new Promise((resolve) => {
|
|
3954
|
+
var _a, _b;
|
|
3921
3955
|
// style
|
|
3922
3956
|
const { maskStyle, modalStyle, titleStyle, textStyle, footStyle, btnStyle } = this.style;
|
|
3923
3957
|
// configuration
|
|
@@ -3982,10 +4016,13 @@ class Modal {
|
|
|
3982
4016
|
// show immediately
|
|
3983
4017
|
document.body.appendChild(this.el);
|
|
3984
4018
|
setTimeout(() => { this.el.style.opacity = '1'; }, 0);
|
|
4019
|
+
// Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
|
|
4020
|
+
this.currentPath = (_b = (_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getLaunchPage();
|
|
3985
4021
|
});
|
|
3986
4022
|
}
|
|
3987
4023
|
show(options = {}) {
|
|
3988
4024
|
return new Promise((resolve) => {
|
|
4025
|
+
var _a, _b;
|
|
3989
4026
|
const config = Object.assign(Object.assign({}, this.options), options);
|
|
3990
4027
|
if (this.hideOpacityTimer)
|
|
3991
4028
|
clearTimeout(this.hideOpacityTimer);
|
|
@@ -4029,6 +4066,8 @@ class Modal {
|
|
|
4029
4066
|
// show
|
|
4030
4067
|
this.el.style.display = 'block';
|
|
4031
4068
|
setTimeout(() => { this.el.style.opacity = '1'; }, 0);
|
|
4069
|
+
// Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
|
|
4070
|
+
this.currentPath = (_b = (_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getLaunchPage();
|
|
4032
4071
|
});
|
|
4033
4072
|
}
|
|
4034
4073
|
hide() {
|
|
@@ -4036,6 +4075,7 @@ class Modal {
|
|
|
4036
4075
|
clearTimeout(this.hideOpacityTimer);
|
|
4037
4076
|
if (this.hideDisplayTimer)
|
|
4038
4077
|
clearTimeout(this.hideDisplayTimer);
|
|
4078
|
+
this.currentPath = null;
|
|
4039
4079
|
this.hideOpacityTimer = setTimeout(() => {
|
|
4040
4080
|
this.el.style.opacity = '0';
|
|
4041
4081
|
this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none'; }, 200);
|
|
@@ -4119,6 +4159,7 @@ class Toast {
|
|
|
4119
4159
|
};
|
|
4120
4160
|
}
|
|
4121
4161
|
create(options = {}, _type = 'toast') {
|
|
4162
|
+
var _a, _b;
|
|
4122
4163
|
// style
|
|
4123
4164
|
const { maskStyle, toastStyle, successStyle, errrorStyle, loadingStyle, imageStyle, textStyle } = this.style;
|
|
4124
4165
|
// configuration
|
|
@@ -4162,9 +4203,12 @@ class Toast {
|
|
|
4162
4203
|
this.type = config._type;
|
|
4163
4204
|
// disappear after duration
|
|
4164
4205
|
config.duration >= 0 && this.hide(config.duration, this.type);
|
|
4206
|
+
// Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
|
|
4207
|
+
this.currentPath = (_b = (_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getLaunchPage();
|
|
4165
4208
|
return '';
|
|
4166
4209
|
}
|
|
4167
4210
|
show(options = {}, _type = 'toast') {
|
|
4211
|
+
var _a, _b;
|
|
4168
4212
|
const config = Object.assign(Object.assign(Object.assign({}, this.options), options), { _type });
|
|
4169
4213
|
if (this.hideOpacityTimer)
|
|
4170
4214
|
clearTimeout(this.hideOpacityTimer);
|
|
@@ -4196,6 +4240,8 @@ class Toast {
|
|
|
4196
4240
|
this.type = config._type;
|
|
4197
4241
|
// disappear after duration
|
|
4198
4242
|
config.duration >= 0 && this.hide(config.duration, this.type);
|
|
4243
|
+
// Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
|
|
4244
|
+
this.currentPath = (_b = (_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getLaunchPage();
|
|
4199
4245
|
return '';
|
|
4200
4246
|
}
|
|
4201
4247
|
hide(duration = 0, type) {
|
|
@@ -4205,6 +4251,7 @@ class Toast {
|
|
|
4205
4251
|
clearTimeout(this.hideOpacityTimer);
|
|
4206
4252
|
if (this.hideDisplayTimer)
|
|
4207
4253
|
clearTimeout(this.hideDisplayTimer);
|
|
4254
|
+
this.currentPath = null;
|
|
4208
4255
|
this.hideOpacityTimer = setTimeout(() => {
|
|
4209
4256
|
this.el.style.opacity = '0';
|
|
4210
4257
|
this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none'; }, 100);
|
|
@@ -4466,10 +4513,15 @@ const showActionSheet = (options = { itemList: [] }) => __awaiter(void 0, void 0
|
|
|
4466
4513
|
return handle.success(({ tapIndex: result }));
|
|
4467
4514
|
}
|
|
4468
4515
|
});
|
|
4469
|
-
Taro.eventCenter.on('
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4516
|
+
Taro.eventCenter.on('__afterTaroRouterChange', () => {
|
|
4517
|
+
var _a, _b;
|
|
4518
|
+
if (toast.currentPath && toast.currentPath !== ((_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path)) {
|
|
4519
|
+
hideToast();
|
|
4520
|
+
hideLoading();
|
|
4521
|
+
}
|
|
4522
|
+
if (modal.currentPath && modal.currentPath !== ((_b = Current$1.page) === null || _b === void 0 ? void 0 : _b.path)) {
|
|
4523
|
+
hideModal();
|
|
4524
|
+
}
|
|
4473
4525
|
});
|
|
4474
4526
|
const enableAlertBeforeUnload = temporarilyNotSupport('enableAlertBeforeUnload');
|
|
4475
4527
|
const disableAlertBeforeUnload = temporarilyNotSupport('disableAlertBeforeUnload');
|
|
@@ -4523,8 +4575,8 @@ const startPullDownRefresh = function ({ success, fail, complete } = {}) {
|
|
|
4523
4575
|
const handle = new MethodHandler({ name: 'startPullDownRefresh', success, fail, complete });
|
|
4524
4576
|
return new Promise((resolve, reject) => {
|
|
4525
4577
|
Taro.eventCenter.trigger('__taroStartPullDownRefresh', {
|
|
4526
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4527
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4578
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4579
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4528
4580
|
});
|
|
4529
4581
|
});
|
|
4530
4582
|
};
|
|
@@ -4535,8 +4587,8 @@ const stopPullDownRefresh = function ({ success, fail, complete } = {}) {
|
|
|
4535
4587
|
const handle = new MethodHandler({ name: 'stopPullDownRefresh', success, fail, complete });
|
|
4536
4588
|
return new Promise((resolve, reject) => {
|
|
4537
4589
|
Taro.eventCenter.trigger('__taroStopPullDownRefresh', {
|
|
4538
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4539
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4590
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4591
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4540
4592
|
});
|
|
4541
4593
|
});
|
|
4542
4594
|
};
|
|
@@ -4555,7 +4607,7 @@ const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300,
|
|
|
4555
4607
|
if (scrollTop === undefined && !selector) {
|
|
4556
4608
|
return handle.fail({
|
|
4557
4609
|
errMsg: 'scrollTop" 或 "selector" 需要其之一'
|
|
4558
|
-
}, reject);
|
|
4610
|
+
}, { resolve, reject });
|
|
4559
4611
|
}
|
|
4560
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');
|
|
4561
4613
|
const el = (id
|
|
@@ -4609,7 +4661,7 @@ const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300,
|
|
|
4609
4661
|
}, FRAME_DURATION);
|
|
4610
4662
|
}
|
|
4611
4663
|
else {
|
|
4612
|
-
return handle.success({}, resolve);
|
|
4664
|
+
return handle.success({}, { resolve, reject });
|
|
4613
4665
|
}
|
|
4614
4666
|
};
|
|
4615
4667
|
scroll();
|
|
@@ -4617,7 +4669,7 @@ const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300,
|
|
|
4617
4669
|
catch (e) {
|
|
4618
4670
|
return handle.fail({
|
|
4619
4671
|
errMsg: e.message
|
|
4620
|
-
}, reject);
|
|
4672
|
+
}, { resolve, reject });
|
|
4621
4673
|
}
|
|
4622
4674
|
});
|
|
4623
4675
|
};
|
|
@@ -4654,8 +4706,8 @@ const showTabBarRedDot = (options) => {
|
|
|
4654
4706
|
return new Promise((resolve, reject) => {
|
|
4655
4707
|
Taro.eventCenter.trigger('__taroShowTabBarRedDotHandler', {
|
|
4656
4708
|
index,
|
|
4657
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4658
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4709
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4710
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4659
4711
|
});
|
|
4660
4712
|
});
|
|
4661
4713
|
};
|
|
@@ -4684,8 +4736,8 @@ const showTabBar = (options = {}) => {
|
|
|
4684
4736
|
return new Promise((resolve, reject) => {
|
|
4685
4737
|
Taro.eventCenter.trigger('__taroShowTabBar', {
|
|
4686
4738
|
animation,
|
|
4687
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4688
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4739
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4740
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4689
4741
|
});
|
|
4690
4742
|
});
|
|
4691
4743
|
};
|
|
@@ -4736,8 +4788,8 @@ const setTabBarStyle = (options = {}) => {
|
|
|
4736
4788
|
selectedColor,
|
|
4737
4789
|
backgroundColor,
|
|
4738
4790
|
borderStyle,
|
|
4739
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4740
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4791
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4792
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4741
4793
|
});
|
|
4742
4794
|
});
|
|
4743
4795
|
};
|
|
@@ -4769,8 +4821,8 @@ const setTabBarItem = (options) => {
|
|
|
4769
4821
|
text,
|
|
4770
4822
|
iconPath,
|
|
4771
4823
|
selectedIconPath,
|
|
4772
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4773
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4824
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4825
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4774
4826
|
});
|
|
4775
4827
|
});
|
|
4776
4828
|
};
|
|
@@ -4809,8 +4861,8 @@ const setTabBarBadge = (options) => {
|
|
|
4809
4861
|
Taro.eventCenter.trigger('__taroSetTabBarBadge', {
|
|
4810
4862
|
index,
|
|
4811
4863
|
text,
|
|
4812
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4813
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4864
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4865
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4814
4866
|
});
|
|
4815
4867
|
});
|
|
4816
4868
|
};
|
|
@@ -4839,8 +4891,8 @@ const removeTabBarBadge = (options) => {
|
|
|
4839
4891
|
return new Promise((resolve, reject) => {
|
|
4840
4892
|
Taro.eventCenter.trigger('__taroRemoveTabBarBadge', {
|
|
4841
4893
|
index,
|
|
4842
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4843
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4894
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4895
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4844
4896
|
});
|
|
4845
4897
|
});
|
|
4846
4898
|
};
|
|
@@ -4869,8 +4921,8 @@ const hideTabBarRedDot = (options) => {
|
|
|
4869
4921
|
return new Promise((resolve, reject) => {
|
|
4870
4922
|
Taro.eventCenter.trigger('__taroHideTabBarRedDotHandler', {
|
|
4871
4923
|
index,
|
|
4872
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4873
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4924
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4925
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4874
4926
|
});
|
|
4875
4927
|
});
|
|
4876
4928
|
};
|
|
@@ -4899,8 +4951,8 @@ const hideTabBar = (options = {}) => {
|
|
|
4899
4951
|
return new Promise((resolve, reject) => {
|
|
4900
4952
|
Taro.eventCenter.trigger('__taroHideTabBar', {
|
|
4901
4953
|
animation,
|
|
4902
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4903
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4954
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4955
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4904
4956
|
});
|
|
4905
4957
|
});
|
|
4906
4958
|
};
|
|
@@ -4938,6 +4990,159 @@ const offWindowResize = callback => {
|
|
|
4938
4990
|
// Worker
|
|
4939
4991
|
const createWorker = temporarilyNotSupport('createWorker');
|
|
4940
4992
|
|
|
4993
|
+
// pollify
|
|
4994
|
+
import('intersection-observer');
|
|
4995
|
+
class TaroH5IntersectionObserver {
|
|
4996
|
+
constructor(component, options = {}) {
|
|
4997
|
+
// 选项
|
|
4998
|
+
this._options = {
|
|
4999
|
+
thresholds: [0],
|
|
5000
|
+
initialRatio: 0,
|
|
5001
|
+
observeAll: false
|
|
5002
|
+
};
|
|
5003
|
+
// 监控中的选择器
|
|
5004
|
+
this._listeners = [];
|
|
5005
|
+
// 用来扩展(或收缩)参照节点布局区域的边界
|
|
5006
|
+
this._rootMargin = {};
|
|
5007
|
+
// 是否已初始化
|
|
5008
|
+
this._isInited = false;
|
|
5009
|
+
this._component = component;
|
|
5010
|
+
Object.assign(this._options, options);
|
|
5011
|
+
}
|
|
5012
|
+
// selector 的容器节点
|
|
5013
|
+
get container() {
|
|
5014
|
+
const container = (this._component !== null
|
|
5015
|
+
? (findDOM(this._component) || document)
|
|
5016
|
+
: document);
|
|
5017
|
+
return container;
|
|
5018
|
+
}
|
|
5019
|
+
createInst() {
|
|
5020
|
+
// 去除原本的实例
|
|
5021
|
+
this.disconnect();
|
|
5022
|
+
const { left = 0, top = 0, bottom = 0, right = 0 } = this._rootMargin;
|
|
5023
|
+
return new IntersectionObserver(entries => {
|
|
5024
|
+
entries.forEach(entry => {
|
|
5025
|
+
const _callback = this._getCallbackByElement(entry.target);
|
|
5026
|
+
const result = {
|
|
5027
|
+
boundingClientRect: entry.boundingClientRect,
|
|
5028
|
+
intersectionRatio: entry.intersectionRatio,
|
|
5029
|
+
intersectionRect: entry.intersectionRect,
|
|
5030
|
+
relativeRect: entry.rootBounds || { left: 0, right: 0, top: 0, bottom: 0 },
|
|
5031
|
+
time: entry.time
|
|
5032
|
+
};
|
|
5033
|
+
// web端会默认首次触发
|
|
5034
|
+
if (!this._isInited && this._options.initialRatio <= Math.min.apply(Math, this._options.thresholds)) {
|
|
5035
|
+
// 初始的相交比例,如果调用时检测到的相交比例与这个值不相等且达到阈值,则会触发一次监听器的回调函数。
|
|
5036
|
+
return;
|
|
5037
|
+
}
|
|
5038
|
+
_callback && _callback.call(this, result);
|
|
5039
|
+
});
|
|
5040
|
+
this._isInited = true;
|
|
5041
|
+
}, {
|
|
5042
|
+
root: this._root,
|
|
5043
|
+
rootMargin: [`${top}px`, `${right}px`, `${bottom}px`, `${left}px`].join(' '),
|
|
5044
|
+
threshold: this._options.thresholds
|
|
5045
|
+
});
|
|
5046
|
+
}
|
|
5047
|
+
disconnect() {
|
|
5048
|
+
if (this._observerInst) {
|
|
5049
|
+
let listener;
|
|
5050
|
+
while ((listener = this._listeners.pop())) {
|
|
5051
|
+
this._observerInst.unobserve(listener.element);
|
|
5052
|
+
}
|
|
5053
|
+
this._observerInst.disconnect();
|
|
5054
|
+
}
|
|
5055
|
+
}
|
|
5056
|
+
observe(targetSelector, callback) {
|
|
5057
|
+
// 同wx小程序效果一致,每个实例监听一个Selector
|
|
5058
|
+
if (this._listeners.length)
|
|
5059
|
+
return;
|
|
5060
|
+
// 监听前没有设置关联的节点
|
|
5061
|
+
if (!this._observerInst) {
|
|
5062
|
+
console.warn('Intersection observer will be ignored because no relative nodes are found.');
|
|
5063
|
+
return;
|
|
5064
|
+
}
|
|
5065
|
+
const nodeList = this._options.observeAll
|
|
5066
|
+
? this.container.querySelectorAll(targetSelector)
|
|
5067
|
+
: [this.container.querySelector(targetSelector)];
|
|
5068
|
+
nodeList.forEach(element => {
|
|
5069
|
+
if (!element)
|
|
5070
|
+
return;
|
|
5071
|
+
this._observerInst.observe(element);
|
|
5072
|
+
this._listeners.push({ element, callback });
|
|
5073
|
+
});
|
|
5074
|
+
}
|
|
5075
|
+
relativeTo(selector, margins) {
|
|
5076
|
+
// 已设置observe监听后,重新关联节点
|
|
5077
|
+
if (this._listeners.length) {
|
|
5078
|
+
console.error('Relative nodes cannot be added after "observe" call in IntersectionObserver');
|
|
5079
|
+
return this;
|
|
5080
|
+
}
|
|
5081
|
+
this._root = this.container.querySelector(selector) || null;
|
|
5082
|
+
if (margins) {
|
|
5083
|
+
this._rootMargin = margins;
|
|
5084
|
+
}
|
|
5085
|
+
this._observerInst = this.createInst();
|
|
5086
|
+
return this;
|
|
5087
|
+
}
|
|
5088
|
+
relativeToViewport(margins) {
|
|
5089
|
+
return this.relativeTo('.taro_page', margins);
|
|
5090
|
+
}
|
|
5091
|
+
_getCallbackByElement(element) {
|
|
5092
|
+
const listener = this._listeners.find(listener => listener.element === element);
|
|
5093
|
+
return listener ? listener.callback : null;
|
|
5094
|
+
}
|
|
5095
|
+
}
|
|
5096
|
+
|
|
5097
|
+
function generateMediaQueryStr(descriptor) {
|
|
5098
|
+
const mediaQueryArr = [];
|
|
5099
|
+
const descriptorMenu = ['width', 'minWidth', 'maxWidth', 'height', 'minHeight', 'maxHeight', 'orientation'];
|
|
5100
|
+
for (const item of descriptorMenu) {
|
|
5101
|
+
if (item !== 'orientation' &&
|
|
5102
|
+
descriptor[item] &&
|
|
5103
|
+
Number(descriptor[item]) >= 0) {
|
|
5104
|
+
mediaQueryArr.push(`(${(toKebabCase(item))}: ${Number(descriptor[item])}px)`);
|
|
5105
|
+
}
|
|
5106
|
+
if (item === 'orientation' && descriptor[item]) {
|
|
5107
|
+
mediaQueryArr.push(`(${toKebabCase(item)}: ${descriptor[item]})`);
|
|
5108
|
+
}
|
|
5109
|
+
}
|
|
5110
|
+
return mediaQueryArr.join(' and ');
|
|
5111
|
+
}
|
|
5112
|
+
class MediaQueryObserver {
|
|
5113
|
+
// 监听页面媒体查询变化情况
|
|
5114
|
+
observe(descriptor, callback) {
|
|
5115
|
+
if (isFunction(callback)) {
|
|
5116
|
+
// 创建媒体查询对象
|
|
5117
|
+
this._mediaQueryObserver = window.matchMedia(generateMediaQueryStr(descriptor));
|
|
5118
|
+
// 监听器
|
|
5119
|
+
this._listener = (ev) => {
|
|
5120
|
+
callback({ matches: ev.matches });
|
|
5121
|
+
};
|
|
5122
|
+
callback({ matches: this._mediaQueryObserver.matches });
|
|
5123
|
+
// 兼容旧浏览器中 MediaQueryList 尚未继承于 EventTarget 导致不存在 'addEventListener'
|
|
5124
|
+
if ('addEventListener' in this._mediaQueryObserver) {
|
|
5125
|
+
this._mediaQueryObserver.addEventListener('change', this._listener);
|
|
5126
|
+
}
|
|
5127
|
+
else {
|
|
5128
|
+
this._mediaQueryObserver.addListener(this._listener);
|
|
5129
|
+
}
|
|
5130
|
+
}
|
|
5131
|
+
}
|
|
5132
|
+
// 停止监听,销毁媒体查询对象
|
|
5133
|
+
disconnect() {
|
|
5134
|
+
if (this._mediaQueryObserver && this._listener) {
|
|
5135
|
+
// 兼容旧浏览器中 MediaQueryList 尚未继承于 EventTarget 导致不存在 'removeEventListener'
|
|
5136
|
+
if ('removeEventListener' in this._mediaQueryObserver) {
|
|
5137
|
+
this._mediaQueryObserver.removeEventListener('change', this._listener);
|
|
5138
|
+
}
|
|
5139
|
+
else {
|
|
5140
|
+
this._mediaQueryObserver.removeListener(this._listener);
|
|
5141
|
+
}
|
|
5142
|
+
}
|
|
5143
|
+
}
|
|
5144
|
+
}
|
|
5145
|
+
|
|
4941
5146
|
class NodesRef {
|
|
4942
5147
|
constructor(selector, querySelectorQuery, single) {
|
|
4943
5148
|
this._component = querySelectorQuery._component;
|
|
@@ -5163,9 +5368,9 @@ class SelectorQuery {
|
|
|
5163
5368
|
const _queueCb = this._queueCb;
|
|
5164
5369
|
res.forEach((item, index) => {
|
|
5165
5370
|
const cb = _queueCb[index];
|
|
5166
|
-
|
|
5371
|
+
isFunction(cb) && cb.call(this, item);
|
|
5167
5372
|
});
|
|
5168
|
-
|
|
5373
|
+
isFunction(cb) && cb.call(this, res);
|
|
5169
5374
|
});
|
|
5170
5375
|
return this;
|
|
5171
5376
|
}
|
|
@@ -5183,7 +5388,12 @@ class SelectorQuery {
|
|
|
5183
5388
|
const createSelectorQuery = () => {
|
|
5184
5389
|
return new SelectorQuery();
|
|
5185
5390
|
};
|
|
5186
|
-
const createIntersectionObserver =
|
|
5391
|
+
const createIntersectionObserver = (component, options) => {
|
|
5392
|
+
return new TaroH5IntersectionObserver(component, options);
|
|
5393
|
+
};
|
|
5394
|
+
const createMediaQueryObserver = () => {
|
|
5395
|
+
return new MediaQueryObserver();
|
|
5396
|
+
};
|
|
5187
5397
|
|
|
5188
5398
|
const { Behavior, getEnv, ENV_TYPE, Link, interceptors, getInitPxTransform, Current, options, eventCenter, Events, preload } = Taro;
|
|
5189
5399
|
const taro = {
|
|
@@ -5213,7 +5423,7 @@ const requirePlugin = permanentlyNotSupport('requirePlugin');
|
|
|
5213
5423
|
const pxTransform = function (size) {
|
|
5214
5424
|
const options = taro.config;
|
|
5215
5425
|
const baseFontSize = options.baseFontSize || 20;
|
|
5216
|
-
const designWidth = ((input = 0) =>
|
|
5426
|
+
const designWidth = ((input = 0) => isFunction(options.designWidth)
|
|
5217
5427
|
? options.designWidth(input)
|
|
5218
5428
|
: options.designWidth);
|
|
5219
5429
|
const rootValue = (input = 0) => baseFontSize / options.deviceRatio[designWidth(input)] * 2;
|
|
@@ -5230,5 +5440,5 @@ taro.initPxTransform = initPxTransform;
|
|
|
5230
5440
|
// @ts-ignore
|
|
5231
5441
|
taro.canIUseWebp = canIUseWebp;
|
|
5232
5442
|
|
|
5233
|
-
export { Behavior, Current, ENV_TYPE, Events, Link, addCard, addFileToFavorites, addInterceptor, addPhoneCalendar, addPhoneContact, addPhoneRepeatCalendar, addVideoToFavorites, advancedGeneralIdentify, animalClassify, arrayBufferToBase64, authPrivateMessage, authorize, authorizeForMiniProgram, base64ToArrayBuffer, canIUse, canIUseWebp, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, carClassify, checkIsOpenAccessibility, checkIsSoterEnrolledInDevice, checkIsSupportFacialRecognition, checkIsSupportSoterAuthentication, checkSession, chooseAddress, chooseContact, chooseImage, chooseInvoice, chooseInvoiceTitle, chooseLicensePlate, chooseLocation, chooseMedia, chooseMessageFile, choosePoi, chooseVideo, clearStorage, clearStorageSync, closeBLEConnection, closeBluetoothAdapter, closeSocket, cloud, compressImage, compressVideo, connectSocket, connectWifi, createAnimation, createAudioContext, createBLEConnection, createBLEPeripheralServer, createBufferURL, createCameraContext, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createInterstitialAd, createLivePlayerContext, createLivePusherContext, createMapContext, createMediaAudioPlayer, createMediaContainer, createMediaRecorder, createOffscreenCanvas, createRewardedVideoAd, createSelectorQuery, createTCPSocket, createUDPSocket, createVKSession, createVideoContext, createVideoDecoder, createWebAudioContext, createWorker, taro as default, disableAlertBeforeUnload, dishClassify, downloadFile, enableAlertBeforeUnload, eventCenter, exitMiniProgram, exitVoIPChat, faceDetect, faceVerifyForPay, getAccountInfoSync, getApp, getAppAuthorizeSetting, getAppBaseInfo, getAvailableAudioSources, getBLEDeviceCharacteristics, getBLEDeviceRSSI, getBLEDeviceServices, getBLEMTU, getBackgroundAudioManager, getBackgroundAudioPlayerState, getBackgroundFetchData, getBackgroundFetchToken, getBatteryInfo, getBatteryInfoSync, getBeacons, getBluetoothAdapterState, getBluetoothDevices, getChannelsLiveInfo, getChannelsLiveNoticeInfo, getClipboardData, getConnectedBluetoothDevices, getConnectedWifi, getCurrentInstance, getDeviceInfo, getEnterOptionsSync, getEnv, getExptInfoSync, getExtConfig, getExtConfigSync, getFileInfo, getFileSystemManager, getFuzzyLocation, getGroupEnterInfo, getHCEState, getImageInfo, getLaunchOptionsSync, getLocalIPAddress, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNFCAdapter, getNetworkType, getOpenUserInfo, getPerformance, getRandomValues, getRealtimeLogManager, getRecorderManager, getSavedFileInfo, getSavedFileList, getScreenBrightness, getSelectedTextRange, getSetting, getShareInfo, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSwanId, getSystemInfo, getSystemInfoAsync, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserCryptoManager, getUserInfo, getUserProfile, getVideoInfo, getWeRunData, getWifiList, getWindowInfo, hideHomeButton, hideKeyboard, hideLoading, hideNavigationBarLoading, hideShareMenu, hideTabBar, hideTabBarRedDot, hideToast, imageAudit, initFaceDetect, initPxTransform, initTabBarApis, interceptors, isBluetoothDevicePaired, isVKSupport, joinVoIPChat, loadFontFace, login, logoClassify, makeBluetoothPair, makePhoneCall, navigateBackMiniProgram, navigateBackSmartProgram, navigateToMiniProgram, navigateToSmartGameProgram, navigateToSmartProgram, nextTick, notifyBLECharacteristicValueChange, objectDetectIdentify, ocrBankCard, ocrDrivingLicense, ocrIdCard, ocrVehicleLicense, offAccelerometerChange, offAppHide, offAppShow, offAudioInterruptionBegin, offAudioInterruptionEnd, offBLECharacteristicValueChange, offBLEConnectionStateChange, offBLEMTUChange, offBLEPeripheralConnectionStateChanged, offBeaconServiceChange, offBeaconUpdate, offBluetoothAdapterStateChange, offBluetoothDeviceFound, offCompassChange, offCopyUrl, offDeviceMotionChange, offError, offGetWifiList, offGyroscopeChange, offHCEMessage, offKeyboardHeightChange, offLocalServiceDiscoveryStop, offLocalServiceFound, offLocalServiceLost, offLocalServiceResolveFail, offLocationChange, offLocationChangeError, offMemoryWarning, offNetworkStatusChange, offNetworkWeakChange, offPageNotFound, offThemeChange, offUnhandledRejection, offUserCaptureScreen, offVoIPChatInterrupted, offVoIPChatMembersChanged, offVoIPChatStateChanged, offVoIPVideoMembersChanged, offWifiConnected, offWindowResize, onAccelerometerChange, onAppHide, onAppShow, onAudioInterruptionBegin, onAudioInterruptionEnd, onBLECharacteristicValueChange, onBLEConnectionStateChange, onBLEMTUChange, onBLEPeripheralConnectionStateChanged, onBackgroundAudioPause, onBackgroundAudioPlay, onBackgroundAudioStop, onBackgroundFetchData, onBeaconServiceChange, onBeaconUpdate, onBluetoothAdapterStateChange, onBluetoothDeviceFound, onCompassChange, onCopyUrl, onDeviceMotionChange, onError, onGetWifiList, onGyroscopeChange, onHCEMessage, onKeyboardHeightChange, onLocalServiceDiscoveryStop, onLocalServiceFound, onLocalServiceLost, onLocalServiceResolveFail, onLocationChange, onLocationChangeError, onMemoryWarning, onNetworkStatusChange, onNetworkWeakChange, onPageNotFound, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onThemeChange, onUnhandledRejection, onUserCaptureScreen, onVoIPChatInterrupted, onVoIPChatMembersChanged, onVoIPChatSpeakersChanged, onVoIPChatStateChanged, onVoIPVideoMembersChanged, onWifiConnected, onWifiConnectedWithPartialInfo, onWindowResize, openAppAuthorizeSetting, openBluetoothAdapter, openBusinessView, openCard, openChannelsActivity, openChannelsEvent, openChannelsLive, openCustomerServiceChat, openDocument, openEmbeddedMiniProgram, openLocation, openSetting, openSystemBluetoothSetting, openVideoEditor, options, pageScrollTo, pauseBackgroundAudio, pauseVoice, plantClassify, playBackgroundAudio, playVoice, pluginLogin, preload, preloadSubPackage, previewImage, previewMedia, pxTransform, readBLECharacteristicValue, removeSavedFile, removeStorage, removeStorageSync, removeTabBarBadge, reportAnalytics, reportEvent, reportMonitor, reportPerformance, request, requestOrderPayment, requestPayment, requestPolymerPayment, requestSubscribeMessage, requirePlugin, reserveChannelsLive, revokeBufferURL, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, seekBackgroundAudio, sendHCEMessage, sendSocketMessage, setBLEMTU, setBackgroundColor, setBackgroundFetchToken, setBackgroundTextStyle, setClipboardData, setEnable1v1Chat, setEnableDebug, setInnerAudioOption, setKeepScreenOn, setNavigationBarColor, setNavigationBarTitle, setPageInfo, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopBarText, setVisualEffectOnCapture, setWifiList, setWindowSize, shareFileMessage, shareToWeRun, shareVideoMessage, showActionSheet, showLoading, showModal, showNavigationBarLoading, showRedPackage, showShareImageMenu, showShareMenu, showTabBar, showTabBarRedDot, showToast, startAccelerometer, startBeaconDiscovery, startBluetoothDevicesDiscovery, startCompass, startDeviceMotionListening, startFacialRecognitionVerify, startFacialRecognitionVerifyAndUploadVideo, startGyroscope, startHCE, startLocalServiceDiscovery, startLocationUpdate, startLocationUpdateBackground, startPullDownRefresh, startRecord, startSoterAuthentication, startWifi, stopAccelerometer, stopBackgroundAudio, stopBeaconDiscovery, stopBluetoothDevicesDiscovery, stopCompass, stopDeviceMotionListening, stopFaceDetect, stopGyroscope, stopHCE, stopLocalServiceDiscovery, stopLocationUpdate, stopPullDownRefresh, stopRecord, stopVoice, stopWifi, subscribeVoIPVideoMembers, textReview, textToAudio, updateShareMenu, updateVoIPChatMuteConfig, updateWeChatApp, uploadFile, vibrateLong, vibrateShort, writeBLECharacteristicValue };
|
|
5443
|
+
export { Behavior, Current, ENV_TYPE, Events, Link, addCard, addFileToFavorites, addInterceptor, addPhoneCalendar, addPhoneContact, addPhoneRepeatCalendar, addVideoToFavorites, advancedGeneralIdentify, animalClassify, arrayBufferToBase64, authPrivateMessage, authorize, authorizeForMiniProgram, base64ToArrayBuffer, canIUse, canIUseWebp, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, carClassify, checkIsOpenAccessibility, checkIsSoterEnrolledInDevice, checkIsSupportFacialRecognition, checkIsSupportSoterAuthentication, checkSession, chooseAddress, chooseContact, chooseImage, chooseInvoice, chooseInvoiceTitle, chooseLicensePlate, chooseLocation, chooseMedia, chooseMessageFile, choosePoi, chooseVideo, clearStorage, clearStorageSync, closeBLEConnection, closeBluetoothAdapter, closeSocket, cloud, compressImage, compressVideo, connectSocket, connectWifi, createAnimation, createAudioContext, createBLEConnection, createBLEPeripheralServer, createBufferURL, createCameraContext, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createInterstitialAd, createLivePlayerContext, createLivePusherContext, createMapContext, createMediaAudioPlayer, createMediaContainer, createMediaQueryObserver, createMediaRecorder, createOffscreenCanvas, createRewardedVideoAd, createSelectorQuery, createTCPSocket, createUDPSocket, createVKSession, createVideoContext, createVideoDecoder, createWebAudioContext, createWorker, taro as default, disableAlertBeforeUnload, dishClassify, downloadFile, enableAlertBeforeUnload, eventCenter, exitMiniProgram, exitVoIPChat, faceDetect, faceVerifyForPay, getAccountInfoSync, getApp, getAppAuthorizeSetting, getAppBaseInfo, getAvailableAudioSources, getBLEDeviceCharacteristics, getBLEDeviceRSSI, getBLEDeviceServices, getBLEMTU, getBackgroundAudioManager, getBackgroundAudioPlayerState, getBackgroundFetchData, getBackgroundFetchToken, getBatteryInfo, getBatteryInfoSync, getBeacons, getBluetoothAdapterState, getBluetoothDevices, getChannelsLiveInfo, getChannelsLiveNoticeInfo, getClipboardData, getConnectedBluetoothDevices, getConnectedWifi, getCurrentInstance, getDeviceInfo, getEnterOptionsSync, getEnv, getExptInfoSync, getExtConfig, getExtConfigSync, getFileInfo, getFileSystemManager, getFuzzyLocation, getGroupEnterInfo, getHCEState, getImageInfo, getLaunchOptionsSync, getLocalIPAddress, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNFCAdapter, getNetworkType, getOpenUserInfo, getPerformance, getRandomValues, getRealtimeLogManager, getRecorderManager, getSavedFileInfo, getSavedFileList, getScreenBrightness, getSelectedTextRange, getSetting, getShareInfo, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSwanId, getSystemInfo, getSystemInfoAsync, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserCryptoManager, getUserInfo, getUserProfile, getVideoInfo, getWeRunData, getWifiList, getWindowInfo, hideHomeButton, hideKeyboard, hideLoading, hideNavigationBarLoading, hideShareMenu, hideTabBar, hideTabBarRedDot, hideToast, imageAudit, initFaceDetect, initPxTransform, initTabBarApis, interceptors, isBluetoothDevicePaired, isVKSupport, joinVoIPChat, loadFontFace, login, logoClassify, makeBluetoothPair, makePhoneCall, navigateBackMiniProgram, navigateBackSmartProgram, navigateToMiniProgram, navigateToSmartGameProgram, navigateToSmartProgram, nextTick, notifyBLECharacteristicValueChange, objectDetectIdentify, ocrBankCard, ocrDrivingLicense, ocrIdCard, ocrVehicleLicense, offAccelerometerChange, offAppHide, offAppShow, offAudioInterruptionBegin, offAudioInterruptionEnd, offBLECharacteristicValueChange, offBLEConnectionStateChange, offBLEMTUChange, offBLEPeripheralConnectionStateChanged, offBeaconServiceChange, offBeaconUpdate, offBluetoothAdapterStateChange, offBluetoothDeviceFound, offCompassChange, offCopyUrl, offDeviceMotionChange, offError, offGetWifiList, offGyroscopeChange, offHCEMessage, offKeyboardHeightChange, offLocalServiceDiscoveryStop, offLocalServiceFound, offLocalServiceLost, offLocalServiceResolveFail, offLocationChange, offLocationChangeError, offMemoryWarning, offNetworkStatusChange, offNetworkWeakChange, offPageNotFound, offThemeChange, offUnhandledRejection, offUserCaptureScreen, offVoIPChatInterrupted, offVoIPChatMembersChanged, offVoIPChatStateChanged, offVoIPVideoMembersChanged, offWifiConnected, offWindowResize, onAccelerometerChange, onAppHide, onAppShow, onAudioInterruptionBegin, onAudioInterruptionEnd, onBLECharacteristicValueChange, onBLEConnectionStateChange, onBLEMTUChange, onBLEPeripheralConnectionStateChanged, onBackgroundAudioPause, onBackgroundAudioPlay, onBackgroundAudioStop, onBackgroundFetchData, onBeaconServiceChange, onBeaconUpdate, onBluetoothAdapterStateChange, onBluetoothDeviceFound, onCompassChange, onCopyUrl, onDeviceMotionChange, onError, onGetWifiList, onGyroscopeChange, onHCEMessage, onKeyboardHeightChange, onLocalServiceDiscoveryStop, onLocalServiceFound, onLocalServiceLost, onLocalServiceResolveFail, onLocationChange, onLocationChangeError, onMemoryWarning, onNetworkStatusChange, onNetworkWeakChange, onPageNotFound, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onThemeChange, onUnhandledRejection, onUserCaptureScreen, onVoIPChatInterrupted, onVoIPChatMembersChanged, onVoIPChatSpeakersChanged, onVoIPChatStateChanged, onVoIPVideoMembersChanged, onWifiConnected, onWifiConnectedWithPartialInfo, onWindowResize, openAppAuthorizeSetting, openBluetoothAdapter, openBusinessView, openCard, openChannelsActivity, openChannelsEvent, openChannelsLive, openCustomerServiceChat, openDocument, openEmbeddedMiniProgram, openLocation, openSetting, openSystemBluetoothSetting, openVideoEditor, options, pageScrollTo, pauseBackgroundAudio, pauseVoice, plantClassify, playBackgroundAudio, playVoice, pluginLogin, preload, preloadSubPackage, previewImage, previewMedia, pxTransform, readBLECharacteristicValue, removeSavedFile, removeStorage, removeStorageSync, removeTabBarBadge, reportAnalytics, reportEvent, reportMonitor, reportPerformance, request, requestOrderPayment, requestPayment, requestPolymerPayment, requestSubscribeMessage, requirePlugin, reserveChannelsLive, revokeBufferURL, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, seekBackgroundAudio, sendHCEMessage, sendSocketMessage, setBLEMTU, setBackgroundColor, setBackgroundFetchToken, setBackgroundTextStyle, setClipboardData, setEnable1v1Chat, setEnableDebug, setInnerAudioOption, setKeepScreenOn, setNavigationBarColor, setNavigationBarTitle, setPageInfo, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopBarText, setVisualEffectOnCapture, setWifiList, setWindowSize, shareFileMessage, shareToWeRun, shareVideoMessage, showActionSheet, showLoading, showModal, showNavigationBarLoading, showRedPackage, showShareImageMenu, showShareMenu, showTabBar, showTabBarRedDot, showToast, startAccelerometer, startBeaconDiscovery, startBluetoothDevicesDiscovery, startCompass, startDeviceMotionListening, startFacialRecognitionVerify, startFacialRecognitionVerifyAndUploadVideo, startGyroscope, startHCE, startLocalServiceDiscovery, startLocationUpdate, startLocationUpdateBackground, startPullDownRefresh, startRecord, startSoterAuthentication, startWifi, stopAccelerometer, stopBackgroundAudio, stopBeaconDiscovery, stopBluetoothDevicesDiscovery, stopCompass, stopDeviceMotionListening, stopFaceDetect, stopGyroscope, stopHCE, stopLocalServiceDiscovery, stopLocationUpdate, stopPullDownRefresh, stopRecord, stopVoice, stopWifi, subscribeVoIPVideoMembers, textReview, textToAudio, updateShareMenu, updateVoIPChatMuteConfig, updateWeChatApp, uploadFile, vibrateLong, vibrateShort, writeBLECharacteristicValue };
|
|
5234
5444
|
//# sourceMappingURL=index.esm.js.map
|