@linxin666/dsh-client-ui-browser-view 0.4.12 → 0.4.13
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.i18n.yaml +2 -2
- package/README.md +43 -12
- package/README.zh.md +43 -12
- package/icon.svg +3 -0
- package/lib/client.js +1733 -17
- package/lib/client.js.map +1 -1
- package/lib/index.js +363 -48
- package/lib/types/client/BrowserViewSettingsCard.d.ts +40 -0
- package/lib/types/client/PluginSettingsCard.d.ts +255 -0
- package/lib/types/client/RangeBubble.d.ts +46 -0
- package/lib/types/client/SegmentGroup.d.ts +28 -0
- package/lib/types/client/config.d.ts +6 -0
- package/lib/types/client/index.d.ts +10 -0
- package/lib/types/client/locales.d.ts +26 -0
- package/lib/types/client/plugin-card-seat.d.ts +110 -0
- package/lib/types/client/settings-entry-form.d.ts +49 -0
- package/lib/types/client/settings-form.d.ts +235 -0
- package/lib/types/core/protocol.d.ts +7 -1
- package/lib/types/core/tabs.d.ts +20 -0
- package/lib/types/host/cdp-endpoint.d.ts +27 -0
- package/lib/types/host/config.d.ts +26 -0
- package/lib/types/host/service.d.ts +25 -9
- package/lib/types/index.d.ts +10 -1
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +14 -2
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Form model behind the plugin settings card. Every control applies itself:
|
|
3
|
+
* a pick (a segment, a select option, a reset) writes the moment it is made,
|
|
4
|
+
* and typed text writes once typing pauses or the reader leaves the field.
|
|
5
|
+
* Between the edit and the write the edit is held here as a draft, so what is
|
|
6
|
+
* on screen is exactly what the write will store; a write the Host refuses
|
|
7
|
+
* puts a pick back to the stored value and keeps typed text for correcting.
|
|
8
|
+
* Family-shared slice inlined into each plugin's client bundle.
|
|
9
|
+
*/
|
|
10
|
+
import type { ConfigForm } from '@deepseek-ai/dsh-client-ui-settings/client';
|
|
11
|
+
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
|
|
12
|
+
/** The write one field's draft text performs when it is applied. */
|
|
13
|
+
export type FieldWrite = {
|
|
14
|
+
kind: 'set';
|
|
15
|
+
value: unknown;
|
|
16
|
+
} | {
|
|
17
|
+
kind: 'clear';
|
|
18
|
+
};
|
|
19
|
+
/** How one field converts between its stored value and its draft text. */
|
|
20
|
+
export interface FieldSpec {
|
|
21
|
+
/** Field name inside the namespace section. */
|
|
22
|
+
field: string;
|
|
23
|
+
/**
|
|
24
|
+
* How the reader enters a value, which decides when it is written: a `pick`
|
|
25
|
+
* is a whole value at once and applies immediately; `type` is text arriving
|
|
26
|
+
* a keystroke at a time and applies once typing pauses or the field is left.
|
|
27
|
+
*/
|
|
28
|
+
entry: 'pick' | 'type';
|
|
29
|
+
/**
|
|
30
|
+
* Whether the Host treats this field as a secret and redacts its value from
|
|
31
|
+
* the read-back (role('secret') in the section schema). Redacted secrets are
|
|
32
|
+
* never compared against the draft on save: the Host strips them from every
|
|
33
|
+
* wire view layer, so the settled snapshot carries nothing to read back. A
|
|
34
|
+
* staged secret set is judged by the mutation settling; the rest of its
|
|
35
|
+
* batch, when one exists, is still judged by read-back, and the atomic
|
|
36
|
+
* mutation lands every write or none.
|
|
37
|
+
*/
|
|
38
|
+
secret?: boolean;
|
|
39
|
+
/** Render a stored value as draft text; the empty string when the section carries none. */
|
|
40
|
+
format: (value: unknown) => string;
|
|
41
|
+
/**
|
|
42
|
+
* The write this draft text performs, or undefined when the text is not a
|
|
43
|
+
* value this field accepts — which holds the draft unwritten rather than
|
|
44
|
+
* discarding it.
|
|
45
|
+
*/
|
|
46
|
+
parse: (text: string) => FieldWrite | undefined;
|
|
47
|
+
}
|
|
48
|
+
/** One field as the card renders it. */
|
|
49
|
+
export interface FieldState {
|
|
50
|
+
/** Draft text the control renders. */
|
|
51
|
+
text: string;
|
|
52
|
+
/** Whether the field leaves (or will leave) a user-layer entry. */
|
|
53
|
+
overridden: boolean;
|
|
54
|
+
/** Whether the draft is not a value this field accepts, which holds it unwritten. */
|
|
55
|
+
invalid: boolean;
|
|
56
|
+
}
|
|
57
|
+
/** Form state every plugin settings card shares. */
|
|
58
|
+
export interface CardShell {
|
|
59
|
+
/** False while the namespace is still loading; the card renders nothing. */
|
|
60
|
+
available: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Whether the namespace is actually served to this client. False when the
|
|
63
|
+
* Host deployment does not expose it (e.g. the owning plugin's settings
|
|
64
|
+
* domain is not mounted): the card renders an explanation
|
|
65
|
+
* instead of its form, so a missing namespace never looks like a missing
|
|
66
|
+
* plugin.
|
|
67
|
+
*/
|
|
68
|
+
exposed: boolean;
|
|
69
|
+
/** Whether the Host document accepts writes. */
|
|
70
|
+
writable: boolean;
|
|
71
|
+
/** Whether the form holds drafts not yet written (typed text waiting for its pause). */
|
|
72
|
+
dirty: boolean;
|
|
73
|
+
/** Whether any draft is invalid, which holds it unwritten. */
|
|
74
|
+
invalid: boolean;
|
|
75
|
+
/** Whether a write is crossing the wire. */
|
|
76
|
+
saving: boolean;
|
|
77
|
+
/** Whether the last write did not land; cleared by the next edit or write. */
|
|
78
|
+
failed: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* The rejection code/message the Host returned for the last failed save,
|
|
81
|
+
* surfaced next to the generic failure text. Undefined while no save has
|
|
82
|
+
* failed (or the failure carried no server reason).
|
|
83
|
+
*/
|
|
84
|
+
failedReason?: string;
|
|
85
|
+
}
|
|
86
|
+
/** The write actions the card's slot entry injects. */
|
|
87
|
+
export interface CardActions {
|
|
88
|
+
/** Take draft text for one field; a pick writes at once, typed text after a pause. */
|
|
89
|
+
edit: (field: string, text: string) => void;
|
|
90
|
+
/** Clear one field at once, so it re-inherits the composition layer. */
|
|
91
|
+
resetField: (field: string) => void;
|
|
92
|
+
/** Write every pending draft now (a text field's Enter or blur), then re-seed from what the Host accepted. */
|
|
93
|
+
save: () => void;
|
|
94
|
+
/** Drop every pending draft, putting each control back to the stored value (a text field's Escape). */
|
|
95
|
+
discard: () => void;
|
|
96
|
+
}
|
|
97
|
+
/** How long typed text rests before it is written. */
|
|
98
|
+
export declare const TYPE_PAUSE_MS = 600;
|
|
99
|
+
/** One durable write inside the save's atomic form mutation. */
|
|
100
|
+
export interface BatchedWrite {
|
|
101
|
+
/** Field this entry writes. */
|
|
102
|
+
field: string;
|
|
103
|
+
/** set stores a value; unset drops the leaf. */
|
|
104
|
+
op: 'set' | 'unset';
|
|
105
|
+
/** Value for op set (absent for unset). */
|
|
106
|
+
value?: unknown;
|
|
107
|
+
}
|
|
108
|
+
/** Constraints a numeric field's accepted drafts must satisfy, mirroring the host schema. */
|
|
109
|
+
export interface NumberConstraints {
|
|
110
|
+
/** The accepted value must be a whole number. */
|
|
111
|
+
integer?: boolean;
|
|
112
|
+
/** The accepted value must be at least this. */
|
|
113
|
+
min?: number;
|
|
114
|
+
}
|
|
115
|
+
/** A whole- or decimal-number field. An empty draft clears the field; any other draft that is not a finite number within the constraints stays unwritten. */
|
|
116
|
+
export declare function numberField(field: string, constraints?: NumberConstraints): FieldSpec;
|
|
117
|
+
/**
|
|
118
|
+
* A free-text field. An empty draft clears the field. `entry` is `pick` when
|
|
119
|
+
* the text arrives whole from a picker (a preset or a reasoning level).
|
|
120
|
+
*/
|
|
121
|
+
export declare function textField(field: string, entry?: FieldSpec['entry']): FieldSpec;
|
|
122
|
+
/**
|
|
123
|
+
* A free-text field the Host treats as a secret and redacts from the read-back
|
|
124
|
+
* (role('secret') in the section schema). The card still edits it like text,
|
|
125
|
+
* but a save never compares the redacted value back: the staged set is judged
|
|
126
|
+
* by the mutation settling (see {@link FieldSpec.secret}).
|
|
127
|
+
*/
|
|
128
|
+
export declare function secretField(field: string): FieldSpec;
|
|
129
|
+
/** A boolean field, edited through true/false draft text. */
|
|
130
|
+
export declare function booleanField(field: string): FieldSpec;
|
|
131
|
+
/** An enumerated string field; only the listed choices are accepted. An empty draft clears the field. */
|
|
132
|
+
export declare function choiceField(field: string, choices: readonly string[]): FieldSpec;
|
|
133
|
+
/**
|
|
134
|
+
* Applies one card's edits to one settings namespace as the reader makes them.
|
|
135
|
+
*
|
|
136
|
+
* The Host is the only authority on whether a value was accepted — its
|
|
137
|
+
* validators own the constraints no schema can express — so the outcome is
|
|
138
|
+
* read back from the section rather than predicted here. A write that did not
|
|
139
|
+
* land puts each pick back to the stored value, the way a switch that could not
|
|
140
|
+
* flip springs back, and keeps typed text so the reader can correct it instead
|
|
141
|
+
* of retyping.
|
|
142
|
+
*/
|
|
143
|
+
export declare class CardForm<T> {
|
|
144
|
+
private readonly scope;
|
|
145
|
+
private readonly specs;
|
|
146
|
+
private readonly staged;
|
|
147
|
+
private readonly listeners;
|
|
148
|
+
/** The form subscription installed in the constructor; released by dispose(). */
|
|
149
|
+
private readonly disposeForm;
|
|
150
|
+
private disposed;
|
|
151
|
+
/** The pending write of typed text, waiting for typing to pause. */
|
|
152
|
+
private typePause;
|
|
153
|
+
private saving;
|
|
154
|
+
/** A save asked for while one was in flight; it runs once the first settles (#1754). */
|
|
155
|
+
private saveQueued;
|
|
156
|
+
private failed;
|
|
157
|
+
private failedReason;
|
|
158
|
+
/** @param scope - the bound configuration form for this card's namespace. */
|
|
159
|
+
constructor(scope: ConfigForm<T>, specs: FieldSpec[]);
|
|
160
|
+
/**
|
|
161
|
+
* Release the form subscription and every bound store listener. The card
|
|
162
|
+
* must call this on teardown; later calls are no-ops.
|
|
163
|
+
*/
|
|
164
|
+
dispose(): void;
|
|
165
|
+
/** Publish a projection of this form, rebuilt whenever the form or a draft changes. */
|
|
166
|
+
bind<S>(project: () => S): SnapshotStore<S>;
|
|
167
|
+
/** Read the card-level state: what the Host serves, and what is still waiting to be written. */
|
|
168
|
+
shell(): CardShell;
|
|
169
|
+
/** Read one field's state from the effective section and its staged draft. */
|
|
170
|
+
field(field: string): FieldState;
|
|
171
|
+
/** The actions the card's slot registration injects. */
|
|
172
|
+
actions(): CardActions;
|
|
173
|
+
/**
|
|
174
|
+
* Run one write, and re-run it once if another was asked for while this one
|
|
175
|
+
* was still in flight.
|
|
176
|
+
*
|
|
177
|
+
* A write is a Host round trip that also drives the profile reconcile, and
|
|
178
|
+
* the Host runs it inside one exclusive transaction. Answering an edit that
|
|
179
|
+
* arrives mid-flight by returning immediately dropped it with no explanation
|
|
180
|
+
* (#1754). Serializing instead means an edit made while another write is
|
|
181
|
+
* still settling is written against the settled state.
|
|
182
|
+
* @returns settlement after the mutation and the read-back.
|
|
183
|
+
*/
|
|
184
|
+
requestSave(): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* Write every valid draft in one atomic form mutation, then re-seed from
|
|
187
|
+
* what the Host accepted. A draft the field does not accept stays on screen,
|
|
188
|
+
* unwritten, without holding the others back.
|
|
189
|
+
*
|
|
190
|
+
* The batch rides one mutate, so cross-field validate hooks (baseURL+model)
|
|
191
|
+
* judge it as a unit: the Host either applies every write or refuses the
|
|
192
|
+
* batch. The form contract answers a refusal or a skipped write with `false`
|
|
193
|
+
* (it recovers with a fresh Host view instead of throwing), so the outcome is
|
|
194
|
+
* judged twice: the answer itself, and then the settled snapshot read back
|
|
195
|
+
* one planned write at a time. One missed write fails the whole batch. A
|
|
196
|
+
* transport that rejects instead (the dsh-web bridge controller on a dead
|
|
197
|
+
* connection) reports through the same failure path with its rejection
|
|
198
|
+
* message. A batch that did not land puts its picks and clears back to the
|
|
199
|
+
* stored value and keeps its typed text, so the reader can correct it.
|
|
200
|
+
* @returns settlement after the mutation and the read-back.
|
|
201
|
+
*/
|
|
202
|
+
save(): Promise<void>;
|
|
203
|
+
/**
|
|
204
|
+
* Every staged edit a write would carry. An entry whose draft is not a value
|
|
205
|
+
* its field accepts carries no write: the form is still dirty, and the draft
|
|
206
|
+
* stays on screen rather than being dropped. A staged edit that matches the
|
|
207
|
+
* effective section is not a write at all.
|
|
208
|
+
* @returns the planned writes, in the order the fields were staged.
|
|
209
|
+
*/
|
|
210
|
+
private plan;
|
|
211
|
+
/**
|
|
212
|
+
* Read-back judgment for a planned set: the user layer must hold the
|
|
213
|
+
* intended value once the mutation has settled.
|
|
214
|
+
*/
|
|
215
|
+
private landedSet;
|
|
216
|
+
/**
|
|
217
|
+
* Read-back judgment for a planned unset: the field must be gone from the
|
|
218
|
+
* user layer once the mutation has settled.
|
|
219
|
+
*/
|
|
220
|
+
private landedUnset;
|
|
221
|
+
/**
|
|
222
|
+
* Take one edit and schedule its write: a pick or a clear is written now,
|
|
223
|
+
* typed text once typing has rested for TYPE_PAUSE_MS.
|
|
224
|
+
*/
|
|
225
|
+
private stage;
|
|
226
|
+
/** Write every pending draft now, taking the place of a waiting pause. */
|
|
227
|
+
private applyNow;
|
|
228
|
+
private specOf;
|
|
229
|
+
private snapshotOf;
|
|
230
|
+
private sectionValue;
|
|
231
|
+
private baseValue;
|
|
232
|
+
private userLayer;
|
|
233
|
+
private stored;
|
|
234
|
+
private publish;
|
|
235
|
+
}
|
|
@@ -42,6 +42,8 @@ export interface BrowserTabView {
|
|
|
42
42
|
loading: boolean;
|
|
43
43
|
/** Session that last acted on the tab, when any. */
|
|
44
44
|
sessionId?: string;
|
|
45
|
+
/** Whether DSH created this target or adopted an existing real-browser tab. */
|
|
46
|
+
origin?: 'created' | 'adopted';
|
|
45
47
|
}
|
|
46
48
|
/** What the header of the panel shows. */
|
|
47
49
|
export interface BrowserPanelState {
|
|
@@ -49,8 +51,12 @@ export interface BrowserPanelState {
|
|
|
49
51
|
tabs: BrowserTabView[];
|
|
50
52
|
/** Tab the panel is watching, null when none is open. */
|
|
51
53
|
activeTabId: string | null;
|
|
52
|
-
/** Whether the host half currently
|
|
54
|
+
/** Whether the host half currently has a live browser process or CDP attachment. */
|
|
53
55
|
running: boolean;
|
|
56
|
+
/** Browser source selected for the current configuration; absent in older hosts. */
|
|
57
|
+
mode?: 'isolated' | 'cdp';
|
|
58
|
+
/** Normalized loopback CDP origin when real-browser mode is selected. */
|
|
59
|
+
cdpEndpoint?: string;
|
|
54
60
|
/** Last error text the host wants the panel to show instead of a frame. */
|
|
55
61
|
message?: string;
|
|
56
62
|
}
|
package/lib/types/core/tabs.d.ts
CHANGED
|
@@ -51,6 +51,10 @@ export interface TabManagerOptions {
|
|
|
51
51
|
onFrame?: (frame: ScreencastFrame) => void;
|
|
52
52
|
/** Notifies that a tab's url, title, loading state, or membership changed. */
|
|
53
53
|
onTabsChanged?: () => void;
|
|
54
|
+
/** Discover and adopt existing/future page targets instead of only DSH-created ones. */
|
|
55
|
+
discoverTargets?: boolean;
|
|
56
|
+
/** Pin new tabs to the fixed isolated viewport. @default true */
|
|
57
|
+
pinViewport?: boolean;
|
|
54
58
|
}
|
|
55
59
|
/** One tab's host-side record. */
|
|
56
60
|
interface TabRecord {
|
|
@@ -66,6 +70,7 @@ interface TabRecord {
|
|
|
66
70
|
*/
|
|
67
71
|
loaderId: string | undefined;
|
|
68
72
|
ownerSessionId: string | undefined;
|
|
73
|
+
origin: 'created' | 'adopted';
|
|
69
74
|
console: BrowserConsoleEntry[];
|
|
70
75
|
network: BrowserNetworkEntry[];
|
|
71
76
|
/** Pending requests keyed by network request id, so response frames update in place. */
|
|
@@ -91,11 +96,14 @@ export declare class TabManager {
|
|
|
91
96
|
private readonly viewport;
|
|
92
97
|
private readonly ringSize;
|
|
93
98
|
private readonly now;
|
|
99
|
+
private readonly discoversTargets;
|
|
100
|
+
private readonly pinViewports;
|
|
94
101
|
private onFrame;
|
|
95
102
|
private onTabsChanged;
|
|
96
103
|
private readonly tabs;
|
|
97
104
|
private readonly bySession;
|
|
98
105
|
private readonly unsubscribers;
|
|
106
|
+
private readonly attaching;
|
|
99
107
|
private active;
|
|
100
108
|
private disposed;
|
|
101
109
|
/**
|
|
@@ -129,6 +137,16 @@ export declare class TabManager {
|
|
|
129
137
|
url?: string;
|
|
130
138
|
sessionId?: string;
|
|
131
139
|
}): Promise<BrowserTabView>;
|
|
140
|
+
/** Discover every existing page and keep following pages created later. */
|
|
141
|
+
discoverExistingTabs(): Promise<void>;
|
|
142
|
+
/** Adopt one target-created event without racing an explicit create/attach. */
|
|
143
|
+
private adoptTarget;
|
|
144
|
+
/** Attach a page exactly once, coalescing discovery and Target.createTarget. */
|
|
145
|
+
private attachTarget;
|
|
146
|
+
/** Build and instrument one previously unseen page record. */
|
|
147
|
+
private attachNewTarget;
|
|
148
|
+
/** Forget a target the real browser closed. */
|
|
149
|
+
private removeTarget;
|
|
132
150
|
/**
|
|
133
151
|
* Pin CSS-pixel viewport metrics so frames, boxes, and clicks share one
|
|
134
152
|
* coordinate space regardless of the window the browser opened with.
|
|
@@ -184,6 +202,8 @@ export declare class TabManager {
|
|
|
184
202
|
* @returns the emitted frame.
|
|
185
203
|
*/
|
|
186
204
|
refreshFrame(tabId: string): Promise<ScreencastFrame>;
|
|
205
|
+
/** Read the real CSS viewport without changing it in external-browser mode. */
|
|
206
|
+
private frameViewport;
|
|
187
207
|
/**
|
|
188
208
|
* Console entries captured so far, oldest first.
|
|
189
209
|
* @param tabId - target tab.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loopback-only discovery of an external Chrome DevTools endpoint.
|
|
3
|
+
* @module @linxin666/dsh-client-ui-browser-view/host/cdp-endpoint
|
|
4
|
+
*/
|
|
5
|
+
/** Normalized external CDP HTTP endpoint. */
|
|
6
|
+
export interface CdpEndpoint {
|
|
7
|
+
/** Origin with no path, credentials, query, or fragment. */
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
/** The discovery document that publishes the browser WebSocket. */
|
|
10
|
+
versionUrl: string;
|
|
11
|
+
}
|
|
12
|
+
/** Browser discovery facts needed to open a CDP connection. */
|
|
13
|
+
export interface CdpVersion {
|
|
14
|
+
webSocketDebuggerUrl: string;
|
|
15
|
+
browser?: string;
|
|
16
|
+
}
|
|
17
|
+
/** Parse and normalize the configured HTTP endpoint, failing closed. */
|
|
18
|
+
export declare function parseCdpEndpoint(raw: string): CdpEndpoint;
|
|
19
|
+
/** Validate the WebSocket published by the local discovery document. */
|
|
20
|
+
export declare function parseCdpWebSocketUrl(raw: string): string;
|
|
21
|
+
/** Fetch and validate the external browser's discovery document. */
|
|
22
|
+
export declare function fetchCdpVersion(endpoint: CdpEndpoint, options?: {
|
|
23
|
+
timeoutMs?: number;
|
|
24
|
+
fetchImpl?: typeof fetch;
|
|
25
|
+
}): Promise<CdpVersion>;
|
|
26
|
+
/** Add the real-browser startup constraints to any external connection error. */
|
|
27
|
+
export declare function realBrowserConnectionError(endpoint: CdpEndpoint, error: unknown): Error;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-view plugin configuration. The Host turns this volatile schema into
|
|
3
|
+
* the profile entry's settings form and commits edits into live references.
|
|
4
|
+
* @module @linxin666/dsh-client-ui-browser-view/host/config
|
|
5
|
+
*/
|
|
6
|
+
import type { Volatile } from '@deepseek-ai/cordis';
|
|
7
|
+
import z from '@deepseek-ai/schemastery';
|
|
8
|
+
/** Runtime configuration: one live reference per settings field. */
|
|
9
|
+
export interface Config {
|
|
10
|
+
realBrowserEnabled: Volatile<boolean>;
|
|
11
|
+
cdpEndpoint: Volatile<string>;
|
|
12
|
+
}
|
|
13
|
+
/** Profile-patch shape before the schema adds defaults and live references. */
|
|
14
|
+
export interface ConfigInput {
|
|
15
|
+
realBrowserEnabled?: boolean;
|
|
16
|
+
cdpEndpoint?: string;
|
|
17
|
+
}
|
|
18
|
+
/** Values after defaults and live references have been resolved. */
|
|
19
|
+
export interface ResolvedConfig {
|
|
20
|
+
realBrowserEnabled: boolean;
|
|
21
|
+
cdpEndpoint: string;
|
|
22
|
+
}
|
|
23
|
+
/** Settings schema exported through the host loader entry. */
|
|
24
|
+
export declare const Config: z<ConfigInput, Config>;
|
|
25
|
+
/** Read the current values, including edits committed without a plugin remount. */
|
|
26
|
+
export declare function effectiveConfig(config?: Config): ResolvedConfig;
|
|
@@ -48,8 +48,26 @@ export interface BrowserViewBackend {
|
|
|
48
48
|
*/
|
|
49
49
|
handleCommand(sink: BrowserViewSink, command: BrowserViewCommand): Promise<void>;
|
|
50
50
|
}
|
|
51
|
+
export type BrowserMode = 'isolated' | 'cdp';
|
|
52
|
+
/** Current browser source, resolved live when a session starts. */
|
|
53
|
+
export interface BrowserConnectionConfig {
|
|
54
|
+
mode: BrowserMode;
|
|
55
|
+
cdpEndpoint?: string;
|
|
56
|
+
}
|
|
57
|
+
/** Options shared by the isolated and external session factories. */
|
|
58
|
+
export interface OpenSessionOptions extends BrowserConnectionConfig {
|
|
59
|
+
jpegQuality: number;
|
|
60
|
+
viewport: {
|
|
61
|
+
width: number;
|
|
62
|
+
height: number;
|
|
63
|
+
};
|
|
64
|
+
onFrame: (frame: ScreencastFrame) => void;
|
|
65
|
+
onTabsChanged: () => void;
|
|
66
|
+
}
|
|
51
67
|
/** One running browser plus the tab manager over it. */
|
|
52
68
|
export interface BrowserSession {
|
|
69
|
+
/** Explicit ownership/lifecycle mode; never inferred from process fields. */
|
|
70
|
+
mode: BrowserMode;
|
|
53
71
|
/** Protocol transport the tabs and the actions share. */
|
|
54
72
|
transport: CdpTransport;
|
|
55
73
|
/** Tabs of this browser. */
|
|
@@ -76,16 +94,10 @@ export interface BrowserViewServiceOptions {
|
|
|
76
94
|
* the loader from `ctx.get('connection')`; absent here means no auth top-up.
|
|
77
95
|
*/
|
|
78
96
|
authenticatedUrl?: (url: string) => string | undefined;
|
|
97
|
+
/** Live browser source; called for state and every new connection. */
|
|
98
|
+
resolveConfig?: () => BrowserConnectionConfig;
|
|
79
99
|
/** Browser factory, replaced by tests. */
|
|
80
|
-
openSession?: (options:
|
|
81
|
-
jpegQuality: number;
|
|
82
|
-
viewport: {
|
|
83
|
-
width: number;
|
|
84
|
-
height: number;
|
|
85
|
-
};
|
|
86
|
-
onFrame: (frame: ScreencastFrame) => void;
|
|
87
|
-
onTabsChanged: () => void;
|
|
88
|
-
}) => Promise<BrowserSession>;
|
|
100
|
+
openSession?: (options: OpenSessionOptions) => Promise<BrowserSession>;
|
|
89
101
|
}
|
|
90
102
|
/**
|
|
91
103
|
* The plugin's single browser service.
|
|
@@ -95,6 +107,7 @@ export declare class BrowserViewService implements BrowserViewBackend {
|
|
|
95
107
|
private readonly viewport;
|
|
96
108
|
private readonly now;
|
|
97
109
|
private readonly openSession;
|
|
110
|
+
private readonly resolveConfig;
|
|
98
111
|
private readonly authenticatedUrl;
|
|
99
112
|
private readonly sinks;
|
|
100
113
|
private readonly bindings;
|
|
@@ -121,6 +134,7 @@ export declare class BrowserViewService implements BrowserViewBackend {
|
|
|
121
134
|
private opening;
|
|
122
135
|
private openingTab;
|
|
123
136
|
private lastError;
|
|
137
|
+
private generation;
|
|
124
138
|
private disposed;
|
|
125
139
|
/**
|
|
126
140
|
* @param options - quality, viewport, clock, and the browser factory seam.
|
|
@@ -341,6 +355,8 @@ export declare class BrowserViewService implements BrowserViewBackend {
|
|
|
341
355
|
}>;
|
|
342
356
|
/** Push one event to every attached panel, dropping sockets that fail. */
|
|
343
357
|
broadcast(event: BrowserViewEvent): void;
|
|
358
|
+
/** Apply a settings edit: detach the old source and restart an attached panel's stream. */
|
|
359
|
+
reconfigure(): Promise<void>;
|
|
344
360
|
/**
|
|
345
361
|
* Tear everything down: stop pushing, stop streaming, close the socket, kill
|
|
346
362
|
* the browser.
|
package/lib/types/index.d.ts
CHANGED
|
@@ -20,6 +20,15 @@
|
|
|
20
20
|
* @module @linxin666/dsh-client-ui-browser-view
|
|
21
21
|
*/
|
|
22
22
|
import type { Context } from '@deepseek-ai/cordis';
|
|
23
|
+
import { type Config as RuntimeConfig } from './host/config.ts';
|
|
24
|
+
export { Config } from './host/config.ts';
|
|
25
|
+
export type { ConfigInput, ResolvedConfig } from './host/config.ts';
|
|
26
|
+
declare module '@deepseek-ai/cordis' {
|
|
27
|
+
interface Events {
|
|
28
|
+
/** Volatile settings committed without remounting this plugin row. */
|
|
29
|
+
'loader/volatile-update'(paths: readonly (readonly string[])[]): void;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
23
32
|
/** Stable cordis plugin name. */
|
|
24
33
|
export declare const name = "browser-view";
|
|
25
34
|
/** Services required before the routes and the tools can mount. */
|
|
@@ -28,4 +37,4 @@ export declare const inject: string[];
|
|
|
28
37
|
* Mount the routes, the tools, and the browser lifetime.
|
|
29
38
|
* @param ctx - host plugin context carrying webServer and tools.
|
|
30
39
|
*/
|
|
31
|
-
export declare function apply(ctx: Context): void;
|
|
40
|
+
export declare function apply(ctx: Context, config?: RuntimeConfig): void;
|
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linxin666/dsh-client-ui-browser-view",
|
|
3
3
|
"description": "Right-docked live browser view for the DSH Web GUI: a CDP-driven Chromium the agent operates, a screencast panel the user watches, and screenshots attached to every tool result.",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.13",
|
|
5
|
+
"icon": "icon.svg",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "lib/index.js",
|
|
7
8
|
"types": "lib/types/index.d.ts",
|
|
@@ -15,6 +16,8 @@
|
|
|
15
16
|
"default": "./lib/client.js"
|
|
16
17
|
},
|
|
17
18
|
"./src/*": "./src/*",
|
|
19
|
+
"./locale/en.json": "./locale/en.json",
|
|
20
|
+
"./locale/zh.json": "./locale/zh.json",
|
|
18
21
|
"./package.json": "./package.json"
|
|
19
22
|
},
|
|
20
23
|
"dsh": {
|
|
@@ -30,6 +33,9 @@
|
|
|
30
33
|
"@deepseek-ai/dsh-client-ui-renderer",
|
|
31
34
|
"@deepseek-ai/dsh-client-ui-layout",
|
|
32
35
|
"@deepseek-ai/dsh-client-ui-sidebar-right",
|
|
36
|
+
"@deepseek-ai/dsh-client-ui-settings",
|
|
37
|
+
"@deepseek-ai/dsh-api-remotes",
|
|
38
|
+
"@deepseek-ai/dsh-client-store",
|
|
33
39
|
"@deepseek-ai/dsh-client-locale"
|
|
34
40
|
],
|
|
35
41
|
"platform": "web"
|
|
@@ -45,10 +51,14 @@
|
|
|
45
51
|
},
|
|
46
52
|
"devDependencies": {
|
|
47
53
|
"@deepseek-ai/cordis": "^4.0.5",
|
|
54
|
+
"@deepseek-ai/dsh-api-remotes": "0.2.1-rc.3",
|
|
48
55
|
"@deepseek-ai/dsh-client-locale": "^0.2.1-rc.3",
|
|
56
|
+
"@deepseek-ai/dsh-client-store": "0.2.1-rc.3",
|
|
49
57
|
"@deepseek-ai/dsh-client-ui-layout": "^0.2.1-rc.3",
|
|
58
|
+
"@deepseek-ai/dsh-client-ui-plugin-manager": "0.2.1-rc.3",
|
|
50
59
|
"@deepseek-ai/dsh-client-ui-primitives": "^0.2.1-rc.3",
|
|
51
60
|
"@deepseek-ai/dsh-client-ui-renderer": "^0.2.1-rc.3",
|
|
61
|
+
"@deepseek-ai/dsh-client-ui-settings": "0.2.1-rc.3",
|
|
52
62
|
"@deepseek-ai/dsh-client-ui-sidebar-right": "^0.2.1-rc.3",
|
|
53
63
|
"@deepseek-ai/dsh-client-ui-slots": "^0.2.1-rc.3",
|
|
54
64
|
"@deepseek-ai/dsh-host-webserver": "^0.2.1-rc.3",
|
|
@@ -72,7 +82,9 @@
|
|
|
72
82
|
"cordis.patch.yml",
|
|
73
83
|
"README.md",
|
|
74
84
|
"README.zh.md",
|
|
75
|
-
"README.i18n.yaml"
|
|
85
|
+
"README.i18n.yaml",
|
|
86
|
+
"icon.svg",
|
|
87
|
+
"locale"
|
|
76
88
|
],
|
|
77
89
|
"license": "BSD-3-Clause",
|
|
78
90
|
"scripts": {
|