@tarojs/taro-h5 3.5.9 → 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
@@ -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: any): Promise<unknown>;
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: any): Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
689
+ declare function setNavigationBarTitle(options?: Taro.setNavigationBarTitle.Option): Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
690
690
  /**
691
691
  * 设置页面导航条颜色
692
692
  */
package/dist/index.esm.js CHANGED
@@ -1,6 +1,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 = {}, resolve = Promise.resolve.bind(Promise)) {
22
+ success(res = {}, promise = {}) {
19
23
  if (!res.errMsg) {
20
24
  res.errMsg = `${this.methodName}:ok`;
21
25
  }
22
- typeof this.__success === 'function' && this.__success(res);
23
- typeof this.__complete === 'function' && this.__complete(res);
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 = {}, reject = Promise.reject.bind(Promise)) {
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
- console.error(res.errMsg);
34
- typeof this.__fail === 'function' && this.__fail(res);
35
- typeof this.__complete === 'function' && this.__complete(res);
36
- return reject(res);
38
+ if (!isProd) {
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 (typeof opt === 'function') {
90
+ if (isFunction(opt)) {
81
91
  opt(...args);
82
92
  }
83
93
  else {
84
94
  const { callback, ctx } = opt;
85
- typeof callback === 'function' && callback.call(ctx, ...args);
95
+ isFunction(callback) && callback.call(ctx, ...args);
86
96
  }
87
97
  });
88
98
  };
@@ -134,9 +144,6 @@ 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);
@@ -278,7 +285,7 @@ function processOpenApi({ name, defaultOptions, standardMethod, formatOptions =
278
285
  // @ts-ignore
279
286
  const targetApi = (_a = window === null || window === void 0 ? void 0 : window.wx) === null || _a === void 0 ? void 0 : _a[name];
280
287
  const opts = formatOptions(Object.assign({}, defaultOptions, options));
281
- if (typeof targetApi === 'function') {
288
+ if (isFunction(targetApi)) {
282
289
  return new Promise((resolve, reject) => {
283
290
  ['fail', 'success', 'complete'].forEach(k => {
284
291
  opts[k] = preRef => {
@@ -295,7 +302,7 @@ function processOpenApi({ name, defaultOptions, standardMethod, formatOptions =
295
302
  });
296
303
  });
297
304
  }
298
- else if (typeof standardMethod === 'function') {
305
+ else if (isFunction(standardMethod)) {
299
306
  return standardMethod(opts);
300
307
  }
301
308
  else {
@@ -303,6 +310,30 @@ function processOpenApi({ name, defaultOptions, standardMethod, formatOptions =
303
310
  }
304
311
  };
305
312
  }
313
+ /**
314
+ * 根据url获取应用的启动页面
315
+ * @returns
316
+ */
317
+ function getLaunchPage() {
318
+ var _a, _b, _c, _d, _e, _f, _g;
319
+ const appConfig = window.__taroAppConfig || {};
320
+ // createPageConfig时根据stack的长度来设置stamp以保证页面path的唯一,此函数是在createPageConfig之前调用,预先设置stamp=1
321
+ const stamp = '?stamp=1';
322
+ let entryPath = '';
323
+ 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') {
324
+ entryPath = location.pathname;
325
+ }
326
+ else {
327
+ entryPath = location.hash.slice(1).split('?')[0];
328
+ }
329
+ const routePath = addLeadingSlash(stripBasename(entryPath, (_c = appConfig.router) === null || _c === void 0 ? void 0 : _c.basename));
330
+ 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));
331
+ // url上没有指定应用的启动页面时使用homePath
332
+ if (routePath === '/') {
333
+ return homePath + stamp;
334
+ }
335
+ return routePath + stamp;
336
+ }
306
337
 
307
338
  // 广告
308
339
  const createRewardedVideoAd = temporarilyNotSupport('createRewardedVideoAd');
@@ -1458,7 +1489,7 @@ const setClipboardData = ({ data, success, fail, complete }) => __awaiter(void 0
1458
1489
  * iOS < 10 的系统可能无法使用编程方式访问剪贴板,参考:
1459
1490
  * https://stackoverflow.com/questions/34045777/copy-to-clipboard-using-javascript-in-ios/34046084
1460
1491
  */
1461
- if (typeof document.execCommand === 'function') {
1492
+ if (isFunction(document.execCommand)) {
1462
1493
  const textarea = document.createElement('textarea');
1463
1494
  textarea.readOnly = true;
1464
1495
  textarea.value = data;
@@ -1918,9 +1949,9 @@ const getLocationByW3CApi = (options) => {
1918
1949
  /** 调用结果,自动补充 */
1919
1950
  errMsg: ''
1920
1951
  };
1921
- handle.success(result, resolve);
1952
+ handle.success(result, { resolve, reject });
1922
1953
  }, (error) => {
1923
- handle.fail({ errMsg: error.message }, reject);
1954
+ handle.fail({ errMsg: error.message }, { resolve, reject });
1924
1955
  }, positionOptions);
1925
1956
  });
1926
1957
  };
@@ -2018,7 +2049,7 @@ const chooseLocation = ({ success, fail, complete, mapOpts } = {}) => {
2018
2049
  console.warn('chooseLocation api 依赖腾讯地图定位api,需要在 defineConstants 中配置 LOCATION_APIKEY');
2019
2050
  return handle.fail({
2020
2051
  errMsg: 'LOCATION_APIKEY needed'
2021
- }, reject);
2052
+ }, { resolve, reject });
2022
2053
  }
2023
2054
  const onMessage = event => {
2024
2055
  // 接收位置信息,用户选择确认位置点后选点组件会触发该事件,回传用户的位置信息
@@ -2037,14 +2068,14 @@ const chooseLocation = ({ success, fail, complete, mapOpts } = {}) => {
2037
2068
  chooser.remove();
2038
2069
  }, 300);
2039
2070
  if (res) {
2040
- return handle.fail(res, reject);
2071
+ return handle.fail(res, { resolve, reject });
2041
2072
  }
2042
2073
  else {
2043
2074
  if (chooseLocation.latitude && chooseLocation.longitude) {
2044
- return handle.success(chooseLocation, resolve);
2075
+ return handle.success(chooseLocation, { resolve, reject });
2045
2076
  }
2046
2077
  else {
2047
- return handle.fail({}, reject);
2078
+ return handle.fail({}, { resolve, reject });
2048
2079
  }
2049
2080
  }
2050
2081
  }, key, mapOpts);
@@ -2301,12 +2332,12 @@ const getImageInfo = (options) => {
2301
2332
  width: image.naturalWidth,
2302
2333
  height: image.naturalHeight,
2303
2334
  path: getBase64Image(image) || src
2304
- }, resolve);
2335
+ }, { resolve, reject });
2305
2336
  };
2306
2337
  image.onerror = (e) => {
2307
2338
  handle.fail({
2308
2339
  errMsg: e.message
2309
- }, reject);
2340
+ }, { resolve, reject });
2310
2341
  };
2311
2342
  image.src = src;
2312
2343
  });
@@ -2333,7 +2364,7 @@ const previewImage = (options) => __awaiter(void 0, void 0, void 0, function* ()
2333
2364
  item.appendChild(div);
2334
2365
  // Note: 等待图片加载完后返回,会导致轮播被卡住
2335
2366
  resolve(item);
2336
- if (typeof loadFail === 'function') {
2367
+ if (isFunction(loadFail)) {
2337
2368
  image.addEventListener('error', (err) => {
2338
2369
  loadFail({ errMsg: err.message });
2339
2370
  });
@@ -2438,7 +2469,7 @@ const chooseImage = function (options) {
2438
2469
  el.removeAttribute('capture');
2439
2470
  }
2440
2471
  }
2441
- return new Promise(resolve => {
2472
+ return new Promise((resolve, reject) => {
2442
2473
  const TaroMouseEvents = document.createEvent('MouseEvents');
2443
2474
  TaroMouseEvents.initEvent('click', true, true);
2444
2475
  if (el) {
@@ -2457,7 +2488,7 @@ const chooseImage = function (options) {
2457
2488
  (_a = res.tempFilePaths) === null || _a === void 0 ? void 0 : _a.push(url);
2458
2489
  (_b = res.tempFiles) === null || _b === void 0 ? void 0 : _b.push({ path: url, size: item.size, type: item.type, originalFileObj: item });
2459
2490
  });
2460
- handle.success(res, resolve);
2491
+ handle.success(res, { resolve, reject });
2461
2492
  target.value = '';
2462
2493
  }
2463
2494
  };
@@ -2525,7 +2556,7 @@ const chooseVideo = (options) => {
2525
2556
  inputEl.setAttribute('accept', 'video/*');
2526
2557
  inputEl.setAttribute('style', 'position: fixed; top: -4000px; left: -3000px; z-index: -300;');
2527
2558
  document.body.appendChild(inputEl);
2528
- return new Promise(resolve => {
2559
+ return new Promise((resolve, reject) => {
2529
2560
  const TaroMouseEvents = document.createEvent('MouseEvents');
2530
2561
  TaroMouseEvents.initEvent('click', true, true);
2531
2562
  inputEl.dispatchEvent(TaroMouseEvents);
@@ -2546,7 +2577,7 @@ const chooseVideo = (options) => {
2546
2577
  res.size = event.total;
2547
2578
  res.height = videoEl.videoHeight;
2548
2579
  res.width = videoEl.videoHeight;
2549
- return handle.success(res, resolve);
2580
+ return handle.success(res, { resolve, reject });
2550
2581
  };
2551
2582
  };
2552
2583
  if (file) {
@@ -2827,13 +2858,13 @@ function _request(options) {
2827
2858
  .then(data => {
2828
2859
  res.statusCode = 200;
2829
2860
  res.data = data;
2830
- typeof success === 'function' && success(res);
2831
- typeof complete === 'function' && complete(res);
2861
+ isFunction(success) && success(res);
2862
+ isFunction(complete) && complete(res);
2832
2863
  return res;
2833
2864
  })
2834
2865
  .catch(err => {
2835
- typeof fail === 'function' && fail(err);
2836
- typeof complete === 'function' && complete(res);
2866
+ isFunction(fail) && fail(err);
2867
+ isFunction(complete) && complete(res);
2837
2868
  return Promise.reject(err);
2838
2869
  });
2839
2870
  }
@@ -2901,13 +2932,13 @@ function _request(options) {
2901
2932
  })
2902
2933
  .then(data => {
2903
2934
  res.data = data;
2904
- typeof success === 'function' && success(res);
2905
- typeof complete === 'function' && complete(res);
2935
+ isFunction(success) && success(res);
2936
+ isFunction(complete) && complete(res);
2906
2937
  return res;
2907
2938
  })
2908
2939
  .catch(err => {
2909
- typeof fail === 'function' && fail(err);
2910
- typeof complete === 'function' && complete(res);
2940
+ isFunction(fail) && fail(err);
2941
+ isFunction(complete) && complete(res);
2911
2942
  err.statusCode = res.statusCode;
2912
2943
  err.errMsg = err.message;
2913
2944
  return Promise.reject(err);
@@ -3096,14 +3127,14 @@ class SocketTask {
3096
3127
  if (this.readyState !== 1) {
3097
3128
  const res = { errMsg: 'SocketTask.send:fail SocketTask.readState is not OPEN' };
3098
3129
  console.error(res.errMsg);
3099
- typeof fail === 'function' && fail(res);
3100
- typeof complete === 'function' && complete(res);
3130
+ isFunction(fail) && fail(res);
3131
+ isFunction(complete) && complete(res);
3101
3132
  return Promise.reject(res);
3102
3133
  }
3103
3134
  this.ws.send(data);
3104
3135
  const res = { errMsg: 'sendSocketMessage:ok' };
3105
- typeof success === 'function' && success(res);
3106
- typeof complete === 'function' && complete(res);
3136
+ isFunction(success) && success(res);
3137
+ isFunction(complete) && complete(res);
3107
3138
  return Promise.resolve(res);
3108
3139
  }
3109
3140
  close(opts = {}) {
@@ -3115,8 +3146,8 @@ class SocketTask {
3115
3146
  this._destroyWhenClose && this._destroyWhenClose();
3116
3147
  this.ws.close();
3117
3148
  const res = { errMsg: 'closeSocket:ok' };
3118
- typeof success === 'function' && success(res);
3119
- typeof complete === 'function' && complete(res);
3149
+ isFunction(success) && success(res);
3150
+ isFunction(complete) && complete(res);
3120
3151
  return Promise.resolve(res);
3121
3152
  }
3122
3153
  onOpen(func) {
@@ -3174,13 +3205,13 @@ function connectSocket(options) {
3174
3205
  correct: 'String',
3175
3206
  wrong: url
3176
3207
  })
3177
- }, reject);
3208
+ }, { resolve, reject });
3178
3209
  }
3179
3210
  // options.url must be invalid
3180
3211
  if (!url.startsWith('ws://') && !url.startsWith('wss://')) {
3181
3212
  return handle.fail({
3182
3213
  errMsg: `request:fail invalid url "${url}"`
3183
- }, reject);
3214
+ }, { resolve, reject });
3184
3215
  }
3185
3216
  // protocols must be array
3186
3217
  const _protocols = Array.isArray(protocols) ? protocols : null;
@@ -3188,7 +3219,7 @@ function connectSocket(options) {
3188
3219
  if (socketTasks.length > 1) {
3189
3220
  return handle.fail({
3190
3221
  errMsg: '同时最多发起 2 个 socket 请求,更多请参考文档。'
3191
- }, reject);
3222
+ }, { resolve, reject });
3192
3223
  }
3193
3224
  const task = new SocketTask(url, _protocols);
3194
3225
  task._destroyWhenClose = function () {
@@ -3918,6 +3949,7 @@ class Modal {
3918
3949
  }
3919
3950
  create(options = {}) {
3920
3951
  return new Promise((resolve) => {
3952
+ var _a, _b;
3921
3953
  // style
3922
3954
  const { maskStyle, modalStyle, titleStyle, textStyle, footStyle, btnStyle } = this.style;
3923
3955
  // configuration
@@ -3982,10 +4014,13 @@ class Modal {
3982
4014
  // show immediately
3983
4015
  document.body.appendChild(this.el);
3984
4016
  setTimeout(() => { this.el.style.opacity = '1'; }, 0);
4017
+ // Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
4018
+ this.currentPath = (_b = (_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getLaunchPage();
3985
4019
  });
3986
4020
  }
3987
4021
  show(options = {}) {
3988
4022
  return new Promise((resolve) => {
4023
+ var _a, _b;
3989
4024
  const config = Object.assign(Object.assign({}, this.options), options);
3990
4025
  if (this.hideOpacityTimer)
3991
4026
  clearTimeout(this.hideOpacityTimer);
@@ -4029,6 +4064,8 @@ class Modal {
4029
4064
  // show
4030
4065
  this.el.style.display = 'block';
4031
4066
  setTimeout(() => { this.el.style.opacity = '1'; }, 0);
4067
+ // Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
4068
+ this.currentPath = (_b = (_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getLaunchPage();
4032
4069
  });
4033
4070
  }
4034
4071
  hide() {
@@ -4036,6 +4073,7 @@ class Modal {
4036
4073
  clearTimeout(this.hideOpacityTimer);
4037
4074
  if (this.hideDisplayTimer)
4038
4075
  clearTimeout(this.hideDisplayTimer);
4076
+ this.currentPath = null;
4039
4077
  this.hideOpacityTimer = setTimeout(() => {
4040
4078
  this.el.style.opacity = '0';
4041
4079
  this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none'; }, 200);
@@ -4119,6 +4157,7 @@ class Toast {
4119
4157
  };
4120
4158
  }
4121
4159
  create(options = {}, _type = 'toast') {
4160
+ var _a, _b;
4122
4161
  // style
4123
4162
  const { maskStyle, toastStyle, successStyle, errrorStyle, loadingStyle, imageStyle, textStyle } = this.style;
4124
4163
  // configuration
@@ -4162,9 +4201,12 @@ class Toast {
4162
4201
  this.type = config._type;
4163
4202
  // disappear after duration
4164
4203
  config.duration >= 0 && this.hide(config.duration, this.type);
4204
+ // Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
4205
+ this.currentPath = (_b = (_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getLaunchPage();
4165
4206
  return '';
4166
4207
  }
4167
4208
  show(options = {}, _type = 'toast') {
4209
+ var _a, _b;
4168
4210
  const config = Object.assign(Object.assign(Object.assign({}, this.options), options), { _type });
4169
4211
  if (this.hideOpacityTimer)
4170
4212
  clearTimeout(this.hideOpacityTimer);
@@ -4196,6 +4238,8 @@ class Toast {
4196
4238
  this.type = config._type;
4197
4239
  // disappear after duration
4198
4240
  config.duration >= 0 && this.hide(config.duration, this.type);
4241
+ // Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
4242
+ this.currentPath = (_b = (_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getLaunchPage();
4199
4243
  return '';
4200
4244
  }
4201
4245
  hide(duration = 0, type) {
@@ -4205,6 +4249,7 @@ class Toast {
4205
4249
  clearTimeout(this.hideOpacityTimer);
4206
4250
  if (this.hideDisplayTimer)
4207
4251
  clearTimeout(this.hideDisplayTimer);
4252
+ this.currentPath = null;
4208
4253
  this.hideOpacityTimer = setTimeout(() => {
4209
4254
  this.el.style.opacity = '0';
4210
4255
  this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none'; }, 100);
@@ -4466,10 +4511,15 @@ const showActionSheet = (options = { itemList: [] }) => __awaiter(void 0, void 0
4466
4511
  return handle.success(({ tapIndex: result }));
4467
4512
  }
4468
4513
  });
4469
- Taro.eventCenter.on('__taroRouterChange', () => {
4470
- hideToast();
4471
- hideLoading();
4472
- hideModal();
4514
+ Taro.eventCenter.on('__afterTaroRouterChange', () => {
4515
+ var _a, _b;
4516
+ if (toast.currentPath && toast.currentPath !== ((_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path)) {
4517
+ hideToast();
4518
+ hideLoading();
4519
+ }
4520
+ if (modal.currentPath && modal.currentPath !== ((_b = Current$1.page) === null || _b === void 0 ? void 0 : _b.path)) {
4521
+ hideModal();
4522
+ }
4473
4523
  });
4474
4524
  const enableAlertBeforeUnload = temporarilyNotSupport('enableAlertBeforeUnload');
4475
4525
  const disableAlertBeforeUnload = temporarilyNotSupport('disableAlertBeforeUnload');
@@ -4523,8 +4573,8 @@ const startPullDownRefresh = function ({ success, fail, complete } = {}) {
4523
4573
  const handle = new MethodHandler({ name: 'startPullDownRefresh', success, fail, complete });
4524
4574
  return new Promise((resolve, reject) => {
4525
4575
  Taro.eventCenter.trigger('__taroStartPullDownRefresh', {
4526
- successHandler: (res = {}) => handle.success(res, resolve),
4527
- errorHandler: (res = {}) => handle.fail(res, reject)
4576
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
4577
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
4528
4578
  });
4529
4579
  });
4530
4580
  };
@@ -4535,8 +4585,8 @@ const stopPullDownRefresh = function ({ success, fail, complete } = {}) {
4535
4585
  const handle = new MethodHandler({ name: 'stopPullDownRefresh', success, fail, complete });
4536
4586
  return new Promise((resolve, reject) => {
4537
4587
  Taro.eventCenter.trigger('__taroStopPullDownRefresh', {
4538
- successHandler: (res = {}) => handle.success(res, resolve),
4539
- errorHandler: (res = {}) => handle.fail(res, reject)
4588
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
4589
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
4540
4590
  });
4541
4591
  });
4542
4592
  };
@@ -4555,7 +4605,7 @@ const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300,
4555
4605
  if (scrollTop === undefined && !selector) {
4556
4606
  return handle.fail({
4557
4607
  errMsg: 'scrollTop" 或 "selector" 需要其之一'
4558
- }, reject);
4608
+ }, { resolve, reject });
4559
4609
  }
4560
4610
  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
4611
  const el = (id
@@ -4609,7 +4659,7 @@ const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300,
4609
4659
  }, FRAME_DURATION);
4610
4660
  }
4611
4661
  else {
4612
- return handle.success({}, resolve);
4662
+ return handle.success({}, { resolve, reject });
4613
4663
  }
4614
4664
  };
4615
4665
  scroll();
@@ -4617,7 +4667,7 @@ const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300,
4617
4667
  catch (e) {
4618
4668
  return handle.fail({
4619
4669
  errMsg: e.message
4620
- }, reject);
4670
+ }, { resolve, reject });
4621
4671
  }
4622
4672
  });
4623
4673
  };
@@ -4654,8 +4704,8 @@ const showTabBarRedDot = (options) => {
4654
4704
  return new Promise((resolve, reject) => {
4655
4705
  Taro.eventCenter.trigger('__taroShowTabBarRedDotHandler', {
4656
4706
  index,
4657
- successHandler: (res = {}) => handle.success(res, resolve),
4658
- errorHandler: (res = {}) => handle.fail(res, reject)
4707
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
4708
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
4659
4709
  });
4660
4710
  });
4661
4711
  };
@@ -4684,8 +4734,8 @@ const showTabBar = (options = {}) => {
4684
4734
  return new Promise((resolve, reject) => {
4685
4735
  Taro.eventCenter.trigger('__taroShowTabBar', {
4686
4736
  animation,
4687
- successHandler: (res = {}) => handle.success(res, resolve),
4688
- errorHandler: (res = {}) => handle.fail(res, reject)
4737
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
4738
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
4689
4739
  });
4690
4740
  });
4691
4741
  };
@@ -4736,8 +4786,8 @@ const setTabBarStyle = (options = {}) => {
4736
4786
  selectedColor,
4737
4787
  backgroundColor,
4738
4788
  borderStyle,
4739
- successHandler: (res = {}) => handle.success(res, resolve),
4740
- errorHandler: (res = {}) => handle.fail(res, reject)
4789
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
4790
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
4741
4791
  });
4742
4792
  });
4743
4793
  };
@@ -4769,8 +4819,8 @@ const setTabBarItem = (options) => {
4769
4819
  text,
4770
4820
  iconPath,
4771
4821
  selectedIconPath,
4772
- successHandler: (res = {}) => handle.success(res, resolve),
4773
- errorHandler: (res = {}) => handle.fail(res, reject)
4822
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
4823
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
4774
4824
  });
4775
4825
  });
4776
4826
  };
@@ -4809,8 +4859,8 @@ const setTabBarBadge = (options) => {
4809
4859
  Taro.eventCenter.trigger('__taroSetTabBarBadge', {
4810
4860
  index,
4811
4861
  text,
4812
- successHandler: (res = {}) => handle.success(res, resolve),
4813
- errorHandler: (res = {}) => handle.fail(res, reject)
4862
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
4863
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
4814
4864
  });
4815
4865
  });
4816
4866
  };
@@ -4839,8 +4889,8 @@ const removeTabBarBadge = (options) => {
4839
4889
  return new Promise((resolve, reject) => {
4840
4890
  Taro.eventCenter.trigger('__taroRemoveTabBarBadge', {
4841
4891
  index,
4842
- successHandler: (res = {}) => handle.success(res, resolve),
4843
- errorHandler: (res = {}) => handle.fail(res, reject)
4892
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
4893
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
4844
4894
  });
4845
4895
  });
4846
4896
  };
@@ -4869,8 +4919,8 @@ const hideTabBarRedDot = (options) => {
4869
4919
  return new Promise((resolve, reject) => {
4870
4920
  Taro.eventCenter.trigger('__taroHideTabBarRedDotHandler', {
4871
4921
  index,
4872
- successHandler: (res = {}) => handle.success(res, resolve),
4873
- errorHandler: (res = {}) => handle.fail(res, reject)
4922
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
4923
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
4874
4924
  });
4875
4925
  });
4876
4926
  };
@@ -4899,8 +4949,8 @@ const hideTabBar = (options = {}) => {
4899
4949
  return new Promise((resolve, reject) => {
4900
4950
  Taro.eventCenter.trigger('__taroHideTabBar', {
4901
4951
  animation,
4902
- successHandler: (res = {}) => handle.success(res, resolve),
4903
- errorHandler: (res = {}) => handle.fail(res, reject)
4952
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
4953
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
4904
4954
  });
4905
4955
  });
4906
4956
  };
@@ -5163,9 +5213,9 @@ class SelectorQuery {
5163
5213
  const _queueCb = this._queueCb;
5164
5214
  res.forEach((item, index) => {
5165
5215
  const cb = _queueCb[index];
5166
- typeof cb === 'function' && cb.call(this, item);
5216
+ isFunction(cb) && cb.call(this, item);
5167
5217
  });
5168
- typeof cb === 'function' && cb.call(this, res);
5218
+ isFunction(cb) && cb.call(this, res);
5169
5219
  });
5170
5220
  return this;
5171
5221
  }
@@ -5213,7 +5263,7 @@ const requirePlugin = permanentlyNotSupport('requirePlugin');
5213
5263
  const pxTransform = function (size) {
5214
5264
  const options = taro.config;
5215
5265
  const baseFontSize = options.baseFontSize || 20;
5216
- const designWidth = ((input = 0) => typeof options.designWidth === 'function'
5266
+ const designWidth = ((input = 0) => isFunction(options.designWidth)
5217
5267
  ? options.designWidth(input)
5218
5268
  : options.designWidth);
5219
5269
  const rootValue = (input = 0) => baseFontSize / options.deviceRatio[designWidth(input)] * 2;