@tarojs/taro 3.4.0 → 3.4.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/taro",
3
- "version": "3.4.0",
3
+ "version": "3.4.1",
4
4
  "description": "Taro framework",
5
5
  "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro#readme",
6
6
  "main": "index.js",
@@ -24,9 +24,9 @@
24
24
  "author": "O2Team",
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
- "@tarojs/api": "3.4.0",
28
- "@tarojs/runtime": "3.4.0",
29
- "@tarojs/taro-h5": "3.4.0"
27
+ "@tarojs/api": "3.4.1",
28
+ "@tarojs/runtime": "3.4.1",
29
+ "@tarojs/taro-h5": "3.4.1"
30
30
  },
31
- "gitHead": "a0e97bc937f878cc059f54748c9a3829fa3f4664"
31
+ "gitHead": "a2437215b1966fd0b6dd09311bcb4fd894a871d0"
32
32
  }
@@ -153,22 +153,16 @@ declare module '../../index' {
153
153
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.html
154
154
  */
155
155
  interface InnerAudioContext {
156
+ /** 音频资源的地址,用于直接播放。 */
157
+ src: string
158
+ /** 开始播放的位置(单位:s)
159
+ * @default 0
160
+ */
161
+ startTime: number
156
162
  /** 是否自动开始播放
157
163
  * @default false
158
164
  */
159
165
  autoplay: boolean
160
- /** 音频缓冲的时间点,仅保证当前播放时间点到此时间点内容已缓冲
161
- * @readonly
162
- */
163
- buffered: number
164
- /** 当前音频的播放位置(单位 s)。只有在当前有合法的 src 时返回,时间保留小数点后 6 位
165
- * @readonly
166
- */
167
- currentTime: number
168
- /** 当前音频的长度(单位 s)。只有在当前有合法的 src 时返回
169
- * @readonly
170
- */
171
- duration: number
172
166
  /** 是否循环播放
173
167
  * @default false
174
168
  */
@@ -177,16 +171,6 @@ declare module '../../index' {
177
171
  * @default true
178
172
  */
179
173
  obeyMuteSwitch: boolean
180
- /** 当前是是否暂停或停止状态
181
- * @readonly
182
- */
183
- paused: boolean
184
- /** 音频资源的地址,用于直接播放。 */
185
- src: string
186
- /** 开始播放的位置(单位:s)
187
- * @default 0
188
- */
189
- startTime: number
190
174
  /** 音量。范围 0~1。
191
175
  * @default 1
192
176
  */
@@ -195,6 +179,24 @@ declare module '../../index' {
195
179
  * @default 1
196
180
  */
197
181
  playbackRate: number
182
+ /** 当前音频的长度(单位 s)。只有在当前有合法的 src 时返回
183
+ * @readonly
184
+ */
185
+ duration: number
186
+ /** 当前音频的播放位置(单位 s)。只有在当前有合法的 src 时返回,时间保留小数点后 6 位
187
+ * @readonly
188
+ */
189
+ currentTime: number
190
+ /** 当前是是否暂停或停止状态
191
+ * @readonly
192
+ */
193
+ paused: boolean
194
+ /** 音频缓冲的时间点,仅保证当前播放时间点到此时间点内容已缓冲
195
+ * @readonly
196
+ */
197
+ buffered: number
198
+ /** origin: 发送完整的 referrer; no-referrer: 不发送 */
199
+ referrerPolicy?: 'origin' | 'no-referrer' | string
198
200
  /** 播放 */
199
201
  play(): void
200
202
  /** 暂停 */
@@ -100,70 +100,76 @@ declare module '../../index' {
100
100
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/BackgroundAudioManager.html
101
101
  */
102
102
  interface BackgroundAudioManager {
103
- /** 音频已缓冲的时间,仅保证当前播放时间点到此时间点内容已缓冲。
104
- * @readonly
105
- */
106
- buffered: number
103
+ /** 音频的数据源([2.2.3](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 开始支持云文件ID)。默认为空字符串,**当设置了新的 src 时,会自动开始播放**,目前支持的格式有 m4a, aac, mp3, wav。 */
104
+ src: string
105
+ /** 音频开始播放的位置(单位:s)。 */
106
+ startTime: number
107
+ /** 音频标题,用于原生音频播放器音频标题(必填)。原生音频播放器中的分享功能,分享出去的卡片标题,也将使用该值。 */
108
+ title: string
109
+ /** 专辑名,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值。 */
110
+ epname: string
111
+ /** 歌手名,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值。 */
112
+ singer: string
107
113
  /** 封面图 URL,用于做原生音频播放器背景图。原生音频播放器中的分享功能,分享出去的卡片配图及背景也将使用该图。 */
108
114
  coverImgUrl: string
109
- /** 当前音频的播放位置(单位:s),只有在有合法 src 时返回。
110
- * @readonly
115
+ /** 页面链接,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值。 */
116
+ webUrl: string
117
+ /** 音频协议。默认值为 'http',设置 'hls' 可以支持播放 HLS 协议的直播音频。 */
118
+ protocol: string
119
+ /** 播放速度。范围 0.5-2.0。
120
+ * @default 1
111
121
  */
112
- currentTime: number
122
+ playbackRate?: number
113
123
  /** 当前音频的长度(单位:s),只有在有合法 src 时返回。
114
124
  * @readonly
115
125
  */
116
126
  duration: number
117
- /** 专辑名,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值。 */
118
- epname: string
127
+ /** 当前音频的播放位置(单位:s),只有在有合法 src 时返回。
128
+ * @readonly
129
+ */
130
+ currentTime: number
119
131
  /** 当前是否暂停或停止。
120
132
  * @readonly
121
133
  */
122
134
  paused: boolean
123
- /** 音频协议。默认值为 'http',设置 'hls' 可以支持播放 HLS 协议的直播音频。 */
124
- protocol: string
125
- /** 歌手名,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值。 */
126
- singer: string
127
- /** 音频的数据源([2.2.3](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 开始支持云文件ID)。默认为空字符串,**当设置了新的 src 时,会自动开始播放**,目前支持的格式有 m4a, aac, mp3, wav。 */
128
- src: string
129
- /** 音频开始播放的位置(单位:s)。 */
130
- startTime: number
131
- /** 音频标题,用于原生音频播放器音频标题(必填)。原生音频播放器中的分享功能,分享出去的卡片标题,也将使用该值。 */
132
- title: string
133
- /** 页面链接,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值。 */
134
- webUrl: string
135
+ /** 音频已缓冲的时间,仅保证当前播放时间点到此时间点内容已缓冲。
136
+ * @readonly
137
+ */
138
+ buffered: number
139
+ /** origin: 发送完整的 referrer; no-referrer: 不发送 */
140
+ referrerPolicy?: 'origin' | 'no-referrer' | string
135
141
  /** 播放 */
136
142
  play(): void
137
143
  /** 暂停 */
138
144
  pause(): void
139
- /** 停止 */
140
- stop(): void
141
145
  /** 跳转到指定位置,单位 s */
142
146
  seek(position: any): void
147
+ /** 停止 */
148
+ stop(): void
143
149
  /** 背景音频进入可以播放状态,但不保证后面可以流畅播放 */
144
150
  onCanplay(callback?: () => void): void
151
+ /** 音频加载中事件,当音频因为数据不足,需要停下来加载时会触发 */
152
+ onWaiting(callback?: () => void): void
153
+ /** 背景音频播放错误事件 */
154
+ onError(callback?: () => void): void
145
155
  /** 背景音频播放事件 */
146
156
  onPlay(callback?: () => void): void
147
157
  /** 背景音频暂停事件 */
148
158
  onPause(callback?: () => void): void
149
- /** 背景音频停止事件 */
150
- onStop(callback?: () => void): void
159
+ /** 背景音频开始跳转操作事件 */
160
+ onSeeking(callback?: () => void): void
161
+ /** 背景音频完成跳转操作事件 */
162
+ onSeeked(callback?: () => void): void
151
163
  /** 背景音频自然播放结束事件 */
152
164
  onEnded(callback?: () => void): void
165
+ /** 背景音频停止事件 */
166
+ onStop(callback?: () => void): void
153
167
  /** 背景音频播放进度更新事件 */
154
168
  onTimeUpdate(callback?: () => void): void
155
169
  /** 用户在系统音乐播放面板点击上一曲事件(iOS only) */
156
170
  onPrev(callback?: () => void): void
157
171
  /** 用户在系统音乐播放面板点击下一曲事件(iOS only) */
158
172
  onNext(callback?: () => void): void
159
- /** 背景音频播放错误事件 */
160
- onError(callback?: () => void): void
161
- /** 音频加载中事件,当音频因为数据不足,需要停下来加载时会触发 */
162
- onWaiting(callback?: () => void): void
163
- /** 背景音频开始跳转操作事件 */
164
- onSeeking(callback?: () => void): void
165
- /** 背景音频完成跳转操作事件 */
166
- onSeeked(callback?: () => void): void
167
173
  }
168
174
 
169
175
  interface TaroStatic {
@@ -270,7 +270,7 @@ declare module '../../index' {
270
270
  previewImage(option: previewImage.Option): Promise<TaroGeneral.CallbackResult>
271
271
 
272
272
  /** 预览图片和视频。
273
- * @supported weapp 基础库 2.12.0 开始支持,低版本需做兼容处理。
273
+ * @supported weapp
274
274
  * @example
275
275
  * ```tsx
276
276
  * Taro.previewMedia({
@@ -29,7 +29,7 @@ declare module '../../index' {
29
29
 
30
30
  interface TaroStatic {
31
31
  /** 打开微信客服。了解更多信息,可以参考微信客服介绍:https://work.weixin.qq.com/kf/。
32
- * @supported weapp 基础库 2.19.0 开始支持,低版本需做兼容处理。
32
+ * @supported weapp
33
33
  * @example
34
34
  * ```tsx
35
35
  * Taro.openCustomerServiceChat({
@@ -54,9 +54,7 @@ declare module '../../index' {
54
54
  }
55
55
 
56
56
  interface TaroStatic {
57
- /**
58
- * 退出当前小程序。必须有点击行为才能调用成功。
59
- * 基础库 2.17.3 开始支持
57
+ /** 退出当前小程序。必须有点击行为才能调用成功。
60
58
  * @supported weapp
61
59
  * @example
62
60
  * ```tsx
@@ -141,6 +141,40 @@ declare module '../../index' {
141
141
  }
142
142
  }
143
143
 
144
+ /** `MediaQueryObserver` 对象,用于监听页面 media query 状态的变化,如界面的长宽是不是在某个指定的范围内。 */
145
+ interface MediaQueryObserver {
146
+ /** 开始监听页面 media query 变化情况 */
147
+ observe(descriptor: MediaQueryObserver.descriptor, callback: MediaQueryObserver.observeCallback): void
148
+ /** 停止监听。回调函数将不再触发 */
149
+ disconnect(): void
150
+ }
151
+
152
+ namespace MediaQueryObserver {
153
+ /** media query 描述符 */
154
+ interface descriptor {
155
+ /** 页面最小宽度 (单位: px) */
156
+ minWidth: number
157
+ /** 页面最大宽度 (单位: px) */
158
+ maxWidth: number
159
+ /** 页面宽度 (单位: px) */
160
+ width: number
161
+ /** 页面最小高度 (单位: px) */
162
+ minHeight: number
163
+ /** 页面最大高度(px 为单位) */
164
+ maxHeight: number
165
+ /** 页面高度(px 为单位) */
166
+ height: number
167
+ /** 屏幕方向 */
168
+ orientation: 'landscape' | 'portrait'
169
+ }
170
+
171
+ /** 监听 media query 状态变化的回调函数 */
172
+ type observeCallback = (res: {
173
+ /** 页面的当前状态是否满足所指定的 media query */
174
+ matches: boolean
175
+ }) => void
176
+ }
177
+
144
178
  /** 查询节点信息的对象
145
179
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.html
146
180
  */
@@ -23,29 +23,22 @@ declare module './index' {
23
23
  onTabItemTap?(obj: TabItemTapObject): void
24
24
  onResize?(obj: PageResizeObject): void
25
25
  }
26
-
27
26
  interface ComponentOptions {
28
27
  addGlobalClass?: boolean
29
28
  styleIsolation?: 'isolated' | 'apply-shared' | 'shared'
30
29
  }
31
-
32
30
  interface ComponentClass<P = {}, S = any> extends StaticLifecycle<P, S> {
33
31
  new (...args: any[]): Component<P, {}>
34
32
  propTypes?: any // TODO: Use prop-types type definition.
35
33
  defaultProps?: Partial<P>
36
34
  displayName?: string
37
35
  }
38
-
39
36
  // ref: packages/taro-runtime/src/current.ts
40
37
  interface RouterInfo<TParams extends Partial<Record<string, string>> = Partial<Record<string, string>>> {
41
- /**
42
- * 路由参数。
43
- */
38
+ /** 路由参数 */
44
39
  params: TParams
45
40
 
46
- /**
47
- * 页面路径。
48
- */
41
+ /** 页面路径 */
49
42
  path: string
50
43
 
51
44
  onReady: string
@@ -55,13 +48,10 @@ declare module './index' {
55
48
  shareTicket: string | undefined
56
49
  scene: number | undefined
57
50
  }
58
-
59
51
  interface Component<P = {}, S = {}, SS = any> extends ComponentLifecycle<P, S, SS> {
60
52
  $scope?: any
61
53
  }
62
-
63
54
  type PropsWithChildren<P> = P & { children?: React.ReactNode }
64
-
65
55
  interface FunctionComponent<P = {}> {
66
56
  (props: PropsWithChildren<P>, context?: any): React.ReactElement | null
67
57
  propTypes?: any // TODO: Use prop-types type definition.
@@ -70,13 +60,10 @@ declare module './index' {
70
60
  options?: ComponentOptions
71
61
  externalClasses?: string[]
72
62
  }
73
-
74
63
  type FC<P = {}> = FunctionComponent<P>
75
-
76
64
  interface StatelessFunctionComponent {
77
65
  (): JSX.Element
78
66
  }
79
-
80
67
  type SFC = StatelessFunctionComponent
81
68
 
82
69
  interface Show {
@@ -85,23 +72,19 @@ declare module './index' {
85
72
  onShow?(): void
86
73
  onHide?(): void
87
74
  }
88
-
89
75
  interface AppInstance extends Show {
90
76
  mount(component: React.ComponentClass | Vue.ComponentOptions<Vue>, id: string, cb: () => void): void
91
77
  componentDidShow?(options?: Record<string, unknown>): void
92
78
  onShow?(options?: Record<string, unknown>): void
93
79
  unmount(id: string, cb: () => void): void
94
80
  }
95
-
96
81
  type Target = Record<string, unknown> & { dataset: Record<string, unknown>; id: string }
97
-
98
82
  interface MpEvent {
99
83
  type: string
100
84
  detail: Record<string, unknown>
101
85
  target: Target
102
86
  currentTarget: Target
103
87
  }
104
-
105
88
  interface PageLifeCycle extends Show {
106
89
  onPullDownRefresh?(): void
107
90
  onReachBottom?(): void
@@ -117,50 +100,87 @@ declare module './index' {
117
100
  onLoad(options: Record<string, unknown>): void
118
101
  onUnload(): void
119
102
  }
120
-
121
- interface PageInstance extends PageLifeCycle {
122
- /**
123
- * 页面配置。
124
- */
103
+ interface ComponentInstance<
104
+ TData extends Record<string, unknown> = Record<string, unknown>,
105
+ TParams extends Record<string, string> = Record<string, string>
106
+ > {
107
+ /** 组件的文件路径 */
108
+ is?: string
109
+ /** 节点id */
110
+ id?: string
111
+ /** 节点dataset */
112
+ dataset?: string
113
+ /** 组件数据,包括内部数据和属性值 */
114
+ data?: TData
115
+ /** 组件数据,包括内部数据和属性值(与 data 一致) */
116
+ properties?: TData
117
+ /** 相对于当前自定义组件的 Router 对象 */
118
+ router?: RouterInfo<TParams>
119
+ /** 相对于当前自定义组件所在页面的 Router 对象 */
120
+ pageRouter?: RouterInfo<TParams>
121
+ /** 设置data并执行视图层渲染 */
122
+ setData?(newData: Partial<TData>): void
123
+ /** 检查组件是否具有 behavior (检查时会递归检查被直接或间接引入的所有behavior) */
124
+ hasBehavior?(behavior: unknown): boolean
125
+ /** 触发事件,参见[组件间通信与事件](https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/events.html) */
126
+ triggerEvent?(name: string, detail: Record<string, unknown>, options: {
127
+ /** 事件是否冒泡 */
128
+ bubbles?: boolean
129
+ /** 事件是否可以穿越组件边界,为 false 时,事件将只能在引用组件的节点树上触发,不进入其他任何组件内部 */
130
+ composed?: boolean
131
+ /** 事件是否拥有捕获阶段 */
132
+ capturePhase?: boolean
133
+ }): void
134
+ /** 创建一个 SelectorQuery 对象,选择器选取范围为这个组件实例内 */
135
+ createSelectorQuery?(): SelectorQuery
136
+ /** 创建一个 IntersectionObserver 对象,选择器选取范围为这个组件实例内 */
137
+ createIntersectionObserver?(): IntersectionObserver
138
+ /** 创建一个 MediaQueryObserver 对象 */
139
+ createMediaQueryObserver?(): MediaQueryObserver
140
+ /** 使用选择器选择组件实例节点,返回匹配到的第一个组件实例对象(会被 wx://component-export 影响) */
141
+ selectComponent?<
142
+ TD extends Record<string, unknown> = Record<string, unknown>,
143
+ TP extends Record<string, string> = Record<string, string>
144
+ >(selector: string): ComponentInstance<TD, TP>
145
+ /** 使用选择器选择组件实例节点,返回匹配到的全部组件实例对象组成的数组(会被 wx://component-export 影响) */
146
+ selectAllComponents?<
147
+ TD extends Record<string, unknown> = Record<string, unknown>,
148
+ TP extends Record<string, string> = Record<string, string>
149
+ >(selector: string): ComponentInstance<TD, TP>
150
+ /** 选取当前组件节点所在的组件实例(即组件的引用者),返回它的组件实例对象(会被 wx://component-export 影响) */
151
+ selectOwnerComponent?<
152
+ TD extends Record<string, unknown> = Record<string, unknown>,
153
+ TP extends Record<string, string> = Record<string, string>
154
+ >(): ComponentInstance<TD, TP>
155
+ /** 获取这个关系所对应的所有关联节点,参见[组件间关系](https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/relations.html) */
156
+ getRelationNodes?(relationKey: string): NodesRef[]
157
+ /** 立刻执行 callback ,其中的多个 setData 之间不会触发界面绘制(只有某些特殊场景中需要,如用于在不同组件同时 setData 时进行界面绘制同步) */
158
+ groupSetData?(callback: () => void): void
159
+ /** 返回当前页面的 custom-tab-bar 的组件实例,详见[自定义 tabBar](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/custom-tabbar.html) */
160
+ getTabBar?(): ComponentInstance
161
+ /** 返回页面标识符(一个字符串),可以用来判断几个自定义组件实例是不是在同一个页面内 */
162
+ getPageId?(): string
163
+ /** 执行关键帧动画,详见[动画](https://developers.weixin.qq.com/miniprogram/dev/framework/view/animation.html) */
164
+ animate?(selector: string, keyFrames: KeyFrame[], duration: number, callback: () => void): void
165
+ /** 清除关键帧动画,详见[动画](https://developers.weixin.qq.com/miniprogram/dev/framework/view/animation.html) */
166
+ clearAnimation?(selector: string, options: ClearAnimationOptions, callback: () => void): void
167
+ /** 清除关键帧动画,详见[动画](https://developers.weixin.qq.com/miniprogram/dev/framework/view/animation.html) */
168
+ setUpdatePerformanceListener?(options: {
169
+ /** 是否返回变更的 data 字段信息 */
170
+ withDataPaths?: boolean
171
+ }, listener: () => void): void
172
+ }
173
+ interface PageInstance extends PageLifeCycle, ComponentInstance {
174
+ /** 页面配置 */
125
175
  config?: PageConfig
126
176
  data?: Record<string, unknown>
127
177
  path?: string
128
178
  options?: Record<string, unknown>
129
- /**
130
- * 执行关键帧动画,详见[动画](https://developers.weixin.qq.com/miniprogram/dev/framework/view/animation.html)
131
- *
132
- * 最低基础库版本:[`2.9.0`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
133
- **/
134
- animate?(selector: string, keyFrames: KeyFrame[], duration: number, callback: () => void): void
135
- /**
136
- * 执行关键帧动画,详见[动画](https://developers.weixin.qq.com/miniprogram/dev/framework/view/animation.html)
137
- *
138
- * 最低基础库版本:[`2.9.0`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
139
- **/
140
- animate?(
141
- selector: string,
142
- keyFrames: ScrollTimelineKeyframe[],
143
- duration: number,
144
- scrollTimeline: ScrollTimelineOption
145
- ): void
146
- /**
147
- * 清除关键帧动画,详见[动画](https://developers.weixin.qq.com/miniprogram/dev/framework/view/animation.html)
148
- *
149
- * 最低基础库版本:[`2.9.0`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
150
- **/
151
- clearAnimation?(selector: string, callback: () => void): void
152
- /**
153
- * 清除关键帧动画,详见[动画](https://developers.weixin.qq.com/miniprogram/dev/framework/view/animation.html)
154
- *
155
- * 最低基础库版本:[`2.9.0`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
156
- **/
157
- clearAnimation?(selector: string, options: ClearAnimationOptions, callback: () => void): void
158
179
  }
159
-
160
180
  interface TaroStatic {
161
181
  memo<P = {}>(
162
182
  FunctionComponent: FunctionComponent<P>,
163
- compare?: (oldProps: P, newProps: P) => Boolean
183
+ compare?: (oldProps: P, newProps: P) => boolean
164
184
  ): FunctionComponent<P>
165
185
  }
166
186
  }
@@ -5,201 +5,174 @@ declare module './index' {
5
5
  * 微信小程序全局 Window 配置和页面配置的公共项目
6
6
  */
7
7
  interface CommonConfig {
8
- /**
9
- * 导航栏背景颜色,HexColor
10
- * default: #000000
8
+ /** 导航栏背景颜色,HexColor
9
+ * @default: "#000000"
11
10
  */
12
11
  navigationBarBackgroundColor?: string
13
- /**
14
- * 导航栏标题颜色,仅支持 black/white
15
- * default: 'white'
12
+ /** 导航栏标题颜色,仅支持 black/white
13
+ * @default: "white"
16
14
  */
17
15
  navigationBarTextStyle?: 'white' | 'black'
18
- /**
19
- * 导航栏标题文字内容
20
- */
16
+ /** 导航栏标题文字内容 */
21
17
  navigationBarTitleText?: string
22
- /**
23
- * 导航栏样式,仅支持以下值:
24
- * default 默认样式
25
- * custom 自定义导航栏
18
+ /** 导航栏样式,仅支持以下值:
19
+ * - default 默认样式
20
+ * - custom 自定义导航栏
26
21
  */
27
22
  navigationStyle?: 'default' | 'custom'
28
- /**
29
- * 窗口的背景色, HexColor
30
- * default: #ffffff
23
+ /** 窗口的背景色, HexColor
24
+ * @default: "#ffffff"
31
25
  */
32
26
  backgroundColor?: string
33
- /**
34
- * 下拉背景字体、loading 图的样式,仅支持 dark/light
35
- * default: 'dark'
27
+ /** 下拉背景字体、loading 图的样式,仅支持 dark/light
28
+ * @default: "dark"
36
29
  */
37
30
  backgroundTextStyle?: 'dark' | 'light'
38
- /**
39
- * 顶部窗口的背景色,仅 iOS 支持
40
- * default: #ffffff
31
+ /** 顶部窗口的背景色,仅 iOS 支持
32
+ * @default: "#ffffff"
41
33
  */
42
34
  backgroundColorTop?: string
43
- /**
44
- * 底部窗口的背景色,仅 iOS 支持
45
- * default: #ffffff
35
+ /** 底部窗口的背景色,仅 iOS 支持
36
+ * @default: "#ffffff"
46
37
  */
47
38
  backgroundColorBottom?: string
48
- /**
49
- * 是否开启下拉刷新
50
- * default: false
39
+ /** 是否开启下拉刷新
40
+ * @default: false
51
41
  */
52
42
  enablePullDownRefresh?: boolean
53
- /**
54
- * 页面上拉触底事件触发时距页面底部距离,单位为px
55
- * default: 50
43
+ /** 页面上拉触底事件触发时距页面底部距离,单位为 px
44
+ * @default: 50
56
45
  */
57
46
  onReachBottomDistance?: number
47
+ /** 屏幕旋转设置
48
+ * @see https://developers.weixin.qq.com/miniprogram/dev/framework/view/resizable.html
49
+ */
50
+ pageOrientation?: 'auto' | 'portrait' | 'landscape'
51
+ /** 页面初始渲染缓存配置,支持 static / dynamic */
52
+ initialRenderingCache?: 'static' | 'dynamic'
53
+ /** 重新启动策略配置
54
+ * - homePage: 如果从这个页面退出小程序,下次将从首页冷启动
55
+ * - homePageAndLatestPage: 如果从这个页面退出小程序,下次冷启动后立刻加载这个页面,页面的参数保持不变(不可用于 tab 页)
56
+ * @default "homePage"
57
+ */
58
+ restartStrategy?: 'homePage' | 'homePageAndLatestPage'
58
59
  }
59
60
 
60
61
  interface PageConfig extends CommonConfig {
61
- /**
62
- * 设置为 true 则页面整体不能上下滚动;
62
+ /** 设置为 true 则页面整体不能上下滚动;
63
63
  * 只在页面配置中有效,无法在 app.json 中设置该项
64
- * default: false
64
+ * @default: false
65
65
  */
66
66
  disableScroll?: boolean
67
- /**
68
- * 禁止页面右滑手势返回
69
- * default: false
67
+ /** 禁止页面右滑手势返回
70
68
  *
71
69
  * **注意** 自微信客户端 7.0.5 开始,页面配置中的 disableSwipeBack 属性将不再生效,
72
70
  * 详情见[右滑手势返回能力调整](https://developers.weixin.qq.com/community/develop/doc/000868190489286620a8b27f156c01)公告
71
+ * @default: false
73
72
  * @since 微信客户端 7.0.0
74
73
  */
75
74
  disableSwipeBack?: boolean
76
- /**
77
- * 是否启用分享给好友。
78
- *
75
+ /** 是否启用分享给好友。
79
76
  * @default false
80
77
  */
81
78
  enableShareAppMessage?: boolean
82
- /**
83
- * 是否启用分享到朋友圈。
84
- *
79
+ /** 是否启用分享到朋友圈。
85
80
  * @default false
86
81
  */
87
82
  enableShareTimeline?: boolean
83
+ /** 页面自定义组件配置
84
+ * @see https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/
85
+ */
86
+ usingComponents?: Record<string, string>
87
+ /** 指定使用升级后的 weui 样式
88
+ * - v2: 可表明启用新版的组件样式
89
+ * @default default
90
+ */
91
+ style?: string
92
+ /** 单页模式相关配置 */
93
+ singlePage?: SinglePage
88
94
  }
89
95
 
90
96
  interface WindowConfig extends CommonConfig {
91
- /**
92
- * 屏幕旋转设置
93
- * 支持 auto / portrait / landscape
94
- * default: portrait
95
- * 详见 [响应显示区域变化](https://developers.weixin.qq.com/miniprogram/dev/framework/view/resizable.html)
97
+ /** 切入系统后台时,隐藏页面内容,保护用户隐私。支持 hidden / none
98
+ * @default none
96
99
  */
97
- pageOrientation?: 'auto' | 'portrait' | 'landscape'
98
- /**
99
- * 是否允许下拉刷新
100
- * default: NO
100
+ visualEffectInBackground?: 'hidden' | 'none'
101
+ /** 是否允许下拉刷新
101
102
  * 备注:下拉刷新生效的前提是 allowsBounceVertical 值为 YES
103
+ * @default: "NO"
102
104
  */
103
105
  pullRefresh?: 'YES' | 'NO' | boolean
104
- /**
105
- * 是否允许向下拉拽
106
- * default: YES
106
+ /** 是否允许向下拉拽
107
+ * @default: "YES"
107
108
  */
108
109
  allowsBounceVertical?: 'YES' | 'NO'
109
110
  }
110
111
 
111
112
  interface TabBarItem {
112
- /**
113
- * 页面路径,必须在 pages 中先定义
114
- */
113
+ /** 页面路径,必须在 pages 中先定义 */
115
114
  pagePath: string
116
- /**
117
- * tab 上按钮文字
118
- */
115
+ /** tab 上按钮文字 */
119
116
  text: string
120
- /**
121
- * 图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px,当 postion 为 top 时,此参数无效,不支持网络图片
122
- */
117
+ /** 图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px,当 position 为 top 时,此参数无效,不支持网络图片 */
123
118
  iconPath?: string
124
- /**
125
- * 选中时的图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px ,当 postion 为 top 时,此参数无效
126
- */
119
+ /** 选中时的图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px ,当 position 为 top 时,此参数无效 */
127
120
  selectedIconPath?: string
128
121
  }
129
122
 
130
123
  interface TabBar {
131
- /**
132
- * tab 上的文字默认颜色
133
- */
124
+ /** tab 上的文字默认颜色 */
134
125
  color?: string
135
- /**
136
- * tab 上的文字选中时的颜色
137
- */
126
+ /** tab 上的文字选中时的颜色 */
138
127
  selectedColor?: string
139
- /**
140
- * tab 的背景色
141
- */
128
+ /** tab 的背景色 */
142
129
  backgroundColor?: string
143
- /**
144
- * tabbar上边框的颜色, 仅支持 black/white
130
+ /** tabbar上边框的颜色, 仅支持 black/white
145
131
  * @default: black
146
132
  */
147
133
  borderStyle?: 'black' | 'white'
148
- /**
149
- * tabar 的位置,可选值 bottom、top
134
+ /** tab 的列表,详见 list 属性说明,最少 2 个、最多 5 个 tab */
135
+ list: TabBarItem[]
136
+ /** tabbar 的位置,可选值 bottom、top
150
137
  * @default: 'bottom'
151
138
  */
152
139
  position?: 'bottom' | 'top'
153
- /**
154
- * 自定义 tabBar,见[详情](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/custom-tabbar.html)
140
+ /** 自定义 tabBar,见[详情](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/custom-tabbar.html)
155
141
  * @default false
156
142
  * @since 2.1.0
157
143
  */
158
144
  custom?: boolean
159
-
160
- list: TabBarItem[]
161
145
  }
162
146
 
163
147
  interface NetworkTimeout {
164
- /**
165
- * wx.request 的超时时间,单位毫秒。
148
+ /** Taro.request 的超时时间,单位毫秒。
166
149
  * @default 60000
167
150
  */
168
151
  request?: number
169
- /**
170
- * wx.connectSocket 的超时时间,单位毫秒。
152
+ /** Taro.connectSocket 的超时时间,单位毫秒。
171
153
  * @default 60000
172
154
  */
173
155
  connectSocket?: number
174
- /**
175
- * wx.uploadFile 的超时时间,单位毫秒。
156
+ /** Taro.uploadFile 的超时时间,单位毫秒。
176
157
  * @default 60000
177
158
  */
178
159
  uploadFile?: number
179
- /**
180
- * wx.downloadFile 的超时时间,单位毫秒。
160
+ /** Taro.downloadFile 的超时时间,单位毫秒。
181
161
  * @default 60000
182
162
  */
183
163
  downloadFile?: number
184
164
  }
185
165
 
186
166
  interface SubPackage {
187
- /**
188
- * 分包根路径
167
+ /** 分包根路径
189
168
  * - 注意:不能放在主包pages目录下
190
169
  */
191
170
  root: string
192
- /**
193
- * 分包路径下的所有页面配置
194
- */
171
+ /** 分包路径下的所有页面配置 */
195
172
  pages: string[]
196
- /**
197
- * 分包别名,分包预下载时可以使用
198
- */
173
+ /** 分包别名,分包预下载时可以使用 */
199
174
  name?: string
200
- /**
201
- * 分包是否是独立分包
202
- */
175
+ /** 分包是否是独立分包 */
203
176
  independent?: boolean
204
177
  }
205
178
 
@@ -212,15 +185,12 @@ declare module './index' {
212
185
 
213
186
  interface PreloadRule {
214
187
  [key: string]: {
215
- /**
216
- *进入页面后预下载分包的 root 或 name。__APP__ 表示主包。
217
- */
188
+ /** 进入页面后预下载分包的 root 或 name。__APP__ 表示主包。 */
218
189
  packages: string[]
219
- /**
220
- * 在指定网络下预下载,可选值为:
221
- * all: 不限网络
222
- * wifi: wifi下预下载
223
- * @default wifi
190
+ /** 在指定网络下预下载,可选值为:
191
+ * - all: 不限网络
192
+ * - wifi: 仅wifi下预下载
193
+ * @default "wifi"
224
194
  */
225
195
  network?: 'all' | 'wifi'
226
196
  }
@@ -228,55 +198,53 @@ declare module './index' {
228
198
 
229
199
  interface Permission {
230
200
  [key: string]: {
231
- /**
232
- * 小程序获取权限时展示的接口用途说明。最长30个字符
233
- */
201
+ /** 小程序获取权限时展示的接口用途说明。最长30个字符 */
234
202
  desc: string
235
203
  }
236
204
  }
237
205
 
206
+ interface SinglePage {
207
+ /** 导航栏与页面的相交状态,值为 float 时表示导航栏浮在页面上,与页面相交;值为 squeezed 时表示页面被导航栏挤压,与页面不相交
208
+ * @default "默认自动调整,若原页面是自定义导航栏,则为 float,否则为 squeezed"
209
+ */
210
+ navigationBarFit?: string
211
+ }
212
+
238
213
  interface RouterAnimate {
239
- /**
240
- * 动画切换时间,单位毫秒
214
+ /** 动画切换时间,单位毫秒
241
215
  * @default 300
242
216
  */
243
217
  duration?: number
244
- /**
245
- * 动画切换时间,单位毫秒
218
+ /** 动画切换时间,单位毫秒
246
219
  * @default 50
247
220
  */
248
221
  delay?: number
249
222
  }
250
223
 
251
224
  interface AppConfig {
252
- /**
253
- * 小程序默认启动首页,未指定 entryPagePath 时,数组的第一项代表小程序的初始页面(首页)。
254
- */
225
+ /** 小程序默认启动首页,未指定 entryPagePath 时,数组的第一项代表小程序的初始页面(首页)。 */
255
226
  entryPagePath?: string
256
- /**
257
- * 接受一个数组,每一项都是字符串,来指定小程序由哪些页面组成,数组的第一项代表小程序的初始页面
258
- */
227
+ /** 接受一个数组,每一项都是字符串,来指定小程序由哪些页面组成,数组的第一项代表小程序的初始页面 */
259
228
  pages?: string[]
229
+ /** 全局的默认窗口表现 */
230
+ window?: WindowConfig
231
+ /** 底部 tab 栏的表现 */
260
232
  tabBar?: TabBar
261
- /**
262
- * 各类网络请求的超时时间,单位均为毫秒。
263
- */
233
+ /** 各类网络请求的超时时间,单位均为毫秒。 */
264
234
  networkTimeout?: NetworkTimeout
265
- /**
266
- * 是否开启 debug 模式,默认关闭
235
+ /** 是否开启 debug 模式,默认关闭
267
236
  * @default false
268
237
  */
269
238
  debug?: boolean
270
- /**
271
- * 启用插件功能页时,插件所有者小程序需要设置其 functionalPages 为 true。
239
+ /** 启用插件功能页时,插件所有者小程序需要设置其 functionalPages 为 true。
272
240
  * @see https://developers.weixin.qq.com/miniprogram/dev/framework/plugin/functional-pages.html
273
241
  * @default false
274
242
  * @since 2.1.0
275
243
  */
276
244
  functionalPages?: boolean
277
- /**
278
- * 分包加载配置
279
- * 示例:
245
+ /** 分包结构配置
246
+ * @example
247
+ * ```json
280
248
  * [
281
249
  * {
282
250
  * root: 'packages/module',
@@ -285,77 +253,118 @@ declare module './index' {
285
253
  * ]
286
254
  * }
287
255
  * ]
256
+ * ```
288
257
  * @since 1.7.3
289
258
  */
290
259
  subPackages?: SubPackage[]
291
260
  subpackages?: SubPackage[]
292
- /**
293
- * Worker 代码放置的目录
261
+ /** Worker 代码放置的目录
294
262
  * 使用 Worker 处理多线程任务时,设置 Worker 代码放置的目录
295
263
  * @since 1.9.90
296
264
  */
297
265
  workers?: string
298
- /**
299
- * 申明需要后台运行的能力,类型为数组。目前支持以下项目:
266
+ /** 申明需要后台运行的能力,类型为数组。目前支持以下项目:
267
+ * - audio: 后台音乐播放
268
+ * - location: 后台定位
300
269
  * @since 微信客户端 6.7.2 及以上版本支持
301
270
  */
302
- requiredBackgroundModes?: ['audio']
303
- /**
304
- * 使用到的插件
271
+ requiredBackgroundModes?: ('audio' | 'location')[]
272
+ /** 使用到的插件
305
273
  * @since 1.9.6
306
274
  */
307
275
  plugins?: Plugins
308
- /**
309
- * 声明分包预下载的规则。
276
+ /** 声明分包预下载的规则。
310
277
  * preloadRule 中,key 是页面路径,value 是进入此页面的预下载配置
311
278
  * 注意: 分包预下载目前只支持通过配置方式使用,暂不支持通过调用API完成。
312
279
  * vConsole 里有 preloadSubpackages 开头的日志信息,可以用来验证预下载的情况。
313
280
  * @since 2.3.0
314
281
  */
315
282
  preloadRule?: PreloadRule
316
- /**
317
- * iPad 小程序是否支持屏幕旋转
283
+ /** PC 小程序是否支持用户任意改变窗口大小(包括最大化窗口);iPad 小程序是否支持屏幕旋转
318
284
  * @default false
319
285
  * @since 2.3.0
320
286
  */
321
287
  resizable?: boolean
322
- /**
323
- * 需要跳转的小程序列表
288
+ /** 需要跳转的小程序列表
324
289
  * @since 2.4.0
325
290
  */
326
291
  navigateToMiniProgramAppIdList?: string[]
327
- /**
328
- * 小程序接口权限相关设置
292
+ /** 全局自定义组件配置
293
+ * @see https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/
294
+ */
295
+ usingComponents?: Record<string, string>
296
+ /** 小程序接口权限相关设置
329
297
  * @since 微信客户端 7.0.0
330
298
  */
331
299
  permission?: Permission
332
- /**
333
- * 指定使用升级后的weui样式
334
- * @since 2.8.0
335
- */
336
- style?: 'v2'
300
+ /** 指明 sitemap.json 的位置 */
301
+ sitemapLocation?: string
302
+ /** 指定使用升级后的 weui 样式
303
+ * - v2: 可表明启用新版的组件样式
304
+ * @default default
305
+ */
306
+ style?: string
307
+ /** 指定需要引用的扩展库
308
+ * 指定需要引用的扩展库。目前支持以下项目:
309
+ * - kbone: 多端开发框架
310
+ * - weui: WeUI 组件库
311
+ */
312
+ useExtendedLib?: Record<string, boolean>
313
+ /** 微信消息用小程序打开
314
+ * @see https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/location-message.html
315
+ */
316
+ entranceDeclare?: {
317
+ /** 声明“位置消息”场景进入小程序的启动页面 */
318
+ locationMessage?: {
319
+ /** 启动页路径,必须是在pages中已经定义 */
320
+ path?: string
321
+ /** 启动页参数 */
322
+ query?: string
323
+ }
324
+ }
337
325
  /**
338
326
  * 配置 darkMode 为 true,即表示当前小程序已适配 DarkMode
339
327
  * @since 2.11.0
340
328
  */
341
329
  darkmode?: boolean
342
- /**
343
- * 指定 darkMode 变量配置文件 theme.json 路径
330
+ /** 指明 theme.json 的位置,darkmode为true为必填
344
331
  * @since 2.11.0
345
332
  */
346
333
  themeLocation?: string
347
- /**
348
- * 接受一个数组,每一项都是字符串,来指定编译为原生小程序组件的组件入口
349
- */
334
+ /** 配置自定义组件代码按需注入 */
335
+ lazyCodeLoading?: string
336
+ /** 单页模式相关配置 */
337
+ singlePage?: SinglePage
338
+ /** 聊天素材小程序打开相关配置
339
+ * @see https://developers.weixin.qq.com/miniprogram/dev/framework/material/support_material.html
340
+ */
341
+ supportedMaterials?: {
342
+ /** 支持文件类型的MimeType,音频,视频支持二级配置的通配模式,例如: video/*。通配模式配置和精确类型配置同时存在时,则优先使用精确类型的配置(例如video/*和video/mp4同时存在,会优先使用video/mp4的配置)。 */
343
+ materialType: string
344
+ /** 开发者配置的标题,在素材页面会展示该标题,配置中必须包含${nickname}, 代码包编译后会自动替换为小程序名称,如果声明了简称则会优先使用简称。除去${nickname}其余字数不得超过6个。 */
345
+ name: string
346
+ /** 用途描述,会在推荐列表展示该描述,限定字数不超过22个。 */
347
+ desc: string
348
+ /** 在该场景下打开小程序时跳转页面 */
349
+ path: string
350
+ }
351
+ /** 定制化型服务商票据 */
352
+ serviceProviderTicket?: string
353
+ /** 半屏小程序 appId */
354
+ embeddedAppIdList?: string[]
355
+ /** 视频号直播半屏场景设置 */
356
+ halfPage?: {
357
+ /** 视频号直播打开的第一个页面的全屏状态使用自定义顶部,支持 */
358
+ firstPageNavigationStyle?: 'default' | 'custom'
359
+ }
360
+ /** 接受一个数组,每一项都是字符串,来指定编译为原生小程序组件的组件入口 */
350
361
  components?: string[]
351
- /**
352
- * 渲染页面的容器 id
362
+ /** 渲染页面的容器 id
353
363
  * @default "app"
354
364
  * @since 3.3.18
355
365
  */
356
366
  appId?: string
357
- /**
358
- * 是否开启 h5 端路由动画功能,默认开启
367
+ /** 是否开启 h5 端路由动画功能,默认开启
359
368
  * @supported h5
360
369
  * @since 3.3.18
361
370
  */
@@ -363,12 +372,7 @@ declare module './index' {
363
372
  }
364
373
 
365
374
  interface Config extends PageConfig, AppConfig {
366
- usingComponents?: {
367
- [key: string]: string
368
- }
369
- window?: WindowConfig
370
375
  cloud?: boolean
371
- pageOrientation?: 'auto' | 'portrait' | 'landscape'
372
376
  }
373
377
 
374
378
  interface TaroStatic {