@doubao-dev/plugin-app-dev 1.0.0-rc.7 → 1.0.0-rc.8
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.
- package/dist/plugin.js +6 -6
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/02-/347/263/273/347/273/237.md +123 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/10-/345/217/257/350/247/201/346/200/247.md +175 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/37-/347/224/273/345/270/203.md +181 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/groups.md +3 -2
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/quick-reference.md +11 -1
- package/package.json +3 -3
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
| [onThemeChange](#onthemechange) | 监听应用主题变化。 当用户在系统设置或豆包客户端内切换浅色、深色主题时触发。回调参数中的 theme 表示切换后的主题,可与 getAppBaseInfo 返回的 theme 字段配合使用。<br><br>返回取消监听函数。 |
|
|
18
18
|
| [getSystemInfo](#getsysteminfo) | 获取系统信息。 |
|
|
19
19
|
| [getSystemInfoSync](#getsysteminfosync) | 同步获取系统信息。<br><br>同步 API。 |
|
|
20
|
+
| [onWindowResize](#onwindowresize) | 监听当前窗口尺寸变化。 使用与 getWindowInfoSync 相同的数据源,仅在窗口宽度或高度变化时触发,注册时不触发回调。<br><br>返回取消监听函数。 |
|
|
20
21
|
|
|
21
22
|
## API 详情
|
|
22
23
|
|
|
@@ -1096,6 +1097,105 @@ console.log(result.screenWidth, result.screenHeight);
|
|
|
1096
1097
|
|
|
1097
1098
|
- **Android**:abi 返回豆包客户端二进制接口类型(如 arm64-v8a),iOS 不返回该字段
|
|
1098
1099
|
|
|
1100
|
+
<a id="onwindowresize"></a>
|
|
1101
|
+
### onWindowResize()
|
|
1102
|
+
|
|
1103
|
+
---
|
|
1104
|
+
internal: true
|
|
1105
|
+
---
|
|
1106
|
+
|
|
1107
|
+
# onWindowResize
|
|
1108
|
+
|
|
1109
|
+
监听当前窗口尺寸变化。
|
|
1110
|
+
|
|
1111
|
+
使用与 getWindowInfoSync 相同的数据源,仅在窗口宽度或高度变化时触发,注册时不触发回调。
|
|
1112
|
+
|
|
1113
|
+
## 支持版本
|
|
1114
|
+
|
|
1115
|
+
前端库版本不低于 `0.10.0`。
|
|
1116
|
+
|
|
1117
|
+
## 支持平台
|
|
1118
|
+
|
|
1119
|
+
<table>
|
|
1120
|
+
<thead>
|
|
1121
|
+
<tr><th>平台</th><th>支持情况</th></tr>
|
|
1122
|
+
</thead>
|
|
1123
|
+
<tbody>
|
|
1124
|
+
<tr><td>Android</td><td>支持</td></tr>
|
|
1125
|
+
<tr><td>iOS</td><td>支持</td></tr>
|
|
1126
|
+
<tr><td>PC</td><td>不支持</td></tr>
|
|
1127
|
+
<tr><td>HarmonyOS</td><td>不支持</td></tr>
|
|
1128
|
+
</tbody>
|
|
1129
|
+
</table>
|
|
1130
|
+
|
|
1131
|
+
## 支持场景
|
|
1132
|
+
|
|
1133
|
+
<table>
|
|
1134
|
+
<thead>
|
|
1135
|
+
<tr><th>场景</th><th>支持情况</th></tr>
|
|
1136
|
+
</thead>
|
|
1137
|
+
<tbody>
|
|
1138
|
+
<tr><td>页面</td><td>支持</td></tr>
|
|
1139
|
+
<tr><td>卡片</td><td>不支持</td></tr>
|
|
1140
|
+
</tbody>
|
|
1141
|
+
</table>
|
|
1142
|
+
|
|
1143
|
+
## 使用说明
|
|
1144
|
+
|
|
1145
|
+
- 注册时不会立即触发回调;不再需要监听时,调用返回的函数取消监听。
|
|
1146
|
+
|
|
1147
|
+
## 调用方式
|
|
1148
|
+
|
|
1149
|
+
### 事件监听 API
|
|
1150
|
+
|
|
1151
|
+
```typescript
|
|
1152
|
+
onWindowResize(callback: WindowResizeListener): () => void
|
|
1153
|
+
```
|
|
1154
|
+
|
|
1155
|
+
## 入参
|
|
1156
|
+
|
|
1157
|
+
无。
|
|
1158
|
+
|
|
1159
|
+
## 调用示例
|
|
1160
|
+
|
|
1161
|
+
```typescript
|
|
1162
|
+
import { onWindowResize } from '@doubao-dev/framework/api';
|
|
1163
|
+
|
|
1164
|
+
const offWindowResize = onWindowResize(({ size }) => {
|
|
1165
|
+
console.log(size.windowWidth, size.windowHeight);
|
|
1166
|
+
});
|
|
1167
|
+
|
|
1168
|
+
offWindowResize();
|
|
1169
|
+
```
|
|
1170
|
+
|
|
1171
|
+
## 回调参数
|
|
1172
|
+
|
|
1173
|
+
<table>
|
|
1174
|
+
<thead>
|
|
1175
|
+
<tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
|
|
1176
|
+
</thead>
|
|
1177
|
+
<tbody>
|
|
1178
|
+
<tr><td><code>event.size</code></td><td><code>object</code></td><td>是</td><td>变化后的窗口尺寸,单位为逻辑像素。</td></tr>
|
|
1179
|
+
<tr><td><code>event.size.windowHeight</code></td><td><code>number</code></td><td>是</td><td>窗口高度。</td></tr>
|
|
1180
|
+
<tr><td><code>event.size.windowWidth</code></td><td><code>number</code></td><td>是</td><td>窗口宽度。</td></tr>
|
|
1181
|
+
</tbody>
|
|
1182
|
+
</table>
|
|
1183
|
+
|
|
1184
|
+
## 返回值
|
|
1185
|
+
|
|
1186
|
+
取消当前监听的函数。
|
|
1187
|
+
|
|
1188
|
+
### 回调示例
|
|
1189
|
+
|
|
1190
|
+
```json
|
|
1191
|
+
{
|
|
1192
|
+
"size": {
|
|
1193
|
+
"windowWidth": 393,
|
|
1194
|
+
"windowHeight": 852
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
```
|
|
1198
|
+
|
|
1099
1199
|
## 相关类型
|
|
1100
1200
|
|
|
1101
1201
|
<a id="windowsafearea"></a>
|
|
@@ -1369,3 +1469,26 @@ HealthKit 读取权限状态码。 - -1:未知或当前系统不支持该类
|
|
|
1369
1469
|
• **enableDebug?**: `boolean` - 豆包客户端是否为调试构建
|
|
1370
1470
|
• **deviceOrientation?**: `'portrait' | 'landscape'` - 设备方向
|
|
1371
1471
|
• **abi?**: `string` - 豆包客户端二进制接口类型(如 arm64-v8a),仅 Android 返回
|
|
1472
|
+
|
|
1473
|
+
<a id="windowresizelistener"></a>
|
|
1474
|
+
### WindowResizeListener
|
|
1475
|
+
|
|
1476
|
+
窗口尺寸变化监听函数。
|
|
1477
|
+
|
|
1478
|
+
#### Type
|
|
1479
|
+
|
|
1480
|
+
`(event: WindowResizeEvent) => void`
|
|
1481
|
+
|
|
1482
|
+
<a id="windowresizeevent"></a>
|
|
1483
|
+
### WindowResizeEvent
|
|
1484
|
+
|
|
1485
|
+
窗口尺寸变化事件。
|
|
1486
|
+
|
|
1487
|
+
#### Properties
|
|
1488
|
+
|
|
1489
|
+
• **size**: `{
|
|
1490
|
+
/** 窗口宽度。 */
|
|
1491
|
+
windowWidth: number;
|
|
1492
|
+
/** 窗口高度。 */
|
|
1493
|
+
windowHeight: number;
|
|
1494
|
+
}` - 变化后的窗口尺寸,单位为逻辑像素
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
| API | 说明 |
|
|
10
10
|
| --- | --- |
|
|
11
11
|
| [createIntersectionObserver](#createintersectionobserver) | 创建节点相交观察器,用于监听页面或卡片内目标节点的可见比例。 在当前视图 中查询目标和参照节点。 relativeTo 的参照节点应是目标的祖先节点,无效参照可能退回当前视图。 在当前视图中查询类选择器匹配的节点,匹配列表在调用 observe 时确定。 相交结果受祖先节点裁剪影响,不能用于判断其他节点是否遮挡目标。 |
|
|
12
|
+
| [createSelectorQuery](#createselectorquery) | 创建节点查询。先用 select 或 selectAll 选中节点并登记查询,再调用 exec 执行。 exec 的回调按登记顺序接收结果。可查询节点位置、尺寸、滚动偏移和计算样式。 |
|
|
12
13
|
|
|
13
14
|
## API 详情
|
|
14
15
|
|
|
@@ -123,6 +124,88 @@ useDestroy(() => observer.current?.disconnect());
|
|
|
123
124
|
- 目标初始相交比例为 0 时可能没有回调,滚动后收到的第一条回调仍会与 initialRatio 比较。
|
|
124
125
|
- 多次设置参照区域时,真机最后一次设置生效。部分版本的 time 固定为 0。
|
|
125
126
|
|
|
127
|
+
<a id="createselectorquery"></a>
|
|
128
|
+
### createSelectorQuery()
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
internal: true
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
# createSelectorQuery
|
|
135
|
+
|
|
136
|
+
创建节点查询。先用 select 或 selectAll 选中节点并登记查询,再调用 exec 执行。
|
|
137
|
+
exec 的回调按登记顺序接收结果。可查询节点位置、尺寸、滚动偏移和计算样式。
|
|
138
|
+
|
|
139
|
+
## 支持版本
|
|
140
|
+
|
|
141
|
+
前端库版本不低于 `0.10.0`。
|
|
142
|
+
|
|
143
|
+
## 支持平台
|
|
144
|
+
|
|
145
|
+
<table>
|
|
146
|
+
<thead>
|
|
147
|
+
<tr><th>平台</th><th>支持情况</th></tr>
|
|
148
|
+
</thead>
|
|
149
|
+
<tbody>
|
|
150
|
+
<tr><td>Android</td><td>支持</td></tr>
|
|
151
|
+
<tr><td>iOS</td><td>支持</td></tr>
|
|
152
|
+
<tr><td>PC</td><td>不支持</td></tr>
|
|
153
|
+
<tr><td>HarmonyOS</td><td>不支持</td></tr>
|
|
154
|
+
</tbody>
|
|
155
|
+
</table>
|
|
156
|
+
|
|
157
|
+
## 接入准备
|
|
158
|
+
|
|
159
|
+
### 前置条件
|
|
160
|
+
|
|
161
|
+
- 在视图后台脚本中调用,执行查询前确保目标节点已渲染
|
|
162
|
+
|
|
163
|
+
## 调用方式
|
|
164
|
+
|
|
165
|
+
### 同步 API
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
createSelectorQuery(): SelectorQuery
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## 入参
|
|
172
|
+
|
|
173
|
+
无。
|
|
174
|
+
|
|
175
|
+
## 调用示例
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
import { createSelectorQuery } from '@doubao-dev/framework/api';
|
|
179
|
+
|
|
180
|
+
createSelectorQuery().select('#target').fields({ size: true }).exec(console.log);
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## 返回值
|
|
184
|
+
|
|
185
|
+
<table>
|
|
186
|
+
<thead>
|
|
187
|
+
<tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
|
|
188
|
+
</thead>
|
|
189
|
+
<tbody>
|
|
190
|
+
<tr><td><code>exec</code></td><td><code>unknown</code></td><td>是</td><td>执行已登记的查询,按登记顺序将结果传给回调。</td></tr>
|
|
191
|
+
<tr><td><code>in</code></td><td><code>unknown</code></td><td>是</td><td>返回当前查询对象,查询范围保持为当前视图。</td></tr>
|
|
192
|
+
<tr><td><code>select</code></td><td><code>unknown</code></td><td>是</td><td>选取第一个匹配的节点。</td></tr>
|
|
193
|
+
<tr><td><code>selectAll</code></td><td><code>unknown</code></td><td>是</td><td>选取所有匹配的节点。</td></tr>
|
|
194
|
+
<tr><td><code>selectViewport</code></td><td><code>unknown</code></td><td>是</td><td>选取当前视图的视口。</td></tr>
|
|
195
|
+
</tbody>
|
|
196
|
+
</table>
|
|
197
|
+
|
|
198
|
+
### 返回示例
|
|
199
|
+
|
|
200
|
+
```json
|
|
201
|
+
[{ "width": 120, "height": 40 }]
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## 已知限制与注意事项
|
|
205
|
+
|
|
206
|
+
- in(component) 不切换查询范围。暂不支持查询 context、node、mark 和 properties。
|
|
207
|
+
- 滚动偏移仅支持可查询的滚动容器,暂不支持查询视口的滚动偏移。
|
|
208
|
+
|
|
126
209
|
## 相关类型
|
|
127
210
|
|
|
128
211
|
<a id="intersectionobservermargins"></a>
|
|
@@ -176,6 +259,19 @@ useDestroy(() => observer.current?.disconnect());
|
|
|
176
259
|
• **observe**: `(selector: string, callback: (result: IntersectionObserverResult) => void) => void` - 监听相交变化。支持节点 ID 和 SelectorQuery 可解析的选择器,例如 .target。调用时目标需已渲染
|
|
177
260
|
• **disconnect**: `() => void` - 停止监听并释放观察器
|
|
178
261
|
|
|
262
|
+
<a id="selectorquery"></a>
|
|
263
|
+
### SelectorQuery
|
|
264
|
+
|
|
265
|
+
批量查询节点及其布局信息。 @public。
|
|
266
|
+
|
|
267
|
+
#### Properties
|
|
268
|
+
|
|
269
|
+
• **select**: `(selector: string) => SelectorQueryNodesRef` - 选取第一个匹配的节点
|
|
270
|
+
• **selectAll**: `(selector: string) => SelectorQueryNodesRef` - 选取所有匹配的节点
|
|
271
|
+
• **selectViewport**: `() => SelectorQueryNodesRef` - 选取当前视图的视口
|
|
272
|
+
• **in**: `(component: object) => SelectorQuery` - 返回当前查询对象,查询范围保持为当前视图
|
|
273
|
+
• **exec**: `(callback?: SelectorQueryCallback<unknown[]>) => void` - 执行已登记的查询,按登记顺序将结果传给回调
|
|
274
|
+
|
|
179
275
|
<a id="intersectionobserverrect"></a>
|
|
180
276
|
### IntersectionObserverRect
|
|
181
277
|
|
|
@@ -187,3 +283,82 @@ useDestroy(() => observer.current?.disconnect());
|
|
|
187
283
|
• **right**: `number` - 右边界坐标
|
|
188
284
|
• **bottom**: `number` - 下边界坐标
|
|
189
285
|
• **left**: `number` - 左边界坐标
|
|
286
|
+
|
|
287
|
+
<a id="selectorquerycallback"></a>
|
|
288
|
+
### SelectorQueryCallback
|
|
289
|
+
|
|
290
|
+
接收单项或批量查询结果的回调。 @public。
|
|
291
|
+
|
|
292
|
+
#### Type
|
|
293
|
+
|
|
294
|
+
`(result: T) => void`
|
|
295
|
+
|
|
296
|
+
<a id="selectorquerynodesref"></a>
|
|
297
|
+
### SelectorQueryNodesRef
|
|
298
|
+
|
|
299
|
+
对选中的节点登记查询操作。 @public。
|
|
300
|
+
|
|
301
|
+
#### Properties
|
|
302
|
+
|
|
303
|
+
• **boundingClientRect**: `(callback?: SelectorQueryCallback<SelectorQueryResult<SelectorQueryRect>>) => SelectorQuery`
|
|
304
|
+
• **fields**: `(fields: SelectorQueryFields, callback?: SelectorQueryCallback<SelectorQueryResult<Record<string, unknown>>>) => SelectorQuery`
|
|
305
|
+
• **scrollOffset**: `(callback?: SelectorQueryCallback<SelectorQueryResult<SelectorQueryScrollOffset>>) => SelectorQuery`
|
|
306
|
+
• **context**: `(callback?: SelectorQueryCallback<null>) => SelectorQuery`
|
|
307
|
+
• **node**: `(callback?: SelectorQueryCallback<null>) => SelectorQuery`
|
|
308
|
+
|
|
309
|
+
<a id="selectorqueryfields"></a>
|
|
310
|
+
### SelectorQueryFields
|
|
311
|
+
|
|
312
|
+
控制节点查询返回的字段。 @public。
|
|
313
|
+
|
|
314
|
+
#### Properties
|
|
315
|
+
|
|
316
|
+
• **id?**: `boolean`
|
|
317
|
+
• **dataset?**: `boolean`
|
|
318
|
+
• **rect?**: `boolean`
|
|
319
|
+
• **size?**: `boolean`
|
|
320
|
+
• **scrollOffset?**: `boolean`
|
|
321
|
+
• **computedStyle?**: `string[]`
|
|
322
|
+
• **properties?**: `string[]`
|
|
323
|
+
• **mark?**: `boolean`
|
|
324
|
+
• **context?**: `boolean`
|
|
325
|
+
• **node?**: `boolean`
|
|
326
|
+
|
|
327
|
+
<a id="selectorqueryrect"></a>
|
|
328
|
+
### SelectorQueryRect
|
|
329
|
+
|
|
330
|
+
节点的位置、尺寸和标识信息。 @public。
|
|
331
|
+
|
|
332
|
+
#### Properties
|
|
333
|
+
|
|
334
|
+
• **id**: `string`
|
|
335
|
+
• **dataset**: `Record<string, unknown>`
|
|
336
|
+
• **left**: `number`
|
|
337
|
+
• **right**: `number`
|
|
338
|
+
• **top**: `number`
|
|
339
|
+
• **bottom**: `number`
|
|
340
|
+
• **width**: `number`
|
|
341
|
+
• **height**: `number`
|
|
342
|
+
|
|
343
|
+
<a id="selectorqueryresult"></a>
|
|
344
|
+
### SelectorQueryResult
|
|
345
|
+
|
|
346
|
+
单节点结果、多节点结果或未命中时的空值。 @public。
|
|
347
|
+
|
|
348
|
+
#### Type
|
|
349
|
+
|
|
350
|
+
`T | T[] | null`
|
|
351
|
+
|
|
352
|
+
<a id="selectorqueryscrolloffset"></a>
|
|
353
|
+
### SelectorQueryScrollOffset
|
|
354
|
+
|
|
355
|
+
滚动容器的偏移量及节点信息。 @public。
|
|
356
|
+
|
|
357
|
+
#### Type
|
|
358
|
+
|
|
359
|
+
`{
|
|
360
|
+
id: string;
|
|
361
|
+
dataset: Record<string, unknown>;
|
|
362
|
+
scrollLeft: number;
|
|
363
|
+
scrollTop: number;
|
|
364
|
+
}`
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# 豆包应用插件的端能力 API: 画布
|
|
2
|
+
|
|
3
|
+
离屏画布创建和 2D 绘制。
|
|
4
|
+
|
|
5
|
+
[返回目录](./groups.md) | [返回速查](./quick-reference.md)
|
|
6
|
+
|
|
7
|
+
## 速查
|
|
8
|
+
|
|
9
|
+
| API | 说明 |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| [createOffscreenCanvas](#createoffscreencanvas) | 同步创建离屏画布,用于 2D 绘制、像素读取和图片导出。 |
|
|
12
|
+
|
|
13
|
+
## API 详情
|
|
14
|
+
|
|
15
|
+
<a id="createoffscreencanvas"></a>
|
|
16
|
+
### createOffscreenCanvas()
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
internal: true
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# createOffscreenCanvas
|
|
23
|
+
|
|
24
|
+
同步创建离屏画布,用于 2D 绘制、像素读取和图片导出。
|
|
25
|
+
|
|
26
|
+
## 支持版本
|
|
27
|
+
|
|
28
|
+
前端库版本不低于 `0.10.0`。
|
|
29
|
+
|
|
30
|
+
## 支持平台
|
|
31
|
+
|
|
32
|
+
<table>
|
|
33
|
+
<thead>
|
|
34
|
+
<tr><th>平台</th><th>支持情况</th></tr>
|
|
35
|
+
</thead>
|
|
36
|
+
<tbody>
|
|
37
|
+
<tr><td>Android</td><td>支持</td></tr>
|
|
38
|
+
<tr><td>iOS</td><td>支持</td></tr>
|
|
39
|
+
<tr><td>PC</td><td>不支持</td></tr>
|
|
40
|
+
<tr><td>HarmonyOS</td><td>不支持</td></tr>
|
|
41
|
+
</tbody>
|
|
42
|
+
</table>
|
|
43
|
+
|
|
44
|
+
## 接入准备
|
|
45
|
+
|
|
46
|
+
### 前置条件
|
|
47
|
+
|
|
48
|
+
- 无需挂载 canvas 节点
|
|
49
|
+
|
|
50
|
+
## 使用说明
|
|
51
|
+
|
|
52
|
+
- 检查创建结果及 getContext 返回值;图片须在 onload 后绘制。
|
|
53
|
+
|
|
54
|
+
## 调用方式
|
|
55
|
+
|
|
56
|
+
### 同步 API
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
createOffscreenCanvas(options: OffscreenCanvasOptions): OffscreenCanvas | undefined
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## 入参
|
|
63
|
+
|
|
64
|
+
<table>
|
|
65
|
+
<thead>
|
|
66
|
+
<tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
|
|
67
|
+
</thead>
|
|
68
|
+
<tbody>
|
|
69
|
+
<tr><td><code>height</code></td><td><code>number</code></td><td>否</td><td><code>-</code></td><td>-</td><td>高度。</td></tr>
|
|
70
|
+
<tr><td><code>width</code></td><td><code>number</code></td><td>否</td><td><code>-</code></td><td>-</td><td>宽度。</td></tr>
|
|
71
|
+
</tbody>
|
|
72
|
+
</table>
|
|
73
|
+
|
|
74
|
+
## 调用示例
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { createOffscreenCanvas } from '@doubao-dev/framework/api';
|
|
78
|
+
|
|
79
|
+
const canvas = createOffscreenCanvas({ width: 64, height: 64 });
|
|
80
|
+
const ctx = canvas?.getContext('2d');
|
|
81
|
+
if (ctx) {
|
|
82
|
+
ctx.fillStyle = '#0068c4';
|
|
83
|
+
ctx.fillRect(0, 0, 64, 64);
|
|
84
|
+
console.log(ctx.getImageData(0, 0, 64, 64).data);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## 返回值
|
|
89
|
+
|
|
90
|
+
<table>
|
|
91
|
+
<thead>
|
|
92
|
+
<tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
|
|
93
|
+
</thead>
|
|
94
|
+
<tbody>
|
|
95
|
+
<tr><td><code>createImage</code></td><td><code>() => CanvasImage | undefined</code></td><td>否</td><td>创建图片对象</td></tr>
|
|
96
|
+
<tr><td><code>getContext</code></td><td><code>(contextType: "2d") => Canvas2DContext | null</code></td><td>否</td><td>获取绘图上下文</td></tr>
|
|
97
|
+
<tr><td><code>height</code></td><td><code>number</code></td><td>否</td><td>画布高度(buffer 像素数)</td></tr>
|
|
98
|
+
<tr><td><code>toDataURL</code></td><td><code>(type?: string, encoderOptions?: number) => string</code></td><td>否</td><td>导出画布内容为 data URI</td></tr>
|
|
99
|
+
<tr><td><code>width</code></td><td><code>number</code></td><td>否</td><td>画布宽度(buffer 像素数)</td></tr>
|
|
100
|
+
</tbody>
|
|
101
|
+
</table>
|
|
102
|
+
|
|
103
|
+
### 返回示例
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{ "width": 64, "height": 64 }
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## 相关类型
|
|
110
|
+
|
|
111
|
+
<a id="offscreencanvasoptions"></a>
|
|
112
|
+
### OffscreenCanvasOptions
|
|
113
|
+
|
|
114
|
+
离屏画布尺寸,单位为画布像素。@public。
|
|
115
|
+
|
|
116
|
+
#### Properties
|
|
117
|
+
|
|
118
|
+
• **width?**: `number` - 宽度
|
|
119
|
+
• **height?**: `number` - 高度
|
|
120
|
+
|
|
121
|
+
<a id="canvasimage"></a>
|
|
122
|
+
### CanvasImage
|
|
123
|
+
|
|
124
|
+
#### Properties
|
|
125
|
+
|
|
126
|
+
• **src**: `string` - 图片资源地址
|
|
127
|
+
• **width**: `number` - 图片原始宽度
|
|
128
|
+
• **height**: `number` - 图片原始高度
|
|
129
|
+
• **complete**: `boolean` - 图片资源是否加载完成
|
|
130
|
+
• **onload**: `(() => void) | null` - 图片加载完成时触发
|
|
131
|
+
• **onerror**: `((error: unknown) => void) | null` - 图片加载失败时触发
|
|
132
|
+
• **addEventListener**: `(
|
|
133
|
+
event: 'load' | 'error',
|
|
134
|
+
listener: (event: unknown) => void,
|
|
135
|
+
options?: AddEventListenerOptions | boolean
|
|
136
|
+
) => void` - 添加图片加载或失败事件监听器
|
|
137
|
+
• **removeEventListener**: `(
|
|
138
|
+
event: 'load' | 'error',
|
|
139
|
+
listener: (event: unknown) => void,
|
|
140
|
+
options?: EventListenerOptions | boolean
|
|
141
|
+
) => void` - 移除图片加载或失败事件监听器
|
|
142
|
+
|
|
143
|
+
<a id="canvas2dcontext"></a>
|
|
144
|
+
### Canvas2DContext
|
|
145
|
+
|
|
146
|
+
#### Properties
|
|
147
|
+
|
|
148
|
+
• **drawImage**: `(image: DrawImageSource, dx: number, dy: number) => void`
|
|
149
|
+
• **drawImage**: `(image: DrawImageSource, dx: number, dy: number, dw: number, dh: number) => void`
|
|
150
|
+
• **drawImage**: `(image: DrawImageSource, sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, dw: number, dh: number) => void`
|
|
151
|
+
|
|
152
|
+
<a id="offscreencanvas"></a>
|
|
153
|
+
### OffscreenCanvas
|
|
154
|
+
|
|
155
|
+
#### Properties
|
|
156
|
+
|
|
157
|
+
• **width**: `number` - 画布宽度(buffer 像素数)
|
|
158
|
+
• **height**: `number` - 画布高度(buffer 像素数)
|
|
159
|
+
• **getContext**: `{
|
|
160
|
+
(contextType: '2d'): Canvas2DContext | null;
|
|
161
|
+
(contextType: 'webgl', contextAttributes?: WebGLContextAttributes): WebGLRenderingContext | null;
|
|
162
|
+
(contextType: 'webgl2', contextAttributes?: WebGLContextAttributes): WebGL2RenderingContext | null;
|
|
163
|
+
}` - 获取绘图上下文
|
|
164
|
+
• **createImage**: `() => CanvasImage | undefined` - 创建图片对象
|
|
165
|
+
• **toDataURL**: `(type?: string, encoderOptions?: number) => string` - 导出画布内容为 data URI
|
|
166
|
+
|
|
167
|
+
<a id="drawimagesource"></a>
|
|
168
|
+
### DrawImageSource
|
|
169
|
+
|
|
170
|
+
#### Type
|
|
171
|
+
|
|
172
|
+
`CanvasImageSource | CanvasImage | OffscreenCanvas`
|
|
173
|
+
|
|
174
|
+
<a id="webglcontextattributes"></a>
|
|
175
|
+
### WebGLContextAttributes
|
|
176
|
+
|
|
177
|
+
#### Properties
|
|
178
|
+
|
|
179
|
+
• **alpha?**: `boolean` - 是否开启透明通道,开启后画布背景透明可与下层内容叠加显示
|
|
180
|
+
• **preserveDrawingBuffer?**: `boolean` - 是否保留绘图缓冲区,开启后 toDataURL/readPixels 可在绘制后正常读取
|
|
181
|
+
• **antialias?**: `boolean` - 是否开启抗锯齿
|
package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/groups.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
| 分组 | 说明 | API 数量 | 详细文档 |
|
|
8
8
|
| --- | --- | ---: | --- |
|
|
9
9
|
| 基础 | 账号、授权、豆包客户端信息、窗口信息和能力可用性。 | 10 | [查看](./01-基础.md) |
|
|
10
|
-
| 系统 | 豆包客户端信息、窗口信息和系统设置。 |
|
|
10
|
+
| 系统 | 豆包客户端信息、窗口信息和系统设置。 | 10 | [查看](./02-系统.md) |
|
|
11
11
|
| 自定义通信 | 在应用插件的页面或卡片实例之间发送和接收自定义事件。 | 1 | [查看](./03-自定义通信.md) |
|
|
12
12
|
| 定位 | 获取设备当前的地理位置信息。 | 5 | [查看](./04-定位.md) |
|
|
13
13
|
| 存储 | 本地缓存;带 Sync 后缀的是同步 API。 | 10 | [查看](./05-存储.md) |
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
| 界面 | 对话框状态、交互反馈、键盘、输入框和节点可见性观察能力。 | 3 | [查看](./07-界面.md) |
|
|
16
16
|
| 交互 | Toast、Loading、Modal、ActionSheet、BottomSheet 和返回前提醒。 | 10 | [查看](./08-交互.md) |
|
|
17
17
|
| 输入 | 键盘和输入框选区能力。 | 2 | [查看](./09-输入.md) |
|
|
18
|
-
| 可见性 | 节点相交区域和可见比例观察。 |
|
|
18
|
+
| 可见性 | 节点相交区域和可见比例观察。 | 2 | [查看](./10-可见性.md) |
|
|
19
19
|
| 网络 | 网络请求与 WebSocket。 | 4 | [查看](./11-网络.md) |
|
|
20
20
|
| 媒体 | 图片选择、预览、保存、压缩和信息读取;录音管理;背景音频和内部音频播放。 | 8 | [查看](./12-媒体.md) |
|
|
21
21
|
| 业务能力 | 开放业务能力、卡片更新、模型上下文、任务和隐私设置。 | 7 | [查看](./13-业务能力.md) |
|
|
@@ -42,3 +42,4 @@
|
|
|
42
42
|
| 屏幕 | 屏幕亮度、常亮和截屏/录屏相关能力。 | 7 | [查看](./34-屏幕.md) |
|
|
43
43
|
| 震动 | 触发短震动和长震动。 | 2 | [查看](./35-震动.md) |
|
|
44
44
|
| 文件系统 | 文件读写、目录管理和文件信息操作。 | 1 | [查看](./36-文件系统.md) |
|
|
45
|
+
| 画布 | 离屏画布创建和 2D 绘制。 | 1 | [查看](./37-画布.md) |
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> 这是豆包应用插件运行时 API,也称 Open API。默认从 `@doubao-dev/framework/api` 导入;本文件根据 `packages/open-api/src` 的导出结构自动生成,按模块列出 API 名称和说明。
|
|
4
4
|
|
|
5
|
-
覆盖
|
|
5
|
+
覆盖 162 个函数。详细参数、返回值、示例和相关类型请查看 [豆包应用插件的端能力 API 分组目录](groups.md),精确字段也可按参数/结果类型名查看 IDE 类型提示或 `@doubao-dev/framework/api` 类型定义。
|
|
6
6
|
|
|
7
7
|
## 使用方式
|
|
8
8
|
|
|
@@ -64,6 +64,7 @@ import { showToast, request, getStorage } from '@doubao-dev/framework/api';
|
|
|
64
64
|
| [onThemeChange](02-系统.md#onthemechange) | 监听应用主题变化。 当用户在系统设置或豆包客户端内切换浅色、深色主题时触发。回调参数中的 theme 表示切换后的主题,可与 getAppBaseInfo 返回的 theme 字段配合使用。<br><br>返回取消监听函数。 |
|
|
65
65
|
| [getSystemInfo](02-系统.md#getsysteminfo) | 获取系统信息。 |
|
|
66
66
|
| [getSystemInfoSync](02-系统.md#getsysteminfosync) | 同步获取系统信息。<br><br>同步 API。 |
|
|
67
|
+
| [onWindowResize](02-系统.md#onwindowresize) | 监听当前窗口尺寸变化。 使用与 getWindowInfoSync 相同的数据源,仅在窗口宽度或高度变化时触发,注册时不触发回调。<br><br>返回取消监听函数。 |
|
|
67
68
|
|
|
68
69
|
## 自定义通信
|
|
69
70
|
|
|
@@ -160,6 +161,7 @@ Toast、Loading、Modal、ActionSheet、BottomSheet 和返回前提醒。
|
|
|
160
161
|
| API | 说明 |
|
|
161
162
|
| --- | --- |
|
|
162
163
|
| [createIntersectionObserver](10-可见性.md#createintersectionobserver) | 创建节点相交观察器,用于监听页面或卡片内目标节点的可见比例。 在当前视图 中查询目标和参照节点。 relativeTo 的参照节点应是目标的祖先节点,无效参照可能退回当前视图。 在当前视图中查询类选择器匹配的节点,匹配列表在调用 observe 时确定。 相交结果受祖先节点裁剪影响,不能用于判断其他节点是否遮挡目标。 |
|
|
164
|
+
| [createSelectorQuery](10-可见性.md#createselectorquery) | 创建节点查询。先用 select 或 selectAll 选中节点并登记查询,再调用 exec 执行。 exec 的回调按登记顺序接收结果。可查询节点位置、尺寸、滚动偏移和计算样式。 |
|
|
163
165
|
|
|
164
166
|
## 网络
|
|
165
167
|
|
|
@@ -442,3 +444,11 @@ iBeacon 搜索和结果读取能力。
|
|
|
442
444
|
| API | 说明 |
|
|
443
445
|
| --- | --- |
|
|
444
446
|
| [getFileSystemManager](36-文件系统.md#getfilesystemmanager) | 获取文件系统管理器。 |
|
|
447
|
+
|
|
448
|
+
## 画布
|
|
449
|
+
|
|
450
|
+
离屏画布创建和 2D 绘制。
|
|
451
|
+
|
|
452
|
+
| API | 说明 |
|
|
453
|
+
| --- | --- |
|
|
454
|
+
| [createOffscreenCanvas](37-画布.md#createoffscreencanvas) | 同步创建离屏画布,用于 2D 绘制、像素读取和图片导出。 |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doubao-dev/plugin-app-dev",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.8",
|
|
4
4
|
"description": "App development tools for Doubao Plugin CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
"!dist/**/*.map"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@lynx-js/debug-router-connector": "0.0.
|
|
23
|
+
"@lynx-js/debug-router-connector": "0.0.21",
|
|
24
24
|
"open": "10.1.0",
|
|
25
25
|
"ws": "^8.21.0",
|
|
26
26
|
"moleculer": "^0.15.0",
|
|
27
27
|
"zod": "4.2.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@byted-doubao-apps/plugin-app-dev": "1.0.0-rc.
|
|
30
|
+
"@byted-doubao-apps/plugin-app-dev": "1.0.0-rc.8",
|
|
31
31
|
"@rslib/core": "1.0.0-beta.1",
|
|
32
32
|
"@types/node": "22.20.4",
|
|
33
33
|
"rimraf": "3.0.2",
|