@gjsify/devtools-browser 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/README.md +75 -0
- package/package.json +71 -0
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @gjsify/devtools-browser
|
|
2
|
+
|
|
3
|
+
A minimalist **Adwaita web browser** for debugging the web apps you build with gjsify — remotely controllable over MCP. Open a URL (or a `page:*` built-in page), then drive it from an AI agent: navigate, screenshot the rendered page, evaluate JS in the page, inspect elements, and read the DOM / network / accessibility trees.
|
|
4
|
+
|
|
5
|
+
It is built on [`@gjsify/iframe`](../iframe) (a `WebKit.WebView` postMessage bridge) and exposes the [`@gjsify/devtools`](../devtools) control plane through a **browser tool profile**, so the same `gjsify debug` MCP bridge that drives GTK apps drives the browser too.
|
|
6
|
+
|
|
7
|
+
## Quick start — `gjsify browse`
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
gjsify browse # open page:welcome
|
|
11
|
+
gjsify browse https://localhost:8080 # open your gjsify web app
|
|
12
|
+
gjsify browse https://localhost:8080 --devtools # + the MCP control plane
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
With `--devtools`, point an MCP client at the browser profile:
|
|
16
|
+
|
|
17
|
+
```jsonc
|
|
18
|
+
// .mcp.json
|
|
19
|
+
{ "mcpServers": { "browser": { "command": "gjsify", "args": ["debug", "--profile", "browser"] } } }
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Programmatic launch
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { runBrowserDevtools } from '@gjsify/devtools-browser';
|
|
26
|
+
|
|
27
|
+
await runBrowserDevtools({
|
|
28
|
+
applicationId: 'org.example.Browser',
|
|
29
|
+
homeUrl: 'https://localhost:8080',
|
|
30
|
+
// title: 'My Debug Browser',
|
|
31
|
+
// devtools: true, // force-enable; otherwise gated on GJSIFY_DEVTOOLS
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## The browser MCP tools (profile `browser`)
|
|
36
|
+
|
|
37
|
+
On top of the generic devtools tools (`get_status`, `screenshot`, …), the browser profile adds:
|
|
38
|
+
|
|
39
|
+
- **Navigation:** `navigate`, `back`, `forward`, `reload`, `get_page_info`, `wait_for_load`
|
|
40
|
+
- **Capture:** `page_screenshot` (PNG of the rendered **web content** via the WebKit compositor — the generic `screenshot` is blank because WebKit composites out-of-process; `region=full|visible`), `set_viewport`
|
|
41
|
+
- **Scripting / DOM:** `eval_js`, `get_links`, `follow_link`, `query_dom`, `get_console`
|
|
42
|
+
- **Inspector data (Tier B):** `inspect_element` (tag/id/class + attributes + bounding rect + box model + curated computed styles), `dom_tree`, `get_network` (Resource Timing API), `get_accessibility`
|
|
43
|
+
- **Inspector panel:** `open_inspector`, `close_inspector` (toggle the WebKit Web Inspector)
|
|
44
|
+
|
|
45
|
+
Because the apps you debug are themselves gjsify-built, you can render one here and assert against its real output in-page — no separate browser-automation stack. See the [Debugging & remote control guide](https://gjsify.github.io/gjsify/guides/devtools/).
|
|
46
|
+
|
|
47
|
+
## Inspector-data builders (Tier B)
|
|
48
|
+
|
|
49
|
+
The inspector tools are powered by **pure JS-expression builders** handed to `IFrameBridge.evaluateJavaScript` — the same headless-testable pattern as `@gjsify/iframe`'s DOM helpers. They are exported so you can reuse them:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { buildInspectElementExpression, buildDomTreeExpression } from '@gjsify/devtools-browser';
|
|
53
|
+
|
|
54
|
+
const expr = buildInspectElementExpression('main .card');
|
|
55
|
+
const data = await bridge.evaluateJavaScript(expr); // { found, tagName, boxModel, computedStyle, … }
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`buildInspectElementExpression`, `buildDomTreeExpression`, `buildNetworkExpression`, `buildAccessibilityExpression` (selectors are `JSON.stringify`'d so they can't break out of the generated expression).
|
|
59
|
+
|
|
60
|
+
## Exports
|
|
61
|
+
|
|
62
|
+
- `runBrowserDevtools(options)` / `BrowserApplication` — the one-call launcher + the `Adw.Application` host.
|
|
63
|
+
- `BrowserWindow` — the Adwaita shell (URL bar + the `IFrameBridge` content area).
|
|
64
|
+
- `BrowserCore` — the platform-agnostic navigation core (history stack, `navigate` / `back` / `forward` / `reload`, `onStateChange` / `onPageLoaded`); `BUILTIN_PAGE_URLS`, `DEFAULT_HOME_URL`.
|
|
65
|
+
- `browserDevtoolsExtension(...)` — the `DevtoolsExtension` that adds the `Browser*` methods to the control plane.
|
|
66
|
+
- the inspector-data expression builders + their result types (`InspectedElement`, `DomNode`, `AccessibilityNode`, `NetworkEntry`, `BoxModel`, …).
|
|
67
|
+
|
|
68
|
+
## Build / test
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
gjsify workspace @gjsify/devtools-browser build
|
|
72
|
+
gjsify workspace @gjsify/devtools-browser test
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Requires `webkitgtk-6.0` (via `@gjsify/iframe`). The inspector-expression builders are covered by `src/inspector.spec.ts`; the navigation core by `src/browser-core.spec.ts`.
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gjsify/devtools-browser",
|
|
3
|
+
"version": "0.11.0",
|
|
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
|
+
"type": "module",
|
|
6
|
+
"module": "lib/esm/index.js",
|
|
7
|
+
"types": "lib/types/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/types/index.d.ts",
|
|
11
|
+
"default": "./lib/esm/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"lib"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"clear": "rm -rf lib tmp tsconfig.tsbuildinfo test.gjs.mjs || exit 0",
|
|
19
|
+
"check": "gjsify tsc --noEmit",
|
|
20
|
+
"build": "gjsify run build:gjsify && gjsify run build:types",
|
|
21
|
+
"build:gjsify": "gjsify build --library 'src/**/*.{ts,js}' --exclude 'src/**/*.spec.{mts,ts}' 'src/test.{mts,ts}'",
|
|
22
|
+
"build:types": "gjsify tsc",
|
|
23
|
+
"build:test": "gjsify run build:test:gjs",
|
|
24
|
+
"build:test:gjs": "gjsify build src/test.mts --app gjs --outfile test.gjs.mjs",
|
|
25
|
+
"test": "gjsify run build:gjsify && gjsify run build:test && gjsify run test:gjs",
|
|
26
|
+
"test:gjs": "gjsify run test.gjs.mjs"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"gjs",
|
|
30
|
+
"browser",
|
|
31
|
+
"webkit",
|
|
32
|
+
"devtools",
|
|
33
|
+
"adwaita",
|
|
34
|
+
"mcp"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@girs/adw-1": "1.10.0-4.0.4",
|
|
38
|
+
"@girs/gio-2.0": "2.88.0-4.0.4",
|
|
39
|
+
"@girs/gjs": "4.0.4",
|
|
40
|
+
"@girs/glib-2.0": "2.88.0-4.0.4",
|
|
41
|
+
"@girs/gobject-2.0": "2.88.0-4.0.4",
|
|
42
|
+
"@girs/gtk-4.0": "4.23.0-4.0.4",
|
|
43
|
+
"@girs/webkit-6.0": "2.52.1-4.0.4",
|
|
44
|
+
"@gjsify/devtools": "workspace:^",
|
|
45
|
+
"@gjsify/iframe": "workspace:^"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@gjsify/cli": "workspace:^",
|
|
49
|
+
"@gjsify/unit": "workspace:^",
|
|
50
|
+
"@types/node": "^25.9.2",
|
|
51
|
+
"typescript": "^6.0.3"
|
|
52
|
+
},
|
|
53
|
+
"gjsify": {
|
|
54
|
+
"runtimes": {
|
|
55
|
+
"gjs": "polyfill",
|
|
56
|
+
"node": "none",
|
|
57
|
+
"browser": "none",
|
|
58
|
+
"nativescript": "none"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"license": "MIT",
|
|
62
|
+
"repository": {
|
|
63
|
+
"type": "git",
|
|
64
|
+
"url": "git+https://github.com/gjsify/gjsify.git",
|
|
65
|
+
"directory": "packages/framework/devtools-browser"
|
|
66
|
+
},
|
|
67
|
+
"bugs": {
|
|
68
|
+
"url": "https://github.com/gjsify/gjsify/issues"
|
|
69
|
+
},
|
|
70
|
+
"homepage": "https://github.com/gjsify/gjsify/tree/main/packages/framework/devtools-browser#readme"
|
|
71
|
+
}
|