@doubao-dev/plugin-app-dev 0.0.0-stage → 0.0.40-canary-dea0ddc73-20261026073950

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/README.md +10 -2
  2. package/dist/147.js +9 -0
  3. package/dist/assets.d.ts +5 -0
  4. package/dist/assets.js +4 -0
  5. package/dist/index.d.ts +43 -0
  6. package/dist/index.js +1378 -0
  7. package/dist/plugin.d.ts +102 -0
  8. package/dist/plugin.js +4995 -0
  9. package/dist/preview.js +16 -0
  10. package/dist/rslib-runtime.js +33 -0
  11. package/dist/skills/doubao-plugin-app/SKILL.md +21 -0
  12. package/dist/skills/doubao-plugin-app/references/app-development.md +85 -0
  13. package/dist/skills/doubao-plugin-app/references/frontend/components/container-overlay.md +131 -0
  14. package/dist/skills/doubao-plugin-app/references/frontend/components/form-controls.md +146 -0
  15. package/dist/skills/doubao-plugin-app/references/frontend/components/interactive-controls.md +120 -0
  16. package/dist/skills/doubao-plugin-app/references/frontend/components/map-canvas.md +107 -0
  17. package/dist/skills/doubao-plugin-app/references/frontend/components/overview.md +43 -0
  18. package/dist/skills/doubao-plugin-app/references/frontend/components/scroll-list.md +149 -0
  19. package/dist/skills/doubao-plugin-app/references/frontend/components/text-media.md +209 -0
  20. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/01-/345/237/272/347/241/200.md +1389 -0
  21. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/02-/347/263/273/347/273/237.md +1376 -0
  22. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/03-/350/207/252/345/256/232/344/271/211/351/200/232/344/277/241.md +127 -0
  23. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/04-/345/256/232/344/275/215.md +784 -0
  24. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/05-/345/255/230/345/202/250.md +1176 -0
  25. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/06-/350/267/257/347/224/261.md +839 -0
  26. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/07-/347/225/214/351/235/242.md +376 -0
  27. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/08-/344/272/244/344/272/222.md +1319 -0
  28. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/09-/350/276/223/345/205/245.md +192 -0
  29. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/10-/347/275/221/347/273/234.md +900 -0
  30. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/11-/345/252/222/344/275/223.md +1496 -0
  31. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/12-/344/270/232/345/212/241/350/203/275/345/212/233.md +1281 -0
  32. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/13-/347/231/273/345/275/225.md +511 -0
  33. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/14-/346/224/257/344/273/230.md +943 -0
  34. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/15-/346/225/260/346/215/256/345/210/206/346/236/220.md +124 -0
  35. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/16-/350/223/235/347/211/231.md +3364 -0
  36. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/17-wi-fi.md +1028 -0
  37. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/18-/345/212/240/351/200/237/345/272/246/350/256/241.md +354 -0
  38. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/19-ibeacon.md +508 -0
  39. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/20-/347/275/227/347/233/230.md +320 -0
  40. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/21-/350/256/276/345/244/207/346/226/271/345/220/221.md +351 -0
  41. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/22-/351/231/200/350/236/272/344/273/252.md +354 -0
  42. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/23-/345/252/222/344/275/223-/350/256/276/345/244/207-/347/275/221/347/273/234.md +264 -0
  43. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/24-/347/237/255/344/277/241.md +155 -0
  44. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/25-/346/227/240/351/232/234/347/242/215.md +144 -0
  45. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/26-/345/237/272/347/241/200/344/277/241/346/201/257.md +238 -0
  46. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/27-/347/224/265/346/261/240.md +235 -0
  47. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/28-/345/211/252/350/264/264/346/235/277.md +303 -0
  48. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/29-/345/212/240/345/257/206.md +126 -0
  49. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/30-/346/227/245/345/216/206.md +417 -0
  50. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/31-/347/224/265/350/257/235.md +144 -0
  51. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/32-/346/211/253/347/240/201.md +236 -0
  52. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/33-/345/261/217/345/271/225.md +747 -0
  53. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/34-/351/234/207/345/212/250.md +277 -0
  54. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/35-/346/226/207/344/273/266/347/263/273/347/273/237.md +431 -0
  55. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/common-errors.md +69 -0
  56. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/groups.md +43 -0
  57. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/quick-reference.md +436 -0
  58. package/dist/skills/doubao-plugin-app/references/frontend/examples/common-patterns.md +590 -0
  59. package/dist/skills/doubao-plugin-app/references/frontend/examples/doubao-agentic-service-api-recipes.md +209 -0
  60. package/dist/skills/doubao-plugin-app/references/frontend/examples/page-widget-basics.md +368 -0
  61. package/dist/skills/doubao-plugin-app/references/frontend/examples/page-widget-recipes.md +65 -0
  62. package/dist/skills/doubao-plugin-app/references/frontend/framework/core.md +283 -0
  63. package/dist/skills/doubao-plugin-app/references/frontend/guides/auth.md +277 -0
  64. package/dist/skills/doubao-plugin-app/references/frontend/guides/best-practices.md +574 -0
  65. package/dist/skills/doubao-plugin-app/references/frontend/guides/client-tools-and-events.md +209 -0
  66. package/dist/skills/doubao-plugin-app/references/frontend/guides/component-development.md +832 -0
  67. package/dist/skills/doubao-plugin-app/references/frontend/guides/debugger-mcp.md +537 -0
  68. package/dist/skills/doubao-plugin-app/references/frontend/guides/expired-widget.md +101 -0
  69. package/dist/skills/doubao-plugin-app/references/frontend/guides/performance-optimization.md +417 -0
  70. package/dist/skills/doubao-plugin-app/references/frontend/guides/troubleshooting.md +278 -0
  71. package/dist/skills/doubao-plugin-app/references/frontend/lynx/best-practices.md +720 -0
  72. package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/pseudo-classes.md +149 -0
  73. package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/selectors.md +224 -0
  74. package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/supported-properties.md +269 -0
  75. package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/values-and-units.md +314 -0
  76. package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/flex-layout.md +334 -0
  77. package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/grid-layout.md +408 -0
  78. package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/linear-layout.md +355 -0
  79. package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/relative-layout.md +189 -0
  80. package/dist/skills/doubao-plugin-app/references/frontend/lynx/lynx-vs-web/css-differences.md +737 -0
  81. package/dist/skills/doubao-plugin-app/references/frontend/lynx/lynx-vs-web/migration-guide.md +669 -0
  82. package/dist/skills/doubao-plugin-app/references/frontend/lynx/lynx-vs-web/unsupported-features.md +290 -0
  83. package/dist/skills/doubao-plugin-app/references/frontend/lynx/overview.md +60 -0
  84. package/dist/skills/doubao-plugin-app/references/frontend/lynx/patterns/animation.md +243 -0
  85. package/dist/skills/doubao-plugin-app/references/frontend/lynx/patterns/responsive.md +194 -0
  86. package/dist/skills/doubao-plugin-app/references/frontend/lynx/patterns/theming.md +143 -0
  87. package/dist/skills/doubao-plugin-app/references/frontend/lynx/quick-reference.md +229 -0
  88. package/dist/skills/doubao-plugin-app/references/frontend/rules/dos-and-donts.md +479 -0
  89. package/dist/skills/doubao-plugin-app/references/frontend/widget-templates/design-boundary.md +46 -0
  90. package/dist/skills/doubao-plugin-app/references/frontend/widget-templates/overview.md +118 -0
  91. package/dist/skills/doubao-plugin-app/references/frontend/widget-templates/props.md +301 -0
  92. package/dist/skills/doubao-plugin-app/references/mcp-and-cards.md +38 -0
  93. package/dist/templates/README.md.template +11 -0
  94. package/dist/templates/com.doubao/app/manifest.yaml +41 -0
  95. package/dist/templates/com.doubao/app/package.json.template +13 -0
  96. package/dist/templates/com.doubao/app/src/app.config.ts.template +5 -0
  97. package/dist/templates/com.doubao/app/src/app.ts.template +3 -0
  98. package/dist/templates/com.doubao/app/src/pages/home/index.css +14 -0
  99. package/dist/templates/com.doubao/app/src/pages/home/index.tsx.template +14 -0
  100. package/dist/templates/com.doubao/app/src/widgets/example/index.tsx.template +29 -0
  101. package/dist/templates/com.doubao/app/tsconfig.json +19 -0
  102. package/dist/templates/mcp.json +9 -0
  103. package/dist/templates/plugin.json.template +29 -0
  104. package/dist/templates/skills/example/SKILL.md.template +14 -0
  105. package/dist/upload.d.ts +44 -0
  106. package/dist/upload.js +38 -0
  107. package/package.json +60 -3
@@ -0,0 +1,1389 @@
1
+ # 豆包应用插件的端能力 API: 基础
2
+
3
+ 账号、授权、豆包客户端信息、窗口信息和能力可用性。
4
+
5
+ [返回目录](./groups.md) | [返回速查](./quick-reference.md)
6
+
7
+ ## 速查
8
+
9
+ | API | 说明 |
10
+ | --- | --- |
11
+ | [getAccountInfo](#getaccountinfo) | 异步获取账号信息。 |
12
+ | [getAccountInfoSync](#getaccountinfosync) | 同步获取账号信息。<br><br>同步 API。 |
13
+ | [authorize](#authorize) | 提前向用户发起指定 scope 的授权;scope.healthData 仅用于选择 iOS HealthKit 系统授权路径。 |
14
+ | [arrayBufferToBase64](#arraybuffertobase64) | 将 ArrayBuffer 转换为 Base64 字符串。 |
15
+ | [base64ToArrayBuffer](#base64toarraybuffer) | 将 Base64 字符串转换为 ArrayBuffer。 |
16
+ | [canIUse](#caniuse) | 检测当前环境是否支持指定 API 或能力。 |
17
+ | [getPerformance](#getperformance) | 获取当前应用插件的性能数据。 Entry 由客户端保存;getEntries*() 同步查询当前快照,observer 只接收新完成的 Entry。 |
18
+ | [getSetting](#getsetting) | 获取用户当前的应用授权设置。 |
19
+ | [openSetting](#opensetting) | 打开应用插件授权设置页面。 |
20
+ | [getUserIdentifiers](#getuseridentifiers) | 获取当前用户的加密设备标识,参数可省略或传入空对象。 |
21
+
22
+ ## API 详情
23
+
24
+ <a id="getaccountinfo"></a>
25
+ ### getAccountInfo()
26
+
27
+ # getAccountInfo
28
+
29
+ 异步获取账号信息。
30
+
31
+ ## 扫码预览
32
+ ![扫码预览 getAccountInfo](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fbasic%252Fget-account-info%252Findex)
33
+
34
+ ## 使用限制
35
+
36
+ > [!WARNING]
37
+ > **Android、iOS**:仅返回 develop 或 release,永远不会返回 trial;依赖 trial 判断体验版环境的逻辑不会生效。
38
+
39
+ ## 支持版本
40
+
41
+ 前端库版本不低于 `0.0.18`。
42
+
43
+ ## 支持平台
44
+
45
+ <table>
46
+ <thead>
47
+ <tr><th>平台</th><th>支持情况</th></tr>
48
+ </thead>
49
+ <tbody>
50
+ <tr><td>Android</td><td>支持</td></tr>
51
+ <tr><td>iOS</td><td>支持</td></tr>
52
+ <tr><td>PC</td><td>不支持</td></tr>
53
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
54
+ </tbody>
55
+ </table>
56
+
57
+ ## 支持场景
58
+
59
+ <table>
60
+ <thead>
61
+ <tr><th>场景</th><th>支持情况</th></tr>
62
+ </thead>
63
+ <tbody>
64
+ <tr><td>页面</td><td>支持</td></tr>
65
+ <tr><td>卡片</td><td>支持</td></tr>
66
+ </tbody>
67
+ </table>
68
+
69
+ ## 调用方式
70
+
71
+ ### 异步 API
72
+
73
+ ```typescript
74
+ getAccountInfo(params?: object): Promise<GetAccountInfoResult>
75
+ ```
76
+
77
+ ## 入参
78
+
79
+ 无。
80
+
81
+ ## 调用示例
82
+
83
+ ```typescript
84
+ import { getAccountInfo } from '@doubao-dev/framework/api';
85
+
86
+ const result = await getAccountInfo();
87
+ console.log(result.miniProgram.appId, result.miniProgram.envVersion, result.miniProgram.version);
88
+ ```
89
+
90
+ ## 成功返回
91
+
92
+ <table>
93
+ <thead>
94
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>约束</th><th>说明</th></tr>
95
+ </thead>
96
+ <tbody>
97
+ <tr><td><code>miniProgram</code></td><td><code>DoubaoAppAccountInfo</code></td><td>是</td><td>-</td><td>应用插件账号信息</td></tr>
98
+ <tr><td><code>miniProgram.appId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>应用插件 appId</td></tr>
99
+ <tr><td><code>miniProgram.envVersion</code></td><td><code>&quot;develop&quot; | &quot;trial&quot; | &quot;release&quot;</code></td><td>是</td><td>Android、iOS 当前只返回 develop 或 release,不会返回 trial</td><td>当前应用插件的版本类型。<br><br>- develop:开发版<br>- trial:体验版<br>- release:正式版。Android、iOS:仅返回 develop 或 release,永远不会返回 trial。</td></tr>
100
+ <tr><td><code>miniProgram.version</code></td><td><code>string</code></td><td>是</td><td>-</td><td>应用插件版本号。</td></tr>
101
+ <tr><td><code>plugin</code></td><td><code>PluginAccountInfo</code></td><td>否</td><td>-</td><td>插件账号信息(仅在插件中调用时包含)</td></tr>
102
+ <tr><td><code>plugin.appId</code></td><td><code>string</code></td><td>否</td><td>-</td><td>插件 appId</td></tr>
103
+ <tr><td><code>plugin.version</code></td><td><code>string</code></td><td>否</td><td>-</td><td>插件版本号,'a.b.c' 形式</td></tr>
104
+ </tbody>
105
+ </table>
106
+
107
+ ### 返回示例
108
+
109
+ ```json
110
+ {
111
+ "miniProgram": {
112
+ "appId": "7000000000000000000",
113
+ "envVersion": "release",
114
+ "version": "1.0.0"
115
+ }
116
+ }
117
+ ```
118
+
119
+ ## 错误处理
120
+
121
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
122
+
123
+ ### 错误码
124
+
125
+ #### 通用错误码
126
+
127
+ <table>
128
+ <thead>
129
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
130
+ </thead>
131
+ <tbody>
132
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android</td></tr>
133
+ </tbody>
134
+ </table>
135
+
136
+ <a id="getaccountinfosync"></a>
137
+ ### getAccountInfoSync()
138
+
139
+ # getAccountInfoSync
140
+
141
+ 同步获取账号信息。
142
+
143
+ ## 扫码预览
144
+ ![扫码预览 getAccountInfoSync](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fbasic%252Fget-account-info%252Findex)
145
+
146
+ ## 使用限制
147
+
148
+ > [!WARNING]
149
+ > **Android、iOS**:仅返回 develop 或 release,永远不会返回 trial;依赖 trial 判断体验版环境的逻辑不会生效。
150
+
151
+ ## 支持版本
152
+
153
+ 前端库版本不低于 `0.0.18`。
154
+
155
+ ## 支持平台
156
+
157
+ <table>
158
+ <thead>
159
+ <tr><th>平台</th><th>支持情况</th></tr>
160
+ </thead>
161
+ <tbody>
162
+ <tr><td>Android</td><td>支持</td></tr>
163
+ <tr><td>iOS</td><td>支持</td></tr>
164
+ <tr><td>PC</td><td>不支持</td></tr>
165
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
166
+ </tbody>
167
+ </table>
168
+
169
+ ## 支持场景
170
+
171
+ <table>
172
+ <thead>
173
+ <tr><th>场景</th><th>支持情况</th></tr>
174
+ </thead>
175
+ <tbody>
176
+ <tr><td>页面</td><td>支持</td></tr>
177
+ <tr><td>卡片</td><td>支持</td></tr>
178
+ </tbody>
179
+ </table>
180
+
181
+ ## 调用方式
182
+
183
+ ### 同步 API
184
+
185
+ ```typescript
186
+ getAccountInfoSync(params?: object): GetAccountInfoResult
187
+ ```
188
+
189
+ ## 入参
190
+
191
+ 无。
192
+
193
+ ## 调用示例
194
+
195
+ ```typescript
196
+ import { getAccountInfoSync } from '@doubao-dev/framework/api';
197
+
198
+ const result = getAccountInfoSync();
199
+ console.log(result.miniProgram.appId, result.miniProgram.envVersion, result.miniProgram.version);
200
+ ```
201
+
202
+ ## 返回值
203
+
204
+ <table>
205
+ <thead>
206
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>约束</th><th>说明</th></tr>
207
+ </thead>
208
+ <tbody>
209
+ <tr><td><code>miniProgram</code></td><td><code>DoubaoAppAccountInfo</code></td><td>是</td><td>-</td><td>应用插件账号信息</td></tr>
210
+ <tr><td><code>miniProgram.appId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>应用插件 appId</td></tr>
211
+ <tr><td><code>miniProgram.envVersion</code></td><td><code>&quot;develop&quot; | &quot;trial&quot; | &quot;release&quot;</code></td><td>是</td><td>Android、iOS 当前只返回 develop 或 release,不会返回 trial</td><td>当前应用插件的版本类型。<br><br>- develop:开发版<br>- trial:体验版<br>- release:正式版。Android、iOS:仅返回 develop 或 release,永远不会返回 trial。</td></tr>
212
+ <tr><td><code>miniProgram.version</code></td><td><code>string</code></td><td>是</td><td>-</td><td>应用插件版本号。</td></tr>
213
+ <tr><td><code>plugin</code></td><td><code>PluginAccountInfo</code></td><td>否</td><td>-</td><td>插件账号信息(仅在插件中调用时包含)</td></tr>
214
+ <tr><td><code>plugin.appId</code></td><td><code>string</code></td><td>否</td><td>-</td><td>插件 appId</td></tr>
215
+ <tr><td><code>plugin.version</code></td><td><code>string</code></td><td>否</td><td>-</td><td>插件版本号,'a.b.c' 形式</td></tr>
216
+ </tbody>
217
+ </table>
218
+
219
+ ### 返回示例
220
+
221
+ ```json
222
+ {
223
+ "miniProgram": {
224
+ "appId": "7000000000000000000",
225
+ "envVersion": "release",
226
+ "version": "1.0.0"
227
+ }
228
+ }
229
+ ```
230
+
231
+ ## 错误处理
232
+
233
+ 同步调用失败时抛出错误。错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
234
+
235
+ ### 错误码
236
+
237
+ #### 通用错误码
238
+
239
+ <table>
240
+ <thead>
241
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
242
+ </thead>
243
+ <tbody>
244
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android</td></tr>
245
+ </tbody>
246
+ </table>
247
+
248
+ <a id="authorize"></a>
249
+ ### authorize()
250
+
251
+ # authorize
252
+
253
+ 提前向用户发起指定 scope 的授权;scope.healthData 仅用于选择 iOS HealthKit 系统授权路径。
254
+
255
+ ## 扫码预览
256
+ ![扫码预览 authorize](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fbasic%252Fauthorize%252Findex)
257
+
258
+ ## 使用限制
259
+
260
+ > [!WARNING]
261
+ > **Android、iOS**:传入 scope.payment 时被判为非法 scope 并直接失败;依赖 scope.payment 发起授权的调用无法成功。
262
+
263
+ ## 支持版本
264
+
265
+ 前端库版本不低于 `0.0.18`。
266
+
267
+ ## 支持平台
268
+
269
+ <table>
270
+ <thead>
271
+ <tr><th>平台</th><th>支持情况</th></tr>
272
+ </thead>
273
+ <tbody>
274
+ <tr><td>Android</td><td>支持</td></tr>
275
+ <tr><td>iOS</td><td>支持</td></tr>
276
+ <tr><td>PC</td><td>不支持</td></tr>
277
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
278
+ </tbody>
279
+ </table>
280
+
281
+ ## 支持场景
282
+
283
+ <table>
284
+ <thead>
285
+ <tr><th>场景</th><th>支持情况</th></tr>
286
+ </thead>
287
+ <tbody>
288
+ <tr><td>页面</td><td>支持</td></tr>
289
+ <tr><td>卡片</td><td>不支持</td></tr>
290
+ </tbody>
291
+ </table>
292
+
293
+ ## 接入准备
294
+
295
+ ### 权限要求
296
+
297
+ <table>
298
+ <thead>
299
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
300
+ </thead>
301
+ <tbody>
302
+ <tr><td>应用权限</td><td><code>非 scope.healthData 的 scope</code></td><td>必须</td><td>Android、iOS</td><td>按传入 scope 发起对应的应用授权。</td></tr>
303
+ <tr><td>应用权限</td><td><code>scope.healthData</code></td><td>否</td><td>iOS</td><td>不校验 manifest,也不查询或更新服务端应用插件的 scope 状态。</td></tr>
304
+ <tr><td>系统权限</td><td>HealthKit read</td><td>必须</td><td>iOS</td><td>scope.healthData 会申请 options.types 对应的系统读取权限。</td></tr>
305
+ </tbody>
306
+ </table>
307
+
308
+ ### 授权行为
309
+
310
+ - **Android**:非健康 scope 会发起应用插件及相应系统授权;当前不支持 scope.healthData。
311
+ - **iOS**:非健康 scope 会发起应用插件及相应系统授权;scope.healthData 仅可能展示 HealthKit 系统授权框。
312
+
313
+ ### 前置条件
314
+
315
+ - **Android**:非健康 scope 需要在应用权限声明中配置;当前不支持 scope.healthData
316
+ - **iOS**:非健康 scope 需要在应用权限声明中配置;scope.healthData 不需要 manifest 声明
317
+
318
+ ## 使用说明
319
+
320
+ - **Android**:非健康 scope 的授权状态可通过 `getSetting` 查询;当前不支持 scope.healthData。
321
+ - **iOS**:非健康 scope 的授权状态可通过 `getSetting` 查询;scope.healthData 的逐类型系统状态通过 `getAppAuthorizeSetting` 查询。
322
+ - **iOS**:HealthKit 授权成功表示系统授权流程已完成;Apple 不向应用公开每个读取类型是否被用户拒绝。
323
+
324
+ ## 调用方式
325
+
326
+ ### 异步 API
327
+
328
+ ```typescript
329
+ authorize(params: AuthorizeRequest): Promise<object>
330
+ ```
331
+
332
+ ## 入参
333
+
334
+ <table>
335
+ <thead>
336
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
337
+ </thead>
338
+ <tbody>
339
+ <tr><td><code>options</code></td><td><code>HealthDataAuthorizeOptions</code></td><td>否</td><td><code>-</code></td><td>-</td><td>权限扩展参数;仅 scope.healthData 生效,用于传入 HealthKit 读取类型,其他 scope 会忽略该字段。</td></tr>
340
+ <tr><td><code>options.types</code></td><td><code>HealthDataType[]</code></td><td>否</td><td>-</td><td>-</td><td>健康数据类型列表;用于申请对应的 HealthKit 读取权限。</td></tr>
341
+ <tr><td><code>scope</code></td><td><code>Scope</code></td><td>是</td><td>-</td><td>-</td><td>授权范围。Android、iOS:传入 scope.payment 时被判为非法 scope 并直接失败。</td></tr>
342
+ </tbody>
343
+ </table>
344
+
345
+ ## 调用示例
346
+
347
+ ```typescript
348
+ import { authorize } from '@doubao-dev/framework/api';
349
+
350
+ await authorize({ scope: 'scope.userLocation' });
351
+ await authorize({
352
+ scope: 'scope.healthData',
353
+ options: { types: ['heart_rate', 'step_count'] }
354
+ });
355
+ ```
356
+
357
+ ## 成功返回
358
+
359
+ 无返回字段。
360
+
361
+ ## 错误处理
362
+
363
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
364
+
365
+ ### 失败示例
366
+
367
+ ```json
368
+ {
369
+ "errNo": 107,
370
+ "errMsg": "user permission denied"
371
+ }
372
+ ```
373
+
374
+ ### 错误码
375
+
376
+ <table>
377
+ <thead>
378
+ <tr><th>errNo</th><th>errMsg</th><th>平台</th><th>触发条件</th><th>处理建议</th></tr>
379
+ </thead>
380
+ <tbody>
381
+ <tr><td><code>104</code></td><td><code>invalid parameter</code></td><td>Android、iOS</td><td>传入的 scope 为空或不受支持(如 scope.payment)</td><td>检查并传入受支持的 scope 后重试。</td></tr>
382
+ <tr><td><code>104</code></td><td><code>invalid parameter</code></td><td>iOS</td><td>scope.healthData 未传 options.types、列表为空或包含不支持类型</td><td>传入非空且受支持的健康数据类型列表。</td></tr>
383
+ <tr><td><code>106</code></td><td><code>system permission denied</code></td><td>Android、iOS</td><td>对应能力的系统权限被拒绝</td><td>引导用户在系统设置中开启对应权限后重试。</td></tr>
384
+ <tr><td><code>107</code></td><td><code>user permission denied</code></td><td>Android、iOS</td><td>用户拒绝了本次应用授权</td><td>说明能力用途后再次调用 `authorize` 重新发起授权。</td></tr>
385
+ <tr><td><code>114</code></td><td><code>operation cancelled</code></td><td>Android、iOS</td><td>用户取消了授权弹窗</td><td>用户需要时可再次调用 `authorize` 重新发起授权。</td></tr>
386
+ <tr><td><code>301</code></td><td><code>network request cancelled</code></td><td>iOS</td><td>授权过程中的网络请求被取消</td><td>确认应用和网络状态后重试。</td></tr>
387
+ <tr><td><code>302</code></td><td><code>connection timed out</code></td><td>iOS</td><td>授权过程中的网络连接超时</td><td>检查网络连接后重试。</td></tr>
388
+ <tr><td><code>303</code></td><td><code>no network connection</code></td><td>iOS</td><td>当前无可用网络连接</td><td>恢复网络连接后重试。</td></tr>
389
+ <tr><td><code>305</code></td><td><code>network failure</code></td><td>Android、iOS</td><td>授权过程中发生其他网络错误</td><td>检查网络连接,稍后重试。</td></tr>
390
+ <tr><td><code>112</code></td><td><code>invalid result</code></td><td>iOS</td><td>授权服务返回的数据无法解析</td><td>稍后重试;持续失败时反馈服务端响应异常。</td></tr>
391
+ </tbody>
392
+ </table>
393
+
394
+ #### 通用错误码
395
+
396
+ <table>
397
+ <thead>
398
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
399
+ </thead>
400
+ <tbody>
401
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
402
+ </tbody>
403
+ </table>
404
+
405
+ ## 平台差异
406
+
407
+ - **iOS**:网络类失败会细分为 301/302/303/305,并可能返回 112;Android 的网络类失败统一返回 305。
408
+
409
+ <a id="arraybuffertobase64"></a>
410
+ ### arrayBufferToBase64()
411
+
412
+ # arrayBufferToBase64
413
+
414
+ 将 ArrayBuffer 转换为 Base64 字符串。
415
+
416
+ ## 扫码预览
417
+ ![扫码预览 arrayBufferToBase64](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fbasic%252Fbase64%252Findex)
418
+
419
+ ## 支持版本
420
+
421
+ 前端库版本不低于 `0.1.0`。
422
+
423
+ ## 支持平台
424
+
425
+ <table>
426
+ <thead>
427
+ <tr><th>平台</th><th>支持情况</th></tr>
428
+ </thead>
429
+ <tbody>
430
+ <tr><td>Android</td><td>支持</td></tr>
431
+ <tr><td>iOS</td><td>支持</td></tr>
432
+ <tr><td>PC</td><td>支持</td></tr>
433
+ <tr><td>HarmonyOS</td><td>支持</td></tr>
434
+ </tbody>
435
+ </table>
436
+
437
+ ## 支持场景
438
+
439
+ <table>
440
+ <thead>
441
+ <tr><th>场景</th><th>支持情况</th></tr>
442
+ </thead>
443
+ <tbody>
444
+ <tr><td>页面</td><td>支持</td></tr>
445
+ <tr><td>卡片</td><td>支持</td></tr>
446
+ </tbody>
447
+ </table>
448
+
449
+ ## 调用方式
450
+
451
+ ### 同步 API
452
+
453
+ ```typescript
454
+ arrayBufferToBase64(buffer: ArrayBuffer): string
455
+ ```
456
+
457
+ ## 入参
458
+
459
+ <table>
460
+ <thead>
461
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
462
+ </thead>
463
+ <tbody>
464
+ <tr><td><code>buffer</code></td><td><code>ArrayBuffer</code></td><td>是</td><td>-</td><td>-</td><td>需要编码的二进制数据。</td></tr>
465
+ </tbody>
466
+ </table>
467
+
468
+ ## 调用示例
469
+
470
+ ```typescript
471
+ import { arrayBufferToBase64 } from '@doubao-dev/framework/api';
472
+
473
+ const base64 = arrayBufferToBase64(new Uint8Array([1, 2, 3, 4]).buffer);
474
+ console.log(base64); // AQIDBA==
475
+ ```
476
+
477
+ ## 返回值
478
+
479
+ 标准 Base64 编码字符串。
480
+
481
+ ### 返回示例
482
+
483
+ ```json
484
+ "AQIDBA=="
485
+ ```
486
+
487
+ <a id="base64toarraybuffer"></a>
488
+ ### base64ToArrayBuffer()
489
+
490
+ # base64ToArrayBuffer
491
+
492
+ 将 Base64 字符串转换为 ArrayBuffer。
493
+
494
+ ## 扫码预览
495
+ ![扫码预览 base64ToArrayBuffer](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fbasic%252Fbase64%252Findex)
496
+
497
+ ## 支持版本
498
+
499
+ 前端库版本不低于 `0.1.0`。
500
+
501
+ ## 支持平台
502
+
503
+ <table>
504
+ <thead>
505
+ <tr><th>平台</th><th>支持情况</th></tr>
506
+ </thead>
507
+ <tbody>
508
+ <tr><td>Android</td><td>支持</td></tr>
509
+ <tr><td>iOS</td><td>支持</td></tr>
510
+ <tr><td>PC</td><td>支持</td></tr>
511
+ <tr><td>HarmonyOS</td><td>支持</td></tr>
512
+ </tbody>
513
+ </table>
514
+
515
+ ## 支持场景
516
+
517
+ <table>
518
+ <thead>
519
+ <tr><th>场景</th><th>支持情况</th></tr>
520
+ </thead>
521
+ <tbody>
522
+ <tr><td>页面</td><td>支持</td></tr>
523
+ <tr><td>卡片</td><td>支持</td></tr>
524
+ </tbody>
525
+ </table>
526
+
527
+ ## 调用方式
528
+
529
+ ### 同步 API
530
+
531
+ ```typescript
532
+ base64ToArrayBuffer(base64: string): ArrayBuffer
533
+ ```
534
+
535
+ ## 入参
536
+
537
+ <table>
538
+ <thead>
539
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
540
+ </thead>
541
+ <tbody>
542
+ <tr><td><code>base64</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>需要解码的标准 Base64 字符串。</td></tr>
543
+ </tbody>
544
+ </table>
545
+
546
+ ## 调用示例
547
+
548
+ ```typescript
549
+ import { base64ToArrayBuffer } from '@doubao-dev/framework/api';
550
+
551
+ const buffer = base64ToArrayBuffer('AQIDBA==');
552
+ console.log(Array.from(new Uint8Array(buffer))); // [1, 2, 3, 4]
553
+ ```
554
+
555
+ ## 返回值
556
+
557
+ 解码后的二进制数据。
558
+
559
+ ### 返回示例
560
+
561
+ ```json
562
+ {
563
+ "byteLength": 4
564
+ }
565
+ ```
566
+
567
+ <a id="caniuse"></a>
568
+ ### canIUse()
569
+
570
+ # canIUse
571
+
572
+ 检测当前环境是否支持指定 API 或能力。
573
+
574
+ ## 支持版本
575
+
576
+ 前端库版本不低于 `0.0.14`。
577
+
578
+ ## 支持平台
579
+
580
+ <table>
581
+ <thead>
582
+ <tr><th>平台</th><th>支持情况</th></tr>
583
+ </thead>
584
+ <tbody>
585
+ <tr><td>Android</td><td>支持</td></tr>
586
+ <tr><td>iOS</td><td>支持</td></tr>
587
+ <tr><td>PC</td><td>不支持</td></tr>
588
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
589
+ </tbody>
590
+ </table>
591
+
592
+ ## 调用方式
593
+
594
+ ### 异步 API
595
+
596
+ ```typescript
597
+ canIUse(params: CanIUseParams): Promise<CanIUseResult>
598
+ ```
599
+
600
+ ## 入参
601
+
602
+ <table>
603
+ <thead>
604
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
605
+ </thead>
606
+ <tbody>
607
+ <tr><td><code>schema</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>需要检测的能力标识,例如 API 名称</td></tr>
608
+ </tbody>
609
+ </table>
610
+
611
+ ## 调用示例
612
+
613
+ ```typescript
614
+ import { canIUse } from '@doubao-dev/framework/api';
615
+
616
+ const { result } = await canIUse({ schema: 'doubao.getLocation' });
617
+ console.log('是否支持 getLocation:', result);
618
+ ```
619
+
620
+ ## 成功返回
621
+
622
+ <table>
623
+ <thead>
624
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
625
+ </thead>
626
+ <tbody>
627
+ <tr><td><code>result</code></td><td><code>boolean</code></td><td>是</td><td>是否支持所检测的能力</td></tr>
628
+ </tbody>
629
+ </table>
630
+
631
+ ### 返回示例
632
+
633
+ ```json
634
+ {
635
+ "result": true
636
+ }
637
+ ```
638
+
639
+ ## 错误处理
640
+
641
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
642
+
643
+ ### 失败示例
644
+
645
+ ```json
646
+ {
647
+ "errNo": 600001,
648
+ "errMsg": "invalid parameter"
649
+ }
650
+ ```
651
+
652
+ ### 错误码
653
+
654
+ <table>
655
+ <thead>
656
+ <tr><th>errNo</th><th>errMsg</th><th>平台</th><th>触发条件</th><th>处理建议</th></tr>
657
+ </thead>
658
+ <tbody>
659
+ <tr><td><code>600001</code></td><td><code>invalid parameter</code></td><td>Android、iOS</td><td>schema 为空或格式不合法</td><td>传入有效的 schema 字符串,格式为&quot;命名空间.方法名&quot;</td></tr>
660
+ </tbody>
661
+ </table>
662
+
663
+ <a id="getperformance"></a>
664
+ ### getPerformance()
665
+
666
+ # getPerformance
667
+
668
+ 获取当前应用插件的性能数据。
669
+
670
+ Entry 由客户端保存;`getEntries*()` 同步查询当前快照,observer 只接收新完成的 Entry。
671
+
672
+ ## 支持版本
673
+
674
+ 前端库版本不低于 `0.0.42`。
675
+
676
+ ## 支持平台
677
+
678
+ <table>
679
+ <thead>
680
+ <tr><th>平台</th><th>支持情况</th></tr>
681
+ </thead>
682
+ <tbody>
683
+ <tr><td>Android</td><td>支持</td></tr>
684
+ <tr><td>iOS</td><td>支持</td></tr>
685
+ <tr><td>PC</td><td>不支持</td></tr>
686
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
687
+ </tbody>
688
+ </table>
689
+
690
+ ## 支持场景
691
+
692
+ <table>
693
+ <thead>
694
+ <tr><th>场景</th><th>支持情况</th></tr>
695
+ </thead>
696
+ <tbody>
697
+ <tr><td>页面</td><td>支持</td></tr>
698
+ <tr><td>卡片</td><td>支持</td></tr>
699
+ </tbody>
700
+ </table>
701
+
702
+ ## 使用说明
703
+
704
+ - 仅在需要接收后续新完成的 Entry 时创建 observer;不再需要时调用 disconnect。
705
+
706
+ ## 调用方式
707
+
708
+ ### 同步 API
709
+
710
+ ```typescript
711
+ getPerformance(): Performance
712
+ ```
713
+
714
+ ## 入参
715
+
716
+ 无。
717
+
718
+ ## 调用示例
719
+
720
+ ```typescript
721
+ import { getPerformance } from '@doubao-dev/framework/api';
722
+
723
+ const performance = getPerformance();
724
+ const observer = performance.createObserver((entryList) => {
725
+ console.log(entryList.getEntries());
726
+ });
727
+
728
+ performance.setBufferSize(100);
729
+ observer.observe({ entryTypes: ['render'] });
730
+ console.log(performance.getEntriesByType('render'));
731
+ observer.disconnect();
732
+ ```
733
+
734
+ ## 返回值
735
+
736
+ <table>
737
+ <thead>
738
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
739
+ </thead>
740
+ <tbody>
741
+ <tr><td><code>createObserver</code></td><td><code>(callback: PerformanceObserverCallback) =&gt; PerformanceObserver</code></td><td>是</td><td>创建性能观察者。调用返回对象的 `observe` 后,回调会接收之后新完成且匹配的 Entry。</td></tr>
742
+ <tr><td><code>getEntries</code></td><td><code>() =&gt; PerformanceEntry[]</code></td><td>是</td><td>返回当前应用插件已记录的全部性能 Entry。</td></tr>
743
+ <tr><td><code>getEntriesByName</code></td><td><code>(name: string, entryType?: string) =&gt; PerformanceEntry[]</code></td><td>是</td><td>返回指定名称的性能 Entry;传入 entryType 时同时按类型筛选。</td></tr>
744
+ <tr><td><code>getEntriesByType</code></td><td><code>(entryType: string) =&gt; PerformanceEntry[]</code></td><td>是</td><td>返回指定 entryType 的性能 Entry。</td></tr>
745
+ <tr><td><code>setBufferSize</code></td><td><code>(size: number) =&gt; void</code></td><td>是</td><td>设置客户端最多保留的性能 Entry 数量。</td></tr>
746
+ </tbody>
747
+ </table>
748
+
749
+ ### 返回示例
750
+
751
+ ```json
752
+ [
753
+ {
754
+ "entryType": "render",
755
+ "name": "firstRender",
756
+ "startTime": 1730000000000,
757
+ "duration": 42,
758
+ "path": "pages/index/index",
759
+ "pageId": 1
760
+ }
761
+ ]
762
+ ```
763
+
764
+ <a id="getsetting"></a>
765
+ ### getSetting()
766
+
767
+ # getSetting
768
+
769
+ 获取用户当前的应用授权设置。
770
+
771
+ ## 扫码预览
772
+ ![扫码预览 getSetting](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fbasic%252Fget-setting%252Findex)
773
+
774
+ ## 支持版本
775
+
776
+ 前端库版本不低于 `0.0.36`。
777
+
778
+ ## 支持平台
779
+
780
+ <table>
781
+ <thead>
782
+ <tr><th>平台</th><th>支持情况</th></tr>
783
+ </thead>
784
+ <tbody>
785
+ <tr><td>Android</td><td>支持</td></tr>
786
+ <tr><td>iOS</td><td>支持</td></tr>
787
+ <tr><td>PC</td><td>不支持</td></tr>
788
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
789
+ </tbody>
790
+ </table>
791
+
792
+ ## 支持场景
793
+
794
+ <table>
795
+ <thead>
796
+ <tr><th>场景</th><th>支持情况</th></tr>
797
+ </thead>
798
+ <tbody>
799
+ <tr><td>页面</td><td>支持</td></tr>
800
+ <tr><td>卡片</td><td>支持</td></tr>
801
+ </tbody>
802
+ </table>
803
+
804
+ ## 使用说明
805
+
806
+ - authSetting 只表示当前应用插件的 scope 授权,不表示操作系统权限;HealthKit 逐类型系统状态通过 getAppAuthorizeSetting 查询。
807
+ - authSetting 只包含已向用户请求过且状态明确的权限;豆包当前不支持订阅模板,不要传入 withSubscriptions: true。
808
+
809
+ ## 调用方式
810
+
811
+ ### 异步 API
812
+
813
+ ```typescript
814
+ getSetting(params?: GetSettingParams): Promise<GetSettingResult>
815
+ ```
816
+
817
+ ## 入参
818
+
819
+ <table>
820
+ <thead>
821
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
822
+ </thead>
823
+ <tbody>
824
+ <tr><td><code>withSubscriptions</code></td><td><code>false</code></td><td>否</td><td><code>false</code></td><td>豆包 Android、iOS 当前不支持订阅模板,仅支持 false</td><td>是否同时获取用户订阅消息的订阅状态;当前仅支持 false。</td></tr>
825
+ </tbody>
826
+ </table>
827
+
828
+ ## 调用示例
829
+
830
+ ```typescript
831
+ import { getSetting } from '@doubao-dev/framework/api';
832
+
833
+ const result = await getSetting();
834
+ console.log(result.authSetting['scope.userLocation']);
835
+ ```
836
+
837
+ ## 成功返回
838
+
839
+ <table>
840
+ <thead>
841
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
842
+ </thead>
843
+ <tbody>
844
+ <tr><td><code>authSetting</code></td><td><code>AuthSetting</code></td><td>是</td><td>用户授权结果,key 为权限 scope,value 表示是否已授权</td></tr>
845
+ <tr><td><code>subscriptionsSetting</code></td><td><code>SubscriptionsSetting</code></td><td>否</td><td>预留的订阅消息设置字段。豆包当前仅支持 `withSubscriptions: false`,因此不会返回该字段。</td></tr>
846
+ <tr><td><code>subscriptionsSetting.itemSettings</code></td><td><code>Record&lt;string, SubscriptionSettingStatus&gt;</code></td><td>否</td><td>一次性订阅消息模板的订阅状态</td></tr>
847
+ <tr><td><code>subscriptionsSetting.mainSwitch</code></td><td><code>boolean</code></td><td>否</td><td>设置页订阅消息总开关</td></tr>
848
+ <tr><td><code>subscriptionsSetting.templateSettings</code></td><td><code>Record&lt;string, SubscriptionTemplateSetting&gt;</code></td><td>否</td><td>模板订阅状态</td></tr>
849
+ </tbody>
850
+ </table>
851
+
852
+ ### 返回示例
853
+
854
+ ```json
855
+ {
856
+ "authSetting": {
857
+ "scope.userLocation": true,
858
+ "scope.record": false
859
+ }
860
+ }
861
+ ```
862
+
863
+ ## 错误处理
864
+
865
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
866
+
867
+ ### 失败示例
868
+
869
+ ```json
870
+ {
871
+ "errNo": 103,
872
+ "errMsg": "feature not support"
873
+ }
874
+ ```
875
+
876
+ ### 错误码
877
+
878
+ <table>
879
+ <thead>
880
+ <tr><th>errNo</th><th>errMsg</th><th>平台</th><th>触发条件</th><th>处理建议</th></tr>
881
+ </thead>
882
+ <tbody>
883
+ <tr><td><code>103</code></td><td><code>feature not support</code></td><td>Android、iOS</td><td>传入 withSubscriptions: true,豆包当前不支持订阅消息模板</td><td>不要传入 withSubscriptions: true,仅使用默认的 false</td></tr>
884
+ <tr><td><code>116</code></td><td><code>resource not found</code></td><td>Android</td><td>豆包未找到当前应用插件</td><td>确认当前应用插件已正确安装后重试</td></tr>
885
+ </tbody>
886
+ </table>
887
+
888
+ #### 通用错误码
889
+
890
+ <table>
891
+ <thead>
892
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
893
+ </thead>
894
+ <tbody>
895
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
896
+ </tbody>
897
+ </table>
898
+
899
+ ## 平台差异
900
+
901
+ - **iOS**:iOS 不返回 errNo 116(resource not found),相应失败场景统一以 errNo 102(internal error)返回。
902
+
903
+ <a id="opensetting"></a>
904
+ ### openSetting()
905
+
906
+ # openSetting
907
+
908
+ 打开应用插件授权设置页面
909
+
910
+ ## 扫码预览
911
+ ![扫码预览 openSetting](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fbasic%252Fopen-setting%252Findex)
912
+
913
+ ## 支持版本
914
+
915
+ 前端库版本不低于 `0.0.39`。
916
+
917
+ ## 支持平台
918
+
919
+ <table>
920
+ <thead>
921
+ <tr><th>平台</th><th>支持情况</th></tr>
922
+ </thead>
923
+ <tbody>
924
+ <tr><td>Android</td><td>支持</td></tr>
925
+ <tr><td>iOS</td><td>支持</td></tr>
926
+ <tr><td>PC</td><td>不支持</td></tr>
927
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
928
+ </tbody>
929
+ </table>
930
+
931
+ ## 支持场景
932
+
933
+ <table>
934
+ <thead>
935
+ <tr><th>场景</th><th>支持情况</th></tr>
936
+ </thead>
937
+ <tbody>
938
+ <tr><td>页面</td><td>支持</td></tr>
939
+ <tr><td>卡片</td><td>支持</td></tr>
940
+ </tbody>
941
+ </table>
942
+
943
+ ## 接入准备
944
+
945
+ ### 前置条件
946
+
947
+ - 无额外前置条件,不要求在用户点击事件中调用
948
+
949
+ ## 使用说明
950
+
951
+ 该接口不要求在用户点击事件中调用。
952
+ JavaScript 调用方也不要传入 `withSubscriptions: true`,否则豆包会返回 `subscription templates are not supported yet`。
953
+
954
+ - 设置页只能修改当前应用插件的 scope,不承载 HealthKit 系统权限设置。
955
+ - 豆包当前不支持订阅模板,不要传入 withSubscriptions: true。
956
+
957
+ ## 调用方式
958
+
959
+ ### 异步 API
960
+
961
+ ```typescript
962
+ openSetting(params?: OpenSettingOptions): Promise<OpenSettingResult>
963
+ ```
964
+
965
+ ## 入参
966
+
967
+ <table>
968
+ <thead>
969
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
970
+ </thead>
971
+ <tbody>
972
+ <tr><td><code>withSubscriptions</code></td><td><code>false</code></td><td>否</td><td><code>false</code></td><td>豆包 Android、iOS 当前不支持订阅模板,仅支持 false</td><td>是否同时获取用户订阅消息的订阅状态;当前仅支持 false。</td></tr>
973
+ </tbody>
974
+ </table>
975
+
976
+ ## 调用示例
977
+
978
+ ```typescript
979
+ import { openSetting } from '@doubao-dev/framework/api';
980
+
981
+ try {
982
+ const result = await openSetting();
983
+ console.log(result.authSetting['scope.userLocation']);
984
+ } catch (error) {
985
+ console.error(error);
986
+ }
987
+ ```
988
+
989
+ ## 成功返回
990
+
991
+ <table>
992
+ <thead>
993
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
994
+ </thead>
995
+ <tbody>
996
+ <tr><td><code>authSetting</code></td><td><code>AuthSetting</code></td><td>是</td><td>用户授权结果,key 为权限 scope,value 表示是否已授权</td></tr>
997
+ <tr><td><code>subscriptionsSetting</code></td><td><code>SubscriptionsSetting</code></td><td>否</td><td>预留的订阅消息设置字段。豆包当前仅支持 `withSubscriptions: false`,因此不会返回该字段。</td></tr>
998
+ <tr><td><code>subscriptionsSetting.itemSettings</code></td><td><code>Record&lt;string, SubscriptionSettingStatus&gt;</code></td><td>否</td><td>一次性订阅消息模板的订阅状态</td></tr>
999
+ <tr><td><code>subscriptionsSetting.mainSwitch</code></td><td><code>boolean</code></td><td>否</td><td>设置页订阅消息总开关</td></tr>
1000
+ <tr><td><code>subscriptionsSetting.templateSettings</code></td><td><code>Record&lt;string, SubscriptionTemplateSetting&gt;</code></td><td>否</td><td>模板订阅状态</td></tr>
1001
+ </tbody>
1002
+ </table>
1003
+
1004
+ ### 返回示例
1005
+
1006
+ ```json
1007
+ {
1008
+ "authSetting": {
1009
+ "scope.userLocation": true,
1010
+ "scope.record": false
1011
+ }
1012
+ }
1013
+ ```
1014
+
1015
+ <a id="getuseridentifiers"></a>
1016
+ ### getUserIdentifiers()
1017
+
1018
+ ---
1019
+ internal: true
1020
+ ---
1021
+
1022
+ # getUserIdentifiers
1023
+
1024
+ 获取当前用户的加密设备标识,参数可省略或传入空对象。
1025
+
1026
+ ## 扫码预览
1027
+ ![扫码预览 getUserIdentifiers](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fbasic%252Fget-user-identifiers%252Findex)
1028
+
1029
+ ## 支持版本
1030
+
1031
+ 前端库版本不低于 `0.5.0`。
1032
+
1033
+ ## 支持平台
1034
+
1035
+ <table>
1036
+ <thead>
1037
+ <tr><th>平台</th><th>支持情况</th></tr>
1038
+ </thead>
1039
+ <tbody>
1040
+ <tr><td>Android</td><td>支持</td></tr>
1041
+ <tr><td>iOS</td><td>支持</td></tr>
1042
+ <tr><td>PC</td><td>不支持</td></tr>
1043
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
1044
+ </tbody>
1045
+ </table>
1046
+
1047
+ ## 接入准备
1048
+
1049
+ ### 前置条件
1050
+
1051
+ - 用户已登录且标识服务可用
1052
+
1053
+ ## 使用说明
1054
+
1055
+ - 同一用户、设备和应用插件的成功结果在进程内缓存。
1056
+
1057
+ ## 调用方式
1058
+
1059
+ ### 异步 API
1060
+
1061
+ ```typescript
1062
+ getUserIdentifiers(params?: object): Promise<GetUserIdentifiersResult>
1063
+ ```
1064
+
1065
+ ## 入参
1066
+
1067
+ 无。
1068
+
1069
+ ## 调用示例
1070
+
1071
+ ```typescript
1072
+ import { getUserIdentifiers } from '@doubao-dev/framework/api';
1073
+ const { edid } = await getUserIdentifiers({});
1074
+ ```
1075
+
1076
+ ## 成功返回
1077
+
1078
+ :::public
1079
+ <table>
1080
+ <thead>
1081
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
1082
+ </thead>
1083
+ <tbody>
1084
+ </tbody>
1085
+ </table>
1086
+ :::
1087
+
1088
+ :::internal
1089
+ <table>
1090
+ <thead>
1091
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
1092
+ </thead>
1093
+ <tbody>
1094
+ <tr><td><code>edid</code></td><td><code>string</code></td><td>是</td><td>用户加密设备标识,成功时非空。</td></tr>
1095
+ </tbody>
1096
+ </table>
1097
+ :::
1098
+
1099
+ ### 返回示例
1100
+
1101
+ ```json
1102
+ { "edid": "example-encrypted-identifier" }
1103
+ ```
1104
+
1105
+ ## 错误处理
1106
+
1107
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
1108
+
1109
+ ### 失败示例
1110
+
1111
+ ```json
1112
+ { "errNo": 303, "errMsg": "no network connection" }
1113
+ ```
1114
+
1115
+ ### 错误码
1116
+
1117
+ <table>
1118
+ <thead>
1119
+ <tr><th>errNo</th><th>errMsg</th><th>平台</th><th>触发条件</th><th>处理建议</th></tr>
1120
+ </thead>
1121
+ <tbody>
1122
+ <tr><td><code>302</code></td><td><code>connection timed out</code></td><td>Android、iOS</td><td>请求超时</td><td>稍后重试</td></tr>
1123
+ <tr><td><code>303</code></td><td><code>no network connection</code></td><td>Android、iOS</td><td>无网络连接</td><td>联网后重试</td></tr>
1124
+ <tr><td><code>305</code></td><td><code>network failure</code></td><td>Android、iOS</td><td>请求失败</td><td>检查网络和服务后重试</td></tr>
1125
+ </tbody>
1126
+ </table>
1127
+
1128
+ #### 通用错误码
1129
+
1130
+ <table>
1131
+ <thead>
1132
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
1133
+ </thead>
1134
+ <tbody>
1135
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
1136
+ <tr><td><code>103</code></td><td><code>feature not support</code></td><td>当前环境不支持该能力</td><td>Android、iOS</td></tr>
1137
+ <tr><td><code>104</code></td><td><code>invalid parameter</code></td><td>参数不合法</td><td>Android、iOS</td></tr>
1138
+ <tr><td><code>105</code></td><td><code>authentication fail</code></td><td>身份认证失败</td><td>Android、iOS</td></tr>
1139
+ <tr><td><code>112</code></td><td><code>invalid result</code></td><td>返回结果无效</td><td>Android、iOS</td></tr>
1140
+ </tbody>
1141
+ </table>
1142
+
1143
+ ## 相关类型
1144
+
1145
+ <a id="doubaoappaccountinfo"></a>
1146
+ ### DoubaoAppAccountInfo
1147
+
1148
+ 应用插件账号信息。
1149
+
1150
+ #### Properties
1151
+
1152
+ • **appId**: `string` - 应用插件 appId
1153
+ • **envVersion**: `'develop' | 'trial' | 'release'` - 当前应用插件的版本类型。 - develop:开发版 - trial:体验版 - release:正式版
1154
+ • **version**: `string` - 应用插件版本号
1155
+
1156
+ <a id="pluginaccountinfo"></a>
1157
+ ### PluginAccountInfo
1158
+
1159
+ 插件账号信息(仅在插件中调用时包含)。
1160
+
1161
+ #### Properties
1162
+
1163
+ • **appId**: `string` - 插件 appId
1164
+ • **version**: `string` - 插件版本号,'a.b.c' 形式
1165
+
1166
+ <a id="getaccountinforesult"></a>
1167
+ ### GetAccountInfoResult
1168
+
1169
+ 获取当前账号信息。
1170
+
1171
+ #### Properties
1172
+
1173
+ • **miniProgram**: `DoubaoAppAccountInfo` - 应用插件账号信息
1174
+ • **plugin?**: `PluginAccountInfo` - 插件账号信息(仅在插件中调用时包含)
1175
+
1176
+ <a id="healthdatatype"></a>
1177
+ ### HealthDataType
1178
+
1179
+ #### Type
1180
+
1181
+ `BridgeHealthDataType`
1182
+
1183
+ <a id="scope"></a>
1184
+ ### Scope
1185
+
1186
+ #### Type
1187
+
1188
+ `| 'scope.userLocation'
1189
+ | 'scope.userFuzzyLocation'
1190
+ | 'scope.userLocationBackground'
1191
+ | 'scope.payment'
1192
+ | 'scope.record'
1193
+ | 'scope.bluetooth'
1194
+ | 'scope.camera'
1195
+ | 'scope.addPhoneContact'
1196
+ | 'scope.addPhoneCalendar'
1197
+ | 'scope.healthData'`
1198
+
1199
+ <a id="healthdataauthorizeoptions"></a>
1200
+ ### HealthDataAuthorizeOptions
1201
+
1202
+ #### Properties
1203
+
1204
+ • **types**: `HealthDataType[]` - 健康数据类型列表;用于申请对应的 HealthKit 读取权限
1205
+
1206
+ <a id="authorizerequest"></a>
1207
+ ### AuthorizeRequest
1208
+
1209
+ #### Properties
1210
+
1211
+ • **scope**: `Scope` - 授权范围
1212
+ • **options?**: `HealthDataAuthorizeOptions` - 权限扩展参数;仅 scope.healthData 生效,用于传入 HealthKit 读取类型,其他 scope 会忽略该字段
1213
+
1214
+ <a id="caniuseparams"></a>
1215
+ ### CanIUseParams
1216
+
1217
+ #### Properties
1218
+
1219
+ • **schema**: `string` - 需要检测的能力标识,例如 API 名称
1220
+
1221
+ <a id="caniuseresult"></a>
1222
+ ### CanIUseResult
1223
+
1224
+ #### Properties
1225
+
1226
+ • **result**: `boolean` - 是否支持所检测的能力
1227
+
1228
+ <a id="performanceentry"></a>
1229
+ ### PerformanceEntry
1230
+
1231
+ #### Properties
1232
+
1233
+ • **entryType**: `PerformanceEntryType` - 性能指标所属类别
1234
+ • **name**: `string` - 性能指标名称,例如 appLaunch、route、evaluateScript 或 firstRender
1235
+ • **startTime**: `number` - 指标开始或发生时刻的 Unix 时间戳,单位为毫秒
1236
+ • **duration?**: `number` - 指标持续时间,单位为毫秒;仅耗时类指标提供
1237
+ • **path?**: `string` - 页面路径;仅页面的 navigation 和 render 类型指标提供
1238
+ • **pageId?**: `number` - path 对应的页面实例 Id(随机生成,不保证递增);仅页面相关指标提供
1239
+ • **referrerPath?**: `string` - 路由来源页面的路径;仅 navigation / route 指标提供
1240
+ • **referrerPageId?**: `number` - 路由来源页面的实例 ID;仅 navigation / route 指标提供
1241
+ • **navigationStart?**: `number` - 路由开始被渲染层处理的 Unix 时间戳,单位为毫秒;仅 navigation 类型指标提供
1242
+ • **navigationType?**: `string` - 路由类型。仅 navigation 类型的 Entry 有效
1243
+ • **moduleName?**: `string` - 被执行脚本的模块名称;仅 script / evaluateScript 指标提供
1244
+ • **viewLayerReadyTime?**: `number` - 视图层准备完成的 Unix 时间戳,单位为毫秒;仅 render / firstRender 指标提供
1245
+ • **viewLayerRenderStartTime?**: `number` - 视图层首次渲染开始的 Unix 时间戳,单位为毫秒;仅 render / firstRender 指标提供
1246
+ • **viewLayerRenderEndTime?**: `number` - 视图层首次渲染结束的 Unix 时间戳,单位为毫秒;仅 render / firstRender 指标提供
1247
+ • **widgetId?**: `string` - Widget 标识;仅 Widget 的 render 类型指标提供
1248
+ • **widgetInstanceId?**: `string` - Widget 实例 Id(随机生成,不保证递增);仅 Widget 的 render 类型指标提供
1249
+ • **isAppColdLaunch?**: `boolean` - Widget 关联的应用是否冷启动;仅 Widget 的 render 类型指标提供
1250
+
1251
+ <a id="performanceobservercallback"></a>
1252
+ ### PerformanceObserverCallback
1253
+
1254
+ #### Type
1255
+
1256
+ `(entryList: PerformanceObserverEntryList) => void`
1257
+
1258
+ <a id="performanceobserver"></a>
1259
+ ### PerformanceObserver
1260
+
1261
+ #### Properties
1262
+
1263
+ • **observe**: `(options: PerformanceObserverOptions) => void`
1264
+ • **disconnect**: `() => void`
1265
+
1266
+ <a id="performance"></a>
1267
+ ### Performance
1268
+
1269
+ #### Properties
1270
+
1271
+ • **createObserver**: `(callback: PerformanceObserverCallback) => PerformanceObserver` - 创建性能观察者。调用返回对象的 observe 后,回调会接收之后新完成且匹配的 Entry
1272
+ • **setBufferSize**: `(size: number) => void` - 设置客户端最多保留的性能 Entry 数量
1273
+ • **getEntries**: `() => PerformanceEntry[]` - 返回当前应用插件已记录的全部性能 Entry
1274
+ • **getEntriesByType**: `(entryType: string) => PerformanceEntry[]` - 返回指定 entryType 的性能 Entry
1275
+ • **getEntriesByName**: `(name: string, entryType?: string) => PerformanceEntry[]` - 返回指定名称的性能 Entry;传入 entryType 时同时按类型筛选
1276
+
1277
+ <a id="performanceentrytype"></a>
1278
+ ### PerformanceEntryType
1279
+
1280
+ #### Type
1281
+
1282
+ `'navigation' | 'script' | 'render'`
1283
+
1284
+ <a id="performanceobserverentrylist"></a>
1285
+ ### PerformanceObserverEntryList
1286
+
1287
+ #### Properties
1288
+
1289
+ • **getEntries**: `() => PerformanceEntry[]`
1290
+ • **getEntriesByType**: `(entryType: string) => PerformanceEntry[]`
1291
+ • **getEntriesByName**: `(name: string, entryType?: string) => PerformanceEntry[]`
1292
+
1293
+ <a id="performanceobserveroptions"></a>
1294
+ ### PerformanceObserverOptions
1295
+
1296
+ #### Properties
1297
+
1298
+ • **entryTypes**: `string[]`
1299
+
1300
+ <a id="getsettingparams"></a>
1301
+ ### GetSettingParams
1302
+
1303
+ #### Properties
1304
+
1305
+ • **withSubscriptions?**: `false` - 是否同时获取用户订阅消息的订阅状态;当前仅支持 false
1306
+
1307
+ <a id="authsetting"></a>
1308
+ ### AuthSetting
1309
+
1310
+ #### Type
1311
+
1312
+ `Record<string, boolean>`
1313
+
1314
+ <a id="subscriptionsettingstatus"></a>
1315
+ ### SubscriptionSettingStatus
1316
+
1317
+ #### Type
1318
+
1319
+ `'accept' | 'reject' | 'ban' | 'filter'`
1320
+
1321
+ <a id="subscriptiontemplatesetting"></a>
1322
+ ### SubscriptionTemplateSetting
1323
+
1324
+ #### Properties
1325
+
1326
+ • **status**: `SubscriptionSettingStatus` - 订阅结果
1327
+ • **alwaysSubscribe?**: `boolean` - 是否为长期订阅状态
1328
+ • **allowReminderWay?**: `SubscriptionReminderWay[]` - 模板支持的提醒方式对应的用户授权结果
1329
+
1330
+ <a id="subscriptionssetting"></a>
1331
+ ### SubscriptionsSetting
1332
+
1333
+ #### Properties
1334
+
1335
+ • **mainSwitch**: `boolean` - 设置页订阅消息总开关
1336
+ • **itemSettings?**: `Record<string, SubscriptionSettingStatus>` - 一次性订阅消息模板的订阅状态
1337
+ • **templateSettings?**: `Record<string, SubscriptionTemplateSetting>` - 模板订阅状态
1338
+
1339
+ <a id="getsettingresult"></a>
1340
+ ### GetSettingResult
1341
+
1342
+ #### Properties
1343
+
1344
+ • **authSetting**: `AuthSetting` - 用户授权结果,key 为权限 scope,value 表示是否已授权
1345
+ • **subscriptionsSetting?**: `SubscriptionsSetting` - 预留的订阅消息设置字段。豆包当前仅支持 withSubscriptions: false,因此不会返回该字段
1346
+
1347
+ <a id="subscriptionreminderway"></a>
1348
+ ### SubscriptionReminderWay
1349
+
1350
+ #### Properties
1351
+
1352
+ • **reminderType**: `SubscriptionReminderType` - 提醒方式
1353
+ • **reminderStatus**: `SubscriptionReminderStatus` - 提醒授权结果
1354
+
1355
+ <a id="subscriptionremindertype"></a>
1356
+ ### SubscriptionReminderType
1357
+
1358
+ #### Type
1359
+
1360
+ `'message_notice' | 'feed' | 'push'`
1361
+
1362
+ <a id="subscriptionreminderstatus"></a>
1363
+ ### SubscriptionReminderStatus
1364
+
1365
+ #### Type
1366
+
1367
+ `'accept' | 'reject'`
1368
+
1369
+ <a id="opensettingoptions"></a>
1370
+ ### OpenSettingOptions
1371
+
1372
+ #### Properties
1373
+
1374
+ • **withSubscriptions?**: `false` - 是否同时获取用户订阅消息的订阅状态;当前仅支持 false
1375
+
1376
+ <a id="opensettingresult"></a>
1377
+ ### OpenSettingResult
1378
+
1379
+ #### Properties
1380
+
1381
+ • **authSetting**: `AuthSetting` - 用户授权结果,key 为权限 scope,value 表示是否已授权
1382
+ • **subscriptionsSetting?**: `SubscriptionsSetting` - 预留的订阅消息设置字段。豆包当前仅支持 withSubscriptions: false,因此不会返回该字段
1383
+
1384
+ <a id="getuseridentifiersresult"></a>
1385
+ ### GetUserIdentifiersResult
1386
+
1387
+ #### Properties
1388
+
1389
+ • **edid**: `string` - 用户加密设备标识,成功时非空