@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,354 @@
1
+ # 豆包应用插件的端能力 API: 陀螺仪
2
+
3
+ 陀螺仪监听能力。
4
+
5
+ [返回目录](./groups.md) | [返回速查](./quick-reference.md)
6
+
7
+ ## 速查
8
+
9
+ | API | 说明 |
10
+ | --- | --- |
11
+ | [startGyroscope](#startgyroscope) | 开始监听陀螺仪。 |
12
+ | [stopGyroscope](#stopgyroscope) | 停止监听陀螺仪。 |
13
+ | [onGyroscopeChange](#ongyroscopechange) | 监听陀螺仪数据变化事件。<br><br>返回取消监听函数。 |
14
+
15
+ ## API 详情
16
+
17
+ <a id="startgyroscope"></a>
18
+ ### startGyroscope()
19
+
20
+ # startGyroscope
21
+
22
+ 开始监听陀螺仪。
23
+
24
+ ## 扫码预览
25
+ ![扫码预览 startGyroscope](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fgyroscope%252Findex)
26
+
27
+ ## 支持版本
28
+
29
+ 前端库版本不低于 `0.0.25`。
30
+
31
+ ## 支持平台
32
+
33
+ <table>
34
+ <thead>
35
+ <tr><th>平台</th><th>支持情况</th></tr>
36
+ </thead>
37
+ <tbody>
38
+ <tr><td>Android</td><td>支持</td></tr>
39
+ <tr><td>iOS</td><td>支持</td></tr>
40
+ <tr><td>PC</td><td>不支持</td></tr>
41
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
42
+ </tbody>
43
+ </table>
44
+
45
+ ## 支持场景
46
+
47
+ <table>
48
+ <thead>
49
+ <tr><th>场景</th><th>支持情况</th></tr>
50
+ </thead>
51
+ <tbody>
52
+ <tr><td>页面</td><td>支持</td></tr>
53
+ <tr><td>卡片</td><td>不支持</td></tr>
54
+ </tbody>
55
+ </table>
56
+
57
+ ## 接入准备
58
+
59
+ ### 前置条件
60
+
61
+ - 无额外前置条件;建议在启动前注册 `onGyroscopeChange`
62
+
63
+ ## 使用说明
64
+
65
+ 需配对调用 stopGyroscope。
66
+
67
+ - 不再需要时及时调用 `stopGyroscope`,避免持续采集造成额外功耗
68
+
69
+ ## 调用方式
70
+
71
+ ### 异步 API
72
+
73
+ ```typescript
74
+ startGyroscope(params?: StartGyroscopeParams): Promise<object>
75
+ ```
76
+
77
+ ## 入参
78
+
79
+ <table>
80
+ <thead>
81
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
82
+ </thead>
83
+ <tbody>
84
+ <tr><td><code>interval</code></td><td><code>SensorInterval</code></td><td>否</td><td><code>normal</code></td><td>game 表示约 20 次/秒,ui 表示约 60 次/秒,normal 表示约 5 次/秒</td><td>监听频率。</td></tr>
85
+ </tbody>
86
+ </table>
87
+
88
+ ## 调用示例
89
+
90
+ ```typescript
91
+ import { startGyroscope } from '@doubao-dev/framework/api';
92
+
93
+ await startGyroscope({ interval: 'normal' });
94
+ ```
95
+
96
+ ## 成功返回
97
+
98
+ 无返回字段。
99
+
100
+ ### 返回示例
101
+
102
+ ```json
103
+ {}
104
+ ```
105
+
106
+ ## 错误处理
107
+
108
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
109
+
110
+ ### 失败示例
111
+
112
+ ```json
113
+ {
114
+ "errNo": 103,
115
+ "errMsg": "feature not support"
116
+ }
117
+ ```
118
+
119
+ ### 错误码
120
+
121
+ <table>
122
+ <thead>
123
+ <tr><th>errNo</th><th>errMsg</th><th>平台</th><th>触发条件</th><th>处理建议</th></tr>
124
+ </thead>
125
+ <tbody>
126
+ <tr><td><code>103</code></td><td><code>feature not support</code></td><td>Android、iOS</td><td>当前设备不支持陀螺仪传感器或无法注册监听</td><td>在具备陀螺仪传感器的设备上调用,或提前提示用户设备不支持。</td></tr>
127
+ </tbody>
128
+ </table>
129
+
130
+ #### 通用错误码
131
+
132
+ <table>
133
+ <thead>
134
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
135
+ </thead>
136
+ <tbody>
137
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
138
+ </tbody>
139
+ </table>
140
+
141
+ <a id="stopgyroscope"></a>
142
+ ### stopGyroscope()
143
+
144
+ # stopGyroscope
145
+
146
+ 停止监听陀螺仪。
147
+
148
+ ## 扫码预览
149
+ ![扫码预览 stopGyroscope](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fgyroscope%252Findex)
150
+
151
+ ## 支持版本
152
+
153
+ 前端库版本不低于 `0.0.25`。
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
+ ### 前置条件
184
+
185
+ - 无额外前置条件;通常在 `startGyroscope` 后调用
186
+
187
+ ## 使用说明
188
+
189
+ - 未启动时调用也会直接成功,可用于安全清理监听状态
190
+
191
+ ## 调用方式
192
+
193
+ ### 异步 API
194
+
195
+ ```typescript
196
+ stopGyroscope(params?: object): Promise<object>
197
+ ```
198
+
199
+ ## 入参
200
+
201
+ 无。
202
+
203
+ ## 调用示例
204
+
205
+ ```typescript
206
+ import { stopGyroscope } from '@doubao-dev/framework/api';
207
+
208
+ await stopGyroscope();
209
+ ```
210
+
211
+ ## 成功返回
212
+
213
+ 无返回字段。
214
+
215
+ ### 返回示例
216
+
217
+ ```json
218
+ {}
219
+ ```
220
+
221
+ <a id="ongyroscopechange"></a>
222
+ ### onGyroscopeChange()
223
+
224
+ # onGyroscopeChange
225
+
226
+ 监听陀螺仪数据变化事件。
227
+
228
+ ## 扫码预览
229
+ ![扫码预览 onGyroscopeChange](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fgyroscope%252Findex)
230
+
231
+ ## 支持版本
232
+
233
+ 前端库版本不低于 `0.0.27`。
234
+
235
+ ## 支持平台
236
+
237
+ <table>
238
+ <thead>
239
+ <tr><th>平台</th><th>支持情况</th></tr>
240
+ </thead>
241
+ <tbody>
242
+ <tr><td>Android</td><td>支持</td></tr>
243
+ <tr><td>iOS</td><td>支持</td></tr>
244
+ <tr><td>PC</td><td>不支持</td></tr>
245
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
246
+ </tbody>
247
+ </table>
248
+
249
+ ## 支持场景
250
+
251
+ <table>
252
+ <thead>
253
+ <tr><th>场景</th><th>支持情况</th></tr>
254
+ </thead>
255
+ <tbody>
256
+ <tr><td>页面</td><td>支持</td></tr>
257
+ <tr><td>卡片</td><td>不支持</td></tr>
258
+ </tbody>
259
+ </table>
260
+
261
+ ## 接入准备
262
+
263
+ ### 前置条件
264
+
265
+ - 调用 `startGyroscope` 后事件才会持续回调
266
+
267
+ ## 使用说明
268
+
269
+ - 取消函数只移除本地回调,需要停止采集时调用 `stopGyroscope`
270
+
271
+ ## 调用方式
272
+
273
+ ### 事件监听 API
274
+
275
+ ```typescript
276
+ onGyroscopeChange(callback: (event: GyroscopeChangeEvent) => void): () => void
277
+ ```
278
+
279
+ ## 入参
280
+
281
+ 无。
282
+
283
+ ## 调用示例
284
+
285
+ ```ts
286
+ import { onGyroscopeChange } from '@doubao-dev/framework/api';
287
+
288
+ const off = onGyroscopeChange(({ x, y, z, timestamp }) => {
289
+ console.log(x, y, z, timestamp);
290
+ });
291
+
292
+ off();
293
+ ```
294
+
295
+ ## 回调参数
296
+
297
+ <table>
298
+ <thead>
299
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
300
+ </thead>
301
+ <tbody>
302
+ <tr><td><code>event.timestamp</code></td><td><code>number</code></td><td>是</td><td>数据采集时间戳,单位纳秒。</td></tr>
303
+ <tr><td><code>event.x</code></td><td><code>number</code></td><td>是</td><td>绕 X 轴旋转的角速度,单位 rad/s。</td></tr>
304
+ <tr><td><code>event.y</code></td><td><code>number</code></td><td>是</td><td>绕 Y 轴旋转的角速度,单位 rad/s。</td></tr>
305
+ <tr><td><code>event.z</code></td><td><code>number</code></td><td>是</td><td>绕 Z 轴旋转的角速度,单位 rad/s。</td></tr>
306
+ </tbody>
307
+ </table>
308
+
309
+ ## 返回值
310
+
311
+ 返回取消当前监听函数的函数。
312
+
313
+ ### 回调示例
314
+
315
+ ```json
316
+ {
317
+ "x": 0.01,
318
+ "y": -0.02,
319
+ "z": 0.03,
320
+ "timestamp": 1784088000000000000
321
+ }
322
+ ```
323
+
324
+ ## 相关类型
325
+
326
+ <a id="startgyroscopeparams"></a>
327
+ ### StartGyroscopeParams
328
+
329
+ 开始监听陀螺仪的请求参数。
330
+
331
+ #### Properties
332
+
333
+ • **interval?**: `SensorInterval` - 监听频率
334
+
335
+ <a id="sensorinterval"></a>
336
+ ### SensorInterval
337
+
338
+ 传感器监听频率。
339
+
340
+ #### Type
341
+
342
+ `'game' | 'ui' | 'normal'`
343
+
344
+ <a id="gyroscopechangeevent"></a>
345
+ ### GyroscopeChangeEvent
346
+
347
+ 陀螺仪数据变化事件。
348
+
349
+ #### Properties
350
+
351
+ • **x**: `number` - 绕 X 轴旋转的角速度,单位 rad/s
352
+ • **y**: `number` - 绕 Y 轴旋转的角速度,单位 rad/s
353
+ • **z**: `number` - 绕 Z 轴旋转的角速度,单位 rad/s
354
+ • **timestamp**: `number` - 数据采集时间戳,单位纳秒
@@ -0,0 +1,264 @@
1
+ # 豆包应用插件的端能力 API: 媒体 / 设备 / 网络
2
+
3
+ 网络类型和本机局域网 IP。
4
+
5
+ [返回目录](./groups.md) | [返回速查](./quick-reference.md)
6
+
7
+ ## 速查
8
+
9
+ | API | 说明 |
10
+ | --- | --- |
11
+ | [getNetworkType](#getnetworktype) | 获取当前网络类型。 |
12
+ | [onNetworkStatusChange](#onnetworkstatuschange) | 监听网络状态变化事件。<br><br>返回取消监听函数。 |
13
+
14
+ ## API 详情
15
+
16
+ <a id="getnetworktype"></a>
17
+ ### getNetworkType()
18
+
19
+ # getNetworkType
20
+
21
+ 获取当前网络类型。
22
+
23
+ ## 扫码预览
24
+ ![扫码预览 getNetworkType](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fget-network-type%252Findex)
25
+
26
+ ## 使用限制
27
+
28
+ > [!WARNING]
29
+ > **Android、iOS**:iOS 在蜂窝网络下可能返回联合类型外的 &quot;mobile&quot;;依赖联合类型穷举分支的调用方会遗漏该取值。
30
+
31
+ ## 支持版本
32
+
33
+ 前端库版本不低于 `0.0.25`。
34
+
35
+ ## 支持平台
36
+
37
+ <table>
38
+ <thead>
39
+ <tr><th>平台</th><th>支持情况</th></tr>
40
+ </thead>
41
+ <tbody>
42
+ <tr><td>Android</td><td>支持</td></tr>
43
+ <tr><td>iOS</td><td>支持</td></tr>
44
+ <tr><td>PC</td><td>不支持</td></tr>
45
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
46
+ </tbody>
47
+ </table>
48
+
49
+ ## 支持场景
50
+
51
+ <table>
52
+ <thead>
53
+ <tr><th>场景</th><th>支持情况</th></tr>
54
+ </thead>
55
+ <tbody>
56
+ <tr><td>页面</td><td>支持</td></tr>
57
+ <tr><td>卡片</td><td>不支持</td></tr>
58
+ </tbody>
59
+ </table>
60
+
61
+ ## 使用说明
62
+
63
+ - 需要持续跟踪网络切换时改用 `onNetworkStatusChange`
64
+
65
+ ## 调用方式
66
+
67
+ ### 异步 API
68
+
69
+ ```typescript
70
+ getNetworkType(params?: GetNetworkTypeParams): Promise<GetNetworkTypeResult>
71
+ ```
72
+
73
+ ## 入参
74
+
75
+ 无。
76
+
77
+ ## 调用示例
78
+
79
+ ```ts
80
+ import { getNetworkType } from '@doubao-dev/framework/api';
81
+
82
+ const result = await getNetworkType();
83
+ console.log(result.networkType);
84
+ ```
85
+
86
+ ## 成功返回
87
+
88
+ <table>
89
+ <thead>
90
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>约束</th><th>说明</th></tr>
91
+ </thead>
92
+ <tbody>
93
+ <tr><td><code>hasSystemProxy</code></td><td><code>boolean</code></td><td>否</td><td>-</td><td>设备是否使用了系统代理。</td></tr>
94
+ <tr><td><code>networkType</code></td><td><code>NetworkType</code></td><td>是</td><td>-</td><td>当前网络类型。Android、iOS:iOS 在蜂窝网络下可能返回联合类型外的 &quot;mobile&quot;。</td></tr>
95
+ <tr><td><code>signalStrength</code></td><td><code>number</code></td><td>否</td><td>仅 Android Wi-Fi 环境下返回</td><td>信号强弱,单位 dBm。</td></tr>
96
+ <tr><td><code>weakNet</code></td><td><code>boolean</code></td><td>否</td><td>仅 Android 返回</td><td>是否处于弱网环境。</td></tr>
97
+ </tbody>
98
+ </table>
99
+
100
+ ### 返回示例
101
+
102
+ ```json
103
+ {
104
+ "networkType": "wifi",
105
+ "hasSystemProxy": false
106
+ }
107
+ ```
108
+
109
+ ## 错误处理
110
+
111
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
112
+
113
+ ### 错误码
114
+
115
+ #### 通用错误码
116
+
117
+ <table>
118
+ <thead>
119
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
120
+ </thead>
121
+ <tbody>
122
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android</td></tr>
123
+ </tbody>
124
+ </table>
125
+
126
+ ## 平台差异
127
+
128
+ - **Android**:正常场景稳定返回网络类型;失败时返回 102。
129
+ - **iOS**:始终成功返回网络类型,无失败分支。
130
+
131
+ <a id="onnetworkstatuschange"></a>
132
+ ### onNetworkStatusChange()
133
+
134
+ # onNetworkStatusChange
135
+
136
+ 监听网络状态变化事件。
137
+
138
+ ## 扫码预览
139
+ ![扫码预览 onNetworkStatusChange](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fget-network-type%252Findex)
140
+
141
+ ## 支持版本
142
+
143
+ 前端库版本不低于 `0.0.26`。
144
+
145
+ ## 支持平台
146
+
147
+ <table>
148
+ <thead>
149
+ <tr><th>平台</th><th>支持情况</th></tr>
150
+ </thead>
151
+ <tbody>
152
+ <tr><td>Android</td><td>支持</td></tr>
153
+ <tr><td>iOS</td><td>支持</td></tr>
154
+ <tr><td>PC</td><td>不支持</td></tr>
155
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
156
+ </tbody>
157
+ </table>
158
+
159
+ ## 支持场景
160
+
161
+ <table>
162
+ <thead>
163
+ <tr><th>场景</th><th>支持情况</th></tr>
164
+ </thead>
165
+ <tbody>
166
+ <tr><td>页面</td><td>支持</td></tr>
167
+ <tr><td>卡片</td><td>不支持</td></tr>
168
+ </tbody>
169
+ </table>
170
+
171
+ ## 使用说明
172
+
173
+ - 取消函数只移除本地回调,不影响系统网络状态
174
+
175
+ ## 调用方式
176
+
177
+ ### 事件监听 API
178
+
179
+ ```typescript
180
+ onNetworkStatusChange(callback: (event: NetworkStatusChangeEvent) => void): () => void
181
+ ```
182
+
183
+ ## 入参
184
+
185
+ 无。
186
+
187
+ ## 调用示例
188
+
189
+ ```ts
190
+ import { onNetworkStatusChange } from '@doubao-dev/framework/api';
191
+
192
+ const off = onNetworkStatusChange(({ isConnected, networkType }) => {
193
+ console.log(isConnected, networkType);
194
+ });
195
+
196
+ off();
197
+ ```
198
+
199
+ ## 回调参数
200
+
201
+ <table>
202
+ <thead>
203
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
204
+ </thead>
205
+ <tbody>
206
+ <tr><td><code>event.isConnected</code></td><td><code>boolean</code></td><td>是</td><td>当前是否有可用网络连接。</td></tr>
207
+ <tr><td><code>event.networkType</code></td><td><code>NetworkType</code></td><td>是</td><td>当前网络类型。</td></tr>
208
+ </tbody>
209
+ </table>
210
+
211
+ ## 返回值
212
+
213
+ 返回取消当前监听函数的函数。
214
+
215
+ ### 回调示例
216
+
217
+ ```json
218
+ {
219
+ "isConnected": true,
220
+ "networkType": "wifi"
221
+ }
222
+ ```
223
+
224
+ ## 相关类型
225
+
226
+ <a id="networktype"></a>
227
+ ### NetworkType
228
+
229
+ 网络类型。 - wifi - Wi-Fi 网络 - 2g - 2G 网络 - 3g - 3G 网络 - 4g - 4G 网络 - 5g - 5G 网络 - unknown - Android 下不常见的网络类型 - none - 无网络。
230
+
231
+ #### Type
232
+
233
+ `'wifi' | '2g' | '3g' | '4g' | '5g' | 'unknown' | 'none'`
234
+
235
+ <a id="getnetworktypeparams"></a>
236
+ ### GetNetworkTypeParams
237
+
238
+ 获取网络类型的请求参数。 当前无需传入任何字段,预留扩展位。
239
+
240
+ #### Properties
241
+
242
+ 无字段。
243
+
244
+ <a id="getnetworktyperesult"></a>
245
+ ### GetNetworkTypeResult
246
+
247
+ 获取网络类型的返回结果。
248
+
249
+ #### Properties
250
+
251
+ • **networkType**: `NetworkType` - 当前网络类型
252
+ • **signalStrength?**: `number` - 信号强弱,单位 dBm
253
+ • **hasSystemProxy?**: `boolean` - 设备是否使用了系统代理
254
+ • **weakNet?**: `boolean` - 是否处于弱网环境
255
+
256
+ <a id="networkstatuschangeevent"></a>
257
+ ### NetworkStatusChangeEvent
258
+
259
+ 网络状态变化事件。
260
+
261
+ #### Properties
262
+
263
+ • **isConnected**: `boolean` - 当前是否有可用网络连接
264
+ • **networkType**: `NetworkType` - 当前网络类型