@copylee/dsh-computer-use 0.8.4 → 0.8.6
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/helper/CuHelper.cs +37 -2
- package/lib/client.js +3 -1
- package/lib/types/client/nav-icon.d.ts +1 -1
- package/package.json +1 -1
package/helper/CuHelper.cs
CHANGED
|
@@ -1077,6 +1077,7 @@ namespace DshComputerUse
|
|
|
1077
1077
|
public static Bitmap Capture(Rectangle area, IntPtr exclude)
|
|
1078
1078
|
{
|
|
1079
1079
|
if (!Ready()) return null;
|
|
1080
|
+
Bitmap result = null;
|
|
1080
1081
|
try
|
|
1081
1082
|
{
|
|
1082
1083
|
// The never-shown host must be as large as the capture, or the control is clipped.
|
|
@@ -1086,7 +1087,7 @@ namespace DshComputerUse
|
|
|
1086
1087
|
frame = null;
|
|
1087
1088
|
var rc = new Native.RECT { Left = area.Left, Top = area.Top, Right = area.Right, Bottom = area.Bottom };
|
|
1088
1089
|
if (!MagSetWindowSource(magnifier, rc)) { broken = true; Why = "source"; return null; }
|
|
1089
|
-
|
|
1090
|
+
result = frame;
|
|
1090
1091
|
frame = null;
|
|
1091
1092
|
if (result == null || result.Width != area.Width || result.Height != area.Height)
|
|
1092
1093
|
{
|
|
@@ -1095,9 +1096,43 @@ namespace DshComputerUse
|
|
|
1095
1096
|
broken = true;
|
|
1096
1097
|
return null;
|
|
1097
1098
|
}
|
|
1099
|
+
if (!HasVisiblePixels(result))
|
|
1100
|
+
{
|
|
1101
|
+
result.Dispose();
|
|
1102
|
+
broken = true;
|
|
1103
|
+
Why = "black magnifier frame";
|
|
1104
|
+
Console.Error.WriteLine("Magnification capture returned a black frame; using BitBlt for the rest of this helper process.");
|
|
1105
|
+
return null;
|
|
1106
|
+
}
|
|
1098
1107
|
return result;
|
|
1099
1108
|
}
|
|
1100
|
-
catch (Exception e)
|
|
1109
|
+
catch (Exception e)
|
|
1110
|
+
{
|
|
1111
|
+
if (result != null) result.Dispose();
|
|
1112
|
+
broken = true;
|
|
1113
|
+
Why = "capture: " + e.Message;
|
|
1114
|
+
return null;
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
internal static bool HasVisiblePixels(Bitmap bitmap)
|
|
1119
|
+
{
|
|
1120
|
+
var data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppRgb);
|
|
1121
|
+
try
|
|
1122
|
+
{
|
|
1123
|
+
var row = new byte[bitmap.Width * 4];
|
|
1124
|
+
for (int y = 0; y < bitmap.Height; y++)
|
|
1125
|
+
{
|
|
1126
|
+
Marshal.Copy(IntPtr.Add(data.Scan0, y * data.Stride), row, 0, row.Length);
|
|
1127
|
+
for (int x = 0; x < row.Length; x += 4)
|
|
1128
|
+
{
|
|
1129
|
+
// Ignore the padding byte and allow black-level noise.
|
|
1130
|
+
if (row[x] > 3 || row[x + 1] > 3 || row[x + 2] > 3) return true;
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
return false;
|
|
1134
|
+
}
|
|
1135
|
+
finally { bitmap.UnlockBits(data); }
|
|
1101
1136
|
}
|
|
1102
1137
|
|
|
1103
1138
|
static bool OnImage(IntPtr hwnd, IntPtr srcdata, MAGIMAGEHEADER h, IntPtr destdata, MAGIMAGEHEADER dh, Native.RECT unclipped, Native.RECT clipped, IntPtr dirty)
|
package/lib/client.js
CHANGED
|
@@ -231,7 +231,9 @@ window.__ModuleLoader__.load({
|
|
|
231
231
|
const MARKER = "data-dsh-computer-use-settings-nav";
|
|
232
232
|
const POINTER_SVG = "%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z'/%3E%3C/svg%3E";
|
|
233
233
|
const navIconCss = `
|
|
234
|
-
|
|
234
|
+
/* Older shells render the SVG directly; newer shells wrap it in a decorative span. */
|
|
235
|
+
[${MARKER}] > svg:first-child,
|
|
236
|
+
[${MARKER}] > span[aria-hidden="true"]:first-child { display: none; }
|
|
235
237
|
[${MARKER}]::before {
|
|
236
238
|
content: '';
|
|
237
239
|
flex: none;
|
|
@@ -7,6 +7,6 @@
|
|
|
7
7
|
* our own row by its label and let CSS swap the glyph (Lucide mouse-pointer-2,
|
|
8
8
|
* drawn as a currentColor mask so hover / active colors still apply).
|
|
9
9
|
*/
|
|
10
|
-
export declare const navIconCss = "\n[data-dsh-computer-use-settings-nav] > svg:first-child { display: none; }\n[data-dsh-computer-use-settings-nav]::before {\n content: '';\n flex: none;\n width: 16px;\n height: 16px;\n background: currentColor;\n -webkit-mask: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z'/%3E%3C/svg%3E\") center / contain no-repeat;\n mask: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z'/%3E%3C/svg%3E\") center / contain no-repeat;\n}\n";
|
|
10
|
+
export declare const navIconCss = "\n/* Older shells render the SVG directly; newer shells wrap it in a decorative span. */\n[data-dsh-computer-use-settings-nav] > svg:first-child,\n[data-dsh-computer-use-settings-nav] > span[aria-hidden=\"true\"]:first-child { display: none; }\n[data-dsh-computer-use-settings-nav]::before {\n content: '';\n flex: none;\n width: 16px;\n height: 16px;\n background: currentColor;\n -webkit-mask: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z'/%3E%3C/svg%3E\") center / contain no-repeat;\n mask: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z'/%3E%3C/svg%3E\") center / contain no-repeat;\n}\n";
|
|
11
11
|
/** Keep the marker on the settings-nav button labelled `label`; returns a disposer. */
|
|
12
12
|
export declare function registerNavIcon(label: string): () => void;
|
package/package.json
CHANGED