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
package/lib/index.js
CHANGED
|
@@ -10,14 +10,6 @@ import { accessSync, constants, readFileSync, realpathSync, statSync } from "nod
|
|
|
10
10
|
import { delimiter, dirname, join } from "node:path";
|
|
11
11
|
import { pathToFileURL } from "node:url";
|
|
12
12
|
//#region src/config.ts
|
|
13
|
-
/**
|
|
14
|
-
* Settings/config surface for the Playwright fetch provider: the schemastery
|
|
15
|
-
* schema the loader validates the row against, the settings namespace's
|
|
16
|
-
* resolved shape, and the small pure normalizers the provider applies per
|
|
17
|
-
* fetch (CDP endpoint shaping) — kept network-free for unit tests.
|
|
18
|
-
*
|
|
19
|
-
* @module dsh-web-fetch-playwright/config
|
|
20
|
-
*/
|
|
21
13
|
/** Default CDP endpoint when the settings section leaves it blank. */
|
|
22
14
|
const DEFAULT_CDP_ENDPOINT = "127.0.0.1:9222";
|
|
23
15
|
/**
|
|
@@ -32,16 +24,59 @@ const MAX_CHALLENGE_WAIT_MS = 6e4;
|
|
|
32
24
|
/** Default same-page re-navigation attempts after a challenge wait runs out. */
|
|
33
25
|
const DEFAULT_CHALLENGE_RETRIES = 1;
|
|
34
26
|
const Config = z.object({
|
|
35
|
-
backend: z.union([z.const("local"), z.const("cdp")]).default("local"),
|
|
36
|
-
playwrightPath: z.string().default(""),
|
|
37
|
-
cdpEndpoint: z.string().default(""),
|
|
38
|
-
shareBrowserContext: z.boolean().default(true),
|
|
39
|
-
denoise: z.boolean().default(true),
|
|
40
|
-
maxConcurrency: z.number().step(1).min(1).max(200),
|
|
41
|
-
challengeWaitMs: z.number().step(100).min(0).max(MAX_CHALLENGE_WAIT_MS).default(DEFAULT_CHALLENGE_WAIT_MS),
|
|
42
|
-
challengeRetries: z.number().step(1).min(0).max(3).default(1)
|
|
27
|
+
backend: z.union([z.const("local"), z.const("cdp")]).default("local").volatile(),
|
|
28
|
+
playwrightPath: z.string().default("").volatile(),
|
|
29
|
+
cdpEndpoint: z.string().default("").volatile(),
|
|
30
|
+
shareBrowserContext: z.boolean().default(true).volatile(),
|
|
31
|
+
denoise: z.boolean().default(true).volatile(),
|
|
32
|
+
maxConcurrency: z.number().step(1).min(1).max(200).volatile(),
|
|
33
|
+
challengeWaitMs: z.number().step(100).min(0).max(MAX_CHALLENGE_WAIT_MS).default(DEFAULT_CHALLENGE_WAIT_MS).volatile(),
|
|
34
|
+
challengeRetries: z.number().step(1).min(0).max(3).default(1).volatile()
|
|
43
35
|
});
|
|
44
36
|
/**
|
|
37
|
+
* Read the live references `apply` holds into one plain input for
|
|
38
|
+
* {@link resolveConfig}; a settings commit has usually replaced the
|
|
39
|
+
* snapshots since the last call, which is the whole point.
|
|
40
|
+
*
|
|
41
|
+
* @param config - the plugin config as the loader resolved it.
|
|
42
|
+
* @returns the current snapshots, ready for resolution.
|
|
43
|
+
*/
|
|
44
|
+
function snapshotsOf(config) {
|
|
45
|
+
return {
|
|
46
|
+
backend: config.backend.get(),
|
|
47
|
+
playwrightPath: config.playwrightPath.get(),
|
|
48
|
+
cdpEndpoint: config.cdpEndpoint.get(),
|
|
49
|
+
shareBrowserContext: config.shareBrowserContext.get(),
|
|
50
|
+
denoise: config.denoise.get(),
|
|
51
|
+
maxConcurrency: config.maxConcurrency.get(),
|
|
52
|
+
challengeWaitMs: config.challengeWaitMs.get(),
|
|
53
|
+
challengeRetries: config.challengeRetries.get()
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Resolve any accepted config input into the fully-defaulted, plain form the
|
|
58
|
+
* provider consumes per fetch. Validation goes through the schema, so the
|
|
59
|
+
* volatile wrappers that produces are unwrapped immediately — the provider
|
|
60
|
+
* consumes plain values. The input face is `Partial` by design (composition
|
|
61
|
+
* entries and volatile snapshots both omit fields; defaults supply them).
|
|
62
|
+
*
|
|
63
|
+
* @param config - composition entry, settings-section value, or volatile snapshots.
|
|
64
|
+
* @returns the resolved config.
|
|
65
|
+
*/
|
|
66
|
+
function resolveConfig(config) {
|
|
67
|
+
const resolved = Config(config);
|
|
68
|
+
return {
|
|
69
|
+
backend: resolved.backend.get(),
|
|
70
|
+
playwrightPath: resolved.playwrightPath.get(),
|
|
71
|
+
cdpEndpoint: resolved.cdpEndpoint.get(),
|
|
72
|
+
shareBrowserContext: resolved.shareBrowserContext.get(),
|
|
73
|
+
denoise: resolved.denoise.get(),
|
|
74
|
+
maxConcurrency: resolved.maxConcurrency.get(),
|
|
75
|
+
challengeWaitMs: resolved.challengeWaitMs.get(),
|
|
76
|
+
challengeRetries: resolved.challengeRetries.get()
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
45
80
|
* The concurrency limit a fetch actually runs with: an explicit setting
|
|
46
81
|
* wins; otherwise the backend default (local launches browsers, CDP only
|
|
47
82
|
* opens tabs, so their budgets differ by an order of magnitude).
|
|
@@ -1424,26 +1459,31 @@ function guardPopups(page) {
|
|
|
1424
1459
|
//#region src/index.ts
|
|
1425
1460
|
/** Cordis plugin name used by loader diagnostics. */
|
|
1426
1461
|
const name = "dsh-web-fetch-playwright";
|
|
1427
|
-
/**
|
|
1462
|
+
/**
|
|
1463
|
+
* The capability seam this plugin registers into. The settings section
|
|
1464
|
+
* needs no inject: the host's settings service derives it from the entry's
|
|
1465
|
+
* `Config` schema (its volatile fields) by entry id.
|
|
1466
|
+
*/
|
|
1428
1467
|
const inject = ["web"];
|
|
1429
|
-
/**
|
|
1468
|
+
/**
|
|
1469
|
+
* Settings namespace carrying this provider's configuration page: the
|
|
1470
|
+
* composition entry id, which is what the settings service keys the
|
|
1471
|
+
* derived section by.
|
|
1472
|
+
*/
|
|
1430
1473
|
const WEB_FETCH_PLAYWRIGHT_SETTINGS_NAMESPACE = "web-fetch-playwright";
|
|
1431
|
-
/**
|
|
1474
|
+
/**
|
|
1475
|
+
* Register the Playwright fetch provider with `ctx.web`.
|
|
1476
|
+
*
|
|
1477
|
+
* @param ctx - plugin context supplying the web seam.
|
|
1478
|
+
* @param config - the loader-resolved plugin config; its volatile fields are
|
|
1479
|
+
* live references a settings commit updates in place.
|
|
1480
|
+
*/
|
|
1432
1481
|
function apply(ctx, config) {
|
|
1433
|
-
|
|
1434
|
-
ctx.inject(["settings"], (settingsCtx) => {
|
|
1435
|
-
settingsCtx.settings.installSection(ctx, WEB_FETCH_PLAYWRIGHT_SETTINGS_NAMESPACE, Config, config, {
|
|
1436
|
-
setSource: (source) => {
|
|
1437
|
-
current = source;
|
|
1438
|
-
},
|
|
1439
|
-
onChange: () => {}
|
|
1440
|
-
});
|
|
1441
|
-
});
|
|
1442
|
-
const provider = new PlaywrightFetchProvider(() => current());
|
|
1482
|
+
const provider = new PlaywrightFetchProvider(() => resolveConfig(snapshotsOf(config)));
|
|
1443
1483
|
ctx.effect(() => () => {
|
|
1444
1484
|
provider.dispose();
|
|
1445
1485
|
}, "dsh-web-fetch-playwright: shared CDP connection");
|
|
1446
1486
|
ctx.web.registerFetchProvider(provider);
|
|
1447
1487
|
}
|
|
1448
1488
|
//#endregion
|
|
1449
|
-
export { CHALLENGE_DOM_PROBE, CHALLENGE_FINISH_RESERVE_MS, CHALLENGE_POLL_INTERVAL_MS, CHALLENGE_TITLE_RE, CdpConnectionPool, Config, DEFAULT_CDP_ENDPOINT, DEFAULT_CHALLENGE_RETRIES, DEFAULT_CHALLENGE_WAIT_MS, PLAYWRIGHT_FETCH_PROVIDER_ID, PlaywrightFetchProvider, WEB_FETCH_CHALLENGE_CODE, WEB_FETCH_PLAYWRIGHT_SETTINGS_NAMESPACE, apply, classifyChallengeHtml, classifyChallengeResponse, effectiveChallengeRetries, effectiveChallengeWaitMs, effectiveContextMode, htmlToMarkdown, inject, isChallengeCompatibleResponse, name, normalizeCdpEndpoint };
|
|
1489
|
+
export { CHALLENGE_DOM_PROBE, CHALLENGE_FINISH_RESERVE_MS, CHALLENGE_POLL_INTERVAL_MS, CHALLENGE_TITLE_RE, CdpConnectionPool, Config, DEFAULT_CDP_ENDPOINT, DEFAULT_CHALLENGE_RETRIES, DEFAULT_CHALLENGE_WAIT_MS, PLAYWRIGHT_FETCH_PROVIDER_ID, PlaywrightFetchProvider, WEB_FETCH_CHALLENGE_CODE, WEB_FETCH_PLAYWRIGHT_SETTINGS_NAMESPACE, apply, classifyChallengeHtml, classifyChallengeResponse, effectiveChallengeRetries, effectiveChallengeWaitMs, effectiveContextMode, htmlToMarkdown, inject, isChallengeCompatibleResponse, name, normalizeCdpEndpoint, resolveConfig, snapshotsOf };
|
|
@@ -1,31 +1,27 @@
|
|
|
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
|
-
import {
|
|
11
|
+
import type { ReactNode } from 'react';
|
|
9
12
|
import type { CardShell } from './form.ts';
|
|
10
13
|
/** Copy keys the chrome itself renders (the card's dictionary supplies them). */
|
|
11
|
-
export interface
|
|
12
|
-
expand: string;
|
|
13
|
-
collapse: string;
|
|
14
|
-
unsaved: string;
|
|
14
|
+
export interface CardFormCopy {
|
|
15
15
|
readOnly: string;
|
|
16
16
|
saveFailed: string;
|
|
17
17
|
discard: string;
|
|
18
18
|
save: string;
|
|
19
19
|
saving: string;
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
22
|
-
export interface
|
|
21
|
+
/** Form chrome props. */
|
|
22
|
+
export interface CardFormProps {
|
|
23
23
|
/** Chrome copy (a subset of the card's locale keys). */
|
|
24
|
-
copy:
|
|
25
|
-
/** The plugin's display name. */
|
|
26
|
-
title: string;
|
|
27
|
-
/** The line describing what this plugin's settings govern. */
|
|
28
|
-
description: string;
|
|
24
|
+
copy: CardFormCopy;
|
|
29
25
|
/** The card's form state: availability, writability, and what a save would do. */
|
|
30
26
|
state: CardShell;
|
|
31
27
|
/** Write every staged edit. */
|
|
@@ -36,8 +32,8 @@ export interface PluginCardProps {
|
|
|
36
32
|
children: ReactNode;
|
|
37
33
|
}
|
|
38
34
|
/**
|
|
39
|
-
* Render the Playwright
|
|
40
|
-
* @param props - the
|
|
41
|
-
* @returns the
|
|
35
|
+
* Render the Playwright form's chrome.
|
|
36
|
+
* @param props - the form's copy, form state, and controls.
|
|
37
|
+
* @returns the form body with its footer.
|
|
42
38
|
*/
|
|
43
|
-
export declare function
|
|
39
|
+
export declare function CardForm(props: CardFormProps): import("react").JSX.Element;
|
|
@@ -5,15 +5,22 @@
|
|
|
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
|
import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
|
|
11
17
|
import type { PlaywrightCardFace } from './controller.ts';
|
|
12
18
|
/** Props the renderer binds for the Playwright card. */
|
|
13
|
-
export type PlaywrightCardProps = PropsRuntime<'
|
|
19
|
+
export type PlaywrightCardProps = (PropsRuntime<'plugins.bundle.config'> | PropsRuntime<'plugins.row.config'>) & PropsLocale<'web-fetch-playwright'> & InjectFace<PlaywrightCardFace>;
|
|
14
20
|
/**
|
|
15
|
-
* Render the Playwright card
|
|
16
|
-
*
|
|
17
|
-
* @
|
|
21
|
+
* Render the Playwright card: its one-liner for the list, or the staged form
|
|
22
|
+
* for the page.
|
|
23
|
+
* @param props - the view asked for, locale copy, the card snapshot, and its form actions.
|
|
24
|
+
* @returns the one-liner, the form, or nothing while the namespace is unavailable.
|
|
18
25
|
*/
|
|
19
|
-
export declare function PlaywrightCard(props: PlaywrightCardProps): import("react").JSX.Element;
|
|
26
|
+
export declare function PlaywrightCard(props: PlaywrightCardProps): string | import("react").JSX.Element | null;
|
|
@@ -1,15 +1,21 @@
|
|
|
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
|
-
import type {
|
|
12
|
+
import type { ConfigForm } from '@deepseek-ai/dsh-client-ui-settings/client';
|
|
9
13
|
import type { CardShell, CardFieldState, CardActions, SnapshotStore } from './form.ts';
|
|
10
14
|
/**
|
|
11
|
-
* Settings namespace this card edits
|
|
12
|
-
*
|
|
15
|
+
* Settings namespace this card edits: the composition entry id, which is
|
|
16
|
+
* what the host's settings service keys the section derived from the
|
|
17
|
+
* plugin's Config schema by. Spelled here rather than imported: a client
|
|
18
|
+
* package must not depend on a Host package.
|
|
13
19
|
*/
|
|
14
20
|
export declare const WEB_FETCH_PLAYWRIGHT_NS = "web-fetch-playwright";
|
|
15
21
|
/** The section fields this card edits. */
|
|
@@ -60,18 +66,22 @@ export interface PlaywrightCardFace extends CardActions {
|
|
|
60
66
|
playwrightCard: SnapshotStore<PlaywrightCardState>;
|
|
61
67
|
};
|
|
62
68
|
}
|
|
63
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* Bridges the `web-fetch-playwright` configuration form onto the card.
|
|
71
|
+
*/
|
|
64
72
|
export declare class PlaywrightCardController {
|
|
65
73
|
private readonly form;
|
|
66
74
|
private readonly store;
|
|
67
75
|
/**
|
|
68
|
-
* @param scope - the
|
|
76
|
+
* @param scope - the shared configuration form for the `web-fetch-playwright` entry.
|
|
69
77
|
*/
|
|
70
|
-
constructor(scope:
|
|
78
|
+
constructor(scope: ConfigForm<PlaywrightSettings>);
|
|
71
79
|
private projection;
|
|
72
80
|
/**
|
|
73
81
|
* Build the face the card's slot registration injects.
|
|
74
82
|
* @returns the card's snapshot and its form actions.
|
|
75
83
|
*/
|
|
76
84
|
inject(): PlaywrightCardFace;
|
|
85
|
+
/** Release the form subscription and every bound stores. */
|
|
86
|
+
dispose(): void;
|
|
77
87
|
}
|
|
@@ -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
|
|
@@ -12,7 +14,7 @@
|
|
|
12
14
|
*
|
|
13
15
|
* @module dsh-web-fetch-playwright/client/form
|
|
14
16
|
*/
|
|
15
|
-
import type {
|
|
17
|
+
import type { ConfigForm } from '@deepseek-ai/dsh-client-ui-settings/client';
|
|
16
18
|
/** The write one field's staged draft performs when the card is saved. */
|
|
17
19
|
export type FieldWrite = {
|
|
18
20
|
kind: 'set';
|
|
@@ -105,22 +107,26 @@ export declare function checkboxField(field: string): CardFieldSpec;
|
|
|
105
107
|
*/
|
|
106
108
|
export declare function numberField(field: string, min: number, max: number): CardFieldSpec;
|
|
107
109
|
/**
|
|
108
|
-
* Stages the Playwright card's edits over one
|
|
109
|
-
* them on save. Publishes through a snapshot store because
|
|
110
|
-
* read through a selector while both the
|
|
110
|
+
* Stages the Playwright card's edits over one plugin-entry configuration
|
|
111
|
+
* form and writes them on save. Publishes through a snapshot store because
|
|
112
|
+
* slot components read through a selector while both the form and the drafts
|
|
113
|
+
* change below.
|
|
111
114
|
*/
|
|
112
115
|
export declare class CardForm<T> {
|
|
113
116
|
private readonly scope;
|
|
114
117
|
private readonly specs;
|
|
115
118
|
private readonly staged;
|
|
116
119
|
private readonly listeners;
|
|
120
|
+
private readonly unsubscribe;
|
|
117
121
|
private saving;
|
|
118
122
|
private failed;
|
|
119
123
|
/**
|
|
120
|
-
* @param scope - the
|
|
124
|
+
* @param scope - the shared configuration form for this plugin's entry.
|
|
121
125
|
* @param specs - the section fields this card edits.
|
|
122
126
|
*/
|
|
123
|
-
constructor(scope:
|
|
127
|
+
constructor(scope: ConfigForm<T>, specs: CardFieldSpec[]);
|
|
128
|
+
/** Release the form subscription and every bound stores. */
|
|
129
|
+
dispose(): void;
|
|
124
130
|
/**
|
|
125
131
|
* Publish a projection of this form, rebuilt whenever the scope or a draft
|
|
126
132
|
* changes.
|
|
@@ -147,7 +153,9 @@ export declare class CardForm<T> {
|
|
|
147
153
|
/**
|
|
148
154
|
* Write every staged edit, then re-seed from what the Host accepted. A save
|
|
149
155
|
* that did not land keeps its drafts, so the user corrects them instead of
|
|
150
|
-
* retyping.
|
|
156
|
+
* retyping. The shared form reports `false` (and reloads Host state) for a
|
|
157
|
+
* refused revision or validation, and a transport drop rejects — both fold
|
|
158
|
+
* into the same failed-save path.
|
|
151
159
|
*/
|
|
152
160
|
save(): Promise<void>;
|
|
153
161
|
/**
|
|
@@ -1,9 +1,19 @@
|
|
|
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
|
*/
|
|
@@ -11,7 +21,8 @@ import type { Context } from 'cordis';
|
|
|
11
21
|
/** Required services (cordis fiber inject). */
|
|
12
22
|
export declare const inject: string[];
|
|
13
23
|
/**
|
|
14
|
-
* Mount the Playwright plugin-configuration card
|
|
24
|
+
* Mount the Playwright plugin-configuration card while the Host serves the
|
|
25
|
+
* `web-fetch-playwright` namespace.
|
|
15
26
|
* @param ctx - the browser plugin context.
|
|
16
27
|
*/
|
|
17
28
|
export declare function apply(ctx: Context): void;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @module dsh-web-fetch-playwright/client/locales
|
|
6
6
|
*/
|
|
7
7
|
/** Locale keys this card renders. */
|
|
8
|
-
export type PlaywrightCardLocaleKey = '
|
|
8
|
+
export type PlaywrightCardLocaleKey = 'description' | 'backendLabel' | 'backendLocal' | 'backendLocalHint' | 'backendCdp' | 'backendCdpHint' | 'playwrightPath' | 'playwrightPathHint' | 'playwrightPathPlaceholder' | 'cdpEndpoint' | 'cdpEndpointHint' | 'shareBrowserContext' | 'shareBrowserContextHint' | 'denoise' | 'denoiseHint' | 'maxConcurrency' | 'maxConcurrencyHint' | 'maxConcurrencyPlaceholder' | 'challengeWaitMs' | 'challengeWaitMsHint' | 'challengeWaitMsPlaceholder' | 'overridden' | 'reset' | 'readOnly' | 'save' | 'saving' | 'discard' | 'saveFailed' | 'invalidText';
|
|
9
9
|
/** This plugin's dictionary namespace, merged into the locale key map. */
|
|
10
10
|
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
11
11
|
interface LocaleNamespaceMap {
|
package/lib/types/config.d.ts
CHANGED
|
@@ -4,8 +4,15 @@
|
|
|
4
4
|
* resolved shape, and the small pure normalizers the provider applies per
|
|
5
5
|
* fetch (CDP endpoint shaping) — kept network-free for unit tests.
|
|
6
6
|
*
|
|
7
|
+
* Since dsh 0.1.7 the settings service derives a plugin's configuration page
|
|
8
|
+
* from its composition entry's `Config` schema: every field marked
|
|
9
|
+
* `.volatile()` is editable live (Settings → Plugins), and a committed edit
|
|
10
|
+
* is pushed into the running plugin's volatile references without a remount —
|
|
11
|
+
* this schema IS the `web-fetch-playwright` settings section.
|
|
12
|
+
*
|
|
7
13
|
* @module dsh-web-fetch-playwright/config
|
|
8
14
|
*/
|
|
15
|
+
import type { Volatile } from '@deepseek-ai/cordis';
|
|
9
16
|
import z from '@deepseek-ai/schemastery';
|
|
10
17
|
/** Default CDP endpoint when the settings section leaves it blank. */
|
|
11
18
|
export declare const DEFAULT_CDP_ENDPOINT = "127.0.0.1:9222";
|
|
@@ -86,7 +93,72 @@ export interface Config {
|
|
|
86
93
|
*/
|
|
87
94
|
maxConcurrency?: number;
|
|
88
95
|
}
|
|
89
|
-
export declare const Config: z<
|
|
96
|
+
export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
97
|
+
backend: z<"local" | "cdp", "local" | "cdp", "volatile-defined">;
|
|
98
|
+
playwrightPath: z<string, string, "volatile-defined">;
|
|
99
|
+
cdpEndpoint: z<string, string, "volatile-defined">;
|
|
100
|
+
shareBrowserContext: z<boolean, boolean, "volatile-defined">;
|
|
101
|
+
denoise: z<boolean, boolean, "volatile-defined">;
|
|
102
|
+
maxConcurrency: z<number, number, "volatile">;
|
|
103
|
+
challengeWaitMs: z<number, number, "volatile-defined">;
|
|
104
|
+
challengeRetries: z<number, number, "volatile-defined">;
|
|
105
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
106
|
+
backend: z<"local" | "cdp", "local" | "cdp", "volatile-defined">;
|
|
107
|
+
playwrightPath: z<string, string, "volatile-defined">;
|
|
108
|
+
cdpEndpoint: z<string, string, "volatile-defined">;
|
|
109
|
+
shareBrowserContext: z<boolean, boolean, "volatile-defined">;
|
|
110
|
+
denoise: z<boolean, boolean, "volatile-defined">;
|
|
111
|
+
maxConcurrency: z<number, number, "volatile">;
|
|
112
|
+
challengeWaitMs: z<number, number, "volatile-defined">;
|
|
113
|
+
challengeRetries: z<number, number, "volatile-defined">;
|
|
114
|
+
}>>, "plain">;
|
|
115
|
+
/**
|
|
116
|
+
* The config `apply` receives once the schema resolves: every volatile field
|
|
117
|
+
* arrives as a live reference whose snapshot a settings commit replaces in
|
|
118
|
+
* place, so the provider re-reads them per fetch (the plugin never remounts
|
|
119
|
+
* for an edit).
|
|
120
|
+
*/
|
|
121
|
+
export interface PlaywrightPluginConfig {
|
|
122
|
+
/** Backend selector as a live reference. */
|
|
123
|
+
backend: Volatile<PlaywrightBackend>;
|
|
124
|
+
/** Local backend executable path as a live reference. */
|
|
125
|
+
playwrightPath: Volatile<string>;
|
|
126
|
+
/** CDP endpoint as a live reference. */
|
|
127
|
+
cdpEndpoint: Volatile<string>;
|
|
128
|
+
/** Shared-context toggle as a live reference. */
|
|
129
|
+
shareBrowserContext: Volatile<boolean>;
|
|
130
|
+
/** Denoise toggle as a live reference. */
|
|
131
|
+
denoise: Volatile<boolean>;
|
|
132
|
+
/**
|
|
133
|
+
* Concurrency limit as a live reference; `undefined` while unset (the
|
|
134
|
+
* field owns no default — the backend resolves one).
|
|
135
|
+
*/
|
|
136
|
+
maxConcurrency: Volatile<number | undefined>;
|
|
137
|
+
/** Challenge wait budget (ms) as a live reference. */
|
|
138
|
+
challengeWaitMs: Volatile<number>;
|
|
139
|
+
/** Challenge retry count as a live reference. */
|
|
140
|
+
challengeRetries: Volatile<number>;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Read the live references `apply` holds into one plain input for
|
|
144
|
+
* {@link resolveConfig}; a settings commit has usually replaced the
|
|
145
|
+
* snapshots since the last call, which is the whole point.
|
|
146
|
+
*
|
|
147
|
+
* @param config - the plugin config as the loader resolved it.
|
|
148
|
+
* @returns the current snapshots, ready for resolution.
|
|
149
|
+
*/
|
|
150
|
+
export declare function snapshotsOf(config: PlaywrightPluginConfig): Config;
|
|
151
|
+
/**
|
|
152
|
+
* Resolve any accepted config input into the fully-defaulted, plain form the
|
|
153
|
+
* provider consumes per fetch. Validation goes through the schema, so the
|
|
154
|
+
* volatile wrappers that produces are unwrapped immediately — the provider
|
|
155
|
+
* consumes plain values. The input face is `Partial` by design (composition
|
|
156
|
+
* entries and volatile snapshots both omit fields; defaults supply them).
|
|
157
|
+
*
|
|
158
|
+
* @param config - composition entry, settings-section value, or volatile snapshots.
|
|
159
|
+
* @returns the resolved config.
|
|
160
|
+
*/
|
|
161
|
+
export declare function resolveConfig(config: Partial<Config>): ResolvedConfig;
|
|
90
162
|
/**
|
|
91
163
|
* Complete config after schemastery applies the field defaults it owns.
|
|
92
164
|
* `maxConcurrency` stays optional — {@link effectiveMaxConcurrency} resolves
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `dsh-web-fetch-playwright`: registers the Playwright/CDP
|
|
3
|
-
* {@link PlaywrightFetchProvider} with `ctx.web
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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 {
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
30
|
-
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-web-fetch-playwright",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
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.
|
|
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-
|
|
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.
|
|
111
|
-
"@deepseek-ai/dsh-
|
|
112
|
-
"@deepseek-ai/dsh-client-locale": "0.1.
|
|
113
|
-
"@deepseek-ai/dsh-client-
|
|
114
|
-
"@deepseek-ai/dsh-client-
|
|
115
|
-
"@deepseek-ai/dsh-client-ui-
|
|
116
|
-
"@deepseek-ai/dsh-client-ui-settings
|
|
117
|
-
"@deepseek-ai/dsh-client-ui-slots": "0.1.
|
|
118
|
-
"@deepseek-ai/dsh-
|
|
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",
|