dsh-browser-view 0.4.1 → 0.7.0

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 (86) hide show
  1. package/README.md +14 -10
  2. package/lib/client.js +1 -1
  3. package/lib/index.js +7776 -5392
  4. package/lib/types/browser/adapters/antd.d.ts +14 -0
  5. package/lib/types/browser/adapters/archetypes.d.ts +93 -0
  6. package/lib/types/browser/adapters/dom.d.ts +6 -0
  7. package/lib/types/browser/adapters/element.d.ts +5 -0
  8. package/lib/types/browser/adapters/engine.d.ts +51 -0
  9. package/lib/types/browser/adapters/generic.d.ts +5 -0
  10. package/lib/types/browser/adapters/index.d.ts +10 -0
  11. package/lib/types/browser/adapters/modules/drag.d.ts +3 -0
  12. package/lib/types/browser/adapters/modules/editor.d.ts +3 -0
  13. package/lib/types/browser/adapters/modules/hierarchy.d.ts +3 -0
  14. package/lib/types/browser/adapters/modules/temporal.d.ts +3 -0
  15. package/lib/types/browser/adapters/modules/transfer.d.ts +3 -0
  16. package/lib/types/browser/adapters/modules/virtual.d.ts +4 -0
  17. package/lib/types/browser/adapters/quiescence.d.ts +3 -0
  18. package/lib/types/browser/adapters/registry.d.ts +64 -0
  19. package/lib/types/browser/adapters/select.d.ts +15 -0
  20. package/lib/types/browser/adapters/types.d.ts +134 -0
  21. package/lib/types/browser/codegen/playwright.d.ts +10 -0
  22. package/lib/types/browser/definitions/collaboration.d.ts +4 -0
  23. package/lib/types/browser/definitions/doctor.d.ts +4 -0
  24. package/lib/types/browser/definitions/extract.d.ts +4 -0
  25. package/lib/types/browser/definitions/inspection.d.ts +4 -0
  26. package/lib/types/browser/definitions/interaction.d.ts +4 -0
  27. package/lib/types/browser/definitions/navigation.d.ts +4 -0
  28. package/lib/types/browser/definitions/recorder.d.ts +4 -0
  29. package/lib/types/browser/definitions/testing.d.ts +4 -0
  30. package/lib/types/browser/policy/engine.d.ts +26 -0
  31. package/lib/types/browser/policy/types.d.ts +36 -0
  32. package/lib/types/browser/primitives/dialog.d.ts +12 -0
  33. package/lib/types/browser/primitives/dom.d.ts +43 -0
  34. package/lib/types/browser/primitives/drag.d.ts +3 -0
  35. package/lib/types/browser/primitives/editor.d.ts +3 -0
  36. package/lib/types/browser/primitives/form.d.ts +7 -0
  37. package/lib/types/browser/primitives/hierarchy.d.ts +3 -0
  38. package/lib/types/browser/primitives/index.d.ts +12 -0
  39. package/lib/types/browser/primitives/select.d.ts +7 -0
  40. package/lib/types/browser/primitives/temporal.d.ts +3 -0
  41. package/lib/types/browser/primitives/transfer.d.ts +3 -0
  42. package/lib/types/browser/primitives/types.d.ts +48 -0
  43. package/lib/types/browser/primitives/virtual.d.ts +4 -0
  44. package/lib/types/browser/reports.d.ts +0 -2
  45. package/lib/types/browser/session/cache.d.ts +103 -0
  46. package/lib/types/browser/session/collaboration.d.ts +53 -0
  47. package/lib/types/browser/session/recorder.d.ts +62 -0
  48. package/lib/types/browser/session/screencast.d.ts +37 -0
  49. package/lib/types/browser/session/screenshot.d.ts +17 -0
  50. package/lib/types/browser/session/semantic.d.ts +94 -0
  51. package/lib/types/browser/session/target.d.ts +16 -0
  52. package/lib/types/browser/session/tracer.d.ts +56 -0
  53. package/lib/types/browser/session.d.ts +7 -140
  54. package/lib/types/browser/stealth/keyboard.d.ts +13 -0
  55. package/lib/types/browser/stealth/mouse.d.ts +28 -0
  56. package/lib/types/browser/tools/collaboration.d.ts +73 -0
  57. package/lib/types/browser/tools/common.d.ts +67 -0
  58. package/lib/types/browser/tools/doctor.d.ts +31 -0
  59. package/lib/types/browser/tools/extract.d.ts +92 -0
  60. package/lib/types/browser/tools/inspection.d.ts +93 -0
  61. package/lib/types/browser/tools/interaction.d.ts +148 -0
  62. package/lib/types/browser/tools/navigation.d.ts +126 -0
  63. package/lib/types/browser/tools/recorder.d.ts +236 -0
  64. package/lib/types/browser/tools/testing.d.ts +94 -0
  65. package/lib/types/browser/tools.d.ts +9 -873
  66. package/lib/types/browser/types.d.ts +70 -7
  67. package/lib/types/browser/walker.d.ts +3 -12
  68. package/lib/types/client/api.d.ts +24 -0
  69. package/lib/types/client/components/ConfirmCard.d.ts +20 -0
  70. package/lib/types/client/components/FloatingOverlay.d.ts +10 -0
  71. package/lib/types/client/components/FloatingPanel.d.ts +40 -0
  72. package/lib/types/client/components/InspectionModal.d.ts +51 -0
  73. package/lib/types/client/components/SettingsSection.d.ts +5 -0
  74. package/lib/types/client/components/styles.d.ts +18 -0
  75. package/lib/types/client/hooks/useBrowserStatus.d.ts +11 -0
  76. package/lib/types/client/hooks/useConfirmPolling.d.ts +6 -0
  77. package/lib/types/client/hooks/usePickPolling.d.ts +5 -0
  78. package/lib/types/client/hooks/useRecordings.d.ts +9 -0
  79. package/lib/types/client/index.d.ts +7 -10
  80. package/lib/types/client/theme.d.ts +7 -0
  81. package/lib/types/client/types.d.ts +74 -0
  82. package/lib/types/lib/config.d.ts +0 -2
  83. package/lib/types/lib/http.d.ts +0 -2
  84. package/lib/types/lib/types.d.ts +1 -0
  85. package/package.json +13 -3
  86. package/lib/types/embed.d.ts +0 -7
@@ -0,0 +1,14 @@
1
+ import type { Page } from "playwright-core";
2
+ import { BaseUIAdapter } from "./engine.js";
3
+ import type { FormFieldItem } from "./types.js";
4
+ export declare class AntDesignAdapter extends BaseUIAdapter {
5
+ constructor();
6
+ /**
7
+ * Ant Design 专有复合组件字段填充 (支持 DatePicker 与 Cascader)
8
+ */
9
+ fillFormField(page: Page, field: FormFieldItem, scope?: string): Promise<{
10
+ handled: boolean;
11
+ error?: string;
12
+ }>;
13
+ }
14
+ //# sourceMappingURL=antd.d.ts.map
@@ -0,0 +1,93 @@
1
+ import type { Page } from "playwright-core";
2
+ /**
3
+ * 交互目标提升规则 (Target Lifting)
4
+ */
5
+ export interface LiftingRule {
6
+ /** 目标标识,如 "checkbox-radio" 或 "combobox-input" */
7
+ kind: string;
8
+ /**
9
+ * 浏览器端元素特征判定
10
+ */
11
+ matches: (el: Element) => boolean;
12
+ /**
13
+ * 提升后的目标 Locator XPath 或选择器表达式
14
+ */
15
+ liftSelector: string;
16
+ }
17
+ /**
18
+ * UI 框架声明式描述符接口 (UIFrameworkDescriptor)
19
+ * 允许针对任何现代前端框架 (Ant Design, Element Plus, Arco Design, TDesign, Mantine 等)
20
+ * 仅通过声明式配置即可获得完整的语义提取、弹窗隔离、目标提升、下拉与交互自愈能力。
21
+ */
22
+ export interface UIFrameworkDescriptor {
23
+ /** 适配器唯一名称,如 "ant-design", "element-plus", "generic", "arco-design" */
24
+ name: string;
25
+ /** 框架探测规则 */
26
+ detection: {
27
+ /** 页面特征选择器,如 "[class*='ant-'], #__ANTD_PRO__" */
28
+ selector?: string;
29
+ /** 全局变量判定,如 "__ANTD_PRO__" */
30
+ globalVar?: string;
31
+ /** 自定义匹配函数 */
32
+ customCheck?: (page: Page) => Promise<boolean>;
33
+ };
34
+ /** 弹窗与抽屉浮层隔离 */
35
+ dialogs: {
36
+ /** 活动状态弹窗/抽屉选择器列表,如 [".ant-modal:not([style*='display: none'])"] */
37
+ activeSelectors: string[];
38
+ /** 弹窗标题选择器,如 ".ant-modal-title, .ant-drawer-title" */
39
+ titleSelector?: string;
40
+ };
41
+ /** 表单与 Label 关联 */
42
+ forms: {
43
+ /** 表单项包装容器选择器,如 ".ant-form-item" */
44
+ itemSelector: string;
45
+ /** 表单项 Label 选择器,如 ".ant-form-item-label, label" */
46
+ labelSelector: string;
47
+ /** 单选/多选/开关包装选择器,如 "label, .ant-radio-wrapper, .ant-checkbox-wrapper, [class*='wrapper']" */
48
+ wrapperSelector?: string;
49
+ };
50
+ /** 下拉与浮层交互规范 */
51
+ select: {
52
+ /** 下拉触发器外层宿主选择器,如 ".ant-select, .ant-select-selector" */
53
+ triggerSelector: string;
54
+ /** controlsId 匹配模式,如 /^rc_select_/ */
55
+ controlsIdPattern?: RegExp;
56
+ /** 展开状态的 class 名称列表,如 ["ant-select-open", "is-focus"] */
57
+ openClassNames?: string[];
58
+ /** 点击展开时优先点击的子选择器,如 ".ant-select-selector" */
59
+ clickTargetSelector?: string;
60
+ /** 激活状态的下拉浮层容器选择器,如 ".ant-select-dropdown:not(.ant-select-dropdown-hidden):not([style*='display: none'])" */
61
+ dropdownSelector: string;
62
+ /** 下拉浮层基础类名(用于 controlsId 逆向查找),如 "ant-select-dropdown" */
63
+ dropdownBaseClass?: string;
64
+ /** 选项条目选择器,如 ".ant-select-item-option, [role='option']" */
65
+ optionSelector: string;
66
+ /** 清除所有选中项按钮选择器,如 ".ant-select-clear, .el-select__clear, [class*='-clear']" */
67
+ clearSelector?: string;
68
+ /** 多选模式下单个标签的移除按钮选择器,如 ".ant-select-selection-item-remove, .el-tag__close, [class*='item-remove']" */
69
+ removeTagSelector?: string;
70
+ /** 数据为空时的指示容器选择器,如 ".ant-select-dropdown-empty, .ant-empty, .ant-select-item-empty" */
71
+ emptySelector?: string;
72
+ };
73
+ /** 目标提升规则 (Target Lifting) */
74
+ lifting?: LiftingRule[];
75
+ /** DOM Class -> ARIA Role 角色增强映射 */
76
+ roleMappings?: Record<string, string>;
77
+ /** 框架特异性隐藏类名判定 (如 "-hidden", "is-hidden") */
78
+ hiddenClassSubstrings?: string[];
79
+ /** 交互错误自愈策略 */
80
+ recovery?: {
81
+ /** 遮罩层 class 特征,如 ["ant-modal-wrap", "ant-modal-mask", "ant-drawer-mask"] */
82
+ maskClassSubstrings?: string[];
83
+ /** 框架元素 class 前缀,用于判断是否由动画未结束挂起,如 "ant-" */
84
+ targetClassSubstring?: string;
85
+ };
86
+ }
87
+ /** 内置 Ant Design (Vue / React) 描述符 */
88
+ export declare const antdDescriptor: UIFrameworkDescriptor;
89
+ /** 内置 Element Plus / Element UI 描述符 */
90
+ export declare const elementPlusDescriptor: UIFrameworkDescriptor;
91
+ /** 内置 Generic W3C 标准描述符 */
92
+ export declare const genericDescriptor: UIFrameworkDescriptor;
93
+ //# sourceMappingURL=archetypes.d.ts.map
@@ -0,0 +1,6 @@
1
+ import type { Locator, Page } from "playwright-core";
2
+ import { extractElementLabel, isElementDisabled } from "../primitives/index.js";
3
+ export { extractElementLabel, isElementDisabled };
4
+ export declare const ACTIVE_DIALOG_SELECTORS: string;
5
+ export declare function getActiveDialog(page: Page): Locator;
6
+ //# sourceMappingURL=dom.d.ts.map
@@ -0,0 +1,5 @@
1
+ import { BaseUIAdapter } from "./engine.js";
2
+ export declare class ElementPlusAdapter extends BaseUIAdapter {
3
+ constructor();
4
+ }
5
+ //# sourceMappingURL=element.d.ts.map
@@ -0,0 +1,51 @@
1
+ import type { Locator, Page } from "playwright-core";
2
+ import type { ActionContext, ActionInterceptor, ActionResult, FormFieldItem, QuiescenceOptions, SelectContext, SelectResult, SemanticExtractionHook, UIAdapter, VirtualExtractOptions } from "./types.js";
3
+ import type { LiftingRule, UIFrameworkDescriptor } from "./archetypes.js";
4
+ /**
5
+ * 通用下拉选择状态机引擎
6
+ * 参数化适配任何符合 UIFrameworkDescriptor 规范的 UI 组件库
7
+ */
8
+ export declare function executeArchetypeSelect(desc: UIFrameworkDescriptor, ctx: SelectContext): Promise<SelectResult>;
9
+ /**
10
+ * 目标提升执行器
11
+ */
12
+ export declare function executeArchetypeLifting(rules: LiftingRule[] | undefined, ctx: ActionContext): Promise<Locator | void>;
13
+ /**
14
+ * 交互错误自愈执行器
15
+ */
16
+ export declare function executeArchetypeRecovery(desc: UIFrameworkDescriptor, ctx: ActionContext, error: Error): Promise<ActionResult | void>;
17
+ /**
18
+ * 语义抽取钩子工厂
19
+ */
20
+ export declare function createArchetypeSemanticHook(desc: UIFrameworkDescriptor): SemanticExtractionHook;
21
+ /**
22
+ * 统一基底组件库适配器 (BaseUIAdapter)
23
+ * 接受任何 UIFrameworkDescriptor,直接提供完整的 UIAdapter 协议实现
24
+ */
25
+ export declare class BaseUIAdapter implements UIAdapter {
26
+ readonly name: string;
27
+ readonly descriptor: UIFrameworkDescriptor;
28
+ readonly activeDialogSelector: string;
29
+ readonly extractionHook: SemanticExtractionHook;
30
+ readonly actionInterceptor: ActionInterceptor;
31
+ constructor(descriptor: UIFrameworkDescriptor);
32
+ matches(page: Page): Promise<boolean>;
33
+ waitForQuiescence(page: Page, options?: QuiescenceOptions): Promise<boolean>;
34
+ matchesSelect(ctx: SelectContext): Promise<boolean>;
35
+ selectOption(ctx: SelectContext): Promise<SelectResult>;
36
+ fillFormField(page: Page, field: FormFieldItem, scope?: string): Promise<{
37
+ handled: boolean;
38
+ error?: string;
39
+ }>;
40
+ fillDate(ctx: ActionContext, field: string, dateValue: string | [string, string]): Promise<boolean>;
41
+ selectPath(ctx: ActionContext, field: string, path: string[]): Promise<boolean>;
42
+ transferItems(ctx: ActionContext, selector: string, direction: "left" | "right", items: string[]): Promise<boolean>;
43
+ extractVirtualList(page: Page, options: VirtualExtractOptions): Promise<Record<string, any>[]>;
44
+ fillEditorContent(ctx: ActionContext, selector: string, content: string): Promise<boolean>;
45
+ dragAndDrop(ctx: ActionContext, sourceSelector: string, targetSelector: string): Promise<boolean>;
46
+ }
47
+ /**
48
+ * 声明式 UI 适配器工厂函数
49
+ */
50
+ export declare function defineUIAdapter(descriptor: UIFrameworkDescriptor, overrides?: Partial<UIAdapter>): UIAdapter;
51
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1,5 @@
1
+ import { BaseUIAdapter } from "./engine.js";
2
+ export declare class GenericAdapter extends BaseUIAdapter {
3
+ constructor();
4
+ }
5
+ //# sourceMappingURL=generic.d.ts.map
@@ -0,0 +1,10 @@
1
+ export * from "./types.js";
2
+ export * from "./archetypes.js";
3
+ export * from "./engine.js";
4
+ export * from "./registry.js";
5
+ export { waitForDOMQuiescence } from "./quiescence.js";
6
+ export * from "./antd.js";
7
+ export * from "./element.js";
8
+ export * from "./generic.js";
9
+ export * from "./dom.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ import type { Page } from "playwright-core";
2
+ export declare function dragAndDropHelper(page: Page, sourceSelector: string, targetSelector: string): Promise<boolean>;
3
+ //# sourceMappingURL=drag.d.ts.map
@@ -0,0 +1,3 @@
1
+ import type { Page } from "playwright-core";
2
+ export declare function fillEditorHelper(page: Page, selector: string, content: string): Promise<boolean>;
3
+ //# sourceMappingURL=editor.d.ts.map
@@ -0,0 +1,3 @@
1
+ import type { Locator, Page } from "playwright-core";
2
+ export declare function selectPathHelper(page: Page, trigger: string | Locator, path: string[]): Promise<boolean>;
3
+ //# sourceMappingURL=hierarchy.d.ts.map
@@ -0,0 +1,3 @@
1
+ import type { Locator, Page } from "playwright-core";
2
+ export declare function fillDateRangeHelper(page: Page, container: string | Locator, dateValue: string | [string, string]): Promise<boolean>;
3
+ //# sourceMappingURL=temporal.d.ts.map
@@ -0,0 +1,3 @@
1
+ import type { Page } from "playwright-core";
2
+ export declare function transferItemsHelper(page: Page, containerSelector: string, direction: "left" | "right", items: string[]): Promise<boolean>;
3
+ //# sourceMappingURL=transfer.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { Page } from "playwright-core";
2
+ import type { VirtualExtractOptions } from "../types.js";
3
+ export declare function extractVirtualListHelper(page: Page, options: VirtualExtractOptions): Promise<Record<string, any>[]>;
4
+ //# sourceMappingURL=virtual.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { waitForDOMQuiescence } from "../primitives/index.js";
2
+ export type { QuiescenceOptions } from "../primitives/index.js";
3
+ //# sourceMappingURL=quiescence.d.ts.map
@@ -0,0 +1,64 @@
1
+ import type { Page } from "playwright-core";
2
+ import type { UIFrameworkDescriptor } from "./archetypes.js";
3
+ import type { ActionContext, ActionResult, FormFieldItem, SelectContext, SelectResult, UIAdapter, VirtualExtractOptions } from "./types.js";
4
+ declare class UIAdapterRegistryImpl {
5
+ private adapters;
6
+ private pageAdapterCache;
7
+ constructor();
8
+ /** 注册新的 UI 适配器插件 */
9
+ register(adapter: UIAdapter): void;
10
+ /** 声明式注册新的 UI 框架描述符 (自动生成对应 UIAdapter) */
11
+ registerDescriptor(descriptor: UIFrameworkDescriptor, overrides?: Partial<UIAdapter>): UIAdapter;
12
+ /** 获取指定适配器 */
13
+ get(name: string): UIAdapter | undefined;
14
+ /**
15
+ * 自动探测并获取当前页面对应的适配器
16
+ * 结果绑定到 Page 弱引用缓存中,避免重复探测
17
+ */
18
+ getActiveAdapter(page: Page): Promise<UIAdapter>;
19
+ /**
20
+ * 聚合所有已注册适配器的活动弹窗/对话框选择器
21
+ */
22
+ getActiveDialogSelectors(): string;
23
+ /**
24
+ * 聚合所有已注册适配器的表单项容器选择器
25
+ */
26
+ getFormItemSelectors(): string;
27
+ /**
28
+ * 聚合所有已注册适配器的表单项 Label 选择器
29
+ */
30
+ getFormLabelSelectors(): string;
31
+ /**
32
+ * 调度器入口: 自动根据目标节点特征解析最合适的 UI 适配器执行下拉交互
33
+ */
34
+ executeSelect(ctx: SelectContext): Promise<SelectResult>;
35
+ /**
36
+ * 清理页面的适配器缓存 (通常在页面发生整页导航时调用)
37
+ */
38
+ clearCache(page: Page): void;
39
+ /**
40
+ * 动作预处理管道 (执行目标提升等)
41
+ */
42
+ beforeAction(ctx: ActionContext): Promise<void | import("playwright-core").Locator>;
43
+ /**
44
+ * 动作异常自愈管道 (处理遮罩层、阻挡重试等)
45
+ */
46
+ onActionError(ctx: ActionContext, error: Error): Promise<ActionResult | void>;
47
+ /**
48
+ * 表单项智能填充调度:
49
+ * 优先尝试当前匹配的 UI 框架特异性适配器,若未处理则交由通用适配器兜底
50
+ */
51
+ fillFormField(page: Page, field: FormFieldItem, scope?: string): Promise<{
52
+ handled: boolean;
53
+ error?: string;
54
+ }>;
55
+ fillDate(ctx: ActionContext, field: string, dateValue: string | [string, string]): Promise<boolean>;
56
+ selectPath(ctx: ActionContext, field: string, path: string[]): Promise<boolean>;
57
+ transferItems(ctx: ActionContext, selector: string, direction: "left" | "right", items: string[]): Promise<boolean>;
58
+ extractVirtualList(page: Page, options: VirtualExtractOptions): Promise<Record<string, any>[]>;
59
+ fillEditorContent(ctx: ActionContext, selector: string, content: string): Promise<boolean>;
60
+ dragAndDrop(ctx: ActionContext, sourceSelector: string, targetSelector: string): Promise<boolean>;
61
+ }
62
+ export declare const adapterRegistry: UIAdapterRegistryImpl;
63
+ export {};
64
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1,15 @@
1
+ import type { SelectContext, SelectResult } from "./types.js";
2
+ export type { SelectContext, SelectResult };
3
+ /**
4
+ * 下拉适配器接口 (向后兼容类型导出)
5
+ */
6
+ export interface SelectAdapter {
7
+ readonly name: string;
8
+ matches(ctx: SelectContext): Promise<boolean>;
9
+ select(ctx: SelectContext): Promise<SelectResult>;
10
+ }
11
+ /**
12
+ * 调度器入口: 自动委托给 adapterRegistry 解析最合适的 UI 适配器执行交互。
13
+ */
14
+ export declare function executeSelectAdapter(ctx: SelectContext): Promise<SelectResult>;
15
+ //# sourceMappingURL=select.d.ts.map
@@ -0,0 +1,134 @@
1
+ import type { Locator, Page } from "playwright-core";
2
+ import type { BrowserConfig } from "../types.js";
3
+ /** 动作执行上下文 */
4
+ export interface ActionContext {
5
+ page: Page;
6
+ config: BrowserConfig;
7
+ target: Locator;
8
+ action: "click" | "type" | "select" | "press";
9
+ args: Record<string, any>;
10
+ retries?: number;
11
+ }
12
+ /** 动作执行自愈结果 */
13
+ export interface ActionResult {
14
+ handled: boolean;
15
+ result?: any;
16
+ retryWith?: {
17
+ force?: boolean;
18
+ timeoutMs?: number;
19
+ target?: Locator;
20
+ };
21
+ }
22
+ /**
23
+ * 语义抽取钩子 (在页内注入执行,必须为自包含逻辑)
24
+ * 用于扩展 walker.ts 的 nameOf、roleOf 与 isVisible
25
+ */
26
+ export interface SemanticExtractionHook {
27
+ /** 根据元素与角色提取语义名称,返回 null 表示未命中由默认逻辑处理 */
28
+ resolveName?(el: Element, role: string): string | null;
29
+ /** 识别特异性角色,返回 null 表示由默认逻辑处理 */
30
+ resolveRole?(el: Element): string | null;
31
+ /** 快速可见性启发式判定,返回 null 表示由默认逻辑处理 */
32
+ checkVisible?(el: Element): boolean | null;
33
+ }
34
+ /**
35
+ * 交互动作拦截器 (在 Node.js 主机侧执行)
36
+ */
37
+ export interface ActionInterceptor {
38
+ /** 交互发生前的预处理,如点击目标提升(Target Lifting) */
39
+ beforeAction?(ctx: ActionContext): Promise<Locator | void>;
40
+ /** 交互抛出错误时的自愈拦截器,如处理遮罩层拦截 */
41
+ onActionError?(ctx: ActionContext, error: Error): Promise<ActionResult | void>;
42
+ }
43
+ /**
44
+ * 页面稳态等待选项
45
+ */
46
+ export interface QuiescenceOptions {
47
+ /** 连续无 DOM 变更的静默时间(ms),默认 80ms */
48
+ quietMs?: number;
49
+ /** 最大等待超时(ms),默认 2500ms */
50
+ maxTimeoutMs?: number;
51
+ /** 检查的根节点选择器,默认 document.body */
52
+ scope?: string;
53
+ }
54
+ /**
55
+ * 下拉选择交互上下文
56
+ */
57
+ export interface SelectContext {
58
+ page: Page;
59
+ target: Locator;
60
+ label: string;
61
+ want: string;
62
+ exact: boolean;
63
+ timeout: number;
64
+ clear?: boolean;
65
+ }
66
+ /**
67
+ * 下拉选择结果
68
+ */
69
+ export interface SelectResult {
70
+ selected: string;
71
+ }
72
+ /** 单个表单项填充参数 */
73
+ export interface FormFieldItem {
74
+ key: string;
75
+ value: any;
76
+ }
77
+ /** 批量表单填充汇总结果 */
78
+ export interface FormFillResult {
79
+ filled: string[];
80
+ skipped: string[];
81
+ errors: Record<string, string>;
82
+ submitted?: boolean;
83
+ }
84
+ /** 虚拟滚动长列表抽取选项 */
85
+ export interface VirtualExtractOptions {
86
+ scope?: string;
87
+ fields: Record<string, string>;
88
+ maxRows: number;
89
+ stepPixels?: number;
90
+ }
91
+ /**
92
+ * 统一组件库适配器接口 (Pluggable UI Adapter Protocol v2)
93
+ */
94
+ export interface UIAdapter {
95
+ /** 适配器唯一标识,如 "ant-design", "element-plus", "generic" */
96
+ readonly name: string;
97
+ /**
98
+ * 页内环境探测:判断当前页面是否命中该 UI 框架特征
99
+ * 在 page.evaluate 中运行
100
+ */
101
+ matches(page: Page): Promise<boolean>;
102
+ /** 语义抽取扩展钩子 (页内序列化注入) */
103
+ readonly extractionHook?: SemanticExtractionHook;
104
+ /** 交互动作拦截器 (主机侧) */
105
+ readonly actionInterceptor?: ActionInterceptor;
106
+ /** 稳态等待策略 */
107
+ waitForQuiescence?(page: Page, options?: QuiescenceOptions): Promise<boolean>;
108
+ /** 活动弹窗/对话框的选择器列表 (用于限制作用域) */
109
+ readonly activeDialogSelector?: string;
110
+ /** 是否匹配该 UI 框架的下拉/浮层触发器 */
111
+ matchesSelect?(ctx: SelectContext): Promise<boolean>;
112
+ /** 执行下拉/浮层选择 */
113
+ selectOption?(ctx: SelectContext): Promise<SelectResult>;
114
+ /**
115
+ * 组件库特异性表单字段填充 (如 AntD a-form-item、Checkbox、DatePicker 等)
116
+ */
117
+ fillFormField?(page: Page, field: FormFieldItem, scope?: string): Promise<{
118
+ handled: boolean;
119
+ error?: string;
120
+ }>;
121
+ /** 1. 时序组件: 处理日期/时间/范围选择 */
122
+ fillDate?(ctx: ActionContext, field: string, dateValue: string | [string, string]): Promise<boolean>;
123
+ /** 2. 层级组件: 处理级联与树选择 (路径驱动) */
124
+ selectPath?(ctx: ActionContext, field: string, path: string[]): Promise<boolean>;
125
+ /** 3. 穿梭组件: 批量移动左/右项 */
126
+ transferItems?(ctx: ActionContext, selector: string, direction: "left" | "right", items: string[]): Promise<boolean>;
127
+ /** 4. 虚拟滚动: 接管长列表滚动抽取 */
128
+ extractVirtualList?(page: Page, options: VirtualExtractOptions): Promise<Record<string, any>[]>;
129
+ /** 5. 编辑器组件: 富文本与代码编辑器安全设值 */
130
+ fillEditorContent?(ctx: ActionContext, selector: string, content: string): Promise<boolean>;
131
+ /** 6. 拖拽组件: 物理轨迹跨容器拖拽 */
132
+ dragAndDrop?(ctx: ActionContext, sourceSelector: string, targetSelector: string): Promise<boolean>;
133
+ }
134
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,10 @@
1
+ import type { ReplayStep } from "../types.js";
2
+ export interface CompileOptions {
3
+ title?: string;
4
+ baseUrl?: string;
5
+ }
6
+ /**
7
+ * 将录制序列转译为符合行业标准规范的原生 Playwright TypeScript 测试代码
8
+ */
9
+ export declare function compileToPlaywrightSpec(steps: ReplayStep[], options?: CompileOptions): string;
10
+ //# sourceMappingURL=playwright.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { PlainToolDefinition } from "../../lib/types.js";
2
+ import type { BrowserConfig } from "../types.js";
3
+ export declare function getCollaborationTools(config: BrowserConfig, timeout: (ms?: number) => number, stepImpls?: Record<string, (a: any) => Promise<unknown>>): PlainToolDefinition[];
4
+ //# sourceMappingURL=collaboration.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { PlainToolDefinition } from "../../lib/types.js";
2
+ import type { BrowserConfig } from "../types.js";
3
+ export declare function getDoctorTools(config: BrowserConfig, timeout: (ms?: number) => number, stepImpls?: Record<string, (a: any) => Promise<unknown>>): PlainToolDefinition[];
4
+ //# sourceMappingURL=doctor.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { PlainToolDefinition } from "../../lib/types.js";
2
+ import type { BrowserConfig } from "../types.js";
3
+ export declare function getExtractTools(config: BrowserConfig, timeout: (ms?: number) => number, stepImpls?: Record<string, (a: any) => Promise<unknown>>): PlainToolDefinition[];
4
+ //# sourceMappingURL=extract.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { PlainToolDefinition } from "../../lib/types.js";
2
+ import type { BrowserConfig } from "../types.js";
3
+ export declare function getInspectionTools(config: BrowserConfig, timeout: (ms?: number) => number, stepImpls?: Record<string, (a: any) => Promise<unknown>>): PlainToolDefinition[];
4
+ //# sourceMappingURL=inspection.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { PlainToolDefinition } from "../../lib/types.js";
2
+ import type { BrowserConfig } from "../types.js";
3
+ export declare function getInteractionTools(config: BrowserConfig, timeout: (ms?: number) => number, stepImpls?: Record<string, (a: any) => Promise<unknown>>): PlainToolDefinition[];
4
+ //# sourceMappingURL=interaction.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { PlainToolDefinition } from "../../lib/types.js";
2
+ import type { BrowserConfig } from "../types.js";
3
+ export declare function getNavigationTools(config: BrowserConfig, timeout: (ms?: number) => number, stepImpls?: Record<string, (a: any) => Promise<unknown>>): PlainToolDefinition[];
4
+ //# sourceMappingURL=navigation.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { PlainToolDefinition } from "../../lib/types.js";
2
+ import type { BrowserConfig } from "../types.js";
3
+ export declare function getRecorderTools(config: BrowserConfig, timeout: (ms?: number) => number, stepImpls: Record<string, (a: any) => Promise<unknown>>): PlainToolDefinition[];
4
+ //# sourceMappingURL=recorder.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { PlainToolDefinition } from "../../lib/types.js";
2
+ import type { BrowserConfig } from "../types.js";
3
+ export declare function getTestingTools(config: BrowserConfig, timeout: (ms?: number) => number, stepImpls?: Record<string, (a: any) => Promise<unknown>>): PlainToolDefinition[];
4
+ //# sourceMappingURL=testing.d.ts.map
@@ -0,0 +1,26 @@
1
+ import type { BrowserConfig } from "../types.js";
2
+ import type { PolicyDecision, PolicyEvaluationContext, PolicyRule } from "./types.js";
3
+ export declare const DEFAULT_SENSITIVE_PATTERNS: string[];
4
+ export declare const DEFAULT_SENSITIVE_TOOLS: string[];
5
+ export interface SensitiveDesc {
6
+ role?: string;
7
+ name?: string;
8
+ text?: string;
9
+ id?: string;
10
+ testid?: string;
11
+ tag?: string;
12
+ }
13
+ /**
14
+ * 纯逻辑: 元素描述命中了哪些敏感模式(role/name/text/id/testid/tag 拼接后
15
+ * 子串匹配, 大小写不敏感; 空白模式忽略)。返回命中的模式列表(空 = 放行)。
16
+ */
17
+ export declare function sensitiveHits(desc?: SensitiveDesc | null, patterns?: string[]): string[];
18
+ /**
19
+ * 判定单条策略规则是否匹配当前上下文
20
+ */
21
+ export declare function matchPolicyRule(rule: PolicyRule, ctx: PolicyEvaluationContext): boolean;
22
+ /**
23
+ * 策略引擎评估入口: 按规则链顺序判定,优先匹配第一条命中的规则
24
+ */
25
+ export declare function evaluatePolicy(config: BrowserConfig, ctx: PolicyEvaluationContext): PolicyDecision;
26
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1,36 @@
1
+ export interface PolicyRule {
2
+ /** 规则名称/标识 */
3
+ name: string;
4
+ /** 页面 URL 正则模式,如 ".*(localhost|127\\.0\\.0\\.1|\\.test\\.|\\.qa\\.).*" */
5
+ urlPattern?: string;
6
+ /** 动作/工具正则模式,如 "browser_click", "browser_.*" */
7
+ actionPattern?: string;
8
+ /** 选择器正则模式,如 "#danger-action.*" */
9
+ selectorPattern?: string;
10
+ /** 敏感文本模式数组,如 ["提交", "删除", "支付"] */
11
+ patterns?: string[];
12
+ /** 拦截级别:off(直接放行) | manual(提示) | auto(强制审批弹卡) */
13
+ level: "off" | "manual" | "auto";
14
+ /** 审批超时时间 (毫秒),覆盖全局 confirmTimeoutMs */
15
+ timeoutMs?: number;
16
+ }
17
+ export interface PolicyEvaluationContext {
18
+ url: string;
19
+ tool: string;
20
+ selector: string;
21
+ desc?: {
22
+ role?: string;
23
+ name?: string;
24
+ text?: string;
25
+ id?: string;
26
+ testid?: string;
27
+ tag?: string;
28
+ } | null;
29
+ }
30
+ export interface PolicyDecision {
31
+ matchedRule?: PolicyRule;
32
+ level: "off" | "manual" | "auto";
33
+ reason?: string;
34
+ timeoutMs?: number;
35
+ }
36
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { Locator, Page } from "playwright-core";
2
+ /**
3
+ * 通用活动弹窗/对话框/抽屉选择器列表
4
+ * 基于 W3C WAI-ARIA 规范 (role="dialog", aria-modal="true") 与现代 Web 通用命名规范
5
+ */
6
+ export declare const ACTIVE_DIALOG_SELECTORS: string;
7
+ /**
8
+ * 获取当前页面上处于活动状态的最顶层弹窗容器 (Locator)
9
+ */
10
+ export declare function getActiveDialog(page: Page): Locator;
11
+ export declare function getActiveDialogSelectors(): string;
12
+ //# sourceMappingURL=dialog.d.ts.map
@@ -0,0 +1,43 @@
1
+ import type { Locator, Page } from "playwright-core";
2
+ import type { QuiescenceOptions } from "./types.js";
3
+ /**
4
+ * 提取表单元素关联的语义 Label:
5
+ * 覆盖原生 label、aria-labelledby、以及各类主流组件库的表单包装结构。
6
+ * 供 targetLocator 及无障碍名称校验在浏览器端(evaluate)执行。
7
+ */
8
+ export declare function extractElementLabel(el: Element): string;
9
+ /**
10
+ * 统一判定元素或其上下文是否处于禁用状态 (Native disabled, WAI-ARIA aria-disabled, 以及通用 disabled class)
11
+ */
12
+ export declare function isElementDisabled(el: Element): boolean;
13
+ /**
14
+ * 等待页面 DOM 达到稳定状态 (基于 MutationObserver 静默期)
15
+ */
16
+ export declare function waitForDOMQuiescence(page: Page, options?: QuiescenceOptions): Promise<boolean>;
17
+ /**
18
+ * 目标提升原语 (Target Lifting):
19
+ * 现代 Web 页面中自定义 checkbox / radio 的原生 <input> 通常设置了 opacity: 0 或宽高为 0,
20
+ * 并由外层 label 或 wrapper 承载视觉与交互。当目标为隐藏 input 时,自动提升定位至可见的外层宿主容器。
21
+ */
22
+ export declare function liftTargetIfHiddenInput(target: Locator, evalTimeout?: number): Promise<Locator>;
23
+ /**
24
+ * 遮罩与过渡拦截自愈:
25
+ * 处理弹窗打开/关闭动画期间遮罩层 (mask) 暂时拦截指针事件的偶发异常
26
+ */
27
+ export declare function isMaskInterceptionError(error: Error): boolean;
28
+ /**
29
+ * 开始记录 DOM 变化(点击前调用):在页内装 MutationObserver,变化累积到
30
+ * window.__dshWatch。失败静默(endChangeWatch 会返回空摘要,不放大错误)。
31
+ */
32
+ export declare function beginChangeWatch(page: Page): Promise<void>;
33
+ /**
34
+ * 收口变化记录(点击后调用):graceMs 宽限(默认 600ms,等异步涟漪)后断开
35
+ * 观察器,返回去重截断(≤30)的变化元素选择器列表。未曾 begin 时返回空摘要。
36
+ */
37
+ export declare function endChangeWatch(page: Page, options?: {
38
+ graceMs?: number;
39
+ }): Promise<{
40
+ mutations: string[];
41
+ domChanged: boolean;
42
+ }>;
43
+ //# sourceMappingURL=dom.d.ts.map
@@ -0,0 +1,3 @@
1
+ import type { Page } from "playwright-core";
2
+ export declare function dragAndDropHelper(page: Page, sourceSelector: string, targetSelector: string): Promise<boolean>;
3
+ //# sourceMappingURL=drag.d.ts.map
@@ -0,0 +1,3 @@
1
+ import type { Page } from "playwright-core";
2
+ export declare function fillEditorHelper(page: Page, selector: string, content: string): Promise<boolean>;
3
+ //# sourceMappingURL=editor.d.ts.map
@@ -0,0 +1,7 @@
1
+ import type { Page } from "playwright-core";
2
+ import type { FormFieldItem } from "./types.js";
3
+ export declare function fillFormFieldHelper(page: Page, field: FormFieldItem, scope?: string): Promise<{
4
+ handled: boolean;
5
+ error?: string;
6
+ }>;
7
+ //# sourceMappingURL=form.d.ts.map