@spcsn/taro 0.1.2 → 1.0.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/README.md +13 -6
- package/dist/index.js +223 -1
- package/dist/index.js.map +1 -1
- package/package.json +17 -48
- package/types/api/ad/index.d.ts +3 -6
- package/types/api/base/debug.d.ts +8 -8
- package/types/api/base/env.d.ts +3 -3
- package/types/api/base/index.d.ts +3 -3
- package/types/api/base/performance.d.ts +5 -5
- package/types/api/base/system.d.ts +8 -16
- package/types/api/base/update.d.ts +6 -6
- package/types/api/base/weapp/app-event.d.ts +12 -12
- package/types/api/base/weapp/life-cycle.d.ts +1 -1
- package/types/api/canvas/index.d.ts +71 -72
- package/types/api/data-analysis/index.d.ts +1 -1
- package/types/api/device/accelerometer.d.ts +4 -4
- package/types/api/device/accessibility.d.ts +1 -1
- package/types/api/device/battery.d.ts +2 -2
- package/types/api/device/bluetooth-ble.d.ts +14 -14
- package/types/api/device/bluetooth-peripheral.d.ts +15 -15
- package/types/api/device/bluetooth.d.ts +11 -11
- package/types/api/device/calendar.d.ts +2 -2
- package/types/api/device/clipboard.d.ts +2 -4
- package/types/api/device/compass.d.ts +4 -4
- package/types/api/device/gyroscope.d.ts +4 -4
- package/types/api/device/iBeacon.d.ts +7 -7
- package/types/api/device/keyboard.d.ts +3 -3
- package/types/api/device/memory.d.ts +2 -2
- package/types/api/device/motion.d.ts +4 -4
- package/types/api/device/network.d.ts +5 -20
- package/types/api/device/nfc.d.ts +17 -17
- package/types/api/device/phone.d.ts +1 -1
- package/types/api/device/scan.d.ts +1 -1
- package/types/api/device/screen.d.ts +6 -6
- package/types/api/device/sms.d.ts +1 -1
- package/types/api/device/vibrate.d.ts +2 -2
- package/types/api/device/wifi.d.ts +10 -10
- package/types/api/ext/index.d.ts +2 -2
- package/types/api/files/index.d.ts +46 -46
- package/types/api/framework/index.d.ts +2 -2
- package/types/api/location/index.d.ts +38 -45
- package/types/api/media/audio.d.ts +30 -30
- package/types/api/media/background-audio.d.ts +1 -1
- package/types/api/media/camera.d.ts +12 -25
- package/types/api/media/image.d.ts +8 -13
- package/types/api/media/map.d.ts +15 -15
- package/types/api/media/recorder.d.ts +11 -11
- package/types/api/media/video.d.ts +19 -21
- package/types/api/navigate/index.d.ts +2 -2
- package/types/api/network/download.d.ts +7 -8
- package/types/api/network/request.d.ts +14 -33
- package/types/api/network/upload.d.ts +7 -9
- package/types/api/network/websocket.d.ts +14 -14
- package/types/api/open-api/account.d.ts +1 -1
- package/types/api/open-api/address.d.ts +5 -5
- package/types/api/open-api/authorize.d.ts +1 -1
- package/types/api/open-api/login.d.ts +5 -5
- package/types/api/open-api/settings.d.ts +2 -2
- package/types/api/open-api/subscribe-message.d.ts +15 -15
- package/types/api/open-api/user-info.d.ts +2 -3
- package/types/api/payment/index.d.ts +1 -1
- package/types/api/route/index.d.ts +5 -8
- package/types/api/share/index.d.ts +3 -3
- package/types/api/storage/background-fetch.d.ts +6 -9
- package/types/api/storage/index.d.ts +11 -11
- package/types/api/taro.extend.d.ts +7 -24
- package/types/api/taro.hooks.d.ts +8 -33
- package/types/api/ui/animation.d.ts +33 -36
- package/types/api/ui/background.d.ts +2 -4
- package/types/api/ui/custom-component.d.ts +1 -1
- package/types/api/ui/fonts.d.ts +1 -10
- package/types/api/ui/interaction.d.ts +6 -6
- package/types/api/ui/menu.d.ts +1 -1
- package/types/api/ui/navigation-bar.d.ts +5 -7
- package/types/api/ui/pull-down-refresh.d.ts +2 -3
- package/types/api/ui/scroll.d.ts +3 -4
- package/types/api/ui/tab-bar.d.ts +8 -8
- package/types/api/ui/window.d.ts +2 -2
- package/types/api/wxml/index.d.ts +19 -23
- package/types/compile/compiler.d.ts +4 -10
- package/types/compile/config/index.d.ts +0 -3
- package/types/compile/config/mini.d.ts +17 -39
- package/types/compile/config/plugin.d.ts +14 -4
- package/types/compile/config/project.d.ts +23 -61
- package/types/compile/config/util.d.ts +18 -73
- package/types/compile/index.d.ts +16 -1
- package/types/compile/viteCompilerContext.d.ts +18 -52
- package/types/global.d.ts +1 -12
- package/types/index.d.ts +0 -11
- package/types/taro.api.d.ts +0 -9
- package/types/taro.component.d.ts +0 -2
- package/types/taro.config.d.ts +0 -120
- package/types/taro.runtime.d.ts +7 -3
- package/types/api/alipay/index.d.ts +0 -69
- package/types/api/qq/index.d.ts +0 -354
- package/types/api/swan/bookshelf.d.ts +0 -307
- package/types/api/swan/download-package.d.ts +0 -80
- package/types/api/swan/index.d.ts +0 -251
- package/types/api/swan/pay.d.ts +0 -139
- package/types/compile/config/h5.d.ts +0 -134
- package/types/compile/config/harmony.d.ts +0 -118
- package/types/compile/config/rn.d.ts +0 -85
|
@@ -18,12 +18,12 @@ declare module '../../index' {
|
|
|
18
18
|
*/
|
|
19
19
|
interface IntersectionObserver {
|
|
20
20
|
/** 停止监听。回调函数将不再触发
|
|
21
|
-
* @supported weapp
|
|
21
|
+
* @supported weapp
|
|
22
22
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/IntersectionObserver.disconnect.html
|
|
23
23
|
*/
|
|
24
24
|
disconnect(): void
|
|
25
25
|
/** 指定目标节点并开始监听相交状态变化情况
|
|
26
|
-
* @supported weapp
|
|
26
|
+
* @supported weapp
|
|
27
27
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/IntersectionObserver.observe.html
|
|
28
28
|
*/
|
|
29
29
|
observe(
|
|
@@ -33,7 +33,7 @@ declare module '../../index' {
|
|
|
33
33
|
callback: IntersectionObserver.ObserveCallback,
|
|
34
34
|
): void
|
|
35
35
|
/** 使用选择器指定一个节点,作为参照区域之一。
|
|
36
|
-
* @supported weapp
|
|
36
|
+
* @supported weapp
|
|
37
37
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/IntersectionObserver.relativeTo.html
|
|
38
38
|
*/
|
|
39
39
|
relativeTo(
|
|
@@ -43,7 +43,7 @@ declare module '../../index' {
|
|
|
43
43
|
margins?: IntersectionObserver.RelativeToMargins,
|
|
44
44
|
): IntersectionObserver
|
|
45
45
|
/** 指定页面显示区域作为参照区域之一
|
|
46
|
-
* @supported weapp
|
|
46
|
+
* @supported weapp
|
|
47
47
|
* @example
|
|
48
48
|
* 下面的示例代码中,如果目标节点(用选择器 .target-class 指定)进入显示区域以下 100px 时,就会触发回调函数。
|
|
49
49
|
*
|
|
@@ -66,14 +66,10 @@ declare module '../../index' {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
namespace IntersectionObserver {
|
|
69
|
-
/** 监听相交状态变化的回调函数
|
|
70
|
-
* @description Harmony 找不到对应元素时,回调会返回一个 Error 对象
|
|
71
|
-
*/
|
|
69
|
+
/** 监听相交状态变化的回调函数 */
|
|
72
70
|
type ObserveCallback = (result: ObserveCallbackResult) => void
|
|
73
71
|
interface ObserveCallbackResult extends TaroGeneral.CallbackResult {
|
|
74
|
-
/** 错误信息,会在找不到对应元素时返回
|
|
75
|
-
* @supported harmony
|
|
76
|
-
*/
|
|
72
|
+
/** 错误信息,会在找不到对应元素时返回 */
|
|
77
73
|
errMsg?: string
|
|
78
74
|
/** 目标边界 */
|
|
79
75
|
boundingClientRect?: BoundingClientRectResult
|
|
@@ -190,7 +186,7 @@ declare module '../../index' {
|
|
|
190
186
|
*/
|
|
191
187
|
interface NodesRef {
|
|
192
188
|
/** 添加节点的布局位置的查询请求。相对于显示区域,以像素为单位。其功能类似于 DOM 的 `getBoundingClientRect`。返回 `NodesRef` 对应的 `SelectorQuery`。
|
|
193
|
-
* @supported weapp
|
|
189
|
+
* @supported weapp
|
|
194
190
|
* @example
|
|
195
191
|
* ```tsx
|
|
196
192
|
* Taro.createSelectorQuery().select('#the-id').boundingClientRect(function(rect){
|
|
@@ -226,7 +222,7 @@ declare module '../../index' {
|
|
|
226
222
|
callback?: NodesRef.BoundingClientRectCallback,
|
|
227
223
|
): SelectorQuery
|
|
228
224
|
/** 添加节点的 Context 对象查询请求。目前支持 [VideoContext](/docs/apis/media/video/VideoContext)、[CanvasContext](/docs/apis/canvas/CanvasContext)、[LivePlayerContext](/docs/apis/media/live/LivePlayerContext)、[EditorContext](/docs/apis/media/editor/EditorContext)和 [MapContext](/docs/apis/media/map/MapContext) 的获取。
|
|
229
|
-
* @supported weapp
|
|
225
|
+
* @supported weapp
|
|
230
226
|
* @example
|
|
231
227
|
* ```tsx
|
|
232
228
|
* Taro.createSelectorQuery().select('.the-video-class').context(function (res) {
|
|
@@ -243,7 +239,7 @@ declare module '../../index' {
|
|
|
243
239
|
*
|
|
244
240
|
* **注意**
|
|
245
241
|
* computedStyle 的优先级高于 size,当同时在 computedStyle 里指定了 width/height 和传入了 size: true,则优先返回 computedStyle 获取到的 width/height。
|
|
246
|
-
* @supported weapp
|
|
242
|
+
* @supported weapp
|
|
247
243
|
* @example
|
|
248
244
|
* ```tsx
|
|
249
245
|
* Taro.createSelectorQuery().select('#the-id').fields({
|
|
@@ -275,7 +271,7 @@ declare module '../../index' {
|
|
|
275
271
|
callback?: NodesRef.FieldsCallback,
|
|
276
272
|
): SelectorQuery
|
|
277
273
|
/** 获取 Node 节点实例。目前支持 [Canvas](/docs/components/canvas) 的获取。
|
|
278
|
-
* @supported weapp
|
|
274
|
+
* @supported weapp
|
|
279
275
|
* @example
|
|
280
276
|
* ```tsx
|
|
281
277
|
* Taro.createSelectorQuery().select('.canvas').node(function(res){
|
|
@@ -289,7 +285,7 @@ declare module '../../index' {
|
|
|
289
285
|
callback?: NodesRef.NodeCallback,
|
|
290
286
|
): SelectorQuery
|
|
291
287
|
/** 添加节点的滚动位置查询请求。以像素为单位。节点必须是 `scroll-view` 或者 `viewport`,返回 `NodesRef` 对应的 `SelectorQuery`。
|
|
292
|
-
* @supported weapp
|
|
288
|
+
* @supported weapp
|
|
293
289
|
* @example
|
|
294
290
|
* ```tsx
|
|
295
291
|
* Taro.createSelectorQuery().selectViewport().scrollOffset(function(res){
|
|
@@ -390,7 +386,7 @@ declare module '../../index' {
|
|
|
390
386
|
*/
|
|
391
387
|
interface SelectorQuery {
|
|
392
388
|
/** 执行所有的请求。请求结果按请求次序构成数组,在callback的第一个参数中返回。
|
|
393
|
-
* @supported weapp
|
|
389
|
+
* @supported weapp
|
|
394
390
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.exec.html
|
|
395
391
|
*/
|
|
396
392
|
exec(
|
|
@@ -398,7 +394,7 @@ declare module '../../index' {
|
|
|
398
394
|
callback?: (...args: any[]) => any,
|
|
399
395
|
): NodesRef
|
|
400
396
|
/** 将选择器的选取范围更改为自定义组件 `component` 内。(初始时,选择器仅选取页面范围的节点,不会选取任何自定义组件中的节点)。
|
|
401
|
-
* @supported weapp
|
|
397
|
+
* @supported weapp
|
|
402
398
|
* @example
|
|
403
399
|
* ```tsx
|
|
404
400
|
* Component({
|
|
@@ -429,7 +425,7 @@ declare module '../../index' {
|
|
|
429
425
|
* - 后代选择器:.the-ancestor .the-descendant
|
|
430
426
|
* - 跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant
|
|
431
427
|
* - 多选择器的并集:#a-node, .some-other-nodes
|
|
432
|
-
* @supported weapp
|
|
428
|
+
* @supported weapp
|
|
433
429
|
* @example
|
|
434
430
|
* ```tsx
|
|
435
431
|
* Taro.createSelectorQuery().select('#the-id').fields({
|
|
@@ -465,7 +461,7 @@ declare module '../../index' {
|
|
|
465
461
|
* - 后代选择器:.the-ancestor .the-descendant
|
|
466
462
|
* - 跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant
|
|
467
463
|
* - 多选择器的并集:#a-node, .some-other-nodes
|
|
468
|
-
* @supported weapp
|
|
464
|
+
* @supported weapp
|
|
469
465
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.selectAll.html
|
|
470
466
|
*/
|
|
471
467
|
selectAll(
|
|
@@ -473,7 +469,7 @@ declare module '../../index' {
|
|
|
473
469
|
selector: string,
|
|
474
470
|
): NodesRef
|
|
475
471
|
/** 选择显示区域。可用于获取显示区域的尺寸、滚动位置等信息。
|
|
476
|
-
* @supported weapp
|
|
472
|
+
* @supported weapp
|
|
477
473
|
* @example
|
|
478
474
|
* ```tsx
|
|
479
475
|
* Taro.createSelectorQuery().selectViewport().scrollOffset(function (res) {
|
|
@@ -490,7 +486,7 @@ declare module '../../index' {
|
|
|
490
486
|
|
|
491
487
|
interface TaroStatic {
|
|
492
488
|
/** 返回一个 SelectorQuery 对象实例。在自定义组件或包含自定义组件的页面中,应使用 `this.createSelectorQuery()` 来代替。
|
|
493
|
-
* @supported weapp
|
|
489
|
+
* @supported weapp
|
|
494
490
|
* @example
|
|
495
491
|
* ```tsx
|
|
496
492
|
* const query = Taro.createSelectorQuery()
|
|
@@ -506,7 +502,7 @@ declare module '../../index' {
|
|
|
506
502
|
createSelectorQuery(): SelectorQuery
|
|
507
503
|
|
|
508
504
|
/** 创建并返回一个 IntersectionObserver 对象实例。在自定义组件或包含自定义组件的页面中,应使用 `this.createIntersectionObserver([options])` 来代替。
|
|
509
|
-
* @supported weapp
|
|
505
|
+
* @supported weapp
|
|
510
506
|
* @example
|
|
511
507
|
* ```tsx
|
|
512
508
|
* const observer = Taro.createIntersectionObserver(this, { thresholds: [0], observeAll: true })
|
|
@@ -521,7 +517,7 @@ declare module '../../index' {
|
|
|
521
517
|
): IntersectionObserver
|
|
522
518
|
|
|
523
519
|
/** 创建并返回一个 MediaQueryObserver 对象实例。在自定义组件或包含自定义组件的页面中,应使用 `this.createMediaQueryObserver()` 来代替。
|
|
524
|
-
* @supported
|
|
520
|
+
* @supported weapp
|
|
525
521
|
* @example
|
|
526
522
|
* ```tsx
|
|
527
523
|
* let createMediaQueryObserver
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import type Webpack from 'webpack'
|
|
1
|
+
export type SwcConfig = Record<string, any>
|
|
3
2
|
|
|
4
3
|
export type CompilerViteTypes = 'vite'
|
|
5
4
|
|
|
6
|
-
export type
|
|
7
|
-
|
|
8
|
-
export type CompilerTypes = CompilerWebpackTypes | CompilerViteTypes
|
|
5
|
+
export type CompilerTypes = CompilerViteTypes
|
|
9
6
|
|
|
10
7
|
interface IPrebundle {
|
|
11
8
|
enable?: boolean
|
|
@@ -15,10 +12,7 @@ interface IPrebundle {
|
|
|
15
12
|
include?: string[]
|
|
16
13
|
exclude?: string[]
|
|
17
14
|
esbuild?: Record<string, any>
|
|
18
|
-
swc?:
|
|
19
|
-
webpack?: Webpack.Configuration & {
|
|
20
|
-
provide?: any[]
|
|
21
|
-
}
|
|
15
|
+
swc?: SwcConfig
|
|
22
16
|
}
|
|
23
17
|
|
|
24
18
|
interface ICompiler<T> {
|
|
@@ -29,4 +23,4 @@ interface ICompiler<T> {
|
|
|
29
23
|
errorLevel?: number
|
|
30
24
|
}
|
|
31
25
|
|
|
32
|
-
export type Compiler<T extends CompilerTypes =
|
|
26
|
+
export type Compiler<T extends CompilerTypes = CompilerViteTypes> = T | ICompiler<T>
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type Chain from 'webpack-chain'
|
|
3
|
-
import type { IOption, IPostcssOption, IUrlLoaderOption } from './util'
|
|
4
|
-
import type { OutputOptions as RollupOutputOptions } from 'rollup'
|
|
5
|
-
import type { Compiler, CompilerTypes, CompilerWebpackTypes } from '../compiler'
|
|
1
|
+
import type { Compiler, CompilerTypes, CompilerViteTypes } from '../compiler'
|
|
6
2
|
import type { OutputExt } from './project'
|
|
3
|
+
import type { IOption, IPostcssOption, IUrlLoaderOption } from './util'
|
|
4
|
+
|
|
5
|
+
type ViteOutputOptions = {
|
|
6
|
+
chunkFileNames?: string | ((chunkInfo: any) => string)
|
|
7
|
+
}
|
|
7
8
|
|
|
8
9
|
interface Runtime {
|
|
9
10
|
enableSizeAPIs?: boolean
|
|
@@ -13,11 +14,11 @@ interface Runtime {
|
|
|
13
14
|
enableMutationObserver?: boolean
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
export interface IMiniAppConfig<T extends CompilerTypes =
|
|
17
|
+
export interface IMiniAppConfig<T extends CompilerTypes = CompilerViteTypes> {
|
|
17
18
|
/** 用于控制是否生成 js、css 对应的 sourceMap (默认值:watch 模式下为 true,否则为 false) */
|
|
18
19
|
enableSourceMap?: boolean
|
|
19
20
|
|
|
20
|
-
/**
|
|
21
|
+
/** sourcemap 类型配置 */
|
|
21
22
|
sourceMapType?: string
|
|
22
23
|
|
|
23
24
|
/** 指定 React 框架相关的代码是否使用开发环境(未压缩)代码,默认使用生产环境(压缩后)代码 */
|
|
@@ -32,47 +33,24 @@ export interface IMiniAppConfig<T extends CompilerTypes = CompilerWebpackTypes>
|
|
|
32
33
|
collapseWhitespace?: boolean
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
* @param chain [webpackChain](https://github.com/neutrinojs/webpack-chain) 对象
|
|
38
|
-
* @param webpack webpack 实例
|
|
39
|
-
* @param PARSE_AST_TYPE 小程序编译时的文件类型集合
|
|
40
|
-
* @returns
|
|
41
|
-
*/
|
|
42
|
-
webpackChain?: (chain: Chain, webpack: typeof Webpack, PARSE_AST_TYPE: any) => void
|
|
43
|
-
|
|
44
|
-
/** webpack 编译模式下,可用于修改、拓展 Webpack 的 output 选项,配置项参考[官方文档](https://webpack.js.org/configuration/output/)
|
|
45
|
-
* vite 编译模式下,用于修改、扩展 rollup 的 output,目前仅适配 chunkFileNames 和 assetFileNames 两个配置,修改其他配置请使用 vite 插件进行修改。配置想参考[官方文档](https://rollupjs.org/configuration-options/)
|
|
46
|
-
*/
|
|
47
|
-
output?: T extends 'vite'
|
|
48
|
-
? Pick<RollupOutputOptions, 'chunkFileNames'> & OutputExt
|
|
49
|
-
: Webpack.Configuration['output'] & OutputExt
|
|
36
|
+
/** Vite 小程序输出配置,目前仅适配 chunkFileNames。 */
|
|
37
|
+
output?: Pick<ViteOutputOptions, 'chunkFileNames'> & OutputExt
|
|
50
38
|
|
|
51
39
|
/** 配置 postcss 相关插件 */
|
|
52
40
|
postcss?: IPostcssOption<'mini'>
|
|
53
41
|
|
|
54
|
-
/**
|
|
42
|
+
/** CSS 处理的附加配置 */
|
|
55
43
|
cssLoaderOption?: IOption
|
|
56
|
-
|
|
57
|
-
/** [sass-loader](https://github.com/webpack-contrib/sass-loader) 的附加配置 */
|
|
58
|
-
sassLoaderOption?: IOption
|
|
59
|
-
|
|
60
|
-
/** [less-loader](https://github.com/webpack-contrib/less-loader) 的附加配置 */
|
|
61
|
-
lessLoaderOption?: IOption
|
|
62
|
-
|
|
63
|
-
/** [stylus-loader](https://github.com/shama/stylus-loader) 的附加配置 */
|
|
64
|
-
stylusLoaderOption?: IOption
|
|
65
|
-
|
|
66
|
-
/** 针对 mp4 | webm | ogg | mp3 | wav | flac | aac 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
|
|
44
|
+
/** 针对 mp4 | webm | ogg | mp3 | wav | flac | aac 文件的资源处理配置 */
|
|
67
45
|
mediaUrlLoaderOption?: IUrlLoaderOption
|
|
68
46
|
|
|
69
|
-
/** 针对 woff | woff2 | eot | ttf | otf
|
|
47
|
+
/** 针对 woff | woff2 | eot | ttf | otf 文件的资源处理配置 */
|
|
70
48
|
fontUrlLoaderOption?: IUrlLoaderOption
|
|
71
49
|
|
|
72
|
-
/** 针对 png | jpg | jpeg | gif | bpm | svg
|
|
50
|
+
/** 针对 png | jpg | jpeg | gif | bpm | svg 文件的资源处理配置 */
|
|
73
51
|
imageUrlLoaderOption?: IUrlLoaderOption
|
|
74
52
|
|
|
75
|
-
/**
|
|
53
|
+
/** 样式抽取的附加配置 */
|
|
76
54
|
miniCssExtractPluginOption?: IOption
|
|
77
55
|
|
|
78
56
|
/** 用于告诉 Taro 编译器需要抽取的公共文件 */
|
|
@@ -91,14 +69,14 @@ export interface IMiniAppConfig<T extends CompilerTypes = CompilerWebpackTypes>
|
|
|
91
69
|
compile?: {
|
|
92
70
|
exclude?: any[]
|
|
93
71
|
include?: any[]
|
|
94
|
-
/** 对应
|
|
72
|
+
/** 对应 Vite 小程序编译链路的文件过滤配置。 */
|
|
95
73
|
filter?: (filename: string) => boolean
|
|
96
74
|
}
|
|
97
75
|
|
|
98
76
|
/** 插件内部使用 */
|
|
99
77
|
runtime?: Runtime
|
|
100
78
|
|
|
101
|
-
/** 使用的编译工具。可选值:
|
|
79
|
+
/** 使用的编译工具。可选值:vite */
|
|
102
80
|
compiler?: Compiler<T>
|
|
103
81
|
|
|
104
82
|
/** 体验式功能 */
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
type RollupCustomPluginOptions = Record<string, any>
|
|
2
|
+
|
|
3
|
+
type RollupResolvedId = {
|
|
4
|
+
id: string
|
|
5
|
+
external?: boolean | 'absolute' | 'relative'
|
|
6
|
+
meta?: Record<string, any>
|
|
7
|
+
moduleSideEffects?: boolean | 'no-treeshake' | null
|
|
8
|
+
syntheticNamedExports?: boolean | string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type RollupResolveIdResult = string | false | null | RollupResolvedId
|
|
2
12
|
|
|
3
13
|
interface IRollupPluginResolveIdOptions {
|
|
4
14
|
assertions?: Record<string, string>
|
|
5
|
-
custom?:
|
|
15
|
+
custom?: RollupCustomPluginOptions
|
|
6
16
|
isEntry?: boolean
|
|
7
17
|
skipSelf?: boolean
|
|
8
18
|
}
|
|
@@ -11,7 +21,7 @@ export type TRollupResolveMethod = (
|
|
|
11
21
|
source: string,
|
|
12
22
|
importer?: string,
|
|
13
23
|
options?: IRollupPluginResolveIdOptions
|
|
14
|
-
) => Promise<
|
|
24
|
+
) => Promise<RollupResolvedId | null>
|
|
15
25
|
|
|
16
26
|
export interface ILoaderMeta {
|
|
17
27
|
importFrameworkStatement: string
|
|
@@ -30,5 +40,5 @@ export interface ILoaderMeta {
|
|
|
30
40
|
options?: IRollupPluginResolveIdOptions
|
|
31
41
|
name?: string
|
|
32
42
|
resolve: TRollupResolveMethod
|
|
33
|
-
}) => Promise<
|
|
43
|
+
}) => Promise<RollupResolveIdResult> | RollupResolveIdResult
|
|
34
44
|
}
|
|
@@ -1,36 +1,26 @@
|
|
|
1
|
-
import type Webpack from 'webpack'
|
|
2
|
-
import type Chain from 'webpack-chain'
|
|
3
|
-
import type { Input } from 'postcss'
|
|
4
1
|
import type { AppConfig } from '../../index'
|
|
5
|
-
import type { Compiler, CompilerTypes,
|
|
2
|
+
import type { Compiler, CompilerTypes, CompilerViteTypes } from '../compiler'
|
|
6
3
|
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
4
|
import type { IMiniAppConfig, IMiniFilesConfig } from './mini'
|
|
11
|
-
import type {
|
|
5
|
+
import type { ICopyOptions, IOption, TogglableOptions } from './util'
|
|
6
|
+
|
|
7
|
+
type PostcssInput = string | number
|
|
12
8
|
|
|
13
9
|
export type PluginItem<T = object> = string | [string, T] | [string, () => T | Promise<T>]
|
|
14
10
|
|
|
15
11
|
interface ICache {
|
|
16
12
|
/**
|
|
17
|
-
*
|
|
18
|
-
* @description ```
|
|
19
|
-
* 值为 false 时:开发模式下 WebpackConfig.cache.type = 'memory',而生产模式下 WebpackConfig.cache = false;
|
|
20
|
-
* 值为 true 时:开发模式和生产模式下均为 WebpackConfig.cache.type = 'filesystem'
|
|
21
|
-
* ```
|
|
13
|
+
* 是否开启持久化缓存。
|
|
22
14
|
*/
|
|
23
15
|
enable?: boolean
|
|
24
16
|
|
|
25
17
|
/**
|
|
26
18
|
* 当依赖的文件或该文件的依赖改变时,使缓存失效。
|
|
27
|
-
* @description 详详情请参考 [WebpackConfig.cache.buildDependencies](https://webpack.js.org/configuration/cache/#cachebuilddependencies)。
|
|
28
19
|
*/
|
|
29
20
|
buildDependencies?: Record<string, any>
|
|
30
21
|
|
|
31
22
|
/**
|
|
32
|
-
*
|
|
33
|
-
* @description 详情请参考 [WebpackConfig.cache.name](https://webpack.js.org/configuration/cache/#cachename)
|
|
23
|
+
* 缓存子目录的名称。
|
|
34
24
|
*/
|
|
35
25
|
name?: string
|
|
36
26
|
}
|
|
@@ -38,7 +28,7 @@ interface ICache {
|
|
|
38
28
|
interface ILogger {
|
|
39
29
|
/** 是否简化输出日志 (默认值 true)*/
|
|
40
30
|
quiet: boolean
|
|
41
|
-
/**
|
|
31
|
+
/** 是否输出构建统计信息 (默认值 false) */
|
|
42
32
|
stats: boolean
|
|
43
33
|
}
|
|
44
34
|
|
|
@@ -52,7 +42,7 @@ export interface IProjectBaseConfig {
|
|
|
52
42
|
date?: string
|
|
53
43
|
|
|
54
44
|
/** 设计稿尺寸 */
|
|
55
|
-
designWidth?: number | ((size?:
|
|
45
|
+
designWidth?: number | ((size?: PostcssInput) => number)
|
|
56
46
|
|
|
57
47
|
/** 设计稿尺寸换算规则 */
|
|
58
48
|
deviceRatio?: TaroGeneral.TDeviceRatio
|
|
@@ -112,8 +102,8 @@ export interface IProjectBaseConfig {
|
|
|
112
102
|
/** 用于把文件从源码目录直接拷贝到编译后的生产目录 */
|
|
113
103
|
copy?: ICopyOptions
|
|
114
104
|
|
|
115
|
-
/** 配置 JS 压缩工具 (默认
|
|
116
|
-
jsMinimizer?: 'terser' | 'esbuild'
|
|
105
|
+
/** 配置 JS 压缩工具 (默认 oxc),显式配置时可在 development/watch 构建中强制启用压缩 */
|
|
106
|
+
jsMinimizer?: 'oxc' | 'terser' | 'esbuild'
|
|
117
107
|
|
|
118
108
|
/** 配置 CSS 压缩工具 (默认 csso) */
|
|
119
109
|
cssMinimizer?: 'csso' | 'esbuild' | 'lightningcss'
|
|
@@ -127,10 +117,6 @@ export interface IProjectBaseConfig {
|
|
|
127
117
|
esbuild?: Record<'minify', TogglableOptions>
|
|
128
118
|
|
|
129
119
|
uglify?: TogglableOptions
|
|
130
|
-
|
|
131
|
-
/** 用于控制对 scss 代码的编译行为,默认使用 dart-sass,具体配置可以参考 https://www.npmjs.com/package/sass */
|
|
132
|
-
sass?: ISassOptions
|
|
133
|
-
|
|
134
120
|
/** 配置 Taro 插件 */
|
|
135
121
|
plugins?: PluginItem[]
|
|
136
122
|
|
|
@@ -140,14 +126,14 @@ export interface IProjectBaseConfig {
|
|
|
140
126
|
/** 模板循环次数 */
|
|
141
127
|
baseLevel?: number
|
|
142
128
|
|
|
143
|
-
/** 使用的开发框架。可选值:react
|
|
144
|
-
framework?: 'react'
|
|
129
|
+
/** 使用的开发框架。可选值:react */
|
|
130
|
+
framework?: 'react'
|
|
145
131
|
frameworkExts?: string[]
|
|
146
132
|
|
|
147
|
-
/** 使用的编译工具。可选值:
|
|
133
|
+
/** 使用的编译工具。可选值:vite */
|
|
148
134
|
compiler?: Compiler
|
|
149
135
|
|
|
150
|
-
/**
|
|
136
|
+
/** 持久化缓存配置 */
|
|
151
137
|
cache?: ICache
|
|
152
138
|
|
|
153
139
|
/** 控制 Taro 编译日志的输出方式 */
|
|
@@ -169,22 +155,10 @@ export interface IProjectBaseConfig {
|
|
|
169
155
|
/**
|
|
170
156
|
* 编译结束(保存代码每次编译结束后都会触发)
|
|
171
157
|
*/
|
|
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>
|
|
158
|
+
onBuildFinish?: (res: { error: unknown; stats: unknown; isWatch: boolean }) => Promise<any>
|
|
180
159
|
|
|
181
160
|
modifyAppConfig?: (appConfig: AppConfig) => Promise<any>
|
|
182
161
|
|
|
183
|
-
/**
|
|
184
|
-
* 编译中修改 webpack 配置,在这个钩子中,你可以对 webpackChain 作出想要的调整,等同于配置 [`webpackChain`](./config-detail#miniwebpackchain)
|
|
185
|
-
*/
|
|
186
|
-
modifyWebpackChain?: (chain: Chain, webpack: typeof Webpack, data: IModifyChainData) => Promise<any>
|
|
187
|
-
|
|
188
162
|
/**
|
|
189
163
|
* 编译中修改 vite 配置
|
|
190
164
|
*/
|
|
@@ -207,7 +181,7 @@ export interface IProjectBaseConfig {
|
|
|
207
181
|
}
|
|
208
182
|
|
|
209
183
|
/** 暴露出来给 config/index 使用的配置类型,参考 https://github.com/NervJS/taro-doctor/blob/main/assets/config_schema.json */
|
|
210
|
-
export interface IProjectConfig<T extends CompilerTypes =
|
|
184
|
+
export interface IProjectConfig<T extends CompilerTypes = CompilerViteTypes> {
|
|
211
185
|
/** 项目名称 */
|
|
212
186
|
projectName?: string
|
|
213
187
|
|
|
@@ -215,7 +189,7 @@ export interface IProjectConfig<T extends CompilerTypes = CompilerWebpackTypes>
|
|
|
215
189
|
date?: string
|
|
216
190
|
|
|
217
191
|
/** 设计稿尺寸 */
|
|
218
|
-
designWidth?: number | ((size?:
|
|
192
|
+
designWidth?: number | ((size?: PostcssInput) => number)
|
|
219
193
|
|
|
220
194
|
/** 设计稿尺寸换算规则 */
|
|
221
195
|
deviceRatio?: TaroGeneral.TDeviceRatio
|
|
@@ -273,8 +247,8 @@ export interface IProjectConfig<T extends CompilerTypes = CompilerWebpackTypes>
|
|
|
273
247
|
/** 用于把文件从源码目录直接拷贝到编译后的生产目录 */
|
|
274
248
|
copy?: ICopyOptions
|
|
275
249
|
|
|
276
|
-
/** 配置 JS 压缩工具 (默认
|
|
277
|
-
jsMinimizer?: 'terser' | 'esbuild'
|
|
250
|
+
/** 配置 JS 压缩工具 (默认 oxc),显式配置时可在 development/watch 构建中强制启用压缩 */
|
|
251
|
+
jsMinimizer?: 'oxc' | 'terser' | 'esbuild'
|
|
278
252
|
|
|
279
253
|
/** 配置 CSS 压缩工具 (默认 csso) */
|
|
280
254
|
cssMinimizer?: 'csso' | 'esbuild' | 'lightningcss'
|
|
@@ -286,39 +260,27 @@ export interface IProjectConfig<T extends CompilerTypes = CompilerWebpackTypes>
|
|
|
286
260
|
terser?: TogglableOptions
|
|
287
261
|
|
|
288
262
|
esbuild?: Record<'minify', TogglableOptions>
|
|
289
|
-
|
|
290
|
-
/** 用于控制对 scss 代码的编译行为,默认使用 dart-sass,具体配置可以参考 https://www.npmjs.com/package/sass */
|
|
291
|
-
sass?: ISassOptions
|
|
292
|
-
|
|
293
263
|
/** 配置 Taro 插件 */
|
|
294
264
|
plugins?: PluginItem[]
|
|
295
265
|
|
|
296
266
|
/** 一个 preset 是一系列 Taro 插件的集合,配置语法同 plugins */
|
|
297
267
|
presets?: PluginItem[]
|
|
298
268
|
|
|
299
|
-
/** 使用的开发框架。可选值:react
|
|
300
|
-
framework?: 'react'
|
|
269
|
+
/** 使用的开发框架。可选值:react */
|
|
270
|
+
framework?: 'react'
|
|
301
271
|
|
|
302
|
-
/**
|
|
272
|
+
/** 持久化缓存配置 */
|
|
303
273
|
cache?: ICache
|
|
304
274
|
|
|
305
275
|
/** 控制 Taro 编译日志的输出方式 */
|
|
306
276
|
logger?: ILogger
|
|
307
277
|
|
|
308
|
-
/** 使用的编译工具。可选值:
|
|
278
|
+
/** 使用的编译工具。可选值:vite */
|
|
309
279
|
compiler?: Compiler<T>
|
|
310
280
|
|
|
311
|
-
/** 专属于 H5 的配置 */
|
|
312
|
-
h5?: IH5Config<T>
|
|
313
|
-
|
|
314
281
|
/** 专属于小程序的配置 */
|
|
315
282
|
mini?: IMiniAppConfig<T>
|
|
316
283
|
|
|
317
|
-
/** 专属于 RN 的配置 */
|
|
318
|
-
rn?: IRNConfig
|
|
319
|
-
|
|
320
|
-
harmony?: IHarmonyConfig<T>
|
|
321
|
-
|
|
322
284
|
[key: string]: any
|
|
323
285
|
}
|
|
324
286
|
|