Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(types): sync components types #261

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion docs/apis/media/audio/WebAudioContext.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,15 @@ const myArrayBuffer = audioCtx.createBuffer(channels, frameCount, audioCtx.sampl
> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.decodeAudioData.html)

```tsx
() => AudioBuffer
(audioData: ArrayBuffer, successCallback: (buffer: AudioBuffer) => void, errorCallback: (error: any) => void) => Promise<AudioBuffer>
```

| 参数 | 类型 |
| --- | --- |
| audioData | `ArrayBuffer` |
| successCallback | `(buffer: AudioBuffer) => void` |
| errorCallback | `(error: any) => void` |

#### 示例代码

```tsx
Expand Down
2 changes: 1 addition & 1 deletion docs/apis/network/request/request.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ sidebar_label: request
| referrerStrategy | `keyof ReferrerStrategy` | `"querystring"` | 否 | referer 策略,用于控制当前请求 header 对象中 referer 字段格式。该参数默认值可通过 app.json 中的配置进行修改。<br />API 支持度: alipay 支付宝: 10.3.50+ APPX: 2.8.7 开发者工具: 3.5.1<br />[参考地址](https://opendocs.alipay.com/mini/api/owycmh#referrerStrategy%20%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E) |
| success | `(result: SuccessCallbackResult<T>) => void` | | 否 | 接口调用成功的回调函数 |
| fail | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用失败的回调函数 |
| complete | `(res: Partial<SuccessCallbackResult> & TaroGeneral.CallbackResult) => void` | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
| complete | `(res: any) => void` | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
| jsonp | string or boolean | `false` | 否 | 设置是否使用 jsonp 方式获取数据<br />API 支持度: h5 |
| jsonpCache | `RequestCache` | | 否 | 设置 jsonp 请求 url 是否需要被缓存<br />API 支持度: h5 |
| mode | `keyof CorsMode` | `"same-origin"` | 否 | 设置是否允许跨域请求<br />API 支持度: h5 |
Expand Down
6 changes: 5 additions & 1 deletion packages/taro/types/api/media/audio.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,11 @@ declare module '../../index' {
* ```
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.decodeAudioData.html
*/
decodeAudioData(): AudioBuffer
decodeAudioData(
audioData: ArrayBuffer,
successCallback: (buffer: AudioBuffer) => void,
errorCallback: (error: any) => void
): Promise<AudioBuffer>
}

namespace WebAudioContext {
Expand Down
5 changes: 3 additions & 2 deletions packages/taro/types/compile/config/h5.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ export interface IH5Config <T extends CompilerTypes = CompilerWebpackTypes> {

/** Web 编译过程的相关配置 */
compile?: {
exclude?: (string | RegExp)[]
include?: (string | RegExp)[]
exclude?: any[]
include?: any[]
/** 对应 @rollup/plugin-babel 插件的 filter 配置。只在 vite 编译模式下有效 */
filter?: (filename: string) => boolean
}
/** 生成的代码是否要兼容旧版浏览器,值为 true 时,会去读取 package.json 的 browserslist 字段。只在 vite 编译模式下有效 */
Expand Down
5 changes: 3 additions & 2 deletions packages/taro/types/compile/config/mini.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ export interface IMiniAppConfig<T extends CompilerTypes = CompilerWebpackTypes>

/** 小程序编译过程的相关配置 */
compile?: {
exclude?: (string | RegExp)[]
include?: (string | RegExp)[]
exclude?: any[]
include?: any[]
/** 对应 @rollup/plugin-babel 插件的 filter 配置。只在 vite 编译模式下有效 */
filter?: (filename: string) => boolean
}

Expand Down
11 changes: 9 additions & 2 deletions packages/taro/types/compile/viteCompilerContext.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import type { AppConfig, PageConfig } from '../index'

export interface ViteNativeCompMeta {
name: string
exportName: string
scriptPath: string
configPath: string
config: PageConfig
isNative: true
templatePath: string
cssPath?: string
isPackage?: boolean
isGenerated?: boolean
}

export interface ViteFileType {
Expand Down Expand Up @@ -109,6 +111,7 @@ export interface ViteCompilerContext<T> {
configFileList: string[]
compilePage: (pageName: string) => VitePageMeta
watchConfigFile: (rollupCtx: PluginContext) => void
collectedDeps: (rollupCtx: PluginContext, id: string, filter, cache: Set<string> = new Set()) => Promise<Set<string>>
getAppScriptPath: () => string
getApp: () => ViteAppMeta
getPages: () => VitePageMeta[]
Expand Down Expand Up @@ -140,7 +143,9 @@ export interface ViteHarmonyCompilerContext extends ViteCompilerContext<ViteHarm
getCommonChunks: () => string[]
modifyHarmonyConfig: (config: Partial<AppConfig>) => void
modifyHostPackage: (deps?: Record<string, string>, devDeps?: Record<string, string>) => Exclude<IHarmonyConfig['ohPackage'], void>
collectNativeComponents: (meta: ViteAppMeta | VitePageMeta | ViteNativeCompMeta) => void
resolvePageImportPath: (scriptPath: string, pageName: string) => string
collectNativeComponents: (meta: ViteAppMeta | VitePageMeta | ViteNativeCompMeta) => ViteNativeCompMeta[]
generateNativeComponent: (rollupCtx: PluginContext, meta: ViteNativeCompMeta, implicitlyLoadedAfterOneOf: string[] = []) => void
getScriptPath: (filePath: string) => string
getStylePath: (filePath: string) => string
getConfigPath: (filePath: string) => string
Expand All @@ -151,7 +156,9 @@ export interface ViteMiniCompilerContext extends ViteCompilerContext<ViteMiniBui
commonChunks: string[]
nativeComponents : Map<string, ViteNativeCompMeta>
getCommonChunks: () => string[]
collectNativeComponents: (meta: ViteAppMeta | VitePageMeta | ViteNativeCompMeta) => void
resolvePageImportPath: (scriptPath: string, pageName: string) => string
collectNativeComponents: (meta: ViteAppMeta | VitePageMeta | ViteNativeCompMeta) => ViteNativeCompMeta[]
generateNativeComponent: (rollupCtx: PluginContext, meta: ViteNativeCompMeta, implicitlyLoadedAfterOneOf: string[] = []) => void
getScriptPath: (filePath: string) => string
getTemplatePath: (filePath: string) => string
getStylePath: (filePath: string) => string
Expand Down
1 change: 1 addition & 0 deletions packages/taro/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,5 @@ declare namespace Taro {
declare global {
const defineAppConfig: (config: Taro.AppConfig) => Taro.AppConfig
const definePageConfig: (config: Taro.PageConfig) => Taro.Config
const importNativeComponent: <T> (path: string, name = '', exportName = 'default') => Awaited<T>
}
2 changes: 1 addition & 1 deletion packages/taro/types/taro.config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ declare module './index' {
/** 页面自定义组件配置
* @see https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/
*/
usingComponents?: Record<string, string>
usingComponents?: Record<string, string | [string, string]>
/** 指定使用升级后的 weui 样式
* - v2: 可表明启用新版的组件样式
* @default default
Expand Down