@gjsify/iframe 0.10.0 → 0.11.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,6 +1,14 @@
|
|
|
1
1
|
import WebKit from 'gi://WebKit?version=6.0';
|
|
2
|
+
import './promisify.js';
|
|
2
3
|
import type { IFrameWindowProxy } from './iframe-window-proxy.js';
|
|
4
|
+
import type { ConsoleCallback, ConsoleLogEntry } from './types/index.js';
|
|
3
5
|
import type { MessagePort } from '@gjsify/message-channel';
|
|
6
|
+
/** Options for {@link MessageBridge}. */
|
|
7
|
+
export interface MessageBridgeOptions {
|
|
8
|
+
/** Inject the console-capture UserScript so the page's console.* is
|
|
9
|
+
* forwarded to the host. Default: false. */
|
|
10
|
+
captureConsole?: boolean;
|
|
11
|
+
}
|
|
4
12
|
/**
|
|
5
13
|
* Synthetic origin attached to messages travelling FROM the GJS host
|
|
6
14
|
* INTO the WebView. The WebView can use this in a targetOrigin filter to
|
|
@@ -65,7 +73,19 @@ export declare class MessageBridge {
|
|
|
65
73
|
private _nextPortId;
|
|
66
74
|
private _transport;
|
|
67
75
|
private _getTransport;
|
|
68
|
-
|
|
76
|
+
private _captureConsole;
|
|
77
|
+
private _consoleBuffer;
|
|
78
|
+
private _consoleCallbacks;
|
|
79
|
+
constructor(webView: WebKit.WebView, options?: MessageBridgeOptions);
|
|
80
|
+
/** Buffered console entries captured from the page (oldest first). Empty
|
|
81
|
+
* unless the bridge was created with `captureConsole`. */
|
|
82
|
+
getConsoleLogs(): ConsoleLogEntry[];
|
|
83
|
+
/** Drop all buffered console entries. */
|
|
84
|
+
clearConsoleLogs(): void;
|
|
85
|
+
/** Subscribe to console entries as they arrive. */
|
|
86
|
+
onConsole(cb: ConsoleCallback): void;
|
|
87
|
+
/** @internal Record a parsed console entry + fan out to subscribers. */
|
|
88
|
+
private _recordConsole;
|
|
69
89
|
/** Connect the IFrameWindowProxy that will receive messages from the WebView */
|
|
70
90
|
setWindowProxy(proxy: IFrameWindowProxy): void;
|
|
71
91
|
/** Update current URI (called by IFrameBridge on load-changed) */
|
|
@@ -118,4 +138,10 @@ export declare class MessageBridge {
|
|
|
118
138
|
* window.parent.postMessage() bridges back to GJS.
|
|
119
139
|
*/
|
|
120
140
|
private _injectBootstrapScript;
|
|
141
|
+
/**
|
|
142
|
+
* Inject the opt-in console-capture UserScript so the page's `console.*`
|
|
143
|
+
* output is mirrored to the host. Self-contained (own handler reference +
|
|
144
|
+
* idempotency guard), so it is independent of the bootstrap script.
|
|
145
|
+
*/
|
|
146
|
+
private _injectConsoleCaptureScript;
|
|
121
147
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,6 +4,10 @@ export interface IFrameBridgeOptions {
|
|
|
4
4
|
enableDeveloperExtras?: boolean;
|
|
5
5
|
/** Enable JavaScript execution in the WebView. Default: true */
|
|
6
6
|
enableJavascript?: boolean;
|
|
7
|
+
/** Mirror the page's `console.*` output to the host so it can be read via
|
|
8
|
+
* `getConsoleLogs()` / `onConsole()`. Off by default — it wraps `console`
|
|
9
|
+
* on every page, so it is opt-in. Default: false */
|
|
10
|
+
captureConsole?: boolean;
|
|
7
11
|
}
|
|
8
12
|
/** Data structure for messages crossing the GJS/WebView boundary */
|
|
9
13
|
export interface IFrameMessageData {
|
|
@@ -13,3 +17,23 @@ export interface IFrameMessageData {
|
|
|
13
17
|
}
|
|
14
18
|
/** Callback for when the IFrameBridge is ready */
|
|
15
19
|
export type IFrameReadyCallback = (iframe: globalThis.HTMLIFrameElement) => void;
|
|
20
|
+
/** Detail of the most recent failed load (a network / main-resource failure
|
|
21
|
+
* surfaced by WebKit's `load-failed` signal, distinct from an HTTP error
|
|
22
|
+
* page which still loads and reports `FINISHED`). */
|
|
23
|
+
export interface LoadErrorInfo {
|
|
24
|
+
/** The URI that failed to load. */
|
|
25
|
+
uri: string;
|
|
26
|
+
/** Human-readable failure message from WebKit / GLib. */
|
|
27
|
+
message: string;
|
|
28
|
+
}
|
|
29
|
+
/** Callback invoked when a load fails. */
|
|
30
|
+
export type LoadErrorCallback = (info: LoadErrorInfo) => void;
|
|
31
|
+
/** A captured `console.*` call forwarded from the page. */
|
|
32
|
+
export interface ConsoleLogEntry {
|
|
33
|
+
/** The console level (`log` / `warn` / `error` / `info` / `debug`). */
|
|
34
|
+
level: string;
|
|
35
|
+
/** The call arguments, stringified in-page. */
|
|
36
|
+
args: string[];
|
|
37
|
+
}
|
|
38
|
+
/** Callback invoked for each captured console entry. */
|
|
39
|
+
export type ConsoleCallback = (entry: ConsoleLogEntry) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/iframe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "HTMLIFrameElement for GJS, backed by WebKit.WebView",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"@girs/gtk-4.0": "4.23.0-4.0.4",
|
|
39
39
|
"@girs/javascriptcore-6.0": "2.52.1-4.0.4",
|
|
40
40
|
"@girs/webkit-6.0": "2.52.1-4.0.4",
|
|
41
|
-
"@gjsify/dom-elements": "^0.
|
|
42
|
-
"@gjsify/dom-events": "^0.
|
|
43
|
-
"@gjsify/message-channel": "^0.
|
|
41
|
+
"@gjsify/dom-elements": "^0.11.0",
|
|
42
|
+
"@gjsify/dom-events": "^0.11.0",
|
|
43
|
+
"@gjsify/message-channel": "^0.11.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@gjsify/cli": "^0.
|
|
47
|
-
"@gjsify/unit": "^0.
|
|
46
|
+
"@gjsify/cli": "^0.11.0",
|
|
47
|
+
"@gjsify/unit": "^0.11.0",
|
|
48
48
|
"@types/node": "^25.9.2",
|
|
49
49
|
"typescript": "^6.0.3"
|
|
50
50
|
},
|