dsh-gufa-code 1.3.200 → 1.3.201

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/client.js CHANGED
@@ -16,7 +16,7 @@ const GUFA_NS = 'gufa-code'
16
16
  const G = {}
17
17
  G.NS = GUFA_NS
18
18
  /** 客户端构建标记(排查页面是否加载了新代码时看标题栏) */
19
- G.BUILD = '1.3.200'
19
+ G.BUILD = '1.3.201'
20
20
  G.PANEL_ID = 'gufa-code'
21
21
  /** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
22
22
  G.pendingEntryWorkspace = null
@@ -1164,6 +1164,11 @@ G.CSS = `
1164
1164
 
1165
1165
  /* 桌面悬浮层(摸鱼)模式:整窗半透明,透明度由 --gufa-float-alpha 控制(标题栏滑块) */
1166
1166
  html[data-gufa-float]{--gufa-float-alpha:0.55}
1167
+ /* Windows:窗口用 LAYERED 整窗 alpha 实现透明(才能跨进程穿透),页面必须完全不透明,
1168
+ 否则页面里的半透明像素会被合成成白底/黑底。滑块只改原生窗口 alpha(helper 轮询 prefs)。 */
1169
+ html[data-gufa-float][data-gufa-float-win]{--gufa-float-alpha:1}
1170
+ html[data-gufa-float][data-gufa-float-win] body{background:#0d0f13!important}
1171
+ html[data-gufa-float][data-gufa-float-win] .gufa-overlay-root{background:rgba(13,15,19,1)!important}
1167
1172
  html[data-gufa-float] body{background:transparent!important;color-scheme:dark;
1168
1173
  --dsw-alias-label-primary:#f4f1e8!important;--dsw-alias-label-secondary:rgba(244,241,232,0.72)!important;
1169
1174
  --dsw-alias-bg-base:#0d0f13!important;--dsw-alias-bg-layer-1:#14161b!important;--dsw-alias-bg-layer-2:#1a1e24!important;
@@ -12908,7 +12913,8 @@ G.GufaApp = function GufaApp(props) {
12908
12913
  })
12909
12914
  useEffect(() => {
12910
12915
  try {
12911
- document.documentElement.style.setProperty('--gufa-float-alpha', String(floatAlpha / 100))
12916
+ const winFloat = document.documentElement.hasAttribute('data-gufa-float-win')
12917
+ document.documentElement.style.setProperty('--gufa-float-alpha', winFloat ? '1' : String(floatAlpha / 100))
12912
12918
  localStorage.setItem('gufa-code:float-alpha', String(floatAlpha))
12913
12919
  } catch {
12914
12920
  /* ignore */
@@ -14099,7 +14105,12 @@ G.GufaApp = function GufaApp(props) {
14099
14105
  })()
14100
14106
  useEffect(() => {
14101
14107
  if (floatRequested !== true) return undefined
14102
- try { document.documentElement.setAttribute('data-gufa-float', '1') } catch { /* ignore */ }
14108
+ try {
14109
+ document.documentElement.setAttribute('data-gufa-float', '1')
14110
+ /* Windows:per-pixel alpha 与跨进程穿透不能兼得,改由 helper 控制整窗 alpha,
14111
+ 页面必须渲染成不透明,否则透明区域会显示成白底/黑底。 */
14112
+ if (/Win/i.test(navigator.platform || '')) document.documentElement.setAttribute('data-gufa-float-win', '1')
14113
+ } catch { /* ignore */ }
14103
14114
  const enter = (attempt) => {
14104
14115
  try {
14105
14116
  if (typeof G.mode?.get === 'function' && G.mode.get() !== true) G.mode.set(true)
@@ -16561,6 +16572,7 @@ const GUFA_PLUGIN = {
16561
16572
  }
16562
16573
  if (floatMode) {
16563
16574
  document.documentElement.setAttribute('data-gufa-float', '1')
16575
+ if (/Win/i.test(navigator.platform || '')) document.documentElement.setAttribute('data-gufa-float-win', '1')
16564
16576
  document.documentElement.setAttribute('data-gufa-booting', '1')
16565
16577
  /* 摸鱼窗口不需要皮肤:关掉皮肤插件的动画开关并移除其背景节点,
16566
16578
  否则它仍在 rAF 里持续写 body.style / 画 canvas(看不见但耗 CPU、占内存) */
@@ -39,6 +39,7 @@
39
39
  #include <cstdarg>
40
40
  #include <cstdio>
41
41
  #include <cstdlib>
42
+ #include <cstring>
42
43
  #include <ctime>
43
44
  #include <cwctype>
44
45
  #include <exception>
@@ -976,6 +977,8 @@ class FloatApp {
976
977
  void OnFollowTimer();
977
978
  void ApplyFollowFrame();
978
979
  void ApplyClickThrough();
980
+ void ApplyWindowAlpha(int percent);
981
+ void PollWindowAlpha();
979
982
  void ForwardMouseToUnderlying(UINT message, const MSLLHOOKSTRUCT* info);
980
983
  static LRESULT CALLBACK LowLevelMouseProc(int code, WPARAM wparam, LPARAM lparam);
981
984
  void OnHideDshTimer();
@@ -1050,6 +1053,7 @@ class FloatApp {
1050
1053
  bool hideDshDone_ = false;
1051
1054
  bool clickThrough_ = false;
1052
1055
  bool clickThroughHotkey_ = false;
1056
+ int windowAlphaPercent_ = 55;
1053
1057
  HHOOK mouseHook_ = nullptr;
1054
1058
  bool mouseHookInstalled_ = false;
1055
1059
  HWND forwardedTarget_ = nullptr;
@@ -1371,9 +1375,10 @@ bool FloatApp::CreateMainWindow() {
1371
1375
  bool FloatApp::CreateHostWindow(const RECT& rect, bool composition) {
1372
1376
  hostingMode_ = composition ? HostingMode::Composition : HostingMode::Windowed;
1373
1377
  DWORD extendedStyle = WS_EX_TOPMOST | WS_EX_TOOLWINDOW;
1374
- /* 透明视觉继续用 NORD + DComp(per-pixel alpha 正确);穿透改为鼠标钩子转发,
1375
- 不再用 LAYERED 改变窗口合成路径(否则透明白底/黑底,摸鱼透明度会乱)。 */
1376
- if (composition) extendedStyle |= WS_EX_NOREDIRECTIONBITMAP;
1378
+ /* Windows 上 WS_EX_NOREDIRECTIONBITMAP 让 per-pixel alpha 正常,但无法跨进程穿透。
1379
+ 这里改用 WS_EX_LAYERED + DComp:页面在 Windows 渲染为不透明,透明由整窗 alpha 控制,
1380
+ 穿透直接翻转 WS_EX_TRANSPARENT —— 点击/拖拽/右键/滚轮全部原生透传到下层窗口,无钩子无闪烁。 */
1381
+ if (composition) extendedStyle |= WS_EX_LAYERED;
1377
1382
  const DWORD style = WS_POPUP | WS_THICKFRAME | WS_CLIPCHILDREN;
1378
1383
  hwnd_ = CreateWindowExW(extendedStyle, kMainWindowClass, kWindowTitle, style, rect.left,
1379
1384
  rect.top, rect.right - rect.left, rect.bottom - rect.top, nullptr,
@@ -1387,6 +1392,10 @@ bool FloatApp::CreateHostWindow(const RECT& rect, bool composition) {
1387
1392
  LogFmt(L"main-window-created composition=%d rect=(%ld,%ld)-(%ld,%ld) dpi=%u",
1388
1393
  composition ? 1 : 0, static_cast<long>(rect.left), static_cast<long>(rect.top),
1389
1394
  static_cast<long>(rect.right), static_cast<long>(rect.bottom), WindowDpi(hwnd_));
1395
+ if (composition) {
1396
+ windowAlphaPercent_ = payload_.alpha >= 20 && payload_.alpha <= 100 ? payload_.alpha : 55;
1397
+ ApplyWindowAlpha(windowAlphaPercent_);
1398
+ }
1390
1399
  if (RegisterHotKey(hwnd_, kHotkeyClickThrough, MOD_CONTROL | MOD_ALT | MOD_SHIFT, 'G')) {
1391
1400
  clickThroughHotkey_ = true;
1392
1401
  Log(L"click-through-hotkey=registered Ctrl+Alt+Shift+G");
@@ -1973,6 +1982,7 @@ void FloatApp::DeleteControlFile() {
1973
1982
 
1974
1983
  void FloatApp::OnControlTimer() {
1975
1984
  if (exiting_) return;
1985
+ PollWindowAlpha();
1976
1986
  RaiseStrip();
1977
1987
  if (!payload_.controlPath.empty()) {
1978
1988
  const DWORD attributes = GetFileAttributesW(payload_.controlPath.c_str());
@@ -2549,28 +2559,60 @@ void FloatApp::ToggleClickThrough() {
2549
2559
 
2550
2560
  void FloatApp::ApplyClickThrough() {
2551
2561
  if (hwnd_ == nullptr) return;
2552
- /* 保持 NORD+DComp 的 per-pixel 透明,不切 LAYERED。
2553
- 穿透通过 WH_MOUSE_LL 钩子把鼠标消息转发给下层窗口实现(跨进程唯一不破坏透明的方式):
2554
- - 点击/滚轮:临时隐藏自身 → WindowFromPoint 找下层窗口 → 显示自身 → SendMessage 转发;
2555
- - 左键按住拖动期间保持隐藏,松开后恢复,drag 直接作用在下层 App。 */
2556
- if (clickThrough_ && !mouseHookInstalled_) {
2557
- mouseHook_ = SetWindowsHookExW(WH_MOUSE_LL, LowLevelMouseProc, g_instance, 0);
2558
- mouseHookInstalled_ = mouseHook_ != nullptr;
2559
- if (!mouseHookInstalled_) {
2560
- LogFmt(L"click-through-hook=register-failed err=%lu", static_cast<unsigned long>(GetLastError()));
2561
- clickThrough_ = false;
2562
- }
2563
- } else if (!clickThrough_ && mouseHookInstalled_) {
2564
- if (mouseHook_ != nullptr) UnhookWindowsHookEx(mouseHook_);
2565
- mouseHook_ = nullptr;
2566
- mouseHookInstalled_ = false;
2567
- forwardedTarget_ = nullptr;
2568
- forwardedLeftDown_ = false;
2569
- if (IsWindowVisible(hwnd_) == FALSE) ShowWindow(hwnd_, SW_SHOWNOACTIVATE);
2570
- }
2571
- LogFmt(L"click-through=%d mode=%s hook=%d", clickThrough_ ? 1 : 0,
2562
+ /* 原生穿透:WS_EX_LAYERED 常驻(从创建时就有),只翻转 WS_EX_TRANSPARENT。
2563
+ 这样鼠标的点击/拖动/右键/滚轮全部由系统直接送给下层窗口,不再需要鼠标钩子,
2564
+ 也不会出现隐藏悬浮层造成的闪烁。 */
2565
+ LONG_PTR exStyle = GetWindowLongPtrW(hwnd_, GWL_EXSTYLE);
2566
+ const LONG_PTR next = clickThrough_ ? (exStyle | WS_EX_TRANSPARENT)
2567
+ : (exStyle & ~static_cast<LONG_PTR>(WS_EX_TRANSPARENT));
2568
+ if (next != exStyle) {
2569
+ SetWindowLongPtrW(hwnd_, GWL_EXSTYLE, next);
2570
+ SetWindowPos(hwnd_, nullptr, 0, 0, 0, 0,
2571
+ SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
2572
+ }
2573
+ LogFmt(L"click-through=%d mode=%s layered=%d styleTransparent=%d", clickThrough_ ? 1 : 0,
2572
2574
  hostingMode_ == HostingMode::Composition ? L"composition" : L"windowed",
2573
- mouseHookInstalled_ ? 1 : 0);
2575
+ (GetWindowLongPtrW(hwnd_, GWL_EXSTYLE) & WS_EX_LAYERED) != 0 ? 1 : 0,
2576
+ (GetWindowLongPtrW(hwnd_, GWL_EXSTYLE) & WS_EX_TRANSPARENT) != 0 ? 1 : 0);
2577
+ }
2578
+
2579
+ void FloatApp::ApplyWindowAlpha(int percent) {
2580
+ if (hostingMode_ != HostingMode::Composition || hwnd_ == nullptr) return;
2581
+ const int clamped = percent < 20 ? 20 : (percent > 100 ? 100 : percent);
2582
+ const BYTE alpha = static_cast<BYTE>((clamped * 255 + 50) / 100);
2583
+ SetLayeredWindowAttributes(hwnd_, 0, alpha, LWA_ALPHA);
2584
+ windowAlphaPercent_ = clamped;
2585
+ }
2586
+
2587
+ void FloatApp::PollWindowAlpha() {
2588
+ if (hostingMode_ != HostingMode::Composition || hwnd_ == nullptr) return;
2589
+ wchar_t profile[32768];
2590
+ profile[0] = L'\0';
2591
+ const DWORD len = GetEnvironmentVariableW(L"USERPROFILE", profile, static_cast<DWORD>(_countof(profile)));
2592
+ if (len == 0 || len >= _countof(profile)) return;
2593
+ const std::wstring path = std::wstring(profile, len) + L"\\.dsh\\gufa-float-prefs.json";
2594
+ HANDLE file = CreateFileW(path.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
2595
+ nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
2596
+ if (file == INVALID_HANDLE_VALUE) return;
2597
+ char buffer[4096];
2598
+ DWORD read = 0;
2599
+ const BOOL ok = ReadFile(file, buffer, static_cast<DWORD>(_countof(buffer) - 1), &read, nullptr);
2600
+ CloseHandle(file);
2601
+ if (ok == FALSE || read == 0) return;
2602
+ buffer[read] = '\0';
2603
+ const char* key = std::strstr(buffer, "\"alpha\"");
2604
+ if (key == nullptr) return;
2605
+ key += 7;
2606
+ while (*key == ' ' || *key == ':' || *key == '\t') ++key;
2607
+ int value = 0;
2608
+ bool hasValue = false;
2609
+ while (*key >= '0' && *key <= '9') {
2610
+ value = value * 10 + (*key - '0');
2611
+ hasValue = true;
2612
+ ++key;
2613
+ }
2614
+ if (!hasValue) return;
2615
+ if (value != windowAlphaPercent_) ApplyWindowAlpha(value);
2574
2616
  }
2575
2617
 
2576
2618
  void FloatApp::ForwardMouseToUnderlying(UINT message, const MSLLHOOKSTRUCT* info) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-gufa-code",
3
- "version": "1.3.200",
3
+ "version": "1.3.201",
4
4
  "description": "古法编程 · AI 辅助:一键把 DSH 主面板变成 VS Code 风格 IDE(Monaco 编辑器、文件树、Git、SSH、真实终端 + 右侧官方会话);主张亲手写、每个改动心中有数,AI 是助理、你是第一责任人",
5
5
  "icon": "icon.svg",
6
6
  "keywords": [
@@ -1156,6 +1156,11 @@ G.CSS = `
1156
1156
 
1157
1157
  /* 桌面悬浮层(摸鱼)模式:整窗半透明,透明度由 --gufa-float-alpha 控制(标题栏滑块) */
1158
1158
  html[data-gufa-float]{--gufa-float-alpha:0.55}
1159
+ /* Windows:窗口用 LAYERED 整窗 alpha 实现透明(才能跨进程穿透),页面必须完全不透明,
1160
+ 否则页面里的半透明像素会被合成成白底/黑底。滑块只改原生窗口 alpha(helper 轮询 prefs)。 */
1161
+ html[data-gufa-float][data-gufa-float-win]{--gufa-float-alpha:1}
1162
+ html[data-gufa-float][data-gufa-float-win] body{background:#0d0f13!important}
1163
+ html[data-gufa-float][data-gufa-float-win] .gufa-overlay-root{background:rgba(13,15,19,1)!important}
1159
1164
  html[data-gufa-float] body{background:transparent!important;color-scheme:dark;
1160
1165
  --dsw-alias-label-primary:#f4f1e8!important;--dsw-alias-label-secondary:rgba(244,241,232,0.72)!important;
1161
1166
  --dsw-alias-bg-base:#0d0f13!important;--dsw-alias-bg-layer-1:#14161b!important;--dsw-alias-bg-layer-2:#1a1e24!important;
@@ -276,7 +276,8 @@ G.GufaApp = function GufaApp(props) {
276
276
  })
277
277
  useEffect(() => {
278
278
  try {
279
- document.documentElement.style.setProperty('--gufa-float-alpha', String(floatAlpha / 100))
279
+ const winFloat = document.documentElement.hasAttribute('data-gufa-float-win')
280
+ document.documentElement.style.setProperty('--gufa-float-alpha', winFloat ? '1' : String(floatAlpha / 100))
280
281
  localStorage.setItem('gufa-code:float-alpha', String(floatAlpha))
281
282
  } catch {
282
283
  /* ignore */
@@ -1467,7 +1468,12 @@ G.GufaApp = function GufaApp(props) {
1467
1468
  })()
1468
1469
  useEffect(() => {
1469
1470
  if (floatRequested !== true) return undefined
1470
- try { document.documentElement.setAttribute('data-gufa-float', '1') } catch { /* ignore */ }
1471
+ try {
1472
+ document.documentElement.setAttribute('data-gufa-float', '1')
1473
+ /* Windows:per-pixel alpha 与跨进程穿透不能兼得,改由 helper 控制整窗 alpha,
1474
+ 页面必须渲染成不透明,否则透明区域会显示成白底/黑底。 */
1475
+ if (/Win/i.test(navigator.platform || '')) document.documentElement.setAttribute('data-gufa-float-win', '1')
1476
+ } catch { /* ignore */ }
1471
1477
  const enter = (attempt) => {
1472
1478
  try {
1473
1479
  if (typeof G.mode?.get === 'function' && G.mode.get() !== true) G.mode.set(true)
@@ -230,6 +230,7 @@ const GUFA_PLUGIN = {
230
230
  }
231
231
  if (floatMode) {
232
232
  document.documentElement.setAttribute('data-gufa-float', '1')
233
+ if (/Win/i.test(navigator.platform || '')) document.documentElement.setAttribute('data-gufa-float-win', '1')
233
234
  document.documentElement.setAttribute('data-gufa-booting', '1')
234
235
  /* 摸鱼窗口不需要皮肤:关掉皮肤插件的动画开关并移除其背景节点,
235
236
  否则它仍在 rAF 里持续写 body.style / 画 canvas(看不见但耗 CPU、占内存) */