dsh-web-fetch-playwright 0.1.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/LICENSE +21 -0
- package/README.md +108 -0
- package/README.zh-CN.md +108 -0
- package/cordis.patch.yml +31 -0
- package/dsh.plugin.json +16 -0
- package/lib/client.js +854 -0
- package/lib/index.js +669 -0
- package/lib/types/client/PluginCard.d.ts +43 -0
- package/lib/types/client/card.d.ts +18 -0
- package/lib/types/client/controller.d.ts +58 -0
- package/lib/types/client/fields.d.ts +69 -0
- package/lib/types/client/form.d.ts +159 -0
- package/lib/types/client/index.d.ts +17 -0
- package/lib/types/client/locales.d.ts +18 -0
- package/lib/types/config.d.ts +42 -0
- package/lib/types/index.d.ts +26 -0
- package/lib/types/markdown.d.ts +37 -0
- package/lib/types/playwright-resolve.d.ts +57 -0
- package/lib/types/provider.d.ts +71 -0
- package/lib/types/types.d.ts +58 -0
- package/package.json +130 -0
- package/src/client/PluginCard.module.css +155 -0
- package/src/client/PluginCard.tsx +110 -0
- package/src/client/card.tsx +117 -0
- package/src/client/controller.ts +89 -0
- package/src/client/fields.module.css +228 -0
- package/src/client/fields.tsx +189 -0
- package/src/client/form.ts +337 -0
- package/src/client/index.ts +45 -0
- package/src/client/locales.ts +81 -0
- package/src/client/styles.d.ts +4 -0
- package/src/config.ts +67 -0
- package/src/gfm.d.ts +9 -0
- package/src/index.ts +52 -0
- package/src/markdown.ts +161 -0
- package/src/playwright-resolve.ts +210 -0
- package/src/provider.ts +329 -0
- package/src/types.ts +51 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural types over the Playwright surface this plugin uses. Declared
|
|
3
|
+
* locally (not imported from `playwright`) because the runtime module is
|
|
4
|
+
* discovered dynamically — a user's global install, a pinned browser
|
|
5
|
+
* executable, or the bundled `playwright-core` — and only these members are
|
|
6
|
+
* load-bearing.
|
|
7
|
+
*
|
|
8
|
+
* @module dsh-web-fetch-playwright/types
|
|
9
|
+
*/
|
|
10
|
+
/** A navigation response, as `page.goto` returns it. */
|
|
11
|
+
export interface PlaywrightResponse {
|
|
12
|
+
status(): number;
|
|
13
|
+
headers(): Record<string, string>;
|
|
14
|
+
text(): Promise<string>;
|
|
15
|
+
}
|
|
16
|
+
/** A page inside a context. */
|
|
17
|
+
export interface PlaywrightPage {
|
|
18
|
+
goto(url: string, options?: {
|
|
19
|
+
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle' | 'commit';
|
|
20
|
+
timeout?: number;
|
|
21
|
+
}): Promise<PlaywrightResponse | null>;
|
|
22
|
+
waitForLoadState(state?: 'load' | 'domcontentloaded' | 'networkidle', options?: {
|
|
23
|
+
timeout?: number;
|
|
24
|
+
}): Promise<void>;
|
|
25
|
+
url(): string;
|
|
26
|
+
content(): Promise<string>;
|
|
27
|
+
close(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
/** An isolated browser context (the CDP backend gets a fresh one per fetch). */
|
|
30
|
+
export interface PlaywrightContext {
|
|
31
|
+
newPage(): Promise<PlaywrightPage>;
|
|
32
|
+
route(glob: string, handler: (route: PlaywrightRoute) => Promise<void>): Promise<void>;
|
|
33
|
+
close(): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/** A route interception decision. */
|
|
36
|
+
export interface PlaywrightRoute {
|
|
37
|
+
request(): {
|
|
38
|
+
resourceType(): string;
|
|
39
|
+
};
|
|
40
|
+
abort(): Promise<void>;
|
|
41
|
+
continue(): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
/** A browser instance (launched locally or connected over CDP). */
|
|
44
|
+
export interface PlaywrightBrowser {
|
|
45
|
+
newContext(): Promise<PlaywrightContext>;
|
|
46
|
+
close(): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
/** The `chromium` namespace of whichever Playwright module serves a fetch. */
|
|
49
|
+
export interface PlaywrightChromium {
|
|
50
|
+
launch(options?: {
|
|
51
|
+
headless?: boolean;
|
|
52
|
+
executablePath?: string;
|
|
53
|
+
timeout?: number;
|
|
54
|
+
}): Promise<PlaywrightBrowser>;
|
|
55
|
+
connectOverCDP(endpointURL: string, options?: {
|
|
56
|
+
timeout?: number;
|
|
57
|
+
}): Promise<PlaywrightBrowser>;
|
|
58
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-web-fetch-playwright",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Playwright/CDP web-fetch provider for DeepSeek Harness: renders pages in a real browser, denoises them (Readability + DOMPurify), and returns markdown.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "lib/index.js",
|
|
8
|
+
"types": "lib/types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./lib/types/index.d.ts",
|
|
12
|
+
"default": "./lib/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json",
|
|
15
|
+
"./client": {
|
|
16
|
+
"types": "./lib/types/client/index.d.ts",
|
|
17
|
+
"default": "./lib/client.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=20"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"lib/index.js",
|
|
25
|
+
"lib/client.js",
|
|
26
|
+
"lib/types/**/*.d.ts",
|
|
27
|
+
"src",
|
|
28
|
+
"cordis.patch.yml",
|
|
29
|
+
"dsh.plugin.json",
|
|
30
|
+
"README.md",
|
|
31
|
+
"README.zh-CN.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "rm -rf lib && tsc -p tsconfig.build.json --emitDeclarationOnly && tsdown",
|
|
36
|
+
"prepare": "pnpm run build",
|
|
37
|
+
"prepublishOnly": "pnpm run build",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"test": "vitest run"
|
|
40
|
+
},
|
|
41
|
+
"dsh": {
|
|
42
|
+
"bundle": {
|
|
43
|
+
"patch": "./cordis.patch.yml"
|
|
44
|
+
},
|
|
45
|
+
"client": {
|
|
46
|
+
"platform": "web",
|
|
47
|
+
"inject": [
|
|
48
|
+
"@deepseek-ai/dsh-client-locale",
|
|
49
|
+
"@deepseek-ai/dsh-client-runtime",
|
|
50
|
+
"@deepseek-ai/dsh-client-ui-settings"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"keywords": [
|
|
55
|
+
"deepseek-harness",
|
|
56
|
+
"dsh",
|
|
57
|
+
"dsh-plugin",
|
|
58
|
+
"cordis",
|
|
59
|
+
"playwright",
|
|
60
|
+
"cdp",
|
|
61
|
+
"web-fetch",
|
|
62
|
+
"fetch-provider",
|
|
63
|
+
"markdown",
|
|
64
|
+
"bundle"
|
|
65
|
+
],
|
|
66
|
+
"repository": {
|
|
67
|
+
"type": "git",
|
|
68
|
+
"url": "git+https://github.com/chendefine/dsh-web-fetch-playwright.git"
|
|
69
|
+
},
|
|
70
|
+
"homepage": "https://github.com/chendefine/dsh-web-fetch-playwright#readme",
|
|
71
|
+
"bugs": {
|
|
72
|
+
"url": "https://github.com/chendefine/dsh-web-fetch-playwright/issues"
|
|
73
|
+
},
|
|
74
|
+
"publishConfig": {
|
|
75
|
+
"access": "public"
|
|
76
|
+
},
|
|
77
|
+
"disclosure": {
|
|
78
|
+
"cloud": false,
|
|
79
|
+
"network": [],
|
|
80
|
+
"offlineMode": false,
|
|
81
|
+
"apiKeys": [],
|
|
82
|
+
"permissions": [
|
|
83
|
+
"network:fetch (renders the URLs the user requests in a local browser)",
|
|
84
|
+
"network:connect (user-configured CDP endpoint, default 127.0.0.1:9222)",
|
|
85
|
+
"fs:read (user-configured playwright/browser executable path)"
|
|
86
|
+
],
|
|
87
|
+
"jurisdiction": [],
|
|
88
|
+
"retention": "none"
|
|
89
|
+
},
|
|
90
|
+
"dependencies": {
|
|
91
|
+
"@deepseek-ai/schemastery": ">=3.18.1-rc.1 <4",
|
|
92
|
+
"@joplin/turndown-plugin-gfm": "^1.0.56",
|
|
93
|
+
"@mozilla/readability": "^0.6.0",
|
|
94
|
+
"dompurify": "^3.2.4",
|
|
95
|
+
"jsdom": "^26.0.0",
|
|
96
|
+
"playwright-core": "^1.50.0",
|
|
97
|
+
"turndown": "^7.2.0"
|
|
98
|
+
},
|
|
99
|
+
"peerDependencies": {
|
|
100
|
+
"@deepseek-ai/cordis": ">=4.0.1-rc.1 <5",
|
|
101
|
+
"@deepseek-ai/dsh-settings": ">=0.1.0-rc.6 <1",
|
|
102
|
+
"@deepseek-ai/dsh-web": ">=0.1.0-rc.6 <1"
|
|
103
|
+
},
|
|
104
|
+
"peerDependenciesMeta": {
|
|
105
|
+
"@deepseek-ai/cordis": {
|
|
106
|
+
"optional": true
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"devDependencies": {
|
|
110
|
+
"@deepseek-ai/cordis": "4.0.1",
|
|
111
|
+
"@deepseek-ai/dsh-client-locale": "0.1.1-rc.1",
|
|
112
|
+
"@deepseek-ai/dsh-client-runtime": "0.1.1-rc.1",
|
|
113
|
+
"@deepseek-ai/dsh-client-ui-settings": "0.1.1-rc.1",
|
|
114
|
+
"@deepseek-ai/dsh-client-ui-settings-plugins": "0.1.1-rc.1",
|
|
115
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.1.1-rc.1",
|
|
116
|
+
"@deepseek-ai/dsh-settings": "0.1.1-rc.1",
|
|
117
|
+
"@deepseek-ai/dsh-web": "0.1.1-rc.1",
|
|
118
|
+
"@types/jsdom": "^30.0.0",
|
|
119
|
+
"@types/node": "^24.0.0",
|
|
120
|
+
"@types/react": "^18.3.1",
|
|
121
|
+
"@types/react-dom": "^18.3.1",
|
|
122
|
+
"@types/turndown": "^5.0.6",
|
|
123
|
+
"lightningcss": "^1.32.0",
|
|
124
|
+
"react": "^18.3.1",
|
|
125
|
+
"react-dom": "^18.3.1",
|
|
126
|
+
"tsdown": "^0.22.2",
|
|
127
|
+
"typescript": "^5.8.0",
|
|
128
|
+
"vitest": "^4.1.8"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/* Plugin card chrome — copied from the shipped ui-settings-plugins styles
|
|
2
|
+
(same dsw-alias tokens, same rhythm) so the card is indistinguishable from
|
|
3
|
+
the built-in plugin-configuration cards. */
|
|
4
|
+
|
|
5
|
+
.card {
|
|
6
|
+
list-style: none;
|
|
7
|
+
border: 1px solid var(--dsw-alias-border-l2);
|
|
8
|
+
border-radius: 12px;
|
|
9
|
+
background: var(--dsw-alias-bg-layer-3);
|
|
10
|
+
transition: border-color .16s, background .16s;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.card:hover {
|
|
14
|
+
border-color: var(--dsw-alias-label-dimmed);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.cardOpen {
|
|
18
|
+
background: var(--dsw-alias-bg-layer-2);
|
|
19
|
+
border-color: var(--dsw-alias-label-dimmed);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.header {
|
|
23
|
+
width: 100%;
|
|
24
|
+
appearance: none;
|
|
25
|
+
border: 0;
|
|
26
|
+
background: none;
|
|
27
|
+
font: inherit;
|
|
28
|
+
color: inherit;
|
|
29
|
+
text-align: left;
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
gap: 12px;
|
|
34
|
+
padding: 14px 16px;
|
|
35
|
+
border-radius: 12px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.header:focus-visible {
|
|
39
|
+
outline: 2px solid var(--dsw-alias-brand-primary);
|
|
40
|
+
outline-offset: -2px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.headText {
|
|
44
|
+
flex: 1;
|
|
45
|
+
min-width: 0;
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-direction: column;
|
|
48
|
+
gap: 4px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.name {
|
|
52
|
+
font-size: 15px;
|
|
53
|
+
font-weight: 600;
|
|
54
|
+
line-height: 1.4;
|
|
55
|
+
color: var(--dsw-alias-label-primary);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.description {
|
|
59
|
+
font-size: 13px;
|
|
60
|
+
line-height: 1.5;
|
|
61
|
+
color: var(--dsw-alias-label-tertiary);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.chevron {
|
|
65
|
+
flex: none;
|
|
66
|
+
color: var(--dsw-alias-label-tertiary);
|
|
67
|
+
transition: transform .16s;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.chevronOpen {
|
|
71
|
+
transform: rotate(180deg);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.body {
|
|
75
|
+
border-top: 1px solid var(--dsw-alias-border-l2);
|
|
76
|
+
margin: 0 16px;
|
|
77
|
+
padding-bottom: 8px;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.readOnly {
|
|
81
|
+
margin: 12px 0 0;
|
|
82
|
+
font-size: 12px;
|
|
83
|
+
line-height: 1.5;
|
|
84
|
+
color: var(--dsw-alias-label-tertiary);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.pending {
|
|
88
|
+
flex: none;
|
|
89
|
+
border-radius: 999px;
|
|
90
|
+
padding: 1px 8px;
|
|
91
|
+
font-size: 11px;
|
|
92
|
+
line-height: 17px;
|
|
93
|
+
font-weight: 500;
|
|
94
|
+
white-space: nowrap;
|
|
95
|
+
background: var(--dsw-alias-bg-module-platform);
|
|
96
|
+
color: var(--dsw-alias-label-secondary);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.footer {
|
|
100
|
+
display: flex;
|
|
101
|
+
align-items: center;
|
|
102
|
+
justify-content: flex-end;
|
|
103
|
+
gap: 8px;
|
|
104
|
+
padding: 12px 0 4px;
|
|
105
|
+
border-top: 1px solid var(--dsw-alias-border-l2);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.failed {
|
|
109
|
+
flex: 1;
|
|
110
|
+
min-width: 0;
|
|
111
|
+
margin: 0;
|
|
112
|
+
font-size: 12px;
|
|
113
|
+
line-height: 1.5;
|
|
114
|
+
color: var(--dsw-alias-label-error);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.discard,
|
|
118
|
+
.save {
|
|
119
|
+
appearance: none;
|
|
120
|
+
border: 1px solid transparent;
|
|
121
|
+
border-radius: 8px;
|
|
122
|
+
padding: 5px 14px;
|
|
123
|
+
font: inherit;
|
|
124
|
+
font-size: 13px;
|
|
125
|
+
line-height: 1.5;
|
|
126
|
+
cursor: pointer;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.discard {
|
|
130
|
+
border-color: var(--dsw-alias-border-l2);
|
|
131
|
+
background: none;
|
|
132
|
+
color: var(--dsw-alias-label-secondary);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.discard:hover:not(:disabled) {
|
|
136
|
+
color: var(--dsw-alias-label-primary);
|
|
137
|
+
border-color: var(--dsw-alias-label-dimmed);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.save {
|
|
141
|
+
background: var(--dsw-alias-label-primary);
|
|
142
|
+
color: var(--dsw-alias-bg-layer-3);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.discard:disabled,
|
|
146
|
+
.save:disabled {
|
|
147
|
+
opacity: 0.4;
|
|
148
|
+
cursor: default;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.discard:focus-visible,
|
|
152
|
+
.save:focus-visible {
|
|
153
|
+
outline: 2px solid var(--dsw-alias-brand-primary);
|
|
154
|
+
outline-offset: 1px;
|
|
155
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The card chrome — a faithful local copy of the shipped `ui-settings-plugins`
|
|
3
|
+
* PluginCard (disclosure header, unsaved marker, save/discard footer), with
|
|
4
|
+
* the chevron inlined so the bundle stays self-contained.
|
|
5
|
+
*
|
|
6
|
+
* @module dsh-web-fetch-playwright/client/PluginCard
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { useState, type ReactNode } from 'react'
|
|
10
|
+
import type { CardShell } from './form.ts'
|
|
11
|
+
import css from './PluginCard.module.css'
|
|
12
|
+
|
|
13
|
+
/** Copy keys the chrome itself renders (the card's dictionary supplies them). */
|
|
14
|
+
export interface CardChromeCopy {
|
|
15
|
+
expand: string
|
|
16
|
+
collapse: string
|
|
17
|
+
unsaved: string
|
|
18
|
+
readOnly: string
|
|
19
|
+
saveFailed: string
|
|
20
|
+
discard: string
|
|
21
|
+
save: string
|
|
22
|
+
saving: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Card chrome props. */
|
|
26
|
+
export interface PluginCardProps {
|
|
27
|
+
/** Chrome copy (a subset of the card's locale keys). */
|
|
28
|
+
copy: CardChromeCopy
|
|
29
|
+
/** The plugin's display name. */
|
|
30
|
+
title: string
|
|
31
|
+
/** The line describing what this plugin's settings govern. */
|
|
32
|
+
description: string
|
|
33
|
+
/** The card's form state: availability, writability, and what a save would do. */
|
|
34
|
+
state: CardShell
|
|
35
|
+
/** Write every staged edit. */
|
|
36
|
+
onSave: () => void
|
|
37
|
+
/** Drop every staged edit. */
|
|
38
|
+
onDiscard: () => void
|
|
39
|
+
/** The plugin's controls. */
|
|
40
|
+
children: ReactNode
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function cx(...parts: Array<string | false | undefined>): string {
|
|
44
|
+
return parts.filter(part => typeof part === 'string').join(' ')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function ChevronDown({ className }: { className?: string }) {
|
|
48
|
+
return (
|
|
49
|
+
<svg className={className} width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
|
50
|
+
<path d="M4 6l4 4 4-4" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
|
|
51
|
+
</svg>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Render the Playwright card's chrome.
|
|
57
|
+
* @param props - the card's copy, name, form state, and controls.
|
|
58
|
+
* @returns the card, or nothing when the namespace is unavailable.
|
|
59
|
+
*/
|
|
60
|
+
export function PluginCard(props: PluginCardProps) {
|
|
61
|
+
const [open, setOpen] = useState(false)
|
|
62
|
+
const { state, copy } = props
|
|
63
|
+
if (!state.available) return null
|
|
64
|
+
const blocked = !state.dirty || state.invalid || state.saving
|
|
65
|
+
return (
|
|
66
|
+
<li className={cx(css.card, open && css.cardOpen)}>
|
|
67
|
+
<button
|
|
68
|
+
type="button"
|
|
69
|
+
className={css.header}
|
|
70
|
+
aria-expanded={open}
|
|
71
|
+
aria-label={`${open ? copy.collapse : copy.expand}: ${props.title}`}
|
|
72
|
+
onClick={() => { setOpen(!open) }}
|
|
73
|
+
>
|
|
74
|
+
<span className={css.headText}>
|
|
75
|
+
<span className={css.name}>{props.title}</span>
|
|
76
|
+
<span className={css.description}>{props.description}</span>
|
|
77
|
+
</span>
|
|
78
|
+
{state.dirty ? <span className={css.pending}>{copy.unsaved}</span> : null}
|
|
79
|
+
<ChevronDown className={cx(css.chevron, open && css.chevronOpen)} />
|
|
80
|
+
</button>
|
|
81
|
+
{open
|
|
82
|
+
? (
|
|
83
|
+
<div className={css.body}>
|
|
84
|
+
{!state.writable ? <p className={css.readOnly} role="status">{copy.readOnly}</p> : null}
|
|
85
|
+
{props.children}
|
|
86
|
+
<div className={css.footer}>
|
|
87
|
+
{state.failed ? <p className={css.failed} role="status">{copy.saveFailed}</p> : null}
|
|
88
|
+
<button
|
|
89
|
+
type="button"
|
|
90
|
+
className={css.discard}
|
|
91
|
+
disabled={!state.dirty || state.saving}
|
|
92
|
+
onClick={props.onDiscard}
|
|
93
|
+
>
|
|
94
|
+
{copy.discard}
|
|
95
|
+
</button>
|
|
96
|
+
<button
|
|
97
|
+
type="button"
|
|
98
|
+
className={css.save}
|
|
99
|
+
disabled={blocked}
|
|
100
|
+
onClick={props.onSave}
|
|
101
|
+
>
|
|
102
|
+
{state.saving ? copy.saving : copy.save}
|
|
103
|
+
</button>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
)
|
|
107
|
+
: null}
|
|
108
|
+
</li>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Playwright plugin-configuration card: backend radio group (each option
|
|
3
|
+
* carrying its backend-specific input nested inside — local path under Local
|
|
4
|
+
* Playwright, CDP endpoint under Remote CDP) plus the denoise checkbox,
|
|
5
|
+
* staged and saved through the card form like the built-in plugin cards.
|
|
6
|
+
*
|
|
7
|
+
* @module dsh-web-fetch-playwright/client/card
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
|
|
11
|
+
import { PluginCard } from './PluginCard.tsx'
|
|
12
|
+
import { CheckboxField, RadioGroupField, ValueField } from './fields.tsx'
|
|
13
|
+
import type { PlaywrightCardFace, PlaywrightCardState } from './controller.ts'
|
|
14
|
+
|
|
15
|
+
/** Props the renderer binds for the Playwright card. */
|
|
16
|
+
export type PlaywrightCardProps =
|
|
17
|
+
PropsRuntime<'settings.plugin.item'>
|
|
18
|
+
& PropsLocale<'web-fetch-playwright'>
|
|
19
|
+
& InjectFace<PlaywrightCardFace>
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Render the Playwright card.
|
|
23
|
+
* @param props - locale copy, the card snapshot, and its form actions.
|
|
24
|
+
* @returns the card.
|
|
25
|
+
*/
|
|
26
|
+
export function PlaywrightCard(props: PlaywrightCardProps) {
|
|
27
|
+
const { t } = props
|
|
28
|
+
const state = props.usePlaywrightCard(snapshot => snapshot)
|
|
29
|
+
const disabled = !state.writable
|
|
30
|
+
const backend = state.backend.text === 'cdp' ? 'cdp' : 'local'
|
|
31
|
+
return (
|
|
32
|
+
<PluginCard
|
|
33
|
+
copy={{
|
|
34
|
+
expand: t('expand'),
|
|
35
|
+
collapse: t('collapse'),
|
|
36
|
+
unsaved: t('unsaved'),
|
|
37
|
+
readOnly: t('readOnly'),
|
|
38
|
+
saveFailed: t('saveFailed'),
|
|
39
|
+
discard: t('discard'),
|
|
40
|
+
save: t('save'),
|
|
41
|
+
saving: t('saving'),
|
|
42
|
+
}}
|
|
43
|
+
title={t('title')}
|
|
44
|
+
description={t('description')}
|
|
45
|
+
state={state}
|
|
46
|
+
onSave={props.save}
|
|
47
|
+
onDiscard={props.discard}
|
|
48
|
+
>
|
|
49
|
+
<RadioGroupField
|
|
50
|
+
label={t('backendLabel')}
|
|
51
|
+
options={[
|
|
52
|
+
{
|
|
53
|
+
value: 'local',
|
|
54
|
+
label: t('backendLocal'),
|
|
55
|
+
hint: t('backendLocalHint'),
|
|
56
|
+
content: (
|
|
57
|
+
<ValueField
|
|
58
|
+
embedded
|
|
59
|
+
id="plugin-config-playwright-path"
|
|
60
|
+
label={t('playwrightPath')}
|
|
61
|
+
hint={t('playwrightPathHint')}
|
|
62
|
+
placeholder={t('playwrightPathPlaceholder')}
|
|
63
|
+
overriddenLabel={t('overridden')}
|
|
64
|
+
resetLabel={t('reset')}
|
|
65
|
+
invalidLabel={t('invalidText')}
|
|
66
|
+
disabled={disabled || backend !== 'local'}
|
|
67
|
+
{...state.playwrightPath}
|
|
68
|
+
onEdit={(text) => { props.edit('playwrightPath', text) }}
|
|
69
|
+
onReset={() => { props.resetField('playwrightPath') }}
|
|
70
|
+
/>
|
|
71
|
+
),
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
value: 'cdp',
|
|
75
|
+
label: t('backendCdp'),
|
|
76
|
+
hint: t('backendCdpHint'),
|
|
77
|
+
content: (
|
|
78
|
+
<ValueField
|
|
79
|
+
embedded
|
|
80
|
+
id="plugin-config-playwright-cdp"
|
|
81
|
+
label={t('cdpEndpoint')}
|
|
82
|
+
hint={t('cdpEndpointHint')}
|
|
83
|
+
placeholder="127.0.0.1:9222"
|
|
84
|
+
overriddenLabel={t('overridden')}
|
|
85
|
+
resetLabel={t('reset')}
|
|
86
|
+
invalidLabel={t('invalidText')}
|
|
87
|
+
disabled={disabled || backend !== 'cdp'}
|
|
88
|
+
{...state.cdpEndpoint}
|
|
89
|
+
onEdit={(text) => { props.edit('cdpEndpoint', text) }}
|
|
90
|
+
onReset={() => { props.resetField('cdpEndpoint') }}
|
|
91
|
+
/>
|
|
92
|
+
),
|
|
93
|
+
},
|
|
94
|
+
]}
|
|
95
|
+
text={state.backend.text}
|
|
96
|
+
overridden={state.backend.overridden}
|
|
97
|
+
overriddenLabel={t('overridden')}
|
|
98
|
+
resetLabel={t('reset')}
|
|
99
|
+
disabled={disabled}
|
|
100
|
+
onEdit={(text) => { props.edit('backend', text) }}
|
|
101
|
+
onReset={() => { props.resetField('backend') }}
|
|
102
|
+
/>
|
|
103
|
+
<CheckboxField
|
|
104
|
+
id="plugin-config-playwright-denoise"
|
|
105
|
+
label={t('denoise')}
|
|
106
|
+
hint={t('denoiseHint')}
|
|
107
|
+
checked={state.denoise.text !== 'false'}
|
|
108
|
+
overridden={state.denoise.overridden}
|
|
109
|
+
overriddenLabel={t('overridden')}
|
|
110
|
+
resetLabel={t('reset')}
|
|
111
|
+
disabled={disabled}
|
|
112
|
+
onEdit={(text) => { props.edit('denoise', text) }}
|
|
113
|
+
onReset={() => { props.resetField('denoise') }}
|
|
114
|
+
/>
|
|
115
|
+
</PluginCard>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Playwright card's controller: the staged form over the
|
|
3
|
+
* `web-fetch-playwright` settings namespace, projected into one snapshot the
|
|
4
|
+
* card's slot entry injects.
|
|
5
|
+
*
|
|
6
|
+
* @module dsh-web-fetch-playwright/client/controller
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { SettingsScope } from '@deepseek-ai/dsh-client-runtime/client'
|
|
10
|
+
import { CardForm, checkboxField, radioField, textField } from './form.ts'
|
|
11
|
+
import type { CardShell, CardFieldState, CardActions, SnapshotStore } from './form.ts'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Settings namespace this card edits. Spelled here rather than imported: a
|
|
15
|
+
* client package must not depend on a Host package.
|
|
16
|
+
*/
|
|
17
|
+
export const WEB_FETCH_PLAYWRIGHT_NS = 'web-fetch-playwright'
|
|
18
|
+
|
|
19
|
+
/** The section fields this card edits. */
|
|
20
|
+
export interface PlaywrightSettings {
|
|
21
|
+
/** Backend selector: local Playwright launch or a remote CDP endpoint. */
|
|
22
|
+
backend?: string
|
|
23
|
+
/** Local backend: playwright/browser executable path. */
|
|
24
|
+
playwrightPath?: string
|
|
25
|
+
/** CDP backend: endpoint (host:port / http(s) / ws). */
|
|
26
|
+
cdpEndpoint?: string
|
|
27
|
+
/** Whether the Readability + DOMPurify pipeline runs. */
|
|
28
|
+
denoise?: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** What the Playwright card renders. */
|
|
32
|
+
export interface PlaywrightCardState extends CardShell {
|
|
33
|
+
/** Backend radio group. */
|
|
34
|
+
backend: CardFieldState
|
|
35
|
+
/** Local-backend path input. */
|
|
36
|
+
playwrightPath: CardFieldState
|
|
37
|
+
/** CDP endpoint input. */
|
|
38
|
+
cdpEndpoint: CardFieldState
|
|
39
|
+
/** Denoise checkbox (draft 'true'/'false'). */
|
|
40
|
+
denoise: CardFieldState
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The registration-side face the card's slot entry injects. */
|
|
44
|
+
export interface PlaywrightCardFace extends CardActions {
|
|
45
|
+
hooks: {
|
|
46
|
+
/** Card snapshot bound by the renderer as usePlaywrightCard. */
|
|
47
|
+
playwrightCard: SnapshotStore<PlaywrightCardState>
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Bridges the `web-fetch-playwright` settings scope onto the card. */
|
|
52
|
+
export class PlaywrightCardController {
|
|
53
|
+
private readonly form: CardForm<PlaywrightSettings>
|
|
54
|
+
private readonly store: SnapshotStore<PlaywrightCardState>
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @param scope - the bound settings scope for the `web-fetch-playwright` namespace.
|
|
58
|
+
*/
|
|
59
|
+
constructor(scope: SettingsScope<PlaywrightSettings>) {
|
|
60
|
+
this.form = new CardForm(
|
|
61
|
+
scope,
|
|
62
|
+
[
|
|
63
|
+
radioField('backend', ['local', 'cdp']),
|
|
64
|
+
textField('playwrightPath'),
|
|
65
|
+
textField('cdpEndpoint'),
|
|
66
|
+
checkboxField('denoise'),
|
|
67
|
+
],
|
|
68
|
+
)
|
|
69
|
+
this.store = this.form.bind(() => this.projection())
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private projection(): PlaywrightCardState {
|
|
73
|
+
return {
|
|
74
|
+
...this.form.shell(),
|
|
75
|
+
backend: this.form.field('backend'),
|
|
76
|
+
playwrightPath: this.form.field('playwrightPath'),
|
|
77
|
+
cdpEndpoint: this.form.field('cdpEndpoint'),
|
|
78
|
+
denoise: this.form.field('denoise'),
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Build the face the card's slot registration injects.
|
|
84
|
+
* @returns the card's snapshot and its form actions.
|
|
85
|
+
*/
|
|
86
|
+
inject(): PlaywrightCardFace {
|
|
87
|
+
return { hooks: { playwrightCard: this.store }, ...this.form.actions() }
|
|
88
|
+
}
|
|
89
|
+
}
|