@copylee/dsh-computer-use 0.1.4 → 0.1.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/lib/client.js +55 -0
- package/lib/types/client/nav-icon.d.ts +12 -0
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -70,6 +70,60 @@ window.__ModuleLoader__.load({
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
//#endregion
|
|
73
|
+
//#region lib/types/client/nav-icon.js
|
|
74
|
+
/**
|
|
75
|
+
* Give the "电脑控制" row in the DSH settings navigation a mouse-pointer icon
|
|
76
|
+
* instead of the shell's fallback gear.
|
|
77
|
+
*
|
|
78
|
+
* `settings.section` registrations only carry `id`, `order` and `label`; the
|
|
79
|
+
* shell picks icons for built-in ids only. So, like dsh-better-sidebar, we mark
|
|
80
|
+
* our own row by its label and let CSS swap the glyph (Lucide mouse-pointer-2,
|
|
81
|
+
* drawn as a currentColor mask so hover / active colors still apply).
|
|
82
|
+
*/
|
|
83
|
+
const MARKER = "data-dsh-computer-use-settings-nav";
|
|
84
|
+
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";
|
|
85
|
+
const navIconCss = `
|
|
86
|
+
[${MARKER}] > svg:first-child { display: none; }
|
|
87
|
+
[${MARKER}]::before {
|
|
88
|
+
content: '';
|
|
89
|
+
flex: none;
|
|
90
|
+
width: 16px;
|
|
91
|
+
height: 16px;
|
|
92
|
+
background: currentColor;
|
|
93
|
+
-webkit-mask: url("data:image/svg+xml,${POINTER_SVG}") center / contain no-repeat;
|
|
94
|
+
mask: url("data:image/svg+xml,${POINTER_SVG}") center / contain no-repeat;
|
|
95
|
+
}
|
|
96
|
+
`;
|
|
97
|
+
/** Keep the marker on the settings-nav button labelled `label`; returns a disposer. */
|
|
98
|
+
function registerNavIcon(label) {
|
|
99
|
+
const style = document.createElement("style");
|
|
100
|
+
style.setAttribute("data-dsh-computer-use", "nav-icon");
|
|
101
|
+
style.textContent = navIconCss;
|
|
102
|
+
document.head.appendChild(style);
|
|
103
|
+
let disposed = false;
|
|
104
|
+
const sync = () => {
|
|
105
|
+
if (disposed) return;
|
|
106
|
+
for (const button of document.querySelectorAll("[role=\"dialog\"] nav button")) {
|
|
107
|
+
const mine = button.textContent?.trim() === label;
|
|
108
|
+
if (mine && !button.hasAttribute(MARKER)) button.setAttribute(MARKER, "");
|
|
109
|
+
else if (!mine && button.hasAttribute(MARKER)) button.removeAttribute(MARKER);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
sync();
|
|
113
|
+
const observer = new MutationObserver(sync);
|
|
114
|
+
observer.observe(document.body, {
|
|
115
|
+
childList: true,
|
|
116
|
+
subtree: true,
|
|
117
|
+
characterData: true
|
|
118
|
+
});
|
|
119
|
+
return () => {
|
|
120
|
+
disposed = true;
|
|
121
|
+
observer.disconnect();
|
|
122
|
+
style.remove();
|
|
123
|
+
document.querySelectorAll(`[${MARKER}]`).forEach((element) => element.removeAttribute(MARKER));
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
//#endregion
|
|
73
127
|
//#region lib/types/client/select.js
|
|
74
128
|
const h$1 = react.createElement;
|
|
75
129
|
/** Menu appearance and fixed-position behavior follow dsh-free-search / dsh-proxy. */
|
|
@@ -743,6 +797,7 @@ window.__ModuleLoader__.load({
|
|
|
743
797
|
"remote.settings"
|
|
744
798
|
];
|
|
745
799
|
function apply(ctx) {
|
|
800
|
+
ctx.effect(() => registerNavIcon("电脑控制"), "computer-use: settings nav icon");
|
|
746
801
|
ctx.slots.inject("settings.section", () => ctx.slots.register({
|
|
747
802
|
name: "settings.section",
|
|
748
803
|
id: ENTRY_ID,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Give the "电脑控制" row in the DSH settings navigation a mouse-pointer icon
|
|
3
|
+
* instead of the shell's fallback gear.
|
|
4
|
+
*
|
|
5
|
+
* `settings.section` registrations only carry `id`, `order` and `label`; the
|
|
6
|
+
* shell picks icons for built-in ids only. So, like dsh-better-sidebar, we mark
|
|
7
|
+
* our own row by its label and let CSS swap the glyph (Lucide mouse-pointer-2,
|
|
8
|
+
* drawn as a currentColor mask so hover / active colors still apply).
|
|
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";
|
|
11
|
+
/** Keep the marker on the settings-nav button labelled `label`; returns a disposer. */
|
|
12
|
+
export declare function registerNavIcon(label: string): () => void;
|
package/package.json
CHANGED