dsh-gufa-code 1.3.53 → 1.3.55
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 +3 -2
- package/client.js +1 -1
- 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 +12 -1
- package/desktop/float/linux/x11.c +336 -40
- package/desktop/float/linux/x11.h +4 -0
- package/desktop/float/win/CMakeLists.txt +1 -0
- package/desktop/float/win/README-WIN.md +13 -17
- package/desktop/float/win/main.cpp +582 -49
- 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 +16 -2
- package/host/dev.js +10 -52
- package/host/float-platform.js +97 -0
- package/package.json +7 -1
- package/scripts/selftest-host.mjs +50 -0
|
@@ -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.55</string>
|
|
11
|
+
<key>CFBundleVersion</key><string>1.3.55</string>
|
|
12
12
|
<key>LSUIElement</key><true/>
|
|
13
13
|
<key>NSHighResolutionCapable</key><true/>
|
|
14
14
|
<key>NSPrincipalClass</key><string>NSApplication</string>
|
|
Binary file
|
package/docs/FLOAT-ACCEPTANCE.md
CHANGED
|
@@ -12,6 +12,18 @@
|
|
|
12
12
|
|
|
13
13
|
如果「摸鱼」按钮点了没反应、或选择器报错,也点「自检」,把报错/JSON 发出来。
|
|
14
14
|
|
|
15
|
+
## 0.5 CI 已自动覆盖的能力(2026-11 起)
|
|
16
|
+
|
|
17
|
+
每次 push / release 的 `build-float-helper` 会在真实 runner 上跑:
|
|
18
|
+
|
|
19
|
+
| 平台 | 自动化验证 |
|
|
20
|
+
|---|---|
|
|
21
|
+
| Windows (windows-latest) | ciProbe 加载本地页面 ok:true;真实窗口创建(EnumWindows 数可见窗口);**跟随** notepad 窗口位置/大小、移动后继续跟随;**隐藏/恢复**标题为 "DeepSeek Harness" 的窗口;**状态注入**(页面读回 `gufa-code:float` / `float-state` / `project` / `ui:v1` 全部正确);**透明 composition**(日志 `transparent-mode=composition` + 窗口 `WS_EX_NOREDIRECTIONBITMAP`);**opaque 回退**(`transparent-mode=windowed reason=payload-opaque` 下窗口/退出正常);**顶部拖动条命中**(WM_NCHITTEST 拖动区 HTCAPTION / 客户区 HTCLIENT);**键盘输入**(SetForegroundWindow+keybd_event 后页面收到 keydown);controlPath 优雅退出 |
|
|
22
|
+
| Linux (ubuntu-24.04 + Xvfb + openbox) | ciProbe 加载本地页面 ok:true;真实窗口创建;**跟随** xterm 窗口位置/大小、移动后继续跟随;**状态注入**(同上四项 localStorage 全部正确);**隐藏/恢复**标题为 "DeepSeek Harness" 的 xmessage 窗口(XUnmap→XMap);**RGBA 透明路径**(xcompmgr 下日志 `使用 RGBA visual`);**键盘输入**(xdotool XTEST 发送 G 后页面收到 keydown);controlPath 优雅退出 |
|
|
23
|
+
| macOS (macos-latest) | universal 构建 + 窗口列表辅助功能检查 |
|
|
24
|
+
|
|
25
|
+
所以剩下的真机验收重点:真实 DSH 集成(主窗口隐藏/唤回)、多显示器/DPI、外观(Windows 首版不透明)、Wayland(Linux)等 CI 覆盖不到的部分。
|
|
26
|
+
|
|
15
27
|
## 1. macOS(Apple Silicon / Intel)
|
|
16
28
|
|
|
17
29
|
前置:系统设置 → 隐私与安全性 → **辅助功能** 勾选 **DeepSeek Harness**(改完重启一次 DSH)。
|
|
@@ -38,8 +50,10 @@
|
|
|
38
50
|
- 目标窗口最小化/关闭时悬浮层保持最后位置、不崩;
|
|
39
51
|
- `任务管理器` 里退出后没有 `gufa-float-win.exe` 残留。
|
|
40
52
|
|
|
41
|
-
|
|
42
|
-
-
|
|
53
|
+
已知限制 / 真机重点(1.3.54+):
|
|
54
|
+
- 透明窗口用 DirectComposition 合成,**真机重点看观感**(能否透出下层 App;系统/远程桌面不支持时会自动回退不透明,日志 `transparent-mode=fallback reason=...`);
|
|
55
|
+
- composition 模式顶部拖动条是网页层(按住可拖、右键菜单),页面内「退出摸鱼」按钮仍可用;
|
|
56
|
+
- **键盘输入**依赖 WebView2 焦点(CI 测不到);
|
|
43
57
|
- 虚拟桌面切换时悬浮窗可能留在原桌面,切回后才可见;
|
|
44
58
|
- 多屏/DPI 已处理,但极端 DPI 组合仍需验证。
|
|
45
59
|
|
package/host/dev.js
CHANGED
|
@@ -10,6 +10,7 @@ import { promisify } from 'node:util'
|
|
|
10
10
|
import { dirname, join } from 'node:path'
|
|
11
11
|
import { fileURLToPath } from 'node:url'
|
|
12
12
|
import { ApiError } from './context.js'
|
|
13
|
+
import { floatBinaryCandidates, parsePowerShellWindowList, parseTasklistPids, parseWmctrlWindowList } from './float-platform.js'
|
|
13
14
|
|
|
14
15
|
const PLUGIN_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..')
|
|
15
16
|
const DEBUG_LOG_PATH = '/tmp/gufa-code-debug.log'
|
|
@@ -29,28 +30,7 @@ const runFile = promisify(execFile)
|
|
|
29
30
|
/** 查找当前平台编译好的悬浮层 helper。 */
|
|
30
31
|
function floatBinaryPath() {
|
|
31
32
|
const root = join(PLUGIN_ROOT, 'desktop', 'float', 'bin')
|
|
32
|
-
|
|
33
|
-
if (process.platform === 'darwin') {
|
|
34
|
-
const arch = process.arch === 'arm64' ? 'arm64' : 'x64'
|
|
35
|
-
candidates = [
|
|
36
|
-
join(root, `gufa-float-macos-${arch}`),
|
|
37
|
-
join(root, 'gufa-float-macos-universal'),
|
|
38
|
-
join(root, 'gufa-float-macos-arm64'),
|
|
39
|
-
join(root, 'gufa-float-macos-x64'),
|
|
40
|
-
]
|
|
41
|
-
} else if (process.platform === 'win32') {
|
|
42
|
-
candidates = [
|
|
43
|
-
join(root, 'win-x64', 'gufa-float-win.exe'),
|
|
44
|
-
join(root, 'gufa-float-win.exe'),
|
|
45
|
-
]
|
|
46
|
-
} else if (process.platform === 'linux') {
|
|
47
|
-
candidates = [
|
|
48
|
-
join(root, 'linux-x64', 'gufa-float-linux'),
|
|
49
|
-
join(root, 'linux-x64', 'gufa-float-linux-x64'),
|
|
50
|
-
join(root, 'gufa-float-linux'),
|
|
51
|
-
]
|
|
52
|
-
}
|
|
53
|
-
for (const full of candidates) {
|
|
33
|
+
for (const full of floatBinaryCandidates(process.platform, process.arch, root)) {
|
|
54
34
|
if (existsSync(full)) return full
|
|
55
35
|
}
|
|
56
36
|
return null
|
|
@@ -147,13 +127,7 @@ export function register(router, env) {
|
|
|
147
127
|
for (const pid of alive) pids.add(pid)
|
|
148
128
|
try {
|
|
149
129
|
const { stdout } = await runFile('tasklist', ['/FI', 'IMAGENAME eq gufa-float-win.exe', '/FO', 'CSV', '/NH'], { timeout: 5000 })
|
|
150
|
-
for (const
|
|
151
|
-
const match = /^"([^"]+)","(\d+)"/.exec(line.trim())
|
|
152
|
-
if (match !== null) {
|
|
153
|
-
const pid = Number(match[2])
|
|
154
|
-
if (Number.isFinite(pid) && pid > 0) pids.add(pid)
|
|
155
|
-
}
|
|
156
|
-
}
|
|
130
|
+
for (const pid of parseTasklistPids(stdout)) pids.add(pid)
|
|
157
131
|
} catch {
|
|
158
132
|
/* tasklist 不可用:只用 child pid */
|
|
159
133
|
}
|
|
@@ -269,14 +243,10 @@ export function register(router, env) {
|
|
|
269
243
|
"ConvertTo-Json -InputObject ([pscustomobject]@{ ok = $true; accessibility = $true; apps = @($rows) }) -Compress -Depth 5",
|
|
270
244
|
].join('\n')
|
|
271
245
|
const { stdout } = await runFile('powershell', ['-NoProfile', '-NonInteractive', '-Command', script], { timeout: 20_000, maxBuffer: 8 * 1024 * 1024 })
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
if (parsed === null || parsed.ok !== true) throw new ApiError('list-failed', '读取 Windows 窗口列表失败', 500)
|
|
275
|
-
let apps = parsed.apps
|
|
276
|
-
if (!Array.isArray(apps)) apps = apps === null || apps === undefined ? [] : [apps]
|
|
246
|
+
const parsed = parsePowerShellWindowList(stdout)
|
|
247
|
+
if (parsed === null) throw new ApiError('list-failed', '读取 Windows 窗口列表失败', 500)
|
|
277
248
|
const helperPids = new Set(await listFloatPids())
|
|
278
|
-
apps = apps.filter((row) =>
|
|
279
|
-
apps = apps.map((row) => ({ ...row, name: typeof row.name === 'string' && row.name !== '' ? row.name : row.owner }))
|
|
249
|
+
const apps = parsed.apps.filter((row) => !helperPids.has(Number(row.pid)))
|
|
280
250
|
return { ok: true, accessibility: true, apps }
|
|
281
251
|
}
|
|
282
252
|
|
|
@@ -304,25 +274,13 @@ export function register(router, env) {
|
|
|
304
274
|
} catch {
|
|
305
275
|
throw new ApiError('missing-tool', 'Linux 下列出窗口失败:请重新构建 helper,或安装 wmctrl(sudo apt install wmctrl)', 500)
|
|
306
276
|
}
|
|
307
|
-
const apps =
|
|
308
|
-
const seen = new Set()
|
|
309
|
-
for (const line of String(stdout ?? '').split('\n')) {
|
|
310
|
-
const match = /^0x[0-9a-fA-F]+\s+\d+\s+(\d+)\s+(.*)$/.exec(line.trim())
|
|
311
|
-
if (match === null) continue
|
|
312
|
-
const pid = Number(match[1])
|
|
313
|
-
const title = match[2].trim()
|
|
314
|
-
if (!Number.isFinite(pid) || pid <= 0 || title === '') continue
|
|
315
|
-
const key = `${pid}:${title}`
|
|
316
|
-
if (seen.has(key)) continue
|
|
317
|
-
seen.add(key)
|
|
318
|
-
let owner = String(pid)
|
|
277
|
+
const apps = parseWmctrlWindowList(stdout, (pid) => {
|
|
319
278
|
try {
|
|
320
|
-
|
|
279
|
+
return readFileSync(`/proc/${pid}/comm`, 'utf8')
|
|
321
280
|
} catch {
|
|
322
|
-
|
|
281
|
+
return undefined
|
|
323
282
|
}
|
|
324
|
-
|
|
325
|
-
}
|
|
283
|
+
})
|
|
326
284
|
return { ok: true, accessibility: true, apps }
|
|
327
285
|
}
|
|
328
286
|
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 跨平台摸鱼悬浮层:Host 侧纯函数(无 DSH 依赖,可单元测试)。
|
|
3
|
+
*
|
|
4
|
+
* host/dev.js 的 float.* 平台分支用这些函数做「二进制候选路径 / 任务列表解析 /
|
|
5
|
+
* PowerShell 窗口列表解析 / wmctrl 窗口列表解析」。把解析逻辑放这里是为了:
|
|
6
|
+
* 1) 在 macOS 上也能用固定字符串测试 Windows/Linux 两条分支;
|
|
7
|
+
* 2) 避免 dev.js 越堆越大。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** 当前平台优先使用的 helper 二进制候选(按顺序尝试)。 */
|
|
11
|
+
export function floatBinaryCandidates(platform, arch, binRoot) {
|
|
12
|
+
const join = (name) => `${binRoot.replace(/\/+$/, '')}/${name}`
|
|
13
|
+
if (platform === 'darwin') {
|
|
14
|
+
const macArch = arch === 'arm64' ? 'arm64' : 'x64'
|
|
15
|
+
return [
|
|
16
|
+
join(`gufa-float-macos-${macArch}`),
|
|
17
|
+
join('gufa-float-macos-universal'),
|
|
18
|
+
join('gufa-float-macos-arm64'),
|
|
19
|
+
join('gufa-float-macos-x64'),
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
if (platform === 'win32') {
|
|
23
|
+
return [join('win-x64/gufa-float-win.exe'), join('gufa-float-win.exe')]
|
|
24
|
+
}
|
|
25
|
+
if (platform === 'linux') {
|
|
26
|
+
return [join('linux-x64/gufa-float-linux'), join('linux-x64/gufa-float-linux-x64'), join('gufa-float-linux')]
|
|
27
|
+
}
|
|
28
|
+
return []
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** 解析 `tasklist /FI "IMAGENAME eq gufa-float-win.exe" /FO CSV /NH` 的进程号。 */
|
|
32
|
+
export function parseTasklistPids(stdout) {
|
|
33
|
+
const pids = new Set()
|
|
34
|
+
for (const line of String(stdout ?? '').split('\n')) {
|
|
35
|
+
const match = /^"([^"]+)","(\d+)"/.exec(line.trim())
|
|
36
|
+
if (match !== null) {
|
|
37
|
+
const pid = Number(match[2])
|
|
38
|
+
if (Number.isFinite(pid) && pid > 0) pids.add(pid)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return [...pids]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 解析 Windows 窗口列表 PowerShell 输出:
|
|
46
|
+
* ConvertTo-Json -InputObject ([pscustomobject]@{ ok=$true; accessibility=$true; apps=@($rows) })
|
|
47
|
+
* 返回 { ok, accessibility, apps } 或 null(解析失败/非 ok)。
|
|
48
|
+
*/
|
|
49
|
+
export function parsePowerShellWindowList(stdout) {
|
|
50
|
+
let parsed = null
|
|
51
|
+
try {
|
|
52
|
+
parsed = JSON.parse(String(stdout ?? '').trim())
|
|
53
|
+
} catch {
|
|
54
|
+
return null
|
|
55
|
+
}
|
|
56
|
+
if (parsed === null || typeof parsed !== 'object' || parsed.ok !== true) return null
|
|
57
|
+
let apps = parsed.apps
|
|
58
|
+
if (!Array.isArray(apps)) apps = apps === null || apps === undefined ? [] : [apps]
|
|
59
|
+
apps = apps
|
|
60
|
+
.filter((row) => row !== null && typeof row === 'object' && Number(row.pid) > 0 &&
|
|
61
|
+
typeof row.title === 'string' && row.title !== '')
|
|
62
|
+
.map((row) => ({
|
|
63
|
+
...row,
|
|
64
|
+
name: typeof row.name === 'string' && row.name !== '' ? row.name : (typeof row.owner === 'string' ? row.owner : String(row.pid)),
|
|
65
|
+
}))
|
|
66
|
+
return { ok: true, accessibility: true, apps }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 解析 `wmctrl -lp` 输出为窗口列表。
|
|
71
|
+
* @param {string} stdout wmctrl 输出
|
|
72
|
+
* @param {(pid:number)=>string|undefined} readComm 读取进程名(Linux 上读 /proc/<pid>/comm;测试可注入)
|
|
73
|
+
*/
|
|
74
|
+
export function parseWmctrlWindowList(stdout, readComm) {
|
|
75
|
+
const apps = []
|
|
76
|
+
const seen = new Set()
|
|
77
|
+
for (const line of String(stdout ?? '').split('\n')) {
|
|
78
|
+
// 格式:`0x窗口ID 桌面号 PID 主机名 窗口标题`(标题可含空格)
|
|
79
|
+
const match = /^0x[0-9a-fA-F]+\s+\d+\s+(\d+)\s+(\S+)\s+(.*)$/.exec(line.trim())
|
|
80
|
+
if (match === null) continue
|
|
81
|
+
const pid = Number(match[1])
|
|
82
|
+
const title = match[3].trim()
|
|
83
|
+
if (!Number.isFinite(pid) || pid <= 0 || title === '') continue
|
|
84
|
+
const key = `${pid}:${title}`
|
|
85
|
+
if (seen.has(key)) continue
|
|
86
|
+
seen.add(key)
|
|
87
|
+
let owner = String(pid)
|
|
88
|
+
try {
|
|
89
|
+
const comm = readComm(pid)
|
|
90
|
+
if (typeof comm === 'string' && comm.trim() !== '') owner = comm.trim()
|
|
91
|
+
} catch {
|
|
92
|
+
/* 进程可能已退出 */
|
|
93
|
+
}
|
|
94
|
+
apps.push({ pid, name: owner, owner, title, bundleId: owner, windowNumber: apps.length + 1, frontmost: 0 })
|
|
95
|
+
}
|
|
96
|
+
return apps
|
|
97
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-gufa-code",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.55",
|
|
4
4
|
"description": "古法编程 · AI 辅助:一键把 DSH 主面板变成 VS Code 风格 IDE(Monaco 编辑器、文件树、Git、SSH、真实终端 + 右侧官方会话);主张亲手写、每个改动心中有数,AI 是助理、你是第一责任人",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"keywords": [
|
|
@@ -66,5 +66,11 @@
|
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
69
|
+
},
|
|
70
|
+
"scripts": {
|
|
71
|
+
"test": "node scripts/selftest-client.mjs && node scripts/selftest-host.mjs && node scripts/test-editor.mjs",
|
|
72
|
+
"build:client": "node scripts/build-client.mjs",
|
|
73
|
+
"build:float:macos": "./scripts/build-float-macos.sh",
|
|
74
|
+
"build:float:linux": "./scripts/build-float-linux.sh"
|
|
69
75
|
}
|
|
70
76
|
}
|
|
@@ -10,6 +10,7 @@ import { tmpdir } from 'node:os'
|
|
|
10
10
|
import { join } from 'node:path'
|
|
11
11
|
|
|
12
12
|
import * as assets from '../host/assets.js'
|
|
13
|
+
import * as floatPlatform from '../host/float-platform.js'
|
|
13
14
|
import * as chat from '../host/chat.js'
|
|
14
15
|
import * as fs from '../host/fs.js'
|
|
15
16
|
import * as git from '../host/git.js'
|
|
@@ -179,6 +180,55 @@ try {
|
|
|
179
180
|
const wsNone = await wsRouterUnavailable.methods.get('workspaces.list')({})
|
|
180
181
|
check('workspaces.list unavailable fallback', wsNone.available === false && wsNone.workspaces.length === 0)
|
|
181
182
|
|
|
183
|
+
console.log('float 平台分支纯函数')
|
|
184
|
+
const binRoot = '/plugin/desktop/float/bin'
|
|
185
|
+
const macArm = floatPlatform.floatBinaryCandidates('darwin', 'arm64', binRoot)
|
|
186
|
+
check('float binary candidates darwin arm64 顺序', macArm[0].endsWith('gufa-float-macos-arm64') && macArm[1].endsWith('gufa-float-macos-universal'), JSON.stringify(macArm))
|
|
187
|
+
const macX64 = floatPlatform.floatBinaryCandidates('darwin', 'x64', binRoot)
|
|
188
|
+
check('float binary candidates darwin x64 顺序', macX64[0].endsWith('gufa-float-macos-x64'), JSON.stringify(macX64))
|
|
189
|
+
const winBins = floatPlatform.floatBinaryCandidates('win32', 'x64', binRoot)
|
|
190
|
+
check('float binary candidates win32', winBins[0] === '/plugin/desktop/float/bin/win-x64/gufa-float-win.exe' && winBins[1].endsWith('gufa-float-win.exe'), JSON.stringify(winBins))
|
|
191
|
+
const linuxBins = floatPlatform.floatBinaryCandidates('linux', 'x64', binRoot)
|
|
192
|
+
check('float binary candidates linux', linuxBins[0] === '/plugin/desktop/float/bin/linux-x64/gufa-float-linux', JSON.stringify(linuxBins))
|
|
193
|
+
check('float binary candidates 未知平台为空', floatPlatform.floatBinaryCandidates('aix', 'x64', binRoot).length === 0)
|
|
194
|
+
|
|
195
|
+
const tasklistOut = [
|
|
196
|
+
'"gufa-float-win.exe","1234","Console","1","10,000 K"',
|
|
197
|
+
'"gufa-float-win.exe","5678","Console","1","10,000 K"',
|
|
198
|
+
'INFO: No tasks are running which match the specified criteria.',
|
|
199
|
+
'',
|
|
200
|
+
].join('\n')
|
|
201
|
+
check('parseTasklistPids 解析 CSV', JSON.stringify(floatPlatform.parseTasklistPids(tasklistOut)) === '[1234,5678]', JSON.stringify(floatPlatform.parseTasklistPids(tasklistOut)))
|
|
202
|
+
check('parseTasklistPids 空输入', floatPlatform.parseTasklistPids('').length === 0)
|
|
203
|
+
|
|
204
|
+
const psArray = JSON.stringify({ ok: true, accessibility: true, apps: [
|
|
205
|
+
{ pid: 10, owner: 'chrome', title: 'Chrome', bundleId: '', windowNumber: 1, frontmost: 0 },
|
|
206
|
+
{ pid: 11, owner: 'wechat', title: 'WeChat', bundleId: '', windowNumber: 2, frontmost: 1 },
|
|
207
|
+
] })
|
|
208
|
+
const psParsed = floatPlatform.parsePowerShellWindowList(psArray)
|
|
209
|
+
check('parsePowerShellWindowList 数组 + name 回填', psParsed !== null && psParsed.apps.length === 2 && psParsed.apps[0].name === 'chrome', JSON.stringify(psParsed))
|
|
210
|
+
const psSingle = floatPlatform.parsePowerShellWindowList(JSON.stringify({ ok: true, accessibility: true, apps: { pid: 12, owner: 'code', title: 'VS Code' } }))
|
|
211
|
+
check('parsePowerShellWindowList 单对象转数组', psSingle !== null && psSingle.apps.length === 1 && psSingle.apps[0].name === 'code', JSON.stringify(psSingle))
|
|
212
|
+
check('parsePowerShellWindowList ok:false', floatPlatform.parsePowerShellWindowList(JSON.stringify({ ok: false })) === null)
|
|
213
|
+
check('parsePowerShellWindowList 非法 JSON', floatPlatform.parsePowerShellWindowList('not-json') === null)
|
|
214
|
+
const psFiltered = floatPlatform.parsePowerShellWindowList(JSON.stringify({ ok: true, apps: [
|
|
215
|
+
{ pid: 1, owner: 'a', title: '' },
|
|
216
|
+
{ pid: 0, owner: 'b', title: 'B' },
|
|
217
|
+
{ pid: 2, owner: 'c', title: 'C' },
|
|
218
|
+
] }))
|
|
219
|
+
check('parsePowerShellWindowList 过滤空标题/非法 pid', psFiltered !== null && psFiltered.apps.length === 1 && psFiltered.apps[0].pid === 2, JSON.stringify(psFiltered))
|
|
220
|
+
|
|
221
|
+
const wmctrlOut = [
|
|
222
|
+
'0x03e00007 0 1234 host One Title With Spaces',
|
|
223
|
+
'0x03e00008 0 1234 host One Title With Spaces',
|
|
224
|
+
'0x03e00009 1 4321 host Another',
|
|
225
|
+
'malformed line',
|
|
226
|
+
].join('\n')
|
|
227
|
+
const wmApps = floatPlatform.parseWmctrlWindowList(wmctrlOut, (pid) => (pid === 1234 ? 'chrome' : 'wechat'))
|
|
228
|
+
check('parseWmctrlWindowList 解析/去重/owner', wmApps.length === 2 && wmApps[0].owner === 'chrome' && wmApps[0].title === 'One Title With Spaces' && wmApps[1].owner === 'wechat', JSON.stringify(wmApps))
|
|
229
|
+
const wmFallback = floatPlatform.parseWmctrlWindowList('0x1 0 999 host T', () => { throw new Error('gone') })
|
|
230
|
+
check('parseWmctrlWindowList comm 失败回退 pid', wmFallback.length === 1 && wmFallback[0].owner === '999', JSON.stringify(wmFallback))
|
|
231
|
+
|
|
182
232
|
console.log('ssh / assets / placeholders')
|
|
183
233
|
const sshHosts = await call(router, 'ssh.hosts')
|
|
184
234
|
check('ssh.hosts shape', Array.isArray(sshHosts.hosts))
|