Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc534b72b4 | ||
|
|
6e7c5e602a | ||
|
|
9bd4ac67ef | ||
|
|
2b8ea23074 | ||
|
|
371eb11629 | ||
|
|
655f015038 | ||
|
|
e8c9186a76 | ||
|
|
de523c5323 |
No files matched your search
@@ -2,6 +2,18 @@
|
||||
|
||||
本文件只记录 Reims-Go 桌面应用的变化。便携运行时(`runtime-*`)的版本另见 [Releases](https://github.com/Nwflower/Reims-Go/releases)。
|
||||
|
||||
## 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
|
||||
|
||||
### 新功能
|
||||
|
||||
@@ -390,7 +390,7 @@ UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`
|
||||
|
||||
| 入口 | 内容 |
|
||||
| :--- | :--- |
|
||||
| CLI | `reims-go plugin list / search / install <zip\|id> / update [id] / 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>` |
|
||||
| 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` 展示驱动或插件提供的键值信息 |
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "reims-go-frontend",
|
||||
"private": true,
|
||||
"version": "0.2.9",
|
||||
"version": "0.2.10",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1 +1 @@
|
||||
640cefb23cef4711cf51530e8a87140c
|
||||
58f4fafea894c5f7c1c6ebefde51e110
|
||||
@@ -46,6 +46,7 @@ export const Sidebar: React.FC<Props> = ({
|
||||
}) => {
|
||||
const tr = (k: I18nKey) => t(locale, k)
|
||||
const listRef = useRef<HTMLDivElement>(null)
|
||||
const ctxOpenedByPointerRef = useRef(false)
|
||||
const ids = [...vms.map((v) => v.name), INSTALLERS_ID, PLUGINS_ID, HOST_ID, SETTINGS_ID, ABOUT_ID]
|
||||
|
||||
// Listbox keyboard model: ↑/↓/Home/End move selection and focus together.
|
||||
@@ -129,9 +130,26 @@ export const Sidebar: React.FC<Props> = ({
|
||||
if (!onVMContextAction) return trigger
|
||||
return (
|
||||
<Ctx.Root key={vm.name}>
|
||||
<Ctx.Trigger asChild>{trigger}</Ctx.Trigger>
|
||||
<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"
|
||||
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')}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as Menu from '@radix-ui/react-dropdown-menu'
|
||||
import { Check, PanelLeft } from 'lucide-react'
|
||||
import React, { useState } from 'react'
|
||||
import React, { useRef, useState } from 'react'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { Locale } from '../types'
|
||||
import { Tip } from '../ui/controls'
|
||||
@@ -10,6 +10,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
|
||||
@@ -42,7 +47,17 @@ 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'
|
||||
@@ -64,19 +79,111 @@ 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
|
||||
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 titlebar-menu-content${indented ? ' menu-indented' : ''}`}
|
||||
data-menubar-switch={menuState.id === id && 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 target = e.target as Node | null
|
||||
if (target && navRef.current?.contains(target)) {
|
||||
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 +192,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,7 +203,7 @@ 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' })}
|
||||
|
||||
@@ -160,12 +160,17 @@ export const VMPage: React.FC<Props> = ({
|
||||
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,6 +188,12 @@ 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)
|
||||
}, [name])
|
||||
useEffect(() => {
|
||||
let live = true
|
||||
api.GetVMSSHUser(name).then((u) => { if (live) setSshUser(u ?? '') }).catch(() => { if (live) setSshUser('') })
|
||||
@@ -337,10 +348,26 @@ 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
|
||||
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"
|
||||
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>
|
||||
@@ -351,11 +378,27 @@ export const VMPage: React.FC<Props> = ({
|
||||
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 && (
|
||||
@@ -841,16 +884,53 @@ 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
|
||||
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 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.Content
|
||||
className="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" onSelect={writeSSHConfig}>
|
||||
<FileCode2 size={14} /> {tr('sshWriteConfig')}
|
||||
</Menu.Item>
|
||||
|
||||
@@ -34,7 +34,7 @@ button { font: inherit; color: inherit; touch-action: manipulation; }
|
||||
h1, h2, h3, p { margin: 0; }
|
||||
|
||||
:focus { outline: none; }
|
||||
:focus-visible { box-shadow: var(--focus-ring); border-radius: var(--r-md); }
|
||||
:focus-visible:not(.dialog):not(.menu) { box-shadow: var(--focus-ring); border-radius: var(--r-md); }
|
||||
|
||||
::-webkit-scrollbar { width: 8px; height: 8px; }
|
||||
::-webkit-scrollbar-track { background: transparent; }
|
||||
@@ -80,8 +80,8 @@ h1, h2, h3, p { margin: 0; }
|
||||
}
|
||||
.titlebar-right { display: flex; align-items: center; height: 100%; gap: var(--sp-1); --wails-draggable: no-drag; }
|
||||
|
||||
/* Left of the title bar: sidebar toggle + a small menu bar. Only the controls
|
||||
opt out of window dragging; the gaps between them still move the window. */
|
||||
/* Left of the title bar: sidebar toggle + a small menu bar. Controls and the
|
||||
menu bar group opt out of window dragging so sweeping across menus stays smooth. */
|
||||
.titlebar-left { display: flex; align-items: center; gap: 2px; height: 100%; margin-left: calc(var(--sp-2) * -1); }
|
||||
.titlebar-icon, .titlebar-menu {
|
||||
--wails-draggable: no-drag;
|
||||
@@ -94,7 +94,7 @@ h1, h2, h3, p { margin: 0; }
|
||||
.titlebar-icon:hover, .titlebar-menu:hover { background: var(--surface-hover); color: var(--text); }
|
||||
.titlebar-menu[data-state="open"] { background: var(--surface-active); color: var(--text); }
|
||||
.titlebar-icon:active, .titlebar-menu:active { transform: scale(0.96); }
|
||||
.titlebar-menus { display: flex; align-items: center; gap: 2px; }
|
||||
.titlebar-menus { display: flex; align-items: center; gap: 2px; --wails-draggable: no-drag; }
|
||||
.titlebar-menu-content { min-width: 220px; }
|
||||
|
||||
/* Menu rows with a trailing shortcut, check marks and group labels. */
|
||||
@@ -1312,6 +1312,7 @@ button.status-issue + .status-metric { margin-left: 6px; }
|
||||
.overlay { animation: fade-in var(--dur) var(--ease-out) both; }
|
||||
.dialog { animation: pop-in var(--dur-modal) var(--ease-out) both; }
|
||||
.menu { transform-origin: var(--radix-dropdown-menu-content-transform-origin, top); animation: menu-in 160ms var(--ease-out) both; }
|
||||
.menu[data-menubar-switch="true"] { animation: none; }
|
||||
.tooltip { animation: tip-in 125ms var(--ease-out) both; }
|
||||
.tooltip[data-state="instant-open"] { animation-duration: 0ms; }
|
||||
.pane-anim { display: flex; flex-direction: column; gap: 20px; animation: rise-in var(--dur) var(--ease-out) both; }
|
||||
@@ -1818,6 +1819,6 @@ button.status-issue + .status-metric { margin-left: 6px; }
|
||||
cannot override them even with !important (§5.1, B7/M15). */
|
||||
@layer host-guard {
|
||||
.rg-p-titlebar { --wails-draggable: drag !important; }
|
||||
:focus-visible { box-shadow: var(--focus-ring) !important; }
|
||||
:focus-visible:not(.dialog):not(.menu) { box-shadow: var(--focus-ring) !important; }
|
||||
.icon-btn, .win-btn { min-width: 28px !important; min-height: 28px !important; }
|
||||
}
|
||||
@@ -10,21 +10,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" side={side} sideOffset={6} collisionPadding={8}>
|
||||
{label}
|
||||
{shortcut && <kbd>{shortcut}</kbd>}
|
||||
</RTooltip.Content>
|
||||
</RTooltip.Portal>
|
||||
</RTooltip.Root>
|
||||
)
|
||||
}
|
||||
|
||||
type ButtonVariant = 'secondary' | 'primary' | 'danger' | 'ghost'
|
||||
|
||||
|
||||
@@ -23,10 +23,21 @@ export const Modal: React.FC<Props> = ({ title, subtitle, closeLabel, dismissabl
|
||||
<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.
|
||||
// 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 first = (e.currentTarget as HTMLElement | null)?.querySelector<HTMLElement>('input, select, textarea')
|
||||
if (first) { e.preventDefault(); first.focus() }
|
||||
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 })
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="dialog-head">
|
||||
|
||||
Vendored
+3
-3
@@ -1,10 +1,10 @@
|
||||
// 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';
|
||||
@@ -189,10 +189,10 @@ export function ScanInstalledPlugin(arg1:string):Promise<plugin.ScanReport>;
|
||||
|
||||
export function SetActiveTheme(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function SetAutoPinPCores(arg1:boolean):Promise<void>;
|
||||
|
||||
export function SetAppUpdateChannel(arg1:string):Promise<void>;
|
||||
|
||||
export function SetAutoPinPCores(arg1:boolean):Promise<void>;
|
||||
|
||||
export function SetDataRoot(arg1:string):Promise<void>;
|
||||
|
||||
export function SetGuestPreventSleep(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
@@ -362,6 +362,10 @@ 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);
|
||||
}
|
||||
@@ -386,10 +390,6 @@ export function SetPluginSettings(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['SetPluginSettings'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function SetAppUpdateChannel(arg1) {
|
||||
return window['go']['app']['App']['SetAppUpdateChannel'](arg1);
|
||||
}
|
||||
|
||||
export function SetRuntimeChannel(arg1) {
|
||||
return window['go']['app']['App']['SetRuntimeChannel'](arg1);
|
||||
}
|
||||
|
||||
+422
-244
@@ -1170,6 +1170,46 @@ export namespace plugin {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
export class CapabilityItem {
|
||||
id: string;
|
||||
level: string;
|
||||
title: LocalizedText;
|
||||
summary: LocalizedText;
|
||||
examples?: string[];
|
||||
extra_count?: number;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new CapabilityItem(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.id = source["id"];
|
||||
this.level = source["level"];
|
||||
this.title = this.convertValues(source["title"], LocalizedText);
|
||||
this.summary = this.convertValues(source["summary"], LocalizedText);
|
||||
this.examples = source["examples"];
|
||||
this.extra_count = source["extra_count"];
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (a.slice && a.map) {
|
||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||
} else if ("object" === typeof a) {
|
||||
if (asMap) {
|
||||
for (const key of Object.keys(a)) {
|
||||
a[key] = new classs(a[key]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return new classs(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
export class DoctorFinding {
|
||||
severity: string;
|
||||
@@ -1187,6 +1227,237 @@ export namespace plugin {
|
||||
this.message = source["message"];
|
||||
}
|
||||
}
|
||||
export class Engines {
|
||||
"reims-go"?: string;
|
||||
pluginApi?: string;
|
||||
uiApi?: string;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new Engines(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this["reims-go"] = source["reims-go"];
|
||||
this.pluginApi = source["pluginApi"];
|
||||
this.uiApi = source["uiApi"];
|
||||
}
|
||||
}
|
||||
export class ExecutableFile {
|
||||
path: string;
|
||||
sha256: string;
|
||||
declared: boolean;
|
||||
size_bytes: number;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new ExecutableFile(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.path = source["path"];
|
||||
this.sha256 = source["sha256"];
|
||||
this.declared = source["declared"];
|
||||
this.size_bytes = source["size_bytes"];
|
||||
}
|
||||
}
|
||||
|
||||
export class MarketWithdrawal {
|
||||
id: string;
|
||||
reason: LocalizedText;
|
||||
instead_id?: string;
|
||||
instead_name?: string;
|
||||
withdrawn_at?: string;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new MarketWithdrawal(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.id = source["id"];
|
||||
this.reason = this.convertValues(source["reason"], LocalizedText);
|
||||
this.instead_id = source["instead_id"];
|
||||
this.instead_name = source["instead_name"];
|
||||
this.withdrawn_at = source["withdrawn_at"];
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (a.slice && a.map) {
|
||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||
} else if ("object" === typeof a) {
|
||||
if (asMap) {
|
||||
for (const key of Object.keys(a)) {
|
||||
a[key] = new classs(a[key]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return new classs(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
export class MarketEntry {
|
||||
id: string;
|
||||
version: string;
|
||||
name: LocalizedText;
|
||||
description: LocalizedText;
|
||||
publisher: string;
|
||||
license: string;
|
||||
channel: string;
|
||||
trust: string;
|
||||
kind?: string;
|
||||
tier?: string;
|
||||
homepage?: string;
|
||||
readme_url?: string;
|
||||
engines: Engines;
|
||||
platforms?: string[];
|
||||
permissions?: string[];
|
||||
download_url: string;
|
||||
sha256: string;
|
||||
size_bytes?: number;
|
||||
signer?: string;
|
||||
changelog?: LocalizedText;
|
||||
tags?: string[];
|
||||
updated_at?: string;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new MarketEntry(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.id = source["id"];
|
||||
this.version = source["version"];
|
||||
this.name = this.convertValues(source["name"], LocalizedText);
|
||||
this.description = this.convertValues(source["description"], LocalizedText);
|
||||
this.publisher = source["publisher"];
|
||||
this.license = source["license"];
|
||||
this.channel = source["channel"];
|
||||
this.trust = source["trust"];
|
||||
this.kind = source["kind"];
|
||||
this.tier = source["tier"];
|
||||
this.homepage = source["homepage"];
|
||||
this.readme_url = source["readme_url"];
|
||||
this.engines = this.convertValues(source["engines"], Engines);
|
||||
this.platforms = source["platforms"];
|
||||
this.permissions = source["permissions"];
|
||||
this.download_url = source["download_url"];
|
||||
this.sha256 = source["sha256"];
|
||||
this.size_bytes = source["size_bytes"];
|
||||
this.signer = source["signer"];
|
||||
this.changelog = this.convertValues(source["changelog"], LocalizedText);
|
||||
this.tags = source["tags"];
|
||||
this.updated_at = source["updated_at"];
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (a.slice && a.map) {
|
||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||
} else if ("object" === typeof a) {
|
||||
if (asMap) {
|
||||
for (const key of Object.keys(a)) {
|
||||
a[key] = new classs(a[key]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return new classs(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
export class MarketCatalogItem {
|
||||
entry: MarketEntry;
|
||||
installed: boolean;
|
||||
installed_version?: string;
|
||||
update_available: boolean;
|
||||
compatible: boolean;
|
||||
incompatible_reason?: string;
|
||||
withdrawn?: MarketWithdrawal;
|
||||
high_risk_permissions?: string[];
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new MarketCatalogItem(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.entry = this.convertValues(source["entry"], MarketEntry);
|
||||
this.installed = source["installed"];
|
||||
this.installed_version = source["installed_version"];
|
||||
this.update_available = source["update_available"];
|
||||
this.compatible = source["compatible"];
|
||||
this.incompatible_reason = source["incompatible_reason"];
|
||||
this.withdrawn = this.convertValues(source["withdrawn"], MarketWithdrawal);
|
||||
this.high_risk_permissions = source["high_risk_permissions"];
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (a.slice && a.map) {
|
||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||
} else if ("object" === typeof a) {
|
||||
if (asMap) {
|
||||
for (const key of Object.keys(a)) {
|
||||
a[key] = new classs(a[key]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return new classs(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
export class MarketBrowseResult {
|
||||
source: string;
|
||||
stale: boolean;
|
||||
fetch_error?: string;
|
||||
updated_at?: string;
|
||||
items: MarketCatalogItem[];
|
||||
withdrawn_installed?: MarketWithdrawal[];
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new MarketBrowseResult(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.source = source["source"];
|
||||
this.stale = source["stale"];
|
||||
this.fetch_error = source["fetch_error"];
|
||||
this.updated_at = source["updated_at"];
|
||||
this.items = this.convertValues(source["items"], MarketCatalogItem);
|
||||
this.withdrawn_installed = this.convertValues(source["withdrawn_installed"], MarketWithdrawal);
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (a.slice && a.map) {
|
||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||
} else if ("object" === typeof a) {
|
||||
if (asMap) {
|
||||
for (const key of Object.keys(a)) {
|
||||
a[key] = new classs(a[key]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return new classs(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
export class MenuContribution {
|
||||
id: string;
|
||||
@@ -1459,12 +1730,25 @@ export namespace plugin {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
export interface ResolvedLocaleFont {
|
||||
export class ResolvedLocaleFont {
|
||||
family: string;
|
||||
url: string;
|
||||
weight?: string;
|
||||
style?: string;
|
||||
unicodeRange?: string;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new ResolvedLocaleFont(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.family = source["family"];
|
||||
this.url = source["url"];
|
||||
this.weight = source["weight"];
|
||||
this.style = source["style"];
|
||||
this.unicodeRange = source["unicodeRange"];
|
||||
}
|
||||
}
|
||||
export class ResolvedLocalePack {
|
||||
locale: string;
|
||||
@@ -1472,7 +1756,7 @@ export namespace plugin {
|
||||
fallback?: string;
|
||||
has_ui_messages?: boolean;
|
||||
messages?: Record<string, string>;
|
||||
plugin_messages?: Record<string, Record<string, string>>;
|
||||
plugin_messages?: Record<string, any>;
|
||||
fonts?: ResolvedLocaleFont[];
|
||||
pluginIds?: string[];
|
||||
|
||||
@@ -1488,9 +1772,27 @@ export namespace plugin {
|
||||
this.has_ui_messages = source["has_ui_messages"];
|
||||
this.messages = source["messages"];
|
||||
this.plugin_messages = source["plugin_messages"];
|
||||
this.fonts = source["fonts"];
|
||||
this.fonts = this.convertValues(source["fonts"], ResolvedLocaleFont);
|
||||
this.pluginIds = source["pluginIds"];
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (a.slice && a.map) {
|
||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||
} else if ("object" === typeof a) {
|
||||
if (asMap) {
|
||||
for (const key of Object.keys(a)) {
|
||||
a[key] = new classs(a[key]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return new classs(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
export class RuntimeSourceContribution {
|
||||
id: string;
|
||||
@@ -1536,6 +1838,104 @@ export namespace plugin {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
export class ScanFinding {
|
||||
severity: string;
|
||||
check: string;
|
||||
target?: string;
|
||||
message: string;
|
||||
localized?: LocalizedText;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new ScanFinding(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.severity = source["severity"];
|
||||
this.check = source["check"];
|
||||
this.target = source["target"];
|
||||
this.message = source["message"];
|
||||
this.localized = this.convertValues(source["localized"], LocalizedText);
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (a.slice && a.map) {
|
||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||
} else if ("object" === typeof a) {
|
||||
if (asMap) {
|
||||
for (const key of Object.keys(a)) {
|
||||
a[key] = new classs(a[key]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return new classs(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
export class ScanReport {
|
||||
plugin_id?: string;
|
||||
version?: string;
|
||||
name?: LocalizedText;
|
||||
tier?: string;
|
||||
trust?: string;
|
||||
publisher?: string;
|
||||
license?: string;
|
||||
passed: boolean;
|
||||
hard_blocked: boolean;
|
||||
needs_approval: boolean;
|
||||
headline: LocalizedText;
|
||||
native_exec_notice?: LocalizedText;
|
||||
hard_findings?: ScanFinding[];
|
||||
capabilities?: CapabilityItem[];
|
||||
pending_findings?: ScanFinding[];
|
||||
executables?: ExecutableFile[];
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new ScanReport(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.plugin_id = source["plugin_id"];
|
||||
this.version = source["version"];
|
||||
this.name = this.convertValues(source["name"], LocalizedText);
|
||||
this.tier = source["tier"];
|
||||
this.trust = source["trust"];
|
||||
this.publisher = source["publisher"];
|
||||
this.license = source["license"];
|
||||
this.passed = source["passed"];
|
||||
this.hard_blocked = source["hard_blocked"];
|
||||
this.needs_approval = source["needs_approval"];
|
||||
this.headline = this.convertValues(source["headline"], LocalizedText);
|
||||
this.native_exec_notice = this.convertValues(source["native_exec_notice"], LocalizedText);
|
||||
this.hard_findings = this.convertValues(source["hard_findings"], ScanFinding);
|
||||
this.capabilities = this.convertValues(source["capabilities"], CapabilityItem);
|
||||
this.pending_findings = this.convertValues(source["pending_findings"], ScanFinding);
|
||||
this.executables = this.convertValues(source["executables"], ExecutableFile);
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (a.slice && a.map) {
|
||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||
} else if ("object" === typeof a) {
|
||||
if (asMap) {
|
||||
for (const key of Object.keys(a)) {
|
||||
a[key] = new classs(a[key]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return new classs(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
export class SettingsPageContribution {
|
||||
id: string;
|
||||
@@ -1702,246 +2102,6 @@ export namespace plugin {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
export class Engines {
|
||||
'reims-go'?: string;
|
||||
pluginApi?: string;
|
||||
uiApi?: string;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new Engines(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this['reims-go'] = source["reims-go"];
|
||||
this.pluginApi = source["pluginApi"];
|
||||
this.uiApi = source["uiApi"];
|
||||
}
|
||||
}
|
||||
export class ScanFinding {
|
||||
severity: string;
|
||||
check: string;
|
||||
target?: string;
|
||||
message: string;
|
||||
localized?: LocalizedText;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new ScanFinding(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.severity = source["severity"];
|
||||
this.check = source["check"];
|
||||
this.target = source["target"];
|
||||
this.message = source["message"];
|
||||
this.localized = source["localized"] ? new LocalizedText(source["localized"]) : undefined;
|
||||
}
|
||||
}
|
||||
export class ExecutableFile {
|
||||
path: string;
|
||||
sha256: string;
|
||||
declared: boolean;
|
||||
size_bytes: number;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new ExecutableFile(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.path = source["path"];
|
||||
this.sha256 = source["sha256"];
|
||||
this.declared = source["declared"];
|
||||
this.size_bytes = source["size_bytes"];
|
||||
}
|
||||
}
|
||||
export class CapabilityItem {
|
||||
id: string;
|
||||
level: string;
|
||||
title: LocalizedText;
|
||||
summary: LocalizedText;
|
||||
examples?: string[];
|
||||
extra_count?: number;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new CapabilityItem(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.id = source["id"];
|
||||
this.level = source["level"];
|
||||
this.title = new LocalizedText(source["title"]);
|
||||
this.summary = new LocalizedText(source["summary"]);
|
||||
this.examples = source["examples"];
|
||||
this.extra_count = source["extra_count"];
|
||||
}
|
||||
}
|
||||
export class ScanReport {
|
||||
plugin_id?: string;
|
||||
version?: string;
|
||||
name?: LocalizedText;
|
||||
tier?: string;
|
||||
trust?: string;
|
||||
publisher?: string;
|
||||
license?: string;
|
||||
passed: boolean;
|
||||
hard_blocked: boolean;
|
||||
needs_approval: boolean;
|
||||
headline: LocalizedText;
|
||||
native_exec_notice?: LocalizedText;
|
||||
hard_findings?: ScanFinding[];
|
||||
capabilities?: CapabilityItem[];
|
||||
pending_findings?: ScanFinding[];
|
||||
executables?: ExecutableFile[];
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new ScanReport(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.plugin_id = source["plugin_id"];
|
||||
this.version = source["version"];
|
||||
this.name = source["name"] ? new LocalizedText(source["name"]) : undefined;
|
||||
this.tier = source["tier"];
|
||||
this.trust = source["trust"];
|
||||
this.publisher = source["publisher"];
|
||||
this.license = source["license"];
|
||||
this.passed = source["passed"];
|
||||
this.hard_blocked = source["hard_blocked"];
|
||||
this.needs_approval = source["needs_approval"];
|
||||
this.headline = new LocalizedText(source["headline"]);
|
||||
this.native_exec_notice = source["native_exec_notice"] ? new LocalizedText(source["native_exec_notice"]) : undefined;
|
||||
this.hard_findings = (source["hard_findings"] || []).map((x: any) => new ScanFinding(x));
|
||||
this.capabilities = (source["capabilities"] || []).map((x: any) => new CapabilityItem(x));
|
||||
this.pending_findings = (source["pending_findings"] || []).map((x: any) => new ScanFinding(x));
|
||||
this.executables = (source["executables"] || []).map((x: any) => new ExecutableFile(x));
|
||||
}
|
||||
}
|
||||
export class MarketEntry {
|
||||
id: string;
|
||||
version: string;
|
||||
name: LocalizedText;
|
||||
description: LocalizedText;
|
||||
publisher: string;
|
||||
license: string;
|
||||
channel: string;
|
||||
trust: string;
|
||||
kind?: string;
|
||||
tier?: string;
|
||||
homepage?: string;
|
||||
readme_url?: string;
|
||||
engines: Engines;
|
||||
platforms?: string[];
|
||||
permissions?: string[];
|
||||
download_url: string;
|
||||
sha256: string;
|
||||
size_bytes?: number;
|
||||
signer?: string;
|
||||
changelog?: LocalizedText;
|
||||
tags?: string[];
|
||||
updated_at?: string;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new MarketEntry(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.id = source["id"];
|
||||
this.version = source["version"];
|
||||
this.name = new LocalizedText(source["name"]);
|
||||
this.description = new LocalizedText(source["description"]);
|
||||
this.publisher = source["publisher"];
|
||||
this.license = source["license"];
|
||||
this.channel = source["channel"];
|
||||
this.trust = source["trust"];
|
||||
this.kind = source["kind"];
|
||||
this.tier = source["tier"];
|
||||
this.homepage = source["homepage"];
|
||||
this.readme_url = source["readme_url"];
|
||||
this.engines = new Engines(source["engines"]);
|
||||
this.platforms = source["platforms"];
|
||||
this.permissions = source["permissions"];
|
||||
this.download_url = source["download_url"];
|
||||
this.sha256 = source["sha256"];
|
||||
this.size_bytes = source["size_bytes"];
|
||||
this.signer = source["signer"];
|
||||
this.changelog = source["changelog"] ? new LocalizedText(source["changelog"]) : undefined;
|
||||
this.tags = source["tags"];
|
||||
this.updated_at = source["updated_at"];
|
||||
}
|
||||
}
|
||||
export class MarketWithdrawal {
|
||||
id: string;
|
||||
reason: LocalizedText;
|
||||
instead_id?: string;
|
||||
instead_name?: string;
|
||||
withdrawn_at?: string;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new MarketWithdrawal(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.id = source["id"];
|
||||
this.reason = new LocalizedText(source["reason"]);
|
||||
this.instead_id = source["instead_id"];
|
||||
this.instead_name = source["instead_name"];
|
||||
this.withdrawn_at = source["withdrawn_at"];
|
||||
}
|
||||
}
|
||||
export class MarketCatalogItem {
|
||||
entry: MarketEntry;
|
||||
installed: boolean;
|
||||
installed_version?: string;
|
||||
update_available: boolean;
|
||||
compatible: boolean;
|
||||
incompatible_reason?: string;
|
||||
withdrawn?: MarketWithdrawal;
|
||||
high_risk_permissions?: string[];
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new MarketCatalogItem(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.entry = new MarketEntry(source["entry"]);
|
||||
this.installed = source["installed"];
|
||||
this.installed_version = source["installed_version"];
|
||||
this.update_available = source["update_available"];
|
||||
this.compatible = source["compatible"];
|
||||
this.incompatible_reason = source["incompatible_reason"];
|
||||
this.withdrawn = source["withdrawn"] ? new MarketWithdrawal(source["withdrawn"]) : undefined;
|
||||
this.high_risk_permissions = source["high_risk_permissions"];
|
||||
}
|
||||
}
|
||||
export class MarketBrowseResult {
|
||||
source: string;
|
||||
stale: boolean;
|
||||
fetch_error?: string;
|
||||
updated_at?: string;
|
||||
items: MarketCatalogItem[];
|
||||
withdrawn_installed?: MarketWithdrawal[];
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new MarketBrowseResult(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.source = source["source"];
|
||||
this.stale = source["stale"];
|
||||
this.fetch_error = source["fetch_error"];
|
||||
this.updated_at = source["updated_at"];
|
||||
this.items = (source["items"] || []).map((x: any) => new MarketCatalogItem(x));
|
||||
this.withdrawn_installed = (source["withdrawn_installed"] || []).map((x: any) => new MarketWithdrawal(x));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2389,7 +2549,7 @@ export namespace runtime {
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.kind = source["kind"];
|
||||
this.name = source["name"];
|
||||
this.name = this.convertValues(source["name"], plugin.LocalizedText);
|
||||
this.name_zh = source["name_zh"];
|
||||
this.name_en = source["name_en"];
|
||||
this.required_files = source["required_files"];
|
||||
@@ -2397,6 +2557,24 @@ export namespace runtime {
|
||||
this.builtin = source["builtin"];
|
||||
this.plugin_id = source["plugin_id"];
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (a.slice && a.map) {
|
||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||
} else if ("object" === typeof a) {
|
||||
if (asMap) {
|
||||
for (const key of Object.keys(a)) {
|
||||
a[key] = new classs(a[key]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return new classs(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+4
-2
@@ -1400,8 +1400,10 @@ func (a *App) StartVM(name string) error {
|
||||
}
|
||||
} else {
|
||||
a.syncGuestTools(c, name, &curDetail)
|
||||
if env := a.inputBridgeEnv(name, curDetail.Directory); len(env) > 0 {
|
||||
c.Env = append(c.Env, env...)
|
||||
if prep.Runtime.Manifest.HasCapability("win32-unicode-input") {
|
||||
if env := a.inputBridgeEnv(name, curDetail.Directory); len(env) > 0 {
|
||||
c.Env = append(c.Env, env...)
|
||||
}
|
||||
}
|
||||
prep.Prepare(context.Background(), name, rep, &curDetail)
|
||||
if rep.NeedsColdRebootWorkaround {
|
||||
|
||||
@@ -46,6 +46,12 @@ func (a *App) startGuestToolsServer() (srv *guesttools.Server, port int, created
|
||||
srv = guesttools.NewServer(nil)
|
||||
}
|
||||
srv.SetHostTextHandler(func(vmName, text string) {
|
||||
a.mu.Lock()
|
||||
mgr := a.pluginMgr
|
||||
a.mu.Unlock()
|
||||
if mgr != nil && !mgr.Registry().IsActive(builtin.IDInput) {
|
||||
return
|
||||
}
|
||||
a.injectRemoteText(vmName, "", text)
|
||||
})
|
||||
a.guestTools = srv
|
||||
|
||||
@@ -859,7 +859,9 @@ func (a *App) InspectPluginArchive(archivePath string) (plugin.ScanReport, error
|
||||
if mgr != nil {
|
||||
tmpDir = mgr.Layout().TmpDir()
|
||||
}
|
||||
return plugin.ScanArchive(archivePath, tmpDir, version.Version, plugin.ScanOptions{})
|
||||
return plugin.ScanArchive(archivePath, tmpDir, version.Version, plugin.ScanOptions{
|
||||
Keyring: plugin.DefaultKeyring(),
|
||||
})
|
||||
}
|
||||
|
||||
// ScanInstalledPlugin runs the unified static risk report against an installed
|
||||
@@ -891,7 +893,9 @@ func (a *App) ScanInstalledPlugin(pluginID string) (plugin.ScanReport, error) {
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
rep := plugin.ScanDirectory(info.InstallDir, version.Version, plugin.ScanOptions{})
|
||||
rep := plugin.ScanDirectory(info.InstallDir, version.Version, plugin.ScanOptions{
|
||||
Keyring: plugin.DefaultKeyring(),
|
||||
})
|
||||
if info.Trust == plugin.TrustDev {
|
||||
rep.Trust = plugin.TrustDev
|
||||
}
|
||||
|
||||
+55
-2
@@ -83,7 +83,7 @@ func openCLIMarketClient(cfg *config.Config) *plugin.MarketClient {
|
||||
|
||||
func cmdPlugin(cfg *config.Config, loc i18n.Locale, args []string) error {
|
||||
if len(args) == 0 {
|
||||
return fmt.Errorf("usage: reims-go plugin <list|search|install|update|link|enable|disable|remove|info|doctor|locale|run>")
|
||||
return fmt.Errorf("usage: reims-go plugin <list|search|install|update|pack|link|enable|disable|remove|info|doctor|locale|run>")
|
||||
}
|
||||
ctx := context.Background()
|
||||
switch args[0] {
|
||||
@@ -279,6 +279,59 @@ func cmdPlugin(cfg *config.Config, loc i18n.Locale, args []string) error {
|
||||
}
|
||||
return nil
|
||||
|
||||
case "pack":
|
||||
fs := flag.NewFlagSet("plugin pack", flag.ContinueOnError)
|
||||
outPath := fs.String("out", "", "Output .zip path (defaults to <id>-<version>.zip)")
|
||||
contractPath := fs.String("contract", "", "Optional path to ui-contract.json for CSS validation")
|
||||
signKeySpec := fs.String("sign-key", "", "Optional ed25519 private key (file path or hex/base64) to sign SHA256SUMS.sig")
|
||||
asJSON := fs.Bool("json", false, "Output JSON summary")
|
||||
if err := fs.Parse(args[1:]); err != nil {
|
||||
return err
|
||||
}
|
||||
if fs.NArg() < 1 {
|
||||
return fmt.Errorf("usage: reims-go plugin pack [--out file.zip] [--contract ui-contract.json] [--sign-key key] [--json] <dir>")
|
||||
}
|
||||
var contract *plugin.UIContract
|
||||
if *contractPath != "" {
|
||||
raw, rErr := os.ReadFile(*contractPath)
|
||||
if rErr != nil {
|
||||
return rErr
|
||||
}
|
||||
var c plugin.UIContract
|
||||
if rErr := json.Unmarshal(raw, &c); rErr != nil {
|
||||
return fmt.Errorf("parse ui-contract.json: %w", rErr)
|
||||
}
|
||||
contract = &c
|
||||
}
|
||||
packOpts := plugin.PackOptions{
|
||||
HostVersion: version.Version,
|
||||
Contract: contract,
|
||||
OutputPath: *outPath,
|
||||
}
|
||||
if strings.TrimSpace(*signKeySpec) != "" {
|
||||
pk, kErr := plugin.ParseEd25519PrivateKey(*signKeySpec)
|
||||
if kErr != nil {
|
||||
return fmt.Errorf("parse --sign-key: %w", kErr)
|
||||
}
|
||||
packOpts.SignKey = pk
|
||||
}
|
||||
res, pErr := plugin.PackDirectory(fs.Arg(0), packOpts)
|
||||
if pErr != nil {
|
||||
if res.Report.HardBlocked && !*asJSON {
|
||||
fmt.Fprintln(os.Stderr, res.Report.SummaryText(string(loc)))
|
||||
}
|
||||
return pErr
|
||||
}
|
||||
if *asJSON {
|
||||
enc := json.NewEncoder(os.Stdout)
|
||||
enc.SetIndent("", " ")
|
||||
return enc.Encode(res)
|
||||
}
|
||||
fmt.Println(i18n.T(loc, "plugin.packed", res.PluginID, res.Version, res.OutputPath))
|
||||
fmt.Printf("SHA-256: %s\n", res.SHA256)
|
||||
fmt.Printf("Size: %d bytes (%d files, signed=%v)\n", res.SizeBytes, res.FileCount, res.Signed)
|
||||
return nil
|
||||
|
||||
case "link":
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("usage: reims-go plugin link <dir>")
|
||||
@@ -387,7 +440,7 @@ func cmdPlugin(cfg *config.Config, loc i18n.Locale, args []string) error {
|
||||
}
|
||||
contract = &c
|
||||
}
|
||||
scanOpts := plugin.ScanOptions{Contract: contract}
|
||||
scanOpts := plugin.ScanOptions{Contract: contract, Keyring: plugin.DefaultKeyring()}
|
||||
target := ""
|
||||
if fs.NArg() > 0 {
|
||||
target = fs.Arg(0)
|
||||
|
||||
@@ -1119,7 +1119,7 @@ func (s *Server) handleHostText(w http.ResponseWriter, r *http.Request) {
|
||||
fn := s.onHostText
|
||||
s.mu.RUnlock()
|
||||
if fn != nil {
|
||||
go fn(vmSnap.name, string(body))
|
||||
fn(vmSnap.name, string(body))
|
||||
}
|
||||
w.WriteHeader(http.StatusAccepted)
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ var catalog = map[Locale]map[string]string{
|
||||
"cli.usage.cmd_inst_del": " installer delete <文件名> 删除已下载的安装包(正在使用或下载中的会被拒绝)",
|
||||
"cli.usage.cmd_inst_dl": " installer download <版本> 下载离线安装包(如 26.7.1、tahoe、latest;Ctrl+C 暂停,再次运行续传)",
|
||||
"cli.usage.cmd_inst_list": " installer list 列出 Apple 提供的离线安装包版本(需联网)",
|
||||
"cli.usage.cmd_plugin": " plugin list|search|install|update|link|enable|disable|remove|info|doctor|locale|run\n 管理内置扩展、语言包、插件市场与静态安全检查",
|
||||
"cli.usage.cmd_plugin": " plugin list|search|install|update|pack|link|enable|disable|remove|info|doctor|locale|run\n 管理内置扩展、语言包、插件市场、打包与静态安全检查",
|
||||
"cli.usage.cmd_rt_avail": " runtime available 列出 GitHub 上发布的运行时(--alpha 含 alpha 版)",
|
||||
"cli.usage.cmd_rt_fetch": " runtime fetch [commit] 在线下载、校验并安装运行时(默认最新;Ctrl+C 暂停,再次运行续传)",
|
||||
"cli.usage.cmd_rt_install": " runtime install <archive> 导入并校验本地运行时包(.tar.zst 或 .zip)",
|
||||
@@ -352,6 +352,7 @@ var catalog = map[Locale]map[string]string{
|
||||
"plugin.market.up_to_date": "所有已安装插件均已是最新版本",
|
||||
"plugin.needs_approval": "提示:此插件包含高危权限,启用前请运行:reims-go plugin enable --approve-high-risk {id}",
|
||||
"plugin.not_found": "未找到插件 \"{id}\"",
|
||||
"plugin.packed": "已打包插件 {id}@{ver} -> {path}",
|
||||
"plugin.removed": "已卸载 {id}(purge={purge})",
|
||||
"plugin.target_not_found": "未找到插件或目录 \"{target}\"",
|
||||
"pluginSafeModeShort": "安全模式",
|
||||
@@ -538,7 +539,7 @@ var catalog = map[Locale]map[string]string{
|
||||
"cli.usage.cmd_inst_del": " installer delete <name> Delete a downloaded installer (refused if in use or downloading)",
|
||||
"cli.usage.cmd_inst_dl": " installer download <ver> Download an offline installer (26.7.1, tahoe, latest; Ctrl+C pauses, rerun resumes)",
|
||||
"cli.usage.cmd_inst_list": " installer list List offline macOS installers Apple offers (needs network)",
|
||||
"cli.usage.cmd_plugin": " plugin list|search|install|update|link|enable|disable|remove|info|doctor|locale|run\n Manage built-in extensions, language packs, plugin market and security checks",
|
||||
"cli.usage.cmd_plugin": " plugin list|search|install|update|pack|link|enable|disable|remove|info|doctor|locale|run\n Manage built-in extensions, language packs, market, packaging and security checks",
|
||||
"cli.usage.cmd_rt_avail": " runtime available List runtimes published on GitHub (--alpha includes alpha builds)",
|
||||
"cli.usage.cmd_rt_fetch": " runtime fetch [commit] Download, verify and install a runtime (newest by default; Ctrl+C pauses)",
|
||||
"cli.usage.cmd_rt_install": " runtime install <archive> Verify and install a local runtime package (.tar.zst or .zip)",
|
||||
@@ -855,6 +856,7 @@ var catalog = map[Locale]map[string]string{
|
||||
"plugin.market.up_to_date": "All installed plugins are up to date",
|
||||
"plugin.needs_approval": "Note: plugin requires high-risk permission approval; run: reims-go plugin enable --approve-high-risk {id}",
|
||||
"plugin.not_found": "plugin \"{id}\" not found",
|
||||
"plugin.packed": "Packed {id}@{ver} -> {path}",
|
||||
"plugin.removed": "Removed {id} (purge={purge})",
|
||||
"plugin.target_not_found": "plugin or directory \"{target}\" not found",
|
||||
"pluginSafeModeShort": "Safe mode",
|
||||
@@ -1095,6 +1097,7 @@ var paramOrder = map[string][]string{
|
||||
"plugin.linked": {"id", "ver", "dir"},
|
||||
"plugin.needs_approval": {"id"},
|
||||
"plugin.not_found": {"id"},
|
||||
"plugin.packed": {"id", "ver", "path"},
|
||||
"plugin.removed": {"id", "purge"},
|
||||
"plugin.target_not_found": {"target"},
|
||||
"resLooksLike": {"h", "w"},
|
||||
|
||||
@@ -60,7 +60,7 @@ type HostCallbacks struct {
|
||||
func appVersion() string {
|
||||
v := strings.TrimPrefix(strings.TrimSpace(version.Version), "v")
|
||||
if v == "" || v == "dev" {
|
||||
return "0.2.9"
|
||||
return "0.2.10"
|
||||
}
|
||||
return v
|
||||
}
|
||||
@@ -162,8 +162,10 @@ func defGuestTools(ver string, cb HostCallbacks, desiredFn func(string, bool) bo
|
||||
gtCfg = cb.ValidateDriveConfig(gtCfg)
|
||||
}
|
||||
s.RegisterVM(gtCfg)
|
||||
intent.Env["REIMS_GO_INPUT_URL"] = fmt.Sprintf("http://127.0.0.1:%d/v1/host-text", port)
|
||||
intent.Env["REIMS_GO_INPUT_TOKEN"] = gtCfg.Token
|
||||
if sc.Registry().IsActive(IDInput) && hasCap(p.RuntimeCaps, "win32-unicode-input") {
|
||||
intent.Env["REIMS_GO_INPUT_URL"] = fmt.Sprintf("http://127.0.0.1:%d/v1/host-text", port)
|
||||
intent.Env["REIMS_GO_INPUT_TOKEN"] = gtCfg.Token
|
||||
}
|
||||
}
|
||||
if reims.HasGuestToolsArgs(p.ExtraArgs) && cb.GuestToolsImg != nil && err == nil {
|
||||
imgPath := cb.GuestToolsImg(p.VMName)
|
||||
|
||||
@@ -139,3 +139,62 @@ func TestBuiltinInstallGuideLifecycleZeroResidue(t *testing.T) {
|
||||
t.Fatal("expected a fresh ui.install-guide service instance after re-enable")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGuestToolsInputBridgeEnvGating(t *testing.T) {
|
||||
reg := plugin.NewRegistry(nil)
|
||||
gtSrv := guesttools.NewTransportServer(nil)
|
||||
if _, err := gtSrv.Start(-1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() { _ = gtSrv.Close(context.Background()) }()
|
||||
|
||||
cb := HostCallbacks{
|
||||
GetConfig: func() config.Config { return config.Config{DataRoot: t.TempDir()} },
|
||||
EnsureGuestTools: func() (*guesttools.Server, int, error) {
|
||||
return gtSrv, gtSrv.Port(), nil
|
||||
},
|
||||
}
|
||||
if err := RegisterAll(reg, cb, nil); err != nil {
|
||||
t.Fatalf("RegisterAll: %v", err)
|
||||
}
|
||||
reg.Reconcile(context.Background())
|
||||
|
||||
vmDir := t.TempDir()
|
||||
dispatch := func(caps []string) map[string]string {
|
||||
intents, err := reg.Hooks().DispatchBeforeStart(context.Background(), plugin.BeforeStartPayload{
|
||||
VMName: "mac",
|
||||
VMDir: vmDir,
|
||||
DriverID: IDDriverReimsMacOS,
|
||||
RuntimeCaps: caps,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("DispatchBeforeStart: %v", err)
|
||||
}
|
||||
for _, in := range intents {
|
||||
if in.PluginID == IDGuestTools {
|
||||
return in.Env
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Runtime without safe win32-unicode-input capability (e.g. runtime-3731afd-p3)
|
||||
// must NOT receive REIMS_GO_INPUT_URL / REIMS_GO_INPUT_TOKEN.
|
||||
if env := dispatch(nil); env["REIMS_GO_INPUT_URL"] != "" || env["REIMS_GO_INPUT_TOKEN"] != "" {
|
||||
t.Fatalf("without capability: unexpected input bridge env %v", env)
|
||||
}
|
||||
|
||||
// Fixed runtime + active builtin.input plugin -> env vars injected.
|
||||
env := dispatch([]string{"win32-unicode-input"})
|
||||
if env["REIMS_GO_INPUT_URL"] == "" || env["REIMS_GO_INPUT_TOKEN"] == "" {
|
||||
t.Fatalf("with capability and active input plugin: missing input bridge env %v", env)
|
||||
}
|
||||
|
||||
// Disabling builtin.input stops injecting REIMS_GO_INPUT_URL / TOKEN even on fixed runtime.
|
||||
if err := reg.SetDesired(context.Background(), IDInput, false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if env := dispatch([]string{"win32-unicode-input"}); env["REIMS_GO_INPUT_URL"] != "" || env["REIMS_GO_INPUT_TOKEN"] != "" {
|
||||
t.Fatalf("with input plugin disabled: unexpected input bridge env %v", env)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"crypto/ed25519"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// EnvPluginExtraKeys optionally points to a JSON file or inline JSON array of
|
||||
// extra ed25519 public signing keys (useful for local/enterprise verification
|
||||
// and integration tests without recompiling the binary).
|
||||
const EnvPluginExtraKeys = "REIMS_GO_PLUGIN_EXTRA_KEYS"
|
||||
|
||||
type rawSigningKey struct {
|
||||
KeyID string `json:"key_id"`
|
||||
Publisher string `json:"publisher"`
|
||||
Trust TrustLevel `json:"trust"`
|
||||
PublicKey string `json:"public_key"` // hex or standard base64 (32 bytes)
|
||||
}
|
||||
|
||||
// builtinTrustedKeys holds official/verified ed25519 public keys published by
|
||||
// the reims-go organization. Populate entries once org release keys are minted
|
||||
// in reims-go/plugins/keys/.
|
||||
var builtinTrustedKeys = []rawSigningKey{}
|
||||
|
||||
// DefaultKeyring returns the trusted ed25519 signing keyring built into the
|
||||
// host binary plus any optional extra keys configured via REIMS_GO_PLUGIN_EXTRA_KEYS.
|
||||
func DefaultKeyring() []SigningKey {
|
||||
var out []SigningKey
|
||||
for _, rk := range builtinTrustedKeys {
|
||||
if k, err := parseSigningKey(rk); err == nil {
|
||||
out = append(out, k)
|
||||
}
|
||||
}
|
||||
if extra := strings.TrimSpace(os.Getenv(EnvPluginExtraKeys)); extra != "" {
|
||||
raw := []byte(extra)
|
||||
if !strings.HasPrefix(extra, "[") {
|
||||
if fileBytes, err := os.ReadFile(extra); err == nil {
|
||||
raw = fileBytes
|
||||
}
|
||||
}
|
||||
var list []rawSigningKey
|
||||
if err := json.Unmarshal(raw, &list); err == nil {
|
||||
for _, rk := range list {
|
||||
if k, err := parseSigningKey(rk); err == nil {
|
||||
out = append(out, k)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func parseSigningKey(rk rawSigningKey) (SigningKey, error) {
|
||||
pubBytes, err := decodeEd25519KeyBytes(rk.PublicKey, ed25519.PublicKeySize)
|
||||
if err != nil {
|
||||
return SigningKey{}, fmt.Errorf("invalid public key %q: %w", rk.KeyID, err)
|
||||
}
|
||||
trust := rk.Trust
|
||||
if trust != TrustOfficial && trust != TrustVerified {
|
||||
trust = TrustVerified
|
||||
}
|
||||
return SigningKey{
|
||||
KeyID: strings.TrimSpace(rk.KeyID),
|
||||
Publisher: strings.TrimSpace(rk.Publisher),
|
||||
Trust: trust,
|
||||
PublicKey: ed25519.PublicKey(pubBytes),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ParseEd25519PrivateKey decodes a 32-byte seed or 64-byte ed25519 private key
|
||||
// from hex or base64 text (or from a file path containing that text).
|
||||
func ParseEd25519PrivateKey(spec string) (ed25519.PrivateKey, error) {
|
||||
s := strings.TrimSpace(spec)
|
||||
if s == "" {
|
||||
return nil, fmt.Errorf("empty private key")
|
||||
}
|
||||
if st, err := os.Stat(s); err == nil && !st.IsDir() {
|
||||
raw, rErr := os.ReadFile(s)
|
||||
if rErr != nil {
|
||||
return nil, rErr
|
||||
}
|
||||
s = strings.TrimSpace(string(raw))
|
||||
}
|
||||
if b, err := decodeEd25519KeyBytes(s, ed25519.PrivateKeySize); err == nil {
|
||||
return ed25519.PrivateKey(b), nil
|
||||
}
|
||||
if seed, err := decodeEd25519KeyBytes(s, ed25519.SeedSize); err == nil {
|
||||
return ed25519.NewKeyFromSeed(seed), nil
|
||||
}
|
||||
return nil, fmt.Errorf("expected 32-byte seed or 64-byte ed25519 private key in hex or base64")
|
||||
}
|
||||
|
||||
func decodeEd25519KeyBytes(raw string, wantLen int) ([]byte, error) {
|
||||
s := strings.TrimSpace(raw)
|
||||
if b, err := hex.DecodeString(s); err == nil && len(b) == wantLen {
|
||||
return b, nil
|
||||
}
|
||||
if b, err := base64.StdEncoding.DecodeString(s); err == nil && len(b) == wantLen {
|
||||
return b, nil
|
||||
}
|
||||
if b, err := base64.RawStdEncoding.DecodeString(s); err == nil && len(b) == wantLen {
|
||||
return b, nil
|
||||
}
|
||||
return nil, fmt.Errorf("key length != %d", wantLen)
|
||||
}
|
||||
@@ -190,9 +190,9 @@ func defaultNativeLocaleLabel(tag string) string {
|
||||
case "zh-CN":
|
||||
return "简体中文"
|
||||
case "zh-TW":
|
||||
return "繁體中文(台灣)"
|
||||
return "繁體中文"
|
||||
case "zh-HK":
|
||||
return "繁體中文(香港)"
|
||||
return "繁體中文(中國香港)"
|
||||
case "en-US":
|
||||
return "English (US)"
|
||||
case "ja-JP":
|
||||
|
||||
@@ -69,6 +69,9 @@ type Manager struct {
|
||||
// NewManager initializes the Plugin Manager for DataRoot. If state.json is
|
||||
// corrupt, stateLoadErr is recorded and returned on load rather than wiping state (§6.1).
|
||||
func NewManager(opts ManagerOptions) (*Manager, error) {
|
||||
if len(opts.Keyring) == 0 {
|
||||
opts.Keyring = DefaultKeyring()
|
||||
}
|
||||
layout := NewPluginsLayout(opts.DataRoot)
|
||||
reg := NewRegistry(opts.Logger)
|
||||
if opts.LocaleFn != nil {
|
||||
|
||||
@@ -30,9 +30,13 @@ const (
|
||||
// "off"/"offline" to use the embedded fallback only.
|
||||
EnvPluginMarketURL = "REIMS_GO_PLUGIN_MARKET_URL"
|
||||
|
||||
// DefaultMarketIndexURL is the static plugin market index published from
|
||||
// the community plugins dist branch (never fetches on app startup).
|
||||
DefaultMarketIndexURL = "https://raw.githubusercontent.com/Nwflower/reims-go-plugins/dist/index.json"
|
||||
// DefaultMarketIndexURL is the primary static plugin market index published
|
||||
// from the reims-go/plugins dist branch (never fetched on app startup).
|
||||
DefaultMarketIndexURL = "https://raw.githubusercontent.com/reims-go/plugins/dist/index.json"
|
||||
|
||||
// DefaultMarketMirrorURL is the CDN mirror automatically tried when the
|
||||
// primary GitHub raw endpoint is unreachable or blocked.
|
||||
DefaultMarketMirrorURL = "https://cdn.jsdelivr.net/gh/reims-go/plugins@dist/index.json"
|
||||
|
||||
defaultMarketCacheTTL = 10 * time.Minute
|
||||
maxMarketIndexBytes = 4 << 20 // 4 MiB ceiling for lightweight index.json
|
||||
@@ -161,11 +165,12 @@ type MarketClient struct {
|
||||
}
|
||||
|
||||
// DefaultMarketURLs resolves market index URL(s) from REIMS_GO_PLUGIN_MARKET_URL
|
||||
// or falls back to DefaultMarketIndexURL. Returning nil means offline mode.
|
||||
// or falls back to DefaultMarketIndexURL + DefaultMarketMirrorURL. Returning nil
|
||||
// means offline mode.
|
||||
func DefaultMarketURLs() []string {
|
||||
raw := strings.TrimSpace(os.Getenv(EnvPluginMarketURL))
|
||||
if raw == "" {
|
||||
return []string{DefaultMarketIndexURL}
|
||||
return []string{DefaultMarketIndexURL, DefaultMarketMirrorURL}
|
||||
}
|
||||
low := strings.ToLower(raw)
|
||||
if low == "off" || low == "offline" || low == "none" || low == "0" {
|
||||
|
||||
@@ -0,0 +1,255 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"crypto/ed25519"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// PackOptions configures PackDirectory.
|
||||
type PackOptions struct {
|
||||
HostVersion string
|
||||
Contract *UIContract
|
||||
OutputPath string // optional; defaults to "<cwd>/<id>-<version>.zip"
|
||||
SignKey ed25519.PrivateKey
|
||||
}
|
||||
|
||||
// PackResult describes a freshly packed plugin archive ready for distribution
|
||||
// or market submission.
|
||||
type PackResult struct {
|
||||
PluginID string `json:"plugin_id"`
|
||||
Version string `json:"version"`
|
||||
Tier Tier `json:"tier"`
|
||||
OutputPath string `json:"output_path"`
|
||||
SHA256 string `json:"sha256"`
|
||||
SizeBytes int64 `json:"size_bytes"`
|
||||
FileCount int `json:"file_count"`
|
||||
Signed bool `json:"signed"`
|
||||
Report ScanReport `json:"report"`
|
||||
}
|
||||
|
||||
// PackDirectory validates dir through the unified static security gate, generates
|
||||
// deterministic SHA256SUMS (plus optional SHA256SUMS.sig), and writes a standard
|
||||
// plugin .zip archive ready for local import or GitHub Release publishing.
|
||||
func PackDirectory(dir string, opts PackOptions) (PackResult, error) {
|
||||
absDir, err := filepath.Abs(dir)
|
||||
if err != nil {
|
||||
return PackResult{}, err
|
||||
}
|
||||
st, err := os.Stat(absDir)
|
||||
if err != nil {
|
||||
return PackResult{}, err
|
||||
}
|
||||
if !st.IsDir() {
|
||||
return PackResult{}, fmt.Errorf("%q is not a directory", dir)
|
||||
}
|
||||
|
||||
rawMan, err := os.ReadFile(filepath.Join(absDir, "plugin.json"))
|
||||
if err != nil {
|
||||
return PackResult{}, fmt.Errorf("read plugin.json: %w", err)
|
||||
}
|
||||
var m Manifest
|
||||
if err := json.Unmarshal(rawMan, &m); err != nil {
|
||||
return PackResult{}, fmt.Errorf("parse plugin.json: %w", err)
|
||||
}
|
||||
|
||||
// Run static security gate before creating any output archive.
|
||||
report := ScanDirectory(absDir, opts.HostVersion, ScanOptions{
|
||||
Contract: opts.Contract,
|
||||
RequireChecksums: false,
|
||||
})
|
||||
if report.HardBlocked {
|
||||
var reasons []string
|
||||
for _, f := range report.HardFindings {
|
||||
if f.Target != "" {
|
||||
reasons = append(reasons, fmt.Sprintf("[%s] %s: %s", f.Check, f.Target, f.Message))
|
||||
} else {
|
||||
reasons = append(reasons, fmt.Sprintf("[%s] %s", f.Check, f.Message))
|
||||
}
|
||||
}
|
||||
return PackResult{
|
||||
PluginID: m.ID,
|
||||
Version: m.Version,
|
||||
Tier: report.Tier,
|
||||
Report: report,
|
||||
}, fmt.Errorf("plugin directory blocked by static security gate: %s", strings.Join(reasons, "; "))
|
||||
}
|
||||
|
||||
// Collect all regular files (excluding VCS metadata & old checksums/sigs).
|
||||
type packFile struct {
|
||||
rel string
|
||||
full string
|
||||
hash string
|
||||
mode os.FileMode
|
||||
}
|
||||
var files []packFile
|
||||
if err := filepath.Walk(absDir, func(p string, info os.FileInfo, wErr error) error {
|
||||
if wErr != nil {
|
||||
return wErr
|
||||
}
|
||||
rel, rErr := filepath.Rel(absDir, p)
|
||||
if rErr != nil {
|
||||
return rErr
|
||||
}
|
||||
if rel == "." {
|
||||
return nil
|
||||
}
|
||||
slash := filepath.ToSlash(rel)
|
||||
if info.IsDir() {
|
||||
base := info.Name()
|
||||
if base == ".git" || base == ".svn" || base == "__MACOSX" {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if info.Mode()&os.ModeSymlink != 0 {
|
||||
return fmt.Errorf("symlinks are forbidden in plugin packages: %s", slash)
|
||||
}
|
||||
if slash == "SHA256SUMS" || slash == "SHA256SUMS.sig" || info.Name() == ".DS_Store" || info.Name() == "Thumbs.db" {
|
||||
return nil
|
||||
}
|
||||
h, hErr := fileSHA256Hex(p)
|
||||
if hErr != nil {
|
||||
return hErr
|
||||
}
|
||||
files = append(files, packFile{
|
||||
rel: slash,
|
||||
full: p,
|
||||
hash: h,
|
||||
mode: info.Mode(),
|
||||
})
|
||||
return nil
|
||||
}); err != nil {
|
||||
return PackResult{}, err
|
||||
}
|
||||
sort.Slice(files, func(i, j int) bool { return files[i].rel < files[j].rel })
|
||||
|
||||
var sumsBuilder strings.Builder
|
||||
for _, f := range files {
|
||||
fmt.Fprintf(&sumsBuilder, "%s %s\n", f.hash, f.rel)
|
||||
}
|
||||
sumsBytes := []byte(sumsBuilder.String())
|
||||
|
||||
var sigBytes []byte
|
||||
signed := false
|
||||
if len(opts.SignKey) == ed25519.PrivateKeySize {
|
||||
sig := ed25519.Sign(opts.SignKey, sumsBytes)
|
||||
sigBytes = []byte(base64.StdEncoding.EncodeToString(sig) + "\n")
|
||||
signed = true
|
||||
}
|
||||
|
||||
outPath := strings.TrimSpace(opts.OutputPath)
|
||||
if outPath == "" {
|
||||
outPath = fmt.Sprintf("%s-%s.zip", m.ID, m.Version)
|
||||
}
|
||||
absOut, err := filepath.Abs(outPath)
|
||||
if err != nil {
|
||||
return PackResult{}, err
|
||||
}
|
||||
if err := os.MkdirAll(filepath.Dir(absOut), 0o755); err != nil {
|
||||
return PackResult{}, err
|
||||
}
|
||||
|
||||
tmpOut := absOut + ".tmp"
|
||||
fOut, err := os.Create(tmpOut)
|
||||
if err != nil {
|
||||
return PackResult{}, err
|
||||
}
|
||||
zw := zip.NewWriter(fOut)
|
||||
fixedTime := time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
|
||||
writeBytesEntry := func(name string, data []byte, mode os.FileMode) error {
|
||||
hdr := &zip.FileHeader{
|
||||
Name: name,
|
||||
Method: zip.Deflate,
|
||||
Modified: fixedTime,
|
||||
}
|
||||
hdr.SetMode(mode)
|
||||
w, wErr := zw.CreateHeader(hdr)
|
||||
if wErr != nil {
|
||||
return wErr
|
||||
}
|
||||
_, wErr = w.Write(data)
|
||||
return wErr
|
||||
}
|
||||
|
||||
writeFail := func(cause error) (PackResult, error) {
|
||||
_ = zw.Close()
|
||||
_ = fOut.Close()
|
||||
_ = os.Remove(tmpOut)
|
||||
return PackResult{}, cause
|
||||
}
|
||||
|
||||
for _, pf := range files {
|
||||
hdr := &zip.FileHeader{
|
||||
Name: pf.rel,
|
||||
Method: zip.Deflate,
|
||||
Modified: fixedTime,
|
||||
}
|
||||
hdr.SetMode(pf.mode)
|
||||
w, wErr := zw.CreateHeader(hdr)
|
||||
if wErr != nil {
|
||||
return writeFail(wErr)
|
||||
}
|
||||
src, oErr := os.Open(pf.full)
|
||||
if oErr != nil {
|
||||
return writeFail(oErr)
|
||||
}
|
||||
_, cErr := io.Copy(w, src)
|
||||
_ = src.Close()
|
||||
if cErr != nil {
|
||||
return writeFail(cErr)
|
||||
}
|
||||
}
|
||||
|
||||
if err := writeBytesEntry("SHA256SUMS", sumsBytes, 0o644); err != nil {
|
||||
return writeFail(err)
|
||||
}
|
||||
if signed {
|
||||
if err := writeBytesEntry("SHA256SUMS.sig", sigBytes, 0o644); err != nil {
|
||||
return writeFail(err)
|
||||
}
|
||||
}
|
||||
if err := zw.Close(); err != nil {
|
||||
_ = fOut.Close()
|
||||
_ = os.Remove(tmpOut)
|
||||
return PackResult{}, err
|
||||
}
|
||||
if err := fOut.Close(); err != nil {
|
||||
_ = os.Remove(tmpOut)
|
||||
return PackResult{}, err
|
||||
}
|
||||
if err := os.Rename(tmpOut, absOut); err != nil {
|
||||
_ = os.Remove(tmpOut)
|
||||
return PackResult{}, err
|
||||
}
|
||||
|
||||
zipHash, err := fileSHA256Hex(absOut)
|
||||
if err != nil {
|
||||
return PackResult{}, err
|
||||
}
|
||||
zipStat, err := os.Stat(absOut)
|
||||
if err != nil {
|
||||
return PackResult{}, err
|
||||
}
|
||||
|
||||
return PackResult{
|
||||
PluginID: m.ID,
|
||||
Version: m.Version,
|
||||
Tier: report.Tier,
|
||||
OutputPath: absOut,
|
||||
SHA256: zipHash,
|
||||
SizeBytes: zipStat.Size(),
|
||||
FileCount: len(files),
|
||||
Signed: signed,
|
||||
Report: report,
|
||||
}, nil
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package plugin_test
|
||||
|
||||
import (
|
||||
"crypto/ed25519"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Nwflower/reims-go/internal/plugin"
|
||||
)
|
||||
|
||||
func TestPackDirectorySignAndInstallRoundTrip(t *testing.T) {
|
||||
pub, priv, err := ed25519.GenerateKey(nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
srcDir := t.TempDir()
|
||||
man, _ := json.Marshal(plugin.Manifest{
|
||||
Schema: 1,
|
||||
ID: "official.theme.packtest",
|
||||
Version: "1.0.0",
|
||||
Name: plugin.LocalizedText{ZhCN: "打包测试主题", EnUS: "Pack Test Theme"},
|
||||
Description: plugin.LocalizedText{EnUS: "Clean theme for pack test"},
|
||||
Publisher: "reims-go",
|
||||
License: "Apache-2.0",
|
||||
Contributes: plugin.Contributes{
|
||||
Themes: []plugin.ThemeContribution{{
|
||||
ID: "official.theme.packtest",
|
||||
Name: plugin.LocalizedText{EnUS: "Pack Test"},
|
||||
Stylesheet: "theme.css",
|
||||
}},
|
||||
},
|
||||
})
|
||||
_ = os.WriteFile(filepath.Join(srcDir, "plugin.json"), man, 0o644)
|
||||
_ = os.WriteFile(filepath.Join(srcDir, "theme.css"), []byte(`.rg-p-sidebar { background: var(--surface-sidebar); }`), 0o644)
|
||||
// Junk files that pack must ignore.
|
||||
_ = os.MkdirAll(filepath.Join(srcDir, ".git"), 0o755)
|
||||
_ = os.WriteFile(filepath.Join(srcDir, ".git", "HEAD"), []byte("ref: refs/heads/main\n"), 0o644)
|
||||
_ = os.WriteFile(filepath.Join(srcDir, ".DS_Store"), []byte("junk"), 0o644)
|
||||
|
||||
outZip := filepath.Join(t.TempDir(), "official.theme.packtest-1.0.0.zip")
|
||||
res, err := plugin.PackDirectory(srcDir, plugin.PackOptions{
|
||||
HostVersion: "0.2.8",
|
||||
OutputPath: outZip,
|
||||
SignKey: priv,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("PackDirectory: %v", err)
|
||||
}
|
||||
if !res.Signed || len(res.SHA256) != 64 || res.FileCount != 2 {
|
||||
t.Fatalf("unexpected PackResult: %+v", res)
|
||||
}
|
||||
|
||||
// Verify round-trip install with keyring derived via EnvPluginExtraKeys.
|
||||
extraJSON, _ := json.Marshal([]map[string]string{{
|
||||
"key_id": "org-official",
|
||||
"publisher": "reims-go",
|
||||
"trust": "official",
|
||||
"public_key": hex.EncodeToString(pub),
|
||||
}})
|
||||
t.Setenv(plugin.EnvPluginExtraKeys, string(extraJSON))
|
||||
|
||||
keyring := plugin.DefaultKeyring()
|
||||
if len(keyring) == 0 {
|
||||
t.Fatal("expected DefaultKeyring to load REIMS_GO_PLUGIN_EXTRA_KEYS")
|
||||
}
|
||||
|
||||
layout := plugin.NewPluginsLayout(t.TempDir())
|
||||
installed, err := plugin.InstallArchive(layout, outZip, plugin.PackageInstallOptions{
|
||||
HostVersion: "0.2.8",
|
||||
Keyring: keyring,
|
||||
AllowUnsigned: false,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("InstallArchive packed zip: %v", err)
|
||||
}
|
||||
if installed.Trust != plugin.TrustOfficial {
|
||||
t.Fatalf("trust = %s, want official", installed.Trust)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPackDirectoryRefusesBlockedPackage(t *testing.T) {
|
||||
srcDir := t.TempDir()
|
||||
man, _ := json.Marshal(plugin.Manifest{
|
||||
Schema: 1,
|
||||
ID: "community.theme.badpack",
|
||||
Version: "1.0.0",
|
||||
Name: plugin.LocalizedText{EnUS: "Bad Pack"},
|
||||
})
|
||||
_ = os.WriteFile(filepath.Join(srcDir, "plugin.json"), man, 0o644)
|
||||
_ = os.WriteFile(filepath.Join(srcDir, "sneak.ps1"), []byte(`Write-Host "nope"`), 0o644)
|
||||
|
||||
outZip := filepath.Join(t.TempDir(), "should-not-exist.zip")
|
||||
res, err := plugin.PackDirectory(srcDir, plugin.PackOptions{
|
||||
HostVersion: "0.2.8",
|
||||
OutputPath: outZip,
|
||||
})
|
||||
if err == nil || !strings.Contains(err.Error(), "static security gate") || !res.Report.HardBlocked {
|
||||
t.Fatalf("expected hard gate refusal during pack, got res=%+v err=%v", res, err)
|
||||
}
|
||||
if _, statErr := os.Stat(outZip); !os.IsNotExist(statErr) {
|
||||
t.Fatalf("blocked pack must not create output zip")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultMarketURLsPointToReimsGoOrg(t *testing.T) {
|
||||
t.Setenv(plugin.EnvPluginMarketURL, "")
|
||||
urls := plugin.DefaultMarketURLs()
|
||||
if len(urls) < 2 {
|
||||
t.Fatalf("expected primary + mirror URLs, got %v", urls)
|
||||
}
|
||||
if !strings.Contains(urls[0], "reims-go/plugins") || !strings.Contains(urls[1], "reims-go/plugins") {
|
||||
t.Fatalf("expected reims-go/plugins URLs, got %v", urls)
|
||||
}
|
||||
t.Setenv(plugin.EnvPluginMarketURL, "off")
|
||||
if got := plugin.DefaultMarketURLs(); got != nil {
|
||||
t.Fatalf("expected nil URLs in offline mode, got %v", got)
|
||||
}
|
||||
}
|
||||
@@ -3,15 +3,15 @@
|
||||
"id": "official.lang.zh-tw",
|
||||
"version": "1.0.0",
|
||||
"name": {
|
||||
"zh-CN": "繁体中文(台湾)语言包",
|
||||
"en-US": "Traditional Chinese (Taiwan) Language Pack",
|
||||
"zh-TW": "繁體中文(台灣)語言套件",
|
||||
"zh-HK": "繁體中文(台灣)語言套件"
|
||||
"zh-CN": "繁体中文语言包",
|
||||
"en-US": "Traditional Chinese Language Pack",
|
||||
"zh-TW": "繁體中文語言套件",
|
||||
"zh-HK": "繁體中文語言套件"
|
||||
},
|
||||
"description": {
|
||||
"zh-CN": "为 Reims-Go 提供台湾地区正体中文界面、Win32 安装引导、系统托盘与命令行本地化",
|
||||
"en-US": "Provides Traditional Chinese (Taiwan) UI, Win32 install guide, system tray, and CLI localization",
|
||||
"zh-TW": "為 Reims-Go 提供台灣地區繁體中文介面、Win32 安裝引導、系統匣與命令列本地化"
|
||||
"zh-CN": "为 Reims-Go 提供繁体中文界面、Win32 安装引导、系统托盘与命令行本地化",
|
||||
"en-US": "Provides Traditional Chinese UI, Win32 install guide, system tray, and CLI localization",
|
||||
"zh-TW": "為 Reims-Go 提供繁體中文介面、Win32 安裝引導、系統匣與命令列本地化"
|
||||
},
|
||||
"publisher": "Reims-Go",
|
||||
"license": "Apache-2.0",
|
||||
@@ -22,7 +22,7 @@
|
||||
"locales": [
|
||||
{
|
||||
"locale": "zh-TW",
|
||||
"label": "繁體中文(台灣)",
|
||||
"label": "繁體中文",
|
||||
"fallback": "zh-CN",
|
||||
"files": {
|
||||
"core": "locales/core.json",
|
||||
|
||||
@@ -130,6 +130,13 @@ func (m Manifest) EffectiveRuntimeAPI() string {
|
||||
return DefaultRuntimeAPI
|
||||
}
|
||||
|
||||
// buggyWin32UnicodeInputPatchSHA256 is the SHA-256 of the initial
|
||||
// reims-vgpu-win32-unicode-input.patch shipped in runtime-3731afd-p2/p3,
|
||||
// which compared WM_CHAR.time against WM_KEYDOWN.time and duplicated
|
||||
// physical keystrokes (issue #14). Runtimes built with this patch hash must
|
||||
// NOT advertise the "win32-unicode-input" capability.
|
||||
const buggyWin32UnicodeInputPatchSHA256 = "0b34f7c0ebdf3ca537c7f4523af97967a06924aedba7058dbc978870f561b366"
|
||||
|
||||
// EffectiveCapabilities returns declared capabilities plus inferred legacy
|
||||
// capabilities derived from Patches so callers no longer match raw patch filenames (§5.2).
|
||||
func (m Manifest) EffectiveCapabilities() []string {
|
||||
@@ -156,6 +163,10 @@ func (m Manifest) EffectiveCapabilities() []string {
|
||||
add("win10-compat")
|
||||
case strings.Contains(low, "coroutine-fiber"):
|
||||
add("win32-coroutine-fiber")
|
||||
case strings.Contains(low, "win32-unicode-input"):
|
||||
if sha := strings.TrimSpace(p.SHA256); sha != "" && !strings.EqualFold(sha, buggyWin32UnicodeInputPatchSHA256) {
|
||||
add("win32-unicode-input")
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
|
||||
@@ -39,6 +39,48 @@ func TestKindRegistryAndCapabilities(t *testing.T) {
|
||||
if !m.HasCapability("nested-virt-nonfatal") || !m.HasCapability("win10-startup-ipis") {
|
||||
t.Fatalf("expected inferred capabilities, got %v", m.EffectiveCapabilities())
|
||||
}
|
||||
|
||||
// Buggy p2/p3 win32-unicode-input patch hash (issue #14) and empty hash must
|
||||
// not advertise the win32-unicode-input capability; fixed patch hashes and
|
||||
// explicit capability declarations must advertise it.
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
m Manifest
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
name: "buggy-p3-hash",
|
||||
m: Manifest{Patches: []Patch{{
|
||||
Name: "reims-vgpu-win32-unicode-input.patch",
|
||||
SHA256: buggyWin32UnicodeInputPatchSHA256,
|
||||
}}},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "missing-hash",
|
||||
m: Manifest{Patches: []Patch{{
|
||||
Name: "reims-vgpu-win32-unicode-input.patch",
|
||||
}}},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "fixed-patch-hash",
|
||||
m: Manifest{Patches: []Patch{{
|
||||
Name: "reims-vgpu-win32-unicode-input.patch",
|
||||
SHA256: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
}}},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "explicit-capability",
|
||||
m: Manifest{Capabilities: []string{"win32-unicode-input"}},
|
||||
want: true,
|
||||
},
|
||||
} {
|
||||
if got := tc.m.HasCapability("win32-unicode-input"); got != tc.want {
|
||||
t.Fatalf("%s: HasCapability(win32-unicode-input) = %v, want %v", tc.name, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMultiKindCoexistenceAndCompatibility(t *testing.T) {
|
||||
|
||||
@@ -16,8 +16,8 @@ import (
|
||||
// Version is the current Reims-Go release version. Release builds may override
|
||||
// it at link time with:
|
||||
//
|
||||
// -ldflags "-X github.com/Nwflower/reims-go/internal/version.Version=v0.2.9"
|
||||
var Version = "v0.2.9"
|
||||
// -ldflags "-X github.com/Nwflower/reims-go/internal/version.Version=v0.2.10"
|
||||
var Version = "v0.2.10"
|
||||
|
||||
const (
|
||||
DefaultReleasesRepo = "Nwflower/Reims-Go"
|
||||
|
||||
@@ -297,6 +297,14 @@
|
||||
]
|
||||
},
|
||||
"plugin.doctor.errors": "plugin doctor found errors",
|
||||
"plugin.packed": {
|
||||
"message": "Packed {id}@{ver} -> {path}",
|
||||
"$params": [
|
||||
"id",
|
||||
"ver",
|
||||
"path"
|
||||
]
|
||||
},
|
||||
"plugin.market.stale_warn": "Remote plugin market unreachable; falling back to cached or embedded index",
|
||||
"plugin.market.empty": "No matching plugins found in the market index",
|
||||
"plugin.market.up_to_date": "All installed plugins are up to date",
|
||||
@@ -793,7 +801,7 @@
|
||||
"cli.usage.cmd_inst_dl": " installer download <ver> Download an offline installer (26.7.1, tahoe, latest; Ctrl+C pauses, rerun resumes)",
|
||||
"cli.usage.cmd_inst_cached": " installer cached List downloaded installers and the space they take",
|
||||
"cli.usage.cmd_inst_del": " installer delete <name> Delete a downloaded installer (refused if in use or downloading)",
|
||||
"cli.usage.cmd_plugin": " plugin list|search|install|update|link|enable|disable|remove|info|doctor|locale|run\n Manage built-in extensions, language packs, plugin market and security checks",
|
||||
"cli.usage.cmd_plugin": " plugin list|search|install|update|pack|link|enable|disable|remove|info|doctor|locale|run\n Manage built-in extensions, language packs, market, packaging and security checks",
|
||||
"cli.usage.cmd_version": " version Show current version",
|
||||
"cli.start.running_in_tray": {
|
||||
"message": "{name} is starting (Reims-Go is running in the tray).",
|
||||
|
||||
@@ -297,6 +297,14 @@
|
||||
]
|
||||
},
|
||||
"plugin.doctor.errors": "插件检查发现错误",
|
||||
"plugin.packed": {
|
||||
"message": "已打包插件 {id}@{ver} -> {path}",
|
||||
"$params": [
|
||||
"id",
|
||||
"ver",
|
||||
"path"
|
||||
]
|
||||
},
|
||||
"plugin.market.stale_warn": "远程插件市场索引暂不可达,已回退至本地缓存/内置索引",
|
||||
"plugin.market.empty": "当前插件市场暂无匹配插件",
|
||||
"plugin.market.up_to_date": "所有已安装插件均已是最新版本",
|
||||
@@ -793,7 +801,7 @@
|
||||
"cli.usage.cmd_inst_dl": " installer download <版本> 下载离线安装包(如 26.7.1、tahoe、latest;Ctrl+C 暂停,再次运行续传)",
|
||||
"cli.usage.cmd_inst_cached": " installer cached 查看已下载的安装包及占用空间",
|
||||
"cli.usage.cmd_inst_del": " installer delete <文件名> 删除已下载的安装包(正在使用或下载中的会被拒绝)",
|
||||
"cli.usage.cmd_plugin": " plugin list|search|install|update|link|enable|disable|remove|info|doctor|locale|run\n 管理内置扩展、语言包、插件市场与静态安全检查",
|
||||
"cli.usage.cmd_plugin": " plugin list|search|install|update|pack|link|enable|disable|remove|info|doctor|locale|run\n 管理内置扩展、语言包、插件市场、打包与静态安全检查",
|
||||
"cli.usage.cmd_version": " version 查看当前版本",
|
||||
"cli.start.running_in_tray": {
|
||||
"message": "{name} 已在启动中(Reims-Go 在托盘运行)。",
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@
|
||||
### 1. `reims-vgpu-win32-unicode-input.patch`
|
||||
- **目标**:`steelbrain/reims-vgpu`(`crates/reims-vgpu-window`:`native/windows.rs`、`native/sdl_thread/ui.rs`)
|
||||
- **根因**:SDL3 窗口层未启用文本输入且仅转发 `0x04..=0xE7` 物理扫描码,扫描码为 0 的 `VK_PACKET` 及 `WM_CHAR`/`WM_UNICHAR`/`WM_IME_CHAR`(宿主机 IME、中文、语音与远程输入)全部被丢弃。
|
||||
- **最小修复**:仅在检测到 `REIMS_GO_INPUT_URL`(限定回环地址)时挂接 `SDL_SetWindowsMessageHook` 异步转发非物理字符,对物理键码路径零影响。
|
||||
- **最小修复**:仅在检测到 `REIMS_GO_INPUT_URL`(限定回环地址)时挂接 `SDL_SetWindowsMessageHook` 异步转发非物理字符;对 `WM_CHAR` 按 `lParam` 硬件扫描码(`scan_code == 0`)过滤(不比对 `msg.time`,避免 `TranslateMessage` 写入当前 `GetTickCount()` 导致物理按键被二次转发),对物理键码路径零影响。
|
||||
|
||||
### 2. `reims-ctl-win32-random-bytes.patch`
|
||||
- **目标**:`steelbrain/reims-vgpu`(`crates/reims-ctl/src/vm.rs:849-864`)
|
||||
|
||||
@@ -37,7 +37,7 @@ index cc456c5..4ce46a6 100644
|
||||
};
|
||||
use windows_sys::Win32::Foundation::{FALSE, HWND, RPC_E_CHANGED_MODE, S_FALSE, S_OK, TRUE};
|
||||
use windows_sys::Win32::System::Com::{
|
||||
@@ -62,6 +69,198 @@ use crate::capture::HostOs;
|
||||
@@ -62,6 +69,203 @@ use crate::capture::HostOs;
|
||||
/// The OS whose names the title gives the release chord's keys: Ctrl+Alt+Win (the module doc).
|
||||
pub(super) const HOST_OS: HostOs = HostOs::Windows;
|
||||
|
||||
@@ -51,9 +51,9 @@ index cc456c5..4ce46a6 100644
|
||||
+ /// WPARAM.
|
||||
+ w_param: usize,
|
||||
+ /// LPARAM.
|
||||
+ _l_param: isize,
|
||||
+ l_param: isize,
|
||||
+ /// Message timestamp (GetMessageTime).
|
||||
+ time: u32,
|
||||
+ _time: u32,
|
||||
+ /// Cursor position (POINT).
|
||||
+ _pt: [i32; 2],
|
||||
+}
|
||||
@@ -81,8 +81,6 @@ index cc456c5..4ce46a6 100644
|
||||
+thread_local! {
|
||||
+ /// Whether the most recent WM_KEYDOWN was unmapped (VK_PACKET or VK_PROCESSKEY).
|
||||
+ static LAST_KEY_UNMAPPED: Cell<bool> = const { Cell::new(false) };
|
||||
+ /// Timestamp of the most recent normal WM_KEYDOWN that SDL translates to a USB key.
|
||||
+ static LAST_MAPPED_KEY_TIME: Cell<u32> = const { Cell::new(0) };
|
||||
+}
|
||||
+
|
||||
+/// Parses a loopback http://127.0.0.1:<port><path> endpoint from REIMS_GO_INPUT_URL.
|
||||
@@ -148,20 +146,27 @@ index cc456c5..4ce46a6 100644
|
||||
+ match msg.message {
|
||||
+ WM_KEYDOWN | WM_SYSKEYDOWN => {
|
||||
+ let vk = (msg.w_param & 0xFFFF) as u16;
|
||||
+ if vk == VK_PACKET || vk == VK_PROCESSKEY {
|
||||
+ LAST_KEY_UNMAPPED.set(true);
|
||||
+ } else {
|
||||
+ LAST_KEY_UNMAPPED.set(false);
|
||||
+ LAST_MAPPED_KEY_TIME.set(msg.time);
|
||||
+ LAST_KEY_UNMAPPED.set(vk == VK_PACKET || vk == VK_PROCESSKEY);
|
||||
+ true
|
||||
+ }
|
||||
+ WM_CHAR => {
|
||||
+ let unit = (msg.w_param & 0xFFFF) as u16;
|
||||
+ let scan_code = (msg.l_param.cast_unsigned() >> 16) & 0xFF;
|
||||
+ // Any WM_CHAR carrying a hardware scan code came from TranslateMessage on
|
||||
+ // a physical WM_KEYDOWN that SDL already forwarded as a USB HID key.
|
||||
+ // Never compare msg.time against WM_KEYDOWN.time: TranslateMessage stamps
|
||||
+ // WM_CHAR with the current GetTickCount(), not the keydown's time.
|
||||
+ let non_physical = scan_code == 0
|
||||
+ && (LAST_KEY_UNMAPPED.get() || unit >= 0x80 || msg.l_param == 0);
|
||||
+ if non_physical && (unit >= 0x20 || unit == 0x0D || unit == 0x09) {
|
||||
+ enqueue_utf16(unit);
|
||||
+ return false;
|
||||
+ }
|
||||
+ true
|
||||
+ }
|
||||
+ WM_CHAR | WM_IME_CHAR => {
|
||||
+ WM_IME_CHAR => {
|
||||
+ let unit = (msg.w_param & 0xFFFF) as u16;
|
||||
+ let non_physical = unit >= 0x80
|
||||
+ || LAST_KEY_UNMAPPED.get()
|
||||
+ || msg.time != LAST_MAPPED_KEY_TIME.get();
|
||||
+ if non_physical && (unit >= 0x20 || unit == 0x0D || unit == 0x09) {
|
||||
+ if unit >= 0x20 || unit == 0x0D || unit == 0x09 {
|
||||
+ enqueue_utf16(unit);
|
||||
+ return false;
|
||||
+ }
|
||||
@@ -219,7 +224,7 @@ index cc456c5..4ce46a6 100644
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/// Sends a minimal HTTP/1.1 POST with UTF-8 ext to the local host bridge.
|
||||
+/// Sends a minimal HTTP/1.1 POST with UTF-8 text to the local host bridge.
|
||||
+fn post_loopback_text(addr: SocketAddr, path: &str, token: &str, text: &str) {
|
||||
+ let Ok(mut stream) = TcpStream::connect_timeout(&addr, Duration::from_millis(500)) else {
|
||||
+ return;
|
||||
|
||||
Reference in new issue
Block a user