@jobshimo/browser-link 0.29.0 → 0.31.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 (51) hide show
  1. package/dist/activity/extract.js +1 -0
  2. package/dist/activity/extract.js.map +1 -1
  3. package/dist/agent-instructions/content.js +12 -0
  4. package/dist/agent-instructions/content.js.map +1 -1
  5. package/dist/bridge/dispatch.js +5 -3
  6. package/dist/bridge/dispatch.js.map +1 -1
  7. package/dist/cdp/expect.d.ts +95 -0
  8. package/dist/cdp/expect.js +197 -0
  9. package/dist/cdp/expect.js.map +1 -0
  10. package/dist/cdp/flow.d.ts +7 -0
  11. package/dist/cdp/flow.js +4 -47
  12. package/dist/cdp/flow.js.map +1 -1
  13. package/dist/cdp/inpage/builders.d.ts +39 -0
  14. package/dist/cdp/inpage/builders.js +136 -0
  15. package/dist/cdp/inpage/builders.js.map +1 -1
  16. package/dist/cdp/screenshot.d.ts +109 -0
  17. package/dist/cdp/screenshot.js +189 -0
  18. package/dist/cdp/screenshot.js.map +1 -0
  19. package/dist/cdp/support.js +1 -0
  20. package/dist/cdp/support.js.map +1 -1
  21. package/dist/cdp/transport.js +43 -1
  22. package/dist/cdp/transport.js.map +1 -1
  23. package/dist/commands/about.js +2 -0
  24. package/dist/commands/about.js.map +1 -1
  25. package/dist/extension/background.js +53 -1
  26. package/dist/extension/background.js.map +1 -1
  27. package/dist/extension/expect.d.ts +95 -0
  28. package/dist/extension/expect.js +203 -0
  29. package/dist/extension/expect.js.map +1 -0
  30. package/dist/extension/flow.d.ts +7 -0
  31. package/dist/extension/flow.js +4 -51
  32. package/dist/extension/flow.js.map +1 -1
  33. package/dist/extension/inpage/builders.d.ts +39 -0
  34. package/dist/extension/inpage/builders.js +136 -0
  35. package/dist/extension/inpage/builders.js.map +1 -1
  36. package/dist/extension/manifest.json +1 -1
  37. package/dist/extension/screenshot.d.ts +113 -0
  38. package/dist/extension/screenshot.js +193 -0
  39. package/dist/extension/screenshot.js.map +1 -0
  40. package/dist/permissions.js +6 -0
  41. package/dist/permissions.js.map +1 -1
  42. package/dist/tools/browser-definitions.js +105 -3
  43. package/dist/tools/browser-definitions.js.map +1 -1
  44. package/dist/tools/browser-dispatch.js +129 -9
  45. package/dist/tools/browser-dispatch.js.map +1 -1
  46. package/dist/tools/responses.d.ts +14 -2
  47. package/dist/tools/responses.js +21 -0
  48. package/dist/tools/responses.js.map +1 -1
  49. package/dist/tools/server-instructions.js +18 -0
  50. package/dist/tools/server-instructions.js.map +1 -1
  51. package/package.json +1 -1
@@ -126,6 +126,21 @@ export interface FocusResolveOpts {
126
126
  selector: string;
127
127
  }
128
128
  export declare function buildFocusJs(opts: FocusResolveOpts): string;
129
+ /**
130
+ * Build the element-rect probe for `browser.screenshot`'s element mode.
131
+ * Resolves the selector with the same deep search scope as click/find,
132
+ * scrolls it into view (frames first), and returns its border-box rect in
133
+ * TOP-document page coordinates (viewport rect + accumulated iframe content
134
+ * origins + top-window scroll) — the space `Page.captureScreenshot`'s
135
+ * `clip` expects. Returns:
136
+ * { ok: true, x, y, width, height }
137
+ * { ok: false, reason: 'invalid-selector', error }
138
+ * { ok: false, reason: 'not-found' }
139
+ */
140
+ export interface ElementRectOpts {
141
+ selector: string;
142
+ }
143
+ export declare function buildElementRectJs(opts: ElementRectOpts): string;
129
144
  /**
130
145
  * Build the settle-await expression shared by `browser.click`, `.type` and
131
146
  * `.press`. Called AFTER the action's CDP input events have been
@@ -154,6 +169,30 @@ export interface SettleOpts {
154
169
  settle_timeout_ms: number;
155
170
  }
156
171
  export declare function buildSettleJs(opts: SettleOpts): string;
172
+ export interface ExpectProbeOpts {
173
+ selector_appears?: string;
174
+ selector_disappears?: string;
175
+ text_appears?: string;
176
+ }
177
+ /**
178
+ * Build the `expect` probe: ONE cheap in-page sample of everything an
179
+ * action's `expect` may ask about, polled by `verifyExpect` (expect.ts)
180
+ * until its conditions hold or its window closes. Returns
181
+ * `{ url, selector_appears?, selector_disappears?, text_appears?,
182
+ * invalid_selector? }` — only the keys that were requested are present.
183
+ *
184
+ * - `selector_appears` / `selector_disappears` resolve through
185
+ * `deepQueryAll` (open Shadow DOM + same-origin iframes, like click and
186
+ * find) and count only VISIBLE matches (`isVisible`, the same notion
187
+ * find/snapshot use). "Disappears" holds when no visible match remains.
188
+ * - `text_appears` is a case-insensitive, whitespace-collapsed substring
189
+ * test over the rendered text of the document, every open shadow root
190
+ * and every same-origin iframe.
191
+ * - A selector the parser rejects is reported as `invalid_selector`
192
+ * (naming the condition) instead of silently reading as "absent" —
193
+ * which would make `selector_disappears` trivially, wrongly true.
194
+ */
195
+ export declare function buildExpectProbeJs(opts: ExpectProbeOpts): string;
157
196
  /**
158
197
  * Build the `browser.state` expression: a compact orientation snapshot —
159
198
  * current url/title, the deep-resolved focused element, visible dialog-role
@@ -337,6 +337,52 @@ export function buildFocusJs(opts) {
337
337
  return true;
338
338
  })()`;
339
339
  }
340
+ export function buildElementRectJs(opts) {
341
+ const optsJson = JSON.stringify({ selector: opts.selector });
342
+ return `
343
+ (() => {
344
+ ${DEEP_QUERY_JS}
345
+ const opts = ${optsJson};
346
+ try {
347
+ document.querySelector(opts.selector);
348
+ } catch (e) {
349
+ return { ok: false, reason: 'invalid-selector', error: e && e.message ? e.message : String(e) };
350
+ }
351
+ const el = deepQueryFirst(opts.selector);
352
+ if (!el) return { ok: false, reason: 'not-found' };
353
+ const chain = frameElementChain(el);
354
+ // behavior 'instant' overrides CSS scroll-behavior: smooth, which would
355
+ // leave the rect below stale while the scroll is still animating.
356
+ const jump = { block: 'center', inline: 'center', behavior: 'instant' };
357
+ for (const fe of chain) {
358
+ if (fe.scrollIntoView) fe.scrollIntoView(jump);
359
+ }
360
+ if (el.scrollIntoView) el.scrollIntoView(jump);
361
+ const rect = el.getBoundingClientRect();
362
+ let offsetX = 0;
363
+ let offsetY = 0;
364
+ for (const fe of chain) {
365
+ const fr = fe.getBoundingClientRect();
366
+ const origin = frameViewportOriginOffset(fe);
367
+ offsetX += fr.left + origin.x;
368
+ offsetY += fr.top + origin.y;
369
+ }
370
+ let scrollX = 0;
371
+ let scrollY = 0;
372
+ try {
373
+ const top = window.top || window;
374
+ scrollX = top.scrollX || 0;
375
+ scrollY = top.scrollY || 0;
376
+ } catch (_) {}
377
+ return {
378
+ ok: true,
379
+ x: offsetX + rect.left + scrollX,
380
+ y: offsetY + rect.top + scrollY,
381
+ width: rect.width,
382
+ height: rect.height,
383
+ };
384
+ })()`;
385
+ }
340
386
  export function buildSettleJs(opts) {
341
387
  const optsJson = JSON.stringify({
342
388
  settleMs: Math.max(0, opts.settle_ms),
@@ -391,6 +437,96 @@ export function buildSettleJs(opts) {
391
437
  });
392
438
  })()`;
393
439
  }
440
+ /**
441
+ * Build the `expect` probe: ONE cheap in-page sample of everything an
442
+ * action's `expect` may ask about, polled by `verifyExpect` (expect.ts)
443
+ * until its conditions hold or its window closes. Returns
444
+ * `{ url, selector_appears?, selector_disappears?, text_appears?,
445
+ * invalid_selector? }` — only the keys that were requested are present.
446
+ *
447
+ * - `selector_appears` / `selector_disappears` resolve through
448
+ * `deepQueryAll` (open Shadow DOM + same-origin iframes, like click and
449
+ * find) and count only VISIBLE matches (`isVisible`, the same notion
450
+ * find/snapshot use). "Disappears" holds when no visible match remains.
451
+ * - `text_appears` is a case-insensitive, whitespace-collapsed substring
452
+ * test over the rendered text of the document, every open shadow root
453
+ * and every same-origin iframe.
454
+ * - A selector the parser rejects is reported as `invalid_selector`
455
+ * (naming the condition) instead of silently reading as "absent" —
456
+ * which would make `selector_disappears` trivially, wrongly true.
457
+ */
458
+ export function buildExpectProbeJs(opts) {
459
+ const optsJson = JSON.stringify({
460
+ selectorAppears: opts.selector_appears,
461
+ selectorDisappears: opts.selector_disappears,
462
+ textAppears: opts.text_appears,
463
+ });
464
+ return `
465
+ (() => {
466
+ ${DEEP_QUERY_JS}
467
+ ${DOM_HELPERS_JS}
468
+ const opts = ${optsJson};
469
+ const out = { url: location.href };
470
+ function selectorIsValid(sel) {
471
+ try {
472
+ document.querySelector(sel);
473
+ return true;
474
+ } catch (_) {
475
+ return false;
476
+ }
477
+ }
478
+ function hasVisibleMatch(sel) {
479
+ return deepQueryAll(sel).some(isVisible);
480
+ }
481
+ function normalized(s) {
482
+ return String(s).replace(/\\s+/g, ' ').trim().toLowerCase();
483
+ }
484
+ function ownText(node) {
485
+ const t = node.innerText;
486
+ return typeof t === 'string' ? t : node.textContent || '';
487
+ }
488
+ function elementText(el) {
489
+ const tag = el.tagName;
490
+ if (tag === 'STYLE' || tag === 'SCRIPT' || tag === 'TEMPLATE' || tag === 'NOSCRIPT') return '';
491
+ if (!isVisible(el)) return '';
492
+ return ownText(el);
493
+ }
494
+ function rootText(root) {
495
+ if (root.nodeType === 9) {
496
+ let frame = null;
497
+ try {
498
+ frame = root.defaultView && root.defaultView.frameElement;
499
+ } catch (_) {}
500
+ if (frame && !isVisible(frame)) return '';
501
+ return root.body ? ownText(root.body) : '';
502
+ }
503
+ if (root.host && !isVisible(root.host)) return '';
504
+ const kids = root.children || [];
505
+ const parts = [];
506
+ for (let j = 0; j < kids.length; j++) parts.push(elementText(kids[j]));
507
+ return parts.join(' ');
508
+ }
509
+ function renderedText() {
510
+ const roots = collectSearchRoots(document);
511
+ const parts = [];
512
+ for (let i = 0; i < roots.length; i++) parts.push(rootText(roots[i]));
513
+ return normalized(parts.join(' '));
514
+ }
515
+ if (opts.selectorAppears !== undefined) {
516
+ if (selectorIsValid(opts.selectorAppears)) out.selector_appears = hasVisibleMatch(opts.selectorAppears);
517
+ else out.invalid_selector = 'selector_appears';
518
+ }
519
+ if (opts.selectorDisappears !== undefined) {
520
+ if (selectorIsValid(opts.selectorDisappears)) out.selector_disappears = !hasVisibleMatch(opts.selectorDisappears);
521
+ else out.invalid_selector = 'selector_disappears';
522
+ }
523
+ if (opts.textAppears !== undefined) {
524
+ out.text_appears = renderedText().indexOf(normalized(opts.textAppears)) !== -1;
525
+ }
526
+ return out;
527
+ })()
528
+ `;
529
+ }
394
530
  /**
395
531
  * Build the `browser.state` expression: a compact orientation snapshot —
396
532
  * current url/title, the deep-resolved focused element, visible dialog-role
@@ -1 +1 @@
1
- {"version":3,"file":"builders.js","sourceRoot":"","sources":["../../../src/cdp/inpage/builders.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AA6BlD,MAAM,UAAU,eAAe,CAAC,OAAqB,EAAE;IACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAC9B,cAAc,EAAE,OAAO,IAAI,CAAC,eAAe,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI;QACtF,eAAe,EAAE,IAAI,CAAC,gBAAgB,KAAK,IAAI;QAC/C,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;QACxD,cAAc,EACZ,OAAO,IAAI,CAAC,eAAe,KAAK,QAAQ,IAAI,IAAI,CAAC,eAAe,GAAG,CAAC;YAClE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,CAAC;YACrC,CAAC,CAAC,GAAG;KACV,CAAC,CAAC;IACH,OAAO;;IAEL,aAAa;IACb,cAAc;iBACD,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8FxB,CAAC;AACF,CAAC;AAwCD,MAAM,UAAU,WAAW,CAAC,IAAc;IACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAC9B,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAA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;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAqB;IACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAC9B,eAAe,EAAE,IAAI,CAAC,gBAAgB;QACtC,kBAAkB,EAAE,IAAI,CAAC,mBAAmB;QAC5C,WAAW,EAAE,IAAI,CAAC,YAAY;KAC/B,CAAC,CAAC;IACH,OAAO;;IAEL,aAAa;IACb,cAAc;iBACD,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4DxB,CAAC;AACF,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO;;IAEL,aAAa;IACb,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmFjB,CAAC;AACF,CAAC"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Independent copy of `packages/extension/src/screenshot.ts` (this package
3
+ * publishes to npm standalone and cannot import the extension). Everything
4
+ * below this header is byte-identical to the original; `cdp/drift.test.ts`
5
+ * fails the build if the two diverge. Used by the cdp-direct transport
6
+ * (`./transport.ts`) over a raw CDP connection.
7
+ */
8
+ export type ScreenshotMode = 'viewport' | 'full_page' | 'element';
9
+ export type ScreenshotFormat = 'png' | 'jpeg';
10
+ export declare const DEFAULT_MAX_DIMENSION = 8000;
11
+ /** Below this scale the text in a page is unreadable; crop instead. */
12
+ export declare const MIN_SCALE = 0.25;
13
+ /** Cap on the decoded image size returned to the agent. */
14
+ export declare const MAX_IMAGE_BYTES: number;
15
+ export declare const DEFAULT_JPEG_QUALITY = 80;
16
+ export interface Size {
17
+ width: number;
18
+ height: number;
19
+ }
20
+ export interface Rect extends Size {
21
+ x: number;
22
+ y: number;
23
+ }
24
+ export interface LayoutMetrics {
25
+ cssContentSize?: Size;
26
+ contentSize?: Size;
27
+ cssVisualViewport?: {
28
+ pageX: number;
29
+ pageY: number;
30
+ clientWidth: number;
31
+ clientHeight: number;
32
+ };
33
+ visualViewport?: {
34
+ pageX: number;
35
+ pageY: number;
36
+ clientWidth: number;
37
+ clientHeight: number;
38
+ };
39
+ /** Layout viewport in device pixels / CSS pixels — their ratio is the DPR. */
40
+ layoutViewport?: {
41
+ clientWidth: number;
42
+ };
43
+ cssLayoutViewport?: {
44
+ clientWidth: number;
45
+ };
46
+ }
47
+ export interface ScreenshotPlan {
48
+ clip: Rect & {
49
+ scale: number;
50
+ };
51
+ /** Output size in pixels. */
52
+ width: number;
53
+ height: number;
54
+ scale: number;
55
+ /** Device pixels per CSS pixel; the capture is clip x scale x dpr pixels. */
56
+ dpr: number;
57
+ truncated: boolean;
58
+ }
59
+ /**
60
+ * Device pixels per CSS pixel, derived from the layout metrics (no extra
61
+ * in-page round trip): layout-viewport width ratio, else content-size
62
+ * ratio, else 1.
63
+ */
64
+ export declare function dprFromMetrics(m: LayoutMetrics): number;
65
+ export declare function planClip(mode: ScreenshotMode, metrics: LayoutMetrics, elementRect: Rect | undefined, maxDimension: number): ScreenshotPlan;
66
+ /** Decoded byte length of a base64 string. */
67
+ export declare function base64ByteLength(b64: string): number;
68
+ export interface Attempt {
69
+ format: ScreenshotFormat;
70
+ scale: number;
71
+ quality: number | undefined;
72
+ }
73
+ /**
74
+ * What to try after an image came back over the byte cap: PNG → JPEG at the
75
+ * same scale, then JPEG at a scale reduced in proportion to the overshoot.
76
+ * `null` when nothing smaller is worth trying.
77
+ */
78
+ export declare function nextOversizeAttempt(prev: Attempt, bytes: number, cap: number): Attempt | null;
79
+ export type ElementRectOutcome = ({
80
+ ok: true;
81
+ } & Rect) | {
82
+ ok: false;
83
+ reason: 'invalid-selector' | 'not-found';
84
+ error?: string;
85
+ };
86
+ export interface ScreenshotDeps {
87
+ send: (method: string, params?: Record<string, unknown>) => Promise<unknown>;
88
+ resolveElementRect: (selector: string) => Promise<ElementRectOutcome>;
89
+ }
90
+ export interface ScreenshotOptions {
91
+ mode?: ScreenshotMode;
92
+ selector?: string;
93
+ format?: ScreenshotFormat;
94
+ quality?: number;
95
+ maxDimension?: number;
96
+ }
97
+ export interface ScreenshotResult {
98
+ ok: true;
99
+ mode: ScreenshotMode;
100
+ format: ScreenshotFormat;
101
+ width: number;
102
+ height: number;
103
+ scale: number;
104
+ bytes: number;
105
+ truncated?: true;
106
+ size_reduced?: true;
107
+ image_b64: string;
108
+ }
109
+ export declare function runScreenshot(deps: ScreenshotDeps, opts: ScreenshotOptions): Promise<ScreenshotResult>;
@@ -0,0 +1,189 @@
1
+ /**
2
+ * Independent copy of `packages/extension/src/screenshot.ts` (this package
3
+ * publishes to npm standalone and cannot import the extension). Everything
4
+ * below this header is byte-identical to the original; `cdp/drift.test.ts`
5
+ * fails the build if the two diverge. Used by the cdp-direct transport
6
+ * (`./transport.ts`) over a raw CDP connection.
7
+ */
8
+ export const DEFAULT_MAX_DIMENSION = 8000;
9
+ /** Below this scale the text in a page is unreadable; crop instead. */
10
+ export const MIN_SCALE = 0.25;
11
+ /** Hard floor when shrinking to satisfy the byte cap. */
12
+ const ABSOLUTE_MIN_SCALE = 0.1;
13
+ /** Cap on the decoded image size returned to the agent. */
14
+ export const MAX_IMAGE_BYTES = 8 * 1024 * 1024;
15
+ export const DEFAULT_JPEG_QUALITY = 80;
16
+ const MAX_ATTEMPTS = 4;
17
+ /**
18
+ * Device pixels per CSS pixel, derived from the layout metrics (no extra
19
+ * in-page round trip): layout-viewport width ratio, else content-size
20
+ * ratio, else 1.
21
+ */
22
+ export function dprFromMetrics(m) {
23
+ const pairs = [
24
+ [m.layoutViewport?.clientWidth, m.cssLayoutViewport?.clientWidth],
25
+ [m.contentSize?.width, m.cssContentSize?.width],
26
+ [m.visualViewport?.clientWidth, m.cssVisualViewport?.clientWidth],
27
+ ];
28
+ for (const [device, css] of pairs) {
29
+ if (positive(device) && positive(css))
30
+ return device / css;
31
+ }
32
+ return 1;
33
+ }
34
+ function positive(n) {
35
+ return typeof n === 'number' && Number.isFinite(n) && n > 0;
36
+ }
37
+ export function planClip(mode, metrics, elementRect, maxDimension) {
38
+ const dpr = dprFromMetrics(metrics);
39
+ let region;
40
+ if (mode === 'element') {
41
+ if (!elementRect)
42
+ throw new Error('screenshot: element rect missing for element mode');
43
+ region = { ...elementRect };
44
+ }
45
+ else if (mode === 'viewport') {
46
+ // Device-pixel fallback values are converted to the CSS pixels clip uses.
47
+ const css = metrics.cssVisualViewport;
48
+ const dev = metrics.visualViewport;
49
+ if (css) {
50
+ region = { x: css.pageX, y: css.pageY, width: css.clientWidth, height: css.clientHeight };
51
+ }
52
+ else if (dev) {
53
+ region = {
54
+ x: dev.pageX / dpr,
55
+ y: dev.pageY / dpr,
56
+ width: dev.clientWidth / dpr,
57
+ height: dev.clientHeight / dpr,
58
+ };
59
+ }
60
+ else {
61
+ throw new Error('screenshot: layout metrics have no viewport');
62
+ }
63
+ }
64
+ else {
65
+ const size = metrics.cssContentSize
66
+ ? metrics.cssContentSize
67
+ : metrics.contentSize
68
+ ? { width: metrics.contentSize.width / dpr, height: metrics.contentSize.height / dpr }
69
+ : undefined;
70
+ if (!size)
71
+ throw new Error('screenshot: layout metrics have no content size');
72
+ region = { x: 0, y: 0, width: size.width, height: size.height };
73
+ }
74
+ if (!positive(region.width) || !positive(region.height)) {
75
+ throw new Error(`screenshot: ${mode} region is zero-sized — nothing to capture`);
76
+ }
77
+ // The output is clip x scale x dpr DEVICE pixels, so max_dimension bounds
78
+ // the longest side in device pixels.
79
+ let scale = Math.min(1, maxDimension / (Math.max(region.width, region.height) * dpr));
80
+ let truncated = false;
81
+ if (scale < MIN_SCALE) {
82
+ scale = MIN_SCALE;
83
+ const limit = maxDimension / (MIN_SCALE * dpr);
84
+ if (region.width > limit)
85
+ region.width = limit;
86
+ if (region.height > limit)
87
+ region.height = limit;
88
+ truncated = true;
89
+ }
90
+ return {
91
+ clip: { ...region, scale },
92
+ width: Math.max(1, Math.round(region.width * scale * dpr)),
93
+ height: Math.max(1, Math.round(region.height * scale * dpr)),
94
+ scale,
95
+ dpr,
96
+ truncated,
97
+ };
98
+ }
99
+ /** Decoded byte length of a base64 string. */
100
+ export function base64ByteLength(b64) {
101
+ if (b64.length === 0)
102
+ return 0;
103
+ let padding = 0;
104
+ if (b64.endsWith('=='))
105
+ padding = 2;
106
+ else if (b64.endsWith('='))
107
+ padding = 1;
108
+ return Math.floor((b64.length * 3) / 4) - padding;
109
+ }
110
+ /**
111
+ * What to try after an image came back over the byte cap: PNG → JPEG at the
112
+ * same scale, then JPEG at a scale reduced in proportion to the overshoot.
113
+ * `null` when nothing smaller is worth trying.
114
+ */
115
+ export function nextOversizeAttempt(prev, bytes, cap) {
116
+ if (prev.format === 'png') {
117
+ return { format: 'jpeg', scale: prev.scale, quality: prev.quality ?? DEFAULT_JPEG_QUALITY };
118
+ }
119
+ if (prev.scale <= ABSOLUTE_MIN_SCALE)
120
+ return null;
121
+ const next = Math.max(ABSOLUTE_MIN_SCALE, prev.scale * Math.sqrt(cap / bytes) * 0.85);
122
+ return { format: 'jpeg', scale: next, quality: prev.quality ?? DEFAULT_JPEG_QUALITY };
123
+ }
124
+ export async function runScreenshot(deps, opts) {
125
+ const mode = opts.mode ?? 'viewport';
126
+ const maxDimension = opts.maxDimension ?? DEFAULT_MAX_DIMENSION;
127
+ let elementRect;
128
+ if (mode === 'element') {
129
+ if (!opts.selector)
130
+ throw new Error('screenshot: selector is required for element mode');
131
+ const r = await deps.resolveElementRect(opts.selector);
132
+ if (!r.ok) {
133
+ if (r.reason === 'invalid-selector') {
134
+ throw new Error(`Invalid selector "${opts.selector}": ${r.error ?? 'syntax error'}`);
135
+ }
136
+ throw new Error(`Element not found: ${opts.selector}`);
137
+ }
138
+ elementRect = { x: r.x, y: r.y, width: r.width, height: r.height };
139
+ }
140
+ // Always read the metrics: besides the page size they carry the DPR the
141
+ // output dimensions depend on.
142
+ const metrics = (await deps.send('Page.getLayoutMetrics'));
143
+ const plan = planClip(mode, metrics, elementRect, maxDimension);
144
+ let attempt = {
145
+ format: opts.format ?? 'png',
146
+ scale: plan.scale,
147
+ quality: opts.quality,
148
+ };
149
+ let reduced = false;
150
+ let lastBytes = 0;
151
+ for (let i = 0; i < MAX_ATTEMPTS; i++) {
152
+ const params = {
153
+ format: attempt.format,
154
+ captureBeyondViewport: mode !== 'viewport',
155
+ clip: { ...plan.clip, scale: attempt.scale },
156
+ };
157
+ if (attempt.format === 'jpeg' && attempt.quality !== undefined) {
158
+ params.quality = attempt.quality;
159
+ }
160
+ const res = (await deps.send('Page.captureScreenshot', params));
161
+ const bytes = base64ByteLength(res.data);
162
+ lastBytes = bytes;
163
+ if (bytes <= MAX_IMAGE_BYTES) {
164
+ const result = {
165
+ ok: true,
166
+ mode,
167
+ format: attempt.format,
168
+ width: Math.max(1, Math.round(plan.clip.width * attempt.scale * plan.dpr)),
169
+ height: Math.max(1, Math.round(plan.clip.height * attempt.scale * plan.dpr)),
170
+ scale: attempt.scale,
171
+ bytes,
172
+ image_b64: res.data,
173
+ };
174
+ if (plan.truncated)
175
+ result.truncated = true;
176
+ if (reduced)
177
+ result.size_reduced = true;
178
+ return result;
179
+ }
180
+ const next = nextOversizeAttempt(attempt, bytes, MAX_IMAGE_BYTES);
181
+ if (!next)
182
+ break;
183
+ attempt = next;
184
+ reduced = true;
185
+ }
186
+ const mb = (n) => (n / (1024 * 1024)).toFixed(1);
187
+ throw new Error(`screenshot: image is ${mb(lastBytes)} MB, which exceeds the ${mb(MAX_IMAGE_BYTES)} MB cap even after reducing quality and scale — use mode "element", a smaller max_dimension, or jpeg`);
188
+ }
189
+ //# sourceMappingURL=screenshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screenshot.js","sourceRoot":"","sources":["../../src/cdp/screenshot.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAC1C,uEAAuE;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,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,KAAK;gBACL,SAAS,EAAE,GAAG,CAAC,IAAI;aACpB,CAAC;YACF,IAAI,IAAI,CAAC,SAAS;gBAAE,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC;YAC5C,IAAI,OAAO;gBAAE,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC;YACxC,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,MAAM,IAAI,GAAG,mBAAmB,CAAC,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;QAClE,IAAI,CAAC,IAAI;YAAE,MAAM;QACjB,OAAO,GAAG,IAAI,CAAC;QACf,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IACD,MAAM,EAAE,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACjE,MAAM,IAAI,KAAK,CACb,wBAAwB,EAAE,CAAC,SAAS,CAAC,0BAA0B,EAAE,CAAC,eAAe,CAAC,sGAAsG,CACzL,CAAC;AACJ,CAAC"}
@@ -32,6 +32,7 @@ export const CDP_TOOL_SUPPORT = new Map([
32
32
  ['snapshot', true],
33
33
  ['find', true],
34
34
  ['state', true],
35
+ ['screenshot', true],
35
36
  ['click', true],
36
37
  ['type', true],
37
38
  ['press', true],
@@ -1 +1 @@
1
- {"version":3,"file":"support.js","sourceRoot":"","sources":["../../src/cdp/support.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wEAAwE;AACxE,qEAAqE;AACrE,4EAA4E;AAC5E,yEAAyE;AACzE,sEAAsE;AACtE,0EAA0E;AAC1E,eAAe;AACf,MAAM,CAAC,MAAM,gBAAgB,GAAiC,IAAI,GAAG,CAAC;IACpE,CAAC,MAAM,EAAE,IAAI,CAAC;IACd,CAAC,UAAU,EAAE,IAAI,CAAC;IAClB,CAAC,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