dsh-gufa-code 1.3.50 → 1.3.52
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 +6 -1
- package/client.js +77 -1
- package/desktop/float/GufaFloat.m +12 -0
- package/desktop/float/bin/gufa-float-macos-arm64 +0 -0
- package/desktop/float/bin/gufa-float-macos-universal +0 -0
- package/desktop/float/bin/gufa-float-macos-x64 +0 -0
- package/desktop/float/bin/linux-x64/gufa-float-linux +0 -0
- package/desktop/float/bin/win-x64/gufa-float-win.exe +0 -0
- package/desktop/float/linux/README-LINUX.md +19 -6
- package/desktop/float/linux/main.c +102 -15
- package/desktop/float/win/main.cpp +340 -29
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/Info.plist +2 -2
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/MacOS/gufa-float +0 -0
- package/docs/FLOAT-ACCEPTANCE.md +85 -0
- package/docs/RELEASE.md +32 -0
- package/host/dev.js +177 -5
- package/package.json +1 -1
- package/scripts/build-float-macos.sh +1 -0
- package/src/client/00-core.js +3 -0
- package/src/client/90-app.js +73 -0
|
@@ -102,6 +102,19 @@ std::string WideToUtf8(const std::wstring& text) {
|
|
|
102
102
|
return result;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
std::wstring Utf8ToWide(const std::string& text) {
|
|
106
|
+
if (text.empty()) return std::wstring();
|
|
107
|
+
const int length = MultiByteToWideChar(CP_UTF8, 0, text.c_str(),
|
|
108
|
+
static_cast<int>(text.size()), nullptr, 0);
|
|
109
|
+
if (length <= 0) return std::wstring();
|
|
110
|
+
std::wstring result(static_cast<std::size_t>(length), L'\0');
|
|
111
|
+
MultiByteToWideChar(CP_UTF8, 0, text.c_str(), static_cast<int>(text.size()),
|
|
112
|
+
&result[0], length);
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
void LogFmt(const wchar_t* format, ...); // 定义在后面;WriteFileUtf8 诊断用
|
|
117
|
+
|
|
105
118
|
void WriteStdout(const std::wstring& text) {
|
|
106
119
|
const std::string utf8 = WideToUtf8(text);
|
|
107
120
|
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
@@ -110,6 +123,203 @@ void WriteStdout(const std::wstring& text) {
|
|
|
110
123
|
WriteFile(handle, utf8.data(), static_cast<DWORD>(utf8.size()), &written, nullptr);
|
|
111
124
|
}
|
|
112
125
|
|
|
126
|
+
/* 把文本以 UTF-8 覆盖写入文件(ciProbe 结果文件用)。写失败返回 false,不影响主流程。 */
|
|
127
|
+
bool WriteFileUtf8(const std::wstring& path, const std::wstring& text) {
|
|
128
|
+
if (path.empty()) {
|
|
129
|
+
LogFmt(L"write-file-utf8 skipped: empty path");
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
const std::string utf8 = WideToUtf8(text);
|
|
133
|
+
HANDLE handle = CreateFileW(path.c_str(), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS,
|
|
134
|
+
FILE_ATTRIBUTE_NORMAL, nullptr);
|
|
135
|
+
if (handle == INVALID_HANDLE_VALUE) {
|
|
136
|
+
LogFmt(L"write-file-utf8 open-failed path=%s err=%lu", path.c_str(),
|
|
137
|
+
static_cast<unsigned long>(GetLastError()));
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
DWORD written = 0;
|
|
141
|
+
const BOOL ok = WriteFile(handle, utf8.data(), static_cast<DWORD>(utf8.size()), &written,
|
|
142
|
+
nullptr);
|
|
143
|
+
const DWORD writeError = ok != FALSE ? 0 : GetLastError();
|
|
144
|
+
CloseHandle(handle);
|
|
145
|
+
if (ok == FALSE || written != static_cast<DWORD>(utf8.size())) {
|
|
146
|
+
LogFmt(L"write-file-utf8 write-failed path=%s err=%lu written=%lu", path.c_str(),
|
|
147
|
+
static_cast<unsigned long>(writeError), static_cast<unsigned long>(written));
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/* HRESULT -> 8 位大写十六进制(ASCII,可直接放进 JSON reason 字段)。 */
|
|
154
|
+
std::wstring HexHresult(HRESULT value) {
|
|
155
|
+
wchar_t buffer[16];
|
|
156
|
+
buffer[0] = L'\0';
|
|
157
|
+
_snwprintf_s(buffer, _countof(buffer), _TRUNCATE, L"%08lX",
|
|
158
|
+
static_cast<unsigned long>(value));
|
|
159
|
+
return std::wstring(buffer);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* ciProbe 结束时输出的单行 JSON(stdout 与 ciProbeOut 文件内容一致)。
|
|
163
|
+
* reason 仅用于失败诊断,先过滤成 JSON 安全字符。 */
|
|
164
|
+
std::wstring BuildCiProbeLine(bool ok, bool urlLoaded, const std::wstring& reason) {
|
|
165
|
+
std::wstring sanitized;
|
|
166
|
+
for (const wchar_t c : reason) {
|
|
167
|
+
const bool safe = c >= 0x20 && c <= 0x7E && c != L'"' && c != L'\\';
|
|
168
|
+
sanitized.push_back(safe ? c : L'_');
|
|
169
|
+
}
|
|
170
|
+
std::wstring line = L"{\"ok\":";
|
|
171
|
+
line += ok ? L"true" : L"false";
|
|
172
|
+
line += L",\"platform\":\"win32\",\"urlLoaded\":";
|
|
173
|
+
line += urlLoaded ? L"true" : L"false";
|
|
174
|
+
if (!sanitized.empty()) {
|
|
175
|
+
line += L",\"reason\":\"";
|
|
176
|
+
line += sanitized;
|
|
177
|
+
line += L"\"";
|
|
178
|
+
}
|
|
179
|
+
line += L"}";
|
|
180
|
+
return line;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/* 读取环境变量 GUFA_FLOAT_PAYLOAD(优先 Unicode 环境块;失败再按 UTF-8 读 ANSI 版)。
|
|
184
|
+
* CI 可用 Start-Process + 环境变量传 payload,绕开 PowerShell 对含引号参数的拼接问题。 */
|
|
185
|
+
std::wstring ReadEnvironmentPayload() {
|
|
186
|
+
const wchar_t* kName = L"GUFA_FLOAT_PAYLOAD";
|
|
187
|
+
wchar_t wideBuffer[32768];
|
|
188
|
+
wideBuffer[0] = L'\0';
|
|
189
|
+
const DWORD wideLength =
|
|
190
|
+
GetEnvironmentVariableW(kName, wideBuffer, static_cast<DWORD>(_countof(wideBuffer)));
|
|
191
|
+
if (wideLength > 0 && wideLength < _countof(wideBuffer)) {
|
|
192
|
+
return std::wstring(wideBuffer, wideLength);
|
|
193
|
+
}
|
|
194
|
+
char narrowBuffer[32768];
|
|
195
|
+
narrowBuffer[0] = '\0';
|
|
196
|
+
const DWORD narrowLength =
|
|
197
|
+
GetEnvironmentVariableA("GUFA_FLOAT_PAYLOAD", narrowBuffer, static_cast<DWORD>(_countof(narrowBuffer)));
|
|
198
|
+
if (narrowLength > 0 && narrowLength < _countof(narrowBuffer)) {
|
|
199
|
+
return Utf8ToWide(std::string(narrowBuffer, narrowLength));
|
|
200
|
+
}
|
|
201
|
+
return std::wstring();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
std::wstring ToLowerCopy(const std::wstring& text) {
|
|
205
|
+
std::wstring result = text;
|
|
206
|
+
for (wchar_t& c : result) c = static_cast<wchar_t>(std::towlower(c));
|
|
207
|
+
return result;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
bool IsAsciiWhitespace(wchar_t c) {
|
|
211
|
+
return c == L' ' || c == L'\t' || c == L'\r' || c == L'\n';
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
bool HexValue(wchar_t c, unsigned int* value) {
|
|
215
|
+
if (value == nullptr) return false;
|
|
216
|
+
if (c >= L'0' && c <= L'9') {
|
|
217
|
+
*value = static_cast<unsigned int>(c - L'0');
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
if (c >= L'a' && c <= L'f') {
|
|
221
|
+
*value = static_cast<unsigned int>(c - L'a' + 10);
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
if (c >= L'A' && c <= L'F') {
|
|
225
|
+
*value = static_cast<unsigned int>(c - L'A' + 10);
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* 从可能被 shell 拼坏(引号被吃掉)的 JSON 文本里宽松提取一个字符串字段。
|
|
232
|
+
* 只用于 ciProbeOut 兜底:合法 JSON 走正常解析,这里只是保证失败时也能留下探针文件。 */
|
|
233
|
+
std::wstring ExtractStringFieldLoose(const std::wstring& text, const std::wstring& key) {
|
|
234
|
+
if (text.empty() || key.empty()) return std::wstring();
|
|
235
|
+
const std::size_t found = ToLowerCopy(text).find(ToLowerCopy(key));
|
|
236
|
+
if (found == std::wstring::npos) return std::wstring();
|
|
237
|
+
std::size_t position = found + key.size();
|
|
238
|
+
while (position < text.size() && IsAsciiWhitespace(text[position])) ++position;
|
|
239
|
+
if (position < text.size() && text[position] == L'"') ++position; // 合法 JSON 里键的收尾引号
|
|
240
|
+
while (position < text.size() && IsAsciiWhitespace(text[position])) ++position;
|
|
241
|
+
if (position < text.size() && (text[position] == L':' || text[position] == L'=')) ++position;
|
|
242
|
+
while (position < text.size() && IsAsciiWhitespace(text[position])) ++position;
|
|
243
|
+
if (position < text.size() && text[position] == L'"') {
|
|
244
|
+
++position;
|
|
245
|
+
std::wstring result;
|
|
246
|
+
while (position < text.size()) {
|
|
247
|
+
const wchar_t c = text[position++];
|
|
248
|
+
if (c == L'"') return result;
|
|
249
|
+
if (c != L'\\' || position >= text.size()) {
|
|
250
|
+
result.push_back(c);
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
const wchar_t escape = text[position++];
|
|
254
|
+
switch (escape) {
|
|
255
|
+
case L'\\':
|
|
256
|
+
result.push_back(L'\\');
|
|
257
|
+
break;
|
|
258
|
+
case L'"':
|
|
259
|
+
result.push_back(L'"');
|
|
260
|
+
break;
|
|
261
|
+
case L'/':
|
|
262
|
+
result.push_back(L'/');
|
|
263
|
+
break;
|
|
264
|
+
case L'b':
|
|
265
|
+
result.push_back(L'\b');
|
|
266
|
+
break;
|
|
267
|
+
case L'f':
|
|
268
|
+
result.push_back(L'\f');
|
|
269
|
+
break;
|
|
270
|
+
case L'n':
|
|
271
|
+
result.push_back(L'\n');
|
|
272
|
+
break;
|
|
273
|
+
case L'r':
|
|
274
|
+
result.push_back(L'\r');
|
|
275
|
+
break;
|
|
276
|
+
case L't':
|
|
277
|
+
result.push_back(L'\t');
|
|
278
|
+
break;
|
|
279
|
+
case L'u': {
|
|
280
|
+
unsigned int code = 0;
|
|
281
|
+
bool ok = position + 4 <= text.size();
|
|
282
|
+
for (int i = 0; ok && i < 4; ++i) {
|
|
283
|
+
unsigned int digit = 0;
|
|
284
|
+
ok = HexValue(text[position + static_cast<std::size_t>(i)], &digit);
|
|
285
|
+
code = (code << 4) | digit;
|
|
286
|
+
}
|
|
287
|
+
if (ok) {
|
|
288
|
+
position += 4;
|
|
289
|
+
result.push_back(static_cast<wchar_t>(code));
|
|
290
|
+
} else {
|
|
291
|
+
result.push_back(L'u');
|
|
292
|
+
}
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
default:
|
|
296
|
+
result.push_back(escape);
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return result;
|
|
301
|
+
}
|
|
302
|
+
// 引号已被 shell 吃掉:读到 JSON 分隔符为止;若原文是 JSON 转义(\\)则还原。
|
|
303
|
+
const std::size_t start = position;
|
|
304
|
+
while (position < text.size()) {
|
|
305
|
+
const wchar_t c = text[position];
|
|
306
|
+
if (c == L',' || c == L'}' || c == L']' || IsAsciiWhitespace(c)) break;
|
|
307
|
+
++position;
|
|
308
|
+
}
|
|
309
|
+
const std::wstring raw = text.substr(start, position - start);
|
|
310
|
+
if (raw.find(L"\\\\") == std::wstring::npos) return raw;
|
|
311
|
+
std::wstring unescaped;
|
|
312
|
+
for (std::size_t i = 0; i < raw.size(); ++i) {
|
|
313
|
+
if (raw[i] == L'\\' && i + 1 < raw.size()) {
|
|
314
|
+
unescaped.push_back(raw[i + 1]);
|
|
315
|
+
++i;
|
|
316
|
+
} else {
|
|
317
|
+
unescaped.push_back(raw[i]);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return unescaped;
|
|
321
|
+
}
|
|
322
|
+
|
|
113
323
|
std::wstring GetTempDirectory() {
|
|
114
324
|
wchar_t buffer[32768];
|
|
115
325
|
buffer[0] = L'\0';
|
|
@@ -420,6 +630,7 @@ struct FloatPayload {
|
|
|
420
630
|
std::wstring build;
|
|
421
631
|
std::wstring selftest;
|
|
422
632
|
std::wstring followTitle;
|
|
633
|
+
std::wstring ciProbeOut;
|
|
423
634
|
bool hasFollow = false;
|
|
424
635
|
DWORD followPid = 0;
|
|
425
636
|
bool hasState = false;
|
|
@@ -457,6 +668,7 @@ bool ParsePayloadJson(const std::wstring& text, FloatPayload* payload, std::wstr
|
|
|
457
668
|
readString(L"controlPath", &payload->controlPath);
|
|
458
669
|
readString(L"build", &payload->build);
|
|
459
670
|
readString(L"selftest", &payload->selftest);
|
|
671
|
+
readString(L"ciProbeOut", &payload->ciProbeOut);
|
|
460
672
|
|
|
461
673
|
const gufa::JsonValue* follow = root.Find(L"follow");
|
|
462
674
|
if (follow != nullptr && follow->IsObject()) {
|
|
@@ -697,6 +909,9 @@ class FloatApp {
|
|
|
697
909
|
int RunMessageLoop();
|
|
698
910
|
void RequestExit(int exitCode);
|
|
699
911
|
bool IsCiProbe() const { return payload_.ciProbe; }
|
|
912
|
+
std::wstring CiProbeOutputPath() const { return payload_.ciProbeOut; }
|
|
913
|
+
/* 兜底:ciProbe 进程即将结束但还没写结果时,补写一个 ok:false 的探针文件。 */
|
|
914
|
+
void EnsureCiProbeResultWritten(const std::wstring& reason);
|
|
700
915
|
|
|
701
916
|
static LRESULT CALLBACK MainWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
|
|
702
917
|
static LRESULT CALLBACK StripWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
|
|
@@ -745,8 +960,9 @@ class FloatApp {
|
|
|
745
960
|
void OnPageProbeTimer();
|
|
746
961
|
void OnSelftestTimer();
|
|
747
962
|
void HandleWebViewEnvironmentFailure(HRESULT errorCode);
|
|
963
|
+
void WriteCiProbeOutput(bool ok, bool urlLoaded, const std::wstring& reason);
|
|
748
964
|
void FinishProbe(bool loaded);
|
|
749
|
-
void FinishProbeFailure();
|
|
965
|
+
void FinishProbeFailure(const std::wstring& reason);
|
|
750
966
|
|
|
751
967
|
void DoGracefulExit();
|
|
752
968
|
void OnWindowDestroyed();
|
|
@@ -1082,8 +1298,12 @@ int FloatApp::RunMessageLoop() {
|
|
|
1082
1298
|
|
|
1083
1299
|
void FloatApp::RequestExit(int exitCode) {
|
|
1084
1300
|
exitCode_ = exitCode;
|
|
1085
|
-
if (exiting_)
|
|
1301
|
+
if (exiting_) {
|
|
1302
|
+
LogFmt(L"request-exit-ignored code=%d", exitCode);
|
|
1303
|
+
return;
|
|
1304
|
+
}
|
|
1086
1305
|
exiting_ = true;
|
|
1306
|
+
LogFmt(L"request-exit code=%d", exitCode);
|
|
1087
1307
|
if (hwnd_ != nullptr) {
|
|
1088
1308
|
PostMessageW(hwnd_, kMsgExitGraceful, 0, 0);
|
|
1089
1309
|
} else {
|
|
@@ -1239,7 +1459,7 @@ void FloatApp::OnTimer(UINT_PTR timerId) {
|
|
|
1239
1459
|
case kTimerProbeWatchdog:
|
|
1240
1460
|
KillTimer(hwnd_, kTimerProbeWatchdog);
|
|
1241
1461
|
Log(L"ciprobe-watchdog-timeout");
|
|
1242
|
-
FinishProbeFailure();
|
|
1462
|
+
FinishProbeFailure(L"ci-probe-watchdog-timeout");
|
|
1243
1463
|
break;
|
|
1244
1464
|
case kTimerPageProbe:
|
|
1245
1465
|
KillTimer(hwnd_, kTimerPageProbe);
|
|
@@ -1723,26 +1943,45 @@ void FloatApp::OnSelftestTimer() {
|
|
|
1723
1943
|
.Get());
|
|
1724
1944
|
}
|
|
1725
1945
|
|
|
1946
|
+
void FloatApp::WriteCiProbeOutput(bool ok, bool urlLoaded, const std::wstring& reason) {
|
|
1947
|
+
const std::wstring line = BuildCiProbeLine(ok, urlLoaded, reason);
|
|
1948
|
+
WriteStdout(line + L"\n");
|
|
1949
|
+
LogFmt(L"ciprobe-result ok=%d urlLoaded=%d reason=%s", ok ? 1 : 0, urlLoaded ? 1 : 0,
|
|
1950
|
+
reason.c_str());
|
|
1951
|
+
if (payload_.ciProbeOut.empty()) {
|
|
1952
|
+
Log(L"ciprobe-out path-empty");
|
|
1953
|
+
return;
|
|
1954
|
+
}
|
|
1955
|
+
const bool wrote = WriteFileUtf8(payload_.ciProbeOut, line + L"\n");
|
|
1956
|
+
LogFmt(L"ciprobe-out file=%s wrote=%d", payload_.ciProbeOut.c_str(), wrote ? 1 : 0);
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
void FloatApp::EnsureCiProbeResultWritten(const std::wstring& reason) {
|
|
1960
|
+
if (!payload_.ciProbe || ciProbeFinished_) return;
|
|
1961
|
+
ciProbeFinished_ = true;
|
|
1962
|
+
LogFmt(L"ciprobe-result-missing reason=%s", reason.c_str());
|
|
1963
|
+
WriteCiProbeOutput(false, false, reason);
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1726
1966
|
void FloatApp::FinishProbe(bool loaded) {
|
|
1727
1967
|
if (ciProbeFinished_) return;
|
|
1728
1968
|
ciProbeFinished_ = true;
|
|
1729
|
-
WriteStdout(loaded ? L"{\"ok\":true,\"platform\":\"win32\",\"urlLoaded\":true}\n"
|
|
1730
|
-
: L"{\"ok\":true,\"platform\":\"win32\",\"urlLoaded\":false}\n");
|
|
1731
1969
|
LogFmt(L"ciprobe-finished loaded=%d", loaded ? 1 : 0);
|
|
1970
|
+
WriteCiProbeOutput(true, loaded, std::wstring());
|
|
1732
1971
|
RequestExit(0);
|
|
1733
1972
|
}
|
|
1734
1973
|
|
|
1735
|
-
void FloatApp::FinishProbeFailure() {
|
|
1974
|
+
void FloatApp::FinishProbeFailure(const std::wstring& reason) {
|
|
1736
1975
|
if (ciProbeFinished_) return;
|
|
1737
1976
|
ciProbeFinished_ = true;
|
|
1738
|
-
|
|
1739
|
-
|
|
1977
|
+
LogFmt(L"ciprobe-failed reason=%s", reason.c_str());
|
|
1978
|
+
WriteCiProbeOutput(false, false, reason);
|
|
1740
1979
|
RequestExit(1);
|
|
1741
1980
|
}
|
|
1742
1981
|
|
|
1743
1982
|
void FloatApp::HandleWebViewEnvironmentFailure(HRESULT errorCode) {
|
|
1744
1983
|
if (payload_.ciProbe) {
|
|
1745
|
-
FinishProbeFailure();
|
|
1984
|
+
FinishProbeFailure(L"webview2-environment-failed hr=0x" + HexHresult(errorCode));
|
|
1746
1985
|
return;
|
|
1747
1986
|
}
|
|
1748
1987
|
if (exiting_) return;
|
|
@@ -1872,42 +2111,99 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE previousInstance, PWSTR comman
|
|
|
1872
2111
|
InstallCrashHandlers();
|
|
1873
2112
|
|
|
1874
2113
|
int argumentCount = 0;
|
|
1875
|
-
LPWSTR*
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
2114
|
+
LPWSTR* rawArguments = CommandLineToArgvW(GetCommandLineW(), &argumentCount);
|
|
2115
|
+
std::wstring firstArgument;
|
|
2116
|
+
if (rawArguments == nullptr) {
|
|
2117
|
+
Log(L"commandline-parse-failed (will try GUFA_FLOAT_PAYLOAD)");
|
|
2118
|
+
} else {
|
|
2119
|
+
if (argumentCount > 1) firstArgument = std::wstring(rawArguments[1]);
|
|
2120
|
+
LocalFree(rawArguments);
|
|
2121
|
+
rawArguments = nullptr;
|
|
1879
2122
|
}
|
|
1880
|
-
|
|
1881
|
-
argumentCount > 1 ? std::wstring(arguments[1]) : std::wstring();
|
|
2123
|
+
|
|
1882
2124
|
if (firstArgument == L"--version" || firstArgument == L"-v") {
|
|
1883
|
-
|
|
1884
|
-
|
|
2125
|
+
const std::wstring version = L"gufa-float-win 1.0.0";
|
|
2126
|
+
WriteStdout(version + L"\n");
|
|
2127
|
+
LogFmt(L"--version %s", version.c_str());
|
|
1885
2128
|
return 0;
|
|
1886
2129
|
}
|
|
1887
2130
|
if (firstArgument == L"--help" || firstArgument == L"-h" || firstArgument == L"/?") {
|
|
1888
2131
|
WriteStdout(L"gufa-float-win — Windows 悬浮层 helper(由 DSH Host 自动启动)\n"
|
|
1889
2132
|
L"用法: gufa-float-win '<payload-json>'\n"
|
|
1890
|
-
L" gufa-float-win --version\n"
|
|
1891
|
-
|
|
2133
|
+
L" gufa-float-win --version\n"
|
|
2134
|
+
L"环境变量: GUFA_FLOAT_PAYLOAD=<payload-json>(无参数时的 payload 兜底)\n");
|
|
2135
|
+
Log(L"--help");
|
|
1892
2136
|
return 0;
|
|
1893
2137
|
}
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
2138
|
+
|
|
2139
|
+
// payload 来源:argv[1] 优先;没有或解析失败时回退环境变量 GUFA_FLOAT_PAYLOAD。
|
|
2140
|
+
// CI 用 Start-Process + 环境变量传 JSON,可绕开 PowerShell 对含引号参数的拼接问题。
|
|
2141
|
+
std::wstring argumentPayload = firstArgument;
|
|
2142
|
+
if (argumentPayload == L"--ci-probe") argumentPayload = L"{\"ciProbe\":true}";
|
|
2143
|
+
const std::wstring environmentPayload = ReadEnvironmentPayload();
|
|
2144
|
+
|
|
2145
|
+
FloatPayload selectedPayload;
|
|
2146
|
+
std::wstring payloadText;
|
|
2147
|
+
std::wstring payloadSource;
|
|
2148
|
+
if (!argumentPayload.empty()) {
|
|
2149
|
+
FloatPayload candidate;
|
|
2150
|
+
std::wstring parseError;
|
|
2151
|
+
if (ParsePayloadJson(argumentPayload, &candidate, &parseError) &&
|
|
2152
|
+
ValidatePayload(candidate, &parseError)) {
|
|
2153
|
+
selectedPayload = candidate;
|
|
2154
|
+
payloadText = argumentPayload;
|
|
2155
|
+
payloadSource = L"argv";
|
|
2156
|
+
} else {
|
|
2157
|
+
LogFmt(L"payload-argv-invalid reason=%s", parseError.c_str());
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
if (payloadText.empty() && !environmentPayload.empty()) {
|
|
2161
|
+
FloatPayload candidate;
|
|
2162
|
+
std::wstring parseError;
|
|
2163
|
+
if (ParsePayloadJson(environmentPayload, &candidate, &parseError) &&
|
|
2164
|
+
ValidatePayload(candidate, &parseError)) {
|
|
2165
|
+
selectedPayload = candidate;
|
|
2166
|
+
payloadText = environmentPayload;
|
|
2167
|
+
payloadSource = L"env:GUFA_FLOAT_PAYLOAD";
|
|
2168
|
+
} else {
|
|
2169
|
+
LogFmt(L"payload-env-invalid reason=%s", parseError.c_str());
|
|
2170
|
+
}
|
|
1898
2171
|
}
|
|
1899
2172
|
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
2173
|
+
if (payloadText.empty()) {
|
|
2174
|
+
const bool nothingProvided = argumentPayload.empty() && environmentPayload.empty();
|
|
2175
|
+
const std::wstring reason = nothingProvided ? std::wstring(L"missing-payload")
|
|
2176
|
+
: std::wstring(L"invalid-payload");
|
|
2177
|
+
if (nothingProvided) Log(L"missing-payload-argument");
|
|
2178
|
+
LogFmt(L"payload-unusable reason=%s", reason.c_str());
|
|
2179
|
+
// 参数可能被 shell 拼坏:尽量从原始文本里救出 ciProbeOut,先落一个 ok:false 的探针文件。
|
|
2180
|
+
std::wstring probePath = ExtractStringFieldLoose(environmentPayload, L"ciProbeOut");
|
|
2181
|
+
if (probePath.empty()) probePath = ExtractStringFieldLoose(argumentPayload, L"ciProbeOut");
|
|
2182
|
+
if (!probePath.empty()) {
|
|
2183
|
+
const std::wstring line = BuildCiProbeLine(false, false, reason);
|
|
2184
|
+
WriteStdout(line + L"\n");
|
|
2185
|
+
const bool wrote = WriteFileUtf8(probePath, line + L"\n");
|
|
2186
|
+
LogFmt(L"ciprobe-out-early path=%s wrote=%d reason=%s", probePath.c_str(),
|
|
2187
|
+
wrote ? 1 : 0, reason.c_str());
|
|
2188
|
+
}
|
|
2189
|
+
return 2;
|
|
2190
|
+
}
|
|
2191
|
+
LogFmt(L"payload-source=%s length=%zu ciProbe=%d ciProbeOut=%s", payloadSource.c_str(),
|
|
2192
|
+
payloadText.size(), selectedPayload.ciProbe ? 1 : 0,
|
|
2193
|
+
selectedPayload.ciProbeOut.c_str());
|
|
1905
2194
|
|
|
1906
2195
|
EnableDpiAwareness();
|
|
1907
2196
|
|
|
1908
2197
|
const HRESULT comResult = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
|
1909
2198
|
if (FAILED(comResult)) {
|
|
1910
2199
|
LogFmt(L"com-init-failed hr=%08lX", static_cast<unsigned long>(comResult));
|
|
2200
|
+
if (selectedPayload.ciProbe && !selectedPayload.ciProbeOut.empty()) {
|
|
2201
|
+
const std::wstring line = BuildCiProbeLine(false, false, L"com-init-failed");
|
|
2202
|
+
WriteStdout(line + L"\n");
|
|
2203
|
+
const bool wrote = WriteFileUtf8(selectedPayload.ciProbeOut, line + L"\n");
|
|
2204
|
+
LogFmt(L"ciprobe-out-early path=%s wrote=%d reason=com-init-failed",
|
|
2205
|
+
selectedPayload.ciProbeOut.c_str(), wrote ? 1 : 0);
|
|
2206
|
+
}
|
|
1911
2207
|
return 1;
|
|
1912
2208
|
}
|
|
1913
2209
|
|
|
@@ -1915,10 +2211,23 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE previousInstance, PWSTR comman
|
|
|
1915
2211
|
{
|
|
1916
2212
|
FloatApp app;
|
|
1917
2213
|
if (!app.ParseCommandLine(payloadText)) {
|
|
2214
|
+
Log(L"payload-parse-failed-after-preselect");
|
|
2215
|
+
if (selectedPayload.ciProbe && !selectedPayload.ciProbeOut.empty()) {
|
|
2216
|
+
const std::wstring line = BuildCiProbeLine(false, false, L"invalid-payload");
|
|
2217
|
+
WriteStdout(line + L"\n");
|
|
2218
|
+
const bool wrote = WriteFileUtf8(selectedPayload.ciProbeOut, line + L"\n");
|
|
2219
|
+
LogFmt(L"ciprobe-out-early path=%s wrote=%d reason=invalid-payload",
|
|
2220
|
+
selectedPayload.ciProbeOut.c_str(), wrote ? 1 : 0);
|
|
2221
|
+
}
|
|
1918
2222
|
exitCode = 2;
|
|
1919
2223
|
} else if (!app.CreateMainWindow()) {
|
|
1920
2224
|
if (app.IsCiProbe()) {
|
|
1921
|
-
|
|
2225
|
+
const std::wstring probePath = app.CiProbeOutputPath();
|
|
2226
|
+
const std::wstring line = BuildCiProbeLine(false, false, L"create-main-window-failed");
|
|
2227
|
+
WriteStdout(line + L"\n");
|
|
2228
|
+
const bool wrote = WriteFileUtf8(probePath, line + L"\n");
|
|
2229
|
+
LogFmt(L"ciprobe-out-early path=%s wrote=%d reason=create-main-window-failed",
|
|
2230
|
+
probePath.c_str(), wrote ? 1 : 0);
|
|
1922
2231
|
exitCode = 1;
|
|
1923
2232
|
} else {
|
|
1924
2233
|
exitCode = 3;
|
|
@@ -1926,6 +2235,8 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE previousInstance, PWSTR comman
|
|
|
1926
2235
|
} else {
|
|
1927
2236
|
app.Start();
|
|
1928
2237
|
exitCode = app.RunMessageLoop();
|
|
2238
|
+
// 兜底:ciProbe 进程结束了但没写结果(例如 WebView2 回调一直没来)也要留下探针文件。
|
|
2239
|
+
app.EnsureCiProbeResultWritten(L"exited-without-probe-result");
|
|
1929
2240
|
}
|
|
1930
2241
|
}
|
|
1931
2242
|
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
<key>CFBundleDisplayName</key><string>古法编程悬浮层</string>
|
|
8
8
|
<key>CFBundleExecutable</key><string>gufa-float</string>
|
|
9
9
|
<key>CFBundlePackageType</key><string>APPL</string>
|
|
10
|
-
<key>CFBundleShortVersionString</key><string>1.3.
|
|
11
|
-
<key>CFBundleVersion</key><string>1.3.
|
|
10
|
+
<key>CFBundleShortVersionString</key><string>1.3.52</string>
|
|
11
|
+
<key>CFBundleVersion</key><string>1.3.52</string>
|
|
12
12
|
<key>LSUIElement</key><true/>
|
|
13
13
|
<key>NSHighResolutionCapable</key><true/>
|
|
14
14
|
<key>NSPrincipalClass</key><string>NSApplication</string>
|
|
Binary file
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# 摸鱼悬浮层 · 三平台真机验收清单
|
|
2
|
+
|
|
3
|
+
> 适用版本:`dsh-gufa-code >= 1.3.51`
|
|
4
|
+
> 先看一遍「通用自检」,遇到问题把自检 JSON + 平台日志一起发来,定位最快。
|
|
5
|
+
|
|
6
|
+
## 0. 通用自检(所有平台先做这一步)
|
|
7
|
+
|
|
8
|
+
1. 在 IDE 标题栏点「摸鱼」(📺 图标按钮);
|
|
9
|
+
2. 选择器底部点「**自检**」;
|
|
10
|
+
3. 弹窗会显示平台、helper 路径/版本、运行时依赖、显示环境、辅助功能/WebView2 检测结果和 `notes` 提示;
|
|
11
|
+
4. 点「复制」把 JSON 保存下来;或点「**保存报告**」——会把自检 JSON + 最近日志写成一个 txt 文件(保存在 `~/.dsh/gufa-float-report-*.txt`)并自动在文件管理器中选中,直接把该文件发回来即可。`notes` 为空 = 没发现明显问题。
|
|
12
|
+
|
|
13
|
+
如果「摸鱼」按钮点了没反应、或选择器报错,也点「自检」,把报错/JSON 发出来。
|
|
14
|
+
|
|
15
|
+
## 1. macOS(Apple Silicon / Intel)
|
|
16
|
+
|
|
17
|
+
前置:系统设置 → 隐私与安全性 → **辅助功能** 勾选 **DeepSeek Harness**(改完重启一次 DSH)。
|
|
18
|
+
|
|
19
|
+
验收步骤:
|
|
20
|
+
1. 点「摸鱼」→ 出现运行中 App 列表(图标 + 名称);
|
|
21
|
+
2. 选一个普通窗口 App(如「访达」/「活动监视器」)→ 主窗口隐藏,悬浮层吸附到目标窗口;
|
|
22
|
+
3. 拖动/缩放目标窗口 → 悬浮层实时跟随;
|
|
23
|
+
4. 透明度滑块 20–100% 生效,重开摸鱼保持上次值;
|
|
24
|
+
5. 标题栏「退出摸鱼」→ 主窗口恢复、项目/标签页/会话状态带回;`ps aux | grep gufa-float` 无残留;
|
|
25
|
+
6. 全屏 App(如视频/音乐全屏)也能吸附。
|
|
26
|
+
|
|
27
|
+
日志:`/tmp/gufa-float-debug.log`、`/tmp/gufa-code-debug.log`
|
|
28
|
+
|
|
29
|
+
## 2. Windows 10/11 x64
|
|
30
|
+
|
|
31
|
+
前置:
|
|
32
|
+
- **WebView2 Runtime**:Win10/11 的 Edge 一般已自带;自检里 `deps.webview2Runtime` 为空说明缺失,去 <https://go.microsoft.com/fwlink/p/?LinkId=2124703> 装;
|
|
33
|
+
- 首次运行 helper exe 可能被 SmartScreen 拦截:「更多信息 → 仍要运行」;
|
|
34
|
+
- 无需辅助功能权限(窗口跟随走 Win32 API)。
|
|
35
|
+
|
|
36
|
+
验收步骤(和 macOS 相同 1–6 步),另外确认:
|
|
37
|
+
- 吸附后移动/缩放目标窗口,悬浮层跟随(允许 1–2 帧延迟);
|
|
38
|
+
- 目标窗口最小化/关闭时悬浮层保持最后位置、不崩;
|
|
39
|
+
- `任务管理器` 里退出后没有 `gufa-float-win.exe` 残留。
|
|
40
|
+
|
|
41
|
+
已知限制(1.3.51 首版):
|
|
42
|
+
- **悬浮窗不透明**(不能透出下层 App,透明度滑块对窗口背景无效)——后续 DComp 方案;
|
|
43
|
+
- 虚拟桌面切换时悬浮窗可能留在原桌面,切回后才可见;
|
|
44
|
+
- 多屏/DPI 已处理,但极端 DPI 组合仍需验证。
|
|
45
|
+
|
|
46
|
+
日志:`%TEMP%\gufa-float-debug.log`、`%TEMP%\gufa-code-debug.log`
|
|
47
|
+
WebView2 用户数据:`%LOCALAPPDATA%\gufa-float\`
|
|
48
|
+
|
|
49
|
+
## 3. Linux(仅 X11)
|
|
50
|
+
|
|
51
|
+
前置(Arch/Debian/Ubuntu 包名示例):
|
|
52
|
+
```bash
|
|
53
|
+
# GTK3 + WebKit2GTK 运行库(4.1 或 4.0 任一)
|
|
54
|
+
sudo apt install libgtk-3-0 libwebkit2gtk-4.1-0 libsoup-3.0-0 # Debian/Ubuntu
|
|
55
|
+
# 可选:列窗口兜底
|
|
56
|
+
sudo apt install wmctrl xdotool
|
|
57
|
+
```
|
|
58
|
+
Requirements: DSH 必须在 **X11 会话**里运行(`echo $XDG_SESSION_TYPE`);如果是 Wayland:
|
|
59
|
+
- 有 XWayland 时:用 `GDK_BACKEND=x11` 启动 DSH 后可用;
|
|
60
|
+
- 纯 Wayland:悬浮层只能「自由悬浮」,不能跟随/隐藏其它窗口(自检 `notes` 会提示)。
|
|
61
|
+
|
|
62
|
+
验收步骤:
|
|
63
|
+
1. 点「摸鱼」→ App 列表出现(优先用 helper 的 X11 实现;没有就退回 `wmctrl`);
|
|
64
|
+
2. 选一个窗口 App → 主窗口隐藏、悬浮层吸附;
|
|
65
|
+
3. 拖/缩放目标窗口 → 跟随;
|
|
66
|
+
4. 「退出摸鱼」→ 主窗口恢复、状态带回、无残留进程(`ps aux | grep gufa-float`);
|
|
67
|
+
5. 透明度:有合成器(GNOME/KDE 默认)时悬浮层应半透明。
|
|
68
|
+
|
|
69
|
+
已知限制:
|
|
70
|
+
- 纯 Wayland 下不跟随;
|
|
71
|
+
- 全屏 App 的置顶层级取决于窗口管理器(WM);
|
|
72
|
+
- 无合成器时窗口不透明。
|
|
73
|
+
|
|
74
|
+
日志:`/tmp/gufa-float-debug.log`、`/tmp/gufa-code-debug.log`
|
|
75
|
+
|
|
76
|
+
## 4. 反馈模板
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
平台/版本:Windows 11 23H2 / macOS 15.2 / Ubuntu 24.04 (X11)
|
|
80
|
+
DSH 版本 + 插件版本:
|
|
81
|
+
操作步骤:
|
|
82
|
+
现象(截图更好):
|
|
83
|
+
自检 JSON / 或「保存报告」生成的文件路径:
|
|
84
|
+
日志片段(/tmp 或 %TEMP% 里对应文件):
|
|
85
|
+
```
|
package/docs/RELEASE.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# 发布流程(维护者)
|
|
2
|
+
|
|
3
|
+
## 一键发布:打 tag + 建 GitHub Release
|
|
4
|
+
|
|
5
|
+
1. 确认 `package.json` 版本号已更新(`npm version patch --no-git-tag-version` 或手改);
|
|
6
|
+
2. 提交并推送 tag:
|
|
7
|
+
```bash
|
|
8
|
+
git tag v1.3.x && git push origin v1.3.x
|
|
9
|
+
```
|
|
10
|
+
3. 建一个 GitHub Release(网页或 CLI):
|
|
11
|
+
```bash
|
|
12
|
+
gh release create v1.3.x --title "..." --notes "..."
|
|
13
|
+
```
|
|
14
|
+
4. 触发两个 workflow:
|
|
15
|
+
- `.github/workflows/publish.yml`:**npm trusted publishing(OIDC provenance)自动发布**,不需要本地 npm token / 2FA;
|
|
16
|
+
- `.github/workflows/build-float.yml`:三平台编译 helper + 严格冒烟,并把二进制作为 release assets 附上。
|
|
17
|
+
5. 验证:`npm view dsh-gufa-code version`、Release 页面 assets。
|
|
18
|
+
|
|
19
|
+
## 本地发布(不推荐,需要 npm 2FA)
|
|
20
|
+
|
|
21
|
+
`npm publish`(会要求网页 2FA 验证)。优先用上面的 GitHub Release 流程。
|
|
22
|
+
|
|
23
|
+
## 发布前检查
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
node scripts/build-client.mjs
|
|
27
|
+
node --check client.js
|
|
28
|
+
node scripts/selftest-client.mjs # 99
|
|
29
|
+
node scripts/selftest-host.mjs # 30
|
|
30
|
+
node scripts/test-editor.mjs # 19
|
|
31
|
+
npm pack --dry-run | grep desktop/float/bin # 三平台二进制在包里
|
|
32
|
+
```
|