fix(desktop): apply shared theme tokens to update dialogs
This commit is contained in:
1 parent
c4f49704a1
commit
a50412d71b
22 files changed
+226
-47
No files matched your search
@@ -57,8 +57,8 @@
|
||||
en: 9b90a2651a6d2b52
|
||||
zh: 86d4d9c4358aad80
|
||||
/deepseek-harness-desktop/updates:
|
||||
en: 98f65a8aa5056623
|
||||
zh: 8ff5d1e2880188b0
|
||||
en: 3b6b72608010e60c
|
||||
zh: 2e3de2af38bb07bc
|
||||
/deepseek-harness-desktop/updates/local-desktop-settings:
|
||||
en: 2e57457c44c85b5f
|
||||
zh: 5b8510a3dc4c6c9d
|
||||
|
||||
@@ -273,6 +273,8 @@ On macOS, installation preparation waits for the product window to leave fullscr
|
||||
|
||||
Ordinary update dialogs use an isolated shell-origin WebContentsView inside the product window, so loading a result does not raise a separate native window. The document remains available before the workspace Host is ready. While attached, it intercepts product keyboard input; closing it releases its listeners and view. Windows caption controls remain above the view.
|
||||
|
||||
Ordinary update dialogs, the Windows first-close notice, and mandatory-update documents share the UI design tokens bundled with the shell. Before displaying a card, each document resolves Electron's application theme through `prefers-color-scheme` and updates its dark-theme attribute when the palette changes. Explicit light/dark preferences and system appearance share this path; the isolated document keeps its background transparent.
|
||||
|
||||
Packaged applications check fixed Nightly asynchronously at startup. Ordinary polling uses a ten-minute base interval with independently sampled ±20% jitter. Each check failure doubles the base delay up to one hour; success resets it. The randomized delay is bounded by that cap and starts after all joined callers settle. Foreground and system-resume checks respect the same monotonic deadline; the localized Check for Updates menu item, including in the Windows caption's Application menu, runs immediately and joins an in-flight check. A newly received mandatory policy also requests an immediate feed check. Automatic checks never open dialogs or download packages. Manual checks display checking, failure, or no-update feedback with the installed version. Ordinary update dialogs fade in and out in place; consecutive prompts replace the card content and reset its scroll position while retaining the dark translucent backdrop without blurring the parent page.
|
||||
|
||||
`DSH_DESKTOP_UPDATE_CHECK_INTERVAL_MS` configures the ordinary base interval, and `DSH_DESKTOP_UPDATE_CHECK_MAX_BACKOFF_MS` configures the cap; both accept integer milliseconds from 1000 through 2147483647, with the cap at least the interval. An omitted cap defaults to the larger of one hour and the interval. `DSH_DESKTOP_UPDATE_CHECK_JITTER` sets the fractional jitter from 0 through 1, defaulting to `0.2`; the final delay is at least one second and never exceeds the cap. These settings do not change mandatory-policy polling or authorize download retries.
|
||||
|
||||
@@ -273,6 +273,8 @@ macOS 在安装准备阶段等待产品主窗口退出全屏,再显示重启
|
||||
|
||||
普通更新弹窗使用产品窗口内、隔离的壳静态源 WebContentsView,检查结果加载不会抬升独立的原生窗口。工作区 Host 尚未就绪时,该文档仍可使用。视图挂载期间拦截产品键盘输入,关闭时释放监听和视图。Windows 标题栏控件位于视图上方。
|
||||
|
||||
普通更新弹窗、Windows 首次关闭提示和强更文档共用随壳打包的 UI design token。各文档在显示卡片前通过 `prefers-color-scheme` 解析 Electron 的应用主题,配色变化时同步暗色主题属性。明确选择浅色/暗色及跟随系统共用此路径,隔离文档保持透明背景。
|
||||
|
||||
打包应用在启动后异步检查固定 Nightly。常规轮询以十分钟为基础间隔,每次独立采样 ±20% 的随机抖动。每次检查失败将基础延迟翻倍,上限为一小时;成功后重置。随机延迟不超过该上限,并从全部复用调用结算后开始计时。本地化的“检查更新…”菜单项(Windows 可从顶栏的“应用”菜单进入)立即执行,并复用正在进行的检查。回到前台和系统恢复时遵守相同的单调时钟截止时间。新收到的强更策略也会立即请求检查更新清单。自动检查从不弹窗或下载安装包。手动检查显示正在检查、失败或包含已安装版本号的无更新反馈。常规更新弹窗原位渐入渐出;连续弹窗替换卡片内容并重置其滚动位置,保留黑色半透明蒙层,不模糊父页面。
|
||||
|
||||
`DSH_DESKTOP_UPDATE_CHECK_INTERVAL_MS` 配置常规基础间隔,`DSH_DESKTOP_UPDATE_CHECK_MAX_BACKOFF_MS` 配置上限;两者均接受 1000 至 2147483647 的整数毫秒数,且上限不能小于间隔。省略上限时取一小时与间隔中的较大值。`DSH_DESKTOP_UPDATE_CHECK_JITTER` 配置 0 至 1 的抖动比例,默认 `0.2`;最终延迟至少一秒,且不超过上限。这些配置不改变强更策略轮询,也不授权下载重试。
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#status, #version { margin-top: 12px; color: #555962; }
|
||||
#status, #version { margin-top: 12px; color: var(--dsw-alias-label-secondary); }
|
||||
#status:empty, #version:empty { display: none; }
|
||||
#error { margin-top: 12px; color: #d93025; }
|
||||
#address { display: block; width: 100%; margin-top: 4px; padding: 8px; border: 1px solid #e6e7eb; border-radius: 8px; background: #f5f5f5; font: 12px/20px monospace; color: #555962; overflow-wrap: anywhere; resize: vertical; }
|
||||
#actions button:not(.primary) { min-height: 32px; padding: 5px 8px; color: #555962; background: transparent; }
|
||||
#error { margin-top: 12px; color: var(--dsw-alias-state-error-primary); }
|
||||
#address { display: block; width: 100%; margin-top: 4px; padding: 8px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 8px; background: var(--dsw-alias-bg-layer-2); font: 12px/20px monospace; color: var(--dsw-alias-label-secondary); overflow-wrap: anywhere; resize: vertical; }
|
||||
#actions button:not(.primary) { min-height: 32px; padding: 5px 8px; color: var(--dsw-alias-label-secondary); background: transparent; }
|
||||
#update, #refresh { border-radius: 100px; }
|
||||
#fallback { border-top: 1px solid #e6e7eb; margin-top: 12px; padding-top: 12px; }
|
||||
#fallback p, #manual-copy { font-size: 12px; line-height: 20px; color: #555962; }
|
||||
#copy { min-height: 32px; padding: 3px 0; background: transparent; color: #4d6bfe; font-size: 12px; }
|
||||
#copy-message { color: #d93025 !important; }
|
||||
#fallback { border-top: 1px solid var(--dsw-alias-border-l2); margin-top: 12px; padding-top: 12px; }
|
||||
#fallback p, #manual-copy { font-size: 12px; line-height: 20px; color: var(--dsw-alias-label-secondary); }
|
||||
#copy { min-height: 32px; padding: 3px 0; background: transparent; color: var(--dsw-alias-link); font-size: 12px; }
|
||||
#copy-message { color: var(--dsw-alias-state-error-primary) !important; }
|
||||
#manual-copy { display: block; margin-top: 8px; }
|
||||
#progress { display: block; width: 100%; height: 4px; margin-top: 12px; border: 0; appearance: none; -webkit-appearance: none; background: #e6e7eb; accent-color: #0f1115; }
|
||||
#progress { display: block; width: 100%; height: 4px; margin-top: 12px; border: 0; appearance: none; -webkit-appearance: none; background: var(--dsw-alias-border-l2); accent-color: var(--dsw-alias-button-primary-fill); }
|
||||
|
||||
#progress::-webkit-progress-bar { background: #e6e7eb; }
|
||||
#progress::-webkit-progress-value { background: #0f1115; }
|
||||
#progress::-moz-progress-bar { background: #0f1115; }
|
||||
#progress::-webkit-progress-bar { background: var(--dsw-alias-border-l2); }
|
||||
#progress::-webkit-progress-value { background: var(--dsw-alias-button-primary-fill); }
|
||||
#progress::-moz-progress-bar { background: var(--dsw-alias-button-primary-fill); }
|
||||
@@ -5,10 +5,12 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self'; connect-src 'none'; img-src 'none'">
|
||||
<title></title>
|
||||
<link rel="stylesheet" href="design-platform.css">
|
||||
<link rel="stylesheet" href="update-dialog.css">
|
||||
<link rel="stylesheet" href="mandatory-update.css">
|
||||
</head>
|
||||
<body class="update-dialog">
|
||||
<script src="update-theme.js"></script>
|
||||
<main role="alertdialog" aria-modal="true" aria-labelledby="title" aria-describedby="detail">
|
||||
<header><h1 id="title"></h1></header>
|
||||
<p id="detail"></p>
|
||||
|
||||
@@ -1,28 +1,29 @@
|
||||
:root {
|
||||
color-scheme: light;
|
||||
color-scheme: light dark;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
|
||||
color: #0f1115;
|
||||
background: transparent;
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
body { margin: 0; height: 100vh; display: grid; place-items: center; isolation: isolate; }
|
||||
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: rgb(0 0 0 / 24%); }
|
||||
main { width: min(380px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; padding: 22px 24px 24px; border-radius: 24px; background: #fff; box-shadow: 0 0 1px rgb(0 0 0 / 20%), 0 0 4px rgb(0 0 0 / 2%), 0 12px 32px rgb(0 0 0 / 8%); }
|
||||
body { margin: 0; height: 100vh; display: grid; place-items: center; isolation: isolate; background: transparent; color: var(--dsw-alias-label-primary); color-scheme: light; }
|
||||
body[data-ds-dark-theme] { color-scheme: dark; }
|
||||
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: var(--dsw-alias-bg-mask-1); }
|
||||
main { width: min(380px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; padding: 22px 24px 24px; border-radius: 24px; background: var(--dsw-alias-bg-layer-1); box-shadow: 0 0 1px rgb(0 0 0 / 20%), 0 0 4px rgb(0 0 0 / 2%), 0 12px 32px rgb(0 0 0 / 8%); }
|
||||
header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
|
||||
main:focus { outline: none; }
|
||||
h1 { margin: 0; min-height: 28px; font-size: 16px; font-weight: 500; line-height: 24px; overflow-wrap: anywhere; }
|
||||
p { margin: 0; font-size: 14px; line-height: 22px; white-space: pre-wrap; overflow-wrap: anywhere; }
|
||||
#actions { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; position: sticky; bottom: 0; background: #fff; }
|
||||
button { min-height: 44px; padding: 9px 16px; border: 0; border-radius: 12px; font-family: inherit; font-size: 14px; font-weight: 500; line-height: 22px; cursor: pointer; }
|
||||
.primary { background: #0f1115; color: #fff; }
|
||||
.secondary { background: #f5f5f5; color: inherit; }
|
||||
#actions { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; position: sticky; bottom: 0; background: var(--dsw-alias-bg-layer-1); }
|
||||
button { min-height: 44px; padding: 9px 16px; border: 0; border-radius: 12px; font-family: inherit; font-size: 14px; font-weight: 500; line-height: 22px; color: inherit; cursor: pointer; }
|
||||
.primary { background: var(--dsw-alias-button-primary-fill); color: var(--dsw-alias-label-primary-inverted); }
|
||||
.primary:hover { background: var(--dsw-alias-button-primary-hover); }
|
||||
.secondary { background: var(--dsw-alias-button-primary-dimmed); color: inherit; }
|
||||
.close { display: grid; place-items: center; flex: none; width: 28px; min-height: 28px; padding: 7px; border-radius: 50%; background: transparent; }
|
||||
.close img { width: 14px; height: 14px; }
|
||||
button:hover { filter: brightness(0.95); }
|
||||
button:focus-visible, summary:focus-visible, pre:focus-visible { outline: 2px solid #4d6bfe; outline-offset: 3px; }
|
||||
.close::before { content: ""; width: 14px; height: 14px; background: currentColor; mask: url("update-close.svg") center / contain no-repeat; }
|
||||
.secondary:hover, .close:hover { background: var(--dsw-alias-interactive-bg-hover); }
|
||||
button:focus-visible, summary:focus-visible, pre:focus-visible { outline: 2px solid var(--dsw-alias-link); outline-offset: 3px; }
|
||||
details { margin-top: 12px; font-size: 13px; line-height: 20px; }
|
||||
summary { cursor: pointer; color: #5b6472; }
|
||||
pre { margin: 8px 0 0; padding: 10px; max-height: min(180px, 30vh); overflow: auto; border-radius: 8px; background: #f5f5f5; font: 12px/18px monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
|
||||
summary { cursor: pointer; color: var(--dsw-alias-label-secondary); }
|
||||
pre { margin: 8px 0 0; padding: 10px; max-height: min(180px, 30vh); overflow: auto; border-radius: 8px; background: var(--dsw-alias-bg-layer-2); font: 12px/18px monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
|
||||
button:disabled { opacity: 0.5; cursor: default; }
|
||||
[hidden] { display: none !important; }
|
||||
body.update-dialog { opacity: 0; transition: opacity 150ms ease; }
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self'; connect-src 'none'; img-src 'self'">
|
||||
<title></title>
|
||||
<link rel="stylesheet" href="design-platform.css">
|
||||
<link rel="stylesheet" href="update-dialog.css">
|
||||
</head>
|
||||
<body class="update-dialog">
|
||||
<script src="update-theme.js"></script>
|
||||
<main id="dialog" role="dialog" tabindex="-1" aria-modal="true" aria-labelledby="title" aria-describedby="detail" hidden>
|
||||
<header><h1 id="title"></h1><button id="close" class="close" type="button"><img src="update-close.svg" alt=""></button></header>
|
||||
<header><h1 id="title"></h1><button id="close" class="close" type="button"></button></header>
|
||||
<p id="detail"></p>
|
||||
<details id="technical-details" hidden>
|
||||
<summary id="technical-details-label"></summary>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
/** Shell documents follow Electron's app-resolved palette before rendering their cards. */
|
||||
const palette = window.matchMedia('(prefers-color-scheme: dark)')
|
||||
const applyPalette = () => { document.body.toggleAttribute('data-ds-dark-theme', palette.matches) }
|
||||
applyPalette()
|
||||
palette.addEventListener('change', applyPalette)
|
||||
window.addEventListener('pagehide', () => { palette.removeEventListener('change', applyPalette) }, { once: true })
|
||||
@@ -29,7 +29,7 @@ export async function createInstalledUpdateBuilderConfig(manifest: string, versi
|
||||
directories: { ...config.directories, output: join(run.root, version, 'installer') },
|
||||
extraMetadata: { ...config.extraMetadata, name: `dsh-update-test-${run.id}`, version, main: 'qualification-bootstrap.mjs' },
|
||||
files: [
|
||||
{ from: application, to: '.', filter: ['lib/*.js', 'lib/*.cjs', 'renderer/**/*', 'qualification-bootstrap.mjs', 'installed-update-identity.mjs'] },
|
||||
{ from: application, to: '.', filter: ['lib/*.js', 'lib/*.cjs', 'lib/welcome/design-platform.css', 'renderer/**/*', 'qualification-bootstrap.mjs', 'installed-update-identity.mjs'] },
|
||||
'package.json',
|
||||
...config.files.filter((file): file is string => typeof file === 'string' && file.startsWith('!')),
|
||||
{ from: dsh, to: 'dsh', filter: ['**/*'] },
|
||||
|
||||
@@ -32,7 +32,7 @@ export async function prepareInstalledUpdateApplication(manifest: string, source
|
||||
const modules = (await readdir(join(source, 'lib'), { withFileTypes: true }))
|
||||
.filter(entry => /\.(?:js|cjs)$/u.test(entry.name))
|
||||
if (modules.some(entry => !entry.isFile())) throw new Error('installed update: application modules must be regular files')
|
||||
const paths = [...modules.map(entry => `lib/${entry.name}`), ...await applicationFiles(source, 'renderer')].sort()
|
||||
const paths = [...modules.map(entry => `lib/${entry.name}`), ...await applicationFiles(source, 'renderer'), 'lib/welcome/design-platform.css'].sort()
|
||||
for (const required of ['lib/main.js', 'lib/preload-app.cjs', 'lib/preload-mandatory.cjs', 'lib/preload-update-dialog.cjs']) {
|
||||
if (!paths.includes(required)) throw new Error('installed update: rebuild Desktop before freezing application files')
|
||||
}
|
||||
@@ -76,7 +76,8 @@ export async function verifyInstalledUpdateApplication(root: string): Promise<st
|
||||
if (typeof entry !== 'object' || entry === null || !('path' in entry) || !('sha256' in entry)
|
||||
|| typeof entry.path !== 'string' || typeof entry.sha256 !== 'string'
|
||||
|| entry.path.includes('\\') || entry.path.includes(':') || entry.path.split('/').some(part => ['', '.', '..'].includes(part))
|
||||
|| !/^(?:lib\/[^/]+\.(?:js|cjs)|renderer\/.+|qualification-bootstrap\.mjs|installed-update-identity\.mjs)$/u.test(entry.path)
|
||||
|| (entry.path !== 'lib/welcome/design-platform.css'
|
||||
&& !/^(?:lib\/[^/]+\.(?:js|cjs)|renderer\/.+|qualification-bootstrap\.mjs|installed-update-identity\.mjs)$/u.test(entry.path))
|
||||
|| !/^[a-f0-9]{64}$/u.test(entry.sha256) || paths.has(entry.path)) {
|
||||
throw new Error('installed update: invalid application file inventory')
|
||||
}
|
||||
@@ -87,7 +88,7 @@ export async function verifyInstalledUpdateApplication(root: string): Promise<st
|
||||
}
|
||||
const actual = await applicationFiles(join(directory, 'files'))
|
||||
if (actual.length !== paths.size || actual.some(path => !paths.has(path))
|
||||
|| ['lib/main.js', 'qualification-bootstrap.mjs', 'installed-update-identity.mjs'].some(path => !paths.has(path))) {
|
||||
|| ['lib/main.js', 'lib/welcome/design-platform.css', 'qualification-bootstrap.mjs', 'installed-update-identity.mjs'].some(path => !paths.has(path))) {
|
||||
throw new Error('installed update: frozen application inventory has missing or additional files')
|
||||
}
|
||||
return join(directory, 'files')
|
||||
|
||||
@@ -668,7 +668,8 @@ async function main(): Promise<void> {
|
||||
protocol.handle(SCHEME, (request) => {
|
||||
const url = new URL(request.url)
|
||||
// Shell-owned documents live in the application bundle and never pass through the Host.
|
||||
if (url.hostname === 'shell') return serveWebDocument(request, join(app.getAppPath(), 'renderer'))
|
||||
if (url.hostname === 'shell') return serveWebDocument(request, join(app.getAppPath(),
|
||||
url.pathname === '/design-platform.css' ? 'lib/welcome' : 'renderer'))
|
||||
if (url.hostname === 'app') {
|
||||
if (url.pathname === '/' || url.pathname === '/index.html' || url.pathname.startsWith('/assets/')
|
||||
|| ['/favicon.svg', '/manifest.webmanifest'].includes(url.pathname)) {
|
||||
|
||||
@@ -9,8 +9,11 @@
|
||||
en: 94559f431b0b2151
|
||||
zh: 1a22166a2bc59686
|
||||
/desktop-local-update-verification/table-of-contents:
|
||||
en: a5edee063916cd27
|
||||
zh: 7a5286350ff09e58
|
||||
en: 86afdf78fa613876
|
||||
zh: 66fad143d99e999f
|
||||
/desktop-local-update-verification/update-dialog-themes:
|
||||
en: 5efb8e1e06763314
|
||||
zh: 07fcab120f2ee6e1
|
||||
/desktop-local-update-verification/native-overlay-visibility:
|
||||
en: 6f4de4503748f3e2
|
||||
zh: 648370375f16e463
|
||||
|
||||
@@ -10,11 +10,24 @@ Installed qualification can opt into `DSH_DESKTOP_UPDATE_JOURNAL_DIR`, an absolu
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Update dialog themes](#verification-theme)
|
||||
- [Native overlay visibility](#verification-overlay)
|
||||
- [Evidence](#verification-evidence)
|
||||
- [Manual walkthrough](#verification-interactive)
|
||||
- [Open verification](#verification-open)
|
||||
|
||||
<a id="verification-theme"></a>
|
||||
|
||||
## Update dialog themes
|
||||
|
||||
After `pnpm --dir apps/desktop run build`, run the real Electron palette fixture on macOS:
|
||||
|
||||
```sh
|
||||
apps/desktop/.desktop-build/targets/mac-arm64/electron/Electron.app/Contents/MacOS/Electron apps/desktop/tests/fixtures/update-theme.mjs
|
||||
```
|
||||
|
||||
The fixture creates a private profile, loads the production shell HTML, sandboxed preloads, renderer scripts, and bundled design tokens, and substitutes only fixed IPC status responses. Its 12 cases cover ordinary and mandatory documents starting in light/dark mode, switching while open, and following system appearance. It checks transparent document backgrounds, surface/text/button/mask colors, and the ordinary close icon, then writes four screenshots and `result.json` to `.desktop-build/qualification/update-theme-*`. It does not start a Host, download updates, run an installer, or qualify Windows native rendering. The first-close notice shares the ordinary document's CSS and theme script.
|
||||
|
||||
<a id="verification-overlay"></a>
|
||||
|
||||
## Native overlay visibility
|
||||
|
||||
@@ -10,11 +10,24 @@
|
||||
|
||||
## 目录
|
||||
|
||||
- [更新弹窗主题](#verification-theme)
|
||||
- [原生浮层可见性](#verification-overlay)
|
||||
- [验证证据](#verification-evidence)
|
||||
- [手动演练](#verification-interactive)
|
||||
- [待验证事项](#verification-open)
|
||||
|
||||
<a id="verification-theme"></a>
|
||||
|
||||
## 更新弹窗主题
|
||||
|
||||
执行 `pnpm --dir apps/desktop run build` 后,在 macOS 上运行真实 Electron 配色夹具:
|
||||
|
||||
```sh
|
||||
apps/desktop/.desktop-build/targets/mac-arm64/electron/Electron.app/Contents/MacOS/Electron apps/desktop/tests/fixtures/update-theme.mjs
|
||||
```
|
||||
|
||||
夹具创建独立 profile,加载生产壳 HTML、sandboxed preload、渲染脚本及打包的 design token,仅替换固定 IPC 状态响应。12 个用例覆盖普通和强更文档的浅色/暗色初始状态、打开时切换及跟随系统。它检查文档背景透明、卡片/文字/按钮/遮罩配色及普通弹窗关闭图标,并将四张截图和 `result.json` 写入 `.desktop-build/qualification/update-theme-*`。它不启动 Host、不下载更新、不运行安装器,也不验证 Windows 原生渲染。首次关闭提示共用普通文档的 CSS 和主题脚本。
|
||||
|
||||
<a id="verification-overlay"></a>
|
||||
|
||||
## 原生浮层可见性
|
||||
|
||||
+2
-2
@@ -231,9 +231,9 @@ async function main() {
|
||||
protocol.handle('dsh-app', async request => {
|
||||
if (new URL(request.url).hostname === 'app') return new Response('<!doctype html><title>Updater qualification</title>', { headers: { 'content-type': 'text/html' } })
|
||||
const path = new URL(request.url).pathname.slice(1)
|
||||
assert.ok(['mandatory-update-frame.js', 'mandatory-update.html', 'mandatory-update.js', 'mandatory-update.css', 'update-dialog.css'].includes(path))
|
||||
assert.ok(['design-platform.css', 'update-theme.js', 'mandatory-update-frame.js', 'mandatory-update.html', 'mandatory-update.js', 'mandatory-update.css', 'update-dialog.css'].includes(path))
|
||||
const mime = path.endsWith('.js') ? 'text/javascript' : path.endsWith('.css') ? 'text/css' : 'text/html'
|
||||
return new Response(await readFile(new URL(`../../renderer/${path}`, import.meta.url)), { headers: { 'content-type': mime } })
|
||||
return new Response(await readFile(new URL(`${path === 'design-platform.css' ? '../../lib/welcome' : '../../renderer'}/${path}`, import.meta.url)), { headers: { 'content-type': mime } })
|
||||
})
|
||||
const parent = new BrowserWindow({ show: true, width: 900, height: 650, webPreferences: { preload: fileURLToPath(new URL('../../lib/preload-app.cjs', import.meta.url)), sandbox: true, contextIsolation: true } })
|
||||
await parent.loadURL('dsh-app://app/')
|
||||
|
||||
+6
-3
@@ -4,7 +4,7 @@ import { once } from 'node:events'
|
||||
import { access, readFile, writeFile } from 'node:fs/promises'
|
||||
import { join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { app, BrowserWindow, protocol } from 'electron'
|
||||
import { app, BrowserWindow, nativeTheme, protocol } from 'electron'
|
||||
import { DesktopUpdateDialog } from '../../lib/types/update-dialog.js'
|
||||
import { DesktopBackgroundNotice } from '../../lib/types/background-notice.js'
|
||||
import { desktopUpdateReadyConfirmation, resolveDesktopLocale } from '../../lib/types/locale.js'
|
||||
@@ -20,15 +20,17 @@ async function rendered(window) {
|
||||
|
||||
/** Exercise cancellation and explicit installation through the production preload and renderer. */
|
||||
export async function qualifyUpdateDialogs(root, fixture) {
|
||||
const theme = nativeTheme.themeSource
|
||||
nativeTheme.themeSource = 'light'
|
||||
const locale = resolveDesktopLocale('zh-CN')
|
||||
const messages = locale.messages
|
||||
const screenshots = []
|
||||
protocol.handle('dsh-app', async request => {
|
||||
const name = new URL(request.url).pathname.slice(1)
|
||||
assert.ok(['update-dialog.html', 'update-dialog.js', 'update-dialog.css', 'update-close.svg'].includes(name))
|
||||
assert.ok(['design-platform.css', 'update-theme.js', 'update-dialog.html', 'update-dialog.js', 'update-dialog.css', 'update-close.svg'].includes(name))
|
||||
const mime = name.endsWith('.js') ? 'text/javascript' : name.endsWith('.css') ? 'text/css'
|
||||
: name.endsWith('.svg') ? 'image/svg+xml' : 'text/html'
|
||||
return new Response(await readFile(new URL(`../../renderer/${name}`, import.meta.url)), { headers: { 'content-type': mime } })
|
||||
return new Response(await readFile(new URL(`${name === 'design-platform.css' ? '../../lib/welcome' : '../../renderer'}/${name}`, import.meta.url)), { headers: { 'content-type': mime } })
|
||||
})
|
||||
const parent = new BrowserWindow({ show: true, width: 900, height: 650 })
|
||||
const dialogs = new DesktopUpdateDialog(fileURLToPath(new URL('../../lib/preload-update-dialog.cjs', import.meta.url)), locale)
|
||||
@@ -161,5 +163,6 @@ export async function qualifyUpdateDialogs(root, fixture) {
|
||||
dialogs.dispose()
|
||||
parent.destroy()
|
||||
protocol.unhandle('dsh-app')
|
||||
nativeTheme.themeSource = theme
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
/** Real Chromium qualification of shared shell tokens and app-resolved palette changes. */
|
||||
import assert from 'node:assert/strict'
|
||||
import { mkdirSync, mkdtempSync } from 'node:fs'
|
||||
import { readFile, writeFile } from 'node:fs/promises'
|
||||
import { join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { app, BrowserWindow, ipcMain, nativeTheme, protocol } from 'electron'
|
||||
import { resolveDesktopLocale } from '../../lib/types/locale.js'
|
||||
import { UPDATE_DIALOG_IPC } from '../../lib/types/update-dialog.js'
|
||||
import { MANDATORY_IPC } from '../../lib/types/mandatory-update-ipc.js'
|
||||
|
||||
const directory = fileURLToPath(new URL('../../.desktop-build/qualification/', import.meta.url))
|
||||
mkdirSync(directory, { recursive: true })
|
||||
const root = mkdtempSync(join(directory, 'update-theme-'))
|
||||
app.setPath('userData', root)
|
||||
protocol.registerSchemesAsPrivileged([{ scheme: 'dsh-app', privileges: { standard: true, secure: true, supportFetchAPI: true } }])
|
||||
app.on('window-all-closed', () => {})
|
||||
|
||||
async function main() {
|
||||
await app.whenReady()
|
||||
const original = nativeTheme.themeSource
|
||||
const locale = resolveDesktopLocale('en')
|
||||
const results = []
|
||||
const windows = []
|
||||
const deadline = setTimeout(() => { console.error('Theme qualification deadline exceeded'); app.exit(1) }, 30000)
|
||||
protocol.handle('dsh-app', async request => {
|
||||
const name = new URL(request.url).pathname.slice(1)
|
||||
const file = new URL(`${name === 'design-platform.css' ? '../../lib/welcome' : '../../renderer'}/${name}`, import.meta.url)
|
||||
const mime = name.endsWith('.css') ? 'text/css' : name.endsWith('.js') ? 'text/javascript'
|
||||
: name.endsWith('.svg') ? 'image/svg+xml' : 'text/html'
|
||||
return new Response(await readFile(file), { headers: { 'content-type': mime } })
|
||||
})
|
||||
ipcMain.handle(UPDATE_DIALOG_IPC.status, () => ({ revision: 1, locale: locale.id,
|
||||
title: 'Check for updates', message: 'Update ready', detail: 'Shell palette qualification',
|
||||
buttons: ['Install', 'Later'], cancelId: 1, closeLabel: 'Close', technicalDetails: 'Details', technicalDetailsLabel: 'Details' }))
|
||||
ipcMain.handle(MANDATORY_IPC.status, () => ({ locale, policy: { blocking: true, checking: false },
|
||||
update: { phase: 'error', failedOperation: 'download', version: '1.0.0', technicalDetails: 'Details' }, deferred: false }))
|
||||
try {
|
||||
assert.equal(await readFile(new URL('../../lib/welcome/design-platform.css', import.meta.url), 'utf8'),
|
||||
await readFile(new URL('../../../../packages/client/ui-theme/src/styles/design-platform.css', import.meta.url), 'utf8'))
|
||||
for (const document of ['update-dialog', 'mandatory-update']) {
|
||||
for (const initial of ['light', 'dark']) {
|
||||
nativeTheme.themeSource = initial
|
||||
const window = new BrowserWindow({ show: true, width: 600, height: 650,
|
||||
webPreferences: { preload: fileURLToPath(new URL(`../../lib/preload-${document === 'update-dialog' ? 'update-dialog' : 'mandatory'}.cjs`, import.meta.url)),
|
||||
contextIsolation: true, sandbox: true, nodeIntegration: false } })
|
||||
windows.push(window)
|
||||
await window.loadURL(`dsh-app://shell/${document}.html`)
|
||||
for (const source of [initial, initial === 'light' ? 'dark' : 'light', 'system']) {
|
||||
nativeTheme.themeSource = source
|
||||
const dark = nativeTheme.shouldUseDarkColors
|
||||
const colors = await window.webContents.executeJavaScript(`new Promise((resolve, reject) => {
|
||||
const dark = ${dark};
|
||||
const deadline = setTimeout(() => { observer.disconnect(); reject(new Error('Palette did not settle')); }, 10000);
|
||||
const observer = new MutationObserver(check);
|
||||
function check() {
|
||||
if (!document.body.classList.contains('visible') || document.body.hasAttribute('data-ds-dark-theme') !== dark) return;
|
||||
observer.disconnect(); clearTimeout(deadline);
|
||||
const card = getComputedStyle(document.querySelector('main'));
|
||||
const primary = getComputedStyle(document.querySelector('.primary'));
|
||||
resolve({ dark, surface: card.backgroundColor, label: card.color, primary: primary.backgroundColor,
|
||||
primaryLabel: primary.color, body: getComputedStyle(document.body).backgroundColor,
|
||||
mask: getComputedStyle(document.body, '::before').backgroundColor,
|
||||
close: document.querySelector('.close') ? getComputedStyle(document.querySelector('.close'), '::before').backgroundColor : null });
|
||||
}
|
||||
observer.observe(document.body, { attributes: true }); check();
|
||||
})`)
|
||||
assert.deepEqual(colors, { dark, surface: dark ? 'rgb(35, 35, 36)' : 'rgb(255, 255, 255)',
|
||||
label: dark ? 'rgb(249, 250, 251)' : 'rgb(15, 17, 21)',
|
||||
primary: dark ? 'rgb(249, 250, 251)' : 'rgb(15, 17, 21)',
|
||||
primaryLabel: dark ? 'rgb(53, 54, 56)' : 'rgb(255, 255, 255)', body: 'rgba(0, 0, 0, 0)',
|
||||
mask: dark ? 'rgba(0, 0, 0, 0.5)' : 'rgba(0, 0, 0, 0.24)',
|
||||
close: document === 'update-dialog' ? dark ? 'rgb(249, 250, 251)' : 'rgb(15, 17, 21)' : null })
|
||||
results.push({ document, initial, source, ...colors })
|
||||
if (source === initial) {
|
||||
await window.webContents.executeJavaScript('Promise.all(document.getAnimations().map(animation => animation.finished))')
|
||||
await writeFile(join(root, `${document}-${initial}.png`), (await window.webContents.capturePage()).toPNG())
|
||||
}
|
||||
}
|
||||
window.destroy()
|
||||
}
|
||||
}
|
||||
await writeFile(join(root, 'result.json'), JSON.stringify(results, null, 2) + '\n')
|
||||
console.log(`Update theme qualification passed (${results.length} cases): ${root}`)
|
||||
} finally {
|
||||
clearTimeout(deadline)
|
||||
for (const window of windows) if (!window.isDestroyed()) window.destroy()
|
||||
ipcMain.removeHandler(UPDATE_DIALOG_IPC.status)
|
||||
ipcMain.removeHandler(MANDATORY_IPC.status)
|
||||
protocol.unhandle('dsh-app')
|
||||
nativeTheme.themeSource = original
|
||||
}
|
||||
}
|
||||
void main().then(() => app.exit(0), error => { console.error(error); app.exit(1) })
|
||||
@@ -35,6 +35,8 @@ async function fixture<T>(body: (manifest: string, source: string) => Promise<T>
|
||||
await prepareInstalledUpdateBootstrap(manifest)
|
||||
const source = join(root, 'app')
|
||||
await mkdir(join(source, 'lib'), { recursive: true })
|
||||
await mkdir(join(source, 'lib/welcome'), { recursive: true })
|
||||
await writeFile(join(source, 'lib/welcome/design-platform.css'), 'body { --fixture-token: white; }\n')
|
||||
await mkdir(join(source, 'renderer'))
|
||||
for (const file of ['main.js', 'preload-app.cjs', 'preload-mandatory.cjs', 'preload-update-dialog.cjs']) {
|
||||
await writeFile(join(source, 'lib', file), '// inert fixture\n')
|
||||
@@ -57,19 +59,23 @@ describe('installed-update application inputs and builder configuration', () =>
|
||||
.toMatchObject({ dependenciesFrozen: false, signed: false, bootTested: false })
|
||||
const directory = await verifyInstalledUpdateApplication(join(manifest, '..'))
|
||||
expect((await readdir(directory)).sort()).toEqual(['installed-update-identity.mjs', 'lib', 'qualification-bootstrap.mjs', 'renderer'])
|
||||
expect(await readFile(join(directory, 'lib/welcome/design-platform.css'), 'utf8')).toBe('body { --fixture-token: white; }\n')
|
||||
await writeFile(join(source, 'lib/main.js'), '// later checkout\n')
|
||||
expect(await readFile(join(directory, 'lib/main.js'), 'utf8')).toBe('// inert fixture\n')
|
||||
await expect(prepareInstalledUpdateApplication(manifest, source)).rejects.toMatchObject({ code: 'EEXIST' })
|
||||
})
|
||||
})
|
||||
|
||||
it.each(['modified', 'added', 'missing'] as const)('rejects %s frozen application bytes', async (failure) => {
|
||||
it.each([
|
||||
['modified', 'lib/main.js'], ['added', 'lib/unrecorded.js'], ['missing', 'lib/main.js'],
|
||||
['modified', 'lib/welcome/design-platform.css'], ['missing', 'lib/welcome/design-platform.css'],
|
||||
] as const)('rejects %s frozen application bytes in %s', async (failure, file) => {
|
||||
await fixture(async (manifest, source) => {
|
||||
await prepareInstalledUpdateApplication(manifest, source)
|
||||
const root = join(manifest, '..')
|
||||
const directory = await verifyInstalledUpdateApplication(root)
|
||||
if (failure === 'missing') await rm(join(directory, 'lib/main.js'))
|
||||
else await writeFile(join(directory, failure === 'added' ? 'lib/unrecorded.js' : 'lib/main.js'), '// invalid\n')
|
||||
if (failure === 'missing') await rm(join(directory, file))
|
||||
else await writeFile(join(directory, file), '// invalid\n')
|
||||
await expect(verifyInstalledUpdateApplication(root)).rejects.toThrow()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -55,6 +55,8 @@ async function fixture(body: (context: {
|
||||
await prepareInstalledUpdateBootstrap(manifest)
|
||||
const source = join(root, 'source')
|
||||
await mkdir(join(source, 'lib'), { recursive: true })
|
||||
await mkdir(join(source, 'lib/welcome'), { recursive: true })
|
||||
await writeFile(join(source, 'lib/welcome/design-platform.css'), 'body { --fixture-token: white; }\n')
|
||||
await mkdir(join(source, 'renderer'))
|
||||
for (const name of ['main.js', 'preload-app.cjs', 'preload-mandatory.cjs', 'preload-update-dialog.cjs']) {
|
||||
await writeFile(join(source, 'lib', name), '// inert fixture\n')
|
||||
@@ -104,7 +106,7 @@ describe('installed update archive contents', () => {
|
||||
it.each(versions)('reads real ASAR and runtime inventories for %s without claiming installation', async (version) => {
|
||||
await fixture(async ({ manifest, payload }) => {
|
||||
expect(await verifyInstalledUpdatePackageContent(manifest, version, payload, publisher)).toMatchObject({
|
||||
version, applicationFiles: 7, dependenciesFrozen: false, installed: false,
|
||||
version, applicationFiles: 8, dependenciesFrozen: false, installed: false,
|
||||
resignedExecutables: [join(payload, 'resources/app.asar.unpacked/dsh/tool.exe')],
|
||||
})
|
||||
}, version)
|
||||
|
||||
@@ -501,7 +501,7 @@ describe('desktop main startup', () => {
|
||||
for (const [name, mime] of [
|
||||
['update-dialog.html', 'text/html'], ['update-dialog.css', 'text/css'], ['update-dialog.js', 'text/javascript'],
|
||||
['mandatory-update.html', 'text/html'], ['mandatory-update.css', 'text/css'], ['mandatory-update.js', 'text/javascript'],
|
||||
['update-close.svg', 'image/svg+xml'],
|
||||
['update-close.svg', 'image/svg+xml'], ['update-theme.js', 'text/javascript'],
|
||||
] as const) {
|
||||
const response = await handler(new Request(`dsh-app://shell/${name}`))
|
||||
expect(response.status).toBe(200)
|
||||
@@ -530,6 +530,9 @@ describe('desktop main startup', () => {
|
||||
await handler(request)
|
||||
expect(serveWebDocument).toHaveBeenLastCalledWith(request, join('desktop-test-app', 'renderer'))
|
||||
}
|
||||
const tokens = new Request('dsh-app://shell/design-platform.css')
|
||||
await handler(tokens)
|
||||
expect(serveWebDocument).toHaveBeenLastCalledWith(tokens, join('desktop-test-app', 'lib/welcome'))
|
||||
expect(forwardWebRequest).not.toHaveBeenCalled()
|
||||
expect((await handler(new Request('dsh-app://unknown/update-dialog.html'))).status).toBe(404)
|
||||
})
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { runInContext } from 'node:vm'
|
||||
import { JSDOM } from 'jsdom'
|
||||
import { expect, it, vi } from 'vitest'
|
||||
|
||||
it.each([false, true])('applies the initial app palette before the card and follows changes (dark=%s)', (dark) => {
|
||||
const dom = new JSDOM('<body></body>', { runScripts: 'outside-only' })
|
||||
const palette = Object.assign(new dom.window.EventTarget(), { matches: dark, media: '(prefers-color-scheme: dark)',
|
||||
onchange: null, addListener: vi.fn(), removeListener: vi.fn() })
|
||||
const remove = vi.spyOn(palette, 'removeEventListener')
|
||||
dom.window.matchMedia = vi.fn(() => palette)
|
||||
try {
|
||||
runInContext(readFileSync(new URL('../renderer/update-theme.js', import.meta.url), 'utf8'), dom.getInternalVMContext())
|
||||
expect(dom.window.matchMedia).toHaveBeenCalledWith('(prefers-color-scheme: dark)')
|
||||
expect(dom.window.document.body.hasAttribute('data-ds-dark-theme')).toBe(dark)
|
||||
palette.matches = !dark
|
||||
palette.dispatchEvent(new dom.window.Event('change'))
|
||||
expect(dom.window.document.body.hasAttribute('data-ds-dark-theme')).toBe(!dark)
|
||||
dom.window.dispatchEvent(new dom.window.Event('pagehide'))
|
||||
expect(remove).toHaveBeenCalledWith('change', expect.any(Function))
|
||||
palette.matches = dark
|
||||
palette.dispatchEvent(new dom.window.Event('change'))
|
||||
expect(dom.window.document.body.hasAttribute('data-ds-dark-theme')).toBe(!dark)
|
||||
} finally { dom.window.close() }
|
||||
})
|
||||
@@ -56,7 +56,7 @@ export default defineConfig([
|
||||
plugins: [{
|
||||
name: 'desktop-brand-font',
|
||||
async generateBundle() {
|
||||
for (const name of ['brand-font.css', 'montserrat-regular.woff2', 'montserrat-light.woff2', 'montserrat-medium.woff2', 'Montserrat-OFL.txt']) {
|
||||
for (const name of ['design-platform.css', 'brand-font.css', 'montserrat-regular.woff2', 'montserrat-light.woff2', 'montserrat-medium.woff2', 'Montserrat-OFL.txt']) {
|
||||
this.emitFile({
|
||||
type: 'asset',
|
||||
fileName: name,
|
||||
|
||||
Reference in new issue
Block a user