dsh-browser-cdp 0.18.3 โ†’ 0.18.5

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.18.3",
5
+ "version": "0.18.5",
6
6
  "manifestVersion": "0.15",
7
7
  "facets": {
8
8
  "host": {
package/lib/client.js CHANGED
@@ -1848,6 +1848,7 @@ function FamLinks(props) {
1848
1848
  function apply(ctx) {
1849
1849
  mountFamilySettingsCard(ctx);
1850
1850
  mountPluginsPageCard(ctx);
1851
+ mountComposerDecoration(ctx);
1851
1852
  var betterSidebarService;
1852
1853
  try {
1853
1854
  betterSidebarService = typeof ctx.get === "function" ? ctx.get("betterSidebar") : void 0;
@@ -3094,6 +3095,189 @@ var TAB_CSS = `
3094
3095
  * {"cdpEndpoint":..., "targetId":..., "pageUrl":..., "elements":[{n,backendNodeId,tag,id,name,focusable,describe}]}
3095
3096
  * [/CDP-PICKS]
3096
3097
  */
3098
+ function mountComposerDecoration(ctx) {
3099
+ var cards = [];
3100
+ var lastSig = "";
3101
+ function hide() {
3102
+ for (var i = 0; i < cards.length; i++) {
3103
+ var el = cards[i];
3104
+ el && el.parentNode && el.parentNode.removeChild(el);
3105
+ }
3106
+ cards = [];
3107
+ }
3108
+ function ensureAnchor() {
3109
+ var input = document.querySelector("[data-composer-input]");
3110
+ if (!input || !input.parentNode) return null;
3111
+ return input.parentNode;
3112
+ }
3113
+ function cardStyle() {
3114
+ return {
3115
+ display: "grid",
3116
+ gap: "4px",
3117
+ margin: "0 0 6px",
3118
+ padding: "8px 10px",
3119
+ font: "inherit",
3120
+ fontSize: "12px",
3121
+ color: "var(--dsw-alias-label-primary, inherit)",
3122
+ background: "var(--dsw-alias-bg-module-platform, rgba(127,127,127,.08))",
3123
+ border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.3))",
3124
+ borderRadius: "12px",
3125
+ boxSizing: "border-box",
3126
+ width: "100%"
3127
+ };
3128
+ }
3129
+ function chipStyle() {
3130
+ return {
3131
+ display: "flex",
3132
+ alignItems: "baseline",
3133
+ gap: "6px",
3134
+ padding: "3px 8px",
3135
+ background: "var(--dsw-alias-bg-module-platform, rgba(127,127,127,.1))",
3136
+ border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.22))",
3137
+ borderRadius: "8px",
3138
+ minWidth: 0
3139
+ };
3140
+ }
3141
+ function render(pageTitle, endpoint, pageUrl, elements) {
3142
+ var anchor = ensureAnchor();
3143
+ if (!anchor) {
3144
+ hide();
3145
+ return;
3146
+ }
3147
+ hide();
3148
+ var h = React.createElement;
3149
+ var head = h("div", { style: {
3150
+ display: "flex",
3151
+ alignItems: "center",
3152
+ gap: "6px",
3153
+ flexWrap: "wrap"
3154
+ } }, h("span", { style: badgeLike() }, "๐ŸŒ"), h("span", { style: { fontWeight: 600 } }, wt("pickCardTitle")), h("span", { style: {
3155
+ color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))",
3156
+ overflow: "hidden",
3157
+ textOverflow: "ellipsis",
3158
+ whiteSpace: "nowrap",
3159
+ minWidth: 0
3160
+ } }, (endpoint || "") + " ยท " + (pageTitle || pageUrl || "")), h("span", { style: {
3161
+ color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))",
3162
+ flex: "0 0 auto"
3163
+ } }, wt("pickCardElements", { n: elements.length })));
3164
+ var chips = elements.slice(0, 6).map(function(el) {
3165
+ return h("div", {
3166
+ key: el.n,
3167
+ style: chipStyle()
3168
+ }, h("span", { style: {
3169
+ fontWeight: 700,
3170
+ flex: "0 0 auto",
3171
+ color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))"
3172
+ } }, "#" + el.n), h("span", { style: {
3173
+ fontWeight: 600,
3174
+ flex: "0 0 auto"
3175
+ } }, el.tag || "?"), h("span", { style: {
3176
+ overflow: "hidden",
3177
+ textOverflow: "ellipsis",
3178
+ whiteSpace: "nowrap",
3179
+ minWidth: 0
3180
+ } }, el.describe || el.name || ""));
3181
+ });
3182
+ if (elements.length > 6) chips.push(h("div", { style: {
3183
+ fontSize: "11px",
3184
+ color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.7))"
3185
+ } }, "โ€ฆ +" + (elements.length - 6)));
3186
+ var card = document.createElement("div");
3187
+ card.setAttribute("data-dsh-cdp-picks-card", "");
3188
+ var host = null;
3189
+ try {
3190
+ host = renderToDom(h("div", { style: cardStyle() }, head, chips));
3191
+ } catch (e) {
3192
+ host = null;
3193
+ }
3194
+ if (!host) return;
3195
+ card.appendChild(host);
3196
+ anchor.insertBefore(card, anchor.firstChild);
3197
+ cards.push(card);
3198
+ }
3199
+ function badgeLike() {
3200
+ return {
3201
+ fontSize: "12px",
3202
+ lineHeight: "16px"
3203
+ };
3204
+ }
3205
+ function renderToDom(vdom) {
3206
+ if (vdom === null || vdom === void 0 || vdom === false) return document.createTextNode("");
3207
+ if (typeof vdom === "string" || typeof vdom === "number") return document.createTextNode(String(vdom));
3208
+ if (Array.isArray(vdom)) {
3209
+ var frag = document.createDocumentFragment();
3210
+ for (var i = 0; i < vdom.length; i++) frag.appendChild(renderToDom(vdom[i]));
3211
+ return frag;
3212
+ }
3213
+ var el = document.createElement(vdom.type || "div");
3214
+ var props = vdom.props || {};
3215
+ if (props.style) for (var k in props.style) el.style[k] = props.style[k];
3216
+ if (props.key) el.setAttribute("data-key", String(props.key));
3217
+ var children = props.children;
3218
+ el.appendChild(renderToDom(children === void 0 ? null : children));
3219
+ return el;
3220
+ }
3221
+ function tick() {
3222
+ try {
3223
+ var sid = currentSessionId(ctx.sessions.list.getSnapshot());
3224
+ if (!sid) {
3225
+ if (lastSig !== "") {
3226
+ lastSig = "";
3227
+ hide();
3228
+ }
3229
+ return;
3230
+ }
3231
+ var conversation = ctx.get("conversation");
3232
+ if (!conversation || !conversation.input) return;
3233
+ var actx = ctx.sessions.scope(sid);
3234
+ if (!actx) return;
3235
+ var input = conversation.input.for(actx);
3236
+ var snap = input && input.state && input.state.getSnapshot ? input.state.getSnapshot() : null;
3237
+ var draft = snap && typeof snap.draft === "string" ? snap.draft : "";
3238
+ if (draft === lastSig) return;
3239
+ lastSig = draft;
3240
+ var re = /\[(?:๐ŸŒ )?CDP-PICKS page="([^"]*)" targetId="([^"]*)" endpoint="([^"]*)"\]\n([\s\S]*?)\n\[\/CDP-PICKS\]/g;
3241
+ var found = [], mm;
3242
+ while ((mm = re.exec(draft)) !== null) {
3243
+ var elements = [];
3244
+ try {
3245
+ var obj = JSON.parse(mm[4]);
3246
+ elements = obj && obj.elements || [];
3247
+ } catch (e) {}
3248
+ found.push({
3249
+ title: mm[1],
3250
+ targetId: mm[2],
3251
+ endpoint: mm[3],
3252
+ elements
3253
+ });
3254
+ }
3255
+ if (found.length === 0) {
3256
+ hide();
3257
+ return;
3258
+ }
3259
+ for (var i = 0; i < found.length; i++) render(found[i].title, found[i].endpoint, found[i].title, found[i].elements);
3260
+ } catch (e) {}
3261
+ }
3262
+ var timer = window.setInterval(tick, 1e3);
3263
+ tick();
3264
+ return function() {
3265
+ window.clearInterval(timer);
3266
+ hide();
3267
+ };
3268
+ }
3269
+ function currentSessionId(list) {
3270
+ if (!list || typeof list !== "object") return "";
3271
+ if (typeof list.current === "string") return list.current;
3272
+ var byId = list.byId;
3273
+ if (!byId || typeof byId !== "object") return "";
3274
+ var ids = Object.keys(byId);
3275
+ for (var i = 0; i < ids.length; i++) {
3276
+ var row = byId[ids[i]];
3277
+ if (row && row.retainedBy && (row.retainedBy.mainView ?? 0) > 0) return ids[i];
3278
+ }
3279
+ return "";
3280
+ }
3097
3281
  function deliverPickToConversation(ctx, element, action) {
3098
3282
  try {
3099
3283
  var describe = element && typeof element.describe === "string" ? element.describe : "";
@@ -3105,7 +3289,7 @@ function deliverPickToConversation(ctx, element, action) {
3105
3289
  ok: false,
3106
3290
  code: "bad-action"
3107
3291
  };
3108
- var sessionId = ctx.sessions.list.getSnapshot().current;
3292
+ var sessionId = currentSessionId(ctx.sessions.list.getSnapshot());
3109
3293
  if (!sessionId) return {
3110
3294
  ok: false,
3111
3295
  code: "no-active-session"
@@ -3141,7 +3325,7 @@ function deliverPickToConversation(ctx, element, action) {
3141
3325
  focusable: !!element.keyboardFocusable,
3142
3326
  describe
3143
3327
  };
3144
- var re = /\[CDP-PICKS[^\]]*\]\n([\s\S]*?)\n\[\/CDP-PICKS\]/g, found = null, mm;
3328
+ var re = /\[(?:๐ŸŒ )?CDP-PICKS[^\]]*\]\n([\s\S]*?)\n\[\/CDP-PICKS\]/g, found = null, mm;
3145
3329
  while ((mm = re.exec(draft)) !== null) try {
3146
3330
  var obj = JSON.parse(mm[1]);
3147
3331
  if (obj && obj.targetId === src.targetId && obj.cdpEndpoint === src.endpoint) {
@@ -3168,7 +3352,7 @@ function deliverPickToConversation(ctx, element, action) {
3168
3352
  draft = draft.slice(0, found.index) + draft.slice(found.index + found[0].length);
3169
3353
  } catch (e) {}
3170
3354
  if (!page.elements) page.elements = elements;
3171
- 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]";
3355
+ 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]";
3172
3356
  draft = draft ? draft + (draft.charAt(draft.length - 1) === "\n" ? "" : "\n") + block : block;
3173
3357
  input.setDraft(draft);
3174
3358
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-browser-cdp",
3
- "version": "0.18.3",
3
+ "version": "0.18.5",
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",