@spcsn/taro 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/README.md +12 -0
  2. package/dist/index.js +147 -0
  3. package/dist/index.js.map +1 -0
  4. package/index.js +9 -0
  5. package/package.json +86 -0
  6. package/types/api/ad/index.d.ts +197 -0
  7. package/types/api/ai/face.d.ts +133 -0
  8. package/types/api/ai/inference.d.ts +129 -0
  9. package/types/api/ai/visionkit.d.ts +874 -0
  10. package/types/api/alipay/index.d.ts +69 -0
  11. package/types/api/base/crypto.d.ts +104 -0
  12. package/types/api/base/debug.d.ts +329 -0
  13. package/types/api/base/env.d.ts +19 -0
  14. package/types/api/base/index.d.ts +102 -0
  15. package/types/api/base/performance.d.ts +258 -0
  16. package/types/api/base/system.d.ts +742 -0
  17. package/types/api/base/update.d.ts +130 -0
  18. package/types/api/base/weapp/app-event.d.ts +265 -0
  19. package/types/api/base/weapp/life-cycle.d.ts +155 -0
  20. package/types/api/canvas/index.d.ts +2162 -0
  21. package/types/api/cloud/index.d.ts +2622 -0
  22. package/types/api/data-analysis/index.d.ts +122 -0
  23. package/types/api/device/accelerometer.d.ts +102 -0
  24. package/types/api/device/accessibility.d.ts +26 -0
  25. package/types/api/device/battery.d.ts +46 -0
  26. package/types/api/device/bluetooth-ble.d.ts +601 -0
  27. package/types/api/device/bluetooth-peripheral.d.ts +430 -0
  28. package/types/api/device/bluetooth.d.ts +463 -0
  29. package/types/api/device/calendar.d.ts +98 -0
  30. package/types/api/device/clipboard.d.ts +81 -0
  31. package/types/api/device/compass.d.ts +105 -0
  32. package/types/api/device/contact.d.ts +110 -0
  33. package/types/api/device/gyroscope.d.ts +85 -0
  34. package/types/api/device/iBeacon.d.ts +168 -0
  35. package/types/api/device/keyboard.d.ts +97 -0
  36. package/types/api/device/memory.d.ts +52 -0
  37. package/types/api/device/motion.d.ts +88 -0
  38. package/types/api/device/network.d.ts +172 -0
  39. package/types/api/device/nfc.d.ts +1238 -0
  40. package/types/api/device/phone.d.ts +30 -0
  41. package/types/api/device/scan.d.ts +111 -0
  42. package/types/api/device/screen.d.ts +217 -0
  43. package/types/api/device/sms.d.ts +26 -0
  44. package/types/api/device/vibrate.d.ts +51 -0
  45. package/types/api/device/wifi.d.ts +301 -0
  46. package/types/api/ext/index.d.ts +64 -0
  47. package/types/api/files/index.d.ts +1472 -0
  48. package/types/api/framework/index.d.ts +51 -0
  49. package/types/api/location/index.d.ts +517 -0
  50. package/types/api/media/audio.d.ts +1013 -0
  51. package/types/api/media/background-audio.d.ts +291 -0
  52. package/types/api/media/camera.d.ts +207 -0
  53. package/types/api/media/editor.d.ts +239 -0
  54. package/types/api/media/image.d.ts +469 -0
  55. package/types/api/media/live.d.ts +461 -0
  56. package/types/api/media/map.d.ts +638 -0
  57. package/types/api/media/media-recorder.d.ts +117 -0
  58. package/types/api/media/recorder.d.ts +317 -0
  59. package/types/api/media/video-decoder.d.ts +117 -0
  60. package/types/api/media/video-processing.d.ts +84 -0
  61. package/types/api/media/video.d.ts +527 -0
  62. package/types/api/media/voip.d.ts +393 -0
  63. package/types/api/navigate/index.d.ts +327 -0
  64. package/types/api/network/download.d.ts +173 -0
  65. package/types/api/network/mdns.d.ts +191 -0
  66. package/types/api/network/request.d.ts +480 -0
  67. package/types/api/network/tcp.d.ts +181 -0
  68. package/types/api/network/udp.d.ts +218 -0
  69. package/types/api/network/upload.d.ts +201 -0
  70. package/types/api/network/websocket.d.ts +383 -0
  71. package/types/api/open-api/account.d.ts +51 -0
  72. package/types/api/open-api/address.d.ts +68 -0
  73. package/types/api/open-api/authorize.d.ts +80 -0
  74. package/types/api/open-api/card.d.ts +110 -0
  75. package/types/api/open-api/channels.d.ts +225 -0
  76. package/types/api/open-api/customer-service.d.ts +45 -0
  77. package/types/api/open-api/device-voip.d.ts +103 -0
  78. package/types/api/open-api/facial.d.ts +98 -0
  79. package/types/api/open-api/favorites.d.ts +101 -0
  80. package/types/api/open-api/group.d.ts +59 -0
  81. package/types/api/open-api/invoice.d.ts +87 -0
  82. package/types/api/open-api/license-plate.d.ts +27 -0
  83. package/types/api/open-api/login.d.ts +115 -0
  84. package/types/api/open-api/my-miniprogram.d.ts +28 -0
  85. package/types/api/open-api/privacy.d.ts +107 -0
  86. package/types/api/open-api/redpackage.d.ts +24 -0
  87. package/types/api/open-api/settings.d.ts +174 -0
  88. package/types/api/open-api/soter.d.ts +184 -0
  89. package/types/api/open-api/sticker.d.ts +83 -0
  90. package/types/api/open-api/subscribe-message.d.ts +305 -0
  91. package/types/api/open-api/user-info.d.ts +182 -0
  92. package/types/api/open-api/werun.d.ts +101 -0
  93. package/types/api/payment/index.d.ts +119 -0
  94. package/types/api/qq/index.d.ts +354 -0
  95. package/types/api/route/index.d.ts +324 -0
  96. package/types/api/share/index.d.ts +354 -0
  97. package/types/api/skyline/index.d.ts +345 -0
  98. package/types/api/storage/background-fetch.d.ts +131 -0
  99. package/types/api/storage/cache-manager.d.ts +249 -0
  100. package/types/api/storage/index.d.ts +405 -0
  101. package/types/api/swan/bookshelf.d.ts +307 -0
  102. package/types/api/swan/download-package.d.ts +80 -0
  103. package/types/api/swan/index.d.ts +251 -0
  104. package/types/api/swan/pay.d.ts +139 -0
  105. package/types/api/taro.extend.d.ts +233 -0
  106. package/types/api/taro.hooks.d.ts +148 -0
  107. package/types/api/ui/animation.d.ts +427 -0
  108. package/types/api/ui/background.d.ts +69 -0
  109. package/types/api/ui/custom-component.d.ts +23 -0
  110. package/types/api/ui/fonts.d.ts +77 -0
  111. package/types/api/ui/interaction.d.ts +281 -0
  112. package/types/api/ui/menu.d.ts +29 -0
  113. package/types/api/ui/navigation-bar.d.ts +130 -0
  114. package/types/api/ui/pull-down-refresh.d.ts +50 -0
  115. package/types/api/ui/scroll.d.ts +114 -0
  116. package/types/api/ui/sticky.d.ts +32 -0
  117. package/types/api/ui/tab-bar.d.ts +196 -0
  118. package/types/api/ui/window.d.ts +71 -0
  119. package/types/api/worker/index.d.ts +83 -0
  120. package/types/api/wxml/index.d.ts +540 -0
  121. package/types/compile/compiler.d.ts +32 -0
  122. package/types/compile/config/h5.d.ts +134 -0
  123. package/types/compile/config/harmony.d.ts +118 -0
  124. package/types/compile/config/index.d.ts +8 -0
  125. package/types/compile/config/manifest.d.ts +155 -0
  126. package/types/compile/config/mini.d.ts +118 -0
  127. package/types/compile/config/plugin.d.ts +34 -0
  128. package/types/compile/config/project.d.ts +338 -0
  129. package/types/compile/config/rn.d.ts +85 -0
  130. package/types/compile/config/util.d.ts +179 -0
  131. package/types/compile/hooks.d.ts +13 -0
  132. package/types/compile/index.d.ts +11 -0
  133. package/types/compile/viteCompilerContext.d.ts +167 -0
  134. package/types/global.d.ts +428 -0
  135. package/types/index.d.ts +190 -0
  136. package/types/taro.api.d.ts +130 -0
  137. package/types/taro.component.d.ts +168 -0
  138. package/types/taro.config.d.ts +712 -0
  139. package/types/taro.lifecycle.d.ts +220 -0
  140. package/types/taro.runtime.d.ts +9 -0
@@ -0,0 +1,338 @@
1
+ import type Webpack from 'webpack'
2
+ import type Chain from 'webpack-chain'
3
+ import type { Input } from 'postcss'
4
+ import type { AppConfig } from '../../index'
5
+ import type { Compiler, CompilerTypes, CompilerWebpackTypes } from '../compiler'
6
+ import type { IModifyChainData } from '../hooks'
7
+ import type { ICopyOptions, IOption, ISassOptions, TogglableOptions } from './util'
8
+ import type { IH5Config } from './h5'
9
+ import type { IHarmonyConfig } from './harmony'
10
+ import type { IMiniAppConfig, IMiniFilesConfig } from './mini'
11
+ import type { IRNConfig } from './rn'
12
+
13
+ export type PluginItem<T = object> = string | [string, T] | [string, () => T | Promise<T>]
14
+
15
+ interface ICache {
16
+ /**
17
+ * 是否开启持久化缓存 (默认值 false)
18
+ * @description ```
19
+ * 值为 false 时:开发模式下 WebpackConfig.cache.type = 'memory',而生产模式下 WebpackConfig.cache = false;
20
+ * 值为 true 时:开发模式和生产模式下均为 WebpackConfig.cache.type = 'filesystem'
21
+ * ```
22
+ */
23
+ enable?: boolean
24
+
25
+ /**
26
+ * 当依赖的文件或该文件的依赖改变时,使缓存失效。
27
+ * @description 详详情请参考 [WebpackConfig.cache.buildDependencies](https://webpack.js.org/configuration/cache/#cachebuilddependencies)。
28
+ */
29
+ buildDependencies?: Record<string, any>
30
+
31
+ /**
32
+ * 缓存子目录的名称 (默认值 process.env.NODE_ENV-process.env.TARO_ENV)
33
+ * @description 详情请参考 [WebpackConfig.cache.name](https://webpack.js.org/configuration/cache/#cachename)
34
+ */
35
+ name?: string
36
+ }
37
+
38
+ interface ILogger {
39
+ /** 是否简化输出日志 (默认值 true)*/
40
+ quiet: boolean
41
+ /** 是否输出 Webpack Stats 信息 (默认值 false) */
42
+ stats: boolean
43
+ }
44
+
45
+ export interface IProjectBaseConfig {
46
+ isWatch?: boolean
47
+ port?: number
48
+ /** 项目名称 */
49
+ projectName?: string
50
+
51
+ /** 项目创建日期 */
52
+ date?: string
53
+
54
+ /** 设计稿尺寸 */
55
+ designWidth?: number | ((size?: string | number | Input) => number)
56
+
57
+ /** 设计稿尺寸换算规则 */
58
+ deviceRatio?: TaroGeneral.TDeviceRatio
59
+
60
+ watcher?: any[]
61
+
62
+ /** 源码存放目录 (默认值:'src') */
63
+ sourceRoot?: string
64
+
65
+ /** 代码编译后的生产目录 (默认值:'dist') */
66
+ outputRoot?: string
67
+
68
+ /**
69
+ * 用于配置`process.env.xxxx`相关的环境变量
70
+ * @deprecated 建议使用根目录下的 .env 文件替代
71
+ * @description 注意:这里的环境变量只能在业务代码中使用,编译时的 node 环境中无法使用
72
+ * @example
73
+ * ```ts
74
+ * // config/index.ts
75
+ * export default defineConfig({
76
+ * env: {
77
+ * xxxx: '"测试"'
78
+ * }
79
+ * })
80
+ *
81
+ * // src/app.ts
82
+ * onShow() {
83
+ * console.log(process.env.xxxx) // 打印 "测试"
84
+ * }
85
+ * ```
86
+ */
87
+ env?: IOption
88
+
89
+ /** 用于配置目录别名,从而方便书写代码引用路径 */
90
+ alias?: IOption
91
+
92
+ /**
93
+ * 用于配置一些常量供代码中进行全局替换使用
94
+ * @description 注意:这里的环境变量只能在业务代码中使用,编译时的 node 环境中无法使用
95
+ * @example
96
+ * ```ts
97
+ * // config/index.ts
98
+ * export default defineConfig({
99
+ * defineConstants: {
100
+ * __TEST__: JSON.stringify('test')
101
+ * }
102
+ * })
103
+ *
104
+ * // src/app.ts
105
+ * onShow() {
106
+ * console.log(__TEST__) // 打印 "test"
107
+ * }
108
+ * ```
109
+ */
110
+ defineConstants?: IOption
111
+
112
+ /** 用于把文件从源码目录直接拷贝到编译后的生产目录 */
113
+ copy?: ICopyOptions
114
+
115
+ /** 配置 JS 压缩工具 (默认 terser) */
116
+ jsMinimizer?: 'terser' | 'esbuild'
117
+
118
+ /** 配置 CSS 压缩工具 (默认 csso) */
119
+ cssMinimizer?: 'csso' | 'esbuild' | 'lightningcss'
120
+
121
+ /** 配置 csso 工具以压缩 CSS 代码 */
122
+ csso?: TogglableOptions
123
+
124
+ /** 配置 terser 工具以压缩 JS 代码 */
125
+ terser?: TogglableOptions
126
+
127
+ esbuild?: Record<'minify', TogglableOptions>
128
+
129
+ uglify?: TogglableOptions
130
+
131
+ /** 用于控制对 scss 代码的编译行为,默认使用 dart-sass,具体配置可以参考 https://www.npmjs.com/package/sass */
132
+ sass?: ISassOptions
133
+
134
+ /** 配置 Taro 插件 */
135
+ plugins?: PluginItem[]
136
+
137
+ /** 一个 preset 是一系列 Taro 插件的集合,配置语法同 plugins */
138
+ presets?: PluginItem[]
139
+
140
+ /** 模板循环次数 */
141
+ baseLevel?: number
142
+
143
+ /** 使用的开发框架。可选值:react、preact、vue3 */
144
+ framework?: 'react' | 'preact' | 'solid' | 'vue3'
145
+ frameworkExts?: string[]
146
+
147
+ /** 使用的编译工具。可选值:webpack5 */
148
+ compiler?: Compiler
149
+
150
+ /** Webpack5 持久化缓存配置。具体配置请参考 [WebpackConfig.cache](https://webpack.js.org/configuration/cache/#cache) */
151
+ cache?: ICache
152
+
153
+ /** 控制 Taro 编译日志的输出方式 */
154
+ logger?: ILogger
155
+
156
+ /** 用于控制是否生成 js、css 对应的 sourceMap */
157
+ enableSourceMap?: boolean
158
+
159
+ /**
160
+ * 编译开始
161
+ */
162
+ onBuildStart?: (...args: any[]) => Promise<any>
163
+
164
+ /**
165
+ * 编译完成(启动项目后首次编译结束后会触发一次)
166
+ */
167
+ onBuildComplete?: (...args: any[]) => Promise<any>
168
+
169
+ /**
170
+ * 编译结束(保存代码每次编译结束后都会触发)
171
+ */
172
+ onBuildFinish?: (res: { error; stats; isWatch }) => Promise<any>
173
+
174
+ /**
175
+ * 修改编译过程中的页面组件配置
176
+ */
177
+ onCompilerMake?: (compilation: Webpack.Compilation, compiler: Webpack.Compiler, plugin: any) => Promise<any>
178
+
179
+ onWebpackChainReady?: (webpackChain: Chain) => Promise<any>
180
+
181
+ modifyAppConfig?: (appConfig: AppConfig) => Promise<any>
182
+
183
+ /**
184
+ * 编译中修改 webpack 配置,在这个钩子中,你可以对 webpackChain 作出想要的调整,等同于配置 [`webpackChain`](./config-detail#miniwebpackchain)
185
+ */
186
+ modifyWebpackChain?: (chain: Chain, webpack: typeof Webpack, data: IModifyChainData) => Promise<any>
187
+
188
+ /**
189
+ * 编译中修改 vite 配置
190
+ */
191
+ modifyViteConfig?: (viteConfig: any, data: IModifyChainData) => void
192
+
193
+ /**
194
+ * 修改编译后的结果
195
+ */
196
+ modifyBuildAssets?: (assets: any, miniPlugin?: any) => Promise<any>
197
+
198
+ /**
199
+ * 修改编译过程中的页面组件配置
200
+ */
201
+ modifyMiniConfigs?: (configMap: IMiniFilesConfig) => Promise<any>
202
+
203
+ /**
204
+ * 修改 Taro 编译配置
205
+ */
206
+ modifyRunnerOpts?: (opts: any) => Promise<any>
207
+ }
208
+
209
+ /** 暴露出来给 config/index 使用的配置类型,参考 https://github.com/NervJS/taro-doctor/blob/main/assets/config_schema.json */
210
+ export interface IProjectConfig<T extends CompilerTypes = CompilerWebpackTypes> {
211
+ /** 项目名称 */
212
+ projectName?: string
213
+
214
+ /** 项目创建日期 */
215
+ date?: string
216
+
217
+ /** 设计稿尺寸 */
218
+ designWidth?: number | ((size?: string | number | Input) => number)
219
+
220
+ /** 设计稿尺寸换算规则 */
221
+ deviceRatio?: TaroGeneral.TDeviceRatio
222
+
223
+ /** 源码存放目录 (默认值:'src') */
224
+ sourceRoot?: string
225
+
226
+ /** 代码编译后的生产目录 (默认值:'dist') */
227
+ outputRoot?: string
228
+
229
+ /**
230
+ * 用于配置`process.env.xxxx`相关的环境变量
231
+ * @deprecated 建议使用根目录下的 .env 文件替代
232
+ * @description 注意:这里的环境变量只能在业务代码中使用,编译时的 node 环境中无法使用
233
+ * @example
234
+ * ```ts
235
+ * // config/index.ts
236
+ * export default defineConfig({
237
+ * env: {
238
+ * xxxx: '"测试"'
239
+ * }
240
+ * })
241
+ *
242
+ * // src/app.ts
243
+ * onShow() {
244
+ * console.log(process.env.xxxx) // 打印 "测试"
245
+ * }
246
+ * ```
247
+ */
248
+ env?: IOption
249
+
250
+ /** 用于配置目录别名,从而方便书写代码引用路径 */
251
+ alias?: IOption
252
+
253
+ /**
254
+ * 用于配置一些常量供代码中进行全局替换使用
255
+ * @description 注意:这里的环境变量只能在业务代码中使用,编译时的 node 环境中无法使用
256
+ * @example
257
+ * ```ts
258
+ * // config/index.ts
259
+ * export default defineConfig({
260
+ * defineConstants: {
261
+ * __TEST__: JSON.stringify('test')
262
+ * }
263
+ * })
264
+ *
265
+ * // src/app.ts
266
+ * onShow() {
267
+ * console.log(__TEST__) // 打印 "test"
268
+ * }
269
+ * ```
270
+ */
271
+ defineConstants?: IOption
272
+
273
+ /** 用于把文件从源码目录直接拷贝到编译后的生产目录 */
274
+ copy?: ICopyOptions
275
+
276
+ /** 配置 JS 压缩工具 (默认 terser) */
277
+ jsMinimizer?: 'terser' | 'esbuild'
278
+
279
+ /** 配置 CSS 压缩工具 (默认 csso) */
280
+ cssMinimizer?: 'csso' | 'esbuild' | 'lightningcss'
281
+
282
+ /** 配置 csso 工具以压缩 CSS 代码 */
283
+ csso?: TogglableOptions
284
+
285
+ /** 配置 terser 工具以压缩 JS 代码 */
286
+ terser?: TogglableOptions
287
+
288
+ esbuild?: Record<'minify', TogglableOptions>
289
+
290
+ /** 用于控制对 scss 代码的编译行为,默认使用 dart-sass,具体配置可以参考 https://www.npmjs.com/package/sass */
291
+ sass?: ISassOptions
292
+
293
+ /** 配置 Taro 插件 */
294
+ plugins?: PluginItem[]
295
+
296
+ /** 一个 preset 是一系列 Taro 插件的集合,配置语法同 plugins */
297
+ presets?: PluginItem[]
298
+
299
+ /** 使用的开发框架。可选值:react、preact、solid、vue3、 none */
300
+ framework?: 'react' | 'preact' | 'solid' | 'vue3' | 'none'
301
+
302
+ /** Webpack5 持久化缓存配置。具体配置请参考 [WebpackConfig.cache](https://webpack.js.org/configuration/cache/#cache) */
303
+ cache?: ICache
304
+
305
+ /** 控制 Taro 编译日志的输出方式 */
306
+ logger?: ILogger
307
+
308
+ /** 使用的编译工具。可选值:webpack5、vite */
309
+ compiler?: Compiler<T>
310
+
311
+ /** 专属于 H5 的配置 */
312
+ h5?: IH5Config<T>
313
+
314
+ /** 专属于小程序的配置 */
315
+ mini?: IMiniAppConfig<T>
316
+
317
+ /** 专属于 RN 的配置 */
318
+ rn?: IRNConfig
319
+
320
+ harmony?: IHarmonyConfig<T>
321
+
322
+ [key: string]: any
323
+ }
324
+
325
+ export interface OutputExt {
326
+ /**
327
+ * 编译前清空输出目录
328
+ * @since Taro v3.6.9
329
+ * @description
330
+ * - 默认清空输出目录,可设置 clean: false 不清空
331
+ * - 可设置 clean: { keep: ['project.config.json'] } 保留指定文件
332
+ * - 注意 clean.keep 不支持函数
333
+ */
334
+ clean?: boolean | {
335
+ /** 保留指定文件不删除 */
336
+ keep?: Array<string | RegExp> | string | RegExp
337
+ }
338
+ }
@@ -0,0 +1,85 @@
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 { RollupOptions } from 'rollup'
6
+ import type { IOption, IPostcssOption } from './util'
7
+
8
+ export interface IRNConfig {
9
+ /** 设置 RN bundle 中注册应用的名称 */
10
+ appName?: string
11
+
12
+ /** entry 利用模块查找规则{name}.{platform}.{ext}自动区分平台 */
13
+ entry?: string
14
+
15
+ /** 设置 Metro 打包生成 bundle 的输出路径,默认 dist 目录下 */
16
+ output?: any
17
+
18
+ /** [sass](https://github.com/sass/node-sass#options) 相关配置 */
19
+ sass?: IOption
20
+
21
+ /** [less](https://lesscss.org/usage/#less-options) 相关配置 */
22
+ less?: IOption
23
+
24
+ /** [stylus](https://github.com/NervJS/taro/blob/main/packages/taro-rn-style-transformer/README.md#rnstylus) 相关配置 */
25
+ stylus?: IOption
26
+
27
+ /** 配置 postcss 相关插件 */
28
+ postcss?: {
29
+ /** postcss 配置,参考 https://github.com/postcss/postcss#options */
30
+ options?: any
31
+ /** 默认true,控制是否对 css value 进行 scalePx2dp 转换,pxtransform配置 enable 才生效 */
32
+ scalable?: boolean
33
+ pxtransform?: {
34
+ enable?: boolean
35
+ /** 插件 pxtransform 配置项 */
36
+ config?: {
37
+ additionalProperties?: boolean
38
+ [key: string]: any
39
+ }
40
+ },
41
+ cssModules?: {
42
+ enable: boolean
43
+ },
44
+ [key: string]: any
45
+ }
46
+
47
+ resolve?: any
48
+
49
+ /** 支持多 className 转换,以 classname 或 style 结尾的, 提取前缀, 然后根据前缀,再生成对应的 xxxStyle。如:barClassName -> barStyle。默认值 false,不开启 */
50
+ enableMultipleClassName?: boolean
51
+
52
+ /** 当标签 style 属性值是数组时转换成对象。默认值 false,不开启 */
53
+ enableMergeStyle?: boolean
54
+
55
+ /** 将 svg 文件转换为组件引入。默认值 false,不开启 */
56
+ enableSvgTransform?: boolean
57
+
58
+ alias?: IOption
59
+
60
+ /** 设计稿尺寸 */
61
+ designWidth?: number | ((size?: string | number | Input) => number)
62
+
63
+ /** 设计稿尺寸换算规则 */
64
+ deviceRatio?: TaroGeneral.TDeviceRatio
65
+
66
+ /** 原生组件编译配置 */
67
+ nativeComponents?: {
68
+ /**
69
+ * 外部依赖
70
+ */
71
+ external?: Array<string | RegExp> | ((arr: Array<string | RegExp>) => Array<string | RegExp>)
72
+ /**
73
+ * 设置外部依赖,如果返回 string, 则将该值作为 external, 我们默认将 node_modules 路径下的文件设置为外部依赖
74
+ */
75
+ exteranlResolve?: (importee: string, importer: string) => string
76
+ /**
77
+ * 组件输出路径,默认值为 'dist'
78
+ */
79
+ output?: string
80
+ /**
81
+ * 修改 Rollup 打包配置
82
+ */
83
+ modifyRollupConfig?: (config: RollupOptions, innerPlugins: { taroResolver: typeof taroResolver, styleTransformer: typeof styleTransformer }) => RollupOptions
84
+ }
85
+ }
@@ -0,0 +1,179 @@
1
+ import type { Input } from 'postcss'
2
+ import type { Options as PostcssUrlOption } from 'postcss-url'
3
+
4
+ export type Func = (...args: any[]) => any
5
+
6
+ export type IOption = Record<string, any>
7
+
8
+ export type TogglableOptions<T = IOption> = {
9
+ enable?: boolean
10
+ config?: T
11
+ }
12
+
13
+ export interface IUrlLoaderOption extends IOption {
14
+ limit?: number | boolean
15
+ name?: ((moduleId: string) => string) | string
16
+ }
17
+
18
+ export namespace PostcssOption {
19
+ export type cssModules = TogglableOptions<{
20
+ /** 转换模式,取值为 global/module */
21
+ namingPattern: 'global' | string
22
+ /** 自定义生成的class名称规则 */
23
+ generateScopedName: string | ((localName: string, absoluteFilePath: string) => string)
24
+ }>
25
+ export type url = TogglableOptions<PostcssUrlOption>
26
+ }
27
+
28
+ export interface IHtmlTransformOption {
29
+ /** 是否启用 postcss-html-transform 插件 */
30
+ enable?: boolean
31
+ config?: {
32
+ /** 当前编译平台 (此选项插件内部根据编译平台自行生成,无需传入) */
33
+ readonly platform?: string
34
+ /** 设置是否去除 cursor 相关样式 (h5默认值:true) */
35
+ removeCursorStyle: boolean
36
+ }
37
+ }
38
+
39
+ export interface IPxTransformOption {
40
+ /** 设置 1px 是否需要被转换 */
41
+ onePxTransform?: boolean
42
+ /** REM 单位允许的小数位 */
43
+ unitPrecision?: number
44
+ /** 允许转换的属性列表 (默认 [*]) */
45
+ propList?: string[]
46
+ /** 黑名单里的选择器将会被忽略 */
47
+ selectorBlackList?: Array<string | RegExp>
48
+ /** 直接替换而不是追加一条进行覆盖 */
49
+ replace?: boolean
50
+ /** 允许媒体查询里的 px 单位转换 */
51
+ mediaQuery?: boolean
52
+ /** 设置一个可被转换的最小 px 值 */
53
+ minPixelValue?: number
54
+ /**
55
+ * 转换后的单位,可选值为 rpx、vw、rem,当前仅支持小程序 (默认 rpx) 和 Web 端 (默认 rem)
56
+ * @description Web 端使用 rem 单位时会注入脚本用于设置 body 上的 font-size 属性,其他单位无该操作
57
+ */
58
+ targetUnit?: 'rpx' | 'vw' | 'rem'
59
+ /**
60
+ * H5 字体尺寸大小基准值,开发者可以自行调整单位换算的基准值(默认20)
61
+ * @supported h5
62
+ */
63
+ baseFontSize?: number
64
+ /**
65
+ * H5 根节点 font-size 的最大值 (默认 40)
66
+ * @supported h5
67
+ */
68
+ maxRootSize?: number
69
+ /**
70
+ * H5 根节点 font-size 的最小值(默认 20)
71
+ * @supported h5
72
+ */
73
+ minRootSize?: number
74
+ /** 设计稿尺寸 */
75
+ designWidth?: number | ((size?: string | number | Input) => number)
76
+ /** 设计稿尺寸换算规则 */
77
+ deviceRatio?: TaroGeneral.TDeviceRatio
78
+ /** 平台 */
79
+ platform?: 'weapp' | 'h5' | string
80
+ /** 启用的能力 Scope 默认为 ['platform', 'size'] */
81
+ methods?: string[]
82
+ /** filter 回调函数,可 exclude 不处理的文件 */
83
+ exclude?: (fileName: string) => boolean
84
+ }
85
+
86
+ interface IBasePostcssOption {
87
+ autoprefixer?: TogglableOptions
88
+ pxtransform?: TogglableOptions<IPxTransformOption>
89
+ cssModules?: PostcssOption.cssModules
90
+ /** 插件 postcss-html-transform 相关配置, 一般启用了 @tarojs/plugin-html 插件才配置 */
91
+ htmltransform?: IHtmlTransformOption
92
+ [key: string]: any
93
+ }
94
+
95
+ export type IPostcssOption<T = 'h5' | 'harmony' | 'mini'> = T extends 'h5'
96
+ ? IBasePostcssOption & { url?: PostcssOption.url }
97
+ : IBasePostcssOption
98
+
99
+ export type Config = ViteConfig | WebpackConfig
100
+
101
+ export interface ICopyOptions {
102
+ patterns: {
103
+ from: string
104
+ to: string
105
+ ignore?: string[]
106
+ transform?: Func
107
+ watch?: boolean
108
+ }[]
109
+ options: {
110
+ ignore?: string[]
111
+ }
112
+ }
113
+
114
+ export interface ISassOptions {
115
+ /**
116
+ * 引入的全局 sass 文件,如果要引入多个文件,支持数组形式传入
117
+ */
118
+ resource?: string | string[]
119
+ /**
120
+ * 项目根目录的绝对地址(若为小程序云开发模板,则应该是client目录)
121
+ */
122
+ projectDirectory?: string
123
+ /**
124
+ * 全局 scss 变量,若 data 与 resource 中设置了同样的变量,则 data 的优先级高于 resource
125
+ */
126
+ data?: string
127
+ }
128
+
129
+ export interface ICompileOption {
130
+ exclude?: string[]
131
+ include?: string[]
132
+ }
133
+
134
+ export const enum TEMPLATE_TYPES {
135
+ WEAPP = '.wxml',
136
+ SWAN = '.swan',
137
+ ALIPAY = '.axml',
138
+ TT = '.ttml',
139
+ QUICKAPP = '.ux',
140
+ QQ = '.qml'
141
+ }
142
+
143
+ export const enum STYLE_TYPES {
144
+ WEAPP = '.wxss',
145
+ SWAN = '.css',
146
+ ALIPAY = '.acss',
147
+ TT = '.ttss',
148
+ QUICKAPP = '.css',
149
+ QQ = '.qss'
150
+ }
151
+
152
+ export const enum SCRIPT_TYPES {
153
+ WEAPP = '.js',
154
+ SWAN = '.js',
155
+ ALIPAY = '.js',
156
+ TT = '.js',
157
+ QUICKAPP = '.js',
158
+ QQ = '.js'
159
+ }
160
+
161
+ export const enum CONFIG_TYPES {
162
+ WEAPP = '.json',
163
+ SWAN = '.json',
164
+ ALIPAY = '.json',
165
+ TT = '.json',
166
+ QUICKAPP = '.json',
167
+ QQ = '.json'
168
+ }
169
+
170
+ export type IMINI_APP_FILE_TYPE = {
171
+ TEMPL: TEMPLATE_TYPES
172
+ STYLE: STYLE_TYPES
173
+ SCRIPT: SCRIPT_TYPES
174
+ CONFIG: CONFIG_TYPES
175
+ }
176
+
177
+ export type IMINI_APP_FILES = {
178
+ [key: string]: IMINI_APP_FILE_TYPE
179
+ }
@@ -0,0 +1,13 @@
1
+ type Tagname = string
2
+ type Attrs = Set<string>
3
+
4
+ export interface IComponentConfig {
5
+ includes: Set<string>
6
+ exclude: Set<string>
7
+ thirdPartyComponents: Map<Tagname, Attrs>
8
+ includeAll: boolean
9
+ }
10
+
11
+ export interface IModifyChainData {
12
+ componentConfig?: IComponentConfig
13
+ }
@@ -0,0 +1,11 @@
1
+ export { Current } from '@spcsn/taro-runtime'
2
+
3
+ export interface IFileType {
4
+ style: string
5
+ script: string
6
+ templ: string
7
+ config: string
8
+ xs?: string
9
+ }
10
+
11
+ export * from './config'