Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cb6467a3c | ||
|
|
d55c965e6d | ||
|
|
8df8663932 | ||
|
|
a312ff4567 | ||
|
|
8d94d7976c | ||
|
|
d573104072 | ||
|
|
ae253be3e1 | ||
|
|
f26f5be4c3 | ||
|
|
3281bfed12 | ||
|
|
bc59aca9e5 | ||
|
|
5c6735ada1 | ||
|
|
fd48130c32 | ||
|
|
5a8014864e | ||
|
|
03dc4cbe4c | ||
|
|
16fe93defd | ||
|
|
b493b395e4 | ||
|
|
593a8d92a3 | ||
|
|
6eca802ddd | ||
|
|
fbfe376403 | ||
|
|
4b12b435ed | ||
|
|
49659193fa | ||
|
|
3c75181fbc | ||
|
|
d11ea85b73 | ||
|
|
2fde035993 | ||
|
|
ee5c02f54f | ||
|
|
6fbcd6422e | ||
|
|
a1b8e96c3d | ||
|
|
5e12d5511b | ||
|
|
3b33e3b6bf | ||
|
|
dfa1372f9c | ||
|
|
3ab04c3627 | ||
|
|
8721f3de70 | ||
|
|
6bac79b346 | ||
|
|
c8b792b316 | ||
|
|
563b5a45bb | ||
|
|
aacaec535d | ||
|
|
8887771bec | ||
|
|
97597d5334 | ||
|
|
07ec5f9543 | ||
|
|
f8943ea78c | ||
|
|
aabe0cf29f | ||
|
|
974389f56b | ||
|
|
b1eec6050b | ||
|
|
30db99fc71 | ||
|
|
0bb1e1a8a6 | ||
|
|
f0207315b6 | ||
|
|
de1eb1f92f | ||
|
|
1fdbefd9c9 | ||
|
|
cbcbec7f83 | ||
|
|
6628da21ff | ||
|
|
e62742f65d | ||
|
|
7672925cac | ||
|
|
e7a6dd7a5b | ||
|
|
0e8454d494 | ||
|
|
c2c168da4e | ||
|
|
8150b4aee3 | ||
|
|
80bc11f1c2 | ||
|
|
e6c8388c37 | ||
|
|
5f96f4ab08 | ||
|
|
43d793ec36 | ||
|
|
4a2bffd5d2 | ||
|
|
fc19631676 | ||
|
|
059c1a3b76 | ||
|
|
2d5ee45163 | ||
|
|
c125fb2510 | ||
|
|
0d6a153621 | ||
|
|
003821a28a | ||
|
|
5f8d96a401 | ||
|
|
1c5e5484b9 | ||
|
|
a32fe323ab | ||
|
|
f622a3a5b0 | ||
|
|
061e65bc52 | ||
|
|
4cc4b6c02c | ||
|
|
790a42912e | ||
|
|
552d6e4cad | ||
|
|
2596728789 | ||
|
|
347840490e | ||
|
|
585669e0b3 | ||
|
|
f96d78be14 | ||
|
|
8270597fe2 | ||
|
|
c1b33c9c4f | ||
|
|
05ddd2b6f3 | ||
|
|
847d447d81 | ||
|
|
9eb8d95443 | ||
|
|
2235195587 | ||
|
|
827f942238 | ||
|
|
84f42a7604 | ||
|
|
e83cce28e6 | ||
|
|
93c981ff01 | ||
|
|
b6fde8fd4b | ||
|
|
8b6ca5c719 | ||
|
|
71fb8bb458 | ||
|
|
74be2f73a9 | ||
|
|
7ba5e3fa9c | ||
|
|
890ca4c5ad | ||
|
|
25766a9cdb | ||
|
|
59aaf36eb5 | ||
|
|
9204b58987 | ||
|
|
5cbd7bceac | ||
|
|
d7e1091074 | ||
|
|
6dcf33f71b | ||
|
|
2ffddf94b4 | ||
|
|
5e39b11566 | ||
|
|
fe139def0c | ||
|
|
e259833b5f | ||
|
|
809ce68cf3 | ||
|
|
8ff80090d8 | ||
|
|
f4993fa333 | ||
|
|
18acc57209 | ||
|
|
e62f6127fe | ||
|
|
957da43b2d | ||
|
|
9baa1e341c | ||
|
|
dc534b72b4 | ||
|
|
6e7c5e602a | ||
|
|
9bd4ac67ef | ||
|
|
2b8ea23074 | ||
|
|
371eb11629 | ||
|
|
655f015038 | ||
|
|
e8c9186a76 | ||
|
|
de523c5323 | ||
|
|
3ce0000215 | ||
|
|
1e80caa255 | ||
|
|
bcfedf5d36 | ||
|
|
9e9ae6f19b | ||
|
|
5a5977f93e | ||
|
|
2513513470 | ||
|
|
ceeb483cfb | ||
|
|
5c647308f4 | ||
|
|
14f72889dd | ||
|
|
66da194b05 | ||
|
|
fd23e88679 | ||
|
|
18df9e5c49 | ||
|
|
e800d55f9f | ||
|
|
7582fd2cfb | ||
|
|
ceeec602be | ||
|
|
21eef18f7b | ||
|
|
d085734c58 | ||
|
|
2a87c8d3b0 | ||
|
|
c91f5901a7 | ||
|
|
0802f77705 | ||
|
|
464ff5683f | ||
|
|
1eb7ac949a | ||
|
|
f20bb61724 | ||
|
|
7b023e5c82 | ||
|
|
5e67d50012 |
No files matched your search
@@ -1,2 +1,3 @@
|
||||
*.patch -text
|
||||
*.diff -text
|
||||
internal/guesttools/file_sync.sh text eol=lf
|
||||
@@ -1,32 +1,57 @@
|
||||
name: Bug 反馈
|
||||
description: 报告启动失败、安装异常或界面问题
|
||||
name: Bug Report / Bug 反馈
|
||||
description: Report a crash, startup failure, install error, or UI issue / 报告崩溃、启动失败、装机异常或界面问题
|
||||
title: "[Bug]: "
|
||||
labels: ["bug"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thank you for reporting an issue! Both **English** and **Chinese (中文)** are welcome.
|
||||
感谢反馈!支持使用 **中文** 或 **English** 填写,请勿附带真实序列号、MAC 地址、SMC OSK 或任何 Apple 系统镜像。
|
||||
|
||||
- type: dropdown
|
||||
id: area
|
||||
attributes:
|
||||
label: Area / 问题所属阶段或模块
|
||||
description: Select the closest area where the issue occurs / 选择最接近的问题模块
|
||||
options:
|
||||
- Host check & WHPX / 宿主机体检与 WHPX
|
||||
- Portable runtime install & update / 便携运行时安装与更新
|
||||
- macOS installer download & setup / 镜像下载与装机
|
||||
- VM startup, GPU & display / 虚拟机启动、显卡与显示
|
||||
- Performance & disk I/O / 性能与磁盘 I/O
|
||||
- Guest Tools (clipboard, shared folder, sleep) / Guest Tools(剪贴板、共享目录、防休眠)
|
||||
- Plugins, UI & CLI / 插件、界面与命令行
|
||||
- Other / 其他
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: 问题描述
|
||||
description: 简述遇到了什么问题,以及预期行为。
|
||||
label: What happened? / 问题描述
|
||||
description: Describe the actual behavior and what you expected / 简述实际现象以及你的预期行为
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: env
|
||||
attributes:
|
||||
label: 宿主机环境
|
||||
description: 建议附带 `reims-go doctor` 输出(请勿包含序列号、MAC 地址或 OSK 等敏感信息)。
|
||||
label: Host & Runtime Environment / 宿主机与运行时环境
|
||||
description: Paste `reims-go doctor` output or fill in the summary below (redact any sensitive info) / 建议粘贴 `reims-go doctor` 输出或填写以下信息
|
||||
placeholder: |
|
||||
- Windows 版本:例如 Windows 11 24H2 / Windows 10 22H2
|
||||
- CPU / 显卡:例如 i7-12700K / RTX 4070 Ti
|
||||
- Reims-Go 版本:例如 v0.2.0
|
||||
- 运行时版本:例如 runtime-3731afd
|
||||
- Windows: e.g. Windows 11 24H2 / Windows 10 22H2 (Build 19045)
|
||||
- CPU / GPU: e.g. i7-12700K / RTX 4070 Ti (Driver version)
|
||||
- Reims-Go: e.g. v0.2.8
|
||||
- Runtime: e.g. runtime-3731afd (stable / alpha)
|
||||
- macOS guest: e.g. macOS 26.x
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: steps
|
||||
attributes:
|
||||
label: 复现步骤
|
||||
label: Steps to Reproduce / 复现步骤
|
||||
placeholder: |
|
||||
1. ...
|
||||
2. ...
|
||||
@@ -34,5 +59,8 @@ body:
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: 相关日志(可选)
|
||||
label: Logs or Redacted Diagnostics Bundle / 日志或脱敏排障包(可选)
|
||||
description: |
|
||||
You can attach the redacted diagnostics archive exported from the app, or paste relevant QEMU / console logs here.
|
||||
可直接拖入应用导出的「脱敏排障包」,或粘贴相关 QEMU / 日志片段。
|
||||
render: text
|
||||
@@ -1,5 +1,8 @@
|
||||
blank_issues_enabled: true
|
||||
contact_links:
|
||||
- name: 开发路线图(Roadmap)
|
||||
- name: Roadmap / 开发路线图
|
||||
url: https://github.com/Nwflower/Reims-Go/blob/main/docs/roadmap.md
|
||||
about: 查看当前进度与已规划功能,避免重复提问
|
||||
about: Check current progress and planned features before opening a duplicate / 查看当前进度与已规划功能,避免重复提问
|
||||
- name: Documentation / 使用文档(中文 · English)
|
||||
url: https://github.com/Nwflower/Reims-Go/blob/main/README.en.md
|
||||
about: Quick start, requirements, and troubleshooting guides / 快速开始、环境要求与常见问题排查
|
||||
@@ -1,16 +1,24 @@
|
||||
name: 功能建议
|
||||
description: 提出新功能想法或体验改进建议
|
||||
name: Feature Request / 功能建议
|
||||
description: Propose a new feature or UX improvement / 提出新功能想法或体验改进建议
|
||||
title: "[Feature]: "
|
||||
labels: ["enhancement"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Both **English** and **Chinese (中文)** are welcome. Feel free to check the [Roadmap](https://github.com/Nwflower/Reims-Go/blob/main/docs/roadmap.md) first.
|
||||
支持使用 **中文** 或 **English** 填写,建议先查阅 [开发路线图](https://github.com/Nwflower/Reims-Go/blob/main/docs/roadmap.md) 确认是否已在规划中。
|
||||
|
||||
- type: textarea
|
||||
id: summary
|
||||
attributes:
|
||||
label: 你希望解决什么问题或新增什么功能?
|
||||
label: Problem or Feature Idea / 你希望解决什么问题或新增什么功能?
|
||||
description: Describe the workflow or pain point this would improve / 说明具体使用场景、痛点或期望能力
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: details
|
||||
attributes:
|
||||
label: 补充说明(可选)
|
||||
description: 使用场景、交互设想或参考案例。
|
||||
label: Proposed Design or References (Optional) / 交互设想或参考案例(可选)
|
||||
description: Mockups, CLI examples, or similar tools / 可附草图、CLI 用法设想或参考产品
|
||||
@@ -0,0 +1,51 @@
|
||||
name: Hardware Compatibility Report / 硬件兼容性反馈
|
||||
description: Share GPU, CPU, or Windows 10/11 vGPU compatibility test results / 反馈显卡、CPU 或 Windows 10/11 的 vGPU 实测兼容情况
|
||||
title: "[Compat]: "
|
||||
labels: ["compatibility"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Help improve the Windows hardware compatibility matrix (GPU Vulkan drivers, hybrid CPUs, Windows 10/11 WHPX). Both **English** and **Chinese (中文)** are welcome.
|
||||
欢迎提交你的宿主机硬件实测结果(NVIDIA / AMD / Intel Arc 显卡驱动、混合架构 CPU、Win10/Win11 WHPX),帮助完善兼容性分级。
|
||||
|
||||
- type: dropdown
|
||||
id: result
|
||||
attributes:
|
||||
label: Result / 实测结果
|
||||
options:
|
||||
- Works cleanly with reims-vgpu / reims-vgpu 硬件加速正常可用
|
||||
- Boots with issues (artifacts, device lost, sleep/reboot issue) / 可启动但存在异常(花屏、设备丢失、休眠或重启异常)
|
||||
- Fails on reims-vgpu, works on VMware SVGA / reims-vgpu 不可用,切换 VMware SVGA 后正常
|
||||
- Fails to boot (WHPX / CPU / kernel-irqchip issue) / 无法启动(WHPX、CPU 或中断控制器问题)
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: hardware
|
||||
attributes:
|
||||
label: Hardware & OS Details / 硬件与系统信息
|
||||
description: Paste `reims-go doctor` output (recommended) or fill in the fields below / 建议直接粘贴 `reims-go doctor` 输出,或按模板填写
|
||||
placeholder: |
|
||||
- Windows: e.g. Windows 11 24H2 (Build 26100) / Windows 10 22H2 (Build 19045)
|
||||
- CPU: e.g. Intel Core Ultra 9 285H / Ryzen 7 7840HS
|
||||
- GPU & Driver: e.g. AMD Radeon 780M / RTX 4070 Ti (Driver xx.x.x, Vulkan 1.x)
|
||||
- Reims-Go & Runtime: e.g. v0.2.8 + runtime-3731afd (stable / alpha)
|
||||
- macOS Guest & Controller: e.g. macOS 26.x, 8 vCPU, 16G RAM, NVMe / VirtIO
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: notes
|
||||
attributes:
|
||||
label: Observations & Workarounds / 现象说明与有效绕过方式
|
||||
description: Note whether kernel-irqchip, P-core pinning, or a specific driver version made a difference / 说明是否开启了 kernel-irqchip、P 核绑定,或切换特定显卡驱动后的差异
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: Relevant Logs (Optional) / 相关日志片段(可选)
|
||||
description: Redact serial numbers or MAC addresses before posting / 粘贴前请确保不含序列号或 MAC 地址
|
||||
render: text
|
||||
@@ -0,0 +1,68 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 743 180" width="743" height="180" role="img" aria-label="Reims-Go"><svg x="0" y="0" width="180" height="180" viewBox="0 0 1024 1024">
|
||||
<defs>
|
||||
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0" stop-color="#3b8cff"/>
|
||||
<stop offset="0.55" stop-color="#2f5bea"/>
|
||||
<stop offset="1" stop-color="#3b1fb8"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="gloss" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#ffffff" stop-opacity="0.28"/>
|
||||
<stop offset="0.45" stop-color="#ffffff" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="sky" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#6d5dfc"/>
|
||||
<stop offset="0.45" stop-color="#ff7a9a"/>
|
||||
<stop offset="0.8" stop-color="#ffb86b"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="lake" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#2f6bff"/>
|
||||
<stop offset="1" stop-color="#1a2a8f"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="bolt" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#ffe14d"/>
|
||||
<stop offset="1" stop-color="#ff9f0a"/>
|
||||
</linearGradient>
|
||||
<clipPath id="screen">
|
||||
<rect x="252" y="372" width="520" height="318" rx="26"/>
|
||||
</clipPath>
|
||||
<filter id="shadow" x="-20%" y="-20%" width="140%" height="150%">
|
||||
<feDropShadow dx="0" dy="22" stdDeviation="26" flood-color="#0b0d3a" flood-opacity="0.35"/>
|
||||
</filter>
|
||||
<filter id="iconShadow" x="-10%" y="-10%" width="120%" height="125%">
|
||||
<feDropShadow dx="0" dy="14" stdDeviation="16" flood-color="#000000" flood-opacity="0.22"/>
|
||||
</filter>
|
||||
</defs>
|
||||
|
||||
<!-- squircle base -->
|
||||
<g filter="url(#iconShadow)">
|
||||
<rect x="80" y="80" width="864" height="864" rx="200" fill="url(#bg)"/>
|
||||
<rect x="80" y="80" width="864" height="864" rx="200" fill="url(#gloss)"/>
|
||||
</g>
|
||||
|
||||
<!-- VM window -->
|
||||
<g filter="url(#shadow)">
|
||||
<rect x="220" y="268" width="584" height="454" rx="52" fill="#f7f8fc"/>
|
||||
</g>
|
||||
<circle cx="280" cy="322" r="17" fill="#ff5f57"/>
|
||||
<circle cx="332" cy="322" r="17" fill="#febc2e"/>
|
||||
<circle cx="384" cy="322" r="17" fill="#28c840"/>
|
||||
|
||||
<!-- guest display: a lake at dusk -->
|
||||
<g clip-path="url(#screen)">
|
||||
<rect x="252" y="372" width="520" height="318" fill="url(#sky)"/>
|
||||
<circle cx="600" cy="540" r="44" fill="#fff3d6" opacity="0.9"/>
|
||||
<path d="M252 560 L340 470 L400 520 L480 430 L560 505 L620 465 L700 530 L772 480 L772 600 L252 600 Z" fill="#2b2d7a"/>
|
||||
<path d="M252 585 L330 530 L420 575 L500 520 L590 570 L672 535 L772 580 L772 610 L252 610 Z" fill="#1c1f5e"/>
|
||||
<rect x="252" y="598" width="520" height="92" fill="url(#lake)"/>
|
||||
<rect x="560" y="616" width="80" height="6" rx="3" fill="#fff3d6" opacity="0.7"/>
|
||||
<rect x="574" y="636" width="52" height="6" rx="3" fill="#fff3d6" opacity="0.5"/>
|
||||
<rect x="586" y="656" width="28" height="6" rx="3" fill="#fff3d6" opacity="0.35"/>
|
||||
</g>
|
||||
|
||||
<!-- GPU acceleration badge -->
|
||||
<g filter="url(#shadow)">
|
||||
<circle cx="776" cy="724" r="128" fill="#16182e"/>
|
||||
</g>
|
||||
<circle cx="776" cy="724" r="128" fill="none" stroke="#ffffff" stroke-opacity="0.92" stroke-width="16"/>
|
||||
<path d="M800 628 L708 744 L768 744 L748 822 L846 700 L784 700 Z" fill="url(#bolt)" stroke="#ffcf3a" stroke-width="6" stroke-linejoin="round"/>
|
||||
</svg><g transform="translate(206 126)"><defs><linearGradient id="wm" gradientUnits="userSpaceOnUse" x1="376" y1="0" x2="531" y2="0"><stop offset="0" stop-color="#3b8cff"/><stop offset="0.5" stop-color="#6d5dfc"/><stop offset="1" stop-color="#ff7a9a"/></linearGradient><linearGradient id="wmb" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#ffd43b"/><stop offset="1" stop-color="#ff9f0a"/></linearGradient></defs><g fill="none" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"><path d="M7.5 -7.5V-36A24 28.5 0 0 1 31.5 -64.5" stroke="#f4f5fa"/><path d="M50.5 -36H107.5A28.5 28.5 0 1 0 100.18 -16.93" stroke="#f4f5fa"/><path d="M133.5 -64.5V-7.5" stroke="#f4f5fa"/><circle cx="133.5" cy="-94" r="9" fill="#ff7a9a"/><path d="M159.5 -7.5V-36A22 28.5 0 0 1 203.5 -36V-7.5M203.5 -36A22 28.5 0 0 1 247.5 -36V-7.5" stroke="#f4f5fa"/><path d="M311.05 -59.02A21 14.25 0 0 0 273.5 -50.25A21 14.25 0 0 0 294.5 -36A21 14.25 0 0 1 315.5 -21.75A21 14.25 0 0 1 277.95 -12.98" stroke="#f4f5fa"/><path d="M340.5 -36H358.5" stroke="#5d6382"/><path d="M440.5 -36A28.5 28.5 0 1 1 440.5 -36.01" stroke="url(#wm)"/><path d="M440.5 -64.5V0A28.5 22.5 0 0 1 387.32 11.25" stroke="url(#wm)"/><path d="M523.5 -36A28.5 28.5 0 1 1 523.5 -36.01" stroke="url(#wm)"/></g></g></svg>
|
||||
|
After Width: | Height: | Size: 4.5 KiB |
@@ -0,0 +1,68 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 743 180" width="743" height="180" role="img" aria-label="Reims-Go"><svg x="0" y="0" width="180" height="180" viewBox="0 0 1024 1024">
|
||||
<defs>
|
||||
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0" stop-color="#3b8cff"/>
|
||||
<stop offset="0.55" stop-color="#2f5bea"/>
|
||||
<stop offset="1" stop-color="#3b1fb8"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="gloss" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#ffffff" stop-opacity="0.28"/>
|
||||
<stop offset="0.45" stop-color="#ffffff" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="sky" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#6d5dfc"/>
|
||||
<stop offset="0.45" stop-color="#ff7a9a"/>
|
||||
<stop offset="0.8" stop-color="#ffb86b"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="lake" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#2f6bff"/>
|
||||
<stop offset="1" stop-color="#1a2a8f"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="bolt" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#ffe14d"/>
|
||||
<stop offset="1" stop-color="#ff9f0a"/>
|
||||
</linearGradient>
|
||||
<clipPath id="screen">
|
||||
<rect x="252" y="372" width="520" height="318" rx="26"/>
|
||||
</clipPath>
|
||||
<filter id="shadow" x="-20%" y="-20%" width="140%" height="150%">
|
||||
<feDropShadow dx="0" dy="22" stdDeviation="26" flood-color="#0b0d3a" flood-opacity="0.35"/>
|
||||
</filter>
|
||||
<filter id="iconShadow" x="-10%" y="-10%" width="120%" height="125%">
|
||||
<feDropShadow dx="0" dy="14" stdDeviation="16" flood-color="#000000" flood-opacity="0.22"/>
|
||||
</filter>
|
||||
</defs>
|
||||
|
||||
<!-- squircle base -->
|
||||
<g filter="url(#iconShadow)">
|
||||
<rect x="80" y="80" width="864" height="864" rx="200" fill="url(#bg)"/>
|
||||
<rect x="80" y="80" width="864" height="864" rx="200" fill="url(#gloss)"/>
|
||||
</g>
|
||||
|
||||
<!-- VM window -->
|
||||
<g filter="url(#shadow)">
|
||||
<rect x="220" y="268" width="584" height="454" rx="52" fill="#f7f8fc"/>
|
||||
</g>
|
||||
<circle cx="280" cy="322" r="17" fill="#ff5f57"/>
|
||||
<circle cx="332" cy="322" r="17" fill="#febc2e"/>
|
||||
<circle cx="384" cy="322" r="17" fill="#28c840"/>
|
||||
|
||||
<!-- guest display: a lake at dusk -->
|
||||
<g clip-path="url(#screen)">
|
||||
<rect x="252" y="372" width="520" height="318" fill="url(#sky)"/>
|
||||
<circle cx="600" cy="540" r="44" fill="#fff3d6" opacity="0.9"/>
|
||||
<path d="M252 560 L340 470 L400 520 L480 430 L560 505 L620 465 L700 530 L772 480 L772 600 L252 600 Z" fill="#2b2d7a"/>
|
||||
<path d="M252 585 L330 530 L420 575 L500 520 L590 570 L672 535 L772 580 L772 610 L252 610 Z" fill="#1c1f5e"/>
|
||||
<rect x="252" y="598" width="520" height="92" fill="url(#lake)"/>
|
||||
<rect x="560" y="616" width="80" height="6" rx="3" fill="#fff3d6" opacity="0.7"/>
|
||||
<rect x="574" y="636" width="52" height="6" rx="3" fill="#fff3d6" opacity="0.5"/>
|
||||
<rect x="586" y="656" width="28" height="6" rx="3" fill="#fff3d6" opacity="0.35"/>
|
||||
</g>
|
||||
|
||||
<!-- GPU acceleration badge -->
|
||||
<g filter="url(#shadow)">
|
||||
<circle cx="776" cy="724" r="128" fill="#16182e"/>
|
||||
</g>
|
||||
<circle cx="776" cy="724" r="128" fill="none" stroke="#ffffff" stroke-opacity="0.92" stroke-width="16"/>
|
||||
<path d="M800 628 L708 744 L768 744 L748 822 L846 700 L784 700 Z" fill="url(#bolt)" stroke="#ffcf3a" stroke-width="6" stroke-linejoin="round"/>
|
||||
</svg><g transform="translate(206 126)"><defs><linearGradient id="wm" gradientUnits="userSpaceOnUse" x1="376" y1="0" x2="531" y2="0"><stop offset="0" stop-color="#3b8cff"/><stop offset="0.5" stop-color="#6d5dfc"/><stop offset="1" stop-color="#ff7a9a"/></linearGradient><linearGradient id="wmb" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#ffd43b"/><stop offset="1" stop-color="#ff9f0a"/></linearGradient></defs><g fill="none" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"><path d="M7.5 -7.5V-36A24 28.5 0 0 1 31.5 -64.5" stroke="#16182e"/><path d="M50.5 -36H107.5A28.5 28.5 0 1 0 100.18 -16.93" stroke="#16182e"/><path d="M133.5 -64.5V-7.5" stroke="#16182e"/><circle cx="133.5" cy="-94" r="9" fill="#ff7a9a"/><path d="M159.5 -7.5V-36A22 28.5 0 0 1 203.5 -36V-7.5M203.5 -36A22 28.5 0 0 1 247.5 -36V-7.5" stroke="#16182e"/><path d="M311.05 -59.02A21 14.25 0 0 0 273.5 -50.25A21 14.25 0 0 0 294.5 -36A21 14.25 0 0 1 315.5 -21.75A21 14.25 0 0 1 277.95 -12.98" stroke="#16182e"/><path d="M340.5 -36H358.5" stroke="#a3a8bf"/><path d="M440.5 -36A28.5 28.5 0 1 1 440.5 -36.01" stroke="url(#wm)"/><path d="M440.5 -64.5V0A28.5 22.5 0 0 1 387.32 11.25" stroke="url(#wm)"/><path d="M523.5 -36A28.5 28.5 0 1 1 523.5 -36.01" stroke="url(#wm)"/></g></g></svg>
|
||||
|
After Width: | Height: | Size: 4.5 KiB |
@@ -1,309 +0,0 @@
|
||||
name: Build Portable Runtime (Alpha)
|
||||
|
||||
# Daily: build the newest steelbrain/reims-vgpu commit with the patch queue
|
||||
# (patches/series.txt) and publish it as a GitHub prerelease = the alpha
|
||||
# channel (portable-runtime-spec.md section 6). Never publishes stable:
|
||||
# promotion needs a real-host smoke test and a person (AGENTS.md rule 6).
|
||||
on:
|
||||
schedule:
|
||||
- cron: "23 3 * * *" # 03:23 UTC daily; skipped when upstream has not moved
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
upstream_commit:
|
||||
description: "steelbrain/reims-vgpu commit (empty = upstream default branch HEAD)"
|
||||
required: false
|
||||
default: ""
|
||||
publish:
|
||||
description: "Publish as an alpha prerelease (never stable)"
|
||||
type: boolean
|
||||
default: true
|
||||
rebuild:
|
||||
description: "Build a new patch revision (runtime-<commit>-pN) even if this upstream commit is already released"
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
|
||||
concurrency:
|
||||
group: build-runtime
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
UPSTREAM_URL: https://github.com/steelbrain/reims-vgpu.git
|
||||
KEEP_ALPHAS: "7" # unpromoted alpha prereleases kept; older ones are deleted
|
||||
|
||||
jobs:
|
||||
resolve:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
commit: ${{ steps.r.outputs.commit }}
|
||||
skip: ${{ steps.r.outputs.skip }}
|
||||
suffix: ${{ steps.r.outputs.suffix }}
|
||||
steps:
|
||||
- id: r
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
WANT: ${{ inputs.upstream_commit }}
|
||||
REBUILD: ${{ inputs.rebuild }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git clone -q --filter=blob:none --no-checkout "$UPSTREAM_URL" up
|
||||
commit="$(git -C up rev-parse --verify "${WANT:-HEAD}^{commit}")"
|
||||
echo "commit=$commit" >> "$GITHUB_OUTPUT"
|
||||
# Already published (alpha or stable) under any short-hash length or -pN revision?
|
||||
max_rev=0
|
||||
for tag in $(gh release list -R "$GITHUB_REPOSITORY" --limit 1000 --json tagName -q '.[].tagName' | grep '^runtime-' || true); do
|
||||
rest="${tag#runtime-}"
|
||||
base="${rest%%-p*}"
|
||||
case "$commit" in
|
||||
"$base"*)
|
||||
rev=1
|
||||
if [ "$rest" != "$base" ]; then
|
||||
num="${rest#"$base"-p}"
|
||||
case "$num" in
|
||||
''|*[!0-9]*) ;;
|
||||
*) rev="$num" ;;
|
||||
esac
|
||||
fi
|
||||
if [ "$rev" -gt "$max_rev" ]; then max_rev="$rev"; fi
|
||||
echo "Upstream $commit is already released as $tag (rev $rev)"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
skip=false
|
||||
suffix=""
|
||||
if [ "$max_rev" -gt 0 ]; then
|
||||
if [ "$REBUILD" = "true" ]; then
|
||||
suffix="-p$((max_rev + 1))"
|
||||
echo "Rebuild requested: will publish with suffix $suffix"
|
||||
else
|
||||
skip=true
|
||||
fi
|
||||
fi
|
||||
echo "skip=$skip" >> "$GITHUB_OUTPUT"
|
||||
echo "suffix=$suffix" >> "$GITHUB_OUTPUT"
|
||||
|
||||
build:
|
||||
needs: resolve
|
||||
if: needs.resolve.outputs.skip != 'true'
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 150
|
||||
outputs:
|
||||
short: ${{ steps.patches.outputs.short }}
|
||||
release_id: ${{ steps.patches.outputs.release_id }}
|
||||
applied: ${{ steps.patches.outputs.applied }}
|
||||
merged: ${{ steps.patches.outputs.merged }}
|
||||
conflict: ${{ steps.patches.outputs.conflict }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup MSYS2 CLANG64
|
||||
id: msys2
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
msystem: CLANG64
|
||||
update: true
|
||||
install: >-
|
||||
git zstd tar mingw-w64-clang-x86_64-toolchain
|
||||
mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-meson
|
||||
mingw-w64-clang-x86_64-ninja mingw-w64-clang-x86_64-pkgconf
|
||||
mingw-w64-clang-x86_64-glib2 mingw-w64-clang-x86_64-pixman
|
||||
mingw-w64-clang-x86_64-gtk3 mingw-w64-clang-x86_64-libslirp
|
||||
mingw-w64-clang-x86_64-libusb mingw-w64-clang-x86_64-libva
|
||||
mingw-w64-clang-x86_64-mesa mingw-w64-clang-x86_64-vulkan-loader
|
||||
mingw-w64-clang-x86_64-python mingw-w64-clang-x86_64-python-pip
|
||||
|
||||
- name: Check out upstream and apply the patch queue
|
||||
id: patches
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$work = Join-Path $env:RUNNER_TEMP 'reims-vgpu'
|
||||
foreach ($d in 'cargo', 'xdg-data', 'xdg-cache') { New-Item -ItemType Directory -Force -Path (Join-Path $env:RUNNER_TEMP $d) | Out-Null }
|
||||
# The runner's git defaults to core.autocrlf=true; LF patches need an LF
|
||||
# checkout (upstream also rewrites CRLF files to LF, install-ctl.sh).
|
||||
git config --global core.autocrlf false
|
||||
git clone -q $env:UPSTREAM_URL $work
|
||||
if ($LASTEXITCODE) { throw 'clone failed' }
|
||||
git -C $work checkout -q '${{ needs.resolve.outputs.commit }}'
|
||||
if ($LASTEXITCODE) { throw 'checkout failed' }
|
||||
git -C $work submodule update --init --depth 1 vendor/qemu
|
||||
if ($LASTEXITCODE) { git -C $work submodule update --init vendor/qemu }
|
||||
if ($LASTEXITCODE) { throw 'vendor/qemu submodule failed' }
|
||||
$short = (git -C $work rev-parse --short=7 HEAD).Trim()
|
||||
$releaseId = "$short${{ needs.resolve.outputs.suffix }}"
|
||||
"short=$short" >> $env:GITHUB_OUTPUT
|
||||
"release_id=$releaseId" >> $env:GITHUB_OUTPUT
|
||||
|
||||
# Applies what applies, skips what upstream already has, stops on a
|
||||
# conflict without touching the patch (AGENTS.md rule 4).
|
||||
$resultFile = Join-Path $env:RUNNER_TEMP 'patches.json'
|
||||
try {
|
||||
pwsh -NoProfile -File scripts/apply-patch-series.ps1 -ReimsRepo $work -ResultFile $resultFile
|
||||
$ok = $LASTEXITCODE -eq 0
|
||||
} finally {
|
||||
if (Test-Path $resultFile) {
|
||||
$r = Get-Content -Raw $resultFile | ConvertFrom-Json
|
||||
"applied=$(@($r.applied) -join ',')" >> $env:GITHUB_OUTPUT
|
||||
"merged=$(@($r.merged) -join ',')" >> $env:GITHUB_OUTPUT
|
||||
"conflict=$($r.conflict)" >> $env:GITHUB_OUTPUT
|
||||
"APPLIED_PATCHES=$(@($r.applied) -join ',')" >> $env:GITHUB_ENV
|
||||
}
|
||||
}
|
||||
if (-not $ok) { throw 'patch queue does not apply' }
|
||||
"UPSTREAM_DIR=$work" >> $env:GITHUB_ENV
|
||||
"SHORT_COMMIT=$short" >> $env:GITHUB_ENV
|
||||
"RELEASE_ID=$releaseId" >> $env:GITHUB_ENV
|
||||
"CARGO_HOME=$(Join-Path $env:RUNNER_TEMP 'cargo')" >> $env:GITHUB_ENV
|
||||
"XDG_DATA_HOME=$(Join-Path $env:RUNNER_TEMP 'xdg-data')" >> $env:GITHUB_ENV
|
||||
"XDG_CACHE_HOME=$(Join-Path $env:RUNNER_TEMP 'xdg-cache')" >> $env:GITHUB_ENV
|
||||
|
||||
- name: Build upstream runtime in MSYS2 CLANG64
|
||||
shell: msys2 {0}
|
||||
env:
|
||||
REIMS_INSTALL_SKIP_HOST_CHECKS: "1"
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd "$(cygpath -u "$UPSTREAM_DIR")"
|
||||
# Upstream's own non-interactive CLANG64 build script.
|
||||
bash scripts/install-ctl.sh --yes
|
||||
|
||||
- name: Package alpha runtime and source archives
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$outDir = Join-Path $env:RUNNER_TEMP 'releases'
|
||||
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
|
||||
# In-process call, so an empty list (every patch already upstream) binds
|
||||
# as an empty array rather than being dropped as an empty argument.
|
||||
$applied = @($env:APPLIED_PATCHES -split ',' | Where-Object { $_ })
|
||||
& ./scripts/pack-runtime.ps1 `
|
||||
-ReimsRepo $env:UPSTREAM_DIR `
|
||||
-CargoHome $env:CARGO_HOME `
|
||||
-QemuDir (Join-Path $env:XDG_DATA_HOME 'reims-ctl\qemu\current') `
|
||||
-Msys2 '${{ steps.msys2.outputs.msys2-location }}' `
|
||||
-OutDir $outDir `
|
||||
-TempRoot $env:RUNNER_TEMP `
|
||||
-Channel alpha `
|
||||
-ReleaseId $env:RELEASE_ID `
|
||||
-Patches $applied
|
||||
|
||||
- name: Alpha entry gate
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
& ./scripts/check-runtime-alpha.ps1 `
|
||||
-OutDir (Join-Path $env:RUNNER_TEMP 'releases') `
|
||||
-Commit $env:RELEASE_ID -RequireSlim `
|
||||
-Zstd (Join-Path '${{ steps.msys2.outputs.msys2-location }}' 'usr\bin\zstd.exe') `
|
||||
-AppliedPatches @($env:APPLIED_PATCHES -split ',' | Where-Object { $_ })
|
||||
|
||||
- name: Upload alpha artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: reims-runtime-win-x64-${{ env.RELEASE_ID }}-alpha
|
||||
path: |
|
||||
${{ runner.temp }}/releases/reims-runtime-*.tar.zst
|
||||
${{ runner.temp }}/releases/SHA256SUMS.txt
|
||||
retention-days: 14
|
||||
|
||||
- name: Publish alpha prerelease (never stable)
|
||||
if: github.event_name == 'schedule' || inputs.publish
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
MERGED: ${{ steps.patches.outputs.merged }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$c = $env:RELEASE_ID
|
||||
$short = $env:SHORT_COMMIT
|
||||
$dir = Join-Path $env:RUNNER_TEMP 'releases'
|
||||
$assets = @("reims-runtime-win-x64-$c.tar.zst", "reims-runtime-src-$c.tar.zst", "reims-runtime-msys2-src-$c.tar.zst", "reims-runtime-symbols-$c.tar.zst", 'SHA256SUMS.txt') |
|
||||
ForEach-Object { Join-Path $dir $_ }
|
||||
$applied = if ($env:APPLIED_PATCHES) { ($env:APPLIED_PATCHES -split ',' | ForEach-Object { "- ``$_``" }) -join "`n" } else { '- (none)' }
|
||||
$merged = if ($env:MERGED) { "`n`nAlready upstream, skipped (retire from patches/): $env:MERGED" } else { '' }
|
||||
$notes = @"
|
||||
**Alpha** runtime (``$c``), built automatically from upstream [steelbrain/reims-vgpu@$short](https://github.com/steelbrain/reims-vgpu/commit/${{ needs.resolve.outputs.commit }}).
|
||||
|
||||
Not smoke-tested on a real host. It becomes stable only after ``scripts/smoke-runtime.ps1`` passes on a real Windows host and a person approves (portable-runtime-spec.md section 6).
|
||||
|
||||
Local patches applied (sources and patches are in the attached source packages):
|
||||
$applied$merged
|
||||
|
||||
The optional ``reims-runtime-symbols-$c.tar.zst`` contains matching debug files for crash analysis.
|
||||
|
||||
Build: $env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID
|
||||
"@
|
||||
gh release create "runtime-$c" @assets --prerelease --title "Portable Runtime runtime-$c (alpha)" --notes $notes
|
||||
if ($LASTEXITCODE) { throw "gh release create failed ($LASTEXITCODE)" }
|
||||
|
||||
- name: Mirror alpha prerelease to GitCode (best-effort)
|
||||
if: github.event_name == 'schedule' || inputs.publish
|
||||
continue-on-error: true
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITCODE_TOKEN: ${{ secrets.GITCODE_TOKEN }}
|
||||
GITHUB_REPO: ${{ github.repository }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
if (-not $env:GITCODE_TOKEN) {
|
||||
Write-Host 'GITCODE_TOKEN not set; skipping GitCode mirror'
|
||||
exit 0
|
||||
}
|
||||
$tag = "runtime-$($env:RELEASE_ID)"
|
||||
git fetch --tags origin
|
||||
git -c credential.helper= push "https://Nwflower:$($env:GITCODE_TOKEN)@gitcode.com/Nwflower/Reims-Go.git" "refs/tags/${tag}:refs/tags/${tag}"
|
||||
python scripts/sync-gitcode-release.py $tag
|
||||
|
||||
- name: Prune old alpha prereleases
|
||||
if: github.event_name == 'schedule' || inputs.publish
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
# Only unpromoted runtime prereleases; stable releases are never touched.
|
||||
$alphas = gh release list -R $env:GITHUB_REPOSITORY --limit 1000 --json tagName,isPrerelease,isDraft,createdAt | ConvertFrom-Json |
|
||||
Where-Object { $_.tagName -like 'runtime-*' -and $_.isPrerelease -and -not $_.isDraft } |
|
||||
Sort-Object createdAt -Descending
|
||||
$alphas | Select-Object -Skip ([int]$env:KEEP_ALPHAS) | ForEach-Object {
|
||||
Write-Host "Deleting old alpha $($_.tagName)"
|
||||
gh release delete $_.tagName -R $env:GITHUB_REPOSITORY --yes --cleanup-tag
|
||||
}
|
||||
|
||||
report:
|
||||
needs: [resolve, build]
|
||||
if: always() && needs.resolve.outputs.skip != 'true' && (failure() || needs.build.outputs.merged != '')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
RESULT: ${{ needs.build.result }}
|
||||
COMMIT: ${{ needs.resolve.outputs.commit }}
|
||||
CONFLICT: ${{ needs.build.outputs.conflict }}
|
||||
MERGED: ${{ needs.build.outputs.merged }}
|
||||
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# One open issue per kind; later runs add a comment instead of a new issue.
|
||||
file_issue() {
|
||||
local title="$1" body="$2" n
|
||||
n="$(gh issue list -R "$GITHUB_REPOSITORY" --state open --search "in:title \"$title\"" --json number,title -q ".[] | select(.title == \"$title\") | .number" | head -n1)"
|
||||
if [ -n "$n" ]; then
|
||||
gh issue comment "$n" -R "$GITHUB_REPOSITORY" --body "$body"
|
||||
else
|
||||
gh issue create -R "$GITHUB_REPOSITORY" --title "$title" --body "$body"
|
||||
fi
|
||||
}
|
||||
if [ "$RESULT" != "success" ]; then
|
||||
if [ -n "$CONFLICT" ]; then
|
||||
why="Patch \`$CONFLICT\` neither applies to upstream \`$COMMIT\` nor is already there. Per AGENTS.md rule 4 the patch was not edited; a person decides how to rebase or retire it."
|
||||
else
|
||||
why="The build, packaging or alpha gate failed for upstream \`$COMMIT\`; see the log."
|
||||
fi
|
||||
file_issue "Runtime alpha build failed" "$why"$'\n\n'"Run: $RUN_URL"$'\n\n'"No alpha was published."
|
||||
fi
|
||||
if [ -n "$MERGED" ]; then
|
||||
file_issue "Patch queue: patches already upstream" "Upstream \`$COMMIT\` already contains: \`$MERGED\`. They were skipped. Record the merge commit in portable-runtime-spec.md section 5, then remove them from patches/ and patches/series.txt."$'\n\n'"Run: $RUN_URL"
|
||||
fi
|
||||
@@ -39,12 +39,19 @@ jobs:
|
||||
& ./scripts/build-release-notes.ps1 -Tag $ver -OutFile $tmp
|
||||
Write-Host "PASS CHANGELOG.md contains valid release notes for $ver ($((Get-Item -LiteralPath $tmp).Length) bytes)"
|
||||
|
||||
- name: Frontend build
|
||||
- name: Frontend test & build
|
||||
shell: pwsh
|
||||
run: |
|
||||
pnpm --dir frontend install --frozen-lockfile
|
||||
pnpm --dir frontend test
|
||||
pnpm --dir frontend build
|
||||
|
||||
- name: Debug workspace hygiene check & self-test
|
||||
shell: pwsh
|
||||
run: |
|
||||
node scripts/debug/check.mjs
|
||||
node --test scripts/debug/debug.test.mjs
|
||||
|
||||
- name: Go test & vet
|
||||
shell: pwsh
|
||||
run: |
|
||||
|
||||
@@ -0,0 +1,239 @@
|
||||
name: Dev Release (Rolling)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- "docs/**"
|
||||
- "README.md"
|
||||
- "README.en.md"
|
||||
- "AGENTS.md"
|
||||
- ".github/ISSUE_TEMPLATE/**"
|
||||
- ".github/readme/**"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
concurrency:
|
||||
group: dev-release-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
dev-release:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: pnpm
|
||||
cache-dependency-path: frontend/pnpm-lock.yaml
|
||||
|
||||
- name: Resolve rolling dev version
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
function Parse-StableSemVer([string]$v) {
|
||||
if ($v -match '^v([0-9]+)\.([0-9]+)\.([0-9]+)$') {
|
||||
return [PSCustomObject]@{
|
||||
Tag = $v
|
||||
Major = [int]$Matches[1]
|
||||
Minor = [int]$Matches[2]
|
||||
Patch = [int]$Matches[3]
|
||||
}
|
||||
}
|
||||
return $null
|
||||
}
|
||||
|
||||
function Compare-SemVer($a, $b) {
|
||||
if ($a.Major -ne $b.Major) { return [Math]::Sign($a.Major - $b.Major) }
|
||||
if ($a.Minor -ne $b.Minor) { return [Math]::Sign($a.Minor - $b.Minor) }
|
||||
return [Math]::Sign($a.Patch - $b.Patch)
|
||||
}
|
||||
|
||||
$shortSha = (git rev-parse --short=7 HEAD).Trim()
|
||||
if ([string]::IsNullOrWhiteSpace($shortSha)) {
|
||||
throw 'Could not resolve HEAD short commit SHA'
|
||||
}
|
||||
|
||||
$stableTags = @(
|
||||
git tag --list 'v*' |
|
||||
ForEach-Object { Parse-StableSemVer $_.Trim() } |
|
||||
Where-Object { $_ -ne $null } |
|
||||
Sort-Object Major, Minor, Patch -Descending
|
||||
)
|
||||
$latestStable = if ($stableTags.Count -gt 0) { $stableTags[0] } else { $null }
|
||||
|
||||
$codeVer = $null
|
||||
$verFile = Get-Content -Raw -LiteralPath 'internal/version/version.go'
|
||||
if ($verFile -match 'var\s+Version\s*=\s*"(v[0-9]+\.[0-9]+\.[0-9]+)"') {
|
||||
$codeVer = Parse-StableSemVer $Matches[1]
|
||||
}
|
||||
|
||||
if ($latestStable) {
|
||||
if ($codeVer -and (Compare-SemVer $codeVer $latestStable) -gt 0) {
|
||||
$nextBase = $codeVer.Tag
|
||||
} else {
|
||||
$nextBase = "v$($latestStable.Major).$($latestStable.Minor).$($latestStable.Patch + 1)"
|
||||
}
|
||||
$baseStableTag = $latestStable.Tag
|
||||
} elseif ($codeVer) {
|
||||
$nextBase = $codeVer.Tag
|
||||
$baseStableTag = ''
|
||||
} else {
|
||||
$nextBase = 'v0.0.1'
|
||||
$baseStableTag = ''
|
||||
}
|
||||
|
||||
$devVersion = "$nextBase-dev-$shortSha"
|
||||
"DEV_VERSION=$devVersion" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
"DEV_COMMIT=$shortSha" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
"BASE_STABLE_TAG=$baseStableTag" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
Write-Host "Resolved DEV_VERSION=$devVersion (commit=$shortSha, baseStable=$baseStableTag)"
|
||||
|
||||
- name: Generate dev release notes
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$devVersion = $env:DEV_VERSION
|
||||
$runtimeTag = ''
|
||||
$runtimeTitle = ''
|
||||
try {
|
||||
$rels = gh release list -R $env:GITHUB_REPOSITORY --limit 100 --json tagName,name,isPrerelease,isDraft,createdAt | ConvertFrom-Json
|
||||
$stable = $rels |
|
||||
Where-Object { $_.tagName -like 'runtime-*' -and -not $_.isPrerelease -and -not $_.isDraft } |
|
||||
Sort-Object createdAt -Descending |
|
||||
Select-Object -First 1
|
||||
if ($stable) {
|
||||
$runtimeTag = $stable.tagName
|
||||
$runtimeTitle = if ($stable.name) { $stable.name } else { $stable.tagName }
|
||||
}
|
||||
} catch {
|
||||
Write-Warning "Could not query latest stable runtime release: $_"
|
||||
}
|
||||
$notesFile = Join-Path $env:RUNNER_TEMP "release-notes-dev.md"
|
||||
& ./scripts/build-release-notes.ps1 `
|
||||
-Tag $devVersion `
|
||||
-Channel dev `
|
||||
-PrevTag $env:BASE_STABLE_TAG `
|
||||
-Commit $env:DEV_COMMIT `
|
||||
-Repo $env:GITHUB_REPOSITORY `
|
||||
-StableRuntimeTag $runtimeTag `
|
||||
-StableRuntimeTitle $runtimeTitle `
|
||||
-OutFile $notesFile
|
||||
"RELEASE_NOTES_FILE=$notesFile" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
Write-Host "Generated dev release notes ($((Get-Item -LiteralPath $notesFile).Length) bytes) for $devVersion"
|
||||
|
||||
- name: Build frontend
|
||||
shell: pwsh
|
||||
run: |
|
||||
pnpm --dir frontend install --frozen-lockfile
|
||||
pnpm --dir frontend build
|
||||
|
||||
- name: Go test & vet
|
||||
shell: pwsh
|
||||
run: |
|
||||
go test ./...
|
||||
go vet ./...
|
||||
|
||||
- name: Install Wails CLI
|
||||
shell: pwsh
|
||||
run: go install github.com/wailsapp/wails/v2/cmd/wails@v2.17.1
|
||||
|
||||
- name: Build Windows x64 binary
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$ver = $env:DEV_VERSION
|
||||
$dist = 'dist-release'
|
||||
New-Item -ItemType Directory -Force -Path $dist | Out-Null
|
||||
$verPkg = 'github.com/Nwflower/reims-go/internal/version'
|
||||
$guiOut = Join-Path $dist "reims-go-$ver-windows-amd64.exe"
|
||||
wails build -s -trimpath -ldflags "-s -w -X $verPkg.Version=$ver" -o "reims-go-$ver-windows-amd64.exe"
|
||||
if ($LASTEXITCODE) { throw "wails build failed ($LASTEXITCODE)" }
|
||||
Copy-Item (Join-Path 'build\bin' "reims-go-$ver-windows-amd64.exe") $guiOut
|
||||
$zipOut = [IO.Path]::ChangeExtension($guiOut, '.zip')
|
||||
Compress-Archive -LiteralPath @($guiOut, 'LICENSE', 'NOTICE.md') -DestinationPath $zipOut -CompressionLevel Optimal -Force
|
||||
$lines = @(Get-Item -LiteralPath $guiOut, $zipOut | ForEach-Object {
|
||||
$h = (Get-FileHash -Algorithm SHA256 -LiteralPath $_.FullName).Hash.ToLowerInvariant()
|
||||
"$h $($_.Name)"
|
||||
})
|
||||
[IO.File]::WriteAllText((Join-Path $dist 'SHA256SUMS.txt'), ($lines -join "`n") + "`n", [Text.UTF8Encoding]::new($false))
|
||||
Get-Content (Join-Path $dist 'SHA256SUMS.txt')
|
||||
|
||||
- name: Update rolling dev GitHub Release
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$releaseTag = 'dev'
|
||||
$ver = $env:DEV_VERSION
|
||||
$notesFile = $env:RELEASE_NOTES_FILE
|
||||
if (-not (Test-Path -LiteralPath $notesFile) -or (Get-Item -LiteralPath $notesFile).Length -eq 0) {
|
||||
throw "Release notes file is missing or empty: $notesFile"
|
||||
}
|
||||
$title = "Reims-Go Dev ($ver)"
|
||||
$files = @(Get-ChildItem -LiteralPath 'dist-release' -File | Select-Object -ExpandProperty FullName)
|
||||
$keepNames = @($files | ForEach-Object { [IO.Path]::GetFileName($_) })
|
||||
|
||||
# Point the fixed 'dev' tag to the commit being built.
|
||||
git tag -f $releaseTag $env:GITHUB_SHA
|
||||
if ($LASTEXITCODE -ne 0) { throw "git tag -f $releaseTag failed ($LASTEXITCODE)" }
|
||||
git push --force origin "refs/tags/$releaseTag"
|
||||
if ($LASTEXITCODE -ne 0) { throw "git push --force refs/tags/$releaseTag failed ($LASTEXITCODE)" }
|
||||
|
||||
$exists = $true
|
||||
$existingAssets = @()
|
||||
try {
|
||||
$relJson = gh release view $releaseTag --json assets 2>$null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
$exists = $false
|
||||
} else {
|
||||
$existingAssets = @(($relJson | ConvertFrom-Json).assets)
|
||||
}
|
||||
} catch {
|
||||
$exists = $false
|
||||
}
|
||||
|
||||
if ($exists) {
|
||||
# Upload new assets first so the release is never left empty if upload fails.
|
||||
gh release upload $releaseTag @files --clobber
|
||||
if ($LASTEXITCODE -ne 0) { throw "gh release upload failed ($LASTEXITCODE)" }
|
||||
foreach ($asset in $existingAssets) {
|
||||
if ($keepNames -notcontains $asset.name) {
|
||||
Write-Host "Removing stale dev asset $($asset.name)"
|
||||
gh release delete-asset $releaseTag $asset.name --yes
|
||||
if ($LASTEXITCODE -ne 0) { throw "gh release delete-asset $($asset.name) failed ($LASTEXITCODE)" }
|
||||
}
|
||||
}
|
||||
gh release edit $releaseTag `
|
||||
--target $env:GITHUB_SHA `
|
||||
--prerelease `
|
||||
--title $title `
|
||||
--notes-file $notesFile
|
||||
if ($LASTEXITCODE -ne 0) { throw "gh release edit failed ($LASTEXITCODE)" }
|
||||
} else {
|
||||
gh release create $releaseTag @files `
|
||||
--target $env:GITHUB_SHA `
|
||||
--prerelease `
|
||||
--title $title `
|
||||
--notes-file $notesFile
|
||||
if ($LASTEXITCODE -ne 0) { throw "gh release create failed ($LASTEXITCODE)" }
|
||||
}
|
||||
@@ -7,7 +7,7 @@ on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: "Release tag to build & publish (e.g. v0.2.1)"
|
||||
description: "Release tag to build & publish (e.g. v0.2.9 or v0.2.9-alpha.1)"
|
||||
required: true
|
||||
|
||||
permissions:
|
||||
@@ -20,6 +20,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || '' }}
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
@@ -35,20 +36,31 @@ jobs:
|
||||
cache: pnpm
|
||||
cache-dependency-path: frontend/pnpm-lock.yaml
|
||||
|
||||
- name: Resolve version tag
|
||||
- name: Resolve version tag and channel
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$tag = if ('${{ github.event_name }}' -eq 'workflow_dispatch') { '${{ inputs.tag }}' } else { '${{ github.ref_name }}' }
|
||||
if (-not $tag.StartsWith('v')) { throw "Release tag must start with 'v', got: $tag" }
|
||||
$tag = $tag.Trim()
|
||||
if ($tag -match '^v[0-9]+\.[0-9]+\.[0-9]+$') {
|
||||
$channel = 'stable'
|
||||
} elseif ($tag -match '^v[0-9]+\.[0-9]+\.[0-9]+-alpha(?:[.-][0-9A-Za-z.-]+)?$') {
|
||||
$channel = 'alpha'
|
||||
} else {
|
||||
throw "Release tag must be stable (vX.Y.Z) or alpha test (vX.Y.Z-alpha[.N]), got: $tag"
|
||||
}
|
||||
"RELEASE_TAG=$tag" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
"RELEASE_CHANNEL=$channel" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
Write-Host "Resolved tag=$tag channel=$channel"
|
||||
|
||||
- name: Generate release notes from CHANGELOG.md
|
||||
- name: Generate release notes
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$tag = $env:RELEASE_TAG
|
||||
$channel = $env:RELEASE_CHANNEL
|
||||
$runtimeTag = ''
|
||||
$runtimeTitle = ''
|
||||
try {
|
||||
@@ -67,13 +79,14 @@ jobs:
|
||||
$notesFile = Join-Path $env:RUNNER_TEMP "release-notes-$tag.md"
|
||||
& ./scripts/build-release-notes.ps1 `
|
||||
-Tag $tag `
|
||||
-Channel $channel `
|
||||
-ChangelogPath 'CHANGELOG.md' `
|
||||
-Repo $env:GITHUB_REPOSITORY `
|
||||
-StableRuntimeTag $runtimeTag `
|
||||
-StableRuntimeTitle $runtimeTitle `
|
||||
-OutFile $notesFile
|
||||
"RELEASE_NOTES_FILE=$notesFile" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
Write-Host "Generated release notes ($((Get-Item -LiteralPath $notesFile).Length) bytes) for $tag"
|
||||
Write-Host "Generated $channel release notes ($((Get-Item -LiteralPath $notesFile).Length) bytes) for $tag"
|
||||
|
||||
- name: Build frontend
|
||||
shell: pwsh
|
||||
@@ -105,7 +118,7 @@ jobs:
|
||||
if ($LASTEXITCODE) { throw "wails build failed ($LASTEXITCODE)" }
|
||||
Copy-Item (Join-Path 'build\bin' "reims-go-$tag-windows-amd64.exe") $guiOut
|
||||
$zipOut = [IO.Path]::ChangeExtension($guiOut, '.zip')
|
||||
Compress-Archive -LiteralPath $guiOut -DestinationPath $zipOut -CompressionLevel Optimal -Force
|
||||
Compress-Archive -LiteralPath @($guiOut, 'LICENSE', 'NOTICE.md') -DestinationPath $zipOut -CompressionLevel Optimal -Force
|
||||
$lines = @(Get-Item -LiteralPath $guiOut, $zipOut | ForEach-Object {
|
||||
$h = (Get-FileHash -Algorithm SHA256 -LiteralPath $_.FullName).Hash.ToLowerInvariant()
|
||||
"$h $($_.Name)"
|
||||
@@ -120,10 +133,12 @@ jobs:
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$tag = $env:RELEASE_TAG
|
||||
$channel = $env:RELEASE_CHANNEL
|
||||
$notesFile = $env:RELEASE_NOTES_FILE
|
||||
if (-not (Test-Path -LiteralPath $notesFile) -or (Get-Item -LiteralPath $notesFile).Length -eq 0) {
|
||||
throw "Release notes file is missing or empty: $notesFile"
|
||||
}
|
||||
$title = if ($channel -eq 'alpha') { "Reims-Go $tag (Alpha)" } else { "Reims-Go $tag" }
|
||||
$files = @(Get-ChildItem -LiteralPath 'dist-release' -File | Select-Object -ExpandProperty FullName)
|
||||
$exists = $true
|
||||
$existingBody = ''
|
||||
@@ -140,15 +155,52 @@ jobs:
|
||||
if ($exists) {
|
||||
gh release upload $tag @files --clobber
|
||||
if ($LASTEXITCODE -ne 0) { throw "gh release upload failed ($LASTEXITCODE)" }
|
||||
$editArgs = @('release', 'edit', $tag, '--title', $title)
|
||||
if ($channel -eq 'alpha') {
|
||||
$editArgs += '--prerelease'
|
||||
} else {
|
||||
$editArgs += @('--prerelease=false', '--latest')
|
||||
}
|
||||
# Backfill notes if the existing release body is empty or only GitHub's auto-generated compare link.
|
||||
$isAutoOnly = [string]::IsNullOrWhiteSpace($existingBody) -or ($existingBody -match '^\*\*Full Changelog\*\*:\s*https://\S+$')
|
||||
if ($isAutoOnly) {
|
||||
gh release edit $tag --notes-file $notesFile
|
||||
if ($LASTEXITCODE -ne 0) { throw "gh release edit failed ($LASTEXITCODE)" }
|
||||
$editArgs += @('--notes-file', $notesFile)
|
||||
}
|
||||
& gh @editArgs
|
||||
if ($LASTEXITCODE -ne 0) { throw "gh release edit failed ($LASTEXITCODE)" }
|
||||
} else {
|
||||
gh release create $tag @files `
|
||||
--title "Reims-Go $tag" `
|
||||
--notes-file $notesFile
|
||||
$createArgs = @('release', 'create', $tag) + $files + @('--title', $title, '--notes-file', $notesFile)
|
||||
if ($channel -eq 'alpha') {
|
||||
$createArgs += '--prerelease'
|
||||
} else {
|
||||
$createArgs += '--latest'
|
||||
}
|
||||
& gh @createArgs
|
||||
if ($LASTEXITCODE -ne 0) { throw "gh release create failed ($LASTEXITCODE)" }
|
||||
}
|
||||
|
||||
- name: Delete all published alpha test releases after stable release
|
||||
if: env.RELEASE_CHANNEL == 'stable'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
# Only delete app alpha prereleases (vX.Y.Z-alpha*); never touch runtime-* or the rolling dev release.
|
||||
$rels = gh release list -R $env:GITHUB_REPOSITORY --limit 1000 --json tagName,isPrerelease,isDraft | ConvertFrom-Json
|
||||
$alphas = @($rels | Where-Object {
|
||||
$_.isPrerelease -and
|
||||
-not $_.isDraft -and
|
||||
$_.tagName -match '^v[0-9]+\.[0-9]+\.[0-9]+-alpha(?:[.-][0-9A-Za-z.-]+)?$'
|
||||
})
|
||||
if ($alphas.Count -eq 0) {
|
||||
Write-Host "No published alpha test releases to clean up."
|
||||
exit 0
|
||||
}
|
||||
foreach ($rel in $alphas) {
|
||||
Write-Host "Deleting alpha test release $($rel.tagName)"
|
||||
gh release delete $rel.tagName -R $env:GITHUB_REPOSITORY --yes --cleanup-tag
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to delete alpha test release $($rel.tagName) (exit $LASTEXITCODE)"
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
name: Sync Mirror to GitCode
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
release:
|
||||
types: [published, released, edited, prereleased]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: "Specific release tag to sync (empty = latest app release + all runtime-* releases)"
|
||||
required: false
|
||||
default: ""
|
||||
sync_releases:
|
||||
description: "Also sync Release metadata and assets to GitCode"
|
||||
type: boolean
|
||||
default: true
|
||||
|
||||
concurrency:
|
||||
group: sync-gitcode
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GITCODE_REPO: Nwflower/Reims-Go
|
||||
GITCODE_USER: Nwflower
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Push main branch and tags to GitCode
|
||||
env:
|
||||
GITCODE_TOKEN: ${{ secrets.GITCODE_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ -z "$GITCODE_TOKEN" ]; then
|
||||
echo "GITCODE_TOKEN secret is not configured; skipping."
|
||||
exit 0
|
||||
fi
|
||||
git fetch --tags origin
|
||||
# Use GIT_ASKPASS so the token never appears in URLs or process argv.
|
||||
askpass="$(mktemp)"
|
||||
chmod 700 "$askpass"
|
||||
cat > "$askpass" <<'EOF'
|
||||
#!/bin/sh
|
||||
case "$1" in
|
||||
*Username*) printf '%s\n' "$GITCODE_USER" ;;
|
||||
*) printf '%s\n' "$GITCODE_TOKEN" ;;
|
||||
esac
|
||||
EOF
|
||||
trap 'rm -f "$askpass"' EXIT
|
||||
GIT_TERMINAL_PROMPT=0 GIT_ASKPASS="$askpass" git -c credential.helper= push "https://gitcode.com/${GITCODE_REPO}.git" HEAD:refs/heads/main
|
||||
GIT_TERMINAL_PROMPT=0 GIT_ASKPASS="$askpass" git -c credential.helper= push "https://gitcode.com/${GITCODE_REPO}.git" --tags
|
||||
|
||||
- name: Sync Release and assets to GitCode
|
||||
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.sync_releases)
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITCODE_TOKEN: ${{ secrets.GITCODE_TOKEN }}
|
||||
GITHUB_REPO: ${{ github.repository }}
|
||||
TARGET_TAG: ${{ github.event.release.tag_name || inputs.tag }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ -z "$GITCODE_TOKEN" ]; then
|
||||
echo "GITCODE_TOKEN secret is not configured; skipping release sync."
|
||||
exit 0
|
||||
fi
|
||||
if [ -n "$TARGET_TAG" ]; then
|
||||
python3 scripts/sync-gitcode-release.py "$TARGET_TAG"
|
||||
else
|
||||
python3 scripts/sync-gitcode-release.py
|
||||
fi
|
||||
@@ -28,3 +28,6 @@ Thumbs.db
|
||||
*.log
|
||||
.vscode/
|
||||
.idea/
|
||||
|
||||
# Local debugging scratch, work orders, run logs, caches, scratch worktrees
|
||||
.debug/
|
||||
@@ -8,23 +8,54 @@
|
||||
|
||||
与上游 [`steelbrain/reims-vgpu`](https://github.com/steelbrain/reims-vgpu) 的分工:
|
||||
- **`reims-vgpu`**:底层引擎(QEMU 分支、`reims-graphics-pci`、`metal2vulkan`、`reims-ctl`、`reims-util`)。
|
||||
- **`reims-go`(本仓库)**:桌面应用、命令行包装与便携运行时打包/分发流水线,提供开箱即用的环境体检、离线装机、硬件调优、Guest Tools、恢复点与 CoW 派生能力。
|
||||
- **`reims-go`(本仓库)**:桌面应用、命令行包装与运行时下载管理,提供开箱即用的环境体检、离线装机、硬件调优、Guest Tools、恢复点与 CoW 派生能力。
|
||||
|
||||
## 存储与产物边界
|
||||
|
||||
1. **大体积文件严禁入库**:便携运行时包、macOS 安装包、`.qcow2` 磁盘与快照一律保存在用户或开发者本地指定的 `<DataRoot>`(推荐非系统盘),不得提交到仓库。
|
||||
2. **临时文件及时清理**:打包草稿、一次性测试目录使用完后清理,不留在仓库工作区。
|
||||
1. **大体积文件严禁入库**:便携运行时包、macOS 安装包、`.qcow2` 磁盘与快照一律保存在用户或开发者本地指定的 `<DataRoot>`(推荐非系统盘),不得提交到仓库,也不放入 `.debug/`。
|
||||
2. **禁止使用系统临时目录存放任务中间产物**:开发与排查产生的临时脚本、截图、日志、构建/测试缓存与隔离运行产物一律写入仓库根目录的 `.debug/`(已加入 `.gitignore`,严禁提交),不读写系统临时目录(`%TEMP%` / `/tmp`)。
|
||||
3. **临时文件及时退役**:任务完成后清理草稿与会话目录;值得长期保留的探针沉淀为正式单元测试(`*_test.go`)或 `scripts/` 下的工具脚本,不留在 `.debug/`。
|
||||
|
||||
## 调试目录与临时产物纪律(`.debug/`)
|
||||
|
||||
1. **顶层目录白名单**:`.debug/` 顶层只允许 [`scripts/debug/paths.mjs`](scripts/debug/paths.mjs) 声明的 5 个子目录,任何工具与脚本必须写入其中之一,`node scripts/debug/check.mjs` 会拒绝顶层出现其他杂项:
|
||||
- `.debug/tmp/` — 一次性会话临时产物,由 `scripts/debug/tmp.mjs` 创建、记录属主 PID 并回收。
|
||||
- `.debug/work/` — 跨会话工单与交接材料(含 `refs/`、`shots/`、`tmp/` 与 `work.md`),由 `scripts/debug/work.mjs` 管理。
|
||||
- `.debug/cache/` — 可由源码树重建的本地工具缓存。
|
||||
- `.debug/runs/` — 本地运行输出(日志、抓包、报告、追踪与隔离运行目录)。
|
||||
- `.debug/worktrees/` — 临时 Git 工作树,由 `scripts/debug/worktree.mjs` 管理(移除前先解除 Windows Junction / 符号链接,避免误删主树 `frontend/node_modules`)。
|
||||
2. **脚本与命令行红线**:
|
||||
- **禁止在命令行内联长多行脚本**:需要多行脚本时,先写入 `.debug/tmp/`(或所属工单的 `tmp/`)再执行。
|
||||
- **作者修改走编辑工具**:新逻辑、文案与规则变更直接通过编辑工具修改;跨文件机械改造(重命名、批量改路径、语法迁移)可将脚本放在 `.debug/tmp/` 运行,执行后通读完整 `git diff` 并通过全部校验,脚本不得编写新逻辑。
|
||||
3. **一次性临时目录与工单分工**:
|
||||
- 范围明确、当前会话可完成的小修改、只读检查和一次性试验直接进行,不建工单;无中间产物时不创建临时目录。
|
||||
- 用户显式要求工单,或任务需要跨会话恢复、多人/多 Agent 交接、持续积累验收证据时,再通过 `work.mjs` 建立或复用工单。
|
||||
- 一次性产物用 `node scripts/debug/tmp.mjs new <label>` 或 `run <label> -- <command>`(向子进程注入 `REIMS_TMP_DIR`):正常结束(退出码 0)自动删除目录,失败保留证据供排查;超期(24 小时)且属主进程已退出的残留由 `gc --yes` 回收,存活进程与符号链接/Junction 受保护。
|
||||
- 工单按 `draft → active → review → close` 流转;`close` 校验通过后删除整个工单目录。
|
||||
- **持久文档零引用**:`README.md`、`README.en.md`、`CHANGELOG.md`、`AGENTS.md` 与 `docs/` 严禁引用具体工单 ID 或 `.debug/tmp/` 会话实例路径。
|
||||
|
||||
| 命令 | 用途 |
|
||||
| :--- | :--- |
|
||||
| `node scripts/debug/tmp.mjs new <label>` | 在 `.debug/tmp/` 创建带属主记录的会话目录并打印路径 |
|
||||
| `node scripts/debug/tmp.mjs run <label> -- <cmd>` | 注入 `REIMS_TMP_DIR` 执行命令;成功自动删除,失败保留证据 |
|
||||
| `node scripts/debug/tmp.mjs list \| close <id> \| gc [--yes]` | 查看、关闭或回收已退出且超期的临时会话目录 |
|
||||
| `node scripts/debug/work.mjs new <slug> --title "…"` | 在 `.debug/work/` 创建工单及 `refs/`、`shots/`、`tmp/` |
|
||||
| `node scripts/debug/work.mjs start \| verify \| review \| close <id>` | 推进工单状态;`close` 校验后删除工单目录 |
|
||||
| `node scripts/debug/work.mjs path <id> [tmp\|refs\|shots]` | 打印工单材料目录绝对路径;`paths <id>` 打印工单声明的文件列表 |
|
||||
| `node scripts/debug/worktree.mjs add\|remove <path> [ref]` | 在 `.debug/worktrees/` 安全创建或移除临时工作树 |
|
||||
| `node scripts/debug/check.mjs` | 校验 `.debug/` 顶层白名单、临时会话、工单与持久文档引用 |
|
||||
|
||||
## 事实核验与安全规则
|
||||
|
||||
1. **上游行为以一手源码为准**:引用 `reims-ctl` / `reims-vgpu` 行为时核对对应上游 commit 与 `文件:行号`;未实测项显式标注「待验证」。
|
||||
2. **人工确认红线**:UAC 提权启用 WHPX、重启 Windows、macOS 图形安装向导、向上游提交 PR、将运行时升级为 `stable` 正式发布,均须由人确认触发。自动化例外:[`.github/workflows/build-runtime.yml`](.github/workflows/build-runtime.yml) 每日从上游构建,通过 `alpha` 准入检查后自动发布为 GitHub 预发布(`alpha` 通道),并自动清理较旧的未升级 `alpha` 预发布。
|
||||
2. **人工确认红线**:UAC 提权启用 WHPX、重启 Windows、macOS 图形安装向导、向上游提交 PR、将运行时升级为 `stable` 正式发布,均须由人确认触发。自动化例外:Reims vGPU fork 的 Preview 工作流每天构建,通过 `alpha` 准入检查后在运行时仓库发布 GitHub 预发布。
|
||||
3. **敏感与专有内容零入库**:严禁提交 SMC OSK、SMBIOS 真实序列号、MAC 地址、任何 Apple IPSW / BaseSystem / 解密固件或闭源二进制。
|
||||
4. **对上游的修改只走补丁队列**:不长期维护 fork。补丁放 [`patches/`](patches/),顺序与状态统一在 [`patches/series.txt`](patches/series.txt) 与 [`patches/README.md`](patches/README.md) 维护,目标是清零。补丁打不上就停下报告,不要自动改写补丁。
|
||||
4. **构建职责**:本仓库构建并发布客户端。便携运行时的编译、打包、依赖补丁和 Preview 发布由 [Reims vGPU fork 的 CI](https://github.com/yxc0915/reims-vgpu/blob/master/.github/workflows/runtime-preview.yml) 负责。
|
||||
5. **运行时包如实声明来源**:`manifest.json` 必须写清上游各仓库 commit 与实际应用的全部补丁;带补丁的包不得宣称为纯上游构建。
|
||||
6. **默认用户只拿 `stable` 通道**:CI 产物先入 `alpha`,经真实宿主冒烟并人工确认后才升为 `stable`(见 [`docs/portable-runtime-spec.md`](docs/portable-runtime-spec.md))。
|
||||
7. **配置写入只走 `reims-ctl set`**:不直接改写 `vm.toml`,保证上游校验与 OpenCore 重建生效(见 [`docs/design-guidelines.md`](docs/design-guidelines.md))。
|
||||
8. **文档维护纪律**:`docs/` 只存放当前生效的长期文档,使用单一事实来源;不写私人本机路径、日期补丁式叙事、易过时的伪代码/ASCII 草图;一次性排查、审视与排期记录留在 Issue 或 PR 中。
|
||||
9. **禁止空 `catch` 吞错**:严禁编写带有空代码块(含仅注释或空语句)的 `catch` 语句或空回调(如 `catch {}`、`catch (e) {}`、`.catch(() => {})`、`.then(..., () => {})`)把失败静默包装成成功;捕获异常后必须执行明确的错误处理(上报/展示错误、记录诊断告警、分类过滤预期错误并重抛其余异常,或显式回退状态)。该约束由 [`frontend/scripts/test-no-empty-catch.mjs`](frontend/scripts/test-no-empty-catch.mjs) 在 `pnpm --dir frontend test` 中强制校验。
|
||||
|
||||
## 开源合规边界
|
||||
|
||||
@@ -39,6 +70,8 @@
|
||||
- [`docs/roadmap.md`](docs/roadmap.md) — 公开路线图与近期重点
|
||||
- [`docs/architecture.md`](docs/architecture.md) — 系统架构、模块职责与安全边界
|
||||
- [`docs/design-guidelines.md`](docs/design-guidelines.md) — 产品与界面设计规范(配置原语、状态模型、视觉与文案)
|
||||
- [`docs/pr-review-guidelines.md`](docs/pr-review-guidelines.md) — PR 变更归属、跨仓交付与客户端独立性审查
|
||||
- [`docs/portable-runtime-spec.md`](docs/portable-runtime-spec.md) — 便携运行时打包、发布通道与合规规范
|
||||
- [`docs/plugin-architecture.md`](docs/plugin-architecture.md) — 插件系统架构与扩展接口规范
|
||||
- [`patches/README.md`](patches/README.md) — 上游临时补丁队列与 PR 跟踪
|
||||
- [`docs/guest-plugin-migration.md`](docs/guest-plugin-migration.md) — 客体插件化与 macOS 剥离的迁移路径
|
||||
- [运行时补丁与上游跟踪](https://github.com/yxc0915/reims-vgpu/blob/master/packaging/windows-runtime/patches/README.md) — 运行时源码入口与依赖补丁
|
||||
@@ -2,6 +2,65 @@
|
||||
|
||||
本文件只记录 Reims-Go 桌面应用的变化。便携运行时(`runtime-*`)的版本另见 [Releases](https://github.com/Nwflower/Reims-Go/releases)。
|
||||
|
||||
## v0.2.11 — 2026-12-01
|
||||
|
||||
### 新功能
|
||||
|
||||
- **Intel 虚拟机挂起与瞬间恢复**([#37](https://github.com/Nwflower/Reims-Go/pull/37)):支持在虚拟机运行中挂起保存内存与图形状态并在下次启动秒级恢复,采用事务化状态保存、异常回滚与多通道直接 I/O 优化。
|
||||
- **自定义共享文件夹与 WebDAV 路径隔离**([#38](https://github.com/Nwflower/Reims-Go/pull/38)、[#39](https://github.com/Nwflower/Reims-Go/pull/39)):Guest Tools 升级至 v8,支持按虚拟机配置自定义宿主机共享文件夹(含卷校验与设置页管理),并统一基于 `os.Root` 收紧 WebDAV 与回退文件同步的路径边界。
|
||||
- **内置并行下载器插件与可扩展下载器接口**([#24](https://github.com/Nwflower/Reims-Go/pull/24)、[#52](https://github.com/Nwflower/Reims-Go/pull/52)):离线安装包与镜像下载支持多线程分片并行加速,并开放 `downloaders` 插件扩展点。
|
||||
- **可插拔「镜像」页面与内置 macOS 镜像源**:将原安装包页升级为支持多插件镜像源切换的「镜像」页(`images.source` 扩展点),内置 macOS 镜像插件并接入品牌描边加载动画与服务可用性提示。
|
||||
- **插件 UI / 桥接契约锁定与主题能力升级(uiApi 2.0 / bridgeApi 1.0)**:冻结插件契约,新增主题插槽(slots)、全窗装饰层(layers)、布局选项(侧栏位置/模式、界面紧凑度、标题栏高度)以及图标与品牌标志覆写。
|
||||
- **虚拟机硬件、显示与交互增强**:
|
||||
- 支持按虚拟机配置 Windows 修饰键重映射及 `Win` 键映射为 macOS `Command`([#53](https://github.com/Nwflower/Reims-Go/pull/53))。
|
||||
- 支持一键轮换 OpenCore SMBIOS 硬件标识([#47](https://github.com/Nwflower/Reims-Go/pull/47))及可选同步宿主机 SMBIOS Type 17 内存规格([#44](https://github.com/Nwflower/Reims-Go/pull/44))。
|
||||
- 支持 `qcow2` `extended_l2` 磁盘性能优化、快照改写保护与 Windows Defender 排除项引导([#56](https://github.com/Nwflower/Reims-Go/pull/56))。
|
||||
- 全屏模式与客体分辨率解耦以支持 1.5x HiDPI 缩放([#22](https://github.com/Nwflower/Reims-Go/pull/22));新增关机模式选择与一键强制退出([#51](https://github.com/Nwflower/Reims-Go/pull/51))、虚拟机关闭确认弹窗及「关于」页 Discord 社区入口([#57](https://github.com/Nwflower/Reims-Go/pull/57))。
|
||||
- 支持停用内置 macOS 客体插件并按驱动隔离虚拟机生命周期路由。
|
||||
|
||||
### 优化与修复
|
||||
|
||||
- **统一插件前端组件与视觉样式**:合并已安装列表、插件市场与首次向导中的插件图标块、信任徽标、胶囊筛选按钮与搜索框(补齐语言包图标识别与 RTL 逻辑属性),将插件危险确认弹窗、表单、复选框、错误提示条与加载骨架屏收敛至全局基础组件。
|
||||
- **修复 Apple 在线恢复镜像鉴权与离线路径展开**([#34](https://github.com/Nwflower/Reims-Go/pull/34)):修复恢复镜像下载鉴权、分区 chunklist 校验及 `reims-ctl show` 主目录路径展开问题。
|
||||
- **修复剪贴板互通与文件同步可靠性**([#28](https://github.com/Nwflower/Reims-Go/pull/28)、[#33](https://github.com/Nwflower/Reims-Go/pull/33)):加固 Windows 剪贴板锁与 DIB/PNG 回声抑制,修复回退同步删除传播、Windows 驱动器挂载认证及 CLI 直接启动时保留 Guest Tools 的问题。
|
||||
- **修复 Vulkan 诊断与 GPU 驱动发现**([#21](https://github.com/Nwflower/Reims-Go/pull/21)、[#46](https://github.com/Nwflower/Reims-Go/pull/46)):清理失效的 GPU 驱动缓存文件,从活动显示驱动包中发现缺失的 Vulkan ICD 并在向导与 `doctor` 中展示探测诊断。
|
||||
- **界面性能与工程健壮性加固**([#57](https://github.com/Nwflower/Reims-Go/pull/57)):消除软件合成模式下的弹窗卡顿,修复插件状态判定、列表错误上报与休眠虚拟机停用驱动插件问题,全面禁止空 `catch` 吞错并加入静态门禁测试;运行时发布源切换至独立的 Reims vGPU / QEMU fork 通道。
|
||||
|
||||
## v0.2.10 — 2026-11-30
|
||||
|
||||
### 新功能
|
||||
|
||||
- 插件市场默认索引切换至 `reims-go/plugins` 组织仓库并新增 jsDelivr CDN 备选镜像自动回退;新增内置 `ed25519` 公钥环验签机制(`internal/plugin/keyring.go`)与 `reims-go plugin pack` 打包签名命令(自动执行静态门禁、生成 `SHA256SUMS` 与可选 `SHA256SUMS.sig`)。
|
||||
|
||||
### 优化与修复
|
||||
|
||||
- 修复虚拟机键盘打字时偶发字符重复/错序(如 `ABC` 变为 `ABCC`/`ABCAC`/`ABCAB`)及中文拼音首字连发(如 `h` 跳出两个 `h` 变为 `h好的`)的问题([#14](https://github.com/Nwflower/Reims-Go/issues/14)):在运行时补丁中改用 `WM_CHAR` 硬件扫描码区分物理与非物理字符,并在客户端按能力门控 `REIMS_GO_INPUT_URL`(同时受「宿主输入服务与 IME 桥接」插件开关控制),使已安装 `runtime-3731afd-p3` 的用户升级应用后即可直接恢复。
|
||||
- 修复标题栏菜单切换闪烁与浮层焦点提示竞争问题([#16](https://github.com/Nwflower/Reims-Go/pull/16))。
|
||||
- 将界面繁体中文(`zh-TW`)语言标签调整为更中性的表述。
|
||||
|
||||
## v0.2.9 — 2026-11-30
|
||||
|
||||
### 新功能
|
||||
|
||||
- 全新多语种与本地化架构(i18n / L10n v2,来自 [#10](https://github.com/Nwflower/Reims-Go/pull/10)):重构 7 域语言目录、零依赖 ICU 复数/格式引擎与区域回退链,支持系统语言自动跟随与完整第三方语言包插件协议(新增 `reims-go plugin locale init|check` 工具链);全面本地化系统托盘、文件选择器及高 DPI 悬浮安装引导,并为错误信息加入错误码与自动脱敏诊断详情。
|
||||
- 应用内更新新增通道切换:「关于」页支持选择 `stable`(正式版)、`alpha`(测试版)或 `dev`(开发构建)更新通道;切换至测试通道更新时自动保留上一版本备份以便随时回滚。
|
||||
- 完善插件静态安全准入与插件市场能力:
|
||||
- 新增统一静态安全扫描与硬拦截门禁(`internal/plugin/scanner.go`):拦截 L1/L4 插件夹带可执行文件或系统脚本、L3 插件未声明二进制、SVG `<script>`/`on*`/`javascript:` 主动内容、主题/交互脚本宿主逃逸(`window.go`/`window.runtime`/`eval`/`Function`)及未声明网络调用;针对 L3 Sidecar 原生程序如实声明完整 Windows 账户权限并展示可执行文件 SHA-256 与通俗能力说明。
|
||||
- 新增惰性插件市场客户端(`internal/plugin/market.go`):支持静态远程 `index.json` 拉取(环境变量 `REIMS_GO_PLUGIN_MARKET_URL` 自定义镜像或离线模式)、内存/磁盘双层缓存与内嵌离线兜底、软撤回(`withdrawn`)拦截与替代提示、下载前 `engines`/`platforms` 兼容预检与 SHA-256 强校验。
|
||||
- CLI 新增 `reims-go plugin search`、`reims-go plugin update`、`reims-go plugin install <id>` 及支持 `.zip`/`--json` 三段式安全报告的 `reims-go plugin doctor`;界面「插件」页新增「插件市场」标签页、本地包导入前静态安全报告弹窗与已安装插件安全扫描入口。
|
||||
- 支持清理未激活的旧版便携运行时:在「内核」页及命令行均可一键删除不再使用的历史运行时以释放磁盘空间。
|
||||
- 新增宿主侧 CoW backing 链深度体检(无须提权):当虚拟系统盘 CoW 派生链深度 ≥ 2 层或父镜像缺失时,在 `reims-go doctor`、宿主机体检及虚拟机详情/存储设置页一致展示提示。
|
||||
- 「关于」页新增第三方开源许可证查看器,随应用内置完整第三方开源许可证文本。
|
||||
- 新增三层系统盘小文件 I/O 基准与采样工具套件(`scripts/io-bench/`:`darwin/amd64` 客体基准、QMP `query-blockstats` / 延迟直方图采样与语言无关 Windows `PhysicalDisk` 计数器采集),`internal/qmp` 补充通用 `Query` 与块层统计查询方法。
|
||||
|
||||
### 优化与修复
|
||||
|
||||
- OpenCore 引导阶段新增对 FileVault 预启动界面鼠标与数字键盘输入的支持([#6](https://github.com/Nwflower/Reims-Go/pull/6))。
|
||||
- 修复新建虚拟机向导中下载 macOS 安装包时与「安装包」页进度不同步的问题([#13](https://github.com/Nwflower/Reims-Go/pull/13))。
|
||||
- 修复虚拟机重启流程:重启前等待 QEMU 进程完全退出并回收已提交内存,避免连续重启时内存占用叠加或启动失败。
|
||||
- 统一 `qcow2` 建盘选项来源:空间回收(`CompactDisk`)与 CoW 派生(`CreateCoWOverlay`)自动读取源镜像的 `compat`、`cluster_size`、`lazy_refcounts`、`extended_l2`、`refcount_bits` 与 `compression_type` 并原样透传,导入转换统一使用与上游一致的默认选项。
|
||||
- 移除已停用的 GitCode 运行时镜像同步与下载源,并加固多语种插件信任边界、敏感信息脱敏、WCAG 对比度与窄窗口布局。
|
||||
|
||||
## v0.2.8 — 2026-11-29
|
||||
|
||||
### 优化与修复
|
||||
|
||||
@@ -3,7 +3,41 @@
|
||||
`Reims-Go` itself (Go backend and desktop frontend) is licensed under the Apache
|
||||
License, Version 2.0 (see `LICENSE`). That license applies to Reims-Go's own code
|
||||
only and is separate from the portable runtime bundle it invokes as an external
|
||||
child process.
|
||||
child process. Compatibility patches in the runtime repository are licensed
|
||||
under terms compatible with their target upstream projects (see [runtime patch
|
||||
licenses](https://github.com/yxc0915/reims-vgpu/blob/master/packaging/windows-runtime/patches/LICENSE)).
|
||||
|
||||
The Reims-Go desktop executable also incorporates open-source Go and frontend
|
||||
libraries (including Wails, React, Radix UI, Lucide, Inter font, Go `golang.org/x`
|
||||
packages, `klauspost/compress`, and `ulikunitz/xz`) under permissive licenses
|
||||
(MIT, BSD, ISC, and SIL OFL 1.1); see `go.mod` and `frontend/package.json` for
|
||||
the complete dependency list.
|
||||
|
||||
### go-toml v2
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2021 - 2023 Thomas Pelletier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
## Portable runtime
|
||||
|
||||
The portable runtime bundle (`reims-runtime-win-x64-<commit>.tar.zst`) contains
|
||||
precompiled binaries built from the following upstream open-source projects.
|
||||
@@ -15,16 +49,16 @@ Each runtime release ships the matching source package, `NOTICE.md`, and
|
||||
- License: `GPL-2.0-or-later OR LGPL-3.0-or-later`
|
||||
2. **metal2vulkan / metal2vulkan-runtime**
|
||||
- Upstream: https://github.com/steelbrain/metal2vulkan
|
||||
- License: See upstream repository license
|
||||
- License: `GPL-2.0-or-later OR LGPL-3.0-or-later`
|
||||
3. **reims-util**
|
||||
- Upstream: https://github.com/steelbrain/reims-util
|
||||
- License: See upstream repository license
|
||||
- License: `GPL-2.0-or-later OR LGPL-3.0-or-later`
|
||||
4. **QEMU (qemu-reims-vgpu fork)**
|
||||
- Upstream: https://github.com/steelbrain/qemu-reims-vgpu
|
||||
- License: `GPL-2.0-only` / `GPL-2.0-or-later` (and component licenses in QEMU)
|
||||
5. **MSYS2 CLANG64 runtime libraries, libva, Mesa vaon12**
|
||||
- Upstream: https://github.com/msys2/MINGW-packages
|
||||
- License: Respective open-source licenses of each packaged DLL
|
||||
- License: Respective open-source licenses of each packaged DLL (bundled under `licenses/msys2/` in the runtime archive)
|
||||
|
||||
No Apple proprietary files, macOS installers, recovery images, or SMC keys are
|
||||
included in this repository or in any runtime bundle.
|
||||
+122
-101
@@ -1,20 +1,42 @@
|
||||
<p align="center">
|
||||
<a href="https://github.com/Nwflower/Reims-Go">
|
||||
<img src="./assets/logo.png" width="76" height="76" alt="Reims-Go" />
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="./.github/readme/banner-dark.svg" />
|
||||
<img src="./.github/readme/banner-light.svg" width="440" alt="Reims-Go" />
|
||||
</picture>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<h1 align="center">Reims-Go</h1>
|
||||
<p align="center">
|
||||
<strong>A macOS virtual machine for Windows. GPU-accelerated, ready out of the box.</strong>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
Run a GPU-accelerated macOS virtual machine on Windows — prebuilt, ready out of the box.
|
||||
<img src="https://img.shields.io/badge/macOS-Tahoe%2026-16182e?logo=apple&logoColor=white" alt="macOS Tahoe 26" />
|
||||
<img src="https://img.shields.io/badge/host-Windows%2010%20%7C%2011-0078D4?logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZmlsbD0id2hpdGUiIGQ9Ik0wIDMuNCA5LjggMnY5LjRIMHptMTEtMS42TDI0IDB2MTEuM0gxMXpNMCAxMi42aDkuOFYyMkwwIDIwLjZ6bTExIDBoMTNWMjRsLTEzLTEuOHoiLz48L3N2Zz4=" alt="Windows 10 | 11" />
|
||||
<a href="https://github.com/Nwflower/Reims-Go/releases"><img src="https://img.shields.io/github/v/release/Nwflower/Reims-Go?label=release&color=3b8cff" alt="release" /></a>
|
||||
<a href="https://github.com/Nwflower/Reims-Go/stargazers"><img src="https://img.shields.io/github/stars/Nwflower/Reims-Go?style=flat&label=stars&logo=github&color=ffb86b" alt="GitHub stars" /></a>
|
||||
<a href="./LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-ff7a9a" alt="license Apache-2.0" /></a>
|
||||
<a href="https://discord.gg/Tj682rW5rS"><img src="https://img.shields.io/badge/Discord-Join-5865F2?logo=discord&logoColor=white" alt="Discord" /></a>
|
||||
<a href="https://qm.qq.com/q/TBmRJlVbSo"><img src="https://img.shields.io/badge/QQ%20Group-1136042744-12B7F5?logo=qq&logoColor=white" alt="QQ Group 1136042744" /></a>
|
||||
<!-- Go daily list: uncomment after making it; replace %23N with the rank
|
||||
<a href="https://github.com/trending/go?since=daily"><img src="https://img.shields.io/badge/Trending-%23N%20Go%20Repo%20of%20the%20Day-00ADD8?logo=go&logoColor=white" alt="GitHub Trending: Go Repo of the Day" /></a>
|
||||
-->
|
||||
</p>
|
||||
|
||||
<!-- Official Trendshift badge: uncomment once https://trendshift.io/api/badge/repositories/385884 loads
|
||||
<p align="center">
|
||||
<a href="https://trendshift.io/repositories/385884?utm_source=repository-badge&utm_medium=badge&utm_campaign=badge-repository-385884" target="_blank" rel="noopener noreferrer"><img src="https://trendshift.io/api/badge/repositories/385884" alt="Nwflower%2FReims-Go | Trendshift" width="250" height="55"/></a>
|
||||
</p>
|
||||
-->
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/Nwflower/Reims-Go/releases"><strong>Download</strong></a> ·
|
||||
<a href="#quick-start">Quick Start</a> ·
|
||||
<a href="#screenshots">Screenshots</a> ·
|
||||
<a href="./docs/roadmap.md">Roadmap</a>
|
||||
<a href="#plugin-development">Plugins</a> ·
|
||||
<a href="./docs/roadmap.md">Roadmap</a> ·
|
||||
<a href="#organization-and-community">Community</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -29,106 +51,25 @@
|
||||
|
||||
<br />
|
||||
|
||||
Reims-Go is a Windows desktop app and CLI wrapper for [reims-vgpu](https://github.com/steelbrain/reims-vgpu). Host checks, runtime installation, macOS downloads, VM creation, and day-to-day management all happen in one window.
|
||||
Reims-Go is a Windows desktop app for [reims-vgpu](https://github.com/steelbrain/reims-vgpu). Installing the runtime, downloading macOS, creating VMs and using them day to day all happen in one window.
|
||||
|
||||
> Early active development — features and UI are still being refined.
|
||||
> Early development. Features and UI will keep changing.
|
||||
|
||||
<br />
|
||||
## Highlights
|
||||
|
||||
## Features
|
||||
- **GPU acceleration**: macOS Metal graphics run on your Windows GPU through Vulkan.
|
||||
- **Nothing to compile**: download one exe and run it. The app installs the runtime for you, with system proxy support and local archive import.
|
||||
- **No typing during install**: installers come straight from Apple. One click in Recovery types the install command, which erases the disk and starts installing.
|
||||
|
||||
### Out of the Box
|
||||
Once macOS is running:
|
||||
|
||||
- **No compilation required** — Download and verify the portable runtime in one click, without installing MSYS2 or Rust. Automatically falls back to the GitCode mirror if GitHub is unreachable, and honors Windows system proxy settings.
|
||||
- **Check before you start** — First launch inspects virtualization (WHPX), Vulkan GPUs, and host memory; if Hypervisor Platform is off, enable it with one click.
|
||||
- **Keep C: clean** — Runtimes, installers, virtual disks, and temporary files all live in the data folder you choose.
|
||||
- Clipboard (including images) and shared folders work both ways; drop files on the window to send them to macOS
|
||||
- Type with Windows IMEs and emoji directly
|
||||
- Save a restore point before updates and roll back in one click; clone a stopped VM in seconds
|
||||
- Close the window and it stays in the tray, with clipboard and sharing still working
|
||||
- SSH port forwarding and VS Code Remote-SSH; common tasks also work from the command line
|
||||
|
||||
### Installing macOS
|
||||
|
||||
- **Direct downloads from Apple** — Download full offline macOS installers on Windows with pause and resume; no network is required during installation.
|
||||
- **No manual typing** — One click types the install command straight into macOS Recovery Terminal to erase the disk and start installation automatically.
|
||||
- **Tuned for your PC** — Suggests memory based on available Windows commit memory and recommends crisp HiDPI resolutions for your display and DPI scaling.
|
||||
- **Pre-configured system language** — Choose your macOS language up front so Recovery and Setup Assistant launch in your preferred language.
|
||||
- **Import existing disks** — Reuse an existing `.qcow2`, VMDK, or RAW disk when creating a VM.
|
||||
|
||||
### Everyday Use
|
||||
|
||||
- **Windows interoperability** — Bidirectional clipboard (including images), shared folders with drag-and-drop file delivery, and optional read-only sharing of Windows drives to macOS Finder.
|
||||
- **Native IME & Unicode input** — Type CJK characters, emoji, and Windows IME text directly into the VM.
|
||||
- **Live status at a glance** — Screen preview plus live CPU, memory, and disk usage; copy a VM screenshot in one click.
|
||||
- **System tray integration** — Closing the window keeps clipboard and shared folders running in the background; start, stop, or keep macOS awake from the tray.
|
||||
- **Edit settings anytime** — Change VM settings even while running; the UI clearly shows whether changes apply immediately or on next start. Enter or exit Recovery mode in one click.
|
||||
- **Light & dark appearance, English & Chinese UI** — Automatically detects your Windows display language on first launch.
|
||||
|
||||
### Performance
|
||||
|
||||
- **GPU acceleration** — Accelerate macOS Metal graphics with your Windows discrete Vulkan GPU.
|
||||
- **Performance-core scheduling** — Automatically pins VMs to P-cores on hybrid CPUs to reduce stutter, or configure per-VM processor affinity live without restarting.
|
||||
- **Pre-start memory check** — Warns before starting if Windows commit memory is too low to allocate the VM.
|
||||
|
||||
### Power Features
|
||||
|
||||
- **Instant CoW clones** — Derive an independent copy-on-write clone from any stopped VM in seconds with near-zero initial disk overhead.
|
||||
- **Restore points** — Save an offline qcow2 snapshot before OS updates or major changes, and roll back with one click.
|
||||
- **Disk management** — Grow virtual disks or reclaim unused sparse space from stopped VMs.
|
||||
- **SSH helpers** — Port forwarding, one-click terminal launch, `~/.ssh/config` writer, and VS Code Remote-SSH integration.
|
||||
- **Built-in CLI** — Run host diagnostics, manage runtimes, download installers, and create, configure, start, or stop VMs from scripts.
|
||||
- **Diagnostics & Win10 compatibility** — Export a redacted diagnostics archive (`.zip`) in one click; seamless cold-reboot handling on Windows 10 when macOS restarts itself.
|
||||
|
||||
<br />
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Requirements
|
||||
|
||||
- Windows 10 / 11 (64-bit) with CPU virtualization enabled in BIOS (Intel VT-x / AMD-V)
|
||||
- Discrete Vulkan-capable GPU (NVIDIA RTX series recommended)
|
||||
- 16 GB+ RAM recommended
|
||||
- 150 GB+ free disk space recommended, 60 GB minimum (an offline installer is ~20 GB and virtual disks grow with use); an internal non-system drive is recommended
|
||||
|
||||
### Installation
|
||||
|
||||
Download the single-file `reims-go.exe` from [Releases](https://github.com/Nwflower/Reims-Go/releases) and double-click to run.
|
||||
|
||||
<details>
|
||||
<summary>Build from source</summary>
|
||||
|
||||
Requires [Go](https://go.dev/dl/), [Node.js](https://nodejs.org), [pnpm](https://pnpm.io), and [Wails](https://wails.io/docs/gettingstarted/installation):
|
||||
|
||||
```powershell
|
||||
git clone https://github.com/Nwflower/Reims-Go
|
||||
cd Reims-Go
|
||||
wails build
|
||||
```
|
||||
|
||||
The binary is written to `build\bin\reims-go.exe`.
|
||||
|
||||
</details>
|
||||
|
||||
### Getting Started
|
||||
|
||||
1. **Initial setup** — Pick a data folder on first launch, check host readiness (enable WHPX with one click and reboot Windows if needed), and install the runtime online.
|
||||
2. **Create a VM** — Click **+** in the sidebar, choose **Offline installer** (or pre-download one on the **Installers** page), and configure CPU, memory, and disk size.
|
||||
3. **Install macOS** — Start the VM and follow the on-screen Recovery guide: open Terminal in Recovery and click the keyboard icon to type the install command automatically; once Setup Assistant appears, click **Exit recovery mode**.
|
||||
4. **Install Guest Tools** — On the macOS desktop, click **Install…** on the Guest Tools row in Reims-Go and run the command shown in macOS Terminal to enable clipboard sync, shared folders, and IME input.
|
||||
5. **Daily management** — Settings, restore points, and SSH tools are on the VM page; the **More** menu provides Send text, Recovery mode, CoW cloning, and diagnostics export.
|
||||
|
||||
### Command Line
|
||||
|
||||
The CLI lives inside the same `reims-go.exe`: running it with no arguments opens the window, while passing a subcommand executes in the terminal.
|
||||
|
||||
```powershell
|
||||
reims-go doctor | Out-Host # Inspect host environment
|
||||
reims-go runtime fetch | Out-Host # Install portable runtime online
|
||||
reims-go installer download tahoe | Out-Host # Download offline installer (resumable)
|
||||
reims-go vm create macos-tahoe | Out-Host # Create a VM
|
||||
reims-go vm start macos-tahoe | Out-Host # Start the VM
|
||||
reims-go vm stop macos-tahoe | Out-Host # Shut down the VM
|
||||
```
|
||||
|
||||
In interactive PowerShell or cmd, pipe to `| Out-Host` so the terminal waits for the command to finish and returns its exit code. Run `reims-go help` to view all commands; pass `--lang en-US` or `--lang zh-CN` to override the output language.
|
||||
|
||||
<br />
|
||||
For everything else, see the [changelog](./CHANGELOG.md).
|
||||
|
||||
## Screenshots
|
||||
|
||||
@@ -167,12 +108,92 @@ In interactive PowerShell or cmd, pipe to `| Out-Host` so the terminal waits for
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
## Quick Start
|
||||
|
||||
### Requirements
|
||||
|
||||
- Windows 10 / 11 (64-bit) with Intel VT-x or AMD-V enabled in BIOS
|
||||
- A discrete Vulkan GPU, NVIDIA RTX series recommended
|
||||
- 16 GB of RAM or more
|
||||
- 150 GB of free disk space, 60 GB at minimum, ideally not on the system drive
|
||||
|
||||
### Install and set up
|
||||
|
||||
Download `reims-go.exe` from [Releases](https://github.com/Nwflower/Reims-Go/releases) and double-click it.
|
||||
|
||||
1. **First launch**: pick a data folder, check your PC and install the runtime. If virtualization is off, turn it on in one click and restart Windows.
|
||||
2. **Create a VM**: click **+** in the sidebar, choose **Offline installer**, and set CPU, memory and disk size.
|
||||
3. **Install macOS**: start the VM, then click the keyboard icon in Recovery Terminal to type the install command. When Setup Assistant appears, click **Exit recovery mode**.
|
||||
4. **Install Guest Tools**: on the macOS desktop, click **Install…** on the Guest Tools row of the VM page, then run the command it shows in macOS Terminal. Clipboard, shared folders and IME input work after that.
|
||||
|
||||
<details>
|
||||
<summary>Command line</summary>
|
||||
|
||||
Run `reims-go.exe` with no arguments to open the window, or with a subcommand to run it in the terminal:
|
||||
|
||||
```powershell
|
||||
reims-go doctor | Out-Host # Check your PC
|
||||
reims-go runtime fetch | Out-Host # Install the runtime
|
||||
reims-go installer download tahoe | Out-Host # Download an installer (resumable)
|
||||
reims-go vm create macos-tahoe | Out-Host # Create a VM
|
||||
reims-go vm start macos-tahoe | Out-Host # Start the VM
|
||||
reims-go vm stop macos-tahoe | Out-Host # Shut down the VM
|
||||
```
|
||||
|
||||
In PowerShell or cmd, add `| Out-Host` so the terminal waits for the command to finish. `reims-go help` lists every subcommand.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Build from source</summary>
|
||||
|
||||
Requires [Go](https://go.dev/dl/), [Node.js](https://nodejs.org), [pnpm](https://pnpm.io) and [Wails](https://wails.io/docs/gettingstarted/installation):
|
||||
|
||||
```powershell
|
||||
git clone https://github.com/Nwflower/Reims-Go
|
||||
cd Reims-Go
|
||||
wails build
|
||||
```
|
||||
|
||||
The binary is written to `build\bin\reims-go.exe`.
|
||||
|
||||
</details>
|
||||
|
||||
## Plugin Development
|
||||
|
||||
Reims-Go ships an out-of-process plugin system with zero external runtime dependencies. Browse and install plugins from the built-in **Plugins** page or import a local `.zip` archive; if a third-party plugin breaks startup, launch with `reims-go --safe-mode` to skip all third-party plugins.
|
||||
|
||||
- **L1 declarative plugins** (JSON + static assets): UI themes backed by the versioned [UI contract](./frontend/ui-contract.json), language packs (domain JSON + optional `.woff2` fonts), VM templates, runtime sources, input filters and rule hooks.
|
||||
- **L3 sidecar plugins** (standalone executables in any language): one isolated process per plugin speaking `Content-Length`-framed JSON-RPC 2.0 over stdin/stdout for custom guest drivers (such as non-macOS VMs), lifecycle hooks, custom commands and diagnostics; Go authors can use the zero-dependency SDK in [`pkg/pluginsdk`](./pkg/pluginsdk).
|
||||
- **Declarative UI extensions**: render native plugin settings from `settings` JSON Schema and contribute menu items, cards and status items to declared host slots.
|
||||
|
||||
<details>
|
||||
<summary>Plugin development CLI</summary>
|
||||
|
||||
```powershell
|
||||
reims-go plugin link <dir> | Out-Host # Link a local plugin directory for development
|
||||
reims-go plugin doctor --contract frontend/ui-contract.json <dir|zip> | Out-Host # Run static security, manifest and UI contract checks
|
||||
reims-go plugin locale init ja-JP --out <dir> | Out-Host # Scaffold a language pack
|
||||
reims-go plugin locale check <dir> | Out-Host # Validate language pack coverage and syntax
|
||||
reims-go plugin pack <dir> | Out-Host # Verify and pack a .zip with SHA256SUMS (optional --sign-key)
|
||||
reims-go plugin search | Out-Host # Browse the official plugin market
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
- Full architecture, `plugin.json` manifest reference, permission tiers and protocol spec: [`docs/plugin-architecture.md`](./docs/plugin-architecture.md)
|
||||
- Official plugin market index and submissions: [`reims-go/plugins`](https://github.com/reims-go/plugins)
|
||||
|
||||
## Organization and Community
|
||||
|
||||
- **GitHub Organization**: [`reims-go`](https://github.com/reims-go) — Maintains the official plugin market index ([`reims-go/plugins`](https://github.com/reims-go/plugins)) and ecosystem repositories; the desktop launcher repository lives at [`Nwflower/Reims-Go`](https://github.com/Nwflower/Reims-Go)
|
||||
- **Discord**: [Join the Discord server](https://discord.gg/Tj682rW5rS) — Bilingual chat, troubleshooting, hardware compatibility reports, alpha testing and plugin development
|
||||
- **QQ Group**: [1136042744](https://qm.qq.com/q/TBmRJlVbSo) — Chinese community chat and feedback
|
||||
|
||||
## License & Notice
|
||||
|
||||
- **Open-source license**: Reims-Go itself is licensed under [Apache-2.0](./LICENSE). Bundled runtime components such as QEMU are distributed as separate executables; see [`NOTICE.md`](./NOTICE.md) for third-party licenses. Every runtime release ships with its corresponding source archive.
|
||||
- **About macOS**: Reims-Go does not include or distribute any Apple system files; installers are downloaded directly from Apple on the user's machine. **The macOS Software License Agreement permits virtualization only on Apple-branded hardware** — evaluate your own compliance responsibilities on non-Apple hardware. This project is not affiliated with Apple Inc.; macOS is a registered trademark of Apple Inc.
|
||||
- Reims-Go is licensed under [Apache-2.0](./LICENSE). Runtime components such as QEMU ship as separate programs; their licenses are in [`NOTICE.md`](./NOTICE.md), and every runtime release includes the matching source.
|
||||
- Reims-Go contains no Apple system files; installers are downloaded from Apple on your machine. **The macOS license only permits virtualization on Apple hardware**, so assess your own compliance on other hardware. This project is not affiliated with Apple Inc.; macOS is a registered trademark of Apple Inc.
|
||||
|
||||
## Links
|
||||
|
||||
|
||||
@@ -1,20 +1,42 @@
|
||||
<p align="center">
|
||||
<a href="https://github.com/Nwflower/Reims-Go">
|
||||
<img src="./assets/logo.png" width="76" height="76" alt="Reims-Go" />
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="./.github/readme/banner-dark.svg" />
|
||||
<img src="./.github/readme/banner-light.svg" width="440" alt="Reims-Go" />
|
||||
</picture>
|
||||
</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<strong>为 Windows 打造的 macOS 虚拟机。图形加速、开箱即用。</strong>
|
||||
</p>
|
||||
|
||||
<h1 align="center">Reims-Go</h1>
|
||||
|
||||
<p align="center">
|
||||
在 Windows 上开一台带 GPU 加速的 macOS 虚拟机——免编译,开箱即用。
|
||||
<img src="https://img.shields.io/badge/macOS-Tahoe%2026-16182e?logo=apple&logoColor=white" alt="macOS Tahoe 26" />
|
||||
<img src="https://img.shields.io/badge/host-Windows%2010%20%7C%2011-0078D4?logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZmlsbD0id2hpdGUiIGQ9Ik0wIDMuNCA5LjggMnY5LjRIMHptMTEtMS42TDI0IDB2MTEuM0gxMXpNMCAxMi42aDkuOFYyMkwwIDIwLjZ6bTExIDBoMTNWMjRsLTEzLTEuOHoiLz48L3N2Zz4=" alt="Windows 10 | 11" />
|
||||
<a href="https://github.com/Nwflower/Reims-Go/releases"><img src="https://img.shields.io/github/v/release/Nwflower/Reims-Go?label=release&color=3b8cff" alt="release" /></a>
|
||||
<a href="https://github.com/Nwflower/Reims-Go/stargazers"><img src="https://img.shields.io/github/stars/Nwflower/Reims-Go?style=flat&label=stars&logo=github&color=ffb86b" alt="GitHub stars" /></a>
|
||||
<a href="./LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-ff7a9a" alt="license Apache-2.0" /></a>
|
||||
<a href="https://discord.gg/Tj682rW5rS"><img src="https://img.shields.io/badge/Discord-Join-5865F2?logo=discord&logoColor=white" alt="Discord" /></a>
|
||||
<a href="https://qm.qq.com/q/TBmRJlVbSo"><img src="https://img.shields.io/badge/QQ%20群-1136042744-12B7F5?logo=qq&logoColor=white" alt="QQ 交流群 1136042744" /></a>
|
||||
<!-- Go 日榜:上榜后取消注释,把 %23N 改成名次
|
||||
<a href="https://github.com/trending/go?since=daily"><img src="https://img.shields.io/badge/Trending-%23N%20Go%20日榜-00ADD8?logo=go&logoColor=white" alt="GitHub Trending: Go 日榜" /></a>
|
||||
-->
|
||||
</p>
|
||||
|
||||
<!-- Trendshift 官方徽章:https://trendshift.io/api/badge/repositories/385884 能打开后取消注释
|
||||
<p align="center">
|
||||
<a href="https://trendshift.io/repositories/385884?utm_source=repository-badge&utm_medium=badge&utm_campaign=badge-repository-385884" target="_blank" rel="noopener noreferrer"><img src="https://trendshift.io/api/badge/repositories/385884" alt="Nwflower%2FReims-Go | Trendshift" width="250" height="55"/></a>
|
||||
</p>
|
||||
-->
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/Nwflower/Reims-Go/releases"><strong>下载</strong></a> ·
|
||||
<a href="#快速开始">快速开始</a> ·
|
||||
<a href="#界面">界面</a> ·
|
||||
<a href="./docs/roadmap.md">路线图</a>
|
||||
<a href="#插件与开发">插件与开发</a> ·
|
||||
<a href="./docs/roadmap.md">路线图</a> ·
|
||||
<a href="#项目组与社区">项目组与社区</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -29,106 +51,25 @@
|
||||
|
||||
<br />
|
||||
|
||||
Reims-Go 是 [reims-vgpu](https://github.com/steelbrain/reims-vgpu) 的 Windows 桌面应用。从检查电脑、安装运行时、下载 macOS,到创建和日常使用虚拟机,都在一个窗口里完成。
|
||||
Reims-Go 是 [reims-vgpu](https://github.com/steelbrain/reims-vgpu) 的 Windows 桌面应用。装运行时、下载 macOS、建虚拟机和日常使用,都在一个窗口里完成。
|
||||
|
||||
> 早期迭代中,功能与界面仍在持续打磨。
|
||||
> 仍在早期迭代,功能和界面会继续调整。
|
||||
|
||||
<br />
|
||||
## 特点
|
||||
|
||||
## 特性
|
||||
- **显卡加速**:macOS 的 Metal 图形经 Vulkan 交给 Windows 独显执行。
|
||||
- **免编译**:下载一个 exe 就能用。运行时在应用里一键安装,支持系统代理和本地压缩包导入。
|
||||
- **装机不用敲命令**:安装包直接从 Apple 下载;在恢复模式里点一下,装机命令会自动键入,抹盘和安装随即开始。
|
||||
|
||||
### 开箱即用
|
||||
装好之后:
|
||||
|
||||
- **不用编译** — 运行时在应用里一键下载安装,不用装 MSYS2、Rust,也不用自己编译。GitHub 连不上时自动改从 GitCode 国内镜像下载,并沿用 Windows 的系统代理设置。
|
||||
- **先检查再开工** — 首次打开会检查虚拟化、显卡和内存;虚拟化没开的话可以一键开启。
|
||||
- **不占 C 盘** — 运行时、安装包、虚拟磁盘和临时文件都放在你选的数据目录里。
|
||||
- 剪贴板(含图片)和共享文件夹与 Windows 互通,文件拖进窗口就能传进 macOS
|
||||
- 中文输入法和 emoji 可以直接输入
|
||||
- 升级系统前留个恢复点,出问题一键回滚;关机的虚拟机能秒级派生副本
|
||||
- 关掉窗口后常驻托盘,剪贴板和共享照常工作
|
||||
- 支持 SSH 端口转发和 VS Code 远程连接,常用操作也能在命令行里完成
|
||||
|
||||
### 装机
|
||||
|
||||
- **安装包直接从 Apple 下载** — 在 Windows 上下载完整安装包,可以暂停和续传;装机过程不用联网。
|
||||
- **不用手敲命令** — 装机命令点一下就自动键入到 macOS 的恢复终端,抹盘和安装都会自动完成。
|
||||
- **按本机配置推荐** — 内存大小按电脑的空闲内存推荐,分辨率按显示器和缩放推荐清晰的 HiDPI 档位。
|
||||
- **装机界面用中文** — 可以提前选好 macOS 系统语言,恢复模式和设置助理不再只有英文。
|
||||
- **导入已有磁盘** — 新建时可以直接用现成的 VMDK 或 RAW 磁盘。
|
||||
|
||||
### 日常使用
|
||||
|
||||
- **和 Windows 互通** — 双向剪贴板(包括图片)和共享文件夹,把文件拖到窗口里就能传进 macOS;还可以把 Windows 磁盘以只读方式共享给 macOS。
|
||||
- **直接打中文** — 中文、emoji 和 Windows 输入法都能直接输入到虚拟机。
|
||||
- **一眼看清状态** — 页面上有屏幕预览,以及 CPU、内存、磁盘的实时占用;一键截屏并复制。
|
||||
- **常驻托盘** — 关掉窗口后剪贴板和共享照常工作,可以从托盘启动或关闭虚拟机,也可以让 macOS 保持唤醒。
|
||||
- **随时修改设置** — 虚拟机运行时也能改设置,界面会说明改动是立即生效还是下次启动生效;一键进入或退出恢复模式。
|
||||
- **浅色、深色外观,中英双语** — 首次启动自动识别 Windows 系统语言。
|
||||
|
||||
### 性能
|
||||
|
||||
- **显卡加速** — 用 Windows 上的独立显卡加速 macOS 的图形显示。
|
||||
- **自动挑选性能核** — 在大小核处理器上,虚拟机自动跑在性能核上,减少卡顿;也可以给每台虚拟机单独指定用哪些核,运行中修改立即生效。
|
||||
- **启动前检查内存** — 内存不够时会先提示,避免启动到一半失败。
|
||||
|
||||
### 进阶
|
||||
|
||||
- **秒级派生副本** — 已关机的虚拟机可以秒级派生出一台独立副本,副本只记录与原机的差异,刚派生时几乎不占额外空间。
|
||||
- **恢复点** — 升级系统或大改环境前留一个恢复点,出问题时一键回滚。
|
||||
- **磁盘管理** — 关机后可以给虚拟磁盘扩容,或回收没有用到的空间。
|
||||
- **SSH** — 端口转发,一键打开终端、写入 `~/.ssh/config` 或用 VS Code 远程连接。
|
||||
- **命令行** — 检查环境、安装运行时、下载安装包,以及新建、修改、启动和关闭虚拟机,都能在命令行里完成,方便写脚本。
|
||||
- **排障** — 一键导出已去掉隐私信息的日志包;Windows 10 上 macOS 自己重启时也能正常回到系统。
|
||||
|
||||
<br />
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 环境要求
|
||||
|
||||
- Windows 10 / 11(64 位),处理器支持虚拟化,并已在 BIOS 里开启 Intel VT-x / AMD-V
|
||||
- 支持 Vulkan 的独立显卡(推荐 NVIDIA RTX 系列)
|
||||
- 内存建议 16 GB 以上
|
||||
- 可用磁盘空间建议 150 GB 以上,至少 60 GB(一个安装包约 20 GB,虚拟磁盘会随使用增长);最好不要放在系统盘或外置盘
|
||||
|
||||
### 安装
|
||||
|
||||
前往 [Releases](https://github.com/Nwflower/Reims-Go/releases) 下载单文件 `reims-go.exe`,双击即可运行。
|
||||
|
||||
<details>
|
||||
<summary>从源码构建</summary>
|
||||
|
||||
需预先安装 [Go](https://go.dev/dl/)、[Node.js](https://nodejs.org)、[pnpm](https://pnpm.io) 与 [Wails](https://wails.io/docs/gettingstarted/installation):
|
||||
|
||||
```powershell
|
||||
git clone https://github.com/Nwflower/Reims-Go
|
||||
cd Reims-Go
|
||||
wails build
|
||||
```
|
||||
|
||||
产物位于 `build\bin\reims-go.exe`。
|
||||
|
||||
</details>
|
||||
|
||||
### 上手步骤
|
||||
|
||||
1. **初始化** — 首次打开时按引导选好数据目录,完成电脑检查(虚拟化没开可以一键开启,之后需要重启 Windows),再在线安装运行时。
|
||||
2. **新建虚拟机** — 点侧边栏的 **+**,安装来源选「离线安装包」(也可以先到「安装包」页下载好),再设好 CPU、内存和磁盘。
|
||||
3. **安装 macOS** — 启动虚拟机,按页面上的装机引导操作:在恢复终端里点键盘图标,装机命令会自动键入,抹盘和安装随即开始;看到「设置助理」后点「退出恢复模式」。
|
||||
4. **安装 Guest Tools** — 进入 macOS 桌面后,在虚拟机页 Guest Tools 一行点「安装…」,再到 macOS 终端里运行页面给出的命令。装好后剪贴板、共享文件夹和中文输入就能用了。
|
||||
5. **日常管理** — 设置、恢复点和 SSH 都在虚拟机页上;「更多」菜单里还有发送文本、进入恢复模式、派生副本、导出排障日志等操作。
|
||||
|
||||
### 命令行
|
||||
|
||||
命令行就在同一个 `reims-go.exe` 里:不带参数会打开窗口,带上子命令就在终端里执行。
|
||||
|
||||
```powershell
|
||||
reims-go doctor | Out-Host # 检查电脑环境
|
||||
reims-go runtime fetch | Out-Host # 在线安装运行时
|
||||
reims-go installer download tahoe | Out-Host # 下载安装包(支持续传)
|
||||
reims-go vm create macos-tahoe | Out-Host # 新建虚拟机
|
||||
reims-go vm start macos-tahoe | Out-Host # 启动虚拟机
|
||||
reims-go vm stop macos-tahoe | Out-Host # 关闭虚拟机
|
||||
```
|
||||
|
||||
在 PowerShell 或 cmd 里直接输入命令时,要加上 `| Out-Host`,终端才会等命令执行完再返回。运行 `reims-go help` 可以查看全部子命令,加 `--lang en-US` 会改成英文输出。
|
||||
|
||||
<br />
|
||||
更多功能见[更新日志](./CHANGELOG.md)。
|
||||
|
||||
## 界面
|
||||
|
||||
@@ -167,12 +108,92 @@ reims-go vm stop macos-tahoe | Out-Host # 关闭虚拟机
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
## 快速开始
|
||||
|
||||
### 环境要求
|
||||
|
||||
- Windows 10 / 11(64 位),BIOS 里已开启 Intel VT-x 或 AMD-V
|
||||
- 支持 Vulkan 的独立显卡,推荐 NVIDIA RTX 系列
|
||||
- 内存 16 GB 以上
|
||||
- 磁盘空间 150 GB 以上,最少 60 GB,最好不放在系统盘
|
||||
|
||||
### 安装与上手
|
||||
|
||||
从 [Releases](https://github.com/Nwflower/Reims-Go/releases) 下载 `reims-go.exe`,双击运行。
|
||||
|
||||
1. **初始化**:按引导选数据目录、检查电脑、安装运行时。虚拟化没开的话可以一键开启,之后重启 Windows。
|
||||
2. **新建虚拟机**:点侧边栏的 **+**,安装来源选「离线安装包」,设好 CPU、内存和磁盘。
|
||||
3. **安装 macOS**:启动虚拟机,在恢复终端里点键盘图标,装机命令自动键入。看到「设置助理」后点「退出恢复模式」。
|
||||
4. **安装 Guest Tools**:进入桌面后,在虚拟机页 Guest Tools 一行点「安装…」,再到 macOS 终端运行页面给出的命令。装好后剪贴板、共享文件夹和中文输入就能用了。
|
||||
|
||||
<details>
|
||||
<summary>命令行</summary>
|
||||
|
||||
不带参数运行 `reims-go.exe` 会打开窗口,带上子命令则在终端里执行:
|
||||
|
||||
```powershell
|
||||
reims-go doctor | Out-Host # 检查电脑环境
|
||||
reims-go runtime fetch | Out-Host # 安装运行时
|
||||
reims-go installer download tahoe | Out-Host # 下载安装包(支持续传)
|
||||
reims-go vm create macos-tahoe | Out-Host # 新建虚拟机
|
||||
reims-go vm start macos-tahoe | Out-Host # 启动虚拟机
|
||||
reims-go vm stop macos-tahoe | Out-Host # 关闭虚拟机
|
||||
```
|
||||
|
||||
在 PowerShell 或 cmd 里要加上 `| Out-Host`,终端才会等命令执行完再返回。`reims-go help` 列出全部子命令。
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>从源码构建</summary>
|
||||
|
||||
需要 [Go](https://go.dev/dl/)、[Node.js](https://nodejs.org)、[pnpm](https://pnpm.io) 和 [Wails](https://wails.io/docs/gettingstarted/installation):
|
||||
|
||||
```powershell
|
||||
git clone https://github.com/Nwflower/Reims-Go
|
||||
cd Reims-Go
|
||||
wails build
|
||||
```
|
||||
|
||||
产物在 `build\bin\reims-go.exe`。
|
||||
|
||||
</details>
|
||||
|
||||
## 插件与开发
|
||||
|
||||
Reims-Go 内置进程外隔离的插件体系,零外部运行时依赖。可以在应用的「插件」页直接浏览安装官方市场插件或导入本地 `.zip` 包;如插件引发启动异常,可用 `reims-go --safe-mode` 跳过全部第三方插件恢复。
|
||||
|
||||
- **L1 声明式插件**(纯 JSON + 静态资源):界面主题(基于稳定的 [UI 契约](./frontend/ui-contract.json))、多语种语言包(分域 JSON 与可选 `.woff2` 字体)、虚拟机模板、运行时源、输入过滤与规则 Hook。
|
||||
- **L3 Sidecar 插件**(任意语言独立可执行文件):每插件独立进程,通过 stdin/stdout `Content-Length` 分帧 JSON-RPC 2.0 通信,可用于非 macOS 虚拟机驱动、生命周期 Hook、自定义命令与排障采集;Go 开发者可直接使用零依赖 SDK [`pkg/pluginsdk`](./pkg/pluginsdk)。
|
||||
- **声明式 UI 扩展**:通过 `settings` JSON Schema 原生渲染插件设置页,向宿主预定义槽位贡献菜单项、卡片与状态项。
|
||||
|
||||
<details>
|
||||
<summary>插件开发常用命令</summary>
|
||||
|
||||
```powershell
|
||||
reims-go plugin link <dir> | Out-Host # 链接本地插件目录用于开发调试
|
||||
reims-go plugin doctor --contract frontend/ui-contract.json <dir|zip> | Out-Host # 静态安全扫描与清单/UI 契约校验
|
||||
reims-go plugin locale init ja-JP --out <dir> | Out-Host # 生成多语种语言包脚手架
|
||||
reims-go plugin locale check <dir> | Out-Host # 校验语言包覆盖率与格式
|
||||
reims-go plugin pack <dir> | Out-Host # 校验并打包 .zip(自动生成 SHA256SUMS,支持 --sign-key)
|
||||
reims-go plugin search | Out-Host # 浏览官方插件市场
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
- 完整插件架构、清单字段(`plugin.json`)、权限分级与协议规范见 [`docs/plugin-architecture.md`](./docs/plugin-architecture.md)
|
||||
- 官方插件市场索引与投稿发布见 [`reims-go/plugins`](https://github.com/reims-go/plugins)
|
||||
|
||||
## 项目组与社区
|
||||
|
||||
- **GitHub 项目组**:[`reims-go`](https://github.com/reims-go) — 维护官方插件市场索引([`reims-go/plugins`](https://github.com/reims-go/plugins))及周边生态项目;桌面客户端主仓库位于 [`Nwflower/Reims-Go`](https://github.com/Nwflower/Reims-Go)
|
||||
- **Discord 社区**:[加入 Discord 服务器](https://discord.gg/Tj682rW5rS) — 中英双语交流、排障求助、硬件兼容性实测、Alpha 测试与插件开发
|
||||
- **QQ 交流群**:[1136042744](https://qm.qq.com/q/TBmRJlVbSo) — 中文日常交流与使用反馈
|
||||
|
||||
## 许可与声明
|
||||
|
||||
- **开源协议**:Reims-Go 本身采用 [Apache-2.0](./LICENSE) 协议。运行时里的 QEMU 等组件作为独立程序随附,各自的许可证见 [`NOTICE.md`](./NOTICE.md);每个运行时 Release 都附带对应的源码包。
|
||||
- **关于 macOS**:Reims-Go 不包含、不分发任何 Apple 系统文件,安装包由本机直连 Apple 服务器获取。**macOS 软件许可协议仅允许在 Apple 硬件上虚拟化**,在非 Apple 硬件上使用请自行评估合规责任。本项目与 Apple Inc. 无关,macOS 为 Apple Inc. 注册商标。
|
||||
- Reims-Go 采用 [Apache-2.0](./LICENSE) 协议。运行时里的 QEMU 等组件作为独立程序随附,许可证见 [`NOTICE.md`](./NOTICE.md),每个运行时 Release 都附带对应源码。
|
||||
- Reims-Go 不包含、不分发任何 Apple 系统文件,安装包由本机直接从 Apple 下载。**macOS 软件许可协议只允许在 Apple 硬件上虚拟化**,在其他硬件上使用请自行评估。本项目与 Apple Inc. 无关,macOS 是 Apple Inc. 的注册商标。
|
||||
|
||||
## 友情链接
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 539 141" width="539" height="141" role="img" aria-label="Reims-Go"><g transform="translate(4 107)"><defs><linearGradient id="wm" gradientUnits="userSpaceOnUse" x1="376" y1="0" x2="531" y2="0"><stop offset="0" stop-color="#3b8cff"/><stop offset="0.5" stop-color="#6d5dfc"/><stop offset="1" stop-color="#ff7a9a"/></linearGradient><linearGradient id="wmb" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#ffd43b"/><stop offset="1" stop-color="#ff9f0a"/></linearGradient></defs><g fill="none" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"><path d="M7.5 -7.5V-36A24 28.5 0 0 1 31.5 -64.5" stroke="#f4f5fa"/><path d="M50.5 -36H107.5A28.5 28.5 0 1 0 100.18 -16.93" stroke="#f4f5fa"/><path d="M133.5 -64.5V-7.5" stroke="#f4f5fa"/><circle cx="133.5" cy="-94" r="9" fill="#ff7a9a"/><path d="M159.5 -7.5V-36A22 28.5 0 0 1 203.5 -36V-7.5M203.5 -36A22 28.5 0 0 1 247.5 -36V-7.5" stroke="#f4f5fa"/><path d="M311.05 -59.02A21 14.25 0 0 0 273.5 -50.25A21 14.25 0 0 0 294.5 -36A21 14.25 0 0 1 315.5 -21.75A21 14.25 0 0 1 277.95 -12.98" stroke="#f4f5fa"/><path d="M340.5 -36H358.5" stroke="#5d6382"/><path d="M440.5 -36A28.5 28.5 0 1 1 440.5 -36.01" stroke="url(#wm)"/><path d="M440.5 -64.5V0A28.5 22.5 0 0 1 387.32 11.25" stroke="url(#wm)"/><path d="M523.5 -36A28.5 28.5 0 1 1 523.5 -36.01" stroke="url(#wm)"/></g></g></svg>
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 539 141" width="539" height="141" role="img" aria-label="Reims-Go"><g transform="translate(4 107)"><defs><linearGradient id="wm" gradientUnits="userSpaceOnUse" x1="376" y1="0" x2="531" y2="0"><stop offset="0" stop-color="#3b8cff"/><stop offset="0.5" stop-color="#6d5dfc"/><stop offset="1" stop-color="#ff7a9a"/></linearGradient><linearGradient id="wmb" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#ffd43b"/><stop offset="1" stop-color="#ff9f0a"/></linearGradient></defs><g fill="none" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"><path d="M7.5 -7.5V-36A24 28.5 0 0 1 31.5 -64.5" stroke="#16182e"/><path d="M50.5 -36H107.5A28.5 28.5 0 1 0 100.18 -16.93" stroke="#16182e"/><path d="M133.5 -64.5V-7.5" stroke="#16182e"/><circle cx="133.5" cy="-94" r="9" fill="#ff7a9a"/><path d="M159.5 -7.5V-36A22 28.5 0 0 1 203.5 -36V-7.5M203.5 -36A22 28.5 0 0 1 247.5 -36V-7.5" stroke="#16182e"/><path d="M311.05 -59.02A21 14.25 0 0 0 273.5 -50.25A21 14.25 0 0 0 294.5 -36A21 14.25 0 0 1 315.5 -21.75A21 14.25 0 0 1 277.95 -12.98" stroke="#16182e"/><path d="M340.5 -36H358.5" stroke="#a3a8bf"/><path d="M440.5 -36A28.5 28.5 0 1 1 440.5 -36.01" stroke="url(#wm)"/><path d="M440.5 -64.5V0A28.5 22.5 0 0 1 387.32 11.25" stroke="url(#wm)"/><path d="M523.5 -36A28.5 28.5 0 1 1 523.5 -36.01" stroke="url(#wm)"/></g></g></svg>
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,327 @@
|
||||
// Command i18ngen compiles and validates the canonical JSON message catalogs
|
||||
// under locales/{zh-CN,en-US}/*.json, enforcing:
|
||||
// - 100% key parity between zh-CN and en-US in every domain
|
||||
// - valid lightweight ICU AST syntax across every entry
|
||||
// - identical {var} placeholder sets between zh-CN, en-US, and optional $params
|
||||
//
|
||||
// Outputs:
|
||||
// - internal/i18n/catalog_gen.go
|
||||
// - frontend/src/i18n/keys.gen.ts
|
||||
// - frontend/src/i18n/domains/{core,vm,wizard,settings,plugins}.gen.ts
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/Nwflower/reims-go/internal/i18n"
|
||||
)
|
||||
|
||||
var (
|
||||
allDomains = []string{"core", "vm", "wizard", "settings", "plugins", "native", "macos-glossary"}
|
||||
goDomains = []string{"native", "macos-glossary", "core"}
|
||||
feEagerDomains = []string{"core", "vm"}
|
||||
feLazyDomains = []string{"wizard", "settings", "plugins"}
|
||||
)
|
||||
|
||||
type parsedEntry struct {
|
||||
Message string
|
||||
Params []string
|
||||
Comment string
|
||||
MaxLength int
|
||||
}
|
||||
|
||||
func main() {
|
||||
root := "."
|
||||
if _, err := os.Stat("locales/zh-CN/core.json"); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "i18ngen: must be run from repository root: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
zhByDomain := make(map[string]map[string]parsedEntry)
|
||||
enByDomain := make(map[string]map[string]parsedEntry)
|
||||
keyOwnerDomain := make(map[string]string)
|
||||
|
||||
var validationErrors []string
|
||||
|
||||
for _, dom := range allDomains {
|
||||
zhPath := filepath.Join(root, "locales", "zh-CN", dom+".json")
|
||||
enPath := filepath.Join(root, "locales", "en-US", dom+".json")
|
||||
|
||||
zhMap, err := readCatalogFile(zhPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "i18ngen: read %s: %v\n", zhPath, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
enMap, err := readCatalogFile(enPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "i18ngen: read %s: %v\n", enPath, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for k := range zhMap {
|
||||
if prevDom, exists := keyOwnerDomain[k]; exists {
|
||||
validationErrors = append(validationErrors, fmt.Sprintf("duplicate key %q across domains %q and %q", k, prevDom, dom))
|
||||
}
|
||||
keyOwnerDomain[k] = dom
|
||||
if _, ok := enMap[k]; !ok {
|
||||
validationErrors = append(validationErrors, fmt.Sprintf("[%s] key %q exists in zh-CN but missing in en-US", dom, k))
|
||||
}
|
||||
}
|
||||
for k := range enMap {
|
||||
if _, ok := zhMap[k]; !ok {
|
||||
validationErrors = append(validationErrors, fmt.Sprintf("[%s] key %q exists in en-US but missing in zh-CN", dom, k))
|
||||
}
|
||||
}
|
||||
|
||||
keys := sortedKeys(zhMap)
|
||||
for _, k := range keys {
|
||||
ze, ok := zhMap[k]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
ee, ok := enMap[k]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
_, zhVars, zErr := i18n.ParseICU(ze.Message)
|
||||
if zErr != nil {
|
||||
validationErrors = append(validationErrors, fmt.Sprintf("[%s] zh-CN %q invalid ICU syntax: %v", dom, k, zErr))
|
||||
continue
|
||||
}
|
||||
_, enVars, eErr := i18n.ParseICU(ee.Message)
|
||||
if eErr != nil {
|
||||
validationErrors = append(validationErrors, fmt.Sprintf("[%s] en-US %q invalid ICU syntax: %v", dom, k, eErr))
|
||||
continue
|
||||
}
|
||||
if !reflect.DeepEqual(zhVars, enVars) {
|
||||
validationErrors = append(validationErrors, fmt.Sprintf("[%s] placeholder mismatch for %q: zh-CN=%v vs en-US=%v", dom, k, zhVars, enVars))
|
||||
}
|
||||
if len(ze.Params) > 0 {
|
||||
decl := append([]string(nil), ze.Params...)
|
||||
sort.Strings(decl)
|
||||
if !reflect.DeepEqual(decl, zhVars) {
|
||||
validationErrors = append(validationErrors, fmt.Sprintf("[%s] zh-CN $params %v does not match template vars %v for %q", dom, ze.Params, zhVars, k))
|
||||
}
|
||||
}
|
||||
if len(ee.Params) > 0 {
|
||||
decl := append([]string(nil), ee.Params...)
|
||||
sort.Strings(decl)
|
||||
if !reflect.DeepEqual(decl, enVars) {
|
||||
validationErrors = append(validationErrors, fmt.Sprintf("[%s] en-US $params %v does not match template vars %v for %q", dom, ee.Params, enVars, k))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
zhByDomain[dom] = zhMap
|
||||
enByDomain[dom] = enMap
|
||||
}
|
||||
|
||||
if len(validationErrors) > 0 {
|
||||
for _, msg := range validationErrors {
|
||||
fmt.Fprintln(os.Stderr, "ERROR:", msg)
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err := writeGoCatalog(root, zhByDomain, enByDomain); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "i18ngen: write Go catalog: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if err := writeFrontendCatalogs(root, zhByDomain, enByDomain); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "i18ngen: write frontend catalogs: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Println("i18ngen: OK")
|
||||
}
|
||||
|
||||
func readCatalogFile(path string) (map[string]parsedEntry, error) {
|
||||
raw, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var rawMap map[string]json.RawMessage
|
||||
if err := json.Unmarshal(raw, &rawMap); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out := make(map[string]parsedEntry, len(rawMap))
|
||||
for k, v := range rawMap {
|
||||
if strings.HasPrefix(k, "$") {
|
||||
continue
|
||||
}
|
||||
var plain string
|
||||
if err := json.Unmarshal(v, &plain); err == nil {
|
||||
out[k] = parsedEntry{Message: plain}
|
||||
continue
|
||||
}
|
||||
var meta struct {
|
||||
Message string `json:"message"`
|
||||
Params []string `json:"$params"`
|
||||
Comment string `json:"$comment"`
|
||||
MaxLength int `json:"$maxLength"`
|
||||
}
|
||||
if err := json.Unmarshal(v, &meta); err != nil {
|
||||
return nil, fmt.Errorf("key %q: %w", k, err)
|
||||
}
|
||||
out[k] = parsedEntry{
|
||||
Message: meta.Message,
|
||||
Params: meta.Params,
|
||||
Comment: meta.Comment,
|
||||
MaxLength: meta.MaxLength,
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func sortedKeys[V any](m map[string]V) []string {
|
||||
keys := make([]string, 0, len(m))
|
||||
for k := range m {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
return keys
|
||||
}
|
||||
|
||||
func writeGoCatalog(root string, zhByDom, enByDom map[string]map[string]parsedEntry) error {
|
||||
zhMerged := make(map[string]string)
|
||||
enMerged := make(map[string]string)
|
||||
params := make(map[string][]string)
|
||||
|
||||
for _, dom := range goDomains {
|
||||
for k, e := range zhByDom[dom] {
|
||||
zhMerged[k] = e.Message
|
||||
if len(e.Params) > 0 {
|
||||
params[k] = e.Params
|
||||
} else if ee := enByDom[dom][k]; len(ee.Params) > 0 {
|
||||
params[k] = ee.Params
|
||||
} else {
|
||||
_, vars, _ := i18n.ParseICU(e.Message)
|
||||
if len(vars) > 0 {
|
||||
params[k] = vars
|
||||
}
|
||||
}
|
||||
}
|
||||
for k, e := range enByDom[dom] {
|
||||
enMerged[k] = e.Message
|
||||
}
|
||||
}
|
||||
|
||||
keys := sortedKeys(zhMerged)
|
||||
var b bytes.Buffer
|
||||
b.WriteString("// Code generated by cmd/i18ngen; DO NOT EDIT.\n\npackage i18n\n\n")
|
||||
b.WriteString("var catalog = map[Locale]map[string]string{\n")
|
||||
b.WriteString("\tZhCN: {\n")
|
||||
for _, k := range keys {
|
||||
fmt.Fprintf(&b, "\t\t%q: %q,\n", k, zhMerged[k])
|
||||
}
|
||||
b.WriteString("\t},\n\tEnUS: {\n")
|
||||
for _, k := range keys {
|
||||
fmt.Fprintf(&b, "\t\t%q: %q,\n", k, enMerged[k])
|
||||
}
|
||||
b.WriteString("\t},\n}\n\n")
|
||||
|
||||
paramKeys := sortedKeys(params)
|
||||
b.WriteString("var paramOrder = map[string][]string{\n")
|
||||
for _, k := range paramKeys {
|
||||
p := params[k]
|
||||
quoted := make([]string, len(p))
|
||||
for i, name := range p {
|
||||
quoted[i] = fmt.Sprintf("%q", name)
|
||||
}
|
||||
fmt.Fprintf(&b, "\t%q: {%s},\n", k, strings.Join(quoted, ", "))
|
||||
}
|
||||
b.WriteString("}\n")
|
||||
|
||||
return os.WriteFile(filepath.Join(root, "internal/i18n/catalog_gen.go"), b.Bytes(), 0o644)
|
||||
}
|
||||
|
||||
func writeFrontendCatalogs(root string, zhByDom, enByDom map[string]map[string]parsedEntry) error {
|
||||
feDir := filepath.Join(root, "frontend/src/i18n")
|
||||
domDir := filepath.Join(feDir, "domains")
|
||||
if err := os.MkdirAll(domDir, 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Merge macos-glossary into frontend core domain as well so UI components can use official glossary keys.
|
||||
feDomains := []string{"core", "vm", "wizard", "settings", "plugins"}
|
||||
var allFEKeys []string
|
||||
|
||||
for _, dom := range feDomains {
|
||||
zhMap := make(map[string]string)
|
||||
enMap := make(map[string]string)
|
||||
for k, v := range zhByDom[dom] {
|
||||
zhMap[k] = v.Message
|
||||
}
|
||||
for k, v := range enByDom[dom] {
|
||||
enMap[k] = v.Message
|
||||
}
|
||||
if dom == "core" {
|
||||
for k, v := range zhByDom["macos-glossary"] {
|
||||
zhMap[k] = v.Message
|
||||
}
|
||||
for k, v := range enByDom["macos-glossary"] {
|
||||
enMap[k] = v.Message
|
||||
}
|
||||
}
|
||||
|
||||
keys := sortedKeys(zhMap)
|
||||
allFEKeys = append(allFEKeys, keys...)
|
||||
|
||||
isLazy := false
|
||||
for _, ld := range feLazyDomains {
|
||||
if ld == dom {
|
||||
isLazy = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
var b bytes.Buffer
|
||||
b.WriteString("// Code generated by cmd/i18ngen; DO NOT EDIT.\n")
|
||||
if isLazy {
|
||||
b.WriteString("import { registerBuiltinDomain } from '../runtime'\n\n")
|
||||
} else {
|
||||
b.WriteString("\n")
|
||||
}
|
||||
fmt.Fprintf(&b, "export const %sZh: Record<string, string> = {\n", dom)
|
||||
for _, k := range keys {
|
||||
fmt.Fprintf(&b, " %s: %s,\n", tsQuoted(k), tsQuoted(zhMap[k]))
|
||||
}
|
||||
b.WriteString("}\n\n")
|
||||
fmt.Fprintf(&b, "export const %sEn: Record<string, string> = {\n", dom)
|
||||
for _, k := range keys {
|
||||
fmt.Fprintf(&b, " %s: %s,\n", tsQuoted(k), tsQuoted(enMap[k]))
|
||||
}
|
||||
b.WriteString("}\n")
|
||||
if isLazy {
|
||||
fmt.Fprintf(&b, "\nregisterBuiltinDomain(%sZh, %sEn)\n", dom, dom)
|
||||
}
|
||||
|
||||
if err := os.WriteFile(filepath.Join(domDir, dom+".gen.ts"), b.Bytes(), 0o644); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
sort.Strings(allFEKeys)
|
||||
var kb bytes.Buffer
|
||||
kb.WriteString("// Code generated by cmd/i18ngen; DO NOT EDIT.\n\n")
|
||||
kb.WriteString("export type I18nKey =\n")
|
||||
for i, k := range allFEKeys {
|
||||
sep := ""
|
||||
if i == len(allFEKeys)-1 {
|
||||
sep = ";"
|
||||
}
|
||||
fmt.Fprintf(&kb, " | %s%s\n", tsQuoted(k), sep)
|
||||
}
|
||||
return os.WriteFile(filepath.Join(feDir, "keys.gen.ts"), kb.Bytes(), 0o644)
|
||||
}
|
||||
|
||||
func tsQuoted(s string) string {
|
||||
raw, _ := json.Marshal(s)
|
||||
return string(raw)
|
||||
}
|
||||
+33
-15
@@ -10,7 +10,7 @@
|
||||
2. **包装而非重写引擎**:通过受控子进程调用上游 `reims-ctl`、`reims-util` 与 `qemu-img`,不手写易随上游演进失效的 QEMU 启动参数拼接逻辑。
|
||||
3. **GUI 与 CLI 单文件同源**:所有业务逻辑下沉在 `internal/`。无参数启动 Wails 桌面窗口,带子命令(`reims-go <subcommand>`)进入命令行模式,供终端、脚本与自动化工具调用。
|
||||
4. **数据目录隔离**:运行时、下载缓存、虚拟机磁盘、快照与临时文件全部落在用户选定的 `<DataRoot>` 下,不污染系统盘。
|
||||
5. **原生中英双语**:前后端内置 `zh-CN` / `en-US` 双语字典,自动跟随系统语言并支持运行时切换。
|
||||
5. **同构多语言与语言包扩展**:单一事实源分域 JSON 词表(`locales/`)在编译期同时生成 Go 与 TypeScript 类型安全字典,前后端共用轻量 ICU 消息语法与多跳区域回退链;主程序内置 `zh-CN` 与 `en-US`(默认 `auto` 跟随系统并支持热切换),其他语种通过 L1 声明式语言包插件按需扩展并覆盖桌面界面、Win32 原生浮层、系统托盘与命令行。
|
||||
6. **跨平台开发友好**:所有 Windows 原生 API(WHPX、注册表、处理器拓扑、进程亲和性、系统代理、托盘)严格隔离在 `*_windows.go`,提供 `*_other.go` 桩实现,确保非 Windows 环境也能执行 `go build` 与 `go test ./...`。
|
||||
|
||||
---
|
||||
@@ -54,31 +54,35 @@ flowchart TB
|
||||
| :--- | :--- |
|
||||
| `main.go`、`console_*.go` | 统一入口:无参数启动 Wails GUI,带子命令进入 `internal/cli`;处理 GUI 子系统下的父控制台句柄接管 |
|
||||
| `internal/app` | Wails 绑定与桌面编排(启停、安装、快照、CoW 派生、磁盘扩容/回收、SSH、脱敏排障包、任务状态、运行监视) |
|
||||
| `internal/vmstart` | GUI 与 CLI 共用的启动前准备:提交内存预检、离线辅助盘、恢复模式引导、客体语言重放、WHPX 兼容处理、启动后 CPU 绑核 |
|
||||
| `internal/vmstart` | 通用启动辅助:提交内存等待、启动后 CPU 绑核、亲和性配置与命令行日志 |
|
||||
| `internal/macos/startprep` | macOS 启动前准备:WHPX/内存检查、离线辅助盘、恢复模式引导、客体语言重放与兼容处理 |
|
||||
| `internal/cli` | 命令行子命令实现、单实例参数解析与向界面进程交接 `vm start` |
|
||||
| `internal/host` | 宿主机体检与硬件调优:WHPX 检测与 UAC 启用、提交内存预检、Vulkan ICD 扫描、三层大小核拓扑与实时绑核、显示器 HiDPI 推荐、音频与磁盘总线探测、窗口置前、IME 文本钩子 |
|
||||
| `internal/runtime` | 便携运行时拉取(GitHub 主源 + GitCode 国内镜像回退)、原子解压、多版本切换与子进程环境变量构造 |
|
||||
| `internal/runtime` | 便携运行时拉取(GitHub Releases)、原子解压、多版本切换与子进程环境变量构造 |
|
||||
| `internal/fetch` | 发布附件下载:HTTP `Range` 续传与按发布页 `SHA256SUMS.txt` 强制校验,运行时安装与应用内更新共用 |
|
||||
| `internal/selfupdate` | 应用内更新:把已校验的新版 `reims-go.exe` 换入运行中程序的位置、重新拉起与残留清理 |
|
||||
| `internal/installer` | 包装 `reims-util --json` 实现 macOS 离线安装包查询、宿主机直连下载、断点续传、互斥锁保护与缓存清理 |
|
||||
| `internal/driver/reims` | `reims-ctl` 与 `qemu-img` 受控子进程包装、输出解析、快照/派生/导入操作、日志与配置脱敏 |
|
||||
| `internal/macos/installer` | 包装 `reims-util --json` 实现 macOS 离线安装包查询、宿主机直连下载、断点续传、互斥锁保护与缓存清理 |
|
||||
| `internal/macos/reims` | `reims-ctl` 与 `qemu-img` 受控子进程包装、输出解析、快照/派生/导入操作、日志与配置脱敏 |
|
||||
| `internal/macos/macosdriver` | 把 `internal/macos/reims` 适配为通用 `driver.Driver`(内置驱动 `builtin.driver.reims-macos`) |
|
||||
| `internal/macos/guest` | 内置可选插件 `builtin.guest.macos`:静态驱动声明、宿主体检、启动与兼容 Hook、安装引导服务,以及数据布局 v2 的状态与参数账本迁移 |
|
||||
| `internal/macos/installguide` | 虚拟机窗口旁的 macOS 安装与恢复分步引导(Win32 浮层) |
|
||||
| `internal/qmp` | QMP 客户端:键盘键入、截屏与 Win10 冷重启监视 |
|
||||
| `internal/guesttools` | 本地回环鉴权 HTTP/WebDAV 服务:图文双向剪贴板、共享目录、Windows 盘符只读共享、防休眠开关与 `REIMSTOOLS` 辅助盘生成 |
|
||||
| `internal/opencore` | 改写 OpenCore 镜像中的 `prev-lang:kbd`,实现系统外预设 macOS 语言 |
|
||||
| `internal/macos/opencore` | 改写 OpenCore 镜像中的 `prev-lang:kbd`,实现系统外预设 macOS 语言 |
|
||||
| `internal/netproxy` | 统一 HTTP Transport:优先环境变量代理,回退读取 Windows 系统代理配置 |
|
||||
| `internal/config`、`internal/i18n` | 应用配置持久化(`reims-go.json`)与 Go 端双语消息/结构化错误码 |
|
||||
| `locales/`、`cmd/i18ngen` | 单一事实源分域 JSON 词表(含译者上下文 `$comment` 与 Apple macOS 官方多语种词汇表)及编译期前后端字典代码生成器 |
|
||||
| `internal/config`、`internal/i18n` | 应用配置持久化(`reims-go.json`)、轻量 ICU 格式化引擎、多跳语言回退链与带稳定排障码的结构化错误(`CodedError`) |
|
||||
| `internal/thumb`、`internal/tray`、`internal/version` | 4K 截屏行级缩放预览、Windows 系统托盘常驻、版本信息与新版本检查 |
|
||||
| `frontend/src` | 桌面界面:`components/`(页面与对话框)、`ui/`(Radix 基件封装)、`lib/`(格式化、日志与任务)、`styles/`(设计令牌) |
|
||||
| `patches/` | 上游临时补丁队列与 PR 跟踪,见 [`patches/README.md`](../patches/README.md) |
|
||||
| `scripts/` | 便携运行时打包、二进制裁剪与符号分离、MSYS2 源码归档、`alpha` 准入与冒烟脚本 |
|
||||
| `frontend/src` | 桌面界面:`components/`(页面与对话框)、`macos/`(macOS 专属页面与组件)、`ui/`(Radix 基件封装)、`lib/`(格式化、日志与任务)、`styles/`(设计令牌) |
|
||||
| `scripts/` | 便携运行时打包、二进制裁剪与符号分离、MSYS2 源码归档、`alpha` 准入与冒烟脚本,以及 `scripts/debug/` 本地调试目录管理与卫生校验脚本 |
|
||||
|
||||
---
|
||||
|
||||
## 4. 关键机制与安全边界
|
||||
|
||||
### 4.1 启动编排与单实例交接
|
||||
- `internal/vmstart` 承载 GUI 与 CLI 共用的启动步骤;只有常驻进程才能维持的能力(Guest Tools 桥接、Win10 冷重启监视)由界面进程托管。
|
||||
- CLI 执行 `vm start` 时,默认交由桌面进程启动:界面已在运行时通过 Wails 单实例锁(`WM_COPYDATA`)发消息不弹窗拉起;未运行时以 `--background` 启动隐藏到托盘的后台界面进程,结果经 `<DataRoot>\tmp\cli-start-*.json` 回传并带退出码返回。
|
||||
- `internal/lifecycle` 统一 GUI、CLI 与窗口交接的 VM 列表、详情、设置、启动、停止、重启、删除、介质动作和日志读取:按 `VMRef` 解析所属驱动,先收集第三方 Hook,否决时不调用驱动,成功后再发事件。macOS 的启动前检查、参数账本与磁盘准备由 `internal/macos/macosdriver` 自己完成,准备失败即中止;`internal/vmstart` 保留共享检查与旧回退。只有常驻进程才能维持的能力(Guest Tools 桥接、Win10 冷重启监视)由界面进程托管。
|
||||
- CLI 执行 `vm start` 时,默认交由桌面进程启动:界面已在运行时通过 Wails 单实例锁(`WM_COPYDATA`)发消息不弹窗拉起;未运行时以 `--background` 启动隐藏到托盘的后台界面进程,结果经 `<DataRoot>\tmp\cli-start-*.json` 回传并带退出码返回。交接同时携带 `--start-driver=`,裸名称不再作为跨驱动的完整身份。
|
||||
- 仅在 CLI 显式指定 `--data-root` 时由命令进程直接启动,此时不包含 Guest Tools 桥接与 Win10 冷重启监视。
|
||||
- `reims-go.exe` 编译为 Windows GUI 子系统程序,命令行模式下保留调用方管道/文件句柄,缺失时通过 `AttachConsole` 挂载父控制台;在交互式 PowerShell/cmd 中加 `| Out-Host` 可等待命令执行完毕。
|
||||
|
||||
@@ -87,13 +91,13 @@ flowchart TB
|
||||
- **Win10 冷重启监视通道**:Windows 10 19045 缺少 `WHvResetPartition`,客体热重启会导致 WHPX 退出异常。在 Win10 宿主上,启动时附加 `-no-reboot` 并另开一条独立的 `AF_UNIX` QMP 通道监听重启退出事件,干净退出后自动重新拉起。使用 `AF_UNIX` 而非 TCP,避免客体经 SLIRP 的 `10.0.2.2` 访问宿主机监控接口。
|
||||
|
||||
### 4.3 Guest Tools 与宿客安全边界
|
||||
- Guest Tools 服务仅监听 `127.0.0.1`,每台虚拟机分配独立的 256-bit 随机 Token(Bearer / Basic 鉴权)。
|
||||
- Guest Tools 服务仅监听 `127.0.0.1`,每台虚拟机分配独立的 256-bit 随机 Token(Bearer / Basic 鉴权)。注册表、连接状态、剪贴板策略、文本输入与 WebDAV handler 按 `driver.VMRef.Key()` 隔离;token 认证同时识别驱动与名称,既有客体 URL 不变。
|
||||
- WebDAV 共享目录(`/dav/<vm>/`)严格校验路径防目录穿越;Windows 盘符只读共享(`/dav/<vm>/drives/<盘符>/`)默认全部关闭,服务端同时限制 HTTP 写方法与只读打开标志、校验持久化 Volume GUID 防盘符漂移、限制 `PROPFIND Depth` 并校验 Junction/符号链接解析目标仍在授权盘符内。
|
||||
|
||||
### 4.4 宿主机体检与硬件调优
|
||||
- **免提权 WHPX 检测**:通过 `WinHvPlatform.dll`(`WHvGetCapability`)与系统功能查询判断状态,仅在缺失且用户确认时通过 `ShellExecuteW(..., "runas", ...)` 触发 UAC 启用。
|
||||
- **提交内存预检**:通过 `GlobalMemoryStatusEx` 检查可用提交内存(`AvailPageFile`),因为 QEMU 在 Windows 上会一次性提交整块客体内存;建机时推荐安全档位,启动前余量不足时提前拦截。
|
||||
- **GPU 与大小核**:扫描注册表 Vulkan ICD 并过滤虚拟显示适配器;解析 `GetLogicalProcessorInformationEx` 识别 P / E / LP-E 三层混合核心,支持按 VM 实时调整进程亲和性,避免超售卡顿。
|
||||
- **GPU 与大小核**:扫描注册表 Vulkan ICD 并过滤虚拟显示适配器;解析 `GetLogicalProcessorInformationEx` 识别 P / E / LP-E 三层混合核心,支持按 VM 实时调整进程亲和性,避免超售卡顿。宿主只评估通用硬件事实;`kernel_irqchip`、冷重启等 macOS/WHPX 建议由所属驱动的 `driver.OptimizationAdvisor` 提供,与启动准备共用运行时判定。
|
||||
|
||||
### 4.5 应用内更新
|
||||
- 界面启动后检查一次新版本,之后每 6 小时检查一次(后端缓存 10 分钟),只看 `vX.Y.Z` 正式版,忽略草稿与预发布。有新版本时侧栏顶部显示更新胶囊卡片,关于页提供同样的操作。
|
||||
@@ -103,10 +107,24 @@ flowchart TB
|
||||
- 开发构建(`wails dev`,`dev` 标签)与非 Windows 平台不支持应用内更新;程序所在目录不可写(如未提权的 `Program Files`)时提示改为手动更新。
|
||||
|
||||
### 4.6 资源回收与内存约束
|
||||
- 按 VM 生命周期分配的状态(缩略图锁、Guest Tools 注册与 WebDAV handler、进程采样、绑核记录、文本队列与 worker)在删除 VM 或轮询发现外部删除时立即回收。
|
||||
- 按 VM 生命周期分配的状态(过渡态、待生效设置、冷重启监视、磁盘路径缓存、进程采样、缩略图与键入锁、文本队列与 worker)以 `driver.VMRef.Key()` 隔离,并在删除 VM 或轮询发现外部删除时立即回收;VM 日志来源也使用规范键。
|
||||
- 日志监视器对单行无换行输出设 **64 KiB** 内存上限(原始日志文件完整保留);已结束任务在 10 分钟后从前后端状态中清理。
|
||||
- 4K 屏幕预览采用按行流式缩放降低单帧分配;手动复制截图仍保留全分辨率。不在热路径中人为调用 `debug.FreeOSMemory`。
|
||||
|
||||
### 4.7 数据目录版本与迁移
|
||||
- `<DataRoot>\.reims-go-data.json` 记录数据布局版本 `data_version`,以及最后一次提升它的应用版本 `written_by`。它不放进 `reims-go.json`,因为配置每次保存都会按结构体整体重写,旧版本会丢掉不认识的字段。
|
||||
- 每个版本都带着从旧布局升到自身布局的全部迁移步骤(`internal/datamigrate`),GUI 与 CLI 启动时、读取数据之前按版本号依次执行。步骤必须可重复执行;某步失败时,版本号停在最后一个成功的步骤,下次启动从那里继续。用户可以从任意旧版本直接升到新版本。
|
||||
- GUI 启动、首次设置、切换数据目录与 CLI 都经 `internal/dataroot` 打开数据目录:先不加锁读取版本戳,需要迁移时才取 `<DataRoot>.reims-go.lock` 并在锁内重读版本戳,两个进程同时打开同一目录时迁移只执行一次。
|
||||
- 数据目录由更新版本写入、版本戳无法解析、迁移失败或另一进程长时间持锁时,以只读模式打开,不创建或修改任何文件(包括锁文件):GUI 不启动插件、不轮询虚拟机,以只读界面代替工作台;CLI 只放行 `version`、`help` 与 `doctor`。版本戳损坏时可由用户显式修复,从 v0 重新执行全部步骤。
|
||||
- 首次设置选定目录之前,宿主不写入默认建议目录:不迁移、不启动插件、不轮询,界面中的选择只保存在内存里,由 `CompleteSetup` 写入选定的目录。
|
||||
- 只有删除很老的迁移步骤之后,才需要「最低迁移版本」:新版本根据 `data_version` 判断,并提示先安装某个中间版本。这个判断看的是数据本身,所以直接下载新版本运行也会生效。
|
||||
- 现有步骤:v1 为 reims-ctl 管理的每台 VM(目录含 `vm.toml`)补写驱动归属标记,见 [plugin-architecture.md](plugin-architecture.md) 的「VM 归属」;v3 一次性把正式版 `builtin.core` 的设置、`builtin.install-guide` 的启停和已知参数账本条目迁入 `builtin.guest.macos`,把按裸 VM 名的插件设置键改为 `driverID:vmName`,并补扫无归属标记的 VM。`state.json` 只加载、保存一次,原始 `.bak` 不被中间布局覆盖;功能分支上的 v2 仍可直升,未公开发布过的旧插件 ID 不做长期迁移。
|
||||
|
||||
### 4.8 macOS 代码边界
|
||||
- macOS 专属代码集中在 `internal/macos/` 与 `frontend/src/macos/`,最终作为独立插件移出本仓库;宿主只应经驱动层(`driver.Router`)与宿主服务使用它。
|
||||
- 三个棘轮测试守住边界:`internal/archtest` 分别检查宿主到 macOS、macOS 到宿主私有 Go 包的依赖,`frontend/scripts/test-macos-boundary.mjs` 检查前端文件。只有列入清单的包或文件可以跨界;新增引用、或清单中的条目已不再引用时,测试都会失败,所以清单只能缩短。
|
||||
- 宿主到 macOS 的例外包括 GUI 与 CLI 的组装入口、数据布局 v2 的迁移,以及仍混有宿主与 macOS 逻辑、待拆分的 `internal/guesttools`。反向清单记录 macOS 对宿主私有包的现有依赖,随公开接口建设逐步清零。
|
||||
|
||||
---
|
||||
|
||||
## 5. 与上游 `reims-vgpu` 的边界
|
||||
|
||||
@@ -20,7 +20,7 @@ Reims-Go 的桌面外壳遵循「**macOS 的结构与词表,Windows 的平台
|
||||
| :--- | :--- |
|
||||
| **声明式配置** | 一台虚拟机对应一份声明式配置,界面只编辑配置项,不让用户直接拼 QEMU 命令行参数。 |
|
||||
| **先校验,后保存** | 保存前在 Go 端完成前置校验(CPU 核数、可用提交内存上限、Vulkan ICD 路径存在性、切换磁盘控制器前是否已弹出安装盘),非法值在提交前拦截。 |
|
||||
| **随时可编辑,标明生效时机** | 无论虚拟机运行与否,设置面板均可打开编辑;每项设置明确标注生效时机。运行中保存「下次启动生效」的修改时,详情页汇总待生效项并提供「重启以应用」。 |
|
||||
| **标明设置的生效时机** | 虚拟机运行中或已停止时可编辑设置。每项设置明确标注生效时机。运行中保存「下次启动生效」的修改时,详情页汇总待生效项并提供「重启以应用」。 |
|
||||
|
||||
**写入约束**:凡属于上游 `reims-ctl` 管理的配置项,一律通过 `reims-ctl set` 写入,不直接改写 `vm.toml`,确保上游校验与 OpenCore 重建逻辑照常生效。
|
||||
|
||||
@@ -55,11 +55,14 @@ Reims-Go 的桌面外壳遵循「**macOS 的结构与词表,Windows 的平台
|
||||
| **正在创建** | 创建流程进行中 | 无(展示分步进度) | 取消创建 |
|
||||
| **已停止** | 上游 `stopped` | **启动** | 设置、恢复点、更多(派生副本、扩容/回收、打开目录、删除) |
|
||||
| **正在启动** | 发起 `start` 至 `running` | 启动中(忙碌态,禁用) | 设置、强制关机 |
|
||||
| **运行中** | 上游 `running` | **显示 VM 窗口** | 关机、截屏、设置、更多(重启、强制关机、发送文本、进入/退出恢复模式、导出排障包) |
|
||||
| **运行中** | 上游 `running` | **显示 VM 窗口** | 挂起(需支持此功能的内核)、关机、截屏、设置、更多(重启、强制关机、发送文本、进入/退出恢复模式、导出排障包) |
|
||||
| **正在停止** | 发起 `stop` 至 `stopped` | 停止中(忙碌态,禁用) | 强制关机 |
|
||||
| **正在挂起** | 正在保存运行状态 | 挂起中(忙碌态,禁用) | 强制关机 |
|
||||
| **已挂起** | 运行状态已保存到磁盘 | **恢复**(需支持此功能的内核) | 更多(放弃挂起状态、打开目录) |
|
||||
| **正在恢复** | 正在从磁盘恢复运行状态 | 恢复中(忙碌态,禁用) | 强制关机 |
|
||||
| **配置损坏** | 上游 `broken` | **查看问题** | 打开目录、删除 |
|
||||
|
||||
- 暂不提供暂停或运行中热快照状态(`paused` / `saving` / `restoring`),直到上游验证 `reims-vgpu` 显存与设备状态序列化。
|
||||
- 已挂起时,恢复或放弃挂起状态后才可修改配置、管理磁盘和安装或弹出 Guest Tools。切换到不支持挂起的内核时,禁用恢复并提示用户切换内核。放弃挂起状态须经破坏性操作确认框确认。
|
||||
- 禁用按钮不占据主操作位置;状态变化时直接切换为当前最合适的主操作。
|
||||
|
||||
---
|
||||
@@ -82,7 +85,7 @@ Reims-Go 的桌面外壳遵循「**macOS 的结构与词表,Windows 的平台
|
||||
## 6. 视觉、图标与无障碍基线
|
||||
|
||||
- **样式令牌化**:所有颜色、字号、间距(4 px 网格)、圆角与阴影统一引用 [`frontend/src/styles/tokens.css`](../frontend/src/styles/tokens.css) 中的 CSS 变量,禁止在组件内联写死颜色或字号。
|
||||
- **字体**:内嵌开源 Inter Variable 作为拉丁字体,并针对 Windows DirectWrite 特性显式映射中文字体字重,避免正文过细或中英混排断层。
|
||||
- **字体与区域排印**:内嵌开源 Inter Variable 作为拉丁字体,并通过动态 `<html lang dir>` 与 `:lang()` 选择器按区域分离东亚字体栈(简体、繁体、日文、韩文各自优先匹配对应系统 UI 字体,避免 Han Unification 异体字混用);繁体与日文正文采用 `400` 字重与更舒展的行高防止高笔画糊字,开启中西文自动盘古间距;Win32 原生引导浮层按脚本分级探测 GDI 字体并支持卡片宽度自适应与长按钮纵向堆叠。语言包插件可附带沙箱校验的 `.woff2` 字体补齐缺字宿主。
|
||||
- **按钮层级**:每视图至多 1 个实底主按钮;常用操作用次按钮或图标按钮;破坏性操作仅用红字出现在菜单与确认框。
|
||||
- **纯图标按钮边界**:仅当图标含义通用(启动、停止、设置、更多、新建、复制、关闭、刷新、日志)且既非主操作也非破坏性操作时才允许纯图标;所有纯图标按钮必须具备悬停 Tooltip(含快捷键)、`aria-label` 与 ≥ 28×28 px 的点击热区。领域专有操作(如「弹出安装盘」「显示 VM 窗口」「重启以应用」)必须保留文字。
|
||||
- **键盘与缩放**:所有可交互项必须为原生 `<button>` 或带完整 ARIA 语义的 Radix 基件,提供 `:focus-visible` 焦点环;全局快捷键包括 `Ctrl+N`(新建)、`Ctrl+B`(折叠侧栏)、`Ctrl+,`(设置)、`Ctrl+L`(日志)。最小窗口尺寸 960×640,需在 100% / 125% / 150% DPI 下无文字截断。
|
||||
@@ -101,9 +104,9 @@ Reims-Go 的桌面外壳遵循「**macOS 的结构与词表,Windows 的平台
|
||||
| `x86-64 macOS guest (q35 and OpenCore, WHPX)` | 本地化简述(如「macOS · Intel · WHPX 加速」) | 技术信息 |
|
||||
| `user (MAC configured), ssh on 127.0.0.1:2222` | 「NAT · SSH 2222」 | 技术信息 |
|
||||
| 环境变量或底层参数名(如 `REIMS_VGPU_LOG`) | 用效果命名标题,不把变量名放进标题 | 描述或技术信息 |
|
||||
| 内部错误原始文本 | 本地化的一句话说明 + 下一步建议 | 详情折叠区 / 日志 |
|
||||
| 内部错误原始文本 | 本地化的一句话说明 + 稳定错误码徽标(如 `[E_VM_CLONE_RUNNING]`) | 详情折叠区保留原始英文技术输出并支持一键复制完整诊断信息 |
|
||||
|
||||
格式化逻辑统一集中在 [`frontend/src/lib/format.ts`](../frontend/src/lib/format.ts),不在组件中零散拼接。
|
||||
格式化逻辑统一集中在 [`frontend/src/lib/format.ts`](../frontend/src/lib/format.ts)(数字、列表与相对时间统一经原生 `Intl` API 按当前语种格式化),不在组件中零散拼接。跨宿主与客户机语言的安装引导提示(如宿主机中文操作英文 macOS 恢复环境)自动采用「宿主译名 (`Guest Term`)」双标,同语种则单标。开发模式下提供 `en-XA` 伪本地化语种用于排查硬编码与长词截断。
|
||||
|
||||
### 7.2 文案风格
|
||||
- **克制直接**:标题用名词;按钮用 2–5 字动词;描述控制在清晰的一句话;不使用「请」「您」「成功」和感叹号;按钮和短提示末尾不加句号。
|
||||
|
||||
@@ -0,0 +1,272 @@
|
||||
# 客体插件化与 macOS 剥离方案
|
||||
|
||||
> 状态:待评审。本文描述从现有代码走到"与客体无关的主程序 + macOS 外部插件"的路径。[plugin-architecture.md](plugin-architecture.md) 记录的是插件系统当前的权威设计;本文的每一步合入时,同步修改该文对应章节(§3.2、§5.3、§5.4、§12 等),两份文档不得长期并存矛盾。
|
||||
|
||||
## 1. 目标与边界
|
||||
|
||||
- **终态**:主程序是与客体无关的本地虚拟机工作台。macOS 能力作为外部插件(独立仓库、独立发布)提供;主程序的源码、文档、语言词表、发布物与运行时流水线不含 macOS 专属内容。
|
||||
- **过渡态**:macOS 先成为内置插件 `builtin.guest.macos`,仍随 `reims-go.exe` 编译。过渡期只保证两件事,以免外置时再做一次迁移:
|
||||
- **职责与数据按终态划分**:设置、参数账本、VM 归属、启动准备从一开始就归 macOS 插件与它的驱动所有。
|
||||
- **调用面按终态收敛**:macOS 代码只经驱动接口、Hook 与宿主服务使用宿主;它对宿主 Go 包的依赖逐步收敛到可公开的 `pkg/` 包(第 6 节的反向棘轮)。
|
||||
- 界面是唯一允许的例外:过渡期可挂载原生页面,步骤 5 替换。
|
||||
- **特权按角色而不是按 ID 前缀**:宿主内置插件(留在主程序的部分)保留现有特权;拥有某台 VM 的驱动,对该 VM 的启动参数拥有完整控制(含 `-drive`、`-chardev`、`-qmp` 等),无论它是内置还是外部。外部驱动本身是 L3 原生程序,拥有完整账户权限,这不构成提权;第三方 Hook 仍受现有脱敏、超时与参数族限制。
|
||||
- **Linux 驱动**用于验证接口通用性,按 plugin-architecture.md Phase 4 以独立仓库的 L3 插件实现。Android 只预留接口。
|
||||
- **不在本方案内**:常驻后台服务、OCI 分发、运行态热迁移、整盘导出导入、稳定 VM ID(第 8 节)。
|
||||
- 哪些内容构成法律风险、需剥离到什么程度,不由本文判断,见第 9 节。
|
||||
|
||||
## 2. 现状
|
||||
|
||||
macOS 代码已集中到 `internal/macos/`(`installer`、`opencore`、`installguide`、`reims`、`macosdriver`)与 `frontend/src/macos/`,宿主到 macOS 的 import 由两处棘轮测试守住([architecture.md](architecture.md) §4.8)。仍需解决的问题:
|
||||
|
||||
### 2.1 身份与数据
|
||||
|
||||
| 问题 | 现状 |
|
||||
| :--- | :--- |
|
||||
| 驱动 ID 与旧插件 ID 混用 | `builtin.driver.reims-macos` 同时列在 `builtin.RetiredIDs` 中,不能直接拿来做新插件 ID |
|
||||
| 设置迁移不原子 | `MigrateRetired` 先落盘删除旧记录,再单独落盘新设置;两次写盘之间退出会丢失用户关闭过的选项 |
|
||||
| 安装引导独立成插件 | `builtin.install-guide` 是独立可选插件,内容是纯 macOS 的安装与恢复引导 |
|
||||
| 使用中保护依赖静态声明 | 使用中检查经 `DeclaredDriverIDs` 读取清单的 `guestDrivers`;`builtin.core` 在激活时动态注册驱动,未静态声明。核心插件不可停用所以目前无害,macOS 插件可停用后会失效 |
|
||||
| VM 以裸名称索引 | `PluginRecord.VMSettings` 以 VM 名为键;宿主内存态(`transitions`、`pendingChanges`、`rebootWatchers`、`diskPaths`、`procSamples`)、Guest Tools 注册表、缩略图与键入锁、日志来源同样以名称索引;界面进程交接参数 `--start-vm=` 不带驱动 |
|
||||
| VM 目录只有一个根 | 路由与"驱动不可用"扫描只看 `<DataRoot>/data/reims-ctl/vms` |
|
||||
| 运行时只能选一个 | `config.ActiveRuntime` 是单个字符串;非默认种类直接取已安装列表第一项;已装多个 reims-vgpu 运行时且未选定时,所有依赖运行时的功能失败 |
|
||||
|
||||
### 2.2 数据目录写入
|
||||
|
||||
GUI 启动、首次设置、`SetDataRoot`、CLI 各自打开数据目录;迁移失败时 GUI 只记日志、CLI 只打印警告;`SetDataRoot` 先保存配置再迁移;首次设置完成前,宿主已把默认建议目录当作数据目录读写;版本戳损坏时按 v0 重跑;没有跨进程写锁。
|
||||
|
||||
### 2.3 启动链路
|
||||
|
||||
| 问题 | 现状 |
|
||||
| :--- | :--- |
|
||||
| 启动入口 | GUI 的 `App.StartVM` 直接取 reims 客户端、自做 WHPX 检查,启动事件写死 macOS 驱动 ID 与能力;CLI 有直接启动(`startVM`)与交给界面进程(`startInWindow`)两条路径 |
|
||||
| 启动准备放在公共 Hook | `builtin.core` 的 `vm.beforeStart` 依次执行离线辅助盘、恢复启动、引导语言、WHPX 兼容降级、Win10 冷重启五步;恢复与语言两步在回调里直接写恢复标记、改写 OpenCore 镜像,后续插件否决时磁盘已被改动 |
|
||||
| 特权按前缀 | `BuiltinOnlyQEMUOptionFamilies`(`-drive`、`-chardev`、`-qmp`、`-fw_cfg`、`-global`、`-object`)、宿主环境变量白名单与 `PostStart` 动作都按 `builtin.` 前缀放行;外部插件的 `vm.beforeStart` 拿不到 `VMDir`、`ExtraArgs`、`InstallerPath`,单个回调限时 2 秒 |
|
||||
| 驱动接口缺参数 | `Driver.Start` 只收 VM 名,不接收合并后的参数、环境变量与启动后动作;参数账本的合并结果在 `StartVM` 中经 `reims-ctl set --extra-args` 写入;`stripLegacyManagedExtraArgs` 在 `internal/app` 中直接调用 macOS 代码 |
|
||||
| 调优不分驱动 | `host.EvaluateOptimizations` 一次算出绑核、irqchip、冷重启、独显与 CoW 建议 |
|
||||
|
||||
### 2.4 路由与界面
|
||||
|
||||
列表、详情、设置、停止、删除、日志等十余处直接调用 reims 客户端;`Router.ListAllVMs` 没有调用方且按名称去重;`Router.ResolveVM` 返回第一个同名结果;CLI 只有 `vm create --driver` 走驱动层;前端类型直接使用 `reims.VMDetail`,`CreateWizard`、`SettingsModal`、`lib/tasks.ts` 含 OpenCore、恢复、引导语言、无边框、安装包等字段与交互(不经 import,棘轮看不到)。
|
||||
|
||||
### 2.5 外置障碍
|
||||
|
||||
| 问题 | 现状 |
|
||||
| :--- | :--- |
|
||||
| Go 可见性 | `internal/macos/*` 导入宿主的 `internal/config`、`host`、`i18n`、`driver`、`plugin`、`runtime`、`vmstart`;外部仓库不能导入别的模块的 `internal/` 包 |
|
||||
| SDK | `pkg/pluginsdk` 只有 JSON-RPC 骨架 |
|
||||
| 反向宿主接口 | Sidecar 只能调用 `notify`、`audit`、`vm.spawn`、`vm.stop`、`vm.isRunning`;没有运行时查询、内存预检、绑核、日志与任务、进程退出、窗口信息等服务 |
|
||||
| 外部界面 | 外部插件不能贡献整页界面;沙箱 iframe 没有文件选择、流式任务进度、弹窗与尺寸协调等桥接 |
|
||||
| 非 import 耦合 | 全局脱敏器(`i18n.SetDetailRedactor`、插件管理器 `RedactFn`、排障包、界面错误上报)都直接用 `reims.RedactText`;`internal/runtime` 内置 `DefaultKind = "reims-vgpu"`、`reims-ctl` / `reims-util` 路径、reims 专用环境变量、按补丁推断能力与发布源;`locales/*/macos-glossary.json` 与 `internal/i18n/glossary.go`,以及 `vm`、`wizard`、`settings` 等词表中的 macOS 文案;`internal/app/macos_release.go`(`.reims-go-macos`);数据目录禁止逗号源于 `reims-util`;`internal/host` 中面向 reims-vgpu / metal2vulkan 的显卡兼容判断;CLI 顶层 `installer` 子命令 |
|
||||
| 外围文件 | `patches/`、`.github/workflows/build-runtime.yml`、`scripts/` 中的运行时打包与补丁脚本、`docs/portable-runtime-spec.md` |
|
||||
|
||||
## 3. 身份模型
|
||||
|
||||
| 身份 | 作用 | 规则 |
|
||||
| :--- | :--- | :--- |
|
||||
| 插件 ID | 启停、设置、贡献、参数账本归属 | 过渡期 `builtin.guest.macos`;外部插件不可使用 `builtin.` 前缀,换新 ID,经声明式承接接收旧 ID 的数据(见下) |
|
||||
| 驱动 ID | 一台 VM 由谁管理,写在 VM 目录的 `.reims-go-driver` | 过渡期保留 `builtin.driver.reims-macos`;外部驱动换新 ID,并把旧 ID 声明为别名,已有标记不改写 |
|
||||
| 运行时种类 | 安装哪套可执行程序、驱动要求的接口版本 | 每种类单独选定活跃运行时(步骤 3.5) |
|
||||
| VM 引用 `VMRef` | 一次操作、一份设置或一项内存状态针对哪台 VM | `{驱动 ID, 驱动内名称}`,自步骤 2 起贯穿宿主;稳定 VM ID 见第 8 节 |
|
||||
| VM 目录根 | 驱动的 VM 放在哪里 | 驱动在清单中静态声明自己的 VM 根目录(相对 DataRoot);macOS 驱动声明现有的 `data/reims-ctl/vms`。停用的驱动清单仍可读,宿主据此扫描"驱动不可用"的 VM,两个驱动的同名 VM 不会在磁盘上冲突 |
|
||||
|
||||
**声明式承接**:外部插件在清单中声明 `replaces`(它承接的旧插件 ID)与驱动 `aliases`(它承接的旧驱动 ID)。宿主在**安装或首次激活该插件时**把旧 ID 名下的设置、参数账本条目与按 VM 设置转给它,并让带旧驱动 ID 标记的 VM 归它管理。约束:
|
||||
|
||||
- 宿主在旧插件消失后保留其 `state.json` 记录与账本条目,直到有插件承接,期间这些 VM 显示"驱动不可用"。
|
||||
- 承接 `builtin.*` ID 只允许信任等级为 `official` 的包,或经用户逐项确认,防止任意插件接管已有 VM。
|
||||
- 主程序不硬编码任何 macOS 新旧 ID 映射。数据迁移带入的 `driver.RenamedDriverIDs` 只用于主程序内部的内置驱动改名,外部插件改名一律走 `aliases`。
|
||||
|
||||
驱动 ID 从此与插件 ID 分开:步骤 1 将 `builtin.driver.reims-macos` 移出 `RetiredIDs`,只有正式发布过的旧记录进入迁移清单:`builtin.core` 的设置与账本,以及 `builtin.install-guide` 的启停。未公开发布过的独立 theme/driver、compat/prep 插件记录不迁移、不删除。
|
||||
|
||||
## 4. 分步方案
|
||||
|
||||
每一步单独合入、单独发布,完成后对应的棘轮例外缩短(第 6 节)。
|
||||
|
||||
### 步骤 0:数据目录写入保护
|
||||
|
||||
后续每一步的数据迁移都依赖它;不依赖第 3 节的任何决定,可以立即开始。
|
||||
|
||||
- **统一打开入口**:新增宿主包(暂名 `internal/dataroot`),GUI 启动(`config.Resolve`)、首次设置(`CompleteSetup`)、切换目录(`SetDataRoot`)与 CLI 都经它进入。顺序为:
|
||||
1. 不加锁读取版本戳。版本高于本程序、或版本戳无法解析时,以只读模式返回,**不创建锁文件、不写任何文件**。
|
||||
2. 需要迁移或即将写入时,才创建并获取写锁,**拿锁后重新读取版本戳**,再决定是否迁移。另一个进程已完成迁移时直接返回。
|
||||
3. 迁移完成、版本戳写入后释放写锁。
|
||||
- **写锁**:把 `internal/macos/installer` 中基于 `LockFileEx` 的文件锁上提为宿主公共实现(`internal/filelock`),锁文件放在数据目录内,只在迁移时持有。配置与 `state.json` 都以临时文件加改名的方式原子写入,单次写入不会留下残缺文件,因此不为单次写入加锁;GUI 与 CLI 同时修改同一份配置时的相互覆盖不在本步解决。
|
||||
- **只读诊断模式**:GUI 不启动插件、不轮询虚拟机,以只读界面代替工作台,说明原因与详细信息,可选择其他目录;版本记录损坏时提供显式"修复(从 v0 重新迁移)",另一进程升级中或升级失败时提供"重试"。CLI 只放行 `version`、`help` 与 `doctor`,其他命令以非零退出码拒绝。
|
||||
- **写入点清单**(只读模式与首次设置前全部拦截):`reims-go.json`、`plugins/state.json` 与其备份、市场索引缓存、版本戳、启动哨兵 `.startup-sentinel`、`cli-start-*.json`、界面健康日志 `logs/ui-health.log`、应用更新后对更新下载目录的清理、VM 目录内的参数账本与归属标记。`CompleteSetup` 对候选目录的可写性探测(`.write-test-*`)只针对用户已选定的目录,保留。
|
||||
- **首次设置前零写入**:`needsSetup` 期间不把默认建议目录当作数据目录,数据迁移、插件状态与配置保存都要等目录选定。`REIMS_GO_FIRST_RUN` 测试模式必须同时指定隔离的数据目录,否则拒绝启动。
|
||||
- **CLI 交给界面进程**:`location.json` 位于数据目录之外。CLI 未指定数据目录、经单实例交给界面进程时,以界面进程当前打开的目录为准;该目录处于只读模式时,写命令被拒绝并说明原因。
|
||||
- **`MigrateRetired` 一次落盘**:删除旧记录与写入新设置合并为一次 `state.json` 原子替换。
|
||||
|
||||
**验收**
|
||||
- 高版本或版本戳损坏的数据目录:GUI 进入只读模式、CLI 写命令被拒,目录内无任何文件(含锁文件)被创建或修改。
|
||||
- 首次设置测试模式与设置完成前,默认建议目录内无任何文件被创建或修改。
|
||||
- 在 `MigrateRetired` 两步之间模拟退出,重启后用户关闭的选项仍为关闭。
|
||||
- GUI 与 CLI 同时启动并触发迁移,迁移只执行一次,结果一致。
|
||||
|
||||
### 步骤 1:macOS 插件身份与元数据迁移(已落地,合并至 v3)
|
||||
|
||||
- 新增内置插件 `builtin.guest.macos`,注册代码放在 `internal/macos/guest` 内,由 GUI 与 CLI 组装入口注册。`builtin.core` 只保留客体无关的默认主题。过渡期 macOS 插件默认启用,以保留存量 VM 的升级行为。
|
||||
- **安装引导并入**:`builtin.install-guide` 并入 `builtin.guest.macos`,成为它的一个可开关功能;旧 ID 退役,用户原来的启用状态转为新插件的对应设置。外部 macOS 插件因此只是一个包。
|
||||
- **静态声明驱动**:新插件在清单 `guestDrivers` 中静态声明 `builtin.driver.reims-macos`,运行中检查才能阻止在 macOS VM 运行时停用它,使用中检查才能阻止在仍有 macOS VM 时卸载它。
|
||||
- **设置迁移**:`whpx_fallback`、`win10_cold_reboot` 从 `builtin.core` 转给新插件,合并顺序为"新插件显式值 → 旧插件显式值 → 默认值"。
|
||||
- **参数账本迁移**:每台 VM 的账本中,只把已知由 macOS 启动步骤写入的条目转给新插件;用户手动参数与其他插件的条目保持原所有者。无账本的旧 VM(老版本或 CLI 直接启动过)由 `stripLegacyManagedExtraArgs` 兜底,该函数随之迁入 macOS 代码。
|
||||
- **迁移方式**:在写锁下先备份受影响的小文件,一次替换 `state.json`,各步可重复执行,全部校验通过后才写版本戳 v3;与步骤 2a 的 VMRef 设置键转换共用一次 `state.json` 读取和写入,保留升级前原始备份。VM 目录、磁盘、快照、CoW 父盘与 `vm.toml` 不移动。
|
||||
- **反向棘轮**:新增"`internal/macos/` 只能导入列入清单的宿主包"的测试,清单从现状开始,只减不增。
|
||||
|
||||
**验收**
|
||||
- 从 v0.2.x 直升:用户关闭过的兼容选项与安装引导开关保持原值,手动设置的 `kernel-irqchip` 仍优先。
|
||||
- 迁移中途退出后重启,迁移可继续,结果与一次完成相同。
|
||||
- 同一台 VM 连续启动两次,参数不重复追加,辅助盘不重复挂载。
|
||||
|
||||
### 步骤 2:VM 引用与启动链路
|
||||
|
||||
**2a. `VMRef` 身份、内部索引与 list/start/stop 用户入口已落地**(原计划在步骤 3,提前是因为统一启动入口就要按归属解析 VM)
|
||||
|
||||
- 引入 `VMRef{DriverID, Name}`;`Router.ResolveVM` 遇到多个同名结果时返回歧义错误;`ListAllVMs` 不再按名称去重。
|
||||
- 驱动在清单中声明 VM 根目录(第 3 节),路由与"驱动不可用"扫描遍历所有已声明的根。
|
||||
- 宿主内存态、Guest Tools 注册表、缩略图与键入锁、日志来源改为按 `VMRef` 索引;对客体已经暴露的访问路径保留兼容。
|
||||
- `PluginRecord.VMSettings` 的键改为 `VMRef` 的规范字符串,与步骤 1 共用版本 v3 的一次写入:已有键全部归属 `builtin.driver.reims-macos`。
|
||||
- 界面进程交接参数增加驱动;只给名称且不重名时仍可用。
|
||||
|
||||
**2b. 驱动自有准备与第三方意图分开(已落地)**
|
||||
|
||||
- `Driver.Start` 改为接收启动请求:`VMRef`、第三方插件经 `vm.beforeStart` 给出的意图(参数片段、环境变量、启动后动作),以及日志输出。
|
||||
- 启动前检查(WHPX、运行时兼容)与启动准备由驱动自己完成。macOS 的离线辅助盘、恢复启动、引导语言、WHPX 兼容降级、Win10 冷重启、Guest Tools 辅助盘从 `vm.beforeStart` 移入 macOS 驱动的 `Start`,"先准备恢复环境,再写引导语言"的顺序由驱动保证。
|
||||
- 参数账本的合并与写入(对 reims 即 `reims-ctl set --extra-args`)由驱动执行,宿主以公共函数提供账本合并逻辑。
|
||||
- `vm.beforeStart` 只留给第三方插件,继续脱敏、限时、限参数族。驱动在完成全部第三方 Hook、无人否决之后才改动磁盘,因此不需要通用回滚:准备步骤保持可重复执行,任一步失败即中止启动并明确报错;用户选择恢复启动而准备失败时,不悄悄转为普通启动。
|
||||
- 特权按第 1 节的角色规则判定:驱动对自己的 VM 拥有完整参数控制;宿主内置插件保留现有白名单;其他插件按现有限制。
|
||||
|
||||
**2c. 统一入口与职责拆分(已落地)**
|
||||
|
||||
- 新增生命周期模块(暂名 `internal/lifecycle`),GUI 的 `StartVM` 与 CLI 的 `startVM` 都调用它,`startInWindow` 交给界面进程后同样进入它。宿主负责按 `VMRef` 解析驱动、串行化同一台 VM 的操作、派发事件(驱动 ID、运行时与能力取自该 VM)、任务与日志、进程退出监视。
|
||||
- **拆分 `vmstart`**:提交内存检查、P 核绑核、亲和性配置留在宿主;离线辅助盘、恢复标记与 OpenCore 相关步骤迁入 `internal/macos/`。
|
||||
- **拆分 Guest Tools**:传输、剪贴板与共享目录留在宿主(`guest-tools.transport` 服务),macOS 客体代理与辅助盘镜像(`BuildToolsDiskImage` 等)迁入 `internal/macos/`;镜像构建由 macOS 驱动在全部启动 Hook 通过后执行。
|
||||
- **拆分调优判定**:宿主只报告探测事实;驱动针对选中的 VM 结合运行时能力给出建议,设置页与实际启动共用同一份判定。`kernel-irqchip`、WHPX 兼容降级与冷重启补偿的策略归 macOS 驱动。
|
||||
|
||||
**验收**
|
||||
- 升级后用原有 macOS VM 验证:恢复引导、离线辅助盘、引导语言、冷重启监视、Guest Tools 与升级前行为一致;按 VM 的插件设置不丢失。
|
||||
- 第三方插件否决启动时,VM 目录与 OpenCore 镜像未被修改。
|
||||
- 测试驱动在相同宿主探测结果下,不会收到 OpenCore、辅助盘或冷重启参数。
|
||||
|
||||
### 步骤 3:其余入口统一路由(通用 App/CLI 已去 reims 直调,原生 macOS 流程按文件例外隔离)
|
||||
|
||||
- **后端**:VM 列表与轮询、详情、创建、设置、停止、重启、删除、日志、弹出安装介质,以及快照、克隆、磁盘、缩略图、统计、排障采集、亲和性等流程,全部经生命周期模块按 `VMRef` 路由。
|
||||
- **CLI**:`vm` 子命令全部走驱动层,重名时要求 `--driver`。顶层 `installer` 子命令改由 macOS 插件经 `commands` 扩展点贡献,宿主 CLI 提供插件命令转发。
|
||||
- **前端**:改用通用 VM 模型(名称、驱动、状态、CPU、内存、磁盘摘要、可用操作),按驱动能力位显示入口,后端执行时同样校验能力。`CreateWizard`、`SettingsModal` 中的 macOS 字段改为驱动的 `CreateSchema` / `SettingsSchema` 或插件页面。
|
||||
- **macOS 界面**:安装包页、在线恢复、版本图、OpenCore 设置由 macOS 插件贡献;过渡期经同一处注册表挂载 `frontend/src/macos/` 内的原生页面。
|
||||
|
||||
**验收**
|
||||
- 在测试装配中不注册 macOS 插件:工作台仍可用测试驱动完成"创建 → 启动 → 停止 → 删除"。
|
||||
- 两个驱动各有一台名为 `dev` 的 VM:两台都出现在列表、各自的按 VM 设置互不覆盖;停止其中一台只调用其所属驱动。
|
||||
- 恢复 macOS 插件后,原有 macOS VM 沿原路径启动,无需转换磁盘或重建配置。
|
||||
|
||||
### 步骤 3.5:宿主服务与按种类的运行时
|
||||
|
||||
Linux 驱动(步骤 4)与 macOS 外置(步骤 5)共同的前置条件,可在步骤 2 之后与步骤 3 并行开发。
|
||||
|
||||
- **按种类选定运行时**:配置改为每个运行时种类各记一个活跃运行时,随数据版本迁移现有的单值;只读操作在未选定时临时使用该种类最新安装的运行时、不写回配置,启动与创建前要求选定(待决,见第 9 节)。
|
||||
- **运行时与 reims 解耦**:`internal/runtime` 只保留按种类的通用安装、校验、切换与环境构造;reims-vgpu 的默认种类、`reims-ctl` / `reims-util` 路径、专用环境变量、按补丁推断能力与发布源,改由运行时种类声明提供(过渡期由 macOS 插件声明)。
|
||||
- **反向宿主接口扩充**(同时进入 `pkg/pluginsdk` 的公开类型):运行时查询(按种类返回路径与能力)、提交内存预检、绑核、日志与任务进度、进程退出通知、QMP 访问、VM 窗口信息与宿主明暗主题事件(安装引导浮层需要)。每项按权限校验。
|
||||
- **脱敏注册**:宿主提供通用脱敏层,插件可注册自己的脱敏规则;全局脱敏器、插件管理器、排障包与界面错误上报改用它。macOS 的规则由 macOS 插件注册。
|
||||
|
||||
### 步骤 4:Linux 最小驱动与驱动契约测试
|
||||
|
||||
- 新增与具体驱动无关的契约测试集(暂名 `internal/driver/drivertest`),对每个驱动运行同一组用例:生命周期调用的幂等与可重试边界、错误分类,以及"进程已启动 / 控制通道可用 / 客体已就绪"三种状态的区分。
|
||||
- Linux 驱动以独立仓库的 L3 插件实现,只依赖 `pkg/pluginsdk` 与反向宿主接口;先跑通一种镜像的创建、启动、停止与删除,再按 plugin-architecture.md Phase 4 的验收标准补齐。
|
||||
- 只有出现两份以上重复实现时,才从中提取磁盘或 QEMU 公共模块。
|
||||
|
||||
**验收**:契约测试同时覆盖 macOS 内置驱动与 Linux 驱动;Linux 驱动不修改主程序源码即可接入。
|
||||
|
||||
### 步骤 5:macOS 外置
|
||||
|
||||
前置条件:
|
||||
|
||||
- **外部插件页面**:整页插件页面(iframe,插件自带前端包,宿主提供主题令牌与到插件自身 Sidecar 的桥接)、创建向导步骤槽位、VM 详情分区槽位。桥接至少提供:宿主文件与目录选择(返回宿主路径交给插件 Sidecar,iframe 内不可见)、长任务的注册与流式进度(下载、取消、退出前拦截活跃任务)、由宿主绘制的对话框、iframe 高度自适应与焦点和快捷键传递。
|
||||
- **运行时需求声明**:插件在清单中声明需要的运行时种类与版本范围;缺少时宿主引导用户安装。运行时包不随插件安装事务自动拉取,插件之间的安装期依赖等出现真实用例再设计。
|
||||
- **语言与文案**:`macos-glossary.json`、`internal/i18n/glossary.go` 与各词表中的 macOS 文案迁入 macOS 插件的 `l10n`;第三方语言包对 macOS 文案的翻译改为针对该插件的 `pluginOverrides`。
|
||||
- **反向棘轮清零**:`internal/macos/` 不再导入任何宿主 `internal/` 包,只依赖 `pkg/`。
|
||||
- **声明式承接可用**:`replaces` 与 `aliases`(第 3 节)已实现并有测试。
|
||||
|
||||
外置本身:
|
||||
|
||||
- 迁出清单:`internal/macos/`、`frontend/src/macos/`、macOS 词表、`patches/`、`.github/workflows/build-runtime.yml`、`scripts/` 中的运行时打包与补丁脚本、`docs/portable-runtime-spec.md` 中 reims-vgpu 专属部分。用 `git filter-repo` 按清单生成 macOS 插件仓库,保留这部分历史;主仓库一次提交删除,并改写 README 与 AGENTS 中的产品定位。若历史本身也需剥离,改为反向拆分(第 9 节)。
|
||||
- 发布不含 macOS 的主程序:已有 macOS VM 因归属标记与 macOS 驱动声明的 VM 根仍在列表中,显示"需要安装对应驱动插件",由用户自行安装;主程序不自动安装、不默认推荐。用户安装外部 macOS 插件后,经声明式承接取回设置、账本与 VM 归属。
|
||||
|
||||
**验收**
|
||||
- 主仓库删除迁出清单后,构建、测试与两处棘轮全部通过;对 `macOS`、`OpenCore`、`reims`、`Apple` 等词的全仓检索只剩明确列出的例外(如"驱动不可用"提示中的通用说法)。
|
||||
- 安装外部 macOS 插件后,原有 macOS VM 无需转换即可启动,用户关闭过的选项保持关闭。
|
||||
|
||||
## 5. 顺序与并行
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
S0["步骤 0\n数据目录写入保护"] --> S1["步骤 1\nmacOS 插件身份\n与 v3 迁移"]
|
||||
S1 --> S2["步骤 2\nVMRef 与启动链路"]
|
||||
S2 --> S3["步骤 3\n其余入口统一路由"]
|
||||
S2 --> S35["步骤 3.5\n宿主服务与\n按种类的运行时"]
|
||||
S3 --> S4["步骤 4\nLinux 最小驱动"]
|
||||
S35 --> S4
|
||||
S3 --> S5["步骤 5\nmacOS 外置"]
|
||||
S35 --> S5
|
||||
P5["外部插件页面 · 承接机制\n语言迁出 · 反向棘轮清零"] --> S5
|
||||
```
|
||||
|
||||
- 步骤 0 不依赖其他决定,可以立即开始;步骤 1、2 开始前需定下第 3 节的身份模型与第 1 节的特权规则。
|
||||
- 步骤 3 与 3.5 可并行;外部插件页面、承接机制与语言迁出可在步骤 2 之后并行开发。
|
||||
- 以法律目标为准时,最快路径仍要经过步骤 1–3.5;跳过它们会让外置时再做一次数据与职责迁移。
|
||||
|
||||
## 6. 棘轮与检查
|
||||
|
||||
**宿主 → macOS**(现有,`internal/archtest` 与 `frontend/scripts/test-macos-boundary.mjs`):
|
||||
|
||||
| 例外 | 移除时机 |
|
||||
| :--- | :--- |
|
||||
| `internal/plugin/builtin`(仅源码的 Guest Tools 参数辅助) | 步骤 2:客体代理与辅助盘镜像迁出后移除;注册与测试例外已在步骤 1 移除 |
|
||||
| `internal/datamigrate` | 步骤 5:历史 v3 迁移改为不依赖 macOS 实现的通用数据迁移后移除 |
|
||||
| `internal/guesttools`(源码与测试) | 步骤 2:客体代理与辅助盘镜像迁出 |
|
||||
| `internal/plugin`(仅测试) | 步骤 3:Sidecar 测试改用通用测试替身 |
|
||||
| `internal/app`、`internal/cli` | 步骤 3:只剩一个组装文件注册 macOS 插件,例外细化到该文件 |
|
||||
| 前端 `App.tsx`、`Sidebar.tsx`、`VMPage.tsx` | 步骤 3:改为插件贡献 |
|
||||
| 组装文件 | 步骤 5:macOS 外置后删除 |
|
||||
|
||||
**macOS → 宿主 `internal/`**(步骤 1 新增):清单从现状开始,随步骤 2 与 3.5 把依赖改到 `pkg/`,步骤 5 前清零。
|
||||
|
||||
**非 import 耦合**:import 棘轮看不到第 2.5 节所列的词表、脱敏、运行时、前端字段等耦合。不为它们另建常驻检查;各自在所属步骤内迁移,步骤 5 以一次全仓检索作为验收。
|
||||
|
||||
## 7. 风险
|
||||
|
||||
| 风险 | 应对 |
|
||||
| :--- | :--- |
|
||||
| 迁移改坏用户数据 | 步骤 0 的写锁、只读模式与一次落盘;迁移前备份小文件;只动元数据,不动磁盘 |
|
||||
| 升级后 macOS VM 行为变化 | 每步以原有 macOS VM 做回归:恢复引导、辅助盘、引导语言、冷重启监视、Guest Tools、绑核 |
|
||||
| 特权模型改变引入越权 | "驱动对自己的 VM 拥有完整参数控制"只授予 VM 的所属驱动;`builtin.*` 的承接只允许 `official` 包或用户逐项确认;改动单独评审 |
|
||||
| `VMRef` 迁移遗漏某处按名索引的状态 | 步骤 2a 以"两台同名 VM"作为贯穿测试用例,覆盖设置、内存态、Guest Tools 与交接参数 |
|
||||
| 新旧版本混用 | 只读模式只保护新版本;降级支持的最低版本需明确公布(第 9 节) |
|
||||
| 步骤之间长期停留在半迁移状态 | 每步自成闭环、可单独发布;棘轮清单只减不增 |
|
||||
| 外部插件界面体验不及原生 | 过渡期保留原生页面;外置前以安装包页与恢复向导做可用性验收 |
|
||||
|
||||
## 8. 后续(不在本方案内)
|
||||
|
||||
触发条件出现时再立项:
|
||||
|
||||
- **稳定 VM ID**:VM 改名需要保持设置与历史、PID 复用或 CLI 超时重试出现实际问题时,引入 VM ID、一次开机的运行 ID 与一次长操作的操作 ID(参考 libvirt 的 UUID 与 containerd 将对象与运行分离的做法)。`VMRef` 届时作为人读入口保留。
|
||||
- **重新接管**:管理进程重启后重新连接正在运行的 VM,GUI 退出后 CLI 能找回同一次运行。
|
||||
- **常驻服务**:需要"GUI 退出后任务继续""多客户端订阅同一状态"或第三方程序调用时,再把生命周期模块放到用户级后台进程后,经 Windows 命名管道提供带版本的接口。
|
||||
- **整盘迁移**:换盘、换电脑做成停机导出与导入;验收为原数据目录完全不可访问时,目标机仍能从带 CoW 子盘的副本启动。
|
||||
- **升级交接**:进行中的创建、克隆、快照绑定发起时的驱动版本,运行中 VM 的控制权在重连验证后移交(参考 Magpie 插件宿主升级时的处理)。
|
||||
- **插件间安装期依赖**:出现"插件 A 必须与插件 B 一起安装"的真实用例后再设计,届时优先考虑只提示、不自动求解。
|
||||
|
||||
## 9. 待决事项
|
||||
|
||||
步骤 1 开始前需要定下:
|
||||
|
||||
1. **特权规则**:是否接受第 1 节"按角色授予特权"的规则,替代现有按 `builtin.` 前缀放行。
|
||||
2. **承接的信任要求**:承接 `builtin.*` ID 是只允许 `official` 包,还是也允许用户逐项确认。
|
||||
3. **过渡期 macOS 插件是否默认启用**:步骤 1 暂取默认启用,保证升级无感;默认关闭更贴近剥离方向,但存量用户升级后会看到"驱动不可用"。最终实现仍待评审。
|
||||
|
||||
可在后续步骤前决定:
|
||||
|
||||
4. **多运行时未选定时的行为**(步骤 3.5):建议只读操作临时使用最新安装的运行时、不写回配置,启动与创建前要求选定。
|
||||
5. **降级支持**(步骤 0 发布前):可安全退回的最低版本,以及只读模式的提示文案。
|
||||
6. **剥离范围**(步骤 5):法律风险具体涉及哪些内容(OpenCore 与 SMBIOS 处理、Apple 安装包下载、产品定位中的 macOS 字样、reims-vgpu 运行时),决定迁出清单的范围。
|
||||
7. **官方市场是否上架 macOS 插件**(步骤 5):上架方便用户,但官方索引仍与 macOS 产生关联。
|
||||
8. **代码历史**(步骤 5):只删除当前代码,还是让主程序以新仓库重新开始历史、本仓库保留为 macOS 插件仓库。
|
||||
+103
-31
@@ -1,7 +1,7 @@
|
||||
# 插件系统架构(Plugin Architecture)
|
||||
|
||||
> 状态:**核心内核、内置扩展、主题引擎、Sidecar 托管与 CLI/GUI 管理已落地**;市场远端索引与 L2 脚本层按需迭代。
|
||||
> 关联文档:[`architecture.md`](architecture.md) · [`design-guidelines.md`](design-guidelines.md) · [`portable-runtime-spec.md`](portable-runtime-spec.md) · [`patches/README.md`](../patches/README.md)
|
||||
> 关联文档:[`architecture.md`](architecture.md) · [`design-guidelines.md`](design-guidelines.md) · [`portable-runtime-spec.md`](portable-runtime-spec.md)
|
||||
|
||||
---
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
flowchart TB
|
||||
subgraph Exe["reims-go.exe(可信核心)"]
|
||||
Reg["扩展点注册表\n依赖解析 · 可逆副作用 · Reconcile"]
|
||||
Builtin["内置扩展(编译期注册)\n核心:reims 驱动 · 默认主题 · 启动准备 · 兼容补偿\n可选:宿客桥接 · 剪贴板 · 输入服务 · 窗口安装引导 · reims-vgpu 运行时种类"]
|
||||
Builtin["内置扩展(编译期注册)\n核心:默认主题\n可选:macOS 客体驱动 · 宿客桥接 · 剪贴板 · 输入服务 · reims-vgpu 运行时种类"]
|
||||
Mgr["插件管理器\n清单校验 · 事务安装 · 状态 · 安全模式"]
|
||||
Broker["Host API 代理\n权限校验 · 脱敏 · 限流 · 审计"]
|
||||
Sup["进程监管器\nJob Object · 重启退避 · 健康检查"]
|
||||
@@ -106,10 +106,11 @@ flowchart TB
|
||||
|
||||
扩展点先由内置功能使用一遍再对外开放。内置功能分两类,判断标准是用户关掉它之后,是「少了一项功能」还是「已有功能坏掉」:
|
||||
|
||||
- **核心** `builtin.core`:Reims-Go 离开它就无法运行 macOS 虚拟机的部分,包括 reims 驱动(驱动 id 仍为 `builtin.driver.reims-macos`)、默认主题(主题 id 仍为 `builtin.theme.default`)、启动准备(离线辅助盘、恢复模式引导切换、引导语言重放)与宿主兼容补偿(WHPX 降级、Win10 冷重启)。它是**系统插件**:始终启用,不能停用或卸载,插件页显示为一行「始终启用」,不参与「使用中」检查。两项兼容补偿作为核心的应用级设置保留开关,仅供排障。启动准备在同一个 `vm.beforeStart` 处理器里按固定顺序执行,引导语言重放必须在恢复模式切换(可能重建 OpenCore)之后。
|
||||
- **核心** `builtin.core`:只保留客体无关的默认主题(主题 id 为 `builtin.theme.default`)。它是**系统插件**:始终启用,不能停用或卸载,不出现在插件页与 `plugin list` 中(按 ID 查询仍可见),不参与「使用中」检查。
|
||||
- **macOS 客体插件** `builtin.guest.macos`:注册代码位于 `internal/macos/guest`,静态声明 reims 驱动(驱动 id 仍为 `builtin.driver.reims-macos`)、宿主体检、启动准备、WHPX 降级、Win10 冷重启和安装引导。它是可停用插件,过渡期默认启用以保留升级行为;有 VM 运行时不能停用,停用后宿主内的 macOS 原生页面与流程(创建、设置、Guest Tools 挂载、安装与恢复等)一并拒绝执行,直到重新启用。安装引导保留独立应用级开关。启动准备暂经 `vm.beforeStart`,下一步改由驱动自己执行,见 [guest-plugin-migration.md](guest-plugin-migration.md) 步骤 2。
|
||||
- **可选内置扩展**:Guest Tools 传输服务、剪贴板互通、宿主输入服务、虚拟机窗口安装引导。经同一注册表注册、可独立启停、停用后零残留,停用即真正停止(不被其他调用方重新拉起)。首批示例为默认开启的剪贴板互通(见 §5.4)。
|
||||
|
||||
核心由曾经拆开的七个内置插件合并而来(`builtin.RetiredIDs`)。启动时删除 `state.json` 中这些旧 ID 的记录,关闭过的兼容补偿转为对应的核心设置;启动 VM 时,参数归属账本中旧 ID 名下的片段移交给核心,继续沿用而不是被当作已卸载插件的残留剥离。
|
||||
旧版曾把 macOS 驱动、兼容补偿、安装引导与准备步骤拆成多个内置插件。数据布局 v2 的迁移删除这些旧 ID 的记录:显式设置与旧安装引导启停状态转入 `builtin.guest.macos`,参数账本中已知 macOS 条目也转给该插件;无关插件与宿主参数保持原所有者。
|
||||
|
||||
---
|
||||
|
||||
@@ -119,7 +120,8 @@ flowchart TB
|
||||
|
||||
- 每个已启用插件(含内置)拥有一个作用域,所有注册行为(提供服务、贡献扩展点、订阅事件、后台服务、Win32 钩子、QMP 监视)都登记一个释放函数;停用、卸载或升级时**逆序释放**,激活中途失败则回滚已登记项。
|
||||
- 插件声明 `requires` / `provides`(服务名 + 版本范围)。Reconcile 先关后开:先释放不再需要的插件及依赖其服务的插件,再按依赖求不动点激活。状态为 `off / pending / active / degraded / failed`。
|
||||
- **使用中不可移除**:仍有 VM 归属的驱动、仍被 VM 使用的运行时,不可停用或卸载;使用情况查询失败按「使用中」处理。
|
||||
- **使用中不可移除**:仍有 VM 归属的驱动不可卸载,仍被 VM 使用的运行时不可删除;使用情况查询失败按「使用中」处理。
|
||||
- **运行中不可停用**:驱动的 VM 只要有一台处于停止、挂起或损坏以外的状态,就不能停用其插件;状态查询失败同样拒绝。VM 都已停止或挂起时可以停用:VM 文件与挂起状态保留,显示为「驱动不可用」,不能启动、恢复或修改,重新启用后恢复。插件页停用这类插件前先弹窗说明。
|
||||
- 内置扩展通过 `pluginApi` 版本做兼容检查;激活 panic 转为 `failed` 并回滚。
|
||||
|
||||
### 4.2 扩展点目录
|
||||
@@ -128,7 +130,7 @@ flowchart TB
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| `themes`(令牌、配色方案、字体、图标、背景、提示音、样式表、状态装饰) | Builtin · L1 | 按 id,同一时刻仅一个主题包生效 | 回退内置默认主题 |
|
||||
| `uiScripts`(交互主题脚本) | 主窗口受信任脚本 | 随所属主题包 | 单个功能出错只停用该功能;整体失败回退到无脚本的主题 |
|
||||
| `locales`(多语种语言包:`locale` / `label` / `fallback` / `file` / `backendFile` / `messages` / `backend`) | Builtin · L1(纯 JSON,免高危权限) | 按 BCP-47 语种合并,自动出现在设置语言下拉框 | 缺失词条回退 `fallback` / 内置英语;停用插件后自动回退内置语言 |
|
||||
| `locales`(声明式语言包:分域 `files`、可选包内 `.woff2` 字体、`pluginOverrides` 跨插件翻译覆盖) | Builtin · L1(纯 JSON + WOFF2,免高危权限) | 按 BCP-47 语种与信任等级合并,覆盖 GUI、Win32 浮层、托盘与 CLI | 缺失词条沿有界多跳 `fallback` 链回退至内置语种;单条坏模板自动回退不崩宿主 |
|
||||
| `inputFilters` | Builtin · L1(仅声明式规则) | 有序列表 | 规则非法即忽略;宿主输入服务异常时卸载钩子、放行原始输入 |
|
||||
| `vmTemplates` | Builtin · L1 | 列表 | 跳过非法项 |
|
||||
| `runtimeSources` | Builtin · L1 | 列表 | 跳过该源,回退其他源 |
|
||||
@@ -137,10 +139,11 @@ flowchart TB
|
||||
| `hooks` | Builtin · L1 · L2 · L3 | 有序列表 | 按事件模式(§4.3) |
|
||||
| `commands` | Builtin · L2 · L3 | 按 id | 报错并提示 |
|
||||
| `menus` / `vmCards` / `settingsPages` / `statusItems` | 声明式 | 列表,设数量上限 | 隐藏该项 |
|
||||
| `panels` | L4 iframe | 限定槽位 | 错误占位 + 重试 |
|
||||
| `panels` | L4 iframe,嵌在槽位内 | 限定槽位,限高 | 错误占位 + 重试 |
|
||||
| `views` | L4 iframe,整页或标签页(§5.6) | 按位置设数量上限 | 错误页 + 重试;不影响其他视图 |
|
||||
| `diagnostics` | Builtin · L3 | 列表 | 跳过;输出强制脱敏 |
|
||||
|
||||
UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`、`settings.plugin`,后续按真实需求再增加 `sidebar.footer`、`statusbar.right`、`create.source`;插件只能向已声明槽位贡献。
|
||||
UI 槽位采用「声明即占有」:插件只能向宿主槽位目录(§5.1)中的槽位贡献。目录中的每个槽位、每种视图位置都必须由宿主实际渲染,前端构建检查覆盖这一点;不能出现可以声明、界面上却不显示的位置(§6.3)。
|
||||
|
||||
### 4.3 Hook 事件与分发模式
|
||||
|
||||
@@ -185,11 +188,14 @@ UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`
|
||||
| 契约 | 内容 |
|
||||
| :--- | :--- |
|
||||
| 设计令牌 | 单一来源(令牌数据同时生成 CSS 变量与前端常量),覆盖颜色、字体排印、形状、阴影、动效时长与缓动、层级;动效档位(含系统「减少动态效果」)在一处解析为文档属性,样式与脚本读同一个值 |
|
||||
| 部件 | 关键区域与控件挂稳定的部件类名(如 `rg-p-sidebar`、`rg-p-vm-header`、`rg-p-statusbar`),每个部件一个独立类名,便于浏览器按类名分桶匹配;主题选择器只允许使用部件、状态属性与令牌,不得依赖内部类名或界面文字 |
|
||||
| 状态属性 | 文档与区域上的只读状态:外观、当前视图、VM 显示状态、忙碌态、是否有错误、侧栏折叠 |
|
||||
| 槽位锚点 | 装饰与扩展内容的挂载点(如侧栏底部、VM 预览四角、状态栏、空状态区) |
|
||||
| 部件 | 区域与控件挂稳定的部件类名,每个部件一个独立类名,便于浏览器按类名分桶匹配;主题选择器只允许使用部件、状态属性与令牌,不得依赖内部类名或界面文字。区域级:`rg-p-shell`、`rg-p-titlebar`、`rg-p-sidebar`、`rg-p-nav`、`rg-p-main`、`rg-p-vm-page`、`rg-p-statusbar`、`rg-p-logpanel`、`rg-p-settings` 等;控件级:`rg-p-nav-group`、`rg-p-nav-item`、`rg-p-button`、`rg-p-icon-button`、`rg-p-card`、`rg-p-badge`、`rg-p-tabs`、`rg-p-tab`、`rg-p-menu`、`rg-p-menu-item`、`rg-p-dialog`、`rg-p-toast`、`rg-p-tooltip`、`rg-p-input`、`rg-p-switch`、`rg-p-progress`、`rg-p-vm-actions`、`rg-p-plugin-view` |
|
||||
| 状态属性 | 文档级只读状态:外观、动效档位、语种与书写方向、当前视图、侧栏折叠、安全模式、布局选项;逐项状态:导航项与 VM 区域带 `data-vm-state`、`data-driver`、`data-selected`、`data-busy`,按钮带 `data-variant`、`data-busy`,对话框与提示条带 `data-tone`。主题可据此为单个 VM 条目做动效,不必解析界面文字 |
|
||||
| 槽位目录 | 每个槽位声明上限与可挂内容(装饰、SDK 挂载、`panels`、`menus`、`statusItems`):`titlebar.center`、`sidebar.header`、`sidebar.footer`、`nav.item.trailing`(逐个 VM 条目)、`vm.header.trailing`、`vm.toolbar`、`vm.card`、`vm.preview.tl/tr/bl/br`、`statusbar.left`、`statusbar.right`、`empty.state`、`create.source`、`settings.plugin` |
|
||||
| 图层 | 全窗口背景层 `layer.background` 与前景装饰层 `layer.overlay`:不拦截指针、不参与焦点,「减少动态效果」时停播动画;用于动态壁纸、粒子与满屏吉祥物 |
|
||||
| 布局选项 | 主题清单的 `layout` 声明:侧栏位置(左/右)、侧栏形态(完整/图标窄栏/悬浮)、密度(紧凑/常规/宽松)、标题栏样式。只改摆放与尺寸,不能隐藏操作入口 |
|
||||
| 图标 | 宿主公开图标名清单(如 `start`、`stop`、`settings`、`plugin`、`vm.state.running`);主题以 `icons` 映射到包内单色 SVG,宿主按令牌着色 |
|
||||
|
||||
契约内的部件、状态属性与令牌的重命名或删除属于 `uiApi` 主版本变更;前端构建检查契约中的每个部件仍由某个组件输出。
|
||||
契约内的部件、状态属性、槽位、图层、布局选项、图标名与令牌的重命名或删除属于 `uiApi` 主版本变更;前端构建检查契约中的每个部件、槽位与图层都由某个组件输出(§6.3)。
|
||||
|
||||
**三档主题能力**
|
||||
|
||||
@@ -203,8 +209,10 @@ UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`
|
||||
|
||||
- 生命周期:主题脚本导出装载函数,所有订阅、计时器与挂载都登记释放函数;切换或停用主题时逆序拆除,单个功能抛错不影响其余功能。
|
||||
- 只读状态订阅:非敏感的 VM 摘要、任务进度、当前视图、外观;不提供原始路径与敏感字段。
|
||||
- 事件流:VM 状态变化(含过渡态)、任务开始/进度/结束、提示条出现、视图切换,供主题做转场动画,不必轮询状态。
|
||||
- 宿主提供的页面观察总线、帧读写管线与按部件查询:主题不自建节点观察者,也不整页查询文档。
|
||||
- 槽位挂载:框架无关的 DOM 挂载,不共享宿主的 React 实例,避免随宿主依赖升级断裂。
|
||||
- 槽位挂载:框架无关的 DOM 挂载,不共享宿主的 React 实例,避免随宿主依赖升级断裂。按 VM 重复的槽位(`nav.item.trailing`)以 VM 引用为键挂载;全窗口图层另有专用挂载;按部件查询可取回重复部件的全部实例。
|
||||
- 声明式装饰与 SDK 挂载共用同一批槽位与图层;重复槽位里的装饰按所在 VM 自身的状态匹配。
|
||||
- 受限动作:仅开放非破坏性界面动作(折叠侧栏、打开设置、前置 VM 窗口等);启停、删除、配置写入不在 SDK 中。
|
||||
- 主题设置:由 `settings` Schema 定义,宿主渲染设置页。
|
||||
|
||||
@@ -214,7 +222,8 @@ UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`
|
||||
- 样式清洗:禁止外部 `url()` 与远程 `@import`,资源只能引用包内清单中的文件;窗口拖拽区、焦点环与最小点击热区等可用性属性由宿主在更高层保留,不被主题覆盖。
|
||||
- 同一时刻只启用一个主题包,切换时先停用旧主题再装载新主题;安全模式一律回到内置主题。
|
||||
- 首帧前按当前主题内联令牌防闪烁;无边框窗口的标题栏由前端绘制,可随主题变化。
|
||||
- 主题只改视觉与交互呈现,不改文案、信息层级与操作入口([`design-guidelines.md`](design-guidelines.md) 的主操作与破坏性操作约束由宿主守住)。
|
||||
- 主题只改视觉与交互呈现,不改文案、信息层级与操作入口([`design-guidelines.md`](design-guidelines.md) 的主操作与破坏性操作约束由宿主守住)。布局选项可以挪动区域、改变侧栏形态,但 VM 列表、新建、设置与插件入口始终可达。
|
||||
- 主题不提供功能页面;需要自有界面的插件走 §5.6 的视图,不经 `ui:script`。
|
||||
- 需要读写用户文件或常驻服务的主题,以同包 L3 Sidecar 实现。
|
||||
- 开发支持:`reims-go plugin link` 链接本地目录并热重载;`reims-go plugin doctor` 校验样式只使用契约内的部件、状态属性与令牌。
|
||||
|
||||
@@ -228,16 +237,17 @@ UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`
|
||||
|
||||
### 5.3 非 macOS 虚拟机(客体驱动,L3)
|
||||
|
||||
**驱动抽象**:当前 `internal/app`、`internal/vmstart`、`internal/cli` 直接依赖 `internal/driver/reims` 的具体类型。抽象后:
|
||||
**驱动抽象**:当前 `internal/app`、`internal/vmstart`、`internal/cli` 直接依赖 `internal/macos/reims` 的具体类型。抽象后:
|
||||
|
||||
| 层 | 内容 |
|
||||
| :--- | :--- |
|
||||
| 通用 VM 模型 | 驱动 id + 名称、状态(`stopped / running / broken` 与过渡态)、CPU / 内存 / 磁盘摘要、目录、能力位 |
|
||||
| 驱动专有数据 | 不透明扩展字段 + 驱动提供的创建/设置 JSON Schema(宿主原生渲染,标注生效时机) |
|
||||
| 能力位 | `snapshot`、`cow_clone`、`resize`、`qmp`、`ssh`、`guest_tools`、`affinity`、`opencore`、`recovery`、`cloud_init`、`uefi_iso` 等;UI 与 CLI 按能力位显隐操作 |
|
||||
| 驱动动作 | `List / Show / ValidateCreate / Create / ValidateSet / Set / Start / Stop / Delete`,可选快照、派生、扩容与通用 `InvokeAction` |
|
||||
| 驱动动作 | `List / Show / ValidateCreate / Create / ValidateSet / Set / Start / Stop / Delete`,可选 `SnapshotDriver`、`CloneDriver`、`DiskDriver` 与通用 `InvokeAction`;存储调用由生命周期先解析 `VMRef`,结果使用 `driver.DiskSnapshot / DiskResizeResult / DiskCompactResult` |
|
||||
|
||||
- **VM 归属**:VM 目录内标记文件记录驱动 id;无标记的存量 VM 自动归属 `builtin.driver.reims-macos`,零迁移。CLI 增加 `vm create --driver <id>`,其余 `vm` 子命令按归属自动路由。
|
||||
- **VM 归属**:VM 目录内的标记文件 `.reims-go-driver` 记录驱动 id;无标记的存量 VM 归属 `builtin.driver.reims-macos`,并由数据迁移补写标记([architecture.md](architecture.md) §4.7)。有标记的 VM 在其驱动缺席时仍以「驱动不可用」列出。驱动迁到另一个插件、id 随之改变时(市场插件不能使用 `builtin.` 前缀),在 `driver.RenamedDriverIDs` 登记旧 id 到新 id 的映射;标记文件不改写,降级后旧版本仍能识别。CLI 增加 `vm create --driver <id>`,其余 `vm` 子命令按归属自动路由。
|
||||
- **VM 引用与根目录**:`driver.VMRef{DriverID, Name}` 的规范键为 `driverID:vmName`;`Router.ListAllVMs` 按完整引用去重,裸名称解析遇到跨驱动同名时返回歧义错误,调用方须显式指定驱动。每个 `guestDrivers` 条目用 `vmRoots` 声明相对 `<DataRoot>` 的斜杠路径,绝对路径、反斜杠与 `..` 均被拒绝;路由遍历所有已声明根(包括停用驱动)以保留「驱动不可用」条目。按 VM 的插件设置也以规范键持久化。
|
||||
- **宿主共享服务**(驱动经反向调用复用):体检报告、提交内存预检、大小核绑核、QMP 截屏与键入、缩略图、Guest Tools 注册、进程退出监视、任务进度、日志通道、托盘菜单。
|
||||
- **VM 进程归宿主托管**:驱动不直接派生 QEMU,而是请求宿主代为启动并返回 PID。这样 VM 进程不随驱动进程的 Job Object 被回收(驱动崩溃或重启不误杀 VM),绑核、退出监视与冷重启补偿也只在宿主实现一份。
|
||||
- **配置写入**:`reims-ctl set` 铁律约束 reims 管理的 VM;Linux 驱动自管配置文件,同样不允许 UI 拼接原始命令行。
|
||||
@@ -269,17 +279,57 @@ UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`
|
||||
| :--- | :--- | :--- |
|
||||
| `builtin.bridge.guest-tools` | `internal/guesttools`、`guesttools_flow.go` | 提供传输服务 + `vm.beforeStart`(注入桥接参数与环境变量)+ `vm.afterStart` + `vm.card`;共享文件夹、盘符共享、防休眠逐步拆为功能扩展 |
|
||||
| `builtin.input` | `host/ime_hook_windows.go` | 提供输入服务与 `inputFilters`;IME 桥成为其上的功能,停用时卸载钩子线程 |
|
||||
| `builtin.install-guide` | `internal/installguide`、`internal/app/install_guide.go` | 提供 `ui.install-guide` 服务 + `vm.afterStop` / `vm.deleted` 观察钩子;在虚拟机窗口悬浮展示安装与恢复引导,停用时立即关闭全部浮层并回退主界面恢复卡片 |
|
||||
| `builtin.core`(系统插件) | `driver/reims_adapter.go`、`vmstart.Prepare` 各步骤、`app.go` 冷重启监视 | `guestDrivers` + `themes` + `host.preflight` + 一个按序执行全部启动准备的 `vm.beforeStart`(离线辅助盘 → 恢复模式引导 → 引导语言 → WHPX 降级 → Win10 冷重启)+ `vm.afterStart` / `vm.afterStop`(冷重启监视);设置 `whpx_fallback`、`win10_cold_reboot` |
|
||||
| `builtin.guest.macos` | `internal/macos/guest`、`internal/macos/installguide`、`macosdriver`、`vmstart.Prepare` 各步骤 | 静态 `guestDrivers` + `host.preflight` + 驱动内启动准备与冷重启意图 + 条件提供的 `ui.install-guide` 服务;设置 `install_guide`、`whpx_fallback`、`win10_cold_reboot` |
|
||||
| `builtin.core`(系统插件) | `internal/plugin/builtin/core.go` | `themes`:默认主题 |
|
||||
|
||||
> 下一步:Guest Tools 的 macOS 客体代理与辅助盘镜像迁入 macOS 插件,传输服务留在宿主;启动准备改由驱动自己执行。见 [guest-plugin-migration.md](guest-plugin-migration.md) 步骤 2。
|
||||
|
||||
### 5.5 与上游补丁队列的边界
|
||||
|
||||
| 类别 | 归属 | 原则 |
|
||||
| :--- | :--- | :--- |
|
||||
| 引擎内部崩溃与 Hypervisor 层修复(WHPX 兼容、协程、构建锁文件等) | [`patches/`](../patches/)(编译期) | 外部插件无法等价替代;坚持上游 PR,合入即退役 |
|
||||
| 引擎内部崩溃与 Hypervisor 层修复(WHPX 兼容、协程、构建锁文件等) | [运行时源码与补丁](https://github.com/yxc0915/reims-vgpu/blob/master/packaging/windows-runtime/patches/README.md)(编译期) | 外部插件无法等价替代,修复交由运行时仓库维护 |
|
||||
| 窗口内部消息循环拦截(如 SDL 窗口内字符消息) | `patches/`,宿主侧做部分补偿 | 跨进程拦截需 DLL 注入,杀软误报风险高,不做成插件 |
|
||||
| 宿主侧绕过、兜底补偿与宿客桥接 | 内置扩展(§5.4) | 运行时缺少对应补丁时平滑降级;依据运行时 `capabilities` 判断 |
|
||||
|
||||
### 5.6 插件自有界面
|
||||
|
||||
插件需要界面时按以下顺序选择形式,能用前一种就不用后一种:
|
||||
|
||||
| 形式 | 适用 | 渲染与信任 |
|
||||
| :--- | :--- | :--- |
|
||||
| **声明式界面** | 应用与按 VM 设置、VM 卡片信息、工具栏按钮与菜单、状态栏项、通知、确认框、表单对话框、任务进度 | 宿主原生渲染,自动跟随主题、语种、键盘操作与无障碍;只需低、中危权限 |
|
||||
| **视图(`views`)与面板(`panels`)** | 自定义可视化、控制台、多步向导、需要自绘交互的页面 | 沙箱 iframe(不透明源),只经插件界面桥(bridge)与宿主通信,能力由权限约束 |
|
||||
| **交互主题脚本** | 仅限主题的视觉与交互增强 | 主窗口受信任脚本(`ui:script`);功能插件不得使用 |
|
||||
|
||||
**视图位置**(`views[].location`;面板仍按槽位嵌入,限高):
|
||||
|
||||
| 位置 | 呈现 | 上限 |
|
||||
| :--- | :--- | :--- |
|
||||
| `sidebar` | 侧栏「扩展」分组中的导航项,点击后在主区域整页打开;导航项的图标、标题、角标与选中态由宿主绘制 | 每插件 2 个;超出部分折叠进「更多」 |
|
||||
| `vm.tab` | VM 页内的标签页;以 `when` 限定驱动或能力位(如只对某驱动的 VM 显示控制台) | 每个 VM 页 4 个 |
|
||||
| `settings` | 设置中的独立分节,用于放不进 Schema 表单的复杂设置 | 每插件 1 个 |
|
||||
| `dialog` | 不常驻;由命令或 bridge 的 `ui.openView` 以模态打开,可返回结果 | 同一时刻 1 个 |
|
||||
|
||||
视图字段:`id`、`title`、`icon`(包内单色 SVG,宿主按令牌着色)、`location`、`entry`(包内 HTML)、`order`、`when`、`minWidth`。宿主负责外框:标题、返回、加载与错误占位、重试、尺寸、焦点进出与快捷键。视图惰性加载;同一时刻保持存活的视图有上限,切走的视图超过上限即卸载,插件停用时全部卸载。
|
||||
|
||||
**插件界面桥(`bridgeApi` 1.0)**:iframe 与宿主之间的请求/响应与事件消息,宿主只应答来源窗口为该 iframe 的消息,每个方法在 Go 侧按权限二次校验并限流。
|
||||
|
||||
| 命名空间 | 方法与事件 | 权限 |
|
||||
| :--- | :--- | :--- |
|
||||
| 握手 | `hello`:返回 `bridgeApi`、`features`、语种与书写方向、完整契约令牌、视图上下文(位置、所在 VM 的 `VMRef`) | 无 |
|
||||
| `ui` | `notify`、`confirm`(宿主原生确认框)、`showForm`(以 Schema 弹出原生表单并返回值)、`setTitle`、`setBadge`、`openView`、`close`(`dialog` 返回结果)、`navigate`(只限宿主路由白名单)、`openExternal`(宿主确认后用系统浏览器打开) | `ui:notify` / `ui:slot` |
|
||||
| `vm` | `list`、`get`(通用 VM 模型,不含敏感字段);事件 `vm.stateChanged` | `vm:read` |
|
||||
| `command` | `invoke`:只能调用本插件声明的命令;VM 启停等动作由命令处理方经 `vm:control` 执行 | `ui:slot` |
|
||||
| `settings` | 读写本插件的应用级与按 VM 设置 | 无(限本插件) |
|
||||
| `storage` | 本插件私有键值存储,位于 `data/<id>/`,有配额 | `fs:plugin_data` |
|
||||
| `file` | `pick` / `save` 弹出宿主文件对话框,只返回不透明句柄;按句柄分块读写,不暴露路径 | `fs:pick` |
|
||||
| `task` | 开始、更新、结束任务;在宿主任务区显示进度并可取消 | `task:progress` |
|
||||
| `net` | `fetch` 经宿主代理发出(iframe 自身 `connect-src 'none'`) | `net:<origin>` |
|
||||
| `events` | 订阅主题与语种变化、视图可见性、任务事件 | 无 |
|
||||
|
||||
大对象分块传输,单条消息设大小上限。宿主以 `/plugin-ui-kit/<uiApi>/` 提供界面套件(令牌样式表与常用控件样式),主题或语种变化时经 bridge 推送新令牌,插件界面因此与宿主外观一致,不必自带一套设计系统。
|
||||
|
||||
---
|
||||
|
||||
## 6. 插件包与清单
|
||||
@@ -302,9 +352,10 @@ UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`
|
||||
| :--- | :--- |
|
||||
| `schema` | 清单格式版本 |
|
||||
| `id` / `version` | 反向域名 id;SemVer |
|
||||
| `name` / `description` | `zh-CN` / `en-US` 本地化文本,**无需执行插件代码即可读取** |
|
||||
| `name` / `description` | 多语种本地化文本(内置 `zh-CN` / `en-US` 及任意 BCP-47 扩展键),**无需执行插件代码即可读取** |
|
||||
| `l10n` | 可选的包内私有词表目录(如 `"locales"`),存放 `<locale>.json` 供插件自身 UI、iframe 面板与 Sidecar 使用;独立语言包可通过 `pluginOverrides` 在外部补充或覆盖任意第三方插件的清单字段与私有词条 |
|
||||
| `publisher` / `license` / `homepage` | 来源与许可,市场审核依据 |
|
||||
| `engines` | `reims-go` 版本范围与 `pluginApi` 范围,**下载前预检** |
|
||||
| `engines` | `reims-go` 版本范围,以及所依赖契约面的范围:`pluginApi`、`uiApi`(主题与面板样式)、`bridgeApi`(视图与面板);**下载前与激活前预检**(§6.3) |
|
||||
| `platforms` | 如 `windows-x64` |
|
||||
| `entry` | Sidecar 可执行文件、脚本文件、面板 HTML 根目录;层级由内容推导,不信任自报 |
|
||||
| `contributes` | 各扩展点贡献(§4.2) |
|
||||
@@ -315,6 +366,24 @@ UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`
|
||||
| `defaultEnabled` | 安装或首次启动时的默认启用状态;仅内置扩展与随主程序附带的插件可为 `true` |
|
||||
| `provenance` | **运行时包必填**:上游仓库与 commit、补丁清单与哈希、源码包文件名 |
|
||||
|
||||
### 6.3 契约版本与演进规则
|
||||
|
||||
公开契约分三个版本面,各自按 SemVer 演进,插件在 `engines` 中声明依赖范围:
|
||||
|
||||
| 版本面 | 范围 |
|
||||
| :--- | :--- |
|
||||
| `pluginApi` | 清单字段、扩展点、Hook 事件与载荷、权限名、Sidecar JSON-RPC 协议 |
|
||||
| `uiApi` | 主题可依赖的界面契约:令牌、部件、状态属性、槽位目录、图层、布局选项、图标名、UI SDK |
|
||||
| `bridgeApi` | 视图与面板的消息协议(§5.6) |
|
||||
|
||||
- **契约先于生态定全**:扩展点、槽位目录、视图位置与 bridge 方法在第三方插件依赖它们之前一次定全。目前生态只有语言包(只依赖 `pluginApi`),`uiApi` 与 `bridgeApi` 在首个第三方主题或界面插件出现前定稿为 `uiApi` 2.0 与 `bridgeApi` 1.0,定稿前可做不兼容清理。
|
||||
- **公开即实现**:每个公开的扩展点、槽位、视图位置、图层与 bridge 方法在发布前都要有宿主实现和契约测试。前端构建检查每个槽位、视图位置与图层都被渲染;Go 测试检查每个扩展点都有消费者。尚未落地的项标为实验性:清单校验接受它,`plugin doctor` 警告,不受兼容承诺约束,市场不允许稳定版插件依赖它;某项在实现它的同一次变更中转为稳定。哪些项仍是实验性,以契约文件为准:`frontend/src/styles/ui-contract.ts`、`frontend/src/lib/bridgeContract.ts` 与 `internal/plugin/contract.go`(构建产物 `ui-contract.json`、`bridge-contract.json` 中的 `experimental` 部分),Go 测试保证三者一致,新增的 `contributes` 字段必须先在目录中登记状态。
|
||||
- **主版本内只增不改**:新增字段一律可选,缺省时保持旧行为;新增枚举值(事件、视图位置、bridge 方法)只投递给声明了相应次版本的插件。改名、删除或改变语义只在主版本发生。
|
||||
- **按特性协商,不按版本号猜**:宿主在 Sidecar 握手、bridge 握手与 UI SDK 中下发 `features` 列表(如 `view.sidebar`、`bridge.file.pick`、`layer.overlay`),插件据此降级。
|
||||
- **未知字段**:宿主忽略清单中的未知字段并由 `plugin doctor` 警告,插件因此可以使用新字段同时兼容旧宿主;`engines` 下限高于宿主版本时拒绝安装与激活。
|
||||
- **命名空间**:`builtin.*` 插件 id、`rg-` 前缀的类名、`data-rg-` 属性与契约令牌归宿主;主题自定义的 CSS 变量使用 `--theme-` 前缀(视图与面板在各自 iframe 内,不受此限);命令 id 由宿主自动加上插件 id 前缀。
|
||||
- **弃用**:先在至少一个次版本中给出 `plugin doctor` 警告与替代项,下一个主版本再删除;契约文件(`ui-contract.json`、bridge 类型定义)随版本发布,作者可在本地校验。
|
||||
|
||||
---
|
||||
|
||||
## 7. 权限、信任与安全边界
|
||||
@@ -324,27 +393,28 @@ UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`
|
||||
| 等级 | 权限 | 审批 |
|
||||
| :--- | :--- | :--- |
|
||||
| **低** | `vm:read`(通用模型,不含敏感字段)、`ui:notify`、`task:progress`、`fs:plugin_data`、`log:read` | 启用时展示说明 |
|
||||
| **中** | `vm:intent`、`runtime:source`、`net:<origin>`(经宿主代理发出)、`ui:slot`、`input:filter`(声明输入过滤规则) | 首次启用逐项确认 |
|
||||
| **中** | `vm:intent`、`runtime:source`、`net:<origin>`(经宿主代理发出)、`ui:slot`、`input:filter`(声明输入过滤规则)、`fs:pick`(经宿主文件对话框读写用户选中的文件) | 首次启用逐项确认 |
|
||||
| **高** | `driver:vm`、`runtime:provider`、`process:spawn`、`vm:control`、`qmp:write`、`fs:vm_dir`、`fs:shared`、`host:clipboard`、`ui:script` | 强提示(展示可执行文件或脚本路径、SHA-256、发布者、许可证)并显式勾选;升级新增高危权限时暂停并要求重新批准 |
|
||||
| **不存在** | 敏感字段读取、UAC 提权、重启 Windows、直写 `vm.toml` | 插件只能请求宿主发起人工确认流程 |
|
||||
|
||||
### 7.2 如实声明的信任边界
|
||||
|
||||
- L1、L2、L4 的权限由宿主强制。**L3 是原生代码,OS 层面无法约束**,权限只约束其对 Host API 的访问;安装与启用 L3 插件时明确告知「此插件能以你的账户身份执行任意操作」。
|
||||
- 信任等级:`official`(官方密钥签名)、`verified`(审核 + 发布者签名)、`community`(仅哈希)、`dev`(本地链接,需开启开发者模式)。`community` 级 L3 插件默认不可启用,需二次确认。
|
||||
- 信任等级:`official`、`verified`、`community`、`dev`(本地链接,需开启开发者模式)。`official` / `verified` 有两个来源:一是包内 ed25519 签名与内置密钥匹配;二是包从项目自有市场索引安装,该索引在本次会话经 HTTPS 从内置地址拉取(非过期缓存),且包的 SHA-256 与索引条目一致,此时沿用索引标注的等级。经 `REIMS_GO_PLUGIN_MARKET_URL` 指向的第三方索引不能担保信任,其条目在市场中一律显示为 `community`。其余情况为 `community`(仅哈希)。
|
||||
- 信任等级只用于标识来源,不豁免任何检查:所有安装包(含 `official`)都走同一套静态安全扫描、高危权限审批与 L3 可执行文件哈希确认;只有内置与随主程序附带的插件预先批准。
|
||||
- 以 AppContainer 或低完整性级别运行 Sidecar 作为后续增强项评估。
|
||||
|
||||
### 7.3 UI 与本地接口安全
|
||||
|
||||
- 插件资源经 Wails AssetServer 的独立路由提供,路径带每次运行随机生成的令牌,校验目录穿越,附 `X-Content-Type-Options: nosniff` 与 CSP;SVG 一律禁脚本。
|
||||
- iframe 面板(后置):`sandbox="allow-scripts"`、`connect-src 'none'`;bridge 只应答来源窗口为自身 iframe 的消息,所有读取在 Go 侧按 `permissions` 二次校验并限流;主题令牌经 bridge 下发。
|
||||
- iframe 视图与面板:`sandbox="allow-scripts"`(不加 `allow-same-origin`、`allow-popups`、`allow-top-navigation`)、`connect-src 'none'`;bridge 只应答来源窗口为自身 iframe 的消息,所有读写在 Go 侧按 `permissions` 二次校验并限流;文件只以句柄交换,网络只经宿主代理;主题令牌经 bridge 下发。
|
||||
- 宿主本地 HTTP 接口(如 Guest Tools)拒绝 `Origin: null`、跨站请求与 `Sec-Fetch-Dest: iframe` 请求,防止被沙箱 iframe 或外部网页借道调用。
|
||||
|
||||
---
|
||||
|
||||
## 8. 进程监管与通信协议
|
||||
|
||||
- **协议**:stdin/stdout 双向 JSON-RPC 2.0,采用 `Content-Length` 分帧(LSP 风格);握手交换 `pluginApi` 版本与能力;stdout 只走协议帧,日志一律走 stderr 并由宿主采集。截图、磁盘镜像等大对象不进 JSON,经插件数据目录内的文件路径传递。
|
||||
- **协议**:stdin/stdout 双向 JSON-RPC 2.0,采用 `Content-Length` 分帧(LSP 风格);握手交换 `pluginApi` 版本、能力、当前生效语种(`locale` / `fallbackChain`)及合并后的插件私有词表(`l10nBundle`),运行期切换界面语言时向已运行 Sidecar 广播 `plugin/localeChanged` 通知(不唤醒休眠进程);stdout 只走协议帧,日志一律走 stderr 并由宿主采集。截图、磁盘镜像等大对象不进 JSON,经插件数据目录内的文件路径传递。
|
||||
- **进程模型**:每个 L3 插件独立进程;全部放入设置 `JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE` 的 Job Object,宿主退出或崩溃时进程树一并回收;L2 脚本宿主额外设置进程内存与 CPU 时间上限。
|
||||
- **健壮性**:单写协程 + 有界队列提供背压;所有请求可取消;回收依据进程句柄而非管道 EOF;子进程不继承协议管道,工作目录固定为 `data/<id>/`;崩溃后指数退避重启,连续失败熔断为 `failed`;升级与配置变更采用「先起新进程、旧进程处理完在途请求再退出」。
|
||||
- **惰性与回收**:按 `activation` 惰性拉起;空闲超时回收;托盘常驻模式下只保留有活动 VM 或后台服务的 Sidecar。
|
||||
@@ -377,8 +447,8 @@ UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`
|
||||
|
||||
- **安装来源**:本地包导入(首批)、市场索引(后续)、开发者模式本地目录链接。
|
||||
- **随主程序附带的插件**:需要时可以标准插件包形式嵌入 `reims-go.exe`,信任等级为 `official`,版本跟随主程序;可启用/停用,不可卸载。
|
||||
- **事务安装**:下载到 `tmp` → 校验 `SHA256SUMS` 与签名 → 核对包内 `id` / `version` 与预期一致(防偷换)→ 兼容预检 → 原子 rename 到 `pkgs/<id>/<version>` → 提交 `state.json`。任一步失败都不改变现状。
|
||||
- **市场索引**:独立仓库发布静态 `index.json`(GitHub 主源 + GitCode 镜像,复用运行时下载源的回退与代理逻辑),含版本、`engines`、下载地址、SHA-256 与签名者;主程序内嵌兜底副本。
|
||||
- **事务安装与静态准入门禁**:下载到 `tmp` → 校验 `SHA256SUMS` 与签名 → 核对包内 `id` / `version` 与预期一致(防偷换)→ 兼容预检 → 静态安全门禁(拦截 L1/L4 夹带可执行/系统脚本、L3 未声明二进制、SVG 主动脚本、`ui:script` 宿主逃逸或未声明联网、市场红线)→ 原子 rename 到 `pkgs/<id>/<version>` → 提交 `state.json`。任一步失败都不改变现状。对 L3 原生程序不声称“代码扫描安全”,仅核对清单完整性与 SHA-256 并向用户如实展示完整当前 Windows 账户权限说明。
|
||||
- **市场索引与软撤回**:独立仓库发布轻量静态 `index.json`(二进制包托管在 GitHub Releases,复用运行时下载与代理逻辑;可通过 `REIMS_GO_PLUGIN_MARKET_URL` 配置镜像或 `off` 强制离线),含版本、`engines`、`platforms`、下载地址、SHA-256、签名者与软撤回列表(`withdrawn`,阻止新装并对存量用户展示替代建议);首次打开市场或执行市场 CLI 命令时惰性拉取;唯一例外是首次启动设置页:系统语言不被内置 zh-CN / en-US 覆盖时,按系统语言查一次索引,若有匹配的语言包,就在设置页提供「同时安装」选项(默认勾选,选好数据目录后安装并启用)。索引条目可用 `locales` 显式声明语言包提供的语言,未声明时按标签与名称译文推断。使用内存 + `<DataRoot>/plugins/index-cache.json` 双层缓存与主程序内嵌兜底副本,网络失败不覆写有效缓存。
|
||||
- **更新与回滚**:新旧版本并存、切换指针,保留最近若干版本;插件同样区分 `alpha` / `stable` 通道,默认只取 `stable`。
|
||||
- **安全模式**:`reims-go --safe-mode` 跳过全部第三方插件,界面顶部显示横幅与插件管理入口;以启动哨兵文件检测上次插件初始化阶段异常退出,下次启动询问是否进入安全模式。
|
||||
- **市场红线**:拒收含 Apple 专有文件、SMBIOS 真值或闭源固件的包;运行时包必须附源码与许可证。
|
||||
@@ -389,8 +459,8 @@ UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`
|
||||
|
||||
| 入口 | 内容 |
|
||||
| :--- | :--- |
|
||||
| CLI | `reims-go plugin list / install / link <dir> / enable [--approve-high-risk] / disable / remove [--purge] / info / doctor / run <id> <command>`;`vm create --driver <id>` |
|
||||
| 应用设置 → 插件 | 分组展示内置插件与第三方插件:核心置顶、显示「始终启用」且无开关;其余显示来源与信任标签、权限摘要、启用开关、故障状态与日志入口;本地包导入 |
|
||||
| CLI | `reims-go plugin list / search / install <zip\|id> / update [id] / pack <dir> / link <dir> / enable [--approve-high-risk] / disable / remove [--purge] / info / doctor [--json] [dir\|zip\|id] / locale <init\|check> / run <id> <command>`;`vm create --driver <id>` |
|
||||
| 应用设置 → 插件 | 提供「已安装 / 插件市场」双视图(市场索引惰性加载):系统插件(核心)不列出;其余显示来源与信任标签、权限摘要、安全扫描报告入口、启用开关、故障状态与日志入口;本地包导入前先展示三段式静态安全报告并执行硬门禁拦截 |
|
||||
| 插件设置页 | 由 `settings` Schema 渲染,复用现有设置控件,标注生效时机 |
|
||||
| VM 页面 | 按能力位显隐操作;`vm.toolbar` 菜单项支持 `when` 条件;`vm.card` 展示驱动或插件提供的键值信息 |
|
||||
| 创建向导 | 先选驱动,再按驱动 `CreateSchema` 渲染专属表单 |
|
||||
@@ -418,6 +488,8 @@ UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`
|
||||
|
||||
## 12. 分阶段演进与验收标准
|
||||
|
||||
从现有代码走到这里所述的客体驱动形态、并将 macOS 外置为插件的具体路径,见 [guest-plugin-migration.md](guest-plugin-migration.md)。
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
P0["Phase 0\n内部抽象\n(不对外)"] --> P1["Phase 1\n插件底座 + L1\n(主题/模板/运行时源/规则 Hook)"]
|
||||
@@ -434,7 +506,7 @@ flowchart LR
|
||||
| **Phase 2** | 运行时种类注册表、`runtime_api` 与 `capabilities`、来源展示 | 第二种运行时与官方运行时并存切换;不兼容组合被拦截并给出提示 |
|
||||
| **Phase 3** | JSON-RPC 协议 v1、进程监管、反向 Host API、权限审批、代码 Hook、插件命令、排障采集、轻量 Go SDK | 死循环或崩溃的示例 Sidecar 不影响主窗口与运行中 VM;退出或禁用后无孤儿进程 |
|
||||
| **Phase 4** | 独立仓库的官方 Linux 驱动 | 不修改主程序源码,经 GUI 与 CLI 完成 Linux VM 创建、WHPX 启动、绑核、截屏、SSH 与快照;真机验证 |
|
||||
| **Phase 5** | 签名体系与市场索引、iframe 面板、交互主题 UI SDK、按需引入 L2 脚本宿主 | 第三方插件经审核上架;iframe 面板无法越权读取或联网;参照 dsh-claude-style 的功能清单逐项确认可由三档主题能力承载或列出缺口 |
|
||||
| **Phase 5** | 签名体系与市场索引、`uiApi` 2.0 与 `bridgeApi` 1.0 定稿(§5.1、§5.6、§6.3)、iframe 视图与面板、交互主题 UI SDK、按需引入 L2 脚本宿主 | 契约检查覆盖全部槽位、视图位置、图层与 bridge 方法,无「可声明但不渲染」项;第三方插件经审核上架;iframe 视图无法越权读取、联网或拿到文件路径;参照 dsh-claude-style 的功能清单逐项确认可由三档主题能力承载或列出缺口 |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ reims-runtime-<commit>/
|
||||
|
||||
### 2.2 裁剪与调试符号分离
|
||||
|
||||
打包脚本 [`scripts/stage-runtime-binaries.ps1`](../scripts/stage-runtime-binaries.ps1) 执行两项体积优化,在缩小下载体积的同时保留完整调试能力:
|
||||
运行时仓库的 [`stage-runtime-binaries.ps1`](https://github.com/yxc0915/reims-vgpu/blob/master/packaging/windows-runtime/scripts/stage-runtime-binaries.ps1) 执行两项体积优化,在缩小下载体积的同时保留完整调试能力:
|
||||
|
||||
1. **裁剪非必要工具与异架构固件**:仅移除 Windows x64 启动器不会调用的 `qemu-system-x86_64w.exe`、`elf2dmp.exe`、`qemu-edid.exe`、`qemu-io.exe`、`qemu-nbd.exe`、`qemu-storage-daemon.exe`,以及 ARM64、RISC-V、LoongArch64 的 EDK2 固件与描述文件;完整保留 x64 固件、BIOS、ROM、keymaps、动态加载的 `libva` 视频驱动与全部 DLL。
|
||||
2. **独立发布调试符号**:使用 MSYS2 CLANG64 的 `llvm-objcopy` 从 5 个主可执行文件(`reims-ctl.exe`、`reims-util.exe`、`qemu-system-x86_64.exe`、`qemu-img.exe`、`reims-vgpu-compile.exe`)提取 `.debug` 符号并写入 GNU debug link,打包为同 Release 下的 `reims-runtime-symbols-<commit>.tar.zst`(客户端默认不下载符号包)。`manifest.json` 记录最终剥离后可执行文件的 SHA-256。
|
||||
@@ -73,38 +73,36 @@ reims-runtime-<commit>/
|
||||
|
||||
## 3. 打包与 CI 自动构建
|
||||
|
||||
### 3.1 本地打包
|
||||
运行 `pwsh -File scripts/pack-runtime.ps1 -Channel alpha` 一次产出以下发布附件:
|
||||
### 3.1 运行时发布附件
|
||||
运行时仓库的 [`pack-runtime.ps1`](https://github.com/yxc0915/reims-vgpu/blob/master/packaging/windows-runtime/scripts/pack-runtime.ps1) 产出以下发布附件。
|
||||
1. `reims-runtime-win-x64-<commit>.tar.zst`(运行时主体)
|
||||
2. `reims-runtime-symbols-<commit>.tar.zst`(独立调试符号包)
|
||||
3. `reims-runtime-src-<commit>.tar.zst`(上游源码 + 补丁原文 + 重建说明)
|
||||
4. `reims-runtime-msys2-src-<commit>.tar.zst`(MSYS2 copyleft DLL 源码包,由 [`scripts/pack-msys2-sources.ps1`](../scripts/pack-msys2-sources.ps1) 生成)
|
||||
3. `reims-runtime-src-<commit>.tar.zst`(运行时源码、依赖补丁和重建说明)
|
||||
4. `reims-runtime-msys2-src-<commit>.tar.zst`(MSYS2 copyleft DLL 源码包,由 [`pack-msys2-sources.ps1`](https://github.com/yxc0915/reims-vgpu/blob/master/packaging/windows-runtime/scripts/pack-msys2-sources.ps1) 生成)
|
||||
5. `SHA256SUMS.txt`(覆盖上述压缩包的统一校验清单)
|
||||
|
||||
打包前脚本会核对构建目录的 `git diff` 是否与声明的补丁逐字节一致;存在未声明修改或补丁不匹配时立即停止。
|
||||
|
||||
### 3.2 每日 CI 构建
|
||||
[`.github/workflows/build-runtime.yml`](../.github/workflows/build-runtime.yml) 每日定时(也支持手动指定 commit)在 `windows-latest`(MSYS2 CLANG64)执行:
|
||||
1. 读取上游默认分支 `HEAD`;若已存在 `runtime-<commit>` Release(不论 `alpha` 或 `stable`)则跳过。
|
||||
2. 由 [`scripts/apply-patch-series.ps1`](../scripts/apply-patch-series.ps1) 按 [`patches/series.txt`](../patches/series.txt) 顺序打补丁:可正常应用的直接应用;已合入上游的自动跳过并开 Issue 提醒退役;遇到冲突则中止构建。
|
||||
3. 执行上游 `scripts/install-ctl.sh --yes` 编译,调用 `scripts/pack-runtime.ps1 -Channel alpha` 打包。
|
||||
4. 运行 [`scripts/check-runtime-alpha.ps1`](../scripts/check-runtime-alpha.ps1) 校验 5 个附件、`SHA256SUMS.txt`、`manifest.json` 哈希一致、许可证齐全,以及在不含 MSYS2 的纯净 `PATH` 下验证 vGPU 设备枚举、CLI 版本与 `qcow2` 创建读取。
|
||||
5. 通过后发布为 GitHub 预发布(`alpha`),并自动清理超过保留上限(最近 7 个)的旧 `alpha` 预发布;正式版不受影响。
|
||||
Reims vGPU fork 的 [Preview 工作流](https://github.com/yxc0915/reims-vgpu/blob/master/.github/workflows/runtime-preview.yml) 每日构建,也支持手动指定提交。工作流从运行时仓库读取打包脚本和依赖补丁,在 `windows-latest`(MSYS2 CLANG64)执行以下步骤。
|
||||
1. 读取 Reims vGPU fork 的运行时分支,并检出其中固定的 QEMU fork 提交。若该 Reims vGPU 提交已有运行时 Release,则跳过。
|
||||
2. 按 [`series.txt`](https://github.com/yxc0915/reims-vgpu/blob/master/packaging/windows-runtime/patches/series.txt) 顺序为固定的依赖版本应用补丁。已合入上游的补丁会跳过并报告,遇到冲突时中止构建。
|
||||
3. 运行 Reims vGPU 源码中的 `scripts/install-ctl.sh --yes` 编译,再调用运行时仓库的打包脚本。
|
||||
4. 运行 [`check-runtime-alpha.ps1`](https://github.com/yxc0915/reims-vgpu/blob/master/packaging/windows-runtime/scripts/check-runtime-alpha.ps1) 校验附件哈希、许可证、挂起能力声明,以及在不含 MSYS2 的 `PATH` 下验证 vGPU 设备枚举、CLI 版本和 `qcow2` 创建读取。
|
||||
5. 通过后在 Reims vGPU fork 的 Releases 发布 Preview,标记为 GitHub 预发布(`alpha`)。手动构建可通过 `publish=false` 仅下载 CI 产物进行验证。
|
||||
|
||||
> **CI 边界**:GitHub 托管的 Windows Server runner 不提供 WHPX,也无法复现 Windows 10 兼容性问题。CI 只验证可编译与控制面基本可用,实际能否启动 macOS 桌面必须经过第 5 节的真机冒烟。
|
||||
|
||||
### 3.3 客户端下载与安装
|
||||
`internal/runtime` 默认从 GitHub Releases(tag `runtime-<commit>`)拉取,并支持官方镜像源 [GitCode `Nwflower/Reims-Go`](https://gitcode.com/Nwflower/Reims-Go) 自动回退(`auto` / `github` / `gitcode`),沿用环境变量与 Windows 系统代理,支持 HTTP `Range` 续传、强制 `SHA256SUMS.txt` 校验、临时目录原子解压与多版本切换。
|
||||
`internal/runtime` 从 `yxc0915/reims-vgpu` 的 GitHub Releases 查找 `runtime-<commit>`。默认列出正式运行时,开启内核 Alpha 后同时列出 Preview。下载沿用环境变量与 Windows 系统代理,支持 HTTP `Range` 续传、强制 `SHA256SUMS.txt` 校验、临时目录原子解压与多版本切换。
|
||||
|
||||
---
|
||||
|
||||
## 4. 补丁队列
|
||||
|
||||
本仓库不维护长期 fork,所有尚未合入上游的最小兼容性补丁统一维护在 [`patches/`](../patches/)。补丁清单、作用对象、上游化进展与退役检查表见:
|
||||
- 机器清单:[`patches/series.txt`](../patches/series.txt)
|
||||
- 维护文档:[`patches/README.md`](../patches/README.md)
|
||||
Reims vGPU 和 QEMU 的修改由各自的 fork 维护。Reims vGPU fork 的 [依赖补丁目录](https://github.com/yxc0915/reims-vgpu/tree/master/packaging/windows-runtime/patches) 保存构建时应用的补丁与维护说明。
|
||||
|
||||
运行时包的 `manifest.json` 必须如实列出所有实际应用的补丁与哈希,带补丁的构建不得标注为纯上游版本。
|
||||
运行时包的 `manifest.json` 记录源码仓库、提交、运行时能力及打包时应用的依赖补丁和哈希。
|
||||
|
||||
---
|
||||
|
||||
@@ -114,11 +112,11 @@ reims-runtime-<commit>/
|
||||
|
||||
| 通道 | GitHub Release 形态 | 准入条件 |
|
||||
| :--- | :--- | :--- |
|
||||
| **`alpha`** | 预发布(Pre-release) | CI 每日自动构建并通过 `scripts/check-runtime-alpha.ps1` 全部校验 |
|
||||
| **`stable`** | 正式发布(Release) | 从 `alpha` 晋升:在真实 Windows 10/11 宿主运行 [`scripts/smoke-runtime.ps1`](../scripts/smoke-runtime.ps1),验证纯净目录 `doctor`、启动至 macOS 桌面、截屏与正常关机,经人工确认后晋升 |
|
||||
| **`alpha`** | 预发布(Pre-release) | 运行时 CI 自动构建并通过 Alpha 准入检查 |
|
||||
| **`stable`** | 正式发布(Release) | 从 `alpha` 晋升。在真实 Windows 10/11 宿主运行 [`smoke-runtime.ps1`](https://github.com/yxc0915/reims-vgpu/blob/master/packaging/windows-runtime/scripts/smoke-runtime.ps1),验证纯净目录 `doctor`、启动至 macOS 桌面、截屏与正常关机,经人工确认后晋升 |
|
||||
|
||||
- 客户端默认仅获取 `stable` 通道;`alpha` 需用户在界面开启「接收 Alpha 版」或在 CLI 传入 `--alpha`。
|
||||
- 晋升 `stable` 不重新打包,仅将既有 GitHub 预发布转为正式发布,确保用户下载的二进制与冒烟验证的资产完全一致(因此包内 `manifest.json` 的构建通道字段保持 `alpha`,客户端以 Release 状态区分通道)。
|
||||
- 晋升 `stable` 时,在运行时仓库将已通过冒烟的 Preview 改为正式 Release,并移除标题中的 Alpha 标记。保留原资产、校验清单和 `manifest.json` 的构建通道。
|
||||
|
||||
---
|
||||
|
||||
@@ -129,6 +127,6 @@ Reims-Go 本体(Go 后端与前端外壳)采用 [Apache-2.0](../LICENSE) 协
|
||||
由于便携运行时包含 GPLv2(QEMU)、`GPL-2.0-or-later OR LGPL-3.0-or-later`(`reims-vgpu` / `reims-ctl` / `metal2vulkan`)以及 MSYS2 CLANG64 / libva 动态库,每个公开运行时 Release **必须同处附带完整对应源码与许可证文本**:
|
||||
|
||||
1. **上游源码包(`reims-runtime-src-<commit>.tar.zst`)**:导出所用 commit 的四个上游仓库源码树、构建所需的 QEMU meson 子项目、`patches/` 中的全部补丁原文及重建说明。
|
||||
2. **MSYS2 copyleft 源码包(`reims-runtime-msys2-src-<commit>.tar.zst`)**:由 [`scripts/pack-msys2-sources.ps1`](../scripts/pack-msys2-sources.ps1) 根据本机 pacman 元数据自动筛选全部无宽松替代协议的 GPL / LGPL / MPL 依赖包,下载官方 `.src.tar.zst` 并使用 `gpgv` 与 MSYS2 密钥逐一验签,同时附带 `MSYS2-PACKAGES.txt` 说明全部 DLL 归属与许可。
|
||||
3. **许可证与声明**:运行时包根目录内置 [`NOTICE.md`](../NOTICE.md) 与 `licenses/` 全文。
|
||||
2. **MSYS2 copyleft 源码包(`reims-runtime-msys2-src-<commit>.tar.zst`)**:由 [`pack-msys2-sources.ps1`](https://github.com/yxc0915/reims-vgpu/blob/master/packaging/windows-runtime/scripts/pack-msys2-sources.ps1) 根据本机 pacman 元数据自动筛选全部无宽松替代协议的 GPL / LGPL / MPL 依赖包,下载官方 `.src.tar.zst` 并使用 `gpgv` 与 MSYS2 密钥逐一验签,同时附带 `MSYS2-PACKAGES.txt` 说明全部 DLL 归属与许可。
|
||||
3. **许可证与声明**:运行时包根目录内置 [`NOTICE.md`](https://github.com/yxc0915/reims-vgpu/blob/master/packaging/windows-runtime/NOTICE.md) 与 `licenses/` 全文。
|
||||
4. **不含 Apple 专有文件**:任何仓库目录或运行时 Release 均不包含 macOS 安装包、恢复镜像、解密固件或 SMC 密钥;系统安装包均由用户端直连 Apple 服务器获取。
|
||||
@@ -0,0 +1,53 @@
|
||||
# PR 变更归属审查
|
||||
|
||||
> 以产生行为的实现为准。先定位改动发生在哪个组件,再决定提交仓库和验证范围。桌面或 CLI 是否有入口,只决定客户端是否也需要改动。
|
||||
|
||||
## 1. 确认归属
|
||||
|
||||
以 PR 实际目标分支与提交的差异为准。使用 GitHub 的「Files changed」或本地 `git diff <base>...<head>`,同时检查生成文件对应的源文件、补丁目标、依赖锁定和 CI 变更。先从用户入口沿调用链找到行为的实现,再按下表归属。
|
||||
|
||||
| 类别 | 行为或改动 | 实现归属 |
|
||||
| :--- | :--- | :--- |
|
||||
| 客户端 | GUI、CLI、虚拟机流程编排、宿主机体检及窗口集成、Guest Tools、运行时下载和安装 | `Reims-Go`。主要入口和模块见[系统架构](architecture.md)。 |
|
||||
| 客户端运行时适配 | 构造命令和环境、调用已发布的 CLI / QMP 接口、解析结果以及处理版本、能力或错误 | `Reims-Go`。生效行为仍由被调用的组件实现。 |
|
||||
| Reims vGPU 内核及控制工具 | `reims-ctl` 的配置、启动与参数语义,`reims-restore` 的恢复流程,Reims 的宿主图形、原生 VM 窗口及输入实现 | [`steelbrain/reims-vgpu`](https://github.com/steelbrain/reims-vgpu)。运行时所用改动以 [Reims vGPU fork](https://github.com/yxc0915/reims-vgpu) 的实际构建提交为准。 |
|
||||
| QEMU 虚拟化层 | WHPX / TCG、客体机器与设备模型、`reims-graphics-pci` 的 PCI 设备侧、QMP 命令实现、`qcow2` 格式与迁移机制 | [`steelbrain/qemu-reims-vgpu`](https://github.com/steelbrain/qemu-reims-vgpu)。核对构建提交中的 `vendor/qemu` gitlink 及其来源。 |
|
||||
| 独立上游工具 | `reims-util` 内的引导资源生成、安装镜像处理和工具自身的参数语义 | [`steelbrain/reims-util`](https://github.com/steelbrain/reims-util)。按运行时锁定的提交定位。 |
|
||||
| 独立图形依赖 | Metal 到 Vulkan 的命令、资源和着色器转换实现 | [`steelbrain/metal2vulkan`](https://github.com/steelbrain/metal2vulkan)。按运行时锁定的提交定位。 |
|
||||
| 其他独立引擎 | 引擎自身的执行、翻译和固件实现 | 对应引擎的源代码仓库。客户端的驱动注册、启动参数适配和状态展示仍归 `Reims-Go`。 |
|
||||
| 运行时集成与分发 | 上游版本选取、依赖补丁、运行时编译、打包、能力清单及 Preview 发布 | [`yxc0915/reims-vgpu`](https://github.com/yxc0915/reims-vgpu) 的运行时流水线。构建及发布规则见[便携运行时规范](portable-runtime-spec.md)。 |
|
||||
|
||||
同一项功能可以涉及多个仓库。窗口安装引导调用已有运行时能力时,浮层、进度和流程编排属于客户端。若同时调整 Reims 原生窗口的事件语义,窗口实现属于 `reims-vgpu`,调用和交互留在客户端。挂起功能同理,GUI / CLI 和任务状态属于客户端,QEMU 的迁移或设备状态实现属于 QEMU;运行时再负责选取具备该能力的版本。
|
||||
|
||||
## 2. 审查客户端独立性
|
||||
|
||||
- **构建与发布**:客户端 CI 仅从 `Reims-Go` 源码检出完成前端构建、Go 检查和应用产物构建。运行时源码、编译工具链和运行时发布产物由运行时仓库管理。客户端自行发布应用,并在虚拟机运行前下载、校验或导入兼容的独立运行时。
|
||||
- **接口边界**:客户端通过约定的子进程接口和协议调用运行时。配置写入沿用 [`reims-ctl set`](design-guidelines.md#2-配置原语)。需要新增命令、参数、字段或能力时,在负责组件实现,并在客户端附上对应接口证据。
|
||||
- **运行时兼容**:客户端 PR 写明验证使用的运行时与最低要求。若依赖新能力,优先使用运行时明确声明的能力或版本,在旧版、缺失运行时和不支持该能力的场景下明确禁用、提示或保留既有流程。客户端合入与运行时发布各自按其流程验收,用户默认仍走受支持的 `stable` 通道。
|
||||
- **跨仓交付**:按归属拆分 PR。客户端 PR 链接底层 PR、提交或运行时版本,列出合并顺序和兼容路径。临时依赖补丁由运行时仓库记录,注明目标仓库、适用提交和退役条件。跨仓定位以源码、依赖锁定和产物清单为证据。
|
||||
|
||||
## 3. PR 描述与合并检查
|
||||
|
||||
提交者在 PR 描述中附上以下信息。纯文档或纯客户端改动可将无关字段写为「不适用」。
|
||||
|
||||
```markdown
|
||||
## 变更归属
|
||||
|
||||
- 用户可见行为
|
||||
- 变更位置与责任仓库
|
||||
- 上游证据(仓库、commit、文件及行号)
|
||||
- 跨仓依赖(关联 PR、合并顺序、运行时要求)
|
||||
- 旧版或缺失运行时的表现
|
||||
|
||||
## 验证
|
||||
|
||||
- 已通过的检查及运行时版本
|
||||
- 待验证场景及其影响
|
||||
```
|
||||
|
||||
审查者在合并前核对以下各项。
|
||||
|
||||
- [ ] 差异中的客户端、内核、独立依赖和分发变更均已注明归属。跨仓实现已拆分并可追溯。
|
||||
- [ ] 客户端能独立通过其 CI。行为变更已按影响验证 GUI、CLI 或两者的正常入口。
|
||||
- [ ] 底层或打包改动有负责仓库的验证证据。涉及运行时发布时,核对 `manifest.json` 中的来源提交、补丁与能力声明,以及相应的 [`alpha` 准入与 `stable` 冒烟要求](portable-runtime-spec.md#5-发布通道alpha--stable)。
|
||||
- [ ] 上游行为已定位到对应提交和源码行号。真机或兼容性覆盖不足的场景标明「待验证」,合并前明确其对客户端发布和能力开放的影响。
|
||||
+4
-3
@@ -12,7 +12,7 @@
|
||||
## 已实现能力(截至 v0.2.6)
|
||||
|
||||
### 1. 免编译与环境初始化
|
||||
- **便携运行时体系**:剥离 MSYS2 / Rust / 源码仓库依赖,支持 GitHub Release(含 GitCode 国内镜像回退与系统代理)在线下载、断点续传、SHA-256 校验、原子切换与本地 `.tar.zst` 导入。
|
||||
- **便携运行时体系**:剥离 MSYS2 / Rust / 源码仓库依赖,支持 GitHub Release(含系统代理)在线下载、断点续传、SHA-256 校验、原子切换与本地 `.tar.zst` 导入。
|
||||
- **宿主机体检与引导**:免提权检测 WHPX(缺失时支持 UAC 一键开启)、物理与可用提交内存预检、Vulkan 独立显卡识别、大小核(P/E/LP-E)拓扑与处理器计划检查、数据盘总线类型风险提示。
|
||||
- **统一发布物**:桌面界面与命令行共用单个 `reims-go.exe`,支持浅色/深色外观与中英双语。
|
||||
|
||||
@@ -33,14 +33,15 @@
|
||||
优先打磨和验证已有能力,在 P0 任务稳定前不堆砌新子系统。
|
||||
|
||||
### 1. 首次装机与发版闭环
|
||||
- 在 GitHub Actions 上实跑 `build-runtime.yml` 每日构建与 `alpha` 准入流程,验证公开资产的 `manifest.json`、补丁队列与源码包一致性。
|
||||
- 在运行时仓库的 [Preview CI](https://github.com/yxc0915/reims-vgpu/actions/workflows/runtime-preview.yml) 验证公开资产的 `manifest.json`、补丁队列与源码包一致性。
|
||||
- 在多种受支持的 Windows 10 / 11、GPU 与 macOS 组合上跑通完整开箱流程(干净目录 → 体检 → 安装运行时 → 下载离线包 → 装机 → 退出恢复模式)。
|
||||
- 完善中断与异常场景的故障恢复(断网续传、磁盘不足、取消 UAC、运行时损坏),确保失败后可安全重试且不残留半配置虚拟机。
|
||||
|
||||
### 2. 日常主力体验与上游性能跟进
|
||||
- 持续跟进上游 [`steelbrain/reims-vgpu`](https://github.com/steelbrain/reims-vgpu) 的 Windows 图形与窗口改进(热切全屏、无黑边窗口缩放、原生 Windows Vulkan 后端、首帧延迟优化、自由指针 `Win → Command` 映射),合入后经 `alpha` 冒烟升级至 `stable`(跟踪明细见 [patches/README.md](../patches/README.md))。
|
||||
- 持续跟进上游 [`steelbrain/reims-vgpu`](https://github.com/steelbrain/reims-vgpu) 的 Windows 图形与窗口改进(热切全屏、无黑边窗口缩放、原生 Windows Vulkan 后端、首帧延迟优化、自由指针 `Win → Command` 映射),合入后经 `alpha` 冒烟升级至 `stable`。跟踪明细见[运行时补丁文档](https://github.com/yxc0915/reims-vgpu/blob/master/packaging/windows-runtime/patches/README.md)。
|
||||
- 推动当前本地兼容性补丁上游化,并逐步清零 `patches/` 队列。
|
||||
- 在真实宿主完成长时间开发负载验证(编译、浏览器、多任务、图文剪贴板、WebDAV 挂载、Windows 盘符只读共享、音频/麦克风与休眠唤醒恢复)。
|
||||
- 修复 WebDAV 共享目录可经 Junction 逃逸的路径校验缺陷,并把共享目录与只读盘统一到基于 `os.Root` 的路径安全层;随后按测量结果推进小文件 I/O 优化。
|
||||
|
||||
### 3. 恢复点与磁盘操作可靠性
|
||||
- 对停机恢复点(创建/回滚/删除)、CoW 派生启动、大容量 VMDK 转换以及停机扩容/空间回收完成真机中断与边界测试,确保空间不足或中途中断不会破坏原盘与 backing file 链。
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"bridgeApi": "1.0.0",
|
||||
"methods": [
|
||||
"hello",
|
||||
"i18n.getBundle",
|
||||
"ui.notify",
|
||||
"vm.list",
|
||||
"command.invoke"
|
||||
],
|
||||
"events": [
|
||||
"theme.changed",
|
||||
"locale.changed"
|
||||
],
|
||||
"experimental": {
|
||||
"methods": [
|
||||
"ui.confirm",
|
||||
"ui.showForm",
|
||||
"ui.setTitle",
|
||||
"ui.setBadge",
|
||||
"ui.openView",
|
||||
"ui.close",
|
||||
"ui.navigate",
|
||||
"ui.openExternal",
|
||||
"vm.get",
|
||||
"settings.get",
|
||||
"settings.set",
|
||||
"storage.get",
|
||||
"storage.set",
|
||||
"storage.list",
|
||||
"storage.delete",
|
||||
"file.pick",
|
||||
"file.save",
|
||||
"file.read",
|
||||
"file.write",
|
||||
"task.start",
|
||||
"task.update",
|
||||
"task.finish",
|
||||
"net.fetch",
|
||||
"events.subscribe",
|
||||
"events.unsubscribe"
|
||||
],
|
||||
"events": [
|
||||
"vm.stateChanged",
|
||||
"view.visibilityChanged",
|
||||
"task.updated"
|
||||
]
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<html dir="ltr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
{
|
||||
"name": "reims-go-frontend",
|
||||
"private": true,
|
||||
"version": "0.2.8",
|
||||
"version": "0.2.11",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"test": "node --test scripts/test-i18n.mjs scripts/test-macos-boundary.mjs scripts/test-no-empty-catch.mjs",
|
||||
"build": "tsc --noEmit && vite build && node scripts/check-ui-contract.mjs",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
|
||||
@@ -1 +1 @@
|
||||
fd01023ab020f4fa559696be6708a9a3
|
||||
d5f2fdb982362b7c1d77e7244b0a024f
|
||||
@@ -1,3 +1,9 @@
|
||||
// Checks the UI and bridge contracts (docs/plugin-architecture.md §5.1, §5.6, §6.3)
|
||||
// and writes ui-contract.json / bridge-contract.json for plugin authors.
|
||||
//
|
||||
// Rule "public means implemented": every stable part, state attribute, slot and
|
||||
// layer must be emitted by the host, and an experimental entry the host already
|
||||
// emits must be promoted to stable in the same change.
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
@@ -7,55 +13,160 @@ const rootDir = path.resolve(__dirname, '..')
|
||||
const srcDir = path.join(rootDir, 'src')
|
||||
|
||||
const contractSrc = fs.readFileSync(path.join(srcDir, 'styles', 'ui-contract.ts'), 'utf8')
|
||||
const bridgeSrc = fs.readFileSync(path.join(srcDir, 'lib', 'bridgeContract.ts'), 'utf8')
|
||||
const tokensCss = fs.readFileSync(path.join(srcDir, 'styles', 'tokens.css'), 'utf8')
|
||||
const appCss = fs.readFileSync(path.join(srcDir, 'styles', 'app.css'), 'utf8')
|
||||
|
||||
function extractArray(name) {
|
||||
function extractArray(src, name) {
|
||||
const re = new RegExp(`export const ${name} = \\[([\\s\\S]*?)\\] as const`)
|
||||
const m = contractSrc.match(re)
|
||||
if (!m) throw new Error(`Could not parse ${name} from ui-contract.ts`)
|
||||
const m = src.match(re)
|
||||
if (!m) throw new Error(`Could not parse ${name}`)
|
||||
return [...m[1].matchAll(/'([^']+)'/g)].map((x) => x[1])
|
||||
}
|
||||
function extractVersion(src, name) {
|
||||
const m = src.match(new RegExp(`${name}\\s*=\\s*'([^']+)'`))
|
||||
if (!m) throw new Error(`Could not parse ${name}`)
|
||||
return m[1]
|
||||
}
|
||||
const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||
|
||||
const apiMatch = contractSrc.match(/UI_API_VERSION\s*=\s*'([^']+)'/)
|
||||
const uiApi = apiMatch ? apiMatch[1] : '1.0.0'
|
||||
const parts = extractArray('UI_CONTRACT_PARTS')
|
||||
const stateAttrs = extractArray('UI_CONTRACT_STATE_ATTRS')
|
||||
const slots = extractArray('UI_CONTRACT_SLOTS')
|
||||
const tokens = extractArray('UI_CONTRACT_TOKENS')
|
||||
const uiApi = extractVersion(contractSrc, 'UI_API_VERSION')
|
||||
const stable = {
|
||||
parts: extractArray(contractSrc, 'UI_CONTRACT_PARTS'),
|
||||
stateAttrs: extractArray(contractSrc, 'UI_CONTRACT_STATE_ATTRS'),
|
||||
itemStates: extractArray(contractSrc, 'UI_CONTRACT_ITEM_STATES'),
|
||||
slots: extractArray(contractSrc, 'UI_CONTRACT_SLOTS'),
|
||||
layers: extractArray(contractSrc, 'UI_CONTRACT_LAYERS'),
|
||||
layoutOptions: extractArray(contractSrc, 'UI_CONTRACT_LAYOUT_OPTIONS'),
|
||||
icons: extractArray(contractSrc, 'UI_CONTRACT_ICONS'),
|
||||
viewLocations: extractArray(contractSrc, 'UI_CONTRACT_VIEW_LOCATIONS'),
|
||||
sdkEvents: extractArray(contractSrc, 'UI_CONTRACT_SDK_EVENTS'),
|
||||
tokens: extractArray(contractSrc, 'UI_CONTRACT_TOKENS'),
|
||||
}
|
||||
const experimental = {
|
||||
parts: extractArray(contractSrc, 'UI_CONTRACT_PARTS_EXPERIMENTAL'),
|
||||
stateAttrs: extractArray(contractSrc, 'UI_CONTRACT_STATE_ATTRS_EXPERIMENTAL'),
|
||||
itemStates: extractArray(contractSrc, 'UI_CONTRACT_ITEM_STATES_EXPERIMENTAL'),
|
||||
slots: extractArray(contractSrc, 'UI_CONTRACT_SLOTS_EXPERIMENTAL'),
|
||||
layers: extractArray(contractSrc, 'UI_CONTRACT_LAYERS_EXPERIMENTAL'),
|
||||
layoutOptions: extractArray(contractSrc, 'UI_CONTRACT_LAYOUT_OPTIONS_EXPERIMENTAL'),
|
||||
icons: extractArray(contractSrc, 'UI_CONTRACT_ICONS_EXPERIMENTAL'),
|
||||
viewLocations: extractArray(contractSrc, 'UI_CONTRACT_VIEW_LOCATIONS_EXPERIMENTAL'),
|
||||
sdkEvents: extractArray(contractSrc, 'UI_CONTRACT_SDK_EVENTS_EXPERIMENTAL'),
|
||||
}
|
||||
const bridgeApi = extractVersion(bridgeSrc, 'BRIDGE_API_VERSION')
|
||||
const bridge = {
|
||||
methods: extractArray(bridgeSrc, 'BRIDGE_METHODS'),
|
||||
events: extractArray(bridgeSrc, 'BRIDGE_EVENTS'),
|
||||
experimentalMethods: extractArray(bridgeSrc, 'BRIDGE_METHODS_EXPERIMENTAL'),
|
||||
experimentalEvents: extractArray(bridgeSrc, 'BRIDGE_EVENTS_EXPERIMENTAL'),
|
||||
}
|
||||
|
||||
// Collect all React component TSX source text (excluding contract/SDK/theme helpers)
|
||||
// and verify every declared part class is emitted as a distinct class token (§5.1, M17).
|
||||
function readComponentTsx(dir) {
|
||||
// Host source the contract is emitted from (contract/SDK definitions excluded).
|
||||
function readSources(dir, exts) {
|
||||
let buf = ''
|
||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const full = path.join(dir, entry.name)
|
||||
if (entry.isDirectory()) buf += readComponentTsx(full)
|
||||
else if (entry.name.endsWith('.tsx')) buf += '\n' + fs.readFileSync(full, 'utf8')
|
||||
if (entry.isDirectory()) buf += readSources(full, exts)
|
||||
else if (exts.some((e) => entry.name.endsWith(e)) && !/ui-contract\.ts$|bridgeContract\.ts$|\.gen\.ts$/.test(entry.name)) {
|
||||
buf += '\n' + fs.readFileSync(full, 'utf8')
|
||||
}
|
||||
}
|
||||
return buf
|
||||
}
|
||||
const allTsx = readSources(srcDir, ['.tsx'])
|
||||
const allCode = readSources(srcDir, ['.ts', '.tsx'])
|
||||
// Per-file sources, for checks that need two things in the same component.
|
||||
function sourceFiles(dir, out = []) {
|
||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const full = path.join(dir, entry.name)
|
||||
if (entry.isDirectory()) sourceFiles(full, out)
|
||||
else if (entry.name.endsWith('.tsx')) out.push(fs.readFileSync(full, 'utf8'))
|
||||
}
|
||||
return out
|
||||
}
|
||||
const tsxFiles = sourceFiles(srcDir)
|
||||
|
||||
const allTsx = readComponentTsx(srcDir)
|
||||
const missingParts = parts.filter((p) => {
|
||||
const re = new RegExp(`(?<![a-zA-Z0-9_-])${p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?![a-zA-Z0-9_-])`)
|
||||
return !re.test(allTsx)
|
||||
const hasClass = (p) => new RegExp(`(?<![a-zA-Z0-9_-])${esc(p)}(?![a-zA-Z0-9_-])`).test(allTsx)
|
||||
const camel = (attr) => attr.replace(/^data-/, '').replace(/-([a-z])/g, (_, c) => c.toUpperCase())
|
||||
const hasAttr = (a) => allCode.includes(a) || new RegExp(`dataset\\.${camel(a)}\\b`).test(allCode)
|
||||
const hasSlot = (s) => allTsx.includes(`data-rg-slot="${s}"`)
|
||||
const hasLayer = (l) => allTsx.includes(`data-rg-layer="${l}"`)
|
||||
|
||||
const errors = []
|
||||
const fail = (msg, list) => { if (list.length) errors.push(`${msg}: ${list.join(', ')}`) }
|
||||
|
||||
fail('stable parts not emitted by any component', stable.parts.filter((p) => !hasClass(p)))
|
||||
fail('stable state attributes never set', stable.stateAttrs.filter((a) => !hasAttr(a)))
|
||||
fail('stable slots without a data-rg-slot anchor', stable.slots.filter((s) => !hasSlot(s)))
|
||||
fail('stable layers without a data-rg-layer element', stable.layers.filter((l) => !hasLayer(l)))
|
||||
fail('stable tokens missing in tokens.css', stable.tokens.filter((tk) => !tokensCss.includes(`${tk}:`)))
|
||||
// An item state counts as emitted when one component carries both the part and the attribute.
|
||||
fail('stable item states not emitted together with their part', stable.itemStates.filter((s) => {
|
||||
const [part, attr] = s.split(':')
|
||||
return !tsxFiles.some((src) => new RegExp(`(?<![a-zA-Z0-9_-])${esc(part)}(?![a-zA-Z0-9_-])`).test(src) && src.includes(`${attr}=`))
|
||||
}))
|
||||
// Layout values other than the defaults need CSS that implements them.
|
||||
const LAYOUT_ATTR = { sidebarPosition: 'data-layout-sidebar', sidebarMode: 'data-layout-sidebar-mode', density: 'data-layout-density', titlebar: 'data-layout-titlebar' }
|
||||
const LAYOUT_DEFAULTS = ['sidebarPosition=left', 'sidebarMode=full', 'density=regular', 'titlebar=standard']
|
||||
fail('stable layout options without CSS in app.css', stable.layoutOptions.filter((o) => {
|
||||
if (LAYOUT_DEFAULTS.includes(o)) return false
|
||||
const [opt, val] = o.split('=')
|
||||
return !LAYOUT_ATTR[opt] || !appCss.includes(`[${LAYOUT_ATTR[opt]}="${val}"]`)
|
||||
}))
|
||||
fail('layout options with an unknown option name', [...stable.layoutOptions, ...experimental.layoutOptions].filter((o) => !LAYOUT_ATTR[o.split('=')[0]]))
|
||||
// Every stable icon name is rendered through <HostIcon name="..."> (or the status-shape map).
|
||||
const controlsSrc = fs.readFileSync(path.join(srcDir, 'ui', 'controls.tsx'), 'utf8')
|
||||
fail('stable icon names never rendered through HostIcon', stable.icons.filter((n) =>
|
||||
!allTsx.includes(`HostIcon name="${n}"`) && !(n.startsWith('vm.state.') && controlsSrc.includes(`'${n}'`))))
|
||||
// Every stable SDK event has an emitter.
|
||||
fail('stable SDK events never emitted', stable.sdkEvents.filter((e) => !allCode.includes(`emitThemeEvent('${e}'`)))
|
||||
|
||||
fail('experimental parts already emitted (promote them to UI_CONTRACT_PARTS)', experimental.parts.filter(hasClass))
|
||||
fail('experimental slots already anchored (promote them to UI_CONTRACT_SLOTS)', experimental.slots.filter(hasSlot))
|
||||
fail('experimental layers already rendered (promote them to UI_CONTRACT_LAYERS)', experimental.layers.filter(hasLayer))
|
||||
|
||||
const overlap = (a, b) => a.filter((x) => b.includes(x))
|
||||
fail('entries listed as both stable and experimental (parts)', overlap(stable.parts, experimental.parts))
|
||||
fail('entries listed as both stable and experimental (state attributes)', overlap(stable.stateAttrs, experimental.stateAttrs))
|
||||
fail('entries listed as both stable and experimental (slots)', overlap(stable.slots, experimental.slots))
|
||||
fail('entries listed as both stable and experimental (layers)', overlap(stable.layers, experimental.layers))
|
||||
fail('entries listed as both stable and experimental (item states)', overlap(stable.itemStates, experimental.itemStates))
|
||||
fail('entries listed as both stable and experimental (layout options)', overlap(stable.layoutOptions, experimental.layoutOptions))
|
||||
fail('entries listed as both stable and experimental (icons)', overlap(stable.icons, experimental.icons))
|
||||
fail('entries listed as both stable and experimental (view locations)', overlap(stable.viewLocations, experimental.viewLocations))
|
||||
fail('entries listed as both stable and experimental (SDK events)', overlap(stable.sdkEvents, experimental.sdkEvents))
|
||||
fail('bridge methods listed as both stable and experimental', overlap(bridge.methods, bridge.experimentalMethods))
|
||||
fail('bridge events listed as both stable and experimental', overlap(bridge.events, bridge.experimentalEvents))
|
||||
|
||||
const knownParts = [...stable.parts, ...experimental.parts]
|
||||
fail('item states on unknown parts', [...stable.itemStates, ...experimental.itemStates].filter((s) => !knownParts.includes(s.split(':')[0])))
|
||||
for (const [name, list] of Object.entries({ ...stable, ...experimental, ...bridge })) {
|
||||
const dupes = list.filter((x, i) => list.indexOf(x) !== i)
|
||||
fail(`duplicate entries in ${name}`, dupes)
|
||||
}
|
||||
|
||||
if (errors.length > 0) {
|
||||
for (const e of errors) console.error(`[ui-contract] ERROR: ${e}`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const write = (file, data) => {
|
||||
const text = JSON.stringify(data, null, 2) + '\n'
|
||||
fs.writeFileSync(path.join(rootDir, file), text, 'utf8')
|
||||
const distDir = path.join(rootDir, 'dist')
|
||||
if (fs.existsSync(distDir)) fs.writeFileSync(path.join(distDir, file), text, 'utf8')
|
||||
}
|
||||
write('ui-contract.json', { uiApi, ...stable, experimental })
|
||||
write('bridge-contract.json', {
|
||||
bridgeApi,
|
||||
methods: bridge.methods,
|
||||
events: bridge.events,
|
||||
experimental: { methods: bridge.experimentalMethods, events: bridge.experimentalEvents },
|
||||
})
|
||||
const missingTokens = tokens.filter((tk) => !tokensCss.includes(`${tk}:`))
|
||||
|
||||
if (missingParts.length > 0) {
|
||||
console.error('[ui-contract] ERROR: contract parts not emitted by any component:', missingParts.join(', '))
|
||||
process.exit(1)
|
||||
}
|
||||
if (missingTokens.length > 0) {
|
||||
console.error('[ui-contract] ERROR: contract tokens missing in tokens.css:', missingTokens.join(', '))
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const out = { uiApi, tokens, parts, stateAttrs, slots }
|
||||
const jsonText = JSON.stringify(out, null, 2) + '\n'
|
||||
fs.writeFileSync(path.join(rootDir, 'ui-contract.json'), jsonText, 'utf8')
|
||||
const distDir = path.join(rootDir, 'dist')
|
||||
if (fs.existsSync(distDir)) {
|
||||
fs.writeFileSync(path.join(distDir, 'ui-contract.json'), jsonText, 'utf8')
|
||||
}
|
||||
console.log(`[ui-contract] OK (uiApi=${uiApi}, parts=${parts.length}, tokens=${tokens.length}, slots=${slots.length})`)
|
||||
console.log(
|
||||
`[ui-contract] OK (uiApi=${uiApi}, parts=${stable.parts.length}+${experimental.parts.length}x, ` +
|
||||
`tokens=${stable.tokens.length}, slots=${stable.slots.length}+${experimental.slots.length}x, layers=${stable.layers.length}, ` +
|
||||
`icons=${stable.icons.length}, sdkEvents=${stable.sdkEvents.length}, ` +
|
||||
`bridgeApi=${bridgeApi}, methods=${bridge.methods.length}+${bridge.experimentalMethods.length}x)`,
|
||||
)
|
||||
@@ -0,0 +1,408 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { createRequire } from 'node:module'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const rootDir = path.resolve(__dirname, '..')
|
||||
const srcDir = path.join(rootDir, 'src')
|
||||
const localesDir = path.resolve(rootDir, '..', 'locales', 'en-US')
|
||||
|
||||
// Resolve esbuild from Vite's dependency tree (zero extra npm dependencies per §8.1).
|
||||
const requireFromRoot = createRequire(path.join(rootDir, 'package.json'))
|
||||
const vitePkgPath = requireFromRoot.resolve('vite/package.json')
|
||||
const requireFromVite = createRequire(vitePkgPath)
|
||||
const esbuild = requireFromVite('esbuild')
|
||||
|
||||
async function loadBundledTS(entrySource) {
|
||||
const result = await esbuild.build({
|
||||
stdin: {
|
||||
contents: entrySource,
|
||||
resolveDir: srcDir,
|
||||
sourcefile: 'test-entry.ts',
|
||||
loader: 'ts',
|
||||
},
|
||||
bundle: true,
|
||||
write: false,
|
||||
format: 'esm',
|
||||
platform: 'browser',
|
||||
target: 'es2022',
|
||||
})
|
||||
const code = result.outputFiles[0].text
|
||||
const dataUrl = `data:text/javascript;base64,${Buffer.from(code, 'utf8').toString('base64')}`
|
||||
return import(dataUrl)
|
||||
}
|
||||
|
||||
function walkFiles(dir, exts) {
|
||||
const out = []
|
||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const full = path.join(dir, entry.name)
|
||||
if (entry.isDirectory()) out.push(...walkFiles(full, exts))
|
||||
else if (exts.some((ext) => entry.name.endsWith(ext))) out.push(full)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
test('Static Guard (CRITICAL-1): lazy i18n domain keys are always backed by domain .gen imports', () => {
|
||||
const lazyDomains = ['wizard', 'settings', 'plugins']
|
||||
const keyToDomain = new Map()
|
||||
for (const dom of ['core', 'vm', ...lazyDomains]) {
|
||||
const raw = JSON.parse(fs.readFileSync(path.join(localesDir, `${dom}.json`), 'utf8'))
|
||||
for (const k of Object.keys(raw)) {
|
||||
if (!k.startsWith('$')) keyToDomain.set(k, dom)
|
||||
}
|
||||
}
|
||||
|
||||
// Known lazy-loaded chunk entry trees (loaded via React.lazy or dynamic import in App.tsx)
|
||||
const lazyEntryBasenames = new Set([
|
||||
'CreateWizard.tsx',
|
||||
'SettingsModal.tsx',
|
||||
'AffinityDialog.tsx',
|
||||
'Setup.tsx',
|
||||
'RuntimeOnline.tsx',
|
||||
'HostView.tsx',
|
||||
'ImagesPage.tsx',
|
||||
'InstallersPage.tsx',
|
||||
'PluginsPage.tsx',
|
||||
'PluginMarket.tsx',
|
||||
'PluginParts.tsx',
|
||||
'AppSettingsPage.tsx',
|
||||
'AboutPage.tsx',
|
||||
'PluginPanelFrame.tsx',
|
||||
'SchemaForm.tsx',
|
||||
'optimizations.ts',
|
||||
])
|
||||
|
||||
for (const file of walkFiles(srcDir, ['.ts', '.tsx'])) {
|
||||
const rel = path.relative(srcDir, file).replace(/\\/g, '/')
|
||||
if (rel.startsWith('i18n/')) continue
|
||||
const base = path.basename(file)
|
||||
const src = fs.readFileSync(file, 'utf8')
|
||||
|
||||
// Match string literals passed to t(..., 'key'), tr('key'), labelKey: 'key', detailKey: 'key', titleKey: 'key', descKey: 'key'
|
||||
const referencedLazyDomains = new Set()
|
||||
const callMatches = [
|
||||
...src.matchAll(/\b(?:tr|t)\(\s*(?:[a-zA-Z0-9_$.]+\s*,\s*)?'([a-zA-Z0-9_.]+)'/g),
|
||||
...src.matchAll(/\b(?:labelKey|detailKey|titleKey|descKey)\s*:\s*'([a-zA-Z0-9_.]+)'/g),
|
||||
]
|
||||
for (const m of callMatches) {
|
||||
const dom = keyToDomain.get(m[1])
|
||||
if (dom && lazyDomains.includes(dom)) {
|
||||
referencedLazyDomains.add(`${dom}:${m[1]}`)
|
||||
}
|
||||
}
|
||||
|
||||
if (referencedLazyDomains.size === 0) continue
|
||||
|
||||
assert.ok(
|
||||
lazyEntryBasenames.has(base),
|
||||
`Eager module ${rel} references lazy domain keys (${[...referencedLazyDomains].join(', ')})! Either move keys to core/vm or lazy-load the module.`,
|
||||
)
|
||||
|
||||
for (const item of referencedLazyDomains) {
|
||||
const [dom, key] = item.split(':')
|
||||
// Sub-dialogs rendered exclusively inside lazy parent chunks inherit their parent's domain registration
|
||||
if (base === 'AffinityDialog.tsx' && dom === 'settings') continue
|
||||
if (base === 'RuntimeOnline.tsx' && (dom === 'wizard' || dom === 'settings')) continue
|
||||
assert.match(
|
||||
src,
|
||||
new RegExp(`i18n/domains/${dom}\\.gen`),
|
||||
`Module ${rel} uses ${dom} key "${key}" without importing i18n/domains/${dom}.gen`,
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
test('Static Guard (CRITICAL-2): every stack-*, notice-*, error-boundary*, and toast-* class in TSX exists in CSS', () => {
|
||||
const css =
|
||||
fs.readFileSync(path.join(srcDir, 'styles', 'app.css'), 'utf8') +
|
||||
'\n' +
|
||||
fs.readFileSync(path.join(srcDir, 'styles', 'tokens.css'), 'utf8')
|
||||
|
||||
const prefixes = ['stack-', 'notice-', 'error-boundary', 'toast-']
|
||||
const used = new Set()
|
||||
for (const file of walkFiles(srcDir, ['.tsx'])) {
|
||||
const src = fs.readFileSync(file, 'utf8')
|
||||
for (const m of src.matchAll(/className\s*=\s*(?:"([^"]+)"|'([^']+)'|\{`([^`]+)`\})/g)) {
|
||||
const raw = (m[1] || m[2] || m[3] || '').replace(/\$\{[^}]+\}/g, ' ')
|
||||
for (const tok of raw.split(/\s+/)) {
|
||||
if (prefixes.some((p) => tok.startsWith(p))) used.add(tok)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const cls of used) {
|
||||
const escaped = cls.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||
assert.match(css, new RegExp(`\\.${escaped}(?![a-zA-Z0-9_-])`), `Missing CSS rule for .${cls}`)
|
||||
}
|
||||
})
|
||||
|
||||
test('Static Guard (CRITICAL-3): Radix Presence .menu/.tooltip animations never replay on close', () => {
|
||||
const rawCss = fs.readFileSync(path.join(srcDir, 'styles', 'app.css'), 'utf8')
|
||||
const css = rawCss.replace(/\/\*[\s\S]*?\*\//g, '')
|
||||
const titleMenus = fs.readFileSync(path.join(srcDir, 'components', 'TitleMenus.tsx'), 'utf8')
|
||||
|
||||
// Unconditional `.menu` / `.tooltip` animation (including animation-name inside
|
||||
// comma-separated selector lists or reduced-motion media queries) causes Radix
|
||||
// Presence to detect an animationName change on close and flash for 160ms.
|
||||
for (const m of css.matchAll(/([^{}@]+)\{([^{}]+)\}/g)) {
|
||||
const selectors = m[1].split(',').map((s) => s.trim()).filter(Boolean)
|
||||
const decls = m[2]
|
||||
if (!/\banimation(?:-name)?\s*:(?!\s*none\b)/.test(decls)) continue
|
||||
for (const sel of selectors) {
|
||||
assert.doesNotMatch(
|
||||
sel,
|
||||
/\.menu(?![a-zA-Z0-9_-])(?!\[data-state="open"\])/,
|
||||
`Non-open .menu selector "${sel}" must not apply an active animation`,
|
||||
)
|
||||
assert.doesNotMatch(
|
||||
sel,
|
||||
/\.tooltip(?![a-zA-Z0-9_-])(?!\[data-state="delayed-open"\])/,
|
||||
`Non-delayed-open .tooltip selector "${sel}" must not apply an active animation`,
|
||||
)
|
||||
}
|
||||
}
|
||||
assert.match(
|
||||
css,
|
||||
/\.menu\[data-state="open"\]\s*\{[^}]*animation\s*:/,
|
||||
'.menu[data-state="open"] must define the menu enter animation',
|
||||
)
|
||||
assert.match(
|
||||
css,
|
||||
/\.menu\[data-state="open"\]\[data-menubar-switch="true"\][^\{]*\{[^}]*animation\s*:\s*none/,
|
||||
'.menu[data-state="open"][data-menubar-switch="true"] must disable enter animation',
|
||||
)
|
||||
assert.match(
|
||||
css,
|
||||
/\.menu\[data-state="closed"\][^\{]*\{[^}]*animation\s*:\s*none/,
|
||||
'.menu[data-state="closed"] must explicitly disable animation so Radix Presence unmounts immediately',
|
||||
)
|
||||
assert.match(
|
||||
css,
|
||||
/\.tooltip\[data-state="closed"\][^\{]*\{[^}]*animation\s*:\s*none/,
|
||||
'.tooltip[data-state="closed"] must explicitly disable animation',
|
||||
)
|
||||
assert.match(
|
||||
css,
|
||||
/@media\s*\(\s*prefers-reduced-motion\s*:\s*reduce\s*\)\s*\{[\s\S]*?\.toast\[data-state="closed"\][^{]*\{[^}]*animation-name\s*:\s*fade-out/,
|
||||
'Reduced-motion .toast[data-state="closed"] must use fade-out',
|
||||
)
|
||||
assert.doesNotMatch(
|
||||
titleMenus,
|
||||
/data-menubar-switch=\{\s*menuState\.id\s*===\s*id\s*&&\s*menuState\.switched/,
|
||||
'TitleMenus must not strip data-menubar-switch from the outgoing sibling menu on switch',
|
||||
)
|
||||
})
|
||||
|
||||
test('Static Guard (CRITICAL-4): software-composited UI avoids backdrop-filter and slow pre shaping', () => {
|
||||
const rawCss = fs.readFileSync(path.join(srcDir, 'styles', 'app.css'), 'utf8')
|
||||
const css = rawCss.replace(/\/\*[\s\S]*?\*\//g, '')
|
||||
|
||||
// main.go sets WebviewGpuIsDisabled: true (software compositing), where
|
||||
// backdrop-filter blurs stall CPU rasterization on animations and scrolling.
|
||||
assert.doesNotMatch(
|
||||
css,
|
||||
/(?:-webkit-)?backdrop-filter\s*:/i,
|
||||
'app.css must not apply backdrop-filter under software compositing',
|
||||
)
|
||||
assert.match(
|
||||
css,
|
||||
/\.license-pre\s*\{[^}]*contain\s*:\s*content/,
|
||||
'.license-pre should isolate scroll/layout repaints with contain: content',
|
||||
)
|
||||
assert.match(
|
||||
css,
|
||||
/\.license-pre\s*\{[^}]*text-rendering\s*:\s*auto/,
|
||||
'.license-pre should opt out of global optimizeLegibility for long monospace texts',
|
||||
)
|
||||
})
|
||||
|
||||
test('Runtime i18n v2: ICU formatting, ghost-locale isolation (H-3), parseAppError (HIGH-2), RTL (L-2), and en-XA', async () => {
|
||||
const mod = await loadBundledTS(`
|
||||
import './i18n/domains/wizard.gen'
|
||||
import './i18n/domains/settings.gen'
|
||||
import './i18n/domains/plugins.gen'
|
||||
export * from './i18n'
|
||||
export * from './lib/format'
|
||||
export * from './lib/themeEngine'
|
||||
`)
|
||||
|
||||
// 1. Built-in bilingual + ICU plural + decimal formatting
|
||||
assert.equal(mod.formatMemory('16G', 'en-US'), '16 GB')
|
||||
assert.equal(mod.formatMemory('1536M', 'de-DE'), '1,5 GB')
|
||||
|
||||
// 2. H-3 & HIGH-9: Functional plugin L10n (has_ui_messages: false) must NOT pollute host UI locales,
|
||||
// while full language pack (has_ui_messages: true) activates properly.
|
||||
mod.setPluginLocales([
|
||||
{
|
||||
locale: 'de-DE',
|
||||
label: 'Deutsch',
|
||||
fallback: 'en-US',
|
||||
has_ui_messages: false,
|
||||
messages: {},
|
||||
plugin_messages: {
|
||||
'acme.de': { 'btn.run': 'Ausführen ({n})' },
|
||||
},
|
||||
},
|
||||
{
|
||||
locale: 'ja-JP',
|
||||
label: '日本語',
|
||||
fallback: 'en-US',
|
||||
has_ui_messages: true,
|
||||
messages: { sidebarSettings: '設定' },
|
||||
plugin_messages: {
|
||||
'acme.de': { 'btn.run': '実行 ({n})' },
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
const opts = mod.getLocaleOptions().map((o) => o.value)
|
||||
assert.ok(opts.includes('ja-JP'), 'ja-JP language pack should appear in UI options')
|
||||
assert.ok(!opts.includes('de-DE'), 'de-DE functional plugin L10n must NOT appear as ghost UI locale')
|
||||
assert.equal(mod.resolveActiveLocale('de-DE'), 'en-US')
|
||||
assert.equal(mod.resolveActiveLocale('ja-JP'), 'ja-JP')
|
||||
assert.equal(mod.t('ja-JP', 'sidebarSettings'), '設定')
|
||||
assert.equal(mod.tPlugin('acme.de', 'de-DE', 'btn.run', { n: 3 }), 'Ausführen (3)')
|
||||
assert.equal(mod.getPluginMessageBundle('acme.de', 'ja-JP')['btn.run'], '実行 ({n})')
|
||||
|
||||
// 3. Pseudo-locale en-XA wraps host & plugin strings in ⟦...⟧ and preserves placeholders
|
||||
const pseudoHost = mod.t('en-XA', 'cores', { n: 8 })
|
||||
assert.ok(pseudoHost.startsWith('⟦') && pseudoHost.endsWith('⟧') && pseudoHost.includes('8'), `bad pseudoHost: ${pseudoHost}`)
|
||||
const pseudoPlugin = mod.tPlugin('acme.de', 'en-XA', 'btn.run', { n: 5 }, 'Run ({n})')
|
||||
assert.ok(pseudoPlugin.startsWith('⟦') && pseudoPlugin.includes('5'), `bad pseudoPlugin: ${pseudoPlugin}`)
|
||||
|
||||
// Reset plugin locales
|
||||
mod.setPluginLocales([])
|
||||
|
||||
// 4. HIGH-2: parseAppError handles suffix & prefix [E_CODE], multi-line summaries, codeless [detail], and Error objects
|
||||
const codedSuffix = mod.parseAppError('First summary line\nSecond summary line [E_VM_BUSY]\n[detail] raw trace line 1\nline 2')
|
||||
assert.equal(codedSuffix.code, 'E_VM_BUSY')
|
||||
assert.equal(codedSuffix.summary, 'First summary line\nSecond summary line')
|
||||
assert.equal(codedSuffix.rawDetail, 'raw trace line 1\nline 2')
|
||||
|
||||
const codedPrefix = mod.parseAppError('[E_VM_BUSY] First summary line\nSecond summary line\n[detail] raw trace line 1\nline 2')
|
||||
assert.equal(codedPrefix.code, 'E_VM_BUSY')
|
||||
assert.equal(codedPrefix.summary, 'First summary line\nSecond summary line')
|
||||
assert.equal(codedPrefix.rawDetail, 'raw trace line 1\nline 2')
|
||||
|
||||
const codelessDetail = mod.parseAppError('Human summary without code\n[detail] exit status 1')
|
||||
assert.equal(codelessDetail.code, undefined)
|
||||
assert.equal(codelessDetail.summary, 'Human summary without code')
|
||||
assert.equal(codelessDetail.rawDetail, 'exit status 1')
|
||||
|
||||
const objErr = mod.parseAppError({ message: 'Timeout [E_NET]' })
|
||||
assert.equal(objErr.code, 'E_NET')
|
||||
assert.equal(objErr.summary, 'Timeout')
|
||||
|
||||
// 5. L-2: 8-subtag RTL parity with Go backend
|
||||
for (const rtl of ['ar-SA', 'he-IL', 'iw-IL', 'fa-IR', 'ur-PK', 'ps-AF', 'dv-MV', 'yi']) {
|
||||
assert.equal(mod.isRTLLocale(rtl), true, `expected RTL for ${rtl}`)
|
||||
}
|
||||
assert.equal(mod.isRTLLocale('en-US'), false)
|
||||
assert.equal(mod.isRTLLocale('zh-TW'), false)
|
||||
|
||||
// 6. LOW-5: resolveGuestLang structured preset lookup without punctuation splitting
|
||||
const zhGuest = mod.resolveGuestLang('zh-CN', 'zh-Hans:0')
|
||||
assert.ok(zhGuest.label.length > 0 && zhGuest.detail && zhGuest.detail.length > 0)
|
||||
|
||||
// 7. HIGH-1: Theme seed token derivation enforces WCAG 2.1 AA contrast on bright vs dark accents
|
||||
const hslContrast = (hslStr, surfaceLum) => {
|
||||
const m = hslStr.match(/hsl\(\s*(\d+)\s+(\d+)%\s+(\d+)%\s*\)/)
|
||||
assert.ok(m, `unexpected hsl string: ${hslStr}`)
|
||||
const h = Number(m[1]), s = Number(m[2]) / 100, l = Number(m[3]) / 100
|
||||
const c = (1 - Math.abs(2 * l - 1)) * s
|
||||
const hp = (h % 360) / 60
|
||||
const x = c * (1 - Math.abs((hp % 2) - 1))
|
||||
const [r1, g1, b1] = hp < 1 ? [c, x, 0] : hp < 2 ? [x, c, 0] : hp < 3 ? [0, c, x] : hp < 4 ? [0, x, c] : hp < 5 ? [x, 0, c] : [c, 0, x]
|
||||
const mv = l - c / 2
|
||||
const lin = (v) => (v <= 0.04045 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4))
|
||||
const lum = 0.2126 * lin(r1 + mv) + 0.7152 * lin(g1 + mv) + 0.0722 * lin(b1 + mv)
|
||||
return (Math.max(lum, surfaceLum) + 0.05) / (Math.min(lum, surfaceLum) + 0.05)
|
||||
}
|
||||
const brightYellow = mod.deriveTokensFromSeeds({ accent: '#ffd60a' }, undefined, 'light')
|
||||
assert.equal(brightYellow['--accent-text'], '#1d1d1f')
|
||||
assert.ok(hslContrast(brightYellow['--accent-soft-text'], 0.92) >= 4.5, `yellow light contrast too low: ${brightYellow['--accent-soft-text']}`)
|
||||
|
||||
const pureBlueDark = mod.deriveTokensFromSeeds({ accent: '#0000ff' }, undefined, 'dark')
|
||||
assert.ok(hslContrast(pureBlueDark['--accent-soft-text'], 0.015) >= 4.5, `blue dark contrast too low: ${pureBlueDark['--accent-soft-text']}`)
|
||||
|
||||
const appleBlue = mod.deriveTokensFromSeeds({ accent: '#0071e3' }, undefined, 'dark')
|
||||
assert.equal(appleBlue['--accent-text'], '#ffffff')
|
||||
assert.ok(hslContrast(appleBlue['--accent-soft-text'], 0.015) >= 4.5, `appleBlue dark contrast too low: ${appleBlue['--accent-soft-text']}`)
|
||||
})
|
||||
|
||||
|
||||
test('VM keymap preserves preset bindings and isolates pending writes by VM', async () => {
|
||||
const source = fs.readFileSync(path.join(srcDir, 'components/SettingsModal.tsx'), 'utf8')
|
||||
const normalized = source.replaceAll('\r\n', '\n')
|
||||
const effects = normalized.slice(
|
||||
normalized.indexOf(' useEffect(() => {\n setKeymap(null)'),
|
||||
normalized.indexOf(' const updateDriveShares'),
|
||||
)
|
||||
const preset = normalized.match(/onChange=\{(\(preset\) => \{\n\s+if \(preset === keymap\.preset\)[\s\S]*?\n\s+\})\} \/>/)?.[1]
|
||||
assert.ok(effects.includes('const updateKeymap') && preset)
|
||||
const { render } = await loadBundledTS(`
|
||||
export function render({ detail, api, useEffect, window, activeVMNameRef, keymapWrite,
|
||||
keymapRevision, setKeymap, setKeymapErr, setKeymapBusy, parseAppError, keymap }) {
|
||||
const cat = 'input'
|
||||
const running = true
|
||||
${effects}
|
||||
return ${preset}
|
||||
}
|
||||
`)
|
||||
let finishWrite
|
||||
const writes = []
|
||||
const reads = []
|
||||
const state = {}
|
||||
let failRead = true
|
||||
const context = {
|
||||
api: {
|
||||
SetVMKeymap(name, req) {
|
||||
writes.push([name, req])
|
||||
return new Promise((resolve) => { finishWrite = resolve })
|
||||
},
|
||||
async GetVMKeymap(name) {
|
||||
reads.push(name)
|
||||
if (name === 'b' && failRead) throw Error('temporary')
|
||||
return { preset: 'off', bindings: {} }
|
||||
},
|
||||
},
|
||||
useEffect(effect) {
|
||||
const cleanup = effect()
|
||||
if (cleanup) this.cleanups.push(cleanup)
|
||||
},
|
||||
cleanups: [],
|
||||
window: { setInterval(refresh) { this.refresh = refresh }, clearInterval() {} },
|
||||
activeVMNameRef: { current: 'a' },
|
||||
keymapWrite: { current: new Set() },
|
||||
keymapRevision: { current: new Map() },
|
||||
setKeymap(value) { state.keymap = value },
|
||||
setKeymapErr(value) { state.error = value },
|
||||
setKeymapBusy(value) { state.busy = value },
|
||||
parseAppError: (error) => ({ summary: error.message }),
|
||||
}
|
||||
context.useEffect = context.useEffect.bind(context)
|
||||
const bindings = { lwin: 'lcmd' }
|
||||
const change = render({ ...context, detail: { name: 'a' }, keymap: { preset: 'win_to_cmd', bindings } })
|
||||
change('win_to_cmd')
|
||||
assert.deepEqual(writes, [])
|
||||
change('custom')
|
||||
assert.deepEqual(writes, [['a', { preset: 'custom', bindings }]])
|
||||
context.cleanups.pop()()
|
||||
context.activeVMNameRef.current = 'b'
|
||||
const changeB = render({ ...context, detail: { name: 'b' }, keymap: { preset: 'custom', bindings } })
|
||||
changeB('custom')
|
||||
assert.equal(writes.length, 1)
|
||||
assert.deepEqual(reads, ['a', 'b'])
|
||||
assert.equal(state.busy, false)
|
||||
await new Promise(setImmediate)
|
||||
assert.equal(state.error, 'temporary')
|
||||
failRead = false
|
||||
await context.window.refresh()
|
||||
assert.equal(state.error, '')
|
||||
finishWrite({ preset: 'custom', bindings })
|
||||
await new Promise(setImmediate)
|
||||
assert.deepEqual(state.keymap, { preset: 'off', bindings: {} })
|
||||
})
|
||||
@@ -0,0 +1,52 @@
|
||||
// macOS UI lives under src/macos so it can leave the app as a plugin. Host
|
||||
// files may import from it only while listed below; the test fails when a new
|
||||
// file starts importing it and when a listed file stops, so the list only
|
||||
// shrinks (same ratchet as internal/archtest on the Go side).
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import ts from 'typescript'
|
||||
|
||||
const srcDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'src')
|
||||
const macosDir = path.join(srcDir, 'macos')
|
||||
|
||||
const MACOS_IMPORTERS = {
|
||||
'App.tsx': 'mounts the installers page and online-recovery dialog; macOS release names in the VM list',
|
||||
'components/Sidebar.tsx': 'macOS version art next to each VM',
|
||||
'components/VMPage.tsx': 'macOS version art in the VM header',
|
||||
}
|
||||
|
||||
function walk(dir) {
|
||||
const out = []
|
||||
for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const p = path.join(dir, e.name)
|
||||
if (e.isDirectory()) {
|
||||
if (p !== macosDir) out.push(...walk(p))
|
||||
} else if (/\.(?:[cm]?[jt]s|[jt]sx)$/.test(e.name)) {
|
||||
out.push(p)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
test('host frontend reaches src/macos only from listed files', () => {
|
||||
const importers = new Set()
|
||||
for (const file of walk(srcDir)) {
|
||||
const text = fs.readFileSync(file, 'utf8')
|
||||
for (const { fileName } of ts.preProcessFile(text, true, true).importedFiles) {
|
||||
let target
|
||||
if (fileName.startsWith('.')) target = path.resolve(path.dirname(file), fileName)
|
||||
else if (fileName.startsWith('/src/')) target = path.resolve(srcDir, fileName.slice(5))
|
||||
else continue
|
||||
if (target === macosDir || target.startsWith(macosDir + path.sep)) {
|
||||
importers.add(path.relative(srcDir, file).split(path.sep).join('/'))
|
||||
}
|
||||
}
|
||||
}
|
||||
const unexpected = [...importers].filter((f) => !(f in MACOS_IMPORTERS)).sort()
|
||||
const stale = Object.keys(MACOS_IMPORTERS).filter((f) => !importers.has(f)).sort()
|
||||
assert.deepEqual(unexpected, [], `host files import src/macos without being listed in MACOS_IMPORTERS: ${unexpected.join(', ')}`)
|
||||
assert.deepEqual(stale, [], `listed files no longer import src/macos; remove them from MACOS_IMPORTERS: ${stale.join(', ')}`)
|
||||
})
|
||||
@@ -0,0 +1,396 @@
|
||||
// Guards the AGENTS.md rule forbidding empty catch blocks that silently turn
|
||||
// failures into successes. Covers JS/TS/JSX/TSX/MJS/CJS via the TypeScript AST
|
||||
// and PowerShell (.ps1/.psm1/.psd1) via a comment- and string-aware lexer.
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import ts from 'typescript'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const repoRoot = path.resolve(__dirname, '..', '..')
|
||||
|
||||
const JS_TS_EXTS = new Set(['.ts', '.tsx', '.mts', '.cts', '.js', '.jsx', '.mjs', '.cjs'])
|
||||
const PS_EXTS = new Set(['.ps1', '.psm1', '.psd1'])
|
||||
const SKIP_DIRS = new Set(['.git', '.debug', 'node_modules', 'dist', 'build', 'wailsjs'])
|
||||
|
||||
function scriptKindFor(filePath) {
|
||||
switch (path.extname(filePath).toLowerCase()) {
|
||||
case '.tsx': return ts.ScriptKind.TSX
|
||||
case '.ts':
|
||||
case '.mts':
|
||||
case '.cts': return ts.ScriptKind.TS
|
||||
case '.jsx': return ts.ScriptKind.JSX
|
||||
default: return ts.ScriptKind.JS
|
||||
}
|
||||
}
|
||||
|
||||
function isEmptyBlock(block) {
|
||||
return ts.isBlock(block) && block.statements.every((stmt) => ts.isEmptyStatement(stmt))
|
||||
}
|
||||
|
||||
function isEmptyFunctionBody(expr) {
|
||||
let current = expr
|
||||
while (ts.isParenthesizedExpression(current)) current = current.expression
|
||||
if (ts.isArrowFunction(current) || ts.isFunctionExpression(current)) {
|
||||
return isEmptyBlock(current.body)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function getCalleeMethodName(callee) {
|
||||
if (ts.isPropertyAccessExpression(callee)) return callee.name.text
|
||||
if (ts.isElementAccessExpression(callee) && ts.isStringLiteralLike(callee.argumentExpression)) {
|
||||
return callee.argumentExpression.text
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds empty `catch` clauses and empty Promise `.catch(...)` / `.then(_, ...)`
|
||||
* rejection callbacks in a JS/TS source string using the TypeScript AST.
|
||||
*/
|
||||
export function findEmptyCatchesInJS(sourceText, filePath = 'sample.ts') {
|
||||
const sf = ts.createSourceFile(filePath, sourceText, ts.ScriptTarget.Latest, true, scriptKindFor(filePath))
|
||||
const findings = []
|
||||
|
||||
const record = (node, kind) => {
|
||||
const pos = sf.getLineAndCharacterOfPosition(node.getStart(sf))
|
||||
findings.push({
|
||||
file: filePath,
|
||||
line: pos.line + 1,
|
||||
column: pos.character + 1,
|
||||
kind,
|
||||
})
|
||||
}
|
||||
|
||||
function visit(node) {
|
||||
if (ts.isCatchClause(node) && isEmptyBlock(node.block)) {
|
||||
record(node, 'empty-catch-clause')
|
||||
} else if (ts.isCallExpression(node)) {
|
||||
const method = getCalleeMethodName(node.expression)
|
||||
if (method === 'catch' && node.arguments.length >= 1 && isEmptyFunctionBody(node.arguments[0])) {
|
||||
record(node.arguments[0], 'empty-promise-catch')
|
||||
} else if (method === 'then' && node.arguments.length >= 2 && isEmptyFunctionBody(node.arguments[1])) {
|
||||
record(node.arguments[1], 'empty-promise-then-reject')
|
||||
}
|
||||
}
|
||||
ts.forEachChild(node, visit)
|
||||
}
|
||||
|
||||
visit(sf)
|
||||
return findings
|
||||
}
|
||||
|
||||
function tokenizePowerShell(sourceText) {
|
||||
const tokens = []
|
||||
let i = 0
|
||||
let line = 1
|
||||
let col = 1
|
||||
const len = sourceText.length
|
||||
|
||||
const advance = () => {
|
||||
const ch = sourceText[i++]
|
||||
if (ch === '\n') {
|
||||
line += 1
|
||||
col = 1
|
||||
} else {
|
||||
col += 1
|
||||
}
|
||||
return ch
|
||||
}
|
||||
|
||||
const atHereStringEnd = (quote) => {
|
||||
if (sourceText[i] !== quote || sourceText[i + 1] !== '@') return false
|
||||
return i === 0 || sourceText[i - 1] === '\n'
|
||||
}
|
||||
|
||||
while (i < len) {
|
||||
const ch = sourceText[i]
|
||||
const next = sourceText[i + 1]
|
||||
|
||||
// Whitespace
|
||||
if (ch === ' ' || ch === '\t' || ch === '\r' || ch === '\n') {
|
||||
advance()
|
||||
continue
|
||||
}
|
||||
|
||||
// Block comment <# ... #>
|
||||
if (ch === '<' && next === '#') {
|
||||
advance()
|
||||
advance()
|
||||
while (i < len && !(sourceText[i] === '#' && sourceText[i + 1] === '>')) advance()
|
||||
if (i < len) {
|
||||
advance()
|
||||
advance()
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// Line comment # ...
|
||||
if (ch === '#') {
|
||||
while (i < len && sourceText[i] !== '\n') advance()
|
||||
continue
|
||||
}
|
||||
|
||||
// Here-strings @' ... '@ and @" ... "@
|
||||
if (ch === '@' && (next === "'" || next === '"')) {
|
||||
const quote = next
|
||||
let look = i + 2
|
||||
while (look < len && (sourceText[look] === ' ' || sourceText[look] === '\t' || sourceText[look] === '\r')) look++
|
||||
if (look < len && sourceText[look] === '\n') {
|
||||
const startLine = line
|
||||
const startCol = col
|
||||
while (i <= look) advance()
|
||||
while (i < len && !atHereStringEnd(quote)) advance()
|
||||
if (i < len) {
|
||||
advance()
|
||||
advance()
|
||||
}
|
||||
tokens.push({ type: 'string', value: '', line: startLine, column: startCol })
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// Single-quoted string ('' escapes ')
|
||||
if (ch === "'") {
|
||||
const startLine = line
|
||||
const startCol = col
|
||||
advance()
|
||||
while (i < len) {
|
||||
if (sourceText[i] === "'") {
|
||||
advance()
|
||||
if (sourceText[i] === "'") {
|
||||
advance()
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
advance()
|
||||
}
|
||||
tokens.push({ type: 'string', value: '', line: startLine, column: startCol })
|
||||
continue
|
||||
}
|
||||
|
||||
// Double-quoted string (` escapes next char, "" escapes ")
|
||||
if (ch === '"') {
|
||||
const startLine = line
|
||||
const startCol = col
|
||||
advance()
|
||||
while (i < len) {
|
||||
if (sourceText[i] === '`') {
|
||||
advance()
|
||||
if (i < len) advance()
|
||||
continue
|
||||
}
|
||||
if (sourceText[i] === '"') {
|
||||
advance()
|
||||
if (sourceText[i] === '"') {
|
||||
advance()
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
advance()
|
||||
}
|
||||
tokens.push({ type: 'string', value: '', line: startLine, column: startCol })
|
||||
continue
|
||||
}
|
||||
|
||||
// Backtick escape outside strings
|
||||
if (ch === '`') {
|
||||
advance()
|
||||
if (i < len) advance()
|
||||
continue
|
||||
}
|
||||
|
||||
const startLine = line
|
||||
const startCol = col
|
||||
|
||||
// :: operator
|
||||
if (ch === ':' && next === ':') {
|
||||
advance()
|
||||
advance()
|
||||
tokens.push({ type: 'punct', value: '::', line: startLine, column: startCol })
|
||||
continue
|
||||
}
|
||||
|
||||
// Punctuation relevant to catch syntax
|
||||
if ('{}[];,.'.includes(ch)) {
|
||||
advance()
|
||||
tokens.push({ type: 'punct', value: ch, line: startLine, column: startCol })
|
||||
continue
|
||||
}
|
||||
|
||||
// Word / identifier / parameter (e.g. -catch, catch)
|
||||
if (/[A-Za-z_-]/.test(ch)) {
|
||||
let word = ''
|
||||
while (i < len && /[A-Za-z0-9_-]/.test(sourceText[i])) word += advance()
|
||||
tokens.push({ type: 'word', value: word, line: startLine, column: startCol })
|
||||
continue
|
||||
}
|
||||
|
||||
// Any other token
|
||||
advance()
|
||||
tokens.push({ type: 'other', value: ch, line: startLine, column: startCol })
|
||||
}
|
||||
|
||||
return tokens
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds empty `catch` blocks (including comment-only and semicolon-only blocks,
|
||||
* with or without `[Type]` exception filters) in a PowerShell script.
|
||||
*/
|
||||
export function findEmptyCatchesInPowerShell(sourceText, filePath = 'sample.ps1') {
|
||||
const tokens = tokenizePowerShell(sourceText)
|
||||
const findings = []
|
||||
|
||||
for (let idx = 0; idx < tokens.length; idx++) {
|
||||
const tok = tokens[idx]
|
||||
if (tok.type !== 'word' || tok.value.toLowerCase() !== 'catch') continue
|
||||
const prev = tokens[idx - 1]
|
||||
if (prev && (prev.value === '.' || prev.value === '::')) continue
|
||||
|
||||
// Skip optional comma-separated type filters: catch [TypeA], [TypeB] { ... }
|
||||
let cursor = idx + 1
|
||||
while (cursor < tokens.length && tokens[cursor].value === '[') {
|
||||
let depth = 0
|
||||
while (cursor < tokens.length) {
|
||||
if (tokens[cursor].value === '[') depth++
|
||||
else if (tokens[cursor].value === ']') {
|
||||
depth--
|
||||
if (depth === 0) {
|
||||
cursor++
|
||||
break
|
||||
}
|
||||
}
|
||||
cursor++
|
||||
}
|
||||
if (cursor < tokens.length && tokens[cursor].value === ',') cursor++
|
||||
else break
|
||||
}
|
||||
|
||||
if (cursor >= tokens.length || tokens[cursor].value !== '{') continue
|
||||
|
||||
// Scan block body until matching '}'
|
||||
let bodyCursor = cursor + 1
|
||||
let empty = true
|
||||
while (bodyCursor < tokens.length && tokens[bodyCursor].value !== '}') {
|
||||
if (tokens[bodyCursor].value !== ';') {
|
||||
empty = false
|
||||
break
|
||||
}
|
||||
bodyCursor++
|
||||
}
|
||||
if (empty && bodyCursor < tokens.length && tokens[bodyCursor].value === '}') {
|
||||
findings.push({
|
||||
file: filePath,
|
||||
line: tok.line,
|
||||
column: tok.column,
|
||||
kind: 'empty-ps-catch',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return findings
|
||||
}
|
||||
|
||||
function walkFiles(dir, out = []) {
|
||||
if (!fs.existsSync(dir)) return out
|
||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
if (SKIP_DIRS.has(entry.name)) continue
|
||||
const full = path.join(dir, entry.name)
|
||||
if (entry.isDirectory()) walkFiles(full, out)
|
||||
else out.push(full)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
test('detector self-test: catches all empty JS/TS catch forms and allows handled catches', () => {
|
||||
const bad = [
|
||||
'try { a() } catch {}',
|
||||
'try { a() } catch (e) {}',
|
||||
'try { a() } catch { /* comment only */ }',
|
||||
'try { a() } catch (e) {\n // comment only\n}',
|
||||
'try { a() } catch { ; ; }',
|
||||
'p.catch(() => {})',
|
||||
'p?.catch((e) => { /* noop */ })',
|
||||
'p["catch"](function () {})',
|
||||
'p.catch(async () => { ; })',
|
||||
'p.then(ok, () => {})',
|
||||
'p.then(ok, (err) => { // noop\n})',
|
||||
].join('\n')
|
||||
|
||||
const badFindings = findEmptyCatchesInJS(bad, 'bad.ts')
|
||||
assert.equal(badFindings.length, 11, `expected 11 findings, got ${JSON.stringify(badFindings)}`)
|
||||
|
||||
const good = [
|
||||
'const text = "try { a() } catch {} .catch(() => {})"',
|
||||
'// try { a() } catch {}',
|
||||
'try { a() } catch (e) { console.warn(e) }',
|
||||
'try { a() } catch { return fallback }',
|
||||
'p.catch((e) => console.warn(e))',
|
||||
'p.catch(() => null)',
|
||||
'p.then(ok, (e) => handle(e))',
|
||||
].join('\n')
|
||||
|
||||
assert.deepEqual(findEmptyCatchesInJS(good, 'good.ts'), [])
|
||||
})
|
||||
|
||||
test('detector self-test: catches empty PowerShell catch blocks and ignores strings/comments', () => {
|
||||
const bad = [
|
||||
'try { foo } catch {}',
|
||||
'try { foo } Catch { # comment only\n}',
|
||||
'try { foo } catch { <# block comment #> ; }',
|
||||
'try { foo } catch [System.IO.IOException], [System.Exception] {}',
|
||||
].join('\n')
|
||||
|
||||
const badFindings = findEmptyCatchesInPowerShell(bad, 'bad.ps1')
|
||||
assert.equal(badFindings.length, 4, `expected 4 findings, got ${JSON.stringify(badFindings)}`)
|
||||
|
||||
const good = [
|
||||
'# try { foo } catch {}',
|
||||
'<# try { foo } catch {} #>',
|
||||
'$s1 = "try { foo } catch {}"',
|
||||
"$s2 = 'try { foo } catch {}'",
|
||||
'$here = @"\ntry { foo } catch {}\n"@',
|
||||
'$obj.catch { }',
|
||||
'try { foo } catch { Write-Warning $_ }',
|
||||
'try { foo } catch [System.Exception] { throw }',
|
||||
].join('\n')
|
||||
|
||||
assert.deepEqual(findEmptyCatchesInPowerShell(good, 'good.ps1'), [])
|
||||
})
|
||||
|
||||
test('repository has zero empty catch blocks across frontend/ and scripts/', () => {
|
||||
const roots = [path.join(repoRoot, 'frontend'), path.join(repoRoot, 'scripts')]
|
||||
const violations = []
|
||||
let scannedJS = 0
|
||||
let scannedPS = 0
|
||||
|
||||
for (const root of roots) {
|
||||
for (const file of walkFiles(root)) {
|
||||
const ext = path.extname(file).toLowerCase()
|
||||
const rel = path.relative(repoRoot, file).split(path.sep).join('/')
|
||||
if (JS_TS_EXTS.has(ext)) {
|
||||
scannedJS += 1
|
||||
const text = fs.readFileSync(file, 'utf8')
|
||||
violations.push(...findEmptyCatchesInJS(text, rel))
|
||||
} else if (PS_EXTS.has(ext)) {
|
||||
scannedPS += 1
|
||||
const text = fs.readFileSync(file, 'utf8')
|
||||
violations.push(...findEmptyCatchesInPowerShell(text, rel))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert.ok(scannedJS > 0, 'expected to scan at least one JS/TS file')
|
||||
assert.ok(scannedPS > 0, 'expected to scan at least one PowerShell file')
|
||||
assert.deepEqual(
|
||||
violations.map((v) => `${v.file}:${v.line}:${v.column} (${v.kind})`),
|
||||
[],
|
||||
`Empty catch blocks found (forbidden by AGENTS.md):\n${violations.map((v) => ` - ${v.file}:${v.line}:${v.column} (${v.kind})`).join('\n')}`,
|
||||
)
|
||||
})
|
||||
+394
-120
@@ -3,25 +3,28 @@ import React, { Suspense, lazy, useCallback, useEffect, useRef, useState } from
|
||||
import type { WizardDraft } from './components/CreateWizard'
|
||||
import { DeleteDialog } from './components/DeleteDialog'
|
||||
import { CloneDialog } from './components/CloneDialog'
|
||||
import { OnlineRecoveryDialog } from './components/OnlineRecoveryDialog'
|
||||
import { OnlineRecoveryDialog } from './macos/OnlineRecoveryDialog'
|
||||
import { SendTextDialog } from './components/SendTextDialog'
|
||||
import type { ThemeMode } from './components/AppSettingsPage'
|
||||
import { LogPanel, LogTab } from './components/LogPanel'
|
||||
import { TitleMenus } from './components/TitleMenus'
|
||||
import { UpdateCapsule, UpdatePhase } from './components/UpdateCapsule'
|
||||
import { DataRootReadOnly } from './components/DataRootReadOnly'
|
||||
import { ABOUT_ID, HOST_ID, INSTALLERS_ID, PAGE_IDS, PLUGINS_ID, SETTINGS_ID, Sidebar } from './components/Sidebar'
|
||||
import { VMAction, VMPage } from './components/VMPage'
|
||||
import { I18nKey, resolveActiveLocale, setPluginLocales, t } from './i18n'
|
||||
import { buildFallbackChain, I18nKey, localeDir, parseAppError, resolveActiveLocale, setPluginLocales, t } from './i18n'
|
||||
import { defaultGuestLang, recommendedMemoryGB, recommendedResolution } from './lib/format'
|
||||
import { LogLine, appendLog } from './lib/logs'
|
||||
import { macOSMajor } from './lib/macosRelease'
|
||||
import { currentTask, finishedTaskTTL, pruneFinishedTasks, upsertTask } from './lib/tasks'
|
||||
import { applyActiveTheme, type UIStateSnapshot } from './lib/themeEngine'
|
||||
import { latestVMStats } from './lib/vmStats'
|
||||
import { ActiveThemePayload, AppState, AppUpdateInfo, CachedInstaller, CreateOpts, Locale, PluginUIContributions, RuntimeSource, Task, VMDetail } from './types'
|
||||
import { macOSMajor } from './macos/macosRelease'
|
||||
import { currentTask, finishedTaskTTL, isActiveInstallerTask, pruneFinishedTasks, upsertTask } from './lib/tasks'
|
||||
import { applyActiveLocaleFonts, applyActiveTheme, disposeActiveThemeAndLocaleFonts, emitThemeEvent, notifyInteractiveThemeState, type UIStateSnapshot } from './lib/themeEngine'
|
||||
import { latestVMStatsWithDriver, refreshSubscribedVMStats, refreshVMStatsWithDriver } from './lib/vmStats'
|
||||
import { vmRefKey } from './lib/vmRef'
|
||||
import { ActiveThemePayload, AppState, AppUpdateInfo, CachedInstaller, CreateOpts, Locale, PluginUIContributions, Task, VMDetail } from './types'
|
||||
import { Button, Tip, TooltipProvider } from './ui/controls'
|
||||
import { Modal } from './ui/dialog'
|
||||
import { ConfirmDialog, Modal } from './ui/dialog'
|
||||
import { Toaster, useToasts } from './ui/toast'
|
||||
import { BrandMark, ThemeDecorations, ThemeVisualsProvider } from './ui/themeVisuals'
|
||||
import { api, events, OnFileDrop, OnFileDropOff, WindowMinimise, WindowToggleMaximise } from './wails'
|
||||
|
||||
// Opened on demand, so each is its own chunk and stays out of the startup
|
||||
@@ -32,16 +35,21 @@ const SettingsModal = lazy(() => import('./components/SettingsModal').then((m) =
|
||||
const AffinityDialog = lazy(() => import('./components/AffinityDialog').then((m) => ({ default: m.AffinityDialog })))
|
||||
const Setup = lazy(() => import('./components/Setup').then((m) => ({ default: m.Setup })))
|
||||
const HostView = lazy(() => import('./components/HostView').then((m) => ({ default: m.HostView })))
|
||||
const InstallersPage = lazy(() => import('./components/InstallersPage').then((m) => ({ default: m.InstallersPage })))
|
||||
const ImagesPage = lazy(() => import('./components/ImagesPage').then((m) => ({ default: m.ImagesPage })))
|
||||
const InstallersPage = lazy(() => import('./macos/InstallersPage').then((m) => ({ default: m.InstallersPage })))
|
||||
const PluginsPage = lazy(() => import('./components/PluginsPage').then((m) => ({ default: m.PluginsPage })))
|
||||
const AppSettingsPage = lazy(() => import('./components/AppSettingsPage').then((m) => ({ default: m.AppSettingsPage })))
|
||||
const AboutPage = lazy(() => import('./components/AboutPage').then((m) => ({ default: m.AboutPage })))
|
||||
|
||||
const errText = (e: unknown) => String(e).replace(/^Error:\s*/, '')
|
||||
const errText = (e: unknown) => parseAppError(e).summary
|
||||
|
||||
const failKey: Record<VMAction, I18nKey> = {
|
||||
start: 'failStart',
|
||||
suspend: 'failSuspend',
|
||||
resume: 'failResume',
|
||||
discardSuspend: 'failDiscardSuspend',
|
||||
focus: 'failFocus',
|
||||
fullscreen: 'failFullscreen',
|
||||
screenshot: 'failScreenshot',
|
||||
stop: 'failStop',
|
||||
forceStop: 'failStop',
|
||||
@@ -71,7 +79,7 @@ export const App: React.FC = () => {
|
||||
const stateReady = !!state
|
||||
useEffect(() => {
|
||||
if (!stateReady) return
|
||||
const check = () => { api.CheckAppUpdate(false).then(setAppUpdate).catch(() => {}) }
|
||||
const check = () => { api.CheckAppUpdate(false).then(setAppUpdate).catch((e) => console.warn('[app] CheckAppUpdate failed:', e)) }
|
||||
check()
|
||||
const id = window.setInterval(check, 6 * 60 * 60 * 1000)
|
||||
return () => window.clearInterval(id)
|
||||
@@ -81,20 +89,25 @@ export const App: React.FC = () => {
|
||||
const [showWizard, setShowWizard] = useState(false)
|
||||
const [wizardDraft, setWizardDraft] = useState<WizardDraft | null>(null)
|
||||
const [showSettings, setShowSettings] = useState(false)
|
||||
const [affinityTarget, setAffinityTarget] = useState<string | null>(null)
|
||||
const [affinityTarget, setAffinityTarget] = useState<{ name: string; driverID: string } | null>(null)
|
||||
const [affinityVersion, setAffinityVersion] = useState(0)
|
||||
const [deleteTarget, setDeleteTarget] = useState<string | null>(null)
|
||||
const [cloneSource, setCloneSource] = useState<string | null>(null)
|
||||
const [discardSuspendTarget, setDiscardSuspendTarget] = useState<string | null>(null)
|
||||
const [cloneSource, setCloneSource] = useState<{ name: string; driverID: string } | null>(null)
|
||||
const [onlineRecoveryTarget, setOnlineRecoveryTarget] = useState<string | null>(null)
|
||||
const [sendTextTarget, setSendTextTarget] = useState<string | null>(null)
|
||||
const [busy, setBusy] = useState<Record<string, VMAction>>({})
|
||||
const busyOpsRef = useRef<Map<string, Map<number, VMAction>>>(new Map())
|
||||
const nextBusyTokenRef = useRef(0)
|
||||
const [dropping, setDropping] = useState(false)
|
||||
const [loadError, setLoadError] = useState('')
|
||||
const [themeMode, setThemeModeState] = useState<ThemeMode>(() => {
|
||||
try {
|
||||
const saved = localStorage.getItem('reims-go-theme')
|
||||
if (saved === 'dark' || saved === 'light') return saved
|
||||
} catch {}
|
||||
} catch (e) {
|
||||
console.warn('[app] read theme preference failed:', e)
|
||||
}
|
||||
return 'system'
|
||||
})
|
||||
const [sysDark, setSysDark] = useState<boolean>(() =>
|
||||
@@ -151,7 +164,9 @@ export const App: React.FC = () => {
|
||||
try {
|
||||
if (mode === 'system') localStorage.removeItem('reims-go-theme')
|
||||
else localStorage.setItem('reims-go-theme', mode)
|
||||
} catch {}
|
||||
} catch (e) {
|
||||
console.warn('[app] persist theme preference failed:', e)
|
||||
}
|
||||
}
|
||||
|
||||
const toggleTheme = () => {
|
||||
@@ -164,7 +179,7 @@ export const App: React.FC = () => {
|
||||
try { return localStorage.getItem('reims-go-sidebar') !== 'hidden' } catch { return true }
|
||||
})
|
||||
const toggleSidebar = () => setSidebarOpen((open) => {
|
||||
try { localStorage.setItem('reims-go-sidebar', open ? 'hidden' : 'shown') } catch {}
|
||||
try { localStorage.setItem('reims-go-sidebar', open ? 'hidden' : 'shown') } catch (e) { console.warn('[app] persist sidebar state failed:', e) }
|
||||
return !open
|
||||
})
|
||||
|
||||
@@ -190,8 +205,8 @@ export const App: React.FC = () => {
|
||||
setLoadError('')
|
||||
setSelected((cur) => {
|
||||
if (PAGE_IDS.includes(cur)) return cur
|
||||
if ((s.vms ?? []).some((v) => v.name === cur)) return cur
|
||||
return s.vms && s.vms.length > 0 ? s.vms[0].name : HOST_ID
|
||||
if ((s.vms ?? []).some((v) => vmRefKey(v) === cur || v.name === cur)) return cur
|
||||
return s.vms && s.vms.length > 0 ? vmRefKey(s.vms[0]) : HOST_ID
|
||||
})
|
||||
if (reloadDetail) setDetailRevision((revision) => revision + 1)
|
||||
} catch (e) {
|
||||
@@ -200,11 +215,22 @@ export const App: React.FC = () => {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
refresh()
|
||||
Promise.all([
|
||||
api.GetPluginUIContributions().catch(() => null),
|
||||
refresh(),
|
||||
]).then(([pui]) => {
|
||||
if (pui) {
|
||||
setPluginLocales(pui.locales)
|
||||
setPluginUI(pui)
|
||||
} else {
|
||||
setPluginUI({} as PluginUIContributions)
|
||||
}
|
||||
})
|
||||
events.emitUIPong()
|
||||
const offPing = events.onUIPing(() => { events.emitUIPong() })
|
||||
const offState = events.onStateChanged(() => {
|
||||
refresh(true)
|
||||
refreshSubscribedVMStats()
|
||||
setThemeRevision((r) => r + 1)
|
||||
})
|
||||
// Logs never pop the panel open (docs/design-guidelines.md §7.3); errors only bump a badge.
|
||||
@@ -216,12 +242,11 @@ export const App: React.FC = () => {
|
||||
}
|
||||
setLogLines((prev) => appendLog(prev, entry))
|
||||
})
|
||||
api.GetPluginUIContributions().then(setPluginUI).catch(() => {})
|
||||
api.GetActiveTheme().then(setActiveThemePayload).catch(() => {})
|
||||
api.GetActiveTheme().then(setActiveThemePayload).catch((e) => console.warn('[app] GetActiveTheme failed:', e))
|
||||
// Tasks: seed from the backend, then follow events.
|
||||
api.GetTasks().then((list) => {
|
||||
setTaskMap((prev) => (list ?? []).reduce(upsertTask, prev))
|
||||
}).catch(() => {})
|
||||
}).catch((e) => console.warn('[app] GetTasks failed:', e))
|
||||
const offTask = events.onTask((task) => onTaskRef.current(task))
|
||||
const onVisibility = () => {
|
||||
if (!document.hidden) {
|
||||
@@ -250,15 +275,15 @@ export const App: React.FC = () => {
|
||||
}, [refresh])
|
||||
|
||||
const vms = state?.vms ?? []
|
||||
const runningVMCount = vms.filter((v) => (state?.transitions[v.name] ?? v.state) === 'running').length
|
||||
const runningVMCount = vms.filter((v) => (state?.transitions[vmRefKey(v)] ?? v.state) === 'running').length
|
||||
const selectedVM = !PAGE_IDS.includes(selected)
|
||||
? vms.find((v) => v.name === selected)
|
||||
? vms.find((v) => vmRefKey(v) === selected) ?? vms.find((v) => v.name === selected)
|
||||
: undefined
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedVM) { setDetail(null); return }
|
||||
api.GetVMDetail(selectedVM.name).then(setDetail).catch(() => setDetail(null))
|
||||
}, [selectedVM?.name, selectedVM?.state, state?.transitions[selectedVM?.name ?? ''], detailRevision])
|
||||
}, [selectedVM?.name, selectedVM?.driver_id, selectedVM?.state, state?.transitions[selectedVM ? vmRefKey(selectedVM) : ''], detailRevision])
|
||||
|
||||
// Display names (the VM's note, .reims-go-note): shown in place of the VM's
|
||||
// name in the sidebar and page title; the name itself stays the identifier.
|
||||
@@ -269,7 +294,7 @@ export const App: React.FC = () => {
|
||||
for (const vm of vms) {
|
||||
api.GetVMNote(vm.name)
|
||||
.then((n) => { if (live) setDisplayNames((m) => ({ ...m, [vm.name]: (n ?? '').trim() })) })
|
||||
.catch(() => {})
|
||||
.catch((e) => console.warn('[app] GetVMNote failed:', vm.name, e))
|
||||
}
|
||||
return () => { live = false }
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
@@ -283,7 +308,7 @@ export const App: React.FC = () => {
|
||||
for (const vm of vms) {
|
||||
api.GetVMMacOS(vm.name)
|
||||
.then((r) => { if (live) setReleases((m) => ({ ...m, [vm.name]: (r ?? '').trim() })) })
|
||||
.catch(() => {})
|
||||
.catch((e) => console.warn('[app] GetVMMacOS failed:', vm.name, e))
|
||||
}
|
||||
return () => { live = false }
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
@@ -294,15 +319,31 @@ export const App: React.FC = () => {
|
||||
// Live VM stats are polled by lib/vmStats.ts and read where they are shown
|
||||
// (VMPage), so a 3-second tick no longer re-renders the whole App.
|
||||
|
||||
setPluginLocales(pluginUI?.locales)
|
||||
const locale: Locale = resolveActiveLocale(state?.config.locale, pluginUI?.locales)
|
||||
const lastPluginLocalesRef = useRef<typeof pluginUI>(undefined)
|
||||
if (lastPluginLocalesRef.current !== pluginUI) {
|
||||
lastPluginLocalesRef.current = pluginUI
|
||||
setPluginLocales(pluginUI?.locales)
|
||||
}
|
||||
const locale: Locale = resolveActiveLocale(state?.config.locale, pluginUI?.locales, state?.detected_locale)
|
||||
const dir = localeDir(locale)
|
||||
useEffect(() => {
|
||||
document.documentElement.lang = locale
|
||||
}, [locale])
|
||||
const html = document.documentElement
|
||||
html.lang = locale === 'en-XA' ? 'en' : locale
|
||||
html.dir = dir
|
||||
html.dataset.locale = locale
|
||||
const chain = buildFallbackChain(locale, pluginUI?.locales)
|
||||
const fontPack = chain
|
||||
.map((step) => pluginUI?.locales?.find((p) => p.locale === step))
|
||||
.find((p) => p?.fonts && p.fonts.length > 0)
|
||||
applyActiveLocaleFonts(fontPack?.fonts)
|
||||
}, [locale, dir, pluginUI?.locales])
|
||||
|
||||
useEffect(() => () => { disposeActiveThemeAndLocaleFonts() }, [])
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const effectiveState = selectedVM ? (state?.transitions[selectedVM.name] ?? selectedVM.state) : ''
|
||||
const pending = selectedVM ? (state?.pending_changes[selectedVM.name] ?? []) : []
|
||||
const effectiveState = selectedVM ? (state?.transitions[vmRefKey(selectedVM)] ?? selectedVM.state) : ''
|
||||
const pending = selectedVM ? (state?.pending_changes[vmRefKey(selectedVM)] ?? []) : []
|
||||
const hostReady = !!state && state.host.whpx === 'ready' && !!state.active_runtime
|
||||
const canSuspend = state?.can_suspend ?? false
|
||||
|
||||
onTaskRef.current = (task: Task) => {
|
||||
if (task.kind === 'app-update' && task.status === 'failed' && !notifiedTasks.current.has(task.id)) {
|
||||
@@ -322,8 +363,10 @@ export const App: React.FC = () => {
|
||||
} else {
|
||||
toasts.push({ kind: 'ok', title: isRuntime ? tr('toastRuntimeReady', { v: task.result || task.subject }) : tr('toastInstallerReady', { v: task.subject }) })
|
||||
}
|
||||
} else if (task.status === 'canceled') toasts.push({ kind: 'ok', title: tr('toastDownloadPaused') })
|
||||
else fail(tr(isRuntime ? 'failRuntime' : isRecovery ? 'failAttachInstaller' : 'failDownload'), task.error ?? '')
|
||||
} else if (task.status === 'canceled') {
|
||||
const wasQueued = task.step.toLowerCase().includes('waiting for another download')
|
||||
toasts.push({ kind: 'ok', title: tr(wasQueued ? 'toastQueueCanceled' : 'toastDownloadPaused') })
|
||||
} else fail(tr(isRuntime ? 'failRuntime' : isRecovery ? 'failAttachInstaller' : 'failDownload'), task.error ?? '')
|
||||
}
|
||||
setTaskMap((prev) => upsertTask(prev, task))
|
||||
}
|
||||
@@ -338,8 +381,20 @@ export const App: React.FC = () => {
|
||||
const setChannel = (alpha: boolean) => {
|
||||
api.SetRuntimeChannel(alpha ? 'alpha' : 'stable').then(() => refresh()).catch((e) => fail(tr('failGeneric'), e))
|
||||
}
|
||||
const setSource = (source: RuntimeSource) => {
|
||||
api.SetRuntimeSource(source).then(() => refresh()).catch((e) => fail(tr('failGeneric'), e))
|
||||
const appUpdateChannel = state?.config.app_update_channel === 'alpha' || state?.config.app_update_channel === 'dev'
|
||||
? state.config.app_update_channel
|
||||
: 'stable'
|
||||
const setAppUpdateChannel = async (ch: 'stable' | 'alpha' | 'dev') => {
|
||||
await api.SetAppUpdateChannel(ch)
|
||||
setDismissedUpdate('')
|
||||
try { localStorage.removeItem('reims-go-update-dismissed') } catch (e) { console.warn('[app] clear dismissed update failed:', e) }
|
||||
await refresh()
|
||||
try {
|
||||
setAppUpdate(await api.CheckAppUpdate(true))
|
||||
} catch (e) {
|
||||
setAppUpdate(null)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
const cancelTask = (id: string) => { api.CancelTask(id).catch((e) => fail(tr('failGeneric'), e)) }
|
||||
|
||||
@@ -361,7 +416,7 @@ export const App: React.FC = () => {
|
||||
const dismissUpdate = () => {
|
||||
if (!appUpdate) return
|
||||
setDismissedUpdate(appUpdate.latest)
|
||||
try { localStorage.setItem('reims-go-update-dismissed', appUpdate.latest) } catch {}
|
||||
try { localStorage.setItem('reims-go-update-dismissed', appUpdate.latest) } catch (e) { console.warn('[app] persist dismissed update failed:', e) }
|
||||
}
|
||||
const [confirmUpdate, setConfirmUpdate] = useState(false)
|
||||
const [installingUpdate, setInstallingUpdate] = useState(false)
|
||||
@@ -381,13 +436,15 @@ export const App: React.FC = () => {
|
||||
// One toast after an update restart: the version changed since the last run.
|
||||
useEffect(() => {
|
||||
const v = state?.app_version
|
||||
if (!v) return
|
||||
if (!v || pluginUI === null) return
|
||||
try {
|
||||
const last = localStorage.getItem('reims-go-last-version')
|
||||
if (last && last !== v) toasts.push({ kind: 'ok', title: tr('updateDoneToast', { v }) })
|
||||
localStorage.setItem('reims-go-last-version', v)
|
||||
} catch {}
|
||||
}, [state?.app_version])
|
||||
} catch (e) {
|
||||
console.warn('[app] track last app version failed:', e)
|
||||
}
|
||||
}, [state?.app_version, pluginUI !== null])
|
||||
const importRuntime = async () => {
|
||||
try {
|
||||
const file = await api.PickFile(tr('importRuntime'), '*.tar.zst;*.zip')
|
||||
@@ -404,6 +461,9 @@ export const App: React.FC = () => {
|
||||
setSetupStage(s?.active_runtime ? null : 'runtime')
|
||||
}
|
||||
const showSetup = !!state && (state.needs_setup || setupStage === 'runtime')
|
||||
// The data folder opened read-only (internal/dataroot): nothing in it may be
|
||||
// changed, so the workspace gives way to a screen that explains why.
|
||||
const showReadOnly = !!state && !showSetup && !!state.data_root_status?.read_only
|
||||
|
||||
// UI Contract v1 read-only document state attributes (§5.1).
|
||||
const currentView = showSetup ? 'setup' : selected === HOST_ID ? 'host' : selected === INSTALLERS_ID ? 'installers' : selected === PLUGINS_ID ? 'plugins' : selected === SETTINGS_ID ? 'settings' : selected === ABOUT_ID ? 'about' : 'vm'
|
||||
@@ -412,6 +472,8 @@ export const App: React.FC = () => {
|
||||
const uiStateRef = useRef<UIStateSnapshot>({
|
||||
appearance: theme,
|
||||
motion: reducedMotion ? 'reduced' : 'full',
|
||||
locale,
|
||||
dir,
|
||||
view: currentView,
|
||||
vmName: selectedVM?.name ?? '',
|
||||
vmState: effectiveState,
|
||||
@@ -419,11 +481,13 @@ export const App: React.FC = () => {
|
||||
hasError: hasAnyError,
|
||||
sidebarCollapsed: !sidebarOpen,
|
||||
safeMode: !!state?.safe_mode,
|
||||
vms: vms.map((v) => ({ name: v.name, state: state?.transitions[v.name] ?? v.state })),
|
||||
vms: vms.map((v) => ({ name: v.name, state: state?.transitions[vmRefKey(v)] ?? v.state })),
|
||||
})
|
||||
uiStateRef.current = {
|
||||
appearance: theme,
|
||||
motion: reducedMotion ? 'reduced' : 'full',
|
||||
locale,
|
||||
dir,
|
||||
view: currentView,
|
||||
vmName: selectedVM?.name ?? '',
|
||||
vmState: effectiveState,
|
||||
@@ -431,7 +495,7 @@ export const App: React.FC = () => {
|
||||
hasError: hasAnyError,
|
||||
sidebarCollapsed: !sidebarOpen,
|
||||
safeMode: !!state?.safe_mode,
|
||||
vms: vms.map((v) => ({ name: v.name, state: state?.transitions[v.name] ?? v.state })),
|
||||
vms: vms.map((v) => ({ name: v.name, state: state?.transitions[vmRefKey(v)] ?? v.state })),
|
||||
}
|
||||
useEffect(() => {
|
||||
const el = document.documentElement
|
||||
@@ -441,12 +505,49 @@ export const App: React.FC = () => {
|
||||
el.dataset.hasError = String(hasAnyError)
|
||||
el.dataset.sidebarCollapsed = String(!sidebarOpen)
|
||||
el.dataset.safeMode = String(!!state?.safe_mode)
|
||||
}, [currentView, effectiveState, isBusyAny, hasAnyError, sidebarOpen, state?.safe_mode])
|
||||
notifyInteractiveThemeState(uiStateRef.current)
|
||||
}, [currentView, effectiveState, isBusyAny, hasAnyError, sidebarOpen, state?.safe_mode, locale, dir, theme])
|
||||
|
||||
// UI SDK event stream (ui-contract UI_CONTRACT_SDK_EVENTS). emitThemeEvent is
|
||||
// a no-op unless an interactive theme is loaded; payloads carry no paths.
|
||||
const selectedRef = selectedVM ? vmRefKey(selectedVM) : ''
|
||||
useEffect(() => {
|
||||
emitThemeEvent('view.changed', { view: currentView, vm: selectedRef })
|
||||
}, [currentView, selectedRef])
|
||||
const vmStatesRef = useRef<Record<string, string> | null>(null)
|
||||
useEffect(() => {
|
||||
const next: Record<string, string> = {}
|
||||
for (const v of vms) next[vmRefKey(v)] = state?.transitions[vmRefKey(v)] ?? v.state
|
||||
const prev = vmStatesRef.current
|
||||
vmStatesRef.current = next
|
||||
if (!prev) return
|
||||
for (const v of vms) {
|
||||
const key = vmRefKey(v)
|
||||
if (prev[key] !== undefined && prev[key] !== next[key]) {
|
||||
emitThemeEvent('vm.stateChanged', { vm: key, name: v.name, driver: v.driver_id ?? '', from: prev[key], to: next[key] })
|
||||
}
|
||||
}
|
||||
}, [vms, state?.transitions])
|
||||
const taskStatesRef = useRef<Record<string, { status: string; percent: number }> | null>(null)
|
||||
useEffect(() => {
|
||||
const prev = taskStatesRef.current
|
||||
const next: Record<string, { status: string; percent: number }> = {}
|
||||
for (const t of Object.values(taskMap)) next[t.id] = { status: t.status, percent: t.percent }
|
||||
taskStatesRef.current = next
|
||||
if (!prev) return
|
||||
for (const t of Object.values(taskMap)) {
|
||||
const was = prev[t.id]
|
||||
const info = { id: t.id, kind: t.kind, vm: t.vm ?? '', percent: t.percent }
|
||||
if (!was && t.status === 'running') emitThemeEvent('task.started', info)
|
||||
else if (was?.status === 'running' && t.status === 'running' && was.percent !== t.percent) emitThemeEvent('task.progress', info)
|
||||
if ((!was || was.status === 'running') && t.status !== 'running') emitThemeEvent('task.finished', { ...info, status: t.status })
|
||||
}
|
||||
}, [taskMap])
|
||||
|
||||
// Apply active theme pack (zero extra CSS for builtin default theme, §5.1 & §8.1).
|
||||
useEffect(() => {
|
||||
api.GetActiveTheme().then(setActiveThemePayload).catch(() => {})
|
||||
api.GetPluginUIContributions().then(setPluginUI).catch(() => {})
|
||||
api.GetActiveTheme().then(setActiveThemePayload).catch((e) => console.warn('[app] GetActiveTheme failed:', e))
|
||||
api.GetPluginUIContributions().then(setPluginUI).catch((e) => console.warn('[app] GetPluginUIContributions failed:', e))
|
||||
}, [themeRevision, state?.safe_mode])
|
||||
|
||||
useEffect(() => {
|
||||
@@ -457,7 +558,7 @@ export const App: React.FC = () => {
|
||||
{
|
||||
toggleSidebar,
|
||||
openSettings: () => setSelected(SETTINGS_ID),
|
||||
focusVMWindow: (vmName) => { void api.FocusVMWindow(vmName).catch(() => {}) },
|
||||
focusVMWindow: (vmName) => { void api.FocusVMWindow(vmName).catch((e) => console.warn('[theme] FocusVMWindow failed:', vmName, e)) },
|
||||
},
|
||||
)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
@@ -477,7 +578,8 @@ export const App: React.FC = () => {
|
||||
const loadVMLog = async (serial: boolean, name = selectedVM?.name) => {
|
||||
if (!name) return
|
||||
try {
|
||||
const text = await api.ReadVMLogs(name, serial)
|
||||
const logDriverID = vms.find((v) => v.name === name)?.driver_id ?? ''
|
||||
const text = await api.ReadVMLogsWithDriver(logDriverID, name, serial)
|
||||
if (serial) setSerialLog(text)
|
||||
else setQemuLog(text)
|
||||
} catch (e) {
|
||||
@@ -489,11 +591,64 @@ export const App: React.FC = () => {
|
||||
const loadSerial = (name?: string) => loadVMLog(true, name)
|
||||
const loadQemu = (name?: string) => loadVMLog(false, name)
|
||||
|
||||
const fail = (title: string, e: unknown) =>
|
||||
toasts.push({ kind: 'error', title, description: errText(e), action: { label: tr('viewLogs'), onClick: () => openLogs('app') } })
|
||||
const fail = (title: string, e: unknown) => {
|
||||
const parsed = parseAppError(e)
|
||||
toasts.push({
|
||||
kind: 'error',
|
||||
title,
|
||||
description: parsed.summary,
|
||||
errorCode: parsed.code,
|
||||
rawDetail: parsed.rawDetail,
|
||||
detailsLabel: tr('errRawDetailsToggle'),
|
||||
copyDetailsLabel: tr('errCopyDetails'),
|
||||
action: { label: tr('viewLogs'), onClick: () => openLogs('app') },
|
||||
})
|
||||
}
|
||||
|
||||
const activeVMBusy = (name: string): VMAction | undefined => {
|
||||
const ops = busyOpsRef.current.get(name)
|
||||
if (!ops || ops.size === 0) return undefined
|
||||
let latest: VMAction | undefined
|
||||
for (const act of ops.values()) latest = act
|
||||
return latest
|
||||
}
|
||||
|
||||
const syncBusyState = () => {
|
||||
const next: Record<string, VMAction> = Object.create(null)
|
||||
for (const [vmName, ops] of busyOpsRef.current) {
|
||||
let latest: VMAction | undefined
|
||||
for (const act of ops.values()) latest = act
|
||||
if (latest) next[vmName] = latest
|
||||
}
|
||||
setBusy(next)
|
||||
}
|
||||
|
||||
const beginVMBusy = (name: string, action: VMAction): number | null => {
|
||||
const ops = busyOpsRef.current.get(name)
|
||||
if (ops && ops.size > 0) {
|
||||
if (action !== 'forceStop') return null
|
||||
for (const act of ops.values()) {
|
||||
if (act === 'forceStop') return null
|
||||
}
|
||||
}
|
||||
const token = ++nextBusyTokenRef.current
|
||||
const vmOps = ops ?? new Map<number, VMAction>()
|
||||
vmOps.set(token, action)
|
||||
busyOpsRef.current.set(name, vmOps)
|
||||
syncBusyState()
|
||||
return token
|
||||
}
|
||||
|
||||
const endVMBusy = (name: string, token: number) => {
|
||||
const ops = busyOpsRef.current.get(name)
|
||||
if (!ops || !ops.delete(token)) return
|
||||
if (ops.size === 0) busyOpsRef.current.delete(name)
|
||||
syncBusyState()
|
||||
}
|
||||
|
||||
const runVMAction = async (name: string, action: VMAction, fn: () => Promise<void>, okTitle?: string) => {
|
||||
setBusy((b) => ({ ...b, [name]: action }))
|
||||
const token = beginVMBusy(name, action)
|
||||
if (token === null) return
|
||||
try {
|
||||
await fn()
|
||||
if (okTitle) toasts.push({ kind: 'ok', title: okTitle })
|
||||
@@ -501,17 +656,15 @@ export const App: React.FC = () => {
|
||||
} catch (e) {
|
||||
fail(tr(failKey[action]), e)
|
||||
} finally {
|
||||
setBusy((b) => {
|
||||
const { [name]: _, ...rest } = b
|
||||
return rest
|
||||
})
|
||||
endVMBusy(name, token)
|
||||
}
|
||||
}
|
||||
|
||||
// Paste as keystrokes: the backend refuses text a US keyboard can't type
|
||||
// (ErrNotTypeable in type_flow.go), which gets a message of its own.
|
||||
const typeInto = async (name: string, fn: () => Promise<number>) => {
|
||||
setBusy((b) => ({ ...b, [name]: 'type' }))
|
||||
const token = beginVMBusy(name, 'type')
|
||||
if (token === null) return
|
||||
try {
|
||||
const n = await fn()
|
||||
toasts.push({ kind: 'ok', title: tr('toastTyped', { n }) })
|
||||
@@ -522,10 +675,7 @@ export const App: React.FC = () => {
|
||||
fail(tr('failType'), e)
|
||||
}
|
||||
} finally {
|
||||
setBusy((b) => {
|
||||
const { [name]: _, ...rest } = b
|
||||
return rest
|
||||
})
|
||||
endVMBusy(name, token)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -543,7 +693,8 @@ export const App: React.FC = () => {
|
||||
return
|
||||
}
|
||||
}
|
||||
setBusy((b) => ({ ...b, [name]: 'attachInstaller' }))
|
||||
const token = beginVMBusy(name, 'attachInstaller')
|
||||
if (token === null) return
|
||||
try {
|
||||
const fileName = await api.AttachInstaller(name, picked)
|
||||
toasts.push({
|
||||
@@ -552,10 +703,7 @@ export const App: React.FC = () => {
|
||||
})
|
||||
await refresh()
|
||||
} finally {
|
||||
setBusy((b) => {
|
||||
const { [name]: _, ...rest } = b
|
||||
return rest
|
||||
})
|
||||
endVMBusy(name, token)
|
||||
}
|
||||
} catch (e) {
|
||||
fail(tr('failAttachInstaller'), e)
|
||||
@@ -563,14 +711,35 @@ export const App: React.FC = () => {
|
||||
}
|
||||
|
||||
const onVMActionFor = (name: string, action: VMAction, isRunning: boolean) => {
|
||||
const actionVM = vms.find((v) => vmRefKey(v) === name) ?? vms.find((v) => v.name === name)
|
||||
const actionDriverID = actionVM?.driver_id ?? ''
|
||||
name = actionVM?.name ?? name
|
||||
if (!canSuspend && (action === 'suspend' || action === 'resume')) return
|
||||
const activeBusy = activeVMBusy(name)
|
||||
if (
|
||||
activeBusy
|
||||
&& action !== 'openFolder'
|
||||
&& action !== 'openSharedFolder'
|
||||
&& (action !== 'forceStop' || activeBusy === 'forceStop')
|
||||
) {
|
||||
return
|
||||
}
|
||||
switch (action) {
|
||||
case 'start': return runVMAction(name, action, () => api.StartVM(name))
|
||||
case 'focus': return api.FocusVMWindow(name).catch((e) => fail(tr('failFocus'), e))
|
||||
case 'screenshot': return runVMAction(name, action, () => api.CopyVMScreenshot(name), tr('toastScreenshotCopied'))
|
||||
case 'stop': return runVMAction(name, action, () => api.StopVM(name, false), tr('toastStopped', { name }))
|
||||
case 'forceStop': return runVMAction(name, action, () => api.StopVM(name, true), tr('toastStopped', { name }))
|
||||
case 'restart': return runVMAction(name, action, () => api.RestartVM(name))
|
||||
case 'eject': return runVMAction(name, action, () => api.EjectInstaller(name), tr('toastEjected'))
|
||||
case 'start': return runVMAction(name, action, () => api.StartVMWithDriver(actionDriverID, name))
|
||||
case 'suspend': return runVMAction(name, action, () => api.SuspendVMWithDriver(actionDriverID, name), tr('toastSuspended', { name }))
|
||||
case 'resume': return runVMAction(name, action, () => api.ResumeVMWithDriver(actionDriverID, name), tr('toastResumed', { name }))
|
||||
case 'discardSuspend': return setDiscardSuspendTarget(actionVM ? vmRefKey(actionVM) : name)
|
||||
case 'focus': return api.FocusVMWindowWithDriver(actionDriverID, name).catch((e) => fail(tr('failFocus'), e))
|
||||
case 'fullscreen':
|
||||
return runVMAction(name, action, async () => {
|
||||
const isFullscreen = await api.ToggleVMFullscreenWithDriver(actionDriverID, name)
|
||||
refreshVMStatsWithDriver(actionDriverID, name, { window_fullscreen: isFullscreen })
|
||||
})
|
||||
case 'screenshot': return runVMAction(name, action, () => api.CopyVMScreenshotWithDriver(actionDriverID, name), tr('toastScreenshotCopied'))
|
||||
case 'stop': return runVMAction(name, action, () => api.StopVMWithDriver(actionDriverID, name, false), tr('toastStopped', { name }))
|
||||
case 'forceStop': return runVMAction(name, action, () => api.StopVMWithDriver(actionDriverID, name, true), tr('toastStopped', { name }))
|
||||
case 'restart': return runVMAction(name, action, () => api.RestartVMWithDriver(actionDriverID, name))
|
||||
case 'eject': return runVMAction(name, action, () => api.EjectInstallerWithDriver(actionDriverID, name), tr('toastEjected'))
|
||||
case 'finishInstall': return runVMAction(name, action, () => api.FinishInstall(name), tr(isRunning ? 'toastExitRecoveryNextStart' : 'toastInstallFinished'))
|
||||
case 'enterRecovery': return runVMAction(name, action, () => api.EnterRecovery(name), tr(isRunning ? 'toastEnterRecoveryNextStart' : 'toastEnterRecovery'))
|
||||
case 'attachInstaller': return attachInstaller(name, isRunning)
|
||||
@@ -581,47 +750,62 @@ export const App: React.FC = () => {
|
||||
case 'upgradeNVMe':
|
||||
return runVMAction(name, action, () => api.UpgradeDiskToNVMe(name), tr(isRunning ? 'toastNVMeNextStart' : 'toastNVMeReady'))
|
||||
case 'exportDiagnostics':
|
||||
return runVMAction(name, action, async () => { await api.ExportDiagnostics(name) }, tr('toastDiagExported'))
|
||||
return runVMAction(name, action, async () => { await api.ExportDiagnosticsWithDriver(actionDriverID, name) }, tr('toastDiagExported'))
|
||||
case 'cloneVM':
|
||||
return setCloneSource(name)
|
||||
return setCloneSource({ name, driverID: actionDriverID })
|
||||
case 'type': return typeInto(name, () => api.TypeClipboard(name))
|
||||
case 'sendText': return setSendTextTarget(name)
|
||||
case 'openFolder':
|
||||
return api.OpenVMFolder(name).catch((e) => fail(tr('failOpenFolder'), e))
|
||||
case 'delete': return setDeleteTarget(name)
|
||||
case 'delete': return setDeleteTarget(actionVM ? vmRefKey(actionVM) : name)
|
||||
}
|
||||
}
|
||||
|
||||
const onVMAction = (action: VMAction) => {
|
||||
if (!selectedVM) return
|
||||
return onVMActionFor(selectedVM.name, action, selectedVM.state === 'running')
|
||||
return onVMActionFor(vmRefKey(selectedVM), action, selectedVM.state === 'running')
|
||||
}
|
||||
|
||||
const onSidebarContextAction = (name: string, action: VMAction | 'settings') => {
|
||||
const vm = vms.find((v) => vmRefKey(v) === name) ?? vms.find((v) => v.name === name)
|
||||
const st = state?.transitions[vm ? vmRefKey(vm) : name] ?? vm?.state ?? 'stopped'
|
||||
if (action === 'settings') {
|
||||
if (st === 'suspended' || st === 'suspending' || st === 'resuming') return
|
||||
setSelected(name)
|
||||
api.GetVMDetail(name).then((d) => { setDetail(d); setShowSettings(true) }).catch((e) => fail(tr('failGeneric'), e))
|
||||
api.GetVMDetail(vm?.name ?? name).then((d) => { setDetail(d); setShowSettings(true) }).catch((e) => fail(tr('failGeneric'), e))
|
||||
return
|
||||
}
|
||||
const vm = vms.find((v) => v.name === name)
|
||||
const st = state?.transitions[name] ?? vm?.state ?? 'stopped'
|
||||
onVMActionFor(name, action, st === 'running')
|
||||
}
|
||||
|
||||
// The state's own main action (Start, or Show Window while running), shared by
|
||||
// The state's own main action (Start, Resume while suspended, or Show Window while running), shared by
|
||||
// Ctrl+Enter and a double-click in the sidebar.
|
||||
const primaryAction = (name: string) => {
|
||||
const vm = vms.find((v) => v.name === name)
|
||||
if (!vm || busy[name]) return
|
||||
const st = state?.transitions[name] ?? vm.state
|
||||
if (st === 'stopped') onVMActionFor(name, 'start', false)
|
||||
else if (st === 'running') onVMActionFor(name, 'focus', true)
|
||||
const vm = vms.find((v) => vmRefKey(v) === name) ?? vms.find((v) => v.name === name)
|
||||
if (!vm || activeVMBusy(vm.name)) return
|
||||
const key = vmRefKey(vm)
|
||||
const st = state?.transitions[key] ?? vm.state
|
||||
if (st === 'stopped') onVMActionFor(key, 'start', false)
|
||||
else if (st === 'suspended') onVMActionFor(key, 'resume', false)
|
||||
else if (st === 'running') onVMActionFor(key, 'focus', true)
|
||||
}
|
||||
|
||||
const confirmDelete = (keepFiles: boolean) => {
|
||||
const name = deleteTarget
|
||||
const target = deleteTarget
|
||||
setDeleteTarget(null)
|
||||
if (name) runVMAction(name, 'delete', () => api.DeleteVM(name, keepFiles), tr('toastDeleted', { name }))
|
||||
const targetVM = vms.find((v) => vmRefKey(v) === target) ?? vms.find((v) => v.name === target)
|
||||
const name = targetVM?.name ?? target
|
||||
const driverID = targetVM?.driver_id ?? ''
|
||||
if (name) runVMAction(name, 'delete', () => api.DeleteVMWithDriver(driverID, name, keepFiles), tr('toastDeleted', { name }))
|
||||
}
|
||||
|
||||
const confirmDiscardSuspend = () => {
|
||||
const target = discardSuspendTarget
|
||||
setDiscardSuspendTarget(null)
|
||||
const targetVM = vms.find((v) => vmRefKey(v) === target) ?? vms.find((v) => v.name === target)
|
||||
const name = targetVM?.name ?? target
|
||||
const driverID = targetVM?.driver_id ?? ''
|
||||
if (name) runVMAction(name, 'discardSuspend', () => api.DiscardSuspendWithDriver(driverID, name), tr('toastDiscardSuspend', { name }))
|
||||
}
|
||||
|
||||
const confirmOnlineRecovery = () => {
|
||||
@@ -637,9 +821,9 @@ export const App: React.FC = () => {
|
||||
const src = cloneSource
|
||||
setCloneSource(null)
|
||||
if (!src) return
|
||||
runVMAction(src, 'cloneVM', async () => {
|
||||
await api.CloneVMCoW(src, cloneName)
|
||||
setSelected(cloneName)
|
||||
runVMAction(src.name, 'cloneVM', async () => {
|
||||
await api.CloneVMCoWWithDriver(src.driverID, src.name, cloneName)
|
||||
setSelected(vmRefKey({ name: cloneName, driver_id: src.driverID }))
|
||||
}, tr('toastCloned', { name: cloneName }))
|
||||
}
|
||||
|
||||
@@ -697,11 +881,12 @@ export const App: React.FC = () => {
|
||||
}
|
||||
|
||||
// The wizard closes as soon as the create starts; progress lives in the status bar
|
||||
// (vm-create task). On failure the toast reopens the wizard with the same answers.
|
||||
// (vm-create task). On failure or cancel the toast offers returning to the wizard.
|
||||
const submitCreate = (payload: CreateOpts, draft: WizardDraft) => {
|
||||
setShowWizard(false)
|
||||
setWizardDraft(null)
|
||||
const name = payload.name
|
||||
const hasDownload = payload.source_mode === 'offline' || payload.source_mode === 'apple'
|
||||
api.CreateVM(payload)
|
||||
.then(() => {
|
||||
toasts.push({ kind: 'ok', title: tr('toastCreated', { name }) })
|
||||
@@ -710,10 +895,24 @@ export const App: React.FC = () => {
|
||||
})
|
||||
.catch((e) => {
|
||||
void refresh()
|
||||
if (/\bcontext canceled\b/i.test(errText(e))) {
|
||||
toasts.push({
|
||||
kind: 'ok',
|
||||
title: tr('toastCreateCanceled', { name }),
|
||||
description: hasDownload ? tr('toastCreateCanceledPartial') : undefined,
|
||||
action: { label: tr('backToEdit'), onClick: () => { setWizardDraft(draft); setShowWizard(true) } },
|
||||
})
|
||||
return
|
||||
}
|
||||
const parsed = parseAppError(e)
|
||||
toasts.push({
|
||||
kind: 'error',
|
||||
title: tr('failCreate', { name }),
|
||||
description: errText(e),
|
||||
description: parsed.summary,
|
||||
errorCode: parsed.code,
|
||||
rawDetail: parsed.rawDetail,
|
||||
detailsLabel: tr('errRawDetailsToggle'),
|
||||
copyDetailsLabel: tr('errCopyDetails'),
|
||||
action: { label: tr('backToEdit'), onClick: () => { setWizardDraft(draft); setShowWizard(true) } },
|
||||
})
|
||||
})
|
||||
@@ -735,15 +934,18 @@ export const App: React.FC = () => {
|
||||
|
||||
// Global shortcuts (docs/design-guidelines.md §6). Dialogs own the keyboard while open.
|
||||
const shortcutRef = useRef<(e: KeyboardEvent) => void>(() => {})
|
||||
const appDialogOpen = showSetup || showReadOnly || showWizard || showSettings || affinityTarget || deleteTarget ||
|
||||
discardSuspendTarget || sendTextTarget || cloneSource || onlineRecoveryTarget || confirmUpdate
|
||||
shortcutRef.current = (e: KeyboardEvent) => {
|
||||
if (!e.ctrlKey || e.altKey || e.metaKey) return
|
||||
if (showWizard || showSettings || affinityTarget || deleteTarget || sendTextTarget) return
|
||||
if (appDialogOpen) return
|
||||
if (document.querySelector('[role="dialog"], [role="alertdialog"]')) return
|
||||
const k = e.key.toLowerCase()
|
||||
if (k === 'n') { e.preventDefault(); openWizard() }
|
||||
else if (k === ',' && detail) { e.preventDefault(); setShowSettings(true) }
|
||||
else if (k === ',' && detail && effectiveState !== 'suspended' && effectiveState !== 'suspending' && effectiveState !== 'resuming') { e.preventDefault(); setShowSettings(true) }
|
||||
else if (k === 'l') { e.preventDefault(); toggleLogs() }
|
||||
else if (k === 'b' && !showSetup) { e.preventDefault(); toggleSidebar() }
|
||||
else if (k === 'enter' && selectedVM && !e.shiftKey) { e.preventDefault(); primaryAction(selectedVM.name) }
|
||||
else if (k === 'enter' && selectedVM && !e.shiftKey) { e.preventDefault(); primaryAction(vmRefKey(selectedVM)) }
|
||||
}
|
||||
useEffect(() => {
|
||||
const h = (e: KeyboardEvent) => shortcutRef.current(e)
|
||||
@@ -758,7 +960,11 @@ export const App: React.FC = () => {
|
||||
useEffect(() => {
|
||||
const offSelect = events.onTraySelectVM((name) => { setSelected(name) })
|
||||
const offNew = events.onTrayNewVM(() => { openWizardRef.current() })
|
||||
return () => { offSelect(); offNew() }
|
||||
const offDiscard = events.onTrayDiscardSuspend((name) => {
|
||||
setSelected(name)
|
||||
setDiscardSuspendTarget(name)
|
||||
})
|
||||
return () => { offSelect(); offNew(); offDiscard() }
|
||||
}, [])
|
||||
|
||||
// Native Wails file drag-and-drop delivery into the selected VM's shared folder.
|
||||
@@ -803,12 +1009,14 @@ export const App: React.FC = () => {
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<ThemeVisualsProvider payload={activeThemePayload}>
|
||||
<TooltipProvider>
|
||||
<div className="app-shell rg-p-shell">
|
||||
<div className="rg-layer rg-layer-background" data-rg-layer="layer.background" aria-hidden="true" />
|
||||
<header className="titlebar rg-p-titlebar" onDoubleClick={() => WindowToggleMaximise()}>
|
||||
{showSetup || !state ? (
|
||||
{showSetup || showReadOnly || !state ? (
|
||||
<div className="brand rg-p-brand">
|
||||
<img className="brand-mark" src="/logo.svg" alt="" aria-hidden="true" />
|
||||
<BrandMark className="brand-mark" />
|
||||
Reims-Go
|
||||
</div>
|
||||
) : (
|
||||
@@ -822,16 +1030,24 @@ export const App: React.FC = () => {
|
||||
canLight={canLight}
|
||||
canDark={canDark}
|
||||
onThemeMode={setThemeMode}
|
||||
vm={selectedVM ? { name: selectedVM.name, state: effectiveState, busy: !!busy[selectedVM.name] } : null}
|
||||
vm={selectedVM ? {
|
||||
name: selectedVM.name,
|
||||
driver_id: selectedVM.driver_id,
|
||||
state: effectiveState,
|
||||
busy: Object.prototype.hasOwnProperty.call(busy, selectedVM.name),
|
||||
graphics: detail?.name === selectedVM.name ? detail.graphics : undefined,
|
||||
canSuspend,
|
||||
} : null}
|
||||
onNewVM={openWizard}
|
||||
onVMAction={onVMAction}
|
||||
onVMSettings={() => { if (detail) setShowSettings(true) }}
|
||||
onVMSettings={() => { if (detail && effectiveState !== 'suspended') setShowSettings(true) }}
|
||||
onVMDelete={() => { if (selectedVM) setDeleteTarget(selectedVM.name) }}
|
||||
onNavigate={setSelected}
|
||||
onOpenURL={(url) => { api.OpenURL(url).catch((e) => fail(tr('failGeneric'), e)) }}
|
||||
appVersion={state.app_version}
|
||||
/>
|
||||
)}
|
||||
<div className="rg-slot-anchor titlebar-center" data-rg-slot="titlebar.center" />
|
||||
<div className="titlebar-right" onDoubleClick={(e) => e.stopPropagation()}>
|
||||
{canLight && canDark && (
|
||||
<Tip label={tr(theme === 'light' ? 'themeSwitchDark' : 'themeSwitchLight')}>
|
||||
@@ -871,31 +1087,47 @@ export const App: React.FC = () => {
|
||||
stage={state.needs_setup ? 'folder' : 'runtime'}
|
||||
runtimeTask={runtimeTask}
|
||||
onLocale={setLang}
|
||||
onPluginsChanged={() => setThemeRevision((r) => r + 1)}
|
||||
onFolderDone={folderDone}
|
||||
onFinish={() => setSetupStage(null)}
|
||||
onError={fail}
|
||||
onChannel={setChannel}
|
||||
onSource={setSource}
|
||||
onInstallRuntime={installRuntime}
|
||||
onCancelTask={cancelTask}
|
||||
onImportRuntime={importRuntime}
|
||||
/>
|
||||
</Suspense>
|
||||
) : showReadOnly && state ? (
|
||||
<DataRootReadOnly
|
||||
locale={locale}
|
||||
status={state.data_root_status}
|
||||
message={state.data_root_message ?? ''}
|
||||
onChanged={() => { void refresh() }}
|
||||
onError={fail}
|
||||
/>
|
||||
) : (
|
||||
<div className={`workspace rg-p-workspace${sidebarOpen ? '' : ' sidebar-hidden'}`}>
|
||||
{sidebarOpen && <div className="sidebar-backdrop" aria-hidden="true" onClick={toggleSidebar} />}
|
||||
<Sidebar
|
||||
locale={locale}
|
||||
vms={vms}
|
||||
transitions={state?.transitions ?? {}}
|
||||
busyActions={busy}
|
||||
selected={selected}
|
||||
hostReady={hostReady}
|
||||
onSelect={setSelected}
|
||||
canSuspend={canSuspend}
|
||||
onSelect={(id) => {
|
||||
setSelected(id)
|
||||
if (sidebarOpen && window.matchMedia('(max-width: 768px)').matches) {
|
||||
toggleSidebar()
|
||||
}
|
||||
}}
|
||||
displayNames={displayNames}
|
||||
macosMajors={macosMajors}
|
||||
onActivate={primaryAction}
|
||||
onNew={openWizard}
|
||||
onVMContextAction={onSidebarContextAction}
|
||||
downloading={Object.values(taskMap).some((x) => x.kind === 'installer-download' && x.status === 'running')}
|
||||
downloading={Object.values(taskMap).some(isActiveInstallerTask)}
|
||||
safeMode={state?.safe_mode}
|
||||
updateDot={!!appUpdate?.has_update}
|
||||
updateCard={showUpdateCard ? (
|
||||
@@ -915,19 +1147,34 @@ export const App: React.FC = () => {
|
||||
|
||||
<main className="main rg-p-main">
|
||||
<div className="scroll">
|
||||
{state?.vm_list_error && <div className="notice notice-error" role="alert">{state.vm_list_error}</div>}
|
||||
<Suspense fallback={null}>
|
||||
{!state ? (
|
||||
<div className="page">
|
||||
{loadError ? <div className="notice notice-error">{loadError}</div> : <span className="muted">…</span>}
|
||||
</div>
|
||||
) : selected === INSTALLERS_ID ? (
|
||||
<InstallersPage
|
||||
<ImagesPage
|
||||
locale={locale}
|
||||
host={state.host}
|
||||
tasks={Object.values(taskMap)}
|
||||
onCreateWithInstaller={openWizardWithInstaller}
|
||||
onError={fail}
|
||||
onToast={(title) => toasts.push({ kind: 'ok', title })}
|
||||
appearance={theme}
|
||||
pluginUI={pluginUI}
|
||||
onOpenPlugins={() => setSelected(PLUGINS_ID)}
|
||||
renderNativeSource={(nativeId, opts) => (
|
||||
nativeId === 'macos' ? (
|
||||
<Suspense fallback={null}>
|
||||
<InstallersPage
|
||||
locale={locale}
|
||||
host={state.host}
|
||||
tasks={Object.values(taskMap)}
|
||||
refreshSignal={opts.refreshSignal}
|
||||
onBusyChange={opts.onBusyChange}
|
||||
onCreateWithInstaller={openWizardWithInstaller}
|
||||
onError={fail}
|
||||
onToast={(title) => toasts.push({ kind: 'ok', title })}
|
||||
/>
|
||||
</Suspense>
|
||||
) : null
|
||||
)}
|
||||
/>
|
||||
) : selected === PLUGINS_ID ? (
|
||||
<PluginsPage
|
||||
@@ -937,24 +1184,27 @@ export const App: React.FC = () => {
|
||||
onRefresh={refresh}
|
||||
onError={fail}
|
||||
onThemeChanged={() => setThemeRevision((r) => r + 1)}
|
||||
onLocaleSwitch={(l) => void setLang(l)}
|
||||
/>
|
||||
) : selectedVM ? (
|
||||
<VMPage
|
||||
locale={locale}
|
||||
name={selectedVM.name}
|
||||
driverID={selectedVM.driver_id ?? ''}
|
||||
displayName={displayNames[selectedVM.name] ?? ''}
|
||||
onDisplayNameSaved={(n) => setDisplayNames((m) => ({ ...m, [selectedVM.name]: n }))}
|
||||
macosMajor={macosMajors[selectedVM.name] ?? null}
|
||||
state={effectiveState}
|
||||
canSuspend={canSuspend}
|
||||
guideActive={state.active_guides?.includes(selectedVM.name) ?? false}
|
||||
installGuideEnabled={!!state.install_guide_enabled}
|
||||
detail={detail}
|
||||
host={state.host}
|
||||
pending={pending}
|
||||
busyAction={busy[selectedVM.name]}
|
||||
busyAction={Object.prototype.hasOwnProperty.call(busy, selectedVM.name) ? busy[selectedVM.name] : undefined}
|
||||
onAction={onVMAction}
|
||||
onSettings={() => setShowSettings(true)}
|
||||
onOpenAffinity={() => setAffinityTarget(selectedVM.name)}
|
||||
onOpenAffinity={() => setAffinityTarget({ name: selectedVM.name, driverID: selectedVM.driver_id ?? '' })}
|
||||
onDelete={() => setDeleteTarget(selectedVM.name)}
|
||||
onViewLogs={() => { openLogs('serial'); loadSerial() }}
|
||||
onCopy={copy}
|
||||
@@ -1004,6 +1254,8 @@ export const App: React.FC = () => {
|
||||
<AboutPage
|
||||
locale={locale}
|
||||
appVersion={state.app_version}
|
||||
appUpdateChannel={appUpdateChannel}
|
||||
onAppUpdateChannel={setAppUpdateChannel}
|
||||
appUpdate={appUpdate}
|
||||
onAppUpdate={setAppUpdate}
|
||||
updatePhase={updatePhase}
|
||||
@@ -1022,9 +1274,9 @@ export const App: React.FC = () => {
|
||||
onRefresh={refresh}
|
||||
onNewVM={openWizard}
|
||||
onError={fail}
|
||||
onToast={(title) => toasts.push({ kind: 'ok', title })}
|
||||
runtimeTask={runtimeTask}
|
||||
onChannel={setChannel}
|
||||
onSource={setSource}
|
||||
onInstallRuntime={installRuntime}
|
||||
onCancelTask={cancelTask}
|
||||
/>
|
||||
@@ -1066,6 +1318,7 @@ export const App: React.FC = () => {
|
||||
<CreateWizard
|
||||
locale={locale}
|
||||
host={state.host}
|
||||
tasks={Object.values(taskMap)}
|
||||
draft={wizardDraft}
|
||||
onClose={() => { setShowWizard(false); setWizardDraft(null) }}
|
||||
onSubmit={submitCreate}
|
||||
@@ -1078,13 +1331,14 @@ export const App: React.FC = () => {
|
||||
<SettingsModal
|
||||
locale={locale}
|
||||
detail={detail}
|
||||
stats={latestVMStats(detail.name)}
|
||||
driverID={selectedVM?.driver_id ?? ''}
|
||||
stats={latestVMStatsWithDriver(selectedVM?.driver_id ?? '', detail.name)}
|
||||
host={state.host}
|
||||
optimizations={state.optimizations}
|
||||
running={effectiveState === 'running'}
|
||||
onCopy={copy}
|
||||
onDiskChanged={refresh}
|
||||
onOpenAffinity={() => setAffinityTarget(detail.name)}
|
||||
onOpenAffinity={() => setAffinityTarget({ name: detail.name, driverID: selectedVM?.driver_id ?? '' })}
|
||||
affinityVersion={affinityVersion}
|
||||
onHostChanged={refresh}
|
||||
onClose={() => setShowSettings(false)}
|
||||
@@ -1101,8 +1355,9 @@ export const App: React.FC = () => {
|
||||
<Suspense fallback={null}>
|
||||
<AffinityDialog
|
||||
locale={locale}
|
||||
vmName={affinityTarget}
|
||||
vcpus={detail?.name === affinityTarget ? detail.cpus : 4}
|
||||
vmName={affinityTarget.name}
|
||||
driverID={affinityTarget.driverID}
|
||||
vcpus={detail?.name === affinityTarget.name ? detail.cpus : 4}
|
||||
host={state.host}
|
||||
globalAutoPin={state.config.auto_pin_pcores}
|
||||
onClose={() => setAffinityTarget(null)}
|
||||
@@ -1147,11 +1402,26 @@ export const App: React.FC = () => {
|
||||
<DeleteDialog locale={locale} name={deleteTarget} onCancel={() => setDeleteTarget(null)} onConfirm={confirmDelete} />
|
||||
)}
|
||||
|
||||
{discardSuspendTarget && (() => {
|
||||
const targetVM = vms.find((v) => vmRefKey(v) === discardSuspendTarget) ?? vms.find((v) => v.name === discardSuspendTarget)
|
||||
const targetName = targetVM?.name ?? discardSuspendTarget
|
||||
return (
|
||||
<ConfirmDialog
|
||||
title={tr('discardSuspendTitle', { name: displayNames[targetName] || targetName })}
|
||||
description={tr('discardSuspendDesc')}
|
||||
cancelLabel={tr('cancel')}
|
||||
confirmLabel={tr('discardSuspendConfirm')}
|
||||
onCancel={() => setDiscardSuspendTarget(null)}
|
||||
onConfirm={confirmDiscardSuspend}
|
||||
/>
|
||||
)
|
||||
})()}
|
||||
|
||||
{cloneSource && (
|
||||
<CloneDialog
|
||||
locale={locale}
|
||||
sourceName={cloneSource}
|
||||
defaultCloneName={`${cloneSource}-clone`}
|
||||
sourceName={cloneSource.name}
|
||||
defaultCloneName={`${cloneSource.name}-clone`}
|
||||
onCancel={() => setCloneSource(null)}
|
||||
onConfirm={confirmClone}
|
||||
/>
|
||||
@@ -1170,7 +1440,7 @@ export const App: React.FC = () => {
|
||||
<SendTextDialog
|
||||
locale={locale}
|
||||
vmName={sendTextTarget}
|
||||
guestToolsConnected={Boolean(latestVMStats(sendTextTarget)?.guest_tools_connected ?? detail?.guest_tools_connected)}
|
||||
guestToolsConnected={Boolean(latestVMStatsWithDriver(selectedVM?.driver_id ?? '', sendTextTarget)?.guest_tools_connected ?? detail?.guest_tools_connected)}
|
||||
onCancel={() => setSendTextTarget(null)}
|
||||
onConfirm={(text) => {
|
||||
const target = sendTextTarget
|
||||
@@ -1180,8 +1450,12 @@ export const App: React.FC = () => {
|
||||
/>
|
||||
)}
|
||||
|
||||
<Toaster items={toasts.items} onRemove={toasts.remove} closeLabel={tr('close')} />
|
||||
<div className="rg-layer rg-layer-overlay" data-rg-layer="layer.overlay" aria-hidden="true" />
|
||||
</div>
|
||||
{/* Outside the isolated shell so toasts stay above dialogs and the overlay layer. */}
|
||||
<Toaster items={toasts.items} onRemove={toasts.remove} closeLabel={tr('close')} dir={dir} />
|
||||
<ThemeDecorations payload={activeThemePayload} snap={uiStateRef.current} locale={locale} />
|
||||
</TooltipProvider>
|
||||
</ThemeVisualsProvider>
|
||||
)
|
||||
}
|
||||
@@ -1,18 +1,27 @@
|
||||
import { Copy, Download, ExternalLink, RotateCw } from 'lucide-react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { Copy, Download, ExternalLink, RotateCw, Scale } from 'lucide-react'
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { taskDetail } from '../lib/tasks'
|
||||
import { AppUpdateInfo, Locale, Task } from '../types'
|
||||
import { Button, IconButton } from '../ui/controls'
|
||||
import { Modal } from '../ui/dialog'
|
||||
import { Segmented } from '../ui/settings'
|
||||
import { api } from '../wails'
|
||||
import { REPO_URL } from './TitleMenus'
|
||||
import type { UpdatePhase } from './UpdateCapsule'
|
||||
import { BrandMark } from '../ui/themeVisuals'
|
||||
|
||||
const DISCORD_INVITE_URL = 'https://discord.gg/Tj682rW5rS'
|
||||
const QQ_GROUP_ID = '1136042744'
|
||||
|
||||
export type AppUpdateChannel = 'stable' | 'alpha' | 'dev'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
appVersion?: string
|
||||
appUpdateChannel: AppUpdateChannel
|
||||
onAppUpdateChannel: (channel: AppUpdateChannel) => Promise<void> | void
|
||||
/** Latest update check, shared with the sidebar's update button. */
|
||||
appUpdate: AppUpdateInfo | null
|
||||
onAppUpdate: (info: AppUpdateInfo) => void
|
||||
@@ -27,17 +36,50 @@ interface Props {
|
||||
onError: (title: string, e: unknown) => void
|
||||
}
|
||||
|
||||
/** About page: version and updates, project links and the community group. */
|
||||
/** About page: version and updates, project links and community channels. */
|
||||
export const AboutPage: React.FC<Props> = ({
|
||||
locale, appVersion, appUpdate, onAppUpdate, updatePhase, updateTask, installing,
|
||||
locale, appVersion, appUpdateChannel, onAppUpdateChannel, appUpdate, onAppUpdate, updatePhase, updateTask, installing,
|
||||
onDownloadUpdate, onCancelUpdate, onInstallUpdate, onCopy, onError,
|
||||
}) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const [checkingUpdate, setCheckingUpdate] = useState(false)
|
||||
const [switchingChannel, setSwitchingChannel] = useState(false)
|
||||
const [updateErr, setUpdateErr] = useState('')
|
||||
const [qqInstalled, setQQInstalled] = useState<boolean | null>(null)
|
||||
const [openingQQ, setOpeningQQ] = useState(false)
|
||||
const [qqLaunchErr, setQQLaunchErr] = useState('')
|
||||
const [licenseOpen, setLicenseOpen] = useState(false)
|
||||
const [licenseTab, setLicenseTab] = useState<'notice' | 'license'>('notice')
|
||||
const [licenses, setLicenses] = useState<{ license: string; notice: string } | null>(null)
|
||||
const mountedRef = useRef(true)
|
||||
const loadingLicensesRef = useRef(false)
|
||||
const licensePreRef = useRef<HTMLPreElement>(null)
|
||||
|
||||
const openLicenses = async () => {
|
||||
if (licenses) {
|
||||
setLicenseOpen(true)
|
||||
return
|
||||
}
|
||||
if (loadingLicensesRef.current) return
|
||||
loadingLicensesRef.current = true
|
||||
try {
|
||||
// Load embedded license text before mounting the modal so the dialog opens
|
||||
// with its final content on frame 1 instead of reflowing mid-animation.
|
||||
const res = await api.GetLicenseTexts()
|
||||
if (!mountedRef.current) return
|
||||
setLicenses({ license: res?.license ?? '', notice: res?.notice ?? '' })
|
||||
setLicenseOpen(true)
|
||||
} catch (e) {
|
||||
if (mountedRef.current) onError(tr('failGeneric'), e)
|
||||
} finally {
|
||||
loadingLicensesRef.current = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleLicenseTabChange = (next: 'notice' | 'license') => {
|
||||
setLicenseTab(next)
|
||||
if (licensePreRef.current) licensePreRef.current.scrollTop = 0
|
||||
}
|
||||
|
||||
const runUpdateCheck = async (force: boolean) => {
|
||||
setCheckingUpdate(true)
|
||||
@@ -52,12 +94,16 @@ export const AboutPage: React.FC<Props> = ({
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
mountedRef.current = true
|
||||
if (!appUpdate) void runUpdateCheck(false)
|
||||
let cancelled = false
|
||||
api.CanOpenQQGroup()
|
||||
.then((ok) => { if (!cancelled) setQQInstalled(!!ok) })
|
||||
.catch(() => { if (!cancelled) setQQInstalled(false) })
|
||||
return () => { cancelled = true }
|
||||
return () => {
|
||||
mountedRef.current = false
|
||||
cancelled = true
|
||||
}
|
||||
}, [])
|
||||
|
||||
const openURL = (url: string) => {
|
||||
@@ -81,15 +127,33 @@ export const AboutPage: React.FC<Props> = ({
|
||||
}
|
||||
}
|
||||
|
||||
const handleChannelChange = async (next: AppUpdateChannel) => {
|
||||
if (next === appUpdateChannel || switchingChannel) return
|
||||
setSwitchingChannel(true)
|
||||
setUpdateErr('')
|
||||
try {
|
||||
await onAppUpdateChannel(next)
|
||||
} catch (e) {
|
||||
setUpdateErr(String(e).replace(/^Error:\s*/, ''))
|
||||
} finally {
|
||||
setSwitchingChannel(false)
|
||||
}
|
||||
}
|
||||
|
||||
const version = appVersion ?? appUpdate?.current ?? ''
|
||||
const pct = updateTask && updateTask.percent >= 0 ? Math.round(updateTask.percent) : null
|
||||
const updateAvailableKey: I18nKey = appUpdate?.channel === 'dev'
|
||||
? 'appUpdateAvailableDev'
|
||||
: appUpdate?.channel === 'alpha'
|
||||
? 'appUpdateAvailableAlpha'
|
||||
: 'appUpdateAvailable'
|
||||
|
||||
let updateSub: React.ReactNode = null
|
||||
if (updatePhase === 'downloading') {
|
||||
updateSub = (
|
||||
<>
|
||||
<div className="row-sub">{tr('updateDownloadingSub', { v: appUpdate?.latest ?? '' })}{updateTask && taskDetail(updateTask) ? ` · ${taskDetail(updateTask)}` : ''}</div>
|
||||
<span className="progress about-update-progress" aria-hidden="true">
|
||||
<span className="progress rg-p-progress about-update-progress" aria-hidden="true">
|
||||
<span className="progress-fill" style={{ transform: `scaleX(${(pct ?? 0) / 100})` }} />
|
||||
</span>
|
||||
</>
|
||||
@@ -99,7 +163,7 @@ export const AboutPage: React.FC<Props> = ({
|
||||
} else if (updatePhase === 'failed') {
|
||||
updateSub = <div className="row-sub warn-text" title={updateTask?.error}>{tr('updateFailedSub')}</div>
|
||||
} else if (appUpdate?.has_update) {
|
||||
updateSub = <div className="row-sub">{tr('appUpdateAvailable', { v: appUpdate.latest })}</div>
|
||||
updateSub = <div className="row-sub">{tr(updateAvailableKey, { v: appUpdate.latest })}</div>
|
||||
} else if (updateErr) {
|
||||
updateSub = <div className="row-sub" title={updateErr}>{tr('appUpdateLookupFailed')}</div>
|
||||
}
|
||||
@@ -120,7 +184,7 @@ export const AboutPage: React.FC<Props> = ({
|
||||
return (
|
||||
<div className="page about-page">
|
||||
<header className="about-hero">
|
||||
<img className="about-hero-mark" src="/logo.svg" alt="" aria-hidden="true" />
|
||||
<BrandMark className="about-hero-mark" />
|
||||
<div className="about-hero-text">
|
||||
<h1>Reims-Go</h1>
|
||||
<p>{tr('aboutTagline')}</p>
|
||||
@@ -134,7 +198,7 @@ export const AboutPage: React.FC<Props> = ({
|
||||
<div className="row-title">
|
||||
{tr('appVersionTitle')} <span className="mono">{version}</span>
|
||||
{appUpdate && !appUpdate.has_update && (
|
||||
<span className="badge badge-ok">{tr('appUpToDate')}</span>
|
||||
<span className="badge rg-p-badge badge-ok">{tr('appUpToDate')}</span>
|
||||
)}
|
||||
</div>
|
||||
{updateSub}
|
||||
@@ -148,6 +212,30 @@ export const AboutPage: React.FC<Props> = ({
|
||||
{updateAction}
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('appUpdateChannelTitle')}</div>
|
||||
<div className="row-sub">
|
||||
{appUpdateChannel === 'stable'
|
||||
? tr('appUpdateChannelSubStable')
|
||||
: tr('appUpdateChannelSubKeepOld', {
|
||||
channel: appUpdateChannel === 'dev' ? tr('appUpdateChannelDev') : tr('appUpdateChannelAlpha'),
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<Segmented
|
||||
label={tr('appUpdateChannelTitle')}
|
||||
value={appUpdateChannel}
|
||||
onChange={(v) => void handleChannelChange(v)}
|
||||
options={[
|
||||
{ value: 'stable' as AppUpdateChannel, label: tr('appUpdateChannelStable'), disabled: switchingChannel || checkingUpdate || updatePhase === 'downloading' || installing },
|
||||
{ value: 'alpha' as AppUpdateChannel, label: tr('appUpdateChannelAlpha'), disabled: switchingChannel || checkingUpdate || updatePhase === 'downloading' || installing },
|
||||
{ value: 'dev' as AppUpdateChannel, label: tr('appUpdateChannelDev'), disabled: switchingChannel || checkingUpdate || updatePhase === 'downloading' || installing },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -176,12 +264,45 @@ export const AboutPage: React.FC<Props> = ({
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('aboutLicensesTitle')}</div>
|
||||
<div className="row-sub">{tr('aboutLicensesSub')}</div>
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<Button icon={<Scale size={14} aria-hidden="true" />} onClick={() => void openLicenses()}>
|
||||
{tr('aboutLicensesView')}
|
||||
</Button>
|
||||
<Button variant="ghost" icon={<ExternalLink size={14} aria-hidden="true" />} onClick={() => openURL(`${REPO_URL}/blob/main/NOTICE.md`)}>
|
||||
{tr('openShort')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('aboutDiscord')}</div>
|
||||
<div className="row-sub">{tr('aboutDiscordSub')}</div>
|
||||
</div>
|
||||
<div className="row-right">
|
||||
{onCopy && (
|
||||
<IconButton
|
||||
small
|
||||
label={tr('aboutCopyDiscord')}
|
||||
icon={<Copy size={14} aria-hidden="true" />}
|
||||
onClick={() => onCopy(DISCORD_INVITE_URL)}
|
||||
/>
|
||||
)}
|
||||
<Button icon={<ExternalLink size={14} aria-hidden="true" />} onClick={() => openURL(DISCORD_INVITE_URL)}>
|
||||
{tr('aboutJoinDiscord')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
{tr('aboutQQGroup')} <span className="mono">{QQ_GROUP_ID}</span>
|
||||
{qqInstalled === false && (
|
||||
<span className="badge">{tr('aboutQQNotInstalled')}</span>
|
||||
<span className="badge rg-p-badge">{tr('aboutQQNotInstalled')}</span>
|
||||
)}
|
||||
</div>
|
||||
{qqInstalled === false ? (
|
||||
@@ -216,6 +337,50 @@ export const AboutPage: React.FC<Props> = ({
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{licenseOpen && (
|
||||
<Modal
|
||||
title={tr('aboutLicensesTitle')}
|
||||
subtitle={tr('aboutLicensesSub')}
|
||||
closeLabel={tr('close')}
|
||||
onClose={() => setLicenseOpen(false)}
|
||||
>
|
||||
<div className="dialog-body license-modal-body">
|
||||
<Segmented
|
||||
label={tr('aboutLicensesTitle')}
|
||||
value={licenseTab}
|
||||
onChange={handleLicenseTabChange}
|
||||
options={[
|
||||
{ value: 'notice', label: tr('aboutLicensesTabNotice') },
|
||||
{ value: 'license', label: tr('aboutLicensesTabLicense') },
|
||||
]}
|
||||
/>
|
||||
<pre
|
||||
ref={licensePreRef}
|
||||
className="license-pre"
|
||||
dir="ltr"
|
||||
tabIndex={0}
|
||||
role="region"
|
||||
aria-label={licenseTab === 'notice' ? tr('aboutLicensesTabNotice') : tr('aboutLicensesTabLicense')}
|
||||
>
|
||||
{licenses
|
||||
? (licenseTab === 'notice' ? licenses.notice : licenses.license)
|
||||
: ''}
|
||||
</pre>
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
<Button
|
||||
variant="ghost"
|
||||
icon={<ExternalLink size={14} aria-hidden="true" />}
|
||||
onClick={() => openURL(`${REPO_URL}/blob/main/${licenseTab === 'notice' ? 'NOTICE.md' : 'LICENSE'}`)}
|
||||
>
|
||||
{tr('aboutLicensesOpenGitHub')}
|
||||
</Button>
|
||||
<Button variant="primary" onClick={() => setLicenseOpen(false)}>
|
||||
{tr('close')}
|
||||
</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { AlertTriangle, Check, Cpu } from 'lucide-react'
|
||||
import React, { useEffect, useMemo, useState } from 'react'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import { I18nKey, parseAppError, t } from '../i18n'
|
||||
import { HostReport, Locale, LogicalCPUInfo, VMAffinityMode, VMAffinityStatus } from '../types'
|
||||
import { Button } from '../ui/controls'
|
||||
import { Modal } from '../ui/dialog'
|
||||
@@ -10,6 +11,7 @@ import { api } from '../wails'
|
||||
interface Props {
|
||||
locale: Locale
|
||||
vmName: string
|
||||
driverID: string
|
||||
vcpus: number
|
||||
host: HostReport
|
||||
globalAutoPin: boolean
|
||||
@@ -78,7 +80,7 @@ export function formatAffinitySummary(locale: Locale, status: VMAffinityStatus |
|
||||
}
|
||||
|
||||
export const AffinityDialog: React.FC<Props> = ({
|
||||
locale, vmName, vcpus, host, globalAutoPin, onClose, onApplied,
|
||||
locale, vmName, driverID, vcpus, host, globalAutoPin, onClose, onApplied,
|
||||
}) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const topology = useMemo(() => buildTopology(host), [host])
|
||||
@@ -98,7 +100,7 @@ export const AffinityDialog: React.FC<Props> = ({
|
||||
let live = true
|
||||
setLoading(true)
|
||||
setErr('')
|
||||
api.GetVMAffinity(vmName)
|
||||
api.GetVMAffinityWithDriver(driverID, vmName)
|
||||
.then((st) => {
|
||||
if (!live) return
|
||||
setStatus(st)
|
||||
@@ -110,7 +112,7 @@ export const AffinityDialog: React.FC<Props> = ({
|
||||
setDisableEcoQoS(st.disable_eco_qos)
|
||||
})
|
||||
.catch((e) => {
|
||||
if (live) setErr(String(e).replace(/^Error:\s*/, ''))
|
||||
if (live) setErr(parseAppError(e).summary)
|
||||
})
|
||||
.finally(() => {
|
||||
if (live) setLoading(false)
|
||||
@@ -204,14 +206,14 @@ export const AffinityDialog: React.FC<Props> = ({
|
||||
setSaving(true)
|
||||
setErr('')
|
||||
try {
|
||||
const updated = await api.SetVMAffinity(vmName, {
|
||||
const updated = await api.SetVMAffinityWithDriver(driverID, vmName, {
|
||||
mode,
|
||||
cpus: mode === 'custom' ? selected : [],
|
||||
disable_eco_qos: disableEcoQoS,
|
||||
})
|
||||
onApplied(updated)
|
||||
} catch (e) {
|
||||
setErr(String(e).replace(/^Error:\s*/, ''))
|
||||
setErr(parseAppError(e).summary)
|
||||
} finally {
|
||||
setSaving(false)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import React from 'react'
|
||||
import { PowerOff } from 'lucide-react'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import { getLocaleOptions, I18nKey, t } from '../i18n'
|
||||
import { findOptimization, optBadgeClass, optStatusLabel } from '../lib/optimizations'
|
||||
import { AppState, Locale, ResolvedLocalePack } from '../types'
|
||||
@@ -26,8 +28,13 @@ export const AppSettingsPage: React.FC<Props> = ({
|
||||
}) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const { host, config, optimizations } = state
|
||||
const quitMode = state.quit_mode
|
||||
|
||||
const pcoreOpt = findOptimization(optimizations, 'pcore_pin')
|
||||
const missingFontScript = state.missing_font_hint || ''
|
||||
const memSpecLabel = host.memory_spec?.speed_mhz
|
||||
? `${host.memory_spec.speed_mhz} MHz${host.memory_spec.type_name ? ` ${host.memory_spec.type_name}` : ''}`
|
||||
: ''
|
||||
|
||||
const guard = (fn: () => Promise<unknown>) => async () => {
|
||||
try {
|
||||
@@ -43,6 +50,14 @@ export const AppSettingsPage: React.FC<Props> = ({
|
||||
if (dir) await api.SetDataRoot(dir)
|
||||
})
|
||||
|
||||
const forceQuit = async () => {
|
||||
try {
|
||||
await api.ForceQuitApp()
|
||||
} catch (e) {
|
||||
onError(tr('quitFailed'), e)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="page rg-p-settings">
|
||||
<header className="page-head">
|
||||
@@ -63,7 +78,7 @@ export const AppSettingsPage: React.FC<Props> = ({
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
{tr('autoPinPCores')}
|
||||
<span className={`badge ${optBadgeClass(pcoreOpt?.status)}`}>
|
||||
<span className={`badge rg-p-badge ${optBadgeClass(pcoreOpt?.status)}`}>
|
||||
{optStatusLabel(locale, pcoreOpt?.status)}
|
||||
</span>
|
||||
</div>
|
||||
@@ -82,6 +97,24 @@ export const AppSettingsPage: React.FC<Props> = ({
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('syncHostMemorySMBIOS')}</div>
|
||||
<div className="row-sub">
|
||||
{memSpecLabel
|
||||
? tr('syncHostMemorySMBIOSSub', { spec: memSpecLabel })
|
||||
: tr('syncHostMemorySMBIOSUnavailable')}
|
||||
</div>
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<Switch
|
||||
label={tr('syncHostMemorySMBIOS')}
|
||||
disabled={!memSpecLabel}
|
||||
checked={!!memSpecLabel && !!config.sync_host_memory_smbios}
|
||||
onChange={(checked) => guard(() => api.SetSyncHostMemorySMBIOS(checked))()}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('minimizeToTray')}</div>
|
||||
@@ -95,6 +128,17 @@ export const AppSettingsPage: React.FC<Props> = ({
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('forceQuitAppTitle')}</div>
|
||||
<div className="row-sub">{tr('forceQuitAppSub')}</div>
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<Button variant="danger" onClick={forceQuit} busy={quitMode === 'force'} icon={<PowerOff size={14} aria-hidden="true" />}>
|
||||
{tr(quitMode === 'force' ? 'forceQuitInProgress' : 'forceQuitAppButton')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -125,13 +169,16 @@ export const AppSettingsPage: React.FC<Props> = ({
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('language')}</div>
|
||||
<div className="row-sub">{tr('languageSub')}</div>
|
||||
{missingFontScript && (
|
||||
<div className="row-sub warn-text">{tr('fontMissingFoDHint', { script: missingFontScript })}</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<PopupSelect
|
||||
label={tr('language')}
|
||||
value={locale}
|
||||
value={config.locale || 'auto'}
|
||||
onChange={onSetLocale}
|
||||
options={getLocaleOptions(locales)}
|
||||
options={getLocaleOptions(locales, locale, state.detected_locale)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -18,7 +18,7 @@ export const CloneDialog: React.FC<Props> = ({ locale, sourceName, defaultCloneN
|
||||
<Alert.Root open onOpenChange={(open) => { if (!open) onCancel() }}>
|
||||
<Alert.Portal>
|
||||
<Alert.Overlay className="overlay" />
|
||||
<Alert.Content className="dialog sm">
|
||||
<Alert.Content className="dialog rg-p-dialog sm" data-tone="neutral">
|
||||
<div className="dialog-body">
|
||||
<Alert.Title className="dialog-title">{t(locale, 'cloneTitle', { name: sourceName })}</Alert.Title>
|
||||
<Alert.Description className="dialog-desc">
|
||||
@@ -28,7 +28,7 @@ export const CloneDialog: React.FC<Props> = ({ locale, sourceName, defaultCloneN
|
||||
<label className="field-label" htmlFor="clone-name">{t(locale, 'cloneNameLabel')}</label>
|
||||
<input
|
||||
id="clone-name"
|
||||
className="input mono"
|
||||
className="input rg-p-input mono"
|
||||
value={cloneName}
|
||||
spellCheck={false}
|
||||
autoComplete="off"
|
||||
@@ -40,10 +40,10 @@ export const CloneDialog: React.FC<Props> = ({ locale, sourceName, defaultCloneN
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
<Alert.Cancel asChild>
|
||||
<button type="button" className="btn">{t(locale, 'cancel')}</button>
|
||||
<button type="button" className="btn rg-p-button">{t(locale, 'cancel')}</button>
|
||||
</Alert.Cancel>
|
||||
<Alert.Action asChild>
|
||||
<button type="button" className="btn btn-primary" disabled={!trimmed} onClick={() => onConfirm(trimmed)}>
|
||||
<button type="button" className="btn rg-p-button btn-primary" disabled={!trimmed} onClick={() => onConfirm(trimmed)}>
|
||||
{t(locale, 'cloneConfirm')}
|
||||
</button>
|
||||
</Alert.Action>
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { Check, ChevronRight, CircleAlert, CircleCheck, CloudDownload, Copy, Disc3, HardDrive, LucideIcon, Package } from 'lucide-react'
|
||||
import React, { Suspense, lazy, useEffect, useState } from 'react'
|
||||
import { I18nKey, locText, t } from '../i18n'
|
||||
import '../i18n/domains/wizard.gen'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import { I18nKey, locText, parseAppError, t } from '../i18n'
|
||||
import {
|
||||
GUEST_LANG_PRESETS,
|
||||
guestLangOptions,
|
||||
MEMORY_MARKS,
|
||||
controllerLabel,
|
||||
defaultGuestLang,
|
||||
@@ -15,6 +18,8 @@ import {
|
||||
memorySafeLimitGB,
|
||||
parseMemoryGB,
|
||||
recommendedCPUs,
|
||||
fullscreenDisplayPresets,
|
||||
FullscreenDisplayPreset,
|
||||
hidpiLooksLike,
|
||||
hostDisplayAdvice,
|
||||
hostDisplayDesc,
|
||||
@@ -25,7 +30,8 @@ import {
|
||||
splitLangLabel,
|
||||
sshCommand,
|
||||
} from '../lib/format'
|
||||
import { CachedInstaller, CreateOpts, DriverSummary, HostReport, Locale, Release, ValidationIssue } from '../types'
|
||||
import { CachedInstaller, CreateOpts, DriverSummary, HostReport, Locale, Release, Task, ValidationIssue } from '../types'
|
||||
import { findActiveOfflineTask, taskInstallerPhase } from '../lib/tasks'
|
||||
import { Button, IconButton } from '../ui/controls'
|
||||
import { NumberField, PopupSelect, RangeField, Segmented, SetGroup, SetRow, Switch } from '../ui/settings'
|
||||
import { Modal } from '../ui/dialog'
|
||||
@@ -43,6 +49,7 @@ export interface WizardDraft {
|
||||
interface Props {
|
||||
locale: Locale
|
||||
host: HostReport
|
||||
tasks?: Task[]
|
||||
draft?: WizardDraft | null
|
||||
onClose: () => void
|
||||
/** Called with the cleaned payload; the caller runs the create in the background. */
|
||||
@@ -51,7 +58,7 @@ interface Props {
|
||||
|
||||
const REVIEW_STEP = 5
|
||||
|
||||
// Which wizard step owns each ValidationIssue.field (internal/driver/reims/reims.go ValidateCreate).
|
||||
// Which wizard step owns each ValidationIssue.field (internal/macos/reims/reims.go ValidateCreate).
|
||||
const STEP_OF_FIELD: Record<string, number> = {
|
||||
installer: 1, disk: 1, macos: 1, guest_lang: 1,
|
||||
cpus: 2, memory: 2,
|
||||
@@ -68,7 +75,7 @@ const SOURCES: { mode: 'offline' | 'apple' | 'installer' | 'disk'; icon: LucideI
|
||||
{ mode: 'disk', icon: HardDrive, title: 'srcDiskTitle', sub: 'srcDiskSub' },
|
||||
]
|
||||
|
||||
export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, onSubmit }) => {
|
||||
export const CreateWizard: React.FC<Props> = ({ locale, host, tasks = [], draft, onClose, onSubmit }) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const [step, setStep] = useState(draft?.step ?? 1)
|
||||
// Once the user has reached the review step, keep validating so step markers stay current.
|
||||
@@ -84,7 +91,7 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
|
||||
useEffect(() => {
|
||||
let live = true
|
||||
api.ListDrivers().then((list) => { if (live) setDrivers(list ?? []) }).catch(() => {})
|
||||
api.ListDrivers().then((list) => { if (live) setDrivers(list ?? []) }).catch((e) => console.warn('[wizard] ListDrivers failed:', e))
|
||||
return () => { live = false }
|
||||
}, [])
|
||||
const activeDriver = drivers.find((d) => d.id === driverID)
|
||||
@@ -152,7 +159,7 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
useEffect(() => {
|
||||
if (opts.source_mode !== 'offline' || releases) return
|
||||
let live = true
|
||||
api.ListInstallers().then((l) => { if (live) setCached(l ?? []) }).catch(() => {})
|
||||
api.ListInstallers().then((l) => { if (live) setCached(l ?? []) }).catch((e) => console.warn('[wizard] ListInstallers failed:', e))
|
||||
api.ListOfflineReleases()
|
||||
.then((list) => {
|
||||
if (!live) return
|
||||
@@ -163,9 +170,12 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
return () => { live = false }
|
||||
}, [opts.source_mode])
|
||||
const isCached = (v: string) => cached.some((c) => c.kind === 'offline' && !c.partial && c.version === v)
|
||||
const activeRelease = (v: string) => findActiveOfflineTask(tasks, v)
|
||||
const chosenRelease = releases?.find((r) => r.version === opts.macos)
|
||||
// reims-util pre-allocates the whole image as it starts (19.7 GB for an 18.4 GB release, measured).
|
||||
const needGB = chosenRelease && !isCached(chosenRelease.version) ? Math.ceil((chosenRelease.size * 1.1) / 1e9) : 0
|
||||
const needGB = chosenRelease && !isCached(chosenRelease.version) && !activeRelease(chosenRelease.version)
|
||||
? Math.ceil((chosenRelease.size * 1.1) / 1e9)
|
||||
: 0
|
||||
|
||||
useEffect(() => {
|
||||
if (!reviewed && step !== REVIEW_STEP) return
|
||||
@@ -180,7 +190,7 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
setCmdPreview(cmd)
|
||||
setErr('')
|
||||
})
|
||||
.catch((e) => { if (live) setErr(String(e).replace(/^Error:\s*/, '')) })
|
||||
.catch((e) => { if (live) setErr(parseAppError(e).summary) })
|
||||
.finally(() => { if (live) setChecking(false) })
|
||||
}, 200)
|
||||
return () => { live = false; clearTimeout(timer) }
|
||||
@@ -262,7 +272,7 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
<SetGroup title={tr('wizardBasics')}>
|
||||
<SetRow
|
||||
title={tr('vmName')}
|
||||
control={<input className="input" value={opts.name} onChange={(e) => set({ name: e.target.value })} />}
|
||||
control={<input className="input rg-p-input" value={opts.name} onChange={(e) => set({ name: e.target.value })} />}
|
||||
/>
|
||||
</SetGroup>
|
||||
{activeDriver.create_schema && (
|
||||
@@ -298,13 +308,14 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
<span className={`source-icon source-icon-${s.mode}`} aria-hidden="true"><Icon size={20} /></span>
|
||||
<span className="source-title">
|
||||
{tr(s.title)}
|
||||
{s.mode === 'offline' && <span className="badge badge-accent">{tr('recommendedBadge')}</span>}
|
||||
{s.mode === 'offline' && <span className="badge rg-p-badge badge-accent">{tr('recommendedBadge')}</span>}
|
||||
</span>
|
||||
<span className="source-sub">{tr(s.sub)}</span>
|
||||
</label>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
<div className="rg-slot-anchor" data-rg-slot="create.source" />
|
||||
|
||||
<SetGroup>
|
||||
{opts.source_mode === 'apple' && (
|
||||
@@ -329,11 +340,19 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
label={tr('macosVersion')}
|
||||
value={opts.macos}
|
||||
onChange={(macos) => set({ macos })}
|
||||
options={releases.map((r) => ({
|
||||
value: r.version,
|
||||
label: `macOS ${r.version}`,
|
||||
detail: `${(r.size / 1e9).toFixed(1)} GB${isCached(r.version) ? ` · ${tr('offlineCached')}` : ''}`,
|
||||
}))}
|
||||
options={releases.map((r) => {
|
||||
const active = activeRelease(r.version)
|
||||
const statusTag = isCached(r.version)
|
||||
? tr('offlineCached')
|
||||
: active
|
||||
? tr(taskInstallerPhase(active.primary) === 'queued' ? 'offlineQueued' : 'offlineDownloading')
|
||||
: ''
|
||||
return {
|
||||
value: r.version,
|
||||
label: `macOS ${r.version}`,
|
||||
detail: `${(r.size / 1e9).toFixed(1)} GB${statusTag ? ` · ${statusTag}` : ''}`,
|
||||
}
|
||||
})}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
@@ -365,7 +384,7 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
label={tr('guestLangShort')}
|
||||
value={opts.guest_lang || defaultGuestLang(locale)}
|
||||
onChange={(guest_lang) => set({ guest_lang })}
|
||||
options={GUEST_LANG_PRESETS.map((p) => splitLangLabel(p.value, locale === 'zh-CN' ? p.zh : p.en))}
|
||||
options={guestLangOptions(locale)}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
@@ -536,17 +555,22 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
title={tr('resolution')}
|
||||
disabled={opts.graphics !== 'reims-vgpu'}
|
||||
reason={tr('gpuSvgaReason')}
|
||||
desc={[hostDisplayDesc(host, tr), hostDisplayAdvice(host, tr)].filter(Boolean).join(' · ') || undefined}
|
||||
desc={[hostDisplayDesc(host, tr), !opts.borderless ? hostDisplayAdvice(host, tr) : undefined].filter(Boolean).join(' · ') || undefined}
|
||||
control={
|
||||
<PopupSelect
|
||||
id="vm-res"
|
||||
label={tr('resolution')}
|
||||
value={opts.resolution}
|
||||
onChange={(resolution) => set({ resolution })}
|
||||
options={recommendedDisplayPresets(host).map((p) => ({
|
||||
options={(opts.borderless ? fullscreenDisplayPresets(host) : recommendedDisplayPresets(host)).map((p: FullscreenDisplayPreset) => ({
|
||||
value: p.resolution,
|
||||
label: p.label,
|
||||
detail: [p.hidpi ? `${tr('hidpiPresetBadge')} · ${hidpiLooksLike(p.resolution, tr) ?? ''}` : '', p.recommended ? tr('recommendedBadge') : ''].filter(Boolean).join(' · ') || undefined,
|
||||
detail: [
|
||||
p.hidpi ? `${tr('hidpiPresetBadge')} · ${hidpiLooksLike(p.resolution, tr) ?? ''}` : '',
|
||||
p.scaleBadge ?? '',
|
||||
p.native ? tr('resNativeBadge') : '',
|
||||
p.recommended ? tr('recommendedBadge') : '',
|
||||
].filter(Boolean).join(' · ') || undefined,
|
||||
}))}
|
||||
/>
|
||||
}
|
||||
@@ -597,8 +621,19 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
/>
|
||||
<SetRow
|
||||
title={tr('fullscreenLaunch')}
|
||||
desc={tr('fullscreenLaunchHint')}
|
||||
control={<Switch label={tr('fullscreenLaunch')} checked={!!opts.borderless} onChange={(borderless) => set({ borderless })} />}
|
||||
desc={opts.borderless ? tr('fullscreenDecoupledHint') : tr('fullscreenLaunchHint')}
|
||||
control={
|
||||
<Switch
|
||||
label={tr('fullscreenLaunch')}
|
||||
checked={!!opts.borderless}
|
||||
onChange={(borderless) => {
|
||||
const list = borderless ? fullscreenDisplayPresets(host) : recommendedDisplayPresets(host)
|
||||
const keep = list.some((p) => p.resolution === opts.resolution)
|
||||
const fallback = list.find((p) => p.recommended)?.resolution ?? list[0]?.resolution ?? opts.resolution
|
||||
set(keep ? { borderless } : { borderless, resolution: fallback })
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<SetRow
|
||||
title={tr('enableLogs')}
|
||||
@@ -645,7 +680,7 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
})
|
||||
onClose()
|
||||
} catch (e) {
|
||||
setErr(String(e).replace(/^Error:\s*/, ''))
|
||||
setErr(parseAppError(e).summary)
|
||||
} finally {
|
||||
setDriverCreating(false)
|
||||
}
|
||||
@@ -759,7 +794,10 @@ const Review: React.FC<ReviewProps> = ({ locale, host, opts, issues, checking, c
|
||||
await navigator.clipboard.writeText(command)
|
||||
setCopied(true)
|
||||
setTimeout(() => setCopied(false), 1500)
|
||||
} catch { /* clipboard unavailable; the text stays selectable */ }
|
||||
} catch (e) {
|
||||
// clipboard unavailable; the text stays selectable
|
||||
console.warn('[wizard] clipboard write failed:', e)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -768,7 +806,7 @@ const Review: React.FC<ReviewProps> = ({ locale, host, opts, issues, checking, c
|
||||
<SetRow
|
||||
title={tr('vmName')}
|
||||
error={nameIssue}
|
||||
control={<input className="input name-input" aria-label={tr('vmName')} value={opts.name} onChange={(e) => onName(e.target.value)} spellCheck={false} />}
|
||||
control={<input className="input rg-p-input name-input" aria-label={tr('vmName')} value={opts.name} onChange={(e) => onName(e.target.value)} spellCheck={false} />}
|
||||
/>
|
||||
<SetRow
|
||||
title={tr('vmDir')}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
import { FolderOpen } from 'lucide-react'
|
||||
import React, { useState } from 'react'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { AppState, Locale } from '../types'
|
||||
import { Button } from '../ui/controls'
|
||||
import { api } from '../wails'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
status: AppState['data_root_status']
|
||||
/** Localized reason from the backend (dataroot.Error). */
|
||||
message: string
|
||||
/** The folder changed or reopened; the app reloads its state. */
|
||||
onChanged: () => void
|
||||
onError: (title: string, e: unknown) => void
|
||||
}
|
||||
|
||||
/**
|
||||
* Shown instead of the workspace while the data folder is open read-only
|
||||
* (written by a newer release, damaged version record, failed or concurrent
|
||||
* upgrade). Nothing in the folder has been changed; the user can repair it,
|
||||
* try again, or pick another folder.
|
||||
*/
|
||||
export const DataRootReadOnly: React.FC<Props> = ({ locale, status, message, onChanged, onError }) => {
|
||||
const tr = (k: I18nKey) => t(locale, k)
|
||||
const [busy, setBusy] = useState<'' | 'repair' | 'retry' | 'choose'>('')
|
||||
|
||||
const run = async (kind: 'repair' | 'retry' | 'choose', fn: () => Promise<unknown>) => {
|
||||
setBusy(kind)
|
||||
try {
|
||||
await fn()
|
||||
onChanged()
|
||||
} catch (e) {
|
||||
onError(tr('failGeneric'), e)
|
||||
} finally {
|
||||
setBusy('')
|
||||
}
|
||||
}
|
||||
|
||||
const choose = () => run('choose', async () => {
|
||||
const dir = await api.PickDirectory(tr('dataRootChooseTitle'))
|
||||
if (dir) await api.SetDataRoot(dir)
|
||||
})
|
||||
|
||||
const canRepair = status.reason === 'damaged'
|
||||
const canRetry = status.reason === 'busy' || status.reason === 'migration_failed'
|
||||
|
||||
return (
|
||||
<div className="setup">
|
||||
<div className="setup-card">
|
||||
<div className="setup-head">
|
||||
<h1>{tr('dataRootReadOnlyTitle')}</h1>
|
||||
<p>{message}</p>
|
||||
</div>
|
||||
<div className="list">
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('dataRootReadOnlyFolder')}</div>
|
||||
<div className="row-sub mono selectable">{status.dir}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{status.detail && (
|
||||
<details className="dataroot-detail">
|
||||
<summary>{tr('dataRootReadOnlyDetail')}</summary>
|
||||
<pre className="mono selectable">{status.detail}</pre>
|
||||
</details>
|
||||
)}
|
||||
<div className="setup-foot">
|
||||
<span className="hstack">
|
||||
{canRepair && (
|
||||
<Button busy={busy === 'repair'} disabled={!!busy} onClick={() => void run('repair', () => api.ReopenDataRoot(true))}>
|
||||
{tr('dataRootRepair')}
|
||||
</Button>
|
||||
)}
|
||||
{canRetry && (
|
||||
<Button busy={busy === 'retry'} disabled={!!busy} onClick={() => void run('retry', () => api.ReopenDataRoot(false))}>
|
||||
{tr('dataRootRetry')}
|
||||
</Button>
|
||||
)}
|
||||
</span>
|
||||
<Button variant="primary" icon={<FolderOpen size={14} aria-hidden="true" />} busy={busy === 'choose'} disabled={!!busy} onClick={() => void choose()}>
|
||||
{tr('dataRootChooseOther')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as Alert from '@radix-ui/react-alert-dialog'
|
||||
import React, { useState } from 'react'
|
||||
import { t } from '../i18n'
|
||||
import { Locale } from '../types'
|
||||
import { ConfirmDialog } from '../ui/dialog'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
@@ -13,32 +13,18 @@ interface Props {
|
||||
export const DeleteDialog: React.FC<Props> = ({ locale, name, onCancel, onConfirm }) => {
|
||||
const [keepFiles, setKeepFiles] = useState(false)
|
||||
return (
|
||||
<Alert.Root open onOpenChange={(open) => { if (!open) onCancel() }}>
|
||||
<Alert.Portal>
|
||||
<Alert.Overlay className="overlay" />
|
||||
<Alert.Content className="dialog sm">
|
||||
<div className="dialog-body">
|
||||
<Alert.Title className="dialog-title">{t(locale, 'deleteTitle', { name })}</Alert.Title>
|
||||
<Alert.Description className="dialog-desc">
|
||||
{t(locale, keepFiles ? 'deleteDescKeep' : 'deleteDesc')}
|
||||
</Alert.Description>
|
||||
<label className="choice">
|
||||
<input type="checkbox" checked={keepFiles} onChange={(e) => setKeepFiles(e.target.checked)} />
|
||||
{t(locale, 'deleteKeepFiles')}
|
||||
</label>
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
<Alert.Cancel asChild>
|
||||
<button type="button" className="btn">{t(locale, 'cancel')}</button>
|
||||
</Alert.Cancel>
|
||||
<Alert.Action asChild>
|
||||
<button type="button" className="btn btn-danger" onClick={() => onConfirm(keepFiles)}>
|
||||
{t(locale, 'deleteConfirm')}
|
||||
</button>
|
||||
</Alert.Action>
|
||||
</div>
|
||||
</Alert.Content>
|
||||
</Alert.Portal>
|
||||
</Alert.Root>
|
||||
<ConfirmDialog
|
||||
title={t(locale, 'deleteTitle', { name })}
|
||||
description={t(locale, keepFiles ? 'deleteDescKeep' : 'deleteDesc')}
|
||||
cancelLabel={t(locale, 'cancel')}
|
||||
confirmLabel={t(locale, 'deleteConfirm')}
|
||||
onCancel={onCancel}
|
||||
onConfirm={() => onConfirm(keepFiles)}
|
||||
>
|
||||
<label className="choice">
|
||||
<input type="checkbox" checked={keepFiles} onChange={(e) => setKeepFiles(e.target.checked)} />
|
||||
{t(locale, 'deleteKeepFiles')}
|
||||
</label>
|
||||
</ConfirmDialog>
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import React from 'react'
|
||||
import { resolveActiveLocale, t } from '../i18n'
|
||||
import { events } from '../wails'
|
||||
|
||||
interface State {
|
||||
@@ -28,65 +29,25 @@ export class ErrorBoundary extends React.Component<{ children: React.ReactNode }
|
||||
const { error, stack } = this.state
|
||||
if (!error) return this.props.children
|
||||
|
||||
const isZh = (document.documentElement.lang || '').toLowerCase().startsWith('zh')
|
||||
const docLocale = typeof document !== 'undefined' ? document.documentElement.dataset.locale : undefined
|
||||
const loc = resolveActiveLocale(docLocale || undefined)
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
height: '100%',
|
||||
padding: 24,
|
||||
background: 'var(--surface-canvas, #1c1c1e)',
|
||||
color: 'var(--text, #f5f5f7)',
|
||||
fontFamily: 'var(--font-sans, system-ui, sans-serif)',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
maxWidth: 560,
|
||||
width: '100%',
|
||||
padding: 20,
|
||||
borderRadius: 12,
|
||||
border: '1px solid var(--border, rgba(128,128,128,0.25))',
|
||||
background: 'var(--surface-1, rgba(128,128,128,0.08))',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: 12,
|
||||
}}
|
||||
>
|
||||
<h2 style={{ margin: 0, fontSize: 16 }}>
|
||||
{isZh ? '界面发生异常' : 'Interface encountered an error'}
|
||||
<div className="error-boundary">
|
||||
<div className="error-boundary-card" role="alert">
|
||||
<h2 className="error-boundary-title">
|
||||
{t(loc, 'errorBoundaryTitle')}
|
||||
</h2>
|
||||
<p style={{ margin: 0, fontSize: 13, opacity: 0.85 }}>
|
||||
{isZh
|
||||
? '渲染过程出现未捕获异常,虚拟机和后台服务不受影响。你可以重新加载界面。'
|
||||
: 'An unexpected UI error occurred. Running VMs and background services are unaffected.'}
|
||||
</p>
|
||||
<pre
|
||||
style={{
|
||||
margin: 0,
|
||||
padding: 10,
|
||||
borderRadius: 8,
|
||||
fontSize: 12,
|
||||
maxHeight: 180,
|
||||
overflow: 'auto',
|
||||
background: 'var(--surface-0, rgba(0,0,0,0.2))',
|
||||
border: '1px solid var(--border, rgba(128,128,128,0.2))',
|
||||
whiteSpace: 'pre-wrap',
|
||||
wordBreak: 'break-word',
|
||||
}}
|
||||
>
|
||||
<pre className="error-boundary-pre selectable">
|
||||
{error.message || String(error)}
|
||||
{stack ? `\n\n${stack}` : ''}
|
||||
</pre>
|
||||
<div style={{ display: 'flex', gap: 8, justifyContent: 'flex-end' }}>
|
||||
<div className="error-boundary-actions">
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary"
|
||||
className="btn rg-p-button btn-primary"
|
||||
onClick={() => window.location.reload()}
|
||||
>
|
||||
{isZh ? '重新加载界面' : 'Reload UI'}
|
||||
{t(loc, 'errorBoundaryReload')}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { Cpu, HardDrive, MemoryStick, Plus, RefreshCw, ShieldCheck } from 'lucide-react'
|
||||
import { Cpu, HardDrive, MemoryStick, Plus, RefreshCw, ShieldCheck, Trash } from 'lucide-react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import '../i18n/domains/wizard.gen'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { formatBytes, gpuCompatHint, gpuKey, gpuMetaLine, sameGPU } from '../lib/format'
|
||||
import { AppState, Locale, RuntimeSource, StorageBreakdown, Task } from '../types'
|
||||
import { AppState, Locale, StorageBreakdown, Task } from '../types'
|
||||
import { Button, IconButton } from '../ui/controls'
|
||||
import { api } from '../wails'
|
||||
import { RuntimeOnline } from './RuntimeOnline'
|
||||
@@ -13,23 +15,25 @@ interface Props {
|
||||
onRefresh: () => void
|
||||
onNewVM?: () => void
|
||||
onError: (title: string, e: unknown) => void
|
||||
onToast?: (title: string) => void
|
||||
runtimeTask: Task | null
|
||||
onChannel: (alpha: boolean) => void
|
||||
onSource: (source: RuntimeSource) => void
|
||||
onInstallRuntime: (commit: string) => void
|
||||
onCancelTask: (id: string) => void
|
||||
}
|
||||
|
||||
export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onNewVM, onError, runtimeTask, onChannel, onSource, onInstallRuntime, onCancelTask }) => {
|
||||
export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onNewVM, onError, onToast, runtimeTask, onChannel, onInstallRuntime, onCancelTask }) => {
|
||||
const [importing, setImporting] = useState(false)
|
||||
const [enabling, setEnabling] = useState(false)
|
||||
const [confirmDelete, setConfirmDelete] = useState('')
|
||||
const [removing, setRemoving] = useState('')
|
||||
const [storage, setStorage] = useState<StorageBreakdown | null>(null)
|
||||
const { host, config, runtimes } = state
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
|
||||
useEffect(() => {
|
||||
let live = true
|
||||
api.GetStorageBreakdown().then((s) => { if (live) setStorage(s) }).catch(() => {})
|
||||
api.GetStorageBreakdown().then((s) => { if (live) setStorage(s) }).catch((e) => console.warn('[host] GetStorageBreakdown failed:', e))
|
||||
return () => { live = false }
|
||||
}, [state.config.data_root, state.vms?.length, state.runtimes?.length])
|
||||
|
||||
@@ -64,6 +68,20 @@ export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onNewVM, o
|
||||
setImporting(false)
|
||||
}
|
||||
|
||||
const removeRuntime = async (commit: string) => {
|
||||
setRemoving(commit)
|
||||
try {
|
||||
await api.RemoveRuntime(commit)
|
||||
setConfirmDelete('')
|
||||
onToast?.(tr('runtimeDeleted', { commit }))
|
||||
onRefresh()
|
||||
} catch (e) {
|
||||
onError(tr('failDelete'), e)
|
||||
} finally {
|
||||
setRemoving('')
|
||||
}
|
||||
}
|
||||
|
||||
const gpuKind = (k: string) =>
|
||||
tr(k === 'discrete' ? 'gpuDiscrete' : k === 'integrated' ? 'gpuIntegrated' : k === 'virtual' ? 'gpuVirtual' : 'gpuUnknown')
|
||||
|
||||
@@ -117,7 +135,12 @@ export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onNewVM, o
|
||||
{tr('hostRAM')}
|
||||
</div>
|
||||
<div className="tile-value">{tr('hostRAMAvail', { n: host.avail_ram_gb.toFixed(1) })}</div>
|
||||
<div className="tile-sub">{tr('hostRAMTotal', { n: host.total_ram_gb.toFixed(1) })}</div>
|
||||
<div className="tile-sub">
|
||||
{tr('hostRAMTotal', { n: host.total_ram_gb.toFixed(1) })}
|
||||
{host.memory_spec?.speed_mhz
|
||||
? ` · ${host.memory_spec.speed_mhz} MHz${host.memory_spec.type_name ? ` ${host.memory_spec.type_name}` : ''}`
|
||||
: ''}
|
||||
</div>
|
||||
</div>
|
||||
<div className="tile">
|
||||
<div className="tile-head">
|
||||
@@ -134,11 +157,11 @@ export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onNewVM, o
|
||||
const instPct = (storage.installers_bytes / tot) * 100
|
||||
const rtPct = (storage.runtimes_bytes / tot) * 100
|
||||
return (
|
||||
<section className="card">
|
||||
<section className="card rg-p-card">
|
||||
<div className="card-title">
|
||||
<span>{tr('storageBreakdownTitle')}</span>
|
||||
<span className="spacer" />
|
||||
<span className="muted tnum" style={{ fontSize: 12, fontWeight: 500 }}>{formatBytes(storage.total_bytes)}</span>
|
||||
<span className="muted tnum" style={{ fontSize: 'var(--fs-12)', fontWeight: 'var(--fw-medium)' }}>{formatBytes(storage.total_bytes, locale)}</span>
|
||||
</div>
|
||||
<div className="storage-bar" aria-hidden="true">
|
||||
{vmsPct > 0 && <div className="storage-seg-vms" style={{ width: `${vmsPct}%` }} />}
|
||||
@@ -148,15 +171,15 @@ export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onNewVM, o
|
||||
<div className="storage-legend">
|
||||
<span className="storage-legend-item">
|
||||
<span className="storage-dot storage-seg-vms" aria-hidden="true" />
|
||||
{tr('storageVMs')} · {formatBytes(storage.vms_bytes)}
|
||||
{tr('storageVMs')} · {formatBytes(storage.vms_bytes, locale)}
|
||||
</span>
|
||||
<span className="storage-legend-item">
|
||||
<span className="storage-dot storage-seg-inst" aria-hidden="true" />
|
||||
{tr('storageInstallers')} · {formatBytes(storage.installers_bytes)}
|
||||
{tr('storageInstallers')} · {formatBytes(storage.installers_bytes, locale)}
|
||||
</span>
|
||||
<span className="storage-legend-item">
|
||||
<span className="storage-dot storage-seg-rt" aria-hidden="true" />
|
||||
{tr('storageRuntimes')} · {formatBytes(storage.runtimes_bytes)}
|
||||
{tr('storageRuntimes')} · {formatBytes(storage.runtimes_bytes, locale)}
|
||||
</span>
|
||||
</div>
|
||||
</section>
|
||||
@@ -174,11 +197,9 @@ export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onNewVM, o
|
||||
<RuntimeOnline
|
||||
locale={locale}
|
||||
channel={config.runtime_channel === 'alpha' ? 'alpha' : 'stable'}
|
||||
source={config.runtime_source === 'github' || config.runtime_source === 'gitcode' ? config.runtime_source : 'auto'}
|
||||
installed={runtimes ?? []}
|
||||
task={runtimeTask}
|
||||
onChannel={onChannel}
|
||||
onSource={onSource}
|
||||
onInstall={onInstallRuntime}
|
||||
onCancel={onCancelTask}
|
||||
/>
|
||||
@@ -189,7 +210,28 @@ export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onNewVM, o
|
||||
<div className="row-sub">{rt.manifest.qemu_version.replace(/^QEMU emulator version\s*/i, 'QEMU ')}</div>
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<Button onClick={guard(() => api.UseRuntime(rt.commit))}>{tr('activate')}</Button>
|
||||
{confirmDelete === rt.commit ? (
|
||||
<>
|
||||
<Button variant="ghost" disabled={removing === rt.commit} onClick={() => setConfirmDelete('')}>
|
||||
{tr('cancel')}
|
||||
</Button>
|
||||
<Button variant="danger" busy={removing === rt.commit} onClick={() => removeRuntime(rt.commit)}>
|
||||
{tr('runtimeDeleteConfirm')}
|
||||
</Button>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Button disabled={removing === rt.commit} onClick={guard(() => api.UseRuntime(rt.commit))}>
|
||||
{tr('activate')}
|
||||
</Button>
|
||||
<IconButton
|
||||
label={tr('runtimeDelete')}
|
||||
icon={<Trash size={15} />}
|
||||
disabled={removing !== ''}
|
||||
onClick={() => setConfirmDelete(rt.commit)}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
@@ -211,10 +253,10 @@ export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onNewVM, o
|
||||
<div className="row-main">
|
||||
<div className="row-title" title={g.vulkan_icd}>
|
||||
{g.name}
|
||||
<span className={`badge ${g.kind === 'discrete' ? 'badge-accent' : ''}`}>{gpuKind(g.kind)}</span>
|
||||
{g.compat === 'unsupported' && <span className="badge badge-warn">{tr('gpuCompatUnsupported')}</span>}
|
||||
{g.compat === 'warn' && <span className="badge badge-warn">{tr('gpuCompatWarn')}</span>}
|
||||
{isRec && g.compat !== 'warn' && g.compat !== 'unsupported' && <span className="badge badge-ok">{tr('gpuRecommended')}</span>}
|
||||
<span className={`badge rg-p-badge ${g.kind === 'discrete' ? 'badge-accent' : ''}`}>{gpuKind(g.kind)}</span>
|
||||
{g.compat === 'unsupported' && <span className="badge rg-p-badge badge-warn">{tr('gpuCompatUnsupported')}</span>}
|
||||
{g.compat === 'warn' && <span className="badge rg-p-badge badge-warn">{tr('gpuCompatWarn')}</span>}
|
||||
{isRec && g.compat !== 'warn' && g.compat !== 'unsupported' && <span className="badge rg-p-badge badge-ok">{tr('gpuRecommended')}</span>}
|
||||
</div>
|
||||
{meta && <div className="row-sub">{meta}</div>}
|
||||
{hint && <div className="row-sub warn-text">{hint}</div>}
|
||||
@@ -235,8 +277,8 @@ export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onNewVM, o
|
||||
<div className="row-title">
|
||||
{d.width} × {d.height}
|
||||
{d.refresh_hz ? ` @ ${d.refresh_hz}Hz` : ''}
|
||||
<span className="badge">{d.scale_pct || 100}%</span>
|
||||
{d.primary && <span className="badge badge-ok">{tr('hostDisplayPrimary')}</span>}
|
||||
<span className="badge rg-p-badge">{d.scale_pct || 100}%</span>
|
||||
{d.primary && <span className="badge rg-p-badge badge-ok">{tr('hostDisplayPrimary')}</span>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
import { Disc3, Puzzle, RefreshCw } from 'lucide-react'
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { ImageSourceContribution, Locale, PluginUIContributions } from '../types'
|
||||
import { Button, IconButton } from '../ui/controls'
|
||||
import { Segmented } from '../ui/settings'
|
||||
import { PluginPanelFrame } from './PluginPanelFrame'
|
||||
import { locText } from './SchemaForm'
|
||||
import { WordmarkLoader } from './WordmarkLoader'
|
||||
|
||||
export interface NativeImageSourceRenderOpts {
|
||||
refreshSignal: number
|
||||
onBusyChange: (busy: boolean) => void
|
||||
}
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
appearance: 'light' | 'dark'
|
||||
pluginUI: PluginUIContributions | null
|
||||
renderNativeSource?: (nativeId: string, opts: NativeImageSourceRenderOpts) => React.ReactNode
|
||||
onOpenPlugins: () => void
|
||||
}
|
||||
|
||||
function sourceKey(src: ImageSourceContribution): string {
|
||||
return `${src.pluginId ?? ''}:${src.id}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Top-level Images page: hosts plugin-registered image source tabs via a top
|
||||
* Segmented control. Built-in plugins (such as macOS Images) mount native host
|
||||
* views; external plugins render in a sandboxed L4 iframe.
|
||||
*/
|
||||
export const ImagesPage: React.FC<Props> = ({
|
||||
locale,
|
||||
appearance,
|
||||
pluginUI,
|
||||
renderNativeSource,
|
||||
onOpenPlugins,
|
||||
}) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const sources = useMemo(() => pluginUI?.image_sources ?? [], [pluginUI?.image_sources])
|
||||
const [selectedKey, setSelectedKey] = useState('')
|
||||
const [refreshSignals, setRefreshSignals] = useState<Record<string, number>>({})
|
||||
const [busyByKey, setBusyByKey] = useState<Record<string, boolean>>({})
|
||||
|
||||
const activeSource = useMemo(() => {
|
||||
if (sources.length === 0) return null
|
||||
return sources.find((s) => sourceKey(s) === selectedKey) ?? sources[0]
|
||||
}, [sources, selectedKey])
|
||||
|
||||
const activeKey = activeSource ? sourceKey(activeSource) : ''
|
||||
|
||||
useEffect(() => {
|
||||
if (activeKey && activeKey !== selectedKey) {
|
||||
setSelectedKey(activeKey)
|
||||
}
|
||||
}, [activeKey, selectedKey])
|
||||
|
||||
const activeBusy = activeKey ? !!busyByKey[activeKey] : false
|
||||
|
||||
const handleActiveBusyChange = useCallback((busy: boolean) => {
|
||||
if (!activeKey) return
|
||||
setBusyByKey((prev) => (prev[activeKey] === busy ? prev : { ...prev, [activeKey]: busy }))
|
||||
}, [activeKey])
|
||||
|
||||
const triggerRefresh = () => {
|
||||
if (!activeKey) return
|
||||
setRefreshSignals((prev) => ({ ...prev, [activeKey]: (prev[activeKey] ?? 0) + 1 }))
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="page installers-page">
|
||||
<header className="page-head">
|
||||
<div className="page-title installers-page-title">
|
||||
<h1>{tr('installersTitle')}</h1>
|
||||
<span>{tr('installersHint')}</span>
|
||||
</div>
|
||||
{activeSource && (
|
||||
<div className="actions">
|
||||
<IconButton
|
||||
label={tr('refresh')}
|
||||
icon={<RefreshCw size={16} className={activeBusy ? 'spin' : undefined} />}
|
||||
disabled={activeBusy}
|
||||
onClick={triggerRefresh}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</header>
|
||||
|
||||
{sources.length > 0 && (
|
||||
<div className="images-switch">
|
||||
<Segmented
|
||||
label={tr('imagesSourcesLabel')}
|
||||
value={activeKey}
|
||||
onChange={setSelectedKey}
|
||||
options={sources.map((src) => ({
|
||||
value: sourceKey(src),
|
||||
label: locText(src.title, locale, src.id),
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{pluginUI === null ? (
|
||||
<WordmarkLoader className="installers-loader" />
|
||||
) : !activeSource ? (
|
||||
<div className="empty-panel images-empty">
|
||||
<Disc3 size={28} aria-hidden="true" />
|
||||
<div className="images-empty-title">{tr('imagesNoSourcesTitle')}</div>
|
||||
<div className="images-empty-desc">{tr('imagesNoSourcesDesc')}</div>
|
||||
<Button variant="primary" icon={<Puzzle size={14} aria-hidden="true" />} onClick={onOpenPlugins}>
|
||||
{tr('imagesOpenPlugins')}
|
||||
</Button>
|
||||
</div>
|
||||
) : activeSource.native ? (
|
||||
renderNativeSource?.(activeSource.native, {
|
||||
refreshSignal: refreshSignals[activeKey] ?? 0,
|
||||
onBusyChange: handleActiveBusyChange,
|
||||
})
|
||||
) : (
|
||||
<PluginPanelFrame
|
||||
key={activeKey}
|
||||
locale={locale}
|
||||
panel={{
|
||||
id: activeSource.id,
|
||||
slot: 'images.source',
|
||||
title: activeSource.title,
|
||||
entry: activeSource.entry || 'index.html',
|
||||
height: activeSource.height || 560,
|
||||
pluginId: activeSource.pluginId,
|
||||
}}
|
||||
assetToken={pluginUI.asset_token ?? ''}
|
||||
appearance={appearance}
|
||||
headless
|
||||
maxHeight={1200}
|
||||
refreshSignal={refreshSignals[activeKey] ?? 0}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,283 +0,0 @@
|
||||
import { AlertTriangle, Check, ChevronDown, Download, LoaderCircle, Pause, Plus, RefreshCw, Trash } from 'lucide-react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { macOSMajor } from '../lib/macosRelease'
|
||||
import { taskDetail } from '../lib/tasks'
|
||||
import { CachedInstaller, HostReport, Locale, Release, Task } from '../types'
|
||||
import { Button, IconButton } from '../ui/controls'
|
||||
import { api } from '../wails'
|
||||
import { VersionArt } from './VersionArt'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
host: HostReport
|
||||
tasks: Task[]
|
||||
onCreateWithInstaller: (item: CachedInstaller) => void
|
||||
onError: (title: string, e: unknown) => void
|
||||
onToast: (title: string) => void
|
||||
}
|
||||
|
||||
const gb = (b: number) => (b >= 1e9 ? `${(b / 1e9).toFixed(1)} GB` : `${Math.max(1, Math.ceil(b / 1e6))} MB`)
|
||||
|
||||
// reims-util creates the whole image as soon as a download starts (19.7 GB for an
|
||||
// 18.4 GB release, measured 2026-11-28): reserve 10% over the release size.
|
||||
const needBytes = (r: Release) => r.size * 1.1
|
||||
|
||||
type ReleaseGroup = { key: string; title: string; major: number | null; releases: Release[] }
|
||||
|
||||
/** Newest point release first, one card per macOS major version. */
|
||||
function groupReleases(releases: Release[]): ReleaseGroup[] {
|
||||
const groups = new Map<string, ReleaseGroup>()
|
||||
for (const release of releases) {
|
||||
const major = macOSMajor(release.version, release.title)
|
||||
const key = major === null ? release.title : String(major)
|
||||
const group = groups.get(key) ?? { key, title: release.title, major, releases: [] }
|
||||
group.releases.push(release)
|
||||
groups.set(key, group)
|
||||
}
|
||||
return [...groups.values()]
|
||||
.map((group) => ({ ...group, releases: group.releases.sort((a, b) => b.version.localeCompare(a.version, undefined, { numeric: true })) }))
|
||||
.sort((a, b) => (b.major ?? -1) - (a.major ?? -1) || a.title.localeCompare(b.title))
|
||||
}
|
||||
|
||||
/** Offline installers (roadmap M2.2): what is downloaded, and Apple's releases to download. */
|
||||
export const InstallersPage: React.FC<Props> = ({ locale, host, tasks, onCreateWithInstaller, onError, onToast }) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const [cached, setCached] = useState<CachedInstaller[] | null>(null)
|
||||
const [releases, setReleases] = useState<Release[] | null>(null)
|
||||
const [releasesErr, setReleasesErr] = useState('')
|
||||
const [confirmDelete, setConfirmDelete] = useState('')
|
||||
|
||||
const downloads = tasks.filter((x) => x.kind === 'installer-download')
|
||||
const running = (version: string) => downloads.find((x) => x.status === 'running' && x.subject === version)
|
||||
const finishedCount = downloads.filter((x) => x.status !== 'running').length
|
||||
|
||||
const loadCached = () => api.ListInstallers().then((l) => setCached(l ?? [])).catch((e) => onError(tr('failGeneric'), e))
|
||||
const loadReleases = () => {
|
||||
setReleases(null)
|
||||
setReleasesErr('')
|
||||
api.ListOfflineReleases()
|
||||
.then((l) => setReleases(l ?? []))
|
||||
.catch((e) => setReleasesErr(String(e).replace(/^Error:\s*/, '')))
|
||||
}
|
||||
useEffect(() => { loadReleases() }, [])
|
||||
// Refresh the downloaded list whenever a download starts or ends.
|
||||
useEffect(() => { loadCached() }, [finishedCount, downloads.length])
|
||||
|
||||
const downloaded = (version: string) => (cached ?? []).find((c) => c.kind === 'offline' && !c.partial && c.version === version)
|
||||
const partial = (version: string) => (cached ?? []).some((c) => c.kind === 'offline' && c.partial && c.version === version)
|
||||
|
||||
const download = (version: string) => {
|
||||
api.DownloadInstaller(version).catch((e) => onError(tr('failDownload'), e))
|
||||
}
|
||||
|
||||
const remove = async (name: string) => {
|
||||
if (confirmDelete !== name) { setConfirmDelete(name); return }
|
||||
setConfirmDelete('')
|
||||
try {
|
||||
await api.DeleteInstaller(name)
|
||||
onToast(tr('toastDeleted', { name }))
|
||||
loadCached()
|
||||
} catch (e) {
|
||||
onError(tr('failDelete'), e)
|
||||
}
|
||||
}
|
||||
|
||||
const progress = (task: Task) => (
|
||||
<span className="task-inline row-sub">
|
||||
<LoaderCircle size={14} className="spin" aria-hidden="true" />
|
||||
{task.percent >= 0 && (
|
||||
<span className="progress" aria-hidden="true">
|
||||
<span className="progress-fill" style={{ transform: `scaleX(${Math.max(0, Math.min(1, task.percent / 100))})` }} />
|
||||
</span>
|
||||
)}
|
||||
<span>{task.percent >= 0 ? `${Math.floor(task.percent)}%` : ''} {taskDetail(task)}</span>
|
||||
</span>
|
||||
)
|
||||
|
||||
const skeleton = (rows: number, label?: string) => (
|
||||
<div className="skeleton-list" role="status" aria-label={label}>
|
||||
{Array.from({ length: rows }).map((_, i) => (
|
||||
<div className="skeleton-row" key={i} aria-hidden="true">
|
||||
<div className="skeleton-stack">
|
||||
<div className="skeleton-bar w-title" />
|
||||
<div className="skeleton-bar w-sub" />
|
||||
</div>
|
||||
<div className="skeleton-bar w-btn" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
|
||||
const spaceShort = (r: Release) => !downloaded(r.version) && !running(r.version) && host.free_disk_gb > 0 && host.free_disk_gb * 1e9 < needBytes(r)
|
||||
|
||||
const releaseAction = (r: Release) => {
|
||||
const task = running(r.version)
|
||||
if (task) return <IconButton label={tr('pauseDownload')} icon={<Pause size={16} />} onClick={() => api.CancelTask(task.id)} />
|
||||
const item = downloaded(r.version)
|
||||
if (item) {
|
||||
return (
|
||||
<Button variant="primary" icon={<Plus size={14} />} onClick={() => onCreateWithInstaller(item)}>
|
||||
{tr('installersCreateVM')}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<Button icon={<Download size={14} />} disabled={spaceShort(r)} onClick={() => download(r.version)}>
|
||||
{partial(r.version) ? tr('installersResume') : tr('installersDownload')}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
const releaseMeta = (r: Release) => (
|
||||
<div className="row-sub">
|
||||
{r.posted} · {gb(r.size)}
|
||||
{spaceShort(r) && <span className="warn-text"> · {tr('installersNoSpace', { need: Math.ceil(needBytes(r) / 1e9), free: host.free_disk_gb.toFixed(0) })}</span>}
|
||||
</div>
|
||||
)
|
||||
|
||||
const groups = groupReleases(releases ?? [])
|
||||
const showDownloaded = cached === null || cached.length > 0 || downloads.length > 0
|
||||
|
||||
return (
|
||||
<div className="page installers-page">
|
||||
<header className="page-head">
|
||||
<div className="page-title installers-page-title">
|
||||
<h1>{tr('installersTitle')}</h1>
|
||||
<span>{tr('installersHint')}</span>
|
||||
</div>
|
||||
<div className="actions">
|
||||
<IconButton label={tr('refresh')} icon={<RefreshCw size={16} />} onClick={() => { loadCached(); loadReleases() }} />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{showDownloaded && (
|
||||
<section className="section">
|
||||
<div className="section-title">
|
||||
<span>{tr('installersDownloaded')}</span>
|
||||
{cached && cached.length > 0 && <span className="section-count">{cached.length}</span>}
|
||||
</div>
|
||||
{cached === null || (cached.length === 0 && downloads.length > 0) ? (
|
||||
skeleton(1, tr('installersDownloaded'))
|
||||
) : (
|
||||
<div className="list installer-list">
|
||||
{cached.map((c) => {
|
||||
const task = c.version ? running(c.version) : undefined
|
||||
const title = c.title ?? c.name
|
||||
return (
|
||||
<div className="row installer-row" key={c.name} title={c.name}>
|
||||
<span className="installer-art">
|
||||
<VersionArt shape="tile" major={macOSMajor(c.version, title)} name={title} />
|
||||
</span>
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
<span>{title} {c.version}</span>
|
||||
{c.kind === 'offline' && !c.partial && <span className="badge badge-ok">{tr('installersKindOffline')}</span>}
|
||||
{c.kind === 'online' && !c.partial && <span className="badge">{tr('installersKindOnline')}</span>}
|
||||
{c.partial && !task && <span className="badge badge-warn">{tr('installersPartial')}</span>}
|
||||
</div>
|
||||
{task ? progress(task) : (
|
||||
<div className="row-sub">{gb(c.bytes)}{c.build ? ` · ${c.build}` : ''}</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="row-right">
|
||||
{task ? (
|
||||
<IconButton label={tr('pauseDownload')} icon={<Pause size={16} />} onClick={() => api.CancelTask(task.id)} />
|
||||
) : (
|
||||
<>
|
||||
{!c.partial && (c.kind === 'offline' || c.kind === 'online') && (
|
||||
<Button variant={c.kind === 'offline' ? 'primary' : 'secondary'} icon={<Plus size={14} />} onClick={() => onCreateWithInstaller(c)}>
|
||||
{tr('installersCreateVM')}
|
||||
</Button>
|
||||
)}
|
||||
{c.partial && c.kind === 'offline' && c.version && (
|
||||
<Button icon={<Download size={14} />} onClick={() => download(c.version!)}>{tr('installersResume')}</Button>
|
||||
)}
|
||||
{confirmDelete === c.name ? (
|
||||
<Button variant="danger" onClick={() => remove(c.name)}>{tr('installersDeleteConfirm')}</Button>
|
||||
) : (
|
||||
<IconButton label={tr('installersDelete')} icon={<Trash size={15} />} onClick={() => remove(c.name)} />
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
)}
|
||||
|
||||
<section className="section">
|
||||
<div className="section-title">{tr('installersAvailable')}</div>
|
||||
{releasesErr ? (
|
||||
<div className="notice notice-error" role="alert">
|
||||
<span className="notice-main">
|
||||
<AlertTriangle size={15} className="notice-icon" aria-hidden="true" />
|
||||
<span>{tr('offlineListFailedDetail', { err: releasesErr })}</span>
|
||||
</span>
|
||||
<Button onClick={loadReleases}>{tr('installersRetry')}</Button>
|
||||
</div>
|
||||
) : releases === null ? (
|
||||
<>
|
||||
{skeleton(2, tr('offlineLoading'))}
|
||||
<span className="hint">{tr('offlineLoading')}</span>
|
||||
</>
|
||||
) : (
|
||||
<div className="release-list">
|
||||
{groups.map((group, groupIndex) => {
|
||||
const [latest, ...older] = group.releases
|
||||
const task = running(latest.version)
|
||||
return (
|
||||
<article className="release-card" key={group.key}>
|
||||
<div className="release-latest">
|
||||
<span className="release-art">
|
||||
<VersionArt shape="tile" major={group.major} name={group.title} />
|
||||
</span>
|
||||
<div className="release-copy">
|
||||
<div className="row-title release-title">
|
||||
<span>{latest.title}</span>
|
||||
<strong>{latest.version}</strong>
|
||||
{groupIndex === 0 && <span className="badge badge-accent">{tr('installersLatest')}</span>}
|
||||
{downloaded(latest.version) && <Check size={15} className="ok-text" aria-label={tr('offlineCached')} />}
|
||||
</div>
|
||||
{task ? progress(task) : releaseMeta(latest)}
|
||||
</div>
|
||||
<div className="row-right">{releaseAction(latest)}</div>
|
||||
</div>
|
||||
{older.length > 0 && (
|
||||
<details className="release-history">
|
||||
<summary>
|
||||
<span>{tr('installersOlder', { count: older.length })}</span>
|
||||
<ChevronDown size={14} aria-hidden="true" />
|
||||
</summary>
|
||||
<div className="release-history-list">
|
||||
{older.map((r) => {
|
||||
const oldTask = running(r.version)
|
||||
return (
|
||||
<div className="release-history-row" key={r.product}>
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
<span>{r.version}</span>
|
||||
<span className="muted">{r.build}</span>
|
||||
{downloaded(r.version) && <span className="badge badge-ok">{tr('offlineCached')}</span>}
|
||||
</div>
|
||||
{oldTask ? progress(oldTask) : releaseMeta(r)}
|
||||
</div>
|
||||
<div className="row-right">{releaseAction(r)}</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</details>
|
||||
)}
|
||||
</article>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
import { AlertTriangle, ArrowDown, ChevronDown, ChevronUp, Copy, Eraser, LoaderCircle, Pause, RefreshCw } from 'lucide-react'
|
||||
import { AlertTriangle, ArrowDown, ChevronDown, ChevronUp, Copy, Eraser, LoaderCircle, Pause, RefreshCw, X } from 'lucide-react'
|
||||
import React, { useLayoutEffect, useMemo, useRef, useState } from 'react'
|
||||
import { t } from '../i18n'
|
||||
import { LogLine } from '../lib/logs'
|
||||
import { taskDetail, taskTitle } from '../lib/tasks'
|
||||
import { taskDetail, taskInstallerPhase, taskStopAction, taskTitle } from '../lib/tasks'
|
||||
import { HostReport, Locale, Task } from '../types'
|
||||
import { Button, IconButton, Tip } from '../ui/controls'
|
||||
import { HostIcon } from '../ui/themeVisuals'
|
||||
|
||||
export type LogTab = 'app' | 'serial' | 'qemu'
|
||||
|
||||
@@ -127,9 +128,18 @@ export const LogPanel: React.FC<Props> = ({
|
||||
try {
|
||||
const saved = Number(localStorage.getItem(LOG_HEIGHT_KEY))
|
||||
if (Number.isFinite(saved) && saved >= MIN_LOG_HEIGHT && saved <= MAX_LOG_HEIGHT) return saved
|
||||
} catch {}
|
||||
} catch (e) {
|
||||
console.warn('[logPanel] read persisted height failed:', e)
|
||||
}
|
||||
return DEFAULT_LOG_HEIGHT
|
||||
})
|
||||
const persistHeight = (value: number) => {
|
||||
try {
|
||||
localStorage.setItem(LOG_HEIGHT_KEY, String(value))
|
||||
} catch (e) {
|
||||
console.warn('[logPanel] persist height failed:', e)
|
||||
}
|
||||
}
|
||||
const [dragging, setDragging] = useState(false)
|
||||
const dragRef = useRef<{ startY: number; startH: number } | null>(null)
|
||||
|
||||
@@ -149,7 +159,7 @@ export const LogPanel: React.FC<Props> = ({
|
||||
dragRef.current = null
|
||||
setDragging(false)
|
||||
if (e.currentTarget.hasPointerCapture(e.pointerId)) e.currentTarget.releasePointerCapture(e.pointerId)
|
||||
try { localStorage.setItem(LOG_HEIGHT_KEY, String(height)) } catch {}
|
||||
persistHeight(height)
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -158,25 +168,44 @@ export const LogPanel: React.FC<Props> = ({
|
||||
<div
|
||||
className="log-resize-handle"
|
||||
role="separator"
|
||||
tabIndex={0}
|
||||
aria-orientation="horizontal"
|
||||
aria-label={tr('resizeLogPanel')}
|
||||
aria-valuemin={MIN_LOG_HEIGHT}
|
||||
aria-valuemax={MAX_LOG_HEIGHT}
|
||||
aria-valuenow={height}
|
||||
data-dragging={dragging}
|
||||
onPointerDown={onResizeDown}
|
||||
onPointerMove={onResizeMove}
|
||||
onPointerUp={onResizeUp}
|
||||
onPointerCancel={onResizeUp}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown') return
|
||||
e.preventDefault()
|
||||
const delta = e.key === 'ArrowUp' ? 24 : -24
|
||||
const next = Math.min(MAX_LOG_HEIGHT, Math.max(MIN_LOG_HEIGHT, height + delta))
|
||||
setHeight(next)
|
||||
persistHeight(next)
|
||||
}}
|
||||
onDoubleClick={() => {
|
||||
setHeight(DEFAULT_LOG_HEIGHT)
|
||||
try { localStorage.setItem(LOG_HEIGHT_KEY, String(DEFAULT_LOG_HEIGHT)) } catch {}
|
||||
persistHeight(DEFAULT_LOG_HEIGHT)
|
||||
}}
|
||||
>
|
||||
<span className="log-resize-pill" aria-hidden="true" />
|
||||
</div>
|
||||
)}
|
||||
<div className="logbar rg-p-statusbar">
|
||||
<span className="rg-slot-inline" data-rg-slot="statusbar.left" />
|
||||
{task ? (
|
||||
<>
|
||||
<Tip label={[task.step, taskDetail(task)].filter(Boolean).join(' · ') || taskTitle(locale, task)} side="top">
|
||||
<Tip
|
||||
label={[
|
||||
taskInstallerPhase(task) === 'queued' ? tr('installersQueuedDesc') : task.step,
|
||||
taskDetail(task),
|
||||
].filter(Boolean).join(' · ') || taskTitle(locale, task)}
|
||||
side="top"
|
||||
>
|
||||
<span className="task" tabIndex={0}>
|
||||
<LoaderCircle size={14} className="spin" aria-hidden="true" />
|
||||
<span className="task-label">
|
||||
@@ -184,7 +213,7 @@ export const LogPanel: React.FC<Props> = ({
|
||||
</span>
|
||||
{task.percent >= 0 && (
|
||||
<>
|
||||
<span className="progress" aria-hidden="true">
|
||||
<span className="progress rg-p-progress" aria-hidden="true">
|
||||
<span className="progress-fill" style={{ transform: `scaleX(${Math.max(0, Math.min(1, task.percent / 100))})` }} />
|
||||
</span>
|
||||
<span className="task-pct">{Math.floor(task.percent)}%</span>
|
||||
@@ -192,9 +221,18 @@ export const LogPanel: React.FC<Props> = ({
|
||||
)}
|
||||
</span>
|
||||
</Tip>
|
||||
{task.cancelable && (
|
||||
<IconButton small tipSide="top" label={tr('pauseDownload')} icon={<Pause size={14} />} onClick={() => onCancelTask(task.id)} />
|
||||
)}
|
||||
{task.cancelable && (() => {
|
||||
const stop = taskStopAction(locale, task)
|
||||
return (
|
||||
<IconButton
|
||||
small
|
||||
tipSide="top"
|
||||
label={stop.label}
|
||||
icon={stop.kind === 'cancel' ? <X size={14} /> : <Pause size={14} />}
|
||||
onClick={() => onCancelTask(task.id)}
|
||||
/>
|
||||
)
|
||||
})()}
|
||||
</>
|
||||
) : host ? (
|
||||
// Host at a glance: a problem first (only when there is one), then
|
||||
@@ -204,7 +242,7 @@ export const LogPanel: React.FC<Props> = ({
|
||||
{!hostReady && onOpenHost && (
|
||||
<Tip side="top" label={tr('footerHostIssueTip')}>
|
||||
<button type="button" className="status-metric status-issue" onClick={onOpenHost}>
|
||||
<AlertTriangle size={12} aria-hidden="true" />
|
||||
<HostIcon name="warning"><AlertTriangle size={12} aria-hidden="true" /></HostIcon>
|
||||
<span>{tr('footerHostIssue')}</span>
|
||||
</button>
|
||||
</Tip>
|
||||
@@ -265,16 +303,31 @@ export const LogPanel: React.FC<Props> = ({
|
||||
{tr('logErrorsOnly')}
|
||||
</button>
|
||||
)}
|
||||
<div className="tabs" role="tablist">
|
||||
<button type="button" role="tab" className="tab" aria-selected={tab === 'app'} onClick={() => onTab('app')}>
|
||||
<div
|
||||
className="tabs rg-p-tabs"
|
||||
role="tablist"
|
||||
onKeyDown={(e) => {
|
||||
if (e.key !== 'ArrowRight' && e.key !== 'ArrowLeft') return
|
||||
e.preventDefault()
|
||||
const order: LogTab[] = showSerial ? ['app', 'serial', 'qemu'] : ['app']
|
||||
const cur = Math.max(0, order.indexOf(tab))
|
||||
const isRTL = getComputedStyle(e.currentTarget).direction === 'rtl'
|
||||
const delta = (e.key === 'ArrowRight') !== isRTL ? 1 : -1
|
||||
const next = order[(cur + delta + order.length) % order.length]
|
||||
onTab(next)
|
||||
const btns = e.currentTarget.querySelectorAll<HTMLButtonElement>('[role="tab"]')
|
||||
btns[order.indexOf(next)]?.focus()
|
||||
}}
|
||||
>
|
||||
<button type="button" role="tab" className="tab rg-p-tab" tabIndex={tab === 'app' ? 0 : -1} aria-selected={tab === 'app'} onClick={() => onTab('app')}>
|
||||
{tr('logActivity')}
|
||||
</button>
|
||||
{showSerial && (
|
||||
<>
|
||||
<button type="button" role="tab" className="tab" aria-selected={tab === 'serial'} onClick={() => onTab('serial')}>
|
||||
<button type="button" role="tab" className="tab rg-p-tab" tabIndex={tab === 'serial' ? 0 : -1} aria-selected={tab === 'serial'} onClick={() => onTab('serial')}>
|
||||
{tr('logSerial')}
|
||||
</button>
|
||||
<button type="button" role="tab" className="tab" aria-selected={tab === 'qemu'} onClick={() => onTab('qemu')}>
|
||||
<button type="button" role="tab" className="tab rg-p-tab" tabIndex={tab === 'qemu' ? 0 : -1} aria-selected={tab === 'qemu'} onClick={() => onTab('qemu')}>
|
||||
{tr('logQemu')}
|
||||
</button>
|
||||
</>
|
||||
@@ -295,7 +348,7 @@ export const LogPanel: React.FC<Props> = ({
|
||||
<IconButton small tipSide="top" label={tr('refresh')} icon={<RefreshCw size={14} />} onClick={onRefreshQemu} />
|
||||
)}
|
||||
<span className="rg-slot-inline" data-rg-slot="statusbar.right" />
|
||||
{!open && unseenErrors > 0 && <span className="badge badge-error" aria-hidden="true">{unseenErrors}</span>}
|
||||
{!open && unseenErrors > 0 && <span className="badge rg-p-badge badge-error" aria-hidden="true">{unseenErrors}</span>}
|
||||
<Tip label={open ? tr('collapseLogs') : tr('expandLogs')} shortcut="Ctrl+L" side="top">
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
import {
|
||||
Boxes, Clipboard, Compass, Cpu, Disc3, Globe, Keyboard,
|
||||
Layers, Monitor, Palette, Puzzle, RotateCcw,
|
||||
} from 'lucide-react'
|
||||
import React from 'react'
|
||||
import { PermissionSpec } from '../types'
|
||||
|
||||
export interface PluginVisualSource {
|
||||
id?: string
|
||||
kind?: string
|
||||
system?: boolean
|
||||
tier?: string
|
||||
locales?: string[]
|
||||
permissions?: Array<PermissionSpec | string>
|
||||
}
|
||||
|
||||
export interface PluginVisual {
|
||||
tone: string
|
||||
icon: React.ReactNode
|
||||
}
|
||||
|
||||
const ICON_SIZES = { sm: 16, md: 18, lg: 20 } as const
|
||||
|
||||
/**
|
||||
* Single visual resolver for both installed plugins (PluginInfo) and market
|
||||
* entries (MarketEntry), so a plugin keeps the same icon and colour across
|
||||
* Market, Installed and first-run setup.
|
||||
*/
|
||||
export function resolvePluginVisual(src: PluginVisualSource, iconSize = 20): PluginVisual {
|
||||
if (src.system) return { tone: 'indigo', icon: <Boxes size={iconSize} aria-hidden="true" /> }
|
||||
switch (src.kind) {
|
||||
case 'theme': return { tone: 'purple', icon: <Palette size={iconSize} aria-hidden="true" /> }
|
||||
case 'locale': return { tone: 'sky', icon: <Globe size={iconSize} aria-hidden="true" /> }
|
||||
case 'driver':
|
||||
case 'runtime': return { tone: 'indigo', icon: <Monitor size={iconSize} aria-hidden="true" /> }
|
||||
}
|
||||
const id = (src.id ?? '').toLowerCase()
|
||||
const perms = new Set((src.permissions ?? []).map((x) => (typeof x === 'string' ? x : x.name)))
|
||||
if ((src.locales?.length ?? 0) > 0 || id.includes('lang') || id.includes('locale')) {
|
||||
return { tone: 'sky', icon: <Globe size={iconSize} aria-hidden="true" /> }
|
||||
}
|
||||
if (id.includes('theme') || perms.has('ui:script')) {
|
||||
return { tone: 'purple', icon: <Palette size={iconSize} aria-hidden="true" /> }
|
||||
}
|
||||
if (id.includes('driver') || perms.has('driver:vm') || perms.has('runtime:provider')) {
|
||||
return { tone: 'indigo', icon: <Monitor size={iconSize} aria-hidden="true" /> }
|
||||
}
|
||||
if (id.includes('clipboard') || perms.has('host:clipboard')) {
|
||||
return { tone: 'sky', icon: <Clipboard size={iconSize} aria-hidden="true" /> }
|
||||
}
|
||||
if (id.includes('ime') || id.includes('input') || id.includes('wheel') || perms.has('input:filter')) {
|
||||
return { tone: 'rose', icon: <Keyboard size={iconSize} aria-hidden="true" /> }
|
||||
}
|
||||
if (id.includes('reboot')) {
|
||||
return { tone: 'amber', icon: <RotateCcw size={iconSize} aria-hidden="true" /> }
|
||||
}
|
||||
if (id.includes('whpx') || id.includes('irq')) {
|
||||
return { tone: 'emerald', icon: <Cpu size={iconSize} aria-hidden="true" /> }
|
||||
}
|
||||
if (id.includes('guide')) {
|
||||
return { tone: 'teal', icon: <Compass size={iconSize} aria-hidden="true" /> }
|
||||
}
|
||||
if (id.includes('offline') || id.includes('installer') || id.includes('helper') || id.includes('image')) {
|
||||
return { tone: 'teal', icon: <Disc3 size={iconSize} aria-hidden="true" /> }
|
||||
}
|
||||
if (src.tier === 'L3') {
|
||||
return { tone: 'slate', icon: <Layers size={iconSize} aria-hidden="true" /> }
|
||||
}
|
||||
return { tone: 'teal', icon: <Puzzle size={iconSize} aria-hidden="true" /> }
|
||||
}
|
||||
|
||||
/** App Store-inspired squircle icon tile shared by Market, Installed and Setup. */
|
||||
export const PluginAppIcon: React.FC<{
|
||||
plugin?: PluginVisualSource
|
||||
kind?: string
|
||||
size?: 'sm' | 'md' | 'lg'
|
||||
}> = ({ plugin, kind, size = 'lg' }) => {
|
||||
const vis = resolvePluginVisual(plugin ?? { kind }, ICON_SIZES[size])
|
||||
const sizeCls = size === 'lg' ? '' : ` is-${size}`
|
||||
return <div className={`plugin-app-icon tone-${vis.tone}${sizeCls}`}>{vis.icon}</div>
|
||||
}
|
||||
@@ -0,0 +1,387 @@
|
||||
import { AlertTriangle, Check, Download, ShieldAlert } from 'lucide-react'
|
||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import '../i18n/domains/plugins.gen'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { Locale, MarketBrowseResult, MarketCatalogItem, PluginInfo } from '../types'
|
||||
import { Button, Tip } from '../ui/controls'
|
||||
import { Modal } from '../ui/dialog'
|
||||
import { api, events, MarketInstallProgress } from '../wails'
|
||||
import { PluginAppIcon, PluginSearchInput, PluginTrustBadge, RiskList } from './PluginParts'
|
||||
import { locText } from './SchemaForm'
|
||||
import { WordmarkLoader } from './WordmarkLoader'
|
||||
|
||||
// Cards are revealed in pages as the feed scrolls into view.
|
||||
const PAGE_SIZE = 24
|
||||
// A manual refresh keeps the loader up at least this long, so it reads as a
|
||||
// response instead of a flicker.
|
||||
const MIN_REFRESH_MS = 900
|
||||
const QUERY_DEBOUNCE_MS = 180
|
||||
|
||||
const KIND_LABELS: Record<string, I18nKey> = {
|
||||
theme: 'pluginMarketKindTheme',
|
||||
locale: 'pluginMarketKindLocale',
|
||||
driver: 'pluginMarketKindDriver',
|
||||
tool: 'pluginMarketKindTool',
|
||||
template: 'pluginMarketKindTemplate',
|
||||
runtime: 'pluginMarketKindRuntime',
|
||||
}
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
safeMode?: boolean
|
||||
/** Installed plugins; a change re-reads install state from the cache. */
|
||||
installed: PluginInfo[]
|
||||
/** Bumped by the page's refresh button to force a network fetch. */
|
||||
refreshSignal: number
|
||||
onBusyChange: (busy: boolean) => void
|
||||
/** Called after an install or enable so the page reloads its plugin list. */
|
||||
onChanged: (opts: { enabled?: PluginInfo }) => Promise<void> | void
|
||||
onError: (title: string, e: unknown) => void
|
||||
}
|
||||
|
||||
type ProgressMap = Record<string, MarketInstallProgress>
|
||||
|
||||
/**
|
||||
* Plugin market feed: a multi-column card grid that paints from the local
|
||||
* cache first, revalidates over the network, and reveals cards page by page.
|
||||
*/
|
||||
export const PluginMarket: React.FC<Props> = ({
|
||||
locale, safeMode, installed, refreshSignal, onBusyChange, onChanged, onError,
|
||||
}) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const [query, setQuery] = useState('')
|
||||
const [kind, setKind] = useState('')
|
||||
const [result, setResult] = useState<MarketBrowseResult | null>(null)
|
||||
const [syncing, setSyncing] = useState(false)
|
||||
const [refreshing, setRefreshing] = useState(false)
|
||||
const [visible, setVisible] = useState(PAGE_SIZE)
|
||||
const [progress, setProgress] = useState<ProgressMap>({})
|
||||
const [prompt, setPrompt] = useState<PluginInfo | null>(null)
|
||||
const [promptChecked, setPromptChecked] = useState(false)
|
||||
const [enabling, setEnabling] = useState(false)
|
||||
|
||||
const seq = useRef(0)
|
||||
const synced = useRef(false)
|
||||
const sentinel = useRef<HTMLDivElement>(null)
|
||||
const params = useRef({ query, kind })
|
||||
params.current = { query, kind }
|
||||
|
||||
useEffect(() => { onBusyChange(syncing) }, [syncing])
|
||||
|
||||
// Network load. Stale responses (an older query) are dropped.
|
||||
const sync = useCallback(async (force: boolean) => {
|
||||
const id = ++seq.current
|
||||
const { query: q, kind: k } = params.current
|
||||
setSyncing(true)
|
||||
const started = Date.now()
|
||||
if (force) setRefreshing(true)
|
||||
try {
|
||||
const res = await api.BrowsePluginMarket(q, k, false, force)
|
||||
if (force) {
|
||||
const wait = MIN_REFRESH_MS - (Date.now() - started)
|
||||
if (wait > 0) await new Promise((r) => window.setTimeout(r, wait))
|
||||
}
|
||||
if (id !== seq.current) return
|
||||
setResult(res)
|
||||
synced.current = true
|
||||
} catch (e) {
|
||||
if (id === seq.current) onError(tr('pluginFailMarketLoad'), e)
|
||||
} finally {
|
||||
if (id === seq.current) {
|
||||
setSyncing(false)
|
||||
setRefreshing(false)
|
||||
}
|
||||
}
|
||||
}, [])
|
||||
|
||||
// Cache-only read: instant, no network.
|
||||
const peek = useCallback(async (keepNetworkState: boolean) => {
|
||||
const { query: q, kind: k } = params.current
|
||||
try {
|
||||
const res = await api.PeekPluginMarket(q, k)
|
||||
setResult((prev) => {
|
||||
if (keepNetworkState && prev) {
|
||||
res.stale = prev.stale
|
||||
res.fetch_error = prev.fetch_error
|
||||
}
|
||||
return res
|
||||
})
|
||||
} catch (e) {
|
||||
// the network load reports errors
|
||||
console.warn('[market] PeekPluginMarket failed:', e)
|
||||
}
|
||||
}, [])
|
||||
|
||||
// First open: paint from cache, then revalidate.
|
||||
useEffect(() => {
|
||||
void peek(false).then(() => sync(false))
|
||||
}, [])
|
||||
|
||||
// Query and category changes; the first render is handled above.
|
||||
const firstFilter = useRef(true)
|
||||
useEffect(() => {
|
||||
if (firstFilter.current) { firstFilter.current = false; return }
|
||||
setVisible(PAGE_SIZE)
|
||||
const timer = window.setTimeout(() => { void sync(false) }, query ? QUERY_DEBOUNCE_MS : 0)
|
||||
return () => window.clearTimeout(timer)
|
||||
}, [query, kind])
|
||||
|
||||
const firstRefresh = useRef(true)
|
||||
useEffect(() => {
|
||||
if (firstRefresh.current) { firstRefresh.current = false; return }
|
||||
void sync(true)
|
||||
}, [refreshSignal])
|
||||
|
||||
// Install state lives in the plugin list; re-read it without the network.
|
||||
const firstInstalled = useRef(true)
|
||||
useEffect(() => {
|
||||
if (firstInstalled.current) { firstInstalled.current = false; return }
|
||||
if (synced.current) void peek(true)
|
||||
}, [installed])
|
||||
|
||||
useEffect(() => events.onPluginInstall((p) => {
|
||||
setProgress((prev) => prev[p.id] ? { ...prev, [p.id]: p } : prev)
|
||||
}), [])
|
||||
|
||||
const items = result?.items ?? []
|
||||
const shown = items.slice(0, visible)
|
||||
const hasMore = items.length > visible
|
||||
|
||||
// Reveal the next page as the sentinel nears the viewport.
|
||||
useEffect(() => {
|
||||
const el = sentinel.current
|
||||
if (!el || !hasMore || typeof IntersectionObserver === 'undefined') return
|
||||
const io = new IntersectionObserver((entries) => {
|
||||
if (entries.some((e) => e.isIntersecting)) setVisible((v) => v + PAGE_SIZE)
|
||||
}, { rootMargin: '240px 0px' })
|
||||
io.observe(el)
|
||||
return () => io.disconnect()
|
||||
}, [hasMore, visible, items.length])
|
||||
|
||||
const install = async (item: MarketCatalogItem) => {
|
||||
const id = item.entry.id
|
||||
setProgress((prev) => ({ ...prev, [id]: { id, phase: 'download', done: 0, total: item.entry.size_bytes ?? 0 } }))
|
||||
try {
|
||||
const info = await api.InstallMarketPlugin(id, false)
|
||||
await onChanged({})
|
||||
if (info && !info.enabled) {
|
||||
setPromptChecked(false)
|
||||
setPrompt(info)
|
||||
}
|
||||
} catch (e) {
|
||||
onError(tr('pluginFailMarketInstall'), e)
|
||||
} finally {
|
||||
setProgress((prev) => {
|
||||
const next = { ...prev }
|
||||
delete next[id]
|
||||
return next
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const enablePrompted = async () => {
|
||||
if (!prompt) return
|
||||
setEnabling(true)
|
||||
try {
|
||||
const target = prompt
|
||||
await api.EnablePlugin(target.id, target.needs_approval)
|
||||
setPrompt(null)
|
||||
await onChanged({ enabled: target })
|
||||
} catch (e) {
|
||||
onError(tr('pluginFailEnable'), e)
|
||||
} finally {
|
||||
setEnabling(false)
|
||||
}
|
||||
}
|
||||
|
||||
const facets = useMemo(() => {
|
||||
const list = [...(result?.kinds ?? [])]
|
||||
if (kind && !list.some((f) => f.kind === kind)) list.push({ kind, count: 0 })
|
||||
return list
|
||||
}, [result, kind])
|
||||
const kindLabel = (k: string) => KIND_LABELS[k] ? tr(KIND_LABELS[k]) : k.charAt(0).toUpperCase() + k.slice(1)
|
||||
|
||||
const action = (item: MarketCatalogItem) => {
|
||||
const e = item.entry
|
||||
const p = progress[e.id]
|
||||
if (p) {
|
||||
const pct = p.phase === 'download' && p.total > 0 ? Math.min(100, Math.round((p.done / p.total) * 100)) : null
|
||||
const text = p.phase === 'install' ? tr('pluginMarketInstalling') : pct === null ? tr('pluginMarketDownloading') : `${pct}%`
|
||||
return (
|
||||
<div
|
||||
className={`market-progress rg-p-progress${pct === null ? ' is-indeterminate' : ''}`}
|
||||
role="progressbar"
|
||||
aria-label={tr('pluginMarketDownloading')}
|
||||
aria-valuemin={0}
|
||||
aria-valuemax={100}
|
||||
aria-valuenow={pct ?? undefined}
|
||||
>
|
||||
<span className="market-progress-fill" style={pct === null ? undefined : { transform: `scaleX(${pct / 100})` }} />
|
||||
<span className="market-progress-text">{text}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
if (item.withdrawn) {
|
||||
const why = locText(item.withdrawn.reason, locale, '')
|
||||
+ (item.withdrawn.instead_id ? ` · ${tr('pluginMarketWithdrawnInstead', { target: item.withdrawn.instead_name || item.withdrawn.instead_id })}` : '')
|
||||
return <Tip label={why || tr('pluginMarketWithdrawn')}><span tabIndex={0}><Button className="market-btn" disabled>{tr('pluginMarketWithdrawn')}</Button></span></Tip>
|
||||
}
|
||||
if (!item.compatible) {
|
||||
return <Tip label={item.incompatible_reason || tr('pluginMarketIncompatible')}><span tabIndex={0}><Button className="market-btn" disabled>{tr('pluginMarketIncompatible')}</Button></span></Tip>
|
||||
}
|
||||
if (item.installed && !item.update_available) {
|
||||
return <Button className="market-btn" disabled icon={<Check size={13} aria-hidden="true" />}>{tr('pluginMarketInstalled')}</Button>
|
||||
}
|
||||
if (item.update_available) {
|
||||
return (
|
||||
<Tip label={tr('pluginMarketVersionTip', { installed: item.installed_version ?? '', version: e.version })}>
|
||||
<span>
|
||||
<Button className="market-btn" variant="primary" disabled={!!safeMode} icon={<Download size={13} aria-hidden="true" />} onClick={() => void install(item)}>
|
||||
{tr('pluginMarketUpdateShort')}
|
||||
</Button>
|
||||
</span>
|
||||
</Tip>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<Button className="market-btn" disabled={!!safeMode} icon={<Download size={13} aria-hidden="true" />} onClick={() => void install(item)}>
|
||||
{tr('pluginMarketInstall')}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
// The loader covers the feed when there is nothing to show yet, or when the
|
||||
// user asked for a refresh and should see it happen.
|
||||
const showLoader = refreshing || (syncing && items.length === 0) || (!result && !synced.current)
|
||||
const emptyAfterSync = !showLoader && items.length === 0
|
||||
|
||||
return (
|
||||
<section className="section plugin-market">
|
||||
<div className="market-toolbar">
|
||||
<PluginSearchInput
|
||||
value={query}
|
||||
onChange={setQuery}
|
||||
placeholder={tr('pluginMarketSearchPlaceholder')}
|
||||
wide
|
||||
/>
|
||||
{facets.length > 1 && (
|
||||
<div className="market-kinds" role="radiogroup" aria-label={tr('pluginMarketKindAll')}>
|
||||
{[{ kind: '', count: 0 }, ...facets].map((f) => (
|
||||
<button
|
||||
key={f.kind || 'all'}
|
||||
type="button"
|
||||
role="radio"
|
||||
aria-checked={kind === f.kind}
|
||||
className={`plugin-pill${kind === f.kind ? ' is-active' : ''}`}
|
||||
onClick={() => setKind(f.kind)}
|
||||
>
|
||||
{f.kind ? kindLabel(f.kind) : tr('pluginMarketKindAll')}
|
||||
{f.kind && f.count > 0 && <span className="plugin-pill-count">{f.count}</span>}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{!showLoader && result?.stale && result.fetch_error && (
|
||||
<div className="notice notice-warn">
|
||||
<span className="notice-main">
|
||||
<AlertTriangle size={15} className="notice-icon" aria-hidden="true" />
|
||||
<span>{tr('pluginMarketStaleBanner')}</span>
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{(result?.withdrawn_installed ?? []).map((w) => (
|
||||
<div className="notice notice-warn" key={w.id}>
|
||||
<span className="notice-main">
|
||||
<ShieldAlert size={15} className="notice-icon" aria-hidden="true" />
|
||||
<span>
|
||||
{tr('pluginMarketWithdrawnInstalledWarn', { id: w.id, reason: locText(w.reason, locale, '') })}
|
||||
{w.instead_id ? ` · ${tr('pluginMarketWithdrawnInstead', { target: w.instead_name || w.instead_id })}` : ''}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
|
||||
{showLoader ? (
|
||||
<WordmarkLoader className="market-loader" label={tr(refreshing || result ? 'pluginMarketSyncing' : 'pluginMarketLoading')} />
|
||||
) : emptyAfterSync ? (
|
||||
<div className="plugins-empty">{query || kind ? tr('pluginSearchEmpty') : tr('pluginMarketEmpty')}</div>
|
||||
) : (
|
||||
<>
|
||||
<div className="market-grid">
|
||||
{shown.map((item, i) => {
|
||||
const e = item.entry
|
||||
const desc = locText(e.description, locale, '')
|
||||
const muted = !!item.withdrawn || !item.compatible
|
||||
return (
|
||||
<article
|
||||
className={`market-card rg-p-card${muted ? ' is-muted' : ''}`}
|
||||
key={e.id}
|
||||
style={{ '--i': i % PAGE_SIZE } as React.CSSProperties}
|
||||
>
|
||||
<div className="market-card-head">
|
||||
<PluginAppIcon plugin={e} size="lg" />
|
||||
<div className="market-card-titles">
|
||||
<h3 className="market-card-name" title={locText(e.name, locale, e.id)}>{locText(e.name, locale, e.id)}</h3>
|
||||
<div className="market-card-byline">
|
||||
<PluginTrustBadge locale={locale} trust={e.trust} publisher={e.publisher} />
|
||||
<span className="market-card-dot" aria-hidden="true">·</span>
|
||||
<span className="market-card-version">v{e.version}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="market-card-action">{action(item)}</div>
|
||||
</div>
|
||||
<p className="market-card-desc" title={desc}>{desc}</p>
|
||||
</article>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
{hasMore
|
||||
? <div ref={sentinel} className="market-sentinel" aria-hidden="true" />
|
||||
: items.length > PAGE_SIZE && <div className="market-feed-end">{tr('pluginMarketFeedEnd', { count: items.length })}</div>}
|
||||
</>
|
||||
)}
|
||||
|
||||
{prompt && (
|
||||
<Modal
|
||||
title={tr('pluginEnablePromptTitle', { name: locText(prompt.name, locale, prompt.id) })}
|
||||
subtitle={`${prompt.publisher || tr('pluginTrustCommunity')} · v${prompt.version}`}
|
||||
closeLabel={tr('close')}
|
||||
onClose={() => { if (!enabling) setPrompt(null) }}
|
||||
>
|
||||
<div className="dialog-body">
|
||||
{(prompt.risks?.length ?? 0) > 0 ? (
|
||||
<>
|
||||
<p className="plugin-enable-lead">{tr('pluginEnablePromptBody')}</p>
|
||||
<RiskList locale={locale} risks={prompt.risks} />
|
||||
</>
|
||||
) : (
|
||||
<p className="plugin-enable-lead">{tr('pluginEnablePromptNoRisk')}</p>
|
||||
)}
|
||||
{prompt.needs_approval && (
|
||||
<label className="choice">
|
||||
<input type="checkbox" checked={promptChecked} onChange={(e) => setPromptChecked(e.target.checked)} />
|
||||
<span>{tr('pluginApproveCheckbox')}</span>
|
||||
</label>
|
||||
)}
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
<span />
|
||||
<span className="hstack">
|
||||
<Button variant="ghost" disabled={enabling} onClick={() => setPrompt(null)}>{tr('pluginEnableLater')}</Button>
|
||||
<Button
|
||||
variant="primary"
|
||||
disabled={enabling || !!safeMode || (prompt.needs_approval && !promptChecked)}
|
||||
onClick={() => void enablePrompted()}
|
||||
>
|
||||
{tr('pluginEnableNow')}
|
||||
</Button>
|
||||
</span>
|
||||
</div>
|
||||
</Modal>
|
||||
)}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { AlertTriangle } from 'lucide-react'
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
import { t } from '../i18n'
|
||||
import { getPluginMessageBundle, localeDir, parseAppError, t } from '../i18n'
|
||||
import { Locale, PanelContribution } from '../types'
|
||||
import { Button } from '../ui/controls'
|
||||
import { api } from '../wails'
|
||||
@@ -7,9 +8,15 @@ import { locText } from './SchemaForm'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
panel: PanelContribution
|
||||
panel: Omit<PanelContribution, 'convertValues'>
|
||||
assetToken: string
|
||||
appearance: 'light' | 'dark'
|
||||
/** Omit the panel title bar (e.g. when hosted inside a tab/segmented view). */
|
||||
headless?: boolean
|
||||
/** Upper bound for the iframe height in px (defaults to 480 for inline panels). */
|
||||
maxHeight?: number
|
||||
/** Incrementing this reloads the iframe cleanly. */
|
||||
refreshSignal?: number
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,11 +44,22 @@ function buildSafePanelSrc(assetToken: string, pluginId: string | undefined, ent
|
||||
return `/plugin-assets/${encodeURIComponent(assetToken)}/${encodeURIComponent(pluginId)}/${segs.map(encodeURIComponent).join('/')}`
|
||||
}
|
||||
|
||||
export const PluginPanelFrame: React.FC<Props> = ({ locale, panel, assetToken, appearance }) => {
|
||||
export const PluginPanelFrame: React.FC<Props> = ({
|
||||
locale, panel, assetToken, appearance, headless, maxHeight = 480, refreshSignal = 0,
|
||||
}) => {
|
||||
const iframeRef = useRef<HTMLIFrameElement>(null)
|
||||
const localeRef = useRef<Locale>(locale)
|
||||
localeRef.current = locale
|
||||
const [failed, setFailed] = useState(false)
|
||||
const [nonce, setNonce] = useState(0)
|
||||
|
||||
useEffect(() => {
|
||||
if (refreshSignal > 0) {
|
||||
setFailed(false)
|
||||
setNonce((n) => n + 1)
|
||||
}
|
||||
}, [refreshSignal])
|
||||
|
||||
const src = buildSafePanelSrc(assetToken, panel.pluginId, panel.entry)
|
||||
|
||||
const syncTheme = () => {
|
||||
@@ -52,7 +70,14 @@ export const PluginPanelFrame: React.FC<Props> = ({ locale, panel, assetToken, a
|
||||
for (const k of ['--surface-0', '--surface-1', '--text', '--text-2', '--border', '--accent', '--font-sans']) {
|
||||
tokens[k] = cs.getPropertyValue(k).trim()
|
||||
}
|
||||
win.postMessage({ type: 'reims:theme', appearance, locale, tokens }, '*')
|
||||
const dir = localeDir(locale)
|
||||
const messages = getPluginMessageBundle(panel.pluginId ?? '', locale)
|
||||
// bridgeApi 1.0 events (bridgeContract.ts).
|
||||
win.postMessage({ type: 'reims:event', event: 'theme.changed', data: { appearance, tokens } }, '*')
|
||||
win.postMessage({ type: 'reims:event', event: 'locale.changed', data: { locale, dir, messages } }, '*')
|
||||
// Pre-1.0 message types, kept for panels written before the bridge contract.
|
||||
win.postMessage({ type: 'reims:theme', appearance, locale, dir, tokens, messages }, '*')
|
||||
win.postMessage({ type: 'reims:i18n', locale, dir, messages }, '*')
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
@@ -76,12 +101,22 @@ export const PluginPanelFrame: React.FC<Props> = ({ locale, panel, assetToken, a
|
||||
? (rawParams as Record<string, unknown>)
|
||||
: {}
|
||||
try {
|
||||
if (msg.method === 'i18n.getBundle') {
|
||||
const curLocale = localeRef.current
|
||||
const bundle = {
|
||||
locale: curLocale,
|
||||
dir: localeDir(curLocale),
|
||||
messages: getPluginMessageBundle(panel.pluginId ?? '', curLocale),
|
||||
}
|
||||
win.postMessage({ type: 'reims:rpc-result', id: msg.id, ok: true, result: bundle }, '*')
|
||||
return
|
||||
}
|
||||
const result = await api.PanelBridgeCall(panel.pluginId ?? '', msg.method, params)
|
||||
if (cancelled || iframeRef.current?.contentWindow !== win) return
|
||||
win.postMessage({ type: 'reims:rpc-result', id: msg.id, ok: true, result }, '*')
|
||||
} catch (err) {
|
||||
if (cancelled || iframeRef.current?.contentWindow !== win) return
|
||||
win.postMessage({ type: 'reims:rpc-result', id: msg.id, ok: false, error: String(err) }, '*')
|
||||
win.postMessage({ type: 'reims:rpc-result', id: msg.id, ok: false, error: parseAppError(err).summary || 'RPC failed' }, '*')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,8 +129,11 @@ export const PluginPanelFrame: React.FC<Props> = ({ locale, panel, assetToken, a
|
||||
|
||||
if (failed || !src) {
|
||||
return (
|
||||
<div className="plugin-panel-error">
|
||||
<span>{t(locale, 'panelLoadFailed')}</span>
|
||||
<div className="notice notice-error" role="alert">
|
||||
<span className="notice-main">
|
||||
<AlertTriangle size={15} className="notice-icon" aria-hidden="true" />
|
||||
<span>{t(locale, 'panelLoadFailed')}</span>
|
||||
</span>
|
||||
{src && (
|
||||
<Button onClick={() => { setFailed(false); setNonce((n) => n + 1) }}>
|
||||
{t(locale, 'installersRetry')}
|
||||
@@ -106,8 +144,8 @@ export const PluginPanelFrame: React.FC<Props> = ({ locale, panel, assetToken, a
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="plugin-panel-wrap">
|
||||
<div className="plugin-panel-head">{locText(panel.title, locale, panel.id)}</div>
|
||||
<div className={`plugin-panel-wrap rg-p-plugin-view${headless ? ' is-headless' : ''}`} data-plugin={panel.pluginId}>
|
||||
{!headless && <div className="plugin-panel-head">{locText(panel.title, locale, panel.id)}</div>}
|
||||
<iframe
|
||||
key={nonce}
|
||||
ref={iframeRef}
|
||||
@@ -116,7 +154,7 @@ export const PluginPanelFrame: React.FC<Props> = ({ locale, panel, assetToken, a
|
||||
src={src}
|
||||
sandbox="allow-scripts"
|
||||
referrerPolicy="no-referrer"
|
||||
style={{ height: Math.max(120, Math.min(480, panel.height || 220)) }}
|
||||
style={{ height: Math.max(120, Math.min(maxHeight, panel.height || 220)) }}
|
||||
onLoad={syncTheme}
|
||||
onError={() => setFailed(true)}
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
import {
|
||||
Activity, BadgeCheck, Binary, Clipboard, Code2, Files, Globe,
|
||||
Keyboard, Monitor, PanelsTopLeft, Search, ShieldCheck, Users,
|
||||
} from 'lucide-react'
|
||||
import React from 'react'
|
||||
import '../i18n/domains/plugins.gen'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { Locale } from '../types'
|
||||
import { Tip } from '../ui/controls'
|
||||
|
||||
export { PluginAppIcon, resolvePluginVisual, type PluginVisual, type PluginVisualSource } from './PluginAppIcon'
|
||||
|
||||
/** Publisher + trust-tier mark shared by Installed rows and Market cards. */
|
||||
export const PluginTrustBadge: React.FC<{
|
||||
locale: Locale
|
||||
trust: string
|
||||
publisher?: string
|
||||
}> = ({ locale, trust, publisher }) => {
|
||||
const tr = (k: I18nKey) => t(locale, k)
|
||||
const meta = trust === 'official'
|
||||
? { cls: 'is-official', icon: <BadgeCheck size={13} aria-hidden="true" />, label: tr('pluginTrustOfficial') }
|
||||
: trust === 'verified'
|
||||
? { cls: 'is-verified', icon: <ShieldCheck size={13} aria-hidden="true" />, label: tr('pluginTrustVerified') }
|
||||
: trust === 'dev'
|
||||
? { cls: 'is-dev', icon: <Code2 size={13} aria-hidden="true" />, label: tr('pluginTrustDev') }
|
||||
: { cls: 'is-community', icon: <Users size={13} aria-hidden="true" />, label: tr('pluginTrustCommunity') }
|
||||
return (
|
||||
<Tip label={meta.label}>
|
||||
<span className={`plugin-trust ${meta.cls}`} tabIndex={0}>
|
||||
{meta.icon}
|
||||
<span className="plugin-trust-name">{publisher || meta.label}</span>
|
||||
</span>
|
||||
</Tip>
|
||||
)
|
||||
}
|
||||
|
||||
/** Search input with leading magnifying glass, shared by Installed and Market. */
|
||||
export const PluginSearchInput: React.FC<{
|
||||
value: string
|
||||
onChange: (value: string) => void
|
||||
placeholder: string
|
||||
wide?: boolean
|
||||
}> = ({ value, onChange, placeholder, wide }) => (
|
||||
<div className={`plugin-search-wrap${wide ? ' is-wide' : ''}`}>
|
||||
<Search size={13} className="plugin-search-icon" aria-hidden="true" />
|
||||
<input
|
||||
type="search"
|
||||
className="input rg-p-input plugin-search"
|
||||
aria-label={placeholder}
|
||||
placeholder={placeholder}
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
const RISKS: Record<string, { key: I18nKey; icon: React.ReactNode; high: boolean }> = {
|
||||
native: { key: 'pluginRiskNative', icon: <Binary size={15} aria-hidden="true" />, high: true },
|
||||
background: { key: 'pluginRiskBackground', icon: <Activity size={15} aria-hidden="true" />, high: true },
|
||||
network: { key: 'pluginRiskNetwork', icon: <Globe size={15} aria-hidden="true" />, high: true },
|
||||
files: { key: 'pluginRiskFiles', icon: <Files size={15} aria-hidden="true" />, high: true },
|
||||
vm: { key: 'pluginRiskVm', icon: <Monitor size={15} aria-hidden="true" />, high: true },
|
||||
clipboard: { key: 'pluginRiskClipboard', icon: <Clipboard size={15} aria-hidden="true" />, high: true },
|
||||
input: { key: 'pluginRiskInput', icon: <Keyboard size={15} aria-hidden="true" />, high: false },
|
||||
ui: { key: 'pluginRiskUi', icon: <PanelsTopLeft size={15} aria-hidden="true" />, high: false },
|
||||
}
|
||||
|
||||
/** Plain-language list of what a plugin can do (backend risk categories). */
|
||||
export const RiskList: React.FC<{ locale: Locale; risks?: string[] }> = ({ locale, risks }) => {
|
||||
const known = (risks ?? []).filter((r) => RISKS[r])
|
||||
if (known.length === 0) return null
|
||||
return (
|
||||
<ul className="plugin-risk-list">
|
||||
{known.map((r) => (
|
||||
<li key={r} className={`plugin-risk${RISKS[r].high ? ' is-high' : ''}`}>
|
||||
<span className="plugin-risk-icon">{RISKS[r].icon}</span>
|
||||
<span>{t(locale, RISKS[r].key)}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
@@ -1,22 +1,27 @@
|
||||
import {
|
||||
AlertTriangle, BadgeCheck, Boxes, Clipboard, Code2, Compass, Cpu, Disc3, FolderOpen, Keyboard,
|
||||
Layers, Monitor, PackagePlus, Palette, Puzzle, RefreshCw, RotateCcw, Search,
|
||||
Settings2, Shield, ShieldAlert, ShieldCheck, Sparkles, Terminal, Trash2,
|
||||
AlertTriangle, CheckCircle2, FolderOpen, PackagePlus, Palette,
|
||||
RefreshCw, Settings2, Shield, ShieldAlert, Sparkles, Terminal, Trash2,
|
||||
} from 'lucide-react'
|
||||
import React, { useEffect, useMemo, useState } from 'react'
|
||||
import '../i18n/domains/plugins.gen'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import {
|
||||
ActiveThemePayload, CustomThemeScheme, Locale, PluginInfo, PluginUIContributions,
|
||||
ActiveThemePayload, CustomThemeScheme, Locale, PluginInfo, PluginUIContributions, ScanReport,
|
||||
} from '../types'
|
||||
import { Button, IconButton, Tip } from '../ui/controls'
|
||||
import { Modal } from '../ui/dialog'
|
||||
import { PopupSelect, Switch } from '../ui/settings'
|
||||
import { ConfirmDialog, Modal } from '../ui/dialog'
|
||||
import { PopupSelect, Segmented, Switch } from '../ui/settings'
|
||||
import { api } from '../wails'
|
||||
import { PluginMarket } from './PluginMarket'
|
||||
import { PluginPanelFrame } from './PluginPanelFrame'
|
||||
import { PluginAppIcon, PluginSearchInput, PluginTrustBadge, RiskList } from './PluginParts'
|
||||
import { SchemaForm, locText } from './SchemaForm'
|
||||
|
||||
// Search only earns its space once the list is long enough to scan.
|
||||
const SEARCH_THRESHOLD = 12
|
||||
// A manual refresh spins at least this long so the click visibly lands.
|
||||
const MIN_SPIN_MS = 500
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
@@ -25,45 +30,8 @@ interface Props {
|
||||
onRefresh: () => void
|
||||
onError: (title: string, e: unknown) => void
|
||||
onThemeChanged?: () => void
|
||||
}
|
||||
|
||||
interface PluginVisual {
|
||||
tone: string
|
||||
icon: React.ReactNode
|
||||
}
|
||||
|
||||
function resolvePluginVisual(p: PluginInfo): PluginVisual {
|
||||
if (p.system) return { tone: 'indigo', icon: <Boxes size={19} aria-hidden="true" /> }
|
||||
const id = p.id.toLowerCase()
|
||||
const perms = new Set((p.permissions ?? []).map((x) => x.name))
|
||||
if (id.includes('theme') || perms.has('ui:script')) {
|
||||
return { tone: 'purple', icon: <Palette size={19} aria-hidden="true" /> }
|
||||
}
|
||||
if (id.includes('driver') || perms.has('driver:vm') || perms.has('runtime:provider')) {
|
||||
return { tone: 'indigo', icon: <Monitor size={19} aria-hidden="true" /> }
|
||||
}
|
||||
if (id.includes('clipboard') || perms.has('host:clipboard')) {
|
||||
return { tone: 'sky', icon: <Clipboard size={19} aria-hidden="true" /> }
|
||||
}
|
||||
if (id.includes('ime') || id.includes('input') || id.includes('wheel') || perms.has('input:filter')) {
|
||||
return { tone: 'rose', icon: <Keyboard size={19} aria-hidden="true" /> }
|
||||
}
|
||||
if (id.includes('reboot')) {
|
||||
return { tone: 'amber', icon: <RotateCcw size={19} aria-hidden="true" /> }
|
||||
}
|
||||
if (id.includes('whpx') || id.includes('irq')) {
|
||||
return { tone: 'emerald', icon: <Cpu size={19} aria-hidden="true" /> }
|
||||
}
|
||||
if (id.includes('guide')) {
|
||||
return { tone: 'teal', icon: <Compass size={19} aria-hidden="true" /> }
|
||||
}
|
||||
if (id.includes('offline') || id.includes('installer') || id.includes('helper')) {
|
||||
return { tone: 'teal', icon: <Disc3 size={19} aria-hidden="true" /> }
|
||||
}
|
||||
if (p.tier === 'L3') {
|
||||
return { tone: 'slate', icon: <Layers size={19} aria-hidden="true" /> }
|
||||
}
|
||||
return { tone: 'purple', icon: <Puzzle size={19} aria-hidden="true" /> }
|
||||
/** Switches the app language (used after enabling a language pack). */
|
||||
onLocaleSwitch?: (l: Locale) => void
|
||||
}
|
||||
|
||||
// The plugin settings dialog shows app-scope fields only; per-VM fields live in
|
||||
@@ -79,9 +47,10 @@ function hasAppSettings(p: PluginInfo): boolean {
|
||||
* Grouped inset list, same pattern as the installers page.
|
||||
*/
|
||||
export const PluginsPage: React.FC<Props> = ({
|
||||
locale, appearance, safeMode, onRefresh, onError, onThemeChanged,
|
||||
locale, appearance, safeMode, onRefresh, onError, onThemeChanged, onLocaleSwitch,
|
||||
}) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const [activeTab, setActiveTab] = useState<'installed' | 'market'>('installed')
|
||||
const [query, setQuery] = useState('')
|
||||
const [plugins, setPlugins] = useState<PluginInfo[]>([])
|
||||
const [contribs, setContribs] = useState<PluginUIContributions | null>(null)
|
||||
@@ -89,13 +58,29 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [busyID, setBusyID] = useState('')
|
||||
const [approveTarget, setApproveTarget] = useState<PluginInfo | null>(null)
|
||||
const [approveReport, setApproveReport] = useState<ScanReport | null>(null)
|
||||
const [approveChecked, setApproveChecked] = useState(false)
|
||||
const [settingsTarget, setSettingsTarget] = useState<PluginInfo | null>(null)
|
||||
const [settingsValues, setSettingsValues] = useState<Record<string, unknown>>({})
|
||||
const [logTarget, setLogTarget] = useState<{ id: string; text: string } | null>(null)
|
||||
const [removeTarget, setRemoveTarget] = useState<PluginInfo | null>(null)
|
||||
const [disableTarget, setDisableTarget] = useState<PluginInfo | null>(null)
|
||||
const [deleteSchemeTarget, setDeleteSchemeTarget] = useState<CustomThemeScheme | null>(null)
|
||||
|
||||
// Static risk scan modal state (pre-install .zip preview or installed plugin scan)
|
||||
const [scanModal, setScanModal] = useState<{
|
||||
mode: 'archive' | 'installed'
|
||||
archivePath?: string
|
||||
report: ScanReport
|
||||
} | null>(null)
|
||||
const [scanBusy, setScanBusy] = useState(false)
|
||||
|
||||
// The market mounts (and touches the network) only once its tab is opened (§8.1).
|
||||
const [marketOpened, setMarketOpened] = useState(false)
|
||||
const [marketRefresh, setMarketRefresh] = useState(0)
|
||||
const [marketBusy, setMarketBusy] = useState(false)
|
||||
const [reloading, setReloading] = useState(false)
|
||||
|
||||
// Theme scheme editor state (§5.1)
|
||||
const [schemeEditorOpen, setSchemeEditorOpen] = useState(false)
|
||||
const [schemeName, setSchemeName] = useState('')
|
||||
@@ -119,12 +104,46 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
}
|
||||
}
|
||||
|
||||
const manualReload = async () => {
|
||||
setReloading(true)
|
||||
const started = Date.now()
|
||||
await reload()
|
||||
const wait = MIN_SPIN_MS - (Date.now() - started)
|
||||
if (wait > 0) await new Promise((r) => window.setTimeout(r, wait))
|
||||
setReloading(false)
|
||||
}
|
||||
|
||||
// Enabling a language pack means the user wants that language: switch to
|
||||
// its first locale unless the current one is already among them.
|
||||
const adoptPluginLocale = (p: PluginInfo) => {
|
||||
const tags = p.locales ?? []
|
||||
if (tags.length > 0 && !tags.includes(locale)) onLocaleSwitch?.(tags[0])
|
||||
}
|
||||
|
||||
const onMarketChanged = async ({ enabled }: { enabled?: PluginInfo }) => {
|
||||
await reload()
|
||||
onRefresh()
|
||||
if (enabled) {
|
||||
onThemeChanged?.()
|
||||
adoptPluginLocale(enabled)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => { void reload() }, [safeMode])
|
||||
|
||||
const togglePlugin = async (p: PluginInfo, enable: boolean) => {
|
||||
useEffect(() => { if (activeTab === 'market') setMarketOpened(true) }, [activeTab])
|
||||
|
||||
const togglePlugin = async (p: PluginInfo, enable: boolean, confirmed = false) => {
|
||||
// Disabling a plugin that still owns VMs leaves them "driver unavailable": say so first.
|
||||
if (!enable && p.in_use && !confirmed) {
|
||||
setDisableTarget(p)
|
||||
return
|
||||
}
|
||||
if (enable && p.needs_approval) {
|
||||
setApproveChecked(false)
|
||||
setApproveReport(null)
|
||||
setApproveTarget(p)
|
||||
void api.ScanInstalledPlugin(p.id).then(setApproveReport).catch((e) => console.warn('[plugins] ScanInstalledPlugin failed:', p.id, e))
|
||||
return
|
||||
}
|
||||
setBusyID(p.id)
|
||||
@@ -134,6 +153,7 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
await reload()
|
||||
onRefresh()
|
||||
onThemeChanged?.()
|
||||
if (enable) adoptPluginLocale(p)
|
||||
} catch (e) {
|
||||
onError(tr('pluginFailToggle'), e)
|
||||
} finally {
|
||||
@@ -145,12 +165,14 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
if (!approveTarget || !approveChecked) return
|
||||
const target = approveTarget
|
||||
setApproveTarget(null)
|
||||
setApproveReport(null)
|
||||
setBusyID(target.id)
|
||||
try {
|
||||
await api.EnablePlugin(target.id, true)
|
||||
await reload()
|
||||
onRefresh()
|
||||
onThemeChanged?.()
|
||||
adoptPluginLocale(target)
|
||||
} catch (e) {
|
||||
onError(tr('pluginFailEnable'), e)
|
||||
} finally {
|
||||
@@ -162,11 +184,41 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
try {
|
||||
const path = await api.PickFile(tr('pluginImportTitle'), '*.zip')
|
||||
if (!path) return
|
||||
await api.InstallPluginArchive(path)
|
||||
setScanBusy(true)
|
||||
const report = await api.InspectPluginArchive(path)
|
||||
setScanModal({ mode: 'archive', archivePath: path, report })
|
||||
} catch (e) {
|
||||
onError(tr('pluginFailScan'), e)
|
||||
} finally {
|
||||
setScanBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
const confirmInstallScannedArchive = async () => {
|
||||
if (!scanModal || scanModal.mode !== 'archive' || !scanModal.archivePath || scanModal.report.hard_blocked) return
|
||||
const archivePath = scanModal.archivePath
|
||||
setScanBusy(true)
|
||||
try {
|
||||
await api.InstallPluginArchive(archivePath)
|
||||
setScanModal(null)
|
||||
await reload()
|
||||
onRefresh()
|
||||
} catch (e) {
|
||||
onError(tr('pluginFailImport'), e)
|
||||
} finally {
|
||||
setScanBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
const inspectInstalledPlugin = async (p: PluginInfo) => {
|
||||
setScanBusy(true)
|
||||
try {
|
||||
const report = await api.ScanInstalledPlugin(p.id)
|
||||
setScanModal({ mode: 'installed', report })
|
||||
} catch (e) {
|
||||
onError(tr('pluginFailScan'), e)
|
||||
} finally {
|
||||
setScanBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,11 +332,8 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
return name.includes(q) || desc.includes(q) || p.id.toLowerCase().includes(q)
|
||||
}
|
||||
|
||||
// The always-on core goes first; the optional builtins keep backend order.
|
||||
const builtins = useMemo(
|
||||
() => plugins.filter((p) => p.source === 'builtin').sort((a, b) => Number(!!b.system) - Number(!!a.system)),
|
||||
[plugins],
|
||||
)
|
||||
// System plugins are part of the host and never listed; builtins keep backend order.
|
||||
const builtins = useMemo(() => plugins.filter((p) => p.source === 'builtin'), [plugins])
|
||||
const external = useMemo(() => plugins.filter((p) => p.source !== 'builtin'), [plugins])
|
||||
const filteredBuiltins = useMemo(() => builtins.filter(matchesFilter), [builtins, q, locale])
|
||||
const filteredExternal = useMemo(() => external.filter(matchesFilter), [external, q, locale])
|
||||
@@ -306,25 +355,16 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
return base
|
||||
}, [activeTheme, customSchemes, presetSchemes])
|
||||
|
||||
const trustMeta = (trLevel: string) => {
|
||||
if (trLevel === 'official') return { label: tr('pluginTrustOfficial'), cls: 'is-official', icon: <BadgeCheck size={12} aria-hidden="true" /> }
|
||||
if (trLevel === 'verified') return { label: tr('pluginTrustVerified'), cls: 'is-verified', icon: <ShieldCheck size={12} aria-hidden="true" /> }
|
||||
if (trLevel === 'dev') return { label: tr('pluginTrustDev'), cls: 'is-dev', icon: <Code2 size={12} aria-hidden="true" /> }
|
||||
return { label: tr('pluginTrustCommunity'), cls: 'is-community', icon: <Shield size={12} aria-hidden="true" /> }
|
||||
}
|
||||
|
||||
// The switch already says on/off, so only surface states that need attention.
|
||||
const stateBadge = (p: PluginInfo) => {
|
||||
if (p.state === 'degraded') return <span className="badge badge-warn">{tr('pluginStateDegraded')}</span>
|
||||
if (p.state === 'failed') return <span className="badge badge-warn">{tr('pluginStateFailed')}</span>
|
||||
if (p.state === 'pending' && p.enabled) return <span className="badge">{tr('pluginStatePending')}</span>
|
||||
if (p.state === 'degraded') return <span className="badge rg-p-badge badge-warn">{tr('pluginStateDegraded')}</span>
|
||||
if (p.state === 'failed') return <span className="badge rg-p-badge badge-warn">{tr('pluginStateFailed')}</span>
|
||||
if (p.state === 'pending' && p.enabled) return <span className="badge rg-p-badge">{tr('pluginStatePending')}</span>
|
||||
return null
|
||||
}
|
||||
|
||||
const renderRow = (p: PluginInfo) => {
|
||||
const visual = resolvePluginVisual(p)
|
||||
const isBuiltin = p.source === 'builtin'
|
||||
const trust = trustMeta(p.trust)
|
||||
const perms = p.permissions ?? []
|
||||
const highPerms = perms.filter((x) => x.level === 'high')
|
||||
const desc = locText(p.description, locale, '')
|
||||
@@ -333,7 +373,7 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
|
||||
return (
|
||||
<div className={`row plugin-row${p.enabled ? ' is-enabled' : ''}`} key={p.id}>
|
||||
<div className={`plugin-app-icon tone-${visual.tone}`}>{visual.icon}</div>
|
||||
<PluginAppIcon plugin={p} size="md" />
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
<span className="plugin-row-name">{locText(p.name, locale, p.id)}</span>
|
||||
@@ -342,7 +382,7 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
{desc && <div className="row-sub plugin-row-desc" title={desc}>{desc}</div>}
|
||||
{!isBuiltin && (
|
||||
<div className="row-sub plugin-row-meta">
|
||||
<span className={`plugin-trust ${trust.cls}`}>{trust.icon}{p.publisher || trust.label}</span>
|
||||
<PluginTrustBadge locale={locale} trust={p.trust} publisher={p.publisher} />
|
||||
<span className="mono">v{p.version}</span>
|
||||
{perms.length > 0 && (
|
||||
<Tip label={tr('pluginPermissionsLabel', { list: perms.map((x) => x.name).join(', ') })}>
|
||||
@@ -359,6 +399,9 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
)}
|
||||
</div>
|
||||
<div className="row-right">
|
||||
{!isBuiltin && (
|
||||
<IconButton label={tr('pluginScanInspect')} icon={<Shield size={15} />} onClick={() => void inspectInstalledPlugin(p)} />
|
||||
)}
|
||||
{hasAppSettings(p) && (
|
||||
<IconButton label={tr('pluginSettings')} icon={<Settings2 size={15} />} onClick={() => void openPluginSettings(p)} />
|
||||
)}
|
||||
@@ -384,7 +427,7 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
) : (
|
||||
<Switch
|
||||
label={locText(p.name, locale, p.id)}
|
||||
disabled={busyID === p.id || (p.enabled && p.in_use) || (!!safeMode && !isBuiltin)}
|
||||
disabled={busyID === p.id || (!!safeMode && !isBuiltin)}
|
||||
checked={p.enabled}
|
||||
onChange={(checked) => void togglePlugin(p, checked)}
|
||||
/>
|
||||
@@ -394,6 +437,113 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
)
|
||||
}
|
||||
|
||||
const renderScanReportBody = (report: ScanReport) => {
|
||||
const hard = report.hard_findings ?? []
|
||||
const caps = report.capabilities ?? []
|
||||
const pending = report.pending_findings ?? []
|
||||
const execs = report.executables ?? []
|
||||
return (
|
||||
<div className="stack-3">
|
||||
<div className={`notice ${report.hard_blocked ? 'notice-error' : report.needs_approval ? 'notice-warn' : 'notice-ok'}`}>
|
||||
<span className="notice-main">
|
||||
{report.hard_blocked
|
||||
? <ShieldAlert size={15} className="notice-icon" aria-hidden="true" />
|
||||
: report.needs_approval
|
||||
? <AlertTriangle size={15} className="notice-icon" aria-hidden="true" />
|
||||
: <CheckCircle2 size={15} className="notice-icon" aria-hidden="true" />}
|
||||
<span>{locText(report.headline, locale, report.hard_blocked ? 'Blocked' : 'Passed')}</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{report.native_exec_notice && locText(report.native_exec_notice, locale, '') && (
|
||||
<div className="notice notice-warn">
|
||||
<span className="notice-main">
|
||||
<ShieldAlert size={15} className="notice-icon" aria-hidden="true" />
|
||||
<span>{locText(report.native_exec_notice, locale, '')}</span>
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{hard.length > 0 && (
|
||||
<div className="plugin-scan-section">
|
||||
<div className="plugin-scan-section-title is-danger">{tr('pluginScanHardSection')}</div>
|
||||
<div className="list">
|
||||
{hard.map((f, idx) => (
|
||||
<div className="row" key={`${f.check}-${idx}`}>
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
<span className="badge rg-p-badge badge-danger">{f.check}</span>
|
||||
{f.target && <span className="mono">{f.target}</span>}
|
||||
</div>
|
||||
<div className="row-sub">{locText(f.localized, locale, f.message)}</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{caps.length > 0 && (
|
||||
<div className="plugin-scan-section">
|
||||
<div className="plugin-scan-section-title">{tr('pluginScanCapabilitiesSection')}</div>
|
||||
<div className="list">
|
||||
{caps.map((c) => (
|
||||
<div className="row" key={c.id}>
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
<span className={`badge rg-p-badge${c.level === 'high' ? ' badge-warn' : ''}`}>{c.level.toUpperCase()}</span>
|
||||
<span>{locText(c.title, locale, c.id)}</span>
|
||||
<span className="mono muted" style={{ fontSize: 'var(--fs-11)' }}>{c.id}</span>
|
||||
</div>
|
||||
<div className="row-sub">{locText(c.summary, locale, '')}</div>
|
||||
{(c.examples?.length ?? 0) > 0 && (
|
||||
<div className="plugin-scan-examples mono">
|
||||
{c.examples!.map((ex, i) => <div key={i}>· {ex}</div>)}
|
||||
{(c.extra_count ?? 0) > 0 && (
|
||||
<div className="muted">· {tr('pluginScanMoreItems', { count: c.extra_count! })}</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{(pending.length > 0 || execs.length > 0) && (
|
||||
<div className="plugin-scan-section">
|
||||
<div className="plugin-scan-section-title">{tr('pluginScanAdvisoriesSection')}</div>
|
||||
<div className="list">
|
||||
{pending.map((f, idx) => (
|
||||
<div className="row" key={`pend-${f.check}-${idx}`}>
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
<span className="badge rg-p-badge">{f.check}</span>
|
||||
{f.target && <span className="mono">{f.target}</span>}
|
||||
</div>
|
||||
<div className="row-sub">{locText(f.localized, locale, f.message)}</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
{execs.map((ex) => (
|
||||
<div className="row" key={ex.path}>
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
<span className={`badge rg-p-badge${ex.declared ? '' : ' badge-danger'}`}>{ex.declared ? 'EXE' : 'UNLISTED'}</span>
|
||||
<span className="mono">{ex.path}</span>
|
||||
</div>
|
||||
<div className="row-sub mono selectable">SHA-256: {ex.sha256}</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const showThemeHero = themes.length > 1 && !q
|
||||
const showSearch = plugins.length > SEARCH_THRESHOLD
|
||||
const noMatches = !loading && !!q && filteredBuiltins.length === 0 && filteredExternal.length === 0
|
||||
@@ -409,28 +559,55 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
{!loading && <span>{tr('pluginActiveCount', { active: activeCount, total: plugins.length })}</span>}
|
||||
</div>
|
||||
<div className="actions">
|
||||
{showSearch && (
|
||||
<div className="plugins-search-wrap">
|
||||
<Search size={13} className="plugins-search-icon" aria-hidden="true" />
|
||||
<input
|
||||
type="search"
|
||||
className="input plugins-search"
|
||||
aria-label={tr('pluginSearchPlaceholder')}
|
||||
placeholder={tr('pluginSearchPlaceholder')}
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
{activeTab === 'installed' && showSearch && (
|
||||
<PluginSearchInput
|
||||
value={query}
|
||||
onChange={setQuery}
|
||||
placeholder={tr('pluginSearchPlaceholder')}
|
||||
/>
|
||||
)}
|
||||
<IconButton label={tr('refresh')} icon={<RefreshCw size={16} />} onClick={() => void reload()} />
|
||||
<IconButton
|
||||
label={activeTab === 'market' ? tr('pluginMarketRefresh') : tr('refresh')}
|
||||
icon={<RefreshCw size={16} className={(activeTab === 'market' ? marketBusy : reloading) ? 'spin' : undefined} />}
|
||||
disabled={activeTab === 'market' ? marketBusy : reloading}
|
||||
onClick={() => activeTab === 'market' ? setMarketRefresh((n) => n + 1) : void manualReload()}
|
||||
/>
|
||||
<IconButton label={tr('pluginLinkDevBtn')} icon={<FolderOpen size={16} />} onClick={linkDevDir} />
|
||||
<Button variant="primary" icon={<PackagePlus size={14} aria-hidden="true" />} onClick={importLocalZip}>
|
||||
<Button variant="primary" disabled={scanBusy} icon={<PackagePlus size={14} aria-hidden="true" />} onClick={importLocalZip}>
|
||||
{tr('pluginImportBtn')}
|
||||
</Button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{showThemeHero && (
|
||||
<div className="plugins-switch">
|
||||
<Segmented
|
||||
label={tr('sidebarPlugins')}
|
||||
value={activeTab}
|
||||
onChange={setActiveTab}
|
||||
options={[
|
||||
{ value: 'installed', label: tr('pluginTabInstalled') },
|
||||
{ value: 'market', label: tr('pluginTabMarket') },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{marketOpened && (
|
||||
<div hidden={activeTab !== 'market'}>
|
||||
<PluginMarket
|
||||
locale={locale}
|
||||
safeMode={safeMode}
|
||||
installed={plugins}
|
||||
refreshSignal={marketRefresh}
|
||||
onBusyChange={setMarketBusy}
|
||||
onChanged={onMarketChanged}
|
||||
onError={onError}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{activeTab === 'installed' && (
|
||||
<>
|
||||
{showThemeHero && (
|
||||
<section className="section">
|
||||
<div className="section-title">{tr('pluginThemeSection')}</div>
|
||||
<div className="theme-hero-card">
|
||||
@@ -488,10 +665,12 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
{activeTheme && activeTheme.theme_id !== 'builtin.theme.default' ? (
|
||||
<div className="theme-scheme-strip">
|
||||
<span className="muted" style={{ fontSize: 'var(--fs-12)' }}>{tr('pluginColorSchemes')}</span>
|
||||
<div className="theme-scheme-chips">
|
||||
<div className="theme-scheme-chips" role="radiogroup" aria-label={tr('pluginColorSchemes')}>
|
||||
<button
|
||||
type="button"
|
||||
className={`plugin-cat-pill${!activeTheme.active_scheme ? ' is-active' : ''}`}
|
||||
role="radio"
|
||||
aria-checked={!activeTheme.active_scheme}
|
||||
className={`plugin-pill${!activeTheme.active_scheme ? ' is-active' : ''}`}
|
||||
onClick={() => void selectTheme(activeTheme.theme_id, '')}
|
||||
>
|
||||
{tr('pluginSchemeDefault')}
|
||||
@@ -500,7 +679,9 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
<button
|
||||
key={s.id}
|
||||
type="button"
|
||||
className={`plugin-cat-pill${activeTheme.active_scheme === s.id ? ' is-active' : ''}`}
|
||||
role="radio"
|
||||
aria-checked={activeTheme.active_scheme === s.id}
|
||||
className={`plugin-pill${activeTheme.active_scheme === s.id ? ' is-active' : ''}`}
|
||||
onClick={() => void selectTheme(activeTheme.theme_id, s.id)}
|
||||
>
|
||||
{s.seeds?.accent && <span className="plugins-scheme-dot" style={{ background: s.seeds.accent }} aria-hidden="true" />}
|
||||
@@ -511,7 +692,9 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
<span className="hstack" style={{ gap: 2 }} key={s.id}>
|
||||
<button
|
||||
type="button"
|
||||
className={`plugin-cat-pill${activeTheme.active_scheme === s.id ? ' is-active' : ''}`}
|
||||
role="radio"
|
||||
aria-checked={activeTheme.active_scheme === s.id}
|
||||
className={`plugin-pill${activeTheme.active_scheme === s.id ? ' is-active' : ''}`}
|
||||
onClick={() => void selectTheme(activeTheme.theme_id, s.id)}
|
||||
>
|
||||
{s.seeds?.accent && <span className="plugins-scheme-dot" style={{ background: s.seeds.accent }} aria-hidden="true" />}
|
||||
@@ -549,7 +732,17 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
{!loading && <span className="section-count">{filteredBuiltins.length}</span>}
|
||||
</div>
|
||||
{loading ? (
|
||||
<div className="list"><div className="row plugin-row"><span className="muted">…</span></div></div>
|
||||
<div className="skeleton-list" role="status" aria-label={tr('sidebarPlugins')}>
|
||||
{[0, 1, 2].map((i) => (
|
||||
<div className="skeleton-row" key={i} aria-hidden="true">
|
||||
<div className="skeleton-stack">
|
||||
<div className="skeleton-bar w-title" />
|
||||
<div className="skeleton-bar w-sub" />
|
||||
</div>
|
||||
<div className="skeleton-bar w-btn" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="list">{filteredBuiltins.map(renderRow)}</div>
|
||||
)}
|
||||
@@ -572,21 +765,60 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
) : (
|
||||
<div className="rg-slot-anchor" data-rg-slot="settings.plugin" />
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{scanModal && (
|
||||
<Modal
|
||||
title={scanModal.mode === 'archive' ? tr('pluginScanArchiveTitle') : tr('pluginScanModalTitle')}
|
||||
subtitle={scanModal.report.plugin_id ? `${locText(scanModal.report.name, locale, scanModal.report.plugin_id)} · v${scanModal.report.version || '—'}` : scanModal.archivePath}
|
||||
closeLabel={tr('close')}
|
||||
onClose={() => { if (!scanBusy) setScanModal(null) }}
|
||||
>
|
||||
<div className="dialog-body">
|
||||
{renderScanReportBody(scanModal.report)}
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
<span className="muted mono" style={{ fontSize: 'var(--fs-11)' }}>
|
||||
{scanModal.report.tier ? `${scanModal.report.tier} · ${scanModal.report.trust || 'community'}` : ''}
|
||||
</span>
|
||||
<span className="hstack">
|
||||
{scanModal.mode === 'archive' ? (
|
||||
<>
|
||||
<Button variant="ghost" disabled={scanBusy} onClick={() => setScanModal(null)}>{tr('cancel')}</Button>
|
||||
<Button
|
||||
variant="primary"
|
||||
disabled={scanBusy || scanModal.report.hard_blocked}
|
||||
onClick={() => void confirmInstallScannedArchive()}
|
||||
>
|
||||
{scanModal.report.hard_blocked ? tr('pluginScanBlockedBtn') : tr('pluginScanInstallConfirm')}
|
||||
</Button>
|
||||
</>
|
||||
) : (
|
||||
<Button variant="primary" onClick={() => setScanModal(null)}>{tr('pluginDone')}</Button>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
</Modal>
|
||||
)}
|
||||
|
||||
{approveTarget && (
|
||||
<Modal
|
||||
title={tr('pluginApproveTitle')}
|
||||
subtitle={locText(approveTarget.name, locale, approveTarget.id)}
|
||||
closeLabel={tr('close')}
|
||||
onClose={() => setApproveTarget(null)}
|
||||
onClose={() => { setApproveTarget(null); setApproveReport(null) }}
|
||||
>
|
||||
<div className="stack-3" style={{ padding: 'var(--sp-4)' }}>
|
||||
<div className="dialog-body">
|
||||
{(approveTarget.tier === 'L3' || (approveTarget.permissions ?? []).some((p) => p.name === 'ui:script')) && (
|
||||
<div className="notice notice-warn">
|
||||
<ShieldAlert size={15} aria-hidden="true" style={{ marginRight: 6, verticalAlign: '-2px' }} />
|
||||
{tr('pluginApproveL3Warn')}
|
||||
<span className="notice-main">
|
||||
<ShieldAlert size={15} className="notice-icon" aria-hidden="true" />
|
||||
<span>{approveReport?.native_exec_notice ? locText(approveReport.native_exec_notice, locale, tr('pluginApproveL3Warn')) : tr('pluginApproveL3Warn')}</span>
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
<RiskList locale={locale} risks={approveTarget.risks} />
|
||||
<div className="list">
|
||||
<div className="row"><div className="row-main"><div className="row-title">{tr('pluginPublisherLicense')}</div><div className="row-sub">{approveTarget.publisher || '—'} · {approveTarget.license || '—'}</div></div></div>
|
||||
{approveTarget.entry_path && (
|
||||
@@ -597,7 +829,25 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
)}
|
||||
<div className="row"><div className="row-main"><div className="row-title">{tr('pluginRequestedPerms')}</div><div className="row-sub mono">{(approveTarget.permissions ?? []).length > 0 ? (approveTarget.permissions ?? []).map((p) => `${p.name} (${p.level})`).join(', ') : '—'}</div></div></div>
|
||||
</div>
|
||||
<label className="hstack" style={{ cursor: 'pointer' }}>
|
||||
{(approveReport?.capabilities?.length ?? 0) > 0 && (
|
||||
<div className="plugin-scan-section">
|
||||
<div className="plugin-scan-section-title">{tr('pluginScanCapabilitiesSection')}</div>
|
||||
<div className="list">
|
||||
{approveReport!.capabilities!.map((c) => (
|
||||
<div className="row" key={c.id}>
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
<span className={`badge rg-p-badge${c.level === 'high' ? ' badge-warn' : ''}`}>{c.level.toUpperCase()}</span>
|
||||
<span>{locText(c.title, locale, c.id)}</span>
|
||||
</div>
|
||||
<div className="row-sub">{locText(c.summary, locale, '')}</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<label className="choice">
|
||||
<input type="checkbox" checked={approveChecked} onChange={(e) => setApproveChecked(e.target.checked)} />
|
||||
<span>{tr('pluginApproveCheckbox')}</span>
|
||||
</label>
|
||||
@@ -605,7 +855,7 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
<div className="dialog-foot">
|
||||
<span />
|
||||
<span className="hstack">
|
||||
<Button variant="ghost" onClick={() => setApproveTarget(null)}>{tr('cancel')}</Button>
|
||||
<Button variant="ghost" onClick={() => { setApproveTarget(null); setApproveReport(null) }}>{tr('cancel')}</Button>
|
||||
<Button variant="primary" disabled={!approveChecked} onClick={() => void confirmApprove()}>
|
||||
{tr('pluginApproveConfirm')}
|
||||
</Button>
|
||||
@@ -621,7 +871,7 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
closeLabel={tr('close')}
|
||||
onClose={() => setSettingsTarget(null)}
|
||||
>
|
||||
<div style={{ padding: 'var(--sp-4)' }}>
|
||||
<div className="dialog-body">
|
||||
<SchemaForm
|
||||
locale={locale}
|
||||
schema={settingsTarget.settings}
|
||||
@@ -637,59 +887,53 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
</Modal>
|
||||
)}
|
||||
|
||||
{removeTarget && (
|
||||
<Modal
|
||||
title={tr('pluginRemove')}
|
||||
subtitle={locText(removeTarget.name, locale, removeTarget.id)}
|
||||
closeLabel={tr('close')}
|
||||
onClose={() => setRemoveTarget(null)}
|
||||
{disableTarget && (
|
||||
<ConfirmDialog
|
||||
title={tr('pluginDisableInUseTitle')}
|
||||
description={tr('pluginDisableInUseBody')}
|
||||
cancelLabel={tr('cancel')}
|
||||
confirmLabel={tr('pluginDisable')}
|
||||
onCancel={() => setDisableTarget(null)}
|
||||
onConfirm={() => {
|
||||
const target = disableTarget
|
||||
setDisableTarget(null)
|
||||
void togglePlugin(target, false, true)
|
||||
}}
|
||||
>
|
||||
<div style={{ padding: 'var(--sp-4)', fontSize: 'var(--fs-13)', color: 'var(--text-2)' }}>
|
||||
<span className="mono">{removeTarget.id}@{removeTarget.version}</span>
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
<span />
|
||||
<span className="hstack">
|
||||
<Button variant="ghost" onClick={() => setRemoveTarget(null)}>{tr('cancel')}</Button>
|
||||
<Button
|
||||
variant="danger"
|
||||
onClick={() => {
|
||||
const target = removeTarget
|
||||
setRemoveTarget(null)
|
||||
void removePlugin(target)
|
||||
}}
|
||||
>
|
||||
{tr('pluginRemove')}
|
||||
</Button>
|
||||
</span>
|
||||
</div>
|
||||
</Modal>
|
||||
<div className="row-sub">{locText(disableTarget.name, locale, disableTarget.id)}</div>
|
||||
</ConfirmDialog>
|
||||
)}
|
||||
|
||||
{removeTarget && (
|
||||
<ConfirmDialog
|
||||
title={tr('pluginRemove')}
|
||||
description={locText(removeTarget.name, locale, removeTarget.id)}
|
||||
cancelLabel={tr('cancel')}
|
||||
confirmLabel={tr('pluginRemove')}
|
||||
onCancel={() => setRemoveTarget(null)}
|
||||
onConfirm={() => {
|
||||
const target = removeTarget
|
||||
setRemoveTarget(null)
|
||||
void removePlugin(target)
|
||||
}}
|
||||
>
|
||||
<div className="row-sub mono">{removeTarget.id}@{removeTarget.version}</div>
|
||||
</ConfirmDialog>
|
||||
)}
|
||||
|
||||
{deleteSchemeTarget && (
|
||||
<Modal
|
||||
<ConfirmDialog
|
||||
title={tr('pluginDeleteScheme')}
|
||||
subtitle={deleteSchemeTarget.name}
|
||||
closeLabel={tr('close')}
|
||||
onClose={() => setDeleteSchemeTarget(null)}
|
||||
>
|
||||
<div className="dialog-foot">
|
||||
<span />
|
||||
<span className="hstack">
|
||||
<Button variant="ghost" onClick={() => setDeleteSchemeTarget(null)}>{tr('cancel')}</Button>
|
||||
<Button
|
||||
variant="danger"
|
||||
onClick={() => {
|
||||
const target = deleteSchemeTarget
|
||||
setDeleteSchemeTarget(null)
|
||||
void deleteScheme(target.id)
|
||||
}}
|
||||
>
|
||||
{tr('pluginDeleteScheme')}
|
||||
</Button>
|
||||
</span>
|
||||
</div>
|
||||
</Modal>
|
||||
description={deleteSchemeTarget.name}
|
||||
cancelLabel={tr('cancel')}
|
||||
confirmLabel={tr('pluginDeleteScheme')}
|
||||
onCancel={() => setDeleteSchemeTarget(null)}
|
||||
onConfirm={() => {
|
||||
const target = deleteSchemeTarget
|
||||
setDeleteSchemeTarget(null)
|
||||
void deleteScheme(target.id)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{logTarget && (
|
||||
@@ -698,9 +942,9 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
closeLabel={tr('close')}
|
||||
onClose={() => setLogTarget(null)}
|
||||
>
|
||||
<pre className="mono selectable" style={{ padding: 'var(--sp-4)', maxHeight: 360, overflow: 'auto', margin: 0 }}>
|
||||
{logTarget.text}
|
||||
</pre>
|
||||
<div className="dialog-body">
|
||||
<pre className="plugin-log-pre mono selectable">{logTarget.text}</pre>
|
||||
</div>
|
||||
</Modal>
|
||||
)}
|
||||
|
||||
@@ -710,19 +954,19 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
closeLabel={tr('close')}
|
||||
onClose={() => setSchemeEditorOpen(false)}
|
||||
>
|
||||
<div className="stack-3" style={{ padding: 'var(--sp-4)' }}>
|
||||
<label className="stack-1">
|
||||
<span>{tr('pluginSchemeName')}</span>
|
||||
<input className="input" value={schemeName} onChange={(e) => setSchemeName(e.target.value)} placeholder={tr('pluginSchemePlaceholder')} />
|
||||
<div className="dialog-body">
|
||||
<label className="field">
|
||||
<span className="field-label">{tr('pluginSchemeName')}</span>
|
||||
<input className="input rg-p-input" value={schemeName} onChange={(e) => setSchemeName(e.target.value)} placeholder={tr('pluginSchemePlaceholder')} />
|
||||
</label>
|
||||
<label className="hstack">
|
||||
<span>{tr('pluginAccentSeed')}</span>
|
||||
<span className="field-label">{tr('pluginAccentSeed')}</span>
|
||||
<input type="color" value={seedAccent} onChange={(e) => setSeedAccent(e.target.value)} />
|
||||
<span className="mono">{seedAccent}</span>
|
||||
</label>
|
||||
<label className="stack-1">
|
||||
<span>{tr('pluginSurfaceSeed')}</span>
|
||||
<input className="input mono" value={seedSurface} onChange={(e) => setSeedSurface(e.target.value)} placeholder="#1d1e23" />
|
||||
<label className="field">
|
||||
<span className="field-label">{tr('pluginSurfaceSeed')}</span>
|
||||
<input className="input rg-p-input mono" value={seedSurface} onChange={(e) => setSeedSurface(e.target.value)} placeholder="#1d1e23" />
|
||||
</label>
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
import { Download, LoaderCircle, Pause, RefreshCw } from 'lucide-react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import '../i18n/domains/wizard.gen'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { taskDetail } from '../lib/tasks'
|
||||
import { InstalledRuntime, Locale, RemoteRuntime, RuntimeSource, Task } from '../types'
|
||||
import { InstalledRuntime, Locale, RemoteRuntime, Task } from '../types'
|
||||
import { Button, IconButton } from '../ui/controls'
|
||||
import { Segmented, Switch } from '../ui/settings'
|
||||
import { Switch } from '../ui/settings'
|
||||
import { api } from '../wails'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
channel: 'stable' | 'alpha'
|
||||
source: RuntimeSource
|
||||
installed: InstalledRuntime[]
|
||||
task: Task | null
|
||||
onChannel: (alpha: boolean) => void
|
||||
onSource: (source: RuntimeSource) => void
|
||||
onInstall: (commit: string) => void
|
||||
onCancel: (taskId: string) => void
|
||||
}
|
||||
@@ -26,9 +25,9 @@ const shortQemu = (v: string) => v.replace(/^QEMU emulator version\s*/i, 'QEMU '
|
||||
|
||||
/**
|
||||
* The runtime rows: the active runtime and whether it is current (or, with
|
||||
* none installed, the newest release to install), then download source and alpha switches.
|
||||
* none installed, the newest release to install), then the alpha switch.
|
||||
*/
|
||||
export const RuntimeOnline: React.FC<Props> = ({ locale, channel, source, installed, task, onChannel, onSource, onInstall, onCancel }) => {
|
||||
export const RuntimeOnline: React.FC<Props> = ({ locale, channel, installed, task, onChannel, onInstall, onCancel }) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const [remote, setRemote] = useState<RemoteRuntime[] | null>(null)
|
||||
const [error, setError] = useState('')
|
||||
@@ -42,7 +41,7 @@ export const RuntimeOnline: React.FC<Props> = ({ locale, channel, source, instal
|
||||
.then((list) => { if (live) setRemote(list ?? []) })
|
||||
.catch((e) => { if (live) setError(String(e).replace(/^Error:\s*/, '')) })
|
||||
return () => { live = false }
|
||||
}, [channel, source, task?.status === 'done', reload])
|
||||
}, [channel, task?.status === 'done', reload])
|
||||
|
||||
const active = installed.find((i) => i.active) ?? installed[0]
|
||||
const latest = remote?.[0]
|
||||
@@ -61,7 +60,7 @@ export const RuntimeOnline: React.FC<Props> = ({ locale, channel, source, instal
|
||||
<div className="row-sub task-inline">
|
||||
<LoaderCircle size={14} className="spin" aria-hidden="true" />
|
||||
{task.percent >= 0 && (
|
||||
<span className="progress" aria-hidden="true">
|
||||
<span className="progress rg-p-progress" aria-hidden="true">
|
||||
<span className="progress-fill" style={{ transform: `scaleX(${Math.max(0, Math.min(1, task.percent / 100))})` }} />
|
||||
</span>
|
||||
)}
|
||||
@@ -79,12 +78,10 @@ export const RuntimeOnline: React.FC<Props> = ({ locale, channel, source, instal
|
||||
} else if (!latest) {
|
||||
sub = <div className="row-sub">{tr('runtimeNoneOnChannel')}</div>
|
||||
} else {
|
||||
const srcLabel = latest.source === 'gitcode' ? 'GitCode' : latest.source === 'github' ? 'GitHub' : ''
|
||||
sub = (
|
||||
<div className="row-sub">
|
||||
{active ? tr('runtimeNewer', { v: latest.commit }) : tr('runtimeLatest', { v: latest.commit })}
|
||||
{' · '}{tr(`runtimeChannel_${latest.channel}` as I18nKey)}
|
||||
{srcLabel ? ` · ${srcLabel}` : ''}
|
||||
{latest.archive_size > 0 ? ` · ${gb(latest.archive_size)}` : ''}
|
||||
</div>
|
||||
)
|
||||
@@ -111,27 +108,10 @@ export const RuntimeOnline: React.FC<Props> = ({ locale, channel, source, instal
|
||||
{tr(active ? 'runtimeUpdate' : 'runtimeInstall')}
|
||||
</Button>
|
||||
) : !running && active && remote ? (
|
||||
<span className="badge badge-ok">{tr('runtimeUpToDate')}</span>
|
||||
<span className="badge rg-p-badge badge-ok">{tr('runtimeUpToDate')}</span>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('runtimeSource')}</div>
|
||||
<div className="row-sub">{tr('runtimeSourceHint')}</div>
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<Segmented
|
||||
label={tr('runtimeSource')}
|
||||
value={source}
|
||||
onChange={onSource}
|
||||
options={(['auto', 'github', 'gitcode'] as RuntimeSource[]).map((s) => ({
|
||||
value: s,
|
||||
label: tr(`runtimeSource_${s}` as I18nKey),
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('runtimeAlpha')}</div>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import React from 'react'
|
||||
import '../i18n/domains/plugins.gen'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import { locText, t } from '../i18n'
|
||||
import { Locale, SettingProperty, SettingsSchema } from '../types'
|
||||
import { NumberField, PopupSelect, Segmented, SetGroup, SetRow, Switch } from '../ui/settings'
|
||||
@@ -51,7 +53,7 @@ export const SchemaForm: React.FC<Props> = ({
|
||||
const eff = prop['x-effect']
|
||||
if (!eff) return null
|
||||
const label = t(locale, eff === 'immediate' ? 'effectImmediate' : 'effectNextStart')
|
||||
return <span className={`badge ${eff === 'immediate' ? 'badge-ok' : ''}`}>{label}</span>
|
||||
return <span className={`badge rg-p-badge ${eff === 'immediate' ? 'badge-ok' : ''}`}>{label}</span>
|
||||
}
|
||||
|
||||
const renderControl = (k: string, prop: SettingProperty) => {
|
||||
@@ -112,7 +114,7 @@ export const SchemaForm: React.FC<Props> = ({
|
||||
return (
|
||||
<input
|
||||
type="password"
|
||||
className="input"
|
||||
className="input rg-p-input"
|
||||
aria-label={label}
|
||||
autoComplete="new-password"
|
||||
placeholder={isMasked ? SECRET_MASK : undefined}
|
||||
@@ -125,7 +127,7 @@ export const SchemaForm: React.FC<Props> = ({
|
||||
return (
|
||||
<input
|
||||
type="text"
|
||||
className="input"
|
||||
className="input rg-p-input"
|
||||
aria-label={label}
|
||||
value={String(cur ?? '')}
|
||||
onChange={(e) => setKey(k, e.target.value)}
|
||||
|
||||
@@ -19,7 +19,7 @@ export const SendTextDialog: React.FC<Props> = ({ locale, vmName, guestToolsConn
|
||||
<Alert.Root open onOpenChange={(open) => { if (!open) onCancel() }}>
|
||||
<Alert.Portal>
|
||||
<Alert.Overlay className="overlay" />
|
||||
<Alert.Content className="dialog sm">
|
||||
<Alert.Content className="dialog rg-p-dialog sm" data-tone="neutral">
|
||||
<div className="dialog-body">
|
||||
<Alert.Title className="dialog-title">{t(locale, 'sendTextTitle', { name: vmName })}</Alert.Title>
|
||||
<Alert.Description className="dialog-desc">
|
||||
@@ -27,7 +27,7 @@ export const SendTextDialog: React.FC<Props> = ({ locale, vmName, guestToolsConn
|
||||
</Alert.Description>
|
||||
<div className="field field-spaced">
|
||||
<textarea
|
||||
className="input textarea"
|
||||
className="input rg-p-input textarea"
|
||||
rows={4}
|
||||
placeholder={t(locale, 'sendTextPlaceholder')}
|
||||
value={text}
|
||||
@@ -44,10 +44,10 @@ export const SendTextDialog: React.FC<Props> = ({ locale, vmName, guestToolsConn
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
<Alert.Cancel asChild>
|
||||
<button type="button" className="btn">{t(locale, 'cancel')}</button>
|
||||
<button type="button" className="btn rg-p-button">{t(locale, 'cancel')}</button>
|
||||
</Alert.Cancel>
|
||||
<Alert.Action asChild>
|
||||
<button type="button" className="btn btn-primary" disabled={!canSend} onClick={() => onConfirm(text)}>
|
||||
<button type="button" className="btn rg-p-button btn-primary" disabled={!canSend} onClick={() => onConfirm(text)}>
|
||||
{t(locale, 'sendTextConfirm')}
|
||||
</button>
|
||||
</Alert.Action>
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,11 +1,14 @@
|
||||
import { FolderOpen, HardDrive } from 'lucide-react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { getLocaleOptions, I18nKey, joinNotices, t } from '../i18n'
|
||||
import { AppState, DataRootCheck, DataRootChoice, Locale, ResolvedLocalePack, RuntimeSource, Task } from '../types'
|
||||
import '../i18n/domains/wizard.gen'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import { getLocaleOptions, I18nKey, joinNotices, locText, t } from '../i18n'
|
||||
import { AppState, DataRootCheck, DataRootChoice, Locale, MarketCatalogItem, ResolvedLocalePack, Task } from '../types'
|
||||
import { Button } from '../ui/controls'
|
||||
import { PopupSelect } from '../ui/settings'
|
||||
import { gpuCompatHint, recommendedMemoryGB, shortGPUName } from '../lib/format'
|
||||
import { api } from '../wails'
|
||||
import { PluginAppIcon } from './PluginAppIcon'
|
||||
import { RuntimeOnline } from './RuntimeOnline'
|
||||
|
||||
interface Props {
|
||||
@@ -15,11 +18,12 @@ interface Props {
|
||||
stage: 'folder' | 'runtime'
|
||||
runtimeTask: Task | null
|
||||
onLocale: (l: Locale) => void
|
||||
/** A plugin was installed or enabled; the app reloads plugin contributions. */
|
||||
onPluginsChanged: () => void
|
||||
onFolderDone: () => void
|
||||
onFinish: () => void
|
||||
onError: (title: string, e: unknown) => void
|
||||
onChannel: (alpha: boolean) => void
|
||||
onSource: (source: RuntimeSource) => void
|
||||
onInstallRuntime: (commit: string) => void
|
||||
onCancelTask: (id: string) => void
|
||||
onImportRuntime: () => void
|
||||
@@ -41,13 +45,16 @@ export const Setup: React.FC<Props> = (p) => {
|
||||
|
||||
type StepProps = Props & { tr: (k: I18nKey, v?: Record<string, string | number>) => string }
|
||||
|
||||
const FolderStep: React.FC<StepProps> = ({ locale, locales, tr, onLocale, onFolderDone, onError }) => {
|
||||
const FolderStep: React.FC<StepProps> = ({ locale, locales, state, tr, onLocale, onPluginsChanged, onFolderDone, onError }) => {
|
||||
const [choices, setChoices] = useState<DataRootChoice[]>([])
|
||||
const [custom, setCustom] = useState('')
|
||||
const [customMode, setCustomMode] = useState(false)
|
||||
const [selected, setSelected] = useState('')
|
||||
const [check, setCheck] = useState<DataRootCheck | null>(null)
|
||||
const [busy, setBusy] = useState(false)
|
||||
// A market language pack for the OS language, looked up once on first launch.
|
||||
const [langPack, setLangPack] = useState<MarketCatalogItem | null>(null)
|
||||
const [langPackOn, setLangPackOn] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
api.SuggestDataRoots().then((list) => {
|
||||
@@ -56,12 +63,18 @@ const FolderStep: React.FC<StepProps> = ({ locale, locales, tr, onLocale, onFold
|
||||
const rec = l.find((c) => c.recommended) ?? l[0]
|
||||
if (rec) setSelected(rec.path)
|
||||
}).catch((e) => onError(tr('failGeneric'), e))
|
||||
api.SuggestLanguagePack().then((p) => { if (p?.entry) setLangPack(p) }).catch((e) => console.warn('[setup] SuggestLanguagePack failed:', e))
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (!selected) { setCheck(null); return }
|
||||
let live = true
|
||||
api.CheckDataRoot(selected).then((c) => { if (live) setCheck(c) }).catch(() => {})
|
||||
api.CheckDataRoot(selected)
|
||||
.then((c) => { if (live) setCheck(c) })
|
||||
.catch((e) => {
|
||||
if (live) setCheck(null)
|
||||
console.warn('[setup] CheckDataRoot failed:', e)
|
||||
})
|
||||
return () => { live = false }
|
||||
}, [selected])
|
||||
|
||||
@@ -74,14 +87,29 @@ const FolderStep: React.FC<StepProps> = ({ locale, locales, tr, onLocale, onFold
|
||||
setBusy(true)
|
||||
try {
|
||||
await api.CompleteSetup(selected)
|
||||
onFolderDone()
|
||||
} catch (e) {
|
||||
onError(tr('failGeneric'), e)
|
||||
} finally {
|
||||
setBusy(false)
|
||||
return
|
||||
}
|
||||
// Plugins live in the data folder, so the pack installs once it exists.
|
||||
// With the language left on "auto", enabling the pack is enough for the
|
||||
// UI to switch to the OS language.
|
||||
if (langPack && langPackOn) {
|
||||
try {
|
||||
const info = await api.InstallMarketPlugin(langPack.entry.id, false)
|
||||
if (info && !info.enabled && !info.needs_approval) await api.EnablePlugin(info.id, false)
|
||||
onPluginsChanged()
|
||||
} catch (e) {
|
||||
onError(tr('setupLangPackFailed'), e)
|
||||
}
|
||||
}
|
||||
setBusy(false)
|
||||
onFolderDone()
|
||||
}
|
||||
|
||||
const osTag = state.detected_locale || locale
|
||||
|
||||
const option = (path: string, meta: React.ReactNode) => (
|
||||
<label key={path} className="choice-card" data-selected={selected === path}>
|
||||
<input type="radio" name="data-root" checked={selected === path} onChange={() => setSelected(path)} />
|
||||
@@ -111,15 +139,15 @@ const FolderStep: React.FC<StepProps> = ({ locale, locales, tr, onLocale, onFold
|
||||
{choices.map((c) => option(c.path, (
|
||||
<>
|
||||
{tr('setupFree', { n: c.free_gb.toFixed(0) })}
|
||||
{c.recommended && <span className="badge badge-accent">{tr('setupRecommended')}</span>}
|
||||
{c.system && <span className="badge">{tr('setupSystem')}</span>}
|
||||
{c.external && <span className="badge badge-warn">{tr('setupExternal')}</span>}
|
||||
{c.recommended && <span className="badge rg-p-badge badge-accent">{tr('setupRecommended')}</span>}
|
||||
{c.system && <span className="badge rg-p-badge">{tr('setupSystem')}</span>}
|
||||
{c.external && <span className="badge rg-p-badge badge-warn">{tr('setupExternal')}</span>}
|
||||
</>
|
||||
)))}
|
||||
{customMode ? (
|
||||
<div className="input-group">
|
||||
<input
|
||||
className="input mono"
|
||||
className="input rg-p-input mono"
|
||||
aria-label={tr('setupOther')}
|
||||
value={custom}
|
||||
placeholder="D:\VMs\reims-go"
|
||||
@@ -142,12 +170,27 @@ const FolderStep: React.FC<StepProps> = ({ locale, locales, tr, onLocale, onFold
|
||||
{customMode && check && check.path === custom && !check.error && (
|
||||
<div className="hint">{tr('setupFree', { n: check.free_gb.toFixed(0) })}</div>
|
||||
)}
|
||||
{langPack && (
|
||||
<label className="setup-langpack">
|
||||
<input type="checkbox" checked={langPackOn} disabled={busy} onChange={(e) => setLangPackOn(e.target.checked)} />
|
||||
<PluginAppIcon kind="locale" size="sm" />
|
||||
<span className="setup-langpack-main">
|
||||
{/* The pack's name and blurb in the OS language: that is who it is for. */}
|
||||
<span className="setup-langpack-title">
|
||||
{tr('setupLangPackOffer', { name: locText(langPack.entry.name, osTag, langPack.entry.id) })}
|
||||
</span>
|
||||
{locText(langPack.entry.description, osTag) && (
|
||||
<span className="setup-langpack-sub">{locText(langPack.entry.description, osTag)}</span>
|
||||
)}
|
||||
</span>
|
||||
</label>
|
||||
)}
|
||||
<div className="setup-foot">
|
||||
<PopupSelect
|
||||
label={tr('language')}
|
||||
value={locale}
|
||||
value={state.config.locale || 'auto'}
|
||||
onChange={onLocale}
|
||||
options={getLocaleOptions(locales)}
|
||||
options={getLocaleOptions(locales, locale, state.detected_locale)}
|
||||
/>
|
||||
<Button variant="primary" busy={busy} disabled={!selected || !!check?.error} onClick={next}>{tr('setupContinue')}</Button>
|
||||
</div>
|
||||
@@ -155,7 +198,7 @@ const FolderStep: React.FC<StepProps> = ({ locale, locales, tr, onLocale, onFold
|
||||
)
|
||||
}
|
||||
|
||||
const RuntimeStep: React.FC<StepProps> = ({ locale, tr, state, runtimeTask, onChannel, onSource, onInstallRuntime, onCancelTask, onImportRuntime, onFinish, onError }) => {
|
||||
const RuntimeStep: React.FC<StepProps> = ({ locale, tr, state, runtimeTask, onChannel, onInstallRuntime, onCancelTask, onImportRuntime, onFinish, onError }) => {
|
||||
const ready = !!state.active_runtime
|
||||
const { host } = state
|
||||
const [enabling, setEnabling] = useState(false)
|
||||
@@ -166,7 +209,7 @@ const RuntimeStep: React.FC<StepProps> = ({ locale, tr, state, runtimeTask, onCh
|
||||
const whpxOK = host.whpx === 'ready'
|
||||
const gpu = host.recommended_gpu ?? (host.gpus ?? []).find((g) => g.kind !== 'virtual')
|
||||
const gpuHint = gpuCompatHint(locale, gpu)
|
||||
const gpuOK = !!gpu && gpu.compat !== 'warn' && gpu.compat !== 'unsupported'
|
||||
const gpuOK = !host.vulkan_probe_error && !!gpu && gpu.compat !== 'warn' && gpu.compat !== 'unsupported'
|
||||
const recMem = recommendedMemoryGB(host)
|
||||
return (
|
||||
<>
|
||||
@@ -190,7 +233,7 @@ const RuntimeStep: React.FC<StepProps> = ({ locale, tr, state, runtimeTask, onCh
|
||||
{host.whpx === 'missing' ? (
|
||||
<Button variant="primary" busy={enabling} onClick={enableWHPX}>{tr('enableWHPX')}</Button>
|
||||
) : (
|
||||
<span className={`badge ${whpxOK ? 'badge-ok' : 'badge-warn'}`}>
|
||||
<span className={`badge rg-p-badge ${whpxOK ? 'badge-ok' : 'badge-warn'}`}>
|
||||
{tr(whpxOK ? 'whpxReady' : host.whpx === 'no_hypervisor' ? 'whpxNoHvShort' : 'whpxUnsupportedShort')}
|
||||
</span>
|
||||
)}
|
||||
@@ -199,11 +242,14 @@ const RuntimeStep: React.FC<StepProps> = ({ locale, tr, state, runtimeTask, onCh
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('setupGPU')}</div>
|
||||
<div className="row-sub">{gpu ? shortGPUName(gpu.name) : tr('setupNoGPU')}</div>
|
||||
{gpu && <div className="row-sub">{shortGPUName(gpu.name)}</div>}
|
||||
{host.vulkan_probe_error ? (
|
||||
<div className="row-sub warn-text">{tr('vulkanProbeFailed', { detail: host.vulkan_probe_error })}</div>
|
||||
) : !gpu && <div className="row-sub">{tr('setupNoGPU')}</div>}
|
||||
{gpuHint && <div className="row-sub warn-text">{gpuHint}</div>}
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<span className={`badge ${gpuOK ? 'badge-ok' : 'badge-warn'}`}>
|
||||
<span className={`badge rg-p-badge ${gpuOK ? 'badge-ok' : 'badge-warn'}`}>
|
||||
{tr(
|
||||
gpuOK
|
||||
? 'whpxReady'
|
||||
@@ -226,7 +272,7 @@ const RuntimeStep: React.FC<StepProps> = ({ locale, tr, state, runtimeTask, onCh
|
||||
</div>
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<span className={`badge ${recMem >= 8 ? 'badge-ok' : 'badge-warn'}`}>{tr('setupRecMem', { n: recMem })}</span>
|
||||
<span className={`badge rg-p-badge ${recMem >= 8 ? 'badge-ok' : 'badge-warn'}`}>{tr('setupRecMem', { n: recMem })}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -235,11 +281,9 @@ const RuntimeStep: React.FC<StepProps> = ({ locale, tr, state, runtimeTask, onCh
|
||||
<RuntimeOnline
|
||||
locale={locale}
|
||||
channel={state.config.runtime_channel === 'alpha' ? 'alpha' : 'stable'}
|
||||
source={state.config.runtime_source === 'github' || state.config.runtime_source === 'gitcode' ? state.config.runtime_source : 'auto'}
|
||||
installed={state.runtimes ?? []}
|
||||
task={runtimeTask}
|
||||
onChannel={onChannel}
|
||||
onSource={onSource}
|
||||
onInstall={onInstallRuntime}
|
||||
onCancel={onCancelTask}
|
||||
/>
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import * as Ctx from '@radix-ui/react-context-menu'
|
||||
import { AppWindow, Camera, CopyPlus, Cpu, Download, FolderOpen, Info, Play, Plus, Power, Puzzle, RotateCw, Settings, Square, Trash } from 'lucide-react'
|
||||
import { AppWindow, Camera, CopyPlus, Cpu, Download, FolderOpen, Info, Maximize2, Pause, Play, Plus, Power, Puzzle, RotateCw, Settings, Square, Trash } from 'lucide-react'
|
||||
import React, { useRef } from 'react'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { I18nKey, localeDir, t } from '../i18n'
|
||||
import { Locale, VMListItem } from '../types'
|
||||
import { vmRefKey } from '../lib/vmRef'
|
||||
import { IconButton, StatusShape, Tip, statusKind } from '../ui/controls'
|
||||
import { VersionArt } from './VersionArt'
|
||||
import { VersionArt } from '../macos/VersionArt'
|
||||
import { BrandMark, HostIcon } from '../ui/themeVisuals'
|
||||
import { VMAction } from './VMPage'
|
||||
|
||||
export const HOST_ID = '__host__'
|
||||
@@ -20,8 +22,12 @@ interface Props {
|
||||
locale: Locale
|
||||
vms: VMListItem[]
|
||||
transitions: Record<string, string>
|
||||
/** VM name → currently running action (disables conflicting context menu actions). */
|
||||
busyActions?: Record<string, VMAction>
|
||||
selected: string
|
||||
hostReady: boolean
|
||||
/** Whether the active runtime supports VM suspend/resume. */
|
||||
canSuspend: boolean
|
||||
onSelect: (id: string) => void
|
||||
/** VM name → display name (its note); empty or missing shows the name. */
|
||||
displayNames?: Record<string, string>
|
||||
@@ -42,11 +48,12 @@ interface Props {
|
||||
}
|
||||
|
||||
export const Sidebar: React.FC<Props> = ({
|
||||
locale, vms, transitions, selected, hostReady, onSelect, displayNames = {}, macosMajors = {}, onActivate, onNew, onVMContextAction, downloading, safeMode, updateCard, updateDot,
|
||||
locale, vms, transitions, busyActions = {}, selected, hostReady, canSuspend, onSelect, displayNames = {}, macosMajors = {}, onActivate, onNew, onVMContextAction, downloading, safeMode, updateCard, updateDot,
|
||||
}) => {
|
||||
const tr = (k: I18nKey) => t(locale, k)
|
||||
const listRef = useRef<HTMLDivElement>(null)
|
||||
const ids = [...vms.map((v) => v.name), INSTALLERS_ID, PLUGINS_ID, HOST_ID, SETTINGS_ID, ABOUT_ID]
|
||||
const ctxOpenedByPointerRef = useRef(false)
|
||||
const ids = [...vms.map((v) => vmRefKey(v)), INSTALLERS_ID, PLUGINS_ID, HOST_ID, SETTINGS_ID, ABOUT_ID]
|
||||
|
||||
// Listbox keyboard model: ↑/↓/Home/End move selection and focus together.
|
||||
const onKeyDown = (e: React.KeyboardEvent) => {
|
||||
@@ -62,6 +69,7 @@ export const Sidebar: React.FC<Props> = ({
|
||||
listRef.current?.querySelector<HTMLElement>(`[data-id="${CSS.escape(ids[next])}"]`)?.focus()
|
||||
}
|
||||
|
||||
const hasSelectedInList = ids.includes(selected)
|
||||
const navBtn = (
|
||||
id: string,
|
||||
label: string,
|
||||
@@ -71,16 +79,21 @@ export const Sidebar: React.FC<Props> = ({
|
||||
kind: ReturnType<typeof statusKind> | null,
|
||||
onDoubleClick?: () => void,
|
||||
dot?: boolean,
|
||||
vm?: { state: string; driver: string; busy: boolean },
|
||||
) => (
|
||||
<button
|
||||
key={id}
|
||||
type="button"
|
||||
role="option"
|
||||
data-id={id}
|
||||
className="nav-item"
|
||||
className="nav-item rg-p-nav-item"
|
||||
data-selected={selected === id ? 'true' : 'false'}
|
||||
data-vm-state={vm?.state}
|
||||
data-driver={vm?.driver}
|
||||
data-busy={vm ? (vm.busy ? 'true' : 'false') : undefined}
|
||||
aria-selected={selected === id}
|
||||
aria-label={stateLabel ? t(locale, 'sidebarItemAria', { label, state: stateLabel }) : label}
|
||||
tabIndex={selected === id ? 0 : -1}
|
||||
tabIndex={selected === id || (!hasSelectedInList && id === ids[0]) ? 0 : -1}
|
||||
onClick={() => onSelect(id)}
|
||||
onDoubleClick={onDoubleClick}
|
||||
>
|
||||
@@ -92,6 +105,7 @@ export const Sidebar: React.FC<Props> = ({
|
||||
<span className="hstack"><StatusShape kind={kind} /></span>
|
||||
</Tip>
|
||||
)}
|
||||
{vm && <span className="rg-slot-anchor nav-item-trailing" data-rg-slot="nav.item.trailing" data-rg-key={id} aria-hidden="true" />}
|
||||
</button>
|
||||
)
|
||||
|
||||
@@ -99,82 +113,124 @@ export const Sidebar: React.FC<Props> = ({
|
||||
<div className="sidebar-wrap">
|
||||
<aside className="sidebar rg-p-sidebar">
|
||||
<div className="sidebar-brand">
|
||||
<img className="sidebar-brand-mark" src="/logo.svg" alt="" aria-hidden="true" />
|
||||
<BrandMark className="sidebar-brand-mark" />
|
||||
<span className="sidebar-brand-name">Reims-Go</span>
|
||||
</div>
|
||||
<div className="rg-slot-anchor" data-rg-slot="sidebar.header" />
|
||||
{updateCard}
|
||||
<div className="sidebar-head rg-p-sidebar-head">
|
||||
<span>{tr('sidebarVMs')}</span>
|
||||
<IconButton small label={tr('newVM')} shortcut="Ctrl+N" icon={<Plus size={15} />} onClick={onNew} tipSide="right" />
|
||||
<IconButton small label={tr('newVM')} shortcut="Ctrl+N" icon={<HostIcon name="new-vm"><Plus size={15} /></HostIcon>} onClick={onNew} tipSide="right" />
|
||||
</div>
|
||||
<div className="nav rg-p-nav" role="listbox" aria-label={tr('sidebarVMs')} ref={listRef} onKeyDown={onKeyDown}>
|
||||
<div className="nav-group nav-vms" role="group" aria-label={tr('sidebarVMs')}>
|
||||
<div className="nav-group rg-p-nav-group nav-vms" role="group" aria-label={tr('sidebarVMs')}>
|
||||
{vms.length === 0 && <div className="nav-empty rg-p-empty" data-rg-slot="empty.state">{tr('emptyVMs')}</div>}
|
||||
{vms.map((vm) => {
|
||||
const st = transitions[vm.name] ?? vm.state
|
||||
const st = transitions[vmRefKey(vm)] ?? vm.state
|
||||
const running = st === 'running'
|
||||
const stopped = st === 'stopped'
|
||||
const transitioning = st === 'starting' || st === 'stopping'
|
||||
const suspended = st === 'suspended'
|
||||
const transitioning = st === 'starting' || st === 'stopping' || st === 'suspending' || st === 'resuming'
|
||||
const busyAction = Object.prototype.hasOwnProperty.call(busyActions, vm.name) ? busyActions[vm.name] : undefined
|
||||
const vmBusy = !!busyAction
|
||||
const label = displayNames[vm.name] || vm.name
|
||||
const trigger = navBtn(
|
||||
vm.name,
|
||||
vmRefKey(vm),
|
||||
label,
|
||||
<VersionArt shape="tile" major={macosMajors[vm.name] ?? null} name={label} />,
|
||||
'nav-icon-art',
|
||||
t(locale, `state_${st}` as I18nKey),
|
||||
statusKind(st),
|
||||
onActivate ? () => onActivate(vm.name) : undefined,
|
||||
onActivate ? () => onActivate(vmRefKey(vm)) : undefined,
|
||||
undefined,
|
||||
{ state: st, driver: vm.driver_id ?? '', busy: vmBusy || transitioning },
|
||||
)
|
||||
if (!onVMContextAction) return trigger
|
||||
return (
|
||||
<Ctx.Root key={vm.name}>
|
||||
<Ctx.Trigger asChild>{trigger}</Ctx.Trigger>
|
||||
<Ctx.Root key={vmRefKey(vm)} dir={localeDir(locale)}>
|
||||
<Ctx.Trigger
|
||||
asChild
|
||||
onContextMenu={(e) => {
|
||||
ctxOpenedByPointerRef.current = e.button === 2 && (e.clientX !== 0 || e.clientY !== 0)
|
||||
}}
|
||||
>
|
||||
{trigger}
|
||||
</Ctx.Trigger>
|
||||
<Ctx.Portal>
|
||||
<Ctx.Content className="menu">
|
||||
<Ctx.Content
|
||||
className="menu rg-p-menu"
|
||||
onCloseAutoFocus={(e) => {
|
||||
if (
|
||||
ctxOpenedByPointerRef.current
|
||||
|| document.querySelector('[role="dialog"], [role="alertdialog"]')
|
||||
) {
|
||||
e.preventDefault()
|
||||
}
|
||||
}}
|
||||
>
|
||||
{stopped && (
|
||||
<Ctx.Item className="menu-item" onSelect={() => onVMContextAction(vm.name, 'start')}>
|
||||
<Play size={14} /> {tr('start')}
|
||||
<Ctx.Item className="menu-item rg-p-menu-item" disabled={vmBusy} onSelect={() => onVMContextAction(vmRefKey(vm), 'start')}>
|
||||
<HostIcon name="start"><Play size={14} /></HostIcon> {tr('start')}
|
||||
</Ctx.Item>
|
||||
)}
|
||||
{suspended && (
|
||||
<>
|
||||
<Ctx.Item className="menu-item rg-p-menu-item" disabled={vmBusy || !canSuspend} onSelect={() => onVMContextAction(vmRefKey(vm), 'resume')}>
|
||||
<HostIcon name="resume"><Play size={14} /></HostIcon> {tr('resume')}
|
||||
</Ctx.Item>
|
||||
{!canSuspend && <Ctx.Label className="menu-group-label">{tr('resumeUnavailable')}</Ctx.Label>}
|
||||
<Ctx.Item className="menu-item rg-p-menu-item danger" disabled={vmBusy} onSelect={() => onVMContextAction(vmRefKey(vm), 'discardSuspend')}>
|
||||
<Power size={14} /> {tr('discardSuspend')}
|
||||
</Ctx.Item>
|
||||
</>
|
||||
)}
|
||||
{running && (
|
||||
<>
|
||||
<Ctx.Item className="menu-item" onSelect={() => onVMContextAction(vm.name, 'focus')}>
|
||||
<AppWindow size={14} /> {tr('showWindow')}
|
||||
<Ctx.Item className="menu-item rg-p-menu-item" disabled={vmBusy} onSelect={() => onVMContextAction(vmRefKey(vm), 'focus')}>
|
||||
<HostIcon name="window"><AppWindow size={14} /></HostIcon> {tr('showWindow')}
|
||||
</Ctx.Item>
|
||||
<Ctx.Item className="menu-item" onSelect={() => onVMContextAction(vm.name, 'screenshot')}>
|
||||
<Camera size={14} /> {tr('copyScreenshot')}
|
||||
<Ctx.Item className="menu-item rg-p-menu-item" disabled={vmBusy} onSelect={() => onVMContextAction(vmRefKey(vm), 'fullscreen')}>
|
||||
<HostIcon name="fullscreen"><Maximize2 size={14} /></HostIcon> {tr('toggleFullscreen')}
|
||||
</Ctx.Item>
|
||||
<Ctx.Item className="menu-item" onSelect={() => onVMContextAction(vm.name, 'stop')}>
|
||||
<Square size={14} /> {tr('stop')}
|
||||
<Ctx.Item className="menu-item rg-p-menu-item" disabled={vmBusy} onSelect={() => onVMContextAction(vmRefKey(vm), 'screenshot')}>
|
||||
<HostIcon name="screenshot"><Camera size={14} /></HostIcon> {tr('copyScreenshot')}
|
||||
</Ctx.Item>
|
||||
<Ctx.Item className="menu-item" onSelect={() => onVMContextAction(vm.name, 'restart')}>
|
||||
<RotateCw size={14} /> {tr('restart')}
|
||||
{canSuspend && (
|
||||
<Ctx.Item className="menu-item rg-p-menu-item" disabled={vmBusy} onSelect={() => onVMContextAction(vmRefKey(vm), 'suspend')}>
|
||||
<HostIcon name="suspend"><Pause size={14} /></HostIcon> {tr('suspend')}
|
||||
</Ctx.Item>
|
||||
)}
|
||||
<Ctx.Item className="menu-item rg-p-menu-item" disabled={vmBusy} onSelect={() => onVMContextAction(vmRefKey(vm), 'stop')}>
|
||||
<HostIcon name="stop"><Square size={14} /></HostIcon> {tr('stop')}
|
||||
</Ctx.Item>
|
||||
<Ctx.Item className="menu-item rg-p-menu-item" disabled={vmBusy} onSelect={() => onVMContextAction(vmRefKey(vm), 'restart')}>
|
||||
<HostIcon name="restart"><RotateCw size={14} /></HostIcon> {tr('restart')}
|
||||
</Ctx.Item>
|
||||
</>
|
||||
)}
|
||||
{(running || transitioning) && (
|
||||
<Ctx.Item className="menu-item danger" onSelect={() => onVMContextAction(vm.name, 'forceStop')}>
|
||||
<Power size={14} /> {tr('forceStop')}
|
||||
<Ctx.Item className="menu-item rg-p-menu-item danger" disabled={busyAction === 'forceStop'} onSelect={() => onVMContextAction(vmRefKey(vm), 'forceStop')}>
|
||||
<HostIcon name="force-stop"><Power size={14} /></HostIcon> {tr('forceStop')}
|
||||
</Ctx.Item>
|
||||
)}
|
||||
<Ctx.Separator className="menu-sep" />
|
||||
<Ctx.Item className="menu-item" onSelect={() => onVMContextAction(vm.name, 'settings')}>
|
||||
<Settings size={14} /> {tr('settingsEllipsis')}
|
||||
<Ctx.Item className="menu-item rg-p-menu-item" disabled={suspended || transitioning} onSelect={() => onVMContextAction(vmRefKey(vm), 'settings')}>
|
||||
<HostIcon name="settings"><Settings size={14} /></HostIcon> {tr('settingsEllipsis')}
|
||||
</Ctx.Item>
|
||||
<Ctx.Item className="menu-item" onSelect={() => onVMContextAction(vm.name, 'openSharedFolder')}>
|
||||
<FolderOpen size={14} /> {tr('openSharedFolder')}
|
||||
<Ctx.Item className="menu-item rg-p-menu-item" onSelect={() => onVMContextAction(vmRefKey(vm), 'openSharedFolder')}>
|
||||
<HostIcon name="folder"><FolderOpen size={14} /></HostIcon> {tr('openSharedFolder')}
|
||||
</Ctx.Item>
|
||||
{stopped && (
|
||||
<Ctx.Item className="menu-item" onSelect={() => onVMContextAction(vm.name, 'cloneVM')}>
|
||||
<CopyPlus size={14} /> {tr('cloneVM')}
|
||||
<Ctx.Item className="menu-item rg-p-menu-item" disabled={vmBusy} onSelect={() => onVMContextAction(vmRefKey(vm), 'cloneVM')}>
|
||||
<HostIcon name="clone"><CopyPlus size={14} /></HostIcon> {tr('cloneVM')}
|
||||
</Ctx.Item>
|
||||
)}
|
||||
<Ctx.Item className="menu-item" onSelect={() => onVMContextAction(vm.name, 'openFolder')}>
|
||||
<FolderOpen size={14} /> {tr('openFolder')}
|
||||
<Ctx.Item className="menu-item rg-p-menu-item" onSelect={() => onVMContextAction(vmRefKey(vm), 'openFolder')}>
|
||||
<HostIcon name="folder"><FolderOpen size={14} /></HostIcon> {tr('openFolder')}
|
||||
</Ctx.Item>
|
||||
<Ctx.Separator className="menu-sep" />
|
||||
<Ctx.Item className="menu-item danger" disabled={running || transitioning} onSelect={() => onVMContextAction(vm.name, 'delete')}>
|
||||
<Trash size={14} /> {tr('delete')}
|
||||
<Ctx.Item className="menu-item rg-p-menu-item danger" disabled={vmBusy || running || suspended || transitioning} onSelect={() => onVMContextAction(vmRefKey(vm), 'delete')}>
|
||||
<HostIcon name="delete"><Trash size={14} /></HostIcon> {tr('delete')}
|
||||
</Ctx.Item>
|
||||
</Ctx.Content>
|
||||
</Ctx.Portal>
|
||||
@@ -182,19 +238,19 @@ export const Sidebar: React.FC<Props> = ({
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
<div className="nav-group nav-system" role="group" aria-label={tr('sidebarSystem')}>
|
||||
<div className="nav-group rg-p-nav-group nav-system" role="group" aria-label={tr('sidebarSystem')}>
|
||||
{navBtn(
|
||||
INSTALLERS_ID,
|
||||
tr('sidebarInstallers'),
|
||||
<Download size={13} />,
|
||||
'nav-icon-installers',
|
||||
downloading ? tr('state_starting') : '',
|
||||
downloading ? tr('installersDownloading') : '',
|
||||
downloading ? 'busy' : null,
|
||||
)}
|
||||
{navBtn(
|
||||
PLUGINS_ID,
|
||||
tr('sidebarPlugins'),
|
||||
<Puzzle size={13} />,
|
||||
<HostIcon name="plugin"><Puzzle size={13} /></HostIcon>,
|
||||
'nav-icon-plugins',
|
||||
safeMode ? tr('pluginSafeModeShort') : '',
|
||||
safeMode ? 'warn' : null,
|
||||
@@ -210,7 +266,7 @@ export const Sidebar: React.FC<Props> = ({
|
||||
{navBtn(
|
||||
SETTINGS_ID,
|
||||
tr('sidebarSettings'),
|
||||
<Settings size={13} />,
|
||||
<HostIcon name="settings"><Settings size={13} /></HostIcon>,
|
||||
'nav-icon-settings',
|
||||
'',
|
||||
null,
|
||||
@@ -218,7 +274,7 @@ export const Sidebar: React.FC<Props> = ({
|
||||
{navBtn(
|
||||
ABOUT_ID,
|
||||
tr('settingsAbout'),
|
||||
<Info size={13} />,
|
||||
<HostIcon name="info"><Info size={13} /></HostIcon>,
|
||||
'nav-icon-about',
|
||||
'',
|
||||
null,
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import * as Menu from '@radix-ui/react-dropdown-menu'
|
||||
import { Check, PanelLeft } from 'lucide-react'
|
||||
import React, { useState } from 'react'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import React, { useRef, useState } from 'react'
|
||||
import { I18nKey, localeDir, t } from '../i18n'
|
||||
import { useVMStats } from '../lib/vmStats'
|
||||
import { Locale } from '../types'
|
||||
import { Tip } from '../ui/controls'
|
||||
import type { ThemeMode } from './AppSettingsPage'
|
||||
@@ -10,6 +11,11 @@ import { VMAction } from './VMPage'
|
||||
|
||||
export const REPO_URL = 'https://github.com/Nwflower/Reims-Go'
|
||||
|
||||
const MENU_IDS = ['vm', 'view', 'help'] as const
|
||||
type MenuId = (typeof MENU_IDS)[number]
|
||||
|
||||
const HOVER_CLICK_GUARD_MS = 300
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
sidebarOpen: boolean
|
||||
@@ -21,7 +27,7 @@ interface Props {
|
||||
canDark?: boolean
|
||||
onThemeMode: (mode: ThemeMode) => void
|
||||
/** The selected VM and its current state, or null on the system pages. */
|
||||
vm: { name: string; state: string; busy: boolean } | null
|
||||
vm: { name: string; driver_id?: string; state: string; busy: boolean; graphics?: string; canSuspend: boolean } | null
|
||||
onNewVM: () => void
|
||||
onVMAction: (action: VMAction) => void
|
||||
onVMSettings: () => void
|
||||
@@ -42,21 +48,39 @@ export const TitleMenus: React.FC<Props> = ({
|
||||
vm, onNewVM, onVMAction, onVMSettings, onVMDelete, onNavigate, onOpenURL, appVersion,
|
||||
}) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const [open, setOpen] = useState<string | null>(null)
|
||||
const [menuState, setMenuState] = useState<{ id: MenuId | null; switched: boolean }>({ id: null, switched: false })
|
||||
const openRef = useRef<MenuId | null>(null)
|
||||
const navRef = useRef<HTMLElement>(null)
|
||||
const hoverOpenedRef = useRef<{ id: MenuId; at: number } | null>(null)
|
||||
const openedByPointerRef = useRef(false)
|
||||
const pointerClosedRef = useRef(false)
|
||||
|
||||
const setActiveMenu = (next: MenuId | null, switched: boolean) => {
|
||||
openRef.current = next
|
||||
setMenuState({ id: next, switched })
|
||||
}
|
||||
|
||||
const running = vm?.state === 'running'
|
||||
const stopped = vm?.state === 'stopped'
|
||||
const transitioning = vm?.state === 'starting' || vm?.state === 'stopping'
|
||||
const suspended = vm?.state === 'suspended'
|
||||
const transitioning = vm?.state === 'starting' || vm?.state === 'stopping' || vm?.state === 'suspending' || vm?.state === 'resuming'
|
||||
const vmBusy = !vm || vm.busy
|
||||
const canFullscreen = running && vm?.graphics !== 'vmware-svga'
|
||||
const stats = useVMStats(vm?.driver_id ?? '', canFullscreen && vm ? vm.name : null, running)
|
||||
const fullscreenLabel = !canFullscreen || !stats?.running
|
||||
? tr('toggleFullscreen')
|
||||
: stats.window_fullscreen
|
||||
? tr('exitFullscreen')
|
||||
: tr('enterFullscreen')
|
||||
|
||||
const item = (label: string, onSelect: () => void, opts: { shortcut?: string; disabled?: boolean; danger?: boolean } = {}) => (
|
||||
<Menu.Item className={`menu-item${opts.danger ? ' danger' : ''}`} disabled={opts.disabled} onSelect={onSelect}>
|
||||
<Menu.Item className={`menu-item rg-p-menu-item${opts.danger ? ' danger' : ''}`} disabled={opts.disabled} onSelect={onSelect}>
|
||||
<span className="menu-label">{label}</span>
|
||||
{opts.shortcut && <kbd className="menu-shortcut">{opts.shortcut}</kbd>}
|
||||
</Menu.Item>
|
||||
)
|
||||
const check = (label: string, checked: boolean, onSelect: () => void, shortcut?: string) => (
|
||||
<Menu.CheckboxItem className="menu-item menu-item-check" checked={checked} onSelect={onSelect}>
|
||||
<Menu.CheckboxItem className="menu-item rg-p-menu-item menu-item-check" checked={checked} onSelect={onSelect}>
|
||||
<Menu.ItemIndicator className="menu-check"><Check size={13} /></Menu.ItemIndicator>
|
||||
<span className="menu-label">{label}</span>
|
||||
{shortcut && <kbd className="menu-shortcut">{shortcut}</kbd>}
|
||||
@@ -64,19 +88,114 @@ export const TitleMenus: React.FC<Props> = ({
|
||||
)
|
||||
|
||||
// `indented`: the menu has check marks, so every row shares their indent.
|
||||
const menu = (id: string, label: string, content: React.ReactNode, indented = false) => (
|
||||
<Menu.Root modal={false} open={open === id} onOpenChange={(o) => setOpen(o ? id : null)}>
|
||||
const menu = (id: MenuId, label: string, content: React.ReactNode, indented = false) => (
|
||||
<Menu.Root
|
||||
dir={localeDir(locale)}
|
||||
modal={false}
|
||||
open={menuState.id === id}
|
||||
onOpenChange={(o) => {
|
||||
if (o) {
|
||||
hoverOpenedRef.current = null
|
||||
pointerClosedRef.current = false
|
||||
setActiveMenu(id, openRef.current !== null && openRef.current !== id)
|
||||
} else if (openRef.current === id) {
|
||||
hoverOpenedRef.current = null
|
||||
setActiveMenu(null, false)
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Menu.Trigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
className="titlebar-menu"
|
||||
onPointerEnter={() => { if (open && open !== id) setOpen(id) }}
|
||||
onPointerEnter={(e) => {
|
||||
if (e.pointerType !== 'mouse') return
|
||||
if (openRef.current && openRef.current !== id) {
|
||||
openedByPointerRef.current = true
|
||||
pointerClosedRef.current = false
|
||||
hoverOpenedRef.current = { id, at: performance.now() }
|
||||
setActiveMenu(id, true)
|
||||
}
|
||||
}}
|
||||
onPointerDown={(e) => {
|
||||
if (e.button === 0 && !e.ctrlKey) {
|
||||
openedByPointerRef.current = true
|
||||
}
|
||||
const h = hoverOpenedRef.current
|
||||
if (
|
||||
e.pointerType === 'mouse'
|
||||
&& e.button === 0
|
||||
&& !e.ctrlKey
|
||||
&& openRef.current === id
|
||||
&& h
|
||||
&& h.id === id
|
||||
&& performance.now() - h.at < HOVER_CLICK_GUARD_MS
|
||||
) {
|
||||
hoverOpenedRef.current = null
|
||||
e.preventDefault()
|
||||
}
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowDown') {
|
||||
openedByPointerRef.current = false
|
||||
}
|
||||
}}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
</Menu.Trigger>
|
||||
<Menu.Portal>
|
||||
<Menu.Content className={`menu titlebar-menu-content${indented ? ' menu-indented' : ''}`} align="start" sideOffset={4} collisionPadding={8}>
|
||||
<Menu.Content
|
||||
className={`menu rg-p-menu titlebar-menu-content${indented ? ' menu-indented' : ''}`}
|
||||
data-menubar-switch={menuState.switched ? 'true' : undefined}
|
||||
align="start"
|
||||
sideOffset={4}
|
||||
collisionPadding={8}
|
||||
onPointerDownCapture={(e) => {
|
||||
if (!(e.target as HTMLElement | null)?.closest('[data-disabled]')) {
|
||||
pointerClosedRef.current = true
|
||||
}
|
||||
}}
|
||||
onKeyDownCapture={() => {
|
||||
pointerClosedRef.current = false
|
||||
}}
|
||||
onPointerDownOutside={(e) => {
|
||||
const orig = e.detail.originalEvent
|
||||
const target = e.target instanceof Element ? e.target : (e.target as Node | null)?.parentElement ?? null
|
||||
const trigger = target?.closest('button.titlebar-menu') ?? null
|
||||
if (orig.button === 0 && !orig.ctrlKey && trigger && navRef.current?.contains(trigger)) {
|
||||
e.preventDefault()
|
||||
return
|
||||
}
|
||||
pointerClosedRef.current = true
|
||||
}}
|
||||
onCloseAutoFocus={(e) => {
|
||||
// Prevent Radix's deferred setTimeout(0) focus restoration from pulling focus
|
||||
// back to the old trigger when switching to a sibling menu (which triggers
|
||||
// onFocusOutside on the newly opened menu), when closed via pointer, or when
|
||||
// an item opens a modal dialog.
|
||||
if (
|
||||
openRef.current !== null
|
||||
|| openedByPointerRef.current
|
||||
|| pointerClosedRef.current
|
||||
|| document.querySelector('[role="dialog"], [role="alertdialog"]')
|
||||
) {
|
||||
e.preventDefault()
|
||||
}
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') return
|
||||
e.preventDefault()
|
||||
const isRTL = navRef.current ? getComputedStyle(navRef.current).direction === 'rtl' : false
|
||||
const delta = (e.key === 'ArrowRight') !== isRTL ? 1 : -1
|
||||
const idx = MENU_IDS.indexOf(id)
|
||||
const nextId = MENU_IDS[(idx + delta + MENU_IDS.length) % MENU_IDS.length]
|
||||
hoverOpenedRef.current = null
|
||||
openedByPointerRef.current = false
|
||||
pointerClosedRef.current = false
|
||||
setActiveMenu(nextId, true)
|
||||
}}
|
||||
>
|
||||
{content}
|
||||
</Menu.Content>
|
||||
</Menu.Portal>
|
||||
@@ -85,7 +204,7 @@ export const TitleMenus: React.FC<Props> = ({
|
||||
|
||||
return (
|
||||
<div className="titlebar-left" onDoubleClick={(e) => e.stopPropagation()}>
|
||||
<Tip label={tr(sidebarOpen ? 'hideSidebar' : 'showSidebar')} shortcut="Ctrl+B">
|
||||
<Tip label={tr(sidebarOpen ? 'hideSidebar' : 'showSidebar')} shortcut="Ctrl+B" disabled={menuState.id !== null}>
|
||||
<button
|
||||
type="button"
|
||||
className="titlebar-icon"
|
||||
@@ -96,23 +215,29 @@ export const TitleMenus: React.FC<Props> = ({
|
||||
<PanelLeft size={16} aria-hidden="true" />
|
||||
</button>
|
||||
</Tip>
|
||||
<nav className="titlebar-menus" aria-label={tr('menuBar')}>
|
||||
<nav ref={navRef} className="titlebar-menus" aria-label={tr('menuBar')}>
|
||||
{menu('vm', tr('menuVM'), (
|
||||
<>
|
||||
{item(tr('newVMEllipsis'), onNewVM, { shortcut: 'Ctrl+N' })}
|
||||
<Menu.Separator className="menu-sep" />
|
||||
{running
|
||||
? item(tr('showWindow'), () => onVMAction('focus'), { shortcut: 'Ctrl+Enter', disabled: vmBusy })
|
||||
: item(tr('start'), () => onVMAction('start'), { shortcut: 'Ctrl+Enter', disabled: vmBusy || !stopped })}
|
||||
: suspended
|
||||
? item(tr('resume'), () => onVMAction('resume'), { shortcut: vm?.canSuspend ? 'Ctrl+Enter' : undefined, disabled: vmBusy || !vm?.canSuspend })
|
||||
: item(tr('start'), () => onVMAction('start'), { shortcut: 'Ctrl+Enter', disabled: vmBusy || !stopped })}
|
||||
{suspended && !vm?.canSuspend && <Menu.Label className="menu-group-label">{tr('resumeUnavailable')}</Menu.Label>}
|
||||
{item(fullscreenLabel, () => onVMAction('fullscreen'), { disabled: vmBusy || !canFullscreen })}
|
||||
{item(tr('suspend'), () => onVMAction('suspend'), { disabled: vmBusy || !running || !vm?.canSuspend })}
|
||||
{item(tr('stop'), () => onVMAction('stop'), { disabled: vmBusy || !running })}
|
||||
{item(tr('restart'), () => onVMAction('restart'), { disabled: vmBusy || !running })}
|
||||
{item(tr('copyScreenshot'), () => onVMAction('screenshot'), { disabled: vmBusy || !running })}
|
||||
<Menu.Separator className="menu-sep" />
|
||||
{item(tr('settingsEllipsis'), onVMSettings, { shortcut: 'Ctrl+,', disabled: !vm })}
|
||||
{item(tr('settingsEllipsis'), onVMSettings, { shortcut: 'Ctrl+,', disabled: !vm || suspended || transitioning })}
|
||||
{item(tr('openFolder'), () => onVMAction('openFolder'), { disabled: !vm })}
|
||||
<Menu.Separator className="menu-sep" />
|
||||
{suspended && item(tr('discardSuspend'), () => onVMAction('discardSuspend'), { danger: true, disabled: vmBusy })}
|
||||
{item(tr('forceStop'), () => onVMAction('forceStop'), { danger: true, disabled: !vm || !(running || transitioning) })}
|
||||
{item(tr('deleteEllipsis'), onVMDelete, { danger: true, disabled: vmBusy || running || transitioning })}
|
||||
{item(tr('deleteEllipsis'), onVMDelete, { danger: true, disabled: vmBusy || running || suspended || transitioning })}
|
||||
</>
|
||||
))}
|
||||
{menu('view', tr('menuView'), (
|
||||
@@ -125,7 +250,7 @@ export const TitleMenus: React.FC<Props> = ({
|
||||
{(['light', 'dark', 'system'] as const).map((m) => (
|
||||
<Menu.RadioItem
|
||||
key={m}
|
||||
className="menu-item menu-item-check"
|
||||
className="menu-item rg-p-menu-item menu-item-check"
|
||||
value={m}
|
||||
disabled={(m === 'light' && !canLight) || (m === 'dark' && !canDark) || (m === 'system' && (!canLight || !canDark))}
|
||||
>
|
||||
|
||||
+340
-109
@@ -7,6 +7,7 @@ import {
|
||||
Archive,
|
||||
Camera,
|
||||
Check,
|
||||
ChevronDown,
|
||||
ChevronRight,
|
||||
Code2,
|
||||
Copy,
|
||||
@@ -22,9 +23,12 @@ import {
|
||||
Info,
|
||||
Keyboard,
|
||||
LifeBuoy,
|
||||
Maximize2,
|
||||
MemoryStick,
|
||||
Minimize2,
|
||||
Monitor,
|
||||
Network,
|
||||
Pause,
|
||||
Pencil,
|
||||
Play,
|
||||
Plus,
|
||||
@@ -38,25 +42,30 @@ import {
|
||||
Upload,
|
||||
UserRound,
|
||||
} from 'lucide-react'
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
import { I18nKey, locText, t } from '../i18n'
|
||||
import React, { useEffect, useId, useRef, useState } from 'react'
|
||||
import { I18nKey, localeDir, locText, t } from '../i18n'
|
||||
import {
|
||||
controllerLabel, formatBytes, formatDiskUsage, formatMemory, formatUptime, graphicsLabel, guestLangLabel,
|
||||
parseMemoryGB, pendingChangeText, splitLangLabel, sshCommand,
|
||||
controllerLabel, formatBytes, formatDiskUsage, formatMemory, formatUptime, graphicsLabel,
|
||||
parseMemoryGB, pendingChangeText, resolveGuestLang, sshCommand,
|
||||
} from '../lib/format'
|
||||
import { useVMStats } from '../lib/vmStats'
|
||||
import { DiskSnapshot, HostReport, Locale, PendingChange, PluginUIContributions, VMDetail, VMThumbnail } from '../types'
|
||||
import { api } from '../wails'
|
||||
import { Button, IconButton, StatusShape, Tip, statusKind } from '../ui/controls'
|
||||
import { Switch } from '../ui/settings'
|
||||
import { VersionArt } from './VersionArt'
|
||||
import { HostIcon } from '../ui/themeVisuals'
|
||||
import { VersionArt } from '../macos/VersionArt'
|
||||
|
||||
export type VMAction =
|
||||
| 'start'
|
||||
| 'suspend'
|
||||
| 'resume'
|
||||
| 'discardSuspend'
|
||||
| 'stop'
|
||||
| 'forceStop'
|
||||
| 'restart'
|
||||
| 'focus'
|
||||
| 'fullscreen'
|
||||
| 'screenshot'
|
||||
| 'eject'
|
||||
| 'finishInstall'
|
||||
@@ -83,12 +92,15 @@ interface Props {
|
||||
locale: Locale
|
||||
/** The VM's identifier (folder, CLI, reims-ctl). */
|
||||
name: string
|
||||
driverID: string
|
||||
/** What the user calls it (its note); empty shows `name`. */
|
||||
displayName: string
|
||||
onDisplayNameSaved: (displayName: string) => void
|
||||
/** macOS major version (26, 15, …) for the artwork shown before a first frame; null if unknown. */
|
||||
macosMajor: number | null
|
||||
state: string
|
||||
/** Whether the active runtime supports VM suspend/resume. */
|
||||
canSuspend: boolean
|
||||
/** Whether the native VM-window installation guide is currently active for this boot. */
|
||||
guideActive: boolean
|
||||
/** Whether the builtin.install-guide plugin is enabled. */
|
||||
@@ -117,6 +129,40 @@ type Tone = '' | ' warn' | ' high'
|
||||
const meterTone = (pct: number, warn = 75, high = 90): Tone => (pct >= high ? ' high' : pct >= warn ? ' warn' : '')
|
||||
const clampPct = (v: number) => Math.min(100, Math.max(0, v))
|
||||
|
||||
function ShutdownButton({ locale, busyAction, onAction }: Pick<Props, 'locale' | 'busyAction' | 'onAction'>) {
|
||||
const [mode, setMode] = useState<'stop' | 'forceStop'>('stop')
|
||||
const forced = mode === 'forceStop'
|
||||
const variant = forced ? 'danger' : 'secondary'
|
||||
const label = t(locale, 'shutdownMode')
|
||||
const Icon = forced ? Power : Square
|
||||
|
||||
return (
|
||||
<div className="shutdown-button" role="group" aria-label={label}>
|
||||
<Button variant={variant} icon={<Icon size={13} aria-hidden="true" />} busy={busyAction === mode}
|
||||
disabled={!!busyAction} onClick={() => onAction(mode)}>{t(locale, mode)}</Button>
|
||||
<Menu.Root dir={localeDir(locale)}>
|
||||
<Menu.Trigger asChild>
|
||||
<Button variant={variant} disabled={!!busyAction} aria-label={label} title={label}>
|
||||
<ChevronDown size={13} aria-hidden="true" />
|
||||
</Button>
|
||||
</Menu.Trigger>
|
||||
<Menu.Portal>
|
||||
<Menu.Content className="menu rg-p-menu" align="end" sideOffset={4} collisionPadding={8}>
|
||||
<Menu.RadioGroup value={mode} onValueChange={(v) => setMode(v === 'forceStop' ? 'forceStop' : 'stop')}>
|
||||
{(['stop', 'forceStop'] as const).map((action) => (
|
||||
<Menu.RadioItem key={action} value={action} className={`menu-item rg-p-menu-item menu-item-check${action === 'forceStop' ? ' danger' : ''}`}>
|
||||
<Menu.ItemIndicator className="menu-check"><Check size={13} /></Menu.ItemIndicator>
|
||||
{t(locale, action)}
|
||||
</Menu.RadioItem>
|
||||
))}
|
||||
</Menu.RadioGroup>
|
||||
</Menu.Content>
|
||||
</Menu.Portal>
|
||||
</Menu.Root>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
interface Spec {
|
||||
key: string
|
||||
/** Shown only in the wide, single-column layout. */
|
||||
@@ -129,43 +175,54 @@ interface Spec {
|
||||
}
|
||||
|
||||
export const VMPage: React.FC<Props> = ({
|
||||
locale, name, displayName, onDisplayNameSaved, macosMajor, state, guideActive, installGuideEnabled, detail, host, pending, busyAction, onAction, onSettings, onOpenAffinity, onDelete, onViewLogs, onCopy, onTypeText, onTogglePreventSleep, onDeliverFile, onToast, onError, dropping, pluginUI,
|
||||
locale, name, driverID, displayName, onDisplayNameSaved, macosMajor, state, canSuspend, guideActive, installGuideEnabled, detail, host, pending, busyAction, onAction, onSettings, onOpenAffinity, onDelete, onViewLogs, onCopy, onTypeText, onTogglePreventSleep, onDeliverFile, onToast, onError, dropping, pluginUI,
|
||||
}) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const busy = busyAction !== undefined
|
||||
const running = state === 'running'
|
||||
const suspended = state === 'suspended'
|
||||
const guestToolsLocked = suspended || state === 'suspending' || state === 'resuming'
|
||||
const resumeHintId = useId()
|
||||
const guestToolsHintId = useId()
|
||||
const installing = !!detail && (detail.has_installer || detail.recovery_mode)
|
||||
const transitioning = state === 'starting' || state === 'stopping'
|
||||
const transitioning = state === 'starting' || state === 'stopping' || state === 'suspending' || state === 'resuming'
|
||||
// Polled here rather than in App so each tick re-renders only this page.
|
||||
const stats = useVMStats(name, running)
|
||||
const stats = useVMStats(driverID, name, running)
|
||||
|
||||
// Screen thumbnail (thumbnail_flow.go): a fresh frame every 15 s while the VM
|
||||
// runs, otherwise the last frame saved. Skipped while this window is hidden;
|
||||
// the backend also skips it while the VM's own window is in front.
|
||||
const [thumb, setThumb] = useState<VMThumbnail | null>(null)
|
||||
useEffect(() => { setThumb(null) }, [name])
|
||||
useEffect(() => { setThumb(null) }, [driverID, name])
|
||||
useEffect(() => {
|
||||
let live = true
|
||||
const pull = () => {
|
||||
if (document.hidden) return
|
||||
api.GetVMThumbnail(name).then((t) => { if (live && t?.data_url) setThumb(t) }).catch(() => {})
|
||||
api.GetVMThumbnailWithDriver(driverID, name)
|
||||
.then((t) => { if (live && t?.data_url) setThumb(t) })
|
||||
.catch((e) => console.warn('[vm] GetVMThumbnailWithDriver failed:', e))
|
||||
}
|
||||
pull()
|
||||
const timer = running ? window.setInterval(pull, 15000) : undefined
|
||||
return () => { live = false; if (timer) window.clearInterval(timer) }
|
||||
}, [name, running])
|
||||
}, [driverID, name, running])
|
||||
|
||||
// Display name, stored as the VM's note (.reims-go-note). Clicking the title
|
||||
// edits it in place; clearing it (or typing the name) falls back to the name.
|
||||
const shownName = displayName || name
|
||||
const [editingName, setEditingName] = useState(false)
|
||||
const [nameDraft, setNameDraft] = useState('')
|
||||
useEffect(() => { setEditingName(false) }, [name])
|
||||
const startRename = () => { setNameDraft(shownName); setEditingName(true) }
|
||||
// From the More menu: keep the menu from pulling focus back to its button,
|
||||
// which would blur (and so save) the name field the moment it appears.
|
||||
// which would blur (and so save) the name field or pop the trigger's tooltip.
|
||||
const renameFromMenu = useRef(false)
|
||||
const nameInputRef = useRef<HTMLInputElement>(null)
|
||||
const [moreMenuOpen, setMoreMenuOpen] = useState(false)
|
||||
const moreOpenedByPointer = useRef(false)
|
||||
const morePointerClosed = useRef(false)
|
||||
const [sshMenuOpen, setSshMenuOpen] = useState(false)
|
||||
const sshOpenedByPointer = useRef(false)
|
||||
const sshPointerClosed = useRef(false)
|
||||
const saveName = async () => {
|
||||
setEditingName(false)
|
||||
let next = nameDraft.trim()
|
||||
@@ -183,28 +240,34 @@ export const VMPage: React.FC<Props> = ({
|
||||
const [sshUser, setSshUser] = useState('')
|
||||
const [sshUserDialog, setSshUserDialog] = useState(false)
|
||||
const [sshUserDraft, setSshUserDraft] = useState('')
|
||||
useEffect(() => {
|
||||
setEditingName(false)
|
||||
setMoreMenuOpen(false)
|
||||
setSshMenuOpen(false)
|
||||
setSshUserDialog(false)
|
||||
}, [driverID, name])
|
||||
useEffect(() => {
|
||||
let live = true
|
||||
api.GetVMSSHUser(name).then((u) => { if (live) setSshUser(u ?? '') }).catch(() => { if (live) setSshUser('') })
|
||||
api.GetVMSSHUserWithDriver(driverID, name).then((u) => { if (live) setSshUser(u ?? '') }).catch(() => { if (live) setSshUser('') })
|
||||
return () => { live = false }
|
||||
}, [name])
|
||||
}, [driverID, name])
|
||||
|
||||
const openSSHTerminal = () => {
|
||||
api.OpenSSHTerminal(name, sshUser).catch((e) => onError(tr('failSSH'), e))
|
||||
api.OpenSSHTerminalWithDriver(driverID, name, sshUser).catch((e) => onError(tr('failSSH'), e))
|
||||
}
|
||||
const writeSSHConfig = () => {
|
||||
api.WriteSSHConfig(name, sshUser)
|
||||
api.WriteSSHConfigWithDriver(driverID, name, sshUser)
|
||||
.then((alias) => onToast(tr('toastSSHConfigWritten', { alias })))
|
||||
.catch((e) => onError(tr('failSSH'), e))
|
||||
}
|
||||
const openVSCodeSSH = () => {
|
||||
api.OpenVSCodeSSH(name, sshUser).catch((e) => onError(tr('failSSH'), e))
|
||||
api.OpenVSCodeSSHWithDriver(driverID, name, sshUser).catch((e) => onError(tr('failSSH'), e))
|
||||
}
|
||||
const saveSSHUser = async () => {
|
||||
const next = sshUserDraft.trim()
|
||||
setSshUserDialog(false)
|
||||
try {
|
||||
await api.SetVMSSHUser(name, next)
|
||||
await api.SetVMSSHUserWithDriver(driverID, name, next)
|
||||
setSshUser(next)
|
||||
onToast(tr('toastSSHUserSaved'))
|
||||
} catch (e) {
|
||||
@@ -226,7 +289,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
const toggleGuideStep = (step: number) => {
|
||||
setDoneSteps((prev) => {
|
||||
const next = prev.includes(step) ? prev.filter((x) => x !== step) : [...prev, step]
|
||||
try { localStorage.setItem(guideKey, JSON.stringify(next)) } catch {}
|
||||
try { localStorage.setItem(guideKey, JSON.stringify(next)) } catch (e) { console.warn('[vm] persist guide progress failed:', e) }
|
||||
return next
|
||||
})
|
||||
}
|
||||
@@ -242,7 +305,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
|
||||
const loadSnapshots = () => {
|
||||
if (!showSnapshots) { setSnapshots([]); return }
|
||||
api.ListSnapshots(name).then((list) => setSnapshots(list ?? [])).catch(() => setSnapshots([]))
|
||||
api.ListSnapshotsWithDriver(driverID, name).then((list) => setSnapshots(list ?? [])).catch(() => setSnapshots([]))
|
||||
}
|
||||
useEffect(() => {
|
||||
setCreatingSnap(false)
|
||||
@@ -250,14 +313,14 @@ export const VMPage: React.FC<Props> = ({
|
||||
setRestoreTarget(null)
|
||||
loadSnapshots()
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [name, showSnapshots, state])
|
||||
}, [driverID, name, showSnapshots, state])
|
||||
|
||||
const handleCreateSnapshot = async () => {
|
||||
const label = snapDraft.trim()
|
||||
if (!label) return
|
||||
setSnapBusy('create')
|
||||
try {
|
||||
await api.CreateSnapshot(name, label)
|
||||
await api.CreateSnapshotWithDriver(driverID, name, label)
|
||||
setSnapDraft('')
|
||||
setCreatingSnap(false)
|
||||
onToast(tr('toastSnapshotCreated', { name: label }))
|
||||
@@ -272,7 +335,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
setRestoreTarget(null)
|
||||
setSnapBusy(`restore:${snapName}`)
|
||||
try {
|
||||
await api.RestoreSnapshot(name, snapName)
|
||||
await api.RestoreSnapshotWithDriver(driverID, name, snapName)
|
||||
onToast(tr('toastSnapshotRestored', { name: snapName }))
|
||||
loadSnapshots()
|
||||
} catch (e) {
|
||||
@@ -284,7 +347,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
const handleDeleteSnapshot = async (snapName: string) => {
|
||||
setSnapBusy(`delete:${snapName}`)
|
||||
try {
|
||||
await api.DeleteSnapshot(name, snapName)
|
||||
await api.DeleteSnapshotWithDriver(driverID, name, snapName)
|
||||
onToast(tr('toastSnapshotDeleted', { name: snapName }))
|
||||
loadSnapshots()
|
||||
} catch (e) {
|
||||
@@ -296,14 +359,15 @@ export const VMPage: React.FC<Props> = ({
|
||||
const formatSnapTime = (sec: number) => {
|
||||
if (!sec) return ''
|
||||
try {
|
||||
return new Intl.DateTimeFormat(locale, { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' }).format(new Date(sec * 1000))
|
||||
const loc = locale === 'en-XA' ? 'en-US' : locale
|
||||
return new Intl.DateTimeFormat(loc, { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' }).format(new Date(sec * 1000))
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
// One primary action per state (docs/design-guidelines.md §4): Start while
|
||||
// stopped, Show Window while running. Ctrl+Enter triggers it (App.tsx).
|
||||
// stopped, Resume while suspended, Show Window while running. Ctrl+Enter triggers it (App.tsx).
|
||||
let primary: React.ReactNode = null
|
||||
let secondary: React.ReactNode = null
|
||||
if (state === 'stopped') {
|
||||
@@ -314,10 +378,29 @@ export const VMPage: React.FC<Props> = ({
|
||||
</Button>
|
||||
</Tip>
|
||||
)
|
||||
} else if (suspended) {
|
||||
primary = (
|
||||
<Tip label={tr('resume')} shortcut={PRIMARY_SHORTCUT} disabled={!canSuspend}>
|
||||
<Button
|
||||
variant={canSuspend ? 'primary' : 'secondary'}
|
||||
icon={<Play size={14} aria-hidden="true" />}
|
||||
busy={busyAction === 'resume'}
|
||||
disabled={busy || !canSuspend}
|
||||
aria-describedby={!canSuspend ? resumeHintId : undefined}
|
||||
onClick={() => onAction('resume')}
|
||||
>
|
||||
{tr('resume')}
|
||||
</Button>
|
||||
</Tip>
|
||||
)
|
||||
} else if (state === 'starting') {
|
||||
primary = <Button variant="primary" busy>{tr('state_starting')}</Button>
|
||||
} else if (state === 'stopping') {
|
||||
primary = <Button busy>{tr('state_stopping')}</Button>
|
||||
} else if (state === 'suspending') {
|
||||
primary = <Button busy>{tr('state_suspending')}</Button>
|
||||
} else if (state === 'resuming') {
|
||||
primary = <Button variant="primary" busy>{tr('state_resuming')}</Button>
|
||||
} else if (running) {
|
||||
const showLabel = tr(guideActive ? 'showInstallGuide' : 'showWindow')
|
||||
primary = (
|
||||
@@ -328,7 +411,14 @@ export const VMPage: React.FC<Props> = ({
|
||||
</Tip>
|
||||
)
|
||||
secondary = (
|
||||
<Button icon={<Square size={12} aria-hidden="true" />} busy={busyAction === 'stop'} disabled={busy} onClick={() => onAction('stop')}>{tr('stop')}</Button>
|
||||
<>
|
||||
{canSuspend && (
|
||||
<Button icon={<Pause size={13} aria-hidden="true" />} busy={busyAction === 'suspend'} disabled={busy} onClick={() => onAction('suspend')}>
|
||||
{tr('suspend')}
|
||||
</Button>
|
||||
)}
|
||||
<ShutdownButton key={name} locale={locale} busyAction={busyAction} onAction={onAction} />
|
||||
</>
|
||||
)
|
||||
} else if (state === 'broken') {
|
||||
primary = <Button variant="primary" icon={<Terminal size={14} aria-hidden="true" />} onClick={onViewLogs}>{tr('viewLogs')}</Button>
|
||||
@@ -336,40 +426,80 @@ export const VMPage: React.FC<Props> = ({
|
||||
|
||||
// "More" menu, grouped by purpose; destructive items last (docs/design-guidelines.md §5.2).
|
||||
const menu = (
|
||||
<Menu.Root>
|
||||
<Tip label={tr('more')}>
|
||||
<Menu.Root
|
||||
dir={localeDir(locale)}
|
||||
open={moreMenuOpen}
|
||||
onOpenChange={(o) => {
|
||||
if (o) morePointerClosed.current = false
|
||||
setMoreMenuOpen(o)
|
||||
}}
|
||||
>
|
||||
<Tip label={tr('more')} disabled={moreMenuOpen}>
|
||||
<Menu.Trigger asChild>
|
||||
<button type="button" className="icon-btn" aria-label={tr('more')}>
|
||||
<button
|
||||
type="button"
|
||||
className="icon-btn rg-p-icon-button"
|
||||
aria-label={tr('more')}
|
||||
onPointerDown={() => { moreOpenedByPointer.current = true }}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowDown') {
|
||||
moreOpenedByPointer.current = false
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Ellipsis size={15} />
|
||||
</button>
|
||||
</Menu.Trigger>
|
||||
</Tip>
|
||||
<Menu.Portal>
|
||||
<Menu.Content
|
||||
className="menu"
|
||||
className="menu rg-p-menu"
|
||||
align="end"
|
||||
sideOffset={4}
|
||||
collisionPadding={8}
|
||||
onPointerDownCapture={(e) => {
|
||||
if (!(e.target as HTMLElement | null)?.closest('[data-disabled]')) {
|
||||
morePointerClosed.current = true
|
||||
}
|
||||
}}
|
||||
onKeyDownCapture={() => { morePointerClosed.current = false }}
|
||||
onPointerDownOutside={() => { morePointerClosed.current = true }}
|
||||
onCloseAutoFocus={(e) => {
|
||||
if (!renameFromMenu.current) return
|
||||
renameFromMenu.current = false
|
||||
e.preventDefault()
|
||||
nameInputRef.current?.focus()
|
||||
if (renameFromMenu.current) {
|
||||
renameFromMenu.current = false
|
||||
e.preventDefault()
|
||||
nameInputRef.current?.focus()
|
||||
return
|
||||
}
|
||||
if (
|
||||
moreOpenedByPointer.current
|
||||
|| morePointerClosed.current
|
||||
|| document.querySelector('[role="dialog"], [role="alertdialog"]')
|
||||
) {
|
||||
e.preventDefault()
|
||||
}
|
||||
}}
|
||||
>
|
||||
{running && (
|
||||
<>
|
||||
<Menu.Item className="menu-item" disabled={busy} onSelect={() => onAction('restart')}>
|
||||
<RotateCw size={14} /> {tr('restart')}
|
||||
{detail?.graphics !== 'vmware-svga' && (
|
||||
<Menu.Item className="menu-item rg-p-menu-item" disabled={busy} onSelect={() => onAction('fullscreen')}>
|
||||
{stats?.window_fullscreen
|
||||
? <><Minimize2 size={14} /> {tr('exitFullscreen')}</>
|
||||
: <><Maximize2 size={14} /> {tr('enterFullscreen')}</>}
|
||||
</Menu.Item>
|
||||
)}
|
||||
<Menu.Item className="menu-item rg-p-menu-item" disabled={busy} onSelect={() => onAction('restart')}>
|
||||
<HostIcon name="restart"><RotateCw size={14} /></HostIcon> {tr('restart')}
|
||||
</Menu.Item>
|
||||
<Menu.Item className="menu-item" disabled={busy} onSelect={() => onAction('sendText')}>
|
||||
<Menu.Item className="menu-item rg-p-menu-item" disabled={busy} onSelect={() => onAction('sendText')}>
|
||||
<Keyboard size={14} /> {tr('sendText')}
|
||||
</Menu.Item>
|
||||
<Menu.Item className="menu-item" disabled={busy} onSelect={() => onAction('type')}>
|
||||
<Menu.Item className="menu-item rg-p-menu-item" disabled={busy} onSelect={() => onAction('type')}>
|
||||
<Keyboard size={14} /> {tr('typeClipboard')}
|
||||
</Menu.Item>
|
||||
<Menu.Item className="menu-item" disabled={busy} onSelect={() => onAction('screenshot')}>
|
||||
<Camera size={14} /> {tr('copyScreenshot')}
|
||||
<Menu.Item className="menu-item rg-p-menu-item" disabled={busy} onSelect={() => onAction('screenshot')}>
|
||||
<HostIcon name="screenshot"><Camera size={14} /></HostIcon> {tr('copyScreenshot')}
|
||||
</Menu.Item>
|
||||
<Menu.Separator className="menu-sep" />
|
||||
</>
|
||||
@@ -377,35 +507,35 @@ export const VMPage: React.FC<Props> = ({
|
||||
{detail && (
|
||||
<>
|
||||
{installing ? (
|
||||
<Menu.Item className="menu-item" disabled={busy || transitioning} onSelect={() => onAction('finishInstall')}>
|
||||
<Menu.Item className="menu-item rg-p-menu-item" disabled={busy || suspended || transitioning} onSelect={() => onAction('finishInstall')}>
|
||||
<LifeBuoy size={14} /> {tr('finishInstall')}
|
||||
</Menu.Item>
|
||||
) : (
|
||||
<>
|
||||
<Menu.Item className="menu-item" disabled={busy || transitioning} onSelect={() => onAction('enterRecovery')}>
|
||||
<Menu.Item className="menu-item rg-p-menu-item" disabled={busy || suspended || transitioning} onSelect={() => onAction('enterRecovery')}>
|
||||
<LifeBuoy size={14} /> {tr('enterRecovery')}
|
||||
</Menu.Item>
|
||||
<Menu.Item className="menu-item" disabled={running || transitioning || busy} onSelect={() => onAction('cloneVM')}>
|
||||
<CopyPlus size={14} /> {tr('cloneVM')}
|
||||
<Menu.Item className="menu-item rg-p-menu-item" disabled={running || suspended || transitioning || busy} onSelect={() => onAction('cloneVM')}>
|
||||
<HostIcon name="clone"><CopyPlus size={14} /></HostIcon> {tr('cloneVM')}
|
||||
</Menu.Item>
|
||||
</>
|
||||
)}
|
||||
<Menu.Item className="menu-item" onSelect={onOpenAffinity}>
|
||||
<Menu.Item className="menu-item rg-p-menu-item" onSelect={onOpenAffinity}>
|
||||
<Cpu size={14} /> {tr('affinityMenu')}
|
||||
</Menu.Item>
|
||||
<Menu.Item className="menu-item" onSelect={() => { renameFromMenu.current = true; startRename() }}>
|
||||
<Menu.Item className="menu-item rg-p-menu-item" onSelect={() => { renameFromMenu.current = true; startRename() }}>
|
||||
<Pencil size={14} /> {tr('displayNameEditEllipsis')}
|
||||
</Menu.Item>
|
||||
<Menu.Separator className="menu-sep" />
|
||||
</>
|
||||
)}
|
||||
<Menu.Item className="menu-item" onSelect={() => onAction('openFolder')}>
|
||||
<FolderOpen size={14} /> {tr('openFolder')}
|
||||
<Menu.Item className="menu-item rg-p-menu-item" onSelect={() => onAction('openFolder')}>
|
||||
<HostIcon name="folder"><FolderOpen size={14} /></HostIcon> {tr('openFolder')}
|
||||
</Menu.Item>
|
||||
<Menu.Item className="menu-item" onSelect={onViewLogs}>
|
||||
<Terminal size={14} /> {tr('viewLogs')}
|
||||
<Menu.Item className="menu-item rg-p-menu-item" onSelect={onViewLogs}>
|
||||
<HostIcon name="logs"><Terminal size={14} /></HostIcon> {tr('viewLogs')}
|
||||
</Menu.Item>
|
||||
<Menu.Item className="menu-item" disabled={busy} onSelect={() => onAction('exportDiagnostics')}>
|
||||
<Menu.Item className="menu-item rg-p-menu-item" disabled={busy} onSelect={() => onAction('exportDiagnostics')}>
|
||||
<Archive size={14} /> {tr('exportDiagnostics')}
|
||||
</Menu.Item>
|
||||
{(pluginUI?.menus ?? [])
|
||||
@@ -413,7 +543,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
.map((m) => (
|
||||
<Menu.Item
|
||||
key={`${m.pluginId}:${m.id}`}
|
||||
className="menu-item"
|
||||
className="menu-item rg-p-menu-item"
|
||||
onSelect={() => {
|
||||
void api.InvokePluginCommand(m.pluginId ?? '', m.command, { vm: name })
|
||||
.then(() => onToast(locText(m.title, locale, m.id)))
|
||||
@@ -424,13 +554,18 @@ export const VMPage: React.FC<Props> = ({
|
||||
</Menu.Item>
|
||||
))}
|
||||
<Menu.Separator className="menu-sep" />
|
||||
{(running || transitioning) && (
|
||||
<Menu.Item className="menu-item danger" disabled={busyAction === 'forceStop'} onSelect={() => onAction('forceStop')}>
|
||||
<Power size={14} /> {tr('forceStop')}
|
||||
{suspended && (
|
||||
<Menu.Item className="menu-item rg-p-menu-item danger" disabled={busy} onSelect={() => onAction('discardSuspend')}>
|
||||
<Power size={14} /> {tr('discardSuspend')}
|
||||
</Menu.Item>
|
||||
)}
|
||||
<Menu.Item className="menu-item danger" disabled={running || transitioning || busy} onSelect={onDelete}>
|
||||
<Trash size={14} /> {tr('delete')}
|
||||
{(running || transitioning) && (
|
||||
<Menu.Item className="menu-item rg-p-menu-item danger" disabled={busyAction === 'forceStop'} onSelect={() => onAction('forceStop')}>
|
||||
<HostIcon name="force-stop"><Power size={14} /></HostIcon> {tr('forceStop')}
|
||||
</Menu.Item>
|
||||
)}
|
||||
<Menu.Item className="menu-item rg-p-menu-item danger" disabled={running || suspended || transitioning || busy} onSelect={onDelete}>
|
||||
<HostIcon name="delete"><Trash size={14} /></HostIcon> {tr('delete')}
|
||||
</Menu.Item>
|
||||
</Menu.Content>
|
||||
</Menu.Portal>
|
||||
@@ -448,7 +583,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
const memPct = memGB > 0 && rss > 0 ? clampPct((rss / (memGB * 1024 ** 3)) * 100) : 0
|
||||
const diskKnown = !!stats && stats.disk_virtual_bytes > 0 && stats.disk_actual_bytes > 0
|
||||
const diskPct = diskKnown ? clampPct((stats!.disk_actual_bytes / stats!.disk_virtual_bytes) * 100) : 0
|
||||
const mem = formatMemory(detail.memory)
|
||||
const mem = formatMemory(detail.memory, locale)
|
||||
|
||||
specs.push(
|
||||
{
|
||||
@@ -458,14 +593,14 @@ export const VMPage: React.FC<Props> = ({
|
||||
},
|
||||
{
|
||||
key: 'mem', label: tr('factMemory'), icon: <MemoryStick size={15} aria-hidden="true" />, value: mem,
|
||||
tip: live && rss > 0 ? tr('specMemLiveTip', { mem, used: formatBytes(rss) }) : tr('specMemTip', { mem }),
|
||||
tip: live && rss > 0 ? tr('specMemLiveTip', { mem, used: formatBytes(rss, locale) }) : tr('specMemTip', { mem }),
|
||||
meter: { pct: memPct, tone: '', idle: !live },
|
||||
},
|
||||
{
|
||||
key: 'disk', label: tr('factDisk'), icon: <HardDrive size={15} aria-hidden="true" />,
|
||||
value: diskKnown ? formatDiskUsage(stats!.disk_actual_bytes, stats!.disk_virtual_bytes) : controllerLabel(detail.disk_controller),
|
||||
value: diskKnown ? formatDiskUsage(stats!.disk_actual_bytes, stats!.disk_virtual_bytes, locale) : controllerLabel(detail.disk_controller),
|
||||
tip: diskKnown
|
||||
? tr('specDiskUsage', { ctl: controllerLabel(detail.disk_controller), used: formatBytes(stats!.disk_actual_bytes), max: formatBytes(stats!.disk_virtual_bytes) })
|
||||
? tr('specDiskUsage', { ctl: controllerLabel(detail.disk_controller), used: formatBytes(stats!.disk_actual_bytes, locale), max: formatBytes(stats!.disk_virtual_bytes, locale) })
|
||||
: tr('specDiskTip', { ctl: controllerLabel(detail.disk_controller) }),
|
||||
meter: { pct: diskPct, tone: meterTone(diskPct, 85, 95), idle: !diskKnown },
|
||||
},
|
||||
@@ -481,7 +616,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
},
|
||||
)
|
||||
if (detail.guest_lang) {
|
||||
const lang = splitLangLabel('', guestLangLabel(locale, detail.guest_lang))
|
||||
const lang = resolveGuestLang(locale, detail.guest_lang)
|
||||
specs.push({
|
||||
key: 'lang', label: tr('specLang'), icon: <Globe size={15} aria-hidden="true" />, value: lang.label,
|
||||
tip: lang.detail
|
||||
@@ -509,13 +644,25 @@ export const VMPage: React.FC<Props> = ({
|
||||
onCopy(rows.join('\n'))
|
||||
}
|
||||
|
||||
const pillClass = running ? ' is-running' : state === 'broken' ? ' is-broken' : transitioning ? ' is-busy' : ''
|
||||
const pillClass = running ? ' is-running' : suspended ? ' is-suspended' : state === 'broken' ? ' is-broken' : transitioning ? ' is-busy' : ''
|
||||
const dropStyle = detail && !installing
|
||||
? ({ '--wails-drop-target': 'drop' } as React.CSSProperties)
|
||||
: undefined
|
||||
|
||||
const formatSuspendTime = (iso?: string) => {
|
||||
if (!iso) return ''
|
||||
const ms = Date.parse(iso)
|
||||
if (!Number.isFinite(ms)) return ''
|
||||
try {
|
||||
const loc = locale === 'en-XA' ? 'en-US' : locale
|
||||
return new Intl.DateTimeFormat(loc, { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' }).format(new Date(ms))
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="page vm-page vm-page-drop rg-p-vm-page" style={dropStyle}>
|
||||
<div className="page vm-page vm-page-drop rg-p-vm-page" data-vm-state={state} data-driver={driverID} style={dropStyle}>
|
||||
{dropping && (
|
||||
<div className="drop-banner" role="status" aria-live="polite">
|
||||
<Upload size={16} aria-hidden="true" />
|
||||
@@ -534,10 +681,10 @@ export const VMPage: React.FC<Props> = ({
|
||||
thumb={thumb}
|
||||
art={<VersionArt shape="screen" className="vm-screen-art" major={macosMajor} name={shownName} />}
|
||||
running={running}
|
||||
startLabel={tr('start')}
|
||||
startLabel={suspended ? tr('resume') : tr('start')}
|
||||
showLabel={tr('showWindow')}
|
||||
shotLabel={tr('copyScreenshot')}
|
||||
onStart={state === 'stopped' && !busy ? () => onAction('start') : undefined}
|
||||
onStart={!busy && (state === 'stopped' || (suspended && canSuspend)) ? () => onAction(suspended ? 'resume' : 'start') : undefined}
|
||||
onShow={running && !busy ? () => onAction('focus') : undefined}
|
||||
onScreenshot={running && !busy ? () => onAction('screenshot') : undefined}
|
||||
/>
|
||||
@@ -574,13 +721,17 @@ export const VMPage: React.FC<Props> = ({
|
||||
<span>{tr(`state_${state}` as I18nKey)}</span>
|
||||
{running && stats && stats.uptime_seconds > 0 && <span className="vm-hero-uptime">· {formatUptime(stats.uptime_seconds, locale)}</span>}
|
||||
</div>
|
||||
<div className="vm-hero-actions">
|
||||
<span className="rg-slot-anchor" data-rg-slot="vm.header.trailing" />
|
||||
<div className="vm-hero-actions rg-p-vm-actions">
|
||||
{primary}
|
||||
{secondary}
|
||||
<Tip label={tr('settings')} shortcut="Ctrl+,">
|
||||
<Button icon={<Settings size={14} aria-hidden="true" />} disabled={!detail} onClick={onSettings}>{tr('settingsEllipsis')}</Button>
|
||||
<Tip label={suspended ? tr('suspendedSettingsHint') : tr('settings')} shortcut={suspended ? undefined : 'Ctrl+,'}>
|
||||
<span>
|
||||
<Button icon={<Settings size={14} aria-hidden="true" />} disabled={!detail || suspended || transitioning} onClick={onSettings}>{tr('settingsEllipsis')}</Button>
|
||||
</span>
|
||||
</Tip>
|
||||
{menu}
|
||||
<span className="rg-slot-anchor" data-rg-slot="vm.toolbar" />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -588,7 +739,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
<div className={`vm-spec-card rg-p-vm-summary${running ? ' is-live' : ''}`} role="list" data-rg-slot="vm.card">
|
||||
{specs.map((s) => (
|
||||
<Tip key={s.key} label={s.tip}>
|
||||
<div className="vm-spec-cell" role="listitem" tabIndex={-1}>
|
||||
<div className="vm-spec-cell" role="listitem" tabIndex={0}>
|
||||
<span className="vm-spec-icon">{s.icon}</span>
|
||||
<span className="vm-spec-label">{s.label}</span>
|
||||
<span className="vm-spec-val">{s.value}</span>
|
||||
@@ -613,6 +764,29 @@ export const VMPage: React.FC<Props> = ({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{suspended && (() => {
|
||||
const suspTime = formatSuspendTime(detail?.suspend_info?.created_at)
|
||||
const suspSize = detail?.suspend_info?.vmstate_size
|
||||
? formatBytes(detail.suspend_info.vmstate_size, locale)
|
||||
: (detail?.memory ? formatMemory(detail.memory, locale) : '—')
|
||||
return (
|
||||
<div className="notice notice-info">
|
||||
<span className="notice-main">
|
||||
<Pause size={15} className="notice-icon" aria-hidden="true" />
|
||||
<span className="notice-text">
|
||||
<span className="notice-title">{tr('suspendedNoticeTitle')}</span>
|
||||
<span className="notice-sub">
|
||||
{suspTime
|
||||
? tr('suspendedNoticeDescWithTime', { time: suspTime, size: suspSize })
|
||||
: tr('suspendedNoticeDesc', { size: suspSize })}
|
||||
</span>
|
||||
{!canSuspend && <span id={resumeHintId} className="notice-sub">{tr('resumeUnavailable')}</span>}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
})()}
|
||||
|
||||
{pending.length > 0 && (
|
||||
<div className="notice notice-info">
|
||||
<span className="notice-main">
|
||||
@@ -639,6 +813,19 @@ export const VMPage: React.FC<Props> = ({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{stats && (stats.disk_backing_depth_warn || (stats.disk_backing_depth ?? 0) >= 2 || stats.disk_backing_broken) && (
|
||||
<div className="notice">
|
||||
<span className="notice-main">
|
||||
<AlertTriangle size={15} className="notice-icon" aria-hidden="true" />
|
||||
<span>
|
||||
{stats.disk_backing_broken
|
||||
? tr('diagBackingChainBroken', { depth: stats.disk_backing_depth ?? 1 })
|
||||
: tr('diagBackingChainWarn', { depth: stats.disk_backing_depth ?? 2 })}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{(host.memory_load_pct ?? 0) >= 85 && (
|
||||
<div className="notice">
|
||||
<span className="notice-main">
|
||||
@@ -670,10 +857,10 @@ export const VMPage: React.FC<Props> = ({
|
||||
: 'guideKindOnline'
|
||||
if (installGuideEnabled) {
|
||||
return (
|
||||
<section className="card" aria-labelledby="guide-title">
|
||||
<section className="card rg-p-card" aria-labelledby="guide-title">
|
||||
<h2 className="card-title" id="guide-title">
|
||||
{tr('guideTitle')}{' '}
|
||||
<span className="badge">{tr(badgeKey)}</span>
|
||||
<span className="badge rg-p-badge">{tr(badgeKey)}</span>
|
||||
</h2>
|
||||
<p className="card-desc">{tr('guideStartHint')}</p>
|
||||
<div className="card-foot">
|
||||
@@ -722,10 +909,10 @@ export const VMPage: React.FC<Props> = ({
|
||||
)
|
||||
}
|
||||
return (
|
||||
<section className="card" aria-labelledby="guide-title">
|
||||
<section className="card rg-p-card" aria-labelledby="guide-title">
|
||||
<h2 className="card-title" id="guide-title">
|
||||
{tr('guideTitle')}{' '}
|
||||
<span className={`badge ${isOffline ? 'badge-ok' : ''}`}>{tr(badgeKey)}</span>
|
||||
<span className={`badge rg-p-badge ${isOffline ? 'badge-ok' : ''}`}>{tr(badgeKey)}</span>
|
||||
</h2>
|
||||
{!hasInstaller ? (
|
||||
<>
|
||||
@@ -786,9 +973,15 @@ export const VMPage: React.FC<Props> = ({
|
||||
const gtConnected = stats?.guest_tools_connected ?? detail.guest_tools_connected ?? false
|
||||
const gtMountMode = stats?.guest_tools_mount_mode || detail.guest_tools_mount_mode || ''
|
||||
const gtSleepActive = stats?.guest_tools_sleep_guard ?? detail.guest_tools_sleep_active ?? false
|
||||
const needsUpgrade = gtConnected && (detail.guest_tools_agent_version ?? 0) > 0 && (detail.guest_tools_agent_version ?? 0) < 3
|
||||
const gtAgentVersion = stats?.guest_tools_agent_version ?? detail.guest_tools_agent_version ?? 0
|
||||
const needsUpgrade = gtConnected && gtAgentVersion > 0 && gtAgentVersion < 10
|
||||
const gtAttachPending = running && pending.some((p) => p.field === 'guest_tools' && p.to === 'attached')
|
||||
// Plugin switched off: show the state and hide controls that would only fail.
|
||||
const gtOff = !!detail.guest_tools_disabled
|
||||
const gtAttached = detail.guest_tools_attached
|
||||
const showToolsAction = !gtOff && (gtAttached || !gtConnected || needsUpgrade)
|
||||
const toolsAction = gtAttached ? 'detachGuestTools' : 'attachGuestTools'
|
||||
const toolsActionLabel = gtAttached ? 'detachGuestTools' : needsUpgrade ? 'gtUpdate' : 'gtInstall'
|
||||
|
||||
// One status word per state; how files are shared goes in the tooltip.
|
||||
let gtTone: 'ok' | 'warn' | 'idle' = 'idle'
|
||||
@@ -807,7 +1000,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
} else {
|
||||
gtStatus = tr('gtStatusNone'); gtTip = tr('gtNotInstalledDesc')
|
||||
}
|
||||
const showInstallCmd = !gtOff && detail.guest_tools_attached && (!gtConnected || needsUpgrade)
|
||||
const showInstallCmd = !gtOff && detail.guest_tools_attached && !gtAttachPending && (!gtConnected || needsUpgrade)
|
||||
const sshText = sshUser ? `ssh -p ${detail.ssh_port} ${sshUser}@127.0.0.1` : sshCommand(detail.ssh_port)
|
||||
|
||||
return (
|
||||
@@ -827,24 +1020,62 @@ export const VMPage: React.FC<Props> = ({
|
||||
<Button icon={<Terminal size={13} aria-hidden="true" />} onClick={openSSHTerminal}>
|
||||
{tr('sshOpenTerminal')}
|
||||
</Button>
|
||||
<Menu.Root>
|
||||
<Tip label={tr('sshMore')}>
|
||||
<Menu.Root
|
||||
dir={localeDir(locale)}
|
||||
open={sshMenuOpen}
|
||||
onOpenChange={(o) => {
|
||||
if (o) sshPointerClosed.current = false
|
||||
setSshMenuOpen(o)
|
||||
}}
|
||||
>
|
||||
<Tip label={tr('sshMore')} disabled={sshMenuOpen}>
|
||||
<Menu.Trigger asChild>
|
||||
<button type="button" className="icon-btn sm" aria-label={tr('sshMore')}>
|
||||
<button
|
||||
type="button"
|
||||
className="icon-btn rg-p-icon-button sm"
|
||||
aria-label={tr('sshMore')}
|
||||
onPointerDown={() => { sshOpenedByPointer.current = true }}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowDown') {
|
||||
sshOpenedByPointer.current = false
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Ellipsis size={14} />
|
||||
</button>
|
||||
</Menu.Trigger>
|
||||
</Tip>
|
||||
<Menu.Portal>
|
||||
<Menu.Content className="menu" align="end" sideOffset={4} collisionPadding={8}>
|
||||
<Menu.Item className="menu-item" onSelect={writeSSHConfig}>
|
||||
<Menu.Content
|
||||
className="menu rg-p-menu"
|
||||
align="end"
|
||||
sideOffset={4}
|
||||
collisionPadding={8}
|
||||
onPointerDownCapture={(e) => {
|
||||
if (!(e.target as HTMLElement | null)?.closest('[data-disabled]')) {
|
||||
sshPointerClosed.current = true
|
||||
}
|
||||
}}
|
||||
onKeyDownCapture={() => { sshPointerClosed.current = false }}
|
||||
onPointerDownOutside={() => { sshPointerClosed.current = true }}
|
||||
onCloseAutoFocus={(e) => {
|
||||
if (
|
||||
sshOpenedByPointer.current
|
||||
|| sshPointerClosed.current
|
||||
|| document.querySelector('[role="dialog"], [role="alertdialog"]')
|
||||
) {
|
||||
e.preventDefault()
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Menu.Item className="menu-item rg-p-menu-item" onSelect={writeSSHConfig}>
|
||||
<FileCode2 size={14} /> {tr('sshWriteConfig')}
|
||||
</Menu.Item>
|
||||
<Menu.Item className="menu-item" onSelect={openVSCodeSSH}>
|
||||
<Menu.Item className="menu-item rg-p-menu-item" onSelect={openVSCodeSSH}>
|
||||
<Code2 size={14} /> {tr('sshOpenVSCode')}
|
||||
</Menu.Item>
|
||||
<Menu.Separator className="menu-sep" />
|
||||
<Menu.Item className="menu-item" onSelect={() => { setSshUserDraft(sshUser); setSshUserDialog(true) }}>
|
||||
<Menu.Item className="menu-item rg-p-menu-item" onSelect={() => { setSshUserDraft(sshUser); setSshUserDialog(true) }}>
|
||||
<UserRound size={14} /> {tr('sshSetUser')}
|
||||
</Menu.Item>
|
||||
</Menu.Content>
|
||||
@@ -864,20 +1095,20 @@ export const VMPage: React.FC<Props> = ({
|
||||
</span>
|
||||
</Tip>
|
||||
</div>
|
||||
{suspended && showToolsAction && (
|
||||
<span id={guestToolsHintId} className="hint">{tr('suspendedGuestToolsHint')}</span>
|
||||
)}
|
||||
<div className="conn-ctrl">
|
||||
{gtOff ? null : detail.guest_tools_attached ? (
|
||||
<Button busy={busyAction === 'detachGuestTools'} disabled={busy} onClick={() => onAction('detachGuestTools')}>
|
||||
{tr('detachGuestTools')}
|
||||
</Button>
|
||||
) : (!gtConnected || needsUpgrade) && (
|
||||
{showToolsAction && (
|
||||
<Button
|
||||
variant={detail.guest_tools_configured ? 'secondary' : 'primary'}
|
||||
icon={<Disc size={13} aria-hidden="true" />}
|
||||
busy={busyAction === 'attachGuestTools'}
|
||||
disabled={busy}
|
||||
onClick={() => onAction('attachGuestTools')}
|
||||
variant={gtAttached || detail.guest_tools_configured || guestToolsLocked ? 'secondary' : 'primary'}
|
||||
icon={gtAttached ? undefined : <Disc size={13} aria-hidden="true" />}
|
||||
busy={busyAction === toolsAction}
|
||||
disabled={busy || guestToolsLocked}
|
||||
aria-describedby={suspended ? guestToolsHintId : undefined}
|
||||
onClick={() => onAction(toolsAction)}
|
||||
>
|
||||
{needsUpgrade ? tr('gtUpdate') : tr('gtInstall')}
|
||||
{tr(toolsActionLabel)}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
@@ -933,16 +1164,16 @@ export const VMPage: React.FC<Props> = ({
|
||||
<section className="section">
|
||||
<div className="section-title">
|
||||
<span className="hstack">
|
||||
<History size={14} aria-hidden="true" />
|
||||
<HostIcon name="snapshot"><History size={14} aria-hidden="true" /></HostIcon>
|
||||
<span>{tr('snapshotsTitle')}</span>
|
||||
<span className="snap-meta-hint">· {tr('snapshotHint')}</span>
|
||||
</span>
|
||||
<Tip label={running || transitioning ? tr('snapshotStopFirst') : tr('snapshotCreate')}>
|
||||
<Tip label={running || suspended || transitioning ? tr('snapshotStopFirst') : tr('snapshotCreate')}>
|
||||
<span>
|
||||
<Button
|
||||
variant="ghost"
|
||||
icon={<Plus size={13} aria-hidden="true" />}
|
||||
disabled={running || transitioning || !!snapBusy}
|
||||
disabled={running || suspended || transitioning || !!snapBusy}
|
||||
onClick={() => setCreatingSnap((v) => !v)}
|
||||
>
|
||||
{tr('snapshotCreate')}
|
||||
@@ -954,7 +1185,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
{creatingSnap && (
|
||||
<div className="snap-create-bar">
|
||||
<input
|
||||
className="input"
|
||||
className="input rg-p-input"
|
||||
value={snapDraft}
|
||||
maxLength={64}
|
||||
spellCheck={false}
|
||||
@@ -988,7 +1219,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
<Button
|
||||
icon={<RotateCcw size={13} aria-hidden="true" />}
|
||||
busy={snapBusy === `restore:${s.name}`}
|
||||
disabled={running || transitioning || !!snapBusy}
|
||||
disabled={running || suspended || transitioning || !!snapBusy}
|
||||
onClick={() => setRestoreTarget(s.name)}
|
||||
>
|
||||
{tr('snapshotRestore')}
|
||||
@@ -998,7 +1229,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
label={tr('snapshotDelete')}
|
||||
icon={<Trash size={14} />}
|
||||
busy={snapBusy === `delete:${s.name}`}
|
||||
disabled={running || transitioning || !!snapBusy}
|
||||
disabled={running || suspended || transitioning || !!snapBusy}
|
||||
onClick={() => void handleDeleteSnapshot(s.name)}
|
||||
/>
|
||||
</div>
|
||||
@@ -1049,13 +1280,13 @@ export const VMPage: React.FC<Props> = ({
|
||||
<Alert.Root open onOpenChange={(open) => { if (!open) setSshUserDialog(false) }}>
|
||||
<Alert.Portal>
|
||||
<Alert.Overlay className="overlay" />
|
||||
<Alert.Content className="dialog sm">
|
||||
<Alert.Content className="dialog rg-p-dialog sm" data-tone="neutral">
|
||||
<div className="dialog-body">
|
||||
<Alert.Title className="dialog-title">{tr('sshUserTitle')}</Alert.Title>
|
||||
<Alert.Description className="dialog-desc">{tr('sshUserDesc')}</Alert.Description>
|
||||
<div className="field field-spaced">
|
||||
<input
|
||||
className="input mono"
|
||||
className="input rg-p-input mono"
|
||||
value={sshUserDraft}
|
||||
spellCheck={false}
|
||||
autoComplete="off"
|
||||
@@ -1067,9 +1298,9 @@ export const VMPage: React.FC<Props> = ({
|
||||
</div>
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
<Alert.Cancel asChild><button type="button" className="btn">{tr('cancel')}</button></Alert.Cancel>
|
||||
<Alert.Cancel asChild><button type="button" className="btn rg-p-button">{tr('cancel')}</button></Alert.Cancel>
|
||||
<Alert.Action asChild>
|
||||
<button type="button" className="btn btn-primary" onClick={() => void saveSSHUser()}>{tr('save')}</button>
|
||||
<button type="button" className="btn rg-p-button btn-primary" onClick={() => void saveSSHUser()}>{tr('save')}</button>
|
||||
</Alert.Action>
|
||||
</div>
|
||||
</Alert.Content>
|
||||
@@ -1081,15 +1312,15 @@ export const VMPage: React.FC<Props> = ({
|
||||
<Alert.Root open onOpenChange={(open) => { if (!open) setRestoreTarget(null) }}>
|
||||
<Alert.Portal>
|
||||
<Alert.Overlay className="overlay" />
|
||||
<Alert.Content className="dialog sm">
|
||||
<Alert.Content className="dialog rg-p-dialog sm" data-tone="danger">
|
||||
<div className="dialog-body">
|
||||
<Alert.Title className="dialog-title">{tr('snapshotRestoreTitle', { name: restoreTarget })}</Alert.Title>
|
||||
<Alert.Description className="dialog-desc">{tr('snapshotRestoreDesc')}</Alert.Description>
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
<Alert.Cancel asChild><button type="button" className="btn">{tr('cancel')}</button></Alert.Cancel>
|
||||
<Alert.Cancel asChild><button type="button" className="btn rg-p-button">{tr('cancel')}</button></Alert.Cancel>
|
||||
<Alert.Action asChild>
|
||||
<button type="button" className="btn btn-danger" onClick={() => void handleRestoreSnapshot(restoreTarget)}>
|
||||
<button type="button" className="btn rg-p-button btn-danger" onClick={() => void handleRestoreSnapshot(restoreTarget)}>
|
||||
{tr('snapshotRestore')}
|
||||
</button>
|
||||
</Alert.Action>
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
import React, { useEffect, useId, useRef } from 'react'
|
||||
|
||||
// Strokes of the Reims-Go wordmark (scripts/brand/wordmark.py), in pen order.
|
||||
// Coordinates sit in the generator's baseline frame (translate 4 107).
|
||||
type Stroke =
|
||||
| { kind: 'path'; d: string; ink: 'ink' | 'dash' | 'brand' }
|
||||
| { kind: 'dot'; cx: number; cy: number; r: number }
|
||||
|
||||
const STROKES: Stroke[] = [
|
||||
{ kind: 'path', ink: 'ink', d: 'M7.5 -7.5V-36A24 28.5 0 0 1 31.5 -64.5' },
|
||||
{ kind: 'path', ink: 'ink', d: 'M50.5 -36H107.5A28.5 28.5 0 1 0 100.18 -16.93' },
|
||||
{ kind: 'path', ink: 'ink', d: 'M133.5 -64.5V-7.5' },
|
||||
{ kind: 'dot', cx: 133.5, cy: -94, r: 9 },
|
||||
{ kind: 'path', ink: 'ink', d: 'M159.5 -7.5V-36A22 28.5 0 0 1 203.5 -36V-7.5M203.5 -36A22 28.5 0 0 1 247.5 -36V-7.5' },
|
||||
{ kind: 'path', ink: 'ink', d: 'M311.05 -59.02A21 14.25 0 0 0 273.5 -50.25A21 14.25 0 0 0 294.5 -36A21 14.25 0 0 1 315.5 -21.75A21 14.25 0 0 1 277.95 -12.98' },
|
||||
{ kind: 'path', ink: 'dash', d: 'M340.5 -36H358.5' },
|
||||
{ kind: 'path', ink: 'brand', d: 'M440.5 -36A28.5 28.5 0 1 1 440.5 -36.01' },
|
||||
{ kind: 'path', ink: 'brand', d: 'M440.5 -64.5V0A28.5 22.5 0 0 1 387.32 11.25' },
|
||||
{ kind: 'path', ink: 'brand', d: 'M523.5 -36A28.5 28.5 0 1 1 523.5 -36.01' },
|
||||
]
|
||||
|
||||
// Pen timing, in ms. Writing speed is constant, so long strokes take longer.
|
||||
const PX_PER_MS = 0.62
|
||||
const LIFT_MS = 70 // pen lift between strokes
|
||||
const DOT_MS = 140
|
||||
const HOLD_MS = 900 // finished word stays on screen
|
||||
const FADE_MS = 420
|
||||
const REST_MS = 260
|
||||
|
||||
const STROKE_EASE = 'cubic-bezier(0.45, 0.05, 0.35, 1)'
|
||||
|
||||
interface Props {
|
||||
/** Rendered width in px; height follows the wordmark's aspect ratio. */
|
||||
width?: number
|
||||
label?: string
|
||||
className?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* The Reims-Go wordmark written stroke by stroke, on a loop. Used while
|
||||
* waiting on network I/O. With reduced motion it shows the finished word
|
||||
* with a slow pulse instead.
|
||||
*/
|
||||
export const WordmarkLoader: React.FC<Props> = ({ width = 168, label, className }) => {
|
||||
const svgRef = useRef<SVGSVGElement>(null)
|
||||
const gid = `wm-${useId().replace(/[^a-zA-Z0-9_-]/g, '')}`
|
||||
|
||||
useEffect(() => {
|
||||
const svg = svgRef.current
|
||||
if (!svg || typeof svg.animate !== 'function') return
|
||||
if (window.matchMedia?.('(prefers-reduced-motion: reduce)').matches) return
|
||||
|
||||
const els = Array.from(svg.querySelectorAll<SVGGeometryElement>('[data-stroke]'))
|
||||
const spans = els.map((el) => {
|
||||
if (el.tagName.toLowerCase() === 'circle') return DOT_MS
|
||||
const len = typeof el.getTotalLength === 'function' ? el.getTotalLength() : 60
|
||||
return Math.max(90, len / PX_PER_MS)
|
||||
})
|
||||
const writeEnd = spans.reduce((sum, s) => sum + s, 0) + LIFT_MS * (spans.length - 1)
|
||||
const total = writeEnd + HOLD_MS + FADE_MS + REST_MS
|
||||
const at = (ms: number) => Math.min(1, ms / total)
|
||||
const holdEnd = at(writeEnd + HOLD_MS)
|
||||
const fadeEnd = at(writeEnd + HOLD_MS + FADE_MS)
|
||||
|
||||
let t = 0
|
||||
const anims = els.map((el, i) => {
|
||||
const s = at(t)
|
||||
const e = at(t + spans[i])
|
||||
t += spans[i] + LIFT_MS
|
||||
const isDot = el.tagName.toLowerCase() === 'circle'
|
||||
// Opacity hides the round cap that a fully-offset dash still paints.
|
||||
const frames: Keyframe[] = isDot
|
||||
? [
|
||||
{ offset: 0, opacity: 0, transform: 'scale(0.2)' },
|
||||
{ offset: s, opacity: 0, transform: 'scale(0.2)', easing: 'cubic-bezier(0.34, 1.56, 0.64, 1)' },
|
||||
{ offset: e, opacity: 1, transform: 'scale(1)' },
|
||||
{ offset: holdEnd, opacity: 1, transform: 'scale(1)' },
|
||||
{ offset: fadeEnd, opacity: 0, transform: 'scale(1)' },
|
||||
{ offset: 1, opacity: 0, transform: 'scale(0.2)' },
|
||||
]
|
||||
: [
|
||||
{ offset: 0, opacity: 0, strokeDashoffset: 1 },
|
||||
{ offset: s, opacity: 0, strokeDashoffset: 1 },
|
||||
{ offset: Math.min(e, s + 0.0005), opacity: 1, strokeDashoffset: 1, easing: STROKE_EASE },
|
||||
{ offset: e, opacity: 1, strokeDashoffset: 0 },
|
||||
{ offset: holdEnd, opacity: 1, strokeDashoffset: 0 },
|
||||
{ offset: fadeEnd, opacity: 0, strokeDashoffset: 0 },
|
||||
{ offset: 1, opacity: 0, strokeDashoffset: 1 },
|
||||
]
|
||||
return el.animate(frames, { duration: total, iterations: Infinity, fill: 'both' })
|
||||
})
|
||||
svg.dataset.animated = 'true'
|
||||
return () => {
|
||||
anims.forEach((a) => a.cancel())
|
||||
delete svg.dataset.animated
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className={`wordmark-loader${className ? ` ${className}` : ''}`} role="status" aria-live="polite">
|
||||
<svg
|
||||
ref={svgRef}
|
||||
className="wordmark-loader-svg"
|
||||
viewBox="0 0 539 141"
|
||||
width={width}
|
||||
height={Math.round((width * 141) / 539)}
|
||||
aria-hidden="true"
|
||||
>
|
||||
<defs>
|
||||
<linearGradient id={gid} gradientUnits="userSpaceOnUse" x1="376" y1="0" x2="531" y2="0">
|
||||
<stop offset="0" stopColor="#3b8cff" />
|
||||
<stop offset="0.5" stopColor="#6d5dfc" />
|
||||
<stop offset="1" stopColor="#ff7a9a" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g transform="translate(4 107)" fill="none" strokeWidth="15" strokeLinecap="round" strokeLinejoin="round">
|
||||
{STROKES.map((s, i) => s.kind === 'dot' ? (
|
||||
<circle
|
||||
key={i}
|
||||
data-stroke=""
|
||||
className="wordmark-loader-dot"
|
||||
cx={s.cx}
|
||||
cy={s.cy}
|
||||
r={s.r}
|
||||
style={{ transformOrigin: 'center', transformBox: 'fill-box' }}
|
||||
/>
|
||||
) : (
|
||||
<path
|
||||
key={i}
|
||||
data-stroke=""
|
||||
className={`wordmark-loader-${s.ink}`}
|
||||
d={s.d}
|
||||
pathLength={1}
|
||||
strokeDasharray="1 1"
|
||||
stroke={s.ink === 'brand' ? `url(#${gid})` : undefined}
|
||||
/>
|
||||
))}
|
||||
</g>
|
||||
</svg>
|
||||
{label && <span className="wordmark-loader-label">{label}</span>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
+349
-1648
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,385 @@
|
||||
// Code generated by cmd/i18ngen; DO NOT EDIT.
|
||||
|
||||
export const coreZh: Record<string, string> = {
|
||||
"affinityMenu": "处理器相关性…",
|
||||
"appearance": "外观",
|
||||
"backToEdit": "返回修改",
|
||||
"borderless": "无边框全屏",
|
||||
"cancel": "取消",
|
||||
"cancelCreate": "取消创建",
|
||||
"cancelQueue": "取消排队",
|
||||
"clear": "清空",
|
||||
"close": "关闭",
|
||||
"closeWindow": "关闭",
|
||||
"collapseLogs": "收起日志",
|
||||
"copy": "复制",
|
||||
"copyTechInfo": "复制技术信息",
|
||||
"dataRootChooseOther": "选择其他数据目录",
|
||||
"dataRootChooseTitle": "选择数据目录",
|
||||
"dataRootReadOnlyDetail": "详细信息",
|
||||
"dataRootReadOnlyFolder": "数据目录",
|
||||
"dataRootReadOnlyTitle": "数据目录暂时无法使用",
|
||||
"dataRootRepair": "修复版本记录",
|
||||
"dataRootRetry": "重试",
|
||||
"delete": "删除…",
|
||||
"deleteEllipsis": "删除…",
|
||||
"displays": "显示器数量",
|
||||
"eject": "弹出安装盘",
|
||||
"emptyVMs": "还没有虚拟机",
|
||||
"errCopyDetails": "复制排障信息",
|
||||
"errRawDetailsToggle": "技术详情",
|
||||
"errorBoundaryReload": "重新加载界面",
|
||||
"errorBoundaryTitle": "界面遇到意外错误",
|
||||
"expandLogs": "展开日志",
|
||||
"failCreate": "{name} 创建失败",
|
||||
"failDownload": "下载失败",
|
||||
"failGeneric": "操作失败",
|
||||
"failRuntime": "运行时安装失败",
|
||||
"failSSH": "SSH 操作失败",
|
||||
"fontMissingFoDHint": "当前 Windows 缺少 {script} 可选字体包,部分原生弹窗字形可能回退;可在「Windows 设置 › 应用 › 可选功能」添加对应补充字体。",
|
||||
"footerDiskLabel": "磁盘",
|
||||
"footerDiskTip": "虚拟机数据目录:{dir}",
|
||||
"footerDiskValue": "可用 {gb} GB",
|
||||
"footerHostIssue": "虚拟化未就绪",
|
||||
"footerHostIssueTip": "打开「内核」页查看需要处理的项",
|
||||
"footerMemLabel": "内存",
|
||||
"footerMemTip": "系统内存:已用 {used} GB / 共 {total} GB(可用 {avail} GB)",
|
||||
"footerMemValue": "{used} / {total} GB",
|
||||
"footerRunningVMs": "{n, plural, other {# 台运行中}}",
|
||||
"forceStop": "硬关机",
|
||||
"gpuErrMissingExt": "缺少必需 Vulkan 扩展({ext}),请更新显卡驱动或改用 VMware SVGA",
|
||||
"gpuErrVulkanCpu": "软件 Vulkan 实现不满足 vGPU 加速要求,请改用 VMware SVGA",
|
||||
"gpuErrVulkanTooOld": "Vulkan {ver} 低于 1.3 最低要求,请更新显卡驱动或改用 VMware SVGA",
|
||||
"gpuWarnAmdLegacy": "AMD Vega/Polaris 在 Windows 闭源驱动下存在上游已知黑屏/设备丢失问题({ref});若有其他独显请改选独显,否则建议暂用 VMware SVGA",
|
||||
"gpuWarnAmdRdna2": "该 AMD 显卡在 Windows 下存在上游已知设备丢失风险({ref});若卡死黑屏请升级驱动或暂用 VMware SVGA",
|
||||
"guestKbdPinyin": "拼音键盘",
|
||||
"guestKbdUS": "美式键盘",
|
||||
"guestKbdUSRecommended": "美式键盘,推荐",
|
||||
"guestLang": "macOS 系统语言",
|
||||
"guestLangEnUS": "English (US)",
|
||||
"guestLangJaJP": "日本語",
|
||||
"guestLangKoKR": "한국어",
|
||||
"guestLangZhHansUS": "简体中文",
|
||||
"guestLangZhHantUS": "繁體中文",
|
||||
"helpAbout": "关于 Reims-Go",
|
||||
"helpCheckUpdate": "检查更新…",
|
||||
"helpProjectPage": "项目主页",
|
||||
"helpReportIssue": "报告问题",
|
||||
"hideSidebar": "隐藏侧边栏",
|
||||
"hidpiTipFullscreen": "窗口里的 macOS 只能 1x,文字会发虚;改用全屏可得到 HiDPI",
|
||||
"hidpiTipScale": "这块屏幕上 macOS 只能 1x,文字会发虚;把 Windows 缩放调到 150% 或以上可得到 HiDPI",
|
||||
"hidpiTipUnavailable": "这块屏幕像素不够,macOS 只能以 1x 显示",
|
||||
"hostDisplayHint": "主屏 {w}×{h},{scale}% 缩放",
|
||||
"hostNeedsAction": "需要处理",
|
||||
"hostReady": "就绪",
|
||||
"importRuntime": "导入运行时包",
|
||||
"installersDownloading": "下载中",
|
||||
"installersQueuedDesc": "等待当前下载完成",
|
||||
"installersRetry": "重试",
|
||||
"jumpLatest": "跳到最新",
|
||||
"localeAuto": "跟随系统",
|
||||
"localeAutoDetail": "当前:{tag}",
|
||||
"logActivity": "活动",
|
||||
"logButton": "日志",
|
||||
"logCopy": "复制日志",
|
||||
"logErrorsOnly": "仅错误/警告",
|
||||
"logQemu": "QEMU",
|
||||
"logSearchPlaceholder": "筛选日志…",
|
||||
"logSerial": "串口",
|
||||
"logsEmpty": "暂无日志",
|
||||
"macos.appsUtilitiesTerminal": "应用程序 › 实用工具 › 终端",
|
||||
"macos.diskUtility": "磁盘工具",
|
||||
"macos.erase": "抹掉",
|
||||
"macos.finder": "访达",
|
||||
"macos.guidPartitionMap": "GUID 分区图",
|
||||
"macos.otherSignInSetUpLater": "其他登录选项 › 稍后设置",
|
||||
"macos.recovery": "恢复",
|
||||
"macos.reinstallMacOS": "重新安装 macOS",
|
||||
"macos.setupAssistant": "设置助理",
|
||||
"macos.showAllDevices": "显示 › 显示所有设备",
|
||||
"macos.utilitiesTerminal": "实用工具 › 终端",
|
||||
"macos.volume": "宗卷",
|
||||
"maximize": "最大化",
|
||||
"menuBar": "菜单栏",
|
||||
"menuHelp": "帮助",
|
||||
"menuVM": "虚拟机",
|
||||
"menuView": "视图",
|
||||
"minimize": "最小化",
|
||||
"more": "更多",
|
||||
"newVM": "新建虚拟机",
|
||||
"newVMEllipsis": "新建虚拟机…",
|
||||
"noRuntimeAlert": "先在「内核」导入运行时包",
|
||||
"off": "关闭",
|
||||
"on": "开启",
|
||||
"openFolder": "打开所在文件夹",
|
||||
"panelLoadFailed": "面板加载失败",
|
||||
"pauseDownload": "暂停下载",
|
||||
"pluginSafeModeShort": "安全模式",
|
||||
"quitFailed": "已取消退出",
|
||||
"quitInProgress": "正在退出…",
|
||||
"refresh": "刷新",
|
||||
"resLooksLike": "看起来像 {w} × {h}",
|
||||
"resizeLogPanel": "拖动调整日志高度",
|
||||
"resolution": "分辨率",
|
||||
"restart": "重启",
|
||||
"safeModeBanner": "安全模式已启用:已跳过全部第三方插件并回退至内置默认主题",
|
||||
"safeModeManagePlugins": "管理插件",
|
||||
"save": "保存",
|
||||
"settings": "设置",
|
||||
"settingsAbout": "关于",
|
||||
"settingsEllipsis": "设置…",
|
||||
"shortcutBarFullscreen": "切换全屏",
|
||||
"shortcutBarRelease": "释放键盘和鼠标",
|
||||
"showSidebar": "显示侧边栏",
|
||||
"shutdownMode": "关机方式",
|
||||
"sidebarHost": "内核",
|
||||
"sidebarInstallers": "镜像",
|
||||
"sidebarItemAria": "{label},{state}",
|
||||
"sidebarLabel": "侧边栏",
|
||||
"sidebarPlugins": "插件",
|
||||
"sidebarSettings": "设置",
|
||||
"sidebarSystem": "系统",
|
||||
"sidebarVMs": "虚拟机",
|
||||
"start": "启动",
|
||||
"starting": "启动中",
|
||||
"stop": "关机",
|
||||
"taskAppUpdate": "下载 Reims-Go {v}",
|
||||
"taskCreate": "创建 {name}",
|
||||
"taskDownload": "下载 macOS {v}",
|
||||
"taskRecoveryDownload": "正在为 {name} 拉取并挂载在线恢复镜像",
|
||||
"taskRuntime": "安装运行时 {v}",
|
||||
"tasksRunning": "{n, plural, other {# 个任务进行中}}",
|
||||
"themeDark": "深色",
|
||||
"themeLight": "浅色",
|
||||
"themeSwitchDark": "切换深色外观",
|
||||
"themeSwitchLight": "切换浅色外观",
|
||||
"themeSystem": "跟随系统",
|
||||
"toastAffinityApplied": "处理器相关性已应用({count} 个逻辑处理器 · {mask})",
|
||||
"toastAffinitySaved": "处理器相关性已保存,下次启动时生效",
|
||||
"toastBorderlessNextStart": "已保存全屏启动偏好,重启虚拟机后生效",
|
||||
"toastBorderlessUpdated": "已保存全屏启动偏好",
|
||||
"toastCopied": "已复制",
|
||||
"toastCreateCanceled": "已取消创建 {name}",
|
||||
"toastCreateCanceledPartial": "已下载部分已保留,可继续下载或返回修改",
|
||||
"toastCreated": "{name} 已创建",
|
||||
"toastDownloadPaused": "已暂停,再次下载会从中断处继续",
|
||||
"toastInstallerReady": "macOS {v} 安装包已就绪",
|
||||
"toastQueueCanceled": "已取消排队",
|
||||
"toastRuntimeReady": "运行时 {v} 已安装",
|
||||
"toastSSHConfigWritten": "已写入 Host {alias}",
|
||||
"toastSSHUserSaved": "已保存 SSH 用户名",
|
||||
"toastSaved": "已保存",
|
||||
"toastSavedNextStart": "已保存,下次启动生效",
|
||||
"updateCancel": "取消下载",
|
||||
"updateCapsuleAvailable": "{v} 可用",
|
||||
"updateCapsuleDownloading": "正在下载更新",
|
||||
"updateCapsuleDownloadingPct": "正在下载 {p}%",
|
||||
"updateCapsuleFailed": "更新下载失败",
|
||||
"updateCapsuleOpen": "查看更新详情",
|
||||
"updateCapsuleReady": "{v} 已就绪",
|
||||
"updateConfirmBody": "{n, plural, other {有 # 台虚拟机正在运行。它们不会被关闭,但 Reims-Go 重启的几秒内,剪贴板、共享文件夹和输入法桥接会暂停,之后自动恢复。}}",
|
||||
"updateConfirmTitle": "重启并安装 {v}",
|
||||
"updateConfirmWin10": "这台 Windows 10 宿主依赖冷重启补偿:这些虚拟机里的 macOS 下次重启后不会自动开机,需要手动启动一次。",
|
||||
"updateDoneToast": "已更新到 {v}",
|
||||
"updateDownload": "下载",
|
||||
"updateFailed": "更新失败",
|
||||
"updateLater": "以后再提醒我",
|
||||
"updateRestart": "重启并安装",
|
||||
"updateRetry": "重试",
|
||||
"uptimeHoursMinutes": "{h} 小时 {m} 分",
|
||||
"uptimeMinutesSeconds": "{m} 分 {s} 秒",
|
||||
"uptimeSeconds": "{s} 秒",
|
||||
"viewLogs": "查看日志",
|
||||
}
|
||||
|
||||
export const coreEn: Record<string, string> = {
|
||||
"affinityMenu": "Processor Affinity…",
|
||||
"appearance": "Appearance",
|
||||
"backToEdit": "Edit and retry",
|
||||
"borderless": "Borderless full screen",
|
||||
"cancel": "Cancel",
|
||||
"cancelCreate": "Cancel creation",
|
||||
"cancelQueue": "Cancel queued download",
|
||||
"clear": "Clear",
|
||||
"close": "Close",
|
||||
"closeWindow": "Close",
|
||||
"collapseLogs": "Hide logs",
|
||||
"copy": "Copy",
|
||||
"copyTechInfo": "Copy technical details",
|
||||
"dataRootChooseOther": "Choose another data folder",
|
||||
"dataRootChooseTitle": "Choose data folder",
|
||||
"dataRootReadOnlyDetail": "Details",
|
||||
"dataRootReadOnlyFolder": "Data folder",
|
||||
"dataRootReadOnlyTitle": "This data folder can’t be used right now",
|
||||
"dataRootRepair": "Repair version record",
|
||||
"dataRootRetry": "Try again",
|
||||
"delete": "Delete…",
|
||||
"deleteEllipsis": "Delete…",
|
||||
"displays": "Displays",
|
||||
"eject": "Eject installer",
|
||||
"emptyVMs": "No virtual machines",
|
||||
"errCopyDetails": "Copy diagnostic details",
|
||||
"errRawDetailsToggle": "Technical details",
|
||||
"errorBoundaryReload": "Reload window",
|
||||
"errorBoundaryTitle": "Something went wrong in the window",
|
||||
"expandLogs": "Show logs",
|
||||
"failCreate": "Couldn’t create {name}",
|
||||
"failDownload": "Download failed",
|
||||
"failGeneric": "Something went wrong",
|
||||
"failRuntime": "Runtime install failed",
|
||||
"failSSH": "SSH action failed",
|
||||
"fontMissingFoDHint": "Windows optional {script} fonts are not installed; native overlay text may use fallback glyphs. Install them under Windows Settings › Apps › Optional features.",
|
||||
"footerDiskLabel": "Disk",
|
||||
"footerDiskTip": "VM data folder: {dir}",
|
||||
"footerDiskValue": "{gb} GB free",
|
||||
"footerHostIssue": "Virtualization not ready",
|
||||
"footerHostIssueTip": "Open the Engine page to see what needs attention",
|
||||
"footerMemLabel": "Memory",
|
||||
"footerMemTip": "System memory: {used} GB used / {total} GB total ({avail} GB free)",
|
||||
"footerMemValue": "{used} / {total} GB",
|
||||
"footerRunningVMs": "{n, plural, one {# running} other {# running}}",
|
||||
"forceStop": "Force shut down",
|
||||
"gpuErrMissingExt": "Missing required Vulkan extensions ({ext}); update GPU drivers or use VMware SVGA",
|
||||
"gpuErrVulkanCpu": "Software Vulkan implementation cannot accelerate vGPU; use VMware SVGA",
|
||||
"gpuErrVulkanTooOld": "Vulkan {ver} is below the required 1.3 floor; update GPU drivers or use VMware SVGA",
|
||||
"gpuWarnAmdLegacy": "AMD Vega/Polaris on Windows hits known upstream black-screen/device-loss issues ({ref}); prefer another discrete GPU or use VMware SVGA for now",
|
||||
"gpuWarnAmdRdna2": "This AMD GPU hits known Windows device-loss issues upstream ({ref}); update drivers or use VMware SVGA if it freezes",
|
||||
"guestKbdPinyin": "Pinyin",
|
||||
"guestKbdUS": "US Keyboard",
|
||||
"guestKbdUSRecommended": "US Keyboard, recommended",
|
||||
"guestLang": "macOS system language",
|
||||
"guestLangEnUS": "English (US)",
|
||||
"guestLangJaJP": "Japanese",
|
||||
"guestLangKoKR": "Korean",
|
||||
"guestLangZhHansUS": "Simplified Chinese",
|
||||
"guestLangZhHantUS": "Traditional Chinese",
|
||||
"helpAbout": "About Reims-Go",
|
||||
"helpCheckUpdate": "Check for Updates…",
|
||||
"helpProjectPage": "Project Page",
|
||||
"helpReportIssue": "Report an Issue",
|
||||
"hideSidebar": "Hide sidebar",
|
||||
"hidpiTipFullscreen": "In a window macOS runs at 1x with rough text; full screen gives HiDPI",
|
||||
"hidpiTipScale": "macOS runs at 1x on this screen, with rough text; Windows scaling at 150% or more gives HiDPI",
|
||||
"hidpiTipUnavailable": "This screen has too few pixels; macOS runs at 1x",
|
||||
"hostDisplayHint": "Main display {w}×{h} at {scale}%",
|
||||
"hostNeedsAction": "Needs attention",
|
||||
"hostReady": "Ready",
|
||||
"importRuntime": "Import runtime",
|
||||
"installersDownloading": "Downloading",
|
||||
"installersQueuedDesc": "Waiting for current download to finish",
|
||||
"installersRetry": "Retry",
|
||||
"jumpLatest": "Jump to latest",
|
||||
"localeAuto": "System Default",
|
||||
"localeAutoDetail": "Current: {tag}",
|
||||
"logActivity": "Activity",
|
||||
"logButton": "Logs",
|
||||
"logCopy": "Copy logs",
|
||||
"logErrorsOnly": "Errors \u0026 warnings",
|
||||
"logQemu": "QEMU",
|
||||
"logSearchPlaceholder": "Filter logs…",
|
||||
"logSerial": "Serial",
|
||||
"logsEmpty": "No logs yet",
|
||||
"macos.appsUtilitiesTerminal": "Applications › Utilities › Terminal",
|
||||
"macos.diskUtility": "Disk Utility",
|
||||
"macos.erase": "Erase",
|
||||
"macos.finder": "Finder",
|
||||
"macos.guidPartitionMap": "GUID Partition Map",
|
||||
"macos.otherSignInSetUpLater": "Other Sign-In Options › Set Up Later",
|
||||
"macos.recovery": "Recovery",
|
||||
"macos.reinstallMacOS": "Reinstall macOS",
|
||||
"macos.setupAssistant": "Setup Assistant",
|
||||
"macos.showAllDevices": "View › Show All Devices",
|
||||
"macos.utilitiesTerminal": "Utilities › Terminal",
|
||||
"macos.volume": "Volume",
|
||||
"maximize": "Maximize",
|
||||
"menuBar": "Menu bar",
|
||||
"menuHelp": "Help",
|
||||
"menuVM": "VM",
|
||||
"menuView": "View",
|
||||
"minimize": "Minimize",
|
||||
"more": "More",
|
||||
"newVM": "New virtual machine",
|
||||
"newVMEllipsis": "New Virtual Machine…",
|
||||
"noRuntimeAlert": "Import a runtime under Engine first",
|
||||
"off": "Off",
|
||||
"on": "On",
|
||||
"openFolder": "Show in folder",
|
||||
"panelLoadFailed": "Panel failed to load",
|
||||
"pauseDownload": "Pause download",
|
||||
"pluginSafeModeShort": "Safe mode",
|
||||
"quitFailed": "Quit canceled",
|
||||
"quitInProgress": "Quitting…",
|
||||
"refresh": "Refresh",
|
||||
"resLooksLike": "Looks like {w} × {h}",
|
||||
"resizeLogPanel": "Drag to resize log panel",
|
||||
"resolution": "Resolution",
|
||||
"restart": "Restart",
|
||||
"safeModeBanner": "Safe mode is active: all third-party plugins are disabled and the built-in theme is restored",
|
||||
"safeModeManagePlugins": "Manage plugins",
|
||||
"save": "Save",
|
||||
"settings": "Settings",
|
||||
"settingsAbout": "About",
|
||||
"settingsEllipsis": "Settings…",
|
||||
"shortcutBarFullscreen": "Toggle full screen",
|
||||
"shortcutBarRelease": "Release keyboard and mouse",
|
||||
"showSidebar": "Show sidebar",
|
||||
"shutdownMode": "Shutdown mode",
|
||||
"sidebarHost": "Engine",
|
||||
"sidebarInstallers": "Images",
|
||||
"sidebarItemAria": "{label}, {state}",
|
||||
"sidebarLabel": "Sidebar",
|
||||
"sidebarPlugins": "Plugins",
|
||||
"sidebarSettings": "Settings",
|
||||
"sidebarSystem": "System",
|
||||
"sidebarVMs": "Virtual machines",
|
||||
"start": "Start",
|
||||
"starting": "Starting",
|
||||
"stop": "Shut down",
|
||||
"taskAppUpdate": "Downloading Reims-Go {v}",
|
||||
"taskCreate": "Creating {name}",
|
||||
"taskDownload": "Downloading macOS {v}",
|
||||
"taskRecoveryDownload": "Downloading online recovery for {name}",
|
||||
"taskRuntime": "Installing runtime {v}",
|
||||
"tasksRunning": "{n, plural, one {# task running} other {# tasks running}}",
|
||||
"themeDark": "Dark",
|
||||
"themeLight": "Light",
|
||||
"themeSwitchDark": "Switch to dark appearance",
|
||||
"themeSwitchLight": "Switch to light appearance",
|
||||
"themeSystem": "System",
|
||||
"toastAffinityApplied": "Processor affinity applied ({count} logical CPUs · {mask})",
|
||||
"toastAffinitySaved": "Processor affinity saved for next start",
|
||||
"toastBorderlessNextStart": "Fullscreen launch saved — applies on next restart",
|
||||
"toastBorderlessUpdated": "Fullscreen launch preference saved",
|
||||
"toastCopied": "Copied",
|
||||
"toastCreateCanceled": "Canceled creating {name}",
|
||||
"toastCreateCanceledPartial": "Downloaded progress is kept; resume anytime or edit and retry",
|
||||
"toastCreated": "{name} created",
|
||||
"toastDownloadPaused": "Paused — downloading again continues where it stopped",
|
||||
"toastInstallerReady": "macOS {v} installer ready",
|
||||
"toastQueueCanceled": "Removed from download queue",
|
||||
"toastRuntimeReady": "Runtime {v} installed",
|
||||
"toastSSHConfigWritten": "Wrote Host {alias}",
|
||||
"toastSSHUserSaved": "Saved SSH username",
|
||||
"toastSaved": "Saved",
|
||||
"toastSavedNextStart": "Saved — applies on next start",
|
||||
"updateCancel": "Cancel download",
|
||||
"updateCapsuleAvailable": "{v} available",
|
||||
"updateCapsuleDownloading": "Downloading update",
|
||||
"updateCapsuleDownloadingPct": "Downloading {p}%",
|
||||
"updateCapsuleFailed": "Update download failed",
|
||||
"updateCapsuleOpen": "Update details",
|
||||
"updateCapsuleReady": "{v} ready",
|
||||
"updateConfirmBody": "{n, plural, one {# VM is running. It will keep running, while clipboard, shared folders and the input bridge pause for a few seconds until Reims-Go is back.} other {# VMs are running. They will keep running, while clipboard, shared folders and the input bridge pause for a few seconds until Reims-Go is back.}}",
|
||||
"updateConfirmTitle": "Restart to install {v}",
|
||||
"updateConfirmWin10": "This Windows 10 host relies on the cold-reboot workaround: the next time macOS in these VMs restarts, start the VM again by hand.",
|
||||
"updateDoneToast": "Updated to {v}",
|
||||
"updateDownload": "Download",
|
||||
"updateFailed": "Update failed",
|
||||
"updateLater": "Remind me later",
|
||||
"updateRestart": "Restart to install",
|
||||
"updateRetry": "Retry",
|
||||
"uptimeHoursMinutes": "{h}h {m}m",
|
||||
"uptimeMinutesSeconds": "{m}m {s}s",
|
||||
"uptimeSeconds": "{s}s",
|
||||
"viewLogs": "View logs",
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
// Code generated by cmd/i18ngen; DO NOT EDIT.
|
||||
import { registerBuiltinDomain } from '../runtime'
|
||||
|
||||
export const pluginsZh: Record<string, string> = {
|
||||
"pluginAccentSeed": "强调种子色",
|
||||
"pluginActiveCount": "已启用 {active} / {total}",
|
||||
"pluginActiveTheme": "当前主题包",
|
||||
"pluginAlwaysOn": "核心组件,始终启用",
|
||||
"pluginApproveCheckbox": "我已核对来源与权限,确认启用此插件",
|
||||
"pluginApproveConfirm": "确认启用",
|
||||
"pluginApproveL3Warn": "此插件为原生可执行程序(L3 Sidecar),能够以当前 Windows 账户身份执行任意操作",
|
||||
"pluginApproveTitle": "高危权限确认",
|
||||
"pluginBuiltinSection": "内置插件",
|
||||
"pluginColorSchemes": "配色方案",
|
||||
"pluginColorSchemesHint": "修改种子色派生整套界面色阶",
|
||||
"pluginDeleteScheme": "删除方案",
|
||||
"pluginDisable": "停用",
|
||||
"pluginDisableInUseBody": "停用后,这个插件管理的虚拟机会显示为「驱动不可用」,不能启动或修改。虚拟机文件和挂起状态都会保留,重新启用即可恢复。运行中的虚拟机需要先停止或挂起。",
|
||||
"pluginDisableInUseTitle": "停用仍有虚拟机的插件",
|
||||
"pluginDone": "完成",
|
||||
"pluginEnableLater": "暂不启用",
|
||||
"pluginEnableNow": "启用",
|
||||
"pluginEnablePromptBody": "要现在启用吗?启用前请了解它会做什么:",
|
||||
"pluginEnablePromptNoRisk": "此插件没有声明额外能力,可以放心启用。",
|
||||
"pluginEnablePromptTitle": "「{name}」已安装",
|
||||
"pluginEntryPath": "入口路径",
|
||||
"pluginExternalSection": "已安装插件",
|
||||
"pluginFailDeleteScheme": "删除配色方案失败",
|
||||
"pluginFailEnable": "启用插件失败",
|
||||
"pluginFailImport": "导入插件包失败",
|
||||
"pluginFailLinkDev": "链接开发插件失败",
|
||||
"pluginFailLoad": "加载插件列表失败",
|
||||
"pluginFailLoadSettings": "读取插件设置失败",
|
||||
"pluginFailMarketInstall": "安装市场插件失败",
|
||||
"pluginFailMarketLoad": "加载插件市场失败",
|
||||
"pluginFailReadLog": "读取插件日志失败",
|
||||
"pluginFailRemove": "卸载插件失败",
|
||||
"pluginFailSaveScheme": "保存配色方案失败",
|
||||
"pluginFailSaveSettings": "保存插件设置失败",
|
||||
"pluginFailScan": "插件安全扫描失败",
|
||||
"pluginFailSwitchTheme": "切换主题失败",
|
||||
"pluginFailToggle": "切换插件状态失败",
|
||||
"pluginGlobalSettings": "插件全局设置",
|
||||
"pluginHighRiskNotice": "包含高危权限,启用前需确认",
|
||||
"pluginImportBtn": "导入插件",
|
||||
"pluginImportTitle": "导入本地插件包 (.zip)",
|
||||
"pluginInUse": "使用中不可卸载",
|
||||
"pluginLinkDevBtn": "链接插件开发目录",
|
||||
"pluginLinkDevTitle": "链接本地开发插件目录",
|
||||
"pluginLogEmpty": "暂无日志记录",
|
||||
"pluginLogTitle": "{id} — 日志",
|
||||
"pluginMarketDownloading": "下载中",
|
||||
"pluginMarketEmpty": "当前插件市场暂无可用条目,你仍可导入本地 .zip 插件包或配置自定义市场索引地址",
|
||||
"pluginMarketFeedEnd": "共 {count} 个插件",
|
||||
"pluginMarketIncompatible": "不兼容",
|
||||
"pluginMarketInstall": "安装",
|
||||
"pluginMarketInstalled": "已安装",
|
||||
"pluginMarketInstalling": "安装中",
|
||||
"pluginMarketKindAll": "全部",
|
||||
"pluginMarketKindDriver": "客体驱动",
|
||||
"pluginMarketKindLocale": "语言包",
|
||||
"pluginMarketKindRuntime": "运行时",
|
||||
"pluginMarketKindTemplate": "模板",
|
||||
"pluginMarketKindTheme": "主题",
|
||||
"pluginMarketKindTool": "工具",
|
||||
"pluginMarketLoading": "正在读取插件市场",
|
||||
"pluginMarketRefresh": "刷新索引",
|
||||
"pluginMarketSearchPlaceholder": "搜索市场插件、作者或标签",
|
||||
"pluginMarketStaleBanner": "远程插件市场暂不可达,当前显示本地缓存或内置回退索引",
|
||||
"pluginMarketSyncing": "正在同步插件市场",
|
||||
"pluginMarketUpdate": "更新至 v{version}",
|
||||
"pluginMarketUpdateShort": "更新",
|
||||
"pluginMarketVersionTip": "已安装 v{installed},可更新至 v{version}",
|
||||
"pluginMarketWithdrawn": "已撤回",
|
||||
"pluginMarketWithdrawnInstalledWarn": "已安装插件 {id} 已从市场撤回:{reason}",
|
||||
"pluginMarketWithdrawnInstead": "建议改用:{target}",
|
||||
"pluginNewScheme": "新建配色方案",
|
||||
"pluginPanelsSection": "插件面板",
|
||||
"pluginPermCount": "{count, plural, other {# 项权限}}",
|
||||
"pluginPermissionsLabel": "权限:{list}",
|
||||
"pluginPublisherLicense": "发布者 / 许可",
|
||||
"pluginRemove": "卸载",
|
||||
"pluginRequestedPerms": "请求权限",
|
||||
"pluginRiskBackground": "该插件可以持久化运行后台代码",
|
||||
"pluginRiskClipboard": "该插件可以读写系统剪贴板",
|
||||
"pluginRiskFiles": "该插件会读写文件",
|
||||
"pluginRiskInput": "该插件会拦截或改写键盘与鼠标输入",
|
||||
"pluginRiskNative": "该插件包含原生程序,拥有您 Windows 账户的全部权限",
|
||||
"pluginRiskNetwork": "该插件会访问网络",
|
||||
"pluginRiskUi": "该插件会修改您看到的用户界面",
|
||||
"pluginRiskVm": "该插件可以控制虚拟机",
|
||||
"pluginScanAdvisoriesSection": "提示信息与可执行文件",
|
||||
"pluginScanArchiveTitle": "导入前安全检查",
|
||||
"pluginScanBlockedBtn": "已拦截,无法安装",
|
||||
"pluginScanCapabilitiesSection": "能力与权限说明",
|
||||
"pluginScanHardSection": "硬性拦截项(禁止安装)",
|
||||
"pluginScanInspect": "安全扫描",
|
||||
"pluginScanInstallConfirm": "确认导入安装",
|
||||
"pluginScanLoading": "正在扫描插件包…",
|
||||
"pluginScanModalTitle": "插件静态安全报告",
|
||||
"pluginScanMoreItems": "另有 {count} 项已折叠",
|
||||
"pluginSchemeDefault": "默认",
|
||||
"pluginSchemeModalTitle": "新建配色方案",
|
||||
"pluginSchemeName": "方案名称",
|
||||
"pluginSchemePlaceholder": "如:柔蓝",
|
||||
"pluginSearchEmpty": "没有匹配的插件",
|
||||
"pluginSearchPlaceholder": "筛选插件",
|
||||
"pluginSettings": "插件设置",
|
||||
"pluginStateDegraded": "已降级",
|
||||
"pluginStateFailed": "故障",
|
||||
"pluginStatePending": "等待依赖",
|
||||
"pluginSurfaceSeed": "画布种子色(可选)",
|
||||
"pluginTabInstalled": "已安装",
|
||||
"pluginTabMarket": "市场",
|
||||
"pluginThemeEmptyHint": "导入本地主题包(.zip)后可在此切换外观与配色方案",
|
||||
"pluginThemeHint": "同一时刻仅启用一个主题包,停用后自动回退默认主题",
|
||||
"pluginThemePackLabel": "主题包",
|
||||
"pluginThemeSafeModeHint": "安全模式下固定使用内置默认主题",
|
||||
"pluginThemeSection": "主题扩展",
|
||||
"pluginTrustCommunity": "社区",
|
||||
"pluginTrustDev": "开发",
|
||||
"pluginTrustOfficial": "官方",
|
||||
"pluginTrustVerified": "已审核",
|
||||
"pluginViewLog": "查看日志",
|
||||
}
|
||||
|
||||
export const pluginsEn: Record<string, string> = {
|
||||
"pluginAccentSeed": "Accent seed",
|
||||
"pluginActiveCount": "{active} / {total} active",
|
||||
"pluginActiveTheme": "Active theme pack",
|
||||
"pluginAlwaysOn": "Core component, always on",
|
||||
"pluginApproveCheckbox": "I have reviewed the source and permissions and confirm enabling this plugin",
|
||||
"pluginApproveConfirm": "Confirm enable",
|
||||
"pluginApproveL3Warn": "This plugin runs native code (L3 Sidecar) and can perform arbitrary actions as your Windows user",
|
||||
"pluginApproveTitle": "Approve high-risk permissions",
|
||||
"pluginBuiltinSection": "Built-in plugins",
|
||||
"pluginColorSchemes": "Color schemes",
|
||||
"pluginColorSchemesHint": "Seed colors derive the full surface, text, and accent ramp",
|
||||
"pluginDeleteScheme": "Delete scheme",
|
||||
"pluginDisable": "Disable",
|
||||
"pluginDisableInUseBody": "Its VMs will show as “Driver unavailable” and can’t be started or changed. Their files and any suspended state are kept; turning the plugin back on restores them. Stop or suspend any running VM first.",
|
||||
"pluginDisableInUseTitle": "Disable a plugin that still has VMs",
|
||||
"pluginDone": "Done",
|
||||
"pluginEnableLater": "Not now",
|
||||
"pluginEnableNow": "Enable",
|
||||
"pluginEnablePromptBody": "Enable it now? Here is what it can do:",
|
||||
"pluginEnablePromptNoRisk": "This plugin declares no extra capabilities.",
|
||||
"pluginEnablePromptTitle": "“{name}” is installed",
|
||||
"pluginEntryPath": "Entry path",
|
||||
"pluginExternalSection": "Installed plugins",
|
||||
"pluginFailDeleteScheme": "Couldn’t delete color scheme",
|
||||
"pluginFailEnable": "Couldn’t enable plugin",
|
||||
"pluginFailImport": "Couldn’t import plugin package",
|
||||
"pluginFailLinkDev": "Couldn’t link dev plugin",
|
||||
"pluginFailLoad": "Couldn’t load plugins",
|
||||
"pluginFailLoadSettings": "Couldn’t load plugin settings",
|
||||
"pluginFailMarketInstall": "Couldn’t install plugin from market",
|
||||
"pluginFailMarketLoad": "Couldn’t load plugin market",
|
||||
"pluginFailReadLog": "Couldn’t read plugin log",
|
||||
"pluginFailRemove": "Couldn’t remove plugin",
|
||||
"pluginFailSaveScheme": "Couldn’t save color scheme",
|
||||
"pluginFailSaveSettings": "Couldn’t save plugin settings",
|
||||
"pluginFailScan": "Couldn’t scan plugin",
|
||||
"pluginFailSwitchTheme": "Couldn’t switch theme",
|
||||
"pluginFailToggle": "Couldn’t toggle plugin",
|
||||
"pluginGlobalSettings": "Plugin settings",
|
||||
"pluginHighRiskNotice": "Contains high-risk permissions; approval required before enabling",
|
||||
"pluginImportBtn": "Import plugin",
|
||||
"pluginImportTitle": "Import plugin package (.zip)",
|
||||
"pluginInUse": "In use",
|
||||
"pluginLinkDevBtn": "Link plugin dev folder",
|
||||
"pluginLinkDevTitle": "Link local dev plugin folder",
|
||||
"pluginLogEmpty": "No log entries yet",
|
||||
"pluginLogTitle": "{id} — Log",
|
||||
"pluginMarketDownloading": "Downloading",
|
||||
"pluginMarketEmpty": "No plugins available in the market index yet. You can still import local .zip packages or configure a custom index URL.",
|
||||
"pluginMarketFeedEnd": "{count} plugins",
|
||||
"pluginMarketIncompatible": "Incompatible",
|
||||
"pluginMarketInstall": "Install",
|
||||
"pluginMarketInstalled": "Installed",
|
||||
"pluginMarketInstalling": "Installing",
|
||||
"pluginMarketKindAll": "All",
|
||||
"pluginMarketKindDriver": "Drivers",
|
||||
"pluginMarketKindLocale": "Languages",
|
||||
"pluginMarketKindRuntime": "Runtimes",
|
||||
"pluginMarketKindTemplate": "Templates",
|
||||
"pluginMarketKindTheme": "Themes",
|
||||
"pluginMarketKindTool": "Tools",
|
||||
"pluginMarketLoading": "Loading the plugin market",
|
||||
"pluginMarketRefresh": "Refresh index",
|
||||
"pluginMarketSearchPlaceholder": "Search market plugins, publishers, or tags",
|
||||
"pluginMarketStaleBanner": "Remote market index is unreachable; showing cached or offline fallback data",
|
||||
"pluginMarketSyncing": "Syncing the plugin market",
|
||||
"pluginMarketUpdate": "Update to v{version}",
|
||||
"pluginMarketUpdateShort": "Update",
|
||||
"pluginMarketVersionTip": "v{installed} installed, v{version} available",
|
||||
"pluginMarketWithdrawn": "Withdrawn",
|
||||
"pluginMarketWithdrawnInstalledWarn": "Installed plugin {id} has been withdrawn: {reason}",
|
||||
"pluginMarketWithdrawnInstead": "Recommended replacement: {target}",
|
||||
"pluginNewScheme": "New scheme",
|
||||
"pluginPanelsSection": "Plugin panels",
|
||||
"pluginPermCount": "{count, plural, one {# permission} other {# permissions}}",
|
||||
"pluginPermissionsLabel": "Permissions: {list}",
|
||||
"pluginPublisherLicense": "Publisher / License",
|
||||
"pluginRemove": "Remove",
|
||||
"pluginRequestedPerms": "Requested permissions",
|
||||
"pluginRiskBackground": "Can keep code running in the background",
|
||||
"pluginRiskClipboard": "Can read and write the system clipboard",
|
||||
"pluginRiskFiles": "Reads and writes files",
|
||||
"pluginRiskInput": "Intercepts or rewrites keyboard and mouse input",
|
||||
"pluginRiskNative": "Ships a native program with full rights of your Windows account",
|
||||
"pluginRiskNetwork": "Accesses the network",
|
||||
"pluginRiskUi": "Changes the interface you see",
|
||||
"pluginRiskVm": "Can control your virtual machines",
|
||||
"pluginScanAdvisoriesSection": "Advisories \u0026 executables",
|
||||
"pluginScanArchiveTitle": "Pre-install security check",
|
||||
"pluginScanBlockedBtn": "Blocked — cannot install",
|
||||
"pluginScanCapabilitiesSection": "Capabilities \u0026 privileges",
|
||||
"pluginScanHardSection": "Hard blockers (install refused)",
|
||||
"pluginScanInspect": "Security scan",
|
||||
"pluginScanInstallConfirm": "Proceed with install",
|
||||
"pluginScanLoading": "Scanning plugin package…",
|
||||
"pluginScanModalTitle": "Plugin security report",
|
||||
"pluginScanMoreItems": "...and {count} more",
|
||||
"pluginSchemeDefault": "Default",
|
||||
"pluginSchemeModalTitle": "New color scheme",
|
||||
"pluginSchemeName": "Scheme name",
|
||||
"pluginSchemePlaceholder": "e.g. Soft Blue",
|
||||
"pluginSearchEmpty": "No matching plugins",
|
||||
"pluginSearchPlaceholder": "Filter plugins",
|
||||
"pluginSettings": "Plugin settings",
|
||||
"pluginStateDegraded": "Degraded",
|
||||
"pluginStateFailed": "Failed",
|
||||
"pluginStatePending": "Pending",
|
||||
"pluginSurfaceSeed": "Surface seed (optional)",
|
||||
"pluginTabInstalled": "Installed",
|
||||
"pluginTabMarket": "Market",
|
||||
"pluginThemeEmptyHint": "Import a local theme package (.zip) to switch visual themes and color schemes",
|
||||
"pluginThemeHint": "One active theme pack at a time; disabling falls back to the built-in default",
|
||||
"pluginThemePackLabel": "Theme pack",
|
||||
"pluginThemeSafeModeHint": "Built-in default theme is enforced in safe mode",
|
||||
"pluginThemeSection": "Theme extensions",
|
||||
"pluginTrustCommunity": "Community",
|
||||
"pluginTrustDev": "Dev",
|
||||
"pluginTrustOfficial": "Official",
|
||||
"pluginTrustVerified": "Verified",
|
||||
"pluginViewLog": "View log",
|
||||
}
|
||||
|
||||
registerBuiltinDomain(pluginsZh, pluginsEn)
|
||||
@@ -0,0 +1,848 @@
|
||||
// Code generated by cmd/i18ngen; DO NOT EDIT.
|
||||
import { registerBuiltinDomain } from '../runtime'
|
||||
|
||||
export const settingsZh: Record<string, string> = {
|
||||
"aboutCommunity": "社区与支持",
|
||||
"aboutCopyDiscord": "复制邀请链接",
|
||||
"aboutCopyQQGroup": "复制群号",
|
||||
"aboutDiscord": "Discord 社区",
|
||||
"aboutDiscordSub": "交流使用体验、硬件兼容反馈、Alpha 测试与插件开发",
|
||||
"aboutIssueSub": "遇到问题或有功能建议,在 GitHub 提交 Issue",
|
||||
"aboutJoinDiscord": "加入服务器",
|
||||
"aboutJoinQQGroup": "加入群聊",
|
||||
"aboutLicensesOpenGitHub": "在 GitHub 查看",
|
||||
"aboutLicensesSub": "Apache-2.0 协议与第三方开源组件声明(离线可查)",
|
||||
"aboutLicensesTabLicense": "Apache-2.0 协议",
|
||||
"aboutLicensesTabNotice": "第三方声明",
|
||||
"aboutLicensesTitle": "开源许可与声明",
|
||||
"aboutLicensesView": "查看",
|
||||
"aboutProjectSub": "GitHub 上的源码、发布版本与使用文档",
|
||||
"aboutQQGroup": "QQ 交流群",
|
||||
"aboutQQGroupSub": "点击直接拉起 QQ 加群,交流使用与问题反馈",
|
||||
"aboutQQLaunchFailed": "未能拉起 QQ,可复制群号手动搜索加入",
|
||||
"aboutQQNotInstalled": "未安装 QQ",
|
||||
"aboutQQNotInstalledSub": "未检测到本地 QQ,可复制群号手动搜索加入",
|
||||
"aboutTagline": "在 Windows 上开一台带 GPU 加速的 macOS 虚拟机——免编译,开箱即用。",
|
||||
"activate": "使用",
|
||||
"affinityApplyNow": "立即应用",
|
||||
"affinityAvoidLPE": "避开 LP-E",
|
||||
"affinityConfigure": "配置…",
|
||||
"affinityEcoQoS": "禁用 Windows 效率模式节流 (EcoQoS)",
|
||||
"affinityEcoQoSDesc": "防止 Windows 11 在窗口失焦或后台运行时把 QEMU 线程压缩到 2 个低功耗核心",
|
||||
"affinityExcludeCPU0": "排除 CPU 0",
|
||||
"affinityLiveMask": "Windows 当前生效:{mask}({count} 线程)",
|
||||
"affinityModeAll": "所有处理器",
|
||||
"affinityModeAllHint": "允许 Windows 将 QEMU 调度到全部宿主机逻辑处理器。",
|
||||
"affinityModeAuto": "自动",
|
||||
"affinityModeAutoHint": "跟随全局策略,在混合大小核处理器上自动避开超售与低功耗核。",
|
||||
"affinityModeCustom": "自定义",
|
||||
"affinityModeCustomHint": "勾选允许运行 QEMU 的逻辑处理器,等价于 Windows 任务管理器的处理器相关性。",
|
||||
"affinityModeNonLPE": "P + E 核",
|
||||
"affinityModeNonLPEHint": "在性能核与能效核(P + E)上运行,仅排除慢速低功耗核(LP-E)。",
|
||||
"affinityModePCores": "仅 P 核",
|
||||
"affinityModePCoresHint": "仅在性能核(P-Core)上运行,减少大小核混调引起的抖动。",
|
||||
"affinityNeedOne": "请至少勾选 1 个逻辑处理器",
|
||||
"affinityOnlyPCores": "仅 P 核",
|
||||
"affinityOversubWarn": "当前只勾选了 {selected} 个逻辑处理器,少于虚拟机分配的 {vcpus} 个 vCPU,可能导致明显卡顿。",
|
||||
"affinityPhysicalOnly": "仅物理核",
|
||||
"affinityRowDesc": "指定虚拟机在哪些核心上运行,立即生效",
|
||||
"affinitySave": "保存",
|
||||
"affinitySelectAll": "所有处理器",
|
||||
"affinitySelectedSummary": "已选 {selected} / {total} 个逻辑处理器 · 掩码 {mask}",
|
||||
"affinitySubtitleRunning": "运行中(PID {pid})· {vcpus} vCPU · 修改后立即生效",
|
||||
"affinitySubtitleStopped": "已停止 · {vcpus} vCPU · 下次启动时自动生效",
|
||||
"affinitySummaryAll": "所有处理器({count} 线程)",
|
||||
"affinitySummaryAuto": "自动({eff} · {count} 线程)",
|
||||
"affinitySummaryCustom": "自定义({count} 线程 · {mask})",
|
||||
"affinitySummaryNonLPE": "P + E 核({count} 线程 · {mask})",
|
||||
"affinitySummaryPCores": "仅 P 核({count} 线程 · {mask})",
|
||||
"affinityTitle": "处理器核心",
|
||||
"appCheckUpdate": "检查更新",
|
||||
"appDownloadUpdate": "前往下载",
|
||||
"appUpToDate": "已是最新",
|
||||
"appUpdateAvailable": "发现新版本 {v}(稳定版)",
|
||||
"appUpdateAvailableAlpha": "发现新版本 {v}(Alpha 测试版)",
|
||||
"appUpdateAvailableDev": "发现新版本 {v}(Dev 滚动版)",
|
||||
"appUpdateChannelAlpha": "Alpha",
|
||||
"appUpdateChannelDev": "Dev",
|
||||
"appUpdateChannelStable": "稳定版",
|
||||
"appUpdateChannelSubKeepOld": "接收 {channel} 预发布版本;启动时不删除旧版程序与已下载安装包,方便随时回退",
|
||||
"appUpdateChannelSubStable": "仅接收经过验证的正式稳定版本",
|
||||
"appUpdateChannelTitle": "更新通道",
|
||||
"appUpdateLookupFailed": "暂时无法连接 GitHub 检查更新",
|
||||
"appVersionTitle": "客户端版本",
|
||||
"appliesNextStart": "下次启动生效",
|
||||
"audioBackendAuto": "自动",
|
||||
"audioBackendDesc": "「静音」保留 macOS 的声卡但不出声,适合排查音频问题",
|
||||
"audioBackendDsound": "DirectSound",
|
||||
"audioBackendNone": "静音",
|
||||
"audioBackendTitle": "声音输出",
|
||||
"audioDesc": "在 Windows 上播放 macOS 的声音",
|
||||
"audioDisabledReason": "请先开启音频",
|
||||
"audioTroubleshootNote": "有爆音时,把 Windows 声音格式设为 48000 Hz;麦克风没声音时,检查 Windows「隐私 › 麦克风」权限",
|
||||
"autoPinPCores": "启动后绑定到性能核",
|
||||
"back": "上一步",
|
||||
"captureInput": "点击窗口时捕获键鼠",
|
||||
"captureInputHint": "开启后 ⌘Tab 等快捷键交给 macOS;关闭时 Win 键和 Alt+Tab 留给 Windows",
|
||||
"catAdvanced": "高级",
|
||||
"catAudio": "音频",
|
||||
"catCompute": "处理器与内存",
|
||||
"catGeneral": "通用",
|
||||
"catGraphics": "图形与显示器",
|
||||
"catInput": "键盘与指针",
|
||||
"catInputAudio": "输入与音频",
|
||||
"catLogs": "日志",
|
||||
"catNetwork": "网络",
|
||||
"catStorage": "存储",
|
||||
"catStorageNet": "存储与网络",
|
||||
"choose": "浏览…",
|
||||
"configured": "已配置",
|
||||
"coresUnit": "核",
|
||||
"cpuOverHint": "留给 Windows 的线程不足 2 个,电脑可能变卡",
|
||||
"cpuRecHint": "推荐 {rec} 核 · 本机共 {n} 线程",
|
||||
"defenderCopyCommand": "复制排除命令",
|
||||
"defenderExclusionDesc": "实时扫描可能拖慢虚拟机磁盘访问。可在 Windows 安全中心为数据目录 {path} 添加排除项。",
|
||||
"defenderExclusionTitle": "Windows Defender 实时防护排除建议",
|
||||
"defenderOpenSecurity": "打开 Windows 安全中心",
|
||||
"diskCompactAction": "立即回收",
|
||||
"diskCompactDesc": "把 macOS 里已删除文件占用的空间还给 Windows,过程中需要与当前占用差不多的空闲空间",
|
||||
"diskCompactDone": "已回收 {reclaimed}({before} → {after})",
|
||||
"diskCompactNoGain": "没有可回收的空间",
|
||||
"diskCompactQcow2Only": "这块磁盘不支持回收空间",
|
||||
"diskCompactTitle": "回收空间",
|
||||
"diskController": "磁盘接口",
|
||||
"diskControllerInstallHint": "装机时保持 SATA,装完弹出安装盘再改 NVMe",
|
||||
"diskControllerNvmeHint": "NVMe 读写更快",
|
||||
"diskControllerNvmeReadyHint": "NVMe 速度快,也兼容恢复模式,推荐",
|
||||
"diskControllerVirtioHint": "VirtIO 开销更低,仍属实验性;遇到问题请改回 NVMe",
|
||||
"diskControllerWarn": "切换前先弹出安装盘",
|
||||
"diskMode": "使用方式",
|
||||
"diskModeCopy": "复制一份,不改动原盘",
|
||||
"diskModeInPlace": "直接使用原盘",
|
||||
"diskOptimizeAction": "优化磁盘结构",
|
||||
"diskOptimizeDesc": "默认 64 KiB 簇可划分为 2 KiB 子簇,减少小块写入的开销,同时整理磁盘并回收空间。",
|
||||
"diskOptimizeDone": "{before} → {after},已回收 {reclaimed}。{status}。",
|
||||
"diskOptimizeEnabled": "已启用 extended_l2",
|
||||
"diskOptimizeInactive": "extended_l2 未启用",
|
||||
"diskOptimizeTitle": "QCOW2 子簇优化",
|
||||
"diskResizeAction": "扩容",
|
||||
"diskResizeDesc": "只能增大。扩大后在 macOS 终端运行提示的命令,新空间才能使用",
|
||||
"diskResizeDone": "已扩大到 {size}。在 macOS 终端运行:",
|
||||
"diskResizeTitle": "扩大磁盘",
|
||||
"diskRewriteBusy": "正在进行另一项磁盘操作。",
|
||||
"diskRewriteOverlay": "此磁盘共享基础镜像,无法直接重写。",
|
||||
"diskRewriteSnapshots": "请先删除内部恢复点,以免重写磁盘时丢失。",
|
||||
"diskSize": "磁盘上限",
|
||||
"diskSizeHint": "按实际占用增长",
|
||||
"diskUsageSummary": "已占用 {actual},上限 {virtual}",
|
||||
"displayGroup": "显示器",
|
||||
"driveShareMaster": "共享 Windows 盘符",
|
||||
"driveShareMasterDesc": "在 macOS 访达中显示所选磁盘,立即生效",
|
||||
"driveShareNeedsTools": "需要 Guest Tools {version} 以上:重启虚拟机,再在 macOS 中重新运行安装命令",
|
||||
"driveShareNoDrives": "没有可共享的内部固定磁盘",
|
||||
"driveShareReadOnly": "只读:macOS 可以打开和复制,不能修改",
|
||||
"driveShareSystem": "系统盘,含个人文件和登录信息,请谨慎共享",
|
||||
"driveShareTitle": "Windows 盘符共享",
|
||||
"effectImmediate": "立即生效",
|
||||
"effectNextStart": "下次启动生效",
|
||||
"enableAudio": "音频",
|
||||
"enableLogs": "记录图形与串口日志",
|
||||
"enableNetwork": "网络(NAT)",
|
||||
"enableWHPX": "启用",
|
||||
"extraArgs": "额外 QEMU 参数",
|
||||
"extraArgsDesc": "原样追加到 QEMU 命令行",
|
||||
"failAffinity": "设置处理器相关性失败",
|
||||
"folderShareAdd": "添加目录…",
|
||||
"folderShareAddTitle": "宿主机目录",
|
||||
"folderShareConfirmRWAction": "改为读写",
|
||||
"folderShareConfirmRWDesc": "允许 macOS 修改或删除「{name}」({path})中的文件,更改会立即同步到宿主机原目录。",
|
||||
"folderShareConfirmRWTitle": "开启读写权限",
|
||||
"folderShareDesc": "在 macOS 桌面 ReimsSharedFolders 中访问,立即生效",
|
||||
"folderShareEmpty": "未添加目录",
|
||||
"folderShareIssueBlocked": "不支持共享此目录(系统目录、数据目录、盘符根或外接盘)",
|
||||
"folderShareIssueCorruptConfig": "Guest Tools 配置文件损坏,已保留原文件未覆盖",
|
||||
"folderShareIssueInvalidMode": "无效的共享权限模式",
|
||||
"folderShareIssueMissing": "目录不存在或已移动",
|
||||
"folderShareIssueNotFound": "未找到该共享目录配置",
|
||||
"folderShareIssueOverlap": "与已有共享目录重复或存在包含关系",
|
||||
"folderShareIssuePathChanged": "目录已被重定向或替换,已暂停共享",
|
||||
"folderShareIssueVolumeMismatch": "所在磁盘已变更,已暂停共享",
|
||||
"folderShareListTitle": "已添加目录",
|
||||
"folderShareModeDisabled": "停用",
|
||||
"folderShareModeRO": "只读",
|
||||
"folderShareModeRW": "读写",
|
||||
"folderShareNeedsTools": "需要 Guest Tools {version} 以上:在虚拟机页面更新工具盘并重启虚拟机,再在 macOS 中重新运行安装命令",
|
||||
"folderShareNote": "仅支持本地固定磁盘目录;新增条目默认只读。CoW 克隆不复制目录配置,但克隆盘会沿用源机 Guest Tools 凭证,需在克隆机重新安装 Guest Tools 以隔离",
|
||||
"folderSharePickTitle": "选择要共享给 macOS 的目录",
|
||||
"folderShareRemove": "移除目录",
|
||||
"folderShareTitle": "自定义共享目录",
|
||||
"folderShareWritableWarn": "读写模式:macOS 中的修改和删除会直接作用于宿主机原目录",
|
||||
"footerDisk": "磁盘可用 {gb} GB",
|
||||
"footerMem": "内存 {pct}%",
|
||||
"footerMemAvail": "可用 {avail} GB",
|
||||
"forceQuitAppButton": "强制退出",
|
||||
"forceQuitAppSub": "对所有运行中的虚拟机执行硬关机,未保存的数据可能丢失。",
|
||||
"forceQuitAppTitle": "强制退出 Reims-Go",
|
||||
"forceQuitInProgress": "正在强制退出…",
|
||||
"fullscreenDecoupledHint": "窗口铺满屏幕;下方分辨率可独立设为原生或超采样 HiDPI(如 4K 1.5× = 5120×2880),由 GPU 自动缩放",
|
||||
"fullscreenLaunch": "无边框全屏启动",
|
||||
"fullscreenLaunchHint": "启动后直接进入无边框全屏",
|
||||
"gpuAutoOption": "自动(优先独显)",
|
||||
"gpuAutoSub": "将使用 {name}",
|
||||
"gpuAutoTitle": "自动",
|
||||
"gpuCompatUnsupported": "不支持加速",
|
||||
"gpuCompatWarn": "已知兼容风险",
|
||||
"gpuCustomIcd": "自定义 Vulkan ICD",
|
||||
"gpuDiscrete": "独显",
|
||||
"gpuIntegrated": "核显",
|
||||
"gpuKindDiscrete": "独立显卡",
|
||||
"gpuKindIntegrated": "集成显卡",
|
||||
"gpuRecommended": "推荐",
|
||||
"gpuSelect": "显卡",
|
||||
"gpuSvgaReason": "VMware SVGA 不使用宿主显卡",
|
||||
"gpuSwitchSvga": "改用 VMware SVGA",
|
||||
"gpuUnavailableHint": "没有找到能加速的显卡,可改用 VMware SVGA",
|
||||
"gpuUnknown": "未知",
|
||||
"gpuVirtual": "虚拟",
|
||||
"graphicsBackend": "虚拟显卡",
|
||||
"graphicsReimsDesc": "用宿主显卡加速 Metal,推荐",
|
||||
"graphicsReimsShort": "Reims vGPU",
|
||||
"graphicsRunningReason": "关机后才能切换",
|
||||
"graphicsSvgaDesc": "没有硬件加速,只用于排障",
|
||||
"graphicsSvgaShort": "VMware SVGA",
|
||||
"groupGraphics": "图形",
|
||||
"groupMacOS": "macOS",
|
||||
"groupPerformance": "性能",
|
||||
"groupQemu": "QEMU",
|
||||
"gtInstallCmd": "安装命令",
|
||||
"guestLangHint": "恢复模式、设置助理和登录界面使用的语言;选美式键盘,在终端输命令不易出错",
|
||||
"guestLangSettingsHint": "恢复模式、设置助理和登录界面使用的语言",
|
||||
"guestLangShort": "系统语言",
|
||||
"guestMemory": "分配内存",
|
||||
"guestToolsConnected": "已连接",
|
||||
"guestToolsPreventSleepSub": "闲置时让 macOS 保持唤醒,立即生效",
|
||||
"guestToolsReady": "已配置",
|
||||
"hidpiPresetBadge": "HiDPI",
|
||||
"hostAudioInput": "Windows 麦克风",
|
||||
"hostAudioMissingIn": "没有检测到麦克风,macOS 录不到声音",
|
||||
"hostAudioMissingOut": "没有检测到扬声器或耳机,虚拟机将没有声音",
|
||||
"hostAudioOutput": "Windows 播放设备",
|
||||
"hostCPU": "处理器",
|
||||
"hostCoresThreads": "{c} 核 · {t} 线程",
|
||||
"hostDataRoot": "数据目录",
|
||||
"hostDisk": "可用空间",
|
||||
"hostDisplayPrimary": "主屏",
|
||||
"hostDisplays": "物理显示器",
|
||||
"hostGPUs": "显卡",
|
||||
"hostRAM": "内存",
|
||||
"hostRAMAvail": "可用 {n} GB",
|
||||
"hostRAMTotal": "共 {n} GB",
|
||||
"hostRuntime": "运行时",
|
||||
"hostWHPX": "Windows 虚拟机监控程序平台",
|
||||
"imagesNoSourcesDesc": "请在「插件」页面启用至少一个镜像源插件(例如 macOS 镜像源)以浏览和下载系统镜像。",
|
||||
"imagesNoSourcesTitle": "未启用镜像源插件",
|
||||
"imagesOpenPlugins": "前往插件",
|
||||
"imagesSourcesLabel": "镜像来源",
|
||||
"installersAvailable": "Apple 提供的版本",
|
||||
"installersCreateVM": "新建虚拟机",
|
||||
"installersDelete": "删除",
|
||||
"installersDeleteConfirm": "确认删除",
|
||||
"installersDownload": "下载",
|
||||
"installersDownloaded": "已下载",
|
||||
"installersDownloadingForVM": "为 {vm} 下载中",
|
||||
"installersDownloadingPct": "下载中 {p}%",
|
||||
"installersEmpty": "还没有下载任何镜像",
|
||||
"installersHint": "下载好的镜像可以重复用来新建虚拟机",
|
||||
"installersKindOffline": "离线完整包",
|
||||
"installersKindOnline": "在线恢复镜像",
|
||||
"installersLatest": "最新",
|
||||
"installersNoSpace": "空间不足:需要约 {need} GB,可用 {free} GB",
|
||||
"installersOlder": "{count, plural, other {# 个旧版本}}",
|
||||
"installersPartial": "未下载完",
|
||||
"installersQueued": "排队中",
|
||||
"installersQueuedForVM": "为 {vm} 排队中",
|
||||
"installersResume": "继续下载",
|
||||
"installersTitle": "镜像",
|
||||
"installersWaitingVM": "{vm} 等待使用",
|
||||
"kernelIrqchipAuto": "自动",
|
||||
"kernelIrqchipLabel": "中断加速",
|
||||
"kernelIrqchipOff": "关闭",
|
||||
"kernelIrqchipOn": "开启",
|
||||
"keymapGroupNote": "仅在此虚拟机窗口位于前台时生效。Ctrl+Alt+Win 保留用于释放捕获。",
|
||||
"keymapGroupTitle": "修饰键映射",
|
||||
"keymapGuestDefault": "默认",
|
||||
"keymapGuestDisabled": "禁用",
|
||||
"keymapGuestEsc": "Esc",
|
||||
"keymapGuestLcmd": "左 ⌘ Command",
|
||||
"keymapGuestLctrl": "左 ⌃ Control",
|
||||
"keymapGuestLopt": "左 ⌥ Option",
|
||||
"keymapGuestRcmd": "右 ⌘ Command",
|
||||
"keymapGuestRctrl": "右 ⌃ Control",
|
||||
"keymapGuestRopt": "右 ⌥ Option",
|
||||
"keymapHostCapslock": "Caps Lock",
|
||||
"keymapHostLalt": "左 Alt",
|
||||
"keymapHostLctrl": "左 Ctrl",
|
||||
"keymapHostLwin": "左 Win",
|
||||
"keymapHostRalt": "右 Alt",
|
||||
"keymapHostRctrl": "右 Ctrl",
|
||||
"keymapHostRwin": "右 Win",
|
||||
"keymapInactive": "修饰键映射未启用",
|
||||
"keymapInputServiceRequired": "请启用宿主输入服务以使用修饰键映射",
|
||||
"keymapPending": "等待 Guest Tools 启用修饰键映射",
|
||||
"keymapPresetCustom": "自定义",
|
||||
"keymapPresetOff": "关闭",
|
||||
"keymapPresetSwapAltWin": "Alt ↔ Win",
|
||||
"keymapPresetTitle": "映射预设",
|
||||
"keymapPresetWinToCmd": "Win → ⌘",
|
||||
"keymapRunning": "虚拟机获得焦点时生效",
|
||||
"keymapStopped": "虚拟机启动后生效",
|
||||
"keymapUpgrade": "请将 Guest Tools 更新到版本 {version}",
|
||||
"keymapWaiting": "等待 Guest Tools 连接",
|
||||
"language": "语言",
|
||||
"languageSub": "内置简体中文与英语,可通过插件扩展更多语言",
|
||||
"logLevel": "日志级别",
|
||||
"logLevelCustom": "自定义",
|
||||
"logLevelDesc": "排查问题时再调高",
|
||||
"macosSlaButton": "查看许可协议",
|
||||
"macosSlaNotice": "使用此软件必须接受软件附带的原始许可协议。",
|
||||
"macosVersion": "macOS 版本",
|
||||
"memCommitHint": "Windows 还能分配 {avail} GB · 推荐 {rec} GB",
|
||||
"memOverHint": "超过推荐值,启动时可能分配失败",
|
||||
"memRecHint": "推荐 {rec} GB · 本机共 {n} GB",
|
||||
"minimizeToTray": "关闭窗口时最小化到系统托盘",
|
||||
"minimizeToTraySub": "关闭窗口后剪贴板和共享文件夹继续工作,可从托盘启停虚拟机",
|
||||
"multiDisplayHint": "{n, plural, other {检测到 # 块显示器,排列方式在 macOS「系统设置 › 显示器」里调整}}",
|
||||
"navHasIssue": "这一页有需要修改的项",
|
||||
"networkDesc": "通过 Windows 的网络连接上网",
|
||||
"networkOfflineHint": "离线安装默认关闭;看到「设置助理」后退出恢复模式并重启即可联网",
|
||||
"networkTitle": "网络",
|
||||
"next": "下一步",
|
||||
"noChanges": "没有更改",
|
||||
"offlineListFailed": "无法读取 Apple 的版本列表",
|
||||
"opencore": "OpenCore",
|
||||
"optAuto": "已自动开启",
|
||||
"optAvailable": "可用",
|
||||
"optExperimental": "实验性",
|
||||
"optKernelIrqchipExp": "实验性:开启可能更快,启动卡住就改回「自动」(Win10 上自动为关闭)",
|
||||
"optKernelIrqchipNestedErr": "当前 Windows 不支持({code}),「自动」会保持关闭",
|
||||
"optKernelIrqchipRec": "由 Windows 直接处理中断,磁盘和多核更流畅。「自动」即开启",
|
||||
"optKernelIrqchipUnavailable": "当前电脑不支持",
|
||||
"optKernelIrqchipWin10NoPatch": "Win10 上需要先更新运行时才能开启",
|
||||
"optPCoreSub": "仅调度到性能核({detail}),减少卡顿",
|
||||
"optPCoreUnavailable": "当前处理器无大小核架构,无需开启",
|
||||
"optRecommended": "推荐",
|
||||
"optSchedBackground": "后台服务",
|
||||
"optSchedNowBackground": "当前为「后台服务」,适合虚拟机在后台运行(影响整个 Windows)",
|
||||
"optSchedNowPrograms": "当前为「程序优先」,虚拟机在后台时可能变慢,建议改为「后台服务」(影响整个 Windows)",
|
||||
"optSchedOpen": "更改…",
|
||||
"optSchedPrograms": "程序优先",
|
||||
"optSchedSub": "选「后台服务」,虚拟机在后台时更稳定(影响整个 Windows)",
|
||||
"optSchedTitle": "Windows 处理器调度",
|
||||
"optUnavailable": "不可用",
|
||||
"pendingChanges": "{n, plural, other {# 项更改,下次启动生效}}",
|
||||
"platformReadonly": "机型、序列号等平台身份信息不在界面显示",
|
||||
"recommendedBadge": "推荐",
|
||||
"resCustom": "自定义",
|
||||
"resCustomSub": "宽 × 高",
|
||||
"resFullscreen": "全屏",
|
||||
"resInvalid": "格式为 宽x高,例如 2560x1600",
|
||||
"resNativeBadge": "原生",
|
||||
"resetAll": "全部还原",
|
||||
"resetField": "还原为当前值",
|
||||
"runtimeDelete": "删除运行时",
|
||||
"runtimeDeleteConfirm": "确认删除",
|
||||
"runtimeDeleted": "已删除运行时 {commit}",
|
||||
"secondsUnit": "秒",
|
||||
"settingsAppearance": "外观与语言",
|
||||
"settingsGeneral": "常规",
|
||||
"settingsTitle": "{name}",
|
||||
"smbiosApplied": "已写入新的 OpenCore 设备码,下次启动虚拟机生效",
|
||||
"smbiosApply": "写入新设备码",
|
||||
"smbiosCheckHint": "建议将序列号复制到 checkcoverage.apple.com 确认显示「无效序列号」(未被真机占用)后再写入。",
|
||||
"smbiosCopySerial": "复制序列号",
|
||||
"smbiosDesc": "写入 OpenCore 的序列号、主板号 (MLB) 与 UUID,用于 Apple 服务识别。ROM 与虚拟网卡 MAC 保持同步,换码时不会修改。",
|
||||
"smbiosDialogSub": "只修改序列号、MLB 与 SystemUUID,保留原 ROM(网卡 MAC)与 NVRAM",
|
||||
"smbiosDialogTitle": "更换 OpenCore 设备码",
|
||||
"smbiosGenerate": "随机生成一组",
|
||||
"smbiosHide": "隐藏",
|
||||
"smbiosLoadFailed": "无法读取 OpenCore 设备码",
|
||||
"smbiosMLB": "主板号 (MLB)",
|
||||
"smbiosModel": "机型",
|
||||
"smbiosROM": "网卡 ROM",
|
||||
"smbiosRotateBtn": "一键换码…",
|
||||
"smbiosSerial": "序列号",
|
||||
"smbiosShow": "显示完整码",
|
||||
"smbiosStopRequired": "请先彻底关机(不能处于运行或休眠状态)",
|
||||
"smbiosTitle": "设备身份 (SMBIOS)",
|
||||
"smbiosUUID": "系统 UUID",
|
||||
"smbiosWarning": "换码前请先在 macOS 中退出 Apple 账户并彻底关机;换码后首次开机可能弹出「设置助理」,iCloud / App Store 需重新登录。",
|
||||
"sourceDisk": "已有虚拟磁盘(.qcow2)",
|
||||
"sourceInstaller": "本地安装器镜像(.img / .dmg)",
|
||||
"sshForward": "SSH 端口转发",
|
||||
"sshNeedsNetwork": "需要先开启网络",
|
||||
"sshOffDesc": "从 Windows 用 SSH 登录 macOS",
|
||||
"sshPort": "SSH 转发端口",
|
||||
"startAfterCreate": "创建后立即启动",
|
||||
"statsCPU": "QEMU CPU",
|
||||
"statsDisk": "磁盘占用",
|
||||
"statsDiskSub": "实际 {actual} / 上限 {virtual}",
|
||||
"statsMemory": "宿主机内存",
|
||||
"statsUptime": "运行时长",
|
||||
"stopBeforeDiskOp": "关机后才能操作",
|
||||
"stopTimeout": "关机等待时间",
|
||||
"stopTimeoutHint": "0 表示一直等待",
|
||||
"storageBreakdownTitle": "空间分布",
|
||||
"storageInstallers": "镜像",
|
||||
"storageRuntimes": "Reims-Go",
|
||||
"storageVMs": "虚拟机文件",
|
||||
"syncHostMemorySMBIOS": "同步宿主机内存规格",
|
||||
"syncHostMemorySMBIOSSub": "在 macOS「关于本机」中显示宿主机真实内存频率与代数(当前:{spec}),下次启动生效",
|
||||
"syncHostMemorySMBIOSUnavailable": "未能从宿主机 SMBIOS 读取物理内存频率,虚拟机将保持默认的 2666 MHz DDR4",
|
||||
"themeLabel": "外观",
|
||||
"themePluginDarkDisabled": "默认主题插件已停用,深色与跟随系统外观不可用",
|
||||
"themePluginLightDisabled": "当前主题仅支持深色外观",
|
||||
"updateDownloadInstall": "下载并安装",
|
||||
"updateDownloadingSub": "正在下载 {v}",
|
||||
"updateFailedSub": "下载或校验失败,可以重试",
|
||||
"updateReadySub": "{v} 已下载并通过校验,重启 Reims-Go 即可完成更新",
|
||||
"updateReleaseNotes": "发行说明",
|
||||
"useDefault": "恢复默认",
|
||||
"vcpus": "虚拟处理器",
|
||||
"vmDir": "存放目录",
|
||||
"vmName": "名称",
|
||||
"welcomeCheckHost": "先完成内核环境配置 →",
|
||||
"welcomeSub": "选择系统来源、分配核数与显卡,几步完成配置",
|
||||
"welcomeTitle": "创建第一台 macOS 虚拟机",
|
||||
"whpxMissing": "启用后需要重启 Windows",
|
||||
"whpxMissingShort": "未启用",
|
||||
"whpxNoHv": "在 BIOS 中开启 Intel VT-x / AMD-V",
|
||||
"whpxNoHvShort": "未激活",
|
||||
"whpxReady": "就绪",
|
||||
"whpxTitle": "WHPX",
|
||||
"whpxUnsupported": "当前不是 Windows 宿主",
|
||||
"whpxUnsupportedShort": "不支持",
|
||||
}
|
||||
|
||||
export const settingsEn: Record<string, string> = {
|
||||
"aboutCommunity": "Community \u0026 support",
|
||||
"aboutCopyDiscord": "Copy invite link",
|
||||
"aboutCopyQQGroup": "Copy group ID",
|
||||
"aboutDiscord": "Discord community",
|
||||
"aboutDiscordSub": "Chat with users, share hardware compatibility, test alphas and build plugins",
|
||||
"aboutIssueSub": "Report a problem or suggest a feature on GitHub",
|
||||
"aboutJoinDiscord": "Join server",
|
||||
"aboutJoinQQGroup": "Join group",
|
||||
"aboutLicensesOpenGitHub": "View on GitHub",
|
||||
"aboutLicensesSub": "Apache-2.0 license and third-party notices (available offline)",
|
||||
"aboutLicensesTabLicense": "Apache-2.0 License",
|
||||
"aboutLicensesTabNotice": "Third-party notices",
|
||||
"aboutLicensesTitle": "Open-source licenses",
|
||||
"aboutLicensesView": "View",
|
||||
"aboutProjectSub": "Source code, releases and docs on GitHub",
|
||||
"aboutQQGroup": "QQ Group",
|
||||
"aboutQQGroupSub": "Launch QQ directly to join for community support and feedback",
|
||||
"aboutQQLaunchFailed": "Couldn’t launch QQ — copy the group ID to join manually",
|
||||
"aboutQQNotInstalled": "QQ not installed",
|
||||
"aboutQQNotInstalledSub": "Local QQ wasn’t detected — copy the group ID to join manually",
|
||||
"aboutTagline": "Run a GPU-accelerated macOS virtual machine on Windows — prebuilt, ready out of the box.",
|
||||
"activate": "Use",
|
||||
"affinityApplyNow": "Apply Now",
|
||||
"affinityAvoidLPE": "Exclude LP-E",
|
||||
"affinityConfigure": "Configure…",
|
||||
"affinityEcoQoS": "Disable Windows EcoQoS power throttling",
|
||||
"affinityEcoQoSDesc": "Prevents Windows 11 from parking unfocused/background QEMU threads onto 2 low-power cores",
|
||||
"affinityExcludeCPU0": "Exclude CPU 0",
|
||||
"affinityLiveMask": "Active in Windows: {mask} ({count} threads)",
|
||||
"affinityModeAll": "All CPUs",
|
||||
"affinityModeAllHint": "Allows Windows to schedule QEMU across all host logical processors.",
|
||||
"affinityModeAuto": "Auto",
|
||||
"affinityModeAutoHint": "Follows global policy and avoids oversubscription and slow LP-E cores on hybrid CPUs.",
|
||||
"affinityModeCustom": "Custom",
|
||||
"affinityModeCustomHint": "Check the host logical CPUs allowed to run QEMU — identical to Windows Task Manager affinity.",
|
||||
"affinityModeNonLPE": "P + E",
|
||||
"affinityModeNonLPEHint": "Runs QEMU on P + E cores while excluding slow SoC LP-E cores.",
|
||||
"affinityModePCores": "P-Cores",
|
||||
"affinityModePCoresHint": "Restricts QEMU to performance cores (P-cores) to minimize scheduling jitter.",
|
||||
"affinityNeedOne": "Select at least 1 logical CPU",
|
||||
"affinityOnlyPCores": "P-cores only",
|
||||
"affinityOversubWarn": "Only {selected} logical CPUs selected for {vcpus} guest vCPUs; this may cause noticeable stalls.",
|
||||
"affinityPhysicalOnly": "Physical cores only",
|
||||
"affinityRowDesc": "Choose which cores the VM runs on. Applies immediately",
|
||||
"affinitySave": "Save",
|
||||
"affinitySelectAll": "All CPUs",
|
||||
"affinitySelectedSummary": "{selected} / {total} logical CPUs selected · Mask {mask}",
|
||||
"affinitySubtitleRunning": "Running (PID {pid}) · {vcpus} vCPU · Applies immediately",
|
||||
"affinitySubtitleStopped": "Stopped · {vcpus} vCPU · Applied on next start",
|
||||
"affinitySummaryAll": "All CPUs ({count}T)",
|
||||
"affinitySummaryAuto": "Auto ({eff} · {count}T)",
|
||||
"affinitySummaryCustom": "Custom ({count}T · {mask})",
|
||||
"affinitySummaryNonLPE": "P + E ({count}T · {mask})",
|
||||
"affinitySummaryPCores": "P-Cores ({count}T · {mask})",
|
||||
"affinityTitle": "CPU cores",
|
||||
"appCheckUpdate": "Check for updates",
|
||||
"appDownloadUpdate": "Download",
|
||||
"appUpToDate": "Up to date",
|
||||
"appUpdateAvailable": "New stable release {v} available",
|
||||
"appUpdateAvailableAlpha": "New alpha release {v} available",
|
||||
"appUpdateAvailableDev": "New dev build {v} available",
|
||||
"appUpdateChannelAlpha": "Alpha",
|
||||
"appUpdateChannelDev": "Dev",
|
||||
"appUpdateChannelStable": "Stable",
|
||||
"appUpdateChannelSubKeepOld": "Receive {channel} prereleases; previous executable and downloaded installers are kept on startup for rollback",
|
||||
"appUpdateChannelSubStable": "Receive verified stable releases only",
|
||||
"appUpdateChannelTitle": "Update channel",
|
||||
"appUpdateLookupFailed": "Couldn’t check GitHub for updates",
|
||||
"appVersionTitle": "App version",
|
||||
"appliesNextStart": "Applies on next start",
|
||||
"audioBackendAuto": "Auto",
|
||||
"audioBackendDesc": "Silent keeps the macOS sound card but plays nothing; useful for troubleshooting",
|
||||
"audioBackendDsound": "DirectSound",
|
||||
"audioBackendNone": "Silent",
|
||||
"audioBackendTitle": "Sound output",
|
||||
"audioDesc": "Plays macOS sound through Windows",
|
||||
"audioDisabledReason": "Enable audio first",
|
||||
"audioTroubleshootNote": "If audio crackles, set the Windows sound format to 48000 Hz. If the mic is silent, check Windows Privacy › Microphone",
|
||||
"autoPinPCores": "Pin to performance cores on start",
|
||||
"back": "Back",
|
||||
"captureInput": "Capture keyboard and mouse on click",
|
||||
"captureInputHint": "When on, shortcuts like ⌘Tab go to macOS; when off, Win and Alt+Tab stay with Windows",
|
||||
"catAdvanced": "Advanced",
|
||||
"catAudio": "Audio",
|
||||
"catCompute": "CPU \u0026 Memory",
|
||||
"catGeneral": "General",
|
||||
"catGraphics": "Graphics \u0026 displays",
|
||||
"catInput": "Keyboard \u0026 pointer",
|
||||
"catInputAudio": "Input \u0026 Audio",
|
||||
"catLogs": "Logs",
|
||||
"catNetwork": "Network",
|
||||
"catStorage": "Storage",
|
||||
"catStorageNet": "Storage \u0026 Network",
|
||||
"choose": "Browse…",
|
||||
"configured": "Configured",
|
||||
"coresUnit": "cores",
|
||||
"cpuOverHint": "Leaves Windows fewer than 2 threads; your PC may slow down",
|
||||
"cpuRecHint": "{rec} cores recommended · this PC has {n} threads",
|
||||
"defenderCopyCommand": "Copy exclusion command",
|
||||
"defenderExclusionDesc": "Real-time scanning can slow VM disk access. You can exclude the data folder {path} in Windows Security.",
|
||||
"defenderExclusionTitle": "Windows Defender real-time protection exclusions",
|
||||
"defenderOpenSecurity": "Open Windows Security",
|
||||
"diskCompactAction": "Reclaim now",
|
||||
"diskCompactDesc": "Gives space from files deleted in macOS back to Windows. Needs about as much free space as the disk uses now",
|
||||
"diskCompactDone": "Reclaimed {reclaimed} ({before} → {after})",
|
||||
"diskCompactNoGain": "Nothing to reclaim",
|
||||
"diskCompactQcow2Only": "This disk does not support reclaiming space",
|
||||
"diskCompactTitle": "Reclaim space",
|
||||
"diskController": "Disk interface",
|
||||
"diskControllerInstallHint": "Keep SATA while installing; switch to NVMe after ejecting the installer",
|
||||
"diskControllerNvmeHint": "NVMe is faster",
|
||||
"diskControllerNvmeReadyHint": "Fast and works with Recovery. Recommended",
|
||||
"diskControllerVirtioHint": "Lower overhead but experimental; switch back to NVMe if you hit problems",
|
||||
"diskControllerWarn": "Eject the installer before switching",
|
||||
"diskMode": "Use disk as",
|
||||
"diskModeCopy": "A copy — original untouched",
|
||||
"diskModeInPlace": "In place",
|
||||
"diskOptimizeAction": "Optimize disk layout",
|
||||
"diskOptimizeDesc": "Splits default 64 KiB clusters into 2 KiB subclusters to reduce small-write overhead while compacting the disk.",
|
||||
"diskOptimizeDone": "{before} → {after}, reclaimed {reclaimed}. {status}.",
|
||||
"diskOptimizeEnabled": "extended_l2 is enabled",
|
||||
"diskOptimizeInactive": "extended_l2 is inactive",
|
||||
"diskOptimizeTitle": "QCOW2 subcluster optimization",
|
||||
"diskResizeAction": "Expand",
|
||||
"diskResizeDesc": "Grow only. Afterwards, run the command shown in macOS Terminal to use the new space",
|
||||
"diskResizeDone": "Expanded to {size}. Run this in macOS Terminal:",
|
||||
"diskResizeTitle": "Expand disk",
|
||||
"diskRewriteBusy": "Another disk operation is in progress.",
|
||||
"diskRewriteOverlay": "This disk shares a backing image and cannot be rewritten directly.",
|
||||
"diskRewriteSnapshots": "Delete internal restore points first to preserve them when rewriting the disk.",
|
||||
"diskSize": "Disk size",
|
||||
"diskSizeHint": "Grows as it fills",
|
||||
"diskUsageSummary": "{actual} used of {virtual}",
|
||||
"displayGroup": "Displays",
|
||||
"driveShareMaster": "Share Windows drives",
|
||||
"driveShareMasterDesc": "Shows the selected drives in macOS Finder. Applies immediately",
|
||||
"driveShareNeedsTools": "Needs Guest Tools {version} or later: restart the VM, then run the install command in macOS again",
|
||||
"driveShareNoDrives": "No internal fixed disks are available to share",
|
||||
"driveShareReadOnly": "Read-only: macOS can open and copy files but not change them",
|
||||
"driveShareSystem": "System drive with personal files and sign-in data; share with care",
|
||||
"driveShareTitle": "Windows drive sharing",
|
||||
"effectImmediate": "Immediate",
|
||||
"effectNextStart": "Next start",
|
||||
"enableAudio": "Audio",
|
||||
"enableLogs": "Keep graphics and serial logs",
|
||||
"enableNetwork": "Network (NAT)",
|
||||
"enableWHPX": "Enable",
|
||||
"extraArgs": "Extra QEMU arguments",
|
||||
"extraArgsDesc": "Appended to the QEMU command line as is",
|
||||
"failAffinity": "Could not update processor affinity",
|
||||
"folderShareAdd": "Add folder…",
|
||||
"folderShareAddTitle": "Host folders",
|
||||
"folderShareConfirmRWAction": "Enable read-write",
|
||||
"folderShareConfirmRWDesc": "Allow macOS to modify or delete files in \"{name}\" ({path}). Changes apply directly to the host folder.",
|
||||
"folderShareConfirmRWTitle": "Enable read-write access",
|
||||
"folderShareDesc": "Accessible from ReimsSharedFolders on the macOS desktop. Applies immediately",
|
||||
"folderShareEmpty": "No folders added",
|
||||
"folderShareIssueBlocked": "This folder cannot be shared (system, data root, drive root, or external volume)",
|
||||
"folderShareIssueCorruptConfig": "Guest Tools config file is unreadable; original file was kept",
|
||||
"folderShareIssueInvalidMode": "Invalid shared folder mode",
|
||||
"folderShareIssueMissing": "Folder is missing or moved",
|
||||
"folderShareIssueNotFound": "Shared folder entry was not found",
|
||||
"folderShareIssueOverlap": "Overlaps with an existing shared folder",
|
||||
"folderShareIssuePathChanged": "Folder target changed or redirected; sharing paused",
|
||||
"folderShareIssueVolumeMismatch": "Volume identity changed; sharing paused",
|
||||
"folderShareListTitle": "Added folders",
|
||||
"folderShareModeDisabled": "Off",
|
||||
"folderShareModeRO": "Read-only",
|
||||
"folderShareModeRW": "Read-write",
|
||||
"folderShareNeedsTools": "Needs Guest Tools {version} or later: mount Guest Tools on the VM page, restart the VM, and run the install command in macOS again",
|
||||
"folderShareNote": "Internal fixed-disk folders only; new entries default to read-only. CoW clones do not copy folder settings, but keep the source Guest Tools token until Guest Tools is reinstalled on the clone",
|
||||
"folderSharePickTitle": "Choose a folder to share with macOS",
|
||||
"folderShareRemove": "Remove folder",
|
||||
"folderShareTitle": "Custom shared folders",
|
||||
"folderShareWritableWarn": "Read-write: changes and deletions in macOS modify the host folder directly",
|
||||
"footerDisk": "Disk {gb} GB free",
|
||||
"footerMem": "Memory {pct}%",
|
||||
"footerMemAvail": "{avail} GB free",
|
||||
"forceQuitAppButton": "Force quit",
|
||||
"forceQuitAppSub": "Cuts power to running virtual machines. Unsaved data may be lost.",
|
||||
"forceQuitAppTitle": "Force quit Reims-Go",
|
||||
"forceQuitInProgress": "Force quitting…",
|
||||
"fullscreenDecoupledHint": "Fills the monitor; pick native or supersampled HiDPI (e.g. 5120×2880 for 4K 1.5×) below, scaled on the GPU",
|
||||
"fullscreenLaunch": "Launch borderless fullscreen",
|
||||
"fullscreenLaunchHint": "Opens macOS in borderless full screen",
|
||||
"gpuAutoOption": "Automatic (prefers discrete)",
|
||||
"gpuAutoSub": "Will use {name}",
|
||||
"gpuAutoTitle": "Automatic",
|
||||
"gpuCompatUnsupported": "Unsupported",
|
||||
"gpuCompatWarn": "Known issue",
|
||||
"gpuCustomIcd": "Custom Vulkan ICD",
|
||||
"gpuDiscrete": "Discrete",
|
||||
"gpuIntegrated": "Integrated",
|
||||
"gpuKindDiscrete": "Discrete",
|
||||
"gpuKindIntegrated": "Integrated",
|
||||
"gpuRecommended": "Recommended",
|
||||
"gpuSelect": "GPU",
|
||||
"gpuSvgaReason": "VMware SVGA does not use the host GPU",
|
||||
"gpuSwitchSvga": "Use VMware SVGA",
|
||||
"gpuUnavailableHint": "No GPU available for acceleration; try VMware SVGA",
|
||||
"gpuUnknown": "Unknown",
|
||||
"gpuVirtual": "Virtual",
|
||||
"graphicsBackend": "Virtual graphics",
|
||||
"graphicsReimsDesc": "Accelerates Metal on the host GPU. Recommended",
|
||||
"graphicsReimsShort": "Reims vGPU",
|
||||
"graphicsRunningReason": "Shut down the VM to change this",
|
||||
"graphicsSvgaDesc": "No acceleration; for troubleshooting only",
|
||||
"graphicsSvgaShort": "VMware SVGA",
|
||||
"groupGraphics": "Graphics",
|
||||
"groupMacOS": "macOS",
|
||||
"groupPerformance": "Performance",
|
||||
"groupQemu": "QEMU",
|
||||
"gtInstallCmd": "Install command",
|
||||
"guestLangHint": "Used by Recovery, Setup Assistant and the login window; a US keyboard layout keeps Terminal input reliable",
|
||||
"guestLangSettingsHint": "Used by Recovery, Setup Assistant and the login window",
|
||||
"guestLangShort": "System language",
|
||||
"guestMemory": "Memory",
|
||||
"guestToolsConnected": "Connected",
|
||||
"guestToolsPreventSleepSub": "Keeps macOS awake while idle; applies immediately",
|
||||
"guestToolsReady": "Configured",
|
||||
"hidpiPresetBadge": "HiDPI",
|
||||
"hostAudioInput": "Windows microphone",
|
||||
"hostAudioMissingIn": "No microphone found; macOS will record silence",
|
||||
"hostAudioMissingOut": "No speakers or headphones found; the VM will be silent",
|
||||
"hostAudioOutput": "Windows playback",
|
||||
"hostCPU": "CPU",
|
||||
"hostCoresThreads": "{c} cores · {t} threads",
|
||||
"hostDataRoot": "Data folder",
|
||||
"hostDisk": "Free space",
|
||||
"hostDisplayPrimary": "Primary",
|
||||
"hostDisplays": "Physical displays",
|
||||
"hostGPUs": "Graphics cards",
|
||||
"hostRAM": "Memory",
|
||||
"hostRAMAvail": "{n} GB free",
|
||||
"hostRAMTotal": "{n} GB total",
|
||||
"hostRuntime": "Runtime",
|
||||
"hostWHPX": "Windows Hypervisor Platform",
|
||||
"imagesNoSourcesDesc": "Enable at least one image source plugin (such as macOS Images) in Plugins to browse and download system images.",
|
||||
"imagesNoSourcesTitle": "No image source plugins enabled",
|
||||
"imagesOpenPlugins": "Open Plugins",
|
||||
"imagesSourcesLabel": "Image sources",
|
||||
"installersAvailable": "Releases from Apple",
|
||||
"installersCreateVM": "Create VM",
|
||||
"installersDelete": "Delete",
|
||||
"installersDeleteConfirm": "Confirm delete",
|
||||
"installersDownload": "Download",
|
||||
"installersDownloaded": "Downloaded",
|
||||
"installersDownloadingForVM": "Downloading for {vm}",
|
||||
"installersDownloadingPct": "Downloading {p}%",
|
||||
"installersEmpty": "No images downloaded yet",
|
||||
"installersHint": "Downloaded images can be reused for new VMs",
|
||||
"installersKindOffline": "Offline installer",
|
||||
"installersKindOnline": "Online recovery",
|
||||
"installersLatest": "Latest",
|
||||
"installersNoSpace": "Not enough space: needs about {need} GB, {free} GB free",
|
||||
"installersOlder": "{count, plural, one {# older version} other {# older versions}}",
|
||||
"installersPartial": "Partly downloaded",
|
||||
"installersQueued": "Queued",
|
||||
"installersQueuedForVM": "Queued for {vm}",
|
||||
"installersResume": "Resume",
|
||||
"installersTitle": "Images",
|
||||
"installersWaitingVM": "{vm} waiting",
|
||||
"kernelIrqchipAuto": "Auto",
|
||||
"kernelIrqchipLabel": "Interrupt acceleration",
|
||||
"kernelIrqchipOff": "Off",
|
||||
"kernelIrqchipOn": "On",
|
||||
"keymapGroupNote": "Applies only while this VM is focused. Ctrl+Alt+Win is reserved for releasing capture.",
|
||||
"keymapGroupTitle": "Modifier keys",
|
||||
"keymapGuestDefault": "Default",
|
||||
"keymapGuestDisabled": "Disabled",
|
||||
"keymapGuestEsc": "Esc",
|
||||
"keymapGuestLcmd": "Left ⌘ Command",
|
||||
"keymapGuestLctrl": "Left ⌃ Control",
|
||||
"keymapGuestLopt": "Left ⌥ Option",
|
||||
"keymapGuestRcmd": "Right ⌘ Command",
|
||||
"keymapGuestRctrl": "Right ⌃ Control",
|
||||
"keymapGuestRopt": "Right ⌥ Option",
|
||||
"keymapHostCapslock": "Caps Lock",
|
||||
"keymapHostLalt": "Left Alt",
|
||||
"keymapHostLctrl": "Left Ctrl",
|
||||
"keymapHostLwin": "Left Win",
|
||||
"keymapHostRalt": "Right Alt",
|
||||
"keymapHostRctrl": "Right Ctrl",
|
||||
"keymapHostRwin": "Right Win",
|
||||
"keymapInactive": "Modifier mapping is inactive",
|
||||
"keymapInputServiceRequired": "Enable Host Input Service to use modifier mapping",
|
||||
"keymapPending": "Waiting for Guest Tools to activate modifier mapping",
|
||||
"keymapPresetCustom": "Custom",
|
||||
"keymapPresetOff": "Off",
|
||||
"keymapPresetSwapAltWin": "Alt ↔ Win",
|
||||
"keymapPresetTitle": "Preset",
|
||||
"keymapPresetWinToCmd": "Win → ⌘",
|
||||
"keymapRunning": "Active while this VM is focused",
|
||||
"keymapStopped": "Applies when this VM is running",
|
||||
"keymapUpgrade": "Update Guest Tools to version {version}",
|
||||
"keymapWaiting": "Waiting for Guest Tools to connect",
|
||||
"language": "Language",
|
||||
"languageSub": "Simplified Chinese and English built in; add more via plugins",
|
||||
"logLevel": "Log level",
|
||||
"logLevelCustom": "Custom",
|
||||
"logLevelDesc": "Raise only when troubleshooting",
|
||||
"macosSlaButton": "View SLA",
|
||||
"macosSlaNotice": "Use of this software requires acceptance of the original license agreement included with the software.",
|
||||
"macosVersion": "macOS version",
|
||||
"memCommitHint": "Windows can allocate {avail} GB more · {rec} GB recommended",
|
||||
"memOverHint": "Above the recommendation; the VM may fail to start",
|
||||
"memRecHint": "{rec} GB recommended · this PC has {n} GB",
|
||||
"minimizeToTray": "Minimize to system tray on close",
|
||||
"minimizeToTraySub": "Clipboard and shared folders keep working; start and stop VMs from the tray",
|
||||
"multiDisplayHint": "{n, plural, one {# display detected; arrange displays inside macOS System Settings › Displays} other {# displays detected; arrange them inside macOS System Settings › Displays}}",
|
||||
"navHasIssue": "This page has settings to fix",
|
||||
"networkDesc": "Uses the Windows network connection",
|
||||
"networkOfflineHint": "Off by default for offline installs. Exit recovery and restart when Setup Assistant appears to enable networking",
|
||||
"networkTitle": "Network",
|
||||
"next": "Next",
|
||||
"noChanges": "No changes",
|
||||
"offlineListFailed": "Couldn’t read Apple’s release list",
|
||||
"opencore": "OpenCore",
|
||||
"optAuto": "Automatic",
|
||||
"optAvailable": "Available",
|
||||
"optExperimental": "Experimental",
|
||||
"optKernelIrqchipExp": "Experimental: may be faster. If startup hangs, go back to Auto (off on Windows 10)",
|
||||
"optKernelIrqchipNestedErr": "Not supported by this Windows ({code}); Auto keeps it off",
|
||||
"optKernelIrqchipRec": "Windows handles interrupts directly for smoother disk and multi-core work. Auto turns it on",
|
||||
"optKernelIrqchipUnavailable": "Not supported on this PC",
|
||||
"optKernelIrqchipWin10NoPatch": "On Windows 10, update the runtime to turn this on",
|
||||
"optPCoreSub": "Schedule QEMU on performance cores only ({detail})",
|
||||
"optPCoreUnavailable": "CPU has no hybrid P/E cores",
|
||||
"optRecommended": "Recommended",
|
||||
"optSchedBackground": "Background services",
|
||||
"optSchedNowBackground": "Set to Background services, which suits a VM running in the background (affects all of Windows)",
|
||||
"optSchedNowPrograms": "Set to Programs, so the VM may slow down in the background. Background services is recommended (affects all of Windows)",
|
||||
"optSchedOpen": "Change…",
|
||||
"optSchedPrograms": "Programs",
|
||||
"optSchedSub": "Background services keeps the VM steady in the background (affects all of Windows)",
|
||||
"optSchedTitle": "Windows processor scheduling",
|
||||
"optUnavailable": "Unavailable",
|
||||
"pendingChanges": "{n, plural, one {# change · applies on next start} other {# changes · applies on next start}}",
|
||||
"platformReadonly": "Model, serial number and other platform identity are never shown",
|
||||
"recommendedBadge": "Recommended",
|
||||
"resCustom": "Custom",
|
||||
"resCustomSub": "Width × height",
|
||||
"resFullscreen": "Full screen",
|
||||
"resInvalid": "Use WIDTHxHEIGHT, e.g. 2560x1600",
|
||||
"resNativeBadge": "Native",
|
||||
"resetAll": "Revert all",
|
||||
"resetField": "Revert to current value",
|
||||
"runtimeDelete": "Delete runtime",
|
||||
"runtimeDeleteConfirm": "Confirm delete",
|
||||
"runtimeDeleted": "Removed runtime {commit}",
|
||||
"secondsUnit": "s",
|
||||
"settingsAppearance": "Appearance \u0026 language",
|
||||
"settingsGeneral": "General",
|
||||
"settingsTitle": "{name}",
|
||||
"smbiosApplied": "Updated OpenCore SMBIOS identity. Applies on next start",
|
||||
"smbiosApply": "Write new codes",
|
||||
"smbiosCheckHint": "Tip: check the serial at checkcoverage.apple.com and verify it reports invalid (not registered to a real Mac) before writing.",
|
||||
"smbiosCopySerial": "Copy serial",
|
||||
"smbiosDesc": "Serial, MLB and UUID written to OpenCore for Apple services. ROM stays synced with the virtual NIC MAC and is left unchanged.",
|
||||
"smbiosDialogSub": "Updates Serial, MLB and SystemUUID only; keeps ROM (NIC MAC) and NVRAM intact",
|
||||
"smbiosDialogTitle": "Rotate OpenCore SMBIOS",
|
||||
"smbiosGenerate": "Generate random",
|
||||
"smbiosHide": "Hide",
|
||||
"smbiosLoadFailed": "Could not read OpenCore SMBIOS",
|
||||
"smbiosMLB": "MLB",
|
||||
"smbiosModel": "Model",
|
||||
"smbiosROM": "NIC ROM",
|
||||
"smbiosRotateBtn": "Rotate codes…",
|
||||
"smbiosSerial": "Serial",
|
||||
"smbiosShow": "Reveal",
|
||||
"smbiosStopRequired": "Shut down the VM completely first (not running or suspended)",
|
||||
"smbiosTitle": "Device identity (SMBIOS)",
|
||||
"smbiosUUID": "System UUID",
|
||||
"smbiosWarning": "Sign out of Apple Account in macOS and shut down completely before rotating. First boot may show Setup Assistant and require signing in to iCloud / App Store again.",
|
||||
"sourceDisk": "Existing virtual disk (.qcow2)",
|
||||
"sourceInstaller": "Local installer image (.img / .dmg)",
|
||||
"sshForward": "SSH port forwarding",
|
||||
"sshNeedsNetwork": "Turn on the network first",
|
||||
"sshOffDesc": "Log in to macOS over SSH from Windows",
|
||||
"sshPort": "SSH forward port",
|
||||
"startAfterCreate": "Start after creating",
|
||||
"statsCPU": "QEMU CPU",
|
||||
"statsDisk": "Disk usage",
|
||||
"statsDiskSub": "{actual} actual / {virtual} max",
|
||||
"statsMemory": "Host RAM",
|
||||
"statsUptime": "Uptime",
|
||||
"stopBeforeDiskOp": "Shut down the VM first",
|
||||
"stopTimeout": "Shutdown timeout",
|
||||
"stopTimeoutHint": "0 waits indefinitely",
|
||||
"storageBreakdownTitle": "Storage breakdown",
|
||||
"storageInstallers": "Images",
|
||||
"storageRuntimes": "Reims-Go",
|
||||
"storageVMs": "VM files",
|
||||
"syncHostMemorySMBIOS": "Sync host memory specs",
|
||||
"syncHostMemorySMBIOSSub": "Show the host's actual memory speed and generation ({spec}) in macOS About This Mac; applies on next start",
|
||||
"syncHostMemorySMBIOSUnavailable": "Could not read host SMBIOS memory speed; VMs keep the default 2666 MHz DDR4",
|
||||
"themeLabel": "Appearance",
|
||||
"themePluginDarkDisabled": "Default theme plugin is disabled; dark and system appearances are unavailable",
|
||||
"themePluginLightDisabled": "The active theme supports dark appearance only",
|
||||
"updateDownloadInstall": "Download and install",
|
||||
"updateDownloadingSub": "Downloading {v}",
|
||||
"updateFailedSub": "Download or verification failed; try again",
|
||||
"updateReadySub": "{v} is downloaded and verified; restart Reims-Go to finish",
|
||||
"updateReleaseNotes": "Release notes",
|
||||
"useDefault": "Use Default",
|
||||
"vcpus": "Virtual CPUs",
|
||||
"vmDir": "Folder",
|
||||
"vmName": "Name",
|
||||
"welcomeCheckHost": "Set up Engine first →",
|
||||
"welcomeSub": "Pick an installer, assign cores and GPU, and launch in minutes",
|
||||
"welcomeTitle": "Create your first macOS VM",
|
||||
"whpxMissing": "Windows restarts after enabling",
|
||||
"whpxMissingShort": "Off",
|
||||
"whpxNoHv": "Turn on Intel VT-x / AMD-V in BIOS",
|
||||
"whpxNoHvShort": "Inactive",
|
||||
"whpxReady": "Ready",
|
||||
"whpxTitle": "WHPX",
|
||||
"whpxUnsupported": "This host isn’t Windows",
|
||||
"whpxUnsupportedShort": "Unsupported",
|
||||
}
|
||||
|
||||
registerBuiltinDomain(settingsZh, settingsEn)
|
||||
@@ -0,0 +1,433 @@
|
||||
// Code generated by cmd/i18ngen; DO NOT EDIT.
|
||||
|
||||
export const vmZh: Record<string, string> = {
|
||||
"attachGuestTools": "挂载 Guest Tools",
|
||||
"attachInstaller": "挂载离线镜像",
|
||||
"brokenHint": "这台虚拟机的配置无法读取",
|
||||
"cloneConfirm": "立即派生",
|
||||
"cloneDesc": "用写时复制瞬间创建副本,几乎不占空间,原虚拟机不受影响",
|
||||
"cloneNameLabel": "新虚拟机名称",
|
||||
"cloneTitle": "从「{name}」派生 CoW 副本",
|
||||
"cloneVM": "秒级派生副本 (CoW)",
|
||||
"connGroup": "连接",
|
||||
"copyScreenshot": "截屏并复制",
|
||||
"cores": "{n, plural, other {# 核}}",
|
||||
"deleteConfirm": "删除",
|
||||
"deleteDesc": "配置和虚拟磁盘会被移除,无法撤销",
|
||||
"deleteDescKeep": "只移除配置,磁盘文件留在原目录",
|
||||
"deleteKeepFiles": "保留磁盘文件",
|
||||
"deleteTitle": "删除「{name}」?",
|
||||
"deliverFileShort": "发送文件…",
|
||||
"detachGuestTools": "弹出工具盘",
|
||||
"diagAhciUpgradeHint": "系统盘还是 SATA,改成 NVMe 读写更快",
|
||||
"diagBackingChainBroken": "当前系统盘 CoW 派生链({depth} 层)存在缺失或无法读取的父镜像,请检查源虚拟机磁盘",
|
||||
"diagBackingChainWarn": "当前系统盘 CoW 派生链深度为 {depth} 层(≥ 2),未分配簇读穿透会拖慢小文件 I/O,建议合并为独立镜像或基于基础镜像重新派生",
|
||||
"diagExternalDriveWarn": "数据目录在外置或网络盘上({dir}),读写会明显变慢",
|
||||
"diagHighMemWarn": "宿主内存已用 {pct}%,虚拟机可能会卡顿",
|
||||
"discardSuspend": "放弃挂起状态",
|
||||
"discardSuspendConfirm": "放弃并关机",
|
||||
"discardSuspendDesc": "将删除已保存的内存与设备状态并回到关机状态,macOS 中尚未保存的工作会丢失,且无法撤销。",
|
||||
"discardSuspendTitle": "放弃「{name}」的挂起状态?",
|
||||
"displayNameEdit": "点按以修改显示名称",
|
||||
"displayNameEditEllipsis": "修改显示名称…",
|
||||
"displayNameLabel": "显示名称",
|
||||
"displayNameTip": "显示名称 · 虚拟机名称为 {name}(点按修改)",
|
||||
"dropFilesHint": "松开以投递到 macOS 共享目录",
|
||||
"enterFullscreen": "进入全屏",
|
||||
"enterRecovery": "进入恢复模式",
|
||||
"exitFullscreen": "退出全屏",
|
||||
"exportDiagnostics": "导出排障日志 (.zip)",
|
||||
"factBackingChain": "CoW 派生链",
|
||||
"factCPU": "处理器",
|
||||
"factDisk": "存储",
|
||||
"factGraphics": "图形",
|
||||
"factMemory": "内存",
|
||||
"failAttachInstaller": "挂载镜像失败",
|
||||
"failCloneVM": "派生 CoW 副本失败",
|
||||
"failDelete": "删除失败",
|
||||
"failDiscardSuspend": "放弃挂起状态失败",
|
||||
"failEject": "弹出安装盘失败",
|
||||
"failEnterRecovery": "进入恢复模式失败",
|
||||
"failExportDiagnostics": "导出排障日志失败",
|
||||
"failFinishInstall": "退出恢复模式失败",
|
||||
"failFocus": "无法定位虚拟机窗口",
|
||||
"failFullscreen": "无法切换全屏",
|
||||
"failGuestTools": "Guest Tools 操作失败",
|
||||
"failOpenFolder": "无法打开文件夹",
|
||||
"failRestart": "重启失败",
|
||||
"failResume": "恢复失败",
|
||||
"failScreenshot": "截屏失败",
|
||||
"failSnapshot": "恢复点操作失败",
|
||||
"failStart": "启动失败",
|
||||
"failStop": "关机失败",
|
||||
"failSuspend": "挂起失败",
|
||||
"failType": "键入失败",
|
||||
"failUpgradeNVMe": "升级到 NVMe 失败",
|
||||
"fieldAudio": "音频",
|
||||
"fieldCPUModel": "CPU 型号",
|
||||
"fieldController": "磁盘控制器",
|
||||
"fieldDir": "目录",
|
||||
"fieldDisk": "磁盘",
|
||||
"fieldGraphicsBackend": "图形后端",
|
||||
"fieldICD": "Vulkan ICD",
|
||||
"fieldKind": "类型",
|
||||
"fieldNetwork": "网络",
|
||||
"fieldVMName": "虚拟机名称",
|
||||
"finishInstall": "退出恢复模式",
|
||||
"gpuAuto": "自动选择 GPU",
|
||||
"gtInstall": "安装…",
|
||||
"gtInstallSub": "在 macOS 终端里运行",
|
||||
"gtNotInstalledDesc": "未安装:挂载工具盘后在 macOS 中运行安装命令",
|
||||
"gtStatusConnected": "已连接",
|
||||
"gtStatusEnabled": "已启用",
|
||||
"gtStatusNone": "未安装",
|
||||
"gtStatusOff": "已停用",
|
||||
"gtStatusOffTip": "Guest Tools 传输服务已在插件页停用,剪贴板、共享文件夹与防休眠都不可用",
|
||||
"gtStatusUpgrade": "需要更新",
|
||||
"gtStatusWaiting": "未连接",
|
||||
"gtStatusWaitingTip": "在 macOS 里运行安装命令后会自动连接",
|
||||
"gtUpdate": "更新…",
|
||||
"guestToolsModeSync": "文件同步模式",
|
||||
"guestToolsModeWebDAV": "WebDAV 挂载",
|
||||
"guestToolsPreventSleep": "防止 macOS 睡眠",
|
||||
"guestToolsSleepActive": "正在保持唤醒",
|
||||
"guestToolsTitle": "Guest Tools",
|
||||
"guestToolsUpgradeHint": "macOS 里的工具是旧版,重新运行安装命令即可升级",
|
||||
"guideBuiltIn1": "启动后在 OpenCore 引导菜单选择「Recovery」",
|
||||
"guideBuiltIn2": "恢复模式可以联网重装;要离线安装就点「挂载离线镜像」",
|
||||
"guideBuiltIn3": "完成后点「退出恢复模式」",
|
||||
"guideKindBuiltIn": "内置恢复",
|
||||
"guideKindOffline": "离线完整安装",
|
||||
"guideKindOnline": "在线恢复安装",
|
||||
"guideOffline1": "不要点「Reinstall macOS Tahoe」,从菜单栏打开「Utilities › Terminal」",
|
||||
"guideOffline2": "运行下面的命令(点键盘图标可直接键入)。它会把空白磁盘抹成 APFS 并开始安装,中途会重启几次:",
|
||||
"guideOffline3": "看到「设置助理」后,点「退出恢复模式」弹出安装盘并恢复网络",
|
||||
"guideStartHint": "启动后在虚拟机窗口查看安装引导",
|
||||
"guideStep1": "打开「磁盘工具」,选中最大的「QEMU HARDDISK Media」(看不到就选 View › Show All Devices),点 Erase:名称 Macintosh HD,格式 APFS,方案 GUID。抹除时可能停顿 10–30 秒,不要强制关机",
|
||||
"guideStep2": "回到恢复主界面,选「Reinstall macOS Tahoe」,装到刚抹好的磁盘,中途会重启几次",
|
||||
"guideStep3": "看到「设置助理」后,点「退出恢复模式」弹出安装盘",
|
||||
"guideTitle": "恢复模式",
|
||||
"netOff": "无网络",
|
||||
"netShared": "共享网络",
|
||||
"onlineRecoveryConfirm": "拉取并挂载(约 1 GB)",
|
||||
"onlineRecoveryDesc": "本地没有恢复镜像。要从 Apple 下载约 1 GB 的恢复镜像并挂载到「{name}」吗?",
|
||||
"onlineRecoveryTitle": "拉取在线恢复镜像?",
|
||||
"openSharedFolder": "打开共享文件夹",
|
||||
"openShort": "打开",
|
||||
"pendingRestartHint": "重启虚拟机后生效",
|
||||
"pendingTitle": "下次启动生效",
|
||||
"pickRecoveryTitle": "选择离线镜像(.img / .dmg)",
|
||||
"restartToApply": "重启以应用",
|
||||
"resume": "恢复",
|
||||
"resumeUnavailable": "切换到支持挂起的内核后可恢复",
|
||||
"sendText": "发送文本到虚拟机…",
|
||||
"sendTextConfirm": "发送 (Ctrl+Enter)",
|
||||
"sendTextDesc": "支持中文、Emoji、宿主机输入法与语音输入,按 Ctrl+Enter 发送到 macOS 当前输入框。",
|
||||
"sendTextDescNoGT": "当前未连接 Guest Tools,仅支持英文/数字等美式键盘字符;安装 Guest Tools 后支持中文与任意文本。",
|
||||
"sendTextPlaceholder": "在这里输入或粘贴要发送到虚拟机的文字…",
|
||||
"sendTextTitle": "发送文本到「{name}」",
|
||||
"sharedFolder": "共享文件夹",
|
||||
"showInstallGuide": "显示安装引导",
|
||||
"showWindow": "显示窗口",
|
||||
"snapshotCreate": "创建恢复点",
|
||||
"snapshotDelete": "删除恢复点",
|
||||
"snapshotEmpty": "尚未创建恢复点,升级系统或大改环境前可先留档",
|
||||
"snapshotHint": "停机快照 · 非异地备份",
|
||||
"snapshotNamePlaceholder": "例如:升级 macOS 前",
|
||||
"snapshotRestore": "回滚",
|
||||
"snapshotRestoreDesc": "当前磁盘在此恢复点之后的改动将被覆盖,且无法撤销。",
|
||||
"snapshotRestoreTitle": "回滚到「{name}」?",
|
||||
"snapshotStopFirst": "停止虚拟机后才可管理恢复点",
|
||||
"snapshotsTitle": "恢复点",
|
||||
"softwareGraphics": "软件渲染",
|
||||
"specCPULiveTip": "处理器 {n} 核,当前占用 {pct}%",
|
||||
"specCPUTip": "{n, plural, other {处理器 # 核}}",
|
||||
"specDiskTip": "存储:{ctl}",
|
||||
"specDiskUsage": "{ctl} · 已用 {used},上限 {max}",
|
||||
"specGraphicsTip": "图形:{gfx}",
|
||||
"specLang": "语言",
|
||||
"specLangTip": "macOS 系统语言:{label}",
|
||||
"specLangTipDetail": "macOS 系统语言:{label}({detail})",
|
||||
"specMemLiveTip": "内存 {mem},虚拟机在宿主上占用 {used}",
|
||||
"specMemTip": "内存 {mem}",
|
||||
"specNetOffTip": "虚拟机没有网络",
|
||||
"specNetSSHTip": "与宿主共享网络连接,SSH 端口 {port}",
|
||||
"specNetTip": "与宿主共享网络连接",
|
||||
"sshMore": "SSH 工具",
|
||||
"sshOpenTerminal": "终端",
|
||||
"sshOpenVSCode": "用 VS Code 打开",
|
||||
"sshSetUser": "设置 SSH 用户名…",
|
||||
"sshUserDesc": "用于打开终端、写入 ~/.ssh/config 和 VS Code 直连(留空则连接时不带用户名)",
|
||||
"sshUserPlaceholder": "例如 admin",
|
||||
"sshUserTitle": "SSH 登录用户名",
|
||||
"sshWriteConfig": "写入 ~/.ssh/config",
|
||||
"state_broken": "出错",
|
||||
"state_creating": "正在创建",
|
||||
"state_driver_unavailable": "驱动不可用",
|
||||
"state_resuming": "恢复中",
|
||||
"state_running": "运行中",
|
||||
"state_starting": "启动中",
|
||||
"state_stopped": "已停止",
|
||||
"state_stopping": "停止中",
|
||||
"state_suspended": "已挂起",
|
||||
"state_suspending": "挂起中",
|
||||
"suspend": "挂起",
|
||||
"suspendedGuestToolsHint": "恢复或放弃挂起状态后可更改",
|
||||
"suspendedNoticeDesc": "恢复后将回到挂起前的桌面与应用状态({size});修改硬件配置或管理磁盘前请先恢复或放弃挂起状态。",
|
||||
"suspendedNoticeDescWithTime": "挂起于 {time}({size})· 恢复后将回到原桌面与应用状态;修改硬件配置或管理磁盘前请先恢复或放弃挂起状态。",
|
||||
"suspendedNoticeTitle": "已保存运行状态",
|
||||
"suspendedSettingsHint": "请先恢复或放弃挂起状态后再修改配置",
|
||||
"techInfo": "技术信息",
|
||||
"toastCloned": "已派生 CoW 副本「{name}」",
|
||||
"toastDeleted": "已删除 {name}",
|
||||
"toastDiagExported": "已导出脱敏排障日志包 (.zip)",
|
||||
"toastDiscardSuspend": "已放弃 {name} 的挂起状态",
|
||||
"toastEjected": "已弹出安装盘",
|
||||
"toastEnterRecovery": "已进入恢复模式,启动后可在引导菜单选 Recovery",
|
||||
"toastEnterRecoveryNextStart": "已准备进入恢复模式,重启后显示引导菜单",
|
||||
"toastExitRecoveryNextStart": "已退出恢复模式,下次启动生效",
|
||||
"toastFileDelivered": "已发送 {name}",
|
||||
"toastFilesDelivered": "{n, plural, other {已投递 # 个文件到共享目录}}",
|
||||
"toastGuestToolsAttached": "已挂载 Guest Tools 工具盘(REIMSTOOLS)",
|
||||
"toastGuestToolsAttachedNextStart": "已挂载 Guest Tools 工具盘,重启虚拟机后在访达中可见",
|
||||
"toastGuestToolsDetached": "已弹出工具盘",
|
||||
"toastGuestToolsDetachedNextStart": "已弹出工具盘,下次启动生效",
|
||||
"toastInstallFinished": "已退出恢复模式",
|
||||
"toastInstallerAttached": "已挂载离线镜像:{name}",
|
||||
"toastInstallerAttachedNextStart": "已挂载离线镜像(重启后生效):{name}",
|
||||
"toastNVMeNextStart": "已切换为 NVMe,下次启动生效",
|
||||
"toastNVMeReady": "已升级到 NVMe 磁盘控制器",
|
||||
"toastOnlineRecoveryAttached": "在线恢复镜像已挂载到 {name}",
|
||||
"toastOnlineRecoveryStarted": "正在拉取在线恢复镜像(约 1 GB),完成后自动挂载",
|
||||
"toastPreventSleepOff": "已关闭 macOS 防休眠守护",
|
||||
"toastPreventSleepOn": "已开启 macOS 防休眠守护",
|
||||
"toastResumed": "{name} 已恢复",
|
||||
"toastScreenshotCopied": "已复制虚拟机画面",
|
||||
"toastSnapshotCreated": "已创建恢复点 {name}",
|
||||
"toastSnapshotDeleted": "已删除恢复点 {name}",
|
||||
"toastSnapshotRestored": "已回滚到 {name}",
|
||||
"toastStopped": "{name} 已关机",
|
||||
"toastSuspended": "{name} 已挂起",
|
||||
"toastTyped": "{n, plural, other {已键入 # 个字符}}",
|
||||
"toggleFullscreen": "切换全屏",
|
||||
"typeClipboard": "粘贴剪贴板到虚拟机",
|
||||
"typeIntoVM": "在虚拟机里键入",
|
||||
"typeUntypeable": "未连接 Guest Tools 时仅支持美式键盘 ASCII 字符;安装并连接 Guest Tools 后即可输入中文与任意 Unicode 文本",
|
||||
"upgradeToNVMe": "升级到 NVMe",
|
||||
}
|
||||
|
||||
export const vmEn: Record<string, string> = {
|
||||
"attachGuestTools": "Attach Guest Tools",
|
||||
"attachInstaller": "Attach offline image",
|
||||
"brokenHint": "This VM’s configuration can’t be read",
|
||||
"cloneConfirm": "Create clone",
|
||||
"cloneDesc": "Makes an instant copy-on-write clone that takes almost no space and leaves the original untouched",
|
||||
"cloneNameLabel": "New VM name",
|
||||
"cloneTitle": "Derive CoW clone from “{name}”",
|
||||
"cloneVM": "Derive CoW clone",
|
||||
"connGroup": "Connection",
|
||||
"copyScreenshot": "Copy screenshot",
|
||||
"cores": "{n, plural, one {# core} other {# cores}}",
|
||||
"deleteConfirm": "Delete",
|
||||
"deleteDesc": "Its configuration and virtual disk are removed. This can’t be undone",
|
||||
"deleteDescKeep": "Only the configuration is removed; disk files stay in place",
|
||||
"deleteKeepFiles": "Keep disk files",
|
||||
"deleteTitle": "Delete \"{name}\"?",
|
||||
"deliverFileShort": "Send File…",
|
||||
"detachGuestTools": "Eject tools disk",
|
||||
"diagAhciUpgradeHint": "The system disk still uses SATA; NVMe is faster",
|
||||
"diagBackingChainBroken": "System disk CoW backing chain ({depth} layers) has a missing or unreadable parent image; check the source VM disk",
|
||||
"diagBackingChainWarn": "System disk CoW backing chain is {depth} layers deep (\u003e= 2); read-through slows small-file I/O — consider flattening or re-deriving from the base image",
|
||||
"diagExternalDriveWarn": "The data folder is on an external or network drive ({dir}); disk access will be slow",
|
||||
"diagHighMemWarn": "Host memory is {pct}% used; the VM may stutter",
|
||||
"discardSuspend": "Discard saved state",
|
||||
"discardSuspendConfirm": "Discard \u0026 Power Off",
|
||||
"discardSuspendDesc": "Removes the saved memory and device state and returns the VM to powered off. Any unsaved work inside macOS will be lost and can’t be undone.",
|
||||
"discardSuspendTitle": "Discard saved state for “{name}”?",
|
||||
"displayNameEdit": "Click to change the display name",
|
||||
"displayNameEditEllipsis": "Change Display Name…",
|
||||
"displayNameLabel": "Display name",
|
||||
"displayNameTip": "Display name · VM name is {name} (click to change)",
|
||||
"dropFilesHint": "Drop files to send to macOS shared folder",
|
||||
"enterFullscreen": "Enter full screen",
|
||||
"enterRecovery": "Enter recovery mode",
|
||||
"exitFullscreen": "Exit full screen",
|
||||
"exportDiagnostics": "Export diagnostics (.zip)",
|
||||
"factBackingChain": "CoW Backing Chain",
|
||||
"factCPU": "CPU",
|
||||
"factDisk": "Storage",
|
||||
"factGraphics": "Graphics",
|
||||
"factMemory": "Memory",
|
||||
"failAttachInstaller": "Couldn’t attach the image",
|
||||
"failCloneVM": "Couldn’t create CoW clone",
|
||||
"failDelete": "Couldn’t delete",
|
||||
"failDiscardSuspend": "Couldn’t discard saved state",
|
||||
"failEject": "Couldn’t eject the installer",
|
||||
"failEnterRecovery": "Couldn’t enter recovery mode",
|
||||
"failExportDiagnostics": "Couldn’t export diagnostics",
|
||||
"failFinishInstall": "Couldn’t exit recovery mode",
|
||||
"failFocus": "Could not focus VM window",
|
||||
"failFullscreen": "Couldn’t toggle full screen",
|
||||
"failGuestTools": "Guest Tools operation failed",
|
||||
"failOpenFolder": "Couldn’t open the folder",
|
||||
"failRestart": "Couldn’t restart",
|
||||
"failResume": "Couldn’t resume",
|
||||
"failScreenshot": "Screenshot failed",
|
||||
"failSnapshot": "Restore point failed",
|
||||
"failStart": "Couldn’t start",
|
||||
"failStop": "Couldn’t shut down",
|
||||
"failSuspend": "Couldn’t suspend",
|
||||
"failType": "Couldn’t type into the VM",
|
||||
"failUpgradeNVMe": "Couldn’t upgrade to NVMe",
|
||||
"fieldAudio": "Audio",
|
||||
"fieldCPUModel": "CPU model",
|
||||
"fieldController": "Disk controller",
|
||||
"fieldDir": "Directory",
|
||||
"fieldDisk": "Disk",
|
||||
"fieldGraphicsBackend": "Graphics backend",
|
||||
"fieldICD": "Vulkan ICD",
|
||||
"fieldKind": "Kind",
|
||||
"fieldNetwork": "Network",
|
||||
"fieldVMName": "VM name",
|
||||
"finishInstall": "Exit recovery mode",
|
||||
"gpuAuto": "Automatic GPU",
|
||||
"gtInstall": "Install…",
|
||||
"gtInstallSub": "Run in macOS Terminal",
|
||||
"gtNotInstalledDesc": "Not installed: attach the tools disk and run the installer in macOS",
|
||||
"gtStatusConnected": "Connected",
|
||||
"gtStatusEnabled": "Enabled",
|
||||
"gtStatusNone": "Not installed",
|
||||
"gtStatusOff": "Off",
|
||||
"gtStatusOffTip": "Guest Tools Transport is turned off on the Plugins page; clipboard, shared folders and keep-awake are unavailable",
|
||||
"gtStatusUpgrade": "Update needed",
|
||||
"gtStatusWaiting": "Not connected",
|
||||
"gtStatusWaitingTip": "Connects once the install command has run in macOS",
|
||||
"gtUpdate": "Update…",
|
||||
"guestToolsModeSync": "Folder sync",
|
||||
"guestToolsModeWebDAV": "WebDAV mount",
|
||||
"guestToolsPreventSleep": "Prevent macOS sleep",
|
||||
"guestToolsSleepActive": "Keeping macOS awake",
|
||||
"guestToolsTitle": "Guest Tools",
|
||||
"guestToolsUpgradeHint": "The tools in macOS are out of date; run the install command again to update",
|
||||
"guideBuiltIn1": "After starting, choose “Recovery” in the OpenCore boot menu",
|
||||
"guideBuiltIn2": "Recovery can reinstall over the network; for an offline install, click “Attach offline image”",
|
||||
"guideBuiltIn3": "When you are done, click “Exit recovery mode”",
|
||||
"guideKindBuiltIn": "Built-in recovery",
|
||||
"guideKindOffline": "Offline install",
|
||||
"guideKindOnline": "Online recovery",
|
||||
"guideOffline1": "Don’t click “Reinstall macOS Tahoe”; open Utilities › Terminal from the menu bar",
|
||||
"guideOffline2": "Run the command below (the keyboard icon types it for you). It erases the blank disk as APFS and starts the install; it restarts a few times:",
|
||||
"guideOffline3": "When Setup Assistant appears, click “Exit recovery mode” to eject the installer and turn the network back on",
|
||||
"guideStartHint": "Start the VM to open the installation guide in its window",
|
||||
"guideStep1": "Open Disk Utility and select the largest “QEMU HARDDISK Media” (View › Show All Devices if it is hidden). Click Erase: name Macintosh HD, format APFS, scheme GUID. It may pause for 10–30 seconds; don’t force it off",
|
||||
"guideStep2": "Back in Recovery, choose “Reinstall macOS Tahoe” and install to the disk you erased. It restarts a few times",
|
||||
"guideStep3": "When Setup Assistant appears, click “Exit recovery mode” to eject the installer",
|
||||
"guideTitle": "Recovery mode",
|
||||
"netOff": "No network",
|
||||
"netShared": "Shared network",
|
||||
"onlineRecoveryConfirm": "Download \u0026 attach (~1 GB)",
|
||||
"onlineRecoveryDesc": "No recovery image is on this PC. Download Apple’s recovery image (about 1 GB) and attach it to “{name}”?",
|
||||
"onlineRecoveryTitle": "Download online recovery image?",
|
||||
"openSharedFolder": "Open shared folder",
|
||||
"openShort": "Open",
|
||||
"pendingRestartHint": "Takes effect after a restart",
|
||||
"pendingTitle": "Applies on next start",
|
||||
"pickRecoveryTitle": "Choose an offline image (.img / .dmg)",
|
||||
"restartToApply": "Restart to apply",
|
||||
"resume": "Resume",
|
||||
"resumeUnavailable": "Switch to a runtime that supports suspend to resume this VM",
|
||||
"sendText": "Send text to VM…",
|
||||
"sendTextConfirm": "Send (Ctrl+Enter)",
|
||||
"sendTextDesc": "Supports Chinese, emoji, host IME, and dictation. Press Ctrl+Enter to inject into the focused macOS field.",
|
||||
"sendTextDescNoGT": "Guest Tools is not connected; only US-keyboard ASCII characters are supported until Guest Tools is connected.",
|
||||
"sendTextPlaceholder": "Type or paste text to send to the VM…",
|
||||
"sendTextTitle": "Send text to “{name}”",
|
||||
"sharedFolder": "Shared folder",
|
||||
"showInstallGuide": "Show install guide",
|
||||
"showWindow": "Show window",
|
||||
"snapshotCreate": "New restore point",
|
||||
"snapshotDelete": "Delete restore point",
|
||||
"snapshotEmpty": "No restore points yet — save one before OS updates or major changes",
|
||||
"snapshotHint": "Offline snapshots · Not a backup",
|
||||
"snapshotNamePlaceholder": "e.g. before-macos-update",
|
||||
"snapshotRestore": "Restore",
|
||||
"snapshotRestoreDesc": "Disk changes made after this restore point will be overwritten and cannot be undone.",
|
||||
"snapshotRestoreTitle": "Restore \"{name}\"?",
|
||||
"snapshotStopFirst": "Stop the VM before managing restore points",
|
||||
"snapshotsTitle": "Restore points",
|
||||
"softwareGraphics": "Software rendering",
|
||||
"specCPULiveTip": "{n, plural, one {# processor core, {pct}% in use} other {# processor cores, {pct}% in use}}",
|
||||
"specCPUTip": "{n, plural, one {# processor core} other {# processor cores}}",
|
||||
"specDiskTip": "Storage: {ctl}",
|
||||
"specDiskUsage": "{ctl} · {used} of {max} used",
|
||||
"specGraphicsTip": "Graphics: {gfx}",
|
||||
"specLang": "Language",
|
||||
"specLangTip": "macOS system language: {label}",
|
||||
"specLangTipDetail": "macOS system language: {label} ({detail})",
|
||||
"specMemLiveTip": "{mem} memory; the VM uses {used} on this PC",
|
||||
"specMemTip": "{mem} memory",
|
||||
"specNetOffTip": "The VM has no network",
|
||||
"specNetSSHTip": "Shares this PC’s network connection; SSH on port {port}",
|
||||
"specNetTip": "Shares this PC’s network connection",
|
||||
"sshMore": "SSH tools",
|
||||
"sshOpenTerminal": "Terminal",
|
||||
"sshOpenVSCode": "Open in VS Code",
|
||||
"sshSetUser": "Set SSH username…",
|
||||
"sshUserDesc": "Used for Terminal, ~/.ssh/config, and VS Code Remote-SSH (leave empty to omit user)",
|
||||
"sshUserPlaceholder": "e.g. admin",
|
||||
"sshUserTitle": "SSH login username",
|
||||
"sshWriteConfig": "Write ~/.ssh/config",
|
||||
"state_broken": "Error",
|
||||
"state_creating": "Creating",
|
||||
"state_driver_unavailable": "Driver unavailable",
|
||||
"state_resuming": "Resuming",
|
||||
"state_running": "Running",
|
||||
"state_starting": "Starting",
|
||||
"state_stopped": "Stopped",
|
||||
"state_stopping": "Stopping",
|
||||
"state_suspended": "Suspended",
|
||||
"state_suspending": "Suspending",
|
||||
"suspend": "Suspend",
|
||||
"suspendedGuestToolsHint": "Resume or discard saved state to make changes",
|
||||
"suspendedNoticeDesc": "Resuming restores your desktop and running apps ({size}). Resume or discard the saved state before changing settings or managing disks.",
|
||||
"suspendedNoticeDescWithTime": "Suspended {time} ({size}) · Resuming restores your desktop and running apps. Resume or discard before changing settings or disks.",
|
||||
"suspendedNoticeTitle": "Saved state ready",
|
||||
"suspendedSettingsHint": "Resume or discard saved state before changing settings",
|
||||
"techInfo": "Technical details",
|
||||
"toastCloned": "CoW clone “{name}” created",
|
||||
"toastDeleted": "{name} deleted",
|
||||
"toastDiagExported": "Redacted diagnostics archive exported (.zip)",
|
||||
"toastDiscardSuspend": "Discarded saved state for {name}",
|
||||
"toastEjected": "Installer ejected",
|
||||
"toastEnterRecovery": "Recovery mode ready — pick Recovery in OpenCore on next start",
|
||||
"toastEnterRecoveryNextStart": "Recovery mode ready — restart to open the boot menu",
|
||||
"toastExitRecoveryNextStart": "Exited recovery mode — applies at next start",
|
||||
"toastFileDelivered": "Sent {name}",
|
||||
"toastFilesDelivered": "{n, plural, one {Sent # file to the shared folder} other {Sent # files to the shared folder}}",
|
||||
"toastGuestToolsAttached": "Guest Tools disk (REIMSTOOLS) attached",
|
||||
"toastGuestToolsAttachedNextStart": "Guest Tools disk attached — restart VM to mount in Finder",
|
||||
"toastGuestToolsDetached": "Tools disk ejected",
|
||||
"toastGuestToolsDetachedNextStart": "Tools disk ejected; applies on next start",
|
||||
"toastInstallFinished": "Exited recovery mode",
|
||||
"toastInstallerAttached": "Offline image attached: {name}",
|
||||
"toastInstallerAttachedNextStart": "Offline image attached (applies on restart): {name}",
|
||||
"toastNVMeNextStart": "Switched to NVMe — applies on next start",
|
||||
"toastNVMeReady": "Upgraded disk controller to NVMe",
|
||||
"toastOnlineRecoveryAttached": "Online recovery image attached to {name}",
|
||||
"toastOnlineRecoveryStarted": "Downloading online recovery image (~1 GB); will attach when ready",
|
||||
"toastPreventSleepOff": "Prevent-sleep guard disabled",
|
||||
"toastPreventSleepOn": "Prevent-sleep guard enabled",
|
||||
"toastResumed": "{name} resumed",
|
||||
"toastScreenshotCopied": "VM screenshot copied",
|
||||
"toastSnapshotCreated": "Created restore point {name}",
|
||||
"toastSnapshotDeleted": "Deleted restore point {name}",
|
||||
"toastSnapshotRestored": "Restored to {name}",
|
||||
"toastStopped": "{name} shut down",
|
||||
"toastSuspended": "{name} suspended",
|
||||
"toastTyped": "{n, plural, one {Typed # character} other {Typed # characters}}",
|
||||
"toggleFullscreen": "Toggle full screen",
|
||||
"typeClipboard": "Send clipboard to VM",
|
||||
"typeIntoVM": "Type into the VM",
|
||||
"typeUntypeable": "Only US-keyboard ASCII characters work without Guest Tools; connect Guest Tools for Chinese and Unicode text",
|
||||
"upgradeToNVMe": "Upgrade to NVMe",
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
// Code generated by cmd/i18ngen; DO NOT EDIT.
|
||||
import { registerBuiltinDomain } from '../runtime'
|
||||
|
||||
export const wizardZh: Record<string, string> = {
|
||||
"commandToggle": "等效命令",
|
||||
"commandToggleHint": "在终端运行下面这条命令效果相同",
|
||||
"createNow": "创建",
|
||||
"createStartedHint": "创建后窗口会关闭,进度在底部状态栏",
|
||||
"issuesCount": "{n, plural, other {有 # 项需要修改}}",
|
||||
"offlineCached": "已下载",
|
||||
"offlineDownloading": "下载中",
|
||||
"offlineHint": "约 20 GB,安装时不联网",
|
||||
"offlineListFailedDetail": "无法读取 Apple 的版本列表:{err}",
|
||||
"offlineLoading": "正在读取 Apple 的版本列表…",
|
||||
"offlineQueued": "排队中",
|
||||
"offlineSpaceWarn": "可用空间 {free} GB,下载这个版本需要约 {need} GB",
|
||||
"runtimeAlpha": "接收 Alpha 版",
|
||||
"runtimeAlphaHint": "Alpha 版由 CI 每天从上游自动构建,未经真实宿主冒烟测试",
|
||||
"runtimeChannel_alpha": "Alpha 版",
|
||||
"runtimeChannel_stable": "稳定版",
|
||||
"runtimeCurrent": "当前运行时",
|
||||
"runtimeInstall": "安装",
|
||||
"runtimeLatest": "最新:{v}",
|
||||
"runtimeLookupFailed": "无法读取运行时列表",
|
||||
"runtimeLookupRateLimit": "GitHub 接口限流(HTTP 403),请稍后重试或手动导入",
|
||||
"runtimeNewer": "有新版本:{v}",
|
||||
"runtimeNoneOnChannel": "这个通道还没有发布运行时",
|
||||
"runtimeOnline": "在线安装",
|
||||
"runtimeRetry": "重试",
|
||||
"runtimeUpToDate": "已是最新",
|
||||
"runtimeUpdate": "更新",
|
||||
"setupCheck": "环境",
|
||||
"setupContinue": "继续",
|
||||
"setupDesc": "虚拟机、安装包和运行时都放在这里",
|
||||
"setupDone": "完成",
|
||||
"setupExternal": "外置盘",
|
||||
"setupFree": "可用 {n} GB",
|
||||
"setupGPU": "显卡(Vulkan)",
|
||||
"setupImport": "导入本地包…",
|
||||
"setupLangPackFailed": "语言包安装失败,可稍后在插件页重试",
|
||||
"setupLangPackOffer": "同时安装「{name}」",
|
||||
"setupLater": "稍后",
|
||||
"setupNoGPU": "没有检测到 Vulkan 显卡,只能用软件渲染",
|
||||
"setupOther": "其他位置…",
|
||||
"setupRecMem": "推荐 {n} GB",
|
||||
"setupRecommended": "推荐",
|
||||
"setupReuse": "这里已有 Reims-Go 数据,会直接沿用",
|
||||
"setupRuntimeDesc": "运行虚拟机所需的 QEMU 与 reims-ctl,从 GitHub 下载并校验",
|
||||
"setupRuntimeTitle": "检查环境并安装运行时",
|
||||
"setupSystem": "系统盘",
|
||||
"setupTitle": "选择数据目录",
|
||||
"setupWarnExternal": "外置盘拔出时,正在运行的虚拟机会损坏",
|
||||
"setupWarnSpace": "可用空间不足 60 GB:一个离线安装包约 20 GB,虚拟磁盘会随使用增长",
|
||||
"setupWarnSystem": "放在系统盘,空间紧张时会影响 Windows",
|
||||
"srcAppleSub": "恢复镜像,系统在装机时在线下载",
|
||||
"srcAppleTitle": "从 Apple 下载",
|
||||
"srcDiskSub": "已装好 macOS 的 .qcow2 等磁盘",
|
||||
"srcDiskTitle": "已有磁盘",
|
||||
"srcInstallerSub": "本机上的 .img 或 .dmg",
|
||||
"srcInstallerTitle": "安装镜像",
|
||||
"srcOfflineSub": "完整安装包,装机时不联网",
|
||||
"srcOfflineTitle": "离线安装包",
|
||||
"step1": "系统来源",
|
||||
"step2": "处理器与内存",
|
||||
"step3": "存储",
|
||||
"step4": "图形与选项",
|
||||
"step5": "确认",
|
||||
"summaryAppleSource": "从 Apple 下载 · {v}",
|
||||
"summaryDefaultDir": "数据目录(默认)",
|
||||
"summaryDiskGrow": "{size},按实际占用增长",
|
||||
"summaryDiskSource": "已有磁盘 · {file}",
|
||||
"summaryEdit": "修改",
|
||||
"summaryInstallerSource": "本地安装器 · {file}",
|
||||
"summaryLogs": "图形与串口日志",
|
||||
"summaryOfflineSource": "离线安装包 · macOS {v}",
|
||||
"summaryOn": "开",
|
||||
"summarySSH": "SSH 转发",
|
||||
"summarySSHPort": "端口 {n}",
|
||||
"summarySource": "来源",
|
||||
"validationChecking": "正在检查…",
|
||||
"validationPassed": "可以创建",
|
||||
"vulkanProbeFailed": "Vulkan 探测失败({detail})。请运行 vulkaninfo --summary 检查驱动。",
|
||||
"wizChooseFile": "选择…",
|
||||
"wizNoFile": "还没有选择文件",
|
||||
"wizOptions": "选项",
|
||||
"wizardBasics": "基本信息",
|
||||
"wizardDriverGroup": "客体平台驱动",
|
||||
"wizardDriverType": "驱动类型",
|
||||
"wizardTitle": "新建虚拟机",
|
||||
}
|
||||
|
||||
export const wizardEn: Record<string, string> = {
|
||||
"commandToggle": "Equivalent command",
|
||||
"commandToggleHint": "Running this in a terminal does the same thing",
|
||||
"createNow": "Create",
|
||||
"createStartedHint": "The window closes once creation starts; progress shows in the status bar",
|
||||
"issuesCount": "{n, plural, one {# issue to fix} other {# issues to fix}}",
|
||||
"offlineCached": "Downloaded",
|
||||
"offlineDownloading": "Downloading",
|
||||
"offlineHint": "About 20 GB; installs with no network",
|
||||
"offlineListFailedDetail": "Couldn’t read Apple’s release list: {err}",
|
||||
"offlineLoading": "Reading Apple’s release list…",
|
||||
"offlineQueued": "Queued",
|
||||
"offlineSpaceWarn": "{free} GB free; this release needs about {need} GB",
|
||||
"runtimeAlpha": "Receive alpha builds",
|
||||
"runtimeAlphaHint": "Built daily from upstream by CI; not smoke-tested on a real host",
|
||||
"runtimeChannel_alpha": "Alpha",
|
||||
"runtimeChannel_stable": "Stable",
|
||||
"runtimeCurrent": "Current runtime",
|
||||
"runtimeInstall": "Install",
|
||||
"runtimeLatest": "Latest: {v}",
|
||||
"runtimeLookupFailed": "Couldn’t read the runtime list",
|
||||
"runtimeLookupRateLimit": "GitHub API rate limit reached (HTTP 403); retry later or import a local bundle",
|
||||
"runtimeNewer": "New version: {v}",
|
||||
"runtimeNoneOnChannel": "No runtime published on this channel yet",
|
||||
"runtimeOnline": "Online install",
|
||||
"runtimeRetry": "Retry",
|
||||
"runtimeUpToDate": "Up to date",
|
||||
"runtimeUpdate": "Update",
|
||||
"setupCheck": "Host",
|
||||
"setupContinue": "Continue",
|
||||
"setupDesc": "VMs, installers and runtimes all live here",
|
||||
"setupDone": "Done",
|
||||
"setupExternal": "External",
|
||||
"setupFree": "{n} GB free",
|
||||
"setupGPU": "Graphics (Vulkan)",
|
||||
"setupImport": "Import a local package…",
|
||||
"setupLangPackFailed": "Could not install the language pack; you can retry from the Plugins page",
|
||||
"setupLangPackOffer": "Also install “{name}”",
|
||||
"setupLater": "Later",
|
||||
"setupNoGPU": "No Vulkan GPU found; only software rendering will work",
|
||||
"setupOther": "Other location…",
|
||||
"setupRecMem": "{n} GB recommended",
|
||||
"setupRecommended": "Recommended",
|
||||
"setupReuse": "This folder already has Reims-Go data; it will be reused",
|
||||
"setupRuntimeDesc": "QEMU and reims-ctl, downloaded from GitHub and verified",
|
||||
"setupRuntimeTitle": "Check the host and install the runtime",
|
||||
"setupSystem": "System drive",
|
||||
"setupTitle": "Choose a data folder",
|
||||
"setupWarnExternal": "Unplugging an external drive corrupts running VMs",
|
||||
"setupWarnSpace": "Under 60 GB free: an offline installer is about 20 GB and virtual disks grow with use",
|
||||
"setupWarnSystem": "On the system drive, low space can affect Windows",
|
||||
"srcAppleSub": "A recovery image; macOS downloads during install",
|
||||
"srcAppleTitle": "Download from Apple",
|
||||
"srcDiskSub": "A .qcow2 or other disk with macOS installed",
|
||||
"srcDiskTitle": "Existing disk",
|
||||
"srcInstallerSub": "An .img or .dmg on this PC",
|
||||
"srcInstallerTitle": "Installer image",
|
||||
"srcOfflineSub": "The full installer; installs with no network",
|
||||
"srcOfflineTitle": "Offline installer",
|
||||
"step1": "Source",
|
||||
"step2": "CPU \u0026 memory",
|
||||
"step3": "Storage",
|
||||
"step4": "Graphics \u0026 options",
|
||||
"step5": "Review",
|
||||
"summaryAppleSource": "Download from Apple · {v}",
|
||||
"summaryDefaultDir": "Data folder (default)",
|
||||
"summaryDiskGrow": "{size}, grows with use",
|
||||
"summaryDiskSource": "Existing disk · {file}",
|
||||
"summaryEdit": "Edit",
|
||||
"summaryInstallerSource": "Local installer · {file}",
|
||||
"summaryLogs": "Graphics \u0026 serial logs",
|
||||
"summaryOfflineSource": "Offline installer · macOS {v}",
|
||||
"summaryOn": "On",
|
||||
"summarySSH": "SSH forwarding",
|
||||
"summarySSHPort": "Port {n}",
|
||||
"summarySource": "Source",
|
||||
"validationChecking": "Checking…",
|
||||
"validationPassed": "Ready to create",
|
||||
"vulkanProbeFailed": "Vulkan probe failed ({detail}). Run vulkaninfo --summary to check the driver.",
|
||||
"wizChooseFile": "Choose…",
|
||||
"wizNoFile": "No file chosen",
|
||||
"wizOptions": "Options",
|
||||
"wizardBasics": "Basics",
|
||||
"wizardDriverGroup": "Guest driver",
|
||||
"wizardDriverType": "Driver",
|
||||
"wizardTitle": "New virtual machine",
|
||||
}
|
||||
|
||||
registerBuiltinDomain(wizardZh, wizardEn)
|
||||
@@ -0,0 +1,376 @@
|
||||
// Zero-dependency isomorphic lightweight ICU MessageFormat evaluator + en-XA pseudo-localizer.
|
||||
// Matches internal/i18n/icu.go 1:1 while delegating plural selection & number formatting
|
||||
// to native zero-bundle-cost browser Intl APIs.
|
||||
|
||||
export type ICUVars = Record<string, string | number | boolean | undefined | null>
|
||||
|
||||
type ICUNode =
|
||||
| { kind: 'text'; text: string }
|
||||
| { kind: 'pound' }
|
||||
| { kind: 'var'; name: string }
|
||||
| { kind: 'number'; name: string; precision: number }
|
||||
| { kind: 'plural' | 'select'; name: string; branches: Array<{ selector: string; nodes: ICUNode[] }> }
|
||||
|
||||
const astCache = new Map<string, ICUNode[] | null>()
|
||||
const pluralRulesCache = new Map<string, Intl.PluralRules>()
|
||||
const numberFormatCache = new Map<string, Intl.NumberFormat>()
|
||||
|
||||
function getPluralRules(locale: string): Intl.PluralRules {
|
||||
const key = locale === 'en-XA' ? 'en-US' : locale
|
||||
let pr = pluralRulesCache.get(key)
|
||||
if (!pr) {
|
||||
try {
|
||||
pr = new Intl.PluralRules(key)
|
||||
} catch {
|
||||
pr = new Intl.PluralRules('en-US')
|
||||
}
|
||||
pluralRulesCache.set(key, pr)
|
||||
}
|
||||
return pr
|
||||
}
|
||||
|
||||
export function formatLocaleNumber(locale: string, value: number, precision = -1): string {
|
||||
const cleanLoc = locale === 'en-XA' ? 'en-US' : locale
|
||||
const cacheKey = `${cleanLoc}:${precision}`
|
||||
let nf = numberFormatCache.get(cacheKey)
|
||||
if (!nf) {
|
||||
const opts: Intl.NumberFormatOptions =
|
||||
precision >= 0
|
||||
? { minimumFractionDigits: precision, maximumFractionDigits: precision, useGrouping: false }
|
||||
: { useGrouping: false }
|
||||
try {
|
||||
nf = new Intl.NumberFormat(cleanLoc, opts)
|
||||
} catch {
|
||||
nf = new Intl.NumberFormat('en-US', opts)
|
||||
}
|
||||
numberFormatCache.set(cacheKey, nf)
|
||||
}
|
||||
return nf.format(value)
|
||||
}
|
||||
|
||||
const MAX_ICU_DEPTH = 16
|
||||
const MAX_ICU_TEMPLATE_LEN = 16384
|
||||
|
||||
export function parseICU(tmpl: string): ICUNode[] | null {
|
||||
if (tmpl.length > MAX_ICU_TEMPLATE_LEN) return null
|
||||
if (astCache.has(tmpl)) {
|
||||
return astCache.get(tmpl) ?? null
|
||||
}
|
||||
let pos = 0
|
||||
const len = tmpl.length
|
||||
|
||||
const skipWS = () => {
|
||||
while (pos < len) {
|
||||
const c = tmpl.charCodeAt(pos)
|
||||
if (c === 32 || c === 9 || c === 10 || c === 13) pos++
|
||||
else break
|
||||
}
|
||||
}
|
||||
|
||||
const readIdent = (): string => {
|
||||
const start = pos
|
||||
while (pos < len) {
|
||||
const c = tmpl.charCodeAt(pos)
|
||||
if (
|
||||
(c >= 97 && c <= 122) ||
|
||||
(c >= 65 && c <= 90) ||
|
||||
(c >= 48 && c <= 57) ||
|
||||
c === 95 || // _
|
||||
c === 45 || // -
|
||||
c === 46 || // .
|
||||
c === 61 // =
|
||||
) {
|
||||
pos++
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return tmpl.slice(start, pos)
|
||||
}
|
||||
|
||||
const parseNodes = (stopAtBrace: boolean, inPlural: boolean, depth: number): ICUNode[] | null => {
|
||||
if (depth > MAX_ICU_DEPTH) return null
|
||||
const nodes: ICUNode[] = []
|
||||
let buf = ''
|
||||
const flush = () => {
|
||||
if (buf.length > 0) {
|
||||
nodes.push({ kind: 'text', text: buf })
|
||||
buf = ''
|
||||
}
|
||||
}
|
||||
|
||||
while (pos < len) {
|
||||
const ch = tmpl[pos]
|
||||
if (ch === "'") {
|
||||
if (pos + 1 < len && tmpl[pos + 1] === "'") {
|
||||
buf += "'"
|
||||
pos += 2
|
||||
continue
|
||||
}
|
||||
const next = pos + 1 < len ? tmpl[pos + 1] : ''
|
||||
if (next === '{' || next === '}' || (inPlural && next === '#')) {
|
||||
pos++
|
||||
while (pos < len) {
|
||||
if (tmpl[pos] === "'") {
|
||||
if (pos + 1 < len && tmpl[pos + 1] === "'") {
|
||||
buf += "'"
|
||||
pos += 2
|
||||
continue
|
||||
}
|
||||
pos++
|
||||
break
|
||||
}
|
||||
buf += tmpl[pos++]
|
||||
}
|
||||
continue
|
||||
}
|
||||
buf += "'"
|
||||
pos++
|
||||
continue
|
||||
}
|
||||
|
||||
if (ch === '}') {
|
||||
if (stopAtBrace) {
|
||||
flush()
|
||||
return nodes
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
if (ch === '#' && inPlural) {
|
||||
flush()
|
||||
nodes.push({ kind: 'pound' })
|
||||
pos++
|
||||
continue
|
||||
}
|
||||
|
||||
if (ch === '{') {
|
||||
flush()
|
||||
const node = parsePlaceholder(inPlural, depth + 1)
|
||||
if (!node) return null
|
||||
nodes.push(node)
|
||||
continue
|
||||
}
|
||||
|
||||
buf += ch
|
||||
pos++
|
||||
}
|
||||
|
||||
if (stopAtBrace) return null
|
||||
flush()
|
||||
return nodes
|
||||
}
|
||||
|
||||
const parsePlaceholder = (parentInPlural: boolean, depth: number): ICUNode | null => {
|
||||
if (depth > MAX_ICU_DEPTH) return null
|
||||
pos++ // skip '{'
|
||||
skipWS()
|
||||
const name = readIdent()
|
||||
if (!name) return null
|
||||
skipWS()
|
||||
if (pos < len && tmpl[pos] === '}') {
|
||||
pos++
|
||||
return { kind: 'var', name }
|
||||
}
|
||||
if (pos >= len || tmpl[pos] !== ',') return null
|
||||
pos++
|
||||
skipWS()
|
||||
const fn = readIdent()
|
||||
skipWS()
|
||||
|
||||
if (fn === 'number') {
|
||||
let precision = -1
|
||||
if (pos < len && tmpl[pos] === ',') {
|
||||
pos++
|
||||
skipWS()
|
||||
const style = readIdent()
|
||||
if (/^\.[0-6]$/.test(style)) {
|
||||
precision = Number.parseInt(style.slice(1), 10)
|
||||
} else if (style !== '') {
|
||||
return null
|
||||
}
|
||||
skipWS()
|
||||
}
|
||||
if (pos >= len || tmpl[pos] !== '}') return null
|
||||
pos++
|
||||
return { kind: 'number', name, precision }
|
||||
}
|
||||
|
||||
if (fn === 'plural' || fn === 'select') {
|
||||
if (pos >= len || tmpl[pos] !== ',') return null
|
||||
pos++
|
||||
const isPlural = fn === 'plural'
|
||||
const branches: Array<{ selector: string; nodes: ICUNode[] }> = []
|
||||
let hasOther = false
|
||||
while (true) {
|
||||
skipWS()
|
||||
if (pos < len && tmpl[pos] === '}') {
|
||||
pos++
|
||||
break
|
||||
}
|
||||
const selector = readIdent()
|
||||
if (!selector) return null
|
||||
if (selector === 'other') hasOther = true
|
||||
skipWS()
|
||||
if (pos >= len || tmpl[pos] !== '{') return null
|
||||
pos++
|
||||
const childNodes = parseNodes(true, isPlural || parentInPlural, depth + 1)
|
||||
if (!childNodes || pos >= len || tmpl[pos] !== '}') return null
|
||||
pos++
|
||||
branches.push({ selector, nodes: childNodes })
|
||||
}
|
||||
if (!hasOther) return null
|
||||
return { kind: fn, name, branches }
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
const parsed = parseNodes(false, false, 0)
|
||||
const valid = parsed && pos === len ? parsed : null
|
||||
if (astCache.size > 3000) astCache.clear()
|
||||
astCache.set(tmpl, valid)
|
||||
return valid
|
||||
}
|
||||
|
||||
export function formatICU(locale: string, tmpl: string, vars?: ICUVars, strictVars = false): string | null {
|
||||
if (!vars && !tmpl.includes('{') && !tmpl.includes('}') && !tmpl.includes("'")) {
|
||||
return tmpl
|
||||
}
|
||||
const nodes = parseICU(tmpl)
|
||||
if (!nodes) return null
|
||||
|
||||
const evalList = (list: ICUNode[], poundVal?: string): string | null => {
|
||||
let out = ''
|
||||
for (const nd of list) {
|
||||
switch (nd.kind) {
|
||||
case 'text':
|
||||
out += nd.text
|
||||
break
|
||||
case 'pound':
|
||||
out += poundVal !== undefined ? poundVal : '#'
|
||||
break
|
||||
case 'var': {
|
||||
const val = vars?.[nd.name]
|
||||
if (val === undefined || val === null) {
|
||||
if (strictVars) return null
|
||||
out += `{${nd.name}}`
|
||||
} else {
|
||||
out += String(val)
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'number': {
|
||||
const val = vars?.[nd.name]
|
||||
if (val === undefined || val === null) {
|
||||
if (strictVars) return null
|
||||
out += `{${nd.name}}`
|
||||
} else {
|
||||
const num = typeof val === 'number' ? val : Number(val)
|
||||
out += Number.isFinite(num) ? formatLocaleNumber(locale, num, nd.precision) : String(val)
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'plural': {
|
||||
const raw = vars?.[nd.name]
|
||||
if ((raw === undefined || raw === null) && strictVars) return null
|
||||
const num = typeof raw === 'number' ? raw : Number(raw ?? 0)
|
||||
const safeNum = Number.isFinite(num) ? num : 0
|
||||
const exact = Number.isInteger(safeNum) ? `=${safeNum}` : ''
|
||||
const cat = getPluralRules(locale).select(safeNum)
|
||||
const chosen =
|
||||
(exact ? nd.branches.find((b) => b.selector === exact) : undefined) ??
|
||||
nd.branches.find((b) => b.selector === cat) ??
|
||||
nd.branches.find((b) => b.selector === 'other') ??
|
||||
nd.branches[nd.branches.length - 1]
|
||||
const formattedNum = formatLocaleNumber(locale, safeNum, -1)
|
||||
const inner = evalList(chosen ? chosen.nodes : [], formattedNum)
|
||||
if (inner === null) return null
|
||||
out += inner
|
||||
break
|
||||
}
|
||||
case 'select': {
|
||||
const raw = vars?.[nd.name]
|
||||
if ((raw === undefined || raw === null) && strictVars) return null
|
||||
const key = raw === undefined || raw === null ? '' : String(raw)
|
||||
const chosen =
|
||||
nd.branches.find((b) => b.selector === key) ??
|
||||
nd.branches.find((b) => b.selector === 'other') ??
|
||||
nd.branches[nd.branches.length - 1]
|
||||
const inner = evalList(chosen ? chosen.nodes : [], poundVal)
|
||||
if (inner === null) return null
|
||||
out += inner
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
return evalList(nodes)
|
||||
}
|
||||
|
||||
const PSEUDO_MAP: Record<string, string> = {
|
||||
a: 'à', b: 'ƀ', c: 'č', d: 'ď', e: 'ë', f: 'ƒ', g: 'ğ', h: 'ĥ', i: 'î', j: 'ĵ', k: 'ķ', l: 'ľ', m: 'ɱ',
|
||||
n: 'ñ', o: 'ô', p: 'þ', q: 'ǫ', r: 'ŕ', s: 'ś', t: 'ť', u: 'ü', v: 'ṽ', w: 'ŵ', x: 'ẋ', y: 'ÿ', z: 'ž',
|
||||
A: 'À', B: 'Ɓ', C: 'Č', D: 'Ď', E: 'Ë', F: 'Ƒ', G: 'Ğ', H: 'Ĥ', I: 'Î', J: 'Ĵ', K: 'Ķ', L: 'Ľ', M: 'Ṁ',
|
||||
N: 'Ñ', O: 'Ô', P: 'Þ', Q: 'Ǫ', R: 'Ŕ', S: 'Š', T: 'Ť', U: 'Ü', V: 'Ṽ', W: 'Ŵ', X: 'Ẋ', Y: 'Ÿ', Z: 'Ž',
|
||||
}
|
||||
|
||||
function accentString(s: string): string {
|
||||
let out = ''
|
||||
for (const ch of s) {
|
||||
out += PSEUDO_MAP[ch] ?? ch
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
export function pseudoLocalizeICU(enTmpl: string): string {
|
||||
const nodes = parseICU(enTmpl)
|
||||
if (!nodes) return `⟦${enTmpl}⟧`
|
||||
|
||||
const countChars = (list: ICUNode[]): number =>
|
||||
list.reduce((acc, n) => acc + (n.kind === 'text' ? [...n.text].length : 0), 0)
|
||||
|
||||
const topChars = countChars(nodes)
|
||||
const topPad =
|
||||
topChars === 0
|
||||
? 0
|
||||
: topChars <= 8
|
||||
? Math.max(4, Math.ceil(topChars * 0.85))
|
||||
: Math.ceil(topChars * 0.35)
|
||||
|
||||
const serialize = (list: ICUNode[], pad: number, isTop: boolean): string => {
|
||||
let s = ''
|
||||
for (const nd of list) {
|
||||
if (nd.kind === 'text') {
|
||||
s += accentString(nd.text)
|
||||
.replaceAll("'", "''")
|
||||
.replaceAll('{', "'{'")
|
||||
.replaceAll('}', "'}'")
|
||||
.replaceAll('#', "'#'")
|
||||
} else if (nd.kind === 'pound') {
|
||||
s += '#'
|
||||
} else if (nd.kind === 'var') {
|
||||
s += `{${nd.name}}`
|
||||
} else if (nd.kind === 'number') {
|
||||
s += nd.precision >= 0 ? `{${nd.name}, number, .${nd.precision}}` : `{${nd.name}, number}`
|
||||
} else {
|
||||
s += `{${nd.name}, ${nd.kind}, `
|
||||
s += nd.branches
|
||||
.map((br) => {
|
||||
const brPad = isTop && topChars === 0 ? Math.max(3, Math.ceil(countChars(br.nodes) * 0.35)) : 0
|
||||
return `${br.selector} {${serialize(br.nodes, brPad, false)}}`
|
||||
})
|
||||
.join(' ')
|
||||
s += '}'
|
||||
}
|
||||
}
|
||||
if (pad > 0) {
|
||||
s += ' ' + '·'.repeat(pad)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
return `⟦${serialize(nodes, topPad, true)}⟧`
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,12 @@
|
||||
import { coreEn, coreZh } from './domains/core.gen'
|
||||
import { vmEn, vmZh } from './domains/vm.gen'
|
||||
|
||||
export const builtinDict: Record<'zh-CN' | 'en-US', Record<string, string>> = {
|
||||
'zh-CN': { ...coreZh, ...vmZh },
|
||||
'en-US': { ...coreEn, ...vmEn },
|
||||
}
|
||||
|
||||
export function registerBuiltinDomain(zh: Record<string, string>, en: Record<string, string>): void {
|
||||
Object.assign(builtinDict['zh-CN'], zh)
|
||||
Object.assign(builtinDict['en-US'], en)
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
// Plugin UI bridge contract, bridgeApi 1.0 (docs/plugin-architecture.md §5.6, §6.3).
|
||||
//
|
||||
// Sandboxed plugin views and panels talk to the host only through these
|
||||
// postMessage envelopes. Stable methods and events are implemented and covered
|
||||
// by the compatibility promise; experimental ones are part of the published
|
||||
// shape but the host answers them with an "experimental" error until they are
|
||||
// promoted. Permissions and rate limits are enforced in Go
|
||||
// (internal/plugin/contract.go BridgeMethodCatalog); a Go test keeps the method
|
||||
// lists here and there identical.
|
||||
|
||||
export const BRIDGE_API_VERSION = '1.0.0' as const
|
||||
|
||||
export const BRIDGE_METHODS = [
|
||||
'hello',
|
||||
'i18n.getBundle',
|
||||
'ui.notify',
|
||||
'vm.list',
|
||||
'command.invoke',
|
||||
] as const
|
||||
|
||||
export const BRIDGE_METHODS_EXPERIMENTAL = [
|
||||
'ui.confirm',
|
||||
'ui.showForm',
|
||||
'ui.setTitle',
|
||||
'ui.setBadge',
|
||||
'ui.openView',
|
||||
'ui.close',
|
||||
'ui.navigate',
|
||||
'ui.openExternal',
|
||||
'vm.get',
|
||||
'settings.get',
|
||||
'settings.set',
|
||||
'storage.get',
|
||||
'storage.set',
|
||||
'storage.list',
|
||||
'storage.delete',
|
||||
'file.pick',
|
||||
'file.save',
|
||||
'file.read',
|
||||
'file.write',
|
||||
'task.start',
|
||||
'task.update',
|
||||
'task.finish',
|
||||
'net.fetch',
|
||||
'events.subscribe',
|
||||
'events.unsubscribe',
|
||||
] as const
|
||||
|
||||
export const BRIDGE_EVENTS = [
|
||||
'theme.changed',
|
||||
'locale.changed',
|
||||
] as const
|
||||
|
||||
export const BRIDGE_EVENTS_EXPERIMENTAL = [
|
||||
'vm.stateChanged',
|
||||
'view.visibilityChanged',
|
||||
'task.updated',
|
||||
] as const
|
||||
|
||||
export type BridgeMethod = (typeof BRIDGE_METHODS)[number] | (typeof BRIDGE_METHODS_EXPERIMENTAL)[number]
|
||||
export type BridgeEventName = (typeof BRIDGE_EVENTS)[number] | (typeof BRIDGE_EVENTS_EXPERIMENTAL)[number]
|
||||
|
||||
/** Plugin → host request. `id` is chosen by the plugin and echoed in the result. */
|
||||
export interface BridgeRequest {
|
||||
type: 'reims:rpc'
|
||||
id: string
|
||||
method: BridgeMethod
|
||||
params?: Record<string, unknown>
|
||||
}
|
||||
|
||||
/** Host → plugin response to one request. */
|
||||
export type BridgeResult =
|
||||
| { type: 'reims:rpc-result'; id: string; ok: true; result: unknown }
|
||||
| { type: 'reims:rpc-result'; id: string; ok: false; error: string }
|
||||
|
||||
/** Host → plugin event. Stable events are always delivered; others only after `events.subscribe`. */
|
||||
export interface BridgeEvent {
|
||||
type: 'reims:event'
|
||||
event: BridgeEventName
|
||||
data: unknown
|
||||
}
|
||||
|
||||
/** Result of `hello`, the first call a view or panel makes. */
|
||||
export interface BridgeHello {
|
||||
bridgeApi: string
|
||||
uiApi: string
|
||||
/** Stable host features, e.g. `bridge.vm.list`; feature-detect instead of comparing versions. */
|
||||
features: string[]
|
||||
locale: string
|
||||
dir: 'ltr' | 'rtl'
|
||||
}
|
||||
+140
-31
@@ -1,6 +1,12 @@
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { formatLocaleNumber } from '../i18n/icu'
|
||||
import { DisplayPreset, GPUInfo, HostReport, Locale, VMDetail } from '../types'
|
||||
|
||||
function currentDocLocale(): string {
|
||||
if (typeof document === 'undefined') return 'en-US'
|
||||
return document.documentElement.dataset.locale || document.documentElement.lang || 'en-US'
|
||||
}
|
||||
|
||||
// Human-readable values for the main view (docs/design-guidelines.md §7.1).
|
||||
// Raw values stay available under "Technical details".
|
||||
|
||||
@@ -45,12 +51,14 @@ export function parseMemoryGB(raw: string | undefined): number | null {
|
||||
return unit === 'T' ? n * 1024 : unit === 'G' ? n : unit === 'M' ? n / 1024 : n / 1024 / 1024
|
||||
}
|
||||
|
||||
/** "16G" / "16384M" / "16GiB" → "16 GB". Unknown shapes pass through. */
|
||||
export function formatMemory(raw: string): string {
|
||||
/** "16G" / "16384M" / "16GiB" → "16 GB" (or "16,5 GB" in comma-decimal locales). */
|
||||
export function formatMemory(raw: string, locale?: Locale): string {
|
||||
const gb = parseMemoryGB(raw)
|
||||
if (gb === null) return raw
|
||||
const rounded = gb >= 10 ? Math.round(gb) : Math.round(gb * 10) / 10
|
||||
return `${rounded} GB`
|
||||
const loc = locale ?? currentDocLocale()
|
||||
const precision = Number.isInteger(rounded) ? 0 : 1
|
||||
return `${formatLocaleNumber(loc, rounded, precision)} GB`
|
||||
}
|
||||
|
||||
export function controllerLabel(raw: string): string {
|
||||
@@ -159,7 +167,7 @@ export function sshCommand(port: number): string {
|
||||
return `ssh -p ${port} 127.0.0.1`
|
||||
}
|
||||
|
||||
export function formatBytes(bytes: number): string {
|
||||
export function formatBytes(bytes: number, locale?: Locale): string {
|
||||
if (!bytes || bytes <= 0) return '0 B'
|
||||
const units = ['B', 'KB', 'MB', 'GB', 'TB']
|
||||
let v = bytes
|
||||
@@ -169,20 +177,22 @@ export function formatBytes(bytes: number): string {
|
||||
i++
|
||||
}
|
||||
const digits = v >= 100 || i === 0 ? 0 : v >= 10 ? 1 : 2
|
||||
return `${v.toFixed(digits)} ${units[i]}`
|
||||
const loc = locale ?? currentDocLocale()
|
||||
return `${formatLocaleNumber(loc, v, digits)} ${units[i]}`
|
||||
}
|
||||
|
||||
/** Compact "54 / 128 GB" when both are gigabytes, falling back to full units. */
|
||||
export function formatDiskUsage(actual: number, virtual: number): string {
|
||||
export function formatDiskUsage(actual: number, virtual: number, locale?: Locale): string {
|
||||
const GiB = 1024 ** 3
|
||||
const loc = locale ?? currentDocLocale()
|
||||
if (actual >= GiB && virtual >= GiB && virtual < 1024 * GiB) {
|
||||
const a = actual / GiB
|
||||
const v = virtual / GiB
|
||||
const aStr = a >= 10 ? Math.round(a).toString() : a.toFixed(1)
|
||||
const vStr = Math.round(v).toString()
|
||||
const aStr = a >= 10 ? formatLocaleNumber(loc, Math.round(a), 0) : formatLocaleNumber(loc, a, 1)
|
||||
const vStr = formatLocaleNumber(loc, Math.round(v), 0)
|
||||
return `${aStr} / ${vStr} GB`
|
||||
}
|
||||
return `${formatBytes(actual)} / ${formatBytes(virtual)}`
|
||||
return `${formatBytes(actual, loc)} / ${formatBytes(virtual, loc)}`
|
||||
}
|
||||
|
||||
export function formatUptime(sec: number, locale: Locale): string {
|
||||
@@ -190,14 +200,9 @@ export function formatUptime(sec: number, locale: Locale): string {
|
||||
const h = Math.floor(sec / 3600)
|
||||
const m = Math.floor((sec % 3600) / 60)
|
||||
const s = sec % 60
|
||||
if (locale.toLowerCase().startsWith('zh')) {
|
||||
if (h > 0) return `${h}小时 ${m}分`
|
||||
if (m > 0) return `${m}分 ${s}秒`
|
||||
return `${s}秒`
|
||||
}
|
||||
if (h > 0) return `${h}h ${m}m`
|
||||
if (m > 0) return `${m}m ${s}s`
|
||||
return `${s}s`
|
||||
if (h > 0) return t(locale, 'uptimeHoursMinutes', { h, m })
|
||||
if (m > 0) return t(locale, 'uptimeMinutesSeconds', { m, s })
|
||||
return t(locale, 'uptimeSeconds', { s })
|
||||
}
|
||||
|
||||
// Used only when the host report has no presets: with nothing known about the
|
||||
@@ -242,6 +247,95 @@ export function recommendedDisplayPresets(host: HostReport): DisplayPreset[] {
|
||||
return DEFAULT_DISPLAY_PRESETS
|
||||
}
|
||||
|
||||
export interface FullscreenDisplayPreset extends DisplayPreset {
|
||||
native?: boolean
|
||||
scaleBadge?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolution presets for borderless fullscreen mode, decoupled from the host
|
||||
* monitor's physical pixels (requires runtime with display-fixed-mode patch
|
||||
* for non-native sizes). On a 4K screen, 5120x2880 renders 2x HiDPI and
|
||||
* downscales to 3840x2160 for a crisp 1.5x ("looks like 2560x1440") desktop.
|
||||
*/
|
||||
export function fullscreenDisplayPresets(host: HostReport): FullscreenDisplayPreset[] {
|
||||
const d = host.primary_display
|
||||
if (!d || d.width <= 0 || d.height <= 0) {
|
||||
return [
|
||||
{ resolution: '5120x2880', label: '5120 × 2880', hidpi: true, scaleBadge: '1.5×' },
|
||||
{ resolution: '3840x2160', label: '3840 × 2160', hidpi: true, native: true, recommended: true },
|
||||
{ resolution: '2560x1440', label: '2560 × 1440', hidpi: false },
|
||||
]
|
||||
}
|
||||
const w = d.width
|
||||
const h = d.height
|
||||
const scalePct = d.scale_pct || 100
|
||||
const align16 = (n: number) => Math.max(16, Math.floor(n / 16) * 16)
|
||||
const align2 = (n: number) => Math.max(2, Math.floor(n / 2) * 2)
|
||||
const out: FullscreenDisplayPreset[] = []
|
||||
const seen = new Set<string>()
|
||||
const push = (p: FullscreenDisplayPreset) => {
|
||||
if (!seen.has(p.resolution)) {
|
||||
seen.add(p.resolution)
|
||||
out.push(p)
|
||||
}
|
||||
}
|
||||
|
||||
// 1.5× HiDPI supersampling for ~4K+ displays (e.g. 3840×2160 -> 5120×2880,
|
||||
// 3840×2400 -> 5120×3200; macOS renders 2× HiDPI = looks like 2560×1440 / 1600).
|
||||
if (w >= 3200) {
|
||||
const sw = align16((w * 4) / 3)
|
||||
const sh = align2((h * 4) / 3)
|
||||
if (sw <= 5120 && sh <= 3200 && (sw !== w || sh !== h)) {
|
||||
push({
|
||||
resolution: `${sw}x${sh}`,
|
||||
label: `${sw} × ${sh}`,
|
||||
hidpi: true,
|
||||
scaleBadge: '1.5×',
|
||||
recommended: scalePct >= 125 && scalePct < 175,
|
||||
})
|
||||
}
|
||||
} else if (w >= 1920) {
|
||||
// Supersampled 2× HiDPI for 1080p / 1440p displays (capped at 5120×3200;
|
||||
// on 2560×1440, 3840×2160 gives crisp "looks like 1920×1080").
|
||||
const factor = w <= 1920 ? 2 : 1.5
|
||||
const sw = Math.min(5120, align16(w * factor))
|
||||
const sh = Math.min(3200, align2((sw * h) / w))
|
||||
if (sw >= 3840 && sh >= 2160 && (sw !== w || sh !== h)) {
|
||||
push({
|
||||
resolution: `${sw}x${sh}`,
|
||||
label: `${sw} × ${sh}`,
|
||||
hidpi: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Native 1:1 monitor resolution (zero-copy blit path).
|
||||
const nativeRecommended = !out.some((p) => p.recommended)
|
||||
push({
|
||||
resolution: `${w}x${h}`,
|
||||
label: `${w} × ${h}`,
|
||||
hidpi: !!host.fullscreen_hidpi,
|
||||
native: true,
|
||||
recommended: nativeRecommended,
|
||||
})
|
||||
|
||||
// 1× scaled option for 4K+ monitors (e.g. 2560×1440 on 4K = 1.5× logical size without HiDPI).
|
||||
if (w >= 3840) {
|
||||
const lw = align16((w * 2) / 3)
|
||||
const lh = align2((h * 2) / 3)
|
||||
if (lw >= 1920 && lh >= 1080) {
|
||||
push({
|
||||
resolution: `${lw}x${lh}`,
|
||||
label: `${lw} × ${lh}`,
|
||||
hidpi: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
export function recommendedResolution(host: HostReport): string {
|
||||
if (host.recommended_resolution) return host.recommended_resolution
|
||||
const rec = recommendedDisplayPresets(host).find((p) => p.recommended)
|
||||
@@ -250,19 +344,27 @@ export function recommendedResolution(host: HostReport): string {
|
||||
|
||||
export interface GuestLangPreset {
|
||||
value: string
|
||||
zh: string
|
||||
en: string
|
||||
labelKey: I18nKey
|
||||
detailKey?: I18nKey
|
||||
}
|
||||
|
||||
export const GUEST_LANG_PRESETS: GuestLangPreset[] = [
|
||||
{ value: 'zh-Hans:0', zh: '简体中文(美式键盘,推荐)', en: 'Simplified Chinese (US Keyboard)' },
|
||||
{ value: 'zh-Hans:252', zh: '简体中文(拼音键盘)', en: 'Simplified Chinese (Pinyin)' },
|
||||
{ value: 'zh-Hant:0', zh: '繁體中文(美式键盘)', en: 'Traditional Chinese (US Keyboard)' },
|
||||
{ value: 'en-US:0', zh: 'English (US)', en: 'English (US)' },
|
||||
{ value: 'ja-JP:0', zh: '日本語(美式键盘)', en: 'Japanese (US Keyboard)' },
|
||||
{ value: 'ko-KR:0', zh: '한국어(美式键盘)', en: 'Korean (US Keyboard)' },
|
||||
{ value: 'zh-Hans:0', labelKey: 'guestLangZhHansUS', detailKey: 'guestKbdUSRecommended' },
|
||||
{ value: 'zh-Hans:252', labelKey: 'guestLangZhHansUS', detailKey: 'guestKbdPinyin' },
|
||||
{ value: 'zh-Hant:0', labelKey: 'guestLangZhHantUS', detailKey: 'guestKbdUS' },
|
||||
{ value: 'en-US:0', labelKey: 'guestLangEnUS' },
|
||||
{ value: 'ja-JP:0', labelKey: 'guestLangJaJP', detailKey: 'guestKbdUS' },
|
||||
{ value: 'ko-KR:0', labelKey: 'guestLangKoKR', detailKey: 'guestKbdUS' },
|
||||
]
|
||||
|
||||
export function guestLangOptions(locale: Locale): Array<{ value: string; label: string; detail?: string }> {
|
||||
return GUEST_LANG_PRESETS.map((p) => ({
|
||||
value: p.value,
|
||||
label: t(locale, p.labelKey),
|
||||
detail: p.detailKey ? t(locale, p.detailKey) : undefined,
|
||||
}))
|
||||
}
|
||||
|
||||
export function defaultGuestLang(locale: Locale): string {
|
||||
const l = locale.toLowerCase()
|
||||
if (l === 'zh-tw' || l === 'zh-hk' || l === 'zh-mo' || l.startsWith('zh-hant')) return 'zh-Hant:0'
|
||||
@@ -272,11 +374,18 @@ export function defaultGuestLang(locale: Locale): string {
|
||||
return 'en-US:0'
|
||||
}
|
||||
|
||||
export function resolveGuestLang(locale: Locale, code: string | undefined): { label: string; detail?: string } {
|
||||
const target = code || defaultGuestLang(locale)
|
||||
const hit = GUEST_LANG_PRESETS.find((p) => p.value === target)
|
||||
if (!hit) return { label: target }
|
||||
const label = t(locale, hit.labelKey)
|
||||
const detail = hit.detailKey ? t(locale, hit.detailKey) : undefined
|
||||
return { label, detail }
|
||||
}
|
||||
|
||||
export function guestLangLabel(locale: Locale, code: string | undefined): string {
|
||||
if (!code) return defaultGuestLang(locale)
|
||||
const hit = GUEST_LANG_PRESETS.find((p) => p.value === code)
|
||||
if (hit) return locale.toLowerCase().startsWith('zh') ? hit.zh : hit.en
|
||||
return code
|
||||
const { label, detail } = resolveGuestLang(locale, code)
|
||||
return detail ? `${label} (${detail})` : label
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -296,10 +405,10 @@ export function splitLangLabel(value: string, text: string): { value: string; la
|
||||
export function pendingChangeText(locale: Locale, p: { field: string; from: string; to: string }, host: HostReport): string {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const bool = (v: string) => tr(v === 'true' ? 'on' : 'off')
|
||||
const lang = (v: string) => splitLangLabel('', guestLangLabel(locale, v)).label
|
||||
const lang = (v: string) => resolveGuestLang(locale, v).label
|
||||
const fields: Record<string, { label: I18nKey; fmt: (v: string) => string }> = {
|
||||
cpus: { label: 'factCPU', fmt: (v) => tr('cores', { n: v }) },
|
||||
memory: { label: 'factMemory', fmt: formatMemory },
|
||||
memory: { label: 'factMemory', fmt: (v) => formatMemory(v, locale) },
|
||||
resolution: { label: 'resolution', fmt: resolutionLabel },
|
||||
gpu: { label: 'factGraphics', fmt: (v) => gpuLabel(locale, v, host) },
|
||||
displays: { label: 'displays', fmt: (v) => v },
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../i18n/domains/settings.gen'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { Locale, Optimization, OptimizationStatus } from '../types'
|
||||
|
||||
|
||||
+136
-3
@@ -1,5 +1,5 @@
|
||||
import { t } from '../i18n'
|
||||
import { Locale, Task } from '../types'
|
||||
import { CachedInstaller, InstallerKind, InstallerPhase, Locale, Task } from '../types'
|
||||
|
||||
// Match the finished-task retention period in internal/app/tasks.go.
|
||||
export const finishedTaskTTL = 10 * 60 * 1000
|
||||
@@ -21,10 +21,15 @@ export function upsertTask(prev: Record<string, Task>, task: Task): Record<strin
|
||||
return { ...prev, [task.id]: task }
|
||||
}
|
||||
|
||||
/** The task to show in the status bar: the most recently updated running one. */
|
||||
/** The task to show in the status bar: active work ahead of queued downloads, newest first. */
|
||||
export function currentTask(all: Record<string, Task>): { task: Task | null; running: number } {
|
||||
const running = Object.values(all).filter((x) => x.status === 'running')
|
||||
running.sort((a, b) => b.updated_at - a.updated_at)
|
||||
running.sort((a, b) => {
|
||||
const aq = a.installer_phase === 'queued' ? 1 : 0
|
||||
const bq = b.installer_phase === 'queued' ? 1 : 0
|
||||
if (aq !== bq) return aq - bq
|
||||
return b.updated_at - a.updated_at
|
||||
})
|
||||
return { task: running[0] ?? null, running: running.length }
|
||||
}
|
||||
|
||||
@@ -49,6 +54,134 @@ export function taskDetail(task: Task): string {
|
||||
return parts.join(' · ')
|
||||
}
|
||||
|
||||
export function isInstallerTask(task: Task): boolean {
|
||||
return task.kind === 'installer-download' || task.kind === 'recovery-download' || !!task.installer_kind
|
||||
}
|
||||
|
||||
export function taskInstallerKind(task: Task): InstallerKind | '' {
|
||||
if (task.installer_kind === 'offline' || task.installer_kind === 'online') return task.installer_kind
|
||||
if (task.kind === 'installer-download') return 'offline'
|
||||
if (task.kind === 'recovery-download') return 'online'
|
||||
return ''
|
||||
}
|
||||
|
||||
export function taskInstallerVersion(task: Task): string {
|
||||
const v = (task.installer_version ?? '').trim()
|
||||
if (v) return v
|
||||
if (task.kind === 'installer-download') return task.subject.trim()
|
||||
if (task.kind === 'recovery-download') return 'latest'
|
||||
return ''
|
||||
}
|
||||
|
||||
export function taskInstallerPhase(task: Task): InstallerPhase | '' {
|
||||
if (task.status !== 'running') return ''
|
||||
if (task.installer_phase === 'queued' || task.installer_phase === 'downloading') return task.installer_phase
|
||||
if (task.kind === 'installer-download' || task.kind === 'recovery-download') return 'downloading'
|
||||
return ''
|
||||
}
|
||||
|
||||
export function isActiveInstallerTask(task: Task): boolean {
|
||||
return taskInstallerPhase(task) !== ''
|
||||
}
|
||||
|
||||
export function taskInstallerKey(task: Task): string {
|
||||
const kind = taskInstallerKind(task)
|
||||
if (!kind) return ''
|
||||
let v = taskInstallerVersion(task).toLowerCase()
|
||||
if (kind === 'online' && !v) v = 'latest'
|
||||
return `${kind}:${v}`
|
||||
}
|
||||
|
||||
export function matchesOnlineInstallerTitle(title: string | undefined, target: string): boolean {
|
||||
const want = target.trim().toLowerCase()
|
||||
if (!want) return false
|
||||
const norm = (title ?? '').trim().toLowerCase().replace(/^macos\s+/, '')
|
||||
return norm === want || norm.replace(/\s+/g, '-') === want
|
||||
}
|
||||
|
||||
export function matchesCachedInstaller(item: CachedInstaller, task: Task): boolean {
|
||||
if (!isActiveInstallerTask(task)) return false
|
||||
const kind = taskInstallerKind(task)
|
||||
if (!kind || kind !== item.kind) return false
|
||||
const v = taskInstallerVersion(task).toLowerCase()
|
||||
if (kind === 'offline') {
|
||||
if (item.version && item.version.toLowerCase() === v) return true
|
||||
return item.partial && !!v && !/^\d/.test(v) && matchesOnlineInstallerTitle(item.title, v)
|
||||
}
|
||||
if (!v || v === 'latest') return item.partial
|
||||
return matchesOnlineInstallerTitle(item.title, v)
|
||||
}
|
||||
|
||||
export interface ActiveInstallerMatch {
|
||||
primary: Task
|
||||
waitingVMs: string[]
|
||||
matchedIDs: string[]
|
||||
}
|
||||
|
||||
function isStandaloneDownload(task: Task): boolean {
|
||||
return task.kind === 'installer-download' || task.kind === 'recovery-download'
|
||||
}
|
||||
|
||||
function pickPrimaryInstallerTask(matches: Task[]): ActiveInstallerMatch | null {
|
||||
if (matches.length === 0) return null
|
||||
const sorted = [...matches].sort((a, b) => {
|
||||
const aStandalone = isStandaloneDownload(a) ? 0 : 1
|
||||
const bStandalone = isStandaloneDownload(b) ? 0 : 1
|
||||
if (aStandalone !== bStandalone) return aStandalone - bStandalone
|
||||
const aQueued = taskInstallerPhase(a) === 'queued' ? 1 : 0
|
||||
const bQueued = taskInstallerPhase(b) === 'queued' ? 1 : 0
|
||||
if (aQueued !== bQueued) return aQueued - bQueued
|
||||
return a.started_at - b.started_at
|
||||
})
|
||||
const primary = sorted[0]
|
||||
const waitingVMs: string[] = []
|
||||
for (const other of sorted.slice(1)) {
|
||||
if (other.kind !== 'vm-create') continue
|
||||
const vm = (other.vm || other.subject).trim()
|
||||
if (vm && !waitingVMs.includes(vm)) waitingVMs.push(vm)
|
||||
}
|
||||
return { primary, waitingVMs, matchedIDs: sorted.map((x) => x.id) }
|
||||
}
|
||||
|
||||
export function findActiveOfflineTask(tasks: Task[], version: string): ActiveInstallerMatch | null {
|
||||
const want = version.trim().toLowerCase()
|
||||
if (!want) return null
|
||||
const matches = tasks.filter(
|
||||
(x) => isActiveInstallerTask(x) && taskInstallerKind(x) === 'offline' && taskInstallerVersion(x).toLowerCase() === want,
|
||||
)
|
||||
return pickPrimaryInstallerTask(matches)
|
||||
}
|
||||
|
||||
export function findActiveCachedTask(tasks: Task[], item: CachedInstaller): ActiveInstallerMatch | null {
|
||||
const matches = tasks.filter((x) => matchesCachedInstaller(item, x))
|
||||
return pickPrimaryInstallerTask(matches)
|
||||
}
|
||||
|
||||
export function groupUnmatchedInstallerTasks(activeTasks: Task[], matchedTaskIDs: Set<string>): ActiveInstallerMatch[] {
|
||||
const buckets = new Map<string, Task[]>()
|
||||
for (const task of activeTasks) {
|
||||
if (matchedTaskIDs.has(task.id)) continue
|
||||
const key = taskInstallerKey(task)
|
||||
if (!key) continue
|
||||
const list = buckets.get(key)
|
||||
if (list) list.push(task)
|
||||
else buckets.set(key, [task])
|
||||
}
|
||||
const out: ActiveInstallerMatch[] = []
|
||||
for (const group of buckets.values()) {
|
||||
const picked = pickPrimaryInstallerTask(group)
|
||||
if (picked) out.push(picked)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
export function taskStopAction(locale: Locale, task: Task): { kind: 'pause' | 'cancel'; label: string } {
|
||||
if (task.kind === 'vm-create') return { kind: 'cancel', label: t(locale, 'cancelCreate') }
|
||||
if (task.kind === 'app-update') return { kind: 'cancel', label: t(locale, 'updateCancel') }
|
||||
if (taskInstallerPhase(task) === 'queued') return { kind: 'cancel', label: t(locale, 'cancelQueue') }
|
||||
return { kind: 'pause', label: t(locale, 'pauseDownload') }
|
||||
}
|
||||
|
||||
function bytes(b: number): string {
|
||||
if (b >= 1e9) return `${(b / 1e9).toFixed(1)} GB`
|
||||
return `${Math.max(1, Math.ceil(b / 1e6))} MB`
|
||||
|
||||
+214
-22
@@ -6,7 +6,7 @@
|
||||
// declarative state-driven slot decorations.
|
||||
// - Tier 3 (Interactive theme): lazy-loads `./uiSdk` only when a trusted `ui_script_url` is active.
|
||||
|
||||
import { UI_CONTRACT_TOKENS } from '../styles/ui-contract'
|
||||
import { UI_CONTRACT_LAYOUT_OPTIONS, UI_CONTRACT_TOKENS, type UIContractSDKEvent } from '../styles/ui-contract'
|
||||
import type { ActiveThemePayload, ThemeDecoration, ThemeDecorationState, TokenDeriveRule } from '../types'
|
||||
|
||||
const LEGACY_CACHE_KEY = 'reims-go-theme-tokens-v1'
|
||||
@@ -34,6 +34,8 @@ interface ThemeTokenCache {
|
||||
export interface UIStateSnapshot {
|
||||
appearance: 'light' | 'dark'
|
||||
motion: 'full' | 'reduced'
|
||||
locale: string
|
||||
dir: 'ltr' | 'rtl'
|
||||
view: string
|
||||
vmName: string
|
||||
vmState: string
|
||||
@@ -51,7 +53,18 @@ export interface ThemeSDKHostActions {
|
||||
}
|
||||
|
||||
let activeUIScriptCleanup: (() => void) | null = null
|
||||
let activeUIScriptNotifier: ((snap: UIStateSnapshot) => void) | null = null
|
||||
let activeUIScriptURL = ''
|
||||
let activeUIScriptEventSink: ((event: string, data: unknown) => void) | null = null
|
||||
|
||||
/**
|
||||
* Forwards a host event to the interactive theme's `sdk.on` handlers. A no-op
|
||||
* unless an interactive theme is loaded; payloads carry no paths or secrets.
|
||||
*/
|
||||
export function emitThemeEvent(event: UIContractSDKEvent, data: unknown): void {
|
||||
if (!activeUIScriptEventSink) return
|
||||
try { activeUIScriptEventSink(event, data) } catch (e) { console.warn('[theme] UI script event handler failed:', event, e) }
|
||||
}
|
||||
let applyGeneration = 0
|
||||
|
||||
function decodeCSSEscapes(s: string): string {
|
||||
@@ -106,6 +119,34 @@ function sanitizeRelativeAssetPath(rel: string): string | null {
|
||||
return cleaned
|
||||
}
|
||||
|
||||
/** Resolves a theme package asset to its served URL, or null when unsafe. */
|
||||
export function themeAssetURL(payload: ActiveThemePayload | null, rel: string | undefined): string | null {
|
||||
if (!payload || !rel) return null
|
||||
const rawBaseURL = payload.asset_base_url ?? ''
|
||||
if (!RE_ASSET_BASE_URL.test(rawBaseURL) || rawBaseURL.includes('..')) return null
|
||||
const safe = sanitizeRelativeAssetPath(rel)
|
||||
return safe ? rawBaseURL + safe : null
|
||||
}
|
||||
|
||||
// Theme `layout` option → <html> attribute (ui-contract UI_CONTRACT_LAYOUT_OPTIONS).
|
||||
const LAYOUT_ATTRS: Record<string, string> = {
|
||||
sidebarPosition: 'data-layout-sidebar',
|
||||
sidebarMode: 'data-layout-sidebar-mode',
|
||||
density: 'data-layout-density',
|
||||
titlebar: 'data-layout-titlebar',
|
||||
}
|
||||
const ALLOWED_LAYOUT = new Set<string>(UI_CONTRACT_LAYOUT_OPTIONS)
|
||||
|
||||
/** Writes the active theme's layout options as data-layout-* attributes; null clears them. */
|
||||
export function applyThemeLayout(layout: Record<string, unknown> | null | undefined): void {
|
||||
const el = document.documentElement
|
||||
for (const [option, attr] of Object.entries(LAYOUT_ATTRS)) {
|
||||
const value = layout?.[option]
|
||||
if (typeof value === 'string' && ALLOWED_LAYOUT.has(`${option}=${value}`)) el.setAttribute(attr, value)
|
||||
else el.removeAttribute(attr)
|
||||
}
|
||||
}
|
||||
|
||||
/** Verifies stylesheet has balanced braces and no unclosed strings/comments so it cannot escape `@layer theme` (B5). */
|
||||
export function isBalancedThemeCSS(css: string): boolean {
|
||||
if (css.toLowerCase().includes('</style')) return false
|
||||
@@ -159,8 +200,8 @@ function resolveInitialAppearance(): 'light' | 'dark' {
|
||||
try {
|
||||
const saved = localStorage.getItem('reims-go-theme')
|
||||
if (saved === 'dark' || saved === 'light') return saved
|
||||
} catch {
|
||||
// ignore storage errors
|
||||
} catch (e) {
|
||||
console.warn('[theme] read theme preference failed:', e)
|
||||
}
|
||||
return window.matchMedia?.('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
|
||||
}
|
||||
@@ -177,8 +218,8 @@ function clearLegacyInlineCache(): void {
|
||||
}
|
||||
localStorage.removeItem(LEGACY_CACHE_KEY)
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
} catch (e) {
|
||||
console.warn('[theme] clear legacy inline cache failed:', e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,8 +255,8 @@ export function applyCachedThemeTokensSync(): void {
|
||||
document.head.appendChild(el)
|
||||
}
|
||||
el.textContent = `@layer theme {\n:root {\n${varLines}\n}\n}`
|
||||
} catch {
|
||||
// ignore corrupt cache
|
||||
} catch (e) {
|
||||
console.warn('[theme] apply cached theme tokens failed:', e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,25 +267,26 @@ function clearDynamicThemeStyles(): void {
|
||||
clearLegacyInlineCache()
|
||||
try {
|
||||
localStorage.removeItem(THEME_CACHE_KEY)
|
||||
} catch {
|
||||
// ignore
|
||||
} catch (e) {
|
||||
console.warn('[theme] clear theme token cache failed:', e)
|
||||
}
|
||||
}
|
||||
|
||||
const RE_VALID_HEX = /^(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/
|
||||
|
||||
/** Parses a #RGB or #RRGGBB hex string into [h (0..360), s (0..1), l (0..1)]. */
|
||||
function hexToHSL(hex: string): [number, number, number] | null {
|
||||
const clean = hex.trim().replace(/^#/, '')
|
||||
if (!RE_VALID_HEX.test(clean)) return null
|
||||
let r = 0, g = 0, b = 0
|
||||
if (clean.length === 3) {
|
||||
r = parseInt(clean[0] + clean[0], 16) / 255
|
||||
g = parseInt(clean[1] + clean[1], 16) / 255
|
||||
b = parseInt(clean[2] + clean[2], 16) / 255
|
||||
} else if (clean.length === 6) {
|
||||
} else {
|
||||
r = parseInt(clean.slice(0, 2), 16) / 255
|
||||
g = parseInt(clean.slice(2, 4), 16) / 255
|
||||
b = parseInt(clean.slice(4, 6), 16) / 255
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) return null
|
||||
const max = Math.max(r, g, b)
|
||||
@@ -264,6 +306,86 @@ function clamp01(x: number): number {
|
||||
return Math.max(0, Math.min(1, x))
|
||||
}
|
||||
|
||||
function srgbChannelToLinear(c: number): number {
|
||||
return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4)
|
||||
}
|
||||
|
||||
/** Computes WCAG 2.1 relative luminance (0..1) for a #RGB or #RRGGBB hex string. */
|
||||
function hexRelativeLuminance(hex: string): number | null {
|
||||
const clean = hex.trim().replace(/^#/, '')
|
||||
if (!RE_VALID_HEX.test(clean)) return null
|
||||
let r = 0, g = 0, b = 0
|
||||
if (clean.length === 3) {
|
||||
r = parseInt(clean[0] + clean[0], 16) / 255
|
||||
g = parseInt(clean[1] + clean[1], 16) / 255
|
||||
b = parseInt(clean[2] + clean[2], 16) / 255
|
||||
} else {
|
||||
r = parseInt(clean.slice(0, 2), 16) / 255
|
||||
g = parseInt(clean.slice(2, 4), 16) / 255
|
||||
b = parseInt(clean.slice(4, 6), 16) / 255
|
||||
}
|
||||
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) return null
|
||||
return 0.2126 * srgbChannelToLinear(r) + 0.7152 * srgbChannelToLinear(g) + 0.0722 * srgbChannelToLinear(b)
|
||||
}
|
||||
|
||||
function hslRelativeLuminance(hDeg: number, s: number, l: number): number {
|
||||
const c = (1 - Math.abs(2 * l - 1)) * s
|
||||
const hp = ((hDeg % 360) + 360) % 360 / 60
|
||||
const x = c * (1 - Math.abs((hp % 2) - 1))
|
||||
let r1 = 0, g1 = 0, b1 = 0
|
||||
if (hp < 1) [r1, g1, b1] = [c, x, 0]
|
||||
else if (hp < 2) [r1, g1, b1] = [x, c, 0]
|
||||
else if (hp < 3) [r1, g1, b1] = [0, c, x]
|
||||
else if (hp < 4) [r1, g1, b1] = [0, x, c]
|
||||
else if (hp < 5) [r1, g1, b1] = [x, 0, c]
|
||||
else [r1, g1, b1] = [c, 0, x]
|
||||
const m = l - c / 2
|
||||
return (
|
||||
0.2126 * srgbChannelToLinear(clamp01(r1 + m)) +
|
||||
0.7152 * srgbChannelToLinear(clamp01(g1 + m)) +
|
||||
0.0722 * srgbChannelToLinear(clamp01(b1 + m))
|
||||
)
|
||||
}
|
||||
|
||||
function contrastRatio(lumA: number, lumB: number): number {
|
||||
const hi = Math.max(lumA, lumB)
|
||||
const lo = Math.min(lumA, lumB)
|
||||
return (hi + 0.05) / (lo + 0.05)
|
||||
}
|
||||
|
||||
function pickAccessibleSoftAccentText(h: number, s: number, l: number, appearance: 'light' | 'dark'): string {
|
||||
// Target surface luminance: light canvas/soft (~0.92), dark surface (~0.015 for #1d1e23).
|
||||
const surfaceLum = appearance === 'dark' ? 0.015 : 0.92
|
||||
const targetRatio = 4.6
|
||||
let candidateL = appearance === 'dark' ? Math.max(l, 0.66) : Math.min(l, 0.42)
|
||||
if (contrastRatio(hslRelativeLuminance(h, s, candidateL), surfaceLum) < targetRatio) {
|
||||
let lo = appearance === 'dark' ? candidateL : 0
|
||||
let hi = appearance === 'dark' ? 1 : candidateL
|
||||
for (let i = 0; i < 16; i++) {
|
||||
const mid = (lo + hi) / 2
|
||||
const ok = contrastRatio(hslRelativeLuminance(h, s, mid), surfaceLum) >= targetRatio
|
||||
if (appearance === 'dark') {
|
||||
if (ok) hi = mid
|
||||
else lo = mid
|
||||
} else {
|
||||
if (ok) lo = mid
|
||||
else hi = mid
|
||||
}
|
||||
}
|
||||
candidateL = appearance === 'dark' ? hi : lo
|
||||
}
|
||||
return `hsl(${Math.round(h)} ${Math.round(s * 100)}% ${Math.round(clamp01(candidateL) * 100)}%)`
|
||||
}
|
||||
|
||||
function pickHighContrastAccentText(hex: string): string {
|
||||
const lum = hexRelativeLuminance(hex)
|
||||
if (lum === null) return '#ffffff'
|
||||
const whiteContrast = 1.05 / (lum + 0.05)
|
||||
const darkInkLum = 0.0123 // #1d1d1f
|
||||
const darkContrast = (lum + 0.05) / (darkInkLum + 0.05)
|
||||
return darkContrast > whiteContrast ? '#1d1d1f' : '#ffffff'
|
||||
}
|
||||
|
||||
/** Derives CSS variable values from seed colors using declarative rules (§5.1). */
|
||||
export function deriveTokensFromSeeds(
|
||||
seeds: Record<string, string>,
|
||||
@@ -276,9 +398,10 @@ export function deriveTokensFromSeeds(
|
||||
out['--accent'] = seeds.accent
|
||||
if (hsl) {
|
||||
const [h, s, l] = hsl
|
||||
out['--accent-text'] = pickHighContrastAccentText(seeds.accent)
|
||||
out['--accent-hover'] = `hsl(${Math.round(h)} ${Math.round(s * 100)}% ${Math.round(clamp01(l + (appearance === 'dark' ? 0.06 : -0.06)) * 100)}%)`
|
||||
out['--accent-soft'] = `hsla(${Math.round(h)}, ${Math.round(s * 100)}%, ${Math.round(l * 100)}%, ${appearance === 'dark' ? 0.2 : 0.12})`
|
||||
out['--accent-soft-text'] = `hsl(${Math.round(h)} ${Math.round(s * 100)}% ${Math.round(clamp01(appearance === 'dark' ? Math.max(l, 0.66) : Math.min(l, 0.42)) * 100)}%)`
|
||||
out['--accent-soft-text'] = pickAccessibleSoftAccentText(h, s, l, appearance)
|
||||
out['--focus-ring'] = `0 0 0 3px hsla(${Math.round(h)}, ${Math.round(s * 100)}%, ${Math.round(l * 100)}%, ${appearance === 'dark' ? 0.45 : 0.30})`
|
||||
}
|
||||
}
|
||||
@@ -351,7 +474,7 @@ export async function applyActiveTheme(
|
||||
// Always tear down previous interactive theme script if URL changed or disabled.
|
||||
const nextScriptURL = payload?.ui_script_url ?? ''
|
||||
if (activeUIScriptCleanup && activeUIScriptURL !== nextScriptURL) {
|
||||
try { activeUIScriptCleanup() } catch {}
|
||||
try { activeUIScriptCleanup() } catch (e) { console.warn('[theme] UI script cleanup failed:', e) }
|
||||
activeUIScriptCleanup = null
|
||||
activeUIScriptURL = ''
|
||||
}
|
||||
@@ -359,10 +482,12 @@ export async function applyActiveTheme(
|
||||
// Builtin default theme (or safe mode) -> zero extra CSS injected (§8.1).
|
||||
if (!payload || !payload.theme || payload.theme_id === 'builtin.theme.default') {
|
||||
clearDynamicThemeStyles()
|
||||
applyThemeLayout(null)
|
||||
return
|
||||
}
|
||||
|
||||
const th = payload.theme
|
||||
applyThemeLayout(th.layout as Record<string, unknown> | undefined)
|
||||
const rawBaseURL = payload.asset_base_url ?? ''
|
||||
const baseURL = RE_ASSET_BASE_URL.test(rawBaseURL) && !rawBaseURL.includes('..') ? rawBaseURL : ''
|
||||
|
||||
@@ -447,21 +572,27 @@ export async function applyActiveTheme(
|
||||
}
|
||||
nextCache[appearance] = sanitizedTokens
|
||||
localStorage.setItem(THEME_CACHE_KEY, JSON.stringify(nextCache))
|
||||
} catch {
|
||||
// ignore storage quota
|
||||
} catch (e) {
|
||||
console.warn('[theme] persist theme token cache failed:', e)
|
||||
}
|
||||
|
||||
// 5. Tier 3: lazy-load UI SDK ONLY when an approved interactive theme script is present (§8.1).
|
||||
if (nextScriptURL && nextScriptURL !== activeUIScriptURL) {
|
||||
try {
|
||||
const { mountInteractiveThemeScript } = await import('./uiSdk')
|
||||
const { mountInteractiveThemeScript, notifyThemeSDKState, emitThemeSDKEvent } = await import('./uiSdk')
|
||||
if (gen !== applyGeneration) return
|
||||
const cleanup = await mountInteractiveThemeScript(nextScriptURL, getState, actions)
|
||||
if (gen !== applyGeneration) {
|
||||
try { cleanup() } catch {}
|
||||
try { cleanup() } catch (e) { console.warn('[theme] stale UI script cleanup failed:', e) }
|
||||
return
|
||||
}
|
||||
activeUIScriptCleanup = cleanup
|
||||
activeUIScriptCleanup = () => {
|
||||
activeUIScriptNotifier = null
|
||||
activeUIScriptEventSink = null
|
||||
cleanup()
|
||||
}
|
||||
activeUIScriptNotifier = notifyThemeSDKState
|
||||
activeUIScriptEventSink = emitThemeSDKEvent
|
||||
activeUIScriptURL = nextScriptURL
|
||||
} catch {
|
||||
if (gen === applyGeneration) {
|
||||
@@ -473,6 +604,67 @@ export async function applyActiveTheme(
|
||||
}
|
||||
}
|
||||
|
||||
const LOCALE_FONT_EL_ID = 'rg-active-locale-fonts'
|
||||
const RE_SAFE_FONT_URL = /^\/plugin-assets\/[a-f0-9]+\/[a-z0-9][a-z0-9._-]*\/[a-zA-Z0-9._/@ -]+\.woff2$/i
|
||||
const RE_SAFE_FONT_FAMILY = /^[\p{L}\p{N} _-]{1,80}$/u
|
||||
|
||||
/**
|
||||
* Injects optional bundled `.woff2` WebFonts declared by the active language pack
|
||||
* into `--font-locale-pack` (scoped strictly inside `@layer theme`, zero cost when empty).
|
||||
*/
|
||||
export function applyActiveLocaleFonts(
|
||||
fonts: Array<{ family: string; url: string; weight?: string; style?: string; unicodeRange?: string }> | undefined,
|
||||
): void {
|
||||
const existing = document.getElementById(LOCALE_FONT_EL_ID)
|
||||
if (!fonts || fonts.length === 0) {
|
||||
existing?.remove()
|
||||
return
|
||||
}
|
||||
const rules: string[] = []
|
||||
const families: string[] = []
|
||||
for (const f of fonts) {
|
||||
const fam = (f.family || '').trim()
|
||||
if (!RE_SAFE_FONT_FAMILY.test(fam) || fam.toLowerCase().includes('</style')) continue
|
||||
if (!f.url || f.url.includes('..') || !RE_SAFE_FONT_URL.test(f.url)) continue
|
||||
const weight = f.weight && RE_FONT_WEIGHT.test(f.weight) ? f.weight : '400'
|
||||
const style = f.style && RE_FONT_STYLE.test(f.style) ? f.style : 'normal'
|
||||
const ur = f.unicodeRange && RE_UNICODE_RANGE.test(f.unicodeRange) ? `unicode-range: ${f.unicodeRange};` : ''
|
||||
rules.push(
|
||||
`@font-face { font-family: "${fam}"; src: url("${f.url}") format("woff2"); font-weight: ${weight}; font-style: ${style}; font-display: swap; ${ur} }`,
|
||||
)
|
||||
if (!families.includes(`"${fam}"`)) {
|
||||
families.push(`"${fam}"`)
|
||||
}
|
||||
}
|
||||
if (rules.length === 0) {
|
||||
existing?.remove()
|
||||
return
|
||||
}
|
||||
let styleEl = existing as HTMLStyleElement | null
|
||||
if (!styleEl) {
|
||||
styleEl = document.createElement('style')
|
||||
styleEl.id = LOCALE_FONT_EL_ID
|
||||
document.head.appendChild(styleEl)
|
||||
}
|
||||
styleEl.textContent = `@layer theme {\n:root {\n --font-locale-pack: ${families.join(', ')}, ;\n}\n${rules.join('\n')}\n}`
|
||||
}
|
||||
|
||||
/** Tears down injected theme/locale style nodes and active UI scripts on unmount. */
|
||||
export function disposeActiveThemeAndLocaleFonts(): void {
|
||||
if (activeUIScriptCleanup) {
|
||||
try { activeUIScriptCleanup() } catch (e) { console.warn('[theme] dispose UI script cleanup failed:', e) }
|
||||
activeUIScriptCleanup = null
|
||||
activeUIScriptNotifier = null
|
||||
activeUIScriptURL = ''
|
||||
}
|
||||
clearDynamicThemeStyles()
|
||||
document.getElementById(LOCALE_FONT_EL_ID)?.remove()
|
||||
}
|
||||
|
||||
export function notifyInteractiveThemeState(snap: UIStateSnapshot): void {
|
||||
activeUIScriptNotifier?.(snap)
|
||||
}
|
||||
|
||||
/** Plays a theme-configured sound for an event if present (fail-silent). */
|
||||
export function playThemeSound(payload: ActiveThemePayload | null, eventName: string): void {
|
||||
const file = payload?.theme?.sounds?.[eventName]
|
||||
@@ -482,8 +674,8 @@ export function playThemeSound(payload: ActiveThemePayload | null, eventName: st
|
||||
try {
|
||||
const audio = new Audio(payload.asset_base_url + safe)
|
||||
audio.volume = 0.35
|
||||
void audio.play().catch(() => {})
|
||||
} catch {
|
||||
// ignore audio decode/autoplay errors
|
||||
void audio.play().catch((e) => console.warn('[theme] sound playback failed:', eventName, e))
|
||||
} catch (e) {
|
||||
console.warn('[theme] sound init failed:', eventName, e)
|
||||
}
|
||||
}
|
||||
+77
-15
@@ -1,12 +1,17 @@
|
||||
// Lazy-loaded Tier-3 Interactive Theme UI SDK (docs/plugin-architecture.md §5.1).
|
||||
// Loaded ONLY when a trusted interactive theme with `ui:script` is enabled (§8.1).
|
||||
|
||||
import { UI_API_VERSION, UI_CONTRACT_PARTS, UI_CONTRACT_SLOTS, type UIContractPart, type UIContractSlot } from '../styles/ui-contract'
|
||||
import {
|
||||
UI_API_VERSION, UI_CONTRACT_FEATURES, UI_CONTRACT_LAYERS, UI_CONTRACT_PARTS, UI_CONTRACT_SDK_EVENTS, UI_CONTRACT_SLOTS,
|
||||
type UIContractLayer, type UIContractPart, type UIContractSDKEvent, type UIContractSlot,
|
||||
} from '../styles/ui-contract'
|
||||
import { hideWailsGlobals } from '../wails'
|
||||
import type { ThemeSDKHostActions, UIStateSnapshot } from './themeEngine'
|
||||
|
||||
export interface ReimsUISDK {
|
||||
readonly uiApi: string
|
||||
/** Stable host features (e.g. `slot.sidebar.footer`); feature-detect instead of comparing versions. */
|
||||
readonly features: readonly string[]
|
||||
/** Registers a cleanup callback run in LIFO order on theme switch/disable. */
|
||||
onDispose: (fn: () => void) => void
|
||||
/** Runs a named feature isolated so errors disable only that feature. */
|
||||
@@ -16,23 +21,44 @@ export interface ReimsUISDK {
|
||||
subscribeState: (cb: (snap: UIStateSnapshot) => void) => () => void
|
||||
/** Queries elements strictly by contract part class (`rg-p-*`). */
|
||||
queryPart: (part: UIContractPart) => HTMLElement | null
|
||||
/** All elements of a repeated part (e.g. `rg-p-nav-item`), in document order. */
|
||||
queryParts: (part: UIContractPart) => HTMLElement[]
|
||||
/** Shared MutationObserver bus scoped to a contract part. */
|
||||
observePart: (part: UIContractPart, cb: () => void) => () => void
|
||||
/** Shared RAF read/write batch pipeline to avoid layout thrashing. */
|
||||
scheduleRead: (fn: () => void) => void
|
||||
scheduleWrite: (fn: () => void) => void
|
||||
/** Framework-agnostic DOM mounting into a declared slot anchor. */
|
||||
mountSlot: (slot: UIContractSlot, node: HTMLElement) => () => void
|
||||
/**
|
||||
* Framework-agnostic DOM mounting into a declared slot anchor. Repeated slots
|
||||
* (`nav.item.trailing`) take the item key from `slotKeys`.
|
||||
*/
|
||||
mountSlot: (slot: UIContractSlot, node: HTMLElement, key?: string) => () => void
|
||||
/** Keys of the currently rendered instances of a repeated slot (VM references). */
|
||||
slotKeys: (slot: UIContractSlot) => string[]
|
||||
/** Mounts into a full-window layer (`layer.background` / `layer.overlay`). */
|
||||
mountLayer: (layer: UIContractLayer, node: HTMLElement) => () => void
|
||||
/** Subscribes to a host event (VM state, tasks, toasts, view changes). */
|
||||
on: (event: UIContractSDKEvent, cb: (data: unknown) => void) => () => void
|
||||
/** Restricted non-destructive UI actions only (no start/stop/delete/config write). */
|
||||
actions: ThemeSDKHostActions
|
||||
}
|
||||
|
||||
const stateListeners = new Set<(snap: UIStateSnapshot) => void>()
|
||||
const eventListeners = new Map<string, Set<(data: unknown) => void>>()
|
||||
|
||||
/** Delivers a host event to subscribed theme handlers (themeEngine.emitThemeEvent). */
|
||||
export function emitThemeSDKEvent(event: string, data: unknown): void {
|
||||
const set = eventListeners.get(event)
|
||||
if (!set) return
|
||||
for (const cb of set) {
|
||||
try { cb(data) } catch (e) { console.warn('[uiSdk] event listener failed:', event, e) }
|
||||
}
|
||||
}
|
||||
|
||||
export function notifyThemeSDKState(snap: UIStateSnapshot): void {
|
||||
if (stateListeners.size === 0) return
|
||||
for (const cb of stateListeners) {
|
||||
try { cb(snap) } catch {}
|
||||
try { cb(snap) } catch (e) { console.warn('[uiSdk] state listener failed:', e) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +73,8 @@ function flushFrame() {
|
||||
const writes = writeQueue
|
||||
readQueue = []
|
||||
writeQueue = []
|
||||
for (const r of reads) { try { r() } catch {} }
|
||||
for (const w of writes) { try { w() } catch {} }
|
||||
for (const r of reads) { try { r() } catch (e) { console.warn('[uiSdk] scheduled read failed:', e) } }
|
||||
for (const w of writes) { try { w() } catch (e) { console.warn('[uiSdk] scheduled write failed:', e) } }
|
||||
}
|
||||
|
||||
function scheduleRAF() {
|
||||
@@ -69,31 +95,45 @@ export async function mountInteractiveThemeScript(
|
||||
const disposers = new Set<() => void>()
|
||||
const partSet = new Set<string>(UI_CONTRACT_PARTS)
|
||||
const slotSet = new Set<string>(UI_CONTRACT_SLOTS)
|
||||
const layerSet = new Set<string>(UI_CONTRACT_LAYERS)
|
||||
const eventSet = new Set<string>(UI_CONTRACT_SDK_EVENTS)
|
||||
|
||||
const addDisposer = (fn: () => void) => {
|
||||
if (disposed) return
|
||||
disposers.add(fn)
|
||||
}
|
||||
|
||||
const mountInto = (host: HTMLElement | null, node: HTMLElement) => {
|
||||
if (disposed || !host) return () => {}
|
||||
host.appendChild(node)
|
||||
const off = () => {
|
||||
node.remove()
|
||||
disposers.delete(off)
|
||||
}
|
||||
addDisposer(off)
|
||||
return off
|
||||
}
|
||||
|
||||
const disposeAll = () => {
|
||||
if (disposed) return
|
||||
disposed = true
|
||||
const list = Array.from(disposers).reverse()
|
||||
disposers.clear()
|
||||
for (const fn of list) {
|
||||
try { fn() } catch {}
|
||||
try { fn() } catch (e) { console.warn('[uiSdk] disposer failed:', e) }
|
||||
}
|
||||
}
|
||||
|
||||
const sdk: ReimsUISDK = {
|
||||
uiApi: UI_API_VERSION,
|
||||
features: UI_CONTRACT_FEATURES,
|
||||
onDispose: addDisposer,
|
||||
feature: (_name, setup) => {
|
||||
if (disposed) return
|
||||
const localDisposers: Array<() => void> = []
|
||||
const localDispose = () => {
|
||||
while (localDisposers.length > 0) {
|
||||
try { localDisposers.pop()?.() } catch {}
|
||||
try { localDisposers.pop()?.() } catch (e) { console.warn('[uiSdk] feature disposer failed:', e) }
|
||||
}
|
||||
}
|
||||
addDisposer(localDispose)
|
||||
@@ -122,13 +162,17 @@ export async function mountInteractiveThemeScript(
|
||||
if (disposed || !partSet.has(part)) return null
|
||||
return document.querySelector<HTMLElement>(`.${part}`)
|
||||
},
|
||||
queryParts: (part) => {
|
||||
if (disposed || !partSet.has(part)) return []
|
||||
return Array.from(document.querySelectorAll<HTMLElement>(`.${part}`))
|
||||
},
|
||||
observePart: (part, cb) => {
|
||||
if (disposed || !partSet.has(part)) return () => {}
|
||||
const target = document.querySelector<HTMLElement>(`.${part}`)
|
||||
if (!target) return () => {}
|
||||
const obs = new MutationObserver(() => {
|
||||
if (disposed) return
|
||||
try { cb() } catch {}
|
||||
try { cb() } catch (e) { console.warn('[uiSdk] part observer failed:', part, e) }
|
||||
})
|
||||
obs.observe(target, { attributes: true, childList: true, subtree: false })
|
||||
const off = () => {
|
||||
@@ -148,13 +192,31 @@ export async function mountInteractiveThemeScript(
|
||||
writeQueue.push(() => { if (!disposed) fn() })
|
||||
scheduleRAF()
|
||||
},
|
||||
mountSlot: (slot, node) => {
|
||||
if (disposed || !slotSet.has(slot)) return () => {}
|
||||
const host = document.querySelector<HTMLElement>(`[data-rg-slot="${CSS.escape(slot)}"]`)
|
||||
if (!host) return () => {}
|
||||
host.appendChild(node)
|
||||
mountSlot: (slot, node, key) => {
|
||||
if (!slotSet.has(slot)) return () => {}
|
||||
const sel = `[data-rg-slot="${CSS.escape(slot)}"]` + (key ? `[data-rg-key="${CSS.escape(key)}"]` : '')
|
||||
return mountInto(document.querySelector<HTMLElement>(sel), node)
|
||||
},
|
||||
slotKeys: (slot) => {
|
||||
if (disposed || !slotSet.has(slot)) return []
|
||||
return Array.from(document.querySelectorAll<HTMLElement>(`[data-rg-slot="${CSS.escape(slot)}"][data-rg-key]`))
|
||||
.map((el) => el.dataset.rgKey ?? '')
|
||||
.filter(Boolean)
|
||||
},
|
||||
mountLayer: (layer, node) => {
|
||||
if (!layerSet.has(layer)) return () => {}
|
||||
return mountInto(document.querySelector<HTMLElement>(`[data-rg-layer="${CSS.escape(layer)}"]`), node)
|
||||
},
|
||||
on: (event, cb) => {
|
||||
if (disposed || !eventSet.has(event)) return () => {}
|
||||
let set = eventListeners.get(event)
|
||||
if (!set) {
|
||||
set = new Set()
|
||||
eventListeners.set(event, set)
|
||||
}
|
||||
set.add(cb)
|
||||
const off = () => {
|
||||
node.remove()
|
||||
eventListeners.get(event)?.delete(cb)
|
||||
disposers.delete(off)
|
||||
}
|
||||
addDisposer(off)
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
export interface VMRefLike {
|
||||
name: string
|
||||
driver_id?: string
|
||||
}
|
||||
|
||||
/** Matches driver.VMRef.Key while tolerating pre-VMRef test/host snapshots. */
|
||||
export function vmRefKey(vm: VMRefLike): string {
|
||||
return vm.driver_id ? `${vm.driver_id}:${vm.name}` : vm.name
|
||||
}
|
||||
+64
-35
@@ -2,13 +2,8 @@ import { useEffect, useState } from 'react'
|
||||
import { VMStats } from '../types'
|
||||
import { api } from '../wails'
|
||||
|
||||
// Shared VM stats poller (stats_flow.go). Components that show stats
|
||||
// subscribe with useVMStats, so a tick re-renders only them, not the whole
|
||||
// App. One timer per VM however many subscribe; it pauses while the window
|
||||
// is hidden and samples once on return.
|
||||
|
||||
// Shared VM stats poller, keyed by VMRef so same-name VMs never share samples.
|
||||
const RUNNING_MS = 3000
|
||||
// A stopped VM only changes disk usage, so it is sampled rarely.
|
||||
const STOPPED_MS = 30000
|
||||
|
||||
interface Entry {
|
||||
@@ -16,70 +11,104 @@ interface Entry {
|
||||
running: boolean
|
||||
last: VMStats | null
|
||||
timer?: number
|
||||
seq: number
|
||||
appliedSeq: number
|
||||
}
|
||||
|
||||
const entries = new Map<string, Entry>()
|
||||
const statsKey = (driverID: string, name: string) => `${driverID}:${name}`
|
||||
|
||||
function sample(name: string) {
|
||||
api.GetVMStats(name)
|
||||
function sample(key: string, driverID: string, name: string, entryRef: Entry) {
|
||||
if (entries.get(key) !== entryRef) return
|
||||
const reqSeq = ++entryRef.seq
|
||||
api.GetVMStatsWithDriver(driverID, name)
|
||||
.then((s) => {
|
||||
const e = entries.get(name)
|
||||
if (!e) return
|
||||
e.last = s
|
||||
e.subs.forEach((f) => f(s))
|
||||
if (entries.get(key) !== entryRef || reqSeq <= entryRef.appliedSeq) return
|
||||
entryRef.appliedSeq = reqSeq
|
||||
entryRef.last = s
|
||||
entryRef.subs.forEach((f) => f(s))
|
||||
})
|
||||
.catch(() => {})
|
||||
.catch((e) => console.warn('[vmStats] GetVMStatsWithDriver failed:', key, e))
|
||||
}
|
||||
|
||||
function schedule(name: string, e: Entry) {
|
||||
function schedule(key: string, driverID: string, name: string, e: Entry) {
|
||||
if (e.timer) window.clearInterval(e.timer)
|
||||
e.timer = undefined
|
||||
if (document.hidden || e.subs.size === 0) return
|
||||
e.timer = window.setInterval(() => sample(name), e.running ? RUNNING_MS : STOPPED_MS)
|
||||
e.timer = window.setInterval(() => sample(key, driverID, name, e), e.running ? RUNNING_MS : STOPPED_MS)
|
||||
}
|
||||
|
||||
if (typeof document !== 'undefined') {
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
entries.forEach((e, name) => {
|
||||
if (!document.hidden && e.subs.size > 0) sample(name)
|
||||
schedule(name, e)
|
||||
entries.forEach((e, key) => {
|
||||
const split = key.indexOf(':')
|
||||
const driverID = key.slice(0, split)
|
||||
const name = key.slice(split + 1)
|
||||
if (!document.hidden && e.subs.size > 0) sample(key, driverID, name, e)
|
||||
schedule(key, driverID, name, e)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/** Latest stats seen for a VM, without subscribing (e.g. when a dialog opens). */
|
||||
export function latestVMStats(name: string | undefined | null): VMStats | null {
|
||||
return name ? entries.get(name)?.last ?? null : null
|
||||
export function latestVMStatsWithDriver(driverID: string, name: string | undefined | null): VMStats | null {
|
||||
return name ? entries.get(statsKey(driverID, name))?.last ?? null : null
|
||||
}
|
||||
export function latestVMStats(name: string | undefined | null): VMStats | null { return latestVMStatsWithDriver('', name) }
|
||||
|
||||
/** Immediately patch cached stats (if any) and re-sample a VM's stats. */
|
||||
export function refreshVMStatsWithDriver(driverID: string, name: string, patch?: Partial<VMStats>) {
|
||||
const key = statsKey(driverID, name)
|
||||
const e = entries.get(key)
|
||||
if (!e) return
|
||||
e.appliedSeq = ++e.seq
|
||||
if (patch && e.last) {
|
||||
e.last = { ...e.last, ...patch }
|
||||
e.subs.forEach((f) => f(e.last!))
|
||||
}
|
||||
sample(key, driverID, name, e)
|
||||
}
|
||||
export function refreshVMStats(name: string, patch?: Partial<VMStats>) { refreshVMStatsWithDriver('', name, patch) }
|
||||
|
||||
/** Re-sample all currently subscribed VMs (e.g. after a tray-triggered state change). */
|
||||
export function refreshSubscribedVMStats() {
|
||||
entries.forEach((e, key) => {
|
||||
if (e.subs.size === 0) return
|
||||
const split = key.indexOf(':')
|
||||
e.appliedSeq = ++e.seq
|
||||
sample(key, key.slice(0, split), key.slice(split + 1), e)
|
||||
})
|
||||
}
|
||||
|
||||
/** Live stats for one VM; `running` picks the sampling rate. Null name: none. */
|
||||
export function useVMStats(name: string | null, running: boolean): VMStats | null {
|
||||
const [stats, setStats] = useState<VMStats | null>(() => latestVMStats(name))
|
||||
|
||||
export function useVMStats(driverID: string, name: string | null, running: boolean): VMStats | null {
|
||||
const [stats, setStats] = useState<VMStats | null>(() => latestVMStatsWithDriver(driverID, name))
|
||||
useEffect(() => {
|
||||
if (!name) { setStats(null); return }
|
||||
let e = entries.get(name)
|
||||
const key = statsKey(driverID, name)
|
||||
let e = entries.get(key)
|
||||
if (!e) {
|
||||
e = { subs: new Set(), running, last: null }
|
||||
entries.set(name, e)
|
||||
e = { subs: new Set(), running, last: null, seq: 0, appliedSeq: 0 }
|
||||
entries.set(key, e)
|
||||
}
|
||||
setStats(e.last)
|
||||
const sub = (s: VMStats) => setStats(s)
|
||||
e.subs.add(sub)
|
||||
// A state change (start/stop) samples at once and re-paces the timer.
|
||||
e.running = running
|
||||
sample(name)
|
||||
schedule(name, e)
|
||||
if (e.running !== running) {
|
||||
e.running = running
|
||||
e.appliedSeq = ++e.seq
|
||||
}
|
||||
sample(key, driverID, name, e)
|
||||
schedule(key, driverID, name, e)
|
||||
return () => {
|
||||
const cur = entries.get(name)
|
||||
if (!cur) return
|
||||
const cur = entries.get(key)
|
||||
if (!cur || cur !== e) return
|
||||
cur.subs.delete(sub)
|
||||
if (cur.subs.size === 0) {
|
||||
if (cur.timer) window.clearInterval(cur.timer)
|
||||
entries.delete(name)
|
||||
entries.delete(key)
|
||||
}
|
||||
}
|
||||
}, [name, running])
|
||||
|
||||
}, [driverID, name, running])
|
||||
return stats
|
||||
}
|
||||
@@ -0,0 +1,423 @@
|
||||
import { AlertTriangle, Check, ChevronDown, Clock, Download, ExternalLink, Info, LoaderCircle, Pause, Plus, Trash, X } from 'lucide-react'
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import '../i18n/domains/wizard.gen'
|
||||
import { WordmarkLoader } from '../components/WordmarkLoader'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { macOSMajor } from './macosRelease'
|
||||
import {
|
||||
ActiveInstallerMatch,
|
||||
findActiveCachedTask,
|
||||
findActiveOfflineTask,
|
||||
groupUnmatchedInstallerTasks,
|
||||
isActiveInstallerTask,
|
||||
isInstallerTask,
|
||||
taskDetail,
|
||||
taskInstallerKey,
|
||||
taskInstallerKind,
|
||||
taskInstallerPhase,
|
||||
taskInstallerVersion,
|
||||
taskStopAction,
|
||||
} from '../lib/tasks'
|
||||
import { CachedInstaller, HostReport, Locale, Release, Task } from '../types'
|
||||
import { Button, IconButton } from '../ui/controls'
|
||||
import { api } from '../wails'
|
||||
import { VersionArt } from './VersionArt'
|
||||
|
||||
const APPLE_SLA_URL = 'https://www.apple.com/legal/sla'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
host: HostReport
|
||||
tasks: Task[]
|
||||
refreshSignal?: number
|
||||
onBusyChange?: (busy: boolean) => void
|
||||
onCreateWithInstaller: (item: CachedInstaller) => void
|
||||
onError: (title: string, e: unknown) => void
|
||||
onToast: (title: string) => void
|
||||
}
|
||||
|
||||
const gb = (b: number) => (b >= 1e9 ? `${(b / 1e9).toFixed(1)} GB` : `${Math.max(1, Math.ceil(b / 1e6))} MB`)
|
||||
|
||||
// reims-util creates the whole image as soon as a download starts (19.7 GB for an
|
||||
// 18.4 GB release, measured 2026-11-28): reserve 10% over the release size.
|
||||
const needBytes = (r: Release) => r.size * 1.1
|
||||
|
||||
type ReleaseGroup = { key: string; title: string; major: number | null; releases: Release[] }
|
||||
|
||||
type DownloadedRow = {
|
||||
key: string
|
||||
title: string
|
||||
version: string
|
||||
kind: CachedInstaller['kind']
|
||||
cached?: CachedInstaller
|
||||
active: ActiveInstallerMatch | null
|
||||
}
|
||||
|
||||
/** Newest point release first, one card per macOS major version. */
|
||||
function groupReleases(releases: Release[]): ReleaseGroup[] {
|
||||
const groups = new Map<string, ReleaseGroup>()
|
||||
for (const release of releases) {
|
||||
const major = macOSMajor(release.version, release.title)
|
||||
const key = major === null ? release.title : String(major)
|
||||
const group = groups.get(key) ?? { key, title: release.title, major, releases: [] }
|
||||
group.releases.push(release)
|
||||
groups.set(key, group)
|
||||
}
|
||||
return [...groups.values()]
|
||||
.map((group) => ({ ...group, releases: group.releases.sort((a, b) => b.version.localeCompare(a.version, undefined, { numeric: true })) }))
|
||||
.sort((a, b) => (b.major ?? -1) - (a.major ?? -1) || a.title.localeCompare(b.title))
|
||||
}
|
||||
|
||||
function formatOnlineTitle(version: string): string {
|
||||
const v = version.trim()
|
||||
if (!v || v.toLowerCase() === 'latest') return 'macOS'
|
||||
const words = v.split(/[-_\s]+/).filter(Boolean).map((w) => w[0].toUpperCase() + w.slice(1))
|
||||
return `macOS ${words.join(' ')}`
|
||||
}
|
||||
|
||||
/** macOS image source view provided by the built-in `builtin.images.macos` plugin. */
|
||||
export const InstallersPage: React.FC<Props> = ({
|
||||
locale, host, tasks, refreshSignal = 0, onBusyChange, onCreateWithInstaller, onError, onToast,
|
||||
}) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const [cached, setCached] = useState<CachedInstaller[] | null>(null)
|
||||
const [releases, setReleases] = useState<Release[] | null>(null)
|
||||
const [releasesErr, setReleasesErr] = useState('')
|
||||
const [confirmDelete, setConfirmDelete] = useState('')
|
||||
const lastRefreshRef = useRef(refreshSignal)
|
||||
const onBusyChangeRef = useRef(onBusyChange)
|
||||
onBusyChangeRef.current = onBusyChange
|
||||
|
||||
const installerTasks = tasks.filter(isInstallerTask)
|
||||
const activeInstallerTasks = installerTasks.filter(isActiveInstallerTask)
|
||||
const installerTasksSig = installerTasks
|
||||
.map((x) => `${x.id}:${x.status}:${x.installer_phase ?? ''}`)
|
||||
.sort()
|
||||
.join('|')
|
||||
|
||||
const loadCached = () => api.ListInstallers().then((l) => setCached(l ?? [])).catch((e) => onError(tr('failGeneric'), e))
|
||||
const loadReleases = () => {
|
||||
setReleases(null)
|
||||
setReleasesErr('')
|
||||
api.ListOfflineReleases()
|
||||
.then((l) => setReleases(l ?? []))
|
||||
.catch((e) => setReleasesErr(String(e).replace(/^Error:\s*/, '')))
|
||||
}
|
||||
useEffect(() => { loadReleases() }, [])
|
||||
useEffect(() => {
|
||||
if (refreshSignal !== lastRefreshRef.current) {
|
||||
lastRefreshRef.current = refreshSignal
|
||||
loadCached()
|
||||
loadReleases()
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [refreshSignal])
|
||||
useEffect(() => {
|
||||
onBusyChangeRef.current?.(releases === null && !releasesErr)
|
||||
}, [releases, releasesErr])
|
||||
useEffect(() => () => { onBusyChangeRef.current?.(false) }, [])
|
||||
// Refresh the downloaded list whenever an installer download starts, shifts phase, or ends.
|
||||
useEffect(() => {
|
||||
setConfirmDelete('')
|
||||
loadCached()
|
||||
}, [installerTasksSig])
|
||||
|
||||
const openSLA = () => {
|
||||
api.OpenURL(APPLE_SLA_URL).catch((e) => onError(tr('failGeneric'), e))
|
||||
}
|
||||
|
||||
const downloaded = (version: string) => (cached ?? []).find((c) => c.kind === 'offline' && !c.partial && c.version === version)
|
||||
const partial = (version: string) => (cached ?? []).some((c) => c.kind === 'offline' && c.partial && c.version === version)
|
||||
const activeForRelease = (version: string) => findActiveOfflineTask(activeInstallerTasks, version)
|
||||
|
||||
const download = (version: string) => {
|
||||
api.DownloadInstaller(version).catch((e) => onError(tr('failDownload'), e))
|
||||
}
|
||||
|
||||
const cancelTask = (task: Task) => {
|
||||
api.CancelTask(task.id).catch((e) => onError(tr('failGeneric'), e))
|
||||
}
|
||||
|
||||
const remove = async (name: string) => {
|
||||
if (confirmDelete !== name) { setConfirmDelete(name); return }
|
||||
setConfirmDelete('')
|
||||
try {
|
||||
await api.DeleteInstaller(name)
|
||||
onToast(tr('toastDeleted', { name }))
|
||||
loadCached()
|
||||
} catch (e) {
|
||||
onError(tr('failDelete'), e)
|
||||
}
|
||||
}
|
||||
|
||||
const progress = (task: Task) => {
|
||||
if (taskInstallerPhase(task) === 'queued') {
|
||||
return (
|
||||
<span className="task-inline row-sub">
|
||||
<Clock size={14} aria-hidden="true" />
|
||||
<span>{tr('installersQueuedDesc')}</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<span className="task-inline row-sub">
|
||||
<LoaderCircle size={14} className="spin" aria-hidden="true" />
|
||||
{task.percent >= 0 && (
|
||||
<span className="progress rg-p-progress" aria-hidden="true">
|
||||
<span className="progress-fill" style={{ transform: `scaleX(${Math.max(0, Math.min(1, task.percent / 100))})` }} />
|
||||
</span>
|
||||
)}
|
||||
<span>{task.percent >= 0 ? `${Math.floor(task.percent)}%` : ''} {taskDetail(task)}</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
const spaceShort = (r: Release) => !downloaded(r.version) && !activeForRelease(r.version) && host.free_disk_gb > 0 && host.free_disk_gb * 1e9 < needBytes(r)
|
||||
|
||||
const releaseAction = (r: Release) => {
|
||||
const active = activeForRelease(r.version)
|
||||
if (active) {
|
||||
const task = active.primary
|
||||
const queued = taskInstallerPhase(task) === 'queued'
|
||||
if (queued) {
|
||||
return <span className="badge rg-p-badge" role="status">{tr('installersQueued')}</span>
|
||||
}
|
||||
return (
|
||||
<span className="badge rg-p-badge badge-accent installer-active-status" role="status">
|
||||
<LoaderCircle size={12} className="spin" aria-hidden="true" />
|
||||
<span>
|
||||
{task.percent >= 0
|
||||
? tr('installersDownloadingPct', { p: Math.floor(task.percent) })
|
||||
: tr('installersDownloading')}
|
||||
</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
const item = downloaded(r.version)
|
||||
if (item) {
|
||||
return (
|
||||
<Button variant="primary" icon={<Plus size={14} />} onClick={() => onCreateWithInstaller(item)}>
|
||||
{tr('installersCreateVM')}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<Button icon={<Download size={14} />} disabled={spaceShort(r)} onClick={() => download(r.version)}>
|
||||
{partial(r.version) ? tr('installersResume') : tr('installersDownload')}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
const releaseMeta = (r: Release) => (
|
||||
<div className="row-sub">
|
||||
{r.posted} · {gb(r.size)}
|
||||
{spaceShort(r) && <span className="warn-text"> · {tr('installersNoSpace', { need: Math.ceil(needBytes(r) / 1e9), free: host.free_disk_gb.toFixed(0) })}</span>}
|
||||
</div>
|
||||
)
|
||||
|
||||
const matchedTaskIDs = new Set<string>()
|
||||
const cachedRows: DownloadedRow[] = (cached ?? []).map((c) => {
|
||||
const active = findActiveCachedTask(activeInstallerTasks, c)
|
||||
if (active) {
|
||||
for (const id of active.matchedIDs) matchedTaskIDs.add(id)
|
||||
}
|
||||
return {
|
||||
key: c.name,
|
||||
title: c.title ?? c.name,
|
||||
version: c.version ?? '',
|
||||
kind: c.kind,
|
||||
cached: c,
|
||||
active,
|
||||
}
|
||||
})
|
||||
|
||||
const virtualRows: DownloadedRow[] = groupUnmatchedInstallerTasks(activeInstallerTasks, matchedTaskIDs).map((active) => {
|
||||
const task = active.primary
|
||||
const kind = taskInstallerKind(task) || 'offline'
|
||||
const version = taskInstallerVersion(task)
|
||||
if (kind === 'offline') {
|
||||
const rel = (releases ?? []).find((r) => r.version.toLowerCase() === version.toLowerCase())
|
||||
return {
|
||||
key: `active-${taskInstallerKey(task) || task.id}`,
|
||||
title: rel?.title ?? 'macOS',
|
||||
version: rel?.version ?? version,
|
||||
kind: 'offline',
|
||||
active,
|
||||
}
|
||||
}
|
||||
return {
|
||||
key: `active-${taskInstallerKey(task) || task.id}`,
|
||||
title: formatOnlineTitle(version),
|
||||
version: '',
|
||||
kind: 'online',
|
||||
active,
|
||||
}
|
||||
})
|
||||
|
||||
const rowPriority = (row: DownloadedRow) => {
|
||||
if (!row.active) return 2
|
||||
return taskInstallerPhase(row.active.primary) === 'queued' ? 1 : 0
|
||||
}
|
||||
const downloadedRows = [...virtualRows, ...cachedRows].sort((a, b) => rowPriority(a) - rowPriority(b))
|
||||
|
||||
const groups = groupReleases(releases ?? [])
|
||||
const showDownloaded = downloadedRows.length > 0
|
||||
|
||||
return (
|
||||
<div className="macos-images-view">
|
||||
<div className="notice notice-info macos-sla-notice" role="note">
|
||||
<span className="notice-main">
|
||||
<Info size={15} className="notice-icon" aria-hidden="true" />
|
||||
<span>{tr('macosSlaNotice')}</span>
|
||||
</span>
|
||||
<Button icon={<ExternalLink size={13} aria-hidden="true" />} onClick={openSLA}>
|
||||
{tr('macosSlaButton')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{showDownloaded && (
|
||||
<section className="section">
|
||||
<div className="section-title">
|
||||
<span>{tr('installersDownloaded')}</span>
|
||||
<span className="section-count">{downloadedRows.length}</span>
|
||||
</div>
|
||||
<div className="list installer-list">
|
||||
{downloadedRows.map((row) => {
|
||||
const c = row.cached
|
||||
const active = row.active
|
||||
const task = active?.primary
|
||||
const queued = !!task && taskInstallerPhase(task) === 'queued'
|
||||
const vmName = task
|
||||
? (task.vm || (task.kind === 'vm-create' || task.kind === 'recovery-download' ? task.subject : ''))
|
||||
: ''
|
||||
const waitingVMs = active?.waitingVMs ?? []
|
||||
const stop = task ? taskStopAction(locale, task) : null
|
||||
return (
|
||||
<div className="row installer-row" key={row.key} title={c?.name ?? row.title}>
|
||||
<span className="installer-art">
|
||||
<VersionArt shape="tile" major={macOSMajor(row.version, row.title)} name={row.title} />
|
||||
</span>
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
<span>{row.title}{row.version ? ` ${row.version}` : ''}</span>
|
||||
{!task && c?.kind === 'offline' && !c.partial && <span className="badge rg-p-badge badge-ok">{tr('installersKindOffline')}</span>}
|
||||
{(!task && c?.kind === 'online' && !c.partial) || (task && row.kind === 'online')
|
||||
? <span className="badge rg-p-badge">{tr('installersKindOnline')}</span>
|
||||
: null}
|
||||
{c?.partial && !task && <span className="badge rg-p-badge badge-warn">{tr('installersPartial')}</span>}
|
||||
{task && vmName && (
|
||||
<span className={`badge rg-p-badge ${queued ? '' : 'badge-accent'}`}>
|
||||
{tr(queued ? 'installersQueuedForVM' : 'installersDownloadingForVM', { vm: vmName })}
|
||||
</span>
|
||||
)}
|
||||
{task && !vmName && waitingVMs.length > 0 && (
|
||||
<span className="badge rg-p-badge badge-accent">
|
||||
{tr('installersWaitingVM', { vm: waitingVMs.join(', ') })}
|
||||
</span>
|
||||
)}
|
||||
{task && !vmName && queued && (
|
||||
<span className="badge rg-p-badge">{tr('installersQueued')}</span>
|
||||
)}
|
||||
</div>
|
||||
{task ? progress(task) : c ? (
|
||||
<div className="row-sub">{gb(c.bytes)}{c.build ? ` · ${c.build}` : ''}</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="row-right">
|
||||
{task && stop ? (
|
||||
<IconButton
|
||||
label={stop.label}
|
||||
icon={stop.kind === 'cancel' ? <X size={16} /> : <Pause size={16} />}
|
||||
onClick={() => cancelTask(task)}
|
||||
/>
|
||||
) : c ? (
|
||||
<>
|
||||
{!c.partial && (c.kind === 'offline' || c.kind === 'online') && (
|
||||
<Button variant={c.kind === 'offline' ? 'primary' : 'secondary'} icon={<Plus size={14} />} onClick={() => onCreateWithInstaller(c)}>
|
||||
{tr('installersCreateVM')}
|
||||
</Button>
|
||||
)}
|
||||
{c.partial && c.kind === 'offline' && c.version && (
|
||||
<Button icon={<Download size={14} />} onClick={() => download(c.version!)}>{tr('installersResume')}</Button>
|
||||
)}
|
||||
{confirmDelete === c.name ? (
|
||||
<Button variant="danger" onClick={() => remove(c.name)}>{tr('installersDeleteConfirm')}</Button>
|
||||
) : (
|
||||
<IconButton label={tr('installersDelete')} icon={<Trash size={15} />} onClick={() => remove(c.name)} />
|
||||
)}
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
<section className="section">
|
||||
<div className="section-title">{tr('installersAvailable')}</div>
|
||||
{releasesErr ? (
|
||||
<div className="notice notice-error" role="alert">
|
||||
<span className="notice-main">
|
||||
<AlertTriangle size={15} className="notice-icon" aria-hidden="true" />
|
||||
<span>{tr('offlineListFailedDetail', { err: releasesErr })}</span>
|
||||
</span>
|
||||
<Button onClick={loadReleases}>{tr('installersRetry')}</Button>
|
||||
</div>
|
||||
) : releases === null ? (
|
||||
<WordmarkLoader className="installers-loader" label={tr('offlineLoading')} />
|
||||
) : (
|
||||
<div className="release-list">
|
||||
{groups.map((group, groupIndex) => {
|
||||
const [latest, ...older] = group.releases
|
||||
return (
|
||||
<article className="release-card" key={group.key}>
|
||||
<div className="release-latest">
|
||||
<span className="release-art">
|
||||
<VersionArt shape="tile" major={group.major} name={group.title} />
|
||||
</span>
|
||||
<div className="release-copy">
|
||||
<div className="row-title release-title">
|
||||
<span>{latest.title}</span>
|
||||
<strong>{latest.version}</strong>
|
||||
{groupIndex === 0 && <span className="badge rg-p-badge badge-accent">{tr('installersLatest')}</span>}
|
||||
{downloaded(latest.version) && <Check size={15} className="ok-text" aria-label={tr('offlineCached')} />}
|
||||
</div>
|
||||
{releaseMeta(latest)}
|
||||
</div>
|
||||
<div className="row-right">{releaseAction(latest)}</div>
|
||||
</div>
|
||||
{older.length > 0 && (
|
||||
<details className="release-history">
|
||||
<summary>
|
||||
<span>{tr('installersOlder', { count: older.length })}</span>
|
||||
<ChevronDown size={14} aria-hidden="true" />
|
||||
</summary>
|
||||
<div className="release-history-list">
|
||||
{older.map((r) => (
|
||||
<div className="release-history-row" key={r.product}>
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
<span>{r.version}</span>
|
||||
<span className="muted">{r.build}</span>
|
||||
{downloaded(r.version) && <span className="badge rg-p-badge badge-ok">{tr('offlineCached')}</span>}
|
||||
</div>
|
||||
{releaseMeta(r)}
|
||||
</div>
|
||||
<div className="row-right">{releaseAction(r)}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</details>
|
||||
)}
|
||||
</article>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
+3
-3
@@ -14,7 +14,7 @@ export const OnlineRecoveryDialog: React.FC<Props> = ({ locale, name, onCancel,
|
||||
<Alert.Root open onOpenChange={(open) => { if (!open) onCancel() }}>
|
||||
<Alert.Portal>
|
||||
<Alert.Overlay className="overlay" />
|
||||
<Alert.Content className="dialog sm">
|
||||
<Alert.Content className="dialog rg-p-dialog sm" data-tone="neutral">
|
||||
<div className="dialog-body">
|
||||
<Alert.Title className="dialog-title">{t(locale, 'onlineRecoveryTitle')}</Alert.Title>
|
||||
<Alert.Description className="dialog-desc">
|
||||
@@ -23,10 +23,10 @@ export const OnlineRecoveryDialog: React.FC<Props> = ({ locale, name, onCancel,
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
<Alert.Cancel asChild>
|
||||
<button type="button" className="btn">{t(locale, 'cancel')}</button>
|
||||
<button type="button" className="btn rg-p-button">{t(locale, 'cancel')}</button>
|
||||
</Alert.Cancel>
|
||||
<Alert.Action asChild>
|
||||
<button type="button" className="btn btn-primary" onClick={onConfirm}>
|
||||
<button type="button" className="btn rg-p-button btn-primary" onClick={onConfirm}>
|
||||
{t(locale, 'onlineRecoveryConfirm')}
|
||||
</button>
|
||||
</Alert.Action>
|
||||
File renamed without changes.
File renamed without changes.
+491
-128
File diff suppressed because it is too large.
Load diff
@@ -8,11 +8,12 @@
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
|
||||
/* Map installed PingFang SC / HarmonyOS Sans SC / MiSans / Noto Sans SC / Source Han Sans CN
|
||||
explicitly across weights. On Windows DirectWrite, PingFang SC Regular renders overly thin
|
||||
compared to macOS Retina CoreText, so body weights (400–550) map to Medium for balanced ink. */
|
||||
/* Scoped Simplified Chinese weight-mapping face ("ReimsCJK-SC").
|
||||
IMPORTANT: Never attach this unconditionally to all languages — doing so
|
||||
hijacks Han Unification `locl` glyphs and turns Traditional Chinese / Japanese
|
||||
Kanji into Mainland Simplified forms. Only `:lang(zh-CN|zh-SG|zh-Hans)` activates it. */
|
||||
@font-face {
|
||||
font-family: "ReimsCJK";
|
||||
font-family: "ReimsCJK-SC";
|
||||
font-style: normal;
|
||||
font-weight: 400 550;
|
||||
src:
|
||||
@@ -26,7 +27,7 @@
|
||||
unicode-range: U+2E80-9FFF, U+3000-303F, U+FF00-FFEF, U+F900-FAFF;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "ReimsCJK";
|
||||
font-family: "ReimsCJK-SC";
|
||||
font-style: normal;
|
||||
font-weight: 560 900;
|
||||
src:
|
||||
@@ -44,9 +45,13 @@
|
||||
:root {
|
||||
color-scheme: light;
|
||||
|
||||
/* Typography */
|
||||
--font-sans: "ReimsSans", "ReimsCJK", "PingFang SC Medium", "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Noto Sans SC", "Source Han Sans CN", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif;
|
||||
/* Typography — regional CJK family injected via --font-cjk per :lang() */
|
||||
--font-locale-pack: ;
|
||||
--font-cjk: "PingFang SC", "Microsoft YaHei UI", "Noto Sans CJK SC", sans-serif;
|
||||
--font-sans: "ReimsSans", var(--font-locale-pack) -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", var(--font-cjk), system-ui, sans-serif;
|
||||
--font-mono: "SF Mono", "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
|
||||
--body-lh: 1.48;
|
||||
--heading-tracking: -0.015em;
|
||||
--fs-11: 11px;
|
||||
--fs-12: 12px;
|
||||
--fs-13: 13px;
|
||||
@@ -85,17 +90,19 @@
|
||||
--surface-statusbar: #eef3fa;
|
||||
--surface-1: #f5f6f8;
|
||||
--surface-card-elevated: #ffffff;
|
||||
--surface-2: rgba(255, 255, 255, 0.94);
|
||||
--surface-2: rgba(255, 255, 255, 0.98);
|
||||
--surface-input: #ffffff;
|
||||
--surface-hover: rgba(15, 23, 42, 0.048);
|
||||
--surface-active: rgba(15, 23, 42, 0.085);
|
||||
--border: rgba(15, 23, 42, 0.08);
|
||||
--border-strong: rgba(15, 23, 42, 0.14);
|
||||
--highlight-top: inset 0 1px 0 rgba(255, 255, 255, 0.85);
|
||||
--scrim: rgba(15, 23, 42, 0.28);
|
||||
--scrim: rgba(15, 23, 42, 0.34);
|
||||
--shadow-btn: 0 1px 2px rgba(15, 23, 42, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.7);
|
||||
--shadow-card: 0 1px 2px rgba(15, 23, 42, 0.025);
|
||||
--shadow-overlay: 0 22px 58px rgba(15, 23, 42, 0.18), 0 4px 14px rgba(15, 23, 42, 0.06), 0 0 0 1px rgba(15, 23, 42, 0.06);
|
||||
--shadow-overlay: 0 16px 36px rgba(15, 23, 42, 0.16), 0 3px 10px rgba(15, 23, 42, 0.06), 0 0 0 1px rgba(15, 23, 42, 0.06);
|
||||
/* Retained for UI Contract v1 (uiApi 1.0.0) theme compatibility; unused by default
|
||||
base styles while main.go runs WebView2 in software compositing mode. */
|
||||
--blur-chrome: blur(20px) saturate(180%);
|
||||
--blur-overlay: blur(18px) saturate(165%);
|
||||
|
||||
@@ -162,17 +169,17 @@
|
||||
--surface-statusbar: #18191e;
|
||||
--surface-1: rgba(255, 255, 255, 0.048);
|
||||
--surface-card-elevated: rgba(255, 255, 255, 0.075);
|
||||
--surface-2: rgba(42, 43, 50, 0.94);
|
||||
--surface-2: rgba(42, 43, 50, 0.98);
|
||||
--surface-input: rgba(0, 0, 0, 0.28);
|
||||
--surface-hover: rgba(255, 255, 255, 0.075);
|
||||
--surface-active: rgba(255, 255, 255, 0.12);
|
||||
--border: rgba(255, 255, 255, 0.085);
|
||||
--border-strong: rgba(255, 255, 255, 0.16);
|
||||
--highlight-top: inset 0 1px 0 rgba(255, 255, 255, 0.08);
|
||||
--scrim: rgba(0, 0, 0, 0.56);
|
||||
--scrim: rgba(0, 0, 0, 0.58);
|
||||
--shadow-btn: 0 1px 2px rgba(0, 0, 0, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
||||
--shadow-card: 0 1px 3px rgba(0, 0, 0, 0.18);
|
||||
--shadow-overlay: 0 26px 68px rgba(0, 0, 0, 0.58), 0 0 0 1px rgba(255, 255, 255, 0.09);
|
||||
--shadow-overlay: 0 18px 40px rgba(0, 0, 0, 0.52), 0 0 0 1px rgba(255, 255, 255, 0.09);
|
||||
|
||||
--text: #f5f5f7;
|
||||
--text-2: #c2c2ca;
|
||||
@@ -245,4 +252,36 @@
|
||||
--text-3: #a6a6b0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Regional script & OpenType `locl` typography stacks:
|
||||
- Simplified Chinese: DirectWrite Medium ink compensation ("ReimsCJK-SC")
|
||||
- Traditional Chinese (TW/HK/MO): Orthodox Traditional glyph stack, 400 regular weight
|
||||
and taller line-height (1.56) so dense 20+ stroke characters never blob at 11–13px
|
||||
- Japanese: Kana/Kanji stack, 400 regular weight, strict kinsoku line-breaking
|
||||
- Korean: Hangul stack, 400 regular weight, `word-break: keep-all` syllable-word integrity */
|
||||
:root:lang(zh-CN), :root:lang(zh-SG), :root:lang(zh-Hans) {
|
||||
--font-cjk: "ReimsCJK-SC", "PingFang SC Medium", "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Noto Sans SC", "Source Han Sans CN", "Microsoft YaHei UI", sans-serif;
|
||||
--heading-tracking: 0em;
|
||||
}
|
||||
|
||||
:root:lang(zh-TW), :root:lang(zh-HK), :root:lang(zh-MO), :root:lang(zh-Hant) {
|
||||
--font-cjk: "PingFang TC", "Noto Sans TC", "Source Han Sans TC", "Microsoft JhengHei UI", "Microsoft JhengHei", sans-serif;
|
||||
--fw-regular: 400;
|
||||
--body-lh: 1.56;
|
||||
--heading-tracking: 0em;
|
||||
}
|
||||
|
||||
:root:lang(ja) {
|
||||
--font-cjk: "Hiragino Sans", "Noto Sans JP", "BIZ UDPGothic", "Yu Gothic UI", "Meiryo UI", "Meiryo", sans-serif;
|
||||
--fw-regular: 400;
|
||||
--body-lh: 1.58;
|
||||
--heading-tracking: 0em;
|
||||
}
|
||||
|
||||
:root:lang(ko) {
|
||||
--font-cjk: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
|
||||
--fw-regular: 400;
|
||||
--body-lh: 1.54;
|
||||
--heading-tracking: 0em;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,17 @@
|
||||
// Single source of truth for UI Contract v1 (docs/plugin-architecture.md §5.1).
|
||||
// Renaming or removing any part, state attribute, or token here is a uiApi major bump.
|
||||
// Single source of truth for UI Contract v2 (docs/plugin-architecture.md §5.1, §6.3).
|
||||
// Renaming or removing any stable entry here is a uiApi major bump.
|
||||
//
|
||||
// Every entry is either stable or experimental. Stable entries must be emitted
|
||||
// by the host (scripts/check-ui-contract.mjs fails the build otherwise) and are
|
||||
// covered by the compatibility promise. Experimental entries are part of the
|
||||
// published shape so plugins can be written against it, but the host does not
|
||||
// render them yet: `plugin doctor` warns, and they carry no compatibility
|
||||
// promise until promoted. Promote an entry by moving it into the stable list
|
||||
// in the same change that renders it. The Go side mirrors slots, layout
|
||||
// options, icon names and view locations in internal/plugin/contract.go, and a
|
||||
// Go test keeps both in step.
|
||||
|
||||
export const UI_API_VERSION = '1.0.0' as const
|
||||
export const UI_API_VERSION = '2.0.0' as const
|
||||
|
||||
export const UI_CONTRACT_PARTS = [
|
||||
'rg-p-shell',
|
||||
@@ -20,38 +30,185 @@ export const UI_CONTRACT_PARTS = [
|
||||
'rg-p-logpanel',
|
||||
'rg-p-settings',
|
||||
'rg-p-empty',
|
||||
// Control-level parts.
|
||||
'rg-p-nav-group',
|
||||
'rg-p-nav-item',
|
||||
'rg-p-button',
|
||||
'rg-p-icon-button',
|
||||
'rg-p-card',
|
||||
'rg-p-badge',
|
||||
'rg-p-tabs',
|
||||
'rg-p-tab',
|
||||
'rg-p-menu',
|
||||
'rg-p-menu-item',
|
||||
'rg-p-dialog',
|
||||
'rg-p-toast',
|
||||
'rg-p-tooltip',
|
||||
'rg-p-input',
|
||||
'rg-p-switch',
|
||||
'rg-p-progress',
|
||||
'rg-p-vm-actions',
|
||||
'rg-p-plugin-view',
|
||||
] as const
|
||||
|
||||
export type UIContractPart = (typeof UI_CONTRACT_PARTS)[number]
|
||||
|
||||
export const UI_CONTRACT_PARTS_EXPERIMENTAL = [] as const
|
||||
|
||||
export const UI_CONTRACT_STATE_ATTRS = [
|
||||
'data-theme',
|
||||
'data-motion',
|
||||
'data-locale',
|
||||
'data-view',
|
||||
'data-vm-state',
|
||||
'data-busy',
|
||||
'data-has-error',
|
||||
'data-sidebar-collapsed',
|
||||
'data-safe-mode',
|
||||
// Set from the active theme layout options; absent with the built-in theme.
|
||||
'data-layout-sidebar',
|
||||
'data-layout-sidebar-mode',
|
||||
'data-layout-density',
|
||||
'data-layout-titlebar',
|
||||
] as const
|
||||
|
||||
export const UI_CONTRACT_STATE_ATTRS_EXPERIMENTAL = [] as const
|
||||
|
||||
// Per-item state attributes, written as `<part>:<attribute>`.
|
||||
export const UI_CONTRACT_ITEM_STATES = [
|
||||
'rg-p-nav-item:data-vm-state',
|
||||
'rg-p-nav-item:data-driver',
|
||||
'rg-p-nav-item:data-selected',
|
||||
'rg-p-nav-item:data-busy',
|
||||
'rg-p-vm-page:data-vm-state',
|
||||
'rg-p-vm-page:data-driver',
|
||||
'rg-p-button:data-variant',
|
||||
'rg-p-button:data-busy',
|
||||
'rg-p-icon-button:data-busy',
|
||||
'rg-p-dialog:data-tone',
|
||||
'rg-p-toast:data-tone',
|
||||
] as const
|
||||
|
||||
export const UI_CONTRACT_ITEM_STATES_EXPERIMENTAL = [] as const
|
||||
|
||||
// Slot anchors (`data-rg-slot`) that decorations and UI SDK mounts can target.
|
||||
// `nav.item.trailing` repeats once per VM entry, keyed by `data-rg-key`
|
||||
// (the VM reference). Which plugin contributions a slot accepts is declared
|
||||
// on the Go side.
|
||||
export const UI_CONTRACT_SLOTS = [
|
||||
'titlebar.center',
|
||||
'sidebar.header',
|
||||
'sidebar.footer',
|
||||
'statusbar.right',
|
||||
'nav.item.trailing',
|
||||
'vm.header.trailing',
|
||||
'vm.toolbar',
|
||||
'vm.card',
|
||||
'settings.plugin',
|
||||
'vm.preview.tl',
|
||||
'vm.preview.tr',
|
||||
'vm.preview.bl',
|
||||
'vm.preview.br',
|
||||
'statusbar.left',
|
||||
'statusbar.right',
|
||||
'empty.state',
|
||||
'create.source',
|
||||
'settings.plugin',
|
||||
] as const
|
||||
|
||||
export type UIContractSlot = (typeof UI_CONTRACT_SLOTS)[number]
|
||||
|
||||
export const UI_CONTRACT_SLOTS_EXPERIMENTAL = [] as const
|
||||
|
||||
// Full-window layers (`data-rg-layer`): never take pointer input or focus;
|
||||
// animations freeze under reduced motion. Decorations and UI SDK mounts can
|
||||
// target them like slots.
|
||||
export const UI_CONTRACT_LAYERS = [
|
||||
'layer.background',
|
||||
'layer.overlay',
|
||||
] as const
|
||||
|
||||
export type UIContractLayer = (typeof UI_CONTRACT_LAYERS)[number]
|
||||
|
||||
export const UI_CONTRACT_LAYERS_EXPERIMENTAL = [] as const
|
||||
|
||||
// Theme `layout` options, written as `<option>=<value>`; each becomes a
|
||||
// data-layout-* attribute on <html>. They move and size regions only;
|
||||
// operation entries always stay reachable.
|
||||
export const UI_CONTRACT_LAYOUT_OPTIONS = [
|
||||
'sidebarPosition=left',
|
||||
'sidebarPosition=right',
|
||||
'sidebarMode=full',
|
||||
'sidebarMode=rail',
|
||||
'sidebarMode=floating',
|
||||
'density=compact',
|
||||
'density=regular',
|
||||
'density=comfortable',
|
||||
'titlebar=standard',
|
||||
'titlebar=compact',
|
||||
] as const
|
||||
|
||||
export const UI_CONTRACT_LAYOUT_OPTIONS_EXPERIMENTAL = [] as const
|
||||
|
||||
// Icon names a theme can map to a packaged monochrome SVG via `icons`.
|
||||
// Every name is rendered through <HostIcon> somewhere in the host.
|
||||
export const UI_CONTRACT_ICONS = [
|
||||
'start',
|
||||
'stop',
|
||||
'force-stop',
|
||||
'restart',
|
||||
'suspend',
|
||||
'resume',
|
||||
'new-vm',
|
||||
'settings',
|
||||
'plugin',
|
||||
'folder',
|
||||
'logs',
|
||||
'screenshot',
|
||||
'fullscreen',
|
||||
'window',
|
||||
'snapshot',
|
||||
'clone',
|
||||
'delete',
|
||||
'info',
|
||||
'warning',
|
||||
'error',
|
||||
'vm.state.running',
|
||||
'vm.state.stopped',
|
||||
'vm.state.suspended',
|
||||
'vm.state.busy',
|
||||
'vm.state.error',
|
||||
] as const
|
||||
|
||||
export type UIContractIcon = (typeof UI_CONTRACT_ICONS)[number]
|
||||
|
||||
export const UI_CONTRACT_ICONS_EXPERIMENTAL = [] as const
|
||||
|
||||
// Where plugin `views` can appear (§5.6).
|
||||
export const UI_CONTRACT_VIEW_LOCATIONS = [] as const
|
||||
|
||||
export const UI_CONTRACT_VIEW_LOCATIONS_EXPERIMENTAL = [
|
||||
'sidebar',
|
||||
'vm.tab',
|
||||
'settings',
|
||||
'dialog',
|
||||
] as const
|
||||
|
||||
// UI SDK event stream for interactive themes (`sdk.on(event, cb)`).
|
||||
export const UI_CONTRACT_SDK_EVENTS = [
|
||||
'vm.stateChanged',
|
||||
'task.started',
|
||||
'task.progress',
|
||||
'task.finished',
|
||||
'toast.shown',
|
||||
'view.changed',
|
||||
] as const
|
||||
|
||||
export type UIContractSDKEvent = (typeof UI_CONTRACT_SDK_EVENTS)[number]
|
||||
|
||||
export const UI_CONTRACT_SDK_EVENTS_EXPERIMENTAL = [] as const
|
||||
|
||||
export const UI_CONTRACT_TOKENS = [
|
||||
'--font-sans', '--font-mono',
|
||||
'--font-sans', '--font-cjk', '--font-mono',
|
||||
'--body-lh', '--heading-tracking',
|
||||
'--fs-11', '--fs-12', '--fs-13', '--fs-14', '--fs-15', '--fs-16', '--fs-20', '--fs-24',
|
||||
'--fw-regular', '--fw-medium', '--fw-strong',
|
||||
'--sp-1', '--sp-2', '--sp-3', '--sp-4', '--sp-5', '--sp-6', '--sp-8',
|
||||
@@ -78,6 +235,34 @@ export const UI_CONTRACT = {
|
||||
uiApi: UI_API_VERSION,
|
||||
parts: [...UI_CONTRACT_PARTS],
|
||||
stateAttrs: [...UI_CONTRACT_STATE_ATTRS],
|
||||
itemStates: [...UI_CONTRACT_ITEM_STATES],
|
||||
slots: [...UI_CONTRACT_SLOTS],
|
||||
layers: [...UI_CONTRACT_LAYERS],
|
||||
layoutOptions: [...UI_CONTRACT_LAYOUT_OPTIONS],
|
||||
icons: [...UI_CONTRACT_ICONS],
|
||||
viewLocations: [...UI_CONTRACT_VIEW_LOCATIONS],
|
||||
sdkEvents: [...UI_CONTRACT_SDK_EVENTS],
|
||||
tokens: [...UI_CONTRACT_TOKENS],
|
||||
experimental: {
|
||||
parts: [...UI_CONTRACT_PARTS_EXPERIMENTAL],
|
||||
stateAttrs: [...UI_CONTRACT_STATE_ATTRS_EXPERIMENTAL],
|
||||
itemStates: [...UI_CONTRACT_ITEM_STATES_EXPERIMENTAL],
|
||||
slots: [...UI_CONTRACT_SLOTS_EXPERIMENTAL],
|
||||
layers: [...UI_CONTRACT_LAYERS_EXPERIMENTAL],
|
||||
layoutOptions: [...UI_CONTRACT_LAYOUT_OPTIONS_EXPERIMENTAL],
|
||||
icons: [...UI_CONTRACT_ICONS_EXPERIMENTAL],
|
||||
viewLocations: [...UI_CONTRACT_VIEW_LOCATIONS_EXPERIMENTAL],
|
||||
sdkEvents: [...UI_CONTRACT_SDK_EVENTS_EXPERIMENTAL],
|
||||
},
|
||||
}
|
||||
|
||||
// Stable host features advertised to themes through the UI SDK (§6.3).
|
||||
export const UI_CONTRACT_FEATURES: readonly string[] = [
|
||||
...UI_CONTRACT_SLOTS.map((s) => `slot.${s}`),
|
||||
...UI_CONTRACT_LAYERS,
|
||||
'theme.layout',
|
||||
'theme.icons',
|
||||
'theme.brandMark',
|
||||
'theme.decorations',
|
||||
...UI_CONTRACT_SDK_EVENTS.map((e) => `sdk.event.${e}`),
|
||||
]
|
||||
+60
-12
@@ -1,7 +1,7 @@
|
||||
// Backend types come from the Wails-generated models (wailsjs/go/models.ts,
|
||||
// regenerated by `wails dev` / `wails build`). This file only adds what Go
|
||||
// cannot say: string unions, and `| null` for slices Go may send as nil.
|
||||
import { app, config, driver, host, installer, plugin, reims, runtime, version } from '../wailsjs/go/models'
|
||||
import { app, config, driver, host, installer, opencore, plugin, reims, runtime, version } from '../wailsjs/go/models'
|
||||
|
||||
/** A generated class as a plain data shape (no convertValues helper). */
|
||||
type Model<T> = Omit<T, 'convertValues'>
|
||||
@@ -9,12 +9,9 @@ type Model<T> = Omit<T, 'convertValues'>
|
||||
export type BuiltinLocale = 'zh-CN' | 'en-US'
|
||||
export type Locale = BuiltinLocale | (string & {})
|
||||
|
||||
export type RuntimeSource = 'auto' | 'github' | 'gitcode'
|
||||
|
||||
export type Config = Model<config.Config> & {
|
||||
locale: Locale
|
||||
runtime_channel?: 'stable' | 'alpha' | ''
|
||||
runtime_source?: RuntimeSource | ''
|
||||
}
|
||||
|
||||
export type DisplayInfo = host.DisplayInfo
|
||||
@@ -48,11 +45,11 @@ export type InstalledRuntime = Model<runtime.Installed>
|
||||
|
||||
export type RemoteRuntime = Model<runtime.Remote> & {
|
||||
channel: 'stable' | 'alpha'
|
||||
source?: 'github' | 'gitcode'
|
||||
}
|
||||
|
||||
export type VMListItem = Model<reims.VMListItem> & {
|
||||
state: 'running' | 'stopped' | 'broken'
|
||||
export type VMListItem = Model<driver.VMListItem> & {
|
||||
driver_id?: string
|
||||
state: 'running' | 'stopped' | 'suspended' | 'broken' | 'driver_unavailable'
|
||||
}
|
||||
|
||||
export type PendingChange = app.PendingChange
|
||||
@@ -64,12 +61,18 @@ export type AppState = Omit<Model<app.AppState>, 'config' | 'host' | 'optimizati
|
||||
runtimes: InstalledRuntime[] | null
|
||||
active_runtime?: InstalledRuntime
|
||||
vms: VMListItem[] | null
|
||||
vm_list_error?: string
|
||||
}
|
||||
|
||||
export type AppUpdateInfo = version.UpdateInfo
|
||||
export type SuspendInfo = reims.SuspendInfo
|
||||
export type VMDetail = reims.VMDetail
|
||||
export type SMBIOSIdentity = opencore.SMBIOSIdentity
|
||||
export type VMStats = app.VMStats
|
||||
export type DriveShareSettings = Model<app.DriveShareSettings>
|
||||
export type SharedFolderInfo = Model<app.SharedFolderInfo>
|
||||
export type SharedFolderSettings = Model<app.SharedFolderSettings>
|
||||
export type SharedFolderMode = 'disabled' | 'ro' | 'rw'
|
||||
export type VMAffinityMode = 'auto' | 'all' | 'pcores' | 'non_lpe' | 'custom'
|
||||
export type VMAffinityUpdate = {
|
||||
mode: VMAffinityMode
|
||||
@@ -83,9 +86,9 @@ export type VMAffinityStatus = Omit<Model<app.VMAffinityStatus>, 'mode' | 'effec
|
||||
/** One frame of a VM's screen (internal/app/thumbnail_flow.go). Empty data_url: none yet. */
|
||||
export type VMThumbnail = app.VMThumbnail
|
||||
export type ValidationIssue = reims.ValidationIssue
|
||||
export type DiskResizeResult = reims.DiskResizeResult
|
||||
export type DiskCompactResult = reims.DiskCompactResult
|
||||
export type DiskSnapshot = reims.DiskSnapshot
|
||||
export type DiskResizeResult = driver.DiskResizeResult
|
||||
export type DiskCompactResult = driver.DiskCompactResult
|
||||
export type DiskSnapshot = driver.DiskSnapshot
|
||||
export type StorageBreakdown = Model<app.StorageBreakdown>
|
||||
export type SetOpts = reims.SetOpts
|
||||
|
||||
@@ -103,9 +106,14 @@ export type CreateOpts = Model<reims.CreateOpts> & {
|
||||
|
||||
export type TaskStatus = 'running' | 'done' | 'failed' | 'canceled'
|
||||
|
||||
export type InstallerKind = 'offline' | 'online'
|
||||
export type InstallerPhase = 'queued' | 'downloading'
|
||||
|
||||
/** A tracked long-running job pushed as "reims:task" (internal/app/tasks.go). */
|
||||
export type Task = Model<app.Task> & {
|
||||
kind: 'installer-download' | 'vm-create' | string
|
||||
kind: 'installer-download' | 'recovery-download' | 'vm-create' | 'runtime-install' | 'app-update' | string
|
||||
installer_kind?: InstallerKind | ''
|
||||
installer_phase?: InstallerPhase | ''
|
||||
status: TaskStatus
|
||||
}
|
||||
|
||||
@@ -126,6 +134,14 @@ export type SettingProperty = plugin.SettingProperty
|
||||
export type SettingsSchema = plugin.SettingsSchema
|
||||
export type PluginInfo = plugin.PluginInfo
|
||||
export type DoctorFinding = plugin.DoctorFinding
|
||||
export type ScanFinding = plugin.ScanFinding
|
||||
export type ExecutableFile = plugin.ExecutableFile
|
||||
export type CapabilityItem = plugin.CapabilityItem
|
||||
export type ScanReport = plugin.ScanReport
|
||||
export type MarketEntry = plugin.MarketEntry
|
||||
export type MarketWithdrawal = plugin.MarketWithdrawal
|
||||
export type MarketCatalogItem = plugin.MarketCatalogItem
|
||||
export type MarketBrowseResult = plugin.MarketBrowseResult
|
||||
export type TokenDeriveRule = plugin.TokenDeriveRule
|
||||
export type ThemeScheme = plugin.ThemeScheme
|
||||
export type ThemeDecoration = plugin.ThemeDecoration
|
||||
@@ -133,10 +149,23 @@ export type ThemeDecorationState = plugin.ThemeDecorationState
|
||||
export type ThemeContribution = plugin.ThemeContribution
|
||||
export type CustomThemeScheme = plugin.CustomThemeScheme
|
||||
export type ActiveThemePayload = plugin.ActiveThemePayload
|
||||
export type ResolvedLocalePack = plugin.ResolvedLocalePack
|
||||
export interface ResolvedLocaleFont {
|
||||
family: string
|
||||
url: string
|
||||
weight?: string
|
||||
style?: string
|
||||
unicodeRange?: string
|
||||
}
|
||||
|
||||
export type ResolvedLocalePack = Model<plugin.ResolvedLocalePack> & {
|
||||
has_ui_messages?: boolean
|
||||
plugin_messages?: Record<string, Record<string, string>>
|
||||
fonts?: ResolvedLocaleFont[]
|
||||
}
|
||||
export type MenuContribution = plugin.MenuContribution
|
||||
export type VMCardContribution = plugin.VMCardContribution
|
||||
export type PanelContribution = plugin.PanelContribution
|
||||
export type ImageSourceContribution = plugin.ImageSourceContribution
|
||||
export type StatusItemContribution = plugin.StatusItemContribution
|
||||
export type PluginUIContributions = app.PluginUIContributions
|
||||
export type DriverSummary = driver.DriverSummary
|
||||
@@ -149,3 +178,22 @@ export interface LogEntry {
|
||||
source: string
|
||||
line: string
|
||||
}
|
||||
export type VMKeymapPreset = 'off' | 'win_to_cmd' | 'swap_alt_win' | 'custom'
|
||||
export type VMKeymapHostModifier = 'lwin' | 'rwin' | 'lalt' | 'ralt' | 'lctrl' | 'rctrl' | 'capslock'
|
||||
export type VMKeymapGuestModifier = 'default' | 'lcmd' | 'rcmd' | 'lopt' | 'ropt' | 'lctrl' | 'rctrl' | 'esc' | 'disabled'
|
||||
|
||||
export interface VMKeymapUpdate {
|
||||
preset: VMKeymapPreset
|
||||
bindings: Partial<Record<VMKeymapHostModifier, VMKeymapGuestModifier>>
|
||||
}
|
||||
|
||||
export interface VMKeymapStatus extends VMKeymapUpdate {
|
||||
needs_guest_tools: boolean
|
||||
guest_connected: boolean
|
||||
guest_agent_version?: number
|
||||
required_agent_version: number
|
||||
input_service_available: boolean
|
||||
guest_keymap_active: boolean
|
||||
hook_active: boolean
|
||||
running: boolean
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
import * as RTooltip from '@radix-ui/react-tooltip'
|
||||
import { LoaderCircle } from 'lucide-react'
|
||||
import React from 'react'
|
||||
import type { UIContractIcon } from '../styles/ui-contract'
|
||||
import { HostIcon } from './themeVisuals'
|
||||
|
||||
export const TooltipProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => (
|
||||
<RTooltip.Provider delayDuration={400} skipDelayDuration={200}>{children}</RTooltip.Provider>
|
||||
@@ -10,21 +12,28 @@ interface TipProps {
|
||||
label: string
|
||||
shortcut?: string
|
||||
side?: 'top' | 'bottom' | 'left' | 'right'
|
||||
disabled?: boolean
|
||||
children: React.ReactElement
|
||||
}
|
||||
|
||||
/** Tooltip around a single focusable child. */
|
||||
export const Tip: React.FC<TipProps> = ({ label, shortcut, side = 'bottom', children }) => (
|
||||
<RTooltip.Root>
|
||||
<RTooltip.Trigger asChild>{children}</RTooltip.Trigger>
|
||||
<RTooltip.Portal>
|
||||
<RTooltip.Content className="tooltip" side={side} sideOffset={6} collisionPadding={8}>
|
||||
{label}
|
||||
{shortcut && <kbd>{shortcut}</kbd>}
|
||||
</RTooltip.Content>
|
||||
</RTooltip.Portal>
|
||||
</RTooltip.Root>
|
||||
)
|
||||
export const Tip: React.FC<TipProps> = ({ label, shortcut, side = 'bottom', disabled, children }) => {
|
||||
const [open, setOpen] = React.useState(false)
|
||||
React.useEffect(() => {
|
||||
if (disabled) setOpen(false)
|
||||
}, [disabled])
|
||||
return (
|
||||
<RTooltip.Root open={disabled ? false : open} onOpenChange={(next) => setOpen(disabled ? false : next)}>
|
||||
<RTooltip.Trigger asChild>{children}</RTooltip.Trigger>
|
||||
<RTooltip.Portal>
|
||||
<RTooltip.Content className="tooltip rg-p-tooltip" side={side} sideOffset={6} collisionPadding={8}>
|
||||
{label}
|
||||
{shortcut && <kbd>{shortcut}</kbd>}
|
||||
</RTooltip.Content>
|
||||
</RTooltip.Portal>
|
||||
</RTooltip.Root>
|
||||
)
|
||||
}
|
||||
|
||||
type ButtonVariant = 'secondary' | 'primary' | 'danger' | 'ghost'
|
||||
|
||||
@@ -39,7 +48,9 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
<button
|
||||
ref={ref}
|
||||
type="button"
|
||||
className={`btn${variant === 'secondary' ? '' : ` btn-${variant}`}${className ? ` ${className}` : ''}`}
|
||||
className={`btn rg-p-button${variant === 'secondary' ? '' : ` btn-${variant}`}${className ? ` ${className}` : ''}`}
|
||||
data-variant={variant}
|
||||
data-busy={busy ? 'true' : undefined}
|
||||
disabled={disabled || busy}
|
||||
aria-busy={busy || undefined}
|
||||
{...rest}
|
||||
@@ -68,7 +79,8 @@ export const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
|
||||
ref={ref}
|
||||
type="button"
|
||||
aria-label={label}
|
||||
className={`icon-btn${small ? ' sm' : ''}${className ? ` ${className}` : ''}`}
|
||||
className={`icon-btn rg-p-icon-button${small ? ' sm' : ''}${className ? ` ${className}` : ''}`}
|
||||
data-busy={busy ? 'true' : undefined}
|
||||
disabled={disabled || busy}
|
||||
aria-busy={busy || undefined}
|
||||
{...rest}
|
||||
@@ -80,16 +92,29 @@ export const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
|
||||
)
|
||||
IconButton.displayName = 'IconButton'
|
||||
|
||||
export type StatusKind = 'running' | 'stopped' | 'busy' | 'broken' | 'warn'
|
||||
export type StatusKind = 'running' | 'stopped' | 'suspended' | 'busy' | 'broken' | 'warn'
|
||||
|
||||
export function statusKind(state: string): StatusKind {
|
||||
if (state === 'running') return 'running'
|
||||
if (state === 'starting' || state === 'stopping' || state === 'creating') return 'busy'
|
||||
if (state === 'suspended') return 'suspended'
|
||||
if (state === 'starting' || state === 'stopping' || state === 'suspending' || state === 'resuming' || state === 'creating') return 'busy'
|
||||
if (state === 'driver_unavailable') return 'warn'
|
||||
if (state === 'broken') return 'broken'
|
||||
return 'stopped'
|
||||
}
|
||||
|
||||
/** Status shape: differs by shape as well as colour. */
|
||||
const STATUS_ICON: Record<StatusKind, UIContractIcon> = {
|
||||
running: 'vm.state.running',
|
||||
stopped: 'vm.state.stopped',
|
||||
suspended: 'vm.state.suspended',
|
||||
busy: 'vm.state.busy',
|
||||
broken: 'vm.state.error',
|
||||
warn: 'vm.state.error',
|
||||
}
|
||||
|
||||
/** Status shape: differs by shape as well as colour; themes may replace it by icon name. */
|
||||
export const StatusShape: React.FC<{ kind: StatusKind }> = ({ kind }) => (
|
||||
<span className={`status status-${kind}`} aria-hidden="true" />
|
||||
<HostIcon name={STATUS_ICON[kind]} size={10}>
|
||||
<span className={`status status-${kind}`} aria-hidden="true" />
|
||||
</HostIcon>
|
||||
)
|
||||
+99
-28
@@ -1,45 +1,116 @@
|
||||
import * as Alert from '@radix-ui/react-alert-dialog'
|
||||
import * as RDialog from '@radix-ui/react-dialog'
|
||||
import { X } from 'lucide-react'
|
||||
import React from 'react'
|
||||
import { IconButton } from './controls'
|
||||
import { Button, IconButton } from './controls'
|
||||
|
||||
interface ConfirmDialogProps {
|
||||
title: string
|
||||
description: string
|
||||
cancelLabel: string
|
||||
confirmLabel: string
|
||||
onCancel: () => void
|
||||
onConfirm: () => void
|
||||
children?: React.ReactNode
|
||||
}
|
||||
|
||||
export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({ title, description, cancelLabel, confirmLabel, onCancel, onConfirm, children }) => {
|
||||
const prevFocusRef = React.useRef<HTMLElement | null>(
|
||||
typeof document !== 'undefined' && document.activeElement instanceof HTMLElement
|
||||
? document.activeElement
|
||||
: null,
|
||||
)
|
||||
return (
|
||||
<Alert.Root open onOpenChange={(open) => { if (!open) onCancel() }}>
|
||||
<Alert.Portal>
|
||||
<Alert.Overlay className="overlay" />
|
||||
<Alert.Content
|
||||
className="dialog rg-p-dialog sm"
|
||||
data-tone="danger"
|
||||
onCloseAutoFocus={(e) => {
|
||||
e.preventDefault()
|
||||
const prev = prevFocusRef.current
|
||||
if (prev?.isConnected) prev.focus({ preventScroll: true })
|
||||
}}
|
||||
>
|
||||
<div className="dialog-body">
|
||||
<Alert.Title className="dialog-title">{title}</Alert.Title>
|
||||
<Alert.Description className="dialog-desc">{description}</Alert.Description>
|
||||
{children}
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
<Alert.Cancel asChild><Button>{cancelLabel}</Button></Alert.Cancel>
|
||||
<Alert.Action asChild><Button variant="danger" onClick={onConfirm}>{confirmLabel}</Button></Alert.Action>
|
||||
</div>
|
||||
</Alert.Content>
|
||||
</Alert.Portal>
|
||||
</Alert.Root>
|
||||
)
|
||||
}
|
||||
|
||||
interface Props {
|
||||
title: string
|
||||
subtitle?: string
|
||||
closeLabel: string
|
||||
/** While false, Esc / outside click / ✕ are ignored (e.g. during a create). */
|
||||
/** While false, Esc / ✕ are ignored (e.g. during a create). */
|
||||
dismissable?: boolean
|
||||
onClose: () => void
|
||||
/** Extra class on the dialog box, e.g. a wider variant. */
|
||||
className?: string
|
||||
/** Exposed as data-tone for themes (ui-contract). */
|
||||
tone?: 'neutral' | 'danger' | 'warn'
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
/** Modal frame: head with title and ✕; children supply body/steps/foot sections. */
|
||||
export const Modal: React.FC<Props> = ({ title, subtitle, closeLabel, dismissable = true, onClose, className, children }) => (
|
||||
<RDialog.Root open onOpenChange={(open) => { if (!open && dismissable) onClose() }}>
|
||||
<RDialog.Portal>
|
||||
<RDialog.Overlay className="overlay" />
|
||||
<RDialog.Content
|
||||
className={className ? `dialog ${className}` : 'dialog'}
|
||||
onInteractOutside={(e) => e.preventDefault()}
|
||||
// Focus the first form field rather than ✕, so the close tooltip doesn't pop on open.
|
||||
onOpenAutoFocus={(e) => {
|
||||
const first = (e.currentTarget as HTMLElement | null)?.querySelector<HTMLElement>('input, select, textarea')
|
||||
if (first) { e.preventDefault(); first.focus() }
|
||||
}}
|
||||
>
|
||||
<div className="dialog-head">
|
||||
<div>
|
||||
<RDialog.Title className="dialog-title">{title}</RDialog.Title>
|
||||
{subtitle ? <RDialog.Description className="dialog-desc">{subtitle}</RDialog.Description> : <RDialog.Description />}
|
||||
export const Modal: React.FC<Props> = ({ title, subtitle, closeLabel, dismissable = true, onClose, className, tone = 'neutral', children }) => {
|
||||
const prevFocusRef = React.useRef<HTMLElement | null>(
|
||||
typeof document !== 'undefined' && document.activeElement instanceof HTMLElement
|
||||
? document.activeElement
|
||||
: null,
|
||||
)
|
||||
return (
|
||||
<RDialog.Root open onOpenChange={(open) => { if (!open && dismissable) onClose() }}>
|
||||
<RDialog.Portal>
|
||||
<RDialog.Overlay className="overlay" />
|
||||
<RDialog.Content
|
||||
className={className ? `dialog rg-p-dialog ${className}` : 'dialog rg-p-dialog'}
|
||||
data-tone={tone}
|
||||
onInteractOutside={(e) => e.preventDefault()}
|
||||
// Focus the first enabled form field, or the dialog container itself when there is
|
||||
// none, so the top-right ✕ close button's tooltip never pops on open.
|
||||
onOpenAutoFocus={(e) => {
|
||||
const root = e.currentTarget as HTMLElement | null
|
||||
if (!root) return
|
||||
e.preventDefault()
|
||||
const first = root.querySelector<HTMLElement>(
|
||||
'input:not(:disabled):not([type="hidden"]):not([type="radio"]:not(:checked)), select:not(:disabled), textarea:not(:disabled)',
|
||||
)
|
||||
if (first) {
|
||||
first.focus({ preventScroll: true })
|
||||
}
|
||||
if (!root.contains(document.activeElement)) {
|
||||
root.focus({ preventScroll: true })
|
||||
}
|
||||
}}
|
||||
onCloseAutoFocus={(e) => {
|
||||
e.preventDefault()
|
||||
const prev = prevFocusRef.current
|
||||
if (prev?.isConnected) prev.focus({ preventScroll: true })
|
||||
}}
|
||||
>
|
||||
<div className="dialog-head">
|
||||
<div>
|
||||
<RDialog.Title className="dialog-title">{title}</RDialog.Title>
|
||||
{subtitle ? <RDialog.Description className="dialog-desc">{subtitle}</RDialog.Description> : <RDialog.Description />}
|
||||
</div>
|
||||
<RDialog.Close asChild>
|
||||
<IconButton label={closeLabel} icon={<X size={16} />} disabled={!dismissable} />
|
||||
</RDialog.Close>
|
||||
</div>
|
||||
<RDialog.Close asChild>
|
||||
<IconButton label={closeLabel} icon={<X size={16} />} disabled={!dismissable} />
|
||||
</RDialog.Close>
|
||||
</div>
|
||||
{children}
|
||||
</RDialog.Content>
|
||||
</RDialog.Portal>
|
||||
</RDialog.Root>
|
||||
)
|
||||
{children}
|
||||
</RDialog.Content>
|
||||
</RDialog.Portal>
|
||||
</RDialog.Root>
|
||||
)
|
||||
}
|
||||
@@ -86,7 +86,7 @@ export const SetValue: React.FC<{ title: string; value: React.ReactNode; mono?:
|
||||
)
|
||||
|
||||
export const Switch: React.FC<{ checked: boolean; onChange: (v: boolean) => void; label: string; disabled?: boolean }> = ({ checked, onChange, label, disabled }) => (
|
||||
<label className="switch">
|
||||
<label className="switch rg-p-switch">
|
||||
<input type="checkbox" role="switch" aria-label={label} checked={checked} disabled={disabled} onChange={(e) => onChange(e.target.checked)} />
|
||||
<span className="slider" />
|
||||
</label>
|
||||
@@ -122,7 +122,10 @@ export function Segmented<V extends string | number>({ options, value, onChange,
|
||||
return next
|
||||
})
|
||||
}
|
||||
useLayoutEffect(measure, [value, options])
|
||||
const optionsSig = options.map((o) => `${String(o.value)}\x1f${o.label}`).join('\x1e')
|
||||
const docDir = typeof document !== 'undefined' ? document.documentElement.dir : ''
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
useLayoutEffect(measure, [value, optionsSig, wide, docDir])
|
||||
useEffect(() => {
|
||||
if (!box.current || typeof ResizeObserver === 'undefined') return
|
||||
let raf = 0
|
||||
@@ -142,30 +145,34 @@ export function Segmented<V extends string | number>({ options, value, onChange,
|
||||
}, [])
|
||||
|
||||
const onKey = (e: React.KeyboardEvent) => {
|
||||
if (e.key !== 'ArrowRight' && e.key !== 'ArrowLeft') return
|
||||
if (e.key !== 'ArrowRight' && e.key !== 'ArrowLeft' && e.key !== 'ArrowDown' && e.key !== 'ArrowUp') return
|
||||
e.preventDefault()
|
||||
const enabled = options.filter((o) => !o.disabled)
|
||||
const i = enabled.findIndex((o) => o.value === value)
|
||||
const next = enabled[(i + (e.key === 'ArrowRight' ? 1 : -1) + enabled.length) % enabled.length]
|
||||
const isRTL = box.current ? getComputedStyle(box.current).direction === 'rtl' : false
|
||||
const forward = e.key === 'ArrowDown' || (e.key === 'ArrowRight' && !isRTL) || (e.key === 'ArrowLeft' && isRTL)
|
||||
const delta = forward ? 1 : -1
|
||||
const next = enabled[(i + delta + enabled.length) % enabled.length]
|
||||
if (next) {
|
||||
onChange(next.value)
|
||||
requestAnimationFrame(() => box.current?.querySelector<HTMLElement>('[aria-checked="true"]')?.focus())
|
||||
}
|
||||
}
|
||||
|
||||
const hasActive = options.some((o) => o.value === value)
|
||||
const firstEnabled = options.findIndex((o) => !o.disabled)
|
||||
const hasActive = options.some((o) => !o.disabled && o.value === value)
|
||||
return (
|
||||
<div ref={box} className={`seg${wide ? ' seg-wide' : ''}`} role="radiogroup" aria-label={label} onKeyDown={onKey}>
|
||||
{thumb && <span className="seg-thumb" style={{ transform: `translateX(${thumb.x}px)`, width: thumb.w }} aria-hidden="true" />}
|
||||
{options.map((o, i) => {
|
||||
const on = o.value === value
|
||||
const on = !o.disabled && o.value === value
|
||||
return (
|
||||
<button
|
||||
key={String(o.value)}
|
||||
type="button"
|
||||
role="radio"
|
||||
aria-checked={on}
|
||||
tabIndex={on || (!hasActive && i === 0) ? 0 : -1}
|
||||
tabIndex={on || (!hasActive && i === firstEnabled) ? 0 : -1}
|
||||
disabled={o.disabled}
|
||||
onClick={() => onChange(o.value)}
|
||||
>
|
||||
@@ -277,7 +284,7 @@ export const RangeField: React.FC<RangeProps> = ({ value, min, max, step = 1, un
|
||||
return (
|
||||
<div className="range-field" data-warn={over || undefined}>
|
||||
<div className="range-main">
|
||||
<div className="range-rail-wrap">
|
||||
<div className="range-rail-wrap" dir="ltr">
|
||||
<div className="range-rail" aria-hidden="true">
|
||||
<div className="range-track" />
|
||||
{recommend && (
|
||||
@@ -350,7 +357,7 @@ export function OptionCards<V extends string>({ options, value, onChange, label,
|
||||
<span className="opt-card-title" title={o.title}>{o.title}</span>
|
||||
{o.sub && <span className="opt-card-sub">{o.sub}</span>}
|
||||
{o.badges && o.badges.length > 0 && (
|
||||
<span className="opt-card-badges">{o.badges.map((b) => <span key={b} className="badge badge-accent">{b}</span>)}</span>
|
||||
<span className="opt-card-badges">{o.badges.map((b) => <span key={b} className="badge rg-p-badge badge-accent">{b}</span>)}</span>
|
||||
)}
|
||||
</label>
|
||||
))}
|
||||
@@ -382,8 +389,9 @@ export function PopupSelect<V extends string>({ value, options, onChange, label,
|
||||
id?: string
|
||||
}) {
|
||||
const cur = options.find((o) => o.value === value)
|
||||
const dir: 'ltr' | 'rtl' = typeof document !== 'undefined' && document.documentElement.dir === 'rtl' ? 'rtl' : 'ltr'
|
||||
return (
|
||||
<Menu.Root modal={false}>
|
||||
<Menu.Root dir={dir} modal={false}>
|
||||
<Menu.Trigger asChild>
|
||||
<button type="button" id={id} className={`popup-btn${wide ? ' popup-wide' : ''}`} aria-label={label}>
|
||||
<span className="popup-value">
|
||||
@@ -394,10 +402,10 @@ export function PopupSelect<V extends string>({ value, options, onChange, label,
|
||||
</button>
|
||||
</Menu.Trigger>
|
||||
<Menu.Portal>
|
||||
<Menu.Content className="menu popup-menu" align="start" sideOffset={4} collisionPadding={8}>
|
||||
<Menu.Content className="menu rg-p-menu popup-menu" align="start" sideOffset={4} collisionPadding={8}>
|
||||
<Menu.RadioGroup value={value ?? ''} onValueChange={(v) => onChange(v as V)}>
|
||||
{options.map((o) => (
|
||||
<Menu.RadioItem key={o.value} value={o.value} disabled={o.disabled} className="menu-item popup-item">
|
||||
<Menu.RadioItem key={o.value} value={o.value} disabled={o.disabled} className="menu-item rg-p-menu-item popup-item">
|
||||
<Menu.ItemIndicator className="popup-check"><Check size={13} /></Menu.ItemIndicator>
|
||||
<span className="popup-item-label">{o.label}</span>
|
||||
{o.detail && <span className="popup-detail">{o.detail}</span>}
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
// Theme visuals from uiApi 2.0 (docs/plugin-architecture.md §5.1): icon
|
||||
// overrides, the brand mark, and declarative decorations rendered into slot
|
||||
// anchors (`data-rg-slot`) and full-window layers (`data-rg-layer`).
|
||||
// With the built-in theme none of this injects anything.
|
||||
import React, { createContext, useContext, useEffect, useMemo, useState } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { locText } from '../i18n'
|
||||
import { matchDecorationState, themeAssetURL, type UIStateSnapshot } from '../lib/themeEngine'
|
||||
import { UI_CONTRACT_ICONS, UI_CONTRACT_LAYERS, UI_CONTRACT_SLOTS, type UIContractIcon } from '../styles/ui-contract'
|
||||
import type { ActiveThemePayload, Locale, ThemeDecoration } from '../types'
|
||||
|
||||
const DEFAULT_BRAND_MARK = '/logo.svg'
|
||||
const KNOWN_ICONS = new Set<string>(UI_CONTRACT_ICONS)
|
||||
const KNOWN_TARGETS = new Set<string>([...UI_CONTRACT_SLOTS, ...UI_CONTRACT_LAYERS])
|
||||
|
||||
export interface ThemeVisuals {
|
||||
brandMarkURL: string
|
||||
icons: Partial<Record<UIContractIcon, string>>
|
||||
}
|
||||
|
||||
const EMPTY: ThemeVisuals = { brandMarkURL: DEFAULT_BRAND_MARK, icons: {} }
|
||||
const ThemeVisualsContext = createContext<ThemeVisuals>(EMPTY)
|
||||
|
||||
function isBuiltin(payload: ActiveThemePayload | null): boolean {
|
||||
return !payload?.theme || payload.theme_id === 'builtin.theme.default'
|
||||
}
|
||||
|
||||
export function resolveThemeVisuals(payload: ActiveThemePayload | null): ThemeVisuals {
|
||||
if (isBuiltin(payload)) return EMPTY
|
||||
const th = payload!.theme!
|
||||
const icons: Partial<Record<UIContractIcon, string>> = {}
|
||||
for (const [name, rel] of Object.entries(th.icons ?? {})) {
|
||||
const url = KNOWN_ICONS.has(name) ? themeAssetURL(payload, rel) : null
|
||||
if (url) icons[name as UIContractIcon] = url
|
||||
}
|
||||
return { brandMarkURL: themeAssetURL(payload, th.brandMark) ?? DEFAULT_BRAND_MARK, icons }
|
||||
}
|
||||
|
||||
export const ThemeVisualsProvider: React.FC<{ payload: ActiveThemePayload | null; children: React.ReactNode }> = ({ payload, children }) => {
|
||||
const value = useMemo(() => resolveThemeVisuals(payload), [payload])
|
||||
return <ThemeVisualsContext.Provider value={value}>{children}</ThemeVisualsContext.Provider>
|
||||
}
|
||||
|
||||
export function useThemeVisuals(): ThemeVisuals {
|
||||
return useContext(ThemeVisualsContext)
|
||||
}
|
||||
|
||||
type IconChild = React.ReactElement<{ size?: number | string; 'data-rg-icon'?: string }>
|
||||
|
||||
/**
|
||||
* A host icon a theme can replace by name (ui-contract UI_CONTRACT_ICONS).
|
||||
* The child is the built-in icon; both carry `data-rg-icon` for styling.
|
||||
*/
|
||||
export const HostIcon: React.FC<{ name: UIContractIcon; size?: number; children: IconChild }> = ({ name, size: sizeProp, children }) => {
|
||||
const { icons } = useThemeVisuals()
|
||||
const url = icons[name]
|
||||
if (!url) return React.cloneElement(children, { 'data-rg-icon': name })
|
||||
const size = sizeProp ?? Number(children.props.size ?? 16)
|
||||
return (
|
||||
<span
|
||||
className="rg-icon"
|
||||
data-rg-icon={name}
|
||||
aria-hidden="true"
|
||||
style={{ width: size, height: size, ['--rg-icon' as string]: `url("${url}")` }}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
/** The product mark, replaceable by a theme's `brandMark`. */
|
||||
export const BrandMark: React.FC<{ className: string }> = ({ className }) => {
|
||||
const { brandMarkURL } = useThemeVisuals()
|
||||
return <img className={className} src={brandMarkURL} alt="" aria-hidden="true" />
|
||||
}
|
||||
|
||||
interface DecorationProps {
|
||||
urls: string[]
|
||||
fps: number
|
||||
reducedMotion: boolean
|
||||
width?: number
|
||||
height?: number
|
||||
alt: string
|
||||
}
|
||||
|
||||
const DecorationImage: React.FC<DecorationProps> = ({ urls, fps, reducedMotion, width, height, alt }) => {
|
||||
const [frame, setFrame] = useState(0)
|
||||
const animate = urls.length > 1 && !reducedMotion
|
||||
useEffect(() => {
|
||||
setFrame(0)
|
||||
if (!animate) return
|
||||
const id = window.setInterval(() => setFrame((f) => (f + 1) % urls.length), 1000 / Math.min(30, Math.max(1, fps || 8)))
|
||||
return () => window.clearInterval(id)
|
||||
}, [animate, fps, urls.join('|')])
|
||||
return (
|
||||
<img
|
||||
className="rg-decoration"
|
||||
src={urls[animate ? frame : 0]}
|
||||
width={width || undefined}
|
||||
height={height || undefined}
|
||||
alt={alt}
|
||||
aria-hidden={alt ? undefined : true}
|
||||
draggable={false}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
const anchorSelector = (target: string) => `[data-rg-slot="${CSS.escape(target)}"], [data-rg-layer="${CSS.escape(target)}"]`
|
||||
|
||||
/**
|
||||
* Renders the active theme's decorations into every matching anchor. Anchors
|
||||
* that repeat per VM (`nav.item.trailing`) evaluate states against that VM.
|
||||
*/
|
||||
export const ThemeDecorations: React.FC<{ payload: ActiveThemePayload | null; snap: UIStateSnapshot; locale: Locale }> = ({ payload, snap, locale }) => {
|
||||
const decorations: ThemeDecoration[] = isBuiltin(payload)
|
||||
? []
|
||||
: (payload!.theme!.decorations ?? []).filter((d) => KNOWN_TARGETS.has(d.slot))
|
||||
const targets = useMemo(() => [...new Set(decorations.map((d) => d.slot))], [decorations.map((d) => d.slot).join('|')])
|
||||
const [anchors, setAnchors] = useState<Record<string, Element[]>>({})
|
||||
|
||||
// Anchors come and go with views; rescan once per frame after DOM changes.
|
||||
useEffect(() => {
|
||||
if (targets.length === 0) {
|
||||
setAnchors({})
|
||||
return
|
||||
}
|
||||
let raf = 0
|
||||
const scan = () => {
|
||||
raf = 0
|
||||
const next: Record<string, Element[]> = {}
|
||||
for (const target of targets) next[target] = Array.from(document.querySelectorAll(anchorSelector(target)))
|
||||
setAnchors((prev) => {
|
||||
const same = targets.every((tg) => (prev[tg]?.length ?? 0) === next[tg].length && next[tg].every((el, i) => prev[tg][i] === el))
|
||||
return same ? prev : next
|
||||
})
|
||||
}
|
||||
scan()
|
||||
const obs = new MutationObserver(() => {
|
||||
if (!raf) raf = requestAnimationFrame(scan)
|
||||
})
|
||||
obs.observe(document.body, { childList: true, subtree: true })
|
||||
return () => {
|
||||
obs.disconnect()
|
||||
if (raf) cancelAnimationFrame(raf)
|
||||
}
|
||||
}, [targets.join('|')])
|
||||
|
||||
if (decorations.length === 0) return null
|
||||
const reducedMotion = snap.motion === 'reduced'
|
||||
const portals: React.ReactNode[] = []
|
||||
for (const dec of decorations) {
|
||||
for (const [i, anchor] of (anchors[dec.slot] ?? []).entries()) {
|
||||
// Per-VM anchors read the VM's own state from the enclosing item.
|
||||
const item = (anchor as HTMLElement).closest<HTMLElement>('[data-vm-state]')
|
||||
const itemSnap = item && (anchor as HTMLElement).dataset.rgKey ? { ...snap, vmState: item.dataset.vmState ?? '', busy: item.dataset.busy === 'true' } : snap
|
||||
const st = matchDecorationState(dec, itemSnap)
|
||||
if (!st) continue
|
||||
const frames = (st.frames ?? []).map((f) => themeAssetURL(payload, f)).filter((u): u is string => !!u)
|
||||
const asset = themeAssetURL(payload, st.asset)
|
||||
const urls = frames.length > 0 ? frames : asset ? [asset] : []
|
||||
if (urls.length === 0) continue
|
||||
portals.push(createPortal(
|
||||
<DecorationImage
|
||||
urls={urls}
|
||||
fps={st.fps ?? 0}
|
||||
reducedMotion={reducedMotion}
|
||||
width={dec.width}
|
||||
height={dec.height}
|
||||
alt={dec.alt ? locText(dec.alt, locale, '') : ''}
|
||||
/>,
|
||||
anchor,
|
||||
`${dec.id}:${i}`,
|
||||
))
|
||||
}
|
||||
}
|
||||
return <>{portals}</>
|
||||
}
|
||||
+105
-23
@@ -1,5 +1,7 @@
|
||||
import * as RToast from '@radix-ui/react-toast'
|
||||
import { CircleCheck, CircleX, X } from 'lucide-react'
|
||||
import { Check, CircleCheck, CircleX, X } from 'lucide-react'
|
||||
import { HostIcon } from './themeVisuals'
|
||||
import { emitThemeEvent } from '../lib/themeEngine'
|
||||
import React, { useCallback, useState } from 'react'
|
||||
import { IconButton } from './controls'
|
||||
|
||||
@@ -7,6 +9,10 @@ export interface ToastInput {
|
||||
kind: 'ok' | 'error'
|
||||
title: string
|
||||
description?: string
|
||||
errorCode?: string
|
||||
rawDetail?: string
|
||||
detailsLabel?: string
|
||||
copyDetailsLabel?: string
|
||||
action?: { label: string; onClick: () => void }
|
||||
}
|
||||
|
||||
@@ -20,40 +26,116 @@ export function useToasts() {
|
||||
const [items, setItems] = useState<ToastItem[]>([])
|
||||
const push = useCallback((input: ToastInput) => {
|
||||
setItems((prev) => [...prev.slice(-3), { ...input, id: seq++ }])
|
||||
emitThemeEvent('toast.shown', { kind: input.kind, title: input.title })
|
||||
}, [])
|
||||
const remove = useCallback((id: number) => setItems((prev) => prev.filter((i) => i.id !== id)), [])
|
||||
return { items, push, remove }
|
||||
}
|
||||
|
||||
interface ToastCardProps {
|
||||
item: ToastItem
|
||||
onRemove: (id: number) => void
|
||||
closeLabel: string
|
||||
}
|
||||
|
||||
const ToastCard: React.FC<ToastCardProps> = ({ item, onRemove, closeLabel }) => {
|
||||
const [expanded, setExpanded] = useState(false)
|
||||
const [copied, setCopied] = useState(false)
|
||||
|
||||
const copyDiagnostic = () => {
|
||||
const full = [
|
||||
item.errorCode ? `[${item.errorCode}] ${item.title}` : item.title,
|
||||
item.description,
|
||||
item.rawDetail,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join('\n')
|
||||
navigator.clipboard
|
||||
?.writeText(full)
|
||||
.then(() => {
|
||||
setCopied(true)
|
||||
window.setTimeout(() => setCopied(false), 1500)
|
||||
})
|
||||
.catch((e) => console.warn('[toast] clipboard write failed:', e))
|
||||
}
|
||||
|
||||
return (
|
||||
<RToast.Root
|
||||
className={`toast rg-p-toast ${item.kind}${item.rawDetail || item.action ? ' has-extra' : ''}`}
|
||||
data-tone={item.kind}
|
||||
duration={expanded ? 600_000 : item.kind === 'error' ? 10_000 : item.action ? 8000 : 3000}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onRemove(item.id)
|
||||
}}
|
||||
>
|
||||
<div className="toast-main-row">
|
||||
{item.kind === 'ok' ? (
|
||||
<CircleCheck size={16} aria-hidden="true" />
|
||||
) : (
|
||||
<HostIcon name="error"><CircleX size={16} aria-hidden="true" /></HostIcon>
|
||||
)}
|
||||
<div className="toast-text">
|
||||
<div className="toast-title-row">
|
||||
<RToast.Title className="toast-title">{item.title}</RToast.Title>
|
||||
{item.errorCode && <span className="toast-code selectable">{item.errorCode}</span>}
|
||||
</div>
|
||||
{item.description && (
|
||||
<RToast.Description className="toast-desc">{item.description}</RToast.Description>
|
||||
)}
|
||||
</div>
|
||||
{item.action && !item.rawDetail && (
|
||||
<RToast.Action asChild altText={item.action.label}>
|
||||
<button type="button" className="btn rg-p-button" onClick={item.action.onClick}>
|
||||
{item.action.label}
|
||||
</button>
|
||||
</RToast.Action>
|
||||
)}
|
||||
<RToast.Close asChild>
|
||||
<IconButton small label={closeLabel} icon={<X size={14} aria-hidden="true" />} tipSide="top" />
|
||||
</RToast.Close>
|
||||
</div>
|
||||
{(item.rawDetail || (item.action && item.rawDetail)) && (
|
||||
<div className="toast-footer">
|
||||
{item.rawDetail && (
|
||||
<details
|
||||
className="toast-details"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onToggle={(e) => setExpanded(e.currentTarget.open)}
|
||||
>
|
||||
<summary>{item.detailsLabel}</summary>
|
||||
<div className="toast-details-body selectable">{item.rawDetail}</div>
|
||||
{item.copyDetailsLabel && (
|
||||
<button type="button" className="toast-copy-btn" onClick={copyDiagnostic}>
|
||||
{copied ? <Check size={12} aria-hidden="true" /> : null}
|
||||
<span>{item.copyDetailsLabel}</span>
|
||||
</button>
|
||||
)}
|
||||
</details>
|
||||
)}
|
||||
{item.action && (
|
||||
<RToast.Action asChild altText={item.action.label}>
|
||||
<button type="button" className="btn rg-p-button toast-action-btn" onClick={item.action.onClick}>
|
||||
{item.action.label}
|
||||
</button>
|
||||
</RToast.Action>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</RToast.Root>
|
||||
)
|
||||
}
|
||||
|
||||
interface ToasterProps {
|
||||
items: ToastItem[]
|
||||
onRemove: (id: number) => void
|
||||
closeLabel: string
|
||||
dir?: 'ltr' | 'rtl'
|
||||
}
|
||||
|
||||
export const Toaster: React.FC<ToasterProps> = ({ items, onRemove, closeLabel }) => (
|
||||
<RToast.Provider swipeDirection="right">
|
||||
export const Toaster: React.FC<ToasterProps> = ({ items, onRemove, closeLabel, dir = 'ltr' }) => (
|
||||
<RToast.Provider swipeDirection={dir === 'rtl' ? 'left' : 'right'}>
|
||||
{items.map((item) => (
|
||||
<RToast.Root
|
||||
key={item.id}
|
||||
className={`toast ${item.kind}`}
|
||||
duration={item.kind === 'error' ? 8000 : 3000}
|
||||
onOpenChange={(open) => { if (!open) onRemove(item.id) }}
|
||||
>
|
||||
{item.kind === 'ok' ? <CircleCheck size={16} /> : <CircleX size={16} />}
|
||||
<div className="toast-text">
|
||||
<RToast.Title className="toast-title">{item.title}</RToast.Title>
|
||||
{item.description && <RToast.Description className="toast-desc">{item.description}</RToast.Description>}
|
||||
</div>
|
||||
{item.action && (
|
||||
<RToast.Action asChild altText={item.action.label}>
|
||||
<button type="button" className="btn" onClick={item.action.onClick}>{item.action.label}</button>
|
||||
</RToast.Action>
|
||||
)}
|
||||
<RToast.Close asChild>
|
||||
<IconButton small label={closeLabel} icon={<X size={14} />} tipSide="top" />
|
||||
</RToast.Close>
|
||||
</RToast.Root>
|
||||
<ToastCard key={item.id} item={item} onRemove={onRemove} closeLabel={closeLabel} />
|
||||
))}
|
||||
<RToast.Viewport className="toast-viewport" />
|
||||
</RToast.Provider>
|
||||
|
||||
+44
-13
@@ -16,8 +16,8 @@ import {
|
||||
} from '../wailsjs/runtime/runtime'
|
||||
import type {
|
||||
ActiveThemePayload, AppState, CachedInstaller, DataRootChoice, DriverSummary,
|
||||
LogEntry, PluginInfo, PluginUIContributions, RemoteRuntime, RuntimeKindSpec,
|
||||
Task, VMAffinityStatus, VMAffinityUpdate,
|
||||
LogEntry, MarketBrowseResult, PluginInfo, PluginUIContributions, RemoteRuntime,
|
||||
RuntimeKindSpec, ScanReport, Task, VMAffinityStatus, VMAffinityUpdate, VMKeymapStatus, VMKeymapUpdate,
|
||||
} from './types'
|
||||
|
||||
type AnyFn = (...args: never[]) => unknown
|
||||
@@ -57,8 +57,9 @@ export function hideWailsGlobals(): void {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
})
|
||||
} catch {
|
||||
} catch (e) {
|
||||
// non-configurable in some test environments
|
||||
console.warn('[wails] hide window.go failed:', e)
|
||||
}
|
||||
try {
|
||||
const minimalRuntime = typeof capturedRuntime.ResolveFilePaths === 'function'
|
||||
@@ -71,8 +72,9 @@ export function hideWailsGlobals(): void {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
})
|
||||
} catch {
|
||||
} catch (e) {
|
||||
// ignore if non-configurable
|
||||
console.warn('[wails] hide window.runtime failed:', e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,14 +114,23 @@ export function WindowToggleMaximise(): void {
|
||||
}
|
||||
|
||||
function eventsOn<T>(eventName: string, cb: (data: T) => void): () => void {
|
||||
if (typeof capturedRuntime.EventsOnMultiple === 'function') {
|
||||
return (capturedRuntime.EventsOnMultiple as (name: string, fn: (data: T) => void, max: number) => () => void)(
|
||||
eventName,
|
||||
cb,
|
||||
-1,
|
||||
)
|
||||
const off = typeof capturedRuntime.EventsOnMultiple === 'function'
|
||||
? (capturedRuntime.EventsOnMultiple as (name: string, fn: (data: T) => void, max: number) => () => void)(
|
||||
eventName,
|
||||
cb,
|
||||
-1,
|
||||
)
|
||||
: RawEventsOn(eventName, cb)
|
||||
// Unsubscribing notifies the backend over IPC, which throws when the bridge
|
||||
// is down (e.g. a browser preview); a failed unsubscribe must not take the
|
||||
// unmounting component down with it.
|
||||
return () => {
|
||||
try {
|
||||
off()
|
||||
} catch (e) {
|
||||
console.warn('[wails] unsubscribe event failed:', eventName, e)
|
||||
}
|
||||
}
|
||||
return RawEventsOn(eventName, cb)
|
||||
}
|
||||
|
||||
function eventsEmit(eventName: string, ...args: unknown[]): void {
|
||||
@@ -129,8 +140,9 @@ function eventsEmit(eventName: string, ...args: unknown[]): void {
|
||||
return
|
||||
}
|
||||
;(RawEventsEmit as (name: string, ...data: unknown[]) => void)(eventName, ...args)
|
||||
} catch {
|
||||
// ignore if Wails runtime is unavailable (e.g. standalone preview)
|
||||
} catch (e) {
|
||||
// Wails runtime may be unavailable (e.g. standalone preview)
|
||||
console.warn('[wails] emit event failed:', eventName, e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,23 +152,42 @@ export const api = {
|
||||
GetTasks: boundGo.GetTasks as () => Promise<Task[]>,
|
||||
GetVMAffinity: boundGo.GetVMAffinity as (name: string) => Promise<VMAffinityStatus>,
|
||||
SetVMAffinity: boundGo.SetVMAffinity as (name: string, req: VMAffinityUpdate) => Promise<VMAffinityStatus>,
|
||||
GetVMAffinityWithDriver: boundGo.GetVMAffinityWithDriver as (driverID: string, name: string) => Promise<VMAffinityStatus>,
|
||||
SetVMAffinityWithDriver: boundGo.SetVMAffinityWithDriver as (driverID: string, name: string, req: VMAffinityUpdate) => Promise<VMAffinityStatus>,
|
||||
GetVMKeymap: boundGo.GetVMKeymap as (name: string) => Promise<VMKeymapStatus>,
|
||||
SetVMKeymap: boundGo.SetVMKeymap as (name: string, req: VMKeymapUpdate) => Promise<VMKeymapStatus>,
|
||||
ListInstallers: boundGo.ListInstallers as () => Promise<CachedInstaller[] | null>,
|
||||
ListRemoteRuntimes: boundGo.ListRemoteRuntimes as () => Promise<RemoteRuntime[] | null>,
|
||||
SuggestDataRoots: boundGo.SuggestDataRoots as () => Promise<DataRootChoice[] | null>,
|
||||
ListPlugins: boundGo.ListPlugins as () => Promise<PluginInfo[] | null>,
|
||||
InspectPluginArchive: boundGo.InspectPluginArchive as (path: string) => Promise<ScanReport>,
|
||||
ScanInstalledPlugin: boundGo.ScanInstalledPlugin as (id: string) => Promise<ScanReport>,
|
||||
BrowsePluginMarket: boundGo.BrowsePluginMarket as (query: string, kind: string, includeAlpha: boolean, forceRefresh: boolean) => Promise<MarketBrowseResult>,
|
||||
PeekPluginMarket: boundGo.PeekPluginMarket as (query: string, kind: string) => Promise<MarketBrowseResult>,
|
||||
InstallMarketPlugin: boundGo.InstallMarketPlugin as (id: string, includeAlpha: boolean) => Promise<PluginInfo>,
|
||||
GetPluginUIContributions: boundGo.GetPluginUIContributions as () => Promise<PluginUIContributions>,
|
||||
GetActiveTheme: boundGo.GetActiveTheme as () => Promise<ActiveThemePayload>,
|
||||
ListDrivers: boundGo.ListDrivers as () => Promise<DriverSummary[] | null>,
|
||||
ListRuntimeKinds: boundGo.ListRuntimeKinds as () => Promise<RuntimeKindSpec[] | null>,
|
||||
}
|
||||
|
||||
export interface MarketInstallProgress {
|
||||
id: string
|
||||
phase: 'download' | 'install'
|
||||
done: number
|
||||
total: number
|
||||
}
|
||||
|
||||
export const events = {
|
||||
onTask: (cb: (task: Task) => void) => eventsOn('reims:task', cb),
|
||||
onStateChanged: (cb: () => void) => eventsOn('reims:state-changed', cb),
|
||||
onLog: (cb: (entry: LogEntry) => void) => eventsOn('reims:log', cb),
|
||||
// Market install progress (internal/app/plugins_flow.go InstallMarketPlugin).
|
||||
onPluginInstall: (cb: (p: MarketInstallProgress) => void) => eventsOn('reims:plugin-install', cb),
|
||||
// Tray menu (internal/app/app.go trayVMAction): "Show in Reims-Go" and "New VM…".
|
||||
onTraySelectVM: (cb: (name: string) => void) => eventsOn('reims:tray-select-vm', cb),
|
||||
onTrayNewVM: (cb: () => void) => eventsOn('reims:tray-new-vm', cb),
|
||||
onTrayDiscardSuspend: (cb: (name: string) => void) => eventsOn('reims:tray-discard-suspend', cb),
|
||||
// Renderer health watchdog & crash reporting (internal/app/ui_health.go).
|
||||
onUIPing: (cb: () => void) => eventsOn('reims:ui-ping', cb),
|
||||
emitUIPong: () => eventsEmit('reims:ui-pong'),
|
||||
|
||||
+154
-41
@@ -1,8 +1,145 @@
|
||||
{
|
||||
"uiApi": "1.0.0",
|
||||
"uiApi": "2.0.0",
|
||||
"parts": [
|
||||
"rg-p-shell",
|
||||
"rg-p-titlebar",
|
||||
"rg-p-brand",
|
||||
"rg-p-workspace",
|
||||
"rg-p-sidebar",
|
||||
"rg-p-sidebar-head",
|
||||
"rg-p-nav",
|
||||
"rg-p-main",
|
||||
"rg-p-vm-page",
|
||||
"rg-p-vm-header",
|
||||
"rg-p-vm-preview",
|
||||
"rg-p-vm-summary",
|
||||
"rg-p-statusbar",
|
||||
"rg-p-logpanel",
|
||||
"rg-p-settings",
|
||||
"rg-p-empty",
|
||||
"rg-p-nav-group",
|
||||
"rg-p-nav-item",
|
||||
"rg-p-button",
|
||||
"rg-p-icon-button",
|
||||
"rg-p-card",
|
||||
"rg-p-badge",
|
||||
"rg-p-tabs",
|
||||
"rg-p-tab",
|
||||
"rg-p-menu",
|
||||
"rg-p-menu-item",
|
||||
"rg-p-dialog",
|
||||
"rg-p-toast",
|
||||
"rg-p-tooltip",
|
||||
"rg-p-input",
|
||||
"rg-p-switch",
|
||||
"rg-p-progress",
|
||||
"rg-p-vm-actions",
|
||||
"rg-p-plugin-view"
|
||||
],
|
||||
"stateAttrs": [
|
||||
"data-theme",
|
||||
"data-motion",
|
||||
"data-locale",
|
||||
"data-view",
|
||||
"data-vm-state",
|
||||
"data-busy",
|
||||
"data-has-error",
|
||||
"data-sidebar-collapsed",
|
||||
"data-safe-mode",
|
||||
"data-layout-sidebar",
|
||||
"data-layout-sidebar-mode",
|
||||
"data-layout-density",
|
||||
"data-layout-titlebar"
|
||||
],
|
||||
"itemStates": [
|
||||
"rg-p-nav-item:data-vm-state",
|
||||
"rg-p-nav-item:data-driver",
|
||||
"rg-p-nav-item:data-selected",
|
||||
"rg-p-nav-item:data-busy",
|
||||
"rg-p-vm-page:data-vm-state",
|
||||
"rg-p-vm-page:data-driver",
|
||||
"rg-p-button:data-variant",
|
||||
"rg-p-button:data-busy",
|
||||
"rg-p-icon-button:data-busy",
|
||||
"rg-p-dialog:data-tone",
|
||||
"rg-p-toast:data-tone"
|
||||
],
|
||||
"slots": [
|
||||
"titlebar.center",
|
||||
"sidebar.header",
|
||||
"sidebar.footer",
|
||||
"nav.item.trailing",
|
||||
"vm.header.trailing",
|
||||
"vm.toolbar",
|
||||
"vm.card",
|
||||
"vm.preview.tl",
|
||||
"vm.preview.tr",
|
||||
"vm.preview.bl",
|
||||
"vm.preview.br",
|
||||
"statusbar.left",
|
||||
"statusbar.right",
|
||||
"empty.state",
|
||||
"create.source",
|
||||
"settings.plugin"
|
||||
],
|
||||
"layers": [
|
||||
"layer.background",
|
||||
"layer.overlay"
|
||||
],
|
||||
"layoutOptions": [
|
||||
"sidebarPosition=left",
|
||||
"sidebarPosition=right",
|
||||
"sidebarMode=full",
|
||||
"sidebarMode=rail",
|
||||
"sidebarMode=floating",
|
||||
"density=compact",
|
||||
"density=regular",
|
||||
"density=comfortable",
|
||||
"titlebar=standard",
|
||||
"titlebar=compact"
|
||||
],
|
||||
"icons": [
|
||||
"start",
|
||||
"stop",
|
||||
"force-stop",
|
||||
"restart",
|
||||
"suspend",
|
||||
"resume",
|
||||
"new-vm",
|
||||
"settings",
|
||||
"plugin",
|
||||
"folder",
|
||||
"logs",
|
||||
"screenshot",
|
||||
"fullscreen",
|
||||
"window",
|
||||
"snapshot",
|
||||
"clone",
|
||||
"delete",
|
||||
"info",
|
||||
"warning",
|
||||
"error",
|
||||
"vm.state.running",
|
||||
"vm.state.stopped",
|
||||
"vm.state.suspended",
|
||||
"vm.state.busy",
|
||||
"vm.state.error"
|
||||
],
|
||||
"viewLocations": [],
|
||||
"sdkEvents": [
|
||||
"vm.stateChanged",
|
||||
"task.started",
|
||||
"task.progress",
|
||||
"task.finished",
|
||||
"toast.shown",
|
||||
"view.changed"
|
||||
],
|
||||
"tokens": [
|
||||
"--font-sans",
|
||||
"--font-cjk",
|
||||
"--font-mono",
|
||||
"--body-lh",
|
||||
"--heading-tracking",
|
||||
"--fs-11",
|
||||
"--fs-12",
|
||||
"--fs-13",
|
||||
@@ -86,44 +223,20 @@
|
||||
"--sidebar-w",
|
||||
"--page-max"
|
||||
],
|
||||
"parts": [
|
||||
"rg-p-shell",
|
||||
"rg-p-titlebar",
|
||||
"rg-p-brand",
|
||||
"rg-p-workspace",
|
||||
"rg-p-sidebar",
|
||||
"rg-p-sidebar-head",
|
||||
"rg-p-nav",
|
||||
"rg-p-main",
|
||||
"rg-p-vm-page",
|
||||
"rg-p-vm-header",
|
||||
"rg-p-vm-preview",
|
||||
"rg-p-vm-summary",
|
||||
"rg-p-statusbar",
|
||||
"rg-p-logpanel",
|
||||
"rg-p-settings",
|
||||
"rg-p-empty"
|
||||
],
|
||||
"stateAttrs": [
|
||||
"data-theme",
|
||||
"data-motion",
|
||||
"data-view",
|
||||
"data-vm-state",
|
||||
"data-busy",
|
||||
"data-has-error",
|
||||
"data-sidebar-collapsed",
|
||||
"data-safe-mode"
|
||||
],
|
||||
"slots": [
|
||||
"sidebar.footer",
|
||||
"statusbar.right",
|
||||
"vm.toolbar",
|
||||
"vm.card",
|
||||
"settings.plugin",
|
||||
"vm.preview.tl",
|
||||
"vm.preview.tr",
|
||||
"vm.preview.bl",
|
||||
"vm.preview.br",
|
||||
"empty.state"
|
||||
]
|
||||
"experimental": {
|
||||
"parts": [],
|
||||
"stateAttrs": [],
|
||||
"itemStates": [],
|
||||
"slots": [],
|
||||
"layers": [],
|
||||
"layoutOptions": [],
|
||||
"icons": [],
|
||||
"viewLocations": [
|
||||
"sidebar",
|
||||
"vm.tab",
|
||||
"settings",
|
||||
"dialog"
|
||||
],
|
||||
"sdkEvents": []
|
||||
}
|
||||
}
|
||||
Vendored
+123
-5
@@ -1,13 +1,19 @@
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
import {reims} from '../models';
|
||||
import {plugin} from '../models';
|
||||
import {version} from '../models';
|
||||
import {app} from '../models';
|
||||
import {driver} from '../models';
|
||||
import {plugin} from '../models';
|
||||
import {runtime} from '../models';
|
||||
import {installer} from '../models';
|
||||
import {http} from '../models';
|
||||
import {dataroot} from '../models';
|
||||
import {opencore} from '../models';
|
||||
|
||||
export function AddVMSharedFolder(arg1:string,arg2:string):Promise<app.SharedFolderSettings>;
|
||||
|
||||
export function ApplyVMSMBIOS(arg1:string,arg2:opencore.SMBIOSIdentity):Promise<opencore.SMBIOSIdentity>;
|
||||
|
||||
export function ApplyVMSettings(arg1:reims.SetOpts):Promise<void>;
|
||||
|
||||
@@ -15,6 +21,8 @@ export function AttachGuestTools(arg1:string):Promise<void>;
|
||||
|
||||
export function AttachInstaller(arg1:string,arg2:string):Promise<string>;
|
||||
|
||||
export function BrowsePluginMarket(arg1:string,arg2:string,arg3:boolean,arg4:boolean):Promise<plugin.MarketBrowseResult>;
|
||||
|
||||
export function CanOpenQQGroup():Promise<boolean>;
|
||||
|
||||
export function CancelTask(arg1:string):Promise<void>;
|
||||
@@ -25,14 +33,30 @@ export function CheckDataRoot(arg1:string):Promise<app.DataRootCheck>;
|
||||
|
||||
export function CloneVMCoW(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function CompactVMDisk(arg1:string):Promise<reims.DiskCompactResult>;
|
||||
export function CloneVMCoWWithDriver(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
|
||||
export function CompactVMDisk(arg1:string):Promise<driver.DiskCompactResult>;
|
||||
|
||||
export function CompactVMDiskWithDriver(arg1:string,arg2:string):Promise<driver.DiskCompactResult>;
|
||||
|
||||
export function OptimizeVMDisk(arg1:string):Promise<driver.DiskCompactResult>;
|
||||
|
||||
export function OptimizeVMDiskWithDriver(arg1:string,arg2:string):Promise<driver.DiskCompactResult>;
|
||||
|
||||
export function OpenWindowsSecurityExclusions():Promise<void>;
|
||||
|
||||
export function GetDefenderExclusionCommand():Promise<string>;
|
||||
|
||||
export function CompleteSetup(arg1:string):Promise<void>;
|
||||
|
||||
export function CopyVMScreenshot(arg1:string):Promise<void>;
|
||||
|
||||
export function CopyVMScreenshotWithDriver(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function CreateSnapshot(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function CreateSnapshotWithDriver(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
|
||||
export function CreateVM(arg1:reims.CreateOpts):Promise<void>;
|
||||
|
||||
export function CreateVMWithDriver(arg1:driver.CreateRequest):Promise<void>;
|
||||
@@ -43,8 +67,12 @@ export function DeleteInstaller(arg1:string):Promise<void>;
|
||||
|
||||
export function DeleteSnapshot(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function DeleteSnapshotWithDriver(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
|
||||
export function DeleteVM(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
export function DeleteVMWithDriver(arg1:string,arg2:string,arg3:boolean):Promise<void>;
|
||||
|
||||
export function DeliverFileToGuest(arg1:string):Promise<string>;
|
||||
|
||||
export function DeliverPathsToGuest(arg1:string,arg2:Array<string>):Promise<Array<string>>;
|
||||
@@ -53,6 +81,10 @@ export function DetachGuestTools(arg1:string):Promise<void>;
|
||||
|
||||
export function DisablePlugin(arg1:string):Promise<void>;
|
||||
|
||||
export function DiscardSuspend(arg1:string):Promise<void>;
|
||||
|
||||
export function DiscardSuspendWithDriver(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function DismissTask(arg1:string):Promise<void>;
|
||||
|
||||
export function DoctorPlugin(arg1:string):Promise<Array<plugin.DoctorFinding>>;
|
||||
@@ -65,6 +97,8 @@ export function DownloadInstaller(arg1:string):Promise<string>;
|
||||
|
||||
export function EjectInstaller(arg1:string):Promise<void>;
|
||||
|
||||
export function EjectInstallerWithDriver(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function EnablePlugin(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
export function EnableWHPX():Promise<void>;
|
||||
@@ -73,12 +107,22 @@ export function EnterRecovery(arg1:string):Promise<void>;
|
||||
|
||||
export function ExportDiagnostics(arg1:string):Promise<string>;
|
||||
|
||||
export function ExportDiagnosticsWithDriver(arg1:string,arg2:string):Promise<string>;
|
||||
|
||||
export function FinishInstall(arg1:string):Promise<void>;
|
||||
|
||||
export function FocusVMWindow(arg1:string):Promise<void>;
|
||||
|
||||
export function FocusVMWindowWithDriver(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function ForceQuitApp():Promise<void>;
|
||||
|
||||
export function GenerateVMSMBIOS(arg1:string):Promise<opencore.SMBIOSIdentity>;
|
||||
|
||||
export function GetActiveTheme():Promise<plugin.ActiveThemePayload>;
|
||||
|
||||
export function GetLicenseTexts():Promise<app.LicenseTexts>;
|
||||
|
||||
export function GetPluginSettings(arg1:string,arg2:string):Promise<Record<string, any>>;
|
||||
|
||||
export function GetPluginUIContributions():Promise<app.PluginUIContributions>;
|
||||
@@ -91,24 +135,44 @@ export function GetTasks():Promise<Array<app.Task>>;
|
||||
|
||||
export function GetVMAffinity(arg1:string):Promise<app.VMAffinityStatus>;
|
||||
|
||||
export function GetVMAffinityWithDriver(arg1:string,arg2:string):Promise<app.VMAffinityStatus>;
|
||||
|
||||
export function GetVMKeymap(arg1:string):Promise<app.VMKeymapStatus>;
|
||||
|
||||
export function GetVMDetail(arg1:string):Promise<reims.VMDetail>;
|
||||
|
||||
export function GetVMDriveShareSettings(arg1:string):Promise<app.DriveShareSettings>;
|
||||
|
||||
export function GetVMInfo(arg1:string,arg2:string):Promise<driver.VMInfo>;
|
||||
|
||||
export function GetVMMacOS(arg1:string):Promise<string>;
|
||||
|
||||
export function GetVMNote(arg1:string):Promise<string>;
|
||||
|
||||
export function GetVMPluginSettings(arg1:string):Promise<Record<string, Record<string, any>>>;
|
||||
|
||||
export function GetVMSMBIOS(arg1:string):Promise<opencore.SMBIOSIdentity>;
|
||||
|
||||
export function GetVMSSHUser(arg1:string):Promise<string>;
|
||||
|
||||
export function GetVMSSHUserWithDriver(arg1:string,arg2:string):Promise<string>;
|
||||
|
||||
export function GetVMSharedFolderSettings(arg1:string):Promise<app.SharedFolderSettings>;
|
||||
|
||||
export function GetVMStats(arg1:string):Promise<app.VMStats>;
|
||||
|
||||
export function GetVMStatsWithDriver(arg1:string,arg2:string):Promise<app.VMStats>;
|
||||
|
||||
export function GetVMThumbnail(arg1:string):Promise<app.VMThumbnail>;
|
||||
|
||||
export function GetVMThumbnailWithDriver(arg1:string,arg2:string):Promise<app.VMThumbnail>;
|
||||
|
||||
export function InspectPluginArchive(arg1:string):Promise<plugin.ScanReport>;
|
||||
|
||||
export function InstallAppUpdate():Promise<void>;
|
||||
|
||||
export function InstallMarketPlugin(arg1:string,arg2:boolean):Promise<plugin.PluginInfo>;
|
||||
|
||||
export function InstallPluginArchive(arg1:string):Promise<plugin.PluginInfo>;
|
||||
|
||||
export function InstallRuntimeArchive(arg1:string):Promise<runtime.Installed>;
|
||||
@@ -131,7 +195,9 @@ export function ListRemoteRuntimes():Promise<Array<runtime.Remote>>;
|
||||
|
||||
export function ListRuntimeKinds():Promise<Array<runtime.KindSpec>>;
|
||||
|
||||
export function ListSnapshots(arg1:string):Promise<Array<reims.DiskSnapshot>>;
|
||||
export function ListSnapshots(arg1:string):Promise<Array<driver.DiskSnapshot>>;
|
||||
|
||||
export function ListSnapshotsWithDriver(arg1:string,arg2:string):Promise<Array<driver.DiskSnapshot>>;
|
||||
|
||||
export function OpenProcessorScheduling():Promise<void>;
|
||||
|
||||
@@ -139,6 +205,8 @@ export function OpenQQGroup():Promise<void>;
|
||||
|
||||
export function OpenSSHTerminal(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function OpenSSHTerminalWithDriver(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
|
||||
export function OpenSharedFolder(arg1:string):Promise<void>;
|
||||
|
||||
export function OpenURL(arg1:string):Promise<void>;
|
||||
@@ -147,8 +215,12 @@ export function OpenVMFolder(arg1:string):Promise<void>;
|
||||
|
||||
export function OpenVSCodeSSH(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function OpenVSCodeSSHWithDriver(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
|
||||
export function PanelBridgeCall(arg1:string,arg2:string,arg3:Record<string, any>):Promise<any>;
|
||||
|
||||
export function PeekPluginMarket(arg1:string,arg2:string):Promise<plugin.MarketBrowseResult>;
|
||||
|
||||
export function PickDirectory(arg1:string):Promise<string>;
|
||||
|
||||
export function PickFile(arg1:string,arg2:string):Promise<string>;
|
||||
@@ -163,20 +235,42 @@ export function ReadPluginLog(arg1:string):Promise<string>;
|
||||
|
||||
export function ReadVMLogs(arg1:string,arg2:boolean):Promise<string>;
|
||||
|
||||
export function ReadVMLogsWithDriver(arg1:string,arg2:string,arg3:boolean):Promise<string>;
|
||||
|
||||
export function RemovePlugin(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
export function RemoveRuntime(arg1:string):Promise<void>;
|
||||
|
||||
export function RemoveVMSharedFolder(arg1:string,arg2:string):Promise<app.SharedFolderSettings>;
|
||||
|
||||
export function ReopenDataRoot(arg1:boolean):Promise<dataroot.Status>;
|
||||
|
||||
export function RequestClose():Promise<void>;
|
||||
|
||||
export function ResizeVMDisk(arg1:string,arg2:string):Promise<reims.DiskResizeResult>;
|
||||
export function ResizeVMDisk(arg1:string,arg2:string):Promise<driver.DiskResizeResult>;
|
||||
|
||||
export function ResizeVMDiskWithDriver(arg1:string,arg2:string,arg3:string):Promise<driver.DiskResizeResult>;
|
||||
|
||||
export function RestartVM(arg1:string):Promise<void>;
|
||||
|
||||
export function RestartVMWithDriver(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function RestoreSnapshot(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function RestoreSnapshotWithDriver(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
|
||||
export function ResumeVM(arg1:string):Promise<void>;
|
||||
|
||||
export function ResumeVMWithDriver(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function SaveCustomThemeScheme(arg1:plugin.CustomThemeScheme):Promise<void>;
|
||||
|
||||
export function ScanInstalledPlugin(arg1:string):Promise<plugin.ScanReport>;
|
||||
|
||||
export function SetActiveTheme(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function SetAppUpdateChannel(arg1:string):Promise<void>;
|
||||
|
||||
export function SetAutoPinPCores(arg1:boolean):Promise<void>;
|
||||
|
||||
export function SetDataRoot(arg1:string):Promise<void>;
|
||||
@@ -191,26 +285,48 @@ export function SetPluginSettings(arg1:string,arg2:string,arg3:Record<string, an
|
||||
|
||||
export function SetRuntimeChannel(arg1:string):Promise<void>;
|
||||
|
||||
export function SetRuntimeSource(arg1:string):Promise<void>;
|
||||
export function SetSyncHostMemorySMBIOS(arg1:boolean):Promise<void>;
|
||||
|
||||
export function SetVMAffinity(arg1:string,arg2:app.VMAffinityUpdate):Promise<app.VMAffinityStatus>;
|
||||
|
||||
export function SetVMAffinityWithDriver(arg1:string,arg2:string,arg3:app.VMAffinityUpdate):Promise<app.VMAffinityStatus>;
|
||||
|
||||
export function SetVMKeymap(arg1:string,arg2:app.VMKeymapUpdate):Promise<app.VMKeymapStatus>;
|
||||
|
||||
export function SetVMDriveShareSettings(arg1:string,arg2:boolean,arg3:Array<string>):Promise<app.DriveShareSettings>;
|
||||
|
||||
export function SetVMNote(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function SetVMSSHUser(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function SetVMSSHUserWithDriver(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
|
||||
export function SetVMSharedFolderMode(arg1:string,arg2:string,arg3:string):Promise<app.SharedFolderSettings>;
|
||||
|
||||
export function ShowMainWindow():Promise<void>;
|
||||
|
||||
export function StartVM(arg1:string):Promise<void>;
|
||||
|
||||
export function StartVMWithDriver(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function StopVM(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
export function StopVMWithDriver(arg1:string,arg2:string,arg3:boolean):Promise<void>;
|
||||
|
||||
export function SuggestDataRoots():Promise<Array<app.DataRootChoice>>;
|
||||
|
||||
export function SuggestLanguagePack():Promise<plugin.MarketCatalogItem>;
|
||||
|
||||
export function SuspendVM(arg1:string):Promise<void>;
|
||||
|
||||
export function SuspendVMWithDriver(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function ToggleBorderless(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
export function ToggleVMFullscreen(arg1:string):Promise<boolean>;
|
||||
|
||||
export function ToggleVMFullscreenWithDriver(arg1:string,arg2:string):Promise<boolean>;
|
||||
|
||||
export function TypeClipboard(arg1:string):Promise<number>;
|
||||
|
||||
export function TypeText(arg1:string,arg2:string):Promise<number>;
|
||||
@@ -224,3 +340,5 @@ export function ValidateCreate(arg1:reims.CreateOpts):Promise<Array<reims.Valida
|
||||
export function ValidateSet(arg1:reims.SetOpts):Promise<Array<reims.ValidationIssue>>;
|
||||
|
||||
export function WriteSSHConfig(arg1:string,arg2:string):Promise<string>;
|
||||
|
||||
export function WriteSSHConfigWithDriver(arg1:string,arg2:string,arg3:string):Promise<string>;
|
||||
@@ -2,6 +2,14 @@
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
export function AddVMSharedFolder(arg1, arg2) {
|
||||
return window['go']['app']['App']['AddVMSharedFolder'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function ApplyVMSMBIOS(arg1, arg2) {
|
||||
return window['go']['app']['App']['ApplyVMSMBIOS'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function ApplyVMSettings(arg1) {
|
||||
return window['go']['app']['App']['ApplyVMSettings'](arg1);
|
||||
}
|
||||
@@ -14,6 +22,10 @@ export function AttachInstaller(arg1, arg2) {
|
||||
return window['go']['app']['App']['AttachInstaller'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function BrowsePluginMarket(arg1, arg2, arg3, arg4) {
|
||||
return window['go']['app']['App']['BrowsePluginMarket'](arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
export function CanOpenQQGroup() {
|
||||
return window['go']['app']['App']['CanOpenQQGroup']();
|
||||
}
|
||||
@@ -34,10 +46,34 @@ export function CloneVMCoW(arg1, arg2) {
|
||||
return window['go']['app']['App']['CloneVMCoW'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function CloneVMCoWWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['CloneVMCoWWithDriver'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function CompactVMDisk(arg1) {
|
||||
return window['go']['app']['App']['CompactVMDisk'](arg1);
|
||||
}
|
||||
|
||||
export function CompactVMDiskWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['CompactVMDiskWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function OptimizeVMDisk(arg1) {
|
||||
return window['go']['app']['App']['OptimizeVMDisk'](arg1);
|
||||
}
|
||||
|
||||
export function OptimizeVMDiskWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['OptimizeVMDiskWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function OpenWindowsSecurityExclusions() {
|
||||
return window['go']['app']['App']['OpenWindowsSecurityExclusions']();
|
||||
}
|
||||
|
||||
export function GetDefenderExclusionCommand() {
|
||||
return window['go']['app']['App']['GetDefenderExclusionCommand']();
|
||||
}
|
||||
|
||||
export function CompleteSetup(arg1) {
|
||||
return window['go']['app']['App']['CompleteSetup'](arg1);
|
||||
}
|
||||
@@ -46,10 +82,18 @@ export function CopyVMScreenshot(arg1) {
|
||||
return window['go']['app']['App']['CopyVMScreenshot'](arg1);
|
||||
}
|
||||
|
||||
export function CopyVMScreenshotWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['CopyVMScreenshotWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function CreateSnapshot(arg1, arg2) {
|
||||
return window['go']['app']['App']['CreateSnapshot'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function CreateSnapshotWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['CreateSnapshotWithDriver'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function CreateVM(arg1) {
|
||||
return window['go']['app']['App']['CreateVM'](arg1);
|
||||
}
|
||||
@@ -70,10 +114,18 @@ export function DeleteSnapshot(arg1, arg2) {
|
||||
return window['go']['app']['App']['DeleteSnapshot'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function DeleteSnapshotWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['DeleteSnapshotWithDriver'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function DeleteVM(arg1, arg2) {
|
||||
return window['go']['app']['App']['DeleteVM'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function DeleteVMWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['DeleteVMWithDriver'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function DeliverFileToGuest(arg1) {
|
||||
return window['go']['app']['App']['DeliverFileToGuest'](arg1);
|
||||
}
|
||||
@@ -90,6 +142,14 @@ export function DisablePlugin(arg1) {
|
||||
return window['go']['app']['App']['DisablePlugin'](arg1);
|
||||
}
|
||||
|
||||
export function DiscardSuspend(arg1) {
|
||||
return window['go']['app']['App']['DiscardSuspend'](arg1);
|
||||
}
|
||||
|
||||
export function DiscardSuspendWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['DiscardSuspendWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function DismissTask(arg1) {
|
||||
return window['go']['app']['App']['DismissTask'](arg1);
|
||||
}
|
||||
@@ -114,6 +174,10 @@ export function EjectInstaller(arg1) {
|
||||
return window['go']['app']['App']['EjectInstaller'](arg1);
|
||||
}
|
||||
|
||||
export function EjectInstallerWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['EjectInstallerWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function EnablePlugin(arg1, arg2) {
|
||||
return window['go']['app']['App']['EnablePlugin'](arg1, arg2);
|
||||
}
|
||||
@@ -130,6 +194,10 @@ export function ExportDiagnostics(arg1) {
|
||||
return window['go']['app']['App']['ExportDiagnostics'](arg1);
|
||||
}
|
||||
|
||||
export function ExportDiagnosticsWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['ExportDiagnosticsWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function FinishInstall(arg1) {
|
||||
return window['go']['app']['App']['FinishInstall'](arg1);
|
||||
}
|
||||
@@ -138,10 +206,26 @@ export function FocusVMWindow(arg1) {
|
||||
return window['go']['app']['App']['FocusVMWindow'](arg1);
|
||||
}
|
||||
|
||||
export function FocusVMWindowWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['FocusVMWindowWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function ForceQuitApp() {
|
||||
return window['go']['app']['App']['ForceQuitApp']();
|
||||
}
|
||||
|
||||
export function GenerateVMSMBIOS(arg1) {
|
||||
return window['go']['app']['App']['GenerateVMSMBIOS'](arg1);
|
||||
}
|
||||
|
||||
export function GetActiveTheme() {
|
||||
return window['go']['app']['App']['GetActiveTheme']();
|
||||
}
|
||||
|
||||
export function GetLicenseTexts() {
|
||||
return window['go']['app']['App']['GetLicenseTexts']();
|
||||
}
|
||||
|
||||
export function GetPluginSettings(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetPluginSettings'](arg1, arg2);
|
||||
}
|
||||
@@ -166,6 +250,14 @@ export function GetVMAffinity(arg1) {
|
||||
return window['go']['app']['App']['GetVMAffinity'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMAffinityWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetVMAffinityWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function GetVMKeymap(arg1) {
|
||||
return window['go']['app']['App']['GetVMKeymap'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMDetail(arg1) {
|
||||
return window['go']['app']['App']['GetVMDetail'](arg1);
|
||||
}
|
||||
@@ -174,6 +266,10 @@ export function GetVMDriveShareSettings(arg1) {
|
||||
return window['go']['app']['App']['GetVMDriveShareSettings'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMInfo(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetVMInfo'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function GetVMMacOS(arg1) {
|
||||
return window['go']['app']['App']['GetVMMacOS'](arg1);
|
||||
}
|
||||
@@ -186,22 +282,50 @@ export function GetVMPluginSettings(arg1) {
|
||||
return window['go']['app']['App']['GetVMPluginSettings'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMSMBIOS(arg1) {
|
||||
return window['go']['app']['App']['GetVMSMBIOS'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMSSHUser(arg1) {
|
||||
return window['go']['app']['App']['GetVMSSHUser'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMSSHUserWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetVMSSHUserWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function GetVMSharedFolderSettings(arg1) {
|
||||
return window['go']['app']['App']['GetVMSharedFolderSettings'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMStats(arg1) {
|
||||
return window['go']['app']['App']['GetVMStats'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMStatsWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetVMStatsWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function GetVMThumbnail(arg1) {
|
||||
return window['go']['app']['App']['GetVMThumbnail'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMThumbnailWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetVMThumbnailWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function InspectPluginArchive(arg1) {
|
||||
return window['go']['app']['App']['InspectPluginArchive'](arg1);
|
||||
}
|
||||
|
||||
export function InstallAppUpdate() {
|
||||
return window['go']['app']['App']['InstallAppUpdate']();
|
||||
}
|
||||
|
||||
export function InstallMarketPlugin(arg1, arg2) {
|
||||
return window['go']['app']['App']['InstallMarketPlugin'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function InstallPluginArchive(arg1) {
|
||||
return window['go']['app']['App']['InstallPluginArchive'](arg1);
|
||||
}
|
||||
@@ -250,6 +374,10 @@ export function ListSnapshots(arg1) {
|
||||
return window['go']['app']['App']['ListSnapshots'](arg1);
|
||||
}
|
||||
|
||||
export function ListSnapshotsWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['ListSnapshotsWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function OpenProcessorScheduling() {
|
||||
return window['go']['app']['App']['OpenProcessorScheduling']();
|
||||
}
|
||||
@@ -262,6 +390,10 @@ export function OpenSSHTerminal(arg1, arg2) {
|
||||
return window['go']['app']['App']['OpenSSHTerminal'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function OpenSSHTerminalWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['OpenSSHTerminalWithDriver'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function OpenSharedFolder(arg1) {
|
||||
return window['go']['app']['App']['OpenSharedFolder'](arg1);
|
||||
}
|
||||
@@ -278,10 +410,18 @@ export function OpenVSCodeSSH(arg1, arg2) {
|
||||
return window['go']['app']['App']['OpenVSCodeSSH'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function OpenVSCodeSSHWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['OpenVSCodeSSHWithDriver'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function PanelBridgeCall(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['PanelBridgeCall'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function PeekPluginMarket(arg1, arg2) {
|
||||
return window['go']['app']['App']['PeekPluginMarket'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function PickDirectory(arg1) {
|
||||
return window['go']['app']['App']['PickDirectory'](arg1);
|
||||
}
|
||||
@@ -310,10 +450,26 @@ export function ReadVMLogs(arg1, arg2) {
|
||||
return window['go']['app']['App']['ReadVMLogs'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function ReadVMLogsWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['ReadVMLogsWithDriver'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function RemovePlugin(arg1, arg2) {
|
||||
return window['go']['app']['App']['RemovePlugin'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function RemoveRuntime(arg1) {
|
||||
return window['go']['app']['App']['RemoveRuntime'](arg1);
|
||||
}
|
||||
|
||||
export function RemoveVMSharedFolder(arg1, arg2) {
|
||||
return window['go']['app']['App']['RemoveVMSharedFolder'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function ReopenDataRoot(arg1) {
|
||||
return window['go']['app']['App']['ReopenDataRoot'](arg1);
|
||||
}
|
||||
|
||||
export function RequestClose() {
|
||||
return window['go']['app']['App']['RequestClose']();
|
||||
}
|
||||
@@ -322,22 +478,50 @@ export function ResizeVMDisk(arg1, arg2) {
|
||||
return window['go']['app']['App']['ResizeVMDisk'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function ResizeVMDiskWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['ResizeVMDiskWithDriver'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function RestartVM(arg1) {
|
||||
return window['go']['app']['App']['RestartVM'](arg1);
|
||||
}
|
||||
|
||||
export function RestartVMWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['RestartVMWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function RestoreSnapshot(arg1, arg2) {
|
||||
return window['go']['app']['App']['RestoreSnapshot'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function RestoreSnapshotWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['RestoreSnapshotWithDriver'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function ResumeVM(arg1) {
|
||||
return window['go']['app']['App']['ResumeVM'](arg1);
|
||||
}
|
||||
|
||||
export function ResumeVMWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['ResumeVMWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function SaveCustomThemeScheme(arg1) {
|
||||
return window['go']['app']['App']['SaveCustomThemeScheme'](arg1);
|
||||
}
|
||||
|
||||
export function ScanInstalledPlugin(arg1) {
|
||||
return window['go']['app']['App']['ScanInstalledPlugin'](arg1);
|
||||
}
|
||||
|
||||
export function SetActiveTheme(arg1, arg2) {
|
||||
return window['go']['app']['App']['SetActiveTheme'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function SetAppUpdateChannel(arg1) {
|
||||
return window['go']['app']['App']['SetAppUpdateChannel'](arg1);
|
||||
}
|
||||
|
||||
export function SetAutoPinPCores(arg1) {
|
||||
return window['go']['app']['App']['SetAutoPinPCores'](arg1);
|
||||
}
|
||||
@@ -366,14 +550,22 @@ export function SetRuntimeChannel(arg1) {
|
||||
return window['go']['app']['App']['SetRuntimeChannel'](arg1);
|
||||
}
|
||||
|
||||
export function SetRuntimeSource(arg1) {
|
||||
return window['go']['app']['App']['SetRuntimeSource'](arg1);
|
||||
export function SetSyncHostMemorySMBIOS(arg1) {
|
||||
return window['go']['app']['App']['SetSyncHostMemorySMBIOS'](arg1);
|
||||
}
|
||||
|
||||
export function SetVMAffinity(arg1, arg2) {
|
||||
return window['go']['app']['App']['SetVMAffinity'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function SetVMAffinityWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['SetVMAffinityWithDriver'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function SetVMKeymap(arg1, arg2) {
|
||||
return window['go']['app']['App']['SetVMKeymap'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function SetVMDriveShareSettings(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['SetVMDriveShareSettings'](arg1, arg2, arg3);
|
||||
}
|
||||
@@ -386,6 +578,14 @@ export function SetVMSSHUser(arg1, arg2) {
|
||||
return window['go']['app']['App']['SetVMSSHUser'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function SetVMSSHUserWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['SetVMSSHUserWithDriver'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function SetVMSharedFolderMode(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['SetVMSharedFolderMode'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function ShowMainWindow() {
|
||||
return window['go']['app']['App']['ShowMainWindow']();
|
||||
}
|
||||
@@ -394,18 +594,46 @@ export function StartVM(arg1) {
|
||||
return window['go']['app']['App']['StartVM'](arg1);
|
||||
}
|
||||
|
||||
export function StartVMWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['StartVMWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function StopVM(arg1, arg2) {
|
||||
return window['go']['app']['App']['StopVM'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function StopVMWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['StopVMWithDriver'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function SuggestDataRoots() {
|
||||
return window['go']['app']['App']['SuggestDataRoots']();
|
||||
}
|
||||
|
||||
export function SuggestLanguagePack() {
|
||||
return window['go']['app']['App']['SuggestLanguagePack']();
|
||||
}
|
||||
|
||||
export function SuspendVM(arg1) {
|
||||
return window['go']['app']['App']['SuspendVM'](arg1);
|
||||
}
|
||||
|
||||
export function SuspendVMWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['SuspendVMWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function ToggleBorderless(arg1, arg2) {
|
||||
return window['go']['app']['App']['ToggleBorderless'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function ToggleVMFullscreen(arg1) {
|
||||
return window['go']['app']['App']['ToggleVMFullscreen'](arg1);
|
||||
}
|
||||
|
||||
export function ToggleVMFullscreenWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['ToggleVMFullscreenWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function TypeClipboard(arg1) {
|
||||
return window['go']['app']['App']['TypeClipboard'](arg1);
|
||||
}
|
||||
@@ -433,3 +661,7 @@ export function ValidateSet(arg1) {
|
||||
export function WriteSSHConfig(arg1, arg2) {
|
||||
return window['go']['app']['App']['WriteSSHConfig'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function WriteSSHConfigWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['WriteSSHConfigWithDriver'](arg1, arg2, arg3);
|
||||
}
|
||||
+978
-79
File diff suppressed because it is too large.
Load diff
@@ -4,6 +4,7 @@ go 1.26.0
|
||||
|
||||
require (
|
||||
github.com/klauspost/compress v1.20.5
|
||||
github.com/pelletier/go-toml/v2 v2.4.3
|
||||
github.com/ulikunitz/xz v0.5.17
|
||||
github.com/wailsapp/wails/v2 v2.17.1
|
||||
golang.org/x/net v0.60.0
|
||||
|
||||
@@ -39,6 +39,8 @@ github.com/mattn/go-colorable v0.1.15 h1:+u9SLTRGnXv73cEsnsmoZBom+dMU88B2M0aDcWy
|
||||
github.com/mattn/go-colorable v0.1.15/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4=
|
||||
github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
|
||||
github.com/pelletier/go-toml/v2 v2.4.3 h1:GTRvJQutkOSftxIFD5xw9aepkYNuPWmVJpffdDPYVpY=
|
||||
github.com/pelletier/go-toml/v2 v2.4.3/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
|
||||
Loaded 100 of 517 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user