merge: 同步 main 到 feat/home
Sync source to CNB / Sync Git ref (push) Skipped

This commit is contained in:
AxTps committed 2026-10-20 21:48:33 +08:00
commit 6501eb6aea
48 files changed
+6983 -2812

No files matched your search

+75 -75
View File
@@ -1,77 +1,77 @@
{
"name": "@modrinth/app-frontend",
"private": true,
"version": "1.0.2-beta8",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"tsc:check": "vue-tsc --noEmit",
"lint": "eslint . && prettier --check .",
"fix": "eslint . --fix && prettier --write .",
"intl:extract": "formatjs extract \"src/**/*.{vue,ts,tsx,js,jsx,mts,cts,mjs,cjs}\" --ignore \"**/*.d.ts\" --ignore node_modules --out-file src/locales/en-US/index.json --format crowdin --preserve-whitespace",
"intl:prune-local": "pnpm -w scripts i18n-icu-contract prune-local --scope apps/app-frontend",
"test": "vue-tsc --noEmit && node --test \"src/**/*.test.ts\""
},
"dependencies": {
"@dnd-kit/core": "6.3.1",
"@dnd-kit/utilities": "3.2.2",
"@dnd-kit/vue": "^0.5.0",
"@lobehub/icons-static-svg": "1.94.0",
"@modrinth/api-client": "workspace:^",
"@modrinth/assets": "workspace:*",
"@modrinth/server": "workspace:*",
"@modrinth/ui": "workspace:*",
"@modrinth/utils": "workspace:*",
"@sfirew/minecraft-motd-parser": "^1.1.6",
"@tanstack/vue-query": "5.90.7",
"@tauri-apps/api": "^2.5.0",
"@tauri-apps/plugin-dialog": "^2.2.1",
"@tauri-apps/plugin-fs": "^2.4.5",
"@tauri-apps/plugin-http": "~2.5.7",
"@tauri-apps/plugin-opener": "^2.2.6",
"@tauri-apps/plugin-os": "^2.2.1",
"@tauri-apps/plugin-updater": "^2.7.1",
"@tauri-apps/plugin-window-state": "^2.2.2",
"@types/three": "^0.172.0",
"@vueuse/core": "^11.1.0",
"dayjs": "^1.11.10",
"deepslate": "0.26.0",
"fflate": "0.8.2",
"floating-vue": "^5.2.2",
"fuse.js": "^6.6.2",
"intl-messageformat": "^10.7.7",
"monaco-editor": "^0.56.0",
"ofetch": "^1.3.4",
"overlayscrollbars": "^2.15.1",
"pinia": "^3.0.0",
"three": "^0.172.0",
"vite-svg-loader": "^5.1.0",
"vue": "^3.5.13",
"vue-i18n": "^10.0.0",
"vue-router": "^4.6.0",
"vuedraggable": "^4.1.0",
"xxhash-wasm": "1.1.0"
},
"devDependencies": {
"@eslint/compat": "^1.1.1",
"@formatjs/cli": "^6.2.12",
"@modrinth/tooling-config": "workspace:*",
"@nuxt/eslint-config": "^0.5.6",
"@vitejs/plugin-vue": "^6.0.3",
"autoprefixer": "^10.4.19",
"eslint": "^9.9.1",
"eslint-plugin-turbo": "^2.5.4",
"postcss": "^8.4.39",
"prettier": "^3.2.5",
"sass": "^1.74.1",
"tailwindcss": "^3.4.4",
"typescript": "^5.5.4",
"vite": "^8.0.0",
"vite-plugin-vue-devtools": "^8.2.1",
"vue-component-type-helpers": "^3.1.8",
"vue-tsc": "^2.1.6"
},
"packageManager": "pnpm@9.4.0",
"web-types": "../../web-types.json"
"name": "@modrinth/app-frontend",
"private": true,
"version": "1.0.2-beta11",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"tsc:check": "vue-tsc --noEmit",
"lint": "eslint . && prettier --check .",
"fix": "eslint . --fix && prettier --write .",
"intl:extract": "formatjs extract \"src/**/*.{vue,ts,tsx,js,jsx,mts,cts,mjs,cjs}\" --ignore \"**/*.d.ts\" --ignore node_modules --out-file src/locales/en-US/index.json --format crowdin --preserve-whitespace",
"intl:prune-local": "pnpm -w scripts i18n-icu-contract prune-local --scope apps/app-frontend",
"test": "vue-tsc --noEmit && node --test \"src/**/*.test.ts\""
},
"dependencies": {
"@dnd-kit/core": "6.3.1",
"@dnd-kit/utilities": "3.2.2",
"@dnd-kit/vue": "^0.5.0",
"@lobehub/icons-static-svg": "1.94.0",
"@modrinth/api-client": "workspace:^",
"@modrinth/assets": "workspace:*",
"@modrinth/server": "workspace:*",
"@modrinth/ui": "workspace:*",
"@modrinth/utils": "workspace:*",
"@sfirew/minecraft-motd-parser": "^1.1.6",
"@tanstack/vue-query": "5.90.7",
"@tauri-apps/api": "^2.5.0",
"@tauri-apps/plugin-dialog": "^2.2.1",
"@tauri-apps/plugin-fs": "^2.4.5",
"@tauri-apps/plugin-http": "~2.5.7",
"@tauri-apps/plugin-opener": "^2.2.6",
"@tauri-apps/plugin-os": "^2.2.1",
"@tauri-apps/plugin-updater": "^2.7.1",
"@tauri-apps/plugin-window-state": "^2.2.2",
"@types/three": "^0.172.0",
"@vueuse/core": "^11.1.0",
"dayjs": "^1.11.10",
"deepslate": "0.26.0",
"fflate": "0.8.2",
"floating-vue": "^5.2.2",
"fuse.js": "^6.6.2",
"intl-messageformat": "^10.7.7",
"monaco-editor": "^0.56.0",
"ofetch": "^1.3.4",
"overlayscrollbars": "^2.15.1",
"pinia": "^3.0.0",
"three": "^0.172.0",
"vite-svg-loader": "^5.1.0",
"vue": "^3.5.13",
"vue-i18n": "^10.0.0",
"vue-router": "^4.6.0",
"vuedraggable": "^4.1.0",
"xxhash-wasm": "1.1.0"
},
"devDependencies": {
"@eslint/compat": "^1.1.1",
"@formatjs/cli": "^6.2.12",
"@modrinth/tooling-config": "workspace:*",
"@nuxt/eslint-config": "^0.5.6",
"@vitejs/plugin-vue": "^6.0.3",
"autoprefixer": "^10.4.19",
"eslint": "^9.9.1",
"eslint-plugin-turbo": "^2.5.4",
"postcss": "^8.4.39",
"prettier": "^3.2.5",
"sass": "^1.74.1",
"tailwindcss": "^3.4.4",
"typescript": "^5.5.4",
"vite": "^8.0.0",
"vite-plugin-vue-devtools": "^8.2.1",
"vue-component-type-helpers": "^3.1.8",
"vue-tsc": "^2.1.6"
},
"packageManager": "pnpm@9.4.0",
"web-types": "../../web-types.json"
}
+237 -76
View File
@@ -32,6 +32,130 @@ export const ANNOUNCEMENT_CHANGE_TYPES: readonly AnnouncementChangeType[] = [
]
export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
{
id: 'launcher-1.0.2-beta11',
version: '1.0.2-beta11',
publishedAt: '2026-10-20',
title: {
'en-US': 'Starlight Launcher 1.0.2-beta11',
'zh-CN': 'Starlight Launcher 1.0.2-beta11',
},
changes: {
fixed: [
{
'en-US':
'Filled missing Chinese translations across skin site sign-in, announcements, verification, registration, account settings, downloads and maps, and localized remaining user and Wiki labels.',
'zh-CN':
'补齐皮肤站登录、公告、验证、注册、账号设置、下载和地图等界面的中文翻译,并修复用户信息与维基权限选项中的英文标签。',
},
{
'en-US':
'Renew the saved skin site JWT on launcher startup before loading the user and announcements. Fixed overlapping refresh, sign-in and sign-out requests that could leave the account in an incorrect state.',
'zh-CN':
'启动启动器时先刷新已保存的皮肤站 JWT,再加载用户与公告;修复刷新、登录和退出请求交错时可能导致的账号状态异常。',
},
{
'en-US':
'Announcements now reload after sign-in, show a sign-in hint when signed out, and offer a retry action after a loading failure.',
'zh-CN': '公告在登录后自动重新加载,未登录时显示登录提示,加载失败时可直接重试。',
},
],
changed: [
{
'en-US':
'Skin site release publishing now uses chunked uploads and reports synchronization failures explicitly. Localization checks also scan message IDs used in source to catch missing catalog entries.',
'zh-CN':
'皮肤站自动发布改用分片上传,同步失败会明确报错;国际化检查新增源码词条扫描,防止再次遗漏语言包内容。',
},
],
},
notes: {
'en-US':
'If the previously saved JWT has already expired, sign in again once to restore the session.',
'zh-CN': '如果此前保存的 JWT 已经过期,需要重新登录一次以恢复会话。',
},
},
{
id: 'launcher-1.0.2-beta10',
version: '1.0.2-beta10',
publishedAt: '2026-10-20',
title: {
'en-US': 'Starlight Launcher 1.0.2-beta10',
'zh-CN': 'Starlight Launcher 1.0.2-beta10',
},
changes: {
security: [
{
'en-US':
'Backported the upstream Axolotl modpack path traversal fix to prevent malicious modpacks from writing files outside the intended installation directory.',
'zh-CN':
'合入上游 Axolotl 整合包路径穿越安全补丁,阻止恶意整合包向安装目录之外写入文件。',
},
{
'en-US':
'Strengthened path validation for Modrinth and CurseForge modpacks, server installations, cached files and modpack uninstall cleanup, including unsafe Windows path aliases.',
'zh-CN':
'加强 Modrinth 与 CurseForge 整合包、服务端安装、缓存文件及整合包卸载清理的路径校验,拦截不安全的 Windows 路径别名。',
},
],
},
notes: {
'en-US':
'Users of earlier versions should update promptly, especially before installing modpacks from untrusted sources.',
'zh-CN': '建议旧版本用户尽快更新,尤其是在安装来源不明的整合包之前。',
},
},
{
id: 'launcher-1.0.2-beta9',
version: '1.0.2-beta9',
publishedAt: '2026-10-19',
title: {
'en-US': 'Starlight Launcher 1.0.2-beta9',
'zh-CN': 'Starlight Launcher 1.0.2-beta9',
},
changes: {
added: [
{
'en-US':
'Finished the skin site admin console: system overview, announcements, user and player management, review paper editor, mod upload with batch operations, chat room management with real-time voice, servers, audit log, resource downloads, donations and launcher releases.',
'zh-CN':
'补全皮肤站管理台:系统概览、公告、用户与玩家管理、审核试卷编辑器、Mod 上传与批量操作、聊天室房间管理与实时语音、服务器、审计日志、资源下载、捐赠与启动器版本管理。',
},
{
'en-US':
'Added Wiki management to the admin console, including a MediaWiki migration center that imports pages from an existing wiki and lets you review, publish or roll back the result.',
'zh-CN':
'管理台新增维基管理,包含 MediaWiki 迁移中心:可从现有 Wiki 导入页面,并对结果进行审核、发布或回滚。',
},
{
'en-US':
'Added a read-only Wiki reader in the launcher: render pages, follow links between entries, and keep a back stack while browsing.',
'zh-CN': '启动器新增维基阅读页:渲染词条正文、跟随词条链接跳转,并在浏览时保留返回栈。',
},
],
changed: [
{
'en-US':
'Releases are now published to the skin site automatically when a tag is pushed, so the download page stays in sync without a manual upload.',
'zh-CN': '推送 tag 发版时会自动把版本同步到皮肤站,下载页无需再手动上传即可保持同步。',
},
{
'en-US': 'Server management pages are only shown to web administrators.',
'zh-CN': '服务器管理页仅对网页管理员展示。',
},
],
fixed: [
{
'en-US': 'Fixed the Chinese and English text on the skin site home navigation cards.',
'zh-CN': '修复皮肤站主页导航卡片的中英文案。',
},
{
'en-US': 'Renamed the public download and map endpoints to resolve a duplicate export.',
'zh-CN': '重命名公开下载与地图接口,解决导出冲突。',
},
],
},
},
{
id: 'launcher-1.0.2-beta8',
version: '1.0.2-beta8',
@@ -43,27 +167,35 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
changes: {
added: [
{
'en-US': 'The skin site is now fully native inside the launcher: sign-in, registration, password reset, account settings, players, downloads, world map and player review all run through the launcher UI instead of an embedded web page.',
'zh-CN': '皮肤站全面改为启动器原生界面:登录、注册、找回密码、账号设置、角色管理、资源下载、服务器地图与玩家审核均不再依赖内嵌网页。',
'en-US':
'The skin site is now fully native inside the launcher: sign-in, registration, password reset, account settings, players, downloads, world map and player review all run through the launcher UI instead of an embedded web page.',
'zh-CN':
'皮肤站全面改为启动器原生界面:登录、注册、找回密码、账号设置、角色管理、资源下载、服务器地图与玩家审核均不再依赖内嵌网页。',
},
{
'en-US': 'Added a bug tracker: browse and filter issues, read details and comments, post replies, create new issues and follow notifications.',
'zh-CN': '新增问题追踪:可浏览与筛选问题、查看详情与评论、发表回复、提交新问题并接收通知。',
'en-US':
'Added a bug tracker: browse and filter issues, read details and comments, post replies, create new issues and follow notifications.',
'zh-CN':
'新增问题追踪:可浏览与筛选问题、查看详情与评论、发表回复、提交新问题并接收通知。',
},
{
'en-US': 'Added an admin console with a permission gate: system overview, announcements, users, players, player review and launcher releases.',
'zh-CN': '新增管理控制台(带权限校验):系统概览、公告管理、用户管理、玩家管理、玩家审核与启动器版本管理。',
'en-US':
'Added an admin console with a permission gate: system overview, announcements, users, players, player review and launcher releases.',
'zh-CN':
'新增管理控制台(带权限校验):系统概览、公告管理、用户管理、玩家管理、玩家审核与启动器版本管理。',
},
],
changed: [
{
'en-US': 'Hosted modpack downloads now go through the dedicated download server, keeping large downloads off the main API host.',
'en-US':
'Hosted modpack downloads now go through the dedicated download server, keeping large downloads off the main API host.',
'zh-CN': '整合包下载改为走独立的下载服务器,避免大文件下载挤占主 API 服务。',
},
],
fixed: [
{
'en-US': 'LogShare now collects logs with a lightweight reader, fixing crash log uploads that previously failed.',
'en-US':
'LogShare now collects logs with a lightweight reader, fixing crash log uploads that previously failed.',
'zh-CN': 'LogShare 改用轻量日志收集,修复崩溃日志上传失败的问题。',
},
{
@@ -92,12 +224,16 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
'zh-CN': '修复实时日志积压导致控制台卡顿的问题。',
},
{
'en-US': 'The update channel now defaults to the build type: installing a Beta build starts on the Beta channel instead of Release.',
'zh-CN': '更新通道默认值改为跟随安装包版本:安装 Beta 版后默认使用 Beta 通道,不再回落为 Release。',
'en-US':
'The update channel now defaults to the build type: installing a Beta build starts on the Beta channel instead of Release.',
'zh-CN':
'更新通道默认值改为跟随安装包版本:安装 Beta 版后默认使用 Beta 通道,不再回落为 Release。',
},
{
'en-US': 'On Linux, the default game directory for StarLight instances no longer points at the system install path (e.g. /usr/bin); it falls back to the home directory.',
'zh-CN': 'Linux 上 StarLight 实例的默认游戏目录不再指向系统安装路径(如 /usr/bin),改为回退到用户主目录。',
'en-US':
'On Linux, the default game directory for StarLight instances no longer points at the system install path (e.g. /usr/bin); it falls back to the home directory.',
'zh-CN':
'Linux 上 StarLight 实例的默认游戏目录不再指向系统安装路径(如 /usr/bin),改为回退到用户主目录。',
},
],
},
@@ -113,15 +249,19 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
changes: {
added: [
{
'en-US': 'Added keyboard shortcut settings: enable and rebind navigation and quick-scrolling shortcuts.',
'en-US':
'Added keyboard shortcut settings: enable and rebind navigation and quick-scrolling shortcuts.',
'zh-CN': '新增键盘快捷键设置:可启用并自定义导航与快速滚动快捷键。',
},
{
'en-US': 'Added crash log sharing and AI analysis: share crash diagnostics to LogShare for a structured summary and optional AI analysis, with a rebuilt crash window that browses log files and streams the analysis.',
'zh-CN': '新增崩溃日志分享与 AI 分析:可将崩溃诊断分享到 LogShare 获取结构化摘要与 AI 分析;崩溃窗口重做为双栏布局,可浏览日志文件并流式查看分析结果。',
'en-US':
'Added crash log sharing and AI analysis: share crash diagnostics to LogShare for a structured summary and optional AI analysis, with a rebuilt crash window that browses log files and streams the analysis.',
'zh-CN':
'新增崩溃日志分享与 AI 分析:可将崩溃诊断分享到 LogShare 获取结构化摘要与 AI 分析;崩溃窗口重做为双栏布局,可浏览日志文件并流式查看分析结果。',
},
{
'en-US': 'Crash logs now also collect JVM crash reports (hs_err_pid*.log) and launcher logs.',
'en-US':
'Crash logs now also collect JVM crash reports (hs_err_pid*.log) and launcher logs.',
'zh-CN': '崩溃日志现在也会收集 JVM 崩溃报告(hs_err_pid*.log)与启动器日志。',
},
{
@@ -162,12 +302,16 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
changes: {
added: [
{
'en-US': 'Added a remote announcements center: a bell in the top bar opens a panel listing launcher announcements fetched from the Starlight skin site.',
'zh-CN': '新增远程公告中心:顶栏的铃铛可打开公告面板,展示从 Starlight 皮肤站拉取的启动器公告。',
'en-US':
'Added a remote announcements center: a bell in the top bar opens a panel listing launcher announcements fetched from the Starlight skin site.',
'zh-CN':
'新增远程公告中心:顶栏的铃铛可打开公告面板,展示从 Starlight 皮肤站拉取的启动器公告。',
},
{
'en-US': 'Added a custom Minecraft window title option: set a global toggle and default title, and let each instance override it. The game window is renamed on Windows.',
'zh-CN': '新增自定义 Minecraft 窗口标题:可设置全局开关与默认标题,并允许各实例单独覆盖;Windows 下会重命名游戏窗口。',
'en-US':
'Added a custom Minecraft window title option: set a global toggle and default title, and let each instance override it. The game window is renamed on Windows.',
'zh-CN':
'新增自定义 Minecraft 窗口标题:可设置全局开关与默认标题,并允许各实例单独覆盖;Windows 下会重命名游戏窗口。',
},
],
fixed: [
@@ -189,24 +333,31 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
changes: {
added: [
{
'en-US': 'Added armor and armor-trim rendering to the skin preview, letting you try on armor pieces and trim patterns directly in the skin editor.',
'zh-CN': '皮肤预览新增盔甲与盔甲纹饰渲染,可在皮肤编辑器内直接试穿各部位盔甲并调整纹饰图案。',
'en-US':
'Added armor and armor-trim rendering to the skin preview, letting you try on armor pieces and trim patterns directly in the skin editor.',
'zh-CN':
'皮肤预览新增盔甲与盔甲纹饰渲染,可在皮肤编辑器内直接试穿各部位盔甲并调整纹饰图案。',
},
{
'en-US': 'Armor preview selections in the skin editor are now saved locally, so they persist across sessions.',
'en-US':
'Armor preview selections in the skin editor are now saved locally, so they persist across sessions.',
'zh-CN': '皮肤编辑器中的盔甲预览选择现在会保存在本地,跨会话保留。',
},
],
changed: [
{
'en-US': 'Improved download scheduling to reduce concurrency automatically when tasks are waiting for capacity, making large Minecraft installations more reliable on constrained connections.',
'zh-CN': '优化下载任务调度:任务因容量不足排队时会自动降低并发,提升大型 Minecraft 版本在受限网络环境下的安装稳定性。',
'en-US':
'Improved download scheduling to reduce concurrency automatically when tasks are waiting for capacity, making large Minecraft installations more reliable on constrained connections.',
'zh-CN':
'优化下载任务调度:任务因容量不足排队时会自动降低并发,提升大型 Minecraft 版本在受限网络环境下的安装稳定性。',
},
],
fixed: [
{
'en-US': 'Fixed downloads timing out while waiting for internal connection capacity, which could cause Minecraft installations to fail even when the network was available.',
'zh-CN': '修复下载任务等待内部连接容量时过早超时,导致网络正常的情况下 Minecraft 安装仍可能失败的问题。',
'en-US':
'Fixed downloads timing out while waiting for internal connection capacity, which could cause Minecraft installations to fail even when the network was available.',
'zh-CN':
'修复下载任务等待内部连接容量时过早超时,导致网络正常的情况下 Minecraft 安装仍可能失败的问题。',
},
{
'en-US': 'Fixed instance group changes not saving for some instances.',
@@ -226,8 +377,10 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
changes: {
fixed: [
{
'en-US': 'Fixed the anniversary celebration banner not showing above the window title bar, and made the banner background semi-transparent so the content behind it stays visible.',
'zh-CN': '修复周年庆庆祝横幅被窗口标题栏遮挡、无法显示的问题,并将横幅背景改为半透明,避免遮住下方内容。',
'en-US':
'Fixed the anniversary celebration banner not showing above the window title bar, and made the banner background semi-transparent so the content behind it stays visible.',
'zh-CN':
'修复周年庆庆祝横幅被窗口标题栏遮挡、无法显示的问题,并将横幅背景改为半透明,避免遮住下方内容。',
},
],
},
@@ -243,8 +396,10 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
changes: {
fixed: [
{
'en-US': 'Fixed the launcher failing to start with "no such table: synced_pack_catalog": the cross-instance sync migration was missing the synced_pack_catalog and synced_pack_instances tables.',
'zh-CN': '修复启动器因 "no such table: synced_pack_catalog" 无法启动的问题:跨实例同步迁移遗漏了 synced_pack_catalog 与 synced_pack_instances 两张表。',
'en-US':
'Fixed the launcher failing to start with "no such table: synced_pack_catalog": the cross-instance sync migration was missing the synced_pack_catalog and synced_pack_instances tables.',
'zh-CN':
'修复启动器因 "no such table: synced_pack_catalog" 无法启动的问题:跨实例同步迁移遗漏了 synced_pack_catalog 与 synced_pack_instances 两张表。',
},
],
},
@@ -260,15 +415,20 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
changes: {
added: [
{
'en-US': 'Cross-instance sync: share game options, resource packs, data packs, multiplayer servers, command history, and creative hotbars across instances, with per-option toggles and a fine-grained game-settings editor.',
'zh-CN': '跨实例同步:可跨实例共享游戏选项、资源包、数据包、多人服务器、命令历史与创造模式快捷栏,支持逐项开关与精细的游戏设置编辑器。',
'en-US':
'Cross-instance sync: share game options, resource packs, data packs, multiplayer servers, command history, and creative hotbars across instances, with per-option toggles and a fine-grained game-settings editor.',
'zh-CN':
'跨实例同步:可跨实例共享游戏选项、资源包、数据包、多人服务器、命令历史与创造模式快捷栏,支持逐项开关与精细的游戏设置编辑器。',
},
{
'en-US': 'Starlight turns 12! On October 4th every year the launcher now shows a celebration banner and falling confetti. The anniversary number is computed from 2014.',
'zh-CN': 'Starlight 十二周年!每年 10 月 4 日,启动器会显示庆祝横幅与飘落的彩带、蛋糕,周年数按 2014 年起算。',
'en-US':
'Starlight turns 12! On October 4th every year the launcher now shows a celebration banner and falling confetti. The anniversary number is computed from 2014.',
'zh-CN':
'Starlight 十二周年!每年 10 月 4 日,启动器会显示庆祝横幅与飘落的彩带、蛋糕,周年数按 2014 年起算。',
},
{
'en-US': 'Added a developer feature flag to preview the anniversary celebration at any time.',
'en-US':
'Added a developer feature flag to preview the anniversary celebration at any time.',
'zh-CN': '新增开发者功能开关,可随时预览周年庆效果。',
},
],
@@ -285,8 +445,10 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
changes: {
added: [
{
'en-US': 'Instance backups: create deduplicated snapshots of an instance while it is closed, preview and restore them, exclude specific files or folders, and move the backup repository.',
'zh-CN': '实例备份:在实例关闭时创建去重快照,可预览与恢复,支持排除指定文件或文件夹,并可迁移备份仓库。',
'en-US':
'Instance backups: create deduplicated snapshots of an instance while it is closed, preview and restore them, exclude specific files or folders, and move the backup repository.',
'zh-CN':
'实例备份:在实例关闭时创建去重快照,可预览与恢复,支持排除指定文件或文件夹,并可迁移备份仓库。',
},
{
'en-US': "Customize the launcher's UI font and monospace font in appearance settings.",
@@ -295,12 +457,16 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
],
fixed: [
{
'en-US': 'Fixed beta builds not auto-updating from beta9 to beta10 (prerelease versions were compared as text instead of by number).',
'zh-CN': '修复 beta 版本无法从 beta9 自动更新到 beta10 的问题(预发布版本此前按文本而非数字比较)。',
'en-US':
'Fixed beta builds not auto-updating from beta9 to beta10 (prerelease versions were compared as text instead of by number).',
'zh-CN':
'修复 beta 版本无法从 beta9 自动更新到 beta10 的问题(预发布版本此前按文本而非数字比较)。',
},
{
'en-US': 'Fixed a cross-crate visibility issue that prevented the launcher from compiling with the ignore-SSL-errors option.',
'zh-CN': '修复因跨 crate 可见性导致的编译失败,此前启用“忽略 SSL 证书错误”选项时无法编译。',
'en-US':
'Fixed a cross-crate visibility issue that prevented the launcher from compiling with the ignore-SSL-errors option.',
'zh-CN':
'修复因跨 crate 可见性导致的编译失败,此前启用“忽略 SSL 证书错误”选项时无法编译。',
},
],
},
@@ -316,11 +482,13 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
changes: {
added: [
{
'en-US': 'Reworked the instance-page tour into four steps covering content, files, worlds, and logs.',
'en-US':
'Reworked the instance-page tour into four steps covering content, files, worlds, and logs.',
'zh-CN': '重做实例页导览,分为内容、文件、世界、日志四步。',
},
{
'en-US': 'When the install location is a drive root, the installer now creates a Starlight subfolder automatically.',
'en-US':
'When the install location is a drive root, the installer now creates a Starlight subfolder automatically.',
'zh-CN': '安装位置选到盘符根目录时,安装器会自动创建 Starlight 子文件夹。',
},
],
@@ -334,11 +502,13 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
'zh-CN': '修复开发者功能开关无法保存的问题。',
},
{
'en-US': 'Fixed instance group edits not saving for instances without an applied content set.',
'en-US':
'Fixed instance group edits not saving for instances without an applied content set.',
'zh-CN': '修复没有应用内容集的实例无法保存分组修改的问题。',
},
{
'en-US': 'Fixed the launcher crashing on startup when feature flags were out of sync between the frontend and backend.',
'en-US':
'Fixed the launcher crashing on startup when feature flags were out of sync between the frontend and backend.',
'zh-CN': '修复前后端功能开关不同步导致启动器启动崩溃的问题。',
},
{
@@ -455,12 +625,10 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
{
'en-US':
'Fixed the onboarding tour skipping steps automatically, getting stuck, or not navigating between steps; the tour bubble no longer covers the left navigation bar.',
'zh-CN':
'修复新手导览自动跳过、卡住或不跳转的问题;导览气泡不再遮挡左侧导航栏。',
'zh-CN': '修复新手导览自动跳过、卡住或不跳转的问题;导览气泡不再遮挡左侧导航栏。',
},
{
'en-US':
'Fixed the onboarding tour target on the minimal home layout.',
'en-US': 'Fixed the onboarding tour target on the minimal home layout.',
'zh-CN': '修复精简主页下导览目标找不到的问题。',
},
],
@@ -491,13 +659,11 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
],
fixed: [
{
'en-US':
'Fixed the developer feature flags page rendering blank.',
'en-US': 'Fixed the developer feature flags page rendering blank.',
'zh-CN': '修复开发者“功能开关”页面空白的问题。',
},
{
'en-US':
'Fixed a build error that prevented the launcher from compiling.',
'en-US': 'Fixed a build error that prevented the launcher from compiling.',
'zh-CN': '修复导致启动器无法编译的构建错误。',
},
],
@@ -514,8 +680,7 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
changes: {
fixed: [
{
'en-US':
'Fixed a build error in 1.0.1-beta3 that prevented the launcher from compiling.',
'en-US': 'Fixed a build error in 1.0.1-beta3 that prevented the launcher from compiling.',
'zh-CN': '修复 1.0.1-beta3 中导致启动器无法编译的构建错误。',
},
],
@@ -574,8 +739,7 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
],
fixed: [
{
'en-US':
'Improved the reliability of live logs and database switching.',
'en-US': 'Improved the reliability of live logs and database switching.',
'zh-CN': '提高实时日志与数据库切换的可靠性。',
},
],
@@ -667,15 +831,13 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
'zh-CN': '修复更新清单的下载地址与发布顺序,更新检查现在可以成功。',
},
{
'en-US':
'Updated the signing key pair used to sign update packages.',
'en-US': 'Updated the signing key pair used to sign update packages.',
'zh-CN': '更新了用于签名更新包的密钥对。',
},
],
changed: [
{
'en-US':
'Removed upstream release announcements prior to 1.0.0-beta1.',
'en-US': 'Removed upstream release announcements prior to 1.0.0-beta1.',
'zh-CN': '移除了 1.0.0-beta1 之前的上游版本公告。',
},
],
@@ -692,13 +854,11 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
changes: {
added: [
{
'en-US':
'Installing a modpack now lets you choose the game directory.',
'en-US': 'Installing a modpack now lets you choose the game directory.',
'zh-CN': '一键安装整合包时现在可以选择游戏目录。',
},
{
'en-US':
'Approved (hosted) modpack sync and StarLight instance mode were added.',
'en-US': 'Approved (hosted) modpack sync and StarLight instance mode were added.',
'zh-CN': '新增获批整合包同步与 StarLight 实例模式。',
},
{
@@ -709,8 +869,7 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
],
changed: [
{
'en-US':
'The about page now plays a looping wither victory animation.',
'en-US': 'The about page now plays a looping wither victory animation.',
'zh-CN': '关于页现在会播放循环的凋灵胜利动画。',
},
],
@@ -722,8 +881,7 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
'修复从 .minecraft 文件夹导入实例的多项问题(内容复制、版本隔离、符号链接、加载器版本识别等)。',
},
{
'en-US':
'Fixed the instance log view stopping updates and overlapping log lines.',
'en-US': 'Fixed the instance log view stopping updates and overlapping log lines.',
'zh-CN': '修复实例日志窗口停更与日志行重叠的问题。',
},
{
@@ -742,8 +900,7 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
'zh-CN': '修复未登录皮肤站时启动卡住且不再弹出玩家选择的问题。',
},
{
'en-US':
'Fixed various skin site login, player list sync, and display issues.',
'en-US': 'Fixed various skin site login, player list sync, and display issues.',
'zh-CN': '修复皮肤站登录、玩家列表同步及若干显示问题。',
},
],
@@ -762,7 +919,8 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
{
'en-US':
'The launcher has been rebranded from Axolotl Launcher to Starlight Launcher, with a new icon and a refreshed about page.',
'zh-CN': '启动器已从 Axolotl Launcher 更名为 Starlight Launcher,并更换了全新图标与关于页。',
'zh-CN':
'启动器已从 Axolotl Launcher 更名为 Starlight Launcher,并更换了全新图标与关于页。',
},
{
'en-US':
@@ -776,7 +934,8 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
],
added: [
{
'en-US': 'A "Starlight" entry was added to the sidebar, which embeds the StarLight skin site.',
'en-US':
'A "Starlight" entry was added to the sidebar, which embeds the StarLight skin site.',
'zh-CN': '侧边栏新增「斯达莱特」入口,内嵌 StarLight 皮肤站。',
},
{
@@ -795,10 +954,12 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
{
'en-US':
'The hard-coded Starlight official server was removed from "Pinned servers"; only servers you favorite yourself are shown now.',
'zh-CN': '移除了「固定的服务器」中写死的 Starlight 官方服务器,现在只显示你自己收藏的服务器。',
'zh-CN':
'移除了「固定的服务器」中写死的 Starlight 官方服务器,现在只显示你自己收藏的服务器。',
},
{
'en-US': 'The swimming axolotl animation on the about page was replaced with a static nether star.',
'en-US':
'The swimming axolotl animation on the about page was replaced with a static nether star.',
'zh-CN': '关于页中游动的美西螈动画已替换为静止的下界之星。',
},
],
@@ -70,6 +70,13 @@ const messages = defineMessages({
defaultMessage: 'Selected',
},
idLabel: { id: 'app.skin-site.chat.user-picker.id', defaultMessage: 'ID' },
emailLabel: { id: 'app.skin-site.chat.user-picker.email', defaultMessage: 'Email' },
registeredLabel: {
id: 'app.skin-site.chat.user-picker.registered',
defaultMessage: 'Registered',
},
bannedStatus: { id: 'app.skin-site.chat.user-picker.banned-status', defaultMessage: 'Banned' },
activeStatus: { id: 'app.skin-site.chat.user-picker.active-status', defaultMessage: 'Active' },
})
const keyword = ref('')
@@ -82,9 +89,7 @@ let timer: ReturnType<typeof setTimeout> | undefined
let requestId = 0
const currentLabel = computed(() => props.label ?? formatMessage(messages.label))
const currentPlaceholder = computed(
() => props.placeholder ?? formatMessage(messages.placeholder),
)
const currentPlaceholder = computed(() => props.placeholder ?? formatMessage(messages.placeholder))
watch([keyword, searchMode], () => {
clearTimeout(timer)
@@ -174,13 +179,19 @@ function formatTime(ts: number): string {
v-model.trim="keyword"
type="text"
maxlength="100"
:placeholder="searchMode === 'player' ? formatMessage(messages.playerHint) : currentPlaceholder"
:placeholder="
searchMode === 'player' ? formatMessage(messages.playerHint) : currentPlaceholder
"
class="min-w-0 flex-1 rounded-lg border border-solid border-surface-5 bg-bg-raised px-3 py-1.5 text-xs text-contrast outline-none focus:border-brand"
autocomplete="off"
/>
</div>
<span class="text-[11px] text-secondary">
{{ searchMode === 'player' ? formatMessage(messages.playerHint) : formatMessage(messages.hint) }}
{{
searchMode === 'player'
? formatMessage(messages.playerHint)
: formatMessage(messages.hint)
}}
</span>
</div>
@@ -201,7 +212,9 @@ function formatTime(ts: number): string {
@click="preview = user"
>
<span class="flex min-w-0 items-center gap-2">
<span class="grid size-8 shrink-0 place-items-center rounded-lg bg-brand/15 text-xs font-bold text-brand">
<span
class="grid size-8 shrink-0 place-items-center rounded-lg bg-brand/15 text-xs font-bold text-brand"
>
{{ user.username.slice(0, 1).toUpperCase() }}
</span>
<span class="min-w-0">
@@ -244,7 +257,7 @@ function formatTime(ts: number): string {
class="rounded-full px-2 py-0.5 text-[10px] font-semibold"
:class="preview.banned ? 'bg-red text-contrast' : 'bg-green text-contrast'"
>
{{ preview.banned ? 'Banned' : 'OK' }}
{{ formatMessage(preview.banned ? messages.bannedStatus : messages.activeStatus) }}
</span>
</div>
<div class="grid gap-2 text-[11px] sm:grid-cols-2">
@@ -253,7 +266,7 @@ function formatTime(ts: number): string {
<span class="block break-all font-mono text-contrast">{{ preview.uuid }}</span>
</div>
<div>
<span class="block text-secondary">Email</span>
<span class="block text-secondary">{{ formatMessage(messages.emailLabel) }}</span>
<span class="block break-all text-contrast">{{ preview.email }}</span>
</div>
<div>
@@ -261,7 +274,7 @@ function formatTime(ts: number): string {
<span class="block text-contrast">{{ preview.qq ?? '—' }}</span>
</div>
<div>
<span class="block text-secondary">Registered</span>
<span class="block text-secondary">{{ formatMessage(messages.registeredLabel) }}</span>
<span class="block text-contrast">{{ formatTime(preview.registerTime) }}</span>
</div>
</div>
@@ -283,7 +296,11 @@ function formatTime(ts: number): string {
:disabled="Boolean(unavailableReason(preview))"
@click="selectPreview"
>
{{ model?.uuid === preview.uuid ? formatMessage(messages.selected) : formatMessage(messages.select) }}
{{
model?.uuid === preview.uuid
? formatMessage(messages.selected)
: formatMessage(messages.select)
}}
</button>
</section>
</div>
@@ -0,0 +1,142 @@
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { createRequire, registerHooks, stripTypeScriptTypes } from 'node:module'
import test from 'node:test'
import { createRenderer, nextTick, ref } from 'vue'
const testSession = {
skinSiteStatus: ref('checking'),
skinSiteUser: ref<{ uuid: string } | null>(null),
}
const testGlobal = globalThis as unknown as {
skinSiteAnnouncementSession: typeof testSession
skinSiteAnnouncementFetch: () => Promise<unknown>
}
testGlobal.skinSiteAnnouncementSession = testSession
const require = createRequire(import.meta.url)
const { parse, compileScript } = require('vue/compiler-sfc')
const componentUrl = new URL('./SkinSiteAnnouncements.vue', import.meta.url).href
const stubs: Record<string, string> = {
'@modrinth/assets': 'export const SpinnerIcon={}',
'@modrinth/ui':
'export const commonMessages={retryButton:{defaultMessage:"Retry"}}; export const defineMessages=x=>x; export const useVIntl=()=>({formatMessage:x=>x.defaultMessage})',
'@/helpers/skin-site-api':
'export const skinSiteAnnouncements=()=>globalThis.skinSiteAnnouncementFetch()',
'@/composables/skin-site-session':
'export const {skinSiteStatus,skinSiteUser}=globalThis.skinSiteAnnouncementSession; export const reloadSkinSiteSession=async()=>{}',
}
const hooks = registerHooks({
resolve(specifier, context, nextResolve) {
if (specifier in stubs)
return {
url: `data:text/javascript,${encodeURIComponent(stubs[specifier])}`,
shortCircuit: true,
}
return nextResolve(specifier, context)
},
load(url, context, nextLoad) {
if (url !== componentUrl) return nextLoad(url, context)
const { descriptor } = parse(readFileSync(new URL(url), 'utf8'))
return {
format: 'module',
source: stripTypeScriptTypes(
compileScript(descriptor, { id: 'skin-announcement-test' }).content,
),
shortCircuit: true,
}
},
})
const { default: Announcements } = await import(componentUrl)
hooks.deregister()
Announcements.render = () => null
type Node = Record<string, unknown>
const renderer = createRenderer<Node, Node>({
createElement: () => ({}),
createText: () => ({}),
createComment: () => ({}),
insert() {},
remove() {},
setText() {},
setElementText() {},
patchProp() {},
parentNode: () => null,
nextSibling: () => null,
})
const flush = async () => {
await new Promise((resolve) => setImmediate(resolve))
await nextTick()
}
type State = {
announcements: Array<{ id: number }>
loading: boolean
failed: boolean
load: () => Promise<void>
}
let requests = 0
function mount(t: test.TestContext) {
const app = renderer.createApp(Announcements)
const instance = app.mount({})
t.after(() => app.unmount())
return instance.$.setupState as State
}
test.beforeEach(() => {
testSession.skinSiteStatus.value = 'checking'
testSession.skinSiteUser.value = null
requests = 0
testGlobal.skinSiteAnnouncementFetch = async () => {
requests++
return { success: true, payload: [{ id: 1, title: '公告', updateAt: 1, star: false }] }
}
})
test('announcements wait for startup renewal and reload when sign-in finishes', async (t) => {
const state = mount(t)
await flush()
assert.equal(requests, 0)
assert.equal(state.loading, true)
testSession.skinSiteUser.value = { uuid: 'owner' }
testSession.skinSiteStatus.value = 'signed-in'
await flush()
assert.equal(requests, 1)
assert.equal(state.announcements.length, 1)
})
test('signed-out users do not request protected announcements or see a load failure', async (t) => {
testSession.skinSiteStatus.value = 'signed-out'
const state = mount(t)
await flush()
assert.equal(requests, 0)
assert.equal(state.loading, false)
assert.equal(state.failed, false)
})
test('signing out clears announcements and ignores an old in-flight response', async (t) => {
testSession.skinSiteStatus.value = 'signed-in'
let finish!: (value: unknown) => void
testGlobal.skinSiteAnnouncementFetch = () =>
new Promise((resolve) => {
finish = resolve
})
const state = mount(t)
await flush()
testSession.skinSiteStatus.value = 'signed-out'
await flush()
finish({ success: true, payload: [{ id: 2 }] })
await flush()
assert.deepEqual(state.announcements, [])
assert.equal(state.failed, false)
})
test('a failed announcement request can be retried', async (t) => {
testSession.skinSiteStatus.value = 'signed-in'
testGlobal.skinSiteAnnouncementFetch = async () => ({ success: false })
const state = mount(t)
await flush()
assert.equal(state.failed, true)
testGlobal.skinSiteAnnouncementFetch = async () => ({ success: true, payload: [{ id: 3 }] })
await state.load()
assert.equal(state.failed, false)
assert.equal(state.announcements[0].id, 3)
})
@@ -1,8 +1,13 @@
<script setup lang="ts">
import { SpinnerIcon } from '@modrinth/assets'
import { defineMessages, useVIntl } from '@modrinth/ui'
import { onMounted, ref } from 'vue'
import { commonMessages, defineMessages, useVIntl } from '@modrinth/ui'
import { onUnmounted, ref, watch } from 'vue'
import {
reloadSkinSiteSession,
skinSiteStatus,
skinSiteUser,
} from '@/composables/skin-site-session'
import { type SkinSiteAnnouncement, skinSiteAnnouncements } from '@/helpers/skin-site-api'
const { formatMessage } = useVIntl()
@@ -18,11 +23,16 @@ const messages = defineMessages({
id: 'app.skin-site.home.announcements.failed',
defaultMessage: 'Could not load announcements.',
},
signedOut: {
id: 'app.skin-site.home.announcements.signed-out',
defaultMessage: 'Sign in to view announcements.',
},
})
const announcements = ref<SkinSiteAnnouncement[]>([])
const loading = ref(true)
const failed = ref(false)
let requestId = 0
function formatDate(ts: number): string {
try {
@@ -32,9 +42,16 @@ function formatDate(ts: number): string {
}
}
onMounted(async () => {
async function load() {
const currentRequest = ++requestId
announcements.value = []
failed.value = skinSiteStatus.value === 'error'
loading.value = skinSiteStatus.value === 'checking'
if (skinSiteStatus.value !== 'signed-in') return
loading.value = true
try {
const result = await skinSiteAnnouncements()
if (currentRequest !== requestId) return
if (result.success) {
announcements.value = [...(result.payload ?? [])]
.sort((a, b) => {
@@ -46,10 +63,20 @@ onMounted(async () => {
failed.value = true
}
} catch {
failed.value = true
if (currentRequest === requestId) failed.value = true
} finally {
loading.value = false
if (currentRequest === requestId) loading.value = false
}
}
async function retry() {
if (skinSiteStatus.value === 'error') await reloadSkinSiteSession()
else await load()
}
watch([skinSiteStatus, () => skinSiteUser.value?.uuid], load, { immediate: true })
onUnmounted(() => {
requestId++
})
</script>
@@ -63,8 +90,14 @@ onMounted(async () => {
<SpinnerIcon class="size-4 animate-spin" />
{{ formatMessage(messages.loading) }}
</div>
<p v-else-if="failed" class="m-0 text-sm text-secondary">
{{ formatMessage(messages.failed) }}
<div v-else-if="failed" class="flex items-center gap-2 text-sm text-secondary">
<p class="m-0">{{ formatMessage(messages.failed) }}</p>
<button type="button" class="text-brand hover:underline" @click="retry">
{{ formatMessage(commonMessages.retryButton) }}
</button>
</div>
<p v-else-if="skinSiteStatus === 'signed-out'" class="m-0 text-sm text-secondary">
{{ formatMessage(messages.signedOut) }}
</p>
<p v-else-if="!announcements.length" class="m-0 text-sm text-secondary">
{{ formatMessage(messages.empty) }}
@@ -7,6 +7,16 @@ import {
skinSiteWikiAudit,
type SkinSiteWikiAuditInfo,
type SkinSiteWikiEditPolicy,
type SkinSiteWikiMigrationCandidate,
skinSiteWikiMigrationCandidates,
skinSiteWikiMigrationDecide,
skinSiteWikiMigrationDelete,
type SkinSiteWikiMigrationJobInfo,
skinSiteWikiMigrationJobs,
skinSiteWikiMigrationPublish,
skinSiteWikiMigrationRollback,
skinSiteWikiMigrationStartAutomatic,
skinSiteWikiMigrationStartXml,
skinSiteWikiPage,
type SkinSiteWikiPageDetail,
skinSiteWikiProtectPage,
@@ -16,22 +26,18 @@ import {
type SkinSiteWikiSettings,
skinSiteWikiSettings,
skinSiteWikiUpdateSettings,
skinSiteWikiMigrationCandidates,
skinSiteWikiMigrationDecide,
skinSiteWikiMigrationDelete,
skinSiteWikiMigrationJobs,
skinSiteWikiMigrationPublish,
skinSiteWikiMigrationRollback,
skinSiteWikiMigrationStartAutomatic,
skinSiteWikiMigrationStartXml,
type SkinSiteWikiMigrationCandidate,
type SkinSiteWikiMigrationJobInfo,
} from '@/helpers/skin-site-api'
const { formatMessage } = useVIntl()
const { handleError, addNotification } = injectNotificationManager()
const messages = defineMessages({
policyPublic: { id: 'app.skin-site.admin.wiki.policy-public', defaultMessage: 'Everyone' },
policyMember: { id: 'app.skin-site.admin.wiki.policy-member', defaultMessage: 'Members' },
policyAdmin: {
id: 'app.skin-site.admin.wiki.policy-admin',
defaultMessage: 'Website administrators',
},
title: { id: 'app.skin-site.admin.wiki.title', defaultMessage: 'Wiki' },
tabPage: { id: 'app.skin-site.admin.wiki.tab-page', defaultMessage: 'Page' },
tabAudit: { id: 'app.skin-site.admin.wiki.tab-audit', defaultMessage: 'Audit log' },
@@ -61,7 +67,8 @@ const messages = defineMessages({
},
credentialsHint: {
id: 'app.skin-site.admin.wiki.credentials-hint',
defaultMessage: 'Credentials stay in memory for this job only. HTTPS is required when supplied.',
defaultMessage:
'Credentials stay in memory for this job only. HTTPS is required when supplied.',
},
allowPrivate: {
id: 'app.skin-site.admin.wiki.allow-private',
@@ -529,8 +536,7 @@ async function loadMigrationJobs() {
if (!res.success) throw new Error(res.errorMessage)
migrationJobs.value = res.payload ?? []
if (selectedJob.value) {
selectedJob.value =
migrationJobs.value.find((j) => j.id === selectedJob.value!.id) ?? null
selectedJob.value = migrationJobs.value.find((j) => j.id === selectedJob.value!.id) ?? null
}
} catch (error) {
handleError(error)
@@ -821,8 +827,8 @@ onMounted(() => void loadSettings())
v-model="protectRead"
class="rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast"
>
<option value="PUBLIC">PUBLIC</option>
<option value="MEMBER">MEMBER</option>
<option value="PUBLIC">{{ formatMessage(messages.policyPublic) }}</option>
<option value="MEMBER">{{ formatMessage(messages.policyMember) }}</option>
</select>
</label>
<label class="flex flex-col gap-1">
@@ -833,8 +839,8 @@ onMounted(() => void loadSettings())
v-model="protectEdit"
class="rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast"
>
<option value="MEMBER">MEMBER</option>
<option value="WEB_ADMIN">WEB_ADMIN</option>
<option value="MEMBER">{{ formatMessage(messages.policyMember) }}</option>
<option value="WEB_ADMIN">{{ formatMessage(messages.policyAdmin) }}</option>
</select>
</label>
<button
@@ -1045,24 +1051,60 @@ onMounted(() => void loadSettings())
</summary>
<div class="mt-3 grid gap-2 sm:grid-cols-3">
<label class="flex flex-col gap-1">
<span class="text-[11px] text-secondary">{{ formatMessage(messages.staleDays) }}</span>
<input v-model.number="automaticForm.rules.staleDays" type="number" min="1" max="36500" class="rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast" />
<span class="text-[11px] text-secondary">{{
formatMessage(messages.staleDays)
}}</span>
<input
v-model.number="automaticForm.rules.staleDays"
type="number"
min="1"
max="36500"
class="rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast"
/>
</label>
<label class="flex flex-col gap-1">
<span class="text-[11px] text-secondary">{{ formatMessage(messages.maintainerWindow) }}</span>
<input v-model.number="automaticForm.rules.maintainerWindowDays" type="number" min="1" max="36500" class="rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast" />
<span class="text-[11px] text-secondary">{{
formatMessage(messages.maintainerWindow)
}}</span>
<input
v-model.number="automaticForm.rules.maintainerWindowDays"
type="number"
min="1"
max="36500"
class="rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast"
/>
</label>
<label class="flex flex-col gap-1">
<span class="text-[11px] text-secondary">{{ formatMessage(messages.maxMaintainers) }}</span>
<input v-model.number="automaticForm.rules.maximumMaintainers" type="number" min="0" max="100" class="rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast" />
<span class="text-[11px] text-secondary">{{
formatMessage(messages.maxMaintainers)
}}</span>
<input
v-model.number="automaticForm.rules.maximumMaintainers"
type="number"
min="0"
max="100"
class="rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast"
/>
</label>
<label class="flex flex-col gap-1 sm:col-span-3">
<span class="text-[11px] text-secondary">{{ formatMessage(messages.staleMarkers) }}</span>
<input v-model="staleMarkersText" type="text" :placeholder="formatMessage(messages.staleMarkersHint)" class="rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast" />
<span class="text-[11px] text-secondary">{{
formatMessage(messages.staleMarkers)
}}</span>
<input
v-model="staleMarkersText"
type="text"
:placeholder="formatMessage(messages.staleMarkersHint)"
class="rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast"
/>
</label>
</div>
</details>
<button type="button" class="rounded-lg bg-brand px-4 py-2 text-sm font-semibold text-contrast hover:brightness-110 disabled:opacity-50" :disabled="startingMigration" @click="startAutomaticMigration">
<button
type="button"
class="rounded-lg bg-brand px-4 py-2 text-sm font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
:disabled="startingMigration"
@click="startAutomaticMigration"
>
{{ formatMessage(messages.startAuto) }}
</button>
</div>
@@ -1075,9 +1117,19 @@ onMounted(() => void loadSettings())
<span class="text-xs font-semibold text-secondary">
{{ formatMessage(messages.xmlFile) }}
</span>
<input ref="xmlInput" type="file" accept=".xml,text/xml,application/xml" class="text-xs text-contrast" />
<input
ref="xmlInput"
type="file"
accept=".xml,text/xml,application/xml"
class="text-xs text-contrast"
/>
</label>
<button type="button" class="rounded-lg bg-brand px-4 py-2 text-sm font-semibold text-contrast hover:brightness-110 disabled:opacity-50" :disabled="startingMigration" @click="startXmlMigration">
<button
type="button"
class="rounded-lg bg-brand px-4 py-2 text-sm font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
:disabled="startingMigration"
@click="startXmlMigration"
>
{{ formatMessage(messages.startXml) }}
</button>
</div>
@@ -1087,16 +1139,27 @@ onMounted(() => void loadSettings())
<h4 class="m-0 text-sm font-bold text-contrast">
{{ formatMessage(messages.jobs) }}
</h4>
<button type="button" class="rounded-lg bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50" :disabled="jobsLoading" @click="loadMigrationJobs">
<button
type="button"
class="rounded-lg bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
:disabled="jobsLoading"
@click="loadMigrationJobs"
>
{{ formatMessage(messages.refreshJobs) }}
</button>
</div>
<div v-if="jobsLoading" class="flex min-h-24 items-center justify-center gap-2 text-sm text-secondary">
<div
v-if="jobsLoading"
class="flex min-h-24 items-center justify-center gap-2 text-sm text-secondary"
>
<SpinnerIcon class="size-4 animate-spin" />
{{ formatMessage(messages.loading) }}
</div>
<p v-else-if="!migrationJobs.length" class="m-0 rounded-lg bg-bg-raised p-3 text-xs text-secondary">
<p
v-else-if="!migrationJobs.length"
class="m-0 rounded-lg bg-bg-raised p-3 text-xs text-secondary"
>
{{ formatMessage(messages.jobsEmpty) }}
</p>
<div v-else class="flex flex-col gap-2">
@@ -1107,21 +1170,43 @@ onMounted(() => void loadSettings())
:class="selectedJob?.id === job.id ? 'border-brand bg-brand/5' : 'border-surface-5'"
>
<div class="flex flex-wrap items-center justify-between gap-2">
<span class="text-sm font-semibold text-contrast">#{{ job.id }} · {{ job.source }}</span>
<span class="rounded-full px-2 py-0.5 text-[10px] font-semibold" :class="jobStateClass(job.state)">
<span class="text-sm font-semibold text-contrast"
>#{{ job.id }} · {{ job.source }}</span
>
<span
class="rounded-full px-2 py-0.5 text-[10px] font-semibold"
:class="jobStateClass(job.state)"
>
{{ jobStateLabel(job.state) }}
</span>
</div>
<div class="mt-2 h-1.5 overflow-hidden rounded-full bg-button-bg">
<div class="h-full bg-brand transition-all" :style="{ width: (job.total ? (job.reviewed / job.total) * 100 : 0) + '%' }"></div>
<div
class="h-full bg-brand transition-all"
:style="{ width: (job.total ? (job.reviewed / job.total) * 100 : 0) + '%' }"
></div>
</div>
<div class="mt-2 flex flex-wrap justify-between gap-2 text-[11px] text-secondary">
<span>{{ formatMessage(messages.reviewedCount, { reviewed: job.reviewed, total: job.total }) }}</span>
<span>{{ formatMessage(messages.importedExcluded, { imported: job.imported, excluded: job.excluded }) }}</span>
<span>{{
formatMessage(messages.reviewedCount, {
reviewed: job.reviewed,
total: job.total,
})
}}</span>
<span>{{
formatMessage(messages.importedExcluded, {
imported: job.imported,
excluded: job.excluded,
})
}}</span>
</div>
<p v-if="job.error" class="m-0 mt-2 text-xs text-red">{{ job.error }}</p>
<div class="mt-2 flex flex-wrap justify-end gap-2">
<button type="button" class="rounded-lg bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110" @click="selectJob(job)">
<button
type="button"
class="rounded-lg bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
@click="selectJob(job)"
>
{{ formatMessage(messages.viewJob) }}
</button>
<button
@@ -1139,10 +1224,19 @@ onMounted(() => void loadSettings())
{{ formatMessage(messages.confirmDeleteJob, { id: job.id }) }}
</p>
<div class="mt-2 flex justify-end gap-2">
<button type="button" class="rounded-lg bg-button-bg px-3 py-1 text-xs font-semibold text-secondary" @click="confirmingDeleteId = null">
<button
type="button"
class="rounded-lg bg-button-bg px-3 py-1 text-xs font-semibold text-secondary"
@click="confirmingDeleteId = null"
>
{{ formatMessage(messages.cancel) }}
</button>
<button type="button" class="rounded-lg bg-red px-3 py-1 text-xs font-semibold text-contrast disabled:opacity-50" :disabled="deletingJob" @click="deleteJob(job)">
<button
type="button"
class="rounded-lg bg-red px-3 py-1 text-xs font-semibold text-contrast disabled:opacity-50"
:disabled="deletingJob"
@click="deleteJob(job)"
>
{{ formatMessage(messages.deleteJob) }}
</button>
</div>
@@ -1151,7 +1245,10 @@ onMounted(() => void loadSettings())
</div>
</div>
<div v-if="selectedJob" class="flex flex-col gap-3 rounded-xl border border-solid border-surface-5 p-4">
<div
v-if="selectedJob"
class="flex flex-col gap-3 rounded-xl border border-solid border-surface-5 p-4"
>
<div class="flex flex-wrap items-center justify-between gap-2">
<h4 class="m-0 text-sm font-bold text-contrast">
{{ formatMessage(messages.candidates) }}
@@ -1180,20 +1277,35 @@ onMounted(() => void loadSettings())
<div v-if="confirmingRollbackId === selectedJob.id" class="rounded-lg bg-yellow/10 p-2">
<p class="m-0 text-xs text-yellow">{{ formatMessage(messages.confirmRollback) }}</p>
<div class="mt-2 flex justify-end gap-2">
<button type="button" class="rounded-lg bg-button-bg px-3 py-1 text-xs font-semibold text-secondary" @click="confirmingRollbackId = null">
<button
type="button"
class="rounded-lg bg-button-bg px-3 py-1 text-xs font-semibold text-secondary"
@click="confirmingRollbackId = null"
>
{{ formatMessage(messages.cancel) }}
</button>
<button type="button" class="rounded-lg bg-yellow px-3 py-1 text-xs font-semibold text-contrast disabled:opacity-50" :disabled="rollingBack" @click="rollbackMigration">
<button
type="button"
class="rounded-lg bg-yellow px-3 py-1 text-xs font-semibold text-contrast disabled:opacity-50"
:disabled="rollingBack"
@click="rollbackMigration"
>
{{ formatMessage(messages.rollback) }}
</button>
</div>
</div>
<div v-if="candidatesLoading && !candidates.length" class="flex min-h-24 items-center justify-center gap-2 text-sm text-secondary">
<div
v-if="candidatesLoading && !candidates.length"
class="flex min-h-24 items-center justify-center gap-2 text-sm text-secondary"
>
<SpinnerIcon class="size-4 animate-spin" />
{{ formatMessage(messages.loading) }}
</div>
<p v-else-if="!candidates.length" class="m-0 rounded-lg bg-bg-raised p-3 text-xs text-secondary">
<p
v-else-if="!candidates.length"
class="m-0 rounded-lg bg-bg-raised p-3 text-xs text-secondary"
>
{{ formatMessage(messages.candidatesEmpty) }}
</p>
<div v-else class="flex flex-col gap-2">
@@ -1203,20 +1315,38 @@ onMounted(() => void loadSettings())
class="flex flex-col gap-2 rounded-lg border border-solid border-surface-5 p-3"
>
<div class="flex flex-wrap items-center gap-2">
<span class="min-w-0 flex-1 truncate text-sm font-semibold text-contrast">{{ candidate.title }}</span>
<span class="rounded-full px-2 py-0.5 text-[10px] font-semibold" :class="decisionClass(candidate.decision)">
<span class="min-w-0 flex-1 truncate text-sm font-semibold text-contrast">{{
candidate.title
}}</span>
<span
class="rounded-full px-2 py-0.5 text-[10px] font-semibold"
:class="decisionClass(candidate.decision)"
>
{{ decisionLabel(candidate.decision) }}
</span>
<span v-if="candidate.conflict" class="rounded-full bg-yellow/20 px-2 py-0.5 text-[10px] font-semibold text-yellow">
<span
v-if="candidate.conflict"
class="rounded-full bg-yellow/20 px-2 py-0.5 text-[10px] font-semibold text-yellow"
>
{{ formatMessage(messages.conflict) }}
</span>
</div>
<div class="flex flex-wrap gap-3 text-[11px] text-secondary">
<span>{{ formatMessage(messages.lastUpdated, { date: new Date(candidate.lastUpdatedAt).toLocaleDateString() }) }}</span>
<span>{{ formatMessage(messages.maintainerCount, { count: candidate.maintainerCount }) }}</span>
<span>{{
formatMessage(messages.lastUpdated, {
date: new Date(candidate.lastUpdatedAt).toLocaleDateString(),
})
}}</span>
<span>{{
formatMessage(messages.maintainerCount, { count: candidate.maintainerCount })
}}</span>
</div>
<div v-if="candidate.suspiciousReasons.length" class="flex flex-wrap gap-1">
<span v-for="reason in candidate.suspiciousReasons" :key="reason" class="rounded bg-bg px-1.5 py-0.5 text-[10px] text-secondary">
<span
v-for="reason in candidate.suspiciousReasons"
:key="reason"
class="rounded bg-bg px-1.5 py-0.5 text-[10px] text-secondary"
>
{{ reason }}
</span>
</div>
@@ -1228,13 +1358,25 @@ onMounted(() => void loadSettings())
class="min-w-0 flex-1 rounded-lg border border-solid border-surface-5 bg-bg-raised px-2 py-1 text-xs text-contrast outline-none focus:border-brand"
/>
<label class="flex cursor-pointer items-center gap-1.5 text-[11px] text-contrast">
<input v-model="candidateOverwrite[candidate.id]" type="checkbox" class="size-3" />
<input
v-model="candidateOverwrite[candidate.id]"
type="checkbox"
class="size-3"
/>
{{ formatMessage(messages.overwrite) }}
</label>
<button type="button" class="rounded-lg bg-green/20 px-3 py-1 text-xs font-semibold text-green hover:brightness-110" @click="decideCandidate(candidate, 'IMPORT')">
<button
type="button"
class="rounded-lg bg-green/20 px-3 py-1 text-xs font-semibold text-green hover:brightness-110"
@click="decideCandidate(candidate, 'IMPORT')"
>
{{ formatMessage(messages.importAction) }}
</button>
<button type="button" class="rounded-lg bg-red/20 px-3 py-1 text-xs font-semibold text-red hover:brightness-110" @click="decideCandidate(candidate, 'EXCLUDE')">
<button
type="button"
class="rounded-lg bg-red/20 px-3 py-1 text-xs font-semibold text-red hover:brightness-110"
@click="decideCandidate(candidate, 'EXCLUDE')"
>
{{ formatMessage(messages.excludeAction) }}
</button>
</div>
@@ -1251,8 +1393,6 @@ onMounted(() => void loadSettings())
</div>
</div>
</div>
</template>
</template>
</div>
</template>
@@ -0,0 +1,208 @@
import assert from 'node:assert/strict'
import { registerHooks } from 'node:module'
import test from 'node:test'
type FetchHandler = (url: string, options: RequestInit) => Promise<Response>
const testGlobal = globalThis as unknown as { skinSiteTestFetch: FetchHandler }
const hooks = registerHooks({
resolve(specifier, context, nextResolve) {
if (specifier === '@tauri-apps/plugin-http') {
return {
url: 'data:text/javascript,export const fetch=(...args)=>globalThis.skinSiteTestFetch(...args)',
shortCircuit: true,
}
}
if (specifier.startsWith('@/')) {
return nextResolve(new URL(`../${specifier.slice(2)}.ts`, import.meta.url).href, context)
}
return nextResolve(specifier, context)
},
})
const session = await import('./skin-site-session.ts')
hooks.deregister()
const user = { uuid: 'owner', username: 'Player', permissions: [] }
const ok = (payload: unknown) => Response.json({ payload })
const storage = new Map<string, string>()
const tokenKey = 'starlight-skin-site-token'
let calls: Array<{ path: string; token: string | undefined }> = []
let respond: FetchHandler
test.beforeEach(() => {
storage.clear()
Object.defineProperty(globalThis, 'localStorage', {
configurable: true,
value: {
getItem: (key: string) => storage.get(key) ?? null,
setItem: (key: string, value: string) => storage.set(key, value),
removeItem: (key: string) => storage.delete(key),
},
})
calls = []
respond = async (url) => {
if (url.endsWith('/user/refresh')) return ok({ username: 'Player', jwt: 'fresh-token' })
if (url.endsWith('/user')) return ok(user)
return ok([])
}
testGlobal.skinSiteTestFetch = async (url, options) => {
calls.push({
path: new URL(url).pathname,
token: (options.headers as Record<string, string>)?.Authorization,
})
return respond(url, options)
}
session.resetSkinSiteSession()
})
test.afterEach(async () => {
session.signOutSkinSite()
await new Promise((resolve) => setImmediate(resolve))
Reflect.deleteProperty(globalThis, 'localStorage')
})
test('startup renews the stored JWT before loading the user with the new token', async () => {
storage.set(tokenKey, 'old-token')
await session.initSkinSiteSession()
assert.deepEqual(calls.slice(0, 2), [
{ path: '/starlight/user/refresh', token: 'Bearer old-token' },
{ path: '/starlight/user', token: 'Bearer fresh-token' },
])
assert.equal(storage.get(tokenKey), 'fresh-token')
assert.equal(session.skinSiteStatus.value, 'signed-in')
})
test('simultaneous startup consumers share one refresh', async () => {
storage.set(tokenKey, 'old-token')
await Promise.all([
session.initSkinSiteSession(),
session.initSkinSiteSession(),
session.waitForSkinSiteSession(),
])
assert.equal(calls.filter((call) => call.path.endsWith('/refresh')).length, 1)
})
test('startup without a stored token does not make authenticated requests', async () => {
await session.initSkinSiteSession()
assert.equal(session.skinSiteStatus.value, 'signed-out')
assert.deepEqual(calls, [])
})
test('an expired token is cleared when renewal is rejected', async () => {
storage.set(tokenKey, 'expired-token')
respond = async () => Response.json({ errorMessage: 'Expired' }, { status: 401 })
await session.initSkinSiteSession()
assert.equal(storage.has(tokenKey), false)
assert.equal(session.skinSiteStatus.value, 'signed-out')
assert.equal(calls.length, 1)
})
test('temporary renewal failure preserves the token and allows startup retry', async () => {
storage.set(tokenKey, 'old-token')
respond = async () => Response.json({ errorMessage: 'Unavailable' }, { status: 503 })
await session.initSkinSiteSession()
assert.equal(session.skinSiteStatus.value, 'error')
assert.equal(storage.get(tokenKey), 'old-token')
respond = async (url) =>
url.endsWith('/refresh')
? ok({ jwt: 'fresh-token' })
: url.endsWith('/user')
? ok(user)
: ok([])
await session.initSkinSiteSession()
assert.equal(session.skinSiteStatus.value, 'signed-in')
})
test('a late refresh cannot restore a session after sign-out', async () => {
storage.set(tokenKey, 'old-token')
let finish!: (response: Response) => void
respond = () =>
new Promise((resolve) => {
finish = resolve
})
const initializing = session.initSkinSiteSession()
await new Promise((resolve) => setImmediate(resolve))
session.signOutSkinSite()
finish(ok({ username: 'Player', jwt: 'late-token' }))
await initializing
assert.equal(storage.has(tokenKey), false)
assert.equal(session.skinSiteStatus.value, 'signed-out')
assert.equal(session.skinSiteUser.value, null)
})
test('a malformed refresh response never replaces the saved token', async () => {
storage.set(tokenKey, 'old-token')
respond = async () => ok({ username: 'Player' })
await session.initSkinSiteSession()
assert.equal(storage.get(tokenKey), 'old-token')
assert.equal(session.skinSiteStatus.value, 'error')
})
test('a failed sign-in attempt does not invalidate a pending startup renewal', async () => {
storage.set(tokenKey, 'old-token')
let finish!: (response: Response) => void
respond = async (url) => {
if (url.endsWith('/refresh'))
return new Promise((resolve) => {
finish = resolve
})
if (url.endsWith('/login'))
return Response.json({ errorMessage: 'Invalid password' }, { status: 401 })
return url.endsWith('/user') ? ok(user) : ok([])
}
const initializing = session.initSkinSiteSession()
await new Promise((resolve) => setImmediate(resolve))
await session.signInSkinSite({ username: 'Player', password: 'wrong', clientId: 'captcha' })
finish(ok({ username: 'Player', jwt: 'fresh-token' }))
await initializing
assert.equal(session.skinSiteStatus.value, 'signed-in')
assert.equal(storage.get(tokenKey), 'fresh-token')
})
test('rejection of an old startup token does not discard a new successful login', async () => {
storage.set(tokenKey, 'expired-token')
let finishRefresh!: (response: Response) => void
let finishLogin!: (response: Response) => void
respond = async (url) => {
if (url.endsWith('/refresh'))
return new Promise((resolve) => {
finishRefresh = resolve
})
if (url.endsWith('/login'))
return new Promise((resolve) => {
finishLogin = resolve
})
return url.endsWith('/user') ? ok(user) : ok([])
}
const initializing = session.initSkinSiteSession()
const signingIn = session.signInSkinSite({
username: 'Player',
password: 'valid',
clientId: 'captcha',
})
await new Promise((resolve) => setImmediate(resolve))
finishRefresh(Response.json({ errorMessage: 'Expired' }, { status: 401 }))
await initializing
finishLogin(ok({ username: 'Player', jwt: 'login-token' }))
await signingIn
assert.equal(session.skinSiteStatus.value, 'signed-in')
assert.equal(storage.get(tokenKey), 'login-token')
})
test('explicit sign-out discards a late successful login', async () => {
let finishLogin!: (response: Response) => void
respond = () =>
new Promise((resolve) => {
finishLogin = resolve
})
const signingIn = session.signInSkinSite({
username: 'Player',
password: 'valid',
clientId: 'captcha',
})
await new Promise((resolve) => setImmediate(resolve))
session.signOutSkinSite()
finishLogin(ok({ username: 'Player', jwt: 'late-login-token' }))
await signingIn
assert.equal(session.skinSiteStatus.value, 'signed-out')
assert.equal(storage.has(tokenKey), false)
})
@@ -65,13 +65,54 @@ function clearSessionState() {
// ---------------------------------------------------------------------------
let initialized: Promise<void> | null = null
let sessionRevision = 0
let loginRevision = 0
let refreshRequest: { token: string; revision: number; promise: Promise<boolean> } | null = null
/** Share renewals and discard results from a session that has since changed. */
function renewSkinSiteToken(): Promise<boolean> {
const token = getSkinSiteToken()
if (!token) return Promise.resolve(false)
const revision = sessionRevision
if (refreshRequest?.token === token && refreshRequest.revision === revision) {
return refreshRequest.promise
}
const request = {
token,
revision,
promise: (async () => {
let result: SkinSiteResponse<{ username: string; jwt: string }>
try {
result = await skinSiteRefresh()
} catch {
return false
}
if (revision !== sessionRevision || getSkinSiteToken() !== token) return false
if (result.success) {
if (typeof result.payload?.jwt !== 'string' || !result.payload.jwt.trim()) return false
setSkinSiteToken(result.payload.jwt)
return true
}
if (result.errorCode === 401 || result.errorCode === 403) invalidateSkinSiteSession()
return false
})(),
}
refreshRequest = request
const clearRequest = () => {
if (refreshRequest === request) refreshRequest = null
}
void request.promise.then(clearRequest, clearRequest)
return request.promise
}
/**
* Resolve the current session from the stored JWT. Safe to call repeatedly;
* Renew the saved JWT on each launcher startup before loading the user.
* Safe to call repeatedly;
* the first call performs the actual work and later ones reuse it.
*/
export function initSkinSiteSession(): Promise<void> {
if (initialized) return initialized
const revision = sessionRevision
initialized = (async () => {
const token = getSkinSiteToken()
if (!token) {
@@ -79,7 +120,13 @@ export function initSkinSiteSession(): Promise<void> {
return
}
status.value = 'checking'
if (!(await renewSkinSiteToken())) {
if (revision === sessionRevision) status.value = 'error'
return
}
if (revision !== sessionRevision) return
const result = await skinSiteCurrentUser()
if (revision !== sessionRevision) return
if (result.success) {
user.value = toUser(result.payload)
status.value = 'signed-in'
@@ -92,11 +139,18 @@ export function initSkinSiteSession(): Promise<void> {
status.value = 'error'
}
})()
.catch(() => {
if (revision === sessionRevision) status.value = 'error'
})
.finally(() => {
if (revision === sessionRevision && status.value === 'error') initialized = null
})
return initialized
}
/** Force a re-check (e.g. after the user signs in from another view). */
export function reloadSkinSiteSession(): Promise<void> {
sessionRevision++
initialized = null
return initSkinSiteSession()
}
@@ -106,10 +160,14 @@ export async function signInSkinSite(payload: {
password: string
clientId: string
}): Promise<SkinSiteResponse<{ username: string; jwt: string }>> {
const attemptRevision = ++loginRevision
const result = await skinSiteLogin(payload)
if (result.success) {
if (result.success && attemptRevision === loginRevision) {
const revision = ++sessionRevision
initialized = null
setSkinSiteToken(result.payload.jwt)
const current = await skinSiteCurrentUser()
if (revision !== sessionRevision) return result
if (current.success) {
user.value = toUser(current.payload)
status.value = 'signed-in'
@@ -122,23 +180,25 @@ export async function signInSkinSite(payload: {
return result
}
export function signOutSkinSite() {
/** Reject an old credential without cancelling a newer explicit login attempt. */
function invalidateSkinSiteSession() {
sessionRevision++
refreshRequest = null
clearSkinSiteToken()
clearSessionState()
status.value = 'signed-out'
initialized = null
}
export function signOutSkinSite() {
loginRevision++
invalidateSkinSiteSession()
}
/** Refresh the JWT; returns true when a new token was stored. */
export async function refreshSkinSiteSession(): Promise<boolean> {
if (status.value !== 'signed-in') return false
const result = await skinSiteRefresh()
if (result.success) {
setSkinSiteToken(result.payload.jwt)
return true
}
if (result.errorCode === 401 || result.errorCode === 403) signOutSkinSite()
return false
return renewSkinSiteToken()
}
// ---------------------------------------------------------------------------
@@ -157,6 +217,9 @@ export function receiveSkinSiteMessage(_event: MessageEvent, _frame: Window | nu
export function openSkinSiteLogin() {}
export function resetSkinSiteSession() {
loginRevision++
sessionRevision++
refreshRequest = null
clearSessionState()
status.value = getSkinSiteToken() ? 'checking' : 'signed-out'
initialized = null
@@ -0,0 +1,96 @@
import assert from 'node:assert/strict'
import test from 'node:test'
import {
hostedDownloadActions,
hostedDownloadState,
runHostedDownloadAction,
runHostedDownloadControl,
} from './hosted-download-controls.ts'
test('only a controllable parent hosted task offers pause, resume and stop', () => {
const bar = {
bar_type: {
type: 'hosted_pack_sync',
instance_id: 'one',
state: 'running' as const,
can_pause: true,
can_cancel: true,
},
}
assert.deepEqual(hostedDownloadActions(bar), ['pause', 'cancel'])
assert.deepEqual(hostedDownloadActions({ bar_type: { ...bar.bar_type, state: 'paused' } }), [
'resume',
'cancel',
])
for (const state of ['finalizing', 'canceling'] as const) {
assert.deepEqual(hostedDownloadActions({ bar_type: { ...bar.bar_type, state } }), [])
}
assert.deepEqual(
hostedDownloadActions({ bar_type: { ...bar.bar_type, type: 'hosted_mod_download' } }),
[],
)
assert.deepEqual(
hostedDownloadActions({ bar_type: { type: 'hosted_pack_sync', instance_id: 'one' } }),
[],
)
})
test('failed and canceled hosted tasks offer direct retry, preserving terminal state', () => {
for (const state of ['failed', 'canceled'] as const) {
const bar = {
bar_type: { type: 'hosted_pack_sync', instance_id: 'one', state, error: 'failure' },
}
assert.deepEqual(hostedDownloadActions(bar), ['retry'])
assert.equal(hostedDownloadState(bar), state)
}
assert.equal(hostedDownloadState({ bar_type: { error: 'old backend failure' } }), 'failed')
})
test('resume refreshes the session before invoking controls; pause and stop need no session', async () => {
const calls: string[] = []
const deps = {
prepareSession: async () => {
calls.push('session')
},
invoke: async (command: string, args: { instanceId: string }) => {
calls.push(`${command}:${args.instanceId}`)
},
}
await runHostedDownloadControl('resume', 'one', deps)
await runHostedDownloadControl('pause', 'one', deps)
await runHostedDownloadControl('cancel', 'one', deps)
assert.deepEqual(calls, [
'session',
'plugin:install|hosted_resume:one',
'plugin:install|hosted_pause:one',
'plugin:install|hosted_cancel:one',
])
})
test('session refresh failures prevent resume', async () => {
await assert.rejects(
runHostedDownloadControl('resume', 'one', {
prepareSession: async () => {
throw new Error('signed out')
},
invoke: async () => {
assert.fail('resume must not run')
},
}),
/signed out/,
)
})
test('retry immediately restarts the existing hosted instance through the manager', async () => {
const calls: string[] = []
await runHostedDownloadAction('retry', 'existing-instance', {
retryHosted: async (instanceId) => {
calls.push(instanceId)
},
control: async () => {
assert.fail('retry must use the full hosted transaction')
},
})
assert.deepEqual(calls, ['existing-instance'])
})
@@ -0,0 +1,45 @@
import type { LoadingBar } from './state.ts'
export type HostedDownloadControl = 'pause' | 'resume' | 'cancel'
export type HostedDownloadAction = HostedDownloadControl | 'retry'
export function runHostedDownloadAction(
action: HostedDownloadAction,
instanceId: string,
operations: {
retryHosted: (instanceId: string) => Promise<void>
control: (action: HostedDownloadControl, instanceId: string) => Promise<void>
},
) {
return action === 'retry'
? operations.retryHosted(instanceId)
: operations.control(action, instanceId)
}
export function hostedDownloadState(bar: LoadingBar) {
return bar.bar_type?.state ?? (bar.bar_type?.error ? 'failed' : 'running')
}
export function hostedDownloadActions(bar: LoadingBar): HostedDownloadAction[] {
const type = bar.bar_type
if (type?.type !== 'hosted_pack_sync' || !type.instance_id) return []
const state = hostedDownloadState(bar)
if (state === 'failed' || state === 'canceled') return ['retry']
if (state !== 'running' && state !== 'paused') return []
const actions: HostedDownloadAction[] = []
if (type.can_pause) actions.push(state === 'paused' ? 'resume' : 'pause')
if (type.can_cancel) actions.push('cancel')
return actions
}
export async function runHostedDownloadControl(
action: HostedDownloadControl,
instanceId: string,
dependencies: {
prepareSession: () => Promise<void>
invoke: (command: string, args: { instanceId: string }) => Promise<void>
},
) {
if (action === 'resume') await dependencies.prepareSession()
await dependencies.invoke(`plugin:install|hosted_${action}`, { instanceId })
}
@@ -3,6 +3,27 @@ import test from 'node:test'
import { createHostedDownloadFailures } from './hosted-download-failures.ts'
test('stopped hosted downloads retain their state and instance for direct retry', () => {
const state = createHostedDownloadFailures()
state.update({
fraction: null,
loader_uuid: 'stopped',
event: {
type: 'hosted_pack_sync',
instance_id: 'existing-instance',
state: 'canceled',
error: 'Stopped by user',
can_pause: false,
can_cancel: false,
},
})
assert.equal(state.values()[0]?.bar_type?.state, 'canceled')
assert.equal(state.values()[0]?.bar_type?.instance_id, 'existing-instance')
state.begin('existing-instance', state.values())
assert.equal(state.has('existing-instance'), false)
assert.equal(state.isRetired('stopped'), true)
})
test('retry clears only its own failure before progress arrives and ignores late old events', () => {
const state = createHostedDownloadFailures()
const failed = (instanceId: string, loader: string, error: string) => ({
@@ -8,6 +8,7 @@ import {
skinSiteUser,
waitForSkinSiteSession,
} from '../composables/skin-site-session.ts'
import { type HostedDownloadControl, runHostedDownloadControl } from './hosted-download-controls.ts'
import { authenticateInstancePlayer } from './instance-player.ts'
export const HOSTED_ACCOUNT_REQUIRED_MESSAGE = '您需要登录正版或皮肤站账号后才能操作'
@@ -146,6 +147,11 @@ export const hostedCreate = async (gameDirRoot?: string | null) => {
}
export const hostedBinding = (instanceId: string) =>
invokeHosted<HostedBinding | null>('plugin:install|hosted_binding', { instanceId })
export const controlHostedDownload = (action: HostedDownloadControl, instanceId: string) =>
runHostedDownloadControl(action, instanceId, {
prepareSession: prepareHostedSession,
invoke: invokeHosted<void>,
})
export const hostedSync = async (instanceId: string) => {
await requireHostedGameAccount()
startHostedPackAttempt(instanceId)
+9 -1
View File
@@ -9,6 +9,9 @@ export interface LoadingBarType {
batch_id?: string
file_name?: string
error?: string | null
state?: 'running' | 'paused' | 'canceling' | 'canceled' | 'failed' | 'finalizing'
can_pause?: boolean
can_cancel?: boolean
type?: string
version?: string
instance_id?: string
@@ -28,7 +31,12 @@ export interface LoadingBar {
}
export type OpeningCommandEvent =
'RunMRPack' | 'InstallServer' | 'InstallVersion' | 'InstallMod' | 'InstallModpack' | string
| 'RunMRPack'
| 'InstallServer'
| 'InstallVersion'
| 'InstallMod'
| 'InstallModpack'
| string
export interface OpeningCommand {
event: OpeningCommandEvent
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+66 -18
View File
@@ -84,7 +84,7 @@
</TagItem>
<Badge
:color="bar.bar_type?.error ? 'red' : 'orange'"
:type="statusLabel(bar.bar_type?.error ? 'failed' : 'running')"
:type="statusLabel(hostedDownloadState(bar))"
/>
</div>
<ProgressBar
@@ -94,16 +94,35 @@
:progress="legacyPercent(bar)"
:max="100"
:label="formatMessage(messages.progress)"
:waiting="!bar.total"
:waiting="!bar.total && hostedDownloadState(bar) !== 'paused'"
:show-progress="Boolean(bar.total)"
/>
<RouterLink
v-else
:to="hostedRetryRoute(bar.bar_type?.instance_id ?? '')"
class="mt-3 inline-block text-brand hover:underline"
<div
v-if="hostedDownloadActions(bar).length"
class="mt-3 flex flex-wrap items-center gap-2"
>
{{ formatMessage(messages.hostedRetry) }}
</RouterLink>
<ButtonStyled
v-for="action in hostedDownloadActions(bar)"
:key="action"
:color="action === 'retry' ? 'brand' : action === 'cancel' ? 'red' : 'standard'"
:type="action === 'retry' ? 'standard' : 'outlined'"
size="small"
>
<button
:disabled="busy.has(hostedBusyKey(bar, action))"
@click="hostedAction(bar, action)"
>
{{ formatMessage(hostedActionMessages[action]) }}
</button>
</ButtonStyled>
<RouterLink
v-if="bar.bar_type?.error"
:to="hostedRetryRoute(bar.bar_type.instance_id ?? '')"
class="text-brand hover:underline"
>
{{ formatMessage(messages.openInstance) }}
</RouterLink>
</div>
</Card>
<Card
@@ -471,7 +490,14 @@ import { useRoute, useRouter } from 'vue-router'
import MissingModpackContentModal from '@/components/ui/modal/MissingModpackContentModal.vue'
import { listPendingCurseForgeManualDownloads } from '@/helpers/curseforge'
import type { CurseForgeManualDownloadItem } from '@/helpers/curseforge-manual'
import {
type HostedDownloadAction,
hostedDownloadActions,
hostedDownloadState,
runHostedDownloadAction,
} from '@/helpers/hosted-download-controls'
import { hostedRetryRoute } from '@/helpers/hosted-install-retry'
import { controlHostedDownload } from '@/helpers/hosted-packs'
import {
download_job_support_details,
type InstallJobSnapshot,
@@ -517,10 +543,6 @@ const focusedJobId = computed(() => focusedDownloadJobId(route.query.job))
const focusState = ref(createDownloadFocusState(focusedJobId.value))
const messages = defineMessages({
hostedRetry: {
id: 'app.hosted-packs.progress.retry',
defaultMessage: 'Return to the instance to retry',
},
newDownload: { id: 'app.downloads.new-download', defaultMessage: 'New download' },
inProgress: { id: 'app.downloads.in-progress', defaultMessage: 'In progress' },
history: { id: 'app.downloads.history', defaultMessage: 'History' },
@@ -653,7 +675,15 @@ const messages = defineMessages({
unknownPhase: { id: 'app.downloads.phase.unknown', defaultMessage: 'Working' },
})
const hostedActionMessages = defineMessages({
pause: { id: 'app.hosted-packs.progress.pause', defaultMessage: 'Pause' },
resume: { id: 'app.hosted-packs.progress.resume', defaultMessage: 'Resume' },
cancel: { id: 'app.hosted-packs.progress.stop', defaultMessage: 'Stop' },
retry: { id: 'app.downloads.retry', defaultMessage: 'Retry' },
})
const statusMessages = defineMessages({
paused: { id: 'app.downloads.status.paused', defaultMessage: 'Paused' },
queued: { id: 'app.downloads.status.queued', defaultMessage: 'Queued' },
running: { id: 'app.downloads.status.running', defaultMessage: 'Running' },
canceling: { id: 'app.downloads.status.canceling', defaultMessage: 'Canceling' },
@@ -1262,6 +1292,7 @@ function toggleExpanded(jobId: string) {
}
async function withBusy(jobId: string, action: () => Promise<void>) {
if (busy.value.has(jobId)) return
busy.value = new Set([...busy.value, jobId])
try {
await action()
@@ -1278,6 +1309,21 @@ async function cancel(job: InstallJobSnapshot) {
await withBusy(job.job_id, () => manager.cancel(job.job_id))
}
function hostedBusyKey(bar: LoadingBar, action: HostedDownloadAction) {
return `hosted-${action === 'retry' ? 'retry' : 'control'}:${bar.bar_type?.instance_id}`
}
async function hostedAction(bar: LoadingBar, action: HostedDownloadAction) {
const instanceId = bar.bar_type?.instance_id
if (!instanceId || !hostedDownloadActions(bar).includes(action)) return
await withBusy(hostedBusyKey(bar, action), () =>
runHostedDownloadAction(action, instanceId, {
retryHosted: manager.retryHosted,
control: controlHostedDownload,
}),
)
}
async function retry(job: InstallJobSnapshot) {
await withBusy(job.job_id, () => manager.retry(job.job_id))
}
@@ -1293,12 +1339,14 @@ async function resolveMissing(job: InstallJobSnapshot) {
(item) =>
item.status === 'skipped' && item.manual_url && item.project_id && item.version_id,
)
.map((item): CurseForgeManualDownloadItem => ({
projectId: Number(item.project_id),
fileId: Number(item.version_id),
fileName: item.name,
websiteUrl: item.manual_url ?? undefined,
}))
.map(
(item): CurseForgeManualDownloadItem => ({
projectId: Number(item.project_id),
fileId: Number(item.version_id),
fileName: item.name,
websiteUrl: item.manual_url ?? undefined,
}),
)
const instanceId = job.instance_id
const hasGeneralMissingItems = job.items.some((item) => item.status === 'failed')
if (instanceId && (job.provider === 'curse_forge' || fallbackCurseForgeItems.length > 0)) {
+1 -1
View File
@@ -1,7 +1,7 @@
[package]
name = "theseus_gui"
# The actual version is set by the theseus-build workflow on tagging
version = "1.0.2-beta7"
version = "1.0.2-beta11"
edition.workspace = true
description = "Axolotl Launcher is a cross-platform Minecraft launcher"
homepage = "https://www.ghs.red"
+3
View File
@@ -380,6 +380,9 @@ fn main() {
"hosted_create",
"hosted_binding",
"hosted_sync",
"hosted_pause",
"hosted_resume",
"hosted_cancel",
"hosted_instance_mode",
"hosted_set_instance_mode",
"install_pack_to_existing_instance",
+18
View File
@@ -20,6 +20,9 @@ pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
hosted_create,
hosted_binding,
hosted_sync,
hosted_pause,
hosted_resume,
hosted_cancel,
hosted_instance_mode,
hosted_set_instance_mode,
install_get_modpack_preview,
@@ -105,6 +108,21 @@ pub async fn hosted_sync(
Ok(theseus::pack::hosted::synchronize(&instance_id).await?)
}
#[tauri::command]
pub async fn hosted_pause(instance_id: String) -> Result<()> {
Ok(theseus::pack::hosted::pause(&instance_id).await?)
}
#[tauri::command]
pub async fn hosted_resume(instance_id: String) -> Result<()> {
Ok(theseus::pack::hosted::resume(&instance_id).await?)
}
#[tauri::command]
pub async fn hosted_cancel(instance_id: String) -> Result<()> {
Ok(theseus::pack::hosted::cancel(&instance_id).await?)
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstallCreateInstanceRequest {