@tarojs/taro 4.0.1 → 4.0.3-alpha.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 (38) hide show
  1. package/package.json +40 -16
  2. package/types/api/base/env.d.ts +1 -1
  3. package/types/api/base/system.d.ts +2 -2
  4. package/types/api/base/weapp/app-event.d.ts +4 -4
  5. package/types/api/device/accelerometer.d.ts +4 -4
  6. package/types/api/device/battery.d.ts +2 -2
  7. package/types/api/device/clipboard.d.ts +14 -14
  8. package/types/api/device/keyboard.d.ts +2 -2
  9. package/types/api/device/network.d.ts +3 -3
  10. package/types/api/device/phone.d.ts +1 -1
  11. package/types/api/device/screen.d.ts +2 -2
  12. package/types/api/device/vibrate.d.ts +2 -2
  13. package/types/api/media/image.d.ts +2 -2
  14. package/types/api/network/request.d.ts +1 -1
  15. package/types/api/route/index.d.ts +5 -5
  16. package/types/api/storage/index.d.ts +4 -4
  17. package/types/api/swan/pay.d.ts +4 -4
  18. package/types/api/taro.extend.d.ts +5 -3
  19. package/types/api/ui/animation.d.ts +1 -1
  20. package/types/api/ui/interaction.d.ts +3 -3
  21. package/types/api/ui/navigation-bar.d.ts +5 -5
  22. package/types/api/ui/pull-down-refresh.d.ts +2 -2
  23. package/types/api/ui/scroll.d.ts +1 -1
  24. package/types/api/ui/tab-bar.d.ts +7 -7
  25. package/types/api/wxml/index.d.ts +15 -9
  26. package/types/compile/compiler.d.ts +9 -4
  27. package/types/compile/config/h5.d.ts +23 -10
  28. package/types/compile/config/harmony.d.ts +118 -0
  29. package/types/compile/config/index.d.ts +1 -0
  30. package/types/compile/config/mini.d.ts +29 -24
  31. package/types/compile/config/plugin.d.ts +34 -0
  32. package/types/compile/config/project.d.ts +49 -21
  33. package/types/compile/config/util.d.ts +21 -7
  34. package/types/compile/index.d.ts +8 -0
  35. package/types/compile/viteCompilerContext.d.ts +159 -0
  36. package/types/index.d.ts +0 -1
  37. package/types/taro.component.d.ts +1 -0
  38. package/types/taro.config.d.ts +5 -0
@@ -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'
@@ -0,0 +1,159 @@
1
+ import type { RecursiveTemplate, UnRecursiveTemplate } from '@tarojs/shared/dist/template'
2
+
3
+ import type { PluginContext } from 'rollup'
4
+ import type { IMiniFilesConfig, IH5Config, IHarmonyConfig, IMiniAppConfig } from './config'
5
+ import type { IProjectConfig } from './config/project'
6
+ import type { IComponentConfig } from './hooks'
7
+ import type { IFileType } from './index'
8
+ import type { AppConfig, PageConfig } from '../index'
9
+
10
+ export interface ViteNativeCompMeta {
11
+ name: string
12
+ scriptPath: string
13
+ configPath: string
14
+ config: PageConfig
15
+ isNative: true
16
+ templatePath: string
17
+ cssPath?: string
18
+ isPackage?: boolean
19
+ }
20
+
21
+ export interface ViteFileType {
22
+ config: string
23
+ script: string
24
+ templ: string
25
+ style: string
26
+ xs?: string
27
+ }
28
+
29
+ export interface ViteAppMeta {
30
+ name: string
31
+ scriptPath: string
32
+ configPath: string
33
+ config: AppConfig
34
+ isNative: false
35
+ }
36
+
37
+ export interface VitePageMeta {
38
+ name: string
39
+ scriptPath: string
40
+ configPath: string
41
+ config: PageConfig
42
+ isNative: boolean
43
+ templatePath?: string
44
+ cssPath?: string
45
+ }
46
+
47
+ export interface ViteH5BuildConfig extends CommonBuildConfig, IH5Config<'vite'> {
48
+ entryFileName?: string
49
+ runtimePath?: string | string[]
50
+ }
51
+
52
+ export interface ViteHarmonyBuildConfig extends CommonBuildConfig, IHarmonyConfig {
53
+ fileType: IFileType
54
+ useETS?: boolean
55
+ useJSON5?: boolean
56
+ blended?: boolean
57
+ runtimePath?: string | string[]
58
+ isPure?: boolean
59
+ taroComponentsPath: string
60
+ }
61
+
62
+ export interface CommonBuildConfig extends IProjectConfig<'vite'> {
63
+ entry: {
64
+ app: string | string[]
65
+ }
66
+ mode: 'production' | 'development' | 'none'
67
+ buildAdapter: string // weapp | swan | alipay | tt | qq | jd | h5
68
+ platformType: string // mini | web
69
+ /** special mode */
70
+ isBuildNativeComp?: boolean
71
+ /** hooks */
72
+ onCompilerMake: (compilation) => Promise<any>
73
+ onParseCreateElement: (nodeName, componentConfig) => Promise<any>
74
+ }
75
+
76
+
77
+ export interface ViteMiniBuildConfig extends CommonBuildConfig, IMiniAppConfig<'vite'> {
78
+ isBuildPlugin: boolean
79
+ isSupportRecursive: boolean
80
+ isSupportXS: boolean
81
+ nodeModulesPath: string
82
+ fileType: ViteFileType
83
+ globalObject: string
84
+ template: RecursiveTemplate | UnRecursiveTemplate
85
+ runtimePath?: string | string[]
86
+ taroComponentsPath?: string
87
+ blended?: boolean
88
+ hot?: boolean
89
+ injectOptions?: {
90
+ include?: Record<string, string | string[]>
91
+ exclude?: string[]
92
+ }
93
+ /** hooks */
94
+ modifyComponentConfig: (componentConfig: IComponentConfig, config: Partial<ViteMiniBuildConfig>) => Promise<any>
95
+ }
96
+
97
+ export interface ViteCompilerContext<T> {
98
+ cwd: string
99
+ sourceDir: string
100
+ taroConfig: T
101
+ rawTaroConfig: T
102
+ frameworkExts: string[]
103
+ app: ViteAppMeta
104
+ pages: VitePageMeta[]
105
+ components?: VitePageMeta[]
106
+ loaderMeta: any
107
+ logger
108
+ filesConfig: IMiniFilesConfig
109
+ configFileList: string[]
110
+ compilePage: (pageName: string) => VitePageMeta
111
+ watchConfigFile: (rollupCtx: PluginContext) => void
112
+ getAppScriptPath: () => string
113
+ getApp: () => ViteAppMeta
114
+ getPages: () => VitePageMeta[]
115
+ isApp: (id: string) => boolean
116
+ isPage: (id: string) => boolean
117
+ isComponent: (id: string) => boolean
118
+ isNativePageORComponent: (templatePath: string) => boolean
119
+ getPageById: (id: string) => VitePageMeta| undefined
120
+ getComponentById: (id: string) => VitePageMeta| undefined
121
+ getConfigFilePath: (filePath: string) => string
122
+ getTargetFilePath: (filePath: string, targetExtName: string) => string
123
+ }
124
+
125
+ export interface ViteH5CompilerContext extends ViteCompilerContext<ViteH5BuildConfig> {
126
+ getBrowserslist: () => void
127
+ routerMeta: {
128
+ routerCreator: string
129
+ getRoutesConfig: (pageName?: string) => string
130
+ }
131
+ browserslist: string[]
132
+ }
133
+
134
+ export interface ViteHarmonyCompilerContext extends ViteCompilerContext<ViteHarmonyBuildConfig> {
135
+ nativeExt: string[]
136
+ fileType: ViteFileType
137
+ commonChunks: string[]
138
+ extraComponents: string[]
139
+ nativeComponents : Map<string, ViteNativeCompMeta>
140
+ getCommonChunks: () => string[]
141
+ modifyHarmonyConfig: (config: Partial<AppConfig>) => void
142
+ modifyHostPackage: (deps?: Record<string, string>, devDeps?: Record<string, string>) => Exclude<IHarmonyConfig['ohPackage'], void>
143
+ collectNativeComponents: (meta: ViteAppMeta | VitePageMeta | ViteNativeCompMeta) => void
144
+ getScriptPath: (filePath: string) => string
145
+ getStylePath: (filePath: string) => string
146
+ getConfigPath: (filePath: string) => string
147
+ }
148
+
149
+ export interface ViteMiniCompilerContext extends ViteCompilerContext<ViteMiniBuildConfig> {
150
+ fileType: ViteFileType
151
+ commonChunks: string[]
152
+ nativeComponents : Map<string, ViteNativeCompMeta>
153
+ getCommonChunks: () => string[]
154
+ collectNativeComponents: (meta: ViteAppMeta | VitePageMeta | ViteNativeCompMeta) => void
155
+ getScriptPath: (filePath: string) => string
156
+ getTemplatePath: (filePath: string) => string
157
+ getStylePath: (filePath: string) => string
158
+ getConfigPath: (filePath: string) => string
159
+ }
package/types/index.d.ts CHANGED
@@ -187,7 +187,6 @@ export as namespace Taro
187
187
  declare const Taro: Taro.TaroStatic
188
188
 
189
189
  declare namespace Taro {
190
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
191
190
  interface TaroStatic {}
192
191
  }
193
192
  declare global {
@@ -19,6 +19,7 @@ declare module './index' {
19
19
  shareTicket: string | undefined
20
20
  scene: number | undefined
21
21
  exitState?: any
22
+ $taroPath?: string
22
23
  }
23
24
 
24
25
  interface Show {
@@ -32,6 +32,11 @@ declare module './index' {
32
32
  * @default: "#ffffff"
33
33
  */
34
34
  backgroundColor?: string
35
+ /** 页面容器背景色, HexColor
36
+ * @see: https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/skyline/custom-route.html#%E8%AE%BE%E7%BD%AE%E9%A1%B5%E9%9D%A2%E9%80%8F%E6%98%8E
37
+ * @default: "#ffffff"
38
+ */
39
+ backgroundColorContent?: string
35
40
  /** 下拉背景字体、loading 图的样式,仅支持 dark/light
36
41
  * 当 app.json 中配置 darkmode 为 true 时可通过变量的形式配置
37
42
  * @see: https://developers.weixin.qq.com/miniprogram/dev/framework/ability/darkmode.html