@tarojs/taro 4.0.0-beta.9 → 4.0.0-beta.90

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": "4.0.0-beta.9",
3
+ "version": "4.0.0-beta.90",
4
4
  "description": "Taro framework",
5
5
  "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro#readme",
6
6
  "main": "index.js",
@@ -21,17 +21,17 @@
21
21
  "author": "O2Team",
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@tarojs/api": "4.0.0-beta.9"
24
+ "@tarojs/api": "4.0.0-beta.90"
25
25
  },
26
26
  "devDependencies": {
27
- "@tarojs/helper": "4.0.0-beta.9",
28
- "@tarojs/shared": "4.0.0-beta.9",
29
- "@tarojs/runtime": "4.0.0-beta.9"
27
+ "@tarojs/helper": "4.0.0-beta.90",
28
+ "@tarojs/shared": "4.0.0-beta.90",
29
+ "@tarojs/runtime": "4.0.0-beta.90"
30
30
  },
31
31
  "peerDependencies": {
32
- "@tarojs/shared": "~4.0.0-beta.9",
33
- "@tarojs/helper": "~4.0.0-beta.9",
34
- "@tarojs/runtime": "~4.0.0-beta.9"
32
+ "@tarojs/shared": "~4.0.0-beta.90",
33
+ "@tarojs/helper": "~4.0.0-beta.90",
34
+ "@tarojs/runtime": "~4.0.0-beta.90"
35
35
  },
36
36
  "peerDependenciesMeta": {
37
37
  "@types/react": {
@@ -9,7 +9,7 @@ declare module '../../index' {
9
9
  env: {
10
10
  [key: string]: string | undefined
11
11
  /** 框架 */
12
- FRAMEWORK: 'react' | 'preact' | 'nerv' | 'vue' | 'vue3'
12
+ FRAMEWORK: 'react' | 'preact' | 'solid' | 'nerv' | 'vue' | 'vue3'
13
13
  /** Taro 环境变量 */
14
14
  TARO_ENV: 'weapp' | 'h5' | 'rn' | 'swan' | 'alipay' | 'tt' | 'qq' | 'jd' | 'quickapp'
15
15
  /** 文件系统中的用户目录路径 (本地路径) */
@@ -191,7 +191,7 @@ declare module '../../index' {
191
191
  src: string
192
192
  }
193
193
  interface Option {
194
- data: AssetsObjectType[]
194
+ data: AssetsObject[]
195
195
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
196
196
  complete?: (res: TaroGeneral.CallbackResult) => void
197
197
  /** 接口调用失败的回调函数 */
@@ -315,10 +315,10 @@ declare module '../../index' {
315
315
  '4:5'
316
316
  /** 宽高比为5比4 */
317
317
  '5:4'
318
- /** 宽高比为619 */
319
- '6:19'
320
- /** 宽高比为196 */
321
- '19:6'
318
+ /** 宽高比为916 */
319
+ '9:16'
320
+ /** 宽高比为169 */
321
+ '16:9'
322
322
  }
323
323
  }
324
324
 
@@ -256,7 +256,7 @@ declare module '../../index' {
256
256
  ): T
257
257
 
258
258
  /** Taro.getStorageInfo 的同步版本
259
- * @supported weapp, alipay, swan, jd, qq, tt, h5, rn, harmony_hybrid
259
+ * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
260
260
  * @example
261
261
  * ```tsx
262
262
  * try {
@@ -238,7 +238,7 @@ declare module '../../index' {
238
238
  showActionSheet(option: showActionSheet.Option): Promise<showActionSheet.SuccessCallbackResult>
239
239
 
240
240
  /** 隐藏消息提示框
241
- * @supported weapp, h5, rn, tt, harmony, harmony_hybrid
241
+ * @supported weapp, h5, rn, tt, harmony_hybrid
242
242
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.hideToast.html
243
243
  */
244
244
  hideToast(option?: hideToast.Option): void
@@ -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 {
@@ -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
  /** 配置路由模式 */
@@ -40,7 +41,9 @@ export interface IH5Config <T extends CompilerTypes = CompilerWebpackTypes> {
40
41
  /** webpack 编译模式下,可用于修改、拓展 Webpack 的 output 选项,配置项参考[官方文档](https://webpack.js.org/configuration/output/)
41
42
  * vite 编译模式下,用于修改、扩展 rollup 的 output,目前仅适配 chunkFileNames 和 assetFileNames 两个配置,修改其他配置请使用 vite 插件进行修改。配置想参考[官方文档](https://rollupjs.org/configuration-options/)
42
43
  */
43
- output?: T extends 'vite' ? Pick<RollupOutputOptions, 'chunkFileNames' | 'assetFileNames' > : Webpack.Configuration['output']
44
+ output?: T extends 'vite'
45
+ ? Pick<RollupOutputOptions, 'chunkFileNames' | 'assetFileNames'> & OutputExt
46
+ : Webpack.Configuration['output']
44
47
 
45
48
  /** 路由相关的配置 */
46
49
  router?: IH5RouterConfig
@@ -100,7 +103,7 @@ export interface IH5Config <T extends CompilerTypes = CompilerWebpackTypes> {
100
103
  /** 配置需要额外的经由 Taro 预设的 postcss 编译的模块 */
101
104
  esnextModules?: string[]
102
105
 
103
- /** 用于控制在 H5 端是否使用兼容性组件库,详情请看 [React 兼容性组件库](https://taro-docs.jd.com/docs/next/h5#react-兼容性组件库)。(默认值:false) */
106
+ /** 用于控制在 H5 端是否使用兼容性组件库,详情请看 [React 兼容性组件库](https://taro-docs.jd.com/docs/h5#react-兼容性组件库)。(默认值:false) */
104
107
  useHtmlComponents?: boolean
105
108
 
106
109
  /** 用于控制在 H5 端是否使用旧版本适配器,旧版本采用全局注册组件,懒加载组件相关依赖;新版本适配器会自动注册相关组件,不再需要引入 @tarojs/components/loader 中的全局 defineCustomElements 方法。(默认值:false) */
@@ -120,7 +123,7 @@ export interface IH5Config <T extends CompilerTypes = CompilerWebpackTypes> {
120
123
  }
121
124
  /** 生成的代码是否要兼容旧版浏览器,值为 true 时,会去读取 package.json 的 browserslist 字段。只在 vite 编译模式下有效 */
122
125
  legacy?: T extends 'vite' ? boolean : undefined
123
-
126
+
124
127
  /** 使用的编译工具。可选值:webpack4、webpack5、vite */
125
128
  compiler?: Compiler<T>
126
129
  }
@@ -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
 
@@ -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
@@ -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'
@@ -140,7 +141,7 @@ export interface IProjectBaseConfig {
140
141
  baseLevel?: number
141
142
 
142
143
  /** 使用的开发框架。可选值:react、preact、nerv、vue、vue3 */
143
- framework?: 'react' | 'preact' | 'nerv' | 'vue' | 'vue3'
144
+ framework?: 'react' | 'preact' | 'solid' | 'nerv' | 'vue' | 'vue3'
144
145
  frameworkExts?: string[]
145
146
 
146
147
  /** 使用的编译工具。可选值:webpack4、webpack5 */
@@ -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
  */
@@ -294,7 +297,7 @@ export interface IProjectConfig<T extends CompilerTypes = CompilerWebpackTypes>
294
297
  presets?: PluginItem[]
295
298
 
296
299
  /** 使用的开发框架。可选值:react、preact、nerv、vue、vue3 */
297
- framework?: 'react' | 'preact' | 'nerv' | 'vue' | 'vue3'
300
+ framework?: 'react' | 'preact' | 'solid' | 'nerv' | 'vue' | 'vue3'
298
301
 
299
302
  /** Webpack5 持久化缓存配置。具体配置请参考 [WebpackConfig.cache](https://webpack.js.org/configuration/cache/#cache) */
300
303
  cache?: ICache
@@ -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
+ }
@@ -20,7 +20,7 @@ export interface IRNConfig {
20
20
  /** [less](https://lesscss.org/usage/#less-options) 相关配置 */
21
21
  less?: IOption
22
22
 
23
- /** [stylus](https://github.com/NervJS/taro/blob/next/packages/taro-rn-style-transformer/README.md#rnstylus) 相关配置 */
23
+ /** [stylus](https://github.com/NervJS/taro/blob/main/packages/taro-rn-style-transformer/README.md#rnstylus) 相关配置 */
24
24
  stylus?: IOption
25
25
 
26
26
  /** 配置 postcss 相关插件 */
@@ -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,10 @@
1
1
  import type { RecursiveTemplate, UnRecursiveTemplate } from '@tarojs/shared/dist/template'
2
+ import type { AppConfig, PageConfig } from '@tarojs/taro'
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'
7
8
 
8
9
  export interface ViteNativeCompMeta {
9
10
  name: string
@@ -13,6 +14,7 @@ export interface ViteNativeCompMeta {
13
14
  isNative: true
14
15
  templatePath: string
15
16
  cssPath?: string
17
+ isPackage?: boolean
16
18
  }
17
19
 
18
20
  export interface ViteFileType {
@@ -41,7 +43,6 @@ export interface VitePageMeta {
41
43
  cssPath?: string
42
44
  }
43
45
 
44
-
45
46
  export interface ViteH5BuildConfig extends CommonBuildConfig, IH5Config<'vite'> {
46
47
  entryFileName?: string
47
48
  runtimePath?: string | string[]
@@ -53,6 +54,7 @@ export interface ViteHarmonyBuildConfig extends CommonBuildConfig, IHarmonyConfi
53
54
  useJSON5?: boolean
54
55
  blended?: boolean
55
56
  runtimePath?: string | string[]
57
+ isPure?: boolean
56
58
  taroComponentsPath: string
57
59
  }
58
60
 
@@ -132,10 +134,11 @@ export interface ViteHarmonyCompilerContext extends ViteCompilerContext<ViteHarm
132
134
  nativeExt: string[]
133
135
  fileType: ViteFileType
134
136
  commonChunks: string[]
137
+ extraComponents: string[]
135
138
  nativeComponents : Map<string, ViteNativeCompMeta>
136
139
  getCommonChunks: () => string[]
137
140
  modifyHarmonyConfig: (config: Partial<AppConfig>) => void
138
- modifyHostPackageDep: (outDir: string, deps?: Record<string, string>, devDeps?: Record<string, string>) => void
141
+ modifyHostPackage: (deps?: Record<string, string>, devDeps?: Record<string, string>) => Exclude<IHarmonyConfig['ohPackage'], void>
139
142
  collectNativeComponents: (meta: ViteAppMeta | VitePageMeta | ViteNativeCompMeta) => void
140
143
  getScriptPath: (filePath: string) => string
141
144
  getStylePath: (filePath: string) => string
@@ -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 {
@@ -139,5 +140,7 @@ declare module './index' {
139
140
  path?: string
140
141
  /** 页面的组件选项 */
141
142
  options?: Record<string, unknown>
143
+ /** 获得一个 EventChannel 对象,用于页面间通讯 */
144
+ getOpenerEventChannel?(): Record<string, any>
142
145
  }
143
146
  }
@@ -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
@@ -424,7 +429,7 @@ declare module './index' {
424
429
  decodeQuery?: 'disable'
425
430
  }
426
431
 
427
- interface AppConfig {
432
+ export interface AppConfig {
428
433
  /** 小程序默认启动首页,未指定 entryPagePath 时,数组的第一项代表小程序的初始页面(首页)。 */
429
434
  entryPagePath?: string
430
435
  /** 接受一个数组,每一项都是字符串,来指定小程序由哪些页面组成,数组的第一项代表小程序的初始页面 */
@@ -561,7 +566,7 @@ declare module './index' {
561
566
  */
562
567
  themeLocation?: string
563
568
  /** 配置自定义组件代码按需注入 */
564
- lazyCodeLoading?: string
569
+ lazyCodeLoading?: 'requiredComponents' | string
565
570
  /** 单页模式相关配置 */
566
571
  singlePage?: SinglePage
567
572
  /** 聊天素材小程序打开相关配置