@gjsify/iframe 0.35.0 → 0.37.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.
@@ -6,30 +6,20 @@ import { HTMLIFrameElement } from './html-iframe-element.js';
6
6
  import { MessageBridge } from './message-bridge.js';
7
7
  import './promisify.js';
8
8
  import type { ConsoleCallback, ConsoleLogEntry, IFrameBridgeOptions, IFrameReadyCallback, LoadErrorCallback, LoadErrorInfo } from './types/index.js';
9
- /** A pending {@link IFrameBridge.waitForNavigation} promise. `sourceId` is the
10
- * GLib timeout source backing its deadline (null when no timeout). */
9
+ /** A pending {@link IFrameBridge.waitForNavigation}; `sourceId` backs its deadline. */
11
10
  interface NavigationWaiter {
12
11
  resolve: () => void;
13
12
  reject: (error: Error) => void;
14
13
  sourceId: number | null;
15
14
  }
16
15
  /**
17
- * A `WebKit.WebView` subclass that handles iframe bootstrapping:
18
- * - Sets up WebKit settings (JavaScript, developer extras)
19
- * - Creates an `HTMLIFrameElement` wrapping this WebView
20
- * - Sets up postMessage bridge for GJS ↔ WebView communication
21
- * - Fires `onReady()` callbacks with the iframe element once loaded
22
- * - `installGlobals()` sets `globalThis.HTMLIFrameElement`
16
+ * A `WebKit.WebView` subclass that wraps itself in an `HTMLIFrameElement` and bridges
17
+ * postMessage between GJS and the page.
23
18
  *
24
- * Usage:
25
19
  * ```ts
26
20
  * const iframeWidget = new IFrameBridge();
27
21
  * iframeWidget.installGlobals();
28
- * iframeWidget.onReady((iframe) => {
29
- * iframe.contentWindow?.addEventListener('message', (e) => {
30
- * console.log('Message from iframe:', e.data);
31
- * });
32
- * });
22
+ * iframeWidget.onReady((iframe) => { … });
33
23
  * iframeWidget.iframeElement.src = 'https://example.com';
34
24
  * window.set_child(iframeWidget);
35
25
  * ```
@@ -46,107 +36,74 @@ export declare const IFrameBridge: {
46
36
  _lastLoadError: LoadErrorInfo | null;
47
37
  _loadErrorCallbacks: LoadErrorCallback[];
48
38
  /**
49
- * GTK4 allocation hook — surfaces WebKit.WebView size changes to any
50
- * ResizeObserver watching the paired HTMLIFrameElement (or an ancestor;
51
- * see notifyElementResize). GTK4 has no `resize` signal on Gtk.Widget
52
- * (only Gtk.DrawingArea/GLArea), so the allocation vfunc is the portable
53
- * way to observe the widget's size.
39
+ * Surfaces size changes to any ResizeObserver watching the paired
40
+ * HTMLIFrameElement or an ancestor. GTK4 has no `resize` signal on Gtk.Widget
41
+ * (only Gtk.DrawingArea/GLArea), so this vfunc is the portable way to see them.
54
42
  */
55
43
  vfunc_size_allocate(width: number, height: number, baseline: number): void;
56
44
  /** The HTMLIFrameElement wrapping this WebView. */
57
45
  get iframeElement(): HTMLIFrameElement;
58
- /**
59
- * Register a callback to be invoked when content has loaded.
60
- * If content is already loaded, the callback fires on next load.
61
- */
46
+ /** Runs `cb` when content has loaded — on the NEXT load if it already has. */
62
47
  onReady(cb: IFrameReadyCallback): void;
63
- /**
64
- * Load a URI into the WebView.
65
- * Also updates the iframe element's src attribute.
66
- */
48
+ /** Load a URI, keeping the iframe element's `src` attribute in step. */
67
49
  loadUri(uri: string): void;
68
- /**
69
- * Load inline HTML into the WebView.
70
- * Also updates the iframe element's srcdoc attribute.
71
- */
50
+ /** Load inline HTML, keeping the iframe element's `srcdoc` attribute in step. */
72
51
  loadHtml(html: string, baseUri?: string): void;
73
- /**
74
- * Send a message to the WebView content via the standard postMessage API.
75
- * Equivalent to `this.iframeElement.contentWindow.postMessage(message, targetOrigin)`.
76
- */
52
+ /** Equivalent to `iframeElement.contentWindow.postMessage(message, targetOrigin)`. */
77
53
  postMessage(message: unknown, targetOrigin?: string): void;
78
54
  /**
79
- * Navigate the embedded WebView back one entry in its internal
80
- * history list. No-op when `canGoBack` is false.
55
+ * Back one entry in WEBKIT's own history list, independent of any
56
+ * application-level history. No-op when `canGoBack` is false.
81
57
  *
82
- * Note: reflects WebKit's own navigation history (independent of
83
- * any application-level history the embedder maintains). The
84
- * browser `<iframe>` element has no equivalent — cross-origin
85
- * iframes cannot be navigated programmatically by the parent. For
86
- * cross-variant (browser + GJS) parity, embedders typically track
87
- * URLs themselves and call `loadUri(url)`; the methods here exist
88
- * for apps that DO want to expose the WebKit-internal back/forward
89
- * list directly (e.g. a "WebView with browser-like UX").
58
+ * The browser `<iframe>` has no equivalent (a parent cannot navigate a
59
+ * cross-origin iframe), so cross-variant parity means tracking URLs yourself and
60
+ * calling `loadUri(url)`.
90
61
  */
91
62
  goBack(): void;
92
- /** Navigate forward in the WebView's internal history. No-op when
93
- * `canGoForward` is false. See `goBack()` for caveats. */
63
+ /** Forward one entry. No-op when `canGoForward` is false; caveats as `goBack()`. */
94
64
  goForward(): void;
95
- /** True when the WebView has prior entries in its internal history.
96
- * Reflects WebKit's `can-go-back` state, NOT any application-level
97
- * history stack. */
65
+ /** WebKit's `can-go-back`, NOT any application-level history stack. */
98
66
  get canGoBack(): boolean;
99
- /** True when the WebView has forward entries in its internal history.
100
- * Reflects WebKit's `can-go-forward` state. */
67
+ /** WebKit's `can-go-forward`. */
101
68
  get canGoForward(): boolean;
102
- /** WebKit's ground-truth current URI (`about:blank` before any load).
103
- * Distinct from any application-side history the embedder maintains. */
69
+ /** WebKit's ground-truth current URI; `about:blank` before any load. */
104
70
  get currentUri(): string;
105
- /** The loaded document's title (empty string before it is known).
106
- * Reflects WebKit's tracked `<title>`. */
71
+ /** WebKit's tracked `<title>`; empty before it is known. */
107
72
  get pageTitle(): string;
108
- /** Detail of the most recent failed load, or null when the current
109
- * page loaded without a main-resource failure. */
73
+ /** The most recent failed load, or null when the current page had no failure. */
110
74
  get lastLoadError(): LoadErrorInfo | null;
111
75
  /** Subscribe to load failures (network / main-resource errors). */
112
76
  onLoadError(cb: LoadErrorCallback): void;
113
77
  /**
114
78
  * Evaluate a JavaScript *expression* in the page and return its value.
115
79
  *
116
- * The value is serialised to JSON in-page and parsed on the GJS host,
117
- * so objects/arrays/strings/numbers/booleans/null round-trip. A value
118
- * that is not JSON-serialisable (DOM node, function, circular object)
119
- * comes back as `undefined`. A thrown page error rejects the promise.
80
+ * The value round-trips through JSON, so anything not JSON-serialisable (DOM
81
+ * node, function, circular object) comes back as `undefined`; a thrown page error
82
+ * rejects the promise.
120
83
  *
121
- * Pass an expression, not statements — wrap multi-statement logic in an
122
- * IIFE that returns a value, e.g.
123
- * `evaluateJavaScript('(() => { const a = 1; return a + 1; })()')`.
124
- * This mirrors Playwright/Puppeteer `page.evaluate` ergonomics.
84
+ * An EXPRESSION, not statements: wrap multi-statement logic in an IIFE that
85
+ * returns a value, as `page.evaluate` requires.
125
86
  */
126
87
  evaluateJavaScript(expression: string): Promise<unknown>;
127
88
  /**
128
89
  * Capture the rendered web content as PNG bytes.
129
90
  *
130
- * `'full'` (default) snapshots the whole scrollable document; `'visible'`
131
- * snapshots only the current viewport. This goes through WebKit's own
132
- * `get_snapshot` — NOT a GSK widget snapshot — because WebKit composites
133
- * its content in a separate process, so a GTK-tree snapshot of the
91
+ * `'full'` (default) takes the whole scrollable document, `'visible'` the current
92
+ * viewport. Through WebKit's own `get_snapshot` and NOT a GSK widget snapshot,
93
+ * because WebKit composites in a separate process, so a GTK-tree snapshot of the
134
94
  * WebView can come back blank or stale.
135
95
  */
136
96
  takeScreenshot(region?: "full" | "visible"): Promise<Uint8Array>;
137
97
  /**
138
98
  * Resolve on the next load that finishes (`LoadEvent.FINISHED`).
139
99
  *
140
- * `onReady()` fires only once and is drained per load, so a
141
- * page-initiated navigation (link click, JS redirect, form submit,
142
- * meta-refresh) never re-triggers it. Register a `waitForNavigation()`
143
- * *before* triggering such a navigation. Rejects on a main-resource
144
- * load failure, or after `timeoutMs` (0 disables the timeout).
100
+ * `onReady()` is drained per load, so a page-initiated navigation (link click, JS
101
+ * redirect, form submit, meta-refresh) never re-triggers it — register this
102
+ * BEFORE triggering one. Rejects on a main-resource failure, or after `timeoutMs`
103
+ * (0 disables the timeout).
145
104
  */
146
105
  waitForNavigation(timeoutMs?: number): Promise<void>;
147
- /** Settle (and clear) every pending waitForNavigation() promise,
148
- * removing its timeout source. Resolves them on success; rejects with
149
- * `error` on a load failure. */
106
+ /** Settle and clear every pending waitForNavigation(), removing its timeout. */
150
107
  _settleNavigationWaiters(error: Error | null): void;
151
108
  /** Current size of the WebView content region, in widget pixels. */
152
109
  getViewportSize(): {
@@ -154,18 +111,16 @@ export declare const IFrameBridge: {
154
111
  height: number;
155
112
  };
156
113
  /**
157
- * Request a content-region size (e.g. for responsive testing). This sets
158
- * the widget's size request; the actual allocation still depends on the
159
- * parent layout, and `getViewportSize()` reflects the realised size.
114
+ * Request a content-region size, e.g. for responsive testing. Only a size REQUEST:
115
+ * the allocation still depends on the parent layout, and `getViewportSize()`
116
+ * reports what was realised.
160
117
  */
161
118
  setViewportSize(width: number, height: number): void;
162
- /** Buffered page `console.*` output. Empty unless the bridge was created
163
- * with `{ captureConsole: true }`. */
119
+ /** Buffered page `console.*` output; empty without `{ captureConsole: true }`. */
164
120
  getConsoleLogs(): ConsoleLogEntry[];
165
121
  /** Drop all buffered console entries. */
166
122
  clearConsoleLogs(): void;
167
- /** Subscribe to captured console entries as they arrive. Requires
168
- * `{ captureConsole: true }` to receive anything. */
123
+ /** Console entries as they arrive; needs `{ captureConsole: true }`. */
169
124
  onConsole(cb: ConsoleCallback): void;
170
125
  /** Every `<a href>` on the page (resolved href, trimmed text, title). */
171
126
  getLinks(): Promise<LinkInfo[]>;
@@ -763,107 +718,74 @@ export declare const IFrameBridge: {
763
718
  _lastLoadError: LoadErrorInfo | null;
764
719
  _loadErrorCallbacks: LoadErrorCallback[];
765
720
  /**
766
- * GTK4 allocation hook — surfaces WebKit.WebView size changes to any
767
- * ResizeObserver watching the paired HTMLIFrameElement (or an ancestor;
768
- * see notifyElementResize). GTK4 has no `resize` signal on Gtk.Widget
769
- * (only Gtk.DrawingArea/GLArea), so the allocation vfunc is the portable
770
- * way to observe the widget's size.
721
+ * Surfaces size changes to any ResizeObserver watching the paired
722
+ * HTMLIFrameElement or an ancestor. GTK4 has no `resize` signal on Gtk.Widget
723
+ * (only Gtk.DrawingArea/GLArea), so this vfunc is the portable way to see them.
771
724
  */
772
725
  vfunc_size_allocate(width: number, height: number, baseline: number): void;
773
726
  /** The HTMLIFrameElement wrapping this WebView. */
774
727
  get iframeElement(): HTMLIFrameElement;
775
- /**
776
- * Register a callback to be invoked when content has loaded.
777
- * If content is already loaded, the callback fires on next load.
778
- */
728
+ /** Runs `cb` when content has loaded — on the NEXT load if it already has. */
779
729
  onReady(cb: IFrameReadyCallback): void;
780
- /**
781
- * Load a URI into the WebView.
782
- * Also updates the iframe element's src attribute.
783
- */
730
+ /** Load a URI, keeping the iframe element's `src` attribute in step. */
784
731
  loadUri(uri: string): void;
785
- /**
786
- * Load inline HTML into the WebView.
787
- * Also updates the iframe element's srcdoc attribute.
788
- */
732
+ /** Load inline HTML, keeping the iframe element's `srcdoc` attribute in step. */
789
733
  loadHtml(html: string, baseUri?: string): void;
790
- /**
791
- * Send a message to the WebView content via the standard postMessage API.
792
- * Equivalent to `this.iframeElement.contentWindow.postMessage(message, targetOrigin)`.
793
- */
734
+ /** Equivalent to `iframeElement.contentWindow.postMessage(message, targetOrigin)`. */
794
735
  postMessage(message: unknown, targetOrigin?: string): void;
795
736
  /**
796
- * Navigate the embedded WebView back one entry in its internal
797
- * history list. No-op when `canGoBack` is false.
737
+ * Back one entry in WEBKIT's own history list, independent of any
738
+ * application-level history. No-op when `canGoBack` is false.
798
739
  *
799
- * Note: reflects WebKit's own navigation history (independent of
800
- * any application-level history the embedder maintains). The
801
- * browser `<iframe>` element has no equivalent — cross-origin
802
- * iframes cannot be navigated programmatically by the parent. For
803
- * cross-variant (browser + GJS) parity, embedders typically track
804
- * URLs themselves and call `loadUri(url)`; the methods here exist
805
- * for apps that DO want to expose the WebKit-internal back/forward
806
- * list directly (e.g. a "WebView with browser-like UX").
740
+ * The browser `<iframe>` has no equivalent (a parent cannot navigate a
741
+ * cross-origin iframe), so cross-variant parity means tracking URLs yourself and
742
+ * calling `loadUri(url)`.
807
743
  */
808
744
  goBack(): void;
809
- /** Navigate forward in the WebView's internal history. No-op when
810
- * `canGoForward` is false. See `goBack()` for caveats. */
745
+ /** Forward one entry. No-op when `canGoForward` is false; caveats as `goBack()`. */
811
746
  goForward(): void;
812
- /** True when the WebView has prior entries in its internal history.
813
- * Reflects WebKit's `can-go-back` state, NOT any application-level
814
- * history stack. */
747
+ /** WebKit's `can-go-back`, NOT any application-level history stack. */
815
748
  get canGoBack(): boolean;
816
- /** True when the WebView has forward entries in its internal history.
817
- * Reflects WebKit's `can-go-forward` state. */
749
+ /** WebKit's `can-go-forward`. */
818
750
  get canGoForward(): boolean;
819
- /** WebKit's ground-truth current URI (`about:blank` before any load).
820
- * Distinct from any application-side history the embedder maintains. */
751
+ /** WebKit's ground-truth current URI; `about:blank` before any load. */
821
752
  get currentUri(): string;
822
- /** The loaded document's title (empty string before it is known).
823
- * Reflects WebKit's tracked `<title>`. */
753
+ /** WebKit's tracked `<title>`; empty before it is known. */
824
754
  get pageTitle(): string;
825
- /** Detail of the most recent failed load, or null when the current
826
- * page loaded without a main-resource failure. */
755
+ /** The most recent failed load, or null when the current page had no failure. */
827
756
  get lastLoadError(): LoadErrorInfo | null;
828
757
  /** Subscribe to load failures (network / main-resource errors). */
829
758
  onLoadError(cb: LoadErrorCallback): void;
830
759
  /**
831
760
  * Evaluate a JavaScript *expression* in the page and return its value.
832
761
  *
833
- * The value is serialised to JSON in-page and parsed on the GJS host,
834
- * so objects/arrays/strings/numbers/booleans/null round-trip. A value
835
- * that is not JSON-serialisable (DOM node, function, circular object)
836
- * comes back as `undefined`. A thrown page error rejects the promise.
762
+ * The value round-trips through JSON, so anything not JSON-serialisable (DOM
763
+ * node, function, circular object) comes back as `undefined`; a thrown page error
764
+ * rejects the promise.
837
765
  *
838
- * Pass an expression, not statements — wrap multi-statement logic in an
839
- * IIFE that returns a value, e.g.
840
- * `evaluateJavaScript('(() => { const a = 1; return a + 1; })()')`.
841
- * This mirrors Playwright/Puppeteer `page.evaluate` ergonomics.
766
+ * An EXPRESSION, not statements: wrap multi-statement logic in an IIFE that
767
+ * returns a value, as `page.evaluate` requires.
842
768
  */
843
769
  evaluateJavaScript(expression: string): Promise<unknown>;
844
770
  /**
845
771
  * Capture the rendered web content as PNG bytes.
846
772
  *
847
- * `'full'` (default) snapshots the whole scrollable document; `'visible'`
848
- * snapshots only the current viewport. This goes through WebKit's own
849
- * `get_snapshot` — NOT a GSK widget snapshot — because WebKit composites
850
- * its content in a separate process, so a GTK-tree snapshot of the
773
+ * `'full'` (default) takes the whole scrollable document, `'visible'` the current
774
+ * viewport. Through WebKit's own `get_snapshot` and NOT a GSK widget snapshot,
775
+ * because WebKit composites in a separate process, so a GTK-tree snapshot of the
851
776
  * WebView can come back blank or stale.
852
777
  */
853
778
  takeScreenshot(region?: "full" | "visible"): Promise<Uint8Array>;
854
779
  /**
855
780
  * Resolve on the next load that finishes (`LoadEvent.FINISHED`).
856
781
  *
857
- * `onReady()` fires only once and is drained per load, so a
858
- * page-initiated navigation (link click, JS redirect, form submit,
859
- * meta-refresh) never re-triggers it. Register a `waitForNavigation()`
860
- * *before* triggering such a navigation. Rejects on a main-resource
861
- * load failure, or after `timeoutMs` (0 disables the timeout).
782
+ * `onReady()` is drained per load, so a page-initiated navigation (link click, JS
783
+ * redirect, form submit, meta-refresh) never re-triggers it — register this
784
+ * BEFORE triggering one. Rejects on a main-resource failure, or after `timeoutMs`
785
+ * (0 disables the timeout).
862
786
  */
863
787
  waitForNavigation(timeoutMs?: number): Promise<void>;
864
- /** Settle (and clear) every pending waitForNavigation() promise,
865
- * removing its timeout source. Resolves them on success; rejects with
866
- * `error` on a load failure. */
788
+ /** Settle and clear every pending waitForNavigation(), removing its timeout. */
867
789
  _settleNavigationWaiters(error: Error | null): void;
868
790
  /** Current size of the WebView content region, in widget pixels. */
869
791
  getViewportSize(): {
@@ -871,18 +793,16 @@ export declare const IFrameBridge: {
871
793
  height: number;
872
794
  };
873
795
  /**
874
- * Request a content-region size (e.g. for responsive testing). This sets
875
- * the widget's size request; the actual allocation still depends on the
876
- * parent layout, and `getViewportSize()` reflects the realised size.
796
+ * Request a content-region size, e.g. for responsive testing. Only a size REQUEST:
797
+ * the allocation still depends on the parent layout, and `getViewportSize()`
798
+ * reports what was realised.
877
799
  */
878
800
  setViewportSize(width: number, height: number): void;
879
- /** Buffered page `console.*` output. Empty unless the bridge was created
880
- * with `{ captureConsole: true }`. */
801
+ /** Buffered page `console.*` output; empty without `{ captureConsole: true }`. */
881
802
  getConsoleLogs(): ConsoleLogEntry[];
882
803
  /** Drop all buffered console entries. */
883
804
  clearConsoleLogs(): void;
884
- /** Subscribe to captured console entries as they arrive. Requires
885
- * `{ captureConsole: true }` to receive anything. */
805
+ /** Console entries as they arrive; needs `{ captureConsole: true }`. */
886
806
  onConsole(cb: ConsoleCallback): void;
887
807
  /** Every `<a href>` on the page (resolved href, trimmed text, title). */
888
808
  getLinks(): Promise<LinkInfo[]>;
@@ -1480,107 +1400,74 @@ export declare const IFrameBridge: {
1480
1400
  _lastLoadError: LoadErrorInfo | null;
1481
1401
  _loadErrorCallbacks: LoadErrorCallback[];
1482
1402
  /**
1483
- * GTK4 allocation hook — surfaces WebKit.WebView size changes to any
1484
- * ResizeObserver watching the paired HTMLIFrameElement (or an ancestor;
1485
- * see notifyElementResize). GTK4 has no `resize` signal on Gtk.Widget
1486
- * (only Gtk.DrawingArea/GLArea), so the allocation vfunc is the portable
1487
- * way to observe the widget's size.
1403
+ * Surfaces size changes to any ResizeObserver watching the paired
1404
+ * HTMLIFrameElement or an ancestor. GTK4 has no `resize` signal on Gtk.Widget
1405
+ * (only Gtk.DrawingArea/GLArea), so this vfunc is the portable way to see them.
1488
1406
  */
1489
1407
  vfunc_size_allocate(width: number, height: number, baseline: number): void;
1490
1408
  /** The HTMLIFrameElement wrapping this WebView. */
1491
1409
  get iframeElement(): HTMLIFrameElement;
1492
- /**
1493
- * Register a callback to be invoked when content has loaded.
1494
- * If content is already loaded, the callback fires on next load.
1495
- */
1410
+ /** Runs `cb` when content has loaded — on the NEXT load if it already has. */
1496
1411
  onReady(cb: IFrameReadyCallback): void;
1497
- /**
1498
- * Load a URI into the WebView.
1499
- * Also updates the iframe element's src attribute.
1500
- */
1412
+ /** Load a URI, keeping the iframe element's `src` attribute in step. */
1501
1413
  loadUri(uri: string): void;
1502
- /**
1503
- * Load inline HTML into the WebView.
1504
- * Also updates the iframe element's srcdoc attribute.
1505
- */
1414
+ /** Load inline HTML, keeping the iframe element's `srcdoc` attribute in step. */
1506
1415
  loadHtml(html: string, baseUri?: string): void;
1507
- /**
1508
- * Send a message to the WebView content via the standard postMessage API.
1509
- * Equivalent to `this.iframeElement.contentWindow.postMessage(message, targetOrigin)`.
1510
- */
1416
+ /** Equivalent to `iframeElement.contentWindow.postMessage(message, targetOrigin)`. */
1511
1417
  postMessage(message: unknown, targetOrigin?: string): void;
1512
1418
  /**
1513
- * Navigate the embedded WebView back one entry in its internal
1514
- * history list. No-op when `canGoBack` is false.
1419
+ * Back one entry in WEBKIT's own history list, independent of any
1420
+ * application-level history. No-op when `canGoBack` is false.
1515
1421
  *
1516
- * Note: reflects WebKit's own navigation history (independent of
1517
- * any application-level history the embedder maintains). The
1518
- * browser `<iframe>` element has no equivalent — cross-origin
1519
- * iframes cannot be navigated programmatically by the parent. For
1520
- * cross-variant (browser + GJS) parity, embedders typically track
1521
- * URLs themselves and call `loadUri(url)`; the methods here exist
1522
- * for apps that DO want to expose the WebKit-internal back/forward
1523
- * list directly (e.g. a "WebView with browser-like UX").
1422
+ * The browser `<iframe>` has no equivalent (a parent cannot navigate a
1423
+ * cross-origin iframe), so cross-variant parity means tracking URLs yourself and
1424
+ * calling `loadUri(url)`.
1524
1425
  */
1525
1426
  goBack(): void;
1526
- /** Navigate forward in the WebView's internal history. No-op when
1527
- * `canGoForward` is false. See `goBack()` for caveats. */
1427
+ /** Forward one entry. No-op when `canGoForward` is false; caveats as `goBack()`. */
1528
1428
  goForward(): void;
1529
- /** True when the WebView has prior entries in its internal history.
1530
- * Reflects WebKit's `can-go-back` state, NOT any application-level
1531
- * history stack. */
1429
+ /** WebKit's `can-go-back`, NOT any application-level history stack. */
1532
1430
  get canGoBack(): boolean;
1533
- /** True when the WebView has forward entries in its internal history.
1534
- * Reflects WebKit's `can-go-forward` state. */
1431
+ /** WebKit's `can-go-forward`. */
1535
1432
  get canGoForward(): boolean;
1536
- /** WebKit's ground-truth current URI (`about:blank` before any load).
1537
- * Distinct from any application-side history the embedder maintains. */
1433
+ /** WebKit's ground-truth current URI; `about:blank` before any load. */
1538
1434
  get currentUri(): string;
1539
- /** The loaded document's title (empty string before it is known).
1540
- * Reflects WebKit's tracked `<title>`. */
1435
+ /** WebKit's tracked `<title>`; empty before it is known. */
1541
1436
  get pageTitle(): string;
1542
- /** Detail of the most recent failed load, or null when the current
1543
- * page loaded without a main-resource failure. */
1437
+ /** The most recent failed load, or null when the current page had no failure. */
1544
1438
  get lastLoadError(): LoadErrorInfo | null;
1545
1439
  /** Subscribe to load failures (network / main-resource errors). */
1546
1440
  onLoadError(cb: LoadErrorCallback): void;
1547
1441
  /**
1548
1442
  * Evaluate a JavaScript *expression* in the page and return its value.
1549
1443
  *
1550
- * The value is serialised to JSON in-page and parsed on the GJS host,
1551
- * so objects/arrays/strings/numbers/booleans/null round-trip. A value
1552
- * that is not JSON-serialisable (DOM node, function, circular object)
1553
- * comes back as `undefined`. A thrown page error rejects the promise.
1444
+ * The value round-trips through JSON, so anything not JSON-serialisable (DOM
1445
+ * node, function, circular object) comes back as `undefined`; a thrown page error
1446
+ * rejects the promise.
1554
1447
  *
1555
- * Pass an expression, not statements — wrap multi-statement logic in an
1556
- * IIFE that returns a value, e.g.
1557
- * `evaluateJavaScript('(() => { const a = 1; return a + 1; })()')`.
1558
- * This mirrors Playwright/Puppeteer `page.evaluate` ergonomics.
1448
+ * An EXPRESSION, not statements: wrap multi-statement logic in an IIFE that
1449
+ * returns a value, as `page.evaluate` requires.
1559
1450
  */
1560
1451
  evaluateJavaScript(expression: string): Promise<unknown>;
1561
1452
  /**
1562
1453
  * Capture the rendered web content as PNG bytes.
1563
1454
  *
1564
- * `'full'` (default) snapshots the whole scrollable document; `'visible'`
1565
- * snapshots only the current viewport. This goes through WebKit's own
1566
- * `get_snapshot` — NOT a GSK widget snapshot — because WebKit composites
1567
- * its content in a separate process, so a GTK-tree snapshot of the
1455
+ * `'full'` (default) takes the whole scrollable document, `'visible'` the current
1456
+ * viewport. Through WebKit's own `get_snapshot` and NOT a GSK widget snapshot,
1457
+ * because WebKit composites in a separate process, so a GTK-tree snapshot of the
1568
1458
  * WebView can come back blank or stale.
1569
1459
  */
1570
1460
  takeScreenshot(region?: "full" | "visible"): Promise<Uint8Array>;
1571
1461
  /**
1572
1462
  * Resolve on the next load that finishes (`LoadEvent.FINISHED`).
1573
1463
  *
1574
- * `onReady()` fires only once and is drained per load, so a
1575
- * page-initiated navigation (link click, JS redirect, form submit,
1576
- * meta-refresh) never re-triggers it. Register a `waitForNavigation()`
1577
- * *before* triggering such a navigation. Rejects on a main-resource
1578
- * load failure, or after `timeoutMs` (0 disables the timeout).
1464
+ * `onReady()` is drained per load, so a page-initiated navigation (link click, JS
1465
+ * redirect, form submit, meta-refresh) never re-triggers it — register this
1466
+ * BEFORE triggering one. Rejects on a main-resource failure, or after `timeoutMs`
1467
+ * (0 disables the timeout).
1579
1468
  */
1580
1469
  waitForNavigation(timeoutMs?: number): Promise<void>;
1581
- /** Settle (and clear) every pending waitForNavigation() promise,
1582
- * removing its timeout source. Resolves them on success; rejects with
1583
- * `error` on a load failure. */
1470
+ /** Settle and clear every pending waitForNavigation(), removing its timeout. */
1584
1471
  _settleNavigationWaiters(error: Error | null): void;
1585
1472
  /** Current size of the WebView content region, in widget pixels. */
1586
1473
  getViewportSize(): {
@@ -1588,18 +1475,16 @@ export declare const IFrameBridge: {
1588
1475
  height: number;
1589
1476
  };
1590
1477
  /**
1591
- * Request a content-region size (e.g. for responsive testing). This sets
1592
- * the widget's size request; the actual allocation still depends on the
1593
- * parent layout, and `getViewportSize()` reflects the realised size.
1478
+ * Request a content-region size, e.g. for responsive testing. Only a size REQUEST:
1479
+ * the allocation still depends on the parent layout, and `getViewportSize()`
1480
+ * reports what was realised.
1594
1481
  */
1595
1482
  setViewportSize(width: number, height: number): void;
1596
- /** Buffered page `console.*` output. Empty unless the bridge was created
1597
- * with `{ captureConsole: true }`. */
1483
+ /** Buffered page `console.*` output; empty without `{ captureConsole: true }`. */
1598
1484
  getConsoleLogs(): ConsoleLogEntry[];
1599
1485
  /** Drop all buffered console entries. */
1600
1486
  clearConsoleLogs(): void;
1601
- /** Subscribe to captured console entries as they arrive. Requires
1602
- * `{ captureConsole: true }` to receive anything. */
1487
+ /** Console entries as they arrive; needs `{ captureConsole: true }`. */
1603
1488
  onConsole(cb: ConsoleCallback): void;
1604
1489
  /** Every `<a href>` on the page (resolved href, trimmed text, title). */
1605
1490
  getLinks(): Promise<LinkInfo[]>;
@@ -2197,107 +2082,74 @@ export declare const IFrameBridge: {
2197
2082
  _lastLoadError: LoadErrorInfo | null;
2198
2083
  _loadErrorCallbacks: LoadErrorCallback[];
2199
2084
  /**
2200
- * GTK4 allocation hook — surfaces WebKit.WebView size changes to any
2201
- * ResizeObserver watching the paired HTMLIFrameElement (or an ancestor;
2202
- * see notifyElementResize). GTK4 has no `resize` signal on Gtk.Widget
2203
- * (only Gtk.DrawingArea/GLArea), so the allocation vfunc is the portable
2204
- * way to observe the widget's size.
2085
+ * Surfaces size changes to any ResizeObserver watching the paired
2086
+ * HTMLIFrameElement or an ancestor. GTK4 has no `resize` signal on Gtk.Widget
2087
+ * (only Gtk.DrawingArea/GLArea), so this vfunc is the portable way to see them.
2205
2088
  */
2206
2089
  vfunc_size_allocate(width: number, height: number, baseline: number): void;
2207
2090
  /** The HTMLIFrameElement wrapping this WebView. */
2208
2091
  get iframeElement(): HTMLIFrameElement;
2209
- /**
2210
- * Register a callback to be invoked when content has loaded.
2211
- * If content is already loaded, the callback fires on next load.
2212
- */
2092
+ /** Runs `cb` when content has loaded — on the NEXT load if it already has. */
2213
2093
  onReady(cb: IFrameReadyCallback): void;
2214
- /**
2215
- * Load a URI into the WebView.
2216
- * Also updates the iframe element's src attribute.
2217
- */
2094
+ /** Load a URI, keeping the iframe element's `src` attribute in step. */
2218
2095
  loadUri(uri: string): void;
2219
- /**
2220
- * Load inline HTML into the WebView.
2221
- * Also updates the iframe element's srcdoc attribute.
2222
- */
2096
+ /** Load inline HTML, keeping the iframe element's `srcdoc` attribute in step. */
2223
2097
  loadHtml(html: string, baseUri?: string): void;
2224
- /**
2225
- * Send a message to the WebView content via the standard postMessage API.
2226
- * Equivalent to `this.iframeElement.contentWindow.postMessage(message, targetOrigin)`.
2227
- */
2098
+ /** Equivalent to `iframeElement.contentWindow.postMessage(message, targetOrigin)`. */
2228
2099
  postMessage(message: unknown, targetOrigin?: string): void;
2229
2100
  /**
2230
- * Navigate the embedded WebView back one entry in its internal
2231
- * history list. No-op when `canGoBack` is false.
2101
+ * Back one entry in WEBKIT's own history list, independent of any
2102
+ * application-level history. No-op when `canGoBack` is false.
2232
2103
  *
2233
- * Note: reflects WebKit's own navigation history (independent of
2234
- * any application-level history the embedder maintains). The
2235
- * browser `<iframe>` element has no equivalent — cross-origin
2236
- * iframes cannot be navigated programmatically by the parent. For
2237
- * cross-variant (browser + GJS) parity, embedders typically track
2238
- * URLs themselves and call `loadUri(url)`; the methods here exist
2239
- * for apps that DO want to expose the WebKit-internal back/forward
2240
- * list directly (e.g. a "WebView with browser-like UX").
2104
+ * The browser `<iframe>` has no equivalent (a parent cannot navigate a
2105
+ * cross-origin iframe), so cross-variant parity means tracking URLs yourself and
2106
+ * calling `loadUri(url)`.
2241
2107
  */
2242
2108
  goBack(): void;
2243
- /** Navigate forward in the WebView's internal history. No-op when
2244
- * `canGoForward` is false. See `goBack()` for caveats. */
2109
+ /** Forward one entry. No-op when `canGoForward` is false; caveats as `goBack()`. */
2245
2110
  goForward(): void;
2246
- /** True when the WebView has prior entries in its internal history.
2247
- * Reflects WebKit's `can-go-back` state, NOT any application-level
2248
- * history stack. */
2111
+ /** WebKit's `can-go-back`, NOT any application-level history stack. */
2249
2112
  get canGoBack(): boolean;
2250
- /** True when the WebView has forward entries in its internal history.
2251
- * Reflects WebKit's `can-go-forward` state. */
2113
+ /** WebKit's `can-go-forward`. */
2252
2114
  get canGoForward(): boolean;
2253
- /** WebKit's ground-truth current URI (`about:blank` before any load).
2254
- * Distinct from any application-side history the embedder maintains. */
2115
+ /** WebKit's ground-truth current URI; `about:blank` before any load. */
2255
2116
  get currentUri(): string;
2256
- /** The loaded document's title (empty string before it is known).
2257
- * Reflects WebKit's tracked `<title>`. */
2117
+ /** WebKit's tracked `<title>`; empty before it is known. */
2258
2118
  get pageTitle(): string;
2259
- /** Detail of the most recent failed load, or null when the current
2260
- * page loaded without a main-resource failure. */
2119
+ /** The most recent failed load, or null when the current page had no failure. */
2261
2120
  get lastLoadError(): LoadErrorInfo | null;
2262
2121
  /** Subscribe to load failures (network / main-resource errors). */
2263
2122
  onLoadError(cb: LoadErrorCallback): void;
2264
2123
  /**
2265
2124
  * Evaluate a JavaScript *expression* in the page and return its value.
2266
2125
  *
2267
- * The value is serialised to JSON in-page and parsed on the GJS host,
2268
- * so objects/arrays/strings/numbers/booleans/null round-trip. A value
2269
- * that is not JSON-serialisable (DOM node, function, circular object)
2270
- * comes back as `undefined`. A thrown page error rejects the promise.
2126
+ * The value round-trips through JSON, so anything not JSON-serialisable (DOM
2127
+ * node, function, circular object) comes back as `undefined`; a thrown page error
2128
+ * rejects the promise.
2271
2129
  *
2272
- * Pass an expression, not statements — wrap multi-statement logic in an
2273
- * IIFE that returns a value, e.g.
2274
- * `evaluateJavaScript('(() => { const a = 1; return a + 1; })()')`.
2275
- * This mirrors Playwright/Puppeteer `page.evaluate` ergonomics.
2130
+ * An EXPRESSION, not statements: wrap multi-statement logic in an IIFE that
2131
+ * returns a value, as `page.evaluate` requires.
2276
2132
  */
2277
2133
  evaluateJavaScript(expression: string): Promise<unknown>;
2278
2134
  /**
2279
2135
  * Capture the rendered web content as PNG bytes.
2280
2136
  *
2281
- * `'full'` (default) snapshots the whole scrollable document; `'visible'`
2282
- * snapshots only the current viewport. This goes through WebKit's own
2283
- * `get_snapshot` — NOT a GSK widget snapshot — because WebKit composites
2284
- * its content in a separate process, so a GTK-tree snapshot of the
2137
+ * `'full'` (default) takes the whole scrollable document, `'visible'` the current
2138
+ * viewport. Through WebKit's own `get_snapshot` and NOT a GSK widget snapshot,
2139
+ * because WebKit composites in a separate process, so a GTK-tree snapshot of the
2285
2140
  * WebView can come back blank or stale.
2286
2141
  */
2287
2142
  takeScreenshot(region?: "full" | "visible"): Promise<Uint8Array>;
2288
2143
  /**
2289
2144
  * Resolve on the next load that finishes (`LoadEvent.FINISHED`).
2290
2145
  *
2291
- * `onReady()` fires only once and is drained per load, so a
2292
- * page-initiated navigation (link click, JS redirect, form submit,
2293
- * meta-refresh) never re-triggers it. Register a `waitForNavigation()`
2294
- * *before* triggering such a navigation. Rejects on a main-resource
2295
- * load failure, or after `timeoutMs` (0 disables the timeout).
2146
+ * `onReady()` is drained per load, so a page-initiated navigation (link click, JS
2147
+ * redirect, form submit, meta-refresh) never re-triggers it — register this
2148
+ * BEFORE triggering one. Rejects on a main-resource failure, or after `timeoutMs`
2149
+ * (0 disables the timeout).
2296
2150
  */
2297
2151
  waitForNavigation(timeoutMs?: number): Promise<void>;
2298
- /** Settle (and clear) every pending waitForNavigation() promise,
2299
- * removing its timeout source. Resolves them on success; rejects with
2300
- * `error` on a load failure. */
2152
+ /** Settle and clear every pending waitForNavigation(), removing its timeout. */
2301
2153
  _settleNavigationWaiters(error: Error | null): void;
2302
2154
  /** Current size of the WebView content region, in widget pixels. */
2303
2155
  getViewportSize(): {
@@ -2305,18 +2157,16 @@ export declare const IFrameBridge: {
2305
2157
  height: number;
2306
2158
  };
2307
2159
  /**
2308
- * Request a content-region size (e.g. for responsive testing). This sets
2309
- * the widget's size request; the actual allocation still depends on the
2310
- * parent layout, and `getViewportSize()` reflects the realised size.
2160
+ * Request a content-region size, e.g. for responsive testing. Only a size REQUEST:
2161
+ * the allocation still depends on the parent layout, and `getViewportSize()`
2162
+ * reports what was realised.
2311
2163
  */
2312
2164
  setViewportSize(width: number, height: number): void;
2313
- /** Buffered page `console.*` output. Empty unless the bridge was created
2314
- * with `{ captureConsole: true }`. */
2165
+ /** Buffered page `console.*` output; empty without `{ captureConsole: true }`. */
2315
2166
  getConsoleLogs(): ConsoleLogEntry[];
2316
2167
  /** Drop all buffered console entries. */
2317
2168
  clearConsoleLogs(): void;
2318
- /** Subscribe to captured console entries as they arrive. Requires
2319
- * `{ captureConsole: true }` to receive anything. */
2169
+ /** Console entries as they arrive; needs `{ captureConsole: true }`. */
2320
2170
  onConsole(cb: ConsoleCallback): void;
2321
2171
  /** Every `<a href>` on the page (resolved href, trimmed text, title). */
2322
2172
  getLinks(): Promise<LinkInfo[]>;
@@ -2914,107 +2764,74 @@ export declare const IFrameBridge: {
2914
2764
  _lastLoadError: LoadErrorInfo | null;
2915
2765
  _loadErrorCallbacks: LoadErrorCallback[];
2916
2766
  /**
2917
- * GTK4 allocation hook — surfaces WebKit.WebView size changes to any
2918
- * ResizeObserver watching the paired HTMLIFrameElement (or an ancestor;
2919
- * see notifyElementResize). GTK4 has no `resize` signal on Gtk.Widget
2920
- * (only Gtk.DrawingArea/GLArea), so the allocation vfunc is the portable
2921
- * way to observe the widget's size.
2767
+ * Surfaces size changes to any ResizeObserver watching the paired
2768
+ * HTMLIFrameElement or an ancestor. GTK4 has no `resize` signal on Gtk.Widget
2769
+ * (only Gtk.DrawingArea/GLArea), so this vfunc is the portable way to see them.
2922
2770
  */
2923
2771
  vfunc_size_allocate(width: number, height: number, baseline: number): void;
2924
2772
  /** The HTMLIFrameElement wrapping this WebView. */
2925
2773
  get iframeElement(): HTMLIFrameElement;
2926
- /**
2927
- * Register a callback to be invoked when content has loaded.
2928
- * If content is already loaded, the callback fires on next load.
2929
- */
2774
+ /** Runs `cb` when content has loaded — on the NEXT load if it already has. */
2930
2775
  onReady(cb: IFrameReadyCallback): void;
2931
- /**
2932
- * Load a URI into the WebView.
2933
- * Also updates the iframe element's src attribute.
2934
- */
2776
+ /** Load a URI, keeping the iframe element's `src` attribute in step. */
2935
2777
  loadUri(uri: string): void;
2936
- /**
2937
- * Load inline HTML into the WebView.
2938
- * Also updates the iframe element's srcdoc attribute.
2939
- */
2778
+ /** Load inline HTML, keeping the iframe element's `srcdoc` attribute in step. */
2940
2779
  loadHtml(html: string, baseUri?: string): void;
2941
- /**
2942
- * Send a message to the WebView content via the standard postMessage API.
2943
- * Equivalent to `this.iframeElement.contentWindow.postMessage(message, targetOrigin)`.
2944
- */
2780
+ /** Equivalent to `iframeElement.contentWindow.postMessage(message, targetOrigin)`. */
2945
2781
  postMessage(message: unknown, targetOrigin?: string): void;
2946
2782
  /**
2947
- * Navigate the embedded WebView back one entry in its internal
2948
- * history list. No-op when `canGoBack` is false.
2783
+ * Back one entry in WEBKIT's own history list, independent of any
2784
+ * application-level history. No-op when `canGoBack` is false.
2949
2785
  *
2950
- * Note: reflects WebKit's own navigation history (independent of
2951
- * any application-level history the embedder maintains). The
2952
- * browser `<iframe>` element has no equivalent — cross-origin
2953
- * iframes cannot be navigated programmatically by the parent. For
2954
- * cross-variant (browser + GJS) parity, embedders typically track
2955
- * URLs themselves and call `loadUri(url)`; the methods here exist
2956
- * for apps that DO want to expose the WebKit-internal back/forward
2957
- * list directly (e.g. a "WebView with browser-like UX").
2786
+ * The browser `<iframe>` has no equivalent (a parent cannot navigate a
2787
+ * cross-origin iframe), so cross-variant parity means tracking URLs yourself and
2788
+ * calling `loadUri(url)`.
2958
2789
  */
2959
2790
  goBack(): void;
2960
- /** Navigate forward in the WebView's internal history. No-op when
2961
- * `canGoForward` is false. See `goBack()` for caveats. */
2791
+ /** Forward one entry. No-op when `canGoForward` is false; caveats as `goBack()`. */
2962
2792
  goForward(): void;
2963
- /** True when the WebView has prior entries in its internal history.
2964
- * Reflects WebKit's `can-go-back` state, NOT any application-level
2965
- * history stack. */
2793
+ /** WebKit's `can-go-back`, NOT any application-level history stack. */
2966
2794
  get canGoBack(): boolean;
2967
- /** True when the WebView has forward entries in its internal history.
2968
- * Reflects WebKit's `can-go-forward` state. */
2795
+ /** WebKit's `can-go-forward`. */
2969
2796
  get canGoForward(): boolean;
2970
- /** WebKit's ground-truth current URI (`about:blank` before any load).
2971
- * Distinct from any application-side history the embedder maintains. */
2797
+ /** WebKit's ground-truth current URI; `about:blank` before any load. */
2972
2798
  get currentUri(): string;
2973
- /** The loaded document's title (empty string before it is known).
2974
- * Reflects WebKit's tracked `<title>`. */
2799
+ /** WebKit's tracked `<title>`; empty before it is known. */
2975
2800
  get pageTitle(): string;
2976
- /** Detail of the most recent failed load, or null when the current
2977
- * page loaded without a main-resource failure. */
2801
+ /** The most recent failed load, or null when the current page had no failure. */
2978
2802
  get lastLoadError(): LoadErrorInfo | null;
2979
2803
  /** Subscribe to load failures (network / main-resource errors). */
2980
2804
  onLoadError(cb: LoadErrorCallback): void;
2981
2805
  /**
2982
2806
  * Evaluate a JavaScript *expression* in the page and return its value.
2983
2807
  *
2984
- * The value is serialised to JSON in-page and parsed on the GJS host,
2985
- * so objects/arrays/strings/numbers/booleans/null round-trip. A value
2986
- * that is not JSON-serialisable (DOM node, function, circular object)
2987
- * comes back as `undefined`. A thrown page error rejects the promise.
2808
+ * The value round-trips through JSON, so anything not JSON-serialisable (DOM
2809
+ * node, function, circular object) comes back as `undefined`; a thrown page error
2810
+ * rejects the promise.
2988
2811
  *
2989
- * Pass an expression, not statements — wrap multi-statement logic in an
2990
- * IIFE that returns a value, e.g.
2991
- * `evaluateJavaScript('(() => { const a = 1; return a + 1; })()')`.
2992
- * This mirrors Playwright/Puppeteer `page.evaluate` ergonomics.
2812
+ * An EXPRESSION, not statements: wrap multi-statement logic in an IIFE that
2813
+ * returns a value, as `page.evaluate` requires.
2993
2814
  */
2994
2815
  evaluateJavaScript(expression: string): Promise<unknown>;
2995
2816
  /**
2996
2817
  * Capture the rendered web content as PNG bytes.
2997
2818
  *
2998
- * `'full'` (default) snapshots the whole scrollable document; `'visible'`
2999
- * snapshots only the current viewport. This goes through WebKit's own
3000
- * `get_snapshot` — NOT a GSK widget snapshot — because WebKit composites
3001
- * its content in a separate process, so a GTK-tree snapshot of the
2819
+ * `'full'` (default) takes the whole scrollable document, `'visible'` the current
2820
+ * viewport. Through WebKit's own `get_snapshot` and NOT a GSK widget snapshot,
2821
+ * because WebKit composites in a separate process, so a GTK-tree snapshot of the
3002
2822
  * WebView can come back blank or stale.
3003
2823
  */
3004
2824
  takeScreenshot(region?: "full" | "visible"): Promise<Uint8Array>;
3005
2825
  /**
3006
2826
  * Resolve on the next load that finishes (`LoadEvent.FINISHED`).
3007
2827
  *
3008
- * `onReady()` fires only once and is drained per load, so a
3009
- * page-initiated navigation (link click, JS redirect, form submit,
3010
- * meta-refresh) never re-triggers it. Register a `waitForNavigation()`
3011
- * *before* triggering such a navigation. Rejects on a main-resource
3012
- * load failure, or after `timeoutMs` (0 disables the timeout).
2828
+ * `onReady()` is drained per load, so a page-initiated navigation (link click, JS
2829
+ * redirect, form submit, meta-refresh) never re-triggers it — register this
2830
+ * BEFORE triggering one. Rejects on a main-resource failure, or after `timeoutMs`
2831
+ * (0 disables the timeout).
3013
2832
  */
3014
2833
  waitForNavigation(timeoutMs?: number): Promise<void>;
3015
- /** Settle (and clear) every pending waitForNavigation() promise,
3016
- * removing its timeout source. Resolves them on success; rejects with
3017
- * `error` on a load failure. */
2834
+ /** Settle and clear every pending waitForNavigation(), removing its timeout. */
3018
2835
  _settleNavigationWaiters(error: Error | null): void;
3019
2836
  /** Current size of the WebView content region, in widget pixels. */
3020
2837
  getViewportSize(): {
@@ -3022,18 +2839,16 @@ export declare const IFrameBridge: {
3022
2839
  height: number;
3023
2840
  };
3024
2841
  /**
3025
- * Request a content-region size (e.g. for responsive testing). This sets
3026
- * the widget's size request; the actual allocation still depends on the
3027
- * parent layout, and `getViewportSize()` reflects the realised size.
2842
+ * Request a content-region size, e.g. for responsive testing. Only a size REQUEST:
2843
+ * the allocation still depends on the parent layout, and `getViewportSize()`
2844
+ * reports what was realised.
3028
2845
  */
3029
2846
  setViewportSize(width: number, height: number): void;
3030
- /** Buffered page `console.*` output. Empty unless the bridge was created
3031
- * with `{ captureConsole: true }`. */
2847
+ /** Buffered page `console.*` output; empty without `{ captureConsole: true }`. */
3032
2848
  getConsoleLogs(): ConsoleLogEntry[];
3033
2849
  /** Drop all buffered console entries. */
3034
2850
  clearConsoleLogs(): void;
3035
- /** Subscribe to captured console entries as they arrive. Requires
3036
- * `{ captureConsole: true }` to receive anything. */
2851
+ /** Console entries as they arrive; needs `{ captureConsole: true }`. */
3037
2852
  onConsole(cb: ConsoleCallback): void;
3038
2853
  /** Every `<a href>` on the page (resolved href, trimmed text, title). */
3039
2854
  getLinks(): Promise<LinkInfo[]>;
@@ -3631,107 +3446,74 @@ export declare const IFrameBridge: {
3631
3446
  _lastLoadError: LoadErrorInfo | null;
3632
3447
  _loadErrorCallbacks: LoadErrorCallback[];
3633
3448
  /**
3634
- * GTK4 allocation hook — surfaces WebKit.WebView size changes to any
3635
- * ResizeObserver watching the paired HTMLIFrameElement (or an ancestor;
3636
- * see notifyElementResize). GTK4 has no `resize` signal on Gtk.Widget
3637
- * (only Gtk.DrawingArea/GLArea), so the allocation vfunc is the portable
3638
- * way to observe the widget's size.
3449
+ * Surfaces size changes to any ResizeObserver watching the paired
3450
+ * HTMLIFrameElement or an ancestor. GTK4 has no `resize` signal on Gtk.Widget
3451
+ * (only Gtk.DrawingArea/GLArea), so this vfunc is the portable way to see them.
3639
3452
  */
3640
3453
  vfunc_size_allocate(width: number, height: number, baseline: number): void;
3641
3454
  /** The HTMLIFrameElement wrapping this WebView. */
3642
3455
  get iframeElement(): HTMLIFrameElement;
3643
- /**
3644
- * Register a callback to be invoked when content has loaded.
3645
- * If content is already loaded, the callback fires on next load.
3646
- */
3456
+ /** Runs `cb` when content has loaded — on the NEXT load if it already has. */
3647
3457
  onReady(cb: IFrameReadyCallback): void;
3648
- /**
3649
- * Load a URI into the WebView.
3650
- * Also updates the iframe element's src attribute.
3651
- */
3458
+ /** Load a URI, keeping the iframe element's `src` attribute in step. */
3652
3459
  loadUri(uri: string): void;
3653
- /**
3654
- * Load inline HTML into the WebView.
3655
- * Also updates the iframe element's srcdoc attribute.
3656
- */
3460
+ /** Load inline HTML, keeping the iframe element's `srcdoc` attribute in step. */
3657
3461
  loadHtml(html: string, baseUri?: string): void;
3658
- /**
3659
- * Send a message to the WebView content via the standard postMessage API.
3660
- * Equivalent to `this.iframeElement.contentWindow.postMessage(message, targetOrigin)`.
3661
- */
3462
+ /** Equivalent to `iframeElement.contentWindow.postMessage(message, targetOrigin)`. */
3662
3463
  postMessage(message: unknown, targetOrigin?: string): void;
3663
3464
  /**
3664
- * Navigate the embedded WebView back one entry in its internal
3665
- * history list. No-op when `canGoBack` is false.
3465
+ * Back one entry in WEBKIT's own history list, independent of any
3466
+ * application-level history. No-op when `canGoBack` is false.
3666
3467
  *
3667
- * Note: reflects WebKit's own navigation history (independent of
3668
- * any application-level history the embedder maintains). The
3669
- * browser `<iframe>` element has no equivalent — cross-origin
3670
- * iframes cannot be navigated programmatically by the parent. For
3671
- * cross-variant (browser + GJS) parity, embedders typically track
3672
- * URLs themselves and call `loadUri(url)`; the methods here exist
3673
- * for apps that DO want to expose the WebKit-internal back/forward
3674
- * list directly (e.g. a "WebView with browser-like UX").
3468
+ * The browser `<iframe>` has no equivalent (a parent cannot navigate a
3469
+ * cross-origin iframe), so cross-variant parity means tracking URLs yourself and
3470
+ * calling `loadUri(url)`.
3675
3471
  */
3676
3472
  goBack(): void;
3677
- /** Navigate forward in the WebView's internal history. No-op when
3678
- * `canGoForward` is false. See `goBack()` for caveats. */
3473
+ /** Forward one entry. No-op when `canGoForward` is false; caveats as `goBack()`. */
3679
3474
  goForward(): void;
3680
- /** True when the WebView has prior entries in its internal history.
3681
- * Reflects WebKit's `can-go-back` state, NOT any application-level
3682
- * history stack. */
3475
+ /** WebKit's `can-go-back`, NOT any application-level history stack. */
3683
3476
  get canGoBack(): boolean;
3684
- /** True when the WebView has forward entries in its internal history.
3685
- * Reflects WebKit's `can-go-forward` state. */
3477
+ /** WebKit's `can-go-forward`. */
3686
3478
  get canGoForward(): boolean;
3687
- /** WebKit's ground-truth current URI (`about:blank` before any load).
3688
- * Distinct from any application-side history the embedder maintains. */
3479
+ /** WebKit's ground-truth current URI; `about:blank` before any load. */
3689
3480
  get currentUri(): string;
3690
- /** The loaded document's title (empty string before it is known).
3691
- * Reflects WebKit's tracked `<title>`. */
3481
+ /** WebKit's tracked `<title>`; empty before it is known. */
3692
3482
  get pageTitle(): string;
3693
- /** Detail of the most recent failed load, or null when the current
3694
- * page loaded without a main-resource failure. */
3483
+ /** The most recent failed load, or null when the current page had no failure. */
3695
3484
  get lastLoadError(): LoadErrorInfo | null;
3696
3485
  /** Subscribe to load failures (network / main-resource errors). */
3697
3486
  onLoadError(cb: LoadErrorCallback): void;
3698
3487
  /**
3699
3488
  * Evaluate a JavaScript *expression* in the page and return its value.
3700
3489
  *
3701
- * The value is serialised to JSON in-page and parsed on the GJS host,
3702
- * so objects/arrays/strings/numbers/booleans/null round-trip. A value
3703
- * that is not JSON-serialisable (DOM node, function, circular object)
3704
- * comes back as `undefined`. A thrown page error rejects the promise.
3490
+ * The value round-trips through JSON, so anything not JSON-serialisable (DOM
3491
+ * node, function, circular object) comes back as `undefined`; a thrown page error
3492
+ * rejects the promise.
3705
3493
  *
3706
- * Pass an expression, not statements — wrap multi-statement logic in an
3707
- * IIFE that returns a value, e.g.
3708
- * `evaluateJavaScript('(() => { const a = 1; return a + 1; })()')`.
3709
- * This mirrors Playwright/Puppeteer `page.evaluate` ergonomics.
3494
+ * An EXPRESSION, not statements: wrap multi-statement logic in an IIFE that
3495
+ * returns a value, as `page.evaluate` requires.
3710
3496
  */
3711
3497
  evaluateJavaScript(expression: string): Promise<unknown>;
3712
3498
  /**
3713
3499
  * Capture the rendered web content as PNG bytes.
3714
3500
  *
3715
- * `'full'` (default) snapshots the whole scrollable document; `'visible'`
3716
- * snapshots only the current viewport. This goes through WebKit's own
3717
- * `get_snapshot` — NOT a GSK widget snapshot — because WebKit composites
3718
- * its content in a separate process, so a GTK-tree snapshot of the
3501
+ * `'full'` (default) takes the whole scrollable document, `'visible'` the current
3502
+ * viewport. Through WebKit's own `get_snapshot` and NOT a GSK widget snapshot,
3503
+ * because WebKit composites in a separate process, so a GTK-tree snapshot of the
3719
3504
  * WebView can come back blank or stale.
3720
3505
  */
3721
3506
  takeScreenshot(region?: "full" | "visible"): Promise<Uint8Array>;
3722
3507
  /**
3723
3508
  * Resolve on the next load that finishes (`LoadEvent.FINISHED`).
3724
3509
  *
3725
- * `onReady()` fires only once and is drained per load, so a
3726
- * page-initiated navigation (link click, JS redirect, form submit,
3727
- * meta-refresh) never re-triggers it. Register a `waitForNavigation()`
3728
- * *before* triggering such a navigation. Rejects on a main-resource
3729
- * load failure, or after `timeoutMs` (0 disables the timeout).
3510
+ * `onReady()` is drained per load, so a page-initiated navigation (link click, JS
3511
+ * redirect, form submit, meta-refresh) never re-triggers it — register this
3512
+ * BEFORE triggering one. Rejects on a main-resource failure, or after `timeoutMs`
3513
+ * (0 disables the timeout).
3730
3514
  */
3731
3515
  waitForNavigation(timeoutMs?: number): Promise<void>;
3732
- /** Settle (and clear) every pending waitForNavigation() promise,
3733
- * removing its timeout source. Resolves them on success; rejects with
3734
- * `error` on a load failure. */
3516
+ /** Settle and clear every pending waitForNavigation(), removing its timeout. */
3735
3517
  _settleNavigationWaiters(error: Error | null): void;
3736
3518
  /** Current size of the WebView content region, in widget pixels. */
3737
3519
  getViewportSize(): {
@@ -3739,18 +3521,16 @@ export declare const IFrameBridge: {
3739
3521
  height: number;
3740
3522
  };
3741
3523
  /**
3742
- * Request a content-region size (e.g. for responsive testing). This sets
3743
- * the widget's size request; the actual allocation still depends on the
3744
- * parent layout, and `getViewportSize()` reflects the realised size.
3524
+ * Request a content-region size, e.g. for responsive testing. Only a size REQUEST:
3525
+ * the allocation still depends on the parent layout, and `getViewportSize()`
3526
+ * reports what was realised.
3745
3527
  */
3746
3528
  setViewportSize(width: number, height: number): void;
3747
- /** Buffered page `console.*` output. Empty unless the bridge was created
3748
- * with `{ captureConsole: true }`. */
3529
+ /** Buffered page `console.*` output; empty without `{ captureConsole: true }`. */
3749
3530
  getConsoleLogs(): ConsoleLogEntry[];
3750
3531
  /** Drop all buffered console entries. */
3751
3532
  clearConsoleLogs(): void;
3752
- /** Subscribe to captured console entries as they arrive. Requires
3753
- * `{ captureConsole: true }` to receive anything. */
3533
+ /** Console entries as they arrive; needs `{ captureConsole: true }`. */
3754
3534
  onConsole(cb: ConsoleCallback): void;
3755
3535
  /** Every `<a href>` on the page (resolved href, trimmed text, title). */
3756
3536
  getLinks(): Promise<LinkInfo[]>;