@tarojs/taro 3.4.0-beta.1 → 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 +5 -7
- package/types/api/base/weapp/app-event.d.ts +3 -3
- package/types/api/canvas/index.d.ts +21 -0
- package/types/api/media/audio.d.ts +24 -22
- package/types/api/media/background-audio.d.ts +39 -33
- package/types/api/media/image.d.ts +1 -81
- package/types/api/media/video.d.ts +290 -31
- package/types/api/network/request.d.ts +18 -1
- package/types/api/open-api/customer-service.d.ts +1 -1
- package/types/api/open-api/navigate.d.ts +1 -3
- package/types/api/wxml/index.d.ts +34 -0
- package/types/compile.d.ts +106 -106
- package/types/taro.component.d.ts +82 -60
- package/types/taro.config.d.ts +174 -170
- package/types/taro.extend.d.ts +0 -17
- package/types/taro.hooks.d.ts +12 -12
- package/types/taro.lifecycle.d.ts +7 -0
- package/h5.js +0 -4
package/types/compile.d.ts
CHANGED
|
@@ -53,12 +53,12 @@ export type IOption = Record<string, any>
|
|
|
53
53
|
|
|
54
54
|
export interface ICopyOptions {
|
|
55
55
|
patterns: {
|
|
56
|
-
from: string
|
|
57
|
-
to: string
|
|
58
|
-
ignore?: string[]
|
|
59
|
-
transform?: Function
|
|
56
|
+
from: string
|
|
57
|
+
to: string
|
|
58
|
+
ignore?: string[]
|
|
59
|
+
transform?: Function
|
|
60
60
|
watch?: boolean
|
|
61
|
-
}[]
|
|
61
|
+
}[]
|
|
62
62
|
options: {
|
|
63
63
|
ignore?: string[]
|
|
64
64
|
}
|
|
@@ -68,11 +68,11 @@ export interface ISassOptions {
|
|
|
68
68
|
/**
|
|
69
69
|
* 引入的全局 sass 文件,如果要引入多个文件,支持数组形式传入
|
|
70
70
|
*/
|
|
71
|
-
resource?: string | string[]
|
|
71
|
+
resource?: string | string[]
|
|
72
72
|
/**
|
|
73
73
|
* 项目根目录的绝对地址(若为小程序云开发模板,则应该是client目录)
|
|
74
74
|
*/
|
|
75
|
-
projectDirectory?: string
|
|
75
|
+
projectDirectory?: string
|
|
76
76
|
/**
|
|
77
77
|
* 全局 scss 变量,若 data 与 resource 中设置了同样的变量,则 data 的优先级高于 resource
|
|
78
78
|
*/
|
|
@@ -89,21 +89,21 @@ export namespace PostcssOption {
|
|
|
89
89
|
generateScopedName: string | ((localName: string, absoluteFilePath: string) => string)
|
|
90
90
|
}>
|
|
91
91
|
export type url = TogglableOptions<{
|
|
92
|
-
limit: number
|
|
92
|
+
limit: number
|
|
93
93
|
basePath?: string | string[]
|
|
94
94
|
}>
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
export interface IPostcssOption {
|
|
98
|
-
autoprefixer?: TogglableOptions
|
|
99
|
-
pxtransform?: TogglableOptions
|
|
100
|
-
cssModules?: PostcssOption.cssModules
|
|
101
|
-
url?: PostcssOption.url
|
|
98
|
+
autoprefixer?: TogglableOptions
|
|
99
|
+
pxtransform?: TogglableOptions
|
|
100
|
+
cssModules?: PostcssOption.cssModules
|
|
101
|
+
url?: PostcssOption.url
|
|
102
102
|
[key: string]: any
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
export interface ICompileOption {
|
|
106
|
-
exclude?: string[]
|
|
106
|
+
exclude?: string[]
|
|
107
107
|
include?: string[]
|
|
108
108
|
}
|
|
109
109
|
|
|
@@ -113,85 +113,85 @@ interface Runtime {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
export interface IMiniAppConfig {
|
|
116
|
-
appOutput?: boolean
|
|
117
|
-
enableSourceMap?: boolean
|
|
118
|
-
sourceMapType?: string
|
|
119
|
-
debugReact?: boolean
|
|
116
|
+
appOutput?: boolean
|
|
117
|
+
enableSourceMap?: boolean
|
|
118
|
+
sourceMapType?: string
|
|
119
|
+
debugReact?: boolean
|
|
120
120
|
minifyXML?: {
|
|
121
121
|
collapseWhitespace?: boolean
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
webpackChain?: (chain: any, webpack: any, PARSE_AST_TYPE: any) => void
|
|
125
|
-
entry?: webpack.Entry
|
|
126
|
-
output?: webpack.Output
|
|
127
|
-
postcss?: IPostcssOption
|
|
128
|
-
cssLoaderOption?: IOption
|
|
129
|
-
sassLoaderOption?: IOption
|
|
130
|
-
lessLoaderOption?: IOption
|
|
131
|
-
stylusLoaderOption?: IOption
|
|
132
|
-
mediaUrlLoaderOption?: IOption
|
|
133
|
-
fontUrlLoaderOption?: IOption
|
|
134
|
-
imageUrlLoaderOption?: IOption
|
|
135
|
-
miniCssExtractPluginOption?: IOption
|
|
136
|
-
|
|
137
|
-
customFilesTypes?: IMINI_APP_FILE_TYPE
|
|
138
|
-
commonChunks?: string[] | ((commonChunks: string[]) => string[])
|
|
139
|
-
addChunkPages?: ((pages: Map<string, string[]>, pagesNames?: string[]) => void)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
webpackChain?: (chain: any, webpack: any, PARSE_AST_TYPE: any) => void
|
|
125
|
+
entry?: webpack.Entry
|
|
126
|
+
output?: webpack.Output
|
|
127
|
+
postcss?: IPostcssOption
|
|
128
|
+
cssLoaderOption?: IOption
|
|
129
|
+
sassLoaderOption?: IOption
|
|
130
|
+
lessLoaderOption?: IOption
|
|
131
|
+
stylusLoaderOption?: IOption
|
|
132
|
+
mediaUrlLoaderOption?: IOption
|
|
133
|
+
fontUrlLoaderOption?: IOption
|
|
134
|
+
imageUrlLoaderOption?: IOption
|
|
135
|
+
miniCssExtractPluginOption?: IOption
|
|
136
|
+
|
|
137
|
+
customFilesTypes?: IMINI_APP_FILE_TYPE
|
|
138
|
+
commonChunks?: string[] | ((commonChunks: string[]) => string[])
|
|
139
|
+
addChunkPages?: ((pages: Map<string, string[]>, pagesNames?: string[]) => void)
|
|
140
140
|
optimizeMainPackage?: {
|
|
141
|
-
enable?: boolean
|
|
141
|
+
enable?: boolean
|
|
142
142
|
exclude?: any[]
|
|
143
|
-
}
|
|
143
|
+
}
|
|
144
144
|
|
|
145
145
|
compile?: {
|
|
146
|
-
exclude?: any[]
|
|
146
|
+
exclude?: any[]
|
|
147
147
|
include?: any[]
|
|
148
148
|
}
|
|
149
149
|
runtime?: Runtime
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
export type TogglableOptions<T = IOption> = {
|
|
153
|
-
enable?: boolean
|
|
153
|
+
enable?: boolean
|
|
154
154
|
config?: T
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
export interface IH5RouterConfig {
|
|
158
|
-
mode?: 'hash' | 'browser' | 'multi'
|
|
159
|
-
customRoutes?: IOption
|
|
160
|
-
basename?: string
|
|
161
|
-
lazyload?: boolean | ((pagename: string) => boolean)
|
|
158
|
+
mode?: 'hash' | 'browser' | 'multi'
|
|
159
|
+
customRoutes?: IOption
|
|
160
|
+
basename?: string
|
|
161
|
+
lazyload?: boolean | ((pagename: string) => boolean)
|
|
162
162
|
renamePagename?: (pagename: string) => string
|
|
163
163
|
forcePath?: string
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
export interface IH5Config {
|
|
167
|
-
publicPath?: string
|
|
168
|
-
staticDirectory?: string
|
|
169
|
-
chunkDirectory?: string
|
|
167
|
+
publicPath?: string
|
|
168
|
+
staticDirectory?: string
|
|
169
|
+
chunkDirectory?: string
|
|
170
170
|
|
|
171
171
|
webpack?: ((webpackConfig: webpack.Configuration, webpack) => webpack.Configuration) | webpack.Configuration
|
|
172
172
|
|
|
173
|
-
webpackChain?: (chain: any, webpack: any) => void
|
|
174
|
-
|
|
175
|
-
entry?: webpack.Entry
|
|
176
|
-
output?: webpack.Output
|
|
177
|
-
router?: IH5RouterConfig
|
|
178
|
-
devServer?: webpackDevServer.Configuration
|
|
179
|
-
enableSourceMap?: boolean
|
|
180
|
-
sourceMapType?: 'none' | 'eval' | 'cheap-eval-source-map' | 'cheap-module-eval-source-map' | 'eval-source-map' | 'cheap-source-map' | 'cheap-module-source-map' | 'inline-cheap-source-map' | 'inline-cheap-module-source-map' | 'source-map' | 'inline-source-map' | 'hidden-source-map' | 'nosources-source-map'
|
|
181
|
-
enableExtract?: boolean
|
|
182
|
-
transformOnly?: boolean
|
|
183
|
-
|
|
184
|
-
cssLoaderOption?: IOption
|
|
185
|
-
styleLoaderOption?: IOption
|
|
186
|
-
sassLoaderOption?: IOption
|
|
187
|
-
lessLoaderOption?: IOption
|
|
188
|
-
stylusLoaderOption?: IOption
|
|
189
|
-
mediaUrlLoaderOption?: IOption
|
|
190
|
-
fontUrlLoaderOption?: IOption
|
|
191
|
-
imageUrlLoaderOption?: IOption
|
|
192
|
-
miniCssExtractPluginOption?: IOption
|
|
193
|
-
esnextModules?: string[]
|
|
194
|
-
useHtmlComponents?: boolean
|
|
173
|
+
webpackChain?: (chain: any, webpack: any) => void
|
|
174
|
+
|
|
175
|
+
entry?: webpack.Entry
|
|
176
|
+
output?: webpack.Output
|
|
177
|
+
router?: IH5RouterConfig
|
|
178
|
+
devServer?: webpackDevServer.Configuration
|
|
179
|
+
enableSourceMap?: boolean
|
|
180
|
+
sourceMapType?: 'none' | 'eval' | 'cheap-eval-source-map' | 'cheap-module-eval-source-map' | 'eval-source-map' | 'cheap-source-map' | 'cheap-module-source-map' | 'inline-cheap-source-map' | 'inline-cheap-module-source-map' | 'source-map' | 'inline-source-map' | 'hidden-source-map' | 'nosources-source-map'
|
|
181
|
+
enableExtract?: boolean
|
|
182
|
+
transformOnly?: boolean
|
|
183
|
+
|
|
184
|
+
cssLoaderOption?: IOption
|
|
185
|
+
styleLoaderOption?: IOption
|
|
186
|
+
sassLoaderOption?: IOption
|
|
187
|
+
lessLoaderOption?: IOption
|
|
188
|
+
stylusLoaderOption?: IOption
|
|
189
|
+
mediaUrlLoaderOption?: IOption
|
|
190
|
+
fontUrlLoaderOption?: IOption
|
|
191
|
+
imageUrlLoaderOption?: IOption
|
|
192
|
+
miniCssExtractPluginOption?: IOption
|
|
193
|
+
esnextModules?: string[]
|
|
194
|
+
useHtmlComponents?: boolean
|
|
195
195
|
|
|
196
196
|
postcss?: IPostcssOption
|
|
197
197
|
}
|
|
@@ -213,11 +213,11 @@ export type SystemConfig = {
|
|
|
213
213
|
/**
|
|
214
214
|
* 打印日志等级,分为 off,error,warn,info,log,debug
|
|
215
215
|
*/
|
|
216
|
-
logLevel?: LogLevel
|
|
216
|
+
logLevel?: LogLevel
|
|
217
217
|
/**
|
|
218
218
|
* 页面设计基准宽度,根据实际设备宽度来缩放元素大小
|
|
219
219
|
*/
|
|
220
|
-
designWidth?: number
|
|
220
|
+
designWidth?: number
|
|
221
221
|
/**
|
|
222
222
|
* 全局数据对象,属性名不能以$或_开头,在页面中可通过 this 进行访问;如果全局数据属性与页面的数据属性重名,则页面初始化时,全局数据会覆盖页面中对应的属性值
|
|
223
223
|
*/
|
|
@@ -228,7 +228,7 @@ type RouterConfig = {
|
|
|
228
228
|
/**
|
|
229
229
|
* 首页名称
|
|
230
230
|
*/
|
|
231
|
-
entry: string
|
|
231
|
+
entry: string
|
|
232
232
|
/**
|
|
233
233
|
* 页面配置列表,key 值为页面名称(对应页面目录名,例如 Hello 对应'Hello'目录),value 为页面详细配置 page
|
|
234
234
|
*/
|
|
@@ -238,14 +238,14 @@ type RouterPage = {
|
|
|
238
238
|
/**
|
|
239
239
|
* 页面对应的组件名,与 ux 文件名保持一致,例如'hello' 对应 'hello.ux'
|
|
240
240
|
*/
|
|
241
|
-
component: string
|
|
241
|
+
component: string
|
|
242
242
|
/**
|
|
243
243
|
* 页面路径,例如“/user”,不填则默认为/<页面名称>。
|
|
244
244
|
* path 必须唯一,不能和其他 page 的 path 相同。
|
|
245
245
|
* 下面 page 的 path 因为缺失,会被设置为“/Index”:
|
|
246
246
|
* "Index": {"component": "index"}
|
|
247
247
|
*/
|
|
248
|
-
path?: string
|
|
248
|
+
path?: string
|
|
249
249
|
/**
|
|
250
250
|
* 声明页面可以处理某种请求
|
|
251
251
|
*/
|
|
@@ -260,31 +260,31 @@ interface IDefaultDisplayConfig {
|
|
|
260
260
|
/**
|
|
261
261
|
* 窗口背景颜色
|
|
262
262
|
*/
|
|
263
|
-
backgroundColor?: string
|
|
263
|
+
backgroundColor?: string
|
|
264
264
|
/**
|
|
265
265
|
* 是否是全屏模式,默认不会同时作用于 titleBar,titleBar 需要继续通过 titleBar 控制
|
|
266
266
|
*/
|
|
267
|
-
fullScreen?: boolean
|
|
267
|
+
fullScreen?: boolean
|
|
268
268
|
/**
|
|
269
269
|
* 是否显示 titleBar
|
|
270
270
|
*/
|
|
271
|
-
titleBar?: boolean
|
|
271
|
+
titleBar?: boolean
|
|
272
272
|
/**
|
|
273
273
|
* 标题栏背景色
|
|
274
274
|
*/
|
|
275
|
-
titleBarBackgroundColor?: string
|
|
275
|
+
titleBarBackgroundColor?: string
|
|
276
276
|
/**
|
|
277
277
|
* 标题栏文字颜色
|
|
278
278
|
*/
|
|
279
|
-
titleBarTextColor?: string
|
|
279
|
+
titleBarTextColor?: string
|
|
280
280
|
/**
|
|
281
281
|
* 标题栏文字(也可通过页面跳转传递参数(titleBarText)设置)
|
|
282
282
|
*/
|
|
283
|
-
titleBarText?: string
|
|
283
|
+
titleBarText?: string
|
|
284
284
|
/**
|
|
285
285
|
* 是否显示标题栏右上角菜单按钮,点击菜单按钮调用页面生命周期 onMenuPress 方法,如果该方法未实现则显示系统默认菜单
|
|
286
286
|
*/
|
|
287
|
-
menu?: boolean
|
|
287
|
+
menu?: boolean
|
|
288
288
|
/**
|
|
289
289
|
* 软键盘弹出时为保证输入框可见,页面的调整方式。 adjustPan:上移页面; adjustResize:压缩页面显示区域,当页面全屏时,此设置不生效
|
|
290
290
|
*/
|
|
@@ -304,31 +304,31 @@ export interface ITaroManifestConfig {
|
|
|
304
304
|
/**
|
|
305
305
|
* 应用包名,确认与原生应用的包名不一致,推荐采用 com.company.module 的格式,如:com.example.demo
|
|
306
306
|
*/
|
|
307
|
-
package: string
|
|
307
|
+
package: string
|
|
308
308
|
/**
|
|
309
309
|
* 应用名称,6 个汉字以内,与应用商店保存的名称一致,用于在桌面图标、弹窗等处显示应用名称
|
|
310
310
|
*/
|
|
311
|
-
name: string
|
|
311
|
+
name: string
|
|
312
312
|
/**
|
|
313
313
|
* 应用图标,提供 192x192 大小的即可
|
|
314
314
|
*/
|
|
315
|
-
icon: string
|
|
315
|
+
icon: string
|
|
316
316
|
/**
|
|
317
317
|
* 应用版本名称,如:"1.0"
|
|
318
318
|
*/
|
|
319
|
-
versionName?: string
|
|
319
|
+
versionName?: string
|
|
320
320
|
/**
|
|
321
321
|
* 应用版本号,从1自增,推荐每次重新上传包时versionCode+1
|
|
322
322
|
*/
|
|
323
|
-
versionCode: number
|
|
323
|
+
versionCode: number
|
|
324
324
|
/**
|
|
325
325
|
* 支持的最小平台版本号,兼容性检查,避免上线后在低版本平台运行并导致不兼容;如果不填按照内测版本处理
|
|
326
326
|
*/
|
|
327
|
-
minPlatformVersion?: string
|
|
327
|
+
minPlatformVersion?: string
|
|
328
328
|
/**
|
|
329
329
|
* 接口列表,绝大部分接口都需要在这里声明,否则不能调用,详见每个接口的文档说明
|
|
330
330
|
*/
|
|
331
|
-
features?: FeatureItem[]
|
|
331
|
+
features?: FeatureItem[]
|
|
332
332
|
/**
|
|
333
333
|
*
|
|
334
334
|
*/
|
|
@@ -339,11 +339,11 @@ export interface IManifestConfig extends ITaroManifestConfig {
|
|
|
339
339
|
/**
|
|
340
340
|
* 系统配置信息
|
|
341
341
|
*/
|
|
342
|
-
config: SystemConfig
|
|
342
|
+
config: SystemConfig
|
|
343
343
|
/**
|
|
344
344
|
* 路由信息
|
|
345
345
|
*/
|
|
346
|
-
router: RouterConfig
|
|
346
|
+
router: RouterConfig
|
|
347
347
|
/**
|
|
348
348
|
* UI 显示相关配置
|
|
349
349
|
*/
|
|
@@ -353,24 +353,24 @@ export interface IManifestConfig extends ITaroManifestConfig {
|
|
|
353
353
|
export type PluginItem = string | [string, object]
|
|
354
354
|
|
|
355
355
|
export interface IProjectBaseConfig {
|
|
356
|
-
projectName?: string
|
|
357
|
-
date?: string
|
|
358
|
-
designWidth?: number
|
|
359
|
-
watcher?: any[]
|
|
360
|
-
deviceRatio?: TaroGeneral.TDeviceRatio
|
|
361
|
-
sourceRoot?: string
|
|
362
|
-
outputRoot?: string
|
|
363
|
-
env?: IOption
|
|
364
|
-
alias?: IOption
|
|
365
|
-
defineConstants?: IOption
|
|
366
|
-
copy?: ICopyOptions
|
|
367
|
-
csso?: TogglableOptions
|
|
368
|
-
terser?: TogglableOptions
|
|
369
|
-
uglify?: TogglableOptions
|
|
370
|
-
sass?: ISassOptions
|
|
371
|
-
plugins?: PluginItem[]
|
|
356
|
+
projectName?: string
|
|
357
|
+
date?: string
|
|
358
|
+
designWidth?: number
|
|
359
|
+
watcher?: any[]
|
|
360
|
+
deviceRatio?: TaroGeneral.TDeviceRatio
|
|
361
|
+
sourceRoot?: string
|
|
362
|
+
outputRoot?: string
|
|
363
|
+
env?: IOption
|
|
364
|
+
alias?: IOption
|
|
365
|
+
defineConstants?: IOption
|
|
366
|
+
copy?: ICopyOptions
|
|
367
|
+
csso?: TogglableOptions
|
|
368
|
+
terser?: TogglableOptions
|
|
369
|
+
uglify?: TogglableOptions
|
|
370
|
+
sass?: ISassOptions
|
|
371
|
+
plugins?: PluginItem[]
|
|
372
372
|
presets?: PluginItem[]
|
|
373
|
-
baseLevel?: number
|
|
373
|
+
baseLevel?: number
|
|
374
374
|
framework?: string
|
|
375
375
|
}
|
|
376
376
|
|
|
@@ -21,31 +21,24 @@ declare module './index' {
|
|
|
21
21
|
onPageScroll?(obj: PageScrollObject): void
|
|
22
22
|
onShareAppMessage?(obj: ShareAppMessageObject): ShareAppMessageReturn
|
|
23
23
|
onTabItemTap?(obj: TabItemTapObject): void
|
|
24
|
-
onResize?(obj:
|
|
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,36 +60,31 @@ 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 {
|
|
83
|
-
componentDidShow?(
|
|
84
|
-
componentDidHide?(
|
|
85
|
-
onShow?(
|
|
86
|
-
onHide?(
|
|
70
|
+
componentDidShow?(): void
|
|
71
|
+
componentDidHide?(): void
|
|
72
|
+
onShow?(): void
|
|
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
|
|
77
|
+
componentDidShow?(options?: Record<string, unknown>): void
|
|
78
|
+
onShow?(options?: Record<string, unknown>): void
|
|
91
79
|
unmount(id: string, cb: () => void): void
|
|
92
80
|
}
|
|
93
|
-
|
|
94
81
|
type Target = Record<string, unknown> & { dataset: Record<string, unknown>; id: string }
|
|
95
|
-
|
|
96
82
|
interface MpEvent {
|
|
97
83
|
type: string
|
|
98
84
|
detail: Record<string, unknown>
|
|
99
85
|
target: Target
|
|
100
86
|
currentTarget: Target
|
|
101
87
|
}
|
|
102
|
-
|
|
103
88
|
interface PageLifeCycle extends Show {
|
|
104
89
|
onPullDownRefresh?(): void
|
|
105
90
|
onReachBottom?(): void
|
|
@@ -115,50 +100,87 @@ declare module './index' {
|
|
|
115
100
|
onLoad(options: Record<string, unknown>): void
|
|
116
101
|
onUnload(): void
|
|
117
102
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
+
/** 页面配置 */
|
|
123
175
|
config?: PageConfig
|
|
124
176
|
data?: Record<string, unknown>
|
|
125
177
|
path?: string
|
|
126
178
|
options?: Record<string, unknown>
|
|
127
|
-
/**
|
|
128
|
-
* 执行关键帧动画,详见[动画](https://developers.weixin.qq.com/miniprogram/dev/framework/view/animation.html)
|
|
129
|
-
*
|
|
130
|
-
* 最低基础库版本:[`2.9.0`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
|
|
131
|
-
**/
|
|
132
|
-
animate?(selector: string, keyFrames: KeyFrame[], duration: number, callback: () => void): void
|
|
133
|
-
/**
|
|
134
|
-
* 执行关键帧动画,详见[动画](https://developers.weixin.qq.com/miniprogram/dev/framework/view/animation.html)
|
|
135
|
-
*
|
|
136
|
-
* 最低基础库版本:[`2.9.0`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
|
|
137
|
-
**/
|
|
138
|
-
animate?(
|
|
139
|
-
selector: string,
|
|
140
|
-
keyFrames: ScrollTimelineKeyframe[],
|
|
141
|
-
duration: number,
|
|
142
|
-
scrollTimeline: ScrollTimelineOption
|
|
143
|
-
): void
|
|
144
|
-
/**
|
|
145
|
-
* 清除关键帧动画,详见[动画](https://developers.weixin.qq.com/miniprogram/dev/framework/view/animation.html)
|
|
146
|
-
*
|
|
147
|
-
* 最低基础库版本:[`2.9.0`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
|
|
148
|
-
**/
|
|
149
|
-
clearAnimation?(selector: string, callback: () => void): void
|
|
150
|
-
/**
|
|
151
|
-
* 清除关键帧动画,详见[动画](https://developers.weixin.qq.com/miniprogram/dev/framework/view/animation.html)
|
|
152
|
-
*
|
|
153
|
-
* 最低基础库版本:[`2.9.0`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
|
|
154
|
-
**/
|
|
155
|
-
clearAnimation?(selector: string, options: ClearAnimationOptions, callback: () => void): void
|
|
156
179
|
}
|
|
157
|
-
|
|
158
180
|
interface TaroStatic {
|
|
159
181
|
memo<P = {}>(
|
|
160
182
|
FunctionComponent: FunctionComponent<P>,
|
|
161
|
-
compare?: (oldProps: P, newProps: P) =>
|
|
183
|
+
compare?: (oldProps: P, newProps: P) => boolean
|
|
162
184
|
): FunctionComponent<P>
|
|
163
185
|
}
|
|
164
186
|
}
|