-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.ts
More file actions
47 lines (38 loc) · 1.48 KB
/
base.ts
File metadata and controls
47 lines (38 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* Abstract base for platform adapters.
*
* Ported from python-sdk/cup/_base.py
*/
import type { CupNode, TreeStats, WindowInfo, WindowMetadata } from "./types.js";
/**
* Interface that each platform tree-capture backend must implement.
*
* Subclasses handle all platform-specific initialization, window
* enumeration, tree walking, and CUP node construction.
*/
export interface PlatformAdapter {
/** Platform identifier used in CUP envelopes. */
readonly platformName: string;
/** Perform any one-time setup (COM init, etc.). Idempotent. */
initialize(): Promise<void>;
/** Return [width, height, scaleFactor] of the primary display. */
getScreenInfo(): Promise<[number, number, number]>;
/** Return metadata about the foreground/focused window. */
getForegroundWindow(): Promise<WindowMetadata>;
/** Return metadata for all visible top-level windows. */
getAllWindows(): Promise<WindowMetadata[]>;
/** Return lightweight metadata for all visible windows. Near-instant. */
getWindowList(): Promise<WindowInfo[]>;
/** Return metadata for the desktop surface, or null. */
getDesktopWindow(): Promise<WindowMetadata | null>;
/**
* Walk the accessibility tree for the given windows.
*
* Returns [treeRoots, stats, refs] where refs maps element IDs
* to native platform references for action execution.
*/
captureTree(
windows: WindowMetadata[],
options?: { maxDepth?: number },
): Promise<[CupNode[], TreeStats, Map<string, unknown>]>;
}