@ap3x/browser 0.1.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 (88) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -0
  3. package/dist/cdp/connection.d.ts +53 -0
  4. package/dist/cdp/connection.d.ts.map +1 -0
  5. package/dist/cdp/endpoint.d.ts +18 -0
  6. package/dist/cdp/endpoint.d.ts.map +1 -0
  7. package/dist/cdp/reconnect.d.ts +22 -0
  8. package/dist/cdp/reconnect.d.ts.map +1 -0
  9. package/dist/chunk-DXCP25KX.js +77 -0
  10. package/dist/config.d.ts +91 -0
  11. package/dist/config.d.ts.map +1 -0
  12. package/dist/dialogs/handler.d.ts +43 -0
  13. package/dist/dialogs/handler.d.ts.map +1 -0
  14. package/dist/dom/clickability.d.ts +4 -0
  15. package/dist/dom/clickability.d.ts.map +1 -0
  16. package/dist/dom/compound.d.ts +4 -0
  17. package/dist/dom/compound.d.ts.map +1 -0
  18. package/dist/dom/constants.d.ts +28 -0
  19. package/dist/dom/constants.d.ts.map +1 -0
  20. package/dist/dom/dom-service.d.ts +65 -0
  21. package/dist/dom/dom-service.d.ts.map +1 -0
  22. package/dist/dom/enhanced-tree.d.ts +52 -0
  23. package/dist/dom/enhanced-tree.d.ts.map +1 -0
  24. package/dist/dom/hashing.d.ts +21 -0
  25. package/dist/dom/hashing.d.ts.map +1 -0
  26. package/dist/dom/node.d.ts +43 -0
  27. package/dist/dom/node.d.ts.map +1 -0
  28. package/dist/dom/overlay.d.ts +11 -0
  29. package/dist/dom/overlay.d.ts.map +1 -0
  30. package/dist/dom/paint-order.d.ts +25 -0
  31. package/dist/dom/paint-order.d.ts.map +1 -0
  32. package/dist/dom/serialize-text.d.ts +16 -0
  33. package/dist/dom/serialize-text.d.ts.map +1 -0
  34. package/dist/dom/serializer.d.ts +33 -0
  35. package/dist/dom/serializer.d.ts.map +1 -0
  36. package/dist/dom/snapshot.d.ts +37 -0
  37. package/dist/dom/snapshot.d.ts.map +1 -0
  38. package/dist/dom/types.d.ts +178 -0
  39. package/dist/dom/types.d.ts.map +1 -0
  40. package/dist/downloads/sanitize.d.ts +13 -0
  41. package/dist/downloads/sanitize.d.ts.map +1 -0
  42. package/dist/driver.d.ts +88 -0
  43. package/dist/driver.d.ts.map +1 -0
  44. package/dist/errors.d.ts +71 -0
  45. package/dist/errors.d.ts.map +1 -0
  46. package/dist/events.d.ts +8 -0
  47. package/dist/events.d.ts.map +1 -0
  48. package/dist/index.d.ts +55 -0
  49. package/dist/index.d.ts.map +1 -0
  50. package/dist/index.js +5066 -0
  51. package/dist/input/dispatcher.d.ts +196 -0
  52. package/dist/input/dispatcher.d.ts.map +1 -0
  53. package/dist/input/keys.d.ts +20 -0
  54. package/dist/input/keys.d.ts.map +1 -0
  55. package/dist/launch/discovery.d.ts +14 -0
  56. package/dist/launch/discovery.d.ts.map +1 -0
  57. package/dist/launch/local-browser.d.ts +59 -0
  58. package/dist/launch/local-browser.d.ts.map +1 -0
  59. package/dist/navigation/navigator.d.ts +37 -0
  60. package/dist/navigation/navigator.d.ts.map +1 -0
  61. package/dist/navigation/policy.d.ts +61 -0
  62. package/dist/navigation/policy.d.ts.map +1 -0
  63. package/dist/providers/cloak.d.ts +26 -0
  64. package/dist/providers/cloak.d.ts.map +1 -0
  65. package/dist/providers/factory.d.ts +17 -0
  66. package/dist/providers/factory.d.ts.map +1 -0
  67. package/dist/providers/index.d.ts +5 -0
  68. package/dist/providers/index.d.ts.map +1 -0
  69. package/dist/providers/local.d.ts +13 -0
  70. package/dist/providers/local.d.ts.map +1 -0
  71. package/dist/providers/types.d.ts +8 -0
  72. package/dist/providers/types.d.ts.map +1 -0
  73. package/dist/recording/har.d.ts +94 -0
  74. package/dist/recording/har.d.ts.map +1 -0
  75. package/dist/recording/screencast.d.ts +40 -0
  76. package/dist/recording/screencast.d.ts.map +1 -0
  77. package/dist/screenshot/service.d.ts +34 -0
  78. package/dist/screenshot/service.d.ts.map +1 -0
  79. package/dist/session.d.ts +130 -0
  80. package/dist/session.d.ts.map +1 -0
  81. package/dist/targets/registry.d.ts +99 -0
  82. package/dist/targets/registry.d.ts.map +1 -0
  83. package/dist/testing.d.ts +53 -0
  84. package/dist/testing.d.ts.map +1 -0
  85. package/dist/testing.js +8 -0
  86. package/dist/types.d.ts +88 -0
  87. package/dist/types.d.ts.map +1 -0
  88. package/package.json +42 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/dom/node.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,mBAAmB,EAAY,MAAM,SAAS,CAAC;AAE3E,4BAA4B;AAC5B,wBAAgB,OAAO,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAEzD;AAED,8CAA8C;AAC9C,wBAAgB,QAAQ,CAAC,IAAI,EAAE,mBAAmB,GAAG,mBAAmB,EAAE,CAEzE;AAED,0EAA0E;AAC1E,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,mBAAmB,GAAG,mBAAmB,EAAE,CAIvF;AAID;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAwBvE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAQvE;AAED,UAAU,UAAU;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAID,uFAAuF;AACvF,wBAAgB,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,UAAU,GAAG,SAAS,CAqC5E;AAYD,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAuBnE;AAcD;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAkBvD;AAED,iCAAiC;AACjC,wBAAgB,cAAc,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,GAAG,SAAS,CAE7E"}
@@ -0,0 +1,11 @@
1
+ import type { CdpTransport } from "../types";
2
+ import type { EnhancedDOMTreeNode } from "./types";
3
+ export declare class ElementOverlay {
4
+ private readonly transport;
5
+ constructor(transport: CdpTransport);
6
+ /** Draw (or move) the overlay onto `node`. No-op if its bounds are unknown. */
7
+ show(node: EnhancedDOMTreeNode, sessionId: string | undefined, signal: AbortSignal | undefined): Promise<void>;
8
+ /** Remove the overlay if present. Always safe to call, even if never shown. */
9
+ clear(sessionId: string | undefined, signal: AbortSignal | undefined): Promise<void>;
10
+ }
11
+ //# sourceMappingURL=overlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/dom/overlay.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,KAAK,EAAW,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAI5D,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,YAAY;IAEpD,+EAA+E;IACzE,IAAI,CACR,IAAI,EAAE,mBAAmB,EACzB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,OAAO,CAAC,IAAI,CAAC;IAchB,+EAA+E;IACzE,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CAc3F"}
@@ -0,0 +1,25 @@
1
+ import type { SimplifiedNode } from "./types";
2
+ /** Closed axis-aligned rectangle: (x1,y1) bottom-left, (x2,y2) top-right. */
3
+ interface Rect {
4
+ x1: number;
5
+ y1: number;
6
+ x2: number;
7
+ y2: number;
8
+ }
9
+ /**
10
+ * A disjoint set of rectangles. `MAX_RECTS` caps fragmentation on pages with
11
+ * many translucent overlapping layers; once hit, `contains` conservatively
12
+ * returns false (less filtering, never wrong removal).
13
+ */
14
+ export declare class RectUnion {
15
+ private static readonly MAX_RECTS;
16
+ private readonly rects;
17
+ /** True iff `r` is fully covered by the union. */
18
+ contains(r: Rect): boolean;
19
+ /** Insert `r` unless already covered, keeping the set disjoint. */
20
+ add(r: Rect): void;
21
+ }
22
+ /** Mark occluded nodes across the tree. Mutates `ignoredByPaintOrder`. */
23
+ export declare function calculatePaintOrder(root: SimplifiedNode): void;
24
+ export {};
25
+ //# sourceMappingURL=paint-order.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paint-order.d.ts","sourceRoot":"","sources":["../../src/dom/paint-order.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAW,cAAc,EAAE,MAAM,SAAS,CAAC;AAEvD,6EAA6E;AAC7E,UAAU,IAAI;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ;AAoBD;;;;GAIG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAQ;IACzC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAc;IAEpC,kDAAkD;IAClD,QAAQ,CAAC,CAAC,EAAE,IAAI,GAAG,OAAO;IAgB1B,mEAAmE;IACnE,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI;CAcnB;AAmBD,0EAA0E;AAC1E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CA2C9D"}
@@ -0,0 +1,16 @@
1
+ import { type EnhancedDOMTreeNode, type SimplifiedNode } from "./types";
2
+ /** Cap a display value, appending "..." when truncated. */
3
+ export declare function capTextLength(text: string, maxLength: number): string;
4
+ /**
5
+ * Build the attribute string for one element. Applies date/time hints, password
6
+ * safety, AX-property merge, current-value overwrite, duplicate/redundancy
7
+ * pruning, and per-value truncation (cap 100). Faithful to design/04a §4.28.
8
+ */
9
+ export declare function buildAttributesString(node: EnhancedDOMTreeNode, includeAttributes: readonly string[], text: string): string;
10
+ /**
11
+ * Render the optimized SimplifiedNode tree to the tab-indented LLM string. The
12
+ * interactive `[backendNodeId]` marker, `*` new-prefix, shadow/scroll/iframe
13
+ * prefixes, and hidden-content hints all follow design/04a §4.28.
14
+ */
15
+ export declare function serializeTree(node: SimplifiedNode | undefined, includeAttributes: readonly string[], depth?: number): string;
16
+ //# sourceMappingURL=serialize-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialize-text.d.ts","sourceRoot":"","sources":["../../src/dom/serialize-text.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,KAAK,mBAAmB,EAExB,KAAK,cAAc,EACpB,MAAM,SAAS,CAAC;AAEjB,2DAA2D;AAC3D,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAErE;AAsCD;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,mBAAmB,EACzB,iBAAiB,EAAE,SAAS,MAAM,EAAE,EACpC,IAAI,EAAE,MAAM,GACX,MAAM,CAgJR;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,cAAc,GAAG,SAAS,EAChC,iBAAiB,EAAE,SAAS,MAAM,EAAE,EACpC,KAAK,SAAI,GACR,MAAM,CA2HR"}
@@ -0,0 +1,33 @@
1
+ import { type DomSelectorMap, type EnhancedDOMTreeNode, type SerializedDOMState } from "./types";
2
+ export interface SerializerOptions {
3
+ previousSelectorMap?: DomSelectorMap;
4
+ enableBboxFiltering?: boolean;
5
+ containmentThreshold?: number;
6
+ paintOrderFiltering?: boolean;
7
+ /** Session id for the session-scoped exclude attribute variant. */
8
+ sessionId?: string;
9
+ }
10
+ export declare class DomSerializer {
11
+ private readonly root;
12
+ private readonly selectorMap;
13
+ private readonly clickableCache;
14
+ private readonly previousBackendIds;
15
+ private readonly enableBboxFiltering;
16
+ private readonly containmentThreshold;
17
+ private readonly paintOrderFiltering;
18
+ private readonly sessionId?;
19
+ constructor(root: EnhancedDOMTreeNode, opts?: SerializerOptions);
20
+ /** Run all five stages and return the serialized state (root + selector map). */
21
+ serialize(): SerializedDOMState;
22
+ private isInteractiveCached;
23
+ private createSimplifiedTree;
24
+ private optimizeTree;
25
+ private filterTreeRecursive;
26
+ private shouldExcludeChild;
27
+ private isContained;
28
+ private isPropagatingElement;
29
+ private assignInteractiveIndices;
30
+ private hasInteractiveDescendants;
31
+ private isInsideShadowDom;
32
+ }
33
+ //# sourceMappingURL=serializer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../../src/dom/serializer.ts"],"names":[],"mappings":"AAaA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,mBAAmB,EAGxB,KAAK,kBAAkB,EAExB,MAAM,SAAS,CAAC;AAiBjB,MAAM,WAAW,iBAAiB;IAChC,mBAAmB,CAAC,EAAE,cAAc,CAAC;IACrC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAwBD,qBAAa,aAAa;IAYtB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAXvB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA6B;IAGzD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAqC;IACpE,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAc;IACjD,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAU;IAC9C,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAS;IAC9C,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAU;IAC9C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAS;gBAGjB,IAAI,EAAE,mBAAmB,EAC1C,IAAI,GAAE,iBAAsB;IAa9B,iFAAiF;IACjF,SAAS,IAAI,kBAAkB;IAa/B,OAAO,CAAC,mBAAmB;IAU3B,OAAO,CAAC,oBAAoB;IAgF5B,OAAO,CAAC,YAAY;IAuBpB,OAAO,CAAC,mBAAmB;IAyB3B,OAAO,CAAC,kBAAkB;IAwB1B,OAAO,CAAC,WAAW;IAcnB,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,wBAAwB;IAmDhC,OAAO,CAAC,yBAAyB;IAQjC,OAAO,CAAC,iBAAiB;CAQ1B"}
@@ -0,0 +1,37 @@
1
+ import type { Protocol } from "devtools-protocol";
2
+ import type { CdpTransport } from "../types";
3
+ import type { TargetId } from "../types";
4
+ import type { EnhancedSnapshotNode, TargetAllTrees } from "./types";
5
+ /** Options for a live capture. */
6
+ export interface CaptureOptions {
7
+ sessionId?: string;
8
+ jsClickListenerBackendIds?: Set<number>;
9
+ /** Caller abort, threaded into every CDP send (composes with per-request timeout). */
10
+ signal?: AbortSignal;
11
+ }
12
+ /**
13
+ * Run the CDP capture for one target and bundle the four data sources. Used by
14
+ * the live path; the integration tier and unit tests build {@link TargetAllTrees}
15
+ * directly and hand it to the pure serializer.
16
+ */
17
+ export declare function captureAllTrees(transport: CdpTransport, targetId: TargetId, opts?: CaptureOptions): Promise<TargetAllTrees>;
18
+ /**
19
+ * device_pixel_ratio = visualViewport.clientWidth / cssVisualViewport.clientWidth.
20
+ * CSS px is what JS/layout sees; using device px caused HiDPI coordinate
21
+ * mismatches. Falls back to 1.0.
22
+ */
23
+ export declare function getViewportRatio(transport: CdpTransport, sessionId?: string, signal?: AbortSignal): Promise<number>;
24
+ export interface SnapshotLookupOptions {
25
+ /** Max frame documents to process; the rest are truncated. Default 100. */
26
+ maxIframes?: number;
27
+ /** Warning sink; defaults to `console.warn` (matches NavigationPolicy's seam). */
28
+ warn?: (message: string) => void;
29
+ }
30
+ /**
31
+ * Decode the flat CDP snapshot into `backendNodeId → EnhancedSnapshotNode`. One
32
+ * entry per node; layout data attached where the node has a layout box. FIRST
33
+ * layout occurrence wins for duplicate node indices. Frame documents beyond
34
+ * `maxIframes` are truncated with a warning (design/04a §4.24 explosion guard).
35
+ */
36
+ export declare function buildSnapshotLookup(snapshot: Protocol.DOMSnapshot.CaptureSnapshotResponse, devicePixelRatio?: number, opts?: SnapshotLookupOptions): Map<number, EnhancedSnapshotNode>;
37
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/dom/snapshot.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,KAAK,EAAW,oBAAoB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE7E,kCAAkC;AAClC,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yBAAyB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACxC,sFAAsF;IACtF,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,YAAY,EACvB,QAAQ,EAAE,QAAQ,EAClB,IAAI,GAAE,cAAmB,GACxB,OAAO,CAAC,cAAc,CAAC,CA8BzB;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,YAAY,EACvB,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAkCD,MAAM,WAAW,qBAAqB;IACpC,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kFAAkF;IAClF,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAAC,uBAAuB,EACtD,gBAAgB,SAAM,EACtB,IAAI,GAAE,qBAA0B,GAC/B,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAyDnC"}
@@ -0,0 +1,178 @@
1
+ import type { BackendNodeId, TargetId } from "../types";
2
+ /** DOM node types, per the DOM spec. Shadow roots present as DocumentFragment. */
3
+ export declare enum NodeType {
4
+ Element = 1,
5
+ Attribute = 2,
6
+ Text = 3,
7
+ CDataSection = 4,
8
+ ProcessingInstruction = 7,
9
+ Comment = 8,
10
+ Document = 9,
11
+ DocumentType = 10,
12
+ DocumentFragment = 11
13
+ }
14
+ /** CDP shadow-root kind. */
15
+ export type ShadowRootType = "open" | "closed" | "user-agent";
16
+ /** A plain rectangle, in CSS pixels unless noted. */
17
+ export interface DOMRect {
18
+ x: number;
19
+ y: number;
20
+ width: number;
21
+ height: number;
22
+ }
23
+ /** One accessibility property (CDP AXPropertyName → value). */
24
+ export interface EnhancedAXProperty {
25
+ name: string;
26
+ value: string | boolean | null;
27
+ }
28
+ /** Condensed accessibility node. `name` is the accessible name. */
29
+ export interface EnhancedAXNode {
30
+ axNodeId: string;
31
+ ignored: boolean;
32
+ role?: string;
33
+ name?: string;
34
+ description?: string;
35
+ properties?: EnhancedAXProperty[];
36
+ childIds?: string[];
37
+ }
38
+ /** Layout/snapshot data for one node, decoded from DOMSnapshot. */
39
+ export interface EnhancedSnapshotNode {
40
+ isClickable?: boolean;
41
+ cursorStyle?: string;
42
+ /** Document coordinates (ignores scroll), already device→CSS px. */
43
+ bounds?: DOMRect;
44
+ /** Viewport coordinates (scroll-aware). NOT divided by device pixel ratio. */
45
+ clientRects?: DOMRect;
46
+ /** Scrollable area of the element. NOT divided by device pixel ratio. */
47
+ scrollRects?: DOMRect;
48
+ computedStyles?: Record<string, string>;
49
+ paintOrder?: number;
50
+ stackingContexts?: number;
51
+ }
52
+ /** A synthetic sub-component of a compound control (date picker, select, …). */
53
+ export interface CompoundChild {
54
+ role: string;
55
+ name: string;
56
+ valuemin: number | null;
57
+ valuemax: number | null;
58
+ valuenow: number | string | null;
59
+ optionsCount?: number;
60
+ firstOptions?: string[];
61
+ formatHint?: string;
62
+ }
63
+ /**
64
+ * The central merged node: DOM identity + AX enrichment + snapshot layout,
65
+ * wired into a tree with a `parentNode` back-pointer (excluded from any JSON).
66
+ */
67
+ export interface EnhancedDOMTreeNode {
68
+ nodeId: number;
69
+ backendNodeId: BackendNodeId;
70
+ nodeType: NodeType;
71
+ /** Tag name for elements (as CDP returns it, usually upper-case). */
72
+ nodeName: string;
73
+ /** Text content for text nodes. */
74
+ nodeValue: string;
75
+ attributes: Record<string, string>;
76
+ isScrollable?: boolean;
77
+ /** Computed visibility per the top-most frame. Filled during tree build. */
78
+ isVisible?: boolean;
79
+ /** Position in top-level page coordinates. */
80
+ absolutePosition?: DOMRect;
81
+ targetId: TargetId;
82
+ frameId?: string;
83
+ sessionId?: string;
84
+ contentDocument?: EnhancedDOMTreeNode;
85
+ shadowRootType?: ShadowRootType;
86
+ shadowRoots?: EnhancedDOMTreeNode[];
87
+ parentNode?: EnhancedDOMTreeNode;
88
+ childrenNodes?: EnhancedDOMTreeNode[];
89
+ axNode?: EnhancedAXNode;
90
+ snapshotNode?: EnhancedSnapshotNode;
91
+ /** Virtual components of compound controls (mutated by the serializer). */
92
+ compoundChildren: CompoundChild[];
93
+ hasJsClickListener: boolean;
94
+ /** Interactive elements in an iframe below the viewport threshold. */
95
+ hiddenElementsInfo: Array<{
96
+ tag: string;
97
+ text: string;
98
+ pages: number;
99
+ }>;
100
+ hasHiddenContent: boolean;
101
+ }
102
+ /** The serializer's lightweight working wrapper around an EnhancedDOMTreeNode. */
103
+ export interface SimplifiedNode {
104
+ originalNode: EnhancedDOMTreeNode;
105
+ children: SimplifiedNode[];
106
+ /** Dormant hook; never set false today (design/10 gap §4.34 OQ#3). */
107
+ shouldDisplay: boolean;
108
+ /** True iff the element made it into the selector map. */
109
+ isInteractive: boolean;
110
+ isNew: boolean;
111
+ ignoredByPaintOrder: boolean;
112
+ excludedByParent: boolean;
113
+ isShadowHost: boolean;
114
+ isCompoundComponent: boolean;
115
+ }
116
+ /** Bounds a link/button propagates down to suppress nested interactivity. */
117
+ export interface PropagatingBounds {
118
+ tag: string;
119
+ bounds: DOMRect;
120
+ nodeId: number;
121
+ depth: number;
122
+ }
123
+ /**
124
+ * The interactive-element map. Keyed by CDP **backendNodeId** — the same integer
125
+ * the LLM sees as `[N]`, that `getElementByIndex(N)` resolves, and that pagination
126
+ * / highlight labels use (design/10 gap #1). There is NO sequential renumbering.
127
+ */
128
+ export type DomSelectorMap = Map<BackendNodeId, EnhancedDOMTreeNode>;
129
+ /** The serialized page state: the working tree root + the selector map. */
130
+ export interface SerializedDOMState {
131
+ root: SimplifiedNode | undefined;
132
+ selectorMap: DomSelectorMap;
133
+ }
134
+ /** Element-matching strictness ladder for history replay (design/05). */
135
+ export declare enum MatchLevel {
136
+ Exact = 1,
137
+ Stable = 2,
138
+ Xpath = 3,
139
+ AxName = 4,
140
+ Attribute = 5,
141
+ /** Last-resort: tag-only parent-branch path (W13c). Coarsest level — declines
142
+ * rather than guesses when more than one fresh candidate shares the path. */
143
+ Structural = 6
144
+ }
145
+ /** A persisted record of a clicked/typed element, for history replay. */
146
+ export interface DOMInteractedElement {
147
+ nodeId: number;
148
+ backendNodeId: BackendNodeId;
149
+ frameId?: string;
150
+ nodeType: NodeType;
151
+ nodeValue: string;
152
+ nodeName: string;
153
+ attributes: Record<string, string>;
154
+ bounds?: DOMRect;
155
+ xpath: string;
156
+ /** Exact hash (MatchLevel.Exact). */
157
+ elementHash: string;
158
+ /** Dynamic-class-filtered hash (MatchLevel.Stable). */
159
+ stableHash: string;
160
+ axName?: string;
161
+ /** Structural tag-chain hash (MatchLevel.Structural). Optional: absent on
162
+ * history files recorded before W13c — those simply can't fall back to it. */
163
+ parentBranchHash?: string;
164
+ }
165
+ /**
166
+ * The four raw captures for one target/frame, merged by the tree builder. This
167
+ * is the seam the browser-gated integration tier feeds real Chromium captures
168
+ * into (via `serializeFromSnapshot`).
169
+ */
170
+ export interface TargetAllTrees {
171
+ snapshot: import("devtools-protocol").Protocol.DOMSnapshot.CaptureSnapshotResponse;
172
+ domTree: import("devtools-protocol").Protocol.DOM.GetDocumentResponse;
173
+ axTree: import("devtools-protocol").Protocol.Accessibility.GetFullAXTreeResponse;
174
+ devicePixelRatio: number;
175
+ /** backendNodeIds carrying JS click/mouse listeners (CDP getEventListeners). */
176
+ jsClickListenerBackendIds?: Set<number>;
177
+ }
178
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/dom/types.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAExD,kFAAkF;AAClF,oBAAY,QAAQ;IAClB,OAAO,IAAI;IACX,SAAS,IAAI;IACb,IAAI,IAAI;IACR,YAAY,IAAI;IAChB,qBAAqB,IAAI;IACzB,OAAO,IAAI;IACX,QAAQ,IAAI;IACZ,YAAY,KAAK;IACjB,gBAAgB,KAAK;CACtB;AAED,4BAA4B;AAC5B,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,QAAQ,GAAG,YAAY,CAAC;AAE9D,qDAAqD;AACrD,MAAM,WAAW,OAAO;IACtB,CAAC,EAAE,MAAM,CAAC;IACV,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,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;kFAC8E;IAC9E,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,OAAO,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAAC,uBAAuB,CAAC;IACnF,OAAO,EAAE,OAAO,mBAAmB,EAAE,QAAQ,CAAC,GAAG,CAAC,mBAAmB,CAAC;IACtE,MAAM,EAAE,OAAO,mBAAmB,EAAE,QAAQ,CAAC,aAAa,CAAC,qBAAqB,CAAC;IACjF,gBAAgB,EAAE,MAAM,CAAC;IACzB,gFAAgF;IAChF,yBAAyB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACzC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Reduce a page-controlled download name to a safe basename. Never returns a name
3
+ * with a path separator; a name that is pure traversal (or empty) becomes
4
+ * `"download"`. Unicode and leading-dot names are preserved.
5
+ */
6
+ export declare function sanitizeDownloadFilename(name: string | undefined | null): string;
7
+ /**
8
+ * True iff `candidate` resolves to `directory` itself or something beneath it,
9
+ * comparing REAL (symlink-resolved) paths. Either path failing to resolve (e.g.
10
+ * it does not exist) yields `false` — fail closed.
11
+ */
12
+ export declare function isPathContained(candidate: string, directory: string): Promise<boolean>;
13
+ //# sourceMappingURL=sanitize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/downloads/sanitize.ts"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAQhF;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAU5F"}
@@ -0,0 +1,88 @@
1
+ import type { ClickResult } from "./input/dispatcher";
2
+ import type { NavigateResult } from "./navigation/navigator";
3
+ import type { BrowserSession } from "./session";
4
+ import type { BrowserStateSummary, ElementIndex, TabId, TabInfo } from "./types";
5
+ /** A click target: an element index (the `[N]`) or a raw viewport point. */
6
+ export type ClickTarget = ElementIndex | number | {
7
+ x: number;
8
+ y: number;
9
+ };
10
+ /** A scroll request: a direction (one page) or a signed pixel amount. */
11
+ export type ScrollTarget = "up" | "down" | number;
12
+ export interface GetStateOptions {
13
+ /** Include a base64 screenshot in the returned state. */
14
+ screenshot?: boolean;
15
+ /** Caller abort, threaded down to the CDP layer (§6.8). */
16
+ signal?: AbortSignal;
17
+ }
18
+ export interface TypeOptions {
19
+ /** Clear the field before typing (default true — matches the MCP `type` tool). */
20
+ clear?: boolean;
21
+ /** Value being typed is a secret — suppress read-back so it never round-trips out. */
22
+ sensitive?: boolean;
23
+ /** Caller abort, threaded down to the CDP layer (§6.8). */
24
+ signal?: AbortSignal;
25
+ }
26
+ export interface ScreenshotOptions {
27
+ /** Capture the full scrollable page rather than just the viewport. */
28
+ fullPage?: boolean;
29
+ /** Caller abort, threaded down to the CDP layer (§6.8). */
30
+ signal?: AbortSignal;
31
+ }
32
+ /** Options carrying only a caller abort (navigate / click / scroll / extract). */
33
+ export interface SignalOptions {
34
+ signal?: AbortSignal;
35
+ }
36
+ /** ponytail: one page ≈ 720px until we thread the live viewport height through. */
37
+ export declare const PAGE_SCROLL_PX = 720;
38
+ export declare class BrowserDriver {
39
+ private readonly session;
40
+ constructor(session: BrowserSession);
41
+ /**
42
+ * Read the current page state: url, title, tabs, the serialized numbered
43
+ * element text the LLM reads, and the selector map keyed by backendNodeId.
44
+ * The returned indices are exactly what {@link click} / {@link type} accept.
45
+ */
46
+ getState(options?: GetStateOptions): Promise<BrowserStateSummary>;
47
+ /**
48
+ * Click an element by its index (the `[N]` from the last {@link getState}) or a
49
+ * raw viewport point. A missing index throws {@link ElementNotFoundError} —
50
+ * re-read the page to re-index before retrying.
51
+ */
52
+ click(target: ClickTarget, options?: SignalOptions): Promise<ClickResult>;
53
+ /**
54
+ * Type text into an element by its index. `clear` (default true) wipes the
55
+ * field first; pass `clear: false` to append. A missing index throws
56
+ * {@link ElementNotFoundError}.
57
+ */
58
+ type(index: ElementIndex | number, text: string, options?: TypeOptions): Promise<void>;
59
+ /** Capture a base64 screenshot of the focused tab. */
60
+ screenshot(options?: ScreenshotOptions): Promise<string>;
61
+ /** Navigate the focused tab (policy-checked before any CDP navigate — A3). */
62
+ navigate(url: string, options?: SignalOptions): Promise<NavigateResult>;
63
+ /** Scroll the page one page in a direction, or by a signed pixel amount. */
64
+ scroll(target: ScrollTarget, options?: SignalOptions): Promise<void>;
65
+ /** The open tabs (4-char ids). */
66
+ tabs(): TabInfo[];
67
+ /** Focus another tab by its 4-char id. */
68
+ switchTab(id: TabId | string): Promise<void>;
69
+ /** Close a tab by its 4-char id (a stale id is a no-op, not an error). */
70
+ closeTab(id: TabId | string): Promise<void>;
71
+ /**
72
+ * Return the page's readable text (the serialized numbered element map). LLM-
73
+ * backed structured extraction lives in the agent/tools layer (M4/M5); here
74
+ * `query` is accepted for signature stability but not yet applied.
75
+ */
76
+ extract(_query?: string, options?: SignalOptions): Promise<string>;
77
+ /**
78
+ * Demo-mode: draw a short-lived highlight around the element at `index` (the
79
+ * one about to be acted on). Fire-and-forget — never throws; a stale index
80
+ * or an inject failure just means no highlight is shown, not a driver error.
81
+ */
82
+ highlightElement(index: number, options?: SignalOptions): Promise<void>;
83
+ /** Remove the demo-mode highlight, if one is showing. Always safe to call. */
84
+ clearHighlight(options?: SignalOptions): Promise<void>;
85
+ /** Resolve an index to its node, or throw the re-index error. */
86
+ private resolve;
87
+ }
88
+ //# sourceMappingURL=driver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAo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,WAAW,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IAOnF;;;;OAIG;IACG,IAAI,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQhG,sDAAsD;IACtD,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC;IAU5D,8EAA8E;IAC9E,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;IAI3E,4EAA4E;IAC5E,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMxE,kCAAkC;IAClC,IAAI,IAAI,OAAO,EAAE;IAIjB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM5C,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3C;;;;OAIG;IACG,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IAK5E;;;;OAIG;IACG,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAUjF,8EAA8E;IACxE,cAAc,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAOhE,iEAAiE;IACjE,OAAO,CAAC,OAAO;CAKhB"}
@@ -0,0 +1,71 @@
1
+ /** Base for every `@ap3x/browser` error. Stable `code` + structured `data`. */
2
+ export declare abstract class BrowserError<TCode extends string = string> extends Error {
3
+ readonly code: TCode;
4
+ readonly data?: Readonly<Record<string, unknown>>;
5
+ readonly cause?: unknown;
6
+ constructor(code: TCode, message: string, options?: {
7
+ data?: Record<string, unknown>;
8
+ cause?: unknown;
9
+ });
10
+ }
11
+ /** Why a CDP connection failed. */
12
+ export type CdpConnectionErrorCode = "closed" | "timeout" | "aborted" | "protocol" | "connect_failed" | "reconnect_failed";
13
+ /**
14
+ * A CDP transport failure. Notably: closing the socket rejects every pending
15
+ * request with `code: "closed"` — that rejection is the reconnect trigger.
16
+ */
17
+ export declare class CdpConnectionError extends BrowserError<CdpConnectionErrorCode> {
18
+ }
19
+ /** Why a URL was refused by {@link NavigationPolicy}. */
20
+ export type UrlNotAllowedReason = "not_in_allowed_domains" | "in_prohibited_domains" | "ip_blocked" | "invalid_url";
21
+ /** Navigation to a URL was blocked by policy (A3 — thrown before CDP navigate). */
22
+ export declare class UrlNotAllowedError extends BrowserError<"url_not_allowed"> {
23
+ readonly url: string;
24
+ readonly reason: UrlNotAllowedReason;
25
+ constructor(url: string, reason: UrlNotAllowedReason, message?: string);
26
+ }
27
+ /** Classifies a {@link NavigationError}. */
28
+ export type NavigationErrorCode = "no_focus" | "timeout" | "failed";
29
+ /** A navigation could not be issued or the page failed to load. */
30
+ export declare class NavigationError extends BrowserError<NavigationErrorCode> {
31
+ readonly url?: string;
32
+ constructor(code: NavigationErrorCode, message: string, options?: {
33
+ url?: string;
34
+ data?: Record<string, unknown>;
35
+ cause?: unknown;
36
+ });
37
+ }
38
+ /**
39
+ * An indexed element the caller asked to interact with is not in the current
40
+ * page map. The selector map is rebuilt on every state read, so a missing index
41
+ * almost always means the page changed since it was read. The message names the
42
+ * fix on purpose — a consumer (or an LLM reading it back) must re-read the page
43
+ * to re-index before retrying. (design/07 §stale-element contract.)
44
+ */
45
+ export declare class ElementNotFoundError extends BrowserError<"element_not_found"> {
46
+ readonly index: number;
47
+ constructor(index: number, message?: string);
48
+ }
49
+ /**
50
+ * A low-level interaction (click/type/scroll/select/upload) could not be
51
+ * carried out, or the target element rejects the requested action (e.g. clicking
52
+ * a `<select>` — see {@link SELECT_ELEMENT_CLICK_MESSAGE}). `reason` classifies it.
53
+ */
54
+ export type InteractionReason = "select_element" | "file_input" | "no_geometry" | "not_a_file_input" | "text_not_found" | "dispatch_failed";
55
+ export declare class InteractionError extends BrowserError<"interaction_failed"> {
56
+ readonly reason: InteractionReason;
57
+ constructor(reason: InteractionReason, message: string, options?: {
58
+ data?: Record<string, unknown>;
59
+ cause?: unknown;
60
+ });
61
+ }
62
+ /**
63
+ * [EXACT-TEXT] Clicking a native `<select>` is redirected to the dropdown tool.
64
+ * The leading sentence `Cannot click on <select> elements.` is a string-match
65
+ * contract (design/07 §7.9): callers match on it to auto-attach the dropdown
66
+ * options, so the sentence must not be reworded.
67
+ */
68
+ export declare const SELECT_ELEMENT_CLICK_MESSAGE = "Cannot click on <select> elements. Use the dropdown-options / select-dropdown action instead.";
69
+ /** File inputs must not be clicked — they need the file-upload path. */
70
+ export declare const FILE_INPUT_CLICK_MESSAGE = "Cannot click on a file input. Use the upload-file action to set its file instead.";
71
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAIA,+EAA+E;AAC/E,8BAAsB,YAAY,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,KAAK;IAC7E,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAClD,SAAkB,KAAK,CAAC,EAAE,OAAO,CAAC;gBAGhC,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAQhE;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a,GACb,kBAAkB,GAClB,gBAAgB,GAChB,iBAAiB,CAAC;AAEtB,qBAAa,gBAAiB,SAAQ,YAAY,CAAC,oBAAoB,CAAC;IACtE,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;gBAGjC,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAQhE;AAED;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,kGACwD,CAAC;AAElG,wEAAwE;AACxE,eAAO,MAAM,wBAAwB,sFACgD,CAAC"}
@@ -0,0 +1,8 @@
1
+ /** Minimal typed pub/sub. Listener errors are isolated so one bad handler
2
+ * cannot break delivery to the others. `T` maps event name → payload type. */
3
+ export declare class TypedEmitter<T> {
4
+ private readonly listeners;
5
+ on<K extends keyof T>(event: K, listener: (payload: T[K]) => void): () => void;
6
+ emit<K extends keyof T>(event: K, payload: T[K]): void;
7
+ }
8
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAGA;8EAC8E;AAC9E,qBAAa,YAAY,CAAC,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0D;IAEpF,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI;IAY9E,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;CAWvD"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @ap3x/browser — CDP browser control primitives.
3
+ *
4
+ * Foundation for driving a Chromium browser over the Chrome DevTools Protocol:
5
+ * the typed CDP transport, target registry, navigation policy, navigator, local
6
+ * browser launch/connect, DOM extraction + serialization, input dispatch,
7
+ * screenshots, dialogs, downloads, and recording. The agent that drives these
8
+ * lives in `@ap3x/browser-agent`.
9
+ *
10
+ * **Entry point:** hosts should obtain a session via `openBrowserSession(config)`
11
+ * (see `providers/factory.ts`) rather than calling `BrowserSession.launch`/
12
+ * `connect` directly — it honours `config.provider` ('local' spawn-or-connect via
13
+ * `AP3X_BROWSER_CDP_URL`, or 'cloak' for a stealth CloakBrowser/cloakserve
14
+ * endpoint via `AP3X_BROWSER_CLOAK_*`), so the same call works across providers.
15
+ * `BrowserSession.launch`/`connect` remain the low-level primitives it's built on.
16
+ */
17
+ export declare const PACKAGE = "@ap3x/browser";
18
+ export declare const VERSION = "0.1.0";
19
+ export * from "./types";
20
+ export * from "./errors";
21
+ export * from "./events";
22
+ export * from "./cdp/connection";
23
+ export * from "./cdp/endpoint";
24
+ export * from "./cdp/reconnect";
25
+ export * from "./targets/registry";
26
+ export * from "./navigation/policy";
27
+ export * from "./navigation/navigator";
28
+ export * from "./launch/discovery";
29
+ export * from "./launch/local-browser";
30
+ export * from "./dom/types";
31
+ export * from "./dom/constants";
32
+ export * from "./dom/node";
33
+ export * from "./dom/hashing";
34
+ export * from "./dom/clickability";
35
+ export * from "./dom/paint-order";
36
+ export * from "./dom/snapshot";
37
+ export * from "./dom/enhanced-tree";
38
+ export * from "./dom/compound";
39
+ export * from "./dom/serialize-text";
40
+ export * from "./dom/serializer";
41
+ export * from "./dom/dom-service";
42
+ export * from "./dom/overlay";
43
+ export * from "./input/keys";
44
+ export * from "./input/dispatcher";
45
+ export * from "./dialogs/handler";
46
+ export * from "./downloads/sanitize";
47
+ export * from "./screenshot/service";
48
+ export * from "./recording/har";
49
+ export * from "./recording/screencast";
50
+ export * from "./config";
51
+ export * from "./session";
52
+ export * from "./driver";
53
+ export * from "./providers";
54
+ export * from "./testing";
55
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,OAAO,kBAAkB,CAAC;AACvC,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAE9B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AAIrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}