@tarojs/taro 3.5.6-alpha.2 → 3.5.7

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.5.6-alpha.2",
3
+ "version": "3.5.7",
4
4
  "description": "Taro framework",
5
5
  "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro#readme",
6
6
  "main": "index.js",
@@ -21,8 +21,8 @@
21
21
  "author": "O2Team",
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@tarojs/api": "3.5.6-alpha.2",
25
- "@tarojs/runtime": "3.5.6-alpha.2"
24
+ "@tarojs/api": "3.5.7",
25
+ "@tarojs/runtime": "3.5.7"
26
26
  },
27
27
  "peerDependenciesMeta": {
28
28
  "@types/react": {
@@ -10,7 +10,7 @@ declare module '../../index' {
10
10
  * ****
11
11
  *
12
12
  * 注: 使用该接口需同时在 [camera](/docs/components/media/camera) 组件属性中指定 frame-size。
13
- * @supported weapp, tt
13
+ * @supported weapp, tt, alipay
14
14
  * @example
15
15
  * ```tsx
16
16
  * const context = wx.createCameraContext()
@@ -26,22 +26,22 @@ declare module '../../index' {
26
26
  callback: CameraContext.OnCameraFrameCallback,
27
27
  ): CameraFrameListener
28
28
  /** 设置缩放级别
29
- * @supported weapp, tt
29
+ * @supported weapp, tt, alipay
30
30
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/CameraContext.setZoom.html
31
31
  */
32
32
  setZoom(option: CameraContext.SetZoomOption): void
33
33
  /** 开始录像
34
- * @supported weapp, rn, tt
34
+ * @supported weapp, rn, tt, alipay
35
35
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/CameraContext.startRecord.html
36
36
  */
37
37
  startRecord(option: CameraContext.StartRecordOption): void
38
38
  /** 结束录像
39
- * @supported weapp, rn, tt
39
+ * @supported weapp, rn, tt, alipay
40
40
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/CameraContext.stopRecord.html
41
41
  */
42
42
  stopRecord(option?: CameraContext.StopRecordOption): void
43
43
  /** 拍摄照片
44
- * @supported weapp, rn, tt
44
+ * @supported weapp, rn, tt, alipay
45
45
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/CameraContext.takePhoto.html
46
46
  */
47
47
  takePhoto(option: CameraContext.TakePhotoOption): void
@@ -61,6 +61,10 @@ declare module '../../index' {
61
61
  interface StartRecordSuccessCallbackResult extends TaroGeneral.CallbackResult {
62
62
  /** 实际设置的缩放级别。由于系统限制,某些机型可能无法设置成指定值,会改用最接近的可设值。 */
63
63
  zoom: number
64
+ /**
65
+ * @supported alipay on android
66
+ */
67
+ setZoom:number
64
68
  }
65
69
  interface StartRecordOption {
66
70
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
@@ -81,6 +85,22 @@ declare module '../../index' {
81
85
  tempThumbPath: string
82
86
  /** 视频的文件的临时路径 */
83
87
  tempVideoPath: string
88
+ /** 视频文件的高度。
89
+ * @supported alipay
90
+ */
91
+ height: string
92
+ /** 视频文件的宽度。
93
+ * @supported alipay
94
+ */
95
+ width: string
96
+ /** 视频文件的尺寸。
97
+ * @supported alipay
98
+ */
99
+ size: string
100
+ /** 录制的持续时间。
101
+ * @supported alipay
102
+ */
103
+ duration: string
84
104
  }
85
105
  interface StopRecordOption {
86
106
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
@@ -171,7 +191,7 @@ declare module '../../index' {
171
191
 
172
192
  interface TaroStatic {
173
193
  /** 创建 camera 上下文 CameraContext 对象。
174
- * @supported weapp, rn, tt
194
+ * @supported weapp, rn, tt, alipay
175
195
  * @example
176
196
  * ```tsx
177
197
  * const cameraContext = Taro.createCameraContext()
@@ -179,5 +199,6 @@ declare module '../../index' {
179
199
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/wx.createCameraContext.html
180
200
  */
181
201
  createCameraContext(): CameraContext
202
+ createCameraContext(id: string): CameraContext
182
203
  }
183
204
  }
@@ -441,6 +441,6 @@ declare module '../../index' {
441
441
  * ```
442
442
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.cropImage.html
443
443
  */
444
- cropImage(option: cropImage.Option): Promise<cropImage.SuccessCallbackResult>
444
+ cropImage(option: cropImage.Option): Promise<cropImage.SuccessCallbackResult>
445
445
  }
446
446
  }
@@ -5,14 +5,19 @@ declare module '../../index' {
5
5
  interface Option {
6
6
  /** 下载资源的 url */
7
7
  url: string
8
- /** 接口调用结束的回调函数(调用成功、失败都会执行) */
9
- complete?: (res: TaroGeneral.CallbackResult) => void
10
- /** 接口调用失败的回调函数 */
11
- fail?: (res: TaroGeneral.CallbackResult) => void
12
8
  /** 指定文件下载后存储的路径 */
13
9
  filePath?: string
14
10
  /** HTTP 请求的 Header,Header 中不能设置 Referer */
15
11
  header?: TaroGeneral.IAnyObject
12
+ /** 是否应使用传出凭据 (cookie) 发送此请求
13
+ * @default true
14
+ * @supported h5
15
+ */
16
+ withCredentials?: boolean
17
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
18
+ complete?: (res: TaroGeneral.CallbackResult) => void
19
+ /** 接口调用失败的回调函数 */
20
+ fail?: (res: TaroGeneral.CallbackResult) => void
16
21
  /** 接口调用成功的回调函数 */
17
22
  success?: (result: FileSuccessCallbackResult) => void
18
23
  }
@@ -19,6 +19,11 @@ declare module '../../index' {
19
19
  * @supported h5
20
20
  */
21
21
  fileName?: string
22
+ /** 是否应使用传出凭据 (cookie) 发送此请求
23
+ * @default true
24
+ * @supported h5
25
+ */
26
+ withCredentials?: boolean
22
27
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
23
28
  complete?: (res: TaroGeneral.CallbackResult) => void
24
29
  /** 接口调用失败的回调函数 */
@@ -0,0 +1,25 @@
1
+ import type swc from '@swc/core'
2
+ import type Webpack from 'webpack'
3
+
4
+ type CompilerTypes = 'webpack4' | 'webpack5'
5
+
6
+ interface IPrebundle {
7
+ enable?: boolean
8
+ timings?: boolean
9
+ cacheDir?: string
10
+ force?: boolean
11
+ include?: string[]
12
+ exclude?: string[]
13
+ esbuild?: Record<string, any>
14
+ swc?: swc.Config
15
+ webpack?: Webpack.Configuration & {
16
+ provide?: any[]
17
+ }
18
+ }
19
+
20
+ interface ICompiler {
21
+ type: CompilerTypes
22
+ prebundle: IPrebundle
23
+ }
24
+
25
+ export type Compiler = CompilerTypes | ICompiler
@@ -0,0 +1,46 @@
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 IH5RouterConfig {
8
+ mode?: 'hash' | 'browser' | 'multi'
9
+ customRoutes?: IOption
10
+ basename?: string
11
+ lazyload?: boolean | ((pagename: string) => boolean)
12
+ renamePagename?: (pagename: string) => string
13
+ forcePath?: string
14
+ }
15
+
16
+ export interface IH5Config {
17
+ publicPath?: string
18
+ staticDirectory?: string
19
+ chunkDirectory?: string
20
+
21
+ webpack?: ((webpackConfig: Webpack.Configuration, webpack) => Webpack.Configuration) | Webpack.Configuration
22
+
23
+ webpackChain?: (chain: Chain, webpack: typeof Webpack) => void
24
+
25
+ output?: Webpack.Configuration['output']
26
+ router?: IH5RouterConfig
27
+ devServer?: webpackDevServer.Configuration
28
+ 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'
29
+ enableExtract?: boolean
30
+ transformOnly?: boolean
31
+
32
+ cssLoaderOption?: IOption
33
+ styleLoaderOption?: IOption
34
+ sassLoaderOption?: IOption
35
+ lessLoaderOption?: IOption
36
+ stylusLoaderOption?: IOption
37
+ mediaUrlLoaderOption?: IOption
38
+ fontUrlLoaderOption?: IOption
39
+ imageUrlLoaderOption?: IOption
40
+ miniCssExtractPluginOption?: IOption
41
+ esnextModules?: string[]
42
+ useHtmlComponents?: boolean
43
+
44
+ postcss?: IPostcssOption
45
+ htmlPluginOption?: HtmlWebpackPlugin.Options
46
+ }
@@ -0,0 +1,6 @@
1
+ export * from './h5'
2
+ export * from './mini'
3
+
4
+ export * from './manifest'
5
+ export * from './project'
6
+ export * from './util'
@@ -0,0 +1,155 @@
1
+ import type { IOption } from './util'
2
+
3
+ type FeatureItem = {
4
+ name: string
5
+ }
6
+
7
+ declare enum LogLevel {
8
+ OFF = 'off',
9
+ ERROR = 'error',
10
+ WARN = 'warn',
11
+ INFO = 'info',
12
+ LOG = 'log',
13
+ DEBUG = 'debug'
14
+ }
15
+
16
+ export type SystemConfig = {
17
+ /**
18
+ * 打印日志等级,分为 off,error,warn,info,log,debug
19
+ */
20
+ logLevel?: LogLevel
21
+ /**
22
+ * 页面设计基准宽度,根据实际设备宽度来缩放元素大小
23
+ */
24
+ designWidth?: number
25
+ /**
26
+ * 全局数据对象,属性名不能以$或_开头,在页面中可通过 this 进行访问;如果全局数据属性与页面的数据属性重名,则页面初始化时,全局数据会覆盖页面中对应的属性值
27
+ */
28
+ data?: IOption
29
+ }
30
+
31
+ type RouterConfig = {
32
+ /**
33
+ * 首页名称
34
+ */
35
+ entry: string
36
+ /**
37
+ * 页面配置列表,key 值为页面名称(对应页面目录名,例如 Hello 对应'Hello'目录),value 为页面详细配置 page
38
+ */
39
+ pages: RouterPage[]
40
+ }
41
+ type RouterPage = {
42
+ /**
43
+ * 页面对应的组件名,与 ux 文件名保持一致,例如'hello' 对应 'hello.ux'
44
+ */
45
+ component: string
46
+ /**
47
+ * 页面路径,例如“/user”,不填则默认为/<页面名称>。
48
+ * path 必须唯一,不能和其他 page 的 path 相同。
49
+ * 下面 page 的 path 因为缺失,会被设置为“/Index”:
50
+ * "Index": {"component": "index"}
51
+ */
52
+ path?: string
53
+ /**
54
+ * 声明页面可以处理某种请求
55
+ */
56
+ filter: {
57
+ [key: string]: {
58
+ uri: string
59
+ }
60
+ }
61
+ }
62
+
63
+ interface IDefaultDisplayConfig {
64
+ /**
65
+ * 窗口背景颜色
66
+ */
67
+ backgroundColor?: string
68
+ /**
69
+ * 是否是全屏模式,默认不会同时作用于 titleBar,titleBar 需要继续通过 titleBar 控制
70
+ */
71
+ fullScreen?: boolean
72
+ /**
73
+ * 是否显示 titleBar
74
+ */
75
+ titleBar?: boolean
76
+ /**
77
+ * 标题栏背景色
78
+ */
79
+ titleBarBackgroundColor?: string
80
+ /**
81
+ * 标题栏文字颜色
82
+ */
83
+ titleBarTextColor?: string
84
+ /**
85
+ * 标题栏文字(也可通过页面跳转传递参数(titleBarText)设置)
86
+ */
87
+ titleBarText?: string
88
+ /**
89
+ * 是否显示标题栏右上角菜单按钮,点击菜单按钮调用页面生命周期 onMenuPress 方法,如果该方法未实现则显示系统默认菜单
90
+ */
91
+ menu?: boolean
92
+ /**
93
+ * 软键盘弹出时为保证输入框可见,页面的调整方式。 adjustPan:上移页面; adjustResize:压缩页面显示区域,当页面全屏时,此设置不生效
94
+ */
95
+ windowSoftInputMode?: 'adjustPan' | 'adjustResize'
96
+ }
97
+
98
+ interface IDisplayConfig extends IDefaultDisplayConfig {
99
+ /**
100
+ * 各个页面的显示样式,key 为页面名(与路由中的页面名保持一致),value 为窗口显示样式,页面样式覆盖 default 样式
101
+ */
102
+ pages?: {
103
+ [key: string]: IDefaultDisplayConfig
104
+ }
105
+ }
106
+
107
+ export interface ITaroManifestConfig {
108
+ /**
109
+ * 应用包名,确认与原生应用的包名不一致,推荐采用 com.company.module 的格式,如:com.example.demo
110
+ */
111
+ package: string
112
+ /**
113
+ * 应用名称,6 个汉字以内,与应用商店保存的名称一致,用于在桌面图标、弹窗等处显示应用名称
114
+ */
115
+ name: string
116
+ /**
117
+ * 应用图标,提供 192x192 大小的即可
118
+ */
119
+ icon: string
120
+ /**
121
+ * 应用版本名称,如:"1.0"
122
+ */
123
+ versionName?: string
124
+ /**
125
+ * 应用版本号,从1自增,推荐每次重新上传包时versionCode+1
126
+ */
127
+ versionCode: number
128
+ /**
129
+ * 支持的最小平台版本号,兼容性检查,避免上线后在低版本平台运行并导致不兼容;如果不填按照内测版本处理
130
+ */
131
+ minPlatformVersion?: string
132
+ /**
133
+ * 接口列表,绝大部分接口都需要在这里声明,否则不能调用,详见每个接口的文档说明
134
+ */
135
+ features?: FeatureItem[]
136
+ /**
137
+ *
138
+ */
139
+ logLevel?: LogLevel
140
+ }
141
+
142
+ export interface IManifestConfig extends ITaroManifestConfig {
143
+ /**
144
+ * 系统配置信息
145
+ */
146
+ config: SystemConfig
147
+ /**
148
+ * 路由信息
149
+ */
150
+ router: RouterConfig
151
+ /**
152
+ * UI 显示相关配置
153
+ */
154
+ display?: IDisplayConfig
155
+ }
@@ -0,0 +1,48 @@
1
+ import type Webpack from 'webpack'
2
+ import type Chain from 'webpack-chain'
3
+ import type { IMINI_APP_FILE_TYPE, IOption, IPostcssOption } from './util'
4
+
5
+ interface Runtime {
6
+ enableInnerHTML: boolean
7
+ enableSizeAPIs: boolean
8
+ enableAdjacentHTML: boolean
9
+ enableTemplateContent: boolean
10
+ enableCloneNode: boolean
11
+ enableContains: boolean
12
+ enableMutationObserver: boolean
13
+ }
14
+
15
+ export interface IMiniAppConfig {
16
+ appOutput?: boolean
17
+ sourceMapType?: string
18
+ debugReact?: boolean
19
+ minifyXML?: {
20
+ collapseWhitespace?: boolean
21
+ }
22
+
23
+ webpackChain?: (chain: Chain, webpack: typeof Webpack, PARSE_AST_TYPE: any) => void
24
+ output?: Webpack.Configuration['output']
25
+ postcss?: IPostcssOption
26
+ cssLoaderOption?: IOption
27
+ sassLoaderOption?: IOption
28
+ lessLoaderOption?: IOption
29
+ stylusLoaderOption?: IOption
30
+ mediaUrlLoaderOption?: IOption
31
+ fontUrlLoaderOption?: IOption
32
+ imageUrlLoaderOption?: IOption
33
+ miniCssExtractPluginOption?: IOption
34
+
35
+ customFilesTypes?: IMINI_APP_FILE_TYPE
36
+ commonChunks?: string[] | ((commonChunks: string[]) => string[])
37
+ addChunkPages?: ((pages: Map<string, string[]>, pagesNames?: string[]) => void)
38
+ optimizeMainPackage?: {
39
+ enable?: boolean
40
+ exclude?: any[]
41
+ }
42
+
43
+ compile?: {
44
+ exclude?: any[]
45
+ include?: any[]
46
+ }
47
+ runtime?: Runtime
48
+ }
@@ -0,0 +1,91 @@
1
+ import type Webpack from 'webpack'
2
+ import type Chain from 'webpack-chain'
3
+ import type { Compiler } from '../compiler'
4
+ import type { IModifyWebpackChain } from '../hooks'
5
+ import type { ICopyOptions, IOption, ISassOptions, TogglableOptions } from "./util"
6
+ import { IH5Config } from './h5'
7
+ import { IMiniAppConfig } from './mini'
8
+
9
+ export type PluginItem = string | [string, object]
10
+
11
+ interface ICache {
12
+ enable?: boolean
13
+ buildDependencies?: Record<string, any>
14
+ name?: string
15
+ }
16
+
17
+ interface ILogger {
18
+ quiet: boolean
19
+ stats: boolean
20
+ }
21
+
22
+ export interface IProjectBaseConfig {
23
+ isWatch?: boolean
24
+ port?: number
25
+ projectName?: string
26
+ date?: string
27
+ designWidth?: number
28
+ watcher?: any[]
29
+ deviceRatio?: TaroGeneral.TDeviceRatio
30
+ sourceRoot?: string
31
+ outputRoot?: string
32
+ env?: IOption
33
+ alias?: IOption
34
+ defineConstants?: IOption
35
+ copy?: ICopyOptions
36
+ jsMinimizer?: 'terser' | 'esbuild'
37
+ cssMinimizer?: 'csso' | 'esbuild' | 'parcelCss'
38
+ csso?: TogglableOptions
39
+ terser?: TogglableOptions
40
+ esbuild?: Record<'minify', TogglableOptions>
41
+ uglify?: TogglableOptions
42
+ sass?: ISassOptions
43
+ plugins?: PluginItem[]
44
+ presets?: PluginItem[]
45
+ baseLevel?: number
46
+ framework?: string
47
+ frameworkExts?: string[]
48
+ compiler?: Compiler
49
+ cache?: ICache
50
+ logger?: ILogger
51
+ enableSourceMap?: boolean
52
+ /**
53
+ * 编译开始
54
+ */
55
+ onBuildStart?: (...args: any[]) => Promise<any>
56
+ /**
57
+ * 编译完成(启动项目后首次编译结束后会触发一次)
58
+ */
59
+ onBuildComplete?: (...args: any[]) => Promise<any>
60
+ /**
61
+ * 编译结束(保存代码每次编译结束后都会触发)
62
+ */
63
+ onBuildFinish?: (res: { error, stats, isWatch }) => Promise<any>
64
+ /**
65
+ * 修改编译过程中的页面组件配置
66
+ */
67
+ onCompilerMake?: (compilation: Webpack.Compilation, compiler: Webpack.Compiler, plugin: any) => Promise<any>
68
+ onWebpackChainReady?: (webpackChain: Chain) => Promise<any>
69
+ /**
70
+ * 编译中修改 webpack 配置,在这个钩子中,你可以对 webpackChain 作出想要的调整,等同于配置 [`webpackChain`](./config-detail.md#miniwebpackchain)
71
+ */
72
+ modifyWebpackChain?: (chain: Chain, webpack: typeof Webpack, data: IModifyWebpackChain) => Promise<any>
73
+ /**
74
+ * 修改编译过程中的页面组件配置
75
+ */
76
+ modifyMiniConfigs?: (configMap: any) => Promise<any>
77
+ /**
78
+ * 修改编译后的结果
79
+ */
80
+ modifyBuildAssets?: (assets: any, miniPlugin?: any) => Promise<any>
81
+ }
82
+
83
+ export interface IProjectConfig extends IProjectBaseConfig {
84
+ ui?: {
85
+ extraWatchFiles?: any[]
86
+ }
87
+ mini?: IMiniAppConfig
88
+ h5?: IH5Config
89
+ rn?: IH5Config
90
+ [key: string]: any
91
+ }
@@ -0,0 +1,107 @@
1
+ export type Func = (...args: any[]) => any
2
+
3
+ export type IOption = Record<string, any>
4
+
5
+ export type TogglableOptions<T = IOption> = {
6
+ enable?: boolean
7
+ config?: T
8
+ }
9
+
10
+ export namespace PostcssOption {
11
+ export type cssModules = TogglableOptions<{
12
+ namingPattern: 'global' | string
13
+ generateScopedName: string | ((localName: string, absoluteFilePath: string) => string)
14
+ }>
15
+ export type url = TogglableOptions<{
16
+ limit: number
17
+ basePath?: string | string[]
18
+ }>
19
+ }
20
+
21
+ export interface IPostcssOption {
22
+ autoprefixer?: TogglableOptions
23
+ pxtransform?: TogglableOptions
24
+ cssModules?: PostcssOption.cssModules
25
+ url?: PostcssOption.url
26
+ [key: string]: any
27
+ }
28
+
29
+ export interface ICopyOptions {
30
+ patterns: {
31
+ from: string
32
+ to: string
33
+ ignore?: string[]
34
+ transform?: Function
35
+ watch?: boolean
36
+ }[]
37
+ options: {
38
+ ignore?: string[]
39
+ }
40
+ }
41
+
42
+ export interface ISassOptions {
43
+ /**
44
+ * 引入的全局 sass 文件,如果要引入多个文件,支持数组形式传入
45
+ */
46
+ resource?: string | string[]
47
+ /**
48
+ * 项目根目录的绝对地址(若为小程序云开发模板,则应该是client目录)
49
+ */
50
+ projectDirectory?: string
51
+ /**
52
+ * 全局 scss 变量,若 data 与 resource 中设置了同样的变量,则 data 的优先级高于 resource
53
+ */
54
+ data?: string
55
+ }
56
+
57
+ export interface ICompileOption {
58
+ exclude?: string[]
59
+ include?: string[]
60
+ }
61
+
62
+ export const enum TEMPLATE_TYPES {
63
+ WEAPP = '.wxml',
64
+ SWAN = '.swan',
65
+ ALIPAY = '.axml',
66
+ TT = '.ttml',
67
+ QUICKAPP = '.ux',
68
+ QQ = '.qml'
69
+ }
70
+
71
+ export const enum STYLE_TYPES {
72
+ WEAPP = '.wxss',
73
+ SWAN = '.css',
74
+ ALIPAY = '.acss',
75
+ TT = '.ttss',
76
+ QUICKAPP = '.css',
77
+ QQ = '.qss'
78
+ }
79
+
80
+ export const enum SCRIPT_TYPES {
81
+ WEAPP = '.js',
82
+ SWAN = '.js',
83
+ ALIPAY = '.js',
84
+ TT = '.js',
85
+ QUICKAPP = '.js',
86
+ QQ = '.js'
87
+ }
88
+
89
+ export const enum CONFIG_TYPES {
90
+ WEAPP = '.json',
91
+ SWAN = '.json',
92
+ ALIPAY = '.json',
93
+ TT = '.json',
94
+ QUICKAPP = '.json',
95
+ QQ = '.json'
96
+ }
97
+
98
+ export type IMINI_APP_FILE_TYPE = {
99
+ TEMPL: TEMPLATE_TYPES,
100
+ STYLE: STYLE_TYPES,
101
+ SCRIPT: SCRIPT_TYPES,
102
+ CONFIG: CONFIG_TYPES
103
+ }
104
+
105
+ export type IMINI_APP_FILES = {
106
+ [key: string]: IMINI_APP_FILE_TYPE
107
+ }
@@ -0,0 +1,13 @@
1
+ type Tagname = string
2
+ type Attrs = Set<string>
3
+
4
+ interface IComponentConfig {
5
+ includes: Set<string>
6
+ exclude: Set<string>
7
+ thirdPartyComponents: Map<Tagname, Attrs>
8
+ includeAll: boolean
9
+ }
10
+
11
+ export interface IModifyWebpackChain {
12
+ componentConfig?: IComponentConfig
13
+ }
@@ -0,0 +1,3 @@
1
+ export { Current } from '@tarojs/runtime'
2
+
3
+ export * from './config'
@@ -28,7 +28,7 @@ declare module './index' {
28
28
  onHide?(): void
29
29
  }
30
30
  interface AppInstance extends Show {
31
- mount(component: React.Component | Vue.ComponentOptions<Vue>, id: string, cb: (...args: any[]) => void): void
31
+ mount(component: React.Component | Vue.ComponentOptions<typeof Vue>, id: string, cb: (...args: any[]) => void): void
32
32
  componentDidShow?(options?: Record<string, unknown>): void
33
33
  onShow?(options?: Record<string, unknown>): void
34
34
  unmount(id: string, cb?: () => void): void
@@ -1,436 +0,0 @@
1
- import swc from '@swc/core'
2
- export { Current } from '@tarojs/runtime'
3
- import webpack from 'webpack'
4
- import webpackDevServer from 'webpack-dev-server'
5
- import HtmlWebpackPlugin from 'html-webpack-plugin'
6
-
7
- export const enum TEMPLATE_TYPES {
8
- WEAPP = '.wxml',
9
- SWAN = '.swan',
10
- ALIPAY = '.axml',
11
- TT = '.ttml',
12
- QUICKAPP = '.ux',
13
- QQ = '.qml'
14
- }
15
-
16
- export const enum STYLE_TYPES {
17
- WEAPP = '.wxss',
18
- SWAN = '.css',
19
- ALIPAY = '.acss',
20
- TT = '.ttss',
21
- QUICKAPP = '.css',
22
- QQ = '.qss'
23
- }
24
-
25
- export const enum SCRIPT_TYPES {
26
- WEAPP = '.js',
27
- SWAN = '.js',
28
- ALIPAY = '.js',
29
- TT = '.js',
30
- QUICKAPP = '.js',
31
- QQ = '.js'
32
- }
33
-
34
- export const enum CONFIG_TYPES {
35
- WEAPP = '.json',
36
- SWAN = '.json',
37
- ALIPAY = '.json',
38
- TT = '.json',
39
- QUICKAPP = '.json',
40
- QQ = '.json'
41
- }
42
-
43
- export type IMINI_APP_FILE_TYPE = {
44
- TEMPL: TEMPLATE_TYPES,
45
- STYLE: STYLE_TYPES,
46
- SCRIPT: SCRIPT_TYPES,
47
- CONFIG: CONFIG_TYPES
48
- }
49
-
50
- export type IMINI_APP_FILES = {
51
- [key: string]: IMINI_APP_FILE_TYPE
52
- }
53
-
54
- export type IOption = Record<string, any>
55
-
56
- export interface ICopyOptions {
57
- patterns: {
58
- from: string
59
- to: string
60
- ignore?: string[]
61
- transform?: Function
62
- watch?: boolean
63
- }[]
64
- options: {
65
- ignore?: string[]
66
- }
67
- }
68
-
69
- export interface ISassOptions {
70
- /**
71
- * 引入的全局 sass 文件,如果要引入多个文件,支持数组形式传入
72
- */
73
- resource?: string | string[]
74
- /**
75
- * 项目根目录的绝对地址(若为小程序云开发模板,则应该是client目录)
76
- */
77
- projectDirectory?: string
78
- /**
79
- * 全局 scss 变量,若 data 与 resource 中设置了同样的变量,则 data 的优先级高于 resource
80
- */
81
- data?: string
82
- }
83
-
84
- export interface ICopyArgOptions {
85
- filter?: (src: string) => boolean
86
- }
87
-
88
- export namespace PostcssOption {
89
- export type cssModules = TogglableOptions<{
90
- namingPattern: 'global' | string
91
- generateScopedName: string | ((localName: string, absoluteFilePath: string) => string)
92
- }>
93
- export type url = TogglableOptions<{
94
- limit: number
95
- basePath?: string | string[]
96
- }>
97
- }
98
-
99
- export interface IPostcssOption {
100
- autoprefixer?: TogglableOptions
101
- pxtransform?: TogglableOptions
102
- cssModules?: PostcssOption.cssModules
103
- url?: PostcssOption.url
104
- [key: string]: any
105
- }
106
-
107
- export interface ICompileOption {
108
- exclude?: string[]
109
- include?: string[]
110
- }
111
-
112
- interface Runtime {
113
- enableInnerHTML: boolean
114
- enableSizeAPIs: boolean
115
- enableAdjacentHTML: boolean
116
- enableTemplateContent: boolean
117
- enableCloneNode: boolean
118
- enableContains: boolean
119
- enableMutationObserver: boolean
120
- }
121
-
122
- export interface IMiniAppConfig {
123
- appOutput?: boolean
124
- sourceMapType?: string
125
- debugReact?: boolean
126
- minifyXML?: {
127
- collapseWhitespace?: boolean
128
- }
129
-
130
- webpackChain?: (chain: any, webpack: any, PARSE_AST_TYPE: any) => void
131
- output?: webpack.Output
132
- postcss?: IPostcssOption
133
- cssLoaderOption?: IOption
134
- sassLoaderOption?: IOption
135
- lessLoaderOption?: IOption
136
- stylusLoaderOption?: IOption
137
- mediaUrlLoaderOption?: IOption
138
- fontUrlLoaderOption?: IOption
139
- imageUrlLoaderOption?: IOption
140
- miniCssExtractPluginOption?: IOption
141
-
142
- customFilesTypes?: IMINI_APP_FILE_TYPE
143
- commonChunks?: string[] | ((commonChunks: string[]) => string[])
144
- addChunkPages?: ((pages: Map<string, string[]>, pagesNames?: string[]) => void)
145
- optimizeMainPackage?: {
146
- enable?: boolean
147
- exclude?: any[]
148
- }
149
-
150
- compile?: {
151
- exclude?: any[]
152
- include?: any[]
153
- }
154
- runtime?: Runtime
155
- }
156
-
157
- export type TogglableOptions<T = IOption> = {
158
- enable?: boolean
159
- config?: T
160
- }
161
-
162
- export interface IH5RouterConfig {
163
- mode?: 'hash' | 'browser' | 'multi'
164
- customRoutes?: IOption
165
- basename?: string
166
- lazyload?: boolean | ((pagename: string) => boolean)
167
- renamePagename?: (pagename: string) => string
168
- forcePath?: string
169
- }
170
-
171
- export interface IH5Config {
172
- publicPath?: string
173
- staticDirectory?: string
174
- chunkDirectory?: string
175
-
176
- webpack?: ((webpackConfig: webpack.Configuration, webpack) => webpack.Configuration) | webpack.Configuration
177
-
178
- webpackChain?: (chain: any, webpack: any) => void
179
-
180
- output?: webpack.Output
181
- router?: IH5RouterConfig
182
- devServer?: webpackDevServer.Configuration
183
- 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'
184
- enableExtract?: boolean
185
- transformOnly?: boolean
186
-
187
- cssLoaderOption?: IOption
188
- styleLoaderOption?: IOption
189
- sassLoaderOption?: IOption
190
- lessLoaderOption?: IOption
191
- stylusLoaderOption?: IOption
192
- mediaUrlLoaderOption?: IOption
193
- fontUrlLoaderOption?: IOption
194
- imageUrlLoaderOption?: IOption
195
- miniCssExtractPluginOption?: IOption
196
- esnextModules?: string[]
197
- useHtmlComponents?: boolean
198
-
199
- postcss?: IPostcssOption
200
- htmlPluginOption?: HtmlWebpackPlugin.Options
201
- }
202
-
203
- type FeatureItem = {
204
- name: string
205
- }
206
-
207
- declare enum LogLevel {
208
- OFF = 'off',
209
- ERROR = 'error',
210
- WARN = 'warn',
211
- INFO = 'info',
212
- LOG = 'log',
213
- DEBUG = 'debug'
214
- }
215
-
216
- export type SystemConfig = {
217
- /**
218
- * 打印日志等级,分为 off,error,warn,info,log,debug
219
- */
220
- logLevel?: LogLevel
221
- /**
222
- * 页面设计基准宽度,根据实际设备宽度来缩放元素大小
223
- */
224
- designWidth?: number
225
- /**
226
- * 全局数据对象,属性名不能以$或_开头,在页面中可通过 this 进行访问;如果全局数据属性与页面的数据属性重名,则页面初始化时,全局数据会覆盖页面中对应的属性值
227
- */
228
- data?: IOption
229
- }
230
-
231
- type RouterConfig = {
232
- /**
233
- * 首页名称
234
- */
235
- entry: string
236
- /**
237
- * 页面配置列表,key 值为页面名称(对应页面目录名,例如 Hello 对应'Hello'目录),value 为页面详细配置 page
238
- */
239
- pages: RouterPage[]
240
- }
241
- type RouterPage = {
242
- /**
243
- * 页面对应的组件名,与 ux 文件名保持一致,例如'hello' 对应 'hello.ux'
244
- */
245
- component: string
246
- /**
247
- * 页面路径,例如“/user”,不填则默认为/<页面名称>。
248
- * path 必须唯一,不能和其他 page 的 path 相同。
249
- * 下面 page 的 path 因为缺失,会被设置为“/Index”:
250
- * "Index": {"component": "index"}
251
- */
252
- path?: string
253
- /**
254
- * 声明页面可以处理某种请求
255
- */
256
- filter: {
257
- [key: string]: {
258
- uri: string
259
- }
260
- }
261
- }
262
-
263
- interface IDefaultDisplayConfig {
264
- /**
265
- * 窗口背景颜色
266
- */
267
- backgroundColor?: string
268
- /**
269
- * 是否是全屏模式,默认不会同时作用于 titleBar,titleBar 需要继续通过 titleBar 控制
270
- */
271
- fullScreen?: boolean
272
- /**
273
- * 是否显示 titleBar
274
- */
275
- titleBar?: boolean
276
- /**
277
- * 标题栏背景色
278
- */
279
- titleBarBackgroundColor?: string
280
- /**
281
- * 标题栏文字颜色
282
- */
283
- titleBarTextColor?: string
284
- /**
285
- * 标题栏文字(也可通过页面跳转传递参数(titleBarText)设置)
286
- */
287
- titleBarText?: string
288
- /**
289
- * 是否显示标题栏右上角菜单按钮,点击菜单按钮调用页面生命周期 onMenuPress 方法,如果该方法未实现则显示系统默认菜单
290
- */
291
- menu?: boolean
292
- /**
293
- * 软键盘弹出时为保证输入框可见,页面的调整方式。 adjustPan:上移页面; adjustResize:压缩页面显示区域,当页面全屏时,此设置不生效
294
- */
295
- windowSoftInputMode?: 'adjustPan' | 'adjustResize'
296
- }
297
-
298
- interface IDisplayConfig extends IDefaultDisplayConfig {
299
- /**
300
- * 各个页面的显示样式,key 为页面名(与路由中的页面名保持一致),value 为窗口显示样式,页面样式覆盖 default 样式
301
- */
302
- pages?: {
303
- [key: string]: IDefaultDisplayConfig
304
- }
305
- }
306
-
307
- export interface ITaroManifestConfig {
308
- /**
309
- * 应用包名,确认与原生应用的包名不一致,推荐采用 com.company.module 的格式,如:com.example.demo
310
- */
311
- package: string
312
- /**
313
- * 应用名称,6 个汉字以内,与应用商店保存的名称一致,用于在桌面图标、弹窗等处显示应用名称
314
- */
315
- name: string
316
- /**
317
- * 应用图标,提供 192x192 大小的即可
318
- */
319
- icon: string
320
- /**
321
- * 应用版本名称,如:"1.0"
322
- */
323
- versionName?: string
324
- /**
325
- * 应用版本号,从1自增,推荐每次重新上传包时versionCode+1
326
- */
327
- versionCode: number
328
- /**
329
- * 支持的最小平台版本号,兼容性检查,避免上线后在低版本平台运行并导致不兼容;如果不填按照内测版本处理
330
- */
331
- minPlatformVersion?: string
332
- /**
333
- * 接口列表,绝大部分接口都需要在这里声明,否则不能调用,详见每个接口的文档说明
334
- */
335
- features?: FeatureItem[]
336
- /**
337
- *
338
- */
339
- logLevel?: LogLevel
340
- }
341
-
342
- export interface IManifestConfig extends ITaroManifestConfig {
343
- /**
344
- * 系统配置信息
345
- */
346
- config: SystemConfig
347
- /**
348
- * 路由信息
349
- */
350
- router: RouterConfig
351
- /**
352
- * UI 显示相关配置
353
- */
354
- display?: IDisplayConfig
355
- }
356
-
357
- export type PluginItem = string | [string, object]
358
-
359
- interface ICache {
360
- enable?: boolean
361
- buildDependencies?: Record<string, any>
362
- name?: string
363
- }
364
-
365
- type CompilerTypes = 'webpack4' | 'webpack5'
366
- interface IPrebundle {
367
- enable?: boolean
368
- timings?: boolean
369
- cacheDir?: string
370
- force?: boolean
371
- include?: string[]
372
- exclude?: string[]
373
- esbuild?: Record<string, any>
374
- swc?: swc.Config
375
- webpack?: webpack.Configuration & {
376
- provide?: any[]
377
- }
378
- }
379
- interface ICompiler {
380
- type: CompilerTypes
381
- prebundle: IPrebundle
382
- }
383
- type Compiler = CompilerTypes | ICompiler
384
-
385
- interface ILogger {
386
- quiet: boolean
387
- stats: boolean
388
- }
389
-
390
- export interface IProjectBaseConfig {
391
- isWatch?: boolean
392
- port?: number
393
- projectName?: string
394
- date?: string
395
- designWidth?: number
396
- watcher?: any[]
397
- deviceRatio?: TaroGeneral.TDeviceRatio
398
- sourceRoot?: string
399
- outputRoot?: string
400
- env?: IOption
401
- alias?: IOption
402
- defineConstants?: IOption
403
- copy?: ICopyOptions
404
- jsMinimizer?: 'terser' | 'esbuild'
405
- cssMinimizer?: 'csso' | 'esbuild' | 'parcelCss'
406
- csso?: TogglableOptions
407
- terser?: TogglableOptions
408
- esbuild?: Record<'minify', TogglableOptions>
409
- uglify?: TogglableOptions
410
- sass?: ISassOptions
411
- plugins?: PluginItem[]
412
- presets?: PluginItem[]
413
- baseLevel?: number
414
- framework?: string
415
- frameworkExts?: string[]
416
- compiler?: Compiler
417
- cache?: ICache
418
- logger?: ILogger
419
- enableSourceMap?: boolean
420
- /** hooks */
421
- modifyWebpackChain?: HookModifyWebpackChain
422
- modifyMiniConfigs?: (configMap) => Promise<any>
423
- modifyBuildAssets?: (assets, plugin?) => Promise<any>
424
- onWebpackChainReady?: (webpackChain: Chain) => Promise<any>
425
- onBuildFinish?: (res: { error, stats, isWatch }) => Promise<any>
426
- }
427
-
428
- export interface IProjectConfig extends IProjectBaseConfig {
429
- ui?: {
430
- extraWatchFiles?: any[]
431
- }
432
- mini?: IMiniAppConfig
433
- h5?: IH5Config
434
- rn?: IH5Config
435
- [key: string]: any
436
- }