refactor(PageController): mv dom and actions

This commit is contained in:
Simon
2025-12-02 21:30:39 +08:00
parent 51f81fc44c
commit ad19a26a57
5 changed files with 0 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,51 @@
// FlatDomTree: 扁平化 DOM 树结构,适用于高效存储和遍历页面结构。
// 每个节点通过 map 索引,支持文本节点和元素节点,字段区分 undefined 和 false。
export interface FlatDomTree {
rootId: string
map: Record<string, DomNode>
}
export type DomNode = TextDomNode | ElementDomNode | InteractiveElementDomNode
export interface TextDomNode {
type: 'TEXT_NODE'
text: string
isVisible: boolean
// 其他可选字段
[key: string]: unknown
}
export interface ElementDomNode {
tagName: string
attributes?: Record<string, string>
xpath?: string
children?: string[]
isVisible?: boolean
isTopElement?: boolean
isInViewport?: boolean
isNew?: boolean
isInteractive?: false
highlightIndex?: number
extra?: Record<string, any>
// 其他可选字段
[key: string]: unknown
}
export interface InteractiveElementDomNode {
tagName: string
attributes?: Record<string, string>
xpath?: string
children?: string[]
isVisible?: boolean
isTopElement?: boolean
isInViewport?: boolean
isInteractive: true
highlightIndex: number
/**
* 可交互元素的 dom 引用
*/
ref: HTMLElement
// 其他可选字段
[key: string]: unknown
}