@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.
- package/LICENSE +21 -0
- package/README.md +30 -0
- package/dist/cdp/connection.d.ts +53 -0
- package/dist/cdp/connection.d.ts.map +1 -0
- package/dist/cdp/endpoint.d.ts +18 -0
- package/dist/cdp/endpoint.d.ts.map +1 -0
- package/dist/cdp/reconnect.d.ts +22 -0
- package/dist/cdp/reconnect.d.ts.map +1 -0
- package/dist/chunk-DXCP25KX.js +77 -0
- package/dist/config.d.ts +91 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/dialogs/handler.d.ts +43 -0
- package/dist/dialogs/handler.d.ts.map +1 -0
- package/dist/dom/clickability.d.ts +4 -0
- package/dist/dom/clickability.d.ts.map +1 -0
- package/dist/dom/compound.d.ts +4 -0
- package/dist/dom/compound.d.ts.map +1 -0
- package/dist/dom/constants.d.ts +28 -0
- package/dist/dom/constants.d.ts.map +1 -0
- package/dist/dom/dom-service.d.ts +65 -0
- package/dist/dom/dom-service.d.ts.map +1 -0
- package/dist/dom/enhanced-tree.d.ts +52 -0
- package/dist/dom/enhanced-tree.d.ts.map +1 -0
- package/dist/dom/hashing.d.ts +21 -0
- package/dist/dom/hashing.d.ts.map +1 -0
- package/dist/dom/node.d.ts +43 -0
- package/dist/dom/node.d.ts.map +1 -0
- package/dist/dom/overlay.d.ts +11 -0
- package/dist/dom/overlay.d.ts.map +1 -0
- package/dist/dom/paint-order.d.ts +25 -0
- package/dist/dom/paint-order.d.ts.map +1 -0
- package/dist/dom/serialize-text.d.ts +16 -0
- package/dist/dom/serialize-text.d.ts.map +1 -0
- package/dist/dom/serializer.d.ts +33 -0
- package/dist/dom/serializer.d.ts.map +1 -0
- package/dist/dom/snapshot.d.ts +37 -0
- package/dist/dom/snapshot.d.ts.map +1 -0
- package/dist/dom/types.d.ts +178 -0
- package/dist/dom/types.d.ts.map +1 -0
- package/dist/downloads/sanitize.d.ts +13 -0
- package/dist/downloads/sanitize.d.ts.map +1 -0
- package/dist/driver.d.ts +88 -0
- package/dist/driver.d.ts.map +1 -0
- package/dist/errors.d.ts +71 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/events.d.ts +8 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5066 -0
- package/dist/input/dispatcher.d.ts +196 -0
- package/dist/input/dispatcher.d.ts.map +1 -0
- package/dist/input/keys.d.ts +20 -0
- package/dist/input/keys.d.ts.map +1 -0
- package/dist/launch/discovery.d.ts +14 -0
- package/dist/launch/discovery.d.ts.map +1 -0
- package/dist/launch/local-browser.d.ts +59 -0
- package/dist/launch/local-browser.d.ts.map +1 -0
- package/dist/navigation/navigator.d.ts +37 -0
- package/dist/navigation/navigator.d.ts.map +1 -0
- package/dist/navigation/policy.d.ts +61 -0
- package/dist/navigation/policy.d.ts.map +1 -0
- package/dist/providers/cloak.d.ts +26 -0
- package/dist/providers/cloak.d.ts.map +1 -0
- package/dist/providers/factory.d.ts +17 -0
- package/dist/providers/factory.d.ts.map +1 -0
- package/dist/providers/index.d.ts +5 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/local.d.ts +13 -0
- package/dist/providers/local.d.ts.map +1 -0
- package/dist/providers/types.d.ts +8 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/recording/har.d.ts +94 -0
- package/dist/recording/har.d.ts.map +1 -0
- package/dist/recording/screencast.d.ts +40 -0
- package/dist/recording/screencast.d.ts.map +1 -0
- package/dist/screenshot/service.d.ts +34 -0
- package/dist/screenshot/service.d.ts.map +1 -0
- package/dist/session.d.ts +130 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/targets/registry.d.ts +99 -0
- package/dist/targets/registry.d.ts.map +1 -0
- package/dist/testing.d.ts +53 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +8 -0
- package/dist/types.d.ts +88 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { EnhancedDOMTreeNode } from "../dom/types";
|
|
2
|
+
import type { CdpTransport } from "../types";
|
|
3
|
+
/** A viewport point. */
|
|
4
|
+
export interface Point {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}
|
|
8
|
+
/** Result of a click: the point clicked, and how it was delivered. */
|
|
9
|
+
export interface ClickResult {
|
|
10
|
+
clickX?: number;
|
|
11
|
+
clickY?: number;
|
|
12
|
+
/** `"cdp"` = real synthesized mouse event; `"js"` = `.click()` fallback. */
|
|
13
|
+
method: "cdp" | "js";
|
|
14
|
+
/** Present for checkbox/radio: the toggle state after the click. */
|
|
15
|
+
checked?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface DispatchTypeOptions {
|
|
18
|
+
/** Clear the field before typing (also forced when `text` is empty). */
|
|
19
|
+
clear?: boolean;
|
|
20
|
+
/** Suppress value read-back (never round-trip a secret through the page). */
|
|
21
|
+
sensitive?: boolean;
|
|
22
|
+
/** Caller abort, threaded into every CDP send this op issues (§6.8). */
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
}
|
|
25
|
+
/** Options carrying only a caller abort (click and other single-verb ops). */
|
|
26
|
+
export interface DispatchSignalOptions {
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
}
|
|
29
|
+
export interface ScrollOptions {
|
|
30
|
+
/** Positive scrolls down, negative up. */
|
|
31
|
+
amount: number;
|
|
32
|
+
/** Scroll within this element/iframe instead of the page. */
|
|
33
|
+
node?: EnhancedDOMTreeNode;
|
|
34
|
+
/** Caller abort, threaded into every CDP send this op issues (§6.8). */
|
|
35
|
+
signal?: AbortSignal;
|
|
36
|
+
}
|
|
37
|
+
export interface InputDispatcherOptions {
|
|
38
|
+
/** Injectable delay (ms). Defaults to real `setTimeout`. */
|
|
39
|
+
sleep?: (ms: number) => Promise<void>;
|
|
40
|
+
/** Session id used when a node carries none (the focused page session). */
|
|
41
|
+
defaultSessionId?: () => string | undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Encode `text` as an XPath 1.0 string literal (C4 quote-safety). XPath 1.0 has no
|
|
45
|
+
* escape mechanism inside a literal, so: no `"` → wrap in `"…"`; else no `'` →
|
|
46
|
+
* wrap in `'…'`; else split on `"` and stitch with `concat(…, '"', …)`. The result
|
|
47
|
+
* always evaluates to exactly `text`, so no interpolated value can alter the query.
|
|
48
|
+
*/
|
|
49
|
+
export declare function xpathLiteral(text: string): string;
|
|
50
|
+
export declare class InputDispatcher {
|
|
51
|
+
private readonly transport;
|
|
52
|
+
private readonly sleep;
|
|
53
|
+
private readonly defaultSessionId?;
|
|
54
|
+
private opSignal?;
|
|
55
|
+
constructor(transport: CdpTransport, options?: InputDispatcherOptions);
|
|
56
|
+
/** Bind `signal` to every CDP send `fn` issues; restores the prior op signal. */
|
|
57
|
+
private withSignal;
|
|
58
|
+
/** The frame-correct session for a node (its own, else the focused page). */
|
|
59
|
+
private sessionFor;
|
|
60
|
+
/**
|
|
61
|
+
* Click an element. Guards non-clickables (a `<select>` or file input raises
|
|
62
|
+
* the redirect-message {@link InteractionError} — never a blind click),
|
|
63
|
+
* scrolls into view, then delivers a real CDP mouse click at the element
|
|
64
|
+
* centre when it is unoccluded, or a JS `.click()` fallback otherwise.
|
|
65
|
+
*/
|
|
66
|
+
click(node: EnhancedDOMTreeNode, options?: DispatchSignalOptions): Promise<ClickResult>;
|
|
67
|
+
private clickImpl;
|
|
68
|
+
/** Click a raw viewport point (no element geometry / occlusion checks). */
|
|
69
|
+
clickCoordinate(x: number, y: number, options?: DispatchSignalOptions): Promise<ClickResult>;
|
|
70
|
+
private clickCoordinateImpl;
|
|
71
|
+
/**
|
|
72
|
+
* Type text into an element: scroll into view, focus (CDP focus first, a
|
|
73
|
+
* click-to-focus fallback), optionally clear, then dispatch per-character key
|
|
74
|
+
* events. keyDown/keyUp carry NO `text`; only the `char` event inserts the
|
|
75
|
+
* character — this mirrors real-keyboard semantics so inputs listening on
|
|
76
|
+
* `keydown` (shortcuts) vs `input` (content) both behave. Empty `text` clears.
|
|
77
|
+
*/
|
|
78
|
+
type(node: EnhancedDOMTreeNode, text: string, options?: DispatchTypeOptions): Promise<void>;
|
|
79
|
+
private typeImpl;
|
|
80
|
+
/** Type to whatever element currently has focus (index 0 / page typing). */
|
|
81
|
+
typeToPage(text: string): Promise<void>;
|
|
82
|
+
private typeChar;
|
|
83
|
+
/**
|
|
84
|
+
* Clear the focused field with the three escalating strategies (design §4.10.8):
|
|
85
|
+
* 1. JS value/content reset (native `.value=""` or contenteditable wipe) — the
|
|
86
|
+
* cheapest and it fires input/change so frameworks notice.
|
|
87
|
+
* 2. triple-click to select-all + Delete — when the JS reset didn't take.
|
|
88
|
+
* 3. keyboard Ctrl/Cmd+A + Backspace — last resort.
|
|
89
|
+
* Each strategy is best-effort; a rung's success (verified empty for #1) stops
|
|
90
|
+
* the ladder. `objectId` is required for #1/#2; without it we fall to #3.
|
|
91
|
+
*/
|
|
92
|
+
private clearField;
|
|
93
|
+
/** Read the first typed char back; if the contenteditable dropped it, retype it. */
|
|
94
|
+
private recoverDroppedFirstChar;
|
|
95
|
+
/** Fire focus→input→change→blur so framework-controlled inputs see the value. */
|
|
96
|
+
private triggerFrameworkEvents;
|
|
97
|
+
/** The field's current value (`.value` for inputs, else `textContent`). */
|
|
98
|
+
private readFieldValue;
|
|
99
|
+
/** Force-set the value via the React/Vue-safe native setter + event chain. */
|
|
100
|
+
private setValueDirectly;
|
|
101
|
+
/**
|
|
102
|
+
* Scroll the page (via a synthesized gesture) or, when a node is given, that
|
|
103
|
+
* element/iframe container. Sign conventions differ and are preserved: wheel
|
|
104
|
+
* `deltaY` positive = down, gesture `yDistance` positive = up (so
|
|
105
|
+
* `yDistance = -amount`).
|
|
106
|
+
*/
|
|
107
|
+
scroll(options: ScrollOptions): Promise<void>;
|
|
108
|
+
private scrollImpl;
|
|
109
|
+
private scrollElement;
|
|
110
|
+
/**
|
|
111
|
+
* Find on-page text and scroll it into view. Tries CDP XPath search
|
|
112
|
+
* (text node → subtree → attributes), then a JS TreeWalker fallback; raises if
|
|
113
|
+
* still not found.
|
|
114
|
+
*
|
|
115
|
+
* `DOM.performSearch`/`DOM.getSearchResults` are NOT swallowed on failure (W5):
|
|
116
|
+
* a genuine "no match" (a completed search with `resultCount === 0`) is the
|
|
117
|
+
* ONLY thing that reaches the `text_not_found` {@link InteractionError} below —
|
|
118
|
+
* a transport/CDP failure propagates as-is, so a caller can't mistake "the
|
|
119
|
+
* search itself broke" for "the text isn't on the page". Cleanup sends
|
|
120
|
+
* (`discardSearchResults`, the post-match `scrollIntoViewIfNeeded`) stay
|
|
121
|
+
* best-effort: they run only once a real match is already known.
|
|
122
|
+
*/
|
|
123
|
+
scrollToText(text: string, options?: DispatchSignalOptions): Promise<void>;
|
|
124
|
+
private scrollToTextImpl;
|
|
125
|
+
/**
|
|
126
|
+
* Send a key or key-combination string (`"Enter"`, `"Control+a"`, or literal
|
|
127
|
+
* text). Combos press the modifiers, then the main key WITH the modifier
|
|
128
|
+
* bitmask, then release in reverse. Non-special single tokens are typed as text.
|
|
129
|
+
*/
|
|
130
|
+
sendKeys(keys: string, options?: DispatchSignalOptions): Promise<void>;
|
|
131
|
+
private sendKeysImpl;
|
|
132
|
+
private keyProps;
|
|
133
|
+
/**
|
|
134
|
+
* Select an option (by exact text or value, case-insensitive) on a native
|
|
135
|
+
* `<select>` or ARIA/custom dropdown, via a JS selection routine run against
|
|
136
|
+
* the resolved element.
|
|
137
|
+
*/
|
|
138
|
+
selectDropdownOption(node: EnhancedDOMTreeNode, text: string, options?: DispatchSignalOptions): Promise<{
|
|
139
|
+
success: boolean;
|
|
140
|
+
value?: string;
|
|
141
|
+
message?: string;
|
|
142
|
+
}>;
|
|
143
|
+
private selectDropdownOptionImpl;
|
|
144
|
+
/**
|
|
145
|
+
* List the option texts of a native `<select>`, ARIA/custom dropdown, OR an ARIA
|
|
146
|
+
* combobox whose options live in a separate `aria-controls` listbox (design
|
|
147
|
+
* §4.10.21). For a combobox we expand it (spray focus/click/mousedown, wait for
|
|
148
|
+
* lazy render), read the referenced listbox, then collapse it back to restore the
|
|
149
|
+
* page state. Everything else enumerates in place.
|
|
150
|
+
*/
|
|
151
|
+
getDropdownOptions(node: EnhancedDOMTreeNode, options?: DispatchSignalOptions): Promise<string[]>;
|
|
152
|
+
private getDropdownOptionsImpl;
|
|
153
|
+
/**
|
|
154
|
+
* Set a file on a `<input type=file>` element (DOM.setFileInputFiles).
|
|
155
|
+
*
|
|
156
|
+
* `filePath` is passed straight to the driver — this layer has no notion of a
|
|
157
|
+
* workspace and cannot contain it. The AUTHORITATIVE gate is the `upload_file`
|
|
158
|
+
* action (@ap3x/browser-agent), which only ever hands us a FileSystem-owned,
|
|
159
|
+
* realpath-contained path or an exact user-authorized entry; a raw
|
|
160
|
+
* model-controlled path must never reach here (GHSA-j9hj-92j8-jv9h).
|
|
161
|
+
*/
|
|
162
|
+
uploadFile(node: EnhancedDOMTreeNode, filePath: string, options?: DispatchSignalOptions): Promise<void>;
|
|
163
|
+
private uploadFileImpl;
|
|
164
|
+
/**
|
|
165
|
+
* Element centre in viewport (CSS-px) coordinates, from a LIVE query only —
|
|
166
|
+
* a CDP box model, else a live `getBoundingClientRect`. Both are viewport-
|
|
167
|
+
* relative and DPR-normalized, so the point is correct on scrolled / HiDPI
|
|
168
|
+
* pages. Stored snapshot geometry (device-px `clientRects`, scroll-inclusive
|
|
169
|
+
* `absolutePosition`) is NEVER used as a click coordinate. The result is
|
|
170
|
+
* clamped into [0, viewport-1] (design 04a:1304-1305).
|
|
171
|
+
*/
|
|
172
|
+
elementCentre(node: EnhancedDOMTreeNode): Promise<Point | undefined>;
|
|
173
|
+
/** Centre from a live `DOM.getBoxModel` content quad (viewport CSS px). */
|
|
174
|
+
private centreFromBoxModel;
|
|
175
|
+
/**
|
|
176
|
+
* Centre from a live `getBoundingClientRect` on the resolved element — the
|
|
177
|
+
* cascade's last live fallback after the box model. Returns viewport CSS px.
|
|
178
|
+
*/
|
|
179
|
+
private centreFromBoundingRect;
|
|
180
|
+
/**
|
|
181
|
+
* Is the element covered by another at `point`? Uses `elementFromPoint`: the
|
|
182
|
+
* target is clickable if the hit element is, contains, or is contained by it.
|
|
183
|
+
* resolveNode failure → assume occluded (safer JS click); JS error → assume
|
|
184
|
+
* NOT occluded (bias toward the real click). (design §4.10.6.)
|
|
185
|
+
*/
|
|
186
|
+
private isOccluded;
|
|
187
|
+
private jsClick;
|
|
188
|
+
private readChecked;
|
|
189
|
+
private resolveObjectId;
|
|
190
|
+
private viewportSize;
|
|
191
|
+
private callFunction;
|
|
192
|
+
private dispatchKey;
|
|
193
|
+
/** Thin send wrapper: methods/params are threaded as the transport's typed union. */
|
|
194
|
+
private send;
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=dispatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/input/dispatcher.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAG7C,wBAAwB;AACxB,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,sEAAsE;AACtE,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,MAAM,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,oEAAoE;IACpE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,wEAAwE;IACxE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,6EAA6E;IAC7E,SAAS,CAAC,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EACzB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,IAAI,CAAC;YAIF,cAAc;IAkB5B;;;;;;;OAOG;IACG,aAAa,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC;IAa1E,2EAA2E;YAC7D,kBAAkB;IAoBhC;;;OAGG;YACW,sBAAsB;IAqBpC;;;;;OAKG;YACW,UAAU;YAkBV,OAAO;YAOP,WAAW;YAcX,eAAe;YAYf,YAAY;YAcZ,YAAY;IAmB1B,OAAO,CAAC,WAAW;IAcnB,qFAAqF;IACrF,OAAO,CAAC,IAAI;CAYb"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** DOM `code` for a base key (letters/digits/common punctuation). */
|
|
2
|
+
export declare function keyCode(baseKey: string): string | undefined;
|
|
3
|
+
export interface CharKey {
|
|
4
|
+
baseKey: string;
|
|
5
|
+
code?: string;
|
|
6
|
+
modifiers: number;
|
|
7
|
+
vk: number;
|
|
8
|
+
}
|
|
9
|
+
/** Map a single character to its keyDown/keyUp descriptor. */
|
|
10
|
+
export declare function charToKey(char: string): CharKey;
|
|
11
|
+
/** Normalize a single key token via the alias map (case-insensitive). */
|
|
12
|
+
export declare function normalizeKeyToken(token: string): string;
|
|
13
|
+
export interface KeyInfo {
|
|
14
|
+
special: boolean;
|
|
15
|
+
code?: string;
|
|
16
|
+
vk?: number;
|
|
17
|
+
}
|
|
18
|
+
/** Resolve a normalized key token to its dispatch info. */
|
|
19
|
+
export declare function keyInfo(token: string): KeyInfo;
|
|
20
|
+
//# sourceMappingURL=keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/input/keys.ts"],"names":[],"mappings":"AAiDA,qEAAqE;AACrE,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAkB3D;AAED,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,8DAA8D;AAC9D,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CA0B/C;AA8BD,yEAAyE;AACzE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvD;AAuCD,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,2DAA2D;AAC3D,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAO9C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type BrowserChannel = "chrome" | "chromium" | "brave" | "edge";
|
|
2
|
+
export interface DiscoveryOptions {
|
|
3
|
+
/** An explicit path — returned verbatim if it exists. */
|
|
4
|
+
executablePath?: string;
|
|
5
|
+
/** Preferred channel; its candidates are tried first. */
|
|
6
|
+
channel?: BrowserChannel;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Locate a Chromium-family executable, or `undefined` if none is found. The
|
|
10
|
+
* explicit `executablePath` wins; otherwise the preferred channel is tried
|
|
11
|
+
* first, then Chrome → Chromium → Brave → Edge, then the puppeteer cache.
|
|
12
|
+
*/
|
|
13
|
+
export declare function findChromeExecutable(options?: DiscoveryOptions): string | undefined;
|
|
14
|
+
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/launch/discovery.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAEtE,MAAM,WAAW,gBAAgB;IAC/B,yDAAyD;IACzD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yDAAyD;IACzD,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AA4FD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM,GAAG,SAAS,CAgBnF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type ChildProcess } from "node:child_process";
|
|
2
|
+
import { type BrowserChannel, type DiscoveryOptions } from "./discovery";
|
|
3
|
+
/** 28 feature names disabled as one `--disable-features=` flag (design/10 §4.5). */
|
|
4
|
+
export declare const CHROME_DISABLED_COMPONENTS: readonly string[];
|
|
5
|
+
/** Baseline launch args (design/10 §4.5, in source order), plus the composed
|
|
6
|
+
* `--disable-features` string built from {@link CHROME_DISABLED_COMPONENTS}. */
|
|
7
|
+
export declare const CHROME_DEFAULT_ARGS: readonly string[];
|
|
8
|
+
/** Docker/no-sandbox args (design/10 §4.5). */
|
|
9
|
+
export declare const CHROME_DOCKER_ARGS: readonly string[];
|
|
10
|
+
/** `disable_security` args (design/10 §4.5). */
|
|
11
|
+
export declare const CHROME_DISABLE_SECURITY_ARGS: readonly string[];
|
|
12
|
+
/** Deterministic-rendering args (design/10 §4.5). */
|
|
13
|
+
export declare const CHROME_DETERMINISTIC_RENDERING_ARGS: readonly string[];
|
|
14
|
+
export interface BuildArgsOptions {
|
|
15
|
+
userDataDir: string;
|
|
16
|
+
port: number;
|
|
17
|
+
headless?: boolean;
|
|
18
|
+
disableSecurity?: boolean;
|
|
19
|
+
deterministicRendering?: boolean;
|
|
20
|
+
/** Apply the docker/no-sandbox arg pack. */
|
|
21
|
+
docker?: boolean;
|
|
22
|
+
/** Sandbox on by default; disabling it also applies the docker pack. */
|
|
23
|
+
sandbox?: boolean;
|
|
24
|
+
extraArgs?: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Collapse every `--disable-features=` occurrence into ONE comma-joined,
|
|
28
|
+
* de-duplicated flag (§9.6 test_security_flags GOLDEN). Order preserved.
|
|
29
|
+
*/
|
|
30
|
+
export declare function consolidateDisableFeatures(args: string[]): string[];
|
|
31
|
+
/** Build the final Chrome CLI args (deduped disable-features, port injected). */
|
|
32
|
+
export declare function buildChromeArgs(options: BuildArgsOptions): string[];
|
|
33
|
+
export interface LaunchOptions extends DiscoveryOptions {
|
|
34
|
+
channel?: BrowserChannel;
|
|
35
|
+
userDataDir?: string;
|
|
36
|
+
headless?: boolean;
|
|
37
|
+
disableSecurity?: boolean;
|
|
38
|
+
deterministicRendering?: boolean;
|
|
39
|
+
docker?: boolean;
|
|
40
|
+
sandbox?: boolean;
|
|
41
|
+
extraArgs?: string[];
|
|
42
|
+
/** CDP readiness poll budget (ms, default 30000). */
|
|
43
|
+
launchTimeoutMs?: number;
|
|
44
|
+
}
|
|
45
|
+
export interface LaunchedBrowser {
|
|
46
|
+
/** The `ws://` DevTools endpoint. */
|
|
47
|
+
cdpUrl: string;
|
|
48
|
+
process: ChildProcess;
|
|
49
|
+
close(): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
/** Reserve a free localhost port (bind :0, read the assigned port, close). */
|
|
52
|
+
export declare function findFreePort(): Promise<number>;
|
|
53
|
+
/**
|
|
54
|
+
* Launch a local Chromium subprocess and return its `ws://` CDP endpoint. Throws
|
|
55
|
+
* a clear error (naming `npx @puppeteer/browsers install chrome`) when no
|
|
56
|
+
* executable can be found.
|
|
57
|
+
*/
|
|
58
|
+
export declare function launchLocalBrowser(options?: LaunchOptions): Promise<LaunchedBrowser>;
|
|
59
|
+
//# sourceMappingURL=local-browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-browser.d.ts","sourceRoot":"","sources":["../../src/launch/local-browser.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,YAAY,EAAS,MAAM,oBAAoB,CAAC;AAO9D,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,gB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AC,EAAE,MAAM,EAAE,CAAC;IACrB,qDAAqD;IACrD,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,YAAY,CAAC;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAID,8EAA8E;AAC9E,wBAAgB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAc9C;AAmBD;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,eAAe,CAAC,CA0D9F"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { LifecycleRecord } from "../targets/registry";
|
|
2
|
+
import type { TargetId } from "../types";
|
|
3
|
+
import type { CdpTransport } from "../types";
|
|
4
|
+
import type { NavigationPolicy } from "./policy";
|
|
5
|
+
export type WaitUntil = "commit" | "domcontentloaded" | "load" | "networkidle";
|
|
6
|
+
/** What Navigator needs from the target registry (or a test fake). */
|
|
7
|
+
export interface FocusProvider {
|
|
8
|
+
getFocusedSession(): {
|
|
9
|
+
targetId: TargetId;
|
|
10
|
+
sessionId: string;
|
|
11
|
+
} | undefined;
|
|
12
|
+
getLifecycleEvents(targetId: TargetId): LifecycleRecord[];
|
|
13
|
+
getCurrentUrl(targetId: TargetId): string | undefined;
|
|
14
|
+
}
|
|
15
|
+
export interface NavigateOptions {
|
|
16
|
+
waitUntil?: WaitUntil;
|
|
17
|
+
/** Budget for the `Page.navigate` call (ms, default 20000). */
|
|
18
|
+
navTimeoutMs?: number;
|
|
19
|
+
/** Budget for the readiness wait (ms, default 8000). */
|
|
20
|
+
readyTimeoutMs?: number;
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
}
|
|
23
|
+
export interface NavigateResult {
|
|
24
|
+
targetId: TargetId;
|
|
25
|
+
loaderId?: string;
|
|
26
|
+
/** Non-undefined when the readiness wait timed out (page may be incomplete). */
|
|
27
|
+
loadingStatus?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare class Navigator {
|
|
30
|
+
private readonly transport;
|
|
31
|
+
private readonly policy;
|
|
32
|
+
private readonly focus;
|
|
33
|
+
constructor(transport: CdpTransport, policy: NavigationPolicy, focus: FocusProvider);
|
|
34
|
+
navigate(url: string, options?: NavigateOptions): Promise<NavigateResult>;
|
|
35
|
+
private waitForReady;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=navigator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigator.d.ts","sourceRoot":"","sources":["../../src/navigation/navigator.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,kBAAkB,GAAG,MAAM,GAAG,aAAa,CAAC;AAE/E,sEAAsE;AACtE,MAAM,WAAW,aAAa;IAC5B,iBAAiB,IAAI;QAAE,QAAQ,EAAE,QAAQ,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IAC3E,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,eAAe,EAAE,CAAC;IAC1D,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;CACvD;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wDAAwD;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAQD,qBAAa,SAAS;IAElB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAFL,SAAS,EAAE,YAAY,EACvB,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,aAAa;IAGjC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;YA6CjE,YAAY;CAsB3B"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type UrlNotAllowedReason } from "../errors";
|
|
2
|
+
/** The 5-entry new-tab set (both slash and no-slash variants). One shared
|
|
3
|
+
* predicate consumed by the security allow-list AND target filtering (C7). */
|
|
4
|
+
export declare const NEW_TAB_URLS: readonly string[];
|
|
5
|
+
export declare function isNewTabPage(url: string): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* True iff `host` canonicalizes to an IP literal, including the encodings the
|
|
8
|
+
* kernel resolver accepts: decimal / hex / octal / short-form IPv4, bracketed
|
|
9
|
+
* and expanded IPv6, percent-encoded digits, NFKC digit variants, and IDNA dot
|
|
10
|
+
* separators (U+3002 / U+FF0E / U+FF61 folded to `.`). Never throws.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isIpAddress(host: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The domain-pattern matcher. Distinct from the security matcher: bare patterns
|
|
15
|
+
* default to **https-only**, ports are
|
|
16
|
+
* stripped, new-tab pages match NOTHING, unsafe wildcard patterns are rejected.
|
|
17
|
+
* Any internal failure → `false` (fail closed).
|
|
18
|
+
*/
|
|
19
|
+
export declare function matchUrlWithDomainPattern(url: string, pattern: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The security list matcher. Looser than the domain-pattern
|
|
22
|
+
* matcher on purpose. `scheme` and `host` are the parsed URL parts; `url` is the
|
|
23
|
+
* canonical (lower-cased, userinfo-stripped) URL for full-URL prefix/fnmatch
|
|
24
|
+
* patterns — never the raw input, so credentials can't spoof the authority.
|
|
25
|
+
*
|
|
26
|
+
* C2: scheme-ful non-glob patterns match by prefix but must END at a path/port/
|
|
27
|
+
* query boundary, so `https://example.com` no longer matches `example.communism.org`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function matchSecurityListPattern(url: string, scheme: string, host: string, pattern: string): boolean;
|
|
30
|
+
export interface NavigationPolicyOptions {
|
|
31
|
+
allowedDomains?: string[] | Set<string>;
|
|
32
|
+
prohibitedDomains?: string[] | Set<string>;
|
|
33
|
+
blockIpAddresses?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Opt-in (W27, default false): permit `file://` navigation, which is
|
|
36
|
+
* otherwise unconditionally blocked (an empty hostname always fails the
|
|
37
|
+
* `invalid_url` check below). SECURITY: file:// reads local disk — this
|
|
38
|
+
* flag is the only gate; default-deny must stay airtight.
|
|
39
|
+
*/
|
|
40
|
+
allowFileUrls?: boolean;
|
|
41
|
+
/** Sink for C1 conversion warnings (default `console.warn`). */
|
|
42
|
+
warn?: (message: string) => void;
|
|
43
|
+
}
|
|
44
|
+
export declare class NavigationPolicy {
|
|
45
|
+
private readonly allowed;
|
|
46
|
+
private readonly prohibited;
|
|
47
|
+
private readonly blockIpAddresses;
|
|
48
|
+
private readonly allowFileUrls;
|
|
49
|
+
constructor(options?: NavigationPolicyOptions);
|
|
50
|
+
/** Decide whether a URL is allowed, with the denial reason. */
|
|
51
|
+
evaluate(url: string): {
|
|
52
|
+
allowed: true;
|
|
53
|
+
} | {
|
|
54
|
+
allowed: false;
|
|
55
|
+
reason: UrlNotAllowedReason;
|
|
56
|
+
};
|
|
57
|
+
isAllowed(url: string): boolean;
|
|
58
|
+
/** Throw {@link UrlNotAllowedError} if the URL is not allowed (A3). */
|
|
59
|
+
check(url: string): void;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/navigation/policy.ts"],"names":[],"mappings":"AAQA,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAIzE;8EAC8E;AAC9E,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAMzC,CAAC;AAEF,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEjD;AAoDD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAcjD;AAeD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAmC/E;AAgBD;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,OAAO,CAgCT;AASD,MAAM,WAAW,uBAAuB;IACtC,cAAc,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;IACxC,iBAAiB,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gEAAgE;IAChE,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAQD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiB;IAC5C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAU;IAC3C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAU;gBAE5B,OAAO,CAAC,EAAE,uBAAuB;IAQ7C,+DAA+D;IAC/D,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,IAAI,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,KAAK,CAAC;QAAC,MAAM,EAAE,mBAAmB,CAAA;KAAE;IA6D1F,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI/B,uEAAuE;IACvE,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;CAIzB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { BrowserConfigOverrides, CloakConfig } from "../config";
|
|
2
|
+
import { type BrowserConnectOptions, BrowserSession } from "../session";
|
|
3
|
+
import type { BrowserProvider } from "./types";
|
|
4
|
+
/** Cloak options — a {@link CloakConfig} with a required endpoint to connect to. */
|
|
5
|
+
export interface CloakOptions extends CloakConfig {
|
|
6
|
+
/** cloakserve base URL or a launched CloakBrowser CDP url (http(s):// or ws(s)://). */
|
|
7
|
+
endpoint: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Build the CDP connection URL by appending the cloak options as cloakserve's
|
|
11
|
+
* isolation query params. Existing query params are preserved; explicit options
|
|
12
|
+
* win over collisions. Works for http(s):// (resolved to ws via /json/version)
|
|
13
|
+
* and ws(s):// (params pass straight through to the socket).
|
|
14
|
+
*
|
|
15
|
+
* Option → cloakserve param: fingerprint, platform→`fingerprint-platform`,
|
|
16
|
+
* proxy, geoip, humanize, timezone, locale.
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildCloakUrl(options: CloakOptions): string;
|
|
19
|
+
export declare class CloakProvider implements BrowserProvider {
|
|
20
|
+
private readonly cloak;
|
|
21
|
+
private readonly seams;
|
|
22
|
+
constructor(cloak: CloakOptions, seams?: BrowserConnectOptions);
|
|
23
|
+
/** Build the isolated CDP url and connect a started session to it. */
|
|
24
|
+
connect(overrides?: BrowserConfigOverrides): Promise<BrowserSession>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=cloak.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloak.d.ts","sourceRoot":"","sources":["../../src/providers/cloak.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAErE,OAAO,EAAE,KAAK,qBAAqB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,oFAAoF;AACpF,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C,uFAAuF;IACvF,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAqB3D;AAED,qBAAa,aAAc,YAAW,eAAe;IACnD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;IACrC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAwB;gBAElC,KAAK,EAAE,YAAY,EAAE,KAAK,GAAE,qBAA0B;IAQlE,sEAAsE;IACtE,OAAO,CAAC,SAAS,GAAE,sBAA2B,GAAG,OAAO,CAAC,cAAc,CAAC;CAIzE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ResolvedBrowserConfig } from "../config";
|
|
2
|
+
import type { BrowserConnectOptions, BrowserSession } from "../session";
|
|
3
|
+
import type { BrowserProvider } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Pick the provider for a resolved config. `seams` (injectable fetch/openTransport)
|
|
6
|
+
* flow to whichever provider ends up on the connect path — CloakProvider always,
|
|
7
|
+
* LocalChromeProvider only when `config.cdpUrl` routes it to connect instead of
|
|
8
|
+
* spawning (W6).
|
|
9
|
+
*/
|
|
10
|
+
export declare function createBrowserProvider(config: ResolvedBrowserConfig, seams?: BrowserConnectOptions): BrowserProvider;
|
|
11
|
+
/**
|
|
12
|
+
* Convenience: pick the provider from config and return a connected session. The
|
|
13
|
+
* config is passed through as overrides so the session honours the same resolved
|
|
14
|
+
* settings (allowed domains, headless, dialog policy, …).
|
|
15
|
+
*/
|
|
16
|
+
export declare function openBrowserSession(config: ResolvedBrowserConfig, seams?: BrowserConnectOptions): Promise<BrowserSession>;
|
|
17
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/providers/factory.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,qBAAqB,EAC7B,KAAK,GAAE,qBAA0B,GAChC,eAAe,CAYjB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,qBAAqB,EAC7B,KAAK,GAAE,qBAA0B,GAChC,OAAO,CAAC,cAAc,CAAC,CAEzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAEA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type BrowserConfigOverrides } from "../config";
|
|
2
|
+
import { type BrowserConnectOptions, BrowserSession } from "../session";
|
|
3
|
+
import type { BrowserProvider } from "./types";
|
|
4
|
+
export declare class LocalChromeProvider implements BrowserProvider {
|
|
5
|
+
private readonly seams;
|
|
6
|
+
constructor(seams?: BrowserConnectOptions);
|
|
7
|
+
/**
|
|
8
|
+
* Connect to `config.cdpUrl` when set; otherwise spawn a local Chromium and
|
|
9
|
+
* connect to it. Unset `cdpUrl` is byte-identical to the pre-W6 behavior.
|
|
10
|
+
*/
|
|
11
|
+
connect(overrides?: BrowserConfigOverrides): Promise<BrowserSession>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=local.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../src/providers/local.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,sBAAsB,EAAwB,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,KAAK,qBAAqB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,qBAAa,mBAAoB,YAAW,eAAe;IACzD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAwB;gBAElC,KAAK,GAAE,qBAA0B;IAI7C;;;OAGG;IACH,OAAO,CAAC,SAAS,GAAE,sBAA2B,GAAG,OAAO,CAAC,cAAc,CAAC;CAOzE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BrowserConfigOverrides } from "../config";
|
|
2
|
+
import type { BrowserSession } from "../session";
|
|
3
|
+
/** Yields a connected {@link BrowserSession}. The one seam launch/connect hides behind. */
|
|
4
|
+
export interface BrowserProvider {
|
|
5
|
+
/** Produce a started, connected session (optionally overriding its config). */
|
|
6
|
+
connect(overrides?: BrowserConfigOverrides): Promise<BrowserSession>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/providers/types.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,2FAA2F;AAC3F,MAAM,WAAW,eAAe;IAC9B,+EAA+E;IAC/E,OAAO,CAAC,SAAS,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACtE"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { CdpTransport } from "../types";
|
|
2
|
+
export interface HarTiming {
|
|
3
|
+
dns: number;
|
|
4
|
+
connect: number;
|
|
5
|
+
ssl: number;
|
|
6
|
+
send: number;
|
|
7
|
+
wait: number;
|
|
8
|
+
receive: number;
|
|
9
|
+
}
|
|
10
|
+
export interface HarHeader {
|
|
11
|
+
name: string;
|
|
12
|
+
value: string;
|
|
13
|
+
}
|
|
14
|
+
export interface HarEntry {
|
|
15
|
+
startedDateTime: string;
|
|
16
|
+
time: number;
|
|
17
|
+
request: {
|
|
18
|
+
method: string;
|
|
19
|
+
url: string;
|
|
20
|
+
httpVersion: string;
|
|
21
|
+
headers: HarHeader[];
|
|
22
|
+
queryString: [];
|
|
23
|
+
cookies: [];
|
|
24
|
+
headersSize: number;
|
|
25
|
+
bodySize: number;
|
|
26
|
+
};
|
|
27
|
+
response: {
|
|
28
|
+
status: number;
|
|
29
|
+
statusText: string;
|
|
30
|
+
httpVersion: string;
|
|
31
|
+
headers: HarHeader[];
|
|
32
|
+
cookies: [];
|
|
33
|
+
content: {
|
|
34
|
+
mimeType: string;
|
|
35
|
+
size: number;
|
|
36
|
+
};
|
|
37
|
+
redirectURL: string;
|
|
38
|
+
headersSize: number;
|
|
39
|
+
bodySize: number;
|
|
40
|
+
};
|
|
41
|
+
cache: Record<string, never>;
|
|
42
|
+
timings: HarTiming;
|
|
43
|
+
pageref?: string;
|
|
44
|
+
serverIPAddress?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface HarPage {
|
|
47
|
+
id: string;
|
|
48
|
+
title: string;
|
|
49
|
+
startedDateTime: string;
|
|
50
|
+
pageTimings: {
|
|
51
|
+
onContentLoad?: number;
|
|
52
|
+
onLoad?: number;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export interface HarLog {
|
|
56
|
+
log: {
|
|
57
|
+
version: "1.2";
|
|
58
|
+
creator: {
|
|
59
|
+
name: string;
|
|
60
|
+
version: string;
|
|
61
|
+
};
|
|
62
|
+
pages: HarPage[];
|
|
63
|
+
entries: HarEntry[];
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export interface HarRecorderOptions {
|
|
67
|
+
/** `"full"` (default) records every request; `"minimal"` keeps only same-origin-as-page requests. */
|
|
68
|
+
mode?: "full" | "minimal";
|
|
69
|
+
}
|
|
70
|
+
export declare class HarRecorder {
|
|
71
|
+
private readonly transport;
|
|
72
|
+
private readonly mode;
|
|
73
|
+
private readonly entries;
|
|
74
|
+
private readonly pages;
|
|
75
|
+
private unsubscribes;
|
|
76
|
+
private recording;
|
|
77
|
+
constructor(transport: CdpTransport, options?: HarRecorderOptions);
|
|
78
|
+
get isRecording(): boolean;
|
|
79
|
+
/** Begin capturing network events across every session. Idempotent. */
|
|
80
|
+
start(): void;
|
|
81
|
+
/** Stop capturing and assemble the HAR JSON from everything captured so far. */
|
|
82
|
+
stop(): HarLog;
|
|
83
|
+
private onRequestWillBeSent;
|
|
84
|
+
private onResponseReceived;
|
|
85
|
+
private onLoadingFinished;
|
|
86
|
+
private onLoadingFailed;
|
|
87
|
+
private onLifecycleEvent;
|
|
88
|
+
private onFrameNavigated;
|
|
89
|
+
private includeEntry;
|
|
90
|
+
private buildHar;
|
|
91
|
+
private toHarEntry;
|
|
92
|
+
private computeTimings;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=har.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"har.d.ts","sourceRoot":"","sources":["../../src/recording/har.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,YAAY,EAAE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