@tarojs/taro 3.4.0-beta.0 → 3.4.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.
package/types/index.d.ts CHANGED
@@ -136,3 +136,7 @@ declare namespace Taro {
136
136
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
137
137
  interface TaroStatic {}
138
138
  }
139
+ declare global {
140
+ const defineAppConfig: (config: Taro.Config) => Taro.Config
141
+ const definePageConfig: (config: Taro.Config) => Taro.Config
142
+ }
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  /// <reference types="vue" />
3
3
 
4
- import Taro, { ComponentOptions, Config, RouterInfo } from './index'
4
+ import Taro, { Config } from './index'
5
5
 
6
6
  declare module './index' {
7
7
  // Components
@@ -21,7 +21,7 @@ declare module './index' {
21
21
  onPageScroll?(obj: PageScrollObject): void
22
22
  onShareAppMessage?(obj: ShareAppMessageObject): ShareAppMessageReturn
23
23
  onTabItemTap?(obj: TabItemTapObject): void
24
- onResize?(obj: any): void
24
+ onResize?(obj: PageResizeObject): void
25
25
  }
26
26
 
27
27
  interface ComponentOptions {
@@ -80,14 +80,16 @@ declare module './index' {
80
80
  type SFC = StatelessFunctionComponent
81
81
 
82
82
  interface Show {
83
- componentDidShow?(options?: unknown): void
84
- componentDidHide?(options?: unknown): void
85
- onShow?(options?: unknown): void
86
- onHide?(options?: unknown): void
83
+ componentDidShow?(): void
84
+ componentDidHide?(): void
85
+ onShow?(): void
86
+ onHide?(): void
87
87
  }
88
88
 
89
89
  interface AppInstance extends Show {
90
90
  mount(component: React.ComponentClass | Vue.ComponentOptions<Vue>, id: string, cb: () => void): void
91
+ componentDidShow?(options?: Record<string, unknown>): void
92
+ onShow?(options?: Record<string, unknown>): void
91
93
  unmount(id: string, cb: () => void): void
92
94
  }
93
95
 
@@ -235,7 +235,24 @@ declare module './index' {
235
235
  }
236
236
  }
237
237
 
238
+ interface RouterAnimate {
239
+ /**
240
+ * 动画切换时间,单位毫秒
241
+ * @default 300
242
+ */
243
+ duration?: number
244
+ /**
245
+ * 动画切换时间,单位毫秒
246
+ * @default 50
247
+ */
248
+ delay?: number
249
+ }
250
+
238
251
  interface AppConfig {
252
+ /**
253
+ * 小程序默认启动首页,未指定 entryPagePath 时,数组的第一项代表小程序的初始页面(首页)。
254
+ */
255
+ entryPagePath?: string
239
256
  /**
240
257
  * 接受一个数组,每一项都是字符串,来指定小程序由哪些页面组成,数组的第一项代表小程序的初始页面
241
258
  */
@@ -292,7 +309,7 @@ declare module './index' {
292
309
  * 声明分包预下载的规则。
293
310
  * preloadRule 中,key 是页面路径,value 是进入此页面的预下载配置
294
311
  * 注意: 分包预下载目前只支持通过配置方式使用,暂不支持通过调用API完成。
295
- * vConsole 里有preloadSubpackages开头的日志信息,可以用来验证预下载的情况。
312
+ * vConsole 里有 preloadSubpackages 开头的日志信息,可以用来验证预下载的情况。
296
313
  * @since 2.3.0
297
314
  */
298
315
  preloadRule?: PreloadRule
@@ -318,12 +335,12 @@ declare module './index' {
318
335
  */
319
336
  style?: 'v2'
320
337
  /**
321
- * 配置 darkmode 为 true,即表示当前小程序已适配 DarkMode
338
+ * 配置 darkMode 为 true,即表示当前小程序已适配 DarkMode
322
339
  * @since 2.11.0
323
340
  */
324
341
  darkmode?: boolean
325
342
  /**
326
- * 指定 darkmode 变量配置文件 theme.json 路径
343
+ * 指定 darkMode 变量配置文件 theme.json 路径
327
344
  * @since 2.11.0
328
345
  */
329
346
  themeLocation?: string
@@ -331,6 +348,18 @@ declare module './index' {
331
348
  * 接受一个数组,每一项都是字符串,来指定编译为原生小程序组件的组件入口
332
349
  */
333
350
  components?: string[]
351
+ /**
352
+ * 渲染页面的容器 id
353
+ * @default "app"
354
+ * @since 3.3.18
355
+ */
356
+ appId?: string
357
+ /**
358
+ * 是否开启 h5 端路由动画功能,默认开启
359
+ * @supported h5
360
+ * @since 3.3.18
361
+ */
362
+ animation?: RouterAnimate | boolean
334
363
  }
335
364
 
336
365
  interface Config extends PageConfig, AppConfig {
@@ -354,6 +383,7 @@ declare module './index' {
354
383
  PreloadRule: PreloadRule
355
384
  Permission: Permission
356
385
  AppConfig: AppConfig
386
+ RouterAnimate: RouterAnimate
357
387
  Config: Config
358
388
  }
359
389
  }
@@ -13,21 +13,6 @@ declare module './index' {
13
13
  [propName: string]: any
14
14
  }
15
15
 
16
- type interceptor = (chain: Chain) => any
17
-
18
- interface Chain {
19
- index: number
20
- requestParams: RequestParams
21
- interceptors: interceptor[]
22
- proceed(requestParams: RequestParams): any
23
- }
24
-
25
- interface interceptors {
26
- logInterceptor(chain: Chain): Promise<any>
27
-
28
- timeoutInterceptor(chain: Chain): Promise<any>
29
- }
30
-
31
16
  interface Current {
32
17
  app: AppInstance | null
33
18
  router: RouterInfo | null
@@ -46,10 +31,27 @@ declare module './index' {
46
31
  install (app: any, data: any): void
47
32
  }
48
33
 
34
+ interface TARO_ENV_TYPE {
35
+ [TaroGeneral.ENV_TYPE.WEAPP]: TaroGeneral.ENV_TYPE.WEAPP
36
+ [TaroGeneral.ENV_TYPE.WEB]: TaroGeneral.ENV_TYPE.WEB
37
+ [TaroGeneral.ENV_TYPE.RN]: TaroGeneral.ENV_TYPE.RN
38
+ [TaroGeneral.ENV_TYPE.SWAN]: TaroGeneral.ENV_TYPE.SWAN
39
+ [TaroGeneral.ENV_TYPE.ALIPAY]: TaroGeneral.ENV_TYPE.ALIPAY
40
+ [TaroGeneral.ENV_TYPE.TT]: TaroGeneral.ENV_TYPE.TT
41
+ [TaroGeneral.ENV_TYPE.QQ]: TaroGeneral.ENV_TYPE.QQ
42
+ [TaroGeneral.ENV_TYPE.JD]: TaroGeneral.ENV_TYPE.JD
43
+ }
44
+
49
45
  interface TaroStatic {
46
+ Events: {
47
+ new (): TaroGeneral.Events
48
+ }
49
+
50
50
  // eventCenter
51
51
  eventCenter: TaroGeneral.Events
52
52
 
53
+ ENV_TYPE: TARO_ENV_TYPE
54
+
53
55
  getEnv(): TaroGeneral.ENV_TYPE
54
56
 
55
57
  render(component: Component | JSX.Element, element: Element | null): any
@@ -60,9 +62,7 @@ declare module './index' {
60
62
  atMessage(options: AtMessageOptions): void
61
63
 
62
64
  pxTransform(size: number, designWidth?: number): string
63
- initPxTransform(config: { designWidth: number; deviceRatio: object }): void
64
-
65
- addInterceptor(interceptor: interceptor): any
65
+ initPxTransform(config: { designWidth: number; deviceRatio: TaroGeneral.TDeviceRatio }): void
66
66
 
67
67
  /**
68
68
  * 小程序引用插件 JS 接口
@@ -5,32 +5,32 @@ declare module './index' {
5
5
  /**
6
6
  * 页面展示时的回调。
7
7
  */
8
- useDidShow(callback: () => any): void
8
+ useDidShow(callback: () => void): void
9
9
 
10
10
  /**
11
11
  * 页面隐藏时的回调。
12
12
  */
13
- useDidHide(callback: () => any): void
13
+ useDidHide(callback: () => void): void
14
14
 
15
15
  /**
16
16
  * 下拉刷新时的回调。
17
17
  */
18
- usePullDownRefresh(callback: () => any): void
18
+ usePullDownRefresh(callback: () => void): void
19
19
 
20
20
  /**
21
21
  * 上拉触底时的回调。
22
22
  */
23
- useReachBottom(callback: () => any): void
23
+ useReachBottom(callback: () => void): void
24
24
 
25
25
  /**
26
26
  * 页面滚动时的回调。
27
27
  */
28
- usePageScroll(callback: (payload: PageScrollObject) => any): void
28
+ usePageScroll(callback: (payload: PageScrollObject) => void): void
29
29
 
30
30
  /**
31
31
  * 页面尺寸改变时的回调。
32
32
  */
33
- useResize(callback: () => any): void
33
+ useResize(callback: (payload: PageResizeObject) => void): void
34
34
 
35
35
  /**
36
36
  * 页面转发时的回调。
@@ -40,12 +40,12 @@ declare module './index' {
40
40
  /**
41
41
  * 当前是 tab 页时,tab 被点击时的回调。
42
42
  */
43
- useTabItemTap(callback: (payload: TabItemTapObject) => any): void
43
+ useTabItemTap(callback: (payload: TabItemTapObject) => void): void
44
44
 
45
45
  /**
46
46
  * 用户点击右上角菜单“收藏”按钮时的回调。
47
47
  */
48
- useAddToFavorites(callback: (paload: AddToFavoritesObject) => AddToFavoritesReturnObject): void
48
+ useAddToFavorites(callback: (payload: AddToFavoritesObject) => AddToFavoritesReturnObject): void
49
49
 
50
50
  /**
51
51
  * 用户点击右上角菜单“分享到朋友圈”按钮时的回调。
@@ -56,7 +56,7 @@ declare module './index' {
56
56
  * 页面初次渲染完成的回调。
57
57
  * 此时页面已经准备妥当,可以和视图层进行交互。
58
58
  */
59
- useReady(callback: () => any): void
59
+ useReady(callback: () => void): void
60
60
 
61
61
  /**
62
62
  * 获取当前路由参数。
@@ -67,18 +67,18 @@ declare module './index' {
67
67
  * 导航栏的标题被点击时的回调。
68
68
  * **仅支付宝小程序支持。**
69
69
  */
70
- useTitleClick(callback: () => any): void
70
+ useTitleClick(callback: () => void): void
71
71
 
72
72
  /**
73
73
  * 导航栏的额外图标被点击时的回调。
74
74
  * **仅支付宝小程序支持。**
75
75
  */
76
- useOptionMenuClick(callback: () => any): void
76
+ useOptionMenuClick(callback: () => void): void
77
77
 
78
78
  /**
79
79
  * 下拉中断时的回调。
80
80
  * **仅支付宝小程序支持。**
81
81
  */
82
- usePullIntercept(callback: () => any): void
82
+ usePullIntercept(callback: () => void): void
83
83
  }
84
84
  }
@@ -55,6 +55,13 @@ declare module './index' {
55
55
  scrollTop: number
56
56
  }
57
57
 
58
+ interface PageResizeObject {
59
+ size: {
60
+ windowWidth: number
61
+ windowHeight: number
62
+ }
63
+ }
64
+
58
65
  interface ShareAppMessageObject {
59
66
  /**
60
67
  * 转发事件来源
package/h5.js DELETED
@@ -1,4 +0,0 @@
1
- import Taro from '@tarojs/taro-h5'
2
- export * from '@tarojs/taro-h5'
3
-
4
- export default Taro