@huaqiu/dsh-xiaoqiu 0.7.29 → 0.7.30
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 +83 -28
- package/lib/host.mjs +49 -4
- package/package.json +13 -2
- package/lib/Xiaoqiu.exe +0 -0
package/README.md
CHANGED
|
@@ -1,28 +1,83 @@
|
|
|
1
|
-
# 华秋 DSH 桌面伙伴「小秋」
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
# 华秋 DSH 桌面伙伴「小秋」
|
|
2
|
+
|
|
3
|
+
小秋是华秋 DSH 的 Windows 桌面伙伴。启用插件后,它会跟随 DSH 桌面端启动,首次出现在主屏右下角。即使工作台已最小化,你也能从小秋的动作看出当前会话是否在等你确认。退出 DSH 时,小秋也会关闭。
|
|
4
|
+
|
|
5
|
+
## 安装与卸载
|
|
6
|
+
|
|
7
|
+
在 DSH 工作台的插件管理页选择离线包 `huaqiu-dsh-xiaoqiu-*.tgz`,在桌面配置中启用 `@huaqiu/dsh-xiaoqiu`,然后重启 DSH。小秋可以与华秋外观插件、工程工作台插件搭配使用。若曾安装同名旧版 0.4.0,请先恢复此前使用的外观插件版本。
|
|
8
|
+
|
|
9
|
+
也可以在离线包所在目录打开 PowerShell,通过 DSH CLI 安装到桌面配置:
|
|
10
|
+
|
|
11
|
+
```powershell
|
|
12
|
+
$cli = Join-Path $env:LOCALAPPDATA 'Programs\Huaqiu Electronic Design Agent Platform\resources\runtime\cli\bin\dsh.cmd'
|
|
13
|
+
& $cli plugin --profile desktop add --offline --ignore-scripts (Resolve-Path '.\huaqiu-dsh-xiaoqiu-*.tgz').Path
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
卸载时,在同一 PowerShell 窗口执行以下命令,然后重启 DSH:
|
|
17
|
+
|
|
18
|
+
```powershell
|
|
19
|
+
& $cli plugin --profile desktop remove '@huaqiu/dsh-xiaoqiu'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 桌面互动
|
|
23
|
+
|
|
24
|
+
| 操作 | 小秋的反应 |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| 单击 / 双击 | 单击摸头,双击跳跃。 |
|
|
27
|
+
| 按住并拖动 | 可拖到另一台显示器。松开后保存位置,下次启动时恢复。 |
|
|
28
|
+
| 右键 →「回到主屏」 | 回到主屏工作区右下角,并保存新位置。 |
|
|
29
|
+
| 空闲时右键 →「让小秋打个盹」 | 小秋开始打盹,再次右键可选「叫醒小秋」。 |
|
|
30
|
+
| 右键 →「隐藏小秋」 | 本次运行中保持隐藏,任务状态变化时也不会弹出。 |
|
|
31
|
+
| 点击工作台左侧栏底部的「唤醒小秋」图标 | 小秋在原处挥爪,显示「我在这儿!」。 |
|
|
32
|
+
|
|
33
|
+
小秋窗口获得焦点后,也可用键盘操作:方向键每次移动 12 像素,`Home` 回到主屏,空格或回车摸头。
|
|
34
|
+
|
|
35
|
+
小秋会跟随**当前会话**切换动作:任务运行时捧起电路板,等待交互时举爪并显示「这一步等你确认」,本轮结束时短暂显示「这一轮结束啦」。空闲时,它会看向附近的指针、眨眼和摆尾。指针移开且空闲一分钟后,它会自行打盹。提示气泡和右键菜单跟随 DSH 的深浅主题,关闭 Windows 动画效果后,各状态以静态姿势显示。
|
|
36
|
+
|
|
37
|
+
位置默认保存在 `~/.hq-edge/plugin-data/dsh-xiaoqiu/position.txt`。若将 `HQ_EDGE_HOME` 设为绝对路径,位置文件就保存在该目录下的 `plugin-data/dsh-xiaoqiu/` 中。
|
|
38
|
+
|
|
39
|
+
## 从源码构建
|
|
40
|
+
|
|
41
|
+
本仓库的 `packages/dsh-xiaoqiu` 是该插件唯一的源码与发布位置,独立仓库已并入。一个包里有三样东西,各有各的工具链:
|
|
42
|
+
|
|
43
|
+
| 产物 | 来源 | 构建方式 |
|
|
44
|
+
| --- | --- | --- |
|
|
45
|
+
| `lib/host.mjs` | `src/host.mjs` | 原样复制 |
|
|
46
|
+
| `lib/client.js` | `src/client.js` | 把 `__XIAOQIU_PORTRAIT__` 换成侧栏头像的 data URL |
|
|
47
|
+
| `lib/Xiaoqiu.exe` | `src/DesktopPet.cs` | 用 Windows 自带的 .NET Framework 4 C# 编译器编译 |
|
|
48
|
+
|
|
49
|
+
在 Windows 上(Node.js + .NET Framework 4 即可,不需要 SDK、NuGet 或 MSBuild):
|
|
50
|
+
|
|
51
|
+
```powershell
|
|
52
|
+
pnpm build
|
|
53
|
+
pnpm pack --pack-destination ..
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`pnpm build` 会把包版本写进程序集版本,因此发布的 exe 不会自称一个包并不具备的版本;编译成功后同时刷新 `prebuilt/Xiaoqiu.exe`。在非 Windows 机器上构建时,两个脚本照常产出,exe 取用 `prebuilt/` 里最近一次 Windows 构建的二进制并给出提示——代码只有这一份,但桌面窗口本身只能在 Windows 上编译。制作离线包时 `pnpm pack` 会先自动构建。
|
|
57
|
+
|
|
58
|
+
### 修改角色图像
|
|
59
|
+
|
|
60
|
+
仓库已包含动画图集和侧栏头像。修改 `src/cat.js` 后,在装有 Google Chrome 的机器上运行以下命令,重新生成 `src/cat-atlas.png` 和 `src/launcher.png`,再构建插件:
|
|
61
|
+
|
|
62
|
+
```powershell
|
|
63
|
+
python -m pip install playwright Pillow
|
|
64
|
+
python src/render_atlas.py
|
|
65
|
+
pnpm build
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 桌面冒烟测试
|
|
69
|
+
|
|
70
|
+
在装有华秋 DSH 桌面端、Google Chrome 和 Node.js 的 Windows 桌面会话中运行。测试使用临时 DSH 配置,会移动鼠标并实际拖动小秋。脚本从本目录的上一级读取以下文件:
|
|
71
|
+
|
|
72
|
+
- `huaqiu-dsh-xiaoqiu-*.tgz`(测试本地改动前,先重新打包)
|
|
73
|
+
- `huaqiu-dsh-green-workbench-*.tgz`
|
|
74
|
+
- `dsh-pcb-eda/.smoke/bom_desktop_host.cjs`
|
|
75
|
+
|
|
76
|
+
在本目录执行:
|
|
77
|
+
|
|
78
|
+
```powershell
|
|
79
|
+
python -m pip install playwright Pillow psutil
|
|
80
|
+
python test/desktop_smoke.py
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
测试覆盖插件包启动、主题切换、透明区域的鼠标穿透、拖动与重启后的位置恢复、隐藏与侧栏唤醒,以及宿主退出时关闭小秋。
|
package/lib/host.mjs
CHANGED
|
@@ -1,26 +1,68 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
2
3
|
import { homedir } from "node:os";
|
|
3
|
-
import { isAbsolute, join } from "node:path";
|
|
4
|
+
import { isAbsolute, join, sep } from "node:path";
|
|
4
5
|
import { fileURLToPath } from "node:url";
|
|
5
6
|
|
|
6
7
|
export const name = "@huaqiu/dsh-xiaoqiu";
|
|
7
8
|
export const inject = ["webServer"];
|
|
8
9
|
const endpoint = "/api/v1/xiaoqiu/activity";
|
|
9
10
|
|
|
11
|
+
/** Path segment that marks a location inside an Electron asar archive. */
|
|
12
|
+
const PACKED = `${sep}app.asar${sep}`;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The on-disk twin of a path that points inside an Electron asar archive.
|
|
16
|
+
*
|
|
17
|
+
* A packed Desktop install keeps this package's JavaScript inside `app.asar` and
|
|
18
|
+
* unpacks the window binary next to it, because `CreateProcess` cannot start a
|
|
19
|
+
* program that only exists in an archive: `spawn` refuses an archived `.exe`
|
|
20
|
+
* synchronously with `EFTYPE`, and Electron's patched `fs` still reports that
|
|
21
|
+
* path as existing, so nothing else reveals the mistake. Resolution therefore
|
|
22
|
+
* has to leave the archive on its own.
|
|
23
|
+
* @param path - absolute path that may be inside an asar archive.
|
|
24
|
+
* @returns the `app.asar.unpacked` twin when it exists, else the input.
|
|
25
|
+
*/
|
|
26
|
+
export function unpackedPath(path) {
|
|
27
|
+
const normalized = path.replaceAll("/", sep);
|
|
28
|
+
const index = normalized.indexOf(PACKED);
|
|
29
|
+
if (index < 0) return path;
|
|
30
|
+
const twin = normalized.slice(0, index) + sep + "app.asar.unpacked" + sep + normalized.slice(index + PACKED.length);
|
|
31
|
+
return existsSync(twin) ? twin : path;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The window binary this package ships, as a path a child process can execute.
|
|
36
|
+
* @param moduleUrl - `import.meta.url` of this module.
|
|
37
|
+
* @returns absolute path of `lib/Xiaoqiu.exe`, outside the archive when packed.
|
|
38
|
+
*/
|
|
39
|
+
export function executablePath(moduleUrl) {
|
|
40
|
+
return unpackedPath(fileURLToPath(new URL("./Xiaoqiu.exe", moduleUrl)));
|
|
41
|
+
}
|
|
42
|
+
|
|
10
43
|
export function apply(ctx) {
|
|
11
44
|
// A web-only or headless server should never open a window on its host machine.
|
|
12
45
|
if (process.platform !== "win32" || !/[\\/]dsh-desktop-host[\\/]lib[\\/]index\.js$/i.test(process.argv[1] || "")) return;
|
|
13
46
|
const dataRoot = process.env.HQ_EDGE_HOME;
|
|
14
47
|
const directory = join(dataRoot && isAbsolute(dataRoot) ? dataRoot : join(homedir(), ".hq-edge"), "plugin-data", "dsh-xiaoqiu");
|
|
15
|
-
const exe =
|
|
48
|
+
const exe = executablePath(import.meta.url);
|
|
16
49
|
ctx.effect(() => {
|
|
17
50
|
let child, retry, stopping = false, latest = "idle light", failures = 0;
|
|
18
51
|
function start() {
|
|
19
|
-
|
|
52
|
+
let pet;
|
|
53
|
+
try {
|
|
54
|
+
pet = spawn(exe, [directory], { windowsHide: true, stdio: ["pipe", "ignore", "inherit"] });
|
|
55
|
+
} catch (error) {
|
|
56
|
+
// A packaging fault: the binary is not where a process can reach it, and
|
|
57
|
+
// every retry would fail the same way. Reported once, the window stays
|
|
58
|
+
// closed and the wake endpoint keeps answering so the client can say so.
|
|
59
|
+
console.warn("[xiaoqiu] 无法启动桌面窗口: " + error.message + " (" + exe + ")");
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
20
62
|
child = pet;
|
|
21
63
|
pet.stdin.on("error", () => {}); // Broken pipe while the native window is closing.
|
|
22
64
|
pet.on("spawn", () => pet.stdin.write(latest + "\n"));
|
|
23
|
-
pet.on("error", error => console.warn("[xiaoqiu] " + error.message));
|
|
65
|
+
pet.on("error", error => console.warn("[xiaoqiu] " + error.message + " (" + exe + ")"));
|
|
24
66
|
const started = Date.now();
|
|
25
67
|
pet.on("close", () => {
|
|
26
68
|
if (child !== pet) return;
|
|
@@ -39,6 +81,9 @@ export function apply(ctx) {
|
|
|
39
81
|
if (!child?.stdin.writable || child.exitCode !== null) {
|
|
40
82
|
clearTimeout(retry); failures = 0; start();
|
|
41
83
|
}
|
|
84
|
+
// Nothing to wake when the binary could not start at all: the client
|
|
85
|
+
// shows its retry hint instead of pretending the window opened.
|
|
86
|
+
if (!child?.stdin.writable) { res.writeHead(503); res.end(); return; }
|
|
42
87
|
child.stdin.write("wake\n");
|
|
43
88
|
res.writeHead(204, { "Cache-Control": "no-store" }); res.end(); return;
|
|
44
89
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huaqiu/dsh-xiaoqiu",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.30",
|
|
4
4
|
"description": "华秋 DSH Windows 桌面伙伴「小秋」",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
6
7
|
"main": "./lib/host.mjs",
|
|
7
8
|
"exports": {
|
|
8
9
|
".": "./lib/host.mjs",
|
|
@@ -22,10 +23,20 @@
|
|
|
22
23
|
]
|
|
23
24
|
}
|
|
24
25
|
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"react": "^18"
|
|
28
|
+
},
|
|
25
29
|
"files": [
|
|
26
30
|
"lib",
|
|
27
31
|
"cordis.patch.yml",
|
|
28
32
|
"README.md"
|
|
29
33
|
],
|
|
30
|
-
"
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"typecheck": "node --check src/host.mjs && node --check src/client.js",
|
|
39
|
+
"build": "node build.mjs",
|
|
40
|
+
"test": "vitest run"
|
|
41
|
+
}
|
|
31
42
|
}
|
package/lib/Xiaoqiu.exe
DELETED
|
Binary file
|