@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}
|
|
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
|
|
18
|
-
*
|
|
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
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
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
|
-
*
|
|
80
|
-
* history
|
|
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
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
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
|
-
/**
|
|
106
|
-
* Reflects WebKit's tracked `<title>`. */
|
|
71
|
+
/** WebKit's tracked `<title>`; empty before it is known. */
|
|
107
72
|
get pageTitle(): string;
|
|
108
|
-
/**
|
|
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
|
|
117
|
-
*
|
|
118
|
-
*
|
|
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
|
-
*
|
|
122
|
-
*
|
|
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)
|
|
131
|
-
*
|
|
132
|
-
*
|
|
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()`
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
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
|
|
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
|
|
158
|
-
* the
|
|
159
|
-
*
|
|
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
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
767
|
-
*
|
|
768
|
-
*
|
|
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
|
-
*
|
|
797
|
-
* history
|
|
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
|
-
*
|
|
800
|
-
*
|
|
801
|
-
*
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
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
|
-
/**
|
|
823
|
-
* Reflects WebKit's tracked `<title>`. */
|
|
753
|
+
/** WebKit's tracked `<title>`; empty before it is known. */
|
|
824
754
|
get pageTitle(): string;
|
|
825
|
-
/**
|
|
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
|
|
834
|
-
*
|
|
835
|
-
*
|
|
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
|
-
*
|
|
839
|
-
*
|
|
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)
|
|
848
|
-
*
|
|
849
|
-
*
|
|
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()`
|
|
858
|
-
*
|
|
859
|
-
*
|
|
860
|
-
*
|
|
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
|
|
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
|
|
875
|
-
* the
|
|
876
|
-
*
|
|
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
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
1484
|
-
*
|
|
1485
|
-
*
|
|
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
|
-
*
|
|
1514
|
-
* history
|
|
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
|
-
*
|
|
1517
|
-
*
|
|
1518
|
-
*
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
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
|
-
/**
|
|
1540
|
-
* Reflects WebKit's tracked `<title>`. */
|
|
1435
|
+
/** WebKit's tracked `<title>`; empty before it is known. */
|
|
1541
1436
|
get pageTitle(): string;
|
|
1542
|
-
/**
|
|
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
|
|
1551
|
-
*
|
|
1552
|
-
*
|
|
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
|
-
*
|
|
1556
|
-
*
|
|
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)
|
|
1565
|
-
*
|
|
1566
|
-
*
|
|
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()`
|
|
1575
|
-
*
|
|
1576
|
-
*
|
|
1577
|
-
*
|
|
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
|
|
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
|
|
1592
|
-
* the
|
|
1593
|
-
*
|
|
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
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
2201
|
-
*
|
|
2202
|
-
*
|
|
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
|
-
*
|
|
2231
|
-
* history
|
|
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
|
-
*
|
|
2234
|
-
*
|
|
2235
|
-
*
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
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
|
-
/**
|
|
2257
|
-
* Reflects WebKit's tracked `<title>`. */
|
|
2117
|
+
/** WebKit's tracked `<title>`; empty before it is known. */
|
|
2258
2118
|
get pageTitle(): string;
|
|
2259
|
-
/**
|
|
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
|
|
2268
|
-
*
|
|
2269
|
-
*
|
|
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
|
-
*
|
|
2273
|
-
*
|
|
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)
|
|
2282
|
-
*
|
|
2283
|
-
*
|
|
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()`
|
|
2292
|
-
*
|
|
2293
|
-
*
|
|
2294
|
-
*
|
|
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
|
|
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
|
|
2309
|
-
* the
|
|
2310
|
-
*
|
|
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
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
2918
|
-
*
|
|
2919
|
-
*
|
|
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
|
-
*
|
|
2948
|
-
* history
|
|
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
|
-
*
|
|
2951
|
-
*
|
|
2952
|
-
*
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
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
|
-
/**
|
|
2974
|
-
* Reflects WebKit's tracked `<title>`. */
|
|
2799
|
+
/** WebKit's tracked `<title>`; empty before it is known. */
|
|
2975
2800
|
get pageTitle(): string;
|
|
2976
|
-
/**
|
|
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
|
|
2985
|
-
*
|
|
2986
|
-
*
|
|
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
|
-
*
|
|
2990
|
-
*
|
|
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)
|
|
2999
|
-
*
|
|
3000
|
-
*
|
|
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()`
|
|
3009
|
-
*
|
|
3010
|
-
*
|
|
3011
|
-
*
|
|
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
|
|
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
|
|
3026
|
-
* the
|
|
3027
|
-
*
|
|
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
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
3635
|
-
*
|
|
3636
|
-
*
|
|
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
|
-
*
|
|
3665
|
-
* history
|
|
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
|
-
*
|
|
3668
|
-
*
|
|
3669
|
-
*
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
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
|
-
/**
|
|
3691
|
-
* Reflects WebKit's tracked `<title>`. */
|
|
3481
|
+
/** WebKit's tracked `<title>`; empty before it is known. */
|
|
3692
3482
|
get pageTitle(): string;
|
|
3693
|
-
/**
|
|
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
|
|
3702
|
-
*
|
|
3703
|
-
*
|
|
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
|
-
*
|
|
3707
|
-
*
|
|
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)
|
|
3716
|
-
*
|
|
3717
|
-
*
|
|
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()`
|
|
3726
|
-
*
|
|
3727
|
-
*
|
|
3728
|
-
*
|
|
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
|
|
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
|
|
3743
|
-
* the
|
|
3744
|
-
*
|
|
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
|
|
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
|
-
/**
|
|
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[]>;
|