dsh-browser-cdp 0.17.16 → 0.17.18

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 CHANGED
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://dsh.community/schemas/dsh-plugin-0.15.json",
3
3
  "id": "dsh-browser-cdp",
4
4
  "name": "dsh-browser-cdp",
5
- "version": "0.17.16",
5
+ "version": "0.17.18",
6
6
  "manifestVersion": "0.15",
7
7
  "facets": {
8
8
  "host": {
package/lib/client.js CHANGED
@@ -3065,6 +3065,7 @@ function apply(ctx) {
3065
3065
  mountFamilySettingsCard(ctx);
3066
3066
  mountPluginsPageCard(ctx);
3067
3067
  mountPicksDockCard(ctx);
3068
+ mountPicksBadge(ctx);
3068
3069
  var betterSidebarService;
3069
3070
  try {
3070
3071
  betterSidebarService = typeof ctx.get === "function" ? ctx.get("betterSidebar") : void 0;
@@ -4311,6 +4312,13 @@ var TAB_CSS = `
4311
4312
  * {"cdpEndpoint":..., "targetId":..., "pageUrl":..., "elements":[{n,backendNodeId,tag,id,name,focusable,describe}]}
4312
4313
  * [/CDP-PICKS]
4313
4314
  */
4315
+ function injectPickCardStyles() {
4316
+ if (document.getElementById("dsh-cdp-picks-styles") !== null) return;
4317
+ var style = document.createElement("style");
4318
+ style.id = "dsh-cdp-picks-styles";
4319
+ 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}";
4320
+ document.head.appendChild(style);
4321
+ }
4314
4322
  function CdpPicksDockCard(props) {
4315
4323
  var input = props.input;
4316
4324
  var h = React.createElement;
@@ -4374,68 +4382,6 @@ function CdpPicksDockCard(props) {
4374
4382
  next = next.replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
4375
4383
  input.setDraft(next);
4376
4384
  }
4377
- var cardStyle = {
4378
- display: "grid",
4379
- gap: "4px",
4380
- padding: "8px 10px",
4381
- font: "inherit",
4382
- fontSize: "12px",
4383
- color: "var(--dsw-alias-label-primary, inherit)",
4384
- background: "var(--dsw-alias-bg-surface, rgba(127,127,127,.14))",
4385
- border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.35))",
4386
- borderRadius: "12px",
4387
- boxSizing: "border-box"
4388
- };
4389
- var headStyle = {
4390
- display: "flex",
4391
- alignItems: "center",
4392
- gap: "6px",
4393
- flexWrap: "wrap"
4394
- };
4395
- var subStyle = {
4396
- fontSize: "11px",
4397
- color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))",
4398
- overflow: "hidden",
4399
- textOverflow: "ellipsis",
4400
- whiteSpace: "nowrap",
4401
- minWidth: 0
4402
- };
4403
- var chipStyle = {
4404
- display: "flex",
4405
- alignItems: "baseline",
4406
- gap: "6px",
4407
- padding: "3px 8px",
4408
- background: "var(--dsw-alias-bg-module-platform, rgba(127,127,127,.1))",
4409
- border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.22))",
4410
- borderRadius: "8px",
4411
- minWidth: 0
4412
- };
4413
- var numStyle = {
4414
- fontWeight: 700,
4415
- flex: "0 0 auto",
4416
- color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))"
4417
- };
4418
- var tagStyle = {
4419
- fontWeight: 600,
4420
- flex: "0 0 auto"
4421
- };
4422
- var descStyle = {
4423
- overflow: "hidden",
4424
- textOverflow: "ellipsis",
4425
- whiteSpace: "nowrap",
4426
- minWidth: 0
4427
- };
4428
- var closeStyle = {
4429
- marginLeft: "auto",
4430
- flex: "0 0 auto",
4431
- font: "inherit",
4432
- fontSize: "12px",
4433
- cursor: "pointer",
4434
- border: "none",
4435
- background: "none",
4436
- color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))",
4437
- padding: "0 2px"
4438
- };
4439
4385
  return h("div", { style: {
4440
4386
  display: "grid",
4441
4387
  gap: "6px"
@@ -4446,10 +4392,10 @@ function CdpPicksDockCard(props) {
4446
4392
  var obj = JSON.parse(content);
4447
4393
  elements = obj && obj.elements || [];
4448
4394
  } catch (e) {}
4449
- var head = h("div", { style: headStyle }, h("span", { style: { fontWeight: 700 } }, "🌐 " + wt("pickCardTitle")), h("span", { style: subStyle }, (r.endpoint || "") + " · " + (r.title || "")), h("span", { style: subStyle }, wt("pickCardElements", { n: r.count })), h("button", {
4395
+ 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", {
4450
4396
  type: "button",
4451
4397
  title: wt("pickCardRemove"),
4452
- style: closeStyle,
4398
+ className: "dsh-cdp-picks-close",
4453
4399
  onClick: function() {
4454
4400
  removeRef(r.line);
4455
4401
  }
@@ -4457,26 +4403,76 @@ function CdpPicksDockCard(props) {
4457
4403
  var chips = [];
4458
4404
  if (typeof content !== "string") chips.push(h("div", {
4459
4405
  key: "loading",
4460
- style: subStyle
4406
+ className: "dsh-cdp-picks-sub"
4461
4407
  }, "…"));
4462
4408
  for (var i = 0; i < elements.length && i < 6; i++) {
4463
4409
  var el = elements[i] || {};
4464
4410
  chips.push(h("div", {
4465
4411
  key: el.n || i,
4466
- style: chipStyle
4467
- }, h("span", { style: numStyle }, "#" + (el.n || i + 1)), h("span", { style: tagStyle }, el.tag || "?"), h("span", { style: descStyle }, el.describe || el.name || "")));
4412
+ className: "dsh-cdp-picks-chip"
4413
+ }, 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 || "")));
4468
4414
  }
4469
4415
  if (elements.length > 6) chips.push(h("div", {
4470
4416
  key: "more",
4471
- style: subStyle
4417
+ className: "dsh-cdp-picks-sub"
4472
4418
  }, "… +" + (elements.length - 6)));
4473
4419
  return h("div", {
4474
4420
  key: r.file,
4475
- style: cardStyle
4421
+ "data-dsh-cdp-picks-card": ""
4476
4422
  }, head, chips);
4477
4423
  }));
4478
4424
  }
4425
+ function CdpPicksBadge(props) {
4426
+ var h = React.createElement;
4427
+ var setTick = React.useState(0)[1];
4428
+ React.useEffect(function() {
4429
+ var timer = window.setInterval(function() {
4430
+ setTick(function(n) {
4431
+ return n + 1;
4432
+ });
4433
+ }, 1e3);
4434
+ return function() {
4435
+ window.clearInterval(timer);
4436
+ };
4437
+ }, []);
4438
+ var refs = [];
4439
+ try {
4440
+ if (props && props.sessionId !== void 0 && props.sessionId !== null ? String(props.sessionId) : null) {
4441
+ var draft = typeof props.getDraft === "function" ? String(props.getDraft() || "") : "";
4442
+ var refRe = /\[🌐 CDP-PICKS → ([^\s|]+) \| ([^|]*) \| ([^|]*) \| elements:(\d+)[^\]]*\]/g;
4443
+ var mm;
4444
+ while ((mm = refRe.exec(draft)) !== null) refs.push({
4445
+ file: mm[1],
4446
+ endpoint: mm[2],
4447
+ title: mm[3],
4448
+ count: Number(mm[4])
4449
+ });
4450
+ }
4451
+ } catch (e) {}
4452
+ try {
4453
+ window.__dshBrowserCdpDeco = Object.assign({}, window.__dshBrowserCdpDeco, { badgeRefs: refs.length });
4454
+ } catch (e) {}
4455
+ if (refs.length === 0) return null;
4456
+ return h("div", { className: "dsh-cdp-picks-badges" }, refs.map(function(r, i) {
4457
+ return h("span", {
4458
+ key: r.file,
4459
+ className: "dsh-cdp-picks-badge",
4460
+ title: "🌐 " + (r.title || "") + " · " + (r.endpoint || "") + " · elements:" + r.count
4461
+ }, "🌐" + (refs.length > 1 ? " " + (i + 1) : ""));
4462
+ }));
4463
+ }
4464
+ function mountPicksBadge(ctx) {
4465
+ ctx.slots.inject("conversation.input.overlay", function() {
4466
+ return ctx.slots.register({
4467
+ name: "conversation.input.overlay",
4468
+ id: "dsh-browser-cdp.picks-badge",
4469
+ order: 110,
4470
+ label: "dsh-browser-cdp picks badge"
4471
+ }, CdpPicksBadge);
4472
+ }, "dsh-browser-cdp: picks badge");
4473
+ }
4479
4474
  function mountPicksDockCard(ctx) {
4475
+ injectPickCardStyles();
4480
4476
  try {
4481
4477
  window.__dshBrowserCdpDeco = Object.assign({}, window.__dshBrowserCdpDeco, { stage: "registered" });
4482
4478
  } catch (e) {}
@@ -4494,7 +4490,12 @@ function mountPicksDockCard(ctx) {
4494
4490
  } catch (e) {
4495
4491
  input = null;
4496
4492
  }
4497
- return { input };
4493
+ return {
4494
+ input,
4495
+ getDraft: function() {
4496
+ return readDraftText(input);
4497
+ }
4498
+ };
4498
4499
  }
4499
4500
  }, CdpPicksDockCard);
4500
4501
  }, "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.17.16",
3
+ "version": "0.17.18",
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.1.7+ line: declarative settings via Config .volatile() fields; for DSH 0.1.2-rc.1 ~ 0.1.6 use the 0.16.x line]",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",