@fefeding/aicmd 1.0.25 → 1.0.27
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/README.md +58 -5
- package/README.zh.md +64 -5
- package/dist/public/.vite/manifest.json +133 -13
- package/dist/public/ai-settings.css +1868 -0
- package/dist/public/ai-settings.js +7579 -0
- package/dist/public/bootstrap-icons.woff +0 -0
- package/dist/public/bootstrap-icons.woff2 +0 -0
- package/dist/public/bootstrap.css +1 -1
- package/dist/public/bootstrap.js +60 -119
- package/dist/public/connection-editor.css +5 -0
- package/dist/public/connection-editor.js +712 -0
- package/dist/public/connection.js +118 -0
- package/dist/public/index.css +0 -381
- package/dist/public/index.js +186 -5467
- package/dist/public/rdp_client_bg.wasm +0 -0
- package/dist/public/selection-copy.css +494 -0
- package/dist/public/selection-copy.js +5501 -0
- package/dist/public/src/term.html +17 -0
- package/dist/public/src/vscode-edit.html +21 -0
- package/dist/public/src/vscode-term.html +24 -0
- package/dist/public/term.css +14 -0
- package/dist/public/term.js +333 -0
- package/dist/public/views.css +111 -1515
- package/dist/public/views.js +233 -7476
- package/dist/public/vscode-clipboard.js +658 -0
- package/dist/public/vscode-edit.js +91 -0
- package/dist/public/vscode-term.js +116 -0
- package/dist/public/vue.js +360 -195
- package/dist/public/xterm.js +1647 -10
- package/dist/public/zmodem.js +2726 -0
- package/dist/server/index.d.ts +12 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +14 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.ts +14 -1
- package/dist/server/model/connection.entity.d.ts +10 -2
- package/dist/server/model/connection.entity.d.ts.map +1 -1
- package/dist/server/model/connection.entity.js +9 -1
- package/dist/server/model/connection.entity.js.map +1 -1
- package/dist/server/model/connection.entity.ts +11 -2
- package/dist/server/service/ai.service.d.ts +15 -0
- package/dist/server/service/ai.service.d.ts.map +1 -1
- package/dist/server/service/ai.service.js +38 -6
- package/dist/server/service/ai.service.js.map +1 -1
- package/dist/server/service/ai.service.ts +43 -6
- package/dist/server/service/rdp-tunnel.service.d.ts +22 -0
- package/dist/server/service/rdp-tunnel.service.d.ts.map +1 -0
- package/dist/server/service/rdp-tunnel.service.js +464 -0
- package/dist/server/service/rdp-tunnel.service.js.map +1 -0
- package/dist/server/service/rdp-tunnel.service.ts +428 -0
- package/dist/server/service/rdp.service.d.ts +64 -0
- package/dist/server/service/rdp.service.d.ts.map +1 -0
- package/dist/server/service/rdp.service.js +324 -0
- package/dist/server/service/rdp.service.js.map +1 -0
- package/dist/server/service/rdp.service.ts +324 -0
- package/dist/server/service/ssh.service.d.ts +68 -2
- package/dist/server/service/ssh.service.d.ts.map +1 -1
- package/dist/server/service/ssh.service.js +551 -118
- package/dist/server/service/ssh.service.js.map +1 -1
- package/dist/server/service/ssh.service.ts +535 -116
- package/dist/server/utils/ansi.d.ts +20 -0
- package/dist/server/utils/ansi.d.ts.map +1 -0
- package/dist/server/utils/ansi.js +39 -0
- package/dist/server/utils/ansi.js.map +1 -0
- package/dist/server/utils/ansi.ts +34 -0
- package/dist/server/utils/rdp-ws.d.ts +15 -0
- package/dist/server/utils/rdp-ws.d.ts.map +1 -0
- package/dist/server/utils/rdp-ws.js +28 -0
- package/dist/server/utils/rdp-ws.js.map +1 -0
- package/dist/server/utils/rdp-ws.ts +32 -0
- package/dist/view/index.html +9 -7
- package/electron/main.js +118 -3
- package/electron/preload.js +4 -0
- package/package.json +32 -31
- package/public/aicmd.png +0 -0
- package/server.js +132 -12
- package/dist/public/rolldown-runtime.js +0 -41
|
@@ -0,0 +1,658 @@
|
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esmMin = (fn, res, err) => () => {
|
|
9
|
+
if (err) throw err[0];
|
|
10
|
+
try {
|
|
11
|
+
return fn && (res = fn(fn = 0)), res;
|
|
12
|
+
} catch (e) {
|
|
13
|
+
throw err = [e], e;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
|
|
17
|
+
var __exportAll = (all, no_symbols) => {
|
|
18
|
+
let target = {};
|
|
19
|
+
for (var name in all) __defProp(target, name, {
|
|
20
|
+
get: all[name],
|
|
21
|
+
enumerable: true
|
|
22
|
+
});
|
|
23
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
24
|
+
return target;
|
|
25
|
+
};
|
|
26
|
+
var __copyProps = (to, from, except, desc) => {
|
|
27
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
28
|
+
key = keys[i];
|
|
29
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
30
|
+
get: ((k) => from[k]).bind(null, key),
|
|
31
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
37
|
+
value: mod,
|
|
38
|
+
enumerable: true
|
|
39
|
+
}) : target, mod));
|
|
40
|
+
// \0vite/modulepreload-polyfill.js
|
|
41
|
+
(function polyfill() {
|
|
42
|
+
const relList = document.createElement("link").relList;
|
|
43
|
+
if (relList && relList.supports && relList.supports("modulepreload")) return;
|
|
44
|
+
for (const link of document.querySelectorAll("link[rel=\"modulepreload\"]")) processPreload(link);
|
|
45
|
+
new MutationObserver((mutations) => {
|
|
46
|
+
for (const mutation of mutations) {
|
|
47
|
+
if (mutation.type !== "childList") continue;
|
|
48
|
+
for (const node of mutation.addedNodes) if (node.tagName === "LINK" && node.rel === "modulepreload") processPreload(node);
|
|
49
|
+
}
|
|
50
|
+
}).observe(document, {
|
|
51
|
+
childList: true,
|
|
52
|
+
subtree: true
|
|
53
|
+
});
|
|
54
|
+
function getFetchOpts(link) {
|
|
55
|
+
const fetchOpts = {};
|
|
56
|
+
if (link.integrity) fetchOpts.integrity = link.integrity;
|
|
57
|
+
if (link.referrerPolicy) fetchOpts.referrerPolicy = link.referrerPolicy;
|
|
58
|
+
if (link.crossOrigin === "use-credentials") fetchOpts.credentials = "include";
|
|
59
|
+
else if (link.crossOrigin === "anonymous") fetchOpts.credentials = "omit";
|
|
60
|
+
else fetchOpts.credentials = "same-origin";
|
|
61
|
+
return fetchOpts;
|
|
62
|
+
}
|
|
63
|
+
function processPreload(link) {
|
|
64
|
+
if (link.ep) return;
|
|
65
|
+
link.ep = true;
|
|
66
|
+
const fetchOpts = getFetchOpts(link);
|
|
67
|
+
fetch(link.href, fetchOpts);
|
|
68
|
+
}
|
|
69
|
+
})();
|
|
70
|
+
// src/utils/vscode-theme.ts
|
|
71
|
+
/** 是否运行在扩展 WebView 的 iframe 中(扩展壳通过 ?aicmd_vscode=1 标记) */
|
|
72
|
+
function isVscodeThemeHost() {
|
|
73
|
+
try {
|
|
74
|
+
return new URLSearchParams(location.search).get("aicmd_vscode") === "1";
|
|
75
|
+
} catch {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/** 监听 VSCode 主题变化,返回取消订阅函数 */
|
|
80
|
+
function onVscodeThemeChange(cb) {
|
|
81
|
+
listeners.add(cb);
|
|
82
|
+
return () => listeners.delete(cb);
|
|
83
|
+
}
|
|
84
|
+
/** 把颜色值归一化为 "r g b" 三元组(供 rgb(var(--x-rgb) / 10%) 语法使用) */
|
|
85
|
+
function toRgbTriplet(value) {
|
|
86
|
+
if (!value) return null;
|
|
87
|
+
const v = value.trim();
|
|
88
|
+
const rgbFn = v.match(/rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/i);
|
|
89
|
+
if (rgbFn) return `${Math.round(+rgbFn[1])} ${Math.round(+rgbFn[2])} ${Math.round(+rgbFn[3])}`;
|
|
90
|
+
const m = v.match(/^#([0-9a-f]{3,8})$/i);
|
|
91
|
+
if (!m) return null;
|
|
92
|
+
let hex = m[1];
|
|
93
|
+
if (hex.length === 3 || hex.length === 4) hex = hex.split("").map((c) => c + c).join("");
|
|
94
|
+
if (hex.length !== 6 && hex.length !== 8) return null;
|
|
95
|
+
return `${parseInt(hex.slice(0, 2), 16)} ${parseInt(hex.slice(2, 4), 16)} ${parseInt(hex.slice(4, 6), 16)}`;
|
|
96
|
+
}
|
|
97
|
+
function pick(payload, names) {
|
|
98
|
+
for (const n of names) {
|
|
99
|
+
const v = payload.vars[n];
|
|
100
|
+
if (v) return v;
|
|
101
|
+
}
|
|
102
|
+
return "";
|
|
103
|
+
}
|
|
104
|
+
function applyTheme(payload) {
|
|
105
|
+
const root = document.documentElement;
|
|
106
|
+
const style = root.style;
|
|
107
|
+
for (const [appVar, sources] of APP_VAR_MAP) {
|
|
108
|
+
const value = pick(payload, sources);
|
|
109
|
+
if (value) style.setProperty(appVar, value);
|
|
110
|
+
}
|
|
111
|
+
style.setProperty("--overlay-rgb", payload.dark ? "255 255 255" : "0 0 0");
|
|
112
|
+
for (const [rgbVar, colorVar] of RGB_VAR_MAP) {
|
|
113
|
+
const triplet = toRgbTriplet(style.getPropertyValue(colorVar));
|
|
114
|
+
if (triplet) style.setProperty(rgbVar, triplet);
|
|
115
|
+
}
|
|
116
|
+
const read = (name) => style.getPropertyValue(name) || void 0;
|
|
117
|
+
const bs = {
|
|
118
|
+
"--bs-body-bg": read("--bg-dark"),
|
|
119
|
+
"--bs-body-color": read("--text-primary"),
|
|
120
|
+
"--bs-emphasis-color": read("--text-primary"),
|
|
121
|
+
"--bs-secondary-color": read("--text-secondary"),
|
|
122
|
+
"--bs-border-color": read("--border-strong"),
|
|
123
|
+
"--bs-border-color-translucent": read("--border-strong"),
|
|
124
|
+
"--bs-secondary-bg": read("--bg-input"),
|
|
125
|
+
"--bs-tertiary-bg": read("--bg-sidebar"),
|
|
126
|
+
"--bs-card-bg": read("--bg-sidebar"),
|
|
127
|
+
"--bs-card-cap-bg": read("--bg-toolbar"),
|
|
128
|
+
"--bs-modal-bg": read("--bg-sidebar"),
|
|
129
|
+
"--bs-modal-border-color": read("--border-color"),
|
|
130
|
+
"--bs-form-control-bg": read("--bg-input"),
|
|
131
|
+
"--bs-form-control-color": read("--text-primary"),
|
|
132
|
+
"--bs-form-control-border-color": read("--border-strong"),
|
|
133
|
+
"--bs-primary": read("--accent"),
|
|
134
|
+
"--bs-link-color": read("--accent"),
|
|
135
|
+
"--bs-link-hover-color": read("--accent-hover"),
|
|
136
|
+
"--bs-danger": read("--danger"),
|
|
137
|
+
"--bs-success": read("--success"),
|
|
138
|
+
"--bs-warning": read("--warning"),
|
|
139
|
+
"--bs-info": read("--info"),
|
|
140
|
+
"--bs-secondary": read("--text-secondary")
|
|
141
|
+
};
|
|
142
|
+
for (const [k, v] of Object.entries(bs)) if (v) style.setProperty(k, v);
|
|
143
|
+
if (payload.dark) {
|
|
144
|
+
style.removeProperty("--bg-recess-soft");
|
|
145
|
+
style.removeProperty("--bg-recess");
|
|
146
|
+
style.removeProperty("--bg-recess-strong");
|
|
147
|
+
} else {
|
|
148
|
+
style.setProperty("--bg-recess-soft", "rgba(0, 0, 0, 0.04)");
|
|
149
|
+
style.setProperty("--bg-recess", "rgba(0, 0, 0, 0.05)");
|
|
150
|
+
style.setProperty("--bg-recess-strong", "rgba(0, 0, 0, 0.08)");
|
|
151
|
+
}
|
|
152
|
+
root.setAttribute("data-bs-theme", payload.dark ? "dark" : "light");
|
|
153
|
+
root.setAttribute("data-vscode-theme", payload.kind);
|
|
154
|
+
style.colorScheme = payload.dark ? "dark" : "light";
|
|
155
|
+
}
|
|
156
|
+
function handlePayload(raw) {
|
|
157
|
+
if (!raw || raw.type !== "aicmd-vscode-theme") return;
|
|
158
|
+
const payload = raw;
|
|
159
|
+
if (!payload.vars) payload.vars = {};
|
|
160
|
+
state = payload;
|
|
161
|
+
applyTheme(payload);
|
|
162
|
+
for (const cb of listeners) try {
|
|
163
|
+
cb(payload);
|
|
164
|
+
} catch (e) {
|
|
165
|
+
console.error("[vscode-theme] listener error", e);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/** 请求扩展壳重新下发一次主题(首帧壳可能先于页面监听发送) */
|
|
169
|
+
function requestTheme() {
|
|
170
|
+
try {
|
|
171
|
+
window.parent?.postMessage({ type: "aicmd-vscode-theme-request" }, "*");
|
|
172
|
+
} catch {}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* 初始化主题桥接(在 app.mount 之前调用)。
|
|
176
|
+
* 非 VSCode 环境为空操作,桌面端 / 浏览器外观完全不变。
|
|
177
|
+
*/
|
|
178
|
+
function initVscodeTheme() {
|
|
179
|
+
if (initialized) return;
|
|
180
|
+
if (!isVscodeThemeHost()) return;
|
|
181
|
+
initialized = true;
|
|
182
|
+
try {
|
|
183
|
+
const params = new URLSearchParams(location.search);
|
|
184
|
+
const kind = params.get("vkind") || "";
|
|
185
|
+
const bg = params.get("vbg") || "";
|
|
186
|
+
const fg = params.get("vfg") || "";
|
|
187
|
+
if (kind) {
|
|
188
|
+
const dark = !kind.startsWith("light") && kind !== "hc-light";
|
|
189
|
+
document.documentElement.setAttribute("data-bs-theme", dark ? "dark" : "light");
|
|
190
|
+
document.documentElement.setAttribute("data-vscode-theme", kind);
|
|
191
|
+
document.documentElement.style.colorScheme = dark ? "dark" : "light";
|
|
192
|
+
}
|
|
193
|
+
if (bg) {
|
|
194
|
+
document.documentElement.style.setProperty("--bg-dark", bg);
|
|
195
|
+
document.body.style.backgroundColor = bg;
|
|
196
|
+
}
|
|
197
|
+
if (fg) {
|
|
198
|
+
document.documentElement.style.setProperty("--text-primary", fg);
|
|
199
|
+
document.body.style.color = fg;
|
|
200
|
+
}
|
|
201
|
+
} catch {}
|
|
202
|
+
window.addEventListener("message", (e) => handlePayload(e.data));
|
|
203
|
+
requestTheme();
|
|
204
|
+
window.addEventListener("load", requestTheme);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* 依据当前 VSCode 主题构造 xterm 配色。
|
|
208
|
+
* 未处于 VSCode(未收到主题)时返回 null,由调用方使用默认配色。
|
|
209
|
+
*/
|
|
210
|
+
function buildVscodeTerminalTheme() {
|
|
211
|
+
if (!state) return null;
|
|
212
|
+
const base = state.dark ? TERMINAL_THEME_DARK : TERMINAL_THEME_LIGHT;
|
|
213
|
+
const v = (name) => state?.vars[name] || "";
|
|
214
|
+
const merged = { ...base };
|
|
215
|
+
const setIf = (key, names) => {
|
|
216
|
+
for (const n of names) {
|
|
217
|
+
const value = v(n);
|
|
218
|
+
if (value) {
|
|
219
|
+
merged[key] = value;
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
setIf("background", ["terminal-background", "editor-background"]);
|
|
225
|
+
setIf("foreground", [
|
|
226
|
+
"terminal-foreground",
|
|
227
|
+
"editor-foreground",
|
|
228
|
+
"foreground"
|
|
229
|
+
]);
|
|
230
|
+
setIf("cursor", ["terminalCursor-foreground", "editorCursor-foreground"]);
|
|
231
|
+
merged.cursorAccent = merged.background;
|
|
232
|
+
setIf("selectionBackground", ["terminal-selectionBackground", "editor-selectionBackground"]);
|
|
233
|
+
merged.selectionForeground = merged.foreground;
|
|
234
|
+
setIf("black", ["terminal-ansiBlack"]);
|
|
235
|
+
setIf("red", ["terminal-ansiRed"]);
|
|
236
|
+
setIf("green", ["terminal-ansiGreen"]);
|
|
237
|
+
setIf("yellow", ["terminal-ansiYellow"]);
|
|
238
|
+
setIf("blue", ["terminal-ansiBlue"]);
|
|
239
|
+
setIf("magenta", ["terminal-ansiMagenta"]);
|
|
240
|
+
setIf("cyan", ["terminal-ansiCyan"]);
|
|
241
|
+
setIf("white", ["terminal-ansiWhite"]);
|
|
242
|
+
setIf("brightBlack", ["terminal-ansiBrightBlack"]);
|
|
243
|
+
setIf("brightRed", ["terminal-ansiBrightRed"]);
|
|
244
|
+
setIf("brightGreen", ["terminal-ansiBrightGreen"]);
|
|
245
|
+
setIf("brightYellow", ["terminal-ansiBrightYellow"]);
|
|
246
|
+
setIf("brightBlue", ["terminal-ansiBrightBlue"]);
|
|
247
|
+
setIf("brightMagenta", ["terminal-ansiBrightMagenta"]);
|
|
248
|
+
setIf("brightCyan", ["terminal-ansiBrightCyan"]);
|
|
249
|
+
setIf("brightWhite", ["terminal-ansiBrightWhite"]);
|
|
250
|
+
return merged;
|
|
251
|
+
}
|
|
252
|
+
var TERMINAL_THEME_DARK, TERMINAL_THEME_LIGHT, listeners, state, initialized, APP_VAR_MAP, RGB_VAR_MAP;
|
|
253
|
+
var init_vscode_theme = __esmMin((() => {
|
|
254
|
+
TERMINAL_THEME_DARK = {
|
|
255
|
+
background: "#1e1e2e",
|
|
256
|
+
foreground: "#cdd6f4",
|
|
257
|
+
cursor: "#f5e0dc",
|
|
258
|
+
cursorAccent: "#1e1e2e",
|
|
259
|
+
selectionBackground: "#585b7066",
|
|
260
|
+
selectionForeground: "#cdd6f4",
|
|
261
|
+
black: "#45475a",
|
|
262
|
+
red: "#f38ba8",
|
|
263
|
+
green: "#a6e3a1",
|
|
264
|
+
yellow: "#f9e2af",
|
|
265
|
+
blue: "#89b4fa",
|
|
266
|
+
magenta: "#f5c2e7",
|
|
267
|
+
cyan: "#94e2d5",
|
|
268
|
+
white: "#bac2de",
|
|
269
|
+
brightBlack: "#585b70",
|
|
270
|
+
brightRed: "#f38ba8",
|
|
271
|
+
brightGreen: "#a6e3a1",
|
|
272
|
+
brightYellow: "#f9e2af",
|
|
273
|
+
brightBlue: "#89b4fa",
|
|
274
|
+
brightMagenta: "#f5c2e7",
|
|
275
|
+
brightCyan: "#94e2d5",
|
|
276
|
+
brightWhite: "#a6adc8"
|
|
277
|
+
};
|
|
278
|
+
TERMINAL_THEME_LIGHT = {
|
|
279
|
+
background: "#eff1f5",
|
|
280
|
+
foreground: "#4c4f69",
|
|
281
|
+
cursor: "#dc8a78",
|
|
282
|
+
cursorAccent: "#eff1f5",
|
|
283
|
+
selectionBackground: "#acb0be40",
|
|
284
|
+
selectionForeground: "#4c4f69",
|
|
285
|
+
black: "#5c5f77",
|
|
286
|
+
red: "#d20f39",
|
|
287
|
+
green: "#40a02b",
|
|
288
|
+
yellow: "#df8e1d",
|
|
289
|
+
blue: "#1e66f5",
|
|
290
|
+
magenta: "#ea76cb",
|
|
291
|
+
cyan: "#179299",
|
|
292
|
+
white: "#acb0be",
|
|
293
|
+
brightBlack: "#6c6f85",
|
|
294
|
+
brightRed: "#d20f39",
|
|
295
|
+
brightGreen: "#40a02b",
|
|
296
|
+
brightYellow: "#df8e1d",
|
|
297
|
+
brightBlue: "#1e66f5",
|
|
298
|
+
brightMagenta: "#ea76cb",
|
|
299
|
+
brightCyan: "#179299",
|
|
300
|
+
brightWhite: "#bcc0cc"
|
|
301
|
+
};
|
|
302
|
+
listeners = /* @__PURE__ */ new Set();
|
|
303
|
+
state = null;
|
|
304
|
+
initialized = false;
|
|
305
|
+
APP_VAR_MAP = [
|
|
306
|
+
["--bg-dark", ["editor-background"]],
|
|
307
|
+
["--bg-sidebar", [
|
|
308
|
+
"sideBar-background",
|
|
309
|
+
"panel-background",
|
|
310
|
+
"editorWidget-background",
|
|
311
|
+
"editor-background"
|
|
312
|
+
]],
|
|
313
|
+
["--bg-toolbar", [
|
|
314
|
+
"editorGroupHeader-tabsBackground",
|
|
315
|
+
"titleBar-activeBackground",
|
|
316
|
+
"sideBar-background",
|
|
317
|
+
"editor-background"
|
|
318
|
+
]],
|
|
319
|
+
["--bg-input", [
|
|
320
|
+
"input-background",
|
|
321
|
+
"dropdown-background",
|
|
322
|
+
"editorWidget-background"
|
|
323
|
+
]],
|
|
324
|
+
["--bg-menu", [
|
|
325
|
+
"menu-background",
|
|
326
|
+
"editorHoverWidget-background",
|
|
327
|
+
"editorWidget-background",
|
|
328
|
+
"editor-background"
|
|
329
|
+
]],
|
|
330
|
+
["--bg-hover", [
|
|
331
|
+
"list-hoverBackground",
|
|
332
|
+
"toolbar-hoverBackground",
|
|
333
|
+
"button-secondaryHoverBackground",
|
|
334
|
+
"menu-selectionBackground"
|
|
335
|
+
]],
|
|
336
|
+
["--text-primary", ["editor-foreground", "foreground"]],
|
|
337
|
+
["--text-secondary", [
|
|
338
|
+
"descriptionForeground",
|
|
339
|
+
"sideBar-foreground",
|
|
340
|
+
"foreground"
|
|
341
|
+
]],
|
|
342
|
+
["--text-muted", ["disabledForeground", "descriptionForeground"]],
|
|
343
|
+
["--border-color", [
|
|
344
|
+
"editorGroup-border",
|
|
345
|
+
"sideBar-border",
|
|
346
|
+
"editorWidget-border",
|
|
347
|
+
"panel-border",
|
|
348
|
+
"contrastBorder"
|
|
349
|
+
]],
|
|
350
|
+
["--border-strong", [
|
|
351
|
+
"input-border",
|
|
352
|
+
"dropdown-border",
|
|
353
|
+
"editorWidget-border",
|
|
354
|
+
"panel-border",
|
|
355
|
+
"contrastBorder"
|
|
356
|
+
]],
|
|
357
|
+
["--accent", [
|
|
358
|
+
"textLink-foreground",
|
|
359
|
+
"button-background",
|
|
360
|
+
"focusBorder",
|
|
361
|
+
"progressBar-background"
|
|
362
|
+
]],
|
|
363
|
+
["--accent-hover", [
|
|
364
|
+
"textLink-activeForeground",
|
|
365
|
+
"button-hoverBackground",
|
|
366
|
+
"focusBorder"
|
|
367
|
+
]],
|
|
368
|
+
["--accent-fg", ["button-foreground"]],
|
|
369
|
+
["--danger", [
|
|
370
|
+
"errorForeground",
|
|
371
|
+
"editorError-foreground",
|
|
372
|
+
"terminal-ansiRed",
|
|
373
|
+
"testing-iconFailed"
|
|
374
|
+
]],
|
|
375
|
+
["--success", [
|
|
376
|
+
"testing-iconPassed",
|
|
377
|
+
"gitDecoration-addedResourceForeground",
|
|
378
|
+
"terminal-ansiGreen",
|
|
379
|
+
"charts-green"
|
|
380
|
+
]],
|
|
381
|
+
["--warning", [
|
|
382
|
+
"editorWarning-foreground",
|
|
383
|
+
"terminal-ansiYellow",
|
|
384
|
+
"charts-yellow"
|
|
385
|
+
]],
|
|
386
|
+
["--warning-strong", [
|
|
387
|
+
"charts-orange",
|
|
388
|
+
"terminal-ansiBrightYellow",
|
|
389
|
+
"terminal-ansiYellow",
|
|
390
|
+
"editorWarning-foreground"
|
|
391
|
+
]],
|
|
392
|
+
["--info", [
|
|
393
|
+
"charts-blue",
|
|
394
|
+
"textLink-foreground",
|
|
395
|
+
"terminal-ansiBlue"
|
|
396
|
+
]],
|
|
397
|
+
["--scrollbar-thumb", ["scrollbarSlider-background"]],
|
|
398
|
+
["--scrollbar-thumb-hover", ["scrollbarSlider-hoverBackground", "scrollbarSlider-activeBackground"]]
|
|
399
|
+
];
|
|
400
|
+
RGB_VAR_MAP = [
|
|
401
|
+
["--accent-rgb", "--accent"],
|
|
402
|
+
["--danger-rgb", "--danger"],
|
|
403
|
+
["--success-rgb", "--success"],
|
|
404
|
+
["--warning-rgb", "--warning"],
|
|
405
|
+
["--warning-strong-rgb", "--warning-strong"],
|
|
406
|
+
["--bg-dark-rgb", "--bg-dark"],
|
|
407
|
+
["--bg-sidebar-rgb", "--bg-sidebar"],
|
|
408
|
+
["--bg-toolbar-rgb", "--bg-toolbar"],
|
|
409
|
+
["--bg-input-rgb", "--bg-input"],
|
|
410
|
+
["--bg-menu-rgb", "--bg-menu"],
|
|
411
|
+
["--border-color-rgb", "--border-color"],
|
|
412
|
+
["--border-strong-rgb", "--border-strong"]
|
|
413
|
+
];
|
|
414
|
+
}));
|
|
415
|
+
// src/utils/vscode-clipboard.ts
|
|
416
|
+
/** 运行在 VSCode WebView 的跨源 iframe 中(且无 Electron preload) */
|
|
417
|
+
function isVscodeWebviewRuntime() {
|
|
418
|
+
const hasElectronClipboard = !!window.electronAPI?.clipboard;
|
|
419
|
+
return isVscodeThemeHost() && !hasElectronClipboard;
|
|
420
|
+
}
|
|
421
|
+
function ensureBridge() {
|
|
422
|
+
if (bridgeReady) return;
|
|
423
|
+
bridgeReady = true;
|
|
424
|
+
window.addEventListener("message", (e) => {
|
|
425
|
+
const d = e.data;
|
|
426
|
+
if (!d || !d.__aicmd_clipboard) return;
|
|
427
|
+
const cb = pending.get(d.reqId);
|
|
428
|
+
if (cb) {
|
|
429
|
+
pending.delete(d.reqId);
|
|
430
|
+
cb(d);
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
function postToHost(msg) {
|
|
435
|
+
try {
|
|
436
|
+
window.parent?.postMessage(msg, "*");
|
|
437
|
+
} catch {}
|
|
438
|
+
}
|
|
439
|
+
function request(msg) {
|
|
440
|
+
ensureBridge();
|
|
441
|
+
const reqId = ++reqCounter;
|
|
442
|
+
return new Promise((resolve, reject) => {
|
|
443
|
+
pending.set(reqId, resolve);
|
|
444
|
+
postToHost({
|
|
445
|
+
...msg,
|
|
446
|
+
__aicmd_clipboard: true,
|
|
447
|
+
reqId
|
|
448
|
+
});
|
|
449
|
+
setTimeout(() => {
|
|
450
|
+
if (pending.has(reqId)) {
|
|
451
|
+
pending.delete(reqId);
|
|
452
|
+
reject(/* @__PURE__ */ new Error("clipboard request timeout"));
|
|
453
|
+
}
|
|
454
|
+
}, 5e3);
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
async function writeClipboardVscode(text) {
|
|
458
|
+
const resp = await request({
|
|
459
|
+
type: "aicmd-clipboard-write-request",
|
|
460
|
+
text
|
|
461
|
+
});
|
|
462
|
+
if (!resp.ok) throw new Error(resp.error || "write failed");
|
|
463
|
+
}
|
|
464
|
+
async function readClipboardVscode() {
|
|
465
|
+
const resp = await request({ type: "aicmd-clipboard-read-request" });
|
|
466
|
+
if (!resp.ok) throw new Error(resp.error || "read failed");
|
|
467
|
+
return resp.text || "";
|
|
468
|
+
}
|
|
469
|
+
/** 写剪贴板:扩展 WebView 走桥接,Electron 用 preload,否则 navigator.clipboard / execCommand 兜底 */
|
|
470
|
+
async function writeClipboard(text) {
|
|
471
|
+
if (isVscodeThemeHost()) try {
|
|
472
|
+
await writeClipboardVscode(text);
|
|
473
|
+
return;
|
|
474
|
+
} catch (err) {
|
|
475
|
+
console.warn("[aicmd] clipboard bridge write failed, fallback:", err);
|
|
476
|
+
}
|
|
477
|
+
const clip = window.electronAPI?.clipboard;
|
|
478
|
+
if (clip) try {
|
|
479
|
+
clip.writeText(text);
|
|
480
|
+
return;
|
|
481
|
+
} catch {}
|
|
482
|
+
if (isVscodeWebviewRuntime()) {
|
|
483
|
+
await writeClipboardVscode(text);
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
try {
|
|
487
|
+
await navigator.clipboard.writeText(text);
|
|
488
|
+
} catch {
|
|
489
|
+
const ta = document.createElement("textarea");
|
|
490
|
+
ta.value = text;
|
|
491
|
+
ta.setAttribute("readonly", "");
|
|
492
|
+
ta.style.position = "fixed";
|
|
493
|
+
ta.style.opacity = "0";
|
|
494
|
+
document.body.appendChild(ta);
|
|
495
|
+
ta.select();
|
|
496
|
+
try {
|
|
497
|
+
document.execCommand("copy");
|
|
498
|
+
} catch {} finally {
|
|
499
|
+
document.body.removeChild(ta);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
/** 读剪贴板:扩展 WebView 走桥接,Electron 用 preload,否则 navigator.clipboard 兜底 */
|
|
504
|
+
async function readClipboard() {
|
|
505
|
+
if (isVscodeThemeHost()) try {
|
|
506
|
+
const text = await readClipboardVscode();
|
|
507
|
+
if (text) return text;
|
|
508
|
+
} catch (err) {
|
|
509
|
+
console.warn("[aicmd] clipboard bridge read failed, fallback:", err);
|
|
510
|
+
}
|
|
511
|
+
const clip = window.electronAPI?.clipboard;
|
|
512
|
+
if (clip) try {
|
|
513
|
+
let text = clip.readText();
|
|
514
|
+
if (!text && clip.readTextAsync) text = await clip.readTextAsync();
|
|
515
|
+
return text || "";
|
|
516
|
+
} catch {}
|
|
517
|
+
if (isVscodeWebviewRuntime()) return await readClipboardVscode();
|
|
518
|
+
try {
|
|
519
|
+
return await navigator.clipboard.readText() || "";
|
|
520
|
+
} catch {
|
|
521
|
+
return "";
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
function isEditableEl(el) {
|
|
525
|
+
const node = el;
|
|
526
|
+
if (!node) return false;
|
|
527
|
+
if (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement) return true;
|
|
528
|
+
return !!node.isContentEditable;
|
|
529
|
+
}
|
|
530
|
+
function isInTerminal(target) {
|
|
531
|
+
const node = target;
|
|
532
|
+
if (!node || typeof node.closest !== "function") return false;
|
|
533
|
+
return !!node.closest(".xterm");
|
|
534
|
+
}
|
|
535
|
+
function getSelectionText() {
|
|
536
|
+
const sel = window.getSelection();
|
|
537
|
+
if (sel && sel.toString()) return sel.toString();
|
|
538
|
+
const el = document.activeElement;
|
|
539
|
+
if (el && typeof el.selectionStart === "number" && typeof el.selectionEnd === "number" && el.value) return el.value.slice(el.selectionStart, el.selectionEnd);
|
|
540
|
+
return "";
|
|
541
|
+
}
|
|
542
|
+
function insertTextAtCursor(el, text) {
|
|
543
|
+
try {
|
|
544
|
+
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {
|
|
545
|
+
const start = el.selectionStart ?? el.value.length;
|
|
546
|
+
const end = el.selectionEnd ?? el.value.length;
|
|
547
|
+
el.value = el.value.slice(0, start) + text + el.value.slice(end);
|
|
548
|
+
const pos = start + text.length;
|
|
549
|
+
el.setSelectionRange(pos, pos);
|
|
550
|
+
el.dispatchEvent(new Event("input", { bubbles: true }));
|
|
551
|
+
} else if (el.isContentEditable) document.execCommand("insertText", false, text);
|
|
552
|
+
} catch {}
|
|
553
|
+
}
|
|
554
|
+
function deleteSelectedText() {
|
|
555
|
+
const el = document.activeElement;
|
|
556
|
+
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {
|
|
557
|
+
const start = el.selectionStart ?? 0;
|
|
558
|
+
const end = el.selectionEnd ?? 0;
|
|
559
|
+
if (start === end) return;
|
|
560
|
+
el.value = el.value.slice(0, start) + el.value.slice(end);
|
|
561
|
+
el.setSelectionRange(start, start);
|
|
562
|
+
el.dispatchEvent(new Event("input", { bubbles: true }));
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* 快捷键级处理(Ctrl/Cmd + C / X / V)。
|
|
567
|
+
*
|
|
568
|
+
* 跨源 iframe 受权限策略限制,浏览器**根本不会派发** copy / paste 事件
|
|
569
|
+
* (终端能正常工作正是因为它直接拦截 keydown,而非依赖原生事件)。
|
|
570
|
+
* 因此这里同样以 keydown 为可靠入口:拦截后经桥接读写剪贴板,并
|
|
571
|
+
* preventDefault 抑制浏览器默认动作,避免与原生事件重复处理。
|
|
572
|
+
* 仅处理 C / X / V,其他快捷键(Ctrl+A / Z 等)一律放行。
|
|
573
|
+
*/
|
|
574
|
+
function handleKeydown(e) {
|
|
575
|
+
if (isInTerminal(e.target)) return;
|
|
576
|
+
if (!(e.ctrlKey || e.metaKey) || e.altKey) return;
|
|
577
|
+
const key = (e.key || "").toLowerCase();
|
|
578
|
+
if (key !== "c" && key !== "x" && key !== "v") return;
|
|
579
|
+
if (key === "v") {
|
|
580
|
+
const el = document.activeElement;
|
|
581
|
+
if (!isEditableEl(el)) return;
|
|
582
|
+
e.preventDefault();
|
|
583
|
+
const target = el;
|
|
584
|
+
readClipboard().then((text) => {
|
|
585
|
+
if (text) insertTextAtCursor(target, text);
|
|
586
|
+
}).catch(() => {});
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
const text = getSelectionText();
|
|
590
|
+
if (!text) return;
|
|
591
|
+
e.preventDefault();
|
|
592
|
+
writeClipboard(text).catch(() => {});
|
|
593
|
+
if (key === "x") deleteSelectedText();
|
|
594
|
+
}
|
|
595
|
+
function handleCopyCut(e) {
|
|
596
|
+
if (isInTerminal(e.target)) return;
|
|
597
|
+
const text = getSelectionText();
|
|
598
|
+
if (!text) return;
|
|
599
|
+
if (e.clipboardData) {
|
|
600
|
+
e.clipboardData.setData("text/plain", text);
|
|
601
|
+
e.preventDefault();
|
|
602
|
+
if (e.type === "cut") deleteSelectedText();
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
e.preventDefault();
|
|
606
|
+
writeClipboard(text).catch(() => {});
|
|
607
|
+
const el = document.activeElement;
|
|
608
|
+
if (e.type === "cut" && (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement)) {
|
|
609
|
+
const start = el.selectionStart ?? 0;
|
|
610
|
+
const end = el.selectionEnd ?? 0;
|
|
611
|
+
el.value = el.value.slice(0, start) + el.value.slice(end);
|
|
612
|
+
el.setSelectionRange(start, start);
|
|
613
|
+
el.dispatchEvent(new Event("input", { bubbles: true }));
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
function handlePaste(e) {
|
|
617
|
+
if (isInTerminal(e.target)) return;
|
|
618
|
+
const el = document.activeElement;
|
|
619
|
+
if (!isEditableEl(el)) return;
|
|
620
|
+
e.preventDefault();
|
|
621
|
+
readClipboard().then((text) => {
|
|
622
|
+
if (text) insertTextAtCursor(el, text);
|
|
623
|
+
}).catch(() => {});
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* 在 VSCode 扩展的跨源 iframe 内安装全局剪贴板桥接,让所有普通输入框
|
|
627
|
+
* (AI 配置、AI 对话、文件管理等)的复制 / 粘贴都走 vscode.env.clipboard。
|
|
628
|
+
* 仅在 VSCode WebView 运行时生效,Electron / 浏览器行为不变。
|
|
629
|
+
*/
|
|
630
|
+
function installVscodeClipboardBridge() {
|
|
631
|
+
if (bridgeInstalled) return;
|
|
632
|
+
if (!isVscodeThemeHost()) return;
|
|
633
|
+
bridgeInstalled = true;
|
|
634
|
+
try {
|
|
635
|
+
Object.defineProperty(navigator, "clipboard", {
|
|
636
|
+
configurable: true,
|
|
637
|
+
enumerable: true,
|
|
638
|
+
value: {
|
|
639
|
+
writeText: (t) => writeClipboard(t).then(() => void 0),
|
|
640
|
+
readText: () => readClipboard()
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
} catch {}
|
|
644
|
+
document.addEventListener("keydown", handleKeydown, true);
|
|
645
|
+
document.addEventListener("copy", handleCopyCut, true);
|
|
646
|
+
document.addEventListener("cut", handleCopyCut, true);
|
|
647
|
+
document.addEventListener("paste", handlePaste, true);
|
|
648
|
+
console.log("[aicmd] clipboard bridge installed", { hasElectronClipboard: !!window.electronAPI?.clipboard });
|
|
649
|
+
}
|
|
650
|
+
var bridgeReady, pending, reqCounter, bridgeInstalled;
|
|
651
|
+
var init_vscode_clipboard = __esmMin((() => {
|
|
652
|
+
init_vscode_theme();
|
|
653
|
+
bridgeReady = false;
|
|
654
|
+
pending = /* @__PURE__ */ new Map();
|
|
655
|
+
reqCounter = 0;
|
|
656
|
+
bridgeInstalled = false;
|
|
657
|
+
}));
|
|
658
|
+
export { writeClipboard as a, buildVscodeTerminalTheme as c, isVscodeThemeHost as d, onVscodeThemeChange as f, __toESM as g, __exportAll as h, readClipboard as i, initVscodeTheme as l, __esmMin as m, installVscodeClipboardBridge as n, TERMINAL_THEME_DARK as o, __commonJSMin as p, isVscodeWebviewRuntime as r, TERMINAL_THEME_LIGHT as s, init_vscode_clipboard as t, init_vscode_theme as u };
|