dsh-browser-cdp 0.17.7 โ†’ 0.17.9

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.7",
5
+ "version": "0.17.9",
6
6
  "manifestVersion": "0.15",
7
7
  "facets": {
8
8
  "host": {
package/lib/client.js CHANGED
@@ -3035,6 +3035,7 @@ function apply(ctx) {
3035
3035
  }
3036
3036
  mountFamilySettingsCard(ctx);
3037
3037
  mountPluginsPageCard(ctx);
3038
+ mountComposerDecoration(ctx);
3038
3039
  var betterSidebarService;
3039
3040
  try {
3040
3041
  betterSidebarService = typeof ctx.get === "function" ? ctx.get("betterSidebar") : void 0;
@@ -4281,6 +4282,189 @@ var TAB_CSS = `
4281
4282
  * {"cdpEndpoint":..., "targetId":..., "pageUrl":..., "elements":[{n,backendNodeId,tag,id,name,focusable,describe}]}
4282
4283
  * [/CDP-PICKS]
4283
4284
  */
4285
+ function mountComposerDecoration(ctx) {
4286
+ var cards = [];
4287
+ var lastSig = "";
4288
+ function hide() {
4289
+ for (var i = 0; i < cards.length; i++) {
4290
+ var el = cards[i];
4291
+ el && el.parentNode && el.parentNode.removeChild(el);
4292
+ }
4293
+ cards = [];
4294
+ }
4295
+ function ensureAnchor() {
4296
+ var input = document.querySelector("[data-composer-input]");
4297
+ if (!input || !input.parentNode) return null;
4298
+ return input.parentNode;
4299
+ }
4300
+ function cardStyle() {
4301
+ return {
4302
+ display: "grid",
4303
+ gap: "4px",
4304
+ margin: "0 0 6px",
4305
+ padding: "8px 10px",
4306
+ font: "inherit",
4307
+ fontSize: "12px",
4308
+ color: "var(--dsw-alias-label-primary, inherit)",
4309
+ background: "var(--dsw-alias-bg-module-platform, rgba(127,127,127,.08))",
4310
+ border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.3))",
4311
+ borderRadius: "12px",
4312
+ boxSizing: "border-box",
4313
+ width: "100%"
4314
+ };
4315
+ }
4316
+ function chipStyle() {
4317
+ return {
4318
+ display: "flex",
4319
+ alignItems: "baseline",
4320
+ gap: "6px",
4321
+ padding: "3px 8px",
4322
+ background: "var(--dsw-alias-bg-module-platform, rgba(127,127,127,.1))",
4323
+ border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.22))",
4324
+ borderRadius: "8px",
4325
+ minWidth: 0
4326
+ };
4327
+ }
4328
+ function render(pageTitle, endpoint, pageUrl, elements) {
4329
+ var anchor = ensureAnchor();
4330
+ if (!anchor) {
4331
+ hide();
4332
+ return;
4333
+ }
4334
+ hide();
4335
+ var h = React.createElement;
4336
+ var head = h("div", { style: {
4337
+ display: "flex",
4338
+ alignItems: "center",
4339
+ gap: "6px",
4340
+ flexWrap: "wrap"
4341
+ } }, h("span", { style: badgeLike() }, "๐ŸŒ"), h("span", { style: { fontWeight: 600 } }, wt("pickCardTitle")), h("span", { style: {
4342
+ color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))",
4343
+ overflow: "hidden",
4344
+ textOverflow: "ellipsis",
4345
+ whiteSpace: "nowrap",
4346
+ minWidth: 0
4347
+ } }, (endpoint || "") + " ยท " + (pageTitle || pageUrl || "")), h("span", { style: {
4348
+ color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))",
4349
+ flex: "0 0 auto"
4350
+ } }, wt("pickCardElements", { n: elements.length })));
4351
+ var chips = elements.slice(0, 6).map(function(el) {
4352
+ return h("div", {
4353
+ key: el.n,
4354
+ style: chipStyle()
4355
+ }, h("span", { style: {
4356
+ fontWeight: 700,
4357
+ flex: "0 0 auto",
4358
+ color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))"
4359
+ } }, "#" + el.n), h("span", { style: {
4360
+ fontWeight: 600,
4361
+ flex: "0 0 auto"
4362
+ } }, el.tag || "?"), h("span", { style: {
4363
+ overflow: "hidden",
4364
+ textOverflow: "ellipsis",
4365
+ whiteSpace: "nowrap",
4366
+ minWidth: 0
4367
+ } }, el.describe || el.name || ""));
4368
+ });
4369
+ if (elements.length > 6) chips.push(h("div", { style: {
4370
+ fontSize: "11px",
4371
+ color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.7))"
4372
+ } }, "โ€ฆ +" + (elements.length - 6)));
4373
+ var card = document.createElement("div");
4374
+ card.setAttribute("data-dsh-cdp-picks-card", "");
4375
+ var host = null;
4376
+ try {
4377
+ host = renderToDom(h("div", { style: cardStyle() }, head, chips));
4378
+ } catch (e) {
4379
+ host = null;
4380
+ }
4381
+ if (!host) return;
4382
+ card.appendChild(host);
4383
+ anchor.insertBefore(card, anchor.firstChild);
4384
+ cards.push(card);
4385
+ }
4386
+ function badgeLike() {
4387
+ return {
4388
+ fontSize: "12px",
4389
+ lineHeight: "16px"
4390
+ };
4391
+ }
4392
+ function renderToDom(vdom) {
4393
+ if (vdom === null || vdom === void 0 || vdom === false) return document.createTextNode("");
4394
+ if (typeof vdom === "string" || typeof vdom === "number") return document.createTextNode(String(vdom));
4395
+ if (Array.isArray(vdom)) {
4396
+ var frag = document.createDocumentFragment();
4397
+ for (var i = 0; i < vdom.length; i++) frag.appendChild(renderToDom(vdom[i]));
4398
+ return frag;
4399
+ }
4400
+ var el = document.createElement(vdom.type || "div");
4401
+ var props = vdom.props || {};
4402
+ if (props.style) for (var k in props.style) el.style[k] = props.style[k];
4403
+ if (props.key) el.setAttribute("data-key", String(props.key));
4404
+ var children = props.children;
4405
+ el.appendChild(renderToDom(children === void 0 ? null : children));
4406
+ return el;
4407
+ }
4408
+ function tick() {
4409
+ try {
4410
+ var sid = currentSessionId(ctx.sessions.list.getSnapshot());
4411
+ if (!sid) {
4412
+ if (lastSig !== "") {
4413
+ lastSig = "";
4414
+ hide();
4415
+ }
4416
+ return;
4417
+ }
4418
+ var conversation = ctx.get("conversation");
4419
+ if (!conversation || !conversation.input) return;
4420
+ var actx = ctx.sessions.scope(sid);
4421
+ if (!actx) return;
4422
+ var input = conversation.input.for(actx);
4423
+ var snap = input && input.state && input.state.getSnapshot ? input.state.getSnapshot() : null;
4424
+ var draft = snap && typeof snap.draft === "string" ? snap.draft : "";
4425
+ if (draft === lastSig) return;
4426
+ lastSig = draft;
4427
+ var re = /\[(?:๐ŸŒ )?CDP-PICKS page="([^"]*)" targetId="([^"]*)" endpoint="([^"]*)"\]\n([\s\S]*?)\n\[\/CDP-PICKS\]/g;
4428
+ var found = [], mm;
4429
+ while ((mm = re.exec(draft)) !== null) {
4430
+ var elements = [];
4431
+ try {
4432
+ var obj = JSON.parse(mm[4]);
4433
+ elements = obj && obj.elements || [];
4434
+ } catch (e) {}
4435
+ found.push({
4436
+ title: mm[1],
4437
+ targetId: mm[2],
4438
+ endpoint: mm[3],
4439
+ elements
4440
+ });
4441
+ }
4442
+ if (found.length === 0) {
4443
+ hide();
4444
+ return;
4445
+ }
4446
+ for (var i = 0; i < found.length; i++) render(found[i].title, found[i].endpoint, found[i].title, found[i].elements);
4447
+ } catch (e) {}
4448
+ }
4449
+ var timer = window.setInterval(tick, 1e3);
4450
+ tick();
4451
+ return function() {
4452
+ window.clearInterval(timer);
4453
+ hide();
4454
+ };
4455
+ }
4456
+ function currentSessionId(list) {
4457
+ if (!list || typeof list !== "object") return "";
4458
+ if (typeof list.current === "string") return list.current;
4459
+ var byId = list.byId;
4460
+ if (!byId || typeof byId !== "object") return "";
4461
+ var ids = Object.keys(byId);
4462
+ for (var i = 0; i < ids.length; i++) {
4463
+ var row = byId[ids[i]];
4464
+ if (row && row.retainedBy && (row.retainedBy.mainView ?? 0) > 0) return ids[i];
4465
+ }
4466
+ return "";
4467
+ }
4284
4468
  function deliverPickToConversation(ctx, element, action) {
4285
4469
  try {
4286
4470
  var describe = element && typeof element.describe === "string" ? element.describe : "";
@@ -4292,7 +4476,7 @@ function deliverPickToConversation(ctx, element, action) {
4292
4476
  ok: false,
4293
4477
  code: "bad-action"
4294
4478
  };
4295
- var sessionId = ctx.sessions.list.getSnapshot().current;
4479
+ var sessionId = currentSessionId(ctx.sessions.list.getSnapshot());
4296
4480
  if (!sessionId) return {
4297
4481
  ok: false,
4298
4482
  code: "no-active-session"
@@ -4328,7 +4512,7 @@ function deliverPickToConversation(ctx, element, action) {
4328
4512
  focusable: !!element.keyboardFocusable,
4329
4513
  describe
4330
4514
  };
4331
- var re = /\[CDP-PICKS[^\]]*\]\n([\s\S]*?)\n\[\/CDP-PICKS\]/g, found = null, mm;
4515
+ var re = /\[(?:๐ŸŒ )?CDP-PICKS[^\]]*\]\n([\s\S]*?)\n\[\/CDP-PICKS\]/g, found = null, mm;
4332
4516
  while ((mm = re.exec(draft)) !== null) try {
4333
4517
  var obj = JSON.parse(mm[1]);
4334
4518
  if (obj && obj.targetId === src.targetId && obj.cdpEndpoint === src.endpoint) {
@@ -4355,7 +4539,7 @@ function deliverPickToConversation(ctx, element, action) {
4355
4539
  draft = draft.slice(0, found.index) + draft.slice(found.index + found[0].length);
4356
4540
  } catch (e) {}
4357
4541
  if (!page.elements) page.elements = elements;
4358
- var block = "[CDP-PICKS page=\"" + String(src.pageTitle || src.pageUrl || "").replace(/"/g, "'") + "\" targetId=\"" + src.targetId + "\" endpoint=\"" + src.endpoint + "\"]\n" + JSON.stringify(page, null, 2) + "\n[/CDP-PICKS]";
4542
+ var block = "[๐ŸŒ CDP-PICKS page=\"" + String(src.pageTitle || src.pageUrl || "").replace(/"/g, "'") + "\" targetId=\"" + src.targetId + "\" endpoint=\"" + src.endpoint + "\"]\n" + JSON.stringify(page, null, 2) + "\n[/CDP-PICKS]";
4359
4543
  draft = draft ? draft + (draft.charAt(draft.length - 1) === "\n" ? "" : "\n") + block : block;
4360
4544
  input.setDraft(draft);
4361
4545
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-browser-cdp",
3
- "version": "0.17.7",
3
+ "version": "0.17.9",
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",