dsh-web-fetch-playwright 0.2.7 → 0.2.8
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 +4 -4
- package/README.zh-CN.md +4 -4
- package/lib/client.js +138 -165
- package/lib/index.js +70 -30
- package/lib/types/client/PluginCard.d.ts +15 -19
- package/lib/types/client/card.d.ts +12 -5
- package/lib/types/client/controller.d.ts +18 -8
- package/lib/types/client/form.d.ts +17 -9
- package/lib/types/client/index.d.ts +17 -6
- package/lib/types/client/locales.d.ts +1 -1
- package/lib/types/config.d.ts +73 -1
- package/lib/types/index.d.ts +29 -11
- package/package.json +12 -15
- package/src/client/PluginCard.module.css +6 -86
- package/src/client/PluginCard.tsx +38 -76
- package/src/client/card.tsx +18 -12
- package/src/client/controller.ts +21 -8
- package/src/client/form.ts +35 -15
- package/src/client/index.ts +64 -18
- package/src/client/locales.ts +3 -11
- package/src/config.ts +94 -12
- package/src/index.ts +51 -30
|
@@ -1,80 +1,12 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
the built-in
|
|
1
|
+
/* Form chrome — built on the same dsw-alias tokens and rhythm as the
|
|
2
|
+
shipped plugin-configuration forms so the card is indistinguishable from
|
|
3
|
+
the built-in ones. Since dsh 0.1.7 the Plugins page draws the title,
|
|
4
|
+
description, and navigation around a configuration entry; this holds the
|
|
5
|
+
form body and its footer only. */
|
|
4
6
|
|
|
5
|
-
.
|
|
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;
|
|
7
|
+
.form {
|
|
46
8
|
display: flex;
|
|
47
9
|
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
10
|
}
|
|
79
11
|
|
|
80
12
|
.readOnly {
|
|
@@ -84,18 +16,6 @@
|
|
|
84
16
|
color: var(--dsw-alias-label-tertiary);
|
|
85
17
|
}
|
|
86
18
|
|
|
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
19
|
.footer {
|
|
100
20
|
display: flex;
|
|
101
21
|
align-items: center;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
3
|
-
*
|
|
4
|
-
* the
|
|
2
|
+
* The form chrome — a page-level container (read-only notice, the staged
|
|
3
|
+
* controls, and the save/discard footer), in the rhythm of the shipped
|
|
4
|
+
* plugin-configuration forms. Since the Plugins page (dsh ≥ 0.1.7) draws the
|
|
5
|
+
* title, description, and navigation around a configuration entry, this is
|
|
6
|
+
* the body only; the disclosure header of the old settings-list card is
|
|
7
|
+
* gone with that seat.
|
|
5
8
|
*
|
|
6
9
|
* @module dsh-web-fetch-playwright/client/PluginCard
|
|
7
10
|
*/
|
|
8
11
|
|
|
9
|
-
import {
|
|
12
|
+
import type { ReactNode } from 'react'
|
|
10
13
|
import type { CardShell } from './form.ts'
|
|
11
14
|
import css from './PluginCard.module.css'
|
|
12
15
|
|
|
13
16
|
/** Copy keys the chrome itself renders (the card's dictionary supplies them). */
|
|
14
|
-
export interface
|
|
15
|
-
expand: string
|
|
16
|
-
collapse: string
|
|
17
|
-
unsaved: string
|
|
17
|
+
export interface CardFormCopy {
|
|
18
18
|
readOnly: string
|
|
19
19
|
saveFailed: string
|
|
20
20
|
discard: string
|
|
@@ -22,14 +22,10 @@ export interface CardChromeCopy {
|
|
|
22
22
|
saving: string
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
/**
|
|
26
|
-
export interface
|
|
25
|
+
/** Form chrome props. */
|
|
26
|
+
export interface CardFormProps {
|
|
27
27
|
/** Chrome copy (a subset of the card's locale keys). */
|
|
28
|
-
copy:
|
|
29
|
-
/** The plugin's display name. */
|
|
30
|
-
title: string
|
|
31
|
-
/** The line describing what this plugin's settings govern. */
|
|
32
|
-
description: string
|
|
28
|
+
copy: CardFormCopy
|
|
33
29
|
/** The card's form state: availability, writability, and what a save would do. */
|
|
34
30
|
state: CardShell
|
|
35
31
|
/** Write every staged edit. */
|
|
@@ -40,71 +36,37 @@ export interface PluginCardProps {
|
|
|
40
36
|
children: ReactNode
|
|
41
37
|
}
|
|
42
38
|
|
|
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
39
|
/**
|
|
56
|
-
* Render the Playwright
|
|
57
|
-
* @param props - the
|
|
58
|
-
* @returns the
|
|
40
|
+
* Render the Playwright form's chrome.
|
|
41
|
+
* @param props - the form's copy, form state, and controls.
|
|
42
|
+
* @returns the form body with its footer.
|
|
59
43
|
*/
|
|
60
|
-
export function
|
|
61
|
-
const [open, setOpen] = useState(false)
|
|
44
|
+
export function CardForm(props: CardFormProps) {
|
|
62
45
|
const { state, copy } = props
|
|
63
|
-
if (!state.available) return null
|
|
64
46
|
const blocked = !state.dirty || state.invalid || state.saving
|
|
65
47
|
return (
|
|
66
|
-
<
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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>
|
|
48
|
+
<div className={css.form}>
|
|
49
|
+
{!state.writable ? <p className={css.readOnly} role="status">{copy.readOnly}</p> : null}
|
|
50
|
+
{props.children}
|
|
51
|
+
<div className={css.footer}>
|
|
52
|
+
{state.failed ? <p className={css.failed} role="status">{copy.saveFailed}</p> : null}
|
|
53
|
+
<button
|
|
54
|
+
type="button"
|
|
55
|
+
className={css.discard}
|
|
56
|
+
disabled={!state.dirty || state.saving}
|
|
57
|
+
onClick={props.onDiscard}
|
|
58
|
+
>
|
|
59
|
+
{copy.discard}
|
|
60
|
+
</button>
|
|
61
|
+
<button
|
|
62
|
+
type="button"
|
|
63
|
+
className={css.save}
|
|
64
|
+
disabled={blocked}
|
|
65
|
+
onClick={props.onSave}
|
|
66
|
+
>
|
|
67
|
+
{state.saving ? copy.saving : copy.save}
|
|
68
|
+
</button>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
109
71
|
)
|
|
110
72
|
}
|
package/src/client/card.tsx
CHANGED
|
@@ -5,44 +5,50 @@
|
|
|
5
5
|
* the denoise checkbox, staged and saved through the card form like the
|
|
6
6
|
* built-in plugin cards.
|
|
7
7
|
*
|
|
8
|
+
* The Plugins page asks for `view: 'summary'` (a row's description
|
|
9
|
+
* fallback) or `view: 'page'` (this form). The same component serves both
|
|
10
|
+
* seats it is registered into: the bundle's own page (between its
|
|
11
|
+
* description and its rows) and the row's page (under the plugin's own
|
|
12
|
+
* title); one controller stages the edits shared by the two.
|
|
13
|
+
*
|
|
8
14
|
* @module dsh-web-fetch-playwright/client/card
|
|
9
15
|
*/
|
|
10
16
|
|
|
11
17
|
import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
|
|
12
|
-
import {
|
|
18
|
+
import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
|
|
19
|
+
import type {} from '@deepseek-ai/dsh-client-ui-plugin-manager/client'
|
|
20
|
+
import { CardForm } from './PluginCard.tsx'
|
|
13
21
|
import { CheckboxField, RadioGroupField, ValueField } from './fields.tsx'
|
|
14
22
|
import type { PlaywrightCardFace, PlaywrightCardState } from './controller.ts'
|
|
15
23
|
|
|
16
24
|
/** Props the renderer binds for the Playwright card. */
|
|
17
25
|
export type PlaywrightCardProps =
|
|
18
|
-
PropsRuntime<'
|
|
26
|
+
(PropsRuntime<'plugins.bundle.config'> | PropsRuntime<'plugins.row.config'>)
|
|
19
27
|
& PropsLocale<'web-fetch-playwright'>
|
|
20
28
|
& InjectFace<PlaywrightCardFace>
|
|
21
29
|
|
|
22
30
|
/**
|
|
23
|
-
* Render the Playwright card
|
|
24
|
-
*
|
|
25
|
-
* @
|
|
31
|
+
* Render the Playwright card: its one-liner for the list, or the staged form
|
|
32
|
+
* for the page.
|
|
33
|
+
* @param props - the view asked for, locale copy, the card snapshot, and its form actions.
|
|
34
|
+
* @returns the one-liner, the form, or nothing while the namespace is unavailable.
|
|
26
35
|
*/
|
|
27
36
|
export function PlaywrightCard(props: PlaywrightCardProps) {
|
|
28
37
|
const { t } = props
|
|
38
|
+
if (props.view === 'summary') return t('description')
|
|
29
39
|
const state = props.usePlaywrightCard(snapshot => snapshot)
|
|
40
|
+
if (!state.available) return null
|
|
30
41
|
const disabled = !state.writable
|
|
31
42
|
const backend = state.backend.text === 'cdp' ? 'cdp' : 'local'
|
|
32
43
|
return (
|
|
33
|
-
<
|
|
44
|
+
<CardForm
|
|
34
45
|
copy={{
|
|
35
|
-
expand: t('expand'),
|
|
36
|
-
collapse: t('collapse'),
|
|
37
|
-
unsaved: t('unsaved'),
|
|
38
46
|
readOnly: t('readOnly'),
|
|
39
47
|
saveFailed: t('saveFailed'),
|
|
40
48
|
discard: t('discard'),
|
|
41
49
|
save: t('save'),
|
|
42
50
|
saving: t('saving'),
|
|
43
51
|
}}
|
|
44
|
-
title={t('title')}
|
|
45
|
-
description={t('description')}
|
|
46
52
|
state={state}
|
|
47
53
|
onSave={props.save}
|
|
48
54
|
onDiscard={props.discard}
|
|
@@ -154,6 +160,6 @@ export function PlaywrightCard(props: PlaywrightCardProps) {
|
|
|
154
160
|
onEdit={(text) => { props.edit('challengeWaitMs', text) }}
|
|
155
161
|
onReset={() => { props.resetField('challengeWaitMs') }}
|
|
156
162
|
/>
|
|
157
|
-
</
|
|
163
|
+
</CardForm>
|
|
158
164
|
)
|
|
159
165
|
}
|
package/src/client/controller.ts
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The Playwright card's controller: the staged form over the
|
|
3
|
-
* `web-fetch-playwright`
|
|
4
|
-
* card's slot entry injects.
|
|
3
|
+
* `web-fetch-playwright` plugin-entry configuration form, projected into one
|
|
4
|
+
* snapshot the card's slot entry injects.
|
|
5
|
+
*
|
|
6
|
+
* Since dsh 0.1.7 the scope is the shared `configForms` form for the plugin
|
|
7
|
+
* entry — the host's settings service derives the section from the plugin's
|
|
8
|
+
* Config schema (its volatile fields), keyed by the composition entry id.
|
|
5
9
|
*
|
|
6
10
|
* @module dsh-web-fetch-playwright/client/controller
|
|
7
11
|
*/
|
|
8
12
|
|
|
9
|
-
import type {
|
|
13
|
+
import type { ConfigForm } from '@deepseek-ai/dsh-client-ui-settings/client'
|
|
10
14
|
import { CardForm, checkboxField, numberField, radioField, textField } from './form.ts'
|
|
11
15
|
import type { CardShell, CardFieldState, CardActions, SnapshotStore } from './form.ts'
|
|
12
16
|
|
|
13
17
|
/**
|
|
14
|
-
* Settings namespace this card edits
|
|
15
|
-
*
|
|
18
|
+
* Settings namespace this card edits: the composition entry id, which is
|
|
19
|
+
* what the host's settings service keys the section derived from the
|
|
20
|
+
* plugin's Config schema by. Spelled here rather than imported: a client
|
|
21
|
+
* package must not depend on a Host package.
|
|
16
22
|
*/
|
|
17
23
|
export const WEB_FETCH_PLAYWRIGHT_NS = 'web-fetch-playwright'
|
|
18
24
|
|
|
@@ -67,15 +73,17 @@ export interface PlaywrightCardFace extends CardActions {
|
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
75
|
|
|
70
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* Bridges the `web-fetch-playwright` configuration form onto the card.
|
|
78
|
+
*/
|
|
71
79
|
export class PlaywrightCardController {
|
|
72
80
|
private readonly form: CardForm<PlaywrightSettings>
|
|
73
81
|
private readonly store: SnapshotStore<PlaywrightCardState>
|
|
74
82
|
|
|
75
83
|
/**
|
|
76
|
-
* @param scope - the
|
|
84
|
+
* @param scope - the shared configuration form for the `web-fetch-playwright` entry.
|
|
77
85
|
*/
|
|
78
|
-
constructor(scope:
|
|
86
|
+
constructor(scope: ConfigForm<PlaywrightSettings>) {
|
|
79
87
|
this.form = new CardForm(
|
|
80
88
|
scope,
|
|
81
89
|
[
|
|
@@ -111,4 +119,9 @@ export class PlaywrightCardController {
|
|
|
111
119
|
inject(): PlaywrightCardFace {
|
|
112
120
|
return { hooks: { playwrightCard: this.store }, ...this.form.actions() }
|
|
113
121
|
}
|
|
122
|
+
|
|
123
|
+
/** Release the form subscription and every bound stores. */
|
|
124
|
+
dispose(): void {
|
|
125
|
+
this.form.dispose()
|
|
126
|
+
}
|
|
114
127
|
}
|
package/src/client/form.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The staged-form model behind the Playwright card — a faithful subset of the
|
|
3
|
-
* shipped
|
|
3
|
+
* shipped plugin-configuration CardForm (same staging semantics: edits stay
|
|
4
4
|
* local until the card's save, presence in the user layer — not value
|
|
5
5
|
* equality — marks a field overridden), plus the two field kinds this card
|
|
6
6
|
* adds: a radio group (backend) and a checkbox (denoise), staged through the
|
|
7
|
-
* same draft mechanism as text.
|
|
7
|
+
* same draft mechanism as text. Since dsh 0.1.7 the scope is the shared
|
|
8
|
+
* `configForms` form for the plugin entry (reads ride the describe mirror;
|
|
9
|
+
* writes are revision-fenced path mutations).
|
|
8
10
|
*
|
|
9
11
|
* Bundled locally because external client bundles cannot value-import
|
|
10
12
|
* `@deepseek-ai/*` packages; the snapshot store is a local structural clone
|
|
@@ -13,7 +15,7 @@
|
|
|
13
15
|
* @module dsh-web-fetch-playwright/client/form
|
|
14
16
|
*/
|
|
15
17
|
|
|
16
|
-
import type {
|
|
18
|
+
import type { ConfigForm, ConfigFormSnapshot } from '@deepseek-ai/dsh-client-ui-settings/client'
|
|
17
19
|
|
|
18
20
|
/** The write one field's staged draft performs when the card is saved. */
|
|
19
21
|
export type FieldWrite =
|
|
@@ -164,27 +166,35 @@ export function numberField(field: string, min: number, max: number): CardFieldS
|
|
|
164
166
|
}
|
|
165
167
|
|
|
166
168
|
/**
|
|
167
|
-
* Stages the Playwright card's edits over one
|
|
168
|
-
* them on save. Publishes through a snapshot store because
|
|
169
|
-
* read through a selector while both the
|
|
169
|
+
* Stages the Playwright card's edits over one plugin-entry configuration
|
|
170
|
+
* form and writes them on save. Publishes through a snapshot store because
|
|
171
|
+
* slot components read through a selector while both the form and the drafts
|
|
172
|
+
* change below.
|
|
170
173
|
*/
|
|
171
174
|
export class CardForm<T> {
|
|
172
175
|
private readonly specs: Map<string, CardFieldSpec>
|
|
173
176
|
private readonly staged = new Map<string, StagedEdit>()
|
|
174
177
|
private readonly listeners = new Set<() => void>()
|
|
178
|
+
private readonly unsubscribe: () => void
|
|
175
179
|
private saving = false
|
|
176
180
|
private failed = false
|
|
177
181
|
|
|
178
182
|
/**
|
|
179
|
-
* @param scope - the
|
|
183
|
+
* @param scope - the shared configuration form for this plugin's entry.
|
|
180
184
|
* @param specs - the section fields this card edits.
|
|
181
185
|
*/
|
|
182
186
|
constructor(
|
|
183
|
-
private readonly scope:
|
|
187
|
+
private readonly scope: ConfigForm<T>,
|
|
184
188
|
specs: CardFieldSpec[],
|
|
185
189
|
) {
|
|
186
190
|
this.specs = new Map(specs.map(spec => [spec.field, spec]))
|
|
187
|
-
scope.subscribe(() => { this.publish() })
|
|
191
|
+
this.unsubscribe = scope.subscribe(() => { this.publish() })
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** Release the form subscription and every bound stores. */
|
|
195
|
+
dispose(): void {
|
|
196
|
+
this.unsubscribe()
|
|
197
|
+
this.listeners.clear()
|
|
188
198
|
}
|
|
189
199
|
|
|
190
200
|
/**
|
|
@@ -270,7 +280,9 @@ export class CardForm<T> {
|
|
|
270
280
|
/**
|
|
271
281
|
* Write every staged edit, then re-seed from what the Host accepted. A save
|
|
272
282
|
* that did not land keeps its drafts, so the user corrects them instead of
|
|
273
|
-
* retyping.
|
|
283
|
+
* retyping. The shared form reports `false` (and reloads Host state) for a
|
|
284
|
+
* refused revision or validation, and a transport drop rejects — both fold
|
|
285
|
+
* into the same failed-save path.
|
|
274
286
|
*/
|
|
275
287
|
async save(): Promise<void> {
|
|
276
288
|
const plan = this.plan()
|
|
@@ -312,13 +324,21 @@ export class CardForm<T> {
|
|
|
312
324
|
}
|
|
313
325
|
|
|
314
326
|
private async clear(field: string): Promise<boolean> {
|
|
315
|
-
|
|
316
|
-
|
|
327
|
+
try {
|
|
328
|
+
return await this.scope.unset(field)
|
|
329
|
+
} catch (_sectionWriteFailure) {
|
|
330
|
+
// The Host refused the write: keep the drafts, flag the failure.
|
|
331
|
+
return false
|
|
332
|
+
}
|
|
317
333
|
}
|
|
318
334
|
|
|
319
335
|
private async store(field: string, value: unknown): Promise<boolean> {
|
|
320
|
-
|
|
321
|
-
|
|
336
|
+
try {
|
|
337
|
+
return await this.scope.set(field, value)
|
|
338
|
+
} catch (_sectionWriteFailure) {
|
|
339
|
+
// The Host refused the write: keep the drafts, flag the failure.
|
|
340
|
+
return false
|
|
341
|
+
}
|
|
322
342
|
}
|
|
323
343
|
|
|
324
344
|
private stage(field: string, edit: StagedEdit): void {
|
|
@@ -333,7 +353,7 @@ export class CardForm<T> {
|
|
|
333
353
|
return spec
|
|
334
354
|
}
|
|
335
355
|
|
|
336
|
-
private snapshotOf():
|
|
356
|
+
private snapshotOf(): ConfigFormSnapshot<T> {
|
|
337
357
|
return this.scope.getSnapshot()
|
|
338
358
|
}
|
|
339
359
|
|
package/src/client/index.ts
CHANGED
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Browser half of `dsh-web-fetch-playwright`: registers the locale
|
|
3
|
-
* and the plugin-configuration card keyed by the
|
|
4
|
-
* settings namespace
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* Browser half of `dsh-web-fetch-playwright`: registers the locale
|
|
3
|
+
* dictionary and the plugin-configuration card keyed by the
|
|
4
|
+
* `web-fetch-playwright` settings namespace (the composition entry id the
|
|
5
|
+
* host's settings service derives from the plugin's Config schema).
|
|
6
|
+
*
|
|
7
|
+
* Since dsh 0.1.7 the Plugins page owns a plugin's configuration, and its
|
|
8
|
+
* slot contract offers a bundle two seats: the bundle's own form on its
|
|
9
|
+
* package page (`plugins.bundle.config`, keyed by package name — what the
|
|
10
|
+
* user opens straight from the plugin list) and one row's page
|
|
11
|
+
* (`plugins.row.config`, keyed `<package name>#<row id>` — the row's
|
|
12
|
+
* configure control). This bundle is one plugin with one config, so BOTH
|
|
13
|
+
* seats inject the SAME card and controller: whichever way the user arrives,
|
|
14
|
+
* the form is on the first page they land on, and one staging area follows
|
|
15
|
+
* them between the two. The mounts ride `configForms.whileServed`, so a
|
|
16
|
+
* deployment that never composed the host entry shows no trace of the card.
|
|
7
17
|
*
|
|
8
18
|
* @module dsh-web-fetch-playwright/client
|
|
9
19
|
*/
|
|
10
20
|
|
|
11
21
|
import type { Context } from 'cordis'
|
|
12
|
-
// Type-only: pulls the ctx.
|
|
13
|
-
//
|
|
14
|
-
//
|
|
22
|
+
// Type-only: pulls the ctx.configForms Context merge (the shared forms
|
|
23
|
+
// service) from the owning client package, the ctx.slots merge from the
|
|
24
|
+
// renderer, and the 'plugins.bundle.config' / 'plugins.row.config' SlotMap
|
|
25
|
+
// declarations from the Plugins page (type-only imports are erased before
|
|
26
|
+
// the purity gate).
|
|
15
27
|
import type {} from '@deepseek-ai/dsh-client-locale/client'
|
|
16
28
|
import type {} from '@deepseek-ai/dsh-client-ui-slots'
|
|
29
|
+
import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
|
|
17
30
|
import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
|
|
18
|
-
import type {} from '@deepseek-ai/dsh-client-ui-
|
|
31
|
+
import type {} from '@deepseek-ai/dsh-client-ui-plugin-manager/client'
|
|
19
32
|
import { PlaywrightCardController, WEB_FETCH_PLAYWRIGHT_NS } from './controller.ts'
|
|
20
33
|
import { PlaywrightCard } from './card.tsx'
|
|
21
34
|
import { en, zh } from './locales.ts'
|
|
@@ -23,23 +36,56 @@ import { en, zh } from './locales.ts'
|
|
|
23
36
|
/** Dictionary namespace owned by this plugin. */
|
|
24
37
|
const NS = 'web-fetch-playwright'
|
|
25
38
|
|
|
39
|
+
/**
|
|
40
|
+
* This bundle's package name — the Plugins page keys a bundle's own
|
|
41
|
+
* configuration by it. Spelled here rather than read from any manifest:
|
|
42
|
+
* this bundle must stay self-contained.
|
|
43
|
+
*/
|
|
44
|
+
const PACKAGE_NAME = 'dsh-web-fetch-playwright'
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The row's configuration key `<package name>#<row id>` with the row id as
|
|
48
|
+
* the bundle's patch declares it.
|
|
49
|
+
*/
|
|
50
|
+
const ROW_CONFIG_KEY = `${PACKAGE_NAME}#web-fetch-playwright`
|
|
51
|
+
|
|
26
52
|
/** Required services (cordis fiber inject). */
|
|
27
|
-
export const inject = ['slots', 'locale', '
|
|
53
|
+
export const inject = ['slots', 'locale', 'configForms']
|
|
28
54
|
|
|
29
55
|
/**
|
|
30
|
-
* Mount the Playwright plugin-configuration card
|
|
56
|
+
* Mount the Playwright plugin-configuration card while the Host serves the
|
|
57
|
+
* `web-fetch-playwright` namespace.
|
|
31
58
|
* @param ctx - the browser plugin context.
|
|
32
59
|
*/
|
|
33
60
|
export function apply(ctx: Context): void {
|
|
34
61
|
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'web-fetch-playwright: card dictionary')
|
|
35
62
|
|
|
36
63
|
const controller = new PlaywrightCardController(
|
|
37
|
-
ctx.
|
|
64
|
+
ctx.configForms.get(WEB_FETCH_PLAYWRIGHT_NS),
|
|
65
|
+
)
|
|
66
|
+
ctx.effect(() => () => { controller.dispose() }, 'web-fetch-playwright: form subscription')
|
|
67
|
+
|
|
68
|
+
// The card's two seats on the Plugins page, one shared controller behind
|
|
69
|
+
// both: the bundle's own page shows the form between its description and
|
|
70
|
+
// its rows, and the row keeps its configure control opening the same form
|
|
71
|
+
// under the plugin's own title. `whileServed` owns both mounts, so a host
|
|
72
|
+
// without the entry never renders an empty section.
|
|
73
|
+
ctx.effect(
|
|
74
|
+
() => ctx.configForms.whileServed([WEB_FETCH_PLAYWRIGHT_NS], () => {
|
|
75
|
+
const offBundle = ctx.slots.inject('plugins.bundle.config', () => ctx.slots.register({
|
|
76
|
+
name: 'plugins.bundle.config',
|
|
77
|
+
key: PACKAGE_NAME,
|
|
78
|
+
locale: NS,
|
|
79
|
+
inject: () => controller.inject(),
|
|
80
|
+
}, PlaywrightCard))
|
|
81
|
+
const offRow = ctx.slots.inject('plugins.row.config', () => ctx.slots.register({
|
|
82
|
+
name: 'plugins.row.config',
|
|
83
|
+
key: ROW_CONFIG_KEY,
|
|
84
|
+
locale: NS,
|
|
85
|
+
inject: () => controller.inject(),
|
|
86
|
+
}, PlaywrightCard))
|
|
87
|
+
return () => { offBundle(); offRow() }
|
|
88
|
+
}),
|
|
89
|
+
'web-fetch-playwright: plugins-page card',
|
|
38
90
|
)
|
|
39
|
-
ctx.slots.inject('settings.plugin.item', () => ctx.slots.register({
|
|
40
|
-
name: 'settings.plugin.item',
|
|
41
|
-
key: WEB_FETCH_PLAYWRIGHT_NS,
|
|
42
|
-
locale: NS,
|
|
43
|
-
inject: () => controller.inject(),
|
|
44
|
-
}, PlaywrightCard))
|
|
45
91
|
}
|
package/src/client/locales.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
/** Locale keys this card renders. */
|
|
9
9
|
export type PlaywrightCardLocaleKey =
|
|
10
|
-
| '
|
|
10
|
+
| 'description'
|
|
11
11
|
| 'backendLabel' | 'backendLocal' | 'backendLocalHint' | 'backendCdp' | 'backendCdpHint'
|
|
12
12
|
| 'playwrightPath' | 'playwrightPathHint' | 'playwrightPathPlaceholder'
|
|
13
13
|
| 'cdpEndpoint' | 'cdpEndpointHint'
|
|
@@ -15,8 +15,8 @@ export type PlaywrightCardLocaleKey =
|
|
|
15
15
|
| 'denoise' | 'denoiseHint'
|
|
16
16
|
| 'maxConcurrency' | 'maxConcurrencyHint' | 'maxConcurrencyPlaceholder'
|
|
17
17
|
| 'challengeWaitMs' | 'challengeWaitMsHint' | 'challengeWaitMsPlaceholder'
|
|
18
|
-
| 'overridden' | 'reset' | 'readOnly'
|
|
19
|
-
| 'save' | 'saving' | 'discard' | '
|
|
18
|
+
| 'overridden' | 'reset' | 'readOnly'
|
|
19
|
+
| 'save' | 'saving' | 'discard' | 'saveFailed' | 'invalidText'
|
|
20
20
|
|
|
21
21
|
/** This plugin's dictionary namespace, merged into the locale key map. */
|
|
22
22
|
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
@@ -27,7 +27,6 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
|
27
27
|
|
|
28
28
|
/** English copy. */
|
|
29
29
|
export const en: Record<PlaywrightCardLocaleKey, string> = {
|
|
30
|
-
title: 'Playwright web fetch',
|
|
31
30
|
description: 'Fetches pages with a real browser (local Playwright or CDP) and returns denoised markdown.',
|
|
32
31
|
backendLabel: 'Playwright backend',
|
|
33
32
|
backendLocal: 'Local Playwright',
|
|
@@ -52,19 +51,15 @@ export const en: Record<PlaywrightCardLocaleKey, string> = {
|
|
|
52
51
|
overridden: 'Overridden',
|
|
53
52
|
reset: 'Reset to default',
|
|
54
53
|
readOnly: 'This deployment stores settings read-only.',
|
|
55
|
-
expand: 'Show settings',
|
|
56
|
-
collapse: 'Hide settings',
|
|
57
54
|
save: 'Save',
|
|
58
55
|
saving: 'Saving…',
|
|
59
56
|
discard: 'Discard',
|
|
60
|
-
unsaved: 'Unsaved',
|
|
61
57
|
saveFailed: 'The deployment did not accept these values; they were left for you to correct.',
|
|
62
58
|
invalidText: 'This value is not accepted here.',
|
|
63
59
|
}
|
|
64
60
|
|
|
65
61
|
/** Simplified Chinese copy. */
|
|
66
62
|
export const zh: Record<PlaywrightCardLocaleKey, string> = {
|
|
67
|
-
title: 'Playwright 网页爬取',
|
|
68
63
|
description: '用真实浏览器(本地 Playwright 或 CDP)抓取网页,降噪后转为 Markdown。',
|
|
69
64
|
backendLabel: 'Playwright 后端',
|
|
70
65
|
backendLocal: '本地 Playwright',
|
|
@@ -89,12 +84,9 @@ export const zh: Record<PlaywrightCardLocaleKey, string> = {
|
|
|
89
84
|
overridden: '已覆盖',
|
|
90
85
|
reset: '恢复默认',
|
|
91
86
|
readOnly: '本部署的设置为只读。',
|
|
92
|
-
expand: '展开设置',
|
|
93
|
-
collapse: '收起设置',
|
|
94
87
|
save: '保存',
|
|
95
88
|
saving: '保存中…',
|
|
96
89
|
discard: '放弃修改',
|
|
97
|
-
unsaved: '未保存',
|
|
98
90
|
saveFailed: '本部署没有接受这些值,已保留供你修改。',
|
|
99
91
|
invalidText: '该值不被此设置项接受。',
|
|
100
92
|
}
|