@tarojs/taro-h5 3.5.10 → 3.6.0-beta.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.
Files changed (38) hide show
  1. package/dist/api/device/clipboard.js +2 -1
  2. package/dist/api/location/chooseLocation.js +4 -4
  3. package/dist/api/location/getLocation.js +2 -2
  4. package/dist/api/media/image/chooseImage.js +2 -2
  5. package/dist/api/media/image/getImageInfo.js +2 -2
  6. package/dist/api/media/image/previewImage.js +2 -1
  7. package/dist/api/media/video/index.js +2 -2
  8. package/dist/api/network/request/index.js +9 -8
  9. package/dist/api/network/websocket/index.d.ts +1 -1
  10. package/dist/api/network/websocket/index.js +3 -3
  11. package/dist/api/network/websocket/socketTask.js +7 -6
  12. package/dist/api/taro.js +2 -1
  13. package/dist/api/ui/interaction/index.js +10 -4
  14. package/dist/api/ui/interaction/modal.d.ts +1 -0
  15. package/dist/api/ui/interaction/modal.js +9 -1
  16. package/dist/api/ui/interaction/toast.d.ts +1 -0
  17. package/dist/api/ui/interaction/toast.js +9 -1
  18. package/dist/api/ui/navigation-bar/index.d.ts +1 -1
  19. package/dist/api/ui/pull-down-refresh.js +4 -4
  20. package/dist/api/ui/scroll/index.js +3 -3
  21. package/dist/api/ui/tab-bar.js +16 -16
  22. package/dist/api/wxml/nodesRef.d.ts +1 -0
  23. package/dist/api/wxml/selectorQuery.js +3 -2
  24. package/dist/index.cjs.d.ts +2 -2
  25. package/dist/index.cjs.js +126 -76
  26. package/dist/index.cjs.js.map +1 -1
  27. package/dist/index.esm.d.ts +2 -2
  28. package/dist/index.esm.js +126 -76
  29. package/dist/index.esm.js.map +1 -1
  30. package/dist/taroApis.d.ts +2 -2
  31. package/dist/utils/handler.d.ts +8 -3
  32. package/dist/utils/handler.js +20 -10
  33. package/dist/utils/index.d.ts +5 -0
  34. package/dist/utils/index.js +28 -2
  35. package/dist/utils/valid.d.ts +1 -2
  36. package/dist/utils/valid.js +0 -3
  37. package/package.json +9 -4
  38. package/types/global.d.ts +1 -0
package/dist/index.cjs.js CHANGED
@@ -4,6 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var Taro = require('@tarojs/api');
6
6
  var router = require('@tarojs/router');
7
+ var shared = require('@tarojs/shared');
8
+ var utils = require('@tarojs/router/dist/utils');
7
9
  var runtime = require('@tarojs/runtime');
8
10
  var base64Js = require('base64-js');
9
11
  var navigate = require('@tarojs/router/dist/utils/navigate');
@@ -18,30 +20,38 @@ var jsonpRetry__default = /*#__PURE__*/_interopDefaultLegacy(jsonpRetry);
18
20
 
19
21
  class MethodHandler {
20
22
  constructor({ name, success, fail, complete }) {
23
+ this.isHandlerError = false;
21
24
  this.methodName = name;
22
25
  this.__success = success;
23
26
  this.__fail = fail;
24
27
  this.__complete = complete;
28
+ this.isHandlerError = shared.isFunction(this.__complete) || shared.isFunction(this.__fail);
25
29
  }
26
- success(res = {}, resolve = Promise.resolve.bind(Promise)) {
30
+ success(res = {}, promise = {}) {
27
31
  if (!res.errMsg) {
28
32
  res.errMsg = `${this.methodName}:ok`;
29
33
  }
30
- typeof this.__success === 'function' && this.__success(res);
31
- typeof this.__complete === 'function' && this.__complete(res);
34
+ shared.isFunction(this.__success) && this.__success(res);
35
+ shared.isFunction(this.__complete) && this.__complete(res);
36
+ const { resolve = Promise.resolve.bind(Promise) } = promise;
32
37
  return resolve(res);
33
38
  }
34
- fail(res = {}, reject = Promise.reject.bind(Promise)) {
39
+ fail(res = {}, promise = {}) {
35
40
  if (!res.errMsg) {
36
41
  res.errMsg = `${this.methodName}:fail`;
37
42
  }
38
43
  else {
39
44
  res.errMsg = `${this.methodName}:fail ${res.errMsg}`;
40
45
  }
41
- console.error(res.errMsg);
42
- typeof this.__fail === 'function' && this.__fail(res);
43
- typeof this.__complete === 'function' && this.__complete(res);
44
- return reject(res);
46
+ if (!isProd) {
47
+ console.error(res.errMsg);
48
+ }
49
+ shared.isFunction(this.__fail) && this.__fail(res);
50
+ shared.isFunction(this.__complete) && this.__complete(res);
51
+ const { resolve = Promise.resolve.bind(Promise), reject = Promise.reject.bind(Promise) } = promise;
52
+ return this.isHandlerError
53
+ ? resolve(res)
54
+ : reject(res);
45
55
  }
46
56
  }
47
57
  class CallbackManager {
@@ -85,12 +95,12 @@ class CallbackManager {
85
95
  */
86
96
  this.trigger = (...args) => {
87
97
  this.callbacks.forEach(opt => {
88
- if (typeof opt === 'function') {
98
+ if (shared.isFunction(opt)) {
89
99
  opt(...args);
90
100
  }
91
101
  else {
92
102
  const { callback, ctx } = opt;
93
- typeof callback === 'function' && callback.call(ctx, ...args);
103
+ shared.isFunction(callback) && callback.call(ctx, ...args);
94
104
  }
95
105
  });
96
106
  };
@@ -142,9 +152,6 @@ function debounce(fn, ms = 250, scope) {
142
152
  };
143
153
  }
144
154
 
145
- function isFunction(obj) {
146
- return typeof obj === 'function';
147
- }
148
155
  const VALID_COLOR_REG = /^#[0-9a-fA-F]{6}$/;
149
156
  const isValidColor = (color) => {
150
157
  return VALID_COLOR_REG.test(color);
@@ -286,7 +293,7 @@ function processOpenApi({ name, defaultOptions, standardMethod, formatOptions =
286
293
  // @ts-ignore
287
294
  const targetApi = (_a = window === null || window === void 0 ? void 0 : window.wx) === null || _a === void 0 ? void 0 : _a[name];
288
295
  const opts = formatOptions(Object.assign({}, defaultOptions, options));
289
- if (typeof targetApi === 'function') {
296
+ if (shared.isFunction(targetApi)) {
290
297
  return new Promise((resolve, reject) => {
291
298
  ['fail', 'success', 'complete'].forEach(k => {
292
299
  opts[k] = preRef => {
@@ -303,7 +310,7 @@ function processOpenApi({ name, defaultOptions, standardMethod, formatOptions =
303
310
  });
304
311
  });
305
312
  }
306
- else if (typeof standardMethod === 'function') {
313
+ else if (shared.isFunction(standardMethod)) {
307
314
  return standardMethod(opts);
308
315
  }
309
316
  else {
@@ -311,6 +318,30 @@ function processOpenApi({ name, defaultOptions, standardMethod, formatOptions =
311
318
  }
312
319
  };
313
320
  }
321
+ /**
322
+ * 根据url获取应用的启动页面
323
+ * @returns
324
+ */
325
+ function getLaunchPage() {
326
+ var _a, _b, _c, _d, _e, _f, _g;
327
+ const appConfig = window.__taroAppConfig || {};
328
+ // createPageConfig时根据stack的长度来设置stamp以保证页面path的唯一,此函数是在createPageConfig之前调用,预先设置stamp=1
329
+ const stamp = '?stamp=1';
330
+ let entryPath = '';
331
+ 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') {
332
+ entryPath = location.pathname;
333
+ }
334
+ else {
335
+ entryPath = location.hash.slice(1).split('?')[0];
336
+ }
337
+ const routePath = utils.addLeadingSlash(utils.stripBasename(entryPath, (_c = appConfig.router) === null || _c === void 0 ? void 0 : _c.basename));
338
+ const homePath = utils.addLeadingSlash(utils.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));
339
+ // url上没有指定应用的启动页面时使用homePath
340
+ if (routePath === '/') {
341
+ return homePath + stamp;
342
+ }
343
+ return routePath + stamp;
344
+ }
314
345
 
315
346
  // 广告
316
347
  const createRewardedVideoAd = temporarilyNotSupport('createRewardedVideoAd');
@@ -1466,7 +1497,7 @@ const setClipboardData = ({ data, success, fail, complete }) => __awaiter(void 0
1466
1497
  * iOS < 10 的系统可能无法使用编程方式访问剪贴板,参考:
1467
1498
  * https://stackoverflow.com/questions/34045777/copy-to-clipboard-using-javascript-in-ios/34046084
1468
1499
  */
1469
- if (typeof document.execCommand === 'function') {
1500
+ if (shared.isFunction(document.execCommand)) {
1470
1501
  const textarea = document.createElement('textarea');
1471
1502
  textarea.readOnly = true;
1472
1503
  textarea.value = data;
@@ -1926,9 +1957,9 @@ const getLocationByW3CApi = (options) => {
1926
1957
  /** 调用结果,自动补充 */
1927
1958
  errMsg: ''
1928
1959
  };
1929
- handle.success(result, resolve);
1960
+ handle.success(result, { resolve, reject });
1930
1961
  }, (error) => {
1931
- handle.fail({ errMsg: error.message }, reject);
1962
+ handle.fail({ errMsg: error.message }, { resolve, reject });
1932
1963
  }, positionOptions);
1933
1964
  });
1934
1965
  };
@@ -2026,7 +2057,7 @@ const chooseLocation = ({ success, fail, complete, mapOpts } = {}) => {
2026
2057
  console.warn('chooseLocation api 依赖腾讯地图定位api,需要在 defineConstants 中配置 LOCATION_APIKEY');
2027
2058
  return handle.fail({
2028
2059
  errMsg: 'LOCATION_APIKEY needed'
2029
- }, reject);
2060
+ }, { resolve, reject });
2030
2061
  }
2031
2062
  const onMessage = event => {
2032
2063
  // 接收位置信息,用户选择确认位置点后选点组件会触发该事件,回传用户的位置信息
@@ -2045,14 +2076,14 @@ const chooseLocation = ({ success, fail, complete, mapOpts } = {}) => {
2045
2076
  chooser.remove();
2046
2077
  }, 300);
2047
2078
  if (res) {
2048
- return handle.fail(res, reject);
2079
+ return handle.fail(res, { resolve, reject });
2049
2080
  }
2050
2081
  else {
2051
2082
  if (chooseLocation.latitude && chooseLocation.longitude) {
2052
- return handle.success(chooseLocation, resolve);
2083
+ return handle.success(chooseLocation, { resolve, reject });
2053
2084
  }
2054
2085
  else {
2055
- return handle.fail({}, reject);
2086
+ return handle.fail({}, { resolve, reject });
2056
2087
  }
2057
2088
  }
2058
2089
  }, key, mapOpts);
@@ -2309,12 +2340,12 @@ const getImageInfo = (options) => {
2309
2340
  width: image.naturalWidth,
2310
2341
  height: image.naturalHeight,
2311
2342
  path: getBase64Image(image) || src
2312
- }, resolve);
2343
+ }, { resolve, reject });
2313
2344
  };
2314
2345
  image.onerror = (e) => {
2315
2346
  handle.fail({
2316
2347
  errMsg: e.message
2317
- }, reject);
2348
+ }, { resolve, reject });
2318
2349
  };
2319
2350
  image.src = src;
2320
2351
  });
@@ -2341,7 +2372,7 @@ const previewImage = (options) => __awaiter(void 0, void 0, void 0, function* ()
2341
2372
  item.appendChild(div);
2342
2373
  // Note: 等待图片加载完后返回,会导致轮播被卡住
2343
2374
  resolve(item);
2344
- if (typeof loadFail === 'function') {
2375
+ if (shared.isFunction(loadFail)) {
2345
2376
  image.addEventListener('error', (err) => {
2346
2377
  loadFail({ errMsg: err.message });
2347
2378
  });
@@ -2446,7 +2477,7 @@ const chooseImage = function (options) {
2446
2477
  el.removeAttribute('capture');
2447
2478
  }
2448
2479
  }
2449
- return new Promise(resolve => {
2480
+ return new Promise((resolve, reject) => {
2450
2481
  const TaroMouseEvents = document.createEvent('MouseEvents');
2451
2482
  TaroMouseEvents.initEvent('click', true, true);
2452
2483
  if (el) {
@@ -2465,7 +2496,7 @@ const chooseImage = function (options) {
2465
2496
  (_a = res.tempFilePaths) === null || _a === void 0 ? void 0 : _a.push(url);
2466
2497
  (_b = res.tempFiles) === null || _b === void 0 ? void 0 : _b.push({ path: url, size: item.size, type: item.type, originalFileObj: item });
2467
2498
  });
2468
- handle.success(res, resolve);
2499
+ handle.success(res, { resolve, reject });
2469
2500
  target.value = '';
2470
2501
  }
2471
2502
  };
@@ -2533,7 +2564,7 @@ const chooseVideo = (options) => {
2533
2564
  inputEl.setAttribute('accept', 'video/*');
2534
2565
  inputEl.setAttribute('style', 'position: fixed; top: -4000px; left: -3000px; z-index: -300;');
2535
2566
  document.body.appendChild(inputEl);
2536
- return new Promise(resolve => {
2567
+ return new Promise((resolve, reject) => {
2537
2568
  const TaroMouseEvents = document.createEvent('MouseEvents');
2538
2569
  TaroMouseEvents.initEvent('click', true, true);
2539
2570
  inputEl.dispatchEvent(TaroMouseEvents);
@@ -2554,7 +2585,7 @@ const chooseVideo = (options) => {
2554
2585
  res.size = event.total;
2555
2586
  res.height = videoEl.videoHeight;
2556
2587
  res.width = videoEl.videoHeight;
2557
- return handle.success(res, resolve);
2588
+ return handle.success(res, { resolve, reject });
2558
2589
  };
2559
2590
  };
2560
2591
  if (file) {
@@ -2835,13 +2866,13 @@ function _request(options) {
2835
2866
  .then(data => {
2836
2867
  res.statusCode = 200;
2837
2868
  res.data = data;
2838
- typeof success === 'function' && success(res);
2839
- typeof complete === 'function' && complete(res);
2869
+ shared.isFunction(success) && success(res);
2870
+ shared.isFunction(complete) && complete(res);
2840
2871
  return res;
2841
2872
  })
2842
2873
  .catch(err => {
2843
- typeof fail === 'function' && fail(err);
2844
- typeof complete === 'function' && complete(res);
2874
+ shared.isFunction(fail) && fail(err);
2875
+ shared.isFunction(complete) && complete(res);
2845
2876
  return Promise.reject(err);
2846
2877
  });
2847
2878
  }
@@ -2909,13 +2940,13 @@ function _request(options) {
2909
2940
  })
2910
2941
  .then(data => {
2911
2942
  res.data = data;
2912
- typeof success === 'function' && success(res);
2913
- typeof complete === 'function' && complete(res);
2943
+ shared.isFunction(success) && success(res);
2944
+ shared.isFunction(complete) && complete(res);
2914
2945
  return res;
2915
2946
  })
2916
2947
  .catch(err => {
2917
- typeof fail === 'function' && fail(err);
2918
- typeof complete === 'function' && complete(res);
2948
+ shared.isFunction(fail) && fail(err);
2949
+ shared.isFunction(complete) && complete(res);
2919
2950
  err.statusCode = res.statusCode;
2920
2951
  err.errMsg = err.message;
2921
2952
  return Promise.reject(err);
@@ -3104,14 +3135,14 @@ class SocketTask {
3104
3135
  if (this.readyState !== 1) {
3105
3136
  const res = { errMsg: 'SocketTask.send:fail SocketTask.readState is not OPEN' };
3106
3137
  console.error(res.errMsg);
3107
- typeof fail === 'function' && fail(res);
3108
- typeof complete === 'function' && complete(res);
3138
+ shared.isFunction(fail) && fail(res);
3139
+ shared.isFunction(complete) && complete(res);
3109
3140
  return Promise.reject(res);
3110
3141
  }
3111
3142
  this.ws.send(data);
3112
3143
  const res = { errMsg: 'sendSocketMessage:ok' };
3113
- typeof success === 'function' && success(res);
3114
- typeof complete === 'function' && complete(res);
3144
+ shared.isFunction(success) && success(res);
3145
+ shared.isFunction(complete) && complete(res);
3115
3146
  return Promise.resolve(res);
3116
3147
  }
3117
3148
  close(opts = {}) {
@@ -3123,8 +3154,8 @@ class SocketTask {
3123
3154
  this._destroyWhenClose && this._destroyWhenClose();
3124
3155
  this.ws.close();
3125
3156
  const res = { errMsg: 'closeSocket:ok' };
3126
- typeof success === 'function' && success(res);
3127
- typeof complete === 'function' && complete(res);
3157
+ shared.isFunction(success) && success(res);
3158
+ shared.isFunction(complete) && complete(res);
3128
3159
  return Promise.resolve(res);
3129
3160
  }
3130
3161
  onOpen(func) {
@@ -3182,13 +3213,13 @@ function connectSocket(options) {
3182
3213
  correct: 'String',
3183
3214
  wrong: url
3184
3215
  })
3185
- }, reject);
3216
+ }, { resolve, reject });
3186
3217
  }
3187
3218
  // options.url must be invalid
3188
3219
  if (!url.startsWith('ws://') && !url.startsWith('wss://')) {
3189
3220
  return handle.fail({
3190
3221
  errMsg: `request:fail invalid url "${url}"`
3191
- }, reject);
3222
+ }, { resolve, reject });
3192
3223
  }
3193
3224
  // protocols must be array
3194
3225
  const _protocols = Array.isArray(protocols) ? protocols : null;
@@ -3196,7 +3227,7 @@ function connectSocket(options) {
3196
3227
  if (socketTasks.length > 1) {
3197
3228
  return handle.fail({
3198
3229
  errMsg: '同时最多发起 2 个 socket 请求,更多请参考文档。'
3199
- }, reject);
3230
+ }, { resolve, reject });
3200
3231
  }
3201
3232
  const task = new SocketTask(url, _protocols);
3202
3233
  task._destroyWhenClose = function () {
@@ -3926,6 +3957,7 @@ class Modal {
3926
3957
  }
3927
3958
  create(options = {}) {
3928
3959
  return new Promise((resolve) => {
3960
+ var _a, _b;
3929
3961
  // style
3930
3962
  const { maskStyle, modalStyle, titleStyle, textStyle, footStyle, btnStyle } = this.style;
3931
3963
  // configuration
@@ -3990,10 +4022,13 @@ class Modal {
3990
4022
  // show immediately
3991
4023
  document.body.appendChild(this.el);
3992
4024
  setTimeout(() => { this.el.style.opacity = '1'; }, 0);
4025
+ // Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
4026
+ this.currentPath = (_b = (_a = runtime.Current.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getLaunchPage();
3993
4027
  });
3994
4028
  }
3995
4029
  show(options = {}) {
3996
4030
  return new Promise((resolve) => {
4031
+ var _a, _b;
3997
4032
  const config = Object.assign(Object.assign({}, this.options), options);
3998
4033
  if (this.hideOpacityTimer)
3999
4034
  clearTimeout(this.hideOpacityTimer);
@@ -4037,6 +4072,8 @@ class Modal {
4037
4072
  // show
4038
4073
  this.el.style.display = 'block';
4039
4074
  setTimeout(() => { this.el.style.opacity = '1'; }, 0);
4075
+ // Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
4076
+ this.currentPath = (_b = (_a = runtime.Current.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getLaunchPage();
4040
4077
  });
4041
4078
  }
4042
4079
  hide() {
@@ -4044,6 +4081,7 @@ class Modal {
4044
4081
  clearTimeout(this.hideOpacityTimer);
4045
4082
  if (this.hideDisplayTimer)
4046
4083
  clearTimeout(this.hideDisplayTimer);
4084
+ this.currentPath = null;
4047
4085
  this.hideOpacityTimer = setTimeout(() => {
4048
4086
  this.el.style.opacity = '0';
4049
4087
  this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none'; }, 200);
@@ -4127,6 +4165,7 @@ class Toast {
4127
4165
  };
4128
4166
  }
4129
4167
  create(options = {}, _type = 'toast') {
4168
+ var _a, _b;
4130
4169
  // style
4131
4170
  const { maskStyle, toastStyle, successStyle, errrorStyle, loadingStyle, imageStyle, textStyle } = this.style;
4132
4171
  // configuration
@@ -4170,9 +4209,12 @@ class Toast {
4170
4209
  this.type = config._type;
4171
4210
  // disappear after duration
4172
4211
  config.duration >= 0 && this.hide(config.duration, this.type);
4212
+ // Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
4213
+ this.currentPath = (_b = (_a = runtime.Current.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getLaunchPage();
4173
4214
  return '';
4174
4215
  }
4175
4216
  show(options = {}, _type = 'toast') {
4217
+ var _a, _b;
4176
4218
  const config = Object.assign(Object.assign(Object.assign({}, this.options), options), { _type });
4177
4219
  if (this.hideOpacityTimer)
4178
4220
  clearTimeout(this.hideOpacityTimer);
@@ -4204,6 +4246,8 @@ class Toast {
4204
4246
  this.type = config._type;
4205
4247
  // disappear after duration
4206
4248
  config.duration >= 0 && this.hide(config.duration, this.type);
4249
+ // Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
4250
+ this.currentPath = (_b = (_a = runtime.Current.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getLaunchPage();
4207
4251
  return '';
4208
4252
  }
4209
4253
  hide(duration = 0, type) {
@@ -4213,6 +4257,7 @@ class Toast {
4213
4257
  clearTimeout(this.hideOpacityTimer);
4214
4258
  if (this.hideDisplayTimer)
4215
4259
  clearTimeout(this.hideDisplayTimer);
4260
+ this.currentPath = null;
4216
4261
  this.hideOpacityTimer = setTimeout(() => {
4217
4262
  this.el.style.opacity = '0';
4218
4263
  this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none'; }, 100);
@@ -4474,10 +4519,15 @@ const showActionSheet = (options = { itemList: [] }) => __awaiter(void 0, void 0
4474
4519
  return handle.success(({ tapIndex: result }));
4475
4520
  }
4476
4521
  });
4477
- Taro__default["default"].eventCenter.on('__taroRouterChange', () => {
4478
- hideToast();
4479
- hideLoading();
4480
- hideModal();
4522
+ Taro__default["default"].eventCenter.on('__afterTaroRouterChange', () => {
4523
+ var _a, _b;
4524
+ if (toast.currentPath && toast.currentPath !== ((_a = runtime.Current.page) === null || _a === void 0 ? void 0 : _a.path)) {
4525
+ hideToast();
4526
+ hideLoading();
4527
+ }
4528
+ if (modal.currentPath && modal.currentPath !== ((_b = runtime.Current.page) === null || _b === void 0 ? void 0 : _b.path)) {
4529
+ hideModal();
4530
+ }
4481
4531
  });
4482
4532
  const enableAlertBeforeUnload = temporarilyNotSupport('enableAlertBeforeUnload');
4483
4533
  const disableAlertBeforeUnload = temporarilyNotSupport('disableAlertBeforeUnload');
@@ -4531,8 +4581,8 @@ const startPullDownRefresh = function ({ success, fail, complete } = {}) {
4531
4581
  const handle = new MethodHandler({ name: 'startPullDownRefresh', success, fail, complete });
4532
4582
  return new Promise((resolve, reject) => {
4533
4583
  Taro__default["default"].eventCenter.trigger('__taroStartPullDownRefresh', {
4534
- successHandler: (res = {}) => handle.success(res, resolve),
4535
- errorHandler: (res = {}) => handle.fail(res, reject)
4584
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
4585
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
4536
4586
  });
4537
4587
  });
4538
4588
  };
@@ -4543,8 +4593,8 @@ const stopPullDownRefresh = function ({ success, fail, complete } = {}) {
4543
4593
  const handle = new MethodHandler({ name: 'stopPullDownRefresh', success, fail, complete });
4544
4594
  return new Promise((resolve, reject) => {
4545
4595
  Taro__default["default"].eventCenter.trigger('__taroStopPullDownRefresh', {
4546
- successHandler: (res = {}) => handle.success(res, resolve),
4547
- errorHandler: (res = {}) => handle.fail(res, reject)
4596
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
4597
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
4548
4598
  });
4549
4599
  });
4550
4600
  };
@@ -4563,7 +4613,7 @@ const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300,
4563
4613
  if (scrollTop === undefined && !selector) {
4564
4614
  return handle.fail({
4565
4615
  errMsg: 'scrollTop" 或 "selector" 需要其之一'
4566
- }, reject);
4616
+ }, { resolve, reject });
4567
4617
  }
4568
4618
  const id = (_b = (_a = runtime.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');
4569
4619
  const el = (id
@@ -4617,7 +4667,7 @@ const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300,
4617
4667
  }, FRAME_DURATION);
4618
4668
  }
4619
4669
  else {
4620
- return handle.success({}, resolve);
4670
+ return handle.success({}, { resolve, reject });
4621
4671
  }
4622
4672
  };
4623
4673
  scroll();
@@ -4625,7 +4675,7 @@ const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300,
4625
4675
  catch (e) {
4626
4676
  return handle.fail({
4627
4677
  errMsg: e.message
4628
- }, reject);
4678
+ }, { resolve, reject });
4629
4679
  }
4630
4680
  });
4631
4681
  };
@@ -4662,8 +4712,8 @@ const showTabBarRedDot = (options) => {
4662
4712
  return new Promise((resolve, reject) => {
4663
4713
  Taro__default["default"].eventCenter.trigger('__taroShowTabBarRedDotHandler', {
4664
4714
  index,
4665
- successHandler: (res = {}) => handle.success(res, resolve),
4666
- errorHandler: (res = {}) => handle.fail(res, reject)
4715
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
4716
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
4667
4717
  });
4668
4718
  });
4669
4719
  };
@@ -4692,8 +4742,8 @@ const showTabBar = (options = {}) => {
4692
4742
  return new Promise((resolve, reject) => {
4693
4743
  Taro__default["default"].eventCenter.trigger('__taroShowTabBar', {
4694
4744
  animation,
4695
- successHandler: (res = {}) => handle.success(res, resolve),
4696
- errorHandler: (res = {}) => handle.fail(res, reject)
4745
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
4746
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
4697
4747
  });
4698
4748
  });
4699
4749
  };
@@ -4744,8 +4794,8 @@ const setTabBarStyle = (options = {}) => {
4744
4794
  selectedColor,
4745
4795
  backgroundColor,
4746
4796
  borderStyle,
4747
- successHandler: (res = {}) => handle.success(res, resolve),
4748
- errorHandler: (res = {}) => handle.fail(res, reject)
4797
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
4798
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
4749
4799
  });
4750
4800
  });
4751
4801
  };
@@ -4777,8 +4827,8 @@ const setTabBarItem = (options) => {
4777
4827
  text,
4778
4828
  iconPath,
4779
4829
  selectedIconPath,
4780
- successHandler: (res = {}) => handle.success(res, resolve),
4781
- errorHandler: (res = {}) => handle.fail(res, reject)
4830
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
4831
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
4782
4832
  });
4783
4833
  });
4784
4834
  };
@@ -4817,8 +4867,8 @@ const setTabBarBadge = (options) => {
4817
4867
  Taro__default["default"].eventCenter.trigger('__taroSetTabBarBadge', {
4818
4868
  index,
4819
4869
  text,
4820
- successHandler: (res = {}) => handle.success(res, resolve),
4821
- errorHandler: (res = {}) => handle.fail(res, reject)
4870
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
4871
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
4822
4872
  });
4823
4873
  });
4824
4874
  };
@@ -4847,8 +4897,8 @@ const removeTabBarBadge = (options) => {
4847
4897
  return new Promise((resolve, reject) => {
4848
4898
  Taro__default["default"].eventCenter.trigger('__taroRemoveTabBarBadge', {
4849
4899
  index,
4850
- successHandler: (res = {}) => handle.success(res, resolve),
4851
- errorHandler: (res = {}) => handle.fail(res, reject)
4900
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
4901
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
4852
4902
  });
4853
4903
  });
4854
4904
  };
@@ -4877,8 +4927,8 @@ const hideTabBarRedDot = (options) => {
4877
4927
  return new Promise((resolve, reject) => {
4878
4928
  Taro__default["default"].eventCenter.trigger('__taroHideTabBarRedDotHandler', {
4879
4929
  index,
4880
- successHandler: (res = {}) => handle.success(res, resolve),
4881
- errorHandler: (res = {}) => handle.fail(res, reject)
4930
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
4931
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
4882
4932
  });
4883
4933
  });
4884
4934
  };
@@ -4907,8 +4957,8 @@ const hideTabBar = (options = {}) => {
4907
4957
  return new Promise((resolve, reject) => {
4908
4958
  Taro__default["default"].eventCenter.trigger('__taroHideTabBar', {
4909
4959
  animation,
4910
- successHandler: (res = {}) => handle.success(res, resolve),
4911
- errorHandler: (res = {}) => handle.fail(res, reject)
4960
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
4961
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
4912
4962
  });
4913
4963
  });
4914
4964
  };
@@ -5171,9 +5221,9 @@ class SelectorQuery {
5171
5221
  const _queueCb = this._queueCb;
5172
5222
  res.forEach((item, index) => {
5173
5223
  const cb = _queueCb[index];
5174
- typeof cb === 'function' && cb.call(this, item);
5224
+ shared.isFunction(cb) && cb.call(this, item);
5175
5225
  });
5176
- typeof cb === 'function' && cb.call(this, res);
5226
+ shared.isFunction(cb) && cb.call(this, res);
5177
5227
  });
5178
5228
  return this;
5179
5229
  }
@@ -5221,7 +5271,7 @@ const requirePlugin = permanentlyNotSupport('requirePlugin');
5221
5271
  const pxTransform = function (size) {
5222
5272
  const options = taro.config;
5223
5273
  const baseFontSize = options.baseFontSize || 20;
5224
- const designWidth = ((input = 0) => typeof options.designWidth === 'function'
5274
+ const designWidth = ((input = 0) => shared.isFunction(options.designWidth)
5225
5275
  ? options.designWidth(input)
5226
5276
  : options.designWidth);
5227
5277
  const rootValue = (input = 0) => baseFontSize / options.deviceRatio[designWidth(input)] * 2;