@tarojs/taro 4.0.0-canary.8 → 4.0.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 (75) hide show
  1. package/package.json +38 -17
  2. package/types/api/base/debug.d.ts +8 -8
  3. package/types/api/base/env.d.ts +2 -2
  4. package/types/api/base/index.d.ts +3 -3
  5. package/types/api/base/performance.d.ts +1 -1
  6. package/types/api/base/system.d.ts +6 -6
  7. package/types/api/base/weapp/app-event.d.ts +10 -10
  8. package/types/api/base/weapp/life-cycle.d.ts +1 -1
  9. package/types/api/canvas/index.d.ts +367 -63
  10. package/types/api/device/battery.d.ts +1 -1
  11. package/types/api/device/clipboard.d.ts +2 -2
  12. package/types/api/device/keyboard.d.ts +1 -1
  13. package/types/api/device/network.d.ts +3 -3
  14. package/types/api/device/phone.d.ts +1 -1
  15. package/types/api/device/screen.d.ts +2 -2
  16. package/types/api/files/index.d.ts +7 -7
  17. package/types/api/framework/index.d.ts +2 -2
  18. package/types/api/location/index.d.ts +4 -4
  19. package/types/api/media/audio.d.ts +21 -12
  20. package/types/api/media/background-audio.d.ts +1 -1
  21. package/types/api/media/image.d.ts +10 -10
  22. package/types/api/media/video.d.ts +11 -11
  23. package/types/api/navigate/index.d.ts +1 -1
  24. package/types/api/network/download.d.ts +5 -5
  25. package/types/api/network/request.d.ts +8 -8
  26. package/types/api/network/upload.d.ts +7 -7
  27. package/types/api/network/websocket.d.ts +8 -8
  28. package/types/api/open-api/account.d.ts +1 -1
  29. package/types/api/open-api/address.d.ts +13 -5
  30. package/types/api/open-api/authorize.d.ts +1 -1
  31. package/types/api/open-api/channels.d.ts +16 -0
  32. package/types/api/open-api/device-voip.d.ts +40 -0
  33. package/types/api/open-api/invoice.d.ts +1 -1
  34. package/types/api/open-api/login.d.ts +15 -2
  35. package/types/api/open-api/privacy.d.ts +8 -0
  36. package/types/api/open-api/settings.d.ts +3 -2
  37. package/types/api/open-api/sticker.d.ts +83 -0
  38. package/types/api/open-api/subscribe-message.d.ts +148 -6
  39. package/types/api/open-api/user-info.d.ts +6 -1
  40. package/types/api/qq/index.d.ts +306 -1
  41. package/types/api/route/index.d.ts +5 -5
  42. package/types/api/storage/index.d.ts +10 -10
  43. package/types/api/swan/bookshelf.d.ts +307 -0
  44. package/types/api/swan/download-package.d.ts +80 -0
  45. package/types/api/swan/index.d.ts +151 -0
  46. package/types/api/swan/pay.d.ts +139 -0
  47. package/types/api/taro.extend.d.ts +3 -2
  48. package/types/api/taro.hooks.d.ts +9 -9
  49. package/types/api/ui/animation.d.ts +32 -32
  50. package/types/api/ui/custom-component.d.ts +1 -1
  51. package/types/api/ui/fonts.d.ts +1 -1
  52. package/types/api/ui/interaction.d.ts +6 -6
  53. package/types/api/ui/menu.d.ts +1 -1
  54. package/types/api/ui/navigation-bar.d.ts +2 -2
  55. package/types/api/ui/pull-down-refresh.d.ts +2 -2
  56. package/types/api/ui/scroll.d.ts +1 -1
  57. package/types/api/ui/tab-bar.d.ts +8 -8
  58. package/types/api/ui/window.d.ts +2 -2
  59. package/types/api/wxml/index.d.ts +30 -24
  60. package/types/compile/compiler.d.ts +6 -2
  61. package/types/compile/config/h5.d.ts +9 -4
  62. package/types/compile/config/harmony.d.ts +43 -7
  63. package/types/compile/config/index.d.ts +1 -0
  64. package/types/compile/config/mini.d.ts +2 -16
  65. package/types/compile/config/project.d.ts +26 -8
  66. package/types/compile/config/rn.d.ts +22 -1
  67. package/types/compile/index.d.ts +8 -0
  68. package/types/compile/viteCompilerContext.d.ts +7 -3
  69. package/types/global.d.ts +2 -1
  70. package/types/index.d.ts +91 -46
  71. package/types/taro.api.d.ts +22 -14
  72. package/types/taro.component.d.ts +3 -0
  73. package/types/taro.config.d.ts +13 -4
  74. package/types/taro.lifecycle.d.ts +3 -0
  75. package/types/taro.runtime.d.ts +9 -0
@@ -18,12 +18,12 @@ declare module '../../index' {
18
18
  */
19
19
  interface IntersectionObserver {
20
20
  /** 停止监听。回调函数将不再触发
21
- * @supported weapp, tt, h5
21
+ * @supported weapp, tt, h5, harmony_hybrid
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, tt, h5
26
+ * @supported weapp, tt, h5, harmony_hybrid
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, tt, h5
36
+ * @supported weapp, tt, h5, harmony_hybrid
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, tt, h5
46
+ * @supported weapp, tt, h5, harmony_hybrid
47
47
  * @example
48
48
  * 下面的示例代码中,如果目标节点(用选择器 .target-class 指定)进入显示区域以下 100px 时,就会触发回调函数。
49
49
  *
@@ -66,19 +66,25 @@ declare module '../../index' {
66
66
  }
67
67
 
68
68
  namespace IntersectionObserver {
69
- /** 监听相交状态变化的回调函数 */
69
+ /** 监听相交状态变化的回调函数
70
+ * @description Harmony 找不到对应元素时,回调会返回一个 Error 对象
71
+ */
70
72
  type ObserveCallback = (result: ObserveCallbackResult) => void
71
- interface ObserveCallbackResult {
73
+ interface ObserveCallbackResult extends TaroGeneral.CallbackResult {
74
+ /** 错误信息,会在找不到对应元素时返回
75
+ * @supported harmony
76
+ */
77
+ errMsg?: string
72
78
  /** 目标边界 */
73
- boundingClientRect: BoundingClientRectResult
79
+ boundingClientRect?: BoundingClientRectResult
74
80
  /** 相交比例 */
75
- intersectionRatio: number
81
+ intersectionRatio?: number
76
82
  /** 相交区域的边界 */
77
- intersectionRect: IntersectionRectResult
83
+ intersectionRect?: IntersectionRectResult
78
84
  /** 参照区域的边界 */
79
- relativeRect: RelativeRectResult
85
+ relativeRect?: RelativeRectResult
80
86
  /** 相交检测时的时间戳 */
81
- time: number
87
+ time?: number
82
88
  }
83
89
  /** 参照区域的边界 */
84
90
  interface RelativeRectResult {
@@ -184,7 +190,7 @@ declare module '../../index' {
184
190
  */
185
191
  interface NodesRef {
186
192
  /** 添加节点的布局位置的查询请求。相对于显示区域,以像素为单位。其功能类似于 DOM 的 `getBoundingClientRect`。返回 `NodesRef` 对应的 `SelectorQuery`。
187
- * @supported weapp, h5, tt
193
+ * @supported weapp, h5, tt, harmony_hybrid
188
194
  * @example
189
195
  * ```tsx
190
196
  * Taro.createSelectorQuery().select('#the-id').boundingClientRect(function(rect){
@@ -220,7 +226,7 @@ declare module '../../index' {
220
226
  callback?: NodesRef.BoundingClientRectCallback,
221
227
  ): SelectorQuery
222
228
  /** 添加节点的 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) 的获取。
223
- * @supported weapp, h5, tt
229
+ * @supported weapp, h5, tt, harmony_hybrid
224
230
  * @example
225
231
  * ```tsx
226
232
  * Taro.createSelectorQuery().select('.the-video-class').context(function (res) {
@@ -237,7 +243,7 @@ declare module '../../index' {
237
243
  *
238
244
  * **注意**
239
245
  * computedStyle 的优先级高于 size,当同时在 computedStyle 里指定了 width/height 和传入了 size: true,则优先返回 computedStyle 获取到的 width/height。
240
- * @supported weapp, h5, tt
246
+ * @supported weapp, h5, tt, harmony_hybrid
241
247
  * @example
242
248
  * ```tsx
243
249
  * Taro.createSelectorQuery().select('#the-id').fields({
@@ -269,7 +275,7 @@ declare module '../../index' {
269
275
  callback?: NodesRef.FieldsCallback,
270
276
  ): SelectorQuery
271
277
  /** 获取 Node 节点实例。目前支持 [Canvas](/docs/components/canvas) 的获取。
272
- * @supported weapp, h5, tt
278
+ * @supported weapp, h5, tt, harmony_hybrid
273
279
  * @example
274
280
  * ```tsx
275
281
  * Taro.createSelectorQuery().select('.canvas').node(function(res){
@@ -283,7 +289,7 @@ declare module '../../index' {
283
289
  callback?: NodesRef.NodeCallback,
284
290
  ): SelectorQuery
285
291
  /** 添加节点的滚动位置查询请求。以像素为单位。节点必须是 `scroll-view` 或者 `viewport`,返回 `NodesRef` 对应的 `SelectorQuery`。
286
- * @supported weapp, h5, tt
292
+ * @supported weapp, h5, tt, harmony_hybrid
287
293
  * @example
288
294
  * ```tsx
289
295
  * Taro.createSelectorQuery().selectViewport().scrollOffset(function(res){
@@ -384,7 +390,7 @@ declare module '../../index' {
384
390
  */
385
391
  interface SelectorQuery {
386
392
  /** 执行所有的请求。请求结果按请求次序构成数组,在callback的第一个参数中返回。
387
- * @supported weapp, h5, tt
393
+ * @supported weapp, h5, tt, harmony_hybrid
388
394
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.exec.html
389
395
  */
390
396
  exec(
@@ -392,7 +398,7 @@ declare module '../../index' {
392
398
  callback?: (...args: any[]) => any,
393
399
  ): NodesRef
394
400
  /** 将选择器的选取范围更改为自定义组件 `component` 内。(初始时,选择器仅选取页面范围的节点,不会选取任何自定义组件中的节点)。
395
- * @supported weapp, h5, tt
401
+ * @supported weapp, h5, tt, harmony_hybrid
396
402
  * @example
397
403
  * ```tsx
398
404
  * Component({
@@ -423,7 +429,7 @@ declare module '../../index' {
423
429
  * - 后代选择器:.the-ancestor .the-descendant
424
430
  * - 跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant
425
431
  * - 多选择器的并集:#a-node, .some-other-nodes
426
- * @supported weapp, h5, tt
432
+ * @supported weapp, h5, tt, harmony_hybrid
427
433
  * @example
428
434
  * ```tsx
429
435
  * Taro.createSelectorQuery().select('#the-id').fields({
@@ -459,7 +465,7 @@ declare module '../../index' {
459
465
  * - 后代选择器:.the-ancestor .the-descendant
460
466
  * - 跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant
461
467
  * - 多选择器的并集:#a-node, .some-other-nodes
462
- * @supported weapp, h5, tt
468
+ * @supported weapp, h5, tt, harmony_hybrid
463
469
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.selectAll.html
464
470
  */
465
471
  selectAll(
@@ -467,7 +473,7 @@ declare module '../../index' {
467
473
  selector: string,
468
474
  ): NodesRef
469
475
  /** 选择显示区域。可用于获取显示区域的尺寸、滚动位置等信息。
470
- * @supported weapp, h5, tt
476
+ * @supported weapp, h5, tt, harmony_hybrid
471
477
  * @example
472
478
  * ```tsx
473
479
  * Taro.createSelectorQuery().selectViewport().scrollOffset(function (res) {
@@ -484,7 +490,7 @@ declare module '../../index' {
484
490
 
485
491
  interface TaroStatic {
486
492
  /** 返回一个 SelectorQuery 对象实例。在自定义组件或包含自定义组件的页面中,应使用 `this.createSelectorQuery()` 来代替。
487
- * @supported weapp, h5, tt, harmony
493
+ * @supported weapp, h5, tt, harmony, harmony_hybrid
488
494
  * @example
489
495
  * ```tsx
490
496
  * const query = Taro.createSelectorQuery()
@@ -500,7 +506,7 @@ declare module '../../index' {
500
506
  createSelectorQuery(): SelectorQuery
501
507
 
502
508
  /** 创建并返回一个 IntersectionObserver 对象实例。在自定义组件或包含自定义组件的页面中,应使用 `this.createIntersectionObserver([options])` 来代替。
503
- * @supported weapp, h5, tt, harmony
509
+ * @supported weapp, h5, tt, harmony, harmony_hybrid
504
510
  * @example
505
511
  * ```tsx
506
512
  * const observer = Taro.createIntersectionObserver(this, { thresholds: [0], observeAll: true })
@@ -515,7 +521,7 @@ declare module '../../index' {
515
521
  ): IntersectionObserver
516
522
 
517
523
  /** 创建并返回一个 MediaQueryObserver 对象实例。在自定义组件或包含自定义组件的页面中,应使用 `this.createMediaQueryObserver()` 来代替。
518
- * @supported h5
524
+ * @supported h5, harmony_hybrid
519
525
  * @example
520
526
  * ```tsx
521
527
  * let createMediaQueryObserver
@@ -1,9 +1,11 @@
1
1
  import type { swc } from '@tarojs/helper'
2
2
  import type Webpack from 'webpack'
3
3
 
4
- export type CompilerTypes = CompilerWebpackTypes | 'vite'
4
+ export type CompilerViteTypes = 'vite'
5
5
 
6
- export type CompilerWebpackTypes = 'webpack5' | 'webpack4'
6
+ export type CompilerWebpackTypes = 'webpack5'
7
+
8
+ export type CompilerTypes = CompilerWebpackTypes | CompilerViteTypes
7
9
 
8
10
  interface IPrebundle {
9
11
  enable?: boolean
@@ -23,6 +25,8 @@ interface ICompiler<T> {
23
25
  type: T
24
26
  prebundle?: IPrebundle
25
27
  vitePlugins?: any
28
+ /** 错误处理级别。可选值:0、1 */
29
+ errorLevel?: number
26
30
  }
27
31
 
28
32
  export type Compiler<T extends CompilerTypes = CompilerWebpackTypes> = T | ICompiler<T>
@@ -5,6 +5,7 @@ import type HtmlWebpackPlugin from 'html-webpack-plugin'
5
5
  import type { IOption, IPostcssOption, IUrlLoaderOption } from './util'
6
6
  import type { OutputOptions as RollupOutputOptions } from 'rollup'
7
7
  import type { Compiler, CompilerTypes, CompilerWebpackTypes } from '../compiler'
8
+ import type { OutputExt } from './project'
8
9
 
9
10
  export interface IH5RouterConfig {
10
11
  /** 配置路由模式 */
@@ -16,6 +17,8 @@ export interface IH5RouterConfig {
16
17
  lazyload?: boolean | ((pagename: string) => boolean)
17
18
  renamePagename?: (pagename: string) => string
18
19
  forcePath?: string
20
+ /** 加上这个参数,可以解决返回页面的时候白屏的问题,但是某些不支持 :has() 选择器的浏览器会有问题 */
21
+ enhanceAnimation?: boolean
19
22
  }
20
23
 
21
24
  export interface IH5Config <T extends CompilerTypes = CompilerWebpackTypes> {
@@ -40,7 +43,9 @@ export interface IH5Config <T extends CompilerTypes = CompilerWebpackTypes> {
40
43
  /** webpack 编译模式下,可用于修改、拓展 Webpack 的 output 选项,配置项参考[官方文档](https://webpack.js.org/configuration/output/)
41
44
  * vite 编译模式下,用于修改、扩展 rollup 的 output,目前仅适配 chunkFileNames 和 assetFileNames 两个配置,修改其他配置请使用 vite 插件进行修改。配置想参考[官方文档](https://rollupjs.org/configuration-options/)
42
45
  */
43
- output?: T extends 'vite' ? Pick<RollupOutputOptions, 'chunkFileNames' | 'assetFileNames' > : Webpack.Configuration['output']
46
+ output?: T extends 'vite'
47
+ ? Pick<RollupOutputOptions, 'chunkFileNames' | 'assetFileNames'> & OutputExt
48
+ : Webpack.Configuration['output']
44
49
 
45
50
  /** 路由相关的配置 */
46
51
  router?: IH5RouterConfig
@@ -100,7 +105,7 @@ export interface IH5Config <T extends CompilerTypes = CompilerWebpackTypes> {
100
105
  /** 配置需要额外的经由 Taro 预设的 postcss 编译的模块 */
101
106
  esnextModules?: string[]
102
107
 
103
- /** 用于控制在 H5 端是否使用兼容性组件库,详情请看 [React 兼容性组件库](https://taro-docs.jd.com/docs/next/h5#react-兼容性组件库)。(默认值:false) */
108
+ /** 用于控制在 H5 端是否使用兼容性组件库,详情请看 [React 兼容性组件库](https://taro-docs.jd.com/docs/h5#react-兼容性组件库)。(默认值:false) */
104
109
  useHtmlComponents?: boolean
105
110
 
106
111
  /** 用于控制在 H5 端是否使用旧版本适配器,旧版本采用全局注册组件,懒加载组件相关依赖;新版本适配器会自动注册相关组件,不再需要引入 @tarojs/components/loader 中的全局 defineCustomElements 方法。(默认值:false) */
@@ -120,7 +125,7 @@ export interface IH5Config <T extends CompilerTypes = CompilerWebpackTypes> {
120
125
  }
121
126
  /** 生成的代码是否要兼容旧版浏览器,值为 true 时,会去读取 package.json 的 browserslist 字段。只在 vite 编译模式下有效 */
122
127
  legacy?: T extends 'vite' ? boolean : undefined
123
-
124
- /** 使用的编译工具。可选值:webpack4、webpack5、vite */
128
+
129
+ /** 使用的编译工具。可选值:webpack5、vite */
125
130
  compiler?: Compiler<T>
126
131
  }
@@ -1,12 +1,17 @@
1
+ import type { OutputOptions as RollupOutputOptions } from 'rollup'
2
+ import type Webpack from 'webpack'
1
3
  import type Chain from 'webpack-chain'
2
4
 
3
5
  import type { IOption, IPostcssOption, IUrlLoaderOption } from './util'
4
- import type { Compiler, CompilerTypes, CompilerWebpackTypes } from '../compiler'
6
+ import type { CompilerTypes, CompilerWebpackTypes } from '../compiler'
7
+ import type { OutputExt } from './project'
5
8
 
6
- export interface IHarmonyConfig<T extends CompilerTypes = CompilerWebpackTypes> {
7
- /** Harmony 编译方式 */
8
- compiler?: Compiler
9
+ export interface IHarmonyRouterConfig {
10
+ /** 配置自定义路由 */
11
+ customRoutes?: IOption
12
+ }
9
13
 
14
+ export interface IHarmonyConfig<T extends CompilerTypes = 'vite'> {
10
15
  /** Harmony 项目地址 */
11
16
  projectPath: string
12
17
 
@@ -20,6 +25,24 @@ export interface IHarmonyConfig<T extends CompilerTypes = CompilerWebpackTypes>
20
25
  */
21
26
  name?: string
22
27
 
28
+ /** oh-package.json 配置 */
29
+ ohPackage?: {
30
+ dependencies?: { [name: string]: string }
31
+ devDependencies?: { [name: string]: string }
32
+ main?: string
33
+ [k: string]: any
34
+ }
35
+
36
+ /** ohpm-cli
37
+ * @default "~/Library/Huawei/ohpm/bin/ohpm"
38
+ */
39
+ ohpm?: string
40
+
41
+ /** 核心依赖前缀
42
+ * @description 用于告诉编译内容如何解析核心依赖,传入时将直接使用依赖前缀,同时不会为工程导入核心依赖
43
+ */
44
+ chorePackagePrefix?: string
45
+
23
46
  /** 用于告诉 Taro 编译器需要抽取的公共文件 */
24
47
  commonChunks?: string[] | ((commonChunks: string[]) => string[])
25
48
 
@@ -30,6 +53,16 @@ export interface IHarmonyConfig<T extends CompilerTypes = CompilerWebpackTypes>
30
53
  filter?: (filename: string) => boolean
31
54
  }
32
55
 
56
+ /** 用于配置半编译模式下的选项 */
57
+ compileModeSetting?: {
58
+ componentReplace?: {
59
+ [key: string]: {
60
+ current_init: string
61
+ dependency_define: string
62
+ }
63
+ }
64
+ }
65
+
33
66
  /** 用于控制是否生成 js、css 对应的 sourceMap (默认值:watch 模式下为 true,否则为 false) */
34
67
  enableSourceMap?: boolean
35
68
 
@@ -47,12 +80,15 @@ export interface IHarmonyConfig<T extends CompilerTypes = CompilerWebpackTypes>
47
80
  webpackChain?: (chain: Chain, webpack: typeof Webpack) => void
48
81
 
49
82
  /** webpack 编译模式下,可用于修改、拓展 Webpack 的 output 选项,配置项参考[官方文档](https://webpack.js.org/configuration/output/)
50
- * vite 编译模式下,用于修改、扩展 rollup 的 output,目前仅适配 chunkFileNames 和 assetFileNames 两个配置,修改其他配置请使用 vite 插件进行修改。配置想参考[官方文档](https://rollupjs.org/configuration-options/)
51
- */
83
+ * vite 编译模式下,用于修改、扩展 rollup 的 output,目前仅适配 chunkFileNames 和 assetFileNames 两个配置,修改其他配置请使用 vite 插件进行修改。配置想参考[官方文档](https://rollupjs.org/configuration-options/)
84
+ */
52
85
  output?: T extends 'vite'
53
- ? Pick<RollupOutputOptions, 'chunkFileNames'> & OutputExt
86
+ ? Pick<RollupOutputOptions, 'chunkFileNames'> & OutputExt
54
87
  : Webpack.Configuration['output'] & OutputExt
55
88
 
89
+ /** 路由相关的配置 */
90
+ router?: IHarmonyRouterConfig
91
+
56
92
  /** 配置 postcss 相关插件 */
57
93
  postcss?: IPostcssOption<'harmony'>
58
94
 
@@ -1,6 +1,7 @@
1
1
  export * from './h5'
2
2
  export * from './harmony'
3
3
  export * from './mini'
4
+ export * from './rn'
4
5
 
5
6
  export * from './manifest'
6
7
  export * from './project'
@@ -3,6 +3,7 @@ import type Chain from 'webpack-chain'
3
3
  import type { IOption, IPostcssOption, IUrlLoaderOption } from './util'
4
4
  import type { OutputOptions as RollupOutputOptions } from 'rollup'
5
5
  import type { Compiler, CompilerTypes, CompilerWebpackTypes } from '../compiler'
6
+ import type { OutputExt } from './project'
6
7
 
7
8
  interface Runtime {
8
9
  enableInnerHTML?: boolean
@@ -14,21 +15,6 @@ interface Runtime {
14
15
  enableMutationObserver?: boolean
15
16
  }
16
17
 
17
- interface OutputExt {
18
- /**
19
- * 编译前清空输出目录
20
- * @since Taro v3.6.9
21
- * @description
22
- * - 默认清空输出目录,可设置 clean: false 不清空
23
- * - 可设置 clean: { keep: ['project.config.json'] } 保留指定文件
24
- * - 注意 clean.keep 不支持函数
25
- */
26
- clean?: boolean | {
27
- /** 保留指定文件不删除 */
28
- keep?: Array<string | RegExp> | string | RegExp
29
- }
30
- }
31
-
32
18
  export interface IMiniAppConfig<T extends CompilerTypes = CompilerWebpackTypes> {
33
19
  /** 用于控制是否生成 js、css 对应的 sourceMap (默认值:watch 模式下为 true,否则为 false) */
34
20
  enableSourceMap?: boolean
@@ -113,7 +99,7 @@ export interface IMiniAppConfig<T extends CompilerTypes = CompilerWebpackTypes>
113
99
  /** 插件内部使用 */
114
100
  runtime?: Runtime
115
101
 
116
- /** 使用的编译工具。可选值:webpack4、webpack5、vite */
102
+ /** 使用的编译工具。可选值:webpack5、vite */
117
103
  compiler?: Compiler<T>
118
104
 
119
105
  /** 体验式功能 */
@@ -1,6 +1,7 @@
1
1
  import type Webpack from 'webpack'
2
2
  import type Chain from 'webpack-chain'
3
3
  import type { Input } from 'postcss'
4
+ import type { AppConfig } from '../../index'
4
5
  import type { Compiler, CompilerTypes, CompilerWebpackTypes } from '../compiler'
5
6
  import type { IModifyChainData } from '../hooks'
6
7
  import type { ICopyOptions, IOption, ISassOptions, TogglableOptions } from './util'
@@ -115,7 +116,7 @@ export interface IProjectBaseConfig {
115
116
  jsMinimizer?: 'terser' | 'esbuild'
116
117
 
117
118
  /** 配置 CSS 压缩工具 (默认 csso) */
118
- cssMinimizer?: 'csso' | 'esbuild' | 'parcelCss'
119
+ cssMinimizer?: 'csso' | 'esbuild' | 'lightningcss'
119
120
 
120
121
  /** 配置 csso 工具以压缩 CSS 代码 */
121
122
  csso?: TogglableOptions
@@ -139,11 +140,11 @@ export interface IProjectBaseConfig {
139
140
  /** 模板循环次数 */
140
141
  baseLevel?: number
141
142
 
142
- /** 使用的开发框架。可选值:react、preact、nerv、vue、vue3 */
143
- framework?: 'react' | 'preact' | 'nerv' | 'vue' | 'vue3'
143
+ /** 使用的开发框架。可选值:react、preact、vue3 */
144
+ framework?: 'react' | 'preact' | 'solid' | 'vue3'
144
145
  frameworkExts?: string[]
145
146
 
146
- /** 使用的编译工具。可选值:webpack4、webpack5 */
147
+ /** 使用的编译工具。可选值:webpack5 */
147
148
  compiler?: Compiler
148
149
 
149
150
  /** Webpack5 持久化缓存配置。具体配置请参考 [WebpackConfig.cache](https://webpack.js.org/configuration/cache/#cache) */
@@ -177,6 +178,8 @@ export interface IProjectBaseConfig {
177
178
 
178
179
  onWebpackChainReady?: (webpackChain: Chain) => Promise<any>
179
180
 
181
+ modifyAppConfig?: (appConfig: AppConfig) => Promise<any>
182
+
180
183
  /**
181
184
  * 编译中修改 webpack 配置,在这个钩子中,你可以对 webpackChain 作出想要的调整,等同于配置 [`webpackChain`](./config-detail#miniwebpackchain)
182
185
  */
@@ -274,7 +277,7 @@ export interface IProjectConfig<T extends CompilerTypes = CompilerWebpackTypes>
274
277
  jsMinimizer?: 'terser' | 'esbuild'
275
278
 
276
279
  /** 配置 CSS 压缩工具 (默认 csso) */
277
- cssMinimizer?: 'csso' | 'esbuild' | 'parcelCss'
280
+ cssMinimizer?: 'csso' | 'esbuild' | 'lightningcss'
278
281
 
279
282
  /** 配置 csso 工具以压缩 CSS 代码 */
280
283
  csso?: TogglableOptions
@@ -293,8 +296,8 @@ export interface IProjectConfig<T extends CompilerTypes = CompilerWebpackTypes>
293
296
  /** 一个 preset 是一系列 Taro 插件的集合,配置语法同 plugins */
294
297
  presets?: PluginItem[]
295
298
 
296
- /** 使用的开发框架。可选值:react、preact、nervvuevue3 */
297
- framework?: 'react' | 'preact' | 'nerv' | 'vue' | 'vue3'
299
+ /** 使用的开发框架。可选值:react、preact、solidvue3none */
300
+ framework?: 'react' | 'preact' | 'solid' | 'vue3' | 'none'
298
301
 
299
302
  /** Webpack5 持久化缓存配置。具体配置请参考 [WebpackConfig.cache](https://webpack.js.org/configuration/cache/#cache) */
300
303
  cache?: ICache
@@ -302,7 +305,7 @@ export interface IProjectConfig<T extends CompilerTypes = CompilerWebpackTypes>
302
305
  /** 控制 Taro 编译日志的输出方式 */
303
306
  logger?: ILogger
304
307
 
305
- /** 使用的编译工具。可选值:webpack4、webpack5、vite */
308
+ /** 使用的编译工具。可选值:webpack5、vite */
306
309
  compiler?: Compiler<T>
307
310
 
308
311
  /** 专属于 H5 的配置 */
@@ -318,3 +321,18 @@ export interface IProjectConfig<T extends CompilerTypes = CompilerWebpackTypes>
318
321
 
319
322
  [key: string]: any
320
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
+ }
@@ -2,6 +2,7 @@ import type Webpack from 'webpack'
2
2
  import type Chain from 'webpack-chain'
3
3
  import type webpackDevServer from 'webpack-dev-server'
4
4
  import type HtmlWebpackPlugin from 'html-webpack-plugin'
5
+ import type { RollupOptions } from 'rollup'
5
6
  import type { IOption, IPostcssOption } from './util'
6
7
 
7
8
  export interface IRNConfig {
@@ -20,7 +21,7 @@ export interface IRNConfig {
20
21
  /** [less](https://lesscss.org/usage/#less-options) 相关配置 */
21
22
  less?: IOption
22
23
 
23
- /** [stylus](https://github.com/NervJS/taro/blob/next/packages/taro-rn-style-transformer/README.md#rnstylus) 相关配置 */
24
+ /** [stylus](https://github.com/NervJS/taro/blob/main/packages/taro-rn-style-transformer/README.md#rnstylus) 相关配置 */
24
25
  stylus?: IOption
25
26
 
26
27
  /** 配置 postcss 相关插件 */
@@ -61,4 +62,24 @@ export interface IRNConfig {
61
62
 
62
63
  /** 设计稿尺寸换算规则 */
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
+ }
64
85
  }
@@ -1,3 +1,11 @@
1
1
  export { Current } from '@tarojs/runtime'
2
2
 
3
+ export interface IFileType {
4
+ style: string
5
+ script: string
6
+ templ: string
7
+ config: string
8
+ xs?: string
9
+ }
10
+
3
11
  export * from './config'
@@ -1,9 +1,11 @@
1
1
  import type { RecursiveTemplate, UnRecursiveTemplate } from '@tarojs/shared/dist/template'
2
+
2
3
  import type { PluginContext } from 'rollup'
3
- import type { AppConfig, PageConfig } from '../index'
4
4
  import type { IMiniFilesConfig, IH5Config, IHarmonyConfig, IMiniAppConfig } from './config'
5
5
  import type { IProjectConfig } from './config/project'
6
6
  import type { IComponentConfig } from './hooks'
7
+ import type { IFileType } from './index'
8
+ import type { AppConfig, PageConfig } from '../index'
7
9
 
8
10
  export interface ViteNativeCompMeta {
9
11
  name: string
@@ -13,6 +15,7 @@ export interface ViteNativeCompMeta {
13
15
  isNative: true
14
16
  templatePath: string
15
17
  cssPath?: string
18
+ isPackage?: boolean
16
19
  }
17
20
 
18
21
  export interface ViteFileType {
@@ -41,7 +44,6 @@ export interface VitePageMeta {
41
44
  cssPath?: string
42
45
  }
43
46
 
44
-
45
47
  export interface ViteH5BuildConfig extends CommonBuildConfig, IH5Config<'vite'> {
46
48
  entryFileName?: string
47
49
  runtimePath?: string | string[]
@@ -53,6 +55,7 @@ export interface ViteHarmonyBuildConfig extends CommonBuildConfig, IHarmonyConfi
53
55
  useJSON5?: boolean
54
56
  blended?: boolean
55
57
  runtimePath?: string | string[]
58
+ isPure?: boolean
56
59
  taroComponentsPath: string
57
60
  }
58
61
 
@@ -132,10 +135,11 @@ export interface ViteHarmonyCompilerContext extends ViteCompilerContext<ViteHarm
132
135
  nativeExt: string[]
133
136
  fileType: ViteFileType
134
137
  commonChunks: string[]
138
+ extraComponents: string[]
135
139
  nativeComponents : Map<string, ViteNativeCompMeta>
136
140
  getCommonChunks: () => string[]
137
141
  modifyHarmonyConfig: (config: Partial<AppConfig>) => void
138
- modifyHostPackageDep: (outDir: string, deps?: Record<string, string>, devDeps?: Record<string, string>) => void
142
+ modifyHostPackage: (deps?: Record<string, string>, devDeps?: Record<string, string>) => Exclude<IHarmonyConfig['ohPackage'], void>
139
143
  collectNativeComponents: (meta: ViteAppMeta | VitePageMeta | ViteNativeCompMeta) => void
140
144
  getScriptPath: (filePath: string) => string
141
145
  getStylePath: (filePath: string) => string
package/types/global.d.ts CHANGED
@@ -419,7 +419,8 @@ declare namespace TaroGeneral {
419
419
  WEB = 'WEB',
420
420
  RN = 'RN',
421
421
  HARMONY = 'HARMONY',
422
- QUICKAPP = 'QUICKAPP'
422
+ QUICKAPP = 'QUICKAPP',
423
+ HARMONYHYBRID = 'HARMONYHYBRID'
423
424
  }
424
425
 
425
426
  type TDeviceRatio = Record<string, number>