@tarojs/taro 3.7.0-alpha.2 → 3.7.0-alpha.4
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 +9 -3
- package/types/api/ai/inference.d.ts +133 -0
- package/types/api/base/crypto.d.ts +17 -3
- package/types/api/base/index.d.ts +2 -2
- package/types/api/base/performance.d.ts +63 -0
- package/types/api/base/system.d.ts +65 -0
- package/types/api/base/weapp/app-event.d.ts +18 -18
- package/types/api/device/calendar.d.ts +2 -2
- package/types/api/device/screen.d.ts +61 -0
- package/types/api/device/sms.d.ts +26 -0
- package/types/api/media/image.d.ts +40 -17
- package/types/api/media/live.d.ts +52 -0
- package/types/api/media/video.d.ts +64 -23
- package/types/api/media/voip.d.ts +103 -0
- package/types/api/network/request.d.ts +18 -15
- package/types/api/open-api/channels.d.ts +31 -0
- package/types/api/open-api/device-voip.d.ts +63 -0
- package/types/api/storage/cache-manager.d.ts +198 -0
- package/types/api/taro.extend.d.ts +200 -0
- package/types/{taro.hooks.d.ts → api/taro.hooks.d.ts} +4 -4
- package/types/compile/compiler.d.ts +1 -1
- package/types/compile/config/h5.d.ts +63 -2
- package/types/compile/config/mini.d.ts +43 -4
- package/types/compile/config/project.d.ts +226 -10
- package/types/compile/config/rn.d.ts +56 -0
- package/types/compile/config/util.d.ts +62 -4
- package/types/global.d.ts +8 -8
- package/types/index.d.ts +7 -7
- package/types/taro.api.d.ts +8 -1
- package/types/taro.component.d.ts +2 -1
- package/types/taro.config.d.ts +8 -1
- package/types/taro.extend.d.ts +0 -112
|
@@ -1,75 +1,186 @@
|
|
|
1
1
|
import type Webpack from 'webpack'
|
|
2
2
|
import type Chain from 'webpack-chain'
|
|
3
|
+
import { type Input } from 'postcss'
|
|
3
4
|
import type { Compiler } from '../compiler'
|
|
4
5
|
import type { IModifyWebpackChain } from '../hooks'
|
|
5
|
-
import type { ICopyOptions, IOption, ISassOptions, TogglableOptions } from
|
|
6
|
+
import type { ICopyOptions, IOption, ISassOptions, TogglableOptions } from './util'
|
|
6
7
|
import type { IH5Config } from './h5'
|
|
7
8
|
import type { IMiniAppConfig } from './mini'
|
|
9
|
+
import { IRNConfig } from './rn'
|
|
8
10
|
|
|
9
|
-
export type PluginItem = string | [string, object]
|
|
11
|
+
export type PluginItem = string | [string, object] | [string, () => object | Promise<object>]
|
|
10
12
|
|
|
11
13
|
interface ICache {
|
|
14
|
+
/**
|
|
15
|
+
* 是否开启持久化缓存 (默认值 false)
|
|
16
|
+
* @description ```
|
|
17
|
+
* 值为 false 时:开发模式下 WebpackConfig.cache.type = 'memory',而生产模式下 WebpackConfig.cache = false;
|
|
18
|
+
* 值为 true 时:开发模式和生产模式下均为 WebpackConfig.cache.type = 'filesystem'
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
12
21
|
enable?: boolean
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 当依赖的文件或该文件的依赖改变时,使缓存失效。
|
|
25
|
+
* @description 详详情请参考 [WebpackConfig.cache.buildDependencies](https://webpack.js.org/configuration/cache/#cachebuilddependencies)。
|
|
26
|
+
*/
|
|
13
27
|
buildDependencies?: Record<string, any>
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 缓存子目录的名称 (默认值 process.env.NODE_ENV-process.env.TARO_ENV)
|
|
31
|
+
* @description 详情请参考 [WebpackConfig.cache.name](https://webpack.js.org/configuration/cache/#cachename)
|
|
32
|
+
*/
|
|
14
33
|
name?: string
|
|
15
34
|
}
|
|
16
35
|
|
|
17
36
|
interface ILogger {
|
|
37
|
+
/** 是否简化输出日志 (默认值 true)*/
|
|
18
38
|
quiet: boolean
|
|
39
|
+
/** 是否输出 Webpack Stats 信息 (默认值 false) */
|
|
19
40
|
stats: boolean
|
|
20
41
|
}
|
|
21
42
|
|
|
22
43
|
export interface IProjectBaseConfig {
|
|
23
44
|
isWatch?: boolean
|
|
24
45
|
port?: number
|
|
46
|
+
/** 项目名称 */
|
|
25
47
|
projectName?: string
|
|
48
|
+
|
|
49
|
+
/** 项目创建日期 */
|
|
26
50
|
date?: string
|
|
27
|
-
|
|
51
|
+
|
|
52
|
+
/** 设计稿尺寸 */
|
|
53
|
+
designWidth?: number | ((size?: string | number | Input) => number)
|
|
54
|
+
|
|
55
|
+
/** 设计稿尺寸换算规则 */
|
|
28
56
|
deviceRatio?: TaroGeneral.TDeviceRatio
|
|
57
|
+
|
|
29
58
|
watcher?: any[]
|
|
59
|
+
|
|
60
|
+
/** 源码存放目录 (默认值:'src') */
|
|
30
61
|
sourceRoot?: string
|
|
62
|
+
|
|
63
|
+
/** 代码编译后的生产目录 (默认值:'dist') */
|
|
31
64
|
outputRoot?: string
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 用于配置`process.env.xxxx`相关的环境变量
|
|
68
|
+
* @deprecated 建议使用根目录下的 .env 文件替代
|
|
69
|
+
* @description 注意:这里的环境变量只能在业务代码中使用,编译时的 node 环境中无法使用
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* // config/index.ts
|
|
73
|
+
* export default defineConfig({
|
|
74
|
+
* env: {
|
|
75
|
+
* xxxx: '"测试"'
|
|
76
|
+
* }
|
|
77
|
+
* })
|
|
78
|
+
*
|
|
79
|
+
* // src/app.ts
|
|
80
|
+
* onShow() {
|
|
81
|
+
* console.log(process.env.xxxx) // 打印 "测试"
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
32
85
|
env?: IOption
|
|
86
|
+
|
|
87
|
+
/** 用于配置目录别名,从而方便书写代码引用路径 */
|
|
33
88
|
alias?: IOption
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 用于配置一些常量供代码中进行全局替换使用
|
|
92
|
+
* @description 注意:这里的环境变量只能在业务代码中使用,编译时的 node 环境中无法使用
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* // config/index.ts
|
|
96
|
+
* export default defineConfig({
|
|
97
|
+
* defineConstants: {
|
|
98
|
+
* __TEST__: JSON.stringify('test')
|
|
99
|
+
* }
|
|
100
|
+
* })
|
|
101
|
+
*
|
|
102
|
+
* // src/app.ts
|
|
103
|
+
* onShow() {
|
|
104
|
+
* console.log(__TEST__) // 打印 "test"
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
34
108
|
defineConstants?: IOption
|
|
109
|
+
|
|
110
|
+
/** 用于把文件从源码目录直接拷贝到编译后的生产目录 */
|
|
35
111
|
copy?: ICopyOptions
|
|
112
|
+
|
|
113
|
+
/** 配置 JS 压缩工具 (默认 terser) */
|
|
36
114
|
jsMinimizer?: 'terser' | 'esbuild'
|
|
115
|
+
|
|
116
|
+
/** 配置 CSS 压缩工具 (默认 csso) */
|
|
37
117
|
cssMinimizer?: 'csso' | 'esbuild' | 'parcelCss'
|
|
118
|
+
|
|
119
|
+
/** 配置 csso 工具以压缩 CSS 代码 */
|
|
38
120
|
csso?: TogglableOptions
|
|
121
|
+
|
|
122
|
+
/** 配置 terser 工具以压缩 JS 代码 */
|
|
39
123
|
terser?: TogglableOptions
|
|
124
|
+
|
|
40
125
|
esbuild?: Record<'minify', TogglableOptions>
|
|
126
|
+
|
|
41
127
|
uglify?: TogglableOptions
|
|
128
|
+
|
|
129
|
+
/** 用于控制对 scss 代码的编译行为,默认使用 dart-sass,具体配置可以参考 https://www.npmjs.com/package/sass */
|
|
42
130
|
sass?: ISassOptions
|
|
131
|
+
|
|
132
|
+
/** 配置 Taro 插件 */
|
|
43
133
|
plugins?: PluginItem[]
|
|
134
|
+
|
|
135
|
+
/** 一个 preset 是一系列 Taro 插件的集合,配置语法同 plugins */
|
|
44
136
|
presets?: PluginItem[]
|
|
137
|
+
|
|
138
|
+
/** 模板循环次数 */
|
|
45
139
|
baseLevel?: number
|
|
46
|
-
|
|
140
|
+
|
|
141
|
+
/** 使用的开发框架。可选值:react、preact、nerv、vue、vue3 */
|
|
142
|
+
framework?: 'react' | 'preact' | 'nerv' | 'vue' | 'vue3'
|
|
47
143
|
frameworkExts?: string[]
|
|
144
|
+
|
|
145
|
+
/** 使用的编译工具。可选值:webpack4、webpack5 */
|
|
48
146
|
compiler?: Compiler
|
|
147
|
+
|
|
148
|
+
/** Webpack5 持久化缓存配置。具体配置请参考 [WebpackConfig.cache](https://webpack.js.org/configuration/cache/#cache) */
|
|
49
149
|
cache?: ICache
|
|
150
|
+
|
|
151
|
+
/** 控制 Taro 编译日志的输出方式 */
|
|
50
152
|
logger?: ILogger
|
|
153
|
+
|
|
154
|
+
/** 用于控制是否生成 js、css 对应的 sourceMap */
|
|
51
155
|
enableSourceMap?: boolean
|
|
156
|
+
|
|
52
157
|
/**
|
|
53
158
|
* 编译开始
|
|
54
159
|
*/
|
|
55
160
|
onBuildStart?: (...args: any[]) => Promise<any>
|
|
161
|
+
|
|
56
162
|
/**
|
|
57
163
|
* 编译完成(启动项目后首次编译结束后会触发一次)
|
|
58
164
|
*/
|
|
59
165
|
onBuildComplete?: (...args: any[]) => Promise<any>
|
|
166
|
+
|
|
60
167
|
/**
|
|
61
168
|
* 编译结束(保存代码每次编译结束后都会触发)
|
|
62
169
|
*/
|
|
63
|
-
onBuildFinish?: (res: { error
|
|
170
|
+
onBuildFinish?: (res: { error; stats; isWatch }) => Promise<any>
|
|
171
|
+
|
|
64
172
|
/**
|
|
65
173
|
* 修改编译过程中的页面组件配置
|
|
66
174
|
*/
|
|
67
175
|
onCompilerMake?: (compilation: Webpack.Compilation, compiler: Webpack.Compiler, plugin: any) => Promise<any>
|
|
176
|
+
|
|
68
177
|
onWebpackChainReady?: (webpackChain: Chain) => Promise<any>
|
|
178
|
+
|
|
69
179
|
/**
|
|
70
180
|
* 编译中修改 webpack 配置,在这个钩子中,你可以对 webpackChain 作出想要的调整,等同于配置 [`webpackChain`](./config-detail#miniwebpackchain)
|
|
71
181
|
*/
|
|
72
182
|
modifyWebpackChain?: (chain: Chain, webpack: typeof Webpack, data: IModifyWebpackChain) => Promise<any>
|
|
183
|
+
|
|
73
184
|
/**
|
|
74
185
|
* 编译中修改 vite 配置
|
|
75
186
|
*/
|
|
@@ -78,18 +189,123 @@ export interface IProjectBaseConfig {
|
|
|
78
189
|
* 修改编译过程中的页面组件配置
|
|
79
190
|
*/
|
|
80
191
|
modifyMiniConfigs?: (configMap: any) => Promise<any>
|
|
192
|
+
|
|
81
193
|
/**
|
|
82
194
|
* 修改编译后的结果
|
|
83
195
|
*/
|
|
84
196
|
modifyBuildAssets?: (assets: any, miniPlugin?: any) => Promise<any>
|
|
85
197
|
}
|
|
86
198
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
199
|
+
/** 暴露出来给 config/index 使用的配置类型,参考 https://github.com/NervJS/taro-doctor/blob/main/assets/config_schema.json */
|
|
200
|
+
export interface IProjectConfig {
|
|
201
|
+
/** 项目名称 */
|
|
202
|
+
projectName?: string
|
|
203
|
+
|
|
204
|
+
/** 项目创建日期 */
|
|
205
|
+
date?: string
|
|
206
|
+
|
|
207
|
+
/** 设计稿尺寸 */
|
|
208
|
+
designWidth?: number | ((size?: string | number | Input) => number)
|
|
209
|
+
|
|
210
|
+
/** 设计稿尺寸换算规则 */
|
|
211
|
+
deviceRatio?: TaroGeneral.TDeviceRatio
|
|
212
|
+
|
|
213
|
+
/** 源码存放目录 (默认值:'src') */
|
|
214
|
+
sourceRoot?: string
|
|
215
|
+
|
|
216
|
+
/** 代码编译后的生产目录 (默认值:'dist') */
|
|
217
|
+
outputRoot?: string
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* 用于配置`process.env.xxxx`相关的环境变量
|
|
221
|
+
* @deprecated 建议使用根目录下的 .env 文件替代
|
|
222
|
+
* @description 注意:这里的环境变量只能在业务代码中使用,编译时的 node 环境中无法使用
|
|
223
|
+
* @example
|
|
224
|
+
* ```ts
|
|
225
|
+
* // config/index.ts
|
|
226
|
+
* export default defineConfig({
|
|
227
|
+
* env: {
|
|
228
|
+
* xxxx: '"测试"'
|
|
229
|
+
* }
|
|
230
|
+
* })
|
|
231
|
+
*
|
|
232
|
+
* // src/app.ts
|
|
233
|
+
* onShow() {
|
|
234
|
+
* console.log(process.env.xxxx) // 打印 "测试"
|
|
235
|
+
* }
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
env?: IOption
|
|
239
|
+
|
|
240
|
+
/** 用于配置目录别名,从而方便书写代码引用路径 */
|
|
241
|
+
alias?: IOption
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* 用于配置一些常量供代码中进行全局替换使用
|
|
245
|
+
* @description 注意:这里的环境变量只能在业务代码中使用,编译时的 node 环境中无法使用
|
|
246
|
+
* @example
|
|
247
|
+
* ```ts
|
|
248
|
+
* // config/index.ts
|
|
249
|
+
* export default defineConfig({
|
|
250
|
+
* defineConstants: {
|
|
251
|
+
* __TEST__: JSON.stringify('test')
|
|
252
|
+
* }
|
|
253
|
+
* })
|
|
254
|
+
*
|
|
255
|
+
* // src/app.ts
|
|
256
|
+
* onShow() {
|
|
257
|
+
* console.log(__TEST__) // 打印 "test"
|
|
258
|
+
* }
|
|
259
|
+
* ```
|
|
260
|
+
*/
|
|
261
|
+
defineConstants?: IOption
|
|
262
|
+
|
|
263
|
+
/** 用于把文件从源码目录直接拷贝到编译后的生产目录 */
|
|
264
|
+
copy?: ICopyOptions
|
|
265
|
+
|
|
266
|
+
/** 配置 JS 压缩工具 (默认 terser) */
|
|
267
|
+
jsMinimizer?: 'terser' | 'esbuild'
|
|
268
|
+
|
|
269
|
+
/** 配置 CSS 压缩工具 (默认 csso) */
|
|
270
|
+
cssMinimizer?: 'csso' | 'esbuild' | 'parcelCss'
|
|
271
|
+
|
|
272
|
+
/** 配置 csso 工具以压缩 CSS 代码 */
|
|
273
|
+
csso?: TogglableOptions
|
|
274
|
+
|
|
275
|
+
/** 配置 terser 工具以压缩 JS 代码 */
|
|
276
|
+
terser?: TogglableOptions
|
|
277
|
+
|
|
278
|
+
esbuild?: Record<'minify', TogglableOptions>
|
|
279
|
+
|
|
280
|
+
/** 用于控制对 scss 代码的编译行为,默认使用 dart-sass,具体配置可以参考 https://www.npmjs.com/package/sass */
|
|
281
|
+
sass?: ISassOptions
|
|
282
|
+
|
|
283
|
+
/** 配置 Taro 插件 */
|
|
284
|
+
plugins?: PluginItem[]
|
|
285
|
+
|
|
286
|
+
/** 一个 preset 是一系列 Taro 插件的集合,配置语法同 plugins */
|
|
287
|
+
presets?: PluginItem[]
|
|
288
|
+
|
|
289
|
+
/** 使用的开发框架。可选值:react、preact、nerv、vue、vue3 */
|
|
290
|
+
framework?: 'react' | 'preact' | 'nerv' | 'vue' | 'vue3'
|
|
291
|
+
|
|
292
|
+
/** 使用的编译工具。可选值:webpack4、webpack5 */
|
|
293
|
+
compiler?: Compiler
|
|
294
|
+
|
|
295
|
+
/** Webpack5 持久化缓存配置。具体配置请参考 [WebpackConfig.cache](https://webpack.js.org/configuration/cache/#cache) */
|
|
296
|
+
cache?: ICache
|
|
297
|
+
|
|
298
|
+
/** 控制 Taro 编译日志的输出方式 */
|
|
299
|
+
logger?: ILogger
|
|
300
|
+
|
|
301
|
+
/** 专属于小程序的配置 */
|
|
91
302
|
mini?: IMiniAppConfig
|
|
303
|
+
|
|
304
|
+
/** 专属于 H5 的配置 */
|
|
92
305
|
h5?: IH5Config
|
|
93
|
-
|
|
306
|
+
|
|
307
|
+
/** 专属于 RN 的配置 */
|
|
308
|
+
rn?: IRNConfig
|
|
309
|
+
|
|
94
310
|
[key: string]: any
|
|
95
311
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type Webpack from 'webpack'
|
|
2
|
+
import type Chain from 'webpack-chain'
|
|
3
|
+
import type webpackDevServer from 'webpack-dev-server'
|
|
4
|
+
import type HtmlWebpackPlugin from 'html-webpack-plugin'
|
|
5
|
+
import type { IOption, IPostcssOption } from './util'
|
|
6
|
+
|
|
7
|
+
export interface IRNConfig {
|
|
8
|
+
/** 设置 RN bundle 中注册应用的名称 */
|
|
9
|
+
appName: string
|
|
10
|
+
|
|
11
|
+
/** entry 利用模块查找规则{name}.{platform}.{ext}自动区分平台 */
|
|
12
|
+
entry?: string
|
|
13
|
+
|
|
14
|
+
/** 设置 Metro 打包生成 bundle 的输出路径,默认 dist 目录下 */
|
|
15
|
+
output?: any
|
|
16
|
+
|
|
17
|
+
/** [sass](https://github.com/sass/node-sass#options) 相关配置 */
|
|
18
|
+
sass?: IOption
|
|
19
|
+
|
|
20
|
+
/** [less](https://lesscss.org/usage/#less-options) 相关配置 */
|
|
21
|
+
less?: IOption
|
|
22
|
+
|
|
23
|
+
/** [stylus](https://github.com/NervJS/taro/blob/next/packages/taro-rn-style-transformer/README.md#rnstylus) 相关配置 */
|
|
24
|
+
stylus?: IOption
|
|
25
|
+
|
|
26
|
+
/** 配置 postcss 相关插件 */
|
|
27
|
+
postcss?: {
|
|
28
|
+
/** postcss 配置,参考 https://github.com/postcss/postcss#options */
|
|
29
|
+
options?: any
|
|
30
|
+
/** 默认true,控制是否对 css value 进行 scalePx2dp 转换,pxtransform配置 enable 才生效 */
|
|
31
|
+
scalable?: boolean
|
|
32
|
+
pxtransform?: {
|
|
33
|
+
enable?: boolean
|
|
34
|
+
/** 插件 pxtransform 配置项 */
|
|
35
|
+
config?: {
|
|
36
|
+
additionalProperties?: boolean
|
|
37
|
+
[key: string]: any
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
cssModules?: {
|
|
41
|
+
enable: boolean
|
|
42
|
+
},
|
|
43
|
+
[key: string]: any
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
resolve?: any
|
|
47
|
+
|
|
48
|
+
/** 支持多 className 转换,以 classname 或 style 结尾的, 提取前缀, 然后根据前缀,再生成对应的 xxxStyle。如:barClassName -> barStyle。默认值 false,不开启 */
|
|
49
|
+
enableMultipleClassName?: boolean
|
|
50
|
+
|
|
51
|
+
/** 当标签 style 属性值是数组时转换成对象。默认值 false,不开启 */
|
|
52
|
+
enableMergeStyle?: boolean
|
|
53
|
+
|
|
54
|
+
/** 将 svg 文件转换为组件引入。默认值 false,不开启 */
|
|
55
|
+
enableSvgTransform?: boolean
|
|
56
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type Input } from 'postcss'
|
|
2
|
+
|
|
1
3
|
export type Func = (...args: any[]) => any
|
|
2
4
|
|
|
3
5
|
export type IOption = Record<string, any>
|
|
@@ -9,7 +11,9 @@ export type TogglableOptions<T = IOption> = {
|
|
|
9
11
|
|
|
10
12
|
export namespace PostcssOption {
|
|
11
13
|
export type cssModules = TogglableOptions<{
|
|
14
|
+
/** 转换模式,取值为 global/module */
|
|
12
15
|
namingPattern: 'global' | string
|
|
16
|
+
/** 自定义生成的class名称规则 */
|
|
13
17
|
generateScopedName: string | ((localName: string, absoluteFilePath: string) => string)
|
|
14
18
|
}>
|
|
15
19
|
export type url = TogglableOptions<{
|
|
@@ -18,11 +22,65 @@ export namespace PostcssOption {
|
|
|
18
22
|
}>
|
|
19
23
|
}
|
|
20
24
|
|
|
25
|
+
export interface IHtmlTransformOption {
|
|
26
|
+
/** 是否启用 postcss-html-transform 插件 */
|
|
27
|
+
enable?: boolean
|
|
28
|
+
config?: {
|
|
29
|
+
/** 当前编译平台 (此选项插件内部根据编译平台自行生成,无需传入) */
|
|
30
|
+
readonly platform?: string
|
|
31
|
+
/** 设置是否去除 cursor 相关样式 (h5默认值:true) */
|
|
32
|
+
removeCursorStyle: boolean
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface IPxTransformOption {
|
|
37
|
+
/** 设置 1px 是否需要被转换 */
|
|
38
|
+
onePxTransform?: boolean
|
|
39
|
+
/** REM 单位允许的小数位 */
|
|
40
|
+
unitPrecision?: number
|
|
41
|
+
/** 允许转换的属性列表 (默认 [*]) */
|
|
42
|
+
propList?: string[]
|
|
43
|
+
/** 黑名单里的选择器将会被忽略 */
|
|
44
|
+
selectorBlackList?: Array<string | RegExp>
|
|
45
|
+
/** 直接替换而不是追加一条进行覆盖 */
|
|
46
|
+
replace?: boolean
|
|
47
|
+
/** 允许媒体查询里的 px 单位转换 */
|
|
48
|
+
mediaQuery?: boolean
|
|
49
|
+
/** 设置一个可被转换的最小 px 值 */
|
|
50
|
+
minPixelValue?: number
|
|
51
|
+
/**
|
|
52
|
+
* 转换后的单位,可选值为 rpx、vw、rem,当前仅支持小程序 (默认 rpx) 和 Web 端 (默认 rem)
|
|
53
|
+
* @description Web 端使用 rem 单位时会注入脚本用于设置 body 上的 font-size 属性,其他单位无该操作
|
|
54
|
+
*/
|
|
55
|
+
targetUnit?: 'rpx' | 'vw' | 'rem'
|
|
56
|
+
/**
|
|
57
|
+
* H5 字体尺寸大小基准值,开发者可以自行调整单位换算的基准值(默认20)
|
|
58
|
+
* @supported h5
|
|
59
|
+
*/
|
|
60
|
+
baseFontSize?: number
|
|
61
|
+
/**
|
|
62
|
+
* H5 根节点 font-size 的最大值 (默认 40)
|
|
63
|
+
* @supported h5
|
|
64
|
+
*/
|
|
65
|
+
maxRootSize?: number
|
|
66
|
+
/**
|
|
67
|
+
* H5 根节点 font-size 的最小值(默认 20)
|
|
68
|
+
* @supported h5
|
|
69
|
+
*/
|
|
70
|
+
minRootSize?: number
|
|
71
|
+
/** 设计稿尺寸 */
|
|
72
|
+
designWidth?: number | ((size?: string | number | Input) => number)
|
|
73
|
+
/** 设计稿尺寸换算规则 */
|
|
74
|
+
deviceRatio?: TaroGeneral.TDeviceRatio
|
|
75
|
+
}
|
|
76
|
+
|
|
21
77
|
export interface IPostcssOption {
|
|
22
78
|
autoprefixer?: TogglableOptions
|
|
23
|
-
pxtransform?: TogglableOptions
|
|
79
|
+
pxtransform?: TogglableOptions<IPxTransformOption>
|
|
24
80
|
cssModules?: PostcssOption.cssModules
|
|
25
81
|
url?: PostcssOption.url
|
|
82
|
+
/** 插件 postcss-html-transform 相关配置, 一般启用了 @tarojs/plugin-html 插件才配置 */
|
|
83
|
+
htmltransform?: IHtmlTransformOption
|
|
26
84
|
[key: string]: any
|
|
27
85
|
}
|
|
28
86
|
|
|
@@ -96,9 +154,9 @@ export const enum CONFIG_TYPES {
|
|
|
96
154
|
}
|
|
97
155
|
|
|
98
156
|
export type IMINI_APP_FILE_TYPE = {
|
|
99
|
-
TEMPL: TEMPLATE_TYPES
|
|
100
|
-
STYLE: STYLE_TYPES
|
|
101
|
-
SCRIPT: SCRIPT_TYPES
|
|
157
|
+
TEMPL: TEMPLATE_TYPES
|
|
158
|
+
STYLE: STYLE_TYPES
|
|
159
|
+
SCRIPT: SCRIPT_TYPES
|
|
102
160
|
CONFIG: CONFIG_TYPES
|
|
103
161
|
}
|
|
104
162
|
|
package/types/global.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ declare namespace TaroGeneral {
|
|
|
6
6
|
type EventCallback = (
|
|
7
7
|
/** 触发事件参数 */
|
|
8
8
|
...args: any
|
|
9
|
-
|
|
9
|
+
) => void
|
|
10
10
|
/** 通用错误 */
|
|
11
11
|
interface CallbackResult {
|
|
12
12
|
/** 错误信息 */
|
|
@@ -35,7 +35,7 @@ declare namespace TaroGeneral {
|
|
|
35
35
|
/** 阻止事件冒泡到父元素,阻止任何父事件处理程序被执行 */
|
|
36
36
|
stopPropagation: () => void
|
|
37
37
|
}
|
|
38
|
-
interface currentTarget extends Target {}
|
|
38
|
+
interface currentTarget extends Target { }
|
|
39
39
|
interface Target {
|
|
40
40
|
/** 事件源组件的id */
|
|
41
41
|
id: string
|
|
@@ -378,33 +378,33 @@ declare namespace TaroGeneral {
|
|
|
378
378
|
*/
|
|
379
379
|
13024
|
|
380
380
|
}
|
|
381
|
-
|
|
381
|
+
type EventName = string | symbol
|
|
382
382
|
// Events
|
|
383
383
|
class Events {
|
|
384
384
|
/**
|
|
385
385
|
* 监听一个事件,接受参数
|
|
386
386
|
*/
|
|
387
|
-
on(eventName:
|
|
387
|
+
on (eventName: EventName, listener: (...args: any[]) => void): this
|
|
388
388
|
|
|
389
389
|
/**
|
|
390
390
|
* 添加一个事件监听,并在事件触发完成之后移除Callbacks链
|
|
391
391
|
*/
|
|
392
|
-
once(eventName:
|
|
392
|
+
once (eventName: EventName, listener: (...args: any[]) => void): this
|
|
393
393
|
|
|
394
394
|
/**
|
|
395
395
|
* 取消监听一个事件
|
|
396
396
|
*/
|
|
397
|
-
off(eventName:
|
|
397
|
+
off (eventName: EventName, listener?: (...args: any[]) => void): this
|
|
398
398
|
|
|
399
399
|
/**
|
|
400
400
|
* 取消监听的所有事件
|
|
401
401
|
*/
|
|
402
|
-
off(): this
|
|
402
|
+
off (): this
|
|
403
403
|
|
|
404
404
|
/**
|
|
405
405
|
* 触发一个事件,传参
|
|
406
406
|
*/
|
|
407
|
-
trigger(eventName:
|
|
407
|
+
trigger (eventName: EventName, ...args: any[]): this
|
|
408
408
|
}
|
|
409
409
|
|
|
410
410
|
// ENV_TYPE
|
package/types/index.d.ts
CHANGED
|
@@ -108,13 +108,13 @@
|
|
|
108
108
|
* │ │ └── interaction.d.ts 界面 -> 交互 API
|
|
109
109
|
* │ ├── worker
|
|
110
110
|
* │ │ └── index.d.ts Worker API
|
|
111
|
-
* │
|
|
112
|
-
* │
|
|
111
|
+
* │ ├── wxml
|
|
112
|
+
* │ │ └── index.d.ts WXML API
|
|
113
|
+
* │ ├── taro.extend.d.ts Taro 扩展 API 类型定义
|
|
114
|
+
* │ └── taro.hooks.d.ts Taro Hooks 类型定义
|
|
113
115
|
* ├── index.d.ts 此文件
|
|
114
116
|
* ├── taro.component.d.ts Taro Component 类型定义
|
|
115
|
-
* ├── taro.config.d.ts
|
|
116
|
-
* ├── taro.extend.d.ts Taro 扩展 API 类型定义
|
|
117
|
-
* ├── taro.hooks.d.ts Taro Hooks 类型定义
|
|
117
|
+
* ├── taro.config.d.ts Taro 小程序 App 与 Window 设置类型定义
|
|
118
118
|
* └── taro.lifecycle.d.ts Taro 生命周期类型定义
|
|
119
119
|
*/
|
|
120
120
|
|
|
@@ -123,8 +123,6 @@
|
|
|
123
123
|
/// <reference path="taro.api.d.ts" />
|
|
124
124
|
/// <reference path="taro.component.d.ts" />
|
|
125
125
|
/// <reference path="taro.config.d.ts" />
|
|
126
|
-
/// <reference path="taro.extend.d.ts" />
|
|
127
|
-
/// <reference path="taro.hooks.d.ts" />
|
|
128
126
|
/// <reference path="taro.lifecycle.d.ts" />
|
|
129
127
|
|
|
130
128
|
/// <reference types="@tarojs/plugin-platform-alipay/types/shims-alipay" />
|
|
@@ -132,6 +130,8 @@
|
|
|
132
130
|
/// <reference types="@tarojs/plugin-platform-swan/types/shims-swan" />
|
|
133
131
|
/// <reference types="@tarojs/plugin-platform-tt/types/shims-tt" />
|
|
134
132
|
/// <reference types="@tarojs/plugin-platform-weapp/types/shims-weapp" />
|
|
133
|
+
/// <reference types="@tarojs/taro-h5/types/overlay" />
|
|
134
|
+
/// <reference types="@tarojs/taro-rn/types/overlay" />
|
|
135
135
|
|
|
136
136
|
export = Taro
|
|
137
137
|
export as namespace Taro
|
package/types/taro.api.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
*
|
|
3
3
|
* 微信端能力
|
|
4
4
|
* original code from: https://github.com/wx-minapp/minapp-wx/blob/master/typing/wx.d.ts
|
|
5
|
-
*
|
|
5
|
+
* Licensed under MIT license: https://github.com/qiu8310/minapp/issues/69
|
|
6
6
|
* thanks for the great work by @qiu8310 👍👍👍
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
/// <reference path="api/payment/index.d.ts" />
|
|
42
42
|
/// <reference path="api/storage/index.d.ts" />
|
|
43
43
|
/// <reference path="api/storage/background-fetch.d.ts" />
|
|
44
|
+
/// <reference path="api/storage/cache-manager.d.ts" />
|
|
44
45
|
/// <reference path="api/data-analysis/index.d.ts" />
|
|
45
46
|
/// <reference path="api/canvas/index.d.ts" />
|
|
46
47
|
/// <reference path="api/media/map.d.ts" />
|
|
@@ -73,6 +74,7 @@
|
|
|
73
74
|
/// <reference path="api/open-api/favorites.d.ts" />
|
|
74
75
|
/// <reference path="api/open-api/license-plate.d.ts" />
|
|
75
76
|
/// <reference path="api/open-api/channels.d.ts" />
|
|
77
|
+
/// <reference path="api/open-api/device-voip.d.ts" />
|
|
76
78
|
/// <reference path="api/open-api/group.d.ts" />
|
|
77
79
|
/// <reference path="api/open-api/customer-service.d.ts" />
|
|
78
80
|
/// <reference path="api/device/bluetooth.d.ts" />
|
|
@@ -88,6 +90,7 @@
|
|
|
88
90
|
/// <reference path="api/device/clipboard.d.ts" />
|
|
89
91
|
/// <reference path="api/device/network.d.ts" />
|
|
90
92
|
/// <reference path="api/device/screen.d.ts" />
|
|
93
|
+
/// <reference path="api/device/sms.d.ts" />
|
|
91
94
|
/// <reference path="api/device/keyboard.d.ts" />
|
|
92
95
|
/// <reference path="api/device/phone.d.ts" />
|
|
93
96
|
/// <reference path="api/device/accelerometer.d.ts" />
|
|
@@ -99,6 +102,7 @@
|
|
|
99
102
|
/// <reference path="api/device/vibrate.d.ts" />
|
|
100
103
|
/// <reference path="api/ai/visionkit.d.ts" />
|
|
101
104
|
/// <reference path="api/ai/face.d.ts" />
|
|
105
|
+
/// <reference path="api/ai/inference.d.ts" />
|
|
102
106
|
/// <reference path="api/worker/index.d.ts" />
|
|
103
107
|
/// <reference path="api/wxml/index.d.ts" />
|
|
104
108
|
/// <reference path="api/ext/index.d.ts" />
|
|
@@ -110,3 +114,6 @@
|
|
|
110
114
|
/// <reference path="api/alipay/index.d.ts" />
|
|
111
115
|
/// <reference path="api/qq/index.d.ts" />
|
|
112
116
|
/// <reference path="api/swan/index.d.ts" />
|
|
117
|
+
|
|
118
|
+
/// <reference path="api/taro.extend.d.ts" />
|
|
119
|
+
/// <reference path="api/taro.hooks.d.ts" />
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import Vue from 'vue'
|
|
3
3
|
|
|
4
|
-
import Taro
|
|
4
|
+
import Taro from './index'
|
|
5
5
|
|
|
6
6
|
declare module './index' {
|
|
7
7
|
// ref: packages/taro-runtime/src/current.ts
|
|
@@ -51,6 +51,7 @@ declare module './index' {
|
|
|
51
51
|
onReachBottom?(): void
|
|
52
52
|
onResize?(opt: PageResizeObject): void
|
|
53
53
|
onShareAppMessage?(opt: ShareAppMessageObject): ShareAppMessageReturn
|
|
54
|
+
onShareTimeline?(): ShareTimelineReturnObject
|
|
54
55
|
onTabItemTap?(opt: TabItemTapObject): void
|
|
55
56
|
onTitleClick?(): void
|
|
56
57
|
onUnload(): void
|
package/types/taro.config.d.ts
CHANGED
|
@@ -154,6 +154,11 @@ declare module './index' {
|
|
|
154
154
|
* @default: false
|
|
155
155
|
*/
|
|
156
156
|
disableScroll?: boolean
|
|
157
|
+
/** 是否使用页面全局滚动,MPA下默认为全局滚动,SPA默认为局部滚动
|
|
158
|
+
* 只在H5生效
|
|
159
|
+
* @default: MPA:true SPA:false
|
|
160
|
+
*/
|
|
161
|
+
usingWindowScroll?: boolean
|
|
157
162
|
/** 禁止页面右滑手势返回
|
|
158
163
|
*
|
|
159
164
|
* **注意** 自微信客户端 7.0.5 开始,页面配置中的 disableSwipeBack 属性将不再生效,
|
|
@@ -360,7 +365,9 @@ declare module './index' {
|
|
|
360
365
|
* @default false
|
|
361
366
|
* @since 2.1.0
|
|
362
367
|
*/
|
|
363
|
-
functionalPages?: boolean
|
|
368
|
+
functionalPages?: boolean | {
|
|
369
|
+
independent?: boolean
|
|
370
|
+
}
|
|
364
371
|
/** 分包结构配置
|
|
365
372
|
* @example
|
|
366
373
|
* ```json
|