dsh-web-fetch-playwright 0.2.7 → 0.2.9

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.
@@ -1,18 +1,22 @@
1
1
  /**
2
2
  * `dsh-web-fetch-playwright`: registers the Playwright/CDP
3
- * {@link PlaywrightFetchProvider} with `ctx.web` and exposes its settings
4
- * section ('web-fetch-playwright') so the web client's plugin-configuration
5
- * card can edit it live.
3
+ * {@link PlaywrightFetchProvider} with `ctx.web`.
4
+ *
5
+ * The `web-fetch-playwright` settings section is derived from this plugin's
6
+ * `Config` schema (dsh ≥ 0.1.7): its volatile fields are editable live on
7
+ * the Plugins page, and a committed change is pushed into the running
8
+ * config's volatile references — the provider re-reads them per fetch, so an
9
+ * edit reaches the next request without a restart or re-registration.
6
10
  *
7
11
  * A function plugin (NOT a default-export service): like the shipped search
8
- * providers, it registers INTO the seam's fetch registry.
12
+ * providers, it registers INTO the web seam's fetch registry.
9
13
  *
10
14
  * @module dsh-web-fetch-playwright
11
15
  */
12
16
  import type { Context } from '@deepseek-ai/cordis';
13
- import { Config } from './config.ts';
14
- export { Config, DEFAULT_CDP_ENDPOINT, DEFAULT_CHALLENGE_RETRIES, DEFAULT_CHALLENGE_WAIT_MS, effectiveChallengeRetries, effectiveChallengeWaitMs, effectiveContextMode, normalizeCdpEndpoint } from './config.ts';
15
- export type { Config as PlaywrightFetchConfig, CdpContextMode, PlaywrightBackend, ResolvedConfig } from './config.ts';
17
+ import type { PlaywrightPluginConfig } from './config.ts';
18
+ export { Config, DEFAULT_CDP_ENDPOINT, DEFAULT_CHALLENGE_RETRIES, DEFAULT_CHALLENGE_WAIT_MS, effectiveChallengeRetries, effectiveChallengeWaitMs, effectiveContextMode, normalizeCdpEndpoint, resolveConfig, snapshotsOf, } from './config.ts';
19
+ export type { Config as PlaywrightFetchConfig, CdpContextMode, PlaywrightBackend, PlaywrightPluginConfig, ResolvedConfig, } from './config.ts';
16
20
  export { CdpConnectionPool } from './cdp-pool.ts';
17
21
  export type { CdpAcquireMode, CdpConnect, CdpLease } from './cdp-pool.ts';
18
22
  export { CHALLENGE_DOM_PROBE, CHALLENGE_FINISH_RESERVE_MS, CHALLENGE_POLL_INTERVAL_MS, CHALLENGE_TITLE_RE, classifyChallengeHtml, classifyChallengeResponse, isChallengeCompatibleResponse } from './challenge.ts';
@@ -22,9 +26,23 @@ export { htmlToMarkdown } from './markdown.ts';
22
26
  export type { DenoiseMode, DenoiseResult } from './markdown.ts';
23
27
  /** Cordis plugin name used by loader diagnostics. */
24
28
  export declare const name = "dsh-web-fetch-playwright";
25
- /** The web seam this provider registers into. */
29
+ /**
30
+ * The capability seam this plugin registers into. The settings section
31
+ * needs no inject: the host's settings service derives it from the entry's
32
+ * `Config` schema (its volatile fields) by entry id.
33
+ */
26
34
  export declare const inject: string[];
27
- /** Settings namespace carrying this provider's configuration card. */
35
+ /**
36
+ * Settings namespace carrying this provider's configuration page: the
37
+ * composition entry id, which is what the settings service keys the
38
+ * derived section by.
39
+ */
28
40
  export declare const WEB_FETCH_PLAYWRIGHT_SETTINGS_NAMESPACE = "web-fetch-playwright";
29
- /** Register the Playwright fetch provider with `ctx.web`. */
30
- export declare function apply(ctx: Context, config: Config): void;
41
+ /**
42
+ * Register the Playwright fetch provider with `ctx.web`.
43
+ *
44
+ * @param ctx - plugin context supplying the web seam.
45
+ * @param config - the loader-resolved plugin config; its volatile fields are
46
+ * live references a settings commit updates in place.
47
+ */
48
+ export declare function apply(ctx: Context, config: PlaywrightPluginConfig): void;
@@ -11,7 +11,10 @@
11
11
  * options and span-safe table rules as the shipped `dsh-tool-web` renderer,
12
12
  * so output is consistent with what `web_fetch` produces elsewhere.
13
13
  *
14
- * Pure and synchronous — unit-tested against fixture pages.
14
+ * Synchronous for its callers and unit-tested against fixture pages: jsdom
15
+ * itself is loaded lazily on the first call — and, inside a dsh profile, only
16
+ * after `installBuiltinSlashResolveCompat`, so a host resolver that
17
+ * mishandles tr46's `require("punycode/")` cannot take the plugin down.
15
18
  *
16
19
  * @module dsh-web-fetch-playwright/markdown
17
20
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-web-fetch-playwright",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "description": "Playwright/CDP web-fetch provider for DeepSeek Harness: renders pages in a real browser, denoises them (Readability + DOMPurify), and returns markdown.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -45,7 +45,6 @@
45
45
  "platform": "web",
46
46
  "inject": [
47
47
  "@deepseek-ai/dsh-client-locale",
48
- "@deepseek-ai/dsh-client-runtime",
49
48
  "@deepseek-ai/dsh-client-ui-settings"
50
49
  ]
51
50
  }
@@ -88,7 +87,7 @@
88
87
  "retention": "none (profile mode: site data lands in the remote browser's own persistent user-data-dir, which this plugin never cleans)"
89
88
  },
90
89
  "dependencies": {
91
- "@deepseek-ai/schemastery": ">=3.18.2 <4",
90
+ "@deepseek-ai/schemastery": ">=3.18.4 <4",
92
91
  "@joplin/turndown-plugin-gfm": "^1.0.56",
93
92
  "@mozilla/readability": "^0.6.0",
94
93
  "dompurify": "^3.2.4",
@@ -98,8 +97,7 @@
98
97
  },
99
98
  "peerDependencies": {
100
99
  "@deepseek-ai/cordis": ">=4.0.1-rc.1 <5",
101
- "@deepseek-ai/dsh-settings": ">=0.1.2-alpha.0 <0.3.0",
102
- "@deepseek-ai/dsh-web": ">=0.1.2-alpha.0 <0.3.0"
100
+ "@deepseek-ai/dsh-web": ">=0.1.0-rc.6 <0.2.0 || >=0.1.1-rc.1 <1"
103
101
  },
104
102
  "peerDependenciesMeta": {
105
103
  "@deepseek-ai/cordis": {
@@ -107,16 +105,15 @@
107
105
  }
108
106
  },
109
107
  "devDependencies": {
110
- "@deepseek-ai/cordis": "4.0.1",
111
- "@deepseek-ai/dsh-brand": "0.1.2-alpha.5",
112
- "@deepseek-ai/dsh-client-locale": "0.1.2-alpha.5",
113
- "@deepseek-ai/dsh-client-runtime": "0.1.1-rc.2",
114
- "@deepseek-ai/dsh-client-store": "0.1.2-alpha.5",
115
- "@deepseek-ai/dsh-client-ui-settings": "0.1.2-alpha.5",
116
- "@deepseek-ai/dsh-client-ui-settings-plugins": "0.1.2-alpha.5",
117
- "@deepseek-ai/dsh-client-ui-slots": "0.1.2-alpha.5",
118
- "@deepseek-ai/dsh-settings": "0.1.2-alpha.5",
119
- "@deepseek-ai/dsh-web": "0.1.2-alpha.5",
108
+ "@deepseek-ai/cordis": "4.0.4",
109
+ "@deepseek-ai/dsh-api-remotes": "0.1.7-rc.2",
110
+ "@deepseek-ai/dsh-client-locale": "0.1.7-rc.2",
111
+ "@deepseek-ai/dsh-client-store": "0.1.7-rc.2",
112
+ "@deepseek-ai/dsh-client-ui-plugin-manager": "0.1.7-rc.2",
113
+ "@deepseek-ai/dsh-client-ui-renderer": "0.1.7-rc.2",
114
+ "@deepseek-ai/dsh-client-ui-settings": "0.1.7-rc.2",
115
+ "@deepseek-ai/dsh-client-ui-slots": "0.1.7-rc.2",
116
+ "@deepseek-ai/dsh-web": "0.1.7-rc.2",
120
117
  "@types/jsdom": "^30.0.0",
121
118
  "@types/node": "^24.0.0",
122
119
  "@types/react": "^18.3.1",
@@ -1,80 +1,12 @@
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. */
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
- .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;
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 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.
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 { useState, type ReactNode } from 'react'
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 CardChromeCopy {
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
- /** Card chrome props. */
26
- export interface PluginCardProps {
25
+ /** Form chrome props. */
26
+ export interface CardFormProps {
27
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
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 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.
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 PluginCard(props: PluginCardProps) {
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
- <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>
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
  }
@@ -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 { PluginCard } from './PluginCard.tsx'
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<'settings.plugin.item'>
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
- * @param props - locale copy, the card snapshot, and its form actions.
25
- * @returns the card.
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
- <PluginCard
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
- </PluginCard>
163
+ </CardForm>
158
164
  )
159
165
  }
@@ -1,18 +1,24 @@
1
1
  /**
2
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.
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 { SettingsScope } from '@deepseek-ai/dsh-client-runtime/client'
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. Spelled here rather than imported: a
15
- * client package must not depend on a Host package.
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
- /** Bridges the `web-fetch-playwright` settings scope onto the card. */
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 bound settings scope for the `web-fetch-playwright` namespace.
84
+ * @param scope - the shared configuration form for the `web-fetch-playwright` entry.
77
85
  */
78
- constructor(scope: SettingsScope<PlaywrightSettings>) {
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
  }
@@ -1,10 +1,12 @@
1
1
  /**
2
2
  * The staged-form model behind the Playwright card — a faithful subset of the
3
- * shipped `ui-settings-plugins` CardForm (same staging semantics: edits stay
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 { SettingsScope, SettingsScopeSnapshot } from '@deepseek-ai/dsh-client-runtime/client'
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 settings namespace and writes
168
- * them on save. Publishes through a snapshot store because slot components
169
- * read through a selector while both the scope and the drafts change below.
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 bound settings scope for this card's namespace.
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: SettingsScope<T>,
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
- await this.scope.unset(field)
316
- return !this.stored(field)
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
- await this.scope.set(field, value)
321
- return this.userLayer()?.[field] === value
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(): SettingsScopeSnapshot<T> {
356
+ private snapshotOf(): ConfigFormSnapshot<T> {
337
357
  return this.scope.getSnapshot()
338
358
  }
339
359