dsh-browser-cdp 0.18.13 → 0.18.15
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/dsh-plugin.json +1 -1
- package/lib/client.js +75 -70
- package/package.json +1 -1
package/dsh-plugin.json
CHANGED
package/lib/client.js
CHANGED
|
@@ -1857,6 +1857,7 @@ function apply(ctx) {
|
|
|
1857
1857
|
mountFamilySettingsCard(ctx);
|
|
1858
1858
|
mountPluginsPageCard(ctx);
|
|
1859
1859
|
mountPicksDockCard(ctx);
|
|
1860
|
+
mountPicksBadge(ctx);
|
|
1860
1861
|
var betterSidebarService;
|
|
1861
1862
|
try {
|
|
1862
1863
|
betterSidebarService = typeof ctx.get === "function" ? ctx.get("betterSidebar") : void 0;
|
|
@@ -3103,6 +3104,13 @@ var TAB_CSS = `
|
|
|
3103
3104
|
* {"cdpEndpoint":..., "targetId":..., "pageUrl":..., "elements":[{n,backendNodeId,tag,id,name,focusable,describe}]}
|
|
3104
3105
|
* [/CDP-PICKS]
|
|
3105
3106
|
*/
|
|
3107
|
+
function injectPickCardStyles() {
|
|
3108
|
+
if (document.getElementById("dsh-cdp-picks-styles") !== null) return;
|
|
3109
|
+
var style = document.createElement("style");
|
|
3110
|
+
style.id = "dsh-cdp-picks-styles";
|
|
3111
|
+
style.textContent = "[data-dsh-cdp-picks-card] {\n box-sizing: border-box; flex: none;\n display: grid; gap: 4px; padding: 8px 10px;\n font: inherit; font-size: 12px;\n color: #1d1d1f; background: #f7f7f9;\n border: 1px solid rgba(0, 0, 0, 0.16); border-radius: 12px;\n box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);\n /* input-traffic 同款限宽:卡宽被限制在内容列(拖动范围)内,两侧留出\n clearance,永不顶满整窗 */\n width: min(\n calc(100% - var(--dsh-composer-side-clearance, 16px) - var(--dsh-composer-side-clearance, 16px) - var(--dsh-composer-dock-inset, 8px) - var(--dsh-composer-dock-inset, 8px)),\n calc(var(--dsh-chat-content-width, 100%) - var(--dsh-composer-dock-inset, 8px) - var(--dsh-composer-dock-inset, 8px))\n );\n overflow-y: auto; max-height: 40vh;\n}\n@media (prefers-color-scheme: dark) {\n [data-dsh-cdp-picks-card] { color: #f2f2f7; background: #1c1c1e; border-color: rgba(255, 255, 255, 0.18); }\n}\n[data-dsh-cdp-picks-card] .dsh-cdp-picks-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }\n[data-dsh-cdp-picks-card] .dsh-cdp-picks-sub { font-size: 11px; color: rgba(60, 60, 67, 0.62); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }\n[data-dsh-cdp-picks-card] .dsh-cdp-picks-chip { display: flex; align-items: baseline; gap: 6px; padding: 3px 8px; background: rgba(120, 120, 128, 0.12); border: 1px solid rgba(0, 0, 0, 0.1); border-radius: 8px; min-width: 0; }\n[data-dsh-cdp-picks-card] .dsh-cdp-picks-num { font-weight: 700; flex: none; color: rgba(60, 60, 67, 0.62); }\n[data-dsh-cdp-picks-card] .dsh-cdp-picks-tag { font-weight: 600; flex: none; }\n[data-dsh-cdp-picks-card] .dsh-cdp-picks-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }\n[data-dsh-cdp-picks-card] .dsh-cdp-picks-close { margin-left: auto; flex: none; font: inherit; font-size: 12px; cursor: pointer; border: none; background: none; color: rgba(60, 60, 67, 0.62); padding: 0 2px; border-radius: 6px; }\n[data-dsh-cdp-picks-card] .dsh-cdp-picks-close:hover { background: rgba(120, 120, 128, 0.18); }\n@media (prefers-color-scheme: dark) {\n [data-dsh-cdp-picks-card] .dsh-cdp-picks-sub { color: rgba(235, 235, 245, 0.62); }\n [data-dsh-cdp-picks-card] .dsh-cdp-picks-chip { background: rgba(120, 120, 128, 0.24); border-color: rgba(255, 255, 255, 0.12); }\n [data-dsh-cdp-picks-card] .dsh-cdp-picks-num { color: rgba(235, 235, 245, 0.62); }\n [data-dsh-cdp-picks-card] .dsh-cdp-picks-close { color: rgba(235, 235, 245, 0.62); }\n [data-dsh-cdp-picks-card] .dsh-cdp-picks-close:hover { background: rgba(120, 120, 128, 0.3); }\n}";
|
|
3112
|
+
document.head.appendChild(style);
|
|
3113
|
+
}
|
|
3106
3114
|
function CdpPicksDockCard(props) {
|
|
3107
3115
|
var input = props.input;
|
|
3108
3116
|
var h = React.createElement;
|
|
@@ -3166,68 +3174,6 @@ function CdpPicksDockCard(props) {
|
|
|
3166
3174
|
next = next.replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
|
|
3167
3175
|
input.setDraft(next);
|
|
3168
3176
|
}
|
|
3169
|
-
var cardStyle = {
|
|
3170
|
-
display: "grid",
|
|
3171
|
-
gap: "4px",
|
|
3172
|
-
padding: "8px 10px",
|
|
3173
|
-
font: "inherit",
|
|
3174
|
-
fontSize: "12px",
|
|
3175
|
-
color: "var(--dsw-alias-label-primary, inherit)",
|
|
3176
|
-
background: "var(--dsw-alias-bg-surface, rgba(127,127,127,.14))",
|
|
3177
|
-
border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.35))",
|
|
3178
|
-
borderRadius: "12px",
|
|
3179
|
-
boxSizing: "border-box"
|
|
3180
|
-
};
|
|
3181
|
-
var headStyle = {
|
|
3182
|
-
display: "flex",
|
|
3183
|
-
alignItems: "center",
|
|
3184
|
-
gap: "6px",
|
|
3185
|
-
flexWrap: "wrap"
|
|
3186
|
-
};
|
|
3187
|
-
var subStyle = {
|
|
3188
|
-
fontSize: "11px",
|
|
3189
|
-
color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))",
|
|
3190
|
-
overflow: "hidden",
|
|
3191
|
-
textOverflow: "ellipsis",
|
|
3192
|
-
whiteSpace: "nowrap",
|
|
3193
|
-
minWidth: 0
|
|
3194
|
-
};
|
|
3195
|
-
var chipStyle = {
|
|
3196
|
-
display: "flex",
|
|
3197
|
-
alignItems: "baseline",
|
|
3198
|
-
gap: "6px",
|
|
3199
|
-
padding: "3px 8px",
|
|
3200
|
-
background: "var(--dsw-alias-bg-module-platform, rgba(127,127,127,.1))",
|
|
3201
|
-
border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.22))",
|
|
3202
|
-
borderRadius: "8px",
|
|
3203
|
-
minWidth: 0
|
|
3204
|
-
};
|
|
3205
|
-
var numStyle = {
|
|
3206
|
-
fontWeight: 700,
|
|
3207
|
-
flex: "0 0 auto",
|
|
3208
|
-
color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))"
|
|
3209
|
-
};
|
|
3210
|
-
var tagStyle = {
|
|
3211
|
-
fontWeight: 600,
|
|
3212
|
-
flex: "0 0 auto"
|
|
3213
|
-
};
|
|
3214
|
-
var descStyle = {
|
|
3215
|
-
overflow: "hidden",
|
|
3216
|
-
textOverflow: "ellipsis",
|
|
3217
|
-
whiteSpace: "nowrap",
|
|
3218
|
-
minWidth: 0
|
|
3219
|
-
};
|
|
3220
|
-
var closeStyle = {
|
|
3221
|
-
marginLeft: "auto",
|
|
3222
|
-
flex: "0 0 auto",
|
|
3223
|
-
font: "inherit",
|
|
3224
|
-
fontSize: "12px",
|
|
3225
|
-
cursor: "pointer",
|
|
3226
|
-
border: "none",
|
|
3227
|
-
background: "none",
|
|
3228
|
-
color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))",
|
|
3229
|
-
padding: "0 2px"
|
|
3230
|
-
};
|
|
3231
3177
|
return h("div", { style: {
|
|
3232
3178
|
display: "grid",
|
|
3233
3179
|
gap: "6px"
|
|
@@ -3238,10 +3184,10 @@ function CdpPicksDockCard(props) {
|
|
|
3238
3184
|
var obj = JSON.parse(content);
|
|
3239
3185
|
elements = obj && obj.elements || [];
|
|
3240
3186
|
} catch (e) {}
|
|
3241
|
-
var head = h("div", {
|
|
3187
|
+
var head = h("div", { className: "dsh-cdp-picks-head" }, h("span", { style: { fontWeight: 700 } }, "🌐 " + wt("pickCardTitle")), h("span", { className: "dsh-cdp-picks-sub" }, (r.endpoint || "") + " · " + (r.title || "")), h("span", { className: "dsh-cdp-picks-sub" }, wt("pickCardElements", { n: r.count })), h("button", {
|
|
3242
3188
|
type: "button",
|
|
3243
3189
|
title: wt("pickCardRemove"),
|
|
3244
|
-
|
|
3190
|
+
className: "dsh-cdp-picks-close",
|
|
3245
3191
|
onClick: function() {
|
|
3246
3192
|
removeRef(r.line);
|
|
3247
3193
|
}
|
|
@@ -3249,26 +3195,80 @@ function CdpPicksDockCard(props) {
|
|
|
3249
3195
|
var chips = [];
|
|
3250
3196
|
if (typeof content !== "string") chips.push(h("div", {
|
|
3251
3197
|
key: "loading",
|
|
3252
|
-
|
|
3198
|
+
className: "dsh-cdp-picks-sub"
|
|
3253
3199
|
}, "…"));
|
|
3254
3200
|
for (var i = 0; i < elements.length && i < 6; i++) {
|
|
3255
3201
|
var el = elements[i] || {};
|
|
3256
3202
|
chips.push(h("div", {
|
|
3257
3203
|
key: el.n || i,
|
|
3258
|
-
|
|
3259
|
-
}, h("span", {
|
|
3204
|
+
className: "dsh-cdp-picks-chip"
|
|
3205
|
+
}, h("span", { className: "dsh-cdp-picks-num" }, "#" + (el.n || i + 1)), h("span", { className: "dsh-cdp-picks-tag" }, el.tag || "?"), h("span", { className: "dsh-cdp-picks-desc" }, el.describe || el.name || "")));
|
|
3260
3206
|
}
|
|
3261
3207
|
if (elements.length > 6) chips.push(h("div", {
|
|
3262
3208
|
key: "more",
|
|
3263
|
-
|
|
3209
|
+
className: "dsh-cdp-picks-sub"
|
|
3264
3210
|
}, "… +" + (elements.length - 6)));
|
|
3265
3211
|
return h("div", {
|
|
3266
3212
|
key: r.file,
|
|
3267
|
-
|
|
3213
|
+
"data-dsh-cdp-picks-card": ""
|
|
3268
3214
|
}, head, chips);
|
|
3269
3215
|
}));
|
|
3270
3216
|
}
|
|
3217
|
+
function CdpPicksBadge(props) {
|
|
3218
|
+
var h = React.createElement;
|
|
3219
|
+
var setTick = React.useState(0)[1];
|
|
3220
|
+
React.useEffect(function() {
|
|
3221
|
+
var timer = window.setInterval(function() {
|
|
3222
|
+
setTick(function(n) {
|
|
3223
|
+
return n + 1;
|
|
3224
|
+
});
|
|
3225
|
+
}, 1e3);
|
|
3226
|
+
return function() {
|
|
3227
|
+
window.clearInterval(timer);
|
|
3228
|
+
};
|
|
3229
|
+
}, []);
|
|
3230
|
+
var refs = [];
|
|
3231
|
+
try {
|
|
3232
|
+
if (props && props.sessionId !== void 0 && props.sessionId !== null ? String(props.sessionId) : null) {
|
|
3233
|
+
var draft = typeof props.getDraft === "function" ? String(props.getDraft() || "") : "";
|
|
3234
|
+
var countRefs = (draft.match(/\[(?:🌐 )?CDP-PICKS/g) || []).length;
|
|
3235
|
+
var refRe2 = /\[🌐 CDP-PICKS → ([^\s|]+) \| ([^|]*) \| ([^|]*) \| elements:(\d+)[^\]]*\]/g;
|
|
3236
|
+
var mm;
|
|
3237
|
+
while ((mm = refRe2.exec(draft)) !== null) refs.push({
|
|
3238
|
+
file: mm[1],
|
|
3239
|
+
endpoint: mm[2],
|
|
3240
|
+
title: mm[3],
|
|
3241
|
+
count: Number(mm[4])
|
|
3242
|
+
});
|
|
3243
|
+
}
|
|
3244
|
+
} catch (e) {}
|
|
3245
|
+
try {
|
|
3246
|
+
window.__dshBrowserCdpDeco = Object.assign({}, window.__dshBrowserCdpDeco, {
|
|
3247
|
+
badgeRefs: refs.length,
|
|
3248
|
+
blockMarkers: countRefs
|
|
3249
|
+
});
|
|
3250
|
+
} catch (e) {}
|
|
3251
|
+
if (refs.length === 0) return null;
|
|
3252
|
+
return h("div", { className: "dsh-cdp-picks-badges" }, refs.map(function(r, i) {
|
|
3253
|
+
return h("span", {
|
|
3254
|
+
key: r.file,
|
|
3255
|
+
className: "dsh-cdp-picks-badge",
|
|
3256
|
+
title: "🌐 " + (r.title || "") + " · " + (r.endpoint || "") + " · elements:" + r.count
|
|
3257
|
+
}, "🌐" + (refs.length > 1 ? " ×" + (i + 1) : ""));
|
|
3258
|
+
}));
|
|
3259
|
+
}
|
|
3260
|
+
function mountPicksBadge(ctx) {
|
|
3261
|
+
ctx.slots.inject("conversation.input.overlay", function() {
|
|
3262
|
+
return ctx.slots.register({
|
|
3263
|
+
name: "conversation.input.overlay",
|
|
3264
|
+
id: "dsh-browser-cdp.picks-badge",
|
|
3265
|
+
order: 110,
|
|
3266
|
+
label: "dsh-browser-cdp picks badge"
|
|
3267
|
+
}, CdpPicksBadge);
|
|
3268
|
+
}, "dsh-browser-cdp: picks badge");
|
|
3269
|
+
}
|
|
3271
3270
|
function mountPicksDockCard(ctx) {
|
|
3271
|
+
injectPickCardStyles();
|
|
3272
3272
|
try {
|
|
3273
3273
|
window.__dshBrowserCdpDeco = Object.assign({}, window.__dshBrowserCdpDeco, { stage: "registered" });
|
|
3274
3274
|
} catch (e) {}
|
|
@@ -3286,7 +3286,12 @@ function mountPicksDockCard(ctx) {
|
|
|
3286
3286
|
} catch (e) {
|
|
3287
3287
|
input = null;
|
|
3288
3288
|
}
|
|
3289
|
-
return {
|
|
3289
|
+
return {
|
|
3290
|
+
input,
|
|
3291
|
+
getDraft: function() {
|
|
3292
|
+
return readDraftText(input);
|
|
3293
|
+
}
|
|
3294
|
+
};
|
|
3290
3295
|
}
|
|
3291
3296
|
}, CdpPicksDockCard);
|
|
3292
3297
|
}, "dsh-browser-cdp: picks dock card");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-browser-cdp",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.15",
|
|
4
4
|
"description": "dsh-browser-cdp: DSH browser plugin — attach to a running Chrome/Edge over CDP (no bundled browser needed); structured browser-automation tools (30+ bcdp_*) that drive the vendored ego runtime through ctx.subprocess, plus a realtime watch panel (live SSE screencast + direct mouse interaction + download capture + human-verification notice). Web shell: floating watch panel without dsh-better-sidebar, sidebar tab with it. Headless/TUI hosts: tools-only. [DSH 0.2.0-rc.1+ line: declarative settings via Config .volatile() fields; for DSH 0.1.2-rc.1 ~ 0.1.7 use the 0.17.x line]",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|