@tarojs/taro 3.3.12 → 3.3.16

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 (98) hide show
  1. package/package.json +5 -5
  2. package/types/api/ad/index.d.ts +34 -28
  3. package/types/api/alipay/index.d.ts +11 -7
  4. package/types/api/base/debug.d.ts +60 -54
  5. package/types/api/base/env.d.ts +12 -8
  6. package/types/api/base/index.d.ts +87 -83
  7. package/types/api/base/system.d.ts +59 -54
  8. package/types/api/base/update.d.ts +37 -33
  9. package/types/api/base/weapp/app-event.d.ts +147 -131
  10. package/types/api/base/weapp/life-cycle.d.ts +14 -10
  11. package/types/api/canvas/index.d.ts +115 -110
  12. package/types/api/cloud/index.d.ts +99 -94
  13. package/types/api/data-analysis/index.d.ts +68 -64
  14. package/types/api/device/accelerometer.d.ts +57 -50
  15. package/types/api/device/battery.d.ts +19 -15
  16. package/types/api/device/ble.d.ts +241 -228
  17. package/types/api/device/bluetooth.d.ts +207 -194
  18. package/types/api/device/clipboard.d.ts +48 -43
  19. package/types/api/device/compass.d.ts +55 -48
  20. package/types/api/device/contact.d.ts +13 -9
  21. package/types/api/device/gyroscope.d.ts +41 -35
  22. package/types/api/device/iBeacon.d.ts +79 -73
  23. package/types/api/device/motion.d.ts +42 -37
  24. package/types/api/device/network.d.ts +80 -42
  25. package/types/api/device/nfc.d.ts +105 -96
  26. package/types/api/device/performance.d.ts +32 -18
  27. package/types/api/device/phone.d.ts +20 -15
  28. package/types/api/device/scan.d.ts +31 -26
  29. package/types/api/device/screen.d.ts +74 -67
  30. package/types/api/device/vibrate.d.ts +31 -25
  31. package/types/api/device/wifi.d.ts +151 -140
  32. package/types/api/ext/index.d.ts +44 -39
  33. package/types/api/files/index.d.ts +219 -209
  34. package/types/api/framework/index.d.ts +25 -20
  35. package/types/api/location/index.d.ts +140 -136
  36. package/types/api/media/audio.d.ts +135 -127
  37. package/types/api/media/background-audio.d.ts +135 -126
  38. package/types/api/media/camera.d.ts +30 -26
  39. package/types/api/media/editor.d.ts +35 -33
  40. package/types/api/media/image.d.ts +161 -150
  41. package/types/api/media/live.d.ts +88 -82
  42. package/types/api/media/map.d.ts +47 -43
  43. package/types/api/media/recorder.d.ts +90 -84
  44. package/types/api/media/video-processing.d.ts +10 -6
  45. package/types/api/media/video.d.ts +63 -58
  46. package/types/api/network/download.d.ts +34 -30
  47. package/types/api/network/mdns.d.ts +104 -91
  48. package/types/api/network/request.d.ts +83 -79
  49. package/types/api/network/udp.d.ts +20 -16
  50. package/types/api/network/upload.d.ts +60 -56
  51. package/types/api/network/websocket.d.ts +201 -194
  52. package/types/api/open-api/account.d.ts +18 -14
  53. package/types/api/open-api/address.d.ts +27 -23
  54. package/types/api/open-api/authorize.d.ts +30 -26
  55. package/types/api/open-api/card.d.ts +55 -51
  56. package/types/api/open-api/customer-service.d.ts +21 -17
  57. package/types/api/open-api/facial.d.ts +28 -24
  58. package/types/api/open-api/invoice.d.ts +38 -34
  59. package/types/api/open-api/login.d.ts +56 -52
  60. package/types/api/open-api/navigate.d.ts +79 -75
  61. package/types/api/open-api/payment.d.ts +34 -30
  62. package/types/api/open-api/settings.d.ts +49 -45
  63. package/types/api/open-api/soter.d.ts +92 -86
  64. package/types/api/open-api/subscribe-message.d.ts +24 -20
  65. package/types/api/open-api/user-info.d.ts +60 -57
  66. package/types/api/open-api/werun.d.ts +50 -46
  67. package/types/api/route/index.d.ts +122 -118
  68. package/types/api/share/index.d.ts +68 -64
  69. package/types/api/storage/background-fetch.d.ts +40 -35
  70. package/types/api/storage/index.d.ts +267 -262
  71. package/types/api/swan/index.d.ts +47 -42
  72. package/types/api/ui/animation.d.ts +21 -17
  73. package/types/api/ui/background.d.ts +38 -34
  74. package/types/api/ui/custom-component.d.ts +22 -18
  75. package/types/api/ui/fonts.d.ts +26 -21
  76. package/types/api/ui/interaction.d.ts +171 -122
  77. package/types/api/ui/keyboard.d.ts +59 -55
  78. package/types/api/ui/menu.d.ts +10 -6
  79. package/types/api/ui/navigation-bar.d.ts +67 -63
  80. package/types/api/ui/pull-down-refresh.d.ts +33 -29
  81. package/types/api/ui/scroll.d.ts +30 -26
  82. package/types/api/ui/sticky.d.ts +22 -19
  83. package/types/api/ui/tab-bar.d.ts +101 -97
  84. package/types/api/ui/window.d.ts +24 -18
  85. package/types/api/worker/index.d.ts +28 -24
  86. package/types/api/wxml/index.d.ts +42 -38
  87. package/types/compile.d.ts +1 -5
  88. package/types/global.d.ts +392 -0
  89. package/types/index.d.ts +12 -98
  90. package/types/taro.api.d.ts +94 -0
  91. package/types/taro.component.d.ts +10 -57
  92. package/types/taro.config.d.ts +24 -6
  93. package/types/taro.extend.d.ts +46 -75
  94. package/types/taro.hooks.d.ts +68 -67
  95. package/types/taro.lifecycle.d.ts +47 -28
  96. package/types/api/ad/index.ts +0 -6
  97. package/types/api/alipay/index.ts +0 -7
  98. package/types/api/index.d.ts +0 -352
@@ -1,42 +1,32 @@
1
- declare namespace Taro {
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
2
4
  namespace showTabBarRedDot {
3
5
  interface Option {
4
6
  /** tabBar 的哪一项,从左边算起 */
5
7
  index: number
6
8
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
7
- complete?: (res: General.CallbackResult) => void
9
+ complete?: (res: TaroGeneral.CallbackResult) => void
8
10
  /** 接口调用失败的回调函数 */
9
- fail?: (res: General.CallbackResult) => void
11
+ fail?: (res: TaroGeneral.CallbackResult) => void
10
12
  /** 接口调用成功的回调函数 */
11
- success?: (res: General.CallbackResult) => void
13
+ success?: (res: TaroGeneral.CallbackResult) => void
12
14
  }
13
15
  }
14
16
 
15
- /** 显示 tabBar 某一项的右上角的红点
16
- * @supported weapp, h5
17
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.showTabBarRedDot.html
18
- */
19
- function showTabBarRedDot(option: showTabBarRedDot.Option): Promise<General.CallbackResult>
20
-
21
17
  namespace showTabBar {
22
18
  interface Option {
23
19
  /** 是否需要动画效果 */
24
20
  animation?: boolean
25
21
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
26
- complete?: (res: General.CallbackResult) => void
22
+ complete?: (res: TaroGeneral.CallbackResult) => void
27
23
  /** 接口调用失败的回调函数 */
28
- fail?: (res: General.CallbackResult) => void
24
+ fail?: (res: TaroGeneral.CallbackResult) => void
29
25
  /** 接口调用成功的回调函数 */
30
- success?: (res: General.CallbackResult) => void
26
+ success?: (res: TaroGeneral.CallbackResult) => void
31
27
  }
32
28
  }
33
29
 
34
- /** 显示 tabBar
35
- * @supported weapp, h5
36
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.showTabBar.html
37
- */
38
- function showTabBar(option?: showTabBar.Option): Promise<General.CallbackResult>
39
-
40
30
  namespace setTabBarStyle {
41
31
  interface Option {
42
32
  /** tab 的背景色,HexColor */
@@ -46,65 +36,35 @@ declare namespace Taro {
46
36
  /** tab 上的文字默认颜色,HexColor */
47
37
  color?: string
48
38
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
49
- complete?: (res: General.CallbackResult) => void
39
+ complete?: (res: TaroGeneral.CallbackResult) => void
50
40
  /** 接口调用失败的回调函数 */
51
- fail?: (res: General.CallbackResult) => void
41
+ fail?: (res: TaroGeneral.CallbackResult) => void
52
42
  /** tab 上的文字选中时的颜色,HexColor */
53
43
  selectedColor?: string
54
44
  /** 接口调用成功的回调函数 */
55
- success?: (res: General.CallbackResult) => void
45
+ success?: (res: TaroGeneral.CallbackResult) => void
56
46
  }
57
47
  }
58
48
 
59
- /** 动态设置 tabBar 的整体样式
60
- * @supported weapp, h5
61
- * @example
62
- * ```tsx
63
- * Taro.setTabBarStyle({
64
- * color: '#FF0000',
65
- * selectedColor: '#00FF00',
66
- * backgroundColor: '#0000FF',
67
- * borderStyle: 'white'
68
- * })
69
- * ```
70
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.setTabBarStyle.html
71
- */
72
- function setTabBarStyle(option?: setTabBarStyle.Option): Promise<General.CallbackResult>
73
-
74
49
  namespace setTabBarItem {
75
50
  interface Option {
76
51
  /** tabBar 的哪一项,从左边算起 */
77
52
  index: number
78
53
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
79
- complete?: (res: General.CallbackResult) => void
54
+ complete?: (res: TaroGeneral.CallbackResult) => void
80
55
  /** 接口调用失败的回调函数 */
81
- fail?: (res: General.CallbackResult) => void
56
+ fail?: (res: TaroGeneral.CallbackResult) => void
82
57
  /** 图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px,当 postion 为 top 时,此参数无效 */
83
58
  iconPath?: string
84
59
  /** 选中时的图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px ,当 postion 为 top 时,此参数无效 */
85
60
  selectedIconPath?: string
86
61
  /** 接口调用成功的回调函数 */
87
- success?: (res: General.CallbackResult) => void
62
+ success?: (res: TaroGeneral.CallbackResult) => void
88
63
  /** tab 上的按钮文字 */
89
64
  text?: string
90
65
  }
91
66
  }
92
67
 
93
- /** 动态设置 tabBar 某一项的内容,`2.7.0` 起图片支持临时文件和网络文件。
94
- * @supported weapp, h5, rn
95
- * @example
96
- * ```tsx
97
- * Taro.setTabBarItem({
98
- * index: 0,
99
- * text: 'text',
100
- * iconPath: '/path/to/iconPath',
101
- * selectedIconPath: '/path/to/selectedIconPath'
102
- * })
103
- * ```
104
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.setTabBarItem.html
105
- */
106
- function setTabBarItem(option: setTabBarItem.Option): Promise<General.CallbackResult>
107
-
108
68
  namespace setTabBarBadge {
109
69
  interface Option {
110
70
  /** tabBar 的哪一项,从左边算起 */
@@ -112,81 +72,125 @@ declare namespace Taro {
112
72
  /** 显示的文本,超过 4 个字符则显示成 ... */
113
73
  text: string
114
74
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
115
- complete?: (res: General.CallbackResult) => void
75
+ complete?: (res: TaroGeneral.CallbackResult) => void
116
76
  /** 接口调用失败的回调函数 */
117
- fail?: (res: General.CallbackResult) => void
77
+ fail?: (res: TaroGeneral.CallbackResult) => void
118
78
  /** 接口调用成功的回调函数 */
119
- success?: (res: General.CallbackResult) => void
79
+ success?: (res: TaroGeneral.CallbackResult) => void
120
80
  }
121
81
  }
122
82
 
123
- /** 为 tabBar 某一项的右上角添加文本
124
- * @supported weapp, h5
125
- * @example
126
- * ```tsx
127
- * Taro.setTabBarBadge({
128
- * index: 0,
129
- * text: '1'
130
- * })
131
- * ```
132
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.setTabBarBadge.html
133
- */
134
- function setTabBarBadge(option: setTabBarBadge.Option): Promise<General.CallbackResult>
135
-
136
83
  namespace removeTabBarBadge {
137
84
  interface Option {
138
85
  /** tabBar 的哪一项,从左边算起 */
139
86
  index: number
140
87
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
141
- complete?: (res: General.CallbackResult) => void
88
+ complete?: (res: TaroGeneral.CallbackResult) => void
142
89
  /** 接口调用失败的回调函数 */
143
- fail?: (res: General.CallbackResult) => void
90
+ fail?: (res: TaroGeneral.CallbackResult) => void
144
91
  /** 接口调用成功的回调函数 */
145
- success?: (res: General.CallbackResult) => void
92
+ success?: (res: TaroGeneral.CallbackResult) => void
146
93
  }
147
94
  }
148
95
 
149
- /** 移除 tabBar 某一项右上角的文本
150
- * @supported weapp, h5
151
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.removeTabBarBadge.html
152
- */
153
- function removeTabBarBadge(option: removeTabBarBadge.Option): Promise<General.CallbackResult>
154
-
155
96
  namespace hideTabBarRedDot {
156
97
  interface Option {
157
98
  /** tabBar 的哪一项,从左边算起 */
158
99
  index: number
159
100
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
160
- complete?: (res: General.CallbackResult) => void
101
+ complete?: (res: TaroGeneral.CallbackResult) => void
161
102
  /** 接口调用失败的回调函数 */
162
- fail?: (res: General.CallbackResult) => void
103
+ fail?: (res: TaroGeneral.CallbackResult) => void
163
104
  /** 接口调用成功的回调函数 */
164
- success?: (res: General.CallbackResult) => void
105
+ success?: (res: TaroGeneral.CallbackResult) => void
165
106
  }
166
107
  }
167
108
 
168
- /** 隐藏 tabBar 某一项的右上角的红点
169
- * @supported weapp, h5
170
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.hideTabBarRedDot.html
171
- */
172
- function hideTabBarRedDot(option: hideTabBarRedDot.Option): Promise<General.CallbackResult>
173
-
174
109
  namespace hideTabBar {
175
110
  interface Option {
176
111
  /** 是否需要动画效果 */
177
112
  animation?: boolean
178
113
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
179
- complete?: (res: General.CallbackResult) => void
114
+ complete?: (res: TaroGeneral.CallbackResult) => void
180
115
  /** 接口调用失败的回调函数 */
181
- fail?: (res: General.CallbackResult) => void
116
+ fail?: (res: TaroGeneral.CallbackResult) => void
182
117
  /** 接口调用成功的回调函数 */
183
- success?: (res: General.CallbackResult) => void
118
+ success?: (res: TaroGeneral.CallbackResult) => void
184
119
  }
185
120
  }
186
121
 
187
- /** 隐藏 tabBar
188
- * @supported weapp, h5
189
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.hideTabBar.html
190
- */
191
- function hideTabBar(option?: hideTabBar.Option): Promise<General.CallbackResult>
122
+ interface TaroStatic {
123
+ /** 显示 tabBar 某一项的右上角的红点
124
+ * @supported weapp, h5
125
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.showTabBarRedDot.html
126
+ */
127
+ showTabBarRedDot(option: showTabBarRedDot.Option): Promise<TaroGeneral.CallbackResult>
128
+
129
+ /** 显示 tabBar
130
+ * @supported weapp, h5
131
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.showTabBar.html
132
+ */
133
+ showTabBar(option?: showTabBar.Option): Promise<TaroGeneral.CallbackResult>
134
+
135
+ /** 动态设置 tabBar 的整体样式
136
+ * @supported weapp, h5
137
+ * @example
138
+ * ```tsx
139
+ * Taro.setTabBarStyle({
140
+ * color: '#FF0000',
141
+ * selectedColor: '#00FF00',
142
+ * backgroundColor: '#0000FF',
143
+ * borderStyle: 'white'
144
+ * })
145
+ * ```
146
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.setTabBarStyle.html
147
+ */
148
+ setTabBarStyle(option?: setTabBarStyle.Option): Promise<TaroGeneral.CallbackResult>
149
+
150
+ /** 动态设置 tabBar 某一项的内容,`2.7.0` 起图片支持临时文件和网络文件。
151
+ * @supported weapp, h5, rn
152
+ * @example
153
+ * ```tsx
154
+ * Taro.setTabBarItem({
155
+ * index: 0,
156
+ * text: 'text',
157
+ * iconPath: '/path/to/iconPath',
158
+ * selectedIconPath: '/path/to/selectedIconPath'
159
+ * })
160
+ * ```
161
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.setTabBarItem.html
162
+ */
163
+ setTabBarItem(option: setTabBarItem.Option): Promise<TaroGeneral.CallbackResult>
164
+
165
+ /** 为 tabBar 某一项的右上角添加文本
166
+ * @supported weapp, h5
167
+ * @example
168
+ * ```tsx
169
+ * Taro.setTabBarBadge({
170
+ * index: 0,
171
+ * text: '1'
172
+ * })
173
+ * ```
174
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.setTabBarBadge.html
175
+ */
176
+ setTabBarBadge(option: setTabBarBadge.Option): Promise<TaroGeneral.CallbackResult>
177
+
178
+ /** 移除 tabBar 某一项右上角的文本
179
+ * @supported weapp, h5
180
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.removeTabBarBadge.html
181
+ */
182
+ removeTabBarBadge(option: removeTabBarBadge.Option): Promise<TaroGeneral.CallbackResult>
183
+
184
+ /** 隐藏 tabBar 某一项的右上角的红点
185
+ * @supported weapp, h5
186
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.hideTabBarRedDot.html
187
+ */
188
+ hideTabBarRedDot(option: hideTabBarRedDot.Option): Promise<TaroGeneral.CallbackResult>
189
+
190
+ /** 隐藏 tabBar
191
+ * @supported weapp, h5
192
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.hideTabBar.html
193
+ */
194
+ hideTabBar(option?: hideTabBar.Option): Promise<TaroGeneral.CallbackResult>
195
+ }
192
196
  }
@@ -1,4 +1,6 @@
1
- declare namespace Taro {
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
2
4
  namespace onWindowResize {
3
5
  /** 窗口尺寸变化事件的回调函数 */
4
6
  type Callback = (result: CallbackResult) => void
@@ -14,25 +16,29 @@ declare namespace Taro {
14
16
  windowWidth: number
15
17
  }
16
18
  }
17
- /** 监听窗口尺寸变化事件
18
- * @supported weapp, h5
19
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/window/wx.onWindowResize.html
20
- */
21
- function onWindowResize(
22
- /** 窗口尺寸变化事件的回调函数 */
23
- callback: onWindowResize.Callback,
24
- ): void
25
19
 
26
20
  namespace offWindowResize {
27
21
  /** 窗口尺寸变化事件的回调函数 */
28
- type Callback = (res: General.CallbackResult) => void
22
+ type Callback = (res: TaroGeneral.CallbackResult) => void
23
+ }
24
+
25
+ interface TaroStatic {
26
+ /** 监听窗口尺寸变化事件
27
+ * @supported weapp, h5
28
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/window/wx.onWindowResize.html
29
+ */
30
+ onWindowResize(
31
+ /** 窗口尺寸变化事件的回调函数 */
32
+ callback: onWindowResize.Callback,
33
+ ): void
34
+
35
+ /** 取消监听窗口尺寸变化事件
36
+ * @supported weapp, h5
37
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/window/wx.offWindowResize.html
38
+ */
39
+ offWindowResize(
40
+ /** 窗口尺寸变化事件的回调函数 */
41
+ callback: offWindowResize.Callback,
42
+ ): void
29
43
  }
30
- /** 取消监听窗口尺寸变化事件
31
- * @supported weapp, h5
32
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/window/wx.offWindowResize.html
33
- */
34
- function offWindowResize(
35
- /** 窗口尺寸变化事件的回调函数 */
36
- callback: offWindowResize.Callback,
37
- ): void
38
44
  }
@@ -1,31 +1,13 @@
1
- declare namespace Taro {
2
- /** 创建一个 Worker 线程。目前限制最多只能创建一个 Worker,创建下一个 Worker 前请先调用 [Worker.terminate](https://developers.weixin.qq.com/miniprogram/dev/api/worker/Worker.terminate.html)
3
- * @supported weapp
4
- * @example
5
- * ```tsx
6
- * const worker = Taro.createWorker('workers/request/index.js') // 文件名指定 worker 的入口文件路径,绝对路径
7
- * worker.onMessage(function (res) {
8
- * console.log(res)
9
- * })
10
- * worker.postMessage({
11
- * msg: 'hello worker'
12
- * })
13
- * worker.terminate()
14
- * ```
15
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/worker/wx.createWorker.html
16
- */
17
- function createWorker(
18
- /** worker 入口文件的**绝对路径** */
19
- scriptPath: string,
20
- ): Worker
1
+ import Taro from '../../index'
21
2
 
3
+ declare module '../../index' {
22
4
  namespace Worker {
23
5
  type OnMessageCallback = (
24
6
  result: OnMessageCallbackResult,
25
7
  ) => void
26
8
  interface OnMessageCallbackResult {
27
9
  /** 主线程/Worker 线程向当前线程发送的消息 */
28
- message: General.IAnyObject
10
+ message: TaroGeneral.IAnyObject
29
11
  }
30
12
  }
31
13
  interface Worker {
@@ -41,7 +23,7 @@ declare namespace Taro {
41
23
  * @supported weapp
42
24
  * @example
43
25
  * worker 线程中
44
- *
26
+ *
45
27
  * ```tsx
46
28
  * worker.postMessage({
47
29
  * msg: 'hello from worker'
@@ -49,7 +31,7 @@ declare namespace Taro {
49
31
  * ```
50
32
  *
51
33
  * 主线程中
52
- *
34
+ *
53
35
  * ```tsx
54
36
  * const worker = Taro.createWorker('workers/request/index.js')
55
37
  * worker.postMessage({
@@ -60,7 +42,7 @@ declare namespace Taro {
60
42
  */
61
43
  postMessage(
62
44
  /** 需要发送的消息,必须是一个可序列化的 JavaScript key-value 形式的对象。 */
63
- message: General.IAnyObject,
45
+ message: TaroGeneral.IAnyObject,
64
46
  ): void
65
47
  /** 结束当前 Worker 线程。仅限在主线程 worker 对象上调用。
66
48
  * @supported weapp
@@ -68,4 +50,26 @@ declare namespace Taro {
68
50
  */
69
51
  terminate(): void
70
52
  }
53
+
54
+ interface TaroStatic {
55
+ /** 创建一个 Worker 线程。目前限制最多只能创建一个 Worker,创建下一个 Worker 前请先调用 [Worker.terminate](https://developers.weixin.qq.com/miniprogram/dev/api/worker/Worker.terminate.html)
56
+ * @supported weapp
57
+ * @example
58
+ * ```tsx
59
+ * const worker = Taro.createWorker('workers/request/index.js') // 文件名指定 worker 的入口文件路径,绝对路径
60
+ * worker.onMessage(function (res) {
61
+ * console.log(res)
62
+ * })
63
+ * worker.postMessage({
64
+ * msg: 'hello worker'
65
+ * })
66
+ * worker.terminate()
67
+ * ```
68
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/worker/wx.createWorker.html
69
+ */
70
+ createWorker(
71
+ /** worker 入口文件的**绝对路径** */
72
+ scriptPath: string,
73
+ ): Worker
74
+ }
71
75
  }
@@ -1,35 +1,6 @@
1
- declare namespace Taro {
2
- /** 返回一个 SelectorQuery 对象实例。在自定义组件或包含自定义组件的页面中,应使用 `this.createSelectorQuery()` 来代替。
3
- * @supported weapp, h5
4
- * @example
5
- * ```tsx
6
- * const query = Taro.createSelectorQuery()
7
- * query.select('#the-id').boundingClientRect()
8
- * query.selectViewport().scrollOffset()
9
- * query.exec(function(res){
10
- * res[0].top // #the-id节点的上边界坐标
11
- * res[1].scrollTop // 显示区域的竖直滚动位置
12
- * })
13
- * ```
14
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/wx.createSelectorQuery.html
15
- */
16
- function createSelectorQuery(): SelectorQuery
17
-
18
- /** 创建并返回一个 IntersectionObserver 对象实例。在自定义组件或包含自定义组件的页面中,应使用 `this.createIntersectionObserver([options])` 来代替。
19
- * @supported weapp
20
- * @example
21
- * ```tsx
22
- * const observer = Taro.createIntersectionObserver(this, { thresholds: [0], observeAll: true })
23
- * ```
24
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/wx.createSelectorQuery.html
25
- */
26
- function createIntersectionObserver(
27
- /** 自定义组件实例 */
28
- component: General.IAnyObject,
29
- /** 选项 */
30
- options?: createIntersectionObserver.Option,
31
- ): IntersectionObserver
1
+ import Taro from '../../index'
32
2
 
3
+ declare module '../../index' {
33
4
  namespace createIntersectionObserver {
34
5
  /** 选项 */
35
6
  interface Option {
@@ -71,7 +42,7 @@ declare namespace Taro {
71
42
  /** 指定页面显示区域作为参照区域之一
72
43
  * @example
73
44
  * 下面的示例代码中,如果目标节点(用选择器 .target-class 指定)进入显示区域以下 100px 时,就会触发回调函数。
74
- *
45
+ *
75
46
  * ```tsx
76
47
  * Taro.createIntersectionObserver().relativeToViewport({bottom: 100}).observe('.target-class', (res) => {
77
48
  * res.intersectionRatio // 相交区域占目标节点的布局区域的比例
@@ -269,7 +240,7 @@ declare namespace Taro {
269
240
  */
270
241
  in(
271
242
  /** 自定义组件实例 */
272
- component: General.IAnyObject,
243
+ component: TaroGeneral.IAnyObject,
273
244
  ): SelectorQuery
274
245
  }
275
246
 
@@ -404,7 +375,7 @@ declare namespace Taro {
404
375
  /** 节点的下边界坐标 */
405
376
  bottom: number
406
377
  /** 节点的 dataset */
407
- dataset: General.IAnyObject
378
+ dataset: TaroGeneral.IAnyObject
408
379
  /** 节点的高度 */
409
380
  height: number
410
381
  /** 节点的 ID */
@@ -422,7 +393,7 @@ declare namespace Taro {
422
393
  type ContextCallback = (result: ContextCallbackResult) => void
423
394
  interface ContextCallbackResult {
424
395
  /** 节点对应的 Context 对象 */
425
- context: General.IAnyObject
396
+ context: TaroGeneral.IAnyObject
426
397
  }
427
398
 
428
399
  interface Fields {
@@ -450,20 +421,20 @@ declare namespace Taro {
450
421
  /** 回调函数 */
451
422
  type FieldsCallback = (
452
423
  /** 节点的相关信息 */
453
- res: General.IAnyObject,
424
+ res: TaroGeneral.IAnyObject,
454
425
  ) => void
455
426
  /** 回调函数,在执行 `SelectorQuery.exec` 方法后,返回节点信息。 */
456
427
  type NodeCallback = (result: NodeCallbackResult) => void
457
428
  /** 回调函数 */
458
429
  interface NodeCallbackResult {
459
430
  /** 节点对应的 Node 实例 */
460
- node: General.IAnyObject
431
+ node: TaroGeneral.IAnyObject
461
432
  }
462
433
  /** 回调函数,在执行 `SelectorQuery.exec` 方法后,节点信息会在 `callback` 中返回。 */
463
434
  type ScrollOffsetCallback = (result: ScrollOffsetCallbackResult) => void
464
435
  interface ScrollOffsetCallbackResult {
465
436
  /** 节点的 dataset */
466
- dataset: General.IAnyObject
437
+ dataset: TaroGeneral.IAnyObject
467
438
  /** 节点的 ID */
468
439
  id: string
469
440
  /** 节点的水平滚动位置 */
@@ -472,4 +443,37 @@ declare namespace Taro {
472
443
  scrollTop: number
473
444
  }
474
445
  }
446
+
447
+ interface TaroStatic {
448
+ /** 返回一个 SelectorQuery 对象实例。在自定义组件或包含自定义组件的页面中,应使用 `this.createSelectorQuery()` 来代替。
449
+ * @supported weapp, h5
450
+ * @example
451
+ * ```tsx
452
+ * const query = Taro.createSelectorQuery()
453
+ * query.select('#the-id').boundingClientRect()
454
+ * query.selectViewport().scrollOffset()
455
+ * query.exec(function(res){
456
+ * res[0].top // #the-id节点的上边界坐标
457
+ * res[1].scrollTop // 显示区域的竖直滚动位置
458
+ * })
459
+ * ```
460
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/wx.createSelectorQuery.html
461
+ */
462
+ createSelectorQuery(): SelectorQuery
463
+
464
+ /** 创建并返回一个 IntersectionObserver 对象实例。在自定义组件或包含自定义组件的页面中,应使用 `this.createIntersectionObserver([options])` 来代替。
465
+ * @supported weapp
466
+ * @example
467
+ * ```tsx
468
+ * const observer = Taro.createIntersectionObserver(this, { thresholds: [0], observeAll: true })
469
+ * ```
470
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/wx.createSelectorQuery.html
471
+ */
472
+ createIntersectionObserver(
473
+ /** 自定义组件实例 */
474
+ component: TaroGeneral.IAnyObject,
475
+ /** 选项 */
476
+ options?: createIntersectionObserver.Option,
477
+ ): IntersectionObserver
478
+ }
475
479
  }
@@ -209,10 +209,6 @@ declare enum LogLevel {
209
209
  DEBUG = 'debug'
210
210
  }
211
211
 
212
- export interface IDeviceRatio {
213
- [key: string]: number
214
- }
215
-
216
212
  export type SystemConfig = {
217
213
  /**
218
214
  * 打印日志等级,分为 off,error,warn,info,log,debug
@@ -361,7 +357,7 @@ export interface IProjectBaseConfig {
361
357
  date?: string,
362
358
  designWidth?: number,
363
359
  watcher?: any[],
364
- deviceRatio?: IDeviceRatio,
360
+ deviceRatio?: TaroGeneral.TDeviceRatio,
365
361
  sourceRoot?: string,
366
362
  outputRoot?: string,
367
363
  env?: IOption,