@ibealec/create-zed-bridge 1.0.5 → 1.0.7
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/package.json +1 -1
- package/templates/@zed-controller/react-bridge/dist/index.cjs +59 -16
- package/templates/@zed-controller/react-bridge/dist/index.cjs.map +1 -1
- package/templates/@zed-controller/react-bridge/dist/index.js +59 -16
- package/templates/@zed-controller/react-bridge/dist/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -200,7 +200,7 @@ function captureContext(element) {
|
|
|
200
200
|
selectedText: getSelectedText(),
|
|
201
201
|
selectedElement: {
|
|
202
202
|
tagName: element.tagName.toLowerCase(),
|
|
203
|
-
className: element
|
|
203
|
+
className: getClassNameString(element),
|
|
204
204
|
id: element.id || void 0,
|
|
205
205
|
innerText: truncateText(element.innerText, 200)
|
|
206
206
|
},
|
|
@@ -222,12 +222,22 @@ function getSelectedText() {
|
|
|
222
222
|
return void 0;
|
|
223
223
|
}
|
|
224
224
|
function truncateText(text, maxLength) {
|
|
225
|
+
if (!text) return "";
|
|
225
226
|
const cleaned = text.replace(/\s+/g, " ").trim();
|
|
226
227
|
if (cleaned.length <= maxLength) {
|
|
227
228
|
return cleaned;
|
|
228
229
|
}
|
|
229
230
|
return cleaned.slice(0, maxLength) + "...";
|
|
230
231
|
}
|
|
232
|
+
function getClassNameString(element) {
|
|
233
|
+
if (typeof element.className === "string") {
|
|
234
|
+
return element.className;
|
|
235
|
+
}
|
|
236
|
+
if (element.className && typeof element.className.baseVal === "string") {
|
|
237
|
+
return element.className.baseVal;
|
|
238
|
+
}
|
|
239
|
+
return "";
|
|
240
|
+
}
|
|
231
241
|
function getSourceFile(element) {
|
|
232
242
|
let current = element;
|
|
233
243
|
while (current) {
|
|
@@ -330,10 +340,13 @@ function getDomPath(element) {
|
|
|
330
340
|
let selector = current.tagName.toLowerCase();
|
|
331
341
|
if (current.id) {
|
|
332
342
|
selector += `#${current.id}`;
|
|
333
|
-
} else
|
|
334
|
-
const
|
|
335
|
-
if (
|
|
336
|
-
|
|
343
|
+
} else {
|
|
344
|
+
const classNameStr = getClassNameString(current);
|
|
345
|
+
if (classNameStr) {
|
|
346
|
+
const classes = classNameStr.split(/\s+/).filter((c) => c && !c.startsWith("__")).slice(0, 2).join(".");
|
|
347
|
+
if (classes) {
|
|
348
|
+
selector += `.${classes}`;
|
|
349
|
+
}
|
|
337
350
|
}
|
|
338
351
|
}
|
|
339
352
|
path.unshift(selector);
|
|
@@ -463,11 +476,34 @@ async function captureElementScreenshot(element, options = {}) {
|
|
|
463
476
|
useCORS: true,
|
|
464
477
|
allowTaint: true,
|
|
465
478
|
backgroundColor: null,
|
|
466
|
-
logging: false
|
|
479
|
+
logging: false,
|
|
480
|
+
// Ignore elements that might cause issues
|
|
481
|
+
ignoreElements: (el) => {
|
|
482
|
+
return el.tagName === "IFRAME" || el.tagName === "VIDEO";
|
|
483
|
+
},
|
|
484
|
+
onclone: (clonedDoc) => {
|
|
485
|
+
try {
|
|
486
|
+
const styleSheets = clonedDoc.styleSheets;
|
|
487
|
+
const fallbackStyle = clonedDoc.createElement("style");
|
|
488
|
+
fallbackStyle.textContent = `
|
|
489
|
+
* {
|
|
490
|
+
/* Fallback for elements using unsupported color functions */
|
|
491
|
+
--html2canvas-fallback: inherit;
|
|
492
|
+
}
|
|
493
|
+
`;
|
|
494
|
+
clonedDoc.head.appendChild(fallbackStyle);
|
|
495
|
+
} catch {
|
|
496
|
+
}
|
|
497
|
+
}
|
|
467
498
|
});
|
|
468
499
|
return canvas.toDataURL("image/png");
|
|
469
500
|
} catch (error) {
|
|
470
|
-
|
|
501
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
502
|
+
if (errorMessage.includes("unsupported color function") || errorMessage.includes("oklch") || errorMessage.includes("lab(") || errorMessage.includes("lch(")) {
|
|
503
|
+
console.debug("[ClaudeBridge] Screenshot skipped: page uses modern CSS colors not supported by html2canvas");
|
|
504
|
+
return void 0;
|
|
505
|
+
}
|
|
506
|
+
console.warn("[ClaudeBridge] Screenshot capture failed:", errorMessage);
|
|
471
507
|
return void 0;
|
|
472
508
|
}
|
|
473
509
|
}
|
|
@@ -510,10 +546,14 @@ function createHighlightOverlay() {
|
|
|
510
546
|
let labelText = element.tagName.toLowerCase();
|
|
511
547
|
if (element.id) {
|
|
512
548
|
labelText += `#${element.id}`;
|
|
513
|
-
} else
|
|
514
|
-
const
|
|
515
|
-
|
|
516
|
-
|
|
549
|
+
} else {
|
|
550
|
+
const className = element.className;
|
|
551
|
+
const classNameStr = typeof className === "string" ? className : className?.baseVal || "";
|
|
552
|
+
if (classNameStr) {
|
|
553
|
+
const firstClass = classNameStr.split(/\s+/)[0];
|
|
554
|
+
if (firstClass && !firstClass.startsWith("__")) {
|
|
555
|
+
labelText += `.${firstClass}`;
|
|
556
|
+
}
|
|
517
557
|
}
|
|
518
558
|
}
|
|
519
559
|
label.textContent = labelText;
|
|
@@ -1740,7 +1780,7 @@ function TaskStatusToast({
|
|
|
1740
1780
|
document.addEventListener("mousemove", handleMouseMove);
|
|
1741
1781
|
document.addEventListener("mouseup", handleMouseUp);
|
|
1742
1782
|
}, [size]);
|
|
1743
|
-
const killSession = (0, import_react5.useCallback)((sessionId) => {
|
|
1783
|
+
const killSession = (0, import_react5.useCallback)((sessionId, taskPrompt) => {
|
|
1744
1784
|
return new Promise((resolve) => {
|
|
1745
1785
|
const wsUrl = serverUrl.replace(/^http/, "ws").replace(/\/$/, "");
|
|
1746
1786
|
const ws = new WebSocket(`${wsUrl}/ws/bridge?token=${encodeURIComponent(token)}`);
|
|
@@ -1755,7 +1795,10 @@ function TaskStatusToast({
|
|
|
1755
1795
|
ws.onopen = () => {
|
|
1756
1796
|
ws.send(JSON.stringify({
|
|
1757
1797
|
type: "kill_session",
|
|
1758
|
-
sessionId
|
|
1798
|
+
sessionId,
|
|
1799
|
+
// Include task prompt for auto-commit message
|
|
1800
|
+
taskPrompt,
|
|
1801
|
+
autoCommit: true
|
|
1759
1802
|
}));
|
|
1760
1803
|
};
|
|
1761
1804
|
ws.onmessage = (event) => {
|
|
@@ -1776,17 +1819,17 @@ function TaskStatusToast({
|
|
|
1776
1819
|
resolve();
|
|
1777
1820
|
}
|
|
1778
1821
|
};
|
|
1779
|
-
setTimeout(cleanup,
|
|
1822
|
+
setTimeout(cleanup, 1e4);
|
|
1780
1823
|
});
|
|
1781
1824
|
}, [serverUrl, token]);
|
|
1782
1825
|
const handleDismiss = (0, import_react5.useCallback)(async () => {
|
|
1783
1826
|
if (killOnClose && task?.sessionId) {
|
|
1784
|
-
await killSession(task.sessionId);
|
|
1827
|
+
await killSession(task.sessionId, task.prompt);
|
|
1785
1828
|
}
|
|
1786
1829
|
setVisible(false);
|
|
1787
1830
|
setExpanded(false);
|
|
1788
1831
|
setTimeout(onDismiss, 300);
|
|
1789
|
-
}, [killOnClose, task?.sessionId, killSession, onDismiss]);
|
|
1832
|
+
}, [killOnClose, task?.sessionId, task?.prompt, killSession, onDismiss]);
|
|
1790
1833
|
const handleToggleExpand = (0, import_react5.useCallback)(() => {
|
|
1791
1834
|
setExpanded(!expanded);
|
|
1792
1835
|
}, [expanded]);
|