-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(types): sync components types
- Loading branch information
1 parent
3e9f0f3
commit e1eee49
Showing
123 changed files
with
3,660 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Node CI | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
permissions: | ||
contents: read # to fetch code (actions/checkout) | ||
|
||
env: | ||
CI: true | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
|
||
- name: Cache pnpm modules and build | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
node_modules | ||
build/taro-docs | ||
key: ${{ runner.os }}-github | ||
restore-keys: | | ||
${{ runner.os }}- | ||
- name: install | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
version: 7 | ||
run_install: | | ||
- recursive: true | ||
args: [--frozen-lockfile, --strict-peer-dependencies] | ||
- name: Build | ||
run: pnpm run build:github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
--- | ||
title: InferenceSession | ||
sidebar_label: InferenceSession | ||
--- | ||
|
||
## 方法 | ||
|
||
### destroy | ||
|
||
销毁 InferenceSession 实例 | ||
|
||
支持情况:<img title="微信小程序" src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img title="H5" src={require('@site/static/img/platform/h5.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="React Native" src={require('@site/static/img/platform/rn.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="Harmony" src={require('@site/static/img/platform/harmony.png').default} className="icon_platform icon_platform--not-support" width="25px"/> | ||
|
||
> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/InferenceSession.destroy.html) | ||
```tsx | ||
() => void | ||
``` | ||
|
||
### offError | ||
|
||
取消监听模型加载失败事件. 传入指定回调函数则只取消指定回调,不传则取消所有回调 | ||
|
||
支持情况:<img title="微信小程序" src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img title="H5" src={require('@site/static/img/platform/h5.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="React Native" src={require('@site/static/img/platform/rn.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="Harmony" src={require('@site/static/img/platform/harmony.png').default} className="icon_platform icon_platform--not-support" width="25px"/> | ||
|
||
> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/InferenceSession.offError.html) | ||
```tsx | ||
(callback?: OffErrorCallback) => void | ||
``` | ||
|
||
| 参数 | 类型 | | ||
| --- | --- | | ||
| callback | `OffErrorCallback` | | ||
|
||
### offLoad | ||
|
||
取消监听模型加载完成事件 | ||
|
||
支持情况:<img title="微信小程序" src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img title="H5" src={require('@site/static/img/platform/h5.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="React Native" src={require('@site/static/img/platform/rn.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="Harmony" src={require('@site/static/img/platform/harmony.png').default} className="icon_platform icon_platform--not-support" width="25px"/> | ||
|
||
> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/InferenceSession.offLoad.html) | ||
```tsx | ||
(callback?: OffLoadCallback) => void | ||
``` | ||
|
||
| 参数 | 类型 | | ||
| --- | --- | | ||
| callback | `OffLoadCallback` | | ||
|
||
### onError | ||
|
||
监听模型加载失败事件 | ||
|
||
支持情况:<img title="微信小程序" src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img title="H5" src={require('@site/static/img/platform/h5.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="React Native" src={require('@site/static/img/platform/rn.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="Harmony" src={require('@site/static/img/platform/harmony.png').default} className="icon_platform icon_platform--not-support" width="25px"/> | ||
|
||
> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/InferenceSession.onError.html) | ||
```tsx | ||
(callback: OnLoadCallback) => void | ||
``` | ||
|
||
| 参数 | 类型 | | ||
| --- | --- | | ||
| callback | `OnLoadCallback` | | ||
|
||
### onLoad | ||
|
||
监听模型加载完成事件 | ||
|
||
支持情况:<img title="微信小程序" src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img title="H5" src={require('@site/static/img/platform/h5.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="React Native" src={require('@site/static/img/platform/rn.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="Harmony" src={require('@site/static/img/platform/harmony.png').default} className="icon_platform icon_platform--not-support" width="25px"/> | ||
|
||
> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/InferenceSession.onLoad.html) | ||
```tsx | ||
(callback: OnLoadCallback) => void | ||
``` | ||
|
||
| 参数 | 类型 | | ||
| --- | --- | | ||
| callback | `OnLoadCallback` | | ||
|
||
### run | ||
|
||
运行推断 | ||
需要在 session.onLoad 回调后使用。接口参数为 Tensors 对象,返回 Promise。 | ||
一个 InferenceSession 被创建完成后可以重复多次调用 InferenceSession.run(), 直到调用 session.destroy() 进行销毁。 | ||
|
||
支持情况:<img title="微信小程序" src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img title="H5" src={require('@site/static/img/platform/h5.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="React Native" src={require('@site/static/img/platform/rn.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="Harmony" src={require('@site/static/img/platform/harmony.png').default} className="icon_platform icon_platform--not-support" width="25px"/> | ||
|
||
> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/InferenceSession.destroy.html) | ||
```tsx | ||
(option: Tensors) => Promise<Tensors> | ||
``` | ||
|
||
| 参数 | 类型 | | ||
| --- | --- | | ||
| option | `Tensors` | | ||
|
||
## 参数 | ||
|
||
### Type | ||
|
||
### Tensor | ||
|
||
| 参数 | 类型 | 说明 | | ||
| --- | --- | --- | | ||
| shape | `number[]` | Tensor shape (Tensor 形状,例如 [1, 3, 224, 224] 即表示一个4唯Tensor,每个维度的长度分别为1, 3, 224, 224) | | ||
| data | `ArrayBuffer` | Tensor 值,一段 ArrayBuffer | | ||
| type | `keyof Type` | ArrayBuffer 值的类型,合法值有 uint8, int8, uint32, int32, float32 | | ||
|
||
### Tensors | ||
|
||
| 参数 | 类型 | | ||
| --- | --- | | ||
| __index | `__index` | | ||
|
||
### OffErrorCallback | ||
|
||
模型加载失败回调函数。 | ||
|
||
```tsx | ||
(res: TaroGeneral.CallbackResult) => void | ||
``` | ||
|
||
| 参数 | 类型 | | ||
| --- | --- | | ||
| res | `TaroGeneral.CallbackResult` | | ||
|
||
### OffLoadCallback | ||
|
||
模型加载完成回调函数 | ||
|
||
```tsx | ||
(res: TaroGeneral.CallbackResult) => void | ||
``` | ||
|
||
| 参数 | 类型 | | ||
| --- | --- | | ||
| res | `TaroGeneral.CallbackResult` | | ||
|
||
### OnLoadCallback | ||
|
||
模型加载失败回调函数 | ||
|
||
```tsx | ||
(res: TaroGeneral.CallbackResult) => void | ||
``` | ||
|
||
| 参数 | 类型 | | ||
| --- | --- | | ||
| res | `TaroGeneral.CallbackResult` | | ||
|
||
## API 支持度 | ||
|
||
| API | 微信小程序 | H5 | React Native | Harmony | | ||
| :---: | :---: | :---: | :---: | :---: | | ||
| InferenceSession.destroy | ✔️ | | | | | ||
| InferenceSession.offError | ✔️ | | | | | ||
| InferenceSession.offLoad | ✔️ | | | | | ||
| InferenceSession.onError | ✔️ | | | | | ||
| InferenceSession.onLoad | ✔️ | | | | | ||
| InferenceSession.run | ✔️ | | | | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
title: Taro.createInferenceSession(option) | ||
sidebar_label: createInferenceSession | ||
--- | ||
|
||
创建 AI 推理 Session | ||
|
||
支持情况:<img title="微信小程序" src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img title="H5" src={require('@site/static/img/platform/h5.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="React Native" src={require('@site/static/img/platform/rn.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="Harmony" src={require('@site/static/img/platform/harmony.png').default} className="icon_platform icon_platform--not-support" width="25px"/> | ||
|
||
> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/wx.createInferenceSession.html) | ||
## 类型 | ||
|
||
```tsx | ||
(option: Option) => InferenceSession | ||
``` | ||
|
||
## 参数 | ||
|
||
| 参数 | 类型 | | ||
| --- | --- | | ||
| option | `Option` | | ||
|
||
### Option | ||
|
||
| 参数 | 类型 | 必填 | 说明 | | ||
| --- | --- | :---: | --- | | ||
| model | `string` | 是 | 模型文件路径,目前只执行后缀为.onnx格式(支持代码包路径,和本地文件系统路径) | | ||
| precesionLevel | `PrecesionLevel` | 否 | 推理精度,有效值为 0 - 4。<br />一般来说,使用的precesionLevel等级越低,推理速度越快,但可能会损失精度。<br />推荐开发者在开发时,在效果满足需求时优先使用更低精度以提高推理速度,节约能耗。 | | ||
| allowQuantize | `boolean` | 否 | 是否生成量化模型推理 | | ||
| allowNPU | `boolean` | 否 | 是否使用NPU推理,仅对IOS有效 | | ||
| typicalShape | `boolean` | 否 | 输入典型分辨率 | | ||
|
||
### PrecesionLevel | ||
|
||
| 参数 | 说明 | | ||
| --- | --- | | ||
| 0 | 使用fp16 存储浮点,fp16计算,Winograd 算法也采取fp16 计算,开启近似math计算 | | ||
| 1 | 使用fp16 存储浮点,fp16计算,禁用 Winograd 算法,开启近似math计算 | | ||
| 2 | 使用fp16 存储浮点,fp32计算,开启 Winograd,开启近似math计算 | | ||
| 3 | 使用fp32 存储浮点,fp32计算,开启 Winograd,开启近似math计算 | | ||
| 4 | 使用fp32 存储浮点,fp32计算,开启 Winograd,关闭近似math计算 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
title: Taro.getInferenceEnvInfo(option) | ||
sidebar_label: getInferenceEnvInfo | ||
--- | ||
|
||
获取通用AI推理引擎版本 | ||
|
||
支持情况:<img title="微信小程序" src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img title="H5" src={require('@site/static/img/platform/h5.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="React Native" src={require('@site/static/img/platform/rn.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="Harmony" src={require('@site/static/img/platform/harmony.png').default} className="icon_platform icon_platform--not-support" width="25px"/> | ||
|
||
> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/wx.getInferenceEnvInfo.html) | ||
## 类型 | ||
|
||
```tsx | ||
(option: Option) => void | ||
``` | ||
|
||
## 参数 | ||
|
||
| 参数 | 类型 | | ||
| --- | --- | | ||
| option | `Option` | | ||
|
||
### Option | ||
|
||
| 参数 | 类型 | 必填 | 说明 | | ||
| --- | --- | :---: | --- | | ||
| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | ||
| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | | ||
| success | `(result: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | | ||
|
||
### SuccessCallbackResult | ||
|
||
| 参数 | 类型 | 说明 | | ||
| --- | --- | --- | | ||
| ver | `string` | AI推理引擎版本 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
title: Taro.preloadAssets(option) | ||
sidebar_label: preloadAssets | ||
--- | ||
|
||
为视图层预加载媒体资源文件, 目前支持:font,image | ||
|
||
支持情况:<img title="微信小程序" src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img title="H5" src={require('@site/static/img/platform/h5.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="React Native" src={require('@site/static/img/platform/rn.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="Harmony" src={require('@site/static/img/platform/harmony.png').default} className="icon_platform icon_platform--not-support" width="25px"/> | ||
|
||
> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/wx.preloadAssets.html) | ||
## 类型 | ||
|
||
```tsx | ||
(option: Option) => Promise<TaroGeneral.CallbackResult> | ||
``` | ||
|
||
## 参数 | ||
|
||
| 参数 | 类型 | | ||
| --- | --- | | ||
| option | `Option` | | ||
|
||
### AssetsObjectType | ||
|
||
| 参数 | 说明 | | ||
| --- | --- | | ||
| font | 字体 | | ||
| image | 图片 | | ||
|
||
### AssetsObject | ||
|
||
| 参数 | 类型 | 说明 | | ||
| --- | --- | --- | | ||
| type | `keyof AssetsObjectType` | 类型 | | ||
| src | `string` | 资源地址 | | ||
|
||
### Option | ||
|
||
| 参数 | 类型 | 必填 | 说明 | | ||
| --- | --- | :---: | --- | | ||
| data | `AssetsObjectType[]` | 是 | | | ||
| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | ||
| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | | ||
| success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
title: Taro.preloadSkylineView(option) | ||
sidebar_label: preloadSkylineView | ||
--- | ||
|
||
预加载下个页面所需要的 Skyline 运行环境 | ||
|
||
支持情况:<img title="微信小程序" src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img title="H5" src={require('@site/static/img/platform/h5.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="React Native" src={require('@site/static/img/platform/rn.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="Harmony" src={require('@site/static/img/platform/harmony.png').default} className="icon_platform icon_platform--not-support" width="25px"/> | ||
|
||
> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/wx.preloadSkylineView.html) | ||
## 类型 | ||
|
||
```tsx | ||
(option: Option) => Promise<TaroGeneral.CallbackResult> | ||
``` | ||
|
||
## 参数 | ||
|
||
| 参数 | 类型 | | ||
| --- | --- | | ||
| option | `Option` | | ||
|
||
### Option | ||
|
||
| 参数 | 类型 | 必填 | 说明 | | ||
| --- | --- | :---: | --- | | ||
| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | ||
| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | | ||
| success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | |
Oops, something went wrong.