dsh-web-fetch-playwright 0.2.6 → 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 CHANGED
@@ -13,7 +13,7 @@ A [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH) plug
13
13
  - **Two backends** — launch a local Playwright browser, or drive an already-running browser over its DevTools Protocol (CDP) endpoint.
14
14
  - **Browser resolution** — a configured path, a `playwright` CLI on `$PATH`, or the bundled `playwright-core`; CDP needs no local browser at all.
15
15
  - **Isolated or profile sessions (CDP)** — every fetch is scoped to exactly one tab. Local launches close their browser per fetch; the CDP backend keeps **one shared connection** to the remote browser and each fetch opens a tab inside it, closed when done. By default that tab lives in the remote browser's **real profile** (its cookies, localStorage, and persistent logins apply — like `playwright-cli open`); unchecking *Share the browser context* switches to a throwaway isolated context per fetch.
16
- - **Live configuration** — a settings card (设置 → 插件 → 插件配置) edits the backend, context mode, denoise toggle, and concurrency; changes apply to the next fetch without a restart.
16
+ - **Live configuration** — the Plugins page (侧边栏 → 插件 → *dsh-web-fetch-playwright*, dsh ≥ 0.1.7) shows the full form right on the plugin's package page (and on the row's own page via its configure control); it edits the backend, context mode, denoise toggle, and concurrency, and a committed change reaches the next fetch without a restart.
17
17
  - **Budget-aware** — per-fetch deadline (45s); concurrency is backend-priced (`maxConcurrency`, default 4 local browsers / **50 CDP tabs**; queued fetches fail fast with a retry hint after 20s instead of hanging); image/font/media subrequests aborted; body capped at 100k chars.
18
18
  - **Bounded Cloudflare-challenge wait** — when a navigation lands on a challenge interstitial ("Just a moment…" and its localized siblings, recognized via the documented `cf-mitigated: challenge` response header plus structural page markers), the fetch keeps the **same tab and context** and waits for the browser's own verification to clear it — tracking the *last* main-frame response (the real page reloads in) and watching the live DOM so SPA-style clears are caught too. Bounded and configurable (`challengeWaitMs`, default 15s; 0 restores the legacy first-response behavior), with a bounded same-tab retry (`challengeRetries`, default 1). When the budget runs out, the fetch fails with the distinct `WEB_FETCH_CHALLENGE` error code instead of returning the interstitial as content. It never clicks, never injects CAPTCHA answers, never fakes browser state, and never exports or copies cookies.
19
19
 
@@ -22,7 +22,7 @@ A [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH) plug
22
22
  | Half | Location | Responsibility |
23
23
  | --- | --- | --- |
24
24
  | Host (server) | `src/` | Registers the fetch provider (id `playwright`) into `ctx.web`; `cordis.patch.yml` pins the web seam's `fetchProvider` to it and enables the `web_fetch` tool with a 60s budget. |
25
- | Browser (client) | `src/client/` | Registers the *Playwright 网页爬取* configuration card, which hot-writes the settings section into `$DSH_HOME/settings.yaml`. |
25
+ | Browser (client) | `src/client/` | Registers the *Playwright web fetch* configuration form on the Plugins page's `plugins.bundle.config` / `plugins.row.config` seats, which stages edits and writes them through the shared settings form service. |
26
26
 
27
27
  ```
28
28
  web_fetch (tool-web)
@@ -60,7 +60,7 @@ After a bundle plugin is added to the profile layer stack, **restart `dsh web`**
60
60
 
61
61
  ## Configuration
62
62
 
63
- The settings card (设置 → 插件 → 插件配置 → *Playwright 网页爬取*) edits the `web-fetch-playwright` settings section live:
63
+ The Plugins page (侧边栏 → 插件) opens the form one click from the list: the *dsh-web-fetch-playwright* card lands on the package page with the full form between its description and its rows, and the row's own configure control opens the same form under the plugin's title. It edits the `web-fetch-playwright` settings section — derived from the plugin entry's `Config` schema — live:
64
64
 
65
65
  ![Playwright 网页爬取 plugin configuration card](./playwright-plugin-config.png)
66
66
 
@@ -109,7 +109,7 @@ Some strict sites serve a Cloudflare interstitial before the real page. A real b
109
109
 
110
110
  With the wait on (default):
111
111
 
112
- 1. **Detection** — a response carrying `cf-mitigated: challenge` (the documented signal for every challenge page type), or a 403/503 HTML document from a `server: cloudflare` edge, or the localized interstitial itself (title family like "Just a moment…", `请稍候…`, "Минутку…", plus structural markers: `/cdn-cgi/challenge-platform/` scripts, `#challenge-*` elements, `cf-chl-widget-` frames, `window._cf_chl_opt`). The content-level markers are the *fallback tier* and only run on challenge-compatible responses — 403/429/503 or a Cloudflare edge (`server: cloudflare` / `cf-ray`) — because interstitials never ship as a plain 200, so an ordinary article that merely quotes challenge text can never be mistaken for one. A hard block ("Sorry, you have been blocked") is classified separately and fails immediately.
112
+ 1. **Detection** — a response carrying `cf-mitigated: challenge` (the documented signal for every challenge page type), or a 403/503 HTML document from a `server: cloudflare` edge, or the localized interstitial itself (title family like "Just a moment…", `请稍候…`, "Минутку…", plus structural markers: `/cdn-cgi/challenge-platform/` scripts, `#challenge-*` elements, `cf-chl-widget-` frames, `window._cf_chl_opt`). The content-level markers are the *fallback tier* and only run on challenge-compatible responses — 403/429/503 or a Cloudflare edge (`server: cloudflare` / `cf-ray`) — because interstitials never ship as a plain 200, so an ordinary article that merely quotes challenge text can never be mistaken for one. Cloudflare Bot Management's passive JavaScript-Detections telemetry (`/cdn-cgi/challenge-platform/scripts/jsd/`, injected into every *normal* page of a protected zone — e.g. openrouter.ai) is neutralized before the prefix scan, so protected 200 pages with real content never misclassify. A hard block ("Sorry, you have been blocked") is classified separately and fails immediately.
113
113
  2. **Bounded wait, same tab and context** — the fetch polls the live DOM (500ms interval) for the challenge to disappear while the browser runs its own verification; the *last* main-frame navigation response is tracked so the reloaded real document's status and headers are the ones reported. SPA-style clears (content swapped without any navigation) are caught by the same DOM probe.
114
114
  3. **Bounded retry** — when a window runs out, the same tab re-navigates once (default; `challengeRetries`) with whatever clearance cookies the context already holds.
115
115
  4. **Clear failure** — `WEB_FETCH_CHALLENGE` (a provider-specific code the web seam's open-string `code` allows) naming the site, the budget spent, and the last challenge status.
@@ -129,7 +129,7 @@ Repository layout:
129
129
 
130
130
  ```
131
131
  src/
132
- ├── index.ts # host entry: registers provider + settings section
132
+ ├── index.ts # host entry: registers the fetch provider (the settings section derives from the plugin's Config schema)
133
133
  ├── config.ts # schemastery schema, CDP endpoint normalizer
134
134
  ├── provider.ts # WebFetchProvider: navigation, deadline, semaphore, caps
135
135
  ├── markdown.ts # denoise pipeline (Readability + DOMPurify + Turndown/GFM)
package/README.zh-CN.md CHANGED
@@ -13,7 +13,7 @@
13
13
  - **两种后端** —— 本地启动 Playwright 浏览器,或通过 DevTools 协议(CDP)驱动一个已在运行的浏览器。
14
14
  - **浏览器解析** —— 配置路径 → `$PATH` 上的 `playwright` CLI → 插件自带的 `playwright-core`;CDP 模式完全不需要本地浏览器。
15
15
  - **共享或隔离会话(CDP)** —— 每次抓取严格限定为一个标签页。本地后端每次抓取启动并关闭自己的浏览器;CDP 后端对远端浏览器保持**一条共享连接**,每次抓取只在其里开一个标签页、用完即关。默认该标签页位于远端浏览器的**真实 profile**(沿用其 cookie、localStorage 与已登录会话,效果类似 `playwright-cli open`);取消勾选「共享浏览器上下文」则切换为每次抓取全新隔离 context。
16
- - **热配置** —— 「设置 → 插件 → 插件配置」卡片可随时切换后端、上下文模式、降噪开关与并发数,改动对下一次抓取即时生效,无需重启。
16
+ - **热配置** —— 插件页(侧边栏 → 插件 → *dsh-web-fetch-playwright*,dsh ≥ 0.1.7)在插件自己的包页面直接展示完整表单(也可通过该行的「配置」入口进入同一表单);可随时切换后端、上下文模式、降噪开关与并发数,提交的改动对下一次抓取即时生效,无需重启。
17
17
  - **预算控制** —— 单次抓取 45s 超时;并发按后端定价(`maxConcurrency`,默认本地 4 个浏览器 / **CDP 50 个标签页**;排队的抓取等不到空位会在 20s 内尽快报错并提示重试,而不是一直挂到被工具层中止);拦截图片/字体/媒体子请求;返回体 10 万字符封顶。
18
18
  - **Cloudflare 挑战有界等待** —— 导航落到验证中间页("Just a moment…" 及其多语言同族,通过官方 `cf-mitigated: challenge` 响应头 + 结构性页面标记识别)时,抓取保持**同一标签页与上下文**,等待浏览器自行通过验证:跟踪*最后一次*主 frame 响应(真实页面随后重载进来),并轮询活 DOM 以捕获 SPA 式清除。有界且可配置(`challengeWaitMs`,默认 15s;`0` 恢复旧版首响应行为),附带同标签页有界重试(`challengeRetries`,默认 1)。预算耗尽时以独立的 `WEB_FETCH_CHALLENGE` 错误码明确失败,而不是把中间页当正文返回。全程不点击、不注入验证码答案、不伪造浏览器状态、不导出或复制 cookie。
19
19
 
@@ -22,7 +22,7 @@
22
22
  | 半端 | 位置 | 职责 |
23
23
  | --- | --- | --- |
24
24
  | 宿主(服务端) | `src/` | 向 `ctx.web` 注册 fetch provider(id `playwright`);`cordis.patch.yml` 把 web seam 的 `fetchProvider` 固定为本插件,并启用 `web_fetch` 工具(60s 预算)。 |
25
- | 浏览器(客户端) | `src/client/` | 注册 *Playwright 网页爬取* 配置卡片,通过 settings 服务把改动热写入 `$DSH_HOME/settings.yaml`。 |
25
+ | 浏览器(客户端) | `src/client/` | 在插件页的 `plugins.bundle.config` / `plugins.row.config` 席位注册 *Playwright 网页爬取* 配置表单,通过共享的设置表单服务提交改动。 |
26
26
 
27
27
  ```
28
28
  web_fetch (tool-web)
@@ -60,7 +60,7 @@ bundle 插件加入 profile 层栈后需**重启 `dsh web`** 生效;卸载用
60
60
 
61
61
  ## 配置项
62
62
 
63
- 设置卡片(设置 → 插件 → 插件配置 → *Playwright 网页爬取*)实时编辑 `web-fetch-playwright` 设置段:
63
+ 插件页(侧边栏 → 插件)从列表一跳即达:*dsh-web-fetch-playwright* 卡片落在包页面,完整表单位于其描述与行列表之间;该行的「配置」入口在插件自己的标题下打开同一表单。表单实时编辑 `web-fetch-playwright` 设置段(由插件条目的 `Config` schema 派生):
64
64
 
65
65
  ![Playwright 网页爬取 plugin configuration card](./playwright-plugin-config.png)
66
66
 
@@ -109,7 +109,7 @@ google-chrome --remote-debugging-port=9222 --user-data-dir="$HOME/.config/chrome
109
109
 
110
110
  开启等待(默认)后的流程:
111
111
 
112
- 1. **识别** —— 响应带 `cf-mitigated: challenge`(Cloudflare 官方文档注明所有挑战页类型都带此头),或 403/503 且 `server: cloudflare` 的 HTML 文档,或本地化的中间页本身("Just a moment…" / "请稍候…" / "Минутку…" 等 title 家族,以及结构性标记:`/cdn-cgi/challenge-platform/` 脚本、`#challenge-*` 元素、`cf-chl-widget-` 框架、`window._cf_chl_opt`)。内容级标记只是**兜底层**,且仅对"挑战兼容"的响应(403/429/503 或来自 Cloudflare 边缘——`server: cloudflare` / `cf-ray`)运行——因为中间页从不会以普通 200 返回,所以正文里引用了挑战文案的普通文章绝不可能被误判。硬封锁页("Sorry, you have been blocked")单独分类并立即失败——等待无法解除。
112
+ 1. **识别** —— 响应带 `cf-mitigated: challenge`(Cloudflare 官方文档注明所有挑战页类型都带此头),或 403/503 且 `server: cloudflare` 的 HTML 文档,或本地化的中间页本身("Just a moment…" / "请稍候…" / "Минутку…" 等 title 家族,以及结构性标记:`/cdn-cgi/challenge-platform/` 脚本、`#challenge-*` 元素、`cf-chl-widget-` 框架、`window._cf_chl_opt`)。内容级标记只是**兜底层**,且仅对"挑战兼容"的响应(403/429/503 或来自 Cloudflare 边缘——`server: cloudflare` / `cf-ray`)运行——因为中间页从不会以普通 200 返回,所以正文里引用了挑战文案的普通文章绝不可能被误判。Cloudflare Bot Management 的被动 JavaScript-Detections 遥测(`/cdn-cgi/challenge-platform/scripts/jsd/`,会注入受保护站点的每一个**正常**页面——如 openrouter.ai)在前缀扫描前被显式中和,因此带真实内容的 200 正常页绝不会被误判。硬封锁页("Sorry, you have been blocked")单独分类并立即失败——等待无法解除。
113
113
  2. **同标签页、同上下文的有界等待** —— 每 500ms 轮询活 DOM,等浏览器跑完自己的验证;同时跟踪**最后一次主 frame 导航响应**,所以重载进来的真实文档的状态码和响应头才是最终上报的。SPA 式清除(无导航、纯内容替换)由同一个 DOM 探测捕获。
114
114
  3. **有界重试** —— 窗口耗尽后,同一标签页默认再导航一次(`challengeRetries`),上下文里已有的通关 cookie 继续生效。
115
115
  4. **明确失败** —— 返回独立的 `WEB_FETCH_CHALLENGE` 错误码(web seam 的 `code` 是开放字符串,允许 provider 专属码),消息中写明站点、等待预算与最后一次挑战响应的状态。
@@ -129,7 +129,7 @@ pnpm build # tsc 声明 + tsdown(宿主 ESM + 客户端 module-registrat
129
129
 
130
130
  ```
131
131
  src/
132
- ├── index.ts # 宿主入口:注册 provider 与设置段
132
+ ├── index.ts # 宿主入口:注册 fetch provider(设置段由插件的 Config schema 派生)
133
133
  ├── config.ts # schemastery schema、CDP 端点归一化
134
134
  ├── provider.ts # WebFetchProvider:导航、超时、信号量、截断
135
135
  ├── markdown.ts # 降噪管线(Readability + DOMPurify + Turndown/GFM)
package/lib/client.js CHANGED
@@ -4,7 +4,6 @@ window.__ModuleLoader__.load({
4
4
  var module = { exports: {} };
5
5
  var exports = module.exports;
6
6
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
- let react = require("react");
8
7
  let react_jsx_runtime = require("react/jsx-runtime");
9
8
  //#region \0@oxc-project+runtime@0.146.0/helpers/esm/typeof.js
10
9
  function _typeof(o) {
@@ -126,13 +125,14 @@ window.__ModuleLoader__.load({
126
125
  };
127
126
  }
128
127
  /**
129
- * Stages the Playwright card's edits over one settings namespace and writes
130
- * them on save. Publishes through a snapshot store because slot components
131
- * read through a selector while both the scope and the drafts change below.
128
+ * Stages the Playwright card's edits over one plugin-entry configuration
129
+ * form and writes them on save. Publishes through a snapshot store because
130
+ * slot components read through a selector while both the form and the drafts
131
+ * change below.
132
132
  */
133
- var CardForm = class {
133
+ var CardForm$1 = class {
134
134
  /**
135
- * @param scope - the bound settings scope for this card's namespace.
135
+ * @param scope - the shared configuration form for this plugin's entry.
136
136
  * @param specs - the section fields this card edits.
137
137
  */
138
138
  constructor(scope, specs) {
@@ -140,13 +140,19 @@ window.__ModuleLoader__.load({
140
140
  _defineProperty(this, "specs", void 0);
141
141
  _defineProperty(this, "staged", /* @__PURE__ */ new Map());
142
142
  _defineProperty(this, "listeners", /* @__PURE__ */ new Set());
143
+ _defineProperty(this, "unsubscribe", void 0);
143
144
  _defineProperty(this, "saving", false);
144
145
  _defineProperty(this, "failed", false);
145
146
  this.specs = new Map(specs.map((spec) => [spec.field, spec]));
146
- scope.subscribe(() => {
147
+ this.unsubscribe = scope.subscribe(() => {
147
148
  this.publish();
148
149
  });
149
150
  }
151
+ /** Release the form subscription and every bound stores. */
152
+ dispose() {
153
+ this.unsubscribe();
154
+ this.listeners.clear();
155
+ }
150
156
  /**
151
157
  * Publish a projection of this form, rebuilt whenever the scope or a draft
152
158
  * changes.
@@ -242,7 +248,9 @@ window.__ModuleLoader__.load({
242
248
  /**
243
249
  * Write every staged edit, then re-seed from what the Host accepted. A save
244
250
  * that did not land keeps its drafts, so the user corrects them instead of
245
- * retyping.
251
+ * retyping. The shared form reports `false` (and reloads Host state) for a
252
+ * refused revision or validation, and a transport drop rejects — both fold
253
+ * into the same failed-save path.
246
254
  */
247
255
  async save() {
248
256
  const plan = this.plan();
@@ -292,12 +300,18 @@ window.__ModuleLoader__.load({
292
300
  return plan;
293
301
  }
294
302
  async clear(field) {
295
- await this.scope.unset(field);
296
- return !this.stored(field);
303
+ try {
304
+ return await this.scope.unset(field);
305
+ } catch (_sectionWriteFailure) {
306
+ return false;
307
+ }
297
308
  }
298
309
  async store(field, value) {
299
- await this.scope.set(field, value);
300
- return this.userLayer()?.[field] === value;
310
+ try {
311
+ return await this.scope.set(field, value);
312
+ } catch (_sectionWriteFailure) {
313
+ return false;
314
+ }
301
315
  }
302
316
  stage(field, edit) {
303
317
  this.staged.set(field, edit);
@@ -332,19 +346,23 @@ window.__ModuleLoader__.load({
332
346
  //#endregion
333
347
  //#region src/client/controller.ts
334
348
  /**
335
- * Settings namespace this card edits. Spelled here rather than imported: a
336
- * client package must not depend on a Host package.
349
+ * Settings namespace this card edits: the composition entry id, which is
350
+ * what the host's settings service keys the section derived from the
351
+ * plugin's Config schema by. Spelled here rather than imported: a client
352
+ * package must not depend on a Host package.
337
353
  */
338
354
  const WEB_FETCH_PLAYWRIGHT_NS = "web-fetch-playwright";
339
- /** Bridges the `web-fetch-playwright` settings scope onto the card. */
355
+ /**
356
+ * Bridges the `web-fetch-playwright` configuration form onto the card.
357
+ */
340
358
  var PlaywrightCardController = class {
341
359
  /**
342
- * @param scope - the bound settings scope for the `web-fetch-playwright` namespace.
360
+ * @param scope - the shared configuration form for the `web-fetch-playwright` entry.
343
361
  */
344
362
  constructor(scope) {
345
363
  _defineProperty(this, "form", void 0);
346
364
  _defineProperty(this, "store", void 0);
347
- this.form = new CardForm(scope, [
365
+ this.form = new CardForm$1(scope, [
348
366
  radioField("backend", ["local", "cdp"]),
349
367
  textField("playwrightPath"),
350
368
  textField("cdpEndpoint"),
@@ -377,10 +395,14 @@ window.__ModuleLoader__.load({
377
395
  ...this.form.actions()
378
396
  };
379
397
  }
398
+ /** Release the form subscription and every bound stores. */
399
+ dispose() {
400
+ this.form.dispose();
401
+ }
380
402
  };
381
403
  //#endregion
382
404
  //#region \0dsh-web-fetch-playwright-css:/opt/dsh/plugins/dsh-web-fetch-playwright/src/client/PluginCard.module.css.mjs
383
- const css$1 = ".UM8-Rq_card{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:12px;list-style:none;transition:border-color .16s,background .16s}.UM8-Rq_card:hover{border-color:var(--dsw-alias-label-dimmed)}.UM8-Rq_cardOpen{background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-label-dimmed)}.UM8-Rq_header{appearance:none;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:0 0;border:0;border-radius:12px;align-items:center;gap:12px;padding:14px 16px;display:flex}.UM8-Rq_header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px}.UM8-Rq_headText{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}.UM8-Rq_name{color:var(--dsw-alias-label-primary);font-size:15px;font-weight:600;line-height:1.4}.UM8-Rq_description{color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:1.5}.UM8-Rq_chevron{color:var(--dsw-alias-label-tertiary);flex:none;transition:transform .16s}.UM8-Rq_chevronOpen{transform:rotate(180deg)}.UM8-Rq_body{border-top:1px solid var(--dsw-alias-border-l2);margin:0 16px;padding-bottom:8px}.UM8-Rq_readOnly{color:var(--dsw-alias-label-tertiary);margin:12px 0 0;font-size:12px;line-height:1.5}.UM8-Rq_pending{white-space:nowrap;background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-secondary);border-radius:999px;flex:none;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px}.UM8-Rq_footer{border-top:1px solid var(--dsw-alias-border-l2);justify-content:flex-end;align-items:center;gap:8px;padding:12px 0 4px;display:flex}.UM8-Rq_failed{min-width:0;color:var(--dsw-alias-label-error);flex:1;margin:0;font-size:12px;line-height:1.5}.UM8-Rq_discard,.UM8-Rq_save{appearance:none;font:inherit;cursor:pointer;border:1px solid #0000;border-radius:8px;padding:5px 14px;font-size:13px;line-height:1.5}.UM8-Rq_discard{border-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);background:0 0}.UM8-Rq_discard:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed)}.UM8-Rq_save{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}.UM8-Rq_discard:disabled,.UM8-Rq_save:disabled{opacity:.4;cursor:default}.UM8-Rq_discard:focus-visible,.UM8-Rq_save:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}";
405
+ const css$1 = ".UM8-Rq_form{flex-direction:column;display:flex}.UM8-Rq_readOnly{color:var(--dsw-alias-label-tertiary);margin:12px 0 0;font-size:12px;line-height:1.5}.UM8-Rq_footer{border-top:1px solid var(--dsw-alias-border-l2);justify-content:flex-end;align-items:center;gap:8px;padding:12px 0 4px;display:flex}.UM8-Rq_failed{min-width:0;color:var(--dsw-alias-label-error);flex:1;margin:0;font-size:12px;line-height:1.5}.UM8-Rq_discard,.UM8-Rq_save{appearance:none;font:inherit;cursor:pointer;border:1px solid #0000;border-radius:8px;padding:5px 14px;font-size:13px;line-height:1.5}.UM8-Rq_discard{border-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);background:0 0}.UM8-Rq_discard:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed)}.UM8-Rq_save{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}.UM8-Rq_discard:disabled,.UM8-Rq_save:disabled{opacity:.4;cursor:default}.UM8-Rq_discard:focus-visible,.UM8-Rq_save:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}";
384
406
  const tagId$1 = "dsh-web-fetch-playwright/PluginCard.module.css";
385
407
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
386
408
  const tag = document.createElement("style");
@@ -390,123 +412,57 @@ window.__ModuleLoader__.load({
390
412
  document.head.appendChild(tag);
391
413
  }
392
414
  var PluginCard_module_css_default = {
393
- "pending": "UM8-Rq_pending",
394
- "chevron": "UM8-Rq_chevron",
395
- "header": "UM8-Rq_header",
396
- "headText": "UM8-Rq_headText",
397
- "card": "UM8-Rq_card",
398
- "body": "UM8-Rq_body",
399
- "readOnly": "UM8-Rq_readOnly",
400
- "description": "UM8-Rq_description",
401
- "chevronOpen": "UM8-Rq_chevronOpen",
402
- "discard": "UM8-Rq_discard",
403
415
  "footer": "UM8-Rq_footer",
416
+ "form": "UM8-Rq_form",
417
+ "discard": "UM8-Rq_discard",
418
+ "save": "UM8-Rq_save",
404
419
  "failed": "UM8-Rq_failed",
405
- "name": "UM8-Rq_name",
406
- "cardOpen": "UM8-Rq_cardOpen",
407
- "save": "UM8-Rq_save"
420
+ "readOnly": "UM8-Rq_readOnly"
408
421
  };
409
422
  //#endregion
410
423
  //#region src/client/PluginCard.tsx
411
424
  /**
412
- * The card chrome — a faithful local copy of the shipped `ui-settings-plugins`
413
- * PluginCard (disclosure header, unsaved marker, save/discard footer), with
414
- * the chevron inlined so the bundle stays self-contained.
415
- *
416
- * @module dsh-web-fetch-playwright/client/PluginCard
425
+ * Render the Playwright form's chrome.
426
+ * @param props - the form's copy, form state, and controls.
427
+ * @returns the form body with its footer.
417
428
  */
418
- function cx(...parts) {
419
- return parts.filter((part) => typeof part === "string").join(" ");
420
- }
421
- function ChevronDown({ className }) {
422
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
423
- className,
424
- width: "14",
425
- height: "14",
426
- viewBox: "0 0 16 16",
427
- fill: "none",
428
- "aria-hidden": "true",
429
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
430
- d: "M4 6l4 4 4-4",
431
- stroke: "currentColor",
432
- strokeWidth: "1.5",
433
- strokeLinecap: "round",
434
- strokeLinejoin: "round"
435
- })
436
- });
437
- }
438
- /**
439
- * Render the Playwright card's chrome.
440
- * @param props - the card's copy, name, form state, and controls.
441
- * @returns the card, or nothing when the namespace is unavailable.
442
- */
443
- function PluginCard(props) {
444
- const [open, setOpen] = (0, react.useState)(false);
429
+ function CardForm(props) {
445
430
  const { state, copy } = props;
446
- if (!state.available) return null;
447
431
  const blocked = !state.dirty || state.invalid || state.saving;
448
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
449
- className: cx(PluginCard_module_css_default.card, open && PluginCard_module_css_default.cardOpen),
450
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
451
- type: "button",
452
- className: PluginCard_module_css_default.header,
453
- "aria-expanded": open,
454
- "aria-label": `${open ? copy.collapse : copy.expand}: ${props.title}`,
455
- onClick: () => {
456
- setOpen(!open);
457
- },
458
- children: [
459
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
460
- className: PluginCard_module_css_default.headText,
461
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
462
- className: PluginCard_module_css_default.name,
463
- children: props.title
464
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
465
- className: PluginCard_module_css_default.description,
466
- children: props.description
467
- })]
468
- }),
469
- state.dirty ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
470
- className: PluginCard_module_css_default.pending,
471
- children: copy.unsaved
472
- }) : null,
473
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChevronDown, { className: cx(PluginCard_module_css_default.chevron, open && PluginCard_module_css_default.chevronOpen) })
474
- ]
475
- }), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
476
- className: PluginCard_module_css_default.body,
477
- children: [
478
- !state.writable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
479
- className: PluginCard_module_css_default.readOnly,
480
- role: "status",
481
- children: copy.readOnly
482
- }) : null,
483
- props.children,
484
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
485
- className: PluginCard_module_css_default.footer,
486
- children: [
487
- state.failed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
488
- className: PluginCard_module_css_default.failed,
489
- role: "status",
490
- children: copy.saveFailed
491
- }) : null,
492
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
493
- type: "button",
494
- className: PluginCard_module_css_default.discard,
495
- disabled: !state.dirty || state.saving,
496
- onClick: props.onDiscard,
497
- children: copy.discard
498
- }),
499
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
500
- type: "button",
501
- className: PluginCard_module_css_default.save,
502
- disabled: blocked,
503
- onClick: props.onSave,
504
- children: state.saving ? copy.saving : copy.save
505
- })
506
- ]
507
- })
508
- ]
509
- }) : null]
432
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
433
+ className: PluginCard_module_css_default.form,
434
+ children: [
435
+ !state.writable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
436
+ className: PluginCard_module_css_default.readOnly,
437
+ role: "status",
438
+ children: copy.readOnly
439
+ }) : null,
440
+ props.children,
441
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
442
+ className: PluginCard_module_css_default.footer,
443
+ children: [
444
+ state.failed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
445
+ className: PluginCard_module_css_default.failed,
446
+ role: "status",
447
+ children: copy.saveFailed
448
+ }) : null,
449
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
450
+ type: "button",
451
+ className: PluginCard_module_css_default.discard,
452
+ disabled: !state.dirty || state.saving,
453
+ onClick: props.onDiscard,
454
+ children: copy.discard
455
+ }),
456
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
457
+ type: "button",
458
+ className: PluginCard_module_css_default.save,
459
+ disabled: blocked,
460
+ onClick: props.onSave,
461
+ children: state.saving ? copy.saving : copy.save
462
+ })
463
+ ]
464
+ })
465
+ ]
510
466
  });
511
467
  }
512
468
  //#endregion
@@ -521,26 +477,26 @@ window.__ModuleLoader__.load({
521
477
  document.head.appendChild(tag);
522
478
  }
523
479
  var fields_module_css_default = {
524
- "fieldEmbedded": "CFSaVG_fieldEmbedded",
480
+ "radioContent": "CFSaVG_radioContent",
481
+ "field": "CFSaVG_field",
482
+ "checkboxRow": "CFSaVG_checkboxRow",
483
+ "radioHint": "CFSaVG_radioHint",
525
484
  "reset": "CFSaVG_reset",
526
- "label": "CFSaVG_label",
527
- "hintIndented": "CFSaVG_hintIndented",
528
- "radioOption": "CFSaVG_radioOption",
529
485
  "badges": "CFSaVG_badges",
530
- "invalid": "CFSaVG_invalid",
531
486
  "radioGroup": "CFSaVG_radioGroup",
487
+ "fieldEmbedded": "CFSaVG_fieldEmbedded",
488
+ "radioOption": "CFSaVG_radioOption",
532
489
  "radioLabel": "CFSaVG_radioLabel",
533
- "hint": "CFSaVG_hint",
534
- "checkboxRow": "CFSaVG_checkboxRow",
535
490
  "inputInvalid": "CFSaVG_inputInvalid",
536
- "radioPick": "CFSaVG_radioPick",
537
491
  "radioText": "CFSaVG_radioText",
538
- "radioHint": "CFSaVG_radioHint",
492
+ "label": "CFSaVG_label",
493
+ "invalid": "CFSaVG_invalid",
494
+ "hintIndented": "CFSaVG_hintIndented",
539
495
  "badge": "CFSaVG_badge",
540
496
  "input": "CFSaVG_input",
541
- "radioContent": "CFSaVG_radioContent",
542
497
  "head": "CFSaVG_head",
543
- "field": "CFSaVG_field"
498
+ "radioPick": "CFSaVG_radioPick",
499
+ "hint": "CFSaVG_hint"
544
500
  };
545
501
  //#endregion
546
502
  //#region src/client/fields.tsx
@@ -694,28 +650,26 @@ window.__ModuleLoader__.load({
694
650
  //#endregion
695
651
  //#region src/client/card.tsx
696
652
  /**
697
- * Render the Playwright card.
698
- * @param props - locale copy, the card snapshot, and its form actions.
699
- * @returns the card.
653
+ * Render the Playwright card: its one-liner for the list, or the staged form
654
+ * for the page.
655
+ * @param props - the view asked for, locale copy, the card snapshot, and its form actions.
656
+ * @returns the one-liner, the form, or nothing while the namespace is unavailable.
700
657
  */
701
658
  function PlaywrightCard(props) {
702
659
  const { t } = props;
660
+ if (props.view === "summary") return t("description");
703
661
  const state = props.usePlaywrightCard((snapshot) => snapshot);
662
+ if (!state.available) return null;
704
663
  const disabled = !state.writable;
705
664
  const backend = state.backend.text === "cdp" ? "cdp" : "local";
706
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PluginCard, {
665
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(CardForm, {
707
666
  copy: {
708
- expand: t("expand"),
709
- collapse: t("collapse"),
710
- unsaved: t("unsaved"),
711
667
  readOnly: t("readOnly"),
712
668
  saveFailed: t("saveFailed"),
713
669
  discard: t("discard"),
714
670
  save: t("save"),
715
671
  saving: t("saving")
716
672
  },
717
- title: t("title"),
718
- description: t("description"),
719
673
  state,
720
674
  onSave: props.save,
721
675
  onDiscard: props.discard,
@@ -852,7 +806,6 @@ window.__ModuleLoader__.load({
852
806
  //#region src/client/locales.ts
853
807
  /** English copy. */
854
808
  const en = {
855
- title: "Playwright web fetch",
856
809
  description: "Fetches pages with a real browser (local Playwright or CDP) and returns denoised markdown.",
857
810
  backendLabel: "Playwright backend",
858
811
  backendLocal: "Local Playwright",
@@ -877,18 +830,14 @@ window.__ModuleLoader__.load({
877
830
  overridden: "Overridden",
878
831
  reset: "Reset to default",
879
832
  readOnly: "This deployment stores settings read-only.",
880
- expand: "Show settings",
881
- collapse: "Hide settings",
882
833
  save: "Save",
883
834
  saving: "Saving…",
884
835
  discard: "Discard",
885
- unsaved: "Unsaved",
886
836
  saveFailed: "The deployment did not accept these values; they were left for you to correct.",
887
837
  invalidText: "This value is not accepted here."
888
838
  };
889
839
  /** Simplified Chinese copy. */
890
840
  const zh = {
891
- title: "Playwright 网页爬取",
892
841
  description: "用真实浏览器(本地 Playwright 或 CDP)抓取网页,降噪后转为 Markdown。",
893
842
  backendLabel: "Playwright 后端",
894
843
  backendLocal: "本地 Playwright",
@@ -913,12 +862,9 @@ window.__ModuleLoader__.load({
913
862
  overridden: "已覆盖",
914
863
  reset: "恢复默认",
915
864
  readOnly: "本部署的设置为只读。",
916
- expand: "展开设置",
917
- collapse: "收起设置",
918
865
  save: "保存",
919
866
  saving: "保存中…",
920
867
  discard: "放弃修改",
921
- unsaved: "未保存",
922
868
  saveFailed: "本部署没有接受这些值,已保留供你修改。",
923
869
  invalidText: "该值不被此设置项接受。"
924
870
  };
@@ -926,14 +872,26 @@ window.__ModuleLoader__.load({
926
872
  //#region src/client/index.ts
927
873
  /** Dictionary namespace owned by this plugin. */
928
874
  const NS = "web-fetch-playwright";
875
+ /**
876
+ * This bundle's package name — the Plugins page keys a bundle's own
877
+ * configuration by it. Spelled here rather than read from any manifest:
878
+ * this bundle must stay self-contained.
879
+ */
880
+ const PACKAGE_NAME = "dsh-web-fetch-playwright";
881
+ /**
882
+ * The row's configuration key `<package name>#<row id>` with the row id as
883
+ * the bundle's patch declares it.
884
+ */
885
+ const ROW_CONFIG_KEY = `${PACKAGE_NAME}#web-fetch-playwright`;
929
886
  /** Required services (cordis fiber inject). */
930
887
  const inject = [
931
888
  "slots",
932
889
  "locale",
933
- "settingsScope"
890
+ "configForms"
934
891
  ];
935
892
  /**
936
- * Mount the Playwright plugin-configuration card.
893
+ * Mount the Playwright plugin-configuration card while the Host serves the
894
+ * `web-fetch-playwright` namespace.
937
895
  * @param ctx - the browser plugin context.
938
896
  */
939
897
  function apply(ctx) {
@@ -941,13 +899,28 @@ window.__ModuleLoader__.load({
941
899
  zh,
942
900
  en
943
901
  }), "web-fetch-playwright: card dictionary");
944
- const controller = new PlaywrightCardController(ctx.settingsScope.bind({ namespace: WEB_FETCH_PLAYWRIGHT_NS }));
945
- ctx.slots.inject("settings.plugin.item", () => ctx.slots.register({
946
- name: "settings.plugin.item",
947
- key: WEB_FETCH_PLAYWRIGHT_NS,
948
- locale: NS,
949
- inject: () => controller.inject()
950
- }, PlaywrightCard));
902
+ const controller = new PlaywrightCardController(ctx.configForms.get(WEB_FETCH_PLAYWRIGHT_NS));
903
+ ctx.effect(() => () => {
904
+ controller.dispose();
905
+ }, "web-fetch-playwright: form subscription");
906
+ ctx.effect(() => ctx.configForms.whileServed([WEB_FETCH_PLAYWRIGHT_NS], () => {
907
+ const offBundle = ctx.slots.inject("plugins.bundle.config", () => ctx.slots.register({
908
+ name: "plugins.bundle.config",
909
+ key: PACKAGE_NAME,
910
+ locale: NS,
911
+ inject: () => controller.inject()
912
+ }, PlaywrightCard));
913
+ const offRow = ctx.slots.inject("plugins.row.config", () => ctx.slots.register({
914
+ name: "plugins.row.config",
915
+ key: ROW_CONFIG_KEY,
916
+ locale: NS,
917
+ inject: () => controller.inject()
918
+ }, PlaywrightCard));
919
+ return () => {
920
+ offBundle();
921
+ offRow();
922
+ };
923
+ }), "web-fetch-playwright: plugins-page card");
951
924
  }
952
925
  //#endregion
953
926
  exports.apply = apply;