@gjsify/devtools-browser 0.11.1 → 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/browser-window.js +1 -1
- package/lib/esm/run.js +1 -1
- package/lib/types/browser-window.d.ts +2 -2
- package/lib/types/run.d.ts +22 -0
- package/package.json +6 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{BrowserCore as e}from"./browser-core.js";import t from"@girs/adw-1";import n from"@girs/gtk-4.0";import{IFrameBridge as r}from"@gjsify/iframe";var BrowserWindow=class{constructor(i,a={}){let o=a.homeUrl??`page:welcome`;this._win=new t.ApplicationWindow({application:i,default_width:1100,default_height:720,title:a.title??`Minimalist Browser`});let s=new t.ToolbarView,c=new t.HeaderBar;s.add_top_bar(c);let l=new n.Button({icon_name:`go-previous-symbolic`,tooltip_text:`Back`,sensitive:!1}),u=new n.Button({icon_name:`go-next-symbolic`,tooltip_text:`Forward`,sensitive:!1}),d=new n.Button({icon_name:`view-refresh-symbolic`,tooltip_text:`Reload`});c.pack_start(l),c.pack_start(u),c.pack_start(d);let f=new n.Entry({placeholder_text:`page:welcome or https://…`,hexpand:!0});f.set_text(o),c.set_title_widget(f);let p=new n.Button({label:`Go`,css_classes:[`suggested-action`]});c.pack_end(p);let m=new n.Box({orientation:n.Orientation.VERTICAL,spacing:0});this._iframeWidget=new r({captureConsole:!0}),this._iframeWidget.installGlobals(),this._iframeWidget.vexpand=!0,this._iframeWidget.hexpand=!0,m.append(this._iframeWidget);let h=new n.Label({halign:n.Align.START,margin_start:12,margin_end:12,margin_top:4,margin_bottom:4});h.add_css_class(`dim-label`),h.add_css_class(`monospace`),h.set_text(`Status: idle`),m.append(h),s.set_content(m),this._win.set_content(s),this._core=new e(this._iframeWidget.iframeElement),this._iframeWidget.onReady(()=>this._core.reattachListener()),this._core.onStateChange(e=>{f.set_text(e.url),l.sensitive=e.canGoBack,u.sensitive=e.canGoForward}),this._core.onPageLoaded(e=>{h.set_text(`Status: loaded "${e.title}" (${e.url})`)});let submitUrl=()=>{let e=f.get_text().trim();e&&this._core.navigate(e)};p.connect(`clicked`,submitUrl),f.connect(`activate`,submitUrl),l.connect(`clicked`,()=>this._core.back()),u.connect(`clicked`,()=>this._core.forward()),d.connect(`clicked`,()=>this._core.reload()),this._core.navigate(o)}get core(){return this._core}get window(){return this._win}get bridge(){return this._iframeWidget}navigate(e){this._core.navigate(e)}present(){this._win.present()}};export{BrowserWindow};
|
package/lib/esm/run.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{browserDevtoolsExtension as e}from"./browser-devtools-extension.js";import{BrowserWindow as t}from"./browser-window.js";import n from"@girs/adw-1";import r from"@girs/gio-2.0";import i from"@girs/gobject-2.0";import{installDevtools as
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{browserDevtoolsExtension as e}from"./browser-devtools-extension.js";import{BrowserWindow as t}from"./browser-window.js";import n from"@girs/adw-1";import r from"@girs/gio-2.0";import i from"@girs/glib-2.0";import a from"@girs/gobject-2.0";import{installDevtools as o}from"@gjsify/devtools";import{inspectorProtocolExtension as s}from"@gjsify/devtools-cdp";var c=class BrowserApplication extends n.Application{static{a.registerClass({GTypeName:`GjsifyBrowserApplication`},BrowserApplication)}constructor(e){super({application_id:e.applicationId,flags:r.ApplicationFlags.DEFAULT_FLAGS}),this._window=null,this._options=e,e.inspectorPort!==void 0&&i.setenv(`WEBKIT_INSPECTOR_HTTP_SERVER`,`127.0.0.1:${e.inspectorPort}`,!0),this.connect(`activate`,()=>this._onActivate())}_onActivate(){if(!this._window){this._window=new t(this,{title:this._options.title,homeUrl:this._options.homeUrl});let n=[e({bridge:this._window.bridge,core:this._window.core,window:this._window})];this._options.inspectorPort!==void 0&&(this._window.bridge.get_settings().set_enable_developer_extras(!0),n.push(s({port:this._options.inspectorPort}))),o(this,{enabled:this._options.devtools||void 0,winActionGroup:this._window.window,extend:n}),this._options.screenshot&&this._scheduleOneShot(this._options.screenshot)}this._window.present()}_scheduleOneShot(e){let t=this._window;if(!t)return;let n=!1,capture=()=>{n||(n=!0,i.timeout_add(i.PRIORITY_DEFAULT,500,()=>(t.bridge.takeScreenshot(`full`).then(t=>{i.file_set_contents(e,t),console.log(`[gjsify browse] screenshot → ${e} (${t.length} bytes)`),this.quit()}).catch(e=>{console.error(`[gjsify browse] screenshot failed: ${e}`),this.quit()}),i.SOURCE_REMOVE)))};t.core.onPageLoaded(()=>capture()),i.timeout_add_seconds(i.PRIORITY_DEFAULT,10,()=>(capture(),i.SOURCE_REMOVE))}};a.type_ensure(c.$gtype);async function runBrowserDevtools(e){return new c(e).runAsync([imports.system.programInvocationName,...ARGV])}export{c as BrowserApplication,runBrowserDevtools};
|
|
@@ -9,8 +9,8 @@ export interface BrowserWindowOptions {
|
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* A self-contained Adwaita browser window: HeaderBar with back/forward/reload +
|
|
12
|
-
* URL entry,
|
|
13
|
-
*
|
|
12
|
+
* URL entry, the WebKit content area, and a status line. The embedded
|
|
13
|
+
* {@link IFrameBridge} captures the page console
|
|
14
14
|
* so devtools `get_console` works.
|
|
15
15
|
*/
|
|
16
16
|
export declare class BrowserWindow {
|
package/lib/types/run.d.ts
CHANGED
|
@@ -5,6 +5,21 @@ export interface RunBrowserDevtoolsOptions extends BrowserWindowOptions {
|
|
|
5
5
|
applicationId: string;
|
|
6
6
|
/** Force-enable the devtools control plane (otherwise gated on `GJSIFY_DEVTOOLS`). */
|
|
7
7
|
devtools?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Enable WebKit's remote inspector protocol on this port (sets
|
|
10
|
+
* `WEBKIT_INSPECTOR_HTTP_SERVER=127.0.0.1:<port>` before the WebView is built)
|
|
11
|
+
* and add the `Cdp*` control-plane methods (@gjsify/devtools-cdp). Drives the
|
|
12
|
+
* deep protocol (Runtime/DOM/CSS/Network/Console/Debugger) over MCP.
|
|
13
|
+
*/
|
|
14
|
+
inspectorPort?: number;
|
|
15
|
+
/**
|
|
16
|
+
* One-shot mode: once the initial page has loaded, capture a WebKit
|
|
17
|
+
* screenshot to this path and quit. Turns `gjsify browse <url> --screenshot
|
|
18
|
+
* out.png` into a build→load→shoot→exit command (CI / quick single captures).
|
|
19
|
+
* For many stories in one session, drive a *running* browser over the
|
|
20
|
+
* `Browser*` control plane instead (no relaunch per shot).
|
|
21
|
+
*/
|
|
22
|
+
screenshot?: string;
|
|
8
23
|
}
|
|
9
24
|
/**
|
|
10
25
|
* Hosts the browser window and installs devtools on activate. Devtools is wired
|
|
@@ -16,6 +31,13 @@ export declare class BrowserApplication extends Adw.Application {
|
|
|
16
31
|
private _options;
|
|
17
32
|
constructor(options: RunBrowserDevtoolsOptions);
|
|
18
33
|
private _onActivate;
|
|
34
|
+
/**
|
|
35
|
+
* One-shot screenshot: capture the page once it has loaded (plus a short
|
|
36
|
+
* settle so it has painted), write it, then quit. Uses the WebKit snapshot
|
|
37
|
+
* (`bridge.takeScreenshot`) — the generic GSK Screenshot would be blank
|
|
38
|
+
* because WebKit composites out-of-process.
|
|
39
|
+
*/
|
|
40
|
+
private _scheduleOneShot;
|
|
19
41
|
}
|
|
20
42
|
/**
|
|
21
43
|
* Construct and run a browser application, resolving with its exit code.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/devtools-browser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Minimalist Adwaita web browser for GJS — shared BrowserCore + native Adw shell + a devtools extension so an agent can drive and inspect web apps over MCP",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -41,12 +41,13 @@
|
|
|
41
41
|
"@girs/gobject-2.0": "2.88.0-4.0.4",
|
|
42
42
|
"@girs/gtk-4.0": "4.23.0-4.0.4",
|
|
43
43
|
"@girs/webkit-6.0": "2.52.1-4.0.4",
|
|
44
|
-
"@gjsify/devtools": "^0.
|
|
45
|
-
"@gjsify/
|
|
44
|
+
"@gjsify/devtools": "^0.12.0",
|
|
45
|
+
"@gjsify/devtools-cdp": "^0.12.0",
|
|
46
|
+
"@gjsify/iframe": "^0.12.0"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@gjsify/cli": "^0.
|
|
49
|
-
"@gjsify/unit": "^0.
|
|
49
|
+
"@gjsify/cli": "^0.12.0",
|
|
50
|
+
"@gjsify/unit": "^0.12.0",
|
|
50
51
|
"@types/node": "^25.9.2",
|
|
51
52
|
"typescript": "^6.0.3"
|
|
52
53
|
},
|