@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.
Files changed (45) 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/IntersectionObserver.d.ts +20 -0
  23. package/dist/api/wxml/IntersectionObserver.js +104 -0
  24. package/dist/api/wxml/MediaQueryObserver.d.ts +7 -0
  25. package/dist/api/wxml/MediaQueryObserver.js +50 -0
  26. package/dist/api/wxml/index.d.ts +2 -1
  27. package/dist/api/wxml/index.js +8 -2
  28. package/dist/api/wxml/nodesRef.d.ts +1 -0
  29. package/dist/api/wxml/selectorQuery.js +3 -2
  30. package/dist/index.cjs.d.ts +5 -4
  31. package/dist/index.cjs.js +310 -81
  32. package/dist/index.cjs.js.map +1 -1
  33. package/dist/index.esm.d.ts +5 -4
  34. package/dist/index.esm.js +292 -82
  35. package/dist/index.esm.js.map +1 -1
  36. package/dist/taroApis.d.ts +5 -4
  37. package/dist/taroApis.js +1 -1
  38. package/dist/utils/handler.d.ts +8 -3
  39. package/dist/utils/handler.js +19 -10
  40. package/dist/utils/index.d.ts +6 -1
  41. package/dist/utils/index.js +34 -6
  42. package/dist/utils/valid.d.ts +1 -2
  43. package/dist/utils/valid.js +0 -3
  44. package/package.json +14 -5
  45. package/types/global.d.ts +1 -0
@@ -13,6 +13,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
13
13
  step((generator = generator.apply(thisArg, _arguments || [])).next());
14
14
  });
15
15
  };
16
+ import { isFunction } from '@tarojs/shared';
16
17
  import { MethodHandler } from '../../utils/handler';
17
18
  import { getStorageSync, setStorage, setStorageSync } from '../storage/index';
18
19
  const CLIPBOARD_STORAGE_NAME = 'taro_clipboard';
@@ -37,7 +38,7 @@ export const setClipboardData = ({ data, success, fail, complete }) => __awaiter
37
38
  * iOS < 10 的系统可能无法使用编程方式访问剪贴板,参考:
38
39
  * https://stackoverflow.com/questions/34045777/copy-to-clipboard-using-javascript-in-ios/34046084
39
40
  */
40
- if (typeof document.execCommand === 'function') {
41
+ if (isFunction(document.execCommand)) {
41
42
  const textarea = document.createElement('textarea');
42
43
  textarea.readOnly = true;
43
44
  textarea.value = data;
@@ -70,7 +70,7 @@ export const chooseLocation = ({ success, fail, complete, mapOpts } = {}) => {
70
70
  console.warn('chooseLocation api 依赖腾讯地图定位api,需要在 defineConstants 中配置 LOCATION_APIKEY');
71
71
  return handle.fail({
72
72
  errMsg: 'LOCATION_APIKEY needed'
73
- }, reject);
73
+ }, { resolve, reject });
74
74
  }
75
75
  const onMessage = event => {
76
76
  // 接收位置信息,用户选择确认位置点后选点组件会触发该事件,回传用户的位置信息
@@ -89,14 +89,14 @@ export const chooseLocation = ({ success, fail, complete, mapOpts } = {}) => {
89
89
  chooser.remove();
90
90
  }, 300);
91
91
  if (res) {
92
- return handle.fail(res, reject);
92
+ return handle.fail(res, { resolve, reject });
93
93
  }
94
94
  else {
95
95
  if (chooseLocation.latitude && chooseLocation.longitude) {
96
- return handle.success(chooseLocation, resolve);
96
+ return handle.success(chooseLocation, { resolve, reject });
97
97
  }
98
98
  else {
99
- return handle.fail({}, reject);
99
+ return handle.fail({}, { resolve, reject });
100
100
  }
101
101
  }
102
102
  }, key, mapOpts);
@@ -52,9 +52,9 @@ const getLocationByW3CApi = (options) => {
52
52
  /** 调用结果,自动补充 */
53
53
  errMsg: ''
54
54
  };
55
- handle.success(result, resolve);
55
+ handle.success(result, { resolve, reject });
56
56
  }, (error) => {
57
- handle.fail({ errMsg: error.message }, reject);
57
+ handle.fail({ errMsg: error.message }, { resolve, reject });
58
58
  }, positionOptions);
59
59
  });
60
60
  };
@@ -57,7 +57,7 @@ export const chooseImage = function (options) {
57
57
  el.removeAttribute('capture');
58
58
  }
59
59
  }
60
- return new Promise(resolve => {
60
+ return new Promise((resolve, reject) => {
61
61
  const TaroMouseEvents = document.createEvent('MouseEvents');
62
62
  TaroMouseEvents.initEvent('click', true, true);
63
63
  if (el) {
@@ -76,7 +76,7 @@ export const chooseImage = function (options) {
76
76
  (_a = res.tempFilePaths) === null || _a === void 0 ? void 0 : _a.push(url);
77
77
  (_b = res.tempFiles) === null || _b === void 0 ? void 0 : _b.push({ path: url, size: item.size, type: item.type, originalFileObj: item });
78
78
  });
79
- handle.success(res, resolve);
79
+ handle.success(res, { resolve, reject });
80
80
  target.value = '';
81
81
  }
82
82
  };
@@ -34,12 +34,12 @@ export const getImageInfo = (options) => {
34
34
  width: image.naturalWidth,
35
35
  height: image.naturalHeight,
36
36
  path: getBase64Image(image) || src
37
- }, resolve);
37
+ }, { resolve, reject });
38
38
  };
39
39
  image.onerror = (e) => {
40
40
  handle.fail({
41
41
  errMsg: e.message
42
- }, reject);
42
+ }, { resolve, reject });
43
43
  };
44
44
  image.src = src;
45
45
  });
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ import { isFunction } from '@tarojs/shared';
10
11
  import { shouldBeObject } from '../../../utils';
11
12
  import { MethodHandler } from '../../../utils/handler';
12
13
  /**
@@ -30,7 +31,7 @@ export const previewImage = (options) => __awaiter(void 0, void 0, void 0, funct
30
31
  item.appendChild(div);
31
32
  // Note: 等待图片加载完后返回,会导致轮播被卡住
32
33
  resolve(item);
33
- if (typeof loadFail === 'function') {
34
+ if (isFunction(loadFail)) {
34
35
  image.addEventListener('error', (err) => {
35
36
  loadFail({ errMsg: err.message });
36
37
  });
@@ -39,7 +39,7 @@ export const chooseVideo = (options) => {
39
39
  inputEl.setAttribute('accept', 'video/*');
40
40
  inputEl.setAttribute('style', 'position: fixed; top: -4000px; left: -3000px; z-index: -300;');
41
41
  document.body.appendChild(inputEl);
42
- return new Promise(resolve => {
42
+ return new Promise((resolve, reject) => {
43
43
  const TaroMouseEvents = document.createEvent('MouseEvents');
44
44
  TaroMouseEvents.initEvent('click', true, true);
45
45
  inputEl.dispatchEvent(TaroMouseEvents);
@@ -60,7 +60,7 @@ export const chooseVideo = (options) => {
60
60
  res.size = event.total;
61
61
  res.height = videoEl.videoHeight;
62
62
  res.width = videoEl.videoHeight;
63
- return handle.success(res, resolve);
63
+ return handle.success(res, { resolve, reject });
64
64
  };
65
65
  };
66
66
  if (file) {
@@ -1,5 +1,6 @@
1
1
  import 'whatwg-fetch';
2
2
  import Taro from '@tarojs/api';
3
+ import { isFunction } from '@tarojs/shared';
3
4
  import jsonpRetry from 'jsonp-retry';
4
5
  import { serializeParams } from '../../../utils';
5
6
  // @ts-ignore
@@ -36,13 +37,13 @@ function _request(options) {
36
37
  .then(data => {
37
38
  res.statusCode = 200;
38
39
  res.data = data;
39
- typeof success === 'function' && success(res);
40
- typeof complete === 'function' && complete(res);
40
+ isFunction(success) && success(res);
41
+ isFunction(complete) && complete(res);
41
42
  return res;
42
43
  })
43
44
  .catch(err => {
44
- typeof fail === 'function' && fail(err);
45
- typeof complete === 'function' && complete(res);
45
+ isFunction(fail) && fail(err);
46
+ isFunction(complete) && complete(res);
46
47
  return Promise.reject(err);
47
48
  });
48
49
  }
@@ -110,13 +111,13 @@ function _request(options) {
110
111
  })
111
112
  .then(data => {
112
113
  res.data = data;
113
- typeof success === 'function' && success(res);
114
- typeof complete === 'function' && complete(res);
114
+ isFunction(success) && success(res);
115
+ isFunction(complete) && complete(res);
115
116
  return res;
116
117
  })
117
118
  .catch(err => {
118
- typeof fail === 'function' && fail(err);
119
- typeof complete === 'function' && complete(res);
119
+ isFunction(fail) && fail(err);
120
+ isFunction(complete) && complete(res);
120
121
  err.statusCode = res.statusCode;
121
122
  err.errMsg = err.message;
122
123
  return Promise.reject(err);
@@ -3,5 +3,5 @@ export declare function onSocketOpen(): void;
3
3
  export declare function onSocketMessage(): void;
4
4
  export declare function onSocketError(): void;
5
5
  export declare function onSocketClose(): void;
6
- export declare function connectSocket(options: any): Promise<unknown>;
6
+ export declare function connectSocket(options?: Taro.connectSocket.Option): Promise<unknown>;
7
7
  export declare function closeSocket(): void;
@@ -38,13 +38,13 @@ export function connectSocket(options) {
38
38
  correct: 'String',
39
39
  wrong: url
40
40
  })
41
- }, reject);
41
+ }, { resolve, reject });
42
42
  }
43
43
  // options.url must be invalid
44
44
  if (!url.startsWith('ws://') && !url.startsWith('wss://')) {
45
45
  return handle.fail({
46
46
  errMsg: `request:fail invalid url "${url}"`
47
- }, reject);
47
+ }, { resolve, reject });
48
48
  }
49
49
  // protocols must be array
50
50
  const _protocols = Array.isArray(protocols) ? protocols : null;
@@ -52,7 +52,7 @@ export function connectSocket(options) {
52
52
  if (socketTasks.length > 1) {
53
53
  return handle.fail({
54
54
  errMsg: '同时最多发起 2 个 socket 请求,更多请参考文档。'
55
- }, reject);
55
+ }, { resolve, reject });
56
56
  }
57
57
  const task = new SocketTask(url, _protocols);
58
58
  task._destroyWhenClose = function () {
@@ -1,3 +1,4 @@
1
+ import { isFunction } from '@tarojs/shared';
1
2
  export class SocketTask {
2
3
  constructor(url, protocols) {
3
4
  if (protocols && protocols.length) {
@@ -21,14 +22,14 @@ export class SocketTask {
21
22
  if (this.readyState !== 1) {
22
23
  const res = { errMsg: 'SocketTask.send:fail SocketTask.readState is not OPEN' };
23
24
  console.error(res.errMsg);
24
- typeof fail === 'function' && fail(res);
25
- typeof complete === 'function' && complete(res);
25
+ isFunction(fail) && fail(res);
26
+ isFunction(complete) && complete(res);
26
27
  return Promise.reject(res);
27
28
  }
28
29
  this.ws.send(data);
29
30
  const res = { errMsg: 'sendSocketMessage:ok' };
30
- typeof success === 'function' && success(res);
31
- typeof complete === 'function' && complete(res);
31
+ isFunction(success) && success(res);
32
+ isFunction(complete) && complete(res);
32
33
  return Promise.resolve(res);
33
34
  }
34
35
  close(opts = {}) {
@@ -40,8 +41,8 @@ export class SocketTask {
40
41
  this._destroyWhenClose && this._destroyWhenClose();
41
42
  this.ws.close();
42
43
  const res = { errMsg: 'closeSocket:ok' };
43
- typeof success === 'function' && success(res);
44
- typeof complete === 'function' && complete(res);
44
+ isFunction(success) && success(res);
45
+ isFunction(complete) && complete(res);
45
46
  return Promise.resolve(res);
46
47
  }
47
48
  onOpen(func) {
package/dist/api/taro.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import Taro from '@tarojs/api';
2
2
  import { history } from '@tarojs/router';
3
+ import { isFunction } from '@tarojs/shared';
3
4
  import { getApp, getCurrentInstance, getCurrentPages, navigateBack, navigateTo, nextTick, redirectTo, reLaunch, switchTab } from '../api';
4
5
  import { permanentlyNotSupport } from '../utils';
5
6
  const { Behavior, getEnv, ENV_TYPE, Link, interceptors, getInitPxTransform, Current, options, eventCenter, Events, preload } = Taro;
@@ -30,7 +31,7 @@ const requirePlugin = permanentlyNotSupport('requirePlugin');
30
31
  const pxTransform = function (size) {
31
32
  const options = taro.config;
32
33
  const baseFontSize = options.baseFontSize || 20;
33
- const designWidth = ((input = 0) => typeof options.designWidth === 'function'
34
+ const designWidth = ((input = 0) => isFunction(options.designWidth)
34
35
  ? options.designWidth(input)
35
36
  : options.designWidth);
36
37
  const rootValue = (input = 0) => baseFontSize / options.deviceRatio[designWidth(input)] * 2;
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import Taro from '@tarojs/api';
11
+ import { Current } from '@tarojs/runtime';
11
12
  import { getParameterError, temporarilyNotSupport } from '../../../utils';
12
13
  import { MethodHandler } from '../../../utils/handler';
13
14
  import ActionSheet from './actionSheet';
@@ -267,10 +268,15 @@ const showActionSheet = (options = { itemList: [] }) => __awaiter(void 0, void 0
267
268
  return handle.success(({ tapIndex: result }));
268
269
  }
269
270
  });
270
- Taro.eventCenter.on('__taroRouterChange', () => {
271
- hideToast();
272
- hideLoading();
273
- hideModal();
271
+ Taro.eventCenter.on('__afterTaroRouterChange', () => {
272
+ var _a, _b;
273
+ if (toast.currentPath && toast.currentPath !== ((_a = Current.page) === null || _a === void 0 ? void 0 : _a.path)) {
274
+ hideToast();
275
+ hideLoading();
276
+ }
277
+ if (modal.currentPath && modal.currentPath !== ((_b = Current.page) === null || _b === void 0 ? void 0 : _b.path)) {
278
+ hideModal();
279
+ }
274
280
  });
275
281
  const enableAlertBeforeUnload = temporarilyNotSupport('enableAlertBeforeUnload');
276
282
  const disableAlertBeforeUnload = temporarilyNotSupport('disableAlertBeforeUnload');
@@ -56,6 +56,7 @@ export default class Modal {
56
56
  flex: string;
57
57
  };
58
58
  };
59
+ currentPath: string | null;
59
60
  el: HTMLDivElement;
60
61
  title: HTMLDivElement;
61
62
  text: HTMLDivElement;
@@ -1,4 +1,5 @@
1
- import { inlineStyle } from '../../../utils';
1
+ import { Current } from '@tarojs/runtime';
2
+ import { getLaunchPage, inlineStyle } from '../../../utils';
2
3
  export default class Modal {
3
4
  constructor() {
4
5
  this.options = {
@@ -61,6 +62,7 @@ export default class Modal {
61
62
  }
62
63
  create(options = {}) {
63
64
  return new Promise((resolve) => {
65
+ var _a, _b;
64
66
  // style
65
67
  const { maskStyle, modalStyle, titleStyle, textStyle, footStyle, btnStyle } = this.style;
66
68
  // configuration
@@ -125,10 +127,13 @@ export default class Modal {
125
127
  // show immediately
126
128
  document.body.appendChild(this.el);
127
129
  setTimeout(() => { this.el.style.opacity = '1'; }, 0);
130
+ // Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
131
+ this.currentPath = (_b = (_a = Current.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getLaunchPage();
128
132
  });
129
133
  }
130
134
  show(options = {}) {
131
135
  return new Promise((resolve) => {
136
+ var _a, _b;
132
137
  const config = Object.assign(Object.assign({}, this.options), options);
133
138
  if (this.hideOpacityTimer)
134
139
  clearTimeout(this.hideOpacityTimer);
@@ -172,6 +177,8 @@ export default class Modal {
172
177
  // show
173
178
  this.el.style.display = 'block';
174
179
  setTimeout(() => { this.el.style.opacity = '1'; }, 0);
180
+ // Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
181
+ this.currentPath = (_b = (_a = Current.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getLaunchPage();
175
182
  });
176
183
  }
177
184
  hide() {
@@ -179,6 +186,7 @@ export default class Modal {
179
186
  clearTimeout(this.hideOpacityTimer);
180
187
  if (this.hideDisplayTimer)
181
188
  clearTimeout(this.hideDisplayTimer);
189
+ this.currentPath = null;
182
190
  this.hideOpacityTimer = setTimeout(() => {
183
191
  this.el.style.opacity = '0';
184
192
  this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none'; }, 200);
@@ -71,6 +71,7 @@ export default class Toast {
71
71
  'font-size': string;
72
72
  };
73
73
  };
74
+ currentPath: string | null;
74
75
  el: HTMLDivElement;
75
76
  mask: HTMLDivElement;
76
77
  icon: HTMLParagraphElement;
@@ -1,4 +1,5 @@
1
- import { inlineStyle } from '../../../utils';
1
+ import { Current } from '@tarojs/runtime';
2
+ import { getLaunchPage, inlineStyle } from '../../../utils';
2
3
  export default class Toast {
3
4
  constructor() {
4
5
  this.options = {
@@ -75,6 +76,7 @@ export default class Toast {
75
76
  };
76
77
  }
77
78
  create(options = {}, _type = 'toast') {
79
+ var _a, _b;
78
80
  // style
79
81
  const { maskStyle, toastStyle, successStyle, errrorStyle, loadingStyle, imageStyle, textStyle } = this.style;
80
82
  // configuration
@@ -118,9 +120,12 @@ export default class Toast {
118
120
  this.type = config._type;
119
121
  // disappear after duration
120
122
  config.duration >= 0 && this.hide(config.duration, this.type);
123
+ // Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
124
+ this.currentPath = (_b = (_a = Current.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getLaunchPage();
121
125
  return '';
122
126
  }
123
127
  show(options = {}, _type = 'toast') {
128
+ var _a, _b;
124
129
  const config = Object.assign(Object.assign(Object.assign({}, this.options), options), { _type });
125
130
  if (this.hideOpacityTimer)
126
131
  clearTimeout(this.hideOpacityTimer);
@@ -152,6 +157,8 @@ export default class Toast {
152
157
  this.type = config._type;
153
158
  // disappear after duration
154
159
  config.duration >= 0 && this.hide(config.duration, this.type);
160
+ // Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
161
+ this.currentPath = (_b = (_a = Current.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getLaunchPage();
155
162
  return '';
156
163
  }
157
164
  hide(duration = 0, type) {
@@ -161,6 +168,7 @@ export default class Toast {
161
168
  clearTimeout(this.hideOpacityTimer);
162
169
  if (this.hideDisplayTimer)
163
170
  clearTimeout(this.hideDisplayTimer);
171
+ this.currentPath = null;
164
172
  this.hideOpacityTimer = setTimeout(() => {
165
173
  this.el.style.opacity = '0';
166
174
  this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none'; }, 100);
@@ -1,6 +1,6 @@
1
1
  import Taro from '@tarojs/api';
2
2
  export declare const showNavigationBarLoading: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
3
- export declare function setNavigationBarTitle(options: any): Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
3
+ export declare function setNavigationBarTitle(options?: Taro.setNavigationBarTitle.Option): Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
4
4
  /**
5
5
  * 设置页面导航条颜色
6
6
  */
@@ -7,8 +7,8 @@ export const startPullDownRefresh = function ({ success, fail, complete } = {})
7
7
  const handle = new MethodHandler({ name: 'startPullDownRefresh', success, fail, complete });
8
8
  return new Promise((resolve, reject) => {
9
9
  Taro.eventCenter.trigger('__taroStartPullDownRefresh', {
10
- successHandler: (res = {}) => handle.success(res, resolve),
11
- errorHandler: (res = {}) => handle.fail(res, reject)
10
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
11
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
12
12
  });
13
13
  });
14
14
  };
@@ -19,8 +19,8 @@ export const stopPullDownRefresh = function ({ success, fail, complete } = {}) {
19
19
  const handle = new MethodHandler({ name: 'stopPullDownRefresh', success, fail, complete });
20
20
  return new Promise((resolve, reject) => {
21
21
  Taro.eventCenter.trigger('__taroStopPullDownRefresh', {
22
- successHandler: (res = {}) => handle.success(res, resolve),
23
- errorHandler: (res = {}) => handle.fail(res, reject)
22
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
23
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
24
24
  });
25
25
  });
26
26
  };
@@ -15,7 +15,7 @@ export const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration
15
15
  if (scrollTop === undefined && !selector) {
16
16
  return handle.fail({
17
17
  errMsg: 'scrollTop" 或 "selector" 需要其之一'
18
- }, reject);
18
+ }, { resolve, reject });
19
19
  }
20
20
  const id = (_b = (_a = Current.page) === null || _a === void 0 ? void 0 : _a.path) === null || _b === void 0 ? void 0 : _b.replace(/([^a-z0-9\u00a0-\uffff_-])/ig, '\\$1');
21
21
  const el = (id
@@ -69,7 +69,7 @@ export const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration
69
69
  }, FRAME_DURATION);
70
70
  }
71
71
  else {
72
- return handle.success({}, resolve);
72
+ return handle.success({}, { resolve, reject });
73
73
  }
74
74
  };
75
75
  scroll();
@@ -77,7 +77,7 @@ export const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration
77
77
  catch (e) {
78
78
  return handle.fail({
79
79
  errMsg: e.message
80
- }, reject);
80
+ }, { resolve, reject });
81
81
  }
82
82
  });
83
83
  };
@@ -30,8 +30,8 @@ export const showTabBarRedDot = (options) => {
30
30
  return new Promise((resolve, reject) => {
31
31
  Taro.eventCenter.trigger('__taroShowTabBarRedDotHandler', {
32
32
  index,
33
- successHandler: (res = {}) => handle.success(res, resolve),
34
- errorHandler: (res = {}) => handle.fail(res, reject)
33
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
34
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
35
35
  });
36
36
  });
37
37
  };
@@ -60,8 +60,8 @@ export const showTabBar = (options = {}) => {
60
60
  return new Promise((resolve, reject) => {
61
61
  Taro.eventCenter.trigger('__taroShowTabBar', {
62
62
  animation,
63
- successHandler: (res = {}) => handle.success(res, resolve),
64
- errorHandler: (res = {}) => handle.fail(res, reject)
63
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
64
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
65
65
  });
66
66
  });
67
67
  };
@@ -112,8 +112,8 @@ export const setTabBarStyle = (options = {}) => {
112
112
  selectedColor,
113
113
  backgroundColor,
114
114
  borderStyle,
115
- successHandler: (res = {}) => handle.success(res, resolve),
116
- errorHandler: (res = {}) => handle.fail(res, reject)
115
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
116
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
117
117
  });
118
118
  });
119
119
  };
@@ -145,8 +145,8 @@ export const setTabBarItem = (options) => {
145
145
  text,
146
146
  iconPath,
147
147
  selectedIconPath,
148
- successHandler: (res = {}) => handle.success(res, resolve),
149
- errorHandler: (res = {}) => handle.fail(res, reject)
148
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
149
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
150
150
  });
151
151
  });
152
152
  };
@@ -185,8 +185,8 @@ export const setTabBarBadge = (options) => {
185
185
  Taro.eventCenter.trigger('__taroSetTabBarBadge', {
186
186
  index,
187
187
  text,
188
- successHandler: (res = {}) => handle.success(res, resolve),
189
- errorHandler: (res = {}) => handle.fail(res, reject)
188
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
189
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
190
190
  });
191
191
  });
192
192
  };
@@ -215,8 +215,8 @@ export const removeTabBarBadge = (options) => {
215
215
  return new Promise((resolve, reject) => {
216
216
  Taro.eventCenter.trigger('__taroRemoveTabBarBadge', {
217
217
  index,
218
- successHandler: (res = {}) => handle.success(res, resolve),
219
- errorHandler: (res = {}) => handle.fail(res, reject)
218
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
219
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
220
220
  });
221
221
  });
222
222
  };
@@ -245,8 +245,8 @@ export const hideTabBarRedDot = (options) => {
245
245
  return new Promise((resolve, reject) => {
246
246
  Taro.eventCenter.trigger('__taroHideTabBarRedDotHandler', {
247
247
  index,
248
- successHandler: (res = {}) => handle.success(res, resolve),
249
- errorHandler: (res = {}) => handle.fail(res, reject)
248
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
249
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
250
250
  });
251
251
  });
252
252
  };
@@ -275,8 +275,8 @@ export const hideTabBar = (options = {}) => {
275
275
  return new Promise((resolve, reject) => {
276
276
  Taro.eventCenter.trigger('__taroHideTabBar', {
277
277
  animation,
278
- successHandler: (res = {}) => handle.success(res, resolve),
279
- errorHandler: (res = {}) => handle.fail(res, reject)
278
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
279
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
280
280
  });
281
281
  });
282
282
  };
@@ -0,0 +1,20 @@
1
+ import Taro from '@tarojs/taro';
2
+ declare type TElement = Document | HTMLElement | Element;
3
+ export declare class TaroH5IntersectionObserver implements Taro.IntersectionObserver {
4
+ private _component;
5
+ private _options;
6
+ private _observerInst;
7
+ private _listeners;
8
+ private _root;
9
+ private _rootMargin;
10
+ private _isInited;
11
+ protected get container(): TElement;
12
+ constructor(component: TaroGeneral.IAnyObject, options?: Taro.createIntersectionObserver.Option);
13
+ private createInst;
14
+ disconnect(): void;
15
+ observe(targetSelector: string, callback: Taro.IntersectionObserver.ObserveCallback): void;
16
+ relativeTo(selector: string, margins?: Taro.IntersectionObserver.RelativeToMargins | undefined): Taro.IntersectionObserver;
17
+ relativeToViewport(margins?: Taro.IntersectionObserver.RelativeToViewportMargins | undefined): Taro.IntersectionObserver;
18
+ private _getCallbackByElement;
19
+ }
20
+ export {};