diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..9aa1673 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,63 @@ +module.exports = { + root: true, + parser: '@typescript-eslint/parser', + parserOptions: { + project: './tsconfig.json' + }, + plugins: [ + '@typescript-eslint', + ], + rules: { + indent: ['error', 4], + 'no-trailing-spaces': ['error'], + semi: ['off'], + '@typescript-eslint/semi': ['error', 'never'], + '@typescript-eslint/no-extra-semi': ['error'], + quotes: ['off'], + '@typescript-eslint/quotes': ['error', 'single'], + '@typescript-eslint/ban-ts-comment': ['off'], + '@typescript-eslint/adjacent-overload-signatures': ['error'], + '@typescript-eslint/ban-types': ['error', { + extendDefaults: true, + types: { + /** + * we are using `{}` as noop + * e.g. `type A

= B & (P extends Q ? C : {})` + * will get `B & C` when `P extends Q` and `B` otherwise + */ + '{}': false, + /** + * we actually need a type accepting any function-like value + * e.g. `type Methods = Record` + */ + 'Function': false, + } + }], + '@typescript-eslint/member-delimiter-style': ['error', { + multiline: { + delimiter: 'none', + requireLast: false, + }, + singleline: { + delimiter: 'comma', + requireLast: false + } + }], + '@typescript-eslint/naming-convention': ['error', { + selector: 'enum', + format: ['PascalCase', 'UPPER_CASE'], + leadingUnderscore: 'forbid', + trailingUnderscore: 'forbid', + }, { + selector: 'typeLike', + format: ['PascalCase'], + leadingUnderscore: 'forbid', + trailingUnderscore: 'forbid', + }], + '@typescript-eslint/array-type': ['error', { + default: 'array-simple', + readonly: 'array-simple' + }], + '@typescript-eslint/no-unnecessary-qualifier': ['error'], + }, +} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..aeecb58 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,30 @@ +name: Test + +on: + - push + - pull_request + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 + name: Install pnpm + with: + version: latest + run_install: false + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: lts/* + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Run test + run: npm run test diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..38f11c6 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +registry=https://registry.npmjs.org diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 086d6ca..0000000 --- a/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: node_js -node_js: - - "lts/*" -script: npm run test diff --git a/CHANGELOG.md b/CHANGELOG.md index 341c41a..ce7e7db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,238 @@ +## 2025-07-15 v4.1.0 +- 修改 `getOpenerEventChannel` 的返回值的类型,使其有可能返回空对象,以正确反映实际情况。这是一个 **破坏性改动**,`getOpenerEventChannel` 的返回值上的 `emit`, `on` 等方法不再可以直接调用 ([#350](https://github.com/wechat-miniprogram/api-typings/issues/350)) +- 解决依赖安全问题 + +## 2025-07-15 v4.0.8 +- 更新 API 定义到 3.8.10 + +## 2025-04-18 v4.0.7 +- 更新云开发拓展能力类型定义 + +## 2025-04-18 v4.0.6 +- 更新 API 定义到 3.8.0 + +## 2025-02-08 v4.0.5 +- 修复 `setTimeout` 和 `setInterval` 的参数 ([#323](https://github.com/wechat-miniprogram/api-typings/issues/323)) +- 更新 API 定义到 3.7.7 + +## 2025-01-14 v4.0.4 +- 解决依赖安全问题 + +## 2025-01-14 v4.0.3 +- 补齐云开发 `CollectionReference` 上的 `aggregate` ([#276](https://github.com/wechat-miniprogram/api-typings/issues/276)) +- 补齐组件实例方法 `setInitialRenderingCache` 和 `getAppBar` by [@Yang Mingshan](https://github.com/yangmingshan) ([#339](https://github.com/wechat-miniprogram/api-typings/issues/339)) +- 更新 API 定义到 3.7.4 + +## 2024-11-13 v4.0.2 +- 补齐 `RaycastHit` ([#337](https://github.com/wechat-miniprogram/api-typings/issues/337)) + +## 2024-09-24 v4.0.1 +- 更新 API 定义到 3.5.7 + +## 2024-09-24 v4.0.0 +合入 [#332](https://github.com/wechat-miniprogram/api-typings/pull/332), [#333](https://github.com/wechat-miniprogram/api-typings/pull/333), [#334](https://github.com/wechat-miniprogram/api-typings/pull/334) by [@lvzl](https://github.com/lv-z-l)。这几个 Pull Request 对 `Component` 和 `Behavior` 的实现进行了较大改动,以支持: +1. 对于 `Array` 和 `Object` 类型的 `property` 和 `data`,以值的实际类型作为泛型推导的结果,而非固定推导为 `any[]` 和 `Record`; +2. 改变了 `BehaviorIdentifier` 的类型,通过为其交叉一个带有 `Behavior` 定义信息的虚假类型,使 `Component` 和 `Behavior` 能自动推导其使用到的 `Behavior` 的 `data`, `properties` 及 `methods`; + +这是一个比较大的 **破坏性改动**,从低于 4.0.0 的版本升级时,可能需要进行一些适配: +1. 全局函数 `Component` 和 `Behavior` 的第四个泛型现在是新的 `TBehavior`,如果之前的代码中有为这两个函数手动指定泛型的用例,需要手动添加这个泛型; +2. `Behavior()` 的返回值不再是 `string`(或者说不完全是),之前使用 `string` 接受 `Behavior()` 返回值的实现需要修改为 `WechatMiniprogram.Behavior.BehaviorIdentifier`; +3. 自定义组件的 `this.data` 和 `this.property` 的推导类型可能会有所变化,需要根据推导类型进行相应改动。 + +## 2024-08-08 v3.12.3 +- 更新 API 定义到 3.5.2 +- 修复 [#235](https://github.com/wechat-miniprogram/api-typings/issues/235), [#302](https://github.com/wechat-miniprogram/api-typings/issues/302), [#303](https://github.com/wechat-miniprogram/api-typings/issues/303), [#304](https://github.com/wechat-miniprogram/api-typings/issues/304) by [@Yang Mingshan](https://github.com/yangmingshan) + +## 2023-12-01 v3.12.2 +- 更新 API 定义到 3.2.3 + +## 2023-10-17 v3.12.1 +- 更新 API 定义到 3.1.2 +- 补齐自定义组件实例的 `getPassiveEvent`, `setPassiveEvent` 方法 + +## 2023-08-24 v3.12.0 +- `App` 生命周期 `onLaunch`, `onShow` 参数中的 `referrerInfo` 字段类型对齐 API 定义中的 `ReferrerInfo`。这是一个 **破坏性改动**,其中 `extraData` 的类型从 `any` 收窄到了 `Record` +- 根据实际实现,修改了 `LaunchOptions` 中 `query` 字段的类型。这是一个 **破坏性改动**,该类型从 `Record` 收窄到了 `Record` + +## 2023-08-24 v3.11.1 +- 更新 API 定义到 3.0.1 + +## 2023-08-04 v3.11.0 +- 更新 API 定义到 3.0.0 + - 暂未支持 [glass-easel](https://github.com/wechat-miniprogram/glass-easel) [Chaining API](https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/glass-easel/chaining-api.html) 的类型定义 +- 补齐 `WXWebAssembly` 定义 + +## 2023-06-09 v3.10.0 +- 更新 API 定义到 2.32.1 +- 新增 CanvasRenderingContext 类型定义 [#111](https://github.com/wechat-miniprogram/api-typings/issues/111) + +## 2023-04-10 v3.9.1 +- 更新 API 定义到 2.30.4 +- 修复页面 `onShareAppMessage` 异步形式的定义错误 + +## 2023-01-12 v3.9.0 +- 更新 API 定义到 2.29.1 +- 将 xr-frame 的命名空间由 `WechatXrFrame` 改为 `XrFrame`。这是一个 **破坏性改动** + +## 2022-09-09 v3.6.0 +- 更新 API 定义到 2.26.0 +- 更改了部分监听方法及其参数的命名 + +## 2022-06-24 v3.5.0 +- 更新 API 定义到 2.24.6 + +## 2022-04-01 v3.4.6 +- 更新 API 定义到 2.23.2 + +## 2022-01-20 v3.4.5 +- 更新 API 定义到 2.21.3 + +## 2021-08-24 v3.4.4 +- 更新 API 定义到 2.20.1 + +## 2021-08-24 v3.4.3 +- 更新 API 定义到 2.19.2 +- 补充自定义组件获取更新性能接口定义 + +## 2021-08-02 v3.4.2 +- 更新 API 定义到 2.19.0 +- 重新整理了注释,包括: + - 加入插件支持情况、版本和说明 + - 将支持和废弃情况挪到前面,使其更不容易因为接口说明太长而被忽略 + - 移除文首、文末和多余(连续超过两个)的空行 + - 修复几个链接 + +## 2021-07-07 v3.4.1 +- 移除一个意外加入的非预期字符 + +## 2021-07-07 v3.4.0 +- 更新 API 定义到 2.18.0 +- 更新来自文档代码示例的测试用例 +- 更新 npm 依赖以解决安全问题 +- 修复 [#202](https://github.com/wechat-miniprogram/api-typings/issues/202), [#204](https://github.com/wechat-miniprogram/api-typings/issues/204) + +## 2021-04-21 v3.3.2 +- 更新 API 定义到 2.16.1 + +## 2021-04-09 v3.3.1 +- 更新 API 定义到 2.16.0 + +## 2021-03-02 v3.3.0 +- 更新部分新接口定义 +- 支持泛型([#177](https://github.com/wechat-miniprogram/api-typings/issues/177)) +- 支持索引签名,以支持 `wx.requestSubscribeMessage`([#175](https://github.com/wechat-miniprogram/api-typings/issues/175)) + +## 2021-02-22 v3.2.3 +- 更新 API 定义到 2.15.0 +- 修复 `Component.triggerEvent` 的 `detail` 类型 +- 修复几个接口的定义([#193](https://github.com/wechat-miniprogram/api-typings/issues/193), [#185](https://github.com/wechat-miniprogram/api-typings/issues/185), [#180](https://github.com/wechat-miniprogram/api-typings/issues/180)) +- 修改 `MethodOption` 以解决 [#161](https://github.com/wechat-miniprogram/api-typings/issues/161)(鸣谢:[@Lienviws](https://github.com/Lienviws)) + +## 2021-01-14 v3.2.2 +- 修复几个接口未 Promise 化的问题 + +## 2021-01-06 v3.2.1 +- 更新 API 定义到 2.14.1 +- 补齐 `virtualHost` ([#174](https://github.com/wechat-miniprogram/api-typings/issues/174)) + +## 2020-11-13 v3.2.0 +- 更新 API 定义到 2.14.0 +- 补齐 NFC 接口的错误码 + +## 2020-11-04 v3.1.6 +- 补齐 `requirePlugin` 和 `requireMiniProgram` + +## 2020-10-29 v3.1.5 +- 更新 API 定义 +- 修复代码格式问题(`no-unnecessary-qualifier`) + +## 2020-10-28 v3.1.4 +- 更新 API 定义到 2.13.2 +- 为被废弃的接口增加了 `@deprecated` 标识 + +## 2020-10-14 v3.1.3 +- 修复 `ICustomTimelineContent` 的 `query` 的类型 + +## 2020-09-30 v3.1.2 +- 更新 API 定义到 2.13.1 + +## 2020-09-24 v3.1.1 +- 更新 API 定义到 2.13.0 +- 改变了嵌套命名空间的写法 +- 支持 `Component` 的第五个泛型参数,用于将自定义组件作为页面根组件使用的情况 + +## 2020-09-22 v3.1.0 +- 将代码风格检查从 tslint 迁移到 eslint + +## 2020-08-19 v3.0.2 +- 更新 API 定义 +- 合并 PR [#151](https://github.com/wechat-miniprogram/api-typings/pull/151), [#152](https://github.com/wechat-miniprogram/api-typings/pull/152),补齐事件类型,补齐 `onShareTimeline` + +## 2020-08-19 v3.0.2 +- 更新 API 定义 +- 合并 PR [#124](https://github.com/wechat-miniprogram/api-typings/pull/124), [#145](https://github.com/wechat-miniprogram/api-typings/pull/145),修复两个动画接口的问题 + +## 2020-08-03 v3.0.1 +- 更新 API 定义 +- 修复某些取消监听的接口(`off`)的参数不为可选值的问题 + +## 2020-07-30 v3.0.0 +- 由于基础库接口基本向前兼容,不再与基础库保持版本同步 +- 更新 API 定义到 2.12.0 + +## 2020-06-15 v2.11.0-1 +- 该版本继续合并了一部分完全相同的 interface / callback,是一个 **破坏性改动**,原本字面上引用了这些 interface / callback 的代码可能会报错。 +- 为 `Component` 构造器增加第四个泛型,以允许在自定义组件上挂载自定义的字段 ([#133](https://github.com/wechat-miniprogram/api-typings/issues/133)) +- 修复一些接口错误 ([#134](https://github.com/wechat-miniprogram/api-typings/issues/134)) +- 补齐 `App` 的 `onThemeChange` ([#135](https://github.com/wechat-miniprogram/api-typings/issues/135)) +- 补齐 `Page` 的 `onAddToFavorites` ([#136](https://github.com/wechat-miniprogram/api-typings/issues/136)) + +## 2020-05-20 v2.11.0 +- 同步 API 定义到基础库 2.11.0 +- 该版本继续合并了一部分完全相同的 interface / callback,是一个 **破坏性改动**,原本字面上引用了这些 interface / callback 的代码可能会报错。 +- 修复接口错误 ([#126](https://github.com/wechat-miniprogram/api-typings/issues/126)) + +## 2020-04-20 v2.10.4 +- 同步 API 定义到基础库 2.10.4 +- 在之前的版本中,分属于不同接口的两个 interface / callback 即使完全相同,也会拥有不同的名字。在这次更新中,他们将合并为同一个(如 `FileSystemManagerGetFileInfoCompleteCallback` 和 `WxGetFileInfoCompleteCallback` 都变成了 `GetFileInfoCompleteCallback`)。这是一个 **破坏性改动**,原本字面上引用了这些 interface / callback 的代码可能会报错。 +- 修复了一些取消监听接口(off callback)的参数错误 ([#120](https://github.com/wechat-miniprogram/api-typings/issues/120)) + +## 2020-04-03 v2.10.3-1 +- 补齐 `Component` 的 `getOpenerEventChannel` ([#112](https://github.com/wechat-miniprogram/api-typings/issues/113) by [@baranwang](https://github.com/baranwang)) +- 加入了部分事件的定义 ([#115](https://github.com/wechat-miniprogram/api-typings/issues/115) by [@zenml](https://github.com/zenml)) +- 更新了小程序·云开发的 API 定义 ([#92](https://github.com/wechat-miniprogram/api-typings/issues/92)) + +## 2020-03-26 v2.10.3 +- 同步 API 定义到基础库 2.10.3 + +## 2020-03-18 v2.10.2-1 +- 支持 API Promise 化调用 ([#105](https://github.com/wechat-miniprogram/api-typings/issues/105)) + +## 2020-03-06 v2.10.2 +- 同步 API 定义到基础库 2.10.2 + +## 2020-02-10 v2.10.1-1 +- 允许重写部分全局变量 (由 `const` 改为 `let`) ([#102](https://github.com/wechat-miniprogram/api-typings/issues/102)) +- 补齐 `Page` 上的 `options` 字段 ([#101](https://github.com/wechat-miniprogram/api-typings/issues/101) by [@baranwang](https://github.com/baranwang)) + +## 2020-01-19 v2.10.1 +- 同步 API 定义到基础库 2.10.1 +- 补齐 `Component` `selectOwnerComponent`, `animate`, `clearAnimation` ([#96](https://github.com/wechat-miniprogram/api-typings/issues/96)) +- 补齐 `App` `onUnhandledRejection` ([#99](https://github.com/wechat-miniprogram/api-typings/issues/99)) + +## 2020-01-07 v2.10.0-1 +- 修复接口错误 ([#95](https://github.com/wechat-miniprogram/api-typings/issues/95)) + ## 2020-01-07 v2.10.0 - 同步 API 定义到基础库 2.10.0 ## 2019-12-20 v2.9.4 - 同步 API 定义到基础库 2.9.4 -- 修正一些接口错误(#88,#89,#91) +- 修正一些接口错误 ([#88](https://github.com/wechat-miniprogram/api-typings/issues/88),[#89](https://github.com/wechat-miniprogram/api-typings/issues/89),[#91](https://github.com/wechat-miniprogram/api-typings/issues/91)) ## 2019-12-06 v2.9.3 - 同步 API 定义到基础库 2.9.3 -- 补齐 `Component` 纯数据字段(`pureDataPattern`) +- 补齐 `Component` 纯数据字段 (`pureDataPattern`) - 支持 `Component` 的属性监听器使用 `string` 类型 ## 2019-11-14 v2.9.2 @@ -22,17 +247,17 @@ ## 2019-10-10 v2.8.3-1 - 修复注释文档中不可用的链接 -- 组件实例类型支持 `Partial` 的自定义方法([用例](https://github.com/wechat-miniprogram/api-typings/blob/master/test/issue.test.ts#L170-L185)) +- 组件实例类型支持 `Partial` 的自定义方法 ([用例](https://github.com/wechat-miniprogram/api-typings/blob/master/test/issue.test.ts#L170-L185)) ## 2019-09-19 v2.8.3 - 同步 API 定义到基础库 2.8.3 -- `getApp` 支持范型(#77) -- 修正一些接口错误(#73, #75, #79) +- `getApp` 支持范型 ([#77](https://github.com/wechat-miniprogram/api-typings/issues/77)) +- 修正一些接口错误 ([#73](https://github.com/wechat-miniprogram/api-typings/issues/73), [#75](https://github.com/wechat-miniprogram/api-typings/issues/75), [#79](https://github.com/wechat-miniprogram/api-typings/issues/79)) - 补齐 `require`, `exports`, `module.exports` 定义,以支持在没有 `@types/node` 下编译 ## 2019-09-10 v2.8.2 - 同步 API 定义到基础库 2.8.2 -- 加强了参数为可选值的方法参数类型定义和注释(如 `FileSystemManager.appendFileSync` 的 `encoding`) +- 加强了参数为可选值的方法参数类型定义和注释 (如 `FileSystemManager.appendFileSync` 的 `encoding`) ## 2019-08-30 v2.8.1 - 同步 API 定义到基础库 2.8.1 @@ -56,19 +281,19 @@ - 不再向全局暴露 `IAnyObject`,收回到命名空间 `WechatMiniprogram` 内 - 对齐代码规范,使用 4 空格缩进,不再使用分号等 - 小幅改动 behavior, component 和 page 的定义,使其对 data 和 properties 等的类型推断更准确 -- 修复了一些其他问题(#60, #59, #48, #47, #45, #33, #13) +- 修复了一些其他问题 ([#60](https://github.com/wechat-miniprogram/api-typings/issues/60), [#59](https://github.com/wechat-miniprogram/api-typings/issues/59), [#48](https://github.com/wechat-miniprogram/api-typings/issues/48), [#47](https://github.com/wechat-miniprogram/api-typings/issues/47), [#45](https://github.com/wechat-miniprogram/api-typings/issues/45), [#33](https://github.com/wechat-miniprogram/api-typings/issues/33), [#13](https://github.com/wechat-miniprogram/api-typings/issues/13)) ## 2019-08-08 v2.7.7-2 -- 补齐了部分接口 fail 回调的错误码(#51) +- 补齐了部分接口 fail 回调的错误码 ([#51](https://github.com/wechat-miniprogram/api-typings/issues/51)) ## 2019-08-06 v2.7.7-1 -- 重写了 page, component 和 behavior 的定义,替换原来不完整的定义,使其更全面,更准确(#46, #40, #30, #28, #27) +- 重写了 page, component 和 behavior 的定义,替换原来不完整的定义,使其更全面,更准确 ([#46](https://github.com/wechat-miniprogram/api-typings/issues/46), [#40](https://github.com/wechat-miniprogram/api-typings/issues/40), [#30](https://github.com/wechat-miniprogram/api-typings/issues/30), [#28](https://github.com/wechat-miniprogram/api-typings/issues/28), [#27](https://github.com/wechat-miniprogram/api-typings/issues/27)) ## 2019-07-31 v2.7.7 - 同步 API 定义到基础库 2.7.7 - 将命名空间从 `Wx` 更改为更正式的 `WechatMiniprogram`,这是一个 **破坏性改动**,原本字面上引用了 `Wx` 命名空间的代码可能失效 -- 修复了云开发的定义无法使用的问题(#25, #32, #42) -- 修复了一些其它问题(#11, #35, #43) \ No newline at end of file +- 修复了云开发的定义无法使用的问题 ([#25](https://github.com/wechat-miniprogram/api-typings/issues/25), [#32](https://github.com/wechat-miniprogram/api-typings/issues/32), [#42](https://github.com/wechat-miniprogram/api-typings/issues/42)) +- 修复了一些其它问题 ([#11](https://github.com/wechat-miniprogram/api-typings/issues/11), [#35](https://github.com/wechat-miniprogram/api-typings/issues/35), [#43](https://github.com/wechat-miniprogram/api-typings/issues/43)) diff --git a/README-en.md b/README-en.md index 2e34677..3405ec9 100644 --- a/README-en.md +++ b/README-en.md @@ -2,30 +2,40 @@ > [中文版本](./README.md) +[![Published on DefinitelyTyped](https://img.shields.io/npm/v/@types/wechat-miniprogram?label=%40types)](https://www.npmjs.com/package/@types/wechat-miniprogram) [![Published on NPM](https://img.shields.io/npm/v/miniprogram-api-typings.svg?style=flat)](https://www.npmjs.com/package/miniprogram-api-typings) [![MIT License](https://img.shields.io/github/license/wechat-miniprogram/api-typings.svg)](https://github.com/wechat-miniprogram/api-typings) -[![Travis CI Test Status](https://travis-ci.org/wechat-miniprogram/api-typings.svg?branch=master)](https://travis-ci.org/wechat-miniprogram/api-typings) +[![GitHub Actions Test Status](https://github.com/wechat-miniprogram/api-typings/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/wechat-miniprogram/api-typings/actions/workflows/test.yml) Type definitions for APIs of Wechat Mini Program in TypeScript ## Install -Install by NPM: +### By standalone npm package + ```bash -# install definitions for latest base library npm install miniprogram-api-typings ``` -or specify a base library version: +Manually import it after installed: -```bash -# install definitions for base library version 2.4.1 -npm install miniprogram-api-typings@2.4.1 -``` +- `import 'miniprogram-api-typings';` + +Or specify types in typescript config: + +- Specify `types: ["miniprogram-api-typings"]` in `tsconfig.json` + +Or reference by [Triple-Slash Directives](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html): -## Versions +- `/// ` -Check out all available versions corresponding to base library version in [VERSIONS.md](https://github.com/wechat-miniprogram/api-typings/blob/master/VERSIONS.md) +or: + +### By DefinitelyTyped + +```bash +npm install @types/wechat-miniprogram +``` ## Changelog @@ -33,10 +43,23 @@ See [CHANGELOG.md](https://github.com/wechat-miniprogram/api-typings/blob/master ## Contribution -Definitions of Wechat APIs (`lib.wx.api.d.ts`) are auto-generated together with our [documentations](https://developers.weixin.qq.com/miniprogram/dev/index.html), therefore PRs including that file will __not__ be merged. If you found some APIs defined wrongly, create an issue instead. +Definitions of Wechat APIs (`lib.wx.api.d.ts`) are auto-generated together with our [documentations](https://developers.weixin.qq.com/miniprogram/en/dev/api/), therefore PRs including that file will __not__ be merged. If you found some APIs defined wrongly, create an issue instead. Both PR and issue are welcomed for definitions of pages (`Page`), custom components (`Component`) and other else, since they are written manually. Help us improve this definition if you have any bug reports or suggestions! Thanks for contributing! +### Contributors + +- [Baran](https://github.com/baranwang) +- [MinLiang Zeng](https://github.com/zenml/) +- [Garfield Lee](https://github.com/Garfield550) +- [Mr.Hope](https://github.com/Mister-Hope) +- [chs97](https://github.com/chs97) +- [Jelf](https://github.com/okxiaoliang4) +- [xieyuhang](https://github.com/haiya6) +- [苏杰豪](https://github.com/Megasu) +- [Yang Mingshan](https://github.com/yangmingshan) +- [lvzl](https://github.com/lv-z-l) + ### Automated tests We use [`tsd`](https://github.com/SamVerschueren/tsd) to check if this definition is working properly. All test cases are under folder `test`. diff --git a/README.md b/README.md index 1ca655c..e2756af 100644 --- a/README.md +++ b/README.md @@ -2,29 +2,40 @@ > [English version](./README-en.md) +[![已在 DefinitelyTyped 发布](https://img.shields.io/npm/v/@types/wechat-miniprogram?label=%40types)](https://www.npmjs.com/package/@types/wechat-miniprogram) [![已在 NPM 发布](https://img.shields.io/npm/v/miniprogram-api-typings.svg?style=flat)](https://www.npmjs.com/package/miniprogram-api-typings) [![MIT 协议](https://img.shields.io/github/license/wechat-miniprogram/api-typings.svg)](https://github.com/wechat-miniprogram/api-typings) -[![Travis CI 测试状况](https://travis-ci.org/wechat-miniprogram/api-typings.svg?branch=master)](https://travis-ci.org/wechat-miniprogram/api-typings) +[![GitHub Actions 测试状况](https://github.com/wechat-miniprogram/api-typings/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/wechat-miniprogram/api-typings/actions/workflows/test.yml) 微信小程序 API 的 TypeScript 类型定义文件 ## 安装 -通过 npm 安装: +### 通过独立 npm 包 + ```bash -# 安装对应最新基础库的定义文件 npm install miniprogram-api-typings ``` -或者通过版本号指定一个基础库版本: -```bash -# 安装对应基础库版本 2.4.1 的定义文件 -npm install miniprogram-api-typings@2.4.1 -``` +安装后手动导入: + +- `import 'miniprogram-api-typings';` + +或者在 ts 配置中指定: + +- 在 `tsconfig.json` 中指定 `types: ["miniprogram-api-typings"]` -## 版本 +或者通过 [三斜杠指令](https://www.tslang.cn/docs/handbook/triple-slash-directives.html) 引用: -所有可用的版本和对应的基础库版本,参考 [VERSIONS.md](https://github.com/wechat-miniprogram/api-typings/blob/master/VERSIONS.md) +- `/// ` + +或: + +### 通过 DefinitelyTyped + +```bash +npm install @types/wechat-miniprogram +``` ## 更新日志 @@ -32,10 +43,23 @@ npm install miniprogram-api-typings@2.4.1 ## 贡献 -API 的定义文件(`lib.wx.api.d.ts`)是随 [文档](https://developers.weixin.qq.com/miniprogram/dev/index.html) 一起自动生成的,如果发现了 API 接口的定义错误,请提一个 issue 给我们,关于 API 的 PR 将 __不会__ 被接受。 +API 的定义文件(`lib.wx.api.d.ts`)是随 [文档](https://developers.weixin.qq.com/miniprogram/dev/api/) 一起自动生成的,如果发现了 API 接口的定义错误,请提一个 issue 给我们,关于 API 的 PR 将 __不会__ 被接受。 如果有针对页面(`Page`)、自定义组件(`Component`)等接口的 bug 和建议,欢迎 PR 或提一个 issue 给我们。非常感谢! +### 贡献者 + +- [Baran](https://github.com/baranwang) +- [MinLiang Zeng](https://github.com/zenml/) +- [Garfield Lee](https://github.com/Garfield550) +- [Mr.Hope](https://github.com/Mister-Hope) +- [chs97](https://github.com/chs97) +- [Jelf](https://github.com/okxiaoliang4) +- [xieyuhang](https://github.com/haiya6) +- [苏杰豪](https://github.com/Megasu) +- [Yang Mingshan](https://github.com/yangmingshan) +- [lvzl](https://github.com/lv-z-l) + ### 测试 本定义文件使用 [`tsd`](https://github.com/SamVerschueren/tsd) 进行测试,所有的测试样例放在 `test` 目录下。 diff --git a/VERSIONS.md b/VERSIONS.md deleted file mode 100644 index f40a8fc..0000000 --- a/VERSIONS.md +++ /dev/null @@ -1,19 +0,0 @@ -## 所有可用版本 - -基础库版本|npm 版本|命令 --|-|- -[v2.10.0](https://developers.weixin.qq.com/miniprogram/dev/framework/release/#v2-10-0-2019-12-24) | [2.10.0](https://www.npmjs.com/package/miniprogram-api-typings/v/2.10.0) | `npm install miniprogram-api-typings@2.10.0` -[v2.9.4](https://developers.weixin.qq.com/miniprogram/dev/framework/release/#v2-9-4-2019-11-28) | [2.9.4](https://www.npmjs.com/package/miniprogram-api-typings/v/2.9.4) | `npm install miniprogram-api-typings@2.9.4` -[v2.9.3](https://developers.weixin.qq.com/miniprogram/dev/framework/release/) | [2.9.3](https://www.npmjs.com/package/miniprogram-api-typings/v/2.9.3) | `npm install miniprogram-api-typings@2.9.3` -[v2.9.2](https://developers.weixin.qq.com/miniprogram/dev/framework/release/#v2-9-2-2019-11-04) | [2.9.2](https://www.npmjs.com/package/miniprogram-api-typings/v/2.9.2) | `npm install miniprogram-api-typings@2.9.2` -[v2.9.1](https://developers.weixin.qq.com/miniprogram/dev/framework/release/#v2-9-1-2019-10-29) | [2.9.1](https://www.npmjs.com/package/miniprogram-api-typings/v/2.9.1) | `npm install miniprogram-api-typings@2.9.1` -[v2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/release/#v2-9-0-2019-10-09) | [2.9.0](https://www.npmjs.com/package/miniprogram-api-typings/v/2.9.0) | `npm install miniprogram-api-typings@2.9.0` -[v2.8.3](https://developers.weixin.qq.com/miniprogram/dev/framework/release/#v2-8-3-2019-09-17) | [2.8.3-1](https://www.npmjs.com/package/miniprogram-api-typings/v/2.8.3-1) | `npm install miniprogram-api-typings@2.8.3-1` -[v2.8.2](https://developers.weixin.qq.com/miniprogram/dev/framework/release/#v2-8-2-2019-08-30) | [2.8.2](https://www.npmjs.com/package/miniprogram-api-typings/v/2.8.2) | `npm install miniprogram-api-typings@2.8.2` -[v2.8.1](https://developers.weixin.qq.com/miniprogram/dev/framework/release/#v2-8-1-2019-08-22) | [2.8.1](https://www.npmjs.com/package/miniprogram-api-typings/v/2.8.1) | `npm install miniprogram-api-typings@2.8.1` -[v2.8.0](https://developers.weixin.qq.com/miniprogram/dev/framework/release/#v2-8-0-2019-07-30) | [2.8.0-2](https://www.npmjs.com/package/miniprogram-api-typings/v/2.8.0-2) | `npm install miniprogram-api-typings@2.8.0-2` -[v2.7.7](https://developers.weixin.qq.com/miniprogram/dev/framework/release/) | [2.7.7-2](https://www.npmjs.com/package/miniprogram-api-typings/v/2.7.7-2) | `npm install miniprogram-api-typings@2.7.7-2` -[v2.6.5](https://developers.weixin.qq.com/miniprogram/dev/framework/release/#v2-6-5-2019-04-02) | [2.6.5-2](https://www.npmjs.com/package/miniprogram-api-typings/v/2.6.5-2) | `npm install miniprogram-api-typings@2.6.5-2` -[v2.4.2](https://developers.weixin.qq.com/miniprogram/dev/framework/release/v2.html#v2-4-2-2018-12-04)|[2.4.2-2](https://www.npmjs.com/package/miniprogram-api-typings/v/2.4.2-2)|`npm install miniprogram-api-typings@2.4.2-2` -[v2.4.1](https://developers.weixin.qq.com/miniprogram/dev/framework/release/v2.html#v2-4-1-2018-11-21)|[2.4.1](https://www.npmjs.com/package/miniprogram-api-typings/v/2.4.1)|`npm install miniprogram-api-typings@2.4.1` -[v2.4.0](https://developers.weixin.qq.com/miniprogram/dev/framework/release/v2.html#v2-4-0-2018-11-05)|[2.4.0-1](https://www.npmjs.com/package/miniprogram-api-typings/v/2.4.0-1)|`npm install miniprogram-api-typings@2.4.0-1` \ No newline at end of file diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 8f558f3..0000000 --- a/package-lock.json +++ /dev/null @@ -1,2545 +0,0 @@ -{ - "name": "miniprogram-api-typings", - "version": "2.10.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@babel/code-frame": { - "version": "7.5.5", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", - "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", - "dev": true, - "requires": { - "@babel/highlight": "^7.0.0" - } - }, - "@babel/highlight": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", - "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", - "dev": true, - "requires": { - "chalk": "^2.0.0", - "esutils": "^2.0.2", - "js-tokens": "^4.0.0" - } - }, - "@mrmlnc/readdir-enhanced": { - "version": "2.2.1", - "resolved": "http://r.tnpm.oa.com/@mrmlnc/readdir-enhanced/download/@mrmlnc/readdir-enhanced-2.2.1.tgz", - "integrity": "sha1-UkryQNGjYFJ7cwR17PoTRKpUDd4=", - "dev": true, - "requires": { - "call-me-maybe": "^1.0.1", - "glob-to-regexp": "^0.3.0" - } - }, - "@nodelib/fs.stat": { - "version": "1.1.3", - "resolved": "http://r.tnpm.oa.com/@nodelib/fs.stat/download/@nodelib/fs.stat-1.1.3.tgz", - "integrity": "sha1-K1o6s/kYzKSKjHVMCBaOPwPrphs=", - "dev": true - }, - "@types/events": { - "version": "3.0.0", - "resolved": "http://r.tnpm.oa.com/@types/events/download/@types/events-3.0.0.tgz", - "integrity": "sha1-KGLz9Yqaf3w+eNefEw3U1xwlwqc=", - "dev": true - }, - "@types/glob": { - "version": "7.1.1", - "resolved": "http://r.tnpm.oa.com/@types/glob/download/@types/glob-7.1.1.tgz", - "integrity": "sha1-qlmhxuP7xCHgfM0xqUTDDrpSFXU=", - "dev": true, - "requires": { - "@types/events": "*", - "@types/minimatch": "*", - "@types/node": "*" - } - }, - "@types/minimatch": { - "version": "3.0.3", - "resolved": "http://r.tnpm.oa.com/@types/minimatch/download/@types/minimatch-3.0.3.tgz", - "integrity": "sha1-PcoOPzOyAPx9ETnAzZbBJoyt/Z0=", - "dev": true - }, - "@types/node": { - "version": "12.12.14", - "resolved": "http://r.tnpm.oa.com/@types/node/download/@types/node-12.12.14.tgz", - "integrity": "sha1-HB1uPHXbpGbgMmlI1W6L1yoZA9I=", - "dev": true - }, - "ansi-align": { - "version": "2.0.0", - "resolved": "http://r.tnpm.oa.com/ansi-align/download/ansi-align-2.0.0.tgz", - "integrity": "sha1-w2rsy6VjuJzrVW82kPCx2eNUf38=", - "dev": true, - "requires": { - "string-width": "^2.0.0" - } - }, - "ansi-escapes": { - "version": "2.0.0", - "resolved": "http://r.tnpm.oa.com/ansi-escapes/download/ansi-escapes-2.0.0.tgz", - "integrity": "sha1-W65SvkJIeN2Xg+iRDj/Cki6DyBs=", - "dev": true - }, - "ansi-regex": { - "version": "3.0.0", - "resolved": "http://r.tnpm.oa.com/ansi-regex/download/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, - "requires": { - "sprintf-js": "~1.0.2" - } - }, - "arr-diff": { - "version": "4.0.0", - "resolved": "http://r.tnpm.oa.com/arr-diff/download/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true - }, - "arr-flatten": { - "version": "1.1.0", - "resolved": "http://r.tnpm.oa.com/arr-flatten/download/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", - "dev": true - }, - "arr-union": { - "version": "3.1.0", - "resolved": "http://r.tnpm.oa.com/arr-union/download/arr-union-3.1.0.tgz", - "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "dev": true - }, - "array-find-index": { - "version": "1.0.2", - "resolved": "http://r.tnpm.oa.com/array-find-index/download/array-find-index-1.0.2.tgz", - "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=", - "dev": true - }, - "array-union": { - "version": "1.0.2", - "resolved": "http://r.tnpm.oa.com/array-union/download/array-union-1.0.2.tgz", - "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", - "dev": true, - "requires": { - "array-uniq": "^1.0.1" - } - }, - "array-uniq": { - "version": "1.0.3", - "resolved": "http://r.tnpm.oa.com/array-uniq/download/array-uniq-1.0.3.tgz", - "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", - "dev": true - }, - "array-unique": { - "version": "0.3.2", - "resolved": "http://r.tnpm.oa.com/array-unique/download/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true - }, - "arrify": { - "version": "1.0.1", - "resolved": "http://r.tnpm.oa.com/arrify/download/arrify-1.0.1.tgz", - "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", - "dev": true - }, - "assign-symbols": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/assign-symbols/download/assign-symbols-1.0.0.tgz", - "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", - "dev": true - }, - "atob": { - "version": "2.1.2", - "resolved": "http://r.tnpm.oa.com/atob/download/atob-2.1.2.tgz", - "integrity": "sha1-bZUX654DDSQ2ZmZR6GvZ9vE1M8k=", - "dev": true - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true - }, - "base": { - "version": "0.11.2", - "resolved": "http://r.tnpm.oa.com/base/download/base-0.11.2.tgz", - "integrity": "sha1-e95c7RRbbVUakNuH+DxVi060io8=", - "dev": true, - "requires": { - "cache-base": "^1.0.1", - "class-utils": "^0.3.5", - "component-emitter": "^1.2.1", - "define-property": "^1.0.0", - "isobject": "^3.0.1", - "mixin-deep": "^1.2.0", - "pascalcase": "^0.1.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/define-property/download/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/is-accessor-descriptor/download/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha1-FpwvbT3x+ZJhgHI2XJsOofaHhlY=", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/is-data-descriptor/download/is-data-descriptor-1.0.0.tgz", - "integrity": "sha1-2Eh2Mh0Oet0DmQQGq7u9NrqSaMc=", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "http://r.tnpm.oa.com/is-descriptor/download/is-descriptor-1.0.2.tgz", - "integrity": "sha1-OxWXRqZmBLBPjIFSS6NlxfFNhuw=", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, - "boxen": { - "version": "1.3.0", - "resolved": "http://r.tnpm.oa.com/boxen/download/boxen-1.3.0.tgz", - "integrity": "sha1-VcbDmouljZxhrSLNh3Uy3rZlogs=", - "dev": true, - "requires": { - "ansi-align": "^2.0.0", - "camelcase": "^4.0.0", - "chalk": "^2.0.1", - "cli-boxes": "^1.0.0", - "string-width": "^2.0.0", - "term-size": "^1.2.0", - "widest-line": "^2.0.0" - } - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "braces": { - "version": "2.3.2", - "resolved": "http://r.tnpm.oa.com/braces/download/braces-2.3.2.tgz", - "integrity": "sha1-WXn9PxTNUxVl5fot8av/8d+u5yk=", - "dev": true, - "requires": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "http://r.tnpm.oa.com/extend-shallow/download/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "builtin-modules": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", - "dev": true - }, - "cache-base": { - "version": "1.0.1", - "resolved": "http://r.tnpm.oa.com/cache-base/download/cache-base-1.0.1.tgz", - "integrity": "sha1-Cn9GQWgxyLZi7jb+TnxZ129marI=", - "dev": true, - "requires": { - "collection-visit": "^1.0.0", - "component-emitter": "^1.2.1", - "get-value": "^2.0.6", - "has-value": "^1.0.0", - "isobject": "^3.0.1", - "set-value": "^2.0.0", - "to-object-path": "^0.3.0", - "union-value": "^1.0.0", - "unset-value": "^1.0.0" - } - }, - "call-me-maybe": { - "version": "1.0.1", - "resolved": "http://r.tnpm.oa.com/call-me-maybe/download/call-me-maybe-1.0.1.tgz", - "integrity": "sha1-JtII6onje1y95gJQoV8DHBak1ms=", - "dev": true - }, - "camelcase": { - "version": "4.1.0", - "resolved": "http://r.tnpm.oa.com/camelcase/download/camelcase-4.1.0.tgz", - "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", - "dev": true - }, - "camelcase-keys": { - "version": "4.2.0", - "resolved": "http://r.tnpm.oa.com/camelcase-keys/download/camelcase-keys-4.2.0.tgz", - "integrity": "sha1-oqpfsa9oh1glnDLBQUJteJI7m3c=", - "dev": true, - "requires": { - "camelcase": "^4.1.0", - "map-obj": "^2.0.0", - "quick-lru": "^1.0.0" - } - }, - "capture-stack-trace": { - "version": "1.0.1", - "resolved": "http://r.tnpm.oa.com/capture-stack-trace/download/capture-stack-trace-1.0.1.tgz", - "integrity": "sha1-psC74fOPOqC5Ijjstv9Cw0TUE10=", - "dev": true - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "ci-info": { - "version": "1.6.0", - "resolved": "http://r.tnpm.oa.com/ci-info/download/ci-info-1.6.0.tgz", - "integrity": "sha1-LKINu5zrMtRSSmgzAzE/AwSx5Jc=", - "dev": true - }, - "class-utils": { - "version": "0.3.6", - "resolved": "http://r.tnpm.oa.com/class-utils/download/class-utils-0.3.6.tgz", - "integrity": "sha1-+TNprouafOAv1B+q0MqDAzGQxGM=", - "dev": true, - "requires": { - "arr-union": "^3.1.0", - "define-property": "^0.2.5", - "isobject": "^3.0.0", - "static-extend": "^0.1.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "http://r.tnpm.oa.com/define-property/download/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - } - } - }, - "cli-boxes": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/cli-boxes/download/cli-boxes-1.0.0.tgz", - "integrity": "sha1-T6kXw+WclKAEzWH47lCdplFocUM=", - "dev": true - }, - "collection-visit": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/collection-visit/download/collection-visit-1.0.0.tgz", - "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", - "dev": true, - "requires": { - "map-visit": "^1.0.0", - "object-visit": "^1.0.0" - } - }, - "color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "requires": { - "color-name": "1.1.3" - } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true - }, - "commander": { - "version": "2.20.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.1.tgz", - "integrity": "sha512-cCuLsMhJeWQ/ZpsFTbE765kvVfoeSddc4nU3up4fV+fDBcfUXnbITJ+JzhkdjzOqhURjZgujxaioam4RM9yGUg==", - "dev": true - }, - "component-emitter": { - "version": "1.3.0", - "resolved": "http://r.tnpm.oa.com/component-emitter/download/component-emitter-1.3.0.tgz", - "integrity": "sha1-FuQHD7qK4ptnnyIVhT7hgasuq8A=", - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "configstore": { - "version": "3.1.2", - "resolved": "http://r.tnpm.oa.com/configstore/download/configstore-3.1.2.tgz", - "integrity": "sha1-xvJd767vJt8S3TNBSwAf6BpUP48=", - "dev": true, - "requires": { - "dot-prop": "^4.1.0", - "graceful-fs": "^4.1.2", - "make-dir": "^1.0.0", - "unique-string": "^1.0.0", - "write-file-atomic": "^2.0.0", - "xdg-basedir": "^3.0.0" - } - }, - "copy-descriptor": { - "version": "0.1.1", - "resolved": "http://r.tnpm.oa.com/copy-descriptor/download/copy-descriptor-0.1.1.tgz", - "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", - "dev": true - }, - "create-error-class": { - "version": "3.0.2", - "resolved": "http://r.tnpm.oa.com/create-error-class/download/create-error-class-3.0.2.tgz", - "integrity": "sha1-Br56vvlHo/FKMP1hBnHUAbyot7Y=", - "dev": true, - "requires": { - "capture-stack-trace": "^1.0.0" - } - }, - "cross-spawn": { - "version": "5.1.0", - "resolved": "http://r.tnpm.oa.com/cross-spawn/download/cross-spawn-5.1.0.tgz", - "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", - "dev": true, - "requires": { - "lru-cache": "^4.0.1", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - } - }, - "crypto-random-string": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/crypto-random-string/download/crypto-random-string-1.0.0.tgz", - "integrity": "sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=", - "dev": true - }, - "currently-unhandled": { - "version": "0.4.1", - "resolved": "http://r.tnpm.oa.com/currently-unhandled/download/currently-unhandled-0.4.1.tgz", - "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=", - "dev": true, - "requires": { - "array-find-index": "^1.0.1" - } - }, - "debug": { - "version": "2.6.9", - "resolved": "http://r.tnpm.oa.com/debug/download/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "decamelize": { - "version": "1.2.0", - "resolved": "http://r.tnpm.oa.com/decamelize/download/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "dev": true - }, - "decamelize-keys": { - "version": "1.1.0", - "resolved": "http://r.tnpm.oa.com/decamelize-keys/download/decamelize-keys-1.1.0.tgz", - "integrity": "sha1-0XGoeTMlKAfrPLYdwcFEXQeN8tk=", - "dev": true, - "requires": { - "decamelize": "^1.1.0", - "map-obj": "^1.0.0" - }, - "dependencies": { - "map-obj": { - "version": "1.0.1", - "resolved": "http://r.tnpm.oa.com/map-obj/download/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", - "dev": true - } - } - }, - "decode-uri-component": { - "version": "0.2.0", - "resolved": "http://r.tnpm.oa.com/decode-uri-component/download/decode-uri-component-0.2.0.tgz", - "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", - "dev": true - }, - "deep-extend": { - "version": "0.6.0", - "resolved": "http://r.tnpm.oa.com/deep-extend/download/deep-extend-0.6.0.tgz", - "integrity": "sha1-xPp8lUBKF6nD6Mp+FTcxK3NjMKw=", - "dev": true - }, - "define-property": { - "version": "2.0.2", - "resolved": "http://r.tnpm.oa.com/define-property/download/define-property-2.0.2.tgz", - "integrity": "sha1-1Flono1lS6d+AqgX+HENcCyxbp0=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.2", - "isobject": "^3.0.1" - }, - "dependencies": { - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/is-accessor-descriptor/download/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha1-FpwvbT3x+ZJhgHI2XJsOofaHhlY=", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/is-data-descriptor/download/is-data-descriptor-1.0.0.tgz", - "integrity": "sha1-2Eh2Mh0Oet0DmQQGq7u9NrqSaMc=", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "http://r.tnpm.oa.com/is-descriptor/download/is-descriptor-1.0.2.tgz", - "integrity": "sha1-OxWXRqZmBLBPjIFSS6NlxfFNhuw=", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, - "diff": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", - "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==", - "dev": true - }, - "dir-glob": { - "version": "2.2.2", - "resolved": "http://r.tnpm.oa.com/dir-glob/download/dir-glob-2.2.2.tgz", - "integrity": "sha1-+gnwaUFTyJGLGLoN6vrpR2n8UMQ=", - "dev": true, - "requires": { - "path-type": "^3.0.0" - } - }, - "dot-prop": { - "version": "4.2.0", - "resolved": "http://r.tnpm.oa.com/dot-prop/download/dot-prop-4.2.0.tgz", - "integrity": "sha1-HxngwuGqDjJ5fEl5nyg3rGr2nFc=", - "dev": true, - "requires": { - "is-obj": "^1.0.0" - } - }, - "duplexer3": { - "version": "0.1.4", - "resolved": "http://r.tnpm.oa.com/duplexer3/download/duplexer3-0.1.4.tgz", - "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=", - "dev": true - }, - "error-ex": { - "version": "1.3.2", - "resolved": "http://r.tnpm.oa.com/error-ex/download/error-ex-1.3.2.tgz", - "integrity": "sha1-tKxAZIEH/c3PriQvQovqihTU8b8=", - "dev": true, - "requires": { - "is-arrayish": "^0.2.1" - } - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - }, - "eslint-formatter-pretty": { - "version": "1.3.0", - "resolved": "http://r.tnpm.oa.com/eslint-formatter-pretty/download/eslint-formatter-pretty-1.3.0.tgz", - "integrity": "sha1-mF2eQcH4R19KCQxdvS388oIdYH4=", - "dev": true, - "requires": { - "ansi-escapes": "^2.0.0", - "chalk": "^2.1.0", - "log-symbols": "^2.0.0", - "plur": "^2.1.2", - "string-width": "^2.0.0" - } - }, - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true - }, - "esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true - }, - "execa": { - "version": "0.7.0", - "resolved": "http://r.tnpm.oa.com/execa/download/execa-0.7.0.tgz", - "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", - "dev": true, - "requires": { - "cross-spawn": "^5.0.1", - "get-stream": "^3.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" - } - }, - "expand-brackets": { - "version": "2.1.4", - "resolved": "http://r.tnpm.oa.com/expand-brackets/download/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "dev": true, - "requires": { - "debug": "^2.3.3", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "posix-character-classes": "^0.1.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "http://r.tnpm.oa.com/define-property/download/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "http://r.tnpm.oa.com/extend-shallow/download/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "extend-shallow": { - "version": "3.0.2", - "resolved": "http://r.tnpm.oa.com/extend-shallow/download/extend-shallow-3.0.2.tgz", - "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", - "dev": true, - "requires": { - "assign-symbols": "^1.0.0", - "is-extendable": "^1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "http://r.tnpm.oa.com/is-extendable/download/is-extendable-1.0.1.tgz", - "integrity": "sha1-p0cPnkJnM9gb2B4RVSZOOjUHyrQ=", - "dev": true, - "requires": { - "is-plain-object": "^2.0.4" - } - } - } - }, - "extglob": { - "version": "2.0.4", - "resolved": "http://r.tnpm.oa.com/extglob/download/extglob-2.0.4.tgz", - "integrity": "sha1-rQD+TcYSqSMuhxhxHcXLWrAoVUM=", - "dev": true, - "requires": { - "array-unique": "^0.3.2", - "define-property": "^1.0.0", - "expand-brackets": "^2.1.4", - "extend-shallow": "^2.0.1", - "fragment-cache": "^0.2.1", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/define-property/download/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "http://r.tnpm.oa.com/extend-shallow/download/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/is-accessor-descriptor/download/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha1-FpwvbT3x+ZJhgHI2XJsOofaHhlY=", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/is-data-descriptor/download/is-data-descriptor-1.0.0.tgz", - "integrity": "sha1-2Eh2Mh0Oet0DmQQGq7u9NrqSaMc=", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "http://r.tnpm.oa.com/is-descriptor/download/is-descriptor-1.0.2.tgz", - "integrity": "sha1-OxWXRqZmBLBPjIFSS6NlxfFNhuw=", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, - "fast-glob": { - "version": "2.2.7", - "resolved": "http://r.tnpm.oa.com/fast-glob/download/fast-glob-2.2.7.tgz", - "integrity": "sha1-aVOFfDr6R1//ku5gFdUtpwpM050=", - "dev": true, - "requires": { - "@mrmlnc/readdir-enhanced": "^2.2.1", - "@nodelib/fs.stat": "^1.1.2", - "glob-parent": "^3.1.0", - "is-glob": "^4.0.0", - "merge2": "^1.2.3", - "micromatch": "^3.1.10" - } - }, - "fill-range": { - "version": "4.0.0", - "resolved": "http://r.tnpm.oa.com/fill-range/download/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "http://r.tnpm.oa.com/extend-shallow/download/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "find-up": { - "version": "2.1.0", - "resolved": "http://r.tnpm.oa.com/find-up/download/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "dev": true, - "requires": { - "locate-path": "^2.0.0" - } - }, - "for-in": { - "version": "1.0.2", - "resolved": "http://r.tnpm.oa.com/for-in/download/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true - }, - "fragment-cache": { - "version": "0.2.1", - "resolved": "http://r.tnpm.oa.com/fragment-cache/download/fragment-cache-0.2.1.tgz", - "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", - "dev": true, - "requires": { - "map-cache": "^0.2.2" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "get-stream": { - "version": "3.0.0", - "resolved": "http://r.tnpm.oa.com/get-stream/download/get-stream-3.0.0.tgz", - "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", - "dev": true - }, - "get-value": { - "version": "2.0.6", - "resolved": "http://r.tnpm.oa.com/get-value/download/get-value-2.0.6.tgz", - "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", - "dev": true - }, - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "glob-parent": { - "version": "3.1.0", - "resolved": "http://r.tnpm.oa.com/glob-parent/download/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", - "dev": true, - "requires": { - "is-glob": "^3.1.0", - "path-dirname": "^1.0.0" - }, - "dependencies": { - "is-glob": { - "version": "3.1.0", - "resolved": "http://r.tnpm.oa.com/is-glob/download/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "dev": true, - "requires": { - "is-extglob": "^2.1.0" - } - } - } - }, - "glob-to-regexp": { - "version": "0.3.0", - "resolved": "http://r.tnpm.oa.com/glob-to-regexp/download/glob-to-regexp-0.3.0.tgz", - "integrity": "sha1-jFoUlNIGbFcMw7/kSWF1rMTVAqs=", - "dev": true - }, - "global-dirs": { - "version": "0.1.1", - "resolved": "http://r.tnpm.oa.com/global-dirs/download/global-dirs-0.1.1.tgz", - "integrity": "sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU=", - "dev": true, - "requires": { - "ini": "^1.3.4" - } - }, - "globby": { - "version": "9.2.0", - "resolved": "http://r.tnpm.oa.com/globby/download/globby-9.2.0.tgz", - "integrity": "sha1-/QKacGxwPSm90XD0tts6P3p8tj0=", - "dev": true, - "requires": { - "@types/glob": "^7.1.1", - "array-union": "^1.0.2", - "dir-glob": "^2.2.2", - "fast-glob": "^2.2.6", - "glob": "^7.1.3", - "ignore": "^4.0.3", - "pify": "^4.0.1", - "slash": "^2.0.0" - } - }, - "got": { - "version": "6.7.1", - "resolved": "http://r.tnpm.oa.com/got/download/got-6.7.1.tgz", - "integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=", - "dev": true, - "requires": { - "create-error-class": "^3.0.0", - "duplexer3": "^0.1.4", - "get-stream": "^3.0.0", - "is-redirect": "^1.0.0", - "is-retry-allowed": "^1.0.0", - "is-stream": "^1.0.0", - "lowercase-keys": "^1.0.0", - "safe-buffer": "^5.0.1", - "timed-out": "^4.0.0", - "unzip-response": "^2.0.1", - "url-parse-lax": "^1.0.0" - } - }, - "graceful-fs": { - "version": "4.2.3", - "resolved": "http://r.tnpm.oa.com/graceful-fs/download/graceful-fs-4.2.3.tgz", - "integrity": "sha1-ShL/G2A3bvCYYsIJPt2Qgyi+hCM=", - "dev": true - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "has-value": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/has-value/download/has-value-1.0.0.tgz", - "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", - "dev": true, - "requires": { - "get-value": "^2.0.6", - "has-values": "^1.0.0", - "isobject": "^3.0.0" - } - }, - "has-values": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/has-values/download/has-values-1.0.0.tgz", - "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", - "dev": true, - "requires": { - "is-number": "^3.0.0", - "kind-of": "^4.0.0" - }, - "dependencies": { - "kind-of": { - "version": "4.0.0", - "resolved": "http://r.tnpm.oa.com/kind-of/download/kind-of-4.0.0.tgz", - "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "hosted-git-info": { - "version": "2.8.5", - "resolved": "http://r.tnpm.oa.com/hosted-git-info/download/hosted-git-info-2.8.5.tgz", - "integrity": "sha1-dZz88sTRVq3lmwst+r3cQqa5xww=", - "dev": true - }, - "ignore": { - "version": "4.0.6", - "resolved": "http://r.tnpm.oa.com/ignore/download/ignore-4.0.6.tgz", - "integrity": "sha1-dQ49tYYgh7RzfrrIIH/9HvJ7Jfw=", - "dev": true - }, - "import-lazy": { - "version": "2.1.0", - "resolved": "http://r.tnpm.oa.com/import-lazy/download/import-lazy-2.1.0.tgz", - "integrity": "sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM=", - "dev": true - }, - "imurmurhash": { - "version": "0.1.4", - "resolved": "http://r.tnpm.oa.com/imurmurhash/download/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", - "dev": true - }, - "indent-string": { - "version": "3.2.0", - "resolved": "http://r.tnpm.oa.com/indent-string/download/indent-string-3.2.0.tgz", - "integrity": "sha1-Sl/W0nzDMvN+VBmlBNu4NxBckok=", - "dev": true - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - }, - "ini": { - "version": "1.3.5", - "resolved": "http://r.tnpm.oa.com/ini/download/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", - "dev": true - }, - "irregular-plurals": { - "version": "1.4.0", - "resolved": "http://r.tnpm.oa.com/irregular-plurals/download/irregular-plurals-1.4.0.tgz", - "integrity": "sha1-LKmwM2UREYVUEvFr5dd8YqRYp2Y=", - "dev": true - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "http://r.tnpm.oa.com/is-accessor-descriptor/download/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "http://r.tnpm.oa.com/kind-of/download/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-arrayish": { - "version": "0.2.1", - "resolved": "http://r.tnpm.oa.com/is-arrayish/download/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", - "dev": true - }, - "is-buffer": { - "version": "1.1.6", - "resolved": "http://r.tnpm.oa.com/is-buffer/download/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", - "dev": true - }, - "is-ci": { - "version": "1.2.1", - "resolved": "http://r.tnpm.oa.com/is-ci/download/is-ci-1.2.1.tgz", - "integrity": "sha1-43ecjuF/zPQoSI9uKBGH8uYyhBw=", - "dev": true, - "requires": { - "ci-info": "^1.5.0" - } - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "http://r.tnpm.oa.com/is-data-descriptor/download/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "http://r.tnpm.oa.com/kind-of/download/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "http://r.tnpm.oa.com/is-descriptor/download/is-descriptor-0.1.6.tgz", - "integrity": "sha1-Nm2CQN3kh8pRgjsaufB6EKeCUco=", - "dev": true, - "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - }, - "dependencies": { - "kind-of": { - "version": "5.1.0", - "resolved": "http://r.tnpm.oa.com/kind-of/download/kind-of-5.1.0.tgz", - "integrity": "sha1-cpyR4thXt6QZofmqZWhcTDP1hF0=", - "dev": true - } - } - }, - "is-extendable": { - "version": "0.1.1", - "resolved": "http://r.tnpm.oa.com/is-extendable/download/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "dev": true - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "http://r.tnpm.oa.com/is-extglob/download/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "http://r.tnpm.oa.com/is-fullwidth-code-point/download/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "is-glob": { - "version": "4.0.1", - "resolved": "http://r.tnpm.oa.com/is-glob/download/is-glob-4.0.1.tgz", - "integrity": "sha1-dWfb6fL14kZ7x3q4PEopSCQHpdw=", - "dev": true, - "requires": { - "is-extglob": "^2.1.1" - } - }, - "is-installed-globally": { - "version": "0.1.0", - "resolved": "http://r.tnpm.oa.com/is-installed-globally/download/is-installed-globally-0.1.0.tgz", - "integrity": "sha1-Df2Y9akRFxbdU13aZJL2e/PSWoA=", - "dev": true, - "requires": { - "global-dirs": "^0.1.0", - "is-path-inside": "^1.0.0" - } - }, - "is-npm": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/is-npm/download/is-npm-1.0.0.tgz", - "integrity": "sha1-8vtjpl5JBbQGyGBydloaTceTufQ=", - "dev": true - }, - "is-number": { - "version": "3.0.0", - "resolved": "http://r.tnpm.oa.com/is-number/download/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "http://r.tnpm.oa.com/kind-of/download/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-obj": { - "version": "1.0.1", - "resolved": "http://r.tnpm.oa.com/is-obj/download/is-obj-1.0.1.tgz", - "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", - "dev": true - }, - "is-path-inside": { - "version": "1.0.1", - "resolved": "http://r.tnpm.oa.com/is-path-inside/download/is-path-inside-1.0.1.tgz", - "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", - "dev": true, - "requires": { - "path-is-inside": "^1.0.1" - } - }, - "is-plain-obj": { - "version": "1.1.0", - "resolved": "http://r.tnpm.oa.com/is-plain-obj/download/is-plain-obj-1.1.0.tgz", - "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", - "dev": true - }, - "is-plain-object": { - "version": "2.0.4", - "resolved": "http://r.tnpm.oa.com/is-plain-object/download/is-plain-object-2.0.4.tgz", - "integrity": "sha1-LBY7P6+xtgbZ0Xko8FwqHDjgdnc=", - "dev": true, - "requires": { - "isobject": "^3.0.1" - } - }, - "is-redirect": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/is-redirect/download/is-redirect-1.0.0.tgz", - "integrity": "sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ=", - "dev": true - }, - "is-retry-allowed": { - "version": "1.2.0", - "resolved": "http://r.tnpm.oa.com/is-retry-allowed/download/is-retry-allowed-1.2.0.tgz", - "integrity": "sha1-13hIi9CkZmo76KFIK58rqv7eqLQ=", - "dev": true - }, - "is-stream": { - "version": "1.1.0", - "resolved": "http://r.tnpm.oa.com/is-stream/download/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", - "dev": true - }, - "is-windows": { - "version": "1.0.2", - "resolved": "http://r.tnpm.oa.com/is-windows/download/is-windows-1.0.2.tgz", - "integrity": "sha1-0YUOuXkezRjmGCzhKjDzlmNLsZ0=", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/isarray/download/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "isexe": { - "version": "2.0.0", - "resolved": "http://r.tnpm.oa.com/isexe/download/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true - }, - "isobject": { - "version": "3.0.1", - "resolved": "http://r.tnpm.oa.com/isobject/download/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - }, - "js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true - }, - "js-yaml": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", - "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", - "dev": true, - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, - "json-parse-better-errors": { - "version": "1.0.2", - "resolved": "http://r.tnpm.oa.com/json-parse-better-errors/download/json-parse-better-errors-1.0.2.tgz", - "integrity": "sha1-u4Z8+zRQ5pEHwTHRxRS6s9yLyqk=", - "dev": true - }, - "kind-of": { - "version": "6.0.2", - "resolved": "http://r.tnpm.oa.com/kind-of/download/kind-of-6.0.2.tgz", - "integrity": "sha1-ARRrNqYhjmTljzqNZt5df8b20FE=", - "dev": true - }, - "latest-version": { - "version": "3.1.0", - "resolved": "http://r.tnpm.oa.com/latest-version/download/latest-version-3.1.0.tgz", - "integrity": "sha1-ogU4P+oyKzO1rjsYq+4NwvNW7hU=", - "dev": true, - "requires": { - "package-json": "^4.0.0" - } - }, - "load-json-file": { - "version": "4.0.0", - "resolved": "http://r.tnpm.oa.com/load-json-file/download/load-json-file-4.0.0.tgz", - "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0", - "strip-bom": "^3.0.0" - }, - "dependencies": { - "pify": { - "version": "3.0.0", - "resolved": "http://r.tnpm.oa.com/pify/download/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true - } - } - }, - "locate-path": { - "version": "2.0.0", - "resolved": "http://r.tnpm.oa.com/locate-path/download/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", - "dev": true, - "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" - } - }, - "log-symbols": { - "version": "2.2.0", - "resolved": "http://r.tnpm.oa.com/log-symbols/download/log-symbols-2.2.0.tgz", - "integrity": "sha1-V0Dhxdbw39pK2TI7UzIQfva0xAo=", - "dev": true, - "requires": { - "chalk": "^2.0.1" - } - }, - "loud-rejection": { - "version": "1.6.0", - "resolved": "http://r.tnpm.oa.com/loud-rejection/download/loud-rejection-1.6.0.tgz", - "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=", - "dev": true, - "requires": { - "currently-unhandled": "^0.4.1", - "signal-exit": "^3.0.0" - } - }, - "lowercase-keys": { - "version": "1.0.1", - "resolved": "http://r.tnpm.oa.com/lowercase-keys/download/lowercase-keys-1.0.1.tgz", - "integrity": "sha1-b54wtHCE2XGnyCD/FabFFnt0wm8=", - "dev": true - }, - "lru-cache": { - "version": "4.1.5", - "resolved": "http://r.tnpm.oa.com/lru-cache/download/lru-cache-4.1.5.tgz", - "integrity": "sha1-i75Q6oW+1ZvJ4z3KuCNe6bz0Q80=", - "dev": true, - "requires": { - "pseudomap": "^1.0.2", - "yallist": "^2.1.2" - } - }, - "make-dir": { - "version": "1.3.0", - "resolved": "http://r.tnpm.oa.com/make-dir/download/make-dir-1.3.0.tgz", - "integrity": "sha1-ecEDO4BRW9bSTsmTPoYMp17ifww=", - "dev": true, - "requires": { - "pify": "^3.0.0" - }, - "dependencies": { - "pify": { - "version": "3.0.0", - "resolved": "http://r.tnpm.oa.com/pify/download/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true - } - } - }, - "map-cache": { - "version": "0.2.2", - "resolved": "http://r.tnpm.oa.com/map-cache/download/map-cache-0.2.2.tgz", - "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "dev": true - }, - "map-obj": { - "version": "2.0.0", - "resolved": "http://r.tnpm.oa.com/map-obj/download/map-obj-2.0.0.tgz", - "integrity": "sha1-plzSkIepJZi4eRJXpSPgISIqwfk=", - "dev": true - }, - "map-visit": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/map-visit/download/map-visit-1.0.0.tgz", - "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", - "dev": true, - "requires": { - "object-visit": "^1.0.0" - } - }, - "meow": { - "version": "5.0.0", - "resolved": "http://r.tnpm.oa.com/meow/download/meow-5.0.0.tgz", - "integrity": "sha1-38c9Y6mvxxSl43F2DrXIi5EHiqQ=", - "dev": true, - "requires": { - "camelcase-keys": "^4.0.0", - "decamelize-keys": "^1.0.0", - "loud-rejection": "^1.0.0", - "minimist-options": "^3.0.1", - "normalize-package-data": "^2.3.4", - "read-pkg-up": "^3.0.0", - "redent": "^2.0.0", - "trim-newlines": "^2.0.0", - "yargs-parser": "^10.0.0" - }, - "dependencies": { - "read-pkg-up": { - "version": "3.0.0", - "resolved": "http://r.tnpm.oa.com/read-pkg-up/download/read-pkg-up-3.0.0.tgz", - "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=", - "dev": true, - "requires": { - "find-up": "^2.0.0", - "read-pkg": "^3.0.0" - } - } - } - }, - "merge2": { - "version": "1.3.0", - "resolved": "http://r.tnpm.oa.com/merge2/download/merge2-1.3.0.tgz", - "integrity": "sha1-WzZu6DsvFYLEj4fkfPGpNSEDyoE=", - "dev": true - }, - "micromatch": { - "version": "3.1.10", - "resolved": "http://r.tnpm.oa.com/micromatch/download/micromatch-3.1.10.tgz", - "integrity": "sha1-cIWbyVyYQJUvNZoGij/En57PrCM=", - "dev": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "http://r.tnpm.oa.com/minimist/download/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - }, - "minimist-options": { - "version": "3.0.2", - "resolved": "http://r.tnpm.oa.com/minimist-options/download/minimist-options-3.0.2.tgz", - "integrity": "sha1-+6TIGRM54T7PTWG+sD8HAQPz2VQ=", - "dev": true, - "requires": { - "arrify": "^1.0.1", - "is-plain-obj": "^1.1.0" - } - }, - "mixin-deep": { - "version": "1.3.2", - "resolved": "http://r.tnpm.oa.com/mixin-deep/download/mixin-deep-1.3.2.tgz", - "integrity": "sha1-ESC0PcNZp4Xc5ltVuC4lfM9HlWY=", - "dev": true, - "requires": { - "for-in": "^1.0.2", - "is-extendable": "^1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "http://r.tnpm.oa.com/is-extendable/download/is-extendable-1.0.1.tgz", - "integrity": "sha1-p0cPnkJnM9gb2B4RVSZOOjUHyrQ=", - "dev": true, - "requires": { - "is-plain-object": "^2.0.4" - } - } - } - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, - "requires": { - "minimist": "0.0.8" - }, - "dependencies": { - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - } - } - }, - "ms": { - "version": "2.0.0", - "resolved": "http://r.tnpm.oa.com/ms/download/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "nanomatch": { - "version": "1.2.13", - "resolved": "http://r.tnpm.oa.com/nanomatch/download/nanomatch-1.2.13.tgz", - "integrity": "sha1-uHqKpPwN6P5r6IiVs4mD/yZb0Rk=", - "dev": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "fragment-cache": "^0.2.1", - "is-windows": "^1.0.2", - "kind-of": "^6.0.2", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - } - }, - "normalize-package-data": { - "version": "2.5.0", - "resolved": "http://r.tnpm.oa.com/normalize-package-data/download/normalize-package-data-2.5.0.tgz", - "integrity": "sha1-5m2xg4sgDB38IzIl0SyzZSDiNKg=", - "dev": true, - "requires": { - "hosted-git-info": "^2.1.4", - "resolve": "^1.10.0", - "semver": "2 || 3 || 4 || 5", - "validate-npm-package-license": "^3.0.1" - } - }, - "npm-run-path": { - "version": "2.0.2", - "resolved": "http://r.tnpm.oa.com/npm-run-path/download/npm-run-path-2.0.2.tgz", - "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", - "dev": true, - "requires": { - "path-key": "^2.0.0" - } - }, - "object-copy": { - "version": "0.1.0", - "resolved": "http://r.tnpm.oa.com/object-copy/download/object-copy-0.1.0.tgz", - "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", - "dev": true, - "requires": { - "copy-descriptor": "^0.1.0", - "define-property": "^0.2.5", - "kind-of": "^3.0.3" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "http://r.tnpm.oa.com/define-property/download/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "kind-of": { - "version": "3.2.2", - "resolved": "http://r.tnpm.oa.com/kind-of/download/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "object-visit": { - "version": "1.0.1", - "resolved": "http://r.tnpm.oa.com/object-visit/download/object-visit-1.0.1.tgz", - "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", - "dev": true, - "requires": { - "isobject": "^3.0.0" - } - }, - "object.pick": { - "version": "1.3.0", - "resolved": "http://r.tnpm.oa.com/object.pick/download/object.pick-1.3.0.tgz", - "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", - "dev": true, - "requires": { - "isobject": "^3.0.1" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1" - } - }, - "p-finally": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/p-finally/download/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", - "dev": true - }, - "p-limit": { - "version": "1.3.0", - "resolved": "http://r.tnpm.oa.com/p-limit/download/p-limit-1.3.0.tgz", - "integrity": "sha1-uGvV8MJWkJEcdZD8v8IBDVSzzLg=", - "dev": true, - "requires": { - "p-try": "^1.0.0" - } - }, - "p-locate": { - "version": "2.0.0", - "resolved": "http://r.tnpm.oa.com/p-locate/download/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", - "dev": true, - "requires": { - "p-limit": "^1.1.0" - } - }, - "p-try": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/p-try/download/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", - "dev": true - }, - "package-json": { - "version": "4.0.1", - "resolved": "http://r.tnpm.oa.com/package-json/download/package-json-4.0.1.tgz", - "integrity": "sha1-iGmgQBJTZhxMTKPabCEh7VVfXu0=", - "dev": true, - "requires": { - "got": "^6.7.1", - "registry-auth-token": "^3.0.1", - "registry-url": "^3.0.3", - "semver": "^5.1.0" - } - }, - "parse-json": { - "version": "4.0.0", - "resolved": "http://r.tnpm.oa.com/parse-json/download/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "dev": true, - "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - } - }, - "pascalcase": { - "version": "0.1.1", - "resolved": "http://r.tnpm.oa.com/pascalcase/download/pascalcase-0.1.1.tgz", - "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", - "dev": true - }, - "path-dirname": { - "version": "1.0.2", - "resolved": "http://r.tnpm.oa.com/path-dirname/download/path-dirname-1.0.2.tgz", - "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", - "dev": true - }, - "path-exists": { - "version": "3.0.0", - "resolved": "http://r.tnpm.oa.com/path-exists/download/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "path-is-inside": { - "version": "1.0.2", - "resolved": "http://r.tnpm.oa.com/path-is-inside/download/path-is-inside-1.0.2.tgz", - "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", - "dev": true - }, - "path-key": { - "version": "2.0.1", - "resolved": "http://r.tnpm.oa.com/path-key/download/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", - "dev": true - }, - "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", - "dev": true - }, - "path-type": { - "version": "3.0.0", - "resolved": "http://r.tnpm.oa.com/path-type/download/path-type-3.0.0.tgz", - "integrity": "sha1-zvMdyOCho7sNEFwM2Xzzv0f0428=", - "dev": true, - "requires": { - "pify": "^3.0.0" - }, - "dependencies": { - "pify": { - "version": "3.0.0", - "resolved": "http://r.tnpm.oa.com/pify/download/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true - } - } - }, - "pify": { - "version": "4.0.1", - "resolved": "http://r.tnpm.oa.com/pify/download/pify-4.0.1.tgz", - "integrity": "sha1-SyzSXFDVmHNcUCkiJP2MbfQeMjE=", - "dev": true - }, - "plur": { - "version": "2.1.2", - "resolved": "http://r.tnpm.oa.com/plur/download/plur-2.1.2.tgz", - "integrity": "sha1-dIJFLBoPUI4+NE6uwxLJHCncZVo=", - "dev": true, - "requires": { - "irregular-plurals": "^1.0.0" - } - }, - "posix-character-classes": { - "version": "0.1.1", - "resolved": "http://r.tnpm.oa.com/posix-character-classes/download/posix-character-classes-0.1.1.tgz", - "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", - "dev": true - }, - "prepend-http": { - "version": "1.0.4", - "resolved": "http://r.tnpm.oa.com/prepend-http/download/prepend-http-1.0.4.tgz", - "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=", - "dev": true - }, - "pseudomap": { - "version": "1.0.2", - "resolved": "http://r.tnpm.oa.com/pseudomap/download/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", - "dev": true - }, - "quick-lru": { - "version": "1.1.0", - "resolved": "http://r.tnpm.oa.com/quick-lru/download/quick-lru-1.1.0.tgz", - "integrity": "sha1-Q2CxfGETatOAeDl/8RQW4Ybc+7g=", - "dev": true - }, - "rc": { - "version": "1.2.8", - "resolved": "http://r.tnpm.oa.com/rc/download/rc-1.2.8.tgz", - "integrity": "sha1-zZJL9SAKB1uDwYjNa54hG3/A0+0=", - "dev": true, - "requires": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - } - }, - "read-pkg": { - "version": "3.0.0", - "resolved": "http://r.tnpm.oa.com/read-pkg/download/read-pkg-3.0.0.tgz", - "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", - "dev": true, - "requires": { - "load-json-file": "^4.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^3.0.0" - } - }, - "read-pkg-up": { - "version": "4.0.0", - "resolved": "http://r.tnpm.oa.com/read-pkg-up/download/read-pkg-up-4.0.0.tgz", - "integrity": "sha1-GyIcYIi6d5lgHICPkRYcZuWPiXg=", - "dev": true, - "requires": { - "find-up": "^3.0.0", - "read-pkg": "^3.0.0" - }, - "dependencies": { - "find-up": { - "version": "3.0.0", - "resolved": "http://r.tnpm.oa.com/find-up/download/find-up-3.0.0.tgz", - "integrity": "sha1-SRafHXmTQwZG2mHsxa41XCHJe3M=", - "dev": true, - "requires": { - "locate-path": "^3.0.0" - } - }, - "locate-path": { - "version": "3.0.0", - "resolved": "http://r.tnpm.oa.com/locate-path/download/locate-path-3.0.0.tgz", - "integrity": "sha1-2+w7OrdZdYBxtY/ln8QYca8hQA4=", - "dev": true, - "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "2.2.1", - "resolved": "http://r.tnpm.oa.com/p-limit/download/p-limit-2.2.1.tgz", - "integrity": "sha1-qgeniMwxUck5tRMfY1cPDdIAlTc=", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "3.0.0", - "resolved": "http://r.tnpm.oa.com/p-locate/download/p-locate-3.0.0.tgz", - "integrity": "sha1-Mi1poFwCZLJZl9n0DNiokasAZKQ=", - "dev": true, - "requires": { - "p-limit": "^2.0.0" - } - }, - "p-try": { - "version": "2.2.0", - "resolved": "http://r.tnpm.oa.com/p-try/download/p-try-2.2.0.tgz", - "integrity": "sha1-yyhoVA4xPWHeWPr741zpAE1VQOY=", - "dev": true - } - } - }, - "redent": { - "version": "2.0.0", - "resolved": "http://r.tnpm.oa.com/redent/download/redent-2.0.0.tgz", - "integrity": "sha1-wbIAe0LVfrE4kHmzyDM2OdXhzKo=", - "dev": true, - "requires": { - "indent-string": "^3.0.0", - "strip-indent": "^2.0.0" - } - }, - "regex-not": { - "version": "1.0.2", - "resolved": "http://r.tnpm.oa.com/regex-not/download/regex-not-1.0.2.tgz", - "integrity": "sha1-H07OJ+ALC2XgJHpoEOaoXYOldSw=", - "dev": true, - "requires": { - "extend-shallow": "^3.0.2", - "safe-regex": "^1.1.0" - } - }, - "registry-auth-token": { - "version": "3.4.0", - "resolved": "http://r.tnpm.oa.com/registry-auth-token/download/registry-auth-token-3.4.0.tgz", - "integrity": "sha1-10RoFUM/XV7WQxzV3KIQSPZrOX4=", - "dev": true, - "requires": { - "rc": "^1.1.6", - "safe-buffer": "^5.0.1" - } - }, - "registry-url": { - "version": "3.1.0", - "resolved": "http://r.tnpm.oa.com/registry-url/download/registry-url-3.1.0.tgz", - "integrity": "sha1-PU74cPc93h138M+aOBQyRE4XSUI=", - "dev": true, - "requires": { - "rc": "^1.0.1" - } - }, - "repeat-element": { - "version": "1.1.3", - "resolved": "http://r.tnpm.oa.com/repeat-element/download/repeat-element-1.1.3.tgz", - "integrity": "sha1-eC4NglwMWjuzlzH4Tv7mt0Lmsc4=", - "dev": true - }, - "repeat-string": { - "version": "1.6.1", - "resolved": "http://r.tnpm.oa.com/repeat-string/download/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true - }, - "resolve": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", - "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", - "dev": true, - "requires": { - "path-parse": "^1.0.6" - } - }, - "resolve-url": { - "version": "0.2.1", - "resolved": "http://r.tnpm.oa.com/resolve-url/download/resolve-url-0.2.1.tgz", - "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", - "dev": true - }, - "ret": { - "version": "0.1.15", - "resolved": "http://r.tnpm.oa.com/ret/download/ret-0.1.15.tgz", - "integrity": "sha1-uKSCXVvbH8P29Twrwz+BOIaBx7w=", - "dev": true - }, - "safe-buffer": { - "version": "5.2.0", - "resolved": "http://r.tnpm.oa.com/safe-buffer/download/safe-buffer-5.2.0.tgz", - "integrity": "sha1-t02uxJsRSPiMZLaNSbHoFcHy9Rk=", - "dev": true - }, - "safe-regex": { - "version": "1.1.0", - "resolved": "http://r.tnpm.oa.com/safe-regex/download/safe-regex-1.1.0.tgz", - "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", - "dev": true, - "requires": { - "ret": "~0.1.10" - } - }, - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - }, - "semver-diff": { - "version": "2.1.0", - "resolved": "http://r.tnpm.oa.com/semver-diff/download/semver-diff-2.1.0.tgz", - "integrity": "sha1-S7uEN8jTfksM8aaP1ybsbWRdbTY=", - "dev": true, - "requires": { - "semver": "^5.0.3" - } - }, - "set-value": { - "version": "2.0.1", - "resolved": "http://r.tnpm.oa.com/set-value/download/set-value-2.0.1.tgz", - "integrity": "sha1-oY1AUw5vB95CKMfe/kInr4ytAFs=", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.3", - "split-string": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "http://r.tnpm.oa.com/extend-shallow/download/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "shebang-command": { - "version": "1.2.0", - "resolved": "http://r.tnpm.oa.com/shebang-command/download/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", - "dev": true, - "requires": { - "shebang-regex": "^1.0.0" - } - }, - "shebang-regex": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/shebang-regex/download/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", - "dev": true - }, - "signal-exit": { - "version": "3.0.2", - "resolved": "http://r.tnpm.oa.com/signal-exit/download/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", - "dev": true - }, - "slash": { - "version": "2.0.0", - "resolved": "http://r.tnpm.oa.com/slash/download/slash-2.0.0.tgz", - "integrity": "sha1-3lUoUaF1nfOo8gZTVEL17E3eq0Q=", - "dev": true - }, - "snapdragon": { - "version": "0.8.2", - "resolved": "http://r.tnpm.oa.com/snapdragon/download/snapdragon-0.8.2.tgz", - "integrity": "sha1-ZJIufFZbDhQgS6GqfWlkJ40lGC0=", - "dev": true, - "requires": { - "base": "^0.11.1", - "debug": "^2.2.0", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "map-cache": "^0.2.2", - "source-map": "^0.5.6", - "source-map-resolve": "^0.5.0", - "use": "^3.1.0" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "http://r.tnpm.oa.com/define-property/download/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "http://r.tnpm.oa.com/extend-shallow/download/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "snapdragon-node": { - "version": "2.1.1", - "resolved": "http://r.tnpm.oa.com/snapdragon-node/download/snapdragon-node-2.1.1.tgz", - "integrity": "sha1-bBdfhv8UvbByRWPo88GwIaKGhTs=", - "dev": true, - "requires": { - "define-property": "^1.0.0", - "isobject": "^3.0.0", - "snapdragon-util": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/define-property/download/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/is-accessor-descriptor/download/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha1-FpwvbT3x+ZJhgHI2XJsOofaHhlY=", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/is-data-descriptor/download/is-data-descriptor-1.0.0.tgz", - "integrity": "sha1-2Eh2Mh0Oet0DmQQGq7u9NrqSaMc=", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "http://r.tnpm.oa.com/is-descriptor/download/is-descriptor-1.0.2.tgz", - "integrity": "sha1-OxWXRqZmBLBPjIFSS6NlxfFNhuw=", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, - "snapdragon-util": { - "version": "3.0.1", - "resolved": "http://r.tnpm.oa.com/snapdragon-util/download/snapdragon-util-3.0.1.tgz", - "integrity": "sha1-+VZHlIbyrNeXAGk/b3uAXkWrVuI=", - "dev": true, - "requires": { - "kind-of": "^3.2.0" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "http://r.tnpm.oa.com/kind-of/download/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "source-map": { - "version": "0.5.7", - "resolved": "http://r.tnpm.oa.com/source-map/download/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - }, - "source-map-resolve": { - "version": "0.5.2", - "resolved": "http://r.tnpm.oa.com/source-map-resolve/download/source-map-resolve-0.5.2.tgz", - "integrity": "sha1-cuLMNAlVQ+Q7LGKyxMENSpBU8lk=", - "dev": true, - "requires": { - "atob": "^2.1.1", - "decode-uri-component": "^0.2.0", - "resolve-url": "^0.2.1", - "source-map-url": "^0.4.0", - "urix": "^0.1.0" - } - }, - "source-map-url": { - "version": "0.4.0", - "resolved": "http://r.tnpm.oa.com/source-map-url/download/source-map-url-0.4.0.tgz", - "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", - "dev": true - }, - "spdx-correct": { - "version": "3.1.0", - "resolved": "http://r.tnpm.oa.com/spdx-correct/download/spdx-correct-3.1.0.tgz", - "integrity": "sha1-+4PlBERSaPFUsHTiGMh8ADzTHfQ=", - "dev": true, - "requires": { - "spdx-expression-parse": "^3.0.0", - "spdx-license-ids": "^3.0.0" - } - }, - "spdx-exceptions": { - "version": "2.2.0", - "resolved": "http://r.tnpm.oa.com/spdx-exceptions/download/spdx-exceptions-2.2.0.tgz", - "integrity": "sha1-LqRQrudPKom/uUUZwH/Nb0EyKXc=", - "dev": true - }, - "spdx-expression-parse": { - "version": "3.0.0", - "resolved": "http://r.tnpm.oa.com/spdx-expression-parse/download/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", - "dev": true, - "requires": { - "spdx-exceptions": "^2.1.0", - "spdx-license-ids": "^3.0.0" - } - }, - "spdx-license-ids": { - "version": "3.0.5", - "resolved": "http://r.tnpm.oa.com/spdx-license-ids/download/spdx-license-ids-3.0.5.tgz", - "integrity": "sha1-NpS1gEVnpFjTyARYQqY1hjL2JlQ=", - "dev": true - }, - "split-string": { - "version": "3.1.0", - "resolved": "http://r.tnpm.oa.com/split-string/download/split-string-3.1.0.tgz", - "integrity": "sha1-fLCd2jqGWFcFxks5pkZgOGguj+I=", - "dev": true, - "requires": { - "extend-shallow": "^3.0.0" - } - }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - }, - "static-extend": { - "version": "0.1.2", - "resolved": "http://r.tnpm.oa.com/static-extend/download/static-extend-0.1.2.tgz", - "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", - "dev": true, - "requires": { - "define-property": "^0.2.5", - "object-copy": "^0.1.0" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "http://r.tnpm.oa.com/define-property/download/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - } - } - }, - "string-width": { - "version": "2.1.1", - "resolved": "http://r.tnpm.oa.com/string-width/download/string-width-2.1.1.tgz", - "integrity": "sha1-q5Pyeo3BPSjKyBXEYhQ6bZASrp4=", - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "http://r.tnpm.oa.com/strip-ansi/download/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } - }, - "strip-bom": { - "version": "3.0.0", - "resolved": "http://r.tnpm.oa.com/strip-bom/download/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", - "dev": true - }, - "strip-eof": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/strip-eof/download/strip-eof-1.0.0.tgz", - "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", - "dev": true - }, - "strip-indent": { - "version": "2.0.0", - "resolved": "http://r.tnpm.oa.com/strip-indent/download/strip-indent-2.0.0.tgz", - "integrity": "sha1-XvjbKV0B5u1sv3qrlpmNeCJSe2g=", - "dev": true - }, - "strip-json-comments": { - "version": "2.0.1", - "resolved": "http://r.tnpm.oa.com/strip-json-comments/download/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "dev": true - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - }, - "term-size": { - "version": "1.2.0", - "resolved": "http://r.tnpm.oa.com/term-size/download/term-size-1.2.0.tgz", - "integrity": "sha1-RYuDiH8oj8Vtb/+/rSYuJmOO+mk=", - "dev": true, - "requires": { - "execa": "^0.7.0" - } - }, - "timed-out": { - "version": "4.0.1", - "resolved": "http://r.tnpm.oa.com/timed-out/download/timed-out-4.0.1.tgz", - "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=", - "dev": true - }, - "to-object-path": { - "version": "0.3.0", - "resolved": "http://r.tnpm.oa.com/to-object-path/download/to-object-path-0.3.0.tgz", - "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "http://r.tnpm.oa.com/kind-of/download/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "to-regex": { - "version": "3.0.2", - "resolved": "http://r.tnpm.oa.com/to-regex/download/to-regex-3.0.2.tgz", - "integrity": "sha1-E8/dmzNlUvMLUfM6iuG0Knp1mc4=", - "dev": true, - "requires": { - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "regex-not": "^1.0.2", - "safe-regex": "^1.1.0" - } - }, - "to-regex-range": { - "version": "2.1.1", - "resolved": "http://r.tnpm.oa.com/to-regex-range/download/to-regex-range-2.1.1.tgz", - "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", - "dev": true, - "requires": { - "is-number": "^3.0.0", - "repeat-string": "^1.6.1" - } - }, - "trim-newlines": { - "version": "2.0.0", - "resolved": "http://r.tnpm.oa.com/trim-newlines/download/trim-newlines-2.0.0.tgz", - "integrity": "sha1-tAPQuRvlDDMd/EuC7s6yLD3hbSA=", - "dev": true - }, - "tsd": { - "version": "0.11.0", - "resolved": "http://r.tnpm.oa.com/tsd/download/tsd-0.11.0.tgz", - "integrity": "sha1-7ei46FhQhFt1P/9+qvaNvTZzcAs=", - "dev": true, - "requires": { - "eslint-formatter-pretty": "^1.3.0", - "globby": "^9.1.0", - "meow": "^5.0.0", - "path-exists": "^3.0.0", - "read-pkg-up": "^4.0.0", - "update-notifier": "^2.5.0" - } - }, - "tslib": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", - "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", - "dev": true - }, - "tslint": { - "version": "5.20.0", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", - "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "builtin-modules": "^1.1.1", - "chalk": "^2.3.0", - "commander": "^2.12.1", - "diff": "^4.0.1", - "glob": "^7.1.1", - "js-yaml": "^3.13.1", - "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", - "resolve": "^1.3.2", - "semver": "^5.3.0", - "tslib": "^1.8.0", - "tsutils": "^2.29.0" - } - }, - "tsutils": { - "version": "2.29.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", - "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", - "dev": true, - "requires": { - "tslib": "^1.8.1" - } - }, - "typescript": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.3.tgz", - "integrity": "sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==", - "dev": true - }, - "union-value": { - "version": "1.0.1", - "resolved": "http://r.tnpm.oa.com/union-value/download/union-value-1.0.1.tgz", - "integrity": "sha1-C2/nuDWuzaYcbqTU8CwUIh4QmEc=", - "dev": true, - "requires": { - "arr-union": "^3.1.0", - "get-value": "^2.0.6", - "is-extendable": "^0.1.1", - "set-value": "^2.0.1" - } - }, - "unique-string": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/unique-string/download/unique-string-1.0.0.tgz", - "integrity": "sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo=", - "dev": true, - "requires": { - "crypto-random-string": "^1.0.0" - } - }, - "unset-value": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/unset-value/download/unset-value-1.0.0.tgz", - "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", - "dev": true, - "requires": { - "has-value": "^0.3.1", - "isobject": "^3.0.0" - }, - "dependencies": { - "has-value": { - "version": "0.3.1", - "resolved": "http://r.tnpm.oa.com/has-value/download/has-value-0.3.1.tgz", - "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", - "dev": true, - "requires": { - "get-value": "^2.0.3", - "has-values": "^0.1.4", - "isobject": "^2.0.0" - }, - "dependencies": { - "isobject": { - "version": "2.1.0", - "resolved": "http://r.tnpm.oa.com/isobject/download/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, - "requires": { - "isarray": "1.0.0" - } - } - } - }, - "has-values": { - "version": "0.1.4", - "resolved": "http://r.tnpm.oa.com/has-values/download/has-values-0.1.4.tgz", - "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", - "dev": true - } - } - }, - "unzip-response": { - "version": "2.0.1", - "resolved": "http://r.tnpm.oa.com/unzip-response/download/unzip-response-2.0.1.tgz", - "integrity": "sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c=", - "dev": true - }, - "update-notifier": { - "version": "2.5.0", - "resolved": "http://r.tnpm.oa.com/update-notifier/download/update-notifier-2.5.0.tgz", - "integrity": "sha1-0HRFk+E/Fh5AassdlAi3LK0Ir/Y=", - "dev": true, - "requires": { - "boxen": "^1.2.1", - "chalk": "^2.0.1", - "configstore": "^3.0.0", - "import-lazy": "^2.1.0", - "is-ci": "^1.0.10", - "is-installed-globally": "^0.1.0", - "is-npm": "^1.0.0", - "latest-version": "^3.0.0", - "semver-diff": "^2.0.0", - "xdg-basedir": "^3.0.0" - } - }, - "urix": { - "version": "0.1.0", - "resolved": "http://r.tnpm.oa.com/urix/download/urix-0.1.0.tgz", - "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", - "dev": true - }, - "url-parse-lax": { - "version": "1.0.0", - "resolved": "http://r.tnpm.oa.com/url-parse-lax/download/url-parse-lax-1.0.0.tgz", - "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", - "dev": true, - "requires": { - "prepend-http": "^1.0.1" - } - }, - "use": { - "version": "3.1.1", - "resolved": "http://r.tnpm.oa.com/use/download/use-3.1.1.tgz", - "integrity": "sha1-1QyMrHmhn7wg8pEfVuuXP04QBw8=", - "dev": true - }, - "validate-npm-package-license": { - "version": "3.0.4", - "resolved": "http://r.tnpm.oa.com/validate-npm-package-license/download/validate-npm-package-license-3.0.4.tgz", - "integrity": "sha1-/JH2uce6FchX9MssXe/uw51PQQo=", - "dev": true, - "requires": { - "spdx-correct": "^3.0.0", - "spdx-expression-parse": "^3.0.0" - } - }, - "which": { - "version": "1.3.1", - "resolved": "http://r.tnpm.oa.com/which/download/which-1.3.1.tgz", - "integrity": "sha1-pFBD1U9YBTFtqNYvn1CRjT2nCwo=", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - }, - "widest-line": { - "version": "2.0.1", - "resolved": "http://r.tnpm.oa.com/widest-line/download/widest-line-2.0.1.tgz", - "integrity": "sha1-dDh2RzDsfvQ4HOTfgvuYpTFCo/w=", - "dev": true, - "requires": { - "string-width": "^2.1.1" - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "write-file-atomic": { - "version": "2.4.3", - "resolved": "http://r.tnpm.oa.com/write-file-atomic/download/write-file-atomic-2.4.3.tgz", - "integrity": "sha1-H9Lprh3z51uNjDZ0Q8aS1MqB9IE=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.11", - "imurmurhash": "^0.1.4", - "signal-exit": "^3.0.2" - } - }, - "xdg-basedir": { - "version": "3.0.0", - "resolved": "http://r.tnpm.oa.com/xdg-basedir/download/xdg-basedir-3.0.0.tgz", - "integrity": "sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=", - "dev": true - }, - "yallist": { - "version": "2.1.2", - "resolved": "http://r.tnpm.oa.com/yallist/download/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", - "dev": true - }, - "yargs-parser": { - "version": "10.1.0", - "resolved": "http://r.tnpm.oa.com/yargs-parser/download/yargs-parser-10.1.0.tgz", - "integrity": "sha1-cgImW4n36eny5XZeD+c1qQXtuqg=", - "dev": true, - "requires": { - "camelcase": "^4.1.0" - } - } - } -} diff --git a/package.json b/package.json index fab53c4..5eade4d 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "name": "miniprogram-api-typings", - "version": "2.10.0", + "version": "4.1.0", "description": "Type definitions for APIs of Wechat Mini Program in TypeScript", "main": "./index.d.ts", "types": "./index.d.ts", "scripts": { - "test": "npm run tsd && npm run tslint", + "test": "npm run tsd && npm run eslint", "tsd": "tsd", - "tslint": "tslint --project ." + "eslint": "eslint --config .eslintrc.js types/**/*.ts" }, "repository": { "type": "git", @@ -19,11 +19,12 @@ "url": "https://github.com/wechat-miniprogram/api-typings/issues" }, "homepage": "https://github.com/wechat-miniprogram/api-typings#readme", - "dependencies": {}, "devDependencies": { - "tsd": "^0.11.0", - "tslint": "^5.20.0", - "typescript": "^3.5.3" + "@typescript-eslint/eslint-plugin": "^6.21.0", + "@typescript-eslint/parser": "^6.21.0", + "eslint": "^8.57.1", + "tsd": "^0.32.0", + "typescript": "^5.2.2 <5.4.0" }, "tsd": { "directory": "test" @@ -31,7 +32,6 @@ "files": [ "LICENSE", "CHANGELOG.md", - "VERSIONS.md", "README.md", "README-en.md", "index.d.ts", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..d6fbc4a --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,1694 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +overrides: + brace-expansion@>=1.0.0 <=1.1.11: '>=1.1.12' + brace-expansion@>=2.0.0 <=2.0.1: '>=2.0.2' + +importers: + + .: + devDependencies: + '@typescript-eslint/eslint-plugin': + specifier: ^6.21.0 + version: 6.21.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.3.3))(eslint@8.57.1)(typescript@5.3.3) + '@typescript-eslint/parser': + specifier: ^6.21.0 + version: 6.21.0(eslint@8.57.1)(typescript@5.3.3) + eslint: + specifier: ^8.57.1 + version: 8.57.1 + tsd: + specifier: ^0.32.0 + version: 0.32.0 + typescript: + specifier: ^5.2.2 <5.4.0 + version: 5.3.3 + +packages: + + '@babel/code-frame@7.26.2': + resolution: {integrity: sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==} + engines: {node: '>=6.9.0'} + + '@babel/helper-validator-identifier@7.25.9': + resolution: {integrity: sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==} + engines: {node: '>=6.9.0'} + + '@eslint-community/eslint-utils@4.6.1': + resolution: {integrity: sha512-KTsJMmobmbrFLe3LDh0PC2FXpcSYJt/MLjlkh/9LEnmKYLSYmT/0EW9JWANjeoemiuZrmogti0tW5Ch+qNUYDw==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 + + '@eslint-community/regexpp@4.12.1': + resolution: {integrity: sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==} + engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} + + '@eslint/eslintrc@2.1.4': + resolution: {integrity: sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + + '@eslint/js@8.57.1': + resolution: {integrity: sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + + '@humanwhocodes/config-array@0.13.0': + resolution: {integrity: sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==} + engines: {node: '>=10.10.0'} + deprecated: Use @eslint/config-array instead + + '@humanwhocodes/module-importer@1.0.1': + resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==} + engines: {node: '>=12.22'} + + '@humanwhocodes/object-schema@2.0.3': + resolution: {integrity: sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==} + deprecated: Use @eslint/object-schema instead + + '@jest/schemas@29.6.3': + resolution: {integrity: sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + '@nodelib/fs.scandir@2.1.5': + resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} + engines: {node: '>= 8'} + + '@nodelib/fs.stat@2.0.5': + resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==} + engines: {node: '>= 8'} + + '@nodelib/fs.walk@1.2.8': + resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} + engines: {node: '>= 8'} + + '@sinclair/typebox@0.27.8': + resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} + + '@tsd/typescript@5.8.3': + resolution: {integrity: sha512-oKarNCN1QUhG148M88mtZdOlBZWWGcInquef+U8QL7gwJkRuNo5WS45Fjsd+3hM9cDJWGpqSZ4Oo097KDx4IWA==} + engines: {node: '>=14.17'} + + '@types/eslint@7.29.0': + resolution: {integrity: sha512-VNcvioYDH8/FxaeTKkM4/TiTwt6pBV9E3OfGmvaw8tPl0rrHCJ4Ll15HRT+pMiFAf/MLQvAzC+6RzUMEL9Ceng==} + + '@types/estree@1.0.7': + resolution: {integrity: sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==} + + '@types/json-schema@7.0.15': + resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} + + '@types/minimist@1.2.5': + resolution: {integrity: sha512-hov8bUuiLiyFPGyFPE1lwWhmzYbirOXQNNo40+y3zow8aFVTeyn3VWL0VFFfdNddA8S4Vf0Tc062rzyNr7Paag==} + + '@types/normalize-package-data@2.4.4': + resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} + + '@types/semver@7.7.0': + resolution: {integrity: sha512-k107IF4+Xr7UHjwDc7Cfd6PRQfbdkiRabXGRjo07b4WyPahFBZCZ1sE+BNxYIJPPg73UkfOsVOLwqVc/6ETrIA==} + + '@typescript-eslint/eslint-plugin@6.21.0': + resolution: {integrity: sha512-oy9+hTPCUFpngkEZUSzbf9MxI65wbKFoQYsgPdILTfbUldp5ovUuphZVe4i30emU9M/kP+T64Di0mxl7dSw3MA==} + engines: {node: ^16.0.0 || >=18.0.0} + peerDependencies: + '@typescript-eslint/parser': ^6.0.0 || ^6.0.0-alpha + eslint: ^7.0.0 || ^8.0.0 + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + + '@typescript-eslint/parser@6.21.0': + resolution: {integrity: sha512-tbsV1jPne5CkFQCgPBcDOt30ItF7aJoZL997JSF7MhGQqOeT3svWRYxiqlfA5RUdlHN6Fi+EI9bxqbdyAUZjYQ==} + engines: {node: ^16.0.0 || >=18.0.0} + peerDependencies: + eslint: ^7.0.0 || ^8.0.0 + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + + '@typescript-eslint/scope-manager@6.21.0': + resolution: {integrity: sha512-OwLUIWZJry80O99zvqXVEioyniJMa+d2GrqpUTqi5/v5D5rOrppJVBPa0yKCblcigC0/aYAzxxqQ1B+DS2RYsg==} + engines: {node: ^16.0.0 || >=18.0.0} + + '@typescript-eslint/type-utils@6.21.0': + resolution: {integrity: sha512-rZQI7wHfao8qMX3Rd3xqeYSMCL3SoiSQLBATSiVKARdFGCYSRvmViieZjqc58jKgs8Y8i9YvVVhRbHSTA4VBag==} + engines: {node: ^16.0.0 || >=18.0.0} + peerDependencies: + eslint: ^7.0.0 || ^8.0.0 + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + + '@typescript-eslint/types@6.21.0': + resolution: {integrity: sha512-1kFmZ1rOm5epu9NZEZm1kckCDGj5UJEf7P1kliH4LKu/RkwpsfqqGmY2OOcUs18lSlQBKLDYBOGxRVtrMN5lpg==} + engines: {node: ^16.0.0 || >=18.0.0} + + '@typescript-eslint/typescript-estree@6.21.0': + resolution: {integrity: sha512-6npJTkZcO+y2/kr+z0hc4HwNfrrP4kNYh57ek7yCNlrBjWQ1Y0OS7jiZTkgumrvkX5HkEKXFZkkdFNkaW2wmUQ==} + engines: {node: ^16.0.0 || >=18.0.0} + peerDependencies: + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + + '@typescript-eslint/utils@6.21.0': + resolution: {integrity: sha512-NfWVaC8HP9T8cbKQxHcsJBY5YE1O33+jpMwN45qzWWaPDZgLIbo12toGMWnmhvCpd3sIxkpDw3Wv1B3dYrbDQQ==} + engines: {node: ^16.0.0 || >=18.0.0} + peerDependencies: + eslint: ^7.0.0 || ^8.0.0 + + '@typescript-eslint/visitor-keys@6.21.0': + resolution: {integrity: sha512-JJtkDduxLi9bivAB+cYOVMtbkqdPOhZ+ZI5LC47MIRrDV4Yn2o+ZnW10Nkmr28xRpSpdJ6Sm42Hjf2+REYXm0A==} + engines: {node: ^16.0.0 || >=18.0.0} + + '@ungap/structured-clone@1.3.0': + resolution: {integrity: sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==} + + acorn-jsx@5.3.2: + resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} + peerDependencies: + acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 + + acorn@8.14.1: + resolution: {integrity: sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==} + engines: {node: '>=0.4.0'} + hasBin: true + + ajv@6.12.6: + resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==} + + ansi-escapes@4.3.2: + resolution: {integrity: sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==} + engines: {node: '>=8'} + + ansi-regex@5.0.1: + resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} + engines: {node: '>=8'} + + ansi-styles@4.3.0: + resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} + engines: {node: '>=8'} + + ansi-styles@5.2.0: + resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==} + engines: {node: '>=10'} + + argparse@2.0.1: + resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} + + array-union@2.1.0: + resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} + engines: {node: '>=8'} + + arrify@1.0.1: + resolution: {integrity: sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA==} + engines: {node: '>=0.10.0'} + + balanced-match@1.0.2: + resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} + + balanced-match@3.0.1: + resolution: {integrity: sha512-vjtV3hiLqYDNRoiAv0zC4QaGAMPomEoq83PRmYIofPswwZurCeWR5LByXm7SyoL0Zh5+2z0+HC7jG8gSZJUh0w==} + engines: {node: '>= 16'} + + brace-expansion@2.0.1: + resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} + + brace-expansion@4.0.1: + resolution: {integrity: sha512-YClrbvTCXGe70pU2JiEiPLYXO9gQkyxYeKpJIQHVS/gOs6EWMQP2RYBwjFLNT322Ji8TOC3IMPfsYCedNpzKfA==} + engines: {node: '>= 18'} + + braces@3.0.3: + resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} + engines: {node: '>=8'} + + callsites@3.1.0: + resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} + engines: {node: '>=6'} + + camelcase-keys@6.2.2: + resolution: {integrity: sha512-YrwaA0vEKazPBkn0ipTiMpSajYDSe+KjQfrjhcBMxJt/znbvlHd8Pw/Vamaz5EB4Wfhs3SUR3Z9mwRu/P3s3Yg==} + engines: {node: '>=8'} + + camelcase@5.3.1: + resolution: {integrity: sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==} + engines: {node: '>=6'} + + chalk@4.1.2: + resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} + engines: {node: '>=10'} + + color-convert@2.0.1: + resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} + engines: {node: '>=7.0.0'} + + color-name@1.1.4: + resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + + cross-spawn@7.0.6: + resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} + engines: {node: '>= 8'} + + debug@4.4.0: + resolution: {integrity: sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + + decamelize-keys@1.1.1: + resolution: {integrity: sha512-WiPxgEirIV0/eIOMcnFBA3/IJZAZqKnwAwWyvvdi4lsr1WCN22nhdf/3db3DoZcUjTV2SqfzIwNyp6y2xs3nmg==} + engines: {node: '>=0.10.0'} + + decamelize@1.2.0: + resolution: {integrity: sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==} + engines: {node: '>=0.10.0'} + + deep-is@0.1.4: + resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} + + diff-sequences@29.6.3: + resolution: {integrity: sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + dir-glob@3.0.1: + resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} + engines: {node: '>=8'} + + doctrine@3.0.0: + resolution: {integrity: sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==} + engines: {node: '>=6.0.0'} + + emoji-regex@8.0.0: + resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} + + error-ex@1.3.2: + resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==} + + escape-string-regexp@4.0.0: + resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} + engines: {node: '>=10'} + + eslint-formatter-pretty@4.1.0: + resolution: {integrity: sha512-IsUTtGxF1hrH6lMWiSl1WbGaiP01eT6kzywdY1U+zLc0MP+nwEnUiS9UI8IaOTUhTeQJLlCEWIbXINBH4YJbBQ==} + engines: {node: '>=10'} + + eslint-rule-docs@1.1.235: + resolution: {integrity: sha512-+TQ+x4JdTnDoFEXXb3fDvfGOwnyNV7duH8fXWTPD1ieaBmB8omj7Gw/pMBBu4uI2uJCCU8APDaQJzWuXnTsH4A==} + + eslint-scope@7.2.2: + resolution: {integrity: sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + + eslint-visitor-keys@3.4.3: + resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + + eslint@8.57.1: + resolution: {integrity: sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + deprecated: This version is no longer supported. Please see https://eslint.org/version-support for other options. + hasBin: true + + espree@9.6.1: + resolution: {integrity: sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + + esquery@1.6.0: + resolution: {integrity: sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==} + engines: {node: '>=0.10'} + + esrecurse@4.3.0: + resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==} + engines: {node: '>=4.0'} + + estraverse@5.3.0: + resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==} + engines: {node: '>=4.0'} + + esutils@2.0.3: + resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} + engines: {node: '>=0.10.0'} + + fast-deep-equal@3.1.3: + resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} + + fast-glob@3.3.3: + resolution: {integrity: sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==} + engines: {node: '>=8.6.0'} + + fast-json-stable-stringify@2.1.0: + resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} + + fast-levenshtein@2.0.6: + resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} + + fastq@1.19.1: + resolution: {integrity: sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==} + + file-entry-cache@6.0.1: + resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==} + engines: {node: ^10.12.0 || >=12.0.0} + + fill-range@7.1.1: + resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} + engines: {node: '>=8'} + + find-up@4.1.0: + resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} + engines: {node: '>=8'} + + find-up@5.0.0: + resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==} + engines: {node: '>=10'} + + flat-cache@3.2.0: + resolution: {integrity: sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==} + engines: {node: ^10.12.0 || >=12.0.0} + + flatted@3.3.3: + resolution: {integrity: sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==} + + fs.realpath@1.0.0: + resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} + + function-bind@1.1.2: + resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} + + glob-parent@5.1.2: + resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} + engines: {node: '>= 6'} + + glob-parent@6.0.2: + resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==} + engines: {node: '>=10.13.0'} + + glob@7.2.3: + resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} + deprecated: Glob versions prior to v9 are no longer supported + + globals@13.24.0: + resolution: {integrity: sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==} + engines: {node: '>=8'} + + globby@11.1.0: + resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} + engines: {node: '>=10'} + + graphemer@1.4.0: + resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==} + + hard-rejection@2.1.0: + resolution: {integrity: sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==} + engines: {node: '>=6'} + + has-flag@4.0.0: + resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} + engines: {node: '>=8'} + + hasown@2.0.2: + resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} + engines: {node: '>= 0.4'} + + hosted-git-info@2.8.9: + resolution: {integrity: sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==} + + hosted-git-info@4.1.0: + resolution: {integrity: sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==} + engines: {node: '>=10'} + + ignore@5.3.2: + resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} + engines: {node: '>= 4'} + + import-fresh@3.3.1: + resolution: {integrity: sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==} + engines: {node: '>=6'} + + imurmurhash@0.1.4: + resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} + engines: {node: '>=0.8.19'} + + indent-string@4.0.0: + resolution: {integrity: sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==} + engines: {node: '>=8'} + + inflight@1.0.6: + resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} + deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. + + inherits@2.0.4: + resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} + + irregular-plurals@3.5.0: + resolution: {integrity: sha512-1ANGLZ+Nkv1ptFb2pa8oG8Lem4krflKuX/gINiHJHjJUKaJHk/SXk5x6K3J+39/p0h1RQ2saROclJJ+QLvETCQ==} + engines: {node: '>=8'} + + is-arrayish@0.2.1: + resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==} + + is-core-module@2.16.1: + resolution: {integrity: sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==} + engines: {node: '>= 0.4'} + + is-extglob@2.1.1: + resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} + engines: {node: '>=0.10.0'} + + is-fullwidth-code-point@3.0.0: + resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} + engines: {node: '>=8'} + + is-glob@4.0.3: + resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} + engines: {node: '>=0.10.0'} + + is-number@7.0.0: + resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} + engines: {node: '>=0.12.0'} + + is-path-inside@3.0.3: + resolution: {integrity: sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==} + engines: {node: '>=8'} + + is-plain-obj@1.1.0: + resolution: {integrity: sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg==} + engines: {node: '>=0.10.0'} + + is-unicode-supported@0.1.0: + resolution: {integrity: sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==} + engines: {node: '>=10'} + + isexe@2.0.0: + resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + + jest-diff@29.7.0: + resolution: {integrity: sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-get-type@29.6.3: + resolution: {integrity: sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + js-tokens@4.0.0: + resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} + + js-yaml@4.1.0: + resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} + hasBin: true + + json-buffer@3.0.1: + resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==} + + json-parse-even-better-errors@2.3.1: + resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} + + json-schema-traverse@0.4.1: + resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} + + json-stable-stringify-without-jsonify@1.0.1: + resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} + + keyv@4.5.4: + resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} + + kind-of@6.0.3: + resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} + engines: {node: '>=0.10.0'} + + levn@0.4.1: + resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} + engines: {node: '>= 0.8.0'} + + lines-and-columns@1.2.4: + resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} + + locate-path@5.0.0: + resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} + engines: {node: '>=8'} + + locate-path@6.0.0: + resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} + engines: {node: '>=10'} + + lodash.merge@4.6.2: + resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} + + log-symbols@4.1.0: + resolution: {integrity: sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==} + engines: {node: '>=10'} + + lru-cache@6.0.0: + resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} + engines: {node: '>=10'} + + map-obj@1.0.1: + resolution: {integrity: sha512-7N/q3lyZ+LVCp7PzuxrJr4KMbBE2hW7BT7YNia330OFxIf4d3r5zVpicP2650l7CPN6RM9zOJRl3NGpqSiw3Eg==} + engines: {node: '>=0.10.0'} + + map-obj@4.3.0: + resolution: {integrity: sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ==} + engines: {node: '>=8'} + + meow@9.0.0: + resolution: {integrity: sha512-+obSblOQmRhcyBt62furQqRAQpNyWXo8BuQ5bN7dG8wmwQ+vwHKp/rCFD4CrTP8CsDQD1sjoZ94K417XEUk8IQ==} + engines: {node: '>=10'} + + merge2@1.4.1: + resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} + engines: {node: '>= 8'} + + micromatch@4.0.8: + resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} + engines: {node: '>=8.6'} + + min-indent@1.0.1: + resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} + engines: {node: '>=4'} + + minimatch@3.1.2: + resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} + + minimatch@9.0.3: + resolution: {integrity: sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==} + engines: {node: '>=16 || 14 >=14.17'} + + minimist-options@4.1.0: + resolution: {integrity: sha512-Q4r8ghd80yhO/0j1O3B2BjweX3fiHg9cdOwjJd2J76Q135c+NDxGCqdYKQ1SKBuFfgWbAUzBfvYjPUEeNgqN1A==} + engines: {node: '>= 6'} + + ms@2.1.3: + resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + + natural-compare@1.4.0: + resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} + + normalize-package-data@2.5.0: + resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==} + + normalize-package-data@3.0.3: + resolution: {integrity: sha512-p2W1sgqij3zMMyRC067Dg16bfzVH+w7hyegmpIvZ4JNjqtGOVAIvLmjBx3yP7YTe9vKJgkoNOPjwQGogDoMXFA==} + engines: {node: '>=10'} + + once@1.4.0: + resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} + + optionator@0.9.4: + resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} + engines: {node: '>= 0.8.0'} + + p-limit@2.3.0: + resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} + engines: {node: '>=6'} + + p-limit@3.1.0: + resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} + engines: {node: '>=10'} + + p-locate@4.1.0: + resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==} + engines: {node: '>=8'} + + p-locate@5.0.0: + resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==} + engines: {node: '>=10'} + + p-try@2.2.0: + resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} + engines: {node: '>=6'} + + parent-module@1.0.1: + resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} + engines: {node: '>=6'} + + parse-json@5.2.0: + resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} + engines: {node: '>=8'} + + path-exists@4.0.0: + resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} + engines: {node: '>=8'} + + path-is-absolute@1.0.1: + resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} + engines: {node: '>=0.10.0'} + + path-key@3.1.1: + resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} + engines: {node: '>=8'} + + path-parse@1.0.7: + resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} + + path-type@4.0.0: + resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} + engines: {node: '>=8'} + + picocolors@1.1.1: + resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + + picomatch@2.3.1: + resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} + engines: {node: '>=8.6'} + + plur@4.0.0: + resolution: {integrity: sha512-4UGewrYgqDFw9vV6zNV+ADmPAUAfJPKtGvb/VdpQAx25X5f3xXdGdyOEVFwkl8Hl/tl7+xbeHqSEM+D5/TirUg==} + engines: {node: '>=10'} + + prelude-ls@1.2.1: + resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} + engines: {node: '>= 0.8.0'} + + pretty-format@29.7.0: + resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + punycode@2.3.1: + resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} + engines: {node: '>=6'} + + queue-microtask@1.2.3: + resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} + + quick-lru@4.0.1: + resolution: {integrity: sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g==} + engines: {node: '>=8'} + + react-is@18.3.1: + resolution: {integrity: sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==} + + read-pkg-up@7.0.1: + resolution: {integrity: sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==} + engines: {node: '>=8'} + + read-pkg@5.2.0: + resolution: {integrity: sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==} + engines: {node: '>=8'} + + redent@3.0.0: + resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==} + engines: {node: '>=8'} + + resolve-from@4.0.0: + resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} + engines: {node: '>=4'} + + resolve@1.22.10: + resolution: {integrity: sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==} + engines: {node: '>= 0.4'} + hasBin: true + + reusify@1.1.0: + resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==} + engines: {iojs: '>=1.0.0', node: '>=0.10.0'} + + rimraf@3.0.2: + resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} + deprecated: Rimraf versions prior to v4 are no longer supported + hasBin: true + + run-parallel@1.2.0: + resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} + + semver@5.7.2: + resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} + hasBin: true + + semver@7.7.1: + resolution: {integrity: sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==} + engines: {node: '>=10'} + hasBin: true + + shebang-command@2.0.0: + resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} + engines: {node: '>=8'} + + shebang-regex@3.0.0: + resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} + engines: {node: '>=8'} + + slash@3.0.0: + resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} + engines: {node: '>=8'} + + spdx-correct@3.2.0: + resolution: {integrity: sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==} + + spdx-exceptions@2.5.0: + resolution: {integrity: sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w==} + + spdx-expression-parse@3.0.1: + resolution: {integrity: sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==} + + spdx-license-ids@3.0.21: + resolution: {integrity: sha512-Bvg/8F5XephndSK3JffaRqdT+gyhfqIPwDHpX80tJrF8QQRYMo8sNMeaZ2Dp5+jhwKnUmIOyFFQfHRkjJm5nXg==} + + string-width@4.2.3: + resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} + engines: {node: '>=8'} + + strip-ansi@6.0.1: + resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} + engines: {node: '>=8'} + + strip-indent@3.0.0: + resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==} + engines: {node: '>=8'} + + strip-json-comments@3.1.1: + resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} + engines: {node: '>=8'} + + supports-color@7.2.0: + resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} + engines: {node: '>=8'} + + supports-hyperlinks@2.3.0: + resolution: {integrity: sha512-RpsAZlpWcDwOPQA22aCH4J0t7L8JmAvsCxfOSEwm7cQs3LshN36QaTkwd70DnBOXDWGssw2eUoc8CaRWT0XunA==} + engines: {node: '>=8'} + + supports-preserve-symlinks-flag@1.0.0: + resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} + engines: {node: '>= 0.4'} + + text-table@0.2.0: + resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} + + to-regex-range@5.0.1: + resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} + engines: {node: '>=8.0'} + + trim-newlines@3.0.1: + resolution: {integrity: sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw==} + engines: {node: '>=8'} + + ts-api-utils@1.4.3: + resolution: {integrity: sha512-i3eMG77UTMD0hZhgRS562pv83RC6ukSAC2GMNWc+9dieh/+jDM5u5YG+NHX6VNDRHQcHwmsTHctP9LhbC3WxVw==} + engines: {node: '>=16'} + peerDependencies: + typescript: '>=4.2.0' + + tsd@0.32.0: + resolution: {integrity: sha512-R5lBZCbxGBowOcW0gpQaiIjGYrG5NmU+PfFDKcc3zbtzWjML1o/zAwzdDnS2ZheSlPu9GW51azpFqEPUBq9DoQ==} + engines: {node: '>=14.16'} + hasBin: true + + type-check@0.4.0: + resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} + engines: {node: '>= 0.8.0'} + + type-fest@0.18.1: + resolution: {integrity: sha512-OIAYXk8+ISY+qTOwkHtKqzAuxchoMiD9Udx+FSGQDuiRR+PJKJHc2NJAXlbhkGwTt/4/nKZxELY1w3ReWOL8mw==} + engines: {node: '>=10'} + + type-fest@0.20.2: + resolution: {integrity: sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==} + engines: {node: '>=10'} + + type-fest@0.21.3: + resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==} + engines: {node: '>=10'} + + type-fest@0.6.0: + resolution: {integrity: sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==} + engines: {node: '>=8'} + + type-fest@0.8.1: + resolution: {integrity: sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==} + engines: {node: '>=8'} + + typescript@5.3.3: + resolution: {integrity: sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==} + engines: {node: '>=14.17'} + hasBin: true + + uri-js@4.4.1: + resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} + + validate-npm-package-license@3.0.4: + resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} + + which@2.0.2: + resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} + engines: {node: '>= 8'} + hasBin: true + + word-wrap@1.2.5: + resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==} + engines: {node: '>=0.10.0'} + + wrappy@1.0.2: + resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} + + yallist@4.0.0: + resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} + + yargs-parser@20.2.9: + resolution: {integrity: sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==} + engines: {node: '>=10'} + + yocto-queue@0.1.0: + resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} + engines: {node: '>=10'} + +snapshots: + + '@babel/code-frame@7.26.2': + dependencies: + '@babel/helper-validator-identifier': 7.25.9 + js-tokens: 4.0.0 + picocolors: 1.1.1 + + '@babel/helper-validator-identifier@7.25.9': {} + + '@eslint-community/eslint-utils@4.6.1(eslint@8.57.1)': + dependencies: + eslint: 8.57.1 + eslint-visitor-keys: 3.4.3 + + '@eslint-community/regexpp@4.12.1': {} + + '@eslint/eslintrc@2.1.4': + dependencies: + ajv: 6.12.6 + debug: 4.4.0 + espree: 9.6.1 + globals: 13.24.0 + ignore: 5.3.2 + import-fresh: 3.3.1 + js-yaml: 4.1.0 + minimatch: 3.1.2 + strip-json-comments: 3.1.1 + transitivePeerDependencies: + - supports-color + + '@eslint/js@8.57.1': {} + + '@humanwhocodes/config-array@0.13.0': + dependencies: + '@humanwhocodes/object-schema': 2.0.3 + debug: 4.4.0 + minimatch: 3.1.2 + transitivePeerDependencies: + - supports-color + + '@humanwhocodes/module-importer@1.0.1': {} + + '@humanwhocodes/object-schema@2.0.3': {} + + '@jest/schemas@29.6.3': + dependencies: + '@sinclair/typebox': 0.27.8 + + '@nodelib/fs.scandir@2.1.5': + dependencies: + '@nodelib/fs.stat': 2.0.5 + run-parallel: 1.2.0 + + '@nodelib/fs.stat@2.0.5': {} + + '@nodelib/fs.walk@1.2.8': + dependencies: + '@nodelib/fs.scandir': 2.1.5 + fastq: 1.19.1 + + '@sinclair/typebox@0.27.8': {} + + '@tsd/typescript@5.8.3': {} + + '@types/eslint@7.29.0': + dependencies: + '@types/estree': 1.0.7 + '@types/json-schema': 7.0.15 + + '@types/estree@1.0.7': {} + + '@types/json-schema@7.0.15': {} + + '@types/minimist@1.2.5': {} + + '@types/normalize-package-data@2.4.4': {} + + '@types/semver@7.7.0': {} + + '@typescript-eslint/eslint-plugin@6.21.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.3.3))(eslint@8.57.1)(typescript@5.3.3)': + dependencies: + '@eslint-community/regexpp': 4.12.1 + '@typescript-eslint/parser': 6.21.0(eslint@8.57.1)(typescript@5.3.3) + '@typescript-eslint/scope-manager': 6.21.0 + '@typescript-eslint/type-utils': 6.21.0(eslint@8.57.1)(typescript@5.3.3) + '@typescript-eslint/utils': 6.21.0(eslint@8.57.1)(typescript@5.3.3) + '@typescript-eslint/visitor-keys': 6.21.0 + debug: 4.4.0 + eslint: 8.57.1 + graphemer: 1.4.0 + ignore: 5.3.2 + natural-compare: 1.4.0 + semver: 7.7.1 + ts-api-utils: 1.4.3(typescript@5.3.3) + optionalDependencies: + typescript: 5.3.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.3.3)': + dependencies: + '@typescript-eslint/scope-manager': 6.21.0 + '@typescript-eslint/types': 6.21.0 + '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.3.3) + '@typescript-eslint/visitor-keys': 6.21.0 + debug: 4.4.0 + eslint: 8.57.1 + optionalDependencies: + typescript: 5.3.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/scope-manager@6.21.0': + dependencies: + '@typescript-eslint/types': 6.21.0 + '@typescript-eslint/visitor-keys': 6.21.0 + + '@typescript-eslint/type-utils@6.21.0(eslint@8.57.1)(typescript@5.3.3)': + dependencies: + '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.3.3) + '@typescript-eslint/utils': 6.21.0(eslint@8.57.1)(typescript@5.3.3) + debug: 4.4.0 + eslint: 8.57.1 + ts-api-utils: 1.4.3(typescript@5.3.3) + optionalDependencies: + typescript: 5.3.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/types@6.21.0': {} + + '@typescript-eslint/typescript-estree@6.21.0(typescript@5.3.3)': + dependencies: + '@typescript-eslint/types': 6.21.0 + '@typescript-eslint/visitor-keys': 6.21.0 + debug: 4.4.0 + globby: 11.1.0 + is-glob: 4.0.3 + minimatch: 9.0.3 + semver: 7.7.1 + ts-api-utils: 1.4.3(typescript@5.3.3) + optionalDependencies: + typescript: 5.3.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/utils@6.21.0(eslint@8.57.1)(typescript@5.3.3)': + dependencies: + '@eslint-community/eslint-utils': 4.6.1(eslint@8.57.1) + '@types/json-schema': 7.0.15 + '@types/semver': 7.7.0 + '@typescript-eslint/scope-manager': 6.21.0 + '@typescript-eslint/types': 6.21.0 + '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.3.3) + eslint: 8.57.1 + semver: 7.7.1 + transitivePeerDependencies: + - supports-color + - typescript + + '@typescript-eslint/visitor-keys@6.21.0': + dependencies: + '@typescript-eslint/types': 6.21.0 + eslint-visitor-keys: 3.4.3 + + '@ungap/structured-clone@1.3.0': {} + + acorn-jsx@5.3.2(acorn@8.14.1): + dependencies: + acorn: 8.14.1 + + acorn@8.14.1: {} + + ajv@6.12.6: + dependencies: + fast-deep-equal: 3.1.3 + fast-json-stable-stringify: 2.1.0 + json-schema-traverse: 0.4.1 + uri-js: 4.4.1 + + ansi-escapes@4.3.2: + dependencies: + type-fest: 0.21.3 + + ansi-regex@5.0.1: {} + + ansi-styles@4.3.0: + dependencies: + color-convert: 2.0.1 + + ansi-styles@5.2.0: {} + + argparse@2.0.1: {} + + array-union@2.1.0: {} + + arrify@1.0.1: {} + + balanced-match@1.0.2: {} + + balanced-match@3.0.1: {} + + brace-expansion@2.0.1: + dependencies: + balanced-match: 1.0.2 + + brace-expansion@4.0.1: + dependencies: + balanced-match: 3.0.1 + + braces@3.0.3: + dependencies: + fill-range: 7.1.1 + + callsites@3.1.0: {} + + camelcase-keys@6.2.2: + dependencies: + camelcase: 5.3.1 + map-obj: 4.3.0 + quick-lru: 4.0.1 + + camelcase@5.3.1: {} + + chalk@4.1.2: + dependencies: + ansi-styles: 4.3.0 + supports-color: 7.2.0 + + color-convert@2.0.1: + dependencies: + color-name: 1.1.4 + + color-name@1.1.4: {} + + cross-spawn@7.0.6: + dependencies: + path-key: 3.1.1 + shebang-command: 2.0.0 + which: 2.0.2 + + debug@4.4.0: + dependencies: + ms: 2.1.3 + + decamelize-keys@1.1.1: + dependencies: + decamelize: 1.2.0 + map-obj: 1.0.1 + + decamelize@1.2.0: {} + + deep-is@0.1.4: {} + + diff-sequences@29.6.3: {} + + dir-glob@3.0.1: + dependencies: + path-type: 4.0.0 + + doctrine@3.0.0: + dependencies: + esutils: 2.0.3 + + emoji-regex@8.0.0: {} + + error-ex@1.3.2: + dependencies: + is-arrayish: 0.2.1 + + escape-string-regexp@4.0.0: {} + + eslint-formatter-pretty@4.1.0: + dependencies: + '@types/eslint': 7.29.0 + ansi-escapes: 4.3.2 + chalk: 4.1.2 + eslint-rule-docs: 1.1.235 + log-symbols: 4.1.0 + plur: 4.0.0 + string-width: 4.2.3 + supports-hyperlinks: 2.3.0 + + eslint-rule-docs@1.1.235: {} + + eslint-scope@7.2.2: + dependencies: + esrecurse: 4.3.0 + estraverse: 5.3.0 + + eslint-visitor-keys@3.4.3: {} + + eslint@8.57.1: + dependencies: + '@eslint-community/eslint-utils': 4.6.1(eslint@8.57.1) + '@eslint-community/regexpp': 4.12.1 + '@eslint/eslintrc': 2.1.4 + '@eslint/js': 8.57.1 + '@humanwhocodes/config-array': 0.13.0 + '@humanwhocodes/module-importer': 1.0.1 + '@nodelib/fs.walk': 1.2.8 + '@ungap/structured-clone': 1.3.0 + ajv: 6.12.6 + chalk: 4.1.2 + cross-spawn: 7.0.6 + debug: 4.4.0 + doctrine: 3.0.0 + escape-string-regexp: 4.0.0 + eslint-scope: 7.2.2 + eslint-visitor-keys: 3.4.3 + espree: 9.6.1 + esquery: 1.6.0 + esutils: 2.0.3 + fast-deep-equal: 3.1.3 + file-entry-cache: 6.0.1 + find-up: 5.0.0 + glob-parent: 6.0.2 + globals: 13.24.0 + graphemer: 1.4.0 + ignore: 5.3.2 + imurmurhash: 0.1.4 + is-glob: 4.0.3 + is-path-inside: 3.0.3 + js-yaml: 4.1.0 + json-stable-stringify-without-jsonify: 1.0.1 + levn: 0.4.1 + lodash.merge: 4.6.2 + minimatch: 3.1.2 + natural-compare: 1.4.0 + optionator: 0.9.4 + strip-ansi: 6.0.1 + text-table: 0.2.0 + transitivePeerDependencies: + - supports-color + + espree@9.6.1: + dependencies: + acorn: 8.14.1 + acorn-jsx: 5.3.2(acorn@8.14.1) + eslint-visitor-keys: 3.4.3 + + esquery@1.6.0: + dependencies: + estraverse: 5.3.0 + + esrecurse@4.3.0: + dependencies: + estraverse: 5.3.0 + + estraverse@5.3.0: {} + + esutils@2.0.3: {} + + fast-deep-equal@3.1.3: {} + + fast-glob@3.3.3: + dependencies: + '@nodelib/fs.stat': 2.0.5 + '@nodelib/fs.walk': 1.2.8 + glob-parent: 5.1.2 + merge2: 1.4.1 + micromatch: 4.0.8 + + fast-json-stable-stringify@2.1.0: {} + + fast-levenshtein@2.0.6: {} + + fastq@1.19.1: + dependencies: + reusify: 1.1.0 + + file-entry-cache@6.0.1: + dependencies: + flat-cache: 3.2.0 + + fill-range@7.1.1: + dependencies: + to-regex-range: 5.0.1 + + find-up@4.1.0: + dependencies: + locate-path: 5.0.0 + path-exists: 4.0.0 + + find-up@5.0.0: + dependencies: + locate-path: 6.0.0 + path-exists: 4.0.0 + + flat-cache@3.2.0: + dependencies: + flatted: 3.3.3 + keyv: 4.5.4 + rimraf: 3.0.2 + + flatted@3.3.3: {} + + fs.realpath@1.0.0: {} + + function-bind@1.1.2: {} + + glob-parent@5.1.2: + dependencies: + is-glob: 4.0.3 + + glob-parent@6.0.2: + dependencies: + is-glob: 4.0.3 + + glob@7.2.3: + dependencies: + fs.realpath: 1.0.0 + inflight: 1.0.6 + inherits: 2.0.4 + minimatch: 3.1.2 + once: 1.4.0 + path-is-absolute: 1.0.1 + + globals@13.24.0: + dependencies: + type-fest: 0.20.2 + + globby@11.1.0: + dependencies: + array-union: 2.1.0 + dir-glob: 3.0.1 + fast-glob: 3.3.3 + ignore: 5.3.2 + merge2: 1.4.1 + slash: 3.0.0 + + graphemer@1.4.0: {} + + hard-rejection@2.1.0: {} + + has-flag@4.0.0: {} + + hasown@2.0.2: + dependencies: + function-bind: 1.1.2 + + hosted-git-info@2.8.9: {} + + hosted-git-info@4.1.0: + dependencies: + lru-cache: 6.0.0 + + ignore@5.3.2: {} + + import-fresh@3.3.1: + dependencies: + parent-module: 1.0.1 + resolve-from: 4.0.0 + + imurmurhash@0.1.4: {} + + indent-string@4.0.0: {} + + inflight@1.0.6: + dependencies: + once: 1.4.0 + wrappy: 1.0.2 + + inherits@2.0.4: {} + + irregular-plurals@3.5.0: {} + + is-arrayish@0.2.1: {} + + is-core-module@2.16.1: + dependencies: + hasown: 2.0.2 + + is-extglob@2.1.1: {} + + is-fullwidth-code-point@3.0.0: {} + + is-glob@4.0.3: + dependencies: + is-extglob: 2.1.1 + + is-number@7.0.0: {} + + is-path-inside@3.0.3: {} + + is-plain-obj@1.1.0: {} + + is-unicode-supported@0.1.0: {} + + isexe@2.0.0: {} + + jest-diff@29.7.0: + dependencies: + chalk: 4.1.2 + diff-sequences: 29.6.3 + jest-get-type: 29.6.3 + pretty-format: 29.7.0 + + jest-get-type@29.6.3: {} + + js-tokens@4.0.0: {} + + js-yaml@4.1.0: + dependencies: + argparse: 2.0.1 + + json-buffer@3.0.1: {} + + json-parse-even-better-errors@2.3.1: {} + + json-schema-traverse@0.4.1: {} + + json-stable-stringify-without-jsonify@1.0.1: {} + + keyv@4.5.4: + dependencies: + json-buffer: 3.0.1 + + kind-of@6.0.3: {} + + levn@0.4.1: + dependencies: + prelude-ls: 1.2.1 + type-check: 0.4.0 + + lines-and-columns@1.2.4: {} + + locate-path@5.0.0: + dependencies: + p-locate: 4.1.0 + + locate-path@6.0.0: + dependencies: + p-locate: 5.0.0 + + lodash.merge@4.6.2: {} + + log-symbols@4.1.0: + dependencies: + chalk: 4.1.2 + is-unicode-supported: 0.1.0 + + lru-cache@6.0.0: + dependencies: + yallist: 4.0.0 + + map-obj@1.0.1: {} + + map-obj@4.3.0: {} + + meow@9.0.0: + dependencies: + '@types/minimist': 1.2.5 + camelcase-keys: 6.2.2 + decamelize: 1.2.0 + decamelize-keys: 1.1.1 + hard-rejection: 2.1.0 + minimist-options: 4.1.0 + normalize-package-data: 3.0.3 + read-pkg-up: 7.0.1 + redent: 3.0.0 + trim-newlines: 3.0.1 + type-fest: 0.18.1 + yargs-parser: 20.2.9 + + merge2@1.4.1: {} + + micromatch@4.0.8: + dependencies: + braces: 3.0.3 + picomatch: 2.3.1 + + min-indent@1.0.1: {} + + minimatch@3.1.2: + dependencies: + brace-expansion: 2.0.1 + + minimatch@9.0.3: + dependencies: + brace-expansion: 4.0.1 + + minimist-options@4.1.0: + dependencies: + arrify: 1.0.1 + is-plain-obj: 1.1.0 + kind-of: 6.0.3 + + ms@2.1.3: {} + + natural-compare@1.4.0: {} + + normalize-package-data@2.5.0: + dependencies: + hosted-git-info: 2.8.9 + resolve: 1.22.10 + semver: 5.7.2 + validate-npm-package-license: 3.0.4 + + normalize-package-data@3.0.3: + dependencies: + hosted-git-info: 4.1.0 + is-core-module: 2.16.1 + semver: 7.7.1 + validate-npm-package-license: 3.0.4 + + once@1.4.0: + dependencies: + wrappy: 1.0.2 + + optionator@0.9.4: + dependencies: + deep-is: 0.1.4 + fast-levenshtein: 2.0.6 + levn: 0.4.1 + prelude-ls: 1.2.1 + type-check: 0.4.0 + word-wrap: 1.2.5 + + p-limit@2.3.0: + dependencies: + p-try: 2.2.0 + + p-limit@3.1.0: + dependencies: + yocto-queue: 0.1.0 + + p-locate@4.1.0: + dependencies: + p-limit: 2.3.0 + + p-locate@5.0.0: + dependencies: + p-limit: 3.1.0 + + p-try@2.2.0: {} + + parent-module@1.0.1: + dependencies: + callsites: 3.1.0 + + parse-json@5.2.0: + dependencies: + '@babel/code-frame': 7.26.2 + error-ex: 1.3.2 + json-parse-even-better-errors: 2.3.1 + lines-and-columns: 1.2.4 + + path-exists@4.0.0: {} + + path-is-absolute@1.0.1: {} + + path-key@3.1.1: {} + + path-parse@1.0.7: {} + + path-type@4.0.0: {} + + picocolors@1.1.1: {} + + picomatch@2.3.1: {} + + plur@4.0.0: + dependencies: + irregular-plurals: 3.5.0 + + prelude-ls@1.2.1: {} + + pretty-format@29.7.0: + dependencies: + '@jest/schemas': 29.6.3 + ansi-styles: 5.2.0 + react-is: 18.3.1 + + punycode@2.3.1: {} + + queue-microtask@1.2.3: {} + + quick-lru@4.0.1: {} + + react-is@18.3.1: {} + + read-pkg-up@7.0.1: + dependencies: + find-up: 4.1.0 + read-pkg: 5.2.0 + type-fest: 0.8.1 + + read-pkg@5.2.0: + dependencies: + '@types/normalize-package-data': 2.4.4 + normalize-package-data: 2.5.0 + parse-json: 5.2.0 + type-fest: 0.6.0 + + redent@3.0.0: + dependencies: + indent-string: 4.0.0 + strip-indent: 3.0.0 + + resolve-from@4.0.0: {} + + resolve@1.22.10: + dependencies: + is-core-module: 2.16.1 + path-parse: 1.0.7 + supports-preserve-symlinks-flag: 1.0.0 + + reusify@1.1.0: {} + + rimraf@3.0.2: + dependencies: + glob: 7.2.3 + + run-parallel@1.2.0: + dependencies: + queue-microtask: 1.2.3 + + semver@5.7.2: {} + + semver@7.7.1: {} + + shebang-command@2.0.0: + dependencies: + shebang-regex: 3.0.0 + + shebang-regex@3.0.0: {} + + slash@3.0.0: {} + + spdx-correct@3.2.0: + dependencies: + spdx-expression-parse: 3.0.1 + spdx-license-ids: 3.0.21 + + spdx-exceptions@2.5.0: {} + + spdx-expression-parse@3.0.1: + dependencies: + spdx-exceptions: 2.5.0 + spdx-license-ids: 3.0.21 + + spdx-license-ids@3.0.21: {} + + string-width@4.2.3: + dependencies: + emoji-regex: 8.0.0 + is-fullwidth-code-point: 3.0.0 + strip-ansi: 6.0.1 + + strip-ansi@6.0.1: + dependencies: + ansi-regex: 5.0.1 + + strip-indent@3.0.0: + dependencies: + min-indent: 1.0.1 + + strip-json-comments@3.1.1: {} + + supports-color@7.2.0: + dependencies: + has-flag: 4.0.0 + + supports-hyperlinks@2.3.0: + dependencies: + has-flag: 4.0.0 + supports-color: 7.2.0 + + supports-preserve-symlinks-flag@1.0.0: {} + + text-table@0.2.0: {} + + to-regex-range@5.0.1: + dependencies: + is-number: 7.0.0 + + trim-newlines@3.0.1: {} + + ts-api-utils@1.4.3(typescript@5.3.3): + dependencies: + typescript: 5.3.3 + + tsd@0.32.0: + dependencies: + '@tsd/typescript': 5.8.3 + eslint-formatter-pretty: 4.1.0 + globby: 11.1.0 + jest-diff: 29.7.0 + meow: 9.0.0 + path-exists: 4.0.0 + read-pkg-up: 7.0.1 + + type-check@0.4.0: + dependencies: + prelude-ls: 1.2.1 + + type-fest@0.18.1: {} + + type-fest@0.20.2: {} + + type-fest@0.21.3: {} + + type-fest@0.6.0: {} + + type-fest@0.8.1: {} + + typescript@5.3.3: {} + + uri-js@4.4.1: + dependencies: + punycode: 2.3.1 + + validate-npm-package-license@3.0.4: + dependencies: + spdx-correct: 3.2.0 + spdx-expression-parse: 3.0.1 + + which@2.0.2: + dependencies: + isexe: 2.0.0 + + word-wrap@1.2.5: {} + + wrappy@1.0.2: {} + + yallist@4.0.0: {} + + yargs-parser@20.2.9: {} + + yocto-queue@0.1.0: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..b435195 --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,3 @@ +overrides: + brace-expansion@>=1.0.0 <=1.1.11: '>=1.1.12' + brace-expansion@>=2.0.0 <=2.0.1: '>=2.0.2' diff --git a/test/.eslintrc.js b/test/.eslintrc.js new file mode 100644 index 0000000..ed1bd7e --- /dev/null +++ b/test/.eslintrc.js @@ -0,0 +1,5 @@ +module.exports = { + rules: { + indent: ['error', 2], + }, +} \ No newline at end of file diff --git a/test/api_doc.test.ts b/test/api-doc.test.ts similarity index 61% rename from test/api_doc.test.ts rename to test/api-doc.test.ts index 604313b..bea1c05 100644 --- a/test/api_doc.test.ts +++ b/test/api-doc.test.ts @@ -1,5 +1,4 @@ import { expectType } from 'tsd' - // Test case from `Animation` { Page({ @@ -455,8 +454,12 @@ import { expectType } from 'tsd' { const worker = wx.createWorker('workers/request/index.js') // 文件名指定 worker 的入口文件路径,绝对路径 - worker.onMessage(function(res) { - expectType>(res.message) + worker.onMessage(function (res) { + expectType(res) + }) + // 监听worker被系统回收事件 + worker.onProcessKilled(function () { + console.log('worker has been killed') }) worker.postMessage({ @@ -508,6 +511,17 @@ import { expectType } from 'tsd' }) } +// Test case from `wx.authorizeForMiniProgram` +{ + wx.authorizeForMiniProgram({ + scope: 'scope.record', + success() { + // 用户已经同意小程序使用录音功能,后续调用 wx.startRecord 接口不会弹窗询问 + wx.startRecord() + }, + }) +} + // Test case from `wx.canIUse` { // 对象的属性或方法 @@ -822,7 +836,7 @@ import { expectType } from 'tsd' // Test case from `wx.getConnectedBluetoothDevices` { wx.getConnectedBluetoothDevices({ - services: [''], + services: ['FEE7'], success(res) { res.devices.forEach(device => { expectType(device.deviceId) @@ -832,17 +846,6 @@ import { expectType } from 'tsd' }) } -// Test case from `wx.getFileInfo` -{ - wx.getFileInfo({ - filePath: '', - success(res) { - expectType(res.size) - expectType(res.digest) - }, - }) -} - // Test case from `wx.getHCEState` { wx.getHCEState({ @@ -895,47 +898,55 @@ import { expectType } from 'tsd' // Test case from `wx.getRealtimeLogManager` { - const logger = wx.getRealtimeLogManager() - logger.info({ str: 'hello world' }, 'info log', 100, [1, 2, 3]) - logger.error({ str: 'hello world' }, 'error log', 100, [1, 2, 3]) - logger.warn({ str: 'hello world' }, 'warn log', 100, [1, 2, 3]) -} + // 小程序端 + { + const logger = wx.getRealtimeLogManager() + logger.info({ str: 'hello world' }, 'info log', 100, [1, 2, 3]) + logger.error({ str: 'hello world' }, 'error log', 100, [1, 2, 3]) + logger.warn({ str: 'hello world' }, 'warn log', 100, [1, 2, 3]) + } -// Test case from `wx.getSavedFileInfo` -{ - wx.getSavedFileList({ - success(res) { - res.fileList - }, - }) + // 插件端,基础库 2.16.0 版本后支持,只允许采用 key-value 的新格式上报 + { + const logManager = wx.getRealtimeLogManager() + const logger = logManager.tag('plugin-log1') + logger.info('key1', 'value1') + logger.error('key2', { str: 'value2' }) + logger.warn('key3', 'value3') + } } -// Test case from `wx.getSavedFileList` +// Test case from `wx.getSelectedTextRange` { - wx.getSavedFileList({ + wx.getSelectedTextRange({ success(res) { - res.fileList + expectType(res.start) + expectType(res.end) }, }) } -// Test case from `wx.getSelectedTextRange` +// Test case from `wx.getSetting` { - wx.getSelectedTextRange({ + wx.getSetting({ success(res) { - expectType(res.start) - expectType(res.end) + expectType(res.authSetting['scope.address']) + expectType(res.subscriptionsSetting.mainSwitch) + expectType | undefined>(res.subscriptionsSetting.itemSettings) }, }) } -// Test case from `wx.getSetting` +// Test case from `SubscriptionsSetting` { wx.getSetting({ + withSubscriptions: true, success(res) { - res.authSetting = { - 'scope.userInfo': true, - 'scope.userLocation': true, + expectType(res.authSetting['scope.userInfo']) + expectType(res.authSetting['scope.userLocation']) + expectType(res.subscriptionsSetting.mainSwitch) + if (res.subscriptionsSetting.itemSettings !== undefined) { + expectType(res.subscriptionsSetting.itemSettings.SYS_MSG_TYPE_INTERACTIVE) } }, }) @@ -983,6 +994,8 @@ import { expectType } from 'tsd' }) } +type TPlatform = 'ios' | 'android' | 'windows' | 'mac' | 'devtools' | 'ohos' + // Test case from `wx.getSystemInfoSync` { wx.getSystemInfo({ @@ -993,7 +1006,7 @@ import { expectType } from 'tsd' expectType(res.windowHeight) expectType(res.language) expectType(res.version) - expectType(res.platform) + expectType(res.platform) }, }) } @@ -1008,11 +1021,26 @@ import { expectType } from 'tsd' expectType(res.windowHeight) expectType(res.language) expectType(res.version) - expectType(res.platform) + expectType(res.platform) }, }) } +// Test case from `wx.getSystemInfoAsync` +{ + wx.getSystemInfoAsync({ + success (res) { + expectType(res.model) + expectType(res.pixelRatio) + expectType(res.windowWidth) + expectType(res.windowHeight) + expectType(res.language) + expectType(res.version) + expectType(res.platform) + } + }) +} + // Test case from `wx.getUserInfo` { // 必须是在用户已经授权的情况下调用 @@ -1055,6 +1083,13 @@ import { expectType } from 'tsd' wx.hideShareMenu() } +// Test case from `wx.hideShareMenu` +{ + wx.hideShareMenu({ + menus: ['shareAppMessage', 'shareTimeline'], + }) +} + // Test case from `wx.loadFontFace` { wx.loadFontFace({ @@ -1071,7 +1106,7 @@ import { expectType } from 'tsd' if (res.code) { // 发起网络请求 wx.request({ - url: 'https://test.com/onLogin', + url: 'https://example.com/onLogin', data: { code: res.code, }, @@ -1388,22 +1423,6 @@ import { expectType } from 'tsd' }) } -// Test case from `wx.removeSavedFile` -{ - wx.getSavedFileList({ - success(res) { - if (res.fileList.length > 0) { - wx.removeSavedFile({ - filePath: res.fileList[0].filePath, - complete(res) { - console.log(res) - }, - }) - } - }, - }) -} - // Test case from `wx.removeStorageSync` { wx.removeStorage({ @@ -1451,17 +1470,20 @@ import { expectType } from 'tsd' } // Test case from `wx.requestSubscribeMessage` -// { -// wx.requestSubscribeMessage({ -// tmplIds: [''], -// success(res) {} -// }) -// } +{ + wx.requestSubscribeMessage({ + tmplIds: [''], + success(res) { + expectType(res.errMsg) + expectType(res.anyTemplateId) + } + }) +} // Test case from `wx.request` { wx.request({ - url: 'test.php', // 仅为示例,并非真实的接口地址 + url: 'example.php', //仅为示例,并非真实的接口地址 data: { x: '', y: '', @@ -1475,21 +1497,6 @@ import { expectType } from 'tsd' }) } -// Test case from `wx.saveFile` -{ - wx.chooseImage({ - success(res) { - const tempFilePaths = res.tempFilePaths - wx.saveFile({ - tempFilePath: tempFilePaths[0], - success(res) { - res.savedFilePath - }, - }) - }, - }) -} - // Test case from `wx.saveImageToPhotosAlbum` { wx.saveImageToPhotosAlbum({ @@ -1744,6 +1751,14 @@ import { expectType } from 'tsd' }) } +// Test case from `wx.showShareMenu` +{ + wx.showShareMenu({ + withShareTicket: true, + menus: ['shareAppMessage', 'shareTimeline'], + }) +} + // Test case from `wx.showToast` { wx.showToast({ @@ -1926,6 +1941,24 @@ import { expectType } from 'tsd' }) } +// Test case from `wx.updateShareMenu` +{ + // 转发私密消息 + wx.updateShareMenu({ + isPrivateMessage: true, + activityId: 'xxx', + templateInfo: { + templateId: '', + parameterList: [{ + name: '', + value: '', + }] + }, + success() {}, + fail() {}, + }) +} + // Test case from `wx.uploadFile` { wx.chooseImage({ @@ -1978,6 +2011,28 @@ import { expectType } from 'tsd' }) } +// Test case from `wx.createWorker` +{ + // 创建普通worker + wx.createWorker('workers/index.js') +} + +// Test case from `wx.createWorker` +{ + // 创建实验worker + const worker = wx.createWorker('workers/index.js', { + useExperimentalWorker: true, + }) + + // 监听worker被系统回收事件 + worker.onProcessKilled(() => { + // 重新创建一个worker + wx.createWorker('workers/index.js', { + useExperimentalWorker: true, + }) + }) +} + // Test case from `wx.clearStorageSync` { try { @@ -2054,7 +2109,7 @@ import { expectType } from 'tsd' expectType(res.windowHeight) expectType(res.language) expectType(res.version) - expectType(res.platform) + expectType(res.platform) } catch (e) { // Do something when catch error } @@ -2070,7 +2125,7 @@ import { expectType } from 'tsd' expectType(res.windowHeight) expectType(res.language) expectType(res.version) - expectType(res.platform) + expectType(res.platform) } catch (e) { // Do something when catch error } @@ -3002,6 +3057,25 @@ import { expectType } from 'tsd' }) } +// Test case from `MapContext.on` +{ + Page({ + mapCtx: {} as WechatMiniprogram.MapContext, + onReady() { + // 使用 wx.createMapContext 获取 map 上下文 + this.mapCtx = wx.createMapContext('myMap') + }, + method() { + this.mapCtx.on('markerClusterCreate', (res) => { + expectType(res) + }) + this.mapCtx.on('markerClusterClick', (res) => { + expectType(res) + }) + } + }) +} + // Test case from `wx.setEnableDebug` { // 打开调试 @@ -3022,12 +3096,14 @@ import { expectType } from 'tsd' onLoad(option) { console.log(option.query) const eventChannel = this.getOpenerEventChannel() - eventChannel.emit('acceptDataFromOpenedPage', { data: 'test' }) - eventChannel.emit('someEvent', { data: 'test' }) - // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据 - eventChannel.on('acceptDataFromOpenerPage', function(data: any) { - console.log(data) - }) + if (typeof eventChannel.emit === 'function') { + eventChannel.emit('acceptDataFromOpenedPage', { data: 'test' }) + eventChannel.emit('someEvent', { data: 'test' }) + // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据 + eventChannel.on('acceptDataFromOpenerPage', function(data: any) { + console.log(data) + }) + } }, }) } @@ -3042,15 +3118,1511 @@ import { expectType } from 'tsd' }) } -// Test case from `wx.getSetting` +// Test case from `wx.chooseMedia` { - wx.getSetting({ - withSubscriptions: true, + wx.chooseMedia({ + count: 9, + mediaType: ['image', 'video'], + sourceType: ['album', 'camera'], + maxDuration: 30, + camera: 'back', success(res) { - expectType(res.authSetting) - expectType(res.authSetting['scope.userInfo']) - expectType(res.authSetting['scope.subscribeMessage']) - expectType>(res.subscriptionsSetting) + expectType(res.tempFiles[0].tempFilePath) + expectType(res.tempFiles[0].thumbTempFilePath) + expectType(res.tempFiles[0].width) + expectType(res.tempFiles[0].height) + expectType(res.tempFiles[0].size) + expectType(res.tempFiles[0].duration) + }, + }) +} + +// Test case from `wx.reportPerformance` +{ + wx.reportPerformance(1101, 680) + wx.reportPerformance(1101, 680, 'custom') +} + +// Test case from `wx.getRandomValues` +{ + wx.getRandomValues({ + length: 6, // 生成 6 个字节长度的随机数 + success: res => { + expectType(res.randomValues) // 转换为 base64 字符串后打印 + } + }) +} + +// Test case from `wx.getGroupEnterInfo` +{ + wx.getGroupEnterInfo({ + success(res) { + expectType(res.errMsg) + expectType(res.encryptedData) + expectType(res.iv) + } + }) +} + +// Test case from `wx.getPerformance` +{ + const performance = wx.getPerformance() + const observer = performance.createObserver(entryList => { + console.log(entryList.getEntries()) + }) + // FIXME + // @ts-ignore + observer.observe({ entryTypes: ['render', 'script', 'navigation'] }) +} + +// Test case from `wx.authPrivateMessage` +{ + wx.authPrivateMessage({ + shareTicket: 'xxxxxx', + success(res) { + expectType(res.valid) + expectType(res.iv) + expectType(res.encryptedData) + }, + fail(res) { + expectType(res.errMsg) + }, + }) +} + +// Test case from `wx.createMediaAudioPlayer` +{ + // 创建视频解码器,具体参数见 createVideoDecoder 文档 + const videoDecoder = wx.createVideoDecoder() + // 创建媒体音频播放器 + const mediaAudioPlayer = wx.createMediaAudioPlayer() + // 启动视频解码器 + videoDecoder.start({ + source: '' + }) + // 启动播放器 + mediaAudioPlayer.start().then(() => { + // 添加播放器音频来源 + mediaAudioPlayer.addAudioSource(videoDecoder).then(res => { + videoDecoder.getFrameData() // 建议在 requestAnimationFrame 里获取每一帧视频数据 + console.log(res) + }) + + // 移除播放器音频来源 + mediaAudioPlayer.removeAudioSource(videoDecoder).then() + // 停止播放器 + mediaAudioPlayer.stop().then() + // 销毁播放器 + mediaAudioPlayer.destroy().then() + // 设置播放器音量 + mediaAudioPlayer.volume = 0.5 + }) +} + +// Test case from `ScrollViewContext` +{ + wx.createSelectorQuery() + .select('#scrollview') + .node() + .exec(res => { + const scrollView = res[0].node + scrollView.scrollEnabled = false + }) +} + +// Test case from `wx.getUserProfile` +{ + Page({ + data: { + userInfo: {}, + hasUserInfo: false, + canIUseGetUserProfile: false, + }, + onLoad() { + if (wx.getUserProfile !== undefined) { + this.setData({ + canIUseGetUserProfile: true, + }) + } + }, + getUserProfile() { + // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认 + // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗 + wx.getUserProfile({ + desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 + success: res => { + this.setData({ + userInfo: res.userInfo, + hasUserInfo: true, + }) + }, + }) + }, + getUserInfo(e: WechatMiniprogram.CustomEvent<{ userInfo: WechatMiniprogram.UserInfo }>) { + // 不推荐使用getUserInfo获取用户信息,预计自2021年4月13日起,getUserInfo将不再弹出弹窗,并直接返回匿名的用户个人信息 + this.setData({ + userInfo: e.detail.userInfo, + hasUserInfo: true, + }) + }, + }) +} + +// Test case from `FileSystemManager.close` +{ + const fs = wx.getFileSystemManager() + // 打开文件 + fs.open({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+', + success(res) { + // 关闭文件 + fs.close({ + fd: res.fd, + }) + }, + }) +} + +// Test case from `FileSystemManager.closeSync` +{ + const fs = wx.getFileSystemManager() + const fd = fs.openSync({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+', + }) + + // 关闭文件 + fs.closeSync({ fd: fd }) +} + +// Test case from `FileSystemManager.fstat` +{ + const fs = wx.getFileSystemManager() + // 打开文件 + fs.open({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+', + success(res) { + // 获取文件的状态信息 + fs.fstat({ + fd: res.fd, + success(res) { + expectType(res.stats) + }, + }) + }, + }) +} + +// Test case from `FileSystemManager.fstatSync` +{ + const fs = wx.getFileSystemManager() + const fd = fs.openSync({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+', + }) + const stats = fs.fstatSync({ fd: fd }) + expectType(stats) +} + +// Test case from `FileSystemManager.ftruncate` +{ + const fs = wx.getFileSystemManager() + // 打开文件 + fs.open({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+', + success(res) { + // 对文件内容进行截断操作 + fs.ftruncate({ + fd: res.fd, + length: 10, // 从第10个字节开始截断文件 + success(res) { + console.log(res) + }, + }) + }, + }) +} + +// Test case from `FileSystemManager.ftruncateSync` +{ + const fs = wx.getFileSystemManager() + const fd = fs.openSync({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+', + }) + fs.ftruncateSync({ + fd: fd, + length: 10, // 从第10个字节开始截断文件 + }) +} + +// Test case from `FileSystemManager.open` +{ + const fs = wx.getFileSystemManager() + fs.open({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+', + success(res) { + expectType(res.fd) + }, + }) +} + +// Test case from `FileSystemManager.openSync` +{ + const fs = wx.getFileSystemManager() + const fd = fs.openSync({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+', + }) + expectType(fd) +} + +// Test case from `FileSystemManager.read` +{ + const fs = wx.getFileSystemManager() + const ab = new ArrayBuffer(1024) + // 打开文件 + fs.open({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+', + success(res) { + // 读取文件到 ArrayBuffer 中 + fs.read({ + fd: res.fd, + arrayBuffer: ab, + length: 10, + success(res) { + console.log(res) + }, + }) }, }) } + +// Test case from `FileSystemManager.readSync` +{ + const fs = wx.getFileSystemManager() + const ab = new ArrayBuffer(1024) + const fd = fs.openSync({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+', + }) + const res = fs.readSync({ + fd: fd, + arrayBuffer: ab, + length: 10, + }) + console.log(res) +} + +// Test case from `FileSystemManager.truncate` +{ + const fs = wx.getFileSystemManager() + fs.truncate({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + length: 10, // 从第10个字节开始截断 + success(res) { + console.log(res) + }, + }) +} + +// Test case from `FileSystemManager.truncateSync` +{ + const fs = wx.getFileSystemManager() + fs.truncateSync({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + length: 10, // 从第10个字节开始截断 + }) +} + +// Test case from `FileSystemManager.write` +{ + const fs = wx.getFileSystemManager() + // 打开文件 + fs.open({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+', + success(res) { + // 写入文件 + fs.write({ + fd: res.fd, + data: 'some text', + success(res) { + expectType(res.bytesWritten) + }, + }) + }, + }) +} + +// Test case from `FileSystemManager.writeSync` +{ + const fs = wx.getFileSystemManager() + const fd = fs.openSync({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+', + }) + const res = fs.writeSync({ + fd: fd, + data: 'some text', + }) + expectType(res.bytesWritten) +} + +// Test case from `FileSystemManager.access` +{ + const fs = wx.getFileSystemManager() + // 判断文件/目录是否存在 + fs.access({ + path: `${wx.env.USER_DATA_PATH}/hello.txt`, + success(res) { + // 文件存在 + console.log(res) + }, + fail(res) { + // 文件不存在或其他错误 + console.error(res) + } + }) + + // 同步接口 + try { + fs.accessSync(`${wx.env.USER_DATA_PATH}/hello.txt`) + } catch(e) { + console.error(e) + } +} + +// Test case from `FileSystemManager.accessSync` +{ + const fs = wx.getFileSystemManager() + // 判断文件/目录是否存在 + fs.access({ + path: `${wx.env.USER_DATA_PATH}/hello.txt`, + success(res) { + // 文件存在 + console.log(res) + }, + fail(res) { + // 文件不存在或其他错误 + console.error(res) + } + }) + + // 同步接口 + try { + fs.accessSync(`${wx.env.USER_DATA_PATH}/hello.txt`) + } catch(e) { + console.error(e) + } +} + +// Test case from `FileSystemManager.appendFile` +{ + const fs = wx.getFileSystemManager() + + fs.appendFile({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + data: 'some text', + encoding: 'utf8', + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } + }) + + // 同步接口 + try { + fs.appendFileSync(`${wx.env.USER_DATA_PATH}/hello.txt`, 'some text', 'utf8') + } catch(e) { + console.error(e) + } +} + +// Test case from `FileSystemManager.appendFileSync` +{ + const fs = wx.getFileSystemManager() + + fs.appendFile({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + data: 'some text', + encoding: 'utf8', + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } + }) + + // 同步接口 + try { + fs.appendFileSync(`${wx.env.USER_DATA_PATH}/hello.txt`, 'some text', 'utf8') + } catch(e) { + console.error(e) + } +} + +// Test case from `FileSystemManager.copyFile` +{ + const fs = wx.getFileSystemManager() + fs.copyFile({ + srcPath: `${wx.env.USER_DATA_PATH}/hello.txt`, + destPath: `${wx.env.USER_DATA_PATH}/hello_copy.txt`, + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } + }) + + // 同步接口 + try { + fs.copyFileSync( + `${wx.env.USER_DATA_PATH}/hello.txt`, + `${wx.env.USER_DATA_PATH}/hello_copy.txt` + ) + } catch(e) { + console.error(e) + } +} + +// Test case from `FileSystemManager.copyFileSync` +{ + const fs = wx.getFileSystemManager() + fs.copyFile({ + srcPath: `${wx.env.USER_DATA_PATH}/hello.txt`, + destPath: `${wx.env.USER_DATA_PATH}/hello_copy.txt`, + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } + }) + + // 同步接口 + try { + fs.copyFileSync( + `${wx.env.USER_DATA_PATH}/hello.txt`, + `${wx.env.USER_DATA_PATH}/hello_copy.txt` + ) + } catch(e) { + console.error(e) + } +} + +// Test case from `FileSystemManager.mkdir` +{ + const fs = wx.getFileSystemManager() + fs.mkdir({ + dirPath: `${wx.env.USER_DATA_PATH}/example`, + recursive: false, + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } + }) + + // 同步接口 + try { + fs.mkdirSync(`${wx.env.USER_DATA_PATH}/example`, false) + } catch(e) { + console.error(e) + } +} + +// Test case from `FileSystemManager.mkdirSync` +{ + const fs = wx.getFileSystemManager() + fs.mkdir({ + dirPath: `${wx.env.USER_DATA_PATH}/example`, + recursive: false, + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } + }) + + // 同步接口 + try { + fs.mkdirSync(`${wx.env.USER_DATA_PATH}/example`, false) + } catch(e) { + console.error(e) + } +} + +// Test case from `FileSystemManager.readFile` +{ + const fs = wx.getFileSystemManager() + fs.readFile({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + encoding: 'utf8', + position: 0, + success(res) { + console.log(res.data) + }, + fail(res) { + console.error(res) + } + }) + + // 同步接口 + try { + const res = fs.readFileSync(`${wx.env.USER_DATA_PATH}/hello.txt`, 'utf8', 0) + expectType(res) + } catch(e) { + console.error(e) + } +} + +// Test case from `FileSystemManager.readFileSync` +{ + const fs = wx.getFileSystemManager() + fs.readFile({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + encoding: 'utf8', + position: 0, + success(res) { + console.log(res.data) + }, + fail(res) { + console.error(res) + } + }) + + // 同步接口 + try { + const res = fs.readFileSync(`${wx.env.USER_DATA_PATH}/hello.txt`, 'utf8', 0) + expectType(res) + } catch(e) { + console.error(e) + } +} + +// Test case from `FileSystemManager.readZipEntry` +{ + const fs = wx.getFileSystemManager() + // 读取zip内某个或多个文件 + fs.readZipEntry({ + filePath: 'wxfile://from/to.zip', + entries: [{ + path: 'some_folder/my_file.txt', // zip内文件路径 + encoding: 'utf-8', // 指定读取文件的字符编码,如果不传 encoding,则以 ArrayBuffer 格式读取文件的二进制内容 + position: 0, // 从文件指定位置开始读,如果不指定,则从文件头开始读。读取的范围应该是左闭右开区间 [position, position+length)。有效范围:[0, fileLength - 1]。单位:byte + length: 10000, // 指定文件的长度,如果不指定,则读到文件末尾。有效范围:[1, fileLength]。单位:byte + }, { + path: 'other_folder/orther_file.txt', // zip内文件路径 + }], + success(res) { + console.log(res.entries) + // res.entries === { + // 'some_folder/my_file.txt': { + // errMsg: 'readZipEntry:ok', + // data: 'xxxxxx' + // }, + // 'other_folder/orther_file.txt': { + // data: (ArrayBuffer) + // } + // } + }, + fail(res) { + console.log(res.errMsg) + }, + }) + + // 读取zip内所有文件。允许指定统一的encoding。position、length则不再允许指定,分别默认为0和文件长度 + fs.readZipEntry({ + filePath: 'wxfile://from/to.zip', + entries: 'all', + encoding: 'utf-8', // 统一指定读取文件的字符编码,如果不传 encoding,则以 ArrayBuffer 格式读取文件的二进制内容 + success(res) { + console.log(res.entries) + // res.entries === { + // 'some_folder/my_file.txt': { + // errMsg: 'readZipEntry:ok', + // data: 'xxxxxx' + // }, + // 'other_folder/orther_file.txt': { + // errMsg: 'readZipEntry:ok', + // data: 'xxxxxx' + // } + // } + }, + fail(res) { + console.log(res.errMsg) + }, + }) +} + +// Test case from `FileSystemManager.readdir` +{ + const fs = wx.getFileSystemManager() + fs.readdir({ + dirPath: `${wx.env.USER_DATA_PATH}/example`, + success(res) { + console.log(res.files) + }, + fail(res) { + console.error(res) + } + }) + + // 同步接口 + try { + const res = fs.readdirSync(`${wx.env.USER_DATA_PATH}/example`) + expectType(res) + } catch(e) { + console.error(e) + } +} + +// Test case from `FileSystemManager.readdirSync` +{ + const fs = wx.getFileSystemManager() + fs.readdir({ + dirPath: `${wx.env.USER_DATA_PATH}/example`, + success(res) { + console.log(res.files) + }, + fail(res) { + console.error(res) + } + }) + + // 同步接口 + try { + const res = fs.readdirSync(`${wx.env.USER_DATA_PATH}/example`) + expectType(res) + } catch(e) { + console.error(e) + } +} + +// Test case from `FileSystemManager.rename` +{ + const fs = wx.getFileSystemManager() + fs.rename({ + oldPath: `${wx.env.USER_DATA_PATH}/hello.txt`, + newPath: `${wx.env.USER_DATA_PATH}/hello_new.txt`, + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } + }) + + // 同步接口 + try { + const res = fs.renameSync( + `${wx.env.USER_DATA_PATH}/hello.txt`, + `${wx.env.USER_DATA_PATH}/hello_new.txt` + ) + console.log(res) + } catch(e) { + console.error(e) + } +} + +// Test case from `FileSystemManager.renameSync` +{ + const fs = wx.getFileSystemManager() + fs.rename({ + oldPath: `${wx.env.USER_DATA_PATH}/hello.txt`, + newPath: `${wx.env.USER_DATA_PATH}/hello_new.txt`, + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } + }) + + // 同步接口 + try { + const res = fs.renameSync( + `${wx.env.USER_DATA_PATH}/hello.txt`, + `${wx.env.USER_DATA_PATH}/hello_new.txt` + ) + console.log(res) + } catch(e) { + console.error(e) + } +} + +// Test case from `FileSystemManager.rmdir` +{ + const fs = wx.getFileSystemManager() + fs.rmdir({ + dirPath: `${wx.env.USER_DATA_PATH}/example`, + recursive: false, + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } + }) + + // 同步接口 + try { + const res = fs.rmdirSync(`${wx.env.USER_DATA_PATH}/example`, false) + console.log(res) + } catch(e) { + console.error(e) + } +} + +// Test case from `FileSystemManager.rmdirSync` +{ + const fs = wx.getFileSystemManager() + fs.rmdir({ + dirPath: `${wx.env.USER_DATA_PATH}/example`, + recursive: false, + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } + }) + + // 同步接口 + try { + const res = fs.rmdirSync(`${wx.env.USER_DATA_PATH}/example`, false) + console.log(res) + } catch(e) { + console.error(e) + } +} + +// Test case from `wx.saveFileToDisk` +{ + wx.saveFileToDisk({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } + }) +} + +// Test case from `FileSystemManager.unlink` +{ + const fs = wx.getFileSystemManager() + fs.unlink({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } + }) + + // 同步接口 + try { + const res = fs.unlinkSync(`${wx.env.USER_DATA_PATH}/hello.txt`) + console.log(res) + } catch(e) { + console.error(e) + } +} + +// Test case from `FileSystemManager.unlinkSync` +{ + const fs = wx.getFileSystemManager() + fs.unlink({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } + }) + + // 同步接口 + try { + const res = fs.unlinkSync(`${wx.env.USER_DATA_PATH}/hello.txt`) + console.log(res) + } catch(e) { + console.error(e) + } +} + +// Test case from `FileSystemManager.unzip` +{ + const fs = wx.getFileSystemManager() + fs.unzip({ + zipFilePath: `${wx.env.USER_DATA_PATH}/example.zip`, + targetPath: '${wx.env.USER_DATA_PATH}/example', + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } + }) +} + +// Test case from `FileSystemManager.writeFile` +{ + const fs = wx.getFileSystemManager() + fs.writeFile({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + data: 'some text or arrayBuffer', + encoding: 'utf8', + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } + }) + + // 同步接口 + try { + const res = fs.writeFileSync( + `${wx.env.USER_DATA_PATH}/hello.txt`, + 'some text or arrayBuffer', + 'utf8' + ) + console.log(res) + } catch(e) { + console.error(e) + } +} + +// Test case from `FileSystemManager.writeFileSync` +{ + const fs = wx.getFileSystemManager() + fs.writeFile({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + data: 'some text or arrayBuffer', + encoding: 'utf8', + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } + }) + + // 同步接口 + try { + const res = fs.writeFileSync( + `${wx.env.USER_DATA_PATH}/hello.txt`, + 'some text or arrayBuffer', + 'utf8' + ) + console.log(res) + } catch(e) { + console.error(e) + } +} + +// Test case from `UserCryptoManager.getLatestUserKey` +{ + const userCryptoManager = wx.getUserCryptoManager() + userCryptoManager.getLatestUserKey({ + success: res => { + const {encryptKey, iv, version, expireTime} = res + console.log(encryptKey, iv, version, expireTime) + } + }) +} + +// Test case from `UserCryptoManager.getRandomValues` +{ + wx.getRandomValues({ + length: 6, // 生成 6 个字节长度的随机数 + success: res => { + console.log(wx.arrayBufferToBase64(res.randomValues)) // 转换为 base64 字符串后打印 + } + }) +} + +// Test case from `wx.createVKSession` +{ + // 创建 session 对象 + const session = wx.createVKSession({ + track: { + plane: { mode: 1 }, + }, + }) + expectType(session) + + // 逐帧分析 + const onFrame = () => { + const canvasWidth = 0 + const canvasHeight = 0 + // 开发者可以自己控制帧率 + const frame = session.getVKFrame(canvasWidth, canvasHeight) + if (frame) { + // 分析完毕,可以拿到帧对象 + expectType(frame) + } + + session.requestAnimationFrame(onFrame) + } + session.start(err => { + if (!err) session.requestAnimationFrame(onFrame) + }) +} + +// Test case from `wx.createVKSession` +{ + const gl: WechatMiniprogram.WebGLRenderingContext = {} + const canvasWidth = 300 + const canvasHeight = 300 + // 以下 demo 以 v2 为例 + // 创建 session 对象 + const session = wx.createVKSession({ + track: { + plane: {mode: 3}, + }, + version: 'v2', + gl, + }) + // 逐帧分析 + const onFrame = (timestamp: number) => { + // 开发者可以自己控制帧率 + const frame = session.getVKFrame(canvasWidth, canvasHeight) + if (frame) { + // 分析完毕,可以拿到帧对象 + doRender(frame) + } + + expectType(timestamp) + + session.requestAnimationFrame(onFrame) + } + session.start(err => { + if (!err) session.requestAnimationFrame(onFrame) + }) + + // 渲染函数 + const doRender = (frame: WechatMiniprogram.VKFrame) => { + expectType(frame) + } +} + +// Test case from `wx.isVKSupport` +{ + const isSupportV2 = wx.isVKSupport('v2') + expectType(isSupportV2) +} + +// Test case from `FileSystemManager.readCompressedFile` +{ + const fs = wx.getFileSystemManager() + + // 异步接口 + fs.readCompressedFile({ + filePath: '${wx.env.USER_DATA_PATH}/hello.br', + compressionAlgorithm: 'br', + success(res) { + expectType(res.data) + }, + fail(res) { + console.log('readCompressedFile fail', res) + }, + }) + + // 同步接口 + const data = fs.readCompressedFileSync({ + filePath: '${wx.env.USER_DATA_PATH}/hello.br', + compressionAlgorithm: 'br', + }) + expectType(data) +} + +// Test case from `FileSystemManager.readCompressedFileSync` +{ + const fs = wx.getFileSystemManager() + + // 异步接口 + fs.readCompressedFile({ + filePath: '${wx.env.USER_DATA_PATH}/hello.br', + compressionAlgorithm: 'br', + success(res) { + expectType(res.data) + }, + fail(res) { + console.log('readCompressedFile fail', res) + }, + }) + + // 同步接口 + try { + const data = fs.readCompressedFileSync({ + filePath: '${wx.env.USER_DATA_PATH}/hello.br', + compressionAlgorithm: 'br', + }) + expectType(data) + } catch (err) { + console.log(err) + } +} + +// Test case from `wx.getStorage` +{ + // 开启加密存储 + wx.setStorage({ + key: 'key', + data: 'value', + encrypt: true, // 若开启加密存储,setStorage 和 getStorage 需要同时声明 encrypt 的值为 true + success() { + wx.getStorage({ + key: 'key', + encrypt: true, // 若开启加密存储,setStorage 和 getStorage 需要同时声明 encrypt 的值为 true + success(res) { + console.log(res.data) + }, + }) + }, + }) +} + +// Test case from `wx.getStorageSync` +{ + // 开启加密存储 + wx.setStorage({ + key: 'key', + data: 'value', + encrypt: true, // 若开启加密存储,setStorage 和 getStorage 需要同时声明 encrypt 的值为 true + success() { + wx.getStorage({ + key: 'key', + encrypt: true, // 若开启加密存储,setStorage 和 getStorage 需要同时声明 encrypt 的值为 true + success(res) { + console.log(res.data) + }, + }) + }, + }) +} + +// Test case from `wx.setStorage` +{ + // 开启加密存储 + wx.setStorage({ + key: 'key', + data: 'value', + encrypt: true, // 若开启加密存储,setStorage 和 getStorage 需要同时声明 encrypt 的值为 true + success() { + wx.getStorage({ + key: 'key', + encrypt: true, // 若开启加密存储,setStorage 和 getStorage 需要同时声明 encrypt 的值为 true + success(res) { + console.log(res.data) + }, + }) + }, + }) +} + +// Test case from `wx.setStorageSync` +{ + // 开启加密存储 + wx.setStorage({ + key: 'key', + data: 'value', + encrypt: true, // 若开启加密存储,setStorage 和 getStorage 需要同时声明 encrypt 的值为 true + success() { + wx.getStorage({ + key: 'key', + encrypt: true, // 若开启加密存储,setStorage 和 getStorage 需要同时声明 encrypt 的值为 true + success(res) { + console.log(res.data) + }, + }) + }, + }) +} + +// Test case from `wx.getLocalIPAddress` +{ + wx.getLocalIPAddress({ + success(res) { + const localip = res.localip + expectType(localip) + }, + }) +} + +// Test case from `wx.onNetworkWeakChange` +{ + wx.onNetworkWeakChange(function (res) { + console.log(res.weakNet) + console.log(res.networkType) + }) + // 取消监听 + wx.offNetworkWeakChange() +} + +// Test case from `VideoDecoder` +(async function () { + const decoder = wx.createVideoDecoder() + // 启动 videoDecoder + await new Promise(resolve => { + decoder.on('start', resolve) + decoder.start({ + source: 'http://...', + abortAudio: true, // 不需要音频 + }) + }) +}) + +// Test case from `wx.openCustomerServiceChat` +{ + wx.openCustomerServiceChat({ + extInfo: { url: '' }, + corpId: '', + success(res) { + expectType(res) + }, + }) +} + +// Test case from `wx.requestSubscribeDeviceMessage` +{ + wx.requestSubscribeDeviceMessage({ + tmplIds: ['xxxxx'], + sn: 'xxxx', + snTicket: 'xxxxx', + modelId: 'xxx', + success(res) { + console.log(res) + }, + fail(res) { + console.log(res) + }, + }) +} + +// Test case from `wx.getMenuButtonBoundingClientRect` +{ + const res = wx.getMenuButtonBoundingClientRect() + + console.log(res.width) + console.log(res.height) + console.log(res.top) + console.log(res.right) + console.log(res.bottom) + console.log(res.left) +} + +// Test case from `wx.createWorker` +{ + const createNewWorker = function () { + const worker = wx.createWorker('workers/index.js', { + useExperimentalWorker: true, + }) + // 监听worker被系统回收事件 + worker.onProcessKilled(() => { + // 重新创建一个worker + createNewWorker() + }) + } + // 创建实验worker + createNewWorker() +} + +// Test case from `wx.createBLEConnection` +{ + wx.createBLEConnection({ + deviceId: '', + success(res) { + console.log(res) + }, + }) +} + +// Test case from `wx.getBLEMTU` +{ + wx.getBLEMTU({ + deviceId: '', + writeType: 'write', + success(res) { + console.log(res) + }, + }) +} + +// Test case from `wx.onBLEMTUChange` +{ + wx.onBLEMTUChange(function (res) { + console.log('bluetooth mtu is', res.mtu) + }) +} + +// Test case from `wx.getAppAuthorizeSetting` +{ + const appAuthorizeSetting = wx.getAppAuthorizeSetting() + + console.log(appAuthorizeSetting.albumAuthorized) + console.log(appAuthorizeSetting.bluetoothAuthorized) + console.log(appAuthorizeSetting.cameraAuthorized) + console.log(appAuthorizeSetting.locationAuthorized) + console.log(appAuthorizeSetting.locationReducedAccuracy) + console.log(appAuthorizeSetting.microphoneAuthorized) + console.log(appAuthorizeSetting.notificationAlertAuthorized) + console.log(appAuthorizeSetting.notificationAuthorized) + console.log(appAuthorizeSetting.notificationBadgeAuthorized) + console.log(appAuthorizeSetting.notificationSoundAuthorized) + console.log(appAuthorizeSetting.phoneCalendarAuthorized) +} + +// Test case from `wx.getAppBaseInfo` +{ + const appBaseInfo = wx.getAppBaseInfo() + + console.log(appBaseInfo.SDKVersion) + console.log(appBaseInfo.enableDebug) + console.log(appBaseInfo.host) + console.log(appBaseInfo.language) + console.log(appBaseInfo.version) + console.log(appBaseInfo.theme) +} + +// Test case from `wx.getDeviceInfo` +{ + const deviceInfo = wx.getDeviceInfo() + + console.log(deviceInfo.abi) + console.log(deviceInfo.benchmarkLevel) + console.log(deviceInfo.brand) + console.log(deviceInfo.model) + console.log(deviceInfo.platform) + console.log(deviceInfo.system) +} + +// Test case from `wx.getSystemSetting` +{ + const systemSetting = wx.getSystemSetting() + + console.log(systemSetting.bluetoothEnabled) + console.log(systemSetting.deviceOrientation) + console.log(systemSetting.locationEnabled) + console.log(systemSetting.wifiEnabled) +} + +// Test case from `wx.getWindowInfo` +{ + const windowInfo = wx.getWindowInfo() + + console.log(windowInfo.pixelRatio) + console.log(windowInfo.screenWidth) + console.log(windowInfo.screenHeight) + console.log(windowInfo.windowWidth) + console.log(windowInfo.windowHeight) + console.log(windowInfo.statusBarHeight) + console.log(windowInfo.safeArea) + console.log(windowInfo.screenTop) +} + +// Test case from `wx.openAppAuthorizeSetting` +{ + wx.openAppAuthorizeSetting({ + success(res) { + console.log(res) + }, + }) +} + +// Test case from `wx.openSystemBluetoothSetting` +{ + wx.openSystemBluetoothSetting({ + success(res) { + console.log(res) + }, + }) +} + +// Test case from `WebAudioContext` +{ + // 监听状态 + const audioCtx = wx.createWebAudioContext() + audioCtx.onstatechange = () => { + expectType(audioCtx.state) + } + setTimeout(audioCtx.suspend, 1000) + setTimeout(audioCtx.resume, 2000) +} + +// Test case from `WebAudioContext.close` +{ + const audioCtx = wx.createWebAudioContext() + audioCtx.close().then(() => { + console.log(audioCtx.state) // bad case:不应该在close后再访问state + }) +} + +// Test case from `WebAudioContext.createPeriodicWave` +{ + const audioCtx = wx.createWebAudioContext() + + const real = new Float32Array(2) + const imag = new Float32Array(2) + real[0] = 0 + imag[0] = 0 + real[1] = 1 + imag[1] = 0 + + audioCtx.createPeriodicWave(real, imag, { + disableNormalization: true, + }) +} + +// Test case from `wx.preloadAssets` +{ + let imgUrl = '' + wx.preloadAssets({ + data: [ + { + type: 'image', + src: imgUrl, + }, + ], + success(resp) { + console.log('preloadAssets success', resp) + }, + fail(err) { + console.log('preloadAssets fail', err) + }, + }) +} + +// Test case from `wx.editImage` +{ + wx.editImage({ + src: '', // 图片路径 + }) +} + +// Test case from `wx.createCacheManager` +{ + const cacheManager = wx.createCacheManager({}) + cacheManager.addRule(/https:\/\/(?:.*)/ig) // 表示所有 https 请求都匹配 + + cacheManager.on('request', evt => { + // 在弱网时接收到 wx.request 请求 + return new Promise((resolve, reject) => { + const matchRes = cacheManager.match(evt) + if (matchRes && matchRes.data) { + // 有缓存,返回 + resolve(matchRes.data) + } else { + // 没缓存,抛错 + reject({ errMsg: 'no cache' }) + } + }) + }) +} + +// Test case from `CacheManager.addRule` +{ + const cacheManager = wx.createCacheManager({}) + const ruleId = cacheManager.addRule({ + id: 'haha-rule', + method: 'GET', + url: '/haha', + maxAge: 123455, + dataSchema: [ + // data 字段的匹配,默认为空,表示不匹配 + // 类型可以是:string、number、boolean、null、object、any(表示任意类型均可),以及这些类型的数组表示方式 + {name: 'aaa', schema: {type: 'string'}}, // 类型为 string + {name: 'bbb', schema: [{type: 'number'}, {type: 'string'}]}, // 类型为 number, string + {name: 'ccc', schema: {type: 'string', value: 'abc'}}, // 值为 abc + {name: 'ddd', schema: {type: 'string', value: /(abc|cba)/ig}}, // 值符合该正则匹配,如果该值不是字符串类型,则会被尝试转成字符串后再进行比较 + {name: 'ddd', schema: {type: 'string', value: (val: string) => val === '123'}}, // 传入函数来校验值 + {name: 'eee', schema: {type: 'object', value: [{ // 类型为对象,则通过嵌套的方式来逐层校验 + name: 'aaa', schema: {type: 'string'}, + // ... + // 嵌套 dataSchema,同上面的方式一样来匹配嵌套的对象 + }]}}, + {name: 'fff', schema: {type: 'string[]'}}, // 类型为 string 数组 + {name: 'ggg', schema: {type: 'any'}}, // 类型为任意类型 + {name: 'hhh', schema: {type: 'any[]'}}, // 类型为任意类型的数组 + ], + }) + expectType(ruleId) +} + +// Test case from `CacheManager.on` +{ + const cacheManager = wx.createCacheManager({}) + cacheManager.on('request', async function () { + // evt.url - 请求 url + // evt.data - 请求参数 + // evt.method - 请求方法 + // evt.request - 原始 request 方法,返回一个 promise + + // if (evt.url === '/xxx') { + // // 如果有些请求仍然希望走到网络,则可以如下处理 + // const res = await evt.request() + // // res 即为网络请求返回 + // } + + return new Promise((resolve, reject) => { + // do sth + let data = {} + if (data) { + // 这里 resolve 的 data 就会作为 wx.request 的 success 回调结果返回 + resolve(data) + } else { + // 这里 reject 的错误信息就会作为 wx.request 的 fail 回调结果返回 + reject('no data') + } + }) + }) +} + +// Test case from `CacheManager.match` +{ + const cacheManager = wx.createCacheManager({}) + cacheManager.on('request', (evt) => { + const cache = cacheManager.match(evt) + // 若有重复监听,则取第一个 handler 返回的 promise + return new Promise((resolve, reject) => { + if (cache.data) { + resolve(cache.data) + } else { + reject('no cache') + } + }) + }) +} + +// Test case from `wx.requestPluginPayment` +{ + wx.requestPluginPayment({ + version: 'release', + fee: 1, + paymentArgs: {}, + currencyType: 'CNY', + success (res) { + expectType(res.errMsg) + }, + fail (res) { + expectType(res.errMsg) + } + }) +} diff --git a/test/api-promisify.test.ts b/test/api-promisify.test.ts new file mode 100644 index 0000000..71ccac0 --- /dev/null +++ b/test/api-promisify.test.ts @@ -0,0 +1,198 @@ +import { expectType } from 'tsd' + +// call with callback +wx.chooseImage({ + success(res) { + expectType(res) + }, +}) +wx.canvasToTempFilePath({ + canvasId: '', + success(res) { + expectType( + res, + ) + }, +}) +wx.stopAccelerometer({ + fail(res) { + expectType(res) + }, +}) +wx.getClipboardData({ + success(res) { + expectType(res) + }, +}) +wx.stopCompass({ + complete(res) { + expectType(res) + }, +}) +wx.addPhoneContact({ + firstName: '', + complete(res) { + expectType(res) + }, +}) +wx.startLocalServiceDiscovery({ + serviceType: '', + success(res) { + expectType(res) + }, +}) +wx.getSystemInfo({ + success(res) { + expectType(res) + }, +}) +wx.chooseLocation({ + success(res) { + expectType(res) + }, +}) +wx.previewImage({ + urls: [], + success(res) { + expectType(res) + }, +}) +wx.saveVideoToPhotosAlbum({ + filePath: '', + success(res) { + expectType(res) + }, +}) + +wx.createBLEConnection({ + deviceId: '', + success(res) { + expectType(res) + }, +}) + +wx.startBluetoothDevicesDiscovery({ + success(res) { + expectType(res) + }, +}) +wx.hideShareMenu({ + success(res) { + expectType(res) + }, +}) + +wx.checkIsSupportSoterAuthentication({ + success(res) { + expectType< + WechatMiniprogram.CheckIsSupportSoterAuthenticationSuccessCallbackResult + >(res) + }, +}) +wx.navigateBack({ + success(res) { + expectType(res) + }, +}) + +// call with Promise.prototype.then +wx.chooseImage({}).then(res => { + expectType(res) +}) +wx.canvasToTempFilePath({ + canvasId: '', +}).then(res => { + expectType(res) +}) +wx.stopAccelerometer().then(res => { + expectType(res) +}) +wx.getClipboardData().then(res => { + expectType(res) +}) +wx.stopCompass().then(res => { + expectType(res) +}) +wx.addPhoneContact({ + firstName: '', +}).then(res => { + expectType(res) +}) +wx.startLocalServiceDiscovery({ serviceType: '' }).then(res => { + expectType(res) +}) +wx.getSystemInfo().then(res => { + expectType(res) +}) +wx.chooseLocation({}).then(res => { + expectType(res) +}) +wx.previewImage({ urls: [] }).then(res => { + expectType(res) +}) +wx.saveVideoToPhotosAlbum({ filePath: '' }).then(res => { + expectType(res) +}) +wx.createBLEConnection({ deviceId: '' }).then(res => { + expectType(res) +}) +wx.startBluetoothDevicesDiscovery({}).then(res => { + expectType(res) +}) +wx.hideShareMenu().then(res => { + expectType(res) +}) +wx.checkIsSupportSoterAuthentication().then(res => { + expectType< + WechatMiniprogram.CheckIsSupportSoterAuthenticationSuccessCallbackResult + >(res) +}) +wx.navigateBack().then(res => { + expectType(res) +}) + +// call with await +async () => { + expectType( + await wx.chooseImage({}), + ) + expectType( + await wx.canvasToTempFilePath({ canvasId: '' }), + ) + expectType( + await wx.stopAccelerometer(), + ) + expectType( + await wx.getClipboardData(), + ) + expectType(await wx.stopCompass()) + expectType( + await wx.addPhoneContact({ firstName: '' }), + ) + expectType( + await wx.startLocalServiceDiscovery({ serviceType: '' }), + ) + expectType( + await wx.getSystemInfo(), + ) + expectType( + await wx.chooseLocation({}), + ) + expectType( + await wx.previewImage({ urls: [] }), + ) + expectType( + await wx.saveVideoToPhotosAlbum({ filePath: '' }), + ) + expectType( + await wx.createBLEConnection({ deviceId: '' }), + ) + expectType( + await wx.startBluetoothDevicesDiscovery({}), + ) + expectType(await wx.hideShareMenu()) + expectType< + WechatMiniprogram.CheckIsSupportSoterAuthenticationSuccessCallbackResult + >(await wx.checkIsSupportSoterAuthentication()) + expectType(await wx.navigateBack()) +} diff --git a/test/api.test.ts b/test/api.test.ts index bb56e1c..b626b04 100644 --- a/test/api.test.ts +++ b/test/api.test.ts @@ -1,4 +1,4 @@ -import { expectType } from 'tsd' +import { expectType, expectNotType } from 'tsd' wx.request({ url: 'https://www.baidu.com', @@ -64,3 +64,48 @@ console.error('console', 'error') console.groupEnd() expectType(wx.env.USER_DATA_PATH) + +wx.getStorage({ + key: 'key', + success(res) { + expectType(res.data) + } +}) +wx.getStorage({ key: 'key' }).then((res) => { + expectType(res.data) +}) +wx.getStorage({ + key: 'key', + success(res) { + expectType(res.data) + expectNotType(res.data) + } +}) + +wx.request({ + url: 'https://developer.weixin.qq.com', + success(res) { + expectType(res.data) + } +}) + +{ + const thisShouldBeAny = wx.getStorageSync('test') + expectType(thisShouldBeAny) + expectNotType(thisShouldBeAny) + const thisShouldBeNumber = wx.getStorageSync('test') + expectNotType(thisShouldBeNumber) + expectType(thisShouldBeNumber) +} + +wx.createSelectorQuery() + .select('#canvas') + .node(({ node }) => { + const canvas = node as WechatMiniprogram.Canvas + const ctx = canvas.getContext('2d') + + expectNotType(ctx) + expectType(ctx.font) + expectType<() => void>(ctx.save) + }) + .exec() diff --git a/test/app.test.ts b/test/app.test.ts index e450cd9..751f166 100644 --- a/test/app.test.ts +++ b/test/app.test.ts @@ -39,6 +39,13 @@ App({ onPageNotFound(e) { expectType(e.isEntryPage) }, + onUnhandledRejection({ reason, promise }) { + expectType(reason) + expectType>(promise) + }, + onThemeChange(res) { + expectType<'dark' | 'light'>(res.theme) + }, }) expectType>>(getApp()) diff --git a/test/behavior.test.ts b/test/behavior.test.ts index 146ef53..603ab83 100644 --- a/test/behavior.test.ts +++ b/test/behavior.test.ts @@ -1,6 +1,6 @@ -import { expectType, expectError } from 'tsd' +import { expectType } from 'tsd' -expectType(Behavior({})) +expectType(Behavior({})) Behavior({ behaviors: [], @@ -31,7 +31,7 @@ Behavior({ attached() {}, methods: { myBehaviorMethod() { - expectError(this.created()) + expectType(this.created) expectType(this.data.text) expectType(this.properties.text) expectType(this.data.max) diff --git a/test/component.test.ts b/test/component.test.ts index c47f772..f15b9c4 100644 --- a/test/component.test.ts +++ b/test/component.test.ts @@ -1,4 +1,4 @@ -import { expectType, expectError } from 'tsd' +import { expectType, expectError, expectNotAssignable } from 'tsd' expectType(Component({})) @@ -62,7 +62,7 @@ Component({ moved() {}, detached() {}, error(err) { - expectType(err) + expectType(err) }, }, @@ -99,6 +99,25 @@ Component({ expectType(oldVal) }, }, + export() { + expectType(this.is) + expectType(this.onMyButtonTap()) + return {} + } +}) + +Component({ + methods: { + f() { + this.triggerEvent('someEvent', { + a: 'test', + b: 123, + c: { + t: 'test', + }, + }) + }, + }, }) expectError( @@ -106,7 +125,7 @@ expectError( custom: 1, methods: { f() { - expectError(this.custom) + this.custom }, }, }), @@ -159,7 +178,7 @@ Component({ expectType(this.data.n2) expectType(this.data.s) expectType(this.data.a) - expectType(this.data.a2) + expectType(this.data.a2) expectType(this.data.b) expectType>(this.data.o) expectType(this.data.a[0]) @@ -199,7 +218,7 @@ Component({ expectType(this.data.n2) expectType(this.data.s) expectType(this.data.a) - expectType(this.data.a2) + expectType(this.data.a2) expectType(this.data.b) expectType>(this.data.o) expectType>(this.data.o2) @@ -224,7 +243,7 @@ Component({ methods: { f() { expectType(this.data.n) - expectType(this.data.a) + expectType(this.data.a) }, }, }) @@ -288,3 +307,207 @@ Component({ onAChange() {}, }, }) + +Component({ + methods: { + animate() { + this.animate( + '#container', + [ + { opacity: 1.0, rotate: 0, backgroundColor: '#FF0000' }, + { opacity: 0.5, rotate: 45, backgroundColor: '#00FF00' }, + { opacity: 0.0, rotate: 90, backgroundColor: '#FF0000' }, + ], + 5000, + () => { + this.clearAnimation( + '#container', + { opacity: true, rotate: true }, + function() { + console.log('清除了#container上的opacity和rotate属性') + }, + ) + }, + ) + + this.animate( + '.block', + [ + { scale: [1, 1], rotate: 0, ease: 'ease-out' }, + { scale: [1.5, 1.5], rotate: 45, ease: 'ease-in', offset: 0.9 }, + { scale: [2, 2], rotate: 90 }, + ], + 5000, + () => { + this.clearAnimation('.block', function() { + console.log('清除了.block上的所有动画属性') + }) + }, + ) + }, + }, +}) + +Component({ + methods: { + animate() { + this.animate( + '.avatar', + [ + { + borderRadius: '0', + borderColor: 'red', + transform: 'scale(1) translateY(-20px)', + offset: 0, + }, + { + borderRadius: '25%', + borderColor: 'blue', + transform: 'scale(.65) translateY(-20px)', + offset: 0.5, + }, + { + borderRadius: '50%', + borderColor: 'blue', + transform: 'scale(.3) translateY(-20px)', + offset: 1, + }, + ], + 2000, + { + scrollSource: '#scroller', + timeRange: 2000, + startScrollOffset: 0, + endScrollOffset: 85, + }, + ) + + this.animate( + '.search_input', + [ + { + opacity: '0', + width: '0%', + }, + { + opacity: '1', + width: '100%', + }, + ], + 1000, + { + scrollSource: '#scroller', + timeRange: 1000, + startScrollOffset: 120, + endScrollOffset: 252, + }, + ) + }, + }, +}) + +Component({ + methods: { + test() { + const channel = this.getOpenerEventChannel() + // `tsd` not yet supports error `ts2722` + // expectError(channel.emit('test', {})) + expectNotAssignable<(...args: any[]) => any>(channel.emit) + channel.emit?.('test', {}) + expectError(channel.emit?.(1, 2)) + channel.on?.('xxx', () => {}) + if (typeof channel.emit === 'function') { + channel.on('xxx', () => {}) + } + }, + }, +}) + +Component<{}, {}, { fn(): void }, []>({ + methods: { + fn() { + expectError(this.notExists) + }, + }, +}) + +{ + const data = { + a: 1, + b: '', + } + const properties = { + c: String, + d: { + type: Number, + value: 4, + }, + } + Component< + typeof data, + typeof properties, + /* methods= */{ fn(): string }, + /* behaviors= */ [], + /* customProperties= */{}, + /* isPage= */true + >({ + data, + properties, + methods: { + onLoad(q) { + expectType(Object.keys(q)) + }, + fn() { + expectType<() => (void | Promise)>(this.onShow) + expectError(this.notExists) + return 'test' + }, + }, + }) +} + +{ + Component({ + properties: { + b: { + type: Boolean, + value: true, + } + }, + methods: { + test() { + expectType(this.data.b) + } + } + }) +} + +{ + Component({ + attached() { + this.setUpdatePerformanceListener({withDataPaths: true}, (res) => { + expectType(res.dataPaths) + expectType(res.updateProcessId) + }) + this.setUpdatePerformanceListener({}, res => { + expectType(res.dataPaths) + expectType(res.updateProcessId) + }) + this.setUpdatePerformanceListener({}) + } + }) +} + +{ + type CustomProperties = { + customProp: string + } + Component<{}, {}, {}, [], CustomProperties>({ + lifetimes: { + created() { + this.customProp = 'customProp' + } + } + }) +} + diff --git a/test/computed.test.d.ts b/test/computed.test.d.ts index b70db9e..ac157b0 100644 --- a/test/computed.test.d.ts +++ b/test/computed.test.d.ts @@ -12,24 +12,27 @@ declare namespace WechatMiniprogram { D extends DataOption, P extends PropertyOption, M extends MethodOption, - C extends ComputedOption - > = Instance & { data: ComputedOptionToData } + C extends ComputedOption, + CustomProperty extends IAnyObject = Record, + > = Instance & { data: ComputedOptionToData } type ComputedOptions< D extends DataOption, P extends PropertyOption, M extends MethodOption, - C extends ComputedOption + C extends ComputedOption, + CustomProperty extends IAnyObject = Record, > = Partial> & - ThisType> & - Options + ThisType> & + Options interface ComputedConstructor { < D extends DataOption, P extends PropertyOption, M extends MethodOption, - C extends ComputedOption + C extends ComputedOption, + CustomProperty extends IAnyObject = Record, >( - options: ComputedOptions, + options: ComputedOptions, ): string } } @@ -40,5 +43,6 @@ declare type ComputedOptions = WechatMiniprogram.Component.ComputedOptions< IAnyObject, IAnyObject, IAnyObject, + IAnyObject, IAnyObject > diff --git a/test/computed.test.ts b/test/computed.test.ts index 68804a7..bef52de 100644 --- a/test/computed.test.ts +++ b/test/computed.test.ts @@ -2,7 +2,8 @@ import { expectType } from 'tsd' /// -(Component as ComputedComponent)({ +const ComputedComponent = Component as ComputedComponent +ComputedComponent({ properties: { a: String, }, @@ -23,7 +24,13 @@ import { expectType } from 'tsd' }, }) -Behavior({ +type IMethods = { + _setData: WechatMiniprogram.Component.InstanceMethods<{}>['setData'] +} +type ICustomProperty = { + _originalSetData: WechatMiniprogram.Component.InstanceMethods<{}>['setData'] +} +Behavior<{}, {}, IMethods, [], ICustomProperty>({ lifetimes: { created() { this._originalSetData = this.setData diff --git a/test/issue.test.ts b/test/issue.test.ts index c79d636..08e0d96 100644 --- a/test/issue.test.ts +++ b/test/issue.test.ts @@ -1,4 +1,4 @@ -import { expectType } from 'tsd' +import { expectError, expectType } from 'tsd' // https://github.com/wechat-miniprogram/api-typings/issues/11 expectType(wx.env.USER_DATA_PATH) @@ -174,7 +174,7 @@ wx.request({ f?: () => string g: () => void } - type Dialog = WechatMiniprogram.Component.Instance<{}, {}, IDialogMethod> + type Dialog = WechatMiniprogram.Component.Instance<{}, {}, IDialogMethod, []> Page({ f() { const comp = this.selectComponent('#comp') as Dialog @@ -206,9 +206,14 @@ import WX = WechatMiniprogram // https://github.com/wechat-miniprogram/api-typings/issues/88 { - wx.canvasToTempFilePath({ canvas: '#canvas' }) + wx.createSelectorQuery() + .select('#canvas') + .fields({ node: true }) + .exec(res => { + wx.canvasToTempFilePath({ canvas: res[0].node }) + wx.canvasToTempFilePath({ canvas: res[0].node, quality: 0.5 }) + }) wx.canvasToTempFilePath({ canvasId: '' }) - wx.canvasToTempFilePath({ canvas: '', quality: 0.5 }) } // https://github.com/wechat-miniprogram/api-typings/issues/89 @@ -227,3 +232,427 @@ import WX = WechatMiniprogram }, }) } + +// https://github.com/wechat-miniprogram/api-typings/issues/95 +{ + Page({ + ctx: {} as WechatMiniprogram.CameraContext, + onLoad() { + this.ctx = wx.createCameraContext() + }, + takePhoto() { + this.ctx.takePhoto({ + quality: 'high', + success: res => { + expectType(res.tempImagePath) + this.setData({ + src: res.tempImagePath, + }) + }, + }) + }, + startRecord() { + this.ctx.startRecord({ + success: res => { + expectType(res.errMsg) + console.log('startRecord') + }, + }) + }, + stopRecord() { + this.ctx.stopRecord({ + success: res => { + expectType(res.tempThumbPath) + expectType(res.tempVideoPath) + this.setData({ + src: res.tempThumbPath, + videoSrc: res.tempVideoPath, + }) + }, + }) + }, + }) +} + +// https://github.com/wechat-miniprogram/api-typings/issues/133 +{ + type IData = { + name: string + } + type IProperty = { + id: typeof Number + } + type IMethod = { + setJob(job: string): void + } + type IBehavior = [] + type ICustomInstanceProperty = { + job: string + } + Component({ + properties: { + id: Number, + }, + + data: { + name: '', + }, + + methods: { + setJob(job) { + this.job = job + expectType(this.job) + }, + }, + }) +} + +// https://github.com/wechat-miniprogram/api-typings/issues/134 +{ + const ctx = wx.createMapContext('map') + ctx.getRegion({ + success(res) { + expectType(res.southwest.longitude) + expectType(res.southwest.latitude) + expectType(res.northeast.longitude) + expectType(res.northeast.latitude) + }, + }) +} + +// https://github.com/wechat-miniprogram/api-typings/issues/135 +{ + App({ + onThemeChange(res) { + expectType<'light' | 'dark'>(res.theme) + }, + }) +} + +// https://github.com/wechat-miniprogram/api-typings/issues/136 +{ + Page({ + onAddToFavorites(res) { + if (res.webviewUrl) { + // webview 页面返回 webviewUrl + expectType(res.webviewUrl) + } + return { + title: '自定义标题', + imageUrl: 'http://demo.png', + query: 'name=xxx&age=xxx', + } + }, + }) +} + +// https://github.com/wechat-miniprogram/api-typings/issues/154 +{ + wx.requestPayment({ + timeStamp: '', + nonceStr: '', + package: '', + signType: 'MD5', + paySign: '', + }) + wx.requestPayment({ + timeStamp: '', + nonceStr: '', + package: '', + signType: 'RSA', + paySign: '', + }) +} + +// https://github.com/wechat-miniprogram/api-typings/issues/157 +// Test case for #157 is removed since `wx.saveFile` is no longer supported + +// https://github.com/wechat-miniprogram/api-typings/issues/159 +{ + Page({ + onShareTimeline() { + return { + title: '', + query: '', + imageUrl: '', + } + }, + }) +} + +// https://github.com/wechat-miniprogram/api-typings/issues/161 +{ + Component({ + properties: { + bar: { + type: Object, + value: { skuNum: 0 }, + observer () {} + } + }, + data: { + foo: 123, + }, + methods: { + getDataOrPoperty() { + return this.data.foo + }, + test() { + expectType<{ + skuNum: number + }>(this.data.bar) + expectType(this.getDataOrPoperty()) + }, + } + }) +} + +// https://github.com/wechat-miniprogram/api-typings/issues/164 +{ + requirePlugin('myPlugin') + requireMiniProgram() +} + +// https://github.com/wechat-miniprogram/api-typings/issues/175 +{ + wx.requestSubscribeMessage({ + tmplIds: ['1', '2'], + success: (res) => { + expectType(res.errMsg) + expectType(res.whatever) + expectType(res.randomTemplateId) + }, + }) +} + +// https://github.com/wechat-miniprogram/api-typings/issues/204 +{ + Page({ + test() { + const observer = wx.createIntersectionObserver(this) + observer.observe('', e => { + expectType(e.id) + expectType>(e.dataset) + }) + } + }) +} + +// https://github.com/wechat-miniprogram/api-typings/issues/189 +{ + const offscreenCanvas = wx.createOffscreenCanvas(800, 600) + expectType(offscreenCanvas.height) + expectType(offscreenCanvas.width) +} + +// https://github.com/wechat-miniprogram/api-typings/issues/332 +{ + Component({ + data: { + a: '' + }, + methods: { + test() { + expectError(this.data.xxx) + }, + } + }) +} + +// https://github.com/wechat-miniprogram/api-typings/issues/332 +{ + interface Foo { + f: string + } + + Component({ + properties: { + bar: { + type: Object, + value: { f: '' } as Foo, + observer () {} + }, + foo: { + type: Array, + value: [] as Foo[], + } + }, + methods: { + getData() { + return this.data.foo + }, + test() { + expectType(this.data.bar) + expectType(this.properties.bar) + expectType(this.getData()) + }, + } + }) +} + +// https://github.com/wechat-miniprogram/api-typings/issues/332 +{ + const bA = Behavior({ + properties: { + pA: { + type: String, + value: '', + }, + pA1: Boolean + }, + data: { + dataA: 'init data', + }, + methods: { + methodA() { + return this.data.dataA + }, + }, + }) + const bB = Behavior({ + properties: { + pB: { + type: Array, + value: [] as string[], + } + }, + data: { + dataB: [] as string[], + }, + methods: { + methodB() { + return this.data.dataB + }, + }, + }) + + Component({ + behaviors: [bA, bB], + methods: { + test() { + expectType(this.data.pA) + expectType(this.data.pA1) + expectType(this.data.dataA) + expectType(this.data.pB) + expectType(this.data.dataB) + expectType(this.methodA()) + expectType(this.methodB()) + }, + } + }) +} +// https://github.com/wechat-miniprogram/api-typings/issues/332#issuecomment-2333434425 +{ + const b1 = Behavior({ + properties: { + pA: { + type: String, + value: '', + }, + pA1: Boolean + }, + data: { + dataA: 'init data', + }, + methods: { + methodA() { + return this.data.dataA + }, + }, + }) + const b2 = Behavior({ + behaviors: [b1], + properties: { + pB: { + type: Array, + value: [] as string[], + } + }, + data: { + dataB: [] as string[], + }, + methods: { + methodB() { + return this.data.dataB + }, + test() { + expectType(this.data.pA) + expectType(this.data.pA1) + expectType(this.data.dataA) + expectType(this.methodA()) + }, + }, + }) + + Component({ + behaviors: [b2], + methods: { + test() { + expectType(this.data.pA) + expectType(this.data.pA1) + expectType(this.data.dataA) + expectType(this.data.pB) + expectType(this.data.dataB) + expectType(this.methodA()) + expectType(this.methodB()) + }, + } + }) +} + +{ + const b1 = Behavior({ + methods: { + methodA() { + return [''] + }, + }, + }) + const b2 = Behavior({ + properties: { + pB: { + type: Array, + value: [] as string[], + } + } + }) + const b3 = Behavior({ + data: { + dataC: 'init data', + } + }) + + Component({ + behaviors: [b1, b2, b3], + methods: { + test() { + expectType(this.data.pB) + expectType(this.data.dataC) + expectType(this.methodA()) + expectError(this.data.xxx) + expectError(this.properties.yyy) + }, + } + }) +} + +// https://github.com/wechat-miniprogram/api-typings/pull/351 +{ + type Properties = { + customProp: string + [key: string]: unknown; + [key: number]: string; + } + Component({ + lifetimes: { + created() { + this.properties[1] = '1'; + expectError(() => { + this.properties[2] = 2; + }); + expectError(this.properties.xxx); + this.properties.customProp = 'customProp'; + } + } + }) +} \ No newline at end of file diff --git a/test/page.test.ts b/test/page.test.ts index 14825af..18080b6 100644 --- a/test/page.test.ts +++ b/test/page.test.ts @@ -1,4 +1,4 @@ -import { expectType, expectError } from 'tsd' +import { expectType, expectError, expectNotAssignable } from 'tsd' expectType(Page({})) @@ -6,9 +6,9 @@ expectType>(getCurrentPages()[0].data) const app = getApp<{ globalData: { - userInfo: WechatMiniprogram.UserInfo; - }; - userInfoReadyCallback(userInfo: WechatMiniprogram.UserInfo): void; + userInfo: WechatMiniprogram.UserInfo + } + userInfoReadyCallback(userInfo: WechatMiniprogram.UserInfo): void }>() Page({ @@ -68,7 +68,7 @@ Page({ onLoad(options) { expectType(options.from) const app = getApp<{ - globalData: { userInfo: WechatMiniprogram.UserInfo }; + globalData: { userInfo: WechatMiniprogram.UserInfo } }>() expectType(app.globalData.userInfo.nickName) }, @@ -83,7 +83,7 @@ Page({ onUnload() {}, onPullDownRefresh() {}, onShareAppMessage(res) { - expectType(res.from) + expectType<'button' | 'menu'>(res.from) if (res.from === 'button') { expectType(res.webViewUrl) } @@ -199,3 +199,46 @@ Page({ expectType(this.data.logs) }, }) + +Page({ + test() { + const channel = this.getOpenerEventChannel() + // `tsd` not yet supports error `ts2722` + // expectError(channel.emit('test', {})) + expectNotAssignable<(...args: any[]) => any>(channel.emit) + channel.emit?.('test', {}) + expectError(channel.emit?.(1, 2)) + channel.on?.('xxx', () => {}) + if (typeof channel.emit === 'function') { + channel.on('xxx', () => {}) + } + }, +}) + +Page({ + onAddToFavorites(res) { + // webview 页面返回 webviewUrl + if (res.webviewUrl) { + console.log('WebviewUrl: ', res.webviewUrl) + } + return { + title: '自定义标题', + imageUrl: 'http://demo.png', + query: 'name=xxx&age=xxx', + } + }, +}) + +Page({ + data: { a: '123' }, + onShow() { + expectType<() => number>(this.fn) + }, + fn() { + const a: number = 1 + return a + }, + onShareAppMessage(): WechatMiniprogram.Page.ICustomShareContent { + return { title: this.data.a, imageUrl: '', path: '' } + }, +}) \ No newline at end of file diff --git a/test/xr-frame.test.ts b/test/xr-frame.test.ts new file mode 100644 index 0000000..e70c06f --- /dev/null +++ b/test/xr-frame.test.ts @@ -0,0 +1,45 @@ +import { expectType } from 'tsd' + +import type * as XrFrame from 'XrFrame' + +const xrFrameSystem = wx.getXrFrameSystem() + +expectType(new xrFrameSystem.Element('test', () => {})) + +const AutoRotateTouchableGLTFDefaultComponents: XrFrame.IEntityComponents = Object.assign({ + 'mesh-shape': {}, + 'auto-rotate': {} +}, xrFrameSystem.GLTFDefaultComponents) + +const AutoRotateTouchableGLTFDataMapping: {[key: string]: string[]} = Object.assign({ + speed: ['auto-rotate', 'speed'] +}, xrFrameSystem.GLTFDataMapping) + +const Element = xrFrameSystem.Element + +class XRAutoRotateTouchableGLTF extends Element { + public readonly defaultComponents: XrFrame.IEntityComponents = AutoRotateTouchableGLTFDefaultComponents + public readonly dataMapping: {[key: string]: string[]} = AutoRotateTouchableGLTFDataMapping +} + +xrFrameSystem.registerElement('auto-rotate-touchable-gltf', XRAutoRotateTouchableGLTF) + +xrFrameSystem.registerMaterial('shining', scene => { + return scene.createMaterial(scene.assets.getAsset('effect', 'shining')) +}) + +const ShiningStarDefaultComponents: XrFrame.IEntityComponents = Object.assign({ + mesh: { + geometry: 'star', + material: 'shining' + } +}, xrFrameSystem.NodeDefaultComponents) + +const ShiningStarDataMapping: {[key: string]: string[]} = Object.assign({ + uniforms: ['mesh', 'uniforms'] +}, xrFrameSystem.NodeDataMapping) + +xrFrameSystem.registerElement('shining-star', class XRShiningStar extends Element { + public readonly defaultComponents: XrFrame.IEntityComponents = ShiningStarDefaultComponents + public readonly dataMapping: {[key: string]: string[]} = ShiningStarDataMapping +}) diff --git a/tsconfig.json b/tsconfig.json index 6479dfc..f96df03 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,7 @@ "experimentalDecorators": true, "inlineSourceMap": true, "inlineSources": true, - "lib": ["es5"], + "lib": ["es6"], "module": "CommonJS", "noFallthroughCasesInSwitch": true, "noImplicitAny": true, diff --git a/tslint.json b/tslint.json deleted file mode 100644 index 53f5e7a..0000000 --- a/tslint.json +++ /dev/null @@ -1,168 +0,0 @@ -{ - "defaultSeverity": "error", - "extends": [], - "rules": { - "adjacent-overload-signatures": true, - "align": { - "options": [ - "parameters", - "statements" - ] - }, - "arrow-return-shorthand": true, - "ban-types": { - "options": [ - [ - "Object", - "Avoid using the `Object` type. Did you mean `object`?" - ], - [ - "Function", - "Avoid using the `Function` type. Prefer a specific function type, like `() => void`." - ], - [ - "Boolean", - "Avoid using the `Boolean` type. Did you mean `boolean`?" - ], - [ - "Number", - "Avoid using the `Number` type. Did you mean `number`?" - ], - [ - "String", - "Avoid using the `String` type. Did you mean `string`?" - ], - [ - "Symbol", - "Avoid using the `Symbol` type. Did you mean `symbol`?" - ] - ] - }, - "comment-format": { - "options": [ - "check-space" - ] - }, - "curly": { - "options": [ - "ignore-same-line" - ] - }, - "cyclomatic-complexity": false, - "import-spacing": true, - "indent": { - "options": [ - "spaces" - ] - }, - "interface-name": false, - "interface-over-type-literal": true, - "no-angle-bracket-type-assertion": true, - "no-arg": true, - "no-conditional-assignment": true, - "no-debugger": true, - "no-duplicate-super": true, - "no-eval": true, - "no-internal-module": true, - "no-misused-new": true, - "no-reference-import": true, - "no-string-literal": true, - "no-string-throw": true, - "no-unnecessary-initializer": true, - "no-unsafe-finally": true, - "no-unused-expression": false, - "no-use-before-declare": false, - "no-var-keyword": true, - "no-var-requires": true, - "one-line": { - "options": [ - "check-catch", - "check-else", - "check-finally", - "check-open-brace", - "check-whitespace" - ] - }, - "one-variable-per-declaration": { - "options": [ - "ignore-for-loop" - ] - }, - "prefer-const": true, - "prefer-for-of": true, - "quotemark": { - "options": [ - "single", - "avoid-escape", - "jsx-double" - ] - }, - "radix": true, - "semicolon": { - "options": [ - "never" - ] - }, - "space-before-function-paren": { - "options": { - "anonymous": "never", - "asyncArrow": "always", - "constructor": "never", - "method": "never", - "named": "never" - } - }, - "trailing-comma": { - "options": { - "esSpecCompliant": true, - "multiline": "always", - "singleline": "never" - } - }, - "triple-equals": { - "options": [ - "allow-null-check" - ] - }, - "typedef": false, - "typedef-whitespace": { - "options": [ - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - }, - { - "call-signature": "onespace", - "index-signature": "onespace", - "parameter": "onespace", - "property-declaration": "onespace", - "variable-declaration": "onespace" - } - ] - }, - "typeof-compare": false, - "unified-signatures": true, - "use-isnan": true, - "whitespace": { - "options": [ - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type", - "check-typecast" - ] - }, - "no-trailing-whitespace": true, - "array-type": [ - true, - "array-simple" - ], - "object-literal-shorthand": true - }, - "jsRules": {}, - "rulesDirectory": [] -} \ No newline at end of file diff --git a/types/wx/index.d.ts b/types/wx/index.d.ts index f3f5f9a..d6deb26 100644 --- a/types/wx/index.d.ts +++ b/types/wx/index.d.ts @@ -1,22 +1,22 @@ /*! ***************************************************************************** -Copyright (c) 2020 Tencent, Inc. All rights reserved. +Copyright (c) 2025 Tencent, Inc. All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ***************************************************************************** */ @@ -24,11 +24,140 @@ SOFTWARE. /// /// /// +/// /// /// +/// +/// declare namespace WechatMiniprogram { type IAnyObject = Record type Optional = F extends (arg: infer P) => infer R ? (arg?: P) => R : F type OptionalInterface = { [K in keyof T]: Optional } + interface AsyncMethodOptionLike { + success?: (...args: any[]) => void + } + type PromisifySuccessResult< + P, + T extends AsyncMethodOptionLike + > = P extends { + success: any + } + ? void + : P extends { fail: any } + ? void + : P extends { complete: any } + ? void + : Promise>[0]> + + // TODO: Extract real definition from `lib.dom.d.ts` to replace this + type IIRFilterNode = any + type WaveShaperNode = any + type ConstantSourceNode = any + type OscillatorNode = any + type GainNode = any + type BiquadFilterNode = any + type PeriodicWaveNode = any + type AudioNode = any + type ChannelSplitterNode = any + type ChannelMergerNode = any + type DelayNode = any + type DynamicsCompressorNode = any + type ScriptProcessorNode = any + type PannerNode = any + type AnalyserNode = any + type WebGLTexture = any + type WebGLRenderingContext = any + + // TODO: fill worklet type + type WorkletFunction = (...args: any) => any + type AnimationObject = any + type SharedValue = T + type DerivedValue = T +} + +declare let console: WechatMiniprogram.Console + +declare let wx: WechatMiniprogram.Wx +/** 引入模块。返回模块通过 `module.exports` 或 `exports` 暴露的接口。 */ +interface Require { + ( + /** 需要引入模块文件相对于当前文件的相对路径,或 npm 模块名,或 npm 模块路径。不支持绝对路径 */ + module: string, + /** 用于异步获取其他分包中的模块的引用结果,详见 [分包异步化]((subpackages/async)) */ + callback?: (moduleExport: any) => void, + /** 异步获取分包失败时的回调,详见 [分包异步化]((subpackages/async)) */ + errorCallback?: (err: any) => void + ): any + /** 以 Promise 形式异步引入模块。返回模块通过 `module.exports` 或 `exports` 暴露的接口。 */ + async( + /** 需要引入模块文件相对于当前文件的相对路径,或 npm 模块名,或 npm 模块路径。不支持绝对路径 */ + module: string + ): Promise +} +declare const require: Require +/** 引入插件。返回插件通过 `main` 暴露的接口。 */ +interface RequirePlugin { + ( + /** 需要引入的插件的 alias */ + module: string, + /** 用于异步获取其他分包中的插件的引用结果,详见 [分包异步化]((subpackages/async)) */ + callback?: (pluginExport: any) => void + ): any + /** 以 Promise 形式异步引入插件。返回插件通过 `main` 暴露的接口。 */ + async( + /** 需要引入的插件的 alias */ + module: string + ): Promise } +declare const requirePlugin: RequirePlugin +/** 插件引入当前使用者小程序。返回使用者小程序通过 [插件配置中 `export` 暴露的接口](https://developers.weixin.qq.com/miniprogram/dev/framework/plugin/using.html#%E5%AF%BC%E5%87%BA%E5%88%B0%E6%8F%92%E4%BB%B6)。 + * + * 该接口只在插件中存在 + * + * 最低基础库: `2.11.1` */ +declare function requireMiniProgram(): any +/** 当前模块对象 */ +declare let module: { + /** 模块向外暴露的对象,使用 `require` 引用该模块时可以获取 */ + exports: any +} +/** `module.exports` 的引用 */ +declare let exports: any + +/** [clearInterval(number intervalID)](https://developers.weixin.qq.com/miniprogram/dev/api/base/timer/clearInterval.html) + * + * 取消由 setInterval 设置的定时器。 */ +declare function clearInterval( + /** 要取消的定时器的 ID */ + intervalID: number +): void +/** [clearTimeout(number timeoutID)](https://developers.weixin.qq.com/miniprogram/dev/api/base/timer/clearTimeout.html) + * + * 取消由 setTimeout 设置的定时器。 */ +declare function clearTimeout( + /** 要取消的定时器的 ID */ + timeoutID: number +): void +/** [number setInterval(function callback, number delay, any rest)](https://developers.weixin.qq.com/miniprogram/dev/api/base/timer/setInterval.html) + * + * 设定一个定时器。按照指定的周期(以毫秒计)来执行注册的回调函数 */ +declare function setInterval( + /** 回调函数 */ + callback: (...args: any[]) => any, + /** 执行回调函数之间的时间间隔,单位 ms。 */ + delay?: number, + /** param1, param2, ..., paramN 等附加参数,它们会作为参数传递给回调函数。 */ + ...rest: any[] +): number +/** [number setTimeout(function callback, number delay, any rest)](https://developers.weixin.qq.com/miniprogram/dev/api/base/timer/setTimeout.html) + * + * 设定一个定时器。在定时到期以后执行注册的回调函数 */ +declare function setTimeout( + /** 回调函数 */ + callback: (...args: any[]) => any, + /** 延迟的时间,函数的调用会在该延迟之后发生,单位 ms。 */ + delay?: number, + /** param1, param2, ..., paramN 等附加参数,它们会作为参数传递给回调函数。 */ + ...rest: any[] +): number diff --git a/types/wx/lib.wx.api.d.ts b/types/wx/lib.wx.api.d.ts index 07d0ac4..53f3d5b 100644 --- a/types/wx/lib.wx.api.d.ts +++ b/types/wx/lib.wx.api.d.ts @@ -1,33 +1,28 @@ /*! ***************************************************************************** -Copyright (c) 2020 Tencent, Inc. All rights reserved. +Copyright (c) 2025 Tencent, Inc. All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ***************************************************************************** */ +/// + declare namespace WechatMiniprogram { - interface AccessFailCallbackResult { - /** 错误信息 - * - * 可选值: - * - 'fail no such file or directory ${path}': 文件/目录不存在; */ - errMsg: string - } interface AccessOption { /** 要判断是否存在的文件/目录路径 (本地路径) */ path: string @@ -38,13 +33,35 @@ declare namespace WechatMiniprogram { /** 接口调用成功的回调函数 */ success?: AccessSuccessCallback } - /** 帐号信息 */ + /** 账号信息 */ interface AccountInfo { - /** 小程序帐号信息 */ + /** 小程序账号信息 */ miniProgram: MiniProgram - /** 插件帐号信息(仅在插件中调用时包含这一项) */ + /** 插件账号信息(仅在插件中调用时包含这一项) */ plugin: Plugin } + interface AddArcOption { + /** 终点 */ + end: MapPostion + /** 圆弧 id */ + id: number + /** 起始点 */ + start: MapPostion + /** 夹角角度 */ + angle?: number + /** 线的颜色 */ + color?: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: AddArcCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: AddArcFailCallback + /** 途经点 */ + pass?: MapPostion + /** 接口调用成功的回调函数 */ + success?: AddArcSuccessCallback + /** 线宽 */ + width?: number + } interface AddCardOption { /** 需要添加的卡券列表 */ cardList: AddCardRequestInfo[] @@ -78,6 +95,92 @@ declare namespace WechatMiniprogram { cardList: AddCardResponseInfo[] errMsg: string } + interface AddCustomLayerOption { + /** 个性化图层id */ + layerId: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: AddCustomLayerCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: AddCustomLayerFailCallback + /** 接口调用成功的回调函数 */ + success?: AddCustomLayerSuccessCallback + } + interface AddFileToFavoritesOption { + /** 要收藏的文件地址,必须为本地路径或临时路径 */ + filePath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: AddFileToFavoritesCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: AddFileToFavoritesFailCallback + /** 自定义文件名,若留空则使用filePath中的文件名 */ + fileName?: string + /** 接口调用成功的回调函数 */ + success?: AddFileToFavoritesSuccessCallback + } + interface AddGroundOverlayOption { + /** 图片覆盖的经纬度范围 */ + bounds: MapBounds + /** 图片图层 id */ + id: string + /** 图片路径,支持网络图片、临时路径、代码包路径 */ + src: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: AddGroundOverlayCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: AddGroundOverlayFailCallback + /** 图层透明度 */ + opacity?: number + /** 接口调用成功的回调函数 */ + success?: AddGroundOverlaySuccessCallback + /** 是否可见 */ + visible?: boolean + /** 图层绘制顺序 */ + zIndex?: number + } + interface AddMarkersOption { + /** 同传入 map 组件的 marker 属性 */ + markers: any[] + /** 是否先清空地图上所有 marker */ + clear?: boolean + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: AddMarkersCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: AddMarkersFailCallback + /** 接口调用成功的回调函数 */ + success?: AddMarkersSuccessCallback + } + interface AddPhoneCalendarOption { + /** 开始时间的 unix 时间戳 */ + startTime: number + /** 日历事件标题 */ + title: string + /** 是否提醒,默认 true */ + alarm?: boolean + /** 提醒提前量,单位秒,默认 0 表示开始时提醒 */ + alarmOffset?: number + /** 是否全天事件,默认 false */ + allDay?: boolean + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: AddPhoneCalendarCompleteCallback + /** 事件说明 */ + description?: string + /** 结束时间的 unix 时间戳,默认与开始时间相同 */ + endTime?: string + /** 接口调用失败的回调函数 */ + fail?: AddPhoneCalendarFailCallback + /** 事件位置 */ + location?: string + /** 需要基础库: `3.7.6` + * + * 跳转小程序路径,必须要和 signature 一起使用,填入后会自动生成跳转链接拼接在事件说明中 */ + path?: string + /** 需要基础库: `3.7.6` + * + * 跳转小程序路径签名,必须要和 path 一起使用,用 session_key 对 path 签名得到的结果,即 `hmac_sha256(session_key, path)`。详见 [用户数据的签名验证和加解密](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html) */ + signature?: string + /** 接口调用成功的回调函数 */ + success?: AddPhoneCalendarSuccessCallback + } interface AddPhoneContactOption { /** 名字 */ firstName: string @@ -150,17 +253,130 @@ declare namespace WechatMiniprogram { /** 工作电话 */ workPhoneNumber?: string } + interface AddPhoneRepeatCalendarOption { + /** 开始时间的 unix 时间戳 (1970年1月1日开始所经过的秒数) */ + startTime: number + /** 日历事件标题 */ + title: string + /** 是否提醒,默认 true */ + alarm?: boolean + /** 提醒提前量,单位秒,默认 0 表示开始时提醒 */ + alarmOffset?: number + /** 是否全天事件,默认 false */ + allDay?: boolean + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: AddPhoneRepeatCalendarCompleteCallback + /** 事件说明 */ + description?: string + /** 结束时间的 unix 时间戳,默认与开始时间相同 */ + endTime?: string + /** 接口调用失败的回调函数 */ + fail?: AddPhoneRepeatCalendarFailCallback + /** 事件位置 */ + location?: string + /** 需要基础库: `3.7.6` + * + * 跳转小程序路径,必须要和 signature 一起使用,填入后会自动生成跳转链接拼接在事件说明中 */ + path?: string + /** 重复周期结束时间的 unix 时间戳,不填表示一直重复 */ + repeatEndTime?: number + /** 重复周期,默认 month 每月重复 + * + * 可选值: + * - 'day': 每天重复; + * - 'week': 每周重复; + * - 'month': 每月重复。该模式日期不能大于 28 日; + * - 'year': 每年重复; */ + repeatInterval?: 'day' | 'week' | 'month' | 'year' + /** 需要基础库: `3.7.6` + * + * 跳转小程序路径签名,必须要和 path 一起使用,用 session_key 对 path 签名得到的结果,即 `hmac_sha256(session_key, path)`。详见 [用户数据的签名验证和加解密](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html) */ + signature?: string + /** 接口调用成功的回调函数 */ + success?: AddPhoneRepeatCalendarSuccessCallback + } + interface AddServiceOption { + /** 描述service的Object */ + service: BLEPeripheralService + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: AddServiceCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: AddServiceFailCallback + /** 接口调用成功的回调函数 */ + success?: AddServiceSuccessCallback + } + interface AddVideoToFavoritesOption { + /** 要收藏的视频地址,必须为本地路径或临时路径 */ + videoPath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: AddVideoToFavoritesCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: AddVideoToFavoritesFailCallback + /** 接口调用成功的回调函数 */ + success?: AddVideoToFavoritesSuccessCallback + /** 缩略图路径,若留空则使用视频首帧 */ + thumbPath?: string + } + interface AddVisualLayerOption { + /** 可视化图层id([创建图层指引](https://lbs.qq.com/dev/console/layers/layerEdit)) */ + layerId: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: AddVisualLayerCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: AddVisualLayerFailCallback + /** 刷新周期,单位秒 */ + interval?: number + /** 图层透明度 */ + opacity?: number + /** 接口调用成功的回调函数 */ + success?: AddVisualLayerSuccessCallback + /** 图层绘制顺序 */ + zIndex?: number + } /** 广播自定义参数 */ interface AdvertiseReqObj { - /** 当前Service是否可连接 */ + /** 需要基础库: `2.20.1` + * + * 以 beacon 设备形式广播的参数。 */ + beacon?: BeaconInfoObj + /** 当前设备是否可连接 */ connectable?: boolean - /** 广播中deviceName字段,默认为当前设备名 */ + /** 广播中 deviceName 字段,默认为空 */ deviceName?: string - /** 广播的制造商信息, 默认为空 */ + /** 广播的制造商信息。仅安卓支持,iOS 因系统限制无法定制。 */ manufacturerData?: ManufacturerData[] - /** 要广播的serviceUuid列表 */ + /** 要广播的服务 UUID 列表。使用 16/32 位 UUID 时请参考注意事项。 */ serviceUuids?: string[] } + /** 订单金额信息。 */ + interface Amount { + /** 订单总需支付金额,也即是真正下单总金额,单位为分。示例值:1300 */ + order_amount: number + /** 货币类型。示例值:CNY + * + * 可选值: + * - 'CNY': 人民币; */ + currency?: 'CNY' + /** 订单总计优惠金额,单位为分。示例值:500 */ + discount?: number + /** 订单运费,单位为分。示例值:200 */ + freight?: number + /** 订单其他费用总金额,单位为分。示例值:600 */ + other_fee?: number + /** 订单所有商品的原价总和,单位为分。示例值:1000 */ + product_amount?: number + } + /** 交易金额对象 */ + interface AmountOption { + /** 交易币种,货币的符号采用ISO4217,3位大写字符进行表达。 */ + currency: string + /** 交易金额,采用ISO4217标准中的最小货币单位进行表达,该值为整数,没有小数点。 */ + total: number + } + /** animationData */ + interface AnimationExportResult { + actions: IAnyObject[] + } /** 动画效果 */ interface AnimationOption { /** 动画变化时间,单位 ms */ @@ -174,15 +390,58 @@ declare namespace WechatMiniprogram { * - 'easeInOut': 动画以低速开始和结束; */ timingFunc?: 'linear' | 'easeIn' | 'easeOut' | 'easeInOut' } - interface AppendFileFailCallbackResult { - /** 错误信息 + interface AppAuthorizeSetting { + /** 允许微信使用相册的开关(仅 iOS 有效) */ + albumAuthorized: 'authorized' | 'denied' | 'not determined' + /** 允许微信使用蓝牙的开关(安卓基础库 3.5.0 以上有效) */ + bluetoothAuthorized: 'authorized' | 'denied' | 'not determined' + /** 允许微信使用摄像头的开关 */ + cameraAuthorized: 'authorized' | 'denied' | 'not determined' + /** 允许微信使用定位的开关 */ + locationAuthorized: 'authorized' | 'denied' | 'not determined' + /** 定位准确度。true 表示模糊定位,false 表示精确定位(仅 iOS 有效) */ + locationReducedAccuracy: boolean + /** 允许微信使用麦克风的开关 */ + microphoneAuthorized: 'authorized' | 'denied' | 'not determined' + /** 允许微信通知带有提醒的开关(仅 iOS 有效) */ + notificationAlertAuthorized: 'authorized' | 'denied' | 'not determined' + /** 允许微信通知的开关 */ + notificationAuthorized: 'authorized' | 'denied' | 'not determined' + /** 允许微信通知带有标记的开关(仅 iOS 有效) */ + notificationBadgeAuthorized: 'authorized' | 'denied' | 'not determined' + /** 允许微信通知带有声音的开关(仅 iOS 有效) */ + notificationSoundAuthorized: 'authorized' | 'denied' | 'not determined' + /** 允许微信读写日历的开关 */ + phoneCalendarAuthorized: 'authorized' | 'denied' | 'not determined' + } + interface AppBaseInfo { + /** 客户端基础库版本 */ + SDKVersion: string + /** 是否已打开调试。可通过右上角菜单或 [wx.setEnableDebug](https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/wx.setEnableDebug.html) 打开调试。 */ + enableDebug: boolean + /** 微信字体大小缩放比例 */ + fontSizeScaleFactor: number + /** 需要基础库: `2.23.4` + * + * 微信字体大小,单位px */ + fontSizeSetting: number + /** 当前小程序运行的宿主环境 */ + host: AppBaseInfoHost + /** 微信设置的语言 */ + language: string + /** 微信版本号 */ + version: string + /** 系统当前主题,取值为`light`或`dark`,全局配置`"darkmode":true`时才能获取,否则为 undefined (不支持小游戏) * * 可选值: - * - 'fail no such file or directory, open ${filePath}': 指定的 filePath 文件不存在; - * - 'fail illegal operation on a directory, open "${filePath}"': 指定的 filePath 是一个已经存在的目录; - * - 'fail permission denied, open ${dirPath}': 指定的 filePath 路径没有写权限; - * - 'fail sdcard not mounted': 指定的 filePath 是一个已经存在的目录; */ - errMsg: string + * - 'dark': 深色主题; + * - 'light': 浅色主题; */ + theme?: 'dark' | 'light' + } + /** 当前小程序运行的宿主环境 */ + interface AppBaseInfoHost { + /** 宿主 app(第三方App) 对应的 appId (当小程序运行在第三方App环境时才返回) */ + appId: string } interface AppendFileOption { /** 要追加的文本或二进制数据 */ @@ -222,31 +481,258 @@ declare namespace WechatMiniprogram { /** 接口调用成功的回调函数 */ success?: AppendFileSuccessCallback } + interface ApplyBlusherStickMakeupOption { + /** 上色程度 0-1 */ + alpha: number + blendMode: string + /** 左腮红资源路径 */ + path: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ApplyBlusherStickMakeupCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ApplyBlusherStickMakeupFailCallback + /** 接口调用成功的回调函数 */ + success?: ApplyBlusherStickMakeupSuccessCallback + } + interface ApplyEyeBrowMakeupOption { + /** 上色程度 0-1 */ + alpha: number + blendMode: string + path: string + shrinkRate: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ApplyEyeBrowMakeupCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ApplyEyeBrowMakeupFailCallback + /** 接口调用成功的回调函数 */ + success?: ApplyEyeBrowMakeupSuccessCallback + } + interface ApplyEyeShadowMakeupOption { + /** 上色程度 0-1 */ + alpha: number + blendMode: string + /** 眼影资源路径 */ + path: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ApplyEyeShadowMakeupCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ApplyEyeShadowMakeupFailCallback + /** 细致效果图片资源路径 */ + shimmerPosition?: string + /** 细致效果图片资源 md5 */ + shimmerPositionMD5?: string + /** 接口调用成功的回调函数 */ + success?: ApplyEyeShadowMakeupSuccessCallback + } + interface ApplyFaceContourMakeupOption { + alpha: number + /** 高光资源路径 */ + path: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ApplyFaceContourMakeupCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ApplyFaceContourMakeupFailCallback + /** 接口调用成功的回调函数 */ + success?: ApplyFaceContourMakeupSuccessCallback + } + interface ApplyFilterOption { + /** 滤镜效果透明度,范围是 0-1 */ + alpha: number + /** 滤镜资源路径 */ + path: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ApplyFilterCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ApplyFilterFailCallback + /** 滤镜资源 md5 */ + md5?: string + /** 接口调用成功的回调函数 */ + success?: ApplyFilterSuccessCallback + } + interface ApplyLipStickMakeupOption { + /** 上色程度 0-1 */ + alpha: number + blendMode: string + faceModel: string + path: string + shimmerPath: string + shimmerType: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ApplyLipStickMakeupCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ApplyLipStickMakeupFailCallback + /** 接口调用成功的回调函数 */ + success?: ApplyLipStickMakeupSuccessCallback + } + interface ApplyStickerOption { + /** 贴纸类型 */ + stickers: Sticker[] + /** 贴纸类型 */ + type: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ApplyStickerCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ApplyStickerFailCallback + /** 接口调用成功的回调函数 */ + success?: ApplyStickerSuccessCallback + templateTransSet?: IAnyObject + } + interface Asset { + src: string + /** 可选值: + * - 'font': 字体; + * - 'image': 图片; */ + type: 'font' | 'image' + } + /** 需要基础库: `2.19.0` + * + * AudioBuffer接口表示存在内存里的一段短小的音频资源,利用[WebAudioContext.decodeAudioData](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.decodeAudioData.html)方法从一个音频文件构建,或者利用 [WebAudioContext.createBuffer](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createBuffer.html)从原始数据构建。把音频放入AudioBuffer后,可以传入到一个 AudioBufferSourceNode进行播放。 */ + interface AudioBuffer { + /** 返回存储在缓存区的PCM数据的时长(单位为秒) */ + duration: number + /** 返回存储在缓存区的PCM数据的采样帧率 */ + length: number + /** 储存在缓存区的PCM数据的通道数 */ + numberOfChannels: number + /** 存储在缓存区的PCM数据的采样率(单位为sample/s) */ + sampleRate: number + /** [AudioBuffer.copyFromChannel()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioBuffer.copyFromChannel.html) + * + * 在插件中使用:不支持 + * + * 从AudioBuffer的指定频道复制到数组终端。 */ + copyFromChannel(): void + /** [AudioBuffer.copyToChannel(Float32Array source, number channelNumber, number startInChannel)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioBuffer.copyToChannel.html) + * + * 在插件中使用:不支持 + * + * 从指定数组复制样本到audioBuffer的特定通道 + * + * **示例代码** + * + * 示例代码参考AudioBuffer.copyFromChannel */ + copyToChannel( + /** 需要复制的源数组 */ + source: Float32Array, + /** 需要复制到的目的通道号 */ + channelNumber: number, + /** 复制偏移数据量 */ + startInChannel: number + ): void + /** [Float32Array AudioBuffer.getChannelData(number channel)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioBuffer.getChannelData.html) + * + * 在插件中使用:不支持 + * + * 返回一个 Float32Array,包含了带有频道的PCM数据,由频道参数定义(有0代表第一个频道) */ + getChannelData( + /** 要获取特定通道数据的索引 */ + channel: number + ): Float32Array + } + /** 空间音频监听器,代表在一个音频场景内唯一的位置和方向信息。 */ + interface AudioListener { + /** 表示监听器的前向系统在同一笛卡尔坐标系中的水平位置,作为位置(位置x,位置和位置和位置)值。 */ + forwardX: number + /** 表示听众的前向方向在同一笛卡尔坐标系中作为位置(位置x,位置和位置和位置)值的垂直位置。 */ + forwardY: number + /** 表示与position (positionX、positionY和positionZ)值在同一笛卡尔坐标系下的听者前进方向的纵向(前后)位置。 */ + forwardZ: number + /** 右手笛卡尔坐标系中X轴的位置。 */ + positionX: number + /** 右手笛卡尔坐标系中Y轴的位置。 */ + positionY: number + /** 右手笛卡尔坐标系中Z轴的位置。 */ + positionZ: number + /** 设置监听器的方向 */ + setOrientation: (...args: any[]) => any + /** 设置监听器的位置 */ + setPosition: (...args: any[]) => any + /** 表示在与position (positionX、positionY和positionZ)值相同的笛卡尔坐标系中侦听器向前方向的水平位置。 */ + upX: number + /** 表示在与position (positionX、positionY和positionZ)值相同的笛卡尔坐标系中侦听器向上方向的水平位置。 */ + upY: number + /** 表示在与position (positionX、positionY和positionZ)值相同的笛卡尔坐标系中侦听器向后方向的水平位置。 */ + upZ: number + } + /** 需要基础库: `2.19.0` + * + * AudioParam 接口代表音频相关的参数,通常是 AudioNode(例如 GainNode.gain)的参数 */ + interface AudioParam { + /** 代表被具体的 AudioNode 创建的 AudioParam 的属性的初始值(只读) */ + defaultValue: number + /** 代表参数有效范围的最大可能值(只读) */ + maxValue: number + /** 代表参数有效范围的最小可能值(只读) */ + minValue: number + /** 当前属性的值(比如音量值或播放倍速值)(可读可写) */ + value: number + } + interface AuthPrivateMessageOption { + /** shareTicket。可以从 wx.getEnterOptionsSync 中获取。详情 [shareTicket](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html) */ + shareTicket: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: AuthPrivateMessageCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: AuthPrivateMessageFailCallback + /** 接口调用成功的回调函数 */ + success?: AuthPrivateMessageSuccessCallback + } + interface AuthPrivateMessageSuccessCallbackResult { + /** 经过加密的activityId,解密后可得到原始的activityId。若解密后得到的activityId可以与开发者后台的活动id对应上则验证通过,否则表明valid字段不可靠(被篡改) 详细见[加密数据解密算法](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html) */ + encryptedData: string + /** 错误信息 */ + errMsg: string + /** 加密算法的初始向量,详细见[加密数据解密算法](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html) */ + iv: string + /** 验证是否通过 */ + valid: boolean + } /** 用户授权设置信息,详情参考[权限](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html) */ interface AuthSetting { - /** 是否授权通讯地址,对应接口 [wx.chooseAddress](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/address/wx.chooseAddress.html) */ + /** 是否授权系统日历,对应接口 [wx.addPhoneRepeatCalendar](https://developers.weixin.qq.com/miniprogram/dev/api/device/calendar/wx.addPhoneRepeatCalendar.html)、[wx.addPhoneCalendar](https://developers.weixin.qq.com/miniprogram/dev/api/device/calendar/wx.addPhoneCalendar.html) */ + 'scope.addPhoneCalendar'?: boolean + /** 是否添加通讯录联系人,对应接口 [wx.addPhoneContact](https://developers.weixin.qq.com/miniprogram/dev/api/device/contact/wx.addPhoneContact.html) */ + 'scope.addPhoneContact'?: boolean + /** 是否授权通讯地址,已取消此项授权,会默认返回true */ 'scope.address'?: boolean + /** 是否授权蓝牙,对应接口 [wx.openBluetoothAdapter](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.openBluetoothAdapter.html)、[wx.createBLEPeripheralServer](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/wx.createBLEPeripheralServer.html) */ + 'scope.bluetooth'?: boolean /** 是否授权摄像头,对应[[camera](https://developers.weixin.qq.com/miniprogram/dev/component/camera.html)](https://developers.weixin.qq.com/miniprogram/dev/component/camera.html) 组件 */ 'scope.camera'?: boolean - /** 是否授权获取发票,对应接口 [wx.chooseInvoice](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/invoice/wx.chooseInvoice.html) */ + /** 是否授权获取发票,已取消此项授权,会默认返回true */ 'scope.invoice'?: boolean - /** 是否授权发票抬头,对应接口 [wx.chooseInvoiceTitle](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/invoice/wx.chooseInvoiceTitle.html) */ + /** 是否授权发票抬头,已取消此项授权,会默认返回true */ 'scope.invoiceTitle'?: boolean - /** 是否授权录音功能,对应接口 [wx.startRecord](https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/wx.startRecord.html) */ + /** 是否授权录音功能,对应接口 [wx.getRecorderManager](https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/wx.getRecorderManager.html) */ 'scope.record'?: boolean - /** 是否授权订阅消息推送功能,对应接口 [wx.requestSubscribeMessage](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/subscribe-message/wx.requestSubscribeMessage.html) */ - 'scope.subscribeMessage'?: boolean + /** 是否授权模糊地理位置,对应接口 [wx.getFuzzyLocation](https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.getFuzzyLocation.html) */ + 'scope.userFuzzyLocation'?: boolean /** 是否授权用户信息,对应接口 [wx.getUserInfo](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserInfo.html) */ 'scope.userInfo'?: boolean - /** 是否授权地理位置,对应接口 [wx.getLocation](https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.getLocation.html), [wx.chooseLocation](https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.chooseLocation.html) */ + /** 是否授权精确地理位置,对应接口 [wx.getLocation](https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.getLocation.html), [wx.chooseLocation](https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.chooseLocation.html) */ 'scope.userLocation'?: boolean /** 是否授权微信运动步数,对应接口 [wx.getWeRunData](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/werun/wx.getWeRunData.html) */ 'scope.werun'?: boolean /** 是否授权保存到相册 [wx.saveImageToPhotosAlbum](https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.saveImageToPhotosAlbum.html), [wx.saveVideoToPhotosAlbum](https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.saveVideoToPhotosAlbum.html) */ 'scope.writePhotosAlbum'?: boolean } + interface AuthorizeForMiniProgramOption { + /** 需要获取权限的 scope,详见 [scope 列表](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html#scope-列表) + * + * 可选值: + * - 'scope.record': ; + * - 'scope.writePhotosAlbum': ; + * - 'scope.camera': ; */ + scope: 'scope.record' | 'scope.writePhotosAlbum' | 'scope.camera' + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: AuthorizeForMiniProgramCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: AuthorizeForMiniProgramFailCallback + /** 接口调用成功的回调函数 */ + success?: AuthorizeForMiniProgramSuccessCallback + } interface AuthorizeOption { - /** 需要获取权限的 scope,详见 [scope 列表]((authorize#scope-列表)) */ + /** 需要获取权限的 scope,详见 [scope 列表](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html#scope-列表) */ scope: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: AuthorizeCompleteCallback @@ -255,36 +741,54 @@ declare namespace WechatMiniprogram { /** 接口调用成功的回调函数 */ success?: AuthorizeSuccessCallback } - /** 设备特征值列表 */ + /** 设备特征列表 */ interface BLECharacteristic { - /** 该特征值支持的操作类型 */ + /** 该特征支持的操作类型 */ properties: BLECharacteristicProperties - /** 蓝牙设备特征值的 uuid */ + /** 蓝牙设备特征的 UUID */ uuid: string } - /** 该特征值支持的操作类型 */ + /** 该特征支持的操作类型 */ interface BLECharacteristicProperties { - /** 该特征值是否支持 indicate 操作 */ + /** 该特征是否支持 indicate 操作 */ indicate: boolean - /** 该特征值是否支持 notify 操作 */ + /** 该特征是否支持 notify 操作 */ notify: boolean - /** 该特征值是否支持 read 操作 */ + /** 该特征是否支持 read 操作 */ read: boolean - /** 该特征值是否支持 write 操作 */ + /** 该特征是否支持 write 操作 */ write: boolean + /** 该特征是否支持有回复写操作 */ + writeDefault: boolean + /** 该特征是否支持无回复写操作 */ + writeNoResponse: boolean + } + interface BLEPeripheralServerCloseOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SocketTaskCloseCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SocketTaskCloseFailCallback + /** 接口调用成功的回调函数 */ + success?: SocketTaskCloseSuccessCallback + } + /** 描述service的Object */ + interface BLEPeripheralService { + /** characteristics列表 */ + characteristics: Characteristic[] + /** 蓝牙服务的 UUID */ + uuid: string } /** 设备服务列表 */ interface BLEService { /** 该服务是否为主服务 */ isPrimary: boolean - /** 蓝牙设备服务的 uuid */ + /** 蓝牙设备服务的 UUID */ uuid: string } /** BackgroundAudioManager 实例,可通过 [wx.getBackgroundAudioManager](https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.getBackgroundAudioManager.html) 获取。 * * **示例代码** * -* * ```js const backgroundAudioManager = wx.getBackgroundAudioManager() @@ -293,9 +797,13 @@ backgroundAudioManager.epname = '此时此刻' backgroundAudioManager.singer = '许巍' backgroundAudioManager.coverImgUrl = 'http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000' // 设置了 src 之后会自动播放 -backgroundAudioManager.src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46' +backgroundAudioManager.src = 'https://wx_test.mp3' ``` */ interface BackgroundAudioManager { + /** 需要基础库: `3.4.8` + * + * 音频类型。可设置 "audio" 和 "music" 两种值,默认为 "audio"。不同音频类型对应的播放器样式不一样(实验特性,目前仅iOS和Android端支持) */ + audioType: string /** 音频已缓冲的时间,仅保证当前播放时间点到此时间点内容已缓冲。(只读) */ buffered: number /** 封面图 URL,用于做原生音频播放器背景图。原生音频播放器中的分享功能,分享出去的卡片配图及背景也将使用该图。 */ @@ -308,10 +816,22 @@ backgroundAudioManager.src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb epname: string /** 当前是否暂停或停止。(只读) */ paused: boolean - /** 音频协议。默认值为 'http',设置 'hls' 可以支持播放 HLS 协议的直播音频。 + /** 需要基础库: `2.11.0` + * + * 播放速度。范围 0.5-2.0,默认为 1。(Android 需要 6 及以上版本) */ + playbackRate: number + /** 需要基础库: `1.9.94` * - * 最低基础库: `1.9.94` */ + * 音频协议。默认值为 'http',设置 'hls' 可以支持播放 HLS 协议的直播音频。 */ protocol: string + /** 需要基础库: `3.4.8` + * + * 关联页面路径。设置后,当点击播放器上的小程序跳转链接时,将跳转到这个关联页面路径(实验特性,目前仅Android端支持) */ + referrerPath: string + /** 需要基础库: `2.13.0` + * + * `origin`: 发送完整的referrer; `no-referrer`: 不发送。格式固定为 `https://servicewechat.com/{appid}/{version}/page-frame.html`,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本; */ + referrerPolicy: string /** 歌手名,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值。 */ singer: string /** 音频的数据源([2.2.3](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 开始支持云文件ID)。默认为空字符串,**当设置了新的 src 时,会自动开始播放**,目前支持的格式有 m4a, aac, mp3, wav。 */ @@ -322,23 +842,247 @@ backgroundAudioManager.src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb title: string /** 页面链接,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值。 */ webUrl: string + /** [BackgroundAudioManager.onCanplay(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/BackgroundAudioManager.onCanplay.html) + * + * 在插件中使用:支持 + * + * 监听背景音频进入可播放状态事件。 但不保证后面可以流畅播放 */ + onCanplay( + /** 背景音频进入可播放状态事件的监听函数 */ + listener: OnCanplayCallback + ): void + /** [BackgroundAudioManager.onEnded(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/BackgroundAudioManager.onEnded.html) + * + * 在插件中使用:支持 + * + * 监听背景音频自然播放结束事件 */ + onEnded( + /** 背景音频自然播放结束事件的监听函数 */ + listener: OnEndedCallback + ): void + /** [BackgroundAudioManager.onError(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/BackgroundAudioManager.onError.html) + * + * 在插件中使用:支持 + * + * 监听背景音频播放错误事件 */ + onError( + /** 背景音频播放错误事件的监听函数 */ + listener: BackgroundAudioManagerOnErrorCallback + ): void + /** [BackgroundAudioManager.onNext(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/BackgroundAudioManager.onNext.html) + * + * 在插件中使用:支持 + * + * 监听用户在系统音乐播放面板点击下一曲事件 */ + onNext( + /** 用户在系统音乐播放面板点击下一曲事件的监听函数 */ + listener: OnNextCallback + ): void + /** [BackgroundAudioManager.onPause(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/BackgroundAudioManager.onPause.html) + * + * 在插件中使用:支持 + * + * 监听背景音频暂停事件 */ + onPause( + /** 背景音频暂停事件的监听函数 */ + listener: OnPauseCallback + ): void + /** [BackgroundAudioManager.onPlay(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/BackgroundAudioManager.onPlay.html) + * + * 在插件中使用:支持 + * + * 监听背景音频播放事件 */ + onPlay( + /** 背景音频播放事件的监听函数 */ + listener: OnPlayCallback + ): void + /** [BackgroundAudioManager.onPrev(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/BackgroundAudioManager.onPrev.html) + * + * 在插件中使用:支持 + * + * 监听用户在系统音乐播放面板点击上一曲事件 */ + onPrev( + /** 用户在系统音乐播放面板点击上一曲事件的监听函数 */ + listener: OnPrevCallback + ): void + /** [BackgroundAudioManager.onSeeked(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/BackgroundAudioManager.onSeeked.html) + * + * 在插件中使用:支持 + * + * 监听背景音频完成跳转操作事件 */ + onSeeked( + /** 背景音频完成跳转操作事件的监听函数 */ + listener: OnSeekedCallback + ): void + /** [BackgroundAudioManager.onSeeking(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/BackgroundAudioManager.onSeeking.html) + * + * 在插件中使用:支持 + * + * 监听背景音频开始跳转操作事件 */ + onSeeking( + /** 背景音频开始跳转操作事件的监听函数 */ + listener: OnSeekingCallback + ): void + /** [BackgroundAudioManager.onStop(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/BackgroundAudioManager.onStop.html) + * + * 在插件中使用:支持 + * + * 监听背景音频停止事件 */ + onStop( + /** 背景音频停止事件的监听函数 */ + listener: InnerAudioContextOnStopCallback + ): void + /** [BackgroundAudioManager.onTimeUpdate(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/BackgroundAudioManager.onTimeUpdate.html) + * + * 在插件中使用:支持 + * + * 监听背景音频播放进度更新事件,只有小程序在前台时会回调。 */ + onTimeUpdate( + /** 背景音频播放进度更新事件的监听函数 */ + listener: OnTimeUpdateCallback + ): void + /** [BackgroundAudioManager.onWaiting(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/BackgroundAudioManager.onWaiting.html) + * + * 在插件中使用:支持 + * + * 监听音频加载中事件。当音频因为数据不足,需要停下来加载时会触发 */ + onWaiting( + /** 音频加载中事件的监听函数 */ + listener: OnWaitingCallback + ): void + /** [BackgroundAudioManager.pause()](https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/BackgroundAudioManager.pause.html) + * + * 在插件中使用:支持 + * + * 暂停音乐 */ + pause(): void + /** [BackgroundAudioManager.play()](https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/BackgroundAudioManager.play.html) + * + * 在插件中使用:支持 + * + * 播放音乐 */ + play(): void + /** [BackgroundAudioManager.seek(number currentTime)](https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/BackgroundAudioManager.seek.html) + * + * 在插件中使用:支持 + * + * 跳转到指定位置 */ + seek( + /** 跳转的位置,单位 s。精确到小数点后 3 位,即支持 ms 级别精确度 */ + currentTime: number + ): void + /** [BackgroundAudioManager.stop()](https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/BackgroundAudioManager.stop.html) + * + * 在插件中使用:支持 + * + * 停止音乐 */ + stop(): void } - /** 搜索到的设备列表 */ - interface BluetoothDeviceInfo { - /** 用于区分设备的 id */ - deviceId: string - /** 蓝牙设备名称,某些设备可能没有 */ - name: string - } - interface BlurOption { + interface BatchGetStorageOption { + /** 本地缓存中指定的 keyList */ + keyList: string[] /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: BlurCompleteCallback + complete?: BatchGetStorageCompleteCallback /** 接口调用失败的回调函数 */ - fail?: BlurFailCallback + fail?: BatchGetStorageFailCallback /** 接口调用成功的回调函数 */ - success?: BlurSuccessCallback + success?: BatchGetStorageSuccessCallback } - interface BoundingClientRectCallbackResult { + interface BatchSetStorageOption { + /** [{ key, value }] */ + kvList: any[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: BatchSetStorageCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: BatchSetStorageFailCallback + /** 接口调用成功的回调函数 */ + success?: BatchSetStorageSuccessCallback + } + /** Beacon 设备 */ + interface BeaconInfo { + /** Beacon 设备的距离,单位 m。iOS 上,proximity 为 0 时,accuracy 为 -1。 */ + accuracy: number + /** Beacon 设备的主 ID */ + major: number + /** Beacon 设备的次 ID */ + minor: number + /** 表示设备距离的枚举值(仅iOS) + * + * 可选值: + * - 0: 信号太弱不足以计算距离,或非 iOS 设备; + * - 1: 十分近; + * - 2: 比较近; + * - 3: 远; */ + proximity: 0 | 1 | 2 | 3 + /** 表示设备的信号强度,单位 dBm */ + rssi: number + /** Beacon 设备广播的 UUID */ + uuid: string + } + /** 需要基础库: `2.20.1` + * + * 以 beacon 设备形式广播的参数。 */ + interface BeaconInfoObj { + /** Beacon 设备的主 ID */ + major: number + /** Beacon 设备的次 ID */ + minor: number + /** Beacon 设备广播的 UUID */ + uuid: string + /** 用于判断距离设备 1 米时 RSSI 大小的参考值 */ + measuredPower?: number + } + interface BindWifiOption { + /** 当前 wifi 网络的 BSSID ,可通过 wx.getConnectedWifi 获取 */ + BSSID: string + } + interface BlueToothDevice { + /** 当前蓝牙设备的信号强度,单位 dBm */ + RSSI: number + /** 当前蓝牙设备的广播数据段中的 ManufacturerData 数据段。 */ + advertisData: ArrayBuffer + /** 当前蓝牙设备的广播数据段中的 ServiceUUIDs 数据段 */ + advertisServiceUUIDs: string[] + /** 当前蓝牙设备是否可连接( Android 8.0 以下不支持返回该值 ) */ + connectable: boolean + /** 蓝牙设备 id */ + deviceId: string + /** 当前蓝牙设备的广播数据段中的 LocalName 数据段 */ + localName: string + /** 蓝牙设备名称,某些设备可能没有 */ + name: string + /** 当前蓝牙设备的广播数据段中的 ServiceData 数据段 */ + serviceData: IAnyObject + } + /** 搜索到的设备列表 */ + interface BluetoothDeviceInfo { + /** 用于区分设备的 id */ + deviceId: string + /** 蓝牙设备名称,某些设备可能没有 */ + name: string + } + interface BlurOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: BlurCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: BlurFailCallback + /** 接口调用成功的回调函数 */ + success?: BlurSuccessCallback + } + /** 需要基础库: `2.28.0` + * + * 人体检测配置。用法详情[指南文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/body.html)。 */ + interface BodyTrack { + /** 需要基础库: `2.28.0` + * + * 人体检测模式 + * + * 可选值: + * - 1: 通过摄像头实时检测; + * - 2: 静态图片检测; */ + mode: 1 | 2 + } + interface BoundingClientRectCallbackResult { /** 节点的下边界坐标 */ bottom: number /** 节点的 dataset */ @@ -371,12307 +1115,28539 @@ backgroundAudioManager.src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb /** 宽度 */ width: number } - /** 新搜索到的设备列表 */ - interface CallbackResultBlueToothDevice { - /** 当前蓝牙设备的信号强度 */ - RSSI: number - /** 当前蓝牙设备的广播数据段中的 ManufacturerData 数据段。 */ - advertisData: ArrayBuffer - /** 当前蓝牙设备的广播数据段中的 ServiceUUIDs 数据段 */ - advertisServiceUUIDs: string[] - /** 用于区分设备的 id */ - deviceId: string - /** 当前蓝牙设备的广播数据段中的 LocalName 数据段 */ - localName: string - /** 蓝牙设备名称,某些设备可能没有 */ - name: string - /** 当前蓝牙设备的广播数据段中的 ServiceData 数据段 */ - serviceData: IAnyObject + /** 音频源节点,通过 [WebAudioContext.createBufferSource](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createBufferSource.html)方法获得。 +* +* **示例代码** +* +* ```js +const source = audioCtx.createBufferSource() +source.buffer = AudioBuffer +source.connect(audioCtx.destination) +source.start() +``` */ + interface BufferSourceNode { + /** [AudioBuffer](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioBuffer.html) + * + * 是一个 AudioBuffer, 它定义了要播放的音频,当设置它的值为 0 时,它会定义一个静默的单通道。(可读可写) */ + buffer: AudioBuffer + /** 定义音频是否循环播放(可读可写) */ + loop?: boolean + /** 定义音频循环播放时,结束播放的位置。单位是秒,默认值是0(可读可写) */ + loopEnd?: number + /** 定义音频循环播放时,开始播放的位置。单位是秒,默认值是0(可读可写) */ + loopStart?: number + /** 定义音频播放结束事件回调函数(可读可写) */ + onended?: (...args: any[]) => any + /** [AudioParam](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioParam.html) + * + * 定义音频的播放倍速,数值越大速度越快,默认速度1.0,有效范围为 0 < playbackRate <= 2.0(可读可写) */ + playbackRate?: AudioParam + /** [BufferSourceNode.connect(AudioNode|[AudioParam](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioParam.html) destination)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/BufferSourceNode.connect.html) + * + * 在插件中使用:不支持 + * + * 连接到一个指定目标。这个指定的目标可能是另一个 AudioNode(从而将音频数据引导到下一个指定节点)或一个AudioParam, 以便上一个节点的输出数据随着时间流逝能自动地对下一个参数值进行改变 */ + connect( + /** 要建立连接的目标节点 */ + destination: AudioNode | AudioParam + ): void + /** [BufferSourceNode.disconnect()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/BufferSourceNode.disconnect.html) + * + * 在插件中使用:不支持 + * + * 与已连接的目标节点断开连接 */ + disconnect(): void + /** [BufferSourceNode.start(number when, number offset, number duration)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/BufferSourceNode.start.html) + * + * 在插件中使用:不支持 + * + * 音频源开始播放 */ + start( + /** 延迟播放的时间,单位是秒。与 AudioContext 使用相同的时间坐标系统。如果 when 小于 AudioContext.currentTime, 或者是 0,声音立即被播放。 默认值是 0 */ + when?: number, + /** 音频开始播放的位置,单位是秒。默认值是 0 */ + offset?: number, + /** 音频播放的持续时间,单位是秒。如果这个参数没有被指定,声音播放到自然结束或者使用stop() 方法结束。使用这个参数的功能与调用 start(when, offset) 和调用 stop(when+duration)效果完全相同 */ + duration?: number + ): void + /** [BufferSourceNode.stop(number when)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/BufferSourceNode.stop.html) + * + * 在插件中使用:不支持 + * + * 停止播放 */ + stop( + /** 延迟停止播放的时间,单位是秒。与 AudioContext 使用相同的时间坐标系统。省略此参数、指定值 0 或传递负值会使声音立即停止播放。 */ + when?: number + ): void + } + /** 需要基础库: `2.24.0` + * + * 缓存管理器。全局只有唯一实例,一旦被创建出来即表示接入缓存管理器。其有以下几个能力: + * + * 1. 在网络通畅时,符合一定规则的用户网络请求(目前只包括普通 wx.request 请求)会被缓存。 + * 2. 在网络通畅时,某些 wx api 调用会被缓存。 + * 3. 进入弱网/离线状态时,会提供事件给用户,用户可以决定是否使用缓存返回。 + * 4. 提供进入和退出弱网/离线状态的事件。 + * + * > 1. 缓存管理器中涉及的网络请求如无特指,均指普通的 wx.request 异步请求,参数和返回值中均不考虑涉及 ArrayBuffer 或 TypedArray 的情形。 + * > 2. 缓存管理器中的缓存不会占用 storage 空间,但是有大小限制,请勿在非必要的请求上使用缓存。 */ + interface CacheManager { + /** 全局缓存有效时间 */ + maxAge: number + /** 当前缓存模式 + * + * 可选值: + * - 'weakNetwork': 默认值,弱网/离线使用缓存返回; + * - 'always': 总是使用缓存返回; + * - 'none': 不开启,后续可手动开启/停止使用缓存返回; */ + mode: 'weakNetwork' | 'always' | 'none' + /** 全局 origin */ + origin: string + /** 当前缓存管理器状态 + * + * 可选值: + * - 0: 不使用缓存返回; + * - 1: 使用缓存返回; + * - 2: 未知; */ + state: 0 | 1 | 2 + /** [Array.<string> CacheManager.addRules(Array.<(string|RegExp|Record.<string, any>)> rules)](https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.addRules.html) + * + * 需要基础库: `2.24.0` + * + * 在插件中使用:不支持 + * + * 批量添加规则,规则写法可参考 [CacheManager.addRule](https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.addRule.html)。 */ + addRules( + /** 规则列表 */ + rules: Array> + ): string[] + /** [CacheManager.clearCaches()](https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.clearCaches.html) + * + * 需要基础库: `2.24.0` + * + * 在插件中使用:不支持 + * + * 清空所有缓存。 */ + clearCaches(): void + /** [CacheManager.clearRules()](https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.clearRules.html) + * + * 需要基础库: `2.24.0` + * + * 在插件中使用:不支持 + * + * 清空所有规则,同时会删除对应规则下所有缓存。 */ + clearRules(): void + /** [CacheManager.deleteCache(string id)](https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.deleteCache.html) + * + * 需要基础库: `2.24.0` + * + * 在插件中使用:不支持 + * + * 删除缓存。 */ + deleteCache( + /** 缓存 id */ + id: string + ): void + /** [CacheManager.deleteCaches(Array.<string> ids)](https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.deleteCaches.html) + * + * 需要基础库: `2.24.0` + * + * 在插件中使用:不支持 + * + * 批量删除缓存。 */ + deleteCaches( + /** 缓存 id 列表 */ + ids: string[] + ): void + /** [CacheManager.deleteRule(string id)](https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.deleteRule.html) + * + * 需要基础库: `2.24.0` + * + * 在插件中使用:不支持 + * + * 删除规则,同时会删除对应规则下所有缓存。 */ + deleteRule( + /** 规则 id */ + id: string + ): void + /** [CacheManager.deleteRules(Array.<string> ids)](https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.deleteRules.html) + * + * 需要基础库: `2.24.0` + * + * 在插件中使用:不支持 + * + * 批量删除规则,同时会删除对应规则下所有缓存。 */ + deleteRules( + /** 规则 id 列表 */ + ids: string[] + ): void + /** [CacheManager.off(string eventName, function handler)](https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.off.html) + * + * 需要基础库: `2.24.0` + * + * 在插件中使用:不支持 + * + * 取消事件监听。 */ + off( + /** 事件名 */ + eventName: string, + /** 事件句柄 */ + handler: (...args: any[]) => any + ): void + /** [CacheManager.on(string eventName, function handler)](https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.on.html) +* +* 需要基础库: `2.24.0` +* +* 在插件中使用:不支持 +* +* 监听事件。 +* +* **** +* +* 这里 request 事件会提供 request 事件对象,用于做后续的处理;在 request 事件中需要返回一个 promise,用来生成 wx.request 请求的返回内容。 +* 这次 request 所返回的请求结果默认不会写入缓存中。如需写入缓存,可以传入参数 `request({ needUpdateCache: true })` +* +* #### 示例代码 +* +* ```js +async function handler(evt) { + // evt.url - 请求 url + // evt.data - 请求参数 + // evt.method - 请求方法 + // evt.request - 原始 request 方法,返回一个 promise + + // if (evt.url === '/xxx') { + // // 如果有些请求仍然希望走到网络,则可以如下处理 + // const res = await evt.request() + // // res 即为网络请求返回 + // } + + return new Promsie((resolve, reject) => { + // do sth + if (data) { + // 这里 resolve 的 data 就会作为 wx.request 的 success 回调结果返回 + resolve(data) + } else { + // 这里 reject 的错误信息就会作为 wx.request 的 fail 回调结果返回 + reject('no data') + } + }) +} +cacheManager.on('request', handler) +``` */ + on( + /** 事件名 + * + * 参数 eventName 可选值: + * - 'request': 发生 wx.request 请求,只在缓存管理器开启阶段会触发; + * - 'enterWeakNetwork': 进入弱网/离线状态; + * - 'exitWeakNetwork': 离开弱网/离线状态; */ + eventName: 'request' | 'enterWeakNetwork' | 'exitWeakNetwork', + /** 事件句柄 */ + handler: (...args: any[]) => any + ): void + /** [CacheManager.start()](https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.start.html) + * + * 需要基础库: `2.24.0` + * + * 在插件中使用:不支持 + * + * 开启缓存,仅在 mode 为 none 时生效,调用后缓存管理器的 state 会置为 1。 */ + start(): void + /** [CacheManager.stop()](https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.stop.html) + * + * 需要基础库: `2.24.0` + * + * 在插件中使用:不支持 + * + * 关闭缓存,仅在 mode 为 none 时生效,调用后缓存管理器的 state 会置为 0。 */ + stop(): void + /** [Object CacheManager.match(Object evt)](https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.match.html) +* +* 需要基础库: `2.24.0` +* +* 在插件中使用:不支持 +* +* 匹配命中的缓存规则,一般需要和 request 事件搭配使用。 +* +* **示例代码** +* +* ```js +function handler(evt) { + const cache = cacheManager.match(evt) + // 若有重复监听,则取第一个 handler 返回的 promise + return new Promise((resolve, reject) => { + if (cache.data) { + resolve(cache.data) + } else { + reject('no cache') + } + }) +} +cacheManager.on('request', handler) +``` */ + match( + /** request 事件对象 */ + evt: IAnyObject + ): MatchCache + /** [string CacheManager.addRule(string|RegExp|Record.<string, any> rule)](https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.addRule.html) +* +* 需要基础库: `2.24.0` +* +* 在插件中使用:不支持 +* +* 添加规则。 +* +* **规则说明** +* +* 支持的规则写法有字符串、正则和对象三种: +* +* ### 字符串写法 +* +* 1. `addRule('/abc')`:纯 uri 串。 +* 2. `addRule('GET /abc'):带方法的 uri 串,除了匹配 uri 外,还会匹配请求方法。如例子中必须是 GET 方法请求才会被匹配。 +* 3. `addRule('/abc/:id'):带可变部分的 uri 串,id 可以是任意符合标准的字符串,表示这一段可以动态变化。比如 `/abc/123` 和 `/abc/321` 都会被匹配,而 `/abc/123/xxx` 因为多了一段,就不会被匹配。 +* 4. `addRule('/abc?aa'):带 query 参数的 uri 串,包含 aa 参数,值可以为任意值。比如 `/abc?aa=haha` 会被匹配,但是 `/abc` 就不会被匹配,因为缺少规则中声明的 aa 参数;不过如果请求是 `/abc?aa=haha&bb=123`,虽然多带了 bb 参数,但是因为包含了 aa 参数,所以也可以被匹配。 +* 5. `addRule('/abc?dd=haha'):带 query 参数的 uri 串,包含 dd 参数且值为 haha。比如 `/abc?dd=haha` 和 `/abc?dd=haha&bb=123` 会被匹配,而 `/abc?dd=123` 就不会被匹配,因为规则要求了 dd 参数的值。 +* +* > 以上写法中的 uri 串如果只有 path 部分,则会取全局 origin 进行补全。比如全局 origin 是 `https://weixin.qq.com`,而规则是 `/abc`,则会补全为 `https://weixin.qq.com/abc`。因此在前面例子中 `addRule('/abc')` 和 `addRule('https://weixin.qq.com/abc')` 的写法效果一致。所以一般情况下如果需要匹配的请求 origin 和全局 origin 一致,则规则中可忽略不写 orign。 +* +* ### 正则写法 +* +* 1. `addRule(/\/(abc|cba)$/ig)`:直接正则匹配请求的 uri,同时会比对请求 origin 和全局 origin 是否一致。 +* 2. `addRule(/^https:\/\/weixin.qq.com\/(abc|cba)$/ig)`:带有 orign 部分的正则表达式,则只匹配 uri,不再比对 origin。 +* +* ### 对象写法 +* +* 使用规则对象,可以更为详细的描述规则内容。(一般使用规则对象,是为了匹配请求参数) +* +* #### 规则对象: +* +* | 属性名 | 类型 | 默认值 | 备注 | +* |---|---|---|---| +* | id | string | | 规则 id,如果不填则会由基础库生成 | +* | method | string | | 请求方法,可选值 GET/POST/PATCH/PUT/DELETE,如果为空则表示前面提到的所有方法都能被匹配到 | +* | url | any | 必填 | uri 匹配规则,可参考规则字符串写法和正则写法 | +* | maxAge | number | 7 * 24 * 60 * 60 * 1000 | 缓存有效时间,单位为 ms,不填则默认取缓存管理器全局的缓存有效时间 | +* | dataSchema | Array\ | | 匹配请求参数 | +* +* 其中,dataSchema 用来匹配对象类型的请求参数(比如 wx.request 的 data),默认可以不填,即不做参数匹配。 +* +* dataSchema 的类型是一个 DataRule 对象数组,一个 DataRule 对象描述一个参数,比如一个 wx.request 请求的 data 是 `{a: 123, b: 'haha', c: true}`,你想要用一条规则来匹配其中的 a 和 b 参数,如果 a 是数字且 b 是字符串就能命中该规则,那么就需要在 dataSchema 中补充两个 DataRule 对象,即 `[{name: 'a', schema: {type: 'number'}}, {name: 'b', schema: {type: 'string'}}]`。 +* +* #### DataRule 对象: +* +* | 属性名 | 类型 | 默认值 | 备注 | +* |---|---|---|---| +* | name | string | | 需要匹配的参数名 | +* | schema | DataSchema/Array\ | 需要匹配的参数模式,支持数组,表示该参数值有多种模式 | +* +* name 表示要匹配的参数名,schema 为 DataSchema 对象,用来描述该参数的类型和值。 +* +* 一个 DataRule 对象也可以匹配可能拥有多种类型的参数,所以 schema 也支持为 DataSchema 对象数组。比如上述例子中,希望匹配的 a 参数必须是数值或者字符串,那么可以这么写:`{name: 'a', schema: [{type: 'number'}, {type: 'string'}]}`。 +* +* #### DataSchema 对象: +* +* | 属性名 | 类型 | 默认值 | 备注 | +* |---|---|---|---| +* | type | string | | 需要匹配的 data 对象的参数类型,string、number、boolean、null、object、any(表示任意类型),同时支持数组模式(数组模式则在类型后面加 [],如 string[] 表示字符串数组) | +* | value | string/regexp/function/Array\ | | 需要匹配的 data 对象的参数值,当 type 为基本类型时,可以用 string/regexp 来匹配固定的值,也可以通过 function 来确定值是否匹配,如果传入的 type 是 object,那么表示需要嵌套匹配值是否正确,可以传入 Array | +* +* type 参数表示要匹配的参数类型,value 表示要匹配的参数值。其中 value 支持多种写法,不同写法有如下匹配方式: +* +* 1. 字符串写法:直接判值的字符串形式是否和给定字符串一样,比如 value 值为 `123`,就要求参数值必须为 123 才能与之匹配。 +* 2. 正则写法:直接判值的字符串形式是否能被正则匹配,比如 value 值为 `/\d+/ig`,就要求参数值必须为数字,如果参数值为 `abc` 则不会被匹配。 +* 3. 函数写法:在匹配时会调用用户传入的函数,交由用户判断是否匹配。 +* 4. DataRule 数组写法:当参数类型为对象时,那么字符串写法和正则写法就无法使用,需要传入 DataRule 数组来进行匹配,即通过嵌套 DataRule 数组的方式来匹配嵌套的对象。 +* +* ### 示例代码 +* +* ```js +const ruleId = cacheManager.addRule({ + id: 'haha-rule', + method: 'GET', + url: '/haha', + maxAge: 123455, + dataSchema: [ + // data 字段的匹配,默认为空,表示不匹配 + // 类型可以是:string、number、boolean、null、object、any(表示任意类型均可),以及这些类型的数组表示方式 + {name: 'aaa', schema: {type: 'string'}}, // 类型为 string + {name: 'bbb', schema: [{type: 'number'}, {type: 'string'}]}, // 类型为 number, string + {name: 'ccc', schema: {type: 'string', value: 'abc'}}, // 值为 abc + {name: 'ddd', schema: {type: 'string', value: /(abc|cba)/ig}}, // 值符合该正则匹配,如果该值不是字符串类型,则会被尝试转成字符串后再进行比较 + {name: 'ddd', schema: {type: 'string', value: val => val === '123'}}, // 传入函数来校验值 + {name: 'eee', schema: {type: 'object', value: [{ // 类型为对象,则通过嵌套的方式来逐层校验 + name: 'aaa', schema: {type: 'string'}, + // ... + // 嵌套 dataSchema,同上面的方式一样来匹配嵌套的对象 + }]}}, + {name: 'fff', schema: {type: 'string[]'}}, // 类型为 string 数组 + {name: 'ggg', schema: {type: 'any'}}, // 类型为任意类型 + {name: 'hhh', schema: {type: 'any[]'}}, // 类型为任意类型的数组 + }], +}) +``` +* +* ### 补充说明 +* +* 用户可以添加多条规则,每条规则都会去解析网络请求,然后判断是否命中规则。假设有多条规则命中,则取第一条命中的规则。 +* +* ### 缓存覆盖 +* +* 不同的网络请求也可能命中同一条规则,所以每条规则可能对应多个缓存。每条规则会有一个规则 id,每个缓存会有一个缓存 id,一个规则 id 可能对应多个缓存 id,而缓存管理器的缓存存储是基于缓存 id 标识的,如果两个不同的请求生成了同样的缓存 id,那么后发生的请求结果缓存会覆盖前者。因此使用时需要思考缓存的覆盖情况,目前缓存 id 生成方式如下: +* +* 1. 规则使用字符串写法:那么按 method + url + 规则中声明的 query 参数来生成缓存 id。 +* +* > 需要注意的是这里不使用真实请求中的 query 参数来生成缓存 id,而是使用规则中匹配到的 query 来生成缓存 id。比如规则是 `/abc?aa=123`,请求是 GET 方法的 `/abc?aa=123&bb=123`,那么就会基于 `GET /abc?aa=123` 来生成缓存 id。而规则里没有声明 `bb=123`,所以 bb 参数不会被纳入缓存 id 的生成基准。 +* +* 2. 规则使用正则写法:那么只按 method + url 生成缓存 id,不考虑 query 参数。 +* 3. 规则使用对象写法:如果规则对象中的 url 是字符串写法,那么按 method + url + 规则中声明的 query 参数 + 规则中 dataSchema 声明的请求参数来生成缓存 id;如果规则对象中的 url 是正则写法,那么按 method + url + 规则中 dataSchema 声明的请求参数来生成缓存 id。 +* +* > 生成缓存 id 时没有使用请求中完整的 query 参数或者请求参数来作为基准,是考虑到很多请求可能会带上 token 或时间戳等参数。因为此参数存在不确定性,会导致每次请求生成的缓存 id 都不同,进而导致缓存命中率下降,故采取规则中声明的 query 参数和 dataSchema 声明的请求参数来作为生成缓存 id 的基准。 */ + addRule( + /** 规则 */ + rule: string | RegExp | Record + ): string + } + interface CameraContextSetZoomOption { + /** 缩放级别,范围[1, maxZoom]。zoom 可取小数,精确到小数后一位。maxZoom 可在 bindinitdone 返回值中获取。 */ + zoom: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetZoomCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetZoomFailCallback + /** 接口调用成功的回调函数 */ + success?: CameraContextSetZoomSuccessCallback } interface CameraContextStartRecordOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: CameraContextStartRecordCompleteCallback + complete?: StartRecordCompleteCallback /** 接口调用失败的回调函数 */ - fail?: CameraContextStartRecordFailCallback + fail?: StartRecordFailCallback + /** 需要基础库: `2.22.0` + * + * 是否开启镜像 */ + selfieMirror?: boolean /** 接口调用成功的回调函数 */ success?: CameraContextStartRecordSuccessCallback - /** 超过30s或页面 `onHide` 时会结束录像 */ + /** 需要基础库: `2.22.0` + * + * 录制时长上限,单位为秒,最长不能超过 5 分钟 */ + timeout?: number + /** 超过录制时长上限时会结束录像并触发此回调,录像异常退出时也会触发此回调 */ timeoutCallback?: StartRecordTimeoutCallback } interface CameraContextStopRecordOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: CameraContextStopRecordCompleteCallback + complete?: StopRecordCompleteCallback /** 启动视频压缩,压缩效果同`chooseVideo` */ compressed?: boolean /** 接口调用失败的回调函数 */ - fail?: CameraContextStopRecordFailCallback + fail?: StopRecordFailCallback /** 接口调用成功的回调函数 */ success?: CameraContextStopRecordSuccessCallback } interface CameraFrameListenerStartOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: CameraFrameListenerStartCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: CameraFrameListenerStartFailCallback - /** 接口调用成功的回调函数 */ - success?: CameraFrameListenerStartSuccessCallback - } - interface CameraFrameListenerStopOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: CameraFrameListenerStopCompleteCallback + complete?: StartCompleteCallback /** 接口调用失败的回调函数 */ - fail?: CameraFrameListenerStopFailCallback + fail?: StartFailCallback /** 接口调用成功的回调函数 */ - success?: CameraFrameListenerStopSuccessCallback + success?: StartSuccessCallback + /** [Worker](https://developers.weixin.qq.com/miniprogram/dev/api/worker/Worker.html) + * + * 需要基础库: `2.25.1` + * + * 可选参数。如果需要在 iOS ExperimentalWorker 内监听摄像头帧数据,则需要传入对应 Worker 对象。详情 [Worker.getCameraFrameData](https://developers.weixin.qq.com/miniprogram/dev/api/worker/Worker.getCameraFrameData.html) */ + worker?: Worker } - /** Canvas 实例,可通过 [SelectorQuery](https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.html) 获取。 - * - * **示例代码** + /** 需要基础库: `2.7.0` * + * Canvas 实例,可通过 [SelectorQuery](https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.html) 获取。 * + * **示例代码** * * 2D Canvas 示例 * [在微信开发者工具中查看示例](https://developers.weixin.qq.com/s/SHfgCmmq7UcM) * * WebGL 示例 - * [在微信开发者工具中查看示例](https://developers.weixin.qq.com/s/qEGUOqmf7T8z) - * - * 最低基础库: `2.7.0` */ + * [在微信开发者工具中查看示例](https://developers.weixin.qq.com/s/qEGUOqmf7T8z) */ interface Canvas { /** 画布高度 */ height: number /** 画布宽度 */ width: number - } - /** canvas 组件的绘图上下文 */ - interface CanvasContext { - /** 填充颜色。用法同 [CanvasContext.setFillStyle()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setFillStyle.html)。 + /** [Canvas.cancelAnimationFrame(number requestID)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Canvas.cancelAnimationFrame.html) * - * 最低基础库: `1.9.90` */ - fillStyle: string | CanvasGradient - /** 当前字体样式的属性。符合 [CSS font 语法](https://developer.mozilla.org/zh-CN/docs/Web/CSS/font) 的 DOMString 字符串,至少需要提供字体大小和字体族名。默认值为 10px sans-serif。 + * 需要基础库: `2.7.0` * - * 最低基础库: `1.9.90` */ - font: string - /** 全局画笔透明度。范围 0-1,0 表示完全透明,1 表示完全不透明。 */ - globalAlpha: number - /** 在绘制新形状时应用的合成操作的类型。目前安卓版本只适用于 `fill` 填充块的合成,用于 `stroke` 线段的合成效果都是 `source-over`。 + * 在插件中使用:支持 * - * 目前支持的操作有 - * - 安卓:xor, source-over, source-atop, destination-out, lighter, overlay, darken, lighten, hard-light - * - iOS:xor, source-over, source-atop, destination-over, destination-out, lighter, multiply, overlay, darken, lighten, color-dodge, color-burn, hard-light, soft-light, difference, exclusion, saturation, luminosity + * 取消由 requestAnimationFrame 添加到计划中的动画帧请求。支持在 2D Canvas 和 WebGL Canvas 下使用, 但不支持混用 2D 和 WebGL 的方法。 */ + cancelAnimationFrame(requestID: number): void + /** [[ImageData](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/ImageData.html) Canvas.createImageData()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Canvas.createImageData.html) * - * 最低基础库: `1.9.90` */ - globalCompositeOperation: string - /** 线条的端点样式。用法同 [CanvasContext.setLineCap()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setLineCap.html)。 + * 需要基础库: `2.9.0` * - * 最低基础库: `1.9.90` */ - lineCap: string - /** 虚线偏移量,初始值为0 + * 在插件中使用:支持 * - * 最低基础库: `1.9.90` */ - lineDashOffset: number - /** 线条的交点样式。用法同 [CanvasContext.setLineJoin()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setLineJoin.html)。 + * 创建一个 ImageData 对象。仅支持在 2D Canvas 中使用。 */ + createImageData(): ImageData + /** [[Image](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Image.html) Canvas.createImage()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Canvas.createImage.html) * - * 可选值: - * - 'bevel': 斜角; - * - 'round': 圆角; - * - 'miter': 尖角; + * 需要基础库: `2.7.0` * - * 最低基础库: `1.9.90` */ - lineJoin: 'bevel' | 'round' | 'miter' - /** 线条的宽度。用法同 [CanvasContext.setLineWidth()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setLineWidth.html)。 + * 在插件中使用:支持 * - * 最低基础库: `1.9.90` */ - lineWidth: number - /** 最大斜接长度。用法同 [CanvasContext.setMiterLimit()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setMiterLimit.html)。 + * 创建一个图片对象。 支持在 2D Canvas 和 WebGL Canvas 下使用, 但不支持混用 2D 和 WebGL 的方法。 */ + createImage(): Image + /** [[Path2D](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Path2D.html) Canvas.createPath2D([Path2D](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Path2D.html) path)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Canvas.createPath2D.html) * - * 最低基础库: `1.9.90` */ - miterLimit: number - /** 阴影的模糊级别 + * 需要基础库: `2.11.0` * - * 最低基础库: `1.9.90` */ - shadowBlur: number - /** 阴影的颜色 + * 在插件中使用:支持 * - * 最低基础库: `1.9.90` */ - shadowColor: number - /** 阴影相对于形状在水平方向的偏移 + * 创建 Path2D 对象 */ + createPath2D( + /** [Path2D](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Path2D.html) */ + path: Path2D + ): Path2D + /** [[RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) Canvas.getContext(string contextType)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Canvas.getContext.html) * - * 最低基础库: `1.9.90` */ - shadowOffsetX: number - /** 阴影相对于形状在竖直方向的偏移 + * 需要基础库: `2.7.0` * - * 最低基础库: `1.9.90` */ - shadowOffsetY: number - /** 边框颜色。用法同 [CanvasContext.setStrokeStyle()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setStrokeStyle.html)。 + * 在插件中使用:支持 * - * 最低基础库: `1.9.90` */ - strokeStyle: string | CanvasGradient - } - interface CanvasGetImageDataOption { - /** 画布标识,传入 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 组件的 `canvas-id` 属性。 */ - canvasId: string - /** 将要被提取的图像数据矩形区域的高度 */ - height: number - /** 将要被提取的图像数据矩形区域的宽度 */ - width: number - /** 将要被提取的图像数据矩形区域的左上角横坐标 */ - x: number - /** 将要被提取的图像数据矩形区域的左上角纵坐标 */ - y: number - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: CanvasGetImageDataCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: CanvasGetImageDataFailCallback - /** 接口调用成功的回调函数 */ - success?: CanvasGetImageDataSuccessCallback - } - interface CanvasGetImageDataSuccessCallbackResult { - /** 图像像素点数据,一维数组,每四项表示一个像素点的 rgba */ - data: Uint8ClampedArray - /** 图像数据矩形的高度 */ - height: number - /** 图像数据矩形的宽度 */ - width: number - errMsg: string - } - interface CanvasPutImageDataOption { - /** 画布标识,传入 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 组件的 canvas-id 属性。 */ - canvasId: string - /** 图像像素点数据,一维数组,每四项表示一个像素点的 rgba */ - data: Uint8ClampedArray - /** 源图像数据矩形区域的高度 */ - height: number - /** 源图像数据矩形区域的宽度 */ - width: number - /** 源图像数据在目标画布中的位置偏移量(x 轴方向的偏移量) */ - x: number - /** 源图像数据在目标画布中的位置偏移量(y 轴方向的偏移量) */ - y: number - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: CanvasPutImageDataCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: CanvasPutImageDataFailCallback - /** 接口调用成功的回调函数 */ - success?: CanvasPutImageDataSuccessCallback - } - interface CanvasToTempFilePathOption { - /** 画布标识,传入 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 组件实例 (canvas type="2d" 时使用该属性)。 */ - canvas?: string - /** 画布标识,传入 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 组件的 canvas-id */ - canvasId?: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: CanvasToTempFilePathCompleteCallback - /** 输出的图片的高度 + * 该方法返回 Canvas 的绘图上下文 * - * 最低基础库: `1.2.0` */ - destHeight?: number - /** 输出的图片的宽度 + * **** * - * 最低基础库: `1.2.0` */ - destWidth?: number - /** 接口调用失败的回调函数 */ - fail?: CanvasToTempFilePathFailCallback - /** 目标文件的类型 + * 支持获取 2D 和 WebGL 绘图上下文 */ + getContext( + /** 上下文类型 + * + * 参数 contextType 可选值: + * - '2d': 2d 绘图上下文; */ + contextType: '2d' + ): CanvasRenderingContext.CanvasRenderingContext2D + /** [[RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) Canvas.getContext(string contextType)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Canvas.getContext.html) * - * 可选值: - * - 'jpg': jpg 图片; - * - 'png': png 图片; + * 需要基础库: `2.7.0` * - * 最低基础库: `1.7.0` */ - fileType?: 'jpg' | 'png' - /** 指定的画布区域的高度 + * 在插件中使用:支持 * - * 最低基础库: `1.2.0` */ - height?: number - /** 图片的质量,目前仅对 jpg 有效。取值范围为 (0, 1],不在范围内时当作 1.0 处理。 + * 该方法返回 Canvas 的绘图上下文 * - * 最低基础库: `1.7.0` */ - quality?: number - /** 接口调用成功的回调函数 */ - success?: CanvasToTempFilePathSuccessCallback - /** 指定的画布区域的宽度 + * **** * - * 最低基础库: `1.2.0` */ - width?: number - /** 指定的画布区域的左上角横坐标 + * 支持获取 2D 和 WebGL 绘图上下文 */ + getContext( + /** 上下文类型 + * + * 参数 contextType 可选值: + * - 'webgl': webgl 绘图上下文; */ + contextType: 'webgl' + ): CanvasRenderingContext.WebGLRenderingContext + /** [[RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) Canvas.getContext(string contextType)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Canvas.getContext.html) * - * 最低基础库: `1.2.0` */ - x?: number - /** 指定的画布区域的左上角纵坐标 + * 需要基础库: `2.7.0` * - * 最低基础库: `1.2.0` */ - y?: number - } - interface CanvasToTempFilePathSuccessCallbackResult { - /** 生成文件的临时路径 (本地路径) */ - tempFilePath: string - errMsg: string - } - /** characteristics列表 */ - interface Characteristic { - /** Characteristic 的 uuid */ - uuid: string - /** 描述符数据 */ - descriptors?: Descriptor - /** 特征值权限 */ - permission?: CharacteristicPermission - /** 特征值支持的操作 */ - properties?: CharacteristicProperties - /** 特征值对应的二进制值 */ - value?: ArrayBuffer - } - /** 特征值权限 */ - interface CharacteristicPermission { - /** 加密读请求 */ - readEncryptionRequired?: boolean - /** 可读 */ - readable?: boolean - /** 加密写请求 */ - writeEncryptionRequired?: boolean - /** 可写 */ - writeable?: boolean - } - /** 特征值支持的操作 */ - interface CharacteristicProperties { - /** 回包 */ - indicate?: boolean - /** 订阅 */ - notify?: boolean - /** 读 */ - read?: boolean - /** 写 */ - write?: boolean - } - interface CheckIsSoterEnrolledInDeviceOption { - /** 认证方式 + * 在插件中使用:支持 * - * 可选值: - * - 'fingerPrint': 指纹识别; - * - 'facial': 人脸识别; - * - 'speech': 声纹识别(暂未支持); */ - checkAuthMode: 'fingerPrint' | 'facial' | 'speech' - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: CheckIsSoterEnrolledInDeviceCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: CheckIsSoterEnrolledInDeviceFailCallback - /** 接口调用成功的回调函数 */ - success?: CheckIsSoterEnrolledInDeviceSuccessCallback - } - interface CheckIsSoterEnrolledInDeviceSuccessCallbackResult { - /** 错误信息 */ - errMsg: string - /** 是否已录入信息 */ - isEnrolled: boolean - } - interface CheckIsSupportSoterAuthenticationOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: CheckIsSupportSoterAuthenticationCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: CheckIsSupportSoterAuthenticationFailCallback - /** 接口调用成功的回调函数 */ - success?: CheckIsSupportSoterAuthenticationSuccessCallback - } - interface CheckIsSupportSoterAuthenticationSuccessCallbackResult { - /** 该设备支持的可被SOTER识别的生物识别方式 + * 该方法返回 Canvas 的绘图上下文 * - * 可选值: - * - 'fingerPrint': 指纹识别; - * - 'facial': 人脸识别; - * - 'speech': 声纹识别(暂未支持); */ - supportMode: Array<'fingerPrint' | 'facial' | 'speech'> - errMsg: string - } - interface CheckSessionOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: CheckSessionCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: CheckSessionFailCallback - /** 接口调用成功的回调函数 */ - success?: CheckSessionSuccessCallback - } - interface ChooseAddressOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ChooseAddressCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: ChooseAddressFailCallback - /** 接口调用成功的回调函数 */ - success?: ChooseAddressSuccessCallback - } - interface ChooseAddressSuccessCallbackResult { - /** 国标收货地址第二级地址 */ - cityName: string - /** 国标收货地址第三级地址 */ - countyName: string - /** 详细收货地址信息 */ - detailInfo: string - /** 错误信息 */ - errMsg: string - /** 收货地址国家码 */ - nationalCode: string - /** 邮编 */ - postalCode: string - /** 国标收货地址第一级地址 */ - provinceName: string - /** 收货人手机号码 */ - telNumber: string - /** 收货人姓名 */ - userName: string - } - /** 返回选择的文件的本地临时文件对象数组 */ - interface ChooseFile { - /** 选择的文件名称 */ - name: string - /** 本地临时文件路径 (本地路径) */ - path: string - /** 本地临时文件大小,单位 B */ - size: number - /** 选择的文件的会话发送时间,Unix时间戳,工具暂不支持此属性 */ - time: number - /** 选择的文件类型 + * **** * - * 可选值: - * - 'video': 选择了视频文件; - * - 'image': 选择了图片文件; - * - 'file': 选择了除图片和视频的文件; */ - type: 'video' | 'image' | 'file' + * 支持获取 2D 和 WebGL 绘图上下文 */ + getContext( + /** 上下文类型 + * + * 参数 contextType 可选值: + * - 'webgl2': webgl2 绘图上下文; */ + contextType: 'webgl2' + ): CanvasRenderingContext.WebGL2RenderingContext + /** [number Canvas.requestAnimationFrame(function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Canvas.requestAnimationFrame.html) + * + * 需要基础库: `2.7.0` + * + * 在插件中使用:支持 + * + * 在下次进行重绘时执行。 支持在 2D Canvas 和 WebGL Canvas 下使用, 但不支持混用 2D 和 WebGL 的方法。 */ + requestAnimationFrame( + /** 执行的 callback */ + callback: (...args: any[]) => any + ): number + /** [string Canvas.toDataURL(string type, number encoderOptions)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Canvas.toDataURL.html) + * + * 需要基础库: `2.11.0` + * + * 在插件中使用:支持 + * + * 返回一个包含图片展示的 data URI 。可以使用 type 参数其类型,默认为 PNG 格式。 */ + toDataURL( + /** 图片格式,默认为 image/png */ + type: string, + /** 在指定图片格式为 image/jpeg 或 image/webp的情况下,可以从 0 到 1 的区间内选择图片的质量。如果超出取值范围,将会使用默认值 0.92。其他参数会被忽略。 */ + encoderOptions: number + ): string } - interface ChooseImageOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ChooseImageCompleteCallback - /** 最多可以选择的图片张数 */ - count?: number - /** 接口调用失败的回调函数 */ - fail?: ChooseImageFailCallback - /** 所选的图片的尺寸 + /** @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 + * + * canvas 组件的绘图上下文。CanvasContext 是旧版的接口, 新版 Canvas 2D 接口与 Web 一致。 */ + interface CanvasContext { + /** 需要基础库: `1.9.90` * - * 可选值: - * - 'original': 原图; - * - 'compressed': 压缩图; */ - sizeType?: Array<'original' | 'compressed'> - /** 选择图片的来源 + * 填充颜色。用法同 [CanvasContext.setFillStyle()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setFillStyle.html)。 */ + fillStyle: string | CanvasGradient + /** 需要基础库: `1.9.90` + * + * 当前字体样式的属性。符合 [CSS font 语法](https://developer.mozilla.org/zh-CN/docs/Web/CSS/font) 的 DOMString 字符串,至少需要提供字体大小和字体族名。默认值为 10px sans-serif。 */ + font: string + /** 全局画笔透明度。范围 0-1,0 表示完全透明,1 表示完全不透明。 */ + globalAlpha: number + /** 需要基础库: `1.9.90` + * + * 在绘制新形状时应用的合成操作的类型。目前安卓版本只适用于 `fill` 填充块的合成,用于 `stroke` 线段的合成效果都是 `source-over`。 + * + * 目前支持的操作有 + * - 安卓:xor, source-over, source-atop, destination-out, lighter, overlay, darken, lighten, hard-light + * - iOS:xor, source-over, source-atop, destination-over, destination-out, lighter, multiply, overlay, darken, lighten, color-dodge, color-burn, hard-light, soft-light, difference, exclusion, saturation, luminosity */ + globalCompositeOperation: string + /** 需要基础库: `1.9.90` + * + * 线条的端点样式。用法同 [CanvasContext.setLineCap()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setLineCap.html)。 */ + lineCap: string + /** 需要基础库: `1.9.90` + * + * 虚线偏移量,初始值为0 */ + lineDashOffset: number + /** 需要基础库: `1.9.90` + * + * 线条的交点样式。用法同 [CanvasContext.setLineJoin()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setLineJoin.html)。 * * 可选值: - * - 'album': 从相册选图; - * - 'camera': 使用相机; */ - sourceType?: Array<'album' | 'camera'> - /** 接口调用成功的回调函数 */ - success?: ChooseImageSuccessCallback - } - interface ChooseImageSuccessCallbackResult { - /** 图片的本地临时文件路径列表 (本地路径) */ - tempFilePaths: string[] - /** 图片的本地临时文件列表 + * - 'bevel': 斜角; + * - 'round': 圆角; + * - 'miter': 尖角; */ + lineJoin: 'bevel' | 'round' | 'miter' + /** 需要基础库: `1.9.90` * - * 最低基础库: `1.2.0` */ - tempFiles: ImageFile[] - errMsg: string - } - interface ChooseInvoiceOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ChooseInvoiceCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: ChooseInvoiceFailCallback - /** 接口调用成功的回调函数 */ - success?: ChooseInvoiceSuccessCallback - } - interface ChooseInvoiceSuccessCallbackResult { - /** 用户选中的发票信息,格式为一个 JSON 字符串,包含三个字段: card_id:所选发票卡券的 cardId,encrypt_code:所选发票卡券的加密 code,报销方可以通过 cardId 和 encryptCode 获得报销发票的信息,app_id: 发票方的 appId。 */ - invoiceInfo: string - errMsg: string - } - interface ChooseInvoiceTitleOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ChooseInvoiceTitleCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: ChooseInvoiceTitleFailCallback - /** 接口调用成功的回调函数 */ - success?: ChooseInvoiceTitleSuccessCallback - } - interface ChooseInvoiceTitleSuccessCallbackResult { - /** 银行账号 */ - bankAccount: string - /** 银行名称 */ - bankName: string - /** 单位地址 */ - companyAddress: string - /** 错误信息 */ - errMsg: string - /** 抬头税号 */ - taxNumber: string - /** 手机号码 */ - telephone: string - /** 抬头名称 */ - title: string - /** 抬头类型 + * 线条的宽度。用法同 [CanvasContext.setLineWidth()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setLineWidth.html)。 */ + lineWidth: number + /** 需要基础库: `1.9.90` * - * 可选值: - * - 0: 单位; - * - 1: 个人; */ - type: 0 | 1 - } - interface ChooseLocationOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ChooseLocationCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: ChooseLocationFailCallback - /** 目标地纬度 + * 最大斜接长度。用法同 [CanvasContext.setMiterLimit()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setMiterLimit.html)。 */ + miterLimit: number + /** 需要基础库: `1.9.90` * - * 最低基础库: `2.9.0` */ - latitude?: number - /** 目标地经度 + * 阴影的模糊级别 */ + shadowBlur: number + /** 需要基础库: `1.9.90` * - * 最低基础库: `2.9.0` */ - longitude?: number - /** 接口调用成功的回调函数 */ - success?: ChooseLocationSuccessCallback - } - interface ChooseLocationSuccessCallbackResult { - /** 详细地址 */ - address: string - /** 纬度,浮点数,范围为-90~90,负数表示南纬。使用 gcj02 国测局坐标系 */ - latitude: string - /** 经度,浮点数,范围为-180~180,负数表示西经。使用 gcj02 国测局坐标系 */ - longitude: string - /** 位置名称 */ - name: string - errMsg: string - } - interface ChooseMediaOption { - /** 仅在 sourceType 为 camera 时生效,使用前置或后置摄像头 + * 阴影的颜色 */ + shadowColor: number + /** 需要基础库: `1.9.90` * - * 可选值: - * - 'back': 使用后置摄像头; - * - 'front': 使用前置摄像头; */ - camera?: 'back' | 'front' - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ChooseMediaCompleteCallback - /** 最多可以选择的文件个数 */ - count?: number - /** 接口调用失败的回调函数 */ - fail?: ChooseMediaFailCallback - /** 拍摄视频最长拍摄时间,单位秒。时间范围为 3s 至 30s 之间 */ - maxDuration?: number - /** 仅对 mediaType 为 image 时有效,是否压缩所选文件 */ - sizeType?: string[] - /** 图片和视频选择的来源 + * 阴影相对于形状在水平方向的偏移 */ + shadowOffsetX: number + /** 需要基础库: `1.9.90` * - * 可选值: - * - 'album': 从相册选择; - * - 'camera': 使用相机拍摄; */ - sourceType?: Array<'album' | 'camera'> - /** 接口调用成功的回调函数 */ - success?: ChooseMediaSuccessCallback - } - interface ChooseMediaSuccessCallbackResult { - /** 本地临时文件列表 */ - tempFiles: MediaFile[] - /** 文件类型,有效值有 image 、video */ - type: string - errMsg: string - } - interface ChooseMessageFileOption { - /** 最多可以选择的文件个数,可以 0~100 */ - count: number - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ChooseMessageFileCompleteCallback - /** 根据文件拓展名过滤,仅 type==file 时有效。每一项都不能是空字符串。默认不过滤。 + * 阴影相对于形状在竖直方向的偏移 */ + shadowOffsetY: number + /** 需要基础库: `1.9.90` * - * 最低基础库: `2.6.0` */ - extension?: string[] - /** 接口调用失败的回调函数 */ - fail?: ChooseMessageFileFailCallback - /** 接口调用成功的回调函数 */ - success?: ChooseMessageFileSuccessCallback - /** 所选的文件的类型 + * 边框颜色。用法同 [CanvasContext.setStrokeStyle()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setStrokeStyle.html)。 */ + strokeStyle: string | CanvasGradient + /** [CanvasContext.arc(number x, number y, number r, number sAngle, number eAngle, boolean counterclockwise)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.arc.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 创建一条弧线。 +* +* - 创建一个圆可以指定起始弧度为 0,终止弧度为 2 * Math.PI。 +* - 用 `stroke` 或者 `fill` 方法来在 `canvas` 中画弧线。 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +// Draw coordinates +ctx.arc(100, 75, 50, 0, 2 * Math.PI) +ctx.setFillStyle('#EEEEEE') +ctx.fill() + +ctx.beginPath() +ctx.moveTo(40, 75) +ctx.lineTo(160, 75) +ctx.moveTo(100, 15) +ctx.lineTo(100, 135) +ctx.setStrokeStyle('#AAAAAA') +ctx.stroke() + +ctx.setFontSize(12) +ctx.setFillStyle('black') +ctx.fillText('0', 165, 78) +ctx.fillText('0.5*PI', 83, 145) +ctx.fillText('1*PI', 15, 78) +ctx.fillText('1.5*PI', 83, 10) + +// Draw points +ctx.beginPath() +ctx.arc(100, 75, 2, 0, 2 * Math.PI) +ctx.setFillStyle('lightgreen') +ctx.fill() + +ctx.beginPath() +ctx.arc(100, 25, 2, 0, 2 * Math.PI) +ctx.setFillStyle('blue') +ctx.fill() + +ctx.beginPath() +ctx.arc(150, 75, 2, 0, 2 * Math.PI) +ctx.setFillStyle('red') +ctx.fill() + +// Draw arc +ctx.beginPath() +ctx.arc(100, 75, 50, 0, 1.5 * Math.PI) +ctx.setStrokeStyle('#333333') +ctx.stroke() + +ctx.draw() +``` +* +* ![](@program/dev/image/canvas/arc.png) +* +* 针对 arc(100, 75, 50, 0, 1.5 * Math.PI)的三个关键坐标如下: +* +* - 绿色: 圆心 (100, 75) +* - 红色: 起始弧度 (0) +* - 蓝色: 终止弧度 (1.5 * Math.PI) */ + arc( + /** 圆心的 x 坐标 */ + x: number, + /** 圆心的 y 坐标 */ + y: number, + /** 圆的半径 */ + r: number, + /** 起始弧度,单位弧度(在3点钟方向) */ + sAngle: number, + /** 终止弧度 */ + eAngle: number, + /** 弧度的方向是否是逆时针 */ + counterclockwise?: boolean + ): void + /** [CanvasContext.arcTo(number x1, number y1, number x2, number y2, number radius)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.arcTo.html) * - * 可选值: - * - 'all': 从所有文件选择; - * - 'video': 只能选择视频文件; - * - 'image': 只能选择图片文件; - * - 'file': 可以选择除了图片和视频之外的其它的文件; */ - type?: 'all' | 'video' | 'image' | 'file' - } - interface ChooseMessageFileSuccessCallbackResult { - /** 返回选择的文件的本地临时文件对象数组 */ - tempFiles: ChooseFile[] - errMsg: string - } - interface ChooseVideoOption { - /** 默认拉起的是前置或者后置摄像头。部分 Android 手机下由于系统 ROM 不支持无法生效 + * 需要基础库: `1.9.90` * - * 可选值: - * - 'back': 默认拉起后置摄像头; - * - 'front': 默认拉起前置摄像头; */ - camera?: 'back' | 'front' - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ChooseVideoCompleteCallback - /** 是否压缩所选择的视频文件 + * 在插件中使用:支持 + * @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 * - * 最低基础库: `1.6.0` */ - compressed?: boolean - /** 接口调用失败的回调函数 */ - fail?: ChooseVideoFailCallback - /** 拍摄视频最长拍摄时间,单位秒 */ - maxDuration?: number - /** 视频选择的来源 + * @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** * - * 可选值: - * - 'album': 从相册选择视频; - * - 'camera': 使用相机拍摄视频; */ - sourceType?: Array<'album' | 'camera'> - /** 接口调用成功的回调函数 */ - success?: ChooseVideoSuccessCallback - } - interface ChooseVideoSuccessCallbackResult { - /** 选定视频的时间长度 */ - duration: number - /** 返回选定视频的高度 */ - height: number - /** 选定视频的数据量大小 */ - size: number - /** 选定视频的临时文件路径 (本地路径) */ - tempFilePath: string - /** 返回选定视频的宽度 */ - width: number - errMsg: string - } - interface ClearOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ClearCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: ClearFailCallback - /** 接口调用成功的回调函数 */ - success?: ClearSuccessCallback - } - interface ClearStorageOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ClearStorageCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: ClearStorageFailCallback - /** 接口调用成功的回调函数 */ - success?: ClearStorageSuccessCallback - } - interface CloseBLEConnectionOption { - /** 用于区分设备的 id */ - deviceId: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: CloseBLEConnectionCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: CloseBLEConnectionFailCallback - /** 接口调用成功的回调函数 */ - success?: CloseBLEConnectionSuccessCallback - } - interface CloseBluetoothAdapterOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: CloseBluetoothAdapterCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: CloseBluetoothAdapterFailCallback - /** 接口调用成功的回调函数 */ - success?: CloseBluetoothAdapterSuccessCallback - } - interface CloseOption { - /** 一个数字值表示关闭连接的状态号,表示连接被关闭的原因。 */ - code?: number + * 根据控制点和半径绘制圆弧路径。 */ + arcTo( + /** 第一个控制点的 x 轴坐标 */ + x1: number, + /** 第一个控制点的 y 轴坐标 */ + y1: number, + /** 第二个控制点的 x 轴坐标 */ + x2: number, + /** 第二个控制点的 y 轴坐标 */ + y2: number, + /** 圆弧的半径 */ + radius: number + ): void + /** [CanvasContext.beginPath()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.beginPath.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 开始创建一个路径。需要调用 `fill` 或者 `stroke` 才会使用路径进行填充或描边 +* +* - 在最开始的时候相当于调用了一次 `beginPath`。 +* - 同一个路径内的多次 `setFillStyle`、`setStrokeStyle`、`setLineWidth`等设置,以最后一次设置为准。 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') +// begin path +ctx.rect(10, 10, 100, 30) +ctx.setFillStyle('yellow') +ctx.fill() + +// begin another path +ctx.beginPath() +ctx.rect(10, 40, 100, 30) + +// only fill this rect, not in current path +ctx.setFillStyle('blue') +ctx.fillRect(10, 70, 100, 30) + +ctx.rect(10, 100, 100, 30) + +// it will fill current path +ctx.setFillStyle('red') +ctx.fill() +ctx.draw() +``` +* +* ![](@program/dev/image/canvas/fill-path.png) */ + beginPath(): void + /** [CanvasContext.bezierCurveTo(number cp1x, number cp1y, number cp2x, number cp2y, number x, number y)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.bezierCurveTo.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 创建三次方贝塞尔曲线路径。曲线的起始点为路径中前一个点。 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +// Draw points +ctx.beginPath() +ctx.arc(20, 20, 2, 0, 2 * Math.PI) +ctx.setFillStyle('red') +ctx.fill() + +ctx.beginPath() +ctx.arc(200, 20, 2, 0, 2 * Math.PI) +ctx.setFillStyle('lightgreen') +ctx.fill() + +ctx.beginPath() +ctx.arc(20, 100, 2, 0, 2 * Math.PI) +ctx.arc(200, 100, 2, 0, 2 * Math.PI) +ctx.setFillStyle('blue') +ctx.fill() + +ctx.setFillStyle('black') +ctx.setFontSize(12) + +// Draw guides +ctx.beginPath() +ctx.moveTo(20, 20) +ctx.lineTo(20, 100) +ctx.lineTo(150, 75) + +ctx.moveTo(200, 20) +ctx.lineTo(200, 100) +ctx.lineTo(70, 75) +ctx.setStrokeStyle('#AAAAAA') +ctx.stroke() + +// Draw quadratic curve +ctx.beginPath() +ctx.moveTo(20, 20) +ctx.bezierCurveTo(20, 100, 200, 100, 200, 20) +ctx.setStrokeStyle('black') +ctx.stroke() + +ctx.draw() +``` +* +* ![](@program/dev/image/canvas/bezier-curve.png) +* +* 针对 moveTo(20, 20) bezierCurveTo(20, 100, 200, 100, 200, 20) 的三个关键坐标如下: +* +* - 红色:起始点(20, 20) +* - 蓝色:两个控制点(20, 100) (200, 100) +* - 绿色:终止点(200, 20) */ + bezierCurveTo( + /** 第一个贝塞尔控制点的 x 坐标 */ + cp1x: number, + /** 第一个贝塞尔控制点的 y 坐标 */ + cp1y: number, + /** 第二个贝塞尔控制点的 x 坐标 */ + cp2x: number, + /** 第二个贝塞尔控制点的 y 坐标 */ + cp2y: number, + /** 结束点的 x 坐标 */ + x: number, + /** 结束点的 y 坐标 */ + y: number + ): void + /** [CanvasContext.clearRect(number x, number y, number width, number height)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.clearRect.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 清除画布上在该矩形区域内的内容 +* +* **示例代码** +* +* clearRect 并非画一个白色的矩形在地址区域,而是清空,为了有直观感受,对 canvas 加了一层背景色。 +* ```html +* +* ``` +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') +ctx.setFillStyle('red') +ctx.fillRect(0, 0, 150, 200) +ctx.setFillStyle('blue') +ctx.fillRect(150, 0, 150, 200) +ctx.clearRect(10, 10, 150, 75) +ctx.draw() +``` +* ![](@program/dev/image/canvas/clear-rect.png) */ + clearRect( + /** 矩形路径左上角的横坐标 */ + x: number, + /** 矩形路径左上角的纵坐标 */ + y: number, + /** 矩形路径的宽度 */ + width: number, + /** 矩形路径的高度 */ + height: number + ): void + /** [CanvasContext.clip()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.clip.html) +* +* 需要基础库: `1.6.0` +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 从原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内(不能访问画布上的其他区域)。可以在使用 `clip` 方法前通过使用 `save` 方法对当前画布区域进行保存,并在以后的任意时间通过`restore`方法对其进行恢复。 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +wx.downloadFile({ + url: 'http://is5.mzstatic.com/image/thumb/Purple128/v4/75/3b/90/753b907c-b7fb-5877-215a-759bd73691a4/source/50x50bb.jpg', + success: function(res) { + ctx.save() + ctx.beginPath() + ctx.arc(50, 50, 25, 0, 2*Math.PI) + ctx.clip() + ctx.drawImage(res.tempFilePath, 25, 25) + ctx.restore() + ctx.draw() + } +}) +``` +* ![](@program/dev/image/canvas/clip.png) */ + clip(): void + /** [CanvasContext.closePath()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.closePath.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 关闭一个路径。会连接起点和终点。如果关闭路径后没有调用 `fill` 或者 `stroke` 并开启了新的路径,那之前的路径将不会被渲染。 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') +ctx.moveTo(10, 10) +ctx.lineTo(100, 10) +ctx.lineTo(100, 100) +ctx.closePath() +ctx.stroke() +ctx.draw() +``` +* ![](@program/dev/image/canvas/close-line.png) +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') +// begin path +ctx.rect(10, 10, 100, 30) +ctx.closePath() + +// begin another path +ctx.beginPath() +ctx.rect(10, 40, 100, 30) + +// only fill this rect, not in current path +ctx.setFillStyle('blue') +ctx.fillRect(10, 70, 100, 30) + +ctx.rect(10, 100, 100, 30) + +// it will fill current path +ctx.setFillStyle('red') +ctx.fill() +ctx.draw() +``` +* +* ![](@program/dev/image/canvas/close-path.png) */ + closePath(): void + /** [CanvasContext.createPattern(string image, string repetition)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.createPattern.html) + * + * 需要基础库: `1.9.90` + * + * 在插件中使用:支持 + * @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 + * + * @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** + * + * 对指定的图像创建模式的方法,可在指定的方向上重复元图像 */ + createPattern( + /** 重复的图像源,支持代码包路径和本地临时路径 (本地路径) */ + image: string, + /** 如何重复图像 + * + * 参数 repetition 可选值: + * - 'repeat': 水平竖直方向都重复; + * - 'repeat-x': 水平方向重复; + * - 'repeat-y': 竖直方向重复; + * - 'no-repeat': 不重复; */ + repetition: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat' + ): void + /** [CanvasContext.draw(boolean reserve, function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.draw.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 将之前在绘图上下文中的描述(路径、变形、样式)画到 canvas 中。 +* +* **示例代码** +* +* 第二次 draw() reserve 为 true。所以保留了上一次的绘制结果,在上下文设置的 fillStyle 'red' 也变成了默认的 'black'。 +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +ctx.setFillStyle('red') +ctx.fillRect(10, 10, 150, 100) +ctx.draw() +ctx.fillRect(50, 50, 150, 100) +ctx.draw(true) +``` +* ![](@program/dev/image/canvas/reserve.png) +* +* **示例代码** +* +* 第二次 draw() reserve 为 false。所以没有保留了上一次的绘制结果和在上下文设置的 fillStyle 'red'。 +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +ctx.setFillStyle('red') +ctx.fillRect(10, 10, 150, 100) +ctx.draw() +ctx.fillRect(50, 50, 150, 100) +ctx.draw() +``` +* ![](@program/dev/image/canvas/un-reserve.png) */ + draw( + /** 本次绘制是否接着上一次绘制。即 reserve 参数为 false,则在本次调用绘制之前 native 层会先清空画布再继续绘制;若 reserve 参数为 true,则保留当前画布上的内容,本次调用 drawCanvas 绘制的内容覆盖在上面,默认 false。 */ + reserve?: boolean, + /** 绘制完成后执行的回调函数 */ + callback?: (...args: any[]) => any + ): void + /** [CanvasContext.drawImage(string imageResource, number sx, number sy, number sWidth, number sHeight, number dx, number dy, number dWidth, number dHeight)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.drawImage.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 绘制图像到画布 +* +* **示例代码** +* +* 有三个版本的写法: +* +* - drawImage(imageResource, dx, dy) +* - drawImage(imageResource, dx, dy, dWidth, dHeight) +* - drawImage(imageResource, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) 从 1.9.0 起支持 +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +wx.chooseImage({ + success: function(res){ + ctx.drawImage(res.tempFilePaths[0], 0, 0, 150, 100) + ctx.draw() + } +}) + +``` +* ![](@program/dev/image/canvas/draw-image.png) */ + drawImage( + /** 所要绘制的图片资源(网络图片要通过 getImageInfo / downloadFile 先下载) */ + imageResource: string, + /** imageResource的左上角在目标 canvas 上 x 轴的位置 */ + dx: number, + /** imageResource的左上角在目标 canvas 上 y 轴的位置 */ + dy: number + ): void + /** [CanvasContext.drawImage(string imageResource, number sx, number sy, number sWidth, number sHeight, number dx, number dy, number dWidth, number dHeight)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.drawImage.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 绘制图像到画布 +* +* **示例代码** +* +* 有三个版本的写法: +* +* - drawImage(imageResource, dx, dy) +* - drawImage(imageResource, dx, dy, dWidth, dHeight) +* - drawImage(imageResource, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) 从 1.9.0 起支持 +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +wx.chooseImage({ + success: function(res){ + ctx.drawImage(res.tempFilePaths[0], 0, 0, 150, 100) + ctx.draw() + } +}) + +``` +* ![](@program/dev/image/canvas/draw-image.png) */ + drawImage( + /** 所要绘制的图片资源(网络图片要通过 getImageInfo / downloadFile 先下载) */ + imageResource: string, + /** imageResource的左上角在目标 canvas 上 x 轴的位置 */ + dx: number, + /** imageResource的左上角在目标 canvas 上 y 轴的位置 */ + dy: number, + /** 在目标画布上绘制imageResource的宽度,允许对绘制的imageResource进行缩放 */ + dWidth: number, + /** 在目标画布上绘制imageResource的高度,允许对绘制的imageResource进行缩放 */ + dHeight: number + ): void + /** [CanvasContext.drawImage(string imageResource, number sx, number sy, number sWidth, number sHeight, number dx, number dy, number dWidth, number dHeight)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.drawImage.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 绘制图像到画布 +* +* **示例代码** +* +* 有三个版本的写法: +* +* - drawImage(imageResource, dx, dy) +* - drawImage(imageResource, dx, dy, dWidth, dHeight) +* - drawImage(imageResource, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) 从 1.9.0 起支持 +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +wx.chooseImage({ + success: function(res){ + ctx.drawImage(res.tempFilePaths[0], 0, 0, 150, 100) + ctx.draw() + } +}) + +``` +* ![](@program/dev/image/canvas/draw-image.png) */ + drawImage( + /** 所要绘制的图片资源(网络图片要通过 getImageInfo / downloadFile 先下载) */ + imageResource: string, + /** 需要绘制到画布中的,imageResource的矩形(裁剪)选择框的左上角 x 坐标 */ + sx: number, + /** 需要绘制到画布中的,imageResource的矩形(裁剪)选择框的左上角 y 坐标 */ + sy: number, + /** 需要绘制到画布中的,imageResource的矩形(裁剪)选择框的宽度 */ + sWidth: number, + /** 需要绘制到画布中的,imageResource的矩形(裁剪)选择框的高度 */ + sHeight: number, + /** imageResource的左上角在目标 canvas 上 x 轴的位置 */ + dx: number, + /** imageResource的左上角在目标 canvas 上 y 轴的位置 */ + dy: number, + /** 在目标画布上绘制imageResource的宽度,允许对绘制的imageResource进行缩放 */ + dWidth: number, + /** 在目标画布上绘制imageResource的高度,允许对绘制的imageResource进行缩放 */ + dHeight: number + ): void + /** [CanvasContext.fill()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.fill.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 对当前路径中的内容进行填充。默认的填充色为黑色。 +* +* **示例代码** +* +* 如果当前路径没有闭合,fill() 方法会将起点和终点进行连接,然后填充。 +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') +ctx.moveTo(10, 10) +ctx.lineTo(100, 10) +ctx.lineTo(100, 100) +ctx.fill() +ctx.draw() +``` +* +* fill() 填充的的路径是从 beginPath() 开始计算,但是不会将 fillRect() 包含进去。 +* +* ![](@program/dev/image/canvas/fill-line.png) +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') +// begin path +ctx.rect(10, 10, 100, 30) +ctx.setFillStyle('yellow') +ctx.fill() + +// begin another path +ctx.beginPath() +ctx.rect(10, 40, 100, 30) + +// only fill this rect, not in current path +ctx.setFillStyle('blue') +ctx.fillRect(10, 70, 100, 30) + +ctx.rect(10, 100, 100, 30) + +// it will fill current path +ctx.setFillStyle('red') +ctx.fill() +ctx.draw() +``` +* +* ![](@program/dev/image/canvas/fill-path.png) */ + fill(): void + /** [CanvasContext.fillRect(number x, number y, number width, number height)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.fillRect.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 填充一个矩形。用 [`setFillStyle`](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setFillStyle.html) 设置矩形的填充色,如果没设置默认是黑色。 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') +ctx.setFillStyle('red') +ctx.fillRect(10, 10, 150, 75) +ctx.draw() +``` +* ![](@program/dev/image/canvas/fill-rect.png) */ + fillRect( + /** 矩形路径左上角的横坐标 */ + x: number, + /** 矩形路径左上角的纵坐标 */ + y: number, + /** 矩形路径的宽度 */ + width: number, + /** 矩形路径的高度 */ + height: number + ): void + /** [CanvasContext.fillText(string text, number x, number y, number maxWidth)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.fillText.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 在画布上绘制被填充的文本 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +ctx.setFontSize(20) +ctx.fillText('Hello', 20, 20) +ctx.fillText('MINA', 100, 100) + +ctx.draw() +``` +* ![](@program/dev/image/canvas/text.png) */ + fillText( + /** 在画布上输出的文本 */ + text: string, + /** 绘制文本的左上角 x 坐标位置 */ + x: number, + /** 绘制文本的左上角 y 坐标位置 */ + y: number, + /** 需要绘制的最大宽度,可选 */ + maxWidth?: number + ): void + /** [CanvasContext.lineTo(number x, number y)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.lineTo.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 增加一个新点,然后创建一条从上次指定点到目标点的线。用 `stroke` 方法来画线条 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') +ctx.moveTo(10, 10) +ctx.rect(10, 10, 100, 50) +ctx.lineTo(110, 60) +ctx.stroke() +ctx.draw() +``` +* ![](@program/dev/image/canvas/line-to.png) */ + lineTo( + /** 目标位置的 x 坐标 */ + x: number, + /** 目标位置的 y 坐标 */ + y: number + ): void + /** [CanvasContext.moveTo(number x, number y)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.moveTo.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 把路径移动到画布中的指定点,不创建线条。用 `stroke` 方法来画线条 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') +ctx.moveTo(10, 10) +ctx.lineTo(100, 10) + +ctx.moveTo(10, 50) +ctx.lineTo(100, 50) +ctx.stroke() +ctx.draw() +``` +* ![](@program/dev/image/canvas/move-to.png) */ + moveTo( + /** 目标位置的 x 坐标 */ + x: number, + /** 目标位置的 y 坐标 */ + y: number + ): void + /** [CanvasContext.quadraticCurveTo(number cpx, number cpy, number x, number y)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.quadraticCurveTo.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 创建二次贝塞尔曲线路径。曲线的起始点为路径中前一个点。 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +// Draw points +ctx.beginPath() +ctx.arc(20, 20, 2, 0, 2 * Math.PI) +ctx.setFillStyle('red') +ctx.fill() + +ctx.beginPath() +ctx.arc(200, 20, 2, 0, 2 * Math.PI) +ctx.setFillStyle('lightgreen') +ctx.fill() + +ctx.beginPath() +ctx.arc(20, 100, 2, 0, 2 * Math.PI) +ctx.setFillStyle('blue') +ctx.fill() + +ctx.setFillStyle('black') +ctx.setFontSize(12) + +// Draw guides +ctx.beginPath() +ctx.moveTo(20, 20) +ctx.lineTo(20, 100) +ctx.lineTo(200, 20) +ctx.setStrokeStyle('#AAAAAA') +ctx.stroke() + +// Draw quadratic curve +ctx.beginPath() +ctx.moveTo(20, 20) +ctx.quadraticCurveTo(20, 100, 200, 20) +ctx.setStrokeStyle('black') +ctx.stroke() + +ctx.draw() +``` +* +* ![](@program/dev/image/canvas/quadratic-curve-to.png) +* +* 针对 moveTo(20, 20) quadraticCurveTo(20, 100, 200, 20) 的三个关键坐标如下: +* +* - 红色:起始点(20, 20) +* - 蓝色:控制点(20, 100) +* - 绿色:终止点(200, 20) */ + quadraticCurveTo( + /** 贝塞尔控制点的 x 坐标 */ + cpx: number, + /** 贝塞尔控制点的 y 坐标 */ + cpy: number, + /** 结束点的 x 坐标 */ + x: number, + /** 结束点的 y 坐标 */ + y: number + ): void + /** [CanvasContext.rect(number x, number y, number width, number height)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.rect.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 创建一个矩形路径。需要用 [`fill`](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.fill.html) 或者 [`stroke`](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.stroke.html) 方法将矩形真正的画到 `canvas` 中 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') +ctx.rect(10, 10, 150, 75) +ctx.setFillStyle('red') +ctx.fill() +ctx.draw() +``` +* ![](@program/dev/image/canvas/fill-rect.png) */ + rect( + /** 矩形路径左上角的横坐标 */ + x: number, + /** 矩形路径左上角的纵坐标 */ + y: number, + /** 矩形路径的宽度 */ + width: number, + /** 矩形路径的高度 */ + height: number + ): void + /** [CanvasContext.restore()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.restore.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 恢复之前保存的绘图上下文。 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +// save the default fill style +ctx.save() +ctx.setFillStyle('red') +ctx.fillRect(10, 10, 150, 100) + +// restore to the previous saved state +ctx.restore() +ctx.fillRect(50, 50, 150, 100) + +ctx.draw() +``` +* ![](@program/dev/image/canvas/save-restore.png) */ + restore(): void + /** [CanvasContext.rotate(number rotate)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.rotate.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 以原点为中心顺时针旋转当前坐标轴。多次调用旋转的角度会叠加。原点可以用 `translate` 方法修改。 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +ctx.strokeRect(100, 10, 150, 100) +ctx.rotate(20 * Math.PI / 180) +ctx.strokeRect(100, 10, 150, 100) +ctx.rotate(20 * Math.PI / 180) +ctx.strokeRect(100, 10, 150, 100) + +ctx.draw() +``` +* ![](@program/dev/image/canvas/rotate.png) */ + rotate( + /** 旋转角度,以弧度计 degrees * Math.PI/180;degrees 范围为 0-360 */ + rotate: number + ): void + /** [CanvasContext.save()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.save.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 保存绘图上下文。 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +// save the default fill style +ctx.save() +ctx.setFillStyle('red') +ctx.fillRect(10, 10, 150, 100) + +// restore to the previous saved state +ctx.restore() +ctx.fillRect(50, 50, 150, 100) + +ctx.draw() +``` +* ![](@program/dev/image/canvas/save-restore.png) */ + save(): void + /** [CanvasContext.scale(number scaleWidth, number scaleHeight)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.scale.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 在调用后,之后创建的路径其横纵坐标会被缩放。多次调用倍数会相乘。 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +ctx.strokeRect(10, 10, 25, 15) +ctx.scale(2, 2) +ctx.strokeRect(10, 10, 25, 15) +ctx.scale(2, 2) +ctx.strokeRect(10, 10, 25, 15) + +ctx.draw() +``` +* ![](@program/dev/image/canvas/scale.png) */ + scale( + /** 横坐标缩放的倍数 (1 = 100%,0.5 = 50%,2 = 200%) */ + scaleWidth: number, + /** 纵坐标轴缩放的倍数 (1 = 100%,0.5 = 50%,2 = 200%) */ + scaleHeight: number + ): void + /** [CanvasContext.setFillStyle(string|[CanvasGradient](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasGradient.html) color)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setFillStyle.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [1.9.90](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [CanvasContext.fillStyle](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 设置填充色。 +* +* **代码示例** +* +* ```js +const ctx = wx.createCanvasContext('myCanvas') +ctx.setFillStyle('red') +ctx.fillRect(10, 10, 150, 75) +ctx.draw() +``` +* ![](@program/dev/image/canvas/fill-rect.png) */ + setFillStyle( + /** 填充的颜色,默认颜色为 black。 */ + color: string | CanvasGradient + ): void + /** [CanvasContext.setFontSize(number fontSize)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setFontSize.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [1.9.90](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [CanvasContext.font](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 设置字体的字号 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +ctx.setFontSize(20) +ctx.fillText('20', 20, 20) +ctx.setFontSize(30) +ctx.fillText('30', 40, 40) +ctx.setFontSize(40) +ctx.fillText('40', 60, 60) +ctx.setFontSize(50) +ctx.fillText('50', 90, 90) + +ctx.draw() +``` +* ![](@program/dev/image/canvas/font-size.png) */ + setFontSize( + /** 字体的字号 */ + fontSize: number + ): void + /** [CanvasContext.setGlobalAlpha(number alpha)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setGlobalAlpha.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [1.9.90](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [CanvasContext.globalAlpha](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 设置全局画笔透明度。 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +ctx.setFillStyle('red') +ctx.fillRect(10, 10, 150, 100) +ctx.setGlobalAlpha(0.2) +ctx.setFillStyle('blue') +ctx.fillRect(50, 50, 150, 100) +ctx.setFillStyle('yellow') +ctx.fillRect(100, 100, 150, 100) + +ctx.draw() +``` +* ![](@program/dev/image/canvas/global-alpha.png) */ + setGlobalAlpha( + /** 透明度。范围 0-1,0 表示完全透明,1 表示完全不透明。 */ + alpha: number + ): void + /** [CanvasContext.setLineCap(string lineCap)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setLineCap.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [1.9.90](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [CanvasContext.lineCap](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 设置线条的端点样式 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') +ctx.beginPath() +ctx.moveTo(10, 10) +ctx.lineTo(150, 10) +ctx.stroke() + +ctx.beginPath() +ctx.setLineCap('butt') +ctx.setLineWidth(10) +ctx.moveTo(10, 30) +ctx.lineTo(150, 30) +ctx.stroke() + +ctx.beginPath() +ctx.setLineCap('round') +ctx.setLineWidth(10) +ctx.moveTo(10, 50) +ctx.lineTo(150, 50) +ctx.stroke() + +ctx.beginPath() +ctx.setLineCap('square') +ctx.setLineWidth(10) +ctx.moveTo(10, 70) +ctx.lineTo(150, 70) +ctx.stroke() + +ctx.draw() +``` +* ![](@program/dev/image/canvas/line-cap.png) */ + setLineCap( + /** 线条的结束端点样式 + * + * 参数 lineCap 可选值: + * - 'butt': 向线条的每个末端添加平直的边缘。; + * - 'round': 向线条的每个末端添加圆形线帽。; + * - 'square': 向线条的每个末端添加正方形线帽。; */ + lineCap: 'butt' | 'round' | 'square' + ): void + /** [CanvasContext.setLineDash(Array.<number> pattern, number offset)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setLineDash.html) +* +* 需要基础库: `1.6.0` +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [1.9.90](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [CanvasContext.lineDashOffset](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 设置虚线样式。 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +ctx.setLineDash([10, 20], 5); + +ctx.beginPath(); +ctx.moveTo(0,100); +ctx.lineTo(400, 100); +ctx.stroke(); + +ctx.draw() +``` +* ![](@program/dev/image/canvas/set-line-dash.png) */ + setLineDash( + /** 一组描述交替绘制线段和间距(坐标空间单位)长度的数字 */ + pattern: number[], + /** 虚线偏移量 */ + offset: number + ): void + /** [CanvasContext.setLineJoin(string lineJoin)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setLineJoin.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [1.9.90](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [CanvasContext.lineJoin](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 设置线条的交点样式 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') +ctx.beginPath() +ctx.moveTo(10, 10) +ctx.lineTo(100, 50) +ctx.lineTo(10, 90) +ctx.stroke() + +ctx.beginPath() +ctx.setLineJoin('bevel') +ctx.setLineWidth(10) +ctx.moveTo(50, 10) +ctx.lineTo(140, 50) +ctx.lineTo(50, 90) +ctx.stroke() + +ctx.beginPath() +ctx.setLineJoin('round') +ctx.setLineWidth(10) +ctx.moveTo(90, 10) +ctx.lineTo(180, 50) +ctx.lineTo(90, 90) +ctx.stroke() + +ctx.beginPath() +ctx.setLineJoin('miter') +ctx.setLineWidth(10) +ctx.moveTo(130, 10) +ctx.lineTo(220, 50) +ctx.lineTo(130, 90) +ctx.stroke() + +ctx.draw() +``` +* ![](@program/dev/image/canvas/line-join.png) */ + setLineJoin( + /** 线条的结束交点样式 + * + * 参数 lineJoin 可选值: + * - 'bevel': 斜角; + * - 'round': 圆角; + * - 'miter': 尖角; */ + lineJoin: 'bevel' | 'round' | 'miter' + ): void + /** [CanvasContext.setLineWidth(number lineWidth)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setLineWidth.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [1.9.90](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [CanvasContext.lineWidth](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 设置线条的宽度 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') +ctx.beginPath() +ctx.moveTo(10, 10) +ctx.lineTo(150, 10) +ctx.stroke() + +ctx.beginPath() +ctx.setLineWidth(5) +ctx.moveTo(10, 30) +ctx.lineTo(150, 30) +ctx.stroke() + +ctx.beginPath() +ctx.setLineWidth(10) +ctx.moveTo(10, 50) +ctx.lineTo(150, 50) +ctx.stroke() + +ctx.beginPath() +ctx.setLineWidth(15) +ctx.moveTo(10, 70) +ctx.lineTo(150, 70) +ctx.stroke() + +ctx.draw() +``` +* +* ![](@program/dev/image/canvas/line-width.png) */ + setLineWidth( + /** 线条的宽度,单位px */ + lineWidth: number + ): void + /** [CanvasContext.setMiterLimit(number miterLimit)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setMiterLimit.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [1.9.90](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [CanvasContext.miterLimit](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 设置最大斜接长度。斜接长度指的是在两条线交汇处内角和外角之间的距离。当 [CanvasContext.setLineJoin()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setLineJoin.html) 为 miter 时才有效。超过最大倾斜长度的,连接处将以 lineJoin 为 bevel 来显示。 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') +ctx.beginPath() +ctx.setLineWidth(10) +ctx.setLineJoin('miter') +ctx.setMiterLimit(1) +ctx.moveTo(10, 10) +ctx.lineTo(100, 50) +ctx.lineTo(10, 90) +ctx.stroke() + +ctx.beginPath() +ctx.setLineWidth(10) +ctx.setLineJoin('miter') +ctx.setMiterLimit(2) +ctx.moveTo(50, 10) +ctx.lineTo(140, 50) +ctx.lineTo(50, 90) +ctx.stroke() + +ctx.beginPath() +ctx.setLineWidth(10) +ctx.setLineJoin('miter') +ctx.setMiterLimit(3) +ctx.moveTo(90, 10) +ctx.lineTo(180, 50) +ctx.lineTo(90, 90) +ctx.stroke() + +ctx.beginPath() +ctx.setLineWidth(10) +ctx.setLineJoin('miter') +ctx.setMiterLimit(4) +ctx.moveTo(130, 10) +ctx.lineTo(220, 50) +ctx.lineTo(130, 90) +ctx.stroke() + +ctx.draw() +``` +* ![](@program/dev/image/canvas/miter-limit.png) */ + setMiterLimit( + /** 最大斜接长度 */ + miterLimit: number + ): void + /** [CanvasContext.setShadow(number offsetX, number offsetY, number blur, string color)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setShadow.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [1.9.90](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [CanvasContext.shadowOffsetX|CanvasContext.shadowOffsetY|CanvasContext.shadowColor|CanvasContext.shadowBlur](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 设定阴影样式。 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') +ctx.setFillStyle('red') +ctx.setShadow(10, 50, 50, 'blue') +ctx.fillRect(10, 10, 150, 75) +ctx.draw() +``` +* ![](@program/dev/image/canvas/shadow.png) */ + setShadow( + /** 阴影相对于形状在水平方向的偏移,默认值为 0。 */ + offsetX: number, + /** 阴影相对于形状在竖直方向的偏移,默认值为 0。 */ + offsetY: number, + /** 阴影的模糊级别,数值越大越模糊。范围 0- 100。,默认值为 0。 */ + blur: number, + /** 阴影的颜色。默认值为 black。 */ + color: string + ): void + /** [CanvasContext.setStrokeStyle(string|[CanvasGradient](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasGradient.html) color)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setStrokeStyle.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [1.9.90](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [CanvasContext.strokeStyle](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 设置描边颜色。 +* +* **代码示例** +* +* ```js +const ctx = wx.createCanvasContext('myCanvas') +ctx.setStrokeStyle('red') +ctx.strokeRect(10, 10, 150, 75) +ctx.draw() +``` +* ![](@program/dev/image/canvas/stroke-rect.png) */ + setStrokeStyle( + /** 描边的颜色,默认颜色为 black。 */ + color: string | CanvasGradient + ): void + /** [CanvasContext.setTextAlign(string align)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setTextAlign.html) +* +* 需要基础库: `1.1.0` +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 设置文字的对齐 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +ctx.setStrokeStyle('red') +ctx.moveTo(150, 20) +ctx.lineTo(150, 170) +ctx.stroke() + +ctx.setFontSize(15) +ctx.setTextAlign('left') +ctx.fillText('textAlign=left', 150, 60) + +ctx.setTextAlign('center') +ctx.fillText('textAlign=center', 150, 80) + +ctx.setTextAlign('right') +ctx.fillText('textAlign=right', 150, 100) + +ctx.draw() +``` +* +* ![](@program/dev/image/canvas/set-text-align.png) */ + setTextAlign( + /** 文字的对齐方式 + * + * 参数 align 可选值: + * - 'left': 左对齐; + * - 'center': 居中对齐; + * - 'right': 右对齐; */ + align: 'left' | 'center' | 'right' + ): void + /** [CanvasContext.setTextBaseline(string textBaseline)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setTextBaseline.html) +* +* 需要基础库: `1.4.0` +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 设置文字的竖直对齐 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +ctx.setStrokeStyle('red') +ctx.moveTo(5, 75) +ctx.lineTo(295, 75) +ctx.stroke() + +ctx.setFontSize(20) + +ctx.setTextBaseline('top') +ctx.fillText('top', 5, 75) + +ctx.setTextBaseline('middle') +ctx.fillText('middle', 50, 75) + +ctx.setTextBaseline('bottom') +ctx.fillText('bottom', 120, 75) + +ctx.setTextBaseline('normal') +ctx.fillText('normal', 200, 75) + +ctx.draw() +``` +* ![](@program/dev/image/canvas/set-text-baseline.png) */ + setTextBaseline( + /** 文字的竖直对齐方式 + * + * 参数 textBaseline 可选值: + * - 'top': 顶部对齐; + * - 'bottom': 底部对齐; + * - 'middle': 居中对齐; + * - 'normal': ; */ + textBaseline: 'top' | 'bottom' | 'middle' | 'normal' + ): void + /** [CanvasContext.setTransform(number scaleX, number skewX, number skewY, number scaleY, number translateX, number translateY)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setTransform.html) + * + * 需要基础库: `1.9.90` + * + * 在插件中使用:支持 + * @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 + * + * @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** + * + * 使用矩阵重新设置(覆盖)当前变换的方法 */ + setTransform( + /** 水平缩放 */ + scaleX: number, + /** 水平倾斜 */ + skewX: number, + /** 垂直倾斜 */ + skewY: number, + /** 垂直缩放 */ + scaleY: number, + /** 水平移动 */ + translateX: number, + /** 垂直移动 */ + translateY: number + ): void + /** [CanvasContext.stroke()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.stroke.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 画出当前路径的边框。默认颜色色为黑色。 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') +ctx.moveTo(10, 10) +ctx.lineTo(100, 10) +ctx.lineTo(100, 100) +ctx.stroke() +ctx.draw() +``` +* ![](@program/dev/image/canvas/stroke-line.png) +* +* stroke() 描绘的的路径是从 beginPath() 开始计算,但是不会将 strokeRect() 包含进去。 +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') +// begin path +ctx.rect(10, 10, 100, 30) +ctx.setStrokeStyle('yellow') +ctx.stroke() + +// begin another path +ctx.beginPath() +ctx.rect(10, 40, 100, 30) + +// only stoke this rect, not in current path +ctx.setStrokeStyle('blue') +ctx.strokeRect(10, 70, 100, 30) + +ctx.rect(10, 100, 100, 30) + +// it will stroke current path +ctx.setStrokeStyle('red') +ctx.stroke() +ctx.draw() +``` +* +* ![](@program/dev/image/canvas/stroke-path.png) */ + stroke(): void + /** [CanvasContext.strokeRect(number x, number y, number width, number height)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.strokeRect.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 画一个矩形(非填充)。 用 [`setStrokeStyle`](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setStrokeStyle.html) 设置矩形线条的颜色,如果没设置默认是黑色。 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') +ctx.setStrokeStyle('red') +ctx.strokeRect(10, 10, 150, 75) +ctx.draw() +``` +* ![](@program/dev/image/canvas/stroke-rect.png) */ + strokeRect( + /** 矩形路径左上角的横坐标 */ + x: number, + /** 矩形路径左上角的纵坐标 */ + y: number, + /** 矩形路径的宽度 */ + width: number, + /** 矩形路径的高度 */ + height: number + ): void + /** [CanvasContext.strokeText(string text, number x, number y, number maxWidth)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.strokeText.html) + * + * 需要基础库: `1.9.90` + * + * 在插件中使用:支持 + * @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 + * + * @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** + * + * 给定的 (x, y) 位置绘制文本描边的方法 */ + strokeText( + /** 要绘制的文本 */ + text: string, + /** 文本起始点的 x 轴坐标 */ + x: number, + /** 文本起始点的 y 轴坐标 */ + y: number, + /** 需要绘制的最大宽度,可选 */ + maxWidth?: number + ): void + /** [CanvasContext.transform(number scaleX, number skewX, number skewY, number scaleY, number translateX, number translateY)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.transform.html) + * + * 需要基础库: `1.9.90` + * + * 在插件中使用:支持 + * @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 + * + * @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** + * + * 使用矩阵多次叠加当前变换的方法 */ + transform( + /** 水平缩放 */ + scaleX: number, + /** 水平倾斜 */ + skewX: number, + /** 垂直倾斜 */ + skewY: number, + /** 垂直缩放 */ + scaleY: number, + /** 水平移动 */ + translateX: number, + /** 垂直移动 */ + translateY: number + ): void + /** [CanvasContext.translate(number x, number y)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.translate.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 对当前坐标系的原点 (0, 0) 进行变换。默认的坐标系原点为页面左上角。 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +ctx.strokeRect(10, 10, 150, 100) +ctx.translate(20, 20) +ctx.strokeRect(10, 10, 150, 100) +ctx.translate(20, 20) +ctx.strokeRect(10, 10, 150, 100) + +ctx.draw() +``` +* +* ![](@program/dev/image/canvas/translate.png) */ + translate( + /** 水平坐标平移量 */ + x: number, + /** 竖直坐标平移量 */ + y: number + ): void + /** [Object CanvasContext.measureText(string text)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.measureText.html) + * + * 需要基础库: `1.9.90` + * + * 在插件中使用:支持 + * @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 + * + * @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** + * + * 测量文本尺寸信息。目前仅返回文本宽度。同步接口。 */ + measureText( + /** 要测量的文本 */ + text: string + ): TextMetrics + /** [[CanvasGradient](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasGradient.html) CanvasContext.createCircularGradient(number x, number y, number r)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.createCircularGradient.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 创建一个圆形的渐变颜色。起点在圆心,终点在圆环。返回的`CanvasGradient`对象需要使用 [CanvasGradient.addColorStop()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasGradient.addColorStop.html) 来指定渐变点,至少要两个。 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +// Create circular gradient +const grd = ctx.createCircularGradient(75, 50, 50) +grd.addColorStop(0, 'red') +grd.addColorStop(1, 'white') + +// Fill with gradient +ctx.setFillStyle(grd) +ctx.fillRect(10, 10, 150, 80) +ctx.draw() +``` +* ![](@program/dev/image/canvas/circular-gradient.png) */ + createCircularGradient( + /** 圆心的 x 坐标 */ + x: number, + /** 圆心的 y 坐标 */ + y: number, + /** 圆的半径 */ + r: number + ): CanvasGradient + /** [[CanvasGradient](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasGradient.html) CanvasContext.createLinearGradient(number x0, number y0, number x1, number y1)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.createLinearGradient.html) +* +* 在插件中使用:支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 创建一个线性的渐变颜色。返回的`CanvasGradient`对象需要使用 [CanvasGradient.addColorStop()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasGradient.addColorStop.html) 来指定渐变点,至少要两个。 +* +* **示例代码** +* +* ```javascript +const ctx = wx.createCanvasContext('myCanvas') + +// Create linear gradient +const grd = ctx.createLinearGradient(0, 0, 200, 0) +grd.addColorStop(0, 'red') +grd.addColorStop(1, 'white') + +// Fill with gradient +ctx.setFillStyle(grd) +ctx.fillRect(10, 10, 150, 80) +ctx.draw() +``` +* ![](@program/dev/image/canvas/linear-gradient.png) */ + createLinearGradient( + /** 起点的 x 坐标 */ + x0: number, + /** 起点的 y 坐标 */ + y0: number, + /** 终点的 x 坐标 */ + x1: number, + /** 终点的 y 坐标 */ + y1: number + ): CanvasGradient + } + interface CanvasGetImageDataOption { + /** 画布标识,传入 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 组件的 `canvas-id` 属性。 */ + canvasId: string + /** 将要被提取的图像数据矩形区域的高度 */ + height: number + /** 将要被提取的图像数据矩形区域的宽度 */ + width: number + /** 将要被提取的图像数据矩形区域的左上角横坐标 */ + x: number + /** 将要被提取的图像数据矩形区域的左上角纵坐标 */ + y: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CanvasGetImageDataCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: CanvasGetImageDataFailCallback + /** 接口调用成功的回调函数 */ + success?: CanvasGetImageDataSuccessCallback + } + interface CanvasGetImageDataSuccessCallbackResult { + /** 图像像素点数据,一维数组,每四项表示一个像素点的 rgba */ + data: Uint8ClampedArray + /** 图像数据矩形的高度 */ + height: number + /** 图像数据矩形的宽度 */ + width: number + errMsg: string + } + interface CanvasPutImageDataOption { + /** 画布标识,传入 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 组件的 canvas-id 属性。 */ + canvasId: string + /** 图像像素点数据,一维数组,每四项表示一个像素点的 rgba */ + data: Uint8ClampedArray + /** 源图像数据矩形区域的高度 */ + height: number + /** 源图像数据矩形区域的宽度 */ + width: number + /** 源图像数据在目标画布中的位置偏移量(x 轴方向的偏移量) */ + x: number + /** 源图像数据在目标画布中的位置偏移量(y 轴方向的偏移量) */ + y: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CanvasPutImageDataCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: CanvasPutImageDataFailCallback + /** 接口调用成功的回调函数 */ + success?: CanvasPutImageDataSuccessCallback + } + interface CanvasToTempFilePathOption { + /** 画布标识,传入 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 组件实例 (canvas type="2d" 时使用该属性)。 */ + canvas?: IAnyObject + /** 画布标识,传入 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 组件的 canvas-id */ + canvasId?: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CanvasToTempFilePathCompleteCallback + /** 需要基础库: `1.2.0` + * + * 输出的图片的高度 */ + destHeight?: number + /** 需要基础库: `1.2.0` + * + * 输出的图片的宽度 */ + destWidth?: number + /** 接口调用失败的回调函数 */ + fail?: CanvasToTempFilePathFailCallback + /** 需要基础库: `1.7.0` + * + * 目标文件的类型 + * + * 可选值: + * - 'jpg': jpg 图片; + * - 'png': png 图片; */ + fileType?: 'jpg' | 'png' + /** 需要基础库: `1.2.0` + * + * 指定的画布区域的高度 */ + height?: number + /** 需要基础库: `1.7.0` + * + * 图片的质量,目前仅对 jpg 有效。取值范围为 (0, 1],不在范围内时当作 1.0 处理。 */ + quality?: number + /** 接口调用成功的回调函数 */ + success?: CanvasToTempFilePathSuccessCallback + /** 需要基础库: `1.2.0` + * + * 指定的画布区域的宽度 */ + width?: number + /** 需要基础库: `1.2.0` + * + * 指定的画布区域的左上角横坐标 */ + x?: number + /** 需要基础库: `1.2.0` + * + * 指定的画布区域的左上角纵坐标 */ + y?: number + } + interface CanvasToTempFilePathSuccessCallbackResult { + /** 生成文件的临时路径 (本地路径) */ + tempFilePath: string + errMsg: string + } + /** characteristics列表 */ + interface Characteristic { + /** characteristic 的 UUID */ + uuid: string + /** 描述符数据 */ + descriptors?: CharacteristicDescriptor[] + /** 特征权限 */ + permission?: CharacteristicPermission + /** 特征支持的操作 */ + properties?: CharacteristicProperties + /** 特征对应的二进制值 */ + value?: ArrayBuffer + } + /** 描述符数据 */ + interface CharacteristicDescriptor { + /** Descriptor 的 UUID */ + uuid: string + /** 描述符的权限 */ + permission?: DescriptorPermission + /** 描述符数据 */ + value?: ArrayBuffer + } + /** 特征权限 */ + interface CharacteristicPermission { + /** 加密读请求 */ + readEncryptionRequired?: boolean + /** 可读 */ + readable?: boolean + /** 加密写请求 */ + writeEncryptionRequired?: boolean + /** 可写 */ + writeable?: boolean + } + /** 特征支持的操作 */ + interface CharacteristicProperties { + /** 回包 */ + indicate?: boolean + /** 订阅 */ + notify?: boolean + /** 读 */ + read?: boolean + /** 写 */ + write?: boolean + /** 无回复写 */ + writeNoResponse?: boolean + } + interface CheckDeviceSupportHevcOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CheckDeviceSupportHevcCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: CheckDeviceSupportHevcFailCallback + /** 接口调用成功的回调函数 */ + success?: CheckDeviceSupportHevcSuccessCallback + } + interface CheckDeviceSupportHevcSuccessCallbackResult { + /** 设备是否支持 H.265 编码 */ + supportHevc: boolean + errMsg: string + } + interface CheckIsAddedToMyMiniProgramOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CheckIsAddedToMyMiniProgramCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: CheckIsAddedToMyMiniProgramFailCallback + /** 接口调用成功的回调函数 */ + success?: CheckIsAddedToMyMiniProgramSuccessCallback + } + interface CheckIsAddedToMyMiniProgramSuccessCallbackResult { + /** 是否被添加至 「我的小程序」 */ + added: boolean + errMsg: string + } + interface CheckIsOpenAccessibilityOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CheckIsOpenAccessibilityCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: CheckIsOpenAccessibilityFailCallback + /** 接口调用成功的回调函数 */ + success?: CheckIsOpenAccessibilitySuccessCallback + } + interface CheckIsOpenAccessibilitySuccessCallbackOption { + /** iOS 上开启辅助功能旁白,安卓开启 talkback 时返回 true */ + open: boolean + errMsg: string + } + interface CheckIsSoterEnrolledInDeviceOption { + /** 认证方式 + * + * 可选值: + * - 'fingerPrint': 指纹识别; + * - 'facial': 人脸识别; + * - 'speech': 声纹识别(暂未支持); */ + checkAuthMode: 'fingerPrint' | 'facial' | 'speech' + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CheckIsSoterEnrolledInDeviceCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: CheckIsSoterEnrolledInDeviceFailCallback + /** 接口调用成功的回调函数 */ + success?: CheckIsSoterEnrolledInDeviceSuccessCallback + } + interface CheckIsSoterEnrolledInDeviceSuccessCallbackResult { + /** 错误信息 */ + errMsg: string + /** 是否已录入信息 */ + isEnrolled: boolean + } + interface CheckIsSupportSoterAuthenticationOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CheckIsSupportSoterAuthenticationCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: CheckIsSupportSoterAuthenticationFailCallback + /** 接口调用成功的回调函数 */ + success?: CheckIsSupportSoterAuthenticationSuccessCallback + } + interface CheckIsSupportSoterAuthenticationSuccessCallbackResult { + /** 该设备支持的可被SOTER识别的生物识别方式 + * + * 可选值: + * - 'fingerPrint': 指纹识别; + * - 'facial': 人脸识别; + * - 'speech': 声纹识别(暂未支持); */ + supportMode: Array<'fingerPrint' | 'facial' | 'speech'> + errMsg: string + } + interface CheckSessionOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CheckSessionCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: CheckSessionFailCallback + /** 接口调用成功的回调函数 */ + success?: CheckSessionSuccessCallback + } + interface ChooseAddressOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ChooseAddressCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ChooseAddressFailCallback + /** 接口调用成功的回调函数 */ + success?: ChooseAddressSuccessCallback + } + interface ChooseAddressSuccessCallbackResult { + /** 国标收货地址第二级地址 */ + cityName: string + /** 国标收货地址第三级地址 */ + countyName: string + /** 详细收货地址信息(包括街道地址) */ + detailInfo: string + /** 新选择器详细收货地址信息 */ + detailInfoNew: string + /** 错误信息 */ + errMsg: string + /** 收货地址国家码 */ + nationalCode: string + /** 邮编 */ + postalCode: string + /** 国标收货地址第一级地址 */ + provinceName: string + /** 国标收货地址第四级地址 */ + streetName: string + /** 收货人手机号码 */ + telNumber: string + /** 收货人姓名 */ + userName: string + } + interface ChooseContactOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ChooseContactCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ChooseContactFailCallback + /** 接口调用成功的回调函数 */ + success?: ChooseContactSuccessCallback + } + interface ChooseContactSuccessCallbackOption { + /** 联系人姓名 */ + displayName: string + /** 手机号 */ + phoneNumber: string + /** 选定联系人的所有手机号(部分 Android 系统只能选联系人而不能选特定手机号) */ + phoneNumberList: string + errMsg: string + } + /** 返回选择的文件的本地临时文件对象数组 */ + interface ChooseFile { + /** 选择的文件名称 */ + name: string + /** 本地临时文件路径 (本地路径) */ + path: string + /** 本地临时文件大小,单位 B */ + size: number + /** 选择的文件的会话发送时间,Unix时间戳,工具暂不支持此属性 */ + time: number + /** 选择的文件类型 + * + * 可选值: + * - 'video': 选择了视频文件; + * - 'image': 选择了图片文件; + * - 'file': 选择了除图片和视频的文件; */ + type: 'video' | 'image' | 'file' + } + interface ChooseImageOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ChooseImageCompleteCallback + /** 最多可以选择的图片张数 */ + count?: number + /** 接口调用失败的回调函数 */ + fail?: ChooseImageFailCallback + /** 所选的图片的尺寸 + * + * 可选值: + * - 'original': 原图; + * - 'compressed': 压缩图; */ + sizeType?: Array<'original' | 'compressed'> + /** 选择图片的来源 + * + * 可选值: + * - 'album': 从相册选图; + * - 'camera': 使用相机; */ + sourceType?: Array<'album' | 'camera'> + /** 接口调用成功的回调函数 */ + success?: ChooseImageSuccessCallback + } + interface ChooseImageSuccessCallbackResult { + /** 图片的本地临时文件路径列表 (本地路径) */ + tempFilePaths: string[] + /** 需要基础库: `1.2.0` + * + * 图片的本地临时文件列表 */ + tempFiles: ImageFile[] + errMsg: string + } + interface ChooseInvoiceOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ChooseInvoiceCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ChooseInvoiceFailCallback + /** 接口调用成功的回调函数 */ + success?: ChooseInvoiceSuccessCallback + } + interface ChooseInvoiceSuccessCallbackResult { + /** 用户选中的发票信息,格式为一个 JSON 字符串,包含三个字段: card_id:所选发票卡券的 cardId,encrypt_code:所选发票卡券的加密 code,报销方可以通过 cardId 和 encryptCode 获得报销发票的信息,app_id: 发票方的 appId。 */ + invoiceInfo: string + errMsg: string + } + interface ChooseInvoiceTitleOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ChooseInvoiceTitleCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ChooseInvoiceTitleFailCallback + /** 接口调用成功的回调函数 */ + success?: ChooseInvoiceTitleSuccessCallback + } + interface ChooseInvoiceTitleSuccessCallbackResult { + /** 银行账号 */ + bankAccount: string + /** 银行名称 */ + bankName: string + /** 单位地址 */ + companyAddress: string + /** 错误信息 */ + errMsg: string + /** 抬头税号 */ + taxNumber: string + /** 手机号码 */ + telephone: string + /** 抬头名称 */ + title: string + /** 抬头类型 + * + * 可选值: + * - 0: 单位; + * - 1: 个人; */ + type: 0 | 1 + } + interface ChooseLicensePlateOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ChooseLicensePlateCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ChooseLicensePlateFailCallback + /** 接口调用成功的回调函数 */ + success?: ChooseLicensePlateSuccessCallback + } + interface ChooseLicensePlateSuccessCallbackResult { + /** 用户选择的车牌号 */ + plateNumber: string + errMsg: string + } + interface ChooseLocationOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ChooseLocationCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ChooseLocationFailCallback + /** 需要基础库: `2.9.0` + * + * 目标地纬度 */ + latitude?: number + /** 需要基础库: `2.9.0` + * + * 目标地经度 */ + longitude?: number + /** 接口调用成功的回调函数 */ + success?: ChooseLocationSuccessCallback + } + interface ChooseLocationSuccessCallbackResult { + /** 详细地址 */ + address: string + /** 纬度,浮点数,范围为-90~90,负数表示南纬。使用 gcj02 国测局坐标系 */ + latitude: number + /** 经度,浮点数,范围为-180~180,负数表示西经。使用 gcj02 国测局坐标系 */ + longitude: number + /** 位置名称 */ + name: string + errMsg: string + } + interface ChooseMediaOption { + /** 仅在 sourceType 为 camera 时生效,使用前置或后置摄像头 + * + * 可选值: + * - 'back': 使用后置摄像头; + * - 'front': 使用前置摄像头; */ + camera?: 'back' | 'front' + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ChooseMediaCompleteCallback + /** 最多可以选择的文件个数,基础库2.25.0前,最多可支持9个文件,2.25.0及以后最多可支持20个文件 */ + count?: number + /** 接口调用失败的回调函数 */ + fail?: ChooseMediaFailCallback + /** 拍摄视频最长拍摄时间,单位秒。时间范围为 3s 至 60s 之间。不限制相册。 */ + maxDuration?: number + /** 文件类型 + * + * 可选值: + * - 'image': 只能拍摄图片或从相册选择图片; + * - 'video': 只能拍摄视频或从相册选择视频; + * - 'mix': 可同时选择图片和视频; */ + mediaType?: Array<'image' | 'video' | 'mix'> + /** 是否压缩所选文件,基础库2.25.0前仅对 mediaType 为 image 时有效,2.25.0及以后对全量 mediaType 有效 */ + sizeType?: string[] + /** 图片和视频选择的来源 + * + * 可选值: + * - 'album': 从相册选择; + * - 'camera': 使用相机拍摄; */ + sourceType?: Array<'album' | 'camera'> + /** 接口调用成功的回调函数 */ + success?: ChooseMediaSuccessCallback + } + interface ChooseMediaSuccessCallbackResult { + /** 本地临时文件列表 */ + tempFiles: MediaFile[] + /** 文件类型,有效值有 image 、video、mix */ + type: string + errMsg: string + } + interface ChooseMessageFileOption { + /** 最多可以选择的文件个数,可以 0~100 */ + count: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ChooseMessageFileCompleteCallback + /** 需要基础库: `2.6.0` + * + * 根据文件拓展名过滤,仅 type==file 时有效。每一项都不能是空字符串。默认不过滤。 */ + extension?: string[] + /** 接口调用失败的回调函数 */ + fail?: ChooseMessageFileFailCallback + /** 接口调用成功的回调函数 */ + success?: ChooseMessageFileSuccessCallback + /** 所选的文件的类型 + * + * 可选值: + * - 'all': 从所有文件选择; + * - 'video': 只能选择视频文件; + * - 'image': 只能选择图片文件; + * - 'file': 可以选择除了图片和视频之外的其它的文件; */ + type?: 'all' | 'video' | 'image' | 'file' + } + interface ChooseMessageFileSuccessCallbackResult { + /** 返回选择的文件的本地临时文件对象数组 */ + tempFiles: ChooseFile[] + errMsg: string + } + interface ChoosePoiOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ChoosePoiCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ChoosePoiFailCallback + /** 接口调用成功的回调函数 */ + success?: ChoosePoiSuccessCallback + } + interface ChoosePoiSuccessCallbackResult { + /** 详细地址 */ + address: string + /** 城市名称 */ + city: number + /** 纬度,浮点数,范围为-90~90,负数表示南纬。使用 gcj02 国测局坐标系(即将废弃) */ + latitude: number + /** 经度,浮点数,范围为-180~180,负数表示西经。使用 gcj02 国测局坐标系(即将废弃) */ + longitude: number + /** 位置名称 */ + name: string + /** 选择城市时,值为 1,选择精确位置时,值为 2 */ + type: number + errMsg: string + } + interface ChooseVideoOption { + /** 默认拉起的是前置或者后置摄像头。部分 Android 手机下由于系统 ROM 不支持无法生效 + * + * 可选值: + * - 'back': 默认拉起后置摄像头; + * - 'front': 默认拉起前置摄像头; */ + camera?: 'back' | 'front' + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ChooseVideoCompleteCallback + /** 需要基础库: `1.6.0` + * + * 是否压缩所选择的视频文件 */ + compressed?: boolean + /** 接口调用失败的回调函数 */ + fail?: ChooseVideoFailCallback + /** 拍摄视频最长拍摄时间,单位秒 */ + maxDuration?: number + /** 视频选择的来源 + * + * 可选值: + * - 'album': 从相册选择视频; + * - 'camera': 使用相机拍摄视频; */ + sourceType?: Array<'album' | 'camera'> + /** 接口调用成功的回调函数 */ + success?: ChooseVideoSuccessCallback + } + interface ChooseVideoSuccessCallbackResult { + /** 选定视频的时间长度 */ + duration: number + /** 返回选定视频的高度 */ + height: number + /** 选定视频的数据量大小 */ + size: number + /** 选定视频的临时文件路径 (本地路径) */ + tempFilePath: string + /** 返回选定视频的宽度 */ + width: number + errMsg: string + } + interface ClearFiltersOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ClearFiltersCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ClearFiltersFailCallback + /** 接口调用成功的回调函数 */ + success?: ClearFiltersSuccessCallback + } + interface ClearMakeupsOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ClearMakeupsCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ClearMakeupsFailCallback + /** 接口调用成功的回调函数 */ + success?: ClearMakeupsSuccessCallback + } + interface ClearOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ClearCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ClearFailCallback + /** 接口调用成功的回调函数 */ + success?: ClearSuccessCallback + } + interface ClearStickersOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ClearStickersCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ClearStickersFailCallback + /** 接口调用成功的回调函数 */ + success?: ClearStickersSuccessCallback + } + interface ClearStorageOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ClearStorageCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ClearStorageFailCallback + /** 接口调用成功的回调函数 */ + success?: ClearStorageSuccessCallback + } + /** 菜单按钮的布局位置信息 */ + interface ClientRect { + /** 下边界坐标,单位:px */ + bottom: number + /** 高度,单位:px */ + height: number + /** 左边界坐标,单位:px */ + left: number + /** 右边界坐标,单位:px */ + right: number + /** 上边界坐标,单位:px */ + top: number + /** 宽度,单位:px */ + width: number + } + interface CloseBLEConnectionOption { + /** 蓝牙设备 id */ + deviceId: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CloseBLEConnectionCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: CloseBLEConnectionFailCallback + /** 接口调用成功的回调函数 */ + success?: CloseBLEConnectionSuccessCallback + } + interface CloseBluetoothAdapterOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CloseBluetoothAdapterCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: CloseBluetoothAdapterFailCallback + /** 接口调用成功的回调函数 */ + success?: CloseBluetoothAdapterSuccessCallback + } + interface CloseSocketOption { + /** 一个数字值表示关闭连接的状态号,表示连接被关闭的原因。 */ + code?: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CloseSocketCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: CloseSocketFailCallback + /** 一个可读的字符串,表示连接被关闭的原因。这个字符串必须是不长于 123 字节的 UTF-8 文本(不是字符)。 */ + reason?: string + /** 接口调用成功的回调函数 */ + success?: CloseSocketSuccessCallback + } + interface CloseSyncOption { + /** 需要被关闭的文件描述符。fd 通过 [FileSystemManager.open](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.open.html) 或 [FileSystemManager.openSync](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.openSync.html) 接口获得 */ + fd: string + } + /** 颜色。可以用以下几种方式来表示 canvas 中使用的颜色: + * + * - RGB 颜色: 如 `'rgb(255, 0, 0)'` + * - RGBA 颜色:如 `'rgba(255, 0, 0, 0.3)'` + * - 16 进制颜色: 如 `'#FF0000'` + * - 预定义的颜色: 如 `'red'` + * + * 其中预定义颜色有以下148个: + * *注意**: Color Name 大小写不敏感 + * + * | Color Name | HEX | + * | -------------------- | ------- | + * | AliceBlue | #F0F8FF | + * | AntiqueWhite | #FAEBD7 | + * | Aqua | #00FFFF | + * | Aquamarine | #7FFFD4 | + * | Azure | #F0FFFF | + * | Beige | #F5F5DC | + * | Bisque | #FFE4C4 | + * | Black | #000000 | + * | BlanchedAlmond | #FFEBCD | + * | Blue | #0000FF | + * | BlueViolet | #8A2BE2 | + * | Brown | #A52A2A | + * | BurlyWood | #DEB887 | + * | CadetBlue | #5F9EA0 | + * | Chartreuse | #7FFF00 | + * | Chocolate | #D2691E | + * | Coral | #FF7F50 | + * | CornflowerBlue | #6495ED | + * | Cornsilk | #FFF8DC | + * | Crimson | #DC143C | + * | Cyan | #00FFFF | + * | DarkBlue | #00008B | + * | DarkCyan | #008B8B | + * | DarkGoldenRod | #B8860B | + * | DarkGray | #A9A9A9 | + * | DarkGrey | #A9A9A9 | + * | DarkGreen | #006400 | + * | DarkKhaki | #BDB76B | + * | DarkMagenta | #8B008B | + * | DarkOliveGreen | #556B2F | + * | DarkOrange | #FF8C00 | + * | DarkOrchid | #9932CC | + * | DarkRed | #8B0000 | + * | DarkSalmon | #E9967A | + * | DarkSeaGreen | #8FBC8F | + * | DarkSlateBlue | #483D8B | + * | DarkSlateGray | #2F4F4F | + * | DarkSlateGrey | #2F4F4F | + * | DarkTurquoise | #00CED1 | + * | DarkViolet | #9400D3 | + * | DeepPink | #FF1493 | + * | DeepSkyBlue | #00BFFF | + * | DimGray | #696969 | + * | DimGrey | #696969 | + * | DodgerBlue | #1E90FF | + * | FireBrick | #B22222 | + * | FloralWhite | #FFFAF0 | + * | ForestGreen | #228B22 | + * | Fuchsia | #FF00FF | + * | Gainsboro | #DCDCDC | + * | GhostWhite | #F8F8FF | + * | Gold | #FFD700 | + * | GoldenRod | #DAA520 | + * | Gray | #808080 | + * | Grey | #808080 | + * | Green | #008000 | + * | GreenYellow | #ADFF2F | + * | HoneyDew | #F0FFF0 | + * | HotPink | #FF69B4 | + * | IndianRed | #CD5C5C | + * | Indigo | #4B0082 | + * | Ivory | #FFFFF0 | + * | Khaki | #F0E68C | + * | Lavender | #E6E6FA | + * | LavenderBlush | #FFF0F5 | + * | LawnGreen | #7CFC00 | + * | LemonChiffon | #FFFACD | + * | LightBlue | #ADD8E6 | + * | LightCoral | #F08080 | + * | LightCyan | #E0FFFF | + * | LightGoldenRodYellow | #FAFAD2 | + * | LightGray | #D3D3D3 | + * | LightGrey | #D3D3D3 | + * | LightGreen | #90EE90 | + * | LightPink | #FFB6C1 | + * | LightSalmon | #FFA07A | + * | LightSeaGreen | #20B2AA | + * | LightSkyBlue | #87CEFA | + * | LightSlateGray | #778899 | + * | LightSlateGrey | #778899 | + * | LightSteelBlue | #B0C4DE | + * | LightYellow | #FFFFE0 | + * | Lime | #00FF00 | + * | LimeGreen | #32CD32 | + * | Linen | #FAF0E6 | + * | Magenta | #FF00FF | + * | Maroon | #800000 | + * | MediumAquaMarine | #66CDAA | + * | MediumBlue | #0000CD | + * | MediumOrchid | #BA55D3 | + * | MediumPurple | #9370DB | + * | MediumSeaGreen | #3CB371 | + * | MediumSlateBlue | #7B68EE | + * | MediumSpringGreen | #00FA9A | + * | MediumTurquoise | #48D1CC | + * | MediumVioletRed | #C71585 | + * | MidnightBlue | #191970 | + * | MintCream | #F5FFFA | + * | MistyRose | #FFE4E1 | + * | Moccasin | #FFE4B5 | + * | NavajoWhite | #FFDEAD | + * | Navy | #000080 | + * | OldLace | #FDF5E6 | + * | Olive | #808000 | + * | OliveDrab | #6B8E23 | + * | Orange | #FFA500 | + * | OrangeRed | #FF4500 | + * | Orchid | #DA70D6 | + * | PaleGoldenRod | #EEE8AA | + * | PaleGreen | #98FB98 | + * | PaleTurquoise | #AFEEEE | + * | PaleVioletRed | #DB7093 | + * | PapayaWhip | #FFEFD5 | + * | PeachPuff | #FFDAB9 | + * | Peru | #CD853F | + * | Pink | #FFC0CB | + * | Plum | #DDA0DD | + * | PowderBlue | #B0E0E6 | + * | Purple | #800080 | + * | RebeccaPurple | #663399 | + * | Red | #FF0000 | + * | RosyBrown | #BC8F8F | + * | RoyalBlue | #4169E1 | + * | SaddleBrown | #8B4513 | + * | Salmon | #FA8072 | + * | SandyBrown | #F4A460 | + * | SeaGreen | #2E8B57 | + * | SeaShell | #FFF5EE | + * | Sienna | #A0522D | + * | Silver | #C0C0C0 | + * | SkyBlue | #87CEEB | + * | SlateBlue | #6A5ACD | + * | SlateGray | #708090 | + * | SlateGrey | #708090 | + * | Snow | #FFFAFA | + * | SpringGreen | #00FF7F | + * | SteelBlue | #4682B4 | + * | Tan | #D2B48C | + * | Teal | #008080 | + * | Thistle | #D8BFD8 | + * | Tomato | #FF6347 | + * | Turquoise | #40E0D0 | + * | Violet | #EE82EE | + * | Wheat | #F5DEB3 | + * | White | #FFFFFF | + * | WhiteSmoke | #F5F5F5 | + * | Yellow | #FFFF00 | + * | YellowGreen | #9ACD32 | */ + interface Color {} + interface CompressImageOption { + /** 图片路径,图片的路径,支持本地路径、代码包路径 */ + src: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CompressImageCompleteCallback + /** 需要基础库: `2.26.0` + * + * 压缩后图片的高度,单位为px,若不填写则默认以compressedWidth为准等比缩放 */ + compressedHeight?: number + /** 需要基础库: `2.26.0` + * + * 压缩后图片的宽度,单位为px,若不填写则默认以compressedHeight为准等比缩放。 */ + compressedWidth?: number + /** 接口调用失败的回调函数 */ + fail?: CompressImageFailCallback + /** 压缩质量,范围0~100,数值越小,质量越低,压缩率越高(仅对jpg有效)。 */ + quality?: number + /** 接口调用成功的回调函数 */ + success?: CompressImageSuccessCallback + } + interface CompressImageSuccessCallbackResult { + /** 压缩后图片的临时文件路径 (本地路径) */ + tempFilePath: string + errMsg: string + } + interface CompressVideoOption { + /** 码率,单位 kbps */ + bitrate: number + /** 帧率 */ + fps: number + /** 相对于原视频的分辨率比例,取值范围(0, 1] */ + resolution: number + /** 视频文件路径,可以是临时文件路径也可以是永久文件路径 */ + src: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CompressVideoCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: CompressVideoFailCallback + /** 压缩质量 + * + * 可选值: + * - 'low': 低; + * - 'medium': 中; + * - 'high': 高; */ + quality?: 'low' | 'medium' | 'high' + /** 接口调用成功的回调函数 */ + success?: CompressVideoSuccessCallback + } + interface CompressVideoSuccessCallbackResult { + /** 压缩后的大小,单位 kB */ + size: string + /** 压缩后的临时文件地址 */ + tempFilePath: string + errMsg: string + } + interface ConnectSocketOption { + /** 开发者服务器 wss 接口地址 */ + url: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ConnectSocketCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ConnectSocketFailCallback + /** 需要基础库: `2.29.0` + * + * 强制使用蜂窝网络发送请求 */ + forceCellularNetwork?: boolean + /** HTTP Header,Header 中不能设置 Referer */ + header?: IAnyObject + /** 需要基础库: `2.8.0` + * + * 是否开启压缩扩展 */ + perMessageDeflate?: boolean + /** 需要基础库: `1.4.0` + * + * 子协议数组 */ + protocols?: string[] + /** 接口调用成功的回调函数 */ + success?: ConnectSocketSuccessCallback + /** 需要基础库: `2.4.0` + * + * 建立 TCP 连接的时候的 TCP_NODELAY 设置 */ + tcpNoDelay?: boolean + /** 需要基础库: `2.10.0` + * + * 超时时间,单位为毫秒 */ + timeout?: number + } + interface ConnectWifiOption { + /** Wi-Fi 设备 SSID */ + SSID: string + /** Wi-Fi 设备密码 */ + password: string + /** Wi-Fi 设备 BSSID */ + BSSID?: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ConnectWifiCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ConnectWifiFailCallback + /** 需要基础库: `2.12.0` + * + * 跳转到系统设置页进行连接 */ + maunal?: boolean + /** 需要基础库: `2.22.0` + * + * 是否需要返回部分 Wi-Fi 信息,仅安卓生效 */ + partialInfo?: boolean + /** 接口调用成功的回调函数 */ + success?: ConnectWifiSuccessCallback + } + /** 一个字典对象,用于指定是否禁用规范化(默认启用规范化) */ + interface Constraints { + /** 如果指定为true则禁用标准化,默认为false */ + disableNormalization?: boolean + } + interface ContextCallbackResult { + /** 节点对应的 Context 对象 */ + context: IAnyObject + } + interface CopyFileOption { + /** 目标文件路径,支持本地路径 */ + destPath: string + /** 源文件路径,支持本地路径 */ + srcPath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CopyFileCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: CopyFileFailCallback + /** 接口调用成功的回调函数 */ + success?: CopyFileSuccessCallback + } + interface CreateBLEConnectionOption { + /** 蓝牙设备 id */ + deviceId: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CreateBLEConnectionCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: CreateBLEConnectionFailCallback + /** 接口调用成功的回调函数 */ + success?: CreateBLEConnectionSuccessCallback + /** 超时时间,单位 ms,不填表示不会超时 */ + timeout?: number + } + interface CreateBLEPeripheralServerOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CreateBLEPeripheralServerCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: CreateBLEPeripheralServerFailCallback + /** 接口调用成功的回调函数 */ + success?: CreateBLEPeripheralServerSuccessCallback + } + interface CreateBLEPeripheralServerSuccessCallbackResult { + /** [BLEPeripheralServer](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.html) + * + * 外围设备的服务端。 */ + server: BLEPeripheralServer + errMsg: string + } + interface CreateCacheManagerOption { + /** 额外的缓存处理 */ + extra?: ExtraOption + /** 全局缓存有效时间,单位为毫秒,默认为 7 天,最长不超过 30 天 */ + maxAge?: number + /** 缓存模式 + * + * 可选值: + * - 'weakNetwork': 弱网/离线使用缓存返回; + * - 'always': 总是使用缓存返回; + * - 'none': 不开启,后续可手动开启/停止使用缓存返回; */ + mode?: 'weakNetwork' | 'always' | 'none' + /** 全局 origin */ + origin?: string + } + interface CreateGlobalPaymentOption { + /** 根据每笔订单实际的交易地区,提供地区编码,不同地区可能匹配不同的支付方式,参考 ISO3166二位字母代码标准,大写。 */ + mchRegion: string + /** true为开发环境,false为生产环境。不传入该参数,则默认为false,即生产环境。 */ + isSandbox?: string + } + interface CreateInferenceSessionOption { + /** 模型文件路径,目前只执行后缀为.onnx格式(支持代码包路径,和本地文件系统路径) */ + model: string + /** 是否使用NPU推理,仅对IOS有效 */ + allowNPU?: boolean + /** 是否生成量化模型推理 */ + allowQuantize?: boolean + /** 推理精度,有效值为 0 - 4。一般来说,使用的precisionLevel等级越低,推理速度越快,但可能会损失精度。推荐开发者在开发时,在效果满足需求时优先使用更低精度以提高推理速度,节约能耗。 + * + * 可选值: + * - 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计算; */ + precisionLevel?: 0 | 1 | 2 | 3 | 4 + /** 输入典型分辨率 */ + typicalShape?: IAnyObject + } + interface CreateInnerAudioContextOption { + /** 需要基础库: `2.19.0` + * + * 是否使用 WebAudio 作为底层音频驱动,默认关闭。对于短音频、播放频繁的音频建议开启此选项,开启后将获得更优的性能表现。由于开启此选项后也会带来一定的内存增长,因此对于长音频建议关闭此选项。 */ + useWebAudioImplement?: boolean + } + /** 选项 */ + interface CreateIntersectionObserverOption { + /** 初始的相交比例,如果调用时检测到的相交比例与这个值不相等且达到阈值,则会触发一次监听器的回调函数。 */ + initialRatio?: number + /** 需要基础库: `3.5.7` + * + * 是否使用原生观察器模式。 */ + nativeMode?: boolean + /** 需要基础库: `2.0.0` + * + * 是否同时观测多个目标节点(而非一个),如果设为 true ,observe 的 targetSelector 将选中多个节点(注意:同时选中过多节点将影响渲染性能) */ + observeAll?: boolean + /** 一个数值数组,包含所有阈值。 */ + thresholds?: number[] + } + interface CreateInterstitialAdOption { + /** 广告单元 id */ + adUnitId: string + } + interface CreateMediaRecorderOption { + /** 指定录制的时长(s),到达自动停止。最大 7200,最小 5 */ + duration?: number + /** 视频 fps */ + fps?: number + /** 视频关键帧间隔 */ + gop?: number + /** 画布录制高度 */ + height?: number + /** 视频比特率(kbps),最小值 600,最大值 3000 */ + videoBitsPerSecond?: number + /** 画布录制宽度 */ + width?: number + } + interface CreateOffscreenCanvasOption { + /** 在自定义组件下,当前组件实例的 this */ + compInst?: Component.TrivialInstance | Page.TrivialInstance + /** 画布高度 */ + height?: number + /** 创建的离屏 canvas 类型 + * + * 可选值: + * - 'webgl': webgl类型上下文; + * - '2d': 2d类型上下文; */ + type?: 'webgl' | '2d' + /** 画布宽度 */ + width?: number + } + interface CreateRewardedVideoAdOption { + /** 广告单元 id */ + adUnitId: string + /** 需要基础库: `3.7.1` + * + * 是否禁用分享页,默认为false */ + disableFallbackSharePage?: boolean + /** 需要基础库: `2.8.0` + * + * 是否启用多例模式,默认为false */ + multiton?: boolean + } + interface CreateTCPSocketOption { + /** 需要基础库: `3.6.4` + * + * 套接字族,必须是 IPv4 或者 IPv6,默认是 IPv4 + * + * 可选值: + * - 'ipv4': IPv4; + * - 'ipv6': IPv6; */ + type?: 'ipv4' | 'ipv6' + } + /** 可选参数 */ + interface CreateWorkerOption { + /** 需要基础库: `2.13.0` + * + * 是否使用实验worker。在iOS下,实验worker的JS运行效率比非实验worker提升数倍,如需在worker内进行重度计算的建议开启此选项。同时,实验worker存在极小概率会在系统资源紧张时被系统回收,因此建议配合 worker.onProcessKilled 事件使用,在worker被回收后可重新创建一个。 */ + useExperimentalWorker?: boolean + } + interface CropImageOption { + /** 裁剪比例 + * + * 可选值: + * - '16:9': 宽高比为16比9; + * - '9:16': 宽高比为9比16; + * - '4:3': 宽高比为4比3; + * - '3:4': 宽高比为3比4; + * - '5:4': 宽高比为5比4; + * - '4:5': 宽高比为4比5; + * - '1:1': 宽高比为1比1; */ + cropScale: '16:9' | '9:16' | '4:3' | '3:4' | '5:4' | '4:5' | '1:1' + /** 图片路径,图片的路径,支持本地路径、代码包路径 */ + src: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CropImageCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: CropImageFailCallback + /** 接口调用成功的回调函数 */ + success?: CropImageSuccessCallback + } + interface CropImageSuccessCallbackResult { + /** 编辑后图片的临时文件路径 (本地路径) */ + tempFilePath: string + errMsg: string + } + interface CurrentState { + /** 当前缓存中的日志条数 */ + logCount: number + /** 当前缓存中最大可存日志条数 */ + maxLogCount: number + /** 当前缓存最大可用空间,以字节为单位 */ + maxSize: number + /** 当前缓存中已使用空间,以字节为单位 */ + size: number + } + /** 自定义路由动画配置 */ + interface CustomRouteConfig { + /** 遮罩层背景色,支持 `rgba()` 和 `#RRGGBBAA` 写法 */ + barrierColor: string + /** 点击遮罩层返回上一页 */ + barrierDismissible: boolean + /** 无障碍语义 */ + barrierLabel: string + /** 是否与前一个页面联动,决定前一个页 `secondaryAnimation` 是否生效 */ + canTransitionFrom: boolean + /** 是否与下一个页面联动,决定当前页 `secondaryAnimation` 是否生效 */ + canTransitionTo: boolean + /** 是否保持前一个页面状态 */ + maintainState: boolean + /** 下一个页面推入后,不显示前一个页面 */ + opaque: boolean + /** 页面推出动画时长,单位 ms */ + reverseTransitionDuration: number + /** 页面推入动画时长,单位 ms */ + transitionDuration: number + } + /** 自定义路由上下文对象 */ + interface CustomRouteContext { + /** 返回上一级,效果同 `wx.navigateBack`,仅可用于 `worklet` 函数内 */ + didPop: (...args: any[]) => any + /** 动画控制器,影响推入页面的进入和退出过渡效果 */ + primaryAnimation: SharedValue + /** 动画控制器状态 */ + primaryAnimationStatus: SharedValue + /** 动画控制器,影响栈顶页面的推出过渡效果 */ + secondaryAnimation: SharedValue + /** 动画控制器状态 */ + secondaryAnimationStatus: SharedValue + /** 手势开始控制路由,与共享元素动画有关 */ + startUserGesture: (...args: any[]) => any + /** 手势不再控制路由,与 `startUserGesture` 成对调用 */ + stopUserGesture: (...args: any[]) => any + /** 当前路由进度由手势控制 */ + userGestureInProgress: SharedValue + } + /** 弹幕内容 */ + interface Danmu { + /** 弹幕文字 */ + text: string + /** 弹幕颜色 */ + color?: string + } + /** 动画配置 */ + interface DecayOption { + /** 边界值,长度为 2 的数组 */ + clamp?: any[] + /** 衰减速率 */ + deceleration?: number + /** 初速度 */ + velocity?: number + } + interface DeleteTextOption { + /** 选区开始位置 */ + index: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: DeleteTextCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: DeleteTextFailCallback + /** 选区长度 */ + length?: number + /** 接口调用成功的回调函数 */ + success?: DeleteTextSuccessCallback + } + /** 帧深度纹理buffer对象 */ + interface DepthBufferRes { + /** 深度纹理buffer */ + DepthAddress: ArrayBuffer + /** 深度纹理高 */ + height: number + /** 深度纹理宽 */ + width: number + } + /** 需要基础库: `3.0.0` + * + * 深度识别配置。用法详情[指南文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/depth.html)。 */ + interface DepthTrack { + /** 需要基础库: `3.0.0` + * + * 深度识别模式 + * + * 可选值: + * - 1: 通过摄像头实时检测; + * - 2: 静态图片检测; */ + mode: 1 | 2 + } + /** 可选的字体描述符 */ + interface DescOption { + /** 字体样式,可选值为 normal / italic / oblique */ + style?: string + /** 设置小型大写字母的字体显示文本,可选值为 normal / small-caps / inherit */ + variant?: string + /** 字体粗细,可选值为 normal / bold / 100 / 200../ 900 */ + weight?: string + } + /** 描述符的权限 */ + interface DescriptorPermission { + /** 读 */ + read?: boolean + /** 写 */ + write?: boolean + } + /** 指定 marker 移动到的目标点 */ + interface DestinationOption { + /** 纬度 */ + latitude: number + /** 经度 */ + longitude: number + } + interface DetectBodyOption { + /** 人脸图像像素点数据,每四项表示一个像素点的 RGBA */ + frameBuffer: ArrayBuffer + /** 图像高度 */ + height: number + /** 图像宽度 */ + width: number + /** 评分阈值。正常情况传入 0.8 即可。 */ + scoreThreshold?: number + /** 图像源类型。正常情况传入 1 即可。当输入的图片是来自一个连续视频的每一帧图像时,sourceType 传入 0 会得到更优的效果 + * + * 可选值: + * - 1: 表示输入的图片是随机的图片; + * - 0: 表示输入的图片是来自一个连续视频的每一帧图像; */ + sourceType?: 1 | 0 + } + interface DetectDepthOption { + /** 需要识别深度的图像像素点数据,每四项表示一个像素点的 RGBA */ + frameBuffer: ArrayBuffer + /** 图像高度 */ + height: number + /** 图像宽度 */ + width: number + } + interface DetectFaceOption { + /** 人脸图像像素点数据,每四项表示一个像素点的 RGBA */ + frameBuffer: ArrayBuffer + /** 图像高度 */ + height: number + /** 图像宽度 */ + width: number + /** 算法模型类型。正常情况传入 1 即可。0、1、2 分别表示小、中、大模型,模型越大识别准确率越高,但资源占用也越高。建议根据用户设备性能进行选择。 + * + * 可选值: + * - 0: 小模型; + * - 1: 中模型; + * - 2: 大模型; */ + modelModel?: 0 | 1 | 2 + /** 评分阈值。正常情况传入 0.8 即可。 */ + scoreThreshold?: number + /** 图像源类型。正常情况传入 1 即可。当输入的图片是来自一个连续视频的每一帧图像时,sourceType 传入 0 会得到更优的效果 + * + * 可选值: + * - 1: 表示输入的图片是随机的图片; + * - 0: 表示输入的图片是来自一个连续视频的每一帧图像; */ + sourceType?: 1 | 0 + } + interface DetectHandOption { + /** 人脸图像像素点数据,每四项表示一个像素点的 RGBA */ + frameBuffer: ArrayBuffer + /** 图像高度 */ + height: number + /** 图像宽度 */ + width: number + /** 算法检测模式 + * + * 可选值: + * - 0: 检测模式,输出框和点; + * - 1: 手势模式,输出框和手势分类; + * - 2: 结合0和1模式,输出框、点、手势分类; */ + algoMode?: 0 | 1 | 2 + /** 评分阈值。正常情况传入 0.8 即可。 */ + scoreThreshold?: number + } + interface DeviceInfo { + /** 应用(微信APP)二进制接口类型(仅 Android 支持) */ + abi: string + /** 设备性能等级(仅 Android 支持)。取值为:-2 或 0(该设备无法运行小游戏),-1(性能未知),>=1(设备性能值,该值越高,设备性能越好,目前最高不到50)
注意:从基础库3.4.5开始,本返回值停止维护,请使用[wx.getDeviceBenchmarkInfo](https://developers.weixin.qq.com/miniprogram/dev/api/base/system/wx.getDeviceBenchmarkInfo.html)获取设备性能等级 */ + benchmarkLevel: number + /** 设备品牌 */ + brand: string + /** 需要基础库: `2.29.0` + * + * 设备 CPU 型号(仅 Android 支持)(Tips: GPU 型号可通过 WebGLRenderingContext.getExtension('WEBGL_debug_renderer_info') 来获取) */ + cpuType: string + /** 需要基础库: `2.25.1` + * + * 设备二进制接口类型(仅 Android 支持) */ + deviceAbi: string + /** 需要基础库: `2.30.0` + * + * 设备内存大小,单位为 MB */ + memorySize: string + /** 设备型号。新机型刚推出一段时间会显示unknown,微信会尽快进行适配。 */ + model: string + /** 客户端平台 */ + platform: string + /** 操作系统及版本 */ + system: string + } + interface DeviceVoIPInfo { + /** 需要基础库: `2.30.4` + * + * 设备组的唯一标识 id(仅设备组时) */ + group_id: string + /** 设备型号 id。通过微信公众平台注册设备获得。(仅单台设备时) */ + model_id: string + /** 设备唯一序列号。(仅单台设备时) */ + sn: string + /** 设备(组)授权状态。0:未授权;1:已授权 */ + status: number + } + interface DisableAlertBeforeUnloadOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: DisableAlertBeforeUnloadCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: DisableAlertBeforeUnloadFailCallback + /** 接口调用成功的回调函数 */ + success?: DisableAlertBeforeUnloadSuccessCallback + } + interface DownloadFileOption { + /** 下载资源的 url */ + url: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: DownloadFileCompleteCallback + /** 需要基础库: `2.10.4` + * + * 是否开启 http2 */ + enableHttp2?: boolean + /** 是否开启 profile,默认开启。开启后可在接口回调的 res.profile 中查看性能调试信息。 */ + enableProfile?: boolean + /** 需要基础库: `2.10.4` + * + * 是否开启 Quic/h3 协议(iOS 微信目前使用 gQUIC-Q43;Android 微信在 v8.0.54 前使用 gQUIC-Q43,v8.0.54 开始使用 IETF QUIC,即 h3 协议;PC微信使用 IETF QUIC,即 h3 协议) */ + enableQuic?: boolean + /** 接口调用失败的回调函数 */ + fail?: DownloadFileFailCallback + /** 需要基础库: `1.8.0` + * + * 指定文件下载后存储的路径 (本地路径) */ + filePath?: string + /** HTTP 请求的 Header,Header 中不能设置 Referer */ + header?: IAnyObject + /** 接口调用成功的回调函数 */ + success?: DownloadFileSuccessCallback + /** 需要基础库: `2.10.0` + * + * 超时时间,单位为毫秒,默认值为 60000 即一分钟。 */ + timeout?: number + /** 需要基础库: `3.4.1` + * + * 使用高性能模式,暂仅支持 Android,默认关闭。该模式下有更优的网络性能表现。 */ + useHighPerformanceMode?: boolean + } + interface DownloadFileSuccessCallbackResult { + /** 用户文件路径 (本地路径)。传入 filePath 时会返回,跟传入的 filePath 一致 */ + filePath: string + /** 需要基础库: `2.10.4` + * + * 网络请求过程中一些调试信息,[查看详细说明](https://developers.weixin.qq.com/miniprogram/dev/framework/performance/network.html) */ + profile: RequestProfile + /** 开发者服务器返回的 HTTP 状态码 */ + statusCode: number + /** 临时文件路径 (本地路径)。没传入 filePath 指定文件存储路径时会返回,下载后的文件会存储到一个临时文件 */ + tempFilePath: string + errMsg: string + } + interface DownloadTaskOnHeadersReceivedListenerResult { + /** 开发者服务器返回的 HTTP Response Header */ + header: IAnyObject + } + interface DownloadTaskOnProgressUpdateListenerResult { + /** 下载进度百分比 */ + progress: number + /** 预期需要下载的数据总长度,单位 Bytes */ + totalBytesExpectedToWrite: number + /** 已经下载的数据长度,单位 Bytes */ + totalBytesWritten: number + } + interface DraggableSheetContextScrollToOption { + /** 是否启用滚动动画 */ + animated?: boolean + /** 滚动动画时长(ms) */ + duration?: number + /** 缓动函数 */ + easingFunction?: string + /** 绝对目标位置 */ + pixels?: number + /** 相对目标位置 */ + size?: number + } + interface EditImageOption { + /** 图片路径,图片的路径,支持本地路径、代码包路径 */ + src: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: EditImageCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: EditImageFailCallback + /** 接口调用成功的回调函数 */ + success?: EditImageSuccessCallback + } + interface EnableAlertBeforeUnloadOption { + /** 询问对话框内容 */ + message: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: EnableAlertBeforeUnloadCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: EnableAlertBeforeUnloadFailCallback + /** 接口调用成功的回调函数 */ + success?: EnableAlertBeforeUnloadSuccessCallback + } + /** 文件读取结果。res.entries 是一个对象,key是文件路径,value是一个对象 FileItem ,表示该文件的读取结果。每个 FileItem 包含 data (文件内容) 和 errMsg (错误信息) 属性。 */ + interface EntriesResult { + /** 文件路径 */ + [path: string]: ZipFileItem + } + /** 要读取的压缩包内的文件列表(当传入"all" 时表示读取压缩包内所有文件) */ + interface EntryItem { + /** 压缩包内文件路径 */ + path: string + /** 指定读取文件的字符编码,如果不传 encoding,则以 ArrayBuffer 格式读取文件的二进制内容 + * + * 可选值: + * - 'ascii': ; + * - 'base64': ; + * - 'binary': ; + * - 'hex': ; + * - 'ucs2': 以小端序读取; + * - 'ucs-2': 以小端序读取; + * - 'utf16le': 以小端序读取; + * - 'utf-16le': 以小端序读取; + * - 'utf-8': ; + * - 'utf8': ; + * - 'latin1': ; */ + encoding?: + | 'ascii' + | 'base64' + | 'binary' + | 'hex' + | 'ucs2' + | 'ucs-2' + | 'utf16le' + | 'utf-16le' + | 'utf-8' + | 'utf8' + | 'latin1' + /** 指定文件的长度,如果不指定,则读到文件末尾。有效范围:[1, fileLength]。单位:byte */ + length?: number + /** 从文件指定位置开始读,如果不指定,则从文件头开始读。读取的范围应该是左闭右开区间 [position, position+length)。有效范围:[0, fileLength - 1]。单位:byte */ + position?: number + } + /** 要擦除的线段数组。详见 [polyline 属性](https://developers.weixin.qq.com/miniprogram/dev/component/map.html#polyline)。 */ + interface EraseLineOptions { + /** 线段的 id。 */ + id: number + /** 指定线段的某一段,线段起点 index 为 0 */ + index: number + /** 指定线段某一段中的点 */ + point: MapPostion + /** 为 true 时擦除,false 时置灰 */ + clear?: boolean + } + interface EraseLinesOption { + /** 要擦除的线段数组。详见 [polyline 属性](https://developers.weixin.qq.com/miniprogram/dev/component/map.html#polyline)。 */ + lines: EraseLineOptions[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: EraseLinesCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: EraseLinesFailCallback + /** 接口调用成功的回调函数 */ + success?: EraseLinesSuccessCallback + } + /** 错误 */ + interface Error { + /** 错误信息,包含堆栈 */ + message: string + } + /** 需要基础库: `3.4.0` + * + * 网络请求过程中的一些异常信息(例如:TCPSocket.connect 传了 enableHttpDNS: true,但最终未使用 HttpDNS 时,exception 就会说明未使用 HttpDNS 的原因) */ + interface Exception { + /** 需要基础库: `3.4.0` + * + * 异常信息 */ + reasons: TCPExceptionReason[] + } + /** 本次请求底层失败信息,所有失败信息均符合Errno错误码 */ + interface ExceptionReason { + /** 错误原因 */ + errMsg: string + /** 错误码 */ + errno: string + } + interface ExecuteVisualLayerCommandOption { + /** 图层指令 */ + command: string + /** 可视化图层id */ + layerId: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ExecuteVisualLayerCommandCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ExecuteVisualLayerCommandFailCallback + /** 接口调用成功的回调函数 */ + success?: ExecuteVisualLayerCommandSuccessCallback + } + interface ExecuteVisualLayerCommandSuccessCallbackResult { + /** SDK 返回的 JSON 数据 */ + data: string + /** 调用结果 */ + errMsg: string + } + interface ExitCastingOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ExitCastingCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ExitCastingFailCallback + /** 接口调用成功的回调函数 */ + success?: ExitCastingSuccessCallback + } + interface ExitFullScreenOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ExitFullScreenCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ExitFullScreenFailCallback + /** 接口调用成功的回调函数 */ + success?: ExitFullScreenSuccessCallback + } + interface ExitMiniProgramOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ExitMiniProgramCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ExitMiniProgramFailCallback + /** 接口调用成功的回调函数 */ + success?: ExitMiniProgramSuccessCallback + } + interface ExitPictureInPictureOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ExitPictureInPictureCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ExitPictureInPictureFailCallback + /** 接口调用成功的回调函数 */ + success?: ExitPictureInPictureSuccessCallback + } + interface ExitVoIPChatOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ExitVoIPChatCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ExitVoIPChatFailCallback + /** 接口调用成功的回调函数 */ + success?: ExitVoIPChatSuccessCallback + } + /** 客服信息 */ + interface ExtInfoOption { + /** 客服链接 */ + url: string + } + /** 额外的缓存处理 */ + interface ExtraOption { + /** 需要缓存的 wx api 接口,不传则表示支持缓存的接口全都做缓存处理。返回的如果是缓存数据,开发者可通过 fromCache 标记区分 + * + * 可选值: + * - 'wx.login': ; + * - 'wx.checkSession': ; + * - 'wx.getSetting': ; */ + apiList?: Array<'wx.login' | 'wx.checkSession' | 'wx.getSetting'> + } + interface ExtractDataSourceOption { + /** 视频源地址,只支持本地文件 */ + source: string + } + /** 人脸角度信息,取值范围 [-1, 1],数值越接近 0 表示越正对摄像头 */ + interface FaceAngel { + /** 仰俯角(点头) */ + pitch: number + /** 翻滚角(左右倾) */ + roll: number + /** 偏航角(摇头) */ + yaw: number + } + /** 人脸置信度,取值范围 [0, 1],数值越大置信度越高(遮挡越少) */ + interface FaceConf { + /** 整体可信度 */ + global: number + /** 左眼可信度 */ + leftEye: number + /** 嘴巴可信度 */ + mouth: number + /** 鼻子可信度 */ + nose: number + /** 右眼可信度 */ + rightEye: number + } + interface FaceDetectOption { + /** 图像像素点数据,每四项表示一个像素点的 RGBA */ + frameBuffer: ArrayBuffer + /** 图像高度 */ + height: number + /** 图像宽度 */ + width: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: FaceDetectCompleteCallback + /** 是否返回当前图像的人脸角度信息 */ + enableAngle?: boolean + /** 是否返回当前图像的人脸的置信度(可表示器官遮挡情况) */ + enableConf?: boolean + /** 是否返回多张人脸的信息 */ + enableMultiFace?: boolean + /** 是否返回当前图像的人脸(106 个点) */ + enablePoint?: boolean + /** 接口调用失败的回调函数 */ + fail?: FaceDetectFailCallback + /** 接口调用成功的回调函数 */ + success?: FaceDetectSuccessCallback + } + interface FaceDetectSuccessCallbackResult { + /** 人脸角度信息,取值范围 [-1, 1],数值越接近 0 表示越正对摄像头 */ + angleArray: FaceAngel + /** 人脸置信度,取值范围 [0, 1],数值越大置信度越高(遮挡越少) */ + confArray: FaceConf + /** 脸部方框数值,对象包含 height, width, originX, originY 四个属性 (origin 为方框左上角坐标) */ + detectRect: IAnyObject + /** 多人模式(enableMultiFace)下的人脸信息,每个对象包含上述其它属性 */ + faceInfo: IAnyObject[] + /** 标记人脸轮廓的 106 个点位置数组,数组每个对象包含 x 和 y */ + pointArray: IAnyObject[] + /** 脸部中心点横坐标,检测不到人脸则为 -1 */ + x: number + /** 脸部中心点纵坐标,检测不到人脸则为 -1 */ + y: number + errMsg: string + } + /** 需要基础库: `2.25.0` + * + * 人脸检测配置。用法详情[指南文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/face.html)。安卓微信8.0.25开始支持,iOS微信8.0.24开始支持。 */ + interface FaceTrack { + /** 需要基础库: `2.25.0` + * + * 人脸检测模式 + * + * 可选值: + * - 1: 通过摄像头实时检测; + * - 2: 静态图片检测; */ + mode: 1 | 2 + } + interface Fields { + /** 需要基础库: `2.1.0` + * + * 指定样式名列表,返回节点对应样式名的当前值 */ + computedStyle?: string[] + /** 需要基础库: `2.4.2` + * + * 是否返回节点对应的 Context 对象 */ + context?: boolean + /** 是否返回节点 dataset */ + dataset?: boolean + /** 是否返回节点 id */ + id?: boolean + /** 是否返回节点 mark */ + mark?: boolean + /** 需要基础库: `2.7.0` + * + * 是否返回节点对应的 Node 实例 */ + node?: boolean + /** 指定属性名列表,返回节点对应属性名的当前属性值(只能获得组件文档中标注的常规属性值,id class style 和事件绑定的属性值不可获取) */ + properties?: string[] + /** 是否返回节点布局位置(`left` `right` `top` `bottom`) */ + rect?: boolean + /** 需要基础库: `3.3.0` + * + * 是否返回节点对应的 Ref 对象,仅 `Skyline` 下支持 */ + ref?: boolean + /** 否 是否返回节点的 `scrollLeft` `scrollTop`,节点必须是 `scroll-view` 或者 `viewport` */ + scrollOffset?: boolean + /** 是否返回节点尺寸(`width` `height`) */ + size?: boolean + } + /** 文件数组 */ + interface FileItem { + /** 文件保存时的时间戳,从1970/01/01 08:00:00 到当前时间的秒数 */ + createTime: number + /** 文件路径 (本地路径) */ + filePath: string + /** 本地文件大小,以字节为单位 */ + size: number + } + /** 每个 FileStats 对象包含 path 和 Stats */ + interface FileStats { + /** 文件/目录路径 */ + path: string + /** [Stats](https://developers.weixin.qq.com/miniprogram/dev/api/file/Stats.html) + * + * Stats 对象,即描述文件状态的对象 */ + stats: Stats + } + interface FileSystemManagerCloseOption { + /** 需要被关闭的文件描述符。fd 通过 [FileSystemManager.open](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.open.html) 或 [FileSystemManager.openSync](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.openSync.html) 接口获得 */ + fd: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: FileSystemManagerCloseCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: FileSystemManagerCloseFailCallback + /** 接口调用成功的回调函数 */ + success?: FileSystemManagerCloseSuccessCallback + } + /** 打开的文件信息数组,只有从聊天素材场景打开(scene为1173)才会携带该参数 */ + interface ForwardMaterials { + /** 文件名 */ + name: string + /** 文件路径(如果是webview则是url) */ + path: string + /** 文件大小 */ + size: number + /** 文件的mimetype类型 */ + type: string + } + /** 视频帧数据,若取不到则返回 null。当缓冲区为空的时候可能暂停取不到数据。 */ + interface FrameDataOptions { + /** 帧数据 */ + data: ArrayBuffer + /** 帧数据高度 */ + height: number + /** 帧原始 dts */ + pkDts: number + /** 帧原始 pts */ + pkPts: number + /** 帧数据宽度 */ + width: number + } + interface FromScreenLocationOption { + /** x 坐标值 */ + x: number + /** y 坐标值 */ + y: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: FromScreenLocationCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: FromScreenLocationFailCallback + /** 接口调用成功的回调函数 */ + success?: FromScreenLocationSuccessCallback + } + interface FstatOption { + /** 文件描述符。fd 通过 [FileSystemManager.open](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.open.html) 或 [FileSystemManager.openSync](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.openSync.html) 接口获得 */ + fd: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: FstatCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: FstatFailCallback + /** 接口调用成功的回调函数 */ + success?: FstatSuccessCallback + } + interface FstatSuccessCallbackResult { + /** [Stats](https://developers.weixin.qq.com/miniprogram/dev/api/file/Stats.html) + * + * Stats 对象,包含了文件的状态信息 */ + stats: Stats + errMsg: string + } + interface FstatSyncOption { + /** 文件描述符。fd 通过 [FileSystemManager.open](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.open.html) 或 [FileSystemManager.openSync](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.openSync.html) 接口获得 */ + fd: string + } + interface FtruncateOption { + /** 文件描述符。fd 通过 [FileSystemManager.open](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.open.html) 或 [FileSystemManager.openSync](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.openSync.html) 接口获得 */ + fd: string + /** 截断位置,默认0。如果 length 小于文件长度(单位:字节),则只有前面 length 个字节会保留在文件中,其余内容会被删除;如果 length 大于文件长度,则会对其进行扩展,并且扩展部分将填充空字节('\0') */ + length: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: FtruncateCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: FtruncateFailCallback + /** 接口调用成功的回调函数 */ + success?: FtruncateSuccessCallback + } + interface FtruncateSyncOption { + /** 文件描述符。fd 通过 [FileSystemManager.open](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.open.html) 或 [FileSystemManager.openSync](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.openSync.html) 接口获得 */ + fd: string + /** 截断位置,默认0。如果 length 小于文件长度(单位:字节),则只有前面 length 个字节会保留在文件中,其余内容会被删除;如果 length 大于文件长度,则会对其进行扩展,并且扩展部分将填充空字节('\0') */ + length: number + } + interface GeneralCallbackResult { + /** 错误信息 */ + errMsg: string + } + interface GetAtqaOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetAtqaCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetAtqaFailCallback + /** 接口调用成功的回调函数 */ + success?: GetAtqaSuccessCallback + } + interface GetAtqaSuccessCallbackResult { + /** 返回 ATQA/SENS_RES 数据 */ + atqa: ArrayBuffer + errMsg: string + } + interface GetAvailableAudioSourcesOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetAvailableAudioSourcesCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetAvailableAudioSourcesFailCallback + /** 接口调用成功的回调函数 */ + success?: GetAvailableAudioSourcesSuccessCallback + } + interface GetAvailableAudioSourcesSuccessCallbackResult { + /** 支持的音频输入源列表,可在 [RecorderManager.start()](https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/RecorderManager.start.html) 接口中使用。返回值定义参考 https://developer.android.com/reference/kotlin/android/media/MediaRecorder.AudioSource + * + * 可选值: + * - 'auto': 自动设置,默认使用手机麦克风,插上耳麦后自动切换使用耳机麦克风,所有平台适用; + * - 'buildInMic': 手机麦克风,仅限 iOS; + * - 'headsetMic': 耳机麦克风,仅限 iOS; + * - 'mic': 麦克风(没插耳麦时是手机麦克风,插耳麦时是耳机麦克风),仅限 Android; + * - 'camcorder': 同 mic,适用于录制音视频内容,仅限 Android; + * - 'voice_communication': 同 mic,适用于实时沟通,仅限 Android; + * - 'voice_recognition': 同 mic,适用于语音识别,仅限 Android; */ + audioSources: Array< + | 'auto' + | 'buildInMic' + | 'headsetMic' + | 'mic' + | 'camcorder' + | 'voice_communication' + | 'voice_recognition' + > + errMsg: string + } + interface GetBLEDeviceCharacteristicsOption { + /** 蓝牙设备 id。需要已经通过 [wx.createBLEConnection](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.createBLEConnection.html) 建立连接 */ + deviceId: string + /** 蓝牙服务 UUID。需要先调用 [wx.getBLEDeviceServices](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEDeviceServices.html) 获取 */ + serviceId: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetBLEDeviceCharacteristicsCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetBLEDeviceCharacteristicsFailCallback + /** 接口调用成功的回调函数 */ + success?: GetBLEDeviceCharacteristicsSuccessCallback + } + interface GetBLEDeviceCharacteristicsSuccessCallbackResult { + /** 设备特征列表 */ + characteristics: BLECharacteristic[] + errMsg: string + } + interface GetBLEDeviceRSSIOption { + /** 蓝牙设备 id */ + deviceId: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetBLEDeviceRSSICompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetBLEDeviceRSSIFailCallback + /** 接口调用成功的回调函数 */ + success?: GetBLEDeviceRSSISuccessCallback + } + interface GetBLEDeviceRSSISuccessCallbackResult { + /** 信号强度,单位 dBm */ + RSSI: number + errMsg: string + } + interface GetBLEDeviceServicesOption { + /** 蓝牙设备 id。需要已经通过 [wx.createBLEConnection](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.createBLEConnection.html) 建立连接 */ + deviceId: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetBLEDeviceServicesCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetBLEDeviceServicesFailCallback + /** 接口调用成功的回调函数 */ + success?: GetBLEDeviceServicesSuccessCallback + } + interface GetBLEDeviceServicesSuccessCallbackResult { + /** 设备服务列表 */ + services: BLEService[] + errMsg: string + } + interface GetBLEMTUOption { + /** 蓝牙设备 id */ + deviceId: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetBLEMTUCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetBLEMTUFailCallback + /** 接口调用成功的回调函数 */ + success?: GetBLEMTUSuccessCallback + /** 写模式 (iOS 特有参数) + * + * 可选值: + * - 'write': 有回复写; + * - 'writeNoResponse': 无回复写; */ + writeType?: 'write' | 'writeNoResponse' + } + interface GetBLEMTUSuccessCallbackResult { + /** 最大传输单元 */ + mtu: number + errMsg: string + } + interface GetBackgroundAudioPlayerStateOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetBackgroundAudioPlayerStateCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetBackgroundAudioPlayerStateFailCallback + /** 接口调用成功的回调函数 */ + success?: GetBackgroundAudioPlayerStateSuccessCallback + } + interface GetBackgroundAudioPlayerStateSuccessCallbackResult { + /** 选定音频的播放位置(单位:s),只有在音乐播放中时返回 */ + currentPosition: number + /** 歌曲数据链接,只有在音乐播放中时返回 */ + dataUrl: string + /** 音频的下载进度百分比,只有在音乐播放中时返回 */ + downloadPercent: number + /** 选定音频的长度(单位:s),只有在音乐播放中时返回 */ + duration: number + /** 播放状态 + * + * 可选值: + * - 0: 暂停中; + * - 1: 播放中; + * - 2: 没有音乐播放; */ + status: 0 | 1 | 2 + errMsg: string + } + interface GetBackgroundFetchDataOption { + /** 缓存数据类别,取值为 periodic 或 pre */ + fetchType: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetBackgroundFetchDataCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetBackgroundFetchDataFailCallback + /** 接口调用成功的回调函数 */ + success?: GetBackgroundFetchDataSuccessCallback + } + interface GetBackgroundFetchDataSuccessCallbackResult { + /** 缓存数据 */ + fetchedData: string + /** 小程序页面路径 */ + path: string + /** 传给页面的 query 参数 */ + query: string + /** 进入小程序的场景值 */ + scene: number + /** 客户端拿到缓存数据的时间戳 ms。(iOS 时间戳存在异常,8.0.27 修复) */ + timeStamp: number + errMsg: string + } + interface GetBackgroundFetchTokenOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetBackgroundFetchTokenCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetBackgroundFetchTokenFailCallback + /** 接口调用成功的回调函数 */ + success?: GetBackgroundFetchTokenSuccessCallback + } + interface GetBackgroundFetchTokenSuccessCallbackResult { + /** 接口调用结果 */ + errMsg: string + /** 自定义的登录态 */ + token: string + } + interface GetBatteryInfoOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetBatteryInfoCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetBatteryInfoFailCallback + /** 接口调用成功的回调函数 */ + success?: GetBatteryInfoSuccessCallback + } + interface GetBatteryInfoSuccessCallbackResult { + /** 是否正在充电中 */ + isCharging: boolean + /** 需要基础库: `3.5.0` + * + * 是否处于省电模式 */ + isLowPowerModeEnabled: boolean + /** 设备电量,范围 1 - 100 */ + level: number + errMsg: string + } + interface GetBatteryInfoSyncResult { + /** 是否正在充电中 */ + isCharging: boolean + /** 需要基础库: `3.5.0` + * + * 是否处于省电模式 */ + isLowPowerModeEnabled: boolean + /** 设备电量,范围 1 - 100 */ + level: number + } + interface GetBeaconsOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetBeaconsCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetBeaconsFailCallback + /** 接口调用成功的回调函数 */ + success?: GetBeaconsSuccessCallback + } + interface GetBeaconsSuccessCallbackResult { + /** Beacon 设备列表 */ + beacons: BeaconInfo[] + errMsg: string + } + interface GetBluetoothAdapterStateOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetBluetoothAdapterStateCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetBluetoothAdapterStateFailCallback + /** 接口调用成功的回调函数 */ + success?: GetBluetoothAdapterStateSuccessCallback + } + interface GetBluetoothAdapterStateSuccessCallbackResult { + /** 蓝牙适配器是否可用 */ + available: boolean + /** 是否正在搜索设备 */ + discovering: boolean + errMsg: string + } + interface GetBluetoothDevicesOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetBluetoothDevicesCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetBluetoothDevicesFailCallback + /** 接口调用成功的回调函数 */ + success?: GetBluetoothDevicesSuccessCallback + } + interface GetBluetoothDevicesSuccessCallbackResult { + /** UUID 对应的已连接设备列表 */ + devices: BlueToothDevice[] + errMsg: string + } + interface GetBoundsOption { + /** 选区开始位置 */ + index: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetBoundsCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetBoundsFailCallback + /** 选区长度 */ + length?: number + /** 接口调用成功的回调函数 */ + success?: GetBoundsSuccessCallback + } + interface GetBoundsSuccessCallbackResult { + /** 选区相对于视口的大小和位置 */ + bounds: IAnyObject + errMsg: string + } + interface GetCenterLocationOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetCenterLocationCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetCenterLocationFailCallback + /** 图标路径,支持网络路径、本地路径、代码包路径 */ + iconPath?: string + /** 接口调用成功的回调函数 */ + success?: GetCenterLocationSuccessCallback + } + interface GetCenterLocationSuccessCallbackResult { + /** 纬度 */ + latitude: number + /** 经度 */ + longitude: number + errMsg: string + } + interface GetChannelsLiveInfoOption { + /** 视频号 id,以“sph”开头的id,可在视频号助手获取 */ + finderUserName: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetChannelsLiveInfoCompleteCallback + /** 需要基础库: `2.29.0` + * + * 结束时间,筛选指定时间段的直播。若上传了startTime,未上传endTime,则endTime默认取当前时间 */ + endTime?: number + /** 接口调用失败的回调函数 */ + fail?: GetChannelsLiveInfoFailCallback + /** 需要基础库: `2.29.0` + * + * 起始时间,筛选指定时间段的直播。若上传了endTime,未上传startTime,则startTime默认为0 */ + startTime?: number + /** 接口调用成功的回调函数 */ + success?: GetChannelsLiveInfoSuccessCallback + } + interface GetChannelsLiveInfoSuccessCallbackResult { + /** 直播主题 */ + description: string + /** 直播 feedId */ + feedId: string + /** 视频号头像 */ + headUrl: string + /** 视频号昵称 */ + nickname: string + /** 直播 nonceId */ + nonceId: string + /** 需要基础库: `2.29.0` + * + * 除最近的一条直播外,其他的直播列表(注意:每次最多返回按时间戳增序排列的15个直播信息,其中时间最近的那个直播会在接口其他的返回参数中展示,其余的直播会在该字段中展示)。 */ + otherInfos: any[] + /** 需要基础库: `2.29.0` + * + * 直播回放状态 + * + * 可选值: + * - 0: 未生成; + * - 1: 已生成; + * - 3: 生成中; + * - 6: 已过期; */ + replayStatus: 0 | 1 | 3 | 6 + /** 直播状态 + * + * 可选值: + * - 1: 直播状态不存在(针对未开过直播的主播); + * - 2: 直播中; + * - 3: 直播已结束; + * - 4: 直播准备中(未开播); */ + status: 1 | 2 | 3 | 4 + errMsg: string + } + interface GetChannelsLiveNoticeInfoOption { + /** 视频号 id,以“sph”开头的id,可在视频号助手获取 */ + finderUserName: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetChannelsLiveNoticeInfoCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetChannelsLiveNoticeInfoFailCallback + /** 接口调用成功的回调函数 */ + success?: GetChannelsLiveNoticeInfoSuccessCallback + } + interface GetChannelsLiveNoticeInfoSuccessCallbackResult { + /** 直播封面 */ + headUrl: string + /** 视频号昵称 */ + nickname: string + /** 预告 id */ + noticeId: string + /** 需要基础库: `2.24.6` + * + * 除最近的一条预告信息外,其他的预告信息列表(注意:每次最多返回按时间戳增序排列的15个预告信息,其中时间最近的那个预告信息会在接口其他的返回参数中展示,其余的预告信息会在该字段中展示)。 */ + otherInfos: any[] + /** 是否可预约 */ + reservable: boolean + /** 开始时间 */ + startTime: string + /** 预告状态:0可用 1取消 2已用 */ + status: number + errMsg: string + } + interface GetChannelsShareKeyOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetChannelsShareKeyCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetChannelsShareKeyFailCallback + /** 接口调用成功的回调函数 */ + success?: GetChannelsShareKeySuccessCallback + } + interface GetChannelsShareKeySuccessCallbackResult { + /** 推广员 */ + promoter: PromoterResult + /** 分享者 openid */ + sharerOpenId: string + errMsg: string + } + interface GetChatToolInfoOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetChatToolInfoCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetChatToolInfoFailCallback + /** 接口调用成功的回调函数 */ + success?: GetChatToolInfoSuccessCallback + } + interface GetChatToolInfoSuccessCallbackResult { + /** 敏感数据对应的云 ID,开通[云开发](https://developers.weixin.qq.com/miniprogram/dev/wxcloudservice/wxcloud/basis/getting-started.html)的小程序才会返回,可通过云调用直接获取开放数据,详细见[云调用直接获取开放数据](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html#method-cloud) */ + cloudID: string + /** 包括敏感数据在内的完整转发信息的加密数据,详细见[加密数据解密算法](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html) */ + encryptedData: string + /** 错误信息 */ + errMsg: string + /** 加密算法的初始向量,详细见[加密数据解密算法](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html) */ + iv: string + } + interface GetClipboardDataOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetClipboardDataCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetClipboardDataFailCallback + /** 接口调用成功的回调函数 */ + success?: GetClipboardDataSuccessCallback + } + interface GetClipboardDataSuccessCallbackOption { + /** 剪贴板的内容 */ + data: string + errMsg: string + } + interface GetCommonConfigOption { + /** 0:通用配置模式 1:实验模式, 参数与返回结果的使用等效于接口[wx.getExptInfoSync](https://developers.weixin.qq.com/miniprogram/dev/api/data-analysis/wx.getExptInfoSync.html) */ + mode: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetCommonConfigCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetCommonConfigFailCallback + /** 需要获取的数据指标的对象数组,每个string的格式约定:配置类型_分表key */ + keys?: string[] + /** 接口调用成功的回调函数 */ + success?: GetCommonConfigSuccessCallback + } + interface GetCommonConfigSuccessCallbackResult { + /** 根据conf_type来确定conf内容,conf_type为1时conf是一个json数组, 类似"[{xxx},{xxx}]", 每一项对应表类型每一行配置内容, 其中conf_type为2时conf是一个json对象,类似"{xxxx}" */ + conf: string + /** 配置类型, 1-表类型 2-kv类型 */ + conf_type: number + /** 错误码 */ + errcode: number + /** 错误信息 */ + errmsg: string + /** 过期时间,单位秒. 0表示当次有效 */ + expire_sec: number + errMsg: string + } + interface GetConnectedBluetoothDevicesOption { + /** 蓝牙设备主服务的 UUID 列表(支持 16/32/128 位 UUID) */ + services: string[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetConnectedBluetoothDevicesCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetConnectedBluetoothDevicesFailCallback + /** 接口调用成功的回调函数 */ + success?: GetConnectedBluetoothDevicesSuccessCallback + } + interface GetConnectedBluetoothDevicesSuccessCallbackResult { + /** 搜索到的设备列表 */ + devices: BluetoothDeviceInfo[] + errMsg: string + } + interface GetConnectedWifiOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetConnectedWifiCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetConnectedWifiFailCallback + /** 需要基础库: `2.22.0` + * + * 是否需要返回部分 Wi-Fi 信息 */ + partialInfo?: boolean + /** 接口调用成功的回调函数 */ + success?: GetConnectedWifiSuccessCallback + } + interface GetConnectedWifiSuccessCallbackResult { + /** [WifiInfo](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/WifiInfo.html) + * + * Wi-Fi 信息 */ + wifi: WifiInfo + errMsg: string + } + interface GetContentsOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetContentsCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetContentsFailCallback + /** 接口调用成功的回调函数 */ + success?: GetContentsSuccessCallback + } + interface GetContentsSuccessCallbackResult { + /** 表示内容的delta对象 */ + delta: IAnyObject + /** 带标签的HTML内容 */ + html: string + /** 纯文本内容 */ + text: string + errMsg: string + } + interface GetDeviceBenchmarkInfoOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetDeviceBenchmarkInfoCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetDeviceBenchmarkInfoFailCallback + /** 接口调用成功的回调函数 */ + success?: GetDeviceBenchmarkInfoSuccessCallback + } + interface GetDeviceBenchmarkInfoSuccessCallbackResult { + /** 需要基础库: `3.4.5` + * + * 设备性能等级。-1(性能未知),>=1(设备性能值,该值越高,设备性能越好,目前最高不超过50)
注意:设备的benchmarkLevel值不会随着时间的推移而变化 */ + benchmarkLevel: number + /** 需要基础库: `3.4.5` + * + * 设备机型档位。0(档位未知),1(高档机),2(中档机),3(低档机)
注意:设备的机型档位会随着时间的推移而变化,因此在使用时请谨慎对待;若业务逻辑依赖于机型档位,但担心受到机型档位变化的影响,请参考[设备档位映射文档](https://developers.weixin.qq.com/minigame/dev/guide/performance/perf-benchmarkLevel.html)自行判断机型档位 */ + modelLevel: number + errMsg: string + } + interface GetDeviceVoIPListOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetDeviceVoIPListCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetDeviceVoIPListFailCallback + /** 接口调用成功的回调函数 */ + success?: GetDeviceVoIPListSuccessCallback + } + interface GetDeviceVoIPListSuccessCallbackResult { + list: DeviceVoIPInfo[] + errMsg: string + } + interface GetExtConfigOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetExtConfigCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetExtConfigFailCallback + /** 接口调用成功的回调函数 */ + success?: GetExtConfigSuccessCallback + } + interface GetExtConfigSuccessCallbackResult { + /** 第三方平台自定义的数据 */ + extConfig: IAnyObject + errMsg: string + } + interface GetFileInfoOption { + /** 要读取的文件路径 (本地路径) */ + filePath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetFileInfoCompleteCallback + /** 计算文件摘要的算法 + * + * 可选值: + * - 'md5': md5 算法; + * - 'sha1': sha1 算法; + * - 'sha256': sha256 算法; */ + digestAlgorithm?: 'md5' | 'sha1' | 'sha256' + /** 接口调用失败的回调函数 */ + fail?: GetFileInfoFailCallback + /** 接口调用成功的回调函数 */ + success?: GetFileInfoSuccessCallback + } + interface GetFileInfoSuccessCallbackResult { + /** 按照传入的 digestAlgorithm 计算得出的的文件摘要 */ + digest: string + /** 文件大小,以字节为单位 */ + size: number + errMsg: string + } + interface GetFuzzyLocationOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetFuzzyLocationCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetFuzzyLocationFailCallback + /** 接口调用成功的回调函数 */ + success?: GetFuzzyLocationSuccessCallback + /** 返回的坐标类型 + * + * 可选值: + * - 'wgs84': 返回 gps 坐标; + * - 'gcj02': 返回 gcj02 坐标,可用于 wx.openLocation; */ + type?: 'wgs84' | 'gcj02' + } + interface GetFuzzyLocationSuccessCallbackResult { + /** 纬度,范围为 -90~90,负数表示南纬 */ + latitude: number + /** 经度,范围为 -180~180,负数表示西经 */ + longitude: number + errMsg: string + } + interface GetGroupEnterInfoOption { + /** 需要基础库: `3.7.8` + * + * 开启后单聊下返回 open_single_roomid */ + allowSingleChat?: boolean + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetGroupEnterInfoCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetGroupEnterInfoFailCallback + /** 需要基础库: `3.7.8` + * + * 开启后返回用户在群(含单聊)下的 group_openid */ + needGroupOpenID?: boolean + /** 接口调用成功的回调函数 */ + success?: GetGroupEnterInfoSuccessCallback + } + interface GetGroupEnterInfoSuccessCallbackResult { + /** 需要基础库: `2.7.0` + * + * 敏感数据对应的云 ID,开通[云开发](https://developers.weixin.qq.com/miniprogram/dev/wxcloudservice/wxcloud/basis/getting-started.html)的小程序才会返回,可通过云调用直接获取开放数据,详细见[云调用直接获取开放数据](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html#method-cloud) */ + cloudID: string + /** 包括敏感数据在内的完整转发信息的加密数据,详细见[加密数据解密算法](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html) */ + encryptedData: string + /** 错误信息 */ + errMsg: string + /** 加密算法的初始向量,详细见[加密数据解密算法](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html) */ + iv: string + } + interface GetHCEStateOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetHCEStateCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetHCEStateFailCallback + /** 接口调用成功的回调函数 */ + success?: GetHCEStateSuccessCallback + } + interface GetHistoricalBytesOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetHistoricalBytesCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetHistoricalBytesFailCallback + /** 接口调用成功的回调函数 */ + success?: GetHistoricalBytesSuccessCallback + } + interface GetHistoricalBytesSuccessCallbackResult { + /** 返回历史二进制数据 */ + histBytes: ArrayBuffer + errMsg: string + } + interface GetImageInfoOption { + /** 图片的路径,支持网络路径、本地路径、代码包路径 */ + src: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetImageInfoCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetImageInfoFailCallback + /** 接口调用成功的回调函数 */ + success?: GetImageInfoSuccessCallback + } + interface GetImageInfoSuccessCallbackResult { + /** 图片原始高度,单位px。不考虑旋转。 */ + height: number + /** 需要基础库: `1.9.90` + * + * [拍照时设备方向](http://sylvana.net/jpegcrop/exif_orientation.html) + * + * 可选值: + * - 'up': 默认方向(手机横持拍照),对应 Exif 中的 1。或无 orientation 信息。; + * - 'up-mirrored': 同 up,但镜像翻转,对应 Exif 中的 2; + * - 'down': 旋转180度,对应 Exif 中的 3; + * - 'down-mirrored': 同 down,但镜像翻转,对应 Exif 中的 4; + * - 'left-mirrored': 同 left,但镜像翻转,对应 Exif 中的 5; + * - 'right': 顺时针旋转90度,对应 Exif 中的 6; + * - 'right-mirrored': 同 right,但镜像翻转,对应 Exif 中的 7; + * - 'left': 逆时针旋转90度,对应 Exif 中的 8; */ + orientation: + | 'up' + | 'up-mirrored' + | 'down' + | 'down-mirrored' + | 'left-mirrored' + | 'right' + | 'right-mirrored' + | 'left' + /** 图片的本地路径 */ + path: string + /** 需要基础库: `1.9.90` + * + * 图片格式 + * + * 可选值: + * - 'unknown': 未知格式; + * - 'jpeg': jpeg压缩格式; + * - 'png': png压缩格式; + * - 'gif': gif压缩格式; + * - 'tiff': tiff压缩格式; */ + type: 'unknown' | 'jpeg' | 'png' | 'gif' | 'tiff' + /** 图片原始宽度,单位px。不考虑旋转。 */ + width: number + errMsg: string + } + interface GetInferenceEnvInfoOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetInferenceEnvInfoCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetInferenceEnvInfoFailCallback + /** 接口调用成功的回调函数 */ + success?: GetInferenceEnvInfoSuccessCallback + } + interface GetInferenceEnvInfoSuccessCallbackResult { + /** AI推理引擎版本 */ + ver: string + errMsg: string + } + interface GetLatestUserKeyOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetLatestUserKeyCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetLatestUserKeyFailCallback + /** 接口调用成功的回调函数 */ + success?: GetLatestUserKeySuccessCallback + } + interface GetLatestUserKeySuccessCallbackResult { + /** 用户加密密钥 */ + encryptKey: string + /** 密钥过期时间 */ + expireTime: number + /** 密钥初始向量 */ + iv: string + /** 密钥版本 */ + version: number + errMsg: string + } + interface GetLocalIPAddressOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetLocalIPAddressCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetLocalIPAddressFailCallback + /** 接口调用成功的回调函数 */ + success?: GetLocalIPAddressSuccessCallback + } + interface GetLocalIPAddressSuccessCallbackResult { + /** 错误信息 */ + errMsg: string + /** 本机局域网IP地址 */ + localip: string + /** 本机局域网子网掩码,基础库 2.24.0 开始支持 */ + netmask: string + } + interface GetLocationOption { + /** 需要基础库: `1.6.0` + * + * 传入 true 会返回高度信息,由于获取高度需要较高精确度,会减慢接口返回速度 */ + altitude?: boolean + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetLocationCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetLocationFailCallback + /** 需要基础库: `2.9.0` + * + * 高精度定位超时时间(ms),指定时间内返回最高精度,该值3000ms以上高精度定位才有效果 */ + highAccuracyExpireTime?: number + /** 需要基础库: `2.9.0` + * + * 开启高精度定位 */ + isHighAccuracy?: boolean + /** 接口调用成功的回调函数 */ + success?: GetLocationSuccessCallback + /** wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标 */ + type?: string + } + interface GetLocationSuccessCallbackResult { + /** 位置的精确度,反应与真实位置之间的接近程度,可以理解成10即与真实位置相差10m,越小越精确 */ + accuracy: number + /** 需要基础库: `1.2.0` + * + * 高度,单位 m */ + altitude: number + /** 需要基础库: `1.2.0` + * + * 水平精度,单位 m */ + horizontalAccuracy: number + /** 纬度,范围为 -90~90,负数表示南纬 */ + latitude: number + /** 经度,范围为 -180~180,负数表示西经 */ + longitude: number + /** 速度,单位 m/s */ + speed: number + /** 需要基础库: `1.2.0` + * + * 垂直精度,单位 m(Android 无法获取,返回 0) */ + verticalAccuracy: number + errMsg: string + } + interface GetLogManagerOption { + /** 需要基础库: `2.3.2` + * + * 取值为0/1,取值为0表示会把 `App`、`Page` 的生命周期函数和 `wx` 命名空间下的函数调用写入日志,取值为1则不会。默认值是 0 */ + level?: number + } + interface GetMaxTransceiveLengthOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetMaxTransceiveLengthCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetMaxTransceiveLengthFailCallback + /** 接口调用成功的回调函数 */ + success?: GetMaxTransceiveLengthSuccessCallback + } + interface GetMaxTransceiveLengthSuccessCallbackResult { + /** 最大传输长度 */ + length: number + errMsg: string + } + interface GetMaxZoomOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetMaxZoomCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetMaxZoomFailCallback + /** 接口调用成功的回调函数 */ + success?: GetMaxZoomSuccessCallback + } + interface GetMaxZoomSuccessCallbackResult { + /** 最大放缩级别 */ + maxZoom: string + errMsg: string + } + interface GetNetworkTypeOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetNetworkTypeCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetNetworkTypeFailCallback + /** 接口调用成功的回调函数 */ + success?: GetNetworkTypeSuccessCallback + } + interface GetNetworkTypeSuccessCallbackResult { + /** 需要基础库: `2.22.1` + * + * 设备是否使用了网络代理 */ + hasSystemProxy: boolean + /** 网络类型 + * + * 可选值: + * - 'wifi': wifi 网络; + * - '2g': 2g 网络; + * - '3g': 3g 网络; + * - '4g': 4g 网络; + * - '5g': 5g 网络; + * - 'unknown': Android 下不常见的网络类型; + * - 'none': 无网络; */ + networkType: 'wifi' | '2g' | '3g' | '4g' | '5g' | 'unknown' | 'none' + /** 信号强弱,单位 dbm */ + signalStrength: number + /** 需要基础库: `3.5.3` + * + * 是否处于弱网环境 */ + weakNet: boolean + errMsg: string + } + interface GetPrivacySettingOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetPrivacySettingCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetPrivacySettingFailCallback + /** 接口调用成功的回调函数 */ + success?: GetPrivacySettingSuccessCallback + } + interface GetPrivacySettingSuccessCallbackResult { + /** 是否需要用户授权隐私协议(如果开发者没有在「MP后台-设置-服务内容声明-用户隐私保护指引」中声明隐私收集类型则会返回false;如果开发者声明了隐私收集,且用户之前同意过隐私协议则会返回false;如果开发者声明了隐私收集,且用户还没同意过则返回true;如果用户之前同意过、但后来小程序又新增了隐私收集类型也会返回true) */ + needAuthorization: boolean + /** 隐私授权协议的名称 */ + privacyContractName: string + errMsg: string + } + interface GetRandomValuesOption { + /** 整数,生成随机数的字节数,最大 1048576 */ + length: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetRandomValuesCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetRandomValuesFailCallback + /** 接口调用成功的回调函数 */ + success?: GetRandomValuesSuccessCallback + } + interface GetRandomValuesSuccessCallbackResult { + /** 随机数内容,长度为传入的字节数 */ + randomValues: ArrayBuffer + errMsg: string + } + interface GetRegionOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetRegionCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetRegionFailCallback + /** 接口调用成功的回调函数 */ + success?: GetRegionSuccessCallback + } + interface GetRegionSuccessCallbackResult { + /** 东北角经纬度 */ + northeast: MapPostion + /** 西南角经纬度 */ + southwest: MapPostion + errMsg: string + } + interface GetRendererUserAgentOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetRendererUserAgentCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetRendererUserAgentFailCallback + /** 接口调用成功的回调函数 */ + success?: GetRendererUserAgentSuccessCallback + } + interface GetRotateOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetRotateCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetRotateFailCallback + /** 接口调用成功的回调函数 */ + success?: GetRotateSuccessCallback + } + interface GetRotateSuccessCallbackResult { + /** 旋转角 */ + rotate: number + errMsg: string + } + interface GetSakOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetSakCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetSakFailCallback + /** 接口调用成功的回调函数 */ + success?: GetSakSuccessCallback + } + interface GetSakSuccessCallbackResult { + /** 返回 SAK/SEL_RES 数据 */ + sak: number + errMsg: string + } + interface GetSavedFileListOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetSavedFileListCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetSavedFileListFailCallback + /** 接口调用成功的回调函数 */ + success?: GetSavedFileListSuccessCallback + } + interface GetSavedFileListSuccessCallbackResult { + /** 文件数组 */ + fileList: FileItem[] + errMsg: string + } + interface GetScaleOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetScaleCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetScaleFailCallback + /** 接口调用成功的回调函数 */ + success?: GetScaleSuccessCallback + } + interface GetScaleSuccessCallbackResult { + /** 缩放值 */ + scale: number + errMsg: string + } + interface GetScreenBrightnessOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetScreenBrightnessCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetScreenBrightnessFailCallback + /** 接口调用成功的回调函数 */ + success?: GetScreenBrightnessSuccessCallback + } + interface GetScreenBrightnessSuccessCallbackOption { + /** 屏幕亮度值,范围 0 ~ 1,0 最暗,1 最亮 */ + value: number + errMsg: string + } + interface GetScreenRecordingStateOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetScreenRecordingStateCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetScreenRecordingStateFailCallback + /** 接口调用成功的回调函数 */ + success?: GetScreenRecordingStateSuccessCallback + } + interface GetScreenRecordingStateSuccessCallbackResult { + /** 录屏状态 + * + * 可选值: + * - 'on': 开启; + * - 'off': 关闭; */ + state: 'on' | 'off' + errMsg: string + } + interface GetSelectedTextRangeOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetSelectedTextRangeCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetSelectedTextRangeFailCallback + /** 接口调用成功的回调函数 */ + success?: GetSelectedTextRangeSuccessCallback + } + interface GetSelectedTextRangeSuccessCallbackResult { + /** 输入框光标结束位置 */ + end: number + /** 输入框光标起始位置 */ + start: number + errMsg: string + } + interface GetSelectionOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetSelectionCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetSelectionFailCallback + /** 接口调用成功的回调函数 */ + success?: GetSelectionSuccessCallback + } + interface GetSelectionSuccessCallbackResult { + /** 选区相对于视口的大小和位置 */ + bounds: IAnyObject + /** 选区位置,index 为开始位置,length 为选区长度 */ + range: IAnyObject + errMsg: string + } + interface GetSelectionTextOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetSelectionTextCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetSelectionTextFailCallback + /** 接口调用成功的回调函数 */ + success?: GetSelectionTextSuccessCallback + } + interface GetSelectionTextSuccessCallbackResult { + /** 纯文本内容 */ + text: string + errMsg: string + } + interface GetSettingOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetSettingCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetSettingFailCallback + /** 接口调用成功的回调函数 */ + success?: GetSettingSuccessCallback + /** 需要基础库: `2.10.1` + * + * 是否同时获取用户订阅消息的订阅状态,默认不获取。注意:withSubscriptions 只返回用户勾选过订阅面板中的“总是保持以上选择,不再询问”的订阅消息。 */ + withSubscriptions?: boolean + } + interface GetSettingSuccessCallbackResult { + /** [AuthSetting](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/setting/AuthSetting.html) + * + * 用户授权结果 */ + authSetting: AuthSetting + /** [SubscriptionsSetting](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/setting/SubscriptionsSetting.html) + * + * 需要基础库: `2.10.1` + * + * 用户订阅消息设置,接口参数`withSubscriptions`值为`true`时才会返回。 */ + subscriptionsSetting: SubscriptionsSetting + /** [AuthSetting](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/setting/AuthSetting.html) + * + * 在插件中调用时,当前宿主小程序的用户授权结果 */ + miniprogramAuthSetting?: AuthSetting + errMsg: string + } + interface GetShareInfoOption { + /** shareTicket,详见[获取更多转发信息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html#获取更多转发信息) */ + shareTicket: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetShareInfoCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetShareInfoFailCallback + /** 接口调用成功的回调函数 */ + success?: GetShareInfoSuccessCallback + /** 需要基础库: `1.9.90` + * + * 超时时间,单位 ms */ + timeout?: number + } + interface GetShowSplashAdStatusOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetShowSplashAdStatusCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetShowSplashAdStatusFailCallback + /** 接口调用成功的回调函数 */ + success?: GetShowSplashAdStatusSuccessCallback + } + interface GetShowSplashAdStatusSuccessCallbackResult { + /** 封面广告组件展示状态码 + * + * 可选值: + * - -1: 初始值,状态未知; + * - 1: 展示成功; + * - 2: 主动拦截过滤,不展示广告; + * - 3: 展示超时; */ + code: -1 | 1 | 2 | 3 + /** 封面广告组件展示状态 + * + * 可选值: + * - 'unknown': 初始值,状态未知; + * - 'pending': 进行展示中; + * - 'success': 展示成功; + * - 'fail': 展示失败; */ + status: 'unknown' | 'pending' | 'success' | 'fail' + errMsg: string + } + interface GetSkewOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetSkewCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetSkewFailCallback + /** 接口调用成功的回调函数 */ + success?: GetSkewSuccessCallback + } + interface GetSkewSuccessCallbackResult { + /** 倾斜角 */ + skew: number + errMsg: string + } + interface GetSkylineInfoOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetSkylineInfoCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetSkylineInfoFailCallback + /** 接口调用成功的回调函数 */ + success?: GetSkylineInfoSuccessCallback + } + interface GetStorageInfoOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetStorageInfoCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetStorageInfoFailCallback + /** 接口调用成功的回调函数 */ + success?: GetStorageInfoSuccessCallback + } + interface GetStorageInfoSuccessCallbackOption { + /** 当前占用的空间大小, 单位 KB */ + currentSize: number + /** 当前 storage 中所有的 key */ + keys: string[] + /** 限制的空间大小,单位 KB */ + limitSize: number + errMsg: string + } + interface GetStorageInfoSyncOption { + /** 当前占用的空间大小, 单位 KB */ + currentSize: number + /** 当前 storage 中所有的 key */ + keys: string[] + /** 限制的空间大小,单位 KB */ + limitSize: number + } + interface GetStorageOption { + /** 本地缓存中指定的 key */ + key: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetStorageCompleteCallback + /** 需要基础库: `2.21.3` + * + * 是否开启加密存储。只有异步的 getStorage 接口支持开启加密存储。开启后,将会对 data 使用 AES128 解密,接口回调耗时将会增加。若开启加密存储,setStorage 和 getStorage 需要同时声明 encrypt 的值为 true */ + encrypt?: boolean + /** 接口调用失败的回调函数 */ + fail?: GetStorageFailCallback + /** 接口调用成功的回调函数 */ + success?: GetStorageSuccessCallback + } + interface GetStorageSuccessCallbackResult { + /** key对应的内容 */ + data: T + errMsg: string + } + interface GetSystemInfoAsyncOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetSystemInfoAsyncCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetSystemInfoAsyncFailCallback + /** 接口调用成功的回调函数 */ + success?: GetSystemInfoAsyncSuccessCallback + } + interface GetSystemInfoOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetSystemInfoCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetSystemInfoFailCallback + /** 接口调用成功的回调函数 */ + success?: GetSystemInfoSuccessCallback + } + interface GetUserInfoOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetUserInfoCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetUserInfoFailCallback + /** 显示用户信息的语言 + * + * 可选值: + * - 'en': 英文; + * - 'zh_CN': 简体中文; + * - 'zh_TW': 繁体中文; */ + lang?: 'en' | 'zh_CN' | 'zh_TW' + /** 接口调用成功的回调函数 */ + success?: GetUserInfoSuccessCallback + /** 是否带上登录态信息。当 withCredentials 为 true 时,要求此前有调用过 wx.login 且登录态尚未过期,此时返回的数据会包含 encryptedData, iv 等敏感信息;当 withCredentials 为 false 时,不要求有登录态,返回的数据不包含 encryptedData, iv 等敏感信息。 */ + withCredentials?: boolean + } + interface GetUserInfoSuccessCallbackResult { + /** 需要基础库: `2.7.0` + * + * 敏感数据对应的云 ID,开通[云开发](https://developers.weixin.qq.com/miniprogram/dev/wxcloudservice/wxcloud/basis/getting-started.html)的小程序才会返回,可通过云调用直接获取开放数据,详细见[云调用直接获取开放数据](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html#method-cloud) */ + cloudID: string + /** 包括敏感数据在内的完整用户信息的加密数据,详见 [用户数据的签名验证和加解密](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html#加密数据解密算法) */ + encryptedData: string + /** 加密算法的初始向量,详见 [用户数据的签名验证和加解密](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html#加密数据解密算法) */ + iv: string + /** 不包括敏感信息的原始数据字符串,用于计算签名 */ + rawData: string + /** 使用 sha1( rawData + sessionkey ) 得到字符串,用于校验用户信息,详见 [用户数据的签名验证和加解密](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html) */ + signature: string + /** [UserInfo](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/UserInfo.html) + * + * 用户信息对象,不包含 openid 等敏感信息 */ + userInfo: UserInfo + errMsg: string + } + interface GetUserProfileOption { + /** 声明获取用户个人信息后的用途,不超过30个字符 */ + desc: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetUserProfileCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetUserProfileFailCallback + /** 显示用户信息的语言 + * + * 可选值: + * - 'en': 英文; + * - 'zh_CN': 简体中文; + * - 'zh_TW': 繁体中文; */ + lang?: 'en' | 'zh_CN' | 'zh_TW' + /** 接口调用成功的回调函数 */ + success?: GetUserProfileSuccessCallback + } + interface GetUserProfileSuccessCallbackResult { + /** 需要基础库: `2.10.4` + * + * 敏感数据对应的云 ID,开通[云开发](https://developers.weixin.qq.com/miniprogram/dev/wxcloudservice/wxcloud/basis/getting-started.html)的小程序才会返回,可通过云调用直接获取开放数据,详细见[云调用直接获取开放数据](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html#method-cloud) */ + cloudID: string + /** 需要基础库: `2.10.4` + * + * 包括敏感数据在内的完整用户信息的加密数据,详见 [用户数据的签名验证和加解密](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html#加密数据解密算法) */ + encryptedData: string + /** 需要基础库: `2.10.4` + * + * 加密算法的初始向量,详见 [用户数据的签名验证和加解密](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html#加密数据解密算法) */ + iv: string + /** 需要基础库: `2.10.4` + * + * 不包括敏感信息的原始数据字符串,用于计算签名 */ + rawData: string + /** 需要基础库: `2.10.4` + * + * 使用 sha1( rawData + sessionkey ) 得到字符串,用于校验用户信息,详见 [用户数据的签名验证和加解密](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html) */ + signature: string + /** [UserInfo](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/UserInfo.html) + * + * 需要基础库: `2.10.4` + * + * 用户信息对象 */ + userInfo: UserInfo + errMsg: string + } + interface GetVideoInfoOption { + /** 视频文件路径,可以是临时文件路径也可以是永久文件路径 */ + src: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetVideoInfoCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetVideoInfoFailCallback + /** 接口调用成功的回调函数 */ + success?: GetVideoInfoSuccessCallback + } + interface GetVideoInfoSuccessCallbackResult { + /** 视频码率,单位 kbps */ + bitrate: number + /** 视频长度 */ + duration: number + /** 视频帧率 */ + fps: number + /** 视频的长,单位 px */ + height: number + /** 画面方向 + * + * 可选值: + * - 'up': 默认; + * - 'down': 180度旋转; + * - 'left': 逆时针旋转90度; + * - 'right': 顺时针旋转90度; + * - 'up-mirrored': 同up,但水平翻转; + * - 'down-mirrored': 同down,但水平翻转; + * - 'left-mirrored': 同left,但垂直翻转; + * - 'right-mirrored': 同right,但垂直翻转; */ + orientation: + | 'up' + | 'down' + | 'left' + | 'right' + | 'up-mirrored' + | 'down-mirrored' + | 'left-mirrored' + | 'right-mirrored' + /** 视频大小,单位 kB */ + size: number + /** 视频格式 */ + type: string + /** 视频的宽,单位 px */ + width: number + errMsg: string + } + interface GetWeRunDataOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetWeRunDataCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetWeRunDataFailCallback + /** 接口调用成功的回调函数 */ + success?: GetWeRunDataSuccessCallback + } + interface GetWeRunDataSuccessCallbackResult { + /** 需要基础库: `2.7.0` + * + * 敏感数据对应的云 ID,开通云开发的小程序才会返回,可通过云调用直接获取开放数据,详细见[云调用直接获取开放数据](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html#method-cloud) */ + cloudID: string + /** 包括敏感数据在内的完整用户信息的加密数据,详细见[加密数据解密算法](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html)。解密后得到的数据结构见后文 */ + encryptedData: string + /** 加密算法的初始向量,详细见[加密数据解密算法](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html) */ + iv: string + errMsg: string + } + interface GetWifiListOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetWifiListCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: GetWifiListFailCallback + /** 接口调用成功的回调函数 */ + success?: GetWifiListSuccessCallback + } + /** 全球收银对象 GlobalPayment */ + interface GlobalPayment { + /** 初始值为null。当开发者调用 openMethodPicker 用户选中具体支付方式后确定,后续不再改变。 +* +* ```js + +const goods = { + goods_id: `goods_1`, + goods_name: `拿铁`, + goods_unit_price: { + currency: 'SGD', + total: 10, + }, + goods_quantity: '1', + goods_category: '1', +} + +const globalPay = async () => { + if (typeof wx.createGlobalPayment !== 'function') { + // 基础库版本不支持 + // 方案一、微信支付做兜底 + wx.requestPayment({ + timeStamp: '', + nonceStr: '', + package: '', + signType: '', + paySign: '', + }) + // 方案二、引导用户更新 + // 方案三、mp后台设置最低基础库版本 3.7.3 + return + } + + const payment = wx.createGlobalPayment({ mchRegion: 'SG', isSandbox: true }) + + try { + const pickerResp = await payment.openMethodPicker({ + amount: goods.goods_unit_price, + }) + + console.log(`openMethodPicker resp: `, pickerResp) + + if (pickerResp.methodKey === 'WECHAT_PAY') { + // 发起微信支付 + } else { + // 后台接口发起预下单 + const preOrderResp = await preOrder( + goods.goods_unit_price, + [goods], + pickerResp.methodKey + ) + + console.log(`preOrder resp: `, preOrderResp) + + const { payment_id, prepay_info } = preOrderResp + + const requestPaymentResp = await payment.requestGlobalPayment({ + paymentId: payment_id, + prepayInfo: prepay_info, + }) + + console.log(`requestGlobalPayment resp: `, requestPaymentResp) + } + } catch (error) { + console.log(error) + } +} + +``` */ + methodKey: string + /** [Promise GlobalPayment.abort()](https://developers.weixin.qq.com/miniprogram/dev/api/payment/GlobalPayment.abort.html) + * + * 需要基础库: `3.7.3` + * + * 在插件中使用:不支持 + * + * 用户选择TPG的支付方式,界面会进入加载的Toast,等待开发者前往TPG完成预下单后携带预支付信息和交易单号调用 requestGlobalPayment,若开发者在 + * TPG预下单未成功或出现异常情况,可调用该接口主动终止TPG支付流程,界面加载的Toast将会隐藏,提示用户下单失败。 */ + abort(): Promise + /** [Promise GlobalPayment.openMethodPicker(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/payment/GlobalPayment.openMethodPicker.html) + * + * 需要基础库: `3.7.3` + * + * 在插件中使用:不支持 + * + * 拉起全球收银的支付方式选择面板。当用户选择支付方式或者关闭选择面板后,返回相应结果。 + * 当用户选定支付方式后,globalPayment上的属性 methodKey 也会更新,后续该对象再次调用将直接失败,不再拉起选择面板。 + * 若用户选择微信支付,请开发者按原微信支付接口 wx.requestPayment 调用完成后续支付流程。 + * 若用户选择TPG的支付方式,流程会等待开发者前往TPG完成预下单后,携带预支付信息和交易单号调用 requestGlobalPayment,若开发者超时未调用,则会提示用户加载超时(超时时间暂定为30s)。 + * 当用户关闭选择面板,即未选择支付方式,开发者后续仍可继续调用接口拉起支付方式选择面板。 */ + openMethodPicker(option: OpenMethodPickerOption): Promise + /** [Promise GlobalPayment.requestGlobalPayment(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/payment/GlobalPayment.requestGlobalPayment.html) + * + * 需要基础库: `3.7.3` + * + * 在插件中使用:不支持 + * + * 开发者调用 openMethodPicker 并在返回值 methodKey 中接受到用户选择了TPG的支付方式后,可调用此接口接入TPG的支付流程。 + * 当用户已成功完成当前订单支付后,再次调用该对象的 requestGlobalPayment 会失败。即每次支付都需创建新的 globalPayment 对象重走流程。 + * 仅在 methodKey 为TPG支付类型才能进入全球收银的支付流程,其他情况会失败。 + * 建议在接口返回后,不论成功或失败,均通过 TPG 接口 inquiry-payment 对订单状态进行查询。 */ + requestGlobalPayment(option: RequestGlobalPaymentOption): Promise + } + interface GroupMemberInfo { + /** 所选用户在此聊天室下的唯一标识,同一个用户在不同的聊天室下id不同 */ + members: string[] + errMsg: string + } + /** 需要基础库: `2.28.0` + * + * 手势检测配置。用法详情[指南文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/hand.html)。 */ + interface HandTrack { + /** 需要基础库: `2.28.0` + * + * 手势检测模式 + * + * 可选值: + * - 1: 通过摄像头实时检测; + * - 2: 静态图片检测; */ + mode: 1 | 2 + } + interface HideHomeButtonOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: HideHomeButtonCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: HideHomeButtonFailCallback + /** 接口调用成功的回调函数 */ + success?: HideHomeButtonSuccessCallback + } + interface HideKeyboardOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: HideKeyboardCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: HideKeyboardFailCallback + /** 接口调用成功的回调函数 */ + success?: HideKeyboardSuccessCallback + } + interface HideLoadingOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: HideLoadingCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: HideLoadingFailCallback + /** 需要基础库: `2.22.1` + * + * 目前 toast 和 loading 相关接口可以相互混用,此参数可用于取消混用特性 */ + noConflict?: boolean + /** 接口调用成功的回调函数 */ + success?: HideLoadingSuccessCallback + } + interface HideNavigationBarLoadingOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: HideNavigationBarLoadingCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: HideNavigationBarLoadingFailCallback + /** 接口调用成功的回调函数 */ + success?: HideNavigationBarLoadingSuccessCallback + } + /** 切后台参数 */ + interface HideOptionsApp { + /** 需要基础库: `3.5.7` + * + * 原因 + * + * 可选值: + * - 0: 用户退出小程序; + * - 1: 进入其他小程序; + * - 2: 打开原生功能页; + * - 3: 其他; */ + reason?: 0 | 1 | 2 | 3 + } + interface HideShareMenuOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: HideShareMenuCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: HideShareMenuFailCallback + /** 需要基础库: `2.11.3` + * + * 本接口为 Beta 版本,暂只在 Android 平台支持。需要隐藏的转发按钮名称列表,默认['shareAppMessage', 'shareTimeline']。按钮名称合法值包含 "shareAppMessage"、"shareTimeline" 两种 */ + menus?: string[] + /** 接口调用成功的回调函数 */ + success?: HideShareMenuSuccessCallback + } + interface HideTabBarOption { + /** 是否需要动画效果 */ + animation?: boolean + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: HideTabBarCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: HideTabBarFailCallback + /** 接口调用成功的回调函数 */ + success?: HideTabBarSuccessCallback + } + interface HideTabBarRedDotOption { + /** tabBar 的哪一项,从左边算起 */ + index: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: HideTabBarRedDotCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: HideTabBarRedDotFailCallback + /** 接口调用成功的回调函数 */ + success?: HideTabBarRedDotSuccessCallback + } + interface HideToastOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: HideToastCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: HideToastFailCallback + /** 需要基础库: `2.22.1` + * + * 目前 toast 和 loading 相关接口可以相互混用,此参数可用于取消混用特性 */ + noConflict?: boolean + /** 接口调用成功的回调函数 */ + success?: HideToastSuccessCallback + } + /** 检测结果 */ + interface HitTestRes { + /** 包含位置、旋转、放缩信息的矩阵,以列为主序 */ + transform: Float32Array + } + /** 需要基础库: `3.3.0` + * + * 身份证检测配置。用法详情[指南文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/idcard.html)。 */ + interface IDCardTrack { + /** 需要基础库: `3.3.0` + * + * 身份证检测模式 + * + * 可选值: + * - 2: 静态图片检测; */ + mode: 2 + } + /** 需要基础库: `2.7.0` + * + * 图片对象 */ + interface Image { + /** 图片的真实高度 */ + height: number + /** 图片加载发生错误后触发的回调函数 */ + onerror: (...args: any[]) => any + /** 图片加载完成后触发的回调函数 */ + onload: (...args: any[]) => any + /** 需要基础库: `2.13.0` + * + * `origin`: 发送完整的referrer; `no-referrer`: 不发送。格式固定为 `https://servicewechat.com/{appid}/{version}/page-frame.html`,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本; */ + referrerPolicy: string + /** 图片的 URL。v2.11.0 起支持传递 base64 Data URI */ + src: string + /** 图片的真实宽度 */ + width: number + } + /** 需要基础库: `2.9.0` + * + * ImageData 对象 */ + interface ImageData { + /** 一维数组,包含以 RGBA 顺序的数据,数据使用 0 至 255(包含)的整数表示 */ + data: Uint8ClampedArray + /** 使用像素描述 ImageData 的实际高度 */ + height: number + /** 使用像素描述 ImageData 的实际宽度 */ + width: number + } + /** 需要基础库: `1.2.0` + * + * 图片的本地临时文件列表 */ + interface ImageFile { + /** 本地临时文件路径 (本地路径) */ + path: string + /** 本地临时文件大小,单位 B */ + size: number + } + interface IncludePointsOption { + /** 要显示在可视区域内的坐标点列表 */ + points: MapPostion[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: IncludePointsCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: IncludePointsFailCallback + /** 坐标点形成的矩形边缘到地图边缘的距离,单位像素。格式为[上,右,下,左]。开发者工具暂不支持padding参数。 */ + padding?: number[] + /** 接口调用成功的回调函数 */ + success?: IncludePointsSuccessCallback + } + interface InitFaceDetectOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: InitFaceDetectCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: InitFaceDetectFailCallback + /** 接口调用成功的回调函数 */ + success?: InitFaceDetectSuccessCallback + } + interface InitMarkerClusterOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: InitMarkerClusterCompleteCallback + /** 启用默认的聚合样式 */ + enableDefaultStyle?: boolean + /** 接口调用失败的回调函数 */ + fail?: InitMarkerClusterFailCallback + /** 聚合算法的可聚合距离,即距离小于该值的点会聚合至一起,以像素为单位 */ + gridSize?: number + /** 接口调用成功的回调函数 */ + success?: InitMarkerClusterSuccessCallback + /** 点击已经聚合的标记点时是否实现聚合分离 */ + zoomOnClick?: boolean + } + /** InnerAudioContext 实例,可通过 [wx.createInnerAudioContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createInnerAudioContext.html) 接口获取实例。注意,音频播放过程中,可能被系统中断,可通过 [wx.onAudioInterruptionBegin](https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onAudioInterruptionBegin.html)、[wx.onAudioInterruptionEnd](https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onAudioInterruptionEnd.html)事件来处理这种情况。 +* +* **支持格式** +* +* | 格式 | iOS | Android | +* | ---- | ---- | ------- | +* | flac | x | √ | +* | m4a | √ | √ | +* | ogg | x | √ | +* | ape | x | √ | +* | amr | x | √ | +* | wma | x | √ | +* | wav | √ | √ | +* | mp3 | √ | √ | +* | mp4 | x | √ | +* | aac | √ | √ | +* | aiff | √ | x | +* | caf | √ | x | +* +* **示例代码** +* +* ```js +const innerAudioContext = wx.createInnerAudioContext() +innerAudioContext.autoplay = true +innerAudioContext.src = 'https://wx_test.mp3' +innerAudioContext.onPlay(() => { + console.log('开始播放') +}) +innerAudioContext.onError((res) => { + console.log(res.errMsg) + console.log(res.errCode) +}) +``` */ + interface InnerAudioContext { + /** 是否自动开始播放,默认为 `false` */ + autoplay: boolean + /** 音频缓冲的时间点,仅保证当前播放时间点到此时间点内容已缓冲(只读) */ + buffered: number + /** 当前音频的播放位置(单位 s)。只有在当前有合法的 src 时返回,时间保留小数点后 6 位(currentTime 属性在基础库 2.26.2 之前只读,基础库 2.26.2 开始可读可写,改变 currentTime 值等同于调用 seek) */ + currentTime: number + /** 当前音频的长度(单位 s)。只有在当前有合法的 src 时返回(只读) */ + duration: number + /** 是否循环播放,默认为 `false` */ + loop: boolean + /** 是否遵循系统静音开关,默认为 `true`。当此参数为 `false` 时,即使用户打开了静音开关,也能继续发出声音。从 2.3.0 版本开始此参数不生效,使用 [wx.setInnerAudioOption](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.setInnerAudioOption.html) 接口统一设置。 */ + obeyMuteSwitch: boolean + /** 当前是是否暂停或停止状态(只读) */ + paused: boolean + /** 需要基础库: `2.11.0` + * + * 播放速度。范围 0.5-2.0,默认为 1。(Android 需要 6 及以上版本) */ + playbackRate: number + /** 需要基础库: `2.13.0` + * + * `origin`: 发送完整的referrer; `no-referrer`: 不发送。格式固定为 `https://servicewechat.com/{appid}/{version}/page-frame.html`,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本; */ + referrerPolicy: string + /** 音频资源的地址,用于直接播放。[2.2.3](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 开始支持云文件ID */ + src: string + /** 开始播放的位置(单位:s),默认为 0 */ + startTime: number + /** 需要基础库: `1.9.90` + * + * 音量。范围 0~1。默认为 1 */ + volume: number + /** [InnerAudioContext.destroy()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.destroy.html) + * + * 在插件中使用:支持 + * + * 销毁当前实例 */ + destroy(): void + /** [InnerAudioContext.offCanplay(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.offCanplay.html) +* +* 需要基础库: `1.9.0` +* +* 在插件中使用:支持 +* +* 移除音频进入可以播放状态的事件的监听函数 +* +* **示例代码** +* +* ```js +const listener = function (res) { console.log(res) } + +InnerAudioContext.onCanplay(listener) +InnerAudioContext.offCanplay(listener) // 需传入与监听时同一个的函数对象 +``` */ + offCanplay( + /** onCanplay 传入的监听函数。不传此参数则移除所有监听函数。 */ + listener?: OffCanplayCallback + ): void + /** [InnerAudioContext.offEnded(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.offEnded.html) +* +* 需要基础库: `1.9.0` +* +* 在插件中使用:支持 +* +* 移除音频自然播放至结束的事件的监听函数 +* +* **示例代码** +* +* ```js +const listener = function (res) { console.log(res) } + +InnerAudioContext.onEnded(listener) +InnerAudioContext.offEnded(listener) // 需传入与监听时同一个的函数对象 +``` */ + offEnded( + /** onEnded 传入的监听函数。不传此参数则移除所有监听函数。 */ + listener?: OffEndedCallback + ): void + /** [InnerAudioContext.offError(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.offError.html) +* +* 需要基础库: `1.9.0` +* +* 在插件中使用:支持 +* +* 移除音频播放错误事件的监听函数 +* +* **示例代码** +* +* ```js +const listener = function (res) { console.log(res) } + +InnerAudioContext.onError(listener) +InnerAudioContext.offError(listener) // 需传入与监听时同一个的函数对象 +``` */ + offError( + /** onError 传入的监听函数。不传此参数则移除所有监听函数。 */ + listener?: InnerAudioContextOffErrorCallback + ): void + /** [InnerAudioContext.offPause(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.offPause.html) +* +* 需要基础库: `1.9.0` +* +* 在插件中使用:支持 +* +* 移除音频暂停事件的监听函数 +* +* **示例代码** +* +* ```js +const listener = function (res) { console.log(res) } + +InnerAudioContext.onPause(listener) +InnerAudioContext.offPause(listener) // 需传入与监听时同一个的函数对象 +``` */ + offPause( + /** onPause 传入的监听函数。不传此参数则移除所有监听函数。 */ + listener?: OffPauseCallback + ): void + /** [InnerAudioContext.offPlay(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.offPlay.html) +* +* 需要基础库: `1.9.0` +* +* 在插件中使用:支持 +* +* 移除音频播放事件的监听函数 +* +* **示例代码** +* +* ```js +const listener = function (res) { console.log(res) } + +InnerAudioContext.onPlay(listener) +InnerAudioContext.offPlay(listener) // 需传入与监听时同一个的函数对象 +``` */ + offPlay( + /** onPlay 传入的监听函数。不传此参数则移除所有监听函数。 */ + listener?: OffPlayCallback + ): void + /** [InnerAudioContext.offSeeked(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.offSeeked.html) +* +* 需要基础库: `1.9.0` +* +* 在插件中使用:支持 +* +* 移除音频完成跳转操作的事件的监听函数 +* +* **示例代码** +* +* ```js +const listener = function (res) { console.log(res) } + +InnerAudioContext.onSeeked(listener) +InnerAudioContext.offSeeked(listener) // 需传入与监听时同一个的函数对象 +``` */ + offSeeked( + /** onSeeked 传入的监听函数。不传此参数则移除所有监听函数。 */ + listener?: OffSeekedCallback + ): void + /** [InnerAudioContext.offSeeking(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.offSeeking.html) +* +* 需要基础库: `1.9.0` +* +* 在插件中使用:支持 +* +* 移除音频进行跳转操作的事件的监听函数 +* +* **示例代码** +* +* ```js +const listener = function (res) { console.log(res) } + +InnerAudioContext.onSeeking(listener) +InnerAudioContext.offSeeking(listener) // 需传入与监听时同一个的函数对象 +``` */ + offSeeking( + /** onSeeking 传入的监听函数。不传此参数则移除所有监听函数。 */ + listener?: OffSeekingCallback + ): void + /** [InnerAudioContext.offStop(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.offStop.html) +* +* 需要基础库: `1.9.0` +* +* 在插件中使用:支持 +* +* 移除音频停止事件的监听函数 +* +* **示例代码** +* +* ```js +const listener = function (res) { console.log(res) } + +InnerAudioContext.onStop(listener) +InnerAudioContext.offStop(listener) // 需传入与监听时同一个的函数对象 +``` */ + offStop( + /** onStop 传入的监听函数。不传此参数则移除所有监听函数。 */ + listener?: OffStopCallback + ): void + /** [InnerAudioContext.offTimeUpdate(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.offTimeUpdate.html) +* +* 需要基础库: `1.9.0` +* +* 在插件中使用:支持 +* +* 移除音频播放进度更新事件的监听函数 +* +* **示例代码** +* +* ```js +const listener = function (res) { console.log(res) } + +InnerAudioContext.onTimeUpdate(listener) +InnerAudioContext.offTimeUpdate(listener) // 需传入与监听时同一个的函数对象 +``` */ + offTimeUpdate( + /** onTimeUpdate 传入的监听函数。不传此参数则移除所有监听函数。 */ + listener?: OffTimeUpdateCallback + ): void + /** [InnerAudioContext.offWaiting(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.offWaiting.html) +* +* 需要基础库: `1.9.0` +* +* 在插件中使用:支持 +* +* 移除音频加载中事件的监听函数 +* +* **示例代码** +* +* ```js +const listener = function (res) { console.log(res) } + +InnerAudioContext.onWaiting(listener) +InnerAudioContext.offWaiting(listener) // 需传入与监听时同一个的函数对象 +``` */ + offWaiting( + /** onWaiting 传入的监听函数。不传此参数则移除所有监听函数。 */ + listener?: OffWaitingCallback + ): void + /** [InnerAudioContext.onCanplay(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.onCanplay.html) + * + * 在插件中使用:支持 + * + * 监听音频进入可以播放状态的事件。但不保证后面可以流畅播放 */ + onCanplay( + /** 音频进入可以播放状态的事件的监听函数 */ + listener: OnCanplayCallback + ): void + /** [InnerAudioContext.onEnded(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.onEnded.html) + * + * 在插件中使用:支持 + * + * 监听音频自然播放至结束的事件 */ + onEnded( + /** 音频自然播放至结束的事件的监听函数 */ + listener: OnEndedCallback + ): void + /** [InnerAudioContext.onError(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.onError.html) + * + * 在插件中使用:支持 + * + * 监听音频播放错误事件 + * + * **Tips** + * + * 1. errCode=100001 时,如若 errMsg 中有 INNERCODE -11828 ,请先检查 response header 是否缺少 Content-Length + * 2. errCode=100001 时,如若 errMsg 中有 systemErrCode:200333420,请检查文件编码格式和 fileExtension 是否一致 */ + onError( + /** 音频播放错误事件的监听函数 */ + listener: InnerAudioContextOnErrorCallback + ): void + /** [InnerAudioContext.onPause(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.onPause.html) + * + * 在插件中使用:支持 + * + * 监听音频暂停事件 */ + onPause( + /** 音频暂停事件的监听函数 */ + listener: OnPauseCallback + ): void + /** [InnerAudioContext.onPlay(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.onPlay.html) + * + * 在插件中使用:支持 + * + * 监听音频播放事件 */ + onPlay( + /** 音频播放事件的监听函数 */ + listener: OnPlayCallback + ): void + /** [InnerAudioContext.onSeeked(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.onSeeked.html) + * + * 在插件中使用:支持 + * + * 监听音频完成跳转操作的事件 */ + onSeeked( + /** 音频完成跳转操作的事件的监听函数 */ + listener: OnSeekedCallback + ): void + /** [InnerAudioContext.onSeeking(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.onSeeking.html) + * + * 在插件中使用:支持 + * + * 监听音频进行跳转操作的事件 */ + onSeeking( + /** 音频进行跳转操作的事件的监听函数 */ + listener: OnSeekingCallback + ): void + /** [InnerAudioContext.onStop(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.onStop.html) + * + * 在插件中使用:支持 + * + * 监听音频停止事件 */ + onStop( + /** 音频停止事件的监听函数 */ + listener: InnerAudioContextOnStopCallback + ): void + /** [InnerAudioContext.onTimeUpdate(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.onTimeUpdate.html) + * + * 在插件中使用:支持 + * + * 监听音频播放进度更新事件 */ + onTimeUpdate( + /** 音频播放进度更新事件的监听函数 */ + listener: OnTimeUpdateCallback + ): void + /** [InnerAudioContext.onWaiting(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.onWaiting.html) + * + * 在插件中使用:支持 + * + * 监听音频加载中事件。当音频因为数据不足,需要停下来加载时会触发 */ + onWaiting( + /** 音频加载中事件的监听函数 */ + listener: OnWaitingCallback + ): void + /** [InnerAudioContext.pause()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.pause.html) + * + * 在插件中使用:支持 + * + * 暂停。暂停后的音频再播放会从暂停处开始播放 */ + pause(): void + /** [InnerAudioContext.play()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.play.html) + * + * 在插件中使用:支持 + * + * 播放 */ + play(): void + /** [InnerAudioContext.seek(number position)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.seek.html) + * + * 在插件中使用:支持 + * + * 跳转到指定位置 */ + seek( + /** 跳转的时间,单位 s。精确到小数点后 3 位,即支持 ms 级别精确度 */ + position: number + ): void + /** [InnerAudioContext.stop()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.stop.html) + * + * 在插件中使用:支持 + * + * 停止。停止后的音频再播放会从头开始播放。 */ + stop(): void + } + interface InnerAudioContextOnErrorListenerResult { + /** 可选值: + * - 10001: 系统错误; + * - 10002: 网络错误; + * - 10003: 文件错误; + * - 10004: 格式错误; + * - -1: 未知错误; */ + errCode: 10001 | 10002 | 10003 | 10004 | -1 + errMsg: string + } + interface InsertCustomBlockOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: InsertCustomBlockCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: InsertCustomBlockFailCallback + /** 插入自定义块后是否自动换行,默认换行 */ + nowrap?: boolean + /** 接口调用成功的回调函数 */ + success?: InsertCustomBlockSuccessCallback + } + interface InsertCustomBlockSuccessCallbackResult { + /** 自定义区块标识符,需结合 [editor-portal](#) 组件一起使用。 */ + blockId: string + errMsg: string + } + interface InsertDividerOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: InsertDividerCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: InsertDividerFailCallback + /** 接口调用成功的回调函数 */ + success?: InsertDividerSuccessCallback + } + interface InsertImageOption { + /** 图片地址,仅支持 http(s)、base64、云图片(2.8.0)、临时文件(2.8.3)。 */ + src: string + /** 图像无法显示时的替代文本 */ + alt?: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: InsertImageCompleteCallback + /** data 被序列化为 name=value;name1=value2 的格式挂在属性 data-custom 上 */ + data?: IAnyObject + /** 添加到图片 img 标签上的类名 */ + extClass?: string + /** 接口调用失败的回调函数 */ + fail?: InsertImageFailCallback + /** 图片高度 (pixels/百分比) */ + height?: string + /** 插入图片后是否自动换行,默认换行 */ + nowrap?: boolean + /** 接口调用成功的回调函数 */ + success?: InsertImageSuccessCallback + /** 图片宽度(pixels/百分比) */ + width?: string + } + interface InsertTextOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: InsertTextCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: InsertTextFailCallback + /** 接口调用成功的回调函数 */ + success?: InsertTextSuccessCallback + /** 文本内容 */ + text?: string + } + interface IntersectionObserverObserveCallbackResult { + /** 目标边界 */ + boundingClientRect: BoundingClientRectResult + /** 节点自定义数据属性 */ + dataset: Record + /** 节点 ID */ + id: string + /** 相交比例 */ + intersectionRatio: number + /** 相交区域的边界 */ + intersectionRect: IntersectionRectResult + /** 参照区域的边界 */ + relativeRect: RelativeRectResult + /** 相交检测时的时间戳 */ + time: number + } + /** 相交区域的边界 */ + interface IntersectionRectResult { + /** 下边界 */ + bottom: number + /** 高度 */ + height: number + /** 左边界 */ + left: number + /** 右边界 */ + right: number + /** 上边界 */ + top: number + /** 宽度 */ + width: number + } + interface InterstitialAdOnErrorListenerResult { + /** 错误码 + * + * 可选值: + * - 1000: 后端接口调用失败; + * - 1001: 参数错误; + * - 1002: 广告单元无效; + * - 1003: 内部错误; + * - 1004: 无合适的广告; + * - 1005: 广告组件审核中; + * - 1006: 广告组件被驳回; + * - 1007: 广告组件被封禁; + * - 1008: 广告单元已关闭; */ + errCode: 1000 | 1001 | 1002 | 1003 | 1004 | 1005 | 1006 | 1007 | 1008 + /** 错误信息 */ + errMsg: string + } + interface IsBluetoothDevicePairedOption { + /** 蓝牙设备 id */ + deviceId: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: IsBluetoothDevicePairedCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: IsBluetoothDevicePairedFailCallback + /** 接口调用成功的回调函数 */ + success?: IsBluetoothDevicePairedSuccessCallback + } + interface IsConnectedOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: IsConnectedCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: IsConnectedFailCallback + /** 接口调用成功的回调函数 */ + success?: IsConnectedSuccessCallback + } + interface Join1v1ChatOption { + /** 呼叫方信息 */ + caller: VoIP1v1ChatUser + /** 接听方信息 */ + listener: VoIP1v1ChatUser + /** 窗口背景色(音频通话背景以及小窗模式背景) + * + * 可选值: + * - 0: #262930; + * - 1: #FA5151; + * - 2: #FA9D3B; + * - 3: #3D7257; + * - 4: #1485EE; + * - 5: #6467F0; */ + backgroundType?: 0 | 1 | 2 | 3 | 4 | 5 + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: Join1v1ChatCompleteCallback + /** 不允许切换到语音通话 */ + disableSwitchVoice?: boolean + /** 接口调用失败的回调函数 */ + fail?: Join1v1ChatFailCallback + /** 小窗样式 */ + minWindowType?: number + /** 通话类型 + * + * 可选值: + * - 'voice': 语音通话; + * - 'video': 视频通话; */ + roomType?: 'voice' | 'video' + /** 接口调用成功的回调函数 */ + success?: Join1v1ChatSuccessCallback + } + interface JoinVoIPChatOption { + /** 小游戏内此房间/群聊的 ID。同一时刻传入相同 groupId 的用户会进入到同个实时语音房间。 */ + groupId: string + /** 验证所需的随机字符串 */ + nonceStr: string + /** 签名,用于验证小游戏的身份 */ + signature: string + /** 验证所需的时间戳 */ + timeStamp: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: JoinVoIPChatCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: JoinVoIPChatFailCallback + /** 需要基础库: `2.29.0` + * + * 开启后,joinVoIPChat 会同时走 Wi-Fi 和蜂窝网络2种网络模式,保证实时通话体验。 */ + forceCellularNetwork?: boolean + /** 静音设置 */ + muteConfig?: MuteConfig + /** 房间类型 + * + * 可选值: + * - 'voice': 音频房间,用于语音通话; + * - 'video': 视频房间,结合 [voip-room](https://developers.weixin.qq.com/miniprogram/dev/component/voip-room.html) 组件可显示成员画面; */ + roomType?: 'voice' | 'video' + /** 接口调用成功的回调函数 */ + success?: JoinVoIPChatSuccessCallback + } + interface JoinVoIPChatSuccessCallbackResult { + /** 错误码 */ + errCode: number + /** 调用结果 */ + errMsg: string + /** 在此通话中的成员 openId 名单 */ + openIdList: string[] + } + interface KvList { + /** key 本地缓存中指定的 key */ + key: string + /** data 需要存储的内容。只支持原生类型、Date、及能够通过`JSON.stringify`序列化的对象。 */ + value: any + } + /** 启动参数 */ + interface LaunchOptionsApp { + /** 需要基础库: `2.20.0` + * + * API 类别 + * + * 可选值: + * - 'default': 默认类别; + * - 'nativeFunctionalized': 原生功能化,视频号直播商品、商品橱窗等场景打开的小程序; + * - 'browseOnly': 仅浏览,朋友圈快照页等场景打开的小程序; + * - 'embedded': 内嵌,通过打开半屏小程序能力打开的小程序; + * - 'chatTool': 聊天工具,通过打开聊天工具能力打开的小程序; */ + apiCategory: + | 'default' + | 'nativeFunctionalized' + | 'browseOnly' + | 'embedded' + | 'chatTool' + /** 打开的文件信息数组,只有从聊天素材场景打开(scene为1173)才会携带该参数 */ + forwardMaterials: ForwardMaterials[] + /** 启动小程序的路径 (代码包路径) */ + path: string + /** 启动小程序的 query 参数 */ + query: Record + /** 来源信息。从另一个小程序、公众号或 App 进入小程序时返回。否则返回 `{}`。(参见后文注意) */ + referrerInfo: ReferrerInfo + /** 启动小程序的[场景值](https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/scene.html) */ + scene: number + /** 从微信群聊/单聊打开小程序时,chatType 表示具体微信群聊/单聊类型 + * + * 可选值: + * - 1: 微信联系人单聊; + * - 2: 企业微信联系人单聊; + * - 3: 普通微信群聊; + * - 4: 企业微信互通群聊; */ + chatType?: 1 | 2 | 3 | 4 + /** shareTicket,详见[获取更多转发信息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html#获取更多转发信息) */ + shareTicket?: string + } + /** 帧深度纹理buffer对象,width * height 大小的 深度值(float32) */ + interface LegSegmentBufferRes { + /** 腿部分割纹理buffer,width * height 大小的 裁剪值(0 为不是脚,越靠近 255 越接近腿部区域)(uint8) */ + DepthAddress: ArrayBuffer + /** 腿部分割纹理高 */ + height: number + /** 腿部分割纹理宽 */ + width: number + } + interface LivePlayerContextRequestFullScreenOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RequestFullScreenCompleteCallback + /** 设置全屏时的方向 + * + * 可选值: + * - 0: 正常竖向; + * - 90: 屏幕逆时针90度; + * - -90: 屏幕顺时针90度; */ + direction?: 0 | 90 | -90 + /** 接口调用失败的回调函数 */ + fail?: RequestFullScreenFailCallback + /** 接口调用成功的回调函数 */ + success?: RequestFullScreenSuccessCallback + } + interface LivePlayerContextSnapshotOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SnapshotCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SnapshotFailCallback + /** 需要基础库: `2.10.0` + * + * 图片的质量 + * + * 可选值: + * - 'raw': 原图; + * - 'compressed': 压缩图; */ + quality?: 'raw' | 'compressed' + /** 需要基础库: `2.25.0` + * + * 截取的源类型 + * + * 可选值: + * - 'stream': 截取视频源; + * - 'view': 截取渲染后的画面; */ + sourceType?: 'stream' | 'view' + /** 接口调用成功的回调函数 */ + success?: LivePlayerContextSnapshotSuccessCallback + } + interface LivePlayerContextSnapshotSuccessCallbackResult { + /** 图片的高度 */ + height: string + /** 图片文件的临时路径 (本地路径) */ + tempImagePath: string + /** 图片的宽度 */ + width: string + errMsg: string + } + interface LivePusherContextSetZoomOption { + /** 缩放级别,范围[1, maxZoom]。zoom 可取小数,精确到小数后一位。 */ + zoom: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetZoomCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetZoomFailCallback + /** 接口调用成功的回调函数 */ + success?: LivePusherContextSetZoomSuccessCallback + } + interface LivePusherContextSnapshotOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SnapshotCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SnapshotFailCallback + /** 需要基础库: `2.10.0` + * + * 图片的质量 + * + * 可选值: + * - 'raw': 原图; + * - 'compressed': 压缩图; */ + quality?: 'raw' | 'compressed' + /** 需要基础库: `2.25.0` + * + * 截取的源类型 + * + * 可选值: + * - 'stream': 截取视频源; + * - 'view': 截取渲染后的画面; */ + sourceType?: 'stream' | 'view' + /** 接口调用成功的回调函数 */ + success?: LivePusherContextSnapshotSuccessCallback + } + interface LivePusherContextSnapshotSuccessCallbackResult { + /** 图片的高度 */ + height: string + /** 图片文件的临时路径 */ + tempImagePath: string + /** 图片的宽度 */ + width: string + errMsg: string + } + interface LivePusherContextStartOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StartFailCallback + /** 接口调用成功的回调函数 */ + success?: StartSuccessCallback + } + interface LoadBuiltInFontFaceOption { + /** 定义的字体名称 */ + family: string + /** 要加载的内置字体名字 + * + * 可选值: + * - 'WeChatSansSS': WeChatSansSS 字体; + * - 'WeChatSansStd': WeChatSansStd 字体; */ + source: 'WeChatSansSS' | 'WeChatSansStd' + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: LoadBuiltInFontFaceCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: LoadBuiltInFontFaceFailCallback + /** <是否全局生效 */ + global?: boolean + /** 字体作用范围,可选值为 webview / native / skyline,默认全选,设置 native 可在 Canvas 2D 下使用 */ + scopes?: any[] + /** 接口调用成功的回调函数 */ + success?: LoadBuiltInFontFaceSuccessCallback + } + interface LoadFontFaceCompleteCallbackResult { + /** 加载字体结果 */ + status: string + } + interface LoadFontFaceOption { + /** 定义的字体名称 */ + family: string + /** 字体资源的地址,可以为 https 链接或者 Data URL。 */ + source: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: LoadFontFaceCompleteCallback + /** 可选的字体描述符 */ + desc?: DescOption + /** 接口调用失败的回调函数 */ + fail?: LoadFontFaceFailCallback + /** 需要基础库: `2.10.0` + * + * 是否全局生效 */ + global?: boolean + /** 字体作用范围,可选值为 webview / native / skyline,默认全选,设置 native 可在 Canvas 2D 下使用 */ + scopes?: any[] + /** 接口调用成功的回调函数 */ + success?: LoadFontFaceSuccessCallback + } + interface LoginOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: LoginCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: LoginFailCallback + /** 接口调用成功的回调函数 */ + success?: LoginSuccessCallback + /** 需要基础库: `1.9.90` + * + * 超时时间,单位ms */ + timeout?: number + } + interface LoginSuccessCallbackResult { + /** 用户登录凭证(有效期五分钟)。开发者需要在开发者服务器后台调用 [code2Session](https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/user-login/code2Session.html),使用 code 换取 openid、unionid、session_key 等信息 */ + code: string + errMsg: string + } + interface MakeBluetoothPairOption { + /** 蓝牙设备 id */ + deviceId: string + /** pin 码,Base64 格式。 */ + pin: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: MakeBluetoothPairCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: MakeBluetoothPairFailCallback + /** 接口调用成功的回调函数 */ + success?: MakeBluetoothPairSuccessCallback + /** 超时时间,单位 ms */ + timeout?: number + } + interface MakePhoneCallOption { + /** 需要拨打的电话号码 */ + phoneNumber: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: MakePhoneCallCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: MakePhoneCallFailCallback + /** 接口调用成功的回调函数 */ + success?: MakePhoneCallSuccessCallback + } + /** 广播的制造商信息。仅安卓支持,iOS 因系统限制无法定制。 */ + interface ManufacturerData { + /** 制造商ID,0x 开头的十六进制 */ + manufacturerId: string + /** 制造商信息 */ + manufacturerSpecificData?: ArrayBuffer + } + /** 图片覆盖的经纬度范围 */ + interface MapBounds { + /** 东北角经纬度 */ + northeast: MapPostion + /** 西南角经纬度 */ + southwest: MapPostion + } + interface MapPostion { + /** 纬度 */ + latitude: number + /** 经度 */ + longitude: number + } + /** 用来扩展(或收缩)参照节点布局区域的边界 */ + interface Margins { + /** 节点布局区域的下边界 */ + bottom?: number + /** 节点布局区域的左边界 */ + left?: number + /** 节点布局区域的右边界 */ + right?: number + /** 节点布局区域的上边界 */ + top?: number + } + /** 匹配到的缓存 */ + interface MatchCache { + /** 缓存 id */ + cacheId: string + /** 缓存创建时间 */ + createTime: number + /** 缓存内容,会带有 fromCache 标记,方便开发者区分内容是否来自缓存 */ + data: any + /** 缓存有效时间 */ + maxAge: number + /** 命中的规则 id */ + ruleId: string + } + /** MediaAudioPlayer 实例,可通过 [wx.createMediaAudioPlayer](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createMediaAudioPlayer.html) 接口获取实例。 */ + interface MediaAudioPlayer { + /** 音量。范围 0~1。默认为 1 */ + volume: number + /** [Promise MediaAudioPlayer.addAudioSource([VideoDecoder](https://developers.weixin.qq.com/miniprogram/dev/api/media/video-decoder/VideoDecoder.html) source)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/MediaAudioPlayer.addAudioSource.html) + * + * 在插件中使用:支持 + * + * 添加音频源 */ + addAudioSource( + /** [VideoDecoder](https://developers.weixin.qq.com/miniprogram/dev/api/media/video-decoder/VideoDecoder.html) + * + * 视频解码器实例。作为音频源添加到音频播放器中 */ + source: VideoDecoder + ): Promise + /** [Promise MediaAudioPlayer.destroy()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/MediaAudioPlayer.destroy.html) + * + * 在插件中使用:支持 + * + * 销毁播放器 */ + destroy(): Promise + /** [Promise MediaAudioPlayer.removeAudioSource([VideoDecoder](https://developers.weixin.qq.com/miniprogram/dev/api/media/video-decoder/VideoDecoder.html) source)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/MediaAudioPlayer.removeAudioSource.html) + * + * 在插件中使用:支持 + * + * 移除音频源 */ + removeAudioSource( + /** [VideoDecoder](https://developers.weixin.qq.com/miniprogram/dev/api/media/video-decoder/VideoDecoder.html) + * + * 视频解码器实例 */ + source: VideoDecoder + ): Promise + /** [Promise MediaAudioPlayer.start()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/MediaAudioPlayer.start.html) + * + * 在插件中使用:支持 + * + * 启动播放器 */ + start(): Promise + /** [Promise MediaAudioPlayer.stop()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/MediaAudioPlayer.stop.html) + * + * 在插件中使用:支持 + * + * 停止播放器 */ + stop(): Promise + } + /** 本地临时文件列表 */ + interface MediaFile { + /** 视频的时间长度 */ + duration: number + /** 文件类型 + * + * 可选值: + * - 'image': 图片; + * - 'video': 视频; */ + fileType: 'image' | 'video' + /** 视频的高度 */ + height: number + /** 本地临时文件大小,单位 B */ + size: number + /** 本地临时文件路径 (本地路径) */ + tempFilePath: string + /** 视频缩略图临时文件路径 */ + thumbTempFilePath: string + /** 视频的宽度 */ + width: number + } + interface MediaQueryObserverObserveCallbackResult { + /** 页面的当前状态是否满足所指定的 media query */ + matches: boolean + } + /** 需要预览的资源列表 */ + interface MediaSource { + /** 图片或视频的地址 */ + url: string + /** 视频的封面图片 */ + poster?: string + /** 资源的类型,默认为图片 + * + * 可选值: + * - 'image': 图片; + * - 'video': 视频; */ + type?: 'image' | 'video' + } + /** 需要基础库: `2.9.0` + * + * 可通过 [MediaContainer.extractDataSource](https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaContainer.extractDataSource.html) 返回。 + * + * [MediaTrack](https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaTrack.html) 音频或视频轨道,可以对轨道进行一些操作 */ + interface MediaTrack { + /** 轨道长度,只读 */ + duration: number + /** 轨道类型,只读 + * + * 可选值: + * - 'audio': 音频轨道; + * - 'video': 视频轨道; */ + kind: 'audio' | 'video' + /** 音量,音频轨道下有效,可写 */ + volume: number + } + /** 小程序账号信息 */ + interface MiniProgram { + /** 小程序 appId */ + appId: string + /** 需要基础库: `2.10.0` + * + * 小程序版本 + * + * 可选值: + * - 'develop': 开发版; + * - 'trial': 体验版; + * - 'release': 正式版; */ + envVersion: 'develop' | 'trial' | 'release' + /** 需要基础库: `2.10.2` + * + * 线上小程序版本号 */ + version: string + } + interface MkdirOption { + /** 创建的目录路径 (本地路径) */ + dirPath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: MkdirCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: MkdirFailCallback + /** 需要基础库: `2.3.0` + * + * 是否在递归创建该目录的上级目录后再创建该目录。如果对应的上级目录已经存在,则不创建该上级目录。如 dirPath 为 a/b/c/d 且 recursive 为 true,将创建 a 目录,再在 a 目录下创建 b 目录,以此类推直至创建 a/b/c 目录下的 d 目录。 */ + recursive?: boolean + /** 接口调用成功的回调函数 */ + success?: MkdirSuccessCallback + } + interface MoveAlongOption { + /** 平滑移动的时间 */ + duration: number + /** 指定 marker */ + markerId: number + /** 移动路径的坐标串,坐标点格式 `{longitude, latitude}` */ + path: any[] + /** 平滑移动触发 map 组件 interpolatepoint 事件的插值精度,单位为 m。默认不触发。 */ + precision: IAnyObject + /** 根据路径方向自动改变 marker 的旋转角度 */ + autoRotate?: boolean + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: MoveAlongCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: MoveAlongFailCallback + /** 接口调用成功的回调函数 */ + success?: MoveAlongSuccessCallback + } + interface MoveToLocationOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: MoveToLocationCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: MoveToLocationFailCallback + /** 需要基础库: `2.8.0` + * + * 纬度 */ + latitude?: number + /** 需要基础库: `2.8.0` + * + * 经度 */ + longitude?: number + /** 接口调用成功的回调函数 */ + success?: MoveToLocationSuccessCallback + } + /** 静音设置 */ + interface MuteConfig { + /** 是否静音耳机 */ + muteEarphone?: boolean + /** 是否静音麦克风 */ + muteMicrophone?: boolean + } + interface MuteOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: MuteCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: MuteFailCallback + /** 接口调用成功的回调函数 */ + success?: MuteSuccessCallback + } + /** 需要基础库: `2.11.2` */ + interface NFCAdapter { + /** 标签类型枚举 */ + tech: TechType + /** [NFCAdapter.offDiscovered(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NFCAdapter.offDiscovered.html) +* +* 需要基础库: `2.11.2` +* +* 在插件中使用:支持 +* +* 移除 NFC Tag的监听函数 +* +* **示例代码** +* +* ```js +const listener = function (res) { console.log(res) } + +NFCAdapter.onDiscovered(listener) +NFCAdapter.offDiscovered(listener) // 需传入与监听时同一个的函数对象 +``` */ + offDiscovered( + /** onDiscovered 传入的监听函数。不传此参数则移除所有监听函数。 */ + listener?: OffDiscoveredCallback + ): void + /** [NFCAdapter.onDiscovered(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NFCAdapter.onDiscovered.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 监听 NFC Tag */ + onDiscovered( + /** 的监听函数 */ + listener: OnDiscoveredCallback + ): void + /** [NFCAdapter.startDiscovery(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NFCAdapter.startDiscovery.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 */ + startDiscovery(option?: StartDiscoveryOption): void + /** [NFCAdapter.stopDiscovery(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NFCAdapter.stopDiscovery.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 */ + stopDiscovery(option?: StopDiscoveryOption): void + /** [[IsoDep](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/IsoDep.html) NFCAdapter.getIsoDep()](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NFCAdapter.getIsoDep.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 获取IsoDep实例,实例支持ISO-DEP (ISO 14443-4)标准的读写 */ + getIsoDep(): IsoDep + /** [[MifareClassic](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/MifareClassic.html) NFCAdapter.getMifareClassic()](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NFCAdapter.getMifareClassic.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 获取MifareClassic实例,实例支持MIFARE Classic标签的读写 */ + getMifareClassic(): MifareClassic + /** [[MifareUltralight](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/MifareUltralight.html) NFCAdapter.getMifareUltralight()](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NFCAdapter.getMifareUltralight.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 获取MifareUltralight实例,实例支持MIFARE Ultralight标签的读写 */ + getMifareUltralight(): MifareUltralight + /** [[Ndef](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/Ndef.html) NFCAdapter.getNdef()](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NFCAdapter.getNdef.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 获取Ndef实例,实例支持对NDEF格式的NFC标签上的NDEF数据的读写 */ + getNdef(): Ndef + /** [[NfcA](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcA.html) NFCAdapter.getNfcA()](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NFCAdapter.getNfcA.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 获取NfcA实例,实例支持NFC-A (ISO 14443-3A)标准的读写 */ + getNfcA(): NfcA + /** [[NfcB](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcB.html) NFCAdapter.getNfcB()](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NFCAdapter.getNfcB.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 获取NfcB实例,实例支持NFC-B (ISO 14443-3B)标准的读写 */ + getNfcB(): NfcB + /** [[NfcF](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcF.html) NFCAdapter.getNfcF()](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NFCAdapter.getNfcF.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 获取NfcF实例,实例支持NFC-F (JIS 6319-4)标准的读写 */ + getNfcF(): NfcF + /** [[NfcV](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcV.html) NFCAdapter.getNfcV()](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NFCAdapter.getNfcV.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 获取NfcV实例,实例支持NFC-V (ISO 15693)标准的读写 */ + getNfcV(): NfcV + } + interface NavigateBackMiniProgramOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: NavigateBackMiniProgramCompleteCallback + /** 需要返回给上一个小程序的数据,上一个小程序可在 `App.onShow` 中获取到这份数据。 [详情](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html)。 */ + extraData?: IAnyObject + /** 接口调用失败的回调函数 */ + fail?: NavigateBackMiniProgramFailCallback + /** 接口调用成功的回调函数 */ + success?: NavigateBackMiniProgramSuccessCallback + } + interface NavigateBackOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: NavigateBackCompleteCallback + /** 返回的页面数,如果 delta 大于现有页面数,则返回到首页。 */ + delta?: number + /** 接口调用失败的回调函数 */ + fail?: NavigateBackFailCallback + /** 接口调用成功的回调函数 */ + success?: NavigateBackSuccessCallback + } + interface NavigateToMiniProgramOption { + /** 要打开的小程序 appId */ + appId?: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: NavigateToMiniProgramCompleteCallback + /** 要打开的小程序版本。仅在当前小程序为开发版或体验版时此参数有效。如果当前小程序是正式版,则打开的小程序必定是正式版。 + * + * 可选值: + * - 'develop': 开发版; + * - 'trial': 体验版; + * - 'release': 正式版; */ + envVersion?: 'develop' | 'trial' | 'release' + /** 需要传递给目标小程序的数据,目标小程序可在 `App.onLaunch`,`App.onShow` 中获取到这份数据。如果跳转的是小游戏,可以在 [wx.onShow](#)、[wx.getLaunchOptionsSync](https://developers.weixin.qq.com/miniprogram/dev/api/base/app/life-cycle/wx.getLaunchOptionsSync.html) 中可以获取到这份数据。 */ + extraData?: IAnyObject + /** 接口调用失败的回调函数 */ + fail?: NavigateToMiniProgramFailCallback + /** 需要基础库: `2.24.0` + * + * 不reLaunch目标小程序,直接打开目标跳转的小程序退后台时的页面,需满足以下条件:1. 目标跳转的小程序生命周期未被销毁;2. 且目标当次启动的path、query与上次启动相同,apiCategory以wx.getApiCategory接口的返回结果为准。 */ + noRelaunchIfPathUnchanged?: boolean + /** 打开的页面路径,如果为空则打开首页。path 中 ? 后面的部分会成为 query,在小程序的 `App.onLaunch`、`App.onShow` 和 `Page.onLoad` 的回调函数或小游戏的 [wx.onShow](#) 回调函数、[wx.getLaunchOptionsSync](https://developers.weixin.qq.com/miniprogram/dev/api/base/app/life-cycle/wx.getLaunchOptionsSync.html) 中可以获取到 query 数据。对于小游戏,可以只传入 query 部分,来实现传参效果,如:传入 "?foo=bar"。 */ + path?: string + /** 需要基础库: `2.18.1` + * + * 小程序链接,当传递该参数后,可以不传 appId 和 path。链接可以通过【小程序菜单】->【复制链接】获取。 */ + shortLink?: string + /** 接口调用成功的回调函数 */ + success?: NavigateToMiniProgramSuccessCallback + } + interface NavigateToOption { + /** 需要跳转的应用内非 tabBar 的页面的路径 (代码包路径), 路径后可以带参数。参数与路径之间使用 `?` 分隔,参数键与参数值用 `=` 相连,不同参数用 `&` 分隔;如 'path?key=value&key2=value2' */ + url: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: NavigateToCompleteCallback + /** 页面间通信接口,用于监听被打开页面发送到当前页面的数据。基础库 2.7.3 开始支持。 */ + events?: IAnyObject + /** 接口调用失败的回调函数 */ + fail?: NavigateToFailCallback + /** 3.4.0 自定义路由配置,相关文档 [自定义路由](https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/skyline/custom-route.html) */ + routeConfig?: IAnyObject + /** 3.4.0 自定义路由参数,相关文档 [自定义路由](https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/skyline/custom-route.html) */ + routeOptions?: IAnyObject + /** 2.29.2 自定义路由类型,相关文档 [自定义路由](https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/skyline/custom-route.html) */ + routeType?: string + /** 接口调用成功的回调函数 */ + success?: NavigateToSuccessCallback + } + interface NavigateToSuccessCallbackResult { + /** [EventChannel](https://developers.weixin.qq.com/miniprogram/dev/api/route/EventChannel.html) + * + * 和被打开页面进行通信 */ + eventChannel: EventChannel + errMsg: string + } + interface NdefCloseOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: NdefCloseCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: NdefCloseFailCallback + /** 接口调用成功的回调函数 */ + success?: NdefCloseSuccessCallback + } + interface NdefConnectOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ConnectCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ConnectFailCallback + /** 接口调用成功的回调函数 */ + success?: ConnectSuccessCallback + } + interface NodeCallbackResult { + /** 节点对应的 Node 实例 */ + node: IAnyObject + } + interface NotifyBLECharacteristicValueChangeOption { + /** 蓝牙特征的 UUID */ + characteristicId: string + /** 蓝牙设备 id */ + deviceId: string + /** 蓝牙特征对应服务的 UUID */ + serviceId: string + /** 是否启用 notify */ + state: boolean + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: NotifyBLECharacteristicValueChangeCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: NotifyBLECharacteristicValueChangeFailCallback + /** 接口调用成功的回调函数 */ + success?: NotifyBLECharacteristicValueChangeSuccessCallback + /** 需要基础库: `2.4.0` + * + * 设置特征订阅类型,有效值有 `notification` 和 `indication` */ + type?: string + } + interface NotifyGroupMembersOption { + /** 文字链跳转路径 */ + entrancePath: string + /** 需要提醒的用户 group_openid 列表 */ + members: string[] + /** 文字链标题,发送的内容将由微信拼接为:@的成员列表+“请完成:”/"请参与:"+打开小程序的文字链,如「@alex @cindy 请完成:团建报名统计」。 */ + title: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: NotifyGroupMembersCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: NotifyGroupMembersFailCallback + /** 接口调用成功的回调函数 */ + success?: NotifyGroupMembersSuccessCallback + /** 展示的动词 + * + * 可选值: + * - 'participate': 请参与; + * - 'complete': 请完成; */ + type?: 'participate' | 'complete' + } + /** 需要基础库: `2.27.0` + * + * OCR检测配置。用法详情[指南文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/ocr.html)。 */ + interface OCRTrack { + /** 需要基础库: `2.27.0` + * + * OCR检测模式 + * + * 可选值: + * - 1: 通过摄像头实时检测; + * - 2: 静态图片检测; */ + mode: 1 | 2 + } + /** media query 描述符 */ + interface ObserveDescriptor { + /** 页面高度( px 为单位) */ + height?: number + /** 页面最大高度( px 为单位) */ + maxHeight?: number + /** 页面最大宽度( px 为单位) */ + maxWidth?: number + /** 页面最小高度( px 为单位) */ + minHeight?: number + /** 页面最小宽度( px 为单位) */ + minWidth?: number + /** 屏幕方向( `landscape` 或 `portrait` ) */ + orientation?: string + /** 页面宽度( px 为单位) */ + width?: number + } + /** 设置 type 监听单个类型的指标,设置 entryTypes 监听多个类型指标。 */ + interface ObserveOption { + /** 指标类型列表。不能和 type 同时使用。 */ + entryTypes?: string[] + /** 指标类型。不能和 entryTypes 同时使用 + * + * 可选值: + * - 'navigation': 路由; + * - 'render': 渲染; + * - 'script': 脚本; + * - 'loadPackage': 代码包下载; */ + type?: 'navigation' | 'render' | 'script' | 'loadPackage' + } + /** 需要基础库: `2.7.0` + * + * 离屏 canvas 实例,可通过 [wx.createOffscreenCanvas](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.createOffscreenCanvas.html) 创建。 */ + interface OffscreenCanvas { + /** 画布高度 */ + height: number + /** 画布宽度 */ + width: number + /** [[Image](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Image.html) OffscreenCanvas.createImage()](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/OffscreenCanvas.createImage.html) + * + * 需要基础库: `2.7.3` + * + * 在插件中使用:需要基础库 `2.16.1` + * + * 创建一个图片对象。支持在 2D Canvas 和 WebGL Canvas 下使用, 但不支持混用 2D 和 WebGL 的方法。 + * + * **** + * + * 注意不允许混用 webgl 和 2d 画布创建的图片对象,使用时请注意尽量使用 canvas 自身的 `createImage` 创建图片对象。 */ + createImage(): Image + /** [[RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) OffscreenCanvas.getContext(string contextType)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/OffscreenCanvas.getContext.html) + * + * 需要基础库: `2.7.0` + * + * 在插件中使用:需要基础库 `2.16.1` + * + * 该方法返回 OffscreenCanvas 的绘图上下文 + * + * **** + * + * 注意不允许混用 webgl 和 2d 绘图上下文,传入的 contextType 必须要与 `wx.createOffscreenCanvas` 传入的 type 类型一致。 */ + getContext( + /** 绘图上下文类型,需要与 createOffscreenCanvas 时传入的 type 一致 + * + * 参数 contextType 可选值: + * - 'webgl': webgl类型上下文; + * - '2d': 2d类型上下文; */ + contextType: 'webgl' | '2d' + ): any + } + interface OnAccelerometerChangeListenerResult { + /** X 轴 */ + x: number + /** Y 轴 */ + y: number + /** Z 轴 */ + z: number + } + interface OnAfterPageLoadListenerResult { + /** 组件框架 + * + * 可选值: + * - 'exparser': 旧版小程序组件框架; + * - 'glass-easel': 新版小程序组件框架; */ + componentFramework: 'exparser' | 'glass-easel' + /** 路由打开类型 */ + openType: string + /** 页面实例 */ + page: IAnyObject + /** 页面路径 */ + path: string + /** 路由参数 */ + query: IAnyObject + /** 路由事件 id */ + routeEventId: string + } + interface OnAfterPageUnloadListenerResult { + /** 页面路径 */ + path: string + /** 路由事件 id */ + routeEventId: string + } + interface OnApiCategoryChangeListenerResult { + /** API 类别 + * + * 可选值: + * - 'default': 默认类别; + * - 'nativeFunctionalized': 原生功能化,视频号直播商品、商品橱窗等场景打开的小程序; + * - 'browseOnly': 仅浏览,朋友圈快照页等场景打开的小程序; + * - 'embedded': 内嵌,通过打开半屏小程序能力打开的小程序; + * - 'chatTool': 聊天工具打开小程序; */ + apiCategory: + | 'default' + | 'nativeFunctionalized' + | 'browseOnly' + | 'embedded' + | 'chatTool' + } + interface OnAppRouteDoneListenerResult { + /** 路由打开类型 */ + openType: string + /** 页面路径 */ + path: string + /** 路由参数 */ + query: IAnyObject + /** 路由事件 id */ + routeEventId: string + /** 路由下发的时间戳 */ + timeStamp: number + /** 当前页面 id */ + webviewId: number + } + interface OnAppRouteListenerResult { + /** 是否未找到页面 */ + notFound: boolean + /** 路由打开类型 */ + openType: string + /** 当前打开页面的相关配置 */ + page: IAnyObject + /** 页面路径 */ + path: string + /** 可选值: + * - 'min': 视频页面缩小为小窗; + * - 'max': 视频小窗还原为页面; */ + pipMode: 'min' | 'max' + /** 路由参数 */ + query: IAnyObject + /** 渲染引擎 + * + * 可选值: + * - 'webview': Webview 渲染引擎; + * - 'skyline': Skyline 渲染引擎; + * - 'xr-frame': xr-frame 解决方案; */ + renderer: 'webview' | 'skyline' | 'xr-frame' + /** 路由事件 id */ + routeEventId: string + /** 路由下发的时间戳 */ + timeStamp: number + /** 当前页面 id */ + webviewId: number + } + interface OnBLECharacteristicValueChangeListenerResult { + /** 蓝牙特征的 UUID */ + characteristicId: string + /** 蓝牙设备 id */ + deviceId: string + /** 蓝牙特征对应服务的 UUID */ + serviceId: string + /** 特征最新的值 */ + value: ArrayBuffer + } + interface OnBLEConnectionStateChangeListenerResult { + /** 是否处于已连接状态 */ + connected: boolean + /** 蓝牙设备 id */ + deviceId: string + } + interface OnBLEMTUChangeListenerResult { + /** 蓝牙设备 id */ + deviceId: string + /** 最大传输单元 */ + mtu: number + } + interface OnBLEPeripheralConnectionStateChangedListenerResult { + /** 连接目前状态 */ + connected: boolean + /** 连接状态变化的设备 id */ + deviceId: string + /** server 的 UUID */ + serverId: string + } + interface OnBackgroundFetchDataListenerResult { + /** 缓存数据类别,取值为 periodic 或 pre */ + fetchType: string + /** 缓存数据 */ + fetchedData: string + /** 小程序页面路径 */ + path: string + /** 传给页面的 query 参数 */ + query: string + /** 进入小程序的场景值 */ + scene: number + /** 客户端拿到缓存数据的时间戳 */ + timeStamp: number + } + interface OnBatteryInfoChangeListenerResult { + /** 是否处于省电模式 */ + isLowPowerModeEnabled: boolean + } + interface OnBeaconServiceChangeListenerResult { + /** 服务目前是否可用 */ + available: boolean + /** 目前是否处于搜索状态 */ + discovering: boolean + } + interface OnBeaconUpdateListenerResult { + /** 当前搜寻到的所有 Beacon 设备列表 */ + beacons: BeaconInfo[] + } + interface OnBeforeAppRouteListenerResult { + /** 是否未找到页面 */ + notFound: boolean + /** 路由打开类型 */ + openType: string + /** 当前打开页面的相关配置 */ + page: IAnyObject + /** 页面路径 */ + path: string + /** 可选值: + * - 'min': 视频页面缩小为小窗; + * - 'max': 视频小窗还原为页面; */ + pipMode: 'min' | 'max' + /** 路由参数 */ + query: IAnyObject + /** 渲染引擎 + * + * 可选值: + * - 'webview': Webview 渲染引擎; + * - 'skyline': Skyline 渲染引擎; + * - 'xr-frame': xr-frame 解决方案; */ + renderer: 'webview' | 'skyline' | 'xr-frame' + /** 路由事件 id */ + routeEventId: string + /** 当前页面 id */ + webviewId: number + } + interface OnBeforePageLoadListenerResult { + /** 组件框架 + * + * 可选值: + * - 'exparser': 旧版小程序组件框架; + * - 'glass-easel': 新版小程序组件框架; */ + componentFramework: 'exparser' | 'glass-easel' + /** 路由打开类型 */ + openType: string + /** 页面路径 */ + path: string + /** 路由参数 */ + query: IAnyObject + /** 路由事件 id */ + routeEventId: string + } + interface OnBeforePageUnloadListenerResult { + /** 页面实例 */ + page: IAnyObject + /** 页面路径 */ + path: string + /** 路由事件 id */ + routeEventId: string + } + interface OnBluetoothAdapterStateChangeListenerResult { + /** 蓝牙适配器是否可用 */ + available: boolean + /** 蓝牙适配器是否处于搜索状态 */ + discovering: boolean + } + interface OnBluetoothDeviceFoundListenerResult { + /** 新搜索到的设备列表 */ + devices: BlueToothDevice[] + } + interface OnCameraFrameCallbackResult { + /** 图像像素点数据,一维数组,每四项表示一个像素点的 rgba */ + data: ArrayBuffer + /** 图像数据矩形的高度 */ + height: number + /** 图像数据矩形的宽度 */ + width: number + } + interface OnCharacteristicReadRequestListenerResult { + /** 唯一标识码,调用 [writeCharacteristicValue](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.writeCharacteristicValue.html) 时使用 */ + callbackId: number + /** 蓝牙特征的 UUID */ + characteristicId: string + /** 蓝牙特征对应服务的 UUID */ + serviceId: string + } + interface OnCharacteristicSubscribedListenerResult { + /** 蓝牙特征的 UUID */ + characteristicId: string + /** 蓝牙特征对应服务的 UUID */ + serviceId: string + } + interface OnCharacteristicWriteRequestListenerResult { + /** 唯一标识码,调用 [writeCharacteristicValue](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.writeCharacteristicValue.html) 时使用 */ + callbackId: number + /** 蓝牙特征的 UUID */ + characteristicId: string + /** 蓝牙特征对应服务的 UUID */ + serviceId: string + /** 请求写入特征的二进制数据值 */ + value: ArrayBuffer + } + interface OnCheckForUpdateListenerResult { + /** 是否有新版本 */ + hasUpdate: boolean + } + interface OnChunkReceivedListenerResult { + /** 返回的chunk buffer */ + data: ArrayBuffer + } + interface OnCompassChangeListenerResult { + /** 需要基础库: `2.4.0` + * + * 精度 */ + accuracy: number | string + /** 面对的方向度数 */ + direction: number + } + interface OnConnectListenerResult { + /** 需要基础库: `3.4.0` + * + * 网络请求过程中的一些异常信息(例如:TCPSocket.connect 传了 enableHttpDNS: true,但最终未使用 HttpDNS 时,exception 就会说明未使用 HttpDNS 的原因) */ + exception: Exception + /** 需要基础库: `3.4.1` + * + * 接收端地址信息(目前仅iOS和Android端支持) */ + localInfo: OnConnectListenerResultLocalInfo + /** 需要基础库: `3.4.1` + * + * 发送端地址信息(目前仅iOS和Android端支持) */ + remoteInfo: OnConnectListenerResultRemoteInfo + /** 需要基础库: `3.4.0` + * + * 本次连接是否使用了 HttpDNS */ + useHttpDNS: boolean + } + /** 需要基础库: `3.4.1` + * + * 接收端地址信息(目前仅iOS和Android端支持) */ + interface OnConnectListenerResultLocalInfo { + /** 需要基础库: `3.4.1` + * + * 接收消息的 socket 的地址 */ + address: string + /** 需要基础库: `3.4.1` + * + * 使用的协议族,为 IPv4 或者 IPv6 */ + family: string + /** 需要基础库: `3.4.1` + * + * 端口号 */ + port: number + } + /** 需要基础库: `3.4.1` + * + * 发送端地址信息(目前仅iOS和Android端支持) */ + interface OnConnectListenerResultRemoteInfo { + /** 需要基础库: `3.4.1` + * + * 发送消息的 socket 的地址 */ + address: string + /** 需要基础库: `3.4.1` + * + * 使用的协议族,为 IPv4 或者 IPv6 */ + family: string + /** 需要基础库: `3.4.1` + * + * 端口号 */ + port: number + } + interface OnCopyUrlListenerResult { + /** 用短链打开小程序时当前页面携带的查询字符串。小程序中使用时,应在进入页面时调用 `wx.onCopyUrl` 自定义 `query`,退出页面时调用 `wx.offCopyUrl`,防止影响其它页面。 */ + query: string + } + interface OnCustomRendererEventCallbackResult { + /** 推流高度 */ + height: number + /** 推流宽度 */ + width: number + } + interface OnDeviceMotionChangeListenerResult { + /** 当 手机坐标 X/Y 和 地球 X/Y 重合时,绕着 Z 轴转动的夹角为 alpha,范围值为 [0, 2*PI)。逆时针转动为正。 */ + alpha: number + /** 当手机坐标 Y/Z 和地球 Y/Z 重合时,绕着 X 轴转动的夹角为 beta。范围值为 [-1*PI, PI) 。顶部朝着地球表面转动为正。也有可能朝着用户为正。 */ + beta: number + /** 当手机 X/Z 和地球 X/Z 重合时,绕着 Y 轴转动的夹角为 gamma。范围值为 [-1*PI/2, PI/2)。右边朝着地球表面转动为正。 */ + gamma: number + } + interface OnDiscoveredListenerResult { + id: ArrayBuffer + /** 可选,NdefMessage 数组,消息格式为 {id: ArrayBuffer, type: ArrayBuffer, payload: ArrayBuffer} */ + messages: any[] + /** tech 数组,用于匹配NFC卡片具体可以使用什么标准(NfcA等实例)处理 */ + techs: any[] + } + interface OnEmbeddedMiniProgramHeightChangeListenerResult { + /** 可视高度 */ + height: number + /** 半屏小程序初始高度 */ + initialHeight: number + } + interface OnFrameRecordedListenerResult { + /** 录音分片数据 */ + frameBuffer: ArrayBuffer + /** 当前帧是否正常录音结束前的最后一帧 */ + isLastFrame: boolean + } + interface OnGetWifiListListenerResult { + /** Wi-Fi 列表数据 */ + wifiList: WifiInfo[] + } + interface OnGyroscopeChangeListenerResult { + /** x 轴的角速度 */ + x: number + /** y 轴的角速度 */ + y: number + /** z 轴的角速度 */ + z: number + } + interface OnHCEMessageListenerResult { + /** `messageType=1` 时 ,客户端接收到 NFC 设备的指令 */ + data: ArrayBuffer + /** 消息类型 + * + * 可选值: + * - 1: HCE APDU Command类型,小程序需对此指令进行处理,并调用 sendHCEMessage 接口返回处理指令; + * - 2: 设备离场事件类型; */ + messageType: 1 | 2 + /** `messageType=2` 时,原因 */ + reason: number + } + interface OnKeyDownListenerResult { + /** 当前是否同时按下了 altKey,同 Web 规范 KeyEvent altKey 属性 */ + altKey: string + /** 按键 code,同 Web 规范 KeyEvent code 属性 */ + code: string + /** 按键名称,同 Web 规范 KeyEvent key 属性 */ + key: string + /** 当前是否同时按下了 shiftKey,同 Web 规范 KeyEvent shiftKey 属性 */ + shiftKey: string + /** 事件触发时的时间戳 */ + timeStamp: number + } + interface OnKeyboardHeightChangeListenerResult { + /** 键盘高度 */ + height: number + } + interface OnLazyLoadErrorListenerResult { + /** 详细信息 */ + errMsg: string + /** 异步组件所属的分包 */ + subpackage: any[] + /** 'subpackage' 失败类型 */ + type: string + } + interface OnLocalServiceFoundListenerResult { + /** 服务的 ip 地址 */ + ip: string + /** 服务的端口 */ + port: number + /** 服务的名称 */ + serviceName: string + /** 服务的类型 */ + serviceType: string + } + interface OnLocalServiceLostListenerResult { + /** 服务的名称 */ + serviceName: string + /** 服务的类型 */ + serviceType: string + } + interface OnLocationChangeErrorListenerResult { + /** 错误码 */ + errCode: number + } + interface OnLocationChangeListenerResult { + /** 位置的精确度 */ + accuracy: number + /** 需要基础库: `1.2.0` + * + * 高度,单位 m */ + altitude: number + /** 需要基础库: `1.2.0` + * + * 水平精度,单位 m */ + horizontalAccuracy: number + /** 纬度,范围为 -90~90,负数表示南纬。使用 gcj02 国测局坐标系 */ + latitude: number + /** 经度,范围为 -180~180,负数表示西经。使用 gcj02 国测局坐标系 */ + longitude: number + /** 速度,单位 m/s */ + speed: number + /** 需要基础库: `1.2.0` + * + * 垂直精度,单位 m(Android 无法获取,返回 0) */ + verticalAccuracy: number + } + interface OnMemoryWarningListenerResult { + /** 内存告警等级,只有 Android 才有,对应系统宏定义 + * + * 可选值: + * - 5: TRIM_MEMORY_RUNNING_MODERATE; + * - 10: TRIM_MEMORY_RUNNING_LOW; + * - 15: TRIM_MEMORY_RUNNING_CRITICAL; */ + level: 5 | 10 | 15 + } + interface OnMenuButtonBoundingClientRectWeightChangeListenerResult { + /** 下边界坐标,单位:px */ + bottom: number + /** 高度,单位:px */ + height: number + /** 左边界坐标,单位:px */ + left: number + /** 右边界坐标,单位:px */ + right: number + /** 上边界坐标,单位:px */ + top: number + /** 宽度,单位:px */ + width: number + } + interface OnMessageListenerResultLocalInfo { + /** 接收消息的 socket 的地址 */ + address: string + /** 使用的协议族,为 IPv4 或者 IPv6 */ + family: string + /** 端口号 */ + port: number + } + interface OnNeedPrivacyAuthorizationListenerResult {} + interface OnNetworkStatusChangeListenerResult { + /** 当前是否有网络连接 */ + isConnected: boolean + /** 网络类型 + * + * 可选值: + * - 'wifi': wifi 网络; + * - '2g': 2g 网络; + * - '3g': 3g 网络; + * - '4g': 4g 网络; + * - '5g': 5g 网络; + * - 'unknown': Android 下不常见的网络类型; + * - 'none': 无网络; */ + networkType: 'wifi' | '2g' | '3g' | '4g' | '5g' | 'unknown' | 'none' + } + interface OnNetworkWeakChangeListenerResult { + /** 当前网络类型 */ + networkType: string + /** 当前是否处于弱网状态 */ + weakNet: boolean + } + interface OnOnUserTriggerTranslationListenerResult { + /** 翻译到的目标语言 */ + locale: string + /** 触发来源, `button` 表示点击了菜单中的翻译按钮, `capsule` 表示点击了胶囊中的翻译提示 */ + type: string + } + interface OnOpenListenerResult { + /** 需要基础库: `2.0.0` + * + * 连接成功的 HTTP 响应 Header */ + header: IAnyObject + /** 需要基础库: `2.10.4` + * + * 网络请求过程中一些调试信息 */ + profile: SocketProfile + } + interface OnPageNotFoundListenerResult { + /** 是否本次启动的首个页面(例如从分享等入口进来,首个页面是开发者配置的分享页面) */ + isEntryPage: boolean + /** 不存在页面的路径 (代码包路径) */ + path: string + /** 打开不存在页面的 query 参数 */ + query: Record + } + interface OnScreenRecordingStateChangedListenerResult { + /** 录屏状态 + * + * 可选值: + * - 'start': 开始录屏; + * - 'stop': 结束录屏; */ + state: 'start' | 'stop' + } + interface OnSocketOpenListenerResult { + /** 需要基础库: `2.0.0` + * + * 连接成功的 HTTP 响应 Header */ + header: IAnyObject + } + interface OnStopListenerResult { + /** 录音总时长,单位:ms */ + duration: number + /** 录音文件大小,单位:Byte */ + fileSize: number + /** 录音文件的临时路径 (本地路径) */ + tempFilePath: string + } + interface OnThemeChangeListenerResult { + /** 系统当前的主题,取值为`light`或`dark` + * + * 可选值: + * - 'dark': 深色主题; + * - 'light': 浅色主题; */ + theme: 'dark' | 'light' + } + interface OnUnhandledRejectionListenerResult { + /** 被拒绝的 Promise 对象 */ + promise: Promise + /** 拒绝原因,一般是一个 Error 对象 */ + reason: string + } + interface OnUserCaptureScreenListenerResult { + /** 需要基础库: `3.3.0` + * + * 如果该参数存在,则其它的参数将会以 resolve 结果为准,如果一秒内不 resolve,分享会使用上面传入的默认参数 */ + promise?: Promise + /** 需要基础库: `3.3.0` + * + * 支持开发者自定义一键打开小程序时的 query */ + query?: string + } + interface OnVoIPChatInterruptedListenerResult { + /** 错误码 */ + errCode: number + /** 调用结果(错误原因) */ + errMsg: string + } + interface OnVoIPChatMembersChangedListenerResult { + /** 错误码 */ + errCode: number + /** 调用结果 */ + errMsg: string + /** 还在实时语音通话中的成员 openId 名单 */ + openIdList: string[] + } + interface OnVoIPChatSpeakersChangedListenerResult { + /** 错误码 */ + errCode: number + /** 调用结果(错误原因) */ + errMsg: string + /** 还在实时语音通话中的成员 openId 名单 */ + openIdList: string[] + } + interface OnVoIPChatStateChangedListenerResult { + /** 事件码 */ + code: number + /** 附加信息 */ + data: IAnyObject + /** 错误码 */ + errCode: number + /** 调用结果 */ + errMsg: string + } + interface OnVoIPVideoMembersChangedListenerResult { + /** 错误码 */ + errCode: number + /** 调用结果 */ + errMsg: string + /** 开启视频的成员名单 */ + openIdList: string[] + } + interface OnWifiConnectedListenerResult { + /** [WifiInfo](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/WifiInfo.html) + * + * Wi-Fi 信息 */ + wifi: WifiInfo + } + interface OnWifiConnectedWithPartialInfoListenerResult { + /** [WifiInfo](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/WifiInfo.html) + * + * 只包含 SSID 属性的 WifiInfo 对象 */ + wifi: WifiInfo + } + interface OnWindowResizeListenerResult { + size: Size + } + interface OnWindowStateChangeListenerResult { + /** 改变的窗口状态,可能的值为: + * - 'minimize':窗口最小化 + * - 'normalize':窗口恢复正常尺寸 + * - 'maximize':窗口最大化 */ + state: string + } + interface OpenAppAuthorizeSettingOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenAppAuthorizeSettingCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenAppAuthorizeSettingFailCallback + /** 接口调用成功的回调函数 */ + success?: OpenAppAuthorizeSettingSuccessCallback + } + interface OpenBluetoothAdapterOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenBluetoothAdapterCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenBluetoothAdapterFailCallback + /** 需要基础库: `2.10.0` + * + * 蓝牙模式,可作为主/从设备,仅 iOS 需要。 + * + * 可选值: + * - 'central': 主机模式; + * - 'peripheral': 从机(外围设备)模式; */ + mode?: 'central' | 'peripheral' + /** 接口调用成功的回调函数 */ + success?: OpenBluetoothAdapterSuccessCallback + } + interface OpenCardOption { + /** 需要打开的卡券列表 */ + cardList: OpenCardRequestInfo[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenCardCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenCardFailCallback + /** 接口调用成功的回调函数 */ + success?: OpenCardSuccessCallback + } + /** 需要打开的卡券列表 */ + interface OpenCardRequestInfo { + /** 卡券 ID */ + cardId: string + /** 由 [wx.addCard](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/card/wx.addCard.html) 的返回对象中的加密 code 通过解密后得到,解密请参照:[code 解码接口](https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1499332673_Unm7V) */ + code: string + } + interface OpenChannelsActivityOption { + /** 视频 feedId */ + feedId: string + /** 视频号 id,以“sph”开头的id,可在视频号助手获取 */ + finderUserName: string + /** 视频号的Feed的nonceId,必填 */ + nonceId: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenChannelsActivityCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenChannelsActivityFailCallback + /** 接口调用成功的回调函数 */ + success?: OpenChannelsActivitySuccessCallback + } + interface OpenChannelsEventOption { + /** 活动 id */ + eventId: string + /** 视频号 id,以“sph”开头的id,可在视频号助手获取 */ + finderUserName: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenChannelsEventCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenChannelsEventFailCallback + /** 接口调用成功的回调函数 */ + success?: OpenChannelsEventSuccessCallback + } + interface OpenChannelsLiveOption { + /** 视频号 id,以“sph”开头的id,可在视频号助手获取 */ + finderUserName: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenChannelsLiveCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenChannelsLiveFailCallback + /** 直播 feedId,通过 getChannelsLiveInfo 接口获取(基础库 v2.19.2 之前的版本需要填写) */ + feedId?: string + /** 直播 nonceId,通过 getChannelsLiveInfo 接口获取(基础库 v2.19.2 之前的版本需要填写) */ + nonceId?: string + /** 接口调用成功的回调函数 */ + success?: OpenChannelsLiveSuccessCallback + } + interface OpenChannelsUserProfileOption { + /** 视频号 id */ + finderUserName: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenChannelsUserProfileCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenChannelsUserProfileFailCallback + /** 接口调用成功的回调函数 */ + success?: OpenChannelsUserProfileSuccessCallback + } + interface OpenChatToolOption { + /** 聊天工具分包内的页面路径 */ + url: string + /** 群聊类型 + * + * 可选值: + * - 1: 微信联系人单聊; + * - 2: 企业微信联系人单聊; + * - 3: 普通微信群聊; + * - 4: 企业微信互通群聊; */ + chatType?: 1 | 2 | 3 | 4 + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenChatToolCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenChatToolFailCallback + /** 聊天室 id,不传则拉起群选择框,可以传入多聊群的 opengid 值,或者单聊群的 open_single_roomid 值 */ + roomid?: string + /** 接口调用成功的回调函数 */ + success?: OpenChatToolSuccessCallback + } + interface OpenCustomerServiceChatOption { + /** 企业ID */ + corpId: string + /** 客服信息 */ + extInfo: ExtInfoOption + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenCustomerServiceChatCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenCustomerServiceChatFailCallback + /** 气泡消息图片 */ + sendMessageImg?: string + /** 气泡消息小程序路径 */ + sendMessagePath?: string + /** 气泡消息标题 */ + sendMessageTitle?: string + /** 是否发送小程序气泡消息 */ + showMessageCard?: boolean + /** 接口调用成功的回调函数 */ + success?: OpenCustomerServiceChatSuccessCallback + } + interface OpenDocumentOption { + /** 文件路径 (本地路径) ,可通过 downloadFile 获得 */ + filePath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenDocumentCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenDocumentFailCallback + /** 需要基础库: `1.4.0` + * + * 文件类型,指定文件类型打开文件 + * + * 可选值: + * - 'doc': doc 格式; + * - 'docx': docx 格式; + * - 'xls': xls 格式; + * - 'xlsx': xlsx 格式; + * - 'ppt': ppt 格式; + * - 'pptx': pptx 格式; + * - 'pdf': pdf 格式; */ + fileType?: 'doc' | 'docx' | 'xls' | 'xlsx' | 'ppt' | 'pptx' | 'pdf' + /** 需要基础库: `2.11.0` + * + * 是否显示右上角菜单 */ + showMenu?: boolean + /** 接口调用成功的回调函数 */ + success?: OpenDocumentSuccessCallback + } + interface OpenEmbeddedMiniProgramOption { + /** 要打开的小程序 appId */ + appId: string + /** 需要基础库: `2.33.0` + * + * 打开的小程序是否支持全屏 */ + allowFullScreen?: boolean + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenEmbeddedMiniProgramCompleteCallback + /** 要打开的小程序版本。仅在当前小程序为开发版或体验版时此参数有效。如果当前小程序是正式版,则打开的小程序必定是正式版。 + * + * 可选值: + * - 'develop': 开发版; + * - 'trial': 体验版; + * - 'release': 正式版; */ + envVersion?: 'develop' | 'trial' | 'release' + /** 需要传递给目标小程序的数据,目标小程序可在 `App.onLaunch`,`App.onShow` 中获取到这份数据。如果跳转的是小游戏,可以在 [wx.onShow](#)、[wx.getLaunchOptionsSync](https://developers.weixin.qq.com/miniprogram/dev/api/base/app/life-cycle/wx.getLaunchOptionsSync.html) 中可以获取到这份数据数据。 */ + extraData?: IAnyObject + /** 接口调用失败的回调函数 */ + fail?: OpenEmbeddedMiniProgramFailCallback + /** 需要基础库: `2.24.0` + * + * 不reLaunch目标小程序,直接打开目标跳转的小程序退后台时的页面,需满足以下条件:1. 目标跳转的小程序生命周期未被销毁;2. 且目标当次启动的path、query与上次启动相同,apiCategory以wx.getApiCategory接口的返回结果为准。 */ + noRelaunchIfPathUnchanged?: boolean + /** 打开的页面路径,如果为空则打开首页。path 中 ? 后面的部分会成为 query,在小程序的 `App.onLaunch`、`App.onShow` 和 `Page.onLoad` 的回调函数或小游戏的 [wx.onShow](#) 回调函数、[wx.getLaunchOptionsSync](https://developers.weixin.qq.com/miniprogram/dev/api/base/app/life-cycle/wx.getLaunchOptionsSync.html) 中可以获取到 query 数据。对于小游戏,可以只传入 query 部分,来实现传参效果,如:传入 "?foo=bar"。 */ + path?: string + /** 小程序链接,当传递该参数后,可以不传 appId 和 path。链接可以通过【小程序菜单】->【复制链接】获取。仅 verify=binding 支持。 */ + shortLink?: string + /** 接口调用成功的回调函数 */ + success?: OpenEmbeddedMiniProgramSuccessCallback + /** 需要基础库: `2.24.3` + * + * 校验方式。 + * + * 可选值: + * - 'binding': 校验小程序管理后台的绑定关系。; + * - 'unionProduct': 校验目标打开链接是否为[小程序联盟](https://developers.weixin.qq.com/doc/ministore/union/brief-introduction.html)商品。; */ + verify?: 'binding' | 'unionProduct' + } + interface OpenHKOfflinePayViewOption { + /** 随机字符串,长度为32个字符以下 */ + nonceStr: string + /** 业务数据包,开发者目前无需感知,直接传空字符串即可 */ + package: string + /** 签名,具体见微信支付文档 */ + paySign: string + /** 时间戳,从 1970 年 1 月 1 日 00:00:00 至今的秒数,即当前的时间 */ + timeStamp: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenHKOfflinePayViewCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenHKOfflinePayViewFailCallback + /** 签名算法,应与后台下单时的值一致,目前仅支持 SHA1 + * + * 可选值: + * - 'SHA1': SHA1签名算法; */ + signType?: 'SHA1' + /** 接口调用成功的回调函数 */ + success?: OpenHKOfflinePayViewSuccessCallback + } + interface OpenLocationOption { + /** 纬度,范围为-90~90,负数表示南纬。使用 gcj02 国测局坐标系 */ + latitude: number + /** 经度,范围为-180~180,负数表示西经。使用 gcj02 国测局坐标系 */ + longitude: number + /** 地址的详细说明 */ + address?: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenLocationCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenLocationFailCallback + /** 位置名 */ + name?: string + /** 缩放比例,范围5~18 */ + scale?: number + /** 接口调用成功的回调函数 */ + success?: OpenLocationSuccessCallback + } + interface OpenMapAppOption { + /** 目的地名称 */ + destination: string + /** 目的地纬度 */ + latitude: number + /** 目的地经度 */ + longitude: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenMapAppCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenMapAppFailCallback + /** 接口调用成功的回调函数 */ + success?: OpenMapAppSuccessCallback + } + interface OpenMethodPickerOption { + /** 交易金额对象 */ + amount: AmountOption + } + interface OpenOfficialAccountArticleFailCallbackErr { + /** 错误码 */ + errCode: number + /** 错误信息 */ + errMsg: string + } + interface OpenOfficialAccountArticleOption { + /** 需要打开的公众号地址 */ + url: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenOfficialAccountArticleCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenOfficialAccountArticleFailCallback + /** 接口调用成功的回调函数 */ + success?: OpenOfficialAccountArticleSuccessCallback + } + interface OpenOfficialAccountArticleSuccessCallbackResult { + /** 为 true 时,表示用户点击了取消(用于 Android 系统区分点击蒙层关闭还是点击取消按钮关闭) */ + cancel: boolean + /** 为 true 时,表示用户点击了确定按钮 */ + confirm: boolean + errMsg: string + } + interface OpenOfficialAccountProfileOption { + /** 需要打开的公众号的微信号 */ + username: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenOfficialAccountProfileCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenOfficialAccountProfileFailCallback + /** 接口调用成功的回调函数 */ + success?: OpenOfficialAccountProfileSuccessCallback + } + interface OpenOption { + /** 文件路径 (本地路径) */ + filePath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenFailCallback + /** 文件系统标志,默认值: 'r' + * + * 可选值: + * - 'a': 打开文件用于追加。 如果文件不存在,则创建该文件; + * - 'ax': 类似于 'a',但如果路径存在,则失败; + * - 'a+': 打开文件用于读取和追加。 如果文件不存在,则创建该文件; + * - 'ax+': 类似于 'a+',但如果路径存在,则失败; + * - 'as': 打开文件用于追加(在同步模式中)。 如果文件不存在,则创建该文件; + * - 'as+': 打开文件用于读取和追加(在同步模式中)。 如果文件不存在,则创建该文件; + * - 'r': 打开文件用于读取。 如果文件不存在,则会发生异常; + * - 'r+': 打开文件用于读取和写入。 如果文件不存在,则会发生异常; + * - 'w': 打开文件用于写入。 如果文件不存在则创建文件,如果文件存在则截断文件; + * - 'wx': 类似于 'w',但如果路径存在,则失败; + * - 'w+': 打开文件用于读取和写入。 如果文件不存在则创建文件,如果文件存在则截断文件; + * - 'wx+': 类似于 'w+',但如果路径存在,则失败; */ + flag?: + | 'a' + | 'ax' + | 'a+' + | 'ax+' + | 'as' + | 'as+' + | 'r' + | 'r+' + | 'w' + | 'wx' + | 'w+' + | 'wx+' + /** 接口调用成功的回调函数 */ + success?: OpenSuccessCallback + } + interface OpenPrivacyContractOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenPrivacyContractCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenPrivacyContractFailCallback + /** 接口调用成功的回调函数 */ + success?: OpenPrivacyContractSuccessCallback + } + interface OpenSettingOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenSettingCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenSettingFailCallback + /** 接口调用成功的回调函数 */ + success?: OpenSettingSuccessCallback + /** 需要基础库: `2.10.3` + * + * 是否同时获取用户订阅消息的订阅状态,默认不获取。注意:withSubscriptions 只返回用户勾选过订阅面板中的“总是保持以上选择,不再询问”的订阅消息。 */ + withSubscriptions?: boolean + } + interface OpenSettingSuccessCallbackResult { + /** [AuthSetting](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/setting/AuthSetting.html) + * + * 用户授权结果 */ + authSetting: AuthSetting + /** [SubscriptionsSetting](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/setting/SubscriptionsSetting.html) + * + * 需要基础库: `2.10.3` + * + * 用户订阅消息设置,接口参数`withSubscriptions`值为`true`时才会返回。 */ + subscriptionsSetting: SubscriptionsSetting + errMsg: string + } + interface OpenSingleStickerViewOption { + /** 表情链接,可前往[表情开放平台](https://sticker.weixin.qq.com/cgi-bin/mmemoticon-bin/loginpage?t=login/index),在详情页中的「小程序跳转链接」入口复制 */ + url: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenSingleStickerViewCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenSingleStickerViewFailCallback + /** 接口调用成功的回调函数 */ + success?: OpenSingleStickerViewSuccessCallback + } + interface OpenStickerIPViewOption { + /** 表情IP合辑链接,可前往[表情开放平台](https://sticker.weixin.qq.com/cgi-bin/mmemoticon-bin/loginpage?t=login/index),在详情页中的「小程序跳转链接」入口复制 */ + url: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenStickerIPViewCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenStickerIPViewFailCallback + /** 接口调用成功的回调函数 */ + success?: OpenStickerIPViewSuccessCallback + } + interface OpenStickerSetViewOption { + /** 表情专辑链接,可前往[表情开放平台](https://sticker.weixin.qq.com/cgi-bin/mmemoticon-bin/loginpage?t=login/index),在详情页中的「小程序跳转链接」入口复制 */ + url: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenStickerSetViewCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenStickerSetViewFailCallback + /** 接口调用成功的回调函数 */ + success?: OpenStickerSetViewSuccessCallback + } + interface OpenStoreCouponDetailFailCallbackResult { + /** 错误码 */ + code: number + /** 错误信息 */ + message: string + } + interface OpenStoreCouponDetailOption { + /** 优惠券id,可以通过[小店后台](https://store.weixin.qq.com/shop/marketing/coupon)获取 */ + couponId: string + /** 小店appid,可以通过[小店后台](https://store.weixin.qq.com/shop/setting/home)获取 */ + shopAppid: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenStoreCouponDetailCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenStoreCouponDetailFailCallback + /** 接口调用成功的回调函数 */ + success?: OpenStoreCouponDetailSuccessCallback + } + interface OpenStoreOrderDetailFailCallbackResult { + /** 错误码 + * + * 可选值: + * - -1: 系统失败; + * - 0: 成功; + * - 1001: 缺少必要参数; + * - 1002: 网络错误; + * - 817323001: 合作账号订单id不合法; + * - 817323002: 无法获取该订单; + * - 817323003: 当前小程序不是绑定的合作账号; */ + code: -1 | 0 | 1001 | 1002 | 817323001 | 817323002 | 817323003 + /** 错误信息 */ + message: string + } + interface OpenStoreOrderDetailOption { + /** 订单id,通过[回调事件](https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/cooperation_shop/order_callback.html#%E4%BA%94%E3%80%81%E5%90%88%E4%BD%9C%E8%B4%A6%E5%8F%B7%E5%BA%97%E9%93%BA%E8%AE%A2%E5%8D%95%E9%80%9A%E7%9F%A5%E4%BA%8B%E4%BB%B6)获取 */ + orderId: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenStoreOrderDetailCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenStoreOrderDetailFailCallback + /** 接口调用成功的回调函数 */ + success?: OpenStoreOrderDetailSuccessCallback + } + interface OpenSuccessCallbackResult { + /** 文件描述符 */ + fd: string + errMsg: string + } + interface OpenSyncOption { + /** 文件路径 (本地路径) */ + filePath: string + /** 文件系统标志,默认值: 'r' + * + * 可选值: + * - 'a': 打开文件用于追加。 如果文件不存在,则创建该文件; + * - 'ax': 类似于 'a',但如果路径存在,则失败; + * - 'a+': 打开文件用于读取和追加。 如果文件不存在,则创建该文件; + * - 'ax+': 类似于 'a+',但如果路径存在,则失败; + * - 'as': 打开文件用于追加(在同步模式中)。 如果文件不存在,则创建该文件; + * - 'as+': 打开文件用于读取和追加(在同步模式中)。 如果文件不存在,则创建该文件; + * - 'r': 打开文件用于读取。 如果文件不存在,则会发生异常; + * - 'r+': 打开文件用于读取和写入。 如果文件不存在,则会发生异常; + * - 'w': 打开文件用于写入。 如果文件不存在则创建文件,如果文件存在则截断文件; + * - 'wx': 类似于 'w',但如果路径存在,则失败; + * - 'w+': 打开文件用于读取和写入。 如果文件不存在则创建文件,如果文件存在则截断文件; + * - 'wx+': 类似于 'w+',但如果路径存在,则失败; */ + flag?: + | 'a' + | 'ax' + | 'a+' + | 'ax+' + | 'as' + | 'as+' + | 'r' + | 'r+' + | 'w' + | 'wx' + | 'w+' + | 'wx+' + } + interface OpenSystemBluetoothSettingOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenSystemBluetoothSettingCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenSystemBluetoothSettingFailCallback + /** 接口调用成功的回调函数 */ + success?: OpenSystemBluetoothSettingSuccessCallback + } + interface OpenVideoEditorOption { + /** 视频源的路径,只支持本地路径 */ + filePath: string + /** 需要基础库: `2.16.1` + * + * 视频裁剪的最大长度 */ + maxDuration: string + /** 需要基础库: `2.16.1` + * + * 视频裁剪的最小长度 */ + minDuration: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenVideoEditorCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: OpenVideoEditorFailCallback + /** 接口调用成功的回调函数 */ + success?: OpenVideoEditorSuccessCallback + } + interface OpenVideoEditorSuccessCallbackResult { + /** 剪辑后生成的视频文件的时长,单位毫秒(ms) */ + duration: number + /** 剪辑后生成的视频文件大小,单位字节数(byte) */ + size: number + /** 编辑后生成的视频文件的临时路径 */ + tempFilePath: string + /** 编辑后生成的缩略图文件的临时路径 */ + tempThumbPath: string + errMsg: string + } + interface PageScrollToOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PageScrollToCompleteCallback + /** 滚动动画的时长,单位 ms */ + duration?: number + /** 接口调用失败的回调函数 */ + fail?: PageScrollToFailCallback + /** 需要基础库: `2.23.1` + * + * 偏移距离,需要和 selector 参数搭配使用,可以滚动到 selector 加偏移距离的位置,单位 px */ + offsetTop?: number + /** 滚动到页面的目标位置,单位 px */ + scrollTop?: number + /** 需要基础库: `2.7.3` + * + * 选择器 */ + selector?: string + /** 接口调用成功的回调函数 */ + success?: PageScrollToSuccessCallback + } + interface PauseBGMOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PauseBGMCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: PauseBGMFailCallback + /** 接口调用成功的回调函数 */ + success?: PauseBGMSuccessCallback + } + interface PauseBackgroundAudioOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PauseBackgroundAudioCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: PauseBackgroundAudioFailCallback + /** 接口调用成功的回调函数 */ + success?: PauseBackgroundAudioSuccessCallback + } + interface PauseOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PauseCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: PauseFailCallback + /** 接口调用成功的回调函数 */ + success?: PauseSuccessCallback + } + interface PauseVoiceOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PauseVoiceCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: PauseVoiceFailCallback + /** 接口调用成功的回调函数 */ + success?: PauseVoiceSuccessCallback + } + /** 单条性能数据。具体数据口径请参考[性能数据文档]((performance/perf_data##_1-4-%E9%80%9A%E8%BF%87-wx-getPerformance-%E5%9C%A8%E5%B0%8F%E7%A8%8B%E5%BA%8F%E5%86%85%E8%8E%B7%E5%8F%96)) */ + interface PerformanceEntry { + /** 需要基础库: `2.24.0` + * + * 解析域名结束时间。仅 resourceTiming 指标有效。 */ + domainLookupEnd: number + /** 需要基础库: `2.24.0` + * + * 解析域名开始时间。仅 resourceTiming 指标有效。 */ + domainLookupStart: number + /** 耗时 ms。仅对于表示阶段的指标有效。 */ + duration: number + /** 指标类型 + * + * 可选值: + * - 'navigation': 路由; + * - 'render': 渲染; + * - 'script': 脚本; */ + entryType: 'navigation' | 'render' | 'script' + /** 需要基础库: `2.21.2` + * + * 注入文件列表。仅 evaluateScript 指标有效。 */ + fileList: string[] + /** 需要基础库: `2.21.2` + * + * 首次渲染参数在渲染层收到的时间。仅 firstRender 指标有效。 */ + initDataRecvTime: number + /** 需要基础库: `2.21.2` + * + * 首次渲染参数从逻辑层发出的时间。仅 firstRender 指标有效。 */ + initDataSendTime: number + /** 需要基础库: `2.24.0` + * + * 初始化性能条目的资源类型。仅 resourceTiming 指标有效。 + * + * 可选值: + * - 'audio': 音频; + * - 'cover-image': cover-image 组件的图片; + * - 'image': 组件的图片; + * - 'open-data': 组件的图片; */ + initiatorType: 'audio' | 'cover-image' | 'image' | 'open-data' + /** 分包名,主包表示为 __APP__ (2.21.2 开始)。仅 evaluateScript 指标有效。 */ + moduleName: string + /** 指标名称 + * + * 可选值: + * - 'appLaunch': 小程序启动耗时。(entryType: navigation); + * - 'route': 路由处理耗时。(entryType: navigation); + * - 'firstRender': 页面首次渲染耗时。(entryType: render); + * - 'firstPaint': 页面首次绘制(FP)时间点,无 duration。(iOS 不支持)(entryType: render); + * - 'firstContentfulPaint': 页面首次内容绘制(FCP)时间点,无 duration。(iOS 14.5 以下版本不支持)(entryType: render); + * - 'largestContentfulPaint': 页面最大内容绘制(LCP)时间点,无 duration。(iOS 不支持)(entryType: render); + * - 'evaluateScript': 逻辑层 JS 代码注入耗时。(entryType: script); + * - 'downloadPackage': 代码包下载耗时。(entryType: loadPackage); + * - 'resourceTiming': 视图层资源加载耗时。(entryType: resource); */ + name: + | 'appLaunch' + | 'route' + | 'firstRender' + | 'firstPaint' + | 'firstContentfulPaint' + | 'largestContentfulPaint' + | 'evaluateScript' + | 'downloadPackage' + | 'resourceTiming' + /** 路由真正响应开始时间。仅 navigation 类型指标有效。 */ + navigationStart: number + /** 路由详细类型,与小程序路由方法对应。仅 navigation 类型指标有效。 */ + navigationType: string + /** 需要基础库: `2.24.0` + * + * 代码包名称。仅 downloadPackage 指标有效。 */ + packageName: string + /** 需要基础库: `2.24.0` + * + * 代码包大小。仅 downloadPackage 指标有效。 */ + packageSize: number + /** 需要基础库: `2.23.1` + * + * path 对应页面实例 Id(随机生成,不保证递增)。仅 render/navigation 指标有效。 */ + pageId: number + /** 页面路径。仅 render 和 navigation 类型指标有效。 */ + path: string + /** 需要基础库: `2.23.1` + * + * referrerPath对应页面实例 Id(随机生成,不保证递增)。仅 route 指标有效。 */ + referrerPageId: number + /** 需要基础库: `2.23.1` + * + * 页面跳转来源页面路径。仅 route 指标有效。 */ + referrerPath: number + /** 开始时间,不同指标的具体含义会有差异。 */ + startTime: number + /** 需要基础库: `2.24.0` + * + * 表示获取资源的大小(以八位字节为单位)的数字。仅 resourceTiming 指标有效。(iOS 不支持) */ + transferSize: number + /** 需要基础库: `2.24.0` + * + * 资源路径。仅 resourceTiming 指标有效。 */ + uri: string + /** 需要基础库: `2.21.2` + * + * 渲染层代码注入完成时间。仅 firstRender 指标有效。 */ + viewLayerReadyTime: number + /** 需要基础库: `2.21.2` + * + * 渲染层执行渲染结束时间。仅 firstRender 指标有效。 */ + viewLayerRenderEndTime: number + /** 需要基础库: `2.21.2` + * + * 渲染层执行渲染开始时间。仅 firstRender 指标有效。 */ + viewLayerRenderStartTime: number + } + /** 需要基础库: `2.11.0` + * + * PerformanceObserver 对象,用于监听性能相关事件 */ + interface PerformanceObserver { + /** 获取当前支持的所有性能指标类型 */ + supportedEntryTypes: any[] + /** [PerformanceObserver.disconnect()](https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/PerformanceObserver.disconnect.html) + * + * 需要基础库: `2.11.0` + * + * 在插件中使用:不支持 + * + * 停止监听 */ + disconnect(): void + /** [PerformanceObserver.observe(Object options)](https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/PerformanceObserver.observe.html) + * + * 需要基础库: `2.11.0` + * + * 在插件中使用:不支持 + * + * 开始监听 */ + observe( + /** 设置 type 监听单个类型的指标,设置 entryTypes 监听多个类型指标。 */ + options: ObserveOption + ): void + } + /** 平面跟踪配置 */ + interface PlaneTrack { + /** 平面跟踪配置模式 + * + * 可选值: + * - 1: 检测横向平面; + * - 2: 检测纵向平面,只有 v2 版本支持; + * - 3: 检测横向和纵向平面,只有 v2 版本支持; */ + mode: 1 | 2 | 3 + /** 需要基础库: `3.6.5` + * + * 是否开启强制使用V2的模式,只有 v2 版本支持 */ + force?: boolean + } + interface PlayBGMOption { + /** 加入背景混音的资源地址 */ + url: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PlayBGMCompleteCallback + /** 需要基础库: `2.31.0` + * + * BGM结束播放时间点,单位ms,0代表播放至文件结尾,若入参为负或超过文件长度,则默认播放至文件结尾 */ + endTimeMs?: number + /** 接口调用失败的回调函数 */ + fail?: PlayBGMFailCallback + /** 需要基础库: `2.31.0` + * + * BGM开始播时间点,单位ms,若入参为负或超过文件长度,则默认从文件开头进行播放 */ + startTimeMs?: number + /** 接口调用成功的回调函数 */ + success?: PlayBGMSuccessCallback + } + interface PlayBackgroundAudioOption { + /** 音乐链接,目前支持的格式有 m4a, aac, mp3, wav */ + dataUrl: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PlayBackgroundAudioCompleteCallback + /** 封面URL */ + coverImgUrl?: string + /** 接口调用失败的回调函数 */ + fail?: PlayBackgroundAudioFailCallback + /** 接口调用成功的回调函数 */ + success?: PlayBackgroundAudioSuccessCallback + /** 音乐标题 */ + title?: string + } + interface PlayOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PlayCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: PlayFailCallback + /** 接口调用成功的回调函数 */ + success?: PlaySuccessCallback + } + interface PlayVoiceOption { + /** 需要播放的语音文件的文件路径 (本地路径) */ + filePath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PlayVoiceCompleteCallback + /** 需要基础库: `1.6.0` + * + * 指定播放时长,到达指定的播放时长后会自动停止播放,单位:秒 */ + duration?: number + /** 接口调用失败的回调函数 */ + fail?: PlayVoiceFailCallback + /** 接口调用成功的回调函数 */ + success?: PlayVoiceSuccessCallback + } + /** 插件账号信息(仅在插件中调用时包含这一项) */ + interface Plugin { + /** 插件 appId */ + appId: string + /** 插件版本号 */ + version: string + } + interface PluginLoginOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PluginLoginCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: PluginLoginFailCallback + /** 接口调用成功的回调函数 */ + success?: PluginLoginSuccessCallback + } + interface PluginLoginSuccessCallbackResult { + /** 用于换取 openpid 的凭证(有效期五分钟)。插件开发者可以用此 code 在开发者服务器后台调用 [getPluginOpenPId](https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/user-info/basic-info/getPluginOpenPId.html) 换取 openpid。 */ + code: string + errMsg: string + } + interface PostMessageToReferrerMiniProgramOption { + /** 需要返回的数据 */ + extraData?: IAnyObject + } + interface PreDownloadSubpackageOption { + /** 分包的类型。目前仅支持填 "workers",表示 workers 分包。 */ + packageType: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PreDownloadSubpackageCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: PreDownloadSubpackageFailCallback + /** 接口调用成功的回调函数 */ + success?: PreDownloadSubpackageSuccessCallback + } + interface PreDownloadSubpackageTaskOnProgressUpdateListenerResult { + /** 分包下载进度百分比 */ + progress: number + /** 预期需要下载的数据总长度,单位 Bytes */ + totalBytesExpectedToWrite: number + /** 已经下载的数据长度,单位 Bytes */ + totalBytesWritten: number + } + interface PreloadAssetsOption { + data: Asset[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PreloadAssetsCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: PreloadAssetsFailCallback + /** 接口调用成功的回调函数 */ + success?: PreloadAssetsSuccessCallback + } + interface PreloadSkylineViewOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PreloadSkylineViewCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: PreloadSkylineViewFailCallback + /** 接口调用成功的回调函数 */ + success?: PreloadSkylineViewSuccessCallback + } + interface PreloadWebviewOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PreloadWebviewCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: PreloadWebviewFailCallback + /** 接口调用成功的回调函数 */ + success?: PreloadWebviewSuccessCallback + } + interface PreviewImageOption { + /** 需要预览的图片链接列表。[2.2.3](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起支持云文件ID。 */ + urls: string[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PreviewImageCompleteCallback + /** 当前显示图片的链接 */ + current?: string + /** 接口调用失败的回调函数 */ + fail?: PreviewImageFailCallback + /** 需要基础库: `2.13.0` + * + * `origin`: 发送完整的referrer; `no-referrer`: 不发送。格式固定为 `https://servicewechat.com/{appid}/{version}/page-frame.html`,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本; */ + referrerPolicy?: string + /** 需要基础库: `2.13.0` + * + * 是否显示长按菜单。 */ + showmenu?: boolean + /** 接口调用成功的回调函数 */ + success?: PreviewImageSuccessCallback + } + interface PreviewMediaOption { + /** 需要预览的资源列表 */ + sources: MediaSource[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PreviewMediaCompleteCallback + /** 当前显示的资源序号 */ + current?: number + /** 接口调用失败的回调函数 */ + fail?: PreviewMediaFailCallback + /** 需要基础库: `2.13.0` + * + * `origin`: 发送完整的referrer; `no-referrer`: 不发送。格式固定为 `https://servicewechat.com/{appid}/{version}/page-frame.html`,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本; */ + referrerPolicy?: string + /** 需要基础库: `2.13.0` + * + * 是否显示长按菜单。 */ + showmenu?: boolean + /** 接口调用成功的回调函数 */ + success?: PreviewMediaSuccessCallback + } + /** 订单详细商品信息列表。 */ + interface ProductInfo { + /** 商户侧该商品所属的类目。示例值:玩偶 */ + category: string + /** 商品主图的url,大小建议64*64。示例值:https://mp.weixin.qq.com/123 */ + head_img: string + /** 该商品原价,单位为分。示例值:5000 */ + org_price: number + /** 商户商品详请页小程序路径。示例值:pages/index */ + path: string + /** 用户购买该商品的数量。示例值:5 */ + quantity: number + /** 该商品售价,单位为分。示例值:4000 */ + sale_price: number + /** 商户系统内该商品的sku属性。示例值:50cm */ + sku_attr: string + /** 商户系统内该商品的skuid。示例值:sku123 */ + sku_id: string + /** 商户系统内该商品的spuid。示例值:spu123456 */ + spu_id: string + /** 商品标题。示例值:QQ长鹅 */ + title: string + } + /** 推广员 */ + interface PromoterResult { + /** 推广员昵称 */ + finderNickname: string + /** 推广员 id */ + promoterId: string + /** 推广员 openid */ + promoterOpenId: string + } + interface ReLaunchOption { + /** 需要跳转的应用内页面路径 (代码包路径),路径后可以带参数。参数与路径之间使用?分隔,参数键与参数值用=相连,不同参数用&分隔;如 'path?key=value&key2=value2' */ + url: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ReLaunchCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ReLaunchFailCallback + /** 接口调用成功的回调函数 */ + success?: ReLaunchSuccessCallback + } + interface ReadBLECharacteristicValueOption { + /** 蓝牙特征的 UUID */ + characteristicId: string + /** 蓝牙设备 id */ + deviceId: string + /** 蓝牙特征对应服务的 UUID */ + serviceId: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ReadBLECharacteristicValueCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ReadBLECharacteristicValueFailCallback + /** 接口调用成功的回调函数 */ + success?: ReadBLECharacteristicValueSuccessCallback + } + interface ReadCompressedFileOption { + /** 文件压缩类型,目前仅支持 'br'。 + * + * 可选值: + * - 'br': brotli压缩文件; */ + compressionAlgorithm: 'br' + /** 要读取的文件的路径 (本地用户文件或代码包文件) */ + filePath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ReadCompressedFileCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ReadCompressedFileFailCallback + /** 接口调用成功的回调函数 */ + success?: ReadCompressedFileSuccessCallback + } + interface ReadCompressedFileSuccessCallbackResult { + /** 文件内容 */ + data: ArrayBuffer + errMsg: string + } + interface ReadCompressedFileSyncOption { + /** 文件压缩类型,目前仅支持 'br'。 + * + * 可选值: + * - 'br': brotli压缩文件; */ + compressionAlgorithm: 'br' + /** 要读取的文件的路径 (本地用户文件或代码包文件) */ + filePath: string + } + interface ReadFileOption { + /** 要读取的文件的路径 (本地路径) */ + filePath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ReadFileCompleteCallback + /** 指定读取文件的字符编码,如果不传 encoding,则以 ArrayBuffer 格式读取文件的二进制内容 + * + * 可选值: + * - 'ascii': ; + * - 'base64': ; + * - 'binary': ; + * - 'hex': ; + * - 'ucs2': 以小端序读取; + * - 'ucs-2': 以小端序读取; + * - 'utf16le': 以小端序读取; + * - 'utf-16le': 以小端序读取; + * - 'utf-8': ; + * - 'utf8': ; + * - 'latin1': ; */ + encoding?: + | 'ascii' + | 'base64' + | 'binary' + | 'hex' + | 'ucs2' + | 'ucs-2' + | 'utf16le' + | 'utf-16le' + | 'utf-8' + | 'utf8' + | 'latin1' + /** 接口调用失败的回调函数 */ + fail?: ReadFileFailCallback + /** 需要基础库: `2.10.0` + * + * 指定文件的长度,如果不指定,则读到文件末尾。有效范围:[1, fileLength]。单位:byte */ + length?: number + /** 需要基础库: `2.10.0` + * + * 从文件指定位置开始读,如果不指定,则从文件头开始读。读取的范围应该是左闭右开区间 [position, position+length)。有效范围:[0, fileLength - 1]。单位:byte */ + position?: number + /** 接口调用成功的回调函数 */ + success?: ReadFileSuccessCallback + } + interface ReadFileSuccessCallbackResult { + /** 文件内容 */ + data: string | ArrayBuffer + errMsg: string + } + interface ReadOption { + /** 数据写入的缓冲区,必须是 ArrayBuffer 实例 */ + arrayBuffer: ArrayBuffer + /** 文件描述符。fd 通过 [FileSystemManager.open](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.open.html) 或 [FileSystemManager.openSync](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.openSync.html) 接口获得 */ + fd: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ReadCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ReadFailCallback + /** 要从文件中读取的字节数,默认0 */ + length?: number + /** 缓冲区中的写入偏移量,默认0 */ + offset?: number + /** 文件读取的起始位置,如不传或传 null,则会从当前文件指针的位置读取。如果 position 是正整数,则文件指针位置会保持不变并从 position 读取文件。 */ + position?: number + /** 接口调用成功的回调函数 */ + success?: ReadSuccessCallback + } + /** 文件读取结果。 通过 [FileSystemManager.readSync](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readSync.html) 接口返回 */ + interface ReadResult { + /** 被写入的缓存区的对象,即接口入参的 arrayBuffer */ + arrayBuffer: ArrayBuffer + /** 实际读取的字节数 */ + bytesRead: number + } + interface ReadSuccessCallbackResult { + /** 被写入的缓存区的对象,即接口入参的 arrayBuffer */ + arrayBuffer: ArrayBuffer + /** 实际读取的字节数 */ + bytesRead: number + errMsg: string + } + interface ReadSyncOption { + /** 数据写入的缓冲区,必须是 ArrayBuffer 实例 */ + arrayBuffer: ArrayBuffer + /** 文件描述符。fd 通过 [FileSystemManager.open](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.open.html) 或 [FileSystemManager.openSync](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.openSync.html) 接口获得 */ + fd: string + /** 要从文件中读取的字节数,默认0 */ + length?: number + /** 缓冲区中的写入偏移量,默认0 */ + offset?: number + /** 文件读取的起始位置,如不传或传 null,则会从当前文件指针的位置读取。如果 position 是正整数,则文件指针位置会保持不变并从 position 读取文件。 */ + position?: number + } + interface ReadZipEntryOption { + /** 要读取的压缩包内的文件列表(当传入"all" 时表示读取压缩包内所有文件) */ + entries: EntryItem[] | 'all' + /** 要读取的压缩包的路径 (本地路径) */ + filePath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ReadZipEntryCompleteCallback + /** 统一指定读取文件的字符编码,只在 entries 值为"all"时有效。如果 entries 值为"all"且不传 encoding,则以 ArrayBuffer 格式读取文件的二进制内容 + * + * 可选值: + * - 'ascii': ; + * - 'base64': ; + * - 'binary': ; + * - 'hex': ; + * - 'ucs2': 以小端序读取; + * - 'ucs-2': 以小端序读取; + * - 'utf16le': 以小端序读取; + * - 'utf-16le': 以小端序读取; + * - 'utf-8': ; + * - 'utf8': ; + * - 'latin1': ; */ + encoding?: + | 'ascii' + | 'base64' + | 'binary' + | 'hex' + | 'ucs2' + | 'ucs-2' + | 'utf16le' + | 'utf-16le' + | 'utf-8' + | 'utf8' + | 'latin1' + /** 接口调用失败的回调函数 */ + fail?: ReadZipEntryFailCallback + /** 接口调用成功的回调函数 */ + success?: ReadZipEntrySuccessCallback + } + interface ReadZipEntrySuccessCallbackResult { + /** 文件读取结果。res.entries 是一个对象,key是文件路径,value是一个对象 FileItem ,表示该文件的读取结果。每个 FileItem 包含 data (文件内容) 和 errMsg (错误信息) 属性。 */ + entries: EntriesResult + errMsg: string + } + interface ReaddirOption { + /** 要读取的目录路径 (本地路径) */ + dirPath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ReaddirCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ReaddirFailCallback + /** 接口调用成功的回调函数 */ + success?: ReaddirSuccessCallback + } + interface ReaddirSuccessCallbackResult { + /** 指定目录下的文件名数组。 */ + files: string[] + errMsg: string + } + interface ReconnectCastingOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ReconnectCastingCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ReconnectCastingFailCallback + /** 接口调用成功的回调函数 */ + success?: ReconnectCastingSuccessCallback + } + interface RecorderManagerStartOption { + /** 需要基础库: `2.1.0` + * + * 指定录音的音频输入源,可通过 [wx.getAvailableAudioSources()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.getAvailableAudioSources.html) 获取当前可用的音频源 + * + * 可选值: + * - 'auto': 自动设置,默认使用手机麦克风,插上耳麦后自动切换使用耳机麦克风,所有平台适用; + * - 'buildInMic': 手机麦克风,仅限 iOS; + * - 'headsetMic': 有线耳机麦克风,仅限 iOS; + * - 'mic': 麦克风(没插耳麦时是手机麦克风,插耳麦时是耳机麦克风),仅限 Android; + * - 'camcorder': 同 mic,适用于录制音视频内容,仅限 Android; + * - 'voice_communication': 同 mic,适用于实时沟通,仅限 Android; + * - 'voice_recognition': 同 mic,适用于语音识别,仅限 Android; */ + audioSource?: + | 'auto' + | 'buildInMic' + | 'headsetMic' + | 'mic' + | 'camcorder' + | 'voice_communication' + | 'voice_recognition' + /** 录音的时长,单位 ms,最大值 600000(10 分钟) */ + duration?: number + /** 编码码率,有效值见下表格 */ + encodeBitRate?: number + /** 音频格式 + * + * 可选值: + * - 'mp3': mp3 格式; + * - 'aac': aac 格式; + * - 'wav': wav 格式; + * - 'PCM': pcm 格式; */ + format?: 'mp3' | 'aac' | 'wav' | 'PCM' + /** 指定帧大小,单位 KB。传入 frameSize 后,每录制指定帧大小的内容后,会回调录制的文件内容,不指定则不会回调。暂仅支持 mp3、pcm 格式。 */ + frameSize?: number + /** 录音通道数 + * + * 可选值: + * - 1: 1 个通道; + * - 2: 2 个通道; */ + numberOfChannels?: 1 | 2 + /** 采样率(pc不支持) + * + * 可选值: + * - 8000: 8000 采样率; + * - 11025: 11025 采样率; + * - 12000: 12000 采样率; + * - 16000: 16000 采样率; + * - 22050: 22050 采样率; + * - 24000: 24000 采样率; + * - 32000: 32000 采样率; + * - 44100: 44100 采样率; + * - 48000: 48000 采样率; */ + sampleRate?: + | 8000 + | 11025 + | 12000 + | 16000 + | 22050 + | 24000 + | 32000 + | 44100 + | 48000 + } + interface RedirectToOption { + /** 需要跳转的应用内非 tabBar 的页面的路径 (代码包路径), 路径后可以带参数。参数与路径之间使用 `?` 分隔,参数键与参数值用 `=` 相连,不同参数用 `&` 分隔;如 'path?key=value&key2=value2' */ + url: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RedirectToCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RedirectToFailCallback + /** 接口调用成功的回调函数 */ + success?: RedirectToSuccessCallback + } + interface RedoOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RedoCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RedoFailCallback + /** 接口调用成功的回调函数 */ + success?: RedoSuccessCallback + } + interface RefCallbackResult { + /** 节点对应的 Ref 对象 */ + ref: IAnyObject + } + /** 来源信息。从另一个小程序、公众号或 App 进入小程序时返回。否则返回 `{}`。(参见后文注意) */ + interface ReferrerInfo { + /** 来源小程序、公众号或 App 的 appId */ + appId: string + /** 来源小程序传过来的数据,scene=1037或1038时支持 */ + extraData: IAnyObject + } + /** 参照区域的边界 */ + interface RelativeRectResult { + /** 下边界 */ + bottom: number + /** 左边界 */ + left: number + /** 右边界 */ + right: number + /** 上边界 */ + top: number + } + interface RemoveArcOption { + /** 圆弧 id */ + id: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RemoveArcCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RemoveArcFailCallback + /** 接口调用成功的回调函数 */ + success?: RemoveArcSuccessCallback + } + interface RemoveCustomLayerOption { + /** 个性化图层id */ + layerId: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RemoveCustomLayerCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RemoveCustomLayerFailCallback + /** 接口调用成功的回调函数 */ + success?: RemoveCustomLayerSuccessCallback + } + interface RemoveFormatOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RemoveFormatCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RemoveFormatFailCallback + /** 接口调用成功的回调函数 */ + success?: RemoveFormatSuccessCallback + } + interface RemoveGroundOverlayOption { + /** 图片图层 id */ + id: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RemoveGroundOverlayCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RemoveGroundOverlayFailCallback + /** 接口调用成功的回调函数 */ + success?: RemoveGroundOverlaySuccessCallback + } + interface RemoveMarkersOption { + /** marker 的 id 集合。 */ + markerIds: any[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RemoveMarkersCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RemoveMarkersFailCallback + /** 接口调用成功的回调函数 */ + success?: RemoveMarkersSuccessCallback + } + interface RemoveSavedFileOption { + /** 需要删除的文件路径 (本地路径) */ + filePath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RemoveSavedFileCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RemoveSavedFileFailCallback + /** 接口调用成功的回调函数 */ + success?: RemoveSavedFileSuccessCallback + } + interface RemoveServiceOption { + /** service 的 UUID */ + serviceId: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RemoveServiceCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RemoveServiceFailCallback + /** 接口调用成功的回调函数 */ + success?: RemoveServiceSuccessCallback + } + interface RemoveStorageOption { + /** 本地缓存中指定的 key */ + key: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RemoveStorageCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RemoveStorageFailCallback + /** 接口调用成功的回调函数 */ + success?: RemoveStorageSuccessCallback + } + interface RemoveTabBarBadgeOption { + /** tabBar 的哪一项,从左边算起 */ + index: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RemoveTabBarBadgeCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RemoveTabBarBadgeFailCallback + /** 接口调用成功的回调函数 */ + success?: RemoveTabBarBadgeSuccessCallback + } + interface RemoveVisualLayerOption { + /** 可视化图层id */ + layerId: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RemoveVisualLayerCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RemoveVisualLayerFailCallback + /** 接口调用成功的回调函数 */ + success?: RemoveVisualLayerSuccessCallback + } + interface RenameOption { + /** 新文件路径,支持本地路径 */ + newPath: string + /** 源文件路径,支持本地路径 */ + oldPath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RenameCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RenameFailCallback + /** 接口调用成功的回调函数 */ + success?: RenameSuccessCallback + } + /** Canvas 绘图上下文。 + * + * **** + * + * - 通过 Canvas.getContext('2d') 接口可以获取 CanvasRenderingContext2D 对象,实现了 [HTML Canvas 2D Context](https://www.w3.org/TR/2dcontext/) 定义的属性、方法。 + * - 通过 Canvas.getContext('webgl') 或 OffscreenCanvas.getContext('webgl') 接口可以获取 WebGLRenderingContext 对象,实现了 [WebGL 1.0](https://www.khronos.org/registry/webgl/specs/latest/1.0/) 定义的所有属性、方法、常量。 + * - CanvasRenderingContext2D 的 drawImage 方法 2.10.0 起支持传入通过 [SelectorQuery](https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.html) 获取的 video 对象,2.29.0 起支持传入开启了自定义渲染的 [LivePusherContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.html) 对象。 + * + * **示例代码** + * + * video 画到 2D Canvas 示例 + * [在微信开发者工具中查看示例](https://developers.weixin.qq.com/s/tJTak7mU7sfX) */ + interface RenderingContext {} + interface RequestCommonPaymentFailCallbackErr { + /** 错误信息 */ + errMsg: string + /** 错误码 */ + errno: number + } + interface RequestCommonPaymentOption { + /** 支付的类型 + * + * 可选值: + * - 'retail_pay_goods': B2b支付; + * - 'retail_pay_combined_goods': 合单支付; + * - 'retail_pay_goods_new': 多渠道B2b支付; + * - 'retail_pay_indirect_goods': 间接支付; */ + mode: + | 'retail_pay_goods' + | 'retail_pay_combined_goods' + | 'retail_pay_goods_new' + | 'retail_pay_indirect_goods' + /** 支付签名, 详见[《签名详解》](https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/virtual-payment.html) */ + paySig: string + /** 具体支付参数见signData, 该参数需以string形式传递, 例如signData: '{"mchid":"1234567890","out_trade_no":"test1244","description":"测试测试","amount":{"order_amount":1,"currency":"CNY"},"attach":"test_attach","env":1}' */ + signData: RequestCommonPaymentSignData + /** 用户态签名, 详见[《签名详解》](https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/virtual-payment.html) */ + signature: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RequestCommonPaymentCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RequestCommonPaymentFailCallback + /** 接口调用成功的回调函数 */ + success?: RequestCommonPaymentSuccessCallback + } + /** 具体支付参数见signData, 该参数需以string形式传递, 例如signData: '{"mchid":"1234567890","out_trade_no":"test1244","description":"测试测试","amount":{"order_amount":1,"currency":"CNY"},"attach":"test_attach","env":1}' */ + interface RequestCommonPaymentSignData { + /** 订单金额信息。 */ + amount: Amount + /** 商品描述。示例值:Image形象店-深圳腾大-QQ公仔 */ + description: string + /** 下单环境。示例值:0 + * + * 可选值: + * - 0: 生产环境/现网环境; + * - 1: 沙箱环境/测试环境; */ + env: 0 | 1 + /** 由微信支付生成并下发的商户号。示例值:1230000109 */ + mchid: string + /** 商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一,长度限制为[6,32]。示例值:1217752501201407033233368018 */ + out_trade_no: string + /** 附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用,实际情况下只有支付完成状态才会返回该字段。示例值:test_attach */ + attach?: string + /** 配送方式。示例值:2 + * + * 可选值: + * - 1: 同城配送; + * - 2: 快递配送; + * - 3: 门店自提; + * - 4: 无需配送与提货; */ + delivery_type?: 1 | 2 | 3 | 4 + /** 订单详细商品信息列表。 */ + product_info?: ProductInfo + /** B2b间连支付场景下,调用requestPaymentInfo的参数 */ + requestPaymentInfo?: RequestPaymentInfo + } + interface RequestCommonPaymentSuccessCallbackResult { + /** 调用成功信息 */ + errMsg: string + } + interface RequestDeviceVoIPOption { + /** 设备名称,将显示在授权弹窗内(长度不超过13)。授权框中「设备名字」= 「deviceName」 + 「modelId 对应设备型号」。 */ + deviceName: string + /** 需要基础库: `2.30.4` + * + * 设备组的唯一标识 id 。isGroup 为 true 时只需要传该参数,isGroup 为 false 时不需要传该参数,但需要传 sn、snTicket、modelId、deviceName 。 */ + groupId: string + /** 设备型号 id。通过微信公众平台注册设备获得。 */ + modelId: string + /** 设备唯一序列号。由厂商分配,长度不能超过128字节。字符只接受数字,大小写字母,下划线(_)和连字符(-)。 */ + sn: string + /** [设备票据](https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/hardware-device/getSnTicket.html),5分钟内有效。 */ + snTicket: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RequestDeviceVoIPCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RequestDeviceVoIPFailCallback + /** 需要基础库: `2.30.4` + * + * 是否为授权设备组,默认 false 。 */ + isGroup?: boolean + /** 接口调用成功的回调函数 */ + success?: RequestDeviceVoIPSuccessCallback + } + /** 需要基础库: `3.0.0` + * + * 网络请求过程中的一些异常信息,例如httpdns超时等 */ + interface RequestException { + /** 本次请求底层失败信息,所有失败信息均符合Errno错误码 */ + reasons: ExceptionReason[] + /** 本次请求底层重试次数 */ + retryCount: number + } + interface RequestFailCallbackErr { + /** 错误信息 */ + errMsg: string + /** 需要基础库: `2.24.0` + * + * errno 错误码,错误码的详细说明参考 [Errno错误码](https://developers.weixin.qq.com/miniprogram/dev/framework/usability/PublicErrno.html) */ + errno: number + } + interface RequestGlobalPaymentOption { + /** ISO4217标准中的最小货币单位进行表达,该值为整数,没有小数点。 */ + paymentId: string + /** 预支付信息 */ + prepayInfo: string + } + interface RequestMerchantTransferOption { + /** 商户号 */ + mchId: string + /** 商家转账付款单跳转收款页 pkg 信息,商家转账付款单受理成功时返回给商户 */ + package: string + /** 商户 appId,普通模式下必填,服务商模式下,appId 和 subAppId 二选一填写 */ + appId?: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RequestMerchantTransferCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RequestMerchantTransferFailCallback + /** 收款用户 openId, 对应传入的商户 appId 下,某用户的 openId */ + openId?: string + /** 子商户 appId,服务商模式下,appId 和 subAppId 二选一填写 */ + subAppId?: string + /** 子商户号,服务商模式下必填 */ + subMchId?: string + /** 接口调用成功的回调函数 */ + success?: RequestMerchantTransferSuccessCallback + } + interface RequestOption< + T extends string | IAnyObject | ArrayBuffer = + | string + | IAnyObject + | ArrayBuffer + > { + /** 开发者服务器接口地址 */ + url: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RequestCompleteCallback + /** 请求的参数 */ + data?: string | IAnyObject | ArrayBuffer + /** 返回的数据格式 + * + * 可选值: + * - 'json': 返回的数据为 JSON,返回后会对返回的数据进行一次 JSON.parse; + * - '其他': 不对返回的内容进行 JSON.parse; */ + dataType?: 'json' | '其他' + /** 需要基础库: `2.10.4` + * + * 开启 Http 缓存 */ + enableCache?: boolean + /** 需要基础库: `2.20.2` + * + * 开启 transfer-encoding chunked。 */ + enableChunked?: boolean + /** 需要基础库: `2.10.4` + * + * 开启 http2 */ + enableHttp2?: boolean + /** 需要基础库: `2.19.1` + * + * 是否开启 HttpDNS 服务。如开启,需要同时填入 httpDNSServiceId 。 HttpDNS 用法详见 [移动解析HttpDNS](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/HTTPDNS.html) */ + enableHttpDNS?: boolean + /** 是否开启 profile,默认开启。开启后可在接口回调的 res.profile 中查看性能调试信息。 */ + enableProfile?: boolean + /** 需要基础库: `2.10.4` + * + * 是否开启 Quic/h3 协议(iOS 微信目前使用 gQUIC-Q43;Android 微信在 v8.0.54 前使用 gQUIC-Q43,v8.0.54 开始使用 IETF QUIC,即 h3 协议;PC微信使用 IETF QUIC,即 h3 协议) */ + enableQuic?: boolean + /** 接口调用失败的回调函数 */ + fail?: RequestFailCallback + /** 需要基础库: `2.21.0` + * + * 强制使用蜂窝网络发送请求 */ + forceCellularNetwork?: boolean + /** 设置请求的 header,header 中不能设置 Referer。 + * + * `content-type` 默认为 `application/json` */ + header?: IAnyObject + /** 需要基础库: `2.19.1` + * + * HttpDNS 服务商 Id。 HttpDNS 用法详见 [移动解析HttpDNS](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/HTTPDNS.html) */ + httpDNSServiceId?: string + /** 需要基础库: `3.8.9` + * + * HttpDNS 超时时间。HttpDNS解析时间超过该值时不再走HttpDNS,本次请求将回退到localDNS。默认为 60000 毫秒。 HttpDNS 用法详见 [移动解析HttpDNS](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/HTTPDNS.html) */ + httpDNSTimeout?: string + /** HTTP 请求方法 + * + * 可选值: + * - 'OPTIONS': HTTP 请求 OPTIONS; + * - 'GET': HTTP 请求 GET; + * - 'HEAD': HTTP 请求 HEAD; + * - 'POST': HTTP 请求 POST; + * - 'PUT': HTTP 请求 PUT; + * - 'DELETE': HTTP 请求 DELETE; + * - 'TRACE': HTTP 请求 TRACE; + * - 'CONNECT': HTTP 请求 CONNECT; */ + method?: + | 'OPTIONS' + | 'GET' + | 'HEAD' + | 'POST' + | 'PUT' + | 'DELETE' + | 'TRACE' + | 'CONNECT' + /** 需要基础库: `3.2.2` + * + * 重定向拦截策略。(目前安卓、iOS、开发者工具已支持,PC端将在后续支持) + * + * 可选值: + * - 'follow': 不拦截重定向,即客户端自动处理重定向; + * - 'manual': 拦截重定向。开启后,当 http 状态码为 3xx 时客户端不再自动重定向,而是触发 onHeadersReceived 回调,并结束本次 request 请求。可通过 onHeadersReceived 回调中的 header.Location 获取重定向的 url; */ + redirect?: 'follow' | 'manual' + /** 需要基础库: `1.7.0` + * + * 响应的数据类型 + * + * 可选值: + * - 'text': 响应的数据为文本; + * - 'arraybuffer': 响应的数据为 ArrayBuffer; */ + responseType?: 'text' | 'arraybuffer' + /** 接口调用成功的回调函数 */ + success?: RequestSuccessCallback + /** 需要基础库: `2.10.0` + * + * 超时时间,单位为毫秒。默认值为 60000 */ + timeout?: number + /** 需要基础库: `3.3.3` + * + * 使用高性能模式,暂仅支持 Android,默认关闭。该模式下有更优的网络性能表现,更多信息请查看下方说明。 */ + useHighPerformanceMode?: boolean + } + interface RequestOrderPaymentOption { + /** 随机字符串,长度为32个字符以下 */ + nonceStr: string + /** 统一下单接口返回的 prepay_id 参数值,提交格式如:prepay_id=*** */ + package: string + /** 签名,具体见微信支付文档 */ + paySign: string + /** 时间戳,从 1970 年 1 月 1 日 00:00:00 至今的秒数,即当前的时间 */ + timeStamp: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RequestOrderPaymentCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RequestOrderPaymentFailCallback + /** 签名算法,应与后台下单时的值一致 + * + * 可选值: + * - 'MD5': 仅在 v2 版本接口适用; + * - 'HMAC-SHA256': 仅在 v2 版本接口适用; + * - 'RSA': 仅在 v3 版本接口适用; */ + signType?: 'MD5' | 'HMAC-SHA256' | 'RSA' + /** 接口调用成功的回调函数 */ + success?: RequestOrderPaymentSuccessCallback + } + /** B2b间连支付场景下,调用requestPaymentInfo的参数 */ + interface RequestPaymentInfo { + /** 随机字符串,长度为32个字符以下 */ + nonceStr?: string + /** 统一下单接口返回的 prepay_id 参数值,提交格式如:prepay_id=*** */ + package?: string + /** 签名,具体见微信支付文档 */ + paySign?: string + /** 签名算法,应与后台下单时的值一致 */ + signType?: string + /** 时间戳,从 1970 年 1 月 1 日 00:00:00 至今的秒数,即当前的时间 */ + timeStamp?: string + } + interface RequestPaymentOption { + /** 随机字符串,长度为32个字符以下 */ + nonceStr: string + /** 统一下单接口返回的 prepay_id 参数值,提交格式如:prepay_id=*** */ + package: string + /** 签名,具体见微信支付文档 */ + paySign: string + /** 时间戳,从 1970 年 1 月 1 日 00:00:00 至今的秒数,即当前的时间 */ + timeStamp: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RequestPaymentCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RequestPaymentFailCallback + /** 签名算法,应与后台下单时的值一致 + * + * 可选值: + * - 'MD5': 仅在 v2 版本接口适用; + * - 'HMAC-SHA256': 仅在 v2 版本接口适用; + * - 'RSA': 仅在 v3 版本接口适用; */ + signType?: 'MD5' | 'HMAC-SHA256' | 'RSA' + /** 接口调用成功的回调函数 */ + success?: RequestPaymentSuccessCallback + } + interface RequestPictureInPictureOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RequestPictureInPictureCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RequestPictureInPictureFailCallback + /** 接口调用成功的回调函数 */ + success?: RequestPictureInPictureSuccessCallback + } + interface RequestPluginPaymentOption { + /** 需要显示在页面中的金额,单位为分 */ + fee: number + /** 任意数据,传递给功能页中的响应函数 */ + paymentArgs: IAnyObject + /** 插件版本 + * + * 可选值: + * - 'develop': 开发版; + * - 'trial': 体验版; + * - 'release': 正式版; */ + version: 'develop' | 'trial' | 'release' + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RequestPluginPaymentCompleteCallback + /** 需要显示在页面中的货币符号的代码 */ + currencyType?: string + /** 接口调用失败的回调函数 */ + fail?: RequestPluginPaymentFailCallback + /** 接口调用成功的回调函数 */ + success?: RequestPluginPaymentSuccessCallback + } + /** 需要基础库: `2.10.4` + * + * 网络请求过程中一些调试信息,[查看详细说明](https://developers.weixin.qq.com/miniprogram/dev/framework/performance/network.html) */ + interface RequestProfile { + /** SSL建立完成的时间,如果不是安全连接,则值为 0 */ + SSLconnectionEnd: number + /** SSL建立连接的时间,如果不是安全连接,则值为 0 */ + SSLconnectionStart: number + /** HTTP(TCP) 完成建立连接的时间(完成握手),如果是持久连接,则与 fetchStart 值相等。注意如果在传输层发生了错误且重新建立连接,则这里显示的是新建立的连接完成的时间。注意这里握手结束,包括安全连接建立完成、SOCKS 授权通过 */ + connectEnd: number + /** HTTP(TCP) 开始建立连接的时间,如果是持久连接,则与 fetchStart 值相等。注意如果在传输层发生了错误且重新建立连接,则这里显示的是新建立的连接开始的时间 */ + connectStart: number + /** Local DNS 域名查询完成的时间,如果使用了本地缓存(即无 DNS 查询)或持久连接,则与 fetchStart 值相等 */ + domainLookUpEnd: number + /** Local DNS 域名查询开始的时间,如果使用了本地缓存(即无 DNS 查询)或持久连接,则与 fetchStart 值相等 */ + domainLookUpStart: number + /** 评估当前网络下载的kbps */ + downstreamThroughputKbpsEstimate: number + /** 评估的网络状态 unknown, offline, slow 2g, 2g, 3g, 4g, last/0, 1, 2, 3, 4, 5, 6 */ + estimate_nettype: number + /** 组件准备好使用 HTTP 请求抓取资源的时间,这发生在检查本地缓存之前 */ + fetchStart: number + /** httpDNS 完成查询的时间。仅当开启 httpDNS 功能时返回该字段 */ + httpDNSDomainLookUpEnd: number + /** httpDNS 开始查询的时间。仅当开启 httpDNS 功能时返回该字段 */ + httpDNSDomainLookUpStart: number + /** 协议层根据多个请求评估当前网络的 rtt(仅供参考) */ + httpRttEstimate: number + /** 调用接口的时间。 */ + invokeStart: number + /** 当前请求的IP */ + peerIP: string + /** 当前请求的端口 */ + port: number + /** 使用协议类型,有效值:http1.1, h2, quic, unknown */ + protocol: string + /** 结束排队的时间。达到并行上限时才需要排队。如果未发生排队,则该字段和 queueStart 字段值相同 */ + queueEnd: number + /** 开始排队的时间。达到并行上限时才需要排队。 */ + queueStart: number + /** 收到字节数 */ + receivedBytedCount: number + /** 最后一个 HTTP 重定向完成时的时间。有跳转且是同域名内部的重定向才算,否则值为 0 */ + redirectEnd: number + /** 第一个 HTTP 重定向发生时的时间。有跳转且是同域名内的重定向才算,否则值为 0 */ + redirectStart: number + /** HTTP请求读取真实文档结束的时间 */ + requestEnd: number + /** HTTP请求读取真实文档开始的时间(完成建立连接),包括从本地读取缓存。连接错误重连时,这里显示的也是新建立连接的时间 */ + requestStart: number + /** HTTP 响应全部接收完成的时间(获取到最后一个字节),包括从本地读取缓存 */ + responseEnd: number + /** HTTP 开始接收响应的时间(获取到第一个字节),包括从本地读取缓存 */ + responseStart: number + /** 当次请求连接过程中实时 rtt */ + rtt: number + /** 发送的字节数 */ + sendBytesCount: number + /** 是否复用连接 */ + socketReused: boolean + /** 当前网络的实际下载kbps */ + throughputKbps: number + /** 传输层根据多个请求评估的当前网络的 rtt(仅供参考) */ + transportRttEstimate: number + /** 是否走到了高性能模式。基础库 v3.3.4 起支持。 */ + usingHighPerformanceMode: boolean + } + interface RequestSubscribeDeviceMessageFailCallbackResult { + /** 接口调用失败错误码,有可能为空 */ + errCode: number + /** 接口调用失败错误信息 */ + errMsg: string + } + interface RequestSubscribeDeviceMessageOption { + /** 设备型号 id 。通过微信公众平台注册设备获得。 */ + modelId: string + /** 设备唯一序列号。由厂商分配,长度不能超过128字节。字符只接受数字,大小写字母,下划线(_)和连字符(-)。 */ + sn: string + /** 设备票据,5分钟内有效。 */ + snTicket: string + /** 需要订阅的消息模板的 id 的集合,一次调用最多可订阅3条消息 */ + tmplIds: any[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RequestSubscribeDeviceMessageCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RequestSubscribeDeviceMessageFailCallback + /** 接口调用成功的回调函数 */ + success?: RequestSubscribeDeviceMessageSuccessCallback + } + interface RequestSubscribeDeviceMessageSuccessCallbackResult { + /** [TEMPLATE_ID]是动态的键,即模板id,值包括'accept'、'reject'、'ban'、'filter'、'acceptWithAudio'。'accept'表示用户同意订阅该条id对应的模板消息,'reject'表示用户拒绝订阅该条id对应的模板消息,'ban'表示已被后台封禁,'acceptWithAudio' 表示用户接收订阅消息并开启了语音提醒,'filter'表示该模板因为模板标题同名被后台过滤。例如 { errMsg: "requestSubscribeDeviceMessage:ok", zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE: "accept"} 表示用户同意订阅zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE这条消息 */ + [TEMPLATE_ID: string]: string + /** 接口调用成功时errMsg值为'requestSubscribeDeviceMessage:ok' */ + errMsg: string + } + interface RequestSubscribeMessageFailCallbackResult { + /** 接口调用失败错误码 */ + errCode: number + /** 接口调用失败错误信息 */ + errMsg: string + } + interface RequestSubscribeMessageOption { + /** 需要订阅的消息模板的id的集合,一次调用最多可订阅3条消息(注意:iOS客户端7.0.6版本、Android客户端7.0.7版本之后的一次性订阅/长期订阅才支持多个模板消息,iOS客户端7.0.5版本、Android客户端7.0.6版本之前的一次订阅只支持一个模板消息)消息模板id在[微信公众平台(mp.weixin.qq.com)-功能-订阅消息]中配置。每个tmplId对应的模板标题需要不相同,否则会被过滤。 */ + tmplIds: any[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RequestSubscribeMessageCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RequestSubscribeMessageFailCallback + /** 接口调用成功的回调函数 */ + success?: RequestSubscribeMessageSuccessCallback + } + interface RequestSubscribeMessageSuccessCallbackResult { + /** [TEMPLATE_ID]是动态的键,即模板id,值包括'accept'、'reject'、'ban'、'filter'。'accept'表示用户同意订阅该条id对应的模板消息,'reject'表示用户拒绝订阅该条id对应的模板消息,'ban'表示已被后台封禁,'filter'表示该模板因为模板标题同名被后台过滤。例如 { errMsg: "requestSubscribeMessage:ok", zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE: "accept"} 表示用户同意订阅zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE这条消息 */ + [TEMPLATE_ID: string]: string + /** 接口调用成功时errMsg值为'requestSubscribeMessage:ok' */ + errMsg: string + } + interface RequestSuccessCallbackResult< + T extends string | IAnyObject | ArrayBuffer = + | string + | IAnyObject + | ArrayBuffer + > { + /** 需要基础库: `2.10.0` + * + * 开发者服务器返回的 cookies,格式为字符串数组 */ + cookies: string[] + /** 开发者服务器返回的数据 */ + data: T + /** 需要基础库: `3.0.0` + * + * 网络请求过程中的一些异常信息,例如httpdns超时等 */ + exception: RequestException + /** 需要基础库: `1.2.0` + * + * 开发者服务器返回的 HTTP Response Header */ + header: IAnyObject + /** 需要基础库: `2.10.4` + * + * 网络请求过程中一些调试信息,[查看详细说明](https://developers.weixin.qq.com/miniprogram/dev/framework/performance/network.html) */ + profile: RequestProfile + /** 开发者服务器返回的 HTTP 状态码 */ + statusCode: number + /** 需要基础库: `3.4.10` + * + * 最终请求是否使用了HttpDNS解析的IP。仅当enableHttpDNS传true时返回此字段。如果开启enableHttpDNS但最终请求未使用HttpDNS解析的IP,可在exception查看原因。 */ + useHttpDNS: boolean + errMsg: string + } + interface RequestTaskOnHeadersReceivedListenerResult { + /** 开发者服务器返回的 cookies,格式为字符串数组 */ + cookies: string[] + /** 开发者服务器返回的 HTTP Response Header */ + header: IAnyObject + /** 开发者服务器返回的 HTTP 状态码 (目前开发者工具上不会返回 statusCode 字段,可用真机查看该字段,后续将会支持) */ + statusCode: number + } + interface RequestVirtualPaymentOption { + /** 支付的类型, 不同的支付类型有各自额外要传的附加参数 + * + * 可选值: + * - 'short_series_goods': 道具直购; + * - 'short_series_coin': 代币充值; */ + mode: 'short_series_goods' | 'short_series_coin' + /** 支付签名, 详见[《签名详解》](https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/virtual-payment.html) */ + paySig: string + /** 具体支付参数见signData, 该参数需以string形式传递, 例如signData: '{"offerId":"123","buyQuantity":1,"env":0,"currencyType":"CNY","productId":"testproductId","goodsPrice":10,"outTradeNo":"xxxxxx","attach":"testdata"}' */ + signData: SignData + /** 用户态签名, 详见[《签名详解》](https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/virtual-payment.html) */ + signature: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RequestVirtualPaymentCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RequestVirtualPaymentFailCallback + /** 接口调用成功的回调函数 */ + success?: RequestVirtualPaymentSuccessCallback + } + interface RequirePrivacyAuthorizeOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RequirePrivacyAuthorizeCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RequirePrivacyAuthorizeFailCallback + /** 接口调用成功的回调函数 */ + success?: RequirePrivacyAuthorizeSuccessCallback + } + interface ReserveChannelsLiveOption { + /** 预告 id,通过 getChannelsLiveNoticeInfo 接口获取 */ + noticeId: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ReserveChannelsLiveCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ReserveChannelsLiveFailCallback + /** 接口调用成功的回调函数 */ + success?: ReserveChannelsLiveSuccessCallback + } + interface RestartMiniProgramOption { + /** 打开的页面路径,path 中 ? 后面的部分会成为 query */ + path: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RestartMiniProgramCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RestartMiniProgramFailCallback + /** 接口调用成功的回调函数 */ + success?: RestartMiniProgramSuccessCallback + } + interface ResumeBGMOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ResumeBGMCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ResumeBGMFailCallback + /** 接口调用成功的回调函数 */ + success?: ResumeBGMSuccessCallback + } + interface ResumeOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ResumeCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ResumeFailCallback + /** 接口调用成功的回调函数 */ + success?: ResumeSuccessCallback + } + interface RewardedVideoAdOnCloseListenerResult { + /** 需要基础库: `2.1.0` + * + * 视频是否是在用户完整观看的情况下被关闭的 */ + isEnded: boolean + } + interface RewardedVideoAdOnErrorListenerResult { + /** 需要基础库: `2.2.2` + * + * 错误码 + * + * 可选值: + * - 1000: 后端接口调用失败; + * - 1001: 参数错误; + * - 1002: 广告单元无效; + * - 1003: 内部错误; + * - 1004: 无合适的广告; + * - 1005: 广告组件审核中; + * - 1006: 广告组件被驳回; + * - 1007: 广告组件被封禁; + * - 1008: 广告单元已关闭; */ + errCode: 1000 | 1001 | 1002 | 1003 | 1004 | 1005 | 1006 | 1007 | 1008 + /** 错误信息 */ + errMsg: string + } + interface RewriteRouteOption { + /** 重写目标页面的路径 (代码包路径), 路径后可以带参数。参数与路径之间使用 `?` 分隔,参数键与参数值用 `=` 相连,不同参数用 `&` 分隔;如 `'path?key=value&key2=value2'` */ + url: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RewriteRouteCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RewriteRouteFailCallback + /** 是否直接保留当前路由事件的参数,默认为 `false`;开启时,`url` 里面传入的参数会被丢弃 */ + preserveQuery?: boolean + /** 接口调用成功的回调函数 */ + success?: RewriteRouteSuccessCallback + } + interface RmdirOption { + /** 要删除的目录路径 (本地路径) */ + dirPath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RmdirCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: RmdirFailCallback + /** 需要基础库: `2.3.0` + * + * 是否递归删除目录。如果为 true,则删除该目录和该目录下的所有子目录以及文件。 */ + recursive?: boolean + /** 接口调用成功的回调函数 */ + success?: RmdirSuccessCallback + } + interface RunOCROption { + /** 待识别图像的像素点数据,每四项表示一个像素点的 RGBA */ + frameBuffer: ArrayBuffer + /** 图像高度 */ + height: number + /** 图像宽度 */ + width: number + } + interface SafeArea { + /** 安全区域右下角纵坐标 */ + bottom: number + /** 安全区域的高度,单位逻辑像素 */ + height: number + /** 安全区域左上角横坐标 */ + left: number + /** 安全区域右下角横坐标 */ + right: number + /** 安全区域左上角纵坐标 */ + top: number + /** 安全区域的宽度,单位逻辑像素 */ + width: number + } + interface SaveFileOption { + /** 临时存储文件路径 (本地路径) */ + tempFilePath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SaveFileCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SaveFileFailCallback + /** 要存储的文件路径 (本地路径) */ + filePath?: string + /** 接口调用成功的回调函数 */ + success?: SaveFileSuccessCallback + } + interface SaveFileSuccessCallbackResult { + /** 存储后的文件路径 (本地路径) */ + savedFilePath: string + errMsg: string + } + interface SaveFileToDiskOption { + /** 待保存文件路径 */ + filePath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SaveFileToDiskCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SaveFileToDiskFailCallback + /** 接口调用成功的回调函数 */ + success?: SaveFileToDiskSuccessCallback + } + interface SaveImageToPhotosAlbumOption { + /** 图片文件路径,可以是临时文件路径或永久文件路径 (本地路径) ,不支持网络路径 */ + filePath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SaveImageToPhotosAlbumCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SaveImageToPhotosAlbumFailCallback + /** 接口调用成功的回调函数 */ + success?: SaveImageToPhotosAlbumSuccessCallback + } + interface SaveVideoToPhotosAlbumOption { + /** 视频文件路径,可以是临时文件路径也可以是永久文件路径 (本地路径) */ + filePath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SaveVideoToPhotosAlbumCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SaveVideoToPhotosAlbumFailCallback + /** 接口调用成功的回调函数 */ + success?: SaveVideoToPhotosAlbumSuccessCallback + } + interface ScanCodeOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ScanCodeCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ScanCodeFailCallback + /** 需要基础库: `1.2.0` + * + * 是否只能从相机扫码,不允许从相册选择图片 */ + onlyFromCamera?: boolean + /** 需要基础库: `1.7.0` + * + * 扫码类型 + * + * 可选值: + * - 'barCode': 一维码; + * - 'qrCode': 二维码; + * - 'wxCode': 小程序码; + * - 'datamatrix': Data Matrix 码; + * - 'pdf417': PDF417 条码; */ + scanType?: Array< + 'barCode' | 'qrCode' | 'wxCode' | 'datamatrix' | 'pdf417' + > + /** 接口调用成功的回调函数 */ + success?: ScanCodeSuccessCallback + } + interface ScanCodeSuccessCallbackResult { + /** 所扫码的字符集 */ + charSet: string + /** 当所扫的码为当前小程序二维码时,会返回此字段,内容为二维码携带的 path */ + path: string + /** 原始数据,base64编码 */ + rawData: string + /** 所扫码的内容 */ + result: string + /** 所扫码的类型 + * + * 可选值: + * - 'QR_CODE': 二维码; + * - 'AZTEC': 一维码; + * - 'CODABAR': 一维码; + * - 'CODE_39': 一维码; + * - 'CODE_93': 一维码; + * - 'CODE_128': 一维码; + * - 'DATA_MATRIX': 二维码; + * - 'EAN_8': 一维码; + * - 'EAN_13': 一维码; + * - 'ITF': 一维码; + * - 'MAXICODE': 一维码; + * - 'PDF_417': 二维码; + * - 'RSS_14': 一维码; + * - 'RSS_EXPANDED': 一维码; + * - 'UPC_A': 一维码; + * - 'UPC_E': 一维码; + * - 'UPC_EAN_EXTENSION': 一维码; + * - 'WX_CODE': 二维码; + * - 'CODE_25': 一维码; */ + scanType: + | 'QR_CODE' + | 'AZTEC' + | 'CODABAR' + | 'CODE_39' + | 'CODE_93' + | 'CODE_128' + | 'DATA_MATRIX' + | 'EAN_8' + | 'EAN_13' + | 'ITF' + | 'MAXICODE' + | 'PDF_417' + | 'RSS_14' + | 'RSS_EXPANDED' + | 'UPC_A' + | 'UPC_E' + | 'UPC_EAN_EXTENSION' + | 'WX_CODE' + | 'CODE_25' + errMsg: string + } + /** 需要基础库: `3.1.0` + * + * 配置项,仅 Skyine 模式支持 */ + interface ScrollIntoViewOptions { + /** 指定目标节点在视口内的位置 */ + alignment?: string + /** 是否启用滚动动画 */ + animated?: boolean + /** 跳转到目标节点时的额外偏移 */ + offset?: number + /** 只跳转到 cacheExtent 以内的目标节点,性能更佳 */ + withinExtent?: boolean + } + interface ScrollOffsetCallbackResult { + /** 节点的 dataset */ + dataset: IAnyObject + /** 节点的 ID */ + id: string + /** 节点的滚动高度 */ + scrollHeight: number + /** 节点的水平滚动位置 */ + scrollLeft: number + /** 节点的竖直滚动位置 */ + scrollTop: number + /** 节点的滚动宽度 */ + scrollWidth: number + } + /** 需要基础库: `2.14.4` +* +* 增强 ScrollView 实例,可通过 [wx.createSelectorQuery](https://developers.weixin.qq.com/miniprogram/dev/api/wxml/wx.createSelectorQuery.html) 的 [NodesRef.node](https://developers.weixin.qq.com/miniprogram/dev/api/wxml/NodesRef.node.html) 方法获取。 仅在 scroll-view 组件开启 enhanced 属性后生效。 +* +* **示例代码** +* +* ```js +wx.createSelectorQuery() + .select('#scrollview') + .node() + .exec((res) => { + const scrollView = res[0].node; + scrollView.scrollEnabled = false; + }) +``` */ + interface ScrollViewContext { + /** 设置滚动边界弹性 (仅在 iOS 下生效) */ + bounces: boolean + /** 取消滚动惯性 (仅在 iOS 下生效) */ + decelerationDisabled: boolean + /** 设置滚动减速速率 (仅在 iOS 下生效) */ + fastDeceleration: boolean + /** 分页滑动开关 */ + pagingEnabled: boolean + /** 滚动开关 */ + scrollEnabled: boolean + /** 设置是否显示滚动条 */ + showScrollbar: boolean + /** [ScrollViewContext.closeRefresh()](https://developers.weixin.qq.com/miniprogram/dev/api/ui/scroll/ScrollViewContext.closeRefresh.html) + * + * 需要基础库: `3.0.0` + * + * 在插件中使用:支持 + * + * 关闭下拉刷新。 */ + closeRefresh(): void + /** [ScrollViewContext.closeTwoLevel(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/scroll/ScrollViewContext.closeTwoLevel.html) + * + * 需要基础库: `3.0.0` + * + * 在插件中使用:支持 + * + * 关闭下拉二级。 */ + closeTwoLevel(option: TriggerRefreshOption): void + /** [ScrollViewContext.scrollIntoView(string selector, object ScrollIntoViewOptions)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/scroll/ScrollViewContext.scrollIntoView.html) + * + * 需要基础库: `2.14.4` + * + * 在插件中使用:支持 + * + * 滚动至指定位置 */ + scrollIntoView( + /** 元素选择器 */ + selector: string, + /** 需要基础库: `3.1.0` + * + * 配置项,仅 Skyine 模式支持 */ + ScrollIntoViewOptions: ScrollIntoViewOptions + ): void + /** [ScrollViewContext.scrollTo(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/scroll/ScrollViewContext.scrollTo.html) + * + * 需要基础库: `2.14.4` + * + * 在插件中使用:支持 + * + * 滚动至指定位置 */ + scrollTo(option: ScrollViewContextScrollToOption): void + /** [ScrollViewContext.triggerRefresh(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/scroll/ScrollViewContext.triggerRefresh.html) + * + * 需要基础库: `3.0.0` + * + * 在插件中使用:支持 + * + * 触发下拉刷新。 */ + triggerRefresh(option: TriggerRefreshOption): void + /** [ScrollViewContext.triggerTwoLevel(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/scroll/ScrollViewContext.triggerTwoLevel.html) + * + * 需要基础库: `3.0.0` + * + * 在插件中使用:支持 + * + * 触发下拉二级。 */ + triggerTwoLevel(option: TriggerRefreshOption): void + } + interface ScrollViewContextScrollToOption { + /** 是否启用滚动动画 */ + animated?: boolean + /** 滚动动画时长 (仅在 iOS 下生效) */ + duration?: number + /** 左边界距离 */ + left?: number + /** 顶部距离 */ + top?: number + /** 初始速度 (仅在 iOS 下生效) */ + velocity?: number + } + interface SeekBackgroundAudioOption { + /** 音乐位置,单位:秒 */ + position: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SeekBackgroundAudioCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SeekBackgroundAudioFailCallback + /** 接口调用成功的回调函数 */ + success?: SeekBackgroundAudioSuccessCallback + } + interface SelectGroupMembersOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SelectGroupMembersCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SelectGroupMembersFailCallback + /** 最多可选人数 */ + maxSelectCount?: number + /** 接口调用成功的回调函数 */ + success?: SelectGroupMembersSuccessCallback + } + interface SendHCEMessageOption { + /** 二进制数据 */ + data: ArrayBuffer + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SendHCEMessageCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SendHCEMessageFailCallback + /** 接口调用成功的回调函数 */ + success?: SendHCEMessageSuccessCallback + } + interface SendMessageOption { + /** SEI消息 */ + msg: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SendMessageCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SendMessageFailCallback + /** 接口调用成功的回调函数 */ + success?: SendMessageSuccessCallback + } + interface SendSmsOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SendSmsCompleteCallback + /** 预填到发送短信面板的内容 */ + content?: string + /** 接口调用失败的回调函数 */ + fail?: SendSmsFailCallback + /** 预填到发送短信面板的手机号 */ + phoneNumber?: string + /** 接口调用成功的回调函数 */ + success?: SendSmsSuccessCallback + } + interface SendSocketMessageOption { + /** 需要发送的内容 */ + data: string | ArrayBuffer + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SendSocketMessageCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SendSocketMessageFailCallback + /** 接口调用成功的回调函数 */ + success?: SendSocketMessageSuccessCallback + } + interface SetBGMVolumeOption { + /** 音量大小,范围是 0-1 */ + volume: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetBGMVolumeCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetBGMVolumeFailCallback + /** 接口调用成功的回调函数 */ + success?: SetBGMVolumeSuccessCallback + } + interface SetBLEMTUFailCallbackResult { + /** 最终协商的 MTU 值。如果协商失败则无此参数。安卓客户端 8.0.9 开始支持。 */ + mtu: number + } + interface SetBLEMTUOption { + /** 蓝牙设备 id */ + deviceId: string + /** 最大传输单元。设置范围为 (22,512) 区间内,单位 bytes */ + mtu: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetBLEMTUCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetBLEMTUFailCallback + /** 接口调用成功的回调函数 */ + success?: SetBLEMTUSuccessCallback + } + interface SetBLEMTUSuccessCallbackResult { + /** 最终协商的 MTU 值,与传入参数一致。安卓客户端 8.0.9 开始支持。 */ + mtu: number + errMsg: string + } + interface SetBackgroundColorOption { + /** 窗口的背景色,必须为十六进制颜色值 */ + backgroundColor?: string + /** 底部窗口的背景色,必须为十六进制颜色值,仅 iOS 支持 */ + backgroundColorBottom?: string + /** 顶部窗口的背景色,必须为十六进制颜色值,仅 iOS 支持 */ + backgroundColorTop?: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetBackgroundColorCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetBackgroundColorFailCallback + /** 接口调用成功的回调函数 */ + success?: SetBackgroundColorSuccessCallback + } + interface SetBackgroundFetchTokenOption { + /** 自定义的登录态 */ + token: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetBackgroundFetchTokenCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetBackgroundFetchTokenFailCallback + /** 接口调用成功的回调函数 */ + success?: SetBackgroundFetchTokenSuccessCallback + } + interface SetBackgroundTextStyleOption { + /** 下拉背景字体、loading 图的样式。 + * + * 可选值: + * - 'dark': dark 样式; + * - 'light': light 样式; */ + textStyle: 'dark' | 'light' + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetBackgroundTextStyleCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetBackgroundTextStyleFailCallback + /** 接口调用成功的回调函数 */ + success?: SetBackgroundTextStyleSuccessCallback + } + interface SetBoundaryOption { + /** 东北角经纬度 */ + northeast: MapPostion + /** 西南角经纬度 */ + southwest: MapPostion + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetBoundaryCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetBoundaryFailCallback + /** 接口调用成功的回调函数 */ + success?: SetBoundarySuccessCallback + } + interface SetCenterOffsetOption { + /** 偏移量,两位数组 */ + offset: number[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetCenterOffsetCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetCenterOffsetFailCallback + /** 接口调用成功的回调函数 */ + success?: SetCenterOffsetSuccessCallback + } + interface SetClipboardDataOption { + /** 剪贴板的内容 */ + data: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetClipboardDataCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetClipboardDataFailCallback + /** 接口调用成功的回调函数 */ + success?: SetClipboardDataSuccessCallback + } + interface SetContentsOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetContentsCompleteCallback + /** 表示内容的delta对象 */ + delta?: IAnyObject + /** 接口调用失败的回调函数 */ + fail?: SetContentsFailCallback + /** 带标签的HTML内容 */ + html?: string + /** 接口调用成功的回调函数 */ + success?: SetContentsSuccessCallback + } + interface SetEnable1v1ChatOption { + /** 是否开启 */ + enable: boolean + /** 窗口背景色(音频通话背景以及小窗模式背景) + * + * 可选值: + * - 0: #262930; + * - 1: #FA5151; + * - 2: #FA9D3B; + * - 3: #3D7257; + * - 4: #1485EE; + * - 5: #6467F0; */ + backgroundType?: 0 | 1 | 2 | 3 | 4 | 5 + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetEnable1v1ChatCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetEnable1v1ChatFailCallback + /** 小窗样式 */ + minWindowType?: number + /** 接口调用成功的回调函数 */ + success?: SetEnable1v1ChatSuccessCallback + } + interface SetEnableDebugOption { + /** 是否打开调试 */ + enableDebug: boolean + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetEnableDebugCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetEnableDebugFailCallback + /** 接口调用成功的回调函数 */ + success?: SetEnableDebugSuccessCallback + } + interface SetInnerAudioOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetInnerAudioOptionCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetInnerAudioOptionFailCallback + /** 是否与其他音频混播,设置为 true 之后,不会终止其他应用或微信内的音乐 */ + mixWithOther?: boolean + /** (仅在 iOS 生效)是否遵循静音开关,设置为 false 之后,即使是在静音模式下,也能播放声音 */ + obeyMuteSwitch?: boolean + /** true 代表用扬声器播放,false 代表听筒播放,默认值为 true。 */ + speakerOn?: boolean + /** 接口调用成功的回调函数 */ + success?: SetInnerAudioOptionSuccessCallback + } + interface SetKeepScreenOnOption { + /** 是否保持屏幕常亮 */ + keepScreenOn: boolean + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetKeepScreenOnCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetKeepScreenOnFailCallback + /** 接口调用成功的回调函数 */ + success?: SetKeepScreenOnSuccessCallback + } + interface SetLocMarkerIconOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetLocMarkerIconCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetLocMarkerIconFailCallback + /** 图标路径,支持网络路径、本地路径、代码包路径 */ + iconPath?: string + /** 接口调用成功的回调函数 */ + success?: SetLocMarkerIconSuccessCallback + } + interface SetMICVolumeOption { + /** 音量大小,范围是 0.0-1.0 */ + volume: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetMICVolumeCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetMICVolumeFailCallback + /** 接口调用成功的回调函数 */ + success?: SetMICVolumeSuccessCallback + } + interface SetNavigationBarColorOption { + /** 背景颜色值,有效值为十六进制颜色 */ + backgroundColor: string + /** 前景颜色值,包括按钮、标题、状态栏的颜色,仅支持 #ffffff 和 #000000 */ + frontColor: string + /** 动画效果 */ + animation?: AnimationOption + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetNavigationBarColorCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetNavigationBarColorFailCallback + /** 接口调用成功的回调函数 */ + success?: SetNavigationBarColorSuccessCallback + } + interface SetNavigationBarTitleOption { + /** 页面标题 */ + title: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetNavigationBarTitleCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetNavigationBarTitleFailCallback + /** 接口调用成功的回调函数 */ + success?: SetNavigationBarTitleSuccessCallback + } + interface SetScreenBrightnessOption { + /** 屏幕亮度值,范围 0 ~ 1,0 最暗,1 最亮。在安卓端支持传入特殊值 -1,表示屏幕亮度跟随系统变化 */ + value: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetScreenBrightnessCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetScreenBrightnessFailCallback + /** 接口调用成功的回调函数 */ + success?: SetScreenBrightnessSuccessCallback + } + interface SetSelectionOption { + /** 选区开始位置 */ + index: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetSelectionCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetSelectionFailCallback + /** 选区长度 */ + length?: number + /** 接口调用成功的回调函数 */ + success?: SetSelectionSuccessCallback + } + interface SetStorageOption { + /** 需要存储的内容。只支持原生类型、Date、及能够通过`JSON.stringify`序列化的对象。 */ + data: T + /** 本地缓存中指定的 key */ + key: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetStorageCompleteCallback + /** 需要基础库: `2.21.3` + * + * 是否开启加密存储。只有异步的 setStorage 接口支持开启加密存储。开启后,将会对 data 使用 AES128 加密,接口回调耗时将会增加。若开启加密存储,setStorage 和 getStorage 需要同时声明 encrypt 的值为 true。此外,由于加密后的数据会比原始数据膨胀1.4倍,因此开启 encrypt 的情况下,单个 key 允许存储的最大数据长度为 0.7MB,所有数据存储上限为 7.1MB */ + encrypt?: boolean + /** 接口调用失败的回调函数 */ + fail?: SetStorageFailCallback + /** 接口调用成功的回调函数 */ + success?: SetStorageSuccessCallback + } + interface SetTabBarBadgeOption { + /** tabBar 的哪一项,从左边算起 */ + index: number + /** 显示的文本,超过 4 个字符则显示成 ... */ + text: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetTabBarBadgeCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetTabBarBadgeFailCallback + /** 接口调用成功的回调函数 */ + success?: SetTabBarBadgeSuccessCallback + } + interface SetTabBarItemOption { + /** tabBar 的哪一项,从左边算起 */ + index: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetTabBarItemCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetTabBarItemFailCallback + /** 图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px,当 postion 为 top 时,此参数无效 */ + iconPath?: string + /** 选中时的图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px ,当 postion 为 top 时,此参数无效 */ + selectedIconPath?: string + /** 接口调用成功的回调函数 */ + success?: SetTabBarItemSuccessCallback + /** tab 上的按钮文字 */ + text?: string + } + interface SetTabBarStyleOption { + /** tab 的背景色,HexColor */ + backgroundColor?: string + /** tabBar上边框的颜色, 仅支持 black/white */ + borderStyle?: string + /** tab 上的文字默认颜色,HexColor */ + color?: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetTabBarStyleCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetTabBarStyleFailCallback + /** tab 上的文字选中时的颜色,HexColor */ + selectedColor?: string + /** 接口调用成功的回调函数 */ + success?: SetTabBarStyleSuccessCallback + } + interface SetTimeoutOption { + /** 设置超时时间 (ms) */ + timeout: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetTimeoutCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetTimeoutFailCallback + /** 接口调用成功的回调函数 */ + success?: SetTimeoutSuccessCallback + } + interface SetTopBarTextOption { + /** 置顶栏文字 */ + text: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetTopBarTextCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetTopBarTextFailCallback + /** 接口调用成功的回调函数 */ + success?: SetTopBarTextSuccessCallback + } + interface SetVisualEffectOnCaptureOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetVisualEffectOnCaptureCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetVisualEffectOnCaptureFailCallback + /** 接口调用成功的回调函数 */ + success?: SetVisualEffectOnCaptureSuccessCallback + /** 截屏/录屏时的表现,仅支持 none / hidden,传入 hidden 则表示在截屏/录屏时隐藏屏幕 */ + visualEffect?: string + } + interface SetWifiListOption { + /** 提供预设的 Wi-Fi 信息列表 */ + wifiList: WifiData[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetWifiListCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetWifiListFailCallback + /** 接口调用成功的回调函数 */ + success?: SetWifiListSuccessCallback + } + interface SetWindowSizeOption { + /** 窗口高度,以像素为单位 */ + height: number + /** 窗口宽度,以像素为单位 */ + width: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetWindowSizeCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SetWindowSizeFailCallback + /** 接口调用成功的回调函数 */ + success?: SetWindowSizeSuccessCallback + } + interface SetZoomSuccessCallbackResult { + /** 实际设置的缩放级别。由于系统限制,某些机型可能无法设置成指定值,会改用最接近的可设值。 */ + zoom: number + errMsg: string + } + interface ShareAppMessageToGroupOption { + /** 转发标题 */ + title: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShareAppMessageToGroupCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ShareAppMessageToGroupFailCallback + /** 自定义图片路径,支持PNG及JPG,显示图片长宽比是 5:4,默认使用截图 */ + imageUrl?: string + /** 转发路径,必须是以 / 开头的完整路径,默认为当前页面 */ + path?: string + /** 接口调用成功的回调函数 */ + success?: ShareAppMessageToGroupSuccessCallback + } + interface ShareEmojiToGroupOption { + /** 要分享的表情地址,必须为本地路径或临时路径 */ + imagePath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShareEmojiToGroupCompleteCallback + /** 从消息小程序入口打开小程序的路径,默认为聊天工具启动路径 */ + entrancePath?: string + /** 接口调用失败的回调函数 */ + fail?: ShareEmojiToGroupFailCallback + /** 分享的表情消息是否要带小程序入口 */ + needShowEntrance?: boolean + /** 接口调用成功的回调函数 */ + success?: ShareEmojiToGroupSuccessCallback + } + interface ShareFileMessageOption { + /** 要分享的文件地址,必须为本地路径或临时路径 */ + filePath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShareFileMessageCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ShareFileMessageFailCallback + /** 自定义文件名,若留空则使用filePath中的文件名 */ + fileName?: string + /** 接口调用成功的回调函数 */ + success?: ShareFileMessageSuccessCallback + } + interface ShareFileToGroupOption { + /** 要分享的文件地址,必须为本地路径或临时路径 */ + filePath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShareFileToGroupCompleteCallback + /** 从消息小程序入口打开小程序的路径,默认为聊天工具启动路径 */ + entrancePath?: string + /** 接口调用失败的回调函数 */ + fail?: ShareFileToGroupFailCallback + /** 自定义文件名,若留空则使用filePath中的文件名 */ + fileName?: string + /** 分享的图片消息是否要带小程序入口 */ + needShowEntrance?: boolean + /** 接口调用成功的回调函数 */ + success?: ShareFileToGroupSuccessCallback + } + interface ShareImageToGroupOption { + /** 要分享的图片地址,必须为本地路径或临时路径 */ + imagePath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShareImageToGroupCompleteCallback + /** 从消息小程序入口打开小程序的路径,默认为聊天工具启动路径 */ + entrancePath?: string + /** 接口调用失败的回调函数 */ + fail?: ShareImageToGroupFailCallback + /** 分享的图片消息是否要带小程序入口 */ + needShowEntrance?: boolean + /** 接口调用成功的回调函数 */ + success?: ShareImageToGroupSuccessCallback + } + interface ShareToWeRunOption { + /** 运动数据列表 */ + recordList: WxaSportRecord[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShareToWeRunCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ShareToWeRunFailCallback + /** 接口调用成功的回调函数 */ + success?: ShareToWeRunSuccessCallback + } + interface ShareVideoMessageOption { + /** 要分享的视频地址,必须为本地路径或临时路径 */ + videoPath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShareVideoMessageCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ShareVideoMessageFailCallback + /** 接口调用成功的回调函数 */ + success?: ShareVideoMessageSuccessCallback + /** 缩略图路径,若留空则使用视频首帧 */ + thumbPath?: string + } + interface ShareVideoToGroupOption { + /** 要分享的视频地址,必须为本地路径或临时路径 */ + videoPath: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShareVideoToGroupCompleteCallback + /** 从消息小程序入口打开小程序的路径,默认为聊天工具启动路径 */ + entrancePath?: string + /** 接口调用失败的回调函数 */ + fail?: ShareVideoToGroupFailCallback + /** 分享的图片消息是否要带小程序入口 */ + needShowEntrance?: boolean + /** 接口调用成功的回调函数 */ + success?: ShareVideoToGroupSuccessCallback + /** 缩略图路径,若留空则使用视频首帧 */ + thumbPath?: string + } + /** 需要基础库: `3.2.1` + * + * 鞋部检测配置。用法详情[指南文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/shoe.html)。 */ + interface ShoeTrack { + /** 需要基础库: `3.2.1` + * + * 鞋部检测模式 + * + * 可选值: + * - 1: 通过摄像头实时检测; */ + mode: 1 + } + interface ShowActionSheetOption { + /** 按钮的文字数组,数组长度最大为 6 */ + itemList: string[] + /** 需要基础库: `2.14.0` + * + * 警示文案 */ + alertText?: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShowActionSheetCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ShowActionSheetFailCallback + /** 按钮的文字颜色 */ + itemColor?: string + /** 接口调用成功的回调函数 */ + success?: ShowActionSheetSuccessCallback + } + interface ShowActionSheetSuccessCallbackResult { + /** 用户点击的按钮序号,从上到下的顺序,从0开始 */ + tapIndex: number + errMsg: string + } + interface ShowLoadingOption { + /** 提示的内容 */ + title: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShowLoadingCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ShowLoadingFailCallback + /** 是否显示透明蒙层,防止触摸穿透 */ + mask?: boolean + /** 接口调用成功的回调函数 */ + success?: ShowLoadingSuccessCallback + } + interface ShowModalOption { + /** 取消按钮的文字颜色,必须是 16 进制格式的颜色字符串 */ + cancelColor?: string + /** 取消按钮的文字,最多 4 个字符 */ + cancelText?: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShowModalCompleteCallback + /** 确认按钮的文字颜色,必须是 16 进制格式的颜色字符串 */ + confirmColor?: string + /** 确认按钮的文字,最多 4 个字符 */ + confirmText?: string + /** 提示的内容 */ + content?: string + /** 需要基础库: `2.17.1` + * + * 是否显示输入框 */ + editable?: boolean + /** 接口调用失败的回调函数 */ + fail?: ShowModalFailCallback + /** 需要基础库: `2.17.1` + * + * 显示输入框时的提示文本 */ + placeholderText?: string + /** 是否显示取消按钮 */ + showCancel?: boolean + /** 接口调用成功的回调函数 */ + success?: ShowModalSuccessCallback + /** 提示的标题 */ + title?: string + } + interface ShowModalSuccessCallbackResult { + /** 需要基础库: `1.1.0` + * + * 为 true 时,表示用户点击了取消(用于 Android 系统区分点击蒙层关闭还是点击取消按钮关闭) */ + cancel: boolean + /** 为 true 时,表示用户点击了确定按钮 */ + confirm: boolean + /** editable 为 true 时,用户输入的文本 */ + content: string + errMsg: string + } + interface ShowNavigationBarLoadingOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShowNavigationBarLoadingCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ShowNavigationBarLoadingFailCallback + /** 接口调用成功的回调函数 */ + success?: ShowNavigationBarLoadingSuccessCallback + } + interface ShowRedPackageOption { + /** 封面地址 */ + url: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShowRedPackageCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ShowRedPackageFailCallback + /** 接口调用成功的回调函数 */ + success?: ShowRedPackageSuccessCallback + } + interface ShowShareImageMenuOption { + /** 要分享的图片地址,必须为本地路径或临时路径 */ + path: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShowShareImageMenuCompleteCallback + /** 需要基础库: `3.2.0` + * + * 发送给朋友时,小程序入口打开小程序的路径,如果当前页面允许分享给朋友,则默认为当前页面路径,否则默认为小程序首页 */ + entrancePath?: string + /** 接口调用失败的回调函数 */ + fail?: ShowShareImageMenuFailCallback + /** 需要基础库: `3.2.0` + * + * 分享的图片消息是否要带小程序入口 */ + needShowEntrance?: boolean + /** 接口调用成功的回调函数 */ + success?: ShowShareImageMenuSuccessCallback + } + interface ShowShareMenuOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShowShareMenuCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ShowShareMenuFailCallback + /** 需要基础库: `2.11.3` + * + * 本接口为 Beta 版本,暂只在 Android 平台支持。需要显示的转发按钮名称列表,默认['shareAppMessage']。按钮名称合法值包含 "shareAppMessage"、"shareTimeline" 两种 */ + menus?: string[] + /** 接口调用成功的回调函数 */ + success?: ShowShareMenuSuccessCallback + /** 是否使用带 shareTicket 的转发[详情](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html) */ + withShareTicket?: boolean + } + interface ShowTabBarOption { + /** 是否需要动画效果 */ + animation?: boolean + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShowTabBarCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ShowTabBarFailCallback + /** 接口调用成功的回调函数 */ + success?: ShowTabBarSuccessCallback + } + interface ShowTabBarRedDotOption { + /** tabBar 的哪一项,从左边算起 */ + index: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShowTabBarRedDotCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: ShowTabBarRedDotFailCallback + /** 接口调用成功的回调函数 */ + success?: ShowTabBarRedDotSuccessCallback + } + interface ShowToastOption { + /** 提示的内容 */ + title: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShowToastCompleteCallback + /** 提示的延迟时间 */ + duration?: number + /** 接口调用失败的回调函数 */ + fail?: ShowToastFailCallback + /** 图标 + * + * 可选值: + * - 'success': 显示成功图标,此时 title 文本最多显示 7 个汉字长度; + * - 'error': 显示失败图标,此时 title 文本最多显示 7 个汉字长度; + * - 'loading': 显示加载图标,此时 title 文本最多显示 7 个汉字长度; + * - 'none': 不显示图标,此时 title 文本最多可显示两行,[1.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)及以上版本支持; */ + icon?: 'success' | 'error' | 'loading' | 'none' + /** 需要基础库: `1.1.0` + * + * 自定义图标的本地路径,image 的优先级高于 icon */ + image?: string + /** 是否显示透明蒙层,防止触摸穿透 */ + mask?: boolean + /** 接口调用成功的回调函数 */ + success?: ShowToastSuccessCallback + } + /** 具体支付参数见signData, 该参数需以string形式传递, 例如signData: '{"offerId":"123","buyQuantity":1,"env":0,"currencyType":"CNY","productId":"testproductId","goodsPrice":10,"outTradeNo":"xxxxxx","attach":"testdata"}' */ + interface SignData { + /** 透传数据, 发货通知时会透传给开发者 */ + attach: string + /** 购买数量 */ + buyQuantity: number + /** 币种 + * + * 可选值: + * - 'CNY': 人民币; */ + currencyType: 'CNY' + /** 在米大师侧申请的应用 id, mp-支付基础配置中的offerid */ + offerId: string + /** 业务订单号, 每个订单号只能使用一次, 重复使用会失败(极端情况不保证唯一, 不建议业务强依赖唯一性). 要求8-32个字符内, 只能是数字、大小写字母、符号 _-|*@组成, 不能以下划线(_)开头 */ + outTradeNo: string + /** 环境配置, 0 米大师正式环境, 1 米大师沙箱环境, 默认为 0 */ + env?: number + /** 道具单价(分), **该字段仅mode=short_series_goods时需要必填**, 用来校验价格与后台道具价格是否一致, 避免用户在业务商城页看到的价格与实际价格不一致导致投诉 */ + goodsPrice?: number + /** 道具ID, **该字段仅mode=short_series_goods时需要必填** */ + productId?: string + } + interface Size { + /** 变化后的窗口高度,单位 px */ + windowHeight: number + /** 变化后的窗口宽度,单位 px */ + windowWidth: number + } + /** 当前运行环境对于 [Skyline 渲染引擎](https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/skyline/introduction.html) 的支持情况 */ + interface SkylineInfo { + /** 当前运行环境是否支持 [Skyline 渲染引擎](https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/skyline/introduction.html) */ + isSupported: boolean + /** 当前运行环境 [Skyline 渲染引擎](https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/skyline/introduction.html) 的版本号,形如 `0.9.7` */ + version: string + /** 当前运行环境不支持 [Skyline 渲染引擎](https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/skyline/introduction.html) 的原因,仅在 `isSupported` 为 `false` 时出现 + * + * 可选值: + * - 'client not supported': 当前微信客户端不支持 [Skyline 渲染引擎](https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/skyline/introduction.html),可以尝试通过升级微信客户端解决; + * - 'baselib not supported': 当前基础库不支持 [Skyline 渲染引擎](https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/skyline/introduction.html),基础库会自动更新到当前客户端所能支持的最新的版本,基础库不支持时也可以尝试通过升级微信客户端解决; + * - 'a-b test not enabled': 命中了 _We 分析_ 平台上的 AB 实验关闭的情况。详细可以查看 [Skyline 起步 > 配置 We 分析 AB 实验]((skyline/migration#%E9%85%8D%E7%BD%AE-We-%E5%88%86%E6%9E%90-AB-%E5%AE%9E%E9%AA%8C)) 一节; + * - 'SwitchRender option set to webview': 本地调试的快捷切换入口被设置为了强制使用 Webview. 详情可以查看 [Skyline 起步 > 快捷切换入口](#) 一节; */ + reason?: + | 'client not supported' + | 'baselib not supported' + | 'a-b test not enabled' + | 'SwitchRender option set to webview' + } + /** Snapshot 实例,可通过 [SelectorQuery](https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.html) 获取。 + * + * [Snapshot](https://developers.weixin.qq.com/miniprogram/dev/api/skyline/Snapshot.html) 通过 `id` 跟一个 [snapshot](#) 组件绑定,操作对应的 [snapshot](#) 组件。 + * + * **示例代码** + * + * [在微信开发者工具中查看示例](https://developers.weixin.qq.com/s/jdkplEm17hJP) */ + interface Snapshot { + /** 画布高度 */ + height: number + /** 画布宽度 */ + width: number + /** [Snapshot.takeSnapshot(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/skyline/Snapshot.takeSnapshot.html) + * + * 需要基础库: `3.0.0` + * + * 在插件中使用:支持 + * + * 对 snapshot 组件子树进行截图 */ + takeSnapshot(option: TakeSnapshotOption): void + } + /** 需要基础库: `2.10.4` + * + * 网络请求过程中一些调试信息 */ + interface SocketProfile { + /** 完成建立连接的时间(完成握手),如果是持久连接,则与 fetchStart 值相等。注意如果在传输层发生了错误且重新建立连接,则这里显示的是新建立的连接完成的时间。注意这里握手结束,包括安全连接建立完成、SOCKS 授权通过 */ + connectEnd: number + /** 开始建立连接的时间,如果是持久连接,则与 fetchStart 值相等。注意如果在传输层发生了错误且重新建立连接,则这里显示的是新建立的连接开始的时间 */ + connectStart: number + /** 上层请求到返回的耗时 */ + cost: number + /** DNS 域名查询完成的时间,如果使用了本地缓存(即无 DNS 查询)或持久连接,则与 fetchStart 值相等 */ + domainLookUpEnd: number + /** DNS 域名查询开始的时间,如果使用了本地缓存(即无 DNS 查询)或持久连接,则与 fetchStart 值相等 */ + domainLookUpStart: number + /** 组件准备好使用 SOCKET 建立请求的时间,这发生在检查本地缓存之前 */ + fetchStart: number + /** 握手耗时 */ + handshakeCost: number + /** 单次连接的耗时,包括 connect ,tls */ + rtt: number + } + interface SocketTaskCloseOption { + /** 一个数字值表示关闭连接的状态号,表示连接被关闭的原因。 */ + code?: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SocketTaskCloseCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SocketTaskCloseFailCallback + /** 一个可读的字符串,表示连接被关闭的原因。这个字符串必须是不长于 123 字节的 UTF-8 文本(不是字符)。 */ + reason?: string + /** 接口调用成功的回调函数 */ + success?: SocketTaskCloseSuccessCallback + } + interface SocketTaskOnCloseListenerResult { + /** 一个数字值表示关闭连接的状态号,表示连接被关闭的原因。 */ + code: number + /** 一个可读的字符串,表示连接被关闭的原因。 */ + reason: string + } + interface SocketTaskOnMessageListenerResult { + /** 服务器返回的消息 */ + data: string | ArrayBuffer + } + interface SocketTaskSendOption { + /** 需要发送的内容 */ + data: string | ArrayBuffer + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SendCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SendFailCallback + /** 接口调用成功的回调函数 */ + success?: SendSuccessCallback + } + /** 动画配置 */ + interface SpringOption { + /** 阻尼系数 */ + damping?: number + /** 重量系数,值越大移动越慢 */ + mass?: number + /** 动画是否可以在指定值上反弹 */ + overshootClamping?: boolean + /** 弹簧静止时的位移 */ + restDisplacementThreshold?: number + /** 弹簧静止的速度 */ + restSpeedThreshold?: number + /** 弹性系数 */ + stiffness?: number + /** 速度 */ + velocity?: number + } + interface StartAccelerometerOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartAccelerometerCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StartAccelerometerFailCallback + /** 需要基础库: `2.1.0` + * + * 监听加速度数据回调函数的执行频率 + * + * 可选值: + * - 'game': 适用于更新游戏的回调频率,在 20ms/次 左右; + * - 'ui': 适用于更新 UI 的回调频率,在 60ms/次 左右; + * - 'normal': 普通的回调频率,在 200ms/次 左右; */ + interval?: 'game' | 'ui' | 'normal' + /** 接口调用成功的回调函数 */ + success?: StartAccelerometerSuccessCallback + } + interface StartAdvertisingObject { + /** 广播自定义参数 */ + advertiseRequest: AdvertiseReqObj + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartAdvertisingCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StartAdvertisingFailCallback + /** 广播功率 + * + * 可选值: + * - 'low': 功率低; + * - 'medium': 功率适中; + * - 'high': 功率高; */ + powerLevel?: 'low' | 'medium' | 'high' + /** 接口调用成功的回调函数 */ + success?: StartAdvertisingSuccessCallback + } + interface StartBeaconDiscoveryOption { + /** Beacon 设备广播的 UUID 列表 */ + uuids: string[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartBeaconDiscoveryCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StartBeaconDiscoveryFailCallback + /** 是否校验蓝牙开关,仅在 iOS 下有效。iOS 11 起,控制面板里关掉蓝牙,还是能继续使用 Beacon 服务。 */ + ignoreBluetoothAvailable?: boolean + /** 接口调用成功的回调函数 */ + success?: StartBeaconDiscoverySuccessCallback + } + interface StartBluetoothDevicesDiscoveryOption { + /** 是否允许重复上报同一设备。如果允许重复上报,则 [wx.onBlueToothDeviceFound](#) 方法会多次上报同一设备,但是 RSSI 值会有不同。 */ + allowDuplicatesKey?: boolean + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartBluetoothDevicesDiscoveryCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StartBluetoothDevicesDiscoveryFailCallback + /** 上报设备的间隔,单位 ms。0 表示找到新设备立即上报,其他数值根据传入的间隔上报。 */ + interval?: number + /** 扫描模式,越高扫描越快,也越耗电。仅安卓微信客户端 7.0.12 及以上支持。 + * + * 可选值: + * - 'low': 低; + * - 'medium': 中; + * - 'high': 高; */ + powerLevel?: 'low' | 'medium' | 'high' + /** 要搜索的蓝牙设备主服务的 UUID 列表(支持 16/32/128 位 UUID)。某些蓝牙设备会广播自己的主 service 的 UUID。如果设置此参数,则只搜索广播包有对应 UUID 的主服务的蓝牙设备。建议通过该参数过滤掉周边不需要处理的其他蓝牙设备。 */ + services?: string[] + /** 接口调用成功的回调函数 */ + success?: StartBluetoothDevicesDiscoverySuccessCallback + } + interface StartCastingOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartCastingCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StartCastingFailCallback + /** 接口调用成功的回调函数 */ + success?: StartCastingSuccessCallback + } + interface StartCompassOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartCompassCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StartCompassFailCallback + /** 接口调用成功的回调函数 */ + success?: StartCompassSuccessCallback + } + interface StartDeviceMotionListeningOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartDeviceMotionListeningCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StartDeviceMotionListeningFailCallback + /** 监听设备方向的变化回调函数的执行频率 + * + * 可选值: + * - 'game': 适用于更新游戏的回调频率,在 20ms/次 左右; + * - 'ui': 适用于更新 UI 的回调频率,在 60ms/次 左右; + * - 'normal': 普通的回调频率,在 200ms/次 左右; */ + interval?: 'game' | 'ui' | 'normal' + /** 接口调用成功的回调函数 */ + success?: StartDeviceMotionListeningSuccessCallback + } + interface StartDiscoveryOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartDiscoveryCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StartDiscoveryFailCallback + /** 接口调用成功的回调函数 */ + success?: StartDiscoverySuccessCallback + } + interface StartGyroscopeOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartGyroscopeCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StartGyroscopeFailCallback + /** 监听陀螺仪数据回调函数的执行频率 + * + * 可选值: + * - 'game': 适用于更新游戏的回调频率,在 20ms/次 左右; + * - 'ui': 适用于更新 UI 的回调频率,在 60ms/次 左右; + * - 'normal': 普通的回调频率,在 200ms/次 左右; */ + interval?: 'game' | 'ui' | 'normal' + /** 接口调用成功的回调函数 */ + success?: StartGyroscopeSuccessCallback + } + interface StartHCEOption { + /** 需要注册到系统的 AID 列表 */ + aid_list: string[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartHCECompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StartHCEFailCallback + /** 接口调用成功的回调函数 */ + success?: StartHCESuccessCallback + } + interface StartLocalServiceDiscoveryFailCallbackResult { + /** 错误信息 + * + * 可选值: + * - 'invalid param': serviceType 为空; + * - 'scan task already exist': 在当前 startLocalServiceDiscovery 发起的搜索未停止的情况下,再次调用 startLocalServiceDiscovery; */ + errMsg: string + } + interface StartLocalServiceDiscoveryOption { + /** 要搜索的服务类型 */ + serviceType: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartLocalServiceDiscoveryCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StartLocalServiceDiscoveryFailCallback + /** 接口调用成功的回调函数 */ + success?: StartLocalServiceDiscoverySuccessCallback + } + interface StartLocationUpdateBackgroundOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartLocationUpdateBackgroundCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StartLocationUpdateBackgroundFailCallback + /** 接口调用成功的回调函数 */ + success?: StartLocationUpdateBackgroundSuccessCallback + /** wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标 */ + type?: string + } + interface StartLocationUpdateOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartLocationUpdateCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StartLocationUpdateFailCallback + /** 接口调用成功的回调函数 */ + success?: StartLocationUpdateSuccessCallback + /** wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标 */ + type?: string + } + interface StartPreviewOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartPreviewCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StartPreviewFailCallback + /** 接口调用成功的回调函数 */ + success?: StartPreviewSuccessCallback + } + interface StartPullDownRefreshOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartPullDownRefreshCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StartPullDownRefreshFailCallback + /** 接口调用成功的回调函数 */ + success?: StartPullDownRefreshSuccessCallback + } + interface StartRecordSuccessCallbackResult { + /** 录音文件的临时路径 (本地路径) */ + tempFilePath: string + errMsg: string + } + interface StartRecordTimeoutCallbackResult { + /** 封面图片文件的临时路径 (本地路径) */ + tempThumbPath: string + /** 视频的文件的临时路径 (本地路径) */ + tempVideoPath: string + } + interface StartSoterAuthenticationOption { + /** 挑战因子。挑战因子为调用者为此次生物鉴权准备的用于签名的字符串关键识别信息,将作为 `resultJSON` 的一部分,供调用者识别本次请求。例如:如果场景为请求用户对某订单进行授权确认,则可以将订单号填入此参数。 */ + challenge: string + /** 请求使用的可接受的生物认证方式 + * + * 可选值: + * - 'fingerPrint': 指纹识别; + * - 'facial': 人脸识别; + * - 'speech': 声纹识别(暂未支持); */ + requestAuthModes: Array<'fingerPrint' | 'facial' | 'speech'> + /** 验证描述,即识别过程中显示在界面上的对话框提示内容 */ + authContent?: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartSoterAuthenticationCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StartSoterAuthenticationFailCallback + /** 接口调用成功的回调函数 */ + success?: StartSoterAuthenticationSuccessCallback + } + interface StartSoterAuthenticationSuccessCallbackResult { + /** 生物认证方式 */ + authMode: string + /** 错误码 */ + errCode: number + /** 错误信息 */ + errMsg: string + /** 在设备安全区域(TEE)内获得的本机安全信息(如TEE名称版本号等以及防重放参数)以及本次认证信息(仅Android支持,本次认证的指纹ID)。具体说明见下文 */ + resultJSON: string + /** 用SOTER安全密钥对 `resultJSON` 的签名(SHA256 with RSA/PSS, saltlen=20) */ + resultJSONSignature: string + } + interface StartWifiOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartWifiCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StartWifiFailCallback + /** 接口调用成功的回调函数 */ + success?: StartWifiSuccessCallback + } + interface StatOption { + /** 文件/目录路径 (本地路径) */ + path: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StatCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StatFailCallback + /** 需要基础库: `2.3.0` + * + * 是否递归获取目录下的每个文件的 Stats 信息 */ + recursive?: boolean + /** 接口调用成功的回调函数 */ + success?: StatSuccessCallback + } + interface StatSuccessCallbackResult { + /** [Stats](https://developers.weixin.qq.com/miniprogram/dev/api/file/Stats.html)|Array.<[FileStats](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileStats.html)> + * + * 当 recursive 为 false 时,res.stats 是一个 Stats 对象。当 recursive 为 true 且 path 是一个目录的路径时,res.stats 是一个 Array,数组的每一项是一个对象,每个对象包含 path 和 stats。 */ + stats: Stats | FileStats[] + errMsg: string + } + /** 描述文件状态的对象 */ + interface Stats { + /** 文件最近一次被存取或被执行的时间,UNIX 时间戳,对应 POSIX stat.st_atime */ + lastAccessedTime: number + /** 文件最后一次被修改的时间,UNIX 时间戳,对应 POSIX stat.st_mtime */ + lastModifiedTime: number + /** 文件的类型和存取的权限,对应 POSIX stat.st_mode */ + mode: number + /** 文件大小,单位:B,对应 POSIX stat.st_size */ + size: number + /** [boolean Stats.isDirectory()](https://developers.weixin.qq.com/miniprogram/dev/api/file/Stats.isDirectory.html) + * + * 在插件中使用:需要基础库 `2.19.2` + * + * 判断当前文件是否一个目录 */ + isDirectory(): boolean + /** [boolean Stats.isFile()](https://developers.weixin.qq.com/miniprogram/dev/api/file/Stats.isFile.html) + * + * 在插件中使用:需要基础库 `2.19.2` + * + * 判断当前文件是否一个普通文件 */ + isFile(): boolean + } + interface StepOption { + /** 动画延迟时间,单位 ms */ + delay?: number + /** 动画持续时间,单位 ms */ + duration?: number + /** 动画的效果 + * + * 可选值: + * - 'linear': 动画从头到尾的速度是相同的; + * - 'ease': 动画以低速开始,然后加快,在结束前变慢; + * - 'ease-in': 动画以低速开始; + * - 'ease-in-out': 动画以低速开始和结束; + * - 'ease-out': 动画以低速结束; + * - 'step-start': 动画第一帧就跳至结束状态直到结束; + * - 'step-end': 动画一直保持开始状态,最后一帧跳到结束状态; */ + timingFunction?: + | 'linear' + | 'ease' + | 'ease-in' + | 'ease-in-out' + | 'ease-out' + | 'step-start' + | 'step-end' + transformOrigin?: string + } + /** 贴纸类型 */ + interface Sticker { + /** 贴纸帧数 */ + len: number + /** 贴纸资源路径。资源必须为一个资源文件夹路径或一个压缩包路径,文件夹或压缩包内的贴纸资源必须按照 `{title}_{index}.{ext}` 格式命名。其中 `{title}` 为贴纸名称;`{index}` 为帧序号,从0开始;`{ext}` 为拓展名。 */ + path: string + /** 贴纸名称 */ + title: string + /** 贴纸触发动作 + * + * 可选值: + * - -1: 循环播放; + * - 10: 张嘴; + * - 11: 噘嘴/kiss; + * - 12: 眨/闭左眼; + * - 13: 眨/闭右眼; + * - 14: 眨/闭眼; + * - 15: 挑眉毛; + * - 16: 左右摇头; + * - 17: 上下点头; + * - 100: 比心; + * - 101: 张开手掌; + * - 102: 剪刀手/比耶/胜利; + * - 103: 握拳; + * - 104: 数字1; + * - 105: 我爱你; + * - 106: 点赞; + * - 107: OK; + * - 108: Rock&Roll; + * - 109: 数字6; + * - 110: 数字8; + * - 111: 暂不支持(留空); + * - 112: 双手抱拳/恭喜发财; */ + active?: + | -1 + | 10 + | 11 + | 12 + | 13 + | 14 + | 15 + | 16 + | 17 + | 100 + | 101 + | 102 + | 103 + | 104 + | 105 + | 106 + | 107 + | 108 + | 109 + | 110 + | 111 + | 112 + /** 贴纸ID */ + id?: string + /** 贴纸资源 md5 */ + md5?: string + /** 贴纸位置,格式为 [x1,y1,x2,y2] 。当 `type` 为 `'2D'` 或 `'front'` 时必填。仅 2D 贴纸和前景贴纸有效 */ + pos?: string[] + /** 背景贴纸展示位置。仅背景贴纸有效 + * + * 可选值: + * - 0: 背景贴纸; + * - 1: 只在人像区域显示的贴纸; */ + segtype?: 0 | 1 + } + interface StopAccelerometerOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: CloseCompleteCallback + complete?: StopAccelerometerCompleteCallback /** 接口调用失败的回调函数 */ - fail?: CloseFailCallback - /** 一个可读的字符串,表示连接被关闭的原因。这个字符串必须是不长于 123 字节的 UTF-8 文本(不是字符)。 */ - reason?: string + fail?: StopAccelerometerFailCallback /** 接口调用成功的回调函数 */ - success?: CloseSuccessCallback + success?: StopAccelerometerSuccessCallback } - interface CloseSocketOption { - /** 一个数字值表示关闭连接的状态号,表示连接被关闭的原因。 */ - code?: number + interface StopAdvertisingOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: CloseSocketCompleteCallback + complete?: StopAdvertisingCompleteCallback /** 接口调用失败的回调函数 */ - fail?: CloseSocketFailCallback - /** 一个可读的字符串,表示连接被关闭的原因。这个字符串必须是不长于 123 字节的 UTF-8 文本(不是字符)。 */ - reason?: string + fail?: StopAdvertisingFailCallback /** 接口调用成功的回调函数 */ - success?: CloseSocketSuccessCallback + success?: StopAdvertisingSuccessCallback } - /** 颜色。可以用以下几种方式来表示 canvas 中使用的颜色: - * - * - RGB 颜色: 如 `'rgb(255, 0, 0)'` - * - RGBA 颜色:如 `'rgba(255, 0, 0, 0.3)'` - * - 16 进制颜色: 如 `'#FF0000'` - * - 预定义的颜色: 如 `'red'` - * - * 其中预定义颜色有以下148个: - * *注意**: Color Name 大小写不敏感 - * - * | Color Name | HEX | - * | -------------------- | ------- | - * | AliceBlue | #F0F8FF | - * | AntiqueWhite | #FAEBD7 | - * | Aqua | #00FFFF | - * | Aquamarine | #7FFFD4 | - * | Azure | #F0FFFF | - * | Beige | #F5F5DC | - * | Bisque | #FFE4C4 | - * | Black | #000000 | - * | BlanchedAlmond | #FFEBCD | - * | Blue | #0000FF | - * | BlueViolet | #8A2BE2 | - * | Brown | #A52A2A | - * | BurlyWood | #DEB887 | - * | CadetBlue | #5F9EA0 | - * | Chartreuse | #7FFF00 | - * | Chocolate | #D2691E | - * | Coral | #FF7F50 | - * | CornflowerBlue | #6495ED | - * | Cornsilk | #FFF8DC | - * | Crimson | #DC143C | - * | Cyan | #00FFFF | - * | DarkBlue | #00008B | - * | DarkCyan | #008B8B | - * | DarkGoldenRod | #B8860B | - * | DarkGray | #A9A9A9 | - * | DarkGrey | #A9A9A9 | - * | DarkGreen | #006400 | - * | DarkKhaki | #BDB76B | - * | DarkMagenta | #8B008B | - * | DarkOliveGreen | #556B2F | - * | DarkOrange | #FF8C00 | - * | DarkOrchid | #9932CC | - * | DarkRed | #8B0000 | - * | DarkSalmon | #E9967A | - * | DarkSeaGreen | #8FBC8F | - * | DarkSlateBlue | #483D8B | - * | DarkSlateGray | #2F4F4F | - * | DarkSlateGrey | #2F4F4F | - * | DarkTurquoise | #00CED1 | - * | DarkViolet | #9400D3 | - * | DeepPink | #FF1493 | - * | DeepSkyBlue | #00BFFF | - * | DimGray | #696969 | - * | DimGrey | #696969 | - * | DodgerBlue | #1E90FF | - * | FireBrick | #B22222 | - * | FloralWhite | #FFFAF0 | - * | ForestGreen | #228B22 | - * | Fuchsia | #FF00FF | - * | Gainsboro | #DCDCDC | - * | GhostWhite | #F8F8FF | - * | Gold | #FFD700 | - * | GoldenRod | #DAA520 | - * | Gray | #808080 | - * | Grey | #808080 | - * | Green | #008000 | - * | GreenYellow | #ADFF2F | - * | HoneyDew | #F0FFF0 | - * | HotPink | #FF69B4 | - * | IndianRed | #CD5C5C | - * | Indigo | #4B0082 | - * | Ivory | #FFFFF0 | - * | Khaki | #F0E68C | - * | Lavender | #E6E6FA | - * | LavenderBlush | #FFF0F5 | - * | LawnGreen | #7CFC00 | - * | LemonChiffon | #FFFACD | - * | LightBlue | #ADD8E6 | - * | LightCoral | #F08080 | - * | LightCyan | #E0FFFF | - * | LightGoldenRodYellow | #FAFAD2 | - * | LightGray | #D3D3D3 | - * | LightGrey | #D3D3D3 | - * | LightGreen | #90EE90 | - * | LightPink | #FFB6C1 | - * | LightSalmon | #FFA07A | - * | LightSeaGreen | #20B2AA | - * | LightSkyBlue | #87CEFA | - * | LightSlateGray | #778899 | - * | LightSlateGrey | #778899 | - * | LightSteelBlue | #B0C4DE | - * | LightYellow | #FFFFE0 | - * | Lime | #00FF00 | - * | LimeGreen | #32CD32 | - * | Linen | #FAF0E6 | - * | Magenta | #FF00FF | - * | Maroon | #800000 | - * | MediumAquaMarine | #66CDAA | - * | MediumBlue | #0000CD | - * | MediumOrchid | #BA55D3 | - * | MediumPurple | #9370DB | - * | MediumSeaGreen | #3CB371 | - * | MediumSlateBlue | #7B68EE | - * | MediumSpringGreen | #00FA9A | - * | MediumTurquoise | #48D1CC | - * | MediumVioletRed | #C71585 | - * | MidnightBlue | #191970 | - * | MintCream | #F5FFFA | - * | MistyRose | #FFE4E1 | - * | Moccasin | #FFE4B5 | - * | NavajoWhite | #FFDEAD | - * | Navy | #000080 | - * | OldLace | #FDF5E6 | - * | Olive | #808000 | - * | OliveDrab | #6B8E23 | - * | Orange | #FFA500 | - * | OrangeRed | #FF4500 | - * | Orchid | #DA70D6 | - * | PaleGoldenRod | #EEE8AA | - * | PaleGreen | #98FB98 | - * | PaleTurquoise | #AFEEEE | - * | PaleVioletRed | #DB7093 | - * | PapayaWhip | #FFEFD5 | - * | PeachPuff | #FFDAB9 | - * | Peru | #CD853F | - * | Pink | #FFC0CB | - * | Plum | #DDA0DD | - * | PowderBlue | #B0E0E6 | - * | Purple | #800080 | - * | RebeccaPurple | #663399 | - * | Red | #FF0000 | - * | RosyBrown | #BC8F8F | - * | RoyalBlue | #4169E1 | - * | SaddleBrown | #8B4513 | - * | Salmon | #FA8072 | - * | SandyBrown | #F4A460 | - * | SeaGreen | #2E8B57 | - * | SeaShell | #FFF5EE | - * | Sienna | #A0522D | - * | Silver | #C0C0C0 | - * | SkyBlue | #87CEEB | - * | SlateBlue | #6A5ACD | - * | SlateGray | #708090 | - * | SlateGrey | #708090 | - * | Snow | #FFFAFA | - * | SpringGreen | #00FF7F | - * | SteelBlue | #4682B4 | - * | Tan | #D2B48C | - * | Teal | #008080 | - * | Thistle | #D8BFD8 | - * | Tomato | #FF6347 | - * | Turquoise | #40E0D0 | - * | Violet | #EE82EE | - * | Wheat | #F5DEB3 | - * | White | #FFFFFF | - * | WhiteSmoke | #F5F5F5 | - * | Yellow | #FFFF00 | - * | YellowGreen | #9ACD32 | */ - interface Color {} - interface CompressImageOption { - /** 图片路径,图片的路径,支持本地路径、代码包路径 */ - src: string + interface StopBGMOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopBGMCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StopBGMFailCallback + /** 接口调用成功的回调函数 */ + success?: StopBGMSuccessCallback + } + interface StopBackgroundAudioOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopBackgroundAudioCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StopBackgroundAudioFailCallback + /** 接口调用成功的回调函数 */ + success?: StopBackgroundAudioSuccessCallback + } + interface StopBeaconDiscoveryOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopBeaconDiscoveryCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StopBeaconDiscoveryFailCallback + /** 接口调用成功的回调函数 */ + success?: StopBeaconDiscoverySuccessCallback + } + interface StopBluetoothDevicesDiscoveryOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopBluetoothDevicesDiscoveryCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StopBluetoothDevicesDiscoveryFailCallback + /** 接口调用成功的回调函数 */ + success?: StopBluetoothDevicesDiscoverySuccessCallback + } + interface StopCompassOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopCompassCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StopCompassFailCallback + /** 接口调用成功的回调函数 */ + success?: StopCompassSuccessCallback + } + interface StopDeviceMotionListeningOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: CompressImageCompleteCallback + complete?: StopDeviceMotionListeningCompleteCallback /** 接口调用失败的回调函数 */ - fail?: CompressImageFailCallback - /** 压缩质量,范围0~100,数值越小,质量越低,压缩率越高(仅对jpg有效)。 */ - quality?: number + fail?: StopDeviceMotionListeningFailCallback /** 接口调用成功的回调函数 */ - success?: CompressImageSuccessCallback + success?: StopDeviceMotionListeningSuccessCallback } - interface CompressImageSuccessCallbackResult { - /** 压缩后图片的临时文件路径 (本地路径) */ - tempFilePath: string - errMsg: string + interface StopDiscoveryOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopDiscoveryCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StopDiscoveryFailCallback + /** 接口调用成功的回调函数 */ + success?: StopDiscoverySuccessCallback } - interface ConnectSocketOption { - /** 开发者服务器 wss 接口地址 */ - url: string + interface StopFaceDetectOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ConnectSocketCompleteCallback + complete?: StopFaceDetectCompleteCallback /** 接口调用失败的回调函数 */ - fail?: ConnectSocketFailCallback - /** HTTP Header,Header 中不能设置 Referer */ - header?: IAnyObject - /** 是否开启压缩扩展 - * - * 最低基础库: `2.8.0` */ - perMessageDeflate?: boolean - /** 子协议数组 - * - * 最低基础库: `1.4.0` */ - protocols?: string[] + fail?: StopFaceDetectFailCallback /** 接口调用成功的回调函数 */ - success?: ConnectSocketSuccessCallback - /** 建立 TCP 连接的时候的 TCP_NODELAY 设置 - * - * 最低基础库: `2.4.0` */ - tcpNoDelay?: boolean - /** 超时时间,单位为毫秒 - * - * 最低基础库: `2.10.0` */ - timeout?: number + success?: StopFaceDetectSuccessCallback } - interface ConnectWifiOption { - /** Wi-Fi 设备 SSID */ - SSID: string - /** Wi-Fi 设备密码 */ - password: string - /** Wi-Fi 设备 BSSID */ - BSSID?: string + interface StopGyroscopeOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ConnectWifiCompleteCallback + complete?: StopGyroscopeCompleteCallback /** 接口调用失败的回调函数 */ - fail?: ConnectWifiFailCallback + fail?: StopGyroscopeFailCallback /** 接口调用成功的回调函数 */ - success?: ConnectWifiSuccessCallback + success?: StopGyroscopeSuccessCallback } - interface ContextCallbackResult { - /** 节点对应的 Context 对象 */ - context: IAnyObject + interface StopHCEOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopHCECompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StopHCEFailCallback + /** 接口调用成功的回调函数 */ + success?: StopHCESuccessCallback } - interface CopyFileFailCallbackResult { + interface StopLocalServiceDiscoveryFailCallbackResult { /** 错误信息 * * 可选值: - * - 'fail permission denied, copyFile ${srcPath} -> ${destPath}': 指定目标文件路径没有写权限; - * - 'fail no such file or directory, copyFile ${srcPath} -> ${destPath}': 源文件不存在,或目标文件路径的上层目录不存在; - * - 'fail the maximum size of the file storage limit is exceeded': 存储空间不足; */ + * - 'task not found': 在当前没有处在搜索服务中的情况下调用 stopLocalServiceDiscovery; */ errMsg: string } - interface CopyFileOption { - /** 目标文件路径,支持本地路径 */ - destPath: string - /** 源文件路径,支持本地路径 */ - srcPath: string + interface StopLocalServiceDiscoveryOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: CopyFileCompleteCallback + complete?: StopLocalServiceDiscoveryCompleteCallback /** 接口调用失败的回调函数 */ - fail?: CopyFileFailCallback + fail?: StopLocalServiceDiscoveryFailCallback /** 接口调用成功的回调函数 */ - success?: CopyFileSuccessCallback + success?: StopLocalServiceDiscoverySuccessCallback } - interface CreateAnimationOption { - /** 动画延迟时间,单位 ms */ - delay?: number - /** 动画持续时间,单位 ms */ - duration?: number - /** 动画的效果 + interface StopLocationUpdateOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopLocationUpdateCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StopLocationUpdateFailCallback + /** 接口调用成功的回调函数 */ + success?: StopLocationUpdateSuccessCallback + } + interface StopOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StopFailCallback + /** 接口调用成功的回调函数 */ + success?: StopSuccessCallback + } + interface StopPreviewOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopPreviewCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StopPreviewFailCallback + /** 接口调用成功的回调函数 */ + success?: StopPreviewSuccessCallback + } + interface StopPullDownRefreshOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopPullDownRefreshCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StopPullDownRefreshFailCallback + /** 接口调用成功的回调函数 */ + success?: StopPullDownRefreshSuccessCallback + } + interface StopRecordSuccessCallbackResult { + /** 封面图片文件的临时路径 (本地路径) */ + tempThumbPath: string + /** 视频的文件的临时路径 (本地路径) */ + tempVideoPath: string + errMsg: string + } + interface StopVoiceOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopVoiceCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StopVoiceFailCallback + /** 接口调用成功的回调函数 */ + success?: StopVoiceSuccessCallback + } + interface StopWifiOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopWifiCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: StopWifiFailCallback + /** 接口调用成功的回调函数 */ + success?: StopWifiSuccessCallback + } + interface SubscribeVoIPVideoMembersOption { + /** 订阅的成员列表 */ + openIdList: string[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SubscribeVoIPVideoMembersCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SubscribeVoIPVideoMembersFailCallback + /** 接口调用成功的回调函数 */ + success?: SubscribeVoIPVideoMembersSuccessCallback + } + /** 订阅消息设置 +* +* **示例代码** +* +* ```javascript +wx.getSetting({ + withSubscriptions: true, + success (res) { + console.log(res.authSetting) + // res.authSetting = { + // "scope.userInfo": true, + // "scope.userLocation": true + // } + console.log(res.subscriptionsSetting) + // res.subscriptionsSetting = { + // mainSwitch: true, // 订阅消息总开关 + // itemSettings: { // 每一项开关 + // SYS_MSG_TYPE_INTERACTIVE: 'accept', // 小游戏系统订阅消息 + // SYS_MSG_TYPE_RANK: 'accept' + // zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE: 'reject', // 普通一次性订阅消息 + // ke_OZC_66gZxALLcsuI7ilCJSP2OJ2vWo2ooUPpkWrw: 'ban', + // } + // } + } +}) +``` */ + interface SubscriptionsSetting { + /** 订阅消息总开关,true为开启,false为关闭 */ + mainSwitch: boolean + /** 每一项订阅消息的订阅状态。itemSettings对象的键为**一次性订阅消息的模板id**或**系统订阅消息的类型**,值为'accept'、'reject'、'ban'中的其中一种。'accept'表示用户同意订阅这条消息,'reject'表示用户拒绝订阅这条消息,'ban'表示已被后台封禁。一次性订阅消息使用方法详见 [wx.requestSubscribeMessage](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/subscribe-message/wx.requestSubscribeMessage.html),永久订阅消息(仅小游戏可用)使用方法详见[wx.requestSubscribeSystemMessage](https://developers.weixin.qq.com/minigame/dev/api/open-api/subscribe-message/wx.requestSubscribeSystemMessage.html) + * ## 注意事项 + * - itemSettings 只返回用户勾选过订阅面板中的“总是保持以上选择,不再询问”的订阅消息。 */ + itemSettings?: IAnyObject + } + interface SwitchCameraOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SwitchCameraCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SwitchCameraFailCallback + /** 接口调用成功的回调函数 */ + success?: SwitchCameraSuccessCallback + } + interface SwitchCastingOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SwitchCastingCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SwitchCastingFailCallback + /** 接口调用成功的回调函数 */ + success?: SwitchCastingSuccessCallback + } + interface SwitchTabOption { + /** 需要跳转的 tabBar 页面的路径 (代码包路径)(需在 app.json 的 [tabBar](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#tabbar) 字段定义的页面),路径后不能带参数。 */ + url: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SwitchTabCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: SwitchTabFailCallback + /** 接口调用成功的回调函数 */ + success?: SwitchTabSuccessCallback + } + interface SystemInfo { + /** 需要基础库: `1.1.0` + * + * 客户端基础库版本 */ + SDKVersion: string + /** 需要基础库: `2.6.0` + * + * 允许微信使用相册的开关(仅 iOS 有效) */ + albumAuthorized: boolean + /** 需要基础库: `1.8.0` + * + * 设备性能等级(仅 Android)。取值为:-2 或 0(该设备无法运行小游戏),-1(性能未知),>=1(设备性能值,该值越高,设备性能越好)
注意:性能等级当前仅反馈真机机型,暂不支持 IDE 模拟器机型 */ + benchmarkLevel: number + /** 需要基础库: `2.6.0` + * + * 蓝牙的系统开关 */ + bluetoothEnabled: boolean + /** 需要基础库: `1.5.0` + * + * 设备品牌 */ + brand: string + /** 需要基础库: `2.6.0` + * + * 允许微信使用摄像头的开关 */ + cameraAuthorized: boolean + /** 设备方向(注意:IOS客户端横屏游戏获取deviceOrientation可能不准,建议以屏幕宽高为准) + * + * 可选值: + * - 'portrait': 竖屏; + * - 'landscape': 横屏; */ + deviceOrientation: 'portrait' | 'landscape' + /** 需要基础库: `2.15.0` + * + * 是否已打开调试。可通过右上角菜单或 [wx.setEnableDebug](https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/wx.setEnableDebug.html) 打开调试。 */ + enableDebug: boolean + /** 需要基础库: `1.5.0` + * + * 用户字体大小(单位px)。以微信客户端「我-设置-通用-字体大小」中的设置为准 */ + fontSizeSetting: number + /** 需要基础库: `2.12.3` + * + * 当前小程序运行的宿主环境 */ + host: SystemInfoHost + /** 微信设置的语言 */ + language: string + /** 需要基础库: `2.6.0` + * + * 允许微信使用定位的开关 */ + locationAuthorized: boolean + /** 需要基础库: `2.6.0` + * + * 地理位置的系统开关 */ + locationEnabled: boolean + /** `true` 表示模糊定位,`false` 表示精确定位,仅 iOS 支持 */ + locationReducedAccuracy: boolean + /** 需要基础库: `2.6.0` + * + * 允许微信使用麦克风的开关 */ + microphoneAuthorized: boolean + /** 设备型号。新机型刚推出一段时间会显示unknown,微信会尽快进行适配。 */ + model: string + /** 需要基础库: `2.6.0` + * + * 允许微信通知带有提醒的开关(仅 iOS 有效) */ + notificationAlertAuthorized: boolean + /** 需要基础库: `2.6.0` + * + * 允许微信通知的开关 */ + notificationAuthorized: boolean + /** 需要基础库: `2.6.0` + * + * 允许微信通知带有标记的开关(仅 iOS 有效) */ + notificationBadgeAuthorized: boolean + /** 需要基础库: `2.6.0` + * + * 允许微信通知带有声音的开关(仅 iOS 有效) */ + notificationSoundAuthorized: boolean + /** 需要基础库: `2.19.3` + * + * 允许微信使用日历的开关 */ + phoneCalendarAuthorized: boolean + /** 设备像素比 */ + pixelRatio: number + /** 客户端平台 + * + * 可选值: + * - 'ios': iOS微信(包含 iPhone、iPad); + * - 'android': Android微信; + * - 'ohos': HarmonyOS微信; + * - 'windows': Windows微信; + * - 'mac': macOS微信; + * - 'devtools': 微信开发者工具; */ + platform: 'ios' | 'android' | 'ohos' | 'windows' | 'mac' | 'devtools' + /** 需要基础库: `2.7.0` + * + * 在竖屏正方向下的安全区域。部分机型没有安全区域概念,也不会返回 safeArea 字段,开发者需自行兼容。 */ + safeArea: SafeArea + /** 需要基础库: `1.1.0` + * + * 屏幕高度,单位px */ + screenHeight: number + /** 需要基础库: `1.1.0` + * + * 屏幕宽度,单位px */ + screenWidth: number + /** 需要基础库: `1.9.0` + * + * 状态栏的高度,单位px */ + statusBarHeight: number + /** 操作系统及版本 */ + system: string + /** 微信版本号 */ + version: string + /** 需要基础库: `2.6.0` + * + * Wi-Fi 的系统开关 */ + wifiEnabled: boolean + /** 可使用窗口高度,单位px */ + windowHeight: number + /** 可使用窗口宽度,单位px */ + windowWidth: number + /** 需要基础库: `2.11.0` + * + * 系统当前主题,取值为`light`或`dark`,全局配置`"darkmode":true`时才能获取,否则为 undefined (不支持小游戏) + * + * 可选值: + * - 'dark': 深色主题; + * - 'light': 浅色主题; */ + theme?: 'dark' | 'light' + } + /** 需要基础库: `2.12.3` + * + * 当前小程序运行的宿主环境 */ + interface SystemInfoHost { + /** 宿主 app 对应的 appId */ + appId: string + } + interface SystemSetting { + /** 蓝牙的系统开关 */ + bluetoothEnabled: boolean + /** 设备方向(注意:IOS客户端横屏游戏获取deviceOrientation可能不准,建议以屏幕宽高为准) + * + * 可选值: + * - 'portrait': 竖屏; + * - 'landscape': 横屏; */ + deviceOrientation: 'portrait' | 'landscape' + /** 地理位置的系统开关 */ + locationEnabled: boolean + /** Wi-Fi 的系统开关 */ + wifiEnabled: boolean + } + /** 需要基础库: `3.4.0` + * + * 异常信息 */ + interface TCPExceptionReason { + /** 错误原因 */ + errMsg: string + /** 错误码 */ + errno: string + } + interface TCPSocketConnectOption { + /** 套接字要连接的地址 */ + address: string + /** 套接字要连接的端口 */ + port: number + /** 需要基础库: `3.4.0` + * + * 是否开启 HttpDNS 服务。如开启,需要同时填入 httpDNSServiceId 。 HttpDNS 用法详见 [移动解析HttpDNS](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/HTTPDNS.html) */ + enableHttpDNS?: boolean + /** 需要基础库: `3.4.0` + * + * HttpDNS 服务商 Id。 HttpDNS 用法详见 [移动解析HttpDNS](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/HTTPDNS.html) */ + httpDNSServiceId?: string + /** 套接字要连接的超时时间,默认为 2s */ + timeout?: number + } + interface TCPSocketOnMessageListenerResult { + /** 接收端地址信息 */ + localInfo: OnMessageListenerResultLocalInfo + /** 收到的消息 */ + message: ArrayBuffer + /** 发送端地址信息 */ + remoteInfo: TCPSocketOnMessageListenerResultRemoteInfo + } + /** 发送端地址信息 */ + interface TCPSocketOnMessageListenerResultRemoteInfo { + /** 发送消息的 socket 的地址 */ + address: string + /** 使用的协议族,为 IPv4 或者 IPv6 */ + family: string + /** 端口号 */ + port: number + } + interface TakePhotoOption { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: TakePhotoCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: TakePhotoFailCallback + /** 成像质量 * * 可选值: - * - 'linear': 动画从头到尾的速度是相同的; - * - 'ease': 动画以低速开始,然后加快,在结束前变慢; - * - 'ease-in': 动画以低速开始; - * - 'ease-in-out': 动画以低速开始和结束; - * - 'ease-out': 动画以低速结束; - * - 'step-start': 动画第一帧就跳至结束状态直到结束; - * - 'step-end': 动画一直保持开始状态,最后一帧跳到结束状态; */ - timingFunction?: - | 'linear' - | 'ease' - | 'ease-in' - | 'ease-in-out' - | 'ease-out' - | 'step-start' - | 'step-end' - transformOrigin?: string + * - 'high': 高质量; + * - 'normal': 普通质量; + * - 'low': 低质量; + * - 'original': 原图; */ + quality?: 'high' | 'normal' | 'low' | 'original' + /** 需要基础库: `2.22.0` + * + * 是否开启镜像 */ + selfieMirror?: boolean + /** 接口调用成功的回调函数 */ + success?: TakePhotoSuccessCallback } - interface CreateBLEConnectionOption { - /** 用于区分设备的 id */ - deviceId: string + interface TakePhotoSuccessCallbackResult { + /** 照片文件的临时路径 (本地路径),安卓是jpg图片格式,ios是png */ + tempImagePath: string + errMsg: string + } + interface TakeSnapshotOption { + /** 截图文件格式,'rgba' 或 'png',默认值为 'png' */ + format: string + /** 截图导出类型,'file' 保存到临时文件目录或 'arraybuffer' 返回图片二进制数据,默认值为 'file' */ + type: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: CreateBLEConnectionCompleteCallback + complete?: TakeSnapshotCompleteCallback /** 接口调用失败的回调函数 */ - fail?: CreateBLEConnectionFailCallback + fail?: TakeSnapshotFailCallback /** 接口调用成功的回调函数 */ - success?: CreateBLEConnectionSuccessCallback - /** 超时时间,单位ms,不填表示不会超时 */ - timeout?: number + success?: TakeSnapshotSuccessCallback } - /** 选项 */ - interface CreateIntersectionObserverOption { - /** 初始的相交比例,如果调用时检测到的相交比例与这个值不相等且达到阈值,则会触发一次监听器的回调函数。 */ - initialRatio?: number - /** 是否同时观测多个目标节点(而非一个),如果设为 true ,observe 的 targetSelector 将选中多个节点(注意:同时选中过多节点将影响渲染性能) - * - * 最低基础库: `2.0.0` */ - observeAll?: boolean - /** 一个数值数组,包含所有阈值。 */ - thresholds?: number[] + interface TakeSnapshotSuccessCallbackResult { + /** 截图对应的二进制数据,当 type 为 arraybuffer 该字段生效 */ + data: ArrayBuffer + /** 截图保存的临时文件路径,当 type 为 file 该字段生效 */ + tempFilePath: string + errMsg: string } - interface CreateInterstitialAdOption { - /** 广告单元 id */ - adUnitId: string + /** 标签类型枚举 */ + interface TechType { + /** 对应IsoDep实例,实例支持ISO-DEP (ISO 14443-4)标准的读写 */ + isoDep: string + /** 对应MifareClassic实例,实例支持MIFARE Classic标签的读写 */ + mifareClassic: string + /** 对应MifareUltralight实例,实例支持MIFARE Ultralight标签的读写 */ + mifareUltralight: string + /** 对应Ndef实例,实例支持对NDEF格式的NFC标签上的NDEF数据的读写 */ + ndef: string + /** 对应NfcA实例,实例支持NFC-A (ISO 14443-3A)标准的读写 */ + nfcA: string + /** 对应NfcB实例,实例支持NFC-B (ISO 14443-3B)标准的读写 */ + nfcB: string + /** 对应NfcF实例,实例支持NFC-F (JIS 6319-4)标准的读写 */ + nfcF: string + /** 对应NfcV实例,实例支持NFC-V (ISO 15693)标准的读写 */ + nfcV: string + } + /** 需要基础库: `2.30.0` +* +* 在插件中使用:需要基础库 `2.30.0` +* +* Tensor +* +* **** +* +* ```js +session.run({ + input1: { + type: 'float32', + data: new Float32Array(3 * 224 * 224).buffer, + shape: [1, 3, 224, 224] // NCHW 顺序 + }, + input2: { + type: 'uint8', + data: new Uint8Array(224 * 224).buffer, + shape: [1, 1, 224, 224] + }, +}).then(res => { + console.log(res.output0) + // output0 结构如下: + // { + // type: 'uint8', + // data: new Uint8Array(224 * 224).buffer, + // shape: [1, 1, 224, 224] + // } +}) +``` */ + interface Tensor { + /** Tensor 值,一段 ArrayBuffer */ + data: ArrayBuffer + /** Tensor shape (Tensor 形状,例如 `[1, 3, 224, 224]` 即表示一个4唯Tensor,每个维度的长度分别为1, 3, 224, 224) */ + shape: number[] + /** ArrayBuffer 值的类型,合法值有 `uint8`, `int8`, `uint32`, `int32`, `float32` */ + type: string } - interface CreateRewardedVideoAdOption { - /** 广告单元 id */ - adUnitId: string - /** 是否启用多例模式,默认为false + /** 需要基础库: `2.30.0` +* +* 在插件中使用:需要基础库 `2.30.0` +* +* Tensors 是 key-value 形式的对象,对象的 key 会作为 input/output name,对象的 value 则是 Tensor。 Tensor 结构如下。 +* +* **** +* +* ```js +session.run({ + input1: { + type: 'float32', + data: new Float32Array(3 * 224 * 224).buffer, + shape: [1, 3, 224, 224] // NCHW 顺序 + }, + input2: { + type: 'uint8', + data: new Uint8Array(224 * 224).buffer, + shape: [1, 1, 224, 224] + }, +}).then(res => { + console.log(res.output0) + // output0 结构如下: + // { + // type: 'uint8', + // data: new Uint8Array(224 * 224).buffer, + // shape: [1, 1, 224, 224] + // } +}) +``` */ + interface Tensors { + /** [Tensor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/Tensor.html) * - * 最低基础库: `2.8.0` */ - multiton?: boolean - } - /** 弹幕内容 */ - interface Danmu { - /** 弹幕文字 */ - text: string - /** 弹幕颜色 */ - color?: string - } - /** 可选的字体描述符 */ - interface DescOption { - /** 字体样式,可选值为 normal / italic / oblique */ - style?: string - /** 设置小型大写字母的字体显示文本,可选值为 normal / small-caps / inherit */ - variant?: string - /** 字体粗细,可选值为 normal / bold / 100 / 200../ 900 */ - weight?: string + * Tensor,每个 Tensor 包含 shape、data、type 字段。 */ + [key: string]: Tensor } - /** 描述符数据 */ - interface Descriptor { - /** Descriptor 的 uuid */ - uuid: string - /** 描述符的权限 */ - permission?: DescriptorPermission - /** 描述符数据 */ - value?: ArrayBuffer + interface TextMetrics { + /** 文本的宽度 */ + width: number } - /** 描述符的权限 */ - interface DescriptorPermission { - /** 读 */ - read?: boolean - /** 写 */ - write?: boolean + /** 动画配置 */ + interface TimingOption { + /** 动画时长 */ + duration?: number + /** 动画曲线,参考 [Easing](https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html) 模块。 */ + easing?: (...args: any[]) => any } - /** 指定 marker 移动到的目标点 */ - interface DestinationOption { + interface ToScreenLocationOption { /** 纬度 */ latitude: number /** 经度 */ longitude: number - } - interface DownloadFileOption { - /** 下载资源的 url */ - url: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: DownloadFileCompleteCallback + complete?: ToScreenLocationCompleteCallback /** 接口调用失败的回调函数 */ - fail?: DownloadFileFailCallback - /** 指定文件下载后存储的路径 (本地路径) - * - * 最低基础库: `1.8.0` */ - filePath?: string - /** HTTP 请求的 Header,Header 中不能设置 Referer */ - header?: IAnyObject + fail?: ToScreenLocationFailCallback /** 接口调用成功的回调函数 */ - success?: DownloadFileSuccessCallback - /** 超时时间,单位为毫秒 - * - * 最低基础库: `2.10.0` */ - timeout?: number + success?: ToScreenLocationSuccessCallback } - interface DownloadFileSuccessCallbackResult { - /** 用户文件路径 (本地路径)。传入 filePath 时会返回,跟传入的 filePath 一致 */ - filePath: string - /** 开发者服务器返回的 HTTP 状态码 */ - statusCode: number - /** 临时文件路径 (本地路径)。没传入 filePath 指定文件存储路径时会返回,下载后的文件会存储到一个临时文件 */ - tempFilePath: string + interface ToScreenLocationSuccessCallbackResult { + /** x 坐标值 */ + x: number + /** y 坐标值 */ + y: number errMsg: string } - interface DownloadTaskOnHeadersReceivedCallbackResult { - /** 开发者服务器返回的 HTTP Response Header */ - header: IAnyObject - } - interface DownloadTaskOnProgressUpdateCallbackResult { - /** 下载进度百分比 */ - progress: number - /** 预期需要下载的数据总长度,单位 Bytes */ - totalBytesExpectedToWrite: number - /** 已经下载的数据长度,单位 Bytes */ - totalBytesWritten: number - } - interface ExitFullScreenOption { + interface ToggleTorchOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ExitFullScreenCompleteCallback + complete?: ToggleTorchCompleteCallback /** 接口调用失败的回调函数 */ - fail?: ExitFullScreenFailCallback + fail?: ToggleTorchFailCallback /** 接口调用成功的回调函数 */ - success?: ExitFullScreenSuccessCallback - } - interface ExtractDataSourceOption { - /** 视频源地址,只支持本地文件 */ - source: string + success?: ToggleTorchSuccessCallback } - interface Fields { - /** 指定样式名列表,返回节点对应样式名的当前值 + /** 跟踪能力配置,目前不同的跟踪能力之间是互斥的,默认使用平面跟踪能力。需要注意目前 track 中不同的跟踪配置存在互斥关系(比如 marker 跟踪配置和 OSD 跟踪配置不能同时存在),请按需配置。 */ + interface Track { + /** 平面跟踪配置 */ + plane: PlaneTrack + /** 需要基础库: `3.3.0` * - * 最低基础库: `2.1.0` */ - computedStyle?: string[] - /** 是否返回节点对应的 Context 对象 + * 身份证检测配置。用法详情[指南文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/idcard.html)。 */ + IDCard?: IDCardTrack + /** 需要基础库: `2.27.0` * - * 最低基础库: `2.4.2` */ - context?: boolean - /** 是否返回节点 dataset */ - dataset?: boolean - /** 是否返回节点 id */ - id?: boolean - /** 是否返回节点 mark */ - mark?: boolean - /** 是否返回节点对应的 Node 实例 + * OCR检测配置。用法详情[指南文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/ocr.html)。 */ + OCR?: OCRTrack + /** 需要基础库: `2.24.5` * - * 最低基础库: `2.7.0` */ - node?: boolean - /** 指定属性名列表,返回节点对应属性名的当前属性值(只能获得组件文档中标注的常规属性值,id class style 和事件绑定的属性值不可获取) */ - properties?: string[] - /** 是否返回节点布局位置(`left` `right` `top` `bottom`) */ - rect?: boolean - /** 否 是否返回节点的 `scrollLeft` `scrollTop`,节点必须是 `scroll-view` 或者 `viewport` */ - scrollOffset?: boolean - /** 是否返回节点尺寸(`width` `height`) */ - size?: boolean + * OSD 跟踪配置 */ + OSD?: boolean + /** 需要基础库: `2.28.0` + * + * 人体检测配置。用法详情[指南文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/body.html)。 */ + body?: BodyTrack + /** 需要基础库: `3.0.0` + * + * 深度识别配置。用法详情[指南文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/depth.html)。 */ + depth?: DepthTrack + /** 需要基础库: `2.25.0` + * + * 人脸检测配置。用法详情[指南文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/face.html)。安卓微信8.0.25开始支持,iOS微信8.0.24开始支持。 */ + face?: FaceTrack + /** 需要基础库: `2.28.0` + * + * 手势检测配置。用法详情[指南文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/hand.html)。 */ + hand?: HandTrack + /** 需要基础库: `2.24.5` + * + * marker 跟踪配置,基础库(3.0.0)开始允许同时支持v2的水平面检测能力 */ + marker?: boolean + /** 需要基础库: `3.2.1` + * + * 鞋部检测配置。用法详情[指南文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/shoe.html)。 */ + shoe?: ShoeTrack + /** 需要基础库: `2.28.0` + * + * 提供基础AR功能,输出相机旋转的3个自由度的位姿,利用手机陀螺仪传感器,实现快速稳定的AR定位能力,适用于简单AR场景。 */ + threeDof?: boolean } - interface FileSystemManagerGetFileInfoOption { - /** 要读取的文件路径 (本地路径) */ - filePath: string + interface TransceiveOption { + /** 需要传递的二进制数据 */ + data: ArrayBuffer /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: FileSystemManagerGetFileInfoCompleteCallback + complete?: TransceiveCompleteCallback /** 接口调用失败的回调函数 */ - fail?: FileSystemManagerGetFileInfoFailCallback + fail?: TransceiveFailCallback /** 接口调用成功的回调函数 */ - success?: FileSystemManagerGetFileInfoSuccessCallback + success?: TransceiveSuccessCallback } - interface FileSystemManagerGetFileInfoSuccessCallbackResult { - /** 文件大小,以字节为单位 */ - size: number + interface TransceiveSuccessCallbackResult { + data: ArrayBuffer errMsg: string } - interface FileSystemManagerGetSavedFileListOption { + interface TranslateMarkerOption { + /** 移动过程中是否自动旋转 marker */ + autoRotate: boolean + /** 指定 marker 移动到的目标点 */ + destination: DestinationOption + /** 指定 marker */ + markerId: number + /** marker 的旋转角度 */ + rotate: number + /** 动画结束回调函数 */ + animationEnd?: (...args: any[]) => any /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: FileSystemManagerGetSavedFileListCompleteCallback + complete?: TranslateMarkerCompleteCallback + /** 动画持续时长,平移与旋转分别计算 */ + duration?: number /** 接口调用失败的回调函数 */ - fail?: FileSystemManagerGetSavedFileListFailCallback + fail?: TranslateMarkerFailCallback + /** 需要基础库: `2.13.0` + * + * 平移和旋转同时进行 */ + moveWithRotate?: boolean /** 接口调用成功的回调函数 */ - success?: FileSystemManagerGetSavedFileListSuccessCallback + success?: TranslateMarkerSuccessCallback } - interface FileSystemManagerGetSavedFileListSuccessCallbackResult { - /** 文件数组 */ - fileList: FileSystemManagerGetSavedFileListSuccessCallbackResultFileItem[] - errMsg: string + interface TriggerRefreshOption { + /** 动画时长 */ + duration?: number + /** [动画曲线](#) */ + easingFunction?: string } - /** 文件数组 */ - interface FileSystemManagerGetSavedFileListSuccessCallbackResultFileItem { - /** 文件保存时的时间戳,从1970/01/01 08:00:00 到当前时间的秒数 */ - createTime: number - /** 文件路径 (本地路径) */ + interface TruncateOption { + /** 要截断的文件路径 (本地路径) */ filePath: string - /** 本地文件大小,以字节为单位 */ - size: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: TruncateCompleteCallback + /** 接口调用失败的回调函数 */ + fail?: TruncateFailCallback + /** 截断位置,默认0。如果 length 小于文件长度(字节),则只有前面 length 个字节会保留在文件中,其余内容会被删除;如果 length 大于文件长度,则会对其进行扩展,并且扩展部分将填充空字节('\0') */ + length?: number + /** 接口调用成功的回调函数 */ + success?: TruncateSuccessCallback } - interface FileSystemManagerRemoveSavedFileOption { - /** 需要删除的文件路径 (本地路径) */ + interface TruncateSyncOption { + /** 要截断的文件路径 (本地路径) */ filePath: string + /** 截断位置,默认0。如果 length 小于文件长度(字节),则只有前面 length 个字节会保留在文件中,其余内容会被删除;如果 length 大于文件长度,则会对其进行扩展,并且扩展部分将填充空字节('\0') */ + length?: number + } + interface UDPSocketConnectOption { + /** 要发消息的地址 */ + address: string + /** 要发送消息的端口号 */ + port: number + } + interface UDPSocketOnMessageListenerResult { + /** 接收端地址信息,2.18.0 起支持 */ + localInfo: OnMessageListenerResultLocalInfo + /** 收到的消息。消息长度需要小于4096。 */ + message: ArrayBuffer + /** 发送端地址信息 */ + remoteInfo: UDPSocketOnMessageListenerResultRemoteInfo + } + /** 发送端地址信息 */ + interface UDPSocketOnMessageListenerResultRemoteInfo { + /** 发送消息的 socket 的地址 */ + address: string + /** 使用的协议族,为 IPv4 或者 IPv6 */ + family: string + /** 端口号 */ + port: number + /** message 的大小,单位:字节 */ + size: number + } + interface UDPSocketSendOption { + /** 要发消息的地址。在基础库 <= 2.9.3 版本必须是和本机同网段的 IP 地址,或安全域名列表内的域名地址;之后版本可以是任意 IP 和域名 */ + address: string + /** 要发送的数据 */ + message: string | ArrayBuffer + /** 要发送消息的端口号 */ + port: number + /** 发送数据的长度,仅当 message 为 ArrayBuffer 类型时有效 */ + length?: number + /** 发送数据的偏移量,仅当 message 为 ArrayBuffer 类型时有效 */ + offset?: number + /** 向指定地址发消息时,是否要开启广播,基础库 2.24.0 开始支持 */ + setBroadcast?: boolean + } + interface UndoOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: FileSystemManagerRemoveSavedFileCompleteCallback + complete?: UndoCompleteCallback /** 接口调用失败的回调函数 */ - fail?: FileSystemManagerRemoveSavedFileFailCallback + fail?: UndoFailCallback /** 接口调用成功的回调函数 */ - success?: FileSystemManagerRemoveSavedFileSuccessCallback + success?: UndoSuccessCallback } - interface FileSystemManagerSaveFileOption { - /** 临时存储文件路径 (本地路径) */ - tempFilePath: string + interface UnlinkOption { + /** 要删除的文件路径 (本地路径) */ + filePath: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: FileSystemManagerSaveFileCompleteCallback + complete?: UnlinkCompleteCallback /** 接口调用失败的回调函数 */ - fail?: FileSystemManagerSaveFileFailCallback - /** 要存储的文件路径 (本地路径) */ - filePath?: string + fail?: UnlinkFailCallback /** 接口调用成功的回调函数 */ - success?: FileSystemManagerSaveFileSuccessCallback - } - interface FileSystemManagerSaveFileSuccessCallbackResult { - /** 存储后的文件路径 (本地路径) */ - savedFilePath: number - errMsg: string + success?: UnlinkSuccessCallback } - interface GetAvailableAudioSourcesOption { + interface UnzipOption { + /** 目标目录路径, 支持本地路径 */ + targetPath: string + /** 源文件路径,支持本地路径, 只可以是 zip 压缩文件 */ + zipFilePath: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetAvailableAudioSourcesCompleteCallback + complete?: UnzipCompleteCallback /** 接口调用失败的回调函数 */ - fail?: GetAvailableAudioSourcesFailCallback + fail?: UnzipFailCallback /** 接口调用成功的回调函数 */ - success?: GetAvailableAudioSourcesSuccessCallback + success?: UnzipSuccessCallback } - interface GetAvailableAudioSourcesSuccessCallbackResult { - /** 支持的音频输入源列表,可在 [RecorderManager.start()](https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/RecorderManager.start.html) 接口中使用。返回值定义参考 https://developer.android.com/reference/kotlin/android/media/MediaRecorder.AudioSource - * - * 可选值: - * - 'auto': 自动设置,默认使用手机麦克风,插上耳麦后自动切换使用耳机麦克风,所有平台适用; - * - 'buildInMic': 手机麦克风,仅限 iOS; - * - 'headsetMic': 耳机麦克风,仅限 iOS; - * - 'mic': 麦克风(没插耳麦时是手机麦克风,插耳麦时是耳机麦克风),仅限 Android; - * - 'camcorder': 同 mic,适用于录制音视频内容,仅限 Android; - * - 'voice_communication': 同 mic,适用于实时沟通,仅限 Android; - * - 'voice_recognition': 同 mic,适用于语音识别,仅限 Android; */ - audioSources: Array< - | 'auto' - | 'buildInMic' - | 'headsetMic' - | 'mic' - | 'camcorder' - | 'voice_communication' - | 'voice_recognition'> - errMsg: string + /** 参数列表 */ + interface UpdatableMessageFrontEndParameter { + /** 参数名 */ + name: string + /** 参数值 */ + value: string } - interface GetBLEDeviceCharacteristicsOption { - /** 蓝牙设备 id */ - deviceId: string - /** 蓝牙服务 uuid,需要使用 `getBLEDeviceServices` 获取 */ - serviceId: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetBLEDeviceCharacteristicsCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: GetBLEDeviceCharacteristicsFailCallback - /** 接口调用成功的回调函数 */ - success?: GetBLEDeviceCharacteristicsSuccessCallback + /** 需要基础库: `2.4.0` + * + * 动态消息的模板信息 */ + interface UpdatableMessageFrontEndTemplateInfo { + /** 参数列表 */ + parameterList: UpdatableMessageFrontEndParameter[] + /** 模板ID */ + templateId: string } - interface GetBLEDeviceCharacteristicsSuccessCallbackResult { - /** 设备特征值列表 */ - characteristics: BLECharacteristic[] - errMsg: string + interface Update3DModeOption { + /** 是否开启三维识别 */ + open3d: boolean } - interface GetBLEDeviceServicesOption { - /** 蓝牙设备 id */ - deviceId: string + interface UpdateGroundOverlayOption { + /** 图片覆盖的经纬度范围 */ + bounds: MapBounds + /** 图片图层 id */ + id: string + /** 图片路径,支持网络图片、临时路径、代码包路径 */ + src: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetBLEDeviceServicesCompleteCallback + complete?: UpdateGroundOverlayCompleteCallback /** 接口调用失败的回调函数 */ - fail?: GetBLEDeviceServicesFailCallback + fail?: UpdateGroundOverlayFailCallback + /** 图层透明度 */ + opacity?: number /** 接口调用成功的回调函数 */ - success?: GetBLEDeviceServicesSuccessCallback + success?: UpdateGroundOverlaySuccessCallback + /** 是否可见 */ + visible?: boolean + /** 图层绘制顺序 */ + zIndex?: number } - interface GetBLEDeviceServicesSuccessCallbackResult { - /** 设备服务列表 */ - services: BLEService[] - errMsg: string + interface UpdateMaskModeOption { + /** 设置是否开启试鞋,返回腿部遮挡纹理 */ + useMask: boolean } - interface GetBackgroundAudioPlayerStateOption { + interface UpdateShareMenuOption { + /** 需要基础库: `2.4.0` + * + * 动态消息的 activityId。通过 [updatableMessage.createActivityId](#) 接口获取 */ + activityId?: string + /** 需要基础库: `3.7.8` + * + * 指定成员的方式 */ + chooseType?: number /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetBackgroundAudioPlayerStateCompleteCallback + complete?: UpdateShareMenuCompleteCallback /** 接口调用失败的回调函数 */ - fail?: GetBackgroundAudioPlayerStateFailCallback + fail?: UpdateShareMenuFailCallback + /** 需要基础库: `2.13.0` + * + * 是否是私密消息。详见 [小程序私密消息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share/private-message.html) */ + isPrivateMessage?: boolean + /** 需要基础库: `2.4.0` + * + * 是否是动态消息,详见[动态消息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share/updatable-message.html) */ + isUpdatableMessage?: boolean + /** 参与用户此聊天室下的 group_openid 列表 */ + participant?: string[] /** 接口调用成功的回调函数 */ - success?: GetBackgroundAudioPlayerStateSuccessCallback - } - interface GetBackgroundAudioPlayerStateSuccessCallbackResult { - /** 选定音频的播放位置(单位:s),只有在音乐播放中时返回 */ - currentPosition: number - /** 歌曲数据链接,只有在音乐播放中时返回 */ - dataUrl: string - /** 音频的下载进度百分比,只有在音乐播放中时返回 */ - downloadPercent: number - /** 选定音频的长度(单位:s),只有在音乐播放中时返回 */ - duration: number - /** 播放状态 + success?: UpdateShareMenuSuccessCallback + /** 需要基础库: `2.4.0` * - * 可选值: - * - 0: 暂停中; - * - 1: 播放中; - * - 2: 没有音乐播放; */ - status: 0 | 1 | 2 - errMsg: string + * 动态消息的模板信息 */ + templateInfo?: UpdatableMessageFrontEndTemplateInfo + /** 需要基础库: `2.11.0` + * + * 群待办消息的id,通过toDoActivityId可以把多个群待办消息聚合为同一个。通过 [updatableMessage.createActivityId](#) 接口获取。详见[群待办消息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html) */ + toDoActivityId?: string + /** 需要基础库: `3.7.8` + * + * 聊天工具模式特殊动态消息 */ + useForChatTool?: boolean + /** 是否使用带 shareTicket 的转发[详情](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html) */ + withShareTicket?: boolean } - interface GetBackgroundFetchDataOption { - /** 取值为 periodic */ - fetchType: string + interface UpdateVoIPChatMuteConfigOption { + /** 静音设置 */ + muteConfig: MuteConfig /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetBackgroundFetchDataCompleteCallback + complete?: UpdateVoIPChatMuteConfigCompleteCallback /** 接口调用失败的回调函数 */ - fail?: GetBackgroundFetchDataFailCallback + fail?: UpdateVoIPChatMuteConfigFailCallback /** 接口调用成功的回调函数 */ - success?: GetBackgroundFetchDataSuccessCallback + success?: UpdateVoIPChatMuteConfigSuccessCallback } - interface GetBackgroundFetchTokenOption { + interface UpdateWeChatAppOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetBackgroundFetchTokenCompleteCallback + complete?: UpdateWeChatAppCompleteCallback /** 接口调用失败的回调函数 */ - fail?: GetBackgroundFetchTokenFailCallback + fail?: UpdateWeChatAppFailCallback /** 接口调用成功的回调函数 */ - success?: GetBackgroundFetchTokenSuccessCallback + success?: UpdateWeChatAppSuccessCallback } - interface GetBatteryInfoOption { + interface UploadFileOption { + /** 要上传文件资源的路径 (本地路径) */ + filePath: string + /** 文件对应的 key,开发者在服务端可以通过这个 key 获取文件的二进制内容 */ + name: string + /** 开发者服务器地址 */ + url: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetBatteryInfoCompleteCallback + complete?: UploadFileCompleteCallback + /** 需要基础库: `2.10.4` + * + * 是否开启 http2 */ + enableHttp2?: boolean + /** 是否开启 profile,默认开启。开启后可在接口回调的 res.profile 中查看性能调试信息。目前仅 iOS 端支持。 */ + enableProfile?: boolean + /** 需要基础库: `2.10.4` + * + * 是否开启 Quic/h3 协议(iOS 微信目前使用 gQUIC-Q43;Android 微信在 v8.0.54 前使用 gQUIC-Q43,v8.0.54 开始使用 IETF QUIC,即 h3 协议;PC微信使用 IETF QUIC,即 h3 协议) */ + enableQuic?: boolean /** 接口调用失败的回调函数 */ - fail?: GetBatteryInfoFailCallback + fail?: UploadFileFailCallback + /** HTTP 请求中其他额外的 form data */ + formData?: IAnyObject + /** HTTP 请求 Header,Header 中不能设置 Referer */ + header?: IAnyObject /** 接口调用成功的回调函数 */ - success?: GetBatteryInfoSuccessCallback + success?: UploadFileSuccessCallback + /** 需要基础库: `2.10.0` + * + * 超时时间,单位为毫秒 */ + timeout?: number + /** 需要基础库: `3.4.1` + * + * 使用高性能模式,暂仅支持 Android,默认关闭。该模式下有更优的网络性能表现。 */ + useHighPerformanceMode?: boolean } - interface GetBatteryInfoSuccessCallbackResult { - /** 是否正在充电中 */ - isCharging: boolean - /** 设备电量,范围 1 - 100 */ - level: string + interface UploadFileSuccessCallbackResult { + /** 开发者服务器返回的数据 */ + data: string + /** 开发者服务器返回的 HTTP 状态码 */ + statusCode: number errMsg: string } - interface GetBatteryInfoSyncResult { - /** 是否正在充电中 */ - isCharging: boolean - /** 设备电量,范围 1 - 100 */ - level: string - } - interface GetBeaconsOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetBeaconsCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: GetBeaconsFailCallback - /** 接口调用成功的回调函数 */ - success?: GetBeaconsSuccessCallback + interface UploadTaskOnProgressUpdateListenerResult { + /** 上传进度百分比 */ + progress: number + /** 预期需要上传的数据总长度,单位 Bytes */ + totalBytesExpectedToSend: number + /** 已经上传的数据长度,单位 Bytes */ + totalBytesSent: number } - interface GetBeaconsSuccessCallbackResult { - /** iBeacon 设备列表 */ - beacons: IBeaconInfo[] - errMsg: string + /** @warning **用户头像昵称获取规则已调整,参考 [用户信息接口调整说明](https://developers.weixin.qq.com/community/develop/doc/000cacfa20ce88df04cb468bc52801)、[小程序用户头像昵称获取规则调整公告](https://developers.weixin.qq.com/community/develop/doc/00022c683e8a80b29bed2142b56c01)** + * + * 用户信息 */ + interface UserInfo { + /** 用户头像图片的 URL。URL 最后一个数值代表正方形头像大小(有 0、46、64、96、132 数值可选,0 代表 640x640 的正方形头像,46 表示 46x46 的正方形头像,剩余数值以此类推。默认132),用户没有头像时该项为空。若用户更换头像,原有头像 URL 将失效。 */ + avatarUrl: string + /** 用户所在城市。不再返回,参考 [相关公告](https://developers.weixin.qq.com/community/develop/doc/00028edbe3c58081e7cc834705b801) */ + city: string + /** 用户所在国家。不再返回,参考 [相关公告](https://developers.weixin.qq.com/community/develop/doc/00028edbe3c58081e7cc834705b801) */ + country: string + /** 用户性别。不再返回,参考 [相关公告](https://developers.weixin.qq.com/community/develop/doc/00028edbe3c58081e7cc834705b801) + * + * 可选值: + * - 0: 未知; + * - 1: 男性; + * - 2: 女性; */ + gender: 0 | 1 | 2 + /** 显示 country,province,city 所用的语言。强制返回 “zh_CN”,参考 [相关公告](https://developers.weixin.qq.com/community/develop/doc/00028edbe3c58081e7cc834705b801) + * + * 可选值: + * - 'en': 英文; + * - 'zh_CN': 简体中文; + * - 'zh_TW': 繁体中文; */ + language: 'en' | 'zh_CN' | 'zh_TW' + /** 用户昵称 */ + nickName: string + /** 用户所在省份。不再返回,参考 [相关公告](https://developers.weixin.qq.com/community/develop/doc/00028edbe3c58081e7cc834705b801) */ + province: string } - interface GetBluetoothAdapterStateOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetBluetoothAdapterStateCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: GetBluetoothAdapterStateFailCallback - /** 接口调用成功的回调函数 */ - success?: GetBluetoothAdapterStateSuccessCallback + /** 需要基础库: `2.28.0` + * + * 人体 anchor + * + * **示例代码** + * + * [静态图像body检测能力使用参考](https://github.com/wechat-miniprogram/miniprogram-demo/tree/master/miniprogram/packageAPI/pages/ar/photo-body-detect) + * + * [实时摄像头body检测能力使用参考](https://github.com/wechat-miniprogram/miniprogram-demo/tree/master/miniprogram/packageAPI/pages/ar/body-detect) */ + interface VKBodyAnchor { + /** 关键点的置信度 */ + confidence: number[] + /** 识别序号 */ + detectId: number + /** 唯一标识 */ + id: number + /** 相对视窗的位置信息,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */ + origin: VKOrigin + /** 关键点 */ + points: VKOrigin[] + /** 总体置信值 */ + score: number + /** 相对视窗的尺寸,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */ + size: VKSize + /** 类型 + * + * 可选值: + * - 5: 人体; */ + type: 5 } - interface GetBluetoothAdapterStateSuccessCallbackResult { - /** 蓝牙适配器是否可用 */ - available: boolean - /** 是否正在搜索设备 */ - discovering: boolean - errMsg: string + /** 需要基础库: `2.20.0` + * + * 相机对象 */ + interface VKCamera { + /** 需要基础库: `2.22.0` + * + * 相机内参,只有 v2 版本支持 */ + intrinsics: Float32Array + /** 相机原始的Pose矩阵 */ + transform: Float32Array + /** 视图矩阵 */ + viewMatrix: Float32Array + /** [Float32Array VKCamera.getProjectionMatrix(number near, number far)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKCamera.getProjectionMatrix.html) + * + * 需要基础库: `2.20.0` + * + * 在插件中使用:需要基础库 `2.20.0` + * + * 获取投影矩阵 */ + getProjectionMatrix( + /** 近视点 */ + near: number, + /** 远视点 */ + far: number + ): Float32Array } - interface GetBluetoothDevicesOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetBluetoothDevicesCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: GetBluetoothDevicesFailCallback - /** 接口调用成功的回调函数 */ - success?: GetBluetoothDevicesSuccessCallback + interface VKConfig { + /** 跟踪能力配置,目前不同的跟踪能力之间是互斥的,默认使用平面跟踪能力。需要注意目前 track 中不同的跟踪配置存在互斥关系(比如 marker 跟踪配置和 OSD 跟踪配置不能同时存在),请按需配置。 */ + track: Track + /** 需要基础库: `2.23.0` + * + * 绑定的 WebGLRenderingContext 对象 */ + gl?: WebGLRenderingContext + /** 需要基础库: `2.22.0` + * + * vision kit 版本。 + * + * 可选值: + * - 'v1': v1适用于用户在平面场景下,例如桌面,地面,泛平面场景,放置虚拟物体,不提供真实世界距离。用户放置物体时,手机相机倾斜向下对着目标平面点击即可,具有广泛的机型支持; + * - 'v2': v2提供真实物理距离的 ar 定位功能,提供平面识别功能,用户在平面范围点击放置虚拟物体的功能,具有[有限的机型支持](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/plane.html#%E9%99%84%E5%BD%95)。iOS 设备在基础库 2.22.0 开始支持v2。安卓设备在基础库 2.25.1 开始支持v2,另外,安卓v2不支持竖直平面。**使用v2算法需要初始化,移动手机进行左右平移初始化效果最佳。**; */ + version?: 'v1' | 'v2' } - interface GetBluetoothDevicesSuccessCallbackResult { - /** uuid 对应的的已连接设备列表 */ - devices: GetBluetoothDevicesSuccessCallbackResultBlueToothDevice[] - errMsg: string + /** 需要基础库: `2.33.0` + * + * depth anchor + * + * **示例代码** + * + * [深度估计能力使用参考](https://github.com/wechat-miniprogram/miniprogram-demo/tree/master/miniprogram/packageAPI/pages/ar/depth-detect) */ + interface VKDepthAnchor { + /** 包含深度信息的数组 */ + depthArray: number[] + /** 唯一标识 */ + id: number + /** 相对视窗的尺寸,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */ + size: VKSize + /** 类型 + * + * 可选值: + * - 8: DEPTH; */ + type: 8 } - /** uuid 对应的的已连接设备列表 */ - interface GetBluetoothDevicesSuccessCallbackResultBlueToothDevice { - /** 当前蓝牙设备的信号强度 */ - RSSI: number - /** 当前蓝牙设备的广播数据段中的 ManufacturerData 数据段。 */ - advertisData: ArrayBuffer - /** 当前蓝牙设备的广播数据段中的 ServiceUUIDs 数据段 */ - advertisServiceUUIDs: string[] - /** 用于区分设备的 id */ - deviceId: string - /** 当前蓝牙设备的广播数据段中的 LocalName 数据段 */ - localName: string - /** 蓝牙设备名称,某些设备可能没有 */ - name: string - /** 当前蓝牙设备的广播数据段中的 ServiceData 数据段 */ - serviceData: IAnyObject + /** 需要基础库: `2.25.0` + * + * 人脸 anchor + * + * **示例代码** + * + * [静态图像人脸检测能力使用参考](https://github.com/wechat-miniprogram/miniprogram-demo/tree/master/miniprogram/packageAPI/pages/ar/photo-face-detect) + * + * [实时摄像头人脸检测能力使用参考](https://github.com/wechat-miniprogram/miniprogram-demo/tree/master/miniprogram/packageAPI/pages/ar/face-detect) */ + interface VKFaceAnchor { + /** 人脸角度信息 */ + angle: number[] + /** 关键点的置信度 */ + confidence: number[] + /** 识别序号 */ + detectId: number + /** 唯一标识 */ + id: number + /** 相对视窗的位置信息,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */ + origin: VKOrigin + /** 人脸 106 个关键点的坐标 */ + points: VKPoint[] + /** 相对视窗的尺寸,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */ + size: VKSize + /** 类型 + * + * 可选值: + * - 3: 人脸; */ + type: 3 } - interface GetCenterLocationOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetCenterLocationCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: GetCenterLocationFailCallback - /** 接口调用成功的回调函数 */ - success?: GetCenterLocationSuccessCallback + /** 需要基础库: `2.20.0` + * + * vision kit 会话对象。 */ + interface VKFrame { + /** [VKCamera](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKCamera.html) + * + * 相机对象 */ + camera: VKCamera + /** 生成时间,单位:纳秒(ns) */ + timestamp: number + /** [ArrayBuffer VKFrame.getCameraBuffer(number width, number height)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFrame.getCameraBuffer.html) + * + * 需要基础库: `2.24.0` + * + * 在插件中使用:不支持 + * + * 获取当前帧 rgba buffer。iOS 端微信在 v8.0.20 开始支持,安卓端微信在 v8.0.30 开始支持。按 aspect-fill 规则裁剪,此接口要求在创建 VKSession 对象时必须传入 gl 参数。此接口仅建议拿来做帧分析使用,上屏请使用 getCameraTexture 来代替。 */ + getCameraBuffer( + /** 宽度,受系统限制,必须是 16 的整数倍 */ + width: number, + /** 高度 */ + height: number + ): ArrayBuffer + /** [ArrayBuffer VKFrame.getCameraJpgBuffer(number width, number height, number quality)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFrame.getCameraJpgBuffer.html) + * + * 需要基础库: `3.0.0` + * + * 在插件中使用:不支持 + * + * 获取当前帧的 jpg 信息Buffer。安卓微信 8.0.49 开始支持,iOS微信 8.0.49 开始支持。 */ + getCameraJpgBuffer( + /** 宽度 */ + width: number, + /** 高度 */ + height: number, + /** 获取纹理质量,(0 - 100) */ + quality: number + ): ArrayBuffer + /** [Float32Array VKFrame.getDisplayTransform()](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFrame.getDisplayTransform.html) + * + * 需要基础库: `2.20.0` + * + * 在插件中使用:需要基础库 `2.20.0` + * + * 获取纹理调整矩阵。默认获取到的纹理是未经裁剪调整的纹理,此矩阵可用于在着色器中根据帧对象尺寸对纹理进行裁剪。 */ + getDisplayTransform(): Float32Array + /** [Object VKFrame.getCameraTexture(WebGLRenderingContext gl)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFrame.getCameraTexture.html) + * + * 需要基础库: `2.20.0` + * + * 在插件中使用:需要基础库 `2.20.0` + * + * 获取当前帧纹理,目前只支持 YUV 纹理。 */ + getCameraTexture( + /** 画布 */ + gl: WebGLRenderingContext + ): YUVTextureRes + /** [Object VKFrame.getDepthBuffer()](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFrame.getDepthBuffer.html) + * + * 需要基础库: `3.0.0` + * + * 在插件中使用:不支持 + * + * 获取每帧的深度图信息Buffer。安卓微信 8.0.38 开始支持,iOS微信 8.0.39 开始支持。 */ + getDepthBuffer(): DepthBufferRes + /** [Object VKFrame.getLegSegmentBuffer()](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFrame.getLegSegmentBuffer.html) + * + * 需要基础库: `3.2.1` + * + * 在插件中使用:不支持 + * + * 获取每帧的腿部分割信息Buffer,安卓微信 8.0.43,iOS微信 8.0.43 开始支持。 */ + getLegSegmentBuffer(): LegSegmentBufferRes } - interface GetCenterLocationSuccessCallbackResult { - /** 纬度 */ - latitude: number - /** 经度 */ - longitude: number - errMsg: string + /** 需要基础库: `2.28.0` + * + * 手势 anchor + * + * **示例代码** + * + * [静态图像hand检测能力使用参考](https://github.com/wechat-miniprogram/miniprogram-demo/tree/master/miniprogram/packageAPI/pages/ar/photo-hand-detect) + * + * [实时摄像头hand检测能力使用参考](https://github.com/wechat-miniprogram/miniprogram-demo/tree/master/miniprogram/packageAPI/pages/ar/hand-detect) */ + interface VKHandAnchor { + /** 关键点的置信度 */ + confidence: number[] + /** 识别序号 */ + detectId: number + /** 手势分类, 返回整数-1到18, -1表示无效手势 + * + * 可选值: + * - 0: 单手比心; + * - 1: 布(数字5); + * - 2: 剪刀(数字2); + * - 3: 握拳; + * - 4: 数字1; + * - 5: 热爱; + * - 6: 点赞; + * - 7: 数字3; + * - 8: 摇滚; + * - 9: 数字6; + * - 10: 数字8; + * - 11: 双手抱拳(恭喜发财); + * - 12: 数字4; + * - 13: 比ok; + * - 14: 不喜欢(踩); + * - 15: 双手比心; + * - 16: 祈祷(双手合十); + * - 17: 双手抱拳; + * - 18: 无手势动作; + * - -1: 无效手势; */ + gesture: + | 0 + | 1 + | 2 + | 3 + | 4 + | 5 + | 6 + | 7 + | 8 + | 9 + | 10 + | 11 + | 12 + | 13 + | 14 + | 15 + | 16 + | 17 + | 18 + | -1 + /** 唯一标识 */ + id: number + /** 相对视窗的位置信息,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */ + origin: VKOrigin + /** 关键点 */ + points: VKOrigin[] + /** 总体置信值 */ + score: number + /** 相对视窗的尺寸,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */ + size: VKSize + /** 类型 + * + * 可选值: + * - 7: 手势; */ + type: 7 } - interface GetClipboardDataOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetClipboardDataCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: GetClipboardDataFailCallback - /** 接口调用成功的回调函数 */ - success?: GetClipboardDataSuccessCallback + interface VKMarker { + /** marker id */ + markerId: number + /** 图片路径 */ + path: string } - interface GetClipboardDataSuccessCallbackOption { - /** 剪贴板的内容 */ - data: string + /** 需要基础库: `2.24.5` + * + * marker anchor + * + * **示例代码** + * + * [2D Marker能力使用参考](https://github.com/wechat-miniprogram/miniprogram-demo/tree/master/miniprogram/packageAPI/pages/ar/2dmarker-ar) */ + interface VKMarkerAnchor { + /** 唯一标识 */ + id: number + /** marker id */ + markerId: number + /** 图片路径 */ + path: string + /** 包含位置、旋转、放缩信息的矩阵,以列为主序 */ + transform: Float32Array + /** 类型 + * + * 可选值: + * - 1: marker; */ + type: 1 } - interface GetConnectedBluetoothDevicesOption { - /** 蓝牙设备主 service 的 uuid 列表 */ - services: string[] - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetConnectedBluetoothDevicesCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: GetConnectedBluetoothDevicesFailCallback - /** 接口调用成功的回调函数 */ - success?: GetConnectedBluetoothDevicesSuccessCallback + /** 需要基础库: `2.27.0` + * + * OCR anchor + * + * **示例代码** + * + * [静态图像OCR检测能力使用参考](https://github.com/wechat-miniprogram/miniprogram-demo/tree/master/miniprogram/packageAPI/pages/ar/photo-ocr-detect) + * + * [实时摄像头OCR检测能力使用参考](https://github.com/wechat-miniprogram/miniprogram-demo/tree/master/miniprogram/packageAPI/pages/ar/ocr-detect) */ + interface VKOCRAnchor { + /** 唯一标识 */ + id: number + /** 识别的文字结果 */ + text: string + /** 类型 + * + * 可选值: + * - 6: OCR; */ + type: 6 } - interface GetConnectedBluetoothDevicesSuccessCallbackResult { - /** 搜索到的设备列表 */ - devices: BluetoothDeviceInfo[] - errMsg: string + /** 需要基础库: `2.24.5` + * + * OSD anchor + * + * **示例代码** + * + * [单样本检测(OSD)能力使用参考](https://github.com/wechat-miniprogram/miniprogram-demo/tree/master/miniprogram/packageAPI/pages/ar/osd-ar) */ + interface VKOSDAnchor { + /** 唯一标识 */ + id: number + /** marker id */ + markerId: number + /** 相对视窗的位置信息,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */ + origin: VKOrigin + /** 图片路径 */ + path: string + /** 相对视窗的尺寸,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */ + size: VKSize + /** 类型 + * + * 可选值: + * - 2: OSD; */ + type: 2 } - interface GetConnectedWifiOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetConnectedWifiCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: GetConnectedWifiFailCallback - /** 接口调用成功的回调函数 */ - success?: GetConnectedWifiSuccessCallback + interface VKOrigin { + /** 横坐标 */ + x: number + /** 纵坐标 */ + y: number } - interface GetConnectedWifiSuccessCallbackResult { - /** [WifiInfo](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/WifiInfo.html) + /** 需要基础库: `2.22.0` + * + * 平面 anchor,只有 v2 版本支持 + * + * **示例代码** + * + * v1 版本:[水平面AR能力使用参考](https://github.com/wechat-miniprogram/miniprogram-demo/tree/master/miniprogram/packageAPI/pages/ar/plane-ar) + * v2 版本:[水平面AR能力v2使用参考](https://github.com/wechat-miniprogram/miniprogram-demo/tree/master/miniprogram/packageAPI/pages/ar/plane-ar-v2) */ + interface VKPlaneAnchor { + /** 方向 */ + alignment: number + /** 唯一标识 */ + id: number + /** 尺寸 */ + size: VKSize + /** 包含位置、旋转、放缩信息的矩阵,以列为主序 */ + transform: Float32Array + /** 类型 * - * Wi-Fi 信息 */ - wifi: WifiInfo - errMsg: string + * 可选值: + * - 0: 平面; */ + type: 0 } - interface GetContentsOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetContentsCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: GetContentsFailCallback - /** 接口调用成功的回调函数 */ - success?: GetContentsSuccessCallback + /** 人脸 106 个关键点的坐标 */ + interface VKPoint { + /** 横坐标 */ + x: number + /** 纵坐标 */ + y: number + } + /** 需要基础库: `2.20.0` + * + * vision kit 会话对象。 */ + interface VKSession { + /** 相机尺寸 */ + cameraSize: VKSize + /** 会话配置 */ + config: VKConfig + /** 会话状态 + * + * 可选值: + * - 0: 不可用; + * - 1: 运行中; + * - 2: 暂停中; + * - 3: 初始化中; */ + state: 0 | 1 | 2 | 3 + /** [Array.<Object> VKSession.getAllMarker()](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.getAllMarker.html) + * + * 需要基础库: `2.24.5` + * + * 在插件中使用:需要基础库 `2.24.5` + * + * 获取所有 marker,要求调 [wx.createVKSession](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/wx.createVKSession.html) 时传入的 track.marker 为 true */ + getAllMarker(): VKMarker[] + /** [Array.<Object> VKSession.getAllOSDMarker()](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.getAllOSDMarker.html) + * + * 需要基础库: `2.24.5` + * + * 在插件中使用:需要基础库 `2.24.5` + * + * 获取所有 OSD marker,要求调 [wx.createVKSession](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/wx.createVKSession.html) 时传入的 track.OSD 为 true */ + getAllOSDMarker(): VKMarker[] + /** [Array.<Object> VKSession.hitTest(number x, number y, Object reset)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.hitTest.html) + * + * 需要基础库: `2.20.0` + * + * 在插件中使用:需要基础库 `2.20.0` + * + * 触摸检测,v1 版本只支持单平面(即 hitTest 生成一次平面后,后续 hitTest 均不会再生成平面,而是以之前生成的平面为基础进行检测)。如果需要重新识别其他平面,可以在调用此方法时将 reset 参数置为 true。 */ + hitTest( + /** 相对视窗的横坐标,取值范围为 [0, 1],0 为左边缘,1 为右边缘 */ + x: number, + /** 相对视窗的纵坐标,取值范围为 [0, 1],0 为上边缘,1 为下边缘 */ + y: number, + /** 是否需要重新识别其他平面,v2 版本不再需要此参数 */ + reset: IAnyObject + ): HitTestRes[] + /** [VKSession.cancelAnimationFrame(number requestID)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.cancelAnimationFrame.html) + * + * 需要基础库: `2.20.0` + * + * 在插件中使用:需要基础库 `2.20.0` + * + * 取消由 requestAnimationFrame 添加到计划中的动画帧请求。 */ + cancelAnimationFrame(requestID: number): void + /** [VKSession.destroy()](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.destroy.html) + * + * 需要基础库: `2.20.0` + * + * 在插件中使用:需要基础库 `2.20.0` + * + * 销毁会话。 */ + destroy(): void + /** [VKSession.detectBody(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.detectBody.html) + * + * 需要基础库: `2.28.0` + * + * 在插件中使用:需要基础库 `2.28.0` + * + * 静态图像人体关键点检测。当 wx.createVKSession 参数传入 {track: {body: {mode: 2} } } 时可用。用法详情[指南文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/body.html)。 */ + detectBody(option: DetectBodyOption): void + /** [VKSession.detectDepth(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.detectDepth.html) + * + * 需要基础库: `2.33.0` + * + * 在插件中使用:需要基础库 `2.33.0` + * + * 深度识别。当 wx.createVKSession 参数传入 {track: {depth: {mode: 2} } } 时可用。用法详情[指南文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/depth.html)。 */ + detectDepth(option: DetectDepthOption): void + /** [VKSession.detectFace(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.detectFace.html) + * + * 需要基础库: `2.25.0` + * + * 在插件中使用:需要基础库 `2.25.0` + * + * 静态图像人脸关键点检测。当 wx.createVKSession 参数传入 {track: {face: {mode: 2} } } 时可用。用法详情[指南文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/face.html)。安卓微信8.0.25开始支持,iOS微信8.0.24开始支持。 + * + * **** + * + * ### 特别说明 + * 若小程序人脸识别功能涉及采集、存储用户生物特征(如人脸照片或视频、身份证和手持身份证、身份证照和免冠照等),此类型服务需使用[微信原生人脸识别接口](https://developers.weixin.qq.com/community/develop/doc/000442d352c1202bd498ecb105c00d?highline=%E4%BA%BA%E8%84%B8%E6%A0%B8%E8%BA%AB)。 */ + detectFace(option: DetectFaceOption): void + /** [VKSession.detectHand(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.detectHand.html) + * + * 需要基础库: `2.28.0` + * + * 在插件中使用:需要基础库 `2.28.0` + * + * 静态图像手势关键点检测。当 wx.createVKSession 参数传入 {track: {hand: {mode: 2} } } 时可用。用法详情[指南文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/hand.html)。 */ + detectHand(option: DetectHandOption): void + /** [VKSession.off(string eventName, function fn)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.off.html) + * + * 需要基础库: `2.20.0` + * + * 在插件中使用:需要基础库 `2.20.0` + * + * 取消监听会话事件。 */ + off( + /** 事件名称 */ + eventName: string, + /** 事件监听函数 */ + fn: (...args: any[]) => any + ): void + /** [VKSession.on(string eventName, function fn)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.on.html) + * + * 需要基础库: `2.20.0` + * + * 在插件中使用:需要基础库 `2.20.0` + * + * 监听会话事件。 */ + on( + /** 事件名称 + * + * 参数 eventName 可选值: + * - 'resize': 相机尺寸变化事件,回调参数为相机尺寸; + * - 'addAnchors': 增加 anchor 事件,回调参数为 [VKPlaneAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKPlaneAnchor.html)/[VKMarkerAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKMarkerAnchor.html)/[VKOSDAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKOSDAnchor.html) 列表(只有v2版本支持) 或 [VKFaceAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFaceAnchor.html)/[VKOCRAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKOCRAnchor.html)/[VKHandAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKHandAnchor.html)/[VKBodyAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKBodyAnchor.html)列表(v1、v2都支持); + * - 'updateAnchors': 更新 anchor 事件,回调参数为 [VKPlaneAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKPlaneAnchor.html)/[VKMarkerAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKMarkerAnchor.html)/[VKOSDAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKOSDAnchor.html) 列表(只有v2版本支持) 或 [VKFaceAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFaceAnchor.html)/[VKOCRAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKOCRAnchor.html)/[VKHandAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKHandAnchor.html)/[VKBodyAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKBodyAnchor.html)列表(v1、v2都支持); + * - 'removeAnchors': 删除 anchor 事件,回调参数为 [VKPlaneAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKPlaneAnchor.html)/[VKMarkerAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKMarkerAnchor.html)/[VKOSDAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKOSDAnchor.html) 列表(只有v2版本支持) 或 [VKFaceAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFaceAnchor.html)/[VKOCRAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKOCRAnchor.html)/[VKHandAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKHandAnchor.html)/[VKBodyAnchor](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKBodyAnchor.html) 列表(v1、v2都支持); */ + eventName: + | 'resize' + | 'addAnchors' + | 'updateAnchors' + | 'removeAnchors', + /** 事件监听函数 */ + fn: (...args: any[]) => any + ): void + /** [VKSession.removeMarker(number markerId)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.removeMarker.html) + * + * 需要基础库: `2.24.5` + * + * 在插件中使用:需要基础库 `2.24.5` + * + * 删除一个 marker,要求调 [wx.createVKSession](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/wx.createVKSession.html) 时传入的 track.marker 为 true */ + removeMarker( + /** marker id */ + markerId: number + ): void + /** [VKSession.removeOSDMarker(number markerId)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.removeOSDMarker.html) + * + * 需要基础库: `2.24.5` + * + * 在插件中使用:需要基础库 `2.24.5` + * + * 删除一个 OSD marker,要求调 [wx.createVKSession](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/wx.createVKSession.html) 时传入的 track.OSD 为 true */ + removeOSDMarker( + /** marker id */ + markerId: number + ): void + /** [VKSession.runOCR(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.runOCR.html) + * + * 需要基础库: `2.27.0` + * + * 在插件中使用:需要基础库 `2.27.0` + * + * 静态图像OCR检测。当 wx.createVKSession 参数传入 {track: {OCR: {mode: 2} } } 时可用。用法详情[指南文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/ocr.html)。 */ + runOCR(option: RunOCROption): void + /** [VKSession.setDepthOccRange(number threshold)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.setDepthOccRange.html) + * + * 需要基础库: `3.0.0` + * + * 在插件中使用:需要基础库 `3.0.0` + * + * 更新 深度遮挡 Occ范围,要求调 [wx.createVKSession](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/wx.createVKSession.html) 时传入 {track: {depth: {mode: 2} } } */ + setDepthOccRange( + /** 阈值 */ + threshold: number + ): void + /** [VKSession.start(function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.start.html) + * + * 需要基础库: `2.20.0` + * + * 在插件中使用:需要基础库 `2.20.0` + * + * 开启会话。 */ + start( + /** 开启会话回调 */ + callback: VKSessionStartCallback + ): void + /** [VKSession.stop()](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.stop.html) + * + * 需要基础库: `2.20.0` + * + * 在插件中使用:需要基础库 `2.20.0` + * + * 停止会话。 */ + stop(): void + /** [VKSession.update3DMode(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.update3DMode.html) + * + * 需要基础库: `2.30.2` + * + * 在插件中使用:需要基础库 `2.30.2` + * + * 更新三维识别相关配置,要求调 [wx.createVKSession](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/wx.createVKSession.html) 时使用 face / hand / body。 */ + update3DMode(option: Update3DModeOption): void + /** [VKSession.updateMaskMode(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.updateMaskMode.html) + * + * 需要基础库: `3.2.1` + * + * 在插件中使用:需要基础库 `3.2.1` + * + * 设置裁剪相关配置,要求调 [wx.createVKSession](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/wx.createVKSession.html) 时使用 shoe。 */ + updateMaskMode(option: UpdateMaskModeOption): void + /** [VKSession.updateOSDThreshold(number threshold)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.updateOSDThreshold.html) + * + * 需要基础库: `2.24.5` + * + * 在插件中使用:需要基础库 `2.24.5` + * + * 更新 OSD 识别精确度,要求调 [wx.createVKSession](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/wx.createVKSession.html) 时传入的 track.OSD 为 true */ + updateOSDThreshold( + /** 阈值 */ + threshold: number + ): void + /** [[VKFrame](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFrame.html) VKSession.getVKFrame(number width, number height)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.getVKFrame.html) + * + * 需要基础库: `2.20.0` + * + * 在插件中使用:需要基础库 `2.20.0` + * + * 获取帧对象,每调用一次都会触发一次帧分析过程。目前 VKSession 相机的最大帧数是 30 fps,因此调用 getVKFrame 的频率也可以限制在 30 fps,以减少渲染开销。 */ + getVKFrame( + /** 宽度 */ + width: number, + /** 高度 */ + height: number + ): VKFrame + /** [number VKSession.addMarker(string path)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.addMarker.html) + * + * 需要基础库: `2.24.5` + * + * 在插件中使用:需要基础库 `2.24.5` + * + * 添加一个 marker,要求调 [wx.createVKSession](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/wx.createVKSession.html) 时传入的 track.marker 为 true + * + * **使用提示** + * + * 注意事项: + * 1. 使用 addMarker 接口之前,需要在 createVKSession 的时候声明开启 marker 跟踪。即 wx.createVKSession({ track: { marker: true } }) + * 2. 可以添加多个 marker 图片,但不能重复添加相同的 marker 图片。 + * 3. 在v2模式下同时支持水平面检测与marker检测,同时可输出多个2d/3d marker位姿(需要基础库版本不低于 [2.33.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) + * + * ### 2Dmarker + * 对传入的图片有如下要求: + * 1. 格式:jpg/png 格式三通道彩图或者 1 通道灰度图 + * 2. 分辨率:尺寸在 480x480 ~ 1920x1920 之间,建议为 1080 分辨率 + * 3. 宽高比:在 1:1 ~ 16:9 之间,要求尽量方正,避免狭长的图片 + * 4. 质量:目标图像为平面模型,需要占画面主体,避免大面积留白,建议用扫描件 + * + * 示例: + * + * image.png + * + * 建议: + * + * 1. 图片具有丰富的细节 + * 2. 避免重复单一的纹理,例如: + * + * image.png + *
+ * image.png + *
+ * image.png + *
+ * + * 3. 避免使用柔和平滑边缘的纹理及大量渐变图像,例如: + * + * image.png + * + * 4. 避免模糊,建议采用高清、高对比度图像作为识别对象 + * 5. 建议图像有均匀的特征(角点)分布,正确示例: + * + * image.png + * + * 避免角点较少、中间大量空白、没有特征及角点的图像,错误示例: + * + * image.png + * + * ### 3Dmarker + * 现小程序demo支持通过上传视频, 生成对应模型的3dmarker识别文件,后缀名为.map + * + * 对传入的视频有如下要求: + * 1.视频长宽比为16:9或4:3; 短边大于480px + * 2.目标物体易于和背景物体区分出来,同时目标物体放置与背景物体一定距离,放置底面与物体易于区分,底面可以放置一张白纸,例如: + * + * image.png + * + * 3.目标物体最好为刚体,本身不会发生较大形变, 容易变形的物体不适合用作识别对象 + * 4.视频匀速移动,避免模糊,对目标识别面环绕物体拍摄,需要保证相机有足够的平移移动 + * 5.marker物体要求与2d图像要求类似,具有丰富细节,避免重复单一纹理,不反光,无高光 + * 6.拍摄视频中特征纹理丰富,如果marker本身问题较弱,可以在背景中适当添加纹理物体 + * 服务耗时:当前版本30s视频耗时约20分钟,请静待算法返回模型 + * + * 建议: + * + * 1.视频格式:视频帧率30fps,分辨率建议1080p + * 2.视频时长:视频建议时长在20s~30s,超过30s会被截断,时长过短会导致marker效果欠佳 */ + addMarker( + /** 图片路径,目前只支持本地用户图片 */ + path: string + ): number + /** [number VKSession.addOSDMarker(string path)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.addOSDMarker.html) + * + * 需要基础库: `2.24.5` + * + * 在插件中使用:需要基础库 `2.24.5` + * + * 添加一个 OSD marker(one-shot detection marker),要求调 [wx.createVKSession](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/wx.createVKSession.html) 时传入的 track.OSD 为 true + * + * **使用提示** + * + * 注意事项: + * 1. 使用 addOSDMarker 接口之前,需要在 createVKSession 的时候声明开启 OSD 跟踪。即 wx.createVKSession({ track: { OSD: true } }) + * 2. 可以添加多个 OSDMarker 图片,但不能重复添加相同的 OSDMarker 图片。 + * + * 对传入的图片有如下要求: + * 1. 格式:jpg 格式彩色图片 + * 2. 分辨率:尺寸不低于 240x240 + * 3. 宽高比:在 1:1 ~ 16:9 之间,要求尽量方正,避免狭长的图片 + * 4. 质量:目标物体需要占画面主体,避免大面积留白,避免大面积文字,不能含其他物体。 + * + * 示例: + * + * image.png + *
+ * image.png + *
+ * image.png + *
+ * + * 建议: + * + * 1. 具有丰富的细节,避免纯色且形状特点不鲜明的物体,例如: + * + * image.png + * + * 2. 避免模糊,最好采用高清图片 */ + addOSDMarker( + /** 图片路径,目前只支持本地用户图片 */ + path: string + ): number + /** [number VKSession.requestAnimationFrame(function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.requestAnimationFrame.html) + * + * 需要基础库: `2.20.0` + * + * 在插件中使用:需要基础库 `2.20.0` + * + * 在下次进行重绘时执行。 */ + requestAnimationFrame( + /** 执行的 callback */ + callback: (...args: any[]) => any + ): number } - interface GetExtConfigOption { + interface VKSize { + /** 高度 */ + height: number + /** 宽度 */ + width: number + } + interface VibrateLongOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetExtConfigCompleteCallback + complete?: VibrateLongCompleteCallback /** 接口调用失败的回调函数 */ - fail?: GetExtConfigFailCallback + fail?: VibrateLongFailCallback /** 接口调用成功的回调函数 */ - success?: GetExtConfigSuccessCallback - } - interface GetExtConfigSuccessCallbackResult { - /** 第三方平台自定义的数据 */ - extConfig: IAnyObject - errMsg: string + success?: VibrateLongSuccessCallback } - interface GetFileInfoFailCallbackResult { + interface VibrateShortFailCallbackResult { /** 错误信息 * * 可选值: - * - 'fail file not exist': 指定的 filePath 找不到文件; */ + * - 'style is not support': 当前设备不支持设置震动等级; */ errMsg: string } - interface GetHCEStateOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetHCEStateCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: GetHCEStateFailCallback - /** 接口调用成功的回调函数 */ - success?: GetHCEStateSuccessCallback - } - interface GetImageInfoOption { - /** 图片的路径,支持网络路径、本地路径、代码包路径 */ - src: string + interface VibrateShortOption { + /** 需要基础库: `2.13.0` + * + * 震动强度类型,有效值为:heavy、medium、light */ + type: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetImageInfoCompleteCallback + complete?: VibrateShortCompleteCallback /** 接口调用失败的回调函数 */ - fail?: GetImageInfoFailCallback + fail?: VibrateShortFailCallback /** 接口调用成功的回调函数 */ - success?: GetImageInfoSuccessCallback + success?: VibrateShortSuccessCallback } - interface GetImageInfoSuccessCallbackResult { - /** 图片原始高度,单位px。不考虑旋转。 */ - height: number - /** [拍照时设备方向](http://sylvana.net/jpegcrop/exif_orientation.html) + interface VideoContextRequestFullScreenOption { + /** 需要基础库: `1.7.0` + * + * 设置全屏时视频的方向,不指定则根据宽高比自动判断。 * * 可选值: - * - 'up': 默认方向(手机横持拍照),对应 Exif 中的 1。或无 orientation 信息。; - * - 'up-mirrored': 同 up,但镜像翻转,对应 Exif 中的 2; - * - 'down': 旋转180度,对应 Exif 中的 3; - * - 'down-mirrored': 同 down,但镜像翻转,对应 Exif 中的 4; - * - 'left-mirrored': 同 left,但镜像翻转,对应 Exif 中的 5; - * - 'right': 顺时针旋转90度,对应 Exif 中的 6; - * - 'right-mirrored': 同 right,但镜像翻转,对应 Exif 中的 7; - * - 'left': 逆时针旋转90度,对应 Exif 中的 8; + * - 0: 正常竖向; + * - 90: 屏幕逆时针90度; + * - -90: 屏幕顺时针90度; */ + direction?: 0 | 90 | -90 + } + interface VideoDecoderStartOption { + /** 需要解码的视频源文件。基础库 2.13.0 以下的版本只支持本地路径。 2.13.0 开始支持 http:// 和 https:// 协议的远程路径。 */ + source: string + /** 需要基础库: `2.15.0` * - * 最低基础库: `1.9.90` */ - orientation: - | 'up' - | 'up-mirrored' - | 'down' - | 'down-mirrored' - | 'left-mirrored' - | 'right' - | 'right-mirrored' - | 'left' - /** 图片的本地路径 */ - path: string - /** 图片格式 + * 是否不需要音频轨道 */ + abortAudio?: boolean + /** 需要基础库: `2.15.0` * - * 最低基础库: `1.9.90` */ - type: string - /** 图片原始宽度,单位px。不考虑旋转。 */ - width: number - errMsg: string + * 是否不需要视频轨道 */ + abortVideo?: boolean + /** 解码模式。0:按 pts 解码;1:以最快速度解码 */ + mode?: number } - interface GetLocationOption { - /** 传入 true 会返回高度信息,由于获取高度需要较高精确度,会减慢接口返回速度 + interface VoIP1v1ChatUser { + /** 昵称 */ + nickname: string + /** 小程序内 openid */ + openid: string + /** 头像 */ + headImage?: string + } + /** 需要基础库: `2.19.0` +* +* WebAudioContext 实例,通过[wx.createWebAudioContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createWebAudioContext.html) 接口获取该实例。 +* +* **示例代码** +* +* ```js +// 监听状态 +const audioCtx = wx.createWebAudioContext() +audioCtx.onstatechange = () => { + console.log(ctx.state) +} +setTimeout(audioCtx.suspend, 1000) +setTimeout(audioCtx.resume, 2000) +``` */ + interface WebAudioContext { + /** 获取当前上下文的时间戳。 */ + currentTime: number + /** [WebAudioContextNode](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContextNode.html) * - * 最低基础库: `1.6.0` */ - altitude?: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetLocationCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: GetLocationFailCallback - /** 高精度定位超时时间(ms),指定时间内返回最高精度,该值3000ms以上高精度定位才有效果 + * 当前上下文的最终目标节点,一般是音频渲染设备。 */ + destination: WebAudioContextNode + /** [AudioListener](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioListener.html) * - * 最低基础库: `2.9.0` */ - highAccuracyExpireTime?: number - /** 开启高精度定位 + * 空间音频监听器。 */ + listener: AudioListener + /** 可写属性,开发者可以对该属性设置一个监听函数,当WebAudio状态改变的时候,会触发开发者设置的监听函数。 */ + onstatechange: (...args: any[]) => any + /** 采样率,通常在8000-96000之间,通常44100hz的采样率最为常见。 */ + sampleRate: number + /** 当前WebAudio上下文的状态。可能的值如下:suspended(暂停)、running(正在运行)、closed(已关闭)。需要注意的是,不要在 audioContext close后再访问state属性 */ + state: string + /** [AnalyserNode WebAudioContext.createAnalyser()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createAnalyser.html) * - * 最低基础库: `2.9.0` */ - isHighAccuracy?: boolean - /** 接口调用成功的回调函数 */ - success?: GetLocationSuccessCallback - /** wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标 */ - type?: string - } - interface GetLocationSuccessCallbackResult { - /** 位置的精确度 */ - accuracy: number - /** 高度,单位 m + * 需要基础库: `2.22.0` * - * 最低基础库: `1.2.0` */ - altitude: number - /** 水平精度,单位 m + * 在插件中使用:不支持 * - * 最低基础库: `1.2.0` */ - horizontalAccuracy: number - /** 纬度,范围为 -90~90,负数表示南纬 */ - latitude: number - /** 经度,范围为 -180~180,负数表示西经 */ - longitude: number - /** 速度,单位 m/s */ - speed: number - /** 垂直精度,单位 m(Android 无法获取,返回 0) + * 创建一个 AnalyserNode 。可以用来获取音频时间和频率数据,以及实现数据可视化。 */ + createAnalyser(): AnalyserNode + /** [BiquadFilterNode WebAudioContext.createBiquadFilter()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createBiquadFilter.html) * - * 最低基础库: `1.2.0` */ - verticalAccuracy: number - errMsg: string - } - interface GetLogManagerOption { - /** 取值为0/1,取值为0表示是否会把 `App`、`Page` 的生命周期函数和 `wx` 命名空间下的函数调用写入日志,取值为1则不会。默认值是 0 + * 在插件中使用:不支持 * - * 最低基础库: `2.3.2` */ - level?: number - } - interface GetNetworkTypeOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetNetworkTypeCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: GetNetworkTypeFailCallback - /** 接口调用成功的回调函数 */ - success?: GetNetworkTypeSuccessCallback - } - interface GetNetworkTypeSuccessCallbackResult { - /** 网络类型 + * 创建一个BiquadFilterNode */ + createBiquadFilter(): BiquadFilterNode + /** [ChannelMergerNode WebAudioContext.createChannelMerger(number numberOfInputs)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createChannelMerger.html) * - * 可选值: - * - 'wifi': wifi 网络; - * - '2g': 2g 网络; - * - '3g': 3g 网络; - * - '4g': 4g 网络; - * - '5g': 5g 网络; - * - 'unknown': Android 下不常见的网络类型; - * - 'none': 无网络; */ - networkType: 'wifi' | '2g' | '3g' | '4g' | '5g' | 'unknown' | 'none' - errMsg: string - } - interface GetRegionOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetRegionCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: GetRegionFailCallback - /** 接口调用成功的回调函数 */ - success?: GetRegionSuccessCallback - } - interface GetRegionSuccessCallbackResult { - /** 东北角经纬度 */ - northeast: number - /** 西南角经纬度 */ - southwest: number - errMsg: string + * 在插件中使用:不支持 + * + * 创建一个ChannelMergerNode */ + createChannelMerger( + /** 输出流中需要保持的输入流的个数 */ + numberOfInputs: number + ): ChannelMergerNode + /** [ChannelSplitterNode WebAudioContext.createChannelSplitter(number numberOfOutputs)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createChannelSplitter.html) + * + * 在插件中使用:不支持 + * + * 创建一个ChannelSplitterNode */ + createChannelSplitter( + /** 要分别输出的输入音频流中的通道数 */ + numberOfOutputs: number + ): ChannelSplitterNode + /** [ConstantSourceNode WebAudioContext.createConstantSource()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createConstantSource.html) + * + * 在插件中使用:不支持 + * + * 创建一个ConstantSourceNode */ + createConstantSource(): ConstantSourceNode + /** [DelayNode WebAudioContext.createDelay(number maxDelayTime)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createDelay.html) + * + * 在插件中使用:不支持 + * + * 创建一个DelayNode */ + createDelay( + /** 最大延迟时间 */ + maxDelayTime: number + ): DelayNode + /** [DynamicsCompressorNode WebAudioContext.createDynamicsCompressor()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createDynamicsCompressor.html) + * + * 在插件中使用:不支持 + * + * 创建一个DynamicsCompressorNode */ + createDynamicsCompressor(): DynamicsCompressorNode + /** [GainNode WebAudioContext.createGain()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createGain.html) + * + * 在插件中使用:不支持 + * + * 创建一个GainNode */ + createGain(): GainNode + /** [IIRFilterNode WebAudioContext.createIIRFilter(Array.<number> feedforward, Array.<number> feedback)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createIIRFilter.html) + * + * 在插件中使用:不支持 + * + * 创建一个IIRFilterNode */ + createIIRFilter( + /** 一个浮点值数组,指定IIR滤波器传递函数的前馈(分子)系数。 */ + feedforward: number[], + /** 一个浮点值数组,指定IIR滤波器传递函数的反馈(分母)系数。 */ + feedback: number[] + ): IIRFilterNode + /** [OscillatorNode WebAudioContext.createOscillator()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createOscillator.html) + * + * 在插件中使用:不支持 + * + * 创建一个OscillatorNode */ + createOscillator(): OscillatorNode + /** [PannerNode WebAudioContext.createPanner()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createPanner.html) + * + * 在插件中使用:不支持 + * + * 创建一个PannerNode */ + createPanner(): PannerNode + /** [PeriodicWaveNode WebAudioContext.createPeriodicWave(Float32Array real, Float32Array imag, object constraints)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createPeriodicWave.html) +* +* 在插件中使用:不支持 +* +* 创建一个PeriodicWaveNode +* +* **注意** +* +* `real`和`imag`数组必须拥有一样的长度,否则抛出错误 +* ```js +const real = new Float32Array(2) +const imag = new Float32Array(2) +real[0] = 0 +imag[0] = 0 +real[1] = 1 +imag[1] = 0 + +const waveNode = audioContext.createPeriodicWave(real, imag, {disableNormalization: true}) +``` */ + createPeriodicWave( + /** 一系列余弦术语(传统上的A项) */ + real: Float32Array, + /** 一系列正弦项(传统上的B项) */ + imag: Float32Array, + /** 一个字典对象,用于指定是否禁用规范化(默认启用规范化) */ + constraints: Constraints + ): PeriodicWaveNode + /** [Promise WebAudioContext.close()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.close.html) +* +* 在插件中使用:不支持 +* +* 关闭WebAudioContext +* +* **注意事项** +* +* 同步关闭对应的WebAudio上下文。close后会立即释放当前上下文的资源,不要在close后再次访问state属性。 +* ```js +const audioCtx = wx.createWebAudioContext() +audioCtx.close().then(() => { + console.log(audioCtx.state) // bad case:不应该在close后再访问state +}) +``` */ + close(): Promise + /** [Promise WebAudioContext.resume()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.resume.html) + * + * 在插件中使用:不支持 + * + * 同步恢复已经被暂停的WebAudioContext上下文 */ + resume(): Promise + /** [Promise WebAudioContext.suspend()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.suspend.html) + * + * 在插件中使用:不支持 + * + * 同步暂停WebAudioContext上下文 */ + suspend(): Promise + /** [ScriptProcessorNode WebAudioContext.createScriptProcessor(number bufferSize, number numberOfInputChannels, number numberOfOutputChannels)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createScriptProcessor.html) + * + * 在插件中使用:不支持 + * + * 创建一个ScriptProcessorNode */ + createScriptProcessor( + /** 缓冲区大小,以样本帧为单位 */ + bufferSize: number, + /** 用于指定输入node的声道的数量 */ + numberOfInputChannels: number, + /** 用于指定输出node的声道的数量 */ + numberOfOutputChannels: number + ): ScriptProcessorNode + /** [WaveShaperNode WebAudioContext.createWaveShaper()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createWaveShaper.html) + * + * 在插件中使用:不支持 + * + * 创建一个WaveShaperNode */ + createWaveShaper(): WaveShaperNode + /** [[AudioBuffer](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioBuffer.html) WebAudioContext.createBuffer(number numOfChannels, number length, number sampleRate)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createBuffer.html) + * + * 在插件中使用:不支持 + * + * 创建一个AudioBuffer,代表着一段驻留在内存中的短音频 */ + createBuffer( + /** 定义了 buffer 中包含的声频通道数量的整数 */ + numOfChannels: number, + /** 代表 buffer 中的样本帧数的整数 */ + length: number, + /** 线性音频样本的采样率,即每一秒包含的关键帧的个数 */ + sampleRate: number + ): AudioBuffer + /** [[AudioBuffer](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioBuffer.html) WebAudioContext.decodeAudioData(ArrayBuffer audioData, function successCallback, function errorCallback)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.decodeAudioData.html) + * + * 在插件中使用:不支持 + * + * 异步解码一段资源为AudioBuffer。 */ + decodeAudioData( + /** 一个包含音频文件数据的 ArrayBuffer */ + audioData: ArrayBuffer, + /** 在音频数据解码成功时被调用,参数为解码后的AudioBuffer */ + successCallback: (...args: any[]) => any, + /** 在音频数据解码失败时被调用 */ + errorCallback: (...args: any[]) => any + ): AudioBuffer + /** [[BufferSourceNode](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/BufferSourceNode.html) WebAudioContext.createBufferSource()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createBufferSource.html) + * + * 在插件中使用:不支持 + * + * 创建一个BufferSourceNode实例,通过AudioBuffer对象来播放音频数据。 */ + createBufferSource(): BufferSourceNode + } + /** 一类音频处理模块,不同的Node具备不同的功能,如GainNode(音量调整)等。一个WebAudioContextNode可以通过上下文来创建。 + * 目前已经支持以下Node: + * IIRFilterNode + * WaveShaperNode + * ConstantSourceNode + * ChannelMergerNode + * OscillatorNode + * GainNode + * BiquadFilterNode + * PeriodicWaveNode + * BufferSourceNode + * ChannelSplitterNode + * ChannelMergerNode + * DelayNode + * DynamicsCompressorNode + * ScriptProcessorNode + * PannerNode + * AnalyserNode */ + interface WebAudioContextNode {} + /** 提供预设的 Wi-Fi 信息列表 */ + interface WifiData { + /** Wi-Fi 的 BSSID */ + BSSID?: string + /** Wi-Fi 的 SSID */ + SSID?: string + /** Wi-Fi 设备密码 */ + password?: string } - interface GetRotateOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetRotateCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: GetRotateFailCallback - /** 接口调用成功的回调函数 */ - success?: GetRotateSuccessCallback + /** Wifi 信息 + * + * **注意** + * + * - 安卓 wx.connectWifi / wx.getConnectedWifi 若设置了 partialInfo:true ,或者调用了 wx.onWifiConnectedWithPartialInfo 事件。将会返回只包含 SSID 属性的 WifiInfo 对象。 + * - iOS wx.getConnectedWifi 若设置了 partialInfo:true ,将会返回只包含 SSID、BSSID 属性的 WifiInfo 对象,且需要用户开启微信定位权限才能正确返回结果。 + * - 在某些情况下,可能 Wi-Fi 已经连接成功,但会因为获取不到完整的 WifiInfo 对象报错。具体错误信息为 errCode: 12010, errMsg: can't gain current wifi 或 no wifi is connected 。如果开发者不需要完整的 WifiInfo 对象,则可以通过采取上述策略解决报错问题。 */ + interface WifiInfo { + /** Wi-Fi 的 BSSID */ + BSSID: string + /** Wi-Fi 的 SSID */ + SSID: string + /** 需要基础库: `2.12.0` + * + * Wi-Fi 频段单位 MHz */ + frequency: number + /** Wi-Fi 是否安全 */ + secure: boolean + /** Wi-Fi 信号强度, 安卓取值 0 ~ 100 ,iOS 取值 0 ~ 1 ,值越大强度越大 */ + signalStrength: number } - interface GetRotateSuccessCallbackResult { - /** 旋转角 */ - rotate: number - errMsg: string + interface WindowInfo { + /** 设备像素比 */ + pixelRatio: number + /** 在竖屏正方向下的安全区域。部分机型没有安全区域概念,也不会返回 safeArea 字段,开发者需自行兼容。 */ + safeArea: SafeArea + /** 屏幕高度,单位px */ + screenHeight: number + /** 窗口上边缘的y值 */ + screenTop: number + /** 屏幕宽度,单位px */ + screenWidth: number + /** 状态栏的高度,单位px */ + statusBarHeight: number + /** 可使用窗口高度,单位px */ + windowHeight: number + /** 可使用窗口宽度,单位px */ + windowWidth: number } - interface GetSavedFileInfoOption { - /** 文件路径 (本地路径) */ - filePath: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetSavedFileInfoCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: GetSavedFileInfoFailCallback - /** 接口调用成功的回调函数 */ - success?: GetSavedFileInfoSuccessCallback + /** Worker 实例,主线程中可通过 [wx.createWorker](https://developers.weixin.qq.com/miniprogram/dev/api/worker/wx.createWorker.html) 接口获取,worker 线程中可通过全局变量 `worker` 获取。 +* +* **示例代码** +* +* 运行以下代码需先进行基础配置,详细请查阅 [多线程 Worker](https://developers.weixin.qq.com/miniprogram/dev/framework/workers.html) 文档了解基础知识和配置方法。 +* +* ```js +const worker = wx.createWorker('workers/request/index.js') // 文件名指定 worker 的入口文件路径,绝对路径 + +worker.onMessage(function (res) { + console.log(res) +}) +// 监听worker被系统回收事件 +worker.onProcessKilled(function () { + console.log('worker has been killed') + // 重新创建一个worker + // wx.createWorker() +}) + +worker.postMessage({ + msg: 'hello worker' +}) + +worker.terminate() +``` */ + interface Worker { + /** worker内的环境变量 */ + env: WorkerEnv + /** [ArrayBuffer Worker.getCameraFrameData()](https://developers.weixin.qq.com/miniprogram/dev/api/worker/Worker.getCameraFrameData.html) +* +* 需要基础库: `2.25.1` +* +* 在插件中使用:不支持 +* +* 获取摄像头当前帧图像,返回ArrayBuffer数据。仅限在 worker 线程中使用。 +* +* **示例代码** +* +* ```js +// app.js +const worker = wx.createWorker('workers/index.js', { + useExperimentalWorker: true +}) + +const cameraContext = wx.createCameraContext() +const cameraFrameListener = cameraContext.onCameraFrame(function() {}) +cameraFrameListener.start({ + worker: worker +}) +``` +* +* ```js +// workers/index.js +const data = worker.getCameraFrameData() +console.log(data) +``` */ + getCameraFrameData(): ArrayBuffer + /** [Worker.onMessage(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/worker/Worker.onMessage.html) + * + * 在插件中使用:不支持 + * + * 监听主线程/Worker 线程向当前线程发送的消息的事件。 */ + onMessage( + /** 主线程/Worker 线程向当前线程发送的消息的事件的监听函数 */ + listener: WorkerOnMessageCallback + ): void + /** [Worker.onProcessKilled(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/worker/Worker.onProcessKilled.html) + * + * 在插件中使用:不支持 + * + * 监听 worker线程被系统回收事件(开启 useExperimentalWorker 后,当iOS系统资源紧张时,ExperimentalWorker 线程存在被系统回收的可能,开发者可监听此事件并重新创建一个worker)。仅限在主线程 worker 对象上调用。 */ + onProcessKilled( + /** worker线程被系统回收事件的监听函数 */ + listener: OnProcessKilledCallback + ): void + /** [Worker.postMessage(Object message)](https://developers.weixin.qq.com/miniprogram/dev/api/worker/Worker.postMessage.html) +* +* 在插件中使用:不支持 +* +* 向主线程/Worker 线程发送的消息。 +* +* **示例代码** +* +* worker 线程中 +* ```js +worker.postMessage({ + msg: 'hello from worker' +}) +``` +* +* 主线程中 +* ```js +const worker = wx.createWorker('workers/request/index.js') + +worker.postMessage({ + msg: 'hello from main' +}) +``` +* +* **提醒** +* +* 在基础库版本2.20.2之前,postMessage仅支持传递可序列化的key-value对象。 +* 在基础库2.20.2之后,postMessage支持传递任意类型的数据。 */ + postMessage( + /** 需要发送的消息。 */ + message: IAnyObject + ): void + /** [Worker.terminate()](https://developers.weixin.qq.com/miniprogram/dev/api/worker/Worker.terminate.html) + * + * 在插件中使用:不支持 + * + * 结束当前 Worker 线程。仅限在主线程 worker 对象上调用。 */ + terminate(): void + /** [Worker.testOnProcessKilled()](https://developers.weixin.qq.com/miniprogram/dev/api/worker/Worker.testOnProcessKilled.html) +* +* 需要基础库: `2.27.1` +* +* 在插件中使用:不支持 +* +* 用于模拟 iOS ExperimentalWorker 线程被系统回收事件,以便于调试。接口仅在 worker 线程内可用。参考 [Worker.onProcessKilled](https://developers.weixin.qq.com/miniprogram/dev/api/worker/Worker.onProcessKilled.html) +* +* **示例代码** +* +* ```js +// game.js +const worker = wx.createWorker('workers/index.js', { + useExperimentalWorker: true +}) + +// 监听 ExperimentalWorker 被系统回收事件 +worker.onProcessKilled(function () { + console.log('worker has been killed') + // 重新创建一个worker + // wx.createWorker() +}) +``` +* +* ```js +// workers/index.js +setTimeout(() => { + // 模拟 ExperimentalWorker 线程被系统回收事件 + worker.testOnProcessKilled() +}, 2000) +``` */ + testOnProcessKilled(): void } - interface GetSavedFileInfoSuccessCallbackResult { - /** 文件保存时的时间戳,从1970/01/01 08:00:00 到该时刻的秒数 */ - createTime: number - /** 文件大小,单位 B */ - size: number - errMsg: string + /** worker内的环境变量 */ + interface WorkerEnv { + /** 文件系统中的用户目录路径 (本地路径) */ + USER_DATA_PATH: string } - interface GetScaleOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetScaleCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: GetScaleFailCallback - /** 接口调用成功的回调函数 */ - success?: GetScaleSuccessCallback + interface WorkerOnMessageListenerResult { + /** 主线程/Worker 线程向当前线程发送的消息 */ + message: IAnyObject } - interface GetScaleSuccessCallbackResult { - /** 缩放值 */ - scale: number - errMsg: string + /** Easing 模块实现了常见的动画缓动函数(动画效果参考 https://easings.net/ ),可从 [wx.worklet](https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/wx.worklet.html) 对象中读取。 +* +* **** +* +* ## 示例代码 +* +* [在微信开发者工具中查看示例](https://developers.weixin.qq.com/s/f94TCOmg7JFH) +* +* ### 预置动画函数 +* +* * [Easing.bounce](#Easing.bounce) 反弹动画 +* * [Easing.ease](#Easing.ease) 惯性动画 +* * [Easing.elastic](#Easing.elastic) 弹性动画 +* +* ### 标准缓动函数 +* +* * [Easing.linear](#Easing.linear) 线性 +* * [Easing.quad](#Easing.quad) 二次方 +* * [Easing.cubic](#Easing.cubic) 三次方 +* * [Easing.poly](#Easing.poly) 实现其它幂函数 +* +* ### 其它数学函数 +* +* * [Easing.bezier](#Easing.bezier) 三次贝塞尔曲线 +* * [Easing.circle](#Easing.circle) 圆形曲线 +* * [Easing.sin](#Easing.sin) 正弦函数 +* * [Easing.exp](#Easing.exp) 指数函数 +* +* ### 缓动方式 +* +* 以上效果均有三种缓动方式 +* +* * [Easing.in](#in) 正向执行缓动函数 +* * [Easing.out](#out) 反向执行缓动函数 +* * [Easing.inOut](#inout) 前半程正向,后半程反向 +* 以 `sin` 函数为例,其中 `Easing.in(Easing.sin)` 和直接使用 `Easing.sin` 效果相同。 +* +* 1. `Easing.in(Easing.sin)` 动画效果参考 https://easings.net/#easeInSine +* 2. `Easing.out(Easing.sin)` 动画效果参考 https://easings.net/#easeOutSine +* 3. `Easing.inOut(Easing.sin)` 动画效果参考 https://easings.net/#easeInOutSine +* +* ### Easing.bounce +* +* 简单的反弹效果,[动画效果参考](https://easings.net/#easeInBounce) +* +* ```js +Easing.bounce(t) +``` +* +* ### Easing.ease +* +* 简单的惯性动画,[动画效果参考](https://cubic-bezier.com/#.42,0,1,1) +* +* ```js +Easing.ease(t) +``` +* +* ### Easing.elastic +* +* 简单的弹性动画,类似弹簧来回摆动,高阶函数。默认弹性为 1,会稍微超出一次。弹性为 0 时 不会过冲。[动画效果参考](https://easings.net/#easeInElastic) +* +* ```js +Easing.elastic(bounciness = 1) +``` +* +* ### Easing.linear +* +* 线性函数,f(t) = t,[动画效果参考](https://cubic-bezier.com/#0,0,1,1) +* +* ```js +Easing.linear(t) +``` +* ### Easing.quad +* +* 二次方函数,f(t) = t * t,[动画效果参考](https://easings.net/#easeInQuad) +* +* ```js +Easing.quad(t) +``` +* +* ### Easing.cubic +* +* 立方函数,f(t) = t * t * t,[动画效果参考](https://easings.net/#easeInCubic) +* +* ```js +Easing.cubic(t) +``` +* +* ### Easing.poly +* +* 高阶函数,返回幂函数 +* +* poly(4): [动画效果参考](https://easings.net/#easeInQuart) +* +* poly(5): [动画效果参考](https://easings.net/#easeInQuint) +* +* ```js +Easing.poly(n) +``` +* +* ### Easing.bezier +* +* 三次贝塞尔曲线,效果同 css `transition-timing-function` +* +* 调试参数可借助 [可视化工具](https://cubic-bezier.com/) +* +* ```js +Easing.bezier(x1, y1, x2, y2) +``` +* +* ### Easing.circle +* +* 圆形曲线,[动画效果参考](https://easings.net/#easeInCirc) +* +* ```js +Easing.circle(t) +``` +* +* ### Easing.sin +* +* 正弦函数,[动画效果参考](https://easings.net/#easeInSine) +* +* ```js +Easing.sin(t) +``` +* +* ### Easing.exp +* +* 指数函数,[动画效果参考](https://easings.net/#easeInExpo) +* +* ```js +Easing.exp(t) +``` +* +* ### Easing.in +* +* 正向运行 `easing function`,高阶函数。 +* +* ```js +Easing.in(easing) +``` +* +* ### Easing.out +* +* 反向运行 `easing function`,高阶函数。 +* +* ```js +Easing.out(easing) +``` +* +* ### Easing.inOut +* +* 前半程正向,后半程反向,高阶函数。 +* +* ```js +Easing.inOut(easing) +``` */ + interface WorkletEasing {} + /** 需要基础库: `3.3.0` + * + * `ScrollView` 实例,可在 `worklet` 函数内操作 `scroll-view` 组件。 */ + interface WorkletScrollViewContext {} + interface WorkletScrollViewContextScrollToOption { + /** 是否启用滚动动画 */ + animated?: boolean + /** 滚动动画时长 */ + duration?: number + /** 动画曲线 */ + easingFunction?: string + /** 左边界距离 */ + left?: number + /** 顶部距离 */ + top?: number } - interface GetScreenBrightnessOption { + interface WriteBLECharacteristicValueOption { + /** 蓝牙特征的 UUID */ + characteristicId: string + /** 蓝牙设备 id */ + deviceId: string + /** 蓝牙特征对应服务的 UUID */ + serviceId: string + /** 蓝牙设备特征对应的二进制值 */ + value: ArrayBuffer /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetScreenBrightnessCompleteCallback + complete?: WriteBLECharacteristicValueCompleteCallback /** 接口调用失败的回调函数 */ - fail?: GetScreenBrightnessFailCallback + fail?: WriteBLECharacteristicValueFailCallback /** 接口调用成功的回调函数 */ - success?: GetScreenBrightnessSuccessCallback - } - interface GetScreenBrightnessSuccessCallbackOption { - /** 屏幕亮度值,范围 0 ~ 1,0 最暗,1 最亮 */ - value: number + success?: WriteBLECharacteristicValueSuccessCallback + /** 蓝牙特征值的写模式设置,有两种模式,iOS 优先 write,安卓优先 writeNoResponse 。(基础库 2.22.0 开始支持) + * + * 可选值: + * - 'write': 强制回复写,不支持时报错; + * - 'writeNoResponse': 强制无回复写,不支持时报错; */ + writeType?: 'write' | 'writeNoResponse' } - interface GetSelectedTextRangeOption { + interface WriteCharacteristicValueObject { + /** 蓝牙特征的 UUID */ + characteristicId: string + /** 是否需要通知主机 value 已更新 */ + needNotify: boolean + /** 蓝牙特征对应服务的 UUID */ + serviceId: string + /** characteristic 对应的二进制值 */ + value: ArrayBuffer + /** 可选,处理回包时使用 */ + callbackId?: number /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetSelectedTextRangeCompleteCallback + complete?: WriteCharacteristicValueCompleteCallback /** 接口调用失败的回调函数 */ - fail?: GetSelectedTextRangeFailCallback + fail?: WriteCharacteristicValueFailCallback /** 接口调用成功的回调函数 */ - success?: GetSelectedTextRangeSuccessCallback + success?: WriteCharacteristicValueSuccessCallback } - interface GetSelectedTextRangeSuccessCallbackResult { - /** 输入框光标结束位置 */ - end: number - /** 输入框光标起始位置 */ - start: number - errMsg: string - } - interface GetSettingOption { + interface WriteFileOption { + /** 要写入的文本或二进制数据 */ + data: string | ArrayBuffer + /** 要写入的文件路径 (本地路径) */ + filePath: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetSettingCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: GetSettingFailCallback - /** 接口调用成功的回调函数 */ - success?: GetSettingSuccessCallback - /** 是否同时获取用户订阅消息的订阅状态,默认不获取 - * - * 最低基础库: `2.10.0` */ - withSubscriptions?: boolean - } - interface GetSettingSuccessCallbackResult { - /** [AuthSetting](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/setting/AuthSetting.html) - * - * 用户授权结果 */ - authSetting: AuthSetting - /** 用户订阅消息(包括一次性订阅消息和永久订阅消息)的订阅状态,需要接口参数withSubscriptions值为true时才会返回。subscriptionsSetting对象的键为**一次性订阅消息的模板id**或**永久订阅消息的类型**,值为'accept'、'reject'、'ban'中的其中一种,'accept'表示用户同意订阅该条订阅消息,'reject'表示用户拒绝订阅该订阅消息,'ban'表示已被后台封禁。一次性订阅消息使用方法详见 [wx.requestSubscribeMessage](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/subscribe-message/wx.requestSubscribeMessage.html),永久订阅消息(仅小游戏可用)使用方法详见[wx.requestSubscribeSystemMessage](#) + complete?: WriteFileCompleteCallback + /** 指定写入文件的字符编码 * - * 最低基础库: `2.10.0` */ - subscriptionsSetting: IAnyObject - errMsg: string - } - interface GetShareInfoOption { - /** shareTicket */ - shareTicket: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetShareInfoCompleteCallback + * 可选值: + * - 'ascii': ; + * - 'base64': (注意,选择 base64 编码,data 只需要传 base64 内容本身,不要传 Data URI 前缀,否则会报 fail base64 encode error 错误。例如,传 aGVsbG8= 而不是传 data:image/png;base64,aGVsbG8= ); + * - 'binary': ; + * - 'hex': ; + * - 'ucs2': 以小端序读取; + * - 'ucs-2': 以小端序读取; + * - 'utf16le': 以小端序读取; + * - 'utf-16le': 以小端序读取; + * - 'utf-8': ; + * - 'utf8': ; + * - 'latin1': ; */ + encoding?: + | 'ascii' + | 'base64' + | 'binary' + | 'hex' + | 'ucs2' + | 'ucs-2' + | 'utf16le' + | 'utf-16le' + | 'utf-8' + | 'utf8' + | 'latin1' /** 接口调用失败的回调函数 */ - fail?: GetShareInfoFailCallback + fail?: WriteFileFailCallback /** 接口调用成功的回调函数 */ - success?: GetShareInfoSuccessCallback - /** 超时时间,单位 ms - * - * 最低基础库: `1.9.90` */ - timeout?: number - } - interface GetShareInfoSuccessCallbackResult { - /** 敏感数据对应的云 ID,开通[云开发](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/basis/getting-started.html)的小程序才会返回,可通过云调用直接获取开放数据,详细见[云调用直接获取开放数据](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html#method-cloud) - * - * 最低基础库: `2.7.0` */ - cloudID: string - /** 包括敏感数据在内的完整转发信息的加密数据,详细见[加密数据解密算法](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html) */ - encryptedData: string - /** 错误信息 */ - errMsg: string - /** 加密算法的初始向量,详细见[加密数据解密算法](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html) */ - iv: string + success?: WriteFileSuccessCallback } - interface GetSkewOption { + interface WriteNdefMessageOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetSkewCompleteCallback + complete?: WriteNdefMessageCompleteCallback /** 接口调用失败的回调函数 */ - fail?: GetSkewFailCallback + fail?: WriteNdefMessageFailCallback + /** 二进制对象数组, 需要指明 id, type 以及 payload (均为 ArrayBuffer 类型) */ + records?: any[] /** 接口调用成功的回调函数 */ - success?: GetSkewSuccessCallback - } - interface GetSkewSuccessCallbackResult { - /** 倾斜角 */ - skew: number - errMsg: string - } - interface GetStorageInfoOption { + success?: WriteNdefMessageSuccessCallback + /** text 数组 */ + texts?: any[] + /** uri 数组 */ + uris?: any[] + } + interface WriteOption { + /** 写入的内容,类型为 String 或 ArrayBuffer */ + data: string | ArrayBuffer + /** 文件描述符。fd 通过 [FileSystemManager.open](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.open.html) 或 [FileSystemManager.openSync](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.openSync.html) 接口获得 */ + fd: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetStorageInfoCompleteCallback + complete?: WriteCompleteCallback + /** 只在 data 类型是 String 时有效,指定写入文件的字符编码,默认为 utf8 + * + * 可选值: + * - 'ascii': ; + * - 'base64': ; + * - 'binary': ; + * - 'hex': ; + * - 'ucs2': 以小端序读取; + * - 'ucs-2': 以小端序读取; + * - 'utf16le': 以小端序读取; + * - 'utf-16le': 以小端序读取; + * - 'utf-8': ; + * - 'utf8': ; + * - 'latin1': ; */ + encoding?: + | 'ascii' + | 'base64' + | 'binary' + | 'hex' + | 'ucs2' + | 'ucs-2' + | 'utf16le' + | 'utf-16le' + | 'utf-8' + | 'utf8' + | 'latin1' /** 接口调用失败的回调函数 */ - fail?: GetStorageInfoFailCallback + fail?: WriteFailCallback + /** 只在 data 类型是 ArrayBuffer 时有效,指定要写入的字节数,默认为 ArrayBuffer 从0开始偏移 offset 个字节后剩余的字节数 */ + length?: number + /** 只在 data 类型是 ArrayBuffer 时有效,决定 ArrayBuffer 中要被写入的部位,即 ArrayBuffer 中的索引,默认0 */ + offset?: number + /** 指定文件开头的偏移量,即数据要被写入的位置。当 position 不传或者传入非 Number 类型的值时,数据会被写入当前指针所在位置。 */ + position?: number /** 接口调用成功的回调函数 */ - success?: GetStorageInfoSuccessCallback + success?: WriteSuccessCallback } - interface GetStorageInfoSuccessCallbackOption { - /** 当前占用的空间大小, 单位 KB */ - currentSize: number - /** 当前 storage 中所有的 key */ - keys: string[] - /** 限制的空间大小,单位 KB */ - limitSize: number + /** 文件写入结果。 通过 [FileSystemManager.writeSync](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.writeSync.html) 接口返回 */ + interface WriteResult { + /** 实际被写入到文件中的字节数(注意,被写入的字节数不一定与被写入的字符串字符数相同) */ + bytesWritten: number } - interface GetStorageInfoSyncOption { - /** 当前占用的空间大小, 单位 KB */ - currentSize: number - /** 当前 storage 中所有的 key */ - keys: string[] - /** 限制的空间大小,单位 KB */ - limitSize: number + interface WriteSuccessCallbackResult { + /** 实际被写入到文件中的字节数(注意,被写入的字节数不一定与被写入的字符串字符数相同) */ + bytesWritten: number + errMsg: string } - interface GetStorageOption { - /** 本地缓存中指定的 key */ - key: string + interface WriteSyncOption { + /** 写入的内容,类型为 String 或 ArrayBuffer */ + data: string | ArrayBuffer + /** 文件描述符。fd 通过 [FileSystemManager.open](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.open.html) 或 [FileSystemManager.openSync](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.openSync.html) 接口获得 */ + fd: string + /** 只在 data 类型是 String 时有效,指定写入文件的字符编码,默认为 utf8 + * + * 可选值: + * - 'ascii': ; + * - 'base64': ; + * - 'binary': ; + * - 'hex': ; + * - 'ucs2': 以小端序读取; + * - 'ucs-2': 以小端序读取; + * - 'utf16le': 以小端序读取; + * - 'utf-16le': 以小端序读取; + * - 'utf-8': ; + * - 'utf8': ; + * - 'latin1': ; */ + encoding?: + | 'ascii' + | 'base64' + | 'binary' + | 'hex' + | 'ucs2' + | 'ucs-2' + | 'utf16le' + | 'utf-16le' + | 'utf-8' + | 'utf8' + | 'latin1' + /** 只在 data 类型是 ArrayBuffer 时有效,指定要写入的字节数,默认为 ArrayBuffer 从0开始偏移 offset 个字节后剩余的字节数 */ + length?: number + /** 只在 data 类型是 ArrayBuffer 时有效,决定 ArrayBuffer 中要被写入的部位,即 ArrayBuffer 中的索引,默认0 */ + offset?: number + /** 指定文件开头的偏移量,即数据要被写入的位置。当 position 不传或者传入非 Number 类型的值时,数据会被写入当前指针所在位置。 */ + position?: number + } + interface WxStartRecordOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetStorageCompleteCallback + complete?: StartRecordCompleteCallback /** 接口调用失败的回调函数 */ - fail?: GetStorageFailCallback + fail?: StartRecordFailCallback /** 接口调用成功的回调函数 */ - success?: GetStorageSuccessCallback - } - interface GetStorageSuccessCallbackResult { - /** key对应的内容 */ - data: any - errMsg: string + success?: WxStartRecordSuccessCallback } - interface GetSystemInfoOption { + interface WxStopRecordOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetSystemInfoCompleteCallback + complete?: StopRecordCompleteCallback /** 接口调用失败的回调函数 */ - fail?: GetSystemInfoFailCallback + fail?: StopRecordFailCallback /** 接口调用成功的回调函数 */ - success?: GetSystemInfoSuccessCallback + success?: WxStopRecordSuccessCallback + } + /** 运动数据列表 */ + interface WxaSportRecord { + /** 消耗卡路里 */ + calorie: number + /** 运动距离 */ + distance: number + /** 运动时长 */ + time: number + /** 运动项目id */ + typeId: number + } + /** 帧纹理对象 */ + interface YUVTextureRes { + /** UV 分量纹理 */ + uvTexture: WebGLTexture + /** Y 分量纹理 */ + yTexture: WebGLTexture + } + /** 文件路径 */ + interface ZipFileItem { + /** 文件内容 */ + data: string | ArrayBuffer + /** 错误信息 */ + errMsg: string } - interface GetSystemInfoSuccessCallbackResult { - /** 客户端基础库版本 + interface Animation { + /** [Object Animation.export()](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.export.html) * - * 最低基础库: `1.1.0` */ - SDKVersion: string - /** 允许微信使用相册的开关(仅 iOS 有效) + * 在插件中使用:支持 * - * 最低基础库: `2.6.0` */ - albumAuthorized: boolean - /** 设备性能等级(仅Android小游戏)。取值为:-2 或 0(该设备无法运行小游戏),-1(性能未知),>=1(设备性能值,该值越高,设备性能越好,目前最高不到50) + * 导出动画队列。**export 方法每次调用后会清掉之前的动画操作。** */ + export(): AnimationExportResult + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.backgroundColor(string value)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.backgroundColor.html) * - * 最低基础库: `1.8.0` */ - benchmarkLevel: number - /** 蓝牙的系统开关 + * 在插件中使用:支持 * - * 最低基础库: `2.6.0` */ - bluetoothEnabled: boolean - /** 设备品牌 + * 设置背景色 */ + backgroundColor( + /** 颜色值 */ + value: string + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.bottom(number|string value)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.bottom.html) * - * 最低基础库: `1.5.0` */ - brand: string - /** 允许微信使用摄像头的开关 + * 在插件中使用:支持 * - * 最低基础库: `2.6.0` */ - cameraAuthorized: boolean - /** 用户字体大小(单位px)。以微信客户端「我-设置-通用-字体大小」中的设置为准 + * 设置 bottom 值 */ + bottom( + /** 长度值,如果传入 number 则默认使用 px,可传入其他自定义单位的长度值 */ + value: number | string + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.height(number|string value)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.height.html) * - * 最低基础库: `1.5.0` */ - fontSizeSetting: number - /** 微信设置的语言 */ - language: string - /** 允许微信使用定位的开关 + * 在插件中使用:支持 * - * 最低基础库: `2.6.0` */ - locationAuthorized: boolean - /** 地理位置的系统开关 + * 设置高度 */ + height( + /** 长度值,如果传入 number 则默认使用 px,可传入其他自定义单位的长度值 */ + value: number | string + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.left(number|string value)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.left.html) * - * 最低基础库: `2.6.0` */ - locationEnabled: boolean - /** 允许微信使用麦克风的开关 + * 在插件中使用:支持 * - * 最低基础库: `2.6.0` */ - microphoneAuthorized: boolean - /** 设备型号 */ - model: string - /** 允许微信通知带有提醒的开关(仅 iOS 有效) + * 设置 left 值 */ + left( + /** 长度值,如果传入 number 则默认使用 px,可传入其他自定义单位的长度值 */ + value: number | string + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.matrix()](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.matrix.html) * - * 最低基础库: `2.6.0` */ - notificationAlertAuthorized: boolean - /** 允许微信通知的开关 + * 在插件中使用:支持 * - * 最低基础库: `2.6.0` */ - notificationAuthorized: boolean - /** 允许微信通知带有标记的开关(仅 iOS 有效) + * 同 [transform-function matrix](https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix) */ + matrix(): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.matrix3d()](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.matrix3d.html) * - * 最低基础库: `2.6.0` */ - notificationBadgeAuthorized: boolean - /** 允许微信通知带有声音的开关(仅 iOS 有效) + * 在插件中使用:支持 * - * 最低基础库: `2.6.0` */ - notificationSoundAuthorized: boolean - /** 设备像素比 */ - pixelRatio: number - /** 客户端平台 */ - platform: string - /** 在竖屏正方向下的安全区域 + * 同 [transform-function matrix3d](https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d) */ + matrix3d(): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.opacity(number value)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.opacity.html) * - * 最低基础库: `2.7.0` */ - safeArea: SafeAreaResult - /** 屏幕高度,单位px + * 在插件中使用:支持 * - * 最低基础库: `1.1.0` */ - screenHeight: number - /** 屏幕宽度,单位px + * 设置透明度 */ + opacity( + /** 透明度,范围 0-1 */ + value: number + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.right(number|string value)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.right.html) * - * 最低基础库: `1.1.0` */ - screenWidth: number - /** 状态栏的高度,单位px + * 在插件中使用:支持 * - * 最低基础库: `1.9.0` */ - statusBarHeight: number - /** 操作系统及版本 */ - system: string - /** 微信版本号 */ - version: string - /** Wi-Fi 的系统开关 + * 设置 right 值 */ + right( + /** 长度值,如果传入 number 则默认使用 px,可传入其他自定义单位的长度值 */ + value: number | string + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.rotate(number angle)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.rotate.html) * - * 最低基础库: `2.6.0` */ - wifiEnabled: boolean - /** 可使用窗口高度,单位px */ - windowHeight: number - /** 可使用窗口宽度,单位px */ - windowWidth: number - errMsg: string - } - interface GetSystemInfoSyncResult { - /** 客户端基础库版本 + * 在插件中使用:支持 * - * 最低基础库: `1.1.0` */ - SDKVersion: string - /** 允许微信使用相册的开关(仅 iOS 有效) + * 从原点顺时针旋转一个角度 */ + rotate( + /** 旋转的角度。范围 [-180, 180] */ + angle: number + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.rotate3d(number x, number y, number z, number angle)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.rotate3d.html) + * + * 在插件中使用:支持 + * + * 从 固定 轴顺时针旋转一个角度 */ + rotate3d( + /** 旋转轴的 x 坐标 */ + x: number, + /** 旋转轴的 y 坐标 */ + y: number, + /** 旋转轴的 z 坐标 */ + z: number, + /** 旋转的角度。范围 [-180, 180] */ + angle: number + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.rotateX(number angle)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.rotateX.html) + * + * 在插件中使用:支持 + * + * 从 X 轴顺时针旋转一个角度 */ + rotateX( + /** 旋转的角度。范围 [-180, 180] */ + angle: number + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.rotateY(number angle)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.rotateY.html) + * + * 在插件中使用:支持 + * + * 从 Y 轴顺时针旋转一个角度 */ + rotateY( + /** 旋转的角度。范围 [-180, 180] */ + angle: number + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.rotateZ(number angle)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.rotateZ.html) + * + * 在插件中使用:支持 + * + * 从 Z 轴顺时针旋转一个角度 */ + rotateZ( + /** 旋转的角度。范围 [-180, 180] */ + angle: number + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.scale(number sx, number sy)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.scale.html) + * + * 在插件中使用:支持 + * + * 缩放 */ + scale( + /** 当仅有 sx 参数时,表示在 X 轴、Y 轴同时缩放sx倍数 */ + sx: number, + /** 在 Y 轴缩放 sy 倍数 */ + sy?: number + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.scale3d(number sx, number sy, number sz)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.scale3d.html) + * + * 在插件中使用:支持 + * + * 缩放 */ + scale3d( + /** x 轴的缩放倍数 */ + sx: number, + /** y 轴的缩放倍数 */ + sy: number, + /** z 轴的缩放倍数 */ + sz: number + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.scaleX(number scale)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.scaleX.html) + * + * 在插件中使用:支持 + * + * 缩放 X 轴 */ + scaleX( + /** X 轴的缩放倍数 */ + scale: number + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.scaleY(number scale)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.scaleY.html) + * + * 在插件中使用:支持 + * + * 缩放 Y 轴 */ + scaleY( + /** Y 轴的缩放倍数 */ + scale: number + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.scaleZ(number scale)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.scaleZ.html) * - * 最低基础库: `2.6.0` */ - albumAuthorized: boolean - /** 设备性能等级(仅Android小游戏)。取值为:-2 或 0(该设备无法运行小游戏),-1(性能未知),>=1(设备性能值,该值越高,设备性能越好,目前最高不到50) + * 在插件中使用:支持 * - * 最低基础库: `1.8.0` */ - benchmarkLevel: number - /** 蓝牙的系统开关 + * 缩放 Z 轴 */ + scaleZ( + /** Z 轴的缩放倍数 */ + scale: number + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.skew(number ax, number ay)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.skew.html) * - * 最低基础库: `2.6.0` */ - bluetoothEnabled: boolean - /** 设备品牌 + * 在插件中使用:支持 * - * 最低基础库: `1.5.0` */ - brand: string - /** 允许微信使用摄像头的开关 + * 对 X、Y 轴坐标进行倾斜 */ + skew( + /** 对 X 轴坐标倾斜的角度,范围 [-180, 180] */ + ax: number, + /** 对 Y 轴坐标倾斜的角度,范围 [-180, 180] */ + ay: number + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.skewX(number angle)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.skewX.html) * - * 最低基础库: `2.6.0` */ - cameraAuthorized: boolean - /** 用户字体大小(单位px)。以微信客户端「我-设置-通用-字体大小」中的设置为准 + * 在插件中使用:支持 * - * 最低基础库: `1.5.0` */ - fontSizeSetting: number - /** 微信设置的语言 */ - language: string - /** 允许微信使用定位的开关 + * 对 X 轴坐标进行倾斜 */ + skewX( + /** 倾斜的角度,范围 [-180, 180] */ + angle: number + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.skewY(number angle)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.skewY.html) * - * 最低基础库: `2.6.0` */ - locationAuthorized: boolean - /** 地理位置的系统开关 + * 在插件中使用:支持 * - * 最低基础库: `2.6.0` */ - locationEnabled: boolean - /** 允许微信使用麦克风的开关 + * 对 Y 轴坐标进行倾斜 */ + skewY( + /** 倾斜的角度,范围 [-180, 180] */ + angle: number + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.step(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.step.html) * - * 最低基础库: `2.6.0` */ - microphoneAuthorized: boolean - /** 设备型号 */ - model: string - /** 允许微信通知带有提醒的开关(仅 iOS 有效) + * 在插件中使用:支持 * - * 最低基础库: `2.6.0` */ - notificationAlertAuthorized: boolean - /** 允许微信通知的开关 + * 表示一组动画完成。可以在一组动画中调用任意多个动画方法,一组动画中的所有动画会同时开始,一组动画完成后才会进行下一组动画。 */ + step(option?: StepOption): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.top(number|string value)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.top.html) * - * 最低基础库: `2.6.0` */ - notificationAuthorized: boolean - /** 允许微信通知带有标记的开关(仅 iOS 有效) + * 在插件中使用:支持 * - * 最低基础库: `2.6.0` */ - notificationBadgeAuthorized: boolean - /** 允许微信通知带有声音的开关(仅 iOS 有效) + * 设置 top 值 */ + top( + /** 长度值,如果传入 number 则默认使用 px,可传入其他自定义单位的长度值 */ + value: number | string + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.translate(number tx, number ty)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.translate.html) * - * 最低基础库: `2.6.0` */ - notificationSoundAuthorized: boolean - /** 设备像素比 */ - pixelRatio: number - /** 客户端平台 */ - platform: string - /** 在竖屏正方向下的安全区域 + * 在插件中使用:支持 * - * 最低基础库: `2.7.0` */ - safeArea: GetSystemInfoSyncResultSafeAreaResult - /** 屏幕高度,单位px + * 平移变换 */ + translate( + /** 当仅有该参数时表示在 X 轴偏移 tx,单位 px */ + tx?: number, + /** 在 Y 轴平移的距离,单位为 px */ + ty?: number + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.translate3d(number tx, number ty, number tz)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.translate3d.html) * - * 最低基础库: `1.1.0` */ - screenHeight: number - /** 屏幕宽度,单位px + * 在插件中使用:支持 * - * 最低基础库: `1.1.0` */ - screenWidth: number - /** 状态栏的高度,单位px + * 对 xyz 坐标进行平移变换 */ + translate3d( + /** 在 X 轴平移的距离,单位为 px */ + tx?: number, + /** 在 Y 轴平移的距离,单位为 px */ + ty?: number, + /** 在 Z 轴平移的距离,单位为 px */ + tz?: number + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.translateX(number translation)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.translateX.html) * - * 最低基础库: `1.9.0` */ - statusBarHeight: number - /** 操作系统及版本 */ - system: string - /** 微信版本号 */ - version: string - /** Wi-Fi 的系统开关 + * 在插件中使用:支持 * - * 最低基础库: `2.6.0` */ - wifiEnabled: boolean - /** 可使用窗口高度,单位px */ - windowHeight: number - /** 可使用窗口宽度,单位px */ - windowWidth: number - } - /** 在竖屏正方向下的安全区域 - * - * 最低基础库: `2.7.0` */ - interface GetSystemInfoSyncResultSafeAreaResult { - /** 安全区域右下角纵坐标 */ - bottom: number - /** 安全区域的高度,单位逻辑像素 */ - height: number - /** 安全区域左上角横坐标 */ - left: number - /** 安全区域右下角横坐标 */ - right: number - /** 安全区域左上角纵坐标 */ - top: number - /** 安全区域的宽度,单位逻辑像素 */ - width: number - } - interface GetUserInfoOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetUserInfoCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: GetUserInfoFailCallback - /** 显示用户信息的语言 + * 对 X 轴平移 */ + translateX( + /** 在 X 轴平移的距离,单位为 px */ + translation: number + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.translateY(number translation)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.translateY.html) * - * 可选值: - * - 'en': 英文; - * - 'zh_CN': 简体中文; - * - 'zh_TW': 繁体中文; */ - lang?: 'en' | 'zh_CN' | 'zh_TW' - /** 接口调用成功的回调函数 */ - success?: GetUserInfoSuccessCallback - /** 是否带上登录态信息。当 withCredentials 为 true 时,要求此前有调用过 wx.login 且登录态尚未过期,此时返回的数据会包含 encryptedData, iv 等敏感信息;当 withCredentials 为 false 时,不要求有登录态,返回的数据不包含 encryptedData, iv 等敏感信息。 */ - withCredentials?: boolean - } - interface GetUserInfoSuccessCallbackResult { - /** 敏感数据对应的云 ID,开通[云开发](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/basis/getting-started.html)的小程序才会返回,可通过云调用直接获取开放数据,详细见[云调用直接获取开放数据](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html#method-cloud) + * 在插件中使用:支持 * - * 最低基础库: `2.7.0` */ - cloudID: string - /** 包括敏感数据在内的完整用户信息的加密数据,详见 [用户数据的签名验证和加解密]((signature#加密数据解密算法)) */ - encryptedData: string - /** 加密算法的初始向量,详见 [用户数据的签名验证和加解密]((signature#加密数据解密算法)) */ - iv: string - /** 不包括敏感信息的原始数据字符串,用于计算签名 */ - rawData: string - /** 使用 sha1( rawData + sessionkey ) 得到字符串,用于校验用户信息,详见 [用户数据的签名验证和加解密](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html) */ - signature: string - /** [UserInfo](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/UserInfo.html) + * 对 Y 轴平移 */ + translateY( + /** 在 Y 轴平移的距离,单位为 px */ + translation: number + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.translateZ(number translation)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.translateZ.html) * - * 用户信息对象,不包含 openid 等敏感信息 */ - userInfo: UserInfo - errMsg: string - } - interface GetWeRunDataOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetWeRunDataCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: GetWeRunDataFailCallback - /** 接口调用成功的回调函数 */ - success?: GetWeRunDataSuccessCallback - } - interface GetWeRunDataSuccessCallbackResult { - /** 敏感数据对应的云 ID,开通云开发的小程序才会返回,可通过云调用直接获取开放数据,详细见[云调用直接获取开放数据](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html#method-cloud) + * 在插件中使用:支持 * - * 最低基础库: `2.7.0` */ - cloudID: string - /** 包括敏感数据在内的完整用户信息的加密数据,详细见[加密数据解密算法](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html)。解密后得到的数据结构见后文 */ - encryptedData: string - /** 加密算法的初始向量,详细见[加密数据解密算法](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html) */ - iv: string - errMsg: string - } - interface GetWifiListOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: GetWifiListCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: GetWifiListFailCallback - /** 接口调用成功的回调函数 */ - success?: GetWifiListSuccessCallback - } - interface HideHomeButtonOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: HideHomeButtonCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: HideHomeButtonFailCallback - /** 接口调用成功的回调函数 */ - success?: HideHomeButtonSuccessCallback - } - interface HideKeyboardOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: HideKeyboardCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: HideKeyboardFailCallback - /** 接口调用成功的回调函数 */ - success?: HideKeyboardSuccessCallback - } - interface HideLoadingOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: HideLoadingCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: HideLoadingFailCallback - /** 接口调用成功的回调函数 */ - success?: HideLoadingSuccessCallback - } - interface HideNavigationBarLoadingOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: HideNavigationBarLoadingCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: HideNavigationBarLoadingFailCallback - /** 接口调用成功的回调函数 */ - success?: HideNavigationBarLoadingSuccessCallback - } - interface HideShareMenuOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: HideShareMenuCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: HideShareMenuFailCallback - /** 接口调用成功的回调函数 */ - success?: HideShareMenuSuccessCallback - } - interface HideTabBarOption { - /** 是否需要动画效果 */ - animation?: boolean - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: HideTabBarCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: HideTabBarFailCallback - /** 接口调用成功的回调函数 */ - success?: HideTabBarSuccessCallback - } - interface HideTabBarRedDotOption { - /** tabBar 的哪一项,从左边算起 */ - index: number - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: HideTabBarRedDotCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: HideTabBarRedDotFailCallback - /** 接口调用成功的回调函数 */ - success?: HideTabBarRedDotSuccessCallback - } - interface HideToastOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: HideToastCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: HideToastFailCallback - /** 接口调用成功的回调函数 */ - success?: HideToastSuccessCallback - } - interface IBeaconInfo { - /** iBeacon 设备的距离 */ - accuracy: number - /** iBeacon 设备的主 id */ - major: string - /** iBeacon 设备的次 id */ - minor: string - /** 表示设备距离的枚举值 */ - proximity: number - /** 表示设备的信号强度 */ - rssi: number - /** iBeacon 设备广播的 uuid */ - uuid: string - } - /** 图片对象 - * - * 最低基础库: `2.7.0` */ - interface Image { - /** 图片的真实高度 */ - height: number - /** 图片加载发生错误后触发的回调函数 */ - onerror: (...args: any[]) => any - /** 图片加载完成后触发的回调函数 */ - onload: (...args: any[]) => any - /** 图片的 URL */ - src: string - /** 图片的真实宽度 */ - width: number - } - /** ImageData 对象 - * - * 最低基础库: `2.9.0` */ - interface ImageData { - /** 一维数组,包含以 RGBA 顺序的数据,数据使用 0 至 255(包含)的整数表示 */ - data: Uint8ClampedArray - /** 使用像素描述 ImageData 的实际高度 */ - height: number - /** 使用像素描述 ImageData 的实际宽度 */ - width: number - } - /** 图片的本地临时文件列表 - * - * 最低基础库: `1.2.0` */ - interface ImageFile { - /** 本地临时文件路径 (本地路径) */ - path: string - /** 本地临时文件大小,单位 B */ - size: number + * 对 Z 轴平移 */ + translateZ( + /** 在 Z 轴平移的距离,单位为 px */ + translation: number + ): Animation + /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.width(number|string value)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.width.html) + * + * 在插件中使用:支持 + * + * 设置宽度 */ + width( + /** 长度值,如果传入 number 则默认使用 px,可传入其他自定义单位的长度值 */ + value: number | string + ): Animation } - interface IncludePointsOption { - /** 要显示在可视区域内的坐标点列表 */ - points: MapPostion[] - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: IncludePointsCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: IncludePointsFailCallback - /** 坐标点形成的矩形边缘到地图边缘的距离,单位像素。格式为[上,右,下,左],安卓上只能识别数组第一项,上下左右的padding一致。开发者工具暂不支持padding参数。 */ - padding?: number[] - /** 接口调用成功的回调函数 */ - success?: IncludePointsSuccessCallback + interface AudioContext { + /** [AudioContext.pause()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioContext.pause.html) + * + * 在插件中使用:支持 + * @deprecated 基础库版本 [1.6.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [wx.createInnerAudioContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createInnerAudioContext.html) 替换 + * + * 暂停音频。 */ + pause(): void + /** [AudioContext.play()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioContext.play.html) + * + * 在插件中使用:支持 + * @deprecated 基础库版本 [1.6.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [wx.createInnerAudioContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createInnerAudioContext.html) 替换 + * + * 播放音频。 */ + play(): void + /** [AudioContext.seek(number position)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioContext.seek.html) + * + * 在插件中使用:支持 + * @deprecated 基础库版本 [1.6.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [wx.createInnerAudioContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createInnerAudioContext.html) 替换 + * + * 跳转到指定位置。 */ + seek( + /** 跳转位置,单位 s */ + position: number + ): void + /** [AudioContext.setSrc(string src)](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioContext.setSrc.html) + * + * 在插件中使用:支持 + * @deprecated 基础库版本 [1.6.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [wx.createInnerAudioContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createInnerAudioContext.html) 替换 + * + * 设置音频地址 */ + setSrc( + /** 音频地址 */ + src: string + ): void } - /** InnerAudioContext 实例,可通过 [wx.createInnerAudioContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createInnerAudioContext.html) 接口获取实例。 + interface BLEPeripheralServer { + /** [BLEPeripheralServer.addService(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.addService.html) + * + * 需要基础库: `2.10.3` + * + * 在插件中使用:不支持 + * + * 添加服务。 */ + addService(option: AddServiceOption): void + /** [BLEPeripheralServer.close(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.close.html) + * + * 需要基础库: `2.10.3` + * + * 在插件中使用:不支持 + * + * 关闭当前服务端。 */ + close(option?: BLEPeripheralServerCloseOption): void + /** [BLEPeripheralServer.offCharacteristicReadRequest(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.offCharacteristicReadRequest.html) * -* **支持格式** +* 需要基础库: `2.10.3` * +* 在插件中使用:不支持 * -* | 格式 | iOS | Android | -* | ---- | ---- | ------- | -* | flac | x | √ | -* | m4a | √ | √ | -* | ogg | x | √ | -* | ape | x | √ | -* | amr | x | √ | -* | wma | x | √ | -* | wav | √ | √ | -* | mp3 | √ | √ | -* | mp4 | x | √ | -* | aac | √ | √ | -* | aiff | √ | x | -* | caf | √ | x | +* 移除已连接的设备请求读当前外围设备的特征值事件的监听函数 * * **示例代码** * +* ```js +const listener = function (res) { console.log(res) } + +BLEPeripheralServer.onCharacteristicReadRequest(listener) +BLEPeripheralServer.offCharacteristicReadRequest(listener) // 需传入与监听时同一个的函数对象 +``` */ + offCharacteristicReadRequest( + /** onCharacteristicReadRequest 传入的监听函数。不传此参数则移除所有监听函数。 */ + listener?: OffCharacteristicReadRequestCallback + ): void + /** [BLEPeripheralServer.offCharacteristicSubscribed(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.offCharacteristicSubscribed.html) +* +* 需要基础库: `2.13.0` +* +* 在插件中使用:不支持 +* +* 移除特征订阅事件的监听函数 +* +* **示例代码** * * ```js -const innerAudioContext = wx.createInnerAudioContext() -innerAudioContext.autoplay = true -innerAudioContext.src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46' -innerAudioContext.onPlay(() => { - console.log('开始播放') -}) -innerAudioContext.onError((res) => { - console.log(res.errMsg) - console.log(res.errCode) -}) +const listener = function (res) { console.log(res) } + +BLEPeripheralServer.onCharacteristicSubscribed(listener) +BLEPeripheralServer.offCharacteristicSubscribed(listener) // 需传入与监听时同一个的函数对象 ``` */ - interface InnerAudioContext { - /** 是否自动开始播放,默认为 `false` */ - autoplay: boolean - /** 音频缓冲的时间点,仅保证当前播放时间点到此时间点内容已缓冲(只读) */ - buffered: number - /** 当前音频的播放位置(单位 s)。只有在当前有合法的 src 时返回,时间保留小数点后 6 位(只读) */ - currentTime: number - /** 当前音频的长度(单位 s)。只有在当前有合法的 src 时返回(只读) */ - duration: number - /** 是否循环播放,默认为 `false` */ - loop: boolean - /** 是否遵循系统静音开关,默认为 `true`。当此参数为 `false` 时,即使用户打开了静音开关,也能继续发出声音。从 2.3.0 版本开始此参数不生效,使用 [wx.setInnerAudioOption](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.setInnerAudioOption.html) 接口统一设置。 */ - obeyMuteSwitch: boolean - /** 当前是是否暂停或停止状态(只读) */ - paused: boolean - /** 音频资源的地址,用于直接播放。[2.2.3](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 开始支持云文件ID */ - src: string - /** 开始播放的位置(单位:s),默认为 0 */ - startTime: number - /** 音量。范围 0~1。默认为 1 + offCharacteristicSubscribed( + /** onCharacteristicSubscribed 传入的监听函数。不传此参数则移除所有监听函数。 */ + listener?: OffCharacteristicSubscribedCallback + ): void + /** [BLEPeripheralServer.offCharacteristicUnsubscribed(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.offCharacteristicUnsubscribed.html) +* +* 需要基础库: `2.13.0` +* +* 在插件中使用:不支持 +* +* 移除取消特征订阅事件的监听函数 +* +* **示例代码** +* +* ```js +const listener = function (res) { console.log(res) } + +BLEPeripheralServer.onCharacteristicUnsubscribed(listener) +BLEPeripheralServer.offCharacteristicUnsubscribed(listener) // 需传入与监听时同一个的函数对象 +``` */ + offCharacteristicUnsubscribed( + /** onCharacteristicUnsubscribed 传入的监听函数。不传此参数则移除所有监听函数。 */ + listener?: OffCharacteristicUnsubscribedCallback + ): void + /** [BLEPeripheralServer.offCharacteristicWriteRequest(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.offCharacteristicWriteRequest.html) +* +* 需要基础库: `2.10.3` +* +* 在插件中使用:不支持 +* +* 移除已连接的设备请求写当前外围设备的特征值事件的监听函数 +* +* **示例代码** +* +* ```js +const listener = function (res) { console.log(res) } + +BLEPeripheralServer.onCharacteristicWriteRequest(listener) +BLEPeripheralServer.offCharacteristicWriteRequest(listener) // 需传入与监听时同一个的函数对象 +``` */ + offCharacteristicWriteRequest( + /** onCharacteristicWriteRequest 传入的监听函数。不传此参数则移除所有监听函数。 */ + listener?: OffCharacteristicWriteRequestCallback + ): void + /** [BLEPeripheralServer.onCharacteristicReadRequest(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.onCharacteristicReadRequest.html) * - * 最低基础库: `1.9.90` */ - volume: number - } - interface InnerAudioContextOnErrorCallbackResult { - /** + * 需要基础库: `2.10.3` * - * 可选值: - * - 10001: 系统错误; - * - 10002: 网络错误; - * - 10003: 文件错误; - * - 10004: 格式错误; - * - -1: 未知错误; */ - errCode: 10001 | 10002 | 10003 | 10004 | -1 - errMsg: string - } - interface InsertDividerOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: InsertDividerCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: InsertDividerFailCallback - /** 接口调用成功的回调函数 */ - success?: InsertDividerSuccessCallback - } - interface InsertImageOption { - /** 图片地址,仅支持 http(s)、base64、云图片(2.8.0)、临时文件(2.8.3)。 */ - src: string - /** 图像无法显示时的替代文本 */ - alt?: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: InsertImageCompleteCallback - /** data 被序列化为 name=value;name1=value2 的格式挂在属性 data-custom 上 */ - data?: IAnyObject - /** 添加到图片 img 标签上的类名 */ - extClass?: string - /** 接口调用失败的回调函数 */ - fail?: InsertImageFailCallback - /** 图片高度 (pixels/百分比) */ - height?: string - /** 接口调用成功的回调函数 */ - success?: InsertImageSuccessCallback - /** 图片宽度(pixels/百分比) */ - width?: string + * 在插件中使用:不支持 + * + * 监听已连接的设备请求读当前外围设备的特征值事件。收到该消息后需要立刻调用 [writeCharacteristicValue](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.writeCharacteristicValue.html) 写回数据,否则主机不会收到响应。 */ + onCharacteristicReadRequest( + /** 已连接的设备请求读当前外围设备的特征值事件的监听函数 */ + listener: OnCharacteristicReadRequestCallback + ): void + /** [BLEPeripheralServer.onCharacteristicSubscribed(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.onCharacteristicSubscribed.html) + * + * 需要基础库: `2.13.0` + * + * 在插件中使用:不支持 + * + * 监听特征订阅事件,仅 iOS 支持。 */ + onCharacteristicSubscribed( + /** 特征订阅事件的监听函数 */ + listener: OnCharacteristicSubscribedCallback + ): void + /** [BLEPeripheralServer.onCharacteristicUnsubscribed(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.onCharacteristicUnsubscribed.html) + * + * 需要基础库: `2.13.0` + * + * 在插件中使用:不支持 + * + * 监听取消特征订阅事件,仅 iOS 支持。 */ + onCharacteristicUnsubscribed( + /** 取消特征订阅事件的监听函数 */ + listener: OnCharacteristicUnsubscribedCallback + ): void + /** [BLEPeripheralServer.onCharacteristicWriteRequest(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.onCharacteristicWriteRequest.html) + * + * 需要基础库: `2.10.3` + * + * 在插件中使用:不支持 + * + * 监听已连接的设备请求写当前外围设备的特征值事件。收到该消息后需要立刻调用 [writeCharacteristicValue](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.writeCharacteristicValue.html) 写回数据,否则主机不会收到响应。 */ + onCharacteristicWriteRequest( + /** 已连接的设备请求写当前外围设备的特征值事件的监听函数 */ + listener: OnCharacteristicWriteRequestCallback + ): void + /** [BLEPeripheralServer.removeService(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.removeService.html) + * + * 需要基础库: `2.10.3` + * + * 在插件中使用:不支持 + * + * 移除服务。 */ + removeService(option: RemoveServiceOption): void + /** [BLEPeripheralServer.startAdvertising(Object Object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.startAdvertising.html) + * + * 需要基础库: `2.10.3` + * + * 在插件中使用:不支持 + * + * 开始广播本地创建的外围设备。 + * + * **注意** + * + * - Android 8.0.9 开始,支持直接使用 16/32/128 位 UUID; + * - Android 8.0.9 以下版本只支持 128 位 UUID,使用 16/32 位的 UUID 时需要进行补位(系统会自动识别是否属于预分配区间),可以参考[蓝牙指南](https://developers.weixin.qq.com/miniprogram/dev/framework/device/ble.html); + * - iOS 必须直接使用 16 位的 UUID,不能补位到 128 位,否则系统组包时仍会按照 128 位传输。iOS 暂不支持 32 位 UUID。 + * - iOS 同时只能发起一个广播,安卓支持同时发起多个广播。 + * - 传 beacon 参数时,不能同时传入 deviceName,serviceUuids,manufacturerData 参数。 */ + startAdvertising(Object: StartAdvertisingObject): void + /** [BLEPeripheralServer.stopAdvertising(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.stopAdvertising.html) + * + * 需要基础库: `2.10.3` + * + * 在插件中使用:不支持 + * + * 停止广播。 */ + stopAdvertising(option?: StopAdvertisingOption): void + /** [BLEPeripheralServer.writeCharacteristicValue(Object Object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.writeCharacteristicValue.html) + * + * 需要基础库: `2.10.3` + * + * 在插件中使用:不支持 + * + * 往指定特征写入二进制数据值,并通知已连接的主机,从机的特征值已发生变化,该接口会处理是走回包还是走订阅。 */ + writeCharacteristicValue(Object: WriteCharacteristicValueObject): void } - interface InsertTextOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: InsertTextCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: InsertTextFailCallback - /** 接口调用成功的回调函数 */ - success?: InsertTextSuccessCallback - /** 文本内容 */ - text?: string + interface BackgroundAudioError { + /** 错误信息 + * + * | 错误码 | 错误信息 | 说明 | + * | - | - | - | + * | 10001 | | 系统错误 | + * | 10002 | | 网络错误 | + * | 10003 | | 文件错误,请检查是否responseheader是否缺少Content-Length | + * | 10004 | | 格式错误 | + * | -1 | | 未知错误 | */ errMsg: string + /** 错误码 + * + * | 错误码 | 错误信息 | 说明 | + * | - | - | - | + * | 10001 | | 系统错误 | + * | 10002 | | 网络错误 | + * | 10003 | | 文件错误,请检查是否responseheader是否缺少Content-Length | + * | 10004 | | 格式错误 | + * | -1 | | 未知错误 | */ errCode: number } - /** 相交区域的边界 */ - interface IntersectionRectResult { - /** 下边界 */ - bottom: number - /** 高度 */ - height: number - /** 左边界 */ - left: number - /** 右边界 */ - right: number - /** 上边界 */ - top: number - /** 宽度 */ - width: number + interface BeaconError { + /** 错误信息 + * + * | 错误码 | 错误信息 | 说明 | + * | - | - | - | + * | 0 | ok | 正常 | + * | 11000 | unsupport | 系统或设备不支持 | + * | 11001 | bluetooth service unavailable | 蓝牙服务不可用 | + * | 11002 | location service unavailable | 位置服务不可用 | + * | 11003 | already start | 已经开始搜索 | + * | 11004 | not startBeaconDiscovery | 还未开始搜索 | + * | 11005 | system error | 系统错误 | + * | 11006 | invalid data | 参数不正确 | */ errMsg: string + /** 错误码 + * + * | 错误码 | 错误信息 | 说明 | + * | - | - | - | + * | 0 | ok | 正常 | + * | 11000 | unsupport | 系统或设备不支持 | + * | 11001 | bluetooth service unavailable | 蓝牙服务不可用 | + * | 11002 | location service unavailable | 位置服务不可用 | + * | 11003 | already start | 已经开始搜索 | + * | 11004 | not startBeaconDiscovery | 还未开始搜索 | + * | 11005 | system error | 系统错误 | + * | 11006 | invalid data | 参数不正确 | */ errCode: number } - interface InterstitialAdOnErrorCallbackResult { + interface BluetoothError { + /** 错误信息 + * + * | 错误码 | 错误信息 | 说明 | + * | - | - | - | + * | 0 | ok | 正常 | + * | -1 | already connect | 已连接 | + * | 10000 | not init | 未初始化蓝牙适配器 | + * | 10001 | not available | 当前蓝牙适配器不可用 | + * | 10002 | no device | 没有找到指定设备 | + * | 10003 | connection fail | 连接失败 | + * | 10004 | no service | 没有找到指定服务 | + * | 10005 | no characteristic | 没有找到指定特征 | + * | 10006 | no connection | 当前连接已断开 | + * | 10007 | property not support | 当前特征不支持此操作 | + * | 10008 | system error | 其余所有系统上报的异常 | + * | 10009 | system not support | Android 系统特有,系统版本低于 4.3 不支持 BLE | + * | 10012 | operate time out | 连接超时 | + * | 10013 | invalid_data | 连接 deviceId 为空或者是格式不正确 | */ errMsg: string /** 错误码 * - * 可选值: - * - 1000: 后端接口调用失败; - * - 1001: 参数错误; - * - 1002: 广告单元无效; - * - 1003: 内部错误; - * - 1004: 无合适的广告; - * - 1005: 广告组件审核中; - * - 1006: 广告组件被驳回; - * - 1007: 广告组件被封禁; - * - 1008: 广告单元已关闭; */ - errCode: 1000 | 1001 | 1002 | 1003 | 1004 | 1005 | 1006 | 1007 | 1008 - /** 错误信息 */ - errMsg: string - } - /** 启动参数 */ - interface LaunchOptionsApp { - /** 启动小程序的路径 (代码包路径) */ - path: string - /** 启动小程序的 query 参数 */ - query: IAnyObject - /** 来源信息。从另一个小程序、公众号或 App 进入小程序时返回。否则返回 `{}`。(参见后文注意) */ - referrerInfo: LaunchOptionsAppReferrerInfo - /** 启动小程序的[场景值](https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/scene.html) */ - scene: number - /** shareTicket,详见[获取更多转发信息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html) */ - shareTicket: string - } - /** 来源信息。从另一个小程序、公众号或 App 进入小程序时返回。否则返回 `{}`。(参见后文注意) */ - interface LaunchOptionsAppReferrerInfo { - /** 来源小程序、公众号或 App 的 appId */ - appId: string - /** 来源小程序传过来的数据,scene=1037或1038时支持 */ - extraData: IAnyObject - } - interface LivePlayerContextPauseOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: LivePlayerContextPauseCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: LivePlayerContextPauseFailCallback - /** 接口调用成功的回调函数 */ - success?: LivePlayerContextPauseSuccessCallback + * | 错误码 | 错误信息 | 说明 | + * | - | - | - | + * | 0 | ok | 正常 | + * | -1 | already connect | 已连接 | + * | 10000 | not init | 未初始化蓝牙适配器 | + * | 10001 | not available | 当前蓝牙适配器不可用 | + * | 10002 | no device | 没有找到指定设备 | + * | 10003 | connection fail | 连接失败 | + * | 10004 | no service | 没有找到指定服务 | + * | 10005 | no characteristic | 没有找到指定特征 | + * | 10006 | no connection | 当前连接已断开 | + * | 10007 | property not support | 当前特征不支持此操作 | + * | 10008 | system error | 其余所有系统上报的异常 | + * | 10009 | system not support | Android 系统特有,系统版本低于 4.3 不支持 BLE | + * | 10012 | operate time out | 连接超时 | + * | 10013 | invalid_data | 连接 deviceId 为空或者是格式不正确 | */ errCode: number } - interface LivePlayerContextRequestFullScreenOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: RequestFullScreenCompleteCallback - /** 设置全屏时的方向 + interface CameraContext { + /** [CameraContext.setZoom(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/CameraContext.setZoom.html) * - * 可选值: - * - 0: 正常竖向; - * - 90: 屏幕逆时针90度; - * - -90: 屏幕顺时针90度; */ - direction?: 0 | 90 | -90 - /** 接口调用失败的回调函数 */ - fail?: RequestFullScreenFailCallback - /** 接口调用成功的回调函数 */ - success?: RequestFullScreenSuccessCallback - } - interface LivePlayerContextResumeOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: LivePlayerContextResumeCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: LivePlayerContextResumeFailCallback - /** 接口调用成功的回调函数 */ - success?: LivePlayerContextResumeSuccessCallback - } - interface LivePlayerContextStopOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: LivePlayerContextStopCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: LivePlayerContextStopFailCallback - /** 接口调用成功的回调函数 */ - success?: LivePlayerContextStopSuccessCallback - } - interface LivePusherContextPauseOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: LivePusherContextPauseCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: LivePusherContextPauseFailCallback - /** 接口调用成功的回调函数 */ - success?: LivePusherContextPauseSuccessCallback - } - interface LivePusherContextResumeOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: LivePusherContextResumeCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: LivePusherContextResumeFailCallback - /** 接口调用成功的回调函数 */ - success?: LivePusherContextResumeSuccessCallback - } - interface LivePusherContextStartOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: LivePusherContextStartCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: LivePusherContextStartFailCallback - /** 接口调用成功的回调函数 */ - success?: LivePusherContextStartSuccessCallback - } - interface LivePusherContextStopOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: LivePusherContextStopCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: LivePusherContextStopFailCallback - /** 接口调用成功的回调函数 */ - success?: LivePusherContextStopSuccessCallback - } - interface LoadFontFaceCompleteCallbackResult { - /** 加载字体结果 */ - status: string - } - interface LoadFontFaceFailCallbackResult { - /** 加载字体结果 */ - status: string - } - interface LoadFontFaceOption { - /** 定义的字体名称 */ - family: string - /** 字体资源的地址。建议格式为 TTF 和 WOFF,WOFF2 在低版本的iOS上会不兼容。 */ - source: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: LoadFontFaceCompleteCallback - /** 可选的字体描述符 */ - desc?: DescOption - /** 接口调用失败的回调函数 */ - fail?: LoadFontFaceFailCallback - /** 是否全局生效 + * 需要基础库: `2.10.0` * - * 最低基础库: `2.10.0` */ - global?: boolean - /** 接口调用成功的回调函数 */ - success?: LoadFontFaceSuccessCallback - } - interface LoadFontFaceSuccessCallbackResult { - /** 加载字体结果 */ - status: string - } - interface LoginOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: LoginCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: LoginFailCallback - /** 接口调用成功的回调函数 */ - success?: LoginSuccessCallback - /** 超时时间,单位ms + * 在插件中使用:支持 * - * 最低基础库: `1.9.90` */ - timeout?: number - } - interface LoginSuccessCallbackResult { - /** 用户登录凭证(有效期五分钟)。开发者需要在开发者服务器后台调用 [auth.code2Session](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/login/auth.code2Session.html),使用 code 换取 openid 和 session_key 等信息 */ - code: string - errMsg: string - } - interface MakePhoneCallOption { - /** 需要拨打的电话号码 */ - phoneNumber: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: MakePhoneCallCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: MakePhoneCallFailCallback - /** 接口调用成功的回调函数 */ - success?: MakePhoneCallSuccessCallback - } - /** 广播的制造商信息, 默认为空 */ - interface ManufacturerData { - /** 制造商ID */ - manufacturerId: string - /** 制造商信息 */ - manufacturerSpecificData: ArrayBuffer - } - /** 要显示在可视区域内的坐标点列表 */ - interface MapPostion { - /** 纬度 */ - latitude: number - /** 经度 */ - longitude: number - } - /** 本地临时文件列表 */ - interface MediaFile { - /** 视频的时间长度 */ - duration: number - /** 视频的高度 */ - height: number - /** 本地临时文件大小,单位 B */ - size: number - /** 本地临时文件路径 (本地路径) */ - tempFilePath: string - /** 视频缩略图临时文件路径 */ - thumbTempFilePath: string - /** 视频的宽度 */ - width: number + * 设置缩放级别 */ + setZoom(option: CameraContextSetZoomOption): void + /** [CameraContext.startRecord(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/CameraContext.startRecord.html) + * + * 在插件中使用:支持 + * + * 开始录像 */ + startRecord(option: CameraContextStartRecordOption): void + /** [CameraContext.stopRecord(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/CameraContext.stopRecord.html) + * + * 在插件中使用:支持 + * + * 结束录像 */ + stopRecord(option: CameraContextStopRecordOption): void + /** [CameraContext.takePhoto(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/CameraContext.takePhoto.html) + * + * 在插件中使用:支持 + * + * 拍摄照片 */ + takePhoto(option: TakePhotoOption): void + /** [[CameraFrameListener](https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/CameraFrameListener.html) CameraContext.onCameraFrame(function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/CameraContext.onCameraFrame.html) +* +* 需要基础库: `2.7.0` +* +* 在插件中使用:不支持 +* +* 获取 Camera 实时帧数据 +* +* **** +* +* 注: 使用该接口需同时在 [camera](https://developers.weixin.qq.com/miniprogram/dev/component/camera.html) 组件属性中指定 frame-size。 +* +* **示例代码** +* +* ```js +const context = wx.createCameraContext() +const listener = context.onCameraFrame((frame) => { + console.log(frame.data instanceof ArrayBuffer, frame.width, frame.height) +}) +listener.start() +``` */ + onCameraFrame( + /** 回调函数 */ + callback: OnCameraFrameCallback + ): CameraFrameListener } - /** 可通过 [MediaContainer.extractDataSource](https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaContainer.extractDataSource.html) 返回。 - * - * [MediaTrack](https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaTrack.html) 音频或视频轨道,可以对轨道进行一些操作 - * - * 最低基础库: `2.9.0` */ - interface MediaTrack { - /** 轨道长度,只读 */ - duration: number - /** 轨道类型,只读 + interface CameraFrameListener { + /** [CameraFrameListener.start(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/CameraFrameListener.start.html) * - * 可选值: - * - 'audio': 音频轨道; - * - 'video': 视频轨道; */ - kind: 'audio' | 'video' - /** 音量,音频轨道下有效,可写 */ - volume: number + * 在插件中使用:不支持 + * + * 开始监听帧数据 */ + start(option?: CameraFrameListenerStartOption): void + /** [CameraFrameListener.stop(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/CameraFrameListener.stop.html) + * + * 在插件中使用:不支持 + * + * 停止监听帧数据 */ + stop(option?: StopOption): void + } + interface CanvasGradient { + /** [CanvasGradient.addColorStop(number stop, string color)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasGradient.addColorStop.html) +* +* 在插件中使用:不支持 +* @deprecated 基础库版本 [2.9.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起已废弃,请使用 [RenderingContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) 替换 +* +* @warning **CanvasContext 是旧版的接口,新版 [Canvas 2D](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 接口与 Web 一致** +* +* 添加颜色的渐变点。小于最小 stop 的部分会按最小 stop 的 color 来渲染,大于最大 stop 的部分会按最大 stop 的 color 来渲染 +* +* **示例代码** +* +* ```js +const ctx = wx.createCanvasContext('myCanvas') + +// Create circular gradient +const grd = ctx.createLinearGradient(30, 10, 120, 10) +grd.addColorStop(0, 'red') +grd.addColorStop(0.16, 'orange') +grd.addColorStop(0.33, 'yellow') +grd.addColorStop(0.5, 'green') +grd.addColorStop(0.66, 'cyan') +grd.addColorStop(0.83, 'blue') +grd.addColorStop(1, 'purple') + +// Fill with gradient +ctx.setFillStyle(grd) +ctx.fillRect(10, 10, 150, 80) +ctx.draw() +``` +* ![](@program/dev/image/canvas/color-stop.png) */ + addColorStop( + /** 表示渐变中开始与结束之间的位置,范围 0-1。 */ + stop: number, + /** 渐变点的颜色。 */ + color: string + ): void } - /** 小程序帐号信息 */ - interface MiniProgram { - /** 小程序 appId */ - appId: string - /** 小程序版本 + interface CommonPaymentError { + /** 错误信息 * - * 可选值: - * - 'develop': 开发版; - * - 'trial': 体验版; - * - 'release': 正式版; + * | 错误码 | 错误信息 | 说明 | + * | - | - | - | + * | 1000 | | 系统错误 | + * | 1022 | | 参数json格式非法 | + * | 702001 | | 参数错误,具体原因见errMsg | + * | 702002 | | 用户态签名错误 | + * | 702003 | | 支付签名错误 | + * | 702004 | | mode不合法 | + * | 702005 | | out_trade_no重复,请更换新单号重试 | + * | 702006 | | 二级商户进件未完成 | + * | 702007 | | 用户未授权给品牌 | + * | 702008 | | 正式版小程序只能用生产环境下单 | + * | 702009 | | B2b授权关系校验不通过 | */ errMsg: string + /** 错误码 * - * 最低基础库: `2.10.0` */ - envVersion: 'develop' | 'trial' | 'release' + * | 错误码 | 错误信息 | 说明 | + * | - | - | - | + * | 1000 | | 系统错误 | + * | 1022 | | 参数json格式非法 | + * | 702001 | | 参数错误,具体原因见errMsg | + * | 702002 | | 用户态签名错误 | + * | 702003 | | 支付签名错误 | + * | 702004 | | mode不合法 | + * | 702005 | | out_trade_no重复,请更换新单号重试 | + * | 702006 | | 二级商户进件未完成 | + * | 702007 | | 用户未授权给品牌 | + * | 702008 | | 正式版小程序只能用生产环境下单 | + * | 702009 | | B2b授权关系校验不通过 | */ errCode: number } - interface MkdirFailCallbackResult { - /** 错误信息 + interface Console { + /** [console.debug()](https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.debug.html) * - * 可选值: - * - 'fail no such file or directory ${dirPath}': 上级目录不存在; - * - 'fail permission denied, open ${dirPath}': 指定的 filePath 路径没有写权限; - * - 'fail file already exists ${dirPath}': 有同名文件或目录; */ - errMsg: string - } - interface MkdirOption { - /** 创建的目录路径 (本地路径) */ - dirPath: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: MkdirCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: MkdirFailCallback - /** 是否在递归创建该目录的上级目录后再创建该目录。如果对应的上级目录已经存在,则不创建该上级目录。如 dirPath 为 a/b/c/d 且 recursive 为 true,将创建 a 目录,再在 a 目录下创建 b 目录,以此类推直至创建 a/b/c 目录下的 d 目录。 + * 在插件中使用:不支持 * - * 最低基础库: `2.3.0` */ - recursive?: boolean - /** 接口调用成功的回调函数 */ - success?: MkdirSuccessCallback - } - interface MoveToLocationOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: MoveToLocationCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: MoveToLocationFailCallback - /** 纬度 + * 向调试面板中打印 debug 日志 */ + debug( + /** 日志内容,可以有任意多个。 */ + ...args: any[] + ): void + /** [console.error()](https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.error.html) * - * 最低基础库: `2.8.0` */ - latitude?: number - /** 经度 + * 在插件中使用:不支持 * - * 最低基础库: `2.8.0` */ - longitude?: number - /** 接口调用成功的回调函数 */ - success?: MoveToLocationSuccessCallback - } - interface MuteOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: MuteCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: MuteFailCallback - /** 接口调用成功的回调函数 */ - success?: MuteSuccessCallback - } - interface NavigateBackMiniProgramOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: NavigateBackMiniProgramCompleteCallback - /** 需要返回给上一个小程序的数据,上一个小程序可在 `App.onShow` 中获取到这份数据。 [详情](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html)。 */ - extraData?: IAnyObject - /** 接口调用失败的回调函数 */ - fail?: NavigateBackMiniProgramFailCallback - /** 接口调用成功的回调函数 */ - success?: NavigateBackMiniProgramSuccessCallback - } - interface NavigateBackOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: NavigateBackCompleteCallback - /** 返回的页面数,如果 delta 大于现有页面数,则返回到首页。 */ - delta?: number - /** 接口调用失败的回调函数 */ - fail?: NavigateBackFailCallback - /** 接口调用成功的回调函数 */ - success?: NavigateBackSuccessCallback - } - interface NavigateToMiniProgramOption { - /** 要打开的小程序 appId */ - appId: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: NavigateToMiniProgramCompleteCallback - /** 要打开的小程序版本。仅在当前小程序为开发版或体验版时此参数有效。如果当前小程序是正式版,则打开的小程序必定是正式版。 + * 向调试面板中打印 error 日志 */ + error( + /** 日志内容,可以有任意多个。 */ + ...args: any[] + ): void + /** [console.group(string label)](https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.group.html) * - * 可选值: - * - 'develop': 开发版; - * - 'trial': 体验版; - * - 'release': 正式版; */ - envVersion?: 'develop' | 'trial' | 'release' - /** 需要传递给目标小程序的数据,目标小程序可在 `App.onLaunch`,`App.onShow` 中获取到这份数据。如果跳转的是小游戏,可以在 [wx.onShow](#)、[wx.getLaunchOptionsSync](https://developers.weixin.qq.com/miniprogram/dev/api/base/app/life-cycle/wx.getLaunchOptionsSync.html) 中可以获取到这份数据数据。 */ - extraData?: IAnyObject - /** 接口调用失败的回调函数 */ - fail?: NavigateToMiniProgramFailCallback - /** 打开的页面路径,如果为空则打开首页。path 中 ? 后面的部分会成为 query,在小程序的 `App.onLaunch`、`App.onShow` 和 `Page.onLoad` 的回调函数或小游戏的 [wx.onShow](#) 回调函数、[wx.getLaunchOptionsSync](https://developers.weixin.qq.com/miniprogram/dev/api/base/app/life-cycle/wx.getLaunchOptionsSync.html) 中可以获取到 query 数据。对于小游戏,可以只传入 query 部分,来实现传参效果,如:传入 "?foo=bar"。 */ - path?: string - /** 接口调用成功的回调函数 */ - success?: NavigateToMiniProgramSuccessCallback - } - interface NavigateToOption { - /** 需要跳转的应用内非 tabBar 的页面的路径 (代码包路径), 路径后可以带参数。参数与路径之间使用 `?` 分隔,参数键与参数值用 `=` 相连,不同参数用 `&` 分隔;如 'path?key=value&key2=value2' */ - url: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: NavigateToCompleteCallback - /** 页面间通信接口,用于监听被打开页面发送到当前页面的数据。基础库 2.7.3 开始支持。 */ - events?: IAnyObject - /** 接口调用失败的回调函数 */ - fail?: NavigateToFailCallback - /** 接口调用成功的回调函数 */ - success?: NavigateToSuccessCallback - } - interface NavigateToSuccessCallbackResult { - /** [EventChannel](https://developers.weixin.qq.com/miniprogram/dev/api/route/EventChannel.html) + * 在插件中使用:不支持 * - * 和被打开页面进行通信 */ - eventChannel: EventChannel - errMsg: string - } - interface NodeCallbackResult { - /** 节点对应的 Node 实例 */ - node: IAnyObject - } - interface NotifyBLECharacteristicValueChangeOption { - /** 蓝牙特征值的 uuid */ - characteristicId: string - /** 蓝牙设备 id */ - deviceId: string - /** 蓝牙特征值对应服务的 uuid */ - serviceId: string - /** 是否启用 notify */ - state: boolean - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: NotifyBLECharacteristicValueChangeCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: NotifyBLECharacteristicValueChangeFailCallback - /** 接口调用成功的回调函数 */ - success?: NotifyBLECharacteristicValueChangeSuccessCallback - } - interface ObserveCallbackResult { - /** 目标边界 */ - boundingClientRect: BoundingClientRectResult - /** 相交比例 */ - intersectionRatio: number - /** 相交区域的边界 */ - intersectionRect: IntersectionRectResult - /** 参照区域的边界 */ - relativeRect: RelativeRectResult - /** 相交检测时的时间戳 */ - time: number - } - interface OnAccelerometerChangeCallbackResult { - /** X 轴 */ - x: number - /** Y 轴 */ - y: number - /** Z 轴 */ - z: number - } - interface OnAppShowCallbackResult { - /** 小程序切前台的路径 (代码包路径) */ - path: string - /** 小程序切前台的 query 参数 */ - query: IAnyObject - /** 来源信息。从另一个小程序、公众号或 App 进入小程序时返回。否则返回 `{}`。(参见后文注意) */ - referrerInfo: ResultReferrerInfo - /** 小程序切前台的[场景值](https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/scene.html) */ - scene: number - /** shareTicket,详见[获取更多转发信息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html) */ - shareTicket: string - } - interface OnBLECharacteristicValueChangeCallbackResult { - /** 蓝牙特征值的 uuid */ - characteristicId: string - /** 蓝牙设备 id */ - deviceId: string - /** 蓝牙特征值对应服务的 uuid */ - serviceId: string - /** 特征值最新的值 */ - value: ArrayBuffer - } - interface OnBLEConnectionStateChangeCallbackResult { - /** 是否处于已连接状态 */ - connected: boolean - /** 蓝牙设备ID */ - deviceId: string - } - interface OnBLEPeripheralConnectionStateChangedCallbackResult { - /** 连接目前状态 */ - connected: boolean - /** 连接状态变化的设备 id */ - deviceId: string - /** server 的 uuid */ - serverId: string - } - interface OnBackgroundFetchDataOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: OnBackgroundFetchDataCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: OnBackgroundFetchDataFailCallback - /** 接口调用成功的回调函数 */ - success?: OnBackgroundFetchDataSuccessCallback - } - interface OnBeaconServiceChangeCallbackResult { - /** 服务目前是否可用 */ - available: boolean - /** 目前是否处于搜索状态 */ - discovering: boolean - } - interface OnBeaconUpdateCallbackResult { - /** 当前搜寻到的所有 iBeacon 设备列表 */ - beacons: IBeaconInfo[] - } - interface OnBluetoothAdapterStateChangeCallbackResult { - /** 蓝牙适配器是否可用 */ - available: boolean - /** 蓝牙适配器是否处于搜索状态 */ - discovering: boolean - } - interface OnBluetoothDeviceFoundCallbackResult { - /** 新搜索到的设备列表 */ - devices: CallbackResultBlueToothDevice[] - } - interface OnCameraFrameCallbackResult { - /** 图像像素点数据,一维数组,每四项表示一个像素点的 rgba */ - data: ArrayBuffer - /** 图像数据矩形的高度 */ - height: number - /** 图像数据矩形的宽度 */ - width: number - } - interface OnCheckForUpdateCallbackResult { - /** 是否有新版本 */ - hasUpdate: boolean - } - interface OnCompassChangeCallbackResult { - /** 精度 + * 在调试面板中创建一个新的分组。随后输出的内容都会被添加一个缩进,表示该内容属于当前分组。调用 [console.groupEnd](https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.groupEnd.html)之后分组结束。 * - * 最低基础库: `2.4.0` */ - accuracy: number | string - /** 面对的方向度数 */ - direction: number - } - interface OnDeviceMotionChangeCallbackResult { - /** 当 手机坐标 X/Y 和 地球 X/Y 重合时,绕着 Z 轴转动的夹角为 alpha,范围值为 [0, 2*PI)。逆时针转动为正。 */ - alpha: number - /** 当手机坐标 Y/Z 和地球 Y/Z 重合时,绕着 X 轴转动的夹角为 beta。范围值为 [-1*PI, PI) 。顶部朝着地球表面转动为正。也有可能朝着用户为正。 */ - beta: number - /** 当手机 X/Z 和地球 X/Z 重合时,绕着 Y 轴转动的夹角为 gamma。范围值为 [-1*PI/2, PI/2)。右边朝着地球表面转动为正。 */ - gamma: number - } - interface OnFrameRecordedCallbackResult { - /** 录音分片数据 */ - frameBuffer: ArrayBuffer - /** 当前帧是否正常录音结束前的最后一帧 */ - isLastFrame: boolean - } - interface OnGetWifiListCallbackResult { - /** Wi-Fi 列表数据 */ - wifiList: WifiInfo[] - } - interface OnGyroscopeChangeCallbackResult { - /** x 轴的角速度 */ - x: number - /** y 轴的角速度 */ - y: number - /** z 轴的角速度 */ - z: number - } - interface OnHCEMessageCallbackResult { - /** `messageType=1` 时 ,客户端接收到 NFC 设备的指令 */ - data: ArrayBuffer - /** 消息类型 + * **注意** + * + * 仅在工具中有效,在 vConsole 中为空函数实现。 */ + group( + /** 分组标记,可选。 */ + label?: string + ): void + /** [console.groupEnd()](https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.groupEnd.html) + * + * 在插件中使用:不支持 + * + * 结束由 [console.group](https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.group.html) 创建的分组 + * + * **注意** * - * 可选值: - * - 1: HCE APDU Command类型,小程序需对此指令进行处理,并调用 sendHCEMessage 接口返回处理指令; - * - 2: 设备离场事件类型; */ - messageType: 1 | 2 - /** `messageType=2` 时,原因 */ - reason: number - } - interface OnKeyboardHeightChangeCallbackResult { - /** 键盘高度 */ - height: number - } - interface OnLocalServiceFoundCallbackResult { - /** 服务的 ip 地址 */ - ip: string - /** 服务的端口 */ - port: number - /** 服务的名称 */ - serviceName: string - /** 服务的类型 */ - serviceType: string - } - interface OnLocalServiceLostCallbackResult { - /** 服务的名称 */ - serviceName: string - /** 服务的类型 */ - serviceType: string - } - interface OnLocalServiceResolveFailCallbackResult { - /** 服务的名称 */ - serviceName: string - /** 服务的类型 */ - serviceType: string - } - interface OnLocationChangeCallbackResult { - /** 位置的精确度 */ - accuracy: number - /** 高度,单位 m + * 仅在工具中有效,在 vConsole 中为空函数实现。 */ + groupEnd(): void + /** [console.info()](https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.info.html) * - * 最低基础库: `1.2.0` */ - altitude: number - /** 水平精度,单位 m + * 在插件中使用:不支持 * - * 最低基础库: `1.2.0` */ - horizontalAccuracy: number - /** 纬度,范围为 -90~90,负数表示南纬 */ - latitude: number - /** 经度,范围为 -180~180,负数表示西经 */ - longitude: number - /** 速度,单位 m/s */ - speed: number - /** 垂直精度,单位 m(Android 无法获取,返回 0) + * 向调试面板中打印 info 日志 */ + info( + /** 日志内容,可以有任意多个。 */ + ...args: any[] + ): void + /** [console.log()](https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.log.html) * - * 最低基础库: `1.2.0` */ - verticalAccuracy: number - } - interface OnMemoryWarningCallbackResult { - /** 内存告警等级,只有 Android 才有,对应系统宏定义 + * 在插件中使用:不支持 * - * 可选值: - * - 5: TRIM_MEMORY_RUNNING_MODERATE; - * - 10: TRIM_MEMORY_RUNNING_LOW; - * - 15: TRIM_MEMORY_RUNNING_CRITICAL; */ - level: 5 | 10 | 15 - } - interface OnNetworkStatusChangeCallbackResult { - /** 当前是否有网络连接 */ - isConnected: boolean - /** 网络类型 + * 向调试面板中打印 log 日志 */ + log( + /** 日志内容,可以有任意多个。 */ + ...args: any[] + ): void + /** [console.warn()](https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.warn.html) * - * 可选值: - * - 'wifi': wifi 网络; - * - '2g': 2g 网络; - * - '3g': 3g 网络; - * - '4g': 4g 网络; - * - 'unknown': Android 下不常见的网络类型; - * - 'none': 无网络; */ - networkType: 'wifi' | '2g' | '3g' | '4g' | 'unknown' | 'none' - } - interface OnOnCharacteristicReadRequestCallbackResult { - /** 唯一标识码,调用 writeCharacteristicValue 时使用 */ - callbackId: number - /** characteristic对应的uuid */ - characteristicId: string - /** service对应的uuid */ - serviceId: string - } - interface OnOnCharacteristicWriteRequestCallbackResult { - /** 唯一标识码,调用 writeCharacteristicValue 时使用 */ - callbackId: number - /** characteristic对应的uuid */ - characteristicId: string - /** service对应的uuid */ - serviceId: string - /** 请求写入的特征值数据 */ - value: ArrayBuffer - } - interface OnOpenCallbackResult { - /** 连接成功的 HTTP 响应 Header + * 在插件中使用:不支持 * - * 最低基础库: `2.0.0` */ - header: IAnyObject - } - interface OnPageNotFoundCallbackResult { - /** 是否本次启动的首个页面(例如从分享等入口进来,首个页面是开发者配置的分享页面) */ - isEntryPage: boolean - /** 不存在页面的路径 (代码包路径) */ - path: string - /** 打开不存在页面的 query 参数 */ - query: IAnyObject - } - interface OnSocketCloseCallbackResult { - /** 一个数字值表示关闭连接的状态号,表示连接被关闭的原因。 */ - code: number - /** 一个可读的字符串,表示连接被关闭的原因。 */ - reason: string + * 向调试面板中打印 warn 日志 */ + warn( + /** 日志内容,可以有任意多个。 */ + ...args: any[] + ): void } - interface OnSocketErrorCallbackResult { - /** 错误信息 */ - errMsg: string + interface DownloadTask { + /** [DownloadTask.abort()](https://developers.weixin.qq.com/miniprogram/dev/api/network/download/DownloadTask.abort.html) + * + * 需要基础库: `1.4.0` + * + * 在插件中使用:支持 + * + * 中断下载任务 */ + abort(): void + /** [DownloadTask.offHeadersReceived(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/network/download/DownloadTask.offHeadersReceived.html) +* +* 需要基础库: `2.1.0` +* +* 在插件中使用:支持 +* +* 移除 HTTP Response Header 事件的监听函数 +* +* **示例代码** +* +* ```js +const listener = function (res) { console.log(res) } + +DownloadTask.onHeadersReceived(listener) +DownloadTask.offHeadersReceived(listener) // 需传入与监听时同一个的函数对象 +``` */ + offHeadersReceived( + /** onHeadersReceived 传入的监听函数。不传此参数则移除所有监听函数。 */ + listener?: DownloadTaskOffHeadersReceivedCallback + ): void + /** [DownloadTask.offProgressUpdate(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/network/download/DownloadTask.offProgressUpdate.html) +* +* 需要基础库: `2.1.0` +* +* 在插件中使用:支持 +* +* 移除下载进度变化事件的监听函数 +* +* **示例代码** +* +* ```js +const listener = function (res) { console.log(res) } + +DownloadTask.onProgressUpdate(listener) +DownloadTask.offProgressUpdate(listener) // 需传入与监听时同一个的函数对象 +``` */ + offProgressUpdate( + /** onProgressUpdate 传入的监听函数。不传此参数则移除所有监听函数。 */ + listener?: DownloadTaskOffProgressUpdateCallback + ): void + /** [DownloadTask.onHeadersReceived(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/network/download/DownloadTask.onHeadersReceived.html) + * + * 需要基础库: `2.1.0` + * + * 在插件中使用:支持 + * + * 监听 HTTP Response Header 事件。会比请求完成事件更早 */ + onHeadersReceived( + /** HTTP Response Header 事件的监听函数 */ + listener: DownloadTaskOnHeadersReceivedCallback + ): void + /** [DownloadTask.onProgressUpdate(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/network/download/DownloadTask.onProgressUpdate.html) + * + * 需要基础库: `1.4.0` + * + * 在插件中使用:支持 + * + * 监听下载进度变化事件 */ + onProgressUpdate( + /** 下载进度变化事件的监听函数 */ + listener: DownloadTaskOnProgressUpdateCallback + ): void } - interface OnSocketMessageCallbackResult { - /** 服务器返回的消息 */ - data: string | ArrayBuffer + interface DraggableSheetContext { + /** [DraggableSheetContext.scrollTo(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/skyline/DraggableSheetContext.scrollTo.html) +* +* 需要基础库: `3.2.0` +* +* 在插件中使用:支持 +* +* 滚动到指定位置。`size` 取值 `[0, 1]`,`size = 1` 时表示撑满 `draggable-sheet` 组件。`size` 和 `pixels` 同时传入时,仅 size 生效。 +* +* **示例代码** +* +* ```javascript +Page({ + onReady() { + this.createSelectorQuery() + .select(".sheet") + .node() + .exec(res => { + const sheetContext = res[0].node + sheetContext.scrollTo({ + size: 0.7, + animated: true, + duration: 300, + easingFunction: 'ease' + }) + }, +}) +``` */ + scrollTo(option: DraggableSheetContextScrollToOption): void } - interface OnSocketOpenCallbackResult { - /** 连接成功的 HTTP 响应 Header + interface EditorContext { + /** [EditorContext.blur(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.blur.html) + * + * 需要基础库: `2.8.3` + * + * 在插件中使用:支持 + * + * 编辑器失焦,同时收起键盘。 */ + blur(option?: BlurOption): void + /** [EditorContext.clear(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.clear.html) + * + * 需要基础库: `2.7.0` + * + * 在插件中使用:支持 + * + * 清空编辑器内容 */ + clear(option?: ClearOption): void + /** [EditorContext.deleteText(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.deleteText.html) + * + * 需要基础库: `3.7.11` + * + * 在插件中使用:支持 + * + * 删除指定选取区的内容 */ + deleteText(option: DeleteTextOption): void + /** [EditorContext.format(string name, string value)](https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.format.html) + * + * 需要基础库: `2.7.0` + * + * 在插件中使用:支持 + * + * 修改样式 + * + * **** + * + * ## 支持设置的样式列表 + * | name | value | verson | + * | --------------------------------------------------------- | ------------------------------- | ------ | + * | bold | | 2.7.0 | + * | italic | | 2.7.0 | + * | underline | | 2.7.0 | + * | strike | | 2.7.0 | + * | ins | | 2.7.0 | + * | script | sub / super | 2.7.0 | + * | header | H1 / H2 / h3 / H4 / h5 / H6 | 2.7.0 | + * | align | left / center / right / justify | 2.7.0 | + * | direction | rtl | 2.7.0 | + * | indent | -1 / +1 | 2.7.0 | + * | list | ordered / bullet / check | 2.7.0 | + * | color | hex color | 2.7.0 | + * | backgroundColor | hex color | 2.7.0 | + * | margin/marginTop/marginBottom/marginLeft/marginRight | css style | 2.7.0 | + * | padding/paddingTop/paddingBottom/paddingLeft/paddingRight | css style | 2.7.0 | + * | font/fontSize/fontStyle/fontVariant/fontWeight/fontFamily | css style | 2.7.0 | + * | lineHeight | css style | 2.7.0 | + * | letterSpacing | css style | 2.7.0 | + * | textDecoration | css style | 2.7.0 | + * | textIndent | css style | 2.8.0 | + * | wordWrap | css style | 2.10.2 | + * | wordBreak | css style | 2.10.2 | + * | whiteSpace | css style | 2.10.2 | + * + * 对已经应用样式的选区设置会取消样式。css style 表示 css 中规定的允许值。 */ + format( + /** 属性 */ + name: string, + /** 值 */ + value?: string + ): void + /** [EditorContext.getBounds(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.getBounds.html) + * + * 需要基础库: `3.7.11` + * + * 在插件中使用:支持 + * + * 获取指定选区的位置和大小 */ + getBounds(option: GetBoundsOption): void + /** [EditorContext.getContents(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.getContents.html) + * + * 需要基础库: `2.7.0` + * + * 在插件中使用:支持 + * + * 获取编辑器内容 */ + getContents(option?: GetContentsOption): void + /** [EditorContext.getSelection(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.getSelection.html) + * + * 需要基础库: `3.7.11` + * + * 在插件中使用:支持 + * + * 获取当前选区 */ + getSelection(option?: GetSelectionOption): void + /** [EditorContext.getSelectionText(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.getSelectionText.html) + * + * 需要基础库: `2.10.2` + * + * 在插件中使用:支持 + * + * 获取编辑器已选区域内的纯文本内容。当编辑器失焦或未选中一段区间时,返回内容为空。 */ + getSelectionText(option?: GetSelectionTextOption): void + /** [EditorContext.insertCustomBlock(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.insertCustomBlock.html) + * + * 需要基础库: `3.7.11` + * + * 在插件中使用:支持 + * + * 插入自定义区块 */ + insertCustomBlock(option: InsertCustomBlockOption): void + /** [EditorContext.insertDivider(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.insertDivider.html) + * + * 需要基础库: `2.7.0` + * + * 在插件中使用:支持 + * + * 插入分割线 */ + insertDivider(option?: InsertDividerOption): void + /** [EditorContext.insertImage(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.insertImage.html) +* +* 需要基础库: `2.7.0` +* +* 在插件中使用:支持 +* +* 插入图片。 +* +* 地址为临时文件时,获取的编辑器html格式内容中 标签增加属性 data-local,delta 格式内容中图片 attributes 属性增加 data-local 字段,该值为传入的临时文件地址。 +* +* 开发者可选择在提交阶段上传图片到服务器,获取到网络地址后进行替换。替换时对于html内容应替换掉 的 src 值,对于 delta 内容应替换掉 `insert { image: abc }` 值。 +* +* **示例代码** +* +* ```javascript +this.editorCtx.insertImage({ + src: 'xx', + width: '100px', + height: '50px', + extClass: className +}) +``` */ + insertImage(option: InsertImageOption): void + /** [EditorContext.insertText(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.insertText.html) + * + * 需要基础库: `2.7.0` + * + * 在插件中使用:支持 + * + * 覆盖当前选区,设置一段文本 */ + insertText(option: InsertTextOption): void + /** [EditorContext.redo(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.redo.html) + * + * 需要基础库: `2.7.0` + * + * 在插件中使用:支持 + * + * 恢复 */ + redo(option?: RedoOption): void + /** [EditorContext.removeFormat(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.removeFormat.html) + * + * 需要基础库: `2.7.0` + * + * 在插件中使用:支持 + * + * 清除当前选区的样式 */ + removeFormat(option?: RemoveFormatOption): void + /** [EditorContext.scrollIntoView()](https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.scrollIntoView.html) + * + * 需要基础库: `2.8.3` + * + * 在插件中使用:支持 + * + * 使得编辑器光标处滚动到窗口可视区域内。 */ + scrollIntoView(): void + /** [EditorContext.setContents(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.setContents.html) + * + * 需要基础库: `2.7.0` * - * 最低基础库: `2.0.0` */ - header: IAnyObject - } - interface OnStopCallbackResult { - /** 录音总时长,单位:ms */ - duration: number - /** 录音文件大小,单位:Byte */ - fileSize: number - /** 录音文件的临时路径 (本地路径) */ - tempFilePath: string - } - interface OnUnhandledRejectionCallbackResult { - /** 被拒绝的 Promise 对象 */ - promise: string - /** 拒绝原因,一般是一个 Error 对象 */ - reason: string - } - interface OnWifiConnectedCallbackResult { - /** [WifiInfo](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/WifiInfo.html) + * 在插件中使用:支持 * - * Wi-Fi 信息 */ - wifi: WifiInfo - } - interface OnWindowResizeCallbackResult { - size: Size - } - interface OpenBluetoothAdapterOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: OpenBluetoothAdapterCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: OpenBluetoothAdapterFailCallback - /** 接口调用成功的回调函数 */ - success?: OpenBluetoothAdapterSuccessCallback - } - interface OpenCardOption { - /** 需要打开的卡券列表 */ - cardList: OpenCardRequestInfo[] - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: OpenCardCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: OpenCardFailCallback - /** 接口调用成功的回调函数 */ - success?: OpenCardSuccessCallback - } - /** 需要打开的卡券列表 */ - interface OpenCardRequestInfo { - /** 卡券 ID */ - cardId: string - /** 由 [wx.addCard](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/card/wx.addCard.html) 的返回对象中的加密 code 通过解密后得到,解密请参照:[code 解码接口](https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1499332673_Unm7V) */ - code: string - } - interface OpenDocumentOption { - /** 文件路径 (本地路径) ,可通过 downloadFile 获得 */ - filePath: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: OpenDocumentCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: OpenDocumentFailCallback - /** 文件类型,指定文件类型打开文件 + * 初始化编辑器内容,html和delta同时存在时仅delta生效 */ + setContents(option: SetContentsOption): void + /** [EditorContext.setSelection(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.setSelection.html) * - * 可选值: - * - 'doc': doc 格式; - * - 'docx': docx 格式; - * - 'xls': xls 格式; - * - 'xlsx': xlsx 格式; - * - 'ppt': ppt 格式; - * - 'pptx': pptx 格式; - * - 'pdf': pdf 格式; + * 需要基础库: `3.7.11` * - * 最低基础库: `1.4.0` */ - fileType?: 'doc' | 'docx' | 'xls' | 'xlsx' | 'ppt' | 'pptx' | 'pdf' - /** 接口调用成功的回调函数 */ - success?: OpenDocumentSuccessCallback - } - interface OpenLocationOption { - /** 纬度,范围为-90~90,负数表示南纬。使用 gcj02 国测局坐标系 */ - latitude: number - /** 经度,范围为-180~180,负数表示西经。使用 gcj02 国测局坐标系 */ - longitude: number - /** 地址的详细说明 */ - address?: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: OpenLocationCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: OpenLocationFailCallback - /** 位置名 */ - name?: string - /** 缩放比例,范围5~18 */ - scale?: number - /** 接口调用成功的回调函数 */ - success?: OpenLocationSuccessCallback - } - interface OpenSettingOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: OpenSettingCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: OpenSettingFailCallback - /** 接口调用成功的回调函数 */ - success?: OpenSettingSuccessCallback - } - interface OpenSettingSuccessCallbackResult { - /** [AuthSetting](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/setting/AuthSetting.html) + * 在插件中使用:支持 * - * 用户授权结果 */ - authSetting: AuthSetting - errMsg: string - } - interface PageScrollToOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: PageScrollToCompleteCallback - /** 滚动动画的时长,单位 ms */ - duration?: number - /** 接口调用失败的回调函数 */ - fail?: PageScrollToFailCallback - /** 滚动到页面的目标位置,单位 px */ - scrollTop?: number - /** 选择器 + * 设置当前选区 */ + setSelection(option: SetSelectionOption): void + /** [EditorContext.undo(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.undo.html) * - * 最低基础库: `2.7.3` */ - selector?: string - /** 接口调用成功的回调函数 */ - success?: PageScrollToSuccessCallback - } - interface PauseBGMOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: PauseBGMCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: PauseBGMFailCallback - /** 接口调用成功的回调函数 */ - success?: PauseBGMSuccessCallback - } - interface PauseBackgroundAudioOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: PauseBackgroundAudioCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: PauseBackgroundAudioFailCallback - /** 接口调用成功的回调函数 */ - success?: PauseBackgroundAudioSuccessCallback - } - interface PauseVoiceOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: PauseVoiceCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: PauseVoiceFailCallback - /** 接口调用成功的回调函数 */ - success?: PauseVoiceSuccessCallback - } - interface PlayBGMOption { - /** 加入背景混音的资源地址 */ - url: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: PlayBGMCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: PlayBGMFailCallback - /** 接口调用成功的回调函数 */ - success?: PlayBGMSuccessCallback - } - interface PlayBackgroundAudioOption { - /** 音乐链接,目前支持的格式有 m4a, aac, mp3, wav */ - dataUrl: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: PlayBackgroundAudioCompleteCallback - /** 封面URL */ - coverImgUrl?: string - /** 接口调用失败的回调函数 */ - fail?: PlayBackgroundAudioFailCallback - /** 接口调用成功的回调函数 */ - success?: PlayBackgroundAudioSuccessCallback - /** 音乐标题 */ - title?: string - } - interface PlayOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: PlayCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: PlayFailCallback - /** 接口调用成功的回调函数 */ - success?: PlaySuccessCallback - } - interface PlayVoiceOption { - /** 需要播放的语音文件的文件路径 (本地路径) */ - filePath: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: PlayVoiceCompleteCallback - /** 指定录音时长,到达指定的录音时长后会自动停止录音,单位:秒 + * 需要基础库: `2.7.0` * - * 最低基础库: `1.6.0` */ - duration?: number - /** 接口调用失败的回调函数 */ - fail?: PlayVoiceFailCallback - /** 接口调用成功的回调函数 */ - success?: PlayVoiceSuccessCallback - } - /** 插件帐号信息(仅在插件中调用时包含这一项) */ - interface Plugin { - /** 插件 appId */ - appId: string - /** 插件版本号 */ - version: string - } - interface PreviewImageOption { - /** 需要预览的图片链接列表。[2.2.3](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起支持云文件ID。 */ - urls: string[] - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: PreviewImageCompleteCallback - /** 当前显示图片的链接 */ - current?: string - /** 接口调用失败的回调函数 */ - fail?: PreviewImageFailCallback - /** 接口调用成功的回调函数 */ - success?: PreviewImageSuccessCallback - } - interface ReLaunchOption { - /** 需要跳转的应用内页面路径 (代码包路径),路径后可以带参数。参数与路径之间使用?分隔,参数键与参数值用=相连,不同参数用&分隔;如 'path?key=value&key2=value2' */ - url: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ReLaunchCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: ReLaunchFailCallback - /** 接口调用成功的回调函数 */ - success?: ReLaunchSuccessCallback - } - interface ReadBLECharacteristicValueOption { - /** 蓝牙特征值的 uuid */ - characteristicId: string - /** 蓝牙设备 id */ - deviceId: string - /** 蓝牙特征值对应服务的 uuid */ - serviceId: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ReadBLECharacteristicValueCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: ReadBLECharacteristicValueFailCallback - /** 接口调用成功的回调函数 */ - success?: ReadBLECharacteristicValueSuccessCallback - } - interface ReadFileFailCallbackResult { - /** 错误信息 + * 在插件中使用:支持 * - * 可选值: - * - 'fail no such file or directory, open ${filePath}': 指定的 filePath 所在目录不存在; - * - 'fail permission denied, open ${dirPath}': 指定的 filePath 路径没有读权限; */ - errMsg: string + * 撤销 */ + undo(option?: UndoOption): void } - interface ReadFileOption { - /** 要读取的文件的路径 (本地路径) */ - filePath: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ReadFileCompleteCallback - /** 指定读取文件的字符编码,如果不传 encoding,则以 ArrayBuffer 格式读取文件的二进制内容 - * - * 可选值: - * - 'ascii': ; - * - 'base64': ; - * - 'binary': ; - * - 'hex': ; - * - 'ucs2': 以小端序读取; - * - 'ucs-2': 以小端序读取; - * - 'utf16le': 以小端序读取; - * - 'utf-16le': 以小端序读取; - * - 'utf-8': ; - * - 'utf8': ; - * - 'latin1': ; */ - encoding?: - | 'ascii' - | 'base64' - | 'binary' - | 'hex' - | 'ucs2' - | 'ucs-2' - | 'utf16le' - | 'utf-16le' - | 'utf-8' - | 'utf8' - | 'latin1' - /** 接口调用失败的回调函数 */ - fail?: ReadFileFailCallback - /** 指定文件的长度,如果不指定,则读到文件末尾。有效范围:[1, fileLength]。单位:byte + interface EmptyEventChannel { + /** [EventChannel.emit(string eventName, any args)](https://developers.weixin.qq.com/miniprogram/dev/api/route/EventChannel.emit.html) * - * 最低基础库: `2.10.0` */ - length?: string - /** 从文件指定位置开始读,如果不指定,则从文件头开始读。读取的范围应该是左闭右开区间 [position, position+length)。有效范围:[0, fileLength - 1]。单位:byte + * 需要基础库: `2.7.3` * - * 最低基础库: `2.10.0` */ - position?: string - /** 接口调用成功的回调函数 */ - success?: ReadFileSuccessCallback - } - interface ReadFileSuccessCallbackResult { - /** 文件内容 */ - data: string | ArrayBuffer - errMsg: string - } - interface ReaddirFailCallbackResult { - /** 错误信息 + * 在插件中使用:支持 * - * 可选值: - * - 'fail no such file or directory ${dirPath}': 目录不存在; - * - 'fail not a directory ${dirPath}': dirPath 不是目录; - * - 'fail permission denied, open ${dirPath}': 指定的 filePath 路径没有读权限; */ - errMsg: string - } - interface ReaddirOption { - /** 要读取的目录路径 (本地路径) */ - dirPath: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ReaddirCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: ReaddirFailCallback - /** 接口调用成功的回调函数 */ - success?: ReaddirSuccessCallback - } - interface ReaddirSuccessCallbackResult { - /** 指定目录下的文件名数组。 */ - files: string[] - errMsg: string - } - interface RecorderManagerOnErrorCallbackResult { - /** 错误信息 */ - errMsg: string - } - interface RecorderManagerStartOption { - /** 指定录音的音频输入源,可通过 [wx.getAvailableAudioSources()](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.getAvailableAudioSources.html) 获取当前可用的音频源 + * 触发一个事件 */ + emit: undefined + /** [EventChannel.off(string eventName, function fn)](https://developers.weixin.qq.com/miniprogram/dev/api/route/EventChannel.off.html) * - * 可选值: - * - 'auto': 自动设置,默认使用手机麦克风,插上耳麦后自动切换使用耳机麦克风,所有平台适用; - * - 'buildInMic': 手机麦克风,仅限 iOS; - * - 'headsetMic': 耳机麦克风,仅限 iOS; - * - 'mic': 麦克风(没插耳麦时是手机麦克风,插耳麦时是耳机麦克风),仅限 Android; - * - 'camcorder': 同 mic,适用于录制音视频内容,仅限 Android; - * - 'voice_communication': 同 mic,适用于实时沟通,仅限 Android; - * - 'voice_recognition': 同 mic,适用于语音识别,仅限 Android; + * 需要基础库: `2.7.3` * - * 最低基础库: `2.1.0` */ - audioSource?: - | 'auto' - | 'buildInMic' - | 'headsetMic' - | 'mic' - | 'camcorder' - | 'voice_communication' - | 'voice_recognition' - /** 录音的时长,单位 ms,最大值 600000(10 分钟) */ - duration?: number - /** 编码码率,有效值见下表格 */ - encodeBitRate?: number - /** 音频格式 + * 在插件中使用:支持 * - * 可选值: - * - 'mp3': mp3 格式; - * - 'aac': aac 格式; - * - 'wav': wav 格式; - * - 'PCM': pcm 格式; */ - format?: 'mp3' | 'aac' | 'wav' | 'PCM' - /** 指定帧大小,单位 KB。传入 frameSize 后,每录制指定帧大小的内容后,会回调录制的文件内容,不指定则不会回调。暂仅支持 mp3 格式。 */ - frameSize?: number - /** 录音通道数 + * 取消监听一个事件。给出第二个参数时,只取消给出的监听函数,否则取消所有监听函数 */ + off: undefined + /** [EventChannel.on(string eventName, function fn)](https://developers.weixin.qq.com/miniprogram/dev/api/route/EventChannel.on.html) * - * 可选值: - * - 1: 1 个通道; - * - 2: 2 个通道; */ - numberOfChannels?: 1 | 2 - /** 采样率 + * 需要基础库: `2.7.3` * - * 可选值: - * - 8000: 8000 采样率; - * - 11025: 11025 采样率; - * - 12000: 12000 采样率; - * - 16000: 16000 采样率; - * - 22050: 22050 采样率; - * - 24000: 24000 采样率; - * - 32000: 32000 采样率; - * - 44100: 44100 采样率; - * - 48000: 48000 采样率; */ - sampleRate?: - | 8000 - | 11025 - | 12000 - | 16000 - | 22050 - | 24000 - | 32000 - | 44100 - | 48000 - } - /** 菜单按钮的布局位置信息 */ - interface Rect { - /** 下边界坐标,单位:px */ - bottom: number - /** 高度,单位:px */ - height: number - /** 左边界坐标,单位:px */ - left: number - /** 右边界坐标,单位:px */ - right: number - /** 上边界坐标,单位:px */ - top: number - /** 宽度,单位:px */ - width: number - } - interface RedirectToOption { - /** 需要跳转的应用内非 tabBar 的页面的路径 (代码包路径), 路径后可以带参数。参数与路径之间使用 `?` 分隔,参数键与参数值用 `=` 相连,不同参数用 `&` 分隔;如 'path?key=value&key2=value2' */ - url: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: RedirectToCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: RedirectToFailCallback - /** 接口调用成功的回调函数 */ - success?: RedirectToSuccessCallback - } - interface RedoOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: RedoCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: RedoFailCallback - /** 接口调用成功的回调函数 */ - success?: RedoSuccessCallback - } - /** 参照区域的边界 */ - interface RelativeRectResult { - /** 下边界 */ - bottom: number - /** 左边界 */ - left: number - /** 右边界 */ - right: number - /** 上边界 */ - top: number - } - /** 用来扩展(或收缩)参照节点布局区域的边界 */ - interface RelativeToMargins { - /** 节点布局区域的下边界 */ - bottom?: number - /** 节点布局区域的左边界 */ - left?: number - /** 节点布局区域的右边界 */ - right?: number - /** 节点布局区域的上边界 */ - top?: number - } - /** 用来扩展(或收缩)参照节点布局区域的边界 */ - interface RelativeToViewportMargins { - /** 节点布局区域的下边界 */ - bottom?: number - /** 节点布局区域的左边界 */ - left?: number - /** 节点布局区域的右边界 */ - right?: number - /** 节点布局区域的上边界 */ - top?: number - } - /** 消息来源的结构化信息 */ - interface RemoteInfo { - /** 发送消息的 socket 的地址 */ - address: string - /** 使用的协议族,为 IPv4 或者 IPv6 */ - family: string - /** 端口号 */ - port: number - /** message 的大小,单位:字节 */ - size: number - } - interface RemoveFormatOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: RemoveFormatCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: RemoveFormatFailCallback - /** 接口调用成功的回调函数 */ - success?: RemoveFormatSuccessCallback - } - interface RemoveSavedFileFailCallbackResult { - /** 错误信息 + * 在插件中使用:支持 * - * 可选值: - * - 'fail file not exist': 指定的 tempFilePath 找不到文件; */ - errMsg: string - } - interface RemoveStorageOption { - /** 本地缓存中指定的 key */ - key: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: RemoveStorageCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: RemoveStorageFailCallback - /** 接口调用成功的回调函数 */ - success?: RemoveStorageSuccessCallback - } - interface RemoveTabBarBadgeOption { - /** tabBar 的哪一项,从左边算起 */ - index: number - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: RemoveTabBarBadgeCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: RemoveTabBarBadgeFailCallback - /** 接口调用成功的回调函数 */ - success?: RemoveTabBarBadgeSuccessCallback - } - interface RenameFailCallbackResult { - /** 错误信息 + * 持续监听一个事件 */ + on: undefined + /** [EventChannel.once(string eventName, function fn)](https://developers.weixin.qq.com/miniprogram/dev/api/route/EventChannel.once.html) * - * 可选值: - * - 'fail permission denied, rename ${oldPath} -> ${newPath}': 指定源文件或目标文件没有写权限; - * - 'fail no such file or directory, rename ${oldPath} -> ${newPath}': 源文件不存在,或目标文件路径的上层目录不存在; */ - errMsg: string + * 需要基础库: `2.7.3` + * + * 在插件中使用:支持 + * + * 监听一个事件一次,触发后失效 */ + once: undefined } - interface RenameOption { - /** 新文件路径,支持本地路径 */ - newPath: string - /** 源文件路径,支持本地路径 */ - oldPath: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: RenameCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: RenameFailCallback - /** 接口调用成功的回调函数 */ - success?: RenameSuccessCallback + interface EntryList { + /** [Array.<[PerformanceEntry](https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/PerformanceEntry.html)> EntryList.getEntries()](https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/EntryList.getEntries.html) + * + * 需要基础库: `2.11.0` + * + * 在插件中使用:不支持 + * + * 该方法返回当前列表中的所有性能数据 */ + getEntries(): PerformanceEntry[] + /** [Array.<[PerformanceEntry](https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/PerformanceEntry.html)> EntryList.getEntriesByName(string name, string entryType)](https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/EntryList.getEntriesByName.html) + * + * 需要基础库: `2.11.0` + * + * 在插件中使用:不支持 + * + * 获取当前列表中所有名称为 [name] 且类型为 [entryType] 的性能数据 */ + getEntriesByName( + name: string, + entryType?: string + ): PerformanceEntry[] + /** [Array.<[PerformanceEntry](https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/PerformanceEntry.html)> EntryList.getEntriesByType(string entryType)](https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/EntryList.getEntriesByType.html) + * + * 需要基础库: `2.11.0` + * + * 在插件中使用:不支持 + * + * 获取当前列表中所有类型为 [entryType] 的性能数据 */ + getEntriesByType(entryType: string): PerformanceEntry[] } - /** Canvas 绘图上下文。 - * - * **** - * - * - 通过 Canvas.getContext('2d') 接口可以获取 CanvasRenderingContext2D 对象,实现了 [HTML Canvas 2D Context](https://www.w3.org/TR/2dcontext/) 定义的属性、方法。 - * - 通过 Canvas.getContext('webgl') 或 OffscreenCanvas.getContext('webgl') 接口可以获取 WebGLRenderingContext 对象,实现了 [WebGL 1.0](https://www.khronos.org/registry/webgl/specs/latest/1.0/) 定义的所有属性、方法、常量。 */ - interface RenderingContext {} - interface RequestOption { - /** 开发者服务器接口地址 */ - url: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: RequestCompleteCallback - /** 请求的参数 */ - data?: string | IAnyObject | ArrayBuffer - /** 返回的数据格式 + interface EventChannel { + /** [EventChannel.emit(string eventName, any args)](https://developers.weixin.qq.com/miniprogram/dev/api/route/EventChannel.emit.html) + * + * 需要基础库: `2.7.3` + * + * 在插件中使用:支持 + * + * 触发一个事件 */ + emit( + /** 事件名称 */ + eventName: string, + /** 事件参数 */ + ...args: any + ): void + /** [EventChannel.off(string eventName, function fn)](https://developers.weixin.qq.com/miniprogram/dev/api/route/EventChannel.off.html) + * + * 需要基础库: `2.7.3` + * + * 在插件中使用:支持 + * + * 取消监听一个事件。给出第二个参数时,只取消给出的监听函数,否则取消所有监听函数 */ + off( + /** 事件名称 */ + eventName: string, + /** 事件监听函数 */ + fn: EventCallback + ): void + /** [EventChannel.on(string eventName, function fn)](https://developers.weixin.qq.com/miniprogram/dev/api/route/EventChannel.on.html) + * + * 需要基础库: `2.7.3` + * + * 在插件中使用:支持 + * + * 持续监听一个事件 */ + on( + /** 事件名称 */ + eventName: string, + /** 事件监听函数 */ + fn: EventCallback + ): void + /** [EventChannel.once(string eventName, function fn)](https://developers.weixin.qq.com/miniprogram/dev/api/route/EventChannel.once.html) * - * 可选值: - * - 'json': 返回的数据为 JSON,返回后会对返回的数据进行一次 JSON.parse; - * - '其他': 不对返回的内容进行 JSON.parse; */ - dataType?: 'json' | '其他' - /** 接口调用失败的回调函数 */ - fail?: RequestFailCallback - /** 设置请求的 header,header 中不能设置 Referer。 + * 需要基础库: `2.7.3` * - * `content-type` 默认为 `application/json` */ - header?: IAnyObject - /** HTTP 请求方法 + * 在插件中使用:支持 * - * 可选值: - * - 'OPTIONS': HTTP 请求 OPTIONS; - * - 'GET': HTTP 请求 GET; - * - 'HEAD': HTTP 请求 HEAD; - * - 'POST': HTTP 请求 POST; - * - 'PUT': HTTP 请求 PUT; - * - 'DELETE': HTTP 请求 DELETE; - * - 'TRACE': HTTP 请求 TRACE; - * - 'CONNECT': HTTP 请求 CONNECT; */ - method?: - | 'OPTIONS' - | 'GET' - | 'HEAD' - | 'POST' - | 'PUT' - | 'DELETE' - | 'TRACE' - | 'CONNECT' - /** 响应的数据类型 + * 监听一个事件一次,触发后失效 */ + once( + /** 事件名称 */ + eventName: string, + /** 事件监听函数 */ + fn: EventCallback + ): void + } + interface FileError { + /** 错误信息 * - * 可选值: - * - 'text': 响应的数据为文本; - * - 'arraybuffer': 响应的数据为 ArrayBuffer; + * | 错误码 | 错误信息 | 说明 | + * | - | - | - | + * | 1300001 | operation not permitted | 操作不被允许(例如,filePath 预期传入一个文件而实际传入一个目录) | + * | 1300002 | no such file or directory ${path} | 文件/目录不存在,或者目标文件路径的上层目录不存在 | + * | 1300005 | Input/output error | 输入输出流不可用 | + * | 1300009 | bad file descriptor | 无效的文件描述符 | + * | 1300013 | permission denied | 权限错误,文件是只读或只写 | + * | 1300014 | Path permission denied | 传入的路径没有权限 | + * | 1300020 | not a directory | dirPath 指定路径不是目录,常见于指定的写入路径的上级路径为一个文件的情况 | + * | 1300021 | Is a directory | 指定路径是一个目录 | + * | 1300022 | Invalid argument | 无效参数,可以检查length或offset是否越界 | + * | 1300036 | File name too long | 文件名过长 | + * | 1300066 | directory not empty | 目录不为空 | + * | 1300201 | system error | 系统接口调用失败 | + * | 1300202 | the maximum size of the file storage limit is exceeded | 存储空间不足,或文件大小超出上限(上限100M) | + * | 1300203 | base64 encode error | 字符编码转换失败(例如 base64 格式错误) | + * | 1300300 | sdcard not mounted | android sdcard 挂载失败 | + * | 1300301 | unable to open as fileType | 无法以fileType打开文件 | + * | 1301000 | permission denied, cannot access file path | 目标路径无访问权限(usr目录) | + * | 1301002 | data to write is empty | 写入数据为空 | + * | 1301003 | illegal operation on a directory | 不可对目录进行此操作(例如,指定的 filePath 是一个已经存在的目录) | + * | 1301004 | illegal operation on a package directory | 不可对代码包目录进行此操作 | + * | 1301005 | file already exists ${dirPath} | 已有同名文件或目录 | + * | 1301006 | value of length is out of range | 传入的 length 不合法 | + * | 1301007 | value of offset is out of range | 传入的 offset 不合法 | + * | 1301009 | value of position is out of range | position值越界 | + * | 1301100 | store directory is empty | store目录为空 | + * | 1301102 | unzip open file fail | 压缩文件打开失败 | + * | 1301103 | unzip entry fail | 解压单个文件失败 | + * | 1301104 | unzip fail | 解压失败 | + * | 1301111 | brotli decompress fail | brotli解压失败(例如,指定的 compressionAlgorithm 与文件实际压缩格式不符) | + * | 1301112 | tempFilePath file not exist | 指定的 tempFilePath 找不到文件 | + * | 1302001 | fail permission denied | 指定的 fd 路径没有读权限/没有写权限 | + * | 1302002 | excced max concurrent fd limit | fd数量已达上限 | + * | 1302003 | invalid flag | 无效的flag | + * | 1302004 | permission denied when open using flag | 无法使用flag标志打开文件 | + * | 1302005 | array buffer does not exist | 未传入arrayBuffer | + * | 1302100 | array buffer is readonly | arrayBuffer只读 | */ errMsg: string + /** 错误码 * - * 最低基础库: `1.7.0` */ - responseType?: 'text' | 'arraybuffer' - /** 接口调用成功的回调函数 */ - success?: RequestSuccessCallback - /** 超时时间,单位为毫秒 + * | 错误码 | 错误信息 | 说明 | + * | - | - | - | + * | 1300001 | operation not permitted | 操作不被允许(例如,filePath 预期传入一个文件而实际传入一个目录) | + * | 1300002 | no such file or directory ${path} | 文件/目录不存在,或者目标文件路径的上层目录不存在 | + * | 1300005 | Input/output error | 输入输出流不可用 | + * | 1300009 | bad file descriptor | 无效的文件描述符 | + * | 1300013 | permission denied | 权限错误,文件是只读或只写 | + * | 1300014 | Path permission denied | 传入的路径没有权限 | + * | 1300020 | not a directory | dirPath 指定路径不是目录,常见于指定的写入路径的上级路径为一个文件的情况 | + * | 1300021 | Is a directory | 指定路径是一个目录 | + * | 1300022 | Invalid argument | 无效参数,可以检查length或offset是否越界 | + * | 1300036 | File name too long | 文件名过长 | + * | 1300066 | directory not empty | 目录不为空 | + * | 1300201 | system error | 系统接口调用失败 | + * | 1300202 | the maximum size of the file storage limit is exceeded | 存储空间不足,或文件大小超出上限(上限100M) | + * | 1300203 | base64 encode error | 字符编码转换失败(例如 base64 格式错误) | + * | 1300300 | sdcard not mounted | android sdcard 挂载失败 | + * | 1300301 | unable to open as fileType | 无法以fileType打开文件 | + * | 1301000 | permission denied, cannot access file path | 目标路径无访问权限(usr目录) | + * | 1301002 | data to write is empty | 写入数据为空 | + * | 1301003 | illegal operation on a directory | 不可对目录进行此操作(例如,指定的 filePath 是一个已经存在的目录) | + * | 1301004 | illegal operation on a package directory | 不可对代码包目录进行此操作 | + * | 1301005 | file already exists ${dirPath} | 已有同名文件或目录 | + * | 1301006 | value of length is out of range | 传入的 length 不合法 | + * | 1301007 | value of offset is out of range | 传入的 offset 不合法 | + * | 1301009 | value of position is out of range | position值越界 | + * | 1301100 | store directory is empty | store目录为空 | + * | 1301102 | unzip open file fail | 压缩文件打开失败 | + * | 1301103 | unzip entry fail | 解压单个文件失败 | + * | 1301104 | unzip fail | 解压失败 | + * | 1301111 | brotli decompress fail | brotli解压失败(例如,指定的 compressionAlgorithm 与文件实际压缩格式不符) | + * | 1301112 | tempFilePath file not exist | 指定的 tempFilePath 找不到文件 | + * | 1302001 | fail permission denied | 指定的 fd 路径没有读权限/没有写权限 | + * | 1302002 | excced max concurrent fd limit | fd数量已达上限 | + * | 1302003 | invalid flag | 无效的flag | + * | 1302004 | permission denied when open using flag | 无法使用flag标志打开文件 | + * | 1302005 | array buffer does not exist | 未传入arrayBuffer | + * | 1302100 | array buffer is readonly | arrayBuffer只读 | */ errCode: number + } + interface FileSystemManager { + /** [Array.<string> FileSystemManager.readdirSync(string dirPath)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readdirSync.html) +* +* 在插件中使用:需要基础库 `2.19.2` +* +* [FileSystemManager.readdir](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readdir.html) 的同步版本 +* +* **注意事项** +* +* - readdir接口无法访问文件系统根路径(wxfile://)。 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +fs.readdir({ + dirPath: `${wx.env.USER_DATA_PATH}/example`, + success(res) { + console.log(res.files) + }, + fail(res) { + console.error(res) + } +}) + +// 同步接口 +try { + const res = fs.readdirSync(`${wx.env.USER_DATA_PATH}/example`) + console.log(res) +} catch(e) { + console.error(e) +} +``` */ + readdirSync( + /** 要读取的目录路径 (本地路径) */ + dirPath: string + ): string[] + /** [ArrayBuffer FileSystemManager.readCompressedFileSync(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readCompressedFileSync.html) +* +* 需要基础库: `2.21.1` +* +* 在插件中使用:不支持 +* +* 同步读取指定压缩类型的本地文件内容 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() + +// 异步接口 +fs.readCompressedFile({ + filePath: '${wx.env.USER_DATA_PATH}/hello.br', + compressionAlgorithm: 'br', + success(res) { + console.log(res.data) + }, + fail(res) { + console.log('readCompressedFile fail', res) + } +}) + +// 同步接口 +try { + const data = fs.readCompressedFileSync({ + filePath: '${wx.env.USER_DATA_PATH}/hello.br', + compressionAlgorithm: 'br', + }) + console.log(data) +} catch (err) { + console.log(err) +} +``` */ + readCompressedFileSync( + option: ReadCompressedFileSyncOption + ): ArrayBuffer + /** [FileSystemManager.access(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.access.html) +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 判断文件/目录是否存在 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +// 判断文件/目录是否存在 +fs.access({ + path: `${wx.env.USER_DATA_PATH}/hello.txt`, + success(res) { + // 文件存在 + console.log(res) + }, + fail(res) { + // 文件不存在或其他错误 + console.error(res) + } +}) + +// 同步接口 +try { + fs.accessSync(`${wx.env.USER_DATA_PATH}/hello.txt`) +} catch(e) { + console.error(e) +} +``` */ + access(option: AccessOption): void + /** [FileSystemManager.accessSync(string path)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.accessSync.html) +* +* 在插件中使用:需要基础库 `2.19.2` +* +* [FileSystemManager.access](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.access.html) 的同步版本 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +// 判断文件/目录是否存在 +fs.access({ + path: `${wx.env.USER_DATA_PATH}/hello.txt`, + success(res) { + // 文件存在 + console.log(res) + }, + fail(res) { + // 文件不存在或其他错误 + console.error(res) + } +}) + +// 同步接口 +try { + fs.accessSync(`${wx.env.USER_DATA_PATH}/hello.txt`) +} catch(e) { + console.error(e) +} +``` */ + accessSync( + /** 要判断是否存在的文件/目录路径 (本地路径) */ + path: string + ): void + /** [FileSystemManager.appendFile(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.appendFile.html) +* +* 需要基础库: `2.1.0` +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 在文件结尾追加内容 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() + +fs.appendFile({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + data: 'some text', + encoding: 'utf8', + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } +}) + +// 同步接口 +try { + fs.appendFileSync(`${wx.env.USER_DATA_PATH}/hello.txt`, 'some text', 'utf8') +} catch(e) { + console.error(e) +} +``` */ + appendFile(option: AppendFileOption): void + /** [FileSystemManager.appendFileSync(string filePath, string|ArrayBuffer data, string encoding)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.appendFileSync.html) +* +* 需要基础库: `2.1.0` +* +* 在插件中使用:需要基础库 `2.19.2` +* +* [FileSystemManager.appendFile](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.appendFile.html) 的同步版本 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() + +fs.appendFile({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + data: 'some text', + encoding: 'utf8', + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } +}) + +// 同步接口 +try { + fs.appendFileSync(`${wx.env.USER_DATA_PATH}/hello.txt`, 'some text', 'utf8') +} catch(e) { + console.error(e) +} +``` */ + appendFileSync( + /** 要追加内容的文件路径 (本地路径) */ + filePath: string, + /** 要追加的文本或二进制数据 */ + data: string | ArrayBuffer, + /** 指定写入文件的字符编码 + * + * 参数 encoding 可选值: + * - 'ascii': ; + * - 'base64': ; + * - 'binary': ; + * - 'hex': ; + * - 'ucs2': 以小端序读取; + * - 'ucs-2': 以小端序读取; + * - 'utf16le': 以小端序读取; + * - 'utf-16le': 以小端序读取; + * - 'utf-8': ; + * - 'utf8': ; + * - 'latin1': ; */ + encoding?: + | 'ascii' + | 'base64' + | 'binary' + | 'hex' + | 'ucs2' + | 'ucs-2' + | 'utf16le' + | 'utf-16le' + | 'utf-8' + | 'utf8' + | 'latin1' + ): void + /** [FileSystemManager.close(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.close.html) +* +* 需要基础库: `2.16.1` +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 关闭文件 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +// 打开文件 +fs.open({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+', + success(res) { + // 关闭文件 + fs.close({ + fd: res.fd + }) + } +}) +``` */ + close(option: FileSystemManagerCloseOption): void + /** [FileSystemManager.copyFile(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.copyFile.html) +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 复制文件 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +fs.copyFile({ + srcPath: `${wx.env.USER_DATA_PATH}/hello.txt`, + destPath: `${wx.env.USER_DATA_PATH}/hello_copy.txt` + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } +}) + +// 同步接口 +try { + fs.copyFileSync( + `${wx.env.USER_DATA_PATH}/hello.txt`, + `${wx.env.USER_DATA_PATH}/hello_copy.txt` + ) +} catch(e) { + console.error(e) +} +``` */ + copyFile(option: CopyFileOption): void + /** [FileSystemManager.copyFileSync(string srcPath, string destPath)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.copyFileSync.html) +* +* 在插件中使用:需要基础库 `2.19.2` +* +* [FileSystemManager.copyFile](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.copyFile.html) 的同步版本 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +fs.copyFile({ + srcPath: `${wx.env.USER_DATA_PATH}/hello.txt`, + destPath: `${wx.env.USER_DATA_PATH}/hello_copy.txt` + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } +}) + +// 同步接口 +try { + fs.copyFileSync( + `${wx.env.USER_DATA_PATH}/hello.txt`, + `${wx.env.USER_DATA_PATH}/hello_copy.txt` + ) +} catch(e) { + console.error(e) +} +``` */ + copyFileSync( + /** 源文件路径,支持本地路径 */ + srcPath: string, + /** 目标文件路径,支持本地路径 */ + destPath: string + ): void + /** [FileSystemManager.fstat(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.fstat.html) +* +* 需要基础库: `2.16.1` +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 获取文件的状态信息 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +// 打开文件 +fs.open({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+', + success(res) { + // 获取文件的状态信息 + fs.fstat({ + fd: res.fd, + success(res) { + console.log(res.stats) + } + }) + } +}) +``` */ + fstat(option: FstatOption): void + /** [FileSystemManager.ftruncate(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.ftruncate.html) +* +* 需要基础库: `2.16.1` +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 对文件内容进行截断操作 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +// 打开文件 +fs.open({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+', + success(res) { + // 对文件内容进行截断操作 + fs.ftruncate({ + fd: res.fd, + length: 10, // 从第10个字节开始截断文件 + success(res) { + console.log(res) + } + }) + } +}) +``` */ + ftruncate(option: FtruncateOption): void + /** [FileSystemManager.getFileInfo(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.getFileInfo.html) * - * 最低基础库: `2.10.0` */ - timeout?: number - } - interface RequestPaymentOption { - /** 随机字符串,长度为32个字符以下 */ - nonceStr: string - /** 统一下单接口返回的 prepay_id 参数值,提交格式如:prepay_id=*** */ - package: string - /** 签名,具体签名方案参见 [小程序支付接口文档](https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=7_7&index=3) */ - paySign: string - /** 时间戳,从 1970 年 1 月 1 日 00:00:00 至今的秒数,即当前的时间 */ - timeStamp: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: RequestPaymentCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: RequestPaymentFailCallback - /** 签名算法 + * 在插件中使用:不支持 * - * 可选值: - * - 'MD5': MD5; - * - 'HMAC-SHA256': HMAC-SHA256; */ - signType?: 'MD5' | 'HMAC-SHA256' - /** 接口调用成功的回调函数 */ - success?: RequestPaymentSuccessCallback - } - interface RequestSubscribeMessageFailCallbackResult { - /** 接口调用失败错误码 */ - errCode: number - /** 接口调用失败错误信息 */ - errMsg: string - } - interface RequestSubscribeMessageOption { - /** 需要订阅的消息模板的id的集合,一次调用最多可订阅3条消息(注意:iOS客户端7.0.6版本、Android客户端7.0.7版本之后的一次性订阅/长期订阅才支持多个模板消息,iOS客户端7.0.5版本、Android客户端7.0.6版本之前的一次订阅只支持一个模板消息)消息模板id在[微信公众平台(mp.weixin.qq.com)-功能-订阅消息]中配置 - * - * #### 错误码(errCode) - * | errCode | errMsg | 说明 | - * | ------- | ------------------------------------------------------ | -------------------------------------------------------------- | - * | 10001 | TmplIds can't be empty | 参数传空了 | - * | 10002 | Request list fai | 网络问题,请求消息列表失败 | - * | 10003 | Request subscribe fail | 网络问题,订阅请求发送失败 | - * | 10004 | Invalid template id | 参数类型错误 | - * | 10005 | Cannot show subscribe message UI | 无法展示 UI,一般是小程序这个时候退后台了导致的 | - * | 20001 | No template data return, verify the template id exist | 没有模板数据,一般是模板 ID 不存在 或者和模板类型不对应 导致的 | - * | 20002 | Templates type must be same | 模板消息类型 既有一次性的又有永久的 | - * | 20003 | Templates count out of max bounds | 模板消息数量超过上限 | - * | 20004 | The main switch is switched off | 用户关闭了主开关,无法进行订阅 | - * | 20005 | This mini program was banned from subscribing messages | 小程序被禁封 | */ - tmplIds: any[] - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: RequestSubscribeMessageCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: RequestSubscribeMessageFailCallback - /** 接口调用成功的回调函数 */ - success?: RequestSubscribeMessageSuccessCallback - } - interface RequestSubscribeMessageSuccessCallbackResult { - /** [TEMPLATE_ID]是动态的键,即模板id,值包括'accept'、'reject'、'ban'。'accept'表示用户同意订阅该条id对应的模板消息,'reject'表示用户拒绝订阅该条id对应的模板消息,'ban'表示已被后台封禁。例如 { errMsg: "requestSubscribeMessage:ok", zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE: "accept"} 表示用户同意订阅zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE这条消息 */ - TEMPLATE_ID: string - /** 接口调用成功时errMsg值为'requestSubscribeMessage:ok' */ - errMsg: string - } - interface RequestSuccessCallbackResult { - /** 开发者服务器返回的 cookies,格式为字符串数组 + * 获取该小程序下的 本地临时文件 或 本地缓存文件 信息 */ + getFileInfo(option: GetFileInfoOption): void + /** [FileSystemManager.getSavedFileList(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.getSavedFileList.html) * - * 最低基础库: `2.10.0` */ - cookies: string[] - /** 开发者服务器返回的数据 */ - data: string | IAnyObject | ArrayBuffer - /** 开发者服务器返回的 HTTP Response Header + * 在插件中使用:不支持 * - * 最低基础库: `1.2.0` */ - header: IAnyObject - /** 开发者服务器返回的 HTTP 状态码 */ - statusCode: number - errMsg: string - } - interface RequestTaskOnHeadersReceivedCallbackResult { - /** 开发者服务器返回的 HTTP Response Header */ - header: IAnyObject - } - /** 来源信息。从另一个小程序、公众号或 App 进入小程序时返回。否则返回 `{}`。(参见后文注意) */ - interface ResultReferrerInfo { - /** 来源小程序、公众号或 App 的 appId */ - appId: string - /** 来源小程序传过来的数据,scene=1037或1038时支持 */ - extraData: IAnyObject - } - interface ResumeBGMOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ResumeBGMCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: ResumeBGMFailCallback - /** 接口调用成功的回调函数 */ - success?: ResumeBGMSuccessCallback - } - interface RewardedVideoAdOnCloseCallbackResult { - /** 视频是否是在用户完整观看的情况下被关闭的 + * 获取该小程序下已保存的本地缓存文件列表 */ + getSavedFileList(option?: GetSavedFileListOption): void + /** [FileSystemManager.mkdir(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.mkdir.html) +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 创建目录 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +fs.mkdir({ + dirPath: `${wx.env.USER_DATA_PATH}/example`, + recursive: false, + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } +}) + +// 同步接口 +try { + fs.mkdirSync(`${wx.env.USER_DATA_PATH}/example`, false) +} catch(e) { + console.error(e) +} +``` */ + mkdir(option: MkdirOption): void + /** [FileSystemManager.mkdirSync(string dirPath, boolean recursive)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.mkdirSync.html) +* +* 在插件中使用:需要基础库 `2.19.2` +* +* [FileSystemManager.mkdir](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.mkdir.html) 的同步版本 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +fs.mkdir({ + dirPath: `${wx.env.USER_DATA_PATH}/example`, + recursive: false, + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } +}) + +// 同步接口 +try { + fs.mkdirSync(`${wx.env.USER_DATA_PATH}/example`, false) +} catch(e) { + console.error(e) +} +``` */ + mkdirSync( + /** 创建的目录路径 (本地路径) */ + dirPath: string, + /** 需要基础库: `2.3.0` + * + * 是否在递归创建该目录的上级目录后再创建该目录。如果对应的上级目录已经存在,则不创建该上级目录。如 dirPath 为 a/b/c/d 且 recursive 为 true,将创建 a 目录,再在 a 目录下创建 b 目录,以此类推直至创建 a/b/c 目录下的 d 目录。 */ + recursive?: boolean + ): void + /** [FileSystemManager.open(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.open.html) +* +* 需要基础库: `2.16.1` +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 打开文件,返回文件描述符 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +fs.open({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+', + success(res) { + console.log(res.fd) + } +}) +``` */ + open(option: OpenOption): void + /** [FileSystemManager.read(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.read.html) +* +* 需要基础库: `2.16.1` +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 读文件 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +const ab = new ArrayBuffer(1024) +// 打开文件 +fs.open({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+', + success(res) { + // 读取文件到 ArrayBuffer 中 + fs.read({ + fd: res.fd, + arrayBuffer: ab, + length: 10, + success(res) { + console.log(res) + } + }) + } +}) +``` +* ## 注意事项 +* - 小游戏 iOS 高性能模式(iOSHighPerformance)暂不支持 FileSystemManager.read 接口,请使用 FileSystemManager.readFile 接口代替 */ + read(option: ReadOption): void + /** [FileSystemManager.readCompressedFile(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readCompressedFile.html) +* +* 需要基础库: `2.21.1` +* +* 在插件中使用:不支持 +* +* 读取指定压缩类型的本地文件内容 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() + +// 异步接口 +fs.readCompressedFile({ + filePath: '${wx.env.USER_DATA_PATH}/hello.br', + compressionAlgorithm: 'br', + success(res) { + console.log(res.data) + }, + fail(res) { + console.log('readCompressedFile fail', res) + } +}) + +// 同步接口 +const data = fs.readCompressedFileSync({ + filePath: '${wx.env.USER_DATA_PATH}/hello.br', + compressionAlgorithm: 'br', +}) +console.log(data) +``` */ + readCompressedFile(option: ReadCompressedFileOption): void + /** [FileSystemManager.readFile(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readFile.html) +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 读取本地文件内容。单个文件大小上限为100M。 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +fs.readFile({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + encoding: 'utf8', + position: 0, + success(res) { + console.log(res.data) + }, + fail(res) { + console.error(res) + } +}) + +// 同步接口 +try { + const res = fs.readFileSync(`${wx.env.USER_DATA_PATH}/hello.txt`, 'utf8', 0) + console.log(res) +} catch(e) { + console.error(e) +} +``` */ + readFile(option: ReadFileOption): void + /** [FileSystemManager.readZipEntry(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readZipEntry.html) +* +* 需要基础库: `2.17.3` +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 读取压缩包内的文件 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +// 读取zip内某个或多个文件 +fs.readZipEntry({ + filePath: 'wxfile://from/to.zip', + entries: [{ + path: 'some_folder/my_file.txt', // zip内文件路径 + encoding: 'utf-8', // 指定读取文件的字符编码,如果不传 encoding,则以 ArrayBuffer 格式读取文件的二进制内容 + position: 0, // 从文件指定位置开始读,如果不指定,则从文件头开始读。读取的范围应该是左闭右开区间 [position, position+length)。有效范围:[0, fileLength - 1]。单位:byte + length: 10000, // 指定文件的长度,如果不指定,则读到文件末尾。有效范围:[1, fileLength]。单位:byte + }, { + path: 'other_folder/orther_file.txt', // zip内文件路径 + }], + success(res) { + console.log(res.entries) + // res.entries === { + // 'some_folder/my_file.txt': { + // errMsg: 'readZipEntry:ok', + // data: 'xxxxxx' + // }, + // 'other_folder/orther_file.txt': { + // data: (ArrayBuffer) + // } + // } + }, + fail(res) { + console.log(res.errMsg) + }, +}) + +// 读取zip内所有文件。允许指定统一的encoding。position、length则不再允许指定,分别默认为0和文件长度 +fs.readZipEntry({ + filePath: 'wxfile://from/to.zip', + entries: 'all' + encoding: 'utf-8', // 统一指定读取文件的字符编码,如果不传 encoding,则以 ArrayBuffer 格式读取文件的二进制内容 + success(res) { + console.log(res.entries) + // res.entries === { + // 'some_folder/my_file.txt': { + // errMsg: 'readZipEntry:ok', + // data: 'xxxxxx' + // }, + // 'other_folder/orther_file.txt': { + // errMsg: 'readZipEntry:ok', + // data: 'xxxxxx' + // } + // } + }, + fail(res) { + console.log(res.errMsg) + }, +}) +``` */ + readZipEntry(option: ReadZipEntryOption): void + /** [FileSystemManager.readdir(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readdir.html) +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 读取目录内文件列表 +* +* **注意事项** +* +* - readdir接口无法访问文件系统根路径(wxfile://)。 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +fs.readdir({ + dirPath: `${wx.env.USER_DATA_PATH}/example`, + success(res) { + console.log(res.files) + }, + fail(res) { + console.error(res) + } +}) + +// 同步接口 +try { + const res = fs.readdirSync(`${wx.env.USER_DATA_PATH}/example`) + console.log(res) +} catch(e) { + console.error(e) +} +``` */ + readdir(option: ReaddirOption): void + /** [FileSystemManager.removeSavedFile(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.removeSavedFile.html) * - * 最低基础库: `2.1.0` */ - isEnded: boolean - } - interface RewardedVideoAdOnErrorCallbackResult { - /** 错误码 + * 在插件中使用:不支持 * - * 可选值: - * - 1000: 后端接口调用失败; - * - 1001: 参数错误; - * - 1002: 广告单元无效; - * - 1003: 内部错误; - * - 1004: 无合适的广告; - * - 1005: 广告组件审核中; - * - 1006: 广告组件被驳回; - * - 1007: 广告组件被封禁; - * - 1008: 广告单元已关闭; + * 删除该小程序下已保存的本地缓存文件 */ + removeSavedFile(option: RemoveSavedFileOption): void + /** [FileSystemManager.rename(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.rename.html) +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 重命名文件。可以把文件从 oldPath 移动到 newPath +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +fs.rename({ + oldPath: `${wx.env.USER_DATA_PATH}/hello.txt`, + newPath: `${wx.env.USER_DATA_PATH}/hello_new.txt`, + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } +}) + +// 同步接口 +try { + const res = fs.renameSync( + `${wx.env.USER_DATA_PATH}/hello.txt`, + `${wx.env.USER_DATA_PATH}/hello_new.txt` + ) + console.log(res) +} catch(e) { + console.error(e) +} +``` */ + rename(option: RenameOption): void + /** [FileSystemManager.renameSync(string oldPath, string newPath)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.renameSync.html) +* +* 在插件中使用:需要基础库 `2.19.2` +* +* [FileSystemManager.rename](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.rename.html) 的同步版本 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +fs.rename({ + oldPath: `${wx.env.USER_DATA_PATH}/hello.txt`, + newPath: `${wx.env.USER_DATA_PATH}/hello_new.txt`, + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } +}) + +// 同步接口 +try { + const res = fs.renameSync( + `${wx.env.USER_DATA_PATH}/hello.txt`, + `${wx.env.USER_DATA_PATH}/hello_new.txt` + ) + console.log(res) +} catch(e) { + console.error(e) +} +``` */ + renameSync( + /** 源文件路径,支持本地路径 */ + oldPath: string, + /** 新文件路径,支持本地路径 */ + newPath: string + ): void + /** [FileSystemManager.rmdir(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.rmdir.html) +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 删除目录 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +fs.rmdir({ + dirPath: `${wx.env.USER_DATA_PATH}/example`, + recursive: false, + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } +}) + +// 同步接口 +try { + const res = fs.rmdirSync(`${wx.env.USER_DATA_PATH}/example`, false) + console.log(res) +} catch(e) { + console.error(e) +} +``` */ + rmdir(option: RmdirOption): void + /** [FileSystemManager.rmdirSync(string dirPath, boolean recursive)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.rmdirSync.html) +* +* 在插件中使用:需要基础库 `2.19.2` +* +* [FileSystemManager.rmdir](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.rmdir.html) 的同步版本 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +fs.rmdir({ + dirPath: `${wx.env.USER_DATA_PATH}/example`, + recursive: false, + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } +}) + +// 同步接口 +try { + const res = fs.rmdirSync(`${wx.env.USER_DATA_PATH}/example`, false) + console.log(res) +} catch(e) { + console.error(e) +} +``` */ + rmdirSync( + /** 要删除的目录路径 (本地路径) */ + dirPath: string, + /** 需要基础库: `2.3.0` + * + * 是否递归删除目录。如果为 true,则删除该目录和该目录下的所有子目录以及文件。 */ + recursive?: boolean + ): void + /** [FileSystemManager.saveFile(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.saveFile.html) * - * 最低基础库: `2.2.2` */ - errCode: 1000 | 1001 | 1002 | 1003 | 1004 | 1005 | 1006 | 1007 | 1008 - /** 错误信息 */ - errMsg: string - } - interface RmdirFailCallbackResult { - /** 错误信息 + * 在插件中使用:不支持 * - * 可选值: - * - 'fail no such file or directory ${dirPath}': 目录不存在; - * - 'fail directory not empty': 目录不为空; - * - 'fail permission denied, open ${dirPath}': 指定的 dirPath 路径没有写权限; */ - errMsg: string - } - interface RmdirOption { - /** 要删除的目录路径 (本地路径) */ - dirPath: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: RmdirCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: RmdirFailCallback - /** 是否递归删除目录。如果为 true,则删除该目录和该目录下的所有子目录以及文件。 + * 保存临时文件到本地。此接口会移动临时文件,因此调用成功后,tempFilePath 将不可用。 */ + saveFile(option: SaveFileOption): void + /** [FileSystemManager.stat(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.stat.html) * - * 最低基础库: `2.3.0` */ - recursive?: boolean - /** 接口调用成功的回调函数 */ - success?: RmdirSuccessCallback - } - /** 在竖屏正方向下的安全区域 - * - * 最低基础库: `2.7.0` */ - interface SafeAreaResult { - /** 安全区域右下角纵坐标 */ - bottom: number - /** 安全区域的高度,单位逻辑像素 */ - height: number - /** 安全区域左上角横坐标 */ - left: number - /** 安全区域右下角横坐标 */ - right: number - /** 安全区域左上角纵坐标 */ - top: number - /** 安全区域的宽度,单位逻辑像素 */ - width: number - } - interface SaveFileFailCallbackResult { - /** 错误信息 + * 在插件中使用:需要基础库 `2.19.2` * - * 可选值: - * - 'fail tempFilePath file not exist': 指定的 tempFilePath 找不到文件; - * - 'fail permission denied, open "${filePath}"': 指定的 filePath 路径没有写权限; - * - 'fail no such file or directory "${dirPath}"': 上级目录不存在; - * - 'fail the maximum size of the file storage limit is exceeded': 存储空间不足; */ - errMsg: string - } - interface SaveImageToPhotosAlbumOption { - /** 图片文件路径,可以是临时文件路径或永久文件路径 (本地路径) ,不支持网络路径 */ - filePath: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SaveImageToPhotosAlbumCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SaveImageToPhotosAlbumFailCallback - /** 接口调用成功的回调函数 */ - success?: SaveImageToPhotosAlbumSuccessCallback - } - interface SaveVideoToPhotosAlbumOption { - /** 视频文件路径,可以是临时文件路径也可以是永久文件路径 (本地路径) */ - filePath: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SaveVideoToPhotosAlbumCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SaveVideoToPhotosAlbumFailCallback - /** 接口调用成功的回调函数 */ - success?: SaveVideoToPhotosAlbumSuccessCallback - } - interface ScanCodeOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ScanCodeCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: ScanCodeFailCallback - /** 是否只能从相机扫码,不允许从相册选择图片 + * 获取文件 Stats 对象 */ + stat(option: StatOption): void + /** [FileSystemManager.truncate(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.truncate.html) +* +* 需要基础库: `2.16.1` +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 对文件内容进行截断操作 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +fs.truncate({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + length: 10, // 从第10个字节开始截断 + success(res) { + console.log(res) + } +}) +``` */ + truncate(option: TruncateOption): void + /** [FileSystemManager.unlink(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.unlink.html) +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 删除文件 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +fs.unlink({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } +}) + +// 同步接口 +try { + const res = fs.unlinkSync(`${wx.env.USER_DATA_PATH}/hello.txt`) + console.log(res) +} catch(e) { + console.error(e) +} +``` */ + unlink(option: UnlinkOption): void + /** [FileSystemManager.unlinkSync(string filePath)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.unlinkSync.html) +* +* 在插件中使用:需要基础库 `2.19.2` +* +* [FileSystemManager.unlink](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.unlink.html) 的同步版本 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +fs.unlink({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } +}) + +// 同步接口 +try { + const res = fs.unlinkSync(`${wx.env.USER_DATA_PATH}/hello.txt`) + console.log(res) +} catch(e) { + console.error(e) +} +``` */ + unlinkSync( + /** 要删除的文件路径 (本地路径) */ + filePath: string + ): void + /** [FileSystemManager.unzip(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.unzip.html) +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 解压文件 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +fs.unzip({ + zipFilePath: `${wx.env.USER_DATA_PATH}/example.zip`, + targetPath: '${wx.env.USER_DATA_PATH}/example', + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } +}) +``` */ + unzip(option: UnzipOption): void + /** [FileSystemManager.write(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.write.html) +* +* 需要基础库: `2.16.1` +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 写入文件 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +// 打开文件 +fs.open({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+', + success(res) { + // 写入文件 + fs.write({ + fd: res.fd, + data: 'some text', + success(res) { + console.log(res.bytesWritten) + } + }) + } +}) +``` */ + write(option: WriteOption): void + /** [FileSystemManager.writeFile(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.writeFile.html) +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 写文件 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +fs.writeFile({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + data: 'some text or arrayBuffer', + encoding: 'utf8', + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } +}) + +// 同步接口 +try { + const res = fs.writeFileSync( + `${wx.env.USER_DATA_PATH}/hello.txt`, + 'some text or arrayBuffer', + 'utf8' + ) + console.log(res) +} catch(e) { + console.error(e) +} +``` */ + writeFile(option: WriteFileOption): void + /** [FileSystemManager.writeFileSync(string filePath, string|ArrayBuffer data, string encoding)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.writeFileSync.html) +* +* 在插件中使用:需要基础库 `2.19.2` +* +* [FileSystemManager.writeFile](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.writeFile.html) 的同步版本 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +fs.writeFile({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + data: 'some text or arrayBuffer', + encoding: 'utf8', + success(res) { + console.log(res) + }, + fail(res) { + console.error(res) + } +}) + +// 同步接口 +try { + const res = fs.writeFileSync( + `${wx.env.USER_DATA_PATH}/hello.txt`, + 'some text or arrayBuffer', + 'utf8' + ) + console.log(res) +} catch(e) { + console.error(e) +} +``` */ + writeFileSync( + /** 要写入的文件路径 (本地路径) */ + filePath: string, + /** 要写入的文本或二进制数据 */ + data: string | ArrayBuffer, + /** 指定写入文件的字符编码 + * + * 参数 encoding 可选值: + * - 'ascii': ; + * - 'base64': (注意,选择 base64 编码,data 只需要传 base64 内容本身,不要传 Data URI 前缀,否则会报 fail base64 encode error 错误。例如,传 aGVsbG8= 而不是传 data:image/png;base64,aGVsbG8= ); + * - 'binary': ; + * - 'hex': ; + * - 'ucs2': 以小端序读取; + * - 'ucs-2': 以小端序读取; + * - 'utf16le': 以小端序读取; + * - 'utf-16le': 以小端序读取; + * - 'utf-8': ; + * - 'utf8': ; + * - 'latin1': ; */ + encoding?: + | 'ascii' + | 'base64' + | 'binary' + | 'hex' + | 'ucs2' + | 'ucs-2' + | 'utf16le' + | 'utf-16le' + | 'utf-8' + | 'utf8' + | 'latin1' + ): void + /** [[ReadResult](https://developers.weixin.qq.com/miniprogram/dev/api/file/ReadResult.html) FileSystemManager.readSync(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readSync.html) +* +* 需要基础库: `2.16.1` +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 读文件 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +const ab = new ArrayBuffer(1024) +const fd = fs.openSync({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+' +}) +const res = fs.readSync({ + fd: fd, + arrayBuffer: ab, + length: 10 +}) +console.log(res) +``` +* ## 注意事项 +* - 小游戏 iOS 高性能模式(iOSHighPerformance)暂不支持 FileSystemManager.readSync 接口,请使用 FileSystemManager.readFileSync 接口代替 */ + readSync(option: ReadSyncOption): ReadResult + /** [[Stats](https://developers.weixin.qq.com/miniprogram/dev/api/file/Stats.html) FileSystemManager.fstatSync(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.fstatSync.html) +* +* 需要基础库: `2.16.1` +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 同步获取文件的状态信息 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +const fd = fs.openSync({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+' +}) +const stats = fs.fstatSync({fd: fd}) +console.log(stats) +``` */ + fstatSync(option: FstatSyncOption): Stats + /** [[Stats](https://developers.weixin.qq.com/miniprogram/dev/api/file/Stats.html)|Array.<[FileStats](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileStats.html)> FileSystemManager.statSync(string path, boolean recursive)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.statSync.html) * - * 最低基础库: `1.2.0` */ - onlyFromCamera?: boolean - /** 扫码类型 + * 在插件中使用:需要基础库 `2.19.2` * - * 可选值: - * - 'barCode': 一维码; - * - 'qrCode': 二维码; - * - 'datamatrix': Data Matrix 码; - * - 'pdf417': PDF417 条码; + * [FileSystemManager.stat](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.stat.html) 的同步版本 */ + statSync( + /** 文件/目录路径 (本地路径) */ + path: string, + /** 需要基础库: `2.3.0` + * + * 是否递归获取目录下的每个文件的 Stats 信息 */ + recursive?: boolean + ): Stats | FileStats[] + /** [[WriteResult](https://developers.weixin.qq.com/miniprogram/dev/api/file/WriteResult.html) FileSystemManager.writeSync(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.writeSync.html) +* +* 需要基础库: `2.16.1` +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 同步写入文件 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +const fd = fs.openSync({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+' +}) +const res = fs.writeSync({ + fd: fd, + data: 'some text' +}) +console.log(res.bytesWritten) +``` */ + writeSync(option: WriteSyncOption): WriteResult + /** [string FileSystemManager.openSync(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.openSync.html) +* +* 需要基础库: `2.16.1` +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 同步打开文件,返回文件描述符 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +const fd = fs.openSync({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+' +}) +console.log(fd) +``` */ + openSync(option: OpenSyncOption): string + /** [string FileSystemManager.saveFileSync(string tempFilePath, string filePath)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.saveFileSync.html) * - * 最低基础库: `1.7.0` */ - scanType?: Array<'barCode' | 'qrCode' | 'datamatrix' | 'pdf417'> - /** 接口调用成功的回调函数 */ - success?: ScanCodeSuccessCallback - } - interface ScanCodeSuccessCallbackResult { - /** 所扫码的字符集 */ - charSet: string - /** 当所扫的码为当前小程序二维码时,会返回此字段,内容为二维码携带的 path */ - path: string - /** 原始数据,base64编码 */ - rawData: string - /** 所扫码的内容 */ - result: string - /** 所扫码的类型 + * 在插件中使用:不支持 * - * 可选值: - * - 'QR_CODE': 二维码; - * - 'AZTEC': 一维码; - * - 'CODABAR': 一维码; - * - 'CODE_39': 一维码; - * - 'CODE_93': 一维码; - * - 'CODE_128': 一维码; - * - 'DATA_MATRIX': 二维码; - * - 'EAN_8': 一维码; - * - 'EAN_13': 一维码; - * - 'ITF': 一维码; - * - 'MAXICODE': 一维码; - * - 'PDF_417': 二维码; - * - 'RSS_14': 一维码; - * - 'RSS_EXPANDED': 一维码; - * - 'UPC_A': 一维码; - * - 'UPC_E': 一维码; - * - 'UPC_EAN_EXTENSION': 一维码; - * - 'WX_CODE': 二维码; - * - 'CODE_25': 一维码; */ - scanType: - | 'QR_CODE' - | 'AZTEC' - | 'CODABAR' - | 'CODE_39' - | 'CODE_93' - | 'CODE_128' - | 'DATA_MATRIX' - | 'EAN_8' - | 'EAN_13' - | 'ITF' - | 'MAXICODE' - | 'PDF_417' - | 'RSS_14' - | 'RSS_EXPANDED' - | 'UPC_A' - | 'UPC_E' - | 'UPC_EAN_EXTENSION' - | 'WX_CODE' - | 'CODE_25' - errMsg: string - } - interface ScrollOffsetCallbackResult { - /** 节点的 dataset */ - dataset: IAnyObject - /** 节点的 ID */ - id: string - /** 节点的水平滚动位置 */ - scrollLeft: number - /** 节点的竖直滚动位置 */ - scrollTop: number - } - interface SeekBackgroundAudioOption { - /** 音乐位置,单位:秒 */ - position: number - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SeekBackgroundAudioCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SeekBackgroundAudioFailCallback - /** 接口调用成功的回调函数 */ - success?: SeekBackgroundAudioSuccessCallback - } - interface SendHCEMessageOption { - /** 二进制数据 */ - data: ArrayBuffer - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SendHCEMessageCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SendHCEMessageFailCallback - /** 接口调用成功的回调函数 */ - success?: SendHCEMessageSuccessCallback - } - interface SendSocketMessageOption { - /** 需要发送的内容 */ - data: string | ArrayBuffer - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SendSocketMessageCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SendSocketMessageFailCallback - /** 接口调用成功的回调函数 */ - success?: SendSocketMessageSuccessCallback - } - /** 描述service的Object */ - interface Service { - /** characteristics列表 */ - characteristics: Characteristic[] - /** service 的 uuid */ - uuid: string - } - interface SetBGMVolumeOption { - /** 音量大小,范围是 0-1 */ - volume: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetBGMVolumeCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SetBGMVolumeFailCallback - /** 接口调用成功的回调函数 */ - success?: SetBGMVolumeSuccessCallback - } - interface SetBackgroundColorOption { - /** 窗口的背景色,必须为十六进制颜色值 */ - backgroundColor?: string - /** 底部窗口的背景色,必须为十六进制颜色值,仅 iOS 支持 */ - backgroundColorBottom?: string - /** 顶部窗口的背景色,必须为十六进制颜色值,仅 iOS 支持 */ - backgroundColorTop?: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetBackgroundColorCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SetBackgroundColorFailCallback - /** 接口调用成功的回调函数 */ - success?: SetBackgroundColorSuccessCallback - } - interface SetBackgroundFetchTokenOption { - /** 自定义的登录态 */ - token: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetBackgroundFetchTokenCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SetBackgroundFetchTokenFailCallback - /** 接口调用成功的回调函数 */ - success?: SetBackgroundFetchTokenSuccessCallback + * [FileSystemManager.saveFile](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.saveFile.html) 的同步版本 */ + saveFileSync( + /** 临时存储文件路径 (本地路径) */ + tempFilePath: string, + /** 要存储的文件路径 (本地路径) */ + filePath?: string + ): string + /** [string|ArrayBuffer FileSystemManager.readFileSync(string filePath, string encoding, number position, number length)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readFileSync.html) +* +* 在插件中使用:需要基础库 `2.19.2` +* +* [FileSystemManager.readFile](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readFile.html) 的同步版本 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +fs.readFile({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + encoding: 'utf8', + position: 0, + success(res) { + console.log(res.data) + }, + fail(res) { + console.error(res) + } +}) + +// 同步接口 +try { + const res = fs.readFileSync(`${wx.env.USER_DATA_PATH}/hello.txt`, 'utf8', 0) + console.log(res) +} catch(e) { + console.error(e) +} +``` */ + readFileSync( + /** 要读取的文件的路径 (本地路径) */ + filePath: string, + /** 指定读取文件的字符编码,如果不传 encoding,则以 ArrayBuffer 格式读取文件的二进制内容 + * + * 参数 encoding 可选值: + * - 'ascii': ; + * - 'base64': ; + * - 'binary': ; + * - 'hex': ; + * - 'ucs2': 以小端序读取; + * - 'ucs-2': 以小端序读取; + * - 'utf16le': 以小端序读取; + * - 'utf-16le': 以小端序读取; + * - 'utf-8': ; + * - 'utf8': ; + * - 'latin1': ; */ + encoding?: + | 'ascii' + | 'base64' + | 'binary' + | 'hex' + | 'ucs2' + | 'ucs-2' + | 'utf16le' + | 'utf-16le' + | 'utf-8' + | 'utf8' + | 'latin1', + /** 需要基础库: `2.10.0` + * + * 从文件指定位置开始读,如果不指定,则从文件头开始读。读取的范围应该是左闭右开区间 [position, position+length)。有效范围:[0, fileLength - 1]。单位:byte */ + position?: number, + /** 需要基础库: `2.10.0` + * + * 指定文件的长度,如果不指定,则读到文件末尾。有效范围:[1, fileLength]。单位:byte */ + length?: number + ): string | ArrayBuffer + /** [undefined FileSystemManager.closeSync(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.closeSync.html) +* +* 需要基础库: `2.16.1` +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 同步关闭文件 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +const fd = fs.openSync({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+' +}) + +// 关闭文件 +fs.closeSync({fd: fd}) +``` */ + closeSync(option: CloseSyncOption): undefined + /** [undefined FileSystemManager.ftruncateSync(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.ftruncateSync.html) +* +* 需要基础库: `2.16.1` +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 对文件内容进行截断操作 +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +const fd = fs.openSync({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + flag: 'a+' +}) +fs.ftruncateSync({ + fd: fd, + length: 10 // 从第10个字节开始截断文件 +}) +``` */ + ftruncateSync(option: FtruncateSyncOption): undefined + /** [undefined FileSystemManager.truncateSync(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.truncateSync.html) +* +* 需要基础库: `2.16.1` +* +* 在插件中使用:需要基础库 `2.19.2` +* +* 对文件内容进行截断操作 (truncate 的同步版本) +* +* **示例代码** +* +* ```js +const fs = wx.getFileSystemManager() +fs.truncateSync({ + filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, + length: 10, // 从第10个字节开始截断 +}) +``` */ + truncateSync(option: TruncateSyncOption): undefined } - interface SetBackgroundTextStyleOption { - /** 下拉背景字体、loading 图的样式。 + interface GetGroupEnterInfoError { + /** 错误信息 * - * 可选值: - * - 'dark': dark 样式; - * - 'light': light 样式; */ - textStyle: 'dark' | 'light' - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetBackgroundTextStyleCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SetBackgroundTextStyleFailCallback - /** 接口调用成功的回调函数 */ - success?: SetBackgroundTextStyleSuccessCallback - } - interface SetCenterOffsetOption { - /** 偏移量,两位数组 */ - offset: number[] - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetCenterOffsetCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SetCenterOffsetFailCallback - /** 接口调用成功的回调函数 */ - success?: SetCenterOffsetSuccessCallback - } - interface SetClipboardDataOption { - /** 剪贴板的内容 */ - data: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetClipboardDataCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SetClipboardDataFailCallback - /** 接口调用成功的回调函数 */ - success?: SetClipboardDataSuccessCallback - } - interface SetContentsOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetContentsCompleteCallback - /** 表示内容的delta对象 */ - delta?: IAnyObject - /** 接口调用失败的回调函数 */ - fail?: SetContentsFailCallback - /** 带标签的HTML内容 */ - html?: string - /** 接口调用成功的回调函数 */ - success?: SetContentsSuccessCallback - } - interface SetEnableDebugOption { - /** 是否打开调试 */ - enableDebug: boolean - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetEnableDebugCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SetEnableDebugFailCallback - /** 接口调用成功的回调函数 */ - success?: SetEnableDebugSuccessCallback - } - interface SetInnerAudioOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetInnerAudioOptionCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SetInnerAudioOptionFailCallback - /** 是否与其他音频混播,设置为 true 之后,不会终止其他应用或微信内的音乐 */ - mixWithOther?: boolean - /** (仅在 iOS 生效)是否遵循静音开关,设置为 false 之后,即使是在静音模式下,也能播放声音 */ - obeyMuteSwitch?: boolean - /** 接口调用成功的回调函数 */ - success?: SetInnerAudioOptionSuccessCallback + * | 错误码 | 错误信息 | 说明 | + * | - | - | - | + * | 40097 | | 场景错误 | + * | 65206 | | 用户已不在该群内 | */ errMsg: string + /** 错误码 + * + * | 错误码 | 错误信息 | 说明 | + * | - | - | - | + * | 40097 | | 场景错误 | + * | 65206 | | 用户已不在该群内 | */ errCode: number } - interface SetKeepScreenOnOption { - /** 是否保持屏幕常亮 */ - keepScreenOn: boolean - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetKeepScreenOnCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SetKeepScreenOnFailCallback - /** 接口调用成功的回调函数 */ - success?: SetKeepScreenOnSuccessCallback + interface InferenceSession { + /** [InferenceSession.destroy()](https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/InferenceSession.destroy.html) +* +* 需要基础库: `2.30.0` +* +* 在插件中使用:需要基础库 `2.30.0` +* +* 销毁 InferenceSession 实例 +* +* **示例代码** +* +* ```js +// 销毁会话 +session.destroy() +``` */ + destroy(): void + /** [InferenceSession.offError(function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/InferenceSession.offError.html) + * + * 需要基础库: `2.30.0` + * + * 在插件中使用:需要基础库 `2.30.0` + * + * 取消监听模型加载失败事件 */ + offError( + /** 模型加载失败回调函数。传入指定回调函数则只取消指定回调,不传则取消所有回调 */ + callback: (...args: any[]) => any + ): void + /** [InferenceSession.offLoad(function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/InferenceSession.offLoad.html) + * + * 需要基础库: `2.30.0` + * + * 在插件中使用:需要基础库 `2.30.0` + * + * 取消监听模型加载完成事件 */ + offLoad( + /** 模型加载完成回调函数。传入指定回调函数则只取消指定回调,不传则取消所有回调 */ + callback: (...args: any[]) => any + ): void + /** [InferenceSession.onError(function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/InferenceSession.onError.html) +* +* 需要基础库: `2.30.0` +* +* 在插件中使用:需要基础库 `2.30.0` +* +* 监听模型加载失败事件 +* +* **示例代码** +* +* ```js +// 创建会话,加载模型 +const session = wx.createInferenceSession({ + model: `${wx.env.USER_DATA_PATH}/MNIST.onnx`, + precisionLevel: 4, + typicalShape:{input1:[1, 3, 224, 224], input2:[1, 1, 224, 224]}, //除非使用动态轴,一般不用显式指定 + allowNPU: false, + allowQuantize: false +}) + +// 监听error事件 +session.onError(err => { + console.error(err) +}) +``` */ + onError( + /** 模型加载失败回调函数 */ + callback: (...args: any[]) => any + ): void + /** [InferenceSession.onLoad(function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/InferenceSession.onLoad.html) +* +* 需要基础库: `2.30.0` +* +* 在插件中使用:需要基础库 `2.30.0` +* +* 监听模型加载完成事件 +* +* **示例代码** +* +* ```js +// 创建会话,加载模型 +const session = wx.createInferenceSession({ + model: `${wx.env.USER_DATA_PATH}/MNIST.onnx`, + precisionLevel: 4, + typicalShape:{input1:[1, 3, 224, 224], input2:[1, 1, 224, 224]}, //除非使用动态轴,一般不用显式指定 + allowNPU: false, + allowQuantize: false +}) + +// 监听模型加载完成事件 +session.onLoad(() => { + // 运行推理 + // 其中input1, input2, output0 必须与使用的onnx模型中实际的输入输出名字完全一致,不可随意填写。 + // 模型输入输出信息可以通过Netron 打开onnx模型看到 + session.run({ + input1: { + type: 'float32', + data: new Float32Array(3 * 224 * 224).buffer, + shape: [1, 3, 224, 224] // NCHW 顺序 + }, + // 多个input的添加方法,假设第二个input需要数据类型为uint8 + input2: { + type: 'uint8', + data: new Uint8Array(224 * 224).buffer, + shape: [1, 1, 224, 224] + }, + }).then(res => { + console.log(res.output0) + }) +}) +``` */ + onLoad( + /** 模型加载完成回调函数 */ + callback: (...args: any[]) => any + ): void + /** [Promise<[Tensors](https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/Tensors.html)> InferenceSession.run([Tensors](https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/Tensors.html) tensors)](https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/InferenceSession.run.html) +* +* 需要基础库: `2.30.0` +* +* 在插件中使用:需要基础库 `2.30.0` +* +* 运行推断。需要在 session.onLoad 回调后使用。接口参数为 Tensors 对象,返回 Promise。一个 InferenceSession 被创建完成后可以重复多次调用 InferenceSession.run(), 直到调用 session.destroy() 进行销毁。 +* +* **示例代码** +* +* ```js +// 创建会话,加载模型 +const session = wx.createInferenceSession({ + model: `${wx.env.USER_DATA_PATH}/MNIST.onnx`, + precisionLevel: 4, + typicalShape:{input1:[1, 3, 224, 224], input2:[1, 1, 224, 224]}, //除非使用动态轴,一般不用显式指定 + allowNPU: false, + allowQuantize: false +}) + +// 监听模型加载完成事件 +session.onLoad(() => { + // 运行推理 + // 其中input1, input2, output0 必须与使用的onnx模型中实际的输入输出名字完全一致,不可随意填写。 + // 模型输入输出信息可以通过Netron 打开onnx模型看到 + session.run({ + input1: { + type: 'float32', + data: new Float32Array(3 * 224 * 224).buffer, + shape: [1, 3, 224, 224] // NCHW 顺序 + }, + // 多个input的添加方法,假设第二个input需要数据类型为uint8 + input2: { + type: 'uint8', + data: new Uint8Array(224 * 224).buffer, + shape: [1, 1, 224, 224] + }, + }).then(res => { + console.log(res.output0) + }) +}) +``` */ + run( + /** [Tensors](https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/Tensors.html) + * + * key-value 形式的对象,对象的 key 会作为 input name,对象的 value 则是 Tensor。 Tensor 结构如下。 */ + tensors: Tensors + ): Promise } - interface SetMICVolumeOption { - /** 音量大小,范围是 0.0-1.0 */ - volume: number - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetMICVolumeCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SetMICVolumeFailCallback - /** 接口调用成功的回调函数 */ - success?: SetMICVolumeSuccessCallback + interface IntersectionObserver { + /** [IntersectionObserver.disconnect()](https://developers.weixin.qq.com/miniprogram/dev/api/wxml/IntersectionObserver.disconnect.html) + * + * 在插件中使用:支持 + * + * 停止监听。回调函数将不再触发 */ + disconnect(): void + /** [IntersectionObserver.observe(string targetSelector, function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/wxml/IntersectionObserver.observe.html) + * + * 在插件中使用:支持 + * + * 指定目标节点并开始监听相交状态变化情况 */ + observe( + /** 选择器 */ + targetSelector: string, + /** 监听相交状态变化的回调函数 */ + callback: IntersectionObserverObserveCallback + ): void + /** [[IntersectionObserver](https://developers.weixin.qq.com/miniprogram/dev/api/wxml/IntersectionObserver.html) IntersectionObserver.relativeTo(string selector, Object margins)](https://developers.weixin.qq.com/miniprogram/dev/api/wxml/IntersectionObserver.relativeTo.html) + * + * 在插件中使用:支持 + * + * 使用选择器指定一个节点,作为参照区域之一。 */ + relativeTo( + /** 选择器 */ + selector: string, + /** 用来扩展(或收缩)参照节点布局区域的边界 */ + margins?: Margins + ): IntersectionObserver + /** [[IntersectionObserver](https://developers.weixin.qq.com/miniprogram/dev/api/wxml/IntersectionObserver.html) IntersectionObserver.relativeToViewport(Object margins)](https://developers.weixin.qq.com/miniprogram/dev/api/wxml/IntersectionObserver.relativeToViewport.html) +* +* 在插件中使用:支持 +* +* 指定页面显示区域作为参照区域之一 +* +* **示例代码** +* +* 下面的示例代码中,如果目标节点(用选择器 .target-class 指定)进入显示区域以下 100px 时,就会触发回调函数。 +* ```javascript +Page({ + onLoad: function(){ + wx.createIntersectionObserver().relativeToViewport({bottom: 100}).observe('.target-class', (res) => { + res.intersectionRatio // 相交区域占目标节点的布局区域的比例 + res.intersectionRect // 相交区域 + res.intersectionRect.left // 相交区域的左边界坐标 + res.intersectionRect.top // 相交区域的上边界坐标 + res.intersectionRect.width // 相交区域的宽度 + res.intersectionRect.height // 相交区域的高度 + }) + } +}) +``` */ + relativeToViewport( + /** 用来扩展(或收缩)参照节点布局区域的边界 */ + margins?: Margins + ): IntersectionObserver } - interface SetNavigationBarColorOption { - /** 背景颜色值,有效值为十六进制颜色 */ - backgroundColor: string - /** 前景颜色值,包括按钮、标题、状态栏的颜色,仅支持 #ffffff 和 #000000 */ - frontColor: string - /** 动画效果 */ - animation?: AnimationOption - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetNavigationBarColorCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SetNavigationBarColorFailCallback - /** 接口调用成功的回调函数 */ - success?: SetNavigationBarColorSuccessCallback + interface InterstitialAd { + /** [InterstitialAd.destroy()](https://developers.weixin.qq.com/miniprogram/dev/api/ad/InterstitialAd.destroy.html) + * + * 需要基础库: `2.8.0` + * + * 在插件中使用:不支持 + * + * 销毁插屏广告实例。 */ + destroy(): void + /** [InterstitialAd.offClose(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/ad/InterstitialAd.offClose.html) +* +* 在插件中使用:不支持 +* +* 移除插屏广告关闭事件的监听函数 +* +* **示例代码** +* +* ```js +const listener = function (res) { console.log(res) } + +InterstitialAd.onClose(listener) +InterstitialAd.offClose(listener) // 需传入与监听时同一个的函数对象 +``` */ + offClose( + /** onClose 传入的监听函数。不传此参数则移除所有监听函数。 */ + listener?: UDPSocketOffCloseCallback + ): void + /** [InterstitialAd.offError(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/ad/InterstitialAd.offError.html) +* +* 在插件中使用:不支持 +* +* 移除插屏错误事件的监听函数 +* +* **示例代码** +* +* ```js +const listener = function (res) { console.log(res) } + +InterstitialAd.onError(listener) +InterstitialAd.offError(listener) // 需传入与监听时同一个的函数对象 +``` */ + offError( + /** onError 传入的监听函数。不传此参数则移除所有监听函数。 */ + listener?: InterstitialAdOffErrorCallback + ): void + /** [InterstitialAd.offLoad(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/ad/InterstitialAd.offLoad.html) +* +* 在插件中使用:不支持 +* +* 移除插屏广告加载事件的监听函数 +* +* **示例代码** +* +* ```js +const listener = function (res) { console.log(res) } + +InterstitialAd.onLoad(listener) +InterstitialAd.offLoad(listener) // 需传入与监听时同一个的函数对象 +``` */ + offLoad( + /** onLoad 传入的监听函数。不传此参数则移除所有监听函数。 */ + listener?: OffLoadCallback + ): void + /** [InterstitialAd.onClose(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/ad/InterstitialAd.onClose.html) + * + * 在插件中使用:不支持 + * + * 监听插屏广告关闭事件。 */ + onClose( + /** 插屏广告关闭事件的监听函数 */ + listener: UDPSocketOnCloseCallback + ): void + /** [InterstitialAd.onError(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/ad/InterstitialAd.onError.html) + * + * 在插件中使用:不支持 + * + * 监听插屏错误事件。 + * + * **错误码信息与解决方案表** + * + * 错误码是通过onError获取到的错误信息。调试期间,可以通过异常返回来捕获信息。可以针对异常返回加上适当的监控信息辅助排查现网情况。 + * + * | 代码 | 异常情况 | 理由 | 解决方案 | + * | ------ | -------------- | --------------- | -------------------------- | + * | 1000 | 后端错误调用失败 | 该项错误不是开发者的异常情况 | 一般情况下忽略一段时间即可恢复。 | + * | 1001 | 参数错误 | 使用方法错误 | 可以前往developers.weixin.qq.com确认具体教程(小程序和小游戏分别有各自的教程,可以在顶部选项中,“设计”一栏的右侧进行切换。| + * | 1002 | 广告单元无效 | 可能是拼写错误、或者误用了其他APP的广告ID | 请重新前往mp.weixin.qq.com确认广告位ID。 | + * | 1003 | 内部错误 | 该项错误不是开发者的异常情况 | 一般情况下忽略一段时间即可恢复。| + * | 1004 | 无适合的广告 | 广告不是每一次都会出现,这次没有出现可能是由于该用户不适合浏览广告 | 属于正常情况,且开发者需要针对这种情况做形态上的兼容。 | + * | 1005 | 广告组件审核中 | 你的广告正在被审核,无法展现广告 | 请前往mp.weixin.qq.com确认审核状态,且开发者需要针对这种情况做形态上的兼容。| + * | 1006 | 广告组件被驳回 | 你的广告审核失败,无法展现广告 | 请前往mp.weixin.qq.com确认审核状态,且开发者需要针对这种情况做形态上的兼容。| + * | 1007 | 广告组件被封禁 | 你的广告能力已经被封禁,封禁期间无法展现广告 | 请前往mp.weixin.qq.com确认小程序广告封禁状态。 | + * | 1008 | 广告单元已关闭 | 该广告位的广告能力已经被关闭 | 请前往mp.weixin.qq.com重新打开对应广告位的展现。| */ + onError( + /** 插屏错误事件的监听函数 */ + listener: InterstitialAdOnErrorCallback + ): void + /** [InterstitialAd.onLoad(function listener)](https://developers.weixin.qq.com/miniprogram/dev/api/ad/InterstitialAd.onLoad.html) + * + * 在插件中使用:不支持 + * + * 监听插屏广告加载事件。 */ + onLoad( + /** 插屏广告加载事件的监听函数 */ + listener: OnLoadCallback + ): void + /** [Promise InterstitialAd.load()](https://developers.weixin.qq.com/miniprogram/dev/api/ad/InterstitialAd.load.html) + * + * 需要基础库: `2.8.0` + * + * 在插件中使用:不支持 + * + * 加载插屏广告。 */ + load(): Promise + /** [Promise InterstitialAd.show()](https://developers.weixin.qq.com/miniprogram/dev/api/ad/InterstitialAd.show.html) + * + * 在插件中使用:不支持 + * + * 显示插屏广告。 + * + * **错误码信息表** + * + * 如果插屏广告显示失败,InterstitialAd.show() 方法会返回一个rejected Promise,开发者可以获取到错误码及对应的错误信息。 + * + * | 代码 | 异常情况 | 理由 | + * | ------ | -------------- | -------------------------- | + * | 2001 | 触发频率限制 | 小程序启动一定时间内不允许展示插屏广告 | + * | 2002 | 触发频率限制 | 距离小程序插屏广告或者激励视频广告上次播放时间间隔不足,不允许展示插屏广告 | + * | 2003 | 触发频率限制 | 当前正在播放激励视频广告或者插屏广告,不允许再次展示插屏广告 | + * | 2004 | 广告渲染失败 | 该项错误不是开发者的异常情况,或因小程序页面切换导致广告渲染失败 | + * | 2005 | 广告调用异常 | 插屏广告实例不允许跨页面调用 | */ + show(): Promise } - interface SetNavigationBarTitleOption { - /** 页面标题 */ - title: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetNavigationBarTitleCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SetNavigationBarTitleFailCallback - /** 接口调用成功的回调函数 */ - success?: SetNavigationBarTitleSuccessCallback + interface IsoDep { + /** [IsoDep.close(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/IsoDep.close.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 断开连接 */ + close(option?: NdefCloseOption): void + /** [IsoDep.connect(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/IsoDep.connect.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 连接 NFC 标签 */ + connect(option?: NdefConnectOption): void + /** [IsoDep.getHistoricalBytes(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/IsoDep.getHistoricalBytes.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 获取复位信息 */ + getHistoricalBytes(option?: GetHistoricalBytesOption): void + /** [IsoDep.getMaxTransceiveLength(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/IsoDep.getMaxTransceiveLength.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 获取最大传输长度 */ + getMaxTransceiveLength(option?: GetMaxTransceiveLengthOption): void + /** [IsoDep.isConnected(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/IsoDep.isConnected.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * @warning **该接口已废弃,连接状态开发者自行维护即可** + * + * 检查是否已连接 */ + isConnected(option?: IsConnectedOption): void + /** [IsoDep.setTimeout(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/IsoDep.setTimeout.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 设置超时时间 */ + setTimeout(option: SetTimeoutOption): void + /** [IsoDep.transceive(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/IsoDep.transceive.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 发送数据 */ + transceive(option: TransceiveOption): void } - interface SetScreenBrightnessOption { - /** 屏幕亮度值,范围 0 ~ 1。0 最暗,1 最亮 */ - value: number - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetScreenBrightnessCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SetScreenBrightnessFailCallback - /** 接口调用成功的回调函数 */ - success?: SetScreenBrightnessSuccessCallback + interface Join1v1ChatError { + /** 错误信息 + * + * | 错误码 | 错误信息 | 说明 | + * | - | - | - | + * | -20000 | not open 1v1 Chat | 未开通双人通话 | + * | -20001 | device not support | 当前设备不支持 | + * | -20002 | on call | 正在通话中 | + * | -20003 | occupied by other miniprogram | 其它小程序正在通话中 | + * | -30000 | system error | 内部系统错误 | + * | -30001 | wechat has no camera authorization | 微信缺失相机权限 | + * | -30002 | wechat has no record authorization | 微信缺失录音权限 | + * | -30003 | miniprogram has no record authorization | 小程序缺失录音权限 | + * | -30004 | miniprogram has no camera authorization | 小程序缺失相机权限 | + * | -1 | | 当前已在房间内 | + * | -2 | | 录音设备被占用,可能是当前正在使用微信内语音通话或系统通话 | + * | -3 | | 加入会话期间退出(可能是用户主动退出,或者退后台、来电等原因),因此加入失败 | + * | -1000 | | 系统错误 | */ errMsg: string + /** 错误码 + * + * | 错误码 | 错误信息 | 说明 | + * | - | - | - | + * | -20000 | not open 1v1 Chat | 未开通双人通话 | + * | -20001 | device not support | 当前设备不支持 | + * | -20002 | on call | 正在通话中 | + * | -20003 | occupied by other miniprogram | 其它小程序正在通话中 | + * | -30000 | system error | 内部系统错误 | + * | -30001 | wechat has no camera authorization | 微信缺失相机权限 | + * | -30002 | wechat has no record authorization | 微信缺失录音权限 | + * | -30003 | miniprogram has no record authorization | 小程序缺失录音权限 | + * | -30004 | miniprogram has no camera authorization | 小程序缺失相机权限 | + * | -1 | | 当前已在房间内 | + * | -2 | | 录音设备被占用,可能是当前正在使用微信内语音通话或系统通话 | + * | -3 | | 加入会话期间退出(可能是用户主动退出,或者退后台、来电等原因),因此加入失败 | + * | -1000 | | 系统错误 | */ errCode: number + } + interface JoinVoIPChatError { + /** 错误信息 + * + * | 错误码 | 错误信息 | 说明 | + * | - | - | - | + * | -1 | 当前已在房间内 | | + * | -2 | 录音设备被占用,可能是当前正在使用微信内语音通话或系统通话 | | + * | -3 | 加入会话期间退出(可能是用户主动退出,或者退后台、来电等原因),因此加入失败 | | + * | -1000 | 系统错误 | | */ errMsg: string + /** 错误码 + * + * | 错误码 | 错误信息 | 说明 | + * | - | - | - | + * | -1 | 当前已在房间内 | | + * | -2 | 录音设备被占用,可能是当前正在使用微信内语音通话或系统通话 | | + * | -3 | 加入会话期间退出(可能是用户主动退出,或者退后台、来电等原因),因此加入失败 | | + * | -1000 | 系统错误 | | */ errCode: number } - interface SetStorageOption { - /** 需要存储的内容。只支持原生类型、Date、及能够通过`JSON.stringify`序列化的对象。 */ - data: any - /** 本地缓存中指定的 key */ - key: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetStorageCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SetStorageFailCallback - /** 接口调用成功的回调函数 */ - success?: SetStorageSuccessCallback + interface LivePlayerContext { + /** [LivePlayerContext.exitBackgroundPlayback()](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.exitBackgroundPlayback.html) + * + * 需要基础库: `2.14.3` + * + * 在插件中使用:支持 + * + * 退出后台音频播放模式。 */ + exitBackgroundPlayback(): void + /** [LivePlayerContext.exitCasting(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.exitCasting.html) + * + * 需要基础库: `2.32.0` + * + * 在插件中使用:支持 + * + * 退出投屏。仅支持在 tap 事件回调内调用。 */ + exitCasting(option?: ExitCastingOption): void + /** [LivePlayerContext.exitFullScreen(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.exitFullScreen.html) + * + * 在插件中使用:支持 + * + * 退出全屏 */ + exitFullScreen(option?: ExitFullScreenOption): void + /** [LivePlayerContext.exitPictureInPicture(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.exitPictureInPicture.html) + * + * 在插件中使用:支持 + * + * 退出小窗,该方法可在任意页面调用 */ + exitPictureInPicture(option?: ExitPictureInPictureOption): void + /** [LivePlayerContext.mute(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.mute.html) + * + * 在插件中使用:支持 + * + * 静音 */ + mute(option?: MuteOption): void + /** [LivePlayerContext.pause(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.pause.html) + * + * 需要基础库: `1.9.90` + * + * 在插件中使用:支持 + * + * 暂停 */ + pause(option?: PauseOption): void + /** [LivePlayerContext.play(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.play.html) + * + * 在插件中使用:支持 + * + * 播放 */ + play(option?: PlayOption): void + /** [LivePlayerContext.reconnectCasting(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.reconnectCasting.html) + * + * 需要基础库: `2.32.0` + * + * 在插件中使用:支持 + * + * 重连投屏设备。仅支持在 tap 事件回调内调用。 */ + reconnectCasting(option?: ReconnectCastingOption): void + /** [LivePlayerContext.requestBackgroundPlayback()](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.requestBackgroundPlayback.html) + * + * 需要基础库: `2.14.3` + * + * 在插件中使用:支持 + * + * 进入后台音频播放模式。 */ + requestBackgroundPlayback(): void + /** [LivePlayerContext.requestFullScreen(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.requestFullScreen.html) + * + * 在插件中使用:支持 + * + * 进入全屏 */ + requestFullScreen( + option: LivePlayerContextRequestFullScreenOption + ): void + /** [LivePlayerContext.requestPictureInPicture(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.requestPictureInPicture.html) + * + * 需要基础库: `2.15.0` + * + * 在插件中使用:支持 + * + * 进入小窗 */ + requestPictureInPicture(option?: RequestPictureInPictureOption): void + /** [LivePlayerContext.resume(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.resume.html) + * + * 需要基础库: `1.9.90` + * + * 在插件中使用:支持 + * + * 恢复 */ + resume(option?: ResumeOption): void + /** [LivePlayerContext.snapshot(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.snapshot.html) + * + * 需要基础库: `2.7.1` + * + * 在插件中使用:支持 + * + * 截图 */ + snapshot(option: LivePlayerContextSnapshotOption): void + /** [LivePlayerContext.startCasting(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.startCasting.html) + * + * 需要基础库: `2.32.0` + * + * 在插件中使用:支持 + * + * 开始投屏, 拉起半屏搜索设备。仅支持在 tap 事件回调内调用。 */ + startCasting(option?: StartCastingOption): void + /** [LivePlayerContext.stop(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.stop.html) + * + * 在插件中使用:支持 + * + * 停止 */ + stop(option?: StopOption): void + /** [LivePlayerContext.switchCasting(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.switchCasting.html) + * + * 需要基础库: `2.32.0` + * + * 在插件中使用:支持 + * + * 切换投屏设备。仅支持在 tap 事件回调内调用。 */ + switchCasting(option?: SwitchCastingOption): void } - interface SetTabBarBadgeOption { - /** tabBar 的哪一项,从左边算起 */ - index: number - /** 显示的文本,超过 4 个字符则显示成 ... */ - text: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetTabBarBadgeCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SetTabBarBadgeFailCallback - /** 接口调用成功的回调函数 */ - success?: SetTabBarBadgeSuccessCallback + interface LivePusherContext { + /** [LivePusherContext.applyBlusherStickMakeup(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.applyBlusherStickMakeup.html) + * + * 需要基础库: `2.14.0` + * + * 在插件中使用:不支持 + * + * 添加腮红美妆特效 */ + applyBlusherStickMakeup(option: ApplyBlusherStickMakeupOption): void + /** [LivePusherContext.applyEyeBrowMakeup(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.applyEyeBrowMakeup.html) + * + * 需要基础库: `2.14.0` + * + * 在插件中使用:不支持 + * + * 添加眉毛美妆特效 */ + applyEyeBrowMakeup(option: ApplyEyeBrowMakeupOption): void + /** [LivePusherContext.applyEyeShadowMakeup(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.applyEyeShadowMakeup.html) + * + * 需要基础库: `2.14.0` + * + * 在插件中使用:不支持 + * + * 添加眼影美妆特效 */ + applyEyeShadowMakeup(option: ApplyEyeShadowMakeupOption): void + /** [LivePusherContext.applyFaceContourMakeup(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.applyFaceContourMakeup.html) + * + * 需要基础库: `2.14.0` + * + * 在插件中使用:不支持 + * + * 添加修容美妆特效 */ + applyFaceContourMakeup(option: ApplyFaceContourMakeupOption): void + /** [LivePusherContext.applyFilter(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.applyFilter.html) + * + * 需要基础库: `2.14.0` + * + * 在插件中使用:不支持 + * + * 添加滤镜效果 */ + applyFilter(option: ApplyFilterOption): void + /** [LivePusherContext.applyLipStickMakeup(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.applyLipStickMakeup.html) + * + * 需要基础库: `2.14.0` + * + * 在插件中使用:不支持 + * + * 添加口红美妆特效 */ + applyLipStickMakeup(option: ApplyLipStickMakeupOption): void + /** [LivePusherContext.applySticker(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.applySticker.html) + * + * 需要基础库: `2.14.0` + * + * 在插件中使用:不支持 + * + * 添加贴纸特效 */ + applySticker(option: ApplyStickerOption): void + /** [LivePusherContext.clearFilters(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.clearFilters.html) + * + * 需要基础库: `2.14.0` + * + * 在插件中使用:不支持 + * + * 清除所有滤镜效果 */ + clearFilters(option?: ClearFiltersOption): void + /** [LivePusherContext.clearMakeups(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.clearMakeups.html) + * + * 需要基础库: `2.14.0` + * + * 在插件中使用:不支持 + * + * 清除所有美妆特效 */ + clearMakeups(option?: ClearMakeupsOption): void + /** [LivePusherContext.clearStickers(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.clearStickers.html) + * + * 需要基础库: `2.14.0` + * + * 在插件中使用:不支持 + * + * 清除所有贴纸特效 */ + clearStickers(option?: ClearStickersOption): void + /** [LivePusherContext.createOffscreenCanvas(object options)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.createOffscreenCanvas.html) + * + * 需要基础库: `2.29.0` + * + * 在插件中使用:支持 + * + * 创建一个能够承接 LivePusher 采集纹理的离屏 Canvas,客户端 8.0.31 版本开始支持。 */ + createOffscreenCanvas( + /** 同[wx.createOffscreenCanvas](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.createOffscreenCanvas.html) */ + options: IAnyObject + ): void + /** [LivePusherContext.exitPictureInPicture(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.exitPictureInPicture.html) + * + * 需要基础库: `2.25.0` + * + * 在插件中使用:支持 + * + * 退出小窗,该方法可在任意页面调用 */ + exitPictureInPicture(option?: ExitPictureInPictureOption): void + /** [LivePusherContext.getMaxZoom(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.getMaxZoom.html) + * + * 需要基础库: `2.31.0` + * + * 在插件中使用:支持 + * + * 获取最大缩放级别 */ + getMaxZoom(option?: GetMaxZoomOption): void + /** [LivePusherContext.onCustomRendererEvent(string event, function|function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.onCustomRendererEvent.html) + * + * 需要基础库: `2.29.0` + * + * 在插件中使用:支持 + * + * 开启自定义渲染时,开发者通过此方法订阅相关事件,客户端 8.0.31 版本开始支持。 */ + onCustomRendererEvent( + /** 事件类型,后订阅的监听器会取消之前的监听器 + * + * 参数 event 可选值: + * - 'frame': 采集到视频帧后触发; + * - 'update': 推流尺寸变更时触发; */ + event: 'frame' | 'update', + /** 自定义渲染事件处理回调函数 */ + callback: CustomRendererFrameEventCallback + ): void + /** [LivePusherContext.pause(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.pause.html) + * + * 在插件中使用:支持 + * + * 暂停推流 */ + pause(option?: PauseOption): void + /** [LivePusherContext.pauseBGM(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.pauseBGM.html) + * + * 需要基础库: `2.4.0` + * + * 在插件中使用:支持 + * + * 暂停背景音 */ + pauseBGM(option?: PauseBGMOption): void + /** [LivePusherContext.playBGM(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.playBGM.html) + * + * 需要基础库: `2.4.0` + * + * 在插件中使用:支持 + * + * 播放背景音 */ + playBGM(option: PlayBGMOption): void + /** [LivePusherContext.resume(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.resume.html) + * + * 在插件中使用:支持 + * + * 恢复推流 */ + resume(option?: ResumeOption): void + /** [LivePusherContext.resumeBGM(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.resumeBGM.html) + * + * 需要基础库: `2.4.0` + * + * 在插件中使用:支持 + * + * 恢复背景音 */ + resumeBGM(option?: ResumeBGMOption): void + /** [LivePusherContext.sendMessage(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.sendMessage.html) + * + * 需要基础库: `2.10.0` + * + * 在插件中使用:支持 + * + * 发送SEI消息 */ + sendMessage(option: SendMessageOption): void + /** [LivePusherContext.setBGMVolume(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.setBGMVolume.html) + * + * 需要基础库: `2.4.0` + * + * 在插件中使用:支持 + * + * 设置背景音音量 */ + setBGMVolume(option: SetBGMVolumeOption): void + /** [LivePusherContext.setMICVolume(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.setMICVolume.html) + * + * 需要基础库: `2.10.0` + * + * 在插件中使用:支持 + * + * 设置麦克风音量 */ + setMICVolume(option: SetMICVolumeOption): void + /** [LivePusherContext.setZoom(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.setZoom.html) + * + * 需要基础库: `2.31.0` + * + * 在插件中使用:支持 + * + * 设置缩放级别 */ + setZoom(option: LivePusherContextSetZoomOption): void + /** [LivePusherContext.snapshot(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.snapshot.html) + * + * 需要基础库: `1.9.90` + * + * 在插件中使用:支持 + * + * 快照 */ + snapshot(option: LivePusherContextSnapshotOption): void + /** [LivePusherContext.start(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.start.html) + * + * 在插件中使用:支持 + * + * 开始推流,同时开启摄像头预览 */ + start(option?: LivePusherContextStartOption): void + /** [LivePusherContext.startPreview(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.startPreview.html) + * + * 需要基础库: `2.7.0` + * + * 在插件中使用:支持 + * + * 开启摄像头预览 */ + startPreview(option?: StartPreviewOption): void + /** [LivePusherContext.stop(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.stop.html) + * + * 在插件中使用:支持 + * + * 停止推流,同时停止摄像头预览 */ + stop(option?: StopOption): void + /** [LivePusherContext.stopBGM(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.stopBGM.html) + * + * 需要基础库: `2.4.0` + * + * 在插件中使用:支持 + * + * 停止背景音 */ + stopBGM(option?: StopBGMOption): void + /** [LivePusherContext.stopPreview(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.stopPreview.html) + * + * 需要基础库: `2.7.0` + * + * 在插件中使用:支持 + * + * 关闭摄像头预览 */ + stopPreview(option?: StopPreviewOption): void + /** [LivePusherContext.switchCamera(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.switchCamera.html) + * + * 在插件中使用:支持 + * + * 切换前后摄像头 */ + switchCamera(option?: SwitchCameraOption): void + /** [LivePusherContext.toggleTorch(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.toggleTorch.html) + * + * 需要基础库: `2.1.0` + * + * 在插件中使用:支持 + * + * 切换手电筒 */ + toggleTorch(option?: ToggleTorchOption): void } - interface SetTabBarItemOption { - /** tabBar 的哪一项,从左边算起 */ - index: number - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetTabBarItemCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SetTabBarItemFailCallback - /** 图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px,当 postion 为 top 时,此参数无效 */ - iconPath?: string - /** 选中时的图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px ,当 postion 为 top 时,此参数无效 */ - selectedIconPath?: string - /** 接口调用成功的回调函数 */ - success?: SetTabBarItemSuccessCallback - /** tab 上的按钮文字 */ - text?: string + interface LogManager { + /** [LogManager.debug()](https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/LogManager.debug.html) + * + * 在插件中使用:不支持 + * + * 写 debug 日志 */ + debug( + /** 日志内容,可以有任意多个。每次调用的参数的总大小不超过100Kb */ + ...args: any[] + ): void + /** [LogManager.info()](https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/LogManager.info.html) + * + * 在插件中使用:不支持 + * + * 写 info 日志 */ + info( + /** 日志内容,可以有任意多个。每次调用的参数的总大小不超过100Kb */ + ...args: any[] + ): void + /** [LogManager.log()](https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/LogManager.log.html) + * + * 在插件中使用:不支持 + * + * 写 log 日志 */ + log( + /** 日志内容,可以有任意多个。每次调用的参数的总大小不超过100Kb */ + ...args: any[] + ): void + /** [LogManager.warn()](https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/LogManager.warn.html) + * + * 在插件中使用:不支持 + * + * 写 warn 日志 */ + warn( + /** 日志内容,可以有任意多个。每次调用的参数的总大小不超过100Kb */ + ...args: any[] + ): void } - interface SetTabBarStyleOption { - /** tab 的背景色,HexColor */ - backgroundColor?: string - /** tabBar上边框的颜色, 仅支持 black/white */ - borderStyle?: string - /** tab 上的文字默认颜色,HexColor */ - color?: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetTabBarStyleCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SetTabBarStyleFailCallback - /** tab 上的文字选中时的颜色,HexColor */ - selectedColor?: string - /** 接口调用成功的回调函数 */ - success?: SetTabBarStyleSuccessCallback + interface MapContext { + /** [MapContext.addArc(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.addArc.html) + * + * 需要基础库: `2.22.0` + * + * 在插件中使用:支持 + * + * 添加弧线,途经点与夹角必须设置一个。途经点必须在起终点有效坐标范围内,否则不能生成正确的弧线,同时设置夹角角度时,以夹角角度为准。夹角定义为起点到终点,与起点外切线逆时针旋转的角度。工具侧暂未支持。 */ + addArc(option: AddArcOption): void + /** [MapContext.addCustomLayer(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.addCustomLayer.html) + * + * 需要基础库: `2.12.0` + * + * 在插件中使用:支持 + * + * 添加个性化图层。图层创建[参考文档](https://lbs.qq.com/dev/console/customLayer/create) */ + addCustomLayer(option: AddCustomLayerOption): void + /** [MapContext.addGroundOverlay(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.addGroundOverlay.html) + * + * 需要基础库: `2.14.0` + * + * 在插件中使用:支持 + * + * 创建自定义图片图层,图片会随着地图缩放而缩放。 */ + addGroundOverlay(option: AddGroundOverlayOption): void + /** [MapContext.addMarkers(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.addMarkers.html) + * + * 需要基础库: `2.13.0` + * + * 在插件中使用:支持 + * + * 添加 marker。 */ + addMarkers(option: AddMarkersOption): void + /** [MapContext.addVisualLayer(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.addVisualLayer.html) + * + * 需要基础库: `2.20.1` + * + * 在插件中使用:支持 + * + * 添加可视化图层。需要刷新时,interval 可设置的最小值为 15 s。 */ + addVisualLayer(option: AddVisualLayerOption): void + /** [MapContext.eraseLines(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.eraseLines.html) + * + * 需要基础库: `2.5.0` + * + * 在插件中使用:支持 + * + * 擦除或置灰已添加到地图中的线段。 */ + eraseLines(option: EraseLinesOption): void + /** [MapContext.executeVisualLayerCommand(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.executeVisualLayerCommand.html) + * + * 需要基础库: `2.26.0` + * + * 在插件中使用:支持 + * + * 执行可视化图层指令,结合 `MapContext.on('visualLayerEvent')` 监听事件使用。 */ + executeVisualLayerCommand(option: ExecuteVisualLayerCommandOption): void + /** [MapContext.fromScreenLocation(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.fromScreenLocation.html) + * + * 需要基础库: `2.14.0` + * + * 在插件中使用:支持 + * + * 获取屏幕上的点对应的经纬度,坐标原点为地图左上角。 */ + fromScreenLocation(option: FromScreenLocationOption): void + /** [MapContext.getCenterLocation(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.getCenterLocation.html) + * + * 在插件中使用:支持 + * + * 获取当前地图中心的经纬度。返回的是 gcj02 坐标系,可以用于 [wx.openLocation()](https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.openLocation.html) */ + getCenterLocation(option: GetCenterLocationOption): void + /** [MapContext.getRegion(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.getRegion.html) + * + * 需要基础库: `1.4.0` + * + * 在插件中使用:支持 + * + * 获取当前地图的视野范围 */ + getRegion(option?: GetRegionOption): void + /** [MapContext.getRotate(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.getRotate.html) + * + * 需要基础库: `2.8.0` + * + * 在插件中使用:支持 + * + * 获取当前地图的旋转角 */ + getRotate(option?: GetRotateOption): void + /** [MapContext.getScale(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.getScale.html) + * + * 需要基础库: `1.4.0` + * + * 在插件中使用:支持 + * + * 获取当前地图的缩放级别 */ + getScale(option?: GetScaleOption): void + /** [MapContext.getSkew(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.getSkew.html) + * + * 需要基础库: `2.8.0` + * + * 在插件中使用:支持 + * + * 获取当前地图的倾斜角 */ + getSkew(option?: GetSkewOption): void + /** [MapContext.includePoints(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.includePoints.html) + * + * 需要基础库: `1.2.0` + * + * 在插件中使用:支持 + * + * 缩放视野展示所有经纬度 */ + includePoints(option: IncludePointsOption): void + /** [MapContext.initMarkerCluster(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.initMarkerCluster.html) + * + * 需要基础库: `2.13.0` + * + * 在插件中使用:支持 + * + * 初始化点聚合的配置,未调用时采用默认配置。 */ + initMarkerCluster(option: InitMarkerClusterOption): void + /** [MapContext.moveAlong(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.moveAlong.html) + * + * 需要基础库: `2.13.0` + * + * 在插件中使用:支持 + * + * 沿指定路径移动 `marker`,用于轨迹回放等场景。动画完成时触发回调事件,若动画进行中,对同一 `marker` 再次调用 `moveAlong` 方法,前一次的动画将被打断。 */ + moveAlong(option: MoveAlongOption): void + /** [MapContext.moveToLocation(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.moveToLocation.html) + * + * 需要基础库: `1.2.0` + * + * 在插件中使用:支持 + * + * 将地图中心移置当前定位点,此时需设置地图组件 show-location 为true。[2.8.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起支持将地图中心移动到指定位置。 */ + moveToLocation(option?: MoveToLocationOption): void + /** [MapContext.on(string event, function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.on.html) +* +* 需要基础库: `2.13.0` +* +* 在插件中使用:支持 +* +* 监听地图事件。 +* +* ### visualLayerEvent +* +* 可视化图层 visualLayer 统一回调出口,[2.26.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起支持。 +* +* #### 返回参数 +* +* | 参数 | 类型 | 说明 | +* | --------- | ------ | -------- | +* | layerId | String | 图层 id | +* | eventType | String | 事件类型 | +* | eventInfo | String | 事件信息 | +* +* ### markerClusterCreate +* +* 缩放或拖动导致新的聚合簇产生时触发,仅返回新创建的聚合簇信息。 +* +* #### 返回参数 +* +* | 参数 | 类型 | 说明 | +* | -------- | -------------------- | ---------- | +* | clusters | `Array` | 聚合簇数据 | +* +* ### markerClusterClick +* +* 聚合簇的点击事件。 +* +* #### 返回参数 +* +* | 参数 | 类型 | 说明 | +* | --------- | ------------- | --------- | +* | cluster | ClusterInfo | 聚合簇 | +* +* #### ClusterInfo 结构 +* +* | 参数 | 类型 | 说明 | +* | --------- | --------------- | -------------------------- | +* | clusterId | Number | 聚合簇的 id | +* | center | LatLng | 聚合簇的坐标 | +* | markerIds | `Array` | 该聚合簇内的点标记数据数组 | +* +* ### markerCollisionStatusChange +* +* marker 参与碰撞后隐藏时的回调,[3.4.3](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 起支持。 +* +* #### 返回参数 +* +* | 参数 | 类型 | 说明 | +* | --------- | ------ | -------- | +* | show | `Array` | 碰撞时隐藏后又显示的 `markerIds` | +* | hide | `Array` | 碰撞时被隐藏的 `markerIds` | +* +* **示例代码** +* +* ```js + MapContext.on('visualLayerEvent', (res) => {}) + MapContext.on('markerClusterCreate', (res) => {}) + MapContext.on('markerClusterClick', (res) => {}) + MapContext.on('markerCollisionStatusChange', (res) => {}) +``` */ + on( + /** 事件名 + * + * 参数 event 可选值: + * - 'markerClusterCreate': ; + * - 'markerClusterClick': ; + * - 'visualLayerEvent': ; + * - 'markerCollisionStatusChange': ; */ + event: + | 'markerClusterCreate' + | 'markerClusterClick' + | 'visualLayerEvent' + | 'markerCollisionStatusChange', + /** 事件的回调函数 */ + callback: (...args: any[]) => any + ): void + /** [MapContext.openMapApp(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.openMapApp.html) + * + * 需要基础库: `2.14.0` + * + * 在插件中使用:支持 + * + * 拉起地图APP选择导航。 */ + openMapApp(option: OpenMapAppOption): void + /** [MapContext.removeArc(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.removeArc.html) + * + * 需要基础库: `2.22.0` + * + * 在插件中使用:支持 + * + * 删除弧线。工具侧暂未支持。 */ + removeArc(option: RemoveArcOption): void + /** [MapContext.removeCustomLayer(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.removeCustomLayer.html) + * + * 需要基础库: `2.12.0` + * + * 在插件中使用:支持 + * + * 移除个性化图层。 */ + removeCustomLayer(option: RemoveCustomLayerOption): void + /** [MapContext.removeGroundOverlay(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.removeGroundOverlay.html) + * + * 需要基础库: `2.14.0` + * + * 在插件中使用:支持 + * + * 移除自定义图片图层。 */ + removeGroundOverlay(option: RemoveGroundOverlayOption): void + /** [MapContext.removeMarkers(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.removeMarkers.html) + * + * 需要基础库: `2.13.0` + * + * 在插件中使用:支持 + * + * 移除 marker。 */ + removeMarkers(option: RemoveMarkersOption): void + /** [MapContext.removeVisualLayer(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.removeVisualLayer.html) + * + * 需要基础库: `2.20.1` + * + * 在插件中使用:支持 + * + * 移除可视化图层。 */ + removeVisualLayer(option: RemoveVisualLayerOption): void + /** [MapContext.setBoundary(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.setBoundary.html) + * + * 需要基础库: `2.22.0` + * + * 在插件中使用:支持 + * + * 限制地图的显示范围。此接口同时会限制地图的最小缩放整数级别。 */ + setBoundary(option: SetBoundaryOption): void + /** [MapContext.setCenterOffset(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.setCenterOffset.html) + * + * 需要基础库: `2.10.0` + * + * 在插件中使用:支持 + * + * 设置地图中心点偏移,向后向下为增长,屏幕比例范围(0.25~0.75),默认偏移为[0.5, 0.5] */ + setCenterOffset(option: SetCenterOffsetOption): void + /** [MapContext.setLocMarkerIcon(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.setLocMarkerIcon.html) + * + * 需要基础库: `2.16.0` + * + * 在插件中使用:支持 + * + * 设置定位点图标,支持网络路径、本地路径、代码包路径 */ + setLocMarkerIcon(option: SetLocMarkerIconOption): void + /** [MapContext.toScreenLocation(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.toScreenLocation.html) + * + * 需要基础库: `2.14.0` + * + * 在插件中使用:支持 + * + * 获取经纬度对应的屏幕坐标,坐标原点为地图左上角。 */ + toScreenLocation(option: ToScreenLocationOption): void + /** [MapContext.translateMarker(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.translateMarker.html) + * + * 需要基础库: `1.2.0` + * + * 在插件中使用:支持 + * + * 平移marker,带动画。 */ + translateMarker(option: TranslateMarkerOption): void + /** [MapContext.updateGroundOverlay(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.updateGroundOverlay.html) + * + * 需要基础库: `2.14.0` + * + * 在插件中使用:支持 + * + * 更新自定义图片图层。 */ + updateGroundOverlay(option: UpdateGroundOverlayOption): void } - interface SetTopBarTextOption { - /** 置顶栏文字 */ - text: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetTopBarTextCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SetTopBarTextFailCallback - /** 接口调用成功的回调函数 */ - success?: SetTopBarTextSuccessCallback + interface MediaContainer { + /** [MediaContainer.addTrack([MediaTrack](https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaTrack.html) track)](https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaContainer.addTrack.html) + * + * 需要基础库: `2.9.0` + * + * 在插件中使用:支持 + * + * 将音频或视频轨道添加到容器 */ + addTrack( + /** [MediaTrack](https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaTrack.html) + * + * 要添加的音频或视频轨道 */ + track: MediaTrack + ): void + /** [MediaContainer.destroy()](https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaContainer.destroy.html) + * + * 需要基础库: `2.9.0` + * + * 在插件中使用:支持 + * + * 将容器销毁,释放资源 */ + destroy(): void + /** [MediaContainer.export()](https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaContainer.export.html) + * + * 需要基础库: `2.9.0` + * + * 在插件中使用:支持 + * + * 将容器内的轨道合并并导出视频文件 */ + export(): void + /** [MediaContainer.extractDataSource(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaContainer.extractDataSource.html) + * + * 需要基础库: `2.9.0` + * + * 在插件中使用:支持 + * + * 将传入的视频源分离轨道。不会自动将轨道添加到待合成的容器里。 */ + extractDataSource(option: ExtractDataSourceOption): void + /** [MediaContainer.removeTrack([MediaTrack](https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaTrack.html) track)](https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaContainer.removeTrack.html) + * + * 需要基础库: `2.9.0` + * + * 在插件中使用:支持 + * + * 将音频或视频轨道从容器中移除 */ + removeTrack( + /** [MediaTrack](https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaTrack.html) + * + * 要移除的音频或视频轨道 */ + track: MediaTrack + ): void } - interface SetWifiListOption { - /** 提供预设的 Wi-Fi 信息列表 */ - wifiList: WifiData[] - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetWifiListCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SetWifiListFailCallback - /** 接口调用成功的回调函数 */ - success?: SetWifiListSuccessCallback + interface MediaQueryObserver { + /** [MediaQueryObserver.disconnect()](https://developers.weixin.qq.com/miniprogram/dev/api/wxml/MediaQueryObserver.disconnect.html) + * + * 在插件中使用:支持 + * + * 停止监听。回调函数将不再触发 */ + disconnect(): void + /** [MediaQueryObserver.observe(Object descriptor, function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/wxml/MediaQueryObserver.observe.html) + * + * 在插件中使用:支持 + * + * 开始监听页面 media query 变化情况 */ + observe( + /** media query 描述符 */ + descriptor: ObserveDescriptor, + /** 监听 media query 状态变化的回调函数 */ + callback: MediaQueryObserverObserveCallback + ): void } - interface SetZoomOption { - /** 缩放级别,范围[1, maxZoom]。zoom 可取小时,精确到小数后一位。maxZoom 可在 bindinitdone 返回值中获取。 */ - zoom: number - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: SetZoomCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: SetZoomFailCallback - /** 接口调用成功的回调函数 */ - success?: SetZoomSuccessCallback + interface MediaRecorder { + /** [MediaRecorder.off(string eventName, function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/media/media-recorder/MediaRecorder.off.html) + * + * 需要基础库: `2.11.0` + * + * 在插件中使用:支持 + * + * 取消监听录制事件。当对应事件触发时,该回调函数不再执行。 */ + off( + /** 事件名 */ + eventName: string, + /** 事件触发时执行的回调函数 */ + callback: (...args: any[]) => any + ): void + /** [MediaRecorder.on(string eventName, function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/media/media-recorder/MediaRecorder.on.html) + * + * 需要基础库: `2.11.0` + * + * 在插件中使用:支持 + * + * 注册监听录制事件的回调函数。当对应事件触发时,回调函数会被执行。 */ + on( + /** 事件名 + * + * 参数 eventName 可选值: + * - 'start': 录制开始事件。; + * - 'stop': 录制结束事件。返回 {tempFilePath, duration, fileSize}; + * - 'pause': 录制暂停事件。; + * - 'resume': 录制继续事件。; + * - 'timeupdate': 录制时间更新事件。; */ + eventName: 'start' | 'stop' | 'pause' | 'resume' | 'timeupdate', + /** 事件触发时执行的回调函数 */ + callback: (...args: any[]) => any + ): void + /** [Promise MediaRecorder.destroy()](https://developers.weixin.qq.com/miniprogram/dev/api/media/media-recorder/MediaRecorder.destroy.html) + * + * 需要基础库: `2.11.0` + * + * 在插件中使用:支持 + * + * 销毁录制器 */ + destroy(): Promise + /** [Promise MediaRecorder.pause()](https://developers.weixin.qq.com/miniprogram/dev/api/media/media-recorder/MediaRecorder.pause.html) + * + * 需要基础库: `2.11.0` + * + * 在插件中使用:支持 + * + * 暂停录制 */ + pause(): Promise + /** [Promise MediaRecorder.requestFrame(function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/media/media-recorder/MediaRecorder.requestFrame.html) + * + * 需要基础库: `2.11.0` + * + * 在插件中使用:支持 + * + * 请求下一帧录制,在 callback 里完成一帧渲染后开始录制当前帧 */ + requestFrame(callback: (...args: any[]) => any): Promise + /** [Promise MediaRecorder.resume()](https://developers.weixin.qq.com/miniprogram/dev/api/media/media-recorder/MediaRecorder.resume.html) + * + * 需要基础库: `2.11.0` + * + * 在插件中使用:支持 + * + * 恢复录制 */ + resume(): Promise + /** [Promise MediaRecorder.start()](https://developers.weixin.qq.com/miniprogram/dev/api/media/media-recorder/MediaRecorder.start.html) + * + * 需要基础库: `2.11.0` + * + * 在插件中使用:支持 + * + * 开始录制 */ + start(): Promise + /** [Promise MediaRecorder.stop()](https://developers.weixin.qq.com/miniprogram/dev/api/media/media-recorder/MediaRecorder.stop.html) + * + * 需要基础库: `2.11.0` + * + * 在插件中使用:支持 + * + * 结束录制 */ + stop(): Promise } - interface ShowActionSheetOption { - /** 按钮的文字数组,数组长度最大为 6 */ - itemList: string[] - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ShowActionSheetCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: ShowActionSheetFailCallback - /** 按钮的文字颜色 */ - itemColor?: string - /** 接口调用成功的回调函数 */ - success?: ShowActionSheetSuccessCallback + interface MifareClassic { + /** [MifareClassic.close(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/MifareClassic.close.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 断开连接 */ + close(option?: NdefCloseOption): void + /** [MifareClassic.connect(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/MifareClassic.connect.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 连接 NFC 标签 */ + connect(option?: NdefConnectOption): void + /** [MifareClassic.getMaxTransceiveLength(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/MifareClassic.getMaxTransceiveLength.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 获取最大传输长度 */ + getMaxTransceiveLength(option?: GetMaxTransceiveLengthOption): void + /** [MifareClassic.isConnected(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/MifareClassic.isConnected.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * @warning **该接口已废弃,连接状态开发者自行维护即可** + * + * 检查是否已连接 */ + isConnected(option?: IsConnectedOption): void + /** [MifareClassic.setTimeout(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/MifareClassic.setTimeout.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 设置超时时间 */ + setTimeout(option: SetTimeoutOption): void + /** [MifareClassic.transceive(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/MifareClassic.transceive.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 发送数据 */ + transceive(option: TransceiveOption): void } - interface ShowActionSheetSuccessCallbackResult { - /** 用户点击的按钮序号,从上到下的顺序,从0开始 */ - tapIndex: number - errMsg: string + interface MifareUltralight { + /** [MifareUltralight.close(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/MifareUltralight.close.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 断开连接 */ + close(option?: NdefCloseOption): void + /** [MifareUltralight.connect(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/MifareUltralight.connect.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 连接 NFC 标签 */ + connect(option?: NdefConnectOption): void + /** [MifareUltralight.getMaxTransceiveLength(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/MifareUltralight.getMaxTransceiveLength.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 获取最大传输长度 */ + getMaxTransceiveLength(option?: GetMaxTransceiveLengthOption): void + /** [MifareUltralight.isConnected(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/MifareUltralight.isConnected.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * @warning **该接口已废弃,连接状态开发者自行维护即可** + * + * 检查是否已连接 */ + isConnected(option?: IsConnectedOption): void + /** [MifareUltralight.setTimeout(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/MifareUltralight.setTimeout.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 设置超时时间 */ + setTimeout(option: SetTimeoutOption): void + /** [MifareUltralight.transceive(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/MifareUltralight.transceive.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 发送数据 */ + transceive(option: TransceiveOption): void } - interface ShowLoadingOption { - /** 提示的内容 */ - title: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ShowLoadingCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: ShowLoadingFailCallback - /** 是否显示透明蒙层,防止触摸穿透 */ - mask?: boolean - /** 接口调用成功的回调函数 */ - success?: ShowLoadingSuccessCallback + interface NFCError { + /** 错误信息 + * + * | 错误码 | 错误信息 | 说明 | + * | - | - | - | + * | 0 | ok | 正常 | + * | 13000 | | 当前设备不支持NFC | + * | 13001 | | 当前设备支持NFC,但系统NFC开关未开启 | + * | 13002 | | 当前设备支持NFC,但不支持HCE | + * | 13003 | | AID列表参数格式错误 | + * | 13004 | | 未设置微信为默认NFC支付应用 | + * | 13005 | | 返回的指令不合法 | + * | 13006 | | 注册AID失败 | */ errMsg: string + /** 错误码 + * + * | 错误码 | 错误信息 | 说明 | + * | - | - | - | + * | 0 | ok | 正常 | + * | 13000 | | 当前设备不支持NFC | + * | 13001 | | 当前设备支持NFC,但系统NFC开关未开启 | + * | 13002 | | 当前设备支持NFC,但不支持HCE | + * | 13003 | | AID列表参数格式错误 | + * | 13004 | | 未设置微信为默认NFC支付应用 | + * | 13005 | | 返回的指令不合法 | + * | 13006 | | 注册AID失败 | */ errCode: number } - interface ShowModalOption { - /** 取消按钮的文字颜色,必须是 16 进制格式的颜色字符串 */ - cancelColor?: string - /** 取消按钮的文字,最多 4 个字符 */ - cancelText?: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ShowModalCompleteCallback - /** 确认按钮的文字颜色,必须是 16 进制格式的颜色字符串 */ - confirmColor?: string - /** 确认按钮的文字,最多 4 个字符 */ - confirmText?: string - /** 提示的内容 */ - content?: string - /** 接口调用失败的回调函数 */ - fail?: ShowModalFailCallback - /** 是否显示取消按钮 */ - showCancel?: boolean - /** 接口调用成功的回调函数 */ - success?: ShowModalSuccessCallback - /** 提示的标题 */ - title?: string + interface Ndef { + /** [Ndef.close(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/Ndef.close.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 断开连接 */ + close(option?: NdefCloseOption): void + /** [Ndef.connect(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/Ndef.connect.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 连接 NFC 标签 */ + connect(option?: NdefConnectOption): void + /** [Ndef.isConnected(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/Ndef.isConnected.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * @warning **该接口已废弃,连接状态开发者自行维护即可** + * + * 检查是否已连接 */ + isConnected(option?: IsConnectedOption): void + /** [Ndef.offNdefMessage(function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/Ndef.offNdefMessage.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 取消监听 Ndef 消息 */ + offNdefMessage(callback: (...args: any[]) => any): void + /** [Ndef.onNdefMessage(function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/Ndef.onNdefMessage.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 监听 Ndef 消息 */ + onNdefMessage(callback: (...args: any[]) => any): void + /** [Ndef.setTimeout(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/Ndef.setTimeout.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 设置超时时间 */ + setTimeout(option: SetTimeoutOption): void + /** [Ndef.writeNdefMessage(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/Ndef.writeNdefMessage.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 重写 Ndef 标签内容 */ + writeNdefMessage(option: WriteNdefMessageOption): void } - interface ShowModalSuccessCallbackResult { - /** 为 true 时,表示用户点击了取消(用于 Android 系统区分点击蒙层关闭还是点击取消按钮关闭) + interface NfcA { + /** [NfcA.close(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcA.close.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 断开连接 */ + close(option?: NdefCloseOption): void + /** [NfcA.connect(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcA.connect.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 * - * 最低基础库: `1.1.0` */ - cancel: boolean - /** 为 true 时,表示用户点击了确定按钮 */ - confirm: boolean - errMsg: string + * 连接 NFC 标签 */ + connect(option?: NdefConnectOption): void + /** [NfcA.getAtqa(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcA.getAtqa.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 获取ATQA信息 */ + getAtqa(option?: GetAtqaOption): void + /** [NfcA.getMaxTransceiveLength(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcA.getMaxTransceiveLength.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 获取最大传输长度 */ + getMaxTransceiveLength(option?: GetMaxTransceiveLengthOption): void + /** [NfcA.getSak(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcA.getSak.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 获取SAK信息 */ + getSak(option?: GetSakOption): void + /** [NfcA.isConnected(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcA.isConnected.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * @warning **该接口已废弃,连接状态开发者自行维护即可** + * + * 检查是否已连接 */ + isConnected(option?: IsConnectedOption): void + /** [NfcA.setTimeout(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcA.setTimeout.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 设置超时时间 */ + setTimeout(option: SetTimeoutOption): void + /** [NfcA.transceive(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcA.transceive.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 发送数据 */ + transceive(option: TransceiveOption): void } - interface ShowNavigationBarLoadingOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ShowNavigationBarLoadingCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: ShowNavigationBarLoadingFailCallback - /** 接口调用成功的回调函数 */ - success?: ShowNavigationBarLoadingSuccessCallback + interface NfcB { + /** [NfcB.close(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcB.close.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 断开连接 */ + close(option?: NdefCloseOption): void + /** [NfcB.connect(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcB.connect.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 连接 NFC 标签 */ + connect(option?: NdefConnectOption): void + /** [NfcB.getMaxTransceiveLength(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcB.getMaxTransceiveLength.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 获取最大传输长度 */ + getMaxTransceiveLength(option?: GetMaxTransceiveLengthOption): void + /** [NfcB.isConnected(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcB.isConnected.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * @warning **该接口已废弃,连接状态开发者自行维护即可** + * + * 检查是否已连接 */ + isConnected(option?: IsConnectedOption): void + /** [NfcB.setTimeout(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcB.setTimeout.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 设置超时时间 */ + setTimeout(option: SetTimeoutOption): void + /** [NfcB.transceive(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcB.transceive.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 发送数据 */ + transceive(option: TransceiveOption): void } - interface ShowRedPackageOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ShowRedPackageCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: ShowRedPackageFailCallback - /** 接口调用成功的回调函数 */ - success?: ShowRedPackageSuccessCallback + interface NfcF { + /** [NfcF.close(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcF.close.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 断开连接 */ + close(option?: NdefCloseOption): void + /** [NfcF.connect(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcF.connect.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 连接 NFC 标签 */ + connect(option?: NdefConnectOption): void + /** [NfcF.getMaxTransceiveLength(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcF.getMaxTransceiveLength.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 获取最大传输长度 */ + getMaxTransceiveLength(option?: GetMaxTransceiveLengthOption): void + /** [NfcF.isConnected(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcF.isConnected.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * @warning **该接口已废弃,连接状态开发者自行维护即可** + * + * 检查是否已连接 */ + isConnected(option?: IsConnectedOption): void + /** [NfcF.setTimeout(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcF.setTimeout.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 设置超时时间 */ + setTimeout(option: SetTimeoutOption): void + /** [NfcF.transceive(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcF.transceive.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 发送数据 */ + transceive(option: TransceiveOption): void } - interface ShowShareMenuOption { - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ShowShareMenuCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: ShowShareMenuFailCallback - /** 接口调用成功的回调函数 */ - success?: ShowShareMenuSuccessCallback - /** 是否使用带 shareTicket 的转发[详情](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html) */ - withShareTicket?: boolean + interface NfcV { + /** [NfcV.close(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcV.close.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 断开连接 */ + close(option?: NdefCloseOption): void + /** [NfcV.connect(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcV.connect.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 连接 NFC 标签 */ + connect(option?: NdefConnectOption): void + /** [NfcV.getMaxTransceiveLength(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcV.getMaxTransceiveLength.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 获取最大传输长度 */ + getMaxTransceiveLength(option?: GetMaxTransceiveLengthOption): void + /** [NfcV.isConnected(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcV.isConnected.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * @warning **该接口已废弃,连接状态开发者自行维护即可** + * + * 检查是否已连接 */ + isConnected(option?: IsConnectedOption): void + /** [NfcV.setTimeout(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcV.setTimeout.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 设置超时时间 */ + setTimeout(option: SetTimeoutOption): void + /** [NfcV.transceive(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NfcV.transceive.html) + * + * 需要基础库: `2.11.2` + * + * 在插件中使用:支持 + * + * 发送数据 */ + transceive(option: TransceiveOption): void } - interface ShowTabBarOption { - /** 是否需要动画效果 */ - animation?: boolean - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ShowTabBarCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: ShowTabBarFailCallback - /** 接口调用成功的回调函数 */ - success?: ShowTabBarSuccessCallback + interface Nfcrwerror { + /** 错误信息 + * + * | 错误码 | 错误信息 | 说明 | + * | - | - | - | + * | 13000 | 设备不支持NFC | | + * | 13001 | 系统NFC开关未打开 | | + * | 13010 | 未知错误 | | + * | 13019 | user is not authorized | 用户未授权 | + * | 13011 | invalid parameter | 参数无效 | + * | 13012 | parse NdefMessage failed | 将参数解析为NdefMessage失败 | + * | 13021 | NFC discovery already started | 已经开始NFC扫描 | + * | 13018 | NFC discovery has not started | 尝试在未开始NFC扫描时停止NFC扫描 | + * | 13022 | Tech already connected | 标签已经连接 | + * | 13023 | Tech has not connected | 尝试在未连接标签时断开连接 | + * | 13013 | NFC tag has not been discovered | 未扫描到NFC标签 | + * | 13014 | invalid tech | 无效的标签技术 | + * | 13015 | unavailable tech | 从标签上获取对应技术失败 | + * | 13024 | function not support | 当前标签技术不支持该功能 | + * | 13017 | system internal error | 相关读写操作失败 | + * | 13016 | connect fail | 连接失败 | */ errMsg: string + /** 错误码 + * + * | 错误码 | 错误信息 | 说明 | + * | - | - | - | + * | 13000 | 设备不支持NFC | | + * | 13001 | 系统NFC开关未打开 | | + * | 13010 | 未知错误 | | + * | 13019 | user is not authorized | 用户未授权 | + * | 13011 | invalid parameter | 参数无效 | + * | 13012 | parse NdefMessage failed | 将参数解析为NdefMessage失败 | + * | 13021 | NFC discovery already started | 已经开始NFC扫描 | + * | 13018 | NFC discovery has not started | 尝试在未开始NFC扫描时停止NFC扫描 | + * | 13022 | Tech already connected | 标签已经连接 | + * | 13023 | Tech has not connected | 尝试在未连接标签时断开连接 | + * | 13013 | NFC tag has not been discovered | 未扫描到NFC标签 | + * | 13014 | invalid tech | 无效的标签技术 | + * | 13015 | unavailable tech | 从标签上获取对应技术失败 | + * | 13024 | function not support | 当前标签技术不支持该功能 | + * | 13017 | system internal error | 相关读写操作失败 | + * | 13016 | connect fail | 连接失败 | */ errCode: number } - interface ShowTabBarRedDotOption { - /** tabBar 的哪一项,从左边算起 */ - index: number - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: ShowTabBarRedDotCompleteCallback - /** 接口调用失败的回调函数 */ - fail?: ShowTabBarRedDotFailCallback - /** 接口调用成功的回调函数 */ - success?: ShowTabBarRedDotSuccessCallback + interface NodesRef { + /** [[SelectorQuery](https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.html) NodesRef.boundingClientRect(function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/wxml/NodesRef.boundingClientRect.html) +* +* 在插件中使用:支持 +* +* 添加节点的布局位置的查询请求。相对于显示区域,以像素为单位。其功能类似于 DOM 的 `getBoundingClientRect`。返回 `NodesRef` 对应的 `SelectorQuery`。 +* +* **示例代码** +* +* ```js +Page({ + getRect () { + wx.createSelectorQuery().select('#the-id').boundingClientRect(function(rect){ + rect.id // 节点的ID + rect.dataset // 节点的dataset + rect.left // 节点的左边界坐标 + rect.right // 节点的右边界坐标 + rect.top // 节点的上边界坐标 + rect.bottom // 节点的下边界坐标 + rect.width // 节点的宽度 + rect.height // 节点的高度 + }).exec() + }, + getAllRects () { + wx.createSelectorQuery().selectAll('.a-class').boundingClientRect(function(rects){ + rects.forEach(function(rect){ + rect.id // 节点的ID + rect.dataset // 节点的dataset + rect.left // 节点的左边界坐标 + rect.right // 节点的右边界坐标 + rect.top // 节点的上边界坐标 + rect.bottom // 节点的下边界坐标 + rect.width // 节点的宽度 + rect.height // 节点的高度 + }) + }).exec() + } +}) +``` */ + boundingClientRect( + /** 回调函数,在执行 `SelectorQuery.exec` 方法后,节点信息会在 `callback` 中返回。 */ + callback?: BoundingClientRectCallback + ): SelectorQuery + /** [[SelectorQuery](https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.html) NodesRef.context(function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/wxml/NodesRef.context.html) +* +* 需要基础库: `2.4.2` +* +* 在插件中使用:支持 +* +* 添加节点的 Context 对象查询请求。目前支持 [VideoContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.html)、[CanvasContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.html)、[LivePlayerContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.html)、[EditorContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.html)和 [MapContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.html) 的获取。 +* +* **示例代码** +* +* ```js +Page({ + getContext () { + wx.createSelectorQuery().select('.the-video-class').context(function(res){ + console.log(res.context) // 节点对应的 Context 对象。如:选中的节点是