@restregular/dsh-visual-browser 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +129 -3
- package/client.js +835 -0
- package/cordis.patch.yml +17 -0
- package/icon.svg +21 -0
- package/index.js +43 -0
- package/lib/browser.js +1045 -0
- package/lib/cdp.js +208 -0
- package/lib/format.js +87 -0
- package/lib/page-scripts.js +528 -0
- package/lib/routes.js +201 -0
- package/lib/tools.js +168 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +70 -4
- package/test/format.test.mjs +62 -0
- package/test/package.test.mjs +56 -0
- package/test/routes.test.mjs +207 -0
- package/test/scripts.test.mjs +214 -0
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# dsh-visual-browser bundle patch.
|
|
2
|
+
#
|
|
3
|
+
# One Host row: it owns the Chrome process, the five browser tools, and the
|
|
4
|
+
# same-origin `/visual-browser/api` route that feeds the panel (live frame,
|
|
5
|
+
# operation timeline, click-through). The Client half ships in the same
|
|
6
|
+
# package and is loaded by the Web module graph from `dsh.client`.
|
|
7
|
+
#
|
|
8
|
+
# `name` must be byte-for-byte the package.json name: the client module graph
|
|
9
|
+
# locates the package by the Loader row name.
|
|
10
|
+
- insert:
|
|
11
|
+
- id: dsh-visual-browser
|
|
12
|
+
name: '@restregular/dsh-visual-browser'
|
|
13
|
+
config:
|
|
14
|
+
headless: true
|
|
15
|
+
viewport:
|
|
16
|
+
width: 1280
|
|
17
|
+
height: 800
|
package/icon.svg
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" width="256" height="256" role="img" aria-label="Visual Browser">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="dvb-bg" x1="0" y1="0" x2="1" y2="1">
|
|
4
|
+
<stop offset="0" stop-color="#4C6EF5"/>
|
|
5
|
+
<stop offset="1" stop-color="#7048E8"/>
|
|
6
|
+
</linearGradient>
|
|
7
|
+
<linearGradient id="dvb-glass" x1="0" y1="0" x2="0" y2="1">
|
|
8
|
+
<stop offset="0" stop-color="#FFFFFF" stop-opacity="0.98"/>
|
|
9
|
+
<stop offset="1" stop-color="#E9EDFF" stop-opacity="0.9"/>
|
|
10
|
+
</linearGradient>
|
|
11
|
+
</defs>
|
|
12
|
+
<rect width="256" height="256" rx="56" fill="url(#dvb-bg)"/>
|
|
13
|
+
<rect x="40" y="52" width="176" height="152" rx="18" fill="url(#dvb-glass)"/>
|
|
14
|
+
<path d="M40 86h176" stroke="#4C6EF5" stroke-opacity="0.22" stroke-width="2"/>
|
|
15
|
+
<circle cx="58" cy="69" r="4.5" fill="#4C6EF5"/>
|
|
16
|
+
<circle cx="74" cy="69" r="4.5" fill="#4C6EF5" fill-opacity="0.62"/>
|
|
17
|
+
<circle cx="90" cy="69" r="4.5" fill="#4C6EF5" fill-opacity="0.34"/>
|
|
18
|
+
<path d="M128 103c-24 0-41 15-47 26 6 11 23 26 47 26s41-15 47-26c-6-11-23-26-47-26Z" fill="#4C6EF5" fill-opacity="0.14" stroke="#4C6EF5" stroke-width="6" stroke-linejoin="round"/>
|
|
19
|
+
<circle cx="128" cy="129" r="14" fill="#4C6EF5"/>
|
|
20
|
+
<path d="M173 150l36 15-16 6-7 17-13-38Z" fill="#1B2559" stroke="#FFFFFF" stroke-width="5" stroke-linejoin="round"/>
|
|
21
|
+
</svg>
|
package/index.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-visual-browser — Host half.
|
|
3
|
+
*
|
|
4
|
+
* Owns one Chrome process, the five browser tools the Agent drives, and the
|
|
5
|
+
* same-origin API the panel reads. The panel itself is `client.js`.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { BrowserManager } from './lib/browser.js';
|
|
9
|
+
import { mountRoutes } from './lib/routes.js';
|
|
10
|
+
import { browserTools } from './lib/tools.js';
|
|
11
|
+
|
|
12
|
+
export const name = 'dsh-visual-browser';
|
|
13
|
+
|
|
14
|
+
export function apply(ctx, config = {}) {
|
|
15
|
+
const logger = ctx.logger;
|
|
16
|
+
const manager = new BrowserManager({ config, logger });
|
|
17
|
+
|
|
18
|
+
// Chrome must never outlive the plugin: unload kills the process tree.
|
|
19
|
+
ctx.effect(
|
|
20
|
+
() => () => {
|
|
21
|
+
manager.dispose();
|
|
22
|
+
},
|
|
23
|
+
'dsh-visual-browser: browser lifecycle',
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const tools = browserTools(manager);
|
|
27
|
+
try {
|
|
28
|
+
ctx.inject(['tools'], (scoped) => {
|
|
29
|
+
for (const definition of tools) {
|
|
30
|
+
try {
|
|
31
|
+
scoped.effect(() => scoped.tools.register(definition), `dsh-visual-browser: ${definition.name}`);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
logger?.warn?.(`[visual-browser] could not register ${definition.name}: ${error?.message ?? error}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
logger?.info?.('[visual-browser] browser tools registered');
|
|
37
|
+
});
|
|
38
|
+
} catch (error) {
|
|
39
|
+
logger?.warn?.(`[visual-browser] tool registration failed: ${error?.message ?? error}`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
mountRoutes(ctx, manager);
|
|
43
|
+
}
|