@doubao-dev/plugin-app-dev 1.0.0-rc.7 → 1.0.0-rc.9
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/{27- → 26-}/345/237/272/347/241/200/344/277/241/346/201/257.md +11 -6
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/36-/347/224/273/345/270/203.md +181 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/groups.md +28 -28
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/quick-reference.md +121 -120
- package/package.json +3 -3
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/10-/345/217/257/350/247/201/346/200/247.md +0 -189
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{11- → 10-}/347/275/221/347/273/234.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{12- → 11-}/345/252/222/344/275/223.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{13- → 12-}/344/270/232/345/212/241/350/203/275/345/212/233.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{14- → 13-}/347/231/273/345/275/225.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{15- → 14-}/346/224/257/344/273/230.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{16- → 15-}/346/225/260/346/215/256/345/210/206/346/236/220.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{17- → 16-}/350/223/235/347/211/231.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{18-wi-fi.md → 17-wi-fi.md} +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{19- → 18-}/345/212/240/351/200/237/345/272/246/350/256/241.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{20-ibeacon.md → 19-ibeacon.md} +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{21- → 20-}/347/275/227/347/233/230.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{22- → 21-}/350/256/276/345/244/207/346/226/271/345/220/221.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{23- → 22-}/351/231/200/350/236/272/344/273/252.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{24- → 23-}/345/252/222/344/275/223-/350/256/276/345/244/207-/347/275/221/347/273/234.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{25- → 24-}/347/237/255/344/277/241.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{26- → 25-}/346/227/240/351/232/234/347/242/215.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{28- → 27-}/347/224/265/346/261/240.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{29- → 28-}/345/211/252/350/264/264/346/235/277.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{30- → 29-}/345/212/240/345/257/206.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{31- → 30-}/346/227/245/345/216/206.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{32- → 31-}/347/224/265/350/257/235.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{33- → 32-}/346/211/253/347/240/201.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{34- → 33-}/345/261/217/345/271/225.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{35- → 34-}/351/234/207/345/212/250.md" +0 -0
- /package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/{36- → 35-}/346/226/207/344/273/266/347/263/273/347/273/237.md" +0 -0
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
# 豆包应用插件的端能力 API: 可见性
|
|
2
|
-
|
|
3
|
-
节点相交区域和可见比例观察。
|
|
4
|
-
|
|
5
|
-
[返回目录](./groups.md) | [返回速查](./quick-reference.md)
|
|
6
|
-
|
|
7
|
-
## 速查
|
|
8
|
-
|
|
9
|
-
| API | 说明 |
|
|
10
|
-
| --- | --- |
|
|
11
|
-
| [createIntersectionObserver](#createintersectionobserver) | 创建节点相交观察器,用于监听页面或卡片内目标节点的可见比例。 在当前视图 中查询目标和参照节点。 relativeTo 的参照节点应是目标的祖先节点,无效参照可能退回当前视图。 在当前视图中查询类选择器匹配的节点,匹配列表在调用 observe 时确定。 相交结果受祖先节点裁剪影响,不能用于判断其他节点是否遮挡目标。 |
|
|
12
|
-
|
|
13
|
-
## API 详情
|
|
14
|
-
|
|
15
|
-
<a id="createintersectionobserver"></a>
|
|
16
|
-
### createIntersectionObserver()
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
internal: true
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
# createIntersectionObserver
|
|
23
|
-
|
|
24
|
-
创建节点相交观察器,用于监听页面或卡片内目标节点的可见比例。
|
|
25
|
-
|
|
26
|
-
在当前视图 中查询目标和参照节点。
|
|
27
|
-
relativeTo 的参照节点应是目标的祖先节点,无效参照可能退回当前视图。
|
|
28
|
-
在当前视图中查询类选择器匹配的节点,匹配列表在调用 observe 时确定。
|
|
29
|
-
相交结果受祖先节点裁剪影响,不能用于判断其他节点是否遮挡目标。
|
|
30
|
-
|
|
31
|
-
## 支持版本
|
|
32
|
-
|
|
33
|
-
前端库版本不低于 `0.10.0`。
|
|
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
|
-
### 前置条件
|
|
64
|
-
|
|
65
|
-
- 豆包版本大于等于 15.5.0。在视图后台脚本中调用,observe 前确保目标节点已渲染
|
|
66
|
-
|
|
67
|
-
## 调用方式
|
|
68
|
-
|
|
69
|
-
### 同步 API
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
createIntersectionObserver(options?: IntersectionObserverOptions): IntersectionObserver
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## 入参
|
|
76
|
-
|
|
77
|
-
<table>
|
|
78
|
-
<thead>
|
|
79
|
-
<tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
|
|
80
|
-
</thead>
|
|
81
|
-
<tbody>
|
|
82
|
-
<tr><td><code>initialRatio</code></td><td><code>number</code></td><td>否</td><td><code>0</code></td><td>-</td><td>初始相交比例,取值为 0 到 1。每个目标的第一条回调若与该比例相等,则跳过。</td></tr>
|
|
83
|
-
<tr><td><code>observeAll</code></td><td><code>boolean</code></td><td>否</td><td><code>false</code></td><td>-</td><td>是否观察选择器匹配的全部节点。默认只观察首个匹配节点。</td></tr>
|
|
84
|
-
<tr><td><code>thresholds</code></td><td><code>number[]</code></td><td>否</td><td><code>[0]</code></td><td>-</td><td>触发相交状态变化通知的阈值,每项取值为 0 到 1。</td></tr>
|
|
85
|
-
</tbody>
|
|
86
|
-
</table>
|
|
87
|
-
|
|
88
|
-
## 调用示例
|
|
89
|
-
|
|
90
|
-
```tsx
|
|
91
|
-
import { createIntersectionObserver } from '@doubao-dev/framework/api';
|
|
92
|
-
import { useMounted, useDestroy, useRef } from '@doubao-dev/framework';
|
|
93
|
-
|
|
94
|
-
// 在页面或卡片组件中使用,渲染带有 target 类名的节点。
|
|
95
|
-
const observer = useRef<ReturnType<typeof createIntersectionObserver> | undefined>(undefined);
|
|
96
|
-
useMounted(() => {
|
|
97
|
-
observer.current = createIntersectionObserver({ thresholds: [0, 0.5, 1], observeAll: true });
|
|
98
|
-
observer.current.relativeToViewport().observe('.target', (result) => {
|
|
99
|
-
console.log(result.intersectionRatio);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
useDestroy(() => observer.current?.disconnect());
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
## 返回值
|
|
106
|
-
|
|
107
|
-
<table>
|
|
108
|
-
<thead>
|
|
109
|
-
<tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
|
|
110
|
-
</thead>
|
|
111
|
-
<tbody>
|
|
112
|
-
<tr><td><code>disconnect</code></td><td><code>() => void</code></td><td>是</td><td>停止监听并释放观察器。</td></tr>
|
|
113
|
-
<tr><td><code>observe</code></td><td><code>(selector: string, callback: (result: IntersectionObserverResult) => void) => void</code></td><td>是</td><td>监听相交变化。支持节点 ID 和 SelectorQuery 可解析的选择器,例如 .target。调用时目标需已渲染。</td></tr>
|
|
114
|
-
<tr><td><code>relativeTo</code></td><td><code>(selector: string, margins?: IntersectionObserverMargins) => IntersectionObserver</code></td><td>是</td><td>指定参照节点及其边界偏移;使用 #id 指定参照节点。</td></tr>
|
|
115
|
-
<tr><td><code>relativeToScreen</code></td><td><code>(margins?: IntersectionObserverMargins) => IntersectionObserver</code></td><td>是</td><td>以屏幕为参照区域。</td></tr>
|
|
116
|
-
<tr><td><code>relativeToViewport</code></td><td><code>(margins?: IntersectionObserverMargins) => IntersectionObserver</code></td><td>是</td><td>以当前视图 的可视区域为参照,不等同于整个屏幕。</td></tr>
|
|
117
|
-
</tbody>
|
|
118
|
-
</table>
|
|
119
|
-
|
|
120
|
-
## 已知限制与注意事项
|
|
121
|
-
|
|
122
|
-
- 类选择器匹配范围由 SelectorQuery 决定,调用 observe 后新增的目标需要重新注册。参照节点使用 #id 查找。
|
|
123
|
-
- 目标初始相交比例为 0 时可能没有回调,滚动后收到的第一条回调仍会与 initialRatio 比较。
|
|
124
|
-
- 多次设置参照区域时,真机最后一次设置生效。部分版本的 time 固定为 0。
|
|
125
|
-
|
|
126
|
-
## 相关类型
|
|
127
|
-
|
|
128
|
-
<a id="intersectionobservermargins"></a>
|
|
129
|
-
### IntersectionObserverMargins
|
|
130
|
-
|
|
131
|
-
扩展或收缩参照区域的边界,正数扩展,负数收缩。@public。
|
|
132
|
-
|
|
133
|
-
#### Properties
|
|
134
|
-
|
|
135
|
-
• **top?**: `number` - 上边界偏移
|
|
136
|
-
• **right?**: `number` - 右边界偏移
|
|
137
|
-
• **bottom?**: `number` - 下边界偏移
|
|
138
|
-
• **left?**: `number` - 左边界偏移
|
|
139
|
-
|
|
140
|
-
<a id="intersectionobserveroptions"></a>
|
|
141
|
-
### IntersectionObserverOptions
|
|
142
|
-
|
|
143
|
-
相交观察器配置。@public。
|
|
144
|
-
|
|
145
|
-
#### Properties
|
|
146
|
-
|
|
147
|
-
• **thresholds?**: `number[]` - 触发相交状态变化通知的阈值,每项取值为 0 到 1
|
|
148
|
-
• **initialRatio?**: `number` - 初始相交比例,取值为 0 到 1。每个目标的第一条回调若与该比例相等,则跳过
|
|
149
|
-
• **observeAll?**: `boolean` - 是否观察选择器匹配的全部节点。默认只观察首个匹配节点
|
|
150
|
-
|
|
151
|
-
<a id="intersectionobserverresult"></a>
|
|
152
|
-
### IntersectionObserverResult
|
|
153
|
-
|
|
154
|
-
相交状态变化数据。@public。
|
|
155
|
-
|
|
156
|
-
#### Properties
|
|
157
|
-
|
|
158
|
-
• **isIntersecting**: `boolean` - 是否与参照区域相交
|
|
159
|
-
• **intersectionRatio**: `number` - 相交比例
|
|
160
|
-
• **intersectionRect**: `IntersectionObserverRect` - 相交区域的边界
|
|
161
|
-
• **boundingClientRect**: `IntersectionObserverRect` - 目标节点的边界
|
|
162
|
-
• **relativeRect**: `IntersectionObserverRect` - 参照区域的边界
|
|
163
|
-
• **observerId**: `string` - 被观察目标的节点标识
|
|
164
|
-
• **time**: `number` - 检测时间;部分豆包版本返回 0,不用于统计曝光时长
|
|
165
|
-
|
|
166
|
-
<a id="intersectionobserver"></a>
|
|
167
|
-
### IntersectionObserver
|
|
168
|
-
|
|
169
|
-
相交观察器。使用结束时调用 disconnect 释放监听。@public。
|
|
170
|
-
|
|
171
|
-
#### Properties
|
|
172
|
-
|
|
173
|
-
• **relativeTo**: `(selector: string, margins?: IntersectionObserverMargins) => IntersectionObserver` - 指定参照节点及其边界偏移;使用 #id 指定参照节点
|
|
174
|
-
• **relativeToViewport**: `(margins?: IntersectionObserverMargins) => IntersectionObserver` - 以当前视图 的可视区域为参照,不等同于整个屏幕
|
|
175
|
-
• **relativeToScreen**: `(margins?: IntersectionObserverMargins) => IntersectionObserver` - 以屏幕为参照区域
|
|
176
|
-
• **observe**: `(selector: string, callback: (result: IntersectionObserverResult) => void) => void` - 监听相交变化。支持节点 ID 和 SelectorQuery 可解析的选择器,例如 .target。调用时目标需已渲染
|
|
177
|
-
• **disconnect**: `() => void` - 停止监听并释放观察器
|
|
178
|
-
|
|
179
|
-
<a id="intersectionobserverrect"></a>
|
|
180
|
-
### IntersectionObserverRect
|
|
181
|
-
|
|
182
|
-
相交区域的四边坐标,相对于当前视图。@public。
|
|
183
|
-
|
|
184
|
-
#### Properties
|
|
185
|
-
|
|
186
|
-
• **top**: `number` - 上边界坐标
|
|
187
|
-
• **right**: `number` - 右边界坐标
|
|
188
|
-
• **bottom**: `number` - 下边界坐标
|
|
189
|
-
• **left**: `number` - 左边界坐标
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|