@tarojs/taro 3.3.13 → 3.3.14

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 (97) 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 +48 -42
  25. package/types/api/device/nfc.d.ts +105 -96
  26. package/types/api/device/performance.d.ts +22 -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 +153 -149
  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/global.d.ts +350 -0
  88. package/types/index.d.ts +12 -98
  89. package/types/taro.api.d.ts +94 -0
  90. package/types/taro.component.d.ts +10 -57
  91. package/types/taro.config.d.ts +24 -6
  92. package/types/taro.extend.d.ts +70 -67
  93. package/types/taro.hooks.d.ts +68 -67
  94. package/types/taro.lifecycle.d.ts +47 -28
  95. package/types/api/ad/index.ts +0 -6
  96. package/types/api/alipay/index.ts +0 -7
  97. package/types/api/index.d.ts +0 -352
@@ -1,8 +1,10 @@
1
- declare namespace Taro {
1
+ import Taro from './index'
2
+
3
+ declare module './index' {
2
4
  /**
3
5
  * 微信小程序全局 Window 配置和页面配置的公共项目
4
6
  */
5
- interface CommonPageConfig {
7
+ interface CommonConfig {
6
8
  /**
7
9
  * 导航栏背景颜色,HexColor
8
10
  * default: #000000
@@ -55,7 +57,7 @@ declare namespace Taro {
55
57
  onReachBottomDistance?: number
56
58
  }
57
59
 
58
- interface PageConfig extends CommonPageConfig {
60
+ interface PageConfig extends CommonConfig {
59
61
  /**
60
62
  * 设置为 true 则页面整体不能上下滚动;
61
63
  * 只在页面配置中有效,无法在 app.json 中设置该项
@@ -85,7 +87,7 @@ declare namespace Taro {
85
87
  enableShareTimeline?: boolean
86
88
  }
87
89
 
88
- interface WindowConfig extends CommonPageConfig {
90
+ interface WindowConfig extends CommonConfig {
89
91
  /**
90
92
  * 屏幕旋转设置
91
93
  * 支持 auto / portrait / landscape
@@ -106,7 +108,7 @@ declare namespace Taro {
106
108
  allowsBounceVertical?: 'YES' | 'NO'
107
109
  }
108
110
 
109
- interface TarbarList {
111
+ interface TabBarItem {
110
112
  /**
111
113
  * 页面路径,必须在 pages 中先定义
112
114
  */
@@ -155,7 +157,7 @@ declare namespace Taro {
155
157
  */
156
158
  custom?: boolean
157
159
 
158
- list: TarbarList[]
160
+ list: TabBarItem[]
159
161
  }
160
162
 
161
163
  interface NetworkTimeout {
@@ -339,4 +341,20 @@ declare namespace Taro {
339
341
  cloud?: boolean
340
342
  pageOrientation?: 'auto' | 'portrait' | 'landscape'
341
343
  }
344
+
345
+ interface TaroStatic {
346
+ CommonConfig: CommonConfig
347
+ PageConfig: PageConfig
348
+ WindowConfig: WindowConfig
349
+ TarBarList: TabBarItem
350
+ TabBar: TabBar
351
+ NetworkTimeout: NetworkTimeout
352
+ SubPackage: SubPackage
353
+ Plugins: Plugins
354
+ PreloadRule: PreloadRule
355
+ Permission: Permission
356
+ AppConfig: AppConfig
357
+ Config: Config
358
+ }
342
359
  }
360
+
@@ -1,59 +1,50 @@
1
- /// <reference types="react" />
2
- /// <reference path="taro.component.d.ts" />
3
- /// <reference path="api/network/request.d.ts" />
1
+ import Taro, { Component } from './index'
4
2
 
5
- declare namespace Taro {
6
- // Events
7
- class Events {
8
- /**
9
- * 监听一个事件,接受参数
10
- */
11
- on(eventName: string, listener: (...args: any[]) => void): this
12
-
13
- /**
14
- * 添加一个事件监听,并在事件触发完成之后移除Callbacks链
15
- */
16
- once(eventName: string, listener: (...args: any[]) => void): this
17
-
18
- /**
19
- * 取消监听一个事件
20
- */
21
- off(eventName: string, listener?: (...args: any[]) => void): this
22
-
23
- /**
24
- * 取消监听的所有事件
25
- */
26
- off(): this
27
-
28
- /**
29
- * 触发一个事件,传参
30
- */
31
- trigger(eventName: string, ...args: any[]): boolean
32
- }
3
+ // Events
4
+ export class TaroEvents {
5
+ /**
6
+ * 监听一个事件,接受参数
7
+ */
8
+ on(eventName: string, listener: (...args: any[]) => void): this
33
9
 
34
- // eventCenter
10
+ /**
11
+ * 添加一个事件监听,并在事件触发完成之后移除Callbacks链
12
+ */
13
+ once(eventName: string, listener: (...args: any[]) => void): this
35
14
 
36
- const eventCenter: Events
15
+ /**
16
+ * 取消监听一个事件
17
+ */
18
+ off(eventName: string, listener?: (...args: any[]) => void): this
37
19
 
38
- // ENV_TYPE
20
+ /**
21
+ * 取消监听的所有事件
22
+ */
23
+ off(): this
39
24
 
40
- enum ENV_TYPE {
41
- WEAPP = 'WEAPP',
42
- WEB = 'WEB',
43
- RN = 'RN',
44
- SWAN = 'SWAN',
45
- ALIPAY = 'ALIPAY',
46
- TT = 'TT',
47
- QQ = 'QQ',
48
- JD = 'JD'
49
- }
25
+ /**
26
+ * 触发一个事件,传参
27
+ */
28
+ trigger(eventName: string, ...args: any[]): boolean
29
+ }
50
30
 
51
- function getEnv(): ENV_TYPE
31
+ // ENV_TYPE
32
+
33
+ export enum TARO_ENV_TYPE {
34
+ WEAPP = 'WEAPP',
35
+ WEB = 'WEB',
36
+ RN = 'RN',
37
+ SWAN = 'SWAN',
38
+ ALIPAY = 'ALIPAY',
39
+ TT = 'TT',
40
+ QQ = 'QQ',
41
+ JD = 'JD'
42
+ }
52
43
 
53
- function render(component: Component | JSX.Element, element: Element | null): any
44
+ declare module './index' {
45
+ type Events = TaroEvents
54
46
 
55
- function internal_safe_set(...arg: any[]): any
56
- function internal_safe_get(...arg: any[]): any
47
+ type ENV_TYPE = TARO_ENV_TYPE
57
48
 
58
49
  type MessageType = 'info' | 'success' | 'error' | 'warning'
59
50
 
@@ -63,11 +54,6 @@ declare namespace Taro {
63
54
  duration?: number
64
55
  }
65
56
 
66
- function atMessage(options: AtMessageOptions): void
67
-
68
- function pxTransform(size: number, designWidth?: number): string
69
- function initPxTransform(config: { designWidth: number; deviceRatio: object }): void
70
-
71
57
  interface RequestParams extends request.Option<any> {
72
58
  [propName: string]: any
73
59
  }
@@ -81,21 +67,12 @@ declare namespace Taro {
81
67
  proceed(requestParams: RequestParams): any
82
68
  }
83
69
 
84
- namespace interceptors {
85
- function logInterceptor(chain: Chain): Promise<any>
70
+ interface interceptors {
71
+ logInterceptor(chain: Chain): Promise<any>
86
72
 
87
- function timeoutInterceptor(chain: Chain): Promise<any>
73
+ timeoutInterceptor(chain: Chain): Promise<any>
88
74
  }
89
75
 
90
- function addInterceptor(interceptor: interceptor): any
91
-
92
- /**
93
- * 小程序引用插件 JS 接口
94
- */
95
- function requirePlugin(pluginName: string): any
96
-
97
- function setIsUsingDiff (flag: boolean)
98
-
99
76
  interface Current {
100
77
  app: AppInstance | null
101
78
  router: RouterInfo | null
@@ -110,7 +87,33 @@ declare namespace Taro {
110
87
  rnNavigationRef?: React.RefObject<any>
111
88
  }
112
89
 
113
- const Current: Current
90
+ interface TaroStatic {
91
+ // eventCenter
92
+ eventCenter: TaroEvents
93
+
94
+ getEnv(): ENV_TYPE
114
95
 
115
- function getCurrentInstance(): Current
96
+ render(component: Component | JSX.Element, element: Element | null): any
97
+
98
+ internal_safe_set(...arg: any[]): any
99
+ internal_safe_get(...arg: any[]): any
100
+
101
+ atMessage(options: AtMessageOptions): void
102
+
103
+ pxTransform(size: number, designWidth?: number): string
104
+ initPxTransform(config: { designWidth: number; deviceRatio: object }): void
105
+
106
+ addInterceptor(interceptor: interceptor): any
107
+
108
+ /**
109
+ * 小程序引用插件 JS 接口
110
+ */
111
+ requirePlugin(pluginName: string): any
112
+
113
+ setIsUsingDiff (flag: boolean)
114
+
115
+ Current: Current
116
+
117
+ getCurrentInstance(): Current
118
+ }
116
119
  }
@@ -1,83 +1,84 @@
1
- /// <reference path="taro.lifecycle.d.ts" />
2
- /// <reference path="taro.component.d.ts" />
1
+ import Taro from './index'
3
2
 
4
- declare namespace Taro {
5
- /**
6
- * 页面展示时的回调。
7
- */
8
- function useDidShow(callback: () => any): void
3
+ declare module './index' {
4
+ interface TaroStatic {
5
+ /**
6
+ * 页面展示时的回调。
7
+ */
8
+ useDidShow(callback: () => any): void
9
9
 
10
- /**
11
- * 页面隐藏时的回调。
12
- */
13
- function useDidHide(callback: () => any): void
10
+ /**
11
+ * 页面隐藏时的回调。
12
+ */
13
+ useDidHide(callback: () => any): void
14
14
 
15
- /**
16
- * 下拉刷新时的回调。
17
- */
18
- function usePullDownRefresh(callback: () => any): void
15
+ /**
16
+ * 下拉刷新时的回调。
17
+ */
18
+ usePullDownRefresh(callback: () => any): void
19
19
 
20
- /**
21
- * 上拉触底时的回调。
22
- */
23
- function useReachBottom(callback: () => any): void
20
+ /**
21
+ * 上拉触底时的回调。
22
+ */
23
+ useReachBottom(callback: () => any): void
24
24
 
25
- /**
26
- * 页面滚动时的回调。
27
- */
28
- function usePageScroll(callback: (payload: PageScrollObject) => any): void
25
+ /**
26
+ * 页面滚动时的回调。
27
+ */
28
+ usePageScroll(callback: (payload: PageScrollObject) => any): void
29
29
 
30
- /**
31
- * 页面尺寸改变时的回调。
32
- */
33
- function useResize(callback: () => any): void
30
+ /**
31
+ * 页面尺寸改变时的回调。
32
+ */
33
+ useResize(callback: () => any): void
34
34
 
35
- /**
36
- * 页面转发时的回调。
37
- */
38
- function useShareAppMessage(callback: (payload: ShareAppMessageObject) => ShareAppMessageReturn): void
35
+ /**
36
+ * 页面转发时的回调。
37
+ */
38
+ useShareAppMessage(callback: (payload: ShareAppMessageObject) => ShareAppMessageReturn): void
39
39
 
40
- /**
41
- * 当前是 tab 页时,tab 被点击时的回调。
42
- */
43
- function useTabItemTap(callback: (payload: TabItemTapObject) => any): void
40
+ /**
41
+ * 当前是 tab 页时,tab 被点击时的回调。
42
+ */
43
+ useTabItemTap(callback: (payload: TabItemTapObject) => any): void
44
44
 
45
- /**
46
- * 用户点击右上角菜单“收藏”按钮时的回调。
47
- */
48
- function useAddToFavorites(callback: (paload: AddToFavoritesObject) => AddToFavoritesReturnObject): void
45
+ /**
46
+ * 用户点击右上角菜单“收藏”按钮时的回调。
47
+ */
48
+ useAddToFavorites(callback: (paload: AddToFavoritesObject) => AddToFavoritesReturnObject): void
49
49
 
50
- /**
51
- * 用户点击右上角菜单“分享到朋友圈”按钮时的回调。
52
- */
53
- function useShareTimeline(callback: () => ShareTimelineReturnObject): void
50
+ /**
51
+ * 用户点击右上角菜单“分享到朋友圈”按钮时的回调。
52
+ */
53
+ useShareTimeline(callback: () => ShareTimelineReturnObject): void
54
54
 
55
- /**
56
- * 页面初次渲染完成的回调。
57
- * 此时页面已经准备妥当,可以和视图层进行交互。
58
- */
59
- function useReady(callback: () => any): void
55
+ /**
56
+ * 页面初次渲染完成的回调。
57
+ * 此时页面已经准备妥当,可以和视图层进行交互。
58
+ */
59
+ useReady(callback: () => any): void
60
60
 
61
- /**
62
- * 获取当前路由参数。
63
- */
64
- function useRouter<TParams extends Partial<Record<string, string>> = Partial<Record<string, string>>>(dynamic?: boolean): RouterInfo<TParams>
61
+ /**
62
+ * 获取当前路由参数。
63
+ */
64
+ useRouter<TParams extends Partial<Record<string, string>> = Partial<Record<string, string>>>(dynamic?: boolean): RouterInfo<TParams>
65
65
 
66
- /**
67
- * 导航栏的标题被点击时的回调。
68
- * **仅支付宝小程序支持。**
69
- */
70
- function useTitleClick(callback: () => any): void
66
+ /**
67
+ * 导航栏的标题被点击时的回调。
68
+ * **仅支付宝小程序支持。**
69
+ */
70
+ useTitleClick(callback: () => any): void
71
71
 
72
- /**
73
- * 导航栏的额外图标被点击时的回调。
74
- * **仅支付宝小程序支持。**
75
- */
76
- function useOptionMenuClick(callback: () => any): void
72
+ /**
73
+ * 导航栏的额外图标被点击时的回调。
74
+ * **仅支付宝小程序支持。**
75
+ */
76
+ useOptionMenuClick(callback: () => any): void
77
77
 
78
- /**
79
- * 下拉中断时的回调。
80
- * **仅支付宝小程序支持。**
81
- */
82
- function usePullIntercept(callback: () => any): void
78
+ /**
79
+ * 下拉中断时的回调。
80
+ * **仅支付宝小程序支持。**
81
+ */
82
+ usePullIntercept(callback: () => any): void
83
+ }
83
84
  }
@@ -1,4 +1,36 @@
1
- declare namespace Taro {
1
+ import Taro from './index'
2
+
3
+ type TaroGetDerivedStateFromProps<P, S> =
4
+ /**
5
+ * Returns an update to a component's state based on its new props and old state.
6
+ *
7
+ * Note: its presence prevents any of the deprecated lifecycle methods from being invoked
8
+ */
9
+ (nextProps: Readonly<P>, prevState: S) => Partial<S> | null;
10
+
11
+ interface TaroStaticLifecycle<P, S> {
12
+ getDerivedStateFromProps?: TaroGetDerivedStateFromProps<P, S>;
13
+ }
14
+
15
+ interface TaroNewLifecycle<P, S, SS> {
16
+ /**
17
+ * Runs before React applies the result of `render` to the document, and
18
+ * returns an object to be given to componentDidUpdate. Useful for saving
19
+ * things such as scroll position before `render` causes changes to it.
20
+ *
21
+ * Note: the presence of getSnapshotBeforeUpdate prevents any of the deprecated
22
+ * lifecycle events from running.
23
+ */
24
+ getSnapshotBeforeUpdate?(prevProps: Readonly<P>, prevState: Readonly<S>): SS | null;
25
+ /**
26
+ * Called immediately after updating occurs. Not called for the initial render.
27
+ *
28
+ * The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null.
29
+ */
30
+ componentDidUpdate?(prevProps: Readonly<P>, prevState: Readonly<S>, snapshot?: SS): void;
31
+ }
32
+
33
+ declare module './index' {
2
34
  interface PageNotFoundObject {
3
35
  /**
4
36
  * 不存在页面的路径
@@ -8,7 +40,7 @@ declare namespace Taro {
8
40
  /**
9
41
  * 打开不存在页面的 query
10
42
  */
11
- query: object
43
+ query: Record<string, unknown>
12
44
 
13
45
  /**
14
46
  * 是否本次启动的首个页面(例如从分享等入口进来,首个页面是开发者配置的分享页面)
@@ -126,33 +158,20 @@ declare namespace Taro {
126
158
  imageUrl?: string
127
159
  }
128
160
 
129
- type GetDerivedStateFromProps<P, S> =
130
- /**
131
- * Returns an update to a component's state based on its new props and old state.
132
- *
133
- * Note: its presence prevents any of the deprecated lifecycle methods from being invoked
134
- */
135
- (nextProps: Readonly<P>, prevState: S) => Partial<S> | null;
161
+ type GetDerivedStateFromProps<P, S> = TaroGetDerivedStateFromProps<P, S>
136
162
 
137
- interface StaticLifecycle<P, S> {
138
- getDerivedStateFromProps?: GetDerivedStateFromProps<P, S>;
139
- }
163
+ type StaticLifecycle<P, S> = TaroStaticLifecycle<P, S>
140
164
 
141
- interface NewLifecycle<P, S, SS> {
142
- /**
143
- * Runs before React applies the result of `render` to the document, and
144
- * returns an object to be given to componentDidUpdate. Useful for saving
145
- * things such as scroll position before `render` causes changes to it.
146
- *
147
- * Note: the presence of getSnapshotBeforeUpdate prevents any of the deprecated
148
- * lifecycle events from running.
149
- */
150
- getSnapshotBeforeUpdate?(prevProps: Readonly<P>, prevState: Readonly<S>): SS | null;
151
- /**
152
- * Called immediately after updating occurs. Not called for the initial render.
153
- *
154
- * The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null.
155
- */
156
- componentDidUpdate?(prevProps: Readonly<P>, prevState: Readonly<S>, snapshot?: SS): void;
165
+ type NewLifecycle<P, S, SS> = TaroNewLifecycle<P, S, SS>
166
+
167
+ interface TaroStatic {
168
+ PageNotFoundObject: PageNotFoundObject
169
+ PageScrollObject: PageScrollObject
170
+ ShareAppMessageObject: ShareAppMessageObject
171
+ ShareAppMessageReturn: ShareAppMessageReturn
172
+ TabItemTapObject: TabItemTapObject
173
+ AddToFavoritesObject: AddToFavoritesObject
174
+ AddToFavoritesReturnObject: AddToFavoritesReturnObject
175
+ ShareTimelineReturnObject: ShareTimelineReturnObject
157
176
  }
158
177
  }
@@ -1,6 +0,0 @@
1
- declare namespace Taro {
2
- // TODO: wx.createRewardedVideoAd
3
- // TODO: wx.createInterstitialAd
4
- // TODO: InterstitialAd
5
- // TODO: RewardedVideoAd
6
- }
@@ -1,7 +0,0 @@
1
- declare namespace Taro {
2
- /**
3
- * @since 10.1.35
4
- * 此接口可获取支付宝会员的基础信息
5
- */
6
- function getOpenUserInfo(): Promise<string>
7
- }