@gjsify/iframe 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/console-capture.js +24 -0
- package/lib/esm/dom-queries.js +1 -0
- package/lib/esm/eval.js +1 -0
- package/lib/esm/iframe-bridge.js +1 -1
- package/lib/esm/message-bridge.js +5 -5
- package/lib/esm/promisify.js +1 -0
- package/lib/types/console-capture.d.ts +34 -0
- package/lib/types/console-capture.spec.d.ts +2 -0
- package/lib/types/dom-queries.d.ts +36 -0
- package/lib/types/dom-queries.spec.d.ts +2 -0
- package/lib/types/eval.d.ts +30 -0
- package/lib/types/eval.spec.d.ts +2 -0
- package/lib/types/iframe-bridge.d.ts +618 -55
- package/lib/types/message-bridge.d.ts +27 -1
- package/lib/types/promisify.d.ts +1 -0
- package/lib/types/types/index.d.ts +24 -0
- package/package.json +6 -6
|
@@ -1,8 +1,18 @@
|
|
|
1
|
+
import GLib from 'gi://GLib?version=2.0';
|
|
1
2
|
import GObject from 'gi://GObject';
|
|
2
3
|
import WebKit from 'gi://WebKit?version=6.0';
|
|
4
|
+
import { type ElementInfo, type LinkInfo } from './dom-queries.js';
|
|
3
5
|
import { HTMLIFrameElement } from './html-iframe-element.js';
|
|
4
6
|
import { MessageBridge } from './message-bridge.js';
|
|
5
|
-
import
|
|
7
|
+
import './promisify.js';
|
|
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). */
|
|
11
|
+
interface NavigationWaiter {
|
|
12
|
+
resolve: () => void;
|
|
13
|
+
reject: (error: Error) => void;
|
|
14
|
+
sourceId: number | null;
|
|
15
|
+
}
|
|
6
16
|
/**
|
|
7
17
|
* A `WebKit.WebView` subclass that handles iframe bootstrapping:
|
|
8
18
|
* - Sets up WebKit settings (JavaScript, developer extras)
|
|
@@ -30,6 +40,19 @@ export declare const IFrameBridge: {
|
|
|
30
40
|
_messageBridge: MessageBridge;
|
|
31
41
|
_readyCallbacks: IFrameReadyCallback[];
|
|
32
42
|
_options: IFrameBridgeOptions;
|
|
43
|
+
/** Pending waitForNavigation() promises, settled on the next load. */
|
|
44
|
+
_navigationWaiters: NavigationWaiter[];
|
|
45
|
+
/** Detail of the most recent failed load, or null after a fresh start. */
|
|
46
|
+
_lastLoadError: LoadErrorInfo | null;
|
|
47
|
+
_loadErrorCallbacks: LoadErrorCallback[];
|
|
48
|
+
/**
|
|
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.
|
|
54
|
+
*/
|
|
55
|
+
vfunc_size_allocate(width: number, height: number, baseline: number): void;
|
|
33
56
|
/** The HTMLIFrameElement wrapping this WebView. */
|
|
34
57
|
get iframeElement(): HTMLIFrameElement;
|
|
35
58
|
/**
|
|
@@ -76,6 +99,86 @@ export declare const IFrameBridge: {
|
|
|
76
99
|
/** True when the WebView has forward entries in its internal history.
|
|
77
100
|
* Reflects WebKit's `can-go-forward` state. */
|
|
78
101
|
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. */
|
|
104
|
+
get currentUri(): string;
|
|
105
|
+
/** The loaded document's title (empty string before it is known).
|
|
106
|
+
* Reflects WebKit's tracked `<title>`. */
|
|
107
|
+
get pageTitle(): string;
|
|
108
|
+
/** Detail of the most recent failed load, or null when the current
|
|
109
|
+
* page loaded without a main-resource failure. */
|
|
110
|
+
get lastLoadError(): LoadErrorInfo | null;
|
|
111
|
+
/** Subscribe to load failures (network / main-resource errors). */
|
|
112
|
+
onLoadError(cb: LoadErrorCallback): void;
|
|
113
|
+
/**
|
|
114
|
+
* Evaluate a JavaScript *expression* in the page and return its value.
|
|
115
|
+
*
|
|
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.
|
|
120
|
+
*
|
|
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.
|
|
125
|
+
*/
|
|
126
|
+
evaluateJavaScript(expression: string): Promise<unknown>;
|
|
127
|
+
/**
|
|
128
|
+
* Capture the rendered web content as PNG bytes.
|
|
129
|
+
*
|
|
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
|
|
134
|
+
* WebView can come back blank or stale.
|
|
135
|
+
*/
|
|
136
|
+
takeScreenshot(region?: "full" | "visible"): Promise<Uint8Array>;
|
|
137
|
+
/**
|
|
138
|
+
* Resolve on the next load that finishes (`LoadEvent.FINISHED`).
|
|
139
|
+
*
|
|
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).
|
|
145
|
+
*/
|
|
146
|
+
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. */
|
|
150
|
+
_settleNavigationWaiters(error: Error | null): void;
|
|
151
|
+
/** Current size of the WebView content region, in widget pixels. */
|
|
152
|
+
getViewportSize(): {
|
|
153
|
+
width: number;
|
|
154
|
+
height: number;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
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.
|
|
160
|
+
*/
|
|
161
|
+
setViewportSize(width: number, height: number): void;
|
|
162
|
+
/** Buffered page `console.*` output. Empty unless the bridge was created
|
|
163
|
+
* with `{ captureConsole: true }`. */
|
|
164
|
+
getConsoleLogs(): ConsoleLogEntry[];
|
|
165
|
+
/** Drop all buffered console entries. */
|
|
166
|
+
clearConsoleLogs(): void;
|
|
167
|
+
/** Subscribe to captured console entries as they arrive. Requires
|
|
168
|
+
* `{ captureConsole: true }` to receive anything. */
|
|
169
|
+
onConsole(cb: ConsoleCallback): void;
|
|
170
|
+
/** Every `<a href>` on the page (resolved href, trimmed text, title). */
|
|
171
|
+
getLinks(): Promise<LinkInfo[]>;
|
|
172
|
+
/** Metadata for elements matching a CSS selector (capped at `limit`). */
|
|
173
|
+
queryDom(selector: string, limit?: number): Promise<ElementInfo[]>;
|
|
174
|
+
/**
|
|
175
|
+
* Click the first element matching `selectorOrText` — a CSS selector, or
|
|
176
|
+
* (failing that) an `<a>` matched by exact trimmed text. Resolves to true
|
|
177
|
+
* when an element was found + clicked. Does NOT wait for navigation: to
|
|
178
|
+
* await a resulting page change, register `waitForNavigation()` *before*
|
|
179
|
+
* calling this, then await it (a fast navigation may finish first).
|
|
180
|
+
*/
|
|
181
|
+
clickElement(selectorOrText: string): Promise<boolean>;
|
|
79
182
|
/**
|
|
80
183
|
* Set `globalThis.HTMLIFrameElement` to the gjsify implementation.
|
|
81
184
|
*/
|
|
@@ -155,7 +258,7 @@ export declare const IFrameBridge: {
|
|
|
155
258
|
vfunc_insecure_content_detected(event: WebKit.InsecureContentEvent): void;
|
|
156
259
|
vfunc_leave_fullscreen(): boolean;
|
|
157
260
|
vfunc_load_changed(load_event: WebKit.LoadEvent): void;
|
|
158
|
-
vfunc_load_failed(load_event: WebKit.LoadEvent, failing_uri: string, error:
|
|
261
|
+
vfunc_load_failed(load_event: WebKit.LoadEvent, failing_uri: string, error: GLib.Error): boolean;
|
|
159
262
|
vfunc_load_failed_with_tls_errors(failing_uri: string, certificate: import("@girs/gio-2.0").default.TlsCertificate, errors: import("@girs/gio-2.0").default.TlsCertificateFlags): boolean;
|
|
160
263
|
vfunc_mouse_target_changed(hit_test_result: WebKit.HitTestResult, modifiers: number): void;
|
|
161
264
|
vfunc_permission_request(permission_request: WebKit.PermissionRequest): boolean;
|
|
@@ -173,9 +276,9 @@ export declare const IFrameBridge: {
|
|
|
173
276
|
vfunc_user_message_received(message: WebKit.UserMessage): boolean;
|
|
174
277
|
vfunc_web_process_crashed(): boolean;
|
|
175
278
|
vfunc_web_process_terminated(reason: WebKit.WebProcessTerminationReason): void;
|
|
176
|
-
call_async_javascript_function(body: string, length: bigint | number, _arguments:
|
|
177
|
-
call_async_javascript_function(body: string, length: bigint | number, _arguments:
|
|
178
|
-
call_async_javascript_function(body: string, length: bigint | number, _arguments:
|
|
279
|
+
call_async_javascript_function(body: string, length: bigint | number, _arguments: GLib.Variant | null, world_name: string | null, source_uri: string | null, cancellable: import("@girs/gio-2.0").default.Cancellable | null): globalThis.Promise<import("@girs/javascriptcore-6.0").default.Value>;
|
|
280
|
+
call_async_javascript_function(body: string, length: bigint | number, _arguments: GLib.Variant | null, world_name: string | null, source_uri: string | null, cancellable: import("@girs/gio-2.0").default.Cancellable | null, callback: import("@girs/gio-2.0").default.AsyncReadyCallback</*elided*/ any>): void;
|
|
281
|
+
call_async_javascript_function(body: string, length: bigint | number, _arguments: GLib.Variant | null, world_name: string | null, source_uri: string | null, cancellable: import("@girs/gio-2.0").default.Cancellable | null, callback?: import("@girs/gio-2.0").default.AsyncReadyCallback</*elided*/ any>): globalThis.Promise<import("@girs/javascriptcore-6.0").default.Value> | void;
|
|
179
282
|
call_async_javascript_function_finish(result: import("@girs/gio-2.0").default.AsyncResult): import("@girs/javascriptcore-6.0").default.Value;
|
|
180
283
|
can_execute_editing_command(command: string, cancellable: import("@girs/gio-2.0").default.Cancellable | null): globalThis.Promise<boolean>;
|
|
181
284
|
can_execute_editing_command(command: string, cancellable: import("@girs/gio-2.0").default.Cancellable | null, callback: import("@girs/gio-2.0").default.AsyncReadyCallback</*elided*/ any>): void;
|
|
@@ -233,7 +336,7 @@ export declare const IFrameBridge: {
|
|
|
233
336
|
is_editable(): boolean;
|
|
234
337
|
leave_immersive_mode(): void;
|
|
235
338
|
load_alternate_html(content: string, content_uri: string, base_uri: string | null): void;
|
|
236
|
-
load_bytes(bytes:
|
|
339
|
+
load_bytes(bytes: GLib.Bytes | Uint8Array, mime_type: string | null, encoding: string | null, base_uri: string | null): void;
|
|
237
340
|
load_html(content: string, base_uri: string | null): void;
|
|
238
341
|
load_plain_text(plain_text: string): void;
|
|
239
342
|
load_request(request: WebKit.URIRequest): void;
|
|
@@ -428,7 +531,6 @@ export declare const IFrameBridge: {
|
|
|
428
531
|
vfunc_root(): void;
|
|
429
532
|
vfunc_set_focus_child(child: import("@girs/gtk-4.0").default.Widget | null): void;
|
|
430
533
|
vfunc_show(): void;
|
|
431
|
-
vfunc_size_allocate(width: number, height: number, baseline: number): void;
|
|
432
534
|
vfunc_snapshot(snapshot: import("@girs/gtk-4.0").default.Snapshot): void;
|
|
433
535
|
vfunc_state_flags_changed(previous_state_flags: import("@girs/gtk-4.0").default.StateFlags): void;
|
|
434
536
|
vfunc_system_setting_changed(settings: import("@girs/gtk-4.0").default.SystemSetting): void;
|
|
@@ -437,7 +539,7 @@ export declare const IFrameBridge: {
|
|
|
437
539
|
vfunc_unroot(): void;
|
|
438
540
|
action_set_enabled(action_name: string, enabled: boolean): void;
|
|
439
541
|
activate(): boolean;
|
|
440
|
-
activate_action(name: string, args:
|
|
542
|
+
activate_action(name: string, args: GLib.Variant | null): boolean;
|
|
441
543
|
activate_default(): void;
|
|
442
544
|
add_controller(controller: import("@girs/gtk-4.0").default.EventController): void;
|
|
443
545
|
add_css_class(css_class: string): void;
|
|
@@ -609,7 +711,7 @@ export declare const IFrameBridge: {
|
|
|
609
711
|
freeze_notify(): void;
|
|
610
712
|
get_data(key: string): null;
|
|
611
713
|
get_property(property_name: string, value: GObject.Value | any): any;
|
|
612
|
-
get_qdata(quark:
|
|
714
|
+
get_qdata(quark: GLib.Quark): null;
|
|
613
715
|
getv(names: string[], values: (GObject.Value | any)[]): void;
|
|
614
716
|
is_floating(): boolean;
|
|
615
717
|
notify(property_name: string): void;
|
|
@@ -620,7 +722,7 @@ export declare const IFrameBridge: {
|
|
|
620
722
|
set_data(key: string, data: null): void;
|
|
621
723
|
set_property(property_name: string, value: GObject.Value | any): void;
|
|
622
724
|
steal_data(key: string): null;
|
|
623
|
-
steal_qdata(quark:
|
|
725
|
+
steal_qdata(quark: GLib.Quark): null;
|
|
624
726
|
thaw_notify(): void;
|
|
625
727
|
unref(): void;
|
|
626
728
|
watch_closure(closure: GObject.Closure): void;
|
|
@@ -640,6 +742,19 @@ export declare const IFrameBridge: {
|
|
|
640
742
|
_messageBridge: MessageBridge;
|
|
641
743
|
_readyCallbacks: IFrameReadyCallback[];
|
|
642
744
|
_options: IFrameBridgeOptions;
|
|
745
|
+
/** Pending waitForNavigation() promises, settled on the next load. */
|
|
746
|
+
_navigationWaiters: NavigationWaiter[];
|
|
747
|
+
/** Detail of the most recent failed load, or null after a fresh start. */
|
|
748
|
+
_lastLoadError: LoadErrorInfo | null;
|
|
749
|
+
_loadErrorCallbacks: LoadErrorCallback[];
|
|
750
|
+
/**
|
|
751
|
+
* GTK4 allocation hook — surfaces WebKit.WebView size changes to any
|
|
752
|
+
* ResizeObserver watching the paired HTMLIFrameElement (or an ancestor;
|
|
753
|
+
* see notifyElementResize). GTK4 has no `resize` signal on Gtk.Widget
|
|
754
|
+
* (only Gtk.DrawingArea/GLArea), so the allocation vfunc is the portable
|
|
755
|
+
* way to observe the widget's size.
|
|
756
|
+
*/
|
|
757
|
+
vfunc_size_allocate(width: number, height: number, baseline: number): void;
|
|
643
758
|
/** The HTMLIFrameElement wrapping this WebView. */
|
|
644
759
|
get iframeElement(): HTMLIFrameElement;
|
|
645
760
|
/**
|
|
@@ -686,6 +801,86 @@ export declare const IFrameBridge: {
|
|
|
686
801
|
/** True when the WebView has forward entries in its internal history.
|
|
687
802
|
* Reflects WebKit's `can-go-forward` state. */
|
|
688
803
|
get canGoForward(): boolean;
|
|
804
|
+
/** WebKit's ground-truth current URI (`about:blank` before any load).
|
|
805
|
+
* Distinct from any application-side history the embedder maintains. */
|
|
806
|
+
get currentUri(): string;
|
|
807
|
+
/** The loaded document's title (empty string before it is known).
|
|
808
|
+
* Reflects WebKit's tracked `<title>`. */
|
|
809
|
+
get pageTitle(): string;
|
|
810
|
+
/** Detail of the most recent failed load, or null when the current
|
|
811
|
+
* page loaded without a main-resource failure. */
|
|
812
|
+
get lastLoadError(): LoadErrorInfo | null;
|
|
813
|
+
/** Subscribe to load failures (network / main-resource errors). */
|
|
814
|
+
onLoadError(cb: LoadErrorCallback): void;
|
|
815
|
+
/**
|
|
816
|
+
* Evaluate a JavaScript *expression* in the page and return its value.
|
|
817
|
+
*
|
|
818
|
+
* The value is serialised to JSON in-page and parsed on the GJS host,
|
|
819
|
+
* so objects/arrays/strings/numbers/booleans/null round-trip. A value
|
|
820
|
+
* that is not JSON-serialisable (DOM node, function, circular object)
|
|
821
|
+
* comes back as `undefined`. A thrown page error rejects the promise.
|
|
822
|
+
*
|
|
823
|
+
* Pass an expression, not statements — wrap multi-statement logic in an
|
|
824
|
+
* IIFE that returns a value, e.g.
|
|
825
|
+
* `evaluateJavaScript('(() => { const a = 1; return a + 1; })()')`.
|
|
826
|
+
* This mirrors Playwright/Puppeteer `page.evaluate` ergonomics.
|
|
827
|
+
*/
|
|
828
|
+
evaluateJavaScript(expression: string): Promise<unknown>;
|
|
829
|
+
/**
|
|
830
|
+
* Capture the rendered web content as PNG bytes.
|
|
831
|
+
*
|
|
832
|
+
* `'full'` (default) snapshots the whole scrollable document; `'visible'`
|
|
833
|
+
* snapshots only the current viewport. This goes through WebKit's own
|
|
834
|
+
* `get_snapshot` — NOT a GSK widget snapshot — because WebKit composites
|
|
835
|
+
* its content in a separate process, so a GTK-tree snapshot of the
|
|
836
|
+
* WebView can come back blank or stale.
|
|
837
|
+
*/
|
|
838
|
+
takeScreenshot(region?: "full" | "visible"): Promise<Uint8Array>;
|
|
839
|
+
/**
|
|
840
|
+
* Resolve on the next load that finishes (`LoadEvent.FINISHED`).
|
|
841
|
+
*
|
|
842
|
+
* `onReady()` fires only once and is drained per load, so a
|
|
843
|
+
* page-initiated navigation (link click, JS redirect, form submit,
|
|
844
|
+
* meta-refresh) never re-triggers it. Register a `waitForNavigation()`
|
|
845
|
+
* *before* triggering such a navigation. Rejects on a main-resource
|
|
846
|
+
* load failure, or after `timeoutMs` (0 disables the timeout).
|
|
847
|
+
*/
|
|
848
|
+
waitForNavigation(timeoutMs?: number): Promise<void>;
|
|
849
|
+
/** Settle (and clear) every pending waitForNavigation() promise,
|
|
850
|
+
* removing its timeout source. Resolves them on success; rejects with
|
|
851
|
+
* `error` on a load failure. */
|
|
852
|
+
_settleNavigationWaiters(error: Error | null): void;
|
|
853
|
+
/** Current size of the WebView content region, in widget pixels. */
|
|
854
|
+
getViewportSize(): {
|
|
855
|
+
width: number;
|
|
856
|
+
height: number;
|
|
857
|
+
};
|
|
858
|
+
/**
|
|
859
|
+
* Request a content-region size (e.g. for responsive testing). This sets
|
|
860
|
+
* the widget's size request; the actual allocation still depends on the
|
|
861
|
+
* parent layout, and `getViewportSize()` reflects the realised size.
|
|
862
|
+
*/
|
|
863
|
+
setViewportSize(width: number, height: number): void;
|
|
864
|
+
/** Buffered page `console.*` output. Empty unless the bridge was created
|
|
865
|
+
* with `{ captureConsole: true }`. */
|
|
866
|
+
getConsoleLogs(): ConsoleLogEntry[];
|
|
867
|
+
/** Drop all buffered console entries. */
|
|
868
|
+
clearConsoleLogs(): void;
|
|
869
|
+
/** Subscribe to captured console entries as they arrive. Requires
|
|
870
|
+
* `{ captureConsole: true }` to receive anything. */
|
|
871
|
+
onConsole(cb: ConsoleCallback): void;
|
|
872
|
+
/** Every `<a href>` on the page (resolved href, trimmed text, title). */
|
|
873
|
+
getLinks(): Promise<LinkInfo[]>;
|
|
874
|
+
/** Metadata for elements matching a CSS selector (capped at `limit`). */
|
|
875
|
+
queryDom(selector: string, limit?: number): Promise<ElementInfo[]>;
|
|
876
|
+
/**
|
|
877
|
+
* Click the first element matching `selectorOrText` — a CSS selector, or
|
|
878
|
+
* (failing that) an `<a>` matched by exact trimmed text. Resolves to true
|
|
879
|
+
* when an element was found + clicked. Does NOT wait for navigation: to
|
|
880
|
+
* await a resulting page change, register `waitForNavigation()` *before*
|
|
881
|
+
* calling this, then await it (a fast navigation may finish first).
|
|
882
|
+
*/
|
|
883
|
+
clickElement(selectorOrText: string): Promise<boolean>;
|
|
689
884
|
/**
|
|
690
885
|
* Set `globalThis.HTMLIFrameElement` to the gjsify implementation.
|
|
691
886
|
*/
|
|
@@ -765,7 +960,7 @@ export declare const IFrameBridge: {
|
|
|
765
960
|
vfunc_insecure_content_detected(event: WebKit.InsecureContentEvent): void;
|
|
766
961
|
vfunc_leave_fullscreen(): boolean;
|
|
767
962
|
vfunc_load_changed(load_event: WebKit.LoadEvent): void;
|
|
768
|
-
vfunc_load_failed(load_event: WebKit.LoadEvent, failing_uri: string, error:
|
|
963
|
+
vfunc_load_failed(load_event: WebKit.LoadEvent, failing_uri: string, error: GLib.Error): boolean;
|
|
769
964
|
vfunc_load_failed_with_tls_errors(failing_uri: string, certificate: import("@girs/gio-2.0").default.TlsCertificate, errors: import("@girs/gio-2.0").default.TlsCertificateFlags): boolean;
|
|
770
965
|
vfunc_mouse_target_changed(hit_test_result: WebKit.HitTestResult, modifiers: number): void;
|
|
771
966
|
vfunc_permission_request(permission_request: WebKit.PermissionRequest): boolean;
|
|
@@ -783,9 +978,9 @@ export declare const IFrameBridge: {
|
|
|
783
978
|
vfunc_user_message_received(message: WebKit.UserMessage): boolean;
|
|
784
979
|
vfunc_web_process_crashed(): boolean;
|
|
785
980
|
vfunc_web_process_terminated(reason: WebKit.WebProcessTerminationReason): void;
|
|
786
|
-
call_async_javascript_function(body: string, length: bigint | number, _arguments:
|
|
787
|
-
call_async_javascript_function(body: string, length: bigint | number, _arguments:
|
|
788
|
-
call_async_javascript_function(body: string, length: bigint | number, _arguments:
|
|
981
|
+
call_async_javascript_function(body: string, length: bigint | number, _arguments: GLib.Variant | null, world_name: string | null, source_uri: string | null, cancellable: import("@girs/gio-2.0").default.Cancellable | null): globalThis.Promise<import("@girs/javascriptcore-6.0").default.Value>;
|
|
982
|
+
call_async_javascript_function(body: string, length: bigint | number, _arguments: GLib.Variant | null, world_name: string | null, source_uri: string | null, cancellable: import("@girs/gio-2.0").default.Cancellable | null, callback: import("@girs/gio-2.0").default.AsyncReadyCallback</*elided*/ any>): void;
|
|
983
|
+
call_async_javascript_function(body: string, length: bigint | number, _arguments: GLib.Variant | null, world_name: string | null, source_uri: string | null, cancellable: import("@girs/gio-2.0").default.Cancellable | null, callback?: import("@girs/gio-2.0").default.AsyncReadyCallback</*elided*/ any>): globalThis.Promise<import("@girs/javascriptcore-6.0").default.Value> | void;
|
|
789
984
|
call_async_javascript_function_finish(result: import("@girs/gio-2.0").default.AsyncResult): import("@girs/javascriptcore-6.0").default.Value;
|
|
790
985
|
can_execute_editing_command(command: string, cancellable: import("@girs/gio-2.0").default.Cancellable | null): globalThis.Promise<boolean>;
|
|
791
986
|
can_execute_editing_command(command: string, cancellable: import("@girs/gio-2.0").default.Cancellable | null, callback: import("@girs/gio-2.0").default.AsyncReadyCallback</*elided*/ any>): void;
|
|
@@ -843,7 +1038,7 @@ export declare const IFrameBridge: {
|
|
|
843
1038
|
is_editable(): boolean;
|
|
844
1039
|
leave_immersive_mode(): void;
|
|
845
1040
|
load_alternate_html(content: string, content_uri: string, base_uri: string | null): void;
|
|
846
|
-
load_bytes(bytes:
|
|
1041
|
+
load_bytes(bytes: GLib.Bytes | Uint8Array, mime_type: string | null, encoding: string | null, base_uri: string | null): void;
|
|
847
1042
|
load_html(content: string, base_uri: string | null): void;
|
|
848
1043
|
load_plain_text(plain_text: string): void;
|
|
849
1044
|
load_request(request: WebKit.URIRequest): void;
|
|
@@ -1038,7 +1233,6 @@ export declare const IFrameBridge: {
|
|
|
1038
1233
|
vfunc_root(): void;
|
|
1039
1234
|
vfunc_set_focus_child(child: import("@girs/gtk-4.0").default.Widget | null): void;
|
|
1040
1235
|
vfunc_show(): void;
|
|
1041
|
-
vfunc_size_allocate(width: number, height: number, baseline: number): void;
|
|
1042
1236
|
vfunc_snapshot(snapshot: import("@girs/gtk-4.0").default.Snapshot): void;
|
|
1043
1237
|
vfunc_state_flags_changed(previous_state_flags: import("@girs/gtk-4.0").default.StateFlags): void;
|
|
1044
1238
|
vfunc_system_setting_changed(settings: import("@girs/gtk-4.0").default.SystemSetting): void;
|
|
@@ -1047,7 +1241,7 @@ export declare const IFrameBridge: {
|
|
|
1047
1241
|
vfunc_unroot(): void;
|
|
1048
1242
|
action_set_enabled(action_name: string, enabled: boolean): void;
|
|
1049
1243
|
activate(): boolean;
|
|
1050
|
-
activate_action(name: string, args:
|
|
1244
|
+
activate_action(name: string, args: GLib.Variant | null): boolean;
|
|
1051
1245
|
activate_default(): void;
|
|
1052
1246
|
add_controller(controller: import("@girs/gtk-4.0").default.EventController): void;
|
|
1053
1247
|
add_css_class(css_class: string): void;
|
|
@@ -1219,7 +1413,7 @@ export declare const IFrameBridge: {
|
|
|
1219
1413
|
freeze_notify(): void;
|
|
1220
1414
|
get_data(key: string): null;
|
|
1221
1415
|
get_property(property_name: string, value: GObject.Value | any): any;
|
|
1222
|
-
get_qdata(quark:
|
|
1416
|
+
get_qdata(quark: GLib.Quark): null;
|
|
1223
1417
|
getv(names: string[], values: (GObject.Value | any)[]): void;
|
|
1224
1418
|
is_floating(): boolean;
|
|
1225
1419
|
notify(property_name: string): void;
|
|
@@ -1230,7 +1424,7 @@ export declare const IFrameBridge: {
|
|
|
1230
1424
|
set_data(key: string, data: null): void;
|
|
1231
1425
|
set_property(property_name: string, value: GObject.Value | any): void;
|
|
1232
1426
|
steal_data(key: string): null;
|
|
1233
|
-
steal_qdata(quark:
|
|
1427
|
+
steal_qdata(quark: GLib.Quark): null;
|
|
1234
1428
|
thaw_notify(): void;
|
|
1235
1429
|
unref(): void;
|
|
1236
1430
|
watch_closure(closure: GObject.Closure): void;
|
|
@@ -1250,6 +1444,19 @@ export declare const IFrameBridge: {
|
|
|
1250
1444
|
_messageBridge: MessageBridge;
|
|
1251
1445
|
_readyCallbacks: IFrameReadyCallback[];
|
|
1252
1446
|
_options: IFrameBridgeOptions;
|
|
1447
|
+
/** Pending waitForNavigation() promises, settled on the next load. */
|
|
1448
|
+
_navigationWaiters: NavigationWaiter[];
|
|
1449
|
+
/** Detail of the most recent failed load, or null after a fresh start. */
|
|
1450
|
+
_lastLoadError: LoadErrorInfo | null;
|
|
1451
|
+
_loadErrorCallbacks: LoadErrorCallback[];
|
|
1452
|
+
/**
|
|
1453
|
+
* GTK4 allocation hook — surfaces WebKit.WebView size changes to any
|
|
1454
|
+
* ResizeObserver watching the paired HTMLIFrameElement (or an ancestor;
|
|
1455
|
+
* see notifyElementResize). GTK4 has no `resize` signal on Gtk.Widget
|
|
1456
|
+
* (only Gtk.DrawingArea/GLArea), so the allocation vfunc is the portable
|
|
1457
|
+
* way to observe the widget's size.
|
|
1458
|
+
*/
|
|
1459
|
+
vfunc_size_allocate(width: number, height: number, baseline: number): void;
|
|
1253
1460
|
/** The HTMLIFrameElement wrapping this WebView. */
|
|
1254
1461
|
get iframeElement(): HTMLIFrameElement;
|
|
1255
1462
|
/**
|
|
@@ -1296,6 +1503,86 @@ export declare const IFrameBridge: {
|
|
|
1296
1503
|
/** True when the WebView has forward entries in its internal history.
|
|
1297
1504
|
* Reflects WebKit's `can-go-forward` state. */
|
|
1298
1505
|
get canGoForward(): boolean;
|
|
1506
|
+
/** WebKit's ground-truth current URI (`about:blank` before any load).
|
|
1507
|
+
* Distinct from any application-side history the embedder maintains. */
|
|
1508
|
+
get currentUri(): string;
|
|
1509
|
+
/** The loaded document's title (empty string before it is known).
|
|
1510
|
+
* Reflects WebKit's tracked `<title>`. */
|
|
1511
|
+
get pageTitle(): string;
|
|
1512
|
+
/** Detail of the most recent failed load, or null when the current
|
|
1513
|
+
* page loaded without a main-resource failure. */
|
|
1514
|
+
get lastLoadError(): LoadErrorInfo | null;
|
|
1515
|
+
/** Subscribe to load failures (network / main-resource errors). */
|
|
1516
|
+
onLoadError(cb: LoadErrorCallback): void;
|
|
1517
|
+
/**
|
|
1518
|
+
* Evaluate a JavaScript *expression* in the page and return its value.
|
|
1519
|
+
*
|
|
1520
|
+
* The value is serialised to JSON in-page and parsed on the GJS host,
|
|
1521
|
+
* so objects/arrays/strings/numbers/booleans/null round-trip. A value
|
|
1522
|
+
* that is not JSON-serialisable (DOM node, function, circular object)
|
|
1523
|
+
* comes back as `undefined`. A thrown page error rejects the promise.
|
|
1524
|
+
*
|
|
1525
|
+
* Pass an expression, not statements — wrap multi-statement logic in an
|
|
1526
|
+
* IIFE that returns a value, e.g.
|
|
1527
|
+
* `evaluateJavaScript('(() => { const a = 1; return a + 1; })()')`.
|
|
1528
|
+
* This mirrors Playwright/Puppeteer `page.evaluate` ergonomics.
|
|
1529
|
+
*/
|
|
1530
|
+
evaluateJavaScript(expression: string): Promise<unknown>;
|
|
1531
|
+
/**
|
|
1532
|
+
* Capture the rendered web content as PNG bytes.
|
|
1533
|
+
*
|
|
1534
|
+
* `'full'` (default) snapshots the whole scrollable document; `'visible'`
|
|
1535
|
+
* snapshots only the current viewport. This goes through WebKit's own
|
|
1536
|
+
* `get_snapshot` — NOT a GSK widget snapshot — because WebKit composites
|
|
1537
|
+
* its content in a separate process, so a GTK-tree snapshot of the
|
|
1538
|
+
* WebView can come back blank or stale.
|
|
1539
|
+
*/
|
|
1540
|
+
takeScreenshot(region?: "full" | "visible"): Promise<Uint8Array>;
|
|
1541
|
+
/**
|
|
1542
|
+
* Resolve on the next load that finishes (`LoadEvent.FINISHED`).
|
|
1543
|
+
*
|
|
1544
|
+
* `onReady()` fires only once and is drained per load, so a
|
|
1545
|
+
* page-initiated navigation (link click, JS redirect, form submit,
|
|
1546
|
+
* meta-refresh) never re-triggers it. Register a `waitForNavigation()`
|
|
1547
|
+
* *before* triggering such a navigation. Rejects on a main-resource
|
|
1548
|
+
* load failure, or after `timeoutMs` (0 disables the timeout).
|
|
1549
|
+
*/
|
|
1550
|
+
waitForNavigation(timeoutMs?: number): Promise<void>;
|
|
1551
|
+
/** Settle (and clear) every pending waitForNavigation() promise,
|
|
1552
|
+
* removing its timeout source. Resolves them on success; rejects with
|
|
1553
|
+
* `error` on a load failure. */
|
|
1554
|
+
_settleNavigationWaiters(error: Error | null): void;
|
|
1555
|
+
/** Current size of the WebView content region, in widget pixels. */
|
|
1556
|
+
getViewportSize(): {
|
|
1557
|
+
width: number;
|
|
1558
|
+
height: number;
|
|
1559
|
+
};
|
|
1560
|
+
/**
|
|
1561
|
+
* Request a content-region size (e.g. for responsive testing). This sets
|
|
1562
|
+
* the widget's size request; the actual allocation still depends on the
|
|
1563
|
+
* parent layout, and `getViewportSize()` reflects the realised size.
|
|
1564
|
+
*/
|
|
1565
|
+
setViewportSize(width: number, height: number): void;
|
|
1566
|
+
/** Buffered page `console.*` output. Empty unless the bridge was created
|
|
1567
|
+
* with `{ captureConsole: true }`. */
|
|
1568
|
+
getConsoleLogs(): ConsoleLogEntry[];
|
|
1569
|
+
/** Drop all buffered console entries. */
|
|
1570
|
+
clearConsoleLogs(): void;
|
|
1571
|
+
/** Subscribe to captured console entries as they arrive. Requires
|
|
1572
|
+
* `{ captureConsole: true }` to receive anything. */
|
|
1573
|
+
onConsole(cb: ConsoleCallback): void;
|
|
1574
|
+
/** Every `<a href>` on the page (resolved href, trimmed text, title). */
|
|
1575
|
+
getLinks(): Promise<LinkInfo[]>;
|
|
1576
|
+
/** Metadata for elements matching a CSS selector (capped at `limit`). */
|
|
1577
|
+
queryDom(selector: string, limit?: number): Promise<ElementInfo[]>;
|
|
1578
|
+
/**
|
|
1579
|
+
* Click the first element matching `selectorOrText` — a CSS selector, or
|
|
1580
|
+
* (failing that) an `<a>` matched by exact trimmed text. Resolves to true
|
|
1581
|
+
* when an element was found + clicked. Does NOT wait for navigation: to
|
|
1582
|
+
* await a resulting page change, register `waitForNavigation()` *before*
|
|
1583
|
+
* calling this, then await it (a fast navigation may finish first).
|
|
1584
|
+
*/
|
|
1585
|
+
clickElement(selectorOrText: string): Promise<boolean>;
|
|
1299
1586
|
/**
|
|
1300
1587
|
* Set `globalThis.HTMLIFrameElement` to the gjsify implementation.
|
|
1301
1588
|
*/
|
|
@@ -1375,7 +1662,7 @@ export declare const IFrameBridge: {
|
|
|
1375
1662
|
vfunc_insecure_content_detected(event: WebKit.InsecureContentEvent): void;
|
|
1376
1663
|
vfunc_leave_fullscreen(): boolean;
|
|
1377
1664
|
vfunc_load_changed(load_event: WebKit.LoadEvent): void;
|
|
1378
|
-
vfunc_load_failed(load_event: WebKit.LoadEvent, failing_uri: string, error:
|
|
1665
|
+
vfunc_load_failed(load_event: WebKit.LoadEvent, failing_uri: string, error: GLib.Error): boolean;
|
|
1379
1666
|
vfunc_load_failed_with_tls_errors(failing_uri: string, certificate: import("@girs/gio-2.0").default.TlsCertificate, errors: import("@girs/gio-2.0").default.TlsCertificateFlags): boolean;
|
|
1380
1667
|
vfunc_mouse_target_changed(hit_test_result: WebKit.HitTestResult, modifiers: number): void;
|
|
1381
1668
|
vfunc_permission_request(permission_request: WebKit.PermissionRequest): boolean;
|
|
@@ -1393,9 +1680,9 @@ export declare const IFrameBridge: {
|
|
|
1393
1680
|
vfunc_user_message_received(message: WebKit.UserMessage): boolean;
|
|
1394
1681
|
vfunc_web_process_crashed(): boolean;
|
|
1395
1682
|
vfunc_web_process_terminated(reason: WebKit.WebProcessTerminationReason): void;
|
|
1396
|
-
call_async_javascript_function(body: string, length: bigint | number, _arguments:
|
|
1397
|
-
call_async_javascript_function(body: string, length: bigint | number, _arguments:
|
|
1398
|
-
call_async_javascript_function(body: string, length: bigint | number, _arguments:
|
|
1683
|
+
call_async_javascript_function(body: string, length: bigint | number, _arguments: GLib.Variant | null, world_name: string | null, source_uri: string | null, cancellable: import("@girs/gio-2.0").default.Cancellable | null): globalThis.Promise<import("@girs/javascriptcore-6.0").default.Value>;
|
|
1684
|
+
call_async_javascript_function(body: string, length: bigint | number, _arguments: GLib.Variant | null, world_name: string | null, source_uri: string | null, cancellable: import("@girs/gio-2.0").default.Cancellable | null, callback: import("@girs/gio-2.0").default.AsyncReadyCallback</*elided*/ any>): void;
|
|
1685
|
+
call_async_javascript_function(body: string, length: bigint | number, _arguments: GLib.Variant | null, world_name: string | null, source_uri: string | null, cancellable: import("@girs/gio-2.0").default.Cancellable | null, callback?: import("@girs/gio-2.0").default.AsyncReadyCallback</*elided*/ any>): globalThis.Promise<import("@girs/javascriptcore-6.0").default.Value> | void;
|
|
1399
1686
|
call_async_javascript_function_finish(result: import("@girs/gio-2.0").default.AsyncResult): import("@girs/javascriptcore-6.0").default.Value;
|
|
1400
1687
|
can_execute_editing_command(command: string, cancellable: import("@girs/gio-2.0").default.Cancellable | null): globalThis.Promise<boolean>;
|
|
1401
1688
|
can_execute_editing_command(command: string, cancellable: import("@girs/gio-2.0").default.Cancellable | null, callback: import("@girs/gio-2.0").default.AsyncReadyCallback</*elided*/ any>): void;
|
|
@@ -1453,7 +1740,7 @@ export declare const IFrameBridge: {
|
|
|
1453
1740
|
is_editable(): boolean;
|
|
1454
1741
|
leave_immersive_mode(): void;
|
|
1455
1742
|
load_alternate_html(content: string, content_uri: string, base_uri: string | null): void;
|
|
1456
|
-
load_bytes(bytes:
|
|
1743
|
+
load_bytes(bytes: GLib.Bytes | Uint8Array, mime_type: string | null, encoding: string | null, base_uri: string | null): void;
|
|
1457
1744
|
load_html(content: string, base_uri: string | null): void;
|
|
1458
1745
|
load_plain_text(plain_text: string): void;
|
|
1459
1746
|
load_request(request: WebKit.URIRequest): void;
|
|
@@ -1648,7 +1935,6 @@ export declare const IFrameBridge: {
|
|
|
1648
1935
|
vfunc_root(): void;
|
|
1649
1936
|
vfunc_set_focus_child(child: import("@girs/gtk-4.0").default.Widget | null): void;
|
|
1650
1937
|
vfunc_show(): void;
|
|
1651
|
-
vfunc_size_allocate(width: number, height: number, baseline: number): void;
|
|
1652
1938
|
vfunc_snapshot(snapshot: import("@girs/gtk-4.0").default.Snapshot): void;
|
|
1653
1939
|
vfunc_state_flags_changed(previous_state_flags: import("@girs/gtk-4.0").default.StateFlags): void;
|
|
1654
1940
|
vfunc_system_setting_changed(settings: import("@girs/gtk-4.0").default.SystemSetting): void;
|
|
@@ -1657,7 +1943,7 @@ export declare const IFrameBridge: {
|
|
|
1657
1943
|
vfunc_unroot(): void;
|
|
1658
1944
|
action_set_enabled(action_name: string, enabled: boolean): void;
|
|
1659
1945
|
activate(): boolean;
|
|
1660
|
-
activate_action(name: string, args:
|
|
1946
|
+
activate_action(name: string, args: GLib.Variant | null): boolean;
|
|
1661
1947
|
activate_default(): void;
|
|
1662
1948
|
add_controller(controller: import("@girs/gtk-4.0").default.EventController): void;
|
|
1663
1949
|
add_css_class(css_class: string): void;
|
|
@@ -1829,7 +2115,7 @@ export declare const IFrameBridge: {
|
|
|
1829
2115
|
freeze_notify(): void;
|
|
1830
2116
|
get_data(key: string): null;
|
|
1831
2117
|
get_property(property_name: string, value: GObject.Value | any): any;
|
|
1832
|
-
get_qdata(quark:
|
|
2118
|
+
get_qdata(quark: GLib.Quark): null;
|
|
1833
2119
|
getv(names: string[], values: (GObject.Value | any)[]): void;
|
|
1834
2120
|
is_floating(): boolean;
|
|
1835
2121
|
notify(property_name: string): void;
|
|
@@ -1840,7 +2126,7 @@ export declare const IFrameBridge: {
|
|
|
1840
2126
|
set_data(key: string, data: null): void;
|
|
1841
2127
|
set_property(property_name: string, value: GObject.Value | any): void;
|
|
1842
2128
|
steal_data(key: string): null;
|
|
1843
|
-
steal_qdata(quark:
|
|
2129
|
+
steal_qdata(quark: GLib.Quark): null;
|
|
1844
2130
|
thaw_notify(): void;
|
|
1845
2131
|
unref(): void;
|
|
1846
2132
|
watch_closure(closure: GObject.Closure): void;
|
|
@@ -1860,6 +2146,19 @@ export declare const IFrameBridge: {
|
|
|
1860
2146
|
_messageBridge: MessageBridge;
|
|
1861
2147
|
_readyCallbacks: IFrameReadyCallback[];
|
|
1862
2148
|
_options: IFrameBridgeOptions;
|
|
2149
|
+
/** Pending waitForNavigation() promises, settled on the next load. */
|
|
2150
|
+
_navigationWaiters: NavigationWaiter[];
|
|
2151
|
+
/** Detail of the most recent failed load, or null after a fresh start. */
|
|
2152
|
+
_lastLoadError: LoadErrorInfo | null;
|
|
2153
|
+
_loadErrorCallbacks: LoadErrorCallback[];
|
|
2154
|
+
/**
|
|
2155
|
+
* GTK4 allocation hook — surfaces WebKit.WebView size changes to any
|
|
2156
|
+
* ResizeObserver watching the paired HTMLIFrameElement (or an ancestor;
|
|
2157
|
+
* see notifyElementResize). GTK4 has no `resize` signal on Gtk.Widget
|
|
2158
|
+
* (only Gtk.DrawingArea/GLArea), so the allocation vfunc is the portable
|
|
2159
|
+
* way to observe the widget's size.
|
|
2160
|
+
*/
|
|
2161
|
+
vfunc_size_allocate(width: number, height: number, baseline: number): void;
|
|
1863
2162
|
/** The HTMLIFrameElement wrapping this WebView. */
|
|
1864
2163
|
get iframeElement(): HTMLIFrameElement;
|
|
1865
2164
|
/**
|
|
@@ -1906,6 +2205,86 @@ export declare const IFrameBridge: {
|
|
|
1906
2205
|
/** True when the WebView has forward entries in its internal history.
|
|
1907
2206
|
* Reflects WebKit's `can-go-forward` state. */
|
|
1908
2207
|
get canGoForward(): boolean;
|
|
2208
|
+
/** WebKit's ground-truth current URI (`about:blank` before any load).
|
|
2209
|
+
* Distinct from any application-side history the embedder maintains. */
|
|
2210
|
+
get currentUri(): string;
|
|
2211
|
+
/** The loaded document's title (empty string before it is known).
|
|
2212
|
+
* Reflects WebKit's tracked `<title>`. */
|
|
2213
|
+
get pageTitle(): string;
|
|
2214
|
+
/** Detail of the most recent failed load, or null when the current
|
|
2215
|
+
* page loaded without a main-resource failure. */
|
|
2216
|
+
get lastLoadError(): LoadErrorInfo | null;
|
|
2217
|
+
/** Subscribe to load failures (network / main-resource errors). */
|
|
2218
|
+
onLoadError(cb: LoadErrorCallback): void;
|
|
2219
|
+
/**
|
|
2220
|
+
* Evaluate a JavaScript *expression* in the page and return its value.
|
|
2221
|
+
*
|
|
2222
|
+
* The value is serialised to JSON in-page and parsed on the GJS host,
|
|
2223
|
+
* so objects/arrays/strings/numbers/booleans/null round-trip. A value
|
|
2224
|
+
* that is not JSON-serialisable (DOM node, function, circular object)
|
|
2225
|
+
* comes back as `undefined`. A thrown page error rejects the promise.
|
|
2226
|
+
*
|
|
2227
|
+
* Pass an expression, not statements — wrap multi-statement logic in an
|
|
2228
|
+
* IIFE that returns a value, e.g.
|
|
2229
|
+
* `evaluateJavaScript('(() => { const a = 1; return a + 1; })()')`.
|
|
2230
|
+
* This mirrors Playwright/Puppeteer `page.evaluate` ergonomics.
|
|
2231
|
+
*/
|
|
2232
|
+
evaluateJavaScript(expression: string): Promise<unknown>;
|
|
2233
|
+
/**
|
|
2234
|
+
* Capture the rendered web content as PNG bytes.
|
|
2235
|
+
*
|
|
2236
|
+
* `'full'` (default) snapshots the whole scrollable document; `'visible'`
|
|
2237
|
+
* snapshots only the current viewport. This goes through WebKit's own
|
|
2238
|
+
* `get_snapshot` — NOT a GSK widget snapshot — because WebKit composites
|
|
2239
|
+
* its content in a separate process, so a GTK-tree snapshot of the
|
|
2240
|
+
* WebView can come back blank or stale.
|
|
2241
|
+
*/
|
|
2242
|
+
takeScreenshot(region?: "full" | "visible"): Promise<Uint8Array>;
|
|
2243
|
+
/**
|
|
2244
|
+
* Resolve on the next load that finishes (`LoadEvent.FINISHED`).
|
|
2245
|
+
*
|
|
2246
|
+
* `onReady()` fires only once and is drained per load, so a
|
|
2247
|
+
* page-initiated navigation (link click, JS redirect, form submit,
|
|
2248
|
+
* meta-refresh) never re-triggers it. Register a `waitForNavigation()`
|
|
2249
|
+
* *before* triggering such a navigation. Rejects on a main-resource
|
|
2250
|
+
* load failure, or after `timeoutMs` (0 disables the timeout).
|
|
2251
|
+
*/
|
|
2252
|
+
waitForNavigation(timeoutMs?: number): Promise<void>;
|
|
2253
|
+
/** Settle (and clear) every pending waitForNavigation() promise,
|
|
2254
|
+
* removing its timeout source. Resolves them on success; rejects with
|
|
2255
|
+
* `error` on a load failure. */
|
|
2256
|
+
_settleNavigationWaiters(error: Error | null): void;
|
|
2257
|
+
/** Current size of the WebView content region, in widget pixels. */
|
|
2258
|
+
getViewportSize(): {
|
|
2259
|
+
width: number;
|
|
2260
|
+
height: number;
|
|
2261
|
+
};
|
|
2262
|
+
/**
|
|
2263
|
+
* Request a content-region size (e.g. for responsive testing). This sets
|
|
2264
|
+
* the widget's size request; the actual allocation still depends on the
|
|
2265
|
+
* parent layout, and `getViewportSize()` reflects the realised size.
|
|
2266
|
+
*/
|
|
2267
|
+
setViewportSize(width: number, height: number): void;
|
|
2268
|
+
/** Buffered page `console.*` output. Empty unless the bridge was created
|
|
2269
|
+
* with `{ captureConsole: true }`. */
|
|
2270
|
+
getConsoleLogs(): ConsoleLogEntry[];
|
|
2271
|
+
/** Drop all buffered console entries. */
|
|
2272
|
+
clearConsoleLogs(): void;
|
|
2273
|
+
/** Subscribe to captured console entries as they arrive. Requires
|
|
2274
|
+
* `{ captureConsole: true }` to receive anything. */
|
|
2275
|
+
onConsole(cb: ConsoleCallback): void;
|
|
2276
|
+
/** Every `<a href>` on the page (resolved href, trimmed text, title). */
|
|
2277
|
+
getLinks(): Promise<LinkInfo[]>;
|
|
2278
|
+
/** Metadata for elements matching a CSS selector (capped at `limit`). */
|
|
2279
|
+
queryDom(selector: string, limit?: number): Promise<ElementInfo[]>;
|
|
2280
|
+
/**
|
|
2281
|
+
* Click the first element matching `selectorOrText` — a CSS selector, or
|
|
2282
|
+
* (failing that) an `<a>` matched by exact trimmed text. Resolves to true
|
|
2283
|
+
* when an element was found + clicked. Does NOT wait for navigation: to
|
|
2284
|
+
* await a resulting page change, register `waitForNavigation()` *before*
|
|
2285
|
+
* calling this, then await it (a fast navigation may finish first).
|
|
2286
|
+
*/
|
|
2287
|
+
clickElement(selectorOrText: string): Promise<boolean>;
|
|
1909
2288
|
/**
|
|
1910
2289
|
* Set `globalThis.HTMLIFrameElement` to the gjsify implementation.
|
|
1911
2290
|
*/
|
|
@@ -1985,7 +2364,7 @@ export declare const IFrameBridge: {
|
|
|
1985
2364
|
vfunc_insecure_content_detected(event: WebKit.InsecureContentEvent): void;
|
|
1986
2365
|
vfunc_leave_fullscreen(): boolean;
|
|
1987
2366
|
vfunc_load_changed(load_event: WebKit.LoadEvent): void;
|
|
1988
|
-
vfunc_load_failed(load_event: WebKit.LoadEvent, failing_uri: string, error:
|
|
2367
|
+
vfunc_load_failed(load_event: WebKit.LoadEvent, failing_uri: string, error: GLib.Error): boolean;
|
|
1989
2368
|
vfunc_load_failed_with_tls_errors(failing_uri: string, certificate: import("@girs/gio-2.0").default.TlsCertificate, errors: import("@girs/gio-2.0").default.TlsCertificateFlags): boolean;
|
|
1990
2369
|
vfunc_mouse_target_changed(hit_test_result: WebKit.HitTestResult, modifiers: number): void;
|
|
1991
2370
|
vfunc_permission_request(permission_request: WebKit.PermissionRequest): boolean;
|
|
@@ -2003,9 +2382,9 @@ export declare const IFrameBridge: {
|
|
|
2003
2382
|
vfunc_user_message_received(message: WebKit.UserMessage): boolean;
|
|
2004
2383
|
vfunc_web_process_crashed(): boolean;
|
|
2005
2384
|
vfunc_web_process_terminated(reason: WebKit.WebProcessTerminationReason): void;
|
|
2006
|
-
call_async_javascript_function(body: string, length: bigint | number, _arguments:
|
|
2007
|
-
call_async_javascript_function(body: string, length: bigint | number, _arguments:
|
|
2008
|
-
call_async_javascript_function(body: string, length: bigint | number, _arguments:
|
|
2385
|
+
call_async_javascript_function(body: string, length: bigint | number, _arguments: GLib.Variant | null, world_name: string | null, source_uri: string | null, cancellable: import("@girs/gio-2.0").default.Cancellable | null): globalThis.Promise<import("@girs/javascriptcore-6.0").default.Value>;
|
|
2386
|
+
call_async_javascript_function(body: string, length: bigint | number, _arguments: GLib.Variant | null, world_name: string | null, source_uri: string | null, cancellable: import("@girs/gio-2.0").default.Cancellable | null, callback: import("@girs/gio-2.0").default.AsyncReadyCallback</*elided*/ any>): void;
|
|
2387
|
+
call_async_javascript_function(body: string, length: bigint | number, _arguments: GLib.Variant | null, world_name: string | null, source_uri: string | null, cancellable: import("@girs/gio-2.0").default.Cancellable | null, callback?: import("@girs/gio-2.0").default.AsyncReadyCallback</*elided*/ any>): globalThis.Promise<import("@girs/javascriptcore-6.0").default.Value> | void;
|
|
2009
2388
|
call_async_javascript_function_finish(result: import("@girs/gio-2.0").default.AsyncResult): import("@girs/javascriptcore-6.0").default.Value;
|
|
2010
2389
|
can_execute_editing_command(command: string, cancellable: import("@girs/gio-2.0").default.Cancellable | null): globalThis.Promise<boolean>;
|
|
2011
2390
|
can_execute_editing_command(command: string, cancellable: import("@girs/gio-2.0").default.Cancellable | null, callback: import("@girs/gio-2.0").default.AsyncReadyCallback</*elided*/ any>): void;
|
|
@@ -2063,7 +2442,7 @@ export declare const IFrameBridge: {
|
|
|
2063
2442
|
is_editable(): boolean;
|
|
2064
2443
|
leave_immersive_mode(): void;
|
|
2065
2444
|
load_alternate_html(content: string, content_uri: string, base_uri: string | null): void;
|
|
2066
|
-
load_bytes(bytes:
|
|
2445
|
+
load_bytes(bytes: GLib.Bytes | Uint8Array, mime_type: string | null, encoding: string | null, base_uri: string | null): void;
|
|
2067
2446
|
load_html(content: string, base_uri: string | null): void;
|
|
2068
2447
|
load_plain_text(plain_text: string): void;
|
|
2069
2448
|
load_request(request: WebKit.URIRequest): void;
|
|
@@ -2258,7 +2637,6 @@ export declare const IFrameBridge: {
|
|
|
2258
2637
|
vfunc_root(): void;
|
|
2259
2638
|
vfunc_set_focus_child(child: import("@girs/gtk-4.0").default.Widget | null): void;
|
|
2260
2639
|
vfunc_show(): void;
|
|
2261
|
-
vfunc_size_allocate(width: number, height: number, baseline: number): void;
|
|
2262
2640
|
vfunc_snapshot(snapshot: import("@girs/gtk-4.0").default.Snapshot): void;
|
|
2263
2641
|
vfunc_state_flags_changed(previous_state_flags: import("@girs/gtk-4.0").default.StateFlags): void;
|
|
2264
2642
|
vfunc_system_setting_changed(settings: import("@girs/gtk-4.0").default.SystemSetting): void;
|
|
@@ -2267,7 +2645,7 @@ export declare const IFrameBridge: {
|
|
|
2267
2645
|
vfunc_unroot(): void;
|
|
2268
2646
|
action_set_enabled(action_name: string, enabled: boolean): void;
|
|
2269
2647
|
activate(): boolean;
|
|
2270
|
-
activate_action(name: string, args:
|
|
2648
|
+
activate_action(name: string, args: GLib.Variant | null): boolean;
|
|
2271
2649
|
activate_default(): void;
|
|
2272
2650
|
add_controller(controller: import("@girs/gtk-4.0").default.EventController): void;
|
|
2273
2651
|
add_css_class(css_class: string): void;
|
|
@@ -2439,7 +2817,7 @@ export declare const IFrameBridge: {
|
|
|
2439
2817
|
freeze_notify(): void;
|
|
2440
2818
|
get_data(key: string): null;
|
|
2441
2819
|
get_property(property_name: string, value: GObject.Value | any): any;
|
|
2442
|
-
get_qdata(quark:
|
|
2820
|
+
get_qdata(quark: GLib.Quark): null;
|
|
2443
2821
|
getv(names: string[], values: (GObject.Value | any)[]): void;
|
|
2444
2822
|
is_floating(): boolean;
|
|
2445
2823
|
notify(property_name: string): void;
|
|
@@ -2450,7 +2828,7 @@ export declare const IFrameBridge: {
|
|
|
2450
2828
|
set_data(key: string, data: null): void;
|
|
2451
2829
|
set_property(property_name: string, value: GObject.Value | any): void;
|
|
2452
2830
|
steal_data(key: string): null;
|
|
2453
|
-
steal_qdata(quark:
|
|
2831
|
+
steal_qdata(quark: GLib.Quark): null;
|
|
2454
2832
|
thaw_notify(): void;
|
|
2455
2833
|
unref(): void;
|
|
2456
2834
|
watch_closure(closure: GObject.Closure): void;
|
|
@@ -2470,6 +2848,19 @@ export declare const IFrameBridge: {
|
|
|
2470
2848
|
_messageBridge: MessageBridge;
|
|
2471
2849
|
_readyCallbacks: IFrameReadyCallback[];
|
|
2472
2850
|
_options: IFrameBridgeOptions;
|
|
2851
|
+
/** Pending waitForNavigation() promises, settled on the next load. */
|
|
2852
|
+
_navigationWaiters: NavigationWaiter[];
|
|
2853
|
+
/** Detail of the most recent failed load, or null after a fresh start. */
|
|
2854
|
+
_lastLoadError: LoadErrorInfo | null;
|
|
2855
|
+
_loadErrorCallbacks: LoadErrorCallback[];
|
|
2856
|
+
/**
|
|
2857
|
+
* GTK4 allocation hook — surfaces WebKit.WebView size changes to any
|
|
2858
|
+
* ResizeObserver watching the paired HTMLIFrameElement (or an ancestor;
|
|
2859
|
+
* see notifyElementResize). GTK4 has no `resize` signal on Gtk.Widget
|
|
2860
|
+
* (only Gtk.DrawingArea/GLArea), so the allocation vfunc is the portable
|
|
2861
|
+
* way to observe the widget's size.
|
|
2862
|
+
*/
|
|
2863
|
+
vfunc_size_allocate(width: number, height: number, baseline: number): void;
|
|
2473
2864
|
/** The HTMLIFrameElement wrapping this WebView. */
|
|
2474
2865
|
get iframeElement(): HTMLIFrameElement;
|
|
2475
2866
|
/**
|
|
@@ -2516,6 +2907,86 @@ export declare const IFrameBridge: {
|
|
|
2516
2907
|
/** True when the WebView has forward entries in its internal history.
|
|
2517
2908
|
* Reflects WebKit's `can-go-forward` state. */
|
|
2518
2909
|
get canGoForward(): boolean;
|
|
2910
|
+
/** WebKit's ground-truth current URI (`about:blank` before any load).
|
|
2911
|
+
* Distinct from any application-side history the embedder maintains. */
|
|
2912
|
+
get currentUri(): string;
|
|
2913
|
+
/** The loaded document's title (empty string before it is known).
|
|
2914
|
+
* Reflects WebKit's tracked `<title>`. */
|
|
2915
|
+
get pageTitle(): string;
|
|
2916
|
+
/** Detail of the most recent failed load, or null when the current
|
|
2917
|
+
* page loaded without a main-resource failure. */
|
|
2918
|
+
get lastLoadError(): LoadErrorInfo | null;
|
|
2919
|
+
/** Subscribe to load failures (network / main-resource errors). */
|
|
2920
|
+
onLoadError(cb: LoadErrorCallback): void;
|
|
2921
|
+
/**
|
|
2922
|
+
* Evaluate a JavaScript *expression* in the page and return its value.
|
|
2923
|
+
*
|
|
2924
|
+
* The value is serialised to JSON in-page and parsed on the GJS host,
|
|
2925
|
+
* so objects/arrays/strings/numbers/booleans/null round-trip. A value
|
|
2926
|
+
* that is not JSON-serialisable (DOM node, function, circular object)
|
|
2927
|
+
* comes back as `undefined`. A thrown page error rejects the promise.
|
|
2928
|
+
*
|
|
2929
|
+
* Pass an expression, not statements — wrap multi-statement logic in an
|
|
2930
|
+
* IIFE that returns a value, e.g.
|
|
2931
|
+
* `evaluateJavaScript('(() => { const a = 1; return a + 1; })()')`.
|
|
2932
|
+
* This mirrors Playwright/Puppeteer `page.evaluate` ergonomics.
|
|
2933
|
+
*/
|
|
2934
|
+
evaluateJavaScript(expression: string): Promise<unknown>;
|
|
2935
|
+
/**
|
|
2936
|
+
* Capture the rendered web content as PNG bytes.
|
|
2937
|
+
*
|
|
2938
|
+
* `'full'` (default) snapshots the whole scrollable document; `'visible'`
|
|
2939
|
+
* snapshots only the current viewport. This goes through WebKit's own
|
|
2940
|
+
* `get_snapshot` — NOT a GSK widget snapshot — because WebKit composites
|
|
2941
|
+
* its content in a separate process, so a GTK-tree snapshot of the
|
|
2942
|
+
* WebView can come back blank or stale.
|
|
2943
|
+
*/
|
|
2944
|
+
takeScreenshot(region?: "full" | "visible"): Promise<Uint8Array>;
|
|
2945
|
+
/**
|
|
2946
|
+
* Resolve on the next load that finishes (`LoadEvent.FINISHED`).
|
|
2947
|
+
*
|
|
2948
|
+
* `onReady()` fires only once and is drained per load, so a
|
|
2949
|
+
* page-initiated navigation (link click, JS redirect, form submit,
|
|
2950
|
+
* meta-refresh) never re-triggers it. Register a `waitForNavigation()`
|
|
2951
|
+
* *before* triggering such a navigation. Rejects on a main-resource
|
|
2952
|
+
* load failure, or after `timeoutMs` (0 disables the timeout).
|
|
2953
|
+
*/
|
|
2954
|
+
waitForNavigation(timeoutMs?: number): Promise<void>;
|
|
2955
|
+
/** Settle (and clear) every pending waitForNavigation() promise,
|
|
2956
|
+
* removing its timeout source. Resolves them on success; rejects with
|
|
2957
|
+
* `error` on a load failure. */
|
|
2958
|
+
_settleNavigationWaiters(error: Error | null): void;
|
|
2959
|
+
/** Current size of the WebView content region, in widget pixels. */
|
|
2960
|
+
getViewportSize(): {
|
|
2961
|
+
width: number;
|
|
2962
|
+
height: number;
|
|
2963
|
+
};
|
|
2964
|
+
/**
|
|
2965
|
+
* Request a content-region size (e.g. for responsive testing). This sets
|
|
2966
|
+
* the widget's size request; the actual allocation still depends on the
|
|
2967
|
+
* parent layout, and `getViewportSize()` reflects the realised size.
|
|
2968
|
+
*/
|
|
2969
|
+
setViewportSize(width: number, height: number): void;
|
|
2970
|
+
/** Buffered page `console.*` output. Empty unless the bridge was created
|
|
2971
|
+
* with `{ captureConsole: true }`. */
|
|
2972
|
+
getConsoleLogs(): ConsoleLogEntry[];
|
|
2973
|
+
/** Drop all buffered console entries. */
|
|
2974
|
+
clearConsoleLogs(): void;
|
|
2975
|
+
/** Subscribe to captured console entries as they arrive. Requires
|
|
2976
|
+
* `{ captureConsole: true }` to receive anything. */
|
|
2977
|
+
onConsole(cb: ConsoleCallback): void;
|
|
2978
|
+
/** Every `<a href>` on the page (resolved href, trimmed text, title). */
|
|
2979
|
+
getLinks(): Promise<LinkInfo[]>;
|
|
2980
|
+
/** Metadata for elements matching a CSS selector (capped at `limit`). */
|
|
2981
|
+
queryDom(selector: string, limit?: number): Promise<ElementInfo[]>;
|
|
2982
|
+
/**
|
|
2983
|
+
* Click the first element matching `selectorOrText` — a CSS selector, or
|
|
2984
|
+
* (failing that) an `<a>` matched by exact trimmed text. Resolves to true
|
|
2985
|
+
* when an element was found + clicked. Does NOT wait for navigation: to
|
|
2986
|
+
* await a resulting page change, register `waitForNavigation()` *before*
|
|
2987
|
+
* calling this, then await it (a fast navigation may finish first).
|
|
2988
|
+
*/
|
|
2989
|
+
clickElement(selectorOrText: string): Promise<boolean>;
|
|
2519
2990
|
/**
|
|
2520
2991
|
* Set `globalThis.HTMLIFrameElement` to the gjsify implementation.
|
|
2521
2992
|
*/
|
|
@@ -2595,7 +3066,7 @@ export declare const IFrameBridge: {
|
|
|
2595
3066
|
vfunc_insecure_content_detected(event: WebKit.InsecureContentEvent): void;
|
|
2596
3067
|
vfunc_leave_fullscreen(): boolean;
|
|
2597
3068
|
vfunc_load_changed(load_event: WebKit.LoadEvent): void;
|
|
2598
|
-
vfunc_load_failed(load_event: WebKit.LoadEvent, failing_uri: string, error:
|
|
3069
|
+
vfunc_load_failed(load_event: WebKit.LoadEvent, failing_uri: string, error: GLib.Error): boolean;
|
|
2599
3070
|
vfunc_load_failed_with_tls_errors(failing_uri: string, certificate: import("@girs/gio-2.0").default.TlsCertificate, errors: import("@girs/gio-2.0").default.TlsCertificateFlags): boolean;
|
|
2600
3071
|
vfunc_mouse_target_changed(hit_test_result: WebKit.HitTestResult, modifiers: number): void;
|
|
2601
3072
|
vfunc_permission_request(permission_request: WebKit.PermissionRequest): boolean;
|
|
@@ -2613,9 +3084,9 @@ export declare const IFrameBridge: {
|
|
|
2613
3084
|
vfunc_user_message_received(message: WebKit.UserMessage): boolean;
|
|
2614
3085
|
vfunc_web_process_crashed(): boolean;
|
|
2615
3086
|
vfunc_web_process_terminated(reason: WebKit.WebProcessTerminationReason): void;
|
|
2616
|
-
call_async_javascript_function(body: string, length: bigint | number, _arguments:
|
|
2617
|
-
call_async_javascript_function(body: string, length: bigint | number, _arguments:
|
|
2618
|
-
call_async_javascript_function(body: string, length: bigint | number, _arguments:
|
|
3087
|
+
call_async_javascript_function(body: string, length: bigint | number, _arguments: GLib.Variant | null, world_name: string | null, source_uri: string | null, cancellable: import("@girs/gio-2.0").default.Cancellable | null): globalThis.Promise<import("@girs/javascriptcore-6.0").default.Value>;
|
|
3088
|
+
call_async_javascript_function(body: string, length: bigint | number, _arguments: GLib.Variant | null, world_name: string | null, source_uri: string | null, cancellable: import("@girs/gio-2.0").default.Cancellable | null, callback: import("@girs/gio-2.0").default.AsyncReadyCallback</*elided*/ any>): void;
|
|
3089
|
+
call_async_javascript_function(body: string, length: bigint | number, _arguments: GLib.Variant | null, world_name: string | null, source_uri: string | null, cancellable: import("@girs/gio-2.0").default.Cancellable | null, callback?: import("@girs/gio-2.0").default.AsyncReadyCallback</*elided*/ any>): globalThis.Promise<import("@girs/javascriptcore-6.0").default.Value> | void;
|
|
2619
3090
|
call_async_javascript_function_finish(result: import("@girs/gio-2.0").default.AsyncResult): import("@girs/javascriptcore-6.0").default.Value;
|
|
2620
3091
|
can_execute_editing_command(command: string, cancellable: import("@girs/gio-2.0").default.Cancellable | null): globalThis.Promise<boolean>;
|
|
2621
3092
|
can_execute_editing_command(command: string, cancellable: import("@girs/gio-2.0").default.Cancellable | null, callback: import("@girs/gio-2.0").default.AsyncReadyCallback</*elided*/ any>): void;
|
|
@@ -2673,7 +3144,7 @@ export declare const IFrameBridge: {
|
|
|
2673
3144
|
is_editable(): boolean;
|
|
2674
3145
|
leave_immersive_mode(): void;
|
|
2675
3146
|
load_alternate_html(content: string, content_uri: string, base_uri: string | null): void;
|
|
2676
|
-
load_bytes(bytes:
|
|
3147
|
+
load_bytes(bytes: GLib.Bytes | Uint8Array, mime_type: string | null, encoding: string | null, base_uri: string | null): void;
|
|
2677
3148
|
load_html(content: string, base_uri: string | null): void;
|
|
2678
3149
|
load_plain_text(plain_text: string): void;
|
|
2679
3150
|
load_request(request: WebKit.URIRequest): void;
|
|
@@ -2868,7 +3339,6 @@ export declare const IFrameBridge: {
|
|
|
2868
3339
|
vfunc_root(): void;
|
|
2869
3340
|
vfunc_set_focus_child(child: import("@girs/gtk-4.0").default.Widget | null): void;
|
|
2870
3341
|
vfunc_show(): void;
|
|
2871
|
-
vfunc_size_allocate(width: number, height: number, baseline: number): void;
|
|
2872
3342
|
vfunc_snapshot(snapshot: import("@girs/gtk-4.0").default.Snapshot): void;
|
|
2873
3343
|
vfunc_state_flags_changed(previous_state_flags: import("@girs/gtk-4.0").default.StateFlags): void;
|
|
2874
3344
|
vfunc_system_setting_changed(settings: import("@girs/gtk-4.0").default.SystemSetting): void;
|
|
@@ -2877,7 +3347,7 @@ export declare const IFrameBridge: {
|
|
|
2877
3347
|
vfunc_unroot(): void;
|
|
2878
3348
|
action_set_enabled(action_name: string, enabled: boolean): void;
|
|
2879
3349
|
activate(): boolean;
|
|
2880
|
-
activate_action(name: string, args:
|
|
3350
|
+
activate_action(name: string, args: GLib.Variant | null): boolean;
|
|
2881
3351
|
activate_default(): void;
|
|
2882
3352
|
add_controller(controller: import("@girs/gtk-4.0").default.EventController): void;
|
|
2883
3353
|
add_css_class(css_class: string): void;
|
|
@@ -3049,7 +3519,7 @@ export declare const IFrameBridge: {
|
|
|
3049
3519
|
freeze_notify(): void;
|
|
3050
3520
|
get_data(key: string): null;
|
|
3051
3521
|
get_property(property_name: string, value: GObject.Value | any): any;
|
|
3052
|
-
get_qdata(quark:
|
|
3522
|
+
get_qdata(quark: GLib.Quark): null;
|
|
3053
3523
|
getv(names: string[], values: (GObject.Value | any)[]): void;
|
|
3054
3524
|
is_floating(): boolean;
|
|
3055
3525
|
notify(property_name: string): void;
|
|
@@ -3060,7 +3530,7 @@ export declare const IFrameBridge: {
|
|
|
3060
3530
|
set_data(key: string, data: null): void;
|
|
3061
3531
|
set_property(property_name: string, value: GObject.Value | any): void;
|
|
3062
3532
|
steal_data(key: string): null;
|
|
3063
|
-
steal_qdata(quark:
|
|
3533
|
+
steal_qdata(quark: GLib.Quark): null;
|
|
3064
3534
|
thaw_notify(): void;
|
|
3065
3535
|
unref(): void;
|
|
3066
3536
|
watch_closure(closure: GObject.Closure): void;
|
|
@@ -3080,6 +3550,19 @@ export declare const IFrameBridge: {
|
|
|
3080
3550
|
_messageBridge: MessageBridge;
|
|
3081
3551
|
_readyCallbacks: IFrameReadyCallback[];
|
|
3082
3552
|
_options: IFrameBridgeOptions;
|
|
3553
|
+
/** Pending waitForNavigation() promises, settled on the next load. */
|
|
3554
|
+
_navigationWaiters: NavigationWaiter[];
|
|
3555
|
+
/** Detail of the most recent failed load, or null after a fresh start. */
|
|
3556
|
+
_lastLoadError: LoadErrorInfo | null;
|
|
3557
|
+
_loadErrorCallbacks: LoadErrorCallback[];
|
|
3558
|
+
/**
|
|
3559
|
+
* GTK4 allocation hook — surfaces WebKit.WebView size changes to any
|
|
3560
|
+
* ResizeObserver watching the paired HTMLIFrameElement (or an ancestor;
|
|
3561
|
+
* see notifyElementResize). GTK4 has no `resize` signal on Gtk.Widget
|
|
3562
|
+
* (only Gtk.DrawingArea/GLArea), so the allocation vfunc is the portable
|
|
3563
|
+
* way to observe the widget's size.
|
|
3564
|
+
*/
|
|
3565
|
+
vfunc_size_allocate(width: number, height: number, baseline: number): void;
|
|
3083
3566
|
/** The HTMLIFrameElement wrapping this WebView. */
|
|
3084
3567
|
get iframeElement(): HTMLIFrameElement;
|
|
3085
3568
|
/**
|
|
@@ -3126,6 +3609,86 @@ export declare const IFrameBridge: {
|
|
|
3126
3609
|
/** True when the WebView has forward entries in its internal history.
|
|
3127
3610
|
* Reflects WebKit's `can-go-forward` state. */
|
|
3128
3611
|
get canGoForward(): boolean;
|
|
3612
|
+
/** WebKit's ground-truth current URI (`about:blank` before any load).
|
|
3613
|
+
* Distinct from any application-side history the embedder maintains. */
|
|
3614
|
+
get currentUri(): string;
|
|
3615
|
+
/** The loaded document's title (empty string before it is known).
|
|
3616
|
+
* Reflects WebKit's tracked `<title>`. */
|
|
3617
|
+
get pageTitle(): string;
|
|
3618
|
+
/** Detail of the most recent failed load, or null when the current
|
|
3619
|
+
* page loaded without a main-resource failure. */
|
|
3620
|
+
get lastLoadError(): LoadErrorInfo | null;
|
|
3621
|
+
/** Subscribe to load failures (network / main-resource errors). */
|
|
3622
|
+
onLoadError(cb: LoadErrorCallback): void;
|
|
3623
|
+
/**
|
|
3624
|
+
* Evaluate a JavaScript *expression* in the page and return its value.
|
|
3625
|
+
*
|
|
3626
|
+
* The value is serialised to JSON in-page and parsed on the GJS host,
|
|
3627
|
+
* so objects/arrays/strings/numbers/booleans/null round-trip. A value
|
|
3628
|
+
* that is not JSON-serialisable (DOM node, function, circular object)
|
|
3629
|
+
* comes back as `undefined`. A thrown page error rejects the promise.
|
|
3630
|
+
*
|
|
3631
|
+
* Pass an expression, not statements — wrap multi-statement logic in an
|
|
3632
|
+
* IIFE that returns a value, e.g.
|
|
3633
|
+
* `evaluateJavaScript('(() => { const a = 1; return a + 1; })()')`.
|
|
3634
|
+
* This mirrors Playwright/Puppeteer `page.evaluate` ergonomics.
|
|
3635
|
+
*/
|
|
3636
|
+
evaluateJavaScript(expression: string): Promise<unknown>;
|
|
3637
|
+
/**
|
|
3638
|
+
* Capture the rendered web content as PNG bytes.
|
|
3639
|
+
*
|
|
3640
|
+
* `'full'` (default) snapshots the whole scrollable document; `'visible'`
|
|
3641
|
+
* snapshots only the current viewport. This goes through WebKit's own
|
|
3642
|
+
* `get_snapshot` — NOT a GSK widget snapshot — because WebKit composites
|
|
3643
|
+
* its content in a separate process, so a GTK-tree snapshot of the
|
|
3644
|
+
* WebView can come back blank or stale.
|
|
3645
|
+
*/
|
|
3646
|
+
takeScreenshot(region?: "full" | "visible"): Promise<Uint8Array>;
|
|
3647
|
+
/**
|
|
3648
|
+
* Resolve on the next load that finishes (`LoadEvent.FINISHED`).
|
|
3649
|
+
*
|
|
3650
|
+
* `onReady()` fires only once and is drained per load, so a
|
|
3651
|
+
* page-initiated navigation (link click, JS redirect, form submit,
|
|
3652
|
+
* meta-refresh) never re-triggers it. Register a `waitForNavigation()`
|
|
3653
|
+
* *before* triggering such a navigation. Rejects on a main-resource
|
|
3654
|
+
* load failure, or after `timeoutMs` (0 disables the timeout).
|
|
3655
|
+
*/
|
|
3656
|
+
waitForNavigation(timeoutMs?: number): Promise<void>;
|
|
3657
|
+
/** Settle (and clear) every pending waitForNavigation() promise,
|
|
3658
|
+
* removing its timeout source. Resolves them on success; rejects with
|
|
3659
|
+
* `error` on a load failure. */
|
|
3660
|
+
_settleNavigationWaiters(error: Error | null): void;
|
|
3661
|
+
/** Current size of the WebView content region, in widget pixels. */
|
|
3662
|
+
getViewportSize(): {
|
|
3663
|
+
width: number;
|
|
3664
|
+
height: number;
|
|
3665
|
+
};
|
|
3666
|
+
/**
|
|
3667
|
+
* Request a content-region size (e.g. for responsive testing). This sets
|
|
3668
|
+
* the widget's size request; the actual allocation still depends on the
|
|
3669
|
+
* parent layout, and `getViewportSize()` reflects the realised size.
|
|
3670
|
+
*/
|
|
3671
|
+
setViewportSize(width: number, height: number): void;
|
|
3672
|
+
/** Buffered page `console.*` output. Empty unless the bridge was created
|
|
3673
|
+
* with `{ captureConsole: true }`. */
|
|
3674
|
+
getConsoleLogs(): ConsoleLogEntry[];
|
|
3675
|
+
/** Drop all buffered console entries. */
|
|
3676
|
+
clearConsoleLogs(): void;
|
|
3677
|
+
/** Subscribe to captured console entries as they arrive. Requires
|
|
3678
|
+
* `{ captureConsole: true }` to receive anything. */
|
|
3679
|
+
onConsole(cb: ConsoleCallback): void;
|
|
3680
|
+
/** Every `<a href>` on the page (resolved href, trimmed text, title). */
|
|
3681
|
+
getLinks(): Promise<LinkInfo[]>;
|
|
3682
|
+
/** Metadata for elements matching a CSS selector (capped at `limit`). */
|
|
3683
|
+
queryDom(selector: string, limit?: number): Promise<ElementInfo[]>;
|
|
3684
|
+
/**
|
|
3685
|
+
* Click the first element matching `selectorOrText` — a CSS selector, or
|
|
3686
|
+
* (failing that) an `<a>` matched by exact trimmed text. Resolves to true
|
|
3687
|
+
* when an element was found + clicked. Does NOT wait for navigation: to
|
|
3688
|
+
* await a resulting page change, register `waitForNavigation()` *before*
|
|
3689
|
+
* calling this, then await it (a fast navigation may finish first).
|
|
3690
|
+
*/
|
|
3691
|
+
clickElement(selectorOrText: string): Promise<boolean>;
|
|
3129
3692
|
/**
|
|
3130
3693
|
* Set `globalThis.HTMLIFrameElement` to the gjsify implementation.
|
|
3131
3694
|
*/
|
|
@@ -3205,7 +3768,7 @@ export declare const IFrameBridge: {
|
|
|
3205
3768
|
vfunc_insecure_content_detected(event: WebKit.InsecureContentEvent): void;
|
|
3206
3769
|
vfunc_leave_fullscreen(): boolean;
|
|
3207
3770
|
vfunc_load_changed(load_event: WebKit.LoadEvent): void;
|
|
3208
|
-
vfunc_load_failed(load_event: WebKit.LoadEvent, failing_uri: string, error:
|
|
3771
|
+
vfunc_load_failed(load_event: WebKit.LoadEvent, failing_uri: string, error: GLib.Error): boolean;
|
|
3209
3772
|
vfunc_load_failed_with_tls_errors(failing_uri: string, certificate: import("@girs/gio-2.0").default.TlsCertificate, errors: import("@girs/gio-2.0").default.TlsCertificateFlags): boolean;
|
|
3210
3773
|
vfunc_mouse_target_changed(hit_test_result: WebKit.HitTestResult, modifiers: number): void;
|
|
3211
3774
|
vfunc_permission_request(permission_request: WebKit.PermissionRequest): boolean;
|
|
@@ -3223,9 +3786,9 @@ export declare const IFrameBridge: {
|
|
|
3223
3786
|
vfunc_user_message_received(message: WebKit.UserMessage): boolean;
|
|
3224
3787
|
vfunc_web_process_crashed(): boolean;
|
|
3225
3788
|
vfunc_web_process_terminated(reason: WebKit.WebProcessTerminationReason): void;
|
|
3226
|
-
call_async_javascript_function(body: string, length: bigint | number, _arguments:
|
|
3227
|
-
call_async_javascript_function(body: string, length: bigint | number, _arguments:
|
|
3228
|
-
call_async_javascript_function(body: string, length: bigint | number, _arguments:
|
|
3789
|
+
call_async_javascript_function(body: string, length: bigint | number, _arguments: GLib.Variant | null, world_name: string | null, source_uri: string | null, cancellable: import("@girs/gio-2.0").default.Cancellable | null): globalThis.Promise<import("@girs/javascriptcore-6.0").default.Value>;
|
|
3790
|
+
call_async_javascript_function(body: string, length: bigint | number, _arguments: GLib.Variant | null, world_name: string | null, source_uri: string | null, cancellable: import("@girs/gio-2.0").default.Cancellable | null, callback: import("@girs/gio-2.0").default.AsyncReadyCallback</*elided*/ any>): void;
|
|
3791
|
+
call_async_javascript_function(body: string, length: bigint | number, _arguments: GLib.Variant | null, world_name: string | null, source_uri: string | null, cancellable: import("@girs/gio-2.0").default.Cancellable | null, callback?: import("@girs/gio-2.0").default.AsyncReadyCallback</*elided*/ any>): globalThis.Promise<import("@girs/javascriptcore-6.0").default.Value> | void;
|
|
3229
3792
|
call_async_javascript_function_finish(result: import("@girs/gio-2.0").default.AsyncResult): import("@girs/javascriptcore-6.0").default.Value;
|
|
3230
3793
|
can_execute_editing_command(command: string, cancellable: import("@girs/gio-2.0").default.Cancellable | null): globalThis.Promise<boolean>;
|
|
3231
3794
|
can_execute_editing_command(command: string, cancellable: import("@girs/gio-2.0").default.Cancellable | null, callback: import("@girs/gio-2.0").default.AsyncReadyCallback</*elided*/ any>): void;
|
|
@@ -3283,7 +3846,7 @@ export declare const IFrameBridge: {
|
|
|
3283
3846
|
is_editable(): boolean;
|
|
3284
3847
|
leave_immersive_mode(): void;
|
|
3285
3848
|
load_alternate_html(content: string, content_uri: string, base_uri: string | null): void;
|
|
3286
|
-
load_bytes(bytes:
|
|
3849
|
+
load_bytes(bytes: GLib.Bytes | Uint8Array, mime_type: string | null, encoding: string | null, base_uri: string | null): void;
|
|
3287
3850
|
load_html(content: string, base_uri: string | null): void;
|
|
3288
3851
|
load_plain_text(plain_text: string): void;
|
|
3289
3852
|
load_request(request: WebKit.URIRequest): void;
|
|
@@ -3478,7 +4041,6 @@ export declare const IFrameBridge: {
|
|
|
3478
4041
|
vfunc_root(): void;
|
|
3479
4042
|
vfunc_set_focus_child(child: import("@girs/gtk-4.0").default.Widget | null): void;
|
|
3480
4043
|
vfunc_show(): void;
|
|
3481
|
-
vfunc_size_allocate(width: number, height: number, baseline: number): void;
|
|
3482
4044
|
vfunc_snapshot(snapshot: import("@girs/gtk-4.0").default.Snapshot): void;
|
|
3483
4045
|
vfunc_state_flags_changed(previous_state_flags: import("@girs/gtk-4.0").default.StateFlags): void;
|
|
3484
4046
|
vfunc_system_setting_changed(settings: import("@girs/gtk-4.0").default.SystemSetting): void;
|
|
@@ -3487,7 +4049,7 @@ export declare const IFrameBridge: {
|
|
|
3487
4049
|
vfunc_unroot(): void;
|
|
3488
4050
|
action_set_enabled(action_name: string, enabled: boolean): void;
|
|
3489
4051
|
activate(): boolean;
|
|
3490
|
-
activate_action(name: string, args:
|
|
4052
|
+
activate_action(name: string, args: GLib.Variant | null): boolean;
|
|
3491
4053
|
activate_default(): void;
|
|
3492
4054
|
add_controller(controller: import("@girs/gtk-4.0").default.EventController): void;
|
|
3493
4055
|
add_css_class(css_class: string): void;
|
|
@@ -3659,7 +4221,7 @@ export declare const IFrameBridge: {
|
|
|
3659
4221
|
freeze_notify(): void;
|
|
3660
4222
|
get_data(key: string): null;
|
|
3661
4223
|
get_property(property_name: string, value: GObject.Value | any): any;
|
|
3662
|
-
get_qdata(quark:
|
|
4224
|
+
get_qdata(quark: GLib.Quark): null;
|
|
3663
4225
|
getv(names: string[], values: (GObject.Value | any)[]): void;
|
|
3664
4226
|
is_floating(): boolean;
|
|
3665
4227
|
notify(property_name: string): void;
|
|
@@ -3670,7 +4232,7 @@ export declare const IFrameBridge: {
|
|
|
3670
4232
|
set_data(key: string, data: null): void;
|
|
3671
4233
|
set_property(property_name: string, value: GObject.Value | any): void;
|
|
3672
4234
|
steal_data(key: string): null;
|
|
3673
|
-
steal_qdata(quark:
|
|
4235
|
+
steal_qdata(quark: GLib.Quark): null;
|
|
3674
4236
|
thaw_notify(): void;
|
|
3675
4237
|
unref(): void;
|
|
3676
4238
|
watch_closure(closure: GObject.Closure): void;
|
|
@@ -3686,3 +4248,4 @@ export declare const IFrameBridge: {
|
|
|
3686
4248
|
}, unknown[]>;
|
|
3687
4249
|
};
|
|
3688
4250
|
export type IFrameBridge = InstanceType<typeof IFrameBridge>;
|
|
4251
|
+
export {};
|